From f4b58e1bbc69b039bd5b5112e99d8a8d18c5553c Mon Sep 17 00:00:00 2001 From: domi7777 Date: Sun, 10 Nov 2024 22:57:24 +0000 Subject: [PATCH] deploy: f78bf0c5e652a13babeefcb931a2b1296b8dec3d --- assets/{index-hu0Kyz0h.js => index-GQ7Rhk9V.js} | 12 ++++++------ index.html | 2 +- sw.js | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) rename assets/{index-hu0Kyz0h.js => index-GQ7Rhk9V.js} (55%) diff --git a/assets/index-hu0Kyz0h.js b/assets/index-GQ7Rhk9V.js similarity index 55% rename from assets/index-hu0Kyz0h.js rename to assets/index-GQ7Rhk9V.js index e401825..44b8b76 100644 --- a/assets/index-hu0Kyz0h.js +++ b/assets/index-GQ7Rhk9V.js @@ -1,4 +1,4 @@ -var Hi=Object.defineProperty;var $i=(n,t,e)=>t in n?Hi(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var w=(n,t,e)=>($i(n,typeof t!="symbol"?t+"":t,e),e);import{r as Ki,a as qi,R as Ui}from"./react-H14vcryl.js";import{P}from"./phaser-pQREW5IE.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function e(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=e(r);fetch(r.href,s)}})();var In={exports:{}},se={};/** +var Ki=Object.defineProperty;var qi=(n,t,e)=>t in n?Ki(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var g=(n,t,e)=>(qi(n,typeof t!="symbol"?t+"":t,e),e);import{r as Ui,a as Gi,R as Wi}from"./react-H14vcryl.js";import{P as y}from"./phaser-pQREW5IE.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function e(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=e(r);fetch(r.href,s)}})();var In={exports:{}},oe={};/** * @license React * react-jsx-runtime.production.min.js * @@ -6,8 +6,8 @@ var Hi=Object.defineProperty;var $i=(n,t,e)=>t in n?Hi(n,t,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Gi=Ki,Wi=Symbol.for("react.element"),Yi=Symbol.for("react.fragment"),Xi=Object.prototype.hasOwnProperty,Qi=Gi.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Zi={key:!0,ref:!0,__self:!0,__source:!0};function jn(n,t,e){var i,r={},s=null,o=null;e!==void 0&&(s=""+e),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(o=t.ref);for(i in t)Xi.call(t,i)&&!Zi.hasOwnProperty(i)&&(r[i]=t[i]);if(n&&n.defaultProps)for(i in t=n.defaultProps,t)r[i]===void 0&&(r[i]=t[i]);return{$$typeof:Wi,type:n,key:s,ref:o,props:r,_owner:Qi.current}}se.Fragment=Yi;se.jsx=jn;se.jsxs=jn;In.exports=se;var Vt=In.exports,Ce={},rn=qi;Ce.createRoot=rn.createRoot,Ce.hydrateRoot=rn.hydrateRoot;const St={Icons:"Icons",Text:"Courier"},Xt={tiny:"15px",small:"30px",medium:"50px",big:"90px"},xe={white:"#FFF"},Ji=async()=>{const n=new FontFace(St.Icons,"url(./fonts/material.woff2)");return document.fonts.add(n),n.load().catch(t=>console.error(t))},N=(n,t=!1)=>P.Display.Color.HexStringToColor(n).darken(t?75:0).color;let Gt=null;const nt=()=>{if(!Gt){const n=window.AudioContext||window.webkitAudioContext;Gt=new n}return Gt},tr=()=>{Gt=null};function er(n=100){const t=nt(),e=t.sampleRate*.05,i=t.createBuffer(1,e,t.sampleRate),r=i.getChannelData(0);for(let p=0;p{const s=n[r],o=t[r];return ye(s)&&ye(o)?Object.assign(Object.assign({},i),{[r]:st(s,o)}):Object.assign(Object.assign({},i),{[r]:r in t?o:s})},{})}function Ae(n){return Le(n)?"target"in n:!1}const cr={alreadydisposed:()=>"View has been already disposed",invalidparams:n=>`Invalid parameters for '${n.name}'`,nomatchingcontroller:n=>`No matching controller for '${n.key}'`,nomatchingview:n=>`No matching view for '${JSON.stringify(n.params)}'`,notbindable:()=>"Value is not bindable",notcompatible:n=>`Not compatible with plugin '${n.id}'`,propertynotfound:n=>`Property '${n.name}' not found`,shouldneverhappen:()=>"This error should never happen"};class E{static alreadyDisposed(){return new E({type:"alreadydisposed"})}static notBindable(){return new E({type:"notbindable"})}static notCompatible(t,e){return new E({type:"notcompatible",context:{id:`${t}.${e}`}})}static propertyNotFound(t){return new E({type:"propertynotfound",context:{name:t}})}static shouldNeverHappen(){return new E({type:"shouldneverhappen"})}constructor(t){var e;this.message=(e=cr[t.type](t.context))!==null&&e!==void 0?e:"Unexpected error",this.name=this.constructor.name,this.stack=new Error(this.message).stack,this.type=t.type}toString(){return this.message}}class Qt{constructor(t,e){this.obj_=t,this.key=e}static isBindable(t){return!(t===null||typeof t!="object"&&typeof t!="function")}read(){return this.obj_[this.key]}write(t){this.obj_[this.key]=t}writeProperty(t,e){const i=this.read();if(!Qt.isBindable(i))throw E.notBindable();if(!(t in i))throw E.propertyNotFound(t);i[t]=e}}class k{constructor(){this.observers_={}}on(t,e,i){var r;let s=this.observers_[t];return s||(s=this.observers_[t]=[]),s.push({handler:e,key:(r=i==null?void 0:i.key)!==null&&r!==void 0?r:e}),this}off(t,e){const i=this.observers_[t];return i&&(this.observers_[t]=i.filter(r=>r.key!==e)),this}emit(t,e){const i=this.observers_[t];i&&i.forEach(r=>{r.handler(e)})}}class pr{constructor(t,e){var i;this.constraint_=e==null?void 0:e.constraint,this.equals_=(i=e==null?void 0:e.equals)!==null&&i!==void 0?i:(r,s)=>r===s,this.emitter=new k,this.rawValue_=t}get constraint(){return this.constraint_}get rawValue(){return this.rawValue_}set rawValue(t){this.setRawValue(t,{forceEmit:!1,last:!0})}setRawValue(t,e){const i=e??{forceEmit:!1,last:!0},r=this.constraint_?this.constraint_.constrain(t):t,s=this.rawValue_;this.equals_(s,r)&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.rawValue_=r,this.emitter.emit("change",{options:i,previousRawValue:s,rawValue:r,sender:this}))}}class dr{constructor(t){this.emitter=new k,this.value_=t}get rawValue(){return this.value_}set rawValue(t){this.setRawValue(t,{forceEmit:!1,last:!0})}setRawValue(t,e){const i=e??{forceEmit:!1,last:!0},r=this.value_;r===t&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.value_=t,this.emitter.emit("change",{options:i,previousRawValue:r,rawValue:this.value_,sender:this}))}}class ur{constructor(t){this.emitter=new k,this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.value_=t,this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_)}get rawValue(){return this.value_.rawValue}onValueBeforeChange_(t){this.emitter.emit("beforechange",Object.assign(Object.assign({},t),{sender:this}))}onValueChange_(t){this.emitter.emit("change",Object.assign(Object.assign({},t),{sender:this}))}}function C(n,t){const e=t==null?void 0:t.constraint,i=t==null?void 0:t.equals;return!e&&!i?new dr(n):new pr(n,t)}function hr(n){return[new ur(n),(t,e)=>{n.setRawValue(t,e)}]}class u{constructor(t){this.emitter=new k,this.valMap_=t;for(const e in this.valMap_)this.valMap_[e].emitter.on("change",()=>{this.emitter.emit("change",{key:e,sender:this})})}static createCore(t){return Object.keys(t).reduce((i,r)=>Object.assign(i,{[r]:C(t[r])}),{})}static fromObject(t){const e=this.createCore(t);return new u(e)}get(t){return this.valMap_[t].rawValue}set(t,e){this.valMap_[t].rawValue=e}value(t){return this.valMap_[t]}}class Ft{constructor(t){this.values=u.fromObject({max:t.max,min:t.min})}constrain(t){const e=this.values.get("max"),i=this.values.get("min");return Math.min(Math.max(t,i),e)}}class vr{constructor(t){this.values=u.fromObject({max:t.max,min:t.min})}constrain(t){const e=this.values.get("max"),i=this.values.get("min");let r=t;return g(i)||(r=Math.max(r,i)),g(e)||(r=Math.min(r,e)),r}}class mr{constructor(t,e=0){this.step=t,this.origin=e}constrain(t){const e=this.origin%this.step,i=Math.round((t-e)/this.step);return e+i*this.step}}class br{constructor(t){this.text=t}evaluate(){return Number(this.text)}toString(){return this.text}}const fr={"**":(n,t)=>Math.pow(n,t),"*":(n,t)=>n*t,"/":(n,t)=>n/t,"%":(n,t)=>n%t,"+":(n,t)=>n+t,"-":(n,t)=>n-t,"<<":(n,t)=>n<>":(n,t)=>n>>t,">>>":(n,t)=>n>>>t,"&":(n,t)=>n&t,"^":(n,t)=>n^t,"|":(n,t)=>n|t};class gr{constructor(t,e,i){this.left=e,this.operator=t,this.right=i}evaluate(){const t=fr[this.operator];if(!t)throw new Error(`unexpected binary operator: '${this.operator}`);return t(this.left.evaluate(),this.right.evaluate())}toString(){return["b(",this.left.toString(),this.operator,this.right.toString(),")"].join(" ")}}const wr={"+":n=>n,"-":n=>-n,"~":n=>~n};class _r{constructor(t,e){this.operator=t,this.expression=e}evaluate(){const t=wr[this.operator];if(!t)throw new Error(`unexpected unary operator: '${this.operator}`);return t(this.expression.evaluate())}toString(){return["u(",this.operator,this.expression.toString(),")"].join(" ")}}function Re(n){return(t,e)=>{for(let i=0;it.startsWith(r,e))[0];return i?(e+=i.length,e+=Tt(t,e).length,{cursor:e,operator:i}):null}function jr(n,t){return(e,i)=>{const r=n(e,i);if(!r)return null;i=r.cursor;let s=r.evaluable;for(;;){const o=Ir(t,e,i);if(!o)break;i=o.cursor;const a=n(e,i);if(!a)return null;i=a.cursor,s=new gr(o.operator,s,a.evaluable)}return s?{cursor:i,evaluable:s}:null}}const Nr=[["**"],["*","/","%"],["+","-"],["<<",">>>",">>"],["&"],["^"],["|"]].reduce((n,t)=>jr(n,t),Hn);function $n(n,t){return t+=Tt(n,t).length,Nr(n,t)}function zr(n){const t=$n(n,0);return!t||t.cursor+Tt(n,t.cursor).length!==n.length?null:t.evaluable}function G(n){var t;const e=zr(n);return(t=e==null?void 0:e.evaluate())!==null&&t!==void 0?t:null}function Kn(n){if(typeof n=="number")return n;if(typeof n=="string"){const t=G(n);if(!g(t))return t}return 0}function Hr(n){return String(n)}function O(n){return t=>t.toFixed(Math.max(Math.min(n,20),0))}function b(n,t,e,i,r){const s=(n-t)/(e-t);return i+s*(r-i)}function sn(n){return String(n.toFixed(10)).split(".")[1].replace(/0+$/,"").length}function V(n,t,e){return Math.min(Math.max(n,t),e)}function qn(n,t){return(n%t+t)%t}function $r(n,t){return g(n.step)?Math.max(sn(t),2):sn(n.step)}function Un(n){var t;return(t=n.step)!==null&&t!==void 0?t:1}function Gn(n,t){var e;const i=Math.abs((e=n.step)!==null&&e!==void 0?e:t);return i===0?.1:Math.pow(10,Math.floor(Math.log10(i))-1)}function Wn(n,t){return g(n.step)?null:new mr(n.step,t)}function Yn(n){return!g(n.max)&&!g(n.min)?new Ft({max:n.max,min:n.min}):!g(n.max)||!g(n.min)?new vr({max:n.max,min:n.min}):null}function Xn(n,t){var e,i,r;return{formatter:(e=n.format)!==null&&e!==void 0?e:O($r(n,t)),keyScale:(i=n.keyScale)!==null&&i!==void 0?i:Un(n),pointerScale:(r=n.pointerScale)!==null&&r!==void 0?r:Gn(n,t)}}function Qn(n){return{format:n.optional.function,keyScale:n.optional.number,max:n.optional.number,min:n.optional.number,pointerScale:n.optional.number,step:n.optional.number}}function Me(n){return{constraint:n.constraint,textProps:u.fromObject(Xn(n.params,n.initialValue))}}class lt{constructor(t){this.controller=t}get element(){return this.controller.view.element}get disabled(){return this.controller.viewProps.get("disabled")}set disabled(t){this.controller.viewProps.set("disabled",t)}get hidden(){return this.controller.viewProps.get("hidden")}set hidden(t){this.controller.viewProps.set("hidden",t)}dispose(){this.controller.viewProps.set("disposed",!0)}importState(t){return this.controller.importState(t)}exportState(){return this.controller.exportState()}}class oe{constructor(t){this.target=t}}class Bt extends oe{constructor(t,e,i){super(t),this.value=e,this.last=i??!0}}class Kr extends oe{constructor(t,e){super(t),this.expanded=e}}class qr extends oe{constructor(t,e){super(t),this.index=e}}class Ur extends oe{constructor(t,e){super(t),this.native=e}}class At extends lt{constructor(t){super(t),this.onValueChange_=this.onValueChange_.bind(this),this.emitter_=new k,this.controller.value.emitter.on("change",this.onValueChange_)}get label(){return this.controller.labelController.props.get("label")}set label(t){this.controller.labelController.props.set("label",t)}get key(){return this.controller.value.binding.target.key}get tag(){return this.controller.tag}set tag(t){this.controller.tag=t}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}refresh(){this.controller.value.fetch()}onValueChange_(t){const e=this.controller.value;this.emitter_.emit("change",new Bt(this,e.binding.target.read(),t.options.last))}}class Gr{constructor(t,e){this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.binding=e,this.value_=t,this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_),this.emitter=new k}get rawValue(){return this.value_.rawValue}set rawValue(t){this.value_.rawValue=t}setRawValue(t,e){this.value_.setRawValue(t,e)}fetch(){this.value_.rawValue=this.binding.read()}push(){this.binding.write(this.value_.rawValue)}onValueBeforeChange_(t){this.emitter.emit("beforechange",Object.assign(Object.assign({},t),{sender:this}))}onValueChange_(t){this.push(),this.emitter.emit("change",Object.assign(Object.assign({},t),{sender:this}))}}function Wr(n){if(!("binding"in n))return!1;const t=n.binding;return Ae(t)&&"read"in t&&"write"in t}function Yr(n,t){const i=Object.keys(t).reduce((r,s)=>{if(r===void 0)return;const o=t[s],a=o(n[s]);return a.succeeded?Object.assign(Object.assign({},r),{[s]:a.value}):void 0},{});return i}function Xr(n,t){return n.reduce((e,i)=>{if(e===void 0)return;const r=t(i);if(!(!r.succeeded||r.value===void 0))return[...e,r.value]},[])}function Qr(n){return n===null?!1:typeof n=="object"}function K(n){return t=>e=>{if(!t&&e===void 0)return{succeeded:!1,value:void 0};if(t&&e===void 0)return{succeeded:!0,value:void 0};const i=n(e);return i!==void 0?{succeeded:!0,value:i}:{succeeded:!1,value:void 0}}}function on(n){return{custom:t=>K(t)(n),boolean:K(t=>typeof t=="boolean"?t:void 0)(n),number:K(t=>typeof t=="number"?t:void 0)(n),string:K(t=>typeof t=="string"?t:void 0)(n),function:K(t=>typeof t=="function"?t:void 0)(n),constant:t=>K(e=>e===t?t:void 0)(n),raw:K(t=>t)(n),object:t=>K(e=>{if(Qr(e))return Yr(e,t)})(n),array:t=>K(e=>{if(Array.isArray(e))return Xr(e,t)})(n)}}const Pe={optional:on(!0),required:on(!1)};function x(n,t){const e=t(Pe),i=Pe.required.object(e)(n);return i.succeeded?i.value:void 0}function M(n,t,e,i){if(t&&!t(n))return!1;const r=x(n,e);return r?i(r):!1}function D(n,t){var e;return st((e=n==null?void 0:n())!==null&&e!==void 0?e:{},t)}function rt(n){return"value"in n}function Zn(n){if(!Le(n)||!("binding"in n))return!1;const t=n.binding;return Ae(t)}const z="http://www.w3.org/2000/svg";function Zt(n){n.offsetHeight}function Zr(n,t){const e=n.style.transition;n.style.transition="none",t(),n.style.transition=e}function De(n){return n.ontouchstart!==void 0}function Jr(){return globalThis}function ts(){return Jr().document}function es(n){const t=n.ownerDocument.defaultView;return t&&"document"in t?n.getContext("2d",{willReadFrequently:!0}):null}const ns={check:'',dropdown:'',p2dpad:''};function ae(n,t){const e=n.createElementNS(z,"svg");return e.innerHTML=ns[t],e}function Jn(n,t,e){n.insertBefore(t,n.children[e])}function Fe(n){n.parentElement&&n.parentElement.removeChild(n)}function ti(n){for(;n.children.length>0;)n.removeChild(n.children[0])}function is(n){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])}function ei(n){return n.relatedTarget?n.relatedTarget:"explicitOriginalTarget"in n?n.explicitOriginalTarget:null}function U(n,t){n.emitter.on("change",e=>{t(e.rawValue)}),t(n.rawValue)}function H(n,t,e){U(n.value(t),e)}const rs="tp";function v(n){return(e,i)=>[rs,"-",n,"v",e?`_${e}`:"",i?`-${i}`:""].join("")}const Ct=v("lbl");function ss(n,t){const e=n.createDocumentFragment();return t.split(` -`).map(r=>n.createTextNode(r)).forEach((r,s)=>{s>0&&e.appendChild(n.createElement("br")),e.appendChild(r)}),e}class ni{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(Ct()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(Ct("l")),H(e.props,"label",s=>{g(s)?this.element.classList.add(Ct(void 0,"nol")):(this.element.classList.remove(Ct(void 0,"nol")),is(i),i.appendChild(ss(t,s)))}),this.element.appendChild(i),this.labelElement=i;const r=t.createElement("div");r.classList.add(Ct("v")),this.element.appendChild(r),this.valueElement=r}}class ii{constructor(t,e){this.props=e.props,this.valueController=e.valueController,this.viewProps=e.valueController.viewProps,this.view=new ni(t,{props:e.props,viewProps:this.viewProps}),this.view.valueElement.appendChild(this.valueController.view.element)}importProps(t){return M(t,null,e=>({label:e.optional.string}),e=>(this.props.set("label",e.label),!0))}exportProps(){return D(null,{label:this.props.get("label")})}}function os(){return["veryfirst","first","last","verylast"]}const an=v(""),ln={veryfirst:"vfst",first:"fst",last:"lst",verylast:"vlst"};class le{constructor(t){this.parent_=null,this.blade=t.blade,this.view=t.view,this.viewProps=t.viewProps;const e=this.view.element;this.blade.value("positions").emitter.on("change",()=>{os().forEach(i=>{e.classList.remove(an(void 0,ln[i]))}),this.blade.get("positions").forEach(i=>{e.classList.add(an(void 0,ln[i]))})}),this.viewProps.handleDispose(()=>{Fe(e)})}get parent(){return this.parent_}set parent(t){this.parent_=t,this.viewProps.set("parent",this.parent_?this.parent_.viewProps:null)}importState(t){return M(t,null,e=>({disabled:e.required.boolean,hidden:e.required.boolean}),e=>(this.viewProps.importState(e),!0))}exportState(){return D(null,Object.assign({},this.viewProps.exportState()))}}class ot extends le{constructor(t,e){if(e.value!==e.valueController.value)throw E.shouldNeverHappen();const i=e.valueController.viewProps,r=new ii(t,{blade:e.blade,props:e.props,valueController:e.valueController});super(Object.assign(Object.assign({},e),{view:new ni(t,{props:e.props,viewProps:i}),viewProps:i})),this.labelController=r,this.value=e.value,this.valueController=e.valueController,this.view.valueElement.appendChild(this.valueController.view.element)}importState(t){return M(t,e=>{var i,r,s;return super.importState(e)&&this.labelController.importProps(e)&&((s=(r=(i=this.valueController).importProps)===null||r===void 0?void 0:r.call(i,t))!==null&&s!==void 0?s:!0)},e=>({value:e.optional.raw}),e=>(e.value&&(this.value.rawValue=e.value),!0))}exportState(){var t,e,i;return D(()=>super.exportState(),Object.assign(Object.assign({value:this.value.rawValue},this.labelController.exportProps()),(i=(e=(t=this.valueController).exportProps)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:{}))}}function cn(n){const t=Object.assign({},n);return delete t.value,t}class ri extends ot{constructor(t,e){super(t,e),this.tag=e.tag}importState(t){return M(t,e=>super.importState(cn(t)),e=>({tag:e.optional.string}),e=>(this.tag=e.tag,!0))}exportState(){return D(()=>cn(super.exportState()),{binding:{key:this.value.binding.target.key,value:this.value.binding.target.read()},tag:this.tag})}}function as(n){return rt(n)&&Zn(n.value)}class ls extends ri{importState(t){return M(t,e=>super.importState(e),e=>({binding:e.required.object({value:e.required.raw})}),e=>(this.value.binding.inject(e.binding.value),this.value.fetch(),!0))}}function cs(n){return rt(n)&&Wr(n.value)}function si(n,t){for(;n.lengthn.length?e.splice(0,e.length-n.length):si(e,n.length),e}class hs{constructor(t){this.emitter=new k,this.onTick_=this.onTick_.bind(this),this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.binding=t.binding,this.value_=C(ps(t.bufferSize)),this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_),this.ticker=t.ticker,this.ticker.emitter.on("tick",this.onTick_),this.fetch()}get rawValue(){return this.value_.rawValue}set rawValue(t){this.value_.rawValue=t}setRawValue(t,e){this.value_.setRawValue(t,e)}fetch(){this.value_.rawValue=us(this.value_.rawValue,this.binding.read())}onTick_(){this.fetch()}onValueBeforeChange_(t){this.emitter.emit("beforechange",Object.assign(Object.assign({},t),{sender:this}))}onValueChange_(t){this.emitter.emit("change",Object.assign(Object.assign({},t),{sender:this}))}}function vs(n){if(!("binding"in n))return!1;const t=n.binding;return Ae(t)&&"read"in t&&!("write"in t)}class ms extends ri{exportState(){return D(()=>super.exportState(),{binding:{readonly:!0}})}}function bs(n){return rt(n)&&vs(n.value)}class fs extends lt{get label(){return this.controller.labelController.props.get("label")}set label(t){this.controller.labelController.props.set("label",t)}get title(){var t;return(t=this.controller.buttonController.props.get("title"))!==null&&t!==void 0?t:""}set title(t){this.controller.buttonController.props.set("title",t)}on(t,e){const i=e.bind(this);return this.controller.buttonController.emitter.on(t,s=>{i(new Ur(this,s.nativeEvent))}),this}off(t,e){return this.controller.buttonController.emitter.off(t,e),this}}function gs(n,t,e){e?n.classList.add(t):n.classList.remove(t)}function ft(n,t){return e=>{gs(n,t,e)}}function Be(n,t){U(n,e=>{t.textContent=e??""})}const pe=v("btn");class ws{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(pe()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("button");i.classList.add(pe("b")),e.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const r=t.createElement("div");r.classList.add(pe("t")),Be(e.props.value("title"),r),this.buttonElement.appendChild(r)}}class _s{constructor(t,e){this.emitter=new k,this.onClick_=this.onClick_.bind(this),this.props=e.props,this.viewProps=e.viewProps,this.view=new ws(t,{props:this.props,viewProps:this.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}importProps(t){return M(t,null,e=>({title:e.optional.string}),e=>(this.props.set("title",e.title),!0))}exportProps(){return D(null,{title:this.props.get("title")})}onClick_(t){this.emitter.emit("click",{nativeEvent:t,sender:this})}}class pn extends le{constructor(t,e){const i=new _s(t,{props:e.buttonProps,viewProps:e.viewProps}),r=new ii(t,{blade:e.blade,props:e.labelProps,valueController:i});super({blade:e.blade,view:r.view,viewProps:e.viewProps}),this.buttonController=i,this.labelController=r}importState(t){return M(t,e=>super.importState(e)&&this.buttonController.importProps(e)&&this.labelController.importProps(e),()=>({}),()=>!0)}exportState(){return D(()=>super.exportState(),Object.assign(Object.assign({},this.buttonController.exportProps()),this.labelController.exportProps()))}}class oi{constructor(t){const[e,i]=t.split("-"),r=e.split(".");this.major=parseInt(r[0],10),this.minor=parseInt(r[1],10),this.patch=parseInt(r[2],10),this.prerelease=i??null}toString(){const t=[this.major,this.minor,this.patch].join(".");return this.prerelease!==null?[t,this.prerelease].join("-"):t}}const gt=new oi("2.0.4");function A(n){return Object.assign({core:gt},n)}const Cs=A({id:"button",type:"blade",accept(n){const t=x(n,e=>({title:e.required.string,view:e.required.constant("button"),label:e.optional.string}));return t?{params:t}:null},controller(n){return new pn(n.document,{blade:n.blade,buttonProps:u.fromObject({title:n.params.title}),labelProps:u.fromObject({label:n.params.label}),viewProps:n.viewProps})},api(n){return n.controller instanceof pn?new fs(n.controller):null}});function xs(n,t){return n.addBlade(Object.assign(Object.assign({},t),{view:"button"}))}function ys(n,t){return n.addBlade(Object.assign(Object.assign({},t),{view:"folder"}))}function Ps(n,t){return n.addBlade(Object.assign(Object.assign({},t),{view:"tab"}))}function Es(n){return Le(n)?"refresh"in n&&typeof n.refresh=="function":!1}function ks(n,t){if(!Qt.isBindable(n))throw E.notBindable();return new Qt(n,t)}class Vs{constructor(t,e){this.onRackValueChange_=this.onRackValueChange_.bind(this),this.controller_=t,this.emitter_=new k,this.pool_=e,this.controller_.rack.emitter.on("valuechange",this.onRackValueChange_)}get children(){return this.controller_.rack.children.map(t=>this.pool_.createApi(t))}addBinding(t,e,i){const r=i??{},s=this.controller_.element.ownerDocument,o=this.pool_.createBinding(s,ks(t,e),r),a=this.pool_.createBindingApi(o);return this.add(a,r.index)}addFolder(t){return ys(this,t)}addButton(t){return xs(this,t)}addTab(t){return Ps(this,t)}add(t,e){const i=t.controller;return this.controller_.rack.add(i,e),t}remove(t){this.controller_.rack.remove(t.controller)}addBlade(t){const e=this.controller_.element.ownerDocument,i=this.pool_.createBlade(e,t),r=this.pool_.createApi(i);return this.add(r,t.index)}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}refresh(){this.children.forEach(t=>{Es(t)&&t.refresh()})}onRackValueChange_(t){const e=t.bladeController,i=this.pool_.createApi(e),r=Zn(e.value)?e.value.binding:null;this.emitter_.emit("change",new Bt(i,r?r.target.read():e.value.rawValue,t.options.last))}}class Ie extends lt{constructor(t,e){super(t),this.rackApi_=new Vs(t.rackController,e)}refresh(){this.rackApi_.refresh()}}class je extends le{constructor(t){super({blade:t.blade,view:t.view,viewProps:t.rackController.viewProps}),this.rackController=t.rackController}importState(t){return M(t,e=>super.importState(e),e=>({children:e.required.array(e.required.raw)}),e=>this.rackController.rack.children.every((i,r)=>i.importState(e.children[r])))}exportState(){return D(()=>super.exportState(),{children:this.rackController.rack.children.map(t=>t.exportState())})}}function Ee(n){return"rackController"in n}class Ss{constructor(t){this.emitter=new k,this.items_=[],this.cache_=new Set,this.onSubListAdd_=this.onSubListAdd_.bind(this),this.onSubListRemove_=this.onSubListRemove_.bind(this),this.extract_=t}get items(){return this.items_}allItems(){return Array.from(this.cache_)}find(t){for(const e of this.allItems())if(t(e))return e;return null}includes(t){return this.cache_.has(t)}add(t,e){if(this.includes(t))throw E.shouldNeverHappen();const i=e!==void 0?e:this.items_.length;this.items_.splice(i,0,t),this.cache_.add(t);const r=this.extract_(t);r&&(r.emitter.on("add",this.onSubListAdd_),r.emitter.on("remove",this.onSubListRemove_),r.allItems().forEach(s=>{this.cache_.add(s)})),this.emitter.emit("add",{index:i,item:t,root:this,target:this})}remove(t){const e=this.items_.indexOf(t);if(e<0)return;this.items_.splice(e,1),this.cache_.delete(t);const i=this.extract_(t);i&&(i.allItems().forEach(r=>{this.cache_.delete(r)}),i.emitter.off("add",this.onSubListAdd_),i.emitter.off("remove",this.onSubListRemove_)),this.emitter.emit("remove",{index:e,item:t,root:this,target:this})}onSubListAdd_(t){this.cache_.add(t.item),this.emitter.emit("add",{index:t.index,item:t.item,root:this,target:t.target})}onSubListRemove_(t){this.cache_.delete(t.item),this.emitter.emit("remove",{index:t.index,item:t.item,root:this,target:t.target})}}function Ts(n,t){for(let e=0;e!r.viewProps.get("hidden")),e=t[0],i=t[t.length-1];this.bcSet_.items.forEach(r=>{const s=[];r===e&&(s.push("first"),(!this.blade_||this.blade_.get("positions").includes("veryfirst"))&&s.push("veryfirst")),r===i&&(s.push("last"),(!this.blade_||this.blade_.get("positions").includes("verylast"))&&s.push("verylast")),r.blade.set("positions",s)})}onChildPositionsChange_(){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildViewPropsChange_(t){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildDispose_(){this.bcSet_.items.filter(e=>e.viewProps.get("disposed")).forEach(e=>{this.bcSet_.remove(e)})}onChildValueChange_(t){const e=Ts(this.find(rt),t.sender);if(!e)throw E.alreadyDisposed();this.emitter.emit("valuechange",{bladeController:e,options:t.options,sender:this})}onRackLayout_(t){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onRackValueChange_(t){this.emitter.emit("valuechange",{bladeController:t.bladeController,options:t.options,sender:this})}onBladePositionsChange_(){this.updatePositions_()}}class Ne{constructor(t){this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this),this.element=t.element,this.viewProps=t.viewProps;const e=new As({blade:t.root?void 0:t.blade,viewProps:t.viewProps});e.emitter.on("add",this.onRackAdd_),e.emitter.on("remove",this.onRackRemove_),this.rack=e,this.viewProps.handleDispose(()=>{for(let i=this.rack.children.length-1;i>=0;i--)this.rack.children[i].viewProps.set("disposed",!0)})}onRackAdd_(t){t.root&&Jn(this.element,t.bladeController.view.element,t.index)}onRackRemove_(t){t.root&&Fe(t.bladeController.view.element)}}function wt(){return new u({positions:C([],{equals:lr})})}class It extends u{constructor(t){super(t)}static create(t){const e={completed:!0,expanded:t,expandedHeight:null,shouldFixHeight:!1,temporaryExpanded:null},i=u.createCore(e);return new It(i)}get styleExpanded(){var t;return(t=this.get("temporaryExpanded"))!==null&&t!==void 0?t:this.get("expanded")}get styleHeight(){if(!this.styleExpanded)return"0";const t=this.get("expandedHeight");return this.get("shouldFixHeight")&&!g(t)?`${t}px`:"auto"}bindExpandedClass(t,e){const i=()=>{this.styleExpanded?t.classList.add(e):t.classList.remove(e)};H(this,"expanded",i),H(this,"temporaryExpanded",i)}cleanUpTransition(){this.set("shouldFixHeight",!1),this.set("expandedHeight",null),this.set("completed",!0)}}function Rs(n,t){let e=0;return Zr(t,()=>{n.set("expandedHeight",null),n.set("temporaryExpanded",!0),Zt(t),e=t.clientHeight,n.set("temporaryExpanded",null),Zt(t)}),e}function dn(n,t){t.style.height=n.styleHeight}function ze(n,t){n.value("expanded").emitter.on("beforechange",()=>{if(n.set("completed",!1),g(n.get("expandedHeight"))){const e=Rs(n,t);e>0&&n.set("expandedHeight",e)}n.set("shouldFixHeight",!0),Zt(t)}),n.emitter.on("change",()=>{dn(n,t)}),dn(n,t),t.addEventListener("transitionend",e=>{e.propertyName==="height"&&n.cleanUpTransition()})}class ai extends Ie{constructor(t,e){super(t,e),this.emitter_=new k,this.controller.foldable.value("expanded").emitter.on("change",i=>{this.emitter_.emit("fold",new Kr(this,i.sender.rawValue))}),this.rackApi_.on("change",i=>{this.emitter_.emit("change",i)})}get expanded(){return this.controller.foldable.get("expanded")}set expanded(t){this.controller.foldable.set("expanded",t)}get title(){return this.controller.props.get("title")}set title(t){this.controller.props.set("title",t)}get children(){return this.rackApi_.children}addBinding(t,e,i){return this.rackApi_.addBinding(t,e,i)}addFolder(t){return this.rackApi_.addFolder(t)}addButton(t){return this.rackApi_.addButton(t)}addTab(t){return this.rackApi_.addTab(t)}add(t,e){return this.rackApi_.add(t,e)}remove(t){this.rackApi_.remove(t)}addBlade(t){return this.rackApi_.addBlade(t)}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}}const li=v("cnt");class Os{constructor(t,e){var i;this.className_=v((i=e.viewName)!==null&&i!==void 0?i:"fld"),this.element=t.createElement("div"),this.element.classList.add(this.className_(),li()),e.viewProps.bindClassModifiers(this.element),this.foldable_=e.foldable,this.foldable_.bindExpandedClass(this.element,this.className_(void 0,"expanded")),H(this.foldable_,"completed",ft(this.element,this.className_(void 0,"cpl")));const r=t.createElement("button");r.classList.add(this.className_("b")),H(e.props,"title",c=>{g(c)?this.element.classList.add(this.className_(void 0,"not")):this.element.classList.remove(this.className_(void 0,"not"))}),e.viewProps.bindDisabled(r),this.element.appendChild(r),this.buttonElement=r;const s=t.createElement("div");s.classList.add(this.className_("i")),this.element.appendChild(s);const o=t.createElement("div");o.classList.add(this.className_("t")),Be(e.props.value("title"),o),this.buttonElement.appendChild(o),this.titleElement=o;const a=t.createElement("div");a.classList.add(this.className_("m")),this.buttonElement.appendChild(a);const l=t.createElement("div");l.classList.add(this.className_("c")),this.element.appendChild(l),this.containerElement=l}}class ke extends je{constructor(t,e){var i;const r=It.create((i=e.expanded)!==null&&i!==void 0?i:!0),s=new Os(t,{foldable:r,props:e.props,viewName:e.root?"rot":void 0,viewProps:e.viewProps});super(Object.assign(Object.assign({},e),{rackController:new Ne({blade:e.blade,element:s.containerElement,root:e.root,viewProps:e.viewProps}),view:s})),this.onTitleClick_=this.onTitleClick_.bind(this),this.props=e.props,this.foldable=r,ze(this.foldable,this.view.containerElement),this.rackController.rack.emitter.on("add",()=>{this.foldable.cleanUpTransition()}),this.rackController.rack.emitter.on("remove",()=>{this.foldable.cleanUpTransition()}),this.view.buttonElement.addEventListener("click",this.onTitleClick_)}get document(){return this.view.element.ownerDocument}importState(t){return M(t,e=>super.importState(e),e=>({expanded:e.required.boolean,title:e.optional.string}),e=>(this.foldable.set("expanded",e.expanded),this.props.set("title",e.title),!0))}exportState(){return D(()=>super.exportState(),{expanded:this.foldable.get("expanded"),title:this.props.get("title")})}onTitleClick_(){this.foldable.set("expanded",!this.foldable.get("expanded"))}}const Ms=A({id:"folder",type:"blade",accept(n){const t=x(n,e=>({title:e.required.string,view:e.required.constant("folder"),expanded:e.optional.boolean}));return t?{params:t}:null},controller(n){return new ke(n.document,{blade:n.blade,expanded:n.params.expanded,props:u.fromObject({title:n.params.title}),viewProps:n.viewProps})},api(n){return n.controller instanceof ke?new ai(n.controller,n.pool):null}}),Ds=v("");function un(n,t){return ft(n,Ds(void 0,t))}class Y extends u{constructor(t){var e;super(t),this.onDisabledChange_=this.onDisabledChange_.bind(this),this.onParentChange_=this.onParentChange_.bind(this),this.onParentGlobalDisabledChange_=this.onParentGlobalDisabledChange_.bind(this),[this.globalDisabled_,this.setGlobalDisabled_]=hr(C(this.getGlobalDisabled_())),this.value("disabled").emitter.on("change",this.onDisabledChange_),this.value("parent").emitter.on("change",this.onParentChange_),(e=this.get("parent"))===null||e===void 0||e.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_)}static create(t){var e,i,r;const s=t??{};return new Y(u.createCore({disabled:(e=s.disabled)!==null&&e!==void 0?e:!1,disposed:!1,hidden:(i=s.hidden)!==null&&i!==void 0?i:!1,parent:(r=s.parent)!==null&&r!==void 0?r:null}))}get globalDisabled(){return this.globalDisabled_}bindClassModifiers(t){U(this.globalDisabled_,un(t,"disabled")),H(this,"hidden",un(t,"hidden"))}bindDisabled(t){U(this.globalDisabled_,e=>{t.disabled=e})}bindTabIndex(t){U(this.globalDisabled_,e=>{t.tabIndex=e?-1:0})}handleDispose(t){this.value("disposed").emitter.on("change",e=>{e&&t()})}importState(t){this.set("disabled",t.disabled),this.set("hidden",t.hidden)}exportState(){return{disabled:this.get("disabled"),hidden:this.get("hidden")}}getGlobalDisabled_(){const t=this.get("parent");return(t?t.globalDisabled.rawValue:!1)||this.get("disabled")}updateGlobalDisabled_(){this.setGlobalDisabled_(this.getGlobalDisabled_())}onDisabledChange_(){this.updateGlobalDisabled_()}onParentGlobalDisabledChange_(){this.updateGlobalDisabled_()}onParentChange_(t){var e;const i=t.previousRawValue;i==null||i.globalDisabled.emitter.off("change",this.onParentGlobalDisabledChange_),(e=this.get("parent"))===null||e===void 0||e.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_),this.updateGlobalDisabled_()}}const hn=v("tbp");class Fs{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(hn()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(hn("c")),this.element.appendChild(i),this.containerElement=i}}const xt=v("tbi");class Bs{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(xt()),e.viewProps.bindClassModifiers(this.element),H(e.props,"selected",s=>{s?this.element.classList.add(xt(void 0,"sel")):this.element.classList.remove(xt(void 0,"sel"))});const i=t.createElement("button");i.classList.add(xt("b")),e.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const r=t.createElement("div");r.classList.add(xt("t")),Be(e.props.value("title"),r),this.buttonElement.appendChild(r),this.titleElement=r}}class Is{constructor(t,e){this.emitter=new k,this.onClick_=this.onClick_.bind(this),this.props=e.props,this.viewProps=e.viewProps,this.view=new Bs(t,{props:e.props,viewProps:e.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}onClick_(){this.emitter.emit("click",{sender:this})}}class Ve extends je{constructor(t,e){const i=new Fs(t,{viewProps:e.viewProps});super(Object.assign(Object.assign({},e),{rackController:new Ne({blade:e.blade,element:i.containerElement,viewProps:e.viewProps}),view:i})),this.onItemClick_=this.onItemClick_.bind(this),this.ic_=new Is(t,{props:e.itemProps,viewProps:Y.create()}),this.ic_.emitter.on("click",this.onItemClick_),this.props=e.props,H(this.props,"selected",r=>{this.itemController.props.set("selected",r),this.viewProps.set("hidden",!r)})}get itemController(){return this.ic_}importState(t){return M(t,e=>super.importState(e),e=>({selected:e.required.boolean,title:e.required.string}),e=>(this.ic_.props.set("selected",e.selected),this.ic_.props.set("title",e.title),!0))}exportState(){return D(()=>super.exportState(),{selected:this.ic_.props.get("selected"),title:this.ic_.props.get("title")})}onItemClick_(){this.props.set("selected",!0)}}class js extends Ie{constructor(t,e){super(t,e),this.emitter_=new k,this.onSelect_=this.onSelect_.bind(this),this.pool_=e,this.rackApi_.on("change",i=>{this.emitter_.emit("change",i)}),this.controller.tab.selectedIndex.emitter.on("change",this.onSelect_)}get pages(){return this.rackApi_.children}addPage(t){const e=this.controller.view.element.ownerDocument,i=new Ve(e,{blade:wt(),itemProps:u.fromObject({selected:!1,title:t.title}),props:u.fromObject({selected:!1}),viewProps:Y.create()}),r=this.pool_.createApi(i);return this.rackApi_.add(r,t.index)}removePage(t){this.rackApi_.remove(this.rackApi_.children[t])}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}onSelect_(t){this.emitter_.emit("select",new qr(this,t.rawValue))}}class Ns extends Ie{get title(){var t;return(t=this.controller.itemController.props.get("title"))!==null&&t!==void 0?t:""}set title(t){this.controller.itemController.props.set("title",t)}get selected(){return this.controller.props.get("selected")}set selected(t){this.controller.props.set("selected",t)}get children(){return this.rackApi_.children}addButton(t){return this.rackApi_.addButton(t)}addFolder(t){return this.rackApi_.addFolder(t)}addTab(t){return this.rackApi_.addTab(t)}add(t,e){this.rackApi_.add(t,e)}remove(t){this.rackApi_.remove(t)}addBinding(t,e,i){return this.rackApi_.addBinding(t,e,i)}addBlade(t){return this.rackApi_.addBlade(t)}}const vn=-1;class zs{constructor(){this.onItemSelectedChange_=this.onItemSelectedChange_.bind(this),this.empty=C(!0),this.selectedIndex=C(vn),this.items_=[]}add(t,e){const i=e??this.items_.length;this.items_.splice(i,0,t),t.emitter.on("change",this.onItemSelectedChange_),this.keepSelection_()}remove(t){const e=this.items_.indexOf(t);e<0||(this.items_.splice(e,1),t.emitter.off("change",this.onItemSelectedChange_),this.keepSelection_())}keepSelection_(){if(this.items_.length===0){this.selectedIndex.rawValue=vn,this.empty.rawValue=!0;return}const t=this.items_.findIndex(e=>e.rawValue);t<0?(this.items_.forEach((e,i)=>{e.rawValue=i===0}),this.selectedIndex.rawValue=0):(this.items_.forEach((e,i)=>{e.rawValue=i===t}),this.selectedIndex.rawValue=t),this.empty.rawValue=!1}onItemSelectedChange_(t){if(t.rawValue){const e=this.items_.findIndex(i=>i===t.sender);this.items_.forEach((i,r)=>{i.rawValue=r===e}),this.selectedIndex.rawValue=e}else this.keepSelection_()}}const yt=v("tab");class Hs{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(yt(),li()),e.viewProps.bindClassModifiers(this.element),U(e.empty,ft(this.element,yt(void 0,"nop")));const i=t.createElement("div");i.classList.add(yt("t")),this.element.appendChild(i),this.itemsElement=i;const r=t.createElement("div");r.classList.add(yt("i")),this.element.appendChild(r);const s=t.createElement("div");s.classList.add(yt("c")),this.element.appendChild(s),this.contentsElement=s}}class mn extends je{constructor(t,e){const i=new zs,r=new Hs(t,{empty:i.empty,viewProps:e.viewProps});super({blade:e.blade,rackController:new Ne({blade:e.blade,element:r.contentsElement,viewProps:e.viewProps}),view:r}),this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this);const s=this.rackController.rack;s.emitter.on("add",this.onRackAdd_),s.emitter.on("remove",this.onRackRemove_),this.tab=i}add(t,e){this.rackController.rack.add(t,e)}remove(t){this.rackController.rack.remove(this.rackController.rack.children[t])}onRackAdd_(t){if(!t.root)return;const e=t.bladeController;Jn(this.view.itemsElement,e.itemController.view.element,t.index),e.itemController.viewProps.set("parent",this.viewProps),this.tab.add(e.props.value("selected"))}onRackRemove_(t){if(!t.root)return;const e=t.bladeController;Fe(e.itemController.view.element),e.itemController.viewProps.set("parent",null),this.tab.remove(e.props.value("selected"))}}const ci=A({id:"tab",type:"blade",accept(n){const t=x(n,e=>({pages:e.required.array(e.required.object({title:e.required.string})),view:e.required.constant("tab")}));return!t||t.pages.length===0?null:{params:t}},controller(n){const t=new mn(n.document,{blade:n.blade,viewProps:n.viewProps});return n.params.pages.forEach(e=>{const i=new Ve(n.document,{blade:wt(),itemProps:u.fromObject({selected:!1,title:e.title}),props:u.fromObject({selected:!1}),viewProps:Y.create()});t.add(i)}),t},api(n){return n.controller instanceof mn?new js(n.controller,n.pool):n.controller instanceof Ve?new Ns(n.controller,n.pool):null}});function $s(n,t){const e=n.accept(t.params);if(!e)return null;const i=x(t.params,r=>({disabled:r.optional.boolean,hidden:r.optional.boolean}));return n.controller({blade:wt(),document:t.document,params:Object.assign(Object.assign({},e.params),{disabled:i==null?void 0:i.disabled,hidden:i==null?void 0:i.hidden}),viewProps:Y.create({disabled:i==null?void 0:i.disabled,hidden:i==null?void 0:i.hidden})})}class He extends At{get options(){return this.controller.valueController.props.get("options")}set options(t){this.controller.valueController.props.set("options",t)}}class Ks{constructor(){this.disabled=!1,this.emitter=new k}dispose(){}tick(){this.disabled||this.emitter.emit("tick",{sender:this})}}class qs{constructor(t,e){this.disabled_=!1,this.timerId_=null,this.onTick_=this.onTick_.bind(this),this.doc_=t,this.emitter=new k,this.interval_=e,this.setTimer_()}get disabled(){return this.disabled_}set disabled(t){this.disabled_=t,this.disabled_?this.clearTimer_():this.setTimer_()}dispose(){this.clearTimer_()}clearTimer_(){if(this.timerId_===null)return;const t=this.doc_.defaultView;t&&t.clearInterval(this.timerId_),this.timerId_=null}setTimer_(){if(this.clearTimer_(),this.interval_<=0)return;const t=this.doc_.defaultView;t&&(this.timerId_=t.setInterval(this.onTick_,this.interval_))}onTick_(){this.disabled_||this.emitter.emit("tick",{sender:this})}}class jt{constructor(t){this.constraints=t}constrain(t){return this.constraints.reduce((e,i)=>i.constrain(e),t)}}function Jt(n,t){if(n instanceof t)return n;if(n instanceof jt){const e=n.constraints.reduce((i,r)=>i||(r instanceof t?r:null),null);if(e)return e}return null}class Nt{constructor(t){this.values=u.fromObject({options:t})}constrain(t){const e=this.values.get("options");return e.length===0||e.filter(r=>r.value===t).length>0?t:e[0].value}}function zt(n){var t;const e=Pe;if(Array.isArray(n))return(t=x({items:n},i=>({items:i.required.array(i.required.object({text:i.required.string,value:i.required.raw}))})))===null||t===void 0?void 0:t.items;if(typeof n=="object")return e.required.raw(n).value}function $e(n){if(Array.isArray(n))return n;const t=[];return Object.keys(n).forEach(e=>{t.push({text:e,value:n[e]})}),t}function Ke(n){return g(n)?null:new Nt($e(n))}const de=v("lst");class Us{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.props_=e.props,this.element=t.createElement("div"),this.element.classList.add(de()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("select");i.classList.add(de("s")),e.viewProps.bindDisabled(i),this.element.appendChild(i),this.selectElement=i;const r=t.createElement("div");r.classList.add(de("m")),r.appendChild(ae(t,"dropdown")),this.element.appendChild(r),e.value.emitter.on("change",this.onValueChange_),this.value_=e.value,H(this.props_,"options",s=>{ti(this.selectElement),s.forEach(o=>{const a=t.createElement("option");a.textContent=o.text,this.selectElement.appendChild(a)}),this.update_()})}update_(){const t=this.props_.get("options").map(e=>e.value);this.selectElement.selectedIndex=t.indexOf(this.value_.rawValue)}onValueChange_(){this.update_()}}class et{constructor(t,e){this.onSelectChange_=this.onSelectChange_.bind(this),this.props=e.props,this.value=e.value,this.viewProps=e.viewProps,this.view=new Us(t,{props:this.props,value:this.value,viewProps:this.viewProps}),this.view.selectElement.addEventListener("change",this.onSelectChange_)}onSelectChange_(t){const e=t.currentTarget;this.value.rawValue=this.props.get("options")[e.selectedIndex].value}importProps(t){return M(t,null,e=>({options:e.required.custom(zt)}),e=>(this.props.set("options",$e(e.options)),!0))}exportProps(){return D(null,{options:this.props.get("options")})}}const bn=v("pop");class Gs{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(bn()),e.viewProps.bindClassModifiers(this.element),U(e.shows,ft(this.element,bn(void 0,"v")))}}class pi{constructor(t,e){this.shows=C(!1),this.viewProps=e.viewProps,this.view=new Gs(t,{shows:this.shows,viewProps:this.viewProps})}}const fn=v("txt");class Ws{constructor(t,e){this.onChange_=this.onChange_.bind(this),this.element=t.createElement("div"),this.element.classList.add(fn()),e.viewProps.bindClassModifiers(this.element),this.props_=e.props,this.props_.emitter.on("change",this.onChange_);const i=t.createElement("input");i.classList.add(fn("i")),i.type="text",e.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,e.value.emitter.on("change",this.onChange_),this.value_=e.value,this.refresh()}refresh(){const t=this.props_.get("formatter");this.inputElement.value=t(this.value_.rawValue)}onChange_(){this.refresh()}}class Rt{constructor(t,e){this.onInputChange_=this.onInputChange_.bind(this),this.parser_=e.parser,this.props=e.props,this.value=e.value,this.viewProps=e.viewProps,this.view=new Ws(t,{props:e.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_)}onInputChange_(t){const i=t.currentTarget.value,r=this.parser_(i);g(r)||(this.value.rawValue=r),this.view.refresh()}}function Ys(n){return String(n)}function di(n){return n==="false"?!1:!!n}function gn(n){return Ys(n)}function Xs(n){return t=>n.reduce((e,i)=>e!==null?e:i(t),null)}const Qs=O(0);function te(n){return Qs(n)+"%"}function ui(n){return String(n)}function Se(n){return n}function _t({primary:n,secondary:t,forward:e,backward:i}){let r=!1;function s(o){r||(r=!0,o(),r=!1)}n.emitter.on("change",o=>{s(()=>{t.setRawValue(e(n.rawValue,t.rawValue),o.options)})}),t.emitter.on("change",o=>{s(()=>{n.setRawValue(i(n.rawValue,t.rawValue),o.options)}),s(()=>{t.setRawValue(e(n.rawValue,t.rawValue),o.options)})}),s(()=>{t.setRawValue(e(n.rawValue,t.rawValue),{forceEmit:!1,last:!0})})}function R(n,t){const e=n*(t.altKey?.1:1)*(t.shiftKey?10:1);return t.upKey?+e:t.downKey?-e:0}function Ot(n){return{altKey:n.altKey,downKey:n.key==="ArrowDown",shiftKey:n.shiftKey,upKey:n.key==="ArrowUp"}}function W(n){return{altKey:n.altKey,downKey:n.key==="ArrowLeft",shiftKey:n.shiftKey,upKey:n.key==="ArrowRight"}}function Zs(n){return n==="ArrowUp"||n==="ArrowDown"}function hi(n){return Zs(n)||n==="ArrowLeft"||n==="ArrowRight"}function ue(n,t){var e,i;const r=t.ownerDocument.defaultView,s=t.getBoundingClientRect();return{x:n.pageX-(((e=r&&r.scrollX)!==null&&e!==void 0?e:0)+s.left),y:n.pageY-(((i=r&&r.scrollY)!==null&&i!==void 0?i:0)+s.top)}}class ct{constructor(t){this.lastTouch_=null,this.onDocumentMouseMove_=this.onDocumentMouseMove_.bind(this),this.onDocumentMouseUp_=this.onDocumentMouseUp_.bind(this),this.onMouseDown_=this.onMouseDown_.bind(this),this.onTouchEnd_=this.onTouchEnd_.bind(this),this.onTouchMove_=this.onTouchMove_.bind(this),this.onTouchStart_=this.onTouchStart_.bind(this),this.elem_=t,this.emitter=new k,t.addEventListener("touchstart",this.onTouchStart_,{passive:!1}),t.addEventListener("touchmove",this.onTouchMove_,{passive:!0}),t.addEventListener("touchend",this.onTouchEnd_),t.addEventListener("mousedown",this.onMouseDown_)}computePosition_(t){const e=this.elem_.getBoundingClientRect();return{bounds:{width:e.width,height:e.height},point:t?{x:t.x,y:t.y}:null}}onMouseDown_(t){var e;t.preventDefault(),(e=t.currentTarget)===null||e===void 0||e.focus();const i=this.elem_.ownerDocument;i.addEventListener("mousemove",this.onDocumentMouseMove_),i.addEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("down",{altKey:t.altKey,data:this.computePosition_(ue(t,this.elem_)),sender:this,shiftKey:t.shiftKey})}onDocumentMouseMove_(t){this.emitter.emit("move",{altKey:t.altKey,data:this.computePosition_(ue(t,this.elem_)),sender:this,shiftKey:t.shiftKey})}onDocumentMouseUp_(t){const e=this.elem_.ownerDocument;e.removeEventListener("mousemove",this.onDocumentMouseMove_),e.removeEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("up",{altKey:t.altKey,data:this.computePosition_(ue(t,this.elem_)),sender:this,shiftKey:t.shiftKey})}onTouchStart_(t){t.preventDefault();const e=t.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("down",{altKey:t.altKey,data:this.computePosition_(e?{x:e.clientX-i.left,y:e.clientY-i.top}:void 0),sender:this,shiftKey:t.shiftKey}),this.lastTouch_=e}onTouchMove_(t){const e=t.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("move",{altKey:t.altKey,data:this.computePosition_(e?{x:e.clientX-i.left,y:e.clientY-i.top}:void 0),sender:this,shiftKey:t.shiftKey}),this.lastTouch_=e}onTouchEnd_(t){var e;const i=(e=t.targetTouches.item(0))!==null&&e!==void 0?e:this.lastTouch_,r=this.elem_.getBoundingClientRect();this.emitter.emit("up",{altKey:t.altKey,data:this.computePosition_(i?{x:i.clientX-r.left,y:i.clientY-r.top}:void 0),sender:this,shiftKey:t.shiftKey})}}const F=v("txt");class Js{constructor(t,e){this.onChange_=this.onChange_.bind(this),this.props_=e.props,this.props_.emitter.on("change",this.onChange_),this.element=t.createElement("div"),this.element.classList.add(F(),F(void 0,"num")),e.arrayPosition&&this.element.classList.add(F(void 0,e.arrayPosition)),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("input");i.classList.add(F("i")),i.type="text",e.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,this.onDraggingChange_=this.onDraggingChange_.bind(this),this.dragging_=e.dragging,this.dragging_.emitter.on("change",this.onDraggingChange_),this.element.classList.add(F()),this.inputElement.classList.add(F("i"));const r=t.createElement("div");r.classList.add(F("k")),this.element.appendChild(r),this.knobElement=r;const s=t.createElementNS(z,"svg");s.classList.add(F("g")),this.knobElement.appendChild(s);const o=t.createElementNS(z,"path");o.classList.add(F("gb")),s.appendChild(o),this.guideBodyElem_=o;const a=t.createElementNS(z,"path");a.classList.add(F("gh")),s.appendChild(a),this.guideHeadElem_=a;const l=t.createElement("div");l.classList.add(v("tt")()),this.knobElement.appendChild(l),this.tooltipElem_=l,e.value.emitter.on("change",this.onChange_),this.value=e.value,this.refresh()}onDraggingChange_(t){if(t.rawValue===null){this.element.classList.remove(F(void 0,"drg"));return}this.element.classList.add(F(void 0,"drg"));const e=t.rawValue/this.props_.get("pointerScale"),i=e+(e>0?-1:e<0?1:0),r=V(-i,-4,4);this.guideHeadElem_.setAttributeNS(null,"d",[`M ${i+r},0 L${i},4 L${i+r},8`,`M ${e},-1 L${e},9`].join(" ")),this.guideBodyElem_.setAttributeNS(null,"d",`M 0,4 L${e},4`);const s=this.props_.get("formatter");this.tooltipElem_.textContent=s(this.value.rawValue),this.tooltipElem_.style.left=`${e}px`}refresh(){const t=this.props_.get("formatter");this.inputElement.value=t(this.value.rawValue)}onChange_(){this.refresh()}}class Ht{constructor(t,e){var i;this.originRawValue_=0,this.onInputChange_=this.onInputChange_.bind(this),this.onInputKeyDown_=this.onInputKeyDown_.bind(this),this.onInputKeyUp_=this.onInputKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.parser_=e.parser,this.props=e.props,this.sliderProps_=(i=e.sliderProps)!==null&&i!==void 0?i:null,this.value=e.value,this.viewProps=e.viewProps,this.dragging_=C(null),this.view=new Js(t,{arrayPosition:e.arrayPosition,dragging:this.dragging_,props:this.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_),this.view.inputElement.addEventListener("keydown",this.onInputKeyDown_),this.view.inputElement.addEventListener("keyup",this.onInputKeyUp_);const r=new ct(this.view.knobElement);r.emitter.on("down",this.onPointerDown_),r.emitter.on("move",this.onPointerMove_),r.emitter.on("up",this.onPointerUp_)}constrainValue_(t){var e,i;const r=(e=this.sliderProps_)===null||e===void 0?void 0:e.get("min"),s=(i=this.sliderProps_)===null||i===void 0?void 0:i.get("max");let o=t;return r!==void 0&&(o=Math.max(o,r)),s!==void 0&&(o=Math.min(o,s)),o}onInputChange_(t){const i=t.currentTarget.value,r=this.parser_(i);g(r)||(this.value.rawValue=this.constrainValue_(r)),this.view.refresh()}onInputKeyDown_(t){const e=R(this.props.get("keyScale"),Ot(t));e!==0&&this.value.setRawValue(this.constrainValue_(this.value.rawValue+e),{forceEmit:!1,last:!1})}onInputKeyUp_(t){R(this.props.get("keyScale"),Ot(t))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}onPointerDown_(){this.originRawValue_=this.value.rawValue,this.dragging_.rawValue=0}computeDraggingValue_(t){if(!t.point)return null;const e=t.point.x-t.bounds.width/2;return this.constrainValue_(this.originRawValue_+e*this.props.get("pointerScale"))}onPointerMove_(t){const e=this.computeDraggingValue_(t.data);e!==null&&(this.value.setRawValue(e,{forceEmit:!1,last:!1}),this.dragging_.rawValue=this.value.rawValue-this.originRawValue_)}onPointerUp_(t){const e=this.computeDraggingValue_(t.data);e!==null&&(this.value.setRawValue(e,{forceEmit:!0,last:!0}),this.dragging_.rawValue=null)}}const he=v("sld");class to{constructor(t,e){this.onChange_=this.onChange_.bind(this),this.props_=e.props,this.props_.emitter.on("change",this.onChange_),this.element=t.createElement("div"),this.element.classList.add(he()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(he("t")),e.viewProps.bindTabIndex(i),this.element.appendChild(i),this.trackElement=i;const r=t.createElement("div");r.classList.add(he("k")),this.trackElement.appendChild(r),this.knobElement=r,e.value.emitter.on("change",this.onChange_),this.value=e.value,this.update_()}update_(){const t=V(b(this.value.rawValue,this.props_.get("min"),this.props_.get("max"),0,100),0,100);this.knobElement.style.width=`${t}%`}onChange_(){this.update_()}}class eo{constructor(t,e){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDownOrMove_=this.onPointerDownOrMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=e.value,this.viewProps=e.viewProps,this.props=e.props,this.view=new to(t,{props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new ct(this.view.trackElement),this.ptHandler_.emitter.on("down",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("move",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.trackElement.addEventListener("keydown",this.onKeyDown_),this.view.trackElement.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(t,e){t.point&&this.value.setRawValue(b(V(t.point.x,0,t.bounds.width),0,t.bounds.width,this.props.get("min"),this.props.get("max")),e)}onPointerDownOrMove_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerUp_(t){this.handlePointerEvent_(t.data,{forceEmit:!0,last:!0})}onKeyDown_(t){const e=R(this.props.get("keyScale"),W(t));e!==0&&this.value.setRawValue(this.value.rawValue+e,{forceEmit:!1,last:!1})}onKeyUp_(t){R(this.props.get("keyScale"),W(t))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const ve=v("sldtxt");class no{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(ve());const i=t.createElement("div");i.classList.add(ve("s")),this.sliderView_=e.sliderView,i.appendChild(this.sliderView_.element),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(ve("t")),this.textView_=e.textView,r.appendChild(this.textView_.element),this.element.appendChild(r)}}class ee{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.sliderC_=new eo(t,{props:e.sliderProps,value:e.value,viewProps:this.viewProps}),this.textC_=new Ht(t,{parser:e.parser,props:e.textProps,sliderProps:e.sliderProps,value:e.value,viewProps:e.viewProps}),this.view=new no(t,{sliderView:this.sliderC_.view,textView:this.textC_.view})}get sliderController(){return this.sliderC_}get textController(){return this.textC_}importProps(t){return M(t,null,e=>({max:e.required.number,min:e.required.number}),e=>{const i=this.sliderC_.props;return i.set("max",e.max),i.set("min",e.min),!0})}exportProps(){const t=this.sliderC_.props;return D(null,{max:t.get("max"),min:t.get("min")})}}function vi(n){return{sliderProps:new u({keyScale:n.keyScale,max:n.max,min:n.min}),textProps:new u({formatter:C(n.formatter),keyScale:n.keyScale,pointerScale:C(n.pointerScale)})}}const io={containerUnitSize:"cnt-usz"};function mi(n){return`--${io[n]}`}function Mt(n){return Qn(n)}function J(n){if(ye(n))return x(n,Mt)}function q(n,t){if(!n)return;const e=[],i=Wn(n,t);i&&e.push(i);const r=Yn(n);return r&&e.push(r),new jt(e)}function ro(n){return n?n.major===gt.major:!1}function bi(n){if(n==="inline"||n==="popup")return n}function $t(n,t){n.write(t)}const Ut=v("ckb");class so{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.element=t.createElement("div"),this.element.classList.add(Ut()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("label");i.classList.add(Ut("l")),this.element.appendChild(i),this.labelElement=i;const r=t.createElement("input");r.classList.add(Ut("i")),r.type="checkbox",this.labelElement.appendChild(r),this.inputElement=r,e.viewProps.bindDisabled(this.inputElement);const s=t.createElement("div");s.classList.add(Ut("w")),this.labelElement.appendChild(s);const o=ae(t,"check");s.appendChild(o),e.value.emitter.on("change",this.onValueChange_),this.value=e.value,this.update_()}update_(){this.inputElement.checked=this.value.rawValue}onValueChange_(){this.update_()}}class oo{constructor(t,e){this.onInputChange_=this.onInputChange_.bind(this),this.onLabelMouseDown_=this.onLabelMouseDown_.bind(this),this.value=e.value,this.viewProps=e.viewProps,this.view=new so(t,{value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_),this.view.labelElement.addEventListener("mousedown",this.onLabelMouseDown_)}onInputChange_(t){const e=t.currentTarget;this.value.rawValue=e.checked,t.preventDefault(),t.stopPropagation()}onLabelMouseDown_(t){t.preventDefault()}}function ao(n){const t=[],e=Ke(n.options);return e&&t.push(e),new jt(t)}const lo=A({id:"input-bool",type:"input",accept:(n,t)=>{if(typeof n!="boolean")return null;const e=x(t,i=>({options:i.optional.custom(zt),readonly:i.optional.constant(!1)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>di,constraint:n=>ao(n.params),writer:n=>$t},controller:n=>{const t=n.document,e=n.value,i=n.constraint,r=i&&Jt(i,Nt);return r?new et(t,{props:new u({options:r.values.value("options")}),value:e,viewProps:n.viewProps}):new oo(t,{value:e,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="boolean"?null:n.controller.valueController instanceof et?new He(n.controller):null}}),it=v("col");class co{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(it()),e.foldable.bindExpandedClass(this.element,it(void 0,"expanded")),H(e.foldable,"completed",ft(this.element,it(void 0,"cpl")));const i=t.createElement("div");i.classList.add(it("h")),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(it("s")),i.appendChild(r),this.swatchElement=r;const s=t.createElement("div");if(s.classList.add(it("t")),i.appendChild(s),this.textElement=s,e.pickerLayout==="inline"){const o=t.createElement("div");o.classList.add(it("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}}function po(n,t,e){const i=V(n/255,0,1),r=V(t/255,0,1),s=V(e/255,0,1),o=Math.max(i,r,s),a=Math.min(i,r,s),l=o-a;let c=0,p=0;const d=(a+o)/2;return l!==0&&(p=l/(1-Math.abs(o+a-1)),i===o?c=(r-s)/l:r===o?c=2+(s-i)/l:c=4+(i-r)/l,c=c/6+(c<0?1:0)),[c*360,p*100,d*100]}function uo(n,t,e){const i=(n%360+360)%360,r=V(t/100,0,1),s=V(e/100,0,1),o=(1-Math.abs(2*s-1))*r,a=o*(1-Math.abs(i/60%2-1)),l=s-o/2;let c,p,d;return i>=0&&i<60?[c,p,d]=[o,a,0]:i>=60&&i<120?[c,p,d]=[a,o,0]:i>=120&&i<180?[c,p,d]=[0,o,a]:i>=180&&i<240?[c,p,d]=[0,a,o]:i>=240&&i<300?[c,p,d]=[a,0,o]:[c,p,d]=[o,0,a],[(c+l)*255,(p+l)*255,(d+l)*255]}function ho(n,t,e){const i=V(n/255,0,1),r=V(t/255,0,1),s=V(e/255,0,1),o=Math.max(i,r,s),a=Math.min(i,r,s),l=o-a;let c;l===0?c=0:o===i?c=60*(((r-s)/l%6+6)%6):o===r?c=60*((s-i)/l+2):c=60*((i-r)/l+4);const p=o===0?0:l/o,d=o;return[c,p*100,d*100]}function fi(n,t,e){const i=qn(n,360),r=V(t/100,0,1),s=V(e/100,0,1),o=s*r,a=o*(1-Math.abs(i/60%2-1)),l=s-o;let c,p,d;return i>=0&&i<60?[c,p,d]=[o,a,0]:i>=60&&i<120?[c,p,d]=[a,o,0]:i>=120&&i<180?[c,p,d]=[0,o,a]:i>=180&&i<240?[c,p,d]=[0,a,o]:i>=240&&i<300?[c,p,d]=[a,0,o]:[c,p,d]=[o,0,a],[(c+l)*255,(p+l)*255,(d+l)*255]}function vo(n,t,e){const i=e+t*(100-Math.abs(2*e-100))/200;return[n,i!==0?t*(100-Math.abs(2*e-100))/i:0,e+t*(100-Math.abs(2*e-100))/(2*100)]}function mo(n,t,e){const i=100-Math.abs(e*(200-t)/100-100);return[n,i!==0?t*e/i:0,e*(200-t)/(2*100)]}function $(n){return[n[0],n[1],n[2]]}function ce(n,t){return[n[0],n[1],n[2],t]}const bo={hsl:{hsl:(n,t,e)=>[n,t,e],hsv:vo,rgb:uo},hsv:{hsl:mo,hsv:(n,t,e)=>[n,t,e],rgb:fi},rgb:{hsl:po,hsv:ho,rgb:(n,t,e)=>[n,t,e]}};function bt(n,t){return[t==="float"?1:n==="rgb"?255:360,t==="float"?1:n==="rgb"?255:100,t==="float"?1:n==="rgb"?255:100]}function fo(n,t){return n===t?t:qn(n,t)}function gi(n,t,e){var i;const r=bt(t,e);return[t==="rgb"?V(n[0],0,r[0]):fo(n[0],r[0]),V(n[1],0,r[1]),V(n[2],0,r[2]),V((i=n[3])!==null&&i!==void 0?i:1,0,1)]}function wn(n,t,e,i){const r=bt(t,e),s=bt(t,i);return n.map((o,a)=>o/r[a]*s[a])}function wi(n,t,e){const i=wn(n,t.mode,t.type,"int"),r=bo[t.mode][e.mode](...i);return wn(r,e.mode,"int",e.type)}class m{static black(){return new m([0,0,0],"rgb")}constructor(t,e){this.type="int",this.mode=e,this.comps_=gi(t,e,this.type)}getComponents(t){return ce(wi($(this.comps_),{mode:this.mode,type:this.type},{mode:t??this.mode,type:this.type}),this.comps_[3])}toRgbaObject(){const t=this.getComponents("rgb");return{r:t[0],g:t[1],b:t[2],a:t[3]}}}const X=v("colp");class go{constructor(t,e){this.alphaViews_=null,this.element=t.createElement("div"),this.element.classList.add(X()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(X("hsv"));const r=t.createElement("div");r.classList.add(X("sv")),this.svPaletteView_=e.svPaletteView,r.appendChild(this.svPaletteView_.element),i.appendChild(r);const s=t.createElement("div");s.classList.add(X("h")),this.hPaletteView_=e.hPaletteView,s.appendChild(this.hPaletteView_.element),i.appendChild(s),this.element.appendChild(i);const o=t.createElement("div");if(o.classList.add(X("rgb")),this.textsView_=e.textsView,o.appendChild(this.textsView_.element),this.element.appendChild(o),e.alphaViews){this.alphaViews_={palette:e.alphaViews.palette,text:e.alphaViews.text};const a=t.createElement("div");a.classList.add(X("a"));const l=t.createElement("div");l.classList.add(X("ap")),l.appendChild(this.alphaViews_.palette.element),a.appendChild(l);const c=t.createElement("div");c.classList.add(X("at")),c.appendChild(this.alphaViews_.text.element),a.appendChild(c),this.element.appendChild(a)}}get allFocusableElements(){const t=[this.svPaletteView_.element,this.hPaletteView_.element,this.textsView_.modeSelectElement,...this.textsView_.inputViews.map(e=>e.inputElement)];return this.alphaViews_&&t.push(this.alphaViews_.palette.element,this.alphaViews_.text.inputElement),t}}function wo(n){return n==="int"?"int":n==="float"?"float":void 0}function qe(n){return x(n,t=>({color:t.optional.object({alpha:t.optional.boolean,type:t.optional.custom(wo)}),expanded:t.optional.boolean,picker:t.optional.custom(bi),readonly:t.optional.constant(!1)}))}function at(n){return n?.1:1}function _i(n){var t;return(t=n.color)===null||t===void 0?void 0:t.type}class Ue{constructor(t,e){this.type="float",this.mode=e,this.comps_=gi(t,e,this.type)}getComponents(t){return ce(wi($(this.comps_),{mode:this.mode,type:this.type},{mode:t??this.mode,type:this.type}),this.comps_[3])}toRgbaObject(){const t=this.getComponents("rgb");return{r:t[0],g:t[1],b:t[2],a:t[3]}}}const _o={int:(n,t)=>new m(n,t),float:(n,t)=>new Ue(n,t)};function Ge(n,t,e){return _o[e](n,t)}function Co(n){return n.type==="float"}function xo(n){return n.type==="int"}function yo(n){const t=n.getComponents(),e=bt(n.mode,"int");return new m([Math.round(b(t[0],0,1,0,e[0])),Math.round(b(t[1],0,1,0,e[1])),Math.round(b(t[2],0,1,0,e[2])),t[3]],n.mode)}function Po(n){const t=n.getComponents(),e=bt(n.mode,"int");return new Ue([b(t[0],0,e[0],0,1),b(t[1],0,e[1],0,1),b(t[2],0,e[2],0,1),t[3]],n.mode)}function L(n,t){if(n.type===t)return n;if(xo(n)&&t==="float")return Po(n);if(Co(n)&&t==="int")return yo(n);throw E.shouldNeverHappen()}function Eo(n,t){return n.alpha===t.alpha&&n.mode===t.mode&&n.notation===t.notation&&n.type===t.type}function B(n,t){const e=n.match(/^(.+)%$/);return Math.min(e?parseFloat(e[1])*.01*t:parseFloat(n),t)}const ko={deg:n=>n,grad:n=>n*360/400,rad:n=>n*360/(2*Math.PI),turn:n=>n*360};function Ci(n){const t=n.match(/^([0-9.]+?)(deg|grad|rad|turn)$/);if(!t)return parseFloat(n);const e=parseFloat(t[1]),i=t[2];return ko[i](e)}function xi(n){const t=n.match(/^rgb\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!t)return null;const e=[B(t[1],255),B(t[2],255),B(t[3],255)];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])?null:e}function Vo(n){const t=xi(n);return t?new m(t,"rgb"):null}function yi(n){const t=n.match(/^rgba\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!t)return null;const e=[B(t[1],255),B(t[2],255),B(t[3],255),B(t[4],1)];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])||isNaN(e[3])?null:e}function So(n){const t=yi(n);return t?new m(t,"rgb"):null}function Pi(n){const t=n.match(/^hsl\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!t)return null;const e=[Ci(t[1]),B(t[2],100),B(t[3],100)];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])?null:e}function To(n){const t=Pi(n);return t?new m(t,"hsl"):null}function Ei(n){const t=n.match(/^hsla\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!t)return null;const e=[Ci(t[1]),B(t[2],100),B(t[3],100),B(t[4],1)];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])||isNaN(e[3])?null:e}function Lo(n){const t=Ei(n);return t?new m(t,"hsl"):null}function ki(n){const t=n.match(/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(t)return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)];const e=n.match(/^(?:#|0x)([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return e?[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]:null}function Ao(n){const t=ki(n);return t?new m(t,"rgb"):null}function Vi(n){const t=n.match(/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(t)return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16),b(parseInt(t[4]+t[4],16),0,255,0,1)];const e=n.match(/^(?:#|0x)?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return e?[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16),b(parseInt(e[4],16),0,255,0,1)]:null}function Ro(n){const t=Vi(n);return t?new m(t,"rgb"):null}function Si(n){const t=n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!t)return null;const e=[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])?null:e}function _n(n){return t=>{const e=Si(t);return e?Ge(e,"rgb",n):null}}function Ti(n){const t=n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*a\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!t)return null;const e=[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])||isNaN(e[3])?null:e}function Cn(n){return t=>{const e=Ti(t);return e?Ge(e,"rgb",n):null}}const Oo=[{parser:ki,result:{alpha:!1,mode:"rgb",notation:"hex"}},{parser:Vi,result:{alpha:!0,mode:"rgb",notation:"hex"}},{parser:xi,result:{alpha:!1,mode:"rgb",notation:"func"}},{parser:yi,result:{alpha:!0,mode:"rgb",notation:"func"}},{parser:Pi,result:{alpha:!1,mode:"hsl",notation:"func"}},{parser:Ei,result:{alpha:!0,mode:"hsl",notation:"func"}},{parser:Si,result:{alpha:!1,mode:"rgb",notation:"object"}},{parser:Ti,result:{alpha:!0,mode:"rgb",notation:"object"}}];function Mo(n){return Oo.reduce((t,{parser:e,result:i})=>t||(e(n)?i:null),null)}function Do(n,t="int"){const e=Mo(n);return e?e.notation==="hex"&&t!=="float"?Object.assign(Object.assign({},e),{type:"int"}):e.notation==="func"?Object.assign(Object.assign({},e),{type:t}):null:null}function Kt(n){const t=[Ao,Ro,Vo,So,To,Lo];n==="int"&&t.push(_n("int"),Cn("int")),n==="float"&&t.push(_n("float"),Cn("float"));const e=Xs(t);return i=>{const r=e(i);return r?L(r,n):null}}function Fo(n){const t=Kt("int");if(typeof n!="string")return m.black();const e=t(n);return e??m.black()}function Li(n){const t=V(Math.floor(n),0,255).toString(16);return t.length===1?`0${t}`:t}function We(n,t="#"){const e=$(n.getComponents("rgb")).map(Li).join("");return`${t}${e}`}function Ye(n,t="#"){const e=n.getComponents("rgb"),i=[e[0],e[1],e[2],e[3]*255].map(Li).join("");return`${t}${i}`}function Ai(n){const t=O(0),e=L(n,"int");return`rgb(${$(e.getComponents("rgb")).map(r=>t(r)).join(", ")})`}function Wt(n){const t=O(2),e=O(0);return`rgba(${L(n,"int").getComponents("rgb").map((s,o)=>(o===3?t:e)(s)).join(", ")})`}function Bo(n){const t=[O(0),te,te],e=L(n,"int");return`hsl(${$(e.getComponents("hsl")).map((r,s)=>t[s](r)).join(", ")})`}function Io(n){const t=[O(0),te,te,O(2)];return`hsla(${L(n,"int").getComponents("hsl").map((r,s)=>t[s](r)).join(", ")})`}function Ri(n,t){const e=O(t==="float"?2:0),i=["r","g","b"],r=L(n,t);return`{${$(r.getComponents("rgb")).map((o,a)=>`${i[a]}: ${e(o)}`).join(", ")}}`}function jo(n){return t=>Ri(t,n)}function Oi(n,t){const e=O(2),i=O(t==="float"?2:0),r=["r","g","b","a"];return`{${L(n,t).getComponents("rgb").map((a,l)=>{const c=l===3?e:i;return`${r[l]}: ${c(a)}`}).join(", ")}}`}function No(n){return t=>Oi(t,n)}const zo=[{format:{alpha:!1,mode:"rgb",notation:"hex",type:"int"},stringifier:We},{format:{alpha:!0,mode:"rgb",notation:"hex",type:"int"},stringifier:Ye},{format:{alpha:!1,mode:"rgb",notation:"func",type:"int"},stringifier:Ai},{format:{alpha:!0,mode:"rgb",notation:"func",type:"int"},stringifier:Wt},{format:{alpha:!1,mode:"hsl",notation:"func",type:"int"},stringifier:Bo},{format:{alpha:!0,mode:"hsl",notation:"func",type:"int"},stringifier:Io},...["int","float"].reduce((n,t)=>[...n,{format:{alpha:!1,mode:"rgb",notation:"object",type:t},stringifier:jo(t)},{format:{alpha:!0,mode:"rgb",notation:"object",type:t},stringifier:No(t)}],[])];function Mi(n){return zo.reduce((t,e)=>t||(Eo(e.format,n)?e.stringifier:null),null)}const Pt=v("apl");class Ho{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.value=e.value,this.value.emitter.on("change",this.onValueChange_),this.element=t.createElement("div"),this.element.classList.add(Pt()),e.viewProps.bindClassModifiers(this.element),e.viewProps.bindTabIndex(this.element);const i=t.createElement("div");i.classList.add(Pt("b")),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(Pt("c")),i.appendChild(r),this.colorElem_=r;const s=t.createElement("div");s.classList.add(Pt("m")),this.element.appendChild(s),this.markerElem_=s;const o=t.createElement("div");o.classList.add(Pt("p")),this.markerElem_.appendChild(o),this.previewElem_=o,this.update_()}update_(){const t=this.value.rawValue,e=t.getComponents("rgb"),i=new m([e[0],e[1],e[2],0],"rgb"),r=new m([e[0],e[1],e[2],255],"rgb"),s=["to right",Wt(i),Wt(r)];this.colorElem_.style.background=`linear-gradient(${s.join(",")})`,this.previewElem_.style.backgroundColor=Wt(t);const o=b(e[3],0,1,0,100);this.markerElem_.style.left=`${o}%`}onValueChange_(){this.update_()}}class $o{constructor(t,e){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=e.value,this.viewProps=e.viewProps,this.view=new Ho(t,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new ct(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(t,e){if(!t.point)return;const i=t.point.x/t.bounds.width,r=this.value.rawValue,[s,o,a]=r.getComponents("hsv");this.value.setRawValue(new m([s,o,a,i],"hsv"),e)}onPointerDown_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerMove_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerUp_(t){this.handlePointerEvent_(t.data,{forceEmit:!0,last:!0})}onKeyDown_(t){const e=R(at(!0),W(t));if(e===0)return;const i=this.value.rawValue,[r,s,o,a]=i.getComponents("hsv");this.value.setRawValue(new m([r,s,o,a+e],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(t){R(at(!0),W(t))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const dt=v("coltxt");function Ko(n){const t=n.createElement("select"),e=[{text:"RGB",value:"rgb"},{text:"HSL",value:"hsl"},{text:"HSV",value:"hsv"},{text:"HEX",value:"hex"}];return t.appendChild(e.reduce((i,r)=>{const s=n.createElement("option");return s.textContent=r.text,s.value=r.value,i.appendChild(s),i},n.createDocumentFragment())),t}class qo{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(dt()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(dt("m")),this.modeElem_=Ko(t),this.modeElem_.classList.add(dt("ms")),i.appendChild(this.modeSelectElement),e.viewProps.bindDisabled(this.modeElem_);const r=t.createElement("div");r.classList.add(dt("mm")),r.appendChild(ae(t,"dropdown")),i.appendChild(r),this.element.appendChild(i);const s=t.createElement("div");s.classList.add(dt("w")),this.element.appendChild(s),this.inputsElem_=s,this.inputViews_=e.inputViews,this.applyInputViews_(),U(e.mode,o=>{this.modeElem_.value=o})}get modeSelectElement(){return this.modeElem_}get inputViews(){return this.inputViews_}set inputViews(t){this.inputViews_=t,this.applyInputViews_()}applyInputViews_(){ti(this.inputsElem_);const t=this.element.ownerDocument;this.inputViews_.forEach(e=>{const i=t.createElement("div");i.classList.add(dt("c")),i.appendChild(e.element),this.inputsElem_.appendChild(i)})}}function Uo(n){return O(n==="float"?2:0)}function Go(n,t,e){const i=bt(n,t)[e];return new Ft({min:0,max:i})}function Wo(n,t,e){return new Ht(n,{arrayPosition:e===0?"fst":e===2?"lst":"mid",parser:t.parser,props:u.fromObject({formatter:Uo(t.colorType),keyScale:at(!1),pointerScale:t.colorType==="float"?.01:1}),value:C(0,{constraint:Go(t.colorMode,t.colorType,e)}),viewProps:t.viewProps})}function Yo(n,t){const e={colorMode:t.colorMode,colorType:t.colorType,parser:G,viewProps:t.viewProps};return[0,1,2].map(i=>{const r=Wo(n,e,i);return _t({primary:t.value,secondary:r.value,forward(s){return L(s,t.colorType).getComponents(t.colorMode)[i]},backward(s,o){const a=t.colorMode,c=L(s,t.colorType).getComponents(a);c[i]=o;const p=Ge(ce($(c),c[3]),a,t.colorType);return L(p,"int")}}),r})}function Xo(n,t){const e=new Rt(n,{parser:Kt("int"),props:u.fromObject({formatter:We}),value:C(m.black()),viewProps:t.viewProps});return _t({primary:t.value,secondary:e.value,forward:i=>new m($(i.getComponents()),i.mode),backward:(i,r)=>new m(ce($(r.getComponents(i.mode)),i.getComponents()[3]),i.mode)}),[e]}function Qo(n){return n!=="hex"}class Zo{constructor(t,e){this.onModeSelectChange_=this.onModeSelectChange_.bind(this),this.colorType_=e.colorType,this.value=e.value,this.viewProps=e.viewProps,this.colorMode=C(this.value.rawValue.mode),this.ccs_=this.createComponentControllers_(t),this.view=new qo(t,{mode:this.colorMode,inputViews:[this.ccs_[0].view,this.ccs_[1].view,this.ccs_[2].view],viewProps:this.viewProps}),this.view.modeSelectElement.addEventListener("change",this.onModeSelectChange_)}createComponentControllers_(t){const e=this.colorMode.rawValue;return Qo(e)?Yo(t,{colorMode:e,colorType:this.colorType_,value:this.value,viewProps:this.viewProps}):Xo(t,{value:this.value,viewProps:this.viewProps})}onModeSelectChange_(t){const e=t.currentTarget;this.colorMode.rawValue=e.value,this.ccs_=this.createComponentControllers_(this.view.element.ownerDocument),this.view.inputViews=this.ccs_.map(i=>i.view)}}const me=v("hpl");class Jo{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.value=e.value,this.value.emitter.on("change",this.onValueChange_),this.element=t.createElement("div"),this.element.classList.add(me()),e.viewProps.bindClassModifiers(this.element),e.viewProps.bindTabIndex(this.element);const i=t.createElement("div");i.classList.add(me("c")),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(me("m")),this.element.appendChild(r),this.markerElem_=r,this.update_()}update_(){const t=this.value.rawValue,[e]=t.getComponents("hsv");this.markerElem_.style.backgroundColor=Ai(new m([e,100,100],"hsv"));const i=b(e,0,360,0,100);this.markerElem_.style.left=`${i}%`}onValueChange_(){this.update_()}}class ta{constructor(t,e){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=e.value,this.viewProps=e.viewProps,this.view=new Jo(t,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new ct(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(t,e){if(!t.point)return;const i=b(V(t.point.x,0,t.bounds.width),0,t.bounds.width,0,360),r=this.value.rawValue,[,s,o,a]=r.getComponents("hsv");this.value.setRawValue(new m([i,s,o,a],"hsv"),e)}onPointerDown_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerMove_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerUp_(t){this.handlePointerEvent_(t.data,{forceEmit:!0,last:!0})}onKeyDown_(t){const e=R(at(!1),W(t));if(e===0)return;const i=this.value.rawValue,[r,s,o,a]=i.getComponents("hsv");this.value.setRawValue(new m([r+e,s,o,a],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(t){R(at(!1),W(t))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const be=v("svp"),xn=64;class ea{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.value=e.value,this.value.emitter.on("change",this.onValueChange_),this.element=t.createElement("div"),this.element.classList.add(be()),e.viewProps.bindClassModifiers(this.element),e.viewProps.bindTabIndex(this.element);const i=t.createElement("canvas");i.height=xn,i.width=xn,i.classList.add(be("c")),this.element.appendChild(i),this.canvasElement=i;const r=t.createElement("div");r.classList.add(be("m")),this.element.appendChild(r),this.markerElem_=r,this.update_()}update_(){const t=es(this.canvasElement);if(!t)return;const i=this.value.rawValue.getComponents("hsv"),r=this.canvasElement.width,s=this.canvasElement.height,o=t.getImageData(0,0,r,s),a=o.data;for(let p=0;pi.getComponents()[3],backward:(i,r)=>{const s=i.getComponents();return s[3]=r,new m(s,i.mode)}}),this.textsC_=new Zo(t,{colorType:e.colorType,value:this.value,viewProps:this.viewProps}),this.view=new go(t,{alphaViews:this.alphaIcs_?{palette:this.alphaIcs_.palette.view,text:this.alphaIcs_.text.view}:null,hPaletteView:this.hPaletteC_.view,supportsAlpha:e.supportsAlpha,svPaletteView:this.svPaletteC_.view,textsView:this.textsC_.view,viewProps:this.viewProps})}get textsController(){return this.textsC_}}const fe=v("colsw");class ra{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),e.value.emitter.on("change",this.onValueChange_),this.value=e.value,this.element=t.createElement("div"),this.element.classList.add(fe()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(fe("sw")),this.element.appendChild(i),this.swatchElem_=i;const r=t.createElement("button");r.classList.add(fe("b")),e.viewProps.bindDisabled(r),this.element.appendChild(r),this.buttonElement=r,this.update_()}update_(){const t=this.value.rawValue;this.swatchElem_.style.backgroundColor=Ye(t)}onValueChange_(){this.update_()}}class sa{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.view=new ra(t,{value:this.value,viewProps:this.viewProps})}}class Xe{constructor(t,e){this.onButtonBlur_=this.onButtonBlur_.bind(this),this.onButtonClick_=this.onButtonClick_.bind(this),this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.value=e.value,this.viewProps=e.viewProps,this.foldable_=It.create(e.expanded),this.swatchC_=new sa(t,{value:this.value,viewProps:this.viewProps});const i=this.swatchC_.view.buttonElement;i.addEventListener("blur",this.onButtonBlur_),i.addEventListener("click",this.onButtonClick_),this.textC_=new Rt(t,{parser:e.parser,props:u.fromObject({formatter:e.formatter}),value:this.value,viewProps:this.viewProps}),this.view=new co(t,{foldable:this.foldable_,pickerLayout:e.pickerLayout}),this.view.swatchElement.appendChild(this.swatchC_.view.element),this.view.textElement.appendChild(this.textC_.view.element),this.popC_=e.pickerLayout==="popup"?new pi(t,{viewProps:this.viewProps}):null;const r=new ia(t,{colorType:e.colorType,supportsAlpha:e.supportsAlpha,value:this.value,viewProps:this.viewProps});r.view.allFocusableElements.forEach(s=>{s.addEventListener("blur",this.onPopupChildBlur_),s.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=r,this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(r.view.element),_t({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:s=>s,backward:(s,o)=>o})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),ze(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onButtonBlur_(t){if(!this.popC_)return;const e=this.view.element,i=t.relatedTarget;(!i||!e.contains(i))&&(this.popC_.shows.rawValue=!1)}onButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.view.allFocusableElements[0].focus()}onPopupChildBlur_(t){if(!this.popC_)return;const e=this.popC_.view.element,i=ei(t);i&&e.contains(i)||i&&i===this.swatchC_.view.buttonElement&&!De(e.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(t){this.popC_?t.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&t.key==="Escape"&&this.swatchC_.view.buttonElement.focus()}}function oa(n){return $(n.getComponents("rgb")).reduce((t,e)=>t<<8|Math.floor(e)&255,0)}function aa(n){return n.getComponents("rgb").reduce((t,e,i)=>{const r=Math.floor(i===3?e*255:e)&255;return t<<8|r},0)>>>0}function la(n){return new m([n>>16&255,n>>8&255,n&255],"rgb")}function ca(n){return new m([n>>24&255,n>>16&255,n>>8&255,b(n&255,0,255,0,1)],"rgb")}function pa(n){return typeof n!="number"?m.black():la(n)}function da(n){return typeof n!="number"?m.black():ca(n)}function Yt(n,t){return typeof n!="object"||g(n)?!1:t in n&&typeof n[t]=="number"}function Di(n){return Yt(n,"r")&&Yt(n,"g")&&Yt(n,"b")}function Fi(n){return Di(n)&&Yt(n,"a")}function Bi(n){return Di(n)}function Qe(n,t){if(n.mode!==t.mode||n.type!==t.type)return!1;const e=n.getComponents(),i=t.getComponents();for(let r=0;r{$t(e,t(i))}:null}function ha(n){const t=n?aa:oa;return(e,i)=>{$t(e,t(i))}}function va(n,t,e){const r=L(t,e).toRgbaObject();n.writeProperty("r",r.r),n.writeProperty("g",r.g),n.writeProperty("b",r.b),n.writeProperty("a",r.a)}function ma(n,t,e){const r=L(t,e).toRgbaObject();n.writeProperty("r",r.r),n.writeProperty("g",r.g),n.writeProperty("b",r.b)}function ba(n,t){return(e,i)=>{n?va(e,i,t):ma(e,i,t)}}function fa(n){var t;return!!(!((t=n==null?void 0:n.color)===null||t===void 0)&&t.alpha)}function ga(n){return n?t=>Ye(t,"0x"):t=>We(t,"0x")}function wa(n){return"color"in n||n.view==="color"}const _a=A({id:"input-color-number",type:"input",accept:(n,t)=>{if(typeof n!="number"||!wa(t))return null;const e=qe(t);return e?{initialValue:n,params:Object.assign(Object.assign({},e),{supportsAlpha:fa(t)})}:null},binding:{reader:n=>n.params.supportsAlpha?da:pa,equals:Qe,writer:n=>ha(n.params.supportsAlpha)},controller:n=>{var t,e;return new Xe(n.document,{colorType:"int",expanded:(t=n.params.expanded)!==null&&t!==void 0?t:!1,formatter:ga(n.params.supportsAlpha),parser:Kt("int"),pickerLayout:(e=n.params.picker)!==null&&e!==void 0?e:"popup",supportsAlpha:n.params.supportsAlpha,value:n.value,viewProps:n.viewProps})}});function Ca(n,t){if(!Bi(n))return L(m.black(),t);if(t==="int"){const e=yn(n);return new m(e,"rgb")}if(t==="float"){const e=yn(n);return new Ue(e,"rgb")}return L(m.black(),"int")}function xa(n){return Fi(n)}function ya(n){return t=>{const e=Ca(t,n);return L(e,"int")}}function Pa(n,t){return e=>n?Oi(e,t):Ri(e,t)}const Ea=A({id:"input-color-object",type:"input",accept:(n,t)=>{var e;if(!Bi(n))return null;const i=qe(t);return i?{initialValue:n,params:Object.assign(Object.assign({},i),{colorType:(e=_i(t))!==null&&e!==void 0?e:"int"})}:null},binding:{reader:n=>ya(n.params.colorType),equals:Qe,writer:n=>ba(xa(n.initialValue),n.params.colorType)},controller:n=>{var t,e;const i=Fi(n.initialValue);return new Xe(n.document,{colorType:n.params.colorType,expanded:(t=n.params.expanded)!==null&&t!==void 0?t:!1,formatter:Pa(i,n.params.colorType),parser:Kt("int"),pickerLayout:(e=n.params.picker)!==null&&e!==void 0?e:"popup",supportsAlpha:i,value:n.value,viewProps:n.viewProps})}}),ka=A({id:"input-color-string",type:"input",accept:(n,t)=>{if(typeof n!="string"||t.view==="text")return null;const e=Do(n,_i(t));if(!e)return null;const i=Mi(e);if(!i)return null;const r=qe(t);return r?{initialValue:n,params:Object.assign(Object.assign({},r),{format:e,stringifier:i})}:null},binding:{reader:()=>Fo,equals:Qe,writer:n=>{const t=ua(n.params.format);if(!t)throw E.notBindable();return t}},controller:n=>{var t,e;return new Xe(n.document,{colorType:n.params.format.type,expanded:(t=n.params.expanded)!==null&&t!==void 0?t:!1,formatter:n.params.stringifier,parser:Kt("int"),pickerLayout:(e=n.params.picker)!==null&&e!==void 0?e:"popup",supportsAlpha:n.params.format.alpha,value:n.value,viewProps:n.viewProps})}});class Ze{constructor(t){this.components=t.components,this.asm_=t.assembly}constrain(t){const e=this.asm_.toComponents(t).map((i,r)=>{var s,o;return(o=(s=this.components[r])===null||s===void 0?void 0:s.constrain(i))!==null&&o!==void 0?o:i});return this.asm_.fromComponents(e)}}const Pn=v("pndtxt");class Va{constructor(t,e){this.textViews=e.textViews,this.element=t.createElement("div"),this.element.classList.add(Pn()),this.textViews.forEach(i=>{const r=t.createElement("div");r.classList.add(Pn("a")),r.appendChild(i.element),this.element.appendChild(r)})}}function Sa(n,t,e){return new Ht(n,{arrayPosition:e===0?"fst":e===t.axes.length-1?"lst":"mid",parser:t.parser,props:t.axes[e].textProps,value:C(0,{constraint:t.axes[e].constraint}),viewProps:t.viewProps})}class Je{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.acs_=e.axes.map((i,r)=>Sa(t,e,r)),this.acs_.forEach((i,r)=>{_t({primary:this.value,secondary:i.value,forward:s=>e.assembly.toComponents(s)[r],backward:(s,o)=>{const a=e.assembly.toComponents(s);return a[r]=o,e.assembly.fromComponents(a)}})}),this.view=new Va(t,{textViews:this.acs_.map(i=>i.view)})}get textControllers(){return this.acs_}}class Ta extends At{get max(){return this.controller.valueController.sliderController.props.get("max")}set max(t){this.controller.valueController.sliderController.props.set("max",t)}get min(){return this.controller.valueController.sliderController.props.get("min")}set min(t){this.controller.valueController.sliderController.props.set("min",t)}}function La(n,t){const e=[],i=Wn(n,t);i&&e.push(i);const r=Yn(n);r&&e.push(r);const s=Ke(n.options);return s&&e.push(s),new jt(e)}const Aa=A({id:"input-number",type:"input",accept:(n,t)=>{if(typeof n!="number")return null;const e=x(t,i=>Object.assign(Object.assign({},Qn(i)),{options:i.optional.custom(zt),readonly:i.optional.constant(!1)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>Kn,constraint:n=>La(n.params,n.initialValue),writer:n=>$t},controller:n=>{const t=n.value,e=n.constraint,i=e&&Jt(e,Nt);if(i)return new et(n.document,{props:new u({options:i.values.value("options")}),value:t,viewProps:n.viewProps});const r=Xn(n.params,t.rawValue),s=e&&Jt(e,Ft);return s?new ee(n.document,Object.assign(Object.assign({},vi(Object.assign(Object.assign({},r),{keyScale:C(r.keyScale),max:s.values.value("max"),min:s.values.value("min")}))),{parser:G,value:t,viewProps:n.viewProps})):new Ht(n.document,{parser:G,props:u.fromObject(r),value:t,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="number"?null:n.controller.valueController instanceof ee?new Ta(n.controller):n.controller.valueController instanceof et?new He(n.controller):null}});class tt{constructor(t=0,e=0){this.x=t,this.y=e}getComponents(){return[this.x,this.y]}static isObject(t){if(g(t))return!1;const e=t.x,i=t.y;return!(typeof e!="number"||typeof i!="number")}static equals(t,e){return t.x===e.x&&t.y===e.y}toObject(){return{x:this.x,y:this.y}}}const Ii={toComponents:n=>n.getComponents(),fromComponents:n=>new tt(...n)},ut=v("p2d");class Ra{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(ut()),e.viewProps.bindClassModifiers(this.element),U(e.expanded,ft(this.element,ut(void 0,"expanded")));const i=t.createElement("div");i.classList.add(ut("h")),this.element.appendChild(i);const r=t.createElement("button");r.classList.add(ut("b")),r.appendChild(ae(t,"p2dpad")),e.viewProps.bindDisabled(r),i.appendChild(r),this.buttonElement=r;const s=t.createElement("div");if(s.classList.add(ut("t")),i.appendChild(s),this.textElement=s,e.pickerLayout==="inline"){const o=t.createElement("div");o.classList.add(ut("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}}const Q=v("p2dp");class Oa{constructor(t,e){this.onFoldableChange_=this.onFoldableChange_.bind(this),this.onPropsChange_=this.onPropsChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.props_=e.props,this.props_.emitter.on("change",this.onPropsChange_),this.element=t.createElement("div"),this.element.classList.add(Q()),e.layout==="popup"&&this.element.classList.add(Q(void 0,"p")),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(Q("p")),e.viewProps.bindTabIndex(i),this.element.appendChild(i),this.padElement=i;const r=t.createElementNS(z,"svg");r.classList.add(Q("g")),this.padElement.appendChild(r),this.svgElem_=r;const s=t.createElementNS(z,"line");s.classList.add(Q("ax")),s.setAttributeNS(null,"x1","0"),s.setAttributeNS(null,"y1","50%"),s.setAttributeNS(null,"x2","100%"),s.setAttributeNS(null,"y2","50%"),this.svgElem_.appendChild(s);const o=t.createElementNS(z,"line");o.classList.add(Q("ax")),o.setAttributeNS(null,"x1","50%"),o.setAttributeNS(null,"y1","0"),o.setAttributeNS(null,"x2","50%"),o.setAttributeNS(null,"y2","100%"),this.svgElem_.appendChild(o);const a=t.createElementNS(z,"line");a.classList.add(Q("l")),a.setAttributeNS(null,"x1","50%"),a.setAttributeNS(null,"y1","50%"),this.svgElem_.appendChild(a),this.lineElem_=a;const l=t.createElement("div");l.classList.add(Q("m")),this.padElement.appendChild(l),this.markerElem_=l,e.value.emitter.on("change",this.onValueChange_),this.value=e.value,this.update_()}get allFocusableElements(){return[this.padElement]}update_(){const[t,e]=this.value.rawValue.getComponents(),i=this.props_.get("max"),r=b(t,-i,+i,0,100),s=b(e,-i,+i,0,100),o=this.props_.get("invertsY")?100-s:s;this.lineElem_.setAttributeNS(null,"x2",`${r}%`),this.lineElem_.setAttributeNS(null,"y2",`${o}%`),this.markerElem_.style.left=`${r}%`,this.markerElem_.style.top=`${o}%`}onValueChange_(){this.update_()}onPropsChange_(){this.update_()}onFoldableChange_(){this.update_()}}function En(n,t,e){return[R(t[0],W(n)),R(t[1],Ot(n))*(e?1:-1)]}class Ma{constructor(t,e){this.onPadKeyDown_=this.onPadKeyDown_.bind(this),this.onPadKeyUp_=this.onPadKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.props=e.props,this.value=e.value,this.viewProps=e.viewProps,this.view=new Oa(t,{layout:e.layout,props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new ct(this.view.padElement),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.padElement.addEventListener("keydown",this.onPadKeyDown_),this.view.padElement.addEventListener("keyup",this.onPadKeyUp_)}handlePointerEvent_(t,e){if(!t.point)return;const i=this.props.get("max"),r=b(t.point.x,0,t.bounds.width,-i,+i),s=b(this.props.get("invertsY")?t.bounds.height-t.point.y:t.point.y,0,t.bounds.height,-i,+i);this.value.setRawValue(new tt(r,s),e)}onPointerDown_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerMove_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerUp_(t){this.handlePointerEvent_(t.data,{forceEmit:!0,last:!0})}onPadKeyDown_(t){hi(t.key)&&t.preventDefault();const[e,i]=En(t,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));e===0&&i===0||this.value.setRawValue(new tt(this.value.rawValue.x+e,this.value.rawValue.y+i),{forceEmit:!1,last:!1})}onPadKeyUp_(t){const[e,i]=En(t,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));e===0&&i===0||this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}class Da{constructor(t,e){var i,r;this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.onPadButtonBlur_=this.onPadButtonBlur_.bind(this),this.onPadButtonClick_=this.onPadButtonClick_.bind(this),this.value=e.value,this.viewProps=e.viewProps,this.foldable_=It.create(e.expanded),this.popC_=e.pickerLayout==="popup"?new pi(t,{viewProps:this.viewProps}):null;const s=new Ma(t,{layout:e.pickerLayout,props:new u({invertsY:C(e.invertsY),max:C(e.max),xKeyScale:e.axes[0].textProps.value("keyScale"),yKeyScale:e.axes[1].textProps.value("keyScale")}),value:this.value,viewProps:this.viewProps});s.view.allFocusableElements.forEach(o=>{o.addEventListener("blur",this.onPopupChildBlur_),o.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=s,this.textC_=new Je(t,{assembly:Ii,axes:e.axes,parser:e.parser,value:this.value,viewProps:this.viewProps}),this.view=new Ra(t,{expanded:this.foldable_.value("expanded"),pickerLayout:e.pickerLayout,viewProps:this.viewProps}),this.view.textElement.appendChild(this.textC_.view.element),(i=this.view.buttonElement)===null||i===void 0||i.addEventListener("blur",this.onPadButtonBlur_),(r=this.view.buttonElement)===null||r===void 0||r.addEventListener("click",this.onPadButtonClick_),this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(this.pickerC_.view.element),_t({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:o=>o,backward:(o,a)=>a})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),ze(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onPadButtonBlur_(t){if(!this.popC_)return;const e=this.view.element,i=t.relatedTarget;(!i||!e.contains(i))&&(this.popC_.shows.rawValue=!1)}onPadButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.view.allFocusableElements[0].focus()}onPopupChildBlur_(t){if(!this.popC_)return;const e=this.popC_.view.element,i=ei(t);i&&e.contains(i)||i&&i===this.view.buttonElement&&!De(e.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(t){this.popC_?t.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&t.key==="Escape"&&this.view.buttonElement.focus()}}function Fa(n){return tt.isObject(n)?new tt(n.x,n.y):new tt}function Ba(n,t){n.writeProperty("x",t.x),n.writeProperty("y",t.y)}function Ia(n,t){return new Ze({assembly:Ii,components:[q(Object.assign(Object.assign({},n),n.x),t.x),q(Object.assign(Object.assign({},n),n.y),t.y)]})}function kn(n,t){var e,i;if(!g(n.min)||!g(n.max))return Math.max(Math.abs((e=n.min)!==null&&e!==void 0?e:0),Math.abs((i=n.max)!==null&&i!==void 0?i:0));const r=Un(n);return Math.max(Math.abs(r)*10,Math.abs(t)*10)}function ja(n,t){var e,i;const r=kn(st(n,(e=n.x)!==null&&e!==void 0?e:{}),t.x),s=kn(st(n,(i=n.y)!==null&&i!==void 0?i:{}),t.y);return Math.max(r,s)}function Na(n){if(!("y"in n))return!1;const t=n.y;return t&&"inverted"in t?!!t.inverted:!1}const za=A({id:"input-point2d",type:"input",accept:(n,t)=>{if(!tt.isObject(n))return null;const e=x(t,i=>Object.assign(Object.assign({},Mt(i)),{expanded:i.optional.boolean,picker:i.optional.custom(bi),readonly:i.optional.constant(!1),x:i.optional.custom(J),y:i.optional.object(Object.assign(Object.assign({},Mt(i)),{inverted:i.optional.boolean}))}));return e?{initialValue:n,params:e}:null},binding:{reader:()=>Fa,constraint:n=>Ia(n.params,n.initialValue),equals:tt.equals,writer:()=>Ba},controller:n=>{var t,e;const i=n.document,r=n.value,s=n.constraint,o=[n.params.x,n.params.y];return new Da(i,{axes:r.rawValue.getComponents().map((a,l)=>{var c;return Me({constraint:s.components[l],initialValue:a,params:st(n.params,(c=o[l])!==null&&c!==void 0?c:{})})}),expanded:(t=n.params.expanded)!==null&&t!==void 0?t:!1,invertsY:Na(n.params),max:ja(n.params,r.rawValue),parser:G,pickerLayout:(e=n.params.picker)!==null&&e!==void 0?e:"popup",value:r,viewProps:n.viewProps})}});class vt{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}getComponents(){return[this.x,this.y,this.z]}static isObject(t){if(g(t))return!1;const e=t.x,i=t.y,r=t.z;return!(typeof e!="number"||typeof i!="number"||typeof r!="number")}static equals(t,e){return t.x===e.x&&t.y===e.y&&t.z===e.z}toObject(){return{x:this.x,y:this.y,z:this.z}}}const ji={toComponents:n=>n.getComponents(),fromComponents:n=>new vt(...n)};function Ha(n){return vt.isObject(n)?new vt(n.x,n.y,n.z):new vt}function $a(n,t){n.writeProperty("x",t.x),n.writeProperty("y",t.y),n.writeProperty("z",t.z)}function Ka(n,t){return new Ze({assembly:ji,components:[q(Object.assign(Object.assign({},n),n.x),t.x),q(Object.assign(Object.assign({},n),n.y),t.y),q(Object.assign(Object.assign({},n),n.z),t.z)]})}const qa=A({id:"input-point3d",type:"input",accept:(n,t)=>{if(!vt.isObject(n))return null;const e=x(t,i=>Object.assign(Object.assign({},Mt(i)),{readonly:i.optional.constant(!1),x:i.optional.custom(J),y:i.optional.custom(J),z:i.optional.custom(J)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>Ha,constraint:n=>Ka(n.params,n.initialValue),equals:vt.equals,writer:n=>$a},controller:n=>{const t=n.value,e=n.constraint,i=[n.params.x,n.params.y,n.params.z];return new Je(n.document,{assembly:ji,axes:t.rawValue.getComponents().map((r,s)=>{var o;return Me({constraint:e.components[s],initialValue:r,params:st(n.params,(o=i[s])!==null&&o!==void 0?o:{})})}),parser:G,value:t,viewProps:n.viewProps})}});class mt{constructor(t=0,e=0,i=0,r=0){this.x=t,this.y=e,this.z=i,this.w=r}getComponents(){return[this.x,this.y,this.z,this.w]}static isObject(t){if(g(t))return!1;const e=t.x,i=t.y,r=t.z,s=t.w;return!(typeof e!="number"||typeof i!="number"||typeof r!="number"||typeof s!="number")}static equals(t,e){return t.x===e.x&&t.y===e.y&&t.z===e.z&&t.w===e.w}toObject(){return{x:this.x,y:this.y,z:this.z,w:this.w}}}const Ni={toComponents:n=>n.getComponents(),fromComponents:n=>new mt(...n)};function Ua(n){return mt.isObject(n)?new mt(n.x,n.y,n.z,n.w):new mt}function Ga(n,t){n.writeProperty("x",t.x),n.writeProperty("y",t.y),n.writeProperty("z",t.z),n.writeProperty("w",t.w)}function Wa(n,t){return new Ze({assembly:Ni,components:[q(Object.assign(Object.assign({},n),n.x),t.x),q(Object.assign(Object.assign({},n),n.y),t.y),q(Object.assign(Object.assign({},n),n.z),t.z),q(Object.assign(Object.assign({},n),n.w),t.w)]})}const Ya=A({id:"input-point4d",type:"input",accept:(n,t)=>{if(!mt.isObject(n))return null;const e=x(t,i=>Object.assign(Object.assign({},Mt(i)),{readonly:i.optional.constant(!1),w:i.optional.custom(J),x:i.optional.custom(J),y:i.optional.custom(J),z:i.optional.custom(J)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>Ua,constraint:n=>Wa(n.params,n.initialValue),equals:mt.equals,writer:n=>Ga},controller:n=>{const t=n.value,e=n.constraint,i=[n.params.x,n.params.y,n.params.z,n.params.w];return new Je(n.document,{assembly:Ni,axes:t.rawValue.getComponents().map((r,s)=>{var o;return Me({constraint:e.components[s],initialValue:r,params:st(n.params,(o=i[s])!==null&&o!==void 0?o:{})})}),parser:G,value:t,viewProps:n.viewProps})}});function Xa(n){const t=[],e=Ke(n.options);return e&&t.push(e),new jt(t)}const Qa=A({id:"input-string",type:"input",accept:(n,t)=>{if(typeof n!="string")return null;const e=x(t,i=>({readonly:i.optional.constant(!1),options:i.optional.custom(zt)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>ui,constraint:n=>Xa(n.params),writer:n=>$t},controller:n=>{const t=n.document,e=n.value,i=n.constraint,r=i&&Jt(i,Nt);return r?new et(t,{props:new u({options:r.values.value("options")}),value:e,viewProps:n.viewProps}):new Rt(t,{parser:s=>s,props:u.fromObject({formatter:Se}),value:e,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="string"?null:n.controller.valueController instanceof et?new He(n.controller):null}}),qt={monitor:{defaultInterval:200,defaultRows:3}},Vn=v("mll");class Za{constructor(t,e){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=e.formatter,this.element=t.createElement("div"),this.element.classList.add(Vn()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("textarea");i.classList.add(Vn("i")),i.style.height=`calc(var(${mi("containerUnitSize")}) * ${e.rows})`,i.readOnly=!0,e.viewProps.bindDisabled(i),this.element.appendChild(i),this.textareaElem_=i,e.value.emitter.on("change",this.onValueUpdate_),this.value=e.value,this.update_()}update_(){const t=this.textareaElem_,e=t.scrollTop===t.scrollHeight-t.clientHeight,i=[];this.value.rawValue.forEach(r=>{r!==void 0&&i.push(this.formatter_(r))}),t.textContent=i.join(` -`),e&&(t.scrollTop=t.scrollHeight)}onValueUpdate_(){this.update_()}}class tn{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.view=new Za(t,{formatter:e.formatter,rows:e.rows,value:this.value,viewProps:this.viewProps})}}const Sn=v("sgl");class Ja{constructor(t,e){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=e.formatter,this.element=t.createElement("div"),this.element.classList.add(Sn()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("input");i.classList.add(Sn("i")),i.readOnly=!0,i.type="text",e.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,e.value.emitter.on("change",this.onValueUpdate_),this.value=e.value,this.update_()}update_(){const t=this.value.rawValue,e=t[t.length-1];this.inputElement.value=e!==void 0?this.formatter_(e):""}onValueUpdate_(){this.update_()}}class en{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.view=new Ja(t,{formatter:e.formatter,value:this.value,viewProps:this.viewProps})}}const tl=A({id:"monitor-bool",type:"monitor",accept:(n,t)=>{if(typeof n!="boolean")return null;const e=x(t,i=>({readonly:i.required.constant(!0),rows:i.optional.number}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>di},controller:n=>{var t;return n.value.rawValue.length===1?new en(n.document,{formatter:gn,value:n.value,viewProps:n.viewProps}):new tn(n.document,{formatter:gn,rows:(t=n.params.rows)!==null&&t!==void 0?t:qt.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}});class el extends At{get max(){return this.controller.valueController.props.get("max")}set max(t){this.controller.valueController.props.set("max",t)}get min(){return this.controller.valueController.props.get("min")}set min(t){this.controller.valueController.props.set("min",t)}}const Z=v("grl");class nl{constructor(t,e){this.onCursorChange_=this.onCursorChange_.bind(this),this.onValueUpdate_=this.onValueUpdate_.bind(this),this.element=t.createElement("div"),this.element.classList.add(Z()),e.viewProps.bindClassModifiers(this.element),this.formatter_=e.formatter,this.props_=e.props,this.cursor_=e.cursor,this.cursor_.emitter.on("change",this.onCursorChange_);const i=t.createElementNS(z,"svg");i.classList.add(Z("g")),i.style.height=`calc(var(${mi("containerUnitSize")}) * ${e.rows})`,this.element.appendChild(i),this.svgElem_=i;const r=t.createElementNS(z,"polyline");this.svgElem_.appendChild(r),this.lineElem_=r;const s=t.createElement("div");s.classList.add(Z("t"),v("tt")()),this.element.appendChild(s),this.tooltipElem_=s,e.value.emitter.on("change",this.onValueUpdate_),this.value=e.value,this.update_()}get graphElement(){return this.svgElem_}update_(){const{clientWidth:t,clientHeight:e}=this.element,i=this.value.rawValue.length-1,r=this.props_.get("min"),s=this.props_.get("max"),o=[];this.value.rawValue.forEach((d,h)=>{if(d===void 0)return;const S=b(h,0,i,0,t),y=b(d,r,s,e,0);o.push([S,y].join(","))}),this.lineElem_.setAttributeNS(null,"points",o.join(" "));const a=this.tooltipElem_,l=this.value.rawValue[this.cursor_.rawValue];if(l===void 0){a.classList.remove(Z("t","a"));return}const c=b(this.cursor_.rawValue,0,i,0,t),p=b(l,r,s,e,0);a.style.left=`${c}px`,a.style.top=`${p}px`,a.textContent=`${this.formatter_(l)}`,a.classList.contains(Z("t","a"))||(a.classList.add(Z("t","a"),Z("t","in")),Zt(a),a.classList.remove(Z("t","in")))}onValueUpdate_(){this.update_()}onCursorChange_(){this.update_()}}class zi{constructor(t,e){if(this.onGraphMouseMove_=this.onGraphMouseMove_.bind(this),this.onGraphMouseLeave_=this.onGraphMouseLeave_.bind(this),this.onGraphPointerDown_=this.onGraphPointerDown_.bind(this),this.onGraphPointerMove_=this.onGraphPointerMove_.bind(this),this.onGraphPointerUp_=this.onGraphPointerUp_.bind(this),this.props=e.props,this.value=e.value,this.viewProps=e.viewProps,this.cursor_=C(-1),this.view=new nl(t,{cursor:this.cursor_,formatter:e.formatter,rows:e.rows,props:this.props,value:this.value,viewProps:this.viewProps}),!De(t))this.view.element.addEventListener("mousemove",this.onGraphMouseMove_),this.view.element.addEventListener("mouseleave",this.onGraphMouseLeave_);else{const i=new ct(this.view.element);i.emitter.on("down",this.onGraphPointerDown_),i.emitter.on("move",this.onGraphPointerMove_),i.emitter.on("up",this.onGraphPointerUp_)}}importProps(t){return M(t,null,e=>({max:e.required.number,min:e.required.number}),e=>(this.props.set("max",e.max),this.props.set("min",e.min),!0))}exportProps(){return D(null,{max:this.props.get("max"),min:this.props.get("min")})}onGraphMouseLeave_(){this.cursor_.rawValue=-1}onGraphMouseMove_(t){const{clientWidth:e}=this.view.element;this.cursor_.rawValue=Math.floor(b(t.offsetX,0,e,0,this.value.rawValue.length))}onGraphPointerDown_(t){this.onGraphPointerMove_(t)}onGraphPointerMove_(t){if(!t.data.point){this.cursor_.rawValue=-1;return}this.cursor_.rawValue=Math.floor(b(t.data.point.x,0,t.data.bounds.width,0,this.value.rawValue.length))}onGraphPointerUp_(){this.cursor_.rawValue=-1}}function Te(n){return g(n.format)?O(2):n.format}function il(n){var t;return n.value.rawValue.length===1?new en(n.document,{formatter:Te(n.params),value:n.value,viewProps:n.viewProps}):new tn(n.document,{formatter:Te(n.params),rows:(t=n.params.rows)!==null&&t!==void 0?t:qt.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}function rl(n){var t,e,i;return new zi(n.document,{formatter:Te(n.params),rows:(t=n.params.rows)!==null&&t!==void 0?t:qt.monitor.defaultRows,props:u.fromObject({max:(e=n.params.max)!==null&&e!==void 0?e:100,min:(i=n.params.min)!==null&&i!==void 0?i:0}),value:n.value,viewProps:n.viewProps})}function Tn(n){return n.view==="graph"}const sl=A({id:"monitor-number",type:"monitor",accept:(n,t)=>{if(typeof n!="number")return null;const e=x(t,i=>({format:i.optional.function,max:i.optional.number,min:i.optional.number,readonly:i.required.constant(!0),rows:i.optional.number,view:i.optional.string}));return e?{initialValue:n,params:e}:null},binding:{defaultBufferSize:n=>Tn(n)?64:1,reader:n=>Kn},controller:n=>Tn(n.params)?rl(n):il(n),api:n=>n.controller.valueController instanceof zi?new el(n.controller):null}),ol=A({id:"monitor-string",type:"monitor",accept:(n,t)=>{if(typeof n!="string")return null;const e=x(t,i=>({multiline:i.optional.boolean,readonly:i.required.constant(!0),rows:i.optional.number}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>ui},controller:n=>{var t;const e=n.value;return e.rawValue.length>1||n.params.multiline?new tn(n.document,{formatter:Se,rows:(t=n.params.rows)!==null&&t!==void 0?t:qt.monitor.defaultRows,value:e,viewProps:n.viewProps}):new en(n.document,{formatter:Se,value:e,viewProps:n.viewProps})}});class al{constructor(){this.map_=new Map}get(t){var e;return(e=this.map_.get(t))!==null&&e!==void 0?e:null}has(t){return this.map_.has(t)}add(t,e){return this.map_.set(t,e),t.viewProps.handleDispose(()=>{this.map_.delete(t)}),e}}class ll{constructor(t){this.target=t.target,this.reader_=t.reader,this.writer_=t.writer}read(){return this.reader_(this.target.read())}write(t){this.writer_(this.target,t)}inject(t){this.write(this.reader_(t))}}function cl(n,t){var e;const i=n.accept(t.target.read(),t.params);if(g(i))return null;const r={target:t.target,initialValue:i.initialValue,params:i.params},s=x(t.params,d=>({disabled:d.optional.boolean,hidden:d.optional.boolean,label:d.optional.string,tag:d.optional.string})),o=n.binding.reader(r),a=n.binding.constraint?n.binding.constraint(r):void 0,l=new ll({reader:o,target:t.target,writer:n.binding.writer(r)}),c=new Gr(C(o(i.initialValue),{constraint:a,equals:n.binding.equals}),l),p=n.controller({constraint:a,document:t.document,initialValue:i.initialValue,params:i.params,value:c,viewProps:Y.create({disabled:s==null?void 0:s.disabled,hidden:s==null?void 0:s.hidden})});return new ls(t.document,{blade:wt(),props:u.fromObject({label:"label"in t.params?(e=s==null?void 0:s.label)!==null&&e!==void 0?e:null:t.target.key}),tag:s==null?void 0:s.tag,value:c,valueController:p})}class pl{constructor(t){this.target=t.target,this.reader_=t.reader}read(){return this.reader_(this.target.read())}}function dl(n,t){return t===0?new Ks:new qs(n,t??qt.monitor.defaultInterval)}function ul(n,t){var e,i,r;const s=n.accept(t.target.read(),t.params);if(g(s))return null;const o={target:t.target,initialValue:s.initialValue,params:s.params},a=x(t.params,h=>({bufferSize:h.optional.number,disabled:h.optional.boolean,hidden:h.optional.boolean,interval:h.optional.number,label:h.optional.string})),l=n.binding.reader(o),c=(i=(e=a==null?void 0:a.bufferSize)!==null&&e!==void 0?e:n.binding.defaultBufferSize&&n.binding.defaultBufferSize(s.params))!==null&&i!==void 0?i:1,p=new hs({binding:new pl({reader:l,target:t.target}),bufferSize:c,ticker:dl(t.document,a==null?void 0:a.interval)}),d=n.controller({document:t.document,params:s.params,value:p,viewProps:Y.create({disabled:a==null?void 0:a.disabled,hidden:a==null?void 0:a.hidden})});return d.viewProps.bindDisabled(p.ticker),d.viewProps.handleDispose(()=>{p.ticker.dispose()}),new ms(t.document,{blade:wt(),props:u.fromObject({label:"label"in t.params?(r=a==null?void 0:a.label)!==null&&r!==void 0?r:null:t.target.key}),value:p,valueController:d})}class hl{constructor(t){this.pluginsMap_={blades:[],inputs:[],monitors:[]},this.apiCache_=t}getAll(){return[...this.pluginsMap_.blades,...this.pluginsMap_.inputs,...this.pluginsMap_.monitors]}register(t,e){if(!ro(e.core))throw E.notCompatible(t,e.id);e.type==="blade"?this.pluginsMap_.blades.unshift(e):e.type==="input"?this.pluginsMap_.inputs.unshift(e):e.type==="monitor"&&this.pluginsMap_.monitors.unshift(e)}createInput_(t,e,i){return this.pluginsMap_.inputs.reduce((r,s)=>r??cl(s,{document:t,target:e,params:i}),null)}createMonitor_(t,e,i){return this.pluginsMap_.monitors.reduce((r,s)=>r??ul(s,{document:t,params:i,target:e}),null)}createBinding(t,e,i){const r=e.read();if(g(r))throw new E({context:{key:e.key},type:"nomatchingcontroller"});const s=this.createInput_(t,e,i);if(s)return s;const o=this.createMonitor_(t,e,i);if(o)return o;throw new E({context:{key:e.key},type:"nomatchingcontroller"})}createBlade(t,e){const i=this.pluginsMap_.blades.reduce((r,s)=>r??$s(s,{document:t,params:e}),null);if(!i)throw new E({type:"nomatchingview",context:{params:e}});return i}createInputBindingApi_(t){const e=this.pluginsMap_.inputs.reduce((i,r)=>{var s,o;return i||((o=(s=r.api)===null||s===void 0?void 0:s.call(r,{controller:t}))!==null&&o!==void 0?o:null)},null);return this.apiCache_.add(t,e??new At(t))}createMonitorBindingApi_(t){const e=this.pluginsMap_.monitors.reduce((i,r)=>{var s,o;return i||((o=(s=r.api)===null||s===void 0?void 0:s.call(r,{controller:t}))!==null&&o!==void 0?o:null)},null);return this.apiCache_.add(t,e??new At(t))}createBindingApi(t){if(this.apiCache_.has(t))return this.apiCache_.get(t);if(cs(t))return this.createInputBindingApi_(t);if(bs(t))return this.createMonitorBindingApi_(t);throw E.shouldNeverHappen()}createApi(t){if(this.apiCache_.has(t))return this.apiCache_.get(t);if(as(t))return this.createBindingApi(t);const e=this.pluginsMap_.blades.reduce((i,r)=>i??r.api({controller:t,pool:this}),null);if(!e)throw E.shouldNeverHappen();return this.apiCache_.add(t,e)}}const vl=new al;function ml(){const n=new hl(vl);return[za,qa,Ya,Qa,Aa,ka,Ea,_a,lo,tl,ol,sl,Cs,Ms,ci].forEach(t=>{n.register("core",t)}),n}class bl extends lt{constructor(t){super(t),this.emitter_=new k,this.controller.value.emitter.on("change",e=>{this.emitter_.emit("change",new Bt(this,e.rawValue))})}get label(){return this.controller.labelController.props.get("label")}set label(t){this.controller.labelController.props.set("label",t)}get options(){return this.controller.valueController.props.get("options")}set options(t){this.controller.valueController.props.set("options",t)}get value(){return this.controller.value.rawValue}set value(t){this.controller.value.rawValue=t}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}}class fl extends lt{}class gl extends lt{constructor(t){super(t),this.emitter_=new k,this.controller.value.emitter.on("change",e=>{this.emitter_.emit("change",new Bt(this,e.rawValue))})}get label(){return this.controller.labelController.props.get("label")}set label(t){this.controller.labelController.props.set("label",t)}get max(){return this.controller.valueController.sliderController.props.get("max")}set max(t){this.controller.valueController.sliderController.props.set("max",t)}get min(){return this.controller.valueController.sliderController.props.get("min")}set min(t){this.controller.valueController.sliderController.props.set("min",t)}get value(){return this.controller.value.rawValue}set value(t){this.controller.value.rawValue=t}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}}class wl extends lt{constructor(t){super(t),this.emitter_=new k,this.controller.value.emitter.on("change",e=>{this.emitter_.emit("change",new Bt(this,e.rawValue))})}get label(){return this.controller.labelController.props.get("label")}set label(t){this.controller.labelController.props.set("label",t)}get formatter(){return this.controller.valueController.props.get("formatter")}set formatter(t){this.controller.valueController.props.set("formatter",t)}get value(){return this.controller.value.rawValue}set value(t){this.controller.value.rawValue=t}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}}const _l=function(){return{id:"list",type:"blade",core:gt,accept(n){const t=x(n,e=>({options:e.required.custom(zt),value:e.required.raw,view:e.required.constant("list"),label:e.optional.string}));return t?{params:t}:null},controller(n){const t=new Nt($e(n.params.options)),e=C(n.params.value,{constraint:t}),i=new et(n.document,{props:new u({options:t.values.value("options")}),value:e,viewProps:n.viewProps});return new ot(n.document,{blade:n.blade,props:u.fromObject({label:n.params.label}),value:e,valueController:i})},api(n){return!(n.controller instanceof ot)||!(n.controller.valueController instanceof et)?null:new bl(n.controller)}}}();class Cl extends ai{constructor(t,e){super(t,e)}get element(){return this.controller.view.element}}class xl extends ke{constructor(t,e){super(t,{expanded:e.expanded,blade:e.blade,props:e.props,root:!0,viewProps:e.viewProps})}}const Ln=v("spr");class yl{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(Ln()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("hr");i.classList.add(Ln("r")),this.element.appendChild(i)}}class An extends le{constructor(t,e){super(Object.assign(Object.assign({},e),{view:new yl(t,{viewProps:e.viewProps})}))}}const Pl={id:"separator",type:"blade",core:gt,accept(n){const t=x(n,e=>({view:e.required.constant("separator")}));return t?{params:t}:null},controller(n){return new An(n.document,{blade:n.blade,viewProps:n.viewProps})},api(n){return n.controller instanceof An?new fl(n.controller):null}},El={id:"slider",type:"blade",core:gt,accept(n){const t=x(n,e=>({max:e.required.number,min:e.required.number,view:e.required.constant("slider"),format:e.optional.function,label:e.optional.string,value:e.optional.number}));return t?{params:t}:null},controller(n){var t,e;const i=(t=n.params.value)!==null&&t!==void 0?t:0,r=new Ft({max:n.params.max,min:n.params.min}),s=C(i,{constraint:r}),o=new ee(n.document,Object.assign(Object.assign({},vi({formatter:(e=n.params.format)!==null&&e!==void 0?e:Hr,keyScale:C(1),max:r.values.value("max"),min:r.values.value("min"),pointerScale:Gn(n.params,i)})),{parser:G,value:s,viewProps:n.viewProps}));return new ot(n.document,{blade:n.blade,props:u.fromObject({label:n.params.label}),value:s,valueController:o})},api(n){return!(n.controller instanceof ot)||!(n.controller.valueController instanceof ee)?null:new gl(n.controller)}},kl=function(){return{id:"text",type:"blade",core:gt,accept(n){const t=x(n,e=>({parse:e.required.function,value:e.required.raw,view:e.required.constant("text"),format:e.optional.function,label:e.optional.string}));return t?{params:t}:null},controller(n){var t;const e=C(n.params.value),i=new Rt(n.document,{parser:n.params.parse,props:u.fromObject({formatter:(t=n.params.format)!==null&&t!==void 0?t:r=>String(r)}),value:e,viewProps:n.viewProps});return new ot(n.document,{blade:n.blade,props:u.fromObject({label:n.params.label}),value:e,valueController:i})},api(n){return!(n.controller instanceof ot)||!(n.controller.valueController instanceof Rt)?null:new wl(n.controller)}}}();function Vl(n){const t=n.createElement("div");return t.classList.add(v("dfw")()),n.body&&n.body.appendChild(t),t}function Sl(n,t,e){if(n.querySelector(`style[data-tp-style=${t}]`))return;const i=n.createElement("style");i.dataset.tpStyle=t,i.textContent=e,n.head.appendChild(i)}class Tl extends Cl{constructor(t){var e,i;const r=t??{},s=(e=r.document)!==null&&e!==void 0?e:ts(),o=ml(),a=new xl(s,{expanded:r.expanded,blade:wt(),props:u.fromObject({title:r.title}),viewProps:Y.create()});super(a,o),this.pool_=o,this.containerElem_=(i=r.container)!==null&&i!==void 0?i:Vl(s),this.containerElem_.appendChild(this.element),this.doc_=s,this.usesDefaultWrapper_=!r.container,this.setUpDefaultPlugins_()}get document(){if(!this.doc_)throw E.alreadyDisposed();return this.doc_}dispose(){const t=this.containerElem_;if(!t)throw E.alreadyDisposed();if(this.usesDefaultWrapper_){const e=t.parentElement;e&&e.removeChild(t)}this.containerElem_=null,this.doc_=null,super.dispose()}registerPlugin(t){t.css&&Sl(this.document,`plugin-${t.id}`,t.css),("plugin"in t?[t.plugin]:"plugins"in t?t.plugins:[]).forEach(i=>{this.pool_.register(t.id,i)})}setUpDefaultPlugins_(){this.registerPlugin({id:"default",css:'.tp-tbiv_b,.tp-coltxtv_ms,.tp-colswv_b,.tp-ckbv_i,.tp-sglv_i,.tp-mllv_i,.tp-grlv_g,.tp-txtv_i,.tp-p2dpv_p,.tp-colswv_sw,.tp-rotv_b,.tp-fldv_b,.tp-p2dv_b,.tp-btnv_b,.tp-lstv_s{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0;outline:none;padding:0}.tp-p2dv_b,.tp-btnv_b,.tp-lstv_s{background-color:var(--btn-bg);border-radius:var(--bld-br);color:var(--btn-fg);cursor:pointer;display:block;font-weight:bold;height:var(--cnt-usz);line-height:var(--cnt-usz);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-p2dv_b:hover,.tp-btnv_b:hover,.tp-lstv_s:hover{background-color:var(--btn-bg-h)}.tp-p2dv_b:focus,.tp-btnv_b:focus,.tp-lstv_s:focus{background-color:var(--btn-bg-f)}.tp-p2dv_b:active,.tp-btnv_b:active,.tp-lstv_s:active{background-color:var(--btn-bg-a)}.tp-p2dv_b:disabled,.tp-btnv_b:disabled,.tp-lstv_s:disabled{opacity:.5}.tp-rotv_c>.tp-cntv.tp-v-lst,.tp-tbpv_c>.tp-cntv.tp-v-lst,.tp-fldv_c>.tp-cntv.tp-v-lst{margin-bottom:calc(-1*var(--cnt-vp))}.tp-rotv_c>.tp-fldv.tp-v-lst .tp-fldv_c,.tp-tbpv_c>.tp-fldv.tp-v-lst .tp-fldv_c,.tp-fldv_c>.tp-fldv.tp-v-lst .tp-fldv_c{border-bottom-left-radius:0}.tp-rotv_c>.tp-fldv.tp-v-lst .tp-fldv_b,.tp-tbpv_c>.tp-fldv.tp-v-lst .tp-fldv_b,.tp-fldv_c>.tp-fldv.tp-v-lst .tp-fldv_b{border-bottom-left-radius:0}.tp-rotv_c>*:not(.tp-v-fst),.tp-tbpv_c>*:not(.tp-v-fst),.tp-fldv_c>*:not(.tp-v-fst){margin-top:var(--cnt-usp)}.tp-rotv_c>.tp-sprv:not(.tp-v-fst),.tp-tbpv_c>.tp-sprv:not(.tp-v-fst),.tp-fldv_c>.tp-sprv:not(.tp-v-fst),.tp-rotv_c>.tp-cntv:not(.tp-v-fst),.tp-tbpv_c>.tp-cntv:not(.tp-v-fst),.tp-fldv_c>.tp-cntv:not(.tp-v-fst){margin-top:var(--cnt-vp)}.tp-rotv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-tbpv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-fldv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-rotv_c>.tp-cntv+*:not(.tp-v-hidden),.tp-tbpv_c>.tp-cntv+*:not(.tp-v-hidden),.tp-fldv_c>.tp-cntv+*:not(.tp-v-hidden){margin-top:var(--cnt-vp)}.tp-rotv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-tbpv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-fldv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-rotv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv,.tp-tbpv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv,.tp-fldv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv{margin-top:0}.tp-tbpv_c>.tp-cntv,.tp-fldv_c>.tp-cntv{margin-left:4px}.tp-tbpv_c>.tp-fldv>.tp-fldv_b,.tp-fldv_c>.tp-fldv>.tp-fldv_b{border-top-left-radius:var(--bld-br);border-bottom-left-radius:var(--bld-br)}.tp-tbpv_c>.tp-fldv.tp-fldv-expanded>.tp-fldv_b,.tp-fldv_c>.tp-fldv.tp-fldv-expanded>.tp-fldv_b{border-bottom-left-radius:0}.tp-tbpv_c .tp-fldv>.tp-fldv_c,.tp-fldv_c .tp-fldv>.tp-fldv_c{border-bottom-left-radius:var(--bld-br)}.tp-tbpv_c>.tp-cntv+.tp-fldv>.tp-fldv_b,.tp-fldv_c>.tp-cntv+.tp-fldv>.tp-fldv_b{border-top-left-radius:0}.tp-tbpv_c>.tp-cntv+.tp-tabv>.tp-tabv_t,.tp-fldv_c>.tp-cntv+.tp-tabv>.tp-tabv_t{border-top-left-radius:0}.tp-tbpv_c>.tp-tabv>.tp-tabv_t,.tp-fldv_c>.tp-tabv>.tp-tabv_t{border-top-left-radius:var(--bld-br)}.tp-tbpv_c .tp-tabv>.tp-tabv_c,.tp-fldv_c .tp-tabv>.tp-tabv_c{border-bottom-left-radius:var(--bld-br)}.tp-rotv_b,.tp-fldv_b{background-color:var(--cnt-bg);color:var(--cnt-fg);cursor:pointer;display:block;height:calc(var(--cnt-usz) + 4px);line-height:calc(var(--cnt-usz) + 4px);overflow:hidden;padding-left:var(--cnt-hp);padding-right:calc(4px + var(--cnt-usz) + var(--cnt-hp));position:relative;text-align:left;text-overflow:ellipsis;white-space:nowrap;width:100%;transition:border-radius .2s ease-in-out .2s}.tp-rotv_b:hover,.tp-fldv_b:hover{background-color:var(--cnt-bg-h)}.tp-rotv_b:focus,.tp-fldv_b:focus{background-color:var(--cnt-bg-f)}.tp-rotv_b:active,.tp-fldv_b:active{background-color:var(--cnt-bg-a)}.tp-rotv_b:disabled,.tp-fldv_b:disabled{opacity:.5}.tp-rotv_m,.tp-fldv_m{background:linear-gradient(to left, var(--cnt-fg), var(--cnt-fg) 2px, transparent 2px, transparent 4px, var(--cnt-fg) 4px);border-radius:2px;bottom:0;content:"";display:block;height:6px;right:calc(var(--cnt-hp) + (var(--cnt-usz) + 4px - 6px)/2 - 2px);margin:auto;opacity:.5;position:absolute;top:0;transform:rotate(90deg);transition:transform .2s ease-in-out;width:6px}.tp-rotv.tp-rotv-expanded .tp-rotv_m,.tp-fldv.tp-fldv-expanded>.tp-fldv_b>.tp-fldv_m{transform:none}.tp-rotv_c,.tp-fldv_c{box-sizing:border-box;height:0;opacity:0;overflow:hidden;padding-bottom:0;padding-top:0;position:relative;transition:height .2s ease-in-out,opacity .2s linear,padding .2s ease-in-out}.tp-rotv.tp-rotv-cpl:not(.tp-rotv-expanded) .tp-rotv_c,.tp-fldv.tp-fldv-cpl:not(.tp-fldv-expanded)>.tp-fldv_c{display:none}.tp-rotv.tp-rotv-expanded .tp-rotv_c,.tp-fldv.tp-fldv-expanded>.tp-fldv_c{opacity:1;padding-bottom:var(--cnt-vp);padding-top:var(--cnt-vp);transform:none;overflow:visible;transition:height .2s ease-in-out,opacity .2s linear .2s,padding .2s ease-in-out}.tp-txtv_i,.tp-p2dpv_p,.tp-colswv_sw{background-color:var(--in-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--in-fg);font-family:inherit;height:var(--cnt-usz);line-height:var(--cnt-usz);min-width:0;width:100%}.tp-txtv_i:hover,.tp-p2dpv_p:hover,.tp-colswv_sw:hover{background-color:var(--in-bg-h)}.tp-txtv_i:focus,.tp-p2dpv_p:focus,.tp-colswv_sw:focus{background-color:var(--in-bg-f)}.tp-txtv_i:active,.tp-p2dpv_p:active,.tp-colswv_sw:active{background-color:var(--in-bg-a)}.tp-txtv_i:disabled,.tp-p2dpv_p:disabled,.tp-colswv_sw:disabled{opacity:.5}.tp-lstv,.tp-coltxtv_m{position:relative}.tp-lstv_s{padding:0 20px 0 4px;width:100%}.tp-lstv_m,.tp-coltxtv_mm{bottom:0;margin:auto;pointer-events:none;position:absolute;right:2px;top:0}.tp-lstv_m svg,.tp-coltxtv_mm svg{bottom:0;height:16px;margin:auto;position:absolute;right:0;top:0;width:16px}.tp-lstv_m svg path,.tp-coltxtv_mm svg path{fill:currentColor}.tp-sglv_i,.tp-mllv_i,.tp-grlv_g{background-color:var(--mo-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--mo-fg);height:var(--cnt-usz);scrollbar-color:currentColor rgba(0,0,0,0);scrollbar-width:thin;width:100%}.tp-sglv_i::-webkit-scrollbar,.tp-mllv_i::-webkit-scrollbar,.tp-grlv_g::-webkit-scrollbar{height:8px;width:8px}.tp-sglv_i::-webkit-scrollbar-corner,.tp-mllv_i::-webkit-scrollbar-corner,.tp-grlv_g::-webkit-scrollbar-corner{background-color:rgba(0,0,0,0)}.tp-sglv_i::-webkit-scrollbar-thumb,.tp-mllv_i::-webkit-scrollbar-thumb,.tp-grlv_g::-webkit-scrollbar-thumb{background-clip:padding-box;background-color:currentColor;border:rgba(0,0,0,0) solid 2px;border-radius:4px}.tp-pndtxtv,.tp-coltxtv_w{display:flex}.tp-pndtxtv_a,.tp-coltxtv_c{width:100%}.tp-pndtxtv_a+.tp-pndtxtv_a,.tp-coltxtv_c+.tp-pndtxtv_a,.tp-pndtxtv_a+.tp-coltxtv_c,.tp-coltxtv_c+.tp-coltxtv_c{margin-left:2px}.tp-rotv{--bs-bg: var(--tp-base-background-color, hsl(230, 7%, 17%));--bs-br: var(--tp-base-border-radius, 6px);--bs-ff: var(--tp-base-font-family, Roboto Mono, Source Code Pro, Menlo, Courier, monospace);--bs-sh: var(--tp-base-shadow-color, rgba(0, 0, 0, 0.2));--bld-br: var(--tp-blade-border-radius, 2px);--bld-hp: var(--tp-blade-horizontal-padding, 4px);--bld-vw: var(--tp-blade-value-width, 160px);--btn-bg: var(--tp-button-background-color, hsl(230, 7%, 70%));--btn-bg-a: var(--tp-button-background-color-active, #d6d7db);--btn-bg-f: var(--tp-button-background-color-focus, #c8cad0);--btn-bg-h: var(--tp-button-background-color-hover, #bbbcc4);--btn-fg: var(--tp-button-foreground-color, hsl(230, 7%, 17%));--cnt-bg: var(--tp-container-background-color, rgba(187, 188, 196, 0.1));--cnt-bg-a: var(--tp-container-background-color-active, rgba(187, 188, 196, 0.25));--cnt-bg-f: var(--tp-container-background-color-focus, rgba(187, 188, 196, 0.2));--cnt-bg-h: var(--tp-container-background-color-hover, rgba(187, 188, 196, 0.15));--cnt-fg: var(--tp-container-foreground-color, hsl(230, 7%, 75%));--cnt-hp: var(--tp-container-horizontal-padding, 4px);--cnt-vp: var(--tp-container-vertical-padding, 4px);--cnt-usp: var(--tp-container-unit-spacing, 4px);--cnt-usz: var(--tp-container-unit-size, 20px);--in-bg: var(--tp-input-background-color, rgba(187, 188, 196, 0.1));--in-bg-a: var(--tp-input-background-color-active, rgba(187, 188, 196, 0.25));--in-bg-f: var(--tp-input-background-color-focus, rgba(187, 188, 196, 0.2));--in-bg-h: var(--tp-input-background-color-hover, rgba(187, 188, 196, 0.15));--in-fg: var(--tp-input-foreground-color, hsl(230, 7%, 75%));--lbl-fg: var(--tp-label-foreground-color, rgba(187, 188, 196, 0.7));--mo-bg: var(--tp-monitor-background-color, rgba(0, 0, 0, 0.2));--mo-fg: var(--tp-monitor-foreground-color, rgba(187, 188, 196, 0.7));--grv-fg: var(--tp-groove-foreground-color, rgba(187, 188, 196, 0.1))}.tp-btnv_b{width:100%}.tp-btnv_t{text-align:center}.tp-ckbv_l{display:block;position:relative}.tp-ckbv_i{left:0;opacity:0;position:absolute;top:0}.tp-ckbv_w{background-color:var(--in-bg);border-radius:var(--bld-br);cursor:pointer;display:block;height:var(--cnt-usz);position:relative;width:var(--cnt-usz)}.tp-ckbv_w svg{display:block;height:16px;inset:0;margin:auto;opacity:0;position:absolute;width:16px}.tp-ckbv_w svg path{fill:none;stroke:var(--in-fg);stroke-width:2}.tp-ckbv_i:hover+.tp-ckbv_w{background-color:var(--in-bg-h)}.tp-ckbv_i:focus+.tp-ckbv_w{background-color:var(--in-bg-f)}.tp-ckbv_i:active+.tp-ckbv_w{background-color:var(--in-bg-a)}.tp-ckbv_i:checked+.tp-ckbv_w svg{opacity:1}.tp-ckbv.tp-v-disabled .tp-ckbv_w{opacity:.5}.tp-colv{position:relative}.tp-colv_h{display:flex}.tp-colv_s{flex-grow:0;flex-shrink:0;width:var(--cnt-usz)}.tp-colv_t{flex:1;margin-left:4px}.tp-colv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-colv.tp-colv-expanded.tp-colv-cpl .tp-colv_p{overflow:visible}.tp-colv.tp-colv-expanded .tp-colv_p{margin-top:var(--cnt-usp);opacity:1}.tp-colv .tp-popv{left:calc(-1*var(--cnt-hp));right:calc(-1*var(--cnt-hp));top:var(--cnt-usz)}.tp-colpv_h,.tp-colpv_ap{margin-left:6px;margin-right:6px}.tp-colpv_h{margin-top:var(--cnt-usp)}.tp-colpv_rgb{display:flex;margin-top:var(--cnt-usp);width:100%}.tp-colpv_a{display:flex;margin-top:var(--cnt-vp);padding-top:calc(var(--cnt-vp) + 2px);position:relative}.tp-colpv_a::before{background-color:var(--grv-fg);content:"";height:2px;left:calc(-1*var(--cnt-hp));position:absolute;right:calc(-1*var(--cnt-hp));top:0}.tp-colpv.tp-v-disabled .tp-colpv_a::before{opacity:.5}.tp-colpv_ap{align-items:center;display:flex;flex:3}.tp-colpv_at{flex:1;margin-left:4px}.tp-svpv{border-radius:var(--bld-br);outline:none;overflow:hidden;position:relative}.tp-svpv.tp-v-disabled{opacity:.5}.tp-svpv_c{cursor:crosshair;display:block;height:calc(var(--cnt-usz)*4);width:100%}.tp-svpv_m{border-radius:100%;border:rgba(255,255,255,.75) solid 2px;box-sizing:border-box;filter:drop-shadow(0 0 1px rgba(0, 0, 0, 0.3));height:12px;margin-left:-6px;margin-top:-6px;pointer-events:none;position:absolute;width:12px}.tp-svpv:focus .tp-svpv_m{border-color:#fff}.tp-hplv{cursor:pointer;height:var(--cnt-usz);outline:none;position:relative}.tp-hplv.tp-v-disabled{opacity:.5}.tp-hplv_c{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAABCAYAAABubagXAAAAQ0lEQVQoU2P8z8Dwn0GCgQEDi2OK/RBgYHjBgIpfovFh8j8YBIgzFGQxuqEgPhaDOT5gOhPkdCxOZeBg+IDFZZiGAgCaSSMYtcRHLgAAAABJRU5ErkJggg==);background-position:left top;background-repeat:no-repeat;background-size:100% 100%;border-radius:2px;display:block;height:4px;left:0;margin-top:-2px;position:absolute;top:50%;width:100%}.tp-hplv_m{border-radius:var(--bld-br);border:rgba(255,255,255,.75) solid 2px;box-shadow:0 0 2px rgba(0,0,0,.1);box-sizing:border-box;height:12px;left:50%;margin-left:-6px;margin-top:-6px;pointer-events:none;position:absolute;top:50%;width:12px}.tp-hplv:focus .tp-hplv_m{border-color:#fff}.tp-aplv{cursor:pointer;height:var(--cnt-usz);outline:none;position:relative;width:100%}.tp-aplv.tp-v-disabled{opacity:.5}.tp-aplv_b{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:4px 4px;background-position:0 0,2px 2px;border-radius:2px;display:block;height:4px;left:0;margin-top:-2px;overflow:hidden;position:absolute;top:50%;width:100%}.tp-aplv_c{inset:0;position:absolute}.tp-aplv_m{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:12px 12px;background-position:0 0,6px 6px;border-radius:var(--bld-br);box-shadow:0 0 2px rgba(0,0,0,.1);height:12px;left:50%;margin-left:-6px;margin-top:-6px;overflow:hidden;pointer-events:none;position:absolute;top:50%;width:12px}.tp-aplv_p{border-radius:var(--bld-br);border:rgba(255,255,255,.75) solid 2px;box-sizing:border-box;inset:0;position:absolute}.tp-aplv:focus .tp-aplv_p{border-color:#fff}.tp-colswv{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:10px 10px;background-position:0 0,5px 5px;border-radius:var(--bld-br);overflow:hidden}.tp-colswv.tp-v-disabled{opacity:.5}.tp-colswv_sw{border-radius:0}.tp-colswv_b{cursor:pointer;display:block;height:var(--cnt-usz);left:0;position:absolute;top:0;width:var(--cnt-usz)}.tp-colswv_b:focus::after{border:rgba(255,255,255,.75) solid 2px;border-radius:var(--bld-br);content:"";display:block;inset:0;position:absolute}.tp-coltxtv{display:flex;width:100%}.tp-coltxtv_m{margin-right:4px}.tp-coltxtv_ms{border-radius:var(--bld-br);color:var(--lbl-fg);cursor:pointer;height:var(--cnt-usz);line-height:var(--cnt-usz);padding:0 18px 0 4px}.tp-coltxtv_ms:hover{background-color:var(--in-bg-h)}.tp-coltxtv_ms:focus{background-color:var(--in-bg-f)}.tp-coltxtv_ms:active{background-color:var(--in-bg-a)}.tp-coltxtv_mm{color:var(--lbl-fg)}.tp-coltxtv.tp-v-disabled .tp-coltxtv_mm{opacity:.5}.tp-coltxtv_w{flex:1}.tp-dfwv{position:absolute;top:8px;right:8px;width:256px}.tp-fldv{position:relative}.tp-fldv_t{padding-left:4px}.tp-fldv_b:disabled .tp-fldv_m{display:none}.tp-fldv_c{padding-left:4px}.tp-fldv_i{bottom:0;color:var(--cnt-bg);left:0;overflow:hidden;position:absolute;top:calc(var(--cnt-usz) + 4px);width:max(var(--bs-br),4px)}.tp-fldv_i::before{background-color:currentColor;bottom:0;content:"";left:0;position:absolute;top:0;width:4px}.tp-fldv_b:hover+.tp-fldv_i{color:var(--cnt-bg-h)}.tp-fldv_b:focus+.tp-fldv_i{color:var(--cnt-bg-f)}.tp-fldv_b:active+.tp-fldv_i{color:var(--cnt-bg-a)}.tp-fldv.tp-v-disabled>.tp-fldv_i{opacity:.5}.tp-grlv{position:relative}.tp-grlv_g{display:block;height:calc(var(--cnt-usz)*3)}.tp-grlv_g polyline{fill:none;stroke:var(--mo-fg);stroke-linejoin:round}.tp-grlv_t{margin-top:-4px;transition:left .05s,top .05s;visibility:hidden}.tp-grlv_t.tp-grlv_t-a{visibility:visible}.tp-grlv_t.tp-grlv_t-in{transition:none}.tp-grlv.tp-v-disabled .tp-grlv_g{opacity:.5}.tp-grlv .tp-ttv{background-color:var(--mo-fg)}.tp-grlv .tp-ttv::before{border-top-color:var(--mo-fg)}.tp-lblv{align-items:center;display:flex;line-height:1.3;padding-left:var(--cnt-hp);padding-right:var(--cnt-hp)}.tp-lblv.tp-lblv-nol{display:block}.tp-lblv_l{color:var(--lbl-fg);flex:1;-webkit-hyphens:auto;hyphens:auto;overflow:hidden;padding-left:4px;padding-right:16px}.tp-lblv.tp-v-disabled .tp-lblv_l{opacity:.5}.tp-lblv.tp-lblv-nol .tp-lblv_l{display:none}.tp-lblv_v{align-self:flex-start;flex-grow:0;flex-shrink:0;width:var(--bld-vw)}.tp-lblv.tp-lblv-nol .tp-lblv_v{width:100%}.tp-lstv_s{padding:0 20px 0 var(--bld-hp);width:100%}.tp-lstv_m{color:var(--btn-fg)}.tp-sglv_i{padding-left:var(--bld-hp);padding-right:var(--bld-hp)}.tp-sglv.tp-v-disabled .tp-sglv_i{opacity:.5}.tp-mllv_i{display:block;height:calc(var(--cnt-usz)*3);line-height:var(--cnt-usz);padding-left:var(--bld-hp);padding-right:var(--bld-hp);resize:none;white-space:pre}.tp-mllv.tp-v-disabled .tp-mllv_i{opacity:.5}.tp-p2dv{position:relative}.tp-p2dv_h{display:flex}.tp-p2dv_b{height:var(--cnt-usz);margin-right:4px;position:relative;width:var(--cnt-usz)}.tp-p2dv_b svg{display:block;height:16px;left:50%;margin-left:-8px;margin-top:-8px;position:absolute;top:50%;width:16px}.tp-p2dv_b svg path{stroke:currentColor;stroke-width:2}.tp-p2dv_b svg circle{fill:currentColor}.tp-p2dv_t{flex:1}.tp-p2dv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-p2dv.tp-p2dv-expanded .tp-p2dv_p{margin-top:var(--cnt-usp);opacity:1}.tp-p2dv .tp-popv{left:calc(-1*var(--cnt-hp));right:calc(-1*var(--cnt-hp));top:var(--cnt-usz)}.tp-p2dpv{padding-left:calc(var(--cnt-usz) + 4px)}.tp-p2dpv_p{cursor:crosshair;height:0;overflow:hidden;padding-bottom:100%;position:relative}.tp-p2dpv.tp-v-disabled .tp-p2dpv_p{opacity:.5}.tp-p2dpv_g{display:block;height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%}.tp-p2dpv_ax{opacity:.1;stroke:var(--in-fg);stroke-dasharray:1}.tp-p2dpv_l{opacity:.5;stroke:var(--in-fg);stroke-dasharray:1}.tp-p2dpv_m{border:var(--in-fg) solid 1px;border-radius:50%;box-sizing:border-box;height:4px;margin-left:-2px;margin-top:-2px;position:absolute;width:4px}.tp-p2dpv_p:focus .tp-p2dpv_m{background-color:var(--in-fg);border-width:0}.tp-popv{background-color:var(--bs-bg);border-radius:var(--bs-br);box-shadow:0 2px 4px var(--bs-sh);display:none;max-width:var(--bld-vw);padding:var(--cnt-vp) var(--cnt-hp);position:absolute;visibility:hidden;z-index:1000}.tp-popv.tp-popv-v{display:block;visibility:visible}.tp-sldv.tp-v-disabled{opacity:.5}.tp-sldv_t{box-sizing:border-box;cursor:pointer;height:var(--cnt-usz);margin:0 6px;outline:none;position:relative}.tp-sldv_t::before{background-color:var(--in-bg);border-radius:1px;content:"";display:block;height:2px;inset:0;margin:auto;position:absolute}.tp-sldv_k{height:100%;left:0;position:absolute;top:0}.tp-sldv_k::before{background-color:var(--in-fg);border-radius:1px;content:"";display:block;height:2px;inset:0;margin-bottom:auto;margin-top:auto;position:absolute}.tp-sldv_k::after{background-color:var(--btn-bg);border-radius:var(--bld-br);bottom:0;content:"";display:block;height:12px;margin-bottom:auto;margin-top:auto;position:absolute;right:-6px;top:0;width:12px}.tp-sldv_t:hover .tp-sldv_k::after{background-color:var(--btn-bg-h)}.tp-sldv_t:focus .tp-sldv_k::after{background-color:var(--btn-bg-f)}.tp-sldv_t:active .tp-sldv_k::after{background-color:var(--btn-bg-a)}.tp-sldtxtv{display:flex}.tp-sldtxtv_s{flex:2}.tp-sldtxtv_t{flex:1;margin-left:4px}.tp-tabv{position:relative}.tp-tabv_t{align-items:flex-end;color:var(--cnt-bg);display:flex;overflow:hidden;position:relative}.tp-tabv_t:hover{color:var(--cnt-bg-h)}.tp-tabv_t:has(*:focus){color:var(--cnt-bg-f)}.tp-tabv_t:has(*:active){color:var(--cnt-bg-a)}.tp-tabv_t::before{background-color:currentColor;bottom:0;content:"";height:2px;left:0;pointer-events:none;position:absolute;right:0}.tp-tabv.tp-v-disabled .tp-tabv_t::before{opacity:.5}.tp-tabv.tp-tabv-nop .tp-tabv_t{height:calc(var(--cnt-usz) + 4px);position:relative}.tp-tabv.tp-tabv-nop .tp-tabv_t::before{background-color:var(--cnt-bg);bottom:0;content:"";height:2px;left:0;position:absolute;right:0}.tp-tabv_i{bottom:0;color:var(--cnt-bg);left:0;overflow:hidden;position:absolute;top:calc(var(--cnt-usz) + 4px);width:max(var(--bs-br),4px)}.tp-tabv_i::before{background-color:currentColor;bottom:0;content:"";left:0;position:absolute;top:0;width:4px}.tp-tabv_t:hover+.tp-tabv_i{color:var(--cnt-bg-h)}.tp-tabv_t:has(*:focus)+.tp-tabv_i{color:var(--cnt-bg-f)}.tp-tabv_t:has(*:active)+.tp-tabv_i{color:var(--cnt-bg-a)}.tp-tabv.tp-v-disabled>.tp-tabv_i{opacity:.5}.tp-tbiv{flex:1;min-width:0;position:relative}.tp-tbiv+.tp-tbiv{margin-left:2px}.tp-tbiv+.tp-tbiv.tp-v-disabled::before{opacity:.5}.tp-tbiv_b{display:block;padding-left:calc(var(--cnt-hp) + 4px);padding-right:calc(var(--cnt-hp) + 4px);position:relative;width:100%}.tp-tbiv_b:disabled{opacity:.5}.tp-tbiv_b::before{background-color:var(--cnt-bg);content:"";inset:0 0 2px;pointer-events:none;position:absolute}.tp-tbiv_b:hover::before{background-color:var(--cnt-bg-h)}.tp-tbiv_b:focus::before{background-color:var(--cnt-bg-f)}.tp-tbiv_b:active::before{background-color:var(--cnt-bg-a)}.tp-tbiv_t{color:var(--cnt-fg);height:calc(var(--cnt-usz) + 4px);line-height:calc(var(--cnt-usz) + 4px);opacity:.5;overflow:hidden;position:relative;text-overflow:ellipsis}.tp-tbiv.tp-tbiv-sel .tp-tbiv_t{opacity:1}.tp-tbpv_c{padding-bottom:var(--cnt-vp);padding-left:4px;padding-top:var(--cnt-vp)}.tp-txtv{position:relative}.tp-txtv_i{padding-left:var(--bld-hp);padding-right:var(--bld-hp)}.tp-txtv.tp-txtv-fst .tp-txtv_i{border-bottom-right-radius:0;border-top-right-radius:0}.tp-txtv.tp-txtv-mid .tp-txtv_i{border-radius:0}.tp-txtv.tp-txtv-lst .tp-txtv_i{border-bottom-left-radius:0;border-top-left-radius:0}.tp-txtv.tp-txtv-num .tp-txtv_i{text-align:right}.tp-txtv.tp-txtv-drg .tp-txtv_i{opacity:.3}.tp-txtv_k{cursor:pointer;height:100%;left:calc(var(--bld-hp) - 5px);position:absolute;top:0;width:12px}.tp-txtv_k::before{background-color:var(--in-fg);border-radius:1px;bottom:0;content:"";height:calc(var(--cnt-usz) - 4px);left:50%;margin-bottom:auto;margin-left:-1px;margin-top:auto;opacity:.1;position:absolute;top:0;transition:border-radius .1s,height .1s,transform .1s,width .1s;width:2px}.tp-txtv_k:hover::before,.tp-txtv.tp-txtv-drg .tp-txtv_k::before{opacity:1}.tp-txtv.tp-txtv-drg .tp-txtv_k::before{border-radius:50%;height:4px;transform:translateX(-1px);width:4px}.tp-txtv_g{bottom:0;display:block;height:8px;left:50%;margin:auto;overflow:visible;pointer-events:none;position:absolute;top:0;visibility:hidden;width:100%}.tp-txtv.tp-txtv-drg .tp-txtv_g{visibility:visible}.tp-txtv_gb{fill:none;stroke:var(--in-fg);stroke-dasharray:1}.tp-txtv_gh{fill:none;stroke:var(--in-fg)}.tp-txtv .tp-ttv{margin-left:6px;visibility:hidden}.tp-txtv.tp-txtv-drg .tp-ttv{visibility:visible}.tp-ttv{background-color:var(--in-fg);border-radius:var(--bld-br);color:var(--bs-bg);padding:2px 4px;pointer-events:none;position:absolute;transform:translate(-50%, -100%)}.tp-ttv::before{border-color:var(--in-fg) rgba(0,0,0,0) rgba(0,0,0,0) rgba(0,0,0,0);border-style:solid;border-width:2px;box-sizing:border-box;content:"";font-size:.9em;height:4px;left:50%;margin-left:-2px;position:absolute;top:100%;width:4px}.tp-rotv{background-color:var(--bs-bg);border-radius:var(--bs-br);box-shadow:0 2px 4px var(--bs-sh);font-family:var(--bs-ff);font-size:11px;font-weight:500;line-height:1;text-align:left}.tp-rotv_b{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br);border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br);padding-left:calc(4px + var(--cnt-usz) + var(--cnt-hp));text-align:center}.tp-rotv.tp-rotv-expanded .tp-rotv_b{border-bottom-left-radius:0;border-bottom-right-radius:0;transition-delay:0s;transition-duration:0s}.tp-rotv.tp-rotv-not>.tp-rotv_b{display:none}.tp-rotv_b:disabled .tp-rotv_m{display:none}.tp-rotv_c>.tp-fldv.tp-v-lst>.tp-fldv_c{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst>.tp-fldv_i{border-bottom-left-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst:not(.tp-fldv-expanded)>.tp-fldv_b{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst.tp-fldv-expanded>.tp-fldv_b{transition-delay:0s;transition-duration:0s}.tp-rotv_c .tp-fldv.tp-v-vlst:not(.tp-fldv-expanded)>.tp-fldv_b{border-bottom-right-radius:var(--bs-br)}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-fldv.tp-v-fst{margin-top:calc(-1*var(--cnt-vp))}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-fldv.tp-v-fst>.tp-fldv_b{border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br)}.tp-rotv_c>.tp-tabv.tp-v-lst>.tp-tabv_c{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-tabv.tp-v-lst>.tp-tabv_i{border-bottom-left-radius:var(--bs-br)}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-tabv.tp-v-fst{margin-top:calc(-1*var(--cnt-vp))}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-tabv.tp-v-fst>.tp-tabv_t{border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br)}.tp-rotv.tp-v-disabled,.tp-rotv .tp-v-disabled{pointer-events:none}.tp-rotv.tp-v-hidden,.tp-rotv .tp-v-hidden{display:none}.tp-sprv_r{background-color:var(--grv-fg);border-width:0;display:block;height:2px;margin:0;width:100%}.tp-sprv.tp-v-disabled .tp-sprv_r{opacity:.5}',plugins:[_l,Pl,El,ci,kl]})}}new oi("4.0.4");const kt=class kt{constructor(t){w(this,"pane");w(this,"sceneControls",{});this.game=t;const e=document.getElementById("settings");if(!e)throw new Error("No settings container found");this.pane=new Tl({title:"settings",expanded:!1,container:e}),t.events.on("scene-change",r=>{Object.values(this.sceneControls).filter(Boolean).forEach(s=>{s.dispose(),this.pane.remove(s)}),r&&(this.sceneControls.deleteLoop=this.pane.addButton({title:"Delete current loop",index:0}).on("click",()=>_.deleteCurrentTrack()),this.sceneControls.deleteInstrument=this.pane.addButton({title:"Delete instrument & loop",index:0}).on("click",()=>_.deleteCurrentInstrumentScene()),this.sceneControls.volume=this.pane.addBinding(r,"volume",{min:0,max:100,step:1,index:0}))}),window.onerror=function(r,s,o,a,l){j.error(` -`+r+" "+s+" "+o+" "+a+" "+l)},this.pane.addButton({title:"Show logs"}).on("click",()=>{i.hidden=!i.hidden});const i=this.pane.addBinding(kt.logsParams,"logs",{label:"",readonly:!0,multiline:!0,rows:10,hidden:!0});this.resize()}static log(t){kt.logsParams.logs+=` -`+t}resize(){const t=Math.min(this.game.canvas.width,this.game.canvas.height),e=t/40+"px",i=t/10+"px";document.querySelectorAll("button").forEach(r=>{r.style.fontSize=e,r.style.height=i})}};w(kt,"logsParams",{logs:""});let ne=kt;const ge=(n,t)=>{ne.log(t.map(e=>e.toString()).join(", ")),console[n](...t)},j={log:(n,...t)=>{ge("log",[n,...t])},error:(n,...t)=>{ge("error",[n,...t])},warn:(n,...t)=>{ge("warn",[n,...t])}},Rn={hihat:er,kick:nr,snare:ir,crash:rr,"hihat-open":sr,ride:or,"tom-low":Nn,"tom-high":ar},Ll=(n,t)=>{try{Rn[n](t)}catch(e){j.error(`Error playing ${n}`,e),tr(),Rn[n](t)}},nn=(n,t,e)=>{const i=[];for(let s=0;si.map(a=>a[o]).reverse()).flat()},Al={hihat:"#FDA341",kick:"#F24E1E",snare:"#4A90E2",crash:"#A0D8C5","hihat-open":"#F9F871",ride:"#F5C542","tom-low":"#FF7F50","tom-high":"#9B59B6"};class On extends P.Scene{constructor(e="drums"){super();w(this,"settings",{volume:100});this.type=e}create({type:e}){e&&(this.type=e),this.createPads(),this.scene.get(_.key).events.emit("track-selected"),this.game.events.emit("scene-change",this.settings)}createPads(){const e=[this.createPad("crash"),this.createPad("ride"),this.createPad("hihat-open"),this.createPad("hihat"),this.createPad("snare"),this.createPad("tom-low"),this.createPad("tom-high"),this.createPad("kick")],i=()=>{const r=window.innerWidth{const h=d%s*a,S=Math.floor(d/s)*l,y=r?0:_.sceneWidthHeight,T=r?_.sceneWidthHeight:0;p.setSize(a,l).setPosition(y+h,T+S)})};window.addEventListener("resize",i),i()}createPad(e){const i=Al[e],r=N(i,this.type==="drums"),s=P.Display.Color.HexStringToColor(i).brighten(4).color,o=this.add.rectangle().setFillStyle(r).setStrokeStyle(2,N("#FFF"),.8).setInteractive().setOrigin(0,0);return o.on("pointerdown",a=>{var c,p;if(((p=(c=a.downElement)==null?void 0:c.tagName)==null?void 0:p.toLowerCase())!=="canvas")return;o.setFillStyle(s);const l=()=>Ll(e,this.settings.volume);l(),this.scene.get(_.key).events.emit("instrument-played",{callback:l,scene:this})}).on("pointerup",()=>o.setFillStyle(r)).on("pointerout",()=>o.setFillStyle(r)),{instrument:e,button:o}}}let Et=null,we=null;const Mn=()=>{Et&&(j.log("stopping note...",Et),Et.stop(),we.stop()),j.log("testing note...");const n=22050,t=Freeverb({input:Bus2(),roomSize:.975,damping:.5}).connect(),e=Synth({gain:.15,attack:44,decay:5512,Q:.8,filterType:2,saturation:2,filterMult:3.25,antialias:!0,cutoff:Add(1,Sine({frequency:.1,gain:.75}))}).connect(Gibberish.output).connect(t.input,.5),i=[55,110,165,220];we=Sequencer.make([55,110,165,220],[n/4],e,"note").start(),Et=Sequencer.make([i.map(r=>r*1.25),i.map(r=>r*1.25*.8),i.map(r=>r*1.25*.8*.8),i.map(r=>r*1.25*.8*.8*1.25)],[n*16],we,"values"),Et.start()};class Rl extends P.Scene{constructor(){super();w(this,"isGibberishLoaded",!1)}create({numberOfPads:e=8}){this.createPads(e),this.scene.get(_.key).events.emit("track-selected")}createPads(e){const i=new Array(e).fill(0).map((s,o)=>this.createPad(o)),r=()=>{const s=window.innerWidth{const S=h%o*l,y=Math.floor(h/o)*c,T=s?0:_.sceneWidthHeight,pt=s?_.sceneWidthHeight:0;d.setSize(l,c).setPosition(T+S,pt+y)})};window.addEventListener("resize",r),r()}createPad(e){const i=P.Display.Color.HSLToColor(e/16,1,.5),r=i.darken(40).color,s=i.brighten(4).color,o=this.add.rectangle().setFillStyle(r).setStrokeStyle(2,N("#FFF"),.8).setInteractive().setOrigin(0,0);return o.on("pointerdown",a=>{var l,c;((c=(l=a.downElement)==null?void 0:l.tagName)==null?void 0:c.toLowerCase())==="canvas"&&(this.isGibberishLoaded?Mn():(this.isGibberishLoaded=!0,Gibberish.workletPath="./worklet.js",j.log("loading Gibberish 2..."),Gibberish.init().then(()=>{j.log("Gibberish is ready!"),Gibberish.export(window),Mn()}).catch(p=>j.error("oops",p))),o.setFillStyle(s))}).on("pointerup",()=>o.setFillStyle(r)).on("pointerout",()=>o.setFillStyle(r)),{instrument:e,button:o}}}class Ol extends P.Scene{constructor(e,i){super();w(this,"pads",[]);w(this,"settings",{volume:75});this.cols=e,this.rows=i}create(){this.createPads(),this.scene.get(_.key).events.emit("track-selected"),this.game.events.emit("scene-change",this.settings)}createPads(){const e=this.cols*this.rows;this.pads=new Array(e).fill(0).map((r,s)=>this.createPad(s,e));const i=()=>{const r=window.innerWidth{const S=h%s*a,y=Math.floor(h/s)*l,T=r?0:_.sceneWidthHeight,pt=r?_.sceneWidthHeight:0;p.setSize(a,l).setPosition(T+S,pt+y),d&&d.setPosition(p.getCenter().x,p.getCenter().y).setFontSize(Xt.tiny).setResolution(2)})};window.addEventListener("resize",i),i()}createPad(e,i){var S;const r=this.getPadColor(i,e),s=(S=this.getPadText)==null?void 0:S.call(this,e),o=r.darken(60).color,a=r.brighten(40).color,l=this.add.rectangle().setFillStyle(o).setStrokeStyle(2,N("#FFF"),.8).setInteractive().setOrigin(0,0);let c;s&&(c=this.add.text(0,0,s,{fontFamily:St.Text,fontSize:Xt.tiny,color:xe.white}).setAlpha(.5).setOrigin(.5,.5).setResolution(2).setPosition(l.getCenter().x,l.getCenter().y).setDepth(1));let p=!1;const d=()=>{p||(this.playSound(e),l.setFillStyle(a),this.scene.get(_.key).events.emit("instrument-played",{callback:()=>this.playSound(e),scene:this}),p=!0)},h=()=>{l.setFillStyle(o),p=!1};return l.on("pointerdown",y=>{var T,pt;((pt=(T=y.downElement)==null?void 0:T.tagName)==null?void 0:pt.toLowerCase())==="canvas"&&d()}).on("pointermove",y=>{y.isDown&&d()}).on("pointerup",()=>h()).on("pointerout",()=>h()),{instrument:e,button:l,text:c}}getPadColor(e,i){return P.Display.Color.HSLToColor((e-i)/(e*1.5),1,.5)}}function Ml(){const n=[];for(let t=0;t<9;t++)n[t]={};return n[2].C=65.40639132514966,n[2]["C#"]=69.29565774421802,n[2].D=73.4161919793519,n[2]["D#"]=77.78174593052023,n[2].E=82.40688922821748,n[2].F=87.30705785825097,n[2]["F#"]=92.4986056779086,n[2].G=97.99885899543732,n[2]["G#"]=103.82617439498628,n[2].A=110,n[2]["A#"]=116.54094037952248,n[2].B=123.47082531403103,n[3].C=130.8127826502993,n[3]["C#"]=138.59131548843604,n[3].D=146.8323839587038,n[3]["D#"]=155.56349186104046,n[3].E=164.81377845643496,n[3].F=174.61411571650194,n[3]["F#"]=184.9972113558172,n[3].G=195.99771799087463,n[3]["G#"]=207.65234878997256,n[3].A=220,n[3]["A#"]=233.08188075904496,n[3].B=246.94165062806206,n[4].C=261.6255653005986,n[4]["C#"]=277.1826309768721,n[4].D=293.6647679174076,n[4]["D#"]=311.1269837220809,n[4].E=329.6275569128699,n[4].F=349.2282314330039,n[4]["F#"]=369.9944227116344,n[4].G=391.99543598174927,n[4]["G#"]=415.3046975799451,n[4].A=440,n[4]["A#"]=466.1637615180899,n[4].B=493.8833012561241,n[5].C=523.2511306011972,n[5]["C#"]=554.3652619537442,n[5].D=587.3295358348151,n[5]["D#"]=622.2539674441618,n[5].E=659.2551138257398,n[5].F=698.4564628660078,n[5]["F#"]=739.9888454232688,n[5].G=783.9908719634985,n[5]["G#"]=830.6093951598903,n[5].A=880,n[5]["A#"]=932.3275230361799,n[5].B=987.7666025122483,n[6].C=1046.5022612023945,n[6]["C#"]=1108.7305239074883,n[6].D=1174.6590716696303,n[6]["D#"]=1244.5079348883237,n[6].E=1318.5102276514797,n[6].F=1396.9129257320155,n[6]["F#"]=1479.9776908465376,n[6].G=1567.981743926997,n[6]["G#"]=1661.2187903197805,n[6].A=1760,n[6]["A#"]=1864.6550460723597,n[6].B=1975.5332050244965,n[7].C=2093.004522404789,n[7]["C#"]=2217.4610478149766,n[7].D=2349.3181433392606,n[7]["D#"]=2489.0158697766474,n[7].E=2637.0204553029594,n[7].F=2793.825851464031,n[7]["F#"]=2959.955381693075,n[7].G=3135.963487853994,n[7]["G#"]=3322.437580639561,n[7].A=3520,n[7]["A#"]=3729.3100921447194,n[7].B=3951.066410048993,n}const Dl=Ml(),_e=Dl.flatMap(n=>Object.entries(n)).map(([n,t])=>({key:n,freq:t})).filter(({freq:n})=>!!n).sort((n,t)=>n.freq-t.freq);class Fl extends Ol{constructor(){super(6,12)}create(){super.create()}getPadText(t){const e=_e[t];return e==null?void 0:e.key}getPadColor(t,e){var s;const i=super.getPadColor(t,e),r=(s=_e[e])==null?void 0:s.key;return r!=null&&r.includes("#")?i.darken(15):i}playSound(t){const e=_e[t].freq;return j.log("Playing note",e),Bl(e,this.settings.volume)}}const Bl=(n,t)=>{const e=nt(),i=e.createOscillator();i.type="sine";const r=e.createGain();i.frequency.setValueAtTime(n,e.currentTime),i.connect(r),r.connect(e.destination);const s=.02,o=1.5;r.gain.setValueAtTime(0,e.currentTime),r.gain.linearRampToValueAtTime(t/100,e.currentTime+s),r.gain.exponentialRampToValueAtTime(1e-4,e.currentTime+o),i.start(e.currentTime),i.stop(e.currentTime+o)},re=class re extends P.Scene{constructor(){super(re.key);w(this,"rowNumber",5);w(this,"colNumber",5);w(this,"instrumentButtons")}create({index:e}){this.scene.bringToTop(),this.game.events.emit("scene-change"),this.cameras.main.setOrigin(0,0).setBackgroundColor("#147"),this.createMatrix();const i=this.instrumentButtons[2][1];i.setData("text",this.addText(i,"Simple Synth"));const r=this.instrumentButtons[1][2];r.setData("text",this.addText(r,"Drums"));const s=this.instrumentButtons[3][2];s.setData("text",this.addText(s,"Other Drums"));const o=this.instrumentButtons[2][3];o.setData("text",this.addText(o,"Gibberish")),[r,s,o,i].forEach(c=>c.setFillStyle(N("#FFF"),.5).setInteractive().on(P.Input.Events.POINTER_DOWN,()=>{this.scene.setVisible(!1)}));const l=_.getTrackSceneKey(e);r.on(P.Input.Events.POINTER_UP,()=>{this.scene.add(l,On,!0,{type:"drums"})}),s.on(P.Input.Events.POINTER_UP,()=>{this.scene.add(l,On,!0,{type:"other"})}),o.on(P.Input.Events.POINTER_UP,()=>{this.scene.add(l,Rl,!0,{numberOfPads:8})}),i.on(P.Input.Events.POINTER_UP,()=>{this.scene.add(l,Fl,!0)}),window.addEventListener("resize",()=>this.resizeScene()),this.resizeScene()}createMatrix(){this.instrumentButtons=[];for(let e=0;e{p.forEach((h,S)=>{h.setSize(r,s).setPosition(r*d,s*S);const y=h.getData("text");if(y){const T=Math.min(h.height,h.width)/5;y.setFontSize(T).setResolution(2).setWordWrapWidth(h.width,!0).setSize(h.width,h.height).setPosition(h.getCenter().x,h.getCenter().y)}})});const o=e?window.innerWidth:window.innerWidth-i,a=e?window.innerHeight-i:window.innerHeight,l=e?0:i,c=e?i:0;this.cameras.main.setPosition(l,c).setViewport(l,c,o,a)}};w(re,"key","EmptyScene");let Dt=re;const I=class I{constructor(t){w(this,"state","readyToRecord");w(this,"events",[]);w(this,"eventEmitter",new P.Events.EventEmitter);w(this,"startRecordingTime");w(this,"startPlayingTime",0);w(this,"currentLoopIndex",0);w(this,"loopTimeout",null);this.trackIndex=t,this.log("Loop created")}getStartPlayingTime(){return this.startPlayingTime}getLoopLength(){var t;return(t=this.events.find(({callback:e})=>e==="endOfLoop"))==null?void 0:t.time}handleClick(){switch(this.nextState(),this.state){case"recording":this.startRecording();break;case"playing":this.startPlaying();break;case"readyToPlay":this.stopPlaying();break}}addLoopEvent(t){if(this.isRecording()){this.startRecordingTime||(this.startRecordingTime=I.masterLoop.getStartPlayingTime());const e=Date.now()-this.startRecordingTime;this.events.push({callback:t,time:e}),this.log(`Recording ${t} at time ${e}ms`)}}isPlaying(){return this.state==="playing"}isReadyToPlay(){return this.state==="readyToPlay"}isRecording(){return this.state==="recording"}isReadyToRecord(){return this.state==="readyToRecord"}destroy(){this.eventEmitter.removeAllListeners(),this.isPlaying()&&this.stopPlaying(),this.events=[],this.isMasterLoop()&&(I.masterLoop=null),this.log("Loop destroyed")}addEventListener(t,e){this.eventEmitter.once(t,e)}nextState(){switch(this.state){case"readyToRecord":this.state="recording";break;case"recording":this.state=this.stopRecording();break;case"readyToPlay":this.state="playing";break;case"playing":this.state="readyToPlay";break}}startRecording(){this.events=[],this.log("Recording started"),I.masterLoop||(I.masterLoop=this,this.startRecordingTime=Date.now())}stopRecording(){var e;if(this.events.length===0)return this.log("No events recorded"),"readyToRecord";if(!this.startRecordingTime)throw new Error("startRecordingTime is not set");const t=Date.now()-this.startRecordingTime;if(this.isMasterLoop()){this.events.push({callback:"endOfLoop",time:t});const i=this.events[0].time;this.events=this.events.map(({time:r,callback:s})=>({time:r-i,callback:s}))}else{j.log("events: "+this.events.length,this.events);const i=(e=I.masterLoop)==null?void 0:e.getLoopLength();if(!i)throw new Error("masterLoopLength is not set");const s=Math.floor(t/i)*i;this.events=this.events.filter(({time:o})=>o<=s),this.events.push({callback:"endOfLoop",time:s})}return this.log(`Recording stopped at ${t} with ${this.events.length} events, start playing`),"playing"}startPlaying(){var e;const t=()=>{this.currentLoopIndex>=this.events.length&&(this.currentLoopIndex=0),this.currentLoopIndex===0&&(this.log("Loop play (re)-started","#0F0"),this.startPlayingTime=Date.now());const{callback:i,time:r}=this.events[this.currentLoopIndex],s=this.currentLoopIndex===0?0:this.events[this.currentLoopIndex-1].time;this.loopTimeout=setTimeout(()=>{this.log(`Playing event ${i} after ${r}ms`),i!=="endOfLoop"?i():this.eventEmitter.emit("endOfLoop"),this.currentLoopIndex++,t()},r-s)};this.log("Loop play starting"),!this.isMasterLoop()&&((e=I.masterLoop)!=null&&e.isPlaying())?I.masterLoop.addEventListener("endOfLoop",()=>{t()}):t()}stopPlaying(){this.loopTimeout&&clearTimeout(this.loopTimeout),this.currentLoopIndex=0,this.log("Loop stopped")}isMasterLoop(){return this===I.masterLoop}log(t,e){const i=`Loop ${this.trackIndex+1}: ${t}`;e?j.log(`%c${i}`,`color: ${e}`):j.log(i)}};w(I,"masterLoop",null);let ie=I;const Il={selected:"#DDD",unselected:"#000"},Dn={play:"play_arrow",record:"fiber_manual_record",stop:"stop"},ht={idle:"#FFF",readyToRecord:"#0FF",recording:"#FD0041",playing:"#0F0"},f=class f extends P.Scene{constructor(){super(f.key);w(this,"resizeTracks",()=>{const e=window.innerWidth{const p=e?i*c:0,d=e?-1:r*c;s.setSize(i,r).setPosition(p,d);const h=e?s.getCenter().x:s.getCenter().x-i/4,S=e?s.getCenter().y-r/4:s.getCenter().y,y=Math.min(r,i);o.setResolution(3).setSize(i,r).setFontSize(y/4).setPosition(h,S),a.setSize(y/3,y/3).setPosition(h,S),l.setOrigin(e?.5:1,e?1:.5).setPosition(e?s.getCenter().x:s.getRightCenter().x,e?s.getBottomCenter().y:s.getCenter().y)}),this.cameras.main.setViewport(0,0,e?window.innerWidth:i,e?r:window.innerHeight)});f.instance=this}static get sceneWidthHeight(){const e=window.innerWidth,i=window.innerHeight;return Math.max(i,e)/10}static deleteCurrentTrack(){const e=f.tracks.find(i=>i.selected);if(e){const i=f.tracks.indexOf(e);return e.loop.destroy(),e.loopProgressArc.clear(),e.loop=new ie(i),this.instance.updateControlsState(),i}throw new Error("No track selected")}static deleteCurrentInstrumentScene(){const e=f.deleteCurrentTrack(),i=f.getTrackSceneKey(e);this.instance.game.scene.remove(i),this.instance.game.scene.start(Dt.key,{index:e}),this.instance.updateControlsState()}static getTrackSceneKey(e){return`track_scene_${e}`}create(){this.cameras.main.setOrigin(0,0).setPosition(0,0).setViewport(0,0,f.sceneWidthHeight,window.innerHeight).setBackgroundColor("#963"),this.createTracks(),this.events.on("track-selected",()=>{this.updateControlsState()}),this.events.on("instrument-played",({callback:e})=>{var i,r;(r=(i=f.tracks.find(s=>s.selected))==null?void 0:i.loop)==null||r.addLoopEvent(e)})}update(){for(const e of f.tracks)e.loop.isPlaying()&&this.updateProgressArc(e)}getTrackScene(e){return this.scene.get(f.getTrackSceneKey(e))}updateProgressArc(e){const i=e.loop.getLoopLength();if(!i)throw new Error("Loop length is not defined");const s=(Date.now()-e.loop.getStartPlayingTime())/i;e.loopProgressArc.clear(),e.loopProgressArc.lineStyle(4,65280,1);const o=P.Math.DegToRad(-90),a=o+P.Math.DegToRad(360*s);e.loopProgressArc.beginPath(),e.loopProgressArc.arc(e.buttonText.x,e.buttonText.y,e.buttonSelectedCircle.width/2,o,a,!1),e.loopProgressArc.strokePath()}createTracks(){f.tracks=new Array(f.numTracks).fill(null).map((e,i)=>({loop:new ie(i),button:this.add.rectangle().setOrigin(0,0).setStrokeStyle(2,N("#FFF"),.8).setInteractive().on(P.Input.Events.POINTER_DOWN,()=>this.selectTrack(i)),selected:!1,buttonSelectedCircle:this.add.ellipse(0,0,0,0,N("#FFF")),buttonText:this.add.text(0,0,`${i+1}`,{fontFamily:St.Text,fontSize:Xt.medium,color:xe.white}).setOrigin(.5,.5).setResolution(2),controlIcon:this.add.text(0,0,"",{fontFamily:St.Icons,fontSize:Xt.medium,color:xe.white}).setOrigin(.5,.5).setResolution(2).setInteractive().on(P.Input.Events.POINTER_DOWN,()=>{this.handleControlClicked(i)}),loopProgressArc:this.add.graphics()})),window.addEventListener("resize",()=>this.resizeTracks()),this.resizeTracks(),this.selectTrack(0)}handleControlClicked(e){f.tracks[e].loop.handleClick(),this.updateControlsState()}selectTrack(e){const i=f.tracks[e];if(i.selected)i.loop.handleClick(),this.updateControlsState();else{const r=f.tracks.find(o=>o.selected);r&&(r.selected=!1,r.loop.isRecording()&&r.loop.handleClick()),i.selected=!0,this.updateControlsState();const s=this.getTrackScene(e);if(s){s.scene.bringToTop();const o=s.settings;this.game.events.emit("scene-change",o)}else this.game.scene.start(Dt.key,{index:e})}}updateControlsState(){f.tracks.forEach((e,i)=>{e.button.setFillStyle(N(Il.unselected)),e.buttonText.setColor(e.selected?"#000":"#FFF"),e.buttonSelectedCircle.setVisible(!0).setFillStyle(N(e.selected?"#FFF":"#000")),this.getTrackScene(i)?e.selected&&(e.loop.isRecording()||e.loop.isReadyToRecord())?e.controlIcon.setText(Dn.record).setColor(e.loop.isRecording()?ht.recording:ht.idle):e.loop.isPlaying()||e.loop.isReadyToPlay()?e.controlIcon.setText(Dn.play).setColor(e.loop.isPlaying()?ht.playing:ht.idle):e.controlIcon.setText("").setColor(ht.idle):e.controlIcon.setText("").setColor(ht.idle)})}};w(f,"key","LoopTracksScene"),w(f,"numTracks",5),w(f,"tracks"),w(f,"instance");let _=f;const jl=()=>window.matchMedia("(prefers-color-scheme: dark)").matches;function Fn(n){const t=window.innerWidth,e=window.innerHeight;n.scale.resize(t,e),n.scene.scenes.forEach(i=>{var r,s;return(s=(r=i.sys)==null?void 0:r.scale)==null?void 0:s.refresh()})}let Bn=!1;const Nl=()=>(Bn||(Bn=!0,Ji().then(()=>{const n=new P.Game({type:P.AUTO,mode:P.Scale.RESIZE,parent:"phaser-container",width:window.innerWidth,height:window.innerHeight,backgroundColor:jl()?"#333":"#DDD",scene:[_,Dt],input:{activePointers:8}}),t=new ne(n);window.addEventListener("resize",()=>{Fn(n),t.resize()}),n.scene.start(_.key),Fn(n)})),Vt.jsx(Vt.Fragment,{}));function zl(){return Vt.jsx(Nl,{})}Ce.createRoot(document.getElementById("root")).render(Vt.jsx(Ui.StrictMode,{children:Vt.jsx(zl,{})})); + */var Yi=Ui,Xi=Symbol.for("react.element"),Qi=Symbol.for("react.fragment"),Zi=Object.prototype.hasOwnProperty,Ji=Yi.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,tr={key:!0,ref:!0,__self:!0,__source:!0};function jn(n,t,e){var i,r={},s=null,o=null;e!==void 0&&(s=""+e),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(o=t.ref);for(i in t)Zi.call(t,i)&&!tr.hasOwnProperty(i)&&(r[i]=t[i]);if(n&&n.defaultProps)for(i in t=n.defaultProps,t)r[i]===void 0&&(r[i]=t[i]);return{$$typeof:Xi,type:n,key:s,ref:o,props:r,_owner:Ji.current}}oe.Fragment=Qi;oe.jsx=jn;oe.jsxs=jn;In.exports=oe;var Tt=In.exports,xe={},rn=Gi;xe.createRoot=rn.createRoot,xe.hydrateRoot=rn.hydrateRoot;const St={Icons:"Icons",Text:"Courier"},Qt={tiny:"15px",small:"30px",medium:"50px",big:"90px"},ye={white:"#FFF"},er=async()=>{const n=new FontFace(St.Icons,"url(./fonts/material.woff2)");return document.fonts.add(n),n.load().catch(t=>console.error(t))},K=(n,t=!1)=>y.Display.Color.HexStringToColor(n).darken(t?75:0).color;let Wt=null;const it=()=>{if(!Wt){const n=window.AudioContext||window.webkitAudioContext;Wt=new n}return Wt},nr=()=>{Wt=null};function ir(n=100){const t=it(),e=t.sampleRate*.05,i=t.createBuffer(1,e,t.sampleRate),r=i.getChannelData(0);for(let p=0;p{const s=n[r],o=t[r];return Pe(s)&&Pe(o)?Object.assign(Object.assign({},i),{[r]:ot(s,o)}):Object.assign(Object.assign({},i),{[r]:r in t?o:s})},{})}function Re(n){return Ae(n)?"target"in n:!1}const ur={alreadydisposed:()=>"View has been already disposed",invalidparams:n=>`Invalid parameters for '${n.name}'`,nomatchingcontroller:n=>`No matching controller for '${n.key}'`,nomatchingview:n=>`No matching view for '${JSON.stringify(n.params)}'`,notbindable:()=>"Value is not bindable",notcompatible:n=>`Not compatible with plugin '${n.id}'`,propertynotfound:n=>`Property '${n.name}' not found`,shouldneverhappen:()=>"This error should never happen"};class x{static alreadyDisposed(){return new x({type:"alreadydisposed"})}static notBindable(){return new x({type:"notbindable"})}static notCompatible(t,e){return new x({type:"notcompatible",context:{id:`${t}.${e}`}})}static propertyNotFound(t){return new x({type:"propertynotfound",context:{name:t}})}static shouldNeverHappen(){return new x({type:"shouldneverhappen"})}constructor(t){var e;this.message=(e=ur[t.type](t.context))!==null&&e!==void 0?e:"Unexpected error",this.name=this.constructor.name,this.stack=new Error(this.message).stack,this.type=t.type}toString(){return this.message}}class Zt{constructor(t,e){this.obj_=t,this.key=e}static isBindable(t){return!(t===null||typeof t!="object"&&typeof t!="function")}read(){return this.obj_[this.key]}write(t){this.obj_[this.key]=t}writeProperty(t,e){const i=this.read();if(!Zt.isBindable(i))throw x.notBindable();if(!(t in i))throw x.propertyNotFound(t);i[t]=e}}class E{constructor(){this.observers_={}}on(t,e,i){var r;let s=this.observers_[t];return s||(s=this.observers_[t]=[]),s.push({handler:e,key:(r=i==null?void 0:i.key)!==null&&r!==void 0?r:e}),this}off(t,e){const i=this.observers_[t];return i&&(this.observers_[t]=i.filter(r=>r.key!==e)),this}emit(t,e){const i=this.observers_[t];i&&i.forEach(r=>{r.handler(e)})}}class dr{constructor(t,e){var i;this.constraint_=e==null?void 0:e.constraint,this.equals_=(i=e==null?void 0:e.equals)!==null&&i!==void 0?i:(r,s)=>r===s,this.emitter=new E,this.rawValue_=t}get constraint(){return this.constraint_}get rawValue(){return this.rawValue_}set rawValue(t){this.setRawValue(t,{forceEmit:!1,last:!0})}setRawValue(t,e){const i=e??{forceEmit:!1,last:!0},r=this.constraint_?this.constraint_.constrain(t):t,s=this.rawValue_;this.equals_(s,r)&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.rawValue_=r,this.emitter.emit("change",{options:i,previousRawValue:s,rawValue:r,sender:this}))}}class hr{constructor(t){this.emitter=new E,this.value_=t}get rawValue(){return this.value_}set rawValue(t){this.setRawValue(t,{forceEmit:!1,last:!0})}setRawValue(t,e){const i=e??{forceEmit:!1,last:!0},r=this.value_;r===t&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.value_=t,this.emitter.emit("change",{options:i,previousRawValue:r,rawValue:this.value_,sender:this}))}}class vr{constructor(t){this.emitter=new E,this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.value_=t,this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_)}get rawValue(){return this.value_.rawValue}onValueBeforeChange_(t){this.emitter.emit("beforechange",Object.assign(Object.assign({},t),{sender:this}))}onValueChange_(t){this.emitter.emit("change",Object.assign(Object.assign({},t),{sender:this}))}}function _(n,t){const e=t==null?void 0:t.constraint,i=t==null?void 0:t.equals;return!e&&!i?new hr(n):new dr(n,t)}function mr(n){return[new vr(n),(t,e)=>{n.setRawValue(t,e)}]}class d{constructor(t){this.emitter=new E,this.valMap_=t;for(const e in this.valMap_)this.valMap_[e].emitter.on("change",()=>{this.emitter.emit("change",{key:e,sender:this})})}static createCore(t){return Object.keys(t).reduce((i,r)=>Object.assign(i,{[r]:_(t[r])}),{})}static fromObject(t){const e=this.createCore(t);return new d(e)}get(t){return this.valMap_[t].rawValue}set(t,e){this.valMap_[t].rawValue=e}value(t){return this.valMap_[t]}}class Ft{constructor(t){this.values=d.fromObject({max:t.max,min:t.min})}constrain(t){const e=this.values.get("max"),i=this.values.get("min");return Math.min(Math.max(t,i),e)}}class br{constructor(t){this.values=d.fromObject({max:t.max,min:t.min})}constrain(t){const e=this.values.get("max"),i=this.values.get("min");let r=t;return w(i)||(r=Math.max(r,i)),w(e)||(r=Math.min(r,e)),r}}class fr{constructor(t,e=0){this.step=t,this.origin=e}constrain(t){const e=this.origin%this.step,i=Math.round((t-e)/this.step);return e+i*this.step}}class gr{constructor(t){this.text=t}evaluate(){return Number(this.text)}toString(){return this.text}}const wr={"**":(n,t)=>Math.pow(n,t),"*":(n,t)=>n*t,"/":(n,t)=>n/t,"%":(n,t)=>n%t,"+":(n,t)=>n+t,"-":(n,t)=>n-t,"<<":(n,t)=>n<>":(n,t)=>n>>t,">>>":(n,t)=>n>>>t,"&":(n,t)=>n&t,"^":(n,t)=>n^t,"|":(n,t)=>n|t};class _r{constructor(t,e,i){this.left=e,this.operator=t,this.right=i}evaluate(){const t=wr[this.operator];if(!t)throw new Error(`unexpected binary operator: '${this.operator}`);return t(this.left.evaluate(),this.right.evaluate())}toString(){return["b(",this.left.toString(),this.operator,this.right.toString(),")"].join(" ")}}const Cr={"+":n=>n,"-":n=>-n,"~":n=>~n};class xr{constructor(t,e){this.operator=t,this.expression=e}evaluate(){const t=Cr[this.operator];if(!t)throw new Error(`unexpected unary operator: '${this.operator}`);return t(this.expression.evaluate())}toString(){return["u(",this.operator,this.expression.toString(),")"].join(" ")}}function Oe(n){return(t,e)=>{for(let i=0;it.startsWith(r,e))[0];return i?(e+=i.length,e+=Lt(t,e).length,{cursor:e,operator:i}):null}function zr(n,t){return(e,i)=>{const r=n(e,i);if(!r)return null;i=r.cursor;let s=r.evaluable;for(;;){const o=Nr(t,e,i);if(!o)break;i=o.cursor;const a=n(e,i);if(!a)return null;i=a.cursor,s=new _r(o.operator,s,a.evaluable)}return s?{cursor:i,evaluable:s}:null}}const Hr=[["**"],["*","/","%"],["+","-"],["<<",">>>",">>"],["&"],["^"],["|"]].reduce((n,t)=>zr(n,t),Hn);function $n(n,t){return t+=Lt(n,t).length,Hr(n,t)}function $r(n){const t=$n(n,0);return!t||t.cursor+Lt(n,t.cursor).length!==n.length?null:t.evaluable}function G(n){var t;const e=$r(n);return(t=e==null?void 0:e.evaluate())!==null&&t!==void 0?t:null}function Kn(n){if(typeof n=="number")return n;if(typeof n=="string"){const t=G(n);if(!w(t))return t}return 0}function Kr(n){return String(n)}function R(n){return t=>t.toFixed(Math.max(Math.min(n,20),0))}function b(n,t,e,i,r){const s=(n-t)/(e-t);return i+s*(r-i)}function sn(n){return String(n.toFixed(10)).split(".")[1].replace(/0+$/,"").length}function k(n,t,e){return Math.min(Math.max(n,t),e)}function qn(n,t){return(n%t+t)%t}function qr(n,t){return w(n.step)?Math.max(sn(t),2):sn(n.step)}function Un(n){var t;return(t=n.step)!==null&&t!==void 0?t:1}function Gn(n,t){var e;const i=Math.abs((e=n.step)!==null&&e!==void 0?e:t);return i===0?.1:Math.pow(10,Math.floor(Math.log10(i))-1)}function Wn(n,t){return w(n.step)?null:new fr(n.step,t)}function Yn(n){return!w(n.max)&&!w(n.min)?new Ft({max:n.max,min:n.min}):!w(n.max)||!w(n.min)?new br({max:n.max,min:n.min}):null}function Xn(n,t){var e,i,r;return{formatter:(e=n.format)!==null&&e!==void 0?e:R(qr(n,t)),keyScale:(i=n.keyScale)!==null&&i!==void 0?i:Un(n),pointerScale:(r=n.pointerScale)!==null&&r!==void 0?r:Gn(n,t)}}function Qn(n){return{format:n.optional.function,keyScale:n.optional.number,max:n.optional.number,min:n.optional.number,pointerScale:n.optional.number,step:n.optional.number}}function Me(n){return{constraint:n.constraint,textProps:d.fromObject(Xn(n.params,n.initialValue))}}class ct{constructor(t){this.controller=t}get element(){return this.controller.view.element}get disabled(){return this.controller.viewProps.get("disabled")}set disabled(t){this.controller.viewProps.set("disabled",t)}get hidden(){return this.controller.viewProps.get("hidden")}set hidden(t){this.controller.viewProps.set("hidden",t)}dispose(){this.controller.viewProps.set("disposed",!0)}importState(t){return this.controller.importState(t)}exportState(){return this.controller.exportState()}}class ae{constructor(t){this.target=t}}class It extends ae{constructor(t,e,i){super(t),this.value=e,this.last=i??!0}}class Ur extends ae{constructor(t,e){super(t),this.expanded=e}}class Gr extends ae{constructor(t,e){super(t),this.index=e}}class Wr extends ae{constructor(t,e){super(t),this.native=e}}class Rt extends ct{constructor(t){super(t),this.onValueChange_=this.onValueChange_.bind(this),this.emitter_=new E,this.controller.value.emitter.on("change",this.onValueChange_)}get label(){return this.controller.labelController.props.get("label")}set label(t){this.controller.labelController.props.set("label",t)}get key(){return this.controller.value.binding.target.key}get tag(){return this.controller.tag}set tag(t){this.controller.tag=t}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}refresh(){this.controller.value.fetch()}onValueChange_(t){const e=this.controller.value;this.emitter_.emit("change",new It(this,e.binding.target.read(),t.options.last))}}class Yr{constructor(t,e){this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.binding=e,this.value_=t,this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_),this.emitter=new E}get rawValue(){return this.value_.rawValue}set rawValue(t){this.value_.rawValue=t}setRawValue(t,e){this.value_.setRawValue(t,e)}fetch(){this.value_.rawValue=this.binding.read()}push(){this.binding.write(this.value_.rawValue)}onValueBeforeChange_(t){this.emitter.emit("beforechange",Object.assign(Object.assign({},t),{sender:this}))}onValueChange_(t){this.push(),this.emitter.emit("change",Object.assign(Object.assign({},t),{sender:this}))}}function Xr(n){if(!("binding"in n))return!1;const t=n.binding;return Re(t)&&"read"in t&&"write"in t}function Qr(n,t){const i=Object.keys(t).reduce((r,s)=>{if(r===void 0)return;const o=t[s],a=o(n[s]);return a.succeeded?Object.assign(Object.assign({},r),{[s]:a.value}):void 0},{});return i}function Zr(n,t){return n.reduce((e,i)=>{if(e===void 0)return;const r=t(i);if(!(!r.succeeded||r.value===void 0))return[...e,r.value]},[])}function Jr(n){return n===null?!1:typeof n=="object"}function $(n){return t=>e=>{if(!t&&e===void 0)return{succeeded:!1,value:void 0};if(t&&e===void 0)return{succeeded:!0,value:void 0};const i=n(e);return i!==void 0?{succeeded:!0,value:i}:{succeeded:!1,value:void 0}}}function on(n){return{custom:t=>$(t)(n),boolean:$(t=>typeof t=="boolean"?t:void 0)(n),number:$(t=>typeof t=="number"?t:void 0)(n),string:$(t=>typeof t=="string"?t:void 0)(n),function:$(t=>typeof t=="function"?t:void 0)(n),constant:t=>$(e=>e===t?t:void 0)(n),raw:$(t=>t)(n),object:t=>$(e=>{if(Jr(e))return Qr(e,t)})(n),array:t=>$(e=>{if(Array.isArray(e))return Zr(e,t)})(n)}}const Ee={optional:on(!0),required:on(!1)};function C(n,t){const e=t(Ee),i=Ee.required.object(e)(n);return i.succeeded?i.value:void 0}function D(n,t,e,i){if(t&&!t(n))return!1;const r=C(n,e);return r?i(r):!1}function M(n,t){var e;return ot((e=n==null?void 0:n())!==null&&e!==void 0?e:{},t)}function st(n){return"value"in n}function Zn(n){if(!Ae(n)||!("binding"in n))return!1;const t=n.binding;return Re(t)}const N="http://www.w3.org/2000/svg";function Jt(n){n.offsetHeight}function ts(n,t){const e=n.style.transition;n.style.transition="none",t(),n.style.transition=e}function Be(n){return n.ontouchstart!==void 0}function es(){return globalThis}function ns(){return es().document}function is(n){const t=n.ownerDocument.defaultView;return t&&"document"in t?n.getContext("2d",{willReadFrequently:!0}):null}const rs={check:'',dropdown:'',p2dpad:''};function le(n,t){const e=n.createElementNS(N,"svg");return e.innerHTML=rs[t],e}function Jn(n,t,e){n.insertBefore(t,n.children[e])}function Fe(n){n.parentElement&&n.parentElement.removeChild(n)}function ti(n){for(;n.children.length>0;)n.removeChild(n.children[0])}function ss(n){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])}function ei(n){return n.relatedTarget?n.relatedTarget:"explicitOriginalTarget"in n?n.explicitOriginalTarget:null}function U(n,t){n.emitter.on("change",e=>{t(e.rawValue)}),t(n.rawValue)}function z(n,t,e){U(n.value(t),e)}const os="tp";function h(n){return(e,i)=>[os,"-",n,"v",e?`_${e}`:"",i?`-${i}`:""].join("")}const xt=h("lbl");function as(n,t){const e=n.createDocumentFragment();return t.split(` +`).map(r=>n.createTextNode(r)).forEach((r,s)=>{s>0&&e.appendChild(n.createElement("br")),e.appendChild(r)}),e}class ni{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(xt()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(xt("l")),z(e.props,"label",s=>{w(s)?this.element.classList.add(xt(void 0,"nol")):(this.element.classList.remove(xt(void 0,"nol")),ss(i),i.appendChild(as(t,s)))}),this.element.appendChild(i),this.labelElement=i;const r=t.createElement("div");r.classList.add(xt("v")),this.element.appendChild(r),this.valueElement=r}}class ii{constructor(t,e){this.props=e.props,this.valueController=e.valueController,this.viewProps=e.valueController.viewProps,this.view=new ni(t,{props:e.props,viewProps:this.viewProps}),this.view.valueElement.appendChild(this.valueController.view.element)}importProps(t){return D(t,null,e=>({label:e.optional.string}),e=>(this.props.set("label",e.label),!0))}exportProps(){return M(null,{label:this.props.get("label")})}}function ls(){return["veryfirst","first","last","verylast"]}const an=h(""),ln={veryfirst:"vfst",first:"fst",last:"lst",verylast:"vlst"};class ce{constructor(t){this.parent_=null,this.blade=t.blade,this.view=t.view,this.viewProps=t.viewProps;const e=this.view.element;this.blade.value("positions").emitter.on("change",()=>{ls().forEach(i=>{e.classList.remove(an(void 0,ln[i]))}),this.blade.get("positions").forEach(i=>{e.classList.add(an(void 0,ln[i]))})}),this.viewProps.handleDispose(()=>{Fe(e)})}get parent(){return this.parent_}set parent(t){this.parent_=t,this.viewProps.set("parent",this.parent_?this.parent_.viewProps:null)}importState(t){return D(t,null,e=>({disabled:e.required.boolean,hidden:e.required.boolean}),e=>(this.viewProps.importState(e),!0))}exportState(){return M(null,Object.assign({},this.viewProps.exportState()))}}class at extends ce{constructor(t,e){if(e.value!==e.valueController.value)throw x.shouldNeverHappen();const i=e.valueController.viewProps,r=new ii(t,{blade:e.blade,props:e.props,valueController:e.valueController});super(Object.assign(Object.assign({},e),{view:new ni(t,{props:e.props,viewProps:i}),viewProps:i})),this.labelController=r,this.value=e.value,this.valueController=e.valueController,this.view.valueElement.appendChild(this.valueController.view.element)}importState(t){return D(t,e=>{var i,r,s;return super.importState(e)&&this.labelController.importProps(e)&&((s=(r=(i=this.valueController).importProps)===null||r===void 0?void 0:r.call(i,t))!==null&&s!==void 0?s:!0)},e=>({value:e.optional.raw}),e=>(e.value&&(this.value.rawValue=e.value),!0))}exportState(){var t,e,i;return M(()=>super.exportState(),Object.assign(Object.assign({value:this.value.rawValue},this.labelController.exportProps()),(i=(e=(t=this.valueController).exportProps)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:{}))}}function cn(n){const t=Object.assign({},n);return delete t.value,t}class ri extends at{constructor(t,e){super(t,e),this.tag=e.tag}importState(t){return D(t,e=>super.importState(cn(t)),e=>({tag:e.optional.string}),e=>(this.tag=e.tag,!0))}exportState(){return M(()=>cn(super.exportState()),{binding:{key:this.value.binding.target.key,value:this.value.binding.target.read()},tag:this.tag})}}function cs(n){return st(n)&&Zn(n.value)}class ps extends ri{importState(t){return D(t,e=>super.importState(e),e=>({binding:e.required.object({value:e.required.raw})}),e=>(this.value.binding.inject(e.binding.value),this.value.fetch(),!0))}}function us(n){return st(n)&&Xr(n.value)}function si(n,t){for(;n.lengthn.length?e.splice(0,e.length-n.length):si(e,n.length),e}class ms{constructor(t){this.emitter=new E,this.onTick_=this.onTick_.bind(this),this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.binding=t.binding,this.value_=_(ds(t.bufferSize)),this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_),this.ticker=t.ticker,this.ticker.emitter.on("tick",this.onTick_),this.fetch()}get rawValue(){return this.value_.rawValue}set rawValue(t){this.value_.rawValue=t}setRawValue(t,e){this.value_.setRawValue(t,e)}fetch(){this.value_.rawValue=vs(this.value_.rawValue,this.binding.read())}onTick_(){this.fetch()}onValueBeforeChange_(t){this.emitter.emit("beforechange",Object.assign(Object.assign({},t),{sender:this}))}onValueChange_(t){this.emitter.emit("change",Object.assign(Object.assign({},t),{sender:this}))}}function bs(n){if(!("binding"in n))return!1;const t=n.binding;return Re(t)&&"read"in t&&!("write"in t)}class fs extends ri{exportState(){return M(()=>super.exportState(),{binding:{readonly:!0}})}}function gs(n){return st(n)&&bs(n.value)}class ws extends ct{get label(){return this.controller.labelController.props.get("label")}set label(t){this.controller.labelController.props.set("label",t)}get title(){var t;return(t=this.controller.buttonController.props.get("title"))!==null&&t!==void 0?t:""}set title(t){this.controller.buttonController.props.set("title",t)}on(t,e){const i=e.bind(this);return this.controller.buttonController.emitter.on(t,s=>{i(new Wr(this,s.nativeEvent))}),this}off(t,e){return this.controller.buttonController.emitter.off(t,e),this}}function _s(n,t,e){e?n.classList.add(t):n.classList.remove(t)}function gt(n,t){return e=>{_s(n,t,e)}}function Ie(n,t){U(n,e=>{t.textContent=e??""})}const ue=h("btn");class Cs{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(ue()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("button");i.classList.add(ue("b")),e.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const r=t.createElement("div");r.classList.add(ue("t")),Ie(e.props.value("title"),r),this.buttonElement.appendChild(r)}}class xs{constructor(t,e){this.emitter=new E,this.onClick_=this.onClick_.bind(this),this.props=e.props,this.viewProps=e.viewProps,this.view=new Cs(t,{props:this.props,viewProps:this.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}importProps(t){return D(t,null,e=>({title:e.optional.string}),e=>(this.props.set("title",e.title),!0))}exportProps(){return M(null,{title:this.props.get("title")})}onClick_(t){this.emitter.emit("click",{nativeEvent:t,sender:this})}}class pn extends ce{constructor(t,e){const i=new xs(t,{props:e.buttonProps,viewProps:e.viewProps}),r=new ii(t,{blade:e.blade,props:e.labelProps,valueController:i});super({blade:e.blade,view:r.view,viewProps:e.viewProps}),this.buttonController=i,this.labelController=r}importState(t){return D(t,e=>super.importState(e)&&this.buttonController.importProps(e)&&this.labelController.importProps(e),()=>({}),()=>!0)}exportState(){return M(()=>super.exportState(),Object.assign(Object.assign({},this.buttonController.exportProps()),this.labelController.exportProps()))}}class oi{constructor(t){const[e,i]=t.split("-"),r=e.split(".");this.major=parseInt(r[0],10),this.minor=parseInt(r[1],10),this.patch=parseInt(r[2],10),this.prerelease=i??null}toString(){const t=[this.major,this.minor,this.patch].join(".");return this.prerelease!==null?[t,this.prerelease].join("-"):t}}const wt=new oi("2.0.4");function L(n){return Object.assign({core:wt},n)}const ys=L({id:"button",type:"blade",accept(n){const t=C(n,e=>({title:e.required.string,view:e.required.constant("button"),label:e.optional.string}));return t?{params:t}:null},controller(n){return new pn(n.document,{blade:n.blade,buttonProps:d.fromObject({title:n.params.title}),labelProps:d.fromObject({label:n.params.label}),viewProps:n.viewProps})},api(n){return n.controller instanceof pn?new ws(n.controller):null}});function Ps(n,t){return n.addBlade(Object.assign(Object.assign({},t),{view:"button"}))}function Es(n,t){return n.addBlade(Object.assign(Object.assign({},t),{view:"folder"}))}function ks(n,t){return n.addBlade(Object.assign(Object.assign({},t),{view:"tab"}))}function Vs(n){return Ae(n)?"refresh"in n&&typeof n.refresh=="function":!1}function Ts(n,t){if(!Zt.isBindable(n))throw x.notBindable();return new Zt(n,t)}class Ss{constructor(t,e){this.onRackValueChange_=this.onRackValueChange_.bind(this),this.controller_=t,this.emitter_=new E,this.pool_=e,this.controller_.rack.emitter.on("valuechange",this.onRackValueChange_)}get children(){return this.controller_.rack.children.map(t=>this.pool_.createApi(t))}addBinding(t,e,i){const r=i??{},s=this.controller_.element.ownerDocument,o=this.pool_.createBinding(s,Ts(t,e),r),a=this.pool_.createBindingApi(o);return this.add(a,r.index)}addFolder(t){return Es(this,t)}addButton(t){return Ps(this,t)}addTab(t){return ks(this,t)}add(t,e){const i=t.controller;return this.controller_.rack.add(i,e),t}remove(t){this.controller_.rack.remove(t.controller)}addBlade(t){const e=this.controller_.element.ownerDocument,i=this.pool_.createBlade(e,t),r=this.pool_.createApi(i);return this.add(r,t.index)}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}refresh(){this.children.forEach(t=>{Vs(t)&&t.refresh()})}onRackValueChange_(t){const e=t.bladeController,i=this.pool_.createApi(e),r=Zn(e.value)?e.value.binding:null;this.emitter_.emit("change",new It(i,r?r.target.read():e.value.rawValue,t.options.last))}}class je extends ct{constructor(t,e){super(t),this.rackApi_=new Ss(t.rackController,e)}refresh(){this.rackApi_.refresh()}}class Ne extends ce{constructor(t){super({blade:t.blade,view:t.view,viewProps:t.rackController.viewProps}),this.rackController=t.rackController}importState(t){return D(t,e=>super.importState(e),e=>({children:e.required.array(e.required.raw)}),e=>this.rackController.rack.children.every((i,r)=>i.importState(e.children[r])))}exportState(){return M(()=>super.exportState(),{children:this.rackController.rack.children.map(t=>t.exportState())})}}function ke(n){return"rackController"in n}class Ls{constructor(t){this.emitter=new E,this.items_=[],this.cache_=new Set,this.onSubListAdd_=this.onSubListAdd_.bind(this),this.onSubListRemove_=this.onSubListRemove_.bind(this),this.extract_=t}get items(){return this.items_}allItems(){return Array.from(this.cache_)}find(t){for(const e of this.allItems())if(t(e))return e;return null}includes(t){return this.cache_.has(t)}add(t,e){if(this.includes(t))throw x.shouldNeverHappen();const i=e!==void 0?e:this.items_.length;this.items_.splice(i,0,t),this.cache_.add(t);const r=this.extract_(t);r&&(r.emitter.on("add",this.onSubListAdd_),r.emitter.on("remove",this.onSubListRemove_),r.allItems().forEach(s=>{this.cache_.add(s)})),this.emitter.emit("add",{index:i,item:t,root:this,target:this})}remove(t){const e=this.items_.indexOf(t);if(e<0)return;this.items_.splice(e,1),this.cache_.delete(t);const i=this.extract_(t);i&&(i.allItems().forEach(r=>{this.cache_.delete(r)}),i.emitter.off("add",this.onSubListAdd_),i.emitter.off("remove",this.onSubListRemove_)),this.emitter.emit("remove",{index:e,item:t,root:this,target:this})}onSubListAdd_(t){this.cache_.add(t.item),this.emitter.emit("add",{index:t.index,item:t.item,root:this,target:t.target})}onSubListRemove_(t){this.cache_.delete(t.item),this.emitter.emit("remove",{index:t.index,item:t.item,root:this,target:t.target})}}function As(n,t){for(let e=0;e!r.viewProps.get("hidden")),e=t[0],i=t[t.length-1];this.bcSet_.items.forEach(r=>{const s=[];r===e&&(s.push("first"),(!this.blade_||this.blade_.get("positions").includes("veryfirst"))&&s.push("veryfirst")),r===i&&(s.push("last"),(!this.blade_||this.blade_.get("positions").includes("verylast"))&&s.push("verylast")),r.blade.set("positions",s)})}onChildPositionsChange_(){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildViewPropsChange_(t){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildDispose_(){this.bcSet_.items.filter(e=>e.viewProps.get("disposed")).forEach(e=>{this.bcSet_.remove(e)})}onChildValueChange_(t){const e=As(this.find(st),t.sender);if(!e)throw x.alreadyDisposed();this.emitter.emit("valuechange",{bladeController:e,options:t.options,sender:this})}onRackLayout_(t){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onRackValueChange_(t){this.emitter.emit("valuechange",{bladeController:t.bladeController,options:t.options,sender:this})}onBladePositionsChange_(){this.updatePositions_()}}class ze{constructor(t){this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this),this.element=t.element,this.viewProps=t.viewProps;const e=new Os({blade:t.root?void 0:t.blade,viewProps:t.viewProps});e.emitter.on("add",this.onRackAdd_),e.emitter.on("remove",this.onRackRemove_),this.rack=e,this.viewProps.handleDispose(()=>{for(let i=this.rack.children.length-1;i>=0;i--)this.rack.children[i].viewProps.set("disposed",!0)})}onRackAdd_(t){t.root&&Jn(this.element,t.bladeController.view.element,t.index)}onRackRemove_(t){t.root&&Fe(t.bladeController.view.element)}}function _t(){return new d({positions:_([],{equals:pr})})}class jt extends d{constructor(t){super(t)}static create(t){const e={completed:!0,expanded:t,expandedHeight:null,shouldFixHeight:!1,temporaryExpanded:null},i=d.createCore(e);return new jt(i)}get styleExpanded(){var t;return(t=this.get("temporaryExpanded"))!==null&&t!==void 0?t:this.get("expanded")}get styleHeight(){if(!this.styleExpanded)return"0";const t=this.get("expandedHeight");return this.get("shouldFixHeight")&&!w(t)?`${t}px`:"auto"}bindExpandedClass(t,e){const i=()=>{this.styleExpanded?t.classList.add(e):t.classList.remove(e)};z(this,"expanded",i),z(this,"temporaryExpanded",i)}cleanUpTransition(){this.set("shouldFixHeight",!1),this.set("expandedHeight",null),this.set("completed",!0)}}function Ds(n,t){let e=0;return ts(t,()=>{n.set("expandedHeight",null),n.set("temporaryExpanded",!0),Jt(t),e=t.clientHeight,n.set("temporaryExpanded",null),Jt(t)}),e}function un(n,t){t.style.height=n.styleHeight}function He(n,t){n.value("expanded").emitter.on("beforechange",()=>{if(n.set("completed",!1),w(n.get("expandedHeight"))){const e=Ds(n,t);e>0&&n.set("expandedHeight",e)}n.set("shouldFixHeight",!0),Jt(t)}),n.emitter.on("change",()=>{un(n,t)}),un(n,t),t.addEventListener("transitionend",e=>{e.propertyName==="height"&&n.cleanUpTransition()})}class ai extends je{constructor(t,e){super(t,e),this.emitter_=new E,this.controller.foldable.value("expanded").emitter.on("change",i=>{this.emitter_.emit("fold",new Ur(this,i.sender.rawValue))}),this.rackApi_.on("change",i=>{this.emitter_.emit("change",i)})}get expanded(){return this.controller.foldable.get("expanded")}set expanded(t){this.controller.foldable.set("expanded",t)}get title(){return this.controller.props.get("title")}set title(t){this.controller.props.set("title",t)}get children(){return this.rackApi_.children}addBinding(t,e,i){return this.rackApi_.addBinding(t,e,i)}addFolder(t){return this.rackApi_.addFolder(t)}addButton(t){return this.rackApi_.addButton(t)}addTab(t){return this.rackApi_.addTab(t)}add(t,e){return this.rackApi_.add(t,e)}remove(t){this.rackApi_.remove(t)}addBlade(t){return this.rackApi_.addBlade(t)}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}}const li=h("cnt");class Ms{constructor(t,e){var i;this.className_=h((i=e.viewName)!==null&&i!==void 0?i:"fld"),this.element=t.createElement("div"),this.element.classList.add(this.className_(),li()),e.viewProps.bindClassModifiers(this.element),this.foldable_=e.foldable,this.foldable_.bindExpandedClass(this.element,this.className_(void 0,"expanded")),z(this.foldable_,"completed",gt(this.element,this.className_(void 0,"cpl")));const r=t.createElement("button");r.classList.add(this.className_("b")),z(e.props,"title",c=>{w(c)?this.element.classList.add(this.className_(void 0,"not")):this.element.classList.remove(this.className_(void 0,"not"))}),e.viewProps.bindDisabled(r),this.element.appendChild(r),this.buttonElement=r;const s=t.createElement("div");s.classList.add(this.className_("i")),this.element.appendChild(s);const o=t.createElement("div");o.classList.add(this.className_("t")),Ie(e.props.value("title"),o),this.buttonElement.appendChild(o),this.titleElement=o;const a=t.createElement("div");a.classList.add(this.className_("m")),this.buttonElement.appendChild(a);const l=t.createElement("div");l.classList.add(this.className_("c")),this.element.appendChild(l),this.containerElement=l}}class Ve extends Ne{constructor(t,e){var i;const r=jt.create((i=e.expanded)!==null&&i!==void 0?i:!0),s=new Ms(t,{foldable:r,props:e.props,viewName:e.root?"rot":void 0,viewProps:e.viewProps});super(Object.assign(Object.assign({},e),{rackController:new ze({blade:e.blade,element:s.containerElement,root:e.root,viewProps:e.viewProps}),view:s})),this.onTitleClick_=this.onTitleClick_.bind(this),this.props=e.props,this.foldable=r,He(this.foldable,this.view.containerElement),this.rackController.rack.emitter.on("add",()=>{this.foldable.cleanUpTransition()}),this.rackController.rack.emitter.on("remove",()=>{this.foldable.cleanUpTransition()}),this.view.buttonElement.addEventListener("click",this.onTitleClick_)}get document(){return this.view.element.ownerDocument}importState(t){return D(t,e=>super.importState(e),e=>({expanded:e.required.boolean,title:e.optional.string}),e=>(this.foldable.set("expanded",e.expanded),this.props.set("title",e.title),!0))}exportState(){return M(()=>super.exportState(),{expanded:this.foldable.get("expanded"),title:this.props.get("title")})}onTitleClick_(){this.foldable.set("expanded",!this.foldable.get("expanded"))}}const Bs=L({id:"folder",type:"blade",accept(n){const t=C(n,e=>({title:e.required.string,view:e.required.constant("folder"),expanded:e.optional.boolean}));return t?{params:t}:null},controller(n){return new Ve(n.document,{blade:n.blade,expanded:n.params.expanded,props:d.fromObject({title:n.params.title}),viewProps:n.viewProps})},api(n){return n.controller instanceof Ve?new ai(n.controller,n.pool):null}}),Fs=h("");function dn(n,t){return gt(n,Fs(void 0,t))}class Y extends d{constructor(t){var e;super(t),this.onDisabledChange_=this.onDisabledChange_.bind(this),this.onParentChange_=this.onParentChange_.bind(this),this.onParentGlobalDisabledChange_=this.onParentGlobalDisabledChange_.bind(this),[this.globalDisabled_,this.setGlobalDisabled_]=mr(_(this.getGlobalDisabled_())),this.value("disabled").emitter.on("change",this.onDisabledChange_),this.value("parent").emitter.on("change",this.onParentChange_),(e=this.get("parent"))===null||e===void 0||e.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_)}static create(t){var e,i,r;const s=t??{};return new Y(d.createCore({disabled:(e=s.disabled)!==null&&e!==void 0?e:!1,disposed:!1,hidden:(i=s.hidden)!==null&&i!==void 0?i:!1,parent:(r=s.parent)!==null&&r!==void 0?r:null}))}get globalDisabled(){return this.globalDisabled_}bindClassModifiers(t){U(this.globalDisabled_,dn(t,"disabled")),z(this,"hidden",dn(t,"hidden"))}bindDisabled(t){U(this.globalDisabled_,e=>{t.disabled=e})}bindTabIndex(t){U(this.globalDisabled_,e=>{t.tabIndex=e?-1:0})}handleDispose(t){this.value("disposed").emitter.on("change",e=>{e&&t()})}importState(t){this.set("disabled",t.disabled),this.set("hidden",t.hidden)}exportState(){return{disabled:this.get("disabled"),hidden:this.get("hidden")}}getGlobalDisabled_(){const t=this.get("parent");return(t?t.globalDisabled.rawValue:!1)||this.get("disabled")}updateGlobalDisabled_(){this.setGlobalDisabled_(this.getGlobalDisabled_())}onDisabledChange_(){this.updateGlobalDisabled_()}onParentGlobalDisabledChange_(){this.updateGlobalDisabled_()}onParentChange_(t){var e;const i=t.previousRawValue;i==null||i.globalDisabled.emitter.off("change",this.onParentGlobalDisabledChange_),(e=this.get("parent"))===null||e===void 0||e.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_),this.updateGlobalDisabled_()}}const hn=h("tbp");class Is{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(hn()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(hn("c")),this.element.appendChild(i),this.containerElement=i}}const yt=h("tbi");class js{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(yt()),e.viewProps.bindClassModifiers(this.element),z(e.props,"selected",s=>{s?this.element.classList.add(yt(void 0,"sel")):this.element.classList.remove(yt(void 0,"sel"))});const i=t.createElement("button");i.classList.add(yt("b")),e.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const r=t.createElement("div");r.classList.add(yt("t")),Ie(e.props.value("title"),r),this.buttonElement.appendChild(r),this.titleElement=r}}class Ns{constructor(t,e){this.emitter=new E,this.onClick_=this.onClick_.bind(this),this.props=e.props,this.viewProps=e.viewProps,this.view=new js(t,{props:e.props,viewProps:e.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}onClick_(){this.emitter.emit("click",{sender:this})}}class Te extends Ne{constructor(t,e){const i=new Is(t,{viewProps:e.viewProps});super(Object.assign(Object.assign({},e),{rackController:new ze({blade:e.blade,element:i.containerElement,viewProps:e.viewProps}),view:i})),this.onItemClick_=this.onItemClick_.bind(this),this.ic_=new Ns(t,{props:e.itemProps,viewProps:Y.create()}),this.ic_.emitter.on("click",this.onItemClick_),this.props=e.props,z(this.props,"selected",r=>{this.itemController.props.set("selected",r),this.viewProps.set("hidden",!r)})}get itemController(){return this.ic_}importState(t){return D(t,e=>super.importState(e),e=>({selected:e.required.boolean,title:e.required.string}),e=>(this.ic_.props.set("selected",e.selected),this.ic_.props.set("title",e.title),!0))}exportState(){return M(()=>super.exportState(),{selected:this.ic_.props.get("selected"),title:this.ic_.props.get("title")})}onItemClick_(){this.props.set("selected",!0)}}class zs extends je{constructor(t,e){super(t,e),this.emitter_=new E,this.onSelect_=this.onSelect_.bind(this),this.pool_=e,this.rackApi_.on("change",i=>{this.emitter_.emit("change",i)}),this.controller.tab.selectedIndex.emitter.on("change",this.onSelect_)}get pages(){return this.rackApi_.children}addPage(t){const e=this.controller.view.element.ownerDocument,i=new Te(e,{blade:_t(),itemProps:d.fromObject({selected:!1,title:t.title}),props:d.fromObject({selected:!1}),viewProps:Y.create()}),r=this.pool_.createApi(i);return this.rackApi_.add(r,t.index)}removePage(t){this.rackApi_.remove(this.rackApi_.children[t])}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}onSelect_(t){this.emitter_.emit("select",new Gr(this,t.rawValue))}}class Hs extends je{get title(){var t;return(t=this.controller.itemController.props.get("title"))!==null&&t!==void 0?t:""}set title(t){this.controller.itemController.props.set("title",t)}get selected(){return this.controller.props.get("selected")}set selected(t){this.controller.props.set("selected",t)}get children(){return this.rackApi_.children}addButton(t){return this.rackApi_.addButton(t)}addFolder(t){return this.rackApi_.addFolder(t)}addTab(t){return this.rackApi_.addTab(t)}add(t,e){this.rackApi_.add(t,e)}remove(t){this.rackApi_.remove(t)}addBinding(t,e,i){return this.rackApi_.addBinding(t,e,i)}addBlade(t){return this.rackApi_.addBlade(t)}}const vn=-1;class $s{constructor(){this.onItemSelectedChange_=this.onItemSelectedChange_.bind(this),this.empty=_(!0),this.selectedIndex=_(vn),this.items_=[]}add(t,e){const i=e??this.items_.length;this.items_.splice(i,0,t),t.emitter.on("change",this.onItemSelectedChange_),this.keepSelection_()}remove(t){const e=this.items_.indexOf(t);e<0||(this.items_.splice(e,1),t.emitter.off("change",this.onItemSelectedChange_),this.keepSelection_())}keepSelection_(){if(this.items_.length===0){this.selectedIndex.rawValue=vn,this.empty.rawValue=!0;return}const t=this.items_.findIndex(e=>e.rawValue);t<0?(this.items_.forEach((e,i)=>{e.rawValue=i===0}),this.selectedIndex.rawValue=0):(this.items_.forEach((e,i)=>{e.rawValue=i===t}),this.selectedIndex.rawValue=t),this.empty.rawValue=!1}onItemSelectedChange_(t){if(t.rawValue){const e=this.items_.findIndex(i=>i===t.sender);this.items_.forEach((i,r)=>{i.rawValue=r===e}),this.selectedIndex.rawValue=e}else this.keepSelection_()}}const Pt=h("tab");class Ks{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(Pt(),li()),e.viewProps.bindClassModifiers(this.element),U(e.empty,gt(this.element,Pt(void 0,"nop")));const i=t.createElement("div");i.classList.add(Pt("t")),this.element.appendChild(i),this.itemsElement=i;const r=t.createElement("div");r.classList.add(Pt("i")),this.element.appendChild(r);const s=t.createElement("div");s.classList.add(Pt("c")),this.element.appendChild(s),this.contentsElement=s}}class mn extends Ne{constructor(t,e){const i=new $s,r=new Ks(t,{empty:i.empty,viewProps:e.viewProps});super({blade:e.blade,rackController:new ze({blade:e.blade,element:r.contentsElement,viewProps:e.viewProps}),view:r}),this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this);const s=this.rackController.rack;s.emitter.on("add",this.onRackAdd_),s.emitter.on("remove",this.onRackRemove_),this.tab=i}add(t,e){this.rackController.rack.add(t,e)}remove(t){this.rackController.rack.remove(this.rackController.rack.children[t])}onRackAdd_(t){if(!t.root)return;const e=t.bladeController;Jn(this.view.itemsElement,e.itemController.view.element,t.index),e.itemController.viewProps.set("parent",this.viewProps),this.tab.add(e.props.value("selected"))}onRackRemove_(t){if(!t.root)return;const e=t.bladeController;Fe(e.itemController.view.element),e.itemController.viewProps.set("parent",null),this.tab.remove(e.props.value("selected"))}}const ci=L({id:"tab",type:"blade",accept(n){const t=C(n,e=>({pages:e.required.array(e.required.object({title:e.required.string})),view:e.required.constant("tab")}));return!t||t.pages.length===0?null:{params:t}},controller(n){const t=new mn(n.document,{blade:n.blade,viewProps:n.viewProps});return n.params.pages.forEach(e=>{const i=new Te(n.document,{blade:_t(),itemProps:d.fromObject({selected:!1,title:e.title}),props:d.fromObject({selected:!1}),viewProps:Y.create()});t.add(i)}),t},api(n){return n.controller instanceof mn?new zs(n.controller,n.pool):n.controller instanceof Te?new Hs(n.controller,n.pool):null}});function qs(n,t){const e=n.accept(t.params);if(!e)return null;const i=C(t.params,r=>({disabled:r.optional.boolean,hidden:r.optional.boolean}));return n.controller({blade:_t(),document:t.document,params:Object.assign(Object.assign({},e.params),{disabled:i==null?void 0:i.disabled,hidden:i==null?void 0:i.hidden}),viewProps:Y.create({disabled:i==null?void 0:i.disabled,hidden:i==null?void 0:i.hidden})})}class $e extends Rt{get options(){return this.controller.valueController.props.get("options")}set options(t){this.controller.valueController.props.set("options",t)}}class Us{constructor(){this.disabled=!1,this.emitter=new E}dispose(){}tick(){this.disabled||this.emitter.emit("tick",{sender:this})}}class Gs{constructor(t,e){this.disabled_=!1,this.timerId_=null,this.onTick_=this.onTick_.bind(this),this.doc_=t,this.emitter=new E,this.interval_=e,this.setTimer_()}get disabled(){return this.disabled_}set disabled(t){this.disabled_=t,this.disabled_?this.clearTimer_():this.setTimer_()}dispose(){this.clearTimer_()}clearTimer_(){if(this.timerId_===null)return;const t=this.doc_.defaultView;t&&t.clearInterval(this.timerId_),this.timerId_=null}setTimer_(){if(this.clearTimer_(),this.interval_<=0)return;const t=this.doc_.defaultView;t&&(this.timerId_=t.setInterval(this.onTick_,this.interval_))}onTick_(){this.disabled_||this.emitter.emit("tick",{sender:this})}}class Nt{constructor(t){this.constraints=t}constrain(t){return this.constraints.reduce((e,i)=>i.constrain(e),t)}}function te(n,t){if(n instanceof t)return n;if(n instanceof Nt){const e=n.constraints.reduce((i,r)=>i||(r instanceof t?r:null),null);if(e)return e}return null}class zt{constructor(t){this.values=d.fromObject({options:t})}constrain(t){const e=this.values.get("options");return e.length===0||e.filter(r=>r.value===t).length>0?t:e[0].value}}function Ht(n){var t;const e=Ee;if(Array.isArray(n))return(t=C({items:n},i=>({items:i.required.array(i.required.object({text:i.required.string,value:i.required.raw}))})))===null||t===void 0?void 0:t.items;if(typeof n=="object")return e.required.raw(n).value}function Ke(n){if(Array.isArray(n))return n;const t=[];return Object.keys(n).forEach(e=>{t.push({text:e,value:n[e]})}),t}function qe(n){return w(n)?null:new zt(Ke(n))}const de=h("lst");class Ws{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.props_=e.props,this.element=t.createElement("div"),this.element.classList.add(de()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("select");i.classList.add(de("s")),e.viewProps.bindDisabled(i),this.element.appendChild(i),this.selectElement=i;const r=t.createElement("div");r.classList.add(de("m")),r.appendChild(le(t,"dropdown")),this.element.appendChild(r),e.value.emitter.on("change",this.onValueChange_),this.value_=e.value,z(this.props_,"options",s=>{ti(this.selectElement),s.forEach(o=>{const a=t.createElement("option");a.textContent=o.text,this.selectElement.appendChild(a)}),this.update_()})}update_(){const t=this.props_.get("options").map(e=>e.value);this.selectElement.selectedIndex=t.indexOf(this.value_.rawValue)}onValueChange_(){this.update_()}}class nt{constructor(t,e){this.onSelectChange_=this.onSelectChange_.bind(this),this.props=e.props,this.value=e.value,this.viewProps=e.viewProps,this.view=new Ws(t,{props:this.props,value:this.value,viewProps:this.viewProps}),this.view.selectElement.addEventListener("change",this.onSelectChange_)}onSelectChange_(t){const e=t.currentTarget;this.value.rawValue=this.props.get("options")[e.selectedIndex].value}importProps(t){return D(t,null,e=>({options:e.required.custom(Ht)}),e=>(this.props.set("options",Ke(e.options)),!0))}exportProps(){return M(null,{options:this.props.get("options")})}}const bn=h("pop");class Ys{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(bn()),e.viewProps.bindClassModifiers(this.element),U(e.shows,gt(this.element,bn(void 0,"v")))}}class pi{constructor(t,e){this.shows=_(!1),this.viewProps=e.viewProps,this.view=new Ys(t,{shows:this.shows,viewProps:this.viewProps})}}const fn=h("txt");class Xs{constructor(t,e){this.onChange_=this.onChange_.bind(this),this.element=t.createElement("div"),this.element.classList.add(fn()),e.viewProps.bindClassModifiers(this.element),this.props_=e.props,this.props_.emitter.on("change",this.onChange_);const i=t.createElement("input");i.classList.add(fn("i")),i.type="text",e.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,e.value.emitter.on("change",this.onChange_),this.value_=e.value,this.refresh()}refresh(){const t=this.props_.get("formatter");this.inputElement.value=t(this.value_.rawValue)}onChange_(){this.refresh()}}class Ot{constructor(t,e){this.onInputChange_=this.onInputChange_.bind(this),this.parser_=e.parser,this.props=e.props,this.value=e.value,this.viewProps=e.viewProps,this.view=new Xs(t,{props:e.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_)}onInputChange_(t){const i=t.currentTarget.value,r=this.parser_(i);w(r)||(this.value.rawValue=r),this.view.refresh()}}function Qs(n){return String(n)}function ui(n){return n==="false"?!1:!!n}function gn(n){return Qs(n)}function Zs(n){return t=>n.reduce((e,i)=>e!==null?e:i(t),null)}const Js=R(0);function ee(n){return Js(n)+"%"}function di(n){return String(n)}function Se(n){return n}function Ct({primary:n,secondary:t,forward:e,backward:i}){let r=!1;function s(o){r||(r=!0,o(),r=!1)}n.emitter.on("change",o=>{s(()=>{t.setRawValue(e(n.rawValue,t.rawValue),o.options)})}),t.emitter.on("change",o=>{s(()=>{n.setRawValue(i(n.rawValue,t.rawValue),o.options)}),s(()=>{t.setRawValue(e(n.rawValue,t.rawValue),o.options)})}),s(()=>{t.setRawValue(e(n.rawValue,t.rawValue),{forceEmit:!1,last:!0})})}function A(n,t){const e=n*(t.altKey?.1:1)*(t.shiftKey?10:1);return t.upKey?+e:t.downKey?-e:0}function Dt(n){return{altKey:n.altKey,downKey:n.key==="ArrowDown",shiftKey:n.shiftKey,upKey:n.key==="ArrowUp"}}function W(n){return{altKey:n.altKey,downKey:n.key==="ArrowLeft",shiftKey:n.shiftKey,upKey:n.key==="ArrowRight"}}function to(n){return n==="ArrowUp"||n==="ArrowDown"}function hi(n){return to(n)||n==="ArrowLeft"||n==="ArrowRight"}function he(n,t){var e,i;const r=t.ownerDocument.defaultView,s=t.getBoundingClientRect();return{x:n.pageX-(((e=r&&r.scrollX)!==null&&e!==void 0?e:0)+s.left),y:n.pageY-(((i=r&&r.scrollY)!==null&&i!==void 0?i:0)+s.top)}}class pt{constructor(t){this.lastTouch_=null,this.onDocumentMouseMove_=this.onDocumentMouseMove_.bind(this),this.onDocumentMouseUp_=this.onDocumentMouseUp_.bind(this),this.onMouseDown_=this.onMouseDown_.bind(this),this.onTouchEnd_=this.onTouchEnd_.bind(this),this.onTouchMove_=this.onTouchMove_.bind(this),this.onTouchStart_=this.onTouchStart_.bind(this),this.elem_=t,this.emitter=new E,t.addEventListener("touchstart",this.onTouchStart_,{passive:!1}),t.addEventListener("touchmove",this.onTouchMove_,{passive:!0}),t.addEventListener("touchend",this.onTouchEnd_),t.addEventListener("mousedown",this.onMouseDown_)}computePosition_(t){const e=this.elem_.getBoundingClientRect();return{bounds:{width:e.width,height:e.height},point:t?{x:t.x,y:t.y}:null}}onMouseDown_(t){var e;t.preventDefault(),(e=t.currentTarget)===null||e===void 0||e.focus();const i=this.elem_.ownerDocument;i.addEventListener("mousemove",this.onDocumentMouseMove_),i.addEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("down",{altKey:t.altKey,data:this.computePosition_(he(t,this.elem_)),sender:this,shiftKey:t.shiftKey})}onDocumentMouseMove_(t){this.emitter.emit("move",{altKey:t.altKey,data:this.computePosition_(he(t,this.elem_)),sender:this,shiftKey:t.shiftKey})}onDocumentMouseUp_(t){const e=this.elem_.ownerDocument;e.removeEventListener("mousemove",this.onDocumentMouseMove_),e.removeEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("up",{altKey:t.altKey,data:this.computePosition_(he(t,this.elem_)),sender:this,shiftKey:t.shiftKey})}onTouchStart_(t){t.preventDefault();const e=t.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("down",{altKey:t.altKey,data:this.computePosition_(e?{x:e.clientX-i.left,y:e.clientY-i.top}:void 0),sender:this,shiftKey:t.shiftKey}),this.lastTouch_=e}onTouchMove_(t){const e=t.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("move",{altKey:t.altKey,data:this.computePosition_(e?{x:e.clientX-i.left,y:e.clientY-i.top}:void 0),sender:this,shiftKey:t.shiftKey}),this.lastTouch_=e}onTouchEnd_(t){var e;const i=(e=t.targetTouches.item(0))!==null&&e!==void 0?e:this.lastTouch_,r=this.elem_.getBoundingClientRect();this.emitter.emit("up",{altKey:t.altKey,data:this.computePosition_(i?{x:i.clientX-r.left,y:i.clientY-r.top}:void 0),sender:this,shiftKey:t.shiftKey})}}const B=h("txt");class eo{constructor(t,e){this.onChange_=this.onChange_.bind(this),this.props_=e.props,this.props_.emitter.on("change",this.onChange_),this.element=t.createElement("div"),this.element.classList.add(B(),B(void 0,"num")),e.arrayPosition&&this.element.classList.add(B(void 0,e.arrayPosition)),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("input");i.classList.add(B("i")),i.type="text",e.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,this.onDraggingChange_=this.onDraggingChange_.bind(this),this.dragging_=e.dragging,this.dragging_.emitter.on("change",this.onDraggingChange_),this.element.classList.add(B()),this.inputElement.classList.add(B("i"));const r=t.createElement("div");r.classList.add(B("k")),this.element.appendChild(r),this.knobElement=r;const s=t.createElementNS(N,"svg");s.classList.add(B("g")),this.knobElement.appendChild(s);const o=t.createElementNS(N,"path");o.classList.add(B("gb")),s.appendChild(o),this.guideBodyElem_=o;const a=t.createElementNS(N,"path");a.classList.add(B("gh")),s.appendChild(a),this.guideHeadElem_=a;const l=t.createElement("div");l.classList.add(h("tt")()),this.knobElement.appendChild(l),this.tooltipElem_=l,e.value.emitter.on("change",this.onChange_),this.value=e.value,this.refresh()}onDraggingChange_(t){if(t.rawValue===null){this.element.classList.remove(B(void 0,"drg"));return}this.element.classList.add(B(void 0,"drg"));const e=t.rawValue/this.props_.get("pointerScale"),i=e+(e>0?-1:e<0?1:0),r=k(-i,-4,4);this.guideHeadElem_.setAttributeNS(null,"d",[`M ${i+r},0 L${i},4 L${i+r},8`,`M ${e},-1 L${e},9`].join(" ")),this.guideBodyElem_.setAttributeNS(null,"d",`M 0,4 L${e},4`);const s=this.props_.get("formatter");this.tooltipElem_.textContent=s(this.value.rawValue),this.tooltipElem_.style.left=`${e}px`}refresh(){const t=this.props_.get("formatter");this.inputElement.value=t(this.value.rawValue)}onChange_(){this.refresh()}}class $t{constructor(t,e){var i;this.originRawValue_=0,this.onInputChange_=this.onInputChange_.bind(this),this.onInputKeyDown_=this.onInputKeyDown_.bind(this),this.onInputKeyUp_=this.onInputKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.parser_=e.parser,this.props=e.props,this.sliderProps_=(i=e.sliderProps)!==null&&i!==void 0?i:null,this.value=e.value,this.viewProps=e.viewProps,this.dragging_=_(null),this.view=new eo(t,{arrayPosition:e.arrayPosition,dragging:this.dragging_,props:this.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_),this.view.inputElement.addEventListener("keydown",this.onInputKeyDown_),this.view.inputElement.addEventListener("keyup",this.onInputKeyUp_);const r=new pt(this.view.knobElement);r.emitter.on("down",this.onPointerDown_),r.emitter.on("move",this.onPointerMove_),r.emitter.on("up",this.onPointerUp_)}constrainValue_(t){var e,i;const r=(e=this.sliderProps_)===null||e===void 0?void 0:e.get("min"),s=(i=this.sliderProps_)===null||i===void 0?void 0:i.get("max");let o=t;return r!==void 0&&(o=Math.max(o,r)),s!==void 0&&(o=Math.min(o,s)),o}onInputChange_(t){const i=t.currentTarget.value,r=this.parser_(i);w(r)||(this.value.rawValue=this.constrainValue_(r)),this.view.refresh()}onInputKeyDown_(t){const e=A(this.props.get("keyScale"),Dt(t));e!==0&&this.value.setRawValue(this.constrainValue_(this.value.rawValue+e),{forceEmit:!1,last:!1})}onInputKeyUp_(t){A(this.props.get("keyScale"),Dt(t))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}onPointerDown_(){this.originRawValue_=this.value.rawValue,this.dragging_.rawValue=0}computeDraggingValue_(t){if(!t.point)return null;const e=t.point.x-t.bounds.width/2;return this.constrainValue_(this.originRawValue_+e*this.props.get("pointerScale"))}onPointerMove_(t){const e=this.computeDraggingValue_(t.data);e!==null&&(this.value.setRawValue(e,{forceEmit:!1,last:!1}),this.dragging_.rawValue=this.value.rawValue-this.originRawValue_)}onPointerUp_(t){const e=this.computeDraggingValue_(t.data);e!==null&&(this.value.setRawValue(e,{forceEmit:!0,last:!0}),this.dragging_.rawValue=null)}}const ve=h("sld");class no{constructor(t,e){this.onChange_=this.onChange_.bind(this),this.props_=e.props,this.props_.emitter.on("change",this.onChange_),this.element=t.createElement("div"),this.element.classList.add(ve()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(ve("t")),e.viewProps.bindTabIndex(i),this.element.appendChild(i),this.trackElement=i;const r=t.createElement("div");r.classList.add(ve("k")),this.trackElement.appendChild(r),this.knobElement=r,e.value.emitter.on("change",this.onChange_),this.value=e.value,this.update_()}update_(){const t=k(b(this.value.rawValue,this.props_.get("min"),this.props_.get("max"),0,100),0,100);this.knobElement.style.width=`${t}%`}onChange_(){this.update_()}}class io{constructor(t,e){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDownOrMove_=this.onPointerDownOrMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=e.value,this.viewProps=e.viewProps,this.props=e.props,this.view=new no(t,{props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new pt(this.view.trackElement),this.ptHandler_.emitter.on("down",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("move",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.trackElement.addEventListener("keydown",this.onKeyDown_),this.view.trackElement.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(t,e){t.point&&this.value.setRawValue(b(k(t.point.x,0,t.bounds.width),0,t.bounds.width,this.props.get("min"),this.props.get("max")),e)}onPointerDownOrMove_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerUp_(t){this.handlePointerEvent_(t.data,{forceEmit:!0,last:!0})}onKeyDown_(t){const e=A(this.props.get("keyScale"),W(t));e!==0&&this.value.setRawValue(this.value.rawValue+e,{forceEmit:!1,last:!1})}onKeyUp_(t){A(this.props.get("keyScale"),W(t))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const me=h("sldtxt");class ro{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(me());const i=t.createElement("div");i.classList.add(me("s")),this.sliderView_=e.sliderView,i.appendChild(this.sliderView_.element),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(me("t")),this.textView_=e.textView,r.appendChild(this.textView_.element),this.element.appendChild(r)}}class ne{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.sliderC_=new io(t,{props:e.sliderProps,value:e.value,viewProps:this.viewProps}),this.textC_=new $t(t,{parser:e.parser,props:e.textProps,sliderProps:e.sliderProps,value:e.value,viewProps:e.viewProps}),this.view=new ro(t,{sliderView:this.sliderC_.view,textView:this.textC_.view})}get sliderController(){return this.sliderC_}get textController(){return this.textC_}importProps(t){return D(t,null,e=>({max:e.required.number,min:e.required.number}),e=>{const i=this.sliderC_.props;return i.set("max",e.max),i.set("min",e.min),!0})}exportProps(){const t=this.sliderC_.props;return M(null,{max:t.get("max"),min:t.get("min")})}}function vi(n){return{sliderProps:new d({keyScale:n.keyScale,max:n.max,min:n.min}),textProps:new d({formatter:_(n.formatter),keyScale:n.keyScale,pointerScale:_(n.pointerScale)})}}const so={containerUnitSize:"cnt-usz"};function mi(n){return`--${so[n]}`}function Mt(n){return Qn(n)}function J(n){if(Pe(n))return C(n,Mt)}function q(n,t){if(!n)return;const e=[],i=Wn(n,t);i&&e.push(i);const r=Yn(n);return r&&e.push(r),new Nt(e)}function oo(n){return n?n.major===wt.major:!1}function bi(n){if(n==="inline"||n==="popup")return n}function Kt(n,t){n.write(t)}const Gt=h("ckb");class ao{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.element=t.createElement("div"),this.element.classList.add(Gt()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("label");i.classList.add(Gt("l")),this.element.appendChild(i),this.labelElement=i;const r=t.createElement("input");r.classList.add(Gt("i")),r.type="checkbox",this.labelElement.appendChild(r),this.inputElement=r,e.viewProps.bindDisabled(this.inputElement);const s=t.createElement("div");s.classList.add(Gt("w")),this.labelElement.appendChild(s);const o=le(t,"check");s.appendChild(o),e.value.emitter.on("change",this.onValueChange_),this.value=e.value,this.update_()}update_(){this.inputElement.checked=this.value.rawValue}onValueChange_(){this.update_()}}class lo{constructor(t,e){this.onInputChange_=this.onInputChange_.bind(this),this.onLabelMouseDown_=this.onLabelMouseDown_.bind(this),this.value=e.value,this.viewProps=e.viewProps,this.view=new ao(t,{value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_),this.view.labelElement.addEventListener("mousedown",this.onLabelMouseDown_)}onInputChange_(t){const e=t.currentTarget;this.value.rawValue=e.checked,t.preventDefault(),t.stopPropagation()}onLabelMouseDown_(t){t.preventDefault()}}function co(n){const t=[],e=qe(n.options);return e&&t.push(e),new Nt(t)}const po=L({id:"input-bool",type:"input",accept:(n,t)=>{if(typeof n!="boolean")return null;const e=C(t,i=>({options:i.optional.custom(Ht),readonly:i.optional.constant(!1)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>ui,constraint:n=>co(n.params),writer:n=>Kt},controller:n=>{const t=n.document,e=n.value,i=n.constraint,r=i&&te(i,zt);return r?new nt(t,{props:new d({options:r.values.value("options")}),value:e,viewProps:n.viewProps}):new lo(t,{value:e,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="boolean"?null:n.controller.valueController instanceof nt?new $e(n.controller):null}}),rt=h("col");class uo{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(rt()),e.foldable.bindExpandedClass(this.element,rt(void 0,"expanded")),z(e.foldable,"completed",gt(this.element,rt(void 0,"cpl")));const i=t.createElement("div");i.classList.add(rt("h")),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(rt("s")),i.appendChild(r),this.swatchElement=r;const s=t.createElement("div");if(s.classList.add(rt("t")),i.appendChild(s),this.textElement=s,e.pickerLayout==="inline"){const o=t.createElement("div");o.classList.add(rt("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}}function ho(n,t,e){const i=k(n/255,0,1),r=k(t/255,0,1),s=k(e/255,0,1),o=Math.max(i,r,s),a=Math.min(i,r,s),l=o-a;let c=0,p=0;const u=(a+o)/2;return l!==0&&(p=l/(1-Math.abs(o+a-1)),i===o?c=(r-s)/l:r===o?c=2+(s-i)/l:c=4+(i-r)/l,c=c/6+(c<0?1:0)),[c*360,p*100,u*100]}function vo(n,t,e){const i=(n%360+360)%360,r=k(t/100,0,1),s=k(e/100,0,1),o=(1-Math.abs(2*s-1))*r,a=o*(1-Math.abs(i/60%2-1)),l=s-o/2;let c,p,u;return i>=0&&i<60?[c,p,u]=[o,a,0]:i>=60&&i<120?[c,p,u]=[a,o,0]:i>=120&&i<180?[c,p,u]=[0,o,a]:i>=180&&i<240?[c,p,u]=[0,a,o]:i>=240&&i<300?[c,p,u]=[a,0,o]:[c,p,u]=[o,0,a],[(c+l)*255,(p+l)*255,(u+l)*255]}function mo(n,t,e){const i=k(n/255,0,1),r=k(t/255,0,1),s=k(e/255,0,1),o=Math.max(i,r,s),a=Math.min(i,r,s),l=o-a;let c;l===0?c=0:o===i?c=60*(((r-s)/l%6+6)%6):o===r?c=60*((s-i)/l+2):c=60*((i-r)/l+4);const p=o===0?0:l/o,u=o;return[c,p*100,u*100]}function fi(n,t,e){const i=qn(n,360),r=k(t/100,0,1),s=k(e/100,0,1),o=s*r,a=o*(1-Math.abs(i/60%2-1)),l=s-o;let c,p,u;return i>=0&&i<60?[c,p,u]=[o,a,0]:i>=60&&i<120?[c,p,u]=[a,o,0]:i>=120&&i<180?[c,p,u]=[0,o,a]:i>=180&&i<240?[c,p,u]=[0,a,o]:i>=240&&i<300?[c,p,u]=[a,0,o]:[c,p,u]=[o,0,a],[(c+l)*255,(p+l)*255,(u+l)*255]}function bo(n,t,e){const i=e+t*(100-Math.abs(2*e-100))/200;return[n,i!==0?t*(100-Math.abs(2*e-100))/i:0,e+t*(100-Math.abs(2*e-100))/(2*100)]}function fo(n,t,e){const i=100-Math.abs(e*(200-t)/100-100);return[n,i!==0?t*e/i:0,e*(200-t)/(2*100)]}function H(n){return[n[0],n[1],n[2]]}function pe(n,t){return[n[0],n[1],n[2],t]}const go={hsl:{hsl:(n,t,e)=>[n,t,e],hsv:bo,rgb:vo},hsv:{hsl:fo,hsv:(n,t,e)=>[n,t,e],rgb:fi},rgb:{hsl:ho,hsv:mo,rgb:(n,t,e)=>[n,t,e]}};function ft(n,t){return[t==="float"?1:n==="rgb"?255:360,t==="float"?1:n==="rgb"?255:100,t==="float"?1:n==="rgb"?255:100]}function wo(n,t){return n===t?t:qn(n,t)}function gi(n,t,e){var i;const r=ft(t,e);return[t==="rgb"?k(n[0],0,r[0]):wo(n[0],r[0]),k(n[1],0,r[1]),k(n[2],0,r[2]),k((i=n[3])!==null&&i!==void 0?i:1,0,1)]}function wn(n,t,e,i){const r=ft(t,e),s=ft(t,i);return n.map((o,a)=>o/r[a]*s[a])}function wi(n,t,e){const i=wn(n,t.mode,t.type,"int"),r=go[t.mode][e.mode](...i);return wn(r,e.mode,"int",e.type)}class v{static black(){return new v([0,0,0],"rgb")}constructor(t,e){this.type="int",this.mode=e,this.comps_=gi(t,e,this.type)}getComponents(t){return pe(wi(H(this.comps_),{mode:this.mode,type:this.type},{mode:t??this.mode,type:this.type}),this.comps_[3])}toRgbaObject(){const t=this.getComponents("rgb");return{r:t[0],g:t[1],b:t[2],a:t[3]}}}const X=h("colp");class _o{constructor(t,e){this.alphaViews_=null,this.element=t.createElement("div"),this.element.classList.add(X()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(X("hsv"));const r=t.createElement("div");r.classList.add(X("sv")),this.svPaletteView_=e.svPaletteView,r.appendChild(this.svPaletteView_.element),i.appendChild(r);const s=t.createElement("div");s.classList.add(X("h")),this.hPaletteView_=e.hPaletteView,s.appendChild(this.hPaletteView_.element),i.appendChild(s),this.element.appendChild(i);const o=t.createElement("div");if(o.classList.add(X("rgb")),this.textsView_=e.textsView,o.appendChild(this.textsView_.element),this.element.appendChild(o),e.alphaViews){this.alphaViews_={palette:e.alphaViews.palette,text:e.alphaViews.text};const a=t.createElement("div");a.classList.add(X("a"));const l=t.createElement("div");l.classList.add(X("ap")),l.appendChild(this.alphaViews_.palette.element),a.appendChild(l);const c=t.createElement("div");c.classList.add(X("at")),c.appendChild(this.alphaViews_.text.element),a.appendChild(c),this.element.appendChild(a)}}get allFocusableElements(){const t=[this.svPaletteView_.element,this.hPaletteView_.element,this.textsView_.modeSelectElement,...this.textsView_.inputViews.map(e=>e.inputElement)];return this.alphaViews_&&t.push(this.alphaViews_.palette.element,this.alphaViews_.text.inputElement),t}}function Co(n){return n==="int"?"int":n==="float"?"float":void 0}function Ue(n){return C(n,t=>({color:t.optional.object({alpha:t.optional.boolean,type:t.optional.custom(Co)}),expanded:t.optional.boolean,picker:t.optional.custom(bi),readonly:t.optional.constant(!1)}))}function lt(n){return n?.1:1}function _i(n){var t;return(t=n.color)===null||t===void 0?void 0:t.type}class Ge{constructor(t,e){this.type="float",this.mode=e,this.comps_=gi(t,e,this.type)}getComponents(t){return pe(wi(H(this.comps_),{mode:this.mode,type:this.type},{mode:t??this.mode,type:this.type}),this.comps_[3])}toRgbaObject(){const t=this.getComponents("rgb");return{r:t[0],g:t[1],b:t[2],a:t[3]}}}const xo={int:(n,t)=>new v(n,t),float:(n,t)=>new Ge(n,t)};function We(n,t,e){return xo[e](n,t)}function yo(n){return n.type==="float"}function Po(n){return n.type==="int"}function Eo(n){const t=n.getComponents(),e=ft(n.mode,"int");return new v([Math.round(b(t[0],0,1,0,e[0])),Math.round(b(t[1],0,1,0,e[1])),Math.round(b(t[2],0,1,0,e[2])),t[3]],n.mode)}function ko(n){const t=n.getComponents(),e=ft(n.mode,"int");return new Ge([b(t[0],0,e[0],0,1),b(t[1],0,e[1],0,1),b(t[2],0,e[2],0,1),t[3]],n.mode)}function S(n,t){if(n.type===t)return n;if(Po(n)&&t==="float")return ko(n);if(yo(n)&&t==="int")return Eo(n);throw x.shouldNeverHappen()}function Vo(n,t){return n.alpha===t.alpha&&n.mode===t.mode&&n.notation===t.notation&&n.type===t.type}function F(n,t){const e=n.match(/^(.+)%$/);return Math.min(e?parseFloat(e[1])*.01*t:parseFloat(n),t)}const To={deg:n=>n,grad:n=>n*360/400,rad:n=>n*360/(2*Math.PI),turn:n=>n*360};function Ci(n){const t=n.match(/^([0-9.]+?)(deg|grad|rad|turn)$/);if(!t)return parseFloat(n);const e=parseFloat(t[1]),i=t[2];return To[i](e)}function xi(n){const t=n.match(/^rgb\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!t)return null;const e=[F(t[1],255),F(t[2],255),F(t[3],255)];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])?null:e}function So(n){const t=xi(n);return t?new v(t,"rgb"):null}function yi(n){const t=n.match(/^rgba\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!t)return null;const e=[F(t[1],255),F(t[2],255),F(t[3],255),F(t[4],1)];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])||isNaN(e[3])?null:e}function Lo(n){const t=yi(n);return t?new v(t,"rgb"):null}function Pi(n){const t=n.match(/^hsl\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!t)return null;const e=[Ci(t[1]),F(t[2],100),F(t[3],100)];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])?null:e}function Ao(n){const t=Pi(n);return t?new v(t,"hsl"):null}function Ei(n){const t=n.match(/^hsla\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!t)return null;const e=[Ci(t[1]),F(t[2],100),F(t[3],100),F(t[4],1)];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])||isNaN(e[3])?null:e}function Ro(n){const t=Ei(n);return t?new v(t,"hsl"):null}function ki(n){const t=n.match(/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(t)return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)];const e=n.match(/^(?:#|0x)([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return e?[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]:null}function Oo(n){const t=ki(n);return t?new v(t,"rgb"):null}function Vi(n){const t=n.match(/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(t)return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16),b(parseInt(t[4]+t[4],16),0,255,0,1)];const e=n.match(/^(?:#|0x)?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return e?[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16),b(parseInt(e[4],16),0,255,0,1)]:null}function Do(n){const t=Vi(n);return t?new v(t,"rgb"):null}function Ti(n){const t=n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!t)return null;const e=[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])?null:e}function _n(n){return t=>{const e=Ti(t);return e?We(e,"rgb",n):null}}function Si(n){const t=n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*a\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!t)return null;const e=[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])||isNaN(e[3])?null:e}function Cn(n){return t=>{const e=Si(t);return e?We(e,"rgb",n):null}}const Mo=[{parser:ki,result:{alpha:!1,mode:"rgb",notation:"hex"}},{parser:Vi,result:{alpha:!0,mode:"rgb",notation:"hex"}},{parser:xi,result:{alpha:!1,mode:"rgb",notation:"func"}},{parser:yi,result:{alpha:!0,mode:"rgb",notation:"func"}},{parser:Pi,result:{alpha:!1,mode:"hsl",notation:"func"}},{parser:Ei,result:{alpha:!0,mode:"hsl",notation:"func"}},{parser:Ti,result:{alpha:!1,mode:"rgb",notation:"object"}},{parser:Si,result:{alpha:!0,mode:"rgb",notation:"object"}}];function Bo(n){return Mo.reduce((t,{parser:e,result:i})=>t||(e(n)?i:null),null)}function Fo(n,t="int"){const e=Bo(n);return e?e.notation==="hex"&&t!=="float"?Object.assign(Object.assign({},e),{type:"int"}):e.notation==="func"?Object.assign(Object.assign({},e),{type:t}):null:null}function qt(n){const t=[Oo,Do,So,Lo,Ao,Ro];n==="int"&&t.push(_n("int"),Cn("int")),n==="float"&&t.push(_n("float"),Cn("float"));const e=Zs(t);return i=>{const r=e(i);return r?S(r,n):null}}function Io(n){const t=qt("int");if(typeof n!="string")return v.black();const e=t(n);return e??v.black()}function Li(n){const t=k(Math.floor(n),0,255).toString(16);return t.length===1?`0${t}`:t}function Ye(n,t="#"){const e=H(n.getComponents("rgb")).map(Li).join("");return`${t}${e}`}function Xe(n,t="#"){const e=n.getComponents("rgb"),i=[e[0],e[1],e[2],e[3]*255].map(Li).join("");return`${t}${i}`}function Ai(n){const t=R(0),e=S(n,"int");return`rgb(${H(e.getComponents("rgb")).map(r=>t(r)).join(", ")})`}function Yt(n){const t=R(2),e=R(0);return`rgba(${S(n,"int").getComponents("rgb").map((s,o)=>(o===3?t:e)(s)).join(", ")})`}function jo(n){const t=[R(0),ee,ee],e=S(n,"int");return`hsl(${H(e.getComponents("hsl")).map((r,s)=>t[s](r)).join(", ")})`}function No(n){const t=[R(0),ee,ee,R(2)];return`hsla(${S(n,"int").getComponents("hsl").map((r,s)=>t[s](r)).join(", ")})`}function Ri(n,t){const e=R(t==="float"?2:0),i=["r","g","b"],r=S(n,t);return`{${H(r.getComponents("rgb")).map((o,a)=>`${i[a]}: ${e(o)}`).join(", ")}}`}function zo(n){return t=>Ri(t,n)}function Oi(n,t){const e=R(2),i=R(t==="float"?2:0),r=["r","g","b","a"];return`{${S(n,t).getComponents("rgb").map((a,l)=>{const c=l===3?e:i;return`${r[l]}: ${c(a)}`}).join(", ")}}`}function Ho(n){return t=>Oi(t,n)}const $o=[{format:{alpha:!1,mode:"rgb",notation:"hex",type:"int"},stringifier:Ye},{format:{alpha:!0,mode:"rgb",notation:"hex",type:"int"},stringifier:Xe},{format:{alpha:!1,mode:"rgb",notation:"func",type:"int"},stringifier:Ai},{format:{alpha:!0,mode:"rgb",notation:"func",type:"int"},stringifier:Yt},{format:{alpha:!1,mode:"hsl",notation:"func",type:"int"},stringifier:jo},{format:{alpha:!0,mode:"hsl",notation:"func",type:"int"},stringifier:No},...["int","float"].reduce((n,t)=>[...n,{format:{alpha:!1,mode:"rgb",notation:"object",type:t},stringifier:zo(t)},{format:{alpha:!0,mode:"rgb",notation:"object",type:t},stringifier:Ho(t)}],[])];function Di(n){return $o.reduce((t,e)=>t||(Vo(e.format,n)?e.stringifier:null),null)}const Et=h("apl");class Ko{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.value=e.value,this.value.emitter.on("change",this.onValueChange_),this.element=t.createElement("div"),this.element.classList.add(Et()),e.viewProps.bindClassModifiers(this.element),e.viewProps.bindTabIndex(this.element);const i=t.createElement("div");i.classList.add(Et("b")),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(Et("c")),i.appendChild(r),this.colorElem_=r;const s=t.createElement("div");s.classList.add(Et("m")),this.element.appendChild(s),this.markerElem_=s;const o=t.createElement("div");o.classList.add(Et("p")),this.markerElem_.appendChild(o),this.previewElem_=o,this.update_()}update_(){const t=this.value.rawValue,e=t.getComponents("rgb"),i=new v([e[0],e[1],e[2],0],"rgb"),r=new v([e[0],e[1],e[2],255],"rgb"),s=["to right",Yt(i),Yt(r)];this.colorElem_.style.background=`linear-gradient(${s.join(",")})`,this.previewElem_.style.backgroundColor=Yt(t);const o=b(e[3],0,1,0,100);this.markerElem_.style.left=`${o}%`}onValueChange_(){this.update_()}}class qo{constructor(t,e){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=e.value,this.viewProps=e.viewProps,this.view=new Ko(t,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new pt(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(t,e){if(!t.point)return;const i=t.point.x/t.bounds.width,r=this.value.rawValue,[s,o,a]=r.getComponents("hsv");this.value.setRawValue(new v([s,o,a,i],"hsv"),e)}onPointerDown_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerMove_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerUp_(t){this.handlePointerEvent_(t.data,{forceEmit:!0,last:!0})}onKeyDown_(t){const e=A(lt(!0),W(t));if(e===0)return;const i=this.value.rawValue,[r,s,o,a]=i.getComponents("hsv");this.value.setRawValue(new v([r,s,o,a+e],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(t){A(lt(!0),W(t))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const dt=h("coltxt");function Uo(n){const t=n.createElement("select"),e=[{text:"RGB",value:"rgb"},{text:"HSL",value:"hsl"},{text:"HSV",value:"hsv"},{text:"HEX",value:"hex"}];return t.appendChild(e.reduce((i,r)=>{const s=n.createElement("option");return s.textContent=r.text,s.value=r.value,i.appendChild(s),i},n.createDocumentFragment())),t}class Go{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(dt()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(dt("m")),this.modeElem_=Uo(t),this.modeElem_.classList.add(dt("ms")),i.appendChild(this.modeSelectElement),e.viewProps.bindDisabled(this.modeElem_);const r=t.createElement("div");r.classList.add(dt("mm")),r.appendChild(le(t,"dropdown")),i.appendChild(r),this.element.appendChild(i);const s=t.createElement("div");s.classList.add(dt("w")),this.element.appendChild(s),this.inputsElem_=s,this.inputViews_=e.inputViews,this.applyInputViews_(),U(e.mode,o=>{this.modeElem_.value=o})}get modeSelectElement(){return this.modeElem_}get inputViews(){return this.inputViews_}set inputViews(t){this.inputViews_=t,this.applyInputViews_()}applyInputViews_(){ti(this.inputsElem_);const t=this.element.ownerDocument;this.inputViews_.forEach(e=>{const i=t.createElement("div");i.classList.add(dt("c")),i.appendChild(e.element),this.inputsElem_.appendChild(i)})}}function Wo(n){return R(n==="float"?2:0)}function Yo(n,t,e){const i=ft(n,t)[e];return new Ft({min:0,max:i})}function Xo(n,t,e){return new $t(n,{arrayPosition:e===0?"fst":e===2?"lst":"mid",parser:t.parser,props:d.fromObject({formatter:Wo(t.colorType),keyScale:lt(!1),pointerScale:t.colorType==="float"?.01:1}),value:_(0,{constraint:Yo(t.colorMode,t.colorType,e)}),viewProps:t.viewProps})}function Qo(n,t){const e={colorMode:t.colorMode,colorType:t.colorType,parser:G,viewProps:t.viewProps};return[0,1,2].map(i=>{const r=Xo(n,e,i);return Ct({primary:t.value,secondary:r.value,forward(s){return S(s,t.colorType).getComponents(t.colorMode)[i]},backward(s,o){const a=t.colorMode,c=S(s,t.colorType).getComponents(a);c[i]=o;const p=We(pe(H(c),c[3]),a,t.colorType);return S(p,"int")}}),r})}function Zo(n,t){const e=new Ot(n,{parser:qt("int"),props:d.fromObject({formatter:Ye}),value:_(v.black()),viewProps:t.viewProps});return Ct({primary:t.value,secondary:e.value,forward:i=>new v(H(i.getComponents()),i.mode),backward:(i,r)=>new v(pe(H(r.getComponents(i.mode)),i.getComponents()[3]),i.mode)}),[e]}function Jo(n){return n!=="hex"}class ta{constructor(t,e){this.onModeSelectChange_=this.onModeSelectChange_.bind(this),this.colorType_=e.colorType,this.value=e.value,this.viewProps=e.viewProps,this.colorMode=_(this.value.rawValue.mode),this.ccs_=this.createComponentControllers_(t),this.view=new Go(t,{mode:this.colorMode,inputViews:[this.ccs_[0].view,this.ccs_[1].view,this.ccs_[2].view],viewProps:this.viewProps}),this.view.modeSelectElement.addEventListener("change",this.onModeSelectChange_)}createComponentControllers_(t){const e=this.colorMode.rawValue;return Jo(e)?Qo(t,{colorMode:e,colorType:this.colorType_,value:this.value,viewProps:this.viewProps}):Zo(t,{value:this.value,viewProps:this.viewProps})}onModeSelectChange_(t){const e=t.currentTarget;this.colorMode.rawValue=e.value,this.ccs_=this.createComponentControllers_(this.view.element.ownerDocument),this.view.inputViews=this.ccs_.map(i=>i.view)}}const be=h("hpl");class ea{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.value=e.value,this.value.emitter.on("change",this.onValueChange_),this.element=t.createElement("div"),this.element.classList.add(be()),e.viewProps.bindClassModifiers(this.element),e.viewProps.bindTabIndex(this.element);const i=t.createElement("div");i.classList.add(be("c")),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(be("m")),this.element.appendChild(r),this.markerElem_=r,this.update_()}update_(){const t=this.value.rawValue,[e]=t.getComponents("hsv");this.markerElem_.style.backgroundColor=Ai(new v([e,100,100],"hsv"));const i=b(e,0,360,0,100);this.markerElem_.style.left=`${i}%`}onValueChange_(){this.update_()}}class na{constructor(t,e){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=e.value,this.viewProps=e.viewProps,this.view=new ea(t,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new pt(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(t,e){if(!t.point)return;const i=b(k(t.point.x,0,t.bounds.width),0,t.bounds.width,0,360),r=this.value.rawValue,[,s,o,a]=r.getComponents("hsv");this.value.setRawValue(new v([i,s,o,a],"hsv"),e)}onPointerDown_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerMove_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerUp_(t){this.handlePointerEvent_(t.data,{forceEmit:!0,last:!0})}onKeyDown_(t){const e=A(lt(!1),W(t));if(e===0)return;const i=this.value.rawValue,[r,s,o,a]=i.getComponents("hsv");this.value.setRawValue(new v([r+e,s,o,a],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(t){A(lt(!1),W(t))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const fe=h("svp"),xn=64;class ia{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.value=e.value,this.value.emitter.on("change",this.onValueChange_),this.element=t.createElement("div"),this.element.classList.add(fe()),e.viewProps.bindClassModifiers(this.element),e.viewProps.bindTabIndex(this.element);const i=t.createElement("canvas");i.height=xn,i.width=xn,i.classList.add(fe("c")),this.element.appendChild(i),this.canvasElement=i;const r=t.createElement("div");r.classList.add(fe("m")),this.element.appendChild(r),this.markerElem_=r,this.update_()}update_(){const t=is(this.canvasElement);if(!t)return;const i=this.value.rawValue.getComponents("hsv"),r=this.canvasElement.width,s=this.canvasElement.height,o=t.getImageData(0,0,r,s),a=o.data;for(let p=0;pi.getComponents()[3],backward:(i,r)=>{const s=i.getComponents();return s[3]=r,new v(s,i.mode)}}),this.textsC_=new ta(t,{colorType:e.colorType,value:this.value,viewProps:this.viewProps}),this.view=new _o(t,{alphaViews:this.alphaIcs_?{palette:this.alphaIcs_.palette.view,text:this.alphaIcs_.text.view}:null,hPaletteView:this.hPaletteC_.view,supportsAlpha:e.supportsAlpha,svPaletteView:this.svPaletteC_.view,textsView:this.textsC_.view,viewProps:this.viewProps})}get textsController(){return this.textsC_}}const ge=h("colsw");class oa{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),e.value.emitter.on("change",this.onValueChange_),this.value=e.value,this.element=t.createElement("div"),this.element.classList.add(ge()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(ge("sw")),this.element.appendChild(i),this.swatchElem_=i;const r=t.createElement("button");r.classList.add(ge("b")),e.viewProps.bindDisabled(r),this.element.appendChild(r),this.buttonElement=r,this.update_()}update_(){const t=this.value.rawValue;this.swatchElem_.style.backgroundColor=Xe(t)}onValueChange_(){this.update_()}}class aa{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.view=new oa(t,{value:this.value,viewProps:this.viewProps})}}class Qe{constructor(t,e){this.onButtonBlur_=this.onButtonBlur_.bind(this),this.onButtonClick_=this.onButtonClick_.bind(this),this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.value=e.value,this.viewProps=e.viewProps,this.foldable_=jt.create(e.expanded),this.swatchC_=new aa(t,{value:this.value,viewProps:this.viewProps});const i=this.swatchC_.view.buttonElement;i.addEventListener("blur",this.onButtonBlur_),i.addEventListener("click",this.onButtonClick_),this.textC_=new Ot(t,{parser:e.parser,props:d.fromObject({formatter:e.formatter}),value:this.value,viewProps:this.viewProps}),this.view=new uo(t,{foldable:this.foldable_,pickerLayout:e.pickerLayout}),this.view.swatchElement.appendChild(this.swatchC_.view.element),this.view.textElement.appendChild(this.textC_.view.element),this.popC_=e.pickerLayout==="popup"?new pi(t,{viewProps:this.viewProps}):null;const r=new sa(t,{colorType:e.colorType,supportsAlpha:e.supportsAlpha,value:this.value,viewProps:this.viewProps});r.view.allFocusableElements.forEach(s=>{s.addEventListener("blur",this.onPopupChildBlur_),s.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=r,this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(r.view.element),Ct({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:s=>s,backward:(s,o)=>o})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),He(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onButtonBlur_(t){if(!this.popC_)return;const e=this.view.element,i=t.relatedTarget;(!i||!e.contains(i))&&(this.popC_.shows.rawValue=!1)}onButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.view.allFocusableElements[0].focus()}onPopupChildBlur_(t){if(!this.popC_)return;const e=this.popC_.view.element,i=ei(t);i&&e.contains(i)||i&&i===this.swatchC_.view.buttonElement&&!Be(e.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(t){this.popC_?t.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&t.key==="Escape"&&this.swatchC_.view.buttonElement.focus()}}function la(n){return H(n.getComponents("rgb")).reduce((t,e)=>t<<8|Math.floor(e)&255,0)}function ca(n){return n.getComponents("rgb").reduce((t,e,i)=>{const r=Math.floor(i===3?e*255:e)&255;return t<<8|r},0)>>>0}function pa(n){return new v([n>>16&255,n>>8&255,n&255],"rgb")}function ua(n){return new v([n>>24&255,n>>16&255,n>>8&255,b(n&255,0,255,0,1)],"rgb")}function da(n){return typeof n!="number"?v.black():pa(n)}function ha(n){return typeof n!="number"?v.black():ua(n)}function Xt(n,t){return typeof n!="object"||w(n)?!1:t in n&&typeof n[t]=="number"}function Mi(n){return Xt(n,"r")&&Xt(n,"g")&&Xt(n,"b")}function Bi(n){return Mi(n)&&Xt(n,"a")}function Fi(n){return Mi(n)}function Ze(n,t){if(n.mode!==t.mode||n.type!==t.type)return!1;const e=n.getComponents(),i=t.getComponents();for(let r=0;r{Kt(e,t(i))}:null}function ma(n){const t=n?ca:la;return(e,i)=>{Kt(e,t(i))}}function ba(n,t,e){const r=S(t,e).toRgbaObject();n.writeProperty("r",r.r),n.writeProperty("g",r.g),n.writeProperty("b",r.b),n.writeProperty("a",r.a)}function fa(n,t,e){const r=S(t,e).toRgbaObject();n.writeProperty("r",r.r),n.writeProperty("g",r.g),n.writeProperty("b",r.b)}function ga(n,t){return(e,i)=>{n?ba(e,i,t):fa(e,i,t)}}function wa(n){var t;return!!(!((t=n==null?void 0:n.color)===null||t===void 0)&&t.alpha)}function _a(n){return n?t=>Xe(t,"0x"):t=>Ye(t,"0x")}function Ca(n){return"color"in n||n.view==="color"}const xa=L({id:"input-color-number",type:"input",accept:(n,t)=>{if(typeof n!="number"||!Ca(t))return null;const e=Ue(t);return e?{initialValue:n,params:Object.assign(Object.assign({},e),{supportsAlpha:wa(t)})}:null},binding:{reader:n=>n.params.supportsAlpha?ha:da,equals:Ze,writer:n=>ma(n.params.supportsAlpha)},controller:n=>{var t,e;return new Qe(n.document,{colorType:"int",expanded:(t=n.params.expanded)!==null&&t!==void 0?t:!1,formatter:_a(n.params.supportsAlpha),parser:qt("int"),pickerLayout:(e=n.params.picker)!==null&&e!==void 0?e:"popup",supportsAlpha:n.params.supportsAlpha,value:n.value,viewProps:n.viewProps})}});function ya(n,t){if(!Fi(n))return S(v.black(),t);if(t==="int"){const e=yn(n);return new v(e,"rgb")}if(t==="float"){const e=yn(n);return new Ge(e,"rgb")}return S(v.black(),"int")}function Pa(n){return Bi(n)}function Ea(n){return t=>{const e=ya(t,n);return S(e,"int")}}function ka(n,t){return e=>n?Oi(e,t):Ri(e,t)}const Va=L({id:"input-color-object",type:"input",accept:(n,t)=>{var e;if(!Fi(n))return null;const i=Ue(t);return i?{initialValue:n,params:Object.assign(Object.assign({},i),{colorType:(e=_i(t))!==null&&e!==void 0?e:"int"})}:null},binding:{reader:n=>Ea(n.params.colorType),equals:Ze,writer:n=>ga(Pa(n.initialValue),n.params.colorType)},controller:n=>{var t,e;const i=Bi(n.initialValue);return new Qe(n.document,{colorType:n.params.colorType,expanded:(t=n.params.expanded)!==null&&t!==void 0?t:!1,formatter:ka(i,n.params.colorType),parser:qt("int"),pickerLayout:(e=n.params.picker)!==null&&e!==void 0?e:"popup",supportsAlpha:i,value:n.value,viewProps:n.viewProps})}}),Ta=L({id:"input-color-string",type:"input",accept:(n,t)=>{if(typeof n!="string"||t.view==="text")return null;const e=Fo(n,_i(t));if(!e)return null;const i=Di(e);if(!i)return null;const r=Ue(t);return r?{initialValue:n,params:Object.assign(Object.assign({},r),{format:e,stringifier:i})}:null},binding:{reader:()=>Io,equals:Ze,writer:n=>{const t=va(n.params.format);if(!t)throw x.notBindable();return t}},controller:n=>{var t,e;return new Qe(n.document,{colorType:n.params.format.type,expanded:(t=n.params.expanded)!==null&&t!==void 0?t:!1,formatter:n.params.stringifier,parser:qt("int"),pickerLayout:(e=n.params.picker)!==null&&e!==void 0?e:"popup",supportsAlpha:n.params.format.alpha,value:n.value,viewProps:n.viewProps})}});class Je{constructor(t){this.components=t.components,this.asm_=t.assembly}constrain(t){const e=this.asm_.toComponents(t).map((i,r)=>{var s,o;return(o=(s=this.components[r])===null||s===void 0?void 0:s.constrain(i))!==null&&o!==void 0?o:i});return this.asm_.fromComponents(e)}}const Pn=h("pndtxt");class Sa{constructor(t,e){this.textViews=e.textViews,this.element=t.createElement("div"),this.element.classList.add(Pn()),this.textViews.forEach(i=>{const r=t.createElement("div");r.classList.add(Pn("a")),r.appendChild(i.element),this.element.appendChild(r)})}}function La(n,t,e){return new $t(n,{arrayPosition:e===0?"fst":e===t.axes.length-1?"lst":"mid",parser:t.parser,props:t.axes[e].textProps,value:_(0,{constraint:t.axes[e].constraint}),viewProps:t.viewProps})}class tn{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.acs_=e.axes.map((i,r)=>La(t,e,r)),this.acs_.forEach((i,r)=>{Ct({primary:this.value,secondary:i.value,forward:s=>e.assembly.toComponents(s)[r],backward:(s,o)=>{const a=e.assembly.toComponents(s);return a[r]=o,e.assembly.fromComponents(a)}})}),this.view=new Sa(t,{textViews:this.acs_.map(i=>i.view)})}get textControllers(){return this.acs_}}class Aa extends Rt{get max(){return this.controller.valueController.sliderController.props.get("max")}set max(t){this.controller.valueController.sliderController.props.set("max",t)}get min(){return this.controller.valueController.sliderController.props.get("min")}set min(t){this.controller.valueController.sliderController.props.set("min",t)}}function Ra(n,t){const e=[],i=Wn(n,t);i&&e.push(i);const r=Yn(n);r&&e.push(r);const s=qe(n.options);return s&&e.push(s),new Nt(e)}const Oa=L({id:"input-number",type:"input",accept:(n,t)=>{if(typeof n!="number")return null;const e=C(t,i=>Object.assign(Object.assign({},Qn(i)),{options:i.optional.custom(Ht),readonly:i.optional.constant(!1)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>Kn,constraint:n=>Ra(n.params,n.initialValue),writer:n=>Kt},controller:n=>{const t=n.value,e=n.constraint,i=e&&te(e,zt);if(i)return new nt(n.document,{props:new d({options:i.values.value("options")}),value:t,viewProps:n.viewProps});const r=Xn(n.params,t.rawValue),s=e&&te(e,Ft);return s?new ne(n.document,Object.assign(Object.assign({},vi(Object.assign(Object.assign({},r),{keyScale:_(r.keyScale),max:s.values.value("max"),min:s.values.value("min")}))),{parser:G,value:t,viewProps:n.viewProps})):new $t(n.document,{parser:G,props:d.fromObject(r),value:t,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="number"?null:n.controller.valueController instanceof ne?new Aa(n.controller):n.controller.valueController instanceof nt?new $e(n.controller):null}});class tt{constructor(t=0,e=0){this.x=t,this.y=e}getComponents(){return[this.x,this.y]}static isObject(t){if(w(t))return!1;const e=t.x,i=t.y;return!(typeof e!="number"||typeof i!="number")}static equals(t,e){return t.x===e.x&&t.y===e.y}toObject(){return{x:this.x,y:this.y}}}const Ii={toComponents:n=>n.getComponents(),fromComponents:n=>new tt(...n)},ht=h("p2d");class Da{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(ht()),e.viewProps.bindClassModifiers(this.element),U(e.expanded,gt(this.element,ht(void 0,"expanded")));const i=t.createElement("div");i.classList.add(ht("h")),this.element.appendChild(i);const r=t.createElement("button");r.classList.add(ht("b")),r.appendChild(le(t,"p2dpad")),e.viewProps.bindDisabled(r),i.appendChild(r),this.buttonElement=r;const s=t.createElement("div");if(s.classList.add(ht("t")),i.appendChild(s),this.textElement=s,e.pickerLayout==="inline"){const o=t.createElement("div");o.classList.add(ht("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}}const Q=h("p2dp");class Ma{constructor(t,e){this.onFoldableChange_=this.onFoldableChange_.bind(this),this.onPropsChange_=this.onPropsChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.props_=e.props,this.props_.emitter.on("change",this.onPropsChange_),this.element=t.createElement("div"),this.element.classList.add(Q()),e.layout==="popup"&&this.element.classList.add(Q(void 0,"p")),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(Q("p")),e.viewProps.bindTabIndex(i),this.element.appendChild(i),this.padElement=i;const r=t.createElementNS(N,"svg");r.classList.add(Q("g")),this.padElement.appendChild(r),this.svgElem_=r;const s=t.createElementNS(N,"line");s.classList.add(Q("ax")),s.setAttributeNS(null,"x1","0"),s.setAttributeNS(null,"y1","50%"),s.setAttributeNS(null,"x2","100%"),s.setAttributeNS(null,"y2","50%"),this.svgElem_.appendChild(s);const o=t.createElementNS(N,"line");o.classList.add(Q("ax")),o.setAttributeNS(null,"x1","50%"),o.setAttributeNS(null,"y1","0"),o.setAttributeNS(null,"x2","50%"),o.setAttributeNS(null,"y2","100%"),this.svgElem_.appendChild(o);const a=t.createElementNS(N,"line");a.classList.add(Q("l")),a.setAttributeNS(null,"x1","50%"),a.setAttributeNS(null,"y1","50%"),this.svgElem_.appendChild(a),this.lineElem_=a;const l=t.createElement("div");l.classList.add(Q("m")),this.padElement.appendChild(l),this.markerElem_=l,e.value.emitter.on("change",this.onValueChange_),this.value=e.value,this.update_()}get allFocusableElements(){return[this.padElement]}update_(){const[t,e]=this.value.rawValue.getComponents(),i=this.props_.get("max"),r=b(t,-i,+i,0,100),s=b(e,-i,+i,0,100),o=this.props_.get("invertsY")?100-s:s;this.lineElem_.setAttributeNS(null,"x2",`${r}%`),this.lineElem_.setAttributeNS(null,"y2",`${o}%`),this.markerElem_.style.left=`${r}%`,this.markerElem_.style.top=`${o}%`}onValueChange_(){this.update_()}onPropsChange_(){this.update_()}onFoldableChange_(){this.update_()}}function En(n,t,e){return[A(t[0],W(n)),A(t[1],Dt(n))*(e?1:-1)]}class Ba{constructor(t,e){this.onPadKeyDown_=this.onPadKeyDown_.bind(this),this.onPadKeyUp_=this.onPadKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.props=e.props,this.value=e.value,this.viewProps=e.viewProps,this.view=new Ma(t,{layout:e.layout,props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new pt(this.view.padElement),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.padElement.addEventListener("keydown",this.onPadKeyDown_),this.view.padElement.addEventListener("keyup",this.onPadKeyUp_)}handlePointerEvent_(t,e){if(!t.point)return;const i=this.props.get("max"),r=b(t.point.x,0,t.bounds.width,-i,+i),s=b(this.props.get("invertsY")?t.bounds.height-t.point.y:t.point.y,0,t.bounds.height,-i,+i);this.value.setRawValue(new tt(r,s),e)}onPointerDown_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerMove_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerUp_(t){this.handlePointerEvent_(t.data,{forceEmit:!0,last:!0})}onPadKeyDown_(t){hi(t.key)&&t.preventDefault();const[e,i]=En(t,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));e===0&&i===0||this.value.setRawValue(new tt(this.value.rawValue.x+e,this.value.rawValue.y+i),{forceEmit:!1,last:!1})}onPadKeyUp_(t){const[e,i]=En(t,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));e===0&&i===0||this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}class Fa{constructor(t,e){var i,r;this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.onPadButtonBlur_=this.onPadButtonBlur_.bind(this),this.onPadButtonClick_=this.onPadButtonClick_.bind(this),this.value=e.value,this.viewProps=e.viewProps,this.foldable_=jt.create(e.expanded),this.popC_=e.pickerLayout==="popup"?new pi(t,{viewProps:this.viewProps}):null;const s=new Ba(t,{layout:e.pickerLayout,props:new d({invertsY:_(e.invertsY),max:_(e.max),xKeyScale:e.axes[0].textProps.value("keyScale"),yKeyScale:e.axes[1].textProps.value("keyScale")}),value:this.value,viewProps:this.viewProps});s.view.allFocusableElements.forEach(o=>{o.addEventListener("blur",this.onPopupChildBlur_),o.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=s,this.textC_=new tn(t,{assembly:Ii,axes:e.axes,parser:e.parser,value:this.value,viewProps:this.viewProps}),this.view=new Da(t,{expanded:this.foldable_.value("expanded"),pickerLayout:e.pickerLayout,viewProps:this.viewProps}),this.view.textElement.appendChild(this.textC_.view.element),(i=this.view.buttonElement)===null||i===void 0||i.addEventListener("blur",this.onPadButtonBlur_),(r=this.view.buttonElement)===null||r===void 0||r.addEventListener("click",this.onPadButtonClick_),this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(this.pickerC_.view.element),Ct({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:o=>o,backward:(o,a)=>a})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),He(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onPadButtonBlur_(t){if(!this.popC_)return;const e=this.view.element,i=t.relatedTarget;(!i||!e.contains(i))&&(this.popC_.shows.rawValue=!1)}onPadButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.view.allFocusableElements[0].focus()}onPopupChildBlur_(t){if(!this.popC_)return;const e=this.popC_.view.element,i=ei(t);i&&e.contains(i)||i&&i===this.view.buttonElement&&!Be(e.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(t){this.popC_?t.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&t.key==="Escape"&&this.view.buttonElement.focus()}}function Ia(n){return tt.isObject(n)?new tt(n.x,n.y):new tt}function ja(n,t){n.writeProperty("x",t.x),n.writeProperty("y",t.y)}function Na(n,t){return new Je({assembly:Ii,components:[q(Object.assign(Object.assign({},n),n.x),t.x),q(Object.assign(Object.assign({},n),n.y),t.y)]})}function kn(n,t){var e,i;if(!w(n.min)||!w(n.max))return Math.max(Math.abs((e=n.min)!==null&&e!==void 0?e:0),Math.abs((i=n.max)!==null&&i!==void 0?i:0));const r=Un(n);return Math.max(Math.abs(r)*10,Math.abs(t)*10)}function za(n,t){var e,i;const r=kn(ot(n,(e=n.x)!==null&&e!==void 0?e:{}),t.x),s=kn(ot(n,(i=n.y)!==null&&i!==void 0?i:{}),t.y);return Math.max(r,s)}function Ha(n){if(!("y"in n))return!1;const t=n.y;return t&&"inverted"in t?!!t.inverted:!1}const $a=L({id:"input-point2d",type:"input",accept:(n,t)=>{if(!tt.isObject(n))return null;const e=C(t,i=>Object.assign(Object.assign({},Mt(i)),{expanded:i.optional.boolean,picker:i.optional.custom(bi),readonly:i.optional.constant(!1),x:i.optional.custom(J),y:i.optional.object(Object.assign(Object.assign({},Mt(i)),{inverted:i.optional.boolean}))}));return e?{initialValue:n,params:e}:null},binding:{reader:()=>Ia,constraint:n=>Na(n.params,n.initialValue),equals:tt.equals,writer:()=>ja},controller:n=>{var t,e;const i=n.document,r=n.value,s=n.constraint,o=[n.params.x,n.params.y];return new Fa(i,{axes:r.rawValue.getComponents().map((a,l)=>{var c;return Me({constraint:s.components[l],initialValue:a,params:ot(n.params,(c=o[l])!==null&&c!==void 0?c:{})})}),expanded:(t=n.params.expanded)!==null&&t!==void 0?t:!1,invertsY:Ha(n.params),max:za(n.params,r.rawValue),parser:G,pickerLayout:(e=n.params.picker)!==null&&e!==void 0?e:"popup",value:r,viewProps:n.viewProps})}});class mt{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}getComponents(){return[this.x,this.y,this.z]}static isObject(t){if(w(t))return!1;const e=t.x,i=t.y,r=t.z;return!(typeof e!="number"||typeof i!="number"||typeof r!="number")}static equals(t,e){return t.x===e.x&&t.y===e.y&&t.z===e.z}toObject(){return{x:this.x,y:this.y,z:this.z}}}const ji={toComponents:n=>n.getComponents(),fromComponents:n=>new mt(...n)};function Ka(n){return mt.isObject(n)?new mt(n.x,n.y,n.z):new mt}function qa(n,t){n.writeProperty("x",t.x),n.writeProperty("y",t.y),n.writeProperty("z",t.z)}function Ua(n,t){return new Je({assembly:ji,components:[q(Object.assign(Object.assign({},n),n.x),t.x),q(Object.assign(Object.assign({},n),n.y),t.y),q(Object.assign(Object.assign({},n),n.z),t.z)]})}const Ga=L({id:"input-point3d",type:"input",accept:(n,t)=>{if(!mt.isObject(n))return null;const e=C(t,i=>Object.assign(Object.assign({},Mt(i)),{readonly:i.optional.constant(!1),x:i.optional.custom(J),y:i.optional.custom(J),z:i.optional.custom(J)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>Ka,constraint:n=>Ua(n.params,n.initialValue),equals:mt.equals,writer:n=>qa},controller:n=>{const t=n.value,e=n.constraint,i=[n.params.x,n.params.y,n.params.z];return new tn(n.document,{assembly:ji,axes:t.rawValue.getComponents().map((r,s)=>{var o;return Me({constraint:e.components[s],initialValue:r,params:ot(n.params,(o=i[s])!==null&&o!==void 0?o:{})})}),parser:G,value:t,viewProps:n.viewProps})}});class bt{constructor(t=0,e=0,i=0,r=0){this.x=t,this.y=e,this.z=i,this.w=r}getComponents(){return[this.x,this.y,this.z,this.w]}static isObject(t){if(w(t))return!1;const e=t.x,i=t.y,r=t.z,s=t.w;return!(typeof e!="number"||typeof i!="number"||typeof r!="number"||typeof s!="number")}static equals(t,e){return t.x===e.x&&t.y===e.y&&t.z===e.z&&t.w===e.w}toObject(){return{x:this.x,y:this.y,z:this.z,w:this.w}}}const Ni={toComponents:n=>n.getComponents(),fromComponents:n=>new bt(...n)};function Wa(n){return bt.isObject(n)?new bt(n.x,n.y,n.z,n.w):new bt}function Ya(n,t){n.writeProperty("x",t.x),n.writeProperty("y",t.y),n.writeProperty("z",t.z),n.writeProperty("w",t.w)}function Xa(n,t){return new Je({assembly:Ni,components:[q(Object.assign(Object.assign({},n),n.x),t.x),q(Object.assign(Object.assign({},n),n.y),t.y),q(Object.assign(Object.assign({},n),n.z),t.z),q(Object.assign(Object.assign({},n),n.w),t.w)]})}const Qa=L({id:"input-point4d",type:"input",accept:(n,t)=>{if(!bt.isObject(n))return null;const e=C(t,i=>Object.assign(Object.assign({},Mt(i)),{readonly:i.optional.constant(!1),w:i.optional.custom(J),x:i.optional.custom(J),y:i.optional.custom(J),z:i.optional.custom(J)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>Wa,constraint:n=>Xa(n.params,n.initialValue),equals:bt.equals,writer:n=>Ya},controller:n=>{const t=n.value,e=n.constraint,i=[n.params.x,n.params.y,n.params.z,n.params.w];return new tn(n.document,{assembly:Ni,axes:t.rawValue.getComponents().map((r,s)=>{var o;return Me({constraint:e.components[s],initialValue:r,params:ot(n.params,(o=i[s])!==null&&o!==void 0?o:{})})}),parser:G,value:t,viewProps:n.viewProps})}});function Za(n){const t=[],e=qe(n.options);return e&&t.push(e),new Nt(t)}const Ja=L({id:"input-string",type:"input",accept:(n,t)=>{if(typeof n!="string")return null;const e=C(t,i=>({readonly:i.optional.constant(!1),options:i.optional.custom(Ht)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>di,constraint:n=>Za(n.params),writer:n=>Kt},controller:n=>{const t=n.document,e=n.value,i=n.constraint,r=i&&te(i,zt);return r?new nt(t,{props:new d({options:r.values.value("options")}),value:e,viewProps:n.viewProps}):new Ot(t,{parser:s=>s,props:d.fromObject({formatter:Se}),value:e,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="string"?null:n.controller.valueController instanceof nt?new $e(n.controller):null}}),Ut={monitor:{defaultInterval:200,defaultRows:3}},Vn=h("mll");class tl{constructor(t,e){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=e.formatter,this.element=t.createElement("div"),this.element.classList.add(Vn()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("textarea");i.classList.add(Vn("i")),i.style.height=`calc(var(${mi("containerUnitSize")}) * ${e.rows})`,i.readOnly=!0,e.viewProps.bindDisabled(i),this.element.appendChild(i),this.textareaElem_=i,e.value.emitter.on("change",this.onValueUpdate_),this.value=e.value,this.update_()}update_(){const t=this.textareaElem_,e=t.scrollTop===t.scrollHeight-t.clientHeight,i=[];this.value.rawValue.forEach(r=>{r!==void 0&&i.push(this.formatter_(r))}),t.textContent=i.join(` +`),e&&(t.scrollTop=t.scrollHeight)}onValueUpdate_(){this.update_()}}class en{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.view=new tl(t,{formatter:e.formatter,rows:e.rows,value:this.value,viewProps:this.viewProps})}}const Tn=h("sgl");class el{constructor(t,e){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=e.formatter,this.element=t.createElement("div"),this.element.classList.add(Tn()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("input");i.classList.add(Tn("i")),i.readOnly=!0,i.type="text",e.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,e.value.emitter.on("change",this.onValueUpdate_),this.value=e.value,this.update_()}update_(){const t=this.value.rawValue,e=t[t.length-1];this.inputElement.value=e!==void 0?this.formatter_(e):""}onValueUpdate_(){this.update_()}}class nn{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.view=new el(t,{formatter:e.formatter,value:this.value,viewProps:this.viewProps})}}const nl=L({id:"monitor-bool",type:"monitor",accept:(n,t)=>{if(typeof n!="boolean")return null;const e=C(t,i=>({readonly:i.required.constant(!0),rows:i.optional.number}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>ui},controller:n=>{var t;return n.value.rawValue.length===1?new nn(n.document,{formatter:gn,value:n.value,viewProps:n.viewProps}):new en(n.document,{formatter:gn,rows:(t=n.params.rows)!==null&&t!==void 0?t:Ut.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}});class il extends Rt{get max(){return this.controller.valueController.props.get("max")}set max(t){this.controller.valueController.props.set("max",t)}get min(){return this.controller.valueController.props.get("min")}set min(t){this.controller.valueController.props.set("min",t)}}const Z=h("grl");class rl{constructor(t,e){this.onCursorChange_=this.onCursorChange_.bind(this),this.onValueUpdate_=this.onValueUpdate_.bind(this),this.element=t.createElement("div"),this.element.classList.add(Z()),e.viewProps.bindClassModifiers(this.element),this.formatter_=e.formatter,this.props_=e.props,this.cursor_=e.cursor,this.cursor_.emitter.on("change",this.onCursorChange_);const i=t.createElementNS(N,"svg");i.classList.add(Z("g")),i.style.height=`calc(var(${mi("containerUnitSize")}) * ${e.rows})`,this.element.appendChild(i),this.svgElem_=i;const r=t.createElementNS(N,"polyline");this.svgElem_.appendChild(r),this.lineElem_=r;const s=t.createElement("div");s.classList.add(Z("t"),h("tt")()),this.element.appendChild(s),this.tooltipElem_=s,e.value.emitter.on("change",this.onValueUpdate_),this.value=e.value,this.update_()}get graphElement(){return this.svgElem_}update_(){const{clientWidth:t,clientHeight:e}=this.element,i=this.value.rawValue.length-1,r=this.props_.get("min"),s=this.props_.get("max"),o=[];this.value.rawValue.forEach((u,m)=>{if(u===void 0)return;const T=b(m,0,i,0,t),P=b(u,r,s,e,0);o.push([T,P].join(","))}),this.lineElem_.setAttributeNS(null,"points",o.join(" "));const a=this.tooltipElem_,l=this.value.rawValue[this.cursor_.rawValue];if(l===void 0){a.classList.remove(Z("t","a"));return}const c=b(this.cursor_.rawValue,0,i,0,t),p=b(l,r,s,e,0);a.style.left=`${c}px`,a.style.top=`${p}px`,a.textContent=`${this.formatter_(l)}`,a.classList.contains(Z("t","a"))||(a.classList.add(Z("t","a"),Z("t","in")),Jt(a),a.classList.remove(Z("t","in")))}onValueUpdate_(){this.update_()}onCursorChange_(){this.update_()}}class zi{constructor(t,e){if(this.onGraphMouseMove_=this.onGraphMouseMove_.bind(this),this.onGraphMouseLeave_=this.onGraphMouseLeave_.bind(this),this.onGraphPointerDown_=this.onGraphPointerDown_.bind(this),this.onGraphPointerMove_=this.onGraphPointerMove_.bind(this),this.onGraphPointerUp_=this.onGraphPointerUp_.bind(this),this.props=e.props,this.value=e.value,this.viewProps=e.viewProps,this.cursor_=_(-1),this.view=new rl(t,{cursor:this.cursor_,formatter:e.formatter,rows:e.rows,props:this.props,value:this.value,viewProps:this.viewProps}),!Be(t))this.view.element.addEventListener("mousemove",this.onGraphMouseMove_),this.view.element.addEventListener("mouseleave",this.onGraphMouseLeave_);else{const i=new pt(this.view.element);i.emitter.on("down",this.onGraphPointerDown_),i.emitter.on("move",this.onGraphPointerMove_),i.emitter.on("up",this.onGraphPointerUp_)}}importProps(t){return D(t,null,e=>({max:e.required.number,min:e.required.number}),e=>(this.props.set("max",e.max),this.props.set("min",e.min),!0))}exportProps(){return M(null,{max:this.props.get("max"),min:this.props.get("min")})}onGraphMouseLeave_(){this.cursor_.rawValue=-1}onGraphMouseMove_(t){const{clientWidth:e}=this.view.element;this.cursor_.rawValue=Math.floor(b(t.offsetX,0,e,0,this.value.rawValue.length))}onGraphPointerDown_(t){this.onGraphPointerMove_(t)}onGraphPointerMove_(t){if(!t.data.point){this.cursor_.rawValue=-1;return}this.cursor_.rawValue=Math.floor(b(t.data.point.x,0,t.data.bounds.width,0,this.value.rawValue.length))}onGraphPointerUp_(){this.cursor_.rawValue=-1}}function Le(n){return w(n.format)?R(2):n.format}function sl(n){var t;return n.value.rawValue.length===1?new nn(n.document,{formatter:Le(n.params),value:n.value,viewProps:n.viewProps}):new en(n.document,{formatter:Le(n.params),rows:(t=n.params.rows)!==null&&t!==void 0?t:Ut.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}function ol(n){var t,e,i;return new zi(n.document,{formatter:Le(n.params),rows:(t=n.params.rows)!==null&&t!==void 0?t:Ut.monitor.defaultRows,props:d.fromObject({max:(e=n.params.max)!==null&&e!==void 0?e:100,min:(i=n.params.min)!==null&&i!==void 0?i:0}),value:n.value,viewProps:n.viewProps})}function Sn(n){return n.view==="graph"}const al=L({id:"monitor-number",type:"monitor",accept:(n,t)=>{if(typeof n!="number")return null;const e=C(t,i=>({format:i.optional.function,max:i.optional.number,min:i.optional.number,readonly:i.required.constant(!0),rows:i.optional.number,view:i.optional.string}));return e?{initialValue:n,params:e}:null},binding:{defaultBufferSize:n=>Sn(n)?64:1,reader:n=>Kn},controller:n=>Sn(n.params)?ol(n):sl(n),api:n=>n.controller.valueController instanceof zi?new il(n.controller):null}),ll=L({id:"monitor-string",type:"monitor",accept:(n,t)=>{if(typeof n!="string")return null;const e=C(t,i=>({multiline:i.optional.boolean,readonly:i.required.constant(!0),rows:i.optional.number}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>di},controller:n=>{var t;const e=n.value;return e.rawValue.length>1||n.params.multiline?new en(n.document,{formatter:Se,rows:(t=n.params.rows)!==null&&t!==void 0?t:Ut.monitor.defaultRows,value:e,viewProps:n.viewProps}):new nn(n.document,{formatter:Se,value:e,viewProps:n.viewProps})}});class cl{constructor(){this.map_=new Map}get(t){var e;return(e=this.map_.get(t))!==null&&e!==void 0?e:null}has(t){return this.map_.has(t)}add(t,e){return this.map_.set(t,e),t.viewProps.handleDispose(()=>{this.map_.delete(t)}),e}}class pl{constructor(t){this.target=t.target,this.reader_=t.reader,this.writer_=t.writer}read(){return this.reader_(this.target.read())}write(t){this.writer_(this.target,t)}inject(t){this.write(this.reader_(t))}}function ul(n,t){var e;const i=n.accept(t.target.read(),t.params);if(w(i))return null;const r={target:t.target,initialValue:i.initialValue,params:i.params},s=C(t.params,u=>({disabled:u.optional.boolean,hidden:u.optional.boolean,label:u.optional.string,tag:u.optional.string})),o=n.binding.reader(r),a=n.binding.constraint?n.binding.constraint(r):void 0,l=new pl({reader:o,target:t.target,writer:n.binding.writer(r)}),c=new Yr(_(o(i.initialValue),{constraint:a,equals:n.binding.equals}),l),p=n.controller({constraint:a,document:t.document,initialValue:i.initialValue,params:i.params,value:c,viewProps:Y.create({disabled:s==null?void 0:s.disabled,hidden:s==null?void 0:s.hidden})});return new ps(t.document,{blade:_t(),props:d.fromObject({label:"label"in t.params?(e=s==null?void 0:s.label)!==null&&e!==void 0?e:null:t.target.key}),tag:s==null?void 0:s.tag,value:c,valueController:p})}class dl{constructor(t){this.target=t.target,this.reader_=t.reader}read(){return this.reader_(this.target.read())}}function hl(n,t){return t===0?new Us:new Gs(n,t??Ut.monitor.defaultInterval)}function vl(n,t){var e,i,r;const s=n.accept(t.target.read(),t.params);if(w(s))return null;const o={target:t.target,initialValue:s.initialValue,params:s.params},a=C(t.params,m=>({bufferSize:m.optional.number,disabled:m.optional.boolean,hidden:m.optional.boolean,interval:m.optional.number,label:m.optional.string})),l=n.binding.reader(o),c=(i=(e=a==null?void 0:a.bufferSize)!==null&&e!==void 0?e:n.binding.defaultBufferSize&&n.binding.defaultBufferSize(s.params))!==null&&i!==void 0?i:1,p=new ms({binding:new dl({reader:l,target:t.target}),bufferSize:c,ticker:hl(t.document,a==null?void 0:a.interval)}),u=n.controller({document:t.document,params:s.params,value:p,viewProps:Y.create({disabled:a==null?void 0:a.disabled,hidden:a==null?void 0:a.hidden})});return u.viewProps.bindDisabled(p.ticker),u.viewProps.handleDispose(()=>{p.ticker.dispose()}),new fs(t.document,{blade:_t(),props:d.fromObject({label:"label"in t.params?(r=a==null?void 0:a.label)!==null&&r!==void 0?r:null:t.target.key}),value:p,valueController:u})}class ml{constructor(t){this.pluginsMap_={blades:[],inputs:[],monitors:[]},this.apiCache_=t}getAll(){return[...this.pluginsMap_.blades,...this.pluginsMap_.inputs,...this.pluginsMap_.monitors]}register(t,e){if(!oo(e.core))throw x.notCompatible(t,e.id);e.type==="blade"?this.pluginsMap_.blades.unshift(e):e.type==="input"?this.pluginsMap_.inputs.unshift(e):e.type==="monitor"&&this.pluginsMap_.monitors.unshift(e)}createInput_(t,e,i){return this.pluginsMap_.inputs.reduce((r,s)=>r??ul(s,{document:t,target:e,params:i}),null)}createMonitor_(t,e,i){return this.pluginsMap_.monitors.reduce((r,s)=>r??vl(s,{document:t,params:i,target:e}),null)}createBinding(t,e,i){const r=e.read();if(w(r))throw new x({context:{key:e.key},type:"nomatchingcontroller"});const s=this.createInput_(t,e,i);if(s)return s;const o=this.createMonitor_(t,e,i);if(o)return o;throw new x({context:{key:e.key},type:"nomatchingcontroller"})}createBlade(t,e){const i=this.pluginsMap_.blades.reduce((r,s)=>r??qs(s,{document:t,params:e}),null);if(!i)throw new x({type:"nomatchingview",context:{params:e}});return i}createInputBindingApi_(t){const e=this.pluginsMap_.inputs.reduce((i,r)=>{var s,o;return i||((o=(s=r.api)===null||s===void 0?void 0:s.call(r,{controller:t}))!==null&&o!==void 0?o:null)},null);return this.apiCache_.add(t,e??new Rt(t))}createMonitorBindingApi_(t){const e=this.pluginsMap_.monitors.reduce((i,r)=>{var s,o;return i||((o=(s=r.api)===null||s===void 0?void 0:s.call(r,{controller:t}))!==null&&o!==void 0?o:null)},null);return this.apiCache_.add(t,e??new Rt(t))}createBindingApi(t){if(this.apiCache_.has(t))return this.apiCache_.get(t);if(us(t))return this.createInputBindingApi_(t);if(gs(t))return this.createMonitorBindingApi_(t);throw x.shouldNeverHappen()}createApi(t){if(this.apiCache_.has(t))return this.apiCache_.get(t);if(cs(t))return this.createBindingApi(t);const e=this.pluginsMap_.blades.reduce((i,r)=>i??r.api({controller:t,pool:this}),null);if(!e)throw x.shouldNeverHappen();return this.apiCache_.add(t,e)}}const bl=new cl;function fl(){const n=new ml(bl);return[$a,Ga,Qa,Ja,Oa,Ta,Va,xa,po,nl,ll,al,ys,Bs,ci].forEach(t=>{n.register("core",t)}),n}class gl extends ct{constructor(t){super(t),this.emitter_=new E,this.controller.value.emitter.on("change",e=>{this.emitter_.emit("change",new It(this,e.rawValue))})}get label(){return this.controller.labelController.props.get("label")}set label(t){this.controller.labelController.props.set("label",t)}get options(){return this.controller.valueController.props.get("options")}set options(t){this.controller.valueController.props.set("options",t)}get value(){return this.controller.value.rawValue}set value(t){this.controller.value.rawValue=t}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}}class wl extends ct{}class _l extends ct{constructor(t){super(t),this.emitter_=new E,this.controller.value.emitter.on("change",e=>{this.emitter_.emit("change",new It(this,e.rawValue))})}get label(){return this.controller.labelController.props.get("label")}set label(t){this.controller.labelController.props.set("label",t)}get max(){return this.controller.valueController.sliderController.props.get("max")}set max(t){this.controller.valueController.sliderController.props.set("max",t)}get min(){return this.controller.valueController.sliderController.props.get("min")}set min(t){this.controller.valueController.sliderController.props.set("min",t)}get value(){return this.controller.value.rawValue}set value(t){this.controller.value.rawValue=t}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}}class Cl extends ct{constructor(t){super(t),this.emitter_=new E,this.controller.value.emitter.on("change",e=>{this.emitter_.emit("change",new It(this,e.rawValue))})}get label(){return this.controller.labelController.props.get("label")}set label(t){this.controller.labelController.props.set("label",t)}get formatter(){return this.controller.valueController.props.get("formatter")}set formatter(t){this.controller.valueController.props.set("formatter",t)}get value(){return this.controller.value.rawValue}set value(t){this.controller.value.rawValue=t}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}}const xl=function(){return{id:"list",type:"blade",core:wt,accept(n){const t=C(n,e=>({options:e.required.custom(Ht),value:e.required.raw,view:e.required.constant("list"),label:e.optional.string}));return t?{params:t}:null},controller(n){const t=new zt(Ke(n.params.options)),e=_(n.params.value,{constraint:t}),i=new nt(n.document,{props:new d({options:t.values.value("options")}),value:e,viewProps:n.viewProps});return new at(n.document,{blade:n.blade,props:d.fromObject({label:n.params.label}),value:e,valueController:i})},api(n){return!(n.controller instanceof at)||!(n.controller.valueController instanceof nt)?null:new gl(n.controller)}}}();class yl extends ai{constructor(t,e){super(t,e)}get element(){return this.controller.view.element}}class Pl extends Ve{constructor(t,e){super(t,{expanded:e.expanded,blade:e.blade,props:e.props,root:!0,viewProps:e.viewProps})}}const Ln=h("spr");class El{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(Ln()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("hr");i.classList.add(Ln("r")),this.element.appendChild(i)}}class An extends ce{constructor(t,e){super(Object.assign(Object.assign({},e),{view:new El(t,{viewProps:e.viewProps})}))}}const kl={id:"separator",type:"blade",core:wt,accept(n){const t=C(n,e=>({view:e.required.constant("separator")}));return t?{params:t}:null},controller(n){return new An(n.document,{blade:n.blade,viewProps:n.viewProps})},api(n){return n.controller instanceof An?new wl(n.controller):null}},Vl={id:"slider",type:"blade",core:wt,accept(n){const t=C(n,e=>({max:e.required.number,min:e.required.number,view:e.required.constant("slider"),format:e.optional.function,label:e.optional.string,value:e.optional.number}));return t?{params:t}:null},controller(n){var t,e;const i=(t=n.params.value)!==null&&t!==void 0?t:0,r=new Ft({max:n.params.max,min:n.params.min}),s=_(i,{constraint:r}),o=new ne(n.document,Object.assign(Object.assign({},vi({formatter:(e=n.params.format)!==null&&e!==void 0?e:Kr,keyScale:_(1),max:r.values.value("max"),min:r.values.value("min"),pointerScale:Gn(n.params,i)})),{parser:G,value:s,viewProps:n.viewProps}));return new at(n.document,{blade:n.blade,props:d.fromObject({label:n.params.label}),value:s,valueController:o})},api(n){return!(n.controller instanceof at)||!(n.controller.valueController instanceof ne)?null:new _l(n.controller)}},Tl=function(){return{id:"text",type:"blade",core:wt,accept(n){const t=C(n,e=>({parse:e.required.function,value:e.required.raw,view:e.required.constant("text"),format:e.optional.function,label:e.optional.string}));return t?{params:t}:null},controller(n){var t;const e=_(n.params.value),i=new Ot(n.document,{parser:n.params.parse,props:d.fromObject({formatter:(t=n.params.format)!==null&&t!==void 0?t:r=>String(r)}),value:e,viewProps:n.viewProps});return new at(n.document,{blade:n.blade,props:d.fromObject({label:n.params.label}),value:e,valueController:i})},api(n){return!(n.controller instanceof at)||!(n.controller.valueController instanceof Ot)?null:new Cl(n.controller)}}}();function Sl(n){const t=n.createElement("div");return t.classList.add(h("dfw")()),n.body&&n.body.appendChild(t),t}function Ll(n,t,e){if(n.querySelector(`style[data-tp-style=${t}]`))return;const i=n.createElement("style");i.dataset.tpStyle=t,i.textContent=e,n.head.appendChild(i)}class Al extends yl{constructor(t){var e,i;const r=t??{},s=(e=r.document)!==null&&e!==void 0?e:ns(),o=fl(),a=new Pl(s,{expanded:r.expanded,blade:_t(),props:d.fromObject({title:r.title}),viewProps:Y.create()});super(a,o),this.pool_=o,this.containerElem_=(i=r.container)!==null&&i!==void 0?i:Sl(s),this.containerElem_.appendChild(this.element),this.doc_=s,this.usesDefaultWrapper_=!r.container,this.setUpDefaultPlugins_()}get document(){if(!this.doc_)throw x.alreadyDisposed();return this.doc_}dispose(){const t=this.containerElem_;if(!t)throw x.alreadyDisposed();if(this.usesDefaultWrapper_){const e=t.parentElement;e&&e.removeChild(t)}this.containerElem_=null,this.doc_=null,super.dispose()}registerPlugin(t){t.css&&Ll(this.document,`plugin-${t.id}`,t.css),("plugin"in t?[t.plugin]:"plugins"in t?t.plugins:[]).forEach(i=>{this.pool_.register(t.id,i)})}setUpDefaultPlugins_(){this.registerPlugin({id:"default",css:'.tp-tbiv_b,.tp-coltxtv_ms,.tp-colswv_b,.tp-ckbv_i,.tp-sglv_i,.tp-mllv_i,.tp-grlv_g,.tp-txtv_i,.tp-p2dpv_p,.tp-colswv_sw,.tp-rotv_b,.tp-fldv_b,.tp-p2dv_b,.tp-btnv_b,.tp-lstv_s{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0;outline:none;padding:0}.tp-p2dv_b,.tp-btnv_b,.tp-lstv_s{background-color:var(--btn-bg);border-radius:var(--bld-br);color:var(--btn-fg);cursor:pointer;display:block;font-weight:bold;height:var(--cnt-usz);line-height:var(--cnt-usz);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-p2dv_b:hover,.tp-btnv_b:hover,.tp-lstv_s:hover{background-color:var(--btn-bg-h)}.tp-p2dv_b:focus,.tp-btnv_b:focus,.tp-lstv_s:focus{background-color:var(--btn-bg-f)}.tp-p2dv_b:active,.tp-btnv_b:active,.tp-lstv_s:active{background-color:var(--btn-bg-a)}.tp-p2dv_b:disabled,.tp-btnv_b:disabled,.tp-lstv_s:disabled{opacity:.5}.tp-rotv_c>.tp-cntv.tp-v-lst,.tp-tbpv_c>.tp-cntv.tp-v-lst,.tp-fldv_c>.tp-cntv.tp-v-lst{margin-bottom:calc(-1*var(--cnt-vp))}.tp-rotv_c>.tp-fldv.tp-v-lst .tp-fldv_c,.tp-tbpv_c>.tp-fldv.tp-v-lst .tp-fldv_c,.tp-fldv_c>.tp-fldv.tp-v-lst .tp-fldv_c{border-bottom-left-radius:0}.tp-rotv_c>.tp-fldv.tp-v-lst .tp-fldv_b,.tp-tbpv_c>.tp-fldv.tp-v-lst .tp-fldv_b,.tp-fldv_c>.tp-fldv.tp-v-lst .tp-fldv_b{border-bottom-left-radius:0}.tp-rotv_c>*:not(.tp-v-fst),.tp-tbpv_c>*:not(.tp-v-fst),.tp-fldv_c>*:not(.tp-v-fst){margin-top:var(--cnt-usp)}.tp-rotv_c>.tp-sprv:not(.tp-v-fst),.tp-tbpv_c>.tp-sprv:not(.tp-v-fst),.tp-fldv_c>.tp-sprv:not(.tp-v-fst),.tp-rotv_c>.tp-cntv:not(.tp-v-fst),.tp-tbpv_c>.tp-cntv:not(.tp-v-fst),.tp-fldv_c>.tp-cntv:not(.tp-v-fst){margin-top:var(--cnt-vp)}.tp-rotv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-tbpv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-fldv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-rotv_c>.tp-cntv+*:not(.tp-v-hidden),.tp-tbpv_c>.tp-cntv+*:not(.tp-v-hidden),.tp-fldv_c>.tp-cntv+*:not(.tp-v-hidden){margin-top:var(--cnt-vp)}.tp-rotv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-tbpv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-fldv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-rotv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv,.tp-tbpv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv,.tp-fldv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv{margin-top:0}.tp-tbpv_c>.tp-cntv,.tp-fldv_c>.tp-cntv{margin-left:4px}.tp-tbpv_c>.tp-fldv>.tp-fldv_b,.tp-fldv_c>.tp-fldv>.tp-fldv_b{border-top-left-radius:var(--bld-br);border-bottom-left-radius:var(--bld-br)}.tp-tbpv_c>.tp-fldv.tp-fldv-expanded>.tp-fldv_b,.tp-fldv_c>.tp-fldv.tp-fldv-expanded>.tp-fldv_b{border-bottom-left-radius:0}.tp-tbpv_c .tp-fldv>.tp-fldv_c,.tp-fldv_c .tp-fldv>.tp-fldv_c{border-bottom-left-radius:var(--bld-br)}.tp-tbpv_c>.tp-cntv+.tp-fldv>.tp-fldv_b,.tp-fldv_c>.tp-cntv+.tp-fldv>.tp-fldv_b{border-top-left-radius:0}.tp-tbpv_c>.tp-cntv+.tp-tabv>.tp-tabv_t,.tp-fldv_c>.tp-cntv+.tp-tabv>.tp-tabv_t{border-top-left-radius:0}.tp-tbpv_c>.tp-tabv>.tp-tabv_t,.tp-fldv_c>.tp-tabv>.tp-tabv_t{border-top-left-radius:var(--bld-br)}.tp-tbpv_c .tp-tabv>.tp-tabv_c,.tp-fldv_c .tp-tabv>.tp-tabv_c{border-bottom-left-radius:var(--bld-br)}.tp-rotv_b,.tp-fldv_b{background-color:var(--cnt-bg);color:var(--cnt-fg);cursor:pointer;display:block;height:calc(var(--cnt-usz) + 4px);line-height:calc(var(--cnt-usz) + 4px);overflow:hidden;padding-left:var(--cnt-hp);padding-right:calc(4px + var(--cnt-usz) + var(--cnt-hp));position:relative;text-align:left;text-overflow:ellipsis;white-space:nowrap;width:100%;transition:border-radius .2s ease-in-out .2s}.tp-rotv_b:hover,.tp-fldv_b:hover{background-color:var(--cnt-bg-h)}.tp-rotv_b:focus,.tp-fldv_b:focus{background-color:var(--cnt-bg-f)}.tp-rotv_b:active,.tp-fldv_b:active{background-color:var(--cnt-bg-a)}.tp-rotv_b:disabled,.tp-fldv_b:disabled{opacity:.5}.tp-rotv_m,.tp-fldv_m{background:linear-gradient(to left, var(--cnt-fg), var(--cnt-fg) 2px, transparent 2px, transparent 4px, var(--cnt-fg) 4px);border-radius:2px;bottom:0;content:"";display:block;height:6px;right:calc(var(--cnt-hp) + (var(--cnt-usz) + 4px - 6px)/2 - 2px);margin:auto;opacity:.5;position:absolute;top:0;transform:rotate(90deg);transition:transform .2s ease-in-out;width:6px}.tp-rotv.tp-rotv-expanded .tp-rotv_m,.tp-fldv.tp-fldv-expanded>.tp-fldv_b>.tp-fldv_m{transform:none}.tp-rotv_c,.tp-fldv_c{box-sizing:border-box;height:0;opacity:0;overflow:hidden;padding-bottom:0;padding-top:0;position:relative;transition:height .2s ease-in-out,opacity .2s linear,padding .2s ease-in-out}.tp-rotv.tp-rotv-cpl:not(.tp-rotv-expanded) .tp-rotv_c,.tp-fldv.tp-fldv-cpl:not(.tp-fldv-expanded)>.tp-fldv_c{display:none}.tp-rotv.tp-rotv-expanded .tp-rotv_c,.tp-fldv.tp-fldv-expanded>.tp-fldv_c{opacity:1;padding-bottom:var(--cnt-vp);padding-top:var(--cnt-vp);transform:none;overflow:visible;transition:height .2s ease-in-out,opacity .2s linear .2s,padding .2s ease-in-out}.tp-txtv_i,.tp-p2dpv_p,.tp-colswv_sw{background-color:var(--in-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--in-fg);font-family:inherit;height:var(--cnt-usz);line-height:var(--cnt-usz);min-width:0;width:100%}.tp-txtv_i:hover,.tp-p2dpv_p:hover,.tp-colswv_sw:hover{background-color:var(--in-bg-h)}.tp-txtv_i:focus,.tp-p2dpv_p:focus,.tp-colswv_sw:focus{background-color:var(--in-bg-f)}.tp-txtv_i:active,.tp-p2dpv_p:active,.tp-colswv_sw:active{background-color:var(--in-bg-a)}.tp-txtv_i:disabled,.tp-p2dpv_p:disabled,.tp-colswv_sw:disabled{opacity:.5}.tp-lstv,.tp-coltxtv_m{position:relative}.tp-lstv_s{padding:0 20px 0 4px;width:100%}.tp-lstv_m,.tp-coltxtv_mm{bottom:0;margin:auto;pointer-events:none;position:absolute;right:2px;top:0}.tp-lstv_m svg,.tp-coltxtv_mm svg{bottom:0;height:16px;margin:auto;position:absolute;right:0;top:0;width:16px}.tp-lstv_m svg path,.tp-coltxtv_mm svg path{fill:currentColor}.tp-sglv_i,.tp-mllv_i,.tp-grlv_g{background-color:var(--mo-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--mo-fg);height:var(--cnt-usz);scrollbar-color:currentColor rgba(0,0,0,0);scrollbar-width:thin;width:100%}.tp-sglv_i::-webkit-scrollbar,.tp-mllv_i::-webkit-scrollbar,.tp-grlv_g::-webkit-scrollbar{height:8px;width:8px}.tp-sglv_i::-webkit-scrollbar-corner,.tp-mllv_i::-webkit-scrollbar-corner,.tp-grlv_g::-webkit-scrollbar-corner{background-color:rgba(0,0,0,0)}.tp-sglv_i::-webkit-scrollbar-thumb,.tp-mllv_i::-webkit-scrollbar-thumb,.tp-grlv_g::-webkit-scrollbar-thumb{background-clip:padding-box;background-color:currentColor;border:rgba(0,0,0,0) solid 2px;border-radius:4px}.tp-pndtxtv,.tp-coltxtv_w{display:flex}.tp-pndtxtv_a,.tp-coltxtv_c{width:100%}.tp-pndtxtv_a+.tp-pndtxtv_a,.tp-coltxtv_c+.tp-pndtxtv_a,.tp-pndtxtv_a+.tp-coltxtv_c,.tp-coltxtv_c+.tp-coltxtv_c{margin-left:2px}.tp-rotv{--bs-bg: var(--tp-base-background-color, hsl(230, 7%, 17%));--bs-br: var(--tp-base-border-radius, 6px);--bs-ff: var(--tp-base-font-family, Roboto Mono, Source Code Pro, Menlo, Courier, monospace);--bs-sh: var(--tp-base-shadow-color, rgba(0, 0, 0, 0.2));--bld-br: var(--tp-blade-border-radius, 2px);--bld-hp: var(--tp-blade-horizontal-padding, 4px);--bld-vw: var(--tp-blade-value-width, 160px);--btn-bg: var(--tp-button-background-color, hsl(230, 7%, 70%));--btn-bg-a: var(--tp-button-background-color-active, #d6d7db);--btn-bg-f: var(--tp-button-background-color-focus, #c8cad0);--btn-bg-h: var(--tp-button-background-color-hover, #bbbcc4);--btn-fg: var(--tp-button-foreground-color, hsl(230, 7%, 17%));--cnt-bg: var(--tp-container-background-color, rgba(187, 188, 196, 0.1));--cnt-bg-a: var(--tp-container-background-color-active, rgba(187, 188, 196, 0.25));--cnt-bg-f: var(--tp-container-background-color-focus, rgba(187, 188, 196, 0.2));--cnt-bg-h: var(--tp-container-background-color-hover, rgba(187, 188, 196, 0.15));--cnt-fg: var(--tp-container-foreground-color, hsl(230, 7%, 75%));--cnt-hp: var(--tp-container-horizontal-padding, 4px);--cnt-vp: var(--tp-container-vertical-padding, 4px);--cnt-usp: var(--tp-container-unit-spacing, 4px);--cnt-usz: var(--tp-container-unit-size, 20px);--in-bg: var(--tp-input-background-color, rgba(187, 188, 196, 0.1));--in-bg-a: var(--tp-input-background-color-active, rgba(187, 188, 196, 0.25));--in-bg-f: var(--tp-input-background-color-focus, rgba(187, 188, 196, 0.2));--in-bg-h: var(--tp-input-background-color-hover, rgba(187, 188, 196, 0.15));--in-fg: var(--tp-input-foreground-color, hsl(230, 7%, 75%));--lbl-fg: var(--tp-label-foreground-color, rgba(187, 188, 196, 0.7));--mo-bg: var(--tp-monitor-background-color, rgba(0, 0, 0, 0.2));--mo-fg: var(--tp-monitor-foreground-color, rgba(187, 188, 196, 0.7));--grv-fg: var(--tp-groove-foreground-color, rgba(187, 188, 196, 0.1))}.tp-btnv_b{width:100%}.tp-btnv_t{text-align:center}.tp-ckbv_l{display:block;position:relative}.tp-ckbv_i{left:0;opacity:0;position:absolute;top:0}.tp-ckbv_w{background-color:var(--in-bg);border-radius:var(--bld-br);cursor:pointer;display:block;height:var(--cnt-usz);position:relative;width:var(--cnt-usz)}.tp-ckbv_w svg{display:block;height:16px;inset:0;margin:auto;opacity:0;position:absolute;width:16px}.tp-ckbv_w svg path{fill:none;stroke:var(--in-fg);stroke-width:2}.tp-ckbv_i:hover+.tp-ckbv_w{background-color:var(--in-bg-h)}.tp-ckbv_i:focus+.tp-ckbv_w{background-color:var(--in-bg-f)}.tp-ckbv_i:active+.tp-ckbv_w{background-color:var(--in-bg-a)}.tp-ckbv_i:checked+.tp-ckbv_w svg{opacity:1}.tp-ckbv.tp-v-disabled .tp-ckbv_w{opacity:.5}.tp-colv{position:relative}.tp-colv_h{display:flex}.tp-colv_s{flex-grow:0;flex-shrink:0;width:var(--cnt-usz)}.tp-colv_t{flex:1;margin-left:4px}.tp-colv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-colv.tp-colv-expanded.tp-colv-cpl .tp-colv_p{overflow:visible}.tp-colv.tp-colv-expanded .tp-colv_p{margin-top:var(--cnt-usp);opacity:1}.tp-colv .tp-popv{left:calc(-1*var(--cnt-hp));right:calc(-1*var(--cnt-hp));top:var(--cnt-usz)}.tp-colpv_h,.tp-colpv_ap{margin-left:6px;margin-right:6px}.tp-colpv_h{margin-top:var(--cnt-usp)}.tp-colpv_rgb{display:flex;margin-top:var(--cnt-usp);width:100%}.tp-colpv_a{display:flex;margin-top:var(--cnt-vp);padding-top:calc(var(--cnt-vp) + 2px);position:relative}.tp-colpv_a::before{background-color:var(--grv-fg);content:"";height:2px;left:calc(-1*var(--cnt-hp));position:absolute;right:calc(-1*var(--cnt-hp));top:0}.tp-colpv.tp-v-disabled .tp-colpv_a::before{opacity:.5}.tp-colpv_ap{align-items:center;display:flex;flex:3}.tp-colpv_at{flex:1;margin-left:4px}.tp-svpv{border-radius:var(--bld-br);outline:none;overflow:hidden;position:relative}.tp-svpv.tp-v-disabled{opacity:.5}.tp-svpv_c{cursor:crosshair;display:block;height:calc(var(--cnt-usz)*4);width:100%}.tp-svpv_m{border-radius:100%;border:rgba(255,255,255,.75) solid 2px;box-sizing:border-box;filter:drop-shadow(0 0 1px rgba(0, 0, 0, 0.3));height:12px;margin-left:-6px;margin-top:-6px;pointer-events:none;position:absolute;width:12px}.tp-svpv:focus .tp-svpv_m{border-color:#fff}.tp-hplv{cursor:pointer;height:var(--cnt-usz);outline:none;position:relative}.tp-hplv.tp-v-disabled{opacity:.5}.tp-hplv_c{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAABCAYAAABubagXAAAAQ0lEQVQoU2P8z8Dwn0GCgQEDi2OK/RBgYHjBgIpfovFh8j8YBIgzFGQxuqEgPhaDOT5gOhPkdCxOZeBg+IDFZZiGAgCaSSMYtcRHLgAAAABJRU5ErkJggg==);background-position:left top;background-repeat:no-repeat;background-size:100% 100%;border-radius:2px;display:block;height:4px;left:0;margin-top:-2px;position:absolute;top:50%;width:100%}.tp-hplv_m{border-radius:var(--bld-br);border:rgba(255,255,255,.75) solid 2px;box-shadow:0 0 2px rgba(0,0,0,.1);box-sizing:border-box;height:12px;left:50%;margin-left:-6px;margin-top:-6px;pointer-events:none;position:absolute;top:50%;width:12px}.tp-hplv:focus .tp-hplv_m{border-color:#fff}.tp-aplv{cursor:pointer;height:var(--cnt-usz);outline:none;position:relative;width:100%}.tp-aplv.tp-v-disabled{opacity:.5}.tp-aplv_b{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:4px 4px;background-position:0 0,2px 2px;border-radius:2px;display:block;height:4px;left:0;margin-top:-2px;overflow:hidden;position:absolute;top:50%;width:100%}.tp-aplv_c{inset:0;position:absolute}.tp-aplv_m{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:12px 12px;background-position:0 0,6px 6px;border-radius:var(--bld-br);box-shadow:0 0 2px rgba(0,0,0,.1);height:12px;left:50%;margin-left:-6px;margin-top:-6px;overflow:hidden;pointer-events:none;position:absolute;top:50%;width:12px}.tp-aplv_p{border-radius:var(--bld-br);border:rgba(255,255,255,.75) solid 2px;box-sizing:border-box;inset:0;position:absolute}.tp-aplv:focus .tp-aplv_p{border-color:#fff}.tp-colswv{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:10px 10px;background-position:0 0,5px 5px;border-radius:var(--bld-br);overflow:hidden}.tp-colswv.tp-v-disabled{opacity:.5}.tp-colswv_sw{border-radius:0}.tp-colswv_b{cursor:pointer;display:block;height:var(--cnt-usz);left:0;position:absolute;top:0;width:var(--cnt-usz)}.tp-colswv_b:focus::after{border:rgba(255,255,255,.75) solid 2px;border-radius:var(--bld-br);content:"";display:block;inset:0;position:absolute}.tp-coltxtv{display:flex;width:100%}.tp-coltxtv_m{margin-right:4px}.tp-coltxtv_ms{border-radius:var(--bld-br);color:var(--lbl-fg);cursor:pointer;height:var(--cnt-usz);line-height:var(--cnt-usz);padding:0 18px 0 4px}.tp-coltxtv_ms:hover{background-color:var(--in-bg-h)}.tp-coltxtv_ms:focus{background-color:var(--in-bg-f)}.tp-coltxtv_ms:active{background-color:var(--in-bg-a)}.tp-coltxtv_mm{color:var(--lbl-fg)}.tp-coltxtv.tp-v-disabled .tp-coltxtv_mm{opacity:.5}.tp-coltxtv_w{flex:1}.tp-dfwv{position:absolute;top:8px;right:8px;width:256px}.tp-fldv{position:relative}.tp-fldv_t{padding-left:4px}.tp-fldv_b:disabled .tp-fldv_m{display:none}.tp-fldv_c{padding-left:4px}.tp-fldv_i{bottom:0;color:var(--cnt-bg);left:0;overflow:hidden;position:absolute;top:calc(var(--cnt-usz) + 4px);width:max(var(--bs-br),4px)}.tp-fldv_i::before{background-color:currentColor;bottom:0;content:"";left:0;position:absolute;top:0;width:4px}.tp-fldv_b:hover+.tp-fldv_i{color:var(--cnt-bg-h)}.tp-fldv_b:focus+.tp-fldv_i{color:var(--cnt-bg-f)}.tp-fldv_b:active+.tp-fldv_i{color:var(--cnt-bg-a)}.tp-fldv.tp-v-disabled>.tp-fldv_i{opacity:.5}.tp-grlv{position:relative}.tp-grlv_g{display:block;height:calc(var(--cnt-usz)*3)}.tp-grlv_g polyline{fill:none;stroke:var(--mo-fg);stroke-linejoin:round}.tp-grlv_t{margin-top:-4px;transition:left .05s,top .05s;visibility:hidden}.tp-grlv_t.tp-grlv_t-a{visibility:visible}.tp-grlv_t.tp-grlv_t-in{transition:none}.tp-grlv.tp-v-disabled .tp-grlv_g{opacity:.5}.tp-grlv .tp-ttv{background-color:var(--mo-fg)}.tp-grlv .tp-ttv::before{border-top-color:var(--mo-fg)}.tp-lblv{align-items:center;display:flex;line-height:1.3;padding-left:var(--cnt-hp);padding-right:var(--cnt-hp)}.tp-lblv.tp-lblv-nol{display:block}.tp-lblv_l{color:var(--lbl-fg);flex:1;-webkit-hyphens:auto;hyphens:auto;overflow:hidden;padding-left:4px;padding-right:16px}.tp-lblv.tp-v-disabled .tp-lblv_l{opacity:.5}.tp-lblv.tp-lblv-nol .tp-lblv_l{display:none}.tp-lblv_v{align-self:flex-start;flex-grow:0;flex-shrink:0;width:var(--bld-vw)}.tp-lblv.tp-lblv-nol .tp-lblv_v{width:100%}.tp-lstv_s{padding:0 20px 0 var(--bld-hp);width:100%}.tp-lstv_m{color:var(--btn-fg)}.tp-sglv_i{padding-left:var(--bld-hp);padding-right:var(--bld-hp)}.tp-sglv.tp-v-disabled .tp-sglv_i{opacity:.5}.tp-mllv_i{display:block;height:calc(var(--cnt-usz)*3);line-height:var(--cnt-usz);padding-left:var(--bld-hp);padding-right:var(--bld-hp);resize:none;white-space:pre}.tp-mllv.tp-v-disabled .tp-mllv_i{opacity:.5}.tp-p2dv{position:relative}.tp-p2dv_h{display:flex}.tp-p2dv_b{height:var(--cnt-usz);margin-right:4px;position:relative;width:var(--cnt-usz)}.tp-p2dv_b svg{display:block;height:16px;left:50%;margin-left:-8px;margin-top:-8px;position:absolute;top:50%;width:16px}.tp-p2dv_b svg path{stroke:currentColor;stroke-width:2}.tp-p2dv_b svg circle{fill:currentColor}.tp-p2dv_t{flex:1}.tp-p2dv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-p2dv.tp-p2dv-expanded .tp-p2dv_p{margin-top:var(--cnt-usp);opacity:1}.tp-p2dv .tp-popv{left:calc(-1*var(--cnt-hp));right:calc(-1*var(--cnt-hp));top:var(--cnt-usz)}.tp-p2dpv{padding-left:calc(var(--cnt-usz) + 4px)}.tp-p2dpv_p{cursor:crosshair;height:0;overflow:hidden;padding-bottom:100%;position:relative}.tp-p2dpv.tp-v-disabled .tp-p2dpv_p{opacity:.5}.tp-p2dpv_g{display:block;height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%}.tp-p2dpv_ax{opacity:.1;stroke:var(--in-fg);stroke-dasharray:1}.tp-p2dpv_l{opacity:.5;stroke:var(--in-fg);stroke-dasharray:1}.tp-p2dpv_m{border:var(--in-fg) solid 1px;border-radius:50%;box-sizing:border-box;height:4px;margin-left:-2px;margin-top:-2px;position:absolute;width:4px}.tp-p2dpv_p:focus .tp-p2dpv_m{background-color:var(--in-fg);border-width:0}.tp-popv{background-color:var(--bs-bg);border-radius:var(--bs-br);box-shadow:0 2px 4px var(--bs-sh);display:none;max-width:var(--bld-vw);padding:var(--cnt-vp) var(--cnt-hp);position:absolute;visibility:hidden;z-index:1000}.tp-popv.tp-popv-v{display:block;visibility:visible}.tp-sldv.tp-v-disabled{opacity:.5}.tp-sldv_t{box-sizing:border-box;cursor:pointer;height:var(--cnt-usz);margin:0 6px;outline:none;position:relative}.tp-sldv_t::before{background-color:var(--in-bg);border-radius:1px;content:"";display:block;height:2px;inset:0;margin:auto;position:absolute}.tp-sldv_k{height:100%;left:0;position:absolute;top:0}.tp-sldv_k::before{background-color:var(--in-fg);border-radius:1px;content:"";display:block;height:2px;inset:0;margin-bottom:auto;margin-top:auto;position:absolute}.tp-sldv_k::after{background-color:var(--btn-bg);border-radius:var(--bld-br);bottom:0;content:"";display:block;height:12px;margin-bottom:auto;margin-top:auto;position:absolute;right:-6px;top:0;width:12px}.tp-sldv_t:hover .tp-sldv_k::after{background-color:var(--btn-bg-h)}.tp-sldv_t:focus .tp-sldv_k::after{background-color:var(--btn-bg-f)}.tp-sldv_t:active .tp-sldv_k::after{background-color:var(--btn-bg-a)}.tp-sldtxtv{display:flex}.tp-sldtxtv_s{flex:2}.tp-sldtxtv_t{flex:1;margin-left:4px}.tp-tabv{position:relative}.tp-tabv_t{align-items:flex-end;color:var(--cnt-bg);display:flex;overflow:hidden;position:relative}.tp-tabv_t:hover{color:var(--cnt-bg-h)}.tp-tabv_t:has(*:focus){color:var(--cnt-bg-f)}.tp-tabv_t:has(*:active){color:var(--cnt-bg-a)}.tp-tabv_t::before{background-color:currentColor;bottom:0;content:"";height:2px;left:0;pointer-events:none;position:absolute;right:0}.tp-tabv.tp-v-disabled .tp-tabv_t::before{opacity:.5}.tp-tabv.tp-tabv-nop .tp-tabv_t{height:calc(var(--cnt-usz) + 4px);position:relative}.tp-tabv.tp-tabv-nop .tp-tabv_t::before{background-color:var(--cnt-bg);bottom:0;content:"";height:2px;left:0;position:absolute;right:0}.tp-tabv_i{bottom:0;color:var(--cnt-bg);left:0;overflow:hidden;position:absolute;top:calc(var(--cnt-usz) + 4px);width:max(var(--bs-br),4px)}.tp-tabv_i::before{background-color:currentColor;bottom:0;content:"";left:0;position:absolute;top:0;width:4px}.tp-tabv_t:hover+.tp-tabv_i{color:var(--cnt-bg-h)}.tp-tabv_t:has(*:focus)+.tp-tabv_i{color:var(--cnt-bg-f)}.tp-tabv_t:has(*:active)+.tp-tabv_i{color:var(--cnt-bg-a)}.tp-tabv.tp-v-disabled>.tp-tabv_i{opacity:.5}.tp-tbiv{flex:1;min-width:0;position:relative}.tp-tbiv+.tp-tbiv{margin-left:2px}.tp-tbiv+.tp-tbiv.tp-v-disabled::before{opacity:.5}.tp-tbiv_b{display:block;padding-left:calc(var(--cnt-hp) + 4px);padding-right:calc(var(--cnt-hp) + 4px);position:relative;width:100%}.tp-tbiv_b:disabled{opacity:.5}.tp-tbiv_b::before{background-color:var(--cnt-bg);content:"";inset:0 0 2px;pointer-events:none;position:absolute}.tp-tbiv_b:hover::before{background-color:var(--cnt-bg-h)}.tp-tbiv_b:focus::before{background-color:var(--cnt-bg-f)}.tp-tbiv_b:active::before{background-color:var(--cnt-bg-a)}.tp-tbiv_t{color:var(--cnt-fg);height:calc(var(--cnt-usz) + 4px);line-height:calc(var(--cnt-usz) + 4px);opacity:.5;overflow:hidden;position:relative;text-overflow:ellipsis}.tp-tbiv.tp-tbiv-sel .tp-tbiv_t{opacity:1}.tp-tbpv_c{padding-bottom:var(--cnt-vp);padding-left:4px;padding-top:var(--cnt-vp)}.tp-txtv{position:relative}.tp-txtv_i{padding-left:var(--bld-hp);padding-right:var(--bld-hp)}.tp-txtv.tp-txtv-fst .tp-txtv_i{border-bottom-right-radius:0;border-top-right-radius:0}.tp-txtv.tp-txtv-mid .tp-txtv_i{border-radius:0}.tp-txtv.tp-txtv-lst .tp-txtv_i{border-bottom-left-radius:0;border-top-left-radius:0}.tp-txtv.tp-txtv-num .tp-txtv_i{text-align:right}.tp-txtv.tp-txtv-drg .tp-txtv_i{opacity:.3}.tp-txtv_k{cursor:pointer;height:100%;left:calc(var(--bld-hp) - 5px);position:absolute;top:0;width:12px}.tp-txtv_k::before{background-color:var(--in-fg);border-radius:1px;bottom:0;content:"";height:calc(var(--cnt-usz) - 4px);left:50%;margin-bottom:auto;margin-left:-1px;margin-top:auto;opacity:.1;position:absolute;top:0;transition:border-radius .1s,height .1s,transform .1s,width .1s;width:2px}.tp-txtv_k:hover::before,.tp-txtv.tp-txtv-drg .tp-txtv_k::before{opacity:1}.tp-txtv.tp-txtv-drg .tp-txtv_k::before{border-radius:50%;height:4px;transform:translateX(-1px);width:4px}.tp-txtv_g{bottom:0;display:block;height:8px;left:50%;margin:auto;overflow:visible;pointer-events:none;position:absolute;top:0;visibility:hidden;width:100%}.tp-txtv.tp-txtv-drg .tp-txtv_g{visibility:visible}.tp-txtv_gb{fill:none;stroke:var(--in-fg);stroke-dasharray:1}.tp-txtv_gh{fill:none;stroke:var(--in-fg)}.tp-txtv .tp-ttv{margin-left:6px;visibility:hidden}.tp-txtv.tp-txtv-drg .tp-ttv{visibility:visible}.tp-ttv{background-color:var(--in-fg);border-radius:var(--bld-br);color:var(--bs-bg);padding:2px 4px;pointer-events:none;position:absolute;transform:translate(-50%, -100%)}.tp-ttv::before{border-color:var(--in-fg) rgba(0,0,0,0) rgba(0,0,0,0) rgba(0,0,0,0);border-style:solid;border-width:2px;box-sizing:border-box;content:"";font-size:.9em;height:4px;left:50%;margin-left:-2px;position:absolute;top:100%;width:4px}.tp-rotv{background-color:var(--bs-bg);border-radius:var(--bs-br);box-shadow:0 2px 4px var(--bs-sh);font-family:var(--bs-ff);font-size:11px;font-weight:500;line-height:1;text-align:left}.tp-rotv_b{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br);border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br);padding-left:calc(4px + var(--cnt-usz) + var(--cnt-hp));text-align:center}.tp-rotv.tp-rotv-expanded .tp-rotv_b{border-bottom-left-radius:0;border-bottom-right-radius:0;transition-delay:0s;transition-duration:0s}.tp-rotv.tp-rotv-not>.tp-rotv_b{display:none}.tp-rotv_b:disabled .tp-rotv_m{display:none}.tp-rotv_c>.tp-fldv.tp-v-lst>.tp-fldv_c{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst>.tp-fldv_i{border-bottom-left-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst:not(.tp-fldv-expanded)>.tp-fldv_b{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst.tp-fldv-expanded>.tp-fldv_b{transition-delay:0s;transition-duration:0s}.tp-rotv_c .tp-fldv.tp-v-vlst:not(.tp-fldv-expanded)>.tp-fldv_b{border-bottom-right-radius:var(--bs-br)}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-fldv.tp-v-fst{margin-top:calc(-1*var(--cnt-vp))}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-fldv.tp-v-fst>.tp-fldv_b{border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br)}.tp-rotv_c>.tp-tabv.tp-v-lst>.tp-tabv_c{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-tabv.tp-v-lst>.tp-tabv_i{border-bottom-left-radius:var(--bs-br)}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-tabv.tp-v-fst{margin-top:calc(-1*var(--cnt-vp))}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-tabv.tp-v-fst>.tp-tabv_t{border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br)}.tp-rotv.tp-v-disabled,.tp-rotv .tp-v-disabled{pointer-events:none}.tp-rotv.tp-v-hidden,.tp-rotv .tp-v-hidden{display:none}.tp-sprv_r{background-color:var(--grv-fg);border-width:0;display:block;height:2px;margin:0;width:100%}.tp-sprv.tp-v-disabled .tp-sprv_r{opacity:.5}',plugins:[xl,kl,Vl,ci,Tl]})}}new oi("4.0.4");const et={sceneChange:"scene-change",instrumentPlayed:"instrument-played"},Vt=class Vt{constructor(t){g(this,"pane");g(this,"sceneControls",{});this.game=t;const e=document.getElementById("settings");if(!e)throw new Error("No settings container found");this.pane=new Al({title:"settings",expanded:!1,container:e}),t.events.on(et.sceneChange,r=>{Object.values(this.sceneControls).filter(Boolean).forEach(s=>{s.dispose(),this.pane.remove(s)}),r&&(this.sceneControls.deleteLoop=this.pane.addButton({title:"Delete current loop",index:0}).on("click",()=>V.deleteCurrentTrack()),this.sceneControls.deleteInstrument=this.pane.addButton({title:"Delete instrument & loop",index:0}).on("click",()=>V.deleteCurrentInstrumentScene()),this.sceneControls.volume=this.pane.addBinding(r,"volume",{min:0,max:100,step:1,index:0}))}),window.onerror=function(r,s,o,a,l){j.error(` +`+r+" "+s+" "+o+" "+a+" "+l)},this.pane.addButton({title:"Show logs"}).on("click",()=>{i.hidden=!i.hidden});const i=this.pane.addBinding(Vt.logsParams,"logs",{label:"",readonly:!0,multiline:!0,rows:10,hidden:!0});this.resize()}static log(t){Vt.logsParams.logs+=` +`+t}resize(){const t=Math.min(this.game.canvas.width,this.game.canvas.height),e=t/40+"px",i=t/10+"px";document.querySelectorAll("button").forEach(r=>{r.style.fontSize=e,r.style.height=i})}};g(Vt,"logsParams",{logs:""});let ie=Vt;const we=(n,t)=>{ie.log(t.map(e=>e.toString()).join(", ")),console[n](...t)},j={log:(n,...t)=>{we("log",[n,...t])},error:(n,...t)=>{we("error",[n,...t])},warn:(n,...t)=>{we("warn",[n,...t])}},Rn={hihat:ir,kick:rr,snare:sr,crash:or,"hihat-open":ar,ride:lr,"tom-low":Nn,"tom-high":cr},Rl=(n,t)=>{try{Rn[n](t)}catch(e){j.error(`Error playing ${n}`,e),nr(),Rn[n](t)}},Hi=(n,t,e)=>{const i=[];for(let s=0;si.map(a=>a[o]).reverse()).flat()};class $i extends y.Scene{constructor(e,i){super();g(this,"pads",[]);g(this,"config");g(this,"settings",{volume:75});this.cols=e,this.rows=i}create(e){this.config=e,this.createPads(),this.game.events.emit(et.sceneChange,this.settings)}createPads(){const e=this.cols*this.rows;this.pads=new Array(e).fill(0).map((r,s)=>this.createPad(s,e));const i=()=>{const r=window.innerWidth{const T=m%s*a,P=Math.floor(m/s)*l,O=r?0:V.sceneWidthHeight,ut=r?V.sceneWidthHeight:0;p.setSize(a,l).setPosition(O+T,ut+P),u&&u.setPosition(p.getCenter().x,p.getCenter().y).setFontSize(Qt.tiny).setResolution(2)})};window.addEventListener("resize",i),i()}createPad(e,i){var T;const r=this.getPadColor(i,e),s=(T=this.getPadText)==null?void 0:T.call(this,e),o=r.color,a=r.brighten(40).color,l=this.add.rectangle().setFillStyle(o).setStrokeStyle(2,K("#FFF"),.8).setInteractive().setOrigin(0,0);let c;s&&(c=this.add.text(0,0,s,{fontFamily:St.Text,fontSize:Qt.tiny,color:ye.white}).setAlpha(.5).setOrigin(.5,.5).setResolution(2).setPosition(l.getCenter().x,l.getCenter().y).setDepth(1));let p=!1;const u=()=>{p||(this.playSound(e),l.setFillStyle(a),this.game.events.emit(et.instrumentPlayed,{callback:()=>this.playSound(e),scene:this}),p=!0)},m=()=>{l.setFillStyle(o),p=!1};return l.on("pointerdown",P=>{var O,ut;((ut=(O=P.downElement)==null?void 0:O.tagName)==null?void 0:ut.toLowerCase())==="canvas"&&u()}).on("pointermove",P=>{P.isDown&&u()}).on("pointerup",()=>m()).on("pointerout",()=>m()),{instrument:e,button:l,text:c}}getPadColor(e,i){return y.Display.Color.HSLToColor((e-i)/(e*1.5),1,.5)}getPadText(e){}}const Ol={hihat:"#FDA341",kick:"#F24E1E",snare:"#4A90E2",crash:"#A0D8C5","hihat-open":"#F9F871",ride:"#F5C542","tom-low":"#FF7F50","tom-high":"#9B59B6"};class On extends $i{constructor(){super(2,4);g(this,"instruments",["crash","ride","hihat-open","hihat","snare","tom-low","tom-high","kick"])}create(e){super.create(e)}getPadColor(e,i){var s;const r=K(Ol[this.instruments[i]],((s=this.config)==null?void 0:s.type)==="drums");return y.Display.Color.IntegerToColor(r)}playSound(e){Rl(this.instruments[e],this.settings.volume)}}let kt=null,_e=null;const Dn=()=>{kt&&(j.log("stopping note...",kt),kt.stop(),_e.stop()),j.log("testing note...");const n=22050,t=Freeverb({input:Bus2(),roomSize:.975,damping:.5}).connect(),e=Synth({gain:.15,attack:44,decay:5512,Q:.8,filterType:2,saturation:2,filterMult:3.25,antialias:!0,cutoff:Add(1,Sine({frequency:.1,gain:.75}))}).connect(Gibberish.output).connect(t.input,.5),i=[55,110,165,220];_e=Sequencer.make([55,110,165,220],[n/4],e,"note").start(),kt=Sequencer.make([i.map(r=>r*1.25),i.map(r=>r*1.25*.8),i.map(r=>r*1.25*.8*.8),i.map(r=>r*1.25*.8*.8*1.25)],[n*16],_e,"values"),kt.start()};class Dl extends y.Scene{constructor(){super();g(this,"isGibberishLoaded",!1)}create({numberOfPads:e=8}){this.createPads(e),this.game.events.emit(et.sceneChange)}createPads(e){const i=new Array(e).fill(0).map((s,o)=>this.createPad(o)),r=()=>{const s=window.innerWidth{const T=m%o*l,P=Math.floor(m/o)*c,O=s?0:V.sceneWidthHeight,ut=s?V.sceneWidthHeight:0;u.setSize(l,c).setPosition(O+T,ut+P)})};window.addEventListener("resize",r),r()}createPad(e){const i=y.Display.Color.HSLToColor(e/16,1,.5),r=i.darken(40).color,s=i.brighten(4).color,o=this.add.rectangle().setFillStyle(r).setStrokeStyle(2,K("#FFF"),.8).setInteractive().setOrigin(0,0);return o.on("pointerdown",a=>{var l,c;((c=(l=a.downElement)==null?void 0:l.tagName)==null?void 0:c.toLowerCase())==="canvas"&&(this.isGibberishLoaded?Dn():(this.isGibberishLoaded=!0,Gibberish.workletPath="./worklet.js",j.log("loading Gibberish 2..."),Gibberish.init().then(()=>{j.log("Gibberish is ready!"),Gibberish.export(window),Dn()}).catch(p=>j.error("oops",p))),o.setFillStyle(s))}).on("pointerup",()=>o.setFillStyle(r)).on("pointerout",()=>o.setFillStyle(r)),{instrument:e,button:o}}}function Ml(){const n=[];for(let t=0;t<9;t++)n[t]={};return n[2].C=65.40639132514966,n[2]["C#"]=69.29565774421802,n[2].D=73.4161919793519,n[2]["D#"]=77.78174593052023,n[2].E=82.40688922821748,n[2].F=87.30705785825097,n[2]["F#"]=92.4986056779086,n[2].G=97.99885899543732,n[2]["G#"]=103.82617439498628,n[2].A=110,n[2]["A#"]=116.54094037952248,n[2].B=123.47082531403103,n[3].C=130.8127826502993,n[3]["C#"]=138.59131548843604,n[3].D=146.8323839587038,n[3]["D#"]=155.56349186104046,n[3].E=164.81377845643496,n[3].F=174.61411571650194,n[3]["F#"]=184.9972113558172,n[3].G=195.99771799087463,n[3]["G#"]=207.65234878997256,n[3].A=220,n[3]["A#"]=233.08188075904496,n[3].B=246.94165062806206,n[4].C=261.6255653005986,n[4]["C#"]=277.1826309768721,n[4].D=293.6647679174076,n[4]["D#"]=311.1269837220809,n[4].E=329.6275569128699,n[4].F=349.2282314330039,n[4]["F#"]=369.9944227116344,n[4].G=391.99543598174927,n[4]["G#"]=415.3046975799451,n[4].A=440,n[4]["A#"]=466.1637615180899,n[4].B=493.8833012561241,n[5].C=523.2511306011972,n[5]["C#"]=554.3652619537442,n[5].D=587.3295358348151,n[5]["D#"]=622.2539674441618,n[5].E=659.2551138257398,n[5].F=698.4564628660078,n[5]["F#"]=739.9888454232688,n[5].G=783.9908719634985,n[5]["G#"]=830.6093951598903,n[5].A=880,n[5]["A#"]=932.3275230361799,n[5].B=987.7666025122483,n[6].C=1046.5022612023945,n[6]["C#"]=1108.7305239074883,n[6].D=1174.6590716696303,n[6]["D#"]=1244.5079348883237,n[6].E=1318.5102276514797,n[6].F=1396.9129257320155,n[6]["F#"]=1479.9776908465376,n[6].G=1567.981743926997,n[6]["G#"]=1661.2187903197805,n[6].A=1760,n[6]["A#"]=1864.6550460723597,n[6].B=1975.5332050244965,n[7].C=2093.004522404789,n[7]["C#"]=2217.4610478149766,n[7].D=2349.3181433392606,n[7]["D#"]=2489.0158697766474,n[7].E=2637.0204553029594,n[7].F=2793.825851464031,n[7]["F#"]=2959.955381693075,n[7].G=3135.963487853994,n[7]["G#"]=3322.437580639561,n[7].A=3520,n[7]["A#"]=3729.3100921447194,n[7].B=3951.066410048993,n}const Bl=Ml(),Ce=Bl.flatMap(n=>Object.entries(n)).map(([n,t])=>({key:n,freq:t})).filter(({freq:n})=>!!n).sort((n,t)=>n.freq-t.freq);class Fl extends $i{constructor(){super(6,12)}create(){super.create()}getPadText(t){const e=Ce[t];return e==null?void 0:e.key}getPadColor(t,e){var s;const i=super.getPadColor(t,e),r=(s=Ce[e])==null?void 0:s.key;return r!=null&&r.includes("#")?i.darken(150):i.darken(60)}playSound(t){const e=Ce[t].freq;return j.log("Playing note",e),Il(e,this.settings.volume)}}const Il=(n,t)=>{const e=it(),i=e.createOscillator();i.type="sine";const r=e.createGain();i.frequency.setValueAtTime(n,e.currentTime),i.connect(r),r.connect(e.destination);const s=.02,o=1.5;r.gain.setValueAtTime(0,e.currentTime),r.gain.linearRampToValueAtTime(t/100,e.currentTime+s),r.gain.exponentialRampToValueAtTime(1e-4,e.currentTime+o),i.start(e.currentTime),i.stop(e.currentTime+o)},se=class se extends y.Scene{constructor(){super(se.key);g(this,"rowNumber",5);g(this,"colNumber",5);g(this,"instrumentButtons")}create({index:e}){this.scene.bringToTop(),this.game.events.emit(et.sceneChange),this.cameras.main.setOrigin(0,0).setBackgroundColor("#147"),this.createMatrix();const i=this.instrumentButtons[2][1];i.setData("text",this.addText(i,"Simple Synth"));const r=this.instrumentButtons[1][2];r.setData("text",this.addText(r,"Drums"));const s=this.instrumentButtons[3][2];s.setData("text",this.addText(s,"Other Drums"));const o=this.instrumentButtons[2][3];o.setData("text",this.addText(o,"Gibberish")),[r,s,o,i].forEach(c=>c.setFillStyle(K("#FFF"),.5).setInteractive().on(y.Input.Events.POINTER_DOWN,()=>{this.scene.setVisible(!1)}));const l=V.getTrackSceneKey(e);r.on(y.Input.Events.POINTER_UP,()=>{this.scene.add(l,On,!0,{type:"drums"})}),s.on(y.Input.Events.POINTER_UP,()=>{this.scene.add(l,On,!0,{type:"other"})}),o.on(y.Input.Events.POINTER_UP,()=>{this.scene.add(l,Dl,!0,{numberOfPads:8})}),i.on(y.Input.Events.POINTER_UP,()=>{this.scene.add(l,Fl,!0)}),window.addEventListener("resize",()=>this.resizeScene()),this.resizeScene()}createMatrix(){this.instrumentButtons=[];for(let e=0;e{p.forEach((m,T)=>{m.setSize(r,s).setPosition(r*u,s*T);const P=m.getData("text");if(P){const O=Math.min(m.height,m.width)/5;P.setFontSize(O).setResolution(2).setWordWrapWidth(m.width,!0).setSize(m.width,m.height).setPosition(m.getCenter().x,m.getCenter().y)}})});const o=e?window.innerWidth:window.innerWidth-i,a=e?window.innerHeight-i:window.innerHeight,l=e?0:i,c=e?i:0;this.cameras.main.setPosition(l,c).setViewport(l,c,o,a)}};g(se,"key","EmptyScene");let Bt=se;const I=class I{constructor(t){g(this,"state","readyToRecord");g(this,"events",[]);g(this,"eventEmitter",new y.Events.EventEmitter);g(this,"startRecordingTime");g(this,"startPlayingTime",0);g(this,"currentLoopIndex",0);g(this,"loopTimeout",null);this.trackIndex=t,this.log("Loop created")}getStartPlayingTime(){return this.startPlayingTime}getLoopLength(){var t;return(t=this.events.find(({callback:e})=>e==="endOfLoop"))==null?void 0:t.time}handleClick(){switch(this.nextState(),this.state){case"recording":this.startRecording();break;case"playing":this.startPlaying();break;case"readyToPlay":this.stopPlaying();break}}addLoopEvent(t){if(this.isRecording()){this.startRecordingTime||(this.startRecordingTime=I.masterLoop.getStartPlayingTime());const e=Date.now()-this.startRecordingTime;this.events.push({callback:t,time:e}),this.log(`Recording ${t} at time ${e}ms`)}}isPlaying(){return this.state==="playing"}isReadyToPlay(){return this.state==="readyToPlay"}isRecording(){return this.state==="recording"}isReadyToRecord(){return this.state==="readyToRecord"}destroy(){this.eventEmitter.removeAllListeners(),this.isPlaying()&&this.stopPlaying(),this.events=[],this.isMasterLoop()&&(I.masterLoop=null),this.log("Loop destroyed")}addEventListener(t,e){this.eventEmitter.once(t,e)}nextState(){switch(this.state){case"readyToRecord":this.state="recording";break;case"recording":this.state=this.stopRecording();break;case"readyToPlay":this.state="playing";break;case"playing":this.state="readyToPlay";break}}startRecording(){this.events=[],this.log("Recording started"),I.masterLoop||(I.masterLoop=this,this.startRecordingTime=Date.now())}stopRecording(){var e;if(this.events.length===0)return this.log("No events recorded"),"readyToRecord";if(!this.startRecordingTime)throw new Error("startRecordingTime is not set");const t=Date.now()-this.startRecordingTime;if(this.isMasterLoop()){this.events.push({callback:"endOfLoop",time:t});const i=this.events[0].time;this.events=this.events.map(({time:r,callback:s})=>({time:r-i,callback:s}))}else{j.log("events: "+this.events.length,this.events);const i=(e=I.masterLoop)==null?void 0:e.getLoopLength();if(!i)throw new Error("masterLoopLength is not set");const s=Math.floor(t/i)*i;this.events=this.events.filter(({time:o})=>o<=s),this.events.push({callback:"endOfLoop",time:s})}return this.log(`Recording stopped at ${t} with ${this.events.length} events, start playing`),"playing"}startPlaying(){var e;const t=()=>{this.currentLoopIndex>=this.events.length&&(this.currentLoopIndex=0),this.currentLoopIndex===0&&(this.log("Loop play (re)-started","#0F0"),this.startPlayingTime=Date.now());const{callback:i,time:r}=this.events[this.currentLoopIndex],s=this.currentLoopIndex===0?0:this.events[this.currentLoopIndex-1].time;this.loopTimeout=setTimeout(()=>{this.log(`Playing event ${i} after ${r}ms`),i!=="endOfLoop"?i():this.eventEmitter.emit("endOfLoop"),this.currentLoopIndex++,t()},r-s)};this.log("Loop play starting"),!this.isMasterLoop()&&((e=I.masterLoop)!=null&&e.isPlaying())?I.masterLoop.addEventListener("endOfLoop",()=>{t()}):t()}stopPlaying(){this.loopTimeout&&clearTimeout(this.loopTimeout),this.currentLoopIndex=0,this.log("Loop stopped")}isMasterLoop(){return this===I.masterLoop}log(t,e){const i=`Loop ${this.trackIndex+1}: ${t}`;e?j.log(`%c${i}`,`color: ${e}`):j.log(i)}};g(I,"masterLoop",null);let re=I;const jl={selected:"#DDD",unselected:"#000"},Mn={play:"play_arrow",record:"fiber_manual_record",stop:"stop"},vt={idle:"#FFF",readyToRecord:"#0FF",recording:"#FD0041",playing:"#0F0"},f=class f extends y.Scene{constructor(){super(f.key);g(this,"resizeTracks",()=>{const e=window.innerWidth{const p=e?i*c:0,u=e?-1:r*c;s.setSize(i,r).setPosition(p,u);const m=e?s.getCenter().x:s.getCenter().x-i/4,T=e?s.getCenter().y-r/4:s.getCenter().y,P=Math.min(r,i);o.setResolution(3).setSize(i,r).setFontSize(P/4).setPosition(m,T),a.setSize(P/3,P/3).setPosition(m,T),l.setOrigin(e?.5:1,e?1:.5).setPosition(e?s.getCenter().x:s.getRightCenter().x,e?s.getBottomCenter().y:s.getCenter().y)}),this.cameras.main.setViewport(0,0,e?window.innerWidth:i,e?r:window.innerHeight)});f.instance=this}static get sceneWidthHeight(){const e=window.innerWidth,i=window.innerHeight;return Math.max(i,e)/10}static deleteCurrentTrack(){const e=f.tracks.find(i=>i.selected);if(e){const i=f.tracks.indexOf(e);return e.loop.destroy(),e.loopProgressArc.clear(),e.loop=new re(i),this.instance.updateControlsState(),i}throw new Error("No track selected")}static deleteCurrentInstrumentScene(){const e=f.deleteCurrentTrack(),i=f.getTrackSceneKey(e);this.instance.game.scene.remove(i),this.instance.game.scene.start(Bt.key,{index:e}),this.instance.updateControlsState()}static getTrackSceneKey(e){return`track_scene_${e}`}create(){this.cameras.main.setOrigin(0,0).setPosition(0,0).setViewport(0,0,f.sceneWidthHeight,window.innerHeight).setBackgroundColor("#963"),this.createTracks(),this.game.events.on(et.sceneChange,()=>{this.updateControlsState()}),this.game.events.on(et.instrumentPlayed,({callback:e})=>{var i,r;(r=(i=f.tracks.find(s=>s.selected))==null?void 0:i.loop)==null||r.addLoopEvent(e)})}update(){for(const e of f.tracks)e.loop.isPlaying()&&this.updateProgressArc(e)}getTrackScene(e){return this.scene.get(f.getTrackSceneKey(e))}updateProgressArc(e){const i=e.loop.getLoopLength();if(!i)throw new Error("Loop length is not defined");const s=(Date.now()-e.loop.getStartPlayingTime())/i;e.loopProgressArc.clear(),e.loopProgressArc.lineStyle(4,65280,1);const o=y.Math.DegToRad(-90),a=o+y.Math.DegToRad(360*s);e.loopProgressArc.beginPath(),e.loopProgressArc.arc(e.buttonText.x,e.buttonText.y,e.buttonSelectedCircle.width/2,o,a,!1),e.loopProgressArc.strokePath()}createTracks(){f.tracks=new Array(f.numTracks).fill(null).map((e,i)=>({loop:new re(i),button:this.add.rectangle().setOrigin(0,0).setStrokeStyle(2,K("#FFF"),.8).setInteractive().on(y.Input.Events.POINTER_DOWN,()=>this.selectTrack(i)),selected:!1,buttonSelectedCircle:this.add.ellipse(0,0,0,0,K("#FFF")),buttonText:this.add.text(0,0,`${i+1}`,{fontFamily:St.Text,fontSize:Qt.medium,color:ye.white}).setOrigin(.5,.5).setResolution(2),controlIcon:this.add.text(0,0,"",{fontFamily:St.Icons,fontSize:Qt.medium,color:ye.white}).setOrigin(.5,.5).setResolution(2).setInteractive().on(y.Input.Events.POINTER_DOWN,()=>{this.handleControlClicked(i)}),loopProgressArc:this.add.graphics()})),window.addEventListener("resize",()=>this.resizeTracks()),this.resizeTracks(),this.selectTrack(0)}handleControlClicked(e){f.tracks[e].loop.handleClick(),this.updateControlsState()}selectTrack(e){const i=f.tracks[e];if(i.selected)i.loop.handleClick(),this.updateControlsState();else{const r=f.tracks.find(o=>o.selected);r&&(r.selected=!1,r.loop.isRecording()&&r.loop.handleClick()),i.selected=!0,this.updateControlsState();const s=this.getTrackScene(e);if(s){s.scene.bringToTop();const o=s.settings;this.game.events.emit(et.sceneChange,o)}else this.game.scene.start(Bt.key,{index:e})}}updateControlsState(){f.tracks.forEach((e,i)=>{e.button.setFillStyle(K(jl.unselected)),e.buttonText.setColor(e.selected?"#000":"#FFF"),e.buttonSelectedCircle.setVisible(!0).setFillStyle(K(e.selected?"#FFF":"#000")),this.getTrackScene(i)?e.selected&&(e.loop.isRecording()||e.loop.isReadyToRecord())?e.controlIcon.setText(Mn.record).setColor(e.loop.isRecording()?vt.recording:vt.idle):e.loop.isPlaying()||e.loop.isReadyToPlay()?e.controlIcon.setText(Mn.play).setColor(e.loop.isPlaying()?vt.playing:vt.idle):e.controlIcon.setText("").setColor(vt.idle):e.controlIcon.setText("").setColor(vt.idle)})}};g(f,"key","LoopTracksScene"),g(f,"numTracks",5),g(f,"tracks"),g(f,"instance");let V=f;const Nl=()=>window.matchMedia("(prefers-color-scheme: dark)").matches;function Bn(n){const t=window.innerWidth,e=window.innerHeight;n.scale.resize(t,e),n.scene.scenes.forEach(i=>{var r,s;return(s=(r=i.sys)==null?void 0:r.scale)==null?void 0:s.refresh()})}let Fn=!1;const zl=()=>(Fn||(Fn=!0,er().then(()=>{const n=new y.Game({type:y.AUTO,mode:y.Scale.RESIZE,parent:"phaser-container",width:window.innerWidth,height:window.innerHeight,backgroundColor:Nl()?"#333":"#DDD",scene:[V,Bt],input:{activePointers:8}}),t=new ie(n);window.addEventListener("resize",()=>{Bn(n),t.resize()}),n.scene.start(V.key),Bn(n)})),Tt.jsx(Tt.Fragment,{}));function Hl(){return Tt.jsx(zl,{})}xe.createRoot(document.getElementById("root")).render(Tt.jsx(Wi.StrictMode,{children:Tt.jsx(Hl,{})})); diff --git a/index.html b/index.html index 26b6519..ecb7be4 100644 --- a/index.html +++ b/index.html @@ -84,7 +84,7 @@ --tp-monitor-foreground-color: hsla(0, 0%, 100%, 0.3); } - + diff --git a/sw.js b/sw.js index fe93861..33c21bb 100644 --- a/sw.js +++ b/sw.js @@ -1 +1 @@ -if(!self.define){let e,s={};const n=(n,i)=>(n=new URL(n+".js",i).href,s[n]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=s,document.head.appendChild(e)}else e=n,importScripts(n),s()})).then((()=>{let e=s[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e})));self.define=(i,r)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(s[o])return;let a={};const t=e=>n(e,o),c={module:{uri:o},exports:a,require:t};s[o]=Promise.all(i.map((e=>c[e]||t(e)))).then((e=>(r(...e),a)))}}define(["./workbox-209e5686"],(function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"assets/index-hu0Kyz0h.js",revision:null},{url:"assets/phaser-pQREW5IE.js",revision:null},{url:"assets/react-H14vcryl.js",revision:null},{url:"icons/favicon-32x32.png",revision:"385f8ba6daaec15480b890f5f7343438"},{url:"icons/pwa-192x192.png",revision:"eabf4d19df264df1374b6b8ec103ece3"},{url:"icons/pwa-512x512.png",revision:"a6a962c6a584754622ba3a30d845f540"},{url:"index.html",revision:"9eeaddebb7804698dc79ae8b885c6036"},{url:"registerSW.js",revision:"402b66900e731ca748771b6fc5e7a068"},{url:"worklet.js",revision:"f2c0e5a03d55601209b3308c32a251aa"},{url:"./icons/pwa-192x192.png",revision:"eabf4d19df264df1374b6b8ec103ece3"},{url:"./icons/pwa-512x512.png",revision:"a6a962c6a584754622ba3a30d845f540"},{url:"manifest.webmanifest",revision:"7f72e7a7dd56296347bb1d27f4279e27"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html"))),e.registerRoute((({url:e})=>"https://docs.google.com"===e.origin&&e.pathname.startsWith("/spreadsheets/")),new e.NetworkFirst({cacheName:"api-cache",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:50,maxAgeSeconds:86400}),new e.CacheableResponsePlugin({statuses:[0,200]})]}),"GET")})); +if(!self.define){let e,s={};const n=(n,i)=>(n=new URL(n+".js",i).href,s[n]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=s,document.head.appendChild(e)}else e=n,importScripts(n),s()})).then((()=>{let e=s[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e})));self.define=(i,r)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(s[o])return;let c={};const a=e=>n(e,o),t={module:{uri:o},exports:c,require:a};s[o]=Promise.all(i.map((e=>t[e]||a(e)))).then((e=>(r(...e),c)))}}define(["./workbox-209e5686"],(function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"assets/index-GQ7Rhk9V.js",revision:null},{url:"assets/phaser-pQREW5IE.js",revision:null},{url:"assets/react-H14vcryl.js",revision:null},{url:"icons/favicon-32x32.png",revision:"385f8ba6daaec15480b890f5f7343438"},{url:"icons/pwa-192x192.png",revision:"eabf4d19df264df1374b6b8ec103ece3"},{url:"icons/pwa-512x512.png",revision:"a6a962c6a584754622ba3a30d845f540"},{url:"index.html",revision:"e77a46bebc04170a5b0c2ccf02d4bbc2"},{url:"registerSW.js",revision:"402b66900e731ca748771b6fc5e7a068"},{url:"worklet.js",revision:"f2c0e5a03d55601209b3308c32a251aa"},{url:"./icons/pwa-192x192.png",revision:"eabf4d19df264df1374b6b8ec103ece3"},{url:"./icons/pwa-512x512.png",revision:"a6a962c6a584754622ba3a30d845f540"},{url:"manifest.webmanifest",revision:"7f72e7a7dd56296347bb1d27f4279e27"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html"))),e.registerRoute((({url:e})=>"https://docs.google.com"===e.origin&&e.pathname.startsWith("/spreadsheets/")),new e.NetworkFirst({cacheName:"api-cache",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:50,maxAgeSeconds:86400}),new e.CacheableResponsePlugin({statuses:[0,200]})]}),"GET")}));