@rogieking/figui3 6.14.1 → 6.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -9
- package/components.css +0 -1
- package/dist/fig-editor.css +1 -1
- package/dist/fig-lab.css +1 -1
- package/dist/fig-lab.js +16 -16
- package/fig-lab.css +430 -59
- package/fig-lab.js +855 -59
- package/package.json +1 -1
package/dist/fig-lab.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
function D(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class I extends HTMLElement{#Q=null;#Z=null;#J=null;#j=!1;#B=null;#O=new Set;#K=0;#_=0;#X=null;#$=null;#Y=0;#f=null;#N=!1;#U=0;#P=null;#G=0;#k=null;#z=null;#T=null;#q=this.#o.bind(this);#C=this.#p.bind(this);#R=this.#d.bind(this);#H=this.#$J.bind(this);#M=this.#e.bind(this);#V=this.#s.bind(this);#g=new Set(["variant","color","text","full","elastic","size","name","class","data-wave-index","data-active","data-elastic-dragging","style"]);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Q)this.#L();if(this.#W(),this.#S(),this.#QJ(),this.#x(),this.removeEventListener("pointerdown",this.#q,{capture:!0}),this.addEventListener("pointerdown",this.#q,{capture:!0,passive:!0}),this.removeEventListener("contextmenu",this.#M),this.addEventListener("contextmenu",this.#M),!this.#B)this.#B=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J)if($.type==="attributes"){if($.attributeName&&this.#g.has($.attributeName))continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#W();if(Z)this.#S(),this.#x()});this.#B.observe(this,{attributes:!0})}disconnectedCallback(){if(this.#B?.disconnect(),this.#K)cancelAnimationFrame(this.#K),this.#K=0;if(this.#_)cancelAnimationFrame(this.#_),this.#_=0;this.#i(),this.#m(),this.#h(),this.#y(),this.#ZJ(),this.removeEventListener("pointerdown",this.#q,{capture:!0}),this.removeEventListener("contextmenu",this.#M),this.#$?.removeEventListener("change",this.#V)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction")this.#W()}#L(){let J=Array.from(this.childNodes).filter((j)=>{return j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())}),Q=J.find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-slider");_.setAttribute("text","true");for(let j of this.#b()){let X=this.getAttribute(j);_.setAttribute(j,X??"")}Z.append($,_),this.#Q=Z,this.#Z=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z),this.#D();for(let j of J){if(j===Q)continue;this.#J.appendChild(j)}}#D(){let J=document.createElement("fig-menu");J.setAttribute("position","bottom left"),J.setAttribute("offset","0 0");let Q=document.createElement("fig-menu-item");Q.setAttribute("value","reset-default"),Q.textContent="Reset to default",J.appendChild(Q),J.addEventListener("change",this.#V),this.#$=J,this.appendChild(J)}#W(){if(!this.#Q||!this.#Z)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()===""){if(this.#Z.parentElement===this.#Q)this.#Z.remove()}else{if(!this.#j)this.#Z.textContent=J?Q??"":"Label";if(this.#Z.parentElement!==this.#Q)this.#Q.prepend(this.#Z)}this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#S(){if(!this.#J)return;let J=this.#b(),Q=new Set(J.filter(($)=>$!=="text"));for(let $ of this.#O)if(!Q.has($))this.#J.removeAttribute($);for(let $ of J){if($==="text")continue;let _=this.getAttribute($);this.#J.setAttribute($,_??"")}this.#J.removeAttribute("variant"),this.#J.removeAttribute("color"),this.#J.removeAttribute("transform"),this.#J.removeAttribute("full"),this.#J.setAttribute("text","true");let Z=(this.getAttribute("type")||"range").toLowerCase();if(Z==="delta"||Z==="stepper")this.#J.setAttribute("default",this.getAttribute("default")??"50");else if(!this.hasAttribute("default"))this.#J.removeAttribute("default");if(Z==="stepper")this.#J.setAttribute("step",this.getAttribute("step")??"10");else if(!this.hasAttribute("step"))this.#J.removeAttribute("step");if(Z==="opacity")this.#J.style.setProperty("--color","light-dark(#444444, #e6e6e6)");else this.#J.style.removeProperty("--color");this.#O=Q,this.#I()}#b(){let J=new Set(["label","direction","oninput","onchange","steppers"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!this.#g.has(Q))}#I(){if(this.#K)cancelAnimationFrame(this.#K);this.#K=requestAnimationFrame(()=>{this.#K=0,this.#n(),this.#E()})}#x(){if(this.#_)cancelAnimationFrame(this.#_);this.#_=requestAnimationFrame(()=>{this.#_=0,this.#E()})}#E(){let J=this.#J?.querySelector('input[type="range"]'),Q=this.#J?.querySelector("fig-input-number input");if(J!==this.#X)this.#c(J);J?.removeAttribute("tabindex"),Q?.setAttribute("tabindex","-1")}#c(J){if(this.#y(),this.#X=J,!this.#X)return;this.#X.addEventListener("dblclick",this.#H,{capture:!0})}#y(){if(!this.#X)return;this.#X.removeEventListener("dblclick",this.#H,{capture:!0}),this.#X=null}#$J(J){J.preventDefault(),J.stopImmediatePropagation(),this.#t()}#o(J){if(J.button!==0||D(this,"disabled"))return;if(this.getAttribute("elastic")==="false")return;if(J.target?.closest?.("fig-input-number"))return;let Q=this.#J?.querySelector('input[type="range"]')??this.#X;if(!Q)return;this.#m(),this.#h(),this.#X=Q,this.#N=!0,this.#k=J.pointerId,this.#U=this.#JJ();let Z=Q.getBoundingClientRect(),$=this.getBoundingClientRect();this.#P={left:Z.left,right:Z.right,width:Z.width},this.#G=$.width,window.addEventListener("pointermove",this.#C,{passive:!0}),window.addEventListener("pointerup",this.#R,{once:!0}),window.addEventListener("pointercancel",this.#R,{once:!0}),window.addEventListener("blur",this.#R,{once:!0})}#p(J){if(!this.#N)return;if(J.pointerId!==this.#k)return;if(J.buttons===0){this.#d(J);return}this.#BJ(J.clientX)}#d(J){if(J?.pointerId!==void 0&&this.#k!==null&&J.pointerId!==this.#k)return;this.#m(),this.#h()}#m(){window.removeEventListener("pointermove",this.#C),window.removeEventListener("pointerup",this.#R),window.removeEventListener("pointercancel",this.#R),window.removeEventListener("blur",this.#R),this.#N=!1,this.#k=null}#e(J){if(D(this,"disabled"))return;J.preventDefault(),J.stopPropagation(),J.stopImmediatePropagation(),this.#i(),this.#XJ(J.clientX,J.clientY)}#XJ(J,Q){let Z=!1,$=0,_=()=>{if(Z)return;Z=!0,window.clearTimeout($),window.removeEventListener("pointerup",_,!0),window.removeEventListener("pointercancel",_,!0),requestAnimationFrame(()=>{this.#$?.showAt?.(J,Q)})};window.addEventListener("pointerup",_,{once:!0,capture:!0}),window.addEventListener("pointercancel",_,{once:!0,capture:!0}),$=window.setTimeout(_,180)}#s(J){if(J.stopPropagation(),J.detail?.value!=="reset-default")return;this.#t()}#i(){if(this.#Y)clearTimeout(this.#Y),this.#Y=0;this.#f=null}#JJ(){let J=getComputedStyle(this).getPropertyValue("--fig-field-slider-elastic-distance").trim();if(J.includes("var(")||!J.endsWith("px")){let Z=document.createElement("div");Object.assign(Z.style,{position:"absolute",visibility:"hidden",pointerEvents:"none",width:"var(--fig-field-slider-elastic-distance)"}),this.appendChild(Z),J=getComputedStyle(Z).width,Z.remove()}let Q=Number.parseFloat(J);return Number.isFinite(Q)?Math.max(0,Q):0}#BJ(J){let Q=this.#P;if(!Q||!this.#U){this.#h();return}let Z=J<Q.left?J-Q.left:J>Q.right?J-Q.right:0;if(!Z){this.#a();return}let $=Math.max(-this.#U,Math.min(this.#U,Z*0.5)),_=Math.abs($),j=this.#G?(this.#G+_)/this.#G:1;this.dataset.elasticDragging="true",this.style.setProperty("--fig-field-slider-elastic-size",`${_}px`),this.style.setProperty("--fig-field-slider-elastic-scale",`${j}`),this.style.setProperty("--fig-field-slider-elastic-origin",$<0?"right center":"left center")}#h(){this.#a(),this.#U=0,this.#P=null,this.#G=0,this.#k=null}#a(){this.removeAttribute("data-elastic-dragging"),this.style.removeProperty("--fig-field-slider-elastic-size"),this.style.removeProperty("--fig-field-slider-elastic-scale")}#KJ(J){let Q=this.#X;if(!Q)return this.#J?.value??"";let Z=Q.getBoundingClientRect(),$=Z.width?Math.min(1,Math.max(0,(J.clientX-Z.left)/Z.width)):0,_=Number(Q.min||0),j=Number(Q.max||100),X=Q.step==="any"?0:Number(Q.step||1),G=_+(j-_)*$;if(!X)return String(G);let B=Math.round((G-_)/X)*X+_,K=Math.max(0,`${X}`.split(".")[1]?.length||0);return String(Number(B.toFixed(K)))}#v(){return this.getAttribute("default")??this.#J?.getAttribute("default")??this.getAttribute("value")??this.#J?.getAttribute("value")??this.#X?.min??"0"}#t(){this.#i(),this.#r(this.#v(),"input"),this.#r(this.#v(),"change")}#r(J,Q){if(!this.#J||J===null||J===void 0)return;this.#J.value=J,this.dispatchEvent(new CustomEvent(Q,{detail:this.#J.value,bubbles:!0,cancelable:!0,composed:!0}))}#n(){if(!this.#J)return;let J=this.#J.querySelector("fig-input-number");if(!J)return;if(!(this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false")){J.removeAttribute("steppers");return}let Z=this.getAttribute("steppers");J.setAttribute("steppers",Z??"")}#QJ(){if(!this.#J)return;if(!this.#z)this.#z=this.#_J.bind(this,"input");if(!this.#T)this.#T=this.#_J.bind(this,"change");this.#J.addEventListener("input",this.#z),this.#J.addEventListener("change",this.#T)}#ZJ(){if(!this.#J)return;if(this.#z)this.#J.removeEventListener("input",this.#z);if(this.#T)this.#J.removeEventListener("change",this.#T)}#_J(J,Q){if(Q.stopImmediatePropagation(),J==="change")this.#h();let Z=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:this.#J?.value;this.dispatchEvent(new CustomEvent(J,{detail:Z,bubbles:!0,cancelable:!0,composed:!0}))}focus(J){this.#J?.querySelector('input[type="range"]')?.focus(J)}resetToDefault(){this.#t()}}customElements.define("fig-field-slider",I);class E extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping"];#Q=50;#Z=50;#J=75;#j=75;#B=0;#O=!1;#K=0;#_=null;#X=null;#$=null;#Y=null;#f=null;#N=null;#U=null;#P=null;#G=null;#k=!1;#z=!1;#T=!1;#q=!1;#C=null;#R="";#H="";#M=null;get#V(){return this.getAttribute("type")||"point"}get#g(){return this.#V==="point-radius"||this.#V==="point-radius-angle"}get#L(){return this.#V==="point-radius-angle"}get#D(){return this.#V==="point-point"}get#W(){return this.#V==="point-radius-angle"||this.#V==="point-point"}get#S(){let J=this.getAttribute("tooltips");return J===null||J!=="false"}get#b(){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"}#I(J){let Q=this.#b;if(Q==="true")return!0;if(Q==="modifier")return!!J;return!1}get#x(){let J=this.getAttribute("name");if(J)return J.split(",")[0].trim();return`${Math.round(this.#Q)}%, ${Math.round(this.#Z)}%`}get#E(){let J=this.getAttribute("name");if(J){let Q=J.split(",");if(Q.length>1)return Q[1].trim()}return`${Math.round(this.#J)}%, ${Math.round(this.#j)}%`}get#c(){return this.getAttribute("drag-surface")||"parent"}get#y(){let J=this.#c;if(J==="parent")return this.parentElement;return this.closest(J)}get#$J(){let J=this.#c;if(J==="parent"){let Q=this.parentElement;if(Q)return Q.setAttribute("data-fig-canvas-control-surface",""),"[data-fig-canvas-control-surface]"}return J}#o(J){if(this.#O)return this.#B/100*J;return this.#B}#p(){if(this.#O)return`Radius ${Math.round(this.#B)}%`;return`Radius ${Math.round(this.#B)}`}connectedCallback(){this.#d(),this.#m()}disconnectedCallback(){this.#NJ(),this.#s(),document.body.classList.remove("fig-lab-move-active")}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"&&!this.#k&&!this.#z&&!this.#T&&!this.#q)if(this.#d(),this.#_)this.#A();else this.#m();if(J==="type")this.#d(),this.#m();if(J==="color"&&this.#_)if(Z)this.#_.setAttribute("color",Z);else this.#_.removeAttribute("color");if(J==="disabled")this.#m();if(J==="tooltips")this.#m();if(J==="snapping"&&this.#_){if(this.#_.setAttribute("drag-snapping",Z||"false"),this.#X)this.#X.setAttribute("drag-snapping",Z||"false")}if(J==="name"){if(this.#N)this.#N.setAttribute("text",this.#x);if(this.#U)this.#U.setAttribute("text",this.#E)}}#d(){let J=this.getAttribute("value");if(!J)return;try{let Q=JSON.parse(J);if(typeof Q.x==="number")this.#Q=Q.x;if(typeof Q.y==="number")this.#Z=Q.y;if(Q.radius!==void 0){let Z=String(Q.radius);if(Z.endsWith("%"))this.#O=!0,this.#B=parseFloat(Z);else this.#O=!1,this.#B=parseFloat(Z);if(!Number.isFinite(this.#B))this.#B=0}if(typeof Q.angle==="number")this.#K=Q.angle;if(typeof Q.x2==="number")this.#J=Q.x2;if(typeof Q.y2==="number")this.#j=Q.y2}catch{}}get value(){let J={x:this.#Q,y:this.#Z};if(this.#V==="color"){let Q=this.getAttribute("color")||this.#_?.getAttribute("color");if(Q)J.color=Q}if(this.#g)J.radius=this.#O?`${this.#B}%`:this.#B;if(this.#L)J.angle=this.#K;if(this.#D)J.x2=this.#J,J.y2=this.#j;return J}set value(J){if(typeof J==="object")this.setAttribute("value",JSON.stringify(J));else if(typeof J==="string")this.setAttribute("value",J)}#m(){this.innerHTML="",this.#_=null,this.#X=null,this.#$=null,this.#Y=null,this.#f=null,this.#N=null,this.#U=null,this.#P=null,this.#G=null;let J=D(this,"disabled"),Q=this.#V,Z=this.#S,$=this.#$J,_=document.createElement("fig-handle");if(_.setAttribute("drag","true"),_.setAttribute("drag-surface",$),_.setAttribute("drag-axes","x,y"),_.setAttribute("drag-snapping",this.#b),_.setAttribute("value",`${this.#Q}% ${this.#Z}%`),J)_.setAttribute("disabled","");if(Q==="color"){_.setAttribute("type","color");let j=this.getAttribute("color");if(j)_.setAttribute("color",j)}else _.setAttribute("type","canvas");if(this.#D)_.setAttribute("hit-area","12 circle"),_.setAttribute("hit-area-mode","delegate");if(this.#_=_,this.#g)this.#KJ();if(this.#W)this.#v();if(Z){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#x),j.appendChild(_),this.appendChild(j),this.#N=j}else this.appendChild(_);if(this.#L)this.#r(J,Z,$);if(this.#D)this.#n(J,Z,$);this.#e(this.#_),this.#e(this.#$),this.#e(this.#X),this.#OJ(),this.#BJ(),requestAnimationFrame(()=>this.#A())}#e(J){if(!J)return;J.addEventListener("pointerdown",(Q)=>this.#XJ(Q),{capture:!0})}#XJ(J){if(D(this,"disabled"))return;if(J?.button!==void 0&&J.button!==0)return;if(J?.isPrimary===!1)return;if(this.#C===null)this.#R=document.body.style.getPropertyValue("cursor"),this.#H=document.body.style.getPropertyPriority("cursor");if(this.#C=J?.pointerId??-1,document.body.classList.add("fig-lab-move-active"),document.body.style.setProperty("cursor","var(--fig-lab-cursor-move)","important"),!this.#M)this.#M=(Q)=>{if(Q?.pointerId!==void 0&&this.#C!==null&&Q.pointerId!==this.#C)return;if(Q?.type==="blur")this.#s();else requestAnimationFrame(()=>this.#s())};window.addEventListener("pointerup",this.#M),window.addEventListener("pointercancel",this.#M),window.addEventListener("blur",this.#M)}#s(){if(this.#C===null)return;if(document.body.classList.remove("fig-lab-move-active"),this.#R)document.body.style.setProperty("cursor",this.#R,this.#H);else document.body.style.removeProperty("cursor");if(this.#C=null,this.#R="",this.#H="",this.#M)window.removeEventListener("pointerup",this.#M),window.removeEventListener("pointercancel",this.#M),window.removeEventListener("blur",this.#M)}#i(J,Q,Z,$){if(!J)return;let _=()=>!!$?.(),j=()=>{let B=Q();if(!B)return;B.removeAttribute("show"),B.hidePopup?.()},X=()=>{if(_()){j();return}let B=Q();if(!B)return;if(Z)B.setAttribute("text",Z());B.setAttribute("show","true"),B.showPopup?.()},G=()=>{j()};J.addEventListener("pointerenter",X),J.addEventListener("pointerleave",G)}#JJ(){return this.#k||this.#z||this.#T||this.#q}#BJ(){if(this.#_)this.#i(this.#_,()=>this.#N,()=>this.#x,()=>this.#JJ()||!!this.#_?.querySelector("fig-color-tip"));if(this.#$)this.#i(this.#$,()=>this.#G,()=>`Angle ${Math.round(this.#K)}°`,()=>this.#JJ());if(this.#X)this.#i(this.#X,()=>this.#U,()=>this.#E,()=>this.#JJ());if(this.#Y){let J=this.#Y.querySelector(".fig-canvas-control-radius-hit");this.#a(J||this.#Y)}if(this.#V==="color"&&this.#_&&this.#N)new MutationObserver(()=>{if(this.#_?.querySelector("fig-color-tip"))this.#N?.removeAttribute("show"),this.#N?.hidePopup?.()}).observe(this.#_,{childList:!0,subtree:!0})}#h(J,Q){let Z=this.#P;if(!Z?.popup)return;let $=Q-8;Z.popup.anchor={getBoundingClientRect:()=>({left:J,top:$,right:J,bottom:$,width:0,height:0,x:J,y:$})},Z.popup.queueReposition?.()}#a(J){if(!J)return;J.addEventListener("pointerenter",(Q)=>{let Z=this.#P;if(!Z)return;Z.setAttribute("text",this.#p()),Z.setAttribute("show","true"),Z.showPopup?.(),this.#h(Q.clientX,Q.clientY)}),J.addEventListener("pointermove",(Q)=>{if(this.#T)return;this.#h(Q.clientX,Q.clientY)}),J.addEventListener("pointerleave",()=>{if(this.#T)return;let Q=this.#P;if(!Q)return;Q.removeAttribute("show")})}#KJ(){let Q=document.createElementNS("http://www.w3.org/2000/svg","svg");Q.classList.add("fig-canvas-control-radius"),Q.setAttribute("overflow","visible");let Z=document.createElementNS("http://www.w3.org/2000/svg","circle");Z.classList.add("fig-canvas-control-radius-hit"),Q.appendChild(Z);let $=document.createElementNS("http://www.w3.org/2000/svg","circle");$.classList.add("fig-canvas-control-radius-halo"),Q.appendChild($);let _=document.createElementNS("http://www.w3.org/2000/svg","circle");if(Q.appendChild(_),this.#Y=Q,this.#S){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#p()),j.appendChild(Q),this.appendChild(j),this.#P=j}else this.appendChild(Q);this.#kJ(Z)}#v(){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.#t(_)}let Z=document.createElementNS("http://www.w3.org/2000/svg","line");Z.classList.add("fig-canvas-control-angle-line-halo"),Q.appendChild(Z);let $=document.createElementNS("http://www.w3.org/2000/svg","line");$.classList.add("fig-canvas-control-angle-line"),Q.appendChild($),this.#f=Q,this.appendChild(Q)}#t(J){J.addEventListener("pointerdown",(Q)=>{if(D(this,"disabled"))return;Q.preventDefault(),Q.stopPropagation();let Z=this.#y;if(!Z)return;let $=Z.getBoundingClientRect(),_=Q.clientX,j=Q.clientY,X=this.#Q,G=this.#Z,B=this.#J,K=this.#j;this.#k=!0,this.#z=!0,document.body.classList.add("fig-lab-move-active"),J.style.pointerEvents="none";let O=(N)=>{let P=Z.getBoundingClientRect(),S=P.width>0?(N.clientX-_)/P.width*100:0,k=P.height>0?(N.clientY-j)/P.height*100:0,L=-Math.min(X,B),V=100-Math.max(X,B),R=-Math.min(G,K),U=100-Math.max(G,K),M=Math.max(L,Math.min(V,S)),z=Math.max(R,Math.min(U,k));this.#Q=X+M,this.#Z=G+z,this.#J=B+M,this.#j=K+z,this.#A(),this.#F()},Y=()=>{document.body.classList.remove("fig-lab-move-active"),J.style.pointerEvents="stroke",this.#w(),this.#l(),window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",Y),requestAnimationFrame(()=>{this.#k=!1,this.#z=!1})};window.addEventListener("pointermove",O),window.addEventListener("pointerup",Y)})}#r(J,Q,Z){let $=document.createElement("fig-handle");if($.setAttribute("type","canvas"),$.setAttribute("drag","true"),$.setAttribute("drag-surface",Z),$.setAttribute("drag-axes","x,y"),$.setAttribute("size","small"),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),J)$.setAttribute("disabled","");if(this.#$=$,Q){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",`${Math.round(this.#K)}°`),_.appendChild($),this.appendChild(_),this.#G=_}else this.appendChild($)}#n(J,Q,Z){let $=document.createElement("fig-handle");if($.setAttribute("type","canvas"),$.setAttribute("drag","true"),$.setAttribute("drag-surface",Z),$.setAttribute("drag-axes","x,y"),$.setAttribute("drag-snapping",this.#b),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),$.setAttribute("value",`${this.#J}% ${this.#j}%`),J)$.setAttribute("disabled","");if(this.#X=$,Q){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#E),_.appendChild($),this.appendChild(_),this.#U=_}else this.appendChild($)}#QJ(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`}#ZJ(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`}#_J(){if(!this.#$||!this.#L)return;let J=this.#$.querySelector(".fig-handle-hit-area");if(!J)return;J.style.cursor=this.#ZJ(this.#K)}#qJ(){return Math.atan2(this.#j-this.#Z,this.#J-this.#Q)*180/Math.PI}#PJ(){if(!this.#D)return;let J=this.#qJ(),Q=(Z,$)=>{if(!Z)return;let _=Z.querySelector(".fig-handle-hit-area");if(_)_.style.cursor=this.#ZJ($)};Q(this.#_,J+180),Q(this.#X,J)}#jJ(J,Q,Z,$){J.style.setProperty("--fig-handle-position-translate","-50% -50%"),J.style.left=`${Q/100*$.width}px`,J.style.top=`${Z/100*$.height}px`}#A(){let J=this.#y;if(!J||!this.#_)return;let Q=J.getBoundingClientRect();if(this.#jJ(this.#_,this.#Q,this.#Z,Q),this.#Y){let Z=this.#Q/100*Q.width,$=this.#Z/100*Q.height,_=this.#o(Q.width),j=this.#Y,X=Math.max(_*2,1);j.style.position="absolute",j.style.width=`${X}px`,j.style.height=`${X}px`,j.style.left=`${Z-_}px`,j.style.top=`${$-_}px`,j.setAttribute("viewBox",`0 0 ${X} ${X}`);let G=j.querySelectorAll("circle");for(let B of G)B.setAttribute("cx",String(_)),B.setAttribute("cy",String(_)),B.setAttribute("r",String(Math.max(_-1,0)))}if(this.#f&&this.#W){let Z=this.#Q/100*Q.width,$=this.#Z/100*Q.height,_,j;if(this.#D)_=this.#J/100*Q.width,j=this.#j/100*Q.height;else{let B=this.#o(Q.width),K=this.#K*Math.PI/180;_=Z+B*Math.cos(K),j=$+B*Math.sin(K)}let X=this.#f;X.style.width=`${Q.width}px`,X.style.height=`${Q.height}px`,X.style.left="0",X.style.top="0",X.setAttribute("viewBox",`0 0 ${Q.width} ${Q.height}`);let G=X.querySelectorAll(".fig-canvas-control-angle-line, .fig-canvas-control-angle-line-halo");for(let B of G)B.setAttribute("x1",String(Z)),B.setAttribute("y1",String($)),B.setAttribute("x2",String(_)),B.setAttribute("y2",String(j))}if(this.#$&&this.#L){let Z=this.#Q/100*Q.width,$=this.#Z/100*Q.height,_=this.#o(Q.width),j=this.#K*Math.PI/180,X=Z+_*Math.cos(j),G=$+_*Math.sin(j),B=Q.width>0?X/Q.width*100:0,K=Q.height>0?G/Q.height*100:0;this.#jJ(this.#$,B,K,Q)}if(this.#X&&this.#D)this.#jJ(this.#X,this.#J,this.#j,Q);this.#_J(),this.#PJ()}#F(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#l(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}#w(){this.setAttribute("value",JSON.stringify(this.value))}#OJ(){if(!this.#_)return;if(this.#_.addEventListener("input",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#F();return}this.#k=!0;let Q=J.detail?.px??this.#Q/100,Z=J.detail?.py??this.#Z/100;if(this.#Q=Math.round(Math.max(0,Math.min(100,Q*100))),this.#Z=Math.round(Math.max(0,Math.min(100,Z*100))),this.#N)this.#N.removeAttribute("show"),this.#N.hidePopup?.();this.#A(),this.#F()}),this.#_.addEventListener("change",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#l();return}let Q=J.detail?.px??this.#Q/100,Z=J.detail?.py??this.#Z/100;if(this.#Q=Math.round(Math.max(0,Math.min(100,Q*100))),this.#Z=Math.round(Math.max(0,Math.min(100,Z*100))),this.#N)this.#N.removeAttribute("show");this.#A(),this.#w(),this.#l(),requestAnimationFrame(()=>{this.#k=!1})}),this.#$)this.#$.addEventListener("input",(J)=>{J.stopPropagation();let Q=this.#y;if(!Q)return;this.#q=!0,this.classList.add("fig-canvas-control-ring-active");let Z=Q.getBoundingClientRect(),$=this.#Q/100*Z.width,_=this.#Z/100*Z.height,j=J.detail?.x??0,X=J.detail?.y??0,G=this.#$.offsetWidth/2,B=this.#$.offsetHeight/2,K=j+G-$,O=X+B-_,Y=Math.atan2(O,K)*180/Math.PI;if(this.#I(J.detail?.shiftKey))Y=Math.round(Y/15)*15;this.#K=Y;let N=Math.sqrt(K*K+O*O);if(this.#I(J.detail?.shiftKey)){let P=this.#O?5:10;if(this.#O){let S=N/Z.width*100;S=Math.round(S/P)*P,N=S/100*Z.width}else N=Math.round(N/P)*P}if(this.#O)this.#B=Math.max(0,N/Z.width*100);else this.#B=Math.max(0,N);if(this.#G)this.#G.setAttribute("text",`Angle ${Math.round(this.#K)}°`),this.#G.setAttribute("show","true"),this.#G.showPopup?.();this.#A(),this.#F()}),this.#$.addEventListener("change",(J)=>{if(J.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#G)this.#G.removeAttribute("show");this.#A(),this.#w(),this.#l(),requestAnimationFrame(()=>{this.#q=!1})}),this.#$.addEventListener("hitareadown",(J)=>{J.stopPropagation();let Q=J.detail?.originalEvent;if(!Q)return;Q.preventDefault();let Z=this.#y;if(!Z)return;if(this.#q=!0,this.classList.add("fig-canvas-control-ring-active"),this.#$.setAttribute("selected",""),this.#G)this.#G.setAttribute("show","true"),this.#G.showPopup?.();let $=(j)=>{let X=Z.getBoundingClientRect(),G=this.#Q/100*X.width,B=this.#Z/100*X.height,K=j.clientX-X.left-G,O=j.clientY-X.top-B,Y=Math.atan2(O,K)*180/Math.PI;if(this.#I(j.shiftKey))Y=Math.round(Y/15)*15;if(this.#K=Y,this.#G)this.#G.setAttribute("text",`Angle ${Math.round(Y)}°`);this.#A(),this.#F()},_=()=>{if(this.#q=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#$.removeAttribute("selected"),this.#G)this.#G.removeAttribute("show");this.#w(),this.#l(),window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",_)};window.addEventListener("pointermove",$),window.addEventListener("pointerup",_)});if(this.#X)this.#X.addEventListener("input",(J)=>{J.stopPropagation(),this.#z=!0;let Q=J.detail?.px??this.#J/100,Z=J.detail?.py??this.#j/100;if(this.#J=Math.round(Math.max(0,Math.min(100,Q*100))),this.#j=Math.round(Math.max(0,Math.min(100,Z*100))),this.#U)this.#U.removeAttribute("show"),this.#U.hidePopup?.();this.#A(),this.#F()}),this.#X.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#U)this.#U.removeAttribute("show");this.#A(),this.#w(),this.#l(),requestAnimationFrame(()=>{this.#z=!1})}),this.#YJ(this.#_,!0),this.#YJ(this.#X,!1)}#YJ(J,Q){if(!J)return;J.addEventListener("hitareadown",(Z)=>{Z.stopPropagation();let $=Z.detail?.originalEvent;if(!$)return;$.preventDefault();let _=this.#y;if(!_)return;this.#k=!0;let j=_.getBoundingClientRect(),X=Q?this.#J:this.#Q,G=Q?this.#j:this.#Z,B=Q?this.#Q:this.#J,K=Q?this.#Z:this.#j,O=X/100*j.width,Y=G/100*j.height,N=B/100*j.width,P=K/100*j.height,S=Math.sqrt((N-O)**2+(P-Y)**2),k=Q?this.#N:this.#U;if(k)k.removeAttribute("show"),k.hidePopup?.();let L=(R)=>{let U=_.getBoundingClientRect(),M=X/100*U.width,z=G/100*U.height,T=R.clientX-U.left-M,f=R.clientY-U.top-z,C=Math.atan2(f,T);if(this.#I(R.shiftKey))C=Math.round(C*180/Math.PI/15)*15*Math.PI/180;let b=M+S*Math.cos(C),y=z+S*Math.sin(C),W=Math.max(0,Math.min(100,b/U.width*100)),H=Math.max(0,Math.min(100,y/U.height*100));if(Q)this.#Q=W,this.#Z=H;else this.#J=W,this.#j=H;this.#A(),this.#F()},V=()=>{if(this.#k=!1,k)k.removeAttribute("show");this.#w(),this.#l(),window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",V)};window.addEventListener("pointermove",L),window.addEventListener("pointerup",V)})}#kJ(J){if(!J)return;J.addEventListener("pointermove",(Z)=>{if(this.#T)return;let $=this.#y;if(!$)return;let _=$.getBoundingClientRect(),j=this.#Q/100*_.width,X=this.#Z/100*_.height,G=Math.atan2(Z.clientY-_.top-X,Z.clientX-_.left-j)*180/Math.PI;J.style.cursor=this.#QJ(G)});let Q=(Z)=>{if(D(this,"disabled"))return;Z.preventDefault(),Z.stopPropagation(),this.#T=!0,this.classList.add("fig-canvas-control-ring-active");let $=this.#y;if(!$)return;if(this.#P)this.#P.setAttribute("show","true"),this.#P.showPopup?.(),this.#h(Z.clientX,Z.clientY);if(this.#G)this.#G.removeAttribute("show"),this.#G.hidePopup?.();let _=this.#$?.style.pointerEvents,j=this.#$?.querySelector(".fig-handle-hit-area"),X=j?.style.pointerEvents;if(this.#$)this.#$.style.pointerEvents="none";if(j)j.style.pointerEvents="none";let G=document.body.style.cursor;J.style.pointerEvents="none";let B=$.getBoundingClientRect(),K=this.#Q/100*B.width,O=this.#Z/100*B.height,Y=Math.atan2(Z.clientY-B.top-O,Z.clientX-B.left-K)*180/Math.PI,N=Math.round(Y);document.body.style.cursor=this.#QJ(N);let P=(k)=>{let L=$.getBoundingClientRect(),V=this.#Q/100*L.width,R=this.#Z/100*L.height,U=k.clientX-L.left-V,M=k.clientY-L.top-R,z=Math.round(Math.atan2(M,U)*180/Math.PI);if(z!==N)N=z,document.body.style.cursor=this.#QJ(z);let T=Math.sqrt(U*U+M*M);if(this.#I(k.shiftKey)){let f=this.#O?5:10;if(this.#O){let C=T/L.width*100;C=Math.round(C/f)*f,T=C/100*L.width}else T=Math.round(T/f)*f}if(this.#O)this.#B=Math.max(0,T/L.width*100);else this.#B=Math.max(0,T);if(this.#P)this.#P.setAttribute("text",this.#p()),this.#h(k.clientX,k.clientY);this.#A(),this.#F()},S=()=>{if(this.#T=!1,this.classList.remove("fig-canvas-control-ring-active"),J.style.pointerEvents="",this.#$)this.#$.style.pointerEvents=_??"";if(j)j.style.pointerEvents=X??"";if(document.body.style.cursor=G,this.#P)this.#P.removeAttribute("show");this.#w(),this.#l(),window.removeEventListener("pointermove",P),window.removeEventListener("pointerup",S)};window.addEventListener("pointermove",P),window.addEventListener("pointerup",S)};J.addEventListener("pointerdown",Q),this._radiusDragCleanup=()=>J.removeEventListener("pointerdown",Q)}#NJ(){if(this._radiusDragCleanup)this._radiusDragCleanup(),this._radiusDragCleanup=null}}customElements.define("fig-canvas-control",E);class q extends HTMLElement{#Q=[q.#H()];#Z=0;#J=2;#j=240;#B=120;#O={min:-1,max:1};#K=null;#_=null;#X=null;#$=null;#Y=0;#f=null;#N=null;#U=null;#P=null;#G=[];#k=[];#z=[];#T=[];#q=new Set;#C=null;#R=null;static TYPES=[{name:"Wave",value:"sine"},{name:"Square",value:"square"},{name:"Sawtooth",value:"sawtooth"},{name:"Triangle",value:"triangle"}];static#H(J="sine"){return{type:J,frequency:1,amplitude:1,phase:0,offset:0}}static get observedAttributes(){return["value","precision","aspect-ratio","edit","disabled"]}connectedCallback(){this.#J=this.#M("precision",2),this.#W(this.getAttribute("value")),this.#D(),this.#p(),this.#h()}disconnectedCallback(){if(this.#K=null,this.#ZJ(),this.#C)this.#C.disconnect(),this.#C=null}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"){if(this.#W(Z),this.isConnected)this.#p();return}if(J==="precision"){if(this.#J=this.#M("precision",2),this.isConnected)this.#GJ();return}if(J==="aspect-ratio"){if(this.#D(),this.#_)this.#n();return}if(J==="edit"||J==="disabled"){if(this.isConnected)this.#p()}}get value(){return JSON.stringify(this.data)}set value(J){this.setAttribute("value",typeof J==="object"&&J!==null?JSON.stringify(J):J)}get data(){return{waves:this.#Q.map((J)=>this.#b(J))}}get preset(){let J=this.#I;return q.TYPES.find((Q)=>Q.value===J.type)?.name}#M(J,Q){let Z=Number.parseInt(this.getAttribute(J)||"",10);return Number.isFinite(Z)?Math.max(0,Math.min(100,Z)):Q}#V(J,Q=!1){let Z=this.getAttribute(J);if(Z===null)return Q;let $=Z.trim().toLowerCase();if($===""||$==="true")return!0;if($==="false")return!1;return!0}#g(){return this.getAttribute("edit")!=="false"}#L(){return this.#V("disabled",!1)}#D(){let J=this.getAttribute("aspect-ratio")||"2 / 1";this.style.setProperty("--aspect-ratio",J)}#W(J){if(!J)return!1;let Q=null;if(typeof J==="string")try{Q=JSON.parse(J)}catch{Q=null}else if(typeof J==="object")Q=J;if(!Q)return!1;let Z=Array.isArray(Q)?Q:Array.isArray(Q.waves)?Q.waves:[Q];if(this.#Q=Z.map(($)=>this.#S($)),!this.#Q.length)this.#Q=[q.#H()];return this.#Z=Math.min(this.#Z,this.#Q.length-1),!0}#S(J={}){return{type:this.#x(J.type),frequency:this.#E(J.frequency,1,0.1,16),amplitude:this.#E(J.amplitude,1,-4,4),phase:this.#E(J.phase,0,-360,360),offset:this.#E(J.offset,0,-4,4)}}#b(J){return{type:J.type,frequency:this.#c(J.frequency),amplitude:this.#c(J.amplitude),phase:this.#c(J.phase),offset:this.#c(J.offset)}}get#I(){if(!this.#Q[this.#Z])this.#Z=0;return this.#Q[this.#Z]||q.#H()}#x(J){let Q=String(J||"").toLowerCase();return q.TYPES.some((Z)=>Z.value===Q)?Q:"sine"}#E(J,Q,Z,$){let _=Number.parseFloat(J);if(!Number.isFinite(_))return Q;return Math.min($,Math.max(Z,_))}#c(J){let Q=10**this.#J;return Math.round(J*Q)/Q}static#y(J){return String(J).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}static#$J(J){return q.TYPES.find((Q)=>Q.value===J)?.name||"Wave"}static waveIcon(J,Q=24){let _=Q-10,j="";for(let X=0;X<=32;X++){let G=X/32,B=q.#o(J,G),K=5+G*_,O=5+(1-(B+1)/2)*_;j+=`${X===0?"M":"L"}${K.toFixed(1)},${O.toFixed(1)}`}return`<svg width="${Q}" height="${Q}" viewBox="0 0 ${Q} ${Q}" fill="none"><path d="${j}" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"/></svg>`}static#o(J,Q,Z=0){let $=Q+Z/360,_=$-Math.floor($),j=$*Math.PI*2;switch(J){case"square":return Math.sin(j)>=0?1:-1;case"sawtooth":return _*2-1;case"triangle":return 1-Math.abs(_*4-2);default:return Math.sin(j)}}#p(){this.#ZJ(),this.innerHTML=this.#d(),this.#i(),this.#a(),this.#n(),this.#A(),this.#QJ()}#d(){let J=this.#L()?" disabled":"";return`<div class="fig-input-oscillator-svg-container">
|
|
2
|
-
<svg viewBox="0 0 ${this.#j} ${this.#
|
|
3
|
-
<rect class="
|
|
4
|
-
<line class="
|
|
5
|
-
<path class="
|
|
6
|
-
<circle class="
|
|
7
|
-
<foreignObject class="
|
|
8
|
-
<foreignObject class="
|
|
1
|
+
function R(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class I extends HTMLElement{#Q=null;#Z=null;#J=null;#j=!1;#X=null;#K=new Set;#B=null;#$=null;static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Q)this.#G();if(this.#_(),this.#k(),this.#Y(),!this.#X)this.#X=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#_();if(Z)this.#k()});this.#X.observe(this,{attributes:!0})}disconnectedCallback(){this.#X?.disconnect(),this.#N()}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction")this.#_()}#G(){let Q=Array.from(this.childNodes).filter((G)=>G.nodeType!==Node.TEXT_NODE||Boolean(G.textContent?.trim())).find((G)=>G.nodeType===Node.ELEMENT_NODE&&G.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-segmented-control"),j=document.createElement("fig-segment"),X=document.createElement("fig-segment");_.setAttribute("sizing","equal"),j.setAttribute("value","off"),j.textContent="Off",X.setAttribute("value","on"),X.textContent="On",_.append(j,X),Z.append($,_),this.#Q=Z,this.#Z=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z)}#_(){if(!this.#Q||!this.#Z)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Z.remove();else{if(!this.#j)this.#Z.textContent=J?Q??"":"Label";if(this.#Z.parentElement!==this.#Q)this.#Q.prepend(this.#Z)}this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#O(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","checked","value"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#k(){if(!this.#J)return;let J=this.#O(),Q=new Set(J);for(let Z of this.#K)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#J.setAttribute("value",R(this,"checked")?"on":"off"),this.#K=Q}#Y(){if(!this.#J)return;this.#B??=this.#q.bind(this,"input"),this.#$??=this.#q.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#$)}#N(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#$)this.#J.removeEventListener("change",this.#$)}#q(J,Q){Q.stopImmediatePropagation();let Z=this.#J?.value==="on";this.toggleAttribute("checked",Z);let $={checked:Z,value:this.getAttribute("value")??""};this.dispatchEvent(new CustomEvent(J,{detail:$,bubbles:!0,cancelable:!0,composed:!0}))}get checked(){return this.#J?this.#J.value==="on":R(this,"checked")}set checked(J){this.toggleAttribute("checked",Boolean(J))}get value(){return this.#J?.value??this.getAttribute("value")??""}set value(J){this.setAttribute("value",J??"")}focus(J){(this.#J?.querySelector("fig-segment[selected]")||this.#J?.querySelector("fig-segment"))?.focus(J)}}customElements.define("propskit-switch",I);class E extends HTMLElement{#Q=null;#Z=null;#J=null;#j=!1;#X=null;#K=new Set;#B=null;#$=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Q)this.#G();if(this.#_(),this.#k(),this.#Y(),!this.#X)this.#X=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction"||$.attributeName==="aria-label")Q=!0;else Z=!0}if(Q)this.#_();if(Z)this.#k()});this.#X.observe(this,{attributes:!0})}disconnectedCallback(){this.#X?.disconnect(),this.#N()}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction"||J==="aria-label")this.#_()}#G(){let J=Array.from(this.childNodes).filter((j)=>j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())),Q=J.find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-dropdown");for(let j of J)if(j!==Q)_.appendChild(j);Z.append($,_),this.#Q=Z,this.#Z=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z)}#_(){if(!this.#Q||!this.#Z||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Z.remove();else{if(!this.#j)this.#Z.textContent=J?Q??"":"Label";if(this.#Z.parentElement!==this.#Q)this.#Q.prepend(this.#Z)}this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("label",this.getAttribute("aria-label")||this.#Z.textContent?.trim()||"Select")}#O(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#k(){if(!this.#J)return;let J=this.#O(),Q=new Set(J);for(let Z of this.#K)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#K=Q}#Y(){if(!this.#J)return;this.#B??=this.#q.bind(this,"input"),this.#$??=this.#q.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#$)}#N(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#$)this.#J.removeEventListener("change",this.#$)}#q(J,Q){Q.stopImmediatePropagation();let Z=this.#J?.value??"";this.setAttribute("value",String(Z));let $=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:Z;this.dispatchEvent(new CustomEvent(J,{detail:$,bubbles:!0,cancelable:!0,composed:!0}))}get value(){return this.#J?.value??this.getAttribute("value")??""}set value(J){if(J===null||J===void 0)this.removeAttribute("value");else this.setAttribute("value",String(J))}focus(J){this.#J?.focus(J)}}customElements.define("propskit-select",E);class A extends HTMLElement{#Q=null;#Z=null;#J=null;#j=!1;#X=null;#K=new Set;#B=null;#$=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Q)this.#G();if(this.#_(),this.#k(),this.#Y(),!this.#X)this.#X=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction"||$.attributeName==="aria-label")Q=!0;else Z=!0}if(Q)this.#_();if(Z)this.#k()});this.#X.observe(this,{attributes:!0})}disconnectedCallback(){this.#X?.disconnect(),this.#N()}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction"||J==="aria-label")this.#_()}#G(){let J=Array.from(this.childNodes).filter((j)=>j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())),Q=J.find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-input-text");for(let j of J)if(j!==Q)_.appendChild(j);Z.append($,_),this.#Q=Z,this.#Z=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z)}#_(){if(!this.#Q||!this.#Z||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Z.remove();else{if(!this.#j)this.#Z.textContent=J?Q??"":"Label";if(this.#Z.parentElement!==this.#Q)this.#Q.prepend(this.#Z)}this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Z.textContent?.trim()||"Text")}#O(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","multiline","resizable"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#k(){if(!this.#J)return;let J=this.#O(),Q=new Set(J);for(let Z of this.#K)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#K=Q}#Y(){if(!this.#J)return;this.#B??=this.#q.bind(this,"input"),this.#$??=this.#q.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#$)}#N(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#$)this.#J.removeEventListener("change",this.#$)}#q(J,Q){Q.stopImmediatePropagation();let Z=this.#J?.value??"";this.setAttribute("value",String(Z));let $=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:Z;this.dispatchEvent(new CustomEvent(J,{detail:$,bubbles:!0,cancelable:!0,composed:!0}))}get value(){return this.#J?.value??this.getAttribute("value")??""}set value(J){if(J===null||J===void 0)this.removeAttribute("value");else this.setAttribute("value",String(J))}focus(J){this.#J?.focus(J)}}customElements.define("propskit-text",A);class b extends HTMLElement{#Q=null;#Z=null;#J=null;#j=!1;#X=null;#K=new Set;#B=null;#$=null;static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Q)this.#G();if(this.#_(),this.#k(),this.#Y(),!this.#X)this.#X=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#_();if(Z)this.#k()});this.#X.observe(this,{attributes:!0})}disconnectedCallback(){this.#X?.disconnect(),this.#N()}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction")this.#_()}#G(){let J=Array.from(this.childNodes).filter((j)=>j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())),Q=J.find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-input-number");Z.append($,_),this.#Q=Z,this.#Z=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z);for(let j of J)if(j!==Q)_.appendChild(j)}#_(){if(!this.#Q||!this.#Z)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Z.remove();else{if(!this.#j)this.#Z.textContent=J?Q??"":"Label";if(this.#Z.parentElement!==this.#Q)this.#Q.prepend(this.#Z)}this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#O(){let J=new Set(["label","direction","oninput","onchange","class","style","id"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#k(){if(!this.#J)return;let J=this.#O(),Q=new Set(J);for(let Z of this.#K)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#K=Q}#Y(){if(!this.#J)return;this.#B??=this.#q.bind(this,"input"),this.#$??=this.#q.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#$)}#N(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#$)this.#J.removeEventListener("change",this.#$)}#q(J,Q){Q.stopImmediatePropagation();let Z=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:this.#J?.value;if(this.#J?.value!==void 0)this.setAttribute("value",String(this.#J.value));this.dispatchEvent(new CustomEvent(J,{detail:Z,bubbles:!0,cancelable:!0,composed:!0}))}get value(){return this.#J?.value??this.getAttribute("value")??""}set value(J){if(J===null||J===void 0||J==="")this.removeAttribute("value");else this.setAttribute("value",String(J))}focus(J){this.#J?.focus(J)}}customElements.define("propskit-number",b);class y extends HTMLElement{#Q=null;#Z=null;#J=null;#j=!1;#X=null;#K=new Set;#B=0;#$=0;#G=null;#_=null;#O=0;#k=null;#Y=!1;#N=0;#q=null;#P=0;#U=null;#T=null;#C=null;#L=this.#o.bind(this);#F=this.#p.bind(this);#V=this.#d.bind(this);#H=this.#$J.bind(this);#z=this.#e.bind(this);#f=this.#s.bind(this);#g=new Set(["variant","color","text","full","elastic","size","name","class","data-wave-index","data-active","data-elastic-dragging","style"]);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Q)this.#S();if(this.#W(),this.#M(),this.#QJ(),this.#x(),this.removeEventListener("pointerdown",this.#L,{capture:!0}),this.addEventListener("pointerdown",this.#L,{capture:!0,passive:!0}),this.removeEventListener("contextmenu",this.#z),this.addEventListener("contextmenu",this.#z),!this.#X)this.#X=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J)if($.type==="attributes"){if($.attributeName&&this.#g.has($.attributeName))continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#W();if(Z)this.#M(),this.#x()});this.#X.observe(this,{attributes:!0})}disconnectedCallback(){if(this.#X?.disconnect(),this.#B)cancelAnimationFrame(this.#B),this.#B=0;if(this.#$)cancelAnimationFrame(this.#$),this.#$=0;this.#i(),this.#m(),this.#h(),this.#y(),this.#ZJ(),this.removeEventListener("pointerdown",this.#L,{capture:!0}),this.removeEventListener("contextmenu",this.#z),this.#_?.removeEventListener("change",this.#f)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction")this.#W()}#S(){let J=Array.from(this.childNodes).filter((j)=>{return j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())}),Q=J.find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-slider");_.setAttribute("text","true");for(let j of this.#b()){let X=this.getAttribute(j);_.setAttribute(j,X??"")}Z.append($,_),this.#Q=Z,this.#Z=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z),this.#D();for(let j of J){if(j===Q)continue;this.#J.appendChild(j)}}#D(){let J=document.createElement("fig-menu");J.setAttribute("position","bottom left"),J.setAttribute("offset","0 0");let Q=document.createElement("fig-menu-item");Q.setAttribute("value","reset-default"),Q.textContent="Reset to default",J.appendChild(Q),J.addEventListener("change",this.#f),this.#_=J,this.appendChild(J)}#W(){if(!this.#Q||!this.#Z)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()===""){if(this.#Z.parentElement===this.#Q)this.#Z.remove()}else{if(!this.#j)this.#Z.textContent=J?Q??"":"Label";if(this.#Z.parentElement!==this.#Q)this.#Q.prepend(this.#Z)}this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#M(){if(!this.#J)return;let J=this.#b(),Q=new Set(J.filter(($)=>$!=="text"));for(let $ of this.#K)if(!Q.has($))this.#J.removeAttribute($);for(let $ of J){if($==="text")continue;let _=this.getAttribute($);this.#J.setAttribute($,_??"")}this.#J.removeAttribute("variant"),this.#J.removeAttribute("color"),this.#J.removeAttribute("transform"),this.#J.removeAttribute("full"),this.#J.setAttribute("text","true");let Z=(this.getAttribute("type")||"range").toLowerCase();if(Z==="delta"||Z==="stepper")this.#J.setAttribute("default",this.getAttribute("default")??"50");else if(!this.hasAttribute("default"))this.#J.removeAttribute("default");if(Z==="stepper")this.#J.setAttribute("step",this.getAttribute("step")??"10");else if(!this.hasAttribute("step"))this.#J.removeAttribute("step");if(Z==="opacity")this.#J.style.setProperty("--color","light-dark(#444444, #e6e6e6)");else this.#J.style.removeProperty("--color");this.#K=Q,this.#I()}#b(){let J=new Set(["label","direction","oninput","onchange","steppers"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!this.#g.has(Q))}#I(){if(this.#B)cancelAnimationFrame(this.#B);this.#B=requestAnimationFrame(()=>{this.#B=0,this.#n(),this.#E()})}#x(){if(this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{this.#$=0,this.#E()})}#E(){let J=this.#J?.querySelector('input[type="range"]'),Q=this.#J?.querySelector("fig-input-number input");if(J!==this.#G)this.#c(J);J?.removeAttribute("tabindex"),Q?.setAttribute("tabindex","-1")}#c(J){if(this.#y(),this.#G=J,!this.#G)return;this.#G.addEventListener("dblclick",this.#H,{capture:!0})}#y(){if(!this.#G)return;this.#G.removeEventListener("dblclick",this.#H,{capture:!0}),this.#G=null}#$J(J){J.preventDefault(),J.stopImmediatePropagation(),this.#t()}#o(J){if(J.button!==0||R(this,"disabled"))return;if(this.getAttribute("elastic")==="false")return;if(J.target?.closest?.("fig-input-number"))return;let Q=this.#J?.querySelector('input[type="range"]')??this.#G;if(!Q)return;this.#m(),this.#h(),this.#G=Q,this.#Y=!0,this.#U=J.pointerId,this.#N=this.#JJ();let Z=Q.getBoundingClientRect(),$=this.getBoundingClientRect();this.#q={left:Z.left,right:Z.right,width:Z.width},this.#P=$.width,window.addEventListener("pointermove",this.#F,{passive:!0}),window.addEventListener("pointerup",this.#V,{once:!0}),window.addEventListener("pointercancel",this.#V,{once:!0}),window.addEventListener("blur",this.#V,{once:!0})}#p(J){if(!this.#Y)return;if(J.pointerId!==this.#U)return;if(J.buttons===0){this.#d(J);return}this.#BJ(J.clientX)}#d(J){if(J?.pointerId!==void 0&&this.#U!==null&&J.pointerId!==this.#U)return;this.#m(),this.#h()}#m(){window.removeEventListener("pointermove",this.#F),window.removeEventListener("pointerup",this.#V),window.removeEventListener("pointercancel",this.#V),window.removeEventListener("blur",this.#V),this.#Y=!1,this.#U=null}#e(J){if(R(this,"disabled"))return;J.preventDefault(),J.stopPropagation(),J.stopImmediatePropagation(),this.#i(),this.#XJ(J.clientX,J.clientY)}#XJ(J,Q){let Z=!1,$=0,_=()=>{if(Z)return;Z=!0,window.clearTimeout($),window.removeEventListener("pointerup",_,!0),window.removeEventListener("pointercancel",_,!0),requestAnimationFrame(()=>{this.#_?.showAt?.(J,Q)})};window.addEventListener("pointerup",_,{once:!0,capture:!0}),window.addEventListener("pointercancel",_,{once:!0,capture:!0}),$=window.setTimeout(_,180)}#s(J){if(J.stopPropagation(),J.detail?.value!=="reset-default")return;this.#t()}#i(){if(this.#O)clearTimeout(this.#O),this.#O=0;this.#k=null}#JJ(){let J=getComputedStyle(this).getPropertyValue("--propskit-slider-elastic-distance").trim();if(J.includes("var(")||!J.endsWith("px")){let Z=document.createElement("div");Object.assign(Z.style,{position:"absolute",visibility:"hidden",pointerEvents:"none",width:"var(--propskit-slider-elastic-distance)"}),this.appendChild(Z),J=getComputedStyle(Z).width,Z.remove()}let Q=Number.parseFloat(J);return Number.isFinite(Q)?Math.max(0,Q):0}#BJ(J){let Q=this.#q;if(!Q||!this.#N){this.#h();return}let Z=J<Q.left?J-Q.left:J>Q.right?J-Q.right:0;if(!Z){this.#a();return}let $=Math.max(-this.#N,Math.min(this.#N,Z*0.5)),_=Math.abs($),j=this.#P?(this.#P+_)/this.#P:1;this.dataset.elasticDragging="true",this.style.setProperty("--propskit-slider-elastic-size",`${_}px`),this.style.setProperty("--propskit-slider-elastic-scale",`${j}`),this.style.setProperty("--propskit-slider-elastic-origin",$<0?"right center":"left center")}#h(){this.#a(),this.#N=0,this.#q=null,this.#P=0,this.#U=null}#a(){this.removeAttribute("data-elastic-dragging"),this.style.removeProperty("--propskit-slider-elastic-size"),this.style.removeProperty("--propskit-slider-elastic-scale")}#KJ(J){let Q=this.#G;if(!Q)return this.#J?.value??"";let Z=Q.getBoundingClientRect(),$=Z.width?Math.min(1,Math.max(0,(J.clientX-Z.left)/Z.width)):0,_=Number(Q.min||0),j=Number(Q.max||100),X=Q.step==="any"?0:Number(Q.step||1),G=_+(j-_)*$;if(!X)return String(G);let B=Math.round((G-_)/X)*X+_,K=Math.max(0,`${X}`.split(".")[1]?.length||0);return String(Number(B.toFixed(K)))}#v(){return this.getAttribute("default")??this.#J?.getAttribute("default")??this.getAttribute("value")??this.#J?.getAttribute("value")??this.#G?.min??"0"}#t(){this.#i(),this.#r(this.#v(),"input"),this.#r(this.#v(),"change")}#r(J,Q){if(!this.#J||J===null||J===void 0)return;this.#J.value=J,this.dispatchEvent(new CustomEvent(Q,{detail:this.#J.value,bubbles:!0,cancelable:!0,composed:!0}))}#n(){if(!this.#J)return;let J=this.#J.querySelector("fig-input-number");if(!J)return;if(!(this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false")){J.removeAttribute("steppers");return}let Z=this.getAttribute("steppers");J.setAttribute("steppers",Z??"")}#QJ(){if(!this.#J)return;if(!this.#T)this.#T=this.#_J.bind(this,"input");if(!this.#C)this.#C=this.#_J.bind(this,"change");this.#J.addEventListener("input",this.#T),this.#J.addEventListener("change",this.#C)}#ZJ(){if(!this.#J)return;if(this.#T)this.#J.removeEventListener("input",this.#T);if(this.#C)this.#J.removeEventListener("change",this.#C)}#_J(J,Q){if(Q.stopImmediatePropagation(),J==="change")this.#h();let Z=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:this.#J?.value;this.dispatchEvent(new CustomEvent(J,{detail:Z,bubbles:!0,cancelable:!0,composed:!0}))}focus(J){this.#J?.querySelector('input[type="range"]')?.focus(J)}resetToDefault(){this.#t()}}customElements.define("propskit-slider",y);class x extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping"];#Q=50;#Z=50;#J=75;#j=75;#X=0;#K=!1;#B=0;#$=null;#G=null;#_=null;#O=null;#k=null;#Y=null;#N=null;#q=null;#P=null;#U=!1;#T=!1;#C=!1;#L=!1;#F=null;#V="";#H="";#z=null;get#f(){return this.getAttribute("type")||"point"}get#g(){return this.#f==="point-radius"||this.#f==="point-radius-angle"}get#S(){return this.#f==="point-radius-angle"}get#D(){return this.#f==="point-point"}get#W(){return this.#f==="point-radius-angle"||this.#f==="point-point"}get#M(){let J=this.getAttribute("tooltips");return J===null||J!=="false"}get#b(){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"}#I(J){let Q=this.#b;if(Q==="true")return!0;if(Q==="modifier")return!!J;return!1}get#x(){let J=this.getAttribute("name");if(J)return J.split(",")[0].trim();return`${Math.round(this.#Q)}%, ${Math.round(this.#Z)}%`}get#E(){let J=this.getAttribute("name");if(J){let Q=J.split(",");if(Q.length>1)return Q[1].trim()}return`${Math.round(this.#J)}%, ${Math.round(this.#j)}%`}get#c(){return this.getAttribute("drag-surface")||"parent"}get#y(){let J=this.#c;if(J==="parent")return this.parentElement;return this.closest(J)}get#$J(){let J=this.#c;if(J==="parent"){let Q=this.parentElement;if(Q)return Q.setAttribute("data-fig-canvas-control-surface",""),"[data-fig-canvas-control-surface]"}return J}#o(J){if(this.#K)return this.#X/100*J;return this.#X}#p(){if(this.#K)return`Radius ${Math.round(this.#X)}%`;return`Radius ${Math.round(this.#X)}`}connectedCallback(){this.#d(),this.#m()}disconnectedCallback(){this.#NJ(),this.#s(),document.body.classList.remove("fig-lab-move-active")}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"&&!this.#U&&!this.#T&&!this.#C&&!this.#L)if(this.#d(),this.#$)this.#A();else this.#m();if(J==="type")this.#d(),this.#m();if(J==="color"&&this.#$)if(Z)this.#$.setAttribute("color",Z);else this.#$.removeAttribute("color");if(J==="disabled")this.#m();if(J==="tooltips")this.#m();if(J==="snapping"&&this.#$){if(this.#$.setAttribute("drag-snapping",Z||"false"),this.#G)this.#G.setAttribute("drag-snapping",Z||"false")}if(J==="name"){if(this.#Y)this.#Y.setAttribute("text",this.#x);if(this.#N)this.#N.setAttribute("text",this.#E)}}#d(){let J=this.getAttribute("value");if(!J)return;try{let Q=JSON.parse(J);if(typeof Q.x==="number")this.#Q=Q.x;if(typeof Q.y==="number")this.#Z=Q.y;if(Q.radius!==void 0){let Z=String(Q.radius);if(Z.endsWith("%"))this.#K=!0,this.#X=parseFloat(Z);else this.#K=!1,this.#X=parseFloat(Z);if(!Number.isFinite(this.#X))this.#X=0}if(typeof Q.angle==="number")this.#B=Q.angle;if(typeof Q.x2==="number")this.#J=Q.x2;if(typeof Q.y2==="number")this.#j=Q.y2}catch{}}get value(){let J={x:this.#Q,y:this.#Z};if(this.#f==="color"){let Q=this.getAttribute("color")||this.#$?.getAttribute("color");if(Q)J.color=Q}if(this.#g)J.radius=this.#K?`${this.#X}%`:this.#X;if(this.#S)J.angle=this.#B;if(this.#D)J.x2=this.#J,J.y2=this.#j;return J}set value(J){if(typeof J==="object")this.setAttribute("value",JSON.stringify(J));else if(typeof J==="string")this.setAttribute("value",J)}#m(){this.innerHTML="",this.#$=null,this.#G=null,this.#_=null,this.#O=null,this.#k=null,this.#Y=null,this.#N=null,this.#q=null,this.#P=null;let J=R(this,"disabled"),Q=this.#f,Z=this.#M,$=this.#$J,_=document.createElement("fig-handle");if(_.setAttribute("drag","true"),_.setAttribute("drag-surface",$),_.setAttribute("drag-axes","x,y"),_.setAttribute("drag-snapping",this.#b),_.setAttribute("value",`${this.#Q}% ${this.#Z}%`),J)_.setAttribute("disabled","");if(Q==="color"){_.setAttribute("type","color");let j=this.getAttribute("color");if(j)_.setAttribute("color",j)}else _.setAttribute("type","canvas");if(this.#D)_.setAttribute("hit-area","12 circle"),_.setAttribute("hit-area-mode","delegate");if(this.#$=_,this.#g)this.#KJ();if(this.#W)this.#v();if(Z){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#x),j.appendChild(_),this.appendChild(j),this.#Y=j}else this.appendChild(_);if(this.#S)this.#r(J,Z,$);if(this.#D)this.#n(J,Z,$);this.#e(this.#$),this.#e(this.#_),this.#e(this.#G),this.#OJ(),this.#BJ(),requestAnimationFrame(()=>this.#A())}#e(J){if(!J)return;J.addEventListener("pointerdown",(Q)=>this.#XJ(Q),{capture:!0})}#XJ(J){if(R(this,"disabled"))return;if(J?.button!==void 0&&J.button!==0)return;if(J?.isPrimary===!1)return;if(this.#F===null)this.#V=document.body.style.getPropertyValue("cursor"),this.#H=document.body.style.getPropertyPriority("cursor");if(this.#F=J?.pointerId??-1,document.body.classList.add("fig-lab-move-active"),document.body.style.setProperty("cursor","var(--fig-lab-cursor-move)","important"),!this.#z)this.#z=(Q)=>{if(Q?.pointerId!==void 0&&this.#F!==null&&Q.pointerId!==this.#F)return;if(Q?.type==="blur")this.#s();else requestAnimationFrame(()=>this.#s())};window.addEventListener("pointerup",this.#z),window.addEventListener("pointercancel",this.#z),window.addEventListener("blur",this.#z)}#s(){if(this.#F===null)return;if(document.body.classList.remove("fig-lab-move-active"),this.#V)document.body.style.setProperty("cursor",this.#V,this.#H);else document.body.style.removeProperty("cursor");if(this.#F=null,this.#V="",this.#H="",this.#z)window.removeEventListener("pointerup",this.#z),window.removeEventListener("pointercancel",this.#z),window.removeEventListener("blur",this.#z)}#i(J,Q,Z,$){if(!J)return;let _=()=>!!$?.(),j=()=>{let B=Q();if(!B)return;B.removeAttribute("show"),B.hidePopup?.()},X=()=>{if(_()){j();return}let B=Q();if(!B)return;if(Z)B.setAttribute("text",Z());B.setAttribute("show","true"),B.showPopup?.()},G=()=>{j()};J.addEventListener("pointerenter",X),J.addEventListener("pointerleave",G)}#JJ(){return this.#U||this.#T||this.#C||this.#L}#BJ(){if(this.#$)this.#i(this.#$,()=>this.#Y,()=>this.#x,()=>this.#JJ()||!!this.#$?.querySelector("fig-color-tip"));if(this.#_)this.#i(this.#_,()=>this.#P,()=>`Angle ${Math.round(this.#B)}°`,()=>this.#JJ());if(this.#G)this.#i(this.#G,()=>this.#N,()=>this.#E,()=>this.#JJ());if(this.#O){let J=this.#O.querySelector(".fig-canvas-control-radius-hit");this.#a(J||this.#O)}if(this.#f==="color"&&this.#$&&this.#Y)new MutationObserver(()=>{if(this.#$?.querySelector("fig-color-tip"))this.#Y?.removeAttribute("show"),this.#Y?.hidePopup?.()}).observe(this.#$,{childList:!0,subtree:!0})}#h(J,Q){let Z=this.#q;if(!Z?.popup)return;let $=Q-8;Z.popup.anchor={getBoundingClientRect:()=>({left:J,top:$,right:J,bottom:$,width:0,height:0,x:J,y:$})},Z.popup.queueReposition?.()}#a(J){if(!J)return;J.addEventListener("pointerenter",(Q)=>{let Z=this.#q;if(!Z)return;Z.setAttribute("text",this.#p()),Z.setAttribute("show","true"),Z.showPopup?.(),this.#h(Q.clientX,Q.clientY)}),J.addEventListener("pointermove",(Q)=>{if(this.#C)return;this.#h(Q.clientX,Q.clientY)}),J.addEventListener("pointerleave",()=>{if(this.#C)return;let Q=this.#q;if(!Q)return;Q.removeAttribute("show")})}#KJ(){let Q=document.createElementNS("http://www.w3.org/2000/svg","svg");Q.classList.add("fig-canvas-control-radius"),Q.setAttribute("overflow","visible");let Z=document.createElementNS("http://www.w3.org/2000/svg","circle");Z.classList.add("fig-canvas-control-radius-hit"),Q.appendChild(Z);let $=document.createElementNS("http://www.w3.org/2000/svg","circle");$.classList.add("fig-canvas-control-radius-halo"),Q.appendChild($);let _=document.createElementNS("http://www.w3.org/2000/svg","circle");if(Q.appendChild(_),this.#O=Q,this.#M){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#p()),j.appendChild(Q),this.appendChild(j),this.#q=j}else this.appendChild(Q);this.#kJ(Z)}#v(){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.#t(_)}let Z=document.createElementNS("http://www.w3.org/2000/svg","line");Z.classList.add("fig-canvas-control-angle-line-halo"),Q.appendChild(Z);let $=document.createElementNS("http://www.w3.org/2000/svg","line");$.classList.add("fig-canvas-control-angle-line"),Q.appendChild($),this.#k=Q,this.appendChild(Q)}#t(J){J.addEventListener("pointerdown",(Q)=>{if(R(this,"disabled"))return;Q.preventDefault(),Q.stopPropagation();let Z=this.#y;if(!Z)return;let $=Z.getBoundingClientRect(),_=Q.clientX,j=Q.clientY,X=this.#Q,G=this.#Z,B=this.#J,K=this.#j;this.#U=!0,this.#T=!0,document.body.classList.add("fig-lab-move-active"),J.style.pointerEvents="none";let O=(N)=>{let P=Z.getBoundingClientRect(),S=P.width>0?(N.clientX-_)/P.width*100:0,k=P.height>0?(N.clientY-j)/P.height*100:0,L=-Math.min(X,B),f=100-Math.max(X,B),V=-Math.min(G,K),U=100-Math.max(G,K),M=Math.max(L,Math.min(f,S)),z=Math.max(V,Math.min(U,k));this.#Q=X+M,this.#Z=G+z,this.#J=B+M,this.#j=K+z,this.#A(),this.#R()},Y=()=>{document.body.classList.remove("fig-lab-move-active"),J.style.pointerEvents="stroke",this.#w(),this.#l(),window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",Y),requestAnimationFrame(()=>{this.#U=!1,this.#T=!1})};window.addEventListener("pointermove",O),window.addEventListener("pointerup",Y)})}#r(J,Q,Z){let $=document.createElement("fig-handle");if($.setAttribute("type","canvas"),$.setAttribute("drag","true"),$.setAttribute("drag-surface",Z),$.setAttribute("drag-axes","x,y"),$.setAttribute("size","small"),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),J)$.setAttribute("disabled","");if(this.#_=$,Q){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",`${Math.round(this.#B)}°`),_.appendChild($),this.appendChild(_),this.#P=_}else this.appendChild($)}#n(J,Q,Z){let $=document.createElement("fig-handle");if($.setAttribute("type","canvas"),$.setAttribute("drag","true"),$.setAttribute("drag-surface",Z),$.setAttribute("drag-axes","x,y"),$.setAttribute("drag-snapping",this.#b),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),$.setAttribute("value",`${this.#J}% ${this.#j}%`),J)$.setAttribute("disabled","");if(this.#G=$,Q){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#E),_.appendChild($),this.appendChild(_),this.#N=_}else this.appendChild($)}#QJ(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`}#ZJ(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`}#_J(){if(!this.#_||!this.#S)return;let J=this.#_.querySelector(".fig-handle-hit-area");if(!J)return;J.style.cursor=this.#ZJ(this.#B)}#qJ(){return Math.atan2(this.#j-this.#Z,this.#J-this.#Q)*180/Math.PI}#PJ(){if(!this.#D)return;let J=this.#qJ(),Q=(Z,$)=>{if(!Z)return;let _=Z.querySelector(".fig-handle-hit-area");if(_)_.style.cursor=this.#ZJ($)};Q(this.#$,J+180),Q(this.#G,J)}#jJ(J,Q,Z,$){J.style.setProperty("--fig-handle-position-translate","-50% -50%"),J.style.left=`${Q/100*$.width}px`,J.style.top=`${Z/100*$.height}px`}#A(){let J=this.#y;if(!J||!this.#$)return;let Q=J.getBoundingClientRect();if(this.#jJ(this.#$,this.#Q,this.#Z,Q),this.#O){let Z=this.#Q/100*Q.width,$=this.#Z/100*Q.height,_=this.#o(Q.width),j=this.#O,X=Math.max(_*2,1);j.style.position="absolute",j.style.width=`${X}px`,j.style.height=`${X}px`,j.style.left=`${Z-_}px`,j.style.top=`${$-_}px`,j.setAttribute("viewBox",`0 0 ${X} ${X}`);let G=j.querySelectorAll("circle");for(let B of G)B.setAttribute("cx",String(_)),B.setAttribute("cy",String(_)),B.setAttribute("r",String(Math.max(_-1,0)))}if(this.#k&&this.#W){let Z=this.#Q/100*Q.width,$=this.#Z/100*Q.height,_,j;if(this.#D)_=this.#J/100*Q.width,j=this.#j/100*Q.height;else{let B=this.#o(Q.width),K=this.#B*Math.PI/180;_=Z+B*Math.cos(K),j=$+B*Math.sin(K)}let X=this.#k;X.style.width=`${Q.width}px`,X.style.height=`${Q.height}px`,X.style.left="0",X.style.top="0",X.setAttribute("viewBox",`0 0 ${Q.width} ${Q.height}`);let G=X.querySelectorAll(".fig-canvas-control-angle-line, .fig-canvas-control-angle-line-halo");for(let B of G)B.setAttribute("x1",String(Z)),B.setAttribute("y1",String($)),B.setAttribute("x2",String(_)),B.setAttribute("y2",String(j))}if(this.#_&&this.#S){let Z=this.#Q/100*Q.width,$=this.#Z/100*Q.height,_=this.#o(Q.width),j=this.#B*Math.PI/180,X=Z+_*Math.cos(j),G=$+_*Math.sin(j),B=Q.width>0?X/Q.width*100:0,K=Q.height>0?G/Q.height*100:0;this.#jJ(this.#_,B,K,Q)}if(this.#G&&this.#D)this.#jJ(this.#G,this.#J,this.#j,Q);this.#_J(),this.#PJ()}#R(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#l(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}#w(){this.setAttribute("value",JSON.stringify(this.value))}#OJ(){if(!this.#$)return;if(this.#$.addEventListener("input",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#R();return}this.#U=!0;let Q=J.detail?.px??this.#Q/100,Z=J.detail?.py??this.#Z/100;if(this.#Q=Math.round(Math.max(0,Math.min(100,Q*100))),this.#Z=Math.round(Math.max(0,Math.min(100,Z*100))),this.#Y)this.#Y.removeAttribute("show"),this.#Y.hidePopup?.();this.#A(),this.#R()}),this.#$.addEventListener("change",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#l();return}let Q=J.detail?.px??this.#Q/100,Z=J.detail?.py??this.#Z/100;if(this.#Q=Math.round(Math.max(0,Math.min(100,Q*100))),this.#Z=Math.round(Math.max(0,Math.min(100,Z*100))),this.#Y)this.#Y.removeAttribute("show");this.#A(),this.#w(),this.#l(),requestAnimationFrame(()=>{this.#U=!1})}),this.#_)this.#_.addEventListener("input",(J)=>{J.stopPropagation();let Q=this.#y;if(!Q)return;this.#L=!0,this.classList.add("fig-canvas-control-ring-active");let Z=Q.getBoundingClientRect(),$=this.#Q/100*Z.width,_=this.#Z/100*Z.height,j=J.detail?.x??0,X=J.detail?.y??0,G=this.#_.offsetWidth/2,B=this.#_.offsetHeight/2,K=j+G-$,O=X+B-_,Y=Math.atan2(O,K)*180/Math.PI;if(this.#I(J.detail?.shiftKey))Y=Math.round(Y/15)*15;this.#B=Y;let N=Math.sqrt(K*K+O*O);if(this.#I(J.detail?.shiftKey)){let P=this.#K?5:10;if(this.#K){let S=N/Z.width*100;S=Math.round(S/P)*P,N=S/100*Z.width}else N=Math.round(N/P)*P}if(this.#K)this.#X=Math.max(0,N/Z.width*100);else this.#X=Math.max(0,N);if(this.#P)this.#P.setAttribute("text",`Angle ${Math.round(this.#B)}°`),this.#P.setAttribute("show","true"),this.#P.showPopup?.();this.#A(),this.#R()}),this.#_.addEventListener("change",(J)=>{if(J.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#P)this.#P.removeAttribute("show");this.#A(),this.#w(),this.#l(),requestAnimationFrame(()=>{this.#L=!1})}),this.#_.addEventListener("hitareadown",(J)=>{J.stopPropagation();let Q=J.detail?.originalEvent;if(!Q)return;Q.preventDefault();let Z=this.#y;if(!Z)return;if(this.#L=!0,this.classList.add("fig-canvas-control-ring-active"),this.#_.setAttribute("selected",""),this.#P)this.#P.setAttribute("show","true"),this.#P.showPopup?.();let $=(j)=>{let X=Z.getBoundingClientRect(),G=this.#Q/100*X.width,B=this.#Z/100*X.height,K=j.clientX-X.left-G,O=j.clientY-X.top-B,Y=Math.atan2(O,K)*180/Math.PI;if(this.#I(j.shiftKey))Y=Math.round(Y/15)*15;if(this.#B=Y,this.#P)this.#P.setAttribute("text",`Angle ${Math.round(Y)}°`);this.#A(),this.#R()},_=()=>{if(this.#L=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#_.removeAttribute("selected"),this.#P)this.#P.removeAttribute("show");this.#w(),this.#l(),window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",_)};window.addEventListener("pointermove",$),window.addEventListener("pointerup",_)});if(this.#G)this.#G.addEventListener("input",(J)=>{J.stopPropagation(),this.#T=!0;let Q=J.detail?.px??this.#J/100,Z=J.detail?.py??this.#j/100;if(this.#J=Math.round(Math.max(0,Math.min(100,Q*100))),this.#j=Math.round(Math.max(0,Math.min(100,Z*100))),this.#N)this.#N.removeAttribute("show"),this.#N.hidePopup?.();this.#A(),this.#R()}),this.#G.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#N)this.#N.removeAttribute("show");this.#A(),this.#w(),this.#l(),requestAnimationFrame(()=>{this.#T=!1})}),this.#YJ(this.#$,!0),this.#YJ(this.#G,!1)}#YJ(J,Q){if(!J)return;J.addEventListener("hitareadown",(Z)=>{Z.stopPropagation();let $=Z.detail?.originalEvent;if(!$)return;$.preventDefault();let _=this.#y;if(!_)return;this.#U=!0;let j=_.getBoundingClientRect(),X=Q?this.#J:this.#Q,G=Q?this.#j:this.#Z,B=Q?this.#Q:this.#J,K=Q?this.#Z:this.#j,O=X/100*j.width,Y=G/100*j.height,N=B/100*j.width,P=K/100*j.height,S=Math.sqrt((N-O)**2+(P-Y)**2),k=Q?this.#Y:this.#N;if(k)k.removeAttribute("show"),k.hidePopup?.();let L=(V)=>{let U=_.getBoundingClientRect(),M=X/100*U.width,z=G/100*U.height,T=V.clientX-U.left-M,D=V.clientY-U.top-z,C=Math.atan2(D,T);if(this.#I(V.shiftKey))C=Math.round(C*180/Math.PI/15)*15*Math.PI/180;let w=M+S*Math.cos(C),g=z+S*Math.sin(C),W=Math.max(0,Math.min(100,w/U.width*100)),H=Math.max(0,Math.min(100,g/U.height*100));if(Q)this.#Q=W,this.#Z=H;else this.#J=W,this.#j=H;this.#A(),this.#R()},f=()=>{if(this.#U=!1,k)k.removeAttribute("show");this.#w(),this.#l(),window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",f)};window.addEventListener("pointermove",L),window.addEventListener("pointerup",f)})}#kJ(J){if(!J)return;J.addEventListener("pointermove",(Z)=>{if(this.#C)return;let $=this.#y;if(!$)return;let _=$.getBoundingClientRect(),j=this.#Q/100*_.width,X=this.#Z/100*_.height,G=Math.atan2(Z.clientY-_.top-X,Z.clientX-_.left-j)*180/Math.PI;J.style.cursor=this.#QJ(G)});let Q=(Z)=>{if(R(this,"disabled"))return;Z.preventDefault(),Z.stopPropagation(),this.#C=!0,this.classList.add("fig-canvas-control-ring-active");let $=this.#y;if(!$)return;if(this.#q)this.#q.setAttribute("show","true"),this.#q.showPopup?.(),this.#h(Z.clientX,Z.clientY);if(this.#P)this.#P.removeAttribute("show"),this.#P.hidePopup?.();let _=this.#_?.style.pointerEvents,j=this.#_?.querySelector(".fig-handle-hit-area"),X=j?.style.pointerEvents;if(this.#_)this.#_.style.pointerEvents="none";if(j)j.style.pointerEvents="none";let G=document.body.style.cursor;J.style.pointerEvents="none";let B=$.getBoundingClientRect(),K=this.#Q/100*B.width,O=this.#Z/100*B.height,Y=Math.atan2(Z.clientY-B.top-O,Z.clientX-B.left-K)*180/Math.PI,N=Math.round(Y);document.body.style.cursor=this.#QJ(N);let P=(k)=>{let L=$.getBoundingClientRect(),f=this.#Q/100*L.width,V=this.#Z/100*L.height,U=k.clientX-L.left-f,M=k.clientY-L.top-V,z=Math.round(Math.atan2(M,U)*180/Math.PI);if(z!==N)N=z,document.body.style.cursor=this.#QJ(z);let T=Math.sqrt(U*U+M*M);if(this.#I(k.shiftKey)){let D=this.#K?5:10;if(this.#K){let C=T/L.width*100;C=Math.round(C/D)*D,T=C/100*L.width}else T=Math.round(T/D)*D}if(this.#K)this.#X=Math.max(0,T/L.width*100);else this.#X=Math.max(0,T);if(this.#q)this.#q.setAttribute("text",this.#p()),this.#h(k.clientX,k.clientY);this.#A(),this.#R()},S=()=>{if(this.#C=!1,this.classList.remove("fig-canvas-control-ring-active"),J.style.pointerEvents="",this.#_)this.#_.style.pointerEvents=_??"";if(j)j.style.pointerEvents=X??"";if(document.body.style.cursor=G,this.#q)this.#q.removeAttribute("show");this.#w(),this.#l(),window.removeEventListener("pointermove",P),window.removeEventListener("pointerup",S)};window.addEventListener("pointermove",P),window.addEventListener("pointerup",S)};J.addEventListener("pointerdown",Q),this._radiusDragCleanup=()=>J.removeEventListener("pointerdown",Q)}#NJ(){if(this._radiusDragCleanup)this._radiusDragCleanup(),this._radiusDragCleanup=null}}customElements.define("fig-canvas-control",x);class q extends HTMLElement{#Q=[q.#H()];#Z=0;#J=2;#j=240;#X=120;#K={min:-1,max:1};#B=null;#$=null;#G=null;#_=null;#O=0;#k=null;#Y=null;#N=null;#q=null;#P=[];#U=[];#T=[];#C=[];#L=new Set;#F=null;#V=null;static TYPES=[{name:"Wave",value:"sine"},{name:"Square",value:"square"},{name:"Sawtooth",value:"sawtooth"},{name:"Triangle",value:"triangle"}];static#H(J="sine"){return{type:J,frequency:1,amplitude:1,phase:0,offset:0}}static get observedAttributes(){return["value","precision","aspect-ratio","edit","disabled"]}connectedCallback(){this.#J=this.#z("precision",2),this.#W(this.getAttribute("value")),this.#D(),this.#p(),this.#h()}disconnectedCallback(){if(this.#B=null,this.#ZJ(),this.#F)this.#F.disconnect(),this.#F=null}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"){if(this.#W(Z),this.isConnected)this.#p();return}if(J==="precision"){if(this.#J=this.#z("precision",2),this.isConnected)this.#GJ();return}if(J==="aspect-ratio"){if(this.#D(),this.#$)this.#n();return}if(J==="edit"||J==="disabled"){if(this.isConnected)this.#p()}}get value(){return JSON.stringify(this.data)}set value(J){this.setAttribute("value",typeof J==="object"&&J!==null?JSON.stringify(J):J)}get data(){return{waves:this.#Q.map((J)=>this.#b(J))}}get preset(){let J=this.#I;return q.TYPES.find((Q)=>Q.value===J.type)?.name}#z(J,Q){let Z=Number.parseInt(this.getAttribute(J)||"",10);return Number.isFinite(Z)?Math.max(0,Math.min(100,Z)):Q}#f(J,Q=!1){let Z=this.getAttribute(J);if(Z===null)return Q;let $=Z.trim().toLowerCase();if($===""||$==="true")return!0;if($==="false")return!1;return!0}#g(){return this.getAttribute("edit")!=="false"}#S(){return this.#f("disabled",!1)}#D(){let J=this.getAttribute("aspect-ratio")||"2 / 1";this.style.setProperty("--aspect-ratio",J)}#W(J){if(!J)return!1;let Q=null;if(typeof J==="string")try{Q=JSON.parse(J)}catch{Q=null}else if(typeof J==="object")Q=J;if(!Q)return!1;let Z=Array.isArray(Q)?Q:Array.isArray(Q.waves)?Q.waves:[Q];if(this.#Q=Z.map(($)=>this.#M($)),!this.#Q.length)this.#Q=[q.#H()];return this.#Z=Math.min(this.#Z,this.#Q.length-1),!0}#M(J={}){return{type:this.#x(J.type),frequency:this.#E(J.frequency,1,0.1,16),amplitude:this.#E(J.amplitude,1,-4,4),phase:this.#E(J.phase,0,-360,360),offset:this.#E(J.offset,0,-4,4)}}#b(J){return{type:J.type,frequency:this.#c(J.frequency),amplitude:this.#c(J.amplitude),phase:this.#c(J.phase),offset:this.#c(J.offset)}}get#I(){if(!this.#Q[this.#Z])this.#Z=0;return this.#Q[this.#Z]||q.#H()}#x(J){let Q=String(J||"").toLowerCase();return q.TYPES.some((Z)=>Z.value===Q)?Q:"sine"}#E(J,Q,Z,$){let _=Number.parseFloat(J);if(!Number.isFinite(_))return Q;return Math.min($,Math.max(Z,_))}#c(J){let Q=10**this.#J;return Math.round(J*Q)/Q}static#y(J){return String(J).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}static#$J(J){return q.TYPES.find((Q)=>Q.value===J)?.name||"Wave"}static waveIcon(J,Q=24){let _=Q-10,j="";for(let X=0;X<=32;X++){let G=X/32,B=q.#o(J,G),K=5+G*_,O=5+(1-(B+1)/2)*_;j+=`${X===0?"M":"L"}${K.toFixed(1)},${O.toFixed(1)}`}return`<svg width="${Q}" height="${Q}" viewBox="0 0 ${Q} ${Q}" fill="none"><path d="${j}" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"/></svg>`}static#o(J,Q,Z=0){let $=Q+Z/360,_=$-Math.floor($),j=$*Math.PI*2;switch(J){case"square":return Math.sin(j)>=0?1:-1;case"sawtooth":return _*2-1;case"triangle":return 1-Math.abs(_*4-2);default:return Math.sin(j)}}#p(){this.#ZJ(),this.innerHTML=this.#d(),this.#i(),this.#a(),this.#n(),this.#A(),this.#QJ()}#d(){let J=this.#S()?" disabled":"";return`<div class="propskit-oscillator-svg-container">
|
|
2
|
+
<svg viewBox="0 0 ${this.#j} ${this.#X}" class="propskit-oscillator-svg">
|
|
3
|
+
<rect class="propskit-oscillator-bounds" x="0" y="0" width="${this.#j}" height="${this.#X}"></rect>
|
|
4
|
+
<line class="propskit-oscillator-baseline"></line>
|
|
5
|
+
<path class="propskit-oscillator-path"></path>
|
|
6
|
+
<circle class="propskit-oscillator-playhead"></circle>
|
|
7
|
+
<foreignObject class="propskit-oscillator-handle propskit-oscillator-amplitude-handle" data-handle="amplitude" width="20" height="20"><div class="propskit-oscillator-handle-inner"><fig-tooltip text="Amplitude"><fig-handle size="small" aria-label="Oscillator amplitude handle"${J}></fig-handle></fig-tooltip></div></foreignObject>
|
|
8
|
+
<foreignObject class="propskit-oscillator-handle propskit-oscillator-frequency-handle" data-handle="frequency" width="20" height="20"><div class="propskit-oscillator-handle-inner"><fig-tooltip text="Frequency"><fig-handle size="small" aria-label="Oscillator frequency handle"${J}></fig-handle></fig-tooltip></div></foreignObject>
|
|
9
9
|
</svg>
|
|
10
10
|
</div>
|
|
11
|
-
${this.#g()?this.#m(J):""}`}#m(J){return`<div class="
|
|
11
|
+
${this.#g()?this.#m(J):""}`}#m(J){return`<div class="propskit-oscillator-waves">
|
|
12
12
|
${this.#Q.map((Q,Z)=>this.#e(Q,Z,J)).join("")}
|
|
13
|
-
</div>`}#e(J,Q,Z){let $=Z||this.#Q.length<=1?" disabled":"",_=Q===this.#Z?" data-active":"",j=q.#$J(J.type);return`<fig-group class="
|
|
13
|
+
</div>`}#e(J,Q,Z){let $=Z||this.#Q.length<=1?" disabled":"",_=Q===this.#Z?" data-active":"",j=q.#$J(J.type);return`<fig-group class="propskit-oscillator-wave" collapsible borderless compact="true"${this.#L.has(Q)?' open="true"':' open="false"'} data-wave-index="${Q}">
|
|
14
14
|
<fig-header borderless>
|
|
15
15
|
<h3>${j}</h3>
|
|
16
16
|
<fig-tooltip text="Remove form">
|
|
17
|
-
<fig-button class="
|
|
17
|
+
<fig-button class="propskit-oscillator-remove-button" variant="ghost" icon data-wave-index="${Q}" aria-label="Remove form"${$}><fig-icon name="minus"></fig-icon></fig-button>
|
|
18
18
|
</fig-tooltip>
|
|
19
19
|
<fig-tooltip text="Add form">
|
|
20
|
-
<fig-button class="
|
|
20
|
+
<fig-button class="propskit-oscillator-add-type-button" type="select" variant="ghost" icon data-wave-index="${Q}" aria-label="Add form"${Z}>
|
|
21
21
|
<fig-icon name="add"></fig-icon>
|
|
22
|
-
${this.#XJ("
|
|
22
|
+
${this.#XJ("propskit-oscillator-add-type","sine",Z,Q)}
|
|
23
23
|
</fig-button>
|
|
24
24
|
</fig-tooltip>
|
|
25
25
|
</fig-header>
|
|
26
|
-
<div class="
|
|
26
|
+
<div class="propskit-oscillator-fields" data-wave-index="${Q}"${_}>
|
|
27
27
|
${this.#s(Q,"frequency","Frequency",0.1,16,0.1,"")}
|
|
28
28
|
${this.#s(Q,"amplitude","Amplitude",-4,4,0.1,"")}
|
|
29
29
|
${this.#s(Q,"phase","Phase",-360,360,1,"°")}
|
|
@@ -32,7 +32,7 @@ function D(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class I ex
|
|
|
32
32
|
</fig-group>`}#XJ(J,Q,Z,$=null){let _=q.TYPES.map((X)=>{let G=X.value===Q?" selected":"";return`<option value="${X.value}"${G}>
|
|
33
33
|
${q.waveIcon(X.value,24)}
|
|
34
34
|
<label>${X.name}</label>
|
|
35
|
-
</option>`}).join(""),j=$===null?"":` data-wave-index="${q.#y(String($))}"`;return`<fig-dropdown class="${J}" value="${Q}" experimental="modern" type="dropdown" label="Add form"${j}${Z}>${_}</fig-dropdown>`}#s(J,Q,Z,$,_,j,X){let G=this.#L()?" disabled":"",B=X?` units="${q.#y(X)}"`:"",K=this.#Q[J]||q.#H();return`<fig-field-slider class="fig-input-oscillator-field" label="${Z}" direction="horizontal" name="${Q}" data-wave-index="${J}" value="${this.#c(K[Q])}" min="${$}" max="${_}" step="${j}" precision="${this.#J}" elastic="false"${B}${G}></fig-field-slider>`}#i(){this.#_=this.querySelector(".fig-input-oscillator-svg"),this.#X=this.querySelector(".fig-input-oscillator-path"),this.#$=this.querySelector(".fig-input-oscillator-playhead"),this.#f=this.querySelector(".fig-input-oscillator-baseline"),this.#N=this.querySelector(".fig-input-oscillator-bounds"),this.#U=this.querySelector('[data-handle="amplitude"]'),this.#P=this.querySelector('[data-handle="frequency"]'),this.#k=Array.from(this.querySelectorAll(".fig-input-oscillator-wave-type")),this.#G=Array.from(this.querySelectorAll("fig-field-slider[name]")),this.#T=Array.from(this.querySelectorAll("fig-group.fig-input-oscillator-wave")),this.#z=Array.from(this.querySelectorAll(".fig-input-oscillator-fields"))}#JJ(J){let Q=new Set;for(let Z of this.#q)if(Z<J)Q.add(Z);else if(Z>J)Q.add(Z-1);this.#q=Q}#BJ(J){let Q=new Set;for(let Z of this.#q)Q.add(Z>=J?Z+1:Z);Q.add(J),this.#q=Q}#h(){if(this.#C||!window.ResizeObserver)return;this.#C=new ResizeObserver(()=>{if(this.#a())this.#n()}),this.#C.observe(this)}#a(){if(!this.#_)return!1;let J=this.#_.getBoundingClientRect(),Q=Math.max(1,Math.round(J.width||240)),Z=Math.max(1,Math.round(J.height||120)),$=Q!==this.#j||Z!==this.#B;return this.#j=Q,this.#B=Z,this.#_.setAttribute("viewBox",`0 0 ${Q} ${Z}`),$}#KJ(){let J=1,Q=256;for(let Z=0;Z<=Q;Z++)J=Math.max(J,Math.abs(this.#r(Z/Q)));return{min:-J,max:J}}#v(J){let{min:Q,max:Z}=this.#O;return this.#B-(J-Q)/(Z-Q)*this.#B}#t(J){let{min:Q,max:Z}=this.#O;return Q+(1-J/this.#B)*(Z-Q)}#r(J){return this.#Q.reduce((Q,Z)=>{let $=J*Z.frequency,_=q.#o(Z.type,$,Z.phase);return Q+Z.offset+_*Z.amplitude},0)}#n(){if(!this.#_||!this.#X)return;if(this.#a(),this.#O=this.#KJ(),this.#N)this.#N.setAttribute("width",this.#j),this.#N.setAttribute("height",this.#B);let J=Math.max(...this.#Q.map((j)=>j.frequency)),Z=this.#Q.some((j)=>j.type==="square"||j.type==="sawtooth")?Math.max(192,Math.ceil(J*64)):Math.max(96,Math.ceil(J*64)),$="";for(let j=0;j<=Z;j++){let X=j/Z,G=X*this.#j,B=this.#v(this.#r(X));$+=`${j===0?"M":"L"}${G.toFixed(1)},${B.toFixed(1)}`}this.#X.setAttribute("d",$);let _=this.#v(0);this.#f?.setAttribute("x1","0"),this.#f?.setAttribute("y1",_),this.#f?.setAttribute("x2",this.#j),this.#f?.setAttribute("y2",_),this.#qJ()}#QJ(){if(this.#Y||!this.#$)return;let J=(Q)=>{if(!this.isConnected||!this.#$){this.#Y=0;return}this.#_J(Q%1000/1000),this.#Y=requestAnimationFrame(J)};this.#Y=requestAnimationFrame(J)}#ZJ(){if(!this.#Y)return;cancelAnimationFrame(this.#Y),this.#Y=0}#_J(J){if(!this.#$)return;let Q=J*this.#j,Z=this.#v(this.#r(J));this.#$.setAttribute("cx",Q.toFixed(1)),this.#$.setAttribute("cy",Z.toFixed(1))}#qJ(){let Q=this.#I,Z=this.#PJ(),$=Math.max(8,Math.min(this.#j-8,this.#j/Q.frequency)),_=this.#v(this.#r(Z/this.#j)),j=this.#v(this.#r($/this.#j));this.#jJ(this.#U,Z,_,8),this.#jJ(this.#P,$,j,8)}#PJ(){let J=this.#I,Q=J.phase/360,Z=Math.max(0.1,J.frequency),$=0.25;if(J.type==="triangle")$=0.5;if(J.type==="sawtooth")$=1;let _=($-Q)/Z;while(_<0)_+=1/Z;while(_>1)_-=1/Z;if(_<0||_>1||!Number.isFinite(_))_=0.25;return Math.max(8,Math.min(this.#j-8,_*this.#j))}#jJ(J,Q,Z,$){if(!J)return;J.setAttribute("x",Q-$),J.setAttribute("y",Z-$),J.setAttribute("width",$*2),J.setAttribute("height",$*2)}#A(){for(let Q of this.#k)Q.addEventListener("change",(Z)=>{if(this.#L())return;let $=this.#F(Q);this.#w($),this.#Q[$].type=this.#x(Z.detail??Z.target?.value),this.#GJ(),this.#u("input"),this.#u("change")});for(let Q of this.#G)Q.addEventListener("input",(Z)=>{Z.stopPropagation(),this.#R=Q;try{this.#OJ(this.#F(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"input")}finally{this.#R=null}}),Q.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#OJ(this.#F(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"change")});for(let Q of this.#T)Q.addEventListener("pointerdown",()=>{this.#w(this.#F(Q))}),Q.addEventListener("focusin",()=>{this.#w(this.#F(Q))}),Q.addEventListener("openchange",(Z)=>{let $=this.#F(Q);if(Z.detail?.open)this.#q.add($);else this.#q.delete($)});for(let Q of this.querySelectorAll(".fig-input-oscillator-add-type")){let Z=($)=>{$.stopPropagation()};Q.addEventListener("pointerdown",Z),Q.addEventListener("click",Z),Q.addEventListener("change",($)=>{if($.target!==Q)return;if(this.#L())return;let j=this.#F(Q)+1,X=this.#x($.detail??Q.value);this.#Q.splice(j,0,q.#H(X)),this.#BJ(j),this.#Z=j,this.#p(),this.#u("input"),this.#u("change")})}for(let Q of this.querySelectorAll(".fig-input-oscillator-add-type-button")){let Z=($)=>{$.stopPropagation()};Q.addEventListener("pointerdown",Z),Q.addEventListener("click",Z),Q.closest("fig-tooltip")?.addEventListener("pointerdown",Z),Q.closest("fig-tooltip")?.addEventListener("click",Z)}for(let Q of this.querySelectorAll(".fig-input-oscillator-remove-button"))Q.addEventListener("pointerdown",(Z)=>{Z.stopPropagation()}),Q.addEventListener("click",(Z)=>{if(Z.stopPropagation(),this.#L()||this.#Q.length<=1)return;let $=this.#F(Q);this.#Q.splice($,1),this.#JJ($),this.#Z=Math.min(this.#Z,this.#Q.length-1),this.#p(),this.#u("input"),this.#u("change")});for(let Q of[this.#U,this.#P])this.#l(Q);this.querySelector(".fig-input-oscillator-svg-container")?.addEventListener("pointerdown",(Q)=>{if(this.#L())return;if(Q.target?.closest?.(".fig-input-oscillator-handle, fig-handle"))return;this.#NJ(Q,"offset")})}#F(J){let Q=Number.parseInt(J?.getAttribute("data-wave-index")||"",10);return Number.isFinite(Q)?Math.min(this.#Q.length-1,Math.max(0,Q)):0}#l(J){let Q=J?.querySelector("fig-handle"),Z=J?.getAttribute("data-handle");if(!Q||!Z)return;Q.addEventListener("pointerdown",($)=>{if(this.#L())return;$.preventDefault(),$.stopImmediatePropagation(),this.#NJ($,Z)},{capture:!0}),Q.addEventListener("keydown",($)=>{if(this.#L())return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes($.key))return;if(!this.#YJ($,Z))return;$.preventDefault(),$.stopImmediatePropagation()},{capture:!0})}#w(J){let Q=Math.min(this.#Q.length-1,Math.max(0,J));if(Q===this.#Z)return;this.#Z=Q,this.#MJ(),this.#qJ()}#OJ(J,Q,Z,$){if(this.#L())return;this.#w(J);let _=Number.parseFloat(Z);if(!Number.isFinite(_)){if($==="change")this.#SJ();return}this.#Q[J]=this.#S({...this.#Q[J],[Q]:_}),this.#GJ({skipFieldSync:$=="input"}),this.#u($)}#YJ(J,Q){let Z=J.shiftKey?0.5:0.1,$=this.#I;switch(Q){case"amplitude":if(J.key==="ArrowUp")$.amplitude+=Z;else if(J.key==="ArrowDown")$.amplitude-=Z;else if(J.key==="Home")$.amplitude=-4;else if(J.key==="End")$.amplitude=4;else return!1;break;case"offset":if(J.key==="ArrowUp")$.offset+=Z;else if(J.key==="ArrowDown")$.offset-=Z;else if(J.key==="Home")$.offset=-4;else if(J.key==="End")$.offset=4;else return!1;break;case"frequency":if(J.key==="ArrowLeft")$.frequency-=Z;else if(J.key==="ArrowRight")$.frequency+=Z;else if(J.key==="Home")$.frequency=0.1;else if(J.key==="End")$.frequency=16;else return!1;break;default:return!1}return this.#Q[this.#Z]=this.#S($),this.#GJ(),this.#u("input"),this.#u("change"),!0}#kJ(J){let Q=this.#_?.getScreenCTM();if(!Q)return{x:0,y:0};let Z=Q.inverse();return{x:Z.a*J.clientX+Z.c*J.clientY+Z.e,y:Z.b*J.clientX+Z.d*J.clientY+Z.f}}#NJ(J,Q){this.#K=Q,this.#_?.classList.add("dragging");let Z=Q==="frequency"?"ew-resize":Q==="amplitude"?"ns-resize":"",$=document.body.style.cursor;if(Z)document.body.style.cursor=Z;let _=(X)=>{if(!this.#K)return;let G=this.#kJ(X),B=this.#I;if(Q==="frequency"){let K=Math.max(1,Math.min(this.#j,G.x));B.frequency=this.#j/K}else if(Q==="offset"){let K=this.#E(G.x/this.#j,0,0,1),O=this.#UJ(B,K);B.offset=this.#t(G.y)-this.#LJ(this.#Z,K)-O*B.amplitude}else if(Q==="amplitude"){let K=this.#E(G.x/this.#j,0,0,1),O=this.#UJ(B,K),Y=this.#t(G.y)-this.#LJ(this.#Z,K)-B.offset;B.amplitude=Math.abs(O)<0.001?B.amplitude:Y/O}this.#Q[this.#Z]=this.#S(B),this.#GJ(),this.#u("input")},j=()=>{if(this.#K=null,this.#_?.classList.remove("dragging"),Z)document.body.style.cursor=$;document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",j),this.#u("change")};document.addEventListener("pointermove",_),document.addEventListener("pointerup",j)}#LJ(J,Q){return this.#Q.reduce((Z,$,_)=>{if(_===J)return Z;let j=Q*$.frequency,X=q.#o($.type,j,$.phase);return Z+$.offset+X*$.amplitude},0)}#UJ(J,Q){return q.#o(J.type,Q*J.frequency,J.phase)}#GJ({skipFieldSync:J=!1}={}){if(this.#zJ(),!J)this.#SJ();this.#MJ(),this.#n()}#zJ(){for(let J of this.#k){let Q=this.#F(J);J.value=this.#Q[Q]?.type||"sine"}}#SJ(){for(let J of this.#G){if(J===this.#R)continue;let Q=this.#F(J),Z=J.getAttribute("name"),$=this.#c(this.#Q[Q]?.[Z]??0),_=J.querySelector("fig-slider");if(_)_.value=$;else J.setAttribute("value",String($))}}#MJ(){for(let J of this.#z)if(this.#F(J)===this.#Z)J.setAttribute("data-active","");else J.removeAttribute("data-active")}#u(J){this.dispatchEvent(new CustomEvent(J,{bubbles:!0,detail:{value:this.value,data:this.data,preset:q.#$J(this.#I.type)}}))}}customElements.define("fig-input-oscillator",q);class A extends HTMLElement{#Q;#Z;#J=null;#j;#B;#O;#K;#_;#X;constructor(){super();this.angle=0,this.#Q=1,this.#Z=0,this.isDragging=!1,this.isShiftHeld=!1,this.handle=null,this.angleInput=null,this.plane=null,this.units="°",this.min=null,this.max=null,this.dial=!0,this.showRotations=!1,this.rotationSpan=null,this.#j=this.#R.bind(this),this.#B=this.#b.bind(this),this.#O=this.#I.bind(this),this.#K=this.#x.bind(this),this.#_=this.#E.bind(this),this.#X=this.#H.bind(this)}connectedCallback(){requestAnimationFrame(()=>{this.precision=this.getAttribute("precision")||1,this.precision=parseInt(this.precision),this.text=this.getAttribute("text")==="true";let J=this.getAttribute("units")||"°";if(J==="deg")J="°";if(this.units=J,this.min=this.hasAttribute("min")?Number(this.getAttribute("min")):null,this.max=this.hasAttribute("max")?Number(this.getAttribute("max")):null,this.dial=this.#Y("dial",!0),this.showRotations=this.#f(),this.#$(),this.#q(),this.#S(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision))})}disconnectedCallback(){this.#C()}#$(){this.innerHTML=this.#N()}#Y(J,Q=!1){let Z=this.getAttribute(J);if(Z===null)return Q;let $=Z.trim().toLowerCase();if($===""||$==="true")return!0;if($==="false")return!1;return!0}#f(){if(this.hasAttribute("rotations"))return this.#Y("rotations",!1);if(this.hasAttribute("show-rotations"))return this.#Y("show-rotations",!1);return!1}#N(){let J=this.#G(),Q=this.min!==null?`min="${this.min}"`:"",Z=this.max!==null?`max="${this.max}"`:"";return`
|
|
35
|
+
</option>`}).join(""),j=$===null?"":` data-wave-index="${q.#y(String($))}"`;return`<fig-dropdown class="${J}" value="${Q}" experimental="modern" type="dropdown" label="Add form"${j}${Z}>${_}</fig-dropdown>`}#s(J,Q,Z,$,_,j,X){let G=this.#S()?" disabled":"",B=X?` units="${q.#y(X)}"`:"",K=this.#Q[J]||q.#H();return`<propskit-slider class="propskit-oscillator-field" label="${Z}" direction="horizontal" name="${Q}" data-wave-index="${J}" value="${this.#c(K[Q])}" min="${$}" max="${_}" step="${j}" precision="${this.#J}" elastic="false"${B}${G}></propskit-slider>`}#i(){this.#$=this.querySelector(".propskit-oscillator-svg"),this.#G=this.querySelector(".propskit-oscillator-path"),this.#_=this.querySelector(".propskit-oscillator-playhead"),this.#k=this.querySelector(".propskit-oscillator-baseline"),this.#Y=this.querySelector(".propskit-oscillator-bounds"),this.#N=this.querySelector('[data-handle="amplitude"]'),this.#q=this.querySelector('[data-handle="frequency"]'),this.#U=Array.from(this.querySelectorAll(".propskit-oscillator-wave-type")),this.#P=Array.from(this.querySelectorAll("propskit-slider[name]")),this.#C=Array.from(this.querySelectorAll("fig-group.propskit-oscillator-wave")),this.#T=Array.from(this.querySelectorAll(".propskit-oscillator-fields"))}#JJ(J){let Q=new Set;for(let Z of this.#L)if(Z<J)Q.add(Z);else if(Z>J)Q.add(Z-1);this.#L=Q}#BJ(J){let Q=new Set;for(let Z of this.#L)Q.add(Z>=J?Z+1:Z);Q.add(J),this.#L=Q}#h(){if(this.#F||!window.ResizeObserver)return;this.#F=new ResizeObserver(()=>{if(this.#a())this.#n()}),this.#F.observe(this)}#a(){if(!this.#$)return!1;let J=this.#$.getBoundingClientRect(),Q=Math.max(1,Math.round(J.width||240)),Z=Math.max(1,Math.round(J.height||120)),$=Q!==this.#j||Z!==this.#X;return this.#j=Q,this.#X=Z,this.#$.setAttribute("viewBox",`0 0 ${Q} ${Z}`),$}#KJ(){let J=1,Q=256;for(let Z=0;Z<=Q;Z++)J=Math.max(J,Math.abs(this.#r(Z/Q)));return{min:-J,max:J}}#v(J){let{min:Q,max:Z}=this.#K;return this.#X-(J-Q)/(Z-Q)*this.#X}#t(J){let{min:Q,max:Z}=this.#K;return Q+(1-J/this.#X)*(Z-Q)}#r(J){return this.#Q.reduce((Q,Z)=>{let $=J*Z.frequency,_=q.#o(Z.type,$,Z.phase);return Q+Z.offset+_*Z.amplitude},0)}#n(){if(!this.#$||!this.#G)return;if(this.#a(),this.#K=this.#KJ(),this.#Y)this.#Y.setAttribute("width",this.#j),this.#Y.setAttribute("height",this.#X);let J=Math.max(...this.#Q.map((j)=>j.frequency)),Z=this.#Q.some((j)=>j.type==="square"||j.type==="sawtooth")?Math.max(192,Math.ceil(J*64)):Math.max(96,Math.ceil(J*64)),$="";for(let j=0;j<=Z;j++){let X=j/Z,G=X*this.#j,B=this.#v(this.#r(X));$+=`${j===0?"M":"L"}${G.toFixed(1)},${B.toFixed(1)}`}this.#G.setAttribute("d",$);let _=this.#v(0);this.#k?.setAttribute("x1","0"),this.#k?.setAttribute("y1",_),this.#k?.setAttribute("x2",this.#j),this.#k?.setAttribute("y2",_),this.#qJ()}#QJ(){if(this.#O||!this.#_)return;let J=(Q)=>{if(!this.isConnected||!this.#_){this.#O=0;return}this.#_J(Q%1000/1000),this.#O=requestAnimationFrame(J)};this.#O=requestAnimationFrame(J)}#ZJ(){if(!this.#O)return;cancelAnimationFrame(this.#O),this.#O=0}#_J(J){if(!this.#_)return;let Q=J*this.#j,Z=this.#v(this.#r(J));this.#_.setAttribute("cx",Q.toFixed(1)),this.#_.setAttribute("cy",Z.toFixed(1))}#qJ(){let Q=this.#I,Z=this.#PJ(),$=Math.max(8,Math.min(this.#j-8,this.#j/Q.frequency)),_=this.#v(this.#r(Z/this.#j)),j=this.#v(this.#r($/this.#j));this.#jJ(this.#N,Z,_,8),this.#jJ(this.#q,$,j,8)}#PJ(){let J=this.#I,Q=J.phase/360,Z=Math.max(0.1,J.frequency),$=0.25;if(J.type==="triangle")$=0.5;if(J.type==="sawtooth")$=1;let _=($-Q)/Z;while(_<0)_+=1/Z;while(_>1)_-=1/Z;if(_<0||_>1||!Number.isFinite(_))_=0.25;return Math.max(8,Math.min(this.#j-8,_*this.#j))}#jJ(J,Q,Z,$){if(!J)return;J.setAttribute("x",Q-$),J.setAttribute("y",Z-$),J.setAttribute("width",$*2),J.setAttribute("height",$*2)}#A(){for(let Q of this.#U)Q.addEventListener("change",(Z)=>{if(this.#S())return;let $=this.#R(Q);this.#w($),this.#Q[$].type=this.#x(Z.detail??Z.target?.value),this.#GJ(),this.#u("input"),this.#u("change")});for(let Q of this.#P)Q.addEventListener("input",(Z)=>{Z.stopPropagation(),this.#V=Q;try{this.#OJ(this.#R(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"input")}finally{this.#V=null}}),Q.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#OJ(this.#R(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"change")});for(let Q of this.#C)Q.addEventListener("pointerdown",()=>{this.#w(this.#R(Q))}),Q.addEventListener("focusin",()=>{this.#w(this.#R(Q))}),Q.addEventListener("openchange",(Z)=>{let $=this.#R(Q);if(Z.detail?.open)this.#L.add($);else this.#L.delete($)});for(let Q of this.querySelectorAll(".propskit-oscillator-add-type")){let Z=($)=>{$.stopPropagation()};Q.addEventListener("pointerdown",Z),Q.addEventListener("click",Z),Q.addEventListener("change",($)=>{if($.target!==Q)return;if(this.#S())return;let j=this.#R(Q)+1,X=this.#x($.detail??Q.value);this.#Q.splice(j,0,q.#H(X)),this.#BJ(j),this.#Z=j,this.#p(),this.#u("input"),this.#u("change")})}for(let Q of this.querySelectorAll(".propskit-oscillator-add-type-button")){let Z=($)=>{$.stopPropagation()};Q.addEventListener("pointerdown",Z),Q.addEventListener("click",Z),Q.closest("fig-tooltip")?.addEventListener("pointerdown",Z),Q.closest("fig-tooltip")?.addEventListener("click",Z)}for(let Q of this.querySelectorAll(".propskit-oscillator-remove-button"))Q.addEventListener("pointerdown",(Z)=>{Z.stopPropagation()}),Q.addEventListener("click",(Z)=>{if(Z.stopPropagation(),this.#S()||this.#Q.length<=1)return;let $=this.#R(Q);this.#Q.splice($,1),this.#JJ($),this.#Z=Math.min(this.#Z,this.#Q.length-1),this.#p(),this.#u("input"),this.#u("change")});for(let Q of[this.#N,this.#q])this.#l(Q);this.querySelector(".propskit-oscillator-svg-container")?.addEventListener("pointerdown",(Q)=>{if(this.#S())return;if(Q.target?.closest?.(".propskit-oscillator-handle, fig-handle"))return;this.#NJ(Q,"offset")})}#R(J){let Q=Number.parseInt(J?.getAttribute("data-wave-index")||"",10);return Number.isFinite(Q)?Math.min(this.#Q.length-1,Math.max(0,Q)):0}#l(J){let Q=J?.querySelector("fig-handle"),Z=J?.getAttribute("data-handle");if(!Q||!Z)return;Q.addEventListener("pointerdown",($)=>{if(this.#S())return;$.preventDefault(),$.stopImmediatePropagation(),this.#NJ($,Z)},{capture:!0}),Q.addEventListener("keydown",($)=>{if(this.#S())return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes($.key))return;if(!this.#YJ($,Z))return;$.preventDefault(),$.stopImmediatePropagation()},{capture:!0})}#w(J){let Q=Math.min(this.#Q.length-1,Math.max(0,J));if(Q===this.#Z)return;this.#Z=Q,this.#MJ(),this.#qJ()}#OJ(J,Q,Z,$){if(this.#S())return;this.#w(J);let _=Number.parseFloat(Z);if(!Number.isFinite(_)){if($==="change")this.#SJ();return}this.#Q[J]=this.#M({...this.#Q[J],[Q]:_}),this.#GJ({skipFieldSync:$=="input"}),this.#u($)}#YJ(J,Q){let Z=J.shiftKey?0.5:0.1,$=this.#I;switch(Q){case"amplitude":if(J.key==="ArrowUp")$.amplitude+=Z;else if(J.key==="ArrowDown")$.amplitude-=Z;else if(J.key==="Home")$.amplitude=-4;else if(J.key==="End")$.amplitude=4;else return!1;break;case"offset":if(J.key==="ArrowUp")$.offset+=Z;else if(J.key==="ArrowDown")$.offset-=Z;else if(J.key==="Home")$.offset=-4;else if(J.key==="End")$.offset=4;else return!1;break;case"frequency":if(J.key==="ArrowLeft")$.frequency-=Z;else if(J.key==="ArrowRight")$.frequency+=Z;else if(J.key==="Home")$.frequency=0.1;else if(J.key==="End")$.frequency=16;else return!1;break;default:return!1}return this.#Q[this.#Z]=this.#M($),this.#GJ(),this.#u("input"),this.#u("change"),!0}#kJ(J){let Q=this.#$?.getScreenCTM();if(!Q)return{x:0,y:0};let Z=Q.inverse();return{x:Z.a*J.clientX+Z.c*J.clientY+Z.e,y:Z.b*J.clientX+Z.d*J.clientY+Z.f}}#NJ(J,Q){this.#B=Q,this.#$?.classList.add("dragging");let Z=Q==="frequency"?"ew-resize":Q==="amplitude"?"ns-resize":"",$=document.body.style.cursor;if(Z)document.body.style.cursor=Z;let _=(X)=>{if(!this.#B)return;let G=this.#kJ(X),B=this.#I;if(Q==="frequency"){let K=Math.max(1,Math.min(this.#j,G.x));B.frequency=this.#j/K}else if(Q==="offset"){let K=this.#E(G.x/this.#j,0,0,1),O=this.#UJ(B,K);B.offset=this.#t(G.y)-this.#LJ(this.#Z,K)-O*B.amplitude}else if(Q==="amplitude"){let K=this.#E(G.x/this.#j,0,0,1),O=this.#UJ(B,K),Y=this.#t(G.y)-this.#LJ(this.#Z,K)-B.offset;B.amplitude=Math.abs(O)<0.001?B.amplitude:Y/O}this.#Q[this.#Z]=this.#M(B),this.#GJ(),this.#u("input")},j=()=>{if(this.#B=null,this.#$?.classList.remove("dragging"),Z)document.body.style.cursor=$;document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",j),this.#u("change")};document.addEventListener("pointermove",_),document.addEventListener("pointerup",j)}#LJ(J,Q){return this.#Q.reduce((Z,$,_)=>{if(_===J)return Z;let j=Q*$.frequency,X=q.#o($.type,j,$.phase);return Z+$.offset+X*$.amplitude},0)}#UJ(J,Q){return q.#o(J.type,Q*J.frequency,J.phase)}#GJ({skipFieldSync:J=!1}={}){if(this.#zJ(),!J)this.#SJ();this.#MJ(),this.#n()}#zJ(){for(let J of this.#U){let Q=this.#R(J);J.value=this.#Q[Q]?.type||"sine"}}#SJ(){for(let J of this.#P){if(J===this.#V)continue;let Q=this.#R(J),Z=J.getAttribute("name"),$=this.#c(this.#Q[Q]?.[Z]??0),_=J.querySelector("fig-slider");if(_)_.value=$;else J.setAttribute("value",String($))}}#MJ(){for(let J of this.#T)if(this.#R(J)===this.#Z)J.setAttribute("data-active","");else J.removeAttribute("data-active")}#u(J){this.dispatchEvent(new CustomEvent(J,{bubbles:!0,detail:{value:this.value,data:this.data,preset:q.#$J(this.#I.type)}}))}}customElements.define("propskit-oscillator",q);class h extends HTMLElement{#Q;#Z;#J=null;#j;#X;#K;#B;#$;#G;constructor(){super();this.angle=0,this.#Q=1,this.#Z=0,this.isDragging=!1,this.isShiftHeld=!1,this.handle=null,this.angleInput=null,this.plane=null,this.units="°",this.min=null,this.max=null,this.dial=!0,this.showRotations=!1,this.rotationSpan=null,this.#j=this.#V.bind(this),this.#X=this.#b.bind(this),this.#K=this.#I.bind(this),this.#B=this.#x.bind(this),this.#$=this.#E.bind(this),this.#G=this.#H.bind(this)}connectedCallback(){requestAnimationFrame(()=>{this.precision=this.getAttribute("precision")||1,this.precision=parseInt(this.precision),this.text=this.getAttribute("text")==="true";let J=this.getAttribute("units")||"°";if(J==="deg")J="°";if(this.units=J,this.min=this.hasAttribute("min")?Number(this.getAttribute("min")):null,this.max=this.hasAttribute("max")?Number(this.getAttribute("max")):null,this.dial=this.#O("dial",!0),this.showRotations=this.#k(),this.#_(),this.#L(),this.#M(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision))})}disconnectedCallback(){this.#F()}#_(){this.innerHTML=this.#Y()}#O(J,Q=!1){let Z=this.getAttribute(J);if(Z===null)return Q;let $=Z.trim().toLowerCase();if($===""||$==="true")return!0;if($==="false")return!1;return!0}#k(){if(this.hasAttribute("rotations"))return this.#O("rotations",!1);if(this.hasAttribute("show-rotations"))return this.#O("show-rotations",!1);return!1}#Y(){let J=this.#P(),Q=this.min!==null?`min="${this.min}"`:"",Z=this.max!==null?`max="${this.max}"`:"";return`
|
|
36
36
|
${this.dial?`<div class="fig-input-angle-plane" tabindex="0">
|
|
37
37
|
<div class="fig-input-angle-handle"></div>
|
|
38
38
|
</div>`:""}
|
|
@@ -45,4 +45,4 @@ function D(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class I ex
|
|
|
45
45
|
units="${this.units}">
|
|
46
46
|
${this.showRotations?'<span slot="append" class="fig-input-angle-rotations"></span>':""}
|
|
47
47
|
</fig-input-number>`:""}
|
|
48
|
-
`}#U(){let J=Math.abs(this.#k(this.angle));return Math.floor(J/360)}#P(){if(!this.rotationSpan)return;let J=this.#U();if(J>1)this.rotationSpan.textContent=`×${J}`,this.rotationSpan.style.display="";else this.rotationSpan.textContent="",this.rotationSpan.style.display="none"}#G(){switch(this.units){case"rad":return 0.01;case"turn":return 0.001;default:return 0.1}}#k(J){switch(this.units){case"rad":return J*180/Math.PI;case"turn":return J*360;default:return J}}#z(J){switch(this.units){case"rad":return J*Math.PI/180;case"turn":return J/360;default:return J}}#T(J,Q,Z){let $;switch(Q){case"rad":$=J*180/Math.PI;break;case"turn":$=J*360;break;default:$=J}switch(Z){case"rad":return $*Math.PI/180;case"turn":return $/360;default:return $}}#q(){if(this.handle=this.querySelector(".fig-input-angle-handle"),this.plane=this.querySelector(".fig-input-angle-plane"),this.angleInput=this.querySelector("fig-input-number[name='angle']"),this.rotationSpan=this.querySelector(".fig-input-angle-rotations"),this.#P(),this.plane?.addEventListener("mousedown",this.#B),this.plane?.addEventListener("touchstart",this.#O),window.addEventListener("keydown",this.#K),window.addEventListener("keyup",this.#_),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#X);this.addEventListener("change",this.#j,!0)}#C(){if(this.plane?.removeEventListener("mousedown",this.#B),this.plane?.removeEventListener("touchstart",this.#O),window.removeEventListener("keydown",this.#K),window.removeEventListener("keyup",this.#_),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#X);this.removeEventListener("change",this.#j,!0)}#R(J){if(!J.target?.matches?.("input"))return;let Z=J.target.value.match(/^(-?\d*\.?\d+)\s*(turn|rad|deg|°)$/i);if(Z){let $=parseFloat(Z[1]),_=Z[2].toLowerCase();if(_==="deg")_="°";if(_!==this.units){let j=this.#T($,_,this.units);J.target.value=String(j)}}}#H(J){J.stopPropagation(),this.angle=Number(J.target.value),this.#M(),this.#S(),this.#P(),this.#D(),this.#W()}#M(){let Q=this.#k(this.angle)*Math.PI/180;this.#Q=Math.cos(Q),this.#Z=Math.sin(Q)}#V(J){if(!this.isShiftHeld)return J;let Q=45;return Math.round(J/Q)*Q}#g(J){let Q=this.plane.getBoundingClientRect(),Z=Q.left+Q.width/2,$=Q.top+Q.height/2,_=J.clientX-Z,j=J.clientY-$;return Math.atan2(j,_)*180/Math.PI}#L(J){let Z=(this.#g(J)%360+360)%360;if(Z=this.#V(Z),this.min!==null||this.max!==null)this.angle=this.#z(Z);else if(this.#J===null){this.#J=Z;let j=(this.#k(this.angle)%360+360)%360,X=Z-j;if(X>180)X-=360;if(X<-180)X+=360;this.angle+=this.#z(X)}else{let _=Z-this.#J;if(_>180)_-=360;if(_<-180)_+=360;this.angle+=this.#z(_),this.#J=Z}if(this.#M(),this.#S(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#P(),this.#D()}#D(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#W(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#S(){if(this.handle){let Q=this.#k(this.angle)*Math.PI/180,Z=this.plane.offsetWidth/2-this.handle.offsetWidth/2,$=Math.cos(Q)*Z,_=Math.sin(Q)*Z;this.handle.style.transform=`translate(${$}px, ${_}px)`}}#b(J){this.isDragging=!0,this.#J=null,this.#L(J);let Q=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#L($)},Z=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("mousemove",Q),window.removeEventListener("mouseup",Z),this.#W()};window.addEventListener("mousemove",Q),window.addEventListener("mouseup",Z)}#I(J){J.preventDefault(),this.isDragging=!0,this.#J=null,this.#L(J.touches[0]);let Q=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#L($.touches[0])},Z=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("touchmove",Q),window.removeEventListener("touchend",Z),this.#W()};window.addEventListener("touchmove",Q),window.addEventListener("touchend",Z)}#x(J){if(J.key==="Shift")this.isShiftHeld=!0}#E(J){if(J.key==="Shift")this.isShiftHeld=!1}focus(){this.plane?.focus()}static get observedAttributes(){return["value","precision","text","min","max","units","dial","rotations","show-rotations"]}get value(){return this.angle}get adjacent(){return this.#Q}get opposite(){return this.#Z}set value(J){if(isNaN(J)){console.error("Invalid value: must be a number.");return}if(this.angle=J,this.#M(),this.#S(),this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#P()}attributeChangedCallback(J,Q,Z){switch(J){case"value":if(this.isDragging)break;this.value=Number(Z);break;case"precision":this.precision=parseInt(Z);break;case"text":if(Z!==Q){if(this.text=Z?.toLowerCase()==="true",this.isConnected)this.#$(),this.#q(),this.#S()}break;case"dial":if(this.dial=this.#Y("dial",!0),this.isConnected)this.#$(),this.#q(),this.#S();break;case"units":{let $=Z||"°";if($==="deg")$="°";if(this.units=$,this.isConnected)this.#$(),this.#q(),this.#S();break}case"min":if(this.min=Z!==null?Number(Z):null,this.isConnected)this.#$(),this.#q(),this.#S();break;case"max":if(this.max=Z!==null?Number(Z):null,this.isConnected)this.#$(),this.#q(),this.#S();break;case"rotations":case"show-rotations":if(this.showRotations=this.#f(),this.isConnected)this.#$(),this.#q(),this.#S();break}}}customElements.define("fig-input-angle",A);class F extends HTMLElement{static observedAttributes=["axis","handle","disabled"];static#Q=6;static#Z=["input","button","select","textarea","a[href]","label","summary","fig-button","fig-dropdown","fig-slider","fig-input-number","fig-input-text","fig-field-slider","fig-checkbox","fig-switch","fig-combo-input","fig-segmented-control","fig-input-color","fig-input-fill",'[contenteditable="true"]'];#J=null;#j=new Map;#B=null;#O=null;connectedCallback(){this.style.display="contents",this.#Y(),this.#J=new MutationObserver(()=>this.#Y()),this.#J.observe(this,{childList:!0})}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#S(),this.#b(),this.#L()}attributeChangedCallback(){if(this.isConnected)this.#Y()}get#K(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}get#_(){return(this.getAttribute("axis")||"vertical").trim().toLowerCase()==="horizontal"?"horizontal":"vertical"}get#X(){return(this.getAttribute("handle")||"").trim()}#$(){return[...this.children].filter((J)=>J.nodeType===Node.ELEMENT_NODE)}#Y(){let J=this.#$(),Q=new Set(J);for(let[Z,$]of this.#j)if(!Q.has(Z))$.target.removeEventListener("pointerdown",$.onPointerDown,!0),this.#j.delete(Z);if(this.#U(J),this.#f(J),this.#K||J.length<2){this.#S();return}for(let Z of J){let $=this.#G(Z),_=this.#j.get(Z);if(_&&_.target===$)continue;if(_)_.target.removeEventListener("pointerdown",_.onPointerDown,!0),this.#j.delete(Z);if(!$)continue;this.#k(Z,$)}this.#P(J),this.#N(J)}#f(J){for(let Q of J)Q.removeAttribute("data-reorder-item")}#N(J){for(let Q of J)Q.setAttribute("data-reorder-item","")}#U(J){for(let Q of J)Q.querySelectorAll("[data-reorder-handle]").forEach((Z)=>Z.removeAttribute("data-reorder-handle"))}#P(J){if(!this.#X)return;for(let Q of J){let Z=Q.querySelector(this.#X);if(Z)Z.setAttribute("data-reorder-handle","")}}#G(J){if(this.#X)return J.querySelector(this.#X);return J}#k(J,Q){let Z=($)=>{if(this.#K||this.#$().length<2)return;if($.button!==0)return;if(!this.#X&&this.#z($.target,J))return;this.#C($,J,Q)};Q.addEventListener("pointerdown",Z,!0),this.#j.set(J,{target:Q,onPointerDown:Z})}#z(J,Q){let Z=J;while(Z&&Z!==Q){if(Z instanceof Element){for(let $ of F.#Z)if(Z.matches($))return!0}Z=Z.parentElement}return!1}static#T="fig-reorder-dragging";static#q(J){document.body.classList.toggle(F.#T,J)}#C(J,Q,Z){this.#b(),F.#q(!0);let $={item:Q,target:Z,pointerId:J.pointerId,oldIndex:this.#$().indexOf(Q),targetIndex:this.#$().indexOf(Q),startX:J.clientX,startY:J.clientY,active:!1,onMove:null,onUp:null,onKeyDown:null};$.onMove=(_)=>{if(_.pointerId!==$.pointerId)return;let j=_.clientX-$.startX,X=_.clientY-$.startY;if(!$.active){if(j*j+X*X<F.#Q*F.#Q)return;$.active=!0,J.preventDefault(),J.stopPropagation(),Q.classList.add("dragging");try{Z.setPointerCapture($.pointerId)}catch{}}_.preventDefault();let G=this.#_==="horizontal"?_.clientX:_.clientY,B=this.#R(G);$.targetIndex=B,this.#g(B,Q)},$.onKeyDown=(_)=>{if(_.key!=="Escape"||!$.active)return;_.preventDefault(),this.#W($,!0)},$.onUp=(_)=>{if(_.pointerId!==$.pointerId)return;this.#W($,_.type==="pointercancel")},this.#B=$,window.addEventListener("pointermove",$.onMove),window.addEventListener("pointerup",$.onUp),window.addEventListener("pointercancel",$.onUp),window.addEventListener("keydown",$.onKeyDown)}#R(J){let Q=this.#$(),Z=this.#_==="horizontal";for(let $=0;$<Q.length;$++){let _=Q[$].getBoundingClientRect(),j=Z?_.left+_.width/2:_.top+_.height/2;if(J<j)return $}return Q.length}#H(J,Q){let Z=this.#$(),$=Z.indexOf(J);if($===-1)return!1;let _=Math.max(0,Math.min(Q,Z.length));if(Q===$)return!1;if(_>=Z.length&&$===Z.length-1)return!1;return!0}#M(J){if(!J.length)return null;let Q=1/0,Z=-1/0,$=1/0,_=-1/0;for(let j of J){let X=j.getBoundingClientRect();Q=Math.min(Q,X.left),Z=Math.max(Z,X.right),$=Math.min($,X.top),_=Math.max(_,X.bottom)}return{left:Q,top:$,width:Z-Q,height:_-$}}#V(){if(this.#O)return this.#O;let J=document.createElement("div");return J.className="fig-reorder-indicator",J.setAttribute("data-axis",this.#_),document.body.appendChild(J),this.#O=J,J}#g(J,Q){let Z=this.#$();if(!this.#H(Q,J)){this.#L();return}let $=this.#M(Z);if(!$){this.#L();return}let _=this.#V();if(_.setAttribute("data-axis",this.#_),this.#_==="horizontal"){let X;if(J<=0)X=Z[0].getBoundingClientRect().left;else if(J>=Z.length)X=Z[Z.length-1].getBoundingClientRect().right;else X=Z[J].getBoundingClientRect().left;_.style.left=`${X-1}px`,_.style.top=`${$.top}px`,_.style.width="2px",_.style.height=`${$.height}px`;return}let j;if(J<=0)j=Z[0].getBoundingClientRect().top;else if(J>=Z.length)j=Z[Z.length-1].getBoundingClientRect().bottom;else j=Z[J].getBoundingClientRect().top;_.style.left=`${$.left}px`,_.style.top=`${j-1}px`,_.style.width=`${$.width}px`,_.style.height="2px"}#L(){this.#O?.remove(),this.#O=null}#D(J,Q){let Z=this.#$(),$=Math.max(0,Math.min(Q,Z.length));if($>=Z.length){if(Z[Z.length-1]!==J)this.appendChild(J);return}let _=Z[$];if(_!==J)this.insertBefore(J,_)}#W(J,Q){let{item:Z,oldIndex:$,active:_,onMove:j,onUp:X,onKeyDown:G}=J;if(window.removeEventListener("pointermove",j),window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X),window.removeEventListener("keydown",G),_){if(!Q){this.#D(Z,J.targetIndex);let B=this.#$().indexOf(Z);if(B!==-1&&B!==$)this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:$,newIndex:B,item:Z}}))}}if(Z.classList.remove("dragging"),F.#q(!1),this.#L(),this.#B===J)this.#B=null}#S(){for(let[,J]of this.#j)J.target.removeEventListener("pointerdown",J.onPointerDown,!0);this.#j.clear()}#b(){if(!this.#B)return;this.#W(this.#B,!0)}}customElements.define("fig-reorder",F);
|
|
48
|
+
`}#N(){let J=Math.abs(this.#U(this.angle));return Math.floor(J/360)}#q(){if(!this.rotationSpan)return;let J=this.#N();if(J>1)this.rotationSpan.textContent=`×${J}`,this.rotationSpan.style.display="";else this.rotationSpan.textContent="",this.rotationSpan.style.display="none"}#P(){switch(this.units){case"rad":return 0.01;case"turn":return 0.001;default:return 0.1}}#U(J){switch(this.units){case"rad":return J*180/Math.PI;case"turn":return J*360;default:return J}}#T(J){switch(this.units){case"rad":return J*Math.PI/180;case"turn":return J/360;default:return J}}#C(J,Q,Z){let $;switch(Q){case"rad":$=J*180/Math.PI;break;case"turn":$=J*360;break;default:$=J}switch(Z){case"rad":return $*Math.PI/180;case"turn":return $/360;default:return $}}#L(){if(this.handle=this.querySelector(".fig-input-angle-handle"),this.plane=this.querySelector(".fig-input-angle-plane"),this.angleInput=this.querySelector("fig-input-number[name='angle']"),this.rotationSpan=this.querySelector(".fig-input-angle-rotations"),this.#q(),this.plane?.addEventListener("mousedown",this.#X),this.plane?.addEventListener("touchstart",this.#K),window.addEventListener("keydown",this.#B),window.addEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#G);this.addEventListener("change",this.#j,!0)}#F(){if(this.plane?.removeEventListener("mousedown",this.#X),this.plane?.removeEventListener("touchstart",this.#K),window.removeEventListener("keydown",this.#B),window.removeEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#G);this.removeEventListener("change",this.#j,!0)}#V(J){if(!J.target?.matches?.("input"))return;let Z=J.target.value.match(/^(-?\d*\.?\d+)\s*(turn|rad|deg|°)$/i);if(Z){let $=parseFloat(Z[1]),_=Z[2].toLowerCase();if(_==="deg")_="°";if(_!==this.units){let j=this.#C($,_,this.units);J.target.value=String(j)}}}#H(J){J.stopPropagation(),this.angle=Number(J.target.value),this.#z(),this.#M(),this.#q(),this.#D(),this.#W()}#z(){let Q=this.#U(this.angle)*Math.PI/180;this.#Q=Math.cos(Q),this.#Z=Math.sin(Q)}#f(J){if(!this.isShiftHeld)return J;let Q=45;return Math.round(J/Q)*Q}#g(J){let Q=this.plane.getBoundingClientRect(),Z=Q.left+Q.width/2,$=Q.top+Q.height/2,_=J.clientX-Z,j=J.clientY-$;return Math.atan2(j,_)*180/Math.PI}#S(J){let Z=(this.#g(J)%360+360)%360;if(Z=this.#f(Z),this.min!==null||this.max!==null)this.angle=this.#T(Z);else if(this.#J===null){this.#J=Z;let j=(this.#U(this.angle)%360+360)%360,X=Z-j;if(X>180)X-=360;if(X<-180)X+=360;this.angle+=this.#T(X)}else{let _=Z-this.#J;if(_>180)_-=360;if(_<-180)_+=360;this.angle+=this.#T(_),this.#J=Z}if(this.#z(),this.#M(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#q(),this.#D()}#D(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#W(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#M(){if(this.handle){let Q=this.#U(this.angle)*Math.PI/180,Z=this.plane.offsetWidth/2-this.handle.offsetWidth/2,$=Math.cos(Q)*Z,_=Math.sin(Q)*Z;this.handle.style.transform=`translate(${$}px, ${_}px)`}}#b(J){this.isDragging=!0,this.#J=null,this.#S(J);let Q=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#S($)},Z=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("mousemove",Q),window.removeEventListener("mouseup",Z),this.#W()};window.addEventListener("mousemove",Q),window.addEventListener("mouseup",Z)}#I(J){J.preventDefault(),this.isDragging=!0,this.#J=null,this.#S(J.touches[0]);let Q=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#S($.touches[0])},Z=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("touchmove",Q),window.removeEventListener("touchend",Z),this.#W()};window.addEventListener("touchmove",Q),window.addEventListener("touchend",Z)}#x(J){if(J.key==="Shift")this.isShiftHeld=!0}#E(J){if(J.key==="Shift")this.isShiftHeld=!1}focus(){this.plane?.focus()}static get observedAttributes(){return["value","precision","text","min","max","units","dial","rotations","show-rotations"]}get value(){return this.angle}get adjacent(){return this.#Q}get opposite(){return this.#Z}set value(J){if(isNaN(J)){console.error("Invalid value: must be a number.");return}if(this.angle=J,this.#z(),this.#M(),this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#q()}attributeChangedCallback(J,Q,Z){switch(J){case"value":if(this.isDragging)break;this.value=Number(Z);break;case"precision":this.precision=parseInt(Z);break;case"text":if(Z!==Q){if(this.text=Z?.toLowerCase()==="true",this.isConnected)this.#_(),this.#L(),this.#M()}break;case"dial":if(this.dial=this.#O("dial",!0),this.isConnected)this.#_(),this.#L(),this.#M();break;case"units":{let $=Z||"°";if($==="deg")$="°";if(this.units=$,this.isConnected)this.#_(),this.#L(),this.#M();break}case"min":if(this.min=Z!==null?Number(Z):null,this.isConnected)this.#_(),this.#L(),this.#M();break;case"max":if(this.max=Z!==null?Number(Z):null,this.isConnected)this.#_(),this.#L(),this.#M();break;case"rotations":case"show-rotations":if(this.showRotations=this.#k(),this.isConnected)this.#_(),this.#L(),this.#M();break}}}customElements.define("fig-input-angle",h);class F extends HTMLElement{static observedAttributes=["axis","handle","disabled"];static#Q=6;static#Z=["input","button","select","textarea","a[href]","label","summary","fig-button","fig-dropdown","fig-slider","fig-input-number","fig-input-text","propskit-number","propskit-select","propskit-slider","propskit-switch","propskit-text","fig-checkbox","fig-switch","fig-combo-input","fig-segmented-control","fig-input-color","fig-input-fill",'[contenteditable="true"]'];#J=null;#j=new Map;#X=null;#K=null;connectedCallback(){this.style.display="contents",this.#O(),this.#J=new MutationObserver(()=>this.#O()),this.#J.observe(this,{childList:!0})}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#M(),this.#b(),this.#S()}attributeChangedCallback(){if(this.isConnected)this.#O()}get#B(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}get#$(){return(this.getAttribute("axis")||"vertical").trim().toLowerCase()==="horizontal"?"horizontal":"vertical"}get#G(){return(this.getAttribute("handle")||"").trim()}#_(){return[...this.children].filter((J)=>J.nodeType===Node.ELEMENT_NODE)}#O(){let J=this.#_(),Q=new Set(J);for(let[Z,$]of this.#j)if(!Q.has(Z))$.target.removeEventListener("pointerdown",$.onPointerDown,!0),this.#j.delete(Z);if(this.#N(J),this.#k(J),this.#B||J.length<2){this.#M();return}for(let Z of J){let $=this.#P(Z),_=this.#j.get(Z);if(_&&_.target===$)continue;if(_)_.target.removeEventListener("pointerdown",_.onPointerDown,!0),this.#j.delete(Z);if(!$)continue;this.#U(Z,$)}this.#q(J),this.#Y(J)}#k(J){for(let Q of J)Q.removeAttribute("data-reorder-item")}#Y(J){for(let Q of J)Q.setAttribute("data-reorder-item","")}#N(J){for(let Q of J)Q.querySelectorAll("[data-reorder-handle]").forEach((Z)=>Z.removeAttribute("data-reorder-handle"))}#q(J){if(!this.#G)return;for(let Q of J){let Z=Q.querySelector(this.#G);if(Z)Z.setAttribute("data-reorder-handle","")}}#P(J){if(this.#G)return J.querySelector(this.#G);return J}#U(J,Q){let Z=($)=>{if(this.#B||this.#_().length<2)return;if($.button!==0)return;if(!this.#G&&this.#T($.target,J))return;this.#F($,J,Q)};Q.addEventListener("pointerdown",Z,!0),this.#j.set(J,{target:Q,onPointerDown:Z})}#T(J,Q){let Z=J;while(Z&&Z!==Q){if(Z instanceof Element){for(let $ of F.#Z)if(Z.matches($))return!0}Z=Z.parentElement}return!1}static#C="fig-reorder-dragging";static#L(J){document.body.classList.toggle(F.#C,J)}#F(J,Q,Z){this.#b(),F.#L(!0);let $={item:Q,target:Z,pointerId:J.pointerId,oldIndex:this.#_().indexOf(Q),targetIndex:this.#_().indexOf(Q),startX:J.clientX,startY:J.clientY,active:!1,onMove:null,onUp:null,onKeyDown:null};$.onMove=(_)=>{if(_.pointerId!==$.pointerId)return;let j=_.clientX-$.startX,X=_.clientY-$.startY;if(!$.active){if(j*j+X*X<F.#Q*F.#Q)return;$.active=!0,J.preventDefault(),J.stopPropagation(),Q.classList.add("dragging");try{Z.setPointerCapture($.pointerId)}catch{}}_.preventDefault();let G=this.#$==="horizontal"?_.clientX:_.clientY,B=this.#V(G);$.targetIndex=B,this.#g(B,Q)},$.onKeyDown=(_)=>{if(_.key!=="Escape"||!$.active)return;_.preventDefault(),this.#W($,!0)},$.onUp=(_)=>{if(_.pointerId!==$.pointerId)return;this.#W($,_.type==="pointercancel")},this.#X=$,window.addEventListener("pointermove",$.onMove),window.addEventListener("pointerup",$.onUp),window.addEventListener("pointercancel",$.onUp),window.addEventListener("keydown",$.onKeyDown)}#V(J){let Q=this.#_(),Z=this.#$==="horizontal";for(let $=0;$<Q.length;$++){let _=Q[$].getBoundingClientRect(),j=Z?_.left+_.width/2:_.top+_.height/2;if(J<j)return $}return Q.length}#H(J,Q){let Z=this.#_(),$=Z.indexOf(J);if($===-1)return!1;let _=Math.max(0,Math.min(Q,Z.length));if(Q===$)return!1;if(_>=Z.length&&$===Z.length-1)return!1;return!0}#z(J){if(!J.length)return null;let Q=1/0,Z=-1/0,$=1/0,_=-1/0;for(let j of J){let X=j.getBoundingClientRect();Q=Math.min(Q,X.left),Z=Math.max(Z,X.right),$=Math.min($,X.top),_=Math.max(_,X.bottom)}return{left:Q,top:$,width:Z-Q,height:_-$}}#f(){if(this.#K)return this.#K;let J=document.createElement("div");return J.className="fig-reorder-indicator",J.setAttribute("data-axis",this.#$),document.body.appendChild(J),this.#K=J,J}#g(J,Q){let Z=this.#_();if(!this.#H(Q,J)){this.#S();return}let $=this.#z(Z);if(!$){this.#S();return}let _=this.#f();if(_.setAttribute("data-axis",this.#$),this.#$==="horizontal"){let X;if(J<=0)X=Z[0].getBoundingClientRect().left;else if(J>=Z.length)X=Z[Z.length-1].getBoundingClientRect().right;else X=Z[J].getBoundingClientRect().left;_.style.left=`${X-1}px`,_.style.top=`${$.top}px`,_.style.width="2px",_.style.height=`${$.height}px`;return}let j;if(J<=0)j=Z[0].getBoundingClientRect().top;else if(J>=Z.length)j=Z[Z.length-1].getBoundingClientRect().bottom;else j=Z[J].getBoundingClientRect().top;_.style.left=`${$.left}px`,_.style.top=`${j-1}px`,_.style.width=`${$.width}px`,_.style.height="2px"}#S(){this.#K?.remove(),this.#K=null}#D(J,Q){let Z=this.#_(),$=Math.max(0,Math.min(Q,Z.length));if($>=Z.length){if(Z[Z.length-1]!==J)this.appendChild(J);return}let _=Z[$];if(_!==J)this.insertBefore(J,_)}#W(J,Q){let{item:Z,oldIndex:$,active:_,onMove:j,onUp:X,onKeyDown:G}=J;if(window.removeEventListener("pointermove",j),window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X),window.removeEventListener("keydown",G),_){if(!Q){this.#D(Z,J.targetIndex);let B=this.#_().indexOf(Z);if(B!==-1&&B!==$)this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:$,newIndex:B,item:Z}}))}}if(Z.classList.remove("dragging"),F.#L(!1),this.#S(),this.#X===J)this.#X=null}#M(){for(let[,J]of this.#j)J.target.removeEventListener("pointerdown",J.onPointerDown,!0);this.#j.clear()}#b(){if(!this.#X)return;this.#W(this.#X,!0)}}customElements.define("fig-reorder",F);
|