From afd9de89640e1e5e1a85e044b49b65b6d6b06b7f Mon Sep 17 00:00:00 2001 From: domi7777 Date: Thu, 14 Nov 2024 22:01:48 +0000 Subject: [PATCH] deploy: 532381009a787e3994fc044f69421db0f4cd2dca --- assets/index-7NGr8UKc.js | 15 +++++++++++++++ assets/index-Sd78XxzD.js | 13 ------------- index.html | 2 +- sw.js | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 assets/index-7NGr8UKc.js delete mode 100644 assets/index-Sd78XxzD.js diff --git a/assets/index-7NGr8UKc.js b/assets/index-7NGr8UKc.js new file mode 100644 index 0000000..fff700e --- /dev/null +++ b/assets/index-7NGr8UKc.js @@ -0,0 +1,15 @@ +var Sl=Object.defineProperty;var Tl=(n,e,t)=>e in n?Sl(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var x=(n,e,t)=>(Tl(n,typeof e!="symbol"?e+"":e,t),t);import{r as Ll,a as $l,R as Al}from"./react-H14vcryl.js";import{P as $}from"./phaser-pQREW5IE.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();var oo={exports:{}},Dn={};/** + * @license React + * react-jsx-runtime.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Ml=Ll,Ol=Symbol.for("react.element"),Rl=Symbol.for("react.fragment"),Dl=Object.prototype.hasOwnProperty,Bl=Ml.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Nl={key:!0,ref:!0,__self:!0,__source:!0};function ao(n,e,t){var i,s={},r=null,o=null;t!==void 0&&(r=""+t),e.key!==void 0&&(r=""+e.key),e.ref!==void 0&&(o=e.ref);for(i in e)Dl.call(e,i)&&!Nl.hasOwnProperty(i)&&(s[i]=e[i]);if(n&&n.defaultProps)for(i in e=n.defaultProps,e)s[i]===void 0&&(s[i]=e[i]);return{$$typeof:Ol,type:n,key:r,ref:o,props:s,_owner:Bl.current}}Dn.Fragment=Rl;Dn.jsx=ao;Dn.jsxs=ao;oo.exports=Dn;var Ft=oo.exports,wi={},Gs=$l;wi.createRoot=Gs.createRoot,wi.hydrateRoot=Gs.hydrateRoot;const jt={Icons:"Icons",Text:"Courier"},xn={tiny:"15px",small:"30px",medium:"50px",big:"90px"},_i={white:"#FFF"},Fl=async()=>{const n=new FontFace(jt.Icons,"url(./fonts/material.woff2)");return document.fonts.add(n),n.load().catch(e=>console.error(e))},fe=(n,e=!1)=>$.Display.Color.HexStringToColor(n).darken(e?75:0).color;let vn=null;const ye=()=>{if(!vn){const n=window.AudioContext||window.webkitAudioContext;vn=new n}return vn},jl=()=>{vn=null};function Il(n=100){const e=ye(),t=e.sampleRate*.05,i=e.createBuffer(1,t,e.sampleRate),s=i.getChannelData(0);for(let p=0;p{const r=n[s],o=e[s];return gi(r)&&gi(o)?Object.assign(Object.assign({},i),{[s]:Ge(r,o)}):Object.assign(Object.assign({},i),{[s]:s in e?o:r})},{})}function Ni(n){return Bi(n)?"target"in n:!1}const Yl={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"};let j=class ht{static alreadyDisposed(){return new ht({type:"alreadydisposed"})}static notBindable(){return new ht({type:"notbindable"})}static notCompatible(e,t){return new ht({type:"notcompatible",context:{id:`${e}.${t}`}})}static propertyNotFound(e){return new ht({type:"propertynotfound",context:{name:e}})}static shouldNeverHappen(){return new ht({type:"shouldneverhappen"})}constructor(e){var t;this.message=(t=Yl[e.type](e.context))!==null&&t!==void 0?t:"Unexpected error",this.name=this.constructor.name,this.stack=new Error(this.message).stack,this.type=e.type}toString(){return this.message}},Ws=class co{constructor(e,t){this.obj_=e,this.key=t}static isBindable(e){return!(e===null||typeof e!="object"&&typeof e!="function")}read(){return this.obj_[this.key]}write(e){this.obj_[this.key]=e}writeProperty(e,t){const i=this.read();if(!co.isBindable(i))throw j.notBindable();if(!(e in i))throw j.propertyNotFound(e);i[e]=t}},M=class{constructor(){this.observers_={}}on(e,t,i){var s;let r=this.observers_[e];return r||(r=this.observers_[e]=[]),r.push({handler:t,key:(s=i==null?void 0:i.key)!==null&&s!==void 0?s:t}),this}off(e,t){const i=this.observers_[e];return i&&(this.observers_[e]=i.filter(s=>s.key!==t)),this}emit(e,t){const i=this.observers_[e];i&&i.forEach(s=>{s.handler(t)})}},Xl=class{constructor(e,t){var i;this.constraint_=t==null?void 0:t.constraint,this.equals_=(i=t==null?void 0:t.equals)!==null&&i!==void 0?i:(s,r)=>s===r,this.emitter=new M,this.rawValue_=e}get constraint(){return this.constraint_}get rawValue(){return this.rawValue_}set rawValue(e){this.setRawValue(e,{forceEmit:!1,last:!0})}setRawValue(e,t){const i=t??{forceEmit:!1,last:!0},s=this.constraint_?this.constraint_.constrain(e):e,r=this.rawValue_;this.equals_(r,s)&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.rawValue_=s,this.emitter.emit("change",{options:i,previousRawValue:r,rawValue:s,sender:this}))}},Ql=class{constructor(e){this.emitter=new M,this.value_=e}get rawValue(){return this.value_}set rawValue(e){this.setRawValue(e,{forceEmit:!1,last:!0})}setRawValue(e,t){const i=t??{forceEmit:!1,last:!0},s=this.value_;s===e&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.value_=e,this.emitter.emit("change",{options:i,previousRawValue:s,rawValue:this.value_,sender:this}))}},Jl=class{constructor(e){this.emitter=new M,this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.value_=e,this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_)}get rawValue(){return this.value_.rawValue}onValueBeforeChange_(e){this.emitter.emit("beforechange",Object.assign(Object.assign({},e),{sender:this}))}onValueChange_(e){this.emitter.emit("change",Object.assign(Object.assign({},e),{sender:this}))}};function k(n,e){const t=e==null?void 0:e.constraint,i=e==null?void 0:e.equals;return!t&&!i?new Ql(n):new Xl(n,e)}function Zl(n){return[new Jl(n),(e,t)=>{n.setRawValue(e,t)}]}let v=class po{constructor(e){this.emitter=new M,this.valMap_=e;for(const t in this.valMap_)this.valMap_[t].emitter.on("change",()=>{this.emitter.emit("change",{key:t,sender:this})})}static createCore(e){return Object.keys(e).reduce((i,s)=>Object.assign(i,{[s]:k(e[s])}),{})}static fromObject(e){const t=this.createCore(e);return new po(t)}get(e){return this.valMap_[e].rawValue}set(e,t){this.valMap_[e].rawValue=t}value(e){return this.valMap_[e]}},Jt=class{constructor(e){this.values=v.fromObject({max:e.max,min:e.min})}constrain(e){const t=this.values.get("max"),i=this.values.get("min");return Math.min(Math.max(e,i),t)}},ec=class{constructor(e){this.values=v.fromObject({max:e.max,min:e.min})}constrain(e){const t=this.values.get("max"),i=this.values.get("min");let s=e;return P(i)||(s=Math.max(s,i)),P(t)||(s=Math.min(s,t)),s}},tc=class{constructor(e,t=0){this.step=e,this.origin=t}constrain(e){const t=this.origin%this.step,i=Math.round((e-t)/this.step);return t+i*this.step}},nc=class{constructor(e){this.text=e}evaluate(){return Number(this.text)}toString(){return this.text}};const ic={"**":(n,e)=>Math.pow(n,e),"*":(n,e)=>n*e,"/":(n,e)=>n/e,"%":(n,e)=>n%e,"+":(n,e)=>n+e,"-":(n,e)=>n-e,"<<":(n,e)=>n<>":(n,e)=>n>>e,">>>":(n,e)=>n>>>e,"&":(n,e)=>n&e,"^":(n,e)=>n^e,"|":(n,e)=>n|e};let sc=class{constructor(e,t,i){this.left=t,this.operator=e,this.right=i}evaluate(){const e=ic[this.operator];if(!e)throw new Error(`unexpected binary operator: '${this.operator}`);return e(this.left.evaluate(),this.right.evaluate())}toString(){return["b(",this.left.toString(),this.operator,this.right.toString(),")"].join(" ")}};const rc={"+":n=>n,"-":n=>-n,"~":n=>~n};let oc=class{constructor(e,t){this.operator=e,this.expression=t}evaluate(){const e=rc[this.operator];if(!e)throw new Error(`unexpected unary operator: '${this.operator}`);return e(this.expression.evaluate())}toString(){return["u(",this.operator,this.expression.toString(),")"].join(" ")}};function Fi(n){return(e,t)=>{for(let i=0;ie.startsWith(s,t))[0];return i?(t+=i.length,t+=It(e,t).length,{cursor:t,operator:i}):null}function Ec(n,e){return(t,i)=>{const s=n(t,i);if(!s)return null;i=s.cursor;let r=s.evaluable;for(;;){const o=yc(e,t,i);if(!o)break;i=o.cursor;const a=n(t,i);if(!a)return null;i=a.cursor,r=new sc(o.operator,r,a.evaluable)}return r?{cursor:i,evaluable:r}:null}}const kc=[["**"],["*","/","%"],["+","-"],["<<",">>>",">>"],["&"],["^"],["|"]].reduce((n,e)=>Ec(n,e),ho);function mo(n,e){return e+=It(n,e).length,kc(n,e)}function Vc(n){const e=mo(n,0);return!e||e.cursor+It(n,e.cursor).length!==n.length?null:e.evaluable}function Ce(n){var e;const t=Vc(n);return(e=t==null?void 0:t.evaluate())!==null&&e!==void 0?e:null}function vo(n){if(typeof n=="number")return n;if(typeof n=="string"){const e=Ce(n);if(!P(e))return e}return 0}function Sc(n){return String(n)}function W(n){return e=>e.toFixed(Math.max(Math.min(n,20),0))}function _(n,e,t,i,s){const r=(n-e)/(t-e);return i+r*(s-i)}function Ys(n){return String(n.toFixed(10)).split(".")[1].replace(/0+$/,"").length}function R(n,e,t){return Math.min(Math.max(n,e),t)}function bo(n,e){return(n%e+e)%e}function Tc(n,e){return P(n.step)?Math.max(Ys(e),2):Ys(n.step)}function fo(n){var e;return(e=n.step)!==null&&e!==void 0?e:1}function wo(n,e){var t;const i=Math.abs((t=n.step)!==null&&t!==void 0?t:e);return i===0?.1:Math.pow(10,Math.floor(Math.log10(i))-1)}function _o(n,e){return P(n.step)?null:new tc(n.step,e)}function go(n){return!P(n.max)&&!P(n.min)?new Jt({max:n.max,min:n.min}):!P(n.max)||!P(n.min)?new ec({max:n.max,min:n.min}):null}function Co(n,e){var t,i,s;return{formatter:(t=n.format)!==null&&t!==void 0?t:W(Tc(n,e)),keyScale:(i=n.keyScale)!==null&&i!==void 0?i:fo(n),pointerScale:(s=n.pointerScale)!==null&&s!==void 0?s:wo(n,e)}}function xo(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 Ii(n){return{constraint:n.constraint,textProps:v.fromObject(Co(n.params,n.initialValue))}}let Ze=class{constructor(e){this.controller=e}get element(){return this.controller.view.element}get disabled(){return this.controller.viewProps.get("disabled")}set disabled(e){this.controller.viewProps.set("disabled",e)}get hidden(){return this.controller.viewProps.get("hidden")}set hidden(e){this.controller.viewProps.set("hidden",e)}dispose(){this.controller.viewProps.set("disposed",!0)}importState(e){return this.controller.importState(e)}exportState(){return this.controller.exportState()}},Bn=class{constructor(e){this.target=e}},Zt=class extends Bn{constructor(e,t,i){super(e),this.value=t,this.last=i??!0}},Lc=class extends Bn{constructor(e,t){super(e),this.expanded=t}},$c=class extends Bn{constructor(e,t){super(e),this.index=t}};class Ac extends Bn{constructor(e,t){super(e),this.native=t}}let Kt=class extends Ze{constructor(e){super(e),this.onValueChange_=this.onValueChange_.bind(this),this.emitter_=new M,this.controller.value.emitter.on("change",this.onValueChange_)}get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get key(){return this.controller.value.binding.target.key}get tag(){return this.controller.tag}set tag(e){this.controller.tag=e}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}refresh(){this.controller.value.fetch()}onValueChange_(e){const t=this.controller.value;this.emitter_.emit("change",new Zt(this,t.binding.target.read(),e.options.last))}};class Mc{constructor(e,t){this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.binding=t,this.value_=e,this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_),this.emitter=new M}get rawValue(){return this.value_.rawValue}set rawValue(e){this.value_.rawValue=e}setRawValue(e,t){this.value_.setRawValue(e,t)}fetch(){this.value_.rawValue=this.binding.read()}push(){this.binding.write(this.value_.rawValue)}onValueBeforeChange_(e){this.emitter.emit("beforechange",Object.assign(Object.assign({},e),{sender:this}))}onValueChange_(e){this.push(),this.emitter.emit("change",Object.assign(Object.assign({},e),{sender:this}))}}function Oc(n){if(!("binding"in n))return!1;const e=n.binding;return Ni(e)&&"read"in e&&"write"in e}function Rc(n,e){const i=Object.keys(e).reduce((s,r)=>{if(s===void 0)return;const o=e[r],a=o(n[r]);return a.succeeded?Object.assign(Object.assign({},s),{[r]:a.value}):void 0},{});return i}function Dc(n,e){return n.reduce((t,i)=>{if(t===void 0)return;const s=e(i);if(!(!s.succeeded||s.value===void 0))return[...t,s.value]},[])}function Bc(n){return n===null?!1:typeof n=="object"}function ve(n){return e=>t=>{if(!e&&t===void 0)return{succeeded:!1,value:void 0};if(e&&t===void 0)return{succeeded:!0,value:void 0};const i=n(t);return i!==void 0?{succeeded:!0,value:i}:{succeeded:!1,value:void 0}}}function Xs(n){return{custom:e=>ve(e)(n),boolean:ve(e=>typeof e=="boolean"?e:void 0)(n),number:ve(e=>typeof e=="number"?e:void 0)(n),string:ve(e=>typeof e=="string"?e:void 0)(n),function:ve(e=>typeof e=="function"?e:void 0)(n),constant:e=>ve(t=>t===e?e:void 0)(n),raw:ve(e=>e)(n),object:e=>ve(t=>{if(Bc(t))return Rc(t,e)})(n),array:e=>ve(t=>{if(Array.isArray(t))return Dc(t,e)})(n)}}const Ci={optional:Xs(!0),required:Xs(!1)};function S(n,e){const t=e(Ci),i=Ci.required.object(t)(n);return i.succeeded?i.value:void 0}function Q(n,e,t,i){if(e&&!e(n))return!1;const s=S(n,t);return s?i(s):!1}function J(n,e){var t;return Ge((t=n==null?void 0:n())!==null&&t!==void 0?t:{},e)}function qe(n){return"value"in n}function Po(n){if(!Bi(n)||!("binding"in n))return!1;const e=n.binding;return Ni(e)}const ue="http://www.w3.org/2000/svg";function Pn(n){n.offsetHeight}function Nc(n,e){const t=n.style.transition;n.style.transition="none",e(),n.style.transition=t}function zi(n){return n.ontouchstart!==void 0}function Fc(){return globalThis}function jc(){return Fc().document}function Ic(n){const e=n.ownerDocument.defaultView;return e&&"document"in e?n.getContext("2d",{willReadFrequently:!0}):null}const zc={check:'',dropdown:'',p2dpad:''};function Nn(n,e){const t=n.createElementNS(ue,"svg");return t.innerHTML=zc[e],t}function yo(n,e,t){n.insertBefore(e,n.children[t])}function Ki(n){n.parentElement&&n.parentElement.removeChild(n)}function Eo(n){for(;n.children.length>0;)n.removeChild(n.children[0])}function Kc(n){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])}function ko(n){return n.relatedTarget?n.relatedTarget:"explicitOriginalTarget"in n?n.explicitOriginalTarget:null}function ge(n,e){n.emitter.on("change",t=>{e(t.rawValue)}),e(n.rawValue)}function he(n,e,t){ge(n.value(e),t)}const Uc="tp";function f(n){return(t,i)=>[Uc,"-",n,"v",t?`_${t}`:"",i?`-${i}`:""].join("")}const Vt=f("lbl");function Hc(n,e){const t=n.createDocumentFragment();return e.split(` +`).map(s=>n.createTextNode(s)).forEach((s,r)=>{r>0&&t.appendChild(n.createElement("br")),t.appendChild(s)}),t}let Vo=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Vt()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(Vt("l")),he(t.props,"label",r=>{P(r)?this.element.classList.add(Vt(void 0,"nol")):(this.element.classList.remove(Vt(void 0,"nol")),Kc(i),i.appendChild(Hc(e,r)))}),this.element.appendChild(i),this.labelElement=i;const s=e.createElement("div");s.classList.add(Vt("v")),this.element.appendChild(s),this.valueElement=s}},So=class{constructor(e,t){this.props=t.props,this.valueController=t.valueController,this.viewProps=t.valueController.viewProps,this.view=new Vo(e,{props:t.props,viewProps:this.viewProps}),this.view.valueElement.appendChild(this.valueController.view.element)}importProps(e){return Q(e,null,t=>({label:t.optional.string}),t=>(this.props.set("label",t.label),!0))}exportProps(){return J(null,{label:this.props.get("label")})}};function qc(){return["veryfirst","first","last","verylast"]}const Qs=f(""),Js={veryfirst:"vfst",first:"fst",last:"lst",verylast:"vlst"};let Fn=class{constructor(e){this.parent_=null,this.blade=e.blade,this.view=e.view,this.viewProps=e.viewProps;const t=this.view.element;this.blade.value("positions").emitter.on("change",()=>{qc().forEach(i=>{t.classList.remove(Qs(void 0,Js[i]))}),this.blade.get("positions").forEach(i=>{t.classList.add(Qs(void 0,Js[i]))})}),this.viewProps.handleDispose(()=>{Ki(t)})}get parent(){return this.parent_}set parent(e){this.parent_=e,this.viewProps.set("parent",this.parent_?this.parent_.viewProps:null)}importState(e){return Q(e,null,t=>({disabled:t.required.boolean,hidden:t.required.boolean}),t=>(this.viewProps.importState(t),!0))}exportState(){return J(null,Object.assign({},this.viewProps.exportState()))}},We=class extends Fn{constructor(e,t){if(t.value!==t.valueController.value)throw j.shouldNeverHappen();const i=t.valueController.viewProps,s=new So(e,{blade:t.blade,props:t.props,valueController:t.valueController});super(Object.assign(Object.assign({},t),{view:new Vo(e,{props:t.props,viewProps:i}),viewProps:i})),this.labelController=s,this.value=t.value,this.valueController=t.valueController,this.view.valueElement.appendChild(this.valueController.view.element)}importState(e){return Q(e,t=>{var i,s,r;return super.importState(t)&&this.labelController.importProps(t)&&((r=(s=(i=this.valueController).importProps)===null||s===void 0?void 0:s.call(i,e))!==null&&r!==void 0?r:!0)},t=>({value:t.optional.raw}),t=>(t.value&&(this.value.rawValue=t.value),!0))}exportState(){var e,t,i;return J(()=>super.exportState(),Object.assign(Object.assign({value:this.value.rawValue},this.labelController.exportProps()),(i=(t=(e=this.valueController).exportProps)===null||t===void 0?void 0:t.call(e))!==null&&i!==void 0?i:{}))}};function Zs(n){const e=Object.assign({},n);return delete e.value,e}class To extends We{constructor(e,t){super(e,t),this.tag=t.tag}importState(e){return Q(e,t=>super.importState(Zs(e)),t=>({tag:t.optional.string}),t=>(this.tag=t.tag,!0))}exportState(){return J(()=>Zs(super.exportState()),{binding:{key:this.value.binding.target.key,value:this.value.binding.target.read()},tag:this.tag})}}function Gc(n){return qe(n)&&Po(n.value)}class Wc extends To{importState(e){return Q(e,t=>super.importState(t),t=>({binding:t.required.object({value:t.required.raw})}),t=>(this.value.binding.inject(t.binding.value),this.value.fetch(),!0))}}function Yc(n){return qe(n)&&Oc(n.value)}function Lo(n,e){for(;n.lengthn.length?t.splice(0,t.length-n.length):Lo(t,n.length),t}class Zc{constructor(e){this.emitter=new M,this.onTick_=this.onTick_.bind(this),this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.binding=e.binding,this.value_=k(Xc(e.bufferSize)),this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_),this.ticker=e.ticker,this.ticker.emitter.on("tick",this.onTick_),this.fetch()}get rawValue(){return this.value_.rawValue}set rawValue(e){this.value_.rawValue=e}setRawValue(e,t){this.value_.setRawValue(e,t)}fetch(){this.value_.rawValue=Jc(this.value_.rawValue,this.binding.read())}onTick_(){this.fetch()}onValueBeforeChange_(e){this.emitter.emit("beforechange",Object.assign(Object.assign({},e),{sender:this}))}onValueChange_(e){this.emitter.emit("change",Object.assign(Object.assign({},e),{sender:this}))}}function ep(n){if(!("binding"in n))return!1;const e=n.binding;return Ni(e)&&"read"in e&&!("write"in e)}class tp extends To{exportState(){return J(()=>super.exportState(),{binding:{readonly:!0}})}}function np(n){return qe(n)&&ep(n.value)}let ip=class extends Ze{get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get title(){var e;return(e=this.controller.buttonController.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller.buttonController.props.set("title",e)}on(e,t){const i=t.bind(this);return this.controller.buttonController.emitter.on(e,r=>{i(new Ac(this,r.nativeEvent))}),this}off(e,t){return this.controller.buttonController.emitter.off(e,t),this}};function sp(n,e,t){t?n.classList.add(e):n.classList.remove(e)}function gt(n,e){return t=>{sp(n,e,t)}}function Ui(n,e){ge(n,t=>{e.textContent=t??""})}const Qn=f("btn");let rp=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Qn()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("button");i.classList.add(Qn("b")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const s=e.createElement("div");s.classList.add(Qn("t")),Ui(t.props.value("title"),s),this.buttonElement.appendChild(s)}},op=class{constructor(e,t){this.emitter=new M,this.onClick_=this.onClick_.bind(this),this.props=t.props,this.viewProps=t.viewProps,this.view=new rp(e,{props:this.props,viewProps:this.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}importProps(e){return Q(e,null,t=>({title:t.optional.string}),t=>(this.props.set("title",t.title),!0))}exportProps(){return J(null,{title:this.props.get("title")})}onClick_(e){this.emitter.emit("click",{nativeEvent:e,sender:this})}},er=class extends Fn{constructor(e,t){const i=new op(e,{props:t.buttonProps,viewProps:t.viewProps}),s=new So(e,{blade:t.blade,props:t.labelProps,valueController:i});super({blade:t.blade,view:s.view,viewProps:t.viewProps}),this.buttonController=i,this.labelController=s}importState(e){return Q(e,t=>super.importState(t)&&this.buttonController.importProps(t)&&this.labelController.importProps(t),()=>({}),()=>!0)}exportState(){return J(()=>super.exportState(),Object.assign(Object.assign({},this.buttonController.exportProps()),this.labelController.exportProps()))}},$o=class{constructor(e){const[t,i]=e.split("-"),s=t.split(".");this.major=parseInt(s[0],10),this.minor=parseInt(s[1],10),this.patch=parseInt(s[2],10),this.prerelease=i??null}toString(){const e=[this.major,this.minor,this.patch].join(".");return this.prerelease!==null?[e,this.prerelease].join("-"):e}};const Ct=new $o("2.0.4");function q(n){return Object.assign({core:Ct},n)}const ap=q({id:"button",type:"blade",accept(n){const e=S(n,t=>({title:t.required.string,view:t.required.constant("button"),label:t.optional.string}));return e?{params:e}:null},controller(n){return new er(n.document,{blade:n.blade,buttonProps:v.fromObject({title:n.params.title}),labelProps:v.fromObject({label:n.params.label}),viewProps:n.viewProps})},api(n){return n.controller instanceof er?new ip(n.controller):null}});function lp(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"button"}))}function cp(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"folder"}))}function pp(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"tab"}))}function up(n){return Bi(n)?"refresh"in n&&typeof n.refresh=="function":!1}function hp(n,e){if(!Ws.isBindable(n))throw j.notBindable();return new Ws(n,e)}let dp=class{constructor(e,t){this.onRackValueChange_=this.onRackValueChange_.bind(this),this.controller_=e,this.emitter_=new M,this.pool_=t,this.controller_.rack.emitter.on("valuechange",this.onRackValueChange_)}get children(){return this.controller_.rack.children.map(e=>this.pool_.createApi(e))}addBinding(e,t,i){const s=i??{},r=this.controller_.element.ownerDocument,o=this.pool_.createBinding(r,hp(e,t),s),a=this.pool_.createBindingApi(o);return this.add(a,s.index)}addFolder(e){return cp(this,e)}addButton(e){return lp(this,e)}addTab(e){return pp(this,e)}add(e,t){const i=e.controller;return this.controller_.rack.add(i,t),e}remove(e){this.controller_.rack.remove(e.controller)}addBlade(e){const t=this.controller_.element.ownerDocument,i=this.pool_.createBlade(t,e),s=this.pool_.createApi(i);return this.add(s,e.index)}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}refresh(){this.children.forEach(e=>{up(e)&&e.refresh()})}onRackValueChange_(e){const t=e.bladeController,i=this.pool_.createApi(t),s=Po(t.value)?t.value.binding:null;this.emitter_.emit("change",new Zt(i,s?s.target.read():t.value.rawValue,e.options.last))}},Hi=class extends Ze{constructor(e,t){super(e),this.rackApi_=new dp(e.rackController,t)}refresh(){this.rackApi_.refresh()}},qi=class extends Fn{constructor(e){super({blade:e.blade,view:e.view,viewProps:e.rackController.viewProps}),this.rackController=e.rackController}importState(e){return Q(e,t=>super.importState(t),t=>({children:t.required.array(t.required.raw)}),t=>this.rackController.rack.children.every((i,s)=>i.importState(t.children[s])))}exportState(){return J(()=>super.exportState(),{children:this.rackController.rack.children.map(e=>e.exportState())})}};function xi(n){return"rackController"in n}let mp=class{constructor(e){this.emitter=new M,this.items_=[],this.cache_=new Set,this.onSubListAdd_=this.onSubListAdd_.bind(this),this.onSubListRemove_=this.onSubListRemove_.bind(this),this.extract_=e}get items(){return this.items_}allItems(){return Array.from(this.cache_)}find(e){for(const t of this.allItems())if(e(t))return t;return null}includes(e){return this.cache_.has(e)}add(e,t){if(this.includes(e))throw j.shouldNeverHappen();const i=t!==void 0?t:this.items_.length;this.items_.splice(i,0,e),this.cache_.add(e);const s=this.extract_(e);s&&(s.emitter.on("add",this.onSubListAdd_),s.emitter.on("remove",this.onSubListRemove_),s.allItems().forEach(r=>{this.cache_.add(r)})),this.emitter.emit("add",{index:i,item:e,root:this,target:this})}remove(e){const t=this.items_.indexOf(e);if(t<0)return;this.items_.splice(t,1),this.cache_.delete(e);const i=this.extract_(e);i&&(i.allItems().forEach(s=>{this.cache_.delete(s)}),i.emitter.off("add",this.onSubListAdd_),i.emitter.off("remove",this.onSubListRemove_)),this.emitter.emit("remove",{index:t,item:e,root:this,target:this})}onSubListAdd_(e){this.cache_.add(e.item),this.emitter.emit("add",{index:e.index,item:e.item,root:this,target:e.target})}onSubListRemove_(e){this.cache_.delete(e.item),this.emitter.emit("remove",{index:e.index,item:e.item,root:this,target:e.target})}};function vp(n,e){for(let t=0;t!s.viewProps.get("hidden")),t=e[0],i=e[e.length-1];this.bcSet_.items.forEach(s=>{const r=[];s===t&&(r.push("first"),(!this.blade_||this.blade_.get("positions").includes("veryfirst"))&&r.push("veryfirst")),s===i&&(r.push("last"),(!this.blade_||this.blade_.get("positions").includes("verylast"))&&r.push("verylast")),s.blade.set("positions",r)})}onChildPositionsChange_(){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildViewPropsChange_(e){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildDispose_(){this.bcSet_.items.filter(t=>t.viewProps.get("disposed")).forEach(t=>{this.bcSet_.remove(t)})}onChildValueChange_(e){const t=vp(this.find(qe),e.sender);if(!t)throw j.alreadyDisposed();this.emitter.emit("valuechange",{bladeController:t,options:e.options,sender:this})}onRackLayout_(e){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onRackValueChange_(e){this.emitter.emit("valuechange",{bladeController:e.bladeController,options:e.options,sender:this})}onBladePositionsChange_(){this.updatePositions_()}},Gi=class{constructor(e){this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this),this.element=e.element,this.viewProps=e.viewProps;const t=new fp({blade:e.root?void 0:e.blade,viewProps:e.viewProps});t.emitter.on("add",this.onRackAdd_),t.emitter.on("remove",this.onRackRemove_),this.rack=t,this.viewProps.handleDispose(()=>{for(let i=this.rack.children.length-1;i>=0;i--)this.rack.children[i].viewProps.set("disposed",!0)})}onRackAdd_(e){e.root&&yo(this.element,e.bladeController.view.element,e.index)}onRackRemove_(e){e.root&&Ki(e.bladeController.view.element)}};function xt(){return new v({positions:k([],{equals:Wl})})}let Wi=class Ao extends v{constructor(e){super(e)}static create(e){const t={completed:!0,expanded:e,expandedHeight:null,shouldFixHeight:!1,temporaryExpanded:null},i=v.createCore(t);return new Ao(i)}get styleExpanded(){var e;return(e=this.get("temporaryExpanded"))!==null&&e!==void 0?e:this.get("expanded")}get styleHeight(){if(!this.styleExpanded)return"0";const e=this.get("expandedHeight");return this.get("shouldFixHeight")&&!P(e)?`${e}px`:"auto"}bindExpandedClass(e,t){const i=()=>{this.styleExpanded?e.classList.add(t):e.classList.remove(t)};he(this,"expanded",i),he(this,"temporaryExpanded",i)}cleanUpTransition(){this.set("shouldFixHeight",!1),this.set("expandedHeight",null),this.set("completed",!0)}};function wp(n,e){let t=0;return Nc(e,()=>{n.set("expandedHeight",null),n.set("temporaryExpanded",!0),Pn(e),t=e.clientHeight,n.set("temporaryExpanded",null),Pn(e)}),t}function tr(n,e){e.style.height=n.styleHeight}function Yi(n,e){n.value("expanded").emitter.on("beforechange",()=>{if(n.set("completed",!1),P(n.get("expandedHeight"))){const t=wp(n,e);t>0&&n.set("expandedHeight",t)}n.set("shouldFixHeight",!0),Pn(e)}),n.emitter.on("change",()=>{tr(n,e)}),tr(n,e),e.addEventListener("transitionend",t=>{t.propertyName==="height"&&n.cleanUpTransition()})}let Mo=class extends Hi{constructor(e,t){super(e,t),this.emitter_=new M,this.controller.foldable.value("expanded").emitter.on("change",i=>{this.emitter_.emit("fold",new Lc(this,i.sender.rawValue))}),this.rackApi_.on("change",i=>{this.emitter_.emit("change",i)})}get expanded(){return this.controller.foldable.get("expanded")}set expanded(e){this.controller.foldable.set("expanded",e)}get title(){return this.controller.props.get("title")}set title(e){this.controller.props.set("title",e)}get children(){return this.rackApi_.children}addBinding(e,t,i){return this.rackApi_.addBinding(e,t,i)}addFolder(e){return this.rackApi_.addFolder(e)}addButton(e){return this.rackApi_.addButton(e)}addTab(e){return this.rackApi_.addTab(e)}add(e,t){return this.rackApi_.add(e,t)}remove(e){this.rackApi_.remove(e)}addBlade(e){return this.rackApi_.addBlade(e)}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}};const Oo=f("cnt");let _p=class{constructor(e,t){var i;this.className_=f((i=t.viewName)!==null&&i!==void 0?i:"fld"),this.element=e.createElement("div"),this.element.classList.add(this.className_(),Oo()),t.viewProps.bindClassModifiers(this.element),this.foldable_=t.foldable,this.foldable_.bindExpandedClass(this.element,this.className_(void 0,"expanded")),he(this.foldable_,"completed",gt(this.element,this.className_(void 0,"cpl")));const s=e.createElement("button");s.classList.add(this.className_("b")),he(t.props,"title",c=>{P(c)?this.element.classList.add(this.className_(void 0,"not")):this.element.classList.remove(this.className_(void 0,"not"))}),t.viewProps.bindDisabled(s),this.element.appendChild(s),this.buttonElement=s;const r=e.createElement("div");r.classList.add(this.className_("i")),this.element.appendChild(r);const o=e.createElement("div");o.classList.add(this.className_("t")),Ui(t.props.value("title"),o),this.buttonElement.appendChild(o),this.titleElement=o;const a=e.createElement("div");a.classList.add(this.className_("m")),this.buttonElement.appendChild(a);const l=e.createElement("div");l.classList.add(this.className_("c")),this.element.appendChild(l),this.containerElement=l}},Pi=class extends qi{constructor(e,t){var i;const s=Wi.create((i=t.expanded)!==null&&i!==void 0?i:!0),r=new _p(e,{foldable:s,props:t.props,viewName:t.root?"rot":void 0,viewProps:t.viewProps});super(Object.assign(Object.assign({},t),{rackController:new Gi({blade:t.blade,element:r.containerElement,root:t.root,viewProps:t.viewProps}),view:r})),this.onTitleClick_=this.onTitleClick_.bind(this),this.props=t.props,this.foldable=s,Yi(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(e){return Q(e,t=>super.importState(t),t=>({expanded:t.required.boolean,title:t.optional.string}),t=>(this.foldable.set("expanded",t.expanded),this.props.set("title",t.title),!0))}exportState(){return J(()=>super.exportState(),{expanded:this.foldable.get("expanded"),title:this.props.get("title")})}onTitleClick_(){this.foldable.set("expanded",!this.foldable.get("expanded"))}};const gp=q({id:"folder",type:"blade",accept(n){const e=S(n,t=>({title:t.required.string,view:t.required.constant("folder"),expanded:t.optional.boolean}));return e?{params:e}:null},controller(n){return new Pi(n.document,{blade:n.blade,expanded:n.params.expanded,props:v.fromObject({title:n.params.title}),viewProps:n.viewProps})},api(n){return n.controller instanceof Pi?new Mo(n.controller,n.pool):null}}),Cp=f("");function nr(n,e){return gt(n,Cp(void 0,e))}let et=class Ro extends v{constructor(e){var t;super(e),this.onDisabledChange_=this.onDisabledChange_.bind(this),this.onParentChange_=this.onParentChange_.bind(this),this.onParentGlobalDisabledChange_=this.onParentGlobalDisabledChange_.bind(this),[this.globalDisabled_,this.setGlobalDisabled_]=Zl(k(this.getGlobalDisabled_())),this.value("disabled").emitter.on("change",this.onDisabledChange_),this.value("parent").emitter.on("change",this.onParentChange_),(t=this.get("parent"))===null||t===void 0||t.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_)}static create(e){var t,i,s;const r=e??{};return new Ro(v.createCore({disabled:(t=r.disabled)!==null&&t!==void 0?t:!1,disposed:!1,hidden:(i=r.hidden)!==null&&i!==void 0?i:!1,parent:(s=r.parent)!==null&&s!==void 0?s:null}))}get globalDisabled(){return this.globalDisabled_}bindClassModifiers(e){ge(this.globalDisabled_,nr(e,"disabled")),he(this,"hidden",nr(e,"hidden"))}bindDisabled(e){ge(this.globalDisabled_,t=>{e.disabled=t})}bindTabIndex(e){ge(this.globalDisabled_,t=>{e.tabIndex=t?-1:0})}handleDispose(e){this.value("disposed").emitter.on("change",t=>{t&&e()})}importState(e){this.set("disabled",e.disabled),this.set("hidden",e.hidden)}exportState(){return{disabled:this.get("disabled"),hidden:this.get("hidden")}}getGlobalDisabled_(){const e=this.get("parent");return(e?e.globalDisabled.rawValue:!1)||this.get("disabled")}updateGlobalDisabled_(){this.setGlobalDisabled_(this.getGlobalDisabled_())}onDisabledChange_(){this.updateGlobalDisabled_()}onParentGlobalDisabledChange_(){this.updateGlobalDisabled_()}onParentChange_(e){var t;const i=e.previousRawValue;i==null||i.globalDisabled.emitter.off("change",this.onParentGlobalDisabledChange_),(t=this.get("parent"))===null||t===void 0||t.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_),this.updateGlobalDisabled_()}};const ir=f("tbp");let xp=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(ir()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(ir("c")),this.element.appendChild(i),this.containerElement=i}};const St=f("tbi");let Pp=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(St()),t.viewProps.bindClassModifiers(this.element),he(t.props,"selected",r=>{r?this.element.classList.add(St(void 0,"sel")):this.element.classList.remove(St(void 0,"sel"))});const i=e.createElement("button");i.classList.add(St("b")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const s=e.createElement("div");s.classList.add(St("t")),Ui(t.props.value("title"),s),this.buttonElement.appendChild(s),this.titleElement=s}},yp=class{constructor(e,t){this.emitter=new M,this.onClick_=this.onClick_.bind(this),this.props=t.props,this.viewProps=t.viewProps,this.view=new Pp(e,{props:t.props,viewProps:t.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}onClick_(){this.emitter.emit("click",{sender:this})}},yi=class extends qi{constructor(e,t){const i=new xp(e,{viewProps:t.viewProps});super(Object.assign(Object.assign({},t),{rackController:new Gi({blade:t.blade,element:i.containerElement,viewProps:t.viewProps}),view:i})),this.onItemClick_=this.onItemClick_.bind(this),this.ic_=new yp(e,{props:t.itemProps,viewProps:et.create()}),this.ic_.emitter.on("click",this.onItemClick_),this.props=t.props,he(this.props,"selected",s=>{this.itemController.props.set("selected",s),this.viewProps.set("hidden",!s)})}get itemController(){return this.ic_}importState(e){return Q(e,t=>super.importState(t),t=>({selected:t.required.boolean,title:t.required.string}),t=>(this.ic_.props.set("selected",t.selected),this.ic_.props.set("title",t.title),!0))}exportState(){return J(()=>super.exportState(),{selected:this.ic_.props.get("selected"),title:this.ic_.props.get("title")})}onItemClick_(){this.props.set("selected",!0)}},Ep=class extends Hi{constructor(e,t){super(e,t),this.emitter_=new M,this.onSelect_=this.onSelect_.bind(this),this.pool_=t,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(e){const t=this.controller.view.element.ownerDocument,i=new yi(t,{blade:xt(),itemProps:v.fromObject({selected:!1,title:e.title}),props:v.fromObject({selected:!1}),viewProps:et.create()}),s=this.pool_.createApi(i);return this.rackApi_.add(s,e.index)}removePage(e){this.rackApi_.remove(this.rackApi_.children[e])}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}onSelect_(e){this.emitter_.emit("select",new $c(this,e.rawValue))}},kp=class extends Hi{get title(){var e;return(e=this.controller.itemController.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller.itemController.props.set("title",e)}get selected(){return this.controller.props.get("selected")}set selected(e){this.controller.props.set("selected",e)}get children(){return this.rackApi_.children}addButton(e){return this.rackApi_.addButton(e)}addFolder(e){return this.rackApi_.addFolder(e)}addTab(e){return this.rackApi_.addTab(e)}add(e,t){this.rackApi_.add(e,t)}remove(e){this.rackApi_.remove(e)}addBinding(e,t,i){return this.rackApi_.addBinding(e,t,i)}addBlade(e){return this.rackApi_.addBlade(e)}};const sr=-1;let Vp=class{constructor(){this.onItemSelectedChange_=this.onItemSelectedChange_.bind(this),this.empty=k(!0),this.selectedIndex=k(sr),this.items_=[]}add(e,t){const i=t??this.items_.length;this.items_.splice(i,0,e),e.emitter.on("change",this.onItemSelectedChange_),this.keepSelection_()}remove(e){const t=this.items_.indexOf(e);t<0||(this.items_.splice(t,1),e.emitter.off("change",this.onItemSelectedChange_),this.keepSelection_())}keepSelection_(){if(this.items_.length===0){this.selectedIndex.rawValue=sr,this.empty.rawValue=!0;return}const e=this.items_.findIndex(t=>t.rawValue);e<0?(this.items_.forEach((t,i)=>{t.rawValue=i===0}),this.selectedIndex.rawValue=0):(this.items_.forEach((t,i)=>{t.rawValue=i===e}),this.selectedIndex.rawValue=e),this.empty.rawValue=!1}onItemSelectedChange_(e){if(e.rawValue){const t=this.items_.findIndex(i=>i===e.sender);this.items_.forEach((i,s)=>{i.rawValue=s===t}),this.selectedIndex.rawValue=t}else this.keepSelection_()}};const Tt=f("tab");let Sp=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Tt(),Oo()),t.viewProps.bindClassModifiers(this.element),ge(t.empty,gt(this.element,Tt(void 0,"nop")));const i=e.createElement("div");i.classList.add(Tt("t")),this.element.appendChild(i),this.itemsElement=i;const s=e.createElement("div");s.classList.add(Tt("i")),this.element.appendChild(s);const r=e.createElement("div");r.classList.add(Tt("c")),this.element.appendChild(r),this.contentsElement=r}},rr=class extends qi{constructor(e,t){const i=new Vp,s=new Sp(e,{empty:i.empty,viewProps:t.viewProps});super({blade:t.blade,rackController:new Gi({blade:t.blade,element:s.contentsElement,viewProps:t.viewProps}),view:s}),this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this);const r=this.rackController.rack;r.emitter.on("add",this.onRackAdd_),r.emitter.on("remove",this.onRackRemove_),this.tab=i}add(e,t){this.rackController.rack.add(e,t)}remove(e){this.rackController.rack.remove(this.rackController.rack.children[e])}onRackAdd_(e){if(!e.root)return;const t=e.bladeController;yo(this.view.itemsElement,t.itemController.view.element,e.index),t.itemController.viewProps.set("parent",this.viewProps),this.tab.add(t.props.value("selected"))}onRackRemove_(e){if(!e.root)return;const t=e.bladeController;Ki(t.itemController.view.element),t.itemController.viewProps.set("parent",null),this.tab.remove(t.props.value("selected"))}};const Do=q({id:"tab",type:"blade",accept(n){const e=S(n,t=>({pages:t.required.array(t.required.object({title:t.required.string})),view:t.required.constant("tab")}));return!e||e.pages.length===0?null:{params:e}},controller(n){const e=new rr(n.document,{blade:n.blade,viewProps:n.viewProps});return n.params.pages.forEach(t=>{const i=new yi(n.document,{blade:xt(),itemProps:v.fromObject({selected:!1,title:t.title}),props:v.fromObject({selected:!1}),viewProps:et.create()});e.add(i)}),e},api(n){return n.controller instanceof rr?new Ep(n.controller,n.pool):n.controller instanceof yi?new kp(n.controller,n.pool):null}});function Tp(n,e){const t=n.accept(e.params);if(!t)return null;const i=S(e.params,s=>({disabled:s.optional.boolean,hidden:s.optional.boolean}));return n.controller({blade:xt(),document:e.document,params:Object.assign(Object.assign({},t.params),{disabled:i==null?void 0:i.disabled,hidden:i==null?void 0:i.hidden}),viewProps:et.create({disabled:i==null?void 0:i.disabled,hidden:i==null?void 0:i.hidden})})}let Xi=class extends Kt{get options(){return this.controller.valueController.props.get("options")}set options(e){this.controller.valueController.props.set("options",e)}},Lp=class{constructor(){this.disabled=!1,this.emitter=new M}dispose(){}tick(){this.disabled||this.emitter.emit("tick",{sender:this})}},$p=class{constructor(e,t){this.disabled_=!1,this.timerId_=null,this.onTick_=this.onTick_.bind(this),this.doc_=e,this.emitter=new M,this.interval_=t,this.setTimer_()}get disabled(){return this.disabled_}set disabled(e){this.disabled_=e,this.disabled_?this.clearTimer_():this.setTimer_()}dispose(){this.clearTimer_()}clearTimer_(){if(this.timerId_===null)return;const e=this.doc_.defaultView;e&&e.clearInterval(this.timerId_),this.timerId_=null}setTimer_(){if(this.clearTimer_(),this.interval_<=0)return;const e=this.doc_.defaultView;e&&(this.timerId_=e.setInterval(this.onTick_,this.interval_))}onTick_(){this.disabled_||this.emitter.emit("tick",{sender:this})}},en=class{constructor(e){this.constraints=e}constrain(e){return this.constraints.reduce((t,i)=>i.constrain(t),e)}};function yn(n,e){if(n instanceof e)return n;if(n instanceof en){const t=n.constraints.reduce((i,s)=>i||(s instanceof e?s:null),null);if(t)return t}return null}let tn=class{constructor(e){this.values=v.fromObject({options:e})}constrain(e){const t=this.values.get("options");return t.length===0||t.filter(s=>s.value===e).length>0?e:t[0].value}};function nn(n){var e;const t=Ci;if(Array.isArray(n))return(e=S({items:n},i=>({items:i.required.array(i.required.object({text:i.required.string,value:i.required.raw}))})))===null||e===void 0?void 0:e.items;if(typeof n=="object")return t.required.raw(n).value}function Qi(n){if(Array.isArray(n))return n;const e=[];return Object.keys(n).forEach(t=>{e.push({text:t,value:n[t]})}),e}function Ji(n){return P(n)?null:new tn(Qi(n))}const Jn=f("lst");let Ap=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.props_=t.props,this.element=e.createElement("div"),this.element.classList.add(Jn()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("select");i.classList.add(Jn("s")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.selectElement=i;const s=e.createElement("div");s.classList.add(Jn("m")),s.appendChild(Nn(e,"dropdown")),this.element.appendChild(s),t.value.emitter.on("change",this.onValueChange_),this.value_=t.value,he(this.props_,"options",r=>{Eo(this.selectElement),r.forEach(o=>{const a=e.createElement("option");a.textContent=o.text,this.selectElement.appendChild(a)}),this.update_()})}update_(){const e=this.props_.get("options").map(t=>t.value);this.selectElement.selectedIndex=e.indexOf(this.value_.rawValue)}onValueChange_(){this.update_()}},Ne=class{constructor(e,t){this.onSelectChange_=this.onSelectChange_.bind(this),this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new Ap(e,{props:this.props,value:this.value,viewProps:this.viewProps}),this.view.selectElement.addEventListener("change",this.onSelectChange_)}onSelectChange_(e){const t=e.currentTarget;this.value.rawValue=this.props.get("options")[t.selectedIndex].value}importProps(e){return Q(e,null,t=>({options:t.required.custom(nn)}),t=>(this.props.set("options",Qi(t.options)),!0))}exportProps(){return J(null,{options:this.props.get("options")})}};const or=f("pop");let Mp=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(or()),t.viewProps.bindClassModifiers(this.element),ge(t.shows,gt(this.element,or(void 0,"v")))}},Bo=class{constructor(e,t){this.shows=k(!1),this.viewProps=t.viewProps,this.view=new Mp(e,{shows:this.shows,viewProps:this.viewProps})}};const ar=f("txt");let Op=class{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.element=e.createElement("div"),this.element.classList.add(ar()),t.viewProps.bindClassModifiers(this.element),this.props_=t.props,this.props_.emitter.on("change",this.onChange_);const i=e.createElement("input");i.classList.add(ar("i")),i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,t.value.emitter.on("change",this.onChange_),this.value_=t.value,this.refresh()}refresh(){const e=this.props_.get("formatter");this.inputElement.value=e(this.value_.rawValue)}onChange_(){this.refresh()}},Ut=class{constructor(e,t){this.onInputChange_=this.onInputChange_.bind(this),this.parser_=t.parser,this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new Op(e,{props:t.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_)}onInputChange_(e){const i=e.currentTarget.value,s=this.parser_(i);P(s)||(this.value.rawValue=s),this.view.refresh()}};function Rp(n){return String(n)}function No(n){return n==="false"?!1:!!n}function lr(n){return Rp(n)}function Dp(n){return e=>n.reduce((t,i)=>t!==null?t:i(e),null)}const Bp=W(0);function En(n){return Bp(n)+"%"}function Fo(n){return String(n)}function Ei(n){return n}function Pt({primary:n,secondary:e,forward:t,backward:i}){let s=!1;function r(o){s||(s=!0,o(),s=!1)}n.emitter.on("change",o=>{r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),o.options)})}),e.emitter.on("change",o=>{r(()=>{n.setRawValue(i(n.rawValue,e.rawValue),o.options)}),r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),o.options)})}),r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),{forceEmit:!1,last:!0})})}function G(n,e){const t=n*(e.altKey?.1:1)*(e.shiftKey?10:1);return e.upKey?+t:e.downKey?-t:0}function Ht(n){return{altKey:n.altKey,downKey:n.key==="ArrowDown",shiftKey:n.shiftKey,upKey:n.key==="ArrowUp"}}function xe(n){return{altKey:n.altKey,downKey:n.key==="ArrowLeft",shiftKey:n.shiftKey,upKey:n.key==="ArrowRight"}}function Np(n){return n==="ArrowUp"||n==="ArrowDown"}function jo(n){return Np(n)||n==="ArrowLeft"||n==="ArrowRight"}function Zn(n,e){var t,i;const s=e.ownerDocument.defaultView,r=e.getBoundingClientRect();return{x:n.pageX-(((t=s&&s.scrollX)!==null&&t!==void 0?t:0)+r.left),y:n.pageY-(((i=s&&s.scrollY)!==null&&i!==void 0?i:0)+r.top)}}let tt=class{constructor(e){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_=e,this.emitter=new M,e.addEventListener("touchstart",this.onTouchStart_,{passive:!1}),e.addEventListener("touchmove",this.onTouchMove_,{passive:!0}),e.addEventListener("touchend",this.onTouchEnd_),e.addEventListener("mousedown",this.onMouseDown_)}computePosition_(e){const t=this.elem_.getBoundingClientRect();return{bounds:{width:t.width,height:t.height},point:e?{x:e.x,y:e.y}:null}}onMouseDown_(e){var t;e.preventDefault(),(t=e.currentTarget)===null||t===void 0||t.focus();const i=this.elem_.ownerDocument;i.addEventListener("mousemove",this.onDocumentMouseMove_),i.addEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("down",{altKey:e.altKey,data:this.computePosition_(Zn(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onDocumentMouseMove_(e){this.emitter.emit("move",{altKey:e.altKey,data:this.computePosition_(Zn(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onDocumentMouseUp_(e){const t=this.elem_.ownerDocument;t.removeEventListener("mousemove",this.onDocumentMouseMove_),t.removeEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("up",{altKey:e.altKey,data:this.computePosition_(Zn(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onTouchStart_(e){e.preventDefault();const t=e.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("down",{altKey:e.altKey,data:this.computePosition_(t?{x:t.clientX-i.left,y:t.clientY-i.top}:void 0),sender:this,shiftKey:e.shiftKey}),this.lastTouch_=t}onTouchMove_(e){const t=e.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("move",{altKey:e.altKey,data:this.computePosition_(t?{x:t.clientX-i.left,y:t.clientY-i.top}:void 0),sender:this,shiftKey:e.shiftKey}),this.lastTouch_=t}onTouchEnd_(e){var t;const i=(t=e.targetTouches.item(0))!==null&&t!==void 0?t:this.lastTouch_,s=this.elem_.getBoundingClientRect();this.emitter.emit("up",{altKey:e.altKey,data:this.computePosition_(i?{x:i.clientX-s.left,y:i.clientY-s.top}:void 0),sender:this,shiftKey:e.shiftKey})}};const Z=f("txt");let Fp=class{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onChange_),this.element=e.createElement("div"),this.element.classList.add(Z(),Z(void 0,"num")),t.arrayPosition&&this.element.classList.add(Z(void 0,t.arrayPosition)),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("input");i.classList.add(Z("i")),i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,this.onDraggingChange_=this.onDraggingChange_.bind(this),this.dragging_=t.dragging,this.dragging_.emitter.on("change",this.onDraggingChange_),this.element.classList.add(Z()),this.inputElement.classList.add(Z("i"));const s=e.createElement("div");s.classList.add(Z("k")),this.element.appendChild(s),this.knobElement=s;const r=e.createElementNS(ue,"svg");r.classList.add(Z("g")),this.knobElement.appendChild(r);const o=e.createElementNS(ue,"path");o.classList.add(Z("gb")),r.appendChild(o),this.guideBodyElem_=o;const a=e.createElementNS(ue,"path");a.classList.add(Z("gh")),r.appendChild(a),this.guideHeadElem_=a;const l=e.createElement("div");l.classList.add(f("tt")()),this.knobElement.appendChild(l),this.tooltipElem_=l,t.value.emitter.on("change",this.onChange_),this.value=t.value,this.refresh()}onDraggingChange_(e){if(e.rawValue===null){this.element.classList.remove(Z(void 0,"drg"));return}this.element.classList.add(Z(void 0,"drg"));const t=e.rawValue/this.props_.get("pointerScale"),i=t+(t>0?-1:t<0?1:0),s=R(-i,-4,4);this.guideHeadElem_.setAttributeNS(null,"d",[`M ${i+s},0 L${i},4 L${i+s},8`,`M ${t},-1 L${t},9`].join(" ")),this.guideBodyElem_.setAttributeNS(null,"d",`M 0,4 L${t},4`);const r=this.props_.get("formatter");this.tooltipElem_.textContent=r(this.value.rawValue),this.tooltipElem_.style.left=`${t}px`}refresh(){const e=this.props_.get("formatter");this.inputElement.value=e(this.value.rawValue)}onChange_(){this.refresh()}},sn=class{constructor(e,t){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_=t.parser,this.props=t.props,this.sliderProps_=(i=t.sliderProps)!==null&&i!==void 0?i:null,this.value=t.value,this.viewProps=t.viewProps,this.dragging_=k(null),this.view=new Fp(e,{arrayPosition:t.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 s=new tt(this.view.knobElement);s.emitter.on("down",this.onPointerDown_),s.emitter.on("move",this.onPointerMove_),s.emitter.on("up",this.onPointerUp_)}constrainValue_(e){var t,i;const s=(t=this.sliderProps_)===null||t===void 0?void 0:t.get("min"),r=(i=this.sliderProps_)===null||i===void 0?void 0:i.get("max");let o=e;return s!==void 0&&(o=Math.max(o,s)),r!==void 0&&(o=Math.min(o,r)),o}onInputChange_(e){const i=e.currentTarget.value,s=this.parser_(i);P(s)||(this.value.rawValue=this.constrainValue_(s)),this.view.refresh()}onInputKeyDown_(e){const t=G(this.props.get("keyScale"),Ht(e));t!==0&&this.value.setRawValue(this.constrainValue_(this.value.rawValue+t),{forceEmit:!1,last:!1})}onInputKeyUp_(e){G(this.props.get("keyScale"),Ht(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}onPointerDown_(){this.originRawValue_=this.value.rawValue,this.dragging_.rawValue=0}computeDraggingValue_(e){if(!e.point)return null;const t=e.point.x-e.bounds.width/2;return this.constrainValue_(this.originRawValue_+t*this.props.get("pointerScale"))}onPointerMove_(e){const t=this.computeDraggingValue_(e.data);t!==null&&(this.value.setRawValue(t,{forceEmit:!1,last:!1}),this.dragging_.rawValue=this.value.rawValue-this.originRawValue_)}onPointerUp_(e){const t=this.computeDraggingValue_(e.data);t!==null&&(this.value.setRawValue(t,{forceEmit:!0,last:!0}),this.dragging_.rawValue=null)}};const ei=f("sld");let jp=class{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onChange_),this.element=e.createElement("div"),this.element.classList.add(ei()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(ei("t")),t.viewProps.bindTabIndex(i),this.element.appendChild(i),this.trackElement=i;const s=e.createElement("div");s.classList.add(ei("k")),this.trackElement.appendChild(s),this.knobElement=s,t.value.emitter.on("change",this.onChange_),this.value=t.value,this.update_()}update_(){const e=R(_(this.value.rawValue,this.props_.get("min"),this.props_.get("max"),0,100),0,100);this.knobElement.style.width=`${e}%`}onChange_(){this.update_()}},Ip=class{constructor(e,t){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=t.value,this.viewProps=t.viewProps,this.props=t.props,this.view=new jp(e,{props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new tt(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_(e,t){e.point&&this.value.setRawValue(_(R(e.point.x,0,e.bounds.width),0,e.bounds.width,this.props.get("min"),this.props.get("max")),t)}onPointerDownOrMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=G(this.props.get("keyScale"),xe(e));t!==0&&this.value.setRawValue(this.value.rawValue+t,{forceEmit:!1,last:!1})}onKeyUp_(e){G(this.props.get("keyScale"),xe(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}};const ti=f("sldtxt");let zp=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(ti());const i=e.createElement("div");i.classList.add(ti("s")),this.sliderView_=t.sliderView,i.appendChild(this.sliderView_.element),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(ti("t")),this.textView_=t.textView,s.appendChild(this.textView_.element),this.element.appendChild(s)}},kn=class{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.sliderC_=new Ip(e,{props:t.sliderProps,value:t.value,viewProps:this.viewProps}),this.textC_=new sn(e,{parser:t.parser,props:t.textProps,sliderProps:t.sliderProps,value:t.value,viewProps:t.viewProps}),this.view=new zp(e,{sliderView:this.sliderC_.view,textView:this.textC_.view})}get sliderController(){return this.sliderC_}get textController(){return this.textC_}importProps(e){return Q(e,null,t=>({max:t.required.number,min:t.required.number}),t=>{const i=this.sliderC_.props;return i.set("max",t.max),i.set("min",t.min),!0})}exportProps(){const e=this.sliderC_.props;return J(null,{max:e.get("max"),min:e.get("min")})}};function Io(n){return{sliderProps:new v({keyScale:n.keyScale,max:n.max,min:n.min}),textProps:new v({formatter:k(n.formatter),keyScale:n.keyScale,pointerScale:k(n.pointerScale)})}}const Kp={containerUnitSize:"cnt-usz"};function zo(n){return`--${Kp[n]}`}function qt(n){return xo(n)}function Me(n){if(gi(n))return S(n,qt)}function we(n,e){if(!n)return;const t=[],i=_o(n,e);i&&t.push(i);const s=go(n);return s&&t.push(s),new en(t)}function Up(n){return n?n.major===Ct.major:!1}function Ko(n){if(n==="inline"||n==="popup")return n}function rn(n,e){n.write(e)}const dn=f("ckb");let Hp=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.element=e.createElement("div"),this.element.classList.add(dn()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("label");i.classList.add(dn("l")),this.element.appendChild(i),this.labelElement=i;const s=e.createElement("input");s.classList.add(dn("i")),s.type="checkbox",this.labelElement.appendChild(s),this.inputElement=s,t.viewProps.bindDisabled(this.inputElement);const r=e.createElement("div");r.classList.add(dn("w")),this.labelElement.appendChild(r);const o=Nn(e,"check");r.appendChild(o),t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.update_()}update_(){this.inputElement.checked=this.value.rawValue}onValueChange_(){this.update_()}},qp=class{constructor(e,t){this.onInputChange_=this.onInputChange_.bind(this),this.onLabelMouseDown_=this.onLabelMouseDown_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.view=new Hp(e,{value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_),this.view.labelElement.addEventListener("mousedown",this.onLabelMouseDown_)}onInputChange_(e){const t=e.currentTarget;this.value.rawValue=t.checked,e.preventDefault(),e.stopPropagation()}onLabelMouseDown_(e){e.preventDefault()}};function Gp(n){const e=[],t=Ji(n.options);return t&&e.push(t),new en(e)}const Wp=q({id:"input-bool",type:"input",accept:(n,e)=>{if(typeof n!="boolean")return null;const t=S(e,i=>({options:i.optional.custom(nn),readonly:i.optional.constant(!1)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>No,constraint:n=>Gp(n.params),writer:n=>rn},controller:n=>{const e=n.document,t=n.value,i=n.constraint,s=i&&yn(i,tn);return s?new Ne(e,{props:new v({options:s.values.value("options")}),value:t,viewProps:n.viewProps}):new qp(e,{value:t,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="boolean"?null:n.controller.valueController instanceof Ne?new Xi(n.controller):null}}),ze=f("col");let Yp=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(ze()),t.foldable.bindExpandedClass(this.element,ze(void 0,"expanded")),he(t.foldable,"completed",gt(this.element,ze(void 0,"cpl")));const i=e.createElement("div");i.classList.add(ze("h")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(ze("s")),i.appendChild(s),this.swatchElement=s;const r=e.createElement("div");if(r.classList.add(ze("t")),i.appendChild(r),this.textElement=r,t.pickerLayout==="inline"){const o=e.createElement("div");o.classList.add(ze("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}};function Xp(n,e,t){const i=R(n/255,0,1),s=R(e/255,0,1),r=R(t/255,0,1),o=Math.max(i,s,r),a=Math.min(i,s,r),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=(s-r)/l:s===o?c=2+(r-i)/l:c=4+(i-s)/l,c=c/6+(c<0?1:0)),[c*360,p*100,u*100]}function Qp(n,e,t){const i=(n%360+360)%360,s=R(e/100,0,1),r=R(t/100,0,1),o=(1-Math.abs(2*r-1))*s,a=o*(1-Math.abs(i/60%2-1)),l=r-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 Jp(n,e,t){const i=R(n/255,0,1),s=R(e/255,0,1),r=R(t/255,0,1),o=Math.max(i,s,r),a=Math.min(i,s,r),l=o-a;let c;l===0?c=0:o===i?c=60*(((s-r)/l%6+6)%6):o===s?c=60*((r-i)/l+2):c=60*((i-s)/l+4);const p=o===0?0:l/o,u=o;return[c,p*100,u*100]}function Uo(n,e,t){const i=bo(n,360),s=R(e/100,0,1),r=R(t/100,0,1),o=r*s,a=o*(1-Math.abs(i/60%2-1)),l=r-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 Zp(n,e,t){const i=t+e*(100-Math.abs(2*t-100))/200;return[n,i!==0?e*(100-Math.abs(2*t-100))/i:0,t+e*(100-Math.abs(2*t-100))/(2*100)]}function eu(n,e,t){const i=100-Math.abs(t*(200-e)/100-100);return[n,i!==0?e*t/i:0,t*(200-e)/(2*100)]}function de(n){return[n[0],n[1],n[2]]}function jn(n,e){return[n[0],n[1],n[2],e]}const tu={hsl:{hsl:(n,e,t)=>[n,e,t],hsv:Zp,rgb:Qp},hsv:{hsl:eu,hsv:(n,e,t)=>[n,e,t],rgb:Uo},rgb:{hsl:Xp,hsv:Jp,rgb:(n,e,t)=>[n,e,t]}};function ft(n,e){return[e==="float"?1:n==="rgb"?255:360,e==="float"?1:n==="rgb"?255:100,e==="float"?1:n==="rgb"?255:100]}function nu(n,e){return n===e?e:bo(n,e)}function Ho(n,e,t){var i;const s=ft(e,t);return[e==="rgb"?R(n[0],0,s[0]):nu(n[0],s[0]),R(n[1],0,s[1]),R(n[2],0,s[2]),R((i=n[3])!==null&&i!==void 0?i:1,0,1)]}function cr(n,e,t,i){const s=ft(e,t),r=ft(e,i);return n.map((o,a)=>o/s[a]*r[a])}function qo(n,e,t){const i=cr(n,e.mode,e.type,"int"),s=tu[e.mode][t.mode](...i);return cr(s,t.mode,"int",t.type)}let g=class Go{static black(){return new Go([0,0,0],"rgb")}constructor(e,t){this.type="int",this.mode=t,this.comps_=Ho(e,t,this.type)}getComponents(e){return jn(qo(de(this.comps_),{mode:this.mode,type:this.type},{mode:e??this.mode,type:this.type}),this.comps_[3])}toRgbaObject(){const e=this.getComponents("rgb");return{r:e[0],g:e[1],b:e[2],a:e[3]}}};const ke=f("colp");let iu=class{constructor(e,t){this.alphaViews_=null,this.element=e.createElement("div"),this.element.classList.add(ke()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(ke("hsv"));const s=e.createElement("div");s.classList.add(ke("sv")),this.svPaletteView_=t.svPaletteView,s.appendChild(this.svPaletteView_.element),i.appendChild(s);const r=e.createElement("div");r.classList.add(ke("h")),this.hPaletteView_=t.hPaletteView,r.appendChild(this.hPaletteView_.element),i.appendChild(r),this.element.appendChild(i);const o=e.createElement("div");if(o.classList.add(ke("rgb")),this.textsView_=t.textsView,o.appendChild(this.textsView_.element),this.element.appendChild(o),t.alphaViews){this.alphaViews_={palette:t.alphaViews.palette,text:t.alphaViews.text};const a=e.createElement("div");a.classList.add(ke("a"));const l=e.createElement("div");l.classList.add(ke("ap")),l.appendChild(this.alphaViews_.palette.element),a.appendChild(l);const c=e.createElement("div");c.classList.add(ke("at")),c.appendChild(this.alphaViews_.text.element),a.appendChild(c),this.element.appendChild(a)}}get allFocusableElements(){const e=[this.svPaletteView_.element,this.hPaletteView_.element,this.textsView_.modeSelectElement,...this.textsView_.inputViews.map(t=>t.inputElement)];return this.alphaViews_&&e.push(this.alphaViews_.palette.element,this.alphaViews_.text.inputElement),e}};function su(n){return n==="int"?"int":n==="float"?"float":void 0}function Zi(n){return S(n,e=>({color:e.optional.object({alpha:e.optional.boolean,type:e.optional.custom(su)}),expanded:e.optional.boolean,picker:e.optional.custom(Ko),readonly:e.optional.constant(!1)}))}function Ye(n){return n?.1:1}function Wo(n){var e;return(e=n.color)===null||e===void 0?void 0:e.type}let es=class{constructor(e,t){this.type="float",this.mode=t,this.comps_=Ho(e,t,this.type)}getComponents(e){return jn(qo(de(this.comps_),{mode:this.mode,type:this.type},{mode:e??this.mode,type:this.type}),this.comps_[3])}toRgbaObject(){const e=this.getComponents("rgb");return{r:e[0],g:e[1],b:e[2],a:e[3]}}};const ru={int:(n,e)=>new g(n,e),float:(n,e)=>new es(n,e)};function ts(n,e,t){return ru[t](n,e)}function ou(n){return n.type==="float"}function au(n){return n.type==="int"}function lu(n){const e=n.getComponents(),t=ft(n.mode,"int");return new g([Math.round(_(e[0],0,1,0,t[0])),Math.round(_(e[1],0,1,0,t[1])),Math.round(_(e[2],0,1,0,t[2])),e[3]],n.mode)}function cu(n){const e=n.getComponents(),t=ft(n.mode,"int");return new es([_(e[0],0,t[0],0,1),_(e[1],0,t[1],0,1),_(e[2],0,t[2],0,1),e[3]],n.mode)}function U(n,e){if(n.type===e)return n;if(au(n)&&e==="float")return cu(n);if(ou(n)&&e==="int")return lu(n);throw j.shouldNeverHappen()}function pu(n,e){return n.alpha===e.alpha&&n.mode===e.mode&&n.notation===e.notation&&n.type===e.type}function ne(n,e){const t=n.match(/^(.+)%$/);return Math.min(t?parseFloat(t[1])*.01*e:parseFloat(n),e)}const uu={deg:n=>n,grad:n=>n*360/400,rad:n=>n*360/(2*Math.PI),turn:n=>n*360};function Yo(n){const e=n.match(/^([0-9.]+?)(deg|grad|rad|turn)$/);if(!e)return parseFloat(n);const t=parseFloat(e[1]),i=e[2];return uu[i](t)}function Xo(n){const e=n.match(/^rgb\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[ne(e[1],255),ne(e[2],255),ne(e[3],255)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function hu(n){const e=Xo(n);return e?new g(e,"rgb"):null}function Qo(n){const e=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(!e)return null;const t=[ne(e[1],255),ne(e[2],255),ne(e[3],255),ne(e[4],1)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function du(n){const e=Qo(n);return e?new g(e,"rgb"):null}function Jo(n){const e=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(!e)return null;const t=[Yo(e[1]),ne(e[2],100),ne(e[3],100)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function mu(n){const e=Jo(n);return e?new g(e,"hsl"):null}function Zo(n){const e=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(!e)return null;const t=[Yo(e[1]),ne(e[2],100),ne(e[3],100),ne(e[4],1)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function vu(n){const e=Zo(n);return e?new g(e,"hsl"):null}function ea(n){const e=n.match(/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(e)return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)];const t=n.match(/^(?:#|0x)([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]:null}function bu(n){const e=ea(n);return e?new g(e,"rgb"):null}function ta(n){const e=n.match(/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(e)return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16),_(parseInt(e[4]+e[4],16),0,255,0,1)];const t=n.match(/^(?:#|0x)?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),_(parseInt(t[4],16),0,255,0,1)]:null}function fu(n){const e=ta(n);return e?new g(e,"rgb"):null}function na(n){const e=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(!e)return null;const t=[parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function pr(n){return e=>{const t=na(e);return t?ts(t,"rgb",n):null}}function ia(n){const e=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(!e)return null;const t=[parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]),parseFloat(e[4])];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function ur(n){return e=>{const t=ia(e);return t?ts(t,"rgb",n):null}}const wu=[{parser:ea,result:{alpha:!1,mode:"rgb",notation:"hex"}},{parser:ta,result:{alpha:!0,mode:"rgb",notation:"hex"}},{parser:Xo,result:{alpha:!1,mode:"rgb",notation:"func"}},{parser:Qo,result:{alpha:!0,mode:"rgb",notation:"func"}},{parser:Jo,result:{alpha:!1,mode:"hsl",notation:"func"}},{parser:Zo,result:{alpha:!0,mode:"hsl",notation:"func"}},{parser:na,result:{alpha:!1,mode:"rgb",notation:"object"}},{parser:ia,result:{alpha:!0,mode:"rgb",notation:"object"}}];function _u(n){return wu.reduce((e,{parser:t,result:i})=>e||(t(n)?i:null),null)}function gu(n,e="int"){const t=_u(n);return t?t.notation==="hex"&&e!=="float"?Object.assign(Object.assign({},t),{type:"int"}):t.notation==="func"?Object.assign(Object.assign({},t),{type:e}):null:null}function on(n){const e=[bu,fu,hu,du,mu,vu];n==="int"&&e.push(pr("int"),ur("int")),n==="float"&&e.push(pr("float"),ur("float"));const t=Dp(e);return i=>{const s=t(i);return s?U(s,n):null}}function Cu(n){const e=on("int");if(typeof n!="string")return g.black();const t=e(n);return t??g.black()}function sa(n){const e=R(Math.floor(n),0,255).toString(16);return e.length===1?`0${e}`:e}function ns(n,e="#"){const t=de(n.getComponents("rgb")).map(sa).join("");return`${e}${t}`}function is(n,e="#"){const t=n.getComponents("rgb"),i=[t[0],t[1],t[2],t[3]*255].map(sa).join("");return`${e}${i}`}function ra(n){const e=W(0),t=U(n,"int");return`rgb(${de(t.getComponents("rgb")).map(s=>e(s)).join(", ")})`}function bn(n){const e=W(2),t=W(0);return`rgba(${U(n,"int").getComponents("rgb").map((r,o)=>(o===3?e:t)(r)).join(", ")})`}function xu(n){const e=[W(0),En,En],t=U(n,"int");return`hsl(${de(t.getComponents("hsl")).map((s,r)=>e[r](s)).join(", ")})`}function Pu(n){const e=[W(0),En,En,W(2)];return`hsla(${U(n,"int").getComponents("hsl").map((s,r)=>e[r](s)).join(", ")})`}function oa(n,e){const t=W(e==="float"?2:0),i=["r","g","b"],s=U(n,e);return`{${de(s.getComponents("rgb")).map((o,a)=>`${i[a]}: ${t(o)}`).join(", ")}}`}function yu(n){return e=>oa(e,n)}function aa(n,e){const t=W(2),i=W(e==="float"?2:0),s=["r","g","b","a"];return`{${U(n,e).getComponents("rgb").map((a,l)=>{const c=l===3?t:i;return`${s[l]}: ${c(a)}`}).join(", ")}}`}function Eu(n){return e=>aa(e,n)}const ku=[{format:{alpha:!1,mode:"rgb",notation:"hex",type:"int"},stringifier:ns},{format:{alpha:!0,mode:"rgb",notation:"hex",type:"int"},stringifier:is},{format:{alpha:!1,mode:"rgb",notation:"func",type:"int"},stringifier:ra},{format:{alpha:!0,mode:"rgb",notation:"func",type:"int"},stringifier:bn},{format:{alpha:!1,mode:"hsl",notation:"func",type:"int"},stringifier:xu},{format:{alpha:!0,mode:"hsl",notation:"func",type:"int"},stringifier:Pu},...["int","float"].reduce((n,e)=>[...n,{format:{alpha:!1,mode:"rgb",notation:"object",type:e},stringifier:yu(e)},{format:{alpha:!0,mode:"rgb",notation:"object",type:e},stringifier:Eu(e)}],[])];function la(n){return ku.reduce((e,t)=>e||(pu(t.format,n)?t.stringifier:null),null)}const Lt=f("apl");let Vu=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(Lt()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("div");i.classList.add(Lt("b")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(Lt("c")),i.appendChild(s),this.colorElem_=s;const r=e.createElement("div");r.classList.add(Lt("m")),this.element.appendChild(r),this.markerElem_=r;const o=e.createElement("div");o.classList.add(Lt("p")),this.markerElem_.appendChild(o),this.previewElem_=o,this.update_()}update_(){const e=this.value.rawValue,t=e.getComponents("rgb"),i=new g([t[0],t[1],t[2],0],"rgb"),s=new g([t[0],t[1],t[2],255],"rgb"),r=["to right",bn(i),bn(s)];this.colorElem_.style.background=`linear-gradient(${r.join(",")})`,this.previewElem_.style.backgroundColor=bn(e);const o=_(t[3],0,1,0,100);this.markerElem_.style.left=`${o}%`}onValueChange_(){this.update_()}},Su=class{constructor(e,t){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=t.value,this.viewProps=t.viewProps,this.view=new Vu(e,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new tt(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_(e,t){if(!e.point)return;const i=e.point.x/e.bounds.width,s=this.value.rawValue,[r,o,a]=s.getComponents("hsv");this.value.setRawValue(new g([r,o,a,i],"hsv"),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=G(Ye(!0),xe(e));if(t===0)return;const i=this.value.rawValue,[s,r,o,a]=i.getComponents("hsv");this.value.setRawValue(new g([s,r,o,a+t],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(e){G(Ye(!0),xe(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}};const ot=f("coltxt");function Tu(n){const e=n.createElement("select"),t=[{text:"RGB",value:"rgb"},{text:"HSL",value:"hsl"},{text:"HSV",value:"hsv"},{text:"HEX",value:"hex"}];return e.appendChild(t.reduce((i,s)=>{const r=n.createElement("option");return r.textContent=s.text,r.value=s.value,i.appendChild(r),i},n.createDocumentFragment())),e}let Lu=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(ot()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(ot("m")),this.modeElem_=Tu(e),this.modeElem_.classList.add(ot("ms")),i.appendChild(this.modeSelectElement),t.viewProps.bindDisabled(this.modeElem_);const s=e.createElement("div");s.classList.add(ot("mm")),s.appendChild(Nn(e,"dropdown")),i.appendChild(s),this.element.appendChild(i);const r=e.createElement("div");r.classList.add(ot("w")),this.element.appendChild(r),this.inputsElem_=r,this.inputViews_=t.inputViews,this.applyInputViews_(),ge(t.mode,o=>{this.modeElem_.value=o})}get modeSelectElement(){return this.modeElem_}get inputViews(){return this.inputViews_}set inputViews(e){this.inputViews_=e,this.applyInputViews_()}applyInputViews_(){Eo(this.inputsElem_);const e=this.element.ownerDocument;this.inputViews_.forEach(t=>{const i=e.createElement("div");i.classList.add(ot("c")),i.appendChild(t.element),this.inputsElem_.appendChild(i)})}};function $u(n){return W(n==="float"?2:0)}function Au(n,e,t){const i=ft(n,e)[t];return new Jt({min:0,max:i})}function Mu(n,e,t){return new sn(n,{arrayPosition:t===0?"fst":t===2?"lst":"mid",parser:e.parser,props:v.fromObject({formatter:$u(e.colorType),keyScale:Ye(!1),pointerScale:e.colorType==="float"?.01:1}),value:k(0,{constraint:Au(e.colorMode,e.colorType,t)}),viewProps:e.viewProps})}function Ou(n,e){const t={colorMode:e.colorMode,colorType:e.colorType,parser:Ce,viewProps:e.viewProps};return[0,1,2].map(i=>{const s=Mu(n,t,i);return Pt({primary:e.value,secondary:s.value,forward(r){return U(r,e.colorType).getComponents(e.colorMode)[i]},backward(r,o){const a=e.colorMode,c=U(r,e.colorType).getComponents(a);c[i]=o;const p=ts(jn(de(c),c[3]),a,e.colorType);return U(p,"int")}}),s})}function Ru(n,e){const t=new Ut(n,{parser:on("int"),props:v.fromObject({formatter:ns}),value:k(g.black()),viewProps:e.viewProps});return Pt({primary:e.value,secondary:t.value,forward:i=>new g(de(i.getComponents()),i.mode),backward:(i,s)=>new g(jn(de(s.getComponents(i.mode)),i.getComponents()[3]),i.mode)}),[t]}function Du(n){return n!=="hex"}let Bu=class{constructor(e,t){this.onModeSelectChange_=this.onModeSelectChange_.bind(this),this.colorType_=t.colorType,this.value=t.value,this.viewProps=t.viewProps,this.colorMode=k(this.value.rawValue.mode),this.ccs_=this.createComponentControllers_(e),this.view=new Lu(e,{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_(e){const t=this.colorMode.rawValue;return Du(t)?Ou(e,{colorMode:t,colorType:this.colorType_,value:this.value,viewProps:this.viewProps}):Ru(e,{value:this.value,viewProps:this.viewProps})}onModeSelectChange_(e){const t=e.currentTarget;this.colorMode.rawValue=t.value,this.ccs_=this.createComponentControllers_(this.view.element.ownerDocument),this.view.inputViews=this.ccs_.map(i=>i.view)}};const ni=f("hpl");let Nu=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(ni()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("div");i.classList.add(ni("c")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(ni("m")),this.element.appendChild(s),this.markerElem_=s,this.update_()}update_(){const e=this.value.rawValue,[t]=e.getComponents("hsv");this.markerElem_.style.backgroundColor=ra(new g([t,100,100],"hsv"));const i=_(t,0,360,0,100);this.markerElem_.style.left=`${i}%`}onValueChange_(){this.update_()}},Fu=class{constructor(e,t){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=t.value,this.viewProps=t.viewProps,this.view=new Nu(e,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new tt(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_(e,t){if(!e.point)return;const i=_(R(e.point.x,0,e.bounds.width),0,e.bounds.width,0,360),s=this.value.rawValue,[,r,o,a]=s.getComponents("hsv");this.value.setRawValue(new g([i,r,o,a],"hsv"),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=G(Ye(!1),xe(e));if(t===0)return;const i=this.value.rawValue,[s,r,o,a]=i.getComponents("hsv");this.value.setRawValue(new g([s+t,r,o,a],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(e){G(Ye(!1),xe(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}};const ii=f("svp"),hr=64;let ju=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(ii()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("canvas");i.height=hr,i.width=hr,i.classList.add(ii("c")),this.element.appendChild(i),this.canvasElement=i;const s=e.createElement("div");s.classList.add(ii("m")),this.element.appendChild(s),this.markerElem_=s,this.update_()}update_(){const e=Ic(this.canvasElement);if(!e)return;const i=this.value.rawValue.getComponents("hsv"),s=this.canvasElement.width,r=this.canvasElement.height,o=e.getImageData(0,0,s,r),a=o.data;for(let p=0;pi.getComponents()[3],backward:(i,s)=>{const r=i.getComponents();return r[3]=s,new g(r,i.mode)}}),this.textsC_=new Bu(e,{colorType:t.colorType,value:this.value,viewProps:this.viewProps}),this.view=new iu(e,{alphaViews:this.alphaIcs_?{palette:this.alphaIcs_.palette.view,text:this.alphaIcs_.text.view}:null,hPaletteView:this.hPaletteC_.view,supportsAlpha:t.supportsAlpha,svPaletteView:this.svPaletteC_.view,textsView:this.textsC_.view,viewProps:this.viewProps})}get textsController(){return this.textsC_}};const si=f("colsw");let Ku=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.element=e.createElement("div"),this.element.classList.add(si()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(si("sw")),this.element.appendChild(i),this.swatchElem_=i;const s=e.createElement("button");s.classList.add(si("b")),t.viewProps.bindDisabled(s),this.element.appendChild(s),this.buttonElement=s,this.update_()}update_(){const e=this.value.rawValue;this.swatchElem_.style.backgroundColor=is(e)}onValueChange_(){this.update_()}},Uu=class{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new Ku(e,{value:this.value,viewProps:this.viewProps})}},ss=class{constructor(e,t){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=t.value,this.viewProps=t.viewProps,this.foldable_=Wi.create(t.expanded),this.swatchC_=new Uu(e,{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 Ut(e,{parser:t.parser,props:v.fromObject({formatter:t.formatter}),value:this.value,viewProps:this.viewProps}),this.view=new Yp(e,{foldable:this.foldable_,pickerLayout:t.pickerLayout}),this.view.swatchElement.appendChild(this.swatchC_.view.element),this.view.textElement.appendChild(this.textC_.view.element),this.popC_=t.pickerLayout==="popup"?new Bo(e,{viewProps:this.viewProps}):null;const s=new zu(e,{colorType:t.colorType,supportsAlpha:t.supportsAlpha,value:this.value,viewProps:this.viewProps});s.view.allFocusableElements.forEach(r=>{r.addEventListener("blur",this.onPopupChildBlur_),r.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=s,this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(s.view.element),Pt({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:r=>r,backward:(r,o)=>o})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),Yi(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onButtonBlur_(e){if(!this.popC_)return;const t=this.view.element,i=e.relatedTarget;(!i||!t.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_(e){if(!this.popC_)return;const t=this.popC_.view.element,i=ko(e);i&&t.contains(i)||i&&i===this.swatchC_.view.buttonElement&&!zi(t.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(e){this.popC_?e.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&e.key==="Escape"&&this.swatchC_.view.buttonElement.focus()}};function Hu(n){return de(n.getComponents("rgb")).reduce((e,t)=>e<<8|Math.floor(t)&255,0)}function qu(n){return n.getComponents("rgb").reduce((e,t,i)=>{const s=Math.floor(i===3?t*255:t)&255;return e<<8|s},0)>>>0}function Gu(n){return new g([n>>16&255,n>>8&255,n&255],"rgb")}function Wu(n){return new g([n>>24&255,n>>16&255,n>>8&255,_(n&255,0,255,0,1)],"rgb")}function Yu(n){return typeof n!="number"?g.black():Gu(n)}function Xu(n){return typeof n!="number"?g.black():Wu(n)}function fn(n,e){return typeof n!="object"||P(n)?!1:e in n&&typeof n[e]=="number"}function ca(n){return fn(n,"r")&&fn(n,"g")&&fn(n,"b")}function pa(n){return ca(n)&&fn(n,"a")}function ua(n){return ca(n)}function rs(n,e){if(n.mode!==e.mode||n.type!==e.type)return!1;const t=n.getComponents(),i=e.getComponents();for(let s=0;s{rn(t,e(i))}:null}function Ju(n){const e=n?qu:Hu;return(t,i)=>{rn(t,e(i))}}function Zu(n,e,t){const s=U(e,t).toRgbaObject();n.writeProperty("r",s.r),n.writeProperty("g",s.g),n.writeProperty("b",s.b),n.writeProperty("a",s.a)}function eh(n,e,t){const s=U(e,t).toRgbaObject();n.writeProperty("r",s.r),n.writeProperty("g",s.g),n.writeProperty("b",s.b)}function th(n,e){return(t,i)=>{n?Zu(t,i,e):eh(t,i,e)}}function nh(n){var e;return!!(!((e=n==null?void 0:n.color)===null||e===void 0)&&e.alpha)}function ih(n){return n?e=>is(e,"0x"):e=>ns(e,"0x")}function sh(n){return"color"in n||n.view==="color"}const rh=q({id:"input-color-number",type:"input",accept:(n,e)=>{if(typeof n!="number"||!sh(e))return null;const t=Zi(e);return t?{initialValue:n,params:Object.assign(Object.assign({},t),{supportsAlpha:nh(e)})}:null},binding:{reader:n=>n.params.supportsAlpha?Xu:Yu,equals:rs,writer:n=>Ju(n.params.supportsAlpha)},controller:n=>{var e,t;return new ss(n.document,{colorType:"int",expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:ih(n.params.supportsAlpha),parser:on("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:n.params.supportsAlpha,value:n.value,viewProps:n.viewProps})}});function oh(n,e){if(!ua(n))return U(g.black(),e);if(e==="int"){const t=dr(n);return new g(t,"rgb")}if(e==="float"){const t=dr(n);return new es(t,"rgb")}return U(g.black(),"int")}function ah(n){return pa(n)}function lh(n){return e=>{const t=oh(e,n);return U(t,"int")}}function ch(n,e){return t=>n?aa(t,e):oa(t,e)}const ph=q({id:"input-color-object",type:"input",accept:(n,e)=>{var t;if(!ua(n))return null;const i=Zi(e);return i?{initialValue:n,params:Object.assign(Object.assign({},i),{colorType:(t=Wo(e))!==null&&t!==void 0?t:"int"})}:null},binding:{reader:n=>lh(n.params.colorType),equals:rs,writer:n=>th(ah(n.initialValue),n.params.colorType)},controller:n=>{var e,t;const i=pa(n.initialValue);return new ss(n.document,{colorType:n.params.colorType,expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:ch(i,n.params.colorType),parser:on("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:i,value:n.value,viewProps:n.viewProps})}}),uh=q({id:"input-color-string",type:"input",accept:(n,e)=>{if(typeof n!="string"||e.view==="text")return null;const t=gu(n,Wo(e));if(!t)return null;const i=la(t);if(!i)return null;const s=Zi(e);return s?{initialValue:n,params:Object.assign(Object.assign({},s),{format:t,stringifier:i})}:null},binding:{reader:()=>Cu,equals:rs,writer:n=>{const e=Qu(n.params.format);if(!e)throw j.notBindable();return e}},controller:n=>{var e,t;return new ss(n.document,{colorType:n.params.format.type,expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:n.params.stringifier,parser:on("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:n.params.format.alpha,value:n.value,viewProps:n.viewProps})}});let os=class{constructor(e){this.components=e.components,this.asm_=e.assembly}constrain(e){const t=this.asm_.toComponents(e).map((i,s)=>{var r,o;return(o=(r=this.components[s])===null||r===void 0?void 0:r.constrain(i))!==null&&o!==void 0?o:i});return this.asm_.fromComponents(t)}};const mr=f("pndtxt");let hh=class{constructor(e,t){this.textViews=t.textViews,this.element=e.createElement("div"),this.element.classList.add(mr()),this.textViews.forEach(i=>{const s=e.createElement("div");s.classList.add(mr("a")),s.appendChild(i.element),this.element.appendChild(s)})}};function dh(n,e,t){return new sn(n,{arrayPosition:t===0?"fst":t===e.axes.length-1?"lst":"mid",parser:e.parser,props:e.axes[t].textProps,value:k(0,{constraint:e.axes[t].constraint}),viewProps:e.viewProps})}let as=class{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.acs_=t.axes.map((i,s)=>dh(e,t,s)),this.acs_.forEach((i,s)=>{Pt({primary:this.value,secondary:i.value,forward:r=>t.assembly.toComponents(r)[s],backward:(r,o)=>{const a=t.assembly.toComponents(r);return a[s]=o,t.assembly.fromComponents(a)}})}),this.view=new hh(e,{textViews:this.acs_.map(i=>i.view)})}get textControllers(){return this.acs_}},mh=class extends Kt{get max(){return this.controller.valueController.sliderController.props.get("max")}set max(e){this.controller.valueController.sliderController.props.set("max",e)}get min(){return this.controller.valueController.sliderController.props.get("min")}set min(e){this.controller.valueController.sliderController.props.set("min",e)}};function vh(n,e){const t=[],i=_o(n,e);i&&t.push(i);const s=go(n);s&&t.push(s);const r=Ji(n.options);return r&&t.push(r),new en(t)}const bh=q({id:"input-number",type:"input",accept:(n,e)=>{if(typeof n!="number")return null;const t=S(e,i=>Object.assign(Object.assign({},xo(i)),{options:i.optional.custom(nn),readonly:i.optional.constant(!1)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>vo,constraint:n=>vh(n.params,n.initialValue),writer:n=>rn},controller:n=>{const e=n.value,t=n.constraint,i=t&&yn(t,tn);if(i)return new Ne(n.document,{props:new v({options:i.values.value("options")}),value:e,viewProps:n.viewProps});const s=Co(n.params,e.rawValue),r=t&&yn(t,Jt);return r?new kn(n.document,Object.assign(Object.assign({},Io(Object.assign(Object.assign({},s),{keyScale:k(s.keyScale),max:r.values.value("max"),min:r.values.value("min")}))),{parser:Ce,value:e,viewProps:n.viewProps})):new sn(n.document,{parser:Ce,props:v.fromObject(s),value:e,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="number"?null:n.controller.valueController instanceof kn?new mh(n.controller):n.controller.valueController instanceof Ne?new Xi(n.controller):null}});let Re=class{constructor(e=0,t=0){this.x=e,this.y=t}getComponents(){return[this.x,this.y]}static isObject(e){if(P(e))return!1;const t=e.x,i=e.y;return!(typeof t!="number"||typeof i!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y}toObject(){return{x:this.x,y:this.y}}};const ha={toComponents:n=>n.getComponents(),fromComponents:n=>new Re(...n)},at=f("p2d");let fh=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(at()),t.viewProps.bindClassModifiers(this.element),ge(t.expanded,gt(this.element,at(void 0,"expanded")));const i=e.createElement("div");i.classList.add(at("h")),this.element.appendChild(i);const s=e.createElement("button");s.classList.add(at("b")),s.appendChild(Nn(e,"p2dpad")),t.viewProps.bindDisabled(s),i.appendChild(s),this.buttonElement=s;const r=e.createElement("div");if(r.classList.add(at("t")),i.appendChild(r),this.textElement=r,t.pickerLayout==="inline"){const o=e.createElement("div");o.classList.add(at("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}};const Ve=f("p2dp");let wh=class{constructor(e,t){this.onFoldableChange_=this.onFoldableChange_.bind(this),this.onPropsChange_=this.onPropsChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onPropsChange_),this.element=e.createElement("div"),this.element.classList.add(Ve()),t.layout==="popup"&&this.element.classList.add(Ve(void 0,"p")),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(Ve("p")),t.viewProps.bindTabIndex(i),this.element.appendChild(i),this.padElement=i;const s=e.createElementNS(ue,"svg");s.classList.add(Ve("g")),this.padElement.appendChild(s),this.svgElem_=s;const r=e.createElementNS(ue,"line");r.classList.add(Ve("ax")),r.setAttributeNS(null,"x1","0"),r.setAttributeNS(null,"y1","50%"),r.setAttributeNS(null,"x2","100%"),r.setAttributeNS(null,"y2","50%"),this.svgElem_.appendChild(r);const o=e.createElementNS(ue,"line");o.classList.add(Ve("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=e.createElementNS(ue,"line");a.classList.add(Ve("l")),a.setAttributeNS(null,"x1","50%"),a.setAttributeNS(null,"y1","50%"),this.svgElem_.appendChild(a),this.lineElem_=a;const l=e.createElement("div");l.classList.add(Ve("m")),this.padElement.appendChild(l),this.markerElem_=l,t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.update_()}get allFocusableElements(){return[this.padElement]}update_(){const[e,t]=this.value.rawValue.getComponents(),i=this.props_.get("max"),s=_(e,-i,+i,0,100),r=_(t,-i,+i,0,100),o=this.props_.get("invertsY")?100-r:r;this.lineElem_.setAttributeNS(null,"x2",`${s}%`),this.lineElem_.setAttributeNS(null,"y2",`${o}%`),this.markerElem_.style.left=`${s}%`,this.markerElem_.style.top=`${o}%`}onValueChange_(){this.update_()}onPropsChange_(){this.update_()}onFoldableChange_(){this.update_()}};function vr(n,e,t){return[G(e[0],xe(n)),G(e[1],Ht(n))*(t?1:-1)]}let _h=class{constructor(e,t){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=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new wh(e,{layout:t.layout,props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new tt(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_(e,t){if(!e.point)return;const i=this.props.get("max"),s=_(e.point.x,0,e.bounds.width,-i,+i),r=_(this.props.get("invertsY")?e.bounds.height-e.point.y:e.point.y,0,e.bounds.height,-i,+i);this.value.setRawValue(new Re(s,r),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onPadKeyDown_(e){jo(e.key)&&e.preventDefault();const[t,i]=vr(e,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));t===0&&i===0||this.value.setRawValue(new Re(this.value.rawValue.x+t,this.value.rawValue.y+i),{forceEmit:!1,last:!1})}onPadKeyUp_(e){const[t,i]=vr(e,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));t===0&&i===0||this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}},gh=class{constructor(e,t){var i,s;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=t.value,this.viewProps=t.viewProps,this.foldable_=Wi.create(t.expanded),this.popC_=t.pickerLayout==="popup"?new Bo(e,{viewProps:this.viewProps}):null;const r=new _h(e,{layout:t.pickerLayout,props:new v({invertsY:k(t.invertsY),max:k(t.max),xKeyScale:t.axes[0].textProps.value("keyScale"),yKeyScale:t.axes[1].textProps.value("keyScale")}),value:this.value,viewProps:this.viewProps});r.view.allFocusableElements.forEach(o=>{o.addEventListener("blur",this.onPopupChildBlur_),o.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=r,this.textC_=new as(e,{assembly:ha,axes:t.axes,parser:t.parser,value:this.value,viewProps:this.viewProps}),this.view=new fh(e,{expanded:this.foldable_.value("expanded"),pickerLayout:t.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_),(s=this.view.buttonElement)===null||s===void 0||s.addEventListener("click",this.onPadButtonClick_),this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(this.pickerC_.view.element),Pt({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),Yi(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onPadButtonBlur_(e){if(!this.popC_)return;const t=this.view.element,i=e.relatedTarget;(!i||!t.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_(e){if(!this.popC_)return;const t=this.popC_.view.element,i=ko(e);i&&t.contains(i)||i&&i===this.view.buttonElement&&!zi(t.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(e){this.popC_?e.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&e.key==="Escape"&&this.view.buttonElement.focus()}};function Ch(n){return Re.isObject(n)?new Re(n.x,n.y):new Re}function xh(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y)}function Ph(n,e){return new os({assembly:ha,components:[we(Object.assign(Object.assign({},n),n.x),e.x),we(Object.assign(Object.assign({},n),n.y),e.y)]})}function br(n,e){var t,i;if(!P(n.min)||!P(n.max))return Math.max(Math.abs((t=n.min)!==null&&t!==void 0?t:0),Math.abs((i=n.max)!==null&&i!==void 0?i:0));const s=fo(n);return Math.max(Math.abs(s)*10,Math.abs(e)*10)}function yh(n,e){var t,i;const s=br(Ge(n,(t=n.x)!==null&&t!==void 0?t:{}),e.x),r=br(Ge(n,(i=n.y)!==null&&i!==void 0?i:{}),e.y);return Math.max(s,r)}function Eh(n){if(!("y"in n))return!1;const e=n.y;return e&&"inverted"in e?!!e.inverted:!1}const kh=q({id:"input-point2d",type:"input",accept:(n,e)=>{if(!Re.isObject(n))return null;const t=S(e,i=>Object.assign(Object.assign({},qt(i)),{expanded:i.optional.boolean,picker:i.optional.custom(Ko),readonly:i.optional.constant(!1),x:i.optional.custom(Me),y:i.optional.object(Object.assign(Object.assign({},qt(i)),{inverted:i.optional.boolean}))}));return t?{initialValue:n,params:t}:null},binding:{reader:()=>Ch,constraint:n=>Ph(n.params,n.initialValue),equals:Re.equals,writer:()=>xh},controller:n=>{var e,t;const i=n.document,s=n.value,r=n.constraint,o=[n.params.x,n.params.y];return new gh(i,{axes:s.rawValue.getComponents().map((a,l)=>{var c;return Ii({constraint:r.components[l],initialValue:a,params:Ge(n.params,(c=o[l])!==null&&c!==void 0?c:{})})}),expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,invertsY:Eh(n.params),max:yh(n.params,s.rawValue),parser:Ce,pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",value:s,viewProps:n.viewProps})}});let dt=class{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}getComponents(){return[this.x,this.y,this.z]}static isObject(e){if(P(e))return!1;const t=e.x,i=e.y,s=e.z;return!(typeof t!="number"||typeof i!="number"||typeof s!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z}toObject(){return{x:this.x,y:this.y,z:this.z}}};const da={toComponents:n=>n.getComponents(),fromComponents:n=>new dt(...n)};function Vh(n){return dt.isObject(n)?new dt(n.x,n.y,n.z):new dt}function Sh(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y),n.writeProperty("z",e.z)}function Th(n,e){return new os({assembly:da,components:[we(Object.assign(Object.assign({},n),n.x),e.x),we(Object.assign(Object.assign({},n),n.y),e.y),we(Object.assign(Object.assign({},n),n.z),e.z)]})}const Lh=q({id:"input-point3d",type:"input",accept:(n,e)=>{if(!dt.isObject(n))return null;const t=S(e,i=>Object.assign(Object.assign({},qt(i)),{readonly:i.optional.constant(!1),x:i.optional.custom(Me),y:i.optional.custom(Me),z:i.optional.custom(Me)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>Vh,constraint:n=>Th(n.params,n.initialValue),equals:dt.equals,writer:n=>Sh},controller:n=>{const e=n.value,t=n.constraint,i=[n.params.x,n.params.y,n.params.z];return new as(n.document,{assembly:da,axes:e.rawValue.getComponents().map((s,r)=>{var o;return Ii({constraint:t.components[r],initialValue:s,params:Ge(n.params,(o=i[r])!==null&&o!==void 0?o:{})})}),parser:Ce,value:e,viewProps:n.viewProps})}});let mt=class{constructor(e=0,t=0,i=0,s=0){this.x=e,this.y=t,this.z=i,this.w=s}getComponents(){return[this.x,this.y,this.z,this.w]}static isObject(e){if(P(e))return!1;const t=e.x,i=e.y,s=e.z,r=e.w;return!(typeof t!="number"||typeof i!="number"||typeof s!="number"||typeof r!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z&&e.w===t.w}toObject(){return{x:this.x,y:this.y,z:this.z,w:this.w}}};const ma={toComponents:n=>n.getComponents(),fromComponents:n=>new mt(...n)};function $h(n){return mt.isObject(n)?new mt(n.x,n.y,n.z,n.w):new mt}function Ah(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y),n.writeProperty("z",e.z),n.writeProperty("w",e.w)}function Mh(n,e){return new os({assembly:ma,components:[we(Object.assign(Object.assign({},n),n.x),e.x),we(Object.assign(Object.assign({},n),n.y),e.y),we(Object.assign(Object.assign({},n),n.z),e.z),we(Object.assign(Object.assign({},n),n.w),e.w)]})}const Oh=q({id:"input-point4d",type:"input",accept:(n,e)=>{if(!mt.isObject(n))return null;const t=S(e,i=>Object.assign(Object.assign({},qt(i)),{readonly:i.optional.constant(!1),w:i.optional.custom(Me),x:i.optional.custom(Me),y:i.optional.custom(Me),z:i.optional.custom(Me)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>$h,constraint:n=>Mh(n.params,n.initialValue),equals:mt.equals,writer:n=>Ah},controller:n=>{const e=n.value,t=n.constraint,i=[n.params.x,n.params.y,n.params.z,n.params.w];return new as(n.document,{assembly:ma,axes:e.rawValue.getComponents().map((s,r)=>{var o;return Ii({constraint:t.components[r],initialValue:s,params:Ge(n.params,(o=i[r])!==null&&o!==void 0?o:{})})}),parser:Ce,value:e,viewProps:n.viewProps})}});function Rh(n){const e=[],t=Ji(n.options);return t&&e.push(t),new en(e)}const Dh=q({id:"input-string",type:"input",accept:(n,e)=>{if(typeof n!="string")return null;const t=S(e,i=>({readonly:i.optional.constant(!1),options:i.optional.custom(nn)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>Fo,constraint:n=>Rh(n.params),writer:n=>rn},controller:n=>{const e=n.document,t=n.value,i=n.constraint,s=i&&yn(i,tn);return s?new Ne(e,{props:new v({options:s.values.value("options")}),value:t,viewProps:n.viewProps}):new Ut(e,{parser:r=>r,props:v.fromObject({formatter:Ei}),value:t,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="string"?null:n.controller.valueController instanceof Ne?new Xi(n.controller):null}}),an={monitor:{defaultInterval:200,defaultRows:3}},fr=f("mll");let Bh=class{constructor(e,t){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=t.formatter,this.element=e.createElement("div"),this.element.classList.add(fr()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("textarea");i.classList.add(fr("i")),i.style.height=`calc(var(${zo("containerUnitSize")}) * ${t.rows})`,i.readOnly=!0,t.viewProps.bindDisabled(i),this.element.appendChild(i),this.textareaElem_=i,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}update_(){const e=this.textareaElem_,t=e.scrollTop===e.scrollHeight-e.clientHeight,i=[];this.value.rawValue.forEach(s=>{s!==void 0&&i.push(this.formatter_(s))}),e.textContent=i.join(` +`),t&&(e.scrollTop=e.scrollHeight)}onValueUpdate_(){this.update_()}},ls=class{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new Bh(e,{formatter:t.formatter,rows:t.rows,value:this.value,viewProps:this.viewProps})}};const wr=f("sgl");let Nh=class{constructor(e,t){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=t.formatter,this.element=e.createElement("div"),this.element.classList.add(wr()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("input");i.classList.add(wr("i")),i.readOnly=!0,i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}update_(){const e=this.value.rawValue,t=e[e.length-1];this.inputElement.value=t!==void 0?this.formatter_(t):""}onValueUpdate_(){this.update_()}},cs=class{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new Nh(e,{formatter:t.formatter,value:this.value,viewProps:this.viewProps})}};const Fh=q({id:"monitor-bool",type:"monitor",accept:(n,e)=>{if(typeof n!="boolean")return null;const t=S(e,i=>({readonly:i.required.constant(!0),rows:i.optional.number}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>No},controller:n=>{var e;return n.value.rawValue.length===1?new cs(n.document,{formatter:lr,value:n.value,viewProps:n.viewProps}):new ls(n.document,{formatter:lr,rows:(e=n.params.rows)!==null&&e!==void 0?e:an.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}});let jh=class extends Kt{get max(){return this.controller.valueController.props.get("max")}set max(e){this.controller.valueController.props.set("max",e)}get min(){return this.controller.valueController.props.get("min")}set min(e){this.controller.valueController.props.set("min",e)}};const Se=f("grl");let Ih=class{constructor(e,t){this.onCursorChange_=this.onCursorChange_.bind(this),this.onValueUpdate_=this.onValueUpdate_.bind(this),this.element=e.createElement("div"),this.element.classList.add(Se()),t.viewProps.bindClassModifiers(this.element),this.formatter_=t.formatter,this.props_=t.props,this.cursor_=t.cursor,this.cursor_.emitter.on("change",this.onCursorChange_);const i=e.createElementNS(ue,"svg");i.classList.add(Se("g")),i.style.height=`calc(var(${zo("containerUnitSize")}) * ${t.rows})`,this.element.appendChild(i),this.svgElem_=i;const s=e.createElementNS(ue,"polyline");this.svgElem_.appendChild(s),this.lineElem_=s;const r=e.createElement("div");r.classList.add(Se("t"),f("tt")()),this.element.appendChild(r),this.tooltipElem_=r,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}get graphElement(){return this.svgElem_}update_(){const{clientWidth:e,clientHeight:t}=this.element,i=this.value.rawValue.length-1,s=this.props_.get("min"),r=this.props_.get("max"),o=[];this.value.rawValue.forEach((u,b)=>{if(u===void 0)return;const O=_(b,0,i,0,e),y=_(u,s,r,t,0);o.push([O,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(Se("t","a"));return}const c=_(this.cursor_.rawValue,0,i,0,e),p=_(l,s,r,t,0);a.style.left=`${c}px`,a.style.top=`${p}px`,a.textContent=`${this.formatter_(l)}`,a.classList.contains(Se("t","a"))||(a.classList.add(Se("t","a"),Se("t","in")),Pn(a),a.classList.remove(Se("t","in")))}onValueUpdate_(){this.update_()}onCursorChange_(){this.update_()}},va=class{constructor(e,t){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=t.props,this.value=t.value,this.viewProps=t.viewProps,this.cursor_=k(-1),this.view=new Ih(e,{cursor:this.cursor_,formatter:t.formatter,rows:t.rows,props:this.props,value:this.value,viewProps:this.viewProps}),!zi(e))this.view.element.addEventListener("mousemove",this.onGraphMouseMove_),this.view.element.addEventListener("mouseleave",this.onGraphMouseLeave_);else{const i=new tt(this.view.element);i.emitter.on("down",this.onGraphPointerDown_),i.emitter.on("move",this.onGraphPointerMove_),i.emitter.on("up",this.onGraphPointerUp_)}}importProps(e){return Q(e,null,t=>({max:t.required.number,min:t.required.number}),t=>(this.props.set("max",t.max),this.props.set("min",t.min),!0))}exportProps(){return J(null,{max:this.props.get("max"),min:this.props.get("min")})}onGraphMouseLeave_(){this.cursor_.rawValue=-1}onGraphMouseMove_(e){const{clientWidth:t}=this.view.element;this.cursor_.rawValue=Math.floor(_(e.offsetX,0,t,0,this.value.rawValue.length))}onGraphPointerDown_(e){this.onGraphPointerMove_(e)}onGraphPointerMove_(e){if(!e.data.point){this.cursor_.rawValue=-1;return}this.cursor_.rawValue=Math.floor(_(e.data.point.x,0,e.data.bounds.width,0,this.value.rawValue.length))}onGraphPointerUp_(){this.cursor_.rawValue=-1}};function ki(n){return P(n.format)?W(2):n.format}function zh(n){var e;return n.value.rawValue.length===1?new cs(n.document,{formatter:ki(n.params),value:n.value,viewProps:n.viewProps}):new ls(n.document,{formatter:ki(n.params),rows:(e=n.params.rows)!==null&&e!==void 0?e:an.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}function Kh(n){var e,t,i;return new va(n.document,{formatter:ki(n.params),rows:(e=n.params.rows)!==null&&e!==void 0?e:an.monitor.defaultRows,props:v.fromObject({max:(t=n.params.max)!==null&&t!==void 0?t:100,min:(i=n.params.min)!==null&&i!==void 0?i:0}),value:n.value,viewProps:n.viewProps})}function _r(n){return n.view==="graph"}const Uh=q({id:"monitor-number",type:"monitor",accept:(n,e)=>{if(typeof n!="number")return null;const t=S(e,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 t?{initialValue:n,params:t}:null},binding:{defaultBufferSize:n=>_r(n)?64:1,reader:n=>vo},controller:n=>_r(n.params)?Kh(n):zh(n),api:n=>n.controller.valueController instanceof va?new jh(n.controller):null}),Hh=q({id:"monitor-string",type:"monitor",accept:(n,e)=>{if(typeof n!="string")return null;const t=S(e,i=>({multiline:i.optional.boolean,readonly:i.required.constant(!0),rows:i.optional.number}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>Fo},controller:n=>{var e;const t=n.value;return t.rawValue.length>1||n.params.multiline?new ls(n.document,{formatter:Ei,rows:(e=n.params.rows)!==null&&e!==void 0?e:an.monitor.defaultRows,value:t,viewProps:n.viewProps}):new cs(n.document,{formatter:Ei,value:t,viewProps:n.viewProps})}});class qh{constructor(){this.map_=new Map}get(e){var t;return(t=this.map_.get(e))!==null&&t!==void 0?t:null}has(e){return this.map_.has(e)}add(e,t){return this.map_.set(e,t),e.viewProps.handleDispose(()=>{this.map_.delete(e)}),t}}class Gh{constructor(e){this.target=e.target,this.reader_=e.reader,this.writer_=e.writer}read(){return this.reader_(this.target.read())}write(e){this.writer_(this.target,e)}inject(e){this.write(this.reader_(e))}}function Wh(n,e){var t;const i=n.accept(e.target.read(),e.params);if(P(i))return null;const s={target:e.target,initialValue:i.initialValue,params:i.params},r=S(e.params,u=>({disabled:u.optional.boolean,hidden:u.optional.boolean,label:u.optional.string,tag:u.optional.string})),o=n.binding.reader(s),a=n.binding.constraint?n.binding.constraint(s):void 0,l=new Gh({reader:o,target:e.target,writer:n.binding.writer(s)}),c=new Mc(k(o(i.initialValue),{constraint:a,equals:n.binding.equals}),l),p=n.controller({constraint:a,document:e.document,initialValue:i.initialValue,params:i.params,value:c,viewProps:et.create({disabled:r==null?void 0:r.disabled,hidden:r==null?void 0:r.hidden})});return new Wc(e.document,{blade:xt(),props:v.fromObject({label:"label"in e.params?(t=r==null?void 0:r.label)!==null&&t!==void 0?t:null:e.target.key}),tag:r==null?void 0:r.tag,value:c,valueController:p})}class Yh{constructor(e){this.target=e.target,this.reader_=e.reader}read(){return this.reader_(this.target.read())}}function Xh(n,e){return e===0?new Lp:new $p(n,e??an.monitor.defaultInterval)}function Qh(n,e){var t,i,s;const r=n.accept(e.target.read(),e.params);if(P(r))return null;const o={target:e.target,initialValue:r.initialValue,params:r.params},a=S(e.params,b=>({bufferSize:b.optional.number,disabled:b.optional.boolean,hidden:b.optional.boolean,interval:b.optional.number,label:b.optional.string})),l=n.binding.reader(o),c=(i=(t=a==null?void 0:a.bufferSize)!==null&&t!==void 0?t:n.binding.defaultBufferSize&&n.binding.defaultBufferSize(r.params))!==null&&i!==void 0?i:1,p=new Zc({binding:new Yh({reader:l,target:e.target}),bufferSize:c,ticker:Xh(e.document,a==null?void 0:a.interval)}),u=n.controller({document:e.document,params:r.params,value:p,viewProps:et.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 tp(e.document,{blade:xt(),props:v.fromObject({label:"label"in e.params?(s=a==null?void 0:a.label)!==null&&s!==void 0?s:null:e.target.key}),value:p,valueController:u})}class Jh{constructor(e){this.pluginsMap_={blades:[],inputs:[],monitors:[]},this.apiCache_=e}getAll(){return[...this.pluginsMap_.blades,...this.pluginsMap_.inputs,...this.pluginsMap_.monitors]}register(e,t){if(!Up(t.core))throw j.notCompatible(e,t.id);t.type==="blade"?this.pluginsMap_.blades.unshift(t):t.type==="input"?this.pluginsMap_.inputs.unshift(t):t.type==="monitor"&&this.pluginsMap_.monitors.unshift(t)}createInput_(e,t,i){return this.pluginsMap_.inputs.reduce((s,r)=>s??Wh(r,{document:e,target:t,params:i}),null)}createMonitor_(e,t,i){return this.pluginsMap_.monitors.reduce((s,r)=>s??Qh(r,{document:e,params:i,target:t}),null)}createBinding(e,t,i){const s=t.read();if(P(s))throw new j({context:{key:t.key},type:"nomatchingcontroller"});const r=this.createInput_(e,t,i);if(r)return r;const o=this.createMonitor_(e,t,i);if(o)return o;throw new j({context:{key:t.key},type:"nomatchingcontroller"})}createBlade(e,t){const i=this.pluginsMap_.blades.reduce((s,r)=>s??Tp(r,{document:e,params:t}),null);if(!i)throw new j({type:"nomatchingview",context:{params:t}});return i}createInputBindingApi_(e){const t=this.pluginsMap_.inputs.reduce((i,s)=>{var r,o;return i||((o=(r=s.api)===null||r===void 0?void 0:r.call(s,{controller:e}))!==null&&o!==void 0?o:null)},null);return this.apiCache_.add(e,t??new Kt(e))}createMonitorBindingApi_(e){const t=this.pluginsMap_.monitors.reduce((i,s)=>{var r,o;return i||((o=(r=s.api)===null||r===void 0?void 0:r.call(s,{controller:e}))!==null&&o!==void 0?o:null)},null);return this.apiCache_.add(e,t??new Kt(e))}createBindingApi(e){if(this.apiCache_.has(e))return this.apiCache_.get(e);if(Yc(e))return this.createInputBindingApi_(e);if(np(e))return this.createMonitorBindingApi_(e);throw j.shouldNeverHappen()}createApi(e){if(this.apiCache_.has(e))return this.apiCache_.get(e);if(Gc(e))return this.createBindingApi(e);const t=this.pluginsMap_.blades.reduce((i,s)=>i??s.api({controller:e,pool:this}),null);if(!t)throw j.shouldNeverHappen();return this.apiCache_.add(e,t)}}const Zh=new qh;function ed(){const n=new Jh(Zh);return[kh,Lh,Oh,Dh,bh,uh,ph,rh,Wp,Fh,Hh,Uh,ap,gp,Do].forEach(e=>{n.register("core",e)}),n}class td extends Ze{constructor(e){super(e),this.emitter_=new M,this.controller.value.emitter.on("change",t=>{this.emitter_.emit("change",new Zt(this,t.rawValue))})}get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get options(){return this.controller.valueController.props.get("options")}set options(e){this.controller.valueController.props.set("options",e)}get value(){return this.controller.value.rawValue}set value(e){this.controller.value.rawValue=e}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}}class nd extends Ze{}class id extends Ze{constructor(e){super(e),this.emitter_=new M,this.controller.value.emitter.on("change",t=>{this.emitter_.emit("change",new Zt(this,t.rawValue))})}get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get max(){return this.controller.valueController.sliderController.props.get("max")}set max(e){this.controller.valueController.sliderController.props.set("max",e)}get min(){return this.controller.valueController.sliderController.props.get("min")}set min(e){this.controller.valueController.sliderController.props.set("min",e)}get value(){return this.controller.value.rawValue}set value(e){this.controller.value.rawValue=e}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}}class sd extends Ze{constructor(e){super(e),this.emitter_=new M,this.controller.value.emitter.on("change",t=>{this.emitter_.emit("change",new Zt(this,t.rawValue))})}get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get formatter(){return this.controller.valueController.props.get("formatter")}set formatter(e){this.controller.valueController.props.set("formatter",e)}get value(){return this.controller.value.rawValue}set value(e){this.controller.value.rawValue=e}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}}const rd=function(){return{id:"list",type:"blade",core:Ct,accept(n){const e=S(n,t=>({options:t.required.custom(nn),value:t.required.raw,view:t.required.constant("list"),label:t.optional.string}));return e?{params:e}:null},controller(n){const e=new tn(Qi(n.params.options)),t=k(n.params.value,{constraint:e}),i=new Ne(n.document,{props:new v({options:e.values.value("options")}),value:t,viewProps:n.viewProps});return new We(n.document,{blade:n.blade,props:v.fromObject({label:n.params.label}),value:t,valueController:i})},api(n){return!(n.controller instanceof We)||!(n.controller.valueController instanceof Ne)?null:new td(n.controller)}}}();class od extends Mo{constructor(e,t){super(e,t)}get element(){return this.controller.view.element}}class ad extends Pi{constructor(e,t){super(e,{expanded:t.expanded,blade:t.blade,props:t.props,root:!0,viewProps:t.viewProps})}}const gr=f("spr");class ld{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(gr()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("hr");i.classList.add(gr("r")),this.element.appendChild(i)}}class Cr extends Fn{constructor(e,t){super(Object.assign(Object.assign({},t),{view:new ld(e,{viewProps:t.viewProps})}))}}const cd={id:"separator",type:"blade",core:Ct,accept(n){const e=S(n,t=>({view:t.required.constant("separator")}));return e?{params:e}:null},controller(n){return new Cr(n.document,{blade:n.blade,viewProps:n.viewProps})},api(n){return n.controller instanceof Cr?new nd(n.controller):null}},pd={id:"slider",type:"blade",core:Ct,accept(n){const e=S(n,t=>({max:t.required.number,min:t.required.number,view:t.required.constant("slider"),format:t.optional.function,label:t.optional.string,value:t.optional.number}));return e?{params:e}:null},controller(n){var e,t;const i=(e=n.params.value)!==null&&e!==void 0?e:0,s=new Jt({max:n.params.max,min:n.params.min}),r=k(i,{constraint:s}),o=new kn(n.document,Object.assign(Object.assign({},Io({formatter:(t=n.params.format)!==null&&t!==void 0?t:Sc,keyScale:k(1),max:s.values.value("max"),min:s.values.value("min"),pointerScale:wo(n.params,i)})),{parser:Ce,value:r,viewProps:n.viewProps}));return new We(n.document,{blade:n.blade,props:v.fromObject({label:n.params.label}),value:r,valueController:o})},api(n){return!(n.controller instanceof We)||!(n.controller.valueController instanceof kn)?null:new id(n.controller)}},ud=function(){return{id:"text",type:"blade",core:Ct,accept(n){const e=S(n,t=>({parse:t.required.function,value:t.required.raw,view:t.required.constant("text"),format:t.optional.function,label:t.optional.string}));return e?{params:e}:null},controller(n){var e;const t=k(n.params.value),i=new Ut(n.document,{parser:n.params.parse,props:v.fromObject({formatter:(e=n.params.format)!==null&&e!==void 0?e:s=>String(s)}),value:t,viewProps:n.viewProps});return new We(n.document,{blade:n.blade,props:v.fromObject({label:n.params.label}),value:t,valueController:i})},api(n){return!(n.controller instanceof We)||!(n.controller.valueController instanceof Ut)?null:new sd(n.controller)}}}();function hd(n){const e=n.createElement("div");return e.classList.add(f("dfw")()),n.body&&n.body.appendChild(e),e}function dd(n,e,t){if(n.querySelector(`style[data-tp-style=${e}]`))return;const i=n.createElement("style");i.dataset.tpStyle=e,i.textContent=t,n.head.appendChild(i)}class md extends od{constructor(e){var t,i;const s=e??{},r=(t=s.document)!==null&&t!==void 0?t:jc(),o=ed(),a=new ad(r,{expanded:s.expanded,blade:xt(),props:v.fromObject({title:s.title}),viewProps:et.create()});super(a,o),this.pool_=o,this.containerElem_=(i=s.container)!==null&&i!==void 0?i:hd(r),this.containerElem_.appendChild(this.element),this.doc_=r,this.usesDefaultWrapper_=!s.container,this.setUpDefaultPlugins_()}get document(){if(!this.doc_)throw j.alreadyDisposed();return this.doc_}dispose(){const e=this.containerElem_;if(!e)throw j.alreadyDisposed();if(this.usesDefaultWrapper_){const t=e.parentElement;t&&t.removeChild(e)}this.containerElem_=null,this.doc_=null,super.dispose()}registerPlugin(e){e.css&&dd(this.document,`plugin-${e.id}`,e.css),("plugin"in e?[e.plugin]:"plugins"in e?e.plugins:[]).forEach(i=>{this.pool_.register(e.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:[rd,cd,pd,Do,ud]})}}new $o("4.0.4");function E(n){return n==null}function ps(n){return n!==null&&typeof n=="object"}function Vi(n){return n!==null&&typeof n=="object"}function vd(n,e){if(n.length!==e.length)return!1;for(let t=0;t{const r=n[s],o=e[s];return Vi(r)&&Vi(o)?Object.assign(Object.assign({},i),{[s]:Xe(r,o)}):Object.assign(Object.assign({},i),{[s]:s in e?o:r})},{})}function bd(n){return ps(n)?"target"in n:!1}const fd={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 K{static alreadyDisposed(){return new K({type:"alreadydisposed"})}static notBindable(){return new K({type:"notbindable"})}static notCompatible(e,t){return new K({type:"notcompatible",context:{id:`${e}.${t}`}})}static propertyNotFound(e){return new K({type:"propertynotfound",context:{name:e}})}static shouldNeverHappen(){return new K({type:"shouldneverhappen"})}constructor(e){var t;this.message=(t=fd[e.type](e.context))!==null&&t!==void 0?t:"Unexpected error",this.name=this.constructor.name,this.stack=new Error(this.message).stack,this.type=e.type}toString(){return this.message}}class Vn{constructor(e,t){this.obj_=e,this.key=t}static isBindable(e){return!(e===null||typeof e!="object"&&typeof e!="function")}read(){return this.obj_[this.key]}write(e){this.obj_[this.key]=e}writeProperty(e,t){const i=this.read();if(!Vn.isBindable(i))throw K.notBindable();if(!(e in i))throw K.propertyNotFound(e);i[e]=t}}class z{constructor(){this.observers_={}}on(e,t){let i=this.observers_[e];return i||(i=this.observers_[e]=[]),i.push({handler:t}),this}off(e,t){const i=this.observers_[e];return i&&(this.observers_[e]=i.filter(s=>s.handler!==t)),this}emit(e,t){const i=this.observers_[e];i&&i.forEach(s=>{s.handler(t)})}}class wd{constructor(e,t){var i;this.constraint_=t==null?void 0:t.constraint,this.equals_=(i=t==null?void 0:t.equals)!==null&&i!==void 0?i:(s,r)=>s===r,this.emitter=new z,this.rawValue_=e}get constraint(){return this.constraint_}get rawValue(){return this.rawValue_}set rawValue(e){this.setRawValue(e,{forceEmit:!1,last:!0})}setRawValue(e,t){const i=t??{forceEmit:!1,last:!0},s=this.constraint_?this.constraint_.constrain(e):e,r=this.rawValue_;this.equals_(r,s)&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.rawValue_=s,this.emitter.emit("change",{options:i,previousRawValue:r,rawValue:s,sender:this}))}}class _d{constructor(e){this.emitter=new z,this.value_=e}get rawValue(){return this.value_}set rawValue(e){this.setRawValue(e,{forceEmit:!1,last:!0})}setRawValue(e,t){const i=t??{forceEmit:!1,last:!0},s=this.value_;s===e&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.value_=e,this.emitter.emit("change",{options:i,previousRawValue:s,rawValue:this.value_,sender:this}))}}class gd{constructor(e){this.emitter=new z,this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.value_=e,this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_)}get rawValue(){return this.value_.rawValue}onValueBeforeChange_(e){this.emitter.emit("beforechange",Object.assign(Object.assign({},e),{sender:this}))}onValueChange_(e){this.emitter.emit("change",Object.assign(Object.assign({},e),{sender:this}))}}function T(n,e){const t=e==null?void 0:e.constraint,i=e==null?void 0:e.equals;return!t&&!i?new _d(n):new wd(n,e)}function Cd(n){return[new gd(n),(e,t)=>{n.setRawValue(e,t)}]}class d{constructor(e){this.emitter=new z,this.valMap_=e;for(const t in this.valMap_)this.valMap_[t].emitter.on("change",()=>{this.emitter.emit("change",{key:t,sender:this})})}static createCore(e){return Object.keys(e).reduce((i,s)=>Object.assign(i,{[s]:T(e[s])}),{})}static fromObject(e){const t=this.createCore(e);return new d(t)}get(e){return this.valMap_[e].rawValue}set(e,t){this.valMap_[e].rawValue=t}value(e){return this.valMap_[e]}}class ln{constructor(e){this.values=d.fromObject({max:e.max,min:e.min})}constrain(e){const t=this.values.get("max"),i=this.values.get("min");return Math.min(Math.max(e,i),t)}}class us{constructor(e){this.values=d.fromObject({max:e.max,min:e.min})}constrain(e){const t=this.values.get("max"),i=this.values.get("min");let s=e;return E(i)||(s=Math.max(s,i)),E(t)||(s=Math.min(s,t)),s}}class xd{constructor(e,t=0){this.step=e,this.origin=t}constrain(e){const t=this.origin%this.step,i=Math.round((e-t)/this.step);return t+i*this.step}}class Pd{constructor(e){this.text=e}evaluate(){return Number(this.text)}toString(){return this.text}}const yd={"**":(n,e)=>Math.pow(n,e),"*":(n,e)=>n*e,"/":(n,e)=>n/e,"%":(n,e)=>n%e,"+":(n,e)=>n+e,"-":(n,e)=>n-e,"<<":(n,e)=>n<>":(n,e)=>n>>e,">>>":(n,e)=>n>>>e,"&":(n,e)=>n&e,"^":(n,e)=>n^e,"|":(n,e)=>n|e};class Ed{constructor(e,t,i){this.left=t,this.operator=e,this.right=i}evaluate(){const e=yd[this.operator];if(!e)throw new Error(`unexpected binary operator: '${this.operator}`);return e(this.left.evaluate(),this.right.evaluate())}toString(){return["b(",this.left.toString(),this.operator,this.right.toString(),")"].join(" ")}}const kd={"+":n=>n,"-":n=>-n,"~":n=>~n};class Vd{constructor(e,t){this.operator=e,this.expression=t}evaluate(){const e=kd[this.operator];if(!e)throw new Error(`unexpected unary operator: '${this.operator}`);return e(this.expression.evaluate())}toString(){return["u(",this.operator,this.expression.toString(),")"].join(" ")}}function hs(n){return(e,t)=>{for(let i=0;ie.startsWith(s,t))[0];return i?(t+=i.length,t+=Gt(e,t).length,{cursor:t,operator:i}):null}function qd(n,e){return(t,i)=>{const s=n(t,i);if(!s)return null;i=s.cursor;let r=s.evaluable;for(;;){const o=Hd(e,t,i);if(!o)break;i=o.cursor;const a=n(t,i);if(!a)return null;i=a.cursor,r=new Ed(o.operator,r,a.evaluable)}return r?{cursor:i,evaluable:r}:null}}const Gd=[["**"],["*","/","%"],["+","-"],["<<",">>>",">>"],["&"],["^"],["|"]].reduce((n,e)=>qd(n,e),fa);function wa(n,e){return e+=Gt(n,e).length,Gd(n,e)}function Wd(n){const e=wa(n,0);return!e||e.cursor+Gt(n,e.cursor).length!==n.length?null:e.evaluable}function ae(n){var e;const t=Wd(n);return(e=t==null?void 0:t.evaluate())!==null&&e!==void 0?e:null}function ms(n){if(typeof n=="number")return n;if(typeof n=="string"){const e=ae(n);if(!E(e))return e}return 0}function F(n){return e=>e.toFixed(Math.max(Math.min(n,20),0))}function h(n,e,t,i,s){const r=(n-e)/(t-e);return i+r*(s-i)}function xr(n){return String(n.toFixed(10)).split(".")[1].replace(/0+$/,"").length}function V(n,e,t){return Math.min(Math.max(n,e),t)}function _a(n,e){return(n%e+e)%e}function Yd(n,e){return E(n.step)?Math.max(xr(e),2):xr(n.step)}function ga(n){var e;return(e=n.step)!==null&&e!==void 0?e:1}function Xd(n,e){var t;const i=Math.abs((t=n.step)!==null&&t!==void 0?t:e);return i===0?.1:Math.pow(10,Math.floor(Math.log10(i))-1)}function vs(n,e){return E(n.step)?null:new xd(n.step,e)}function bs(n){return!E(n.max)&&!E(n.min)?new ln({max:n.max,min:n.min}):!E(n.max)||!E(n.min)?new us({max:n.max,min:n.min}):null}function fs(n,e){var t,i,s;return{formatter:(t=n.format)!==null&&t!==void 0?t:F(Yd(n,e)),keyScale:(i=n.keyScale)!==null&&i!==void 0?i:ga(n),pointerScale:(s=n.pointerScale)!==null&&s!==void 0?s:Xd(n,e)}}function ws(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 _s(n){return{constraint:n.constraint,textProps:d.fromObject(fs(n.params,n.initialValue))}}class nt{constructor(e){this.controller=e}get element(){return this.controller.view.element}get disabled(){return this.controller.viewProps.get("disabled")}set disabled(e){this.controller.viewProps.set("disabled",e)}get hidden(){return this.controller.viewProps.get("hidden")}set hidden(e){this.controller.viewProps.set("hidden",e)}dispose(){this.controller.viewProps.set("disposed",!0)}importState(e){return this.controller.importState(e)}exportState(){return this.controller.exportState()}}class it{constructor(e){this.target=e}}class In extends it{constructor(e,t,i){super(e),this.value=t,this.last=i??!0}}class Qd extends it{constructor(e,t){super(e),this.expanded=t}}class Jd extends it{constructor(e,t){super(e),this.index=t}}class gs extends nt{constructor(e){super(e),this.onValueChange_=this.onValueChange_.bind(this),this.emitter_=new z,this.controller.value.emitter.on("change",this.onValueChange_)}get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get key(){return this.controller.value.binding.target.key}get tag(){return this.controller.tag}set tag(e){this.controller.tag=e}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)}),this}refresh(){this.controller.value.fetch()}onValueChange_(e){const t=this.controller.value;this.emitter_.emit("change",new In(this,t.binding.target.read(),e.options.last))}}function Zd(n,e){const i=Object.keys(e).reduce((s,r)=>{if(s===void 0)return;const o=e[r],a=o(n[r]);return a.succeeded?Object.assign(Object.assign({},s),{[r]:a.value}):void 0},{});return i}function em(n,e){return n.reduce((t,i)=>{if(t===void 0)return;const s=e(i);if(!(!s.succeeded||s.value===void 0))return[...t,s.value]},[])}function tm(n){return n===null?!1:typeof n=="object"}function be(n){return e=>t=>{if(!e&&t===void 0)return{succeeded:!1,value:void 0};if(e&&t===void 0)return{succeeded:!0,value:void 0};const i=n(t);return i!==void 0?{succeeded:!0,value:i}:{succeeded:!1,value:void 0}}}function Pr(n){return{custom:e=>be(e)(n),boolean:be(e=>typeof e=="boolean"?e:void 0)(n),number:be(e=>typeof e=="number"?e:void 0)(n),string:be(e=>typeof e=="string"?e:void 0)(n),function:be(e=>typeof e=="function"?e:void 0)(n),constant:e=>be(t=>t===e?e:void 0)(n),raw:be(e=>e)(n),object:e=>be(t=>{if(tm(t))return Zd(t,e)})(n),array:e=>be(t=>{if(Array.isArray(t))return em(t,e)})(n)}}const Si={optional:Pr(!0),required:Pr(!1)};function L(n,e){const t=e(Si),i=Si.required.object(t)(n);return i.succeeded?i.value:void 0}function ce(n,e,t,i){if(e&&!e(n))return!1;const s=L(n,t);return s?i(s):!1}function pe(n,e){var t;return Xe((t=n==null?void 0:n())!==null&&t!==void 0?t:{},e)}function wn(n){return"value"in n}function nm(n){if(!ps(n)||!("binding"in n))return!1;const e=n.binding;return bd(e)}const B="http://www.w3.org/2000/svg";function Sn(n){n.offsetHeight}function im(n,e){const t=n.style.transition;n.style.transition="none",e(),n.style.transition=t}function zn(n){return n.ontouchstart!==void 0}function sm(n){const e=n.ownerDocument.defaultView;return e&&"document"in e?n.getContext("2d",{willReadFrequently:!0}):null}const rm={check:'',dropdown:'',p2dpad:''};function Kn(n,e){const t=n.createElementNS(B,"svg");return t.innerHTML=rm[e],t}function Ca(n,e,t){n.insertBefore(e,n.children[t])}function Cs(n){n.parentElement&&n.parentElement.removeChild(n)}function xa(n){for(;n.children.length>0;)n.removeChild(n.children[0])}function om(n){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])}function xs(n){return n.relatedTarget?n.relatedTarget:"explicitOriginalTarget"in n?n.explicitOriginalTarget:null}function se(n,e){n.emitter.on("change",t=>{e(t.rawValue)}),e(n.rawValue)}function re(n,e,t){se(n.value(e),t)}const am="tp";function m(n){return(t,i)=>[am,"-",n,"v",t?`_${t}`:"",i?`-${i}`:""].join("")}const $t=m("lbl");function lm(n,e){const t=n.createDocumentFragment();return e.split(` +`).map(s=>n.createTextNode(s)).forEach((s,r)=>{r>0&&t.appendChild(n.createElement("br")),t.appendChild(s)}),t}class Pa{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add($t()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add($t("l")),re(t.props,"label",r=>{E(r)?this.element.classList.add($t(void 0,"nol")):(this.element.classList.remove($t(void 0,"nol")),om(i),i.appendChild(lm(e,r)))}),this.element.appendChild(i),this.labelElement=i;const s=e.createElement("div");s.classList.add($t("v")),this.element.appendChild(s),this.valueElement=s}}class Un{constructor(e,t){this.props=t.props,this.valueController=t.valueController,this.viewProps=t.valueController.viewProps,this.view=new Pa(e,{props:t.props,viewProps:this.viewProps}),this.view.valueElement.appendChild(this.valueController.view.element)}importProps(e){return ce(e,null,t=>({label:t.optional.string}),t=>(this.props.set("label",t.label),!0))}exportProps(){return pe(null,{label:this.props.get("label")})}}function cm(){return["veryfirst","first","last","verylast"]}const yr=m(""),Er={veryfirst:"vfst",first:"fst",last:"lst",verylast:"vlst"};class cn{constructor(e){this.parent_=null,this.blade=e.blade,this.view=e.view,this.viewProps=e.viewProps;const t=this.view.element;this.blade.value("positions").emitter.on("change",()=>{cm().forEach(i=>{t.classList.remove(yr(void 0,Er[i]))}),this.blade.get("positions").forEach(i=>{t.classList.add(yr(void 0,Er[i]))})}),this.viewProps.handleDispose(()=>{Cs(t)})}get parent(){return this.parent_}set parent(e){this.parent_=e,this.viewProps.set("parent",this.parent_?this.parent_.viewProps:null)}importState(e){return ce(e,null,t=>({disabled:t.required.boolean,hidden:t.required.boolean}),t=>(this.viewProps.importState(t),!0))}exportState(){return pe(null,Object.assign({},this.viewProps.exportState()))}}class Tn extends cn{constructor(e,t){if(t.value!==t.valueController.value)throw K.shouldNeverHappen();const i=t.valueController.viewProps,s=new Un(e,{blade:t.blade,props:t.props,valueController:t.valueController});super(Object.assign(Object.assign({},t),{view:new Pa(e,{props:t.props,viewProps:i}),viewProps:i})),this.labelController=s,this.value=t.value,this.valueController=t.valueController,this.view.valueElement.appendChild(this.valueController.view.element)}importState(e){return ce(e,t=>{var i,s,r;return super.importState(t)&&this.labelController.importProps(t)&&((r=(s=(i=this.valueController).importProps)===null||s===void 0?void 0:s.call(i,e))!==null&&r!==void 0?r:!0)},t=>({value:t.optional.raw}),t=>(t.value&&(this.value.rawValue=t.value),!0))}exportState(){var e,t,i;return pe(()=>super.exportState(),Object.assign(Object.assign({value:this.value.rawValue},this.labelController.exportProps()),(i=(t=(e=this.valueController).exportProps)===null||t===void 0?void 0:t.call(e))!==null&&i!==void 0?i:{}))}}function ya(n,e){for(;n.lengthn.length?t.splice(0,t.length-n.length):ya(t,n.length),t}class dm extends nt{get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get title(){var e;return(e=this.controller.buttonController.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller.buttonController.props.set("title",e)}on(e,t){const i=t.bind(this);return this.controller.buttonController.emitter.on(e,()=>{i(new it(this))}),this}}function mm(n,e,t){t?n.classList.add(e):n.classList.remove(e)}function je(n,e){return t=>{mm(n,e,t)}}function Ps(n,e){se(n,t=>{e.textContent=t??""})}const ri=m("btn");class vm{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(ri()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("button");i.classList.add(ri("b")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const s=e.createElement("div");s.classList.add(ri("t")),Ps(t.props.value("title"),s),this.buttonElement.appendChild(s)}}class Ea{constructor(e,t){this.emitter=new z,this.onClick_=this.onClick_.bind(this),this.props=t.props,this.viewProps=t.viewProps,this.view=new vm(e,{props:this.props,viewProps:this.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}importProps(e){return ce(e,null,t=>({title:t.optional.string}),t=>(this.props.set("title",t.title),!0))}exportProps(){return pe(null,{title:this.props.get("title")})}onClick_(){this.emitter.emit("click",{sender:this})}}class kr extends cn{constructor(e,t){const i=new Ea(e,{props:t.buttonProps,viewProps:t.viewProps}),s=new Un(e,{blade:t.blade,props:t.labelProps,valueController:i});super({blade:t.blade,view:s.view,viewProps:t.viewProps}),this.buttonController=i,this.labelController=s}importState(e){return ce(e,t=>super.importState(t)&&this.buttonController.importProps(t)&&this.labelController.importProps(t),()=>({}),()=>!0)}exportState(){return pe(()=>super.exportState(),Object.assign(Object.assign({},this.buttonController.exportProps()),this.labelController.exportProps()))}}class bm{constructor(e){const[t,i]=e.split("-"),s=t.split(".");this.major=parseInt(s[0],10),this.minor=parseInt(s[1],10),this.patch=parseInt(s[2],10),this.prerelease=i??null}toString(){const e=[this.major,this.minor,this.patch].join(".");return this.prerelease!==null?[e,this.prerelease].join("-"):e}}const fm=new bm("2.0.0-beta.2");function A(n){return Object.assign({core:fm},n)}A({id:"button",type:"blade",accept(n){const e=L(n,t=>({title:t.required.string,view:t.required.constant("button"),label:t.optional.string}));return e?{params:e}:null},controller(n){return new kr(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 kr?new dm(n.controller):null}});function wm(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"button"}))}function _m(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"folder"}))}function gm(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"tab"}))}function Cm(n){return ps(n)?"refresh"in n&&typeof n.refresh=="function":!1}function xm(n,e){if(!Vn.isBindable(n))throw K.notBindable();return new Vn(n,e)}class Pm{constructor(e,t){this.onRackValueChange_=this.onRackValueChange_.bind(this),this.controller_=e,this.emitter_=new z,this.pool_=t,this.controller_.rack.emitter.on("valuechange",this.onRackValueChange_)}get children(){return this.controller_.rack.children.map(e=>this.pool_.createApi(e))}addBinding(e,t,i){const s=i??{},r=this.controller_.element.ownerDocument,o=this.pool_.createBinding(r,xm(e,t),s),a=this.pool_.createBindingApi(o);return this.add(a,s.index)}addFolder(e){return _m(this,e)}addButton(e){return wm(this,e)}addTab(e){return gm(this,e)}add(e,t){const i=e.controller;return this.controller_.rack.add(i,t),e}remove(e){this.controller_.rack.remove(e.controller)}addBlade(e){const t=this.controller_.element.ownerDocument,i=this.pool_.createBlade(t,e),s=this.pool_.createApi(i);return this.add(s,e.index)}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)}),this}refresh(){this.children.forEach(e=>{Cm(e)&&e.refresh()})}onRackValueChange_(e){const t=e.bladeController,i=this.pool_.createApi(t),s=nm(t.value)?t.value.binding:null;this.emitter_.emit("change",new In(i,s?s.target.read():t.value.rawValue,e.options.last))}}class ys extends nt{constructor(e,t){super(e),this.rackApi_=new Pm(e.rackController,t)}}class Es extends cn{constructor(e){super({blade:e.blade,view:e.view,viewProps:e.rackController.viewProps}),this.rackController=e.rackController}importState(e){return ce(e,t=>super.importState(t),t=>({children:t.required.array(t.required.raw)}),t=>this.rackController.rack.children.every((i,s)=>i.importState(t.children[s])))}exportState(){return pe(()=>super.exportState(),{children:this.rackController.rack.children.map(e=>e.exportState())})}}function Ti(n){return"rackController"in n}class ym{constructor(e){this.emitter=new z,this.items_=[],this.cache_=new Set,this.onSubListAdd_=this.onSubListAdd_.bind(this),this.onSubListRemove_=this.onSubListRemove_.bind(this),this.extract_=e}get items(){return this.items_}allItems(){return Array.from(this.cache_)}find(e){for(const t of this.allItems())if(e(t))return t;return null}includes(e){return this.cache_.has(e)}add(e,t){if(this.includes(e))throw K.shouldNeverHappen();const i=t!==void 0?t:this.items_.length;this.items_.splice(i,0,e),this.cache_.add(e);const s=this.extract_(e);s&&(s.emitter.on("add",this.onSubListAdd_),s.emitter.on("remove",this.onSubListRemove_),s.allItems().forEach(r=>{this.cache_.add(r)})),this.emitter.emit("add",{index:i,item:e,root:this,target:this})}remove(e){const t=this.items_.indexOf(e);if(t<0)return;this.items_.splice(t,1),this.cache_.delete(e);const i=this.extract_(e);i&&(i.allItems().forEach(s=>{this.cache_.delete(s)}),i.emitter.off("add",this.onSubListAdd_),i.emitter.off("remove",this.onSubListRemove_)),this.emitter.emit("remove",{index:t,item:e,root:this,target:this})}onSubListAdd_(e){this.cache_.add(e.item),this.emitter.emit("add",{index:e.index,item:e.item,root:this,target:e.target})}onSubListRemove_(e){this.cache_.delete(e.item),this.emitter.emit("remove",{index:e.index,item:e.item,root:this,target:e.target})}}function Em(n,e){for(let t=0;t!s.viewProps.get("hidden")),t=e[0],i=e[e.length-1];this.bcSet_.items.forEach(s=>{const r=[];s===t&&(r.push("first"),(!this.blade_||this.blade_.get("positions").includes("veryfirst"))&&r.push("veryfirst")),s===i&&(r.push("last"),(!this.blade_||this.blade_.get("positions").includes("verylast"))&&r.push("verylast")),s.blade.set("positions",r)})}onChildPositionsChange_(){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildViewPropsChange_(e){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildDispose_(){this.bcSet_.items.filter(t=>t.viewProps.get("disposed")).forEach(t=>{this.bcSet_.remove(t)})}onChildValueChange_(e){const t=Em(this.find(wn),e.sender);if(!t)throw K.alreadyDisposed();this.emitter.emit("valuechange",{bladeController:t,options:e.options,sender:this})}onRackLayout_(e){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onRackValueChange_(e){this.emitter.emit("valuechange",{bladeController:e.bladeController,options:e.options,sender:this})}onBladePositionsChange_(){this.updatePositions_()}}class ks{constructor(e){this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this),this.element=e.element,this.viewProps=e.viewProps;const t=new Vm({blade:e.root?void 0:e.blade,viewProps:e.viewProps});t.emitter.on("add",this.onRackAdd_),t.emitter.on("remove",this.onRackRemove_),this.rack=t,this.viewProps.handleDispose(()=>{for(let i=this.rack.children.length-1;i>=0;i--)this.rack.children[i].viewProps.set("disposed",!0)})}onRackAdd_(e){e.root&&Ca(this.element,e.bladeController.view.element,e.index)}onRackRemove_(e){e.root&&Cs(e.bladeController.view.element)}}function ka(){return new d({positions:T([],{equals:vd})})}class yt extends d{constructor(e){super(e)}static create(e){const t={completed:!0,expanded:e,expandedHeight:null,shouldFixHeight:!1,temporaryExpanded:null},i=d.createCore(t);return new yt(i)}get styleExpanded(){var e;return(e=this.get("temporaryExpanded"))!==null&&e!==void 0?e:this.get("expanded")}get styleHeight(){if(!this.styleExpanded)return"0";const e=this.get("expandedHeight");return this.get("shouldFixHeight")&&!E(e)?`${e}px`:"auto"}bindExpandedClass(e,t){const i=()=>{this.styleExpanded?e.classList.add(t):e.classList.remove(t)};re(this,"expanded",i),re(this,"temporaryExpanded",i)}cleanUpTransition(){this.set("shouldFixHeight",!1),this.set("expandedHeight",null),this.set("completed",!0)}}function Sm(n,e){let t=0;return im(e,()=>{n.set("expandedHeight",null),n.set("temporaryExpanded",!0),Sn(e),t=e.clientHeight,n.set("temporaryExpanded",null),Sn(e)}),t}function Vr(n,e){e.style.height=n.styleHeight}function Hn(n,e){n.value("expanded").emitter.on("beforechange",()=>{if(n.set("completed",!1),E(n.get("expandedHeight"))){const t=Sm(n,e);t>0&&n.set("expandedHeight",t)}n.set("shouldFixHeight",!0),Sn(e)}),n.emitter.on("change",()=>{Vr(n,e)}),Vr(n,e),e.addEventListener("transitionend",t=>{t.propertyName==="height"&&n.cleanUpTransition()})}class Tm extends ys{constructor(e,t){super(e,t),this.emitter_=new z,this.controller.foldable.value("expanded").emitter.on("change",i=>{this.emitter_.emit("fold",new Qd(this,i.sender.rawValue))}),this.rackApi_.on("change",i=>{this.emitter_.emit("change",i)})}get expanded(){return this.controller.foldable.get("expanded")}set expanded(e){this.controller.foldable.set("expanded",e)}get title(){return this.controller.props.get("title")}set title(e){this.controller.props.set("title",e)}get children(){return this.rackApi_.children}addBinding(e,t,i){return this.rackApi_.addBinding(e,t,i)}addFolder(e){return this.rackApi_.addFolder(e)}addButton(e){return this.rackApi_.addButton(e)}addTab(e){return this.rackApi_.addTab(e)}add(e,t){return this.rackApi_.add(e,t)}remove(e){this.rackApi_.remove(e)}addBlade(e){return this.rackApi_.addBlade(e)}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)}),this}refresh(){this.rackApi_.refresh()}}const Va=m("cnt");class Lm{constructor(e,t){var i;this.className_=m((i=t.viewName)!==null&&i!==void 0?i:"fld"),this.element=e.createElement("div"),this.element.classList.add(this.className_(),Va()),t.viewProps.bindClassModifiers(this.element),this.foldable_=t.foldable,this.foldable_.bindExpandedClass(this.element,this.className_(void 0,"expanded")),re(this.foldable_,"completed",je(this.element,this.className_(void 0,"cpl")));const s=e.createElement("button");s.classList.add(this.className_("b")),re(t.props,"title",c=>{E(c)?this.element.classList.add(this.className_(void 0,"not")):this.element.classList.remove(this.className_(void 0,"not"))}),t.viewProps.bindDisabled(s),this.element.appendChild(s),this.buttonElement=s;const r=e.createElement("div");r.classList.add(this.className_("i")),this.element.appendChild(r);const o=e.createElement("div");o.classList.add(this.className_("t")),Ps(t.props.value("title"),o),this.buttonElement.appendChild(o),this.titleElement=o;const a=e.createElement("div");a.classList.add(this.className_("m")),this.buttonElement.appendChild(a);const l=e.createElement("div");l.classList.add(this.className_("c")),this.element.appendChild(l),this.containerElement=l}}class Sr extends Es{constructor(e,t){var i;const s=yt.create((i=t.expanded)!==null&&i!==void 0?i:!0),r=new Lm(e,{foldable:s,props:t.props,viewName:t.root?"rot":void 0,viewProps:t.viewProps});super(Object.assign(Object.assign({},t),{rackController:new ks({blade:t.blade,element:r.containerElement,root:t.root,viewProps:t.viewProps}),view:r})),this.onTitleClick_=this.onTitleClick_.bind(this),this.props=t.props,this.foldable=s,Hn(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(e){return ce(e,t=>super.importState(t),t=>({expanded:t.required.boolean,title:t.optional.string}),t=>(this.foldable.set("expanded",t.expanded),this.props.set("title",t.title),!0))}exportState(){return pe(()=>super.exportState(),{expanded:this.foldable.get("expanded"),title:this.props.get("title")})}onTitleClick_(){this.foldable.set("expanded",!this.foldable.get("expanded"))}}A({id:"folder",type:"blade",accept(n){const e=L(n,t=>({title:t.required.string,view:t.required.constant("folder"),expanded:t.optional.boolean}));return e?{params:e}:null},controller(n){return new Sr(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 Sr?new Tm(n.controller,n.pool):null}});const $m=m("");function Tr(n,e){return je(n,$m(void 0,e))}class Pe extends d{constructor(e){var t;super(e),this.onDisabledChange_=this.onDisabledChange_.bind(this),this.onParentChange_=this.onParentChange_.bind(this),this.onParentGlobalDisabledChange_=this.onParentGlobalDisabledChange_.bind(this),[this.globalDisabled_,this.setGlobalDisabled_]=Cd(T(this.getGlobalDisabled_())),this.value("disabled").emitter.on("change",this.onDisabledChange_),this.value("parent").emitter.on("change",this.onParentChange_),(t=this.get("parent"))===null||t===void 0||t.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_)}static create(e){var t,i,s;const r=e??{};return new Pe(d.createCore({disabled:(t=r.disabled)!==null&&t!==void 0?t:!1,disposed:!1,hidden:(i=r.hidden)!==null&&i!==void 0?i:!1,parent:(s=r.parent)!==null&&s!==void 0?s:null}))}get globalDisabled(){return this.globalDisabled_}bindClassModifiers(e){se(this.globalDisabled_,Tr(e,"disabled")),re(this,"hidden",Tr(e,"hidden"))}bindDisabled(e){se(this.globalDisabled_,t=>{e.disabled=t})}bindTabIndex(e){se(this.globalDisabled_,t=>{e.tabIndex=t?-1:0})}handleDispose(e){this.value("disposed").emitter.on("change",t=>{t&&e()})}importState(e){this.set("disabled",e.disabled),this.set("hidden",e.hidden)}exportState(){return{disabled:this.get("disabled"),hidden:this.get("hidden")}}getGlobalDisabled_(){const e=this.get("parent");return(e?e.globalDisabled.rawValue:!1)||this.get("disabled")}updateGlobalDisabled_(){this.setGlobalDisabled_(this.getGlobalDisabled_())}onDisabledChange_(){this.updateGlobalDisabled_()}onParentGlobalDisabledChange_(){this.updateGlobalDisabled_()}onParentChange_(e){var t;const i=e.previousRawValue;i==null||i.globalDisabled.emitter.off("change",this.onParentGlobalDisabledChange_),(t=this.get("parent"))===null||t===void 0||t.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_),this.updateGlobalDisabled_()}}const Lr=m("tbp");class Am{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Lr()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(Lr("c")),this.element.appendChild(i),this.containerElement=i}}const At=m("tbi");class Mm{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(At()),t.viewProps.bindClassModifiers(this.element),re(t.props,"selected",r=>{r?this.element.classList.add(At(void 0,"sel")):this.element.classList.remove(At(void 0,"sel"))});const i=e.createElement("button");i.classList.add(At("b")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const s=e.createElement("div");s.classList.add(At("t")),Ps(t.props.value("title"),s),this.buttonElement.appendChild(s),this.titleElement=s}}class Om{constructor(e,t){this.emitter=new z,this.onClick_=this.onClick_.bind(this),this.props=t.props,this.viewProps=t.viewProps,this.view=new Mm(e,{props:t.props,viewProps:t.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}onClick_(){this.emitter.emit("click",{sender:this})}}class Li extends Es{constructor(e,t){const i=new Am(e,{viewProps:t.viewProps});super(Object.assign(Object.assign({},t),{rackController:new ks({blade:t.blade,element:i.containerElement,viewProps:t.viewProps}),view:i})),this.onItemClick_=this.onItemClick_.bind(this),this.ic_=new Om(e,{props:t.itemProps,viewProps:Pe.create()}),this.ic_.emitter.on("click",this.onItemClick_),this.props=t.props,re(this.props,"selected",s=>{this.itemController.props.set("selected",s),this.viewProps.set("hidden",!s)})}get itemController(){return this.ic_}importState(e){return ce(e,t=>super.importState(t),t=>({selected:t.required.boolean,title:t.required.string}),t=>(this.ic_.props.set("selected",t.selected),this.ic_.props.set("title",t.title),!0))}exportState(){return pe(()=>super.exportState(),{selected:this.ic_.props.get("selected"),title:this.ic_.props.get("title")})}onItemClick_(){this.props.set("selected",!0)}}class Rm extends ys{constructor(e,t){super(e,t),this.emitter_=new z,this.onSelect_=this.onSelect_.bind(this),this.pool_=t,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(e){const t=this.controller.view.element.ownerDocument,i=new Li(t,{blade:ka(),itemProps:d.fromObject({selected:!1,title:e.title}),props:d.fromObject({selected:!1}),viewProps:Pe.create()}),s=this.pool_.createApi(i);return this.rackApi_.add(s,e.index)}removePage(e){this.rackApi_.remove(this.rackApi_.children[e])}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)}),this}onSelect_(e){this.emitter_.emit("select",new Jd(this,e.rawValue))}}class Dm extends ys{get title(){var e;return(e=this.controller.itemController.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller.itemController.props.set("title",e)}get selected(){return this.controller.props.get("selected")}set selected(e){this.controller.props.set("selected",e)}get children(){return this.rackApi_.children}addButton(e){return this.rackApi_.addButton(e)}addFolder(e){return this.rackApi_.addFolder(e)}addTab(e){return this.rackApi_.addTab(e)}add(e,t){this.rackApi_.add(e,t)}remove(e){this.rackApi_.remove(e)}addBinding(e,t,i){return this.rackApi_.addBinding(e,t,i)}addBlade(e){return this.rackApi_.addBlade(e)}refresh(){this.rackApi_.refresh()}}const $r=-1;class Bm{constructor(){this.onItemSelectedChange_=this.onItemSelectedChange_.bind(this),this.empty=T(!0),this.selectedIndex=T($r),this.items_=[]}add(e,t){const i=t??this.items_.length;this.items_.splice(i,0,e),e.emitter.on("change",this.onItemSelectedChange_),this.keepSelection_()}remove(e){const t=this.items_.indexOf(e);t<0||(this.items_.splice(t,1),e.emitter.off("change",this.onItemSelectedChange_),this.keepSelection_())}keepSelection_(){if(this.items_.length===0){this.selectedIndex.rawValue=$r,this.empty.rawValue=!0;return}const e=this.items_.findIndex(t=>t.rawValue);e<0?(this.items_.forEach((t,i)=>{t.rawValue=i===0}),this.selectedIndex.rawValue=0):(this.items_.forEach((t,i)=>{t.rawValue=i===e}),this.selectedIndex.rawValue=e),this.empty.rawValue=!1}onItemSelectedChange_(e){if(e.rawValue){const t=this.items_.findIndex(i=>i===e.sender);this.items_.forEach((i,s)=>{i.rawValue=s===t}),this.selectedIndex.rawValue=t}else this.keepSelection_()}}const Mt=m("tab");class Nm{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Mt(),Va()),t.viewProps.bindClassModifiers(this.element),se(t.empty,je(this.element,Mt(void 0,"nop")));const i=e.createElement("div");i.classList.add(Mt("t")),this.element.appendChild(i),this.itemsElement=i;const s=e.createElement("div");s.classList.add(Mt("i")),this.element.appendChild(s);const r=e.createElement("div");r.classList.add(Mt("c")),this.element.appendChild(r),this.contentsElement=r}}class Ar extends Es{constructor(e,t){const i=new Bm,s=new Nm(e,{empty:i.empty,viewProps:t.viewProps});super({blade:t.blade,rackController:new ks({blade:t.blade,element:s.contentsElement,viewProps:t.viewProps}),view:s}),this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this);const r=this.rackController.rack;r.emitter.on("add",this.onRackAdd_),r.emitter.on("remove",this.onRackRemove_),this.tab=i}add(e,t){this.rackController.rack.add(e,t)}remove(e){this.rackController.rack.remove(this.rackController.rack.children[e])}onRackAdd_(e){if(!e.root)return;const t=e.bladeController;Ca(this.view.itemsElement,t.itemController.view.element,e.index),t.itemController.viewProps.set("parent",this.viewProps),this.tab.add(t.props.value("selected"))}onRackRemove_(e){if(!e.root)return;const t=e.bladeController;Cs(t.itemController.view.element),t.itemController.viewProps.set("parent",null),this.tab.remove(t.props.value("selected"))}}A({id:"tab",type:"blade",accept(n){const e=L(n,t=>({pages:t.required.array(t.required.object({title:t.required.string})),view:t.required.constant("tab")}));return!e||e.pages.length===0?null:{params:e}},controller(n){const e=new Ar(n.document,{blade:n.blade,viewProps:n.viewProps});return n.params.pages.forEach(t=>{const i=new Li(n.document,{blade:ka(),itemProps:d.fromObject({selected:!1,title:t.title}),props:d.fromObject({selected:!1}),viewProps:Pe.create()});e.add(i)}),e},api(n){return n.controller instanceof Ar?new Rm(n.controller,n.pool):n.controller instanceof Li?new Dm(n.controller,n.pool):null}});class Vs extends gs{get options(){return this.controller.valueController.props.get("options")}set options(e){this.controller.valueController.props.set("options",e)}}class Fm{constructor(){this.disabled=!1,this.emitter=new z}dispose(){}tick(){this.disabled||this.emitter.emit("tick",{sender:this})}}class jm{constructor(e,t){this.disabled_=!1,this.timerId_=null,this.onTick_=this.onTick_.bind(this),this.doc_=e,this.emitter=new z,this.interval_=t,this.setTimer_()}get disabled(){return this.disabled_}set disabled(e){this.disabled_=e,this.disabled_?this.clearTimer_():this.setTimer_()}dispose(){this.clearTimer_()}clearTimer_(){if(this.timerId_===null)return;const e=this.doc_.defaultView;e&&e.clearInterval(this.timerId_),this.timerId_=null}setTimer_(){if(this.clearTimer_(),this.interval_<=0)return;const e=this.doc_.defaultView;e&&(this.timerId_=e.setInterval(this.onTick_,this.interval_))}onTick_(){this.disabled_||this.emitter.emit("tick",{sender:this})}}class Et{constructor(e){this.constraints=e}constrain(e){return this.constraints.reduce((t,i)=>i.constrain(t),e)}}function Yt(n,e){if(n instanceof e)return n;if(n instanceof Et){const t=n.constraints.reduce((i,s)=>i||(s instanceof e?s:null),null);if(t)return t}return null}class qn{constructor(e){this.values=d.fromObject({options:e})}constrain(e){const t=this.values.get("options");return t.length===0||t.filter(s=>s.value===e).length>0?e:t[0].value}}function Gn(n){var e;const t=Si;if(Array.isArray(n))return(e=L({items:n},i=>({items:i.required.array(i.required.object({text:i.required.string,value:i.required.raw}))})))===null||e===void 0?void 0:e.items;if(typeof n=="object")return t.required.raw(n).value}function Sa(n){if(Array.isArray(n))return n;const e=[];return Object.keys(n).forEach(t=>{e.push({text:t,value:n[t]})}),e}function Ss(n){return E(n)?null:new qn(Sa(n))}const oi=m("lst");class Im{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.props_=t.props,this.element=e.createElement("div"),this.element.classList.add(oi()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("select");i.classList.add(oi("s")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.selectElement=i;const s=e.createElement("div");s.classList.add(oi("m")),s.appendChild(Kn(e,"dropdown")),this.element.appendChild(s),t.value.emitter.on("change",this.onValueChange_),this.value_=t.value,re(this.props_,"options",r=>{xa(this.selectElement),r.forEach(o=>{const a=e.createElement("option");a.textContent=o.text,this.selectElement.appendChild(a)}),this.update_()})}update_(){const e=this.props_.get("options").map(t=>t.value);this.selectElement.selectedIndex=e.indexOf(this.value_.rawValue)}onValueChange_(){this.update_()}}class wt{constructor(e,t){this.onSelectChange_=this.onSelectChange_.bind(this),this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new Im(e,{props:this.props,value:this.value,viewProps:this.viewProps}),this.view.selectElement.addEventListener("change",this.onSelectChange_)}onSelectChange_(e){const t=e.currentTarget;this.value.rawValue=this.props.get("options")[t.selectedIndex].value}importProps(e){return ce(e,null,t=>({options:t.required.custom(Gn)}),t=>(this.props.set("options",Sa(t.options)),!0))}exportProps(){return pe(null,{options:this.props.get("options")})}}const Mr=m("pop");class zm{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Mr()),t.viewProps.bindClassModifiers(this.element),se(t.shows,je(this.element,Mr(void 0,"v")))}}class Ts{constructor(e,t){this.shows=T(!1),this.viewProps=t.viewProps,this.view=new zm(e,{shows:this.shows,viewProps:this.viewProps})}}const Or=m("txt");class Km{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.element=e.createElement("div"),this.element.classList.add(Or()),t.viewProps.bindClassModifiers(this.element),this.props_=t.props,this.props_.emitter.on("change",this.onChange_);const i=e.createElement("input");i.classList.add(Or("i")),i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,t.value.emitter.on("change",this.onChange_),this.value_=t.value,this.refresh()}refresh(){const e=this.props_.get("formatter");this.inputElement.value=e(this.value_.rawValue)}onChange_(){this.refresh()}}class Wn{constructor(e,t){this.onInputChange_=this.onInputChange_.bind(this),this.parser_=t.parser,this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new Km(e,{props:t.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_)}onInputChange_(e){const i=e.currentTarget.value,s=this.parser_(i);E(s)||(this.value.rawValue=s),this.view.refresh()}}function Um(n){return String(n)}function Ls(n){return n==="false"?!1:!!n}function Rr(n){return Um(n)}function Hm(n){return e=>n.reduce((t,i)=>t!==null?t:i(e),null)}const qm=F(0);function Ln(n){return qm(n)+"%"}function $s(n){return String(n)}function $i(n){return n}function st({primary:n,secondary:e,forward:t,backward:i}){let s=!1;function r(o){s||(s=!0,o(),s=!1)}n.emitter.on("change",o=>{r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),o.options)})}),e.emitter.on("change",o=>{r(()=>{n.setRawValue(i(n.rawValue,e.rawValue),o.options)}),r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),o.options)})}),r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),{forceEmit:!1,last:!0})})}function N(n,e){const t=n*(e.altKey?.1:1)*(e.shiftKey?10:1);return e.upKey?+t:e.downKey?-t:0}function Qe(n){return{altKey:n.altKey,downKey:n.key==="ArrowDown",shiftKey:n.shiftKey,upKey:n.key==="ArrowUp"}}function le(n){return{altKey:n.altKey,downKey:n.key==="ArrowLeft",shiftKey:n.shiftKey,upKey:n.key==="ArrowRight"}}function Gm(n){return n==="ArrowUp"||n==="ArrowDown"}function $n(n){return Gm(n)||n==="ArrowLeft"||n==="ArrowRight"}function ai(n,e){var t,i;const s=e.ownerDocument.defaultView,r=e.getBoundingClientRect();return{x:n.pageX-(((t=s&&s.scrollX)!==null&&t!==void 0?t:0)+r.left),y:n.pageY-(((i=s&&s.scrollY)!==null&&i!==void 0?i:0)+r.top)}}class Ee{constructor(e){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_=e,this.emitter=new z,e.addEventListener("touchstart",this.onTouchStart_,{passive:!1}),e.addEventListener("touchmove",this.onTouchMove_,{passive:!0}),e.addEventListener("touchend",this.onTouchEnd_),e.addEventListener("mousedown",this.onMouseDown_)}computePosition_(e){const t=this.elem_.getBoundingClientRect();return{bounds:{width:t.width,height:t.height},point:e?{x:e.x,y:e.y}:null}}onMouseDown_(e){var t;e.preventDefault(),(t=e.currentTarget)===null||t===void 0||t.focus();const i=this.elem_.ownerDocument;i.addEventListener("mousemove",this.onDocumentMouseMove_),i.addEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("down",{altKey:e.altKey,data:this.computePosition_(ai(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onDocumentMouseMove_(e){this.emitter.emit("move",{altKey:e.altKey,data:this.computePosition_(ai(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onDocumentMouseUp_(e){const t=this.elem_.ownerDocument;t.removeEventListener("mousemove",this.onDocumentMouseMove_),t.removeEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("up",{altKey:e.altKey,data:this.computePosition_(ai(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onTouchStart_(e){e.preventDefault();const t=e.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("down",{altKey:e.altKey,data:this.computePosition_(t?{x:t.clientX-i.left,y:t.clientY-i.top}:void 0),sender:this,shiftKey:e.shiftKey}),this.lastTouch_=t}onTouchMove_(e){const t=e.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("move",{altKey:e.altKey,data:this.computePosition_(t?{x:t.clientX-i.left,y:t.clientY-i.top}:void 0),sender:this,shiftKey:e.shiftKey}),this.lastTouch_=t}onTouchEnd_(e){var t;const i=(t=e.targetTouches.item(0))!==null&&t!==void 0?t:this.lastTouch_,s=this.elem_.getBoundingClientRect();this.emitter.emit("up",{altKey:e.altKey,data:this.computePosition_(i?{x:i.clientX-s.left,y:i.clientY-s.top}:void 0),sender:this,shiftKey:e.shiftKey})}}const ee=m("txt");class Wm{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onChange_),this.element=e.createElement("div"),this.element.classList.add(ee(),ee(void 0,"num")),t.arrayPosition&&this.element.classList.add(ee(void 0,t.arrayPosition)),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("input");i.classList.add(ee("i")),i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,this.onDraggingChange_=this.onDraggingChange_.bind(this),this.dragging_=t.dragging,this.dragging_.emitter.on("change",this.onDraggingChange_),this.element.classList.add(ee()),this.inputElement.classList.add(ee("i"));const s=e.createElement("div");s.classList.add(ee("k")),this.element.appendChild(s),this.knobElement=s;const r=e.createElementNS(B,"svg");r.classList.add(ee("g")),this.knobElement.appendChild(r);const o=e.createElementNS(B,"path");o.classList.add(ee("gb")),r.appendChild(o),this.guideBodyElem_=o;const a=e.createElementNS(B,"path");a.classList.add(ee("gh")),r.appendChild(a),this.guideHeadElem_=a;const l=e.createElement("div");l.classList.add(m("tt")()),this.knobElement.appendChild(l),this.tooltipElem_=l,t.value.emitter.on("change",this.onChange_),this.value=t.value,this.refresh()}onDraggingChange_(e){if(e.rawValue===null){this.element.classList.remove(ee(void 0,"drg"));return}this.element.classList.add(ee(void 0,"drg"));const t=e.rawValue/this.props_.get("pointerScale"),i=t+(t>0?-1:t<0?1:0),s=V(-i,-4,4);this.guideHeadElem_.setAttributeNS(null,"d",[`M ${i+s},0 L${i},4 L${i+s},8`,`M ${t},-1 L${t},9`].join(" ")),this.guideBodyElem_.setAttributeNS(null,"d",`M 0,4 L${t},4`);const r=this.props_.get("formatter");this.tooltipElem_.textContent=r(this.value.rawValue),this.tooltipElem_.style.left=`${t}px`}refresh(){const e=this.props_.get("formatter");this.inputElement.value=e(this.value.rawValue)}onChange_(){this.refresh()}}class pn{constructor(e,t){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_=t.parser,this.props=t.props,this.sliderProps_=(i=t.sliderProps)!==null&&i!==void 0?i:null,this.value=t.value,this.viewProps=t.viewProps,this.dragging_=T(null),this.view=new Wm(e,{arrayPosition:t.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 s=new Ee(this.view.knobElement);s.emitter.on("down",this.onPointerDown_),s.emitter.on("move",this.onPointerMove_),s.emitter.on("up",this.onPointerUp_)}constrainValue_(e){var t,i;const s=(t=this.sliderProps_)===null||t===void 0?void 0:t.get("min"),r=(i=this.sliderProps_)===null||i===void 0?void 0:i.get("max");let o=e;return s!==void 0&&(o=Math.max(o,s)),r!==void 0&&(o=Math.min(o,r)),o}onInputChange_(e){const i=e.currentTarget.value,s=this.parser_(i);E(s)||(this.value.rawValue=this.constrainValue_(s)),this.view.refresh()}onInputKeyDown_(e){const t=N(this.props.get("keyScale"),Qe(e));t!==0&&this.value.setRawValue(this.constrainValue_(this.value.rawValue+t),{forceEmit:!1,last:!1})}onInputKeyUp_(e){N(this.props.get("keyScale"),Qe(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}onPointerDown_(){this.originRawValue_=this.value.rawValue,this.dragging_.rawValue=0}computeDraggingValue_(e){if(!e.point)return null;const t=e.point.x-e.bounds.width/2;return this.constrainValue_(this.originRawValue_+t*this.props.get("pointerScale"))}onPointerMove_(e){const t=this.computeDraggingValue_(e.data);t!==null&&(this.value.setRawValue(t,{forceEmit:!1,last:!1}),this.dragging_.rawValue=this.value.rawValue-this.originRawValue_)}onPointerUp_(e){const t=this.computeDraggingValue_(e.data);t!==null&&(this.value.setRawValue(t,{forceEmit:!0,last:!0}),this.dragging_.rawValue=null)}}const li=m("sld");class Ym{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onChange_),this.element=e.createElement("div"),this.element.classList.add(li()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(li("t")),t.viewProps.bindTabIndex(i),this.element.appendChild(i),this.trackElement=i;const s=e.createElement("div");s.classList.add(li("k")),this.trackElement.appendChild(s),this.knobElement=s,t.value.emitter.on("change",this.onChange_),this.value=t.value,this.update_()}update_(){const e=V(h(this.value.rawValue,this.props_.get("min"),this.props_.get("max"),0,100),0,100);this.knobElement.style.width=`${e}%`}onChange_(){this.update_()}}class Xm{constructor(e,t){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=t.value,this.viewProps=t.viewProps,this.props=t.props,this.view=new Ym(e,{props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Ee(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_(e,t){e.point&&this.value.setRawValue(h(V(e.point.x,0,e.bounds.width),0,e.bounds.width,this.props.get("min"),this.props.get("max")),t)}onPointerDownOrMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=N(this.props.get("keyScale"),le(e));t!==0&&this.value.setRawValue(this.value.rawValue+t,{forceEmit:!1,last:!1})}onKeyUp_(e){N(this.props.get("keyScale"),le(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const ci=m("sldtxt");class Qm{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(ci());const i=e.createElement("div");i.classList.add(ci("s")),this.sliderView_=t.sliderView,i.appendChild(this.sliderView_.element),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(ci("t")),this.textView_=t.textView,s.appendChild(this.textView_.element),this.element.appendChild(s)}}class Dr{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.sliderC_=new Xm(e,{props:t.sliderProps,value:t.value,viewProps:this.viewProps}),this.textC_=new pn(e,{parser:t.parser,props:t.textProps,sliderProps:t.sliderProps,value:t.value,viewProps:t.viewProps}),this.view=new Qm(e,{sliderView:this.sliderC_.view,textView:this.textC_.view})}get sliderController(){return this.sliderC_}get textController(){return this.textC_}importProps(e){return ce(e,null,t=>({max:t.required.number,min:t.required.number}),t=>{const i=this.sliderC_.props;return i.set("max",t.max),i.set("min",t.min),!0})}exportProps(){const e=this.sliderC_.props;return pe(null,{max:e.get("max"),min:e.get("min")})}}function Jm(n){return{sliderProps:new d({keyScale:n.keyScale,max:n.max,min:n.min}),textProps:new d({formatter:T(n.formatter),keyScale:n.keyScale,pointerScale:T(n.pointerScale)})}}const Zm={containerUnitSize:"cnt-usz"};function Ta(n){return`--${Zm[n]}`}class La{constructor(e,t){const i=m(t.viewName);this.element=e.createElement("div"),this.element.classList.add(i()),t.viewProps.bindClassModifiers(this.element)}}function Xt(n){return ws(n)}function Oe(n){if(Vi(n))return L(n,Xt)}function _e(n,e){if(!n)return;const t=[],i=vs(n,e);i&&t.push(i);const s=bs(n);return s&&t.push(s),new Et(t)}function $a(n){if(n==="inline"||n==="popup")return n}function Ie(n,e){n.write(e)}const mn=m("ckb");class ev{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.element=e.createElement("div"),this.element.classList.add(mn()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("label");i.classList.add(mn("l")),this.element.appendChild(i);const s=e.createElement("input");s.classList.add(mn("i")),s.type="checkbox",i.appendChild(s),this.inputElement=s,t.viewProps.bindDisabled(this.inputElement);const r=e.createElement("div");r.classList.add(mn("w")),i.appendChild(r);const o=Kn(e,"check");r.appendChild(o),t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.update_()}update_(){this.inputElement.checked=this.value.rawValue}onValueChange_(){this.update_()}}class tv{constructor(e,t){this.onInputChange_=this.onInputChange_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.view=new ev(e,{value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_)}onInputChange_(e){const t=e.currentTarget;this.value.rawValue=t.checked}}function nv(n){const e=[],t=Ss(n.options);return t&&e.push(t),new Et(e)}A({id:"input-bool",type:"input",accept:(n,e)=>{if(typeof n!="boolean")return null;const t=L(e,i=>({options:i.optional.custom(Gn),readonly:i.optional.constant(!1)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>Ls,constraint:n=>nv(n.params),writer:n=>Ie},controller:n=>{const e=n.document,t=n.value,i=n.constraint,s=i&&Yt(i,qn);return s?new wt(e,{props:new d({options:s.values.value("options")}),value:t,viewProps:n.viewProps}):new tv(e,{value:t,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="boolean"?null:n.controller.valueController instanceof wt?new Vs(n.controller):null}});const Ke=m("col");class iv{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Ke()),t.foldable.bindExpandedClass(this.element,Ke(void 0,"expanded")),re(t.foldable,"completed",je(this.element,Ke(void 0,"cpl")));const i=e.createElement("div");i.classList.add(Ke("h")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(Ke("s")),i.appendChild(s),this.swatchElement=s;const r=e.createElement("div");if(r.classList.add(Ke("t")),i.appendChild(r),this.textElement=r,t.pickerLayout==="inline"){const o=e.createElement("div");o.classList.add(Ke("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}}function sv(n,e,t){const i=V(n/255,0,1),s=V(e/255,0,1),r=V(t/255,0,1),o=Math.max(i,s,r),a=Math.min(i,s,r),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=(s-r)/l:s===o?c=2+(r-i)/l:c=4+(i-s)/l,c=c/6+(c<0?1:0)),[c*360,p*100,u*100]}function rv(n,e,t){const i=(n%360+360)%360,s=V(e/100,0,1),r=V(t/100,0,1),o=(1-Math.abs(2*r-1))*s,a=o*(1-Math.abs(i/60%2-1)),l=r-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 ov(n,e,t){const i=V(n/255,0,1),s=V(e/255,0,1),r=V(t/255,0,1),o=Math.max(i,s,r),a=Math.min(i,s,r),l=o-a;let c;l===0?c=0:o===i?c=60*(((s-r)/l%6+6)%6):o===s?c=60*((r-i)/l+2):c=60*((i-s)/l+4);const p=o===0?0:l/o,u=o;return[c,p*100,u*100]}function Aa(n,e,t){const i=_a(n,360),s=V(e/100,0,1),r=V(t/100,0,1),o=r*s,a=o*(1-Math.abs(i/60%2-1)),l=r-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 av(n,e,t){const i=t+e*(100-Math.abs(2*t-100))/200;return[n,i!==0?e*(100-Math.abs(2*t-100))/i:0,t+e*(100-Math.abs(2*t-100))/(2*100)]}function lv(n,e,t){const i=100-Math.abs(t*(200-e)/100-100);return[n,i!==0?e*t/i:0,t*(200-e)/(2*100)]}function me(n){return[n[0],n[1],n[2]]}function Yn(n,e){return[n[0],n[1],n[2],e]}const cv={hsl:{hsl:(n,e,t)=>[n,e,t],hsv:av,rgb:rv},hsv:{hsl:lv,hsv:(n,e,t)=>[n,e,t],rgb:Aa},rgb:{hsl:sv,hsv:ov,rgb:(n,e,t)=>[n,e,t]}};function _t(n,e){return[e==="float"?1:n==="rgb"?255:360,e==="float"?1:n==="rgb"?255:100,e==="float"?1:n==="rgb"?255:100]}function pv(n,e){return n===e?e:_a(n,e)}function Ma(n,e,t){var i;const s=_t(e,t);return[e==="rgb"?V(n[0],0,s[0]):pv(n[0],s[0]),V(n[1],0,s[1]),V(n[2],0,s[2]),V((i=n[3])!==null&&i!==void 0?i:1,0,1)]}function Br(n,e,t,i){const s=_t(e,t),r=_t(e,i);return n.map((o,a)=>o/s[a]*r[a])}function Oa(n,e,t){const i=Br(n,e.mode,e.type,"int"),s=cv[e.mode][t.mode](...i);return Br(s,t.mode,"int",t.type)}class w{static black(){return new w([0,0,0],"rgb")}constructor(e,t){this.type="int",this.mode=t,this.comps_=Ma(e,t,this.type)}getComponents(e){return Yn(Oa(me(this.comps_),{mode:this.mode,type:this.type},{mode:e??this.mode,type:this.type}),this.comps_[3])}toRgbaObject(){const e=this.getComponents("rgb");return{r:e[0],g:e[1],b:e[2],a:e[3]}}}const Te=m("colp");class uv{constructor(e,t){this.alphaViews_=null,this.element=e.createElement("div"),this.element.classList.add(Te()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(Te("hsv"));const s=e.createElement("div");s.classList.add(Te("sv")),this.svPaletteView_=t.svPaletteView,s.appendChild(this.svPaletteView_.element),i.appendChild(s);const r=e.createElement("div");r.classList.add(Te("h")),this.hPaletteView_=t.hPaletteView,r.appendChild(this.hPaletteView_.element),i.appendChild(r),this.element.appendChild(i);const o=e.createElement("div");if(o.classList.add(Te("rgb")),this.textsView_=t.textsView,o.appendChild(this.textsView_.element),this.element.appendChild(o),t.alphaViews){this.alphaViews_={palette:t.alphaViews.palette,text:t.alphaViews.text};const a=e.createElement("div");a.classList.add(Te("a"));const l=e.createElement("div");l.classList.add(Te("ap")),l.appendChild(this.alphaViews_.palette.element),a.appendChild(l);const c=e.createElement("div");c.classList.add(Te("at")),c.appendChild(this.alphaViews_.text.element),a.appendChild(c),this.element.appendChild(a)}}get allFocusableElements(){const e=[this.svPaletteView_.element,this.hPaletteView_.element,this.textsView_.modeSelectElement,...this.textsView_.inputViews.map(t=>t.inputElement)];return this.alphaViews_&&e.push(this.alphaViews_.palette.element,this.alphaViews_.text.inputElement),e}}function hv(n){return n==="int"?"int":n==="float"?"float":void 0}function As(n){return L(n,e=>({color:e.optional.object({alpha:e.optional.boolean,type:e.optional.custom(hv)}),expanded:e.optional.boolean,picker:e.optional.custom($a),readonly:e.optional.constant(!1)}))}function Je(n){return n?.1:1}function Ra(n){var e;return(e=n.color)===null||e===void 0?void 0:e.type}class Ms{constructor(e,t){this.type="float",this.mode=t,this.comps_=Ma(e,t,this.type)}getComponents(e){return Yn(Oa(me(this.comps_),{mode:this.mode,type:this.type},{mode:e??this.mode,type:this.type}),this.comps_[3])}toRgbaObject(){const e=this.getComponents("rgb");return{r:e[0],g:e[1],b:e[2],a:e[3]}}}const dv={int:(n,e)=>new w(n,e),float:(n,e)=>new Ms(n,e)};function Os(n,e,t){return dv[t](n,e)}function mv(n){return n.type==="float"}function vv(n){return n.type==="int"}function bv(n){const e=n.getComponents(),t=_t(n.mode,"int");return new w([Math.round(h(e[0],0,1,0,t[0])),Math.round(h(e[1],0,1,0,t[1])),Math.round(h(e[2],0,1,0,t[2])),e[3]],n.mode)}function fv(n){const e=n.getComponents(),t=_t(n.mode,"int");return new Ms([h(e[0],0,t[0],0,1),h(e[1],0,t[1],0,1),h(e[2],0,t[2],0,1),e[3]],n.mode)}function H(n,e){if(n.type===e)return n;if(vv(n)&&e==="float")return fv(n);if(mv(n)&&e==="int")return bv(n);throw K.shouldNeverHappen()}function wv(n,e){return n.alpha===e.alpha&&n.mode===e.mode&&n.notation===e.notation&&n.type===e.type}function ie(n,e){const t=n.match(/^(.+)%$/);return Math.min(t?parseFloat(t[1])*.01*e:parseFloat(n),e)}const _v={deg:n=>n,grad:n=>n*360/400,rad:n=>n*360/(2*Math.PI),turn:n=>n*360};function Da(n){const e=n.match(/^([0-9.]+?)(deg|grad|rad|turn)$/);if(!e)return parseFloat(n);const t=parseFloat(e[1]),i=e[2];return _v[i](t)}function Ba(n){const e=n.match(/^rgb\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[ie(e[1],255),ie(e[2],255),ie(e[3],255)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function gv(n){const e=Ba(n);return e?new w(e,"rgb"):null}function Na(n){const e=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(!e)return null;const t=[ie(e[1],255),ie(e[2],255),ie(e[3],255),ie(e[4],1)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function Cv(n){const e=Na(n);return e?new w(e,"rgb"):null}function Fa(n){const e=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(!e)return null;const t=[Da(e[1]),ie(e[2],100),ie(e[3],100)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function xv(n){const e=Fa(n);return e?new w(e,"hsl"):null}function ja(n){const e=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(!e)return null;const t=[Da(e[1]),ie(e[2],100),ie(e[3],100),ie(e[4],1)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function Pv(n){const e=ja(n);return e?new w(e,"hsl"):null}function Ia(n){const e=n.match(/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(e)return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)];const t=n.match(/^(?:#|0x)([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]:null}function yv(n){const e=Ia(n);return e?new w(e,"rgb"):null}function za(n){const e=n.match(/^#?([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(e)return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16),h(parseInt(e[4]+e[4],16),0,255,0,1)];const t=n.match(/^(?:#|0x)?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),h(parseInt(t[4],16),0,255,0,1)]:null}function Ev(n){const e=za(n);return e?new w(e,"rgb"):null}function Ka(n){const e=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(!e)return null;const t=[parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function Nr(n){return e=>{const t=Ka(e);return t?Os(t,"rgb",n):null}}function Ua(n){const e=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(!e)return null;const t=[parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]),parseFloat(e[4])];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function Fr(n){return e=>{const t=Ua(e);return t?Os(t,"rgb",n):null}}const kv=[{parser:Ia,result:{alpha:!1,mode:"rgb",notation:"hex"}},{parser:za,result:{alpha:!0,mode:"rgb",notation:"hex"}},{parser:Ba,result:{alpha:!1,mode:"rgb",notation:"func"}},{parser:Na,result:{alpha:!0,mode:"rgb",notation:"func"}},{parser:Fa,result:{alpha:!1,mode:"hsl",notation:"func"}},{parser:ja,result:{alpha:!0,mode:"hsl",notation:"func"}},{parser:Ka,result:{alpha:!1,mode:"rgb",notation:"object"}},{parser:Ua,result:{alpha:!0,mode:"rgb",notation:"object"}}];function Vv(n){return kv.reduce((e,{parser:t,result:i})=>e||(t(n)?i:null),null)}function Sv(n,e="int"){const t=Vv(n);return t?t.notation==="hex"&&e!=="float"?Object.assign(Object.assign({},t),{type:"int"}):t.notation==="func"?Object.assign(Object.assign({},t),{type:e}):null:null}function un(n){const e=[yv,Ev,gv,Cv,xv,Pv];n==="int"&&e.push(Nr("int"),Fr("int")),n==="float"&&e.push(Nr("float"),Fr("float"));const t=Hm(e);return i=>{const s=t(i);return s?H(s,n):null}}function Tv(n){const e=un("int");if(typeof n!="string")return w.black();const t=e(n);return t??w.black()}function Ha(n){const e=V(Math.floor(n),0,255).toString(16);return e.length===1?`0${e}`:e}function Rs(n,e="#"){const t=me(n.getComponents("rgb")).map(Ha).join("");return`${e}${t}`}function Ds(n,e="#"){const t=n.getComponents("rgb"),i=[t[0],t[1],t[2],t[3]*255].map(Ha).join("");return`${e}${i}`}function qa(n){const e=F(0),t=H(n,"int");return`rgb(${me(t.getComponents("rgb")).map(s=>e(s)).join(", ")})`}function _n(n){const e=F(2),t=F(0);return`rgba(${H(n,"int").getComponents("rgb").map((r,o)=>(o===3?e:t)(r)).join(", ")})`}function Lv(n){const e=[F(0),Ln,Ln],t=H(n,"int");return`hsl(${me(t.getComponents("hsl")).map((s,r)=>e[r](s)).join(", ")})`}function $v(n){const e=[F(0),Ln,Ln,F(2)];return`hsla(${H(n,"int").getComponents("hsl").map((s,r)=>e[r](s)).join(", ")})`}function Ga(n,e){const t=F(e==="float"?2:0),i=["r","g","b"],s=H(n,e);return`{${me(s.getComponents("rgb")).map((o,a)=>`${i[a]}: ${t(o)}`).join(", ")}}`}function Av(n){return e=>Ga(e,n)}function Wa(n,e){const t=F(2),i=F(e==="float"?2:0),s=["r","g","b","a"];return`{${H(n,e).getComponents("rgb").map((a,l)=>{const c=l===3?t:i;return`${s[l]}: ${c(a)}`}).join(", ")}}`}function Mv(n){return e=>Wa(e,n)}const Ov=[{format:{alpha:!1,mode:"rgb",notation:"hex",type:"int"},stringifier:Rs},{format:{alpha:!0,mode:"rgb",notation:"hex",type:"int"},stringifier:Ds},{format:{alpha:!1,mode:"rgb",notation:"func",type:"int"},stringifier:qa},{format:{alpha:!0,mode:"rgb",notation:"func",type:"int"},stringifier:_n},{format:{alpha:!1,mode:"hsl",notation:"func",type:"int"},stringifier:Lv},{format:{alpha:!0,mode:"hsl",notation:"func",type:"int"},stringifier:$v},...["int","float"].reduce((n,e)=>[...n,{format:{alpha:!1,mode:"rgb",notation:"object",type:e},stringifier:Av(e)},{format:{alpha:!0,mode:"rgb",notation:"object",type:e},stringifier:Mv(e)}],[])];function Ya(n){return Ov.reduce((e,t)=>e||(wv(t.format,n)?t.stringifier:null),null)}const Ot=m("apl");class Rv{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(Ot()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("div");i.classList.add(Ot("b")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(Ot("c")),i.appendChild(s),this.colorElem_=s;const r=e.createElement("div");r.classList.add(Ot("m")),this.element.appendChild(r),this.markerElem_=r;const o=e.createElement("div");o.classList.add(Ot("p")),this.markerElem_.appendChild(o),this.previewElem_=o,this.update_()}update_(){const e=this.value.rawValue,t=e.getComponents("rgb"),i=new w([t[0],t[1],t[2],0],"rgb"),s=new w([t[0],t[1],t[2],255],"rgb"),r=["to right",_n(i),_n(s)];this.colorElem_.style.background=`linear-gradient(${r.join(",")})`,this.previewElem_.style.backgroundColor=_n(e);const o=h(t[3],0,1,0,100);this.markerElem_.style.left=`${o}%`}onValueChange_(){this.update_()}}class Dv{constructor(e,t){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=t.value,this.viewProps=t.viewProps,this.view=new Rv(e,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Ee(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_(e,t){if(!e.point)return;const i=e.point.x/e.bounds.width,s=this.value.rawValue,[r,o,a]=s.getComponents("hsv");this.value.setRawValue(new w([r,o,a,i],"hsv"),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=N(Je(!0),le(e));if(t===0)return;const i=this.value.rawValue,[s,r,o,a]=i.getComponents("hsv");this.value.setRawValue(new w([s,r,o,a+t],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(e){N(Je(!0),le(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const lt=m("coltxt");function Bv(n){const e=n.createElement("select"),t=[{text:"RGB",value:"rgb"},{text:"HSL",value:"hsl"},{text:"HSV",value:"hsv"},{text:"HEX",value:"hex"}];return e.appendChild(t.reduce((i,s)=>{const r=n.createElement("option");return r.textContent=s.text,r.value=s.value,i.appendChild(r),i},n.createDocumentFragment())),e}class Nv{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(lt()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(lt("m")),this.modeElem_=Bv(e),this.modeElem_.classList.add(lt("ms")),i.appendChild(this.modeSelectElement),t.viewProps.bindDisabled(this.modeElem_);const s=e.createElement("div");s.classList.add(lt("mm")),s.appendChild(Kn(e,"dropdown")),i.appendChild(s),this.element.appendChild(i);const r=e.createElement("div");r.classList.add(lt("w")),this.element.appendChild(r),this.inputsElem_=r,this.inputViews_=t.inputViews,this.applyInputViews_(),se(t.mode,o=>{this.modeElem_.value=o})}get modeSelectElement(){return this.modeElem_}get inputViews(){return this.inputViews_}set inputViews(e){this.inputViews_=e,this.applyInputViews_()}applyInputViews_(){xa(this.inputsElem_);const e=this.element.ownerDocument;this.inputViews_.forEach(t=>{const i=e.createElement("div");i.classList.add(lt("c")),i.appendChild(t.element),this.inputsElem_.appendChild(i)})}}function Fv(n){return F(n==="float"?2:0)}function jv(n,e,t){const i=_t(n,e)[t];return new ln({min:0,max:i})}function Iv(n,e,t){return new pn(n,{arrayPosition:t===0?"fst":t===2?"lst":"mid",parser:e.parser,props:d.fromObject({formatter:Fv(e.colorType),keyScale:Je(!1),pointerScale:e.colorType==="float"?.01:1}),value:T(0,{constraint:jv(e.colorMode,e.colorType,t)}),viewProps:e.viewProps})}function zv(n,e){const t={colorMode:e.colorMode,colorType:e.colorType,parser:ae,viewProps:e.viewProps};return[0,1,2].map(i=>{const s=Iv(n,t,i);return st({primary:e.value,secondary:s.value,forward(r){return H(r,e.colorType).getComponents(e.colorMode)[i]},backward(r,o){const a=e.colorMode,c=H(r,e.colorType).getComponents(a);c[i]=o;const p=Os(Yn(me(c),c[3]),a,e.colorType);return H(p,"int")}}),s})}function Kv(n,e){const t=new Wn(n,{parser:un("int"),props:d.fromObject({formatter:Rs}),value:T(w.black()),viewProps:e.viewProps});return st({primary:e.value,secondary:t.value,forward:i=>new w(me(i.getComponents()),i.mode),backward:(i,s)=>new w(Yn(me(s.getComponents(i.mode)),i.getComponents()[3]),i.mode)}),[t]}function Uv(n){return n!=="hex"}class Hv{constructor(e,t){this.onModeSelectChange_=this.onModeSelectChange_.bind(this),this.colorType_=t.colorType,this.value=t.value,this.viewProps=t.viewProps,this.colorMode=T(this.value.rawValue.mode),this.ccs_=this.createComponentControllers_(e),this.view=new Nv(e,{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_(e){const t=this.colorMode.rawValue;return Uv(t)?zv(e,{colorMode:t,colorType:this.colorType_,value:this.value,viewProps:this.viewProps}):Kv(e,{value:this.value,viewProps:this.viewProps})}onModeSelectChange_(e){const t=e.currentTarget;this.colorMode.rawValue=t.value,this.ccs_=this.createComponentControllers_(this.view.element.ownerDocument),this.view.inputViews=this.ccs_.map(i=>i.view)}}const pi=m("hpl");class qv{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(pi()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("div");i.classList.add(pi("c")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(pi("m")),this.element.appendChild(s),this.markerElem_=s,this.update_()}update_(){const e=this.value.rawValue,[t]=e.getComponents("hsv");this.markerElem_.style.backgroundColor=qa(new w([t,100,100],"hsv"));const i=h(t,0,360,0,100);this.markerElem_.style.left=`${i}%`}onValueChange_(){this.update_()}}class Gv{constructor(e,t){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=t.value,this.viewProps=t.viewProps,this.view=new qv(e,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Ee(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_(e,t){if(!e.point)return;const i=h(V(e.point.x,0,e.bounds.width),0,e.bounds.width,0,360),s=this.value.rawValue,[,r,o,a]=s.getComponents("hsv");this.value.setRawValue(new w([i,r,o,a],"hsv"),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=N(Je(!1),le(e));if(t===0)return;const i=this.value.rawValue,[s,r,o,a]=i.getComponents("hsv");this.value.setRawValue(new w([s+t,r,o,a],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(e){N(Je(!1),le(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const ui=m("svp"),jr=64;class Wv{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(ui()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("canvas");i.height=jr,i.width=jr,i.classList.add(ui("c")),this.element.appendChild(i),this.canvasElement=i;const s=e.createElement("div");s.classList.add(ui("m")),this.element.appendChild(s),this.markerElem_=s,this.update_()}update_(){const e=sm(this.canvasElement);if(!e)return;const i=this.value.rawValue.getComponents("hsv"),s=this.canvasElement.width,r=this.canvasElement.height,o=e.getImageData(0,0,s,r),a=o.data;for(let p=0;pi.getComponents()[3],backward:(i,s)=>{const r=i.getComponents();return r[3]=s,new w(r,i.mode)}}),this.textsC_=new Hv(e,{colorType:t.colorType,value:this.value,viewProps:this.viewProps}),this.view=new uv(e,{alphaViews:this.alphaIcs_?{palette:this.alphaIcs_.palette.view,text:this.alphaIcs_.text.view}:null,hPaletteView:this.hPaletteC_.view,supportsAlpha:t.supportsAlpha,svPaletteView:this.svPaletteC_.view,textsView:this.textsC_.view,viewProps:this.viewProps})}get textsController(){return this.textsC_}}const hi=m("colsw");class Qv{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.element=e.createElement("div"),this.element.classList.add(hi()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(hi("sw")),this.element.appendChild(i),this.swatchElem_=i;const s=e.createElement("button");s.classList.add(hi("b")),t.viewProps.bindDisabled(s),this.element.appendChild(s),this.buttonElement=s,this.update_()}update_(){const e=this.value.rawValue;this.swatchElem_.style.backgroundColor=Ds(e)}onValueChange_(){this.update_()}}class Jv{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new Qv(e,{value:this.value,viewProps:this.viewProps})}}class Bs{constructor(e,t){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=t.value,this.viewProps=t.viewProps,this.foldable_=yt.create(t.expanded),this.swatchC_=new Jv(e,{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 Wn(e,{parser:t.parser,props:d.fromObject({formatter:t.formatter}),value:this.value,viewProps:this.viewProps}),this.view=new iv(e,{foldable:this.foldable_,pickerLayout:t.pickerLayout}),this.view.swatchElement.appendChild(this.swatchC_.view.element),this.view.textElement.appendChild(this.textC_.view.element),this.popC_=t.pickerLayout==="popup"?new Ts(e,{viewProps:this.viewProps}):null;const s=new Xv(e,{colorType:t.colorType,supportsAlpha:t.supportsAlpha,value:this.value,viewProps:this.viewProps});s.view.allFocusableElements.forEach(r=>{r.addEventListener("blur",this.onPopupChildBlur_),r.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=s,this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(s.view.element),st({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:r=>r,backward:(r,o)=>o})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),Hn(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onButtonBlur_(e){if(!this.popC_)return;const t=this.view.element,i=e.relatedTarget;(!i||!t.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_(e){if(!this.popC_)return;const t=this.popC_.view.element,i=xs(e);i&&t.contains(i)||i&&i===this.swatchC_.view.buttonElement&&!zn(t.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(e){this.popC_?e.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&e.key==="Escape"&&this.swatchC_.view.buttonElement.focus()}}function Zv(n){return me(n.getComponents("rgb")).reduce((e,t)=>e<<8|Math.floor(t)&255,0)}function eb(n){return n.getComponents("rgb").reduce((e,t,i)=>{const s=Math.floor(i===3?t*255:t)&255;return e<<8|s},0)>>>0}function tb(n){return new w([n>>16&255,n>>8&255,n&255],"rgb")}function nb(n){return new w([n>>24&255,n>>16&255,n>>8&255,h(n&255,0,255,0,1)],"rgb")}function ib(n){return typeof n!="number"?w.black():tb(n)}function sb(n){return typeof n!="number"?w.black():nb(n)}function gn(n,e){return typeof n!="object"||E(n)?!1:e in n&&typeof n[e]=="number"}function Xa(n){return gn(n,"r")&&gn(n,"g")&&gn(n,"b")}function Qa(n){return Xa(n)&&gn(n,"a")}function Ja(n){return Xa(n)}function Ns(n,e){if(n.mode!==e.mode||n.type!==e.type)return!1;const t=n.getComponents(),i=e.getComponents();for(let s=0;s{Ie(t,e(i))}:null}function ob(n){const e=n?eb:Zv;return(t,i)=>{Ie(t,e(i))}}function ab(n,e,t){const s=H(e,t).toRgbaObject();n.writeProperty("r",s.r),n.writeProperty("g",s.g),n.writeProperty("b",s.b),n.writeProperty("a",s.a)}function lb(n,e,t){const s=H(e,t).toRgbaObject();n.writeProperty("r",s.r),n.writeProperty("g",s.g),n.writeProperty("b",s.b)}function cb(n,e){return(t,i)=>{n?ab(t,i,e):lb(t,i,e)}}function pb(n){var e;return!!(!((e=n==null?void 0:n.color)===null||e===void 0)&&e.alpha)}function ub(n){return n?e=>Ds(e,"0x"):e=>Rs(e,"0x")}function hb(n){return"color"in n||n.view==="color"}A({id:"input-color-number",type:"input",accept:(n,e)=>{if(typeof n!="number"||!hb(e))return null;const t=As(e);return t?{initialValue:n,params:Object.assign(Object.assign({},t),{supportsAlpha:pb(e)})}:null},binding:{reader:n=>n.params.supportsAlpha?sb:ib,equals:Ns,writer:n=>ob(n.params.supportsAlpha)},controller:n=>{var e,t;return new Bs(n.document,{colorType:"int",expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:ub(n.params.supportsAlpha),parser:un("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:n.params.supportsAlpha,value:n.value,viewProps:n.viewProps})}});function db(n,e){if(!Ja(n))return H(w.black(),e);if(e==="int"){const t=Ir(n);return new w(t,"rgb")}if(e==="float"){const t=Ir(n);return new Ms(t,"rgb")}return H(w.black(),"int")}function mb(n){return Qa(n)}function vb(n){return e=>{const t=db(e,n);return H(t,"int")}}function bb(n,e){return t=>n?Wa(t,e):Ga(t,e)}A({id:"input-color-object",type:"input",accept:(n,e)=>{var t;if(!Ja(n))return null;const i=As(e);return i?{initialValue:n,params:Object.assign(Object.assign({},i),{colorType:(t=Ra(e))!==null&&t!==void 0?t:"int"})}:null},binding:{reader:n=>vb(n.params.colorType),equals:Ns,writer:n=>cb(mb(n.initialValue),n.params.colorType)},controller:n=>{var e,t;const i=Qa(n.initialValue);return new Bs(n.document,{colorType:n.params.colorType,expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:bb(i,n.params.colorType),parser:un("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:i,value:n.value,viewProps:n.viewProps})}});A({id:"input-color-string",type:"input",accept:(n,e)=>{if(typeof n!="string"||e.view==="text")return null;const t=Sv(n,Ra(e));if(!t)return null;const i=Ya(t);if(!i)return null;const s=As(e);return s?{initialValue:n,params:Object.assign(Object.assign({},s),{format:t,stringifier:i})}:null},binding:{reader:()=>Tv,equals:Ns,writer:n=>{const e=rb(n.params.format);if(!e)throw K.notBindable();return e}},controller:n=>{var e,t;return new Bs(n.document,{colorType:n.params.format.type,expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:n.params.stringifier,parser:un("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:n.params.format.alpha,value:n.value,viewProps:n.viewProps})}});class Xn{constructor(e){this.components=e.components,this.asm_=e.assembly}constrain(e){const t=this.asm_.toComponents(e).map((i,s)=>{var r,o;return(o=(r=this.components[s])===null||r===void 0?void 0:r.constrain(i))!==null&&o!==void 0?o:i});return this.asm_.fromComponents(t)}}const zr=m("pndtxt");class fb{constructor(e,t){this.textViews=t.textViews,this.element=e.createElement("div"),this.element.classList.add(zr()),this.textViews.forEach(i=>{const s=e.createElement("div");s.classList.add(zr("a")),s.appendChild(i.element),this.element.appendChild(s)})}}function wb(n,e,t){return new pn(n,{arrayPosition:t===0?"fst":t===e.axes.length-1?"lst":"mid",parser:e.parser,props:e.axes[t].textProps,value:T(0,{constraint:e.axes[t].constraint}),viewProps:e.viewProps})}class kt{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.acs_=t.axes.map((i,s)=>wb(e,t,s)),this.acs_.forEach((i,s)=>{st({primary:this.value,secondary:i.value,forward:r=>t.assembly.toComponents(r)[s],backward:(r,o)=>{const a=t.assembly.toComponents(r);return a[s]=o,t.assembly.fromComponents(a)}})}),this.view=new fb(e,{textViews:this.acs_.map(i=>i.view)})}get textControllers(){return this.acs_}}class _b extends gs{get max(){return this.controller.valueController.sliderController.props.get("max")}set max(e){this.controller.valueController.sliderController.props.set("max",e)}get min(){return this.controller.valueController.sliderController.props.get("min")}set min(e){this.controller.valueController.sliderController.props.set("min",e)}}function gb(n,e){const t=[],i=vs(n,e);i&&t.push(i);const s=bs(n);s&&t.push(s);const r=Ss(n.options);return r&&t.push(r),new Et(t)}A({id:"input-number",type:"input",accept:(n,e)=>{if(typeof n!="number")return null;const t=L(e,i=>Object.assign(Object.assign({},ws(i)),{options:i.optional.custom(Gn),readonly:i.optional.constant(!1)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>ms,constraint:n=>gb(n.params,n.initialValue),writer:n=>Ie},controller:n=>{const e=n.value,t=n.constraint,i=t&&Yt(t,qn);if(i)return new wt(n.document,{props:new d({options:i.values.value("options")}),value:e,viewProps:n.viewProps});const s=fs(n.params,e.rawValue),r=t&&Yt(t,ln);return r?new Dr(n.document,Object.assign(Object.assign({},Jm(Object.assign(Object.assign({},s),{keyScale:T(s.keyScale),max:r.values.value("max"),min:r.values.value("min")}))),{parser:ae,value:e,viewProps:n.viewProps})):new pn(n.document,{parser:ae,props:d.fromObject(s),value:e,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="number"?null:n.controller.valueController instanceof Dr?new _b(n.controller):n.controller.valueController instanceof wt?new Vs(n.controller):null}});class De{constructor(e=0,t=0){this.x=e,this.y=t}getComponents(){return[this.x,this.y]}static isObject(e){if(E(e))return!1;const t=e.x,i=e.y;return!(typeof t!="number"||typeof i!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y}toObject(){return{x:this.x,y:this.y}}}const Za={toComponents:n=>n.getComponents(),fromComponents:n=>new De(...n)},ct=m("p2d");class Cb{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(ct()),t.viewProps.bindClassModifiers(this.element),se(t.expanded,je(this.element,ct(void 0,"expanded")));const i=e.createElement("div");i.classList.add(ct("h")),this.element.appendChild(i);const s=e.createElement("button");s.classList.add(ct("b")),s.appendChild(Kn(e,"p2dpad")),t.viewProps.bindDisabled(s),i.appendChild(s),this.buttonElement=s;const r=e.createElement("div");if(r.classList.add(ct("t")),i.appendChild(r),this.textElement=r,t.pickerLayout==="inline"){const o=e.createElement("div");o.classList.add(ct("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}}const Le=m("p2dp");class xb{constructor(e,t){this.onFoldableChange_=this.onFoldableChange_.bind(this),this.onPropsChange_=this.onPropsChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onPropsChange_),this.element=e.createElement("div"),this.element.classList.add(Le()),t.layout==="popup"&&this.element.classList.add(Le(void 0,"p")),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(Le("p")),t.viewProps.bindTabIndex(i),this.element.appendChild(i),this.padElement=i;const s=e.createElementNS(B,"svg");s.classList.add(Le("g")),this.padElement.appendChild(s),this.svgElem_=s;const r=e.createElementNS(B,"line");r.classList.add(Le("ax")),r.setAttributeNS(null,"x1","0"),r.setAttributeNS(null,"y1","50%"),r.setAttributeNS(null,"x2","100%"),r.setAttributeNS(null,"y2","50%"),this.svgElem_.appendChild(r);const o=e.createElementNS(B,"line");o.classList.add(Le("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=e.createElementNS(B,"line");a.classList.add(Le("l")),a.setAttributeNS(null,"x1","50%"),a.setAttributeNS(null,"y1","50%"),this.svgElem_.appendChild(a),this.lineElem_=a;const l=e.createElement("div");l.classList.add(Le("m")),this.padElement.appendChild(l),this.markerElem_=l,t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.update_()}get allFocusableElements(){return[this.padElement]}update_(){const[e,t]=this.value.rawValue.getComponents(),i=this.props_.get("max"),s=h(e,-i,+i,0,100),r=h(t,-i,+i,0,100),o=this.props_.get("invertsY")?100-r:r;this.lineElem_.setAttributeNS(null,"x2",`${s}%`),this.lineElem_.setAttributeNS(null,"y2",`${o}%`),this.markerElem_.style.left=`${s}%`,this.markerElem_.style.top=`${o}%`}onValueChange_(){this.update_()}onPropsChange_(){this.update_()}onFoldableChange_(){this.update_()}}function Kr(n,e,t){return[N(e[0],le(n)),N(e[1],Qe(n))*(t?1:-1)]}class Pb{constructor(e,t){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=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new xb(e,{layout:t.layout,props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Ee(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_(e,t){if(!e.point)return;const i=this.props.get("max"),s=h(e.point.x,0,e.bounds.width,-i,+i),r=h(this.props.get("invertsY")?e.bounds.height-e.point.y:e.point.y,0,e.bounds.height,-i,+i);this.value.setRawValue(new De(s,r),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onPadKeyDown_(e){$n(e.key)&&e.preventDefault();const[t,i]=Kr(e,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));t===0&&i===0||this.value.setRawValue(new De(this.value.rawValue.x+t,this.value.rawValue.y+i),{forceEmit:!1,last:!1})}onPadKeyUp_(e){const[t,i]=Kr(e,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));t===0&&i===0||this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}class yb{constructor(e,t){var i,s;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=t.value,this.viewProps=t.viewProps,this.foldable_=yt.create(t.expanded),this.popC_=t.pickerLayout==="popup"?new Ts(e,{viewProps:this.viewProps}):null;const r=new Pb(e,{layout:t.pickerLayout,props:new d({invertsY:T(t.invertsY),max:T(t.max),xKeyScale:t.axes[0].textProps.value("keyScale"),yKeyScale:t.axes[1].textProps.value("keyScale")}),value:this.value,viewProps:this.viewProps});r.view.allFocusableElements.forEach(o=>{o.addEventListener("blur",this.onPopupChildBlur_),o.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=r,this.textC_=new kt(e,{assembly:Za,axes:t.axes,parser:t.parser,value:this.value,viewProps:this.viewProps}),this.view=new Cb(e,{expanded:this.foldable_.value("expanded"),pickerLayout:t.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_),(s=this.view.buttonElement)===null||s===void 0||s.addEventListener("click",this.onPadButtonClick_),this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(this.pickerC_.view.element),st({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),Hn(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onPadButtonBlur_(e){if(!this.popC_)return;const t=this.view.element,i=e.relatedTarget;(!i||!t.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_(e){if(!this.popC_)return;const t=this.popC_.view.element,i=xs(e);i&&t.contains(i)||i&&i===this.view.buttonElement&&!zn(t.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(e){this.popC_?e.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&e.key==="Escape"&&this.view.buttonElement.focus()}}function Eb(n){return De.isObject(n)?new De(n.x,n.y):new De}function kb(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y)}function Vb(n,e){return new Xn({assembly:Za,components:[_e(Object.assign(Object.assign({},n),n.x),e.x),_e(Object.assign(Object.assign({},n),n.y),e.y)]})}function Ur(n,e){var t,i;if(!E(n.min)||!E(n.max))return Math.max(Math.abs((t=n.min)!==null&&t!==void 0?t:0),Math.abs((i=n.max)!==null&&i!==void 0?i:0));const s=ga(n);return Math.max(Math.abs(s)*10,Math.abs(e)*10)}function Sb(n,e){var t,i;const s=Ur(Xe(n,(t=n.x)!==null&&t!==void 0?t:{}),e.x),r=Ur(Xe(n,(i=n.y)!==null&&i!==void 0?i:{}),e.y);return Math.max(s,r)}function Tb(n){if(!("y"in n))return!1;const e=n.y;return e&&"inverted"in e?!!e.inverted:!1}A({id:"input-point2d",type:"input",accept:(n,e)=>{if(!De.isObject(n))return null;const t=L(e,i=>Object.assign(Object.assign({},Xt(i)),{expanded:i.optional.boolean,picker:i.optional.custom($a),readonly:i.optional.constant(!1),x:i.optional.custom(Oe),y:i.optional.object(Object.assign(Object.assign({},Xt(i)),{inverted:i.optional.boolean}))}));return t?{initialValue:n,params:t}:null},binding:{reader:()=>Eb,constraint:n=>Vb(n.params,n.initialValue),equals:De.equals,writer:()=>kb},controller:n=>{var e,t;const i=n.document,s=n.value,r=n.constraint,o=[n.params.x,n.params.y];return new yb(i,{axes:s.rawValue.getComponents().map((a,l)=>{var c;return _s({constraint:r.components[l],initialValue:a,params:Xe(n.params,(c=o[l])!==null&&c!==void 0?c:{})})}),expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,invertsY:Tb(n.params),max:Sb(n.params,s.rawValue),parser:ae,pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",value:s,viewProps:n.viewProps})}});class vt{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}getComponents(){return[this.x,this.y,this.z]}static isObject(e){if(E(e))return!1;const t=e.x,i=e.y,s=e.z;return!(typeof t!="number"||typeof i!="number"||typeof s!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z}toObject(){return{x:this.x,y:this.y,z:this.z}}}const el={toComponents:n=>n.getComponents(),fromComponents:n=>new vt(...n)};function Lb(n){return vt.isObject(n)?new vt(n.x,n.y,n.z):new vt}function $b(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y),n.writeProperty("z",e.z)}function Ab(n,e){return new Xn({assembly:el,components:[_e(Object.assign(Object.assign({},n),n.x),e.x),_e(Object.assign(Object.assign({},n),n.y),e.y),_e(Object.assign(Object.assign({},n),n.z),e.z)]})}A({id:"input-point3d",type:"input",accept:(n,e)=>{if(!vt.isObject(n))return null;const t=L(e,i=>Object.assign(Object.assign({},Xt(i)),{readonly:i.optional.constant(!1),x:i.optional.custom(Oe),y:i.optional.custom(Oe),z:i.optional.custom(Oe)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>Lb,constraint:n=>Ab(n.params,n.initialValue),equals:vt.equals,writer:n=>$b},controller:n=>{const e=n.value,t=n.constraint,i=[n.params.x,n.params.y,n.params.z];return new kt(n.document,{assembly:el,axes:e.rawValue.getComponents().map((s,r)=>{var o;return _s({constraint:t.components[r],initialValue:s,params:Xe(n.params,(o=i[r])!==null&&o!==void 0?o:{})})}),parser:ae,value:e,viewProps:n.viewProps})}});class bt{constructor(e=0,t=0,i=0,s=0){this.x=e,this.y=t,this.z=i,this.w=s}getComponents(){return[this.x,this.y,this.z,this.w]}static isObject(e){if(E(e))return!1;const t=e.x,i=e.y,s=e.z,r=e.w;return!(typeof t!="number"||typeof i!="number"||typeof s!="number"||typeof r!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z&&e.w===t.w}toObject(){return{x:this.x,y:this.y,z:this.z,w:this.w}}}const tl={toComponents:n=>n.getComponents(),fromComponents:n=>new bt(...n)};function Mb(n){return bt.isObject(n)?new bt(n.x,n.y,n.z,n.w):new bt}function Ob(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y),n.writeProperty("z",e.z),n.writeProperty("w",e.w)}function Rb(n,e){return new Xn({assembly:tl,components:[_e(Object.assign(Object.assign({},n),n.x),e.x),_e(Object.assign(Object.assign({},n),n.y),e.y),_e(Object.assign(Object.assign({},n),n.z),e.z),_e(Object.assign(Object.assign({},n),n.w),e.w)]})}A({id:"input-point4d",type:"input",accept:(n,e)=>{if(!bt.isObject(n))return null;const t=L(e,i=>Object.assign(Object.assign({},Xt(i)),{readonly:i.optional.constant(!1),w:i.optional.custom(Oe),x:i.optional.custom(Oe),y:i.optional.custom(Oe),z:i.optional.custom(Oe)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>Mb,constraint:n=>Rb(n.params,n.initialValue),equals:bt.equals,writer:n=>Ob},controller:n=>{const e=n.value,t=n.constraint,i=[n.params.x,n.params.y,n.params.z,n.params.w];return new kt(n.document,{assembly:tl,axes:e.rawValue.getComponents().map((s,r)=>{var o;return _s({constraint:t.components[r],initialValue:s,params:Xe(n.params,(o=i[r])!==null&&o!==void 0?o:{})})}),parser:ae,value:e,viewProps:n.viewProps})}});function Db(n){const e=[],t=Ss(n.options);return t&&e.push(t),new Et(e)}A({id:"input-string",type:"input",accept:(n,e)=>{if(typeof n!="string")return null;const t=L(e,i=>({readonly:i.optional.constant(!1),options:i.optional.custom(Gn)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>$s,constraint:n=>Db(n.params),writer:n=>Ie},controller:n=>{const e=n.document,t=n.value,i=n.constraint,s=i&&Yt(i,qn);return s?new wt(e,{props:new d({options:s.values.value("options")}),value:t,viewProps:n.viewProps}):new Wn(e,{parser:r=>r,props:d.fromObject({formatter:$i}),value:t,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="string"?null:n.controller.valueController instanceof wt?new Vs(n.controller):null}});const hn={monitor:{defaultInterval:200,defaultRows:3}},Hr=m("mll");class Bb{constructor(e,t){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=t.formatter,this.element=e.createElement("div"),this.element.classList.add(Hr()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("textarea");i.classList.add(Hr("i")),i.style.height=`calc(var(${Ta("containerUnitSize")}) * ${t.rows})`,i.readOnly=!0,t.viewProps.bindDisabled(i),this.element.appendChild(i),this.textareaElem_=i,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}update_(){const e=this.textareaElem_,t=e.scrollTop===e.scrollHeight-e.clientHeight,i=[];this.value.rawValue.forEach(s=>{s!==void 0&&i.push(this.formatter_(s))}),e.textContent=i.join(` +`),t&&(e.scrollTop=e.scrollHeight)}onValueUpdate_(){this.update_()}}class Fs{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new Bb(e,{formatter:t.formatter,rows:t.rows,value:this.value,viewProps:this.viewProps})}}const qr=m("sgl");class Nb{constructor(e,t){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=t.formatter,this.element=e.createElement("div"),this.element.classList.add(qr()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("input");i.classList.add(qr("i")),i.readOnly=!0,i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}update_(){const e=this.value.rawValue,t=e[e.length-1];this.inputElement.value=t!==void 0?this.formatter_(t):""}onValueUpdate_(){this.update_()}}class js{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new Nb(e,{formatter:t.formatter,value:this.value,viewProps:this.viewProps})}}A({id:"monitor-bool",type:"monitor",accept:(n,e)=>{if(typeof n!="boolean")return null;const t=L(e,i=>({readonly:i.required.constant(!0),rows:i.optional.number}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>Ls},controller:n=>{var e;return n.value.rawValue.length===1?new js(n.document,{formatter:Rr,value:n.value,viewProps:n.viewProps}):new Fs(n.document,{formatter:Rr,rows:(e=n.params.rows)!==null&&e!==void 0?e:hn.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}});class Fb extends gs{get max(){return this.controller.valueController.props.get("max")}set max(e){this.controller.valueController.props.set("max",e)}get min(){return this.controller.valueController.props.get("min")}set min(e){this.controller.valueController.props.set("min",e)}}const $e=m("grl");class jb{constructor(e,t){this.onCursorChange_=this.onCursorChange_.bind(this),this.onValueUpdate_=this.onValueUpdate_.bind(this),this.element=e.createElement("div"),this.element.classList.add($e()),t.viewProps.bindClassModifiers(this.element),this.formatter_=t.formatter,this.props_=t.props,this.cursor_=t.cursor,this.cursor_.emitter.on("change",this.onCursorChange_);const i=e.createElementNS(B,"svg");i.classList.add($e("g")),i.style.height=`calc(var(${Ta("containerUnitSize")}) * ${t.rows})`,this.element.appendChild(i),this.svgElem_=i;const s=e.createElementNS(B,"polyline");this.svgElem_.appendChild(s),this.lineElem_=s;const r=e.createElement("div");r.classList.add($e("t"),m("tt")()),this.element.appendChild(r),this.tooltipElem_=r,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}get graphElement(){return this.svgElem_}update_(){const e=this.svgElem_.getBoundingClientRect(),t=this.value.rawValue.length-1,i=this.props_.get("min"),s=this.props_.get("max"),r=[];this.value.rawValue.forEach((p,u)=>{if(p===void 0)return;const b=h(u,0,t,0,e.width),O=h(p,i,s,e.height,0);r.push([b,O].join(","))}),this.lineElem_.setAttributeNS(null,"points",r.join(" "));const o=this.tooltipElem_,a=this.value.rawValue[this.cursor_.rawValue];if(a===void 0){o.classList.remove($e("t","a"));return}const l=h(this.cursor_.rawValue,0,t,0,e.width),c=h(a,i,s,e.height,0);o.style.left=`${l}px`,o.style.top=`${c}px`,o.textContent=`${this.formatter_(a)}`,o.classList.contains($e("t","a"))||(o.classList.add($e("t","a"),$e("t","in")),Sn(o),o.classList.remove($e("t","in")))}onValueUpdate_(){this.update_()}onCursorChange_(){this.update_()}}class Is{constructor(e,t){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=t.props,this.value=t.value,this.viewProps=t.viewProps,this.cursor_=T(-1),this.view=new jb(e,{cursor:this.cursor_,formatter:t.formatter,rows:t.rows,props:this.props,value:this.value,viewProps:this.viewProps}),!zn(e))this.view.element.addEventListener("mousemove",this.onGraphMouseMove_),this.view.element.addEventListener("mouseleave",this.onGraphMouseLeave_);else{const i=new Ee(this.view.element);i.emitter.on("down",this.onGraphPointerDown_),i.emitter.on("move",this.onGraphPointerMove_),i.emitter.on("up",this.onGraphPointerUp_)}}importProps(e){return ce(e,null,t=>({max:t.required.number,min:t.required.number}),t=>(this.props.set("max",t.max),this.props.set("min",t.min),!0))}exportProps(){return pe(null,{max:this.props.get("max"),min:this.props.get("min")})}onGraphMouseLeave_(){this.cursor_.rawValue=-1}onGraphMouseMove_(e){const t=this.view.element.getBoundingClientRect();this.cursor_.rawValue=Math.floor(h(e.offsetX,0,t.width,0,this.value.rawValue.length))}onGraphPointerDown_(e){this.onGraphPointerMove_(e)}onGraphPointerMove_(e){if(!e.data.point){this.cursor_.rawValue=-1;return}this.cursor_.rawValue=Math.floor(h(e.data.point.x,0,e.data.bounds.width,0,this.value.rawValue.length))}onGraphPointerUp_(){this.cursor_.rawValue=-1}}function Ai(n){return E(n.format)?F(2):n.format}function Ib(n){var e;return n.value.rawValue.length===1?new js(n.document,{formatter:Ai(n.params),value:n.value,viewProps:n.viewProps}):new Fs(n.document,{formatter:Ai(n.params),rows:(e=n.params.rows)!==null&&e!==void 0?e:hn.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}function zb(n){var e,t,i;return new Is(n.document,{formatter:Ai(n.params),rows:(e=n.params.rows)!==null&&e!==void 0?e:hn.monitor.defaultRows,props:d.fromObject({max:(t=n.params.max)!==null&&t!==void 0?t:100,min:(i=n.params.min)!==null&&i!==void 0?i:0}),value:n.value,viewProps:n.viewProps})}function Gr(n){return n.view==="graph"}A({id:"monitor-number",type:"monitor",accept:(n,e)=>{if(typeof n!="number")return null;const t=L(e,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 t?{initialValue:n,params:t}:null},binding:{defaultBufferSize:n=>Gr(n)?64:1,reader:n=>ms},controller:n=>Gr(n.params)?zb(n):Ib(n),api:n=>n.controller.valueController instanceof Is?new Fb(n.controller):null});A({id:"monitor-string",type:"monitor",accept:(n,e)=>{if(typeof n!="string")return null;const t=L(e,i=>({multiline:i.optional.boolean,readonly:i.required.constant(!0),rows:i.optional.number}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>$s},controller:n=>{var e;const t=n.value;return t.rawValue.length>1||n.params.multiline?new Fs(n.document,{formatter:$i,rows:(e=n.params.rows)!==null&&e!==void 0?e:hn.monitor.defaultRows,value:t,viewProps:n.viewProps}):new js(n.document,{formatter:$i,value:t,viewProps:n.viewProps})}});class nl{constructor(e){this.controller_=e}get disabled(){return this.controller_.viewProps.get("disabled")}set disabled(e){this.controller_.viewProps.set("disabled",e)}get title(){var e;return(e=this.controller_.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller_.props.set("title",e)}on(e,t){const i=t.bind(this);return this.controller_.emitter.on(e,()=>{i(new it(this))}),this}}class Kb extends it{constructor(e,t,i){super(e),this.cell=t,this.index=i}}class il extends nt{constructor(e){super(e),this.cellToApiMap_=new Map,this.emitter_=new z;const t=this.controller.valueController;t.cellControllers.forEach((i,s)=>{const r=new nl(i);this.cellToApiMap_.set(i,r),i.emitter.on("click",()=>{const o=s%t.size[0],a=Math.floor(s/t.size[0]);this.emitter_.emit("click",{event:new Kb(this,r,[o,a])})})})}cell(e,t){const i=this.controller.valueController,s=i.cellControllers[t*i.size[0]+e];return this.cellToApiMap_.get(s)}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s.event)}),this}}class sl{constructor(e,t){this.size=t.size;const[i,s]=this.size,r=[];for(let o=0;o{this.cellCs_.forEach(o=>{o.viewProps.set("disposed",!0)})}),this.view=new La(e,{viewProps:this.viewProps,viewName:"btngrid"}),this.view.element.style.gridTemplateColumns=`repeat(${i}, 1fr)`,this.cellCs_.forEach(o=>{this.view.element.appendChild(o.view.element)})}get cellControllers(){return this.cellCs_}}class Wr extends cn{constructor(e,t){const i=t.valueController,s=new Un(e,{blade:t.blade,props:t.labelProps,valueController:i});super({blade:t.blade,view:s.view,viewProps:i.viewProps}),this.valueController=i,this.labelController=s}}const Ub=A({id:"buttongrid",type:"blade",accept(n){const e=L(n,t=>({cells:t.required.function,size:t.required.array(t.required.number),view:t.required.constant("buttongrid"),label:t.optional.string}));return e?{params:e}:null},controller(n){return new Wr(n.document,{blade:n.blade,labelProps:d.fromObject({label:n.params.label}),valueController:new sl(n.document,{cellConfig:n.params.cells,size:n.params.size})})},api(n){return n.controller instanceof Wr?new il(n.controller):null}});class rl extends nt{get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get value(){return this.controller.valueController.value.rawValue}set value(e){this.controller.valueController.value.rawValue=e}on(e,t){const i=t.bind(this);return this.controller.valueController.value.emitter.on(e,s=>{i(new In(this,s.rawValue,s.options.last))}),this}}function te(n,e,t){return n*(1-t)+e*t}const Hb=20,qb=.001,di=100;function Gb(n,e){let t=.25,i=.5,s=-1;for(let r=0;rn.toObject(),fromComponents:n=>new Fe(...n)};function Wb(n){const e=F(2);return`cubic-bezier(${n.toObject().map(i=>e(i)).join(", ")})`}const Yr=[0,.5,.5,1];function Yb(n){const e=n.match(/^cubic-bezier\s*\(\s*([0-9.]+)\s*,\s*([0-9.]+)\s*,\s*([0-9.]+)\s*,\s*([0-9.]+)\s*\)$/);if(!e)return new Fe(...Yr);const t=[e[1],e[2],e[3],e[4]].reduce((i,s)=>{if(!i)return null;const r=Number(s);return isNaN(r)?null:[...i,r]},[]);return new Fe(...t??Yr)}const Ue=m("cbz");class ol{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Ue()),t.viewProps.bindClassModifiers(this.element),t.foldable.bindExpandedClass(this.element,Ue(void 0,"expanded")),re(t.foldable,"completed",je(this.element,Ue(void 0,"cpl")));const i=e.createElement("div");i.classList.add(Ue("h")),this.element.appendChild(i);const s=e.createElement("button");s.classList.add(Ue("b")),t.viewProps.bindDisabled(s);const r=e.createElementNS(B,"svg");r.innerHTML='',s.appendChild(r),i.appendChild(s),this.buttonElement=s;const o=e.createElement("div");if(o.classList.add(Ue("t")),i.appendChild(o),this.textElement=o,t.pickerLayout==="inline"){const a=e.createElement("div");a.classList.add(Ue("p")),this.element.appendChild(a),this.pickerElement=a}else this.pickerElement=null}}const mi=m("cbzp");class al{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(mi()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(mi("g")),this.element.appendChild(i),this.graphElement=i;const s=e.createElement("div");s.classList.add(mi("t")),this.element.appendChild(s),this.textElement=s}}function ll(n,e){const t=new MutationObserver(s=>{for(const r of s)r.type==="childList"&&r.addedNodes.forEach(o=>{o.contains(o)&&(e(),t.disconnect())})}),i=n.ownerDocument;t.observe(i.body,{attributes:!0,childList:!0,subtree:!0})}const Ae=m("cbzg");function Xb(n,e){return t=>e(n(t))}class cl{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Ae()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("div");i.classList.add(Ae("p")),this.element.appendChild(i),this.previewElement=i;const s=e.createElementNS(B,"svg");s.classList.add(Ae("g")),this.element.appendChild(s),this.svgElem_=s;const r=e.createElementNS(B,"path");r.classList.add(Ae("u")),this.svgElem_.appendChild(r),this.guideElem_=r;const o=e.createElementNS(B,"polyline");o.classList.add(Ae("l")),this.svgElem_.appendChild(o),this.lineElem_=o,this.handleElems_=[e.createElement("div"),e.createElement("div")],this.handleElems_.forEach(a=>{a.classList.add(Ae("h")),this.element.appendChild(a)}),this.vectorElems_=[e.createElementNS(B,"line"),e.createElementNS(B,"line")],this.vectorElems_.forEach(a=>{a.classList.add(Ae("v")),this.svgElem_.appendChild(a)}),this.value_=t.value,this.value_.emitter.on("change",this.onValueChange_.bind(this)),this.sel_=t.selection,this.handleElems_.forEach((a,l)=>{se(this.sel_,Xb(c=>c===l,je(a,Ae("h","sel"))))}),ll(this.element,()=>{this.refresh()})}getVertMargin_(e){return e*.25}valueToPosition(e,t){const{clientWidth:i,clientHeight:s}=this.element,r=this.getVertMargin_(s);return{x:h(e,0,1,0,i),y:h(t,0,1,s-r,r)}}positionToValue(e,t){const i=this.element.getBoundingClientRect(),s=i.width,r=i.height,o=this.getVertMargin_(r);return{x:V(h(e,0,s,0,1),0,1),y:h(t,r-o,o,0,1)}}refresh(){this.guideElem_.setAttributeNS(null,"d",[0,1].map(r=>{const o=this.valueToPosition(0,r),a=this.valueToPosition(1,r);return[`M ${o.x},${o.y}`,`L ${a.x},${a.y}`].join(" ")}).join(" "));const e=this.value_.rawValue,t=[];let i=0;for(;;){const r=this.valueToPosition(...e.curve(i));if(t.push([r.x,r.y].join(",")),i>=1)break;i=Math.min(i+.05,1)}this.lineElem_.setAttributeNS(null,"points",t.join(" "));const s=e.toObject();[0,1].forEach(r=>{const o=this.valueToPosition(r,r),a=this.valueToPosition(s[r*2],s[r*2+1]),l=this.vectorElems_[r];l.setAttributeNS(null,"x1",String(o.x)),l.setAttributeNS(null,"y1",String(o.y)),l.setAttributeNS(null,"x2",String(a.x)),l.setAttributeNS(null,"y2",String(a.y));const c=this.handleElems_[r];c.style.left=`${a.x}px`,c.style.top=`${a.y}px`})}onValueChange_(){this.refresh()}}const Xr=24,Qr=400,Jr=1e3,pt=m("cbzprv");class pl{constructor(e,t){this.stopped_=!0,this.startTime_=-1,this.onDispose_=this.onDispose_.bind(this),this.onTimer_=this.onTimer_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.element=e.createElement("div"),this.element.classList.add(pt()),t.viewProps.bindClassModifiers(this.element);const i=e.createElementNS(B,"svg");i.classList.add(pt("g")),this.element.appendChild(i),this.svgElem_=i;const s=e.createElementNS(B,"path");s.classList.add(pt("t")),this.svgElem_.appendChild(s),this.ticksElem_=s;const r=e.createElement("div");r.classList.add(pt("m")),this.element.appendChild(r),this.markerElem_=r,this.value_=t.value,this.value_.emitter.on("change",this.onValueChange_),t.viewProps.handleDispose(this.onDispose_),ll(this.element,()=>{this.refresh()})}play(){this.stop(),this.updateMarker_(0),this.markerElem_.classList.add(pt("m","a")),this.startTime_=new Date().getTime()+Qr,this.stopped_=!1,requestAnimationFrame(this.onTimer_)}stop(){this.stopped_=!0,this.markerElem_.classList.remove(pt("m","a"))}onDispose_(){this.stop()}updateMarker_(e){const t=this.value_.rawValue.y(V(e,0,1));this.markerElem_.style.left=`${t*100}%`}refresh(){const{clientWidth:e,clientHeight:t}=this.svgElem_,i=[],s=this.value_.rawValue;for(let r=0;rJr+Qr&&this.stop(),this.stopped_||requestAnimationFrame(this.onTimer_)}onValueChange_(){this.refresh(),this.play()}}function Mi(n,e,t,i){const s=t-n,r=i-e;return Math.sqrt(s*s+r*r)}function Qb(n,e,t,i){const s=Mi(n,e,t,i),r=Math.atan2(i-e,t-n),o=Math.round(r/(Math.PI/4))*Math.PI/4;return{x:n+Math.cos(o)*s,y:e+Math.sin(o)*s}}class ul{constructor(e,t){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.keyScale_=t.keyScale,this.value=t.value,this.sel_=T(0),this.viewProps=t.viewProps,this.view=new cl(e,{selection:this.sel_,value:this.value,viewProps:this.viewProps}),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_),this.prevView_=new pl(e,{value:this.value,viewProps:this.viewProps}),this.prevView_.element.addEventListener("mousedown",s=>{s.stopImmediatePropagation(),s.preventDefault(),this.prevView_.play()}),this.view.previewElement.appendChild(this.prevView_.element);const i=new Ee(this.view.element);i.emitter.on("down",this.onPointerDown_),i.emitter.on("move",this.onPointerMove_),i.emitter.on("up",this.onPointerUp_)}refresh(){this.view.refresh(),this.prevView_.refresh(),this.prevView_.play()}updateValue_(e,t,i){const s=this.sel_.rawValue,r=this.value.rawValue.toObject(),o=this.view.positionToValue(e.x,e.y),a=t?Qb(s,s,o.x,o.y):o;r[s*2]=a.x,r[s*2+1]=a.y,this.value.setRawValue(new Fe(...r),i)}onPointerDown_(e){const t=e.data;if(!t.point)return;const i=this.value.rawValue,s=this.view.valueToPosition(i.x1,i.y1),r=Mi(t.point.x,t.point.y,s.x,s.y),o=this.view.valueToPosition(i.x2,i.y2),a=Mi(t.point.x,t.point.y,o.x,o.y);this.sel_.rawValue=r<=a?0:1,this.updateValue_(t.point,e.shiftKey,{forceEmit:!1,last:!1})}onPointerMove_(e){const t=e.data;t.point&&this.updateValue_(t.point,e.shiftKey,{forceEmit:!1,last:!1})}onPointerUp_(e){const t=e.data;t.point&&this.updateValue_(t.point,e.shiftKey,{forceEmit:!0,last:!0})}onKeyDown_(e){$n(e.key)&&e.preventDefault();const t=this.sel_.rawValue,i=this.value.rawValue.toObject(),s=this.keyScale_.rawValue;i[t*2]+=N(s,le(e)),i[t*2+1]+=N(s,Qe(e)),this.value.setRawValue(new Fe(...i),{forceEmit:!1,last:!1})}onKeyUp_(e){$n(e.key)&&e.preventDefault();const t=this.keyScale_.rawValue,i=N(t,le(e)),s=N(t,Qe(e));i===0&&s===0||this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}class hl{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new al(e,{viewProps:this.viewProps}),this.gc_=new ul(e,{keyScale:t.axis.textProps.value("keyScale"),value:this.value,viewProps:this.viewProps}),this.view.graphElement.appendChild(this.gc_.view.element);const i=Object.assign(Object.assign({},t.axis),{constraint:new us({max:1,min:0})}),s=Object.assign(Object.assign({},t.axis),{constraint:void 0});this.tc_=new kt(e,{assembly:zs,axes:[i,s,i,s],parser:ae,value:this.value,viewProps:this.viewProps}),this.view.textElement.appendChild(this.tc_.view.element)}get allFocusableElements(){return[this.gc_.view.element,...this.tc_.view.textViews.map(e=>e.inputElement)]}refresh(){this.gc_.refresh()}}class Oi{constructor(e,t){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=t.value,this.viewProps=t.viewProps,this.foldable_=yt.create(t.expanded),this.view=new ol(e,{foldable:this.foldable_,pickerLayout:t.pickerLayout,viewProps:this.viewProps}),this.view.buttonElement.addEventListener("blur",this.onButtonBlur_),this.view.buttonElement.addEventListener("click",this.onButtonClick_),this.tc_=new Wn(e,{parser:Yb,props:d.fromObject({formatter:Wb}),value:this.value,viewProps:this.viewProps}),this.view.textElement.appendChild(this.tc_.view.element),this.popC_=t.pickerLayout==="popup"?new Ts(e,{viewProps:this.viewProps}):null;const i=new hl(e,{axis:t.axis,value:this.value,viewProps:this.viewProps});i.allFocusableElements.forEach(s=>{s.addEventListener("blur",this.onPopupChildBlur_),s.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=i,this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(this.pickerC_.view.element),se(this.popC_.shows,s=>{s&&i.refresh()}),st({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:s=>s,backward:(s,r)=>r})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),Hn(this.foldable_,this.view.pickerElement))}onButtonBlur_(e){if(!this.popC_)return;const t=e.relatedTarget;(!t||!this.popC_.view.element.contains(t))&&(this.popC_.shows.rawValue=!1)}onButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.allFocusableElements[0].focus()}onPopupChildBlur_(e){if(!this.popC_)return;const t=this.popC_.view.element,i=xs(e);i&&t.contains(i)||i&&i===this.view.buttonElement&&!zn(t.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(e){this.popC_&&e.key==="Escape"&&(this.popC_.shows.rawValue=!1)}}function Jb(){return new Xn({assembly:zs,components:[0,1,2,3].map(n=>n%2===0?new us({min:0,max:1}):void 0)})}const Zb=A({id:"cubicbezier",type:"blade",accept(n){const e=L(n,t=>({value:t.required.array(t.required.number),view:t.required.constant("cubicbezier"),expanded:t.optional.boolean,label:t.optional.string,picker:t.optional.custom(i=>i==="inline"||i==="popup"?i:void 0)}));return e?{params:e}:null},controller(n){var e,t;const i=new Fe(...n.params.value),s=T(i,{constraint:Jb(),equals:Fe.equals}),r=new Oi(n.document,{axis:{textProps:d.fromObject({keyScale:.1,pointerScale:.01,formatter:F(2)})},expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",value:s,viewProps:n.viewProps});return new Tn(n.document,{blade:n.blade,props:d.fromObject({label:n.params.label}),value:s,valueController:r})},api(n){return!(n.controller instanceof Tn)||!(n.controller.valueController instanceof Oi)?null:new rl(n.controller)}});class dl extends nt{get fps(){return this.controller.valueController.fps}get max(){return this.controller.valueController.props.get("max")}set max(e){this.controller.valueController.props.set("max",e)}get min(){return this.controller.valueController.props.get("min")}set min(e){this.controller.valueController.props.set("min",e)}begin(){this.controller.valueController.begin()}end(){this.controller.valueController.end()}on(e,t){const i=t.bind(this);return this.controller.valueController.ticker.emitter.on(e,()=>{i(new it(this))}),this}}const Zr=20;class ml{constructor(){this.start_=null,this.duration_=0,this.fps_=null,this.frameCount_=0,this.timestamps_=[]}get duration(){return this.duration_}get fps(){return this.fps_}begin(e){this.start_=e.getTime()}calculateFps_(e){if(this.timestamps_.length===0)return null;const t=this.timestamps_[0];return 1e3*(this.frameCount_-t.frameCount)/(e-t.time)}compactTimestamps_(){if(this.timestamps_.length<=Zr)return;const e=this.timestamps_.length-Zr;this.timestamps_.splice(0,e);const t=this.timestamps_[0].frameCount;this.timestamps_.forEach(i=>{i.frameCount-=t}),this.frameCount_-=t}end(e){if(this.start_===null)return;const t=e.getTime();this.duration_=t-this.start_,this.start_=null,this.fps_=this.calculateFps_(t),this.timestamps_.push({frameCount:this.frameCount_,time:t}),++this.frameCount_,this.compactTimestamps_()}}const Rt=m("fps");class vl{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Rt()),t.viewProps.bindClassModifiers(this.element),this.graphElement=e.createElement("div"),this.graphElement.classList.add(Rt("g")),this.element.appendChild(this.graphElement);const i=e.createElement("div");i.classList.add(Rt("l")),this.element.appendChild(i);const s=e.createElement("span");s.classList.add(Rt("v")),s.textContent="--",i.appendChild(s),this.valueElement=s;const r=e.createElement("span");r.classList.add(Rt("u")),r.textContent="FPS",i.appendChild(r)}}class bl{constructor(e,t){this.stopwatch_=new ml,this.onTick_=this.onTick_.bind(this),this.ticker=t.ticker,this.ticker.emitter.on("tick",this.onTick_),this.props=t.props,this.value_=t.value,this.viewProps=t.viewProps,this.view=new vl(e,{viewProps:this.viewProps}),this.graphC_=new Is(e,{formatter:F(0),props:this.props,rows:t.rows,value:this.value_,viewProps:this.viewProps}),this.view.graphElement.appendChild(this.graphC_.view.element),this.viewProps.handleDispose(()=>{this.graphC_.viewProps.set("disposed",!0),this.ticker.dispose()})}get fps(){return this.stopwatch_.fps}begin(){this.stopwatch_.begin(new Date)}end(){this.stopwatch_.end(new Date)}onTick_(){const e=this.fps;if(e!==null){const t=this.value_.rawValue;this.value_.rawValue=hm(t,e),this.view.valueElement.textContent=e.toFixed(0)}}}class eo extends cn{constructor(e,t){const i=t.valueController,s=new Un(e,{blade:t.blade,props:t.labelProps,valueController:i});super({blade:t.blade,view:s.view,viewProps:i.viewProps}),this.valueController=i,this.labelController=s}}function ef(n,e){return e===0?new Fm:new jm(n,e??hn.monitor.defaultInterval)}const tf=A({id:"fpsgraph",type:"blade",accept(n){const e=L(n,t=>({view:t.required.constant("fpsgraph"),interval:t.optional.number,label:t.optional.string,rows:t.optional.number,max:t.optional.number,min:t.optional.number}));return e?{params:e}:null},controller(n){var e,t,i,s;const r=(e=n.params.interval)!==null&&e!==void 0?e:500;return new eo(n.document,{blade:n.blade,labelProps:d.fromObject({label:n.params.label}),valueController:new bl(n.document,{props:d.fromObject({max:(t=n.params.max)!==null&&t!==void 0?t:90,min:(i=n.params.min)!==null&&i!==void 0?i:0}),rows:(s=n.params.rows)!==null&&s!==void 0?s:2,ticker:ef(n.document,r),value:T(pm(80)),viewProps:n.viewProps})})},api(n){return n.controller instanceof eo?new dl(n.controller):null}});class Y{constructor(e,t){this.min=e,this.max=t}static isObject(e){if(typeof e!="object"||e===null)return!1;const t=e.min,i=e.max;return!(typeof t!="number"||typeof i!="number")}static equals(e,t){return e.min===t.min&&e.max===t.max}get length(){return this.max-this.min}toObject(){return{min:this.min,max:this.max}}}const Ks={fromComponents:n=>new Y(n[0],n[1]),toComponents:n=>[n.min,n.max]};class Us{constructor(e){this.edge=e}constrain(e){var t,i,s,r,o,a,l,c;if(e.min<=e.max)return new Y((i=(t=this.edge)===null||t===void 0?void 0:t.constrain(e.min))!==null&&i!==void 0?i:e.min,(r=(s=this.edge)===null||s===void 0?void 0:s.constrain(e.max))!==null&&r!==void 0?r:e.max);const p=(e.min+e.max)/2;return new Y((a=(o=this.edge)===null||o===void 0?void 0:o.constrain(p))!==null&&a!==void 0?a:p,(c=(l=this.edge)===null||l===void 0?void 0:l.constrain(p))!==null&&c!==void 0?c:p)}}const vi=m("rsltxt");class fl{constructor(e,t){this.sliderView_=t.sliderView,this.textView_=t.textView,this.element=e.createElement("div"),this.element.classList.add(vi());const i=e.createElement("div");i.classList.add(vi("s")),i.appendChild(this.sliderView_.element),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(vi("t")),s.appendChild(this.textView_.element),this.element.appendChild(s)}}const He=m("rsl");class wl{constructor(e,t){this.onSliderPropsChange_=this.onSliderPropsChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.sliderProps_=t.sliderProps,this.sliderProps_.emitter.on("change",this.onSliderPropsChange_),this.element=e.createElement("div"),this.element.classList.add(He()),t.viewProps.bindClassModifiers(this.element),this.value_=t.value,this.value_.emitter.on("change",this.onValueChange_);const i=e.createElement("div");i.classList.add(He("t")),this.element.appendChild(i),this.trackElement=i;const s=e.createElement("div");s.classList.add(He("b")),i.appendChild(s),this.barElement=s;const r=["min","max"].map(o=>{const a=e.createElement("div");return a.classList.add(He("k"),He("k",o)),i.appendChild(a),a});this.knobElements=[r[0],r[1]],this.update_()}valueToX_(e){const t=this.sliderProps_.get("min"),i=this.sliderProps_.get("max");return V(h(e,t,i,0,1),0,1)*100}update_(){const e=this.value_.rawValue;e.length===0?this.element.classList.add(He(void 0,"zero")):this.element.classList.remove(He(void 0,"zero"));const t=[this.valueToX_(e.min),this.valueToX_(e.max)];this.barElement.style.left=`${t[0]}%`,this.barElement.style.right=`${100-t[1]}%`,this.knobElements.forEach((i,s)=>{i.style.left=`${t[s]}%`})}onSliderPropsChange_(){this.update_()}onValueChange_(){this.update_()}}class _l{constructor(e,t){this.grabbing_=null,this.grabOffset_=0,this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.sliderProps=t.sliderProps,this.viewProps=t.viewProps,this.value=t.value,this.view=new wl(e,{sliderProps:this.sliderProps,value:this.value,viewProps:t.viewProps});const i=new Ee(this.view.trackElement);i.emitter.on("down",this.onPointerDown_),i.emitter.on("move",this.onPointerMove_),i.emitter.on("up",this.onPointerUp_)}ofs_(){return this.grabbing_==="min"?this.view.knobElements[0].getBoundingClientRect().width/2:this.grabbing_==="max"?-this.view.knobElements[1].getBoundingClientRect().width/2:0}valueFromData_(e){if(!e.point)return null;const t=(e.point.x+this.ofs_())/e.bounds.width,i=this.sliderProps.get("min"),s=this.sliderProps.get("max");return h(t,0,1,i,s)}onPointerDown_(e){if(!e.data.point)return;const t=e.data.point.x/e.data.bounds.width,i=this.value.rawValue,s=this.sliderProps.get("min"),r=this.sliderProps.get("max"),o=h(i.min,s,r,0,1),a=h(i.max,s,r,0,1);Math.abs(a-t)<=.025?this.grabbing_="max":Math.abs(o-t)<=.025?this.grabbing_="min":t>=o&&t<=a?(this.grabbing_="length",this.grabOffset_=h(t-o,0,1,0,r-s)):ta&&(this.grabbing_="max",this.onPointerMove_(e))}applyPointToValue_(e,t){const i=this.valueFromData_(e);if(i===null)return;const s=this.sliderProps.get("min"),r=this.sliderProps.get("max");if(this.grabbing_==="min")this.value.setRawValue(new Y(i,this.value.rawValue.max),t);else if(this.grabbing_==="max")this.value.setRawValue(new Y(this.value.rawValue.min,i),t);else if(this.grabbing_==="length"){const o=this.value.rawValue.length;let a=i-this.grabOffset_,l=a+o;ar&&(a=r-o,l=r),this.value.setRawValue(new Y(a,l),t)}}onPointerMove_(e){this.applyPointToValue_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.applyPointToValue_(e.data,{forceEmit:!0,last:!0}),this.grabbing_=null}}class gl{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.sc_=new _l(e,t);const i={constraint:t.constraint,textProps:t.textProps};this.tc_=new kt(e,{assembly:Ks,axes:[i,i],parser:t.parser,value:this.value,viewProps:t.viewProps}),this.view=new fl(e,{sliderView:this.sc_.view,textView:this.tc_.view})}get textController(){return this.tc_}}function nf(n){return Y.isObject(n)?new Y(n.min,n.max):new Y(0,0)}function sf(n,e){n.writeProperty("max",e.max),n.writeProperty("min",e.min)}function rf(n){const e=[],t=bs(n);t&&e.push(t);const i=vs(n);return i&&e.push(i),new Us(new Et(e))}const of=A({id:"input-interval",type:"input",accept:(n,e)=>{if(!Y.isObject(n))return null;const t=L(e,i=>Object.assign(Object.assign({},ws(i)),{readonly:i.optional.constant(!1)}));return t?{initialValue:new Y(n.min,n.max),params:t}:null},binding:{reader:n=>nf,constraint:n=>rf(n.params),equals:Y.equals,writer:n=>sf},controller(n){const e=n.value,t=n.constraint;if(!(t instanceof Us))throw K.shouldNeverHappen();const i=(e.rawValue.min+e.rawValue.max)/2,s=d.fromObject(fs(n.params,i)),r=t.edge&&Yt(t.edge,ln);if(r)return new gl(n.document,{constraint:t.edge,parser:ae,sliderProps:new d({keyScale:s.value("keyScale"),max:r.values.value("max"),min:r.values.value("min")}),textProps:s,value:e,viewProps:n.viewProps});const o={constraint:t.edge,textProps:s};return new kt(n.document,{assembly:Ks,axes:[o,o],parser:ae,value:e,viewProps:n.viewProps})}});class Cl{constructor(e){this.controller_=e}get disabled(){return this.controller_.viewProps.get("disabled")}set disabled(e){this.controller_.viewProps.set("disabled",e)}get title(){var e;return(e=this.controller_.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller_.props.set("title",e)}}class xl extends In{constructor(e,t,i,s,r){super(e,s,r),this.cell=t,this.index=i}}class Pl extends nt{constructor(e){super(e),this.cellToApiMap_=new Map,this.controller.valueController.cellControllers.forEach(i=>{const s=new Cl(i);this.cellToApiMap_.set(i,s)})}get value(){return this.controller.value}cell(e,t){const i=this.controller.valueController,s=i.cellControllers[t*i.size[0]+e];return this.cellToApiMap_.get(s)}on(e,t){const i=t.bind(this);this.controller.value.emitter.on(e,s=>{const r=this.controller.valueController,o=r.findCellByValue(s.rawValue);if(!o)return;const a=this.cellToApiMap_.get(o);if(!a)return;const l=r.cellControllers.indexOf(o);i(new xl(this,a,[l%r.size[0],Math.floor(l/r.size[0])],s.rawValue))})}}const Dt=m("rad");class yl{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Dt()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("label");i.classList.add(Dt("l")),this.element.appendChild(i);const s=e.createElement("input");s.classList.add(Dt("i")),s.name=t.name,s.type="radio",t.viewProps.bindDisabled(s),i.appendChild(s),this.inputElement=s;const r=e.createElement("div");r.classList.add(Dt("b")),i.appendChild(r);const o=e.createElement("div");o.classList.add(Dt("t")),r.appendChild(o),re(t.props,"title",a=>{o.textContent=a})}}class El{constructor(e,t){this.props=t.props,this.viewProps=t.viewProps,this.view=new yl(e,{name:t.name,props:this.props,viewProps:this.viewProps})}}class An{constructor(e,t){this.cellCs_=[],this.cellValues_=[],this.onCellInputChange_=this.onCellInputChange_.bind(this),this.size=t.size;const[i,s]=this.size;for(let r=0;r{const o=this.findCellByValue(r);o&&(o.view.inputElement.checked=!0)}),this.viewProps=Pe.create(),this.view=new La(e,{viewProps:this.viewProps,viewName:"radgrid"}),this.view.element.style.gridTemplateColumns=`repeat(${i}, 1fr)`,this.cellCs_.forEach(r=>{r.view.inputElement.addEventListener("change",this.onCellInputChange_),this.view.element.appendChild(r.view.element)})}get cellControllers(){return this.cellCs_}findCellByValue(e){const t=this.cellValues_.findIndex(i=>i===e);return t<0?null:this.cellCs_[t]}onCellInputChange_(e){const t=e.currentTarget,i=this.cellCs_.findIndex(s=>s.view.inputElement===t);i<0||(this.value.rawValue=this.cellValues_[i])}}const af=function(){return A({id:"radiogrid",type:"blade",accept(n){const e=L(n,t=>({cells:t.required.function,groupName:t.required.string,size:t.required.array(t.required.number),value:t.required.raw,view:t.required.constant("radiogrid"),label:t.optional.string}));return e?{params:e}:null},controller(n){const e=T(n.params.value);return new Tn(n.document,{blade:n.blade,props:d.fromObject({label:n.params.label}),value:e,valueController:new An(n.document,{groupName:n.params.groupName,cellConfig:n.params.cells,size:n.params.size,value:e})})},api(n){return!(n.controller instanceof Tn)||!(n.controller.valueController instanceof An)?null:new Pl(n.controller)}})}();function Hs(n){return A({id:"input-radiogrid",type:"input",accept(e,t){if(!n.isType(e))return null;const i=L(t,s=>({cells:s.required.function,groupName:s.required.string,size:s.required.array(s.required.number),view:s.required.constant("radiogrid")}));return i?{initialValue:e,params:i}:null},binding:n.binding,controller:e=>new An(e.document,{cellConfig:e.params.cells,groupName:e.params.groupName,size:e.params.size,value:e.value})})}const lf=Hs({isType:n=>typeof n=="number",binding:{reader:n=>ms,writer:n=>Ie}}),cf=Hs({isType:n=>typeof n=="string",binding:{reader:n=>$s,writer:n=>Ie}}),pf=Hs({isType:n=>typeof n=="boolean",binding:{reader:n=>Ls,writer:n=>Ie}}),uf="essentials",hf='.tp-cbzgv,.tp-radv_b,.tp-rslv_k,.tp-cbzv_b{-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-radv_b,.tp-rslv_k,.tp-cbzv_b{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-radv_b:hover,.tp-rslv_k:hover,.tp-cbzv_b:hover{background-color:var(--btn-bg-h)}.tp-radv_b:focus,.tp-rslv_k:focus,.tp-cbzv_b:focus{background-color:var(--btn-bg-f)}.tp-radv_b:active,.tp-rslv_k:active,.tp-cbzv_b:active{background-color:var(--btn-bg-a)}.tp-radv_b:disabled,.tp-rslv_k:disabled,.tp-cbzv_b:disabled{opacity:.5}.tp-cbzgv{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-cbzgv:hover{background-color:var(--in-bg-h)}.tp-cbzgv:focus{background-color:var(--in-bg-f)}.tp-cbzgv:active{background-color:var(--in-bg-a)}.tp-cbzgv:disabled{opacity:.5}.tp-btngridv{border-radius:var(--bld-br);display:grid;overflow:hidden;gap:2px}.tp-btngridv.tp-v-disabled{opacity:.5}.tp-btngridv .tp-btnv_b:disabled{opacity:1}.tp-btngridv .tp-btnv_b:disabled .tp-btnv_t{opacity:.5}.tp-btngridv .tp-btnv_b{border-radius:0}.tp-cbzv{position:relative}.tp-cbzv_h{display:flex}.tp-cbzv_b{margin-right:4px;position:relative;width:var(--cnt-usz)}.tp-cbzv_b svg{display:block;height:16px;left:50%;margin-left:-8px;margin-top:-8px;position:absolute;top:50%;width:16px}.tp-cbzv_b svg path{stroke:var(--bs-bg);stroke-width:2}.tp-cbzv_t{flex:1}.tp-cbzv_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-cbzv.tp-cbzv-expanded .tp-cbzv_p{margin-top:var(--cnt-usp);opacity:1}.tp-cbzv.tp-cbzv-cpl .tp-cbzv_p{overflow:visible}.tp-cbzv .tp-popv{left:calc(-1 * var(--cnt-hp));position:absolute;right:calc(-1 * var(--cnt-hp));top:var(--cnt-usz)}.tp-cbzpv_t{margin-top:var(--cnt-usp)}.tp-cbzgv{height:auto;overflow:hidden;position:relative}.tp-cbzgv.tp-v-disabled{opacity:.5}.tp-cbzgv_p{left:16px;position:absolute;right:16px;top:0}.tp-cbzgv_g{cursor:pointer;display:block;height:calc(var(--cnt-usz) * 5);width:100%}.tp-cbzgv_u{opacity:.1;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_l{fill:rgba(0,0,0,0);stroke:var(--in-fg)}.tp-cbzgv_v{opacity:.5;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_h{border:var(--in-fg) solid 1px;border-radius:50%;box-sizing:border-box;height:4px;margin-left:-2px;margin-top:-2px;pointer-events:none;position:absolute;width:4px}.tp-cbzgv:focus .tp-cbzgv_h-sel{background-color:var(--in-fg);border-width:0}.tp-cbzprvv{cursor:pointer;height:4px;padding:4px 0;position:relative}.tp-cbzprvv_g{display:block;height:100%;overflow:visible;width:100%}.tp-cbzprvv_t{opacity:.5;stroke:var(--mo-fg)}.tp-cbzprvv_m{background-color:var(--mo-fg);border-radius:50%;height:4px;margin-left:-2px;margin-top:-2px;opacity:0;position:absolute;top:50%;transition:opacity .2s ease-out;width:4px}.tp-cbzprvv_m.tp-cbzprvv_m-a{opacity:1}.tp-fpsv{position:relative}.tp-fpsv_l{bottom:4px;color:var(--mo-fg);line-height:1;right:4px;pointer-events:none;position:absolute}.tp-fpsv_u{margin-left:.2em;opacity:.7}.tp-rslv{cursor:pointer;padding-left:8px;padding-right:8px}.tp-rslv.tp-v-disabled{opacity:.5}.tp-rslv_t{height:calc(var(--cnt-usz));position:relative}.tp-rslv_t::before{background-color:var(--in-bg);border-radius:1px;content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:-4px;right:-4px}.tp-rslv_b{bottom:0;top:0;position:absolute}.tp-rslv_b::before{background-color:var(--in-fg);content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:0;right:0}.tp-rslv_k{height:calc(var(--cnt-usz) - 8px);margin-top:calc((var(--cnt-usz) - 8px)/-2);position:absolute;top:50%;width:8px}.tp-rslv_k.tp-rslv_k-min{margin-left:-8px}.tp-rslv_k.tp-rslv_k-max{margin-left:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-min{border-bottom-right-radius:0;border-top-right-radius:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-max{border-bottom-left-radius:0;border-top-left-radius:0}.tp-rsltxtv{display:flex}.tp-rsltxtv_s{flex:1}.tp-rsltxtv_t{flex:1;margin-left:4px}.tp-radv_l{display:block;position:relative}.tp-radv_i{left:0;opacity:0;position:absolute;top:0}.tp-radv_b{opacity:.5}.tp-radv_i:hover+.tp-radv_b{background-color:var(--btn-bg-h)}.tp-radv_i:focus+.tp-radv_b{background-color:var(--btn-bg-f)}.tp-radv_i:active+.tp-radv_b{background-color:var(--btn-bg-a)}.tp-radv_i:checked+.tp-radv_b{opacity:1}.tp-radv_t{bottom:0;color:inherit;left:0;overflow:hidden;position:absolute;right:0;text-align:center;text-overflow:ellipsis;top:0}.tp-radv_i:disabled+.tp-radv_b>.tp-radv_t{opacity:.5}.tp-radgridv{border-radius:var(--bld-br);display:grid;overflow:hidden;gap:2px}.tp-radgridv.tp-v-disabled{opacity:.5}.tp-radgridv .tp-radv_b{border-radius:0}',df=[Ub,Zb,tf,of,af,pf,lf,cf],mf=Object.freeze(Object.defineProperty({__proto__:null,ButtonCellApi:nl,ButtonGridApi:il,ButtonGridController:sl,CubicBezier:Fe,CubicBezierApi:rl,CubicBezierAssembly:zs,CubicBezierController:Oi,CubicBezierGraphController:ul,CubicBezierGraphView:cl,CubicBezierPickerController:hl,CubicBezierPickerView:al,CubicBezierPreviewView:pl,CubicBezierView:ol,FpsGraphBladeApi:dl,FpsGraphController:bl,FpsView:vl,Fpswatch:ml,Interval:Y,IntervalAssembly:Ks,IntervalConstraint:Us,RadioCellApi:Cl,RadioController:El,RadioGridApi:Pl,RadioGridController:An,RadioView:yl,RangeSliderController:_l,RangeSliderTextController:gl,RangeSliderTextView:fl,RangeSliderView:wl,TpRadioGridChangeEvent:xl,css:hf,id:uf,plugins:df},Symbol.toStringTag,{value:"Module"})),Be={sceneChange:"scene-change",instrumentPlayed:"instrument-played"},Nt=class Nt{constructor(e){x(this,"pane");x(this,"settings");x(this,"sceneControls",{});this.game=e;const t=document.getElementById("settings");if(!t)throw new Error("No settings container found");this.pane=new md({title:"settings",expanded:!1,container:t}),this.pane.registerPlugin(mf),this.pane.on("change",s=>{var o,a;const r=s.target.key;this.settings&&s.last&&r in this.settings&&((a=(o=this.settings).onChange)==null||a.call(o,{[r]:s.value}))}),e.events.on(Be.sceneChange,s=>{this.deleteSettings(),this.settings=s,s&&this.addSettings(s)}),window.onerror=function(s,r,o,a,l){X.error(` +`+s+" "+r+" "+o+" "+a+" "+l)},this.pane.addButton({title:"Show logs"}).on("click",()=>{i.hidden=!i.hidden});const i=this.pane.addBinding(Nt.logsParams,"logs",{label:"",readonly:!0,multiline:!0,rows:10,hidden:!0,interval:1e3});this.resize()}static log(e){Nt.logsParams.logs+=` +`+e}deleteSettings(){Object.values(this.sceneControls).filter(Boolean).forEach(e=>{e.dispose(),this.pane.remove(e)})}addSettings(e){this.sceneControls.deleteInstrument=this.pane.addButton({title:"Delete instrument & loop",index:0}).on("click",()=>I.deleteCurrentInstrumentScene()),this.sceneControls.deleteLoop=this.pane.addButton({title:"Delete current loop",index:0}).on("click",()=>I.deleteCurrentTrack()),e.noteDuration&&(this.sceneControls.noteDuration=this.pane.addBinding(e,"noteDuration",{label:"Note duration",min:.1,max:5,step:.1,index:0})),e.octaveRange&&(this.sceneControls.octaveRange=this.pane.addBinding(e,"octaveRange",{label:"Octave range",min:1,max:6,step:1,index:0})),this.sceneControls.volume=this.pane.addBinding(e,"volume",{min:0,max:100,step:1,index:0})}resize(){const e=Math.min(this.game.canvas.width,this.game.canvas.height),t=e/40+"px",i=e/10+"px";document.querySelectorAll("button").forEach(s=>{s.style.fontSize=t,s.style.height=i})}};x(Nt,"logsParams",{logs:""});let Mn=Nt;const bi=(n,e)=>{Mn.log(e.map(t=>t.toString()).join(", ")),console[n](...e)},X={log:(n,...e)=>{bi("log",[n,...e])},error:(n,...e)=>{bi("error",[n,...e])},warn:(n,...e)=>{bi("warn",[n,...e])}},to={hihat:Il,kick:zl,snare:Kl,crash:Ul,"hihat-open":Hl,ride:ql,"tom-low":lo,"tom-high":Gl},vf=(n,e)=>{try{to[n](e)}catch(t){X.error(`Error playing ${n}`,t),jl(),to[n](e)}},kl=(n,e,t)=>{const i=[];for(let r=0;ri.map(a=>a[o]).reverse()).flat()};class qs extends $.Scene{constructor(t,i){super();x(this,"pads",[]);x(this,"settings",{volume:50,onChange:t=>this.onSettingChange(t)});this.cols=t,this.rows=i}create(){this.createPads(),this.game.events.emit(Be.sceneChange,this.settings)}changePadNumber(t,i){this.cols=t,this.rows=i,this.scene.restart()}createPads(){const t=this.cols*this.rows;this.pads=new Array(t).fill(0).map((s,r)=>this.createPad(r,t));const i=()=>{const s=window.innerWidth{const O=b%r*a,y=Math.floor(b/r)*l,D=s?0:I.sceneWidthHeight,rt=s?I.sceneWidthHeight:0;p.setSize(a,l).setPosition(D+O,rt+y),u&&u.setPosition(p.getCenter().x,p.getCenter().y).setFontSize(xn.tiny).setResolution(2)})};window.addEventListener("resize",i),i()}createPad(t,i){var O;const s=this.getPadColor(i,t),r=(O=this.getPadText)==null?void 0:O.call(this,t),o=s.color,a=s.brighten(40).color,l=this.add.rectangle().setFillStyle(o).setStrokeStyle(2,fe("#FFF"),.8).setInteractive().setOrigin(0,0);let c;r&&(c=this.add.text(0,0,r,{fontFamily:jt.Text,fontSize:xn.tiny,color:_i.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(t),l.setFillStyle(a),this.game.events.emit(Be.instrumentPlayed,{callback:()=>this.playSound(t),scene:this}),p=!0)},b=()=>{l.setFillStyle(o),p=!1};return l.on("pointerdown",y=>{var D,rt;((rt=(D=y.downElement)==null?void 0:D.tagName)==null?void 0:rt.toLowerCase())==="canvas"&&u()}).on("pointermove",y=>{y.isDown&&u()}).on("pointerup",()=>b()).on("pointerout",()=>b()),{instrument:t,button:l,text:c}}getPadColor(t,i){return $.Display.Color.HSLToColor((t-i)/(t*1.5),1,.5)}getPadText(t){}onSettingChange(t){X.log("Setting changed",JSON.stringify(t))}}const bf={hihat:"#FDA341",kick:"#F24E1E",snare:"#4A90E2",crash:"#A0D8C5","hihat-open":"#F9F871",ride:"#F5C542","tom-low":"#FF7F50","tom-high":"#9B59B6"};class ff extends qs{constructor(){super(2,4);x(this,"instruments",["crash","ride","hihat-open","hihat","snare","tom-low","tom-high","kick"])}getPadColor(t,i){const s=fe(bf[this.instruments[i]]);return $.Display.Color.IntegerToColor(s)}getPadText(t){return this.instruments[t]}playSound(t){vf(this.instruments[t],this.settings.volume)}}let Bt=null,fi=null;const no=()=>{Bt&&(X.log("stopping note...",Bt),Bt.stop(),fi.stop()),X.log("testing note...");const n=22050,e=Freeverb({input:Bus2(),roomSize:.975,damping:.5}).connect(),t=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(e.input,.5),i=[55,110,165,220];fi=Sequencer.make([55,110,165,220],[n/4],t,"note").start(),Bt=Sequencer.make([i.map(s=>s*1.25),i.map(s=>s*1.25*.8),i.map(s=>s*1.25*.8*.8),i.map(s=>s*1.25*.8*.8*1.25)],[n*16],fi,"values"),Bt.start()};class wf extends $.Scene{constructor(){super();x(this,"isGibberishLoaded",!1)}create(){this.createPads(8),this.game.events.emit(Be.sceneChange)}createPads(t){const i=new Array(t).fill(0).map((r,o)=>this.createPad(o)),s=()=>{const r=window.innerWidth{const O=b%o*l,y=Math.floor(b/o)*c,D=r?0:I.sceneWidthHeight,rt=r?I.sceneWidthHeight:0;u.setSize(l,c).setPosition(D+O,rt+y)})};window.addEventListener("resize",s),s()}createPad(t){const i=$.Display.Color.HSLToColor(t/16,1,.5),s=i.darken(40).color,r=i.brighten(4).color,o=this.add.rectangle().setFillStyle(s).setStrokeStyle(2,fe("#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?no():(this.isGibberishLoaded=!0,Gibberish.workletPath="./worklet.js",X.log("loading Gibberish 2..."),Gibberish.init().then(()=>{X.log("Gibberish is ready!"),Gibberish.export(window),no()}).catch(p=>X.error("oops",p))),o.setFillStyle(r))}).on("pointerup",()=>o.setFillStyle(s)).on("pointerout",()=>o.setFillStyle(s)),{instrument:t,button:o}}}function _f(){const n=[];for(let e=0;e<9;e++)n[e]={};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 gf=_f(),Cn=gf.flatMap(n=>Object.entries(n)).map(([n,e])=>({key:n,freq:e})).filter(({freq:n})=>!!n).sort((n,e)=>n.freq-e.freq),Ri=12,Di=6,Cf=Ri*Di;class Vl extends qs{constructor(){super(Di,Ri),this.settings.noteDuration=1.5,this.settings.octaveRange={min:1,max:Di}}getPadText(e){const t=Cn[e];return t==null?void 0:t.key}getPadColor(e,t){var r;t+=this.getNoteIndexOffset();const i=super.getPadColor(Cf,t),s=(r=Cn[t])==null?void 0:r.key;return s!=null&&s.includes("#")?i.darken(70):i.darken(50)}getNoteIndexOffset(){return this.getLowerRangeIndex()*Ri}getLowerRangeIndex(){return this.settings.octaveRange.min-1}playSound(e){e+=this.getNoteIndexOffset();const t=Cn[e].freq;return X.log("Playing note",t),xf({frequency:t,...this.settings})}onSettingChange(e){super.onSettingChange(e),e.octaveRange&&super.changePadNumber(e.octaveRange.max+1-e.octaveRange.min,12)}}const xf=({frequency:n,volume:e=50,noteDuration:t=1.5})=>{const i=ye(),s=i.createOscillator();s.type="sine";const r=i.createGain();s.frequency.setValueAtTime(n,i.currentTime),s.connect(r),r.connect(i.destination);const o=.02;r.gain.setValueAtTime(0,i.currentTime),r.gain.linearRampToValueAtTime(e/100,i.currentTime+o),r.gain.exponentialRampToValueAtTime(1e-4,i.currentTime+t),s.start(i.currentTime),s.stop(i.currentTime+t*2)};class Pf extends Vl{constructor(){super(),this.settings.noteDuration=2}getPadColor(e,t){return super.getPadColor(e,t).saturate(50)}playSound(e){const t=Cn[e].freq;return X.log("Playing note",t),yf({frequency:t,...this.settings})}}function yf({frequency:n,volume:e=50,noteDuration:t=1}){const i=ye(),s=i.createOscillator();s.type="sawtooth",s.frequency.setValueAtTime(n,i.currentTime);const r=i.createGain();r.gain.value=e/100,r.gain.exponentialRampToValueAtTime(.001,i.currentTime+t);const o=i.createBiquadFilter();o.type="lowpass",o.frequency.setValueAtTime(800,i.currentTime),o.Q.value=1;const a=i.createWaveShaper();a.curve=Ef(400),a.oversample="4x";const l=i.createOscillator();l.type="sine",l.frequency.setValueAtTime(3,i.currentTime);const c=i.createGain();c.gain.value=200,l.connect(c),c.connect(o.frequency),s.connect(o),o.connect(a),a.connect(r),r.connect(i.destination),s.start(),l.start(),s.stop(i.currentTime+1),l.stop(i.currentTime+1)}function Ef(n){const e=typeof n=="number"?n:50,t=44100,i=new Float32Array(t),s=Math.PI/180;for(let r=0;rc.setFillStyle(fe("#FFF"),.5).setInteractive().on($.Input.Events.POINTER_DOWN,()=>{this.scene.setVisible(!1)}));const l=I.getTrackSceneKey(t);s.on($.Input.Events.POINTER_UP,()=>{this.scene.add(l,ff,!0)}),r.on($.Input.Events.POINTER_UP,()=>{this.scene.add(l,Pf,!0)}),o.on($.Input.Events.POINTER_UP,()=>{this.scene.add(l,wf,!0)}),i.on($.Input.Events.POINTER_UP,()=>{this.scene.add(l,Vl,!0)}),window.addEventListener("resize",()=>this.resizeScene()),this.resizeScene()}createMatrix(){this.instrumentButtons=[];for(let t=0;t{p.forEach((b,O)=>{b.setSize(s,r).setPosition(s*u,r*O);const y=b.getData("text");if(y){const D=Math.min(b.height,b.width)/5;y.setFontSize(D).setResolution(2).setWordWrapWidth(b.width,!0).setSize(b.width,b.height).setPosition(b.getCenter().x,b.getCenter().y)}})});const o=t?window.innerWidth:window.innerWidth-i,a=t?window.innerHeight-i:window.innerHeight,l=t?0:i,c=t?i:0;this.cameras.main.setPosition(l,c).setViewport(l,c,o,a)}};x(Rn,"key","EmptyScene");let Qt=Rn;const oe=class oe{constructor(e){x(this,"state","readyToRecord");x(this,"events",[]);x(this,"eventEmitter",new $.Events.EventEmitter);x(this,"startRecordingTime");x(this,"startPlayingTime",0);x(this,"currentLoopIndex",0);x(this,"loopTimeout",null);this.trackIndex=e,this.log("Loop created")}getStartPlayingTime(){return this.startPlayingTime}getLoopLength(){var e;return(e=this.events.find(({callback:t})=>t==="endOfLoop"))==null?void 0:e.time}handleClick(){switch(this.nextState(),this.state){case"recording":this.startRecording();break;case"playing":this.startPlaying();break;case"readyToPlay":this.stopPlaying();break}}addLoopEvent(e){if(this.isRecording()){this.startRecordingTime||(this.startRecordingTime=oe.masterLoop.getStartPlayingTime());const t=Date.now()-this.startRecordingTime;this.events.push({callback:e,time:t}),this.log(`Recording ${e} at time ${t}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()&&(oe.masterLoop=null),this.log("Loop destroyed")}addEventListener(e,t){this.eventEmitter.once(e,t)}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"),oe.masterLoop||(oe.masterLoop=this,this.startRecordingTime=Date.now())}stopRecording(){var t;if(this.events.length===0)return this.log("No events recorded"),"readyToRecord";if(!this.startRecordingTime)throw new Error("startRecordingTime is not set");const e=Date.now()-this.startRecordingTime;if(this.isMasterLoop()){this.events.push({callback:"endOfLoop",time:e});const i=this.events[0].time;this.events=this.events.map(({time:s,callback:r})=>({time:s-i,callback:r}))}else{X.log("events: "+this.events.length,this.events);const i=(t=oe.masterLoop)==null?void 0:t.getLoopLength();if(!i)throw new Error("masterLoopLength is not set");const r=Math.floor(e/i)*i;this.events=this.events.filter(({time:o})=>o<=r),this.events.push({callback:"endOfLoop",time:r})}return this.log(`Recording stopped at ${e} with ${this.events.length} events, start playing`),"playing"}startPlaying(){var t;const e=()=>{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:s}=this.events[this.currentLoopIndex],r=this.currentLoopIndex===0?0:this.events[this.currentLoopIndex-1].time;this.loopTimeout=setTimeout(()=>{this.log(`Playing event ${i} after ${s}ms`),i!=="endOfLoop"?i():this.eventEmitter.emit("endOfLoop"),this.currentLoopIndex++,e()},s-r)};this.log("Loop play starting"),!this.isMasterLoop()&&((t=oe.masterLoop)!=null&&t.isPlaying())?oe.masterLoop.addEventListener("endOfLoop",()=>{e()}):e()}stopPlaying(){this.loopTimeout&&clearTimeout(this.loopTimeout),this.currentLoopIndex=0,this.log("Loop stopped")}isMasterLoop(){return this===oe.masterLoop}log(e,t){const i=`Loop ${this.trackIndex+1}: ${e}`;t?X.log(`%c${i}`,`color: ${t}`):X.log(i)}};x(oe,"masterLoop",null);let On=oe;const kf={selected:"#DDD",unselected:"#000"},io={play:"play_arrow",record:"fiber_manual_record",stop:"stop"},ut={idle:"#FFF",readyToRecord:"#0FF",recording:"#FD0041",playing:"#0F0"},C=class C extends $.Scene{constructor(){super(C.key);x(this,"resizeTracks",()=>{const t=window.innerWidth{const p=t?i*c:0,u=t?-1:s*c;r.setSize(i,s).setPosition(p,u);const b=t?r.getCenter().x:r.getCenter().x-i/4,O=t?r.getCenter().y-s/4:r.getCenter().y,y=Math.min(s,i);o.setResolution(3).setSize(i,s).setFontSize(y/4).setPosition(b,O),a.setSize(y/3,y/3).setPosition(b,O),l.setOrigin(t?.5:1,t?1:.5).setPosition(t?r.getCenter().x:r.getRightCenter().x,t?r.getBottomCenter().y:r.getCenter().y)}),this.cameras.main.setViewport(0,0,t?window.innerWidth:i,t?s:window.innerHeight)});C.instance=this}static get sceneWidthHeight(){const t=window.innerWidth,i=window.innerHeight;return Math.max(i,t)/10}static deleteCurrentTrack(){const t=C.tracks.find(i=>i.selected);if(t){const i=C.tracks.indexOf(t);return t.loop.destroy(),t.loopProgressArc.clear(),t.loop=new On(i),this.instance.updateControlsState(),i}throw new Error("No track selected")}static deleteCurrentInstrumentScene(){const t=C.deleteCurrentTrack(),i=C.getTrackSceneKey(t);this.instance.game.scene.remove(i),this.instance.game.scene.start(Qt.key,{index:t}),this.instance.updateControlsState()}static getTrackSceneKey(t){return`track_scene_${t}`}create(){this.cameras.main.setOrigin(0,0).setPosition(0,0).setViewport(0,0,C.sceneWidthHeight,window.innerHeight).setBackgroundColor("#963"),this.createTracks(),this.game.events.on(Be.sceneChange,()=>{this.updateControlsState()}),this.game.events.on(Be.instrumentPlayed,({callback:t})=>{var i,s;(s=(i=C.tracks.find(r=>r.selected))==null?void 0:i.loop)==null||s.addLoopEvent(t)})}update(){for(const t of C.tracks)t.loop.isPlaying()&&this.updateProgressArc(t)}getTrackScene(t){return this.scene.get(C.getTrackSceneKey(t))}updateProgressArc(t){const i=t.loop.getLoopLength();if(!i)throw new Error("Loop length is not defined");const r=(Date.now()-t.loop.getStartPlayingTime())/i;t.loopProgressArc.clear(),t.loopProgressArc.lineStyle(4,65280,1);const o=$.Math.DegToRad(-90),a=o+$.Math.DegToRad(360*r);t.loopProgressArc.beginPath(),t.loopProgressArc.arc(t.buttonText.x,t.buttonText.y,t.buttonSelectedCircle.width/2,o,a,!1),t.loopProgressArc.strokePath()}createTracks(){C.tracks=new Array(C.numTracks).fill(null).map((t,i)=>({loop:new On(i),button:this.add.rectangle().setOrigin(0,0).setStrokeStyle(2,fe("#FFF"),.8).setInteractive().on($.Input.Events.POINTER_DOWN,()=>this.selectTrack(i)),selected:!1,buttonSelectedCircle:this.add.ellipse(0,0,0,0,fe("#FFF")),buttonText:this.add.text(0,0,`${i+1}`,{fontFamily:jt.Text,fontSize:xn.medium,color:_i.white}).setOrigin(.5,.5).setResolution(2),controlIcon:this.add.text(0,0,"",{fontFamily:jt.Icons,fontSize:xn.medium,color:_i.white}).setOrigin(.5,.5).setResolution(2).setInteractive().on($.Input.Events.POINTER_DOWN,()=>{this.handleControlClicked(i)}),loopProgressArc:this.add.graphics()})),window.addEventListener("resize",()=>this.resizeTracks()),this.resizeTracks(),this.selectTrack(0)}handleControlClicked(t){C.tracks[t].loop.handleClick(),this.updateControlsState()}selectTrack(t){const i=C.tracks[t];if(i.selected)i.loop.handleClick(),this.updateControlsState();else{const s=C.tracks.find(o=>o.selected);s&&(s.selected=!1,s.loop.isRecording()&&s.loop.handleClick()),i.selected=!0,this.updateControlsState();const r=this.getTrackScene(t);if(r){r.scene.bringToTop();const o=r.settings;this.game.events.emit(Be.sceneChange,o)}else this.game.scene.start(Qt.key,{index:t})}}updateControlsState(){C.tracks.forEach((t,i)=>{t.button.setFillStyle(fe(kf.unselected)),t.buttonText.setColor(t.selected?"#000":"#FFF"),t.buttonSelectedCircle.setVisible(!0).setFillStyle(fe(t.selected?"#FFF":"#000"));const s=this.getTrackScene(i);s&&s instanceof qs?t.selected&&(t.loop.isRecording()||t.loop.isReadyToRecord())?t.controlIcon.setText(io.record).setColor(t.loop.isRecording()?ut.recording:ut.idle):t.loop.isPlaying()||t.loop.isReadyToPlay()?t.controlIcon.setText(io.play).setColor(t.loop.isPlaying()?ut.playing:ut.idle):t.controlIcon.setText("").setColor(ut.idle):t.controlIcon.setText("").setColor(ut.idle)})}};x(C,"key","LoopTracksScene"),x(C,"numTracks",5),x(C,"tracks"),x(C,"instance");let I=C;const Vf=()=>window.matchMedia("(prefers-color-scheme: dark)").matches;function so(n){const e=window.innerWidth,t=window.innerHeight;n.scale.resize(e,t),n.scene.scenes.forEach(i=>{var s,r;return(r=(s=i.sys)==null?void 0:s.scale)==null?void 0:r.refresh()})}let ro=!1;const Sf=()=>(ro||(ro=!0,Fl().then(()=>{const n=new $.Game({type:$.AUTO,mode:$.Scale.RESIZE,parent:"phaser-container",width:window.innerWidth,height:window.innerHeight,backgroundColor:Vf()?"#333":"#DDD",scene:[I,Qt],input:{activePointers:8}}),e=new Mn(n);window.addEventListener("resize",()=>{so(n),e.resize()}),n.scene.start(I.key),so(n)})),Ft.jsx(Ft.Fragment,{}));function Tf(){return Ft.jsx(Sf,{})}wi.createRoot(document.getElementById("root")).render(Ft.jsx(Al.StrictMode,{children:Ft.jsx(Tf,{})})); diff --git a/assets/index-Sd78XxzD.js b/assets/index-Sd78XxzD.js deleted file mode 100644 index f1117e4..0000000 --- a/assets/index-Sd78XxzD.js +++ /dev/null @@ -1,13 +0,0 @@ -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 w=(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:{}},ae={};/** - * @license React - * react-jsx-runtime.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */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}}ae.Fragment=Qi;ae.jsx=jn;ae.jsxs=jn;In.exports=ae;var Tt=In.exports,xe={},sn=Gi;xe.createRoot=sn.createRoot,xe.hydrateRoot=sn.hydrateRoot;const St={Icons:"Icons",Text:"Courier"},Zt={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 Y=()=>{if(!Wt){const n=window.AudioContext||window.webkitAudioContext;Wt=new n}return Wt},nr=()=>{Wt=null};function ir(n=100){const t=Y(),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 Jt{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(!Jt.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 g(i)||(r=Math.max(r,i)),g(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(!g(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 on(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 g(n.step)?Math.max(on(t),2):on(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 fr(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 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 le{constructor(t){this.target=t}}class It extends le{constructor(t,e,i){super(t),this.value=e,this.last=i??!0}}class Ur extends le{constructor(t,e){super(t),this.expanded=e}}class Gr extends le{constructor(t,e){super(t),this.index=e}}class Wr extends le{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 an(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:an(!0),required:an(!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 te(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 ce(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=>{g(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 ln=h(""),cn={veryfirst:"vfst",first:"fst",last:"lst",verylast:"vlst"};class pe{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(ln(void 0,cn[i]))}),this.blade.get("positions").forEach(i=>{e.classList.add(ln(void 0,cn[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 pe{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 pn(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(pn(t)),e=>({tag:e.optional.string}),e=>(this.tag=e.tag,!0))}exportState(){return M(()=>pn(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 de=h("btn");class Cs{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(de()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("button");i.classList.add(de("b")),e.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const r=t.createElement("div");r.classList.add(de("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 un extends pe{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 un(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 un?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(!Jt.isBindable(n))throw x.notBindable();return new Jt(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 pe{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")&&!g(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),te(t),e=t.clientHeight,n.set("temporaryExpanded",null),te(t)}),e}function dn(n,t){t.style.height=n.styleHeight}function He(n,t){n.value("expanded").emitter.on("beforechange",()=>{if(n.set("completed",!1),g(n.get("expandedHeight"))){const e=Ds(n,t);e>0&&n.set("expandedHeight",e)}n.set("shouldFixHeight",!0),te(t)}),n.emitter.on("change",()=>{dn(n,t)}),dn(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=>{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")),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 hn(n,t){return gt(n,Fs(void 0,t))}class X 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 X(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_,hn(t,"disabled")),z(this,"hidden",hn(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 vn=h("tbp");class Is{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(vn()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(vn("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:X.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:X.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 mn=-1;class $s{constructor(){this.onItemSelectedChange_=this.onItemSelectedChange_.bind(this),this.empty=_(!0),this.selectedIndex=_(mn),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=mn,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 bn 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 bn(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:X.create()});t.add(i)}),t},api(n){return n.controller instanceof bn?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:X.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 ee(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 g(n)?null:new zt(Ke(n))}const he=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(he()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("select");i.classList.add(he("s")),e.viewProps.bindDisabled(i),this.element.appendChild(i),this.selectElement=i;const r=t.createElement("div");r.classList.add(he("m")),r.appendChild(ce(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 it{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 fn=h("pop");class Ys{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(fn()),e.viewProps.bindClassModifiers(this.element),U(e.shows,gt(this.element,fn(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 gn=h("txt");class Xs{constructor(t,e){this.onChange_=this.onChange_.bind(this),this.element=t.createElement("div"),this.element.classList.add(gn()),e.viewProps.bindClassModifiers(this.element),this.props_=e.props,this.props_.emitter.on("change",this.onChange_);const i=t.createElement("input");i.classList.add(gn("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);g(r)||(this.value.rawValue=r),this.view.refresh()}}function Qs(n){return String(n)}function ui(n){return n==="false"?!1:!!n}function wn(n){return Qs(n)}function Zs(n){return t=>n.reduce((e,i)=>e!==null?e:i(t),null)}const Js=R(0);function ne(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 ve(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_(ve(t,this.elem_)),sender:this,shiftKey:t.shiftKey})}onDocumentMouseMove_(t){this.emitter.emit("move",{altKey:t.altKey,data:this.computePosition_(ve(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_(ve(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);g(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 me=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(me()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(me("t")),e.viewProps.bindTabIndex(i),this.element.appendChild(i),this.trackElement=i;const r=t.createElement("div");r.classList.add(me("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 be=h("sldtxt");class ro{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(be());const i=t.createElement("div");i.classList.add(be("s")),this.sliderView_=e.sliderView,i.appendChild(this.sliderView_.element),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(be("t")),this.textView_=e.textView,r.appendChild(this.textView_.element),this.element.appendChild(r)}}class ie{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 tt(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=ce(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&&ee(i,zt);return r?new it(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 it?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 ue(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 _n(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=_n(n,t.mode,t.type,"int"),r=go[t.mode][e.mode](...i);return _n(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 ue(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 Q=h("colp");class _o{constructor(t,e){this.alphaViews_=null,this.element=t.createElement("div"),this.element.classList.add(Q()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(Q("hsv"));const r=t.createElement("div");r.classList.add(Q("sv")),this.svPaletteView_=e.svPaletteView,r.appendChild(this.svPaletteView_.element),i.appendChild(r);const s=t.createElement("div");s.classList.add(Q("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(Q("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(Q("a"));const l=t.createElement("div");l.classList.add(Q("ap")),l.appendChild(this.alphaViews_.palette.element),a.appendChild(l);const c=t.createElement("div");c.classList.add(Q("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 ue(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 Cn(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 xn(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(Cn("int"),xn("int")),n==="float"&&t.push(Cn("float"),xn("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),ne,ne],e=S(n,"int");return`hsl(${H(e.getComponents("hsl")).map((r,s)=>t[s](r)).join(", ")})`}function No(n){const t=[R(0),ne,ne,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(ce(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(ue(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(ue(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 fe=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(fe()),e.viewProps.bindClassModifiers(this.element),e.viewProps.bindTabIndex(this.element);const i=t.createElement("div");i.classList.add(fe("c")),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(fe("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 ge=h("svp"),yn=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(ge()),e.viewProps.bindClassModifiers(this.element),e.viewProps.bindTabIndex(this.element);const i=t.createElement("canvas");i.height=yn,i.width=yn,i.classList.add(ge("c")),this.element.appendChild(i),this.canvasElement=i;const r=t.createElement("div");r.classList.add(ge("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 we=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(we()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(we("sw")),this.element.appendChild(i),this.swatchElem_=i;const r=t.createElement("button");r.classList.add(we("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"||g(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=Pn(n);return new v(e,"rgb")}if(t==="float"){const e=Pn(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 En=h("pndtxt");class Sa{constructor(t,e){this.textViews=e.textViews,this.element=t.createElement("div"),this.element.classList.add(En()),this.textViews.forEach(i=>{const r=t.createElement("div");r.classList.add(En("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&&ee(e,zt);if(i)return new it(n.document,{props:new d({options:i.values.value("options")}),value:t,viewProps:n.viewProps});const r=Xn(n.params,t.rawValue),s=e&&ee(e,Ft);return s?new ie(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 ie?new Aa(n.controller):n.controller.valueController instanceof it?new $e(n.controller):null}});class et{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 et(...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(ce(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 Z=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(Z()),e.layout==="popup"&&this.element.classList.add(Z(void 0,"p")),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(Z("p")),e.viewProps.bindTabIndex(i),this.element.appendChild(i),this.padElement=i;const r=t.createElementNS(N,"svg");r.classList.add(Z("g")),this.padElement.appendChild(r),this.svgElem_=r;const s=t.createElementNS(N,"line");s.classList.add(Z("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(Z("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(Z("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(Z("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 kn(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 et(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]=kn(t,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));e===0&&i===0||this.value.setRawValue(new et(this.value.rawValue.x+e,this.value.rawValue.y+i),{forceEmit:!1,last:!1})}onPadKeyUp_(t){const[e,i]=kn(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 et.isObject(n)?new et(n.x,n.y):new et}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 Vn(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 za(n,t){var e,i;const r=Vn(ot(n,(e=n.x)!==null&&e!==void 0?e:{}),t.x),s=Vn(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(!et.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(tt),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:et.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(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 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(tt),y:i.optional.custom(tt),z:i.optional.custom(tt)}));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(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 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(tt),x:i.optional.custom(tt),y:i.optional.custom(tt),z:i.optional.custom(tt)}));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&&ee(i,zt);return r?new it(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 it?new $e(n.controller):null}}),Ut={monitor:{defaultInterval:200,defaultRows:3}},Tn=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(Tn()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("textarea");i.classList.add(Tn("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 Sn=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(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 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:wn,value:n.value,viewProps:n.viewProps}):new en(n.document,{formatter:wn,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 J=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(J()),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(J("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(J("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(J("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(J("t","a"))||(a.classList.add(J("t","a"),J("t","in")),te(a),a.classList.remove(J("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 g(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 Ln(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=>Ln(n)?64:1,reader:n=>Kn},controller:n=>Ln(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(g(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:X.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(g(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:X.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(g(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 it(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 it)?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 An=h("spr");class El{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(An()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("hr");i.classList.add(An("r")),this.element.appendChild(i)}}class Rn extends pe{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 Rn(n.document,{blade:n.blade,viewProps:n.viewProps})},api(n){return n.controller instanceof Rn?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 ie(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 ie)?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:X.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 nt={sceneChange:"scene-change",instrumentPlayed:"instrument-played"},Vt=class Vt{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 Al({title:"settings",expanded:!1,container:e}),t.events.on(nt.sceneChange,r=>{this.deleteSettings(),r&&this.addSettings(r)}),window.onerror=function(r,s,o,a,l){I.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}deleteSettings(){Object.values(this.sceneControls).filter(Boolean).forEach(t=>{t.dispose(),this.pane.remove(t)})}addSettings(t){this.sceneControls.deleteInstrument=this.pane.addButton({title:"Delete instrument & loop",index:0}).on("click",()=>V.deleteCurrentInstrumentScene()),this.sceneControls.deleteLoop=this.pane.addButton({title:"Delete current loop",index:0}).on("click",()=>V.deleteCurrentTrack()),t.noteDuration&&(this.sceneControls.noteDuration=this.pane.addBinding(t,"noteDuration",{label:"Note duration",min:.1,max:5,step:.1,index:0})),this.sceneControls.volume=this.pane.addBinding(t,"volume",{min:0,max:100,step:1,index:0})}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(Vt,"logsParams",{logs:""});let re=Vt;const _e=(n,t)=>{re.log(t.map(e=>e.toString()).join(", ")),console[n](...t)},I={log:(n,...t)=>{_e("log",[n,...t])},error:(n,...t)=>{_e("error",[n,...t])},warn:(n,...t)=>{_e("warn",[n,...t])}},On={hihat:ir,kick:rr,snare:sr,crash:or,"hihat-open":ar,ride:lr,"tom-low":Nn,"tom-high":cr},Rl=(n,t)=>{try{On[n](t)}catch(e){I.error(`Error playing ${n}`,e),nr(),On[n](t)}},Hi=(n,t,e)=>{const i=[];for(let s=0;si.map(a=>a[o]).reverse()).flat()};class rn extends y.Scene{constructor(e,i){super();w(this,"pads",[]);w(this,"settings",{volume:50});this.cols=e,this.rows=i}create(){this.createPads(),this.game.events.emit(nt.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(Zt.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:Zt.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(nt.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 Dl extends rn{constructor(){super(2,4);w(this,"instruments",["crash","ride","hihat-open","hihat","snare","tom-low","tom-high","kick"])}getPadColor(e,i){const r=K(Ol[this.instruments[i]]);return y.Display.Color.IntegerToColor(r)}getPadText(e){return this.instruments[e]}playSound(e){Rl(this.instruments[e],this.settings.volume)}}let kt=null,Ce=null;const Dn=()=>{kt&&(I.log("stopping note...",kt),kt.stop(),Ce.stop()),I.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];Ce=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],Ce,"values"),kt.start()};class Ml extends y.Scene{constructor(){super();w(this,"isGibberishLoaded",!1)}create(){this.createPads(8),this.game.events.emit(nt.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",I.log("loading Gibberish 2..."),Gibberish.init().then(()=>{I.log("Gibberish is ready!"),Gibberish.export(window),Dn()}).catch(p=>I.error("oops",p))),o.setFillStyle(s))}).on("pointerup",()=>o.setFillStyle(r)).on("pointerout",()=>o.setFillStyle(r)),{instrument:e,button:o}}}function Bl(){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 Fl=Bl(),Qt=Fl.flatMap(n=>Object.entries(n)).map(([n,t])=>({key:n,freq:t})).filter(({freq:n})=>!!n).sort((n,t)=>n.freq-t.freq);class $i extends rn{constructor(){super(6,12),this.settings.noteDuration=1.5}getPadText(t){const e=Qt[t];return e==null?void 0:e.key}getPadColor(t,e){var s;const i=super.getPadColor(t,e),r=(s=Qt[e])==null?void 0:s.key;return r!=null&&r.includes("#")?i.darken(70):i.darken(50)}playSound(t){const e=Qt[t].freq;return I.log("Playing note",e),Il({frequency:e,...this.settings})}}const Il=({frequency:n,volume:t=50,noteDuration:e=1.5})=>{const i=Y(),r=i.createOscillator();r.type="sine";const s=i.createGain();r.frequency.setValueAtTime(n,i.currentTime),r.connect(s),s.connect(i.destination);const o=.02;s.gain.setValueAtTime(0,i.currentTime),s.gain.linearRampToValueAtTime(t/100,i.currentTime+o),s.gain.exponentialRampToValueAtTime(1e-4,i.currentTime+e),r.start(i.currentTime),r.stop(i.currentTime+e*2)};class jl extends $i{constructor(){super(),this.settings.noteDuration=2}getPadColor(t,e){return super.getPadColor(t,e).saturate(50)}playSound(t){const e=Qt[t].freq;return I.log("Playing note",e),Nl({frequency:e,...this.settings})}}function Nl({frequency:n,volume:t=50,noteDuration:e=1}){const i=Y(),r=i.createOscillator();r.type="sawtooth",r.frequency.setValueAtTime(n,i.currentTime);const s=i.createGain();s.gain.value=t/100,s.gain.exponentialRampToValueAtTime(.001,i.currentTime+e);const o=i.createBiquadFilter();o.type="lowpass",o.frequency.setValueAtTime(800,i.currentTime),o.Q.value=1;const a=i.createWaveShaper();a.curve=zl(400),a.oversample="4x";const l=i.createOscillator();l.type="sine",l.frequency.setValueAtTime(3,i.currentTime);const c=i.createGain();c.gain.value=200,l.connect(c),c.connect(o.frequency),r.connect(o),o.connect(a),a.connect(s),s.connect(i.destination),r.start(),l.start(),r.stop(i.currentTime+1),l.stop(i.currentTime+1)}function zl(n){const t=typeof n=="number"?n:50,e=44100,i=new Float32Array(e),r=Math.PI/180;for(let s=0;sc.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,Dl,!0)}),s.on(y.Input.Events.POINTER_UP,()=>{this.scene.add(l,jl,!0)}),o.on(y.Input.Events.POINTER_UP,()=>{this.scene.add(l,Ml,!0)}),i.on(y.Input.Events.POINTER_UP,()=>{this.scene.add(l,$i,!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)}};w(oe,"key","EmptyScene");let Bt=oe;const j=class j{constructor(t){w(this,"state","readyToRecord");w(this,"events",[]);w(this,"eventEmitter",new y.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=j.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()&&(j.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"),j.masterLoop||(j.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{I.log("events: "+this.events.length,this.events);const i=(e=j.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=j.masterLoop)!=null&&e.isPlaying())?j.masterLoop.addEventListener("endOfLoop",()=>{t()}):t()}stopPlaying(){this.loopTimeout&&clearTimeout(this.loopTimeout),this.currentLoopIndex=0,this.log("Loop stopped")}isMasterLoop(){return this===j.masterLoop}log(t,e){const i=`Loop ${this.trackIndex+1}: ${t}`;e?I.log(`%c${i}`,`color: ${e}`):I.log(i)}};w(j,"masterLoop",null);let se=j;const Hl={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);w(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 se(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(nt.sceneChange,()=>{this.updateControlsState()}),this.game.events.on(nt.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 se(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:Zt.medium,color:ye.white}).setOrigin(.5,.5).setResolution(2),controlIcon:this.add.text(0,0,"",{fontFamily:St.Icons,fontSize:Zt.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(nt.sceneChange,o)}else this.game.scene.start(Bt.key,{index:e})}}updateControlsState(){f.tracks.forEach((e,i)=>{e.button.setFillStyle(K(Hl.unselected)),e.buttonText.setColor(e.selected?"#000":"#FFF"),e.buttonSelectedCircle.setVisible(!0).setFillStyle(K(e.selected?"#FFF":"#000"));const r=this.getTrackScene(i);r&&r instanceof rn?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)})}};w(f,"key","LoopTracksScene"),w(f,"numTracks",5),w(f,"tracks"),w(f,"instance");let V=f;const $l=()=>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 Kl=()=>(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:$l()?"#333":"#DDD",scene:[V,Bt],input:{activePointers:8}}),t=new re(n);window.addEventListener("resize",()=>{Bn(n),t.resize()}),n.scene.start(V.key),Bn(n)})),Tt.jsx(Tt.Fragment,{}));function ql(){return Tt.jsx(Kl,{})}xe.createRoot(document.getElementById("root")).render(Tt.jsx(Wi.StrictMode,{children:Tt.jsx(ql,{})})); diff --git a/index.html b/index.html index 9544fb6..03a1f51 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 5920298..371ba10 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-Sd78XxzD.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:"0366dde225a9d6ee47269fd6668876f4"},{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 a={};const c=e=>n(e,o),t={module:{uri:o},exports:a,require:c};s[o]=Promise.all(i.map((e=>t[e]||c(e)))).then((e=>(r(...e),a)))}}define(["./workbox-209e5686"],(function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"assets/index-7NGr8UKc.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:"fc28b4b0483d2384780daa6fc2a5d40f"},{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")}));