@rogieking/figui3 6.21.0 → 6.22.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/.cursor/skills/figui3/SKILL.md +1 -15
- package/.cursor/skills/propkit/SKILL.md +2 -2
- package/README.md +6 -8
- package/components.css +338 -200
- package/dist/components.css +1 -1
- package/dist/fig-editor.css +1 -1
- package/dist/fig-editor.js +63 -191
- package/dist/fig-lab.css +1 -1
- package/dist/fig-lab.js +32 -103
- package/dist/fig.css +1 -1
- package/dist/fig.js +128 -39
- package/dist/propskit.css +1 -1
- package/dist/propskit.js +1 -591
- package/fig-editor.js +193 -68
- package/fig-lab.css +32 -307
- package/fig-lab.js +743 -1288
- package/fig.js +1653 -342
- package/package.json +2 -2
package/dist/fig-lab.js
CHANGED
|
@@ -1,39 +1,44 @@
|
|
|
1
|
-
function Y(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class y extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#X=null;#$=null;#q=this.#k.bind(this);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#G();if(this.#B(),this.#K(),this.#M(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),!this.#_)this.#_=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.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#U(),this.removeEventListener("click",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#B()}#G(){let Q=Array.from(this.childNodes).filter((G)=>G.nodeType!==Node.TEXT_NODE||Boolean(G.textContent?.trim())).find((G)=>G.nodeType===Node.ELEMENT_NODE&&G.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-segmented-control"),j=document.createElement("fig-segment"),X=document.createElement("fig-segment");_.setAttribute("sizing","equal"),j.setAttribute("value","off"),j.textContent="Off",X.setAttribute("value","on"),X.textContent="On",_.append(j,X),Z.append($,_),this.#Z=Z,this.#Q=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z)}#B(){if(!this.#Z||!this.#Q)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#D(){let J=new Set(["label","direction","size","oninput","onchange","class","style","id","checked","value"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#K(){if(!this.#J)return;let J=this.#D(),Q=new Set(J);for(let Z of this.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#J.setAttribute("value",Y(this,"checked")?"on":"off"),this.#Y=Q}#M(){if(!this.#J)return;this.#X??=this.#N.bind(this,"input"),this.#$??=this.#N.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);if(this.#$)this.#J.removeEventListener("change",this.#$)}#N(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":Y(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",y);class b extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#X=null;#$=null;#q=this.#H.bind(this);#G=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#B();if(this.#D(),this.#M(),this.#U(),this.#G===null)this.#G=this.getAttribute("default")??this.getAttribute("value")??"";if(this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),!this.#_)this.#_=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.#D();if(Z)this.#M()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#N(),this.removeEventListener("click",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#D()}#B(){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.#Z=Z,this.#Q=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z)}#D(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Color")}#K(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","text","default"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#M(){if(!this.#J)return;let J=this.#K(),Q=new Set(J);for(let Z of this.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J){let $=this.getAttribute(Z)??"";if(Z==="value"&&this.#J.getAttribute("value")===$)continue;this.#J.setAttribute(Z,$)}this.#J.setAttribute("text","true"),this.#Y=Q}#U(){if(!this.#J)return;this.#X??=this.#W.bind(this,"input"),this.#$??=this.#W.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#N(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);if(this.#$)this.#J.removeEventListener("change",this.#$)}#k(J){let Q=J instanceof CustomEvent&&J.detail!==void 0?J.detail:void 0;if(typeof Q==="string"&&Q)return Q;if(Q&&typeof Q==="object"){if(typeof Q.value==="string"&&Q.value)return Q.value;if(typeof Q.hex==="string"&&Q.hex)return Q.hex;if(typeof Q.color==="string"&&Q.color)return Q.color}if(typeof this.#J?.value==="string"&&this.#J.value)return this.#J.value;return this.#J?.getAttribute("value")??""}#W(J,Q){Q.stopImmediatePropagation();let Z=this.#k(Q);if(this.setAttribute("value",Z),this.#J&&this.#J.getAttribute("value")!==Z)this.#J.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}))}#H(J){if(J.target instanceof Element&&J.target.closest("fig-input-color"))return;this.focus()}get value(){return this.getAttribute("value")??this.#J?.value??this.#J?.getAttribute("value")??""}set value(J){if(J===null||J===void 0||J===""){this.removeAttribute("value"),this.#J?.removeAttribute("value");return}let Q=String(J);if(this.setAttribute("value",Q),this.#J&&this.#J.getAttribute("value")!==Q)this.#J.setAttribute("value",Q)}#L(J){if(!this.#J)return;if(this.#J.getAttribute("value")===J)this.#J.removeAttribute("value");this.#J.setAttribute("value",J)}#T(){return this.getAttribute("default")??this.#G??""}resetToDefault(){let J=String(this.#T());this.setAttribute("value",J),this.#L(J),this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,cancelable:!0,composed:!0}))}focus(J){this.#J?.querySelector("input:not([tabindex='-1'])")?.focus(J)}}customElements.define("propskit-color",b);class w extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#X=null;#$=null;#q=this.#T.bind(this);#G=this.#L.bind(this);#B=!1;static get observedAttributes(){return["label","direction","aria-label","options","value"]}connectedCallback(){if(!this.#Z)this.#D();if(this.#K(),this.#U(),this.#N(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),this.removeEventListener("pointerdown",this.#G,!0),this.addEventListener("pointerdown",this.#G,!0),!this.#_)this.#_=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.#K();if(Z)this.#U()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#k(),this.removeEventListener("click",this.#q),this.removeEventListener("pointerdown",this.#G,!0)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label"){this.#K();return}if(J==="options"||J==="value")this.#U()}#D(){let J=this.querySelector(":scope > label"),Q=document.createElement("fig-field"),Z=J||document.createElement("label"),$=document.createElement("fig-select");$.setAttribute("full",""),Q.append(Z,$),this.#Z=Q,this.#Q=Z,this.#J=$,this.#j=Boolean(J),this.replaceChildren(Q)}#K(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Select"),this.#J.setAttribute("full","")}#M(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","full"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#U(){if(!this.#J)return;let J=this.#M().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.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#Y=Q}#N(){if(!this.#J)return;this.#X??=this.#W.bind(this,"input"),this.#$??=this.#W.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#k(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);if(this.#$)this.#J.removeEventListener("change",this.#$)}#W(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}))}#H(){if(!this.#J)return!1;if(this.#J.open)return!0;let J=this.#J.shadowRoot?.querySelector('dialog[is="fig-popup"]');return Boolean(J?.open||J?.matches?.(":open"))}#L(J){if(!(J.target instanceof Element))return;if(J.target.closest("fig-select")){this.#B=!1;return}this.#B=this.#H()}#T(J){if(J.target instanceof Element&&J.target.closest("fig-select")){this.#B=!1;return}if(!this.#J||Y(this.#J,"disabled")){this.#B=!1;return}if(this.#J.focus(),this.#B||this.#H()){this.#B=!1,this.#J.open=!1;return}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",w);class x extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#X=null;#$=null;#q=this.#k.bind(this);static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#G();if(this.#B(),this.#K(),this.#M(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),!this.#_)this.#_=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.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#U(),this.removeEventListener("click",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#B()}#G(){let J=Array.from(this.childNodes).filter((j)=>j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())),Q=J.find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-input-text");for(let j of J)if(j!==Q)_.appendChild(j);Z.append($,_),this.#Z=Z,this.#Q=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z)}#B(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Text")}#D(){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.#D(),Q=new Set(J);for(let Z of this.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#Y=Q}#M(){if(!this.#J)return;this.#X??=this.#N.bind(this,"input"),this.#$??=this.#N.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);if(this.#$)this.#J.removeEventListener("change",this.#$)}#N(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 h extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#X=null;#$=null;#q=this.#k.bind(this);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#G();if(this.#B(),this.#K(),this.#M(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),!this.#_)this.#_=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.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#U(),this.removeEventListener("click",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#B()}#G(){let J=Array.from(this.childNodes).filter((j)=>j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())),Q=J.find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-input-number");Z.append($,_),this.#Z=Z,this.#Q=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z);for(let j of J)if(j!==Q)_.appendChild(j)}#B(){if(!this.#Z||!this.#Q)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#D(){let J=new Set(["label","direction","size","oninput","onchange","class","style","id"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#K(){if(!this.#J)return;let J=this.#D(),Q=new Set(J);for(let Z of this.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#Y=Q}#M(){if(!this.#J)return;this.#X??=this.#N.bind(this,"input"),this.#$??=this.#N.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);if(this.#$)this.#J.removeEventListener("change",this.#$)}#N(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",h);class I extends HTMLElement{static observedAttributes=["name","open","show-reset"];static#Z=["propskit-color","propskit-number","propskit-select","propskit-slider","propskit-switch","propskit-text"].join(",");#Q=null;#J=null;#j=null;#_=new WeakMap;#Y=null;#X=0;#$=()=>this.#B();connectedCallback(){this.#f(),this.#q(),requestAnimationFrame(()=>{this.#W(),this.#T()})}disconnectedCallback(){if(this.#G(),this.#X)cancelAnimationFrame(this.#X),this.#X=0;if(this.#Q)this.#Q.removeEventListener("click",this.#K),this.#Q.removeEventListener("keydown",this.#M);this.#j?.querySelector("fig-button")?.removeEventListener("click",this.#U)}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="open"){this.#Q?.setAttribute("aria-expanded",String(this.open));return}if(J==="show-reset"){this.#O(),this.#T();return}this.#f()}get open(){let J=this.getAttribute("open");return J!==null&&J!=="false"}set open(J){let Q=this.open;if(J)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#Q?.setAttribute("aria-expanded",String(!!J)),Q!==!!J)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!J},bubbles:!0}))}get showReset(){let J=this.getAttribute("show-reset");if(J===null)return!0;return J!=="false"}set showReset(J){if(J)this.setAttribute("show-reset","true");else this.setAttribute("show-reset","false")}get dirty(){return this.hasAttribute("data-dirty")&&this.getAttribute("data-dirty")!=="false"}resetProperties(){this.#S()}#q(){if(this.removeEventListener("input",this.#$,!0),this.removeEventListener("change",this.#$,!0),this.addEventListener("input",this.#$,!0),this.addEventListener("change",this.#$,!0),!this.#Y)this.#Y=new MutationObserver(()=>{this.#W(),this.#B()});this.#Y.disconnect(),this.#Y.observe(this,{childList:!0,subtree:!0})}#G(){this.removeEventListener("input",this.#$,!0),this.removeEventListener("change",this.#$,!0),this.#Y?.disconnect()}#B(){if(this.#X)return;this.#X=requestAnimationFrame(()=>{this.#X=0,this.#W(),this.#T()})}#D(J){return J instanceof Element&&Boolean(J.closest(".propskit-group-reset, .propskit-group-reset-tooltip"))}#K=(J)=>{if(this.#D(J.target))return;J.stopPropagation(),this.open=!this.open};#M=(J)=>{if(this.#D(J.target))return;if(J.key!=="Enter"&&J.key!==" ")return;J.preventDefault(),J.stopPropagation(),this.open=!this.open};#U=(J)=>{J.preventDefault(),J.stopPropagation(),this.#S()};#N(){return[...this.querySelectorAll(I.#Z)].filter((J)=>J.closest("propskit-group")===this)}#k(J){if(J.localName==="propskit-switch")return{kind:"checked",value:Boolean(J.checked)};if("value"in J)return{kind:"value",value:J.value};return{kind:"value",value:J.getAttribute("value")??""}}#W(){for(let J of this.#N()){if(this.#_.has(J))continue;if(J.hasAttribute("default")){if(J.localName==="propskit-switch"){this.#_.set(J,{kind:"checked",value:Y(J,"default")});continue}this.#_.set(J,{kind:"value",value:J.getAttribute("default")??""});continue}this.#_.set(J,this.#k(J))}}#H(J){let Q=this.#_.get(J);if(!Q)return!1;let Z=this.#k(J);if(Q.kind==="checked")return Boolean(Z.value)!==Boolean(Q.value);return String(Z.value??"")!==String(Q.value??"")}#L(){for(let J of this.#N())if(this.#H(J))return!0;return!1}#T(){if(this.#L())this.setAttribute("data-dirty","");else this.removeAttribute("data-dirty");this.#O()}#P(J){let Q=this.#_.get(J);if(!Q)return;if(Q.kind==="checked"){J.checked=Q.value;let $={checked:Boolean(Q.value),value:J.getAttribute("value")??""};J.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,cancelable:!0,composed:!0})),J.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,cancelable:!0,composed:!0}));return}if(typeof J.resetToDefault==="function"){let $=J.getAttribute("default");if(J.setAttribute("default",String(Q.value??"")),J.resetToDefault(),$===null)J.removeAttribute("default");else J.setAttribute("default",$);return}J.value=Q.value;let Z=J.getAttribute?.("value")??("value"in J?J.value:Q.value);J.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,cancelable:!0,composed:!0})),J.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,cancelable:!0,composed:!0}))}#S(){this.#W();for(let J of this.#N())this.#P(J);this.#T(),this.dispatchEvent(new CustomEvent("reset",{bubbles:!0,composed:!0}))}#O(){if(!this.showReset){this.#j?.setAttribute("hidden","");return}this.#R(),this.#j?.removeAttribute("hidden")}#R(){if(!this.#Q||!this.showReset)return;let J=this.#Q.querySelector(":scope > .propskit-group-reset-tooltip");if(!J){J=document.createElement("fig-tooltip"),J.className="propskit-group-reset-tooltip",J.setAttribute("text","Reset properties");let Q=document.createElement("fig-button");Q.className="propskit-group-reset",Q.setAttribute("variant","ghost"),Q.setAttribute("icon",""),Q.setAttribute("aria-label","Reset properties");let Z=document.createElement("fig-icon");Z.setAttribute("name","reset"),Q.appendChild(Z),J.appendChild(Q),this.#Q.appendChild(J),Q.addEventListener("click",this.#U)}else{let Q=J.querySelector("fig-button");Q?.removeEventListener("click",this.#U),Q?.addEventListener("click",this.#U)}this.#j=J}#f(){let Q=this.getAttribute("name")||"Group",Z=this.querySelector(":scope > fig-header");if(Z)this.#Q=Z;else if(!this.#Q||!this.#Q.dataset.generated)this.#Q=document.createElement("fig-header"),this.#Q.setAttribute("borderless",""),this.#Q.dataset.generated="true",this.prepend(this.#Q);let $=this.#Q.querySelector("h3");if(!$)$=document.createElement("h3"),this.#Q.prepend($);if(!$.id)$.id=v("propskit-group");if(this.#Q.dataset.generated){let _=$.querySelector(".propskit-group-chevron");if($.textContent=Q,_)$.prepend(_)}if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",$.id);if(!$.querySelector(".propskit-group-chevron")){let _=document.createElement("fig-icon");_.setAttribute("name","chevron"),_.setAttribute("size","small"),_.className="propskit-group-chevron",$.prepend(_)}if(this.#J=$.querySelector(".propskit-group-chevron"),this.#O(),this.#Q.removeEventListener("click",this.#K),this.#Q.addEventListener("click",this.#K),this.#Q.setAttribute("role","button"),this.#Q.setAttribute("tabindex","0"),this.#Q.setAttribute("aria-expanded",String(this.open)),this.#Q.removeEventListener("keydown",this.#M),this.#Q.addEventListener("keydown",this.#M),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#Q.setAttribute("aria-expanded","false")}}customElements.define("propskit-group",I);class g extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#X=0;#$=0;#q=null;#G=null;#B=0;#D=null;#K=!1;#M=0;#U=null;#N=0;#k=null;#W=null;#H=null;#L=this.#o.bind(this);#T=this.#u.bind(this);#P=this.#jJ.bind(this);#S=this.#i.bind(this);#O=this.#s.bind(this);#R=this.#r.bind(this);#f=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.#Z)this.#z();if(this.#C(),this.#F(),this.#JJ(),this.#A(),this.removeEventListener("pointerdown",this.#L,{capture:!0}),this.addEventListener("pointerdown",this.#L,{capture:!0,passive:!0}),this.removeEventListener("contextmenu",this.#O),this.addEventListener("contextmenu",this.#O),!this.#_)this.#_=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J)if($.type==="attributes"){if($.attributeName&&this.#f.has($.attributeName))continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#C();if(Z)this.#F(),this.#A()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){if(this.#_?.disconnect(),this.#X)cancelAnimationFrame(this.#X),this.#X=0;if(this.#$)cancelAnimationFrame(this.#$),this.#$=0;this.#a(),this.#I(),this.#y(),this.#l(),this.#c(),this.removeEventListener("pointerdown",this.#L,{capture:!0}),this.removeEventListener("contextmenu",this.#O),this.#G?.removeEventListener("change",this.#R)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#C()}#z(){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.#x()){let X=this.getAttribute(j);_.setAttribute(j,X??"")}Z.append($,_),this.#Z=Z,this.#Q=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z),this.#b();for(let j of J){if(j===Q)continue;this.#J.appendChild(j)}}#b(){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.#R),this.#G=J,this.appendChild(J)}#C(){if(!this.#Z||!this.#Q)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()===""){if(this.#Q.parentElement===this.#Z)this.#Q.remove()}else{if(!this.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#F(){if(!this.#J)return;let J=this.#x(),Q=new Set(J.filter(($)=>$!=="text"));for(let $ of this.#Y)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.#Y=Q,this.#E()}#x(){let J=new Set(["label","direction","oninput","onchange","steppers"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!this.#f.has(Q))}#E(){if(this.#X)cancelAnimationFrame(this.#X);this.#X=requestAnimationFrame(()=>{this.#X=0,this.#m(),this.#w()})}#A(){if(this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{this.#$=0,this.#w()})}#w(){let J=this.#J?.querySelector('input[type="range"]'),Q=this.#J?.querySelector("fig-input-number input");if(J!==this.#q)this.#g(J);J?.removeAttribute("tabindex"),Q?.setAttribute("tabindex","-1")}#g(J){if(this.#l(),this.#q=J,!this.#q)return;this.#q.addEventListener("dblclick",this.#S,{capture:!0})}#l(){if(!this.#q)return;this.#q.removeEventListener("dblclick",this.#S,{capture:!0}),this.#q=null}#i(J){J.preventDefault(),J.stopImmediatePropagation(),this.#_J()}#o(J){if(J.button!==0||Y(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.#I(),this.#y(),this.#q=Q,this.#K=!0,this.#k=J.pointerId,this.#M=this.#e();let Z=Q.getBoundingClientRect(),$=this.getBoundingClientRect();this.#U={left:Z.left,right:Z.right,width:Z.width},this.#N=$.width,window.addEventListener("pointermove",this.#T,{passive:!0}),window.addEventListener("pointerup",this.#P,{once:!0}),window.addEventListener("pointercancel",this.#P,{once:!0}),window.addEventListener("blur",this.#P,{once:!0})}#u(J){if(!this.#K)return;if(J.pointerId!==this.#k)return;if(J.buttons===0){this.#jJ(J);return}this.#$J(J.clientX)}#jJ(J){if(J?.pointerId!==void 0&&this.#k!==null&&J.pointerId!==this.#k)return;this.#I(),this.#y()}#I(){window.removeEventListener("pointermove",this.#T),window.removeEventListener("pointerup",this.#P),window.removeEventListener("pointercancel",this.#P),window.removeEventListener("blur",this.#P),this.#K=!1,this.#k=null}#s(J){if(Y(this,"disabled"))return;J.preventDefault(),J.stopPropagation(),J.stopImmediatePropagation(),this.#a(),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.#G?.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.#_J()}#a(){if(this.#B)clearTimeout(this.#B),this.#B=0;this.#D=null}#e(){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}#$J(J){let Q=this.#U;if(!Q||!this.#M){this.#y();return}let Z=J<Q.left?J-Q.left:J>Q.right?J-Q.right:0;if(!Z){this.#n();return}let $=Math.max(-this.#M,Math.min(this.#M,Z*0.5)),_=Math.abs($),j=this.#N?(this.#N+_)/this.#N: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")}#y(){this.#n(),this.#M=0,this.#U=null,this.#N=0,this.#k=null}#n(){this.removeAttribute("data-elastic-dragging"),this.style.removeProperty("--propskit-slider-elastic-size"),this.style.removeProperty("--propskit-slider-elastic-scale")}#YJ(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),X=Q.step==="any"?0:Number(Q.step||1),G=_+(j-_)*$;if(!X)return String(G);let q=Math.round((G-_)/X)*X+_,B=Math.max(0,`${X}`.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"}#_J(){this.#a(),this.#h(this.#p(),"input"),this.#h(this.#p(),"change")}#h(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}))}#m(){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.#t.bind(this,"input");if(!this.#H)this.#H=this.#t.bind(this,"change");this.#J.addEventListener("input",this.#W),this.#J.addEventListener("change",this.#H)}#c(){if(!this.#J)return;if(this.#W)this.#J.removeEventListener("input",this.#W);if(this.#H)this.#J.removeEventListener("change",this.#H)}#t(J,Q){if(Q.stopImmediatePropagation(),J==="change")this.#y();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.#_J()}}customElements.define("propskit-slider",g);class m extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping"];#Z=50;#Q=50;#J=75;#j=75;#_=0;#Y=!1;#X=0;#$=null;#q=null;#G=null;#B=null;#D=null;#K=null;#M=null;#U=null;#N=null;#k=!1;#W=!1;#H=!1;#L=!1;#T=null;#P="";#S="";#O=null;#R=null;#f=null;#z="";#b="";#C=null;get#F(){return this.getAttribute("type")||"point"}get#x(){return this.#F==="point-radius"||this.#F==="point-radius-angle"}get#E(){return this.#F==="point-radius-angle"}get#A(){return this.#F==="point-point"}get#w(){return this.#F==="point-radius-angle"||this.#F==="point-point"}get#g(){let J=this.getAttribute("tooltips");return J===null||J!=="false"}get#l(){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.#l;if(Q==="true")return!0;if(Q==="modifier")return!!J;return!1}get#o(){let J=this.getAttribute("name");if(J)return J.split(",")[0].trim();return`${Math.round(this.#Z)}%, ${Math.round(this.#Q)}%`}get#u(){let J=this.getAttribute("name");if(J){let Q=J.split(",");if(Q.length>1)return Q[1].trim()}return`${Math.round(this.#J)}%, ${Math.round(this.#j)}%`}get#jJ(){return this.getAttribute("drag-surface")||"parent"}get#I(){let J=this.#jJ;if(J==="parent")return this.parentElement;return this.closest(J)}get#s(){let J=this.#jJ;if(J==="parent"){let Q=this.parentElement;if(Q)return Q.setAttribute("data-fig-canvas-control-surface",""),"[data-fig-canvas-control-surface]"}return J}#XJ(J){if(this.#Y)return this.#_/100*J;return this.#_}#r(){if(this.#Y)return`Radius ${Math.round(this.#_)}%`;return`Radius ${Math.round(this.#_)}`}connectedCallback(){this.#a(),this.#e()}disconnectedCallback(){this.#OJ(),this.#n(),this.#h(),document.body.classList.remove("fig-lab-move-active"),document.body.classList.remove("fig-lab-rotate-active")}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"&&!this.#k&&!this.#W&&!this.#H&&!this.#L)if(this.#a(),this.#$)this.#v();else this.#e();if(J==="type")this.#a(),this.#e();if(J==="color"&&this.#$)if(Z)this.#$.setAttribute("color",Z);else this.#$.removeAttribute("color");if(J==="disabled")this.#e();if(J==="tooltips")this.#e();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.#o);if(this.#M)this.#M.setAttribute("text",this.#u)}}#a(){let J=this.getAttribute("value");if(!J)return;try{let Q=JSON.parse(J);if(typeof Q.x==="number")this.#Z=Q.x;if(typeof Q.y==="number")this.#Q=Q.y;if(Q.radius!==void 0){let Z=String(Q.radius);if(Z.endsWith("%"))this.#Y=!0,this.#_=parseFloat(Z);else this.#Y=!1,this.#_=parseFloat(Z);if(!Number.isFinite(this.#_))this.#_=0}if(typeof Q.angle==="number")this.#X=Q.angle;if(typeof Q.x2==="number")this.#J=Q.x2;if(typeof Q.y2==="number")this.#j=Q.y2}catch{}}get value(){let J={x:this.#Z,y:this.#Q};if(this.#F==="color"){let Q=this.getAttribute("color")||this.#$?.getAttribute("color");if(Q)J.color=Q}if(this.#x)J.radius=this.#Y?`${this.#_}%`:this.#_;if(this.#E)J.angle=this.#X;if(this.#A)J.x2=this.#J,J.y2=this.#j;return J}set value(J){if(typeof J==="object")this.setAttribute("value",JSON.stringify(J));else if(typeof J==="string")this.setAttribute("value",J)}#e(){this.innerHTML="",this.#$=null,this.#q=null,this.#G=null,this.#B=null,this.#D=null,this.#K=null,this.#M=null,this.#U=null,this.#N=null;let J=Y(this,"disabled"),Q=this.#F,Z=this.#g,$=this.#s,_=document.createElement("fig-handle");if(_.setAttribute("drag","true"),_.setAttribute("drag-surface",$),_.setAttribute("drag-axes","x,y"),_.setAttribute("drag-snapping",this.#l),_.setAttribute("value",`${this.#Z}% ${this.#Q}%`),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.#A)_.setAttribute("hit-area","12 circle"),_.setAttribute("hit-area-mode","delegate");if(this.#$=_,this.#x)this.#NJ();if(this.#w)this.#MJ();if(Z){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#o),j.appendChild(_),this.appendChild(j),this.#K=j}else this.appendChild(_);if(this.#E)this.#d(J,Z,$);if(this.#A)this.#TJ(J,Z,$);this.#$J(this.#$),this.#$J(this.#G),this.#$J(this.#q),this.#zJ(),this.#c(),requestAnimationFrame(()=>this.#v())}#$J(J){if(!J)return;J.addEventListener("pointerdown",(Q)=>{if(Q.target?.classList?.contains("fig-handle-hit-area")&&J.querySelector(".fig-handle-hit-area"))this.#_J(Q,J);else this.#y(Q)},{capture:!0})}#y(J){if(Y(this,"disabled"))return;if(J?.button!==void 0&&J.button!==0)return;if(J?.isPrimary===!1)return;if(this.#T===null)this.#P=document.body.style.getPropertyValue("cursor"),this.#S=document.body.style.getPropertyPriority("cursor");if(this.#T=J?.pointerId??-1,document.body.classList.add("fig-lab-move-active"),document.body.style.setProperty("cursor","var(--fig-lab-cursor-move)","important"),!this.#O)this.#O=(Q)=>{if(Q?.pointerId!==void 0&&this.#T!==null&&Q.pointerId!==this.#T)return;if(Q?.type==="blur")this.#n();else requestAnimationFrame(()=>this.#n())};window.addEventListener("pointerup",this.#O),window.addEventListener("pointercancel",this.#O),window.addEventListener("blur",this.#O)}#n(){if(this.#T===null)return;if(document.body.classList.remove("fig-lab-move-active"),this.#P)document.body.style.setProperty("cursor",this.#P,this.#S);else document.body.style.removeProperty("cursor");if(this.#T=null,this.#P="",this.#S="",this.#O)window.removeEventListener("pointerup",this.#O),window.removeEventListener("pointercancel",this.#O),window.removeEventListener("blur",this.#O)}#YJ(J){if(!J)return 0;if(J===this.#G)return this.#X;if(!this.#A)return 0;let Q=this.#kJ();return J===this.#$?Q+180:Q}#p(){if(this.#R===null)return;let J=this.#KJ(this.#YJ(this.#f));document.body.style.setProperty("--fig-lab-cursor-rotate",J),document.body.style.setProperty("cursor",J,"important")}#_J(J,Q){if(Y(this,"disabled"))return;if(J?.button!==void 0&&J.button!==0)return;if(J?.isPrimary===!1)return;if(this.#R===null)this.#z=document.body.style.getPropertyValue("cursor"),this.#b=document.body.style.getPropertyPriority("cursor");if(this.#R=J?.pointerId??-1,this.#f=Q,document.body.classList.add("fig-lab-rotate-active"),this.#p(),!this.#C)this.#C=(Z)=>{if(Z?.pointerId!==void 0&&this.#R!==null&&Z.pointerId!==this.#R)return;if(Z?.type==="blur")this.#h();else requestAnimationFrame(()=>this.#h())};window.addEventListener("pointerup",this.#C),window.addEventListener("pointercancel",this.#C),window.addEventListener("blur",this.#C)}#h(){if(this.#R===null)return;if(document.body.classList.remove("fig-lab-rotate-active"),document.body.style.removeProperty("--fig-lab-cursor-rotate"),this.#z)document.body.style.setProperty("cursor",this.#z,this.#b);else document.body.style.removeProperty("cursor");if(this.#R=null,this.#f=null,this.#z="",this.#b="",this.#C)window.removeEventListener("pointerup",this.#C),window.removeEventListener("pointercancel",this.#C),window.removeEventListener("blur",this.#C)}#m(J,Q,Z,$){if(!J)return;let _=()=>!!$?.(),j=()=>{let q=Q();if(!q)return;q.removeAttribute("show"),q.hidePopup?.()},X=()=>{if(_()){j();return}let q=Q();if(!q)return;if(Z)q.setAttribute("text",Z());q.setAttribute("show","true"),q.showPopup?.()},G=()=>{j()};J.addEventListener("pointerenter",X),J.addEventListener("pointerleave",G)}#JJ(){return this.#k||this.#W||this.#H||this.#L}#c(){if(this.#$)this.#m(this.#$,()=>this.#K,()=>this.#o,()=>this.#JJ()||!!this.#$?.querySelector("fig-color-tip"));if(this.#G)this.#m(this.#G,()=>this.#N,()=>`Angle ${Math.round(this.#X)}°`,()=>this.#JJ());if(this.#q)this.#m(this.#q,()=>this.#M,()=>this.#u,()=>this.#JJ());if(this.#B){let J=this.#B.querySelector(".fig-canvas-control-radius-hit");this.#BJ(J||this.#B)}if(this.#F==="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})}#t(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?.()}#BJ(J){if(!J)return;J.addEventListener("pointerenter",(Q)=>{let Z=this.#U;if(!Z)return;Z.setAttribute("text",this.#r()),Z.setAttribute("show","true"),Z.showPopup?.(),this.#t(Q.clientX,Q.clientY)}),J.addEventListener("pointermove",(Q)=>{if(this.#H)return;this.#t(Q.clientX,Q.clientY)}),J.addEventListener("pointerleave",()=>{if(this.#H)return;let Q=this.#U;if(!Q)return;Q.removeAttribute("show")})}#NJ(){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.#g){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#r()),j.appendChild(Q),this.appendChild(j),this.#U=j}else this.appendChild(Q);this.#PJ(Z)}#MJ(){let Q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(Q.classList.add("fig-canvas-control-angle-svg"),Q.setAttribute("overflow","visible"),Q.style.position="absolute",Q.style.pointerEvents="none",this.#A){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.#FJ(_)}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.#D=Q,this.appendChild(Q)}#FJ(J){J.addEventListener("pointerdown",(Q)=>{if(Y(this,"disabled"))return;Q.preventDefault(),Q.stopPropagation();let Z=this.#I;if(!Z)return;let $=Z.getBoundingClientRect(),_=Q.clientX,j=Q.clientY,X=this.#Z,G=this.#Q,q=this.#J,B=this.#j;this.#k=!0,this.#W=!0,document.body.classList.add("fig-lab-move-active"),J.style.pointerEvents="none";let N=(U)=>{let M=Z.getBoundingClientRect(),W=M.width>0?(U.clientX-_)/M.width*100:0,k=M.height>0?(U.clientY-j)/M.height*100:0,D=-Math.min(X,q),P=100-Math.max(X,q),T=-Math.min(G,B),F=100-Math.max(G,B),H=Math.max(D,Math.min(P,W)),z=Math.max(T,Math.min(F,k));this.#Z=X+H,this.#Q=G+z,this.#J=q+H,this.#j=B+z,this.#v(),this.#QJ()},K=()=>{document.body.classList.remove("fig-lab-move-active"),J.style.pointerEvents="stroke",this.#V(),this.#ZJ(),window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",K),requestAnimationFrame(()=>{this.#k=!1,this.#W=!1})};window.addEventListener("pointermove",N),window.addEventListener("pointerup",K)})}#d(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.#G=$,Q){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",`${Math.round(this.#X)}°`),_.appendChild($),this.appendChild(_),this.#N=_}else this.appendChild($)}#TJ(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.#l),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),$.setAttribute("value",`${this.#J}% ${this.#j}%`),J)$.setAttribute("disabled","");if(this.#q=$,Q){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#u),_.appendChild($),this.appendChild(_),this.#M=_}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`}#KJ(J){return`url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 32 32' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform='rotate(${Math.round(J-45)} 16 16)'%3E%3Cg filter='url(%23f)'%3E%3Cpath d='M12.5607 22.4393L12.0216 21.9002C17.1558 21.2216 21.2216 17.1558 21.9002 12.0216L22.4393 12.5607C23.0251 13.1464 23.9749 13.1464 24.5607 12.5607C25.1464 11.9749 25.1464 11.0251 24.5607 10.4393L21.5607 7.43934C20.9749 6.85355 20.0251 6.85355 19.4393 7.43934L16.4393 10.4393C15.8536 11.0251 15.8536 11.9749 16.4393 12.5607C17.0251 13.1464 17.9749 13.1464 18.5607 12.5607L18.8056 12.3157C18.1013 15.5527 15.5527 18.1013 12.3157 18.8056L12.5607 18.5607C13.1464 17.9749 13.1464 17.0251 12.5607 16.4393C11.9749 15.8536 11.0251 15.8536 10.4393 16.4393L7.43934 19.4393C6.85356 20.0251 6.85356 20.9749 7.43934 21.5607L10.4393 24.5607C11.0251 25.1464 11.9749 25.1464 12.5607 24.5607C13.1464 23.9749 13.1464 23.0251 12.5607 22.4393Z' fill='white'/%3E%3C/g%3E%3Cpath d='M23.8536 11.8536C23.6583 12.0488 23.3417 12.0488 23.1464 11.8536L21 9.70711V10.5C21 16.299 16.299 21 10.5 21H9.70711L11.8536 23.1464C12.0488 23.3417 12.0488 23.6583 11.8536 23.8536C11.6583 24.0488 11.3417 24.0488 11.1464 23.8536L8.14645 20.8536C7.95119 20.6583 7.95119 20.3417 8.14645 20.1464L11.1464 17.1464C11.3417 16.9512 11.6583 16.9512 11.8536 17.1464C12.0488 17.3417 12.0488 17.6583 11.8536 17.8536L9.70711 20H10.5C15.7467 20 20 15.7467 20 10.5V9.70711L17.8536 11.8536C17.6583 12.0488 17.3417 12.0488 17.1464 11.8536C16.9512 11.6583 16.9512 11.3417 17.1464 11.1464L20.1464 8.14645C20.3417 7.95119 20.6583 7.95119 20.8536 8.14645L23.8536 11.1464C24.0488 11.3417 24.0488 11.6583 23.8536 11.8536Z' fill='black'/%3E%3C/g%3E%3Cdefs%3E%3Cfilter id='f' x='4' y='5' width='24' height='24' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='a'/%3E%3CfeColorMatrix in='SourceAlpha' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='b'/%3E%3CfeOffset dy='1'/%3E%3CfeGaussianBlur stdDeviation='1.5'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0'/%3E%3CfeBlend in2='a' result='c'/%3E%3CfeBlend in='SourceGraphic' in2='c'/%3E%3C/filter%3E%3C/defs%3E%3C/svg%3E") 16 16, pointer`}#LJ(J,Q){if(!J)return;J.style.setProperty("cursor",Q,"important")}#UJ(J,Q){if(!J)return;let Z=J.querySelector(".fig-handle-hit-area");if(!Z)return;if(Z.setAttribute("data-cursor","rotate"),this.#LJ(Z,this.#KJ(Q)),this.#f===J)this.#p()}#DJ(){if(!this.#G||!this.#E)return;this.#UJ(this.#G,this.#X)}#kJ(){return Math.atan2(this.#j-this.#Q,this.#J-this.#Z)*180/Math.PI}#WJ(){if(!this.#A)return;let J=this.#kJ();this.#$?.style.removeProperty("cursor"),this.#q?.style.removeProperty("cursor"),this.#UJ(this.#$,J+180),this.#UJ(this.#q,J)}#GJ(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`}#v(){let J=this.#I;if(!J||!this.#$)return;let Q=J.getBoundingClientRect();if(this.#GJ(this.#$,this.#Z,this.#Q,Q),this.#B){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,_=this.#XJ(Q.width),j=this.#B,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 q of G)q.setAttribute("cx",String(_)),q.setAttribute("cy",String(_)),q.setAttribute("r",String(Math.max(_-1,0)))}if(this.#D&&this.#w){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,_,j;if(this.#A)_=this.#J/100*Q.width,j=this.#j/100*Q.height;else{let q=this.#XJ(Q.width),B=this.#X*Math.PI/180;_=Z+q*Math.cos(B),j=$+q*Math.sin(B)}let X=this.#D;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 q of G)q.setAttribute("x1",String(Z)),q.setAttribute("y1",String($)),q.setAttribute("x2",String(_)),q.setAttribute("y2",String(j))}if(this.#G&&this.#E){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,_=this.#XJ(Q.width),j=this.#X*Math.PI/180,X=Z+_*Math.cos(j),G=$+_*Math.sin(j),q=Q.width>0?X/Q.width*100:0,B=Q.height>0?G/Q.height*100:0;this.#GJ(this.#G,q,B,Q)}if(this.#q&&this.#A)this.#GJ(this.#q,this.#J,this.#j,Q);this.#DJ(),this.#WJ()}#QJ(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#ZJ(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}#V(){this.setAttribute("value",JSON.stringify(this.value))}#zJ(){if(!this.#$)return;if(this.#$.addEventListener("input",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#QJ();return}this.#k=!0;let Q=J.detail?.px??this.#Z/100,Z=J.detail?.py??this.#Q/100;if(this.#Z=Math.round(Math.max(0,Math.min(100,Q*100))),this.#Q=Math.round(Math.max(0,Math.min(100,Z*100))),this.#K)this.#K.removeAttribute("show"),this.#K.hidePopup?.();this.#v(),this.#QJ()}),this.#$.addEventListener("change",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#ZJ();return}let Q=J.detail?.px??this.#Z/100,Z=J.detail?.py??this.#Q/100;if(this.#Z=Math.round(Math.max(0,Math.min(100,Q*100))),this.#Q=Math.round(Math.max(0,Math.min(100,Z*100))),this.#K)this.#K.removeAttribute("show");this.#v(),this.#V(),this.#ZJ(),requestAnimationFrame(()=>{this.#k=!1})}),this.#G)this.#G.addEventListener("input",(J)=>{J.stopPropagation();let Q=this.#I;if(!Q)return;this.#L=!0,this.classList.add("fig-canvas-control-ring-active");let Z=Q.getBoundingClientRect(),$=this.#Z/100*Z.width,_=this.#Q/100*Z.height,j=J.detail?.x??0,X=J.detail?.y??0,G=this.#G.offsetWidth/2,q=this.#G.offsetHeight/2,B=j+G-$,N=X+q-_,K=Math.atan2(N,B)*180/Math.PI;if(this.#i(J.detail?.shiftKey))K=Math.round(K/15)*15;this.#X=K;let U=Math.sqrt(B*B+N*N);if(this.#i(J.detail?.shiftKey)){let M=this.#Y?5:10;if(this.#Y){let W=U/Z.width*100;W=Math.round(W/M)*M,U=W/100*Z.width}else U=Math.round(U/M)*M}if(this.#Y)this.#_=Math.max(0,U/Z.width*100);else this.#_=Math.max(0,U);if(this.#N)this.#N.setAttribute("text",`Angle ${Math.round(this.#X)}°`),this.#N.setAttribute("show","true"),this.#N.showPopup?.();this.#v(),this.#QJ()}),this.#G.addEventListener("change",(J)=>{if(J.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#N)this.#N.removeAttribute("show");this.#v(),this.#V(),this.#ZJ(),requestAnimationFrame(()=>{this.#L=!1})}),this.#G.addEventListener("hitareadown",(J)=>{J.stopPropagation();let Q=J.detail?.originalEvent;if(!Q)return;Q.preventDefault();let Z=this.#I;if(!Z)return;if(this.#L=!0,this.classList.add("fig-canvas-control-ring-active"),this.#G.setAttribute("selected",""),this.#N)this.#N.setAttribute("show","true"),this.#N.showPopup?.();let $=(j)=>{let X=Z.getBoundingClientRect(),G=this.#Z/100*X.width,q=this.#Q/100*X.height,B=j.clientX-X.left-G,N=j.clientY-X.top-q,K=Math.atan2(N,B)*180/Math.PI;if(this.#i(j.shiftKey))K=Math.round(K/15)*15;if(this.#X=K,this.#N)this.#N.setAttribute("text",`Angle ${Math.round(K)}°`);this.#v(),this.#QJ()},_=()=>{if(this.#L=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#G.removeAttribute("selected"),this.#N)this.#N.removeAttribute("show");this.#V(),this.#ZJ(),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.#j/100;if(this.#J=Math.round(Math.max(0,Math.min(100,Q*100))),this.#j=Math.round(Math.max(0,Math.min(100,Z*100))),this.#M)this.#M.removeAttribute("show"),this.#M.hidePopup?.();this.#v(),this.#QJ()}),this.#q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#M)this.#M.removeAttribute("show");this.#v(),this.#V(),this.#ZJ(),requestAnimationFrame(()=>{this.#W=!1})}),this.#HJ(this.#$,!0),this.#HJ(this.#q,!1)}#HJ(J,Q){if(!J)return;J.addEventListener("hitareadown",(Z)=>{Z.stopPropagation();let $=Z.detail?.originalEvent;if(!$)return;$.preventDefault();let _=this.#I;if(!_)return;this.#k=!0;let j=_.getBoundingClientRect(),X=Q?this.#J:this.#Z,G=Q?this.#j:this.#Q,q=Q?this.#Z:this.#J,B=Q?this.#Q:this.#j,N=X/100*j.width,K=G/100*j.height,U=q/100*j.width,M=B/100*j.height,W=Math.sqrt((U-N)**2+(M-K)**2),k=Q?this.#K:this.#M;if(k)k.removeAttribute("show"),k.hidePopup?.();let D=(T)=>{let F=_.getBoundingClientRect(),H=X/100*F.width,z=G/100*F.height,O=T.clientX-F.left-H,R=T.clientY-F.top-z,C=Math.atan2(R,O);if(this.#i(T.shiftKey))C=Math.round(C*180/Math.PI/15)*15*Math.PI/180;let p=H+W*Math.cos(C),d=z+W*Math.sin(C),A=Math.max(0,Math.min(100,p/F.width*100)),V=Math.max(0,Math.min(100,d/F.height*100));if(Q)this.#Z=A,this.#Q=V;else this.#J=A,this.#j=V;this.#v(),this.#QJ()},P=()=>{if(this.#k=!1,k)k.removeAttribute("show");this.#V(),this.#ZJ(),window.removeEventListener("pointermove",D),window.removeEventListener("pointerup",P)};window.addEventListener("pointermove",D),window.addEventListener("pointerup",P)})}#PJ(J){if(!J)return;J.addEventListener("pointermove",(Z)=>{if(this.#H)return;let $=this.#I;if(!$)return;let _=$.getBoundingClientRect(),j=this.#Z/100*_.width,X=this.#Q/100*_.height,G=Math.atan2(Z.clientY-_.top-X,Z.clientX-_.left-j)*180/Math.PI;this.#LJ(J,this.#qJ(G))});let Q=(Z)=>{if(Y(this,"disabled"))return;Z.preventDefault(),Z.stopPropagation(),this.#H=!0,this.classList.add("fig-canvas-control-ring-active");let $=this.#I;if(!$)return;if(this.#U)this.#U.setAttribute("show","true"),this.#U.showPopup?.(),this.#t(Z.clientX,Z.clientY);if(this.#N)this.#N.removeAttribute("show"),this.#N.hidePopup?.();let _=this.#G?.style.pointerEvents,j=this.#G?.querySelector(".fig-handle-hit-area"),X=j?.style.pointerEvents;if(this.#G)this.#G.style.pointerEvents="none";if(j)j.style.pointerEvents="none";let G=document.body.style.cursor;J.style.pointerEvents="none";let q=$.getBoundingClientRect(),B=this.#Z/100*q.width,N=this.#Q/100*q.height,K=Math.atan2(Z.clientY-q.top-N,Z.clientX-q.left-B)*180/Math.PI,U=Math.round(K);document.body.style.cursor=this.#qJ(U);let M=(k)=>{let D=$.getBoundingClientRect(),P=this.#Z/100*D.width,T=this.#Q/100*D.height,F=k.clientX-D.left-P,H=k.clientY-D.top-T,z=Math.round(Math.atan2(H,F)*180/Math.PI);if(z!==U)U=z,document.body.style.cursor=this.#qJ(z);let O=Math.sqrt(F*F+H*H);if(this.#i(k.shiftKey)){let R=this.#Y?5:10;if(this.#Y){let C=O/D.width*100;C=Math.round(C/R)*R,O=C/100*D.width}else O=Math.round(O/R)*R}if(this.#Y)this.#_=Math.max(0,O/D.width*100);else this.#_=Math.max(0,O);if(this.#U)this.#U.setAttribute("text",this.#r()),this.#t(k.clientX,k.clientY);this.#v(),this.#QJ()},W=()=>{if(this.#H=!1,this.classList.remove("fig-canvas-control-ring-active"),J.style.pointerEvents="",this.#G)this.#G.style.pointerEvents=_??"";if(j)j.style.pointerEvents=X??"";if(document.body.style.cursor=G,this.#U)this.#U.removeAttribute("show");this.#V(),this.#ZJ(),window.removeEventListener("pointermove",M),window.removeEventListener("pointerup",W)};window.addEventListener("pointermove",M),window.addEventListener("pointerup",W)};J.addEventListener("pointerdown",Q),this._radiusDragCleanup=()=>J.removeEventListener("pointerdown",Q)}#OJ(){if(this._radiusDragCleanup)this._radiusDragCleanup(),this._radiusDragCleanup=null}}customElements.define("fig-canvas-control",m);class L extends HTMLElement{#Z=[L.#S()];#Q=0;#J=2;#j=240;#_=120;#Y={min:-1,max:1};#X=null;#$=null;#q=null;#G=null;#B=0;#D=null;#K=null;#M=null;#U=null;#N=[];#k=[];#W=[];#H=[];#L=new Set;#T=null;#P=null;static TYPES=[{name:"Wave",value:"sine"},{name:"Square",value:"square"},{name:"Sawtooth",value:"sawtooth"},{name:"Triangle",value:"triangle"}];static#S(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.#O("precision",2),this.#C(this.getAttribute("value")),this.#b(),this.#u(),this.#y()}disconnectedCallback(){if(this.#X=null,this.#c(),this.#T)this.#T.disconnect(),this.#T=null}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"){if(this.#C(Z),this.isConnected)this.#u();return}if(J==="precision"){if(this.#J=this.#O("precision",2),this.isConnected)this.#GJ();return}if(J==="aspect-ratio"){if(this.#b(),this.#$)this.#m();return}if(J==="edit"||J==="disabled"){if(this.isConnected)this.#u()}}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.#Z.map((J)=>this.#x(J))}}get preset(){let J=this.#E;return L.TYPES.find((Q)=>Q.value===J.type)?.name}#O(J,Q){let Z=Number.parseInt(this.getAttribute(J)||"",10);return Number.isFinite(Z)?Math.max(0,Math.min(100,Z)):Q}#R(J,Q=!1){let Z=this.getAttribute(J);if(Z===null)return Q;let $=Z.trim().toLowerCase();if($===""||$==="true")return!0;if($==="false")return!1;return!0}#f(){return this.getAttribute("edit")!=="false"}#z(){return this.#R("disabled",!1)}#b(){let J=this.getAttribute("aspect-ratio")||"2 / 1";this.style.setProperty("--aspect-ratio",J)}#C(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.#Z=Z.map(($)=>this.#F($)),!this.#Z.length)this.#Z=[L.#S()];return this.#Q=Math.min(this.#Q,this.#Z.length-1),!0}#F(J={}){return{type:this.#A(J.type),frequency:this.#w(J.frequency,1,0.1,16),amplitude:this.#w(J.amplitude,1,-4,4),phase:this.#w(J.phase,0,-360,360),offset:this.#w(J.offset,0,-4,4)}}#x(J){return{type:J.type,frequency:this.#g(J.frequency),amplitude:this.#g(J.amplitude),phase:this.#g(J.phase),offset:this.#g(J.offset)}}get#E(){if(!this.#Z[this.#Q])this.#Q=0;return this.#Z[this.#Q]||L.#S()}#A(J){let Q=String(J||"").toLowerCase();return L.TYPES.some((Z)=>Z.value===Q)?Q:"sine"}#w(J,Q,Z,$){let _=Number.parseFloat(J);if(!Number.isFinite(_))return Q;return Math.min($,Math.max(Z,_))}#g(J){let Q=10**this.#J;return Math.round(J*Q)/Q}static#l(J){return String(J).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}static#i(J){return L.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,q=L.#o(J,G),B=5+G*_,N=5+(1-(q+1)/2)*_;j+=`${X===0?"M":"L"}${B.toFixed(1)},${N.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)}}#u(){this.#c(),this.innerHTML=this.#jJ(),this.#a(),this.#n(),this.#m(),this.#FJ(),this.#JJ()}#jJ(){let J=this.#z()?" disabled":"";return`<div class="propskit-oscillator-svg-container">
|
|
2
|
-
<svg viewBox="0 0 ${this.#
|
|
3
|
-
<rect class="propskit-oscillator-bounds" x="0" y="0" width="${this.#
|
|
1
|
+
function z(J,Q){if(!customElements.get(J))customElements.define(J,Q)}function M(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}var x=0;function i(J="fig-lab"){return x+=1,`${J}-${x}`}class g extends HTMLElement{#Z=null;#Q=null;#J=null;#B=!1;#_=null;#P=new Set;#X=null;#$=null;#j=this.#O.bind(this);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#G();if(this.#Y(),this.#k(),this.#N(),this.removeEventListener("click",this.#j),this.addEventListener("click",this.#j),!this.#_)this.#_=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.#Y();if(Z)this.#k()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#U(),this.removeEventListener("click",this.#j)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#Y()}#G(){let Q=Array.from(this.childNodes).filter((Y)=>Y.nodeType!==Node.TEXT_NODE||Boolean(Y.textContent?.trim())).find((Y)=>Y.nodeType===Node.ELEMENT_NODE&&Y.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),j=document.createElement("fig-segmented-control"),_=document.createElement("fig-segment"),X=document.createElement("fig-segment");j.setAttribute("sizing","equal"),_.setAttribute("value","off"),_.textContent="Off",X.setAttribute("value","on"),X.textContent="On",j.append(_,X),Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#B=Boolean(Q),this.replaceChildren(Z)}#Y(){if(!this.#Z||!this.#Q)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#B)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#M(){let J=new Set(["label","direction","size","oninput","onchange","class","style","id","checked","value"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#k(){if(!this.#J)return;let J=this.#M(),Q=new Set(J);for(let Z of this.#P)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#J.setAttribute("value",M(this,"checked")?"on":"off"),this.#P=Q}#N(){if(!this.#J)return;this.#X??=this.#q.bind(this,"input"),this.#$??=this.#q.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);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}))}#O(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":M(this,"checked")}set checked(J){let Q=Boolean(J);if(this.toggleAttribute("checked",Q),this.#J)this.#J.value=Q?"on":"off"}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)}}z("propskit-switch",g);class m extends HTMLElement{#Z=null;#Q=null;#J=null;#B=!1;#_=null;#P=new Set;#X=null;#$=null;#j=this.#S.bind(this);#G=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#Y();if(this.#M(),this.#N(),this.#U(),this.#G===null)this.#G=this.getAttribute("default")??this.getAttribute("value")??"";if(this.removeEventListener("click",this.#j),this.addEventListener("click",this.#j),!this.#_)this.#_=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.#M();if(Z)this.#N()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#q(),this.removeEventListener("click",this.#j)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#M()}#Y(){let J=Array.from(this.childNodes).filter((_)=>_.nodeType!==Node.TEXT_NODE||Boolean(_.textContent?.trim())),Q=J.find((_)=>_.nodeType===Node.ELEMENT_NODE&&_.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),j=document.createElement("fig-input-color");for(let _ of J)if(_!==Q)j.appendChild(_);Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#B=Boolean(Q),this.replaceChildren(Z)}#M(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#B)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Color")}#k(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","text","default"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#N(){if(!this.#J)return;let J=this.#k(),Q=new Set(J);for(let Z of this.#P)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J){let $=this.getAttribute(Z)??"";if(Z==="value"&&this.#J.getAttribute("value")===$)continue;this.#J.setAttribute(Z,$)}this.#J.setAttribute("text","true"),this.#P=Q}#U(){if(!this.#J)return;this.#X??=this.#L.bind(this,"input"),this.#$??=this.#L.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#q(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);if(this.#$)this.#J.removeEventListener("change",this.#$)}#O(J){let Q=J instanceof CustomEvent&&J.detail!==void 0?J.detail:void 0;if(typeof Q==="string"&&Q)return Q;if(Q&&typeof Q==="object"){if(typeof Q.value==="string"&&Q.value)return Q.value;if(typeof Q.hex==="string"&&Q.hex)return Q.hex;if(typeof Q.color==="string"&&Q.color)return Q.color}if(typeof this.#J?.value==="string"&&this.#J.value)return this.#J.value;return this.#J?.getAttribute("value")??""}#L(J,Q){Q.stopImmediatePropagation();let Z=this.#O(Q);if(this.setAttribute("value",Z),this.#J&&this.#J.getAttribute("value")!==Z)this.#J.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}))}#S(J){if(J.target instanceof Element&&J.target.closest("fig-input-color"))return;this.focus()}get value(){return this.getAttribute("value")??this.#J?.value??this.#J?.getAttribute("value")??""}set value(J){if(J===null||J===void 0||J===""){this.removeAttribute("value"),this.#J?.removeAttribute("value");return}let Q=String(J);if(this.setAttribute("value",Q),this.#J&&this.#J.getAttribute("value")!==Q)this.#J.setAttribute("value",Q)}#z(J){if(!this.#J)return;if(this.#J.getAttribute("value")===J)this.#J.removeAttribute("value");this.#J.setAttribute("value",J)}#K(){return this.getAttribute("default")??this.#G??""}resetToDefault(){let J=String(this.#K());this.setAttribute("value",J),this.#z(J),this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,cancelable:!0,composed:!0}))}focus(J){this.#J?.querySelector("input:not([tabindex='-1'])")?.focus(J)}}z("propskit-color",m);class u extends HTMLElement{#Z=null;#Q=null;#J=null;#B=!1;#_=null;#P=new Set;#X=null;#$=null;#j=this.#K.bind(this);#G=this.#z.bind(this);#Y=!1;static get observedAttributes(){return["label","direction","aria-label","options","value"]}connectedCallback(){if(!this.#Z)this.#M();if(this.#k(),this.#U(),this.#q(),this.removeEventListener("click",this.#j),this.addEventListener("click",this.#j),this.removeEventListener("pointerdown",this.#G,!0),this.addEventListener("pointerdown",this.#G,!0),!this.#_)this.#_=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;let j=$.attributeName;if(j==="label"||j==="direction"||j==="aria-label")Q=!0;else Z=!0}if(Q)this.#k();if(Z)this.#U()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#O(),this.removeEventListener("click",this.#j),this.removeEventListener("pointerdown",this.#G,!0)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label"){this.#k();return}if(J==="options"||J==="value")this.#U()}#M(){let J=this.querySelector(":scope > label"),Q=document.createElement("fig-field"),Z=J||document.createElement("label"),$=document.createElement("fig-select");$.setAttribute("full",""),Q.append(Z,$),this.#Z=Q,this.#Q=Z,this.#J=$,this.#B=Boolean(J),this.replaceChildren(Q)}#k(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#B)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Select"),this.#J.setAttribute("full","")}#N(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","full"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#U(){if(!this.#J)return;let J=this.#N().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.#P)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#P=Q}#q(){if(!this.#J)return;this.#X??=this.#L.bind(this,"input"),this.#$??=this.#L.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#O(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);if(this.#$)this.#J.removeEventListener("change",this.#$)}#L(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}))}#S(){if(!this.#J)return!1;if(this.#J.open)return!0;let J=this.#J.shadowRoot?.querySelector('dialog[is="fig-popup"]');return Boolean(J?.open||J?.matches?.(":open"))}#z(J){if(!(J.target instanceof Element))return;if(J.target.closest("fig-select")){this.#Y=!1;return}this.#Y=this.#S()}#K(J){if(J.target instanceof Element&&J.target.closest("fig-select")){this.#Y=!1;return}if(!this.#J||M(this.#J,"disabled")){this.#Y=!1;return}if(this.#J.focus(),this.#Y||this.#S()){this.#Y=!1,this.#J.open=!1;return}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)}}z("propskit-select",u);class c extends HTMLElement{#Z=null;#Q=null;#J=null;#B=!1;#_=null;#P=new Set;#X=null;#$=null;#j=this.#O.bind(this);static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#G();if(this.#Y(),this.#k(),this.#N(),this.removeEventListener("click",this.#j),this.addEventListener("click",this.#j),!this.#_)this.#_=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.#Y();if(Z)this.#k()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#U(),this.removeEventListener("click",this.#j)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#Y()}#G(){let J=Array.from(this.childNodes).filter((_)=>_.nodeType!==Node.TEXT_NODE||Boolean(_.textContent?.trim())),Q=J.find((_)=>_.nodeType===Node.ELEMENT_NODE&&_.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),j=document.createElement("fig-input-text");for(let _ of J)if(_!==Q)j.appendChild(_);Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#B=Boolean(Q),this.replaceChildren(Z)}#Y(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#B)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Text")}#M(){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.#M(),Q=new Set(J);for(let Z of this.#P)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#P=Q}#N(){if(!this.#J)return;this.#X??=this.#q.bind(this,"input"),this.#$??=this.#q.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);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}))}#O(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){if(this.removeAttribute("value"),this.#J)this.#J.value=""}else{let Q=String(J);if(this.setAttribute("value",Q),this.#J)this.#J.value=Q}}focus(J){this.#J?.focus(J)}}z("propskit-text",c);class v extends HTMLElement{#Z=null;#Q=null;#J=null;#B=!1;#_=null;#P=new Set;#X=null;#$=null;#j=this.#O.bind(this);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#G();if(this.#Y(),this.#k(),this.#N(),this.removeEventListener("click",this.#j),this.addEventListener("click",this.#j),!this.#_)this.#_=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.#Y();if(Z)this.#k()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#U(),this.removeEventListener("click",this.#j)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#Y()}#G(){let J=Array.from(this.childNodes).filter((_)=>_.nodeType!==Node.TEXT_NODE||Boolean(_.textContent?.trim())),Q=J.find((_)=>_.nodeType===Node.ELEMENT_NODE&&_.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),j=document.createElement("fig-input-number");Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#B=Boolean(Q),this.replaceChildren(Z);for(let _ of J)if(_!==Q)j.appendChild(_)}#Y(){if(!this.#Z||!this.#Q)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#B)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#M(){let J=new Set(["label","direction","size","oninput","onchange","class","style","id"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#k(){if(!this.#J)return;let J=this.#M(),Q=new Set(J);for(let Z of this.#P)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#P=Q}#N(){if(!this.#J)return;this.#X??=this.#q.bind(this,"input"),this.#$??=this.#q.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);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}))}#O(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===""){if(this.removeAttribute("value"),this.#J)this.#J.value=""}else{let Q=String(J);if(this.setAttribute("value",Q),this.#J)this.#J.value=Q}}focus(J){this.#J?.focus(J)}}z("propskit-number",v);class b extends HTMLElement{static observedAttributes=["name","open","show-reset"];static#Z=["propskit-color","propskit-number","propskit-select","propskit-slider","propskit-switch","propskit-text"].join(",");#Q=null;#J=null;#B=null;#_=null;#P=new WeakMap;#X=null;#$=0;#j=()=>this.#M();connectedCallback(){this.#R(),this.#G(),requestAnimationFrame(()=>{this.#L(),this.#K()})}disconnectedCallback(){if(this.#Y(),this.#$)cancelAnimationFrame(this.#$),this.#$=0;this.#J?.removeEventListener("click",this.#N),this.#_?.querySelector("fig-button")?.removeEventListener("click",this.#U)}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="open"){this.#J?.setAttribute("aria-expanded",String(this.open));return}if(J==="show-reset"){this.#T(),this.#K();return}this.#R()}get open(){let J=this.getAttribute("open");return J!==null&&J!=="false"}set open(J){let Q=this.open;if(J)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#J?.setAttribute("aria-expanded",String(!!J)),Q!==!!J)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!J},bubbles:!0}))}get showReset(){let J=this.getAttribute("show-reset");if(J===null)return!0;return J!=="false"}set showReset(J){if(J)this.setAttribute("show-reset","true");else this.setAttribute("show-reset","false")}get dirty(){return this.hasAttribute("data-dirty")&&this.getAttribute("data-dirty")!=="false"}resetProperties(){this.#C()}#G(){if(this.removeEventListener("input",this.#j,!0),this.removeEventListener("change",this.#j,!0),this.addEventListener("input",this.#j,!0),this.addEventListener("change",this.#j,!0),!this.#X)this.#X=new MutationObserver(()=>{this.#L(),this.#M()});this.#X.disconnect(),this.#X.observe(this,{childList:!0,subtree:!0})}#Y(){this.removeEventListener("input",this.#j,!0),this.removeEventListener("change",this.#j,!0),this.#X?.disconnect()}#M(){if(this.#$)return;this.#$=requestAnimationFrame(()=>{this.#$=0,this.#L(),this.#K()})}#k(J){return J instanceof Element&&Boolean(J.closest(".propskit-group-reset, .propskit-group-reset-tooltip"))}#N=(J)=>{if(this.#k(J.target))return;J.stopPropagation(),this.open=!this.open};#U=(J)=>{J.preventDefault(),J.stopPropagation(),this.#C()};#q(){return[...this.querySelectorAll(b.#Z)].filter((J)=>J.closest("propskit-group")===this)}#O(J){if(J.localName==="propskit-switch")return{kind:"checked",value:Boolean(J.checked)};if("value"in J)return{kind:"value",value:J.value};return{kind:"value",value:J.getAttribute("value")??""}}#L(){for(let J of this.#q()){if(this.#P.has(J))continue;if(J.hasAttribute("default")){if(J.localName==="propskit-switch"){this.#P.set(J,{kind:"checked",value:M(J,"default")});continue}this.#P.set(J,{kind:"value",value:J.getAttribute("default")??""});continue}this.#P.set(J,this.#O(J))}}#S(J){let Q=this.#P.get(J);if(!Q)return!1;let Z=this.#O(J);if(Q.kind==="checked")return Boolean(Z.value)!==Boolean(Q.value);return String(Z.value??"")!==String(Q.value??"")}#z(){for(let J of this.#q())if(this.#S(J))return!0;return!1}#K(){if(this.#z())this.setAttribute("data-dirty","");else this.removeAttribute("data-dirty");this.#T()}#H(J){let Q=this.#P.get(J);if(!Q)return;if(Q.kind==="checked"){J.checked=Q.value;let $={checked:Boolean(Q.value),value:J.getAttribute("value")??""};J.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,cancelable:!0,composed:!0})),J.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,cancelable:!0,composed:!0}));return}if(typeof J.resetToDefault==="function"){let $=J.getAttribute("default");if(J.setAttribute("default",String(Q.value??"")),J.resetToDefault(),$===null)J.removeAttribute("default");else J.setAttribute("default",$);return}J.value=Q.value;let Z=J.getAttribute?.("value")??("value"in J?J.value:Q.value);J.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,cancelable:!0,composed:!0})),J.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,cancelable:!0,composed:!0}))}#C(){this.#L();for(let J of this.#q())this.#H(J);this.#K(),this.dispatchEvent(new CustomEvent("reset",{bubbles:!0,composed:!0}))}#T(){if(!this.showReset){this.#_?.setAttribute("hidden","");return}this.#F(),this.#_?.removeAttribute("hidden")}#F(){if(!this.#Q||!this.showReset)return;let J=this.#Q.querySelector(":scope > .propskit-group-reset-tooltip");if(!J){J=document.createElement("fig-tooltip"),J.className="propskit-group-reset-tooltip",J.setAttribute("text","Reset properties");let Q=document.createElement("fig-button");Q.className="propskit-group-reset",Q.setAttribute("variant","ghost"),Q.setAttribute("icon",""),Q.setAttribute("aria-label","Reset properties");let Z=document.createElement("fig-icon");Z.setAttribute("name","reset"),Q.appendChild(Z),J.appendChild(Q),this.#Q.appendChild(J),Q.addEventListener("click",this.#U)}else{let Q=J.querySelector("fig-button");Q?.removeEventListener("click",this.#U),Q?.addEventListener("click",this.#U)}this.#_=J}#R(){let Q=this.getAttribute("name")||"Group",Z=this.querySelector(":scope > fig-header");if(Z)this.#Q=Z;else if(!this.#Q||!this.#Q.dataset.generated||this.#Q.parentElement!==this)this.#Q=document.createElement("fig-header"),this.#Q.setAttribute("borderless",""),this.#Q.dataset.generated="true",this.prepend(this.#Q);let $=this.#Q.querySelector(":scope > .propskit-group-disclosure");if(!$){$=document.createElement("fig-button"),$.className="propskit-group-disclosure",$.setAttribute("variant","ghost");let _=this.#Q.querySelector(":scope > h3");if(_)$.appendChild(_);this.#Q.prepend($)}this.#J=$;let j=$.querySelector("h3");if(!j)j=document.createElement("h3"),$.appendChild(j);if(!j.id)j.id=i("propskit-group");if(this.#Q.dataset.generated){let _=j.querySelector(".propskit-group-chevron");if(j.textContent=Q,_)j.prepend(_)}if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",j.id);if(!j.querySelector(".propskit-group-chevron")){let _=document.createElement("fig-icon");_.setAttribute("name","chevron"),_.setAttribute("size","small"),_.className="propskit-group-chevron",j.prepend(_)}if(this.#B=j.querySelector(".propskit-group-chevron"),this.#T(),this.#Q.removeAttribute("role"),this.#Q.removeAttribute("tabindex"),this.#Q.removeAttribute("aria-expanded"),this.#J.setAttribute("aria-labelledby",j.id),this.#J.setAttribute("aria-expanded",String(this.open)),this.#J.removeEventListener("click",this.#N),this.#J.addEventListener("click",this.#N),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#J.setAttribute("aria-expanded","false")}}z("propskit-group",b);class s extends HTMLElement{#Z=null;#Q=null;#J=null;#B=!1;#_=null;#P=new Set;#X=0;#$=0;#j=null;#G=null;#Y=0;#M=null;#k=!1;#N=0;#U=null;#q=0;#O=null;#L=null;#S=null;#z=this.#x.bind(this);#K=this.#QJ.bind(this);#H=this.#p.bind(this);#C=this.#o.bind(this);#T=this.#jJ.bind(this);#F=this.#_J.bind(this);#R=this.#I.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.#Z)this.#D();if(this.#w(),this.#y(),this.#PJ(),this.#E(),this.removeEventListener("pointerdown",this.#z,{capture:!0}),this.addEventListener("pointerdown",this.#z,{capture:!0,passive:!0}),this.removeEventListener("contextmenu",this.#T),this.addEventListener("contextmenu",this.#T),this.removeEventListener("click",this.#R,!0),this.addEventListener("click",this.#R,!0),this.#G?.removeEventListener("change",this.#F),this.#G?.addEventListener("change",this.#F),!this.#_)this.#_=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.#y(),this.#E()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){if(this.#_?.disconnect(),this.#X)cancelAnimationFrame(this.#X),this.#X=0;if(this.#$)cancelAnimationFrame(this.#$),this.#$=0;this.#r(),this.#e(),this.#u(),this.#m(),this.#ZJ(),this.removeEventListener("pointerdown",this.#z,{capture:!0}),this.removeEventListener("contextmenu",this.#T),this.removeEventListener("click",this.#R,!0),this.#G?.removeEventListener("change",this.#F)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#w()}#D(){let J=Array.from(this.childNodes).filter((_)=>{return _.nodeType!==Node.TEXT_NODE||Boolean(_.textContent?.trim())}),Q=J.find((_)=>_.nodeType===Node.ELEMENT_NODE&&_.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),j=document.createElement("fig-slider");j.setAttribute("text","true");for(let _ of this.#f()){let X=this.getAttribute(_);j.setAttribute(_,X??"")}Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#B=Boolean(Q),this.replaceChildren(Z),this.#W();for(let _ of J){if(_===Q)continue;this.#J.appendChild(_)}}#W(){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.#G=J,this.appendChild(J)}#w(){if(!this.#Z||!this.#Q)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()===""){if(this.#Q.parentElement===this.#Z)this.#Q.remove()}else{if(!this.#B)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#y(){if(!this.#J)return;let J=this.#f(),Q=new Set(J.filter(($)=>$!=="text"));for(let $ of this.#P)if(!Q.has($))this.#J.removeAttribute($);for(let $ of J){if($==="text")continue;let j=this.getAttribute($)??"";if(this.#J.getAttribute($)!==j)this.#J.setAttribute($,j)}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.#P=Q,this.#i()}#f(){let J=new Set(["label","direction","oninput","onchange","steppers"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!this.#g.has(Q))}#i(){if(this.#X)cancelAnimationFrame(this.#X);this.#X=requestAnimationFrame(()=>{this.#X=0,this.#YJ(),this.#V()})}#E(){if(this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{this.#$=0,this.#V()})}#V(){let J=this.#J?.querySelector('input[type="range"]'),Q=this.#J?.querySelector("fig-input-number input");if(J!==this.#j)this.#A(J);if(J){J.removeAttribute("tabindex"),J.removeAttribute("aria-hidden");let Z=this.getAttribute("aria-label")||this.#Q?.textContent?.trim()||"Slider";if(!J.hasAttribute("aria-label")&&!J.hasAttribute("aria-labelledby"))J.setAttribute("aria-label",Z)}if(Q)Q.setAttribute("tabindex","-1"),Q.setAttribute("aria-hidden","true")}#I(J){if(M(this,"disabled"))return;if(J.target instanceof Element&&J.target.closest("fig-input-number, fig-menu"))return;this.#h()}#h(){requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this.isConnected&&!M(this,"disabled"))this.focus()})})}#A(J){if(this.#m(),this.#j=J,!this.#j)return;this.#j.addEventListener("dblclick",this.#C,{capture:!0})}#m(){if(!this.#j)return;this.#j.removeEventListener("dblclick",this.#C,{capture:!0}),this.#j=null}#o(J){J.preventDefault(),J.stopImmediatePropagation(),this.#c()}#x(J){if(J.button!==0||M(this,"disabled"))return;if(!J.target?.closest?.("fig-input-number, fig-menu"))this.#h();if(this.getAttribute("elastic")==="false")return;if(J.target?.closest?.("fig-input-number"))return;let Q=this.#J?.querySelector('input[type="range"]')??this.#j;if(!Q)return;this.#e(),this.#u(),this.#j=Q,this.#k=!0,this.#O=J.pointerId,this.#N=this.#XJ();let Z=Q.getBoundingClientRect(),$=this.getBoundingClientRect();this.#U={left:Z.left,right:Z.right,width:Z.width},this.#q=$.width,window.addEventListener("pointermove",this.#K,{passive:!0}),window.addEventListener("pointerup",this.#H,{once:!0}),window.addEventListener("pointercancel",this.#H,{once:!0}),window.addEventListener("blur",this.#H,{once:!0})}#QJ(J){if(!this.#k)return;if(J.pointerId!==this.#O)return;if(J.buttons===0){this.#p(J);return}this.#UJ(J.clientX)}#p(J){if(J?.pointerId!==void 0&&this.#O!==null&&J.pointerId!==this.#O)return;this.#e(),this.#u()}#e(){window.removeEventListener("pointermove",this.#K),window.removeEventListener("pointerup",this.#H),window.removeEventListener("pointercancel",this.#H),window.removeEventListener("blur",this.#H),this.#k=!1,this.#O=null}#jJ(J){if(M(this,"disabled"))return;J.preventDefault(),J.stopPropagation(),J.stopImmediatePropagation(),this.#r(),this.#a(J.clientX,J.clientY)}#a(J,Q){let Z=!1,$=0,j=()=>{if(Z)return;Z=!0,window.clearTimeout($),window.removeEventListener("pointerup",j,!0),window.removeEventListener("pointercancel",j,!0),requestAnimationFrame(()=>{this.#G?.showAt?.(J,Q)})};window.addEventListener("pointerup",j,{once:!0,capture:!0}),window.addEventListener("pointercancel",j,{once:!0,capture:!0}),$=window.setTimeout(j,180)}#_J(J){if(J.stopPropagation(),J.detail?.value!=="reset-default")return;this.#c()}#r(){if(this.#Y)clearTimeout(this.#Y),this.#Y=0;this.#M=null}#XJ(){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}#UJ(J){let Q=this.#U;if(!Q||!this.#N){this.#u();return}let Z=J<Q.left?J-Q.left:J>Q.right?J-Q.right:0;if(!Z){this.#kJ();return}let $=Math.max(-this.#N,Math.min(this.#N,Z*0.5)),j=Math.abs($),_=this.#q?(this.#q+j)/this.#q:1;this.dataset.elasticDragging="true",this.style.setProperty("--propskit-slider-elastic-size",`${j}px`),this.style.setProperty("--propskit-slider-elastic-scale",`${_}`),this.style.setProperty("--propskit-slider-elastic-origin",$<0?"right center":"left center")}#u(){this.#kJ(),this.#N=0,this.#U=null,this.#q=0,this.#O=null}#kJ(){this.removeAttribute("data-elastic-dragging"),this.style.removeProperty("--propskit-slider-elastic-size"),this.style.removeProperty("--propskit-slider-elastic-scale")}#JJ(J){let Q=this.#j;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,j=Number(Q.min||0),_=Number(Q.max||100),X=Q.step==="any"?0:Number(Q.step||1),Y=j+(_-j)*$;if(!X)return String(Y);let B=Math.round((Y-j)/X)*X+j,G=Math.max(0,`${X}`.split(".")[1]?.length||0);return String(Number(B.toFixed(G)))}#BJ(){return this.getAttribute("default")??this.#J?.getAttribute("default")??this.getAttribute("value")??this.#J?.getAttribute("value")??this.#j?.min??"0"}#c(){this.#r(),this.#l(this.#BJ(),"input"),this.#l(this.#BJ(),"change")}#l(J,Q){if(!this.#J||J===null||J===void 0)return;this.#J.value=J,this.setAttribute("value",String(this.#J.value)),this.dispatchEvent(new CustomEvent(Q,{detail:this.#J.value,bubbles:!0,cancelable:!0,composed:!0}))}#YJ(){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??"")}#PJ(){if(!this.#J)return;if(!this.#L)this.#L=this.#GJ.bind(this,"input");if(!this.#S)this.#S=this.#GJ.bind(this,"change");this.#J.addEventListener("input",this.#L),this.#J.addEventListener("change",this.#S)}#ZJ(){if(!this.#J)return;if(this.#L)this.#J.removeEventListener("input",this.#L);if(this.#S)this.#J.removeEventListener("change",this.#S)}#GJ(J,Q){if(Q.stopImmediatePropagation(),J==="change")this.#u();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}))}focus(J){this.#V();let Q=this.#J?.querySelector('input[type="range"]');Q?.setAttribute("data-propskit-focus-called",""),Q?.focus(J)}get value(){return this.getAttribute("value")??this.#J?.value??""}set value(J){if(J===null||J===void 0||J===""){if(this.removeAttribute("value"),this.#J)this.#J.value="";return}let Q=String(J);if(this.setAttribute("value",Q),this.#J)this.#J.value=Q}resetToDefault(){this.#c()}}z("propskit-slider",s);class o extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping"];#Z=50;#Q=50;#J=75;#B=75;#_=0;#P=!1;#X=0;#$=null;#j=null;#G=null;#Y=null;#M=null;#k=null;#N=null;#U=null;#q=null;#O=!1;#L=!1;#S=!1;#z=!1;#K=null;#H="";#C="";#T=null;#F=null;#R=null;#g="";#D="";#W=null;#w=null;#y=null;get#f(){return this.getAttribute("type")||"point"}get#i(){return this.#f==="point-radius"||this.#f==="point-radius-angle"}get#E(){return this.#f==="point-radius-angle"}get#V(){return this.#f==="point-point"}get#I(){return this.#f==="point-radius-angle"||this.#f==="point-point"}get#h(){let J=this.getAttribute("tooltips");return J===null||J!=="false"}get#A(){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"}#m(J){let Q=this.#A;if(Q==="true")return!0;if(Q==="modifier")return!!J;return!1}get#o(){let J=this.getAttribute("name");if(J)return J.split(",")[0].trim();return`${Math.round(this.#Z)}%, ${Math.round(this.#Q)}%`}get#x(){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.#B)}%`}get#QJ(){return this.getAttribute("drag-surface")||"parent"}get#p(){let J=this.#QJ;if(J==="parent")return this.parentElement;return this.closest(J)}get#e(){let J=this.#QJ;if(J==="parent"){let Q=this.parentElement;if(Q)return Q.setAttribute("data-fig-canvas-control-surface",""),"[data-fig-canvas-control-surface]"}return J}#jJ(J){if(this.#P)return this.#_/100*J;return this.#_}#a(){if(this.#P)return`Radius ${Math.round(this.#_)}%`;return`Radius ${Math.round(this.#_)}`}connectedCallback(){this.#_J(),this.#r()}disconnectedCallback(){this.#KJ(),this.#CJ(),this.#u(),this.#c(),document.body.classList.remove("fig-lab-move-active"),document.body.classList.remove("fig-lab-rotate-active")}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"&&!this.#O&&!this.#L&&!this.#S&&!this.#z)if(this.#_J(),this.#$)this.#b();else this.#r();if(J==="type")this.#KJ(),this.#_J(),this.#r();if(J==="color"&&this.#$)if(Z)this.#$.setAttribute("color",Z);else this.#$.removeAttribute("color");if(J==="disabled")this.#KJ(),this.#r();if(J==="tooltips")this.#r();if(J==="snapping"&&this.#$){if(this.#$.setAttribute("drag-snapping",Z||"false"),this.#j)this.#j.setAttribute("drag-snapping",Z||"false")}if(J==="name"){if(this.#k)this.#k.setAttribute("text",this.#o);if(this.#N)this.#N.setAttribute("text",this.#x)}}#_J(){let J=this.getAttribute("value");if(!J)return;try{let Q=JSON.parse(J);if(typeof Q.x==="number")this.#Z=Q.x;if(typeof Q.y==="number")this.#Q=Q.y;if(Q.radius!==void 0){let Z=String(Q.radius);if(Z.endsWith("%"))this.#P=!0,this.#_=parseFloat(Z);else this.#P=!1,this.#_=parseFloat(Z);if(!Number.isFinite(this.#_))this.#_=0}if(typeof Q.angle==="number")this.#X=Q.angle;if(typeof Q.x2==="number")this.#J=Q.x2;if(typeof Q.y2==="number")this.#B=Q.y2}catch{}}get value(){let J={x:this.#Z,y:this.#Q};if(this.#f==="color"){let Q=this.getAttribute("color")||this.#$?.getAttribute("color");if(Q)J.color=Q}if(this.#i)J.radius=this.#P?`${this.#_}%`:this.#_;if(this.#E)J.angle=this.#X;if(this.#V)J.x2=this.#J,J.y2=this.#B;return J}set value(J){if(typeof J==="object")this.setAttribute("value",JSON.stringify(J));else if(typeof J==="string")this.setAttribute("value",J)}#r(){this.#KJ(),this.innerHTML="",this.#$=null,this.#j=null,this.#G=null,this.#Y=null,this.#M=null,this.#k=null,this.#N=null,this.#U=null,this.#q=null;let J=M(this,"disabled"),Q=this.#f,Z=this.#h,$=this.#e,j=document.createElement("fig-handle");if(j.setAttribute("drag","true"),j.setAttribute("drag-surface",$),j.setAttribute("drag-axes","x,y"),j.setAttribute("drag-snapping",this.#A),j.setAttribute("value",`${this.#Z}% ${this.#Q}%`),J)j.setAttribute("disabled","");if(Q==="color"){j.setAttribute("type","color");let _=this.getAttribute("color");if(_)j.setAttribute("color",_)}else j.setAttribute("type","canvas");if(this.#V)j.setAttribute("hit-area","12 circle"),j.setAttribute("hit-area-mode","delegate");if(this.#$=j,this.#i)this.#WJ();if(this.#I)this.#LJ();if(Z){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#o),_.appendChild(j),this.appendChild(_),this.#k=_}else this.appendChild(j);if(this.#E)this.#v(J,Z,$);if(this.#V)this.#VJ(J,Z,$);this.#XJ(this.#$),this.#XJ(this.#G),this.#XJ(this.#j),this.#s(),this.#PJ(),requestAnimationFrame(()=>this.#b())}#XJ(J){if(!J)return;J.addEventListener("pointerdown",(Q)=>{if(Q.target?.classList?.contains("fig-handle-hit-area")&&J.querySelector(".fig-handle-hit-area"))this.#BJ(Q,J);else this.#UJ(Q)},{capture:!0})}#UJ(J){if(M(this,"disabled"))return;if(J?.button!==void 0&&J.button!==0)return;if(J?.isPrimary===!1)return;if(this.#K===null)this.#H=document.body.style.getPropertyValue("cursor"),this.#C=document.body.style.getPropertyPriority("cursor");if(this.#K=J?.pointerId??-1,document.body.classList.add("fig-lab-move-active"),document.body.style.setProperty("cursor","var(--fig-lab-cursor-move)","important"),!this.#T)this.#T=(Q)=>{if(Q?.pointerId!==void 0&&this.#K!==null&&Q.pointerId!==this.#K)return;if(Q?.type==="blur")this.#u();else requestAnimationFrame(()=>this.#u())};window.addEventListener("pointerup",this.#T),window.addEventListener("pointercancel",this.#T),window.addEventListener("blur",this.#T)}#u(){if(this.#K===null)return;if(document.body.classList.remove("fig-lab-move-active"),this.#H)document.body.style.setProperty("cursor",this.#H,this.#C);else document.body.style.removeProperty("cursor");if(this.#K=null,this.#H="",this.#C="",this.#T)window.removeEventListener("pointerup",this.#T),window.removeEventListener("pointercancel",this.#T),window.removeEventListener("blur",this.#T)}#kJ(J){if(!J)return 0;if(J===this.#G)return this.#X;if(!this.#V)return 0;let Q=this.#qJ();return J===this.#$?Q+180:Q}#JJ(){if(this.#F===null)return;let J=this.#MJ(this.#kJ(this.#R));document.body.style.setProperty("--fig-lab-cursor-rotate",J),document.body.style.setProperty("cursor",J,"important")}#BJ(J,Q){if(M(this,"disabled"))return;if(J?.button!==void 0&&J.button!==0)return;if(J?.isPrimary===!1)return;if(this.#F===null)this.#g=document.body.style.getPropertyValue("cursor"),this.#D=document.body.style.getPropertyPriority("cursor");if(this.#F=J?.pointerId??-1,this.#R=Q,document.body.classList.add("fig-lab-rotate-active"),this.#JJ(),!this.#W)this.#W=(Z)=>{if(Z?.pointerId!==void 0&&this.#F!==null&&Z.pointerId!==this.#F)return;if(Z?.type==="blur")this.#c();else requestAnimationFrame(()=>this.#c())};window.addEventListener("pointerup",this.#W),window.addEventListener("pointercancel",this.#W),window.addEventListener("blur",this.#W)}#c(){if(this.#F===null)return;if(document.body.classList.remove("fig-lab-rotate-active"),document.body.style.removeProperty("--fig-lab-cursor-rotate"),this.#g)document.body.style.setProperty("cursor",this.#g,this.#D);else document.body.style.removeProperty("cursor");if(this.#F=null,this.#R=null,this.#g="",this.#D="",this.#W)window.removeEventListener("pointerup",this.#W),window.removeEventListener("pointercancel",this.#W),window.removeEventListener("blur",this.#W)}#l(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?.()},Y=()=>{_()};J.addEventListener("pointerenter",X),J.addEventListener("pointerleave",Y)}#YJ(){return this.#O||this.#L||this.#S||this.#z}#PJ(){if(this.#$)this.#l(this.#$,()=>this.#k,()=>this.#o,()=>this.#YJ()||!!this.#$?.querySelector("fig-color-tip"));if(this.#G)this.#l(this.#G,()=>this.#q,()=>`Angle ${Math.round(this.#X)}°`,()=>this.#YJ());if(this.#j)this.#l(this.#j,()=>this.#N,()=>this.#x,()=>this.#YJ());if(this.#Y){let J=this.#Y.querySelector(".fig-canvas-control-radius-hit");this.#GJ(J||this.#Y)}if(this.#f==="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})}#ZJ(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?.()}#GJ(J){if(!J)return;J.addEventListener("pointerenter",(Q)=>{let Z=this.#U;if(!Z)return;Z.setAttribute("text",this.#a()),Z.setAttribute("show","true"),Z.showPopup?.(),this.#ZJ(Q.clientX,Q.clientY)}),J.addEventListener("pointermove",(Q)=>{if(this.#S)return;this.#ZJ(Q.clientX,Q.clientY)}),J.addEventListener("pointerleave",()=>{if(this.#S)return;let Q=this.#U;if(!Q)return;Q.removeAttribute("show")})}#WJ(){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 j=document.createElementNS("http://www.w3.org/2000/svg","circle");if(Q.appendChild(j),this.#Y=Q,this.#h){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#a()),_.appendChild(Q),this.appendChild(_),this.#U=_}else this.appendChild(Q);this.#fJ(Z)}#LJ(){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.#V){let j=document.createElementNS("http://www.w3.org/2000/svg","line");j.classList.add("fig-canvas-control-angle-line-hit"),j.setAttribute("stroke","transparent"),j.setAttribute("stroke-width","12"),j.setAttribute("stroke-linecap","round"),j.style.pointerEvents="stroke",Q.appendChild(j),this.#RJ(j)}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.#M=Q,this.appendChild(Q)}#RJ(J){J.addEventListener("pointerdown",(Q)=>{if(M(this,"disabled"))return;Q.preventDefault(),Q.stopPropagation();let Z=this.#p;if(!Z)return;let{clientX:$,clientY:j}=Q,_=this.#Z,X=this.#Q,Y=this.#J,B=this.#B;this.#O=!0,this.#L=!0,document.body.classList.add("fig-lab-move-active"),J.style.pointerEvents="none";let G=(P)=>{let q=Z.getBoundingClientRect(),O=q.width>0?(P.clientX-$)/q.width*100:0,N=q.height>0?(P.clientY-j)/q.height*100:0,K=-Math.min(_,Y),S=100-Math.max(_,Y),T=-Math.min(X,B),F=100-Math.max(X,B),L=Math.max(K,Math.min(S,O)),W=Math.max(T,Math.min(F,N));this.#Z=_+L,this.#Q=X+W,this.#J=Y+L,this.#B=B+W,this.#b(),this.#n()},k=this.#FJ((P)=>{if(document.body.classList.remove("fig-lab-move-active"),J.style.pointerEvents="stroke",this.#O=!1,this.#L=!1,P)this.#t(),this.#d()});window.addEventListener("pointermove",G,{signal:k.signal}),window.addEventListener("pointerup",()=>k.finish(!0),{signal:k.signal}),window.addEventListener("pointercancel",()=>k.finish(!1),{signal:k.signal})})}#v(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.#G=$,Q){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",`${Math.round(this.#X)}°`),j.appendChild($),this.appendChild(j),this.#q=j}else this.appendChild($)}#VJ(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.#A),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),$.setAttribute("value",`${this.#J}% ${this.#B}%`),J)$.setAttribute("disabled","");if(this.#j=$,Q){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#x),j.appendChild($),this.appendChild(j),this.#N=j}else this.appendChild($)}#$J(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`}#MJ(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`}#SJ(J,Q){if(!J)return;J.style.setProperty("cursor",Q,"important")}#OJ(J,Q){if(!J)return;let Z=J.querySelector(".fig-handle-hit-area");if(!Z)return;if(Z.setAttribute("data-cursor","rotate"),this.#SJ(Z,this.#MJ(Q)),this.#R===J)this.#JJ()}#zJ(){if(!this.#G||!this.#E)return;this.#OJ(this.#G,this.#X)}#qJ(){return Math.atan2(this.#B-this.#Q,this.#J-this.#Z)*180/Math.PI}#TJ(){if(!this.#V)return;let J=this.#qJ();this.#$?.style.removeProperty("cursor"),this.#j?.style.removeProperty("cursor"),this.#OJ(this.#$,J+180),this.#OJ(this.#j,J)}#NJ(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`}#b(){let J=this.#p;if(!J||!this.#$)return;let Q=J.getBoundingClientRect();if(this.#NJ(this.#$,this.#Z,this.#Q,Q),this.#Y){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,j=this.#jJ(Q.width),_=this.#Y,X=Math.max(j*2,1);_.style.position="absolute",_.style.width=`${X}px`,_.style.height=`${X}px`,_.style.left=`${Z-j}px`,_.style.top=`${$-j}px`,_.setAttribute("viewBox",`0 0 ${X} ${X}`);let Y=_.querySelectorAll("circle");for(let B of Y)B.setAttribute("cx",String(j)),B.setAttribute("cy",String(j)),B.setAttribute("r",String(Math.max(j-1,0)))}if(this.#M&&this.#I){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,j,_;if(this.#V)j=this.#J/100*Q.width,_=this.#B/100*Q.height;else{let B=this.#jJ(Q.width),G=this.#X*Math.PI/180;j=Z+B*Math.cos(G),_=$+B*Math.sin(G)}let X=this.#M;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 Y=X.querySelectorAll(".fig-canvas-control-angle-line, .fig-canvas-control-angle-line-halo, .fig-canvas-control-angle-line-hit");for(let B of Y)B.setAttribute("x1",String(Z)),B.setAttribute("y1",String($)),B.setAttribute("x2",String(j)),B.setAttribute("y2",String(_))}if(this.#G&&this.#E){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,j=this.#jJ(Q.width),_=this.#X*Math.PI/180,X=Z+j*Math.cos(_),Y=$+j*Math.sin(_),B=Q.width>0?X/Q.width*100:0,G=Q.height>0?Y/Q.height*100:0;this.#NJ(this.#G,B,G,Q)}if(this.#j&&this.#V)this.#NJ(this.#j,this.#J,this.#B,Q);this.#zJ(),this.#TJ()}#n(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#d(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}#t(){this.setAttribute("value",JSON.stringify(this.value))}#s(){if(!this.#$)return;if(this.#$.addEventListener("input",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#n();return}this.#O=!0;let Q=J.detail?.px??this.#Z/100,Z=J.detail?.py??this.#Q/100;if(this.#Z=Math.round(Math.max(0,Math.min(100,Q*100))),this.#Q=Math.round(Math.max(0,Math.min(100,Z*100))),this.#k)this.#k.removeAttribute("show"),this.#k.hidePopup?.();this.#b(),this.#n()}),this.#$.addEventListener("change",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#d();return}let Q=J.detail?.px??this.#Z/100,Z=J.detail?.py??this.#Q/100;if(this.#Z=Math.round(Math.max(0,Math.min(100,Q*100))),this.#Q=Math.round(Math.max(0,Math.min(100,Z*100))),this.#k)this.#k.removeAttribute("show");this.#b(),this.#t(),this.#d(),requestAnimationFrame(()=>{this.#O=!1})}),this.#G)this.#G.addEventListener("input",(J)=>{J.stopPropagation();let Q=this.#p;if(!Q)return;this.#z=!0,this.classList.add("fig-canvas-control-ring-active");let Z=Q.getBoundingClientRect(),$=this.#Z/100*Z.width,j=this.#Q/100*Z.height,_=J.detail?.x??0,X=J.detail?.y??0,Y=this.#G.offsetWidth/2,B=this.#G.offsetHeight/2,G=_+Y-$,k=X+B-j,P=Math.atan2(k,G)*180/Math.PI;if(this.#m(J.detail?.shiftKey))P=Math.round(P/15)*15;this.#X=P;let q=Math.sqrt(G*G+k*k);if(this.#m(J.detail?.shiftKey)){let O=this.#P?5:10;if(this.#P){let N=q/Z.width*100;N=Math.round(N/O)*O,q=N/100*Z.width}else q=Math.round(q/O)*O}if(this.#P)this.#_=Math.max(0,q/Z.width*100);else this.#_=Math.max(0,q);if(this.#q)this.#q.setAttribute("text",`Angle ${Math.round(this.#X)}°`),this.#q.setAttribute("show","true"),this.#q.showPopup?.();this.#b(),this.#n()}),this.#G.addEventListener("change",(J)=>{if(J.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#q)this.#q.removeAttribute("show");this.#b(),this.#t(),this.#d(),requestAnimationFrame(()=>{this.#z=!1})}),this.#G.addEventListener("hitareadown",(J)=>{J.stopPropagation();let Q=J.detail?.originalEvent;if(!Q)return;Q.preventDefault();let Z=this.#p;if(!Z)return;if(this.#z=!0,this.classList.add("fig-canvas-control-ring-active"),this.#G.setAttribute("selected",""),this.#q)this.#q.setAttribute("show","true"),this.#q.showPopup?.();let $=(_)=>{let X=Z.getBoundingClientRect(),Y=this.#Z/100*X.width,B=this.#Q/100*X.height,G=_.clientX-X.left-Y,k=_.clientY-X.top-B,P=Math.atan2(k,G)*180/Math.PI;if(this.#m(_.shiftKey))P=Math.round(P/15)*15;if(this.#X=P,this.#q)this.#q.setAttribute("text",`Angle ${Math.round(P)}°`);this.#b(),this.#n()},j=this.#FJ((_)=>{if(this.#z=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#G.removeAttribute("selected"),this.#q)this.#q.removeAttribute("show");if(_)this.#t(),this.#d()});window.addEventListener("pointermove",$,{signal:j.signal}),window.addEventListener("pointerup",()=>j.finish(!0),{signal:j.signal}),window.addEventListener("pointercancel",()=>j.finish(!1),{signal:j.signal})});if(this.#j)this.#j.addEventListener("input",(J)=>{J.stopPropagation(),this.#L=!0;let Q=J.detail?.px??this.#J/100,Z=J.detail?.py??this.#B/100;if(this.#J=Math.round(Math.max(0,Math.min(100,Q*100))),this.#B=Math.round(Math.max(0,Math.min(100,Z*100))),this.#N)this.#N.removeAttribute("show"),this.#N.hidePopup?.();this.#b(),this.#n()}),this.#j.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#N)this.#N.removeAttribute("show");this.#b(),this.#t(),this.#d(),requestAnimationFrame(()=>{this.#L=!1})}),this.#HJ(this.#$,!0),this.#HJ(this.#j,!1)}#HJ(J,Q){if(!J)return;J.addEventListener("hitareadown",(Z)=>{Z.stopPropagation();let $=Z.detail?.originalEvent;if(!$)return;$.preventDefault();let j=this.#p;if(!j)return;this.#O=!0;let _=j.getBoundingClientRect(),X=Q?this.#J:this.#Z,Y=Q?this.#B:this.#Q,B=Q?this.#Z:this.#J,G=Q?this.#Q:this.#B,k=X/100*_.width,P=Y/100*_.height,q=B/100*_.width,O=G/100*_.height,N=Math.sqrt((q-k)**2+(O-P)**2),K=Q?this.#k:this.#N;if(K)K.removeAttribute("show"),K.hidePopup?.();let S=(F)=>{let L=j.getBoundingClientRect(),W=X/100*L.width,f=Y/100*L.height,R=F.clientX-L.left-W,C=F.clientY-L.top-f,V=Math.atan2(C,R);if(this.#m(F.shiftKey))V=Math.round(V*180/Math.PI/15)*15*Math.PI/180;let l=W+N*Math.cos(V),d=f+N*Math.sin(V),y=Math.max(0,Math.min(100,l/L.width*100)),h=Math.max(0,Math.min(100,d/L.height*100));if(Q)this.#Z=y,this.#Q=h;else this.#J=y,this.#B=h;this.#b(),this.#n()},T=this.#FJ((F)=>{if(this.#O=!1,K)K.removeAttribute("show");if(F)this.#t(),this.#d()});window.addEventListener("pointermove",S,{signal:T.signal}),window.addEventListener("pointerup",()=>T.finish(!0),{signal:T.signal}),window.addEventListener("pointercancel",()=>T.finish(!1),{signal:T.signal})})}#fJ(J){if(!J)return;J.addEventListener("pointermove",(Z)=>{if(this.#S)return;let $=this.#p;if(!$)return;let j=$.getBoundingClientRect(),_=this.#Z/100*j.width,X=this.#Q/100*j.height,Y=Math.atan2(Z.clientY-j.top-X,Z.clientX-j.left-_)*180/Math.PI;this.#SJ(J,this.#$J(Y))});let Q=(Z)=>{if(M(this,"disabled"))return;Z.preventDefault(),Z.stopPropagation(),this.#S=!0,this.classList.add("fig-canvas-control-ring-active");let $=this.#p;if(!$)return;if(this.#U)this.#U.setAttribute("show","true"),this.#U.showPopup?.(),this.#ZJ(Z.clientX,Z.clientY);if(this.#q)this.#q.removeAttribute("show"),this.#q.hidePopup?.();let j=this.#G?.style.pointerEvents,_=this.#G?.querySelector(".fig-handle-hit-area"),X=_?.style.pointerEvents;if(this.#G)this.#G.style.pointerEvents="none";if(_)_.style.pointerEvents="none";let Y=document.body.style.cursor;J.style.pointerEvents="none";let B=$.getBoundingClientRect(),G=this.#Z/100*B.width,k=this.#Q/100*B.height,P=Math.atan2(Z.clientY-B.top-k,Z.clientX-B.left-G)*180/Math.PI,q=Math.round(P);document.body.style.cursor=this.#$J(q);let O=(K)=>{let S=$.getBoundingClientRect(),T=this.#Z/100*S.width,F=this.#Q/100*S.height,L=K.clientX-S.left-T,W=K.clientY-S.top-F,f=Math.round(Math.atan2(W,L)*180/Math.PI);if(f!==q)q=f,document.body.style.cursor=this.#$J(f);let R=Math.sqrt(L*L+W*W);if(this.#m(K.shiftKey)){let C=this.#P?5:10;if(this.#P){let V=R/S.width*100;V=Math.round(V/C)*C,R=V/100*S.width}else R=Math.round(R/C)*C}if(this.#P)this.#_=Math.max(0,R/S.width*100);else this.#_=Math.max(0,R);if(this.#U)this.#U.setAttribute("text",this.#a()),this.#ZJ(K.clientX,K.clientY);this.#b(),this.#n()},N=this.#FJ((K)=>{if(this.#S=!1,this.classList.remove("fig-canvas-control-ring-active"),J.style.pointerEvents="",this.#G)this.#G.style.pointerEvents=j??"";if(_)_.style.pointerEvents=X??"";if(document.body.style.cursor=Y,this.#U)this.#U.removeAttribute("show");if(K)this.#t(),this.#d()});window.addEventListener("pointermove",O,{signal:N.signal}),window.addEventListener("pointerup",()=>N.finish(!0),{signal:N.signal}),window.addEventListener("pointercancel",()=>N.finish(!1),{signal:N.signal})};J.addEventListener("pointerdown",Q),this._radiusDragCleanup=()=>J.removeEventListener("pointerdown",Q)}#CJ(){if(this._radiusDragCleanup)this._radiusDragCleanup(),this._radiusDragCleanup=null}#FJ(J){this.#KJ();let Q=new AbortController,Z=!1,$=(j=!1)=>{if(Z)return;if(Z=!0,Q.abort(),this.#w===Q)this.#w=null,this.#y=null;J(j)};return this.#w=Q,this.#y=$,{signal:Q.signal,finish:$}}#KJ(){this.#y?.(!1),this.#w?.abort(),this.#w=null,this.#y=null}}z("fig-canvas-control",o);class U extends HTMLElement{#Z=[U.#F()];#Q=0;#J=2;#B=240;#_=120;#P={min:-1,max:1};#X=null;#$=null;#j=null;#G=null;#Y=0;#M=null;#k=null;#N=null;#U=null;#q=[];#O=[];#L=[];#S=[];#z=new Set;#K=null;#H=null;#C=null;#T=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.#R("precision",2),this.#y(this.getAttribute("value")),this.#w(),this.#x(),this.#UJ()}disconnectedCallback(){if(this.#qJ(),this.#PJ(),this.#K)this.#K.disconnect(),this.#K=null}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"){if(this.#y(Z),this.isConnected)this.#x();return}if(J==="precision"){if(this.#J=this.#R("precision",2),this.isConnected)this.#b();return}if(J==="aspect-ratio"){if(this.#w(),this.#$)this.#l();return}if(J==="edit"||J==="disabled"){if(this.isConnected)this.#x()}}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.#Z.map((J)=>this.#i(J))}}get preset(){let J=this.#E;return U.TYPES.find((Q)=>Q.value===J.type)?.name}#R(J,Q){let Z=Number.parseInt(this.getAttribute(J)||"",10);return Number.isFinite(Z)?Math.max(0,Math.min(100,Z)):Q}#g(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}#D(){return this.getAttribute("edit")!=="false"}#W(){return this.#g("disabled",!1)}#w(){let J=this.getAttribute("aspect-ratio")||"2 / 1";this.style.setProperty("--aspect-ratio",J)}#y(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.#Z=Z.map(($)=>this.#f($)),!this.#Z.length)this.#Z=[U.#F()];return this.#Q=Math.min(this.#Q,this.#Z.length-1),!0}#f(J={}){return{type:this.#V(J.type),frequency:this.#I(J.frequency,1,0.1,16),amplitude:this.#I(J.amplitude,1,-4,4),phase:this.#I(J.phase,0,-360,360),offset:this.#I(J.offset,0,-4,4)}}#i(J){return{type:J.type,frequency:this.#h(J.frequency),amplitude:this.#h(J.amplitude),phase:this.#h(J.phase),offset:this.#h(J.offset)}}get#E(){if(!this.#Z[this.#Q])this.#Q=0;return this.#Z[this.#Q]||U.#F()}#V(J){let Q=String(J||"").toLowerCase();return U.TYPES.some((Z)=>Z.value===Q)?Q:"sine"}#I(J,Q,Z,$){let j=Number.parseFloat(J);if(!Number.isFinite(j))return Q;return Math.min($,Math.max(Z,j))}#h(J){let Q=10**this.#J;return Math.round(J*Q)/Q}static#A(J){return String(J).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}static#m(J){return U.TYPES.find((Q)=>Q.value===J)?.name||"Wave"}static waveIcon(J,Q=24){let j=Q-10,_="";for(let X=0;X<=32;X++){let Y=X/32,B=U.#o(J,Y),G=5+Y*j,k=5+(1-(B+1)/2)*j;_+=`${X===0?"M":"L"}${G.toFixed(1)},${k.toFixed(1)}`}return`<svg width="${Q}" height="${Q}" viewBox="0 0 ${Q} ${Q}" fill="none"><path d="${_}" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"/></svg>`}static#o(J,Q,Z=0){let $=Q+Z/360,j=$-Math.floor($),_=$*Math.PI*2;switch(J){case"square":return Math.sin(_)>=0?1:-1;case"sawtooth":return j*2-1;case"triangle":return 1-Math.abs(j*4-2);default:return Math.sin(_)}}#x(){this.#qJ(),this.#PJ(),this.innerHTML=this.#QJ(),this.#_J(),this.#u(),this.#l(),this.#RJ(),this.#YJ()}#QJ(){let J=this.#D()&&!this.#W(),Q=J?"":" disabled";return`<div class="propskit-oscillator-svg-container">
|
|
2
|
+
<svg viewBox="0 0 ${this.#B} ${this.#_}" class="propskit-oscillator-svg">
|
|
3
|
+
<rect class="propskit-oscillator-bounds" x="0" y="0" width="${this.#B}" height="${this.#_}"></rect>
|
|
4
4
|
<line class="propskit-oscillator-baseline"></line>
|
|
5
5
|
<path class="propskit-oscillator-path"></path>
|
|
6
6
|
<circle class="propskit-oscillator-playhead"></circle>
|
|
7
|
-
|
|
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"
|
|
7
|
+
${J?`<foreignObject class="propskit-oscillator-handle propskit-oscillator-amplitude-handle" data-handle="amplitude" width="20" height="20"><div class="propskit-oscillator-handle-inner"><fig-tooltip text="Amplitude"><fig-handle size="small" aria-label="Oscillator amplitude handle"></fig-handle></fig-tooltip></div></foreignObject>
|
|
8
|
+
<foreignObject class="propskit-oscillator-handle propskit-oscillator-frequency-handle" data-handle="frequency" width="20" height="20"><div class="propskit-oscillator-handle-inner"><fig-tooltip text="Frequency"><fig-handle size="small" aria-label="Oscillator frequency handle"></fig-handle></fig-tooltip></div></foreignObject>`:""}
|
|
9
9
|
</svg>
|
|
10
10
|
</div>
|
|
11
|
-
${this.#
|
|
12
|
-
${this.#Z.map((Q,Z)=>this.#
|
|
13
|
-
</div>`}#
|
|
11
|
+
${this.#D()?this.#p(Q):""}`}#p(J){return`<div class="propskit-oscillator-waves">
|
|
12
|
+
${this.#Z.map((Q,Z)=>this.#e(Q,Z,J)).join("")}
|
|
13
|
+
</div>`}#e(J,Q,Z){let $=Z||this.#Z.length<=1?" disabled":"",j=Q===this.#Q?" data-active":"",_=U.#m(J.type);return`<fig-group class="propskit-oscillator-wave" collapsible borderless compact="true"${this.#z.has(Q)?' open="true"':' open="false"'} data-wave-index="${Q}">
|
|
14
14
|
<fig-header borderless>
|
|
15
|
-
<h3>${
|
|
15
|
+
<h3>${_}</h3>
|
|
16
16
|
<fig-tooltip text="Remove form">
|
|
17
17
|
<fig-button class="propskit-oscillator-remove-button" variant="ghost" icon data-wave-index="${Q}" aria-label="Remove form"${$}><fig-icon name="minus"></fig-icon></fig-button>
|
|
18
18
|
</fig-tooltip>
|
|
19
19
|
<fig-tooltip text="Add form">
|
|
20
|
-
|
|
21
|
-
<fig-icon name="add"></fig-icon>
|
|
22
|
-
${this.#XJ("propskit-oscillator-add-type","sine",Z,Q)}
|
|
23
|
-
</fig-button>
|
|
20
|
+
${this.#jJ("propskit-oscillator-add-type propskit-oscillator-add-type-button","sine",Z,Q)}
|
|
24
21
|
</fig-tooltip>
|
|
25
22
|
</fig-header>
|
|
26
|
-
<div class="propskit-oscillator-fields" data-wave-index="${Q}"${
|
|
27
|
-
${this.#
|
|
28
|
-
${this.#
|
|
29
|
-
${this.#
|
|
30
|
-
${this.#
|
|
23
|
+
<div class="propskit-oscillator-fields" data-wave-index="${Q}"${j}>
|
|
24
|
+
${this.#a(Q,"frequency","Frequency",0.1,16,0.1,"")}
|
|
25
|
+
${this.#a(Q,"amplitude","Amplitude",-4,4,0.1,"")}
|
|
26
|
+
${this.#a(Q,"phase","Phase",-360,360,1,"°")}
|
|
27
|
+
${this.#a(Q,"offset","Offset",-4,4,0.1,"")}
|
|
31
28
|
</div>
|
|
32
|
-
</fig-group>`}#
|
|
33
|
-
|
|
34
|
-
<
|
|
35
|
-
</option>`}).join(""),j=$===null?"":` data-wave-index="${L.#l(String($))}"`;return`<fig-dropdown class="${J}" value="${Q}" experimental="modern" type="dropdown" label="Add form"${j}${Z}>${_}</fig-dropdown>`}#r(J,Q,Z,$,_,j,X){let G=this.#z()?" disabled":"",q=X?` units="${L.#l(X)}"`:"",B=this.#Z[J]||L.#S();return`<propskit-slider class="propskit-oscillator-field" label="${Z}" direction="horizontal" name="${Q}" data-wave-index="${J}" value="${this.#g(B[Q])}" min="${$}" max="${_}" step="${j}" precision="${this.#J}" elastic="false"${q}${G}></propskit-slider>`}#a(){this.#$=this.querySelector(".propskit-oscillator-svg"),this.#q=this.querySelector(".propskit-oscillator-path"),this.#G=this.querySelector(".propskit-oscillator-playhead"),this.#D=this.querySelector(".propskit-oscillator-baseline"),this.#K=this.querySelector(".propskit-oscillator-bounds"),this.#M=this.querySelector('[data-handle="amplitude"]'),this.#U=this.querySelector('[data-handle="frequency"]'),this.#k=Array.from(this.querySelectorAll(".propskit-oscillator-wave-type")),this.#N=Array.from(this.querySelectorAll("propskit-slider[name]")),this.#H=Array.from(this.querySelectorAll("fig-group.propskit-oscillator-wave")),this.#W=Array.from(this.querySelectorAll(".propskit-oscillator-fields"))}#e(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}#$J(J){let Q=new Set;for(let Z of this.#L)Q.add(Z>=J?Z+1:Z);Q.add(J),this.#L=Q}#y(){if(this.#T||!window.ResizeObserver)return;this.#T=new ResizeObserver(()=>{if(this.#n())this.#m()}),this.#T.observe(this)}#n(){if(!this.#$)return!1;let J=this.#$.getBoundingClientRect(),Q=Math.max(1,Math.round(J.width||240)),Z=Math.max(1,Math.round(J.height||120)),$=Q!==this.#j||Z!==this.#_;return this.#j=Q,this.#_=Z,this.#$.setAttribute("viewBox",`0 0 ${Q} ${Z}`),$}#YJ(){let J=1,Q=256;for(let Z=0;Z<=Q;Z++)J=Math.max(J,Math.abs(this.#h(Z/Q)));return{min:-J,max:J}}#p(J){let{min:Q,max:Z}=this.#Y;return this.#_-(J-Q)/(Z-Q)*this.#_}#_J(J){let{min:Q,max:Z}=this.#Y;return Q+(1-J/this.#_)*(Z-Q)}#h(J){return this.#Z.reduce((Q,Z)=>{let $=J*Z.frequency,_=L.#o(Z.type,$,Z.phase);return Q+Z.offset+_*Z.amplitude},0)}#m(){if(!this.#$||!this.#q)return;if(this.#n(),this.#Y=this.#YJ(),this.#K)this.#K.setAttribute("width",this.#j),this.#K.setAttribute("height",this.#_);let J=Math.max(...this.#Z.map((j)=>j.frequency)),Z=this.#Z.some((j)=>j.type==="square"||j.type==="sawtooth")?Math.max(192,Math.ceil(J*64)):Math.max(96,Math.ceil(J*64)),$="";for(let j=0;j<=Z;j++){let X=j/Z,G=X*this.#j,q=this.#p(this.#h(X));$+=`${j===0?"M":"L"}${G.toFixed(1)},${q.toFixed(1)}`}this.#q.setAttribute("d",$);let _=this.#p(0);this.#D?.setAttribute("x1","0"),this.#D?.setAttribute("y1",_),this.#D?.setAttribute("x2",this.#j),this.#D?.setAttribute("y2",_),this.#BJ()}#JJ(){if(this.#B||!this.#G)return;let J=(Q)=>{if(!this.isConnected||!this.#G){this.#B=0;return}this.#t(Q%1000/1000),this.#B=requestAnimationFrame(J)};this.#B=requestAnimationFrame(J)}#c(){if(!this.#B)return;cancelAnimationFrame(this.#B),this.#B=0}#t(J){if(!this.#G)return;let Q=J*this.#j,Z=this.#p(this.#h(J));this.#G.setAttribute("cx",Q.toFixed(1)),this.#G.setAttribute("cy",Z.toFixed(1))}#BJ(){let Q=this.#E,Z=this.#NJ(),$=Math.max(8,Math.min(this.#j-8,this.#j/Q.frequency)),_=this.#p(this.#h(Z/this.#j)),j=this.#p(this.#h($/this.#j));this.#MJ(this.#M,Z,_,8),this.#MJ(this.#U,$,j,8)}#NJ(){let J=this.#E,Q=J.phase/360,Z=Math.max(0.1,J.frequency),$=0.25;if(J.type==="triangle")$=0.5;if(J.type==="sawtooth")$=1;let _=($-Q)/Z;while(_<0)_+=1/Z;while(_>1)_-=1/Z;if(_<0||_>1||!Number.isFinite(_))_=0.25;return Math.max(8,Math.min(this.#j-8,_*this.#j))}#MJ(J,Q,Z,$){if(!J)return;J.setAttribute("x",Q-$),J.setAttribute("y",Z-$),J.setAttribute("width",$*2),J.setAttribute("height",$*2)}#FJ(){for(let Q of this.#k)Q.addEventListener("change",(Z)=>{if(this.#z())return;let $=this.#d(Q);this.#qJ($),this.#Z[$].type=this.#A(Z.detail??Z.target?.value),this.#GJ(),this.#V("input"),this.#V("change")});for(let Q of this.#N)Q.addEventListener("input",(Z)=>{Z.stopPropagation(),this.#P=Q;try{this.#KJ(this.#d(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"input")}finally{this.#P=null}}),Q.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#KJ(this.#d(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"change")});for(let Q of this.#H)Q.addEventListener("pointerdown",()=>{this.#qJ(this.#d(Q))}),Q.addEventListener("focusin",()=>{this.#qJ(this.#d(Q))}),Q.addEventListener("openchange",(Z)=>{let $=this.#d(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.#z())return;let j=this.#d(Q)+1,X=this.#A($.detail??Q.value);this.#Z.splice(j,0,L.#S(X)),this.#$J(j),this.#Q=j,this.#u(),this.#V("input"),this.#V("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.#z()||this.#Z.length<=1)return;let $=this.#d(Q);this.#Z.splice($,1),this.#e($),this.#Q=Math.min(this.#Q,this.#Z.length-1),this.#u(),this.#V("input"),this.#V("change")});for(let Q of[this.#M,this.#U])this.#TJ(Q);this.querySelector(".propskit-oscillator-svg-container")?.addEventListener("pointerdown",(Q)=>{if(this.#z())return;if(Q.target?.closest?.(".propskit-oscillator-handle, fig-handle"))return;this.#DJ(Q,"offset")})}#d(J){let Q=Number.parseInt(J?.getAttribute("data-wave-index")||"",10);return Number.isFinite(Q)?Math.min(this.#Z.length-1,Math.max(0,Q)):0}#TJ(J){let Q=J?.querySelector("fig-handle"),Z=J?.getAttribute("data-handle");if(!Q||!Z)return;Q.addEventListener("pointerdown",($)=>{if(this.#z())return;$.preventDefault(),$.stopImmediatePropagation(),this.#DJ($,Z)},{capture:!0}),Q.addEventListener("keydown",($)=>{if(this.#z())return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes($.key))return;if(!this.#LJ($,Z))return;$.preventDefault(),$.stopImmediatePropagation()},{capture:!0})}#qJ(J){let Q=Math.min(this.#Z.length-1,Math.max(0,J));if(Q===this.#Q)return;this.#Q=Q,this.#ZJ(),this.#BJ()}#KJ(J,Q,Z,$){if(this.#z())return;this.#qJ(J);let _=Number.parseFloat(Z);if(!Number.isFinite(_)){if($==="change")this.#QJ();return}this.#Z[J]=this.#F({...this.#Z[J],[Q]:_}),this.#GJ({skipFieldSync:$=="input"}),this.#V($)}#LJ(J,Q){let Z=J.shiftKey?0.5:0.1,$=this.#E;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.#Z[this.#Q]=this.#F($),this.#GJ(),this.#V("input"),this.#V("change"),!0}#UJ(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}}#DJ(J,Q){this.#X=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.#X)return;let G=this.#UJ(X),q=this.#E;if(Q==="frequency"){let B=Math.max(1,Math.min(this.#j,G.x));q.frequency=this.#j/B}else if(Q==="offset"){let B=this.#w(G.x/this.#j,0,0,1),N=this.#WJ(q,B);q.offset=this.#_J(G.y)-this.#kJ(this.#Q,B)-N*q.amplitude}else if(Q==="amplitude"){let B=this.#w(G.x/this.#j,0,0,1),N=this.#WJ(q,B),K=this.#_J(G.y)-this.#kJ(this.#Q,B)-q.offset;q.amplitude=Math.abs(N)<0.001?q.amplitude:K/N}this.#Z[this.#Q]=this.#F(q),this.#GJ(),this.#V("input")},j=()=>{if(this.#X=null,this.#$?.classList.remove("dragging"),Z)document.body.style.cursor=$;document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",j),this.#V("change")};document.addEventListener("pointermove",_),document.addEventListener("pointerup",j)}#kJ(J,Q){return this.#Z.reduce((Z,$,_)=>{if(_===J)return Z;let j=Q*$.frequency,X=L.#o($.type,j,$.phase);return Z+$.offset+X*$.amplitude},0)}#WJ(J,Q){return L.#o(J.type,Q*J.frequency,J.phase)}#GJ({skipFieldSync:J=!1}={}){if(this.#v(),!J)this.#QJ();this.#ZJ(),this.#m()}#v(){for(let J of this.#k){let Q=this.#d(J);J.value=this.#Z[Q]?.type||"sine"}}#QJ(){for(let J of this.#N){if(J===this.#P)continue;let Q=this.#d(J),Z=J.getAttribute("name"),$=this.#g(this.#Z[Q]?.[Z]??0),_=J.querySelector("fig-slider");if(_)_.value=$;else J.setAttribute("value",String($))}}#ZJ(){for(let J of this.#W)if(this.#d(J)===this.#Q)J.setAttribute("data-active","");else J.removeAttribute("data-active")}#V(J){this.dispatchEvent(new CustomEvent(J,{bubbles:!0,detail:{value:this.value,data:this.data,preset:L.#i(this.#E.type)}}))}}customElements.define("propskit-oscillator",L);class c extends HTMLElement{#Z;#Q;#J=null;#j;#_;#Y;#X;#$;#q;constructor(){super();this.angle=0,this.#Z=1,this.#Q=0,this.isDragging=!1,this.isShiftHeld=!1,this.handle=null,this.angleInput=null,this.plane=null,this.units="°",this.min=null,this.max=null,this.dial=!0,this.showRotations=!1,this.rotationSpan=null,this.#j=this.#P.bind(this),this.#_=this.#x.bind(this),this.#Y=this.#E.bind(this),this.#X=this.#A.bind(this),this.#$=this.#w.bind(this),this.#q=this.#S.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.#D(),this.#G(),this.#L(),this.#F(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision))})}disconnectedCallback(){this.#T()}#G(){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}#D(){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.#N(),Q=this.min!==null?`min="${this.min}"`:"",Z=this.max!==null?`max="${this.max}"`:"";return`
|
|
36
|
-
${this.dial?`<div class="fig-input-angle-plane"
|
|
29
|
+
</fig-group>`}#jJ(J,Q,Z,$=null){let j=U.TYPES.map((X)=>{let Y=X.value===Q?" selected":"";return`<fig-select-option value="${X.value}" label="${X.name}"${Y}>
|
|
30
|
+
<span slot="prepend">${U.waveIcon(X.value,24)}</span>
|
|
31
|
+
<span>${X.name}</span>
|
|
32
|
+
</fig-select-option>`}).join(""),_=$===null?"":` data-wave-index="${U.#A(String($))}"`;return`<fig-select class="${J}" value="${Q}" label="Add form"${_}${Z}><fig-select-options>${j}</fig-select-options></fig-select>`}#a(J,Q,Z,$,j,_,X){let Y=this.#W()?" disabled":"",B=X?` units="${U.#A(X)}"`:"",G=this.#Z[J]||U.#F();return`<propskit-slider class="propskit-oscillator-field" label="${Z}" direction="horizontal" name="${Q}" data-wave-index="${J}" value="${this.#h(G[Q])}" min="${$}" max="${j}" step="${_}" precision="${this.#J}" elastic="false"${B}${Y}></propskit-slider>`}#_J(){this.#$=this.querySelector(".propskit-oscillator-svg"),this.#j=this.querySelector(".propskit-oscillator-path"),this.#G=this.querySelector(".propskit-oscillator-playhead"),this.#M=this.querySelector(".propskit-oscillator-baseline"),this.#k=this.querySelector(".propskit-oscillator-bounds"),this.#N=this.querySelector('[data-handle="amplitude"]'),this.#U=this.querySelector('[data-handle="frequency"]'),this.#O=Array.from(this.querySelectorAll(".propskit-oscillator-wave-type")),this.#q=Array.from(this.querySelectorAll("propskit-slider[name]")),this.#S=Array.from(this.querySelectorAll("fig-group.propskit-oscillator-wave")),this.#L=Array.from(this.querySelectorAll(".propskit-oscillator-fields"))}#r(J){let Q=new Set;for(let Z of this.#z)if(Z<J)Q.add(Z);else if(Z>J)Q.add(Z-1);this.#z=Q}#XJ(J){let Q=new Set;for(let Z of this.#z)Q.add(Z>=J?Z+1:Z);Q.add(J),this.#z=Q}#UJ(){if(this.#K||!window.ResizeObserver)return;this.#K=new ResizeObserver(()=>{if(this.#u())this.#l()}),this.#K.observe(this)}#u(){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.#B||Z!==this.#_;return this.#B=Q,this.#_=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.#c(Z/Q)));return{min:-J,max:J}}#JJ(J){let{min:Q,max:Z}=this.#P;return this.#_-(J-Q)/(Z-Q)*this.#_}#BJ(J){let{min:Q,max:Z}=this.#P;return Q+(1-J/this.#_)*(Z-Q)}#c(J){return this.#Z.reduce((Q,Z)=>{let $=J*Z.frequency,j=U.#o(Z.type,$,Z.phase);return Q+Z.offset+j*Z.amplitude},0)}#l(){if(!this.#$||!this.#j)return;if(this.#u(),this.#P=this.#kJ(),this.#k)this.#k.setAttribute("width",this.#B),this.#k.setAttribute("height",this.#_);let J=Math.max(...this.#Z.map((_)=>_.frequency)),Z=this.#Z.some((_)=>_.type==="square"||_.type==="sawtooth")?Math.max(192,Math.ceil(J*64)):Math.max(96,Math.ceil(J*64)),$="";for(let _=0;_<=Z;_++){let X=_/Z,Y=X*this.#B,B=this.#JJ(this.#c(X));$+=`${_===0?"M":"L"}${Y.toFixed(1)},${B.toFixed(1)}`}this.#j.setAttribute("d",$);let j=this.#JJ(0);this.#M?.setAttribute("x1","0"),this.#M?.setAttribute("y1",j),this.#M?.setAttribute("x2",this.#B),this.#M?.setAttribute("y2",j),this.#GJ()}#YJ(){if(this.#Y||!this.#G)return;let J=(Q)=>{if(!this.isConnected||!this.#G){this.#Y=0;return}this.#ZJ(Q%1000/1000),this.#Y=requestAnimationFrame(J)};this.#Y=requestAnimationFrame(J)}#PJ(){if(!this.#Y)return;cancelAnimationFrame(this.#Y),this.#Y=0}#ZJ(J){if(!this.#G)return;let Q=J*this.#B,Z=this.#JJ(this.#c(J));this.#G.setAttribute("cx",Q.toFixed(1)),this.#G.setAttribute("cy",Z.toFixed(1))}#GJ(){let Q=this.#E,Z=this.#WJ(),$=Math.max(8,Math.min(this.#B-8,this.#B/Q.frequency)),j=this.#JJ(this.#c(Z/this.#B)),_=this.#JJ(this.#c($/this.#B));this.#LJ(this.#N,Z,j,8),this.#LJ(this.#U,$,_,8)}#WJ(){let J=this.#E,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 j=($-Q)/Z;while(j<0)j+=1/Z;while(j>1)j-=1/Z;if(j<0||j>1||!Number.isFinite(j))j=0.25;return Math.max(8,Math.min(this.#B-8,j*this.#B))}#LJ(J,Q,Z,$){if(!J)return;J.setAttribute("x",Q-$),J.setAttribute("y",Z-$),J.setAttribute("width",$*2),J.setAttribute("height",$*2)}#RJ(){if(!this.#D()||this.#W())return;for(let Q of this.#O)Q.addEventListener("change",(Z)=>{if(this.#W())return;let $=this.#v(Q);this.#$J($),this.#Z[$].type=this.#V(Z.detail??Z.target?.value),this.#b(),this.#s("input"),this.#s("change")});for(let Q of this.#q)Q.addEventListener("input",(Z)=>{Z.stopPropagation(),this.#H=Q;try{this.#MJ(this.#v(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"input")}finally{this.#H=null}}),Q.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#MJ(this.#v(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"change")});for(let Q of this.#S)Q.addEventListener("pointerdown",()=>{this.#$J(this.#v(Q))}),Q.addEventListener("focusin",()=>{this.#$J(this.#v(Q))}),Q.addEventListener("openchange",(Z)=>{let $=this.#v(Q);if(Z.detail?.open)this.#z.add($);else this.#z.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.#W())return;let _=this.#v(Q)+1,X=this.#V($.detail??Q.value);this.#Z.splice(_,0,U.#F(X)),this.#XJ(_),this.#Q=_,this.#x(),this.#s("input"),this.#s("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.#W()||this.#Z.length<=1)return;let $=this.#v(Q);this.#Z.splice($,1),this.#r($),this.#Q=Math.min(this.#Q,this.#Z.length-1),this.#x(),this.#s("input"),this.#s("change")});for(let Q of[this.#N,this.#U])this.#VJ(Q);this.querySelector(".propskit-oscillator-svg-container")?.addEventListener("pointerdown",(Q)=>{if(this.#W())return;if(Q.target?.closest?.(".propskit-oscillator-handle, fig-handle"))return;this.#zJ(Q,"offset")})}#v(J){let Q=Number.parseInt(J?.getAttribute("data-wave-index")||"",10);return Number.isFinite(Q)?Math.min(this.#Z.length-1,Math.max(0,Q)):0}#VJ(J){let Q=J?.querySelector("fig-handle"),Z=J?.getAttribute("data-handle");if(!Q||!Z)return;Q.addEventListener("pointerdown",($)=>{if(this.#W())return;$.preventDefault(),$.stopImmediatePropagation(),this.#zJ($,Z)},{capture:!0}),Q.addEventListener("keydown",($)=>{if(this.#W())return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes($.key))return;if(!this.#SJ($,Z))return;$.preventDefault(),$.stopImmediatePropagation()},{capture:!0})}#$J(J){let Q=Math.min(this.#Z.length-1,Math.max(0,J));if(Q===this.#Q)return;this.#Q=Q,this.#t(),this.#GJ()}#MJ(J,Q,Z,$){if(this.#W())return;this.#$J(J);let j=Number.parseFloat(Z);if(!Number.isFinite(j)){if($==="change")this.#d();return}this.#Z[J]=this.#f({...this.#Z[J],[Q]:j}),this.#b({skipFieldSync:$=="input"}),this.#s($)}#SJ(J,Q){let Z=J.shiftKey?0.5:0.1,$=this.#E;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.#Z[this.#Q]=this.#f($),this.#b(),this.#s("input"),this.#s("change"),!0}#OJ(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}}#zJ(J,Q){this.#qJ(),this.#X=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 j=(Y)=>{if(!this.#X)return;let B=this.#OJ(Y),G=this.#E;if(Q==="frequency"){let k=Math.max(1,Math.min(this.#B,B.x));G.frequency=this.#B/k}else if(Q==="offset"){let k=this.#I(B.x/this.#B,0,0,1),P=this.#NJ(G,k);G.offset=this.#BJ(B.y)-this.#TJ(this.#Q,k)-P*G.amplitude}else if(Q==="amplitude"){let k=this.#I(B.x/this.#B,0,0,1),P=this.#NJ(G,k),q=this.#BJ(B.y)-this.#TJ(this.#Q,k)-G.offset;G.amplitude=Math.abs(P)<0.001?G.amplitude:q/P}this.#Z[this.#Q]=this.#f(G),this.#b(),this.#s("input")},_=new AbortController,X=(Y=!1)=>{if(this.#X=null,this.#$?.classList.remove("dragging"),Z)document.body.style.cursor=$;if(_.abort(),this.#C===_)this.#C=null,this.#T=null;if(Y)this.#s("change")};this.#C=_,this.#T=X,document.addEventListener("pointermove",j,{signal:_.signal}),document.addEventListener("pointerup",()=>X(!0),{signal:_.signal}),document.addEventListener("pointercancel",()=>X(!1),{signal:_.signal}),window.addEventListener("blur",()=>X(!1),{signal:_.signal})}#qJ(){this.#T?.(!1),this.#C?.abort(),this.#C=null,this.#T=null,this.#X=null,this.#$?.classList.remove("dragging")}#TJ(J,Q){return this.#Z.reduce((Z,$,j)=>{if(j===J)return Z;let _=Q*$.frequency,X=U.#o($.type,_,$.phase);return Z+$.offset+X*$.amplitude},0)}#NJ(J,Q){return U.#o(J.type,Q*J.frequency,J.phase)}#b({skipFieldSync:J=!1}={}){if(this.#n(),!J)this.#d();this.#t(),this.#l()}#n(){for(let J of this.#O){let Q=this.#v(J);J.value=this.#Z[Q]?.type||"sine"}}#d(){for(let J of this.#q){if(J===this.#H)continue;let Q=this.#v(J),Z=J.getAttribute("name"),$=this.#h(this.#Z[Q]?.[Z]??0),j=J.querySelector("fig-slider");if(j)j.value=$;else J.setAttribute("value",String($))}}#t(){for(let J of this.#L)if(this.#v(J)===this.#Q)J.setAttribute("data-active","");else J.removeAttribute("data-active")}#s(J){this.dispatchEvent(new CustomEvent(J,{bubbles:!0,detail:{value:this.value,data:this.data,preset:U.#m(this.#E.type)}}))}}z("propskit-oscillator",U);class D extends HTMLElement{#Z;#Q;#J=null;#B;#_;#P;#X;#$;#j;#G;#Y=null;#M=null;constructor(){super();this.angle=0,this.#Z=1,this.#Q=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.#B=this.#w.bind(this),this.#_=this.#m.bind(this),this.#P=this.#o.bind(this),this.#X=this.#p.bind(this),this.#$=this.#e.bind(this),this.#j=this.#y.bind(this),this.#G=this.#QJ.bind(this)}connectedCallback(){requestAnimationFrame(()=>{if(!this.isConnected)return;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.#N("dial",!0),this.showRotations=this.#U(),this.#k(),this.#D(),this.#A(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision))})}disconnectedCallback(){this.#x(),this.#W()}#k(){this.#x(),this.#W(),this.innerHTML=this.#q()}#N(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.#N("rotations",!1);if(this.hasAttribute("show-rotations"))return this.#N("show-rotations",!1);return!1}#q(){let J=this.#T(),Q=this.min!==null?`min="${this.min}"`:"",Z=this.max!==null?`max="${this.max}"`:"",$=this.#S(),j=this.getAttribute("aria-label")||this.getAttribute("name")||"Angle",_=this.min??this.#R(0),X=this.max??this.#R(360);return`
|
|
33
|
+
${this.dial?`<div class="fig-input-angle-plane"
|
|
34
|
+
role="slider"
|
|
35
|
+
tabindex="${$?-1:0}"
|
|
36
|
+
aria-label="${D.#L(j)}"
|
|
37
|
+
aria-valuemin="${_}"
|
|
38
|
+
aria-valuemax="${X}"
|
|
39
|
+
aria-valuenow="${this.angle}"
|
|
40
|
+
aria-valuetext="${D.#L(`${this.angle.toFixed(this.precision)}${this.units}`)}"
|
|
41
|
+
${$?'aria-disabled="true"':""}>
|
|
37
42
|
<div class="fig-input-angle-handle"></div>
|
|
38
43
|
</div>`:""}
|
|
39
44
|
${this.text?`<fig-input-number
|
|
@@ -42,85 +47,9 @@ function Y(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class y ex
|
|
|
42
47
|
value="${this.angle}"
|
|
43
48
|
${Q}
|
|
44
49
|
${Z}
|
|
45
|
-
units="${this.units}"
|
|
50
|
+
units="${this.units}"
|
|
51
|
+
aria-label="${D.#L(j)}"
|
|
52
|
+
${$?"disabled":""}>
|
|
46
53
|
${this.showRotations?'<span slot="append" class="fig-input-angle-rotations"></span>':""}
|
|
47
54
|
</fig-input-number>`:""}
|
|
48
|
-
`}#M(){let J=Math.abs(this.#k(this.angle));return Math.floor(J/360)}#U(){if(!this.rotationSpan)return;let J=this.#M();if(J>1)this.rotationSpan.textContent=`×${J}`,this.rotationSpan.style.display="";else this.rotationSpan.textContent="",this.rotationSpan.style.display="none"}#N(){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}}#H(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.#U(),this.plane?.addEventListener("mousedown",this.#_),this.plane?.addEventListener("touchstart",this.#Y),window.addEventListener("keydown",this.#X),window.addEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#q);this.addEventListener("change",this.#j,!0)}#T(){if(this.plane?.removeEventListener("mousedown",this.#_),this.plane?.removeEventListener("touchstart",this.#Y),window.removeEventListener("keydown",this.#X),window.removeEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#q);this.removeEventListener("change",this.#j,!0)}#P(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.#H($,_,this.units);J.target.value=String(j)}}}#S(J){J.stopPropagation(),this.angle=Number(J.target.value),this.#O(),this.#F(),this.#U(),this.#b(),this.#C()}#O(){let Q=this.#k(this.angle)*Math.PI/180;this.#Z=Math.cos(Q),this.#Q=Math.sin(Q)}#R(J){if(!this.isShiftHeld)return J;let Q=45;return Math.round(J/Q)*Q}#f(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}#z(J){let Z=(this.#f(J)%360+360)%360;if(Z=this.#R(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,X=Z-j;if(X>180)X-=360;if(X<-180)X+=360;this.angle+=this.#W(X)}else{let _=Z-this.#J;if(_>180)_-=360;if(_<-180)_+=360;this.angle+=this.#W(_),this.#J=Z}if(this.#O(),this.#F(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#U(),this.#b()}#b(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#C(){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)`}}#x(J){this.isDragging=!0,this.#J=null,this.#z(J);let Q=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#z($)},Z=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("mousemove",Q),window.removeEventListener("mouseup",Z),this.#C()};window.addEventListener("mousemove",Q),window.addEventListener("mouseup",Z)}#E(J){J.preventDefault(),this.isDragging=!0,this.#J=null,this.#z(J.touches[0]);let Q=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#z($.touches[0])},Z=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("touchmove",Q),window.removeEventListener("touchend",Z),this.#C()};window.addEventListener("touchmove",Q),window.addEventListener("touchend",Z)}#A(J){if(J.key==="Shift")this.isShiftHeld=!0}#w(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.#Z}get opposite(){return this.#Q}set value(J){if(isNaN(J)){console.error("Invalid value: must be a number.");return}if(this.angle=J,this.#O(),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.#G(),this.#L(),this.#F()}break;case"dial":if(this.dial=this.#B("dial",!0),this.isConnected)this.#G(),this.#L(),this.#F();break;case"units":{let $=Z||"°";if($==="deg")$="°";if(this.units=$,this.isConnected)this.#G(),this.#L(),this.#F();break}case"min":if(this.min=Z!==null?Number(Z):null,this.isConnected)this.#G(),this.#L(),this.#F();break;case"max":if(this.max=Z!==null?Number(Z):null,this.isConnected)this.#G(),this.#L(),this.#F();break;case"rotations":case"show-rotations":if(this.showRotations=this.#D(),this.isConnected)this.#G(),this.#L(),this.#F();break}}}customElements.define("fig-input-angle",c);class S extends HTMLElement{static observedAttributes=["axis","handle","disabled"];static#Z=6;static#Q=["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;#j=new Map;#_=null;#Y=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.#x(),this.#z()}attributeChangedCallback(){if(this.isConnected)this.#B()}get#X(){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()}#G(){return[...this.children].filter((J)=>J.nodeType===Node.ELEMENT_NODE)}#B(){let J=this.#G(),Q=new Set(J);for(let[Z,$]of this.#j)if(!Q.has(Z))$.target.removeEventListener("pointerdown",$.onPointerDown,!0),this.#j.delete(Z);if(this.#M(J),this.#D(J),this.#X||J.length<2){this.#F();return}for(let Z of J){let $=this.#N(Z),_=this.#j.get(Z);if(_&&_.target===$)continue;if(_)_.target.removeEventListener("pointerdown",_.onPointerDown,!0),this.#j.delete(Z);if(!$)continue;this.#k(Z,$)}this.#U(J),this.#K(J)}#D(J){for(let Q of J)Q.removeAttribute("data-reorder-item")}#K(J){for(let Q of J)Q.setAttribute("data-reorder-item","")}#M(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","")}}#N(J){if(this.#q)return J.querySelector(this.#q);return J}#k(J,Q){let Z=($)=>{if(this.#X||this.#G().length<2)return;if($.button!==0)return;if(!this.#q&&this.#W($.target,J))return;this.#T($,J,Q)};Q.addEventListener("pointerdown",Z,!0),this.#j.set(J,{target:Q,onPointerDown:Z})}#W(J,Q){let Z=J;while(Z&&Z!==Q){if(Z instanceof Element){for(let $ of S.#Q)if(Z.matches($))return!0}Z=Z.parentElement}return!1}static#H="fig-reorder-dragging";static#L(J){document.body.classList.toggle(S.#H,J)}#T(J,Q,Z){this.#x(),S.#L(!0);let $={item:Q,target:Z,pointerId:J.pointerId,oldIndex:this.#G().indexOf(Q),targetIndex:this.#G().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<S.#Z*S.#Z)return;$.active=!0,J.preventDefault(),J.stopPropagation(),Q.classList.add("dragging");try{Z.setPointerCapture($.pointerId)}catch{}}_.preventDefault();let G=this.#$==="horizontal"?_.clientX:_.clientY,q=this.#P(G);$.targetIndex=q,this.#f(q,Q)},$.onKeyDown=(_)=>{if(_.key!=="Escape"||!$.active)return;_.preventDefault(),this.#C($,!0)},$.onUp=(_)=>{if(_.pointerId!==$.pointerId)return;this.#C($,_.type==="pointercancel")},this.#_=$,window.addEventListener("pointermove",$.onMove),window.addEventListener("pointerup",$.onUp),window.addEventListener("pointercancel",$.onUp),window.addEventListener("keydown",$.onKeyDown)}#P(J){let Q=this.#G(),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}#S(J,Q){let Z=this.#G(),$=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}#O(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:_-$}}#R(){if(this.#Y)return this.#Y;let J=document.createElement("div");return J.className="fig-reorder-indicator",J.setAttribute("data-axis",this.#$),document.body.appendChild(J),this.#Y=J,J}#f(J,Q){let Z=this.#G();if(!this.#S(Q,J)){this.#z();return}let $=this.#O(Z);if(!$){this.#z();return}let _=this.#R();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"}#z(){this.#Y?.remove(),this.#Y=null}#b(J,Q){let Z=this.#G(),$=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,_)}#C(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.#b(Z,J.targetIndex);let q=this.#G().indexOf(Z);if(q!==-1&&q!==$)this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:$,newIndex:q,item:Z}}))}}if(Z.classList.remove("dragging"),S.#L(!1),this.#z(),this.#_===J)this.#_=null}#F(){for(let[,J]of this.#j)J.target.removeEventListener("pointerdown",J.onPointerDown,!0);this.#j.clear()}#x(){if(!this.#_)return;this.#C(this.#_,!0)}}customElements.define("fig-reorder",S);var f=0;function v(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 i(J){if(J&&typeof J==="object")return String(J.value??J.label??"");return String(J??"")}function o(J){if(J&&typeof J==="object")return String(J.label??J.value??"");return String(J??"")}class u extends HTMLElement{static get observedAttributes(){return["value","disabled","selected","label"]}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 Y(this,"disabled")}set disabled(J){if(J)this.setAttribute("disabled","");else this.removeAttribute("disabled")}get selected(){return Y(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.#Z()}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="disabled")this.#Z()}#Z(){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",u);function a(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 E(J,Q=1){if(!J)return;J.scrollBy({top:J.clientHeight*0.8*Q,behavior:"smooth"})}function n({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 X=document.createElement("fig-icon");return X.setAttribute("name","chevron"),X.setAttribute("size","small"),X.className="fig-overflow-chevron",j.appendChild(X),j.addEventListener("click",(G)=>{G.preventDefault(),G.stopPropagation(),_?.(G)}),j};return{start:Z("start",J),end:Z("end",Q)}}class s extends HTMLElement{#Z=null;#Q=null;#J=null;#j=this.syncOverflow.bind(this);connectedCallback(){if(!this.hasAttribute("slot"))this.setAttribute("slot","panel");this.#_(),this.#Y(),this.addEventListener("scroll",this.#j,{passive:!0}),this.#J?.disconnect(),this.#J=new ResizeObserver(()=>this.syncOverflow()),this.#J.observe(this),requestAnimationFrame(()=>this.syncOverflow())}disconnectedCallback(){this.removeEventListener("scroll",this.#j),this.#J?.disconnect(),this.#J=null,this.#X()}syncOverflow(){return a(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,X=Math.max(0,Math.min(_+Z.height/2-this.clientHeight/2,j));this.scrollTo({top:X,behavior:Q}),this.syncOverflow()})}#_(){let J=this.querySelector(":scope > fig-chooser");if(!J)return;while(J.firstChild)this.insertBefore(J.firstChild,J);J.remove()}#Y(){if(this.#Z&&this.#Q&&this.contains(this.#Z)&&this.contains(this.#Q))return;this.#X();let J=n({onStart:()=>E(this,-1),onEnd:()=>E(this,1)});this.#Z=J.start,this.#Q=J.end,this.prepend(this.#Z),this.append(this.#Q)}#X(){this.#Z?.remove(),this.#Q?.remove(),this.#Z=null,this.#Q=null,this.classList.remove("overflow-start","overflow-end")}}customElements.define("fig-select-options",s);class r extends HTMLElement{#Z=null;#Q=null;#J=null;#j=null;#_=null;#Y=!1;#X=-1;#$=!1;#q=!1;#G=null;#B=!1;#D=null;#K=null;#M=!1;#U=this.#n.bind(this);#N=this.#YJ.bind(this);#k=this.#p.bind(this);#W=this.#_J.bind(this);#H=this.#u.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 Y(this,"open")}set open(J){if(J)this.setAttribute("open","");else this.removeAttribute("open")}connectedCallback(){if(!this.#Y)this.#f();if(this.#T(),this.#R(),this.#a(),this.#r(),this.#y(),this.#jJ(),this.open)this.#BJ()}disconnectedCallback(){this.#o(),document.removeEventListener("keydown",this.#k,!0),this.#_?.disconnect(),this.#_=null}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Y)return;if(J==="options"){this.#R(),this.#y();return}if(J==="value"||J==="label"){this.#y();return}if(J==="disabled"){this.#a();return}if(J==="open"){if(Z===null||Z==="false")this.#NJ();else this.#BJ();return}if(J==="position"||J==="offset"||J==="closedby")this.#r()}focus(J){this.#Z?.focus(J)}blur(){this.#Z?.blur()}#L(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")}#P(){let Q=(this.#j?.assignedElements({flatten:!0})??[]).find((Z)=>Z.tagName==="FIG-SELECT-OPTIONS");if(Q)return Q;return this.querySelector(":scope > fig-select-options")}#S(){return Boolean(this.querySelector(":scope > fig-select-option:not([data-fig-generated]), :scope > fig-select-options > fig-select-option:not([data-fig-generated])"))}#O(){let J=this.#P();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}#R(){if(this.#S())return;let J=this.hasAttribute("options"),Q=J?this.#O():this.#P();if(!Q)return;this.#M=!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",i(_)),j.textContent=o(_),$)Q.insertBefore(j,$);else Q.appendChild(j)}}finally{this.#M=!1}}#f(){this.#Y=!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"});if($.setAttribute("is","fig-popup"),$.setAttribute("part","listbox"),$.setAttribute("theme","menu"),$.setAttribute("role","listbox"),"popover"in HTMLElement.prototype)$.setAttribute("popover","manual");$.id=v("fig-select-list"),Q.setAttribute("aria-controls",$.id);let _=document.createElement("slot");if(_.setAttribute("name","panel"),$.appendChild(_),J.append(Q,$),this.#Z=Q,this.#J=Z,this.#Q=$,this.#j=_,$.anchor=Q,this.#T(),this.#i(),this.#z(),!this.hasAttribute("value")){let j=this.#I().find((X)=>Y(X,"selected"));if(j)this.setAttribute("value",j.value)}}#z(){if(!this.#Q||this.#q)return;if(typeof this.#Q.positionPopup!=="function")return;this.#G=this.#Q.positionPopup.bind(this.#Q),this.#Q.positionPopup=()=>{if(!this.open){this.#G?.();return}this.#l()},this.#q=!0}#b(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()}#C(){if(typeof this.#Q?.parseViewportMargins==="function")return this.#Q.parseViewportMargins();return{top:8,right:8,bottom:8,left:8}}#F(){let J=this.#J?.getBoundingClientRect();if(!J)return null;return{x:J.x,y:J.y,width:J.width,height:J.height}}#x(){let J=window.visualViewport;return{width:J?.width??window.innerWidth,height:J?.height??window.innerHeight,offsetLeft:J?.offsetLeft??0,offsetTop:J?.offsetTop??0}}#E(J,Q,Z=0.25){if(!J&&!Q)return!1;if(!J||!Q)return!0;return Math.abs(J.x-Q.x)>Z||Math.abs(J.y-Q.y)>Z||Math.abs(J.width-Q.width)>Z||Math.abs(J.height-Q.height)>Z}#A(J,Q,Z=0.25){if(!J&&!Q)return!1;if(!J||!Q)return!0;return Math.abs(J.width-Q.width)>Z||Math.abs(J.height-Q.height)>Z||Math.abs(J.offsetLeft-Q.offsetLeft)>Z||Math.abs(J.offsetTop-Q.offsetTop)>Z}#w(){if(!this.#B)return!1;let J=this.#E(this.#D,this.#F()),Q=this.#A(this.#K,this.#x());return!J&&!Q}#g(){this.#D=this.#F(),this.#K=this.#x()}#l(){if(this.#w())return;let J=this.#Q,Q=this.#J;if(!J||!Q){this.#G?.();return}let Z=this.#I(),$=Z.find((k)=>this.#s(k)===this.value)||Z[0];if(!$){this.#G?.();return}this.#G?.();let _=J.getBoundingClientRect(),j=Q.getBoundingClientRect(),X=this.#b($);if(!_.width||!_.height||!j.width||!X)return;let G=X.left-_.left,q=X.top-_.top,N=Y(this,"full")?this.getBoundingClientRect().left:j.left-G,K=j.top-q,U=this.#C();if(typeof J.clampToViewport==="function")({left:N,top:K}=J.clampToViewport({left:N,top:K},_,U));else{let{left:k,top:D}=U,P=window.innerWidth-_.width-U.right,T=window.innerHeight-_.height-U.bottom;N=Math.min(Math.max(N,k),Math.max(k,P)),K=Math.min(Math.max(K,D),Math.max(D,T))}J.style.setProperty("right","auto","important"),J.style.setProperty("bottom","auto","important"),J.style.setProperty("left",`${Math.round(N)}px`,"important"),J.style.setProperty("top",`${Math.round(K)}px`,"important");let M=this.#P(),W=this.#b($);if(W&&M&&M.scrollHeight>M.clientHeight+1){let k=W.top-j.top;if(Math.abs(k)>0.5)M.scrollTop+=k;M.syncOverflow?.()}if(this.#B||this.open)this.#g()}#i(){this.#Z?.addEventListener("click",this.#U),this.#Z?.addEventListener("keydown",this.#k),this.addEventListener("click",this.#N),this.#Q?.addEventListener("keydown",this.#k),this.#Q?.addEventListener("close",this.#W),this.#j?.addEventListener("slotchange",this.#H)}#o(){this.#Z?.removeEventListener("click",this.#U),this.#Z?.removeEventListener("keydown",this.#k),this.removeEventListener("click",this.#N),this.#Q?.removeEventListener("keydown",this.#k),this.#Q?.removeEventListener("close",this.#W),this.#j?.removeEventListener("slotchange",this.#H)}#u(){this.#T(),this.#y()}#jJ(){if(this.#_)return;this.#_=new MutationObserver((J)=>{if(this.#$||this.#M)return;let Q=!1;for(let Z of J){if(Z.type==="childList"){if([...Z.addedNodes].some(($)=>this.#L($))||[...Z.removedNodes].some(($)=>this.#L($)))Q=!0}if(Z.type==="attributes"&&Z.target?.tagName==="FIG-SELECT-OPTION"&&(Z.attributeName==="value"||Z.attributeName==="disabled"||Z.attributeName==="label"))Q=!0;if(Z.type==="characterData"&&Z.target?.parentElement?.tagName==="FIG-SELECT-OPTION")Q=!0}if(Q)this.#y()}),this.#_.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","disabled","selected","label"]})}#I({enabledOnly:J=!1}={}){let Q=this.#P(),Z=Q?Array.from(Q.querySelectorAll(":scope > fig-select-option")):[];if(!J)return Z;return Z.filter(($)=>!Y($,"disabled"))}#s(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()}#XJ(J){if(!J)return"";let Q=J.getAttribute?.("label");if(Q!=null&&Q!=="")return Q.trim();let Z=[];for(let $ of J.childNodes){if($.nodeType===Node.TEXT_NODE){let X=$.textContent?.trim();if(X)Z.push(X);continue}if(!($ instanceof Element))continue;let _=$.getAttribute("slot");if(_==="prepend"||_==="append")continue;let j=$.textContent?.trim();if(j)Z.push(j)}if(Z.length)return Z.join(" ").trim();return(J.textContent||"").trim()}#r(){if(!this.#Q)return;this.#Q.setAttribute("position",this.getAttribute("position")||"bottom left");let J=this.getAttribute("offset");if(J)this.#Q.setAttribute("offset",J);else this.#Q.removeAttribute("offset");let Q=this.getAttribute("closedby");if(Q)this.#Q.setAttribute("closedby",Q);else this.#Q.removeAttribute("closedby")}#a(){let J=Y(this,"disabled");if(this.#Z)if(J)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(J&&this.open)this.open=!1}#e(J){if(!J.length)return null;let Q=J.find((Z)=>Y(Z,"selected"));if(Q&&!Y(Q,"disabled"))return Q;return J.find((Z)=>!Y(Z,"disabled"))||J[0]||null}#$J(J){this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}#y(){if(this.#$)return;this.#$=!0;try{let J=this.#I(),Q=this.hasAttribute("value"),Z=Q?this.getAttribute("value"):null,$=Q?J.find((G)=>this.#s(G)===Z):null,_=!1;if(!$){if(Q){if(!J.length){if(this.#J)this.#J.textContent=Z||this.getAttribute("label")||"";return}if($=this.#e(J),$){let G=this.#s($);if(Z!==G)this.setAttribute("value",G),_=!0}else this.removeAttribute("value"),_=!0}else if($=J.find((G)=>Y(G,"selected")),$)this.setAttribute("value",this.#s($)),_=!0}for(let G of J){let q=G===$;if(G.setAttribute("aria-selected",q?"true":"false"),q)G.setAttribute("selected","");else G.removeAttribute("selected")}let j=$&&this.#XJ($)||this.getAttribute("label")||"";if(this.#J)this.#J.textContent=j;let X=this.getAttribute("label")||"Select";if(this.#Z?.setAttribute("aria-label",X),this.#P()?.syncOverflow?.(),_)this.#$J(this.getAttribute("value")??"")}finally{this.#$=!1}}#n(J){if(Y(this,"disabled"))return;J.preventDefault(),J.stopPropagation();let Q=!this.open;if(Q&&this.#Q&&this.#Z)this.#Q.anchor=this.#Z;this.open=Q}#YJ(J){let Z=(typeof J.composedPath==="function"?J.composedPath():[]).find(($)=>$?.tagName==="FIG-SELECT-OPTION");if(!Z||!this.contains(Z))return;if(Y(Z,"disabled"))return;this.#h(Z)}#p(J){if(J.currentTarget===document&&J.key!=="Escape")return;if(!(this.open&&(this.#Q?.matches?.(":open")??!1))){if(this.#Z?.contains(J.target)&&(J.key==="ArrowDown"||J.key==="Enter"||J.key===" ")){if(J.preventDefault(),this.#Q&&this.#Z)this.#Q.anchor=this.#Z;this.open=!0,requestAnimationFrame(()=>{let _=this.#I({enabledOnly:!0}).findIndex((j)=>this.#s(j)===this.value);this.#c(_>=0?_:0)})}return}let Z=this.#I({enabledOnly:!0});if(!Z.length)return;switch(J.key){case"ArrowDown":J.preventDefault(),this.#JJ(),this.#c(this.#X+1);break;case"ArrowUp":J.preventDefault(),this.#JJ(),this.#c(this.#X-1);break;case"Home":J.preventDefault(),this.#c(0);break;case"End":J.preventDefault(),this.#c(Z.length-1);break;case"Escape":J.preventDefault(),this.open=!1,this.#Z?.focus();break;case"Enter":case" ":{this.#JJ();let $=Z[this.#X];if(!$)return;J.preventDefault(),this.#h($);break}}}#_J(){if(this.hasAttribute("open"))this.removeAttribute("open");this.#Z?.setAttribute("aria-expanded","false"),this.#Z?.focus(),this.#X=-1}#h(J){let Q=this.#s(J);this.setAttribute("value",Q),this.#y(),this.#$J(Q),this.open=!1}#m(){return this.#I({enabledOnly:!0})}#JJ(){let J=this.#m();if(!J.length){this.#X=-1;return}let Q=J.find(($)=>$===document.activeElement),Z=Q?J.indexOf(Q):-1;this.#X=Z>=0?Z:this.#X}#c(J){let Q=this.#m();if(!Q.length)return;let Z=(J%Q.length+Q.length)%Q.length;this.#X=Z,Q[Z]?.focus()}#t(){if(!this.#Q||!this.#Z)return;let J=Math.ceil(this.getBoundingClientRect().width),Q=Math.ceil(this.#Z.getBoundingClientRect().width),Z=Math.max(J,Q,96);if(Y(this,"full"))this.#Q.style.setProperty("width",`${Z}px`,"important"),this.#Q.style.setProperty("min-width",`${Z}px`,"important"),this.#Q.style.setProperty("max-width",`${Z}px`,"important");else this.#Q.style.setProperty("width","max-content","important"),this.#Q.style.setProperty("min-width",`${Z}px`,"important"),this.#Q.style.setProperty("max-width","min(20rem, calc(100vw - 1rem))","important")}#BJ(){if(!this.#Q||Y(this,"disabled"))return;if(this.#Z)this.#Q.anchor=this.#Z;this.#z(),this.#B=!1,this.#D=null,this.#K=null,this.#y(),this.#t(),this.#Q.open=!0,document.addEventListener("keydown",this.#k,!0),this.#Z?.setAttribute("aria-expanded","true"),this.#X=-1,requestAnimationFrame(()=>{this.#t(),this.#l();let J=this.#P(),Z=this.#m().findIndex(($)=>this.#s($)===this.value);if(Z>=0)this.#c(Z);else if(this.#Z?.hasAttribute("data-focus-visible")||this.#Z?.matches?.(":focus-visible"))this.#c(0);J?.syncOverflow?.(),this.#B=!0,this.#g()})}#NJ(){if(!this.#Q)return;this.#B=!1,this.#D=null,this.#K=null,document.removeEventListener("keydown",this.#k,!0),this.#Q.open=!1,this.#Z?.setAttribute("aria-expanded","false")}}customElements.define("fig-select",r);
|
|
55
|
+
`}#O(){let J=Math.abs(this.#F(this.angle));return Math.floor(J/360)}static#L(J){return String(J).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}#S(){return M(this,"disabled")}#z(J){let Q=Number(J);if(!Number.isFinite(Q))return this.angle;if(this.min!==null&&Number.isFinite(this.min))Q=Math.max(this.min,Q);if(this.max!==null&&Number.isFinite(this.max))Q=Math.min(this.max,Q);return Q}#K(J,{reflect:Q=!0}={}){let Z=this.#z(J);if(this.angle=Z,this.#f(),Q){let $=String(Z);if(this.getAttribute("value")!==$)this.setAttribute("value",$)}if(this.#A(),this.angleInput)this.angleInput.value=Z.toFixed(this.precision);this.#H(),this.#C()}#H(){if(!this.plane)return;this.plane.setAttribute("aria-valuenow",String(this.angle)),this.plane.setAttribute("aria-valuetext",`${this.angle.toFixed(this.precision)}${this.units}`)}#C(){if(!this.rotationSpan)return;let J=this.#O();if(J>1)this.rotationSpan.textContent=`×${J}`,this.rotationSpan.style.display="";else this.rotationSpan.textContent="",this.rotationSpan.style.display="none"}#T(){switch(this.units){case"rad":return 0.01;case"turn":return 0.001;default:return 0.1}}#F(J){switch(this.units){case"rad":return J*180/Math.PI;case"turn":return J*360;default:return J}}#R(J){switch(this.units){case"rad":return J*Math.PI/180;case"turn":return J/360;default:return J}}#g(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 $}}#D(){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.#C(),this.plane?.addEventListener("mousedown",this.#_),this.plane?.addEventListener("touchstart",this.#P),this.plane?.addEventListener("keydown",this.#G),window.addEventListener("keydown",this.#X),window.addEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#j),this.angleInput.addEventListener("change",this.#j);this.addEventListener("change",this.#B,!0)}#W(){if(this.plane?.removeEventListener("mousedown",this.#_),this.plane?.removeEventListener("touchstart",this.#P),this.plane?.removeEventListener("keydown",this.#G),window.removeEventListener("keydown",this.#X),window.removeEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#j),this.angleInput.removeEventListener("change",this.#j);this.removeEventListener("change",this.#B,!0)}#w(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]),j=Z[2].toLowerCase();if(j==="deg")j="°";if(j!==this.units){let _=this.#g($,j,this.units);J.target.value=String(_)}}}#y(J){if(J.stopPropagation(),this.#S())return;if(this.#K(Number(J.target.value)),J.type==="change")this.#h();else this.#I()}#f(){let Q=this.#F(this.angle)*Math.PI/180;this.#Z=Math.cos(Q),this.#Q=Math.sin(Q)}#i(J){if(!this.isShiftHeld)return J;let Q=45;return Math.round(J/Q)*Q}#E(J){let Q=this.plane.getBoundingClientRect(),Z=Q.left+Q.width/2,$=Q.top+Q.height/2,j=J.clientX-Z,_=J.clientY-$;return Math.atan2(_,j)*180/Math.PI}#V(J){let Z=(this.#E(J)%360+360)%360;if(Z=this.#i(Z),this.min!==null||this.max!==null)this.angle=this.#z(this.#R(Z));else if(this.#J===null){this.#J=Z;let _=(this.#F(this.angle)%360+360)%360,X=Z-_;if(X>180)X-=360;if(X<-180)X+=360;this.angle=this.#z(this.angle+this.#R(X))}else{let j=Z-this.#J;if(j>180)j-=360;if(j<-180)j+=360;this.angle=this.#z(this.angle+this.#R(j)),this.#J=Z}if(this.#f(),this.setAttribute("value",String(this.angle)),this.#A(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#C(),this.#H(),this.#I()}#I(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#h(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#A(){if(this.handle){let Q=this.#F(this.angle)*Math.PI/180,Z=this.plane.offsetWidth/2-this.handle.offsetWidth/2,$=Math.cos(Q)*Z,j=Math.sin(Q)*Z;this.handle.style.transform=`translate(${$}px, ${j}px)`}}#m(J){if(this.#S()||J.button!==0)return;this.#x(),this.isDragging=!0,this.#J=null,this.#V(J);let Q=(j)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#V(j)},Z=new AbortController,$=(j=!1)=>{if(this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),Z.abort(),this.#Y===Z)this.#Y=null,this.#M=null;if(j)this.#h()};this.#Y=Z,this.#M=$,window.addEventListener("mousemove",Q,{signal:Z.signal}),window.addEventListener("mouseup",()=>$(!0),{signal:Z.signal}),window.addEventListener("blur",()=>$(!1),{signal:Z.signal})}#o(J){if(this.#S())return;J.preventDefault(),this.#x(),this.isDragging=!0,this.#J=null,this.#V(J.touches[0]);let Q=(j)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#V(j.touches[0])},Z=new AbortController,$=(j=!1)=>{if(this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),Z.abort(),this.#Y===Z)this.#Y=null,this.#M=null;if(j)this.#h()};this.#Y=Z,this.#M=$,window.addEventListener("touchmove",Q,{signal:Z.signal}),window.addEventListener("touchend",()=>$(!0),{signal:Z.signal}),window.addEventListener("touchcancel",()=>$(!1),{signal:Z.signal})}#x(){this.#M?.(!1),this.#Y?.abort(),this.#Y=null,this.#M=null,this.isDragging=!1,this.#J=null,this.plane?.classList.remove("dragging")}#QJ(J){if(this.#S())return;let Q=this.#T()*(J.shiftKey?10:1),Z=this.angle;if(J.key==="ArrowLeft"||J.key==="ArrowDown")Z-=Q;else if(J.key==="ArrowRight"||J.key==="ArrowUp")Z+=Q;else if(J.key==="Home")Z=this.min??this.#R(0);else if(J.key==="End")Z=this.max??this.#R(360);else return;J.preventDefault(),J.stopPropagation(),this.#K(Z),this.#I(),this.#h()}#p(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","disabled","aria-label","name"]}get value(){return this.angle}get adjacent(){return this.#Z}get opposite(){return this.#Q}set value(J){if(isNaN(J)){console.error("Invalid value: must be a number.");return}this.#K(Number(J))}attributeChangedCallback(J,Q,Z){switch(J){case"value":if(this.isDragging)break;if(Z!==null)this.#K(Number(Z),{reflect:!1});break;case"precision":this.precision=parseInt(Z);break;case"text":if(Z!==Q){if(this.text=Z?.toLowerCase()==="true",this.isConnected)this.#k(),this.#D(),this.#A()}break;case"dial":if(this.dial=this.#N("dial",!0),this.isConnected)this.#k(),this.#D(),this.#A();break;case"units":{let $=Z||"°";if($==="deg")$="°";if(this.units=$,this.isConnected)this.#k(),this.#D(),this.#A();break}case"min":if(this.min=Z!==null?Number(Z):null,this.#K(this.angle),this.isConnected)this.#k(),this.#D(),this.#A();break;case"max":if(this.max=Z!==null?Number(Z):null,this.#K(this.angle),this.isConnected)this.#k(),this.#D(),this.#A();break;case"disabled":if(this.#x(),this.isConnected)this.#k(),this.#D(),this.#A();break;case"aria-label":case"name":if(this.isConnected)this.#k(),this.#D(),this.#A();break;case"rotations":case"show-rotations":if(this.showRotations=this.#U(),this.isConnected)this.#k(),this.#D(),this.#A();break}}}z("fig-input-angle",D);class H extends HTMLElement{static observedAttributes=["axis","handle","disabled"];static#Z=6;static#Q=["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;#B=new Map;#_=null;#P=null;#X=null;connectedCallback(){if(this.style.display="contents",!this.hasAttribute("role"))this.setAttribute("role","list");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Reorderable list");this.#z(),this.#M(),this.#J=new MutationObserver(()=>this.#M()),this.#J.observe(this,{childList:!0})}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#V(),this.#I(),this.#y(),this.#X?.remove(),this.#X=null}attributeChangedCallback(){if(this.isConnected){if(this.#$)this.#I();this.#M()}}get#$(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}get#j(){return(this.getAttribute("axis")||"vertical").trim().toLowerCase()==="horizontal"?"horizontal":"vertical"}get#G(){return(this.getAttribute("handle")||"").trim()}#Y(){return[...this.children].filter((J)=>J.nodeType===Node.ELEMENT_NODE&&!J.hasAttribute("data-reorder-live"))}#M(){let J=this.#Y(),Q=new Set(J);for(let[Z,$]of this.#B)if(!Q.has(Z))$.target.removeEventListener("pointerdown",$.onPointerDown,!0),$.target.removeEventListener("keydown",$.onKeyDown),this.#S($),this.#B.delete(Z);if(this.#U(J),this.#k(J),this.#$||J.length<2){this.#V();return}for(let Z of J){let $=this.#O(Z),j=this.#B.get(Z);if(j&&j.target===$)continue;if(j)j.target.removeEventListener("pointerdown",j.onPointerDown,!0),this.#B.delete(Z);if(!$)continue;this.#L(Z,$)}this.#q(J),this.#N(J)}#k(J){for(let Q of J)if(Q.removeAttribute("data-reorder-item"),Q.hasAttribute("data-reorder-generated-role"))Q.removeAttribute("role"),Q.removeAttribute("data-reorder-generated-role")}#N(J){for(let Q of J)if(Q.setAttribute("data-reorder-item",""),!Q.hasAttribute("role"))Q.setAttribute("role","listitem"),Q.setAttribute("data-reorder-generated-role","")}#U(J){for(let Q of J)Q.querySelectorAll("[data-reorder-handle]").forEach((Z)=>{Z.removeAttribute("data-reorder-handle"),Z.removeAttribute("aria-roledescription")})}#q(J){if(!this.#G)return;for(let Q of J){let Z=Q.querySelector(this.#G);if(Z)Z.setAttribute("data-reorder-handle",""),Z.setAttribute("aria-roledescription","reorder handle")}}#O(J){if(this.#G)return J.querySelector(this.#G);return J}#L(J,Q){let Z=(B)=>{if(this.#$||this.#Y().length<2)return;if(B.button!==0)return;if(!this.#G&&this.#H(B.target,J))return;this.#F(B,J,Q)},$=Q.getAttribute("tabindex"),j=Q.getAttribute("aria-label"),_=Q.getAttribute("role"),X=J.getAttribute("aria-label")||J.textContent?.trim().replace(/\s+/g," ").slice(0,80)||"item";if(Q.setAttribute("tabindex","0"),Q.setAttribute("aria-label",`Move ${X}`),Q!==J&&!Q.hasAttribute("role"))Q.setAttribute("role","button");let Y=(B)=>{if(this.#$)return;let G=this.#j==="horizontal",k=G?"ArrowLeft":"ArrowUp",P=G?"ArrowRight":"ArrowDown";if(B.key!==k&&B.key!==P&&B.key!=="Home"&&B.key!=="End")return;B.preventDefault(),B.stopPropagation();let q=this.#Y(),O=q.indexOf(J),N=O;if(B.key===k)N=Math.max(0,O-1);else if(B.key===P)N=Math.min(q.length-1,O+1);else if(B.key==="Home")N=0;else if(B.key==="End")N=q.length-1;if(N===O){this.#K(`${X}, position ${O+1} of ${q.length}`);return}this.#i(J,N),this.#M(),this.#O(J)?.focus(),this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:O,newIndex:N,item:J}})),this.#K(`${X}, position ${N+1} of ${q.length}`)};Q.addEventListener("pointerdown",Z,!0),Q.addEventListener("keydown",Y),this.#B.set(J,{target:Q,onPointerDown:Z,onKeyDown:Y,originalTabIndex:$,originalAriaLabel:j,originalRole:_})}#S(J){let{target:Q,originalTabIndex:Z,originalAriaLabel:$,originalRole:j}=J;if(Z===null)Q.removeAttribute("tabindex");else Q.setAttribute("tabindex",Z);if($===null)Q.removeAttribute("aria-label");else Q.setAttribute("aria-label",$);if(j===null)Q.removeAttribute("role");else Q.setAttribute("role",j)}#z(){if(this.#X?.isConnected)return;let J=document.createElement("span");J.setAttribute("data-reorder-live",""),J.setAttribute("role","status"),J.setAttribute("aria-live","polite"),J.setAttribute("aria-atomic","true"),Object.assign(J.style,{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}),this.#X=J,document.body.appendChild(J)}#K(J){if(!this.#X)return;this.#X.textContent="",requestAnimationFrame(()=>{if(this.#X)this.#X.textContent=J})}#H(J,Q){let Z=J;while(Z&&Z!==Q){if(Z instanceof Element){for(let $ of H.#Q)if(Z.matches($))return!0}Z=Z.parentElement}return!1}static#C="fig-reorder-dragging";static#T(J){document.body.classList.toggle(H.#C,J)}#F(J,Q,Z){this.#I(),H.#T(!0);let $={item:Q,target:Z,pointerId:J.pointerId,oldIndex:this.#Y().indexOf(Q),targetIndex:this.#Y().indexOf(Q),startX:J.clientX,startY:J.clientY,active:!1,onMove:null,onUp:null,onKeyDown:null};$.onMove=(j)=>{if(j.pointerId!==$.pointerId)return;let _=j.clientX-$.startX,X=j.clientY-$.startY;if(!$.active){if(_*_+X*X<H.#Z*H.#Z)return;$.active=!0,J.preventDefault(),J.stopPropagation(),Q.classList.add("dragging");try{Z.setPointerCapture($.pointerId)}catch{}}j.preventDefault();let Y=this.#j==="horizontal"?j.clientX:j.clientY,B=this.#R(Y);$.targetIndex=B,this.#w(B,Q)},$.onKeyDown=(j)=>{if(j.key!=="Escape"||!$.active)return;j.preventDefault(),this.#E($,!0)},$.onUp=(j)=>{if(j.pointerId!==$.pointerId)return;this.#E($,j.type==="pointercancel")},this.#_=$,window.addEventListener("pointermove",$.onMove),window.addEventListener("pointerup",$.onUp),window.addEventListener("pointercancel",$.onUp),window.addEventListener("keydown",$.onKeyDown)}#R(J){let Q=this.#Y(),Z=this.#j==="horizontal";for(let $=0;$<Q.length;$++){let j=Q[$].getBoundingClientRect(),_=Z?j.left+j.width/2:j.top+j.height/2;if(J<_)return $}return Q.length}#g(J,Q){let Z=this.#Y(),$=Z.indexOf(J);if($===-1)return!1;let j=Math.max(0,Math.min(Q,Z.length));if(Q===$)return!1;if(j>=Z.length&&$===Z.length-1)return!1;return!0}#D(J){if(!J.length)return null;let Q=1/0,Z=-1/0,$=1/0,j=-1/0;for(let _ of J){let X=_.getBoundingClientRect();Q=Math.min(Q,X.left),Z=Math.max(Z,X.right),$=Math.min($,X.top),j=Math.max(j,X.bottom)}return{left:Q,top:$,width:Z-Q,height:j-$}}#W(){if(this.#P)return this.#P;let J=document.createElement("div");return J.className="fig-reorder-indicator",J.setAttribute("data-axis",this.#j),document.body.appendChild(J),this.#P=J,J}#w(J,Q){let Z=this.#Y();if(!this.#g(Q,J)){this.#y();return}let $=this.#D(Z);if(!$){this.#y();return}let j=this.#W();if(j.setAttribute("data-axis",this.#j),this.#j==="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;j.style.left=`${X-1}px`,j.style.top=`${$.top}px`,j.style.width="2px",j.style.height=`${$.height}px`;return}let _;if(J<=0)_=Z[0].getBoundingClientRect().top;else if(J>=Z.length)_=Z[Z.length-1].getBoundingClientRect().bottom;else _=Z[J].getBoundingClientRect().top;j.style.left=`${$.left}px`,j.style.top=`${_-1}px`,j.style.width=`${$.width}px`,j.style.height="2px"}#y(){this.#P?.remove(),this.#P=null}#f(J,Q){let Z=this.#Y(),$=Math.max(0,Math.min(Q,Z.length));if($>=Z.length){if(Z[Z.length-1]!==J)this.appendChild(J);return}let j=Z[$];if(j!==J)this.insertBefore(J,j)}#i(J,Q){let $=this.#Y().filter((j)=>j!==J)[Q]??null;if($)this.insertBefore(J,$);else this.appendChild(J)}#E(J,Q){let{item:Z,oldIndex:$,active:j,onMove:_,onUp:X,onKeyDown:Y}=J;if(window.removeEventListener("pointermove",_),window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X),window.removeEventListener("keydown",Y),j){if(!Q){this.#f(Z,J.targetIndex);let B=this.#Y().indexOf(Z);if(B!==-1&&B!==$){this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:$,newIndex:B,item:Z}}));let G=Z.getAttribute("aria-label")||Z.textContent?.trim().replace(/\s+/g," ").slice(0,80)||"item";this.#K(`${G}, position ${B+1} of ${this.#Y().length}`)}}}if(Z.classList.remove("dragging"),H.#T(!1),this.#y(),this.#_===J)this.#_=null}#V(){for(let[,J]of this.#B)J.target.removeEventListener("pointerdown",J.onPointerDown,!0),J.target.removeEventListener("keydown",J.onKeyDown),this.#S(J);this.#B.clear()}#I(){if(!this.#_)return;this.#E(this.#_,!0)}}z("fig-reorder",H);var w=new WeakSet,E=new WeakSet,p=new WeakSet;function a(J){return Array.from(J.querySelectorAll("fig-select-option"))}function A(J,Q,Z=!0){let $=a(J);if(!$.length)return;let j=Q&&$.includes(Q)?Q:$.find((Y)=>M(Y,"selected"));if(!j||M(j,"disabled"))j=$.find((Y)=>!M(Y,"disabled"))||$[0];if(!j)return;let _=j.value??j.getAttribute("value")??"",X=J.getAttribute("value")??"";J.setAttribute("value",String(_));for(let Y of $){let B=Y===j;Y.toggleAttribute("selected",B),Y.setAttribute("aria-selected",String(B))}if(Z&&X!==String(_))J.dispatchEvent(new CustomEvent("input",{detail:String(_),bubbles:!0,composed:!0})),J.dispatchEvent(new CustomEvent("change",{detail:String(_),bubbles:!0,composed:!0}))}function I(J){if(w.has(J))return;if(!J.shadowRoot?.querySelector(".fig-select-trigger")){requestAnimationFrame(()=>{if(J.isConnected)I(J)});return}w.add(J),new MutationObserver(($)=>{let j=null,_=!1;for(let X of $){if(X.type!=="attributes"||X.attributeName!=="selected"||X.target.tagName!=="FIG-SELECT-OPTION")continue;if(M(X.target,"selected"))j=X.target;else if(String(X.target.value??"")===(J.getAttribute("value")??""))_=!0}if(j){let X=String(j.value??"");if((J.getAttribute("value")??"")!==X)A(J,j)}else if(_)A(J,null)}).observe(J,{attributes:!0,subtree:!0,attributeFilter:["selected"]})}function n(J){if(p.has(J))return;let Q=J.shadowRoot?.querySelector(".fig-select-trigger");if(!Q)return;p.add(J),Q.addEventListener("click",()=>{if(M(J,"disabled"))return;J.open=!J.open}),J.addEventListener("click",(Z)=>{let $=Z.composedPath().find((j)=>j?.tagName==="FIG-SELECT-OPTION");if(!$||!J.contains($)||M($,"disabled"))return;A(J,$),J.open=!1})}function t(J){if(J instanceof Element&&J.matches("fig-select"))E.add(J);J.querySelectorAll?.("fig-select").forEach((Q)=>E.add(Q))}function r(J){if(J instanceof Element&&J.matches("fig-select"))I(J);J.querySelectorAll?.("fig-select").forEach((Q)=>I(Q))}r(document);new MutationObserver((J)=>{for(let Q of J){for(let Z of Q.removedNodes)if(Z instanceof Element)t(Z);for(let Z of Q.addedNodes){if(!(Z instanceof Element))continue;r(Z);let $=Z.matches("fig-select")?[Z]:[...Z.querySelectorAll("fig-select")];for(let j of $)if(E.has(j))n(j)}}}).observe(document.documentElement,{childList:!0,subtree:!0});
|