@rogieking/figui3 9.4.5 → 9.4.7
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/.cursor/skills/fig-lab/components.md +1 -0
- package/.cursor/skills/fig-lab/reference.md +2 -0
- package/.cursor/skills/figui3/components.md +7 -0
- package/.cursor/skills/figui3/reference.md +1 -0
- package/CHANGELOG.md +22 -0
- package/README.md +4 -1
- package/components.css +318 -240
- package/dist/components.css +1 -1
- package/dist/fig-lab.js +1 -1
- package/dist/fig.css +1 -1
- package/dist/fig.js +4 -4
- package/fig-lab.js +5 -4
- package/fig.js +84 -8
- package/package.json +1 -1
package/dist/fig-lab.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function T(j,q){if(!customElements.get(j))customElements.define(j,q)}function L(j,q){return j.hasAttribute(q)&&j.getAttribute(q)!=="false"}var u="http://www.w3.org/2000/svg";function m(j,q){let J=(Z)=>{if(Z===null||Z===void 0||Z===!1)return;if(Array.isArray(Z)){Z.forEach(J);return}j.append(Z instanceof Node?Z:String(Z))};return J(q),j}function p(j,q={}){for(let[J,Z]of Object.entries(q)){if(Z===null||Z===void 0||Z===!1)continue;if(J==="className")if(j.namespaceURI===u)j.setAttribute("class",String(Z));else j.className=String(Z);else if(Z===!0)j.setAttribute(J,"");else j.setAttribute(J,String(Z))}return j}function d(j,q,J){let Z=document.createElement(j);return p(Z,q),m(Z,J)}function x(j,q,J){let Z=document.createElementNS(u,j);return p(Z,q),m(Z,J)}function a(j,q,J){let Z=Number(q),$=Number(J),z=Number.isFinite(Z)?Math.max(0,Math.min(1,Z)):Number.isFinite($)?Math.max(0,Math.min(100,$))/100:1,Q=Number.isFinite($)?Math.max(0,Math.min(100,$)):Math.round(z*100);return{color:j,alpha:z,opacity:Q}}class v extends HTMLElement{}T("fig-ai-prompt",v);class h extends HTMLElement{}T("fig-ai-context",h);class g extends HTMLElement{}T("fig-chat-message",g);class c extends HTMLElement{#q=null;#$=null;#Q=null;#_=null;#z=null;#k=null;#U=this.#W.bind(this);#Z=this.#K.bind(this);#M=this.#Y.bind(this);static get observedAttributes(){return["src","name","value","removable","disabled"]}connectedCallback(){if(!this.#$)this.#J();this.#z.removeEventListener("click",this.#U),this.#z.addEventListener("click",this.#U),this.#X(),this.#N()}disconnectedCallback(){this.#z?.removeEventListener("click",this.#U),this.#O()}attributeChangedCallback(j,q,J){if(q===J||!this.#$)return;this.#N()}#J(){this.#q=document.createElement("fig-tooltip"),this.#q.className="fig-attachment-tooltip",this.#$=document.createElement("fig-image"),this.#$.setAttribute("aspect-ratio","1/1"),this.#$.setAttribute("fit","cover"),this.#$.setAttribute("full",""),this.#Q=document.createElement("span"),this.#Q.className="fig-attachment-fallback",this.#Q.setAttribute("aria-hidden","true"),this.#_=document.createElement("fig-tooltip"),this.#_.className="fig-attachment-remove-tooltip",this.#_.setAttribute("text","Remove attachment"),this.#z=document.createElement("fig-button"),this.#z.className="fig-attachment-remove",this.#z.setAttribute("variant","overlay"),this.#z.setAttribute("size","small"),this.#z.setAttribute("icon","");let j=document.createElement("fig-icon");j.setAttribute("name","close"),j.setAttribute("size","small"),this.#z.append(j),this.#_.append(this.#z),this.#$.append(this.#Q),this.#q.append(this.#$),this.replaceChildren(this.#q,this.#_),this.#z.addEventListener("click",this.#U),this.#X()}#X(){let j=this.#$?.mediaEl;if(!j||j===this.#k)return;this.#O(),this.#k=j,this.#k.addEventListener("load",this.#Z),this.#k.addEventListener("error",this.#M)}#O(){if(!this.#k)return;this.#k.removeEventListener("load",this.#Z),this.#k.removeEventListener("error",this.#M),this.#k=null}#N(){let j=this.getAttribute("src")||"",q=this.getAttribute("name")||"Attachment",J=!this.hasAttribute("removable")||L(this,"removable"),Z=L(this,"disabled");if(this.#q.setAttribute("text",q),this.#$.setAttribute("alt",q),j)this.#$.setAttribute("src",j);else this.#$.removeAttribute("src");if(this.#X(),this.#Q.textContent=this.#B(q),this.#z.hidden=!J,this.#z.toggleAttribute("disabled",Z),this.#z.setAttribute("aria-label",`Remove ${q}`),this.toggleAttribute("data-fallback",!j),Z)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled")}#B(j){let q=j.split(/[\\/]/).pop()||"",J=q.lastIndexOf(".");return(J>0&&J<q.length-1?q.slice(J+1).toUpperCase():"FILE").slice(0,4)}#K(){if(this.getAttribute("src"))this.removeAttribute("data-fallback")}#Y(){this.setAttribute("data-fallback","")}#W(j){if(j.stopPropagation(),L(this,"disabled")||this.hasAttribute("removable")&&!L(this,"removable"))return;this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,cancelable:!0,composed:!0,detail:{value:this.getAttribute("value"),name:this.getAttribute("name")||"",src:this.getAttribute("src")||"",attachment:this}}))}}T("fig-attachment",c);class s extends HTMLElement{#q=null;connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","list"),this.setAttribute("data-generated-role","");if(this.#$(),!this.#q)this.#q=new MutationObserver(()=>this.#$()),this.#q.observe(this,{childList:!0})}disconnectedCallback(){this.#q?.disconnect(),this.#q=null}#$(){for(let j of this.querySelectorAll(":scope > fig-attachment"))if(!j.hasAttribute("role"))j.setAttribute("role","listitem"),j.setAttribute("data-generated-role","")}}T("fig-attachments",s);class o extends HTMLElement{static observedAttributes=["url","filename","label","accepts","variant","disabled","full"];#q=null;#$=null;#Q=null;#_=null;#z=null;#k=null;#U=null;#Z=[];#M=0;#J=0;get files(){return this.#q?.files??null}get value(){return this.#q?.value??""}connectedCallback(){if(!this.#q)this.#X();this.#O(),this.#N(),this.#A()}disconnectedCallback(){if(this.#F(),this.#z?.disconnect(),this.#z=null,this.#J)cancelAnimationFrame(this.#J);this.#J=0}attributeChangedCallback(j,q,J){if(q===J||!this.#q)return;if(this.#N(),j==="url")this.#A()}clear(){this.removeAttribute("url"),this.removeAttribute("filename"),this.#q?.clear()}#X(){this.#$=document.createElement("div"),this.#$.className="fig-input-audio-waveform",this.#$.setAttribute("aria-hidden","true"),this.#Q=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.#Q.setAttribute("aria-hidden","true"),this.#Q.setAttribute("preserveAspectRatio","none"),this.#_=document.createElementNS("http://www.w3.org/2000/svg","path"),this.#Q.appendChild(this.#_),this.#$.appendChild(this.#Q),this.#q=document.createElement("fig-input-file"),this.#q.className="fig-input-audio-file",this.#q.addEventListener("input",this.#f),this.#q.addEventListener("change",this.#f),this.replaceChildren(this.#$,this.#q),this.#O()}#O(){if(this.#z||!this.#Q)return;this.#z=new ResizeObserver(()=>this.#L()),this.#z.observe(this.#Q)}#N(){let j=["url","filename","variant"];for(let q of j){let J=this.getAttribute(q);if(J===null)this.#q.removeAttribute(q);else this.#q.setAttribute(q,J)}this.#q.setAttribute("accepts",this.getAttribute("accepts")||"audio/*"),this.#q.setAttribute("label",this.getAttribute("label")||"Upload audio"),this.#B(this.#q,"disabled",this.#Y()),this.#B(this.#q,"full",this.#K("full")),this.#G(),this.#W()}#B(j,q,J){if(J)j.setAttribute(q,"");else j.removeAttribute(q)}#K(j){return this.hasAttribute(j)&&this.getAttribute(j)!=="false"}#Y(){return this.#K("disabled")}#W(){let j=this.#q?.files&&this.#q.files.length>0||!!this.getAttribute("url");this.toggleAttribute("data-has-audio",j),this.#G()}#G(){let j=this.#q?.querySelector('input[type="file"]');if(j)j.setAttribute("aria-label",this.hasAttribute("data-has-audio")?"Replace audio":"Upload audio");this.#q?.querySelector(".fig-input-file-clear")?.setAttribute("aria-label","Remove audio")}#f=(j)=>{if(j.stopPropagation(),j.target!==this.#q)return;let q=j.detail||{files:this.#q.files};if(j.type==="input"){let J=this.#q.files?.[0]||null;if(J){let Z=this.hasAttribute("url");if(Z)this.removeAttribute("url");if(this.#W(),!Z)this.#V(()=>J.arrayBuffer())}else{if(q.cleared)this.removeAttribute("url"),this.removeAttribute("filename");this.#H(),this.#W()}this.#G()}this.dispatchEvent(new CustomEvent(j.type,{bubbles:!0,composed:!0,detail:q}))};#A(){let j=this.#q?.files?.[0];if(j){this.#W(),this.#V(()=>j.arrayBuffer());return}let q=this.getAttribute("url");if(this.#W(),!q){this.#H();return}this.#V(async(J)=>{let Z=await fetch(q,{signal:J});if(!Z.ok)throw Error(`Audio request failed: ${Z.status}`);return Z.arrayBuffer()})}async#V(j){this.#F();let q=++this.#M,J=new AbortController;this.#k=J,this.setAttribute("data-waveform-state","loading"),this.setAttribute("aria-busy","true"),this.#Z=[],this.#L();let Z=null;try{let $=await j(J.signal);if(q!==this.#M||!this.isConnected)return;let z=window.AudioContext||window.webkitAudioContext;if(!z)throw Error("Web Audio is unavailable");Z=new z,this.#U=Z;let Q=await Z.decodeAudioData($);if(q!==this.#M||!this.isConnected)return;this.#Z=this.#P(Q),this.setAttribute("data-waveform-state","ready"),this.#L()}catch($){if(q!==this.#M||$?.name==="AbortError")return;this.#Z=Array(256).fill(0),this.setAttribute("data-waveform-state","unavailable"),this.#L()}finally{if(Z)try{await Z.close()}catch{}if(this.#U===Z)this.#U=null;if(this.#k===J)this.#k=null;if(q===this.#M)this.removeAttribute("aria-busy")}}#P(j){let J=Array(256).fill(0),Z=j.numberOfChannels,$=j.length,z=Math.max(1,Math.ceil($/500000)),Q=0;for(let W=0;W<Z;W+=1){let U=j.getChannelData(W);for(let M=0;M<256;M+=1){let Y=Math.floor(M/256*$),k=Math.max(Y+1,Math.floor((M+1)/256*$)),_=J[M];for(let B=Y;B<k;B+=z){let N=Math.abs(U[B]||0);if(Number.isFinite(N))_=Math.max(_,N)}J[M]=_,Q=Math.max(Q,_)}}if(!Number.isFinite(Q)||Q<=0)return J.fill(0);return J.map((W)=>{let U=Math.sqrt(W/Q);return Number.isFinite(U)?U:0})}#H(){this.#F(),this.#Z=[],this.removeAttribute("data-waveform-state"),this.removeAttribute("aria-busy"),this.#L()}#F(){if(this.#M+=1,this.#k?.abort(),this.#k=null,this.#U){try{this.#U.close()}catch{}this.#U=null}}#L(){if(this.#J)return;this.#J=requestAnimationFrame(()=>{this.#J=0,this.#w()})}#w(){if(!this.#Q||!this.#_)return;let j=this.#Q.getBoundingClientRect(),q=Math.max(1,Math.round(j.width)),J=Math.max(1,Math.round(j.height));if(this.#Q.setAttribute("viewBox",`0 0 ${q} ${J}`),this.#Z.length===0){this.#_.setAttribute("d","");return}let Z=Math.min(this.#Z.length,Math.max(12,Math.floor(q/4))),$=q/Z,z=Number.parseFloat(getComputedStyle(this).getPropertyValue("--fig-input-audio-waveform-stroke-width")),Q=Number.isFinite(z)&&z>0?z:2,W=Math.max(0.5,Math.min(Q,$*0.75)),U=W/2,M=J/2,Y=Math.max(2,J-12),k=[];for(let _=0;_<Z;_+=1){let B=Math.min(this.#Z.length-1,Math.floor(_/Z*this.#Z.length)),N=Math.max(W,this.#Z[B]*Y),G=(_+0.5)*$,X=M-N/2,O=M+N/2,V=G-U,K=G+U;k.push(`M ${G} ${X} Q ${K} ${X} ${K} ${X+U} V ${O-U} Q ${K} ${O} ${G} ${O} Q ${V} ${O} ${V} ${O-U} V ${X+U} Q ${V} ${X} ${G} ${X} Z`)}this.#_.setAttribute("d",k.join(" "))}}T("fig-input-audio",o);class F extends HTMLElement{static#q=33;static#$=60;static#Q=0.55;static#_=1.5;static#z=80;static#k=4;static#U="fig-input-wheel-dragging";#Z=null;#M=null;#J=null;#X=null;#O=null;#N=null;#B=null;#K=0;#Y=0;#W=0;#G=0;#f=0;#A=null;#V=!1;#P=null;#H=0;#F=0;#L=!1;#w=null;#x=0;#C=null;#R=0;#u=0;#v=this.#Yj.bind(this);#S=this.#Fj.bind(this);#p=this.#_j.bind(this);#g=this.#Kj.bind(this);#D=this.#Xj.bind(this);static get observedAttributes(){return["value","disabled","step","min","max","spin"]}connectedCallback(){if(!this.#Z)this.#jj();if(this.#$j(),this.#Zj(),this.#Uj(),this.#A?.disconnect(),globalThis.ResizeObserver)this.#A=new ResizeObserver((j)=>{let q=j.at(-1)?.contentRect;if(q)this.#o(q.width,q.height)}),this.#A.observe(this);this.#b()}disconnectedCallback(){if(this.#A?.disconnect(),this.#W)cancelAnimationFrame(this.#W);this.#W=0,this.#e(),this.#Vj(),this.#n()}attributeChangedCallback(j,q,J){if(q===J||!this.#Z)return;if(j==="disabled")this.#$j();if(j==="value"&&!this.#V)this.#Zj();if(j==="step")this.#i(),this.#b();if(j==="spin")this.#b();if(j==="min"||j==="max")this.#I(this.#j())}#jj(){if(this.#Z=this,this.#M=this,this.#J=this,this.setAttribute("role","spinbutton"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Value");this.setAttribute("tabindex","0");let j=x("svg",{className:"fig-input-wheel-svg","aria-hidden":"true"}),q=d("div",{className:"fig-input-wheel-handle"});this.#X=j,this.replaceChildren(j,q);let J=document.createElement("div");J.setAttribute("aria-hidden","true"),J.style.cssText="position:absolute;visibility:hidden;pointer-events:none;left:0;top:0";let Z=document.createElement("div");Z.style.height="var(--fig-input-wheel-tick-height)";let $=document.createElement("div");$.style.height="var(--fig-input-wheel-tick-height-min)";let z=document.createElement("div");z.style.width="var(--fig-input-wheel-tick-width)";let Q=document.createElement("div");Q.style.width="var(--fig-input-wheel-tick-width-min)",J.append(Z,$,z,Q),this.append(J),this.#B={maxEl:Z,minEl:$,maxWidthEl:z,minWidthEl:Q},this.#qj()}#qj(){if(!this.#X||this.#O)return;this.#O=x("path",{className:"fig-input-wheel-tick"}),this.#X.append(this.#O)}#h(){if(this.#N)return this.#N;return this.#N={maxH:this.#B?.maxEl.getBoundingClientRect().height||8,minH:this.#B?.minEl.getBoundingClientRect().height||4,maxW:this.#B?.maxWidthEl.getBoundingClientRect().width||2,minW:this.#B?.minWidthEl.getBoundingClientRect().width||1},this.#N}#T(){if(this.hasAttribute("step")){let j=Number(this.getAttribute("step"));if(j>0)return j}return 1}#j(){let j=Number(this.getAttribute("value")??0);return Number.isFinite(j)?j:0}#s(j){if(!this.hasAttribute(j))return null;let q=this.getAttribute(j);if(q===null||q.trim()==="")return null;let J=Number(q);return Number.isFinite(J)?J:null}#E(){return this.#s("min")}#m(){return this.#s("max")}#Jj(j,q){if(q===null||q===void 0||q===""){this.removeAttribute(j);return}let J=Number(q);if(!Number.isFinite(J)){this.removeAttribute(j);return}this.setAttribute(j,String(J))}#r(j){let q=j,J=this.#E(),Z=this.#m();if(J!==null)q=Math.max(J,q);if(Z!==null)q=Math.min(Z,q);return q}#c(j){let q=this.#T();if(q<=0)return j;let J=this.#E()??0,Z=Math.round((j-J)/q)*q+J;return Number(Z.toPrecision(15))}#I(j,{snap:q=!1,emit:J=null}={}){let Z=q?this.#c(j):j;Z=this.#r(Z);let $=String(Z);if(this.getAttribute("value")!==$)this.setAttribute("value",$);if(this.#i(Z),this.#b(),J)this.dispatchEvent(new CustomEvent(J,{detail:Z,bubbles:!0,cancelable:!0,composed:!0}))}#Zj(){let j=this.#j(),q=this.#r(j);if(q!==j||this.getAttribute("value")!==String(q)){this.#I(q);return}this.#i(j),this.#b()}#i(j=this.#j()){if(!this.#J)return;let q=this.#E(),J=this.#m();if(this.#J.setAttribute("aria-valuenow",String(j)),this.#J.setAttribute("aria-valuetext",String(j)),q===null)this.#J.removeAttribute("aria-valuemin");else this.#J.setAttribute("aria-valuemin",String(q));if(J===null)this.#J.removeAttribute("aria-valuemax");else this.#J.setAttribute("aria-valuemax",String(J))}#$j(){let j=L(this,"disabled");if(!this.#J)return;if(j){if(this.#V)this.#n();this.#e(),this.setAttribute("aria-disabled","true"),this.#J.setAttribute("tabindex","-1"),this.#J.setAttribute("aria-disabled","true")}else this.removeAttribute("aria-disabled"),this.#J.setAttribute("tabindex","0"),this.#J.removeAttribute("aria-disabled")}#o(j,q){if(!this.#X||j<1||q<1)return;if(j===this.#K&&q===this.#Y)return;this.#K=j,this.#Y=q,this.#N=null,this.#X.setAttribute("viewBox",`0 0 ${j} ${q}`),this.#X.setAttribute("width",String(j)),this.#X.setAttribute("height",String(q)),this.#b()}#b(){if(this.#W)return;this.#W=requestAnimationFrame(()=>{if(!this.isConnected){this.#W=0;return}if(this.#K<1||this.#Y<1){let j=this.#J?.getBoundingClientRect();if(j)this.#o(j.width,j.height)}this.#kj(),this.#W=0})}#kj(){if(!this.#O)return;let j=this.#K,q=this.#Y;if(j<1||q<1)return;let J=this.getAttribute("spin")==="false"?this.#E()??0:this.#w??this.#j(),Z=360/F.#q,$=this.#T(),z=this.#E()??0,Q=(J-z)/$*Z,W=F.#Q,U=j/2,M=q/2,{maxH:Y,minH:k,maxW:_,minW:B}=this.#h(),N=F.#$,G=Math.max(j/2,1),X=G*0.84,O=[];for(let V=0;V<F.#q;V+=1){let K=Q+V*Z;if(K=((K+180)%360+360)%360-180,K<-N||K>=N)continue;let w=K*Math.PI/180,f=U+X*Math.sin(w)/(1-W*Math.cos(w)),A=Math.min(1,Math.abs(f-U)/Math.max(G,1)),S=Math.cos(A*Math.PI*0.5),R=k+(Y-k)*S,D=B+(_-B)*S,C=R/2,E=D/2,I=M-C,H=M+C,b=f-E,y=f+E;O.push(`M ${f} ${I} Q ${y} ${I} ${y} ${I+E} V ${H-E} Q ${y} ${H} ${f} ${H} Q ${b} ${H} ${b} ${H-E} V ${I+E} Q ${b} ${I} ${f} ${I} Z`)}this.#O.setAttribute("d",O.join(" "))}#Uj(){this.#Z?.addEventListener("pointerdown",this.#v),this.#J?.addEventListener("wheel",this.#g,{passive:!1}),this.#J?.addEventListener("keydown",this.#D)}#Vj(){this.#Z?.removeEventListener("pointerdown",this.#v),this.#J?.removeEventListener("wheel",this.#g),this.#J?.removeEventListener("keydown",this.#D),window.removeEventListener("pointermove",this.#S),window.removeEventListener("pointerup",this.#p),window.removeEventListener("pointercancel",this.#p)}#Yj(j){if(L(this,"disabled"))return;if(j.button!==0)return;if(j.preventDefault(),!this.beginScrub(j))return;this.#Z?.setPointerCapture?.(j.pointerId),window.addEventListener("pointermove",this.#S),window.addEventListener("pointerup",this.#p),window.addEventListener("pointercancel",this.#p)}beginScrub(j={}){if(L(this,"disabled"))return!1;let q=typeof j==="number"?j:Number(j?.clientX??j?.x);if(!Number.isFinite(q))return!1;this.#e(),this.#V=!0,this.#P=j&&typeof j==="object"&&j.pointerId!==void 0?j.pointerId:null,this.#H=q;let J=j&&typeof j==="object"?Number(j.startValue):Number.NaN;return this.#F=Number.isFinite(J)?this.#r(J):this.#j(),this.#L=!1,this.#wj(q),this.#Lj(),this.setAttribute("data-fig-input-wheel-active",""),document.body.classList.remove(F.#U),this.focus(),!0}updateScrub(j,q){if(!this.#V)return this.#j();let J=typeof j==="number"?j:Number(j?.clientX??j?.x);if(!Number.isFinite(J))return this.#j();let Z=q??(typeof j==="object"&&j?.shiftKey?10:1);return this.#Wj(J,Z),this.#j()}endScrub(j=!0){if(!this.#V)return this.#j();if(j&&this.#j()!==this.#F)this.#I(this.#j(),{snap:!0,emit:"change"});return this.#n(),this.#j()}#Fj(j){if(!this.#V)return;if(this.#P!==null&&j.pointerId!==this.#P)return;this.updateScrub(j)}#Wj(j,q=1){if(!this.#L&&Math.abs(j-this.#H)>=F.#k)this.#L=!0,document.body.classList.add(F.#U);let J=this.#J?.clientWidth||1,Z=F.#q*(F.#$*2/360),$=this.#T()*Z,z=(j-this.#H)*($/J)*q,Q=this.#w??this.#F,W=this.#r(this.#F+z);this.#Aj(j,q,W!==Q),this.#w=W,this.#I(W,{snap:!0,emit:"input"}),this.#fj(j)}#_j(j){if(!this.#V)return;if(this.#P!==null&&j.pointerId!==this.#P)return;this.endScrub()}#n(){this.#V=!1,this.#P=null,this.#L=!1,this.#w=null,this.removeAttribute("data-fig-input-wheel-active"),document.body.classList.remove(F.#U),this.#Gj(),this.#Bj(),window.removeEventListener("pointermove",this.#S),window.removeEventListener("pointerup",this.#p),window.removeEventListener("pointercancel",this.#p),this.#b()}#Lj(){this.#Bj(),this.#x=this.#zj("--fig-input-wheel-handle-drag-max")}#zj(j){let q=getComputedStyle(this).getPropertyValue(j).trim();if(q.includes("var(")||!q.endsWith("px")){let Z=document.createElement("div");Object.assign(Z.style,{position:"absolute",visibility:"hidden",pointerEvents:"none",width:`var(${j})`}),this.appendChild(Z),q=getComputedStyle(Z).width,Z.remove()}let J=Number.parseFloat(q);return Number.isFinite(J)?Math.max(0,J):0}#fj(j){if(!this.#x){this.#Mj();return}let q=j-this.#H;if(!q){this.#Mj();return}let J=this.#x*Math.tanh(q/Math.max(1,this.#x*3));this.style.setProperty("--fig-input-wheel-handle-drag-offset",`${J}px`)}#Bj(){this.#Mj(),this.#x=0}#Mj(){this.style.removeProperty("--fig-input-wheel-handle-drag-offset")}#wj(j){this.#Gj(),this.#C=j,this.#R=performance.now()}#Aj(j,q,J){let Z=performance.now(),$=Z-this.#R,z=this.#C===null?0:Math.abs(j-this.#C);this.#C=j,this.#R=Z;let Q=$>0?z/$*Math.max(1,Math.abs(q)):0;if(!J||Q<F.#_){this.#t();return}this.toggleAttribute("data-fig-input-wheel-fast",!0),clearTimeout(this.#u),this.#u=window.setTimeout(()=>{this.#t()},F.#z)}#Gj(){this.#C=null,this.#R=0,this.#t()}#t(){clearTimeout(this.#u),this.#u=0,this.removeAttribute("data-fig-input-wheel-fast")}#Kj(j){if(L(this,"disabled"))return;j.preventDefault();let q=j.deltaY===0?Math.sign(j.deltaX):Math.sign(j.deltaY);if(!q)return;let J=j.shiftKey?10:1;this.#I(this.#j()+this.#T()*J*q,{snap:!0,emit:"input"}),this.#I(this.#j(),{emit:"change"})}#Xj(j){if(L(this,"disabled"))return;if(j.target instanceof Element&&j.target.closest("fig-input-number"))return;if(j.key==="Home"){let z=this.#E();if(z===null)return;j.preventDefault(),this.#I(z,{snap:!0,emit:"input"}),this.#I(this.#j(),{emit:"change"});return}if(j.key==="End"){let z=this.#m();if(z===null)return;j.preventDefault(),this.#I(z,{snap:!0,emit:"input"}),this.#I(this.#j(),{emit:"change"});return}if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(j.key))return;j.preventDefault();let J=j.key==="ArrowRight"||j.key==="ArrowUp"?1:-1,Z=j.shiftKey?10:1,$=this.#j();this.#I($+this.#T()*Z*J,{snap:!0,emit:"input"}),this.#Qj($,this.#j(),J,Z),this.#I(this.#j(),{emit:"change"})}#Qj(j,q,J,Z,$=!0){if(j===q||globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches){this.#e();return}if(this.#G)cancelAnimationFrame(this.#G),this.#G=0;clearTimeout(this.#f),this.#f=0,this.removeAttribute("data-fig-input-wheel-keyboard-settling");let z=this.#w??j,Q=Number.parseFloat(this.style.getPropertyValue("--fig-input-wheel-handle-drag-offset"))||0,W=Z>1?120:90,U=performance.now(),M=$;this.setAttribute("data-fig-input-wheel-keyboard-moving","");let Y=(k)=>{let _=Math.min(1,(k-U)/W);if(this.#w=z+(q-z)*_,M){let B=Math.sin(_*Math.PI/2),N=Q+(J*4-Q)*B;this.style.setProperty("--fig-input-wheel-handle-drag-offset",`${N}px`)}if(this.#kj(),_<1){this.#G=requestAnimationFrame(Y);return}this.#G=0,this.#w=null,this.removeAttribute("data-fig-input-wheel-keyboard-moving"),this.setAttribute("data-fig-input-wheel-keyboard-settling",""),this.style.removeProperty("--fig-input-wheel-handle-drag-offset"),this.#f=window.setTimeout(()=>{this.removeAttribute("data-fig-input-wheel-keyboard-settling"),this.#f=0},140),this.#b()};this.#G=requestAnimationFrame(Y)}#e(){if(this.#G)cancelAnimationFrame(this.#G),this.#G=0;if(clearTimeout(this.#f),this.#f=0,this.#w=null,this.removeAttribute("data-fig-input-wheel-keyboard-moving"),this.removeAttribute("data-fig-input-wheel-keyboard-settling"),this.style.removeProperty("--fig-input-wheel-handle-drag-offset"),this.isConnected)this.#b()}get value(){return this.getAttribute("value")??"0"}set value(j){if(j===null||j===void 0||j===""){this.#I(0);return}let q=Number(j);this.#I(Number.isFinite(q)?q:0)}spinTo(j,{animateHandle:q=!1}={}){let J=this.#j();this.value=j;let Z=this.#j();if(this.getAttribute("spin")==="false")return this.#e(),Z;let $=Math.sign(Z-J);return this.#Qj(J,Z,$,Math.abs(Z-J)>this.#T()?10:1,q),Z}get min(){return this.#E()}set min(j){this.#Jj("min",j)}get max(){return this.#m()}set max(j){this.#Jj("max",j)}get step(){return this.#T()}focus(j){HTMLElement.prototype.focus.call(this,j)}}T("fig-input-wheel",F);class l extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping","precision"];#q=50;#$=50;#Q=75;#_=75;#z=0;#k=!1;#U=0;#Z=null;#M=null;#J=null;#X=null;#O=null;#N=null;#B=null;#K=null;#Y=null;#W=!1;#G=!1;#f=!1;#A=!1;#V=null;#P="";#H="";#F=null;#L=null;#w=null;#x="";#C="";#R=null;#u=null;#v=null;get#S(){return this.getAttribute("type")||"point"}get#p(){return this.#S==="point-radius"||this.#S==="point-radius-angle"}get#g(){return this.#S==="point-radius-angle"}get#D(){return this.#S==="point-point"}get#jj(){return this.#S==="point-radius-angle"||this.#S==="point-point"}get#qj(){let j=this.getAttribute("tooltips");return j===null||j!=="false"}get#h(){let j=this.getAttribute("snapping");if(j===null)return"false";let q=j.trim().toLowerCase();if(q==="modifier")return"modifier";if(q===""||q==="true")return"true";return"false"}get#T(){let j=Number(this.getAttribute("precision")??2);if(!Number.isFinite(j))return 2;return Math.max(0,Math.min(8,Math.trunc(j)))}#j(j){let q=10**this.#T,J=Math.round(j*q)/q;return Object.is(J,-0)?0:J}#s(){let j=this.getAttribute("precision");for(let q of[this.#Z,this.#J,this.#M]){if(!q)continue;if(j===null)q.removeAttribute("precision");else q.setAttribute("precision",String(this.#T))}}#E(j){let q=this.#h;if(q==="true")return!0;if(q==="modifier")return!!j;return!1}get#m(){let j=this.getAttribute("name");if(j)return j.split(",")[0].trim();return`${this.#j(this.#q)}%, ${this.#j(this.#$)}%`}get#Jj(){let j=this.getAttribute("name");if(j){let q=j.split(",");if(q.length>1)return q[1].trim()}return`${this.#j(this.#Q)}%, ${this.#j(this.#_)}%`}get#r(){return this.getAttribute("drag-surface")||"parent"}get#c(){let j=this.#r;if(j==="parent")return this.parentElement;return this.closest(j)}get#I(){let j=this.#r;if(j==="parent"){let q=this.parentElement;if(q)return q.setAttribute("data-fig-canvas-control-surface",""),"[data-fig-canvas-control-surface]"}return j}#Zj(j){if(this.#k)return this.#z/100*j;return this.#z}#i(){let j=this.#j(this.#z);if(this.#k)return`Radius ${j}%`;return`Radius ${j}`}connectedCallback(){this.#$j(),this.#o()}disconnectedCallback(){this.#Nj(),this.#Cj(),this.#Uj(),this.#Wj(),document.body.classList.remove("fig-lab-move-active"),document.body.classList.remove("fig-lab-rotate-active")}attributeChangedCallback(j,q,J){if(q===J)return;if(j==="value"&&!this.#W&&!this.#G&&!this.#f&&!this.#A)if(this.#$j(),this.#Z)this.#y();else this.#o();if(j==="type")this.#Nj(),this.#$j(),this.#o();if(j==="color"&&this.#Z)if(J)this.#Z.setAttribute("color",J);else this.#Z.removeAttribute("color");if(j==="disabled")this.#Nj(),this.#o();if(j==="tooltips")this.#o();if(j==="snapping"&&this.#Z){if(this.#Z.setAttribute("drag-snapping",J||"false"),this.#M)this.#M.setAttribute("drag-snapping",J||"false")}if(j==="precision"){if(!this.isConnected)return;this.#s(),this.#q=this.#j(this.#q),this.#$=this.#j(this.#$),this.#Q=this.#j(this.#Q),this.#_=this.#j(this.#_),this.#z=this.#j(this.#z),this.#U=this.#j(this.#U),this.#y(),this.#a()}if(j==="name"){if(this.#N)this.#N.setAttribute("text",this.#m);if(this.#B)this.#B.setAttribute("text",this.#Jj)}}#$j(){let j=this.getAttribute("value");if(!j)return;try{let q=JSON.parse(j);if(typeof q.x==="number")this.#q=this.#j(q.x);if(typeof q.y==="number")this.#$=this.#j(q.y);if(q.radius!==void 0){let J=String(q.radius);if(J.endsWith("%"))this.#k=!0,this.#z=this.#j(parseFloat(J));else this.#k=!1,this.#z=this.#j(parseFloat(J));if(!Number.isFinite(this.#z))this.#z=0}if(typeof q.angle==="number")this.#U=this.#j(q.angle);if(typeof q.x2==="number")this.#Q=this.#j(q.x2);if(typeof q.y2==="number")this.#_=this.#j(q.y2);if(this.#S==="color"&&typeof q.color==="string"&&q.color.trim()&&this.getAttribute("color")!==q.color.trim())this.setAttribute("color",q.color.trim())}catch{}}get value(){let j={x:this.#j(this.#q),y:this.#j(this.#$)};if(this.#S==="color"){let q=this.getAttribute("color")||this.#Z?.getAttribute("color");if(q)j.color=q}if(this.#p){let q=this.#j(this.#z);j.radius=this.#k?`${q}%`:q}if(this.#g)j.angle=this.#j(this.#U);if(this.#D)j.x2=this.#j(this.#Q),j.y2=this.#j(this.#_);return j}set value(j){if(typeof j==="object")this.setAttribute("value",JSON.stringify(j));else if(typeof j==="string")this.setAttribute("value",j)}#o(){this.#Nj(),this.replaceChildren(),this.#Z=null,this.#M=null,this.#J=null,this.#X=null,this.#O=null,this.#N=null,this.#B=null,this.#K=null,this.#Y=null;let j=L(this,"disabled"),q=this.#S,J=this.#qj,Z=this.#I,$=document.createElement("fig-handle");if($.setAttribute("drag","true"),$.setAttribute("drag-surface",Z),$.setAttribute("drag-axes","x,y"),$.setAttribute("drag-snapping",this.#h),$.setAttribute("value",`${this.#q}% ${this.#$}%`),this.hasAttribute("precision"))$.setAttribute("precision",String(this.#T));if(j)$.setAttribute("disabled","");if(q==="color"){$.setAttribute("type","color");let z=this.getAttribute("color");if(z)$.setAttribute("color",z)}else $.setAttribute("type","canvas");if(this.#D)$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate");if(this.#Z=$,this.#p)this.#Bj();if(this.#jj)this.#Mj();if(J){let z=document.createElement("fig-tooltip");z.setAttribute("action","manual"),z.setAttribute("theme","canvas"),z.setAttribute("pointer","false"),z.setAttribute("text",this.#m),z.appendChild($),this.appendChild(z),this.#N=z}else this.appendChild($);if(this.#g)this.#Aj(j,J,Z);if(this.#D)this.#Gj(j,J,Z);this.#b(this.#Z),this.#b(this.#J),this.#b(this.#M),this.#Tj(),this.#Lj(),requestAnimationFrame(()=>this.#y())}#b(j){if(!j)return;j.addEventListener("pointerdown",(q)=>{if(q.target?.classList?.contains("fig-handle-hit-area")&&j.querySelector(".fig-handle-hit-area"))this.#Fj(q,j);else this.#kj(q)},{capture:!0})}#kj(j){if(L(this,"disabled"))return;if(j?.button!==void 0&&j.button!==0)return;if(j?.isPrimary===!1)return;if(this.#V===null)this.#P=document.body.style.getPropertyValue("cursor"),this.#H=document.body.style.getPropertyPriority("cursor");if(this.#V=j?.pointerId??-1,document.body.classList.add("fig-lab-move-active"),document.body.style.setProperty("cursor","var(--fig-lab-cursor-move)","important"),!this.#F)this.#F=(q)=>{if(q?.pointerId!==void 0&&this.#V!==null&&q.pointerId!==this.#V)return;if(q?.type==="blur")this.#Uj();else requestAnimationFrame(()=>this.#Uj())};window.addEventListener("pointerup",this.#F),window.addEventListener("pointercancel",this.#F),window.addEventListener("blur",this.#F)}#Uj(){if(this.#V===null)return;if(document.body.classList.remove("fig-lab-move-active"),this.#P)document.body.style.setProperty("cursor",this.#P,this.#H);else document.body.style.removeProperty("cursor");if(this.#V=null,this.#P="",this.#H="",this.#F)window.removeEventListener("pointerup",this.#F),window.removeEventListener("pointercancel",this.#F),window.removeEventListener("blur",this.#F)}#Vj(j){if(!j)return 0;if(j===this.#J)return this.#U;if(!this.#D)return 0;let q=this.#Sj();return j===this.#Z?q+180:q}#Yj(){if(this.#L===null)return;let j=this.#Kj(this.#Vj(this.#w));document.body.style.setProperty("--fig-lab-cursor-rotate",j),document.body.style.setProperty("cursor",j,"important")}#Fj(j,q){if(L(this,"disabled"))return;if(j?.button!==void 0&&j.button!==0)return;if(j?.isPrimary===!1)return;if(this.#L===null)this.#x=document.body.style.getPropertyValue("cursor"),this.#C=document.body.style.getPropertyPriority("cursor");if(this.#L=j?.pointerId??-1,this.#w=q,document.body.classList.add("fig-lab-rotate-active"),this.#Yj(),!this.#R)this.#R=(J)=>{if(J?.pointerId!==void 0&&this.#L!==null&&J.pointerId!==this.#L)return;if(J?.type==="blur")this.#Wj();else requestAnimationFrame(()=>this.#Wj())};window.addEventListener("pointerup",this.#R),window.addEventListener("pointercancel",this.#R),window.addEventListener("blur",this.#R)}#Wj(){if(this.#L===null)return;if(document.body.classList.remove("fig-lab-rotate-active"),document.body.style.removeProperty("--fig-lab-cursor-rotate"),this.#x)document.body.style.setProperty("cursor",this.#x,this.#C);else document.body.style.removeProperty("cursor");if(this.#L=null,this.#w=null,this.#x="",this.#C="",this.#R)window.removeEventListener("pointerup",this.#R),window.removeEventListener("pointercancel",this.#R),window.removeEventListener("blur",this.#R)}#_j(j,q,J,Z){if(!j)return;let $=()=>!!Z?.(),z=()=>{let U=q();if(!U)return;U.removeAttribute("show"),U.hidePopup?.()},Q=()=>{if($()){z();return}let U=q();if(!U)return;if(J)U.setAttribute("text",J());U.setAttribute("show","true"),U.showPopup?.()},W=()=>{z()};j.addEventListener("pointerenter",Q),j.addEventListener("pointerleave",W)}#n(){return this.#W||this.#G||this.#f||this.#A}#Lj(){if(this.#Z)this.#_j(this.#Z,()=>this.#N,()=>this.#m,()=>this.#n()||!!this.#Z?.querySelector("fig-color-tip"));if(this.#J)this.#_j(this.#J,()=>this.#Y,()=>`Angle ${this.#j(this.#U)}°`,()=>this.#n());if(this.#M)this.#_j(this.#M,()=>this.#B,()=>this.#Jj,()=>this.#n());if(this.#X){let j=this.#X.querySelector(".fig-canvas-control-radius-hit");this.#fj(j||this.#X)}if(this.#S==="color"&&this.#Z&&this.#N)new MutationObserver(()=>{if(this.#Z?.querySelector("fig-color-tip"))this.#N?.removeAttribute("show"),this.#N?.hidePopup?.()}).observe(this.#Z,{childList:!0,subtree:!0})}#zj(j,q){let J=this.#K;if(!J?.popup)return;let Z=q-8;J.popup.anchor={getBoundingClientRect:()=>({left:j,top:Z,right:j,bottom:Z,width:0,height:0,x:j,y:Z})},J.popup.queueReposition?.()}#fj(j){if(!j)return;j.addEventListener("pointerenter",(q)=>{let J=this.#K;if(!J)return;J.setAttribute("text",this.#i()),J.setAttribute("show","true"),J.showPopup?.(),this.#zj(q.clientX,q.clientY)}),j.addEventListener("pointermove",(q)=>{if(this.#f)return;this.#zj(q.clientX,q.clientY)}),j.addEventListener("pointerleave",()=>{if(this.#f)return;let q=this.#K;if(!q)return;q.removeAttribute("show")})}#Bj(){let q=document.createElementNS("http://www.w3.org/2000/svg","svg");q.classList.add("fig-canvas-control-radius"),q.setAttribute("overflow","visible");let J=document.createElementNS("http://www.w3.org/2000/svg","circle");J.classList.add("fig-canvas-control-radius-hit"),q.appendChild(J);let Z=document.createElementNS("http://www.w3.org/2000/svg","circle");Z.classList.add("fig-canvas-control-radius-halo"),q.appendChild(Z);let $=document.createElementNS("http://www.w3.org/2000/svg","circle");if(q.appendChild($),this.#X=q,this.#qj){let z=document.createElement("fig-tooltip");z.setAttribute("action","manual"),z.setAttribute("theme","canvas"),z.setAttribute("pointer","false"),z.setAttribute("text",this.#i()),z.appendChild(q),this.appendChild(z),this.#K=z}else this.appendChild(q);this.#Hj(J)}#Mj(){let q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(q.classList.add("fig-canvas-control-angle-svg"),q.setAttribute("overflow","visible"),q.style.position="absolute",q.style.pointerEvents="none",this.#D){let $=document.createElementNS("http://www.w3.org/2000/svg","line");$.classList.add("fig-canvas-control-angle-line-hit"),$.setAttribute("stroke","transparent"),$.setAttribute("stroke-width","12"),$.setAttribute("stroke-linecap","round"),$.style.pointerEvents="stroke",q.appendChild($),this.#wj($)}let J=document.createElementNS("http://www.w3.org/2000/svg","line");J.classList.add("fig-canvas-control-angle-line-halo"),q.appendChild(J);let Z=document.createElementNS("http://www.w3.org/2000/svg","line");Z.classList.add("fig-canvas-control-angle-line"),q.appendChild(Z),this.#O=q,this.appendChild(q)}#wj(j){j.addEventListener("pointerdown",(q)=>{if(L(this,"disabled"))return;q.preventDefault(),q.stopPropagation();let J=this.#c;if(!J)return;let{clientX:Z,clientY:$}=q,z=this.#q,Q=this.#$,W=this.#Q,U=this.#_;this.#W=!0,this.#G=!0,document.body.classList.add("fig-lab-move-active"),j.style.pointerEvents="none";let M=(k)=>{let _=J.getBoundingClientRect(),B=_.width>0?(k.clientX-Z)/_.width*100:0,N=_.height>0?(k.clientY-$)/_.height*100:0,G=-Math.min(z,W),X=100-Math.max(z,W),O=-Math.min(Q,U),V=100-Math.max(Q,U),K=Math.max(G,Math.min(X,B)),w=Math.max(O,Math.min(V,N));this.#q=this.#j(z+K),this.#$=this.#j(Q+w),this.#Q=this.#j(W+K),this.#_=this.#j(U+w),this.#y(),this.#l()},Y=this.#Oj((k)=>{if(document.body.classList.remove("fig-lab-move-active"),j.style.pointerEvents="stroke",this.#W=!1,this.#G=!1,k)this.#a(),this.#d()});window.addEventListener("pointermove",M,{signal:Y.signal}),window.addEventListener("pointerup",()=>Y.finish(!0),{signal:Y.signal}),window.addEventListener("pointercancel",()=>Y.finish(!1),{signal:Y.signal})})}#Aj(j,q,J){let Z=document.createElement("fig-handle");if(Z.setAttribute("type","canvas"),Z.setAttribute("drag","true"),Z.setAttribute("drag-surface",J),Z.setAttribute("drag-axes","x,y"),Z.setAttribute("size","small"),Z.setAttribute("hit-area","12 circle"),Z.setAttribute("hit-area-mode","delegate"),this.hasAttribute("precision"))Z.setAttribute("precision",String(this.#T));if(j)Z.setAttribute("disabled","");if(this.#J=Z,q){let $=document.createElement("fig-tooltip");$.setAttribute("action","manual"),$.setAttribute("theme","canvas"),$.setAttribute("pointer","false"),$.setAttribute("text",`${this.#j(this.#U)}°`),$.appendChild(Z),this.appendChild($),this.#Y=$}else this.appendChild(Z)}#Gj(j,q,J){let Z=document.createElement("fig-handle");if(Z.setAttribute("type","canvas"),Z.setAttribute("drag","true"),Z.setAttribute("drag-surface",J),Z.setAttribute("drag-axes","x,y"),Z.setAttribute("drag-snapping",this.#h),Z.setAttribute("hit-area","12 circle"),Z.setAttribute("hit-area-mode","delegate"),Z.setAttribute("value",`${this.#Q}% ${this.#_}%`),this.hasAttribute("precision"))Z.setAttribute("precision",String(this.#T));if(j)Z.setAttribute("disabled","");if(this.#M=Z,q){let $=document.createElement("fig-tooltip");$.setAttribute("action","manual"),$.setAttribute("theme","canvas"),$.setAttribute("pointer","false"),$.setAttribute("text",this.#Jj),$.appendChild(Z),this.appendChild($),this.#B=$}else this.appendChild(Z)}#t(j){return`url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 32 32' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform='rotate(${Math.round(j)} 16 16)'%3E%3Cg filter='url(%23f)'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M11.1212 16.9998L11.5607 17.4394C12.1465 18.0252 12.1464 18.975 11.5606 19.5607C10.9748 20.1465 10.0251 20.1465 9.4393 19.5606L6.4393 16.5604C5.85354 15.9746 5.85357 15.0249 6.43938 14.4391L9.43938 11.4393C10.0252 10.8535 10.9749 10.8536 11.5607 11.4394C12.1465 12.0252 12.1464 12.9749 11.5606 13.5607L11.1215 13.9998L20.8786 13.9999L20.4394 13.5607C19.8536 12.9749 19.8535 12.0252 20.4393 11.4394C21.0251 10.8536 21.9749 10.8536 22.5606 11.4394L25.5606 14.4393C25.842 14.7206 26 15.1021 26 15.4999C26 15.8978 25.842 16.2793 25.5607 16.5606L22.5607 19.5607C21.9749 20.1465 21.0251 20.1465 20.4393 19.5607C19.8536 18.9749 19.8535 18.0252 20.4393 17.4394L20.8788 16.9999L11.1212 16.9998Z' fill='white'/%3E%3C/g%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M10.8536 12.1465C11.0488 12.3417 11.0488 12.6583 10.8535 12.8536L8.70715 14.9998L23.2929 14.9999L21.1465 12.8536C20.9512 12.6583 20.9512 12.3417 21.1464 12.1465C21.3417 11.9512 21.6583 11.9512 21.8535 12.1465L24.8535 15.1464C24.9473 15.2402 25 15.3673 25 15.4999C25 15.6326 24.9473 15.7597 24.8536 15.8535L21.8536 18.8536C21.6583 19.0488 21.3417 19.0488 21.1465 18.8536C20.9512 18.6583 20.9512 18.3417 21.1464 18.1465L23.2929 15.9999L8.70705 15.9998L10.8536 18.1465C11.0488 18.3417 11.0488 18.6583 10.8535 18.8536C10.6583 19.0488 10.3417 19.0488 10.1464 18.8535L7.14643 15.8533C6.95118 15.658 6.95119 15.3415 7.14646 15.1462L10.1465 12.1464C10.3417 11.9512 10.6583 11.9512 10.8536 12.1465Z' fill='black'/%3E%3C/g%3E%3Cdefs%3E%3Cfilter id='f' x='3' y='9' width='26' height='15' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='a'/%3E%3CfeColorMatrix in='SourceAlpha' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='b'/%3E%3CfeOffset dy='1'/%3E%3CfeGaussianBlur stdDeviation='1.5'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0'/%3E%3CfeBlend in2='a' result='c'/%3E%3CfeBlend in='SourceGraphic' in2='c'/%3E%3C/filter%3E%3C/defs%3E%3C/svg%3E") 16 16, nwse-resize`}#Kj(j){return`url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 32 32' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform='rotate(${Math.round(j-45)} 16 16)'%3E%3Cg filter='url(%23f)'%3E%3Cpath d='M12.5607 22.4393L12.0216 21.9002C17.1558 21.2216 21.2216 17.1558 21.9002 12.0216L22.4393 12.5607C23.0251 13.1464 23.9749 13.1464 24.5607 12.5607C25.1464 11.9749 25.1464 11.0251 24.5607 10.4393L21.5607 7.43934C20.9749 6.85355 20.0251 6.85355 19.4393 7.43934L16.4393 10.4393C15.8536 11.0251 15.8536 11.9749 16.4393 12.5607C17.0251 13.1464 17.9749 13.1464 18.5607 12.5607L18.8056 12.3157C18.1013 15.5527 15.5527 18.1013 12.3157 18.8056L12.5607 18.5607C13.1464 17.9749 13.1464 17.0251 12.5607 16.4393C11.9749 15.8536 11.0251 15.8536 10.4393 16.4393L7.43934 19.4393C6.85356 20.0251 6.85356 20.9749 7.43934 21.5607L10.4393 24.5607C11.0251 25.1464 11.9749 25.1464 12.5607 24.5607C13.1464 23.9749 13.1464 23.0251 12.5607 22.4393Z' fill='white'/%3E%3C/g%3E%3Cpath d='M23.8536 11.8536C23.6583 12.0488 23.3417 12.0488 23.1464 11.8536L21 9.70711V10.5C21 16.299 16.299 21 10.5 21H9.70711L11.8536 23.1464C12.0488 23.3417 12.0488 23.6583 11.8536 23.8536C11.6583 24.0488 11.3417 24.0488 11.1464 23.8536L8.14645 20.8536C7.95119 20.6583 7.95119 20.3417 8.14645 20.1464L11.1464 17.1464C11.3417 16.9512 11.6583 16.9512 11.8536 17.1464C12.0488 17.3417 12.0488 17.6583 11.8536 17.8536L9.70711 20H10.5C15.7467 20 20 15.7467 20 10.5V9.70711L17.8536 11.8536C17.6583 12.0488 17.3417 12.0488 17.1464 11.8536C16.9512 11.6583 16.9512 11.3417 17.1464 11.1464L20.1464 8.14645C20.3417 7.95119 20.6583 7.95119 20.8536 8.14645L23.8536 11.1464C24.0488 11.3417 24.0488 11.6583 23.8536 11.8536Z' fill='black'/%3E%3C/g%3E%3Cdefs%3E%3Cfilter id='f' x='4' y='5' width='24' height='24' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='a'/%3E%3CfeColorMatrix in='SourceAlpha' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='b'/%3E%3CfeOffset dy='1'/%3E%3CfeGaussianBlur stdDeviation='1.5'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0'/%3E%3CfeBlend in2='a' result='c'/%3E%3CfeBlend in='SourceGraphic' in2='c'/%3E%3C/filter%3E%3C/defs%3E%3C/svg%3E") 16 16, pointer`}#Xj(j,q){if(!j)return;j.style.setProperty("cursor",q,"important")}#Qj(j,q){if(!j)return;let J=j.querySelector(".fig-handle-hit-area");if(!J)return;if(J.setAttribute("data-cursor","rotate"),this.#Xj(J,this.#Kj(q)),this.#w===j)this.#Yj()}#e(){if(!this.#J||!this.#g)return;this.#Qj(this.#J,this.#U)}#Sj(){return Math.atan2(this.#_-this.#$,this.#Q-this.#q)*180/Math.PI}#Pj(){if(!this.#D)return;let j=this.#Sj();this.#Z?.style.removeProperty("cursor"),this.#M?.style.removeProperty("cursor"),this.#Qj(this.#Z,j+180),this.#Qj(this.#M,j)}#Rj(j,q,J,Z){j.style.setProperty("--fig-handle-position-translate","-50% -50%"),j.style.left=`${q/100*Z.width}px`,j.style.top=`${J/100*Z.height}px`}#y(){let j=this.#c;if(!j||!this.#Z)return;let q=j.getBoundingClientRect();if(this.#Rj(this.#Z,this.#q,this.#$,q),this.#X){let J=this.#q/100*q.width,Z=this.#$/100*q.height,$=this.#Zj(q.width),z=this.#X,Q=Math.max($*2,1);z.style.position="absolute",z.style.width=`${Q}px`,z.style.height=`${Q}px`,z.style.left=`${J-$}px`,z.style.top=`${Z-$}px`,z.setAttribute("viewBox",`0 0 ${Q} ${Q}`);let W=z.querySelectorAll("circle");for(let U of W)U.setAttribute("cx",String($)),U.setAttribute("cy",String($)),U.setAttribute("r",String(Math.max($-1,0)))}if(this.#O&&this.#jj){let J=this.#q/100*q.width,Z=this.#$/100*q.height,$,z;if(this.#D)$=this.#Q/100*q.width,z=this.#_/100*q.height;else{let U=this.#Zj(q.width),M=this.#U*Math.PI/180;$=J+U*Math.cos(M),z=Z+U*Math.sin(M)}let Q=this.#O;Q.style.width=`${q.width}px`,Q.style.height=`${q.height}px`,Q.style.left="0",Q.style.top="0",Q.setAttribute("viewBox",`0 0 ${q.width} ${q.height}`);let W=Q.querySelectorAll(".fig-canvas-control-angle-line, .fig-canvas-control-angle-line-halo, .fig-canvas-control-angle-line-hit");for(let U of W)U.setAttribute("x1",String(J)),U.setAttribute("y1",String(Z)),U.setAttribute("x2",String($)),U.setAttribute("y2",String(z))}if(this.#J&&this.#g){let J=this.#q/100*q.width,Z=this.#$/100*q.height,$=this.#Zj(q.width),z=this.#U*Math.PI/180,Q=J+$*Math.cos(z),W=Z+$*Math.sin(z),U=q.width>0?Q/q.width*100:0,M=q.height>0?W/q.height*100:0;this.#Rj(this.#J,U,M,q)}if(this.#M&&this.#D)this.#Rj(this.#M,this.#Q,this.#_,q);this.#e(),this.#Pj()}#l(j=this.value){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:j}))}#d(j=this.value){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:j}))}#Ej(j){return{...this.value,...a(j.color,j.alpha,j.opacity)}}#a(){this.setAttribute("value",JSON.stringify(this.value))}#Tj(){if(!this.#Z)return;if(this.#Z.addEventListener("input",(j)=>{if(j.stopPropagation(),j.detail?.color){this.setAttribute("color",this.#Z.getAttribute("color")||j.detail.color),this.#l(this.#Ej(j.detail));return}this.#W=!0;let q=j.detail?.px??this.#q/100,J=j.detail?.py??this.#$/100;if(this.#q=this.#j(Math.max(0,Math.min(100,q*100))),this.#$=this.#j(Math.max(0,Math.min(100,J*100))),this.#N)this.#N.removeAttribute("show"),this.#N.hidePopup?.();this.#y(),this.#l()}),this.#Z.addEventListener("change",(j)=>{if(j.stopPropagation(),j.detail?.color){this.setAttribute("color",this.#Z.getAttribute("color")||j.detail.color),this.#d(this.#Ej(j.detail));return}let q=j.detail?.px??this.#q/100,J=j.detail?.py??this.#$/100;if(this.#q=this.#j(Math.max(0,Math.min(100,q*100))),this.#$=this.#j(Math.max(0,Math.min(100,J*100))),this.#N)this.#N.removeAttribute("show");this.#y(),this.#a(),this.#d(),requestAnimationFrame(()=>{this.#W=!1})}),this.#J)this.#J.addEventListener("input",(j)=>{j.stopPropagation();let q=this.#c;if(!q)return;this.#A=!0,this.classList.add("fig-canvas-control-ring-active");let J=q.getBoundingClientRect(),Z=this.#q/100*J.width,$=this.#$/100*J.height,z=j.detail?.x??0,Q=j.detail?.y??0,W=this.#J.offsetWidth/2,U=this.#J.offsetHeight/2,M=z+W-Z,Y=Q+U-$,k=Math.atan2(Y,M)*180/Math.PI;if(this.#E(j.detail?.shiftKey))k=Math.round(k/15)*15;this.#U=this.#j(k);let _=Math.sqrt(M*M+Y*Y);if(this.#E(j.detail?.shiftKey)){let B=this.#k?5:10;if(this.#k){let N=_/J.width*100;N=Math.round(N/B)*B,_=N/100*J.width}else _=Math.round(_/B)*B}if(this.#k)this.#z=this.#j(Math.max(0,_/J.width*100));else this.#z=this.#j(Math.max(0,_));if(this.#Y)this.#Y.setAttribute("text",`Angle ${this.#j(this.#U)}°`),this.#Y.setAttribute("show","true"),this.#Y.showPopup?.();this.#y(),this.#l()}),this.#J.addEventListener("change",(j)=>{if(j.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#Y)this.#Y.removeAttribute("show");this.#y(),this.#a(),this.#d(),requestAnimationFrame(()=>{this.#A=!1})}),this.#J.addEventListener("hitareadown",(j)=>{j.stopPropagation();let q=j.detail?.originalEvent;if(!q)return;q.preventDefault();let J=this.#c;if(!J)return;if(this.#A=!0,this.classList.add("fig-canvas-control-ring-active"),this.#J.setAttribute("selected",""),this.#Y)this.#Y.setAttribute("show","true"),this.#Y.showPopup?.();let Z=(z)=>{let Q=J.getBoundingClientRect(),W=this.#q/100*Q.width,U=this.#$/100*Q.height,M=z.clientX-Q.left-W,Y=z.clientY-Q.top-U,k=Math.atan2(Y,M)*180/Math.PI;if(this.#E(z.shiftKey))k=Math.round(k/15)*15;if(this.#U=this.#j(k),this.#Y)this.#Y.setAttribute("text",`Angle ${this.#j(k)}°`);this.#y(),this.#l()},$=this.#Oj((z)=>{if(this.#A=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#J.removeAttribute("selected"),this.#Y)this.#Y.removeAttribute("show");if(z)this.#a(),this.#d()});window.addEventListener("pointermove",Z,{signal:$.signal}),window.addEventListener("pointerup",()=>$.finish(!0),{signal:$.signal}),window.addEventListener("pointercancel",()=>$.finish(!1),{signal:$.signal})});if(this.#M)this.#M.addEventListener("input",(j)=>{j.stopPropagation(),this.#G=!0;let q=j.detail?.px??this.#Q/100,J=j.detail?.py??this.#_/100;if(this.#Q=this.#j(Math.max(0,Math.min(100,q*100))),this.#_=this.#j(Math.max(0,Math.min(100,J*100))),this.#B)this.#B.removeAttribute("show"),this.#B.hidePopup?.();this.#y(),this.#l()}),this.#M.addEventListener("change",(j)=>{if(j.stopPropagation(),this.#B)this.#B.removeAttribute("show");this.#y(),this.#a(),this.#d(),requestAnimationFrame(()=>{this.#G=!1})}),this.#Ij(this.#Z,!0),this.#Ij(this.#M,!1)}#Ij(j,q){if(!j)return;j.addEventListener("hitareadown",(J)=>{J.stopPropagation();let Z=J.detail?.originalEvent;if(!Z)return;Z.preventDefault();let $=this.#c;if(!$)return;this.#W=!0;let z=$.getBoundingClientRect(),Q=q?this.#Q:this.#q,W=q?this.#_:this.#$,U=q?this.#q:this.#Q,M=q?this.#$:this.#_,Y=Q/100*z.width,k=W/100*z.height,_=U/100*z.width,B=M/100*z.height,N=Math.sqrt((_-Y)**2+(B-k)**2),G=q?this.#N:this.#B;if(G)G.removeAttribute("show"),G.hidePopup?.();let X=(V)=>{let K=$.getBoundingClientRect(),w=Q/100*K.width,f=W/100*K.height,A=V.clientX-K.left-w,S=V.clientY-K.top-f,R=Math.atan2(S,A);if(this.#E(V.shiftKey))R=Math.round(R*180/Math.PI/15)*15*Math.PI/180;let D=w+N*Math.cos(R),C=f+N*Math.sin(R),E=Math.max(0,Math.min(100,D/K.width*100)),I=Math.max(0,Math.min(100,C/K.height*100));if(q)this.#q=this.#j(E),this.#$=this.#j(I);else this.#Q=this.#j(E),this.#_=this.#j(I);this.#y(),this.#l()},O=this.#Oj((V)=>{if(this.#W=!1,G)G.removeAttribute("show");if(V)this.#a(),this.#d()});window.addEventListener("pointermove",X,{signal:O.signal}),window.addEventListener("pointerup",()=>O.finish(!0),{signal:O.signal}),window.addEventListener("pointercancel",()=>O.finish(!1),{signal:O.signal})})}#Hj(j){if(!j)return;j.addEventListener("pointermove",(J)=>{if(this.#f)return;let Z=this.#c;if(!Z)return;let $=Z.getBoundingClientRect(),z=this.#q/100*$.width,Q=this.#$/100*$.height,W=Math.atan2(J.clientY-$.top-Q,J.clientX-$.left-z)*180/Math.PI;this.#Xj(j,this.#t(W))});let q=(J)=>{if(L(this,"disabled"))return;J.preventDefault(),J.stopPropagation(),this.#f=!0,this.classList.add("fig-canvas-control-ring-active");let Z=this.#c;if(!Z)return;if(this.#K)this.#K.setAttribute("show","true"),this.#K.showPopup?.(),this.#zj(J.clientX,J.clientY);if(this.#Y)this.#Y.removeAttribute("show"),this.#Y.hidePopup?.();let $=this.#J?.style.pointerEvents,z=this.#J?.querySelector(".fig-handle-hit-area"),Q=z?.style.pointerEvents;if(this.#J)this.#J.style.pointerEvents="none";if(z)z.style.pointerEvents="none";let W=document.body.style.cursor;j.style.pointerEvents="none";let U=Z.getBoundingClientRect(),M=this.#q/100*U.width,Y=this.#$/100*U.height,k=Math.atan2(J.clientY-U.top-Y,J.clientX-U.left-M)*180/Math.PI,_=Math.round(k);document.body.style.cursor=this.#t(_);let B=(G)=>{let X=Z.getBoundingClientRect(),O=this.#q/100*X.width,V=this.#$/100*X.height,K=G.clientX-X.left-O,w=G.clientY-X.top-V,f=Math.round(Math.atan2(w,K)*180/Math.PI);if(f!==_)_=f,document.body.style.cursor=this.#t(f);let A=Math.sqrt(K*K+w*w);if(this.#E(G.shiftKey)){let S=this.#k?5:10;if(this.#k){let R=A/X.width*100;R=Math.round(R/S)*S,A=R/100*X.width}else A=Math.round(A/S)*S}if(this.#k)this.#z=this.#j(Math.max(0,A/X.width*100));else this.#z=this.#j(Math.max(0,A));if(this.#K)this.#K.setAttribute("text",this.#i()),this.#zj(G.clientX,G.clientY);this.#y(),this.#l()},N=this.#Oj((G)=>{if(this.#f=!1,this.classList.remove("fig-canvas-control-ring-active"),j.style.pointerEvents="",this.#J)this.#J.style.pointerEvents=$??"";if(z)z.style.pointerEvents=Q??"";if(document.body.style.cursor=W,this.#K)this.#K.removeAttribute("show");if(G)this.#a(),this.#d()});window.addEventListener("pointermove",B,{signal:N.signal}),window.addEventListener("pointerup",()=>N.finish(!0),{signal:N.signal}),window.addEventListener("pointercancel",()=>N.finish(!1),{signal:N.signal})};j.addEventListener("pointerdown",q),this._radiusDragCleanup=()=>j.removeEventListener("pointerdown",q)}#Cj(){if(this._radiusDragCleanup)this._radiusDragCleanup(),this._radiusDragCleanup=null}#Oj(j){this.#Nj();let q=new AbortController,J=!1,Z=($=!1)=>{if(J)return;if(J=!0,q.abort(),this.#u===q)this.#u=null,this.#v=null;j($)};return this.#u=q,this.#v=Z,{signal:q.signal,finish:Z}}#Nj(){this.#v?.(!1),this.#u?.abort(),this.#u=null,this.#v=null}}T("fig-canvas-control",l);class P extends HTMLElement{static observedAttributes=["axis","handle","items","disabled"];static#q=6;static#$=['[draggable]:not([draggable="false"])','img:not([draggable="false"])','a[href]:not([draggable="false"])','input[type="range"]',"fig-handle","fig-slider","fig-input-number","fig-input-gradient","fig-easing-curve","fig-angle","fig-input-audio","fig-input-wheel","fig-joystick","fig-origin-grid","fig-chooser","fig-canvas-control"];static#Q=new Set(["data-reorder-item","data-reorder-generated-role","data-reorder-handle","role","tabindex","aria-label","aria-roledescription"]);#_=null;#z=null;#k=!1;#U=new Map;#Z=null;#M=null;#J=null;connectedCallback(){if(this.style.display="contents",!this.hasAttribute("role"))this.setAttribute("role","list");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Reorderable list");this.#x(),this.#G(),this.#_=new MutationObserver(()=>this.#G()),this.#_.observe(this,{childList:!0}),this.#X()}disconnectedCallback(){this.#_?.disconnect(),this.#_=null,this.#z?.disconnect(),this.#z=null,this.#E(),this.#m(),this.#h(),this.#J?.remove(),this.#J=null}attributeChangedCallback(){if(this.isConnected){if(this.#O)this.#m();this.#X(),this.#G()}}refresh(){if(this.isConnected)this.#G()}#X(){if(!this.#K){this.#z?.disconnect(),this.#z=null;return}if(this.#z)return;this.#z=new MutationObserver((j)=>{if(!j.some((J)=>J.target.parentElement===this&&!P.#Q.has(J.attributeName)&&!(J.attributeName==="class"&&J.target===this.#Z?.item))||this.#k)return;this.#k=!0,queueMicrotask(()=>{if(this.#k=!1,this.isConnected)this.#G()})}),this.#z.observe(this,{subtree:!0,attributes:!0})}get#O(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}get#N(){return(this.getAttribute("axis")||"vertical").trim().toLowerCase()==="horizontal"?"horizontal":"vertical"}get#B(){return(this.getAttribute("handle")||"").trim()}get#K(){return(this.getAttribute("items")||"").trim()}#Y(){return[...this.children].filter((j)=>j.nodeType===Node.ELEMENT_NODE&&!j.hasAttribute("data-reorder-live"))}#W(){let j=this.#Y(),q=this.#K;if(!q)return j;try{return j.filter((J)=>J.matches(q))}catch{return[]}}#G(){let j=this.#Y(),q=this.#W(),J=new Set(q);for(let[Z,$]of this.#U)if(!J.has(Z))$.target.removeEventListener("pointerdown",$.onPointerDown,!0),$.target.removeEventListener("keydown",$.onKeyDown),this.#w($),this.#U.delete(Z);if(this.#P(j),this.#f(j),this.#V(j.filter((Z)=>!J.has(Z))),this.#O||q.length<2){this.#E();return}for(let Z of q){let $=this.#F(Z),z=this.#U.get(Z);if(z&&z.target===$)continue;if(z)z.target.removeEventListener("pointerdown",z.onPointerDown,!0),this.#U.delete(Z);if(!$)continue;this.#L(Z,$)}this.#H(q),this.#A(q)}#f(j){for(let q of j)if(q.removeAttribute("data-reorder-item"),q.hasAttribute("data-reorder-generated-role"))q.removeAttribute("role"),q.removeAttribute("data-reorder-generated-role")}#A(j){for(let q of j)if(q.setAttribute("data-reorder-item",""),!q.hasAttribute("role"))q.setAttribute("role","listitem"),q.setAttribute("data-reorder-generated-role","")}#V(j){for(let q of j)if(!q.hasAttribute("role"))q.setAttribute("role","none"),q.setAttribute("data-reorder-generated-role","")}#P(j){for(let q of j)q.querySelectorAll("[data-reorder-handle]").forEach((J)=>{J.removeAttribute("data-reorder-handle"),J.removeAttribute("aria-roledescription")})}#H(j){if(!this.#B)return;for(let q of j){let J=q.querySelector(this.#B);if(J)J.setAttribute("data-reorder-handle",""),J.setAttribute("aria-roledescription","reorder handle")}}#F(j){if(this.#B)return j.querySelector(this.#B);return j}#L(j,q){let J=(U)=>{if(this.#O||this.#W().length<2)return;if(U.button!==0)return;if(!this.#B&&this.#R(U.target,j))return;this.#S(U,j,q)},Z=q.getAttribute("tabindex"),$=q.getAttribute("aria-label"),z=q.getAttribute("role"),Q=j.getAttribute("aria-label")||j.textContent?.trim().replace(/\s+/g," ").slice(0,80)||"item";if(q.setAttribute("tabindex","0"),q.setAttribute("aria-label",`Move ${Q}`),q!==j&&!q.hasAttribute("role"))q.setAttribute("role","button");let W=(U)=>{if(this.#O)return;let M=this.#N==="horizontal",Y=M?"ArrowLeft":"ArrowUp",k=M?"ArrowRight":"ArrowDown";if(U.key!==Y&&U.key!==k&&U.key!=="Home"&&U.key!=="End")return;U.preventDefault(),U.stopPropagation();let _=this.#W(),B=_.indexOf(j),N=B;if(U.key===Y)N=Math.max(0,B-1);else if(U.key===k)N=Math.min(_.length-1,B+1);else if(U.key==="Home")N=0;else if(U.key==="End")N=_.length-1;if(N===B){this.#C(`${Q}, position ${B+1} of ${_.length}`);return}this.#j(j,N),this.#G(),this.#F(j)?.focus(),this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:B,newIndex:N,item:j}})),this.#C(`${Q}, position ${N+1} of ${_.length}`)};q.addEventListener("pointerdown",J,!0),q.addEventListener("keydown",W),this.#U.set(j,{target:q,onPointerDown:J,onKeyDown:W,originalTabIndex:Z,originalAriaLabel:$,originalRole:z})}#w(j){let{target:q,originalTabIndex:J,originalAriaLabel:Z,originalRole:$}=j;if(J===null)q.removeAttribute("tabindex");else q.setAttribute("tabindex",J);if(Z===null)q.removeAttribute("aria-label");else q.setAttribute("aria-label",Z);if($===null)q.removeAttribute("role");else q.setAttribute("role",$)}#x(){if(this.#J?.isConnected)return;let j=document.createElement("span");j.setAttribute("data-reorder-live",""),j.setAttribute("role","status"),j.setAttribute("aria-live","polite"),j.setAttribute("aria-atomic","true"),Object.assign(j.style,{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}),this.#J=j,document.body.appendChild(j)}#C(j){if(!this.#J)return;this.#J.textContent="",requestAnimationFrame(()=>{if(this.#J)this.#J.textContent=j})}#R(j,q){let J=j;while(J&&J!==q){if(J instanceof Element){for(let Z of P.#$)if(J.matches(Z))return!0}J=J.parentElement}return!1}static#u="fig-reorder-dragging";static#v(j){document.body.classList.toggle(P.#u,j)}#S(j,q,J){this.#m();let Z={item:q,target:J,pointerId:j.pointerId,oldIndex:this.#W().indexOf(q),targetIndex:this.#W().indexOf(q),startX:j.clientX,startY:j.clientY,active:!1,onMove:null,onUp:null,onKeyDown:null};Z.onMove=($)=>{if($.pointerId!==Z.pointerId)return;let z=$.clientX-Z.startX,Q=$.clientY-Z.startY;if(!Z.active){if(z*z+Q*Q<P.#q*P.#q)return;Z.active=!0,j.preventDefault(),j.stopPropagation(),q.classList.add("dragging"),P.#v(!0);try{J.setPointerCapture(Z.pointerId)}catch{}}$.preventDefault();let W=this.#N==="horizontal"?$.clientX:$.clientY,U=this.#p(W);Z.targetIndex=U,this.#qj(U,q)},Z.onKeyDown=($)=>{if($.key!=="Escape"||!Z.active)return;$.preventDefault(),this.#s(Z,!0)},Z.onUp=($)=>{if($.pointerId!==Z.pointerId)return;this.#s(Z,$.type==="pointercancel")},this.#Z=Z,window.addEventListener("pointermove",Z.onMove),window.addEventListener("pointerup",Z.onUp),window.addEventListener("pointercancel",Z.onUp),window.addEventListener("keydown",Z.onKeyDown)}#p(j){let q=this.#W(),J=this.#N==="horizontal";for(let Z=0;Z<q.length;Z++){let $=q[Z].getBoundingClientRect(),z=J?$.left+$.width/2:$.top+$.height/2;if(j<z)return Z}return q.length}#g(j,q){let J=this.#W(),Z=J.indexOf(j);if(Z===-1)return!1;let $=Math.max(0,Math.min(q,J.length));if(q===Z)return!1;if($>=J.length&&Z===J.length-1)return!1;return!0}#D(j){if(!j.length)return null;let q=1/0,J=-1/0,Z=1/0,$=-1/0;for(let z of j){let Q=z.getBoundingClientRect();q=Math.min(q,Q.left),J=Math.max(J,Q.right),Z=Math.min(Z,Q.top),$=Math.max($,Q.bottom)}return{left:q,top:Z,width:J-q,height:$-Z}}#jj(){if(this.#M)return this.#M;let j=document.createElement("div");return j.className="fig-reorder-indicator",j.setAttribute("data-axis",this.#N),document.body.appendChild(j),this.#M=j,j}#qj(j,q){let J=this.#W();if(!this.#g(q,j)){this.#h();return}let Z=this.#D(J);if(!Z){this.#h();return}let $=this.#jj();if($.setAttribute("data-axis",this.#N),this.#N==="horizontal"){let Q;if(j<=0)Q=J[0].getBoundingClientRect().left;else if(j>=J.length)Q=J[J.length-1].getBoundingClientRect().right;else Q=J[j].getBoundingClientRect().left;$.style.left=`${Q-1}px`,$.style.top=`${Z.top}px`,$.style.width="2px",$.style.height=`${Z.height}px`;return}let z;if(j<=0)z=J[0].getBoundingClientRect().top;else if(j>=J.length)z=J[J.length-1].getBoundingClientRect().bottom;else z=J[j].getBoundingClientRect().top;$.style.left=`${Z.left}px`,$.style.top=`${z-1}px`,$.style.width=`${Z.width}px`,$.style.height="2px"}#h(){this.#M?.remove(),this.#M=null}#T(j,q){let J=this.#W(),Z=Math.max(0,Math.min(q,J.length));if(Z>=J.length){let z=J[J.length-1];if(z&&z!==j)z.after(j);return}let $=J[Z];if($!==j)this.insertBefore(j,$)}#j(j,q){let J=this.#W().filter(($)=>$!==j),Z=J[q]??null;if(Z)this.insertBefore(j,Z);else if(J.length)J[J.length-1].after(j);else this.appendChild(j)}#s(j,q){let{item:J,oldIndex:Z,active:$,onMove:z,onUp:Q,onKeyDown:W}=j;if(window.removeEventListener("pointermove",z),window.removeEventListener("pointerup",Q),window.removeEventListener("pointercancel",Q),window.removeEventListener("keydown",W),$){if(!q){this.#T(J,j.targetIndex);let U=this.#W().indexOf(J);if(U!==-1&&U!==Z){this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:Z,newIndex:U,item:J}}));let M=J.getAttribute("aria-label")||J.textContent?.trim().replace(/\s+/g," ").slice(0,80)||"item";this.#C(`${M}, position ${U+1} of ${this.#W().length}`)}}}if(J.classList.remove("dragging"),P.#v(!1),this.#h(),this.#Z===j)this.#Z=null}#E(){for(let[,j]of this.#U)j.target.removeEventListener("pointerdown",j.onPointerDown,!0),j.target.removeEventListener("keydown",j.onKeyDown),this.#w(j);this.#U.clear()}#m(){if(!this.#Z)return;this.#s(this.#Z,!0)}}T("fig-reorder",P);
|
|
1
|
+
function T(j,q){if(!customElements.get(j))customElements.define(j,q)}function L(j,q){return j.hasAttribute(q)&&j.getAttribute(q)!=="false"}var u="http://www.w3.org/2000/svg";function m(j,q){let J=(Z)=>{if(Z===null||Z===void 0||Z===!1)return;if(Array.isArray(Z)){Z.forEach(J);return}j.append(Z instanceof Node?Z:String(Z))};return J(q),j}function p(j,q={}){for(let[J,Z]of Object.entries(q)){if(Z===null||Z===void 0||Z===!1)continue;if(J==="className")if(j.namespaceURI===u)j.setAttribute("class",String(Z));else j.className=String(Z);else if(Z===!0)j.setAttribute(J,"");else j.setAttribute(J,String(Z))}return j}function d(j,q,J){let Z=document.createElement(j);return p(Z,q),m(Z,J)}function x(j,q,J){let Z=document.createElementNS(u,j);return p(Z,q),m(Z,J)}function a(j,q,J){let Z=Number(q),$=Number(J),z=Number.isFinite(Z)?Math.max(0,Math.min(1,Z)):Number.isFinite($)?Math.max(0,Math.min(100,$))/100:1,Q=Number.isFinite($)?Math.max(0,Math.min(100,$)):Math.round(z*100);return{color:j,alpha:z,opacity:Q}}class v extends HTMLElement{}T("fig-ai-prompt",v);class h extends HTMLElement{}T("fig-ai-context",h);class g extends HTMLElement{}T("fig-chat-message",g);class c extends HTMLElement{#q=null;#$=null;#Q=null;#_=null;#z=null;#k=null;#U=this.#W.bind(this);#Z=this.#K.bind(this);#M=this.#Y.bind(this);static get observedAttributes(){return["src","name","value","removable","disabled"]}connectedCallback(){if(!this.#$)this.#J();this.#z.removeEventListener("click",this.#U),this.#z.addEventListener("click",this.#U),this.#X(),this.#N()}disconnectedCallback(){this.#z?.removeEventListener("click",this.#U),this.#O()}attributeChangedCallback(j,q,J){if(q===J||!this.#$)return;this.#N()}#J(){this.#q=document.createElement("fig-tooltip"),this.#q.className="fig-attachment-tooltip",this.#$=document.createElement("fig-image"),this.#$.setAttribute("aspect-ratio","1/1"),this.#$.setAttribute("fit","cover"),this.#$.setAttribute("full",""),this.#Q=document.createElement("span"),this.#Q.className="fig-attachment-fallback",this.#Q.setAttribute("aria-hidden","true"),this.#_=document.createElement("fig-tooltip"),this.#_.className="fig-attachment-remove-tooltip",this.#_.setAttribute("text","Remove attachment"),this.#z=document.createElement("fig-button"),this.#z.className="fig-attachment-remove",this.#z.setAttribute("variant","overlay"),this.#z.setAttribute("size","small"),this.#z.setAttribute("icon","");let j=document.createElement("fig-icon");j.setAttribute("name","close"),j.setAttribute("size","small"),this.#z.append(j),this.#_.append(this.#z),this.#$.append(this.#Q),this.#q.append(this.#$),this.replaceChildren(this.#q,this.#_),this.#z.addEventListener("click",this.#U),this.#X()}#X(){let j=this.#$?.mediaEl;if(!j||j===this.#k)return;this.#O(),this.#k=j,this.#k.addEventListener("load",this.#Z),this.#k.addEventListener("error",this.#M)}#O(){if(!this.#k)return;this.#k.removeEventListener("load",this.#Z),this.#k.removeEventListener("error",this.#M),this.#k=null}#N(){let j=this.getAttribute("src")||"",q=this.getAttribute("name")||"Attachment",J=!this.hasAttribute("removable")||L(this,"removable"),Z=L(this,"disabled");if(this.#q.setAttribute("text",q),this.#$.setAttribute("alt",q),j)this.#$.setAttribute("src",j);else this.#$.removeAttribute("src");if(this.#X(),this.#Q.textContent=this.#B(q),this.#z.hidden=!J,this.#z.toggleAttribute("disabled",Z),this.#z.setAttribute("aria-label",`Remove ${q}`),this.toggleAttribute("data-fallback",!j),Z)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled")}#B(j){let q=j.split(/[\\/]/).pop()||"",J=q.lastIndexOf(".");return(J>0&&J<q.length-1?q.slice(J+1).toUpperCase():"FILE").slice(0,4)}#K(){if(this.getAttribute("src"))this.removeAttribute("data-fallback")}#Y(){this.setAttribute("data-fallback","")}#W(j){if(j.stopPropagation(),L(this,"disabled")||this.hasAttribute("removable")&&!L(this,"removable"))return;this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,cancelable:!0,composed:!0,detail:{value:this.getAttribute("value"),name:this.getAttribute("name")||"",src:this.getAttribute("src")||"",attachment:this}}))}}T("fig-attachment",c);class s extends HTMLElement{#q=null;connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","list"),this.setAttribute("data-generated-role","");if(this.#$(),!this.#q)this.#q=new MutationObserver(()=>this.#$()),this.#q.observe(this,{childList:!0})}disconnectedCallback(){this.#q?.disconnect(),this.#q=null}#$(){for(let j of this.querySelectorAll(":scope > fig-attachment"))if(!j.hasAttribute("role"))j.setAttribute("role","listitem"),j.setAttribute("data-generated-role","")}}T("fig-attachments",s);class o extends HTMLElement{static observedAttributes=["url","filename","label","accepts","variant","disabled","full"];#q=null;#$=null;#Q=null;#_=null;#z=null;#k=null;#U=null;#Z=[];#M=0;#J=0;get files(){return this.#q?.files??null}get value(){return this.#q?.value??""}connectedCallback(){if(!this.#q)this.#X();this.#O(),this.#N(),this.#A()}disconnectedCallback(){if(this.#F(),this.#z?.disconnect(),this.#z=null,this.#J)cancelAnimationFrame(this.#J);this.#J=0}attributeChangedCallback(j,q,J){if(q===J||!this.#q)return;if(this.#N(),j==="url")this.#A()}clear(){this.removeAttribute("url"),this.removeAttribute("filename"),this.#q?.clear()}#X(){this.#$=document.createElement("div"),this.#$.className="fig-input-audio-waveform",this.#$.setAttribute("aria-hidden","true"),this.#Q=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.#Q.setAttribute("aria-hidden","true"),this.#Q.setAttribute("preserveAspectRatio","none"),this.#_=document.createElementNS("http://www.w3.org/2000/svg","path"),this.#Q.appendChild(this.#_),this.#$.appendChild(this.#Q),this.#q=document.createElement("fig-input-file"),this.#q.className="fig-input-audio-file",this.#q.addEventListener("input",this.#f),this.#q.addEventListener("change",this.#f),this.replaceChildren(this.#$,this.#q),this.#O()}#O(){if(this.#z||!this.#Q)return;this.#z=new ResizeObserver(()=>this.#L()),this.#z.observe(this.#Q)}#N(){let j=["url","filename","variant"];for(let q of j){let J=this.getAttribute(q);if(J===null)this.#q.removeAttribute(q);else this.#q.setAttribute(q,J)}this.#q.setAttribute("accepts",this.getAttribute("accepts")||"audio/*"),this.#q.setAttribute("label",this.getAttribute("label")||"Upload audio"),this.#B(this.#q,"disabled",this.#Y()),this.#B(this.#q,"full",this.#K("full")),this.#G(),this.#W()}#B(j,q,J){if(J)j.setAttribute(q,"");else j.removeAttribute(q)}#K(j){return this.hasAttribute(j)&&this.getAttribute(j)!=="false"}#Y(){return this.#K("disabled")}#W(){let j=this.#q?.files&&this.#q.files.length>0||!!this.getAttribute("url");this.toggleAttribute("data-has-audio",j),this.#G()}#G(){let j=this.#q?.querySelector('input[type="file"]');if(j)j.setAttribute("aria-label",this.hasAttribute("data-has-audio")?"Replace audio":"Upload audio");this.#q?.querySelector(".fig-input-file-clear")?.setAttribute("aria-label","Remove audio")}#f=(j)=>{if(j.stopPropagation(),j.target!==this.#q)return;let q=j.detail||{files:this.#q.files};if(j.type==="input"){let J=this.#q.files?.[0]||null;if(J){let Z=this.hasAttribute("url");if(Z)this.removeAttribute("url");if(this.#W(),!Z)this.#V(()=>J.arrayBuffer())}else{if(q.cleared)this.removeAttribute("url"),this.removeAttribute("filename");this.#H(),this.#W()}this.#G()}this.dispatchEvent(new CustomEvent(j.type,{bubbles:!0,composed:!0,detail:q}))};#A(){let j=this.#q?.files?.[0];if(j){this.#W(),this.#V(()=>j.arrayBuffer());return}let q=this.getAttribute("url");if(this.#W(),!q){this.#H();return}this.#V(async(J)=>{let Z=await fetch(q,{signal:J});if(!Z.ok)throw Error(`Audio request failed: ${Z.status}`);return Z.arrayBuffer()})}async#V(j){this.#F();let q=++this.#M,J=new AbortController;this.#k=J,this.setAttribute("data-waveform-state","loading"),this.setAttribute("aria-busy","true"),this.#Z=[],this.#L();let Z=null;try{let $=await j(J.signal);if(q!==this.#M||!this.isConnected)return;let z=window.AudioContext||window.webkitAudioContext;if(!z)throw Error("Web Audio is unavailable");Z=new z,this.#U=Z;let Q=await Z.decodeAudioData($);if(q!==this.#M||!this.isConnected)return;this.#Z=this.#P(Q),this.setAttribute("data-waveform-state","ready"),this.#L()}catch($){if(q!==this.#M||$?.name==="AbortError")return;this.#Z=Array(256).fill(0),this.setAttribute("data-waveform-state","unavailable"),this.#L()}finally{if(Z)try{await Z.close()}catch{}if(this.#U===Z)this.#U=null;if(this.#k===J)this.#k=null;if(q===this.#M)this.removeAttribute("aria-busy")}}#P(j){let J=Array(256).fill(0),Z=j.numberOfChannels,$=j.length,z=Math.max(1,Math.ceil($/500000)),Q=0;for(let W=0;W<Z;W+=1){let U=j.getChannelData(W);for(let M=0;M<256;M+=1){let Y=Math.floor(M/256*$),k=Math.max(Y+1,Math.floor((M+1)/256*$)),_=J[M];for(let B=Y;B<k;B+=z){let N=Math.abs(U[B]||0);if(Number.isFinite(N))_=Math.max(_,N)}J[M]=_,Q=Math.max(Q,_)}}if(!Number.isFinite(Q)||Q<=0)return J.fill(0);return J.map((W)=>{let U=Math.sqrt(W/Q);return Number.isFinite(U)?U:0})}#H(){this.#F(),this.#Z=[],this.removeAttribute("data-waveform-state"),this.removeAttribute("aria-busy"),this.#L()}#F(){if(this.#M+=1,this.#k?.abort(),this.#k=null,this.#U){try{this.#U.close()}catch{}this.#U=null}}#L(){if(this.#J)return;this.#J=requestAnimationFrame(()=>{this.#J=0,this.#w()})}#w(){if(!this.#Q||!this.#_)return;let j=this.#Q.getBoundingClientRect(),q=Math.max(1,Math.round(j.width)),J=Math.max(1,Math.round(j.height));if(this.#Q.setAttribute("viewBox",`0 0 ${q} ${J}`),this.#Z.length===0){this.#_.setAttribute("d","");return}let Z=Math.min(this.#Z.length,Math.max(12,Math.floor(q/4))),$=q/Z,z=Number.parseFloat(getComputedStyle(this).getPropertyValue("--fig-input-audio-waveform-stroke-width")),Q=Number.isFinite(z)&&z>0?z:2,W=Math.max(0.5,Math.min(Q,$*0.75)),U=W/2,M=J/2,Y=Math.max(2,J-12),k=[];for(let _=0;_<Z;_+=1){let B=Math.min(this.#Z.length-1,Math.floor(_/Z*this.#Z.length)),N=Math.max(W,this.#Z[B]*Y),G=(_+0.5)*$,X=M-N/2,O=M+N/2,V=G-U,K=G+U;k.push(`M ${G} ${X} Q ${K} ${X} ${K} ${X+U} V ${O-U} Q ${K} ${O} ${G} ${O} Q ${V} ${O} ${V} ${O-U} V ${X+U} Q ${V} ${X} ${G} ${X} Z`)}this.#_.setAttribute("d",k.join(" "))}}T("fig-input-audio",o);class F extends HTMLElement{static#q=33;static#$=60;static#Q=0.55;static#_=1.5;static#z=80;static#k=4;static#U="fig-input-wheel-dragging";#Z=null;#M=null;#J=null;#X=null;#O=null;#N=null;#B=null;#K=0;#Y=0;#W=0;#G=0;#f=0;#A=null;#V=!1;#P=null;#H=0;#F=0;#L=!1;#w=null;#x=0;#C=null;#R=0;#u=0;#v=this.#Yj.bind(this);#S=this.#Fj.bind(this);#p=this.#_j.bind(this);#g=this.#Kj.bind(this);#D=this.#Xj.bind(this);static get observedAttributes(){return["value","disabled","step","min","max","spin"]}connectedCallback(){if(!this.#Z)this.#jj();if(this.#$j(),this.#Zj(),this.#Uj(),this.#A?.disconnect(),globalThis.ResizeObserver)this.#A=new ResizeObserver((j)=>{let q=j.at(-1)?.contentRect;if(q)this.#o(q.width,q.height)}),this.#A.observe(this);this.#b()}disconnectedCallback(){if(this.#A?.disconnect(),this.#W)cancelAnimationFrame(this.#W);this.#W=0,this.#e(),this.#Vj(),this.#n()}attributeChangedCallback(j,q,J){if(q===J||!this.#Z)return;if(j==="disabled")this.#$j();if(j==="value"&&!this.#V)this.#Zj();if(j==="step")this.#i(),this.#b();if(j==="spin")this.#b();if(j==="min"||j==="max")this.#I(this.#j())}#jj(){if(this.#Z=this,this.#M=this,this.#J=this,this.setAttribute("role","spinbutton"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Value");this.setAttribute("tabindex","0");let j=x("svg",{className:"fig-input-wheel-svg","aria-hidden":"true"}),q=d("div",{className:"fig-input-wheel-handle"});this.#X=j,this.replaceChildren(j,q);let J=document.createElement("div");J.setAttribute("aria-hidden","true"),J.style.cssText="position:absolute;visibility:hidden;pointer-events:none;left:0;top:0";let Z=document.createElement("div");Z.style.height="var(--fig-input-wheel-tick-height)";let $=document.createElement("div");$.style.height="var(--fig-input-wheel-tick-height-min)";let z=document.createElement("div");z.style.width="var(--fig-input-wheel-tick-width)";let Q=document.createElement("div");Q.style.width="var(--fig-input-wheel-tick-width-min)",J.append(Z,$,z,Q),this.append(J),this.#B={maxEl:Z,minEl:$,maxWidthEl:z,minWidthEl:Q},this.#qj()}#qj(){if(!this.#X||this.#O)return;this.#O=x("path",{className:"fig-input-wheel-tick"}),this.#X.append(this.#O)}#h(){if(this.#N)return this.#N;return this.#N={maxH:this.#B?.maxEl.getBoundingClientRect().height||8,minH:this.#B?.minEl.getBoundingClientRect().height||4,maxW:this.#B?.maxWidthEl.getBoundingClientRect().width||2,minW:this.#B?.minWidthEl.getBoundingClientRect().width||1},this.#N}#T(){if(this.hasAttribute("step")){let j=Number(this.getAttribute("step"));if(j>0)return j}return 1}#j(){let j=Number(this.getAttribute("value")??0);return Number.isFinite(j)?j:0}#s(j){if(!this.hasAttribute(j))return null;let q=this.getAttribute(j);if(q===null||q.trim()==="")return null;let J=Number(q);return Number.isFinite(J)?J:null}#E(){return this.#s("min")}#m(){return this.#s("max")}#Jj(j,q){if(q===null||q===void 0||q===""){this.removeAttribute(j);return}let J=Number(q);if(!Number.isFinite(J)){this.removeAttribute(j);return}this.setAttribute(j,String(J))}#r(j){let q=j,J=this.#E(),Z=this.#m();if(J!==null)q=Math.max(J,q);if(Z!==null)q=Math.min(Z,q);return q}#c(j){let q=this.#T();if(q<=0)return j;let J=this.#E()??0,Z=Math.round((j-J)/q)*q+J;return Number(Z.toPrecision(15))}#I(j,{snap:q=!1,emit:J=null}={}){let Z=q?this.#c(j):j;Z=this.#r(Z);let $=String(Z);if(this.getAttribute("value")!==$)this.setAttribute("value",$);if(this.#i(Z),this.#b(),J)this.dispatchEvent(new CustomEvent(J,{detail:Z,bubbles:!0,cancelable:!0,composed:!0}))}#Zj(){let j=this.#j(),q=this.#r(j);if(q!==j||this.getAttribute("value")!==String(q)){this.#I(q);return}this.#i(j),this.#b()}#i(j=this.#j()){if(!this.#J)return;let q=this.#E(),J=this.#m();if(this.#J.setAttribute("aria-valuenow",String(j)),this.#J.setAttribute("aria-valuetext",String(j)),q===null)this.#J.removeAttribute("aria-valuemin");else this.#J.setAttribute("aria-valuemin",String(q));if(J===null)this.#J.removeAttribute("aria-valuemax");else this.#J.setAttribute("aria-valuemax",String(J))}#$j(){let j=L(this,"disabled");if(!this.#J)return;if(j){if(this.#V)this.#n();this.#e(),this.setAttribute("aria-disabled","true"),this.#J.setAttribute("tabindex","-1"),this.#J.setAttribute("aria-disabled","true")}else this.removeAttribute("aria-disabled"),this.#J.setAttribute("tabindex","0"),this.#J.removeAttribute("aria-disabled")}#o(j,q){if(!this.#X||j<1||q<1)return;if(j===this.#K&&q===this.#Y)return;this.#K=j,this.#Y=q,this.#N=null,this.#X.setAttribute("viewBox",`0 0 ${j} ${q}`),this.#X.setAttribute("width",String(j)),this.#X.setAttribute("height",String(q)),this.#b()}#b(){if(this.#W)return;this.#W=requestAnimationFrame(()=>{if(!this.isConnected){this.#W=0;return}if(this.#K<1||this.#Y<1){let j=this.#J?.getBoundingClientRect();if(j)this.#o(j.width,j.height)}this.#kj(),this.#W=0})}#kj(){if(!this.#O)return;let j=this.#K,q=this.#Y;if(j<1||q<1)return;let J=this.getAttribute("spin")==="false"?this.#E()??0:this.#w??this.#j(),Z=360/F.#q,$=this.#T(),z=this.#E()??0,Q=(J-z)/$*Z,W=F.#Q,U=j/2,M=q/2,{maxH:Y,minH:k,maxW:_,minW:B}=this.#h(),N=F.#$,G=Math.max(j/2,1),X=G*0.84,O=[];for(let V=0;V<F.#q;V+=1){let K=Q+V*Z;if(K=((K+180)%360+360)%360-180,K<-N||K>=N)continue;let w=K*Math.PI/180,f=U+X*Math.sin(w)/(1-W*Math.cos(w)),A=Math.min(1,Math.abs(f-U)/Math.max(G,1)),S=Math.cos(A*Math.PI*0.5),R=k+(Y-k)*S,D=B+(_-B)*S,C=R/2,E=D/2,I=M-C,H=M+C,b=f-E,y=f+E;O.push(`M ${f} ${I} Q ${y} ${I} ${y} ${I+E} V ${H-E} Q ${y} ${H} ${f} ${H} Q ${b} ${H} ${b} ${H-E} V ${I+E} Q ${b} ${I} ${f} ${I} Z`)}this.#O.setAttribute("d",O.join(" "))}#Uj(){this.#Z?.addEventListener("pointerdown",this.#v),this.#J?.addEventListener("wheel",this.#g,{passive:!1}),this.#J?.addEventListener("keydown",this.#D)}#Vj(){this.#Z?.removeEventListener("pointerdown",this.#v),this.#J?.removeEventListener("wheel",this.#g),this.#J?.removeEventListener("keydown",this.#D),window.removeEventListener("pointermove",this.#S),window.removeEventListener("pointerup",this.#p),window.removeEventListener("pointercancel",this.#p)}#Yj(j){if(L(this,"disabled"))return;if(j.button!==0)return;if(j.preventDefault(),!this.beginScrub(j))return;this.#Z?.setPointerCapture?.(j.pointerId),window.addEventListener("pointermove",this.#S),window.addEventListener("pointerup",this.#p),window.addEventListener("pointercancel",this.#p)}beginScrub(j={}){if(L(this,"disabled"))return!1;let q=typeof j==="number"?j:Number(j?.clientX??j?.x);if(!Number.isFinite(q))return!1;this.#e(),this.#V=!0,this.#P=j&&typeof j==="object"&&j.pointerId!==void 0?j.pointerId:null,this.#H=q;let J=j&&typeof j==="object"?Number(j.startValue):Number.NaN;return this.#F=Number.isFinite(J)?this.#r(J):this.#j(),this.#L=!1,this.#wj(q),this.#Lj(),this.setAttribute("data-fig-input-wheel-active",""),document.body.classList.remove(F.#U),this.focus(),!0}updateScrub(j,q){if(!this.#V)return this.#j();let J=typeof j==="number"?j:Number(j?.clientX??j?.x);if(!Number.isFinite(J))return this.#j();let Z=q??(typeof j==="object"&&j?.shiftKey?10:1);return this.#Wj(J,Z),this.#j()}endScrub(j=!0){if(!this.#V)return this.#j();if(j&&this.#j()!==this.#F)this.#I(this.#j(),{snap:!0,emit:"change"});return this.#n(),this.#j()}#Fj(j){if(!this.#V)return;if(this.#P!==null&&j.pointerId!==this.#P)return;this.updateScrub(j)}#Wj(j,q=1){if(!this.#L&&Math.abs(j-this.#H)>=F.#k)this.#L=!0,document.body.classList.add(F.#U);let J=this.#J?.clientWidth||1,Z=F.#q*(F.#$*2/360),$=this.#T()*Z,z=(j-this.#H)*($/J)*q,Q=this.#w??this.#F,W=this.#r(this.#F+z);this.#Aj(j,q,W!==Q),this.#w=W,this.#I(W,{snap:!0,emit:"input"}),this.#fj(j)}#_j(j){if(!this.#V)return;if(this.#P!==null&&j.pointerId!==this.#P)return;this.endScrub()}#n(){this.#V=!1,this.#P=null,this.#L=!1,this.#w=null,this.removeAttribute("data-fig-input-wheel-active"),document.body.classList.remove(F.#U),this.#Gj(),this.#Bj(),window.removeEventListener("pointermove",this.#S),window.removeEventListener("pointerup",this.#p),window.removeEventListener("pointercancel",this.#p),this.#b()}#Lj(){this.#Bj(),this.#x=this.#zj("--fig-input-wheel-handle-drag-max")}#zj(j){let q=getComputedStyle(this).getPropertyValue(j).trim();if(q.includes("var(")||!q.endsWith("px")){let Z=document.createElement("div");Object.assign(Z.style,{position:"absolute",visibility:"hidden",pointerEvents:"none",width:`var(${j})`}),this.appendChild(Z),q=getComputedStyle(Z).width,Z.remove()}let J=Number.parseFloat(q);return Number.isFinite(J)?Math.max(0,J):0}#fj(j){if(!this.#x){this.#Mj();return}let q=j-this.#H;if(!q){this.#Mj();return}let J=this.#x*Math.tanh(q/Math.max(1,this.#x*3));this.style.setProperty("--fig-input-wheel-handle-drag-offset",`${J}px`)}#Bj(){this.#Mj(),this.#x=0}#Mj(){this.style.removeProperty("--fig-input-wheel-handle-drag-offset")}#wj(j){this.#Gj(),this.#C=j,this.#R=performance.now()}#Aj(j,q,J){let Z=performance.now(),$=Z-this.#R,z=this.#C===null?0:Math.abs(j-this.#C);this.#C=j,this.#R=Z;let Q=$>0?z/$*Math.max(1,Math.abs(q)):0;if(!J||Q<F.#_){this.#t();return}this.toggleAttribute("data-fig-input-wheel-fast",!0),clearTimeout(this.#u),this.#u=window.setTimeout(()=>{this.#t()},F.#z)}#Gj(){this.#C=null,this.#R=0,this.#t()}#t(){clearTimeout(this.#u),this.#u=0,this.removeAttribute("data-fig-input-wheel-fast")}#Kj(j){if(L(this,"disabled"))return;j.preventDefault();let q=j.deltaY===0?Math.sign(j.deltaX):Math.sign(j.deltaY);if(!q)return;let J=j.shiftKey?10:1;this.#I(this.#j()+this.#T()*J*q,{snap:!0,emit:"input"}),this.#I(this.#j(),{emit:"change"})}#Xj(j){if(L(this,"disabled"))return;if(j.target instanceof Element&&j.target.closest("fig-input-number"))return;if(j.key==="Home"){let z=this.#E();if(z===null)return;j.preventDefault(),this.#I(z,{snap:!0,emit:"input"}),this.#I(this.#j(),{emit:"change"});return}if(j.key==="End"){let z=this.#m();if(z===null)return;j.preventDefault(),this.#I(z,{snap:!0,emit:"input"}),this.#I(this.#j(),{emit:"change"});return}if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(j.key))return;j.preventDefault();let J=j.key==="ArrowRight"||j.key==="ArrowUp"?1:-1,Z=j.shiftKey?10:1,$=this.#j();this.#I($+this.#T()*Z*J,{snap:!0,emit:"input"}),this.#Qj($,this.#j(),J,Z),this.#I(this.#j(),{emit:"change"})}#Qj(j,q,J,Z,$=!0){if(j===q||globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches){this.#e();return}if(this.#G)cancelAnimationFrame(this.#G),this.#G=0;clearTimeout(this.#f),this.#f=0,this.removeAttribute("data-fig-input-wheel-keyboard-settling");let z=this.#w??j,Q=Number.parseFloat(this.style.getPropertyValue("--fig-input-wheel-handle-drag-offset"))||0,W=Z>1?120:90,U=performance.now(),M=$;this.setAttribute("data-fig-input-wheel-keyboard-moving","");let Y=(k)=>{let _=Math.min(1,(k-U)/W);if(this.#w=z+(q-z)*_,M){let B=Math.sin(_*Math.PI/2),N=Q+(J*4-Q)*B;this.style.setProperty("--fig-input-wheel-handle-drag-offset",`${N}px`)}if(this.#kj(),_<1){this.#G=requestAnimationFrame(Y);return}this.#G=0,this.#w=null,this.removeAttribute("data-fig-input-wheel-keyboard-moving"),this.setAttribute("data-fig-input-wheel-keyboard-settling",""),this.style.removeProperty("--fig-input-wheel-handle-drag-offset"),this.#f=window.setTimeout(()=>{this.removeAttribute("data-fig-input-wheel-keyboard-settling"),this.#f=0},140),this.#b()};this.#G=requestAnimationFrame(Y)}#e(){if(this.#G)cancelAnimationFrame(this.#G),this.#G=0;if(clearTimeout(this.#f),this.#f=0,this.#w=null,this.removeAttribute("data-fig-input-wheel-keyboard-moving"),this.removeAttribute("data-fig-input-wheel-keyboard-settling"),this.style.removeProperty("--fig-input-wheel-handle-drag-offset"),this.isConnected)this.#b()}get value(){return this.getAttribute("value")??"0"}set value(j){if(j===null||j===void 0||j===""){this.#I(0);return}let q=Number(j);this.#I(Number.isFinite(q)?q:0)}spinTo(j,{animateHandle:q=!1}={}){let J=this.#j();this.value=j;let Z=this.#j();if(this.getAttribute("spin")==="false")return this.#e(),Z;let $=Math.sign(Z-J);return this.#Qj(J,Z,$,Math.abs(Z-J)>this.#T()?10:1,q),Z}get min(){return this.#E()}set min(j){this.#Jj("min",j)}get max(){return this.#m()}set max(j){this.#Jj("max",j)}get step(){return this.#T()}focus(j){HTMLElement.prototype.focus.call(this,j)}}T("fig-input-wheel",F);class l extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping","precision"];#q=50;#$=50;#Q=75;#_=75;#z=0;#k=!1;#U=0;#Z=null;#M=null;#J=null;#X=null;#O=null;#N=null;#B=null;#K=null;#Y=null;#W=!1;#G=!1;#f=!1;#A=!1;#V=null;#P="";#H="";#F=null;#L=null;#w=null;#x="";#C="";#R=null;#u=null;#v=null;get#S(){return this.getAttribute("type")||"point"}get#p(){return this.#S==="point-radius"||this.#S==="point-radius-angle"}get#g(){return this.#S==="point-radius-angle"}get#D(){return this.#S==="point-point"}get#jj(){return this.#S==="point-radius-angle"||this.#S==="point-point"}get#qj(){let j=this.getAttribute("tooltips");return j===null||j!=="false"}get#h(){let j=this.getAttribute("snapping");if(j===null)return"false";let q=j.trim().toLowerCase();if(q==="modifier")return"modifier";if(q===""||q==="true")return"true";return"false"}get#T(){let j=Number(this.getAttribute("precision")??2);if(!Number.isFinite(j))return 2;return Math.max(0,Math.min(8,Math.trunc(j)))}#j(j){let q=10**this.#T,J=Math.round(j*q)/q;return Object.is(J,-0)?0:J}#s(){let j=this.getAttribute("precision");for(let q of[this.#Z,this.#J,this.#M]){if(!q)continue;if(j===null)q.removeAttribute("precision");else q.setAttribute("precision",String(this.#T))}}#E(j){let q=this.#h;if(q==="true")return!0;if(q==="modifier")return!!j;return!1}get#m(){let j=this.getAttribute("name");if(j)return j.split(",")[0].trim();return`${this.#j(this.#q)}%, ${this.#j(this.#$)}%`}get#Jj(){let j=this.getAttribute("name");if(j){let q=j.split(",");if(q.length>1)return q[1].trim()}return`${this.#j(this.#Q)}%, ${this.#j(this.#_)}%`}get#r(){return this.getAttribute("drag-surface")||"parent"}get#c(){let j=this.#r;if(j==="parent")return this.parentElement;return this.closest(j)}get#I(){let j=this.#r;if(j==="parent"){let q=this.parentElement;if(q)return q.setAttribute("data-fig-canvas-control-surface",""),"[data-fig-canvas-control-surface]"}return j}#Zj(j){if(this.#k)return this.#z/100*j;return this.#z}#i(){let j=this.#j(this.#z);if(this.#k)return`Radius ${j}%`;return`Radius ${j}`}connectedCallback(){this.#$j(),this.#o()}disconnectedCallback(){this.#Nj(),this.#Cj(),this.#Uj(),this.#Wj(),document.body.classList.remove("fig-lab-move-active"),document.body.classList.remove("fig-lab-rotate-active")}attributeChangedCallback(j,q,J){if(q===J)return;if(j==="value"&&!this.#W&&!this.#G&&!this.#f&&!this.#A)if(this.#$j(),this.#Z)this.#y();else this.#o();if(j==="type")this.#Nj(),this.#$j(),this.#o();if(j==="color"&&this.#Z)if(J)this.#Z.setAttribute("color",J);else this.#Z.removeAttribute("color");if(j==="disabled")this.#Nj(),this.#o();if(j==="tooltips")this.#o();if(j==="snapping"&&this.#Z){if(this.#Z.setAttribute("drag-snapping",J||"false"),this.#M)this.#M.setAttribute("drag-snapping",J||"false")}if(j==="precision"){if(!this.isConnected)return;this.#s(),this.#q=this.#j(this.#q),this.#$=this.#j(this.#$),this.#Q=this.#j(this.#Q),this.#_=this.#j(this.#_),this.#z=this.#j(this.#z),this.#U=this.#j(this.#U),this.#y(),this.#a()}if(j==="name"){if(this.#N)this.#N.setAttribute("text",this.#m);if(this.#B)this.#B.setAttribute("text",this.#Jj)}}#$j(){let j=this.getAttribute("value");if(!j)return;try{let q=JSON.parse(j);if(typeof q.x==="number")this.#q=this.#j(q.x);if(typeof q.y==="number")this.#$=this.#j(q.y);if(q.radius!==void 0){let J=String(q.radius);if(J.endsWith("%"))this.#k=!0,this.#z=this.#j(parseFloat(J));else this.#k=!1,this.#z=this.#j(parseFloat(J));if(!Number.isFinite(this.#z))this.#z=0}if(typeof q.angle==="number")this.#U=this.#j(q.angle);if(typeof q.x2==="number")this.#Q=this.#j(q.x2);if(typeof q.y2==="number")this.#_=this.#j(q.y2);if(this.#S==="color"&&typeof q.color==="string"&&q.color.trim()&&this.getAttribute("color")!==q.color.trim())this.setAttribute("color",q.color.trim())}catch{}}get value(){let j={x:this.#j(this.#q),y:this.#j(this.#$)};if(this.#S==="color"){let q=this.getAttribute("color")||this.#Z?.getAttribute("color");if(q)j.color=q}if(this.#p){let q=this.#j(this.#z);j.radius=this.#k?`${q}%`:q}if(this.#g)j.angle=this.#j(this.#U);if(this.#D)j.x2=this.#j(this.#Q),j.y2=this.#j(this.#_);return j}set value(j){if(typeof j==="object")this.setAttribute("value",JSON.stringify(j));else if(typeof j==="string")this.setAttribute("value",j)}#o(){this.#Nj(),this.replaceChildren(),this.#Z=null,this.#M=null,this.#J=null,this.#X=null,this.#O=null,this.#N=null,this.#B=null,this.#K=null,this.#Y=null;let j=L(this,"disabled"),q=this.#S,J=this.#qj,Z=this.#I,$=document.createElement("fig-handle");if($.setAttribute("drag","true"),$.setAttribute("drag-surface",Z),$.setAttribute("drag-axes","x,y"),$.setAttribute("drag-snapping",this.#h),$.setAttribute("value",`${this.#q}% ${this.#$}%`),this.hasAttribute("precision"))$.setAttribute("precision",String(this.#T));if(j)$.setAttribute("disabled","");if(q==="color"){$.setAttribute("type","color");let z=this.getAttribute("color");if(z)$.setAttribute("color",z)}else $.setAttribute("type","canvas");if(this.#D)$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate");if(this.#Z=$,this.#p)this.#Bj();if(this.#jj)this.#Mj();if(J){let z=document.createElement("fig-tooltip");z.setAttribute("action","manual"),z.setAttribute("theme","canvas"),z.setAttribute("pointer","false"),z.setAttribute("text",this.#m),z.appendChild($),this.appendChild(z),this.#N=z}else this.appendChild($);if(this.#g)this.#Aj(j,J,Z);if(this.#D)this.#Gj(j,J,Z);this.#b(this.#Z),this.#b(this.#J),this.#b(this.#M),this.#Tj(),this.#Lj(),requestAnimationFrame(()=>this.#y())}#b(j){if(!j)return;j.addEventListener("pointerdown",(q)=>{if(q.target?.classList?.contains("fig-handle-hit-area")&&j.querySelector(".fig-handle-hit-area"))this.#Fj(q,j);else this.#kj(q)},{capture:!0})}#kj(j){if(L(this,"disabled"))return;if(j?.button!==void 0&&j.button!==0)return;if(j?.isPrimary===!1)return;if(this.#V===null)this.#P=document.body.style.getPropertyValue("cursor"),this.#H=document.body.style.getPropertyPriority("cursor");if(this.#V=j?.pointerId??-1,document.body.classList.add("fig-lab-move-active"),document.body.style.setProperty("cursor","var(--fig-lab-cursor-move)","important"),!this.#F)this.#F=(q)=>{if(q?.pointerId!==void 0&&this.#V!==null&&q.pointerId!==this.#V)return;if(q?.type==="blur")this.#Uj();else requestAnimationFrame(()=>this.#Uj())};window.addEventListener("pointerup",this.#F),window.addEventListener("pointercancel",this.#F),window.addEventListener("blur",this.#F)}#Uj(){if(this.#V===null)return;if(document.body.classList.remove("fig-lab-move-active"),this.#P)document.body.style.setProperty("cursor",this.#P,this.#H);else document.body.style.removeProperty("cursor");if(this.#V=null,this.#P="",this.#H="",this.#F)window.removeEventListener("pointerup",this.#F),window.removeEventListener("pointercancel",this.#F),window.removeEventListener("blur",this.#F)}#Vj(j){if(!j)return 0;if(j===this.#J)return this.#U;if(!this.#D)return 0;let q=this.#Sj();return j===this.#Z?q+180:q}#Yj(){if(this.#L===null)return;let j=this.#Kj(this.#Vj(this.#w));document.body.style.setProperty("--fig-lab-cursor-rotate",j),document.body.style.setProperty("cursor",j,"important")}#Fj(j,q){if(L(this,"disabled"))return;if(j?.button!==void 0&&j.button!==0)return;if(j?.isPrimary===!1)return;if(this.#L===null)this.#x=document.body.style.getPropertyValue("cursor"),this.#C=document.body.style.getPropertyPriority("cursor");if(this.#L=j?.pointerId??-1,this.#w=q,document.body.classList.add("fig-lab-rotate-active"),this.#Yj(),!this.#R)this.#R=(J)=>{if(J?.pointerId!==void 0&&this.#L!==null&&J.pointerId!==this.#L)return;if(J?.type==="blur")this.#Wj();else requestAnimationFrame(()=>this.#Wj())};window.addEventListener("pointerup",this.#R),window.addEventListener("pointercancel",this.#R),window.addEventListener("blur",this.#R)}#Wj(){if(this.#L===null)return;if(document.body.classList.remove("fig-lab-rotate-active"),document.body.style.removeProperty("--fig-lab-cursor-rotate"),this.#x)document.body.style.setProperty("cursor",this.#x,this.#C);else document.body.style.removeProperty("cursor");if(this.#L=null,this.#w=null,this.#x="",this.#C="",this.#R)window.removeEventListener("pointerup",this.#R),window.removeEventListener("pointercancel",this.#R),window.removeEventListener("blur",this.#R)}#_j(j,q,J,Z){if(!j)return;let $=()=>!!Z?.(),z=()=>{let U=q();if(!U)return;U.removeAttribute("show"),U.hidePopup?.()},Q=()=>{if($()){z();return}let U=q();if(!U)return;if(J)U.setAttribute("text",J());U.setAttribute("show","true"),U.showPopup?.()},W=()=>{z()};j.addEventListener("pointerenter",Q),j.addEventListener("pointerleave",W)}#n(){return this.#W||this.#G||this.#f||this.#A}#Lj(){if(this.#Z)this.#_j(this.#Z,()=>this.#N,()=>this.#m,()=>this.#n()||!!this.#Z?.querySelector("fig-color-tip"));if(this.#J)this.#_j(this.#J,()=>this.#Y,()=>`Angle ${this.#j(this.#U)}°`,()=>this.#n());if(this.#M)this.#_j(this.#M,()=>this.#B,()=>this.#Jj,()=>this.#n());if(this.#X){let j=this.#X.querySelector(".fig-canvas-control-radius-hit");this.#fj(j||this.#X)}if(this.#S==="color"&&this.#Z&&this.#N)new MutationObserver(()=>{if(this.#Z?.querySelector("fig-color-tip"))this.#N?.removeAttribute("show"),this.#N?.hidePopup?.()}).observe(this.#Z,{childList:!0,subtree:!0})}#zj(j,q){let J=this.#K;if(!J?.popup)return;let Z=q-8;J.popup.anchor={getBoundingClientRect:()=>({left:j,top:Z,right:j,bottom:Z,width:0,height:0,x:j,y:Z})},J.popup.queueReposition?.()}#fj(j){if(!j)return;j.addEventListener("pointerenter",(q)=>{let J=this.#K;if(!J)return;J.setAttribute("text",this.#i()),J.setAttribute("show","true"),J.showPopup?.(),this.#zj(q.clientX,q.clientY)}),j.addEventListener("pointermove",(q)=>{if(this.#f)return;this.#zj(q.clientX,q.clientY)}),j.addEventListener("pointerleave",()=>{if(this.#f)return;let q=this.#K;if(!q)return;q.removeAttribute("show")})}#Bj(){let q=document.createElementNS("http://www.w3.org/2000/svg","svg");q.classList.add("fig-canvas-control-radius"),q.setAttribute("overflow","visible");let J=document.createElementNS("http://www.w3.org/2000/svg","circle");J.classList.add("fig-canvas-control-radius-hit"),q.appendChild(J);let Z=document.createElementNS("http://www.w3.org/2000/svg","circle");Z.classList.add("fig-canvas-control-radius-halo"),q.appendChild(Z);let $=document.createElementNS("http://www.w3.org/2000/svg","circle");if(q.appendChild($),this.#X=q,this.#qj){let z=document.createElement("fig-tooltip");z.setAttribute("action","manual"),z.setAttribute("theme","canvas"),z.setAttribute("pointer","false"),z.setAttribute("text",this.#i()),z.appendChild(q),this.appendChild(z),this.#K=z}else this.appendChild(q);this.#Hj(J)}#Mj(){let q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(q.classList.add("fig-canvas-control-angle-svg"),q.setAttribute("overflow","visible"),q.style.position="absolute",q.style.pointerEvents="none",this.#D){let $=document.createElementNS("http://www.w3.org/2000/svg","line");$.classList.add("fig-canvas-control-angle-line-hit"),$.setAttribute("stroke","transparent"),$.setAttribute("stroke-width","12"),$.setAttribute("stroke-linecap","round"),$.style.pointerEvents="stroke",q.appendChild($),this.#wj($)}let J=document.createElementNS("http://www.w3.org/2000/svg","line");J.classList.add("fig-canvas-control-angle-line-halo"),q.appendChild(J);let Z=document.createElementNS("http://www.w3.org/2000/svg","line");Z.classList.add("fig-canvas-control-angle-line"),q.appendChild(Z),this.#O=q,this.appendChild(q)}#wj(j){j.addEventListener("pointerdown",(q)=>{if(L(this,"disabled"))return;q.preventDefault(),q.stopPropagation();let J=this.#c;if(!J)return;let{clientX:Z,clientY:$}=q,z=this.#q,Q=this.#$,W=this.#Q,U=this.#_;this.#W=!0,this.#G=!0,document.body.classList.add("fig-lab-move-active"),j.style.pointerEvents="none";let M=(k)=>{let _=J.getBoundingClientRect(),B=_.width>0?(k.clientX-Z)/_.width*100:0,N=_.height>0?(k.clientY-$)/_.height*100:0,G=-Math.min(z,W),X=100-Math.max(z,W),O=-Math.min(Q,U),V=100-Math.max(Q,U),K=Math.max(G,Math.min(X,B)),w=Math.max(O,Math.min(V,N));this.#q=this.#j(z+K),this.#$=this.#j(Q+w),this.#Q=this.#j(W+K),this.#_=this.#j(U+w),this.#y(),this.#l()},Y=this.#Oj((k)=>{if(document.body.classList.remove("fig-lab-move-active"),j.style.pointerEvents="stroke",this.#W=!1,this.#G=!1,k)this.#a(),this.#d()});window.addEventListener("pointermove",M,{signal:Y.signal}),window.addEventListener("pointerup",()=>Y.finish(!0),{signal:Y.signal}),window.addEventListener("pointercancel",()=>Y.finish(!1),{signal:Y.signal})})}#Aj(j,q,J){let Z=document.createElement("fig-handle");if(Z.setAttribute("type","canvas"),Z.setAttribute("drag","true"),Z.setAttribute("drag-surface",J),Z.setAttribute("drag-axes","x,y"),Z.setAttribute("size","small"),Z.setAttribute("hit-area","12 circle"),Z.setAttribute("hit-area-mode","delegate"),this.hasAttribute("precision"))Z.setAttribute("precision",String(this.#T));if(j)Z.setAttribute("disabled","");if(this.#J=Z,q){let $=document.createElement("fig-tooltip");$.setAttribute("action","manual"),$.setAttribute("theme","canvas"),$.setAttribute("pointer","false"),$.setAttribute("text",`${this.#j(this.#U)}°`),$.appendChild(Z),this.appendChild($),this.#Y=$}else this.appendChild(Z)}#Gj(j,q,J){let Z=document.createElement("fig-handle");if(Z.setAttribute("type","canvas"),Z.setAttribute("drag","true"),Z.setAttribute("drag-surface",J),Z.setAttribute("drag-axes","x,y"),Z.setAttribute("drag-snapping",this.#h),Z.setAttribute("hit-area","12 circle"),Z.setAttribute("hit-area-mode","delegate"),Z.setAttribute("value",`${this.#Q}% ${this.#_}%`),this.hasAttribute("precision"))Z.setAttribute("precision",String(this.#T));if(j)Z.setAttribute("disabled","");if(this.#M=Z,q){let $=document.createElement("fig-tooltip");$.setAttribute("action","manual"),$.setAttribute("theme","canvas"),$.setAttribute("pointer","false"),$.setAttribute("text",this.#Jj),$.appendChild(Z),this.appendChild($),this.#B=$}else this.appendChild(Z)}#t(j){return`url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 32 32' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform='rotate(${Math.round(j)} 16 16)'%3E%3Cg filter='url(%23f)'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M11.1212 16.9998L11.5607 17.4394C12.1465 18.0252 12.1464 18.975 11.5606 19.5607C10.9748 20.1465 10.0251 20.1465 9.4393 19.5606L6.4393 16.5604C5.85354 15.9746 5.85357 15.0249 6.43938 14.4391L9.43938 11.4393C10.0252 10.8535 10.9749 10.8536 11.5607 11.4394C12.1465 12.0252 12.1464 12.9749 11.5606 13.5607L11.1215 13.9998L20.8786 13.9999L20.4394 13.5607C19.8536 12.9749 19.8535 12.0252 20.4393 11.4394C21.0251 10.8536 21.9749 10.8536 22.5606 11.4394L25.5606 14.4393C25.842 14.7206 26 15.1021 26 15.4999C26 15.8978 25.842 16.2793 25.5607 16.5606L22.5607 19.5607C21.9749 20.1465 21.0251 20.1465 20.4393 19.5607C19.8536 18.9749 19.8535 18.0252 20.4393 17.4394L20.8788 16.9999L11.1212 16.9998Z' fill='white'/%3E%3C/g%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M10.8536 12.1465C11.0488 12.3417 11.0488 12.6583 10.8535 12.8536L8.70715 14.9998L23.2929 14.9999L21.1465 12.8536C20.9512 12.6583 20.9512 12.3417 21.1464 12.1465C21.3417 11.9512 21.6583 11.9512 21.8535 12.1465L24.8535 15.1464C24.9473 15.2402 25 15.3673 25 15.4999C25 15.6326 24.9473 15.7597 24.8536 15.8535L21.8536 18.8536C21.6583 19.0488 21.3417 19.0488 21.1465 18.8536C20.9512 18.6583 20.9512 18.3417 21.1464 18.1465L23.2929 15.9999L8.70705 15.9998L10.8536 18.1465C11.0488 18.3417 11.0488 18.6583 10.8535 18.8536C10.6583 19.0488 10.3417 19.0488 10.1464 18.8535L7.14643 15.8533C6.95118 15.658 6.95119 15.3415 7.14646 15.1462L10.1465 12.1464C10.3417 11.9512 10.6583 11.9512 10.8536 12.1465Z' fill='black'/%3E%3C/g%3E%3Cdefs%3E%3Cfilter id='f' x='3' y='9' width='26' height='15' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='a'/%3E%3CfeColorMatrix in='SourceAlpha' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='b'/%3E%3CfeOffset dy='1'/%3E%3CfeGaussianBlur stdDeviation='1.5'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0'/%3E%3CfeBlend in2='a' result='c'/%3E%3CfeBlend in='SourceGraphic' in2='c'/%3E%3C/filter%3E%3C/defs%3E%3C/svg%3E") 16 16, nwse-resize`}#Kj(j){return`url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 32 32' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform='rotate(${Math.round(j-45)} 16 16)'%3E%3Cg filter='url(%23f)'%3E%3Cpath d='M12.5607 22.4393L12.0216 21.9002C17.1558 21.2216 21.2216 17.1558 21.9002 12.0216L22.4393 12.5607C23.0251 13.1464 23.9749 13.1464 24.5607 12.5607C25.1464 11.9749 25.1464 11.0251 24.5607 10.4393L21.5607 7.43934C20.9749 6.85355 20.0251 6.85355 19.4393 7.43934L16.4393 10.4393C15.8536 11.0251 15.8536 11.9749 16.4393 12.5607C17.0251 13.1464 17.9749 13.1464 18.5607 12.5607L18.8056 12.3157C18.1013 15.5527 15.5527 18.1013 12.3157 18.8056L12.5607 18.5607C13.1464 17.9749 13.1464 17.0251 12.5607 16.4393C11.9749 15.8536 11.0251 15.8536 10.4393 16.4393L7.43934 19.4393C6.85356 20.0251 6.85356 20.9749 7.43934 21.5607L10.4393 24.5607C11.0251 25.1464 11.9749 25.1464 12.5607 24.5607C13.1464 23.9749 13.1464 23.0251 12.5607 22.4393Z' fill='white'/%3E%3C/g%3E%3Cpath d='M23.8536 11.8536C23.6583 12.0488 23.3417 12.0488 23.1464 11.8536L21 9.70711V10.5C21 16.299 16.299 21 10.5 21H9.70711L11.8536 23.1464C12.0488 23.3417 12.0488 23.6583 11.8536 23.8536C11.6583 24.0488 11.3417 24.0488 11.1464 23.8536L8.14645 20.8536C7.95119 20.6583 7.95119 20.3417 8.14645 20.1464L11.1464 17.1464C11.3417 16.9512 11.6583 16.9512 11.8536 17.1464C12.0488 17.3417 12.0488 17.6583 11.8536 17.8536L9.70711 20H10.5C15.7467 20 20 15.7467 20 10.5V9.70711L17.8536 11.8536C17.6583 12.0488 17.3417 12.0488 17.1464 11.8536C16.9512 11.6583 16.9512 11.3417 17.1464 11.1464L20.1464 8.14645C20.3417 7.95119 20.6583 7.95119 20.8536 8.14645L23.8536 11.1464C24.0488 11.3417 24.0488 11.6583 23.8536 11.8536Z' fill='black'/%3E%3C/g%3E%3Cdefs%3E%3Cfilter id='f' x='4' y='5' width='24' height='24' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='a'/%3E%3CfeColorMatrix in='SourceAlpha' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='b'/%3E%3CfeOffset dy='1'/%3E%3CfeGaussianBlur stdDeviation='1.5'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0'/%3E%3CfeBlend in2='a' result='c'/%3E%3CfeBlend in='SourceGraphic' in2='c'/%3E%3C/filter%3E%3C/defs%3E%3C/svg%3E") 16 16, pointer`}#Xj(j,q){if(!j)return;j.style.setProperty("cursor",q,"important")}#Qj(j,q){if(!j)return;let J=j.querySelector(".fig-handle-hit-area");if(!J)return;if(J.setAttribute("data-cursor","rotate"),this.#Xj(J,this.#Kj(q)),this.#w===j)this.#Yj()}#e(){if(!this.#J||!this.#g)return;this.#Qj(this.#J,this.#U)}#Sj(){return Math.atan2(this.#_-this.#$,this.#Q-this.#q)*180/Math.PI}#Pj(){if(!this.#D)return;let j=this.#Sj();this.#Z?.style.removeProperty("cursor"),this.#M?.style.removeProperty("cursor"),this.#Qj(this.#Z,j+180),this.#Qj(this.#M,j)}#Rj(j,q,J,Z){j.style.setProperty("--fig-handle-position-translate","-50% -50%"),j.style.left=`${q/100*Z.width}px`,j.style.top=`${J/100*Z.height}px`}#y(){let j=this.#c;if(!j||!this.#Z)return;let q=j.getBoundingClientRect();if(this.#Rj(this.#Z,this.#q,this.#$,q),this.#X){let J=this.#q/100*q.width,Z=this.#$/100*q.height,$=this.#Zj(q.width),z=this.#X,Q=Math.max($*2,1);z.style.position="absolute",z.style.width=`${Q}px`,z.style.height=`${Q}px`,z.style.left=`${J-$}px`,z.style.top=`${Z-$}px`,z.setAttribute("viewBox",`0 0 ${Q} ${Q}`);let W=z.querySelectorAll("circle");for(let U of W)U.setAttribute("cx",String($)),U.setAttribute("cy",String($)),U.setAttribute("r",String(Math.max($-1,0)))}if(this.#O&&this.#jj){let J=this.#q/100*q.width,Z=this.#$/100*q.height,$,z;if(this.#D)$=this.#Q/100*q.width,z=this.#_/100*q.height;else{let U=this.#Zj(q.width),M=this.#U*Math.PI/180;$=J+U*Math.cos(M),z=Z+U*Math.sin(M)}let Q=this.#O;Q.style.width=`${q.width}px`,Q.style.height=`${q.height}px`,Q.style.left="0",Q.style.top="0",Q.setAttribute("viewBox",`0 0 ${q.width} ${q.height}`);let W=Q.querySelectorAll(".fig-canvas-control-angle-line, .fig-canvas-control-angle-line-halo, .fig-canvas-control-angle-line-hit");for(let U of W)U.setAttribute("x1",String(J)),U.setAttribute("y1",String(Z)),U.setAttribute("x2",String($)),U.setAttribute("y2",String(z))}if(this.#J&&this.#g){let J=this.#q/100*q.width,Z=this.#$/100*q.height,$=this.#Zj(q.width),z=this.#U*Math.PI/180,Q=J+$*Math.cos(z),W=Z+$*Math.sin(z),U=q.width>0?Q/q.width*100:0,M=q.height>0?W/q.height*100:0;this.#Rj(this.#J,U,M,q)}if(this.#M&&this.#D)this.#Rj(this.#M,this.#Q,this.#_,q);this.#e(),this.#Pj()}#l(j=this.value){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:j}))}#d(j=this.value){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:j}))}#Ej(j){return{...this.value,...a(j.color,j.alpha,j.opacity)}}#a(){this.setAttribute("value",JSON.stringify(this.value))}#Tj(){if(!this.#Z)return;if(this.#Z.addEventListener("input",(j)=>{if(j.stopPropagation(),j.detail?.color){this.setAttribute("color",this.#Z.getAttribute("color")||j.detail.color),this.#l(this.#Ej(j.detail));return}this.#W=!0;let q=j.detail?.px??this.#q/100,J=j.detail?.py??this.#$/100;if(this.#q=this.#j(Math.max(0,Math.min(100,q*100))),this.#$=this.#j(Math.max(0,Math.min(100,J*100))),this.#N)this.#N.removeAttribute("show"),this.#N.hidePopup?.();this.#y(),this.#l()}),this.#Z.addEventListener("change",(j)=>{if(j.stopPropagation(),j.detail?.color){this.setAttribute("color",this.#Z.getAttribute("color")||j.detail.color),this.#d(this.#Ej(j.detail));return}let q=j.detail?.px??this.#q/100,J=j.detail?.py??this.#$/100;if(this.#q=this.#j(Math.max(0,Math.min(100,q*100))),this.#$=this.#j(Math.max(0,Math.min(100,J*100))),this.#N)this.#N.removeAttribute("show");this.#y(),this.#a(),this.#d(),requestAnimationFrame(()=>{this.#W=!1})}),this.#J)this.#J.addEventListener("input",(j)=>{j.stopPropagation();let q=this.#c;if(!q)return;this.#A=!0,this.classList.add("fig-canvas-control-ring-active");let J=q.getBoundingClientRect(),Z=this.#q/100*J.width,$=this.#$/100*J.height,z=j.detail?.x??0,Q=j.detail?.y??0,W=this.#J.offsetWidth/2,U=this.#J.offsetHeight/2,M=z+W-Z,Y=Q+U-$,k=Math.atan2(Y,M)*180/Math.PI;if(this.#E(j.detail?.shiftKey))k=Math.round(k/15)*15;this.#U=this.#j(k);let _=Math.sqrt(M*M+Y*Y);if(this.#E(j.detail?.shiftKey)){let B=this.#k?5:10;if(this.#k){let N=_/J.width*100;N=Math.round(N/B)*B,_=N/100*J.width}else _=Math.round(_/B)*B}if(this.#k)this.#z=this.#j(Math.max(0,_/J.width*100));else this.#z=this.#j(Math.max(0,_));if(this.#Y)this.#Y.setAttribute("text",`Angle ${this.#j(this.#U)}°`),this.#Y.setAttribute("show","true"),this.#Y.showPopup?.();this.#y(),this.#l()}),this.#J.addEventListener("change",(j)=>{if(j.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#Y)this.#Y.removeAttribute("show");this.#y(),this.#a(),this.#d(),requestAnimationFrame(()=>{this.#A=!1})}),this.#J.addEventListener("hitareadown",(j)=>{j.stopPropagation();let q=j.detail?.originalEvent;if(!q)return;q.preventDefault();let J=this.#c;if(!J)return;if(this.#A=!0,this.classList.add("fig-canvas-control-ring-active"),this.#J.setAttribute("selected",""),this.#Y)this.#Y.setAttribute("show","true"),this.#Y.showPopup?.();let Z=(z)=>{let Q=J.getBoundingClientRect(),W=this.#q/100*Q.width,U=this.#$/100*Q.height,M=z.clientX-Q.left-W,Y=z.clientY-Q.top-U,k=Math.atan2(Y,M)*180/Math.PI;if(this.#E(z.shiftKey))k=Math.round(k/15)*15;if(this.#U=this.#j(k),this.#Y)this.#Y.setAttribute("text",`Angle ${this.#j(k)}°`);this.#y(),this.#l()},$=this.#Oj((z)=>{if(this.#A=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#J.removeAttribute("selected"),this.#Y)this.#Y.removeAttribute("show");if(z)this.#a(),this.#d()});window.addEventListener("pointermove",Z,{signal:$.signal}),window.addEventListener("pointerup",()=>$.finish(!0),{signal:$.signal}),window.addEventListener("pointercancel",()=>$.finish(!1),{signal:$.signal})});if(this.#M)this.#M.addEventListener("input",(j)=>{j.stopPropagation(),this.#G=!0;let q=j.detail?.px??this.#Q/100,J=j.detail?.py??this.#_/100;if(this.#Q=this.#j(Math.max(0,Math.min(100,q*100))),this.#_=this.#j(Math.max(0,Math.min(100,J*100))),this.#B)this.#B.removeAttribute("show"),this.#B.hidePopup?.();this.#y(),this.#l()}),this.#M.addEventListener("change",(j)=>{if(j.stopPropagation(),this.#B)this.#B.removeAttribute("show");this.#y(),this.#a(),this.#d(),requestAnimationFrame(()=>{this.#G=!1})}),this.#Ij(this.#Z,!0),this.#Ij(this.#M,!1)}#Ij(j,q){if(!j)return;j.addEventListener("hitareadown",(J)=>{J.stopPropagation();let Z=J.detail?.originalEvent;if(!Z)return;Z.preventDefault();let $=this.#c;if(!$)return;this.#W=!0;let z=$.getBoundingClientRect(),Q=q?this.#Q:this.#q,W=q?this.#_:this.#$,U=q?this.#q:this.#Q,M=q?this.#$:this.#_,Y=Q/100*z.width,k=W/100*z.height,_=U/100*z.width,B=M/100*z.height,N=Math.sqrt((_-Y)**2+(B-k)**2),G=q?this.#N:this.#B;if(G)G.removeAttribute("show"),G.hidePopup?.();let X=(V)=>{let K=$.getBoundingClientRect(),w=Q/100*K.width,f=W/100*K.height,A=V.clientX-K.left-w,S=V.clientY-K.top-f,R=Math.atan2(S,A);if(this.#E(V.shiftKey))R=Math.round(R*180/Math.PI/15)*15*Math.PI/180;let D=w+N*Math.cos(R),C=f+N*Math.sin(R),E=Math.max(0,Math.min(100,D/K.width*100)),I=Math.max(0,Math.min(100,C/K.height*100));if(q)this.#q=this.#j(E),this.#$=this.#j(I);else this.#Q=this.#j(E),this.#_=this.#j(I);this.#y(),this.#l()},O=this.#Oj((V)=>{if(this.#W=!1,G)G.removeAttribute("show");if(V)this.#a(),this.#d()});window.addEventListener("pointermove",X,{signal:O.signal}),window.addEventListener("pointerup",()=>O.finish(!0),{signal:O.signal}),window.addEventListener("pointercancel",()=>O.finish(!1),{signal:O.signal})})}#Hj(j){if(!j)return;j.addEventListener("pointermove",(J)=>{if(this.#f)return;let Z=this.#c;if(!Z)return;let $=Z.getBoundingClientRect(),z=this.#q/100*$.width,Q=this.#$/100*$.height,W=Math.atan2(J.clientY-$.top-Q,J.clientX-$.left-z)*180/Math.PI;this.#Xj(j,this.#t(W))});let q=(J)=>{if(L(this,"disabled"))return;J.preventDefault(),J.stopPropagation(),this.#f=!0,this.classList.add("fig-canvas-control-ring-active");let Z=this.#c;if(!Z)return;if(this.#K)this.#K.setAttribute("show","true"),this.#K.showPopup?.(),this.#zj(J.clientX,J.clientY);if(this.#Y)this.#Y.removeAttribute("show"),this.#Y.hidePopup?.();let $=this.#J?.style.pointerEvents,z=this.#J?.querySelector(".fig-handle-hit-area"),Q=z?.style.pointerEvents;if(this.#J)this.#J.style.pointerEvents="none";if(z)z.style.pointerEvents="none";let W=document.body.style.cursor;j.style.pointerEvents="none";let U=Z.getBoundingClientRect(),M=this.#q/100*U.width,Y=this.#$/100*U.height,k=Math.atan2(J.clientY-U.top-Y,J.clientX-U.left-M)*180/Math.PI,_=Math.round(k);document.body.style.cursor=this.#t(_);let B=(G)=>{let X=Z.getBoundingClientRect(),O=this.#q/100*X.width,V=this.#$/100*X.height,K=G.clientX-X.left-O,w=G.clientY-X.top-V,f=Math.round(Math.atan2(w,K)*180/Math.PI);if(f!==_)_=f,document.body.style.cursor=this.#t(f);let A=Math.sqrt(K*K+w*w);if(this.#E(G.shiftKey)){let S=this.#k?5:10;if(this.#k){let R=A/X.width*100;R=Math.round(R/S)*S,A=R/100*X.width}else A=Math.round(A/S)*S}if(this.#k)this.#z=this.#j(Math.max(0,A/X.width*100));else this.#z=this.#j(Math.max(0,A));if(this.#K)this.#K.setAttribute("text",this.#i()),this.#zj(G.clientX,G.clientY);this.#y(),this.#l()},N=this.#Oj((G)=>{if(this.#f=!1,this.classList.remove("fig-canvas-control-ring-active"),j.style.pointerEvents="",this.#J)this.#J.style.pointerEvents=$??"";if(z)z.style.pointerEvents=Q??"";if(document.body.style.cursor=W,this.#K)this.#K.removeAttribute("show");if(G)this.#a(),this.#d()});window.addEventListener("pointermove",B,{signal:N.signal}),window.addEventListener("pointerup",()=>N.finish(!0),{signal:N.signal}),window.addEventListener("pointercancel",()=>N.finish(!1),{signal:N.signal})};j.addEventListener("pointerdown",q),this._radiusDragCleanup=()=>j.removeEventListener("pointerdown",q)}#Cj(){if(this._radiusDragCleanup)this._radiusDragCleanup(),this._radiusDragCleanup=null}#Oj(j){this.#Nj();let q=new AbortController,J=!1,Z=($=!1)=>{if(J)return;if(J=!0,q.abort(),this.#u===q)this.#u=null,this.#v=null;j($)};return this.#u=q,this.#v=Z,{signal:q.signal,finish:Z}}#Nj(){this.#v?.(!1),this.#u?.abort(),this.#u=null,this.#v=null}}T("fig-canvas-control",l);class P extends HTMLElement{static observedAttributes=["axis","handle","items","disabled"];static#q=6;static#$=['[draggable]:not([draggable="false"])','img:not([draggable="false"])','a[href]:not([draggable="false"])','input[type="range"]',"fig-handle","fig-slider","fig-input-number","fig-input-gradient","fig-easing-curve","fig-angle","fig-input-audio","fig-input-wheel","fig-joystick","fig-origin-grid","fig-chooser","fig-canvas-control"];static#Q=new Set(["data-reorder-item","data-reorder-generated-role","data-reorder-handle","role","tabindex","aria-label","aria-roledescription"]);#_=null;#z=null;#k=!1;#U=new Map;#Z=null;#M=null;#J=null;connectedCallback(){if(this.style.display="contents",!this.hasAttribute("role"))this.setAttribute("role","list");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Reorderable list");this.#x(),this.#G(),this.#_=new MutationObserver(()=>this.#G()),this.#_.observe(this,{childList:!0}),this.#X()}disconnectedCallback(){this.#_?.disconnect(),this.#_=null,this.#z?.disconnect(),this.#z=null,this.#E(),this.#m(),this.#h(),this.#J?.remove(),this.#J=null}attributeChangedCallback(){if(this.isConnected){if(this.#O)this.#m();this.#X(),this.#G()}}refresh(){if(this.isConnected)this.#G()}#X(){if(!this.#K){this.#z?.disconnect(),this.#z=null;return}if(this.#z)return;this.#z=new MutationObserver((j)=>{if(!j.some((J)=>J.target.parentElement===this&&!P.#Q.has(J.attributeName)&&!(J.attributeName==="class"&&J.target===this.#Z?.item))||this.#k)return;this.#k=!0,queueMicrotask(()=>{if(this.#k=!1,this.isConnected)this.#G()})}),this.#z.observe(this,{subtree:!0,attributes:!0})}get#O(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}get#N(){return(this.getAttribute("axis")||"vertical").trim().toLowerCase()==="horizontal"?"horizontal":"vertical"}get#B(){return(this.getAttribute("handle")||"").trim()}get#K(){return(this.getAttribute("items")||"").trim()}#Y(){return[...this.children].filter((j)=>j.nodeType===Node.ELEMENT_NODE&&!j.hasAttribute("data-reorder-live"))}#W(){let j=this.#Y(),q=this.#K;if(!q)return j;try{return j.filter((J)=>J.matches(q))}catch{return[]}}#G(){let j=this.#Y(),q=this.#W(),J=new Set(q);for(let[$,z]of this.#U)if(!J.has($))z.target.removeEventListener("pointerdown",z.onPointerDown,!0),z.target.removeEventListener("keydown",z.onKeyDown),this.#w(z),this.#U.delete($);this.#P(j),this.#f(j),this.#V(j.filter(($)=>!J.has($)));let Z=!this.#O&&q.length>=2;if(this.#A(q,Z),!Z){this.#E();return}for(let $ of q){let z=this.#F($),Q=this.#U.get($);if(Q&&Q.target===z)continue;if(Q)Q.target.removeEventListener("pointerdown",Q.onPointerDown,!0),this.#U.delete($);if(!z)continue;this.#L($,z)}this.#H(q)}#f(j){for(let q of j)if(q.removeAttribute("data-reorder-item"),q.hasAttribute("data-reorder-generated-role"))q.removeAttribute("role"),q.removeAttribute("data-reorder-generated-role")}#A(j,q=!0){for(let J of j){if(q)J.setAttribute("data-reorder-item","");if(!J.hasAttribute("role"))J.setAttribute("role","listitem"),J.setAttribute("data-reorder-generated-role","")}}#V(j){for(let q of j)if(!q.hasAttribute("role"))q.setAttribute("role","none"),q.setAttribute("data-reorder-generated-role","")}#P(j){for(let q of j)q.querySelectorAll("[data-reorder-handle]").forEach((J)=>{J.removeAttribute("data-reorder-handle"),J.removeAttribute("aria-roledescription")})}#H(j){if(!this.#B)return;for(let q of j){let J=q.querySelector(this.#B);if(J)J.setAttribute("data-reorder-handle",""),J.setAttribute("aria-roledescription","reorder handle")}}#F(j){if(this.#B)return j.querySelector(this.#B);return j}#L(j,q){let J=(U)=>{if(this.#O||this.#W().length<2)return;if(U.button!==0)return;if(!this.#B&&this.#R(U.target,j))return;this.#S(U,j,q)},Z=q.getAttribute("tabindex"),$=q.getAttribute("aria-label"),z=q.getAttribute("role"),Q=j.getAttribute("aria-label")||j.textContent?.trim().replace(/\s+/g," ").slice(0,80)||"item";if(q.setAttribute("tabindex","0"),q.setAttribute("aria-label",`Move ${Q}`),q!==j&&!q.hasAttribute("role"))q.setAttribute("role","button");let W=(U)=>{if(this.#O)return;let M=this.#N==="horizontal",Y=M?"ArrowLeft":"ArrowUp",k=M?"ArrowRight":"ArrowDown";if(U.key!==Y&&U.key!==k&&U.key!=="Home"&&U.key!=="End")return;U.preventDefault(),U.stopPropagation();let _=this.#W(),B=_.indexOf(j),N=B;if(U.key===Y)N=Math.max(0,B-1);else if(U.key===k)N=Math.min(_.length-1,B+1);else if(U.key==="Home")N=0;else if(U.key==="End")N=_.length-1;if(N===B){this.#C(`${Q}, position ${B+1} of ${_.length}`);return}this.#j(j,N),this.#G(),this.#F(j)?.focus(),this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:B,newIndex:N,item:j}})),this.#C(`${Q}, position ${N+1} of ${_.length}`)};q.addEventListener("pointerdown",J,!0),q.addEventListener("keydown",W),this.#U.set(j,{target:q,onPointerDown:J,onKeyDown:W,originalTabIndex:Z,originalAriaLabel:$,originalRole:z})}#w(j){let{target:q,originalTabIndex:J,originalAriaLabel:Z,originalRole:$}=j;if(J===null)q.removeAttribute("tabindex");else q.setAttribute("tabindex",J);if(Z===null)q.removeAttribute("aria-label");else q.setAttribute("aria-label",Z);if($===null)q.removeAttribute("role");else q.setAttribute("role",$)}#x(){if(this.#J?.isConnected)return;let j=document.createElement("span");j.setAttribute("data-reorder-live",""),j.setAttribute("role","status"),j.setAttribute("aria-live","polite"),j.setAttribute("aria-atomic","true"),Object.assign(j.style,{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}),this.#J=j,document.body.appendChild(j)}#C(j){if(!this.#J)return;this.#J.textContent="",requestAnimationFrame(()=>{if(this.#J)this.#J.textContent=j})}#R(j,q){let J=j;while(J&&J!==q){if(J instanceof Element){for(let Z of P.#$)if(J.matches(Z))return!0}J=J.parentElement}return!1}static#u="fig-reorder-dragging";static#v(j){document.body.classList.toggle(P.#u,j)}#S(j,q,J){this.#m();let Z={item:q,target:J,pointerId:j.pointerId,oldIndex:this.#W().indexOf(q),targetIndex:this.#W().indexOf(q),startX:j.clientX,startY:j.clientY,active:!1,onMove:null,onUp:null,onKeyDown:null};Z.onMove=($)=>{if($.pointerId!==Z.pointerId)return;let z=$.clientX-Z.startX,Q=$.clientY-Z.startY;if(!Z.active){if(z*z+Q*Q<P.#q*P.#q)return;Z.active=!0,j.preventDefault(),j.stopPropagation(),q.classList.add("dragging"),P.#v(!0);try{J.setPointerCapture(Z.pointerId)}catch{}}$.preventDefault();let W=this.#N==="horizontal"?$.clientX:$.clientY,U=this.#p(W);Z.targetIndex=U,this.#qj(U,q)},Z.onKeyDown=($)=>{if($.key!=="Escape"||!Z.active)return;$.preventDefault(),this.#s(Z,!0)},Z.onUp=($)=>{if($.pointerId!==Z.pointerId)return;this.#s(Z,$.type==="pointercancel")},this.#Z=Z,window.addEventListener("pointermove",Z.onMove),window.addEventListener("pointerup",Z.onUp),window.addEventListener("pointercancel",Z.onUp),window.addEventListener("keydown",Z.onKeyDown)}#p(j){let q=this.#W(),J=this.#N==="horizontal";for(let Z=0;Z<q.length;Z++){let $=q[Z].getBoundingClientRect(),z=J?$.left+$.width/2:$.top+$.height/2;if(j<z)return Z}return q.length}#g(j,q){let J=this.#W(),Z=J.indexOf(j);if(Z===-1)return!1;let $=Math.max(0,Math.min(q,J.length));if(q===Z)return!1;if($>=J.length&&Z===J.length-1)return!1;return!0}#D(j){if(!j.length)return null;let q=1/0,J=-1/0,Z=1/0,$=-1/0;for(let z of j){let Q=z.getBoundingClientRect();q=Math.min(q,Q.left),J=Math.max(J,Q.right),Z=Math.min(Z,Q.top),$=Math.max($,Q.bottom)}return{left:q,top:Z,width:J-q,height:$-Z}}#jj(){if(this.#M)return this.#M;let j=document.createElement("div");return j.className="fig-reorder-indicator",j.setAttribute("data-axis",this.#N),document.body.appendChild(j),this.#M=j,j}#qj(j,q){let J=this.#W();if(!this.#g(q,j)){this.#h();return}let Z=this.#D(J);if(!Z){this.#h();return}let $=this.#jj();if($.setAttribute("data-axis",this.#N),this.#N==="horizontal"){let Q;if(j<=0)Q=J[0].getBoundingClientRect().left;else if(j>=J.length)Q=J[J.length-1].getBoundingClientRect().right;else Q=J[j].getBoundingClientRect().left;$.style.left=`${Q-1}px`,$.style.top=`${Z.top}px`,$.style.width="2px",$.style.height=`${Z.height}px`;return}let z;if(j<=0)z=J[0].getBoundingClientRect().top;else if(j>=J.length)z=J[J.length-1].getBoundingClientRect().bottom;else z=J[j].getBoundingClientRect().top;$.style.left=`${Z.left}px`,$.style.top=`${z-1}px`,$.style.width=`${Z.width}px`,$.style.height="2px"}#h(){this.#M?.remove(),this.#M=null}#T(j,q){let J=this.#W(),Z=Math.max(0,Math.min(q,J.length));if(Z>=J.length){let z=J[J.length-1];if(z&&z!==j)z.after(j);return}let $=J[Z];if($!==j)this.insertBefore(j,$)}#j(j,q){let J=this.#W().filter(($)=>$!==j),Z=J[q]??null;if(Z)this.insertBefore(j,Z);else if(J.length)J[J.length-1].after(j);else this.appendChild(j)}#s(j,q){let{item:J,oldIndex:Z,active:$,onMove:z,onUp:Q,onKeyDown:W}=j;if(window.removeEventListener("pointermove",z),window.removeEventListener("pointerup",Q),window.removeEventListener("pointercancel",Q),window.removeEventListener("keydown",W),$){if(!q){this.#T(J,j.targetIndex);let U=this.#W().indexOf(J);if(U!==-1&&U!==Z){this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:Z,newIndex:U,item:J}}));let M=J.getAttribute("aria-label")||J.textContent?.trim().replace(/\s+/g," ").slice(0,80)||"item";this.#C(`${M}, position ${U+1} of ${this.#W().length}`)}}}if(J.classList.remove("dragging"),P.#v(!1),this.#h(),this.#Z===j)this.#Z=null}#E(){for(let[,j]of this.#U)j.target.removeEventListener("pointerdown",j.onPointerDown,!0),j.target.removeEventListener("keydown",j.onKeyDown),this.#w(j);this.#U.clear()}#m(){if(!this.#Z)return;this.#s(this.#Z,!0)}}T("fig-reorder",P);
|