UNPKG

ayvajs

Version:

A lightweight, behavior-based JavaScript API for controlling Open Source Multi Axis Stroker Robots.

1 lines 52.7 kB
var __webpack_modules__={570:(e,t,r)=>{r.d(t,{Z:()=>h});var o=r(336);var s=r(254);const a={validateMovements(e,t,r){const o={};let a=!1,n=!1;e&&e.length||(0,s.bG)("Must supply at least one movement."),e.forEach((e=>{e&&"object"==typeof e||(0,s.bG)(`Invalid movement: ${e}`);const i=t=>(0,s.bG)(`Invalid value for parameter '${t}': ${e[t]}`),c=(0,s.e$)(e,"to"),h=(0,s.e$)(e,"speed"),p=(0,s.e$)(e,"duration"),u=(0,s.e$)(e,"value"),f=e.axis||r;if(f||(0,s.bG)("No default axis configured. Must specify an axis for each movement."),(0,s.e$)(e,"axis")&&("string"==typeof e.axis&&e.axis.trim()&&t[e.axis]||i("axis")),c){let r=!1;r="boolean"===t[f].type?"boolean"!=typeof e.to:!Number.isFinite(e.to)||e.to<0||e.to>1,r&&i("to")}else u||(0,s.bG)("Must provide a 'to' property or 'value' function.");h&&p&&(0,s.bG)("Cannot supply both speed and duration."),(h||p)&&(a=!0,h&&(!Number.isFinite(e.speed)||e.speed<=0)?i("speed"):p&&(!Number.isFinite(e.duration)||e.duration<=0)&&i("duration")),h&&!c&&(0,s.bG)("Must provide a target position when specifying speed."),u&&"function"!=typeof e.value&&(0,s.bG)("'value' must be a function."),(0,s.e$)(e,"sync")&&("string"==typeof e.sync&&e.sync.trim()||i("sync"),((0,s.e$)(e,"speed")||(0,s.e$)(e,"duration"))&&(0,s.bG)(`Cannot specify a speed or duration when sync property is present: ${e.axis}`)),"boolean"!==t[f].type?n=!0:((0,s.e$)(e,"speed")&&(0,s.bG)(`Cannot specify speed for boolean axes: ${f}`),(0,s.e$)(e,"duration")&&c&&!u&&(0,s.bG)("Cannot specify a duration for a boolean axis movement with constant value.")),o[f]&&(0,s.bG)(`Duplicate axis movement: ${f}`),o[f]=e,t[f].alias&&(o[t[f].alias]=e)})),e.forEach((e=>{let t=e;const r=e.axis;for(;(0,s.e$)(t,"sync");)o[t.sync]||(0,s.bG)(`Cannot sync with axis not specified in movement: ${t.axis} -> ${t.sync}`),t=o[t.sync],t.sync===r&&(0,s.bG)("Sync axes cannot form a cycle.")})),!a&&n&&(0,s.bG)("At least one movement must have a speed or duration.")},validateAxisConfig(e){e&&"object"==typeof e||(0,s.bG)(`Invalid configuration object: ${e}`);const t={name:"string",type:"string",alias:"string",max:"number",min:"number"},r=["name","type"].filter((t=>void 0===e[t]||null===e[t])).sort();r.length&&(0,s.bG)(`Configuration is missing properties: ${r.join(", ")}`);const o=[];Object.keys(t).forEach((r=>{const s=e[r];null!=s&&(typeof s!==t[r]?o.push(r):"min"===r||"max"===r?(!Number.isFinite(s)||s<0||s>1)&&o.push(r):"alias"!==r&&"name"!==r||/^[a-zA-Z]+[a-zA-Z0-9]*$/.test(s)||o.push(r))}));let{defaultValue:a}=e;if(null!=a?"boolean"===e.type?"boolean"!=typeof a&&o.push("defaultValue"):(!Number.isFinite(a)||a<0||a>1)&&o.push("defaultValue"):a="boolean"!==e.type&&("auxiliary"===e.type?0:.5),o.length){const t=o.sort().map((t=>`${t} = ${e[t]}`)).join(", ");(0,s.bG)(`Invalid configuration parameter(s): ${t}`)}-1===["linear","rotation","auxiliary","boolean"].indexOf(e.type)&&(0,s.bG)(`Invalid type. Must be linear, rotation, auxiliary, or boolean: ${e.type}`);const n={...e,defaultValue:a,max:e.max||1,min:e.min||0,value:a,lastValue:a};return(n.max===n.min||n.min>n.max)&&(0,s.bG)(`Invalid configuration parameter(s): max = ${n.max}, min = ${n.min}`),n},validateMotionParameters({from:e,to:t,phase:r,ecc:o,bpm:a,shift:n}){if(!((0,s.BP)(e,0,1)&&(0,s.BP)(t,0,1)&&(0,s.BP)(r)&&(0,s.BP)(o)&&(0,s.BP)(a)&&a>0&&(0,s.BP)(n)))throw new Error(`One or more motion parameters are invalid (${e}, ${t}, ${r}, ${o}, ${a}, ${n})`)}},n={name:"SR6",defaultAxis:"L0",axes:[{name:"L0",type:"linear",alias:"stroke"},{name:"L1",type:"linear",alias:"surge"},{name:"L2",type:"linear",alias:"sway"},{name:"R0",type:"rotation",alias:"twist"},{name:"R1",type:"rotation",alias:"roll"},{name:"R2",type:"rotation",alias:"pitch"},{name:"A0",alias:"valve",type:"auxiliary"},{name:"A1",alias:"suck",type:"auxiliary"},{name:"A2",alias:"lube",type:"auxiliary",resetOnStop:!0},{name:"V0",alias:"vibe0",type:"auxiliary",resetOnStop:!0},{name:"V1",alias:"vibe1",type:"auxiliary",resetOnStop:!0}]};var i=r(697);class c{#e=[];#t={};#r=50;#o=new Set;#s=1;#a=1;#n=null;#i=!1;#c;#h=new Set;#p=new Set;defaultRamp=c.RAMP_COS;static get precision(){return 10}static get maxFrequency(){return 250}get performing(){return this.#i}get axes(){const e={};return Object.keys(this.#t).forEach((t=>{e[t]=this.getAxis(t)})),e}get frequency(){return this.#r}set frequency(e){if(!(0,s.BP)(e,1,c.maxFrequency))throw new Error(`Invalid frequency ${e}. Frequency must be a number between 1 and ${c.maxFrequency}.`);this.#r=e}get period(){return this.#u}get#u(){return 1/this.#r}constructor(e){(0,s.w6)(this,"$",{}),e&&this.#f(e),"undefined"==typeof Worker?this.#c={sleep:e=>new Promise((t=>{setTimeout(t,1e3*e)})),now:()=>performance.now()/1e3}:this.#c=new class{#l;#m={};#d=1;constructor(){this.#l=new Worker(this.#_((function(){onmessage=function(e){const{id:t,delay:r}=e.data;setTimeout((()=>{postMessage(t)}),1e3*r)}}))),this.#l.onmessage=({data:e})=>{const t=e;this.#m[t](),delete this.#m[t]}}sleep(e){return new Promise((t=>{const r=this.#d++;this.#m[r]=t,this.#l.postMessage({id:r,delay:e})}))}now(){return performance.now()/1e3}#_(e){const t=new Blob([`(${e.toString()})()`],{type:"text/javascript"});return URL.createObjectURL(t)}}}defaultConfiguration(){return this.#f(n),this}getTimer(){return this.#c}setTimer(e){this.#c=e}async do(e){this.#b();const t=this.#a++;for(this.#n=t;this.#i;)await this.sleep();this.#i=!0;const r=this.#v(e);for(;this.#n===t&&!r.complete;)try{await r.perform(this),await this.ready()}catch(e){console.error("Error performing behavior:",e?.stack);break}return this.#i=!1,this.#n===t&&(this.#n=null,!0)}move(...e){if(!this.#e||!this.#e.length)throw new Error("No output devices have been added.");return a.validateMovements(e,this.#t,this.defaultAxis),this.#y(...e)}ready(){return this.#h.size||this.#o.size?new Promise((e=>{this.#p.add(e)})):this.sleep()}moveBuilder(){return new o.Z(this)}async home(e=.5){const t=this.#g().map((t=>{const r={axis:t.name,to:t.defaultValue};return"boolean"!==t.type&&(r.speed=e),r}));return t.length?this.move(...t):(console.warn("No linear or rotation axes configured."),Promise.resolve(!1))}stop(){this.#b()}sleep(e){let t;const r=new Promise((e=>{this.#h.add(e),t=e}));return Promise.any([this.#c.sleep(e).then((()=>!0)),r.then((()=>!1))]).finally((()=>{this.#h.delete(t),this.#w()}))}configureAxis(e){const t=a.validateAxisConfig(e),r=this.#t[e.name];if(r&&(t.value=r.value,t.lastValue=r.lastValue,delete this.#t[r.alias],delete this.$[r.alias]),this.#t[e.name]=t,this.#x(e.name),e.alias){if(this.#t[e.alias])throw new Error(`Alias already refers to another axis: ${e.alias}`);this.#t[e.alias]=t,this.#x(e.alias)}}getAxis(e){const t=this.#t[e];if(t){const e={};return Object.keys(t).forEach((r=>{(0,s.w6)(e,r,t[r])})),e}}getAxes(){return this.#g().map((e=>({name:e.name,alias:e.alias,type:e.type,defaultValue:e.defaultValue,max:e.max,min:e.min,value:e.value,lastValue:e.lastValue,resetOnStop:e.resetOnStop})))}updateLimits(e,t,r){const o=e=>!Number.isFinite(e)||e<0||e>1;if(o(t)||o(r)||t===r)throw new Error(`Invalid limits: min = ${t}, max = ${r}`);if(!this.#t[e])throw new Error(`Invalid axis: ${e}`);this.#t[e].min=Math.min(t,r),this.#t[e].max=Math.max(t,r)}setValues(e){const t=Object.entries(e).map((([e,t])=>({axis:e,value:t})));this.#R(t)}addOutput(...e){this.addOutputDevice(...e)}getOutput(){return this.getOutputDevices()}removeOutput(e){this.removeOutputDevice(e)}addOutputDevice(...e){const t=e.map((e=>{const t=e&&e.write&&e.write instanceof Function;if(!(t||e instanceof Function))throw new Error(`Invalid device: ${e}`);return t?e:{write:e}}));this.#e.push(...t)}getOutputDevices(){return[...this.#e]}removeOutputDevice(e){const t=this.#e.indexOf(e);-1!==t&&this.#e.splice(t,1)}async#y(...e){const t=this.#s++;for(this.#o.add(t);this.#o.has(t)&&this.#o.values().next().value!==t;)await this.sleep();return!!this.#o.has(t)&&this.#L(t,e).finally((()=>{this.#o.delete(t),this.#w()}))}#b(){this.#n=null,this.#o.clear(),this.#h.forEach((e=>e()));const e={};this.#g().forEach((t=>{t.resetOnStop&&(e[t.name]=t.defaultValue)})),Object.keys(e).length&&this.setValues(e)}#x(e){Object.defineProperty(this.$,e,{value:(...t)=>this.moveBuilder()[e](...t),writeable:!1,configurable:!0,enumerable:!0}),Object.defineProperty(this.$[e],"value",{get:()=>this.#t[e].value,set:t=>{const{type:r}=this.#t[e];if("boolean"!==r&&!(0,s.BP)(t,0,1))throw new Error(`Invalid value: ${t}`);this.#R([{axis:e,value:t}])}}),Object.defineProperty(this.$[e],"lastValue",{get:()=>this.#t[e].lastValue}),Object.defineProperty(this.$[e],"defaultValue",{get:()=>this.#t[e].defaultValue}),Object.defineProperty(this.$[e],"min",{get:()=>this.#t[e].min}),Object.defineProperty(this.$[e],"max",{get:()=>this.#t[e].max})}#f(e){this.name=e.name,this.defaultAxis=e.defaultAxis,this.#r=e.frequency||this.#r,e.axes&&e.axes.forEach((e=>{this.configureAxis(e)}))}#v(e){return"function"!=typeof e||e instanceof i.Z?e:(0,s.Af)(e)?new i.Z(e):{perform:e}}#A(e){for(const t of this.#e)t.write(e)}async#L(e,t){const r=this.#k(t),{duration:o,stepCount:s}=this.#M(r),a=r.filter((e=>!e.parameters.stepCount)),n=r.filter((e=>!!e.parameters.stepCount));this.#P(a,0);let i=0;const c=this.#c.now();if(s)for(let t=0;t<s;t++){const r=n.filter((e=>t<e.parameters.stepCount));if(this.#P(r,t),i=await this.#E(t,s,o,c,i),!this.#o.has(e))return!1}else await this.sleep(this.#u);return!0}async#E(e,t,r,o,s){const a=e=>Math.max(e,1/c.maxFrequency);if(e===t-1){const e=this.#c.now()-o,t=Math.min(Math.max(r-e,0),this.#u);await this.sleep(a(t))}else await this.sleep(a(this.#u-s));return this.#c.now()-o-(e+1)*this.#u}#P(e,t){const r=e.map((e=>this.#$(e,t)));this.#R(r)}#$(e,t){const r=t*this.#u,{parameters:o,valueProvider:a}=e,{duration:n}=o,i=a({...o,time:r,index:t,period:this.#u,frequency:this.#r,currentValue:this.#t[o.axis].value,x:Math.min(1,(t+1)/(n*this.#r))}),h=null!=i;return!this.#S(i)&&h&&console.warn(`Invalid value provided: ${i}`),{axis:o.axis,value:Number.isFinite(i)?(0,s.uZ)((0,s.NM)(i,c.precision),0,1):i}}#R(e){const t=e.filter((({value:e})=>this.#S(e))),r=t.map((({axis:e,value:t})=>this.#j(e,t)));r.length&&(this.#A(`${r.join(" ")}\n`),t.forEach((({axis:e,value:t})=>{this.#t[e].lastValue=this.#t[e].value,this.#t[e].value=t})))}#S(e){return Number.isFinite(e)||"boolean"==typeof e}#j(e,t){let r;if("boolean"==typeof t)r=t?"9999":"0000";else{const{min:o,max:a}=this.#t[e],n=(a-o)*(0,s.NM)(.9999*t,4)+o;r=`${(0,s.uZ)((0,s.NM)(1e4*n),0,9999)}`.padStart(4,"0")}return`${this.#t[e].name}${r}`}#k(e){const{parameterObjects:t,maxDuration:r}=this.#O(e);return this.#T(t,r),t.map((e=>{const t={};return(0,s.e$)(e,"value")?t.valueProvider=e.value:"boolean"===this.#t[e.axis].type?t.valueProvider=()=>e.to:e.to!==e.from?t.valueProvider=this.defaultRamp:t.valueProvider=()=>{},delete e.sync,delete e.value,t.parameters=e,t}))}#O(e){let t=0;const r=e.map((e=>{const r=e.axis||this.defaultAxis,o={...e,axis:r,from:this.#t[r].value,period:this.#u};if((0,s.e$)(e,"to")){const t=e.to-o.from,r=Math.abs(t);(0,s.e$)(e,"duration")?o.speed=(0,s.NM)(r/e.duration,c.precision):(0,s.e$)(e,"speed")&&(o.duration=(0,s.NM)(r/o.speed,c.precision)),o.direction=t>0?1:t<0?-1:0}return(0,s.e$)(o,"duration")&&(t=Math.max(o.duration,t)),o}));return{maxDuration:t,parameterObjects:r}}#T(e,t){const r=e.reduce(((e,t)=>(e[t.axis]=t,this.#t[t.axis].alias&&(e[this.#t[t.axis].alias]=t),e)),{});e.forEach((e=>{if((0,s.e$)(e,"sync")){let o=e;for(;(0,s.e$)(o,"sync");)o=r[o.sync];e.duration=o.duration||t,(0,s.e$)(e,"to")&&(e.speed=(0,s.NM)(Math.abs(e.to-e.from)/e.duration,c.precision))}else(0,s.e$)(e,"duration")||"boolean"===this.#t[e.axis].type||(e.duration=t);(0,s.e$)(e,"duration")&&(e.stepCount=Math.ceil(e.duration*this.#r))}))}#M(e){let t=0,r=0;return e.forEach((e=>{const o=e.parameters.stepCount,s=e.parameters.duration;o&&(t=Math.max(o,t)),s&&(r=Math.max(s,r))})),{duration:r,stepCount:t}}#g(){const e={};return Object.values(this.#t).forEach((t=>{e[t.name]=t})),Object.values(e).sort((function(e,t){return e.name>t.name?1:-1}))}#w(){if(0===this.#h.size&&0===this.#o.size&&this.#p.size){for(const e of this.#p)e();this.#p.clear()}}static ramp(e){return t=>{const{from:r,to:o}=t;return r+(o-r)*e(t)}}static RAMP_LINEAR(e){return c.ramp((({x:e})=>e))(e)}static RAMP_COS(e){return c.ramp((({x:e})=>-Math.cos(Math.PI*e)/2+.5))(e)}static RAMP_PARABOLIC(e){return c.ramp((({x:e})=>e*e))(e)}static RAMP_NEGATIVE_PARABOLIC(e){return c.ramp((({x:e})=>1-(e-1)**2))(e)}static tempestMotion(e,t,r=0,o=0,s=60,a=0){const n="object"==typeof e?e:{from:e,to:t,phase:r,ecc:o,bpm:s,shift:a};return c.#I(n)}static#I(e){e={from:0,to:1,phase:0,ecc:0,shift:0,bpm:60,...e},a.validateMotionParameters(e);const{from:t,to:r,phase:o,ecc:s,bpm:n,shift:i}=e,h=2*Math.PI*n/60,p=.5*(r-t),u=.5*(r+t),f=({index:e,frequency:t})=>{const r=(e+1)*h/t+.5*Math.PI*o+i;return u-p*Math.cos(r+s*Math.sin(r))};return c.#B(f,t,r,o,s,n),f}static parabolicMotion(e,t,r=0,o=0,s=60,a=0){const n="object"==typeof e?e:{from:e,to:t,phase:r,ecc:o,bpm:s,shift:a};return c.#C(n)}static#C(e){e={from:0,to:1,phase:0,ecc:0,shift:0,bpm:60,...e},a.validateMotionParameters(e);const{from:t,to:r,phase:o,ecc:s,bpm:n,shift:i}=e,{sin:h,PI:p}=Math,u=2*p*n/60,f=r-t,l=r,m=({index:e,frequency:t})=>{const r=(e+1)*u/t+.5*p*o+i,a=(r%(n=2*p)+n)%n/p-1+s/p*h(r);var n;return l-f*a*a};return c.#B(m,t,r,o,s,n),m}static linearMotion(e,t,r=0,o=0,s=60,a=0){const n="object"==typeof e?e:{from:e,to:t,phase:r,ecc:o,bpm:s,shift:a};return c.#F(n)}static#F(e){e={from:0,to:1,phase:0,ecc:0,shift:0,bpm:60,...e},a.validateMotionParameters(e);const{from:t,to:r,phase:o,ecc:s,bpm:n,shift:i}=e,{abs:h,sin:p,PI:u}=Math,f=2*u*n/60,l=r-t,m=r,d=({index:e,frequency:t})=>{const r=(e+1)*f/t+.5*u*o+i,a=(r%(n=2*u)+n)%n/u-1+s/u*p(r);var n;return m-l*h(a)};return c.#B(d,t,r,o,s,n),d}static#B(e,t,r,o,a,n){(0,s.w6)(e,"from",t),(0,s.w6)(e,"to",r),(0,s.w6)(e,"phase",o),(0,s.w6)(e,"ecc",a),(0,s.w6)(e,"bpm",n)}static blendMotion(e,t,r){return(...o)=>(0,s.NM)((1-r)*e(...o)+r*t(...o),c.precision)}static get defaultConfiguration(){return{...n}}static map(e,t,r,o=0,s=1){return(e-t)*(s-o)/(r-t)+o}}const h=c},321:(e,t,r)=>{r.d(t,{Z:()=>c});var o=r(570),s=r(697),a=r(254),n=r(319);class i extends s.Z{#D;#Z;#V;#q;#N;get speed(){return this.#V}get top(){return this.#D}get bottom(){return this.#Z}get duration(){return this.#q}static get DEFAULT_CONFIG(){return{top:1,bottom:0,speed:1,shape:o.Z.RAMP_COS,relativeSpeeds:[1,1],suck:null,twist:null,pitch:null}}constructor(e=0,t=1,r=1,s=o.Z.RAMP_COS){let a;super(),a="object"!=typeof e||e instanceof Array?{top:t,bottom:e,speed:r,shape:s}:e,this.#G(a)}*generate(e){const{value:t,lastValue:r}=e.$.stroke,{target:o,shape:s,direction:n,relativeSpeed:i}=this.#U(t,r),c=this.#V*i,h={to:o,value:s};void 0!==this.#N.speed?(h.speed=c,this.#V=this.#N.speed.next()):(h.duration=this.#q/i,this.#q=this.#N.duration.next());const p=[h];this.#N.twist&&p.push(this.#W("twist",{direction:n,value:t,target:o,ayva:e,speed:void 0!==this.#N.speed?c:Math.abs(o-t)/h.duration})),this.#N.pitch&&p.push(this.#W("pitch",{direction:n,value:t,target:o,ayva:e,speed:void 0!==this.#N.speed?c:Math.abs(o-t)/h.duration})),(0,a.BP)(this.#N.suck,0,1)&&(e.$.suck.value=this.#N.suck),yield p}#G(e){const t=i.DEFAULT_CONFIG;(0,a.e$)(e,"duration")&&delete t.speed;const r={...t,...e};this.#z(r),r.top=n.Z.createFrom(r.top),r.bottom=n.Z.createFrom(r.bottom),r.relativeSpeeds=n.Z.createFrom(r.relativeSpeeds),(0,a.e$)(r,"duration")?r.duration=n.Z.createFrom(r.duration):r.speed=n.Z.createFrom(r.speed);const{shape:o}=r;r.shape=o instanceof Array?new n.Z((e=>o[e%o.length])):new n.Z((()=>o)),this.#N=r,this.#D=this.#N.top.next(),this.#Z=this.#N.bottom.next(),void 0!==this.#N.speed?this.#V=this.#N.speed.next():this.#q=this.#N.duration.next()}#W(e,{direction:t,value:r,target:s,speed:a,ayva:n}){const{frequency:i}=n,c=("up"===t?0:2)+(this.#N[e].phase||0),h=this.#N[e].ecc||0,p=60*a/(2*Math.abs(r-s)),u=o.Z.tempestMotion(this.#N[e].from,this.#N[e].to,c,h,p),f=u({index:-1,frequency:i});return Math.abs(f-n.$[e].value)>.05?{axis:e,to:o.Z.tempestMotion(this.#N[e].from,this.#N[e].to,c+2,h,p)({index:-1,frequency:i}),value:o.Z.RAMP_COS}:{axis:e,value:u}}#U(e,t){const r=e-t>=0,o=this.#N.shape.index%2==0?"up":"down",s=this.#N.relativeSpeeds.index%2==0?"up":"down";let a,n;return e<=this.#Z||e<this.#D&&!r?(n="up",a=this.#D,this.#D=this.#N.top.next(),"down"===o&&this.#N.shape.next(),"down"===s&&this.#N.relativeSpeeds.next()):(n="down",a=this.#Z,this.#Z=this.#N.bottom.next(),"up"===o&&this.#N.shape.next(),"up"===s&&this.#N.relativeSpeeds.next()),{target:a,shape:this.#N.shape.next(),direction:n,relativeSpeed:this.#N.relativeSpeeds.next()}}#z(e){const t=(e,t)=>{throw new Error(`Invalid stroke ${e}: ${t}`)};if((0,a.BP)(e.bottom,0,1)||"function"==typeof e.bottom||e.bottom instanceof Array||t("bottom",e.bottom),(0,a.BP)(e.top,0,1)||"function"==typeof e.top||e.top instanceof Array||t("top",e.top),e.bottom===e.top)throw new Error(`Invalid stroke range specified: (${e.bottom}, ${e.top})`);if((0,a.e$)(e,"speed")&&(0,a.e$)(e,"duration"))throw new Error("Cannot specify both a speed and duration");if(!(0,a.e$)(e,"speed")||(0,a.BP)(e.speed)&&!(e.speed<=0)||"function"==typeof e.speed||e.speed instanceof Array||t("speed",e.speed),!(0,a.e$)(e,"duration")||(0,a.BP)(e.duration)&&!(e.duration<=0)||"function"==typeof e.duration||e.duration instanceof Array||t("duration",e.duration),"function"==typeof e.shape||e.shape instanceof Array||t("shape",e.shape),!(0,a.e$)(e,"relativeSpeeds")||e.relativeSpeeds instanceof Array||t("relative speeds",e.relativeSpeeds),["twist","pitch"].forEach((r=>{"object"!=typeof e[r]&&t(r,e[r]),e[r]&&((0,a.BP)(e[r].from,0,1)||t(`${r} from`,e[r].from),(0,a.BP)(e[r].to,0,1)||t(`${r} to`,e[r].to),(0,a.e$)(e[r],"phase")&&!(0,a.BP)(e[r].phase)&&t(`${r} phase`,e[r].phase))})),e.shape instanceof Array){if(!e.shape.length)throw new Error("Missing stroke shape.");if(e.shape.length%2!=0)throw new Error("Must specify an even number of stroke shapes.");e.shape.forEach((e=>{"function"!=typeof e&&t("shape",e)}))}if(e.relativeSpeeds instanceof Array){if(e.relativeSpeeds.length%2!=0)throw new Error("Must specify an even number of relative speeds.");e.relativeSpeeds.forEach((e=>{(!(0,a.BP)(e)||e<=0)&&t("relative speed",e)}))}(0,a.e$)(e,"suck")&&!(0,a.BP)(e.suck,0,1)&&null!==e.suck&&t("suck",e.suck)}}const c=i},697:(e,t,r)=>{r.d(t,{Z:()=>i});const o=class extends Function{constructor(){return super("...args","return this.__bound__.__call__(...args)"),this.__bound__=Function.prototype.bind.call(this,this),this.__bound__}__call__(...e){throw new Error("__call__ not implemented.")}};var s=r(336),a=r(570);class n extends o{#K;#X=!1;#H=null;#J;#Q;#Y;get ayva(){return this.#H}constructor(e){if(super(),e){if("GeneratorFunction"!==e.constructor.name)throw Error(`Not a generator function: ${e}`);this.generate=e}}*start(e){}*generate(e){throw new Error("generate() not implemented.")}*iterated(e,t=1){for(let r=0;r<t;r++)yield*this.generate(e)}perform(e=this.#H){const t=this.next(e);return t?Array.isArray(t)?e.move(...t):Number.isFinite(t)&&t>=0?e.ready().then((()=>e.sleep(t))):t instanceof s.Z?t.execute():t instanceof Promise?t:e.move(t):Promise.resolve()}bind(e){return this.unbind(),this.#H=e,this.#J=this.start,this.#Q=this.generate,this.#Y=this.iterated,this.start=this.start.bind(this,e),this.generate=this.generate.bind(this,e),this.iterated=this.iterated.bind(this,e),this}unbind(){this.#H&&(this.#H=null,this.start=this.#J,this.generate=this.#Q,this.iterated=this.#Y)}next(e=this.#H){this.#K&&!this.#X||(this.#K=this.generate(e),this.#X=!1);const{value:t,done:r}=this.#K.next();return this.#X=r,r?null:t}__call__(...e){const t=this.#H?e[0]:e[1],r=this.#H||e[0],o=Number.isFinite(t)&&t>=1?t:void 0;if(void 0!==r&&!(r instanceof a.Z))throw new TypeError(`Invalid Ayva instance: ${r}`);return this.#H?o?this.iterated(o):this.generate():o?this.iterated(r,o):this.generate(r)}[Symbol.iterator](){return this.generate()}}const i=n},590:(__unused_webpack___webpack_module__,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{Z:()=>__WEBPACK_DEFAULT_EXPORT__});var _generator_behavior_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(697),_util_script_whitelist_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(424);class ScriptBehavior extends _generator_behavior_js__WEBPACK_IMPORTED_MODULE_0__.Z{#ee;#te;constructor(e,t={}){super(),this.#ee={..._util_script_whitelist_js__WEBPACK_IMPORTED_MODULE_1__,...t},this.#te=e.replace(/["'`\\]/g,(e=>`\\${e}`))}*generate(e){const t=this.#re(e);for(;!this.complete;)yield*t(e),yield}#re(){const scopeValues=[];let sandboxFunction="new Function(";for(const e in this.#ee)sandboxFunction+=`"${e}", `,scopeValues.push(this.#ee[e]);for(const e in globalThis)Object.prototype.hasOwnProperty.call(this.#ee,e)||(sandboxFunction+=`"${e}", `);sandboxFunction+='"eval", "Function", ',sandboxFunction+=`\`\n return (function*(ayva) { \n ${this.#te} \n }).bind(this);\`);`;try{const sandbox=eval(sandboxFunction);return sandbox.call(this,...scopeValues)}catch(e){throw new SyntaxError("Invalid AyvaScript.")}}}const __WEBPACK_DEFAULT_EXPORT__=ScriptBehavior},824:(e,t,r)=>{r.d(t,{Z:()=>u});var o=r(697),s=r(570),a=r(319);const n={"down-forward":{L0:{from:0,to:1,phase:0,ecc:.5},L1:{from:.8,to:.2,phase:1,ecc:.8},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:.2,to:.8,phase:1,ecc:.8}},"down-backward":{L0:{from:0,to:1,phase:0,ecc:.5},L1:{from:.2,to:.8,phase:1,ecc:.8},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:.8,to:.2,phase:1,ecc:.8}},"back-thrust-down":{L0:{from:0,to:.7,phase:0,ecc:.5},L1:{from:1,to:0,phase:0,ecc:.5},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:.4,to:1,phase:0,ecc:.5}},"back-thrust-down-swirl":{L0:{from:0,to:.7,phase:0,ecc:.5},L1:{from:.9,to:.1,phase:0,ecc:.5},L2:{from:.8,to:.2,phase:1,ecc:.5},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.8,to:.2,phase:1,ecc:.5},R2:{from:.5,to:1,phase:0,ecc:.5}},"thrust-forward":{L0:{from:0,to:.5,phase:0,ecc:.5},L1:{from:.2,to:1,phase:0,ecc:.5},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:.5,to:1,phase:0,ecc:.5}},"thrust-forward-swirl":{L0:{from:0,to:.5,phase:0,ecc:.5},L1:{from:.2,to:1,phase:0,ecc:.5},L2:{from:.8,to:.2,phase:1,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.8,to:.2,phase:1,ecc:0},R2:{from:.5,to:1,phase:0,ecc:.5}},"lean-forward-thrust-down":{L0:{from:0,to:.7,phase:0,ecc:.5},L1:{from:.5,to:.5,phase:0,ecc:0},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:1,to:0,phase:0,ecc:.5}},"lean-forward-thrust-down-swirl":{L0:{from:0,to:.7,phase:0,ecc:.5},L1:{from:.5,to:.5,phase:0,ecc:0},L2:{from:.8,to:.2,phase:1,ecc:.5},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.8,to:.2,phase:1,ecc:.5},R2:{from:1,to:0,phase:0,ecc:.5}},"diagonal-down-back":{L0:{from:0,to:.5,phase:0,ecc:.2},L1:{from:1,to:.2,phase:0,ecc:.2},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:1,to:0,phase:1,ecc:.6}},"diagonal-down-forward":{L0:{from:0,to:.5,phase:0,ecc:.2},L1:{from:0,to:.8,phase:0,ecc:.2},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:0,to:1,phase:1,ecc:.6}},"orbit-tease":{L0:{from:.8,to:1,phase:0,ecc:.3},L1:{from:.9,to:.1,phase:0,ecc:-.3},L2:{from:.1,to:.9,phase:1,ecc:-.3},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.1,to:.9,phase:1,ecc:-.3},R2:{from:.1,to:.9,phase:0,ecc:-.3}},"left-right-tease":{L0:{from:.9,to:.9,phase:0,ecc:0},L1:{from:.5,to:.5,phase:0,ecc:0},L2:{from:0,to:1,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:1,to:0,phase:1,ecc:0},R2:{from:.5,to:.5,phase:0,ecc:0}},"forward-back-tease":{L0:{from:.9,to:.9,phase:0,ecc:0},L1:{from:0,to:1,phase:0,ecc:0},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:0,to:1,phase:1,ecc:0}},"vortex-tease":{L0:{from:.8,to:1,phase:0,ecc:.3},L1:{from:.6,to:.4,phase:0,ecc:0},L2:{from:.4,to:.6,phase:1,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.9,to:.1,phase:1,ecc:0},R2:{from:.9,to:.1,phase:0,ecc:0}},"swirl-tease":{L0:{from:.5,to:1,phase:0,ecc:0},L1:{from:1,to:.3,phase:0,ecc:0},L2:{from:1,to:0,phase:1,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.9,to:.1,phase:1,ecc:0},R2:{from:.4,to:1,phase:0,ecc:0}},"forward-back-grind":{L0:{from:0,to:0,phase:0,ecc:0},L1:{from:.3,to:.7,phase:0,ecc:0},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:0,to:1,phase:.5,ecc:0}},"orbit-grind":{L0:{from:0,to:.3,phase:0,ecc:.3},L1:{from:0,to:.6,phase:0,ecc:-.3},L2:{from:.2,to:.8,phase:1,ecc:-.3},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.1,to:.9,phase:1,ecc:-.3},R2:{from:.9,to:.1,phase:0,ecc:-.3}},"short-low-roll-forward":{L0:{from:0,to:.5,phase:0,ecc:.25},L1:{from:.5,to:.5,phase:1,ecc:0},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:.4,to:.6,phase:1,ecc:0}},"short-low-roll-backward":{L0:{from:0,to:.5,phase:0,ecc:.25},L1:{from:.5,to:.5,phase:1,ecc:0},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:.6,to:.4,phase:1,ecc:0}},"short-mid-roll-forward":{L0:{from:.25,to:.75,phase:0,ecc:.25},L1:{from:.5,to:.5,phase:1,ecc:0},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:.4,to:.6,phase:1,ecc:0}},"short-mid-roll-backward":{L0:{from:.25,to:.75,phase:0,ecc:.25},L1:{from:.5,to:.5,phase:1,ecc:0},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:.6,to:.4,phase:1,ecc:0}},"short-high-roll-backward":{L0:{from:.5,to:1,phase:0,ecc:.25},L1:{from:.5,to:.5,phase:1,ecc:0},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:.4,to:.6,phase:1,ecc:0}},"short-high-roll-forward":{L0:{from:.5,to:1,phase:0,ecc:.25},L1:{from:.5,to:.5,phase:1,ecc:0},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:.6,to:.4,phase:1,ecc:0}},"long-stroke-1":{L0:{from:.1,to:.9,phase:0,ecc:.25},L1:{from:.8,to:.2,phase:1,ecc:.5},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:.3,to:.7,phase:1,ecc:.2}},"long-stroke-2":{L0:{from:.1,to:.9,phase:0,ecc:.25},L1:{from:.2,to:.8,phase:1,ecc:.5},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:.7,to:.3,phase:1,ecc:.2}},"long-stroke-3":{L0:{from:0,to:.7,phase:0,ecc:0},L1:{from:0,to:1,phase:0,ecc:0},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:1,to:.3,phase:0,ecc:.5}},"long-stroke-4":{L0:{from:0,to:.7,phase:0,ecc:0},L1:{from:.6,to:.4,phase:0,ecc:0},L2:{from:.6,to:.4,phase:1,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.7,to:.3,phase:1,ecc:0},R2:{from:.5,to:1,phase:0,ecc:.25}},"long-stroke-5":{L0:{from:0,to:.8,phase:0,ecc:0},L1:{from:.4,to:.6,phase:0,ecc:0},L2:{from:.4,to:.6,phase:1,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.3,to:.7,phase:1,ecc:0},R2:{from:.5,to:1,phase:0,ecc:.25}},"grind-circular":{L0:{from:0,to:0,phase:0,ecc:0},L1:{from:.7,to:.3,phase:0,ecc:0},L2:{from:.3,to:.7,phase:1,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.3,to:.7,phase:1,ecc:0},R2:{from:.3,to:.7,phase:0,ecc:0}},"grind-vortex":{L0:{from:0,to:0,phase:0,ecc:0},L1:{from:.7,to:.3,phase:0,ecc:0},L2:{from:.7,to:.3,phase:1,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.7,to:.3,phase:1,ecc:0},R2:{from:.3,to:.7,phase:0,ecc:0}},"grind-forward-back":{L0:{from:0,to:.1,phase:0,ecc:0},L1:{from:0,to:1,phase:0,ecc:0},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:.6,to:.4,phase:0,ecc:0}},"grind-forward-back-phased":{L0:{from:0,to:.1,phase:0,ecc:0},L1:{from:0,to:1,phase:0,ecc:0},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:.3,to:.7,phase:1,ecc:0}},"grind-forward-back-tilt":{L0:{from:0,to:.2,phase:0,ecc:0},L1:{from:.2,to:.8,phase:0,ecc:0},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:.7,to:0,phase:0,ecc:0}},"grind-forward-tilt":{L0:{from:0,to:.2,phase:0,ecc:0},L1:{from:.3,to:.3,phase:0,ecc:0},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:.1,to:.7,phase:0,ecc:0}},"tease-orbit-right":{L0:{from:.9,to:.9,phase:0,ecc:0},L1:{from:.7,to:.3,phase:0,ecc:0},L2:{from:.3,to:.7,phase:1,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.1,to:.9,phase:1,ecc:0},R2:{from:.1,to:.9,phase:0,ecc:0}},"tease-orbit-left":{L0:{from:.9,to:.9,phase:0,ecc:0},L1:{from:.7,to:.3,phase:0,ecc:0},L2:{from:.7,to:.3,phase:1,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.9,to:.1,phase:1,ecc:0},R2:{from:.1,to:.9,phase:0,ecc:0}},"tease-left-right-rock":{L0:{from:.8,to:.8,phase:0,ecc:0},L1:{from:.5,to:.5,phase:0,ecc:0},L2:{from:.9,to:.1,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:1,to:0,phase:0,ecc:0},R2:{from:.5,to:.5,phase:0,ecc:0}},"tease-down-back":{L0:{from:.8,to:1,phase:0,ecc:0},L1:{from:.2,to:.8,phase:1,ecc:0},L2:{from:.5,to:.5,phase:0,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.5,to:.5,phase:0,ecc:0},R2:{from:.9,to:.3,phase:1,ecc:0}},"tease-back-swirl-right":{L0:{from:.7,to:.9,phase:0,ecc:0},L1:{from:.8,to:.2,phase:0,ecc:0},L2:{from:.2,to:.8,phase:1,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.2,to:.8,phase:1,ecc:0},R2:{from:.3,to:1,phase:0,ecc:0}},"tease-back-swirl-left":{L0:{from:.7,to:.9,phase:0,ecc:0},L1:{from:.8,to:.2,phase:0,ecc:0},L2:{from:.8,to:.2,phase:1,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.8,to:.2,phase:1,ecc:0},R2:{from:.3,to:1,phase:0,ecc:0}},"tease-up-down-circle-right":{L0:{from:.7,to:1,phase:0,ecc:0},L1:{from:.5,to:.5,phase:0,ecc:0},L2:{from:.3,to:.7,phase:1,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.3,to:.7,phase:1,ecc:0},R2:{from:.8,to:.8,phase:0,ecc:0}},"tease-up-down-circle-left":{L0:{from:.7,to:1,phase:0,ecc:0},L1:{from:.5,to:.5,phase:0,ecc:0},L2:{from:.7,to:.3,phase:1,ecc:0},R0:{from:.5,to:.5,phase:0,ecc:0},R1:{from:.7,to:.3,phase:1,ecc:0},R2:{from:.8,to:.8,phase:0,ecc:0}}};var i=r(254);class c extends o.Z{#oe;#se;#ae;#c;#ne;#ie;get angle(){return this.#oe}set angle(e){this.#oe=e}get startAngle(){return this.#ie}set startAngle(e){this.#ie=e}get bpm(){return this.#se}get startTime(){return this.#ne}set startTime(e){this.#ne=e}get timer(){return this.#c}static#ce=36;static#he=(0,i.Xh)(n);static set granularity(e){if(!(0,i.BP)(e,1,180))throw new Error(`Invalid granularity: ${e}`);c.#ce=e}static get granularity(){return c.#ce}static get DEFAULT_PARAMETERS(){return{from:0,to:1,phase:0,ecc:0,shift:0,noise:0,motion:s.Z.tempestMotion}}static get DEFAULT_TIMER(){return()=>performance.now()/1e3}static library=new Proxy({},{get:function(e,t,r){return t in c.#he?(0,i.Xh)(c.#he[t]):Reflect.get(e,t,r)},ownKeys:function(){return Object.keys(c.#he)},getOwnPropertyDescriptor:function(e,t){if(t in c.#he)return{enumerable:!0,configurable:!0,value:this[t]}}});static computeTargetAngle(e,t){const r=Math.abs(e-t),o=Math.floor(r/Math.PI),s=(o+1)*Math.PI+t;return s===e?(o+2)*Math.PI+t:s}static update(e,t){c.#he[e]=(0,i.Xh)(t)}static remove(e){delete c.#he[e]}static restoreLibrary(){c.#he=(0,i.Xh)(n)}constructor(e,t=60,r=0,o=c.DEFAULT_TIMER,s=null){if(super(),"string"==typeof e){if(!(0,i.e$)(c.library,e))throw new Error(`No stroke named ${e} found.`);e=c.library[e]}(0,i.w6)(this,"axes",{}),Object.keys(e).forEach((t=>{this.#pe(e[t]),(0,i.w6)(this.axes,t,{}),Object.keys(e[t]).forEach((r=>{(0,i.w6)(this.axes[t],r,e[t][r])})),Object.keys(c.DEFAULT_PARAMETERS).forEach((r=>{(0,i.e$)(e[t],r)||(0,i.w6)(this.axes[t],r,c.DEFAULT_PARAMETERS[r])}));const{from:r,to:o}=this.axes[t];(0,i.w6)(this.axes[t],"$current",{from:r,to:o})})),this.#oe=r,this.#ie=r,this.#ae=a.Z.createFrom(t),this.#se=this.#ae.next(),this.#c=o instanceof Function?{now:o}:o,this.#ne=s}*generate(e){this.#c?yield*this.#ue(e):yield*this.#fe(e)}*start(e,t){const r=this.getStartMoves(e,t);yield r}getStartMoves(e,t){const r={};t&&((0,i.e$)(t,"speed")||(0,i.e$)(t,"duration"))||(r.speed=1);const o={};return[...Object.keys(this.axes).map((s=>{o[e.getAxis(s).name]=!0;const a=this.axes[s];return{axis:s,to:a.motion(a.$current.from,a.$current.to,a.phase,a.ecc,this.#se,a.shift+this.#oe)({index:-1,frequency:e.frequency}),...r,...t}})),...e.getAxes().filter((e=>!o[e.name])).map((e=>{const o={axis:e.name,to:e.defaultValue,...r,...t};return"boolean"===e.type&&(delete o.speed,delete o.duration),o}))]}transition(e,t=60,r=1,o=null,s=null){return new h(e,t,this,r,o,s)}*#ue(e){this.#ne=this.#ne||this.#c.now();const t=c.computeTargetAngle(this.#oe,this.#ie);for(;this.#oe<t;){const t=2*(this.#c.now()-this.#ne)*Math.PI/60,r=this.#se*t,o=this.#oe;this.#oe=this.#ie+r,this.#le(e,this.#oe-o);const s=this.#se;this.#se=this.#ae.next(),this.#ie+=(s-this.#se)*t,yield e.period}}*#fe(){const{granularity:e}=c,t=this.#oe;for(let r=0;r<e;r++)yield this.#me(r),this.#oe=t+(r+1)*Math.PI/e,this.#se=this.#ae.next()}#le(e,t){const r={};Object.keys(this.axes).forEach((o=>{const s=this.axes[o];r[o]=s.motion(s.$current.from,s.$current.to,s.phase,s.ecc,this.#se,s.shift+this.#oe)({index:-1,frequency:e.frequency}),this.#de(s,this.#oe-t,t)})),e.setValues(r)}#me(){const{granularity:e}=c;return Object.keys(this.axes).map((t=>{const r=this.axes[t],o=30/e,s={axis:t,value:r.motion(r.$current.from,r.$current.to,r.phase,r.ecc,this.#se,r.shift+this.#oe),duration:o/this.#se};return this.#de(r,this.#oe,Math.PI/c.granularity),s}))}#de(e,t,r){if(e.noise){const{PI:o}=Math,s=e=>180*e/o,a=t=>(0,i.BP)(e.noise)?e.noise:e.noise[t]||0,n=e.phase*o/2+e.shift+t,c=Math.round(s(n%(2*o))),h=Math.round(c+s(r)),p=c<180&&h>=180;if(c<360&&h>=360){const t=a("to"),r=(e.from-e.to)/2;e.$current.to=e.to+t*r*Math.random()}else if(p){const t=a("from"),r=(e.to-e.from)/2;e.$current.from=e.from+t*r*Math.random()}}}#pe(e){if((0,i.e$)(e,"noise")){const{noise:t}=e,r=e=>{throw new Error(`Invalid noise: ${e}`)},o="object"==typeof t;o&&(0,i.e$)(t,"from")&&!(0,i.BP)(t.from,0,1)&&r(t.from),o&&(0,i.e$)(t,"to")&&!(0,i.BP)(t.to,0,1)&&r(t.to),o||(0,i.BP)(t,0,1)||r(t)}}}class h extends c{#N;#_e;#be;#ve;constructor(e,t,r,o,s,a){super(e,t,0,r.timer,r.startTime),this.angle=p.computeTransitionStartAngle(r,o,this.bpm),this.startAngle=this.angle;const n=(r.angle-r.startAngle)/(2*r.bpm*Math.PI/60);this.startTime+=n+o,this.#_e=new p(r,this,o),this.#N=e,this.#be=s,this.#ve=a,r.ayva&&(this.bind(r.ayva),this.#_e.bind(r.ayva))}*generate(e){this.#_e.complete||(this.#be instanceof Function&&this.#be(this.#_e.duration,this.bpm),yield*this.#_e(),this.#ve instanceof Function&&this.#ve(this.#N,this.bpm)),yield*super.generate(e)}}class p extends o.Z{#ye;#ge;#q;get duration(){return this.#q}constructor(e,t,r){super(),this.#ye=e,this.#ge=t,this.#q=r}*generate(e){if(!(e instanceof s.Z))throw new TypeError(`Invalid Ayva instance: ${e}`);const t={...c.DEFAULT_PARAMETERS,from:.5,to:.5,$current:{from:.5,to:.5}},r={...c.DEFAULT_PARAMETERS,from:0,to:0,$current:{from:0,to:0}},o=this.#we(this.#ye.axes,e),a=this.#we(this.#ge.axes,e),n={};Object.keys(a).forEach((s=>{const i="auxiliary"===e.getAxis(s).type?r:t,c=o[s]??{...i},h=a[s];n[s]=this.#xe(c,h)})),Object.keys(o).forEach((s=>{if(!n[s]){const a="auxiliary"===e.getAxis(s).type?r:t,i=o[s],c={...a};n[s]=this.#xe(i,c)}}));const i=[];Object.keys(n).forEach((e=>{i.push({axis:e,...n[e]})})),yield i,this.complete=!0}#xe(e,t){const r=this.#ye.bpm,o=(this.#ye.bpm+this.#ge.bpm)/2;return{value:a=>{const{x:n}=a,i=s.Z.map(n,0,1,e.$current.from,t.$current.from),c=s.Z.map(n,0,1,e.$current.to,t.$current.to),h=s.Z.map(n,0,1,e.phase,t.phase),p=s.Z.map(n,0,1,e.ecc,t.ecc),u=s.Z.map(n,0,1,r,o);return s.Z.blendMotion(e.motion(i,c,h,p,u,this.#ye.angle),t.motion(i,c,h,p,u,this.#ye.angle),n)(a)},duration:this.#q}}#we(e,t){return Object.keys(e).reduce(((r,o)=>(r[t.getAxis(o).name]=e[o],r)),{})}static computeTransitionStartAngle(e,t,r){const o=(e.bpm+r)/2;return e.angle+2*Math.PI*(o/60)*t}}const u=c},336:(e,t,r)=>{r.d(t,{Z:()=>o});const o=class{#H;#Re=[];constructor(e){this.#H=e,Object.values(e.axes).forEach((e=>{this[e.name]=this.#Le(e.name),e.alias&&(this[e.alias]=this.#Le(e.alias))}))}execute(){return this.#H.move(...this.#Re)}#Le(e){return(...t)=>{if(3===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]&&"function"==typeof t[2])this.#Re.push({axis:e,to:t[0],duration:t[1],value:t[2]});else if(2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1])this.#Re.push({axis:e,to:t[0],duration:t[1]});else if(2===t.length&&"number"==typeof t[0]&&"function"==typeof t[1])this.#Re.push({axis:e,to:t[0],value:t[1]});else if(1===t.length&&"number"==typeof t[0])this.#Re.push({axis:e,to:t[0]});else if(2===t.length&&"function"==typeof t[0]&&"number"==typeof t[1])this.#Re.push({axis:e,value:t[0],duration:t[1]});else if(1===t.length&&"function"==typeof t[0])this.#Re.push({axis:e,value:t[0]});else{if(1!==t.length||"object"!=typeof t[0])throw new Error(`Invalid arguments: ${t}`);this.#Re.push({...t[0],axis:e})}return this}}}},424:(e,t,r)=>{r.r(t),r.d(t,{Ayva:()=>o.Z,GeneratorBehavior:()=>s.Z,ClassicStroke:()=>a.Z,TempestStroke:()=>n.Z,VariableDuration:()=>i.Z});var o=r(570),s=r(697),a=r(321),n=r(824),i=r(217)},319:(e,t,r)=>{r.d(t,{Z:()=>o});class o{#Ae=0;#ke;constructor(e){this.#ke=e}next(){return this.#ke(this.#Ae++)}get index(){return this.#Ae}static createFrom(e){return new o(e instanceof Array?t=>e[t%e.length]:"function"!=typeof e?()=>e:e)}}},254:(e,t,r)=>{r.d(t,{uZ:()=>Je,Xh:()=>Xe,w6:()=>Ye,bG:()=>tt,e$:()=>et,Af:()=>rt,NM:()=>He,BP:()=>Qe});var o="__lodash_hash_undefined__",s=9007199254740991,a="[object Arguments]",n="[object Boolean]",i="[object Date]",c="[object Function]",h="[object GeneratorFunction]",p="[object Map]",u="[object Number]",f="[object Object]",l="[object Promise]",m="[object RegExp]",d="[object Set]",_="[object String]",b="[object Symbol]",v="[object WeakMap]",y="[object ArrayBuffer]",g="[object DataView]",w="[object Float32Array]",x="[object Float64Array]",R="[object Int8Array]",L="[object Int16Array]",A="[object Int32Array]",k="[object Uint8Array]",M="[object Uint8ClampedArray]",P="[object Uint16Array]",E="[object Uint32Array]",$=/\w*$/,S=/^\[object .+?Constructor\]$/,j=/^(?:0|[1-9]\d*)$/,O={};O[a]=O["[object Array]"]=O[y]=O[g]=O[n]=O[i]=O[w]=O[x]=O[R]=O[L]=O[A]=O[p]=O[u]=O[f]=O[m]=O[d]=O[_]=O[b]=O[k]=O[M]=O[P]=O[E]=!0,O["[object Error]"]=O[c]=O[v]=!1;var T="object"==typeof global&&global&&global.Object===Object&&global,I="object"==typeof self&&self&&self.Object===Object&&self,B=T||I||Function("return this")(),C="object"==typeof exports&&exports&&!exports.nodeType&&exports,F=C&&"object"==typeof module&&module&&!module.nodeType&&module,D=F&&F.exports===C;function Z(e,t){return e.set(t[0],t[1]),e}function V(e,t){return e.add(t),e}function q(e,t,r,o){var s=-1,a=e?e.length:0;for(o&&a&&(r=e[++s]);++s<a;)r=t(r,e[s],s,e);return r}function N(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function G(e){var t=-1,r=Array(e.size);return e.forEach((function(e,o){r[++t]=[o,e]})),r}function U(e,t){return function(r){return e(t(r))}}function W(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}var z,K=Array.prototype,X=Function.prototype,H=Object.prototype,J=B["__core-js_shared__"],Q=(z=/[^.]+$/.exec(J&&J.keys&&J.keys.IE_PROTO||""))?"Symbol(src)_1."+z:"",Y=X.toString,ee=H.hasOwnProperty,te=H.toString,re=RegExp("^"+Y.call(ee).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),oe=D?B.Buffer:void 0,se=B.Symbol,ae=B.Uint8Array,ne=U(Object.getPrototypeOf,Object),ie=Object.create,ce=H.propertyIsEnumerable,he=K.splice,pe=Object.getOwnPropertySymbols,ue=oe?oe.isBuffer:void 0,fe=U(Object.keys,Object),le=Be(B,"DataView"),me=Be(B,"Map"),de=Be(B,"Promise"),_e=Be(B,"Set"),be=Be(B,"WeakMap"),ve=Be(Object,"create"),ye=Ve(le),ge=Ve(me),we=Ve(de),xe=Ve(_e),Re=Ve(be),Le=se?se.prototype:void 0,Ae=Le?Le.valueOf:void 0;function ke(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var o=e[t];this.set(o[0],o[1])}}function Me(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var o=e[t];this.set(o[0],o[1])}}function Pe(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var o=e[t];this.set(o[0],o[1])}}function Ee(e){this.__data__=new Me(e)}function $e(e,t,r){var o=e[t];ee.call(e,t)&&qe(o,r)&&(void 0!==r||t in e)||(e[t]=r)}function Se(e,t){for(var r=e.length;r--;)if(qe(e[r][0],t))return r;return-1}function je(e,t,r,o,s,l,v){var S;if(o&&(S=l?o(e,s,l,v):o(e)),void 0!==S)return S;if(!ze(e))return e;var j=Ne(e);if(j){if(S=function(e){var t=e.length,r=e.constructor(t);return t&&"string"==typeof e[0]&&ee.call(e,"index")&&(r.index=e.index,r.input=e.input),r}(e),!t)return function(e,t){var r=-1,o=e.length;for(t||(t=Array(o));++r<o;)t[r]=e[r];return t}(e,S)}else{var T=Fe(e),I=T==c||T==h;if(Ue(e))return function(e,t){if(t)return e.slice();var r=new e.constructor(e.length);return e.copy(r),r}(e,t);if(T==f||T==a||I&&!l){if(N(e))return l?e:{};if(S=function(e){return"function"!=typeof e.constructor||Ze(e)?{}:ze(t=ne(e))?ie(t):{};var t}(I?{}:e),!t)return function(e,t){return Te(e,Ce(e),t)}(e,function(e,t){return e&&Te(t,Ke(t),e)}(S,e))}else{if(!O[T])return l?e:{};S=function(e,t,r,o){var s,a=e.constructor;switch(t){case y:return Oe(e);case n:case i:return new a(+e);case g:return function(e,t){var r=t?Oe(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,o);case w:case x:case R:case L:case A:case k:case M:case P:case E:return function(e,t){var r=t?Oe(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}(e,o);case p:return function(e,t,r){return q(t?r(G(e),!0):G(e),Z,new e.constructor)}(e,o,r);case u:case _:return new a(e);case m:return function(e){var t=new e.constructor(e.source,$.exec(e));return t.lastIndex=e.lastIndex,t}(e);case d:return function(e,t,r){return q(t?r(W(e),!0):W(e),V,new e.constructor)}(e,o,r);case b:return s=e,Ae?Object(Ae.call(s)):{}}}(e,T,je,t)}}v||(v=new Ee);var B=v.get(e);if(B)return B;if(v.set(e,S),!j)var C=r?function(e){return function(e,t,r){var o=t(e);return Ne(e)?o:function(e,t){for(var r=-1,o=t.length,s=e.length;++r<o;)e[s+r]=t[r];return e}(o,r(e))}(e,Ke,Ce)}(e):Ke(e);return function(e,t){for(var r=-1,o=e?e.length:0;++r<o&&!1!==t(e[r],r););}(C||e,(function(s,a){C&&(s=e[a=s]),$e(S,a,je(s,t,r,o,a,e,v))})),S}function Oe(e){var t=new e.constructor(e.byteLength);return new ae(t).set(new ae(e)),t}function Te(e,t,r,o){r||(r={});for(var s=-1,a=t.length;++s<a;){var n=t[s],i=o?o(r[n],e[n],n,r,e):void 0;$e(r,n,void 0===i?e[n]:i)}return r}function Ie(e,t){var r,o,s=e.__data__;return("string"==(o=typeof(r=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==r:null===r)?s["string"==typeof t?"string":"hash"]:s.map}function Be(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return function(e){return!(!ze(e)||(t=e,Q&&Q in t))&&(We(e)||N(e)?re:S).test(Ve(e));var t}(r)?r:void 0}ke.prototype.clear=function(){this.__data__=ve?ve(null):{}},ke.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},ke.prototype.get=function(e){var t=this.__data__;if(ve){var r=t[e];return r===o?void 0:r}return ee.call(t,e)?t[e]:void 0},ke.prototype.has=function(e){var t=this.__data__;return ve?void 0!==t[e]:ee.call(t,e)},ke.prototype.set=function(e,t){return this.__data__[e]=ve&&void 0===t?o:t,this},Me.prototype.clear=function(){this.__data__=[]},Me.prototype.delete=function(e){var t=this.__data__,r=Se(t,e);return!(r<0||(r==t.length-1?t.pop():he.call(t,r,1),0))},Me.prototype.get=function(e){var t=this.__data__,r=Se(t,e);return r<0?void 0:t[r][1]},Me.prototype.has=function(e){return Se(this.__data__,e)>-1},Me.prototype.set=function(e,t){var r=this.__data__,o=Se(r,e);return o<0?r.push([e,t]):r[o][1]=t,this},Pe.prototype.clear=function(){this.__data__={hash:new ke,map:new(me||Me),string:new ke}},Pe.prototype.delete=function(e){return Ie(this,e).delete(e)},Pe.prototype.get=function(e){return Ie(this,e).get(e)},Pe.prototype.has=function(e){return Ie(this,e).has(e)},Pe.prototype.set=function(e,t){return Ie(this,e).set(e,t),this},Ee.prototype.clear=function(){this.__data__=new Me},Ee.prototype.delete=function(e){return this.__data__.delete(e)},Ee.prototype.get=function(e){return this.__data__.get(e)},Ee.prototype.has=function(e){return this.__data__.has(e)},Ee.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Me){var o=r.__data__;if(!me||o.length<199)return o.push([e,t]),this;r=this.__data__=new Pe(o)}return r.set(e,t),this};var Ce=pe?U(pe,Object):function(){return[]},Fe=function(e){return te.call(e)};function De(e,t){return!!(t=null==t?s:t)&&("number"==typeof e||j.test(e))&&e>-1&&e%1==0&&e<t}function Ze(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||H)}function Ve(e){if(null!=e){try{return Y.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function qe(e,t){return e===t||e!=e&&t!=t}(le&&Fe(new le(new ArrayBuffer(1)))!=g||me&&Fe(new me)!=p||de&&Fe(de.resolve())!=l||_e&&Fe(new _e)!=d||be&&Fe(new be)!=v)&&(Fe=function(e){var t=te.call(e),r=t==f?e.constructor:void 0,o=r?Ve(r):void 0;if(o)switch(o){case ye:return g;case ge:return p;case we:return l;case xe:return d;case Re:return v}return t});var Ne=Array.isArray;function Ge(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=s}(e.length)&&!We(e)}var Ue=ue||function(){return!1};function We(e){var t=ze(e)?te.call(e):"";return t==c||t==h}function ze(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ke(e){return Ge(e)?function(e,t){var r=Ne(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&Ge(e)}(e)&&ee.call(e,"callee")&&(!ce.call(e,"callee")||te.call(e)==a)}(e)?function(e,t){for(var r=-1,o=Array(e);++r<e;)o[r]=t(r);return o}(e.length,String):[],o=r.length,s=!!o;for(var n in e)!t&&!ee.call(e,n)||s&&("length"==n||De(n,o))||r.push(n);return r}(e):function(e){if(!Ze(e))return fe(e);var t=[];for(var r in Object(e))ee.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}const Xe=function(e){return je(e,!0,!0)};function He(e,t=0){const r=10**t;return Math.round(r*e)/r}function Je(e,t,r){return Math.max(t,Math.min(r,e))}function Qe(e,t,r){return!(!Number.isFinite(e)||void 0!==t&&e<t||void 0!==r&&e>r)}function Ye(e,t,r){Object.defineProperty(e,t,{value:r,writeable:!1,configurable:!1,enumerable:!0})}function et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function tt(e){throw new Error(e)}function rt(e){return"GeneratorFunction"===e.constructor.name}},217:(e,t,r)=>{r.d(t,{Z:()=>s});var o=r(254);const s=class{#ne;#Me;constructor(e,t){if((0,o.BP)(e,0)&&void 0===t)this.#Me=1e3*e;else{if(!(0,o.BP)(e,0)||!(0,o.BP)(t,0))throw new Error(`Invalid duration range: (${e}, ${t})`);{const r=Math.min(e,t),o=Math.max(e,t);this.#Me=1e3*(Math.random()*(o-r)+r)}}this.#ne=performance.now()}get targetElapsed(){return this.#Me}get complete(){return performance.now()-this.#ne>=this.#Me}get percentage(){return(0,o.uZ)((performance.now()-this.#ne)/this.#Me,0,1)}}}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](r,r.exports,__webpack_require__),r.exports}__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};(()=>{__webpack_require__.d(__webpack_exports__,{kZ:()=>e.Z,OC:()=>h,fV:()=>o.Z,o0:()=>p,we:()=>t.Z,qT:()=>r.Z,ft:()=>s.Z,ni:()=>a.Z,_I:()=>n,IS:()=>i});var e=__webpack_require__(570),t=__webpack_require__(697),r=__webpack_require__(590),o=__webpack_require__(321),s=__webpack_require__(824),a=__webpack_require__(217);const n=class{connected=!1;_baudRate;_output=null;_input=null;_serial=null;_outputClosedPromise=null;_inputClosedPromise=null;constructor(e=115200,t=null){this._baudRate=e,this._serial=t||(globalThis.navigator?globalThis.navigator.serial:null)}async requestConnection(){if(!this._serial)throw new Error("Web Serial is not supported in this browser.");const e=await this._serial.requestPort();await e.open({baudRate:this._baudRate});const t=new TextEncoderStream;this._outputClosedPromise=t.readable.pipeTo(e.writable);const r=new TextDecoderStream;this._inputClosedPromise=e.readable.pipeTo(r.writable),this._output=t.writable.getWriter(),this._input=r.readable.getReader(),this._port=e,this.connected=!0;const o=t=>{t.target===e&&(this.connected=!1,this._serial.removeEventListener("disconnect",o))};return this._serial.addEventListener("disconnect",o),new Promise((e=>{setTimeout(e,2e3)}))}async disconnect(){this.connected=!1,this._input.cancel(),this._output.close(),await this._inputClosedPromise.catch((()=>{})),await this._outputClosedPromise,await this._port.close(),this._output=null,this._input=null,this._inputClosedPromise=null,this._outputClosedPromise=null}write(e){if(!this.connected)throw new Error("No device connected.");this._output.write(e)}},i=class{connected=!1;_host=null;_port=null;_socket=null;constructor(e,t,r=(()=>{})){this._host=e,this._port=t,this._errorHandler=r}async requestConnection(){let e=!1;return new Promise(((t,r)=>{const o="localhost"===this._host?"ws":"wss",s=new WebSocket(`${o}://${this._host}:${this._port}/ws`);s.onopen=()=>{t(),e=!0,this.connec