@rogieking/figui3 6.16.0 → 6.18.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 +8 -8
- package/components.css +45 -2
- package/dist/components.css +1 -1
- package/dist/fig-editor.css +1 -1
- package/dist/fig-lab.css +1 -1
- package/dist/fig-lab.js +91 -13
- package/dist/fig.css +1 -1
- package/dist/fig.js +22 -22
- package/fig-lab.css +280 -8
- package/fig-lab.js +1077 -26
- package/fig.js +65 -8
- package/package.json +1 -1
package/dist/fig-lab.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function R(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class I extends HTMLElement{#Q=null;#Z=null;#J=null;#_=!1;#j=null;#O=new Set;#G=null;#$=null;#B=this.#P.bind(this);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Q)this.#X();if(this.#K(),this.#Y(),this.#k(),this.removeEventListener("click",this.#B),this.addEventListener("click",this.#B),!this.#j)this.#j=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.#K();if(Z)this.#Y()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#N(),this.removeEventListener("click",this.#B)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction")this.#K()}#X(){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.#_=Boolean(Q),this.replaceChildren(Z)}#K(){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.#_)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")}#U(){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-"))}#Y(){if(!this.#J)return;let J=this.#U(),Q=new Set(J);for(let Z of this.#O)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.#O=Q}#k(){if(!this.#J)return;this.#G??=this.#q.bind(this,"input"),this.#$??=this.#q.bind(this,"change"),this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#$)}#N(){if(!this.#J)return;if(this.#G)this.#J.removeEventListener("input",this.#G);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}))}#P(J){if(J.target instanceof Element&&J.target.closest("fig-segmented-control"))return;let Q=this.#J?.value==="on"?"off":"on";this.#J?.querySelector(`fig-segment[value="${Q}"]`)?.click()}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;#_=!1;#j=null;#O=new Set;#G=null;#$=null;#B=this.#P.bind(this);static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Q)this.#X();if(this.#K(),this.#Y(),this.#k(),this.removeEventListener("click",this.#B),this.addEventListener("click",this.#B),!this.#j)this.#j=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.#K();if(Z)this.#Y()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#N(),this.removeEventListener("click",this.#B)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction"||J==="aria-label")this.#K()}#X(){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-color");for(let j of J)if(j!==Q)_.appendChild(j);Z.append($,_),this.#Q=Z,this.#Z=$,this.#J=_,this.#_=Boolean(Q),this.replaceChildren(Z)}#K(){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.#_)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()||"Color")}#U(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","text"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#Y(){if(!this.#J)return;let J=this.#U(),Q=new Set(J);for(let Z of this.#O)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#J.setAttribute("text","true"),this.#O=Q}#k(){if(!this.#J)return;this.#G??=this.#q.bind(this,"input"),this.#$??=this.#q.bind(this,"change"),this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#$)}#N(){if(!this.#J)return;if(this.#G)this.#J.removeEventListener("input",this.#G);if(this.#$)this.#J.removeEventListener("change",this.#$)}#q(J,Q){Q.stopImmediatePropagation();let Z=this.#J?.getAttribute("value")??"";this.setAttribute("value",Z);let $=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:Z;this.dispatchEvent(new CustomEvent(J,{detail:$,bubbles:!0,cancelable:!0,composed:!0}))}#P(J){if(J.target instanceof Element&&J.target.closest("fig-input-color"))return;this.focus()}get value(){return this.#J?.getAttribute("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?.querySelector("input:not([tabindex='-1'])")?.focus(J)}}customElements.define("propskit-color",E);class A extends HTMLElement{#Q=null;#Z=null;#J=null;#_=!1;#j=null;#O=new Set;#G=null;#$=null;#B=this.#P.bind(this);static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Q)this.#X();if(this.#K(),this.#Y(),this.#k(),this.removeEventListener("click",this.#B),this.addEventListener("click",this.#B),!this.#j)this.#j=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.#K();if(Z)this.#Y()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#N(),this.removeEventListener("click",this.#B)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction"||J==="aria-label")this.#K()}#X(){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.#_=Boolean(Q),this.replaceChildren(Z)}#K(){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.#_)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")}#U(){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-"))}#Y(){if(!this.#J)return;let J=this.#U(),Q=new Set(J);for(let Z of this.#O)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#O=Q}#k(){if(!this.#J)return;this.#G??=this.#q.bind(this,"input"),this.#$??=this.#q.bind(this,"change"),this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#$)}#N(){if(!this.#J)return;if(this.#G)this.#J.removeEventListener("input",this.#G);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}))}#P(J){if(J.target instanceof Element&&J.target.closest("fig-dropdown"))return;let Q=this.#J?.querySelector("select");if(Q?.focus(),typeof Q?.showPicker==="function")try{Q.showPicker()}catch{}}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",A);class b extends HTMLElement{#Q=null;#Z=null;#J=null;#_=!1;#j=null;#O=new Set;#G=null;#$=null;#B=this.#P.bind(this);static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Q)this.#X();if(this.#K(),this.#Y(),this.#k(),this.removeEventListener("click",this.#B),this.addEventListener("click",this.#B),!this.#j)this.#j=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.#K();if(Z)this.#Y()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#N(),this.removeEventListener("click",this.#B)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction"||J==="aria-label")this.#K()}#X(){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.#_=Boolean(Q),this.replaceChildren(Z)}#K(){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.#_)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")}#U(){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-"))}#Y(){if(!this.#J)return;let J=this.#U(),Q=new Set(J);for(let Z of this.#O)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#O=Q}#k(){if(!this.#J)return;this.#G??=this.#q.bind(this,"input"),this.#$??=this.#q.bind(this,"change"),this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#$)}#N(){if(!this.#J)return;if(this.#G)this.#J.removeEventListener("input",this.#G);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}))}#P(J){if(J.target instanceof Element&&J.target.closest("fig-input-text"))return;this.focus()}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",b);class y extends HTMLElement{#Q=null;#Z=null;#J=null;#_=!1;#j=null;#O=new Set;#G=null;#$=null;#B=this.#P.bind(this);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Q)this.#X();if(this.#K(),this.#Y(),this.#k(),this.removeEventListener("click",this.#B),this.addEventListener("click",this.#B),!this.#j)this.#j=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.#K();if(Z)this.#Y()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#N(),this.removeEventListener("click",this.#B)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction")this.#K()}#X(){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.#_=Boolean(Q),this.replaceChildren(Z);for(let j of J)if(j!==Q)_.appendChild(j)}#K(){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.#_)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")}#U(){let J=new Set(["label","direction","oninput","onchange","class","style","id"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#Y(){if(!this.#J)return;let J=this.#U(),Q=new Set(J);for(let Z of this.#O)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#O=Q}#k(){if(!this.#J)return;this.#G??=this.#q.bind(this,"input"),this.#$??=this.#q.bind(this,"change"),this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#$)}#N(){if(!this.#J)return;if(this.#G)this.#J.removeEventListener("input",this.#G);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}))}#P(J){if(J.target instanceof Element&&J.target.closest("fig-input-number"))return;this.focus()}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",y);class x extends HTMLElement{#Q=null;#Z=null;#J=null;#_=!1;#j=null;#O=new Set;#G=0;#$=0;#B=null;#X=null;#K=0;#U=null;#Y=!1;#k=0;#N=null;#q=0;#P=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.#j)this.#j=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.#j.observe(this,{attributes:!0})}disconnectedCallback(){if(this.#j?.disconnect(),this.#G)cancelAnimationFrame(this.#G),this.#G=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.#X?.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.#_=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.#X=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.#_)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.#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.#G)cancelAnimationFrame(this.#G);this.#G=requestAnimationFrame(()=>{this.#G=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.#B)this.#c(J);J?.removeAttribute("tabindex"),Q?.setAttribute("tabindex","-1")}#c(J){if(this.#y(),this.#B=J,!this.#B)return;this.#B.addEventListener("dblclick",this.#H,{capture:!0})}#y(){if(!this.#B)return;this.#B.removeEventListener("dblclick",this.#H,{capture:!0}),this.#B=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.#B;if(!Q)return;this.#m(),this.#h(),this.#B=Q,this.#Y=!0,this.#P=J.pointerId,this.#k=this.#JJ();let Z=Q.getBoundingClientRect(),$=this.getBoundingClientRect();this.#N={left:Z.left,right:Z.right,width:Z.width},this.#q=$.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.#P)return;if(J.buttons===0){this.#d(J);return}this.#BJ(J.clientX)}#d(J){if(J?.pointerId!==void 0&&this.#P!==null&&J.pointerId!==this.#P)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.#P=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.#X?.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.#K)clearTimeout(this.#K),this.#K=0;this.#U=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.#N;if(!Q||!this.#k){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.#k,Math.min(this.#k,Z*0.5)),_=Math.abs($),j=this.#q?(this.#q+_)/this.#q: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.#k=0,this.#N=null,this.#q=0,this.#P=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.#B;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.#B?.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",x);class h extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping"];#Q=50;#Z=50;#J=75;#_=75;#j=0;#O=!1;#G=0;#$=null;#B=null;#X=null;#K=null;#U=null;#Y=null;#k=null;#N=null;#q=null;#P=!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.#_)}%`}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.#j/100*J;return this.#j}#p(){if(this.#O)return`Radius ${Math.round(this.#j)}%`;return`Radius ${Math.round(this.#j)}`}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.#P&&!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.#B)this.#B.setAttribute("drag-snapping",Z||"false")}if(J==="name"){if(this.#Y)this.#Y.setAttribute("text",this.#x);if(this.#k)this.#k.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.#j=parseFloat(Z);else this.#O=!1,this.#j=parseFloat(Z);if(!Number.isFinite(this.#j))this.#j=0}if(typeof Q.angle==="number")this.#G=Q.angle;if(typeof Q.x2==="number")this.#J=Q.x2;if(typeof Q.y2==="number")this.#_=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.#O?`${this.#j}%`:this.#j;if(this.#S)J.angle=this.#G;if(this.#D)J.x2=this.#J,J.y2=this.#_;return J}set value(J){if(typeof J==="object")this.setAttribute("value",JSON.stringify(J));else if(typeof J==="string")this.setAttribute("value",J)}#m(){this.innerHTML="",this.#$=null,this.#B=null,this.#X=null,this.#K=null,this.#U=null,this.#Y=null,this.#k=null,this.#N=null,this.#q=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.#X),this.#e(this.#B),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.#P||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.#X)this.#i(this.#X,()=>this.#q,()=>`Angle ${Math.round(this.#G)}°`,()=>this.#JJ());if(this.#B)this.#i(this.#B,()=>this.#k,()=>this.#E,()=>this.#JJ());if(this.#K){let J=this.#K.querySelector(".fig-canvas-control-radius-hit");this.#a(J||this.#K)}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.#N;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.#N;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.#N;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.#K=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.#N=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.#U=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.#_;this.#P=!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.#_=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.#P=!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.#X=$,Q){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",`${Math.round(this.#G)}°`),_.appendChild($),this.appendChild(_),this.#q=_}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)$.setAttribute("disabled","");if(this.#B=$,Q){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#E),_.appendChild($),this.appendChild(_),this.#k=_}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.#X||!this.#S)return;let J=this.#X.querySelector(".fig-handle-hit-area");if(!J)return;J.style.cursor=this.#ZJ(this.#G)}#qJ(){return Math.atan2(this.#_-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.#B,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.#K){let Z=this.#Q/100*Q.width,$=this.#Z/100*Q.height,_=this.#o(Q.width),j=this.#K,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.#U&&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.#_/100*Q.height;else{let B=this.#o(Q.width),K=this.#G*Math.PI/180;_=Z+B*Math.cos(K),j=$+B*Math.sin(K)}let X=this.#U;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.#X&&this.#S){let Z=this.#Q/100*Q.width,$=this.#Z/100*Q.height,_=this.#o(Q.width),j=this.#G*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.#X,B,K,Q)}if(this.#B&&this.#D)this.#jJ(this.#B,this.#J,this.#_,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.#P=!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.#P=!1})}),this.#X)this.#X.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.#X.offsetWidth/2,B=this.#X.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.#G=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.#j=Math.max(0,N/Z.width*100);else this.#j=Math.max(0,N);if(this.#q)this.#q.setAttribute("text",`Angle ${Math.round(this.#G)}°`),this.#q.setAttribute("show","true"),this.#q.showPopup?.();this.#A(),this.#R()}),this.#X.addEventListener("change",(J)=>{if(J.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#q)this.#q.removeAttribute("show");this.#A(),this.#w(),this.#l(),requestAnimationFrame(()=>{this.#L=!1})}),this.#X.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.#X.setAttribute("selected",""),this.#q)this.#q.setAttribute("show","true"),this.#q.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.#G=Y,this.#q)this.#q.setAttribute("text",`Angle ${Math.round(Y)}°`);this.#A(),this.#R()},_=()=>{if(this.#L=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#X.removeAttribute("selected"),this.#q)this.#q.removeAttribute("show");this.#w(),this.#l(),window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",_)};window.addEventListener("pointermove",$),window.addEventListener("pointerup",_)});if(this.#B)this.#B.addEventListener("input",(J)=>{J.stopPropagation(),this.#T=!0;let Q=J.detail?.px??this.#J/100,Z=J.detail?.py??this.#_/100;if(this.#J=Math.round(Math.max(0,Math.min(100,Q*100))),this.#_=Math.round(Math.max(0,Math.min(100,Z*100))),this.#k)this.#k.removeAttribute("show"),this.#k.hidePopup?.();this.#A(),this.#R()}),this.#B.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#k)this.#k.removeAttribute("show");this.#A(),this.#w(),this.#l(),requestAnimationFrame(()=>{this.#T=!1})}),this.#YJ(this.#$,!0),this.#YJ(this.#B,!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.#P=!0;let j=_.getBoundingClientRect(),X=Q?this.#J:this.#Q,G=Q?this.#_:this.#Z,B=Q?this.#Q:this.#J,K=Q?this.#Z:this.#_,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.#k;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 g=M+S*Math.cos(C),c=z+S*Math.sin(C),W=Math.max(0,Math.min(100,g/U.width*100)),H=Math.max(0,Math.min(100,c/U.height*100));if(Q)this.#Q=W,this.#Z=H;else this.#J=W,this.#_=H;this.#A(),this.#R()},f=()=>{if(this.#P=!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.#N)this.#N.setAttribute("show","true"),this.#N.showPopup?.(),this.#h(Z.clientX,Z.clientY);if(this.#q)this.#q.removeAttribute("show"),this.#q.hidePopup?.();let _=this.#X?.style.pointerEvents,j=this.#X?.querySelector(".fig-handle-hit-area"),X=j?.style.pointerEvents;if(this.#X)this.#X.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.#O?5:10;if(this.#O){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.#O)this.#j=Math.max(0,T/L.width*100);else this.#j=Math.max(0,T);if(this.#N)this.#N.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.#X)this.#X.style.pointerEvents=_??"";if(j)j.style.pointerEvents=X??"";if(document.body.style.cursor=G,this.#N)this.#N.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",h);class q extends HTMLElement{#Q=[q.#H()];#Z=0;#J=2;#_=240;#j=120;#O={min:-1,max:1};#G=null;#$=null;#B=null;#X=null;#K=0;#U=null;#Y=null;#k=null;#N=null;#q=[];#P=[];#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.#G=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">
|
|
1
|
+
function N(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class E extends HTMLElement{#Q=null;#Z=null;#J=null;#_=!1;#j=null;#N=new Set;#G=null;#$=null;#q=this.#k.bind(this);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Q)this.#X();if(this.#B(),this.#K(),this.#L(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),!this.#j)this.#j=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.#B();if(Z)this.#K()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#U(),this.removeEventListener("click",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction")this.#B()}#X(){let Q=Array.from(this.childNodes).filter((X)=>X.nodeType!==Node.TEXT_NODE||Boolean(X.textContent?.trim())).find((X)=>X.nodeType===Node.ELEMENT_NODE&&X.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-segmented-control"),j=document.createElement("fig-segment"),G=document.createElement("fig-segment");_.setAttribute("sizing","equal"),j.setAttribute("value","off"),j.textContent="Off",G.setAttribute("value","on"),G.textContent="On",_.append(j,G),Z.append($,_),this.#Q=Z,this.#Z=$,this.#J=_,this.#_=Boolean(Q),this.replaceChildren(Z)}#B(){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.#_)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")}#z(){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.#z(),Q=new Set(J);for(let Z of this.#N)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#J.setAttribute("value",N(this,"checked")?"on":"off"),this.#N=Q}#L(){if(!this.#J)return;this.#G??=this.#Y.bind(this,"input"),this.#$??=this.#Y.bind(this,"change"),this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#G)this.#J.removeEventListener("input",this.#G);if(this.#$)this.#J.removeEventListener("change",this.#$)}#Y(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}))}#k(J){if(J.target instanceof Element&&J.target.closest("fig-segmented-control"))return;let Q=this.#J?.value==="on"?"off":"on";this.#J?.querySelector(`fig-segment[value="${Q}"]`)?.click()}get checked(){return this.#J?this.#J.value==="on":N(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",E);class y extends HTMLElement{#Q=null;#Z=null;#J=null;#_=!1;#j=null;#N=new Set;#G=null;#$=null;#q=this.#k.bind(this);static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Q)this.#X();if(this.#B(),this.#K(),this.#L(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),!this.#j)this.#j=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.#B();if(Z)this.#K()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#U(),this.removeEventListener("click",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction"||J==="aria-label")this.#B()}#X(){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-color");for(let j of J)if(j!==Q)_.appendChild(j);Z.append($,_),this.#Q=Z,this.#Z=$,this.#J=_,this.#_=Boolean(Q),this.replaceChildren(Z)}#B(){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.#_)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()||"Color")}#z(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","text"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#K(){if(!this.#J)return;let J=this.#z(),Q=new Set(J);for(let Z of this.#N)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#J.setAttribute("text","true"),this.#N=Q}#L(){if(!this.#J)return;this.#G??=this.#Y.bind(this,"input"),this.#$??=this.#Y.bind(this,"change"),this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#G)this.#J.removeEventListener("input",this.#G);if(this.#$)this.#J.removeEventListener("change",this.#$)}#Y(J,Q){Q.stopImmediatePropagation();let Z=this.#J?.getAttribute("value")??"";this.setAttribute("value",Z);let $=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:Z;this.dispatchEvent(new CustomEvent(J,{detail:$,bubbles:!0,cancelable:!0,composed:!0}))}#k(J){if(J.target instanceof Element&&J.target.closest("fig-input-color"))return;this.focus()}get value(){return this.#J?.getAttribute("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?.querySelector("input:not([tabindex='-1'])")?.focus(J)}}customElements.define("propskit-color",y);class b extends HTMLElement{#Q=null;#Z=null;#J=null;#_=!1;#j=null;#N=new Set;#G=null;#$=null;#q=this.#k.bind(this);static get observedAttributes(){return["label","direction","aria-label","options","value"]}connectedCallback(){if(!this.#Q)this.#X();if(this.#B(),this.#K(),this.#L(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),!this.#j)this.#j=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;let _=$.attributeName;if(_==="label"||_==="direction"||_==="aria-label")Q=!0;else Z=!0}if(Q)this.#B();if(Z)this.#K()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#U(),this.removeEventListener("click",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction"||J==="aria-label"){this.#B();return}if(J==="options"||J==="value")this.#K()}#X(){let J=this.querySelector(":scope > label"),Q=document.createElement("fig-field"),Z=J||document.createElement("label"),$=document.createElement("fig-select");Q.append(Z,$),this.#Q=Q,this.#Z=Z,this.#J=$,this.#_=Boolean(J),this.replaceChildren(Q)}#B(){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.#_)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")}#z(){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.#z().sort((Z,$)=>{if(Z==="options")return-1;if($==="options")return 1;if(Z==="value")return 1;if($==="value")return-1;return 0}),Q=new Set(J);for(let Z of this.#N)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#N=Q}#L(){if(!this.#J)return;this.#G??=this.#Y.bind(this,"input"),this.#$??=this.#Y.bind(this,"change"),this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#G)this.#J.removeEventListener("input",this.#G);if(this.#$)this.#J.removeEventListener("change",this.#$)}#Y(J,Q){if(Q.target!==this.#J)return;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}))}#k(J){if(J.target instanceof Element&&J.target.closest("fig-select"))return;if(this.#J?.focus(),this.#J&&!N(this.#J,"disabled"))this.#J.open=!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",b);class x extends HTMLElement{#Q=null;#Z=null;#J=null;#_=!1;#j=null;#N=new Set;#G=null;#$=null;#q=this.#k.bind(this);static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Q)this.#X();if(this.#B(),this.#K(),this.#L(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),!this.#j)this.#j=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.#B();if(Z)this.#K()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#U(),this.removeEventListener("click",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction"||J==="aria-label")this.#B()}#X(){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.#_=Boolean(Q),this.replaceChildren(Z)}#B(){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.#_)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")}#z(){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.#z(),Q=new Set(J);for(let Z of this.#N)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#N=Q}#L(){if(!this.#J)return;this.#G??=this.#Y.bind(this,"input"),this.#$??=this.#Y.bind(this,"change"),this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#G)this.#J.removeEventListener("input",this.#G);if(this.#$)this.#J.removeEventListener("change",this.#$)}#Y(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}))}#k(J){if(J.target instanceof Element&&J.target.closest("fig-input-text"))return;this.focus()}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",x);class w extends HTMLElement{#Q=null;#Z=null;#J=null;#_=!1;#j=null;#N=new Set;#G=null;#$=null;#q=this.#k.bind(this);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Q)this.#X();if(this.#B(),this.#K(),this.#L(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),!this.#j)this.#j=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.#B();if(Z)this.#K()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#U(),this.removeEventListener("click",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction")this.#B()}#X(){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.#_=Boolean(Q),this.replaceChildren(Z);for(let j of J)if(j!==Q)_.appendChild(j)}#B(){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.#_)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")}#z(){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.#z(),Q=new Set(J);for(let Z of this.#N)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#N=Q}#L(){if(!this.#J)return;this.#G??=this.#Y.bind(this,"input"),this.#$??=this.#Y.bind(this,"change"),this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#G)this.#J.removeEventListener("input",this.#G);if(this.#$)this.#J.removeEventListener("change",this.#$)}#Y(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}))}#k(J){if(J.target instanceof Element&&J.target.closest("fig-input-number"))return;this.focus()}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",w);class h extends HTMLElement{#Q=null;#Z=null;#J=null;#_=!1;#j=null;#N=new Set;#G=0;#$=0;#q=null;#X=null;#B=0;#z=null;#K=!1;#L=0;#U=null;#Y=0;#k=null;#W=null;#T=null;#M=this.#u.bind(this);#O=this.#g.bind(this);#S=this.#x.bind(this);#f=this.#t.bind(this);#H=this.#e.bind(this);#C=this.#r.bind(this);#h=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.#D();if(this.#A(),this.#F(),this.#jJ(),this.#E(),this.removeEventListener("pointerdown",this.#M,{capture:!0}),this.addEventListener("pointerdown",this.#M,{capture:!0,passive:!0}),this.removeEventListener("contextmenu",this.#H),this.addEventListener("contextmenu",this.#H),!this.#j)this.#j=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J)if($.type==="attributes"){if($.attributeName&&this.#h.has($.attributeName))continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#A();if(Z)this.#F(),this.#E()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){if(this.#j?.disconnect(),this.#G)cancelAnimationFrame(this.#G),this.#G=0;if(this.#$)cancelAnimationFrame(this.#$),this.#$=0;this.#s(),this.#v(),this.#I(),this.#b(),this.#GJ(),this.removeEventListener("pointerdown",this.#M,{capture:!0}),this.removeEventListener("contextmenu",this.#H),this.#X?.removeEventListener("change",this.#C)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction")this.#A()}#D(){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.#w()){let G=this.getAttribute(j);_.setAttribute(j,G??"")}Z.append($,_),this.#Q=Z,this.#Z=$,this.#J=_,this.#_=Boolean(Q),this.replaceChildren(Z),this.#R();for(let j of J){if(j===Q)continue;this.#J.appendChild(j)}}#R(){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.#C),this.#X=J,this.appendChild(J)}#A(){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.#_)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")}#F(){if(!this.#J)return;let J=this.#w(),Q=new Set(J.filter(($)=>$!=="text"));for(let $ of this.#N)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.#N=Q,this.#y()}#w(){let J=new Set(["label","direction","oninput","onchange","steppers"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!this.#h.has(Q))}#y(){if(this.#G)cancelAnimationFrame(this.#G);this.#G=requestAnimationFrame(()=>{this.#G=0,this.#ZJ(),this.#P()})}#E(){if(this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{this.#$=0,this.#P()})}#P(){let J=this.#J?.querySelector('input[type="range"]'),Q=this.#J?.querySelector("fig-input-number input");if(J!==this.#q)this.#c(J);J?.removeAttribute("tabindex"),Q?.setAttribute("tabindex","-1")}#c(J){if(this.#b(),this.#q=J,!this.#q)return;this.#q.addEventListener("dblclick",this.#f,{capture:!0})}#b(){if(!this.#q)return;this.#q.removeEventListener("dblclick",this.#f,{capture:!0}),this.#q=null}#t(J){J.preventDefault(),J.stopImmediatePropagation(),this.#QJ()}#u(J){if(J.button!==0||N(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.#q;if(!Q)return;this.#v(),this.#I(),this.#q=Q,this.#K=!0,this.#k=J.pointerId,this.#L=this.#d();let Z=Q.getBoundingClientRect(),$=this.getBoundingClientRect();this.#U={left:Z.left,right:Z.right,width:Z.width},this.#Y=$.width,window.addEventListener("pointermove",this.#O,{passive:!0}),window.addEventListener("pointerup",this.#S,{once:!0}),window.addEventListener("pointercancel",this.#S,{once:!0}),window.addEventListener("blur",this.#S,{once:!0})}#g(J){if(!this.#K)return;if(J.pointerId!==this.#k)return;if(J.buttons===0){this.#x(J);return}this.#JJ(J.clientX)}#x(J){if(J?.pointerId!==void 0&&this.#k!==null&&J.pointerId!==this.#k)return;this.#v(),this.#I()}#v(){window.removeEventListener("pointermove",this.#O),window.removeEventListener("pointerup",this.#S),window.removeEventListener("pointercancel",this.#S),window.removeEventListener("blur",this.#S),this.#K=!1,this.#k=null}#e(J){if(N(this,"disabled"))return;J.preventDefault(),J.stopPropagation(),J.stopImmediatePropagation(),this.#s(),this.#$J(J.clientX,J.clientY)}#$J(J,Q){let Z=!1,$=0,_=()=>{if(Z)return;Z=!0,window.clearTimeout($),window.removeEventListener("pointerup",_,!0),window.removeEventListener("pointercancel",_,!0),requestAnimationFrame(()=>{this.#X?.showAt?.(J,Q)})};window.addEventListener("pointerup",_,{once:!0,capture:!0}),window.addEventListener("pointercancel",_,{once:!0,capture:!0}),$=window.setTimeout(_,180)}#r(J){if(J.stopPropagation(),J.detail?.value!=="reset-default")return;this.#QJ()}#s(){if(this.#B)clearTimeout(this.#B),this.#B=0;this.#z=null}#d(){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}#JJ(J){let Q=this.#U;if(!Q||!this.#L){this.#I();return}let Z=J<Q.left?J-Q.left:J>Q.right?J-Q.right:0;if(!Z){this.#i();return}let $=Math.max(-this.#L,Math.min(this.#L,Z*0.5)),_=Math.abs($),j=this.#Y?(this.#Y+_)/this.#Y: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")}#I(){this.#i(),this.#L=0,this.#U=null,this.#Y=0,this.#k=null}#i(){this.removeAttribute("data-elastic-dragging"),this.style.removeProperty("--propskit-slider-elastic-size"),this.style.removeProperty("--propskit-slider-elastic-scale")}#_J(J){let Q=this.#q;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),G=Q.step==="any"?0:Number(Q.step||1),X=_+(j-_)*$;if(!G)return String(X);let q=Math.round((X-_)/G)*G+_,B=Math.max(0,`${G}`.split(".")[1]?.length||0);return String(Number(q.toFixed(B)))}#p(){return this.getAttribute("default")??this.#J?.getAttribute("default")??this.getAttribute("value")??this.#J?.getAttribute("value")??this.#q?.min??"0"}#QJ(){this.#s(),this.#a(this.#p(),"input"),this.#a(this.#p(),"change")}#a(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}))}#ZJ(){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??"")}#jJ(){if(!this.#J)return;if(!this.#W)this.#W=this.#XJ.bind(this,"input");if(!this.#T)this.#T=this.#XJ.bind(this,"change");this.#J.addEventListener("input",this.#W),this.#J.addEventListener("change",this.#T)}#GJ(){if(!this.#J)return;if(this.#W)this.#J.removeEventListener("input",this.#W);if(this.#T)this.#J.removeEventListener("change",this.#T)}#XJ(J,Q){if(Q.stopImmediatePropagation(),J==="change")this.#I();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.#QJ()}}customElements.define("propskit-slider",h);class g extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping"];#Q=50;#Z=50;#J=75;#_=75;#j=0;#N=!1;#G=0;#$=null;#q=null;#X=null;#B=null;#z=null;#K=null;#L=null;#U=null;#Y=null;#k=!1;#W=!1;#T=!1;#M=!1;#O=null;#S="";#f="";#H=null;get#C(){return this.getAttribute("type")||"point"}get#h(){return this.#C==="point-radius"||this.#C==="point-radius-angle"}get#D(){return this.#C==="point-radius-angle"}get#R(){return this.#C==="point-point"}get#A(){return this.#C==="point-radius-angle"||this.#C==="point-point"}get#F(){let J=this.getAttribute("tooltips");return J===null||J!=="false"}get#w(){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"}#y(J){let Q=this.#w;if(Q==="true")return!0;if(Q==="modifier")return!!J;return!1}get#E(){let J=this.getAttribute("name");if(J)return J.split(",")[0].trim();return`${Math.round(this.#Q)}%, ${Math.round(this.#Z)}%`}get#P(){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.#_)}%`}get#c(){return this.getAttribute("drag-surface")||"parent"}get#b(){let J=this.#c;if(J==="parent")return this.parentElement;return this.closest(J)}get#t(){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}#u(J){if(this.#N)return this.#j/100*J;return this.#j}#g(){if(this.#N)return`Radius ${Math.round(this.#j)}%`;return`Radius ${Math.round(this.#j)}`}connectedCallback(){this.#x(),this.#v()}disconnectedCallback(){this.#UJ(),this.#r(),document.body.classList.remove("fig-lab-move-active")}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"&&!this.#k&&!this.#W&&!this.#T&&!this.#M)if(this.#x(),this.#$)this.#m();else this.#v();if(J==="type")this.#x(),this.#v();if(J==="color"&&this.#$)if(Z)this.#$.setAttribute("color",Z);else this.#$.removeAttribute("color");if(J==="disabled")this.#v();if(J==="tooltips")this.#v();if(J==="snapping"&&this.#$){if(this.#$.setAttribute("drag-snapping",Z||"false"),this.#q)this.#q.setAttribute("drag-snapping",Z||"false")}if(J==="name"){if(this.#K)this.#K.setAttribute("text",this.#E);if(this.#L)this.#L.setAttribute("text",this.#P)}}#x(){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.#N=!0,this.#j=parseFloat(Z);else this.#N=!1,this.#j=parseFloat(Z);if(!Number.isFinite(this.#j))this.#j=0}if(typeof Q.angle==="number")this.#G=Q.angle;if(typeof Q.x2==="number")this.#J=Q.x2;if(typeof Q.y2==="number")this.#_=Q.y2}catch{}}get value(){let J={x:this.#Q,y:this.#Z};if(this.#C==="color"){let Q=this.getAttribute("color")||this.#$?.getAttribute("color");if(Q)J.color=Q}if(this.#h)J.radius=this.#N?`${this.#j}%`:this.#j;if(this.#D)J.angle=this.#G;if(this.#R)J.x2=this.#J,J.y2=this.#_;return J}set value(J){if(typeof J==="object")this.setAttribute("value",JSON.stringify(J));else if(typeof J==="string")this.setAttribute("value",J)}#v(){this.innerHTML="",this.#$=null,this.#q=null,this.#X=null,this.#B=null,this.#z=null,this.#K=null,this.#L=null,this.#U=null,this.#Y=null;let J=N(this,"disabled"),Q=this.#C,Z=this.#F,$=this.#t,_=document.createElement("fig-handle");if(_.setAttribute("drag","true"),_.setAttribute("drag-surface",$),_.setAttribute("drag-axes","x,y"),_.setAttribute("drag-snapping",this.#w),_.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.#R)_.setAttribute("hit-area","12 circle"),_.setAttribute("hit-area-mode","delegate");if(this.#$=_,this.#h)this.#_J();if(this.#A)this.#p();if(Z){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#E),j.appendChild(_),this.appendChild(j),this.#K=j}else this.appendChild(_);if(this.#D)this.#a(J,Z,$);if(this.#R)this.#ZJ(J,Z,$);this.#e(this.#$),this.#e(this.#X),this.#e(this.#q),this.#NJ(),this.#JJ(),requestAnimationFrame(()=>this.#m())}#e(J){if(!J)return;J.addEventListener("pointerdown",(Q)=>this.#$J(Q),{capture:!0})}#$J(J){if(N(this,"disabled"))return;if(J?.button!==void 0&&J.button!==0)return;if(J?.isPrimary===!1)return;if(this.#O===null)this.#S=document.body.style.getPropertyValue("cursor"),this.#f=document.body.style.getPropertyPriority("cursor");if(this.#O=J?.pointerId??-1,document.body.classList.add("fig-lab-move-active"),document.body.style.setProperty("cursor","var(--fig-lab-cursor-move)","important"),!this.#H)this.#H=(Q)=>{if(Q?.pointerId!==void 0&&this.#O!==null&&Q.pointerId!==this.#O)return;if(Q?.type==="blur")this.#r();else requestAnimationFrame(()=>this.#r())};window.addEventListener("pointerup",this.#H),window.addEventListener("pointercancel",this.#H),window.addEventListener("blur",this.#H)}#r(){if(this.#O===null)return;if(document.body.classList.remove("fig-lab-move-active"),this.#S)document.body.style.setProperty("cursor",this.#S,this.#f);else document.body.style.removeProperty("cursor");if(this.#O=null,this.#S="",this.#f="",this.#H)window.removeEventListener("pointerup",this.#H),window.removeEventListener("pointercancel",this.#H),window.removeEventListener("blur",this.#H)}#s(J,Q,Z,$){if(!J)return;let _=()=>!!$?.(),j=()=>{let q=Q();if(!q)return;q.removeAttribute("show"),q.hidePopup?.()},G=()=>{if(_()){j();return}let q=Q();if(!q)return;if(Z)q.setAttribute("text",Z());q.setAttribute("show","true"),q.showPopup?.()},X=()=>{j()};J.addEventListener("pointerenter",G),J.addEventListener("pointerleave",X)}#d(){return this.#k||this.#W||this.#T||this.#M}#JJ(){if(this.#$)this.#s(this.#$,()=>this.#K,()=>this.#E,()=>this.#d()||!!this.#$?.querySelector("fig-color-tip"));if(this.#X)this.#s(this.#X,()=>this.#Y,()=>`Angle ${Math.round(this.#G)}°`,()=>this.#d());if(this.#q)this.#s(this.#q,()=>this.#L,()=>this.#P,()=>this.#d());if(this.#B){let J=this.#B.querySelector(".fig-canvas-control-radius-hit");this.#i(J||this.#B)}if(this.#C==="color"&&this.#$&&this.#K)new MutationObserver(()=>{if(this.#$?.querySelector("fig-color-tip"))this.#K?.removeAttribute("show"),this.#K?.hidePopup?.()}).observe(this.#$,{childList:!0,subtree:!0})}#I(J,Q){let Z=this.#U;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?.()}#i(J){if(!J)return;J.addEventListener("pointerenter",(Q)=>{let Z=this.#U;if(!Z)return;Z.setAttribute("text",this.#g()),Z.setAttribute("show","true"),Z.showPopup?.(),this.#I(Q.clientX,Q.clientY)}),J.addEventListener("pointermove",(Q)=>{if(this.#T)return;this.#I(Q.clientX,Q.clientY)}),J.addEventListener("pointerleave",()=>{if(this.#T)return;let Q=this.#U;if(!Q)return;Q.removeAttribute("show")})}#_J(){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.#B=Q,this.#F){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#g()),j.appendChild(Q),this.appendChild(j),this.#U=j}else this.appendChild(Q);this.#LJ(Z)}#p(){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.#R){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.#QJ(_)}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.#z=Q,this.appendChild(Q)}#QJ(J){J.addEventListener("pointerdown",(Q)=>{if(N(this,"disabled"))return;Q.preventDefault(),Q.stopPropagation();let Z=this.#b;if(!Z)return;let $=Z.getBoundingClientRect(),_=Q.clientX,j=Q.clientY,G=this.#Q,X=this.#Z,q=this.#J,B=this.#_;this.#k=!0,this.#W=!0,document.body.classList.add("fig-lab-move-active"),J.style.pointerEvents="none";let Y=(k)=>{let M=Z.getBoundingClientRect(),D=M.width>0?(k.clientX-_)/M.width*100:0,z=M.height>0?(k.clientY-j)/M.height*100:0,L=-Math.min(G,q),T=100-Math.max(G,q),F=-Math.min(X,B),W=100-Math.max(X,B),H=Math.max(L,Math.min(T,D)),P=Math.max(F,Math.min(W,z));this.#Q=G+H,this.#Z=X+P,this.#J=q+H,this.#_=B+P,this.#m(),this.#V()},K=()=>{document.body.classList.remove("fig-lab-move-active"),J.style.pointerEvents="stroke",this.#l(),this.#n(),window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",K),requestAnimationFrame(()=>{this.#k=!1,this.#W=!1})};window.addEventListener("pointermove",Y),window.addEventListener("pointerup",K)})}#a(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.#X=$,Q){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",`${Math.round(this.#G)}°`),_.appendChild($),this.appendChild(_),this.#Y=_}else this.appendChild($)}#ZJ(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.#w),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),$.setAttribute("value",`${this.#J}% ${this.#_}%`),J)$.setAttribute("disabled","");if(this.#q=$,Q){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#P),_.appendChild($),this.appendChild(_),this.#L=_}else this.appendChild($)}#jJ(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`}#GJ(J){return`url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 32 32' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform='rotate(${Math.round(J-45)} 16 16)'%3E%3Cg filter='url(%23f)'%3E%3Cpath d='M12.5607 22.4393L12.0216 21.9002C17.1558 21.2216 21.2216 17.1558 21.9002 12.0216L22.4393 12.5607C23.0251 13.1464 23.9749 13.1464 24.5607 12.5607C25.1464 11.9749 25.1464 11.0251 24.5607 10.4393L21.5607 7.43934C20.9749 6.85355 20.0251 6.85355 19.4393 7.43934L16.4393 10.4393C15.8536 11.0251 15.8536 11.9749 16.4393 12.5607C17.0251 13.1464 17.9749 13.1464 18.5607 12.5607L18.8056 12.3157C18.1013 15.5527 15.5527 18.1013 12.3157 18.8056L12.5607 18.5607C13.1464 17.9749 13.1464 17.0251 12.5607 16.4393C11.9749 15.8536 11.0251 15.8536 10.4393 16.4393L7.43934 19.4393C6.85356 20.0251 6.85356 20.9749 7.43934 21.5607L10.4393 24.5607C11.0251 25.1464 11.9749 25.1464 12.5607 24.5607C13.1464 23.9749 13.1464 23.0251 12.5607 22.4393Z' fill='white'/%3E%3C/g%3E%3Cpath d='M23.8536 11.8536C23.6583 12.0488 23.3417 12.0488 23.1464 11.8536L21 9.70711V10.5C21 16.299 16.299 21 10.5 21H9.70711L11.8536 23.1464C12.0488 23.3417 12.0488 23.6583 11.8536 23.8536C11.6583 24.0488 11.3417 24.0488 11.1464 23.8536L8.14645 20.8536C7.95119 20.6583 7.95119 20.3417 8.14645 20.1464L11.1464 17.1464C11.3417 16.9512 11.6583 16.9512 11.8536 17.1464C12.0488 17.3417 12.0488 17.6583 11.8536 17.8536L9.70711 20H10.5C15.7467 20 20 15.7467 20 10.5V9.70711L17.8536 11.8536C17.6583 12.0488 17.3417 12.0488 17.1464 11.8536C16.9512 11.6583 16.9512 11.3417 17.1464 11.1464L20.1464 8.14645C20.3417 7.95119 20.6583 7.95119 20.8536 8.14645L23.8536 11.1464C24.0488 11.3417 24.0488 11.6583 23.8536 11.8536Z' fill='black'/%3E%3C/g%3E%3Cdefs%3E%3Cfilter id='f' x='4' y='5' width='24' height='24' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='a'/%3E%3CfeColorMatrix in='SourceAlpha' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='b'/%3E%3CfeOffset dy='1'/%3E%3CfeGaussianBlur stdDeviation='1.5'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0'/%3E%3CfeBlend in2='a' result='c'/%3E%3CfeBlend in='SourceGraphic' in2='c'/%3E%3C/filter%3E%3C/defs%3E%3C/svg%3E") 16 16, pointer`}#XJ(){if(!this.#X||!this.#D)return;let J=this.#X.querySelector(".fig-handle-hit-area");if(!J)return;J.style.cursor=this.#GJ(this.#G)}#YJ(){return Math.atan2(this.#_-this.#Z,this.#J-this.#Q)*180/Math.PI}#kJ(){if(!this.#R)return;let J=this.#YJ(),Q=(Z,$)=>{if(!Z)return;let _=Z.querySelector(".fig-handle-hit-area");if(_)_.style.cursor=this.#GJ($)};Q(this.#$,J+180),Q(this.#q,J)}#qJ(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`}#m(){let J=this.#b;if(!J||!this.#$)return;let Q=J.getBoundingClientRect();if(this.#qJ(this.#$,this.#Q,this.#Z,Q),this.#B){let Z=this.#Q/100*Q.width,$=this.#Z/100*Q.height,_=this.#u(Q.width),j=this.#B,G=Math.max(_*2,1);j.style.position="absolute",j.style.width=`${G}px`,j.style.height=`${G}px`,j.style.left=`${Z-_}px`,j.style.top=`${$-_}px`,j.setAttribute("viewBox",`0 0 ${G} ${G}`);let X=j.querySelectorAll("circle");for(let q of X)q.setAttribute("cx",String(_)),q.setAttribute("cy",String(_)),q.setAttribute("r",String(Math.max(_-1,0)))}if(this.#z&&this.#A){let Z=this.#Q/100*Q.width,$=this.#Z/100*Q.height,_,j;if(this.#R)_=this.#J/100*Q.width,j=this.#_/100*Q.height;else{let q=this.#u(Q.width),B=this.#G*Math.PI/180;_=Z+q*Math.cos(B),j=$+q*Math.sin(B)}let G=this.#z;G.style.width=`${Q.width}px`,G.style.height=`${Q.height}px`,G.style.left="0",G.style.top="0",G.setAttribute("viewBox",`0 0 ${Q.width} ${Q.height}`);let X=G.querySelectorAll(".fig-canvas-control-angle-line, .fig-canvas-control-angle-line-halo");for(let q of X)q.setAttribute("x1",String(Z)),q.setAttribute("y1",String($)),q.setAttribute("x2",String(_)),q.setAttribute("y2",String(j))}if(this.#X&&this.#D){let Z=this.#Q/100*Q.width,$=this.#Z/100*Q.height,_=this.#u(Q.width),j=this.#G*Math.PI/180,G=Z+_*Math.cos(j),X=$+_*Math.sin(j),q=Q.width>0?G/Q.width*100:0,B=Q.height>0?X/Q.height*100:0;this.#qJ(this.#X,q,B,Q)}if(this.#q&&this.#R)this.#qJ(this.#q,this.#J,this.#_,Q);this.#XJ(),this.#kJ()}#V(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#n(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}#l(){this.setAttribute("value",JSON.stringify(this.value))}#NJ(){if(!this.#$)return;if(this.#$.addEventListener("input",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#V();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.#K)this.#K.removeAttribute("show"),this.#K.hidePopup?.();this.#m(),this.#V()}),this.#$.addEventListener("change",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#n();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.#K)this.#K.removeAttribute("show");this.#m(),this.#l(),this.#n(),requestAnimationFrame(()=>{this.#k=!1})}),this.#X)this.#X.addEventListener("input",(J)=>{J.stopPropagation();let Q=this.#b;if(!Q)return;this.#M=!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,G=J.detail?.y??0,X=this.#X.offsetWidth/2,q=this.#X.offsetHeight/2,B=j+X-$,Y=G+q-_,K=Math.atan2(Y,B)*180/Math.PI;if(this.#y(J.detail?.shiftKey))K=Math.round(K/15)*15;this.#G=K;let k=Math.sqrt(B*B+Y*Y);if(this.#y(J.detail?.shiftKey)){let M=this.#N?5:10;if(this.#N){let D=k/Z.width*100;D=Math.round(D/M)*M,k=D/100*Z.width}else k=Math.round(k/M)*M}if(this.#N)this.#j=Math.max(0,k/Z.width*100);else this.#j=Math.max(0,k);if(this.#Y)this.#Y.setAttribute("text",`Angle ${Math.round(this.#G)}°`),this.#Y.setAttribute("show","true"),this.#Y.showPopup?.();this.#m(),this.#V()}),this.#X.addEventListener("change",(J)=>{if(J.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#Y)this.#Y.removeAttribute("show");this.#m(),this.#l(),this.#n(),requestAnimationFrame(()=>{this.#M=!1})}),this.#X.addEventListener("hitareadown",(J)=>{J.stopPropagation();let Q=J.detail?.originalEvent;if(!Q)return;Q.preventDefault();let Z=this.#b;if(!Z)return;if(this.#M=!0,this.classList.add("fig-canvas-control-ring-active"),this.#X.setAttribute("selected",""),this.#Y)this.#Y.setAttribute("show","true"),this.#Y.showPopup?.();let $=(j)=>{let G=Z.getBoundingClientRect(),X=this.#Q/100*G.width,q=this.#Z/100*G.height,B=j.clientX-G.left-X,Y=j.clientY-G.top-q,K=Math.atan2(Y,B)*180/Math.PI;if(this.#y(j.shiftKey))K=Math.round(K/15)*15;if(this.#G=K,this.#Y)this.#Y.setAttribute("text",`Angle ${Math.round(K)}°`);this.#m(),this.#V()},_=()=>{if(this.#M=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#X.removeAttribute("selected"),this.#Y)this.#Y.removeAttribute("show");this.#l(),this.#n(),window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",_)};window.addEventListener("pointermove",$),window.addEventListener("pointerup",_)});if(this.#q)this.#q.addEventListener("input",(J)=>{J.stopPropagation(),this.#W=!0;let Q=J.detail?.px??this.#J/100,Z=J.detail?.py??this.#_/100;if(this.#J=Math.round(Math.max(0,Math.min(100,Q*100))),this.#_=Math.round(Math.max(0,Math.min(100,Z*100))),this.#L)this.#L.removeAttribute("show"),this.#L.hidePopup?.();this.#m(),this.#V()}),this.#q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#L)this.#L.removeAttribute("show");this.#m(),this.#l(),this.#n(),requestAnimationFrame(()=>{this.#W=!1})}),this.#KJ(this.#$,!0),this.#KJ(this.#q,!1)}#KJ(J,Q){if(!J)return;J.addEventListener("hitareadown",(Z)=>{Z.stopPropagation();let $=Z.detail?.originalEvent;if(!$)return;$.preventDefault();let _=this.#b;if(!_)return;this.#k=!0;let j=_.getBoundingClientRect(),G=Q?this.#J:this.#Q,X=Q?this.#_:this.#Z,q=Q?this.#Q:this.#J,B=Q?this.#Z:this.#_,Y=G/100*j.width,K=X/100*j.height,k=q/100*j.width,M=B/100*j.height,D=Math.sqrt((k-Y)**2+(M-K)**2),z=Q?this.#K:this.#L;if(z)z.removeAttribute("show"),z.hidePopup?.();let L=(F)=>{let W=_.getBoundingClientRect(),H=G/100*W.width,P=X/100*W.height,O=F.clientX-W.left-H,R=F.clientY-W.top-P,S=Math.atan2(R,O);if(this.#y(F.shiftKey))S=Math.round(S*180/Math.PI/15)*15*Math.PI/180;let r=H+D*Math.cos(S),s=P+D*Math.sin(S),I=Math.max(0,Math.min(100,r/W.width*100)),V=Math.max(0,Math.min(100,s/W.height*100));if(Q)this.#Q=I,this.#Z=V;else this.#J=I,this.#_=V;this.#m(),this.#V()},T=()=>{if(this.#k=!1,z)z.removeAttribute("show");this.#l(),this.#n(),window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",T)};window.addEventListener("pointermove",L),window.addEventListener("pointerup",T)})}#LJ(J){if(!J)return;J.addEventListener("pointermove",(Z)=>{if(this.#T)return;let $=this.#b;if(!$)return;let _=$.getBoundingClientRect(),j=this.#Q/100*_.width,G=this.#Z/100*_.height,X=Math.atan2(Z.clientY-_.top-G,Z.clientX-_.left-j)*180/Math.PI;J.style.cursor=this.#jJ(X)});let Q=(Z)=>{if(N(this,"disabled"))return;Z.preventDefault(),Z.stopPropagation(),this.#T=!0,this.classList.add("fig-canvas-control-ring-active");let $=this.#b;if(!$)return;if(this.#U)this.#U.setAttribute("show","true"),this.#U.showPopup?.(),this.#I(Z.clientX,Z.clientY);if(this.#Y)this.#Y.removeAttribute("show"),this.#Y.hidePopup?.();let _=this.#X?.style.pointerEvents,j=this.#X?.querySelector(".fig-handle-hit-area"),G=j?.style.pointerEvents;if(this.#X)this.#X.style.pointerEvents="none";if(j)j.style.pointerEvents="none";let X=document.body.style.cursor;J.style.pointerEvents="none";let q=$.getBoundingClientRect(),B=this.#Q/100*q.width,Y=this.#Z/100*q.height,K=Math.atan2(Z.clientY-q.top-Y,Z.clientX-q.left-B)*180/Math.PI,k=Math.round(K);document.body.style.cursor=this.#jJ(k);let M=(z)=>{let L=$.getBoundingClientRect(),T=this.#Q/100*L.width,F=this.#Z/100*L.height,W=z.clientX-L.left-T,H=z.clientY-L.top-F,P=Math.round(Math.atan2(H,W)*180/Math.PI);if(P!==k)k=P,document.body.style.cursor=this.#jJ(P);let O=Math.sqrt(W*W+H*H);if(this.#y(z.shiftKey)){let R=this.#N?5:10;if(this.#N){let S=O/L.width*100;S=Math.round(S/R)*R,O=S/100*L.width}else O=Math.round(O/R)*R}if(this.#N)this.#j=Math.max(0,O/L.width*100);else this.#j=Math.max(0,O);if(this.#U)this.#U.setAttribute("text",this.#g()),this.#I(z.clientX,z.clientY);this.#m(),this.#V()},D=()=>{if(this.#T=!1,this.classList.remove("fig-canvas-control-ring-active"),J.style.pointerEvents="",this.#X)this.#X.style.pointerEvents=_??"";if(j)j.style.pointerEvents=G??"";if(document.body.style.cursor=X,this.#U)this.#U.removeAttribute("show");this.#l(),this.#n(),window.removeEventListener("pointermove",M),window.removeEventListener("pointerup",D)};window.addEventListener("pointermove",M),window.addEventListener("pointerup",D)};J.addEventListener("pointerdown",Q),this._radiusDragCleanup=()=>J.removeEventListener("pointerdown",Q)}#UJ(){if(this._radiusDragCleanup)this._radiusDragCleanup(),this._radiusDragCleanup=null}}customElements.define("fig-canvas-control",g);class U extends HTMLElement{#Q=[U.#f()];#Z=0;#J=2;#_=240;#j=120;#N={min:-1,max:1};#G=null;#$=null;#q=null;#X=null;#B=0;#z=null;#K=null;#L=null;#U=null;#Y=[];#k=[];#W=[];#T=[];#M=new Set;#O=null;#S=null;static TYPES=[{name:"Wave",value:"sine"},{name:"Square",value:"square"},{name:"Sawtooth",value:"sawtooth"},{name:"Triangle",value:"triangle"}];static#f(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.#H("precision",2),this.#A(this.getAttribute("value")),this.#R(),this.#g(),this.#I()}disconnectedCallback(){if(this.#G=null,this.#GJ(),this.#O)this.#O.disconnect(),this.#O=null}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"){if(this.#A(Z),this.isConnected)this.#g();return}if(J==="precision"){if(this.#J=this.#H("precision",2),this.isConnected)this.#BJ();return}if(J==="aspect-ratio"){if(this.#R(),this.#$)this.#ZJ();return}if(J==="edit"||J==="disabled"){if(this.isConnected)this.#g()}}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.#w(J))}}get preset(){let J=this.#y;return U.TYPES.find((Q)=>Q.value===J.type)?.name}#H(J,Q){let Z=Number.parseInt(this.getAttribute(J)||"",10);return Number.isFinite(Z)?Math.max(0,Math.min(100,Z)):Q}#C(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}#h(){return this.getAttribute("edit")!=="false"}#D(){return this.#C("disabled",!1)}#R(){let J=this.getAttribute("aspect-ratio")||"2 / 1";this.style.setProperty("--aspect-ratio",J)}#A(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.#F($)),!this.#Q.length)this.#Q=[U.#f()];return this.#Z=Math.min(this.#Z,this.#Q.length-1),!0}#F(J={}){return{type:this.#E(J.type),frequency:this.#P(J.frequency,1,0.1,16),amplitude:this.#P(J.amplitude,1,-4,4),phase:this.#P(J.phase,0,-360,360),offset:this.#P(J.offset,0,-4,4)}}#w(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#y(){if(!this.#Q[this.#Z])this.#Z=0;return this.#Q[this.#Z]||U.#f()}#E(J){let Q=String(J||"").toLowerCase();return U.TYPES.some((Z)=>Z.value===Q)?Q:"sine"}#P(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#b(J){return String(J).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}static#t(J){return U.TYPES.find((Q)=>Q.value===J)?.name||"Wave"}static waveIcon(J,Q=24){let _=Q-10,j="";for(let G=0;G<=32;G++){let X=G/32,q=U.#u(J,X),B=5+X*_,Y=5+(1-(q+1)/2)*_;j+=`${G===0?"M":"L"}${B.toFixed(1)},${Y.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#u(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)}}#g(){this.#GJ(),this.innerHTML=this.#x(),this.#s(),this.#i(),this.#ZJ(),this.#m(),this.#jJ()}#x(){let J=this.#D()?" disabled":"";return`<div class="propskit-oscillator-svg-container">
|
|
2
2
|
<svg viewBox="0 0 ${this.#_} ${this.#j}" class="propskit-oscillator-svg">
|
|
3
3
|
<rect class="propskit-oscillator-bounds" x="0" y="0" width="${this.#_}" height="${this.#j}"></rect>
|
|
4
4
|
<line class="propskit-oscillator-baseline"></line>
|
|
@@ -8,9 +8,9 @@ function R(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class I ex
|
|
|
8
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.#
|
|
11
|
+
${this.#h()?this.#v(J):""}`}#v(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=
|
|
13
|
+
</div>`}#e(J,Q,Z){let $=Z||this.#Q.length<=1?" disabled":"",_=Q===this.#Z?" data-active":"",j=U.#t(J.type);return`<fig-group class="propskit-oscillator-wave" collapsible borderless compact="true"${this.#M.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">
|
|
@@ -19,20 +19,20 @@ function R(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class I ex
|
|
|
19
19
|
<fig-tooltip text="Add form">
|
|
20
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
|
|
22
|
+
${this.#$J("propskit-oscillator-add-type","sine",Z,Q)}
|
|
23
23
|
</fig-button>
|
|
24
24
|
</fig-tooltip>
|
|
25
25
|
</fig-header>
|
|
26
26
|
<div class="propskit-oscillator-fields" data-wave-index="${Q}"${_}>
|
|
27
|
-
${this.#
|
|
28
|
-
${this.#
|
|
29
|
-
${this.#
|
|
30
|
-
${this.#
|
|
27
|
+
${this.#r(Q,"frequency","Frequency",0.1,16,0.1,"")}
|
|
28
|
+
${this.#r(Q,"amplitude","Amplitude",-4,4,0.1,"")}
|
|
29
|
+
${this.#r(Q,"phase","Phase",-360,360,1,"°")}
|
|
30
|
+
${this.#r(Q,"offset","Offset",-4,4,0.1,"")}
|
|
31
31
|
</div>
|
|
32
|
-
</fig-group>`}
|
|
33
|
-
${
|
|
34
|
-
<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.#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.#B=this.querySelector(".propskit-oscillator-path"),this.#X=this.querySelector(".propskit-oscillator-playhead"),this.#U=this.querySelector(".propskit-oscillator-baseline"),this.#Y=this.querySelector(".propskit-oscillator-bounds"),this.#k=this.querySelector('[data-handle="amplitude"]'),this.#N=this.querySelector('[data-handle="frequency"]'),this.#P=Array.from(this.querySelectorAll(".propskit-oscillator-wave-type")),this.#q=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.#_||Z!==this.#j;return this.#_=Q,this.#j=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.#j-(J-Q)/(Z-Q)*this.#j}#t(J){let{min:Q,max:Z}=this.#O;return Q+(1-J/this.#j)*(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.#B)return;if(this.#a(),this.#O=this.#KJ(),this.#Y)this.#Y.setAttribute("width",this.#_),this.#Y.setAttribute("height",this.#j);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.#_,B=this.#v(this.#r(X));$+=`${j===0?"M":"L"}${G.toFixed(1)},${B.toFixed(1)}`}this.#B.setAttribute("d",$);let _=this.#v(0);this.#U?.setAttribute("x1","0"),this.#U?.setAttribute("y1",_),this.#U?.setAttribute("x2",this.#_),this.#U?.setAttribute("y2",_),this.#qJ()}#QJ(){if(this.#K||!this.#X)return;let J=(Q)=>{if(!this.isConnected||!this.#X){this.#K=0;return}this.#_J(Q%1000/1000),this.#K=requestAnimationFrame(J)};this.#K=requestAnimationFrame(J)}#ZJ(){if(!this.#K)return;cancelAnimationFrame(this.#K),this.#K=0}#_J(J){if(!this.#X)return;let Q=J*this.#_,Z=this.#v(this.#r(J));this.#X.setAttribute("cx",Q.toFixed(1)),this.#X.setAttribute("cy",Z.toFixed(1))}#qJ(){let Q=this.#I,Z=this.#PJ(),$=Math.max(8,Math.min(this.#_-8,this.#_/Q.frequency)),_=this.#v(this.#r(Z/this.#_)),j=this.#v(this.#r($/this.#_));this.#jJ(this.#k,Z,_,8),this.#jJ(this.#N,$,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.#_-8,_*this.#_))}#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.#P)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.#q)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.#k,this.#N])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.#G=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.#G)return;let G=this.#kJ(X),B=this.#I;if(Q==="frequency"){let K=Math.max(1,Math.min(this.#_,G.x));B.frequency=this.#_/K}else if(Q==="offset"){let K=this.#E(G.x/this.#_,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.#_,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.#G=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.#P){let Q=this.#R(J);J.value=this.#Q[Q]?.type||"sine"}}#SJ(){for(let J of this.#q){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 w extends HTMLElement{#Q;#Z;#J=null;#_;#j;#O;#G;#$;#B;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.#_=this.#V.bind(this),this.#j=this.#b.bind(this),this.#O=this.#I.bind(this),this.#G=this.#x.bind(this),this.#$=this.#E.bind(this),this.#B=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.#K("dial",!0),this.showRotations=this.#U(),this.#X(),this.#L(),this.#M(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision))})}disconnectedCallback(){this.#F()}#X(){this.innerHTML=this.#Y()}#K(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}#U(){if(this.hasAttribute("rotations"))return this.#K("rotations",!1);if(this.hasAttribute("show-rotations"))return this.#K("show-rotations",!1);return!1}#Y(){let J=this.#q(),Q=this.min!==null?`min="${this.min}"`:"",Z=this.max!==null?`max="${this.max}"`:"";return`
|
|
32
|
+
</fig-group>`}#$J(J,Q,Z,$=null){let _=U.TYPES.map((G)=>{let X=G.value===Q?" selected":"";return`<option value="${G.value}"${X}>
|
|
33
|
+
${U.waveIcon(G.value,24)}
|
|
34
|
+
<label>${G.name}</label>
|
|
35
|
+
</option>`}).join(""),j=$===null?"":` data-wave-index="${U.#b(String($))}"`;return`<fig-dropdown class="${J}" value="${Q}" experimental="modern" type="dropdown" label="Add form"${j}${Z}>${_}</fig-dropdown>`}#r(J,Q,Z,$,_,j,G){let X=this.#D()?" disabled":"",q=G?` units="${U.#b(G)}"`:"",B=this.#Q[J]||U.#f();return`<propskit-slider class="propskit-oscillator-field" label="${Z}" direction="horizontal" name="${Q}" data-wave-index="${J}" value="${this.#c(B[Q])}" min="${$}" max="${_}" step="${j}" precision="${this.#J}" elastic="false"${q}${X}></propskit-slider>`}#s(){this.#$=this.querySelector(".propskit-oscillator-svg"),this.#q=this.querySelector(".propskit-oscillator-path"),this.#X=this.querySelector(".propskit-oscillator-playhead"),this.#z=this.querySelector(".propskit-oscillator-baseline"),this.#K=this.querySelector(".propskit-oscillator-bounds"),this.#L=this.querySelector('[data-handle="amplitude"]'),this.#U=this.querySelector('[data-handle="frequency"]'),this.#k=Array.from(this.querySelectorAll(".propskit-oscillator-wave-type")),this.#Y=Array.from(this.querySelectorAll("propskit-slider[name]")),this.#T=Array.from(this.querySelectorAll("fig-group.propskit-oscillator-wave")),this.#W=Array.from(this.querySelectorAll(".propskit-oscillator-fields"))}#d(J){let Q=new Set;for(let Z of this.#M)if(Z<J)Q.add(Z);else if(Z>J)Q.add(Z-1);this.#M=Q}#JJ(J){let Q=new Set;for(let Z of this.#M)Q.add(Z>=J?Z+1:Z);Q.add(J),this.#M=Q}#I(){if(this.#O||!window.ResizeObserver)return;this.#O=new ResizeObserver(()=>{if(this.#i())this.#ZJ()}),this.#O.observe(this)}#i(){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.#_||Z!==this.#j;return this.#_=Q,this.#j=Z,this.#$.setAttribute("viewBox",`0 0 ${Q} ${Z}`),$}#_J(){let J=1,Q=256;for(let Z=0;Z<=Q;Z++)J=Math.max(J,Math.abs(this.#a(Z/Q)));return{min:-J,max:J}}#p(J){let{min:Q,max:Z}=this.#N;return this.#j-(J-Q)/(Z-Q)*this.#j}#QJ(J){let{min:Q,max:Z}=this.#N;return Q+(1-J/this.#j)*(Z-Q)}#a(J){return this.#Q.reduce((Q,Z)=>{let $=J*Z.frequency,_=U.#u(Z.type,$,Z.phase);return Q+Z.offset+_*Z.amplitude},0)}#ZJ(){if(!this.#$||!this.#q)return;if(this.#i(),this.#N=this.#_J(),this.#K)this.#K.setAttribute("width",this.#_),this.#K.setAttribute("height",this.#j);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 G=j/Z,X=G*this.#_,q=this.#p(this.#a(G));$+=`${j===0?"M":"L"}${X.toFixed(1)},${q.toFixed(1)}`}this.#q.setAttribute("d",$);let _=this.#p(0);this.#z?.setAttribute("x1","0"),this.#z?.setAttribute("y1",_),this.#z?.setAttribute("x2",this.#_),this.#z?.setAttribute("y2",_),this.#YJ()}#jJ(){if(this.#B||!this.#X)return;let J=(Q)=>{if(!this.isConnected||!this.#X){this.#B=0;return}this.#XJ(Q%1000/1000),this.#B=requestAnimationFrame(J)};this.#B=requestAnimationFrame(J)}#GJ(){if(!this.#B)return;cancelAnimationFrame(this.#B),this.#B=0}#XJ(J){if(!this.#X)return;let Q=J*this.#_,Z=this.#p(this.#a(J));this.#X.setAttribute("cx",Q.toFixed(1)),this.#X.setAttribute("cy",Z.toFixed(1))}#YJ(){let Q=this.#y,Z=this.#kJ(),$=Math.max(8,Math.min(this.#_-8,this.#_/Q.frequency)),_=this.#p(this.#a(Z/this.#_)),j=this.#p(this.#a($/this.#_));this.#qJ(this.#L,Z,_,8),this.#qJ(this.#U,$,j,8)}#kJ(){let J=this.#y,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.#_-8,_*this.#_))}#qJ(J,Q,Z,$){if(!J)return;J.setAttribute("x",Q-$),J.setAttribute("y",Z-$),J.setAttribute("width",$*2),J.setAttribute("height",$*2)}#m(){for(let Q of this.#k)Q.addEventListener("change",(Z)=>{if(this.#D())return;let $=this.#V(Q);this.#l($),this.#Q[$].type=this.#E(Z.detail??Z.target?.value),this.#BJ(),this.#o("input"),this.#o("change")});for(let Q of this.#Y)Q.addEventListener("input",(Z)=>{Z.stopPropagation(),this.#S=Q;try{this.#NJ(this.#V(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"input")}finally{this.#S=null}}),Q.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#NJ(this.#V(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"change")});for(let Q of this.#T)Q.addEventListener("pointerdown",()=>{this.#l(this.#V(Q))}),Q.addEventListener("focusin",()=>{this.#l(this.#V(Q))}),Q.addEventListener("openchange",(Z)=>{let $=this.#V(Q);if(Z.detail?.open)this.#M.add($);else this.#M.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.#D())return;let j=this.#V(Q)+1,G=this.#E($.detail??Q.value);this.#Q.splice(j,0,U.#f(G)),this.#JJ(j),this.#Z=j,this.#g(),this.#o("input"),this.#o("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.#D()||this.#Q.length<=1)return;let $=this.#V(Q);this.#Q.splice($,1),this.#d($),this.#Z=Math.min(this.#Z,this.#Q.length-1),this.#g(),this.#o("input"),this.#o("change")});for(let Q of[this.#L,this.#U])this.#n(Q);this.querySelector(".propskit-oscillator-svg-container")?.addEventListener("pointerdown",(Q)=>{if(this.#D())return;if(Q.target?.closest?.(".propskit-oscillator-handle, fig-handle"))return;this.#UJ(Q,"offset")})}#V(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}#n(J){let Q=J?.querySelector("fig-handle"),Z=J?.getAttribute("data-handle");if(!Q||!Z)return;Q.addEventListener("pointerdown",($)=>{if(this.#D())return;$.preventDefault(),$.stopImmediatePropagation(),this.#UJ($,Z)},{capture:!0}),Q.addEventListener("keydown",($)=>{if(this.#D())return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes($.key))return;if(!this.#KJ($,Z))return;$.preventDefault(),$.stopImmediatePropagation()},{capture:!0})}#l(J){let Q=Math.min(this.#Q.length-1,Math.max(0,J));if(Q===this.#Z)return;this.#Z=Q,this.#FJ(),this.#YJ()}#NJ(J,Q,Z,$){if(this.#D())return;this.#l(J);let _=Number.parseFloat(Z);if(!Number.isFinite(_)){if($==="change")this.#DJ();return}this.#Q[J]=this.#F({...this.#Q[J],[Q]:_}),this.#BJ({skipFieldSync:$=="input"}),this.#o($)}#KJ(J,Q){let Z=J.shiftKey?0.5:0.1,$=this.#y;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.#F($),this.#BJ(),this.#o("input"),this.#o("change"),!0}#LJ(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}}#UJ(J,Q){this.#G=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 _=(G)=>{if(!this.#G)return;let X=this.#LJ(G),q=this.#y;if(Q==="frequency"){let B=Math.max(1,Math.min(this.#_,X.x));q.frequency=this.#_/B}else if(Q==="offset"){let B=this.#P(X.x/this.#_,0,0,1),Y=this.#zJ(q,B);q.offset=this.#QJ(X.y)-this.#MJ(this.#Z,B)-Y*q.amplitude}else if(Q==="amplitude"){let B=this.#P(X.x/this.#_,0,0,1),Y=this.#zJ(q,B),K=this.#QJ(X.y)-this.#MJ(this.#Z,B)-q.offset;q.amplitude=Math.abs(Y)<0.001?q.amplitude:K/Y}this.#Q[this.#Z]=this.#F(q),this.#BJ(),this.#o("input")},j=()=>{if(this.#G=null,this.#$?.classList.remove("dragging"),Z)document.body.style.cursor=$;document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",j),this.#o("change")};document.addEventListener("pointermove",_),document.addEventListener("pointerup",j)}#MJ(J,Q){return this.#Q.reduce((Z,$,_)=>{if(_===J)return Z;let j=Q*$.frequency,G=U.#u($.type,j,$.phase);return Z+$.offset+G*$.amplitude},0)}#zJ(J,Q){return U.#u(J.type,Q*J.frequency,J.phase)}#BJ({skipFieldSync:J=!1}={}){if(this.#WJ(),!J)this.#DJ();this.#FJ(),this.#ZJ()}#WJ(){for(let J of this.#k){let Q=this.#V(J);J.value=this.#Q[Q]?.type||"sine"}}#DJ(){for(let J of this.#Y){if(J===this.#S)continue;let Q=this.#V(J),Z=J.getAttribute("name"),$=this.#c(this.#Q[Q]?.[Z]??0),_=J.querySelector("fig-slider");if(_)_.value=$;else J.setAttribute("value",String($))}}#FJ(){for(let J of this.#W)if(this.#V(J)===this.#Z)J.setAttribute("data-active","");else J.removeAttribute("data-active")}#o(J){this.dispatchEvent(new CustomEvent(J,{bubbles:!0,detail:{value:this.value,data:this.data,preset:U.#t(this.#y.type)}}))}}customElements.define("propskit-oscillator",U);class m extends HTMLElement{#Q;#Z;#J=null;#_;#j;#N;#G;#$;#q;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.#_=this.#S.bind(this),this.#j=this.#w.bind(this),this.#N=this.#y.bind(this),this.#G=this.#E.bind(this),this.#$=this.#P.bind(this),this.#q=this.#f.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.#B("dial",!0),this.showRotations=this.#z(),this.#X(),this.#M(),this.#F(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision))})}disconnectedCallback(){this.#O()}#X(){this.innerHTML=this.#K()}#B(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}#z(){if(this.hasAttribute("rotations"))return this.#B("rotations",!1);if(this.hasAttribute("show-rotations"))return this.#B("show-rotations",!1);return!1}#K(){let J=this.#Y(),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,82 @@ function R(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
|
-
`}#k(){let J=Math.abs(this.#P(this.angle));return Math.floor(J/360)}#N(){if(!this.rotationSpan)return;let J=this.#k();if(J>1)this.rotationSpan.textContent=`×${J}`,this.rotationSpan.style.display="";else this.rotationSpan.textContent="",this.rotationSpan.style.display="none"}#q(){switch(this.units){case"rad":return 0.01;case"turn":return 0.001;default:return 0.1}}#P(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.#N(),this.plane?.addEventListener("mousedown",this.#j),this.plane?.addEventListener("touchstart",this.#O),window.addEventListener("keydown",this.#G),window.addEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#B);this.addEventListener("change",this.#_,!0)}#F(){if(this.plane?.removeEventListener("mousedown",this.#j),this.plane?.removeEventListener("touchstart",this.#O),window.removeEventListener("keydown",this.#G),window.removeEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#B);this.removeEventListener("change",this.#_,!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.#N(),this.#D(),this.#W()}#z(){let Q=this.#P(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.#P(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.#N(),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.#P(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.#N()}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.#X(),this.#L(),this.#M()}break;case"dial":if(this.dial=this.#K("dial",!0),this.isConnected)this.#X(),this.#L(),this.#M();break;case"units":{let $=Z||"°";if($==="deg")$="°";if(this.units=$,this.isConnected)this.#X(),this.#L(),this.#M();break}case"min":if(this.min=Z!==null?Number(Z):null,this.isConnected)this.#X(),this.#L(),this.#M();break;case"max":if(this.max=Z!==null?Number(Z):null,this.isConnected)this.#X(),this.#L(),this.#M();break;case"rotations":case"show-rotations":if(this.showRotations=this.#U(),this.isConnected)this.#X(),this.#L(),this.#M();break}}}customElements.define("fig-input-angle",w);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-color","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;#_=new Map;#j=null;#O=null;connectedCallback(){this.style.display="contents",this.#K(),this.#J=new MutationObserver(()=>this.#K()),this.#J.observe(this,{childList:!0})}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#M(),this.#b(),this.#S()}attributeChangedCallback(){if(this.isConnected)this.#K()}get#G(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}get#$(){return(this.getAttribute("axis")||"vertical").trim().toLowerCase()==="horizontal"?"horizontal":"vertical"}get#B(){return(this.getAttribute("handle")||"").trim()}#X(){return[...this.children].filter((J)=>J.nodeType===Node.ELEMENT_NODE)}#K(){let J=this.#X(),Q=new Set(J);for(let[Z,$]of this.#_)if(!Q.has(Z))$.target.removeEventListener("pointerdown",$.onPointerDown,!0),this.#_.delete(Z);if(this.#k(J),this.#U(J),this.#G||J.length<2){this.#M();return}for(let Z of J){let $=this.#q(Z),_=this.#_.get(Z);if(_&&_.target===$)continue;if(_)_.target.removeEventListener("pointerdown",_.onPointerDown,!0),this.#_.delete(Z);if(!$)continue;this.#P(Z,$)}this.#N(J),this.#Y(J)}#U(J){for(let Q of J)Q.removeAttribute("data-reorder-item")}#Y(J){for(let Q of J)Q.setAttribute("data-reorder-item","")}#k(J){for(let Q of J)Q.querySelectorAll("[data-reorder-handle]").forEach((Z)=>Z.removeAttribute("data-reorder-handle"))}#N(J){if(!this.#B)return;for(let Q of J){let Z=Q.querySelector(this.#B);if(Z)Z.setAttribute("data-reorder-handle","")}}#q(J){if(this.#B)return J.querySelector(this.#B);return J}#P(J,Q){let Z=($)=>{if(this.#G||this.#X().length<2)return;if($.button!==0)return;if(!this.#B&&this.#T($.target,J))return;this.#F($,J,Q)};Q.addEventListener("pointerdown",Z,!0),this.#_.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.#X().indexOf(Q),targetIndex:this.#X().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.#j=$,window.addEventListener("pointermove",$.onMove),window.addEventListener("pointerup",$.onUp),window.addEventListener("pointercancel",$.onUp),window.addEventListener("keydown",$.onKeyDown)}#V(J){let Q=this.#X(),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.#X(),$=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.#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.#X();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.#O?.remove(),this.#O=null}#D(J,Q){let Z=this.#X(),$=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.#X().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.#j===J)this.#j=null}#M(){for(let[,J]of this.#_)J.target.removeEventListener("pointerdown",J.onPointerDown,!0);this.#_.clear()}#b(){if(!this.#j)return;this.#W(this.#j,!0)}}customElements.define("fig-reorder",F);
|
|
48
|
+
`}#L(){let J=Math.abs(this.#k(this.angle));return Math.floor(J/360)}#U(){if(!this.rotationSpan)return;let J=this.#L();if(J>1)this.rotationSpan.textContent=`×${J}`,this.rotationSpan.style.display="";else this.rotationSpan.textContent="",this.rotationSpan.style.display="none"}#Y(){switch(this.units){case"rad":return 0.01;case"turn":return 0.001;default:return 0.1}}#k(J){switch(this.units){case"rad":return J*180/Math.PI;case"turn":return J*360;default:return J}}#W(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 $}}#M(){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.#U(),this.plane?.addEventListener("mousedown",this.#j),this.plane?.addEventListener("touchstart",this.#N),window.addEventListener("keydown",this.#G),window.addEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#q);this.addEventListener("change",this.#_,!0)}#O(){if(this.plane?.removeEventListener("mousedown",this.#j),this.plane?.removeEventListener("touchstart",this.#N),window.removeEventListener("keydown",this.#G),window.removeEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#q);this.removeEventListener("change",this.#_,!0)}#S(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)}}}#f(J){J.stopPropagation(),this.angle=Number(J.target.value),this.#H(),this.#F(),this.#U(),this.#R(),this.#A()}#H(){let Q=this.#k(this.angle)*Math.PI/180;this.#Q=Math.cos(Q),this.#Z=Math.sin(Q)}#C(J){if(!this.isShiftHeld)return J;let Q=45;return Math.round(J/Q)*Q}#h(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}#D(J){let Z=(this.#h(J)%360+360)%360;if(Z=this.#C(Z),this.min!==null||this.max!==null)this.angle=this.#W(Z);else if(this.#J===null){this.#J=Z;let j=(this.#k(this.angle)%360+360)%360,G=Z-j;if(G>180)G-=360;if(G<-180)G+=360;this.angle+=this.#W(G)}else{let _=Z-this.#J;if(_>180)_-=360;if(_<-180)_+=360;this.angle+=this.#W(_),this.#J=Z}if(this.#H(),this.#F(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#U(),this.#R()}#R(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#A(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#F(){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)`}}#w(J){this.isDragging=!0,this.#J=null,this.#D(J);let Q=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#D($)},Z=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("mousemove",Q),window.removeEventListener("mouseup",Z),this.#A()};window.addEventListener("mousemove",Q),window.addEventListener("mouseup",Z)}#y(J){J.preventDefault(),this.isDragging=!0,this.#J=null,this.#D(J.touches[0]);let Q=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#D($.touches[0])},Z=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("touchmove",Q),window.removeEventListener("touchend",Z),this.#A()};window.addEventListener("touchmove",Q),window.addEventListener("touchend",Z)}#E(J){if(J.key==="Shift")this.isShiftHeld=!0}#P(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.#H(),this.#F(),this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#U()}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.#X(),this.#M(),this.#F()}break;case"dial":if(this.dial=this.#B("dial",!0),this.isConnected)this.#X(),this.#M(),this.#F();break;case"units":{let $=Z||"°";if($==="deg")$="°";if(this.units=$,this.isConnected)this.#X(),this.#M(),this.#F();break}case"min":if(this.min=Z!==null?Number(Z):null,this.isConnected)this.#X(),this.#M(),this.#F();break;case"max":if(this.max=Z!==null?Number(Z):null,this.isConnected)this.#X(),this.#M(),this.#F();break;case"rotations":case"show-rotations":if(this.showRotations=this.#z(),this.isConnected)this.#X(),this.#M(),this.#F();break}}}customElements.define("fig-input-angle",m);class C 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-color","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;#_=new Map;#j=null;#N=null;connectedCallback(){this.style.display="contents",this.#B(),this.#J=new MutationObserver(()=>this.#B()),this.#J.observe(this,{childList:!0})}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#F(),this.#w(),this.#D()}attributeChangedCallback(){if(this.isConnected)this.#B()}get#G(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}get#$(){return(this.getAttribute("axis")||"vertical").trim().toLowerCase()==="horizontal"?"horizontal":"vertical"}get#q(){return(this.getAttribute("handle")||"").trim()}#X(){return[...this.children].filter((J)=>J.nodeType===Node.ELEMENT_NODE)}#B(){let J=this.#X(),Q=new Set(J);for(let[Z,$]of this.#_)if(!Q.has(Z))$.target.removeEventListener("pointerdown",$.onPointerDown,!0),this.#_.delete(Z);if(this.#L(J),this.#z(J),this.#G||J.length<2){this.#F();return}for(let Z of J){let $=this.#Y(Z),_=this.#_.get(Z);if(_&&_.target===$)continue;if(_)_.target.removeEventListener("pointerdown",_.onPointerDown,!0),this.#_.delete(Z);if(!$)continue;this.#k(Z,$)}this.#U(J),this.#K(J)}#z(J){for(let Q of J)Q.removeAttribute("data-reorder-item")}#K(J){for(let Q of J)Q.setAttribute("data-reorder-item","")}#L(J){for(let Q of J)Q.querySelectorAll("[data-reorder-handle]").forEach((Z)=>Z.removeAttribute("data-reorder-handle"))}#U(J){if(!this.#q)return;for(let Q of J){let Z=Q.querySelector(this.#q);if(Z)Z.setAttribute("data-reorder-handle","")}}#Y(J){if(this.#q)return J.querySelector(this.#q);return J}#k(J,Q){let Z=($)=>{if(this.#G||this.#X().length<2)return;if($.button!==0)return;if(!this.#q&&this.#W($.target,J))return;this.#O($,J,Q)};Q.addEventListener("pointerdown",Z,!0),this.#_.set(J,{target:Q,onPointerDown:Z})}#W(J,Q){let Z=J;while(Z&&Z!==Q){if(Z instanceof Element){for(let $ of C.#Z)if(Z.matches($))return!0}Z=Z.parentElement}return!1}static#T="fig-reorder-dragging";static#M(J){document.body.classList.toggle(C.#T,J)}#O(J,Q,Z){this.#w(),C.#M(!0);let $={item:Q,target:Z,pointerId:J.pointerId,oldIndex:this.#X().indexOf(Q),targetIndex:this.#X().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,G=_.clientY-$.startY;if(!$.active){if(j*j+G*G<C.#Q*C.#Q)return;$.active=!0,J.preventDefault(),J.stopPropagation(),Q.classList.add("dragging");try{Z.setPointerCapture($.pointerId)}catch{}}_.preventDefault();let X=this.#$==="horizontal"?_.clientX:_.clientY,q=this.#S(X);$.targetIndex=q,this.#h(q,Q)},$.onKeyDown=(_)=>{if(_.key!=="Escape"||!$.active)return;_.preventDefault(),this.#A($,!0)},$.onUp=(_)=>{if(_.pointerId!==$.pointerId)return;this.#A($,_.type==="pointercancel")},this.#j=$,window.addEventListener("pointermove",$.onMove),window.addEventListener("pointerup",$.onUp),window.addEventListener("pointercancel",$.onUp),window.addEventListener("keydown",$.onKeyDown)}#S(J){let Q=this.#X(),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}#f(J,Q){let Z=this.#X(),$=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}#H(J){if(!J.length)return null;let Q=1/0,Z=-1/0,$=1/0,_=-1/0;for(let j of J){let G=j.getBoundingClientRect();Q=Math.min(Q,G.left),Z=Math.max(Z,G.right),$=Math.min($,G.top),_=Math.max(_,G.bottom)}return{left:Q,top:$,width:Z-Q,height:_-$}}#C(){if(this.#N)return this.#N;let J=document.createElement("div");return J.className="fig-reorder-indicator",J.setAttribute("data-axis",this.#$),document.body.appendChild(J),this.#N=J,J}#h(J,Q){let Z=this.#X();if(!this.#f(Q,J)){this.#D();return}let $=this.#H(Z);if(!$){this.#D();return}let _=this.#C();if(_.setAttribute("data-axis",this.#$),this.#$==="horizontal"){let G;if(J<=0)G=Z[0].getBoundingClientRect().left;else if(J>=Z.length)G=Z[Z.length-1].getBoundingClientRect().right;else G=Z[J].getBoundingClientRect().left;_.style.left=`${G-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"}#D(){this.#N?.remove(),this.#N=null}#R(J,Q){let Z=this.#X(),$=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,_)}#A(J,Q){let{item:Z,oldIndex:$,active:_,onMove:j,onUp:G,onKeyDown:X}=J;if(window.removeEventListener("pointermove",j),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G),window.removeEventListener("keydown",X),_){if(!Q){this.#R(Z,J.targetIndex);let q=this.#X().indexOf(Z);if(q!==-1&&q!==$)this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:$,newIndex:q,item:Z}}))}}if(Z.classList.remove("dragging"),C.#M(!1),this.#D(),this.#j===J)this.#j=null}#F(){for(let[,J]of this.#_)J.target.removeEventListener("pointerdown",J.onPointerDown,!0);this.#_.clear()}#w(){if(!this.#j)return;this.#A(this.#j,!0)}}customElements.define("fig-reorder",C);var f=0;function p(J="fig-select"){return f+=1,`${J}-${f}`}function l(J){let Q=J||"";if(Q.startsWith("["))try{let $=JSON.parse(Q);return Array.isArray($)?$:[]}catch{}let Z=Q.includes(`
|
|
49
|
+
`)?`
|
|
50
|
+
`:",";return Q.split(Z).map(($)=>$.trim()).filter(Boolean)}function d(J){if(J&&typeof J==="object")return String(J.value??J.label??"");return String(J??"")}function i(J){if(J&&typeof J==="object")return String(J.label??J.value??"");return String(J??"")}class c extends HTMLElement{static get observedAttributes(){return["value","disabled","selected"]}get value(){let J=this.getAttribute("value");if(J!==null)return J;return(this.textContent||"").trim()}set value(J){if(J===null||J===void 0)this.removeAttribute("value");else this.setAttribute("value",String(J))}get disabled(){return N(this,"disabled")}set disabled(J){if(J)this.setAttribute("disabled","");else this.removeAttribute("disabled")}get selected(){return N(this,"selected")}set selected(J){if(J)this.setAttribute("selected","");else this.removeAttribute("selected")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","option");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Q()}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="disabled")this.#Q()}#Q(){if(this.disabled)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}customElements.define("fig-select-option",c);function o(J,Q,Z=2){if(!J||!Q)return!1;let $=Q.scrollHeight-Q.clientHeight>Z,_=!$||Q.scrollTop<=Z,j=!$||Q.scrollTop+Q.clientHeight>=Q.scrollHeight-Z;return J.classList.toggle("overflow-start",!_),J.classList.toggle("overflow-end",!j),$}function A(J,Q=1){if(!J)return;J.scrollBy({top:J.clientHeight*0.8*Q,behavior:"smooth"})}function a({onStart:J,onEnd:Q}={}){let Z=($,_)=>{let j=document.createElement("button");j.type="button",j.className=`fig-overflow fig-overflow-${$}`,j.dataset.figOverflow=$,j.setAttribute("data-fig-select-nav",$),j.setAttribute("tabindex","-1"),j.setAttribute("aria-label",$==="start"?"Scroll up":"Scroll down");let G=document.createElement("fig-icon");return G.setAttribute("name","chevron"),G.setAttribute("size","small"),G.className="fig-overflow-chevron",j.appendChild(G),j.addEventListener("click",(X)=>{X.preventDefault(),X.stopPropagation(),_?.(X)}),j};return{start:Z("start",J),end:Z("end",Q)}}class v extends HTMLElement{#Q=null;#Z=null;#J=null;#_=this.syncOverflow.bind(this);connectedCallback(){if(!this.hasAttribute("slot"))this.setAttribute("slot","panel");this.#j(),this.#N(),this.addEventListener("scroll",this.#_,{passive:!0}),this.#J?.disconnect(),this.#J=new ResizeObserver(()=>this.syncOverflow()),this.#J.observe(this),requestAnimationFrame(()=>this.syncOverflow())}disconnectedCallback(){this.removeEventListener("scroll",this.#_),this.#J?.disconnect(),this.#J=null,this.#G()}syncOverflow(){return o(this,this)}scrollToOption(J,Q="auto"){if(!J||!this.contains(J))return;requestAnimationFrame(()=>{if(!J.isConnected)return;if(this.scrollHeight<=this.clientHeight+1){this.syncOverflow();return}let Z=J.getBoundingClientRect(),$=this.getBoundingClientRect(),_=Z.top-$.top+this.scrollTop,j=this.scrollHeight-this.clientHeight,G=Math.max(0,Math.min(_+Z.height/2-this.clientHeight/2,j));this.scrollTo({top:G,behavior:Q}),this.syncOverflow()})}#j(){let J=this.querySelector(":scope > fig-chooser");if(!J)return;while(J.firstChild)this.insertBefore(J.firstChild,J);J.remove()}#N(){if(this.#Q&&this.#Z&&this.contains(this.#Q)&&this.contains(this.#Z))return;this.#G();let J=a({onStart:()=>A(this,-1),onEnd:()=>A(this,1)});this.#Q=J.start,this.#Z=J.end,this.prepend(this.#Q),this.append(this.#Z)}#G(){this.#Q?.remove(),this.#Z?.remove(),this.#Q=null,this.#Z=null,this.classList.remove("overflow-start","overflow-end")}}customElements.define("fig-select-options",v);class u extends HTMLElement{#Q=null;#Z=null;#J=null;#_=null;#j=null;#N=!1;#G=-1;#$=!1;#q=!1;#X=null;#B=!1;#z=!1;#K=this.#v.bind(this);#L=this.#e.bind(this);#U=this.#$J.bind(this);#Y=this.#r.bind(this);#k=this.#w.bind(this);static get observedAttributes(){return["value","disabled","label","options","position","offset","closedby","open"]}get value(){return this.getAttribute("value")??""}set value(J){if(J===null||J===void 0)this.removeAttribute("value");else this.setAttribute("value",String(J))}get open(){return N(this,"open")}set open(J){if(J)this.setAttribute("open","");else this.removeAttribute("open")}connectedCallback(){if(!this.#N)this.#H();if(this.#T(),this.#f(),this.#t(),this.#b(),this.#x(),this.#y(),this.open)this.#_J()}disconnectedCallback(){this.#F(),document.removeEventListener("keydown",this.#U,!0),this.#j?.disconnect(),this.#j=null}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#N)return;if(J==="options"){this.#f(),this.#x();return}if(J==="value"||J==="label"){this.#x();return}if(J==="disabled"){this.#t();return}if(J==="open"){if(Z===null||Z==="false")this.#p();else this.#_J();return}if(J==="position"||J==="offset"||J==="closedby")this.#b()}focus(J){this.#Q?.focus(J)}blur(){this.#Q?.blur()}#W(J){return J?.nodeType===1&&(J.tagName==="FIG-SELECT-OPTION"||J.tagName==="FIG-MENU-SEPARATOR"||J.tagName==="FIG-SELECT-OPTIONS")}#T(){for(let J of this.querySelectorAll(":scope > fig-select-options"))if(!J.hasAttribute("slot"))J.setAttribute("slot","panel")}#M(){let Q=(this.#_?.assignedElements({flatten:!0})??[]).find((Z)=>Z.tagName==="FIG-SELECT-OPTIONS");if(Q)return Q;return this.querySelector(":scope > fig-select-options")}#O(){return Boolean(this.querySelector(":scope > fig-select-option:not([data-fig-generated]), :scope > fig-select-options > fig-select-option:not([data-fig-generated])"))}#S(){let J=this.#M();if(J){if(!J.hasAttribute("slot"))J.setAttribute("slot","panel");return J}return J=document.createElement("fig-select-options"),J.setAttribute("slot","panel"),J.setAttribute("data-fig-generated",""),this.appendChild(J),J}#f(){if(this.#O())return;let J=this.hasAttribute("options"),Q=J?this.#S():this.#M();if(!Q)return;this.#z=!0;try{for(let _ of Q.querySelectorAll(":scope > fig-select-option[data-fig-generated]"))_.remove();if(!J)return;let Z=l(this.getAttribute("options")),$=Q.querySelector(":scope > .fig-overflow-end");for(let _ of Z){let j=document.createElement("fig-select-option");if(j.setAttribute("data-fig-generated",""),j.setAttribute("value",d(_)),j.textContent=i(_),$)Q.insertBefore(j,$);else Q.appendChild(j)}}finally{this.#z=!1}}#H(){this.#N=!0;let J=this.attachShadow({mode:"open"});J.innerHTML=`
|
|
51
|
+
<style>
|
|
52
|
+
:host {
|
|
53
|
+
display: inline-flex;
|
|
54
|
+
position: relative;
|
|
55
|
+
align-items: center;
|
|
56
|
+
min-width: 0;
|
|
57
|
+
}
|
|
58
|
+
:host([full]:not([full="false"])) {
|
|
59
|
+
display: flex;
|
|
60
|
+
width: 100%;
|
|
61
|
+
}
|
|
62
|
+
.fig-select-trigger {
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
justify-content: flex-start;
|
|
66
|
+
flex: 1;
|
|
67
|
+
min-width: 0;
|
|
68
|
+
width: var(--fig-select-trigger-width, 100%);
|
|
69
|
+
height: 100%;
|
|
70
|
+
margin: 0;
|
|
71
|
+
padding: 0 var(--spacer-4, 1rem) 0 var(--spacer-2, 0.5rem);
|
|
72
|
+
border: 0;
|
|
73
|
+
border-radius: inherit;
|
|
74
|
+
background: transparent;
|
|
75
|
+
box-shadow: none;
|
|
76
|
+
color: inherit;
|
|
77
|
+
font: inherit;
|
|
78
|
+
font-weight: inherit;
|
|
79
|
+
text-align: left;
|
|
80
|
+
white-space: nowrap;
|
|
81
|
+
overflow: hidden;
|
|
82
|
+
text-overflow: ellipsis;
|
|
83
|
+
cursor: default;
|
|
84
|
+
}
|
|
85
|
+
.fig-select-trigger:hover,
|
|
86
|
+
.fig-select-trigger:active,
|
|
87
|
+
.fig-select-trigger:active:hover {
|
|
88
|
+
background: transparent;
|
|
89
|
+
box-shadow: none;
|
|
90
|
+
color: inherit;
|
|
91
|
+
}
|
|
92
|
+
.fig-select-trigger:focus-visible,
|
|
93
|
+
.fig-select-trigger[data-focus-visible] {
|
|
94
|
+
outline: var(--figma-focus-outline);
|
|
95
|
+
outline-offset: var(--figma-focus-outline-offset);
|
|
96
|
+
}
|
|
97
|
+
:host([disabled]:not([disabled="false"])) .fig-select-trigger,
|
|
98
|
+
:host([disabled]:not([disabled="false"])) .fig-select-label {
|
|
99
|
+
color: var(--figma-color-text-tertiary);
|
|
100
|
+
}
|
|
101
|
+
.fig-select-label {
|
|
102
|
+
display: block;
|
|
103
|
+
width: 100%;
|
|
104
|
+
min-width: 0;
|
|
105
|
+
overflow: hidden;
|
|
106
|
+
text-overflow: ellipsis;
|
|
107
|
+
white-space: nowrap;
|
|
108
|
+
text-align: left;
|
|
109
|
+
}
|
|
110
|
+
/* Listbox chrome from document fig-select::part(listbox).
|
|
111
|
+
Overflow UI lives on slotted fig-select-options.
|
|
112
|
+
Never set display except when open — closed <dialog> must stay display:none. */
|
|
113
|
+
dialog[is="fig-popup"] {
|
|
114
|
+
flex-direction: column;
|
|
115
|
+
overflow: hidden;
|
|
116
|
+
}
|
|
117
|
+
dialog[is="fig-popup"][open] {
|
|
118
|
+
display: flex;
|
|
119
|
+
}
|
|
120
|
+
::slotted(fig-select-options) {
|
|
121
|
+
flex: 1 1 auto;
|
|
122
|
+
min-height: 0;
|
|
123
|
+
max-height: inherit;
|
|
124
|
+
}
|
|
125
|
+
</style>
|
|
126
|
+
`;let Q=document.createElement("fig-button");Q.className="fig-select-trigger",Q.setAttribute("part","trigger"),Q.setAttribute("variant","ghost"),Q.setAttribute("aria-haspopup","listbox"),Q.setAttribute("aria-expanded","false");let Z=document.createElement("span");Z.className="fig-select-label",Z.setAttribute("part","label"),Q.appendChild(Z);let $=document.createElement("dialog",{is:"fig-popup"});$.setAttribute("is","fig-popup"),$.setAttribute("part","listbox"),$.setAttribute("theme","menu"),$.setAttribute("role","listbox"),$.id=p("fig-select-list"),Q.setAttribute("aria-controls",$.id);let _=document.createElement("slot");if(_.setAttribute("name","panel"),$.appendChild(_),J.append(Q,$),this.#Q=Q,this.#J=Z,this.#Z=$,this.#_=_,$.anchor=Q,this.#T(),this.#A(),this.#C(),!this.hasAttribute("value")){let j=this.#E().find((G)=>N(G,"selected"));if(j)this.setAttribute("value",j.value)}}#C(){if(!this.#Z||this.#q)return;if(typeof this.#Z.positionPopup!=="function")return;this.#X=this.#Z.positionPopup.bind(this.#Z),this.#Z.positionPopup=()=>{if(!this.open){this.#X?.();return}this.#R()},this.#q=!0}#h(J){if(!J)return null;let Q=document.createRange();Q.selectNodeContents(J);let Z=[...Q.getClientRects()].filter(($)=>$.width>0&&$.height>0);if(Z.length)return Z[0];return J.getBoundingClientRect()}#D(){if(typeof this.#Z?.parseViewportMargins==="function")return this.#Z.parseViewportMargins();return{top:8,right:8,bottom:8,left:8}}#R(){if(this.#B)return;let J=this.#Z,Q=this.#J;if(!J||!Q){this.#X?.();return}let Z=this.#E(),$=Z.find((F)=>this.#P(F)===this.value)||Z[0];if(!$){this.#X?.();return}this.#X?.();let _=J.getBoundingClientRect(),j=Q.getBoundingClientRect(),G=this.#h($);if(!_.width||!_.height||!j.width||!G)return;let X=G.left-_.left,q=G.top-_.top,B=j.left-X,Y=j.top-q,K=this.#D(),k=K.left,M=K.top,D=window.innerWidth-_.width-K.right,z=window.innerHeight-_.height-K.bottom;B=Math.min(Math.max(B,k),Math.max(k,D)),Y=Math.min(Math.max(Y,M),Math.max(M,z)),J.style.left=`${Math.round(B)}px`,J.style.top=`${Math.round(Y)}px`;let L=this.#M(),T=this.#h($);if(T&&L&&L.scrollHeight>L.clientHeight+1){let F=T.top-j.top;if(Math.abs(F)>0.5)L.scrollTop+=F;L.syncOverflow?.()}}#A(){this.#Q?.addEventListener("click",this.#K),this.#Q?.addEventListener("keydown",this.#U),this.addEventListener("click",this.#L),this.#Z?.addEventListener("keydown",this.#U),this.#Z?.addEventListener("close",this.#Y),this.#_?.addEventListener("slotchange",this.#k)}#F(){this.#Q?.removeEventListener("click",this.#K),this.#Q?.removeEventListener("keydown",this.#U),this.removeEventListener("click",this.#L),this.#Z?.removeEventListener("keydown",this.#U),this.#Z?.removeEventListener("close",this.#Y),this.#_?.removeEventListener("slotchange",this.#k)}#w(){this.#T(),this.#x()}#y(){if(this.#j)return;this.#j=new MutationObserver((J)=>{if(this.#$||this.#z)return;let Q=!1;for(let Z of J){if(Z.type==="childList"){if([...Z.addedNodes].some(($)=>this.#W($))||[...Z.removedNodes].some(($)=>this.#W($)))Q=!0}if(Z.type==="attributes"&&Z.target?.tagName==="FIG-SELECT-OPTION"&&(Z.attributeName==="value"||Z.attributeName==="disabled"))Q=!0;if(Z.type==="characterData"&&Z.target?.parentElement?.tagName==="FIG-SELECT-OPTION")Q=!0}if(Q)this.#x()}),this.#j.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","disabled","selected"]})}#E({enabledOnly:J=!1}={}){let Q=this.#M(),Z=Q?Array.from(Q.querySelectorAll(":scope > fig-select-option")):[];if(!J)return Z;return Z.filter(($)=>!N($,"disabled"))}#P(J){if(!J)return"";if(typeof J.value==="string")return J.value;let Q=J.getAttribute?.("value");if(Q!=null)return Q;return(J.textContent||"").trim()}#c(J){return(J?.textContent||"").trim()}#b(){if(!this.#Z)return;this.#Z.setAttribute("position",this.getAttribute("position")||"bottom left");let J=this.getAttribute("offset");if(J)this.#Z.setAttribute("offset",J);else this.#Z.removeAttribute("offset");let Q=this.getAttribute("closedby");if(Q)this.#Z.setAttribute("closedby",Q);else this.#Z.removeAttribute("closedby")}#t(){let J=N(this,"disabled");if(this.#Q)if(J)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(J&&this.open)this.open=!1}#u(J){if(!J.length)return null;let Q=J.find((Z)=>N(Z,"selected"));if(Q&&!N(Q,"disabled"))return Q;return J.find((Z)=>!N(Z,"disabled"))||J[0]||null}#g(J){this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}#x(){if(this.#$)return;this.#$=!0;try{let J=this.#E(),Q=this.hasAttribute("value"),Z=Q?this.getAttribute("value"):null,$=Q?J.find((X)=>this.#P(X)===Z):null,_=!1;if(!$){if(Q){if(!J.length){if(this.#J)this.#J.textContent=Z||this.getAttribute("label")||"";return}if($=this.#u(J),$){let X=this.#P($);if(Z!==X)this.setAttribute("value",X),_=!0}else this.removeAttribute("value"),_=!0}else if($=J.find((X)=>N(X,"selected")),$)this.setAttribute("value",this.#P($)),_=!0}for(let X of J){let q=X===$;if(X.setAttribute("aria-selected",q?"true":"false"),q)X.setAttribute("selected","");else X.removeAttribute("selected")}let j=$&&this.#c($)||this.getAttribute("label")||"";if(this.#J)this.#J.textContent=j;let G=this.getAttribute("label")||"Select";if(this.#Q?.setAttribute("aria-label",G),this.#M()?.syncOverflow?.(),_)this.#g(this.getAttribute("value")??"")}finally{this.#$=!1}}#v(J){if(N(this,"disabled"))return;J.preventDefault(),J.stopPropagation();let Q=this.#Z?.matches?.(":open")??!1;if(this.open&&Q)this.open=!1;else{if(this.#Z&&this.#Q)this.#Z.anchor=this.#Q;this.open=!0}}#e(J){let Z=(typeof J.composedPath==="function"?J.composedPath():[]).find(($)=>$?.tagName==="FIG-SELECT-OPTION");if(!Z||!this.contains(Z))return;if(N(Z,"disabled"))return;this.#s(Z)}#$J(J){if(J.currentTarget===document&&J.key!=="Escape")return;if(!(this.open&&(this.#Z?.matches?.(":open")??!1))){if(this.#Q?.contains(J.target)&&(J.key==="ArrowDown"||J.key==="Enter"||J.key===" ")){if(J.preventDefault(),this.#Z&&this.#Q)this.#Z.anchor=this.#Q;this.open=!0,requestAnimationFrame(()=>{let _=this.#E({enabledOnly:!0}).findIndex((j)=>this.#P(j)===this.value);this.#I(_>=0?_:0)})}return}let Z=this.#E({enabledOnly:!0});if(!Z.length)return;switch(J.key){case"ArrowDown":J.preventDefault(),this.#JJ(),this.#I(this.#G+1);break;case"ArrowUp":J.preventDefault(),this.#JJ(),this.#I(this.#G-1);break;case"Home":J.preventDefault(),this.#I(0);break;case"End":J.preventDefault(),this.#I(Z.length-1);break;case"Escape":J.preventDefault(),this.open=!1,this.#Q?.focus();break;case"Enter":case" ":{this.#JJ();let $=Z[this.#G];if(!$)return;J.preventDefault(),this.#s($);break}}}#r(){if(this.hasAttribute("open"))this.removeAttribute("open");this.#Q?.setAttribute("aria-expanded","false"),this.#Q?.focus(),this.#G=-1}#s(J){let Q=this.#P(J);this.setAttribute("value",Q),this.#x(),this.#g(Q),this.open=!1}#d(){return this.#E({enabledOnly:!0})}#JJ(){let J=this.#d();if(!J.length){this.#G=-1;return}let Q=J.find(($)=>$===document.activeElement),Z=Q?J.indexOf(Q):-1;this.#G=Z>=0?Z:this.#G}#I(J){let Q=this.#d();if(!Q.length)return;let Z=(J%Q.length+Q.length)%Q.length;this.#G=Z,Q[Z]?.focus()}#i(){if(!this.#Z||!this.#Q)return;let J=Math.ceil(this.getBoundingClientRect().width),Q=Math.ceil(this.#Q.getBoundingClientRect().width),Z=Math.max(J,Q,96);if(N(this,"full"))this.#Z.style.setProperty("width",`${Z}px`,"important"),this.#Z.style.setProperty("min-width",`${Z}px`,"important"),this.#Z.style.setProperty("max-width",`${Z}px`,"important");else this.#Z.style.setProperty("width","max-content","important"),this.#Z.style.setProperty("min-width",`${Z}px`,"important"),this.#Z.style.setProperty("max-width","min(20rem, calc(100vw - 1rem))","important")}#_J(){if(!this.#Z||N(this,"disabled"))return;if(this.#Q)this.#Z.anchor=this.#Q;this.#C(),this.#B=!1,this.#x(),this.#i(),this.#Z.open=!0,document.addEventListener("keydown",this.#U,!0),this.#Q?.setAttribute("aria-expanded","true"),this.#G=-1,requestAnimationFrame(()=>{this.#i(),this.#R();let J=this.#M(),Z=this.#d().findIndex(($)=>this.#P($)===this.value);if(Z>=0)this.#I(Z);else if(this.#Q?.hasAttribute("data-focus-visible")||this.#Q?.matches?.(":focus-visible"))this.#I(0);J?.syncOverflow?.(),this.#B=!0})}#p(){if(!this.#Z)return;this.#B=!1,document.removeEventListener("keydown",this.#U,!0),this.#Z.open=!1,this.#Q?.setAttribute("aria-expanded","false")}}customElements.define("fig-select",u);
|