From 03a1bb88cac368ed42b1f25a8863634853cd0eb1 Mon Sep 17 00:00:00 2001 From: domi7777 Date: Thu, 7 Nov 2024 12:43:18 +0000 Subject: [PATCH] deploy: 58a8c5edbf63f42876b87a9779ec4ec23d50fae4 --- assets/{index-EDMudVsa.js => index-ARw_YE2y.js} | 6 +++--- index.html | 2 +- sw.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename assets/{index-EDMudVsa.js => index-ARw_YE2y.js} (78%) diff --git a/assets/index-EDMudVsa.js b/assets/index-ARw_YE2y.js similarity index 78% rename from assets/index-EDMudVsa.js rename to assets/index-ARw_YE2y.js index e30aa9a..a456a97 100644 --- a/assets/index-EDMudVsa.js +++ b/assets/index-ARw_YE2y.js @@ -6,6 +6,6 @@ var Ii=Object.defineProperty;var ji=(n,t,e)=>t in n?Ii(n,t,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var $i=Ni,Ki=Symbol.for("react.element"),qi=Symbol.for("react.fragment"),Ui=Object.prototype.hasOwnProperty,Gi=$i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Wi={key:!0,ref:!0,__self:!0,__source:!0};function Dn(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)Ui.call(t,i)&&!Wi.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:Ki,type:n,key:s,ref:o,props:r,_owner:Gi.current}}ne.Fragment=qi;ne.jsx=Dn;ne.jsxs=Dn;Mn.exports=ne;var Et=Mn.exports,fe={},Je=zi;fe.createRoot=Je.createRoot,fe.hydrateRoot=Je.hydrateRoot;const kt={Icons:"Icons",Text:"Courier"},Gt={tiny:"15px",small:"30px",medium:"50px",big:"90px"},ge={white:"#FFF"},Yi=async()=>{const n=new FontFace(kt.Icons,"url(./fonts/material.woff2)");return document.fonts.add(n),n.load().catch(t=>console.error(t))},j=(n,t=!1)=>y.Display.Color.HexStringToColor(n).darken(t?75:0).color;let Kt=null;const et=()=>{if(!Kt){const n=window.AudioContext||window.webkitAudioContext;Kt=new n}return Kt},Xi=()=>{Kt=null};function Qi(){const n=et(),t=n.sampleRate*.05,e=n.createBuffer(1,t,n.sampleRate),i=e.getChannelData(0);for(let c=0;c{try{tn[n]()}catch(t){console.error(`Error playing ${n}`,t),Xi(),tn[n]()}},ke=(n,t,e)=>{const i=[];for(let s=0;si.map(a=>a[o]).reverse()).flat()},sr={hihat:"#FDA341",kick:"#F24E1E",snare:"#4A90E2",crash:"#A0D8C5","hihat-open":"#F9F871",ride:"#F5C542","tom-low":"#FF7F50","tom-high":"#9B59B6"};class en extends y.Scene{constructor(t="drums"){super(),this.type=t}create({type:t}){t&&(this.type=t),this.createPads(),this.scene.get(_.key).events.emit("track-selected")}createPads(){const t=[this.createPad("crash"),this.createPad("ride"),this.createPad("hihat-open"),this.createPad("hihat"),this.createPad("snare"),this.createPad("tom-low"),this.createPad("tom-high"),this.createPad("kick")],e=()=>{const i=window.innerWidth{const d=p%r*o,h=Math.floor(p/r)*a,S=i?0:_.sceneWidthHeight,x=i?_.sceneWidthHeight:0;c.setSize(o,a).setPosition(S+d,x+h)})};window.addEventListener("resize",e),e()}createPad(t){const e=sr[t],i=j(e,this.type==="drums"),r=y.Display.Color.HexStringToColor(e).brighten(4).color,s=this.add.rectangle().setFillStyle(i).setStrokeStyle(2,j("#FFF"),.8).setInteractive().setOrigin(0,0);return s.on("pointerdown",o=>{var l,c;if(((c=(l=o.downElement)==null?void 0:l.tagName)==null?void 0:c.toLowerCase())!=="canvas")return;s.setFillStyle(r);const a=()=>rr(t);a(),this.scene.get(_.key).events.emit("instrument-played",{callback:a,scene:this})}).on("pointerup",()=>s.setFillStyle(i)).on("pointerout",()=>s.setFillStyle(i)),{instrument:t,button:s}}}let wt=null,ae=null;const nn=()=>{wt&&(console.log("stopping note...",wt),wt.stop(),ae.stop()),console.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];ae=Sequencer.make([55,110,165,220],[n/4],e,"note").start(),wt=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],ae,"values"),wt.start()};class or extends y.Scene{constructor(){super();E(this,"isGibberishLoaded",!1)}create({numberOfPads:e=8}){this.createPads(e),this.scene.get(_.key).events.emit("track-selected")}createPads(e){const i=new Array(e).fill(0).map((s,o)=>this.createPad(o)),r=()=>{const s=window.innerWidth{const S=h%o*l,x=Math.floor(h/o)*c,O=s?0:_.sceneWidthHeight,ct=s?_.sceneWidthHeight:0;d.setSize(l,c).setPosition(O+S,ct+x)})};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,j("#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?nn():(this.isGibberishLoaded=!0,Gibberish.workletPath="./worklet.js",console.log("loading Gibberish 2..."),Gibberish.init().then(()=>{console.log("Gibberish is ready!"),Gibberish.export(window),nn()}).catch(p=>console.error("oops",p))),o.setFillStyle(s))}).on("pointerup",()=>o.setFillStyle(r)).on("pointerout",()=>o.setFillStyle(r)),{instrument:e,button:o}}}class ar extends y.Scene{constructor(e,i){super();E(this,"pads",[]);this.cols=e,this.rows=i}create(){this.createPads(),this.scene.get(_.key).events.emit("track-selected")}createPads(){const e=this.cols*this.rows;this.pads=new Array(e).fill(0).map((r,s)=>this.createPad(s,e));const i=()=>{const r=window.innerWidth{const S=h%s*a,x=Math.floor(h/s)*l,O=r?0:_.sceneWidthHeight,ct=r?_.sceneWidthHeight:0;p.setSize(a,l).setPosition(O+S,ct+x),d&&d.setPosition(p.getCenter().x,p.getCenter().y).setFontSize(Gt.tiny).setResolution(2)})};window.addEventListener("resize",i),i()}createPad(e,i){var S;const r=this.getPadColor(i,e),s=(S=this.getPadText)==null?void 0:S.call(this,e),o=r.darken(60).color,a=r.brighten(40).color,l=this.add.rectangle().setFillStyle(o).setStrokeStyle(2,j("#FFF"),.8).setInteractive().setOrigin(0,0);let c;s&&(c=this.add.text(0,0,s,{fontFamily:kt.Text,fontSize:Gt.tiny,color:ge.white}).setAlpha(.5).setOrigin(.5,.5).setResolution(2).setPosition(l.getCenter().x,l.getCenter().y).setDepth(1));let p=!1;const d=()=>{p||(this.playSound(e),l.setFillStyle(a),this.scene.get(_.key).events.emit("instrument-played",{callback:()=>this.playSound(e),scene:this}),p=!0)},h=()=>{l.setFillStyle(o),p=!1};return l.on("pointerdown",x=>{var O,ct;((ct=(O=x.downElement)==null?void 0:O.tagName)==null?void 0:ct.toLowerCase())==="canvas"&&d()}).on("pointermove",x=>{x.isDown&&d()}).on("pointerup",()=>h()).on("pointerout",()=>h()),{instrument:e,button:l,text:c}}getPadColor(e,i){return y.Display.Color.HSLToColor((e-i)/(e*1.5),1,.5)}}function lr(){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 cr=lr(),le=cr.flatMap(n=>Object.entries(n)).map(([n,t])=>({key:n,freq:t})).filter(({freq:n})=>!!n).sort((n,t)=>n.freq-t.freq);class pr extends ar{constructor(){super(6,12)}create(){super.create()}getPadText(t){const e=le[t];return e==null?void 0:e.key}getPadColor(t,e){var s;const i=super.getPadColor(t,e),r=(s=le[e])==null?void 0:s.key;return r!=null&&r.includes("#")?i.darken(15):i}playSound(t){const e=le[t].freq;return console.log("Playing note",e),dr(e)}}const dr=n=>{const t=et(),e=t.createOscillator();e.type="sine";const i=t.createGain();e.frequency.setValueAtTime(n,t.currentTime),e.connect(i),i.connect(t.destination);const r=.02,s=1.5;i.gain.setValueAtTime(0,t.currentTime),i.gain.linearRampToValueAtTime(.7,t.currentTime+r),i.gain.exponentialRampToValueAtTime(1e-4,t.currentTime+s),e.start(t.currentTime),e.stop(t.currentTime+s)},ee=class ee extends y.Scene{constructor(){super(ee.key);E(this,"rowNumber",5);E(this,"colNumber",5);E(this,"instrumentButtons")}create({index:e}){this.scene.bringToTop(),this.cameras.main.setOrigin(0,0).setBackgroundColor("#147"),this.createMatrix();const i=this.instrumentButtons[2][1];i.setData("text",this.addText(i,"Simple Synth"));const r=this.instrumentButtons[1][2];r.setData("text",this.addText(r,"Drums"));const s=this.instrumentButtons[3][2];s.setData("text",this.addText(s,"Other Drums"));const o=this.instrumentButtons[2][3];o.setData("text",this.addText(o,"Gibberish")),[r,s,o,i].forEach(c=>c.setFillStyle(j("#FFF"),.5).setInteractive().on(y.Input.Events.POINTER_DOWN,()=>{this.scene.setVisible(!1)}));const l=`track_scene_${e}`;r.on(y.Input.Events.POINTER_UP,()=>{this.scene.add(l,en,!0,{type:"drums"})}),s.on(y.Input.Events.POINTER_UP,()=>{this.scene.add(l,en,!0,{type:"other"})}),o.on(y.Input.Events.POINTER_UP,()=>{this.scene.add(l,or,!0,{numberOfPads:8})}),i.on(y.Input.Events.POINTER_UP,()=>{this.scene.add(l,pr,!0)}),window.addEventListener("resize",()=>this.resizeScene()),this.resizeScene()}createMatrix(){this.instrumentButtons=[];for(let e=0;e{p.forEach((h,S)=>{h.setSize(r,s).setPosition(r*d,s*S);const x=h.getData("text");if(x){const O=Math.min(h.height,h.width)/5;x.setFontSize(O).setResolution(2).setWordWrapWidth(h.width,!0).setSize(h.width,h.height).setPosition(h.getCenter().x,h.getCenter().y)}})});const o=e?window.innerWidth:window.innerWidth-i,a=e?window.innerHeight-i:window.innerHeight,l=e?0:i,c=e?i:0;this.cameras.main.setPosition(l,c).setViewport(l,c,o,a)}};E(ee,"key","EmptyScene");let Wt=ee;const I=class I{constructor(t){E(this,"state","readyToRecord");E(this,"events",[]);E(this,"eventEmitter",new y.Events.EventEmitter);E(this,"startRecordingTime");E(this,"startPlayingTime",0);E(this,"currentLoopIndex",0);E(this,"loopTimeout",null);this.trackIndex=t,this.log("Loop created")}getStartPlayingTime(){return this.startPlayingTime}getLoopLength(){var t;return(t=this.events.find(({callback:e})=>e==="endOfLoop"))==null?void 0:t.time}handleClick(){switch(this.nextState(),this.state){case"recording":this.startRecording();break;case"playing":this.startPlaying();break;case"readyToPlay":this.stopPlaying();break}}addLoopEvent(t){if(this.isRecording()){this.startRecordingTime||(this.startRecordingTime=I.masterLoop.getStartPlayingTime());const e=Date.now()-this.startRecordingTime;this.events.push({callback:t,time:e}),this.log(`Recording ${t} at time ${e}ms`)}}isPlaying(){return this.state==="playing"}isReadyToPlay(){return this.state==="readyToPlay"}isRecording(){return this.state==="recording"}isReadyToRecord(){return this.state==="readyToRecord"}destroy(){this.eventEmitter.removeAllListeners(),this.isPlaying()&&this.stopPlaying(),this.events=[],this.isMasterLoop()&&(I.masterLoop=null),this.log("Loop destroyed")}addEventListener(t,e){this.eventEmitter.once(t,e)}nextState(){switch(this.state){case"readyToRecord":this.state="recording";break;case"recording":this.state=this.stopRecording();break;case"readyToPlay":this.state="playing";break;case"playing":this.state="readyToPlay";break}}startRecording(){this.events=[],this.log("Recording started"),I.masterLoop||(I.masterLoop=this,this.startRecordingTime=Date.now())}stopRecording(){var e;if(this.events.length===0)return this.log("No events recorded"),"readyToRecord";if(!this.startRecordingTime)throw new Error("startRecordingTime is not set");const t=Date.now()-this.startRecordingTime;if(this.isMasterLoop()){this.events.push({callback:"endOfLoop",time:t});const i=this.events[0].time;this.events=this.events.map(({time:r,callback:s})=>({time:r-i,callback:s}))}else{console.log(this.events);const i=(e=I.masterLoop)==null?void 0:e.getLoopLength();if(!i)throw new Error("masterLoopLength is not set");const s=Math.floor(t/i)*i;this.events=this.events.filter(({time:o})=>o<=s),this.events.push({callback:"endOfLoop",time:s})}return this.log(`Recording stopped at ${t} with ${this.events.length} events, start playing`),"playing"}startPlaying(){var e;const t=()=>{this.currentLoopIndex>=this.events.length&&(this.currentLoopIndex=0),this.currentLoopIndex===0&&(this.log("Loop play (re)-started","#0F0"),this.startPlayingTime=Date.now());const{callback:i,time:r}=this.events[this.currentLoopIndex],s=this.currentLoopIndex===0?0:this.events[this.currentLoopIndex-1].time;this.loopTimeout=setTimeout(()=>{this.log(`Playing event ${i} after ${r}ms`),i!=="endOfLoop"?i():this.eventEmitter.emit("endOfLoop"),this.currentLoopIndex++,t()},r-s)};this.log("Loop play starting"),!this.isMasterLoop()&&((e=I.masterLoop)!=null&&e.isPlaying())?I.masterLoop.addEventListener("endOfLoop",()=>{t()}):t()}stopPlaying(){this.loopTimeout&&clearTimeout(this.loopTimeout),this.currentLoopIndex=0,this.log("Loop stopped")}isMasterLoop(){return this===I.masterLoop}log(t,e="#FFF"){const i=`%cLoop ${this.trackIndex+1}: ${t}`;console.log(i,`color: ${e}`)}};E(I,"masterLoop",null);let Yt=I;const ur={selected:"#DDD",unselected:"#000"},rn={play:"play_arrow",record:"fiber_manual_record",stop:"stop"},_t={idle:"#FFF",readyToRecord:"#0FF",recording:"#FD0041",playing:"#0F0"},f=class f extends y.Scene{constructor(){super(f.key);E(this,"resizeTracks",()=>{const e=window.innerWidth{const p=e?i*c:0,d=e?-1:r*c;s.setSize(i,r).setPosition(p,d);const h=e?s.getCenter().x:s.getCenter().x-i/4,S=e?s.getCenter().y-r/4:s.getCenter().y,x=Math.min(r,i);o.setResolution(3).setSize(i,r).setFontSize(x/4).setPosition(h,S),a.setSize(x/3,x/3).setPosition(h,S),l.setOrigin(e?.5:1,e?1:.5).setPosition(e?s.getCenter().x:s.getRightCenter().x,e?s.getBottomCenter().y:s.getCenter().y)}),this.cameras.main.setViewport(0,0,e?window.innerWidth:i,e?r:window.innerHeight)});f.instance=this}static get sceneWidthHeight(){const e=window.innerWidth,i=window.innerHeight;return Math.max(i,e)/10}static deleteCurrentTrack(){const e=f.tracks.find(i=>i.selected);e?(e.loop.destroy(),e.loopProgressArc.clear(),e.loop=new Yt(f.tracks.indexOf(e)),f.instance.updateControlsState()):console.error("No track selected")}static getTrackSceneKey(e){return`track_scene_${e}`}create(){this.cameras.main.setOrigin(0,0).setPosition(0,0).setViewport(0,0,f.sceneWidthHeight,window.innerHeight).setBackgroundColor("#963"),this.createTracks(),this.events.on("track-selected",()=>{this.updateControlsState()}),this.events.on("instrument-played",({callback:e})=>{var i,r;(r=(i=f.tracks.find(s=>s.selected))==null?void 0:i.loop)==null||r.addLoopEvent(e)})}update(){for(const e of f.tracks)e.loop.isPlaying()&&this.updateProgressArc(e)}getTrackScene(e){return this.scene.get(f.getTrackSceneKey(e))}updateProgressArc(e){const i=e.loop.getLoopLength();if(!i)throw new Error("Loop length is not defined");const s=(Date.now()-e.loop.getStartPlayingTime())/i;e.loopProgressArc.clear(),e.loopProgressArc.lineStyle(4,65280,1);const o=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 Yt(i),button:this.add.rectangle().setOrigin(0,0).setStrokeStyle(2,j("#FFF"),.8).setInteractive().on(y.Input.Events.POINTER_DOWN,()=>this.selectTrack(i)),selected:!1,buttonSelectedCircle:this.add.ellipse(0,0,0,0,j("#FFF")),buttonText:this.add.text(0,0,`${i+1}`,{fontFamily:kt.Text,fontSize:Gt.medium,color:ge.white}).setOrigin(.5,.5).setResolution(2),controlIcon:this.add.text(0,0,"",{fontFamily:kt.Icons,fontSize:Gt.medium,color:ge.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);s?s.scene.bringToTop():this.game.scene.start(Wt.key,{index:e})}}updateControlsState(){f.tracks.forEach((e,i)=>{e.button.setFillStyle(j(ur.unselected)),e.buttonText.setColor(e.selected?"#000":"#FFF"),e.buttonSelectedCircle.setVisible(!0).setFillStyle(j(e.selected?"#FFF":"#000")),this.getTrackScene(i)&&(e.selected&&(e.loop.isRecording()||e.loop.isReadyToRecord())?e.controlIcon.setText(rn.record).setColor(e.loop.isRecording()?_t.recording:_t.idle):e.loop.isPlaying()||e.loop.isReadyToPlay()?e.controlIcon.setText(rn.play).setColor(e.loop.isPlaying()?_t.playing:_t.idle):e.controlIcon.setText("").setColor(_t.idle))})}};E(f,"key","LoopTracksScene"),E(f,"numTracks",5),E(f,"tracks"),E(f,"instance");let _=f;const hr=()=>window.matchMedia("(prefers-color-scheme: dark)").matches;/*! Tweakpane 4.0.4 (c) 2016 cocopon, licensed under the MIT license. */function g(n){return n==null}function Ve(n){return n!==null&&typeof n=="object"}function we(n){return n!==null&&typeof n=="object"}function vr(n,t){if(n.length!==t.length)return!1;for(let e=0;e{const s=n[r],o=t[r];return we(s)&&we(o)?Object.assign(Object.assign({},i),{[r]:rt(s,o)}):Object.assign(Object.assign({},i),{[r]:r in t?o:s})},{})}function Se(n){return Ve(n)?"target"in n:!1}const mr={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 P{static alreadyDisposed(){return new P({type:"alreadydisposed"})}static notBindable(){return new P({type:"notbindable"})}static notCompatible(t,e){return new P({type:"notcompatible",context:{id:`${t}.${e}`}})}static propertyNotFound(t){return new P({type:"propertynotfound",context:{name:t}})}static shouldNeverHappen(){return new P({type:"shouldneverhappen"})}constructor(t){var e;this.message=(e=mr[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 Xt{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(!Xt.isBindable(i))throw P.notBindable();if(!(t in i))throw P.propertyNotFound(t);i[t]=e}}class k{constructor(){this.observers_={}}on(t,e,i){var r;let s=this.observers_[t];return s||(s=this.observers_[t]=[]),s.push({handler:e,key:(r=i==null?void 0:i.key)!==null&&r!==void 0?r:e}),this}off(t,e){const i=this.observers_[t];return i&&(this.observers_[t]=i.filter(r=>r.key!==e)),this}emit(t,e){const i=this.observers_[t];i&&i.forEach(r=>{r.handler(e)})}}class br{constructor(t,e){var i;this.constraint_=e==null?void 0:e.constraint,this.equals_=(i=e==null?void 0:e.equals)!==null&&i!==void 0?i:(r,s)=>r===s,this.emitter=new k,this.rawValue_=t}get constraint(){return this.constraint_}get rawValue(){return this.rawValue_}set rawValue(t){this.setRawValue(t,{forceEmit:!1,last:!0})}setRawValue(t,e){const i=e??{forceEmit:!1,last:!0},r=this.constraint_?this.constraint_.constrain(t):t,s=this.rawValue_;this.equals_(s,r)&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.rawValue_=r,this.emitter.emit("change",{options:i,previousRawValue:s,rawValue:r,sender:this}))}}class fr{constructor(t){this.emitter=new k,this.value_=t}get rawValue(){return this.value_}set rawValue(t){this.setRawValue(t,{forceEmit:!1,last:!0})}setRawValue(t,e){const i=e??{forceEmit:!1,last:!0},r=this.value_;r===t&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.value_=t,this.emitter.emit("change",{options:i,previousRawValue:r,rawValue:this.value_,sender:this}))}}class gr{constructor(t){this.emitter=new k,this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.value_=t,this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_)}get rawValue(){return this.value_.rawValue}onValueBeforeChange_(t){this.emitter.emit("beforechange",Object.assign(Object.assign({},t),{sender:this}))}onValueChange_(t){this.emitter.emit("change",Object.assign(Object.assign({},t),{sender:this}))}}function w(n,t){const e=t==null?void 0:t.constraint,i=t==null?void 0:t.equals;return!e&&!i?new fr(n):new br(n,t)}function wr(n){return[new gr(n),(t,e)=>{n.setRawValue(t,e)}]}class u{constructor(t){this.emitter=new k,this.valMap_=t;for(const e in this.valMap_)this.valMap_[e].emitter.on("change",()=>{this.emitter.emit("change",{key:e,sender:this})})}static createCore(t){return Object.keys(t).reduce((i,r)=>Object.assign(i,{[r]:w(t[r])}),{})}static fromObject(t){const e=this.createCore(t);return new u(e)}get(t){return this.valMap_[t].rawValue}set(t,e){this.valMap_[t].rawValue=e}value(t){return this.valMap_[t]}}class Ot{constructor(t){this.values=u.fromObject({max:t.max,min:t.min})}constrain(t){const e=this.values.get("max"),i=this.values.get("min");return Math.min(Math.max(t,i),e)}}class _r{constructor(t){this.values=u.fromObject({max:t.max,min:t.min})}constrain(t){const e=this.values.get("max"),i=this.values.get("min");let r=t;return g(i)||(r=Math.max(r,i)),g(e)||(r=Math.min(r,e)),r}}class Cr{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 xr{constructor(t){this.text=t}evaluate(){return Number(this.text)}toString(){return this.text}}const yr={"**":(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 Pr{constructor(t,e,i){this.left=e,this.operator=t,this.right=i}evaluate(){const t=yr[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 Er={"+":n=>n,"-":n=>-n,"~":n=>~n};class kr{constructor(t,e){this.operator=t,this.expression=e}evaluate(){const t=Er[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 Te(n){return(t,e)=>{for(let i=0;it.startsWith(r,e))[0];return i?(e+=i.length,e+=Vt(t,e).length,{cursor:e,operator:i}):null}function qr(n,t){return(e,i)=>{const r=n(e,i);if(!r)return null;i=r.cursor;let s=r.evaluable;for(;;){const o=Kr(t,e,i);if(!o)break;i=o.cursor;const a=n(e,i);if(!a)return null;i=a.cursor,s=new Pr(o.operator,s,a.evaluable)}return s?{cursor:i,evaluable:s}:null}}const Ur=[["**"],["*","/","%"],["+","-"],["<<",">>>",">>"],["&"],["^"],["|"]].reduce((n,t)=>qr(n,t),In);function jn(n,t){return t+=Vt(n,t).length,Ur(n,t)}function Gr(n){const t=jn(n,0);return!t||t.cursor+Vt(n,t.cursor).length!==n.length?null:t.evaluable}function U(n){var t;const e=Gr(n);return(t=e==null?void 0:e.evaluate())!==null&&t!==void 0?t:null}function Nn(n){if(typeof n=="number")return n;if(typeof n=="string"){const t=U(n);if(!g(t))return t}return 0}function Wr(n){return String(n)}function R(n){return t=>t.toFixed(Math.max(Math.min(n,20),0))}function b(n,t,e,i,r){const s=(n-t)/(e-t);return i+s*(r-i)}function sn(n){return String(n.toFixed(10)).split(".")[1].replace(/0+$/,"").length}function V(n,t,e){return Math.min(Math.max(n,t),e)}function zn(n,t){return(n%t+t)%t}function Yr(n,t){return g(n.step)?Math.max(sn(t),2):sn(n.step)}function Hn(n){var t;return(t=n.step)!==null&&t!==void 0?t:1}function $n(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 Kn(n,t){return g(n.step)?null:new Cr(n.step,t)}function qn(n){return!g(n.max)&&!g(n.min)?new Ot({max:n.max,min:n.min}):!g(n.max)||!g(n.min)?new _r({max:n.max,min:n.min}):null}function Un(n,t){var e,i,r;return{formatter:(e=n.format)!==null&&e!==void 0?e:R(Yr(n,t)),keyScale:(i=n.keyScale)!==null&&i!==void 0?i:Hn(n),pointerScale:(r=n.pointerScale)!==null&&r!==void 0?r:$n(n,t)}}function Gn(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 Ae(n){return{constraint:n.constraint,textProps:u.fromObject(Un(n.params,n.initialValue))}}class at{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 ie{constructor(t){this.target=t}}class Mt extends ie{constructor(t,e,i){super(t),this.value=e,this.last=i??!0}}class Xr extends ie{constructor(t,e){super(t),this.expanded=e}}class Qr extends ie{constructor(t,e){super(t),this.index=e}}class Zr extends ie{constructor(t,e){super(t),this.native=e}}class Tt extends at{constructor(t){super(t),this.onValueChange_=this.onValueChange_.bind(this),this.emitter_=new k,this.controller.value.emitter.on("change",this.onValueChange_)}get label(){return this.controller.labelController.props.get("label")}set label(t){this.controller.labelController.props.set("label",t)}get key(){return this.controller.value.binding.target.key}get tag(){return this.controller.tag}set tag(t){this.controller.tag=t}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}refresh(){this.controller.value.fetch()}onValueChange_(t){const e=this.controller.value;this.emitter_.emit("change",new Mt(this,e.binding.target.read(),t.options.last))}}class Jr{constructor(t,e){this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.binding=e,this.value_=t,this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_),this.emitter=new k}get rawValue(){return this.value_.rawValue}set rawValue(t){this.value_.rawValue=t}setRawValue(t,e){this.value_.setRawValue(t,e)}fetch(){this.value_.rawValue=this.binding.read()}push(){this.binding.write(this.value_.rawValue)}onValueBeforeChange_(t){this.emitter.emit("beforechange",Object.assign(Object.assign({},t),{sender:this}))}onValueChange_(t){this.push(),this.emitter.emit("change",Object.assign(Object.assign({},t),{sender:this}))}}function ts(n){if(!("binding"in n))return!1;const t=n.binding;return Se(t)&&"read"in t&&"write"in t}function es(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 ns(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 is(n){return n===null?!1:typeof n=="object"}function $(n){return t=>e=>{if(!t&&e===void 0)return{succeeded:!1,value:void 0};if(t&&e===void 0)return{succeeded:!0,value:void 0};const i=n(e);return i!==void 0?{succeeded:!0,value:i}:{succeeded:!1,value:void 0}}}function on(n){return{custom:t=>$(t)(n),boolean:$(t=>typeof t=="boolean"?t:void 0)(n),number:$(t=>typeof t=="number"?t:void 0)(n),string:$(t=>typeof t=="string"?t:void 0)(n),function:$(t=>typeof t=="function"?t:void 0)(n),constant:t=>$(e=>e===t?t:void 0)(n),raw:$(t=>t)(n),object:t=>$(e=>{if(is(e))return es(e,t)})(n),array:t=>$(e=>{if(Array.isArray(e))return ns(e,t)})(n)}}const _e={optional:on(!0),required:on(!1)};function C(n,t){const e=t(_e),i=_e.required.object(e)(n);return i.succeeded?i.value:void 0}function M(n,t,e,i){if(t&&!t(n))return!1;const r=C(n,e);return r?i(r):!1}function D(n,t){var e;return rt((e=n==null?void 0:n())!==null&&e!==void 0?e:{},t)}function it(n){return"value"in n}function Wn(n){if(!Ve(n)||!("binding"in n))return!1;const t=n.binding;return Se(t)}const N="http://www.w3.org/2000/svg";function Qt(n){n.offsetHeight}function rs(n,t){const e=n.style.transition;n.style.transition="none",t(),n.style.transition=e}function Re(n){return n.ontouchstart!==void 0}function ss(){return globalThis}function os(){return ss().document}function as(n){const t=n.ownerDocument.defaultView;return t&&"document"in t?n.getContext("2d",{willReadFrequently:!0}):null}const ls={check:'',dropdown:'',p2dpad:''};function re(n,t){const e=n.createElementNS(N,"svg");return e.innerHTML=ls[t],e}function Yn(n,t,e){n.insertBefore(t,n.children[e])}function Oe(n){n.parentElement&&n.parentElement.removeChild(n)}function Xn(n){for(;n.children.length>0;)n.removeChild(n.children[0])}function cs(n){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])}function Qn(n){return n.relatedTarget?n.relatedTarget:"explicitOriginalTarget"in n?n.explicitOriginalTarget:null}function q(n,t){n.emitter.on("change",e=>{t(e.rawValue)}),t(n.rawValue)}function z(n,t,e){q(n.value(t),e)}const ps="tp";function v(n){return(e,i)=>[ps,"-",n,"v",e?`_${e}`:"",i?`-${i}`:""].join("")}const Ct=v("lbl");function ds(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 Zn{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(Ct()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(Ct("l")),z(e.props,"label",s=>{g(s)?this.element.classList.add(Ct(void 0,"nol")):(this.element.classList.remove(Ct(void 0,"nol")),cs(i),i.appendChild(ds(t,s)))}),this.element.appendChild(i),this.labelElement=i;const r=t.createElement("div");r.classList.add(Ct("v")),this.element.appendChild(r),this.valueElement=r}}class Jn{constructor(t,e){this.props=e.props,this.valueController=e.valueController,this.viewProps=e.valueController.viewProps,this.view=new Zn(t,{props:e.props,viewProps:this.viewProps}),this.view.valueElement.appendChild(this.valueController.view.element)}importProps(t){return M(t,null,e=>({label:e.optional.string}),e=>(this.props.set("label",e.label),!0))}exportProps(){return D(null,{label:this.props.get("label")})}}function us(){return["veryfirst","first","last","verylast"]}const an=v(""),ln={veryfirst:"vfst",first:"fst",last:"lst",verylast:"vlst"};class se{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",()=>{us().forEach(i=>{e.classList.remove(an(void 0,ln[i]))}),this.blade.get("positions").forEach(i=>{e.classList.add(an(void 0,ln[i]))})}),this.viewProps.handleDispose(()=>{Oe(e)})}get parent(){return this.parent_}set parent(t){this.parent_=t,this.viewProps.set("parent",this.parent_?this.parent_.viewProps:null)}importState(t){return M(t,null,e=>({disabled:e.required.boolean,hidden:e.required.boolean}),e=>(this.viewProps.importState(e),!0))}exportState(){return D(null,Object.assign({},this.viewProps.exportState()))}}class st extends se{constructor(t,e){if(e.value!==e.valueController.value)throw P.shouldNeverHappen();const i=e.valueController.viewProps,r=new Jn(t,{blade:e.blade,props:e.props,valueController:e.valueController});super(Object.assign(Object.assign({},e),{view:new Zn(t,{props:e.props,viewProps:i}),viewProps:i})),this.labelController=r,this.value=e.value,this.valueController=e.valueController,this.view.valueElement.appendChild(this.valueController.view.element)}importState(t){return M(t,e=>{var i,r,s;return super.importState(e)&&this.labelController.importProps(e)&&((s=(r=(i=this.valueController).importProps)===null||r===void 0?void 0:r.call(i,t))!==null&&s!==void 0?s:!0)},e=>({value:e.optional.raw}),e=>(e.value&&(this.value.rawValue=e.value),!0))}exportState(){var t,e,i;return D(()=>super.exportState(),Object.assign(Object.assign({value:this.value.rawValue},this.labelController.exportProps()),(i=(e=(t=this.valueController).exportProps)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:{}))}}function cn(n){const t=Object.assign({},n);return delete t.value,t}class ti extends st{constructor(t,e){super(t,e),this.tag=e.tag}importState(t){return M(t,e=>super.importState(cn(t)),e=>({tag:e.optional.string}),e=>(this.tag=e.tag,!0))}exportState(){return D(()=>cn(super.exportState()),{binding:{key:this.value.binding.target.key,value:this.value.binding.target.read()},tag:this.tag})}}function hs(n){return it(n)&&Wn(n.value)}class vs extends ti{importState(t){return M(t,e=>super.importState(e),e=>({binding:e.required.object({value:e.required.raw})}),e=>(this.value.binding.inject(e.binding.value),this.value.fetch(),!0))}}function ms(n){return it(n)&&ts(n.value)}function ei(n,t){for(;n.lengthn.length?e.splice(0,e.length-n.length):ei(e,n.length),e}class ws{constructor(t){this.emitter=new k,this.onTick_=this.onTick_.bind(this),this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.binding=t.binding,this.value_=w(bs(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=gs(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 _s(n){if(!("binding"in n))return!1;const t=n.binding;return Se(t)&&"read"in t&&!("write"in t)}class Cs extends ti{exportState(){return D(()=>super.exportState(),{binding:{readonly:!0}})}}function xs(n){return it(n)&&_s(n.value)}class ys extends at{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 Zr(this,s.nativeEvent))}),this}off(t,e){return this.controller.buttonController.emitter.off(t,e),this}}function Ps(n,t,e){e?n.classList.add(t):n.classList.remove(t)}function mt(n,t){return e=>{Ps(n,t,e)}}function Me(n,t){q(n,e=>{t.textContent=e??""})}const ce=v("btn");class Es{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(ce()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("button");i.classList.add(ce("b")),e.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const r=t.createElement("div");r.classList.add(ce("t")),Me(e.props.value("title"),r),this.buttonElement.appendChild(r)}}class ks{constructor(t,e){this.emitter=new k,this.onClick_=this.onClick_.bind(this),this.props=e.props,this.viewProps=e.viewProps,this.view=new Es(t,{props:this.props,viewProps:this.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}importProps(t){return M(t,null,e=>({title:e.optional.string}),e=>(this.props.set("title",e.title),!0))}exportProps(){return D(null,{title:this.props.get("title")})}onClick_(t){this.emitter.emit("click",{nativeEvent:t,sender:this})}}class pn extends se{constructor(t,e){const i=new ks(t,{props:e.buttonProps,viewProps:e.viewProps}),r=new Jn(t,{blade:e.blade,props:e.labelProps,valueController:i});super({blade:e.blade,view:r.view,viewProps:e.viewProps}),this.buttonController=i,this.labelController=r}importState(t){return M(t,e=>super.importState(e)&&this.buttonController.importProps(e)&&this.labelController.importProps(e),()=>({}),()=>!0)}exportState(){return D(()=>super.exportState(),Object.assign(Object.assign({},this.buttonController.exportProps()),this.labelController.exportProps()))}}class ni{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 bt=new ni("2.0.4");function L(n){return Object.assign({core:bt},n)}const Vs=L({id:"button",type:"blade",accept(n){const t=C(n,e=>({title:e.required.string,view:e.required.constant("button"),label:e.optional.string}));return t?{params:t}:null},controller(n){return new pn(n.document,{blade:n.blade,buttonProps:u.fromObject({title:n.params.title}),labelProps:u.fromObject({label:n.params.label}),viewProps:n.viewProps})},api(n){return n.controller instanceof pn?new ys(n.controller):null}});function Ss(n,t){return n.addBlade(Object.assign(Object.assign({},t),{view:"button"}))}function Ts(n,t){return n.addBlade(Object.assign(Object.assign({},t),{view:"folder"}))}function Ls(n,t){return n.addBlade(Object.assign(Object.assign({},t),{view:"tab"}))}function As(n){return Ve(n)?"refresh"in n&&typeof n.refresh=="function":!1}function Rs(n,t){if(!Xt.isBindable(n))throw P.notBindable();return new Xt(n,t)}class Os{constructor(t,e){this.onRackValueChange_=this.onRackValueChange_.bind(this),this.controller_=t,this.emitter_=new k,this.pool_=e,this.controller_.rack.emitter.on("valuechange",this.onRackValueChange_)}get children(){return this.controller_.rack.children.map(t=>this.pool_.createApi(t))}addBinding(t,e,i){const r=i??{},s=this.controller_.element.ownerDocument,o=this.pool_.createBinding(s,Rs(t,e),r),a=this.pool_.createBindingApi(o);return this.add(a,r.index)}addFolder(t){return Ts(this,t)}addButton(t){return Ss(this,t)}addTab(t){return Ls(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=>{As(t)&&t.refresh()})}onRackValueChange_(t){const e=t.bladeController,i=this.pool_.createApi(e),r=Wn(e.value)?e.value.binding:null;this.emitter_.emit("change",new Mt(i,r?r.target.read():e.value.rawValue,t.options.last))}}class De extends at{constructor(t,e){super(t),this.rackApi_=new Os(t.rackController,e)}refresh(){this.rackApi_.refresh()}}class Fe extends se{constructor(t){super({blade:t.blade,view:t.view,viewProps:t.rackController.viewProps}),this.rackController=t.rackController}importState(t){return M(t,e=>super.importState(e),e=>({children:e.required.array(e.required.raw)}),e=>this.rackController.rack.children.every((i,r)=>i.importState(e.children[r])))}exportState(){return D(()=>super.exportState(),{children:this.rackController.rack.children.map(t=>t.exportState())})}}function Ce(n){return"rackController"in n}class Ms{constructor(t){this.emitter=new k,this.items_=[],this.cache_=new Set,this.onSubListAdd_=this.onSubListAdd_.bind(this),this.onSubListRemove_=this.onSubListRemove_.bind(this),this.extract_=t}get items(){return this.items_}allItems(){return Array.from(this.cache_)}find(t){for(const e of this.allItems())if(t(e))return e;return null}includes(t){return this.cache_.has(t)}add(t,e){if(this.includes(t))throw P.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 Ds(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=Ds(this.find(it),t.sender);if(!e)throw P.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 Be{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 Bs({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&&Yn(this.element,t.bladeController.view.element,t.index)}onRackRemove_(t){t.root&&Oe(t.bladeController.view.element)}}function ft(){return new u({positions:w([],{equals:vr})})}class Dt extends u{constructor(t){super(t)}static create(t){const e={completed:!0,expanded:t,expandedHeight:null,shouldFixHeight:!1,temporaryExpanded:null},i=u.createCore(e);return new Dt(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 Is(n,t){let e=0;return rs(t,()=>{n.set("expandedHeight",null),n.set("temporaryExpanded",!0),Qt(t),e=t.clientHeight,n.set("temporaryExpanded",null),Qt(t)}),e}function dn(n,t){t.style.height=n.styleHeight}function Ie(n,t){n.value("expanded").emitter.on("beforechange",()=>{if(n.set("completed",!1),g(n.get("expandedHeight"))){const e=Is(n,t);e>0&&n.set("expandedHeight",e)}n.set("shouldFixHeight",!0),Qt(t)}),n.emitter.on("change",()=>{dn(n,t)}),dn(n,t),t.addEventListener("transitionend",e=>{e.propertyName==="height"&&n.cleanUpTransition()})}class ii extends De{constructor(t,e){super(t,e),this.emitter_=new k,this.controller.foldable.value("expanded").emitter.on("change",i=>{this.emitter_.emit("fold",new Xr(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 ri=v("cnt");class js{constructor(t,e){var i;this.className_=v((i=e.viewName)!==null&&i!==void 0?i:"fld"),this.element=t.createElement("div"),this.element.classList.add(this.className_(),ri()),e.viewProps.bindClassModifiers(this.element),this.foldable_=e.foldable,this.foldable_.bindExpandedClass(this.element,this.className_(void 0,"expanded")),z(this.foldable_,"completed",mt(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")),Me(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 xe extends Fe{constructor(t,e){var i;const r=Dt.create((i=e.expanded)!==null&&i!==void 0?i:!0),s=new js(t,{foldable:r,props:e.props,viewName:e.root?"rot":void 0,viewProps:e.viewProps});super(Object.assign(Object.assign({},e),{rackController:new Be({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,Ie(this.foldable,this.view.containerElement),this.rackController.rack.emitter.on("add",()=>{this.foldable.cleanUpTransition()}),this.rackController.rack.emitter.on("remove",()=>{this.foldable.cleanUpTransition()}),this.view.buttonElement.addEventListener("click",this.onTitleClick_)}get document(){return this.view.element.ownerDocument}importState(t){return M(t,e=>super.importState(e),e=>({expanded:e.required.boolean,title:e.optional.string}),e=>(this.foldable.set("expanded",e.expanded),this.props.set("title",e.title),!0))}exportState(){return D(()=>super.exportState(),{expanded:this.foldable.get("expanded"),title:this.props.get("title")})}onTitleClick_(){this.foldable.set("expanded",!this.foldable.get("expanded"))}}const Ns=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 xe(n.document,{blade:n.blade,expanded:n.params.expanded,props:u.fromObject({title:n.params.title}),viewProps:n.viewProps})},api(n){return n.controller instanceof xe?new ii(n.controller,n.pool):null}}),zs=v("");function un(n,t){return mt(n,zs(void 0,t))}class W extends u{constructor(t){var e;super(t),this.onDisabledChange_=this.onDisabledChange_.bind(this),this.onParentChange_=this.onParentChange_.bind(this),this.onParentGlobalDisabledChange_=this.onParentGlobalDisabledChange_.bind(this),[this.globalDisabled_,this.setGlobalDisabled_]=wr(w(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 W(u.createCore({disabled:(e=s.disabled)!==null&&e!==void 0?e:!1,disposed:!1,hidden:(i=s.hidden)!==null&&i!==void 0?i:!1,parent:(r=s.parent)!==null&&r!==void 0?r:null}))}get globalDisabled(){return this.globalDisabled_}bindClassModifiers(t){q(this.globalDisabled_,un(t,"disabled")),z(this,"hidden",un(t,"hidden"))}bindDisabled(t){q(this.globalDisabled_,e=>{t.disabled=e})}bindTabIndex(t){q(this.globalDisabled_,e=>{t.tabIndex=e?-1:0})}handleDispose(t){this.value("disposed").emitter.on("change",e=>{e&&t()})}importState(t){this.set("disabled",t.disabled),this.set("hidden",t.hidden)}exportState(){return{disabled:this.get("disabled"),hidden:this.get("hidden")}}getGlobalDisabled_(){const t=this.get("parent");return(t?t.globalDisabled.rawValue:!1)||this.get("disabled")}updateGlobalDisabled_(){this.setGlobalDisabled_(this.getGlobalDisabled_())}onDisabledChange_(){this.updateGlobalDisabled_()}onParentGlobalDisabledChange_(){this.updateGlobalDisabled_()}onParentChange_(t){var e;const i=t.previousRawValue;i==null||i.globalDisabled.emitter.off("change",this.onParentGlobalDisabledChange_),(e=this.get("parent"))===null||e===void 0||e.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_),this.updateGlobalDisabled_()}}const hn=v("tbp");class Hs{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(hn()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(hn("c")),this.element.appendChild(i),this.containerElement=i}}const xt=v("tbi");class $s{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(xt()),e.viewProps.bindClassModifiers(this.element),z(e.props,"selected",s=>{s?this.element.classList.add(xt(void 0,"sel")):this.element.classList.remove(xt(void 0,"sel"))});const i=t.createElement("button");i.classList.add(xt("b")),e.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const r=t.createElement("div");r.classList.add(xt("t")),Me(e.props.value("title"),r),this.buttonElement.appendChild(r),this.titleElement=r}}class Ks{constructor(t,e){this.emitter=new k,this.onClick_=this.onClick_.bind(this),this.props=e.props,this.viewProps=e.viewProps,this.view=new $s(t,{props:e.props,viewProps:e.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}onClick_(){this.emitter.emit("click",{sender:this})}}class ye extends Fe{constructor(t,e){const i=new Hs(t,{viewProps:e.viewProps});super(Object.assign(Object.assign({},e),{rackController:new Be({blade:e.blade,element:i.containerElement,viewProps:e.viewProps}),view:i})),this.onItemClick_=this.onItemClick_.bind(this),this.ic_=new Ks(t,{props:e.itemProps,viewProps:W.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 M(t,e=>super.importState(e),e=>({selected:e.required.boolean,title:e.required.string}),e=>(this.ic_.props.set("selected",e.selected),this.ic_.props.set("title",e.title),!0))}exportState(){return D(()=>super.exportState(),{selected:this.ic_.props.get("selected"),title:this.ic_.props.get("title")})}onItemClick_(){this.props.set("selected",!0)}}class qs extends De{constructor(t,e){super(t,e),this.emitter_=new k,this.onSelect_=this.onSelect_.bind(this),this.pool_=e,this.rackApi_.on("change",i=>{this.emitter_.emit("change",i)}),this.controller.tab.selectedIndex.emitter.on("change",this.onSelect_)}get pages(){return this.rackApi_.children}addPage(t){const e=this.controller.view.element.ownerDocument,i=new ye(e,{blade:ft(),itemProps:u.fromObject({selected:!1,title:t.title}),props:u.fromObject({selected:!1}),viewProps:W.create()}),r=this.pool_.createApi(i);return this.rackApi_.add(r,t.index)}removePage(t){this.rackApi_.remove(this.rackApi_.children[t])}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}onSelect_(t){this.emitter_.emit("select",new Qr(this,t.rawValue))}}class Us extends De{get title(){var t;return(t=this.controller.itemController.props.get("title"))!==null&&t!==void 0?t:""}set title(t){this.controller.itemController.props.set("title",t)}get selected(){return this.controller.props.get("selected")}set selected(t){this.controller.props.set("selected",t)}get children(){return this.rackApi_.children}addButton(t){return this.rackApi_.addButton(t)}addFolder(t){return this.rackApi_.addFolder(t)}addTab(t){return this.rackApi_.addTab(t)}add(t,e){this.rackApi_.add(t,e)}remove(t){this.rackApi_.remove(t)}addBinding(t,e,i){return this.rackApi_.addBinding(t,e,i)}addBlade(t){return this.rackApi_.addBlade(t)}}const vn=-1;class Gs{constructor(){this.onItemSelectedChange_=this.onItemSelectedChange_.bind(this),this.empty=w(!0),this.selectedIndex=w(vn),this.items_=[]}add(t,e){const i=e??this.items_.length;this.items_.splice(i,0,t),t.emitter.on("change",this.onItemSelectedChange_),this.keepSelection_()}remove(t){const e=this.items_.indexOf(t);e<0||(this.items_.splice(e,1),t.emitter.off("change",this.onItemSelectedChange_),this.keepSelection_())}keepSelection_(){if(this.items_.length===0){this.selectedIndex.rawValue=vn,this.empty.rawValue=!0;return}const t=this.items_.findIndex(e=>e.rawValue);t<0?(this.items_.forEach((e,i)=>{e.rawValue=i===0}),this.selectedIndex.rawValue=0):(this.items_.forEach((e,i)=>{e.rawValue=i===t}),this.selectedIndex.rawValue=t),this.empty.rawValue=!1}onItemSelectedChange_(t){if(t.rawValue){const e=this.items_.findIndex(i=>i===t.sender);this.items_.forEach((i,r)=>{i.rawValue=r===e}),this.selectedIndex.rawValue=e}else this.keepSelection_()}}const yt=v("tab");class Ws{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(yt(),ri()),e.viewProps.bindClassModifiers(this.element),q(e.empty,mt(this.element,yt(void 0,"nop")));const i=t.createElement("div");i.classList.add(yt("t")),this.element.appendChild(i),this.itemsElement=i;const r=t.createElement("div");r.classList.add(yt("i")),this.element.appendChild(r);const s=t.createElement("div");s.classList.add(yt("c")),this.element.appendChild(s),this.contentsElement=s}}class mn extends Fe{constructor(t,e){const i=new Gs,r=new Ws(t,{empty:i.empty,viewProps:e.viewProps});super({blade:e.blade,rackController:new Be({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;Yn(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;Oe(e.itemController.view.element),e.itemController.viewProps.set("parent",null),this.tab.remove(e.props.value("selected"))}}const si=L({id:"tab",type:"blade",accept(n){const t=C(n,e=>({pages:e.required.array(e.required.object({title:e.required.string})),view:e.required.constant("tab")}));return!t||t.pages.length===0?null:{params:t}},controller(n){const t=new mn(n.document,{blade:n.blade,viewProps:n.viewProps});return n.params.pages.forEach(e=>{const i=new ye(n.document,{blade:ft(),itemProps:u.fromObject({selected:!1,title:e.title}),props:u.fromObject({selected:!1}),viewProps:W.create()});t.add(i)}),t},api(n){return n.controller instanceof mn?new qs(n.controller,n.pool):n.controller instanceof ye?new Us(n.controller,n.pool):null}});function Ys(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:ft(),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:W.create({disabled:i==null?void 0:i.disabled,hidden:i==null?void 0:i.hidden})})}class je extends Tt{get options(){return this.controller.valueController.props.get("options")}set options(t){this.controller.valueController.props.set("options",t)}}class Xs{constructor(){this.disabled=!1,this.emitter=new k}dispose(){}tick(){this.disabled||this.emitter.emit("tick",{sender:this})}}class Qs{constructor(t,e){this.disabled_=!1,this.timerId_=null,this.onTick_=this.onTick_.bind(this),this.doc_=t,this.emitter=new k,this.interval_=e,this.setTimer_()}get disabled(){return this.disabled_}set disabled(t){this.disabled_=t,this.disabled_?this.clearTimer_():this.setTimer_()}dispose(){this.clearTimer_()}clearTimer_(){if(this.timerId_===null)return;const t=this.doc_.defaultView;t&&t.clearInterval(this.timerId_),this.timerId_=null}setTimer_(){if(this.clearTimer_(),this.interval_<=0)return;const t=this.doc_.defaultView;t&&(this.timerId_=t.setInterval(this.onTick_,this.interval_))}onTick_(){this.disabled_||this.emitter.emit("tick",{sender:this})}}class Ft{constructor(t){this.constraints=t}constrain(t){return this.constraints.reduce((e,i)=>i.constrain(e),t)}}function Zt(n,t){if(n instanceof t)return n;if(n instanceof Ft){const e=n.constraints.reduce((i,r)=>i||(r instanceof t?r:null),null);if(e)return e}return null}class Bt{constructor(t){this.values=u.fromObject({options:t})}constrain(t){const e=this.values.get("options");return e.length===0||e.filter(r=>r.value===t).length>0?t:e[0].value}}function It(n){var t;const e=_e;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 Ne(n){if(Array.isArray(n))return n;const t=[];return Object.keys(n).forEach(e=>{t.push({text:e,value:n[e]})}),t}function ze(n){return g(n)?null:new Bt(Ne(n))}const pe=v("lst");class Zs{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.props_=e.props,this.element=t.createElement("div"),this.element.classList.add(pe()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("select");i.classList.add(pe("s")),e.viewProps.bindDisabled(i),this.element.appendChild(i),this.selectElement=i;const r=t.createElement("div");r.classList.add(pe("m")),r.appendChild(re(t,"dropdown")),this.element.appendChild(r),e.value.emitter.on("change",this.onValueChange_),this.value_=e.value,z(this.props_,"options",s=>{Xn(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 tt{constructor(t,e){this.onSelectChange_=this.onSelectChange_.bind(this),this.props=e.props,this.value=e.value,this.viewProps=e.viewProps,this.view=new Zs(t,{props:this.props,value:this.value,viewProps:this.viewProps}),this.view.selectElement.addEventListener("change",this.onSelectChange_)}onSelectChange_(t){const e=t.currentTarget;this.value.rawValue=this.props.get("options")[e.selectedIndex].value}importProps(t){return M(t,null,e=>({options:e.required.custom(It)}),e=>(this.props.set("options",Ne(e.options)),!0))}exportProps(){return D(null,{options:this.props.get("options")})}}const bn=v("pop");class Js{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(bn()),e.viewProps.bindClassModifiers(this.element),q(e.shows,mt(this.element,bn(void 0,"v")))}}class oi{constructor(t,e){this.shows=w(!1),this.viewProps=e.viewProps,this.view=new Js(t,{shows:this.shows,viewProps:this.viewProps})}}const fn=v("txt");class to{constructor(t,e){this.onChange_=this.onChange_.bind(this),this.element=t.createElement("div"),this.element.classList.add(fn()),e.viewProps.bindClassModifiers(this.element),this.props_=e.props,this.props_.emitter.on("change",this.onChange_);const i=t.createElement("input");i.classList.add(fn("i")),i.type="text",e.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,e.value.emitter.on("change",this.onChange_),this.value_=e.value,this.refresh()}refresh(){const t=this.props_.get("formatter");this.inputElement.value=t(this.value_.rawValue)}onChange_(){this.refresh()}}class Lt{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 to(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 eo(n){return String(n)}function ai(n){return n==="false"?!1:!!n}function gn(n){return eo(n)}function no(n){return t=>n.reduce((e,i)=>e!==null?e:i(t),null)}const io=R(0);function Jt(n){return io(n)+"%"}function li(n){return String(n)}function Pe(n){return n}function gt({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 At(n){return{altKey:n.altKey,downKey:n.key==="ArrowDown",shiftKey:n.shiftKey,upKey:n.key==="ArrowUp"}}function G(n){return{altKey:n.altKey,downKey:n.key==="ArrowLeft",shiftKey:n.shiftKey,upKey:n.key==="ArrowRight"}}function ro(n){return n==="ArrowUp"||n==="ArrowDown"}function ci(n){return ro(n)||n==="ArrowLeft"||n==="ArrowRight"}function de(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 lt{constructor(t){this.lastTouch_=null,this.onDocumentMouseMove_=this.onDocumentMouseMove_.bind(this),this.onDocumentMouseUp_=this.onDocumentMouseUp_.bind(this),this.onMouseDown_=this.onMouseDown_.bind(this),this.onTouchEnd_=this.onTouchEnd_.bind(this),this.onTouchMove_=this.onTouchMove_.bind(this),this.onTouchStart_=this.onTouchStart_.bind(this),this.elem_=t,this.emitter=new k,t.addEventListener("touchstart",this.onTouchStart_,{passive:!1}),t.addEventListener("touchmove",this.onTouchMove_,{passive:!0}),t.addEventListener("touchend",this.onTouchEnd_),t.addEventListener("mousedown",this.onMouseDown_)}computePosition_(t){const e=this.elem_.getBoundingClientRect();return{bounds:{width:e.width,height:e.height},point:t?{x:t.x,y:t.y}:null}}onMouseDown_(t){var e;t.preventDefault(),(e=t.currentTarget)===null||e===void 0||e.focus();const i=this.elem_.ownerDocument;i.addEventListener("mousemove",this.onDocumentMouseMove_),i.addEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("down",{altKey:t.altKey,data:this.computePosition_(de(t,this.elem_)),sender:this,shiftKey:t.shiftKey})}onDocumentMouseMove_(t){this.emitter.emit("move",{altKey:t.altKey,data:this.computePosition_(de(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_(de(t,this.elem_)),sender:this,shiftKey:t.shiftKey})}onTouchStart_(t){t.preventDefault();const e=t.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("down",{altKey:t.altKey,data:this.computePosition_(e?{x:e.clientX-i.left,y:e.clientY-i.top}:void 0),sender:this,shiftKey:t.shiftKey}),this.lastTouch_=e}onTouchMove_(t){const e=t.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("move",{altKey:t.altKey,data:this.computePosition_(e?{x:e.clientX-i.left,y:e.clientY-i.top}:void 0),sender:this,shiftKey:t.shiftKey}),this.lastTouch_=e}onTouchEnd_(t){var e;const i=(e=t.targetTouches.item(0))!==null&&e!==void 0?e:this.lastTouch_,r=this.elem_.getBoundingClientRect();this.emitter.emit("up",{altKey:t.altKey,data:this.computePosition_(i?{x:i.clientX-r.left,y:i.clientY-r.top}:void 0),sender:this,shiftKey:t.shiftKey})}}const F=v("txt");class so{constructor(t,e){this.onChange_=this.onChange_.bind(this),this.props_=e.props,this.props_.emitter.on("change",this.onChange_),this.element=t.createElement("div"),this.element.classList.add(F(),F(void 0,"num")),e.arrayPosition&&this.element.classList.add(F(void 0,e.arrayPosition)),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("input");i.classList.add(F("i")),i.type="text",e.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,this.onDraggingChange_=this.onDraggingChange_.bind(this),this.dragging_=e.dragging,this.dragging_.emitter.on("change",this.onDraggingChange_),this.element.classList.add(F()),this.inputElement.classList.add(F("i"));const r=t.createElement("div");r.classList.add(F("k")),this.element.appendChild(r),this.knobElement=r;const s=t.createElementNS(N,"svg");s.classList.add(F("g")),this.knobElement.appendChild(s);const o=t.createElementNS(N,"path");o.classList.add(F("gb")),s.appendChild(o),this.guideBodyElem_=o;const a=t.createElementNS(N,"path");a.classList.add(F("gh")),s.appendChild(a),this.guideHeadElem_=a;const l=t.createElement("div");l.classList.add(v("tt")()),this.knobElement.appendChild(l),this.tooltipElem_=l,e.value.emitter.on("change",this.onChange_),this.value=e.value,this.refresh()}onDraggingChange_(t){if(t.rawValue===null){this.element.classList.remove(F(void 0,"drg"));return}this.element.classList.add(F(void 0,"drg"));const e=t.rawValue/this.props_.get("pointerScale"),i=e+(e>0?-1:e<0?1:0),r=V(-i,-4,4);this.guideHeadElem_.setAttributeNS(null,"d",[`M ${i+r},0 L${i},4 L${i+r},8`,`M ${e},-1 L${e},9`].join(" ")),this.guideBodyElem_.setAttributeNS(null,"d",`M 0,4 L${e},4`);const s=this.props_.get("formatter");this.tooltipElem_.textContent=s(this.value.rawValue),this.tooltipElem_.style.left=`${e}px`}refresh(){const t=this.props_.get("formatter");this.inputElement.value=t(this.value.rawValue)}onChange_(){this.refresh()}}class jt{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_=w(null),this.view=new so(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 lt(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"),At(t));e!==0&&this.value.setRawValue(this.constrainValue_(this.value.rawValue+e),{forceEmit:!1,last:!1})}onInputKeyUp_(t){A(this.props.get("keyScale"),At(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 ue=v("sld");class oo{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(ue()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(ue("t")),e.viewProps.bindTabIndex(i),this.element.appendChild(i),this.trackElement=i;const r=t.createElement("div");r.classList.add(ue("k")),this.trackElement.appendChild(r),this.knobElement=r,e.value.emitter.on("change",this.onChange_),this.value=e.value,this.update_()}update_(){const t=V(b(this.value.rawValue,this.props_.get("min"),this.props_.get("max"),0,100),0,100);this.knobElement.style.width=`${t}%`}onChange_(){this.update_()}}class ao{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 oo(t,{props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new lt(this.view.trackElement),this.ptHandler_.emitter.on("down",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("move",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.trackElement.addEventListener("keydown",this.onKeyDown_),this.view.trackElement.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(t,e){t.point&&this.value.setRawValue(b(V(t.point.x,0,t.bounds.width),0,t.bounds.width,this.props.get("min"),this.props.get("max")),e)}onPointerDownOrMove_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerUp_(t){this.handlePointerEvent_(t.data,{forceEmit:!0,last:!0})}onKeyDown_(t){const e=A(this.props.get("keyScale"),G(t));e!==0&&this.value.setRawValue(this.value.rawValue+e,{forceEmit:!1,last:!1})}onKeyUp_(t){A(this.props.get("keyScale"),G(t))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const he=v("sldtxt");class lo{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(he());const i=t.createElement("div");i.classList.add(he("s")),this.sliderView_=e.sliderView,i.appendChild(this.sliderView_.element),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(he("t")),this.textView_=e.textView,r.appendChild(this.textView_.element),this.element.appendChild(r)}}class te{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.sliderC_=new ao(t,{props:e.sliderProps,value:e.value,viewProps:this.viewProps}),this.textC_=new jt(t,{parser:e.parser,props:e.textProps,sliderProps:e.sliderProps,value:e.value,viewProps:e.viewProps}),this.view=new lo(t,{sliderView:this.sliderC_.view,textView:this.textC_.view})}get sliderController(){return this.sliderC_}get textController(){return this.textC_}importProps(t){return M(t,null,e=>({max:e.required.number,min:e.required.number}),e=>{const i=this.sliderC_.props;return i.set("max",e.max),i.set("min",e.min),!0})}exportProps(){const t=this.sliderC_.props;return D(null,{max:t.get("max"),min:t.get("min")})}}function pi(n){return{sliderProps:new u({keyScale:n.keyScale,max:n.max,min:n.min}),textProps:new u({formatter:w(n.formatter),keyScale:n.keyScale,pointerScale:w(n.pointerScale)})}}const co={containerUnitSize:"cnt-usz"};function di(n){return`--${co[n]}`}function Rt(n){return Gn(n)}function Z(n){if(we(n))return C(n,Rt)}function K(n,t){if(!n)return;const e=[],i=Kn(n,t);i&&e.push(i);const r=qn(n);return r&&e.push(r),new Ft(e)}function po(n){return n?n.major===bt.major:!1}function ui(n){if(n==="inline"||n==="popup")return n}function Nt(n,t){n.write(t)}const $t=v("ckb");class uo{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.element=t.createElement("div"),this.element.classList.add($t()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("label");i.classList.add($t("l")),this.element.appendChild(i),this.labelElement=i;const r=t.createElement("input");r.classList.add($t("i")),r.type="checkbox",this.labelElement.appendChild(r),this.inputElement=r,e.viewProps.bindDisabled(this.inputElement);const s=t.createElement("div");s.classList.add($t("w")),this.labelElement.appendChild(s);const o=re(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 ho{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 uo(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 vo(n){const t=[],e=ze(n.options);return e&&t.push(e),new Ft(t)}const mo=L({id:"input-bool",type:"input",accept:(n,t)=>{if(typeof n!="boolean")return null;const e=C(t,i=>({options:i.optional.custom(It),readonly:i.optional.constant(!1)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>ai,constraint:n=>vo(n.params),writer:n=>Nt},controller:n=>{const t=n.document,e=n.value,i=n.constraint,r=i&&Zt(i,Bt);return r?new tt(t,{props:new u({options:r.values.value("options")}),value:e,viewProps:n.viewProps}):new ho(t,{value:e,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="boolean"?null:n.controller.valueController instanceof tt?new je(n.controller):null}}),nt=v("col");class bo{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(nt()),e.foldable.bindExpandedClass(this.element,nt(void 0,"expanded")),z(e.foldable,"completed",mt(this.element,nt(void 0,"cpl")));const i=t.createElement("div");i.classList.add(nt("h")),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(nt("s")),i.appendChild(r),this.swatchElement=r;const s=t.createElement("div");if(s.classList.add(nt("t")),i.appendChild(s),this.textElement=s,e.pickerLayout==="inline"){const o=t.createElement("div");o.classList.add(nt("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}}function fo(n,t,e){const i=V(n/255,0,1),r=V(t/255,0,1),s=V(e/255,0,1),o=Math.max(i,r,s),a=Math.min(i,r,s),l=o-a;let c=0,p=0;const d=(a+o)/2;return l!==0&&(p=l/(1-Math.abs(o+a-1)),i===o?c=(r-s)/l:r===o?c=2+(s-i)/l:c=4+(i-r)/l,c=c/6+(c<0?1:0)),[c*360,p*100,d*100]}function go(n,t,e){const i=(n%360+360)%360,r=V(t/100,0,1),s=V(e/100,0,1),o=(1-Math.abs(2*s-1))*r,a=o*(1-Math.abs(i/60%2-1)),l=s-o/2;let c,p,d;return i>=0&&i<60?[c,p,d]=[o,a,0]:i>=60&&i<120?[c,p,d]=[a,o,0]:i>=120&&i<180?[c,p,d]=[0,o,a]:i>=180&&i<240?[c,p,d]=[0,a,o]:i>=240&&i<300?[c,p,d]=[a,0,o]:[c,p,d]=[o,0,a],[(c+l)*255,(p+l)*255,(d+l)*255]}function wo(n,t,e){const i=V(n/255,0,1),r=V(t/255,0,1),s=V(e/255,0,1),o=Math.max(i,r,s),a=Math.min(i,r,s),l=o-a;let c;l===0?c=0:o===i?c=60*(((r-s)/l%6+6)%6):o===r?c=60*((s-i)/l+2):c=60*((i-r)/l+4);const p=o===0?0:l/o,d=o;return[c,p*100,d*100]}function hi(n,t,e){const i=zn(n,360),r=V(t/100,0,1),s=V(e/100,0,1),o=s*r,a=o*(1-Math.abs(i/60%2-1)),l=s-o;let c,p,d;return i>=0&&i<60?[c,p,d]=[o,a,0]:i>=60&&i<120?[c,p,d]=[a,o,0]:i>=120&&i<180?[c,p,d]=[0,o,a]:i>=180&&i<240?[c,p,d]=[0,a,o]:i>=240&&i<300?[c,p,d]=[a,0,o]:[c,p,d]=[o,0,a],[(c+l)*255,(p+l)*255,(d+l)*255]}function _o(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 Co(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 oe(n,t){return[n[0],n[1],n[2],t]}const xo={hsl:{hsl:(n,t,e)=>[n,t,e],hsv:_o,rgb:go},hsv:{hsl:Co,hsv:(n,t,e)=>[n,t,e],rgb:hi},rgb:{hsl:fo,hsv:wo,rgb:(n,t,e)=>[n,t,e]}};function vt(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 yo(n,t){return n===t?t:zn(n,t)}function vi(n,t,e){var i;const r=vt(t,e);return[t==="rgb"?V(n[0],0,r[0]):yo(n[0],r[0]),V(n[1],0,r[1]),V(n[2],0,r[2]),V((i=n[3])!==null&&i!==void 0?i:1,0,1)]}function wn(n,t,e,i){const r=vt(t,e),s=vt(t,i);return n.map((o,a)=>o/r[a]*s[a])}function mi(n,t,e){const i=wn(n,t.mode,t.type,"int"),r=xo[t.mode][e.mode](...i);return wn(r,e.mode,"int",e.type)}class m{static black(){return new m([0,0,0],"rgb")}constructor(t,e){this.type="int",this.mode=e,this.comps_=vi(t,e,this.type)}getComponents(t){return oe(mi(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 Y=v("colp");class Po{constructor(t,e){this.alphaViews_=null,this.element=t.createElement("div"),this.element.classList.add(Y()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(Y("hsv"));const r=t.createElement("div");r.classList.add(Y("sv")),this.svPaletteView_=e.svPaletteView,r.appendChild(this.svPaletteView_.element),i.appendChild(r);const s=t.createElement("div");s.classList.add(Y("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(Y("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(Y("a"));const l=t.createElement("div");l.classList.add(Y("ap")),l.appendChild(this.alphaViews_.palette.element),a.appendChild(l);const c=t.createElement("div");c.classList.add(Y("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 Eo(n){return n==="int"?"int":n==="float"?"float":void 0}function He(n){return C(n,t=>({color:t.optional.object({alpha:t.optional.boolean,type:t.optional.custom(Eo)}),expanded:t.optional.boolean,picker:t.optional.custom(ui),readonly:t.optional.constant(!1)}))}function ot(n){return n?.1:1}function bi(n){var t;return(t=n.color)===null||t===void 0?void 0:t.type}class $e{constructor(t,e){this.type="float",this.mode=e,this.comps_=vi(t,e,this.type)}getComponents(t){return oe(mi(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 ko={int:(n,t)=>new m(n,t),float:(n,t)=>new $e(n,t)};function Ke(n,t,e){return ko[e](n,t)}function Vo(n){return n.type==="float"}function So(n){return n.type==="int"}function To(n){const t=n.getComponents(),e=vt(n.mode,"int");return new m([Math.round(b(t[0],0,1,0,e[0])),Math.round(b(t[1],0,1,0,e[1])),Math.round(b(t[2],0,1,0,e[2])),t[3]],n.mode)}function Lo(n){const t=n.getComponents(),e=vt(n.mode,"int");return new $e([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 T(n,t){if(n.type===t)return n;if(So(n)&&t==="float")return Lo(n);if(Vo(n)&&t==="int")return To(n);throw P.shouldNeverHappen()}function Ao(n,t){return n.alpha===t.alpha&&n.mode===t.mode&&n.notation===t.notation&&n.type===t.type}function B(n,t){const e=n.match(/^(.+)%$/);return Math.min(e?parseFloat(e[1])*.01*t:parseFloat(n),t)}const Ro={deg:n=>n,grad:n=>n*360/400,rad:n=>n*360/(2*Math.PI),turn:n=>n*360};function fi(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 Ro[i](e)}function gi(n){const t=n.match(/^rgb\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!t)return null;const e=[B(t[1],255),B(t[2],255),B(t[3],255)];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])?null:e}function Oo(n){const t=gi(n);return t?new m(t,"rgb"):null}function wi(n){const t=n.match(/^rgba\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!t)return null;const e=[B(t[1],255),B(t[2],255),B(t[3],255),B(t[4],1)];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])||isNaN(e[3])?null:e}function Mo(n){const t=wi(n);return t?new m(t,"rgb"):null}function _i(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=[fi(t[1]),B(t[2],100),B(t[3],100)];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])?null:e}function Do(n){const t=_i(n);return t?new m(t,"hsl"):null}function Ci(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=[fi(t[1]),B(t[2],100),B(t[3],100),B(t[4],1)];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])||isNaN(e[3])?null:e}function Fo(n){const t=Ci(n);return t?new m(t,"hsl"):null}function xi(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 Bo(n){const t=xi(n);return t?new m(t,"rgb"):null}function yi(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 Io(n){const t=yi(n);return t?new m(t,"rgb"):null}function Pi(n){const t=n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!t)return null;const e=[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])?null:e}function _n(n){return t=>{const e=Pi(t);return e?Ke(e,"rgb",n):null}}function Ei(n){const t=n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*a\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!t)return null;const e=[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])||isNaN(e[3])?null:e}function Cn(n){return t=>{const e=Ei(t);return e?Ke(e,"rgb",n):null}}const jo=[{parser:xi,result:{alpha:!1,mode:"rgb",notation:"hex"}},{parser:yi,result:{alpha:!0,mode:"rgb",notation:"hex"}},{parser:gi,result:{alpha:!1,mode:"rgb",notation:"func"}},{parser:wi,result:{alpha:!0,mode:"rgb",notation:"func"}},{parser:_i,result:{alpha:!1,mode:"hsl",notation:"func"}},{parser:Ci,result:{alpha:!0,mode:"hsl",notation:"func"}},{parser:Pi,result:{alpha:!1,mode:"rgb",notation:"object"}},{parser:Ei,result:{alpha:!0,mode:"rgb",notation:"object"}}];function No(n){return jo.reduce((t,{parser:e,result:i})=>t||(e(n)?i:null),null)}function zo(n,t="int"){const e=No(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 zt(n){const t=[Bo,Io,Oo,Mo,Do,Fo];n==="int"&&t.push(_n("int"),Cn("int")),n==="float"&&t.push(_n("float"),Cn("float"));const e=no(t);return i=>{const r=e(i);return r?T(r,n):null}}function Ho(n){const t=zt("int");if(typeof n!="string")return m.black();const e=t(n);return e??m.black()}function ki(n){const t=V(Math.floor(n),0,255).toString(16);return t.length===1?`0${t}`:t}function qe(n,t="#"){const e=H(n.getComponents("rgb")).map(ki).join("");return`${t}${e}`}function Ue(n,t="#"){const e=n.getComponents("rgb"),i=[e[0],e[1],e[2],e[3]*255].map(ki).join("");return`${t}${i}`}function Vi(n){const t=R(0),e=T(n,"int");return`rgb(${H(e.getComponents("rgb")).map(r=>t(r)).join(", ")})`}function qt(n){const t=R(2),e=R(0);return`rgba(${T(n,"int").getComponents("rgb").map((s,o)=>(o===3?t:e)(s)).join(", ")})`}function $o(n){const t=[R(0),Jt,Jt],e=T(n,"int");return`hsl(${H(e.getComponents("hsl")).map((r,s)=>t[s](r)).join(", ")})`}function Ko(n){const t=[R(0),Jt,Jt,R(2)];return`hsla(${T(n,"int").getComponents("hsl").map((r,s)=>t[s](r)).join(", ")})`}function Si(n,t){const e=R(t==="float"?2:0),i=["r","g","b"],r=T(n,t);return`{${H(r.getComponents("rgb")).map((o,a)=>`${i[a]}: ${e(o)}`).join(", ")}}`}function qo(n){return t=>Si(t,n)}function Ti(n,t){const e=R(2),i=R(t==="float"?2:0),r=["r","g","b","a"];return`{${T(n,t).getComponents("rgb").map((a,l)=>{const c=l===3?e:i;return`${r[l]}: ${c(a)}`}).join(", ")}}`}function Uo(n){return t=>Ti(t,n)}const Go=[{format:{alpha:!1,mode:"rgb",notation:"hex",type:"int"},stringifier:qe},{format:{alpha:!0,mode:"rgb",notation:"hex",type:"int"},stringifier:Ue},{format:{alpha:!1,mode:"rgb",notation:"func",type:"int"},stringifier:Vi},{format:{alpha:!0,mode:"rgb",notation:"func",type:"int"},stringifier:qt},{format:{alpha:!1,mode:"hsl",notation:"func",type:"int"},stringifier:$o},{format:{alpha:!0,mode:"hsl",notation:"func",type:"int"},stringifier:Ko},...["int","float"].reduce((n,t)=>[...n,{format:{alpha:!1,mode:"rgb",notation:"object",type:t},stringifier:qo(t)},{format:{alpha:!0,mode:"rgb",notation:"object",type:t},stringifier:Uo(t)}],[])];function Li(n){return Go.reduce((t,e)=>t||(Ao(e.format,n)?e.stringifier:null),null)}const Pt=v("apl");class Wo{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.value=e.value,this.value.emitter.on("change",this.onValueChange_),this.element=t.createElement("div"),this.element.classList.add(Pt()),e.viewProps.bindClassModifiers(this.element),e.viewProps.bindTabIndex(this.element);const i=t.createElement("div");i.classList.add(Pt("b")),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(Pt("c")),i.appendChild(r),this.colorElem_=r;const s=t.createElement("div");s.classList.add(Pt("m")),this.element.appendChild(s),this.markerElem_=s;const o=t.createElement("div");o.classList.add(Pt("p")),this.markerElem_.appendChild(o),this.previewElem_=o,this.update_()}update_(){const t=this.value.rawValue,e=t.getComponents("rgb"),i=new m([e[0],e[1],e[2],0],"rgb"),r=new m([e[0],e[1],e[2],255],"rgb"),s=["to right",qt(i),qt(r)];this.colorElem_.style.background=`linear-gradient(${s.join(",")})`,this.previewElem_.style.backgroundColor=qt(t);const o=b(e[3],0,1,0,100);this.markerElem_.style.left=`${o}%`}onValueChange_(){this.update_()}}class Yo{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 Wo(t,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new lt(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(t,e){if(!t.point)return;const i=t.point.x/t.bounds.width,r=this.value.rawValue,[s,o,a]=r.getComponents("hsv");this.value.setRawValue(new m([s,o,a,i],"hsv"),e)}onPointerDown_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerMove_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerUp_(t){this.handlePointerEvent_(t.data,{forceEmit:!0,last:!0})}onKeyDown_(t){const e=A(ot(!0),G(t));if(e===0)return;const i=this.value.rawValue,[r,s,o,a]=i.getComponents("hsv");this.value.setRawValue(new m([r,s,o,a+e],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(t){A(ot(!0),G(t))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const pt=v("coltxt");function Xo(n){const t=n.createElement("select"),e=[{text:"RGB",value:"rgb"},{text:"HSL",value:"hsl"},{text:"HSV",value:"hsv"},{text:"HEX",value:"hex"}];return t.appendChild(e.reduce((i,r)=>{const s=n.createElement("option");return s.textContent=r.text,s.value=r.value,i.appendChild(s),i},n.createDocumentFragment())),t}class Qo{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(pt()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(pt("m")),this.modeElem_=Xo(t),this.modeElem_.classList.add(pt("ms")),i.appendChild(this.modeSelectElement),e.viewProps.bindDisabled(this.modeElem_);const r=t.createElement("div");r.classList.add(pt("mm")),r.appendChild(re(t,"dropdown")),i.appendChild(r),this.element.appendChild(i);const s=t.createElement("div");s.classList.add(pt("w")),this.element.appendChild(s),this.inputsElem_=s,this.inputViews_=e.inputViews,this.applyInputViews_(),q(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_(){Xn(this.inputsElem_);const t=this.element.ownerDocument;this.inputViews_.forEach(e=>{const i=t.createElement("div");i.classList.add(pt("c")),i.appendChild(e.element),this.inputsElem_.appendChild(i)})}}function Zo(n){return R(n==="float"?2:0)}function Jo(n,t,e){const i=vt(n,t)[e];return new Ot({min:0,max:i})}function ta(n,t,e){return new jt(n,{arrayPosition:e===0?"fst":e===2?"lst":"mid",parser:t.parser,props:u.fromObject({formatter:Zo(t.colorType),keyScale:ot(!1),pointerScale:t.colorType==="float"?.01:1}),value:w(0,{constraint:Jo(t.colorMode,t.colorType,e)}),viewProps:t.viewProps})}function ea(n,t){const e={colorMode:t.colorMode,colorType:t.colorType,parser:U,viewProps:t.viewProps};return[0,1,2].map(i=>{const r=ta(n,e,i);return gt({primary:t.value,secondary:r.value,forward(s){return T(s,t.colorType).getComponents(t.colorMode)[i]},backward(s,o){const a=t.colorMode,c=T(s,t.colorType).getComponents(a);c[i]=o;const p=Ke(oe(H(c),c[3]),a,t.colorType);return T(p,"int")}}),r})}function na(n,t){const e=new Lt(n,{parser:zt("int"),props:u.fromObject({formatter:qe}),value:w(m.black()),viewProps:t.viewProps});return gt({primary:t.value,secondary:e.value,forward:i=>new m(H(i.getComponents()),i.mode),backward:(i,r)=>new m(oe(H(r.getComponents(i.mode)),i.getComponents()[3]),i.mode)}),[e]}function ia(n){return n!=="hex"}class ra{constructor(t,e){this.onModeSelectChange_=this.onModeSelectChange_.bind(this),this.colorType_=e.colorType,this.value=e.value,this.viewProps=e.viewProps,this.colorMode=w(this.value.rawValue.mode),this.ccs_=this.createComponentControllers_(t),this.view=new Qo(t,{mode:this.colorMode,inputViews:[this.ccs_[0].view,this.ccs_[1].view,this.ccs_[2].view],viewProps:this.viewProps}),this.view.modeSelectElement.addEventListener("change",this.onModeSelectChange_)}createComponentControllers_(t){const e=this.colorMode.rawValue;return ia(e)?ea(t,{colorMode:e,colorType:this.colorType_,value:this.value,viewProps:this.viewProps}):na(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 ve=v("hpl");class sa{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(ve()),e.viewProps.bindClassModifiers(this.element),e.viewProps.bindTabIndex(this.element);const i=t.createElement("div");i.classList.add(ve("c")),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(ve("m")),this.element.appendChild(r),this.markerElem_=r,this.update_()}update_(){const t=this.value.rawValue,[e]=t.getComponents("hsv");this.markerElem_.style.backgroundColor=Vi(new m([e,100,100],"hsv"));const i=b(e,0,360,0,100);this.markerElem_.style.left=`${i}%`}onValueChange_(){this.update_()}}class oa{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 sa(t,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new lt(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(t,e){if(!t.point)return;const i=b(V(t.point.x,0,t.bounds.width),0,t.bounds.width,0,360),r=this.value.rawValue,[,s,o,a]=r.getComponents("hsv");this.value.setRawValue(new m([i,s,o,a],"hsv"),e)}onPointerDown_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerMove_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerUp_(t){this.handlePointerEvent_(t.data,{forceEmit:!0,last:!0})}onKeyDown_(t){const e=A(ot(!1),G(t));if(e===0)return;const i=this.value.rawValue,[r,s,o,a]=i.getComponents("hsv");this.value.setRawValue(new m([r+e,s,o,a],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(t){A(ot(!1),G(t))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const me=v("svp"),xn=64;class aa{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.value=e.value,this.value.emitter.on("change",this.onValueChange_),this.element=t.createElement("div"),this.element.classList.add(me()),e.viewProps.bindClassModifiers(this.element),e.viewProps.bindTabIndex(this.element);const i=t.createElement("canvas");i.height=xn,i.width=xn,i.classList.add(me("c")),this.element.appendChild(i),this.canvasElement=i;const r=t.createElement("div");r.classList.add(me("m")),this.element.appendChild(r),this.markerElem_=r,this.update_()}update_(){const t=as(this.canvasElement);if(!t)return;const i=this.value.rawValue.getComponents("hsv"),r=this.canvasElement.width,s=this.canvasElement.height,o=t.getImageData(0,0,r,s),a=o.data;for(let p=0;pi.getComponents()[3],backward:(i,r)=>{const s=i.getComponents();return s[3]=r,new m(s,i.mode)}}),this.textsC_=new ra(t,{colorType:e.colorType,value:this.value,viewProps:this.viewProps}),this.view=new Po(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 be=v("colsw");class pa{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(be()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(be("sw")),this.element.appendChild(i),this.swatchElem_=i;const r=t.createElement("button");r.classList.add(be("b")),e.viewProps.bindDisabled(r),this.element.appendChild(r),this.buttonElement=r,this.update_()}update_(){const t=this.value.rawValue;this.swatchElem_.style.backgroundColor=Ue(t)}onValueChange_(){this.update_()}}class da{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.view=new pa(t,{value:this.value,viewProps:this.viewProps})}}class Ge{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_=Dt.create(e.expanded),this.swatchC_=new da(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 Lt(t,{parser:e.parser,props:u.fromObject({formatter:e.formatter}),value:this.value,viewProps:this.viewProps}),this.view=new bo(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 oi(t,{viewProps:this.viewProps}):null;const r=new ca(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),gt({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),Ie(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=Qn(t);i&&e.contains(i)||i&&i===this.swatchC_.view.buttonElement&&!Re(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 ua(n){return H(n.getComponents("rgb")).reduce((t,e)=>t<<8|Math.floor(e)&255,0)}function ha(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 va(n){return new m([n>>16&255,n>>8&255,n&255],"rgb")}function ma(n){return new m([n>>24&255,n>>16&255,n>>8&255,b(n&255,0,255,0,1)],"rgb")}function ba(n){return typeof n!="number"?m.black():va(n)}function fa(n){return typeof n!="number"?m.black():ma(n)}function Ut(n,t){return typeof n!="object"||g(n)?!1:t in n&&typeof n[t]=="number"}function Ai(n){return Ut(n,"r")&&Ut(n,"g")&&Ut(n,"b")}function Ri(n){return Ai(n)&&Ut(n,"a")}function Oi(n){return Ai(n)}function We(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{Nt(e,t(i))}:null}function wa(n){const t=n?ha:ua;return(e,i)=>{Nt(e,t(i))}}function _a(n,t,e){const r=T(t,e).toRgbaObject();n.writeProperty("r",r.r),n.writeProperty("g",r.g),n.writeProperty("b",r.b),n.writeProperty("a",r.a)}function Ca(n,t,e){const r=T(t,e).toRgbaObject();n.writeProperty("r",r.r),n.writeProperty("g",r.g),n.writeProperty("b",r.b)}function xa(n,t){return(e,i)=>{n?_a(e,i,t):Ca(e,i,t)}}function ya(n){var t;return!!(!((t=n==null?void 0:n.color)===null||t===void 0)&&t.alpha)}function Pa(n){return n?t=>Ue(t,"0x"):t=>qe(t,"0x")}function Ea(n){return"color"in n||n.view==="color"}const ka=L({id:"input-color-number",type:"input",accept:(n,t)=>{if(typeof n!="number"||!Ea(t))return null;const e=He(t);return e?{initialValue:n,params:Object.assign(Object.assign({},e),{supportsAlpha:ya(t)})}:null},binding:{reader:n=>n.params.supportsAlpha?fa:ba,equals:We,writer:n=>wa(n.params.supportsAlpha)},controller:n=>{var t,e;return new Ge(n.document,{colorType:"int",expanded:(t=n.params.expanded)!==null&&t!==void 0?t:!1,formatter:Pa(n.params.supportsAlpha),parser:zt("int"),pickerLayout:(e=n.params.picker)!==null&&e!==void 0?e:"popup",supportsAlpha:n.params.supportsAlpha,value:n.value,viewProps:n.viewProps})}});function Va(n,t){if(!Oi(n))return T(m.black(),t);if(t==="int"){const e=yn(n);return new m(e,"rgb")}if(t==="float"){const e=yn(n);return new $e(e,"rgb")}return T(m.black(),"int")}function Sa(n){return Ri(n)}function Ta(n){return t=>{const e=Va(t,n);return T(e,"int")}}function La(n,t){return e=>n?Ti(e,t):Si(e,t)}const Aa=L({id:"input-color-object",type:"input",accept:(n,t)=>{var e;if(!Oi(n))return null;const i=He(t);return i?{initialValue:n,params:Object.assign(Object.assign({},i),{colorType:(e=bi(t))!==null&&e!==void 0?e:"int"})}:null},binding:{reader:n=>Ta(n.params.colorType),equals:We,writer:n=>xa(Sa(n.initialValue),n.params.colorType)},controller:n=>{var t,e;const i=Ri(n.initialValue);return new Ge(n.document,{colorType:n.params.colorType,expanded:(t=n.params.expanded)!==null&&t!==void 0?t:!1,formatter:La(i,n.params.colorType),parser:zt("int"),pickerLayout:(e=n.params.picker)!==null&&e!==void 0?e:"popup",supportsAlpha:i,value:n.value,viewProps:n.viewProps})}}),Ra=L({id:"input-color-string",type:"input",accept:(n,t)=>{if(typeof n!="string"||t.view==="text")return null;const e=zo(n,bi(t));if(!e)return null;const i=Li(e);if(!i)return null;const r=He(t);return r?{initialValue:n,params:Object.assign(Object.assign({},r),{format:e,stringifier:i})}:null},binding:{reader:()=>Ho,equals:We,writer:n=>{const t=ga(n.params.format);if(!t)throw P.notBindable();return t}},controller:n=>{var t,e;return new Ge(n.document,{colorType:n.params.format.type,expanded:(t=n.params.expanded)!==null&&t!==void 0?t:!1,formatter:n.params.stringifier,parser:zt("int"),pickerLayout:(e=n.params.picker)!==null&&e!==void 0?e:"popup",supportsAlpha:n.params.format.alpha,value:n.value,viewProps:n.viewProps})}});class Ye{constructor(t){this.components=t.components,this.asm_=t.assembly}constrain(t){const e=this.asm_.toComponents(t).map((i,r)=>{var s,o;return(o=(s=this.components[r])===null||s===void 0?void 0:s.constrain(i))!==null&&o!==void 0?o:i});return this.asm_.fromComponents(e)}}const Pn=v("pndtxt");class Oa{constructor(t,e){this.textViews=e.textViews,this.element=t.createElement("div"),this.element.classList.add(Pn()),this.textViews.forEach(i=>{const r=t.createElement("div");r.classList.add(Pn("a")),r.appendChild(i.element),this.element.appendChild(r)})}}function Ma(n,t,e){return new jt(n,{arrayPosition:e===0?"fst":e===t.axes.length-1?"lst":"mid",parser:t.parser,props:t.axes[e].textProps,value:w(0,{constraint:t.axes[e].constraint}),viewProps:t.viewProps})}class Xe{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.acs_=e.axes.map((i,r)=>Ma(t,e,r)),this.acs_.forEach((i,r)=>{gt({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 Oa(t,{textViews:this.acs_.map(i=>i.view)})}get textControllers(){return this.acs_}}class Da extends Tt{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 Fa(n,t){const e=[],i=Kn(n,t);i&&e.push(i);const r=qn(n);r&&e.push(r);const s=ze(n.options);return s&&e.push(s),new Ft(e)}const Ba=L({id:"input-number",type:"input",accept:(n,t)=>{if(typeof n!="number")return null;const e=C(t,i=>Object.assign(Object.assign({},Gn(i)),{options:i.optional.custom(It),readonly:i.optional.constant(!1)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>Nn,constraint:n=>Fa(n.params,n.initialValue),writer:n=>Nt},controller:n=>{const t=n.value,e=n.constraint,i=e&&Zt(e,Bt);if(i)return new tt(n.document,{props:new u({options:i.values.value("options")}),value:t,viewProps:n.viewProps});const r=Un(n.params,t.rawValue),s=e&&Zt(e,Ot);return s?new te(n.document,Object.assign(Object.assign({},pi(Object.assign(Object.assign({},r),{keyScale:w(r.keyScale),max:s.values.value("max"),min:s.values.value("min")}))),{parser:U,value:t,viewProps:n.viewProps})):new jt(n.document,{parser:U,props:u.fromObject(r),value:t,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="number"?null:n.controller.valueController instanceof te?new Da(n.controller):n.controller.valueController instanceof tt?new je(n.controller):null}});class J{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 Mi={toComponents:n=>n.getComponents(),fromComponents:n=>new J(...n)},dt=v("p2d");class Ia{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(dt()),e.viewProps.bindClassModifiers(this.element),q(e.expanded,mt(this.element,dt(void 0,"expanded")));const i=t.createElement("div");i.classList.add(dt("h")),this.element.appendChild(i);const r=t.createElement("button");r.classList.add(dt("b")),r.appendChild(re(t,"p2dpad")),e.viewProps.bindDisabled(r),i.appendChild(r),this.buttonElement=r;const s=t.createElement("div");if(s.classList.add(dt("t")),i.appendChild(s),this.textElement=s,e.pickerLayout==="inline"){const o=t.createElement("div");o.classList.add(dt("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}}const X=v("p2dp");class ja{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(X()),e.layout==="popup"&&this.element.classList.add(X(void 0,"p")),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(X("p")),e.viewProps.bindTabIndex(i),this.element.appendChild(i),this.padElement=i;const r=t.createElementNS(N,"svg");r.classList.add(X("g")),this.padElement.appendChild(r),this.svgElem_=r;const s=t.createElementNS(N,"line");s.classList.add(X("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(X("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(X("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(X("m")),this.padElement.appendChild(l),this.markerElem_=l,e.value.emitter.on("change",this.onValueChange_),this.value=e.value,this.update_()}get allFocusableElements(){return[this.padElement]}update_(){const[t,e]=this.value.rawValue.getComponents(),i=this.props_.get("max"),r=b(t,-i,+i,0,100),s=b(e,-i,+i,0,100),o=this.props_.get("invertsY")?100-s:s;this.lineElem_.setAttributeNS(null,"x2",`${r}%`),this.lineElem_.setAttributeNS(null,"y2",`${o}%`),this.markerElem_.style.left=`${r}%`,this.markerElem_.style.top=`${o}%`}onValueChange_(){this.update_()}onPropsChange_(){this.update_()}onFoldableChange_(){this.update_()}}function En(n,t,e){return[A(t[0],G(n)),A(t[1],At(n))*(e?1:-1)]}class Na{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 ja(t,{layout:e.layout,props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new lt(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 J(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){ci(t.key)&&t.preventDefault();const[e,i]=En(t,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));e===0&&i===0||this.value.setRawValue(new J(this.value.rawValue.x+e,this.value.rawValue.y+i),{forceEmit:!1,last:!1})}onPadKeyUp_(t){const[e,i]=En(t,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));e===0&&i===0||this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}class za{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_=Dt.create(e.expanded),this.popC_=e.pickerLayout==="popup"?new oi(t,{viewProps:this.viewProps}):null;const s=new Na(t,{layout:e.pickerLayout,props:new u({invertsY:w(e.invertsY),max:w(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 Xe(t,{assembly:Mi,axes:e.axes,parser:e.parser,value:this.value,viewProps:this.viewProps}),this.view=new Ia(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),gt({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),Ie(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=Qn(t);i&&e.contains(i)||i&&i===this.view.buttonElement&&!Re(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 Ha(n){return J.isObject(n)?new J(n.x,n.y):new J}function $a(n,t){n.writeProperty("x",t.x),n.writeProperty("y",t.y)}function Ka(n,t){return new Ye({assembly:Mi,components:[K(Object.assign(Object.assign({},n),n.x),t.x),K(Object.assign(Object.assign({},n),n.y),t.y)]})}function kn(n,t){var e,i;if(!g(n.min)||!g(n.max))return Math.max(Math.abs((e=n.min)!==null&&e!==void 0?e:0),Math.abs((i=n.max)!==null&&i!==void 0?i:0));const r=Hn(n);return Math.max(Math.abs(r)*10,Math.abs(t)*10)}function qa(n,t){var e,i;const r=kn(rt(n,(e=n.x)!==null&&e!==void 0?e:{}),t.x),s=kn(rt(n,(i=n.y)!==null&&i!==void 0?i:{}),t.y);return Math.max(r,s)}function Ua(n){if(!("y"in n))return!1;const t=n.y;return t&&"inverted"in t?!!t.inverted:!1}const Ga=L({id:"input-point2d",type:"input",accept:(n,t)=>{if(!J.isObject(n))return null;const e=C(t,i=>Object.assign(Object.assign({},Rt(i)),{expanded:i.optional.boolean,picker:i.optional.custom(ui),readonly:i.optional.constant(!1),x:i.optional.custom(Z),y:i.optional.object(Object.assign(Object.assign({},Rt(i)),{inverted:i.optional.boolean}))}));return e?{initialValue:n,params:e}:null},binding:{reader:()=>Ha,constraint:n=>Ka(n.params,n.initialValue),equals:J.equals,writer:()=>$a},controller:n=>{var t,e;const i=n.document,r=n.value,s=n.constraint,o=[n.params.x,n.params.y];return new za(i,{axes:r.rawValue.getComponents().map((a,l)=>{var c;return Ae({constraint:s.components[l],initialValue:a,params:rt(n.params,(c=o[l])!==null&&c!==void 0?c:{})})}),expanded:(t=n.params.expanded)!==null&&t!==void 0?t:!1,invertsY:Ua(n.params),max:qa(n.params,r.rawValue),parser:U,pickerLayout:(e=n.params.picker)!==null&&e!==void 0?e:"popup",value:r,viewProps:n.viewProps})}});class ut{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 Di={toComponents:n=>n.getComponents(),fromComponents:n=>new ut(...n)};function Wa(n){return ut.isObject(n)?new ut(n.x,n.y,n.z):new ut}function Ya(n,t){n.writeProperty("x",t.x),n.writeProperty("y",t.y),n.writeProperty("z",t.z)}function Xa(n,t){return new Ye({assembly:Di,components:[K(Object.assign(Object.assign({},n),n.x),t.x),K(Object.assign(Object.assign({},n),n.y),t.y),K(Object.assign(Object.assign({},n),n.z),t.z)]})}const Qa=L({id:"input-point3d",type:"input",accept:(n,t)=>{if(!ut.isObject(n))return null;const e=C(t,i=>Object.assign(Object.assign({},Rt(i)),{readonly:i.optional.constant(!1),x:i.optional.custom(Z),y:i.optional.custom(Z),z:i.optional.custom(Z)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>Wa,constraint:n=>Xa(n.params,n.initialValue),equals:ut.equals,writer:n=>Ya},controller:n=>{const t=n.value,e=n.constraint,i=[n.params.x,n.params.y,n.params.z];return new Xe(n.document,{assembly:Di,axes:t.rawValue.getComponents().map((r,s)=>{var o;return Ae({constraint:e.components[s],initialValue:r,params:rt(n.params,(o=i[s])!==null&&o!==void 0?o:{})})}),parser:U,value:t,viewProps:n.viewProps})}});class ht{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 Fi={toComponents:n=>n.getComponents(),fromComponents:n=>new ht(...n)};function Za(n){return ht.isObject(n)?new ht(n.x,n.y,n.z,n.w):new ht}function Ja(n,t){n.writeProperty("x",t.x),n.writeProperty("y",t.y),n.writeProperty("z",t.z),n.writeProperty("w",t.w)}function tl(n,t){return new Ye({assembly:Fi,components:[K(Object.assign(Object.assign({},n),n.x),t.x),K(Object.assign(Object.assign({},n),n.y),t.y),K(Object.assign(Object.assign({},n),n.z),t.z),K(Object.assign(Object.assign({},n),n.w),t.w)]})}const el=L({id:"input-point4d",type:"input",accept:(n,t)=>{if(!ht.isObject(n))return null;const e=C(t,i=>Object.assign(Object.assign({},Rt(i)),{readonly:i.optional.constant(!1),w:i.optional.custom(Z),x:i.optional.custom(Z),y:i.optional.custom(Z),z:i.optional.custom(Z)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>Za,constraint:n=>tl(n.params,n.initialValue),equals:ht.equals,writer:n=>Ja},controller:n=>{const t=n.value,e=n.constraint,i=[n.params.x,n.params.y,n.params.z,n.params.w];return new Xe(n.document,{assembly:Fi,axes:t.rawValue.getComponents().map((r,s)=>{var o;return Ae({constraint:e.components[s],initialValue:r,params:rt(n.params,(o=i[s])!==null&&o!==void 0?o:{})})}),parser:U,value:t,viewProps:n.viewProps})}});function nl(n){const t=[],e=ze(n.options);return e&&t.push(e),new Ft(t)}const il=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(It)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>li,constraint:n=>nl(n.params),writer:n=>Nt},controller:n=>{const t=n.document,e=n.value,i=n.constraint,r=i&&Zt(i,Bt);return r?new tt(t,{props:new u({options:r.values.value("options")}),value:e,viewProps:n.viewProps}):new Lt(t,{parser:s=>s,props:u.fromObject({formatter:Pe}),value:e,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="string"?null:n.controller.valueController instanceof tt?new je(n.controller):null}}),Ht={monitor:{defaultInterval:200,defaultRows:3}},Vn=v("mll");class rl{constructor(t,e){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=e.formatter,this.element=t.createElement("div"),this.element.classList.add(Vn()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("textarea");i.classList.add(Vn("i")),i.style.height=`calc(var(${di("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 Qe{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.view=new rl(t,{formatter:e.formatter,rows:e.rows,value:this.value,viewProps:this.viewProps})}}const Sn=v("sgl");class sl{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 Ze{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.view=new sl(t,{formatter:e.formatter,value:this.value,viewProps:this.viewProps})}}const ol=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=>ai},controller:n=>{var t;return n.value.rawValue.length===1?new Ze(n.document,{formatter:gn,value:n.value,viewProps:n.viewProps}):new Qe(n.document,{formatter:gn,rows:(t=n.params.rows)!==null&&t!==void 0?t:Ht.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}});class al extends Tt{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 Q=v("grl");class ll{constructor(t,e){this.onCursorChange_=this.onCursorChange_.bind(this),this.onValueUpdate_=this.onValueUpdate_.bind(this),this.element=t.createElement("div"),this.element.classList.add(Q()),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(Q("g")),i.style.height=`calc(var(${di("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(Q("t"),v("tt")()),this.element.appendChild(s),this.tooltipElem_=s,e.value.emitter.on("change",this.onValueUpdate_),this.value=e.value,this.update_()}get graphElement(){return this.svgElem_}update_(){const{clientWidth:t,clientHeight:e}=this.element,i=this.value.rawValue.length-1,r=this.props_.get("min"),s=this.props_.get("max"),o=[];this.value.rawValue.forEach((d,h)=>{if(d===void 0)return;const S=b(h,0,i,0,t),x=b(d,r,s,e,0);o.push([S,x].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(Q("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(Q("t","a"))||(a.classList.add(Q("t","a"),Q("t","in")),Qt(a),a.classList.remove(Q("t","in")))}onValueUpdate_(){this.update_()}onCursorChange_(){this.update_()}}class Bi{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_=w(-1),this.view=new ll(t,{cursor:this.cursor_,formatter:e.formatter,rows:e.rows,props:this.props,value:this.value,viewProps:this.viewProps}),!Re(t))this.view.element.addEventListener("mousemove",this.onGraphMouseMove_),this.view.element.addEventListener("mouseleave",this.onGraphMouseLeave_);else{const i=new lt(this.view.element);i.emitter.on("down",this.onGraphPointerDown_),i.emitter.on("move",this.onGraphPointerMove_),i.emitter.on("up",this.onGraphPointerUp_)}}importProps(t){return M(t,null,e=>({max:e.required.number,min:e.required.number}),e=>(this.props.set("max",e.max),this.props.set("min",e.min),!0))}exportProps(){return D(null,{max:this.props.get("max"),min:this.props.get("min")})}onGraphMouseLeave_(){this.cursor_.rawValue=-1}onGraphMouseMove_(t){const{clientWidth:e}=this.view.element;this.cursor_.rawValue=Math.floor(b(t.offsetX,0,e,0,this.value.rawValue.length))}onGraphPointerDown_(t){this.onGraphPointerMove_(t)}onGraphPointerMove_(t){if(!t.data.point){this.cursor_.rawValue=-1;return}this.cursor_.rawValue=Math.floor(b(t.data.point.x,0,t.data.bounds.width,0,this.value.rawValue.length))}onGraphPointerUp_(){this.cursor_.rawValue=-1}}function Ee(n){return g(n.format)?R(2):n.format}function cl(n){var t;return n.value.rawValue.length===1?new Ze(n.document,{formatter:Ee(n.params),value:n.value,viewProps:n.viewProps}):new Qe(n.document,{formatter:Ee(n.params),rows:(t=n.params.rows)!==null&&t!==void 0?t:Ht.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}function pl(n){var t,e,i;return new Bi(n.document,{formatter:Ee(n.params),rows:(t=n.params.rows)!==null&&t!==void 0?t:Ht.monitor.defaultRows,props:u.fromObject({max:(e=n.params.max)!==null&&e!==void 0?e:100,min:(i=n.params.min)!==null&&i!==void 0?i:0}),value:n.value,viewProps:n.viewProps})}function Tn(n){return n.view==="graph"}const dl=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=>Tn(n)?64:1,reader:n=>Nn},controller:n=>Tn(n.params)?pl(n):cl(n),api:n=>n.controller.valueController instanceof Bi?new al(n.controller):null}),ul=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=>li},controller:n=>{var t;const e=n.value;return e.rawValue.length>1||n.params.multiline?new Qe(n.document,{formatter:Pe,rows:(t=n.params.rows)!==null&&t!==void 0?t:Ht.monitor.defaultRows,value:e,viewProps:n.viewProps}):new Ze(n.document,{formatter:Pe,value:e,viewProps:n.viewProps})}});class hl{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 vl{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 ml(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,d=>({disabled:d.optional.boolean,hidden:d.optional.boolean,label:d.optional.string,tag:d.optional.string})),o=n.binding.reader(r),a=n.binding.constraint?n.binding.constraint(r):void 0,l=new vl({reader:o,target:t.target,writer:n.binding.writer(r)}),c=new Jr(w(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:W.create({disabled:s==null?void 0:s.disabled,hidden:s==null?void 0:s.hidden})});return new vs(t.document,{blade:ft(),props:u.fromObject({label:"label"in t.params?(e=s==null?void 0:s.label)!==null&&e!==void 0?e:null:t.target.key}),tag:s==null?void 0:s.tag,value:c,valueController:p})}class bl{constructor(t){this.target=t.target,this.reader_=t.reader}read(){return this.reader_(this.target.read())}}function fl(n,t){return t===0?new Xs:new Qs(n,t??Ht.monitor.defaultInterval)}function gl(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,h=>({bufferSize:h.optional.number,disabled:h.optional.boolean,hidden:h.optional.boolean,interval:h.optional.number,label:h.optional.string})),l=n.binding.reader(o),c=(i=(e=a==null?void 0:a.bufferSize)!==null&&e!==void 0?e:n.binding.defaultBufferSize&&n.binding.defaultBufferSize(s.params))!==null&&i!==void 0?i:1,p=new ws({binding:new bl({reader:l,target:t.target}),bufferSize:c,ticker:fl(t.document,a==null?void 0:a.interval)}),d=n.controller({document:t.document,params:s.params,value:p,viewProps:W.create({disabled:a==null?void 0:a.disabled,hidden:a==null?void 0:a.hidden})});return d.viewProps.bindDisabled(p.ticker),d.viewProps.handleDispose(()=>{p.ticker.dispose()}),new Cs(t.document,{blade:ft(),props:u.fromObject({label:"label"in t.params?(r=a==null?void 0:a.label)!==null&&r!==void 0?r:null:t.target.key}),value:p,valueController:d})}class wl{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(!po(e.core))throw P.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??ml(s,{document:t,target:e,params:i}),null)}createMonitor_(t,e,i){return this.pluginsMap_.monitors.reduce((r,s)=>r??gl(s,{document:t,params:i,target:e}),null)}createBinding(t,e,i){const r=e.read();if(g(r))throw new P({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 P({context:{key:e.key},type:"nomatchingcontroller"})}createBlade(t,e){const i=this.pluginsMap_.blades.reduce((r,s)=>r??Ys(s,{document:t,params:e}),null);if(!i)throw new P({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 Tt(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 Tt(t))}createBindingApi(t){if(this.apiCache_.has(t))return this.apiCache_.get(t);if(ms(t))return this.createInputBindingApi_(t);if(xs(t))return this.createMonitorBindingApi_(t);throw P.shouldNeverHappen()}createApi(t){if(this.apiCache_.has(t))return this.apiCache_.get(t);if(hs(t))return this.createBindingApi(t);const e=this.pluginsMap_.blades.reduce((i,r)=>i??r.api({controller:t,pool:this}),null);if(!e)throw P.shouldNeverHappen();return this.apiCache_.add(t,e)}}const _l=new hl;function Cl(){const n=new wl(_l);return[Ga,Qa,el,il,Ba,Ra,Aa,ka,mo,ol,ul,dl,Vs,Ns,si].forEach(t=>{n.register("core",t)}),n}class xl extends at{constructor(t){super(t),this.emitter_=new k,this.controller.value.emitter.on("change",e=>{this.emitter_.emit("change",new Mt(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 yl extends at{}class Pl extends at{constructor(t){super(t),this.emitter_=new k,this.controller.value.emitter.on("change",e=>{this.emitter_.emit("change",new Mt(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 El extends at{constructor(t){super(t),this.emitter_=new k,this.controller.value.emitter.on("change",e=>{this.emitter_.emit("change",new Mt(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 kl=function(){return{id:"list",type:"blade",core:bt,accept(n){const t=C(n,e=>({options:e.required.custom(It),value:e.required.raw,view:e.required.constant("list"),label:e.optional.string}));return t?{params:t}:null},controller(n){const t=new Bt(Ne(n.params.options)),e=w(n.params.value,{constraint:t}),i=new tt(n.document,{props:new u({options:t.values.value("options")}),value:e,viewProps:n.viewProps});return new st(n.document,{blade:n.blade,props:u.fromObject({label:n.params.label}),value:e,valueController:i})},api(n){return!(n.controller instanceof st)||!(n.controller.valueController instanceof tt)?null:new xl(n.controller)}}}();class Vl extends ii{constructor(t,e){super(t,e)}get element(){return this.controller.view.element}}class Sl extends xe{constructor(t,e){super(t,{expanded:e.expanded,blade:e.blade,props:e.props,root:!0,viewProps:e.viewProps})}}const Ln=v("spr");class Tl{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(Ln()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("hr");i.classList.add(Ln("r")),this.element.appendChild(i)}}class An extends se{constructor(t,e){super(Object.assign(Object.assign({},e),{view:new Tl(t,{viewProps:e.viewProps})}))}}const Ll={id:"separator",type:"blade",core:bt,accept(n){const t=C(n,e=>({view:e.required.constant("separator")}));return t?{params:t}:null},controller(n){return new An(n.document,{blade:n.blade,viewProps:n.viewProps})},api(n){return n.controller instanceof An?new yl(n.controller):null}},Al={id:"slider",type:"blade",core:bt,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 Ot({max:n.params.max,min:n.params.min}),s=w(i,{constraint:r}),o=new te(n.document,Object.assign(Object.assign({},pi({formatter:(e=n.params.format)!==null&&e!==void 0?e:Wr,keyScale:w(1),max:r.values.value("max"),min:r.values.value("min"),pointerScale:$n(n.params,i)})),{parser:U,value:s,viewProps:n.viewProps}));return new st(n.document,{blade:n.blade,props:u.fromObject({label:n.params.label}),value:s,valueController:o})},api(n){return!(n.controller instanceof st)||!(n.controller.valueController instanceof te)?null:new Pl(n.controller)}},Rl=function(){return{id:"text",type:"blade",core:bt,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=w(n.params.value),i=new Lt(n.document,{parser:n.params.parse,props:u.fromObject({formatter:(t=n.params.format)!==null&&t!==void 0?t:r=>String(r)}),value:e,viewProps:n.viewProps});return new st(n.document,{blade:n.blade,props:u.fromObject({label:n.params.label}),value:e,valueController:i})},api(n){return!(n.controller instanceof st)||!(n.controller.valueController instanceof Lt)?null:new El(n.controller)}}}();function Ol(n){const t=n.createElement("div");return t.classList.add(v("dfw")()),n.body&&n.body.appendChild(t),t}function Ml(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 Dl extends Vl{constructor(t){var e,i;const r=t??{},s=(e=r.document)!==null&&e!==void 0?e:os(),o=Cl(),a=new Sl(s,{expanded:r.expanded,blade:ft(),props:u.fromObject({title:r.title}),viewProps:W.create()});super(a,o),this.pool_=o,this.containerElem_=(i=r.container)!==null&&i!==void 0?i:Ol(s),this.containerElem_.appendChild(this.element),this.doc_=s,this.usesDefaultWrapper_=!r.container,this.setUpDefaultPlugins_()}get document(){if(!this.doc_)throw P.alreadyDisposed();return this.doc_}dispose(){const t=this.containerElem_;if(!t)throw P.alreadyDisposed();if(this.usesDefaultWrapper_){const e=t.parentElement;e&&e.removeChild(t)}this.containerElem_=null,this.doc_=null,super.dispose()}registerPlugin(t){t.css&&Ml(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:[kl,Ll,Al,si,Rl]})}}new ni("4.0.4");class Fl{constructor(t){this.game=t;const e=document.getElementById("settings");if(!e)throw new Error("No settings container found");new Dl({title:"Settings",expanded:!1,container:e}).addButton({title:"Delete current loop"}).on("click",r=>{_.deleteCurrentTrack(),r.native.preventDefault()}),this.resize()}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})}}function Rn(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 On=!1;const Bl=()=>(On||(On=!0,Yi().then(()=>{const n=new y.Game({type:y.AUTO,mode:y.Scale.RESIZE,parent:"phaser-container",width:window.innerWidth,height:window.innerHeight,backgroundColor:hr()?"#333":"#DDD",scene:[_,Wt],input:{activePointers:8}}),t=new Fl(n);window.addEventListener("resize",()=>{Rn(n),t.resize()}),n.scene.start(_.key),Rn(n)})),Et.jsx(Et.Fragment,{}));function Il(){return Et.jsx(Bl,{})}fe.createRoot(document.getElementById("root")).render(Et.jsx(Hi.StrictMode,{children:Et.jsx(Il,{})})); + */var $i=Ni,Ki=Symbol.for("react.element"),qi=Symbol.for("react.fragment"),Ui=Object.prototype.hasOwnProperty,Gi=$i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Wi={key:!0,ref:!0,__self:!0,__source:!0};function Dn(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)Ui.call(t,i)&&!Wi.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:Ki,type:n,key:s,ref:o,props:r,_owner:Gi.current}}ne.Fragment=qi;ne.jsx=Dn;ne.jsxs=Dn;Mn.exports=ne;var Et=Mn.exports,fe={},Je=zi;fe.createRoot=Je.createRoot,fe.hydrateRoot=Je.hydrateRoot;const kt={Icons:"Icons",Text:"Courier"},Wt={tiny:"15px",small:"30px",medium:"50px",big:"90px"},ge={white:"#FFF"},Yi=async()=>{const n=new FontFace(kt.Icons,"url(./fonts/material.woff2)");return document.fonts.add(n),n.load().catch(t=>console.error(t))},j=(n,t=!1)=>y.Display.Color.HexStringToColor(n).darken(t?75:0).color;let qt=null;const et=()=>{if(!qt){const n=window.AudioContext||window.webkitAudioContext;qt=new n}return qt},Xi=()=>{qt=null};function Qi(){const n=et(),t=n.sampleRate*.05,e=n.createBuffer(1,t,n.sampleRate),i=e.getChannelData(0);for(let c=0;c{try{tn[n]()}catch(t){console.error(`Error playing ${n}`,t),Xi(),tn[n]()}},ke=(n,t,e)=>{const i=[];for(let s=0;si.map(a=>a[o]).reverse()).flat()},sr={hihat:"#FDA341",kick:"#F24E1E",snare:"#4A90E2",crash:"#A0D8C5","hihat-open":"#F9F871",ride:"#F5C542","tom-low":"#FF7F50","tom-high":"#9B59B6"};class en extends y.Scene{constructor(t="drums"){super(),this.type=t}create({type:t}){t&&(this.type=t),this.createPads(),this.scene.get(w.key).events.emit("track-selected")}createPads(){const t=[this.createPad("crash"),this.createPad("ride"),this.createPad("hihat-open"),this.createPad("hihat"),this.createPad("snare"),this.createPad("tom-low"),this.createPad("tom-high"),this.createPad("kick")],e=()=>{const i=window.innerWidth{const d=p%r*o,h=Math.floor(p/r)*a,S=i?0:w.sceneWidthHeight,x=i?w.sceneWidthHeight:0;c.setSize(o,a).setPosition(S+d,x+h)})};window.addEventListener("resize",e),e()}createPad(t){const e=sr[t],i=j(e,this.type==="drums"),r=y.Display.Color.HexStringToColor(e).brighten(4).color,s=this.add.rectangle().setFillStyle(i).setStrokeStyle(2,j("#FFF"),.8).setInteractive().setOrigin(0,0);return s.on("pointerdown",o=>{var l,c;if(((c=(l=o.downElement)==null?void 0:l.tagName)==null?void 0:c.toLowerCase())!=="canvas")return;s.setFillStyle(r);const a=()=>rr(t);a(),this.scene.get(w.key).events.emit("instrument-played",{callback:a,scene:this})}).on("pointerup",()=>s.setFillStyle(i)).on("pointerout",()=>s.setFillStyle(i)),{instrument:t,button:s}}}let _t=null,ae=null;const nn=()=>{_t&&(console.log("stopping note...",_t),_t.stop(),ae.stop()),console.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];ae=Sequencer.make([55,110,165,220],[n/4],e,"note").start(),_t=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],ae,"values"),_t.start()};class or extends y.Scene{constructor(){super();E(this,"isGibberishLoaded",!1)}create({numberOfPads:e=8}){this.createPads(e),this.scene.get(w.key).events.emit("track-selected")}createPads(e){const i=new Array(e).fill(0).map((s,o)=>this.createPad(o)),r=()=>{const s=window.innerWidth{const S=h%o*l,x=Math.floor(h/o)*c,O=s?0:w.sceneWidthHeight,ct=s?w.sceneWidthHeight:0;d.setSize(l,c).setPosition(O+S,ct+x)})};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,j("#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?nn():(this.isGibberishLoaded=!0,Gibberish.workletPath="./worklet.js",console.log("loading Gibberish 2..."),Gibberish.init().then(()=>{console.log("Gibberish is ready!"),Gibberish.export(window),nn()}).catch(p=>console.error("oops",p))),o.setFillStyle(s))}).on("pointerup",()=>o.setFillStyle(r)).on("pointerout",()=>o.setFillStyle(r)),{instrument:e,button:o}}}class ar extends y.Scene{constructor(e,i){super();E(this,"pads",[]);this.cols=e,this.rows=i}create(){this.createPads(),this.scene.get(w.key).events.emit("track-selected")}createPads(){const e=this.cols*this.rows;this.pads=new Array(e).fill(0).map((r,s)=>this.createPad(s,e));const i=()=>{const r=window.innerWidth{const S=h%s*a,x=Math.floor(h/s)*l,O=r?0:w.sceneWidthHeight,ct=r?w.sceneWidthHeight:0;p.setSize(a,l).setPosition(O+S,ct+x),d&&d.setPosition(p.getCenter().x,p.getCenter().y).setFontSize(Wt.tiny).setResolution(2)})};window.addEventListener("resize",i),i()}createPad(e,i){var S;const r=this.getPadColor(i,e),s=(S=this.getPadText)==null?void 0:S.call(this,e),o=r.darken(60).color,a=r.brighten(40).color,l=this.add.rectangle().setFillStyle(o).setStrokeStyle(2,j("#FFF"),.8).setInteractive().setOrigin(0,0);let c;s&&(c=this.add.text(0,0,s,{fontFamily:kt.Text,fontSize:Wt.tiny,color:ge.white}).setAlpha(.5).setOrigin(.5,.5).setResolution(2).setPosition(l.getCenter().x,l.getCenter().y).setDepth(1));let p=!1;const d=()=>{p||(this.playSound(e),l.setFillStyle(a),this.scene.get(w.key).events.emit("instrument-played",{callback:()=>this.playSound(e),scene:this}),p=!0)},h=()=>{l.setFillStyle(o),p=!1};return l.on("pointerdown",x=>{var O,ct;((ct=(O=x.downElement)==null?void 0:O.tagName)==null?void 0:ct.toLowerCase())==="canvas"&&d()}).on("pointermove",x=>{x.isDown&&d()}).on("pointerup",()=>h()).on("pointerout",()=>h()),{instrument:e,button:l,text:c}}getPadColor(e,i){return y.Display.Color.HSLToColor((e-i)/(e*1.5),1,.5)}}function lr(){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 cr=lr(),le=cr.flatMap(n=>Object.entries(n)).map(([n,t])=>({key:n,freq:t})).filter(({freq:n})=>!!n).sort((n,t)=>n.freq-t.freq);class pr extends ar{constructor(){super(6,12)}create(){super.create()}getPadText(t){const e=le[t];return e==null?void 0:e.key}getPadColor(t,e){var s;const i=super.getPadColor(t,e),r=(s=le[e])==null?void 0:s.key;return r!=null&&r.includes("#")?i.darken(15):i}playSound(t){const e=le[t].freq;return console.log("Playing note",e),dr(e)}}const dr=n=>{const t=et(),e=t.createOscillator();e.type="sine";const i=t.createGain();e.frequency.setValueAtTime(n,t.currentTime),e.connect(i),i.connect(t.destination);const r=.02,s=1.5;i.gain.setValueAtTime(0,t.currentTime),i.gain.linearRampToValueAtTime(.7,t.currentTime+r),i.gain.exponentialRampToValueAtTime(1e-4,t.currentTime+s),e.start(t.currentTime),e.stop(t.currentTime+s)},ee=class ee extends y.Scene{constructor(){super(ee.key);E(this,"rowNumber",5);E(this,"colNumber",5);E(this,"instrumentButtons")}create({index:e}){this.scene.bringToTop(),this.cameras.main.setOrigin(0,0).setBackgroundColor("#147"),this.createMatrix();const i=this.instrumentButtons[2][1];i.setData("text",this.addText(i,"Simple Synth"));const r=this.instrumentButtons[1][2];r.setData("text",this.addText(r,"Drums"));const s=this.instrumentButtons[3][2];s.setData("text",this.addText(s,"Other Drums"));const o=this.instrumentButtons[2][3];o.setData("text",this.addText(o,"Gibberish")),[r,s,o,i].forEach(c=>c.setFillStyle(j("#FFF"),.5).setInteractive().on(y.Input.Events.POINTER_DOWN,()=>{this.scene.setVisible(!1)}));const l=w.getTrackSceneKey(e);r.on(y.Input.Events.POINTER_UP,()=>{this.scene.add(l,en,!0,{type:"drums"})}),s.on(y.Input.Events.POINTER_UP,()=>{this.scene.add(l,en,!0,{type:"other"})}),o.on(y.Input.Events.POINTER_UP,()=>{this.scene.add(l,or,!0,{numberOfPads:8})}),i.on(y.Input.Events.POINTER_UP,()=>{this.scene.add(l,pr,!0)}),window.addEventListener("resize",()=>this.resizeScene()),this.resizeScene()}createMatrix(){this.instrumentButtons=[];for(let e=0;e{p.forEach((h,S)=>{h.setSize(r,s).setPosition(r*d,s*S);const x=h.getData("text");if(x){const O=Math.min(h.height,h.width)/5;x.setFontSize(O).setResolution(2).setWordWrapWidth(h.width,!0).setSize(h.width,h.height).setPosition(h.getCenter().x,h.getCenter().y)}})});const o=e?window.innerWidth:window.innerWidth-i,a=e?window.innerHeight-i:window.innerHeight,l=e?0:i,c=e?i:0;this.cameras.main.setPosition(l,c).setViewport(l,c,o,a)}};E(ee,"key","EmptyScene");let Vt=ee;const I=class I{constructor(t){E(this,"state","readyToRecord");E(this,"events",[]);E(this,"eventEmitter",new y.Events.EventEmitter);E(this,"startRecordingTime");E(this,"startPlayingTime",0);E(this,"currentLoopIndex",0);E(this,"loopTimeout",null);this.trackIndex=t,this.log("Loop created")}getStartPlayingTime(){return this.startPlayingTime}getLoopLength(){var t;return(t=this.events.find(({callback:e})=>e==="endOfLoop"))==null?void 0:t.time}handleClick(){switch(this.nextState(),this.state){case"recording":this.startRecording();break;case"playing":this.startPlaying();break;case"readyToPlay":this.stopPlaying();break}}addLoopEvent(t){if(this.isRecording()){this.startRecordingTime||(this.startRecordingTime=I.masterLoop.getStartPlayingTime());const e=Date.now()-this.startRecordingTime;this.events.push({callback:t,time:e}),this.log(`Recording ${t} at time ${e}ms`)}}isPlaying(){return this.state==="playing"}isReadyToPlay(){return this.state==="readyToPlay"}isRecording(){return this.state==="recording"}isReadyToRecord(){return this.state==="readyToRecord"}destroy(){this.eventEmitter.removeAllListeners(),this.isPlaying()&&this.stopPlaying(),this.events=[],this.isMasterLoop()&&(I.masterLoop=null),this.log("Loop destroyed")}addEventListener(t,e){this.eventEmitter.once(t,e)}nextState(){switch(this.state){case"readyToRecord":this.state="recording";break;case"recording":this.state=this.stopRecording();break;case"readyToPlay":this.state="playing";break;case"playing":this.state="readyToPlay";break}}startRecording(){this.events=[],this.log("Recording started"),I.masterLoop||(I.masterLoop=this,this.startRecordingTime=Date.now())}stopRecording(){var e;if(this.events.length===0)return this.log("No events recorded"),"readyToRecord";if(!this.startRecordingTime)throw new Error("startRecordingTime is not set");const t=Date.now()-this.startRecordingTime;if(this.isMasterLoop()){this.events.push({callback:"endOfLoop",time:t});const i=this.events[0].time;this.events=this.events.map(({time:r,callback:s})=>({time:r-i,callback:s}))}else{console.log(this.events);const i=(e=I.masterLoop)==null?void 0:e.getLoopLength();if(!i)throw new Error("masterLoopLength is not set");const s=Math.floor(t/i)*i;this.events=this.events.filter(({time:o})=>o<=s),this.events.push({callback:"endOfLoop",time:s})}return this.log(`Recording stopped at ${t} with ${this.events.length} events, start playing`),"playing"}startPlaying(){var e;const t=()=>{this.currentLoopIndex>=this.events.length&&(this.currentLoopIndex=0),this.currentLoopIndex===0&&(this.log("Loop play (re)-started","#0F0"),this.startPlayingTime=Date.now());const{callback:i,time:r}=this.events[this.currentLoopIndex],s=this.currentLoopIndex===0?0:this.events[this.currentLoopIndex-1].time;this.loopTimeout=setTimeout(()=>{this.log(`Playing event ${i} after ${r}ms`),i!=="endOfLoop"?i():this.eventEmitter.emit("endOfLoop"),this.currentLoopIndex++,t()},r-s)};this.log("Loop play starting"),!this.isMasterLoop()&&((e=I.masterLoop)!=null&&e.isPlaying())?I.masterLoop.addEventListener("endOfLoop",()=>{t()}):t()}stopPlaying(){this.loopTimeout&&clearTimeout(this.loopTimeout),this.currentLoopIndex=0,this.log("Loop stopped")}isMasterLoop(){return this===I.masterLoop}log(t,e="#FFF"){const i=`%cLoop ${this.trackIndex+1}: ${t}`;console.log(i,`color: ${e}`)}};E(I,"masterLoop",null);let Yt=I;const ur={selected:"#DDD",unselected:"#000"},rn={play:"play_arrow",record:"fiber_manual_record",stop:"stop"},pt={idle:"#FFF",readyToRecord:"#0FF",recording:"#FD0041",playing:"#0F0"},f=class f extends y.Scene{constructor(){super(f.key);E(this,"resizeTracks",()=>{const e=window.innerWidth{const p=e?i*c:0,d=e?-1:r*c;s.setSize(i,r).setPosition(p,d);const h=e?s.getCenter().x:s.getCenter().x-i/4,S=e?s.getCenter().y-r/4:s.getCenter().y,x=Math.min(r,i);o.setResolution(3).setSize(i,r).setFontSize(x/4).setPosition(h,S),a.setSize(x/3,x/3).setPosition(h,S),l.setOrigin(e?.5:1,e?1:.5).setPosition(e?s.getCenter().x:s.getRightCenter().x,e?s.getBottomCenter().y:s.getCenter().y)}),this.cameras.main.setViewport(0,0,e?window.innerWidth:i,e?r:window.innerHeight)});f.instance=this}static get sceneWidthHeight(){const e=window.innerWidth,i=window.innerHeight;return Math.max(i,e)/10}static deleteCurrentTrack(){const e=f.tracks.find(i=>i.selected);if(e){const i=f.tracks.indexOf(e);return e.loop.destroy(),e.loopProgressArc.clear(),e.loop=new Yt(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(Vt.key,{index:e}),this.instance.updateControlsState()}static getTrackSceneKey(e){return`track_scene_${e}`}create(){this.cameras.main.setOrigin(0,0).setPosition(0,0).setViewport(0,0,f.sceneWidthHeight,window.innerHeight).setBackgroundColor("#963"),this.createTracks(),this.events.on("track-selected",()=>{this.updateControlsState()}),this.events.on("instrument-played",({callback:e})=>{var i,r;(r=(i=f.tracks.find(s=>s.selected))==null?void 0:i.loop)==null||r.addLoopEvent(e)})}update(){for(const e of f.tracks)e.loop.isPlaying()&&this.updateProgressArc(e)}getTrackScene(e){return this.scene.get(f.getTrackSceneKey(e))}updateProgressArc(e){const i=e.loop.getLoopLength();if(!i)throw new Error("Loop length is not defined");const s=(Date.now()-e.loop.getStartPlayingTime())/i;e.loopProgressArc.clear(),e.loopProgressArc.lineStyle(4,65280,1);const o=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 Yt(i),button:this.add.rectangle().setOrigin(0,0).setStrokeStyle(2,j("#FFF"),.8).setInteractive().on(y.Input.Events.POINTER_DOWN,()=>this.selectTrack(i)),selected:!1,buttonSelectedCircle:this.add.ellipse(0,0,0,0,j("#FFF")),buttonText:this.add.text(0,0,`${i+1}`,{fontFamily:kt.Text,fontSize:Wt.medium,color:ge.white}).setOrigin(.5,.5).setResolution(2),controlIcon:this.add.text(0,0,"",{fontFamily:kt.Icons,fontSize:Wt.medium,color:ge.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);s?s.scene.bringToTop():this.game.scene.start(Vt.key,{index:e})}}updateControlsState(){f.tracks.forEach((e,i)=>{e.button.setFillStyle(j(ur.unselected)),e.buttonText.setColor(e.selected?"#000":"#FFF"),e.buttonSelectedCircle.setVisible(!0).setFillStyle(j(e.selected?"#FFF":"#000")),this.getTrackScene(i)?e.selected&&(e.loop.isRecording()||e.loop.isReadyToRecord())?e.controlIcon.setText(rn.record).setColor(e.loop.isRecording()?pt.recording:pt.idle):e.loop.isPlaying()||e.loop.isReadyToPlay()?e.controlIcon.setText(rn.play).setColor(e.loop.isPlaying()?pt.playing:pt.idle):e.controlIcon.setText("").setColor(pt.idle):e.controlIcon.setText("").setColor(pt.idle)})}};E(f,"key","LoopTracksScene"),E(f,"numTracks",5),E(f,"tracks"),E(f,"instance");let w=f;const hr=()=>window.matchMedia("(prefers-color-scheme: dark)").matches;/*! Tweakpane 4.0.4 (c) 2016 cocopon, licensed under the MIT license. */function g(n){return n==null}function Ve(n){return n!==null&&typeof n=="object"}function we(n){return n!==null&&typeof n=="object"}function vr(n,t){if(n.length!==t.length)return!1;for(let e=0;e{const s=n[r],o=t[r];return we(s)&&we(o)?Object.assign(Object.assign({},i),{[r]:rt(s,o)}):Object.assign(Object.assign({},i),{[r]:r in t?o:s})},{})}function Se(n){return Ve(n)?"target"in n:!1}const mr={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 P{static alreadyDisposed(){return new P({type:"alreadydisposed"})}static notBindable(){return new P({type:"notbindable"})}static notCompatible(t,e){return new P({type:"notcompatible",context:{id:`${t}.${e}`}})}static propertyNotFound(t){return new P({type:"propertynotfound",context:{name:t}})}static shouldNeverHappen(){return new P({type:"shouldneverhappen"})}constructor(t){var e;this.message=(e=mr[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 Xt{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(!Xt.isBindable(i))throw P.notBindable();if(!(t in i))throw P.propertyNotFound(t);i[t]=e}}class k{constructor(){this.observers_={}}on(t,e,i){var r;let s=this.observers_[t];return s||(s=this.observers_[t]=[]),s.push({handler:e,key:(r=i==null?void 0:i.key)!==null&&r!==void 0?r:e}),this}off(t,e){const i=this.observers_[t];return i&&(this.observers_[t]=i.filter(r=>r.key!==e)),this}emit(t,e){const i=this.observers_[t];i&&i.forEach(r=>{r.handler(e)})}}class br{constructor(t,e){var i;this.constraint_=e==null?void 0:e.constraint,this.equals_=(i=e==null?void 0:e.equals)!==null&&i!==void 0?i:(r,s)=>r===s,this.emitter=new k,this.rawValue_=t}get constraint(){return this.constraint_}get rawValue(){return this.rawValue_}set rawValue(t){this.setRawValue(t,{forceEmit:!1,last:!0})}setRawValue(t,e){const i=e??{forceEmit:!1,last:!0},r=this.constraint_?this.constraint_.constrain(t):t,s=this.rawValue_;this.equals_(s,r)&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.rawValue_=r,this.emitter.emit("change",{options:i,previousRawValue:s,rawValue:r,sender:this}))}}class fr{constructor(t){this.emitter=new k,this.value_=t}get rawValue(){return this.value_}set rawValue(t){this.setRawValue(t,{forceEmit:!1,last:!0})}setRawValue(t,e){const i=e??{forceEmit:!1,last:!0},r=this.value_;r===t&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.value_=t,this.emitter.emit("change",{options:i,previousRawValue:r,rawValue:this.value_,sender:this}))}}class gr{constructor(t){this.emitter=new k,this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.value_=t,this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_)}get rawValue(){return this.value_.rawValue}onValueBeforeChange_(t){this.emitter.emit("beforechange",Object.assign(Object.assign({},t),{sender:this}))}onValueChange_(t){this.emitter.emit("change",Object.assign(Object.assign({},t),{sender:this}))}}function _(n,t){const e=t==null?void 0:t.constraint,i=t==null?void 0:t.equals;return!e&&!i?new fr(n):new br(n,t)}function wr(n){return[new gr(n),(t,e)=>{n.setRawValue(t,e)}]}class u{constructor(t){this.emitter=new k,this.valMap_=t;for(const e in this.valMap_)this.valMap_[e].emitter.on("change",()=>{this.emitter.emit("change",{key:e,sender:this})})}static createCore(t){return Object.keys(t).reduce((i,r)=>Object.assign(i,{[r]:_(t[r])}),{})}static fromObject(t){const e=this.createCore(t);return new u(e)}get(t){return this.valMap_[t].rawValue}set(t,e){this.valMap_[t].rawValue=e}value(t){return this.valMap_[t]}}class Mt{constructor(t){this.values=u.fromObject({max:t.max,min:t.min})}constrain(t){const e=this.values.get("max"),i=this.values.get("min");return Math.min(Math.max(t,i),e)}}class _r{constructor(t){this.values=u.fromObject({max:t.max,min:t.min})}constrain(t){const e=this.values.get("max"),i=this.values.get("min");let r=t;return g(i)||(r=Math.max(r,i)),g(e)||(r=Math.min(r,e)),r}}class Cr{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 xr{constructor(t){this.text=t}evaluate(){return Number(this.text)}toString(){return this.text}}const yr={"**":(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 Pr{constructor(t,e,i){this.left=e,this.operator=t,this.right=i}evaluate(){const t=yr[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 Er={"+":n=>n,"-":n=>-n,"~":n=>~n};class kr{constructor(t,e){this.operator=t,this.expression=e}evaluate(){const t=Er[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 Te(n){return(t,e)=>{for(let i=0;it.startsWith(r,e))[0];return i?(e+=i.length,e+=St(t,e).length,{cursor:e,operator:i}):null}function qr(n,t){return(e,i)=>{const r=n(e,i);if(!r)return null;i=r.cursor;let s=r.evaluable;for(;;){const o=Kr(t,e,i);if(!o)break;i=o.cursor;const a=n(e,i);if(!a)return null;i=a.cursor,s=new Pr(o.operator,s,a.evaluable)}return s?{cursor:i,evaluable:s}:null}}const Ur=[["**"],["*","/","%"],["+","-"],["<<",">>>",">>"],["&"],["^"],["|"]].reduce((n,t)=>qr(n,t),In);function jn(n,t){return t+=St(n,t).length,Ur(n,t)}function Gr(n){const t=jn(n,0);return!t||t.cursor+St(n,t.cursor).length!==n.length?null:t.evaluable}function U(n){var t;const e=Gr(n);return(t=e==null?void 0:e.evaluate())!==null&&t!==void 0?t:null}function Nn(n){if(typeof n=="number")return n;if(typeof n=="string"){const t=U(n);if(!g(t))return t}return 0}function Wr(n){return String(n)}function R(n){return t=>t.toFixed(Math.max(Math.min(n,20),0))}function b(n,t,e,i,r){const s=(n-t)/(e-t);return i+s*(r-i)}function sn(n){return String(n.toFixed(10)).split(".")[1].replace(/0+$/,"").length}function V(n,t,e){return Math.min(Math.max(n,t),e)}function zn(n,t){return(n%t+t)%t}function Yr(n,t){return g(n.step)?Math.max(sn(t),2):sn(n.step)}function Hn(n){var t;return(t=n.step)!==null&&t!==void 0?t:1}function $n(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 Kn(n,t){return g(n.step)?null:new Cr(n.step,t)}function qn(n){return!g(n.max)&&!g(n.min)?new Mt({max:n.max,min:n.min}):!g(n.max)||!g(n.min)?new _r({max:n.max,min:n.min}):null}function Un(n,t){var e,i,r;return{formatter:(e=n.format)!==null&&e!==void 0?e:R(Yr(n,t)),keyScale:(i=n.keyScale)!==null&&i!==void 0?i:Hn(n),pointerScale:(r=n.pointerScale)!==null&&r!==void 0?r:$n(n,t)}}function Gn(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 Ae(n){return{constraint:n.constraint,textProps:u.fromObject(Un(n.params,n.initialValue))}}class at{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 ie{constructor(t){this.target=t}}class Dt extends ie{constructor(t,e,i){super(t),this.value=e,this.last=i??!0}}class Xr extends ie{constructor(t,e){super(t),this.expanded=e}}class Qr extends ie{constructor(t,e){super(t),this.index=e}}class Zr extends ie{constructor(t,e){super(t),this.native=e}}class Lt extends at{constructor(t){super(t),this.onValueChange_=this.onValueChange_.bind(this),this.emitter_=new k,this.controller.value.emitter.on("change",this.onValueChange_)}get label(){return this.controller.labelController.props.get("label")}set label(t){this.controller.labelController.props.set("label",t)}get key(){return this.controller.value.binding.target.key}get tag(){return this.controller.tag}set tag(t){this.controller.tag=t}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}refresh(){this.controller.value.fetch()}onValueChange_(t){const e=this.controller.value;this.emitter_.emit("change",new Dt(this,e.binding.target.read(),t.options.last))}}class Jr{constructor(t,e){this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.binding=e,this.value_=t,this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_),this.emitter=new k}get rawValue(){return this.value_.rawValue}set rawValue(t){this.value_.rawValue=t}setRawValue(t,e){this.value_.setRawValue(t,e)}fetch(){this.value_.rawValue=this.binding.read()}push(){this.binding.write(this.value_.rawValue)}onValueBeforeChange_(t){this.emitter.emit("beforechange",Object.assign(Object.assign({},t),{sender:this}))}onValueChange_(t){this.push(),this.emitter.emit("change",Object.assign(Object.assign({},t),{sender:this}))}}function ts(n){if(!("binding"in n))return!1;const t=n.binding;return Se(t)&&"read"in t&&"write"in t}function es(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 ns(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 is(n){return n===null?!1:typeof n=="object"}function $(n){return t=>e=>{if(!t&&e===void 0)return{succeeded:!1,value:void 0};if(t&&e===void 0)return{succeeded:!0,value:void 0};const i=n(e);return i!==void 0?{succeeded:!0,value:i}:{succeeded:!1,value:void 0}}}function on(n){return{custom:t=>$(t)(n),boolean:$(t=>typeof t=="boolean"?t:void 0)(n),number:$(t=>typeof t=="number"?t:void 0)(n),string:$(t=>typeof t=="string"?t:void 0)(n),function:$(t=>typeof t=="function"?t:void 0)(n),constant:t=>$(e=>e===t?t:void 0)(n),raw:$(t=>t)(n),object:t=>$(e=>{if(is(e))return es(e,t)})(n),array:t=>$(e=>{if(Array.isArray(e))return ns(e,t)})(n)}}const _e={optional:on(!0),required:on(!1)};function C(n,t){const e=t(_e),i=_e.required.object(e)(n);return i.succeeded?i.value:void 0}function M(n,t,e,i){if(t&&!t(n))return!1;const r=C(n,e);return r?i(r):!1}function D(n,t){var e;return rt((e=n==null?void 0:n())!==null&&e!==void 0?e:{},t)}function it(n){return"value"in n}function Wn(n){if(!Ve(n)||!("binding"in n))return!1;const t=n.binding;return Se(t)}const N="http://www.w3.org/2000/svg";function Qt(n){n.offsetHeight}function rs(n,t){const e=n.style.transition;n.style.transition="none",t(),n.style.transition=e}function Re(n){return n.ontouchstart!==void 0}function ss(){return globalThis}function os(){return ss().document}function as(n){const t=n.ownerDocument.defaultView;return t&&"document"in t?n.getContext("2d",{willReadFrequently:!0}):null}const ls={check:'',dropdown:'',p2dpad:''};function re(n,t){const e=n.createElementNS(N,"svg");return e.innerHTML=ls[t],e}function Yn(n,t,e){n.insertBefore(t,n.children[e])}function Oe(n){n.parentElement&&n.parentElement.removeChild(n)}function Xn(n){for(;n.children.length>0;)n.removeChild(n.children[0])}function cs(n){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])}function Qn(n){return n.relatedTarget?n.relatedTarget:"explicitOriginalTarget"in n?n.explicitOriginalTarget:null}function q(n,t){n.emitter.on("change",e=>{t(e.rawValue)}),t(n.rawValue)}function z(n,t,e){q(n.value(t),e)}const ps="tp";function v(n){return(e,i)=>[ps,"-",n,"v",e?`_${e}`:"",i?`-${i}`:""].join("")}const Ct=v("lbl");function ds(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 Zn{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(Ct()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(Ct("l")),z(e.props,"label",s=>{g(s)?this.element.classList.add(Ct(void 0,"nol")):(this.element.classList.remove(Ct(void 0,"nol")),cs(i),i.appendChild(ds(t,s)))}),this.element.appendChild(i),this.labelElement=i;const r=t.createElement("div");r.classList.add(Ct("v")),this.element.appendChild(r),this.valueElement=r}}class Jn{constructor(t,e){this.props=e.props,this.valueController=e.valueController,this.viewProps=e.valueController.viewProps,this.view=new Zn(t,{props:e.props,viewProps:this.viewProps}),this.view.valueElement.appendChild(this.valueController.view.element)}importProps(t){return M(t,null,e=>({label:e.optional.string}),e=>(this.props.set("label",e.label),!0))}exportProps(){return D(null,{label:this.props.get("label")})}}function us(){return["veryfirst","first","last","verylast"]}const an=v(""),ln={veryfirst:"vfst",first:"fst",last:"lst",verylast:"vlst"};class se{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",()=>{us().forEach(i=>{e.classList.remove(an(void 0,ln[i]))}),this.blade.get("positions").forEach(i=>{e.classList.add(an(void 0,ln[i]))})}),this.viewProps.handleDispose(()=>{Oe(e)})}get parent(){return this.parent_}set parent(t){this.parent_=t,this.viewProps.set("parent",this.parent_?this.parent_.viewProps:null)}importState(t){return M(t,null,e=>({disabled:e.required.boolean,hidden:e.required.boolean}),e=>(this.viewProps.importState(e),!0))}exportState(){return D(null,Object.assign({},this.viewProps.exportState()))}}class st extends se{constructor(t,e){if(e.value!==e.valueController.value)throw P.shouldNeverHappen();const i=e.valueController.viewProps,r=new Jn(t,{blade:e.blade,props:e.props,valueController:e.valueController});super(Object.assign(Object.assign({},e),{view:new Zn(t,{props:e.props,viewProps:i}),viewProps:i})),this.labelController=r,this.value=e.value,this.valueController=e.valueController,this.view.valueElement.appendChild(this.valueController.view.element)}importState(t){return M(t,e=>{var i,r,s;return super.importState(e)&&this.labelController.importProps(e)&&((s=(r=(i=this.valueController).importProps)===null||r===void 0?void 0:r.call(i,t))!==null&&s!==void 0?s:!0)},e=>({value:e.optional.raw}),e=>(e.value&&(this.value.rawValue=e.value),!0))}exportState(){var t,e,i;return D(()=>super.exportState(),Object.assign(Object.assign({value:this.value.rawValue},this.labelController.exportProps()),(i=(e=(t=this.valueController).exportProps)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:{}))}}function cn(n){const t=Object.assign({},n);return delete t.value,t}class ti extends st{constructor(t,e){super(t,e),this.tag=e.tag}importState(t){return M(t,e=>super.importState(cn(t)),e=>({tag:e.optional.string}),e=>(this.tag=e.tag,!0))}exportState(){return D(()=>cn(super.exportState()),{binding:{key:this.value.binding.target.key,value:this.value.binding.target.read()},tag:this.tag})}}function hs(n){return it(n)&&Wn(n.value)}class vs extends ti{importState(t){return M(t,e=>super.importState(e),e=>({binding:e.required.object({value:e.required.raw})}),e=>(this.value.binding.inject(e.binding.value),this.value.fetch(),!0))}}function ms(n){return it(n)&&ts(n.value)}function ei(n,t){for(;n.lengthn.length?e.splice(0,e.length-n.length):ei(e,n.length),e}class ws{constructor(t){this.emitter=new k,this.onTick_=this.onTick_.bind(this),this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.binding=t.binding,this.value_=_(bs(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=gs(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 _s(n){if(!("binding"in n))return!1;const t=n.binding;return Se(t)&&"read"in t&&!("write"in t)}class Cs extends ti{exportState(){return D(()=>super.exportState(),{binding:{readonly:!0}})}}function xs(n){return it(n)&&_s(n.value)}class ys extends at{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 Zr(this,s.nativeEvent))}),this}off(t,e){return this.controller.buttonController.emitter.off(t,e),this}}function Ps(n,t,e){e?n.classList.add(t):n.classList.remove(t)}function bt(n,t){return e=>{Ps(n,t,e)}}function Me(n,t){q(n,e=>{t.textContent=e??""})}const ce=v("btn");class Es{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(ce()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("button");i.classList.add(ce("b")),e.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const r=t.createElement("div");r.classList.add(ce("t")),Me(e.props.value("title"),r),this.buttonElement.appendChild(r)}}class ks{constructor(t,e){this.emitter=new k,this.onClick_=this.onClick_.bind(this),this.props=e.props,this.viewProps=e.viewProps,this.view=new Es(t,{props:this.props,viewProps:this.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}importProps(t){return M(t,null,e=>({title:e.optional.string}),e=>(this.props.set("title",e.title),!0))}exportProps(){return D(null,{title:this.props.get("title")})}onClick_(t){this.emitter.emit("click",{nativeEvent:t,sender:this})}}class pn extends se{constructor(t,e){const i=new ks(t,{props:e.buttonProps,viewProps:e.viewProps}),r=new Jn(t,{blade:e.blade,props:e.labelProps,valueController:i});super({blade:e.blade,view:r.view,viewProps:e.viewProps}),this.buttonController=i,this.labelController=r}importState(t){return M(t,e=>super.importState(e)&&this.buttonController.importProps(e)&&this.labelController.importProps(e),()=>({}),()=>!0)}exportState(){return D(()=>super.exportState(),Object.assign(Object.assign({},this.buttonController.exportProps()),this.labelController.exportProps()))}}class ni{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 ft=new ni("2.0.4");function L(n){return Object.assign({core:ft},n)}const Vs=L({id:"button",type:"blade",accept(n){const t=C(n,e=>({title:e.required.string,view:e.required.constant("button"),label:e.optional.string}));return t?{params:t}:null},controller(n){return new pn(n.document,{blade:n.blade,buttonProps:u.fromObject({title:n.params.title}),labelProps:u.fromObject({label:n.params.label}),viewProps:n.viewProps})},api(n){return n.controller instanceof pn?new ys(n.controller):null}});function Ss(n,t){return n.addBlade(Object.assign(Object.assign({},t),{view:"button"}))}function Ts(n,t){return n.addBlade(Object.assign(Object.assign({},t),{view:"folder"}))}function Ls(n,t){return n.addBlade(Object.assign(Object.assign({},t),{view:"tab"}))}function As(n){return Ve(n)?"refresh"in n&&typeof n.refresh=="function":!1}function Rs(n,t){if(!Xt.isBindable(n))throw P.notBindable();return new Xt(n,t)}class Os{constructor(t,e){this.onRackValueChange_=this.onRackValueChange_.bind(this),this.controller_=t,this.emitter_=new k,this.pool_=e,this.controller_.rack.emitter.on("valuechange",this.onRackValueChange_)}get children(){return this.controller_.rack.children.map(t=>this.pool_.createApi(t))}addBinding(t,e,i){const r=i??{},s=this.controller_.element.ownerDocument,o=this.pool_.createBinding(s,Rs(t,e),r),a=this.pool_.createBindingApi(o);return this.add(a,r.index)}addFolder(t){return Ts(this,t)}addButton(t){return Ss(this,t)}addTab(t){return Ls(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=>{As(t)&&t.refresh()})}onRackValueChange_(t){const e=t.bladeController,i=this.pool_.createApi(e),r=Wn(e.value)?e.value.binding:null;this.emitter_.emit("change",new Dt(i,r?r.target.read():e.value.rawValue,t.options.last))}}class De extends at{constructor(t,e){super(t),this.rackApi_=new Os(t.rackController,e)}refresh(){this.rackApi_.refresh()}}class Fe extends se{constructor(t){super({blade:t.blade,view:t.view,viewProps:t.rackController.viewProps}),this.rackController=t.rackController}importState(t){return M(t,e=>super.importState(e),e=>({children:e.required.array(e.required.raw)}),e=>this.rackController.rack.children.every((i,r)=>i.importState(e.children[r])))}exportState(){return D(()=>super.exportState(),{children:this.rackController.rack.children.map(t=>t.exportState())})}}function Ce(n){return"rackController"in n}class Ms{constructor(t){this.emitter=new k,this.items_=[],this.cache_=new Set,this.onSubListAdd_=this.onSubListAdd_.bind(this),this.onSubListRemove_=this.onSubListRemove_.bind(this),this.extract_=t}get items(){return this.items_}allItems(){return Array.from(this.cache_)}find(t){for(const e of this.allItems())if(t(e))return e;return null}includes(t){return this.cache_.has(t)}add(t,e){if(this.includes(t))throw P.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 Ds(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=Ds(this.find(it),t.sender);if(!e)throw P.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 Be{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 Bs({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&&Yn(this.element,t.bladeController.view.element,t.index)}onRackRemove_(t){t.root&&Oe(t.bladeController.view.element)}}function gt(){return new u({positions:_([],{equals:vr})})}class Ft extends u{constructor(t){super(t)}static create(t){const e={completed:!0,expanded:t,expandedHeight:null,shouldFixHeight:!1,temporaryExpanded:null},i=u.createCore(e);return new Ft(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 Is(n,t){let e=0;return rs(t,()=>{n.set("expandedHeight",null),n.set("temporaryExpanded",!0),Qt(t),e=t.clientHeight,n.set("temporaryExpanded",null),Qt(t)}),e}function dn(n,t){t.style.height=n.styleHeight}function Ie(n,t){n.value("expanded").emitter.on("beforechange",()=>{if(n.set("completed",!1),g(n.get("expandedHeight"))){const e=Is(n,t);e>0&&n.set("expandedHeight",e)}n.set("shouldFixHeight",!0),Qt(t)}),n.emitter.on("change",()=>{dn(n,t)}),dn(n,t),t.addEventListener("transitionend",e=>{e.propertyName==="height"&&n.cleanUpTransition()})}class ii extends De{constructor(t,e){super(t,e),this.emitter_=new k,this.controller.foldable.value("expanded").emitter.on("change",i=>{this.emitter_.emit("fold",new Xr(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 ri=v("cnt");class js{constructor(t,e){var i;this.className_=v((i=e.viewName)!==null&&i!==void 0?i:"fld"),this.element=t.createElement("div"),this.element.classList.add(this.className_(),ri()),e.viewProps.bindClassModifiers(this.element),this.foldable_=e.foldable,this.foldable_.bindExpandedClass(this.element,this.className_(void 0,"expanded")),z(this.foldable_,"completed",bt(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")),Me(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 xe extends Fe{constructor(t,e){var i;const r=Ft.create((i=e.expanded)!==null&&i!==void 0?i:!0),s=new js(t,{foldable:r,props:e.props,viewName:e.root?"rot":void 0,viewProps:e.viewProps});super(Object.assign(Object.assign({},e),{rackController:new Be({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,Ie(this.foldable,this.view.containerElement),this.rackController.rack.emitter.on("add",()=>{this.foldable.cleanUpTransition()}),this.rackController.rack.emitter.on("remove",()=>{this.foldable.cleanUpTransition()}),this.view.buttonElement.addEventListener("click",this.onTitleClick_)}get document(){return this.view.element.ownerDocument}importState(t){return M(t,e=>super.importState(e),e=>({expanded:e.required.boolean,title:e.optional.string}),e=>(this.foldable.set("expanded",e.expanded),this.props.set("title",e.title),!0))}exportState(){return D(()=>super.exportState(),{expanded:this.foldable.get("expanded"),title:this.props.get("title")})}onTitleClick_(){this.foldable.set("expanded",!this.foldable.get("expanded"))}}const Ns=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 xe(n.document,{blade:n.blade,expanded:n.params.expanded,props:u.fromObject({title:n.params.title}),viewProps:n.viewProps})},api(n){return n.controller instanceof xe?new ii(n.controller,n.pool):null}}),zs=v("");function un(n,t){return bt(n,zs(void 0,t))}class W extends u{constructor(t){var e;super(t),this.onDisabledChange_=this.onDisabledChange_.bind(this),this.onParentChange_=this.onParentChange_.bind(this),this.onParentGlobalDisabledChange_=this.onParentGlobalDisabledChange_.bind(this),[this.globalDisabled_,this.setGlobalDisabled_]=wr(_(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 W(u.createCore({disabled:(e=s.disabled)!==null&&e!==void 0?e:!1,disposed:!1,hidden:(i=s.hidden)!==null&&i!==void 0?i:!1,parent:(r=s.parent)!==null&&r!==void 0?r:null}))}get globalDisabled(){return this.globalDisabled_}bindClassModifiers(t){q(this.globalDisabled_,un(t,"disabled")),z(this,"hidden",un(t,"hidden"))}bindDisabled(t){q(this.globalDisabled_,e=>{t.disabled=e})}bindTabIndex(t){q(this.globalDisabled_,e=>{t.tabIndex=e?-1:0})}handleDispose(t){this.value("disposed").emitter.on("change",e=>{e&&t()})}importState(t){this.set("disabled",t.disabled),this.set("hidden",t.hidden)}exportState(){return{disabled:this.get("disabled"),hidden:this.get("hidden")}}getGlobalDisabled_(){const t=this.get("parent");return(t?t.globalDisabled.rawValue:!1)||this.get("disabled")}updateGlobalDisabled_(){this.setGlobalDisabled_(this.getGlobalDisabled_())}onDisabledChange_(){this.updateGlobalDisabled_()}onParentGlobalDisabledChange_(){this.updateGlobalDisabled_()}onParentChange_(t){var e;const i=t.previousRawValue;i==null||i.globalDisabled.emitter.off("change",this.onParentGlobalDisabledChange_),(e=this.get("parent"))===null||e===void 0||e.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_),this.updateGlobalDisabled_()}}const hn=v("tbp");class Hs{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(hn()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(hn("c")),this.element.appendChild(i),this.containerElement=i}}const xt=v("tbi");class $s{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(xt()),e.viewProps.bindClassModifiers(this.element),z(e.props,"selected",s=>{s?this.element.classList.add(xt(void 0,"sel")):this.element.classList.remove(xt(void 0,"sel"))});const i=t.createElement("button");i.classList.add(xt("b")),e.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const r=t.createElement("div");r.classList.add(xt("t")),Me(e.props.value("title"),r),this.buttonElement.appendChild(r),this.titleElement=r}}class Ks{constructor(t,e){this.emitter=new k,this.onClick_=this.onClick_.bind(this),this.props=e.props,this.viewProps=e.viewProps,this.view=new $s(t,{props:e.props,viewProps:e.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}onClick_(){this.emitter.emit("click",{sender:this})}}class ye extends Fe{constructor(t,e){const i=new Hs(t,{viewProps:e.viewProps});super(Object.assign(Object.assign({},e),{rackController:new Be({blade:e.blade,element:i.containerElement,viewProps:e.viewProps}),view:i})),this.onItemClick_=this.onItemClick_.bind(this),this.ic_=new Ks(t,{props:e.itemProps,viewProps:W.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 M(t,e=>super.importState(e),e=>({selected:e.required.boolean,title:e.required.string}),e=>(this.ic_.props.set("selected",e.selected),this.ic_.props.set("title",e.title),!0))}exportState(){return D(()=>super.exportState(),{selected:this.ic_.props.get("selected"),title:this.ic_.props.get("title")})}onItemClick_(){this.props.set("selected",!0)}}class qs extends De{constructor(t,e){super(t,e),this.emitter_=new k,this.onSelect_=this.onSelect_.bind(this),this.pool_=e,this.rackApi_.on("change",i=>{this.emitter_.emit("change",i)}),this.controller.tab.selectedIndex.emitter.on("change",this.onSelect_)}get pages(){return this.rackApi_.children}addPage(t){const e=this.controller.view.element.ownerDocument,i=new ye(e,{blade:gt(),itemProps:u.fromObject({selected:!1,title:t.title}),props:u.fromObject({selected:!1}),viewProps:W.create()}),r=this.pool_.createApi(i);return this.rackApi_.add(r,t.index)}removePage(t){this.rackApi_.remove(this.rackApi_.children[t])}on(t,e){const i=e.bind(this);return this.emitter_.on(t,r=>{i(r)},{key:e}),this}off(t,e){return this.emitter_.off(t,e),this}onSelect_(t){this.emitter_.emit("select",new Qr(this,t.rawValue))}}class Us extends De{get title(){var t;return(t=this.controller.itemController.props.get("title"))!==null&&t!==void 0?t:""}set title(t){this.controller.itemController.props.set("title",t)}get selected(){return this.controller.props.get("selected")}set selected(t){this.controller.props.set("selected",t)}get children(){return this.rackApi_.children}addButton(t){return this.rackApi_.addButton(t)}addFolder(t){return this.rackApi_.addFolder(t)}addTab(t){return this.rackApi_.addTab(t)}add(t,e){this.rackApi_.add(t,e)}remove(t){this.rackApi_.remove(t)}addBinding(t,e,i){return this.rackApi_.addBinding(t,e,i)}addBlade(t){return this.rackApi_.addBlade(t)}}const vn=-1;class Gs{constructor(){this.onItemSelectedChange_=this.onItemSelectedChange_.bind(this),this.empty=_(!0),this.selectedIndex=_(vn),this.items_=[]}add(t,e){const i=e??this.items_.length;this.items_.splice(i,0,t),t.emitter.on("change",this.onItemSelectedChange_),this.keepSelection_()}remove(t){const e=this.items_.indexOf(t);e<0||(this.items_.splice(e,1),t.emitter.off("change",this.onItemSelectedChange_),this.keepSelection_())}keepSelection_(){if(this.items_.length===0){this.selectedIndex.rawValue=vn,this.empty.rawValue=!0;return}const t=this.items_.findIndex(e=>e.rawValue);t<0?(this.items_.forEach((e,i)=>{e.rawValue=i===0}),this.selectedIndex.rawValue=0):(this.items_.forEach((e,i)=>{e.rawValue=i===t}),this.selectedIndex.rawValue=t),this.empty.rawValue=!1}onItemSelectedChange_(t){if(t.rawValue){const e=this.items_.findIndex(i=>i===t.sender);this.items_.forEach((i,r)=>{i.rawValue=r===e}),this.selectedIndex.rawValue=e}else this.keepSelection_()}}const yt=v("tab");class Ws{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(yt(),ri()),e.viewProps.bindClassModifiers(this.element),q(e.empty,bt(this.element,yt(void 0,"nop")));const i=t.createElement("div");i.classList.add(yt("t")),this.element.appendChild(i),this.itemsElement=i;const r=t.createElement("div");r.classList.add(yt("i")),this.element.appendChild(r);const s=t.createElement("div");s.classList.add(yt("c")),this.element.appendChild(s),this.contentsElement=s}}class mn extends Fe{constructor(t,e){const i=new Gs,r=new Ws(t,{empty:i.empty,viewProps:e.viewProps});super({blade:e.blade,rackController:new Be({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;Yn(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;Oe(e.itemController.view.element),e.itemController.viewProps.set("parent",null),this.tab.remove(e.props.value("selected"))}}const si=L({id:"tab",type:"blade",accept(n){const t=C(n,e=>({pages:e.required.array(e.required.object({title:e.required.string})),view:e.required.constant("tab")}));return!t||t.pages.length===0?null:{params:t}},controller(n){const t=new mn(n.document,{blade:n.blade,viewProps:n.viewProps});return n.params.pages.forEach(e=>{const i=new ye(n.document,{blade:gt(),itemProps:u.fromObject({selected:!1,title:e.title}),props:u.fromObject({selected:!1}),viewProps:W.create()});t.add(i)}),t},api(n){return n.controller instanceof mn?new qs(n.controller,n.pool):n.controller instanceof ye?new Us(n.controller,n.pool):null}});function Ys(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:gt(),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:W.create({disabled:i==null?void 0:i.disabled,hidden:i==null?void 0:i.hidden})})}class je extends Lt{get options(){return this.controller.valueController.props.get("options")}set options(t){this.controller.valueController.props.set("options",t)}}class Xs{constructor(){this.disabled=!1,this.emitter=new k}dispose(){}tick(){this.disabled||this.emitter.emit("tick",{sender:this})}}class Qs{constructor(t,e){this.disabled_=!1,this.timerId_=null,this.onTick_=this.onTick_.bind(this),this.doc_=t,this.emitter=new k,this.interval_=e,this.setTimer_()}get disabled(){return this.disabled_}set disabled(t){this.disabled_=t,this.disabled_?this.clearTimer_():this.setTimer_()}dispose(){this.clearTimer_()}clearTimer_(){if(this.timerId_===null)return;const t=this.doc_.defaultView;t&&t.clearInterval(this.timerId_),this.timerId_=null}setTimer_(){if(this.clearTimer_(),this.interval_<=0)return;const t=this.doc_.defaultView;t&&(this.timerId_=t.setInterval(this.onTick_,this.interval_))}onTick_(){this.disabled_||this.emitter.emit("tick",{sender:this})}}class Bt{constructor(t){this.constraints=t}constrain(t){return this.constraints.reduce((e,i)=>i.constrain(e),t)}}function Zt(n,t){if(n instanceof t)return n;if(n instanceof Bt){const e=n.constraints.reduce((i,r)=>i||(r instanceof t?r:null),null);if(e)return e}return null}class It{constructor(t){this.values=u.fromObject({options:t})}constrain(t){const e=this.values.get("options");return e.length===0||e.filter(r=>r.value===t).length>0?t:e[0].value}}function jt(n){var t;const e=_e;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 Ne(n){if(Array.isArray(n))return n;const t=[];return Object.keys(n).forEach(e=>{t.push({text:e,value:n[e]})}),t}function ze(n){return g(n)?null:new It(Ne(n))}const pe=v("lst");class Zs{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.props_=e.props,this.element=t.createElement("div"),this.element.classList.add(pe()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("select");i.classList.add(pe("s")),e.viewProps.bindDisabled(i),this.element.appendChild(i),this.selectElement=i;const r=t.createElement("div");r.classList.add(pe("m")),r.appendChild(re(t,"dropdown")),this.element.appendChild(r),e.value.emitter.on("change",this.onValueChange_),this.value_=e.value,z(this.props_,"options",s=>{Xn(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 tt{constructor(t,e){this.onSelectChange_=this.onSelectChange_.bind(this),this.props=e.props,this.value=e.value,this.viewProps=e.viewProps,this.view=new Zs(t,{props:this.props,value:this.value,viewProps:this.viewProps}),this.view.selectElement.addEventListener("change",this.onSelectChange_)}onSelectChange_(t){const e=t.currentTarget;this.value.rawValue=this.props.get("options")[e.selectedIndex].value}importProps(t){return M(t,null,e=>({options:e.required.custom(jt)}),e=>(this.props.set("options",Ne(e.options)),!0))}exportProps(){return D(null,{options:this.props.get("options")})}}const bn=v("pop");class Js{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(bn()),e.viewProps.bindClassModifiers(this.element),q(e.shows,bt(this.element,bn(void 0,"v")))}}class oi{constructor(t,e){this.shows=_(!1),this.viewProps=e.viewProps,this.view=new Js(t,{shows:this.shows,viewProps:this.viewProps})}}const fn=v("txt");class to{constructor(t,e){this.onChange_=this.onChange_.bind(this),this.element=t.createElement("div"),this.element.classList.add(fn()),e.viewProps.bindClassModifiers(this.element),this.props_=e.props,this.props_.emitter.on("change",this.onChange_);const i=t.createElement("input");i.classList.add(fn("i")),i.type="text",e.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,e.value.emitter.on("change",this.onChange_),this.value_=e.value,this.refresh()}refresh(){const t=this.props_.get("formatter");this.inputElement.value=t(this.value_.rawValue)}onChange_(){this.refresh()}}class At{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 to(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 eo(n){return String(n)}function ai(n){return n==="false"?!1:!!n}function gn(n){return eo(n)}function no(n){return t=>n.reduce((e,i)=>e!==null?e:i(t),null)}const io=R(0);function Jt(n){return io(n)+"%"}function li(n){return String(n)}function Pe(n){return n}function wt({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 Rt(n){return{altKey:n.altKey,downKey:n.key==="ArrowDown",shiftKey:n.shiftKey,upKey:n.key==="ArrowUp"}}function G(n){return{altKey:n.altKey,downKey:n.key==="ArrowLeft",shiftKey:n.shiftKey,upKey:n.key==="ArrowRight"}}function ro(n){return n==="ArrowUp"||n==="ArrowDown"}function ci(n){return ro(n)||n==="ArrowLeft"||n==="ArrowRight"}function de(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 lt{constructor(t){this.lastTouch_=null,this.onDocumentMouseMove_=this.onDocumentMouseMove_.bind(this),this.onDocumentMouseUp_=this.onDocumentMouseUp_.bind(this),this.onMouseDown_=this.onMouseDown_.bind(this),this.onTouchEnd_=this.onTouchEnd_.bind(this),this.onTouchMove_=this.onTouchMove_.bind(this),this.onTouchStart_=this.onTouchStart_.bind(this),this.elem_=t,this.emitter=new k,t.addEventListener("touchstart",this.onTouchStart_,{passive:!1}),t.addEventListener("touchmove",this.onTouchMove_,{passive:!0}),t.addEventListener("touchend",this.onTouchEnd_),t.addEventListener("mousedown",this.onMouseDown_)}computePosition_(t){const e=this.elem_.getBoundingClientRect();return{bounds:{width:e.width,height:e.height},point:t?{x:t.x,y:t.y}:null}}onMouseDown_(t){var e;t.preventDefault(),(e=t.currentTarget)===null||e===void 0||e.focus();const i=this.elem_.ownerDocument;i.addEventListener("mousemove",this.onDocumentMouseMove_),i.addEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("down",{altKey:t.altKey,data:this.computePosition_(de(t,this.elem_)),sender:this,shiftKey:t.shiftKey})}onDocumentMouseMove_(t){this.emitter.emit("move",{altKey:t.altKey,data:this.computePosition_(de(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_(de(t,this.elem_)),sender:this,shiftKey:t.shiftKey})}onTouchStart_(t){t.preventDefault();const e=t.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("down",{altKey:t.altKey,data:this.computePosition_(e?{x:e.clientX-i.left,y:e.clientY-i.top}:void 0),sender:this,shiftKey:t.shiftKey}),this.lastTouch_=e}onTouchMove_(t){const e=t.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("move",{altKey:t.altKey,data:this.computePosition_(e?{x:e.clientX-i.left,y:e.clientY-i.top}:void 0),sender:this,shiftKey:t.shiftKey}),this.lastTouch_=e}onTouchEnd_(t){var e;const i=(e=t.targetTouches.item(0))!==null&&e!==void 0?e:this.lastTouch_,r=this.elem_.getBoundingClientRect();this.emitter.emit("up",{altKey:t.altKey,data:this.computePosition_(i?{x:i.clientX-r.left,y:i.clientY-r.top}:void 0),sender:this,shiftKey:t.shiftKey})}}const F=v("txt");class so{constructor(t,e){this.onChange_=this.onChange_.bind(this),this.props_=e.props,this.props_.emitter.on("change",this.onChange_),this.element=t.createElement("div"),this.element.classList.add(F(),F(void 0,"num")),e.arrayPosition&&this.element.classList.add(F(void 0,e.arrayPosition)),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("input");i.classList.add(F("i")),i.type="text",e.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,this.onDraggingChange_=this.onDraggingChange_.bind(this),this.dragging_=e.dragging,this.dragging_.emitter.on("change",this.onDraggingChange_),this.element.classList.add(F()),this.inputElement.classList.add(F("i"));const r=t.createElement("div");r.classList.add(F("k")),this.element.appendChild(r),this.knobElement=r;const s=t.createElementNS(N,"svg");s.classList.add(F("g")),this.knobElement.appendChild(s);const o=t.createElementNS(N,"path");o.classList.add(F("gb")),s.appendChild(o),this.guideBodyElem_=o;const a=t.createElementNS(N,"path");a.classList.add(F("gh")),s.appendChild(a),this.guideHeadElem_=a;const l=t.createElement("div");l.classList.add(v("tt")()),this.knobElement.appendChild(l),this.tooltipElem_=l,e.value.emitter.on("change",this.onChange_),this.value=e.value,this.refresh()}onDraggingChange_(t){if(t.rawValue===null){this.element.classList.remove(F(void 0,"drg"));return}this.element.classList.add(F(void 0,"drg"));const e=t.rawValue/this.props_.get("pointerScale"),i=e+(e>0?-1:e<0?1:0),r=V(-i,-4,4);this.guideHeadElem_.setAttributeNS(null,"d",[`M ${i+r},0 L${i},4 L${i+r},8`,`M ${e},-1 L${e},9`].join(" ")),this.guideBodyElem_.setAttributeNS(null,"d",`M 0,4 L${e},4`);const s=this.props_.get("formatter");this.tooltipElem_.textContent=s(this.value.rawValue),this.tooltipElem_.style.left=`${e}px`}refresh(){const t=this.props_.get("formatter");this.inputElement.value=t(this.value.rawValue)}onChange_(){this.refresh()}}class Nt{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 so(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 lt(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"),Rt(t));e!==0&&this.value.setRawValue(this.constrainValue_(this.value.rawValue+e),{forceEmit:!1,last:!1})}onInputKeyUp_(t){A(this.props.get("keyScale"),Rt(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 ue=v("sld");class oo{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(ue()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(ue("t")),e.viewProps.bindTabIndex(i),this.element.appendChild(i),this.trackElement=i;const r=t.createElement("div");r.classList.add(ue("k")),this.trackElement.appendChild(r),this.knobElement=r,e.value.emitter.on("change",this.onChange_),this.value=e.value,this.update_()}update_(){const t=V(b(this.value.rawValue,this.props_.get("min"),this.props_.get("max"),0,100),0,100);this.knobElement.style.width=`${t}%`}onChange_(){this.update_()}}class ao{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 oo(t,{props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new lt(this.view.trackElement),this.ptHandler_.emitter.on("down",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("move",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.trackElement.addEventListener("keydown",this.onKeyDown_),this.view.trackElement.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(t,e){t.point&&this.value.setRawValue(b(V(t.point.x,0,t.bounds.width),0,t.bounds.width,this.props.get("min"),this.props.get("max")),e)}onPointerDownOrMove_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerUp_(t){this.handlePointerEvent_(t.data,{forceEmit:!0,last:!0})}onKeyDown_(t){const e=A(this.props.get("keyScale"),G(t));e!==0&&this.value.setRawValue(this.value.rawValue+e,{forceEmit:!1,last:!1})}onKeyUp_(t){A(this.props.get("keyScale"),G(t))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const he=v("sldtxt");class lo{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(he());const i=t.createElement("div");i.classList.add(he("s")),this.sliderView_=e.sliderView,i.appendChild(this.sliderView_.element),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(he("t")),this.textView_=e.textView,r.appendChild(this.textView_.element),this.element.appendChild(r)}}class te{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.sliderC_=new ao(t,{props:e.sliderProps,value:e.value,viewProps:this.viewProps}),this.textC_=new Nt(t,{parser:e.parser,props:e.textProps,sliderProps:e.sliderProps,value:e.value,viewProps:e.viewProps}),this.view=new lo(t,{sliderView:this.sliderC_.view,textView:this.textC_.view})}get sliderController(){return this.sliderC_}get textController(){return this.textC_}importProps(t){return M(t,null,e=>({max:e.required.number,min:e.required.number}),e=>{const i=this.sliderC_.props;return i.set("max",e.max),i.set("min",e.min),!0})}exportProps(){const t=this.sliderC_.props;return D(null,{max:t.get("max"),min:t.get("min")})}}function pi(n){return{sliderProps:new u({keyScale:n.keyScale,max:n.max,min:n.min}),textProps:new u({formatter:_(n.formatter),keyScale:n.keyScale,pointerScale:_(n.pointerScale)})}}const co={containerUnitSize:"cnt-usz"};function di(n){return`--${co[n]}`}function Ot(n){return Gn(n)}function Z(n){if(we(n))return C(n,Ot)}function K(n,t){if(!n)return;const e=[],i=Kn(n,t);i&&e.push(i);const r=qn(n);return r&&e.push(r),new Bt(e)}function po(n){return n?n.major===ft.major:!1}function ui(n){if(n==="inline"||n==="popup")return n}function zt(n,t){n.write(t)}const Kt=v("ckb");class uo{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.element=t.createElement("div"),this.element.classList.add(Kt()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("label");i.classList.add(Kt("l")),this.element.appendChild(i),this.labelElement=i;const r=t.createElement("input");r.classList.add(Kt("i")),r.type="checkbox",this.labelElement.appendChild(r),this.inputElement=r,e.viewProps.bindDisabled(this.inputElement);const s=t.createElement("div");s.classList.add(Kt("w")),this.labelElement.appendChild(s);const o=re(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 ho{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 uo(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 vo(n){const t=[],e=ze(n.options);return e&&t.push(e),new Bt(t)}const mo=L({id:"input-bool",type:"input",accept:(n,t)=>{if(typeof n!="boolean")return null;const e=C(t,i=>({options:i.optional.custom(jt),readonly:i.optional.constant(!1)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>ai,constraint:n=>vo(n.params),writer:n=>zt},controller:n=>{const t=n.document,e=n.value,i=n.constraint,r=i&&Zt(i,It);return r?new tt(t,{props:new u({options:r.values.value("options")}),value:e,viewProps:n.viewProps}):new ho(t,{value:e,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="boolean"?null:n.controller.valueController instanceof tt?new je(n.controller):null}}),nt=v("col");class bo{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(nt()),e.foldable.bindExpandedClass(this.element,nt(void 0,"expanded")),z(e.foldable,"completed",bt(this.element,nt(void 0,"cpl")));const i=t.createElement("div");i.classList.add(nt("h")),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(nt("s")),i.appendChild(r),this.swatchElement=r;const s=t.createElement("div");if(s.classList.add(nt("t")),i.appendChild(s),this.textElement=s,e.pickerLayout==="inline"){const o=t.createElement("div");o.classList.add(nt("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}}function fo(n,t,e){const i=V(n/255,0,1),r=V(t/255,0,1),s=V(e/255,0,1),o=Math.max(i,r,s),a=Math.min(i,r,s),l=o-a;let c=0,p=0;const d=(a+o)/2;return l!==0&&(p=l/(1-Math.abs(o+a-1)),i===o?c=(r-s)/l:r===o?c=2+(s-i)/l:c=4+(i-r)/l,c=c/6+(c<0?1:0)),[c*360,p*100,d*100]}function go(n,t,e){const i=(n%360+360)%360,r=V(t/100,0,1),s=V(e/100,0,1),o=(1-Math.abs(2*s-1))*r,a=o*(1-Math.abs(i/60%2-1)),l=s-o/2;let c,p,d;return i>=0&&i<60?[c,p,d]=[o,a,0]:i>=60&&i<120?[c,p,d]=[a,o,0]:i>=120&&i<180?[c,p,d]=[0,o,a]:i>=180&&i<240?[c,p,d]=[0,a,o]:i>=240&&i<300?[c,p,d]=[a,0,o]:[c,p,d]=[o,0,a],[(c+l)*255,(p+l)*255,(d+l)*255]}function wo(n,t,e){const i=V(n/255,0,1),r=V(t/255,0,1),s=V(e/255,0,1),o=Math.max(i,r,s),a=Math.min(i,r,s),l=o-a;let c;l===0?c=0:o===i?c=60*(((r-s)/l%6+6)%6):o===r?c=60*((s-i)/l+2):c=60*((i-r)/l+4);const p=o===0?0:l/o,d=o;return[c,p*100,d*100]}function hi(n,t,e){const i=zn(n,360),r=V(t/100,0,1),s=V(e/100,0,1),o=s*r,a=o*(1-Math.abs(i/60%2-1)),l=s-o;let c,p,d;return i>=0&&i<60?[c,p,d]=[o,a,0]:i>=60&&i<120?[c,p,d]=[a,o,0]:i>=120&&i<180?[c,p,d]=[0,o,a]:i>=180&&i<240?[c,p,d]=[0,a,o]:i>=240&&i<300?[c,p,d]=[a,0,o]:[c,p,d]=[o,0,a],[(c+l)*255,(p+l)*255,(d+l)*255]}function _o(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 Co(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 oe(n,t){return[n[0],n[1],n[2],t]}const xo={hsl:{hsl:(n,t,e)=>[n,t,e],hsv:_o,rgb:go},hsv:{hsl:Co,hsv:(n,t,e)=>[n,t,e],rgb:hi},rgb:{hsl:fo,hsv:wo,rgb:(n,t,e)=>[n,t,e]}};function mt(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 yo(n,t){return n===t?t:zn(n,t)}function vi(n,t,e){var i;const r=mt(t,e);return[t==="rgb"?V(n[0],0,r[0]):yo(n[0],r[0]),V(n[1],0,r[1]),V(n[2],0,r[2]),V((i=n[3])!==null&&i!==void 0?i:1,0,1)]}function wn(n,t,e,i){const r=mt(t,e),s=mt(t,i);return n.map((o,a)=>o/r[a]*s[a])}function mi(n,t,e){const i=wn(n,t.mode,t.type,"int"),r=xo[t.mode][e.mode](...i);return wn(r,e.mode,"int",e.type)}class m{static black(){return new m([0,0,0],"rgb")}constructor(t,e){this.type="int",this.mode=e,this.comps_=vi(t,e,this.type)}getComponents(t){return oe(mi(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 Y=v("colp");class Po{constructor(t,e){this.alphaViews_=null,this.element=t.createElement("div"),this.element.classList.add(Y()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(Y("hsv"));const r=t.createElement("div");r.classList.add(Y("sv")),this.svPaletteView_=e.svPaletteView,r.appendChild(this.svPaletteView_.element),i.appendChild(r);const s=t.createElement("div");s.classList.add(Y("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(Y("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(Y("a"));const l=t.createElement("div");l.classList.add(Y("ap")),l.appendChild(this.alphaViews_.palette.element),a.appendChild(l);const c=t.createElement("div");c.classList.add(Y("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 Eo(n){return n==="int"?"int":n==="float"?"float":void 0}function He(n){return C(n,t=>({color:t.optional.object({alpha:t.optional.boolean,type:t.optional.custom(Eo)}),expanded:t.optional.boolean,picker:t.optional.custom(ui),readonly:t.optional.constant(!1)}))}function ot(n){return n?.1:1}function bi(n){var t;return(t=n.color)===null||t===void 0?void 0:t.type}class $e{constructor(t,e){this.type="float",this.mode=e,this.comps_=vi(t,e,this.type)}getComponents(t){return oe(mi(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 ko={int:(n,t)=>new m(n,t),float:(n,t)=>new $e(n,t)};function Ke(n,t,e){return ko[e](n,t)}function Vo(n){return n.type==="float"}function So(n){return n.type==="int"}function To(n){const t=n.getComponents(),e=mt(n.mode,"int");return new m([Math.round(b(t[0],0,1,0,e[0])),Math.round(b(t[1],0,1,0,e[1])),Math.round(b(t[2],0,1,0,e[2])),t[3]],n.mode)}function Lo(n){const t=n.getComponents(),e=mt(n.mode,"int");return new $e([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 T(n,t){if(n.type===t)return n;if(So(n)&&t==="float")return Lo(n);if(Vo(n)&&t==="int")return To(n);throw P.shouldNeverHappen()}function Ao(n,t){return n.alpha===t.alpha&&n.mode===t.mode&&n.notation===t.notation&&n.type===t.type}function B(n,t){const e=n.match(/^(.+)%$/);return Math.min(e?parseFloat(e[1])*.01*t:parseFloat(n),t)}const Ro={deg:n=>n,grad:n=>n*360/400,rad:n=>n*360/(2*Math.PI),turn:n=>n*360};function fi(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 Ro[i](e)}function gi(n){const t=n.match(/^rgb\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!t)return null;const e=[B(t[1],255),B(t[2],255),B(t[3],255)];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])?null:e}function Oo(n){const t=gi(n);return t?new m(t,"rgb"):null}function wi(n){const t=n.match(/^rgba\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!t)return null;const e=[B(t[1],255),B(t[2],255),B(t[3],255),B(t[4],1)];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])||isNaN(e[3])?null:e}function Mo(n){const t=wi(n);return t?new m(t,"rgb"):null}function _i(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=[fi(t[1]),B(t[2],100),B(t[3],100)];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])?null:e}function Do(n){const t=_i(n);return t?new m(t,"hsl"):null}function Ci(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=[fi(t[1]),B(t[2],100),B(t[3],100),B(t[4],1)];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])||isNaN(e[3])?null:e}function Fo(n){const t=Ci(n);return t?new m(t,"hsl"):null}function xi(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 Bo(n){const t=xi(n);return t?new m(t,"rgb"):null}function yi(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 Io(n){const t=yi(n);return t?new m(t,"rgb"):null}function Pi(n){const t=n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!t)return null;const e=[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])?null:e}function _n(n){return t=>{const e=Pi(t);return e?Ke(e,"rgb",n):null}}function Ei(n){const t=n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*a\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!t)return null;const e=[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])];return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])||isNaN(e[3])?null:e}function Cn(n){return t=>{const e=Ei(t);return e?Ke(e,"rgb",n):null}}const jo=[{parser:xi,result:{alpha:!1,mode:"rgb",notation:"hex"}},{parser:yi,result:{alpha:!0,mode:"rgb",notation:"hex"}},{parser:gi,result:{alpha:!1,mode:"rgb",notation:"func"}},{parser:wi,result:{alpha:!0,mode:"rgb",notation:"func"}},{parser:_i,result:{alpha:!1,mode:"hsl",notation:"func"}},{parser:Ci,result:{alpha:!0,mode:"hsl",notation:"func"}},{parser:Pi,result:{alpha:!1,mode:"rgb",notation:"object"}},{parser:Ei,result:{alpha:!0,mode:"rgb",notation:"object"}}];function No(n){return jo.reduce((t,{parser:e,result:i})=>t||(e(n)?i:null),null)}function zo(n,t="int"){const e=No(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 Ht(n){const t=[Bo,Io,Oo,Mo,Do,Fo];n==="int"&&t.push(_n("int"),Cn("int")),n==="float"&&t.push(_n("float"),Cn("float"));const e=no(t);return i=>{const r=e(i);return r?T(r,n):null}}function Ho(n){const t=Ht("int");if(typeof n!="string")return m.black();const e=t(n);return e??m.black()}function ki(n){const t=V(Math.floor(n),0,255).toString(16);return t.length===1?`0${t}`:t}function qe(n,t="#"){const e=H(n.getComponents("rgb")).map(ki).join("");return`${t}${e}`}function Ue(n,t="#"){const e=n.getComponents("rgb"),i=[e[0],e[1],e[2],e[3]*255].map(ki).join("");return`${t}${i}`}function Vi(n){const t=R(0),e=T(n,"int");return`rgb(${H(e.getComponents("rgb")).map(r=>t(r)).join(", ")})`}function Ut(n){const t=R(2),e=R(0);return`rgba(${T(n,"int").getComponents("rgb").map((s,o)=>(o===3?t:e)(s)).join(", ")})`}function $o(n){const t=[R(0),Jt,Jt],e=T(n,"int");return`hsl(${H(e.getComponents("hsl")).map((r,s)=>t[s](r)).join(", ")})`}function Ko(n){const t=[R(0),Jt,Jt,R(2)];return`hsla(${T(n,"int").getComponents("hsl").map((r,s)=>t[s](r)).join(", ")})`}function Si(n,t){const e=R(t==="float"?2:0),i=["r","g","b"],r=T(n,t);return`{${H(r.getComponents("rgb")).map((o,a)=>`${i[a]}: ${e(o)}`).join(", ")}}`}function qo(n){return t=>Si(t,n)}function Ti(n,t){const e=R(2),i=R(t==="float"?2:0),r=["r","g","b","a"];return`{${T(n,t).getComponents("rgb").map((a,l)=>{const c=l===3?e:i;return`${r[l]}: ${c(a)}`}).join(", ")}}`}function Uo(n){return t=>Ti(t,n)}const Go=[{format:{alpha:!1,mode:"rgb",notation:"hex",type:"int"},stringifier:qe},{format:{alpha:!0,mode:"rgb",notation:"hex",type:"int"},stringifier:Ue},{format:{alpha:!1,mode:"rgb",notation:"func",type:"int"},stringifier:Vi},{format:{alpha:!0,mode:"rgb",notation:"func",type:"int"},stringifier:Ut},{format:{alpha:!1,mode:"hsl",notation:"func",type:"int"},stringifier:$o},{format:{alpha:!0,mode:"hsl",notation:"func",type:"int"},stringifier:Ko},...["int","float"].reduce((n,t)=>[...n,{format:{alpha:!1,mode:"rgb",notation:"object",type:t},stringifier:qo(t)},{format:{alpha:!0,mode:"rgb",notation:"object",type:t},stringifier:Uo(t)}],[])];function Li(n){return Go.reduce((t,e)=>t||(Ao(e.format,n)?e.stringifier:null),null)}const Pt=v("apl");class Wo{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.value=e.value,this.value.emitter.on("change",this.onValueChange_),this.element=t.createElement("div"),this.element.classList.add(Pt()),e.viewProps.bindClassModifiers(this.element),e.viewProps.bindTabIndex(this.element);const i=t.createElement("div");i.classList.add(Pt("b")),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(Pt("c")),i.appendChild(r),this.colorElem_=r;const s=t.createElement("div");s.classList.add(Pt("m")),this.element.appendChild(s),this.markerElem_=s;const o=t.createElement("div");o.classList.add(Pt("p")),this.markerElem_.appendChild(o),this.previewElem_=o,this.update_()}update_(){const t=this.value.rawValue,e=t.getComponents("rgb"),i=new m([e[0],e[1],e[2],0],"rgb"),r=new m([e[0],e[1],e[2],255],"rgb"),s=["to right",Ut(i),Ut(r)];this.colorElem_.style.background=`linear-gradient(${s.join(",")})`,this.previewElem_.style.backgroundColor=Ut(t);const o=b(e[3],0,1,0,100);this.markerElem_.style.left=`${o}%`}onValueChange_(){this.update_()}}class Yo{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 Wo(t,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new lt(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(t,e){if(!t.point)return;const i=t.point.x/t.bounds.width,r=this.value.rawValue,[s,o,a]=r.getComponents("hsv");this.value.setRawValue(new m([s,o,a,i],"hsv"),e)}onPointerDown_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerMove_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerUp_(t){this.handlePointerEvent_(t.data,{forceEmit:!0,last:!0})}onKeyDown_(t){const e=A(ot(!0),G(t));if(e===0)return;const i=this.value.rawValue,[r,s,o,a]=i.getComponents("hsv");this.value.setRawValue(new m([r,s,o,a+e],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(t){A(ot(!0),G(t))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const dt=v("coltxt");function Xo(n){const t=n.createElement("select"),e=[{text:"RGB",value:"rgb"},{text:"HSL",value:"hsl"},{text:"HSV",value:"hsv"},{text:"HEX",value:"hex"}];return t.appendChild(e.reduce((i,r)=>{const s=n.createElement("option");return s.textContent=r.text,s.value=r.value,i.appendChild(s),i},n.createDocumentFragment())),t}class Qo{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(dt()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(dt("m")),this.modeElem_=Xo(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(re(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_(),q(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_(){Xn(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 Zo(n){return R(n==="float"?2:0)}function Jo(n,t,e){const i=mt(n,t)[e];return new Mt({min:0,max:i})}function ta(n,t,e){return new Nt(n,{arrayPosition:e===0?"fst":e===2?"lst":"mid",parser:t.parser,props:u.fromObject({formatter:Zo(t.colorType),keyScale:ot(!1),pointerScale:t.colorType==="float"?.01:1}),value:_(0,{constraint:Jo(t.colorMode,t.colorType,e)}),viewProps:t.viewProps})}function ea(n,t){const e={colorMode:t.colorMode,colorType:t.colorType,parser:U,viewProps:t.viewProps};return[0,1,2].map(i=>{const r=ta(n,e,i);return wt({primary:t.value,secondary:r.value,forward(s){return T(s,t.colorType).getComponents(t.colorMode)[i]},backward(s,o){const a=t.colorMode,c=T(s,t.colorType).getComponents(a);c[i]=o;const p=Ke(oe(H(c),c[3]),a,t.colorType);return T(p,"int")}}),r})}function na(n,t){const e=new At(n,{parser:Ht("int"),props:u.fromObject({formatter:qe}),value:_(m.black()),viewProps:t.viewProps});return wt({primary:t.value,secondary:e.value,forward:i=>new m(H(i.getComponents()),i.mode),backward:(i,r)=>new m(oe(H(r.getComponents(i.mode)),i.getComponents()[3]),i.mode)}),[e]}function ia(n){return n!=="hex"}class ra{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 Qo(t,{mode:this.colorMode,inputViews:[this.ccs_[0].view,this.ccs_[1].view,this.ccs_[2].view],viewProps:this.viewProps}),this.view.modeSelectElement.addEventListener("change",this.onModeSelectChange_)}createComponentControllers_(t){const e=this.colorMode.rawValue;return ia(e)?ea(t,{colorMode:e,colorType:this.colorType_,value:this.value,viewProps:this.viewProps}):na(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 ve=v("hpl");class sa{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(ve()),e.viewProps.bindClassModifiers(this.element),e.viewProps.bindTabIndex(this.element);const i=t.createElement("div");i.classList.add(ve("c")),this.element.appendChild(i);const r=t.createElement("div");r.classList.add(ve("m")),this.element.appendChild(r),this.markerElem_=r,this.update_()}update_(){const t=this.value.rawValue,[e]=t.getComponents("hsv");this.markerElem_.style.backgroundColor=Vi(new m([e,100,100],"hsv"));const i=b(e,0,360,0,100);this.markerElem_.style.left=`${i}%`}onValueChange_(){this.update_()}}class oa{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 sa(t,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new lt(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(t,e){if(!t.point)return;const i=b(V(t.point.x,0,t.bounds.width),0,t.bounds.width,0,360),r=this.value.rawValue,[,s,o,a]=r.getComponents("hsv");this.value.setRawValue(new m([i,s,o,a],"hsv"),e)}onPointerDown_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerMove_(t){this.handlePointerEvent_(t.data,{forceEmit:!1,last:!1})}onPointerUp_(t){this.handlePointerEvent_(t.data,{forceEmit:!0,last:!0})}onKeyDown_(t){const e=A(ot(!1),G(t));if(e===0)return;const i=this.value.rawValue,[r,s,o,a]=i.getComponents("hsv");this.value.setRawValue(new m([r+e,s,o,a],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(t){A(ot(!1),G(t))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const me=v("svp"),xn=64;class aa{constructor(t,e){this.onValueChange_=this.onValueChange_.bind(this),this.value=e.value,this.value.emitter.on("change",this.onValueChange_),this.element=t.createElement("div"),this.element.classList.add(me()),e.viewProps.bindClassModifiers(this.element),e.viewProps.bindTabIndex(this.element);const i=t.createElement("canvas");i.height=xn,i.width=xn,i.classList.add(me("c")),this.element.appendChild(i),this.canvasElement=i;const r=t.createElement("div");r.classList.add(me("m")),this.element.appendChild(r),this.markerElem_=r,this.update_()}update_(){const t=as(this.canvasElement);if(!t)return;const i=this.value.rawValue.getComponents("hsv"),r=this.canvasElement.width,s=this.canvasElement.height,o=t.getImageData(0,0,r,s),a=o.data;for(let p=0;pi.getComponents()[3],backward:(i,r)=>{const s=i.getComponents();return s[3]=r,new m(s,i.mode)}}),this.textsC_=new ra(t,{colorType:e.colorType,value:this.value,viewProps:this.viewProps}),this.view=new Po(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 be=v("colsw");class pa{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(be()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(be("sw")),this.element.appendChild(i),this.swatchElem_=i;const r=t.createElement("button");r.classList.add(be("b")),e.viewProps.bindDisabled(r),this.element.appendChild(r),this.buttonElement=r,this.update_()}update_(){const t=this.value.rawValue;this.swatchElem_.style.backgroundColor=Ue(t)}onValueChange_(){this.update_()}}class da{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.view=new pa(t,{value:this.value,viewProps:this.viewProps})}}class Ge{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_=Ft.create(e.expanded),this.swatchC_=new da(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 At(t,{parser:e.parser,props:u.fromObject({formatter:e.formatter}),value:this.value,viewProps:this.viewProps}),this.view=new bo(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 oi(t,{viewProps:this.viewProps}):null;const r=new ca(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),wt({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),Ie(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=Qn(t);i&&e.contains(i)||i&&i===this.swatchC_.view.buttonElement&&!Re(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 ua(n){return H(n.getComponents("rgb")).reduce((t,e)=>t<<8|Math.floor(e)&255,0)}function ha(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 va(n){return new m([n>>16&255,n>>8&255,n&255],"rgb")}function ma(n){return new m([n>>24&255,n>>16&255,n>>8&255,b(n&255,0,255,0,1)],"rgb")}function ba(n){return typeof n!="number"?m.black():va(n)}function fa(n){return typeof n!="number"?m.black():ma(n)}function Gt(n,t){return typeof n!="object"||g(n)?!1:t in n&&typeof n[t]=="number"}function Ai(n){return Gt(n,"r")&&Gt(n,"g")&&Gt(n,"b")}function Ri(n){return Ai(n)&&Gt(n,"a")}function Oi(n){return Ai(n)}function We(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{zt(e,t(i))}:null}function wa(n){const t=n?ha:ua;return(e,i)=>{zt(e,t(i))}}function _a(n,t,e){const r=T(t,e).toRgbaObject();n.writeProperty("r",r.r),n.writeProperty("g",r.g),n.writeProperty("b",r.b),n.writeProperty("a",r.a)}function Ca(n,t,e){const r=T(t,e).toRgbaObject();n.writeProperty("r",r.r),n.writeProperty("g",r.g),n.writeProperty("b",r.b)}function xa(n,t){return(e,i)=>{n?_a(e,i,t):Ca(e,i,t)}}function ya(n){var t;return!!(!((t=n==null?void 0:n.color)===null||t===void 0)&&t.alpha)}function Pa(n){return n?t=>Ue(t,"0x"):t=>qe(t,"0x")}function Ea(n){return"color"in n||n.view==="color"}const ka=L({id:"input-color-number",type:"input",accept:(n,t)=>{if(typeof n!="number"||!Ea(t))return null;const e=He(t);return e?{initialValue:n,params:Object.assign(Object.assign({},e),{supportsAlpha:ya(t)})}:null},binding:{reader:n=>n.params.supportsAlpha?fa:ba,equals:We,writer:n=>wa(n.params.supportsAlpha)},controller:n=>{var t,e;return new Ge(n.document,{colorType:"int",expanded:(t=n.params.expanded)!==null&&t!==void 0?t:!1,formatter:Pa(n.params.supportsAlpha),parser:Ht("int"),pickerLayout:(e=n.params.picker)!==null&&e!==void 0?e:"popup",supportsAlpha:n.params.supportsAlpha,value:n.value,viewProps:n.viewProps})}});function Va(n,t){if(!Oi(n))return T(m.black(),t);if(t==="int"){const e=yn(n);return new m(e,"rgb")}if(t==="float"){const e=yn(n);return new $e(e,"rgb")}return T(m.black(),"int")}function Sa(n){return Ri(n)}function Ta(n){return t=>{const e=Va(t,n);return T(e,"int")}}function La(n,t){return e=>n?Ti(e,t):Si(e,t)}const Aa=L({id:"input-color-object",type:"input",accept:(n,t)=>{var e;if(!Oi(n))return null;const i=He(t);return i?{initialValue:n,params:Object.assign(Object.assign({},i),{colorType:(e=bi(t))!==null&&e!==void 0?e:"int"})}:null},binding:{reader:n=>Ta(n.params.colorType),equals:We,writer:n=>xa(Sa(n.initialValue),n.params.colorType)},controller:n=>{var t,e;const i=Ri(n.initialValue);return new Ge(n.document,{colorType:n.params.colorType,expanded:(t=n.params.expanded)!==null&&t!==void 0?t:!1,formatter:La(i,n.params.colorType),parser:Ht("int"),pickerLayout:(e=n.params.picker)!==null&&e!==void 0?e:"popup",supportsAlpha:i,value:n.value,viewProps:n.viewProps})}}),Ra=L({id:"input-color-string",type:"input",accept:(n,t)=>{if(typeof n!="string"||t.view==="text")return null;const e=zo(n,bi(t));if(!e)return null;const i=Li(e);if(!i)return null;const r=He(t);return r?{initialValue:n,params:Object.assign(Object.assign({},r),{format:e,stringifier:i})}:null},binding:{reader:()=>Ho,equals:We,writer:n=>{const t=ga(n.params.format);if(!t)throw P.notBindable();return t}},controller:n=>{var t,e;return new Ge(n.document,{colorType:n.params.format.type,expanded:(t=n.params.expanded)!==null&&t!==void 0?t:!1,formatter:n.params.stringifier,parser:Ht("int"),pickerLayout:(e=n.params.picker)!==null&&e!==void 0?e:"popup",supportsAlpha:n.params.format.alpha,value:n.value,viewProps:n.viewProps})}});class Ye{constructor(t){this.components=t.components,this.asm_=t.assembly}constrain(t){const e=this.asm_.toComponents(t).map((i,r)=>{var s,o;return(o=(s=this.components[r])===null||s===void 0?void 0:s.constrain(i))!==null&&o!==void 0?o:i});return this.asm_.fromComponents(e)}}const Pn=v("pndtxt");class Oa{constructor(t,e){this.textViews=e.textViews,this.element=t.createElement("div"),this.element.classList.add(Pn()),this.textViews.forEach(i=>{const r=t.createElement("div");r.classList.add(Pn("a")),r.appendChild(i.element),this.element.appendChild(r)})}}function Ma(n,t,e){return new Nt(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 Xe{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.acs_=e.axes.map((i,r)=>Ma(t,e,r)),this.acs_.forEach((i,r)=>{wt({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 Oa(t,{textViews:this.acs_.map(i=>i.view)})}get textControllers(){return this.acs_}}class Da extends Lt{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 Fa(n,t){const e=[],i=Kn(n,t);i&&e.push(i);const r=qn(n);r&&e.push(r);const s=ze(n.options);return s&&e.push(s),new Bt(e)}const Ba=L({id:"input-number",type:"input",accept:(n,t)=>{if(typeof n!="number")return null;const e=C(t,i=>Object.assign(Object.assign({},Gn(i)),{options:i.optional.custom(jt),readonly:i.optional.constant(!1)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>Nn,constraint:n=>Fa(n.params,n.initialValue),writer:n=>zt},controller:n=>{const t=n.value,e=n.constraint,i=e&&Zt(e,It);if(i)return new tt(n.document,{props:new u({options:i.values.value("options")}),value:t,viewProps:n.viewProps});const r=Un(n.params,t.rawValue),s=e&&Zt(e,Mt);return s?new te(n.document,Object.assign(Object.assign({},pi(Object.assign(Object.assign({},r),{keyScale:_(r.keyScale),max:s.values.value("max"),min:s.values.value("min")}))),{parser:U,value:t,viewProps:n.viewProps})):new Nt(n.document,{parser:U,props:u.fromObject(r),value:t,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="number"?null:n.controller.valueController instanceof te?new Da(n.controller):n.controller.valueController instanceof tt?new je(n.controller):null}});class J{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 Mi={toComponents:n=>n.getComponents(),fromComponents:n=>new J(...n)},ut=v("p2d");class Ia{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(ut()),e.viewProps.bindClassModifiers(this.element),q(e.expanded,bt(this.element,ut(void 0,"expanded")));const i=t.createElement("div");i.classList.add(ut("h")),this.element.appendChild(i);const r=t.createElement("button");r.classList.add(ut("b")),r.appendChild(re(t,"p2dpad")),e.viewProps.bindDisabled(r),i.appendChild(r),this.buttonElement=r;const s=t.createElement("div");if(s.classList.add(ut("t")),i.appendChild(s),this.textElement=s,e.pickerLayout==="inline"){const o=t.createElement("div");o.classList.add(ut("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}}const X=v("p2dp");class ja{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(X()),e.layout==="popup"&&this.element.classList.add(X(void 0,"p")),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("div");i.classList.add(X("p")),e.viewProps.bindTabIndex(i),this.element.appendChild(i),this.padElement=i;const r=t.createElementNS(N,"svg");r.classList.add(X("g")),this.padElement.appendChild(r),this.svgElem_=r;const s=t.createElementNS(N,"line");s.classList.add(X("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(X("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(X("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(X("m")),this.padElement.appendChild(l),this.markerElem_=l,e.value.emitter.on("change",this.onValueChange_),this.value=e.value,this.update_()}get allFocusableElements(){return[this.padElement]}update_(){const[t,e]=this.value.rawValue.getComponents(),i=this.props_.get("max"),r=b(t,-i,+i,0,100),s=b(e,-i,+i,0,100),o=this.props_.get("invertsY")?100-s:s;this.lineElem_.setAttributeNS(null,"x2",`${r}%`),this.lineElem_.setAttributeNS(null,"y2",`${o}%`),this.markerElem_.style.left=`${r}%`,this.markerElem_.style.top=`${o}%`}onValueChange_(){this.update_()}onPropsChange_(){this.update_()}onFoldableChange_(){this.update_()}}function En(n,t,e){return[A(t[0],G(n)),A(t[1],Rt(n))*(e?1:-1)]}class Na{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 ja(t,{layout:e.layout,props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new lt(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 J(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){ci(t.key)&&t.preventDefault();const[e,i]=En(t,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));e===0&&i===0||this.value.setRawValue(new J(this.value.rawValue.x+e,this.value.rawValue.y+i),{forceEmit:!1,last:!1})}onPadKeyUp_(t){const[e,i]=En(t,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));e===0&&i===0||this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}class za{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_=Ft.create(e.expanded),this.popC_=e.pickerLayout==="popup"?new oi(t,{viewProps:this.viewProps}):null;const s=new Na(t,{layout:e.pickerLayout,props:new u({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 Xe(t,{assembly:Mi,axes:e.axes,parser:e.parser,value:this.value,viewProps:this.viewProps}),this.view=new Ia(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),wt({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),Ie(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=Qn(t);i&&e.contains(i)||i&&i===this.view.buttonElement&&!Re(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 Ha(n){return J.isObject(n)?new J(n.x,n.y):new J}function $a(n,t){n.writeProperty("x",t.x),n.writeProperty("y",t.y)}function Ka(n,t){return new Ye({assembly:Mi,components:[K(Object.assign(Object.assign({},n),n.x),t.x),K(Object.assign(Object.assign({},n),n.y),t.y)]})}function kn(n,t){var e,i;if(!g(n.min)||!g(n.max))return Math.max(Math.abs((e=n.min)!==null&&e!==void 0?e:0),Math.abs((i=n.max)!==null&&i!==void 0?i:0));const r=Hn(n);return Math.max(Math.abs(r)*10,Math.abs(t)*10)}function qa(n,t){var e,i;const r=kn(rt(n,(e=n.x)!==null&&e!==void 0?e:{}),t.x),s=kn(rt(n,(i=n.y)!==null&&i!==void 0?i:{}),t.y);return Math.max(r,s)}function Ua(n){if(!("y"in n))return!1;const t=n.y;return t&&"inverted"in t?!!t.inverted:!1}const Ga=L({id:"input-point2d",type:"input",accept:(n,t)=>{if(!J.isObject(n))return null;const e=C(t,i=>Object.assign(Object.assign({},Ot(i)),{expanded:i.optional.boolean,picker:i.optional.custom(ui),readonly:i.optional.constant(!1),x:i.optional.custom(Z),y:i.optional.object(Object.assign(Object.assign({},Ot(i)),{inverted:i.optional.boolean}))}));return e?{initialValue:n,params:e}:null},binding:{reader:()=>Ha,constraint:n=>Ka(n.params,n.initialValue),equals:J.equals,writer:()=>$a},controller:n=>{var t,e;const i=n.document,r=n.value,s=n.constraint,o=[n.params.x,n.params.y];return new za(i,{axes:r.rawValue.getComponents().map((a,l)=>{var c;return Ae({constraint:s.components[l],initialValue:a,params:rt(n.params,(c=o[l])!==null&&c!==void 0?c:{})})}),expanded:(t=n.params.expanded)!==null&&t!==void 0?t:!1,invertsY:Ua(n.params),max:qa(n.params,r.rawValue),parser:U,pickerLayout:(e=n.params.picker)!==null&&e!==void 0?e:"popup",value:r,viewProps:n.viewProps})}});class ht{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 Di={toComponents:n=>n.getComponents(),fromComponents:n=>new ht(...n)};function Wa(n){return ht.isObject(n)?new ht(n.x,n.y,n.z):new ht}function Ya(n,t){n.writeProperty("x",t.x),n.writeProperty("y",t.y),n.writeProperty("z",t.z)}function Xa(n,t){return new Ye({assembly:Di,components:[K(Object.assign(Object.assign({},n),n.x),t.x),K(Object.assign(Object.assign({},n),n.y),t.y),K(Object.assign(Object.assign({},n),n.z),t.z)]})}const Qa=L({id:"input-point3d",type:"input",accept:(n,t)=>{if(!ht.isObject(n))return null;const e=C(t,i=>Object.assign(Object.assign({},Ot(i)),{readonly:i.optional.constant(!1),x:i.optional.custom(Z),y:i.optional.custom(Z),z:i.optional.custom(Z)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>Wa,constraint:n=>Xa(n.params,n.initialValue),equals:ht.equals,writer:n=>Ya},controller:n=>{const t=n.value,e=n.constraint,i=[n.params.x,n.params.y,n.params.z];return new Xe(n.document,{assembly:Di,axes:t.rawValue.getComponents().map((r,s)=>{var o;return Ae({constraint:e.components[s],initialValue:r,params:rt(n.params,(o=i[s])!==null&&o!==void 0?o:{})})}),parser:U,value:t,viewProps:n.viewProps})}});class vt{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 Fi={toComponents:n=>n.getComponents(),fromComponents:n=>new vt(...n)};function Za(n){return vt.isObject(n)?new vt(n.x,n.y,n.z,n.w):new vt}function Ja(n,t){n.writeProperty("x",t.x),n.writeProperty("y",t.y),n.writeProperty("z",t.z),n.writeProperty("w",t.w)}function tl(n,t){return new Ye({assembly:Fi,components:[K(Object.assign(Object.assign({},n),n.x),t.x),K(Object.assign(Object.assign({},n),n.y),t.y),K(Object.assign(Object.assign({},n),n.z),t.z),K(Object.assign(Object.assign({},n),n.w),t.w)]})}const el=L({id:"input-point4d",type:"input",accept:(n,t)=>{if(!vt.isObject(n))return null;const e=C(t,i=>Object.assign(Object.assign({},Ot(i)),{readonly:i.optional.constant(!1),w:i.optional.custom(Z),x:i.optional.custom(Z),y:i.optional.custom(Z),z:i.optional.custom(Z)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>Za,constraint:n=>tl(n.params,n.initialValue),equals:vt.equals,writer:n=>Ja},controller:n=>{const t=n.value,e=n.constraint,i=[n.params.x,n.params.y,n.params.z,n.params.w];return new Xe(n.document,{assembly:Fi,axes:t.rawValue.getComponents().map((r,s)=>{var o;return Ae({constraint:e.components[s],initialValue:r,params:rt(n.params,(o=i[s])!==null&&o!==void 0?o:{})})}),parser:U,value:t,viewProps:n.viewProps})}});function nl(n){const t=[],e=ze(n.options);return e&&t.push(e),new Bt(t)}const il=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(jt)}));return e?{initialValue:n,params:e}:null},binding:{reader:n=>li,constraint:n=>nl(n.params),writer:n=>zt},controller:n=>{const t=n.document,e=n.value,i=n.constraint,r=i&&Zt(i,It);return r?new tt(t,{props:new u({options:r.values.value("options")}),value:e,viewProps:n.viewProps}):new At(t,{parser:s=>s,props:u.fromObject({formatter:Pe}),value:e,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="string"?null:n.controller.valueController instanceof tt?new je(n.controller):null}}),$t={monitor:{defaultInterval:200,defaultRows:3}},Vn=v("mll");class rl{constructor(t,e){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=e.formatter,this.element=t.createElement("div"),this.element.classList.add(Vn()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("textarea");i.classList.add(Vn("i")),i.style.height=`calc(var(${di("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 Qe{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.view=new rl(t,{formatter:e.formatter,rows:e.rows,value:this.value,viewProps:this.viewProps})}}const Sn=v("sgl");class sl{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 Ze{constructor(t,e){this.value=e.value,this.viewProps=e.viewProps,this.view=new sl(t,{formatter:e.formatter,value:this.value,viewProps:this.viewProps})}}const ol=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=>ai},controller:n=>{var t;return n.value.rawValue.length===1?new Ze(n.document,{formatter:gn,value:n.value,viewProps:n.viewProps}):new Qe(n.document,{formatter:gn,rows:(t=n.params.rows)!==null&&t!==void 0?t:$t.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}});class al extends Lt{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 Q=v("grl");class ll{constructor(t,e){this.onCursorChange_=this.onCursorChange_.bind(this),this.onValueUpdate_=this.onValueUpdate_.bind(this),this.element=t.createElement("div"),this.element.classList.add(Q()),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(Q("g")),i.style.height=`calc(var(${di("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(Q("t"),v("tt")()),this.element.appendChild(s),this.tooltipElem_=s,e.value.emitter.on("change",this.onValueUpdate_),this.value=e.value,this.update_()}get graphElement(){return this.svgElem_}update_(){const{clientWidth:t,clientHeight:e}=this.element,i=this.value.rawValue.length-1,r=this.props_.get("min"),s=this.props_.get("max"),o=[];this.value.rawValue.forEach((d,h)=>{if(d===void 0)return;const S=b(h,0,i,0,t),x=b(d,r,s,e,0);o.push([S,x].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(Q("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(Q("t","a"))||(a.classList.add(Q("t","a"),Q("t","in")),Qt(a),a.classList.remove(Q("t","in")))}onValueUpdate_(){this.update_()}onCursorChange_(){this.update_()}}class Bi{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 ll(t,{cursor:this.cursor_,formatter:e.formatter,rows:e.rows,props:this.props,value:this.value,viewProps:this.viewProps}),!Re(t))this.view.element.addEventListener("mousemove",this.onGraphMouseMove_),this.view.element.addEventListener("mouseleave",this.onGraphMouseLeave_);else{const i=new lt(this.view.element);i.emitter.on("down",this.onGraphPointerDown_),i.emitter.on("move",this.onGraphPointerMove_),i.emitter.on("up",this.onGraphPointerUp_)}}importProps(t){return M(t,null,e=>({max:e.required.number,min:e.required.number}),e=>(this.props.set("max",e.max),this.props.set("min",e.min),!0))}exportProps(){return D(null,{max:this.props.get("max"),min:this.props.get("min")})}onGraphMouseLeave_(){this.cursor_.rawValue=-1}onGraphMouseMove_(t){const{clientWidth:e}=this.view.element;this.cursor_.rawValue=Math.floor(b(t.offsetX,0,e,0,this.value.rawValue.length))}onGraphPointerDown_(t){this.onGraphPointerMove_(t)}onGraphPointerMove_(t){if(!t.data.point){this.cursor_.rawValue=-1;return}this.cursor_.rawValue=Math.floor(b(t.data.point.x,0,t.data.bounds.width,0,this.value.rawValue.length))}onGraphPointerUp_(){this.cursor_.rawValue=-1}}function Ee(n){return g(n.format)?R(2):n.format}function cl(n){var t;return n.value.rawValue.length===1?new Ze(n.document,{formatter:Ee(n.params),value:n.value,viewProps:n.viewProps}):new Qe(n.document,{formatter:Ee(n.params),rows:(t=n.params.rows)!==null&&t!==void 0?t:$t.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}function pl(n){var t,e,i;return new Bi(n.document,{formatter:Ee(n.params),rows:(t=n.params.rows)!==null&&t!==void 0?t:$t.monitor.defaultRows,props:u.fromObject({max:(e=n.params.max)!==null&&e!==void 0?e:100,min:(i=n.params.min)!==null&&i!==void 0?i:0}),value:n.value,viewProps:n.viewProps})}function Tn(n){return n.view==="graph"}const dl=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=>Tn(n)?64:1,reader:n=>Nn},controller:n=>Tn(n.params)?pl(n):cl(n),api:n=>n.controller.valueController instanceof Bi?new al(n.controller):null}),ul=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=>li},controller:n=>{var t;const e=n.value;return e.rawValue.length>1||n.params.multiline?new Qe(n.document,{formatter:Pe,rows:(t=n.params.rows)!==null&&t!==void 0?t:$t.monitor.defaultRows,value:e,viewProps:n.viewProps}):new Ze(n.document,{formatter:Pe,value:e,viewProps:n.viewProps})}});class hl{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 vl{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 ml(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,d=>({disabled:d.optional.boolean,hidden:d.optional.boolean,label:d.optional.string,tag:d.optional.string})),o=n.binding.reader(r),a=n.binding.constraint?n.binding.constraint(r):void 0,l=new vl({reader:o,target:t.target,writer:n.binding.writer(r)}),c=new Jr(_(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:W.create({disabled:s==null?void 0:s.disabled,hidden:s==null?void 0:s.hidden})});return new vs(t.document,{blade:gt(),props:u.fromObject({label:"label"in t.params?(e=s==null?void 0:s.label)!==null&&e!==void 0?e:null:t.target.key}),tag:s==null?void 0:s.tag,value:c,valueController:p})}class bl{constructor(t){this.target=t.target,this.reader_=t.reader}read(){return this.reader_(this.target.read())}}function fl(n,t){return t===0?new Xs:new Qs(n,t??$t.monitor.defaultInterval)}function gl(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,h=>({bufferSize:h.optional.number,disabled:h.optional.boolean,hidden:h.optional.boolean,interval:h.optional.number,label:h.optional.string})),l=n.binding.reader(o),c=(i=(e=a==null?void 0:a.bufferSize)!==null&&e!==void 0?e:n.binding.defaultBufferSize&&n.binding.defaultBufferSize(s.params))!==null&&i!==void 0?i:1,p=new ws({binding:new bl({reader:l,target:t.target}),bufferSize:c,ticker:fl(t.document,a==null?void 0:a.interval)}),d=n.controller({document:t.document,params:s.params,value:p,viewProps:W.create({disabled:a==null?void 0:a.disabled,hidden:a==null?void 0:a.hidden})});return d.viewProps.bindDisabled(p.ticker),d.viewProps.handleDispose(()=>{p.ticker.dispose()}),new Cs(t.document,{blade:gt(),props:u.fromObject({label:"label"in t.params?(r=a==null?void 0:a.label)!==null&&r!==void 0?r:null:t.target.key}),value:p,valueController:d})}class wl{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(!po(e.core))throw P.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??ml(s,{document:t,target:e,params:i}),null)}createMonitor_(t,e,i){return this.pluginsMap_.monitors.reduce((r,s)=>r??gl(s,{document:t,params:i,target:e}),null)}createBinding(t,e,i){const r=e.read();if(g(r))throw new P({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 P({context:{key:e.key},type:"nomatchingcontroller"})}createBlade(t,e){const i=this.pluginsMap_.blades.reduce((r,s)=>r??Ys(s,{document:t,params:e}),null);if(!i)throw new P({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 Lt(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 Lt(t))}createBindingApi(t){if(this.apiCache_.has(t))return this.apiCache_.get(t);if(ms(t))return this.createInputBindingApi_(t);if(xs(t))return this.createMonitorBindingApi_(t);throw P.shouldNeverHappen()}createApi(t){if(this.apiCache_.has(t))return this.apiCache_.get(t);if(hs(t))return this.createBindingApi(t);const e=this.pluginsMap_.blades.reduce((i,r)=>i??r.api({controller:t,pool:this}),null);if(!e)throw P.shouldNeverHappen();return this.apiCache_.add(t,e)}}const _l=new hl;function Cl(){const n=new wl(_l);return[Ga,Qa,el,il,Ba,Ra,Aa,ka,mo,ol,ul,dl,Vs,Ns,si].forEach(t=>{n.register("core",t)}),n}class xl extends at{constructor(t){super(t),this.emitter_=new k,this.controller.value.emitter.on("change",e=>{this.emitter_.emit("change",new Dt(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 yl extends at{}class Pl extends at{constructor(t){super(t),this.emitter_=new k,this.controller.value.emitter.on("change",e=>{this.emitter_.emit("change",new Dt(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 El extends at{constructor(t){super(t),this.emitter_=new k,this.controller.value.emitter.on("change",e=>{this.emitter_.emit("change",new Dt(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 kl=function(){return{id:"list",type:"blade",core:ft,accept(n){const t=C(n,e=>({options:e.required.custom(jt),value:e.required.raw,view:e.required.constant("list"),label:e.optional.string}));return t?{params:t}:null},controller(n){const t=new It(Ne(n.params.options)),e=_(n.params.value,{constraint:t}),i=new tt(n.document,{props:new u({options:t.values.value("options")}),value:e,viewProps:n.viewProps});return new st(n.document,{blade:n.blade,props:u.fromObject({label:n.params.label}),value:e,valueController:i})},api(n){return!(n.controller instanceof st)||!(n.controller.valueController instanceof tt)?null:new xl(n.controller)}}}();class Vl extends ii{constructor(t,e){super(t,e)}get element(){return this.controller.view.element}}class Sl extends xe{constructor(t,e){super(t,{expanded:e.expanded,blade:e.blade,props:e.props,root:!0,viewProps:e.viewProps})}}const Ln=v("spr");class Tl{constructor(t,e){this.element=t.createElement("div"),this.element.classList.add(Ln()),e.viewProps.bindClassModifiers(this.element);const i=t.createElement("hr");i.classList.add(Ln("r")),this.element.appendChild(i)}}class An extends se{constructor(t,e){super(Object.assign(Object.assign({},e),{view:new Tl(t,{viewProps:e.viewProps})}))}}const Ll={id:"separator",type:"blade",core:ft,accept(n){const t=C(n,e=>({view:e.required.constant("separator")}));return t?{params:t}:null},controller(n){return new An(n.document,{blade:n.blade,viewProps:n.viewProps})},api(n){return n.controller instanceof An?new yl(n.controller):null}},Al={id:"slider",type:"blade",core:ft,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 Mt({max:n.params.max,min:n.params.min}),s=_(i,{constraint:r}),o=new te(n.document,Object.assign(Object.assign({},pi({formatter:(e=n.params.format)!==null&&e!==void 0?e:Wr,keyScale:_(1),max:r.values.value("max"),min:r.values.value("min"),pointerScale:$n(n.params,i)})),{parser:U,value:s,viewProps:n.viewProps}));return new st(n.document,{blade:n.blade,props:u.fromObject({label:n.params.label}),value:s,valueController:o})},api(n){return!(n.controller instanceof st)||!(n.controller.valueController instanceof te)?null:new Pl(n.controller)}},Rl=function(){return{id:"text",type:"blade",core:ft,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 At(n.document,{parser:n.params.parse,props:u.fromObject({formatter:(t=n.params.format)!==null&&t!==void 0?t:r=>String(r)}),value:e,viewProps:n.viewProps});return new st(n.document,{blade:n.blade,props:u.fromObject({label:n.params.label}),value:e,valueController:i})},api(n){return!(n.controller instanceof st)||!(n.controller.valueController instanceof At)?null:new El(n.controller)}}}();function Ol(n){const t=n.createElement("div");return t.classList.add(v("dfw")()),n.body&&n.body.appendChild(t),t}function Ml(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 Dl extends Vl{constructor(t){var e,i;const r=t??{},s=(e=r.document)!==null&&e!==void 0?e:os(),o=Cl(),a=new Sl(s,{expanded:r.expanded,blade:gt(),props:u.fromObject({title:r.title}),viewProps:W.create()});super(a,o),this.pool_=o,this.containerElem_=(i=r.container)!==null&&i!==void 0?i:Ol(s),this.containerElem_.appendChild(this.element),this.doc_=s,this.usesDefaultWrapper_=!r.container,this.setUpDefaultPlugins_()}get document(){if(!this.doc_)throw P.alreadyDisposed();return this.doc_}dispose(){const t=this.containerElem_;if(!t)throw P.alreadyDisposed();if(this.usesDefaultWrapper_){const e=t.parentElement;e&&e.removeChild(t)}this.containerElem_=null,this.doc_=null,super.dispose()}registerPlugin(t){t.css&&Ml(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:[kl,Ll,Al,si,Rl]})}}new ni("4.0.4");class Fl{constructor(t){this.game=t;const e=document.getElementById("settings");if(!e)throw new Error("No settings container found");const i=new Dl({title:"Settings",expanded:!1,container:e});i.addButton({title:"Delete current loop"}).on("click",()=>{w.deleteCurrentTrack()}),i.addButton({title:"Delete instrument & loop"}).on("click",()=>{w.deleteCurrentInstrumentScene()}),this.resize()}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})}}function Rn(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 On=!1;const Bl=()=>(On||(On=!0,Yi().then(()=>{const n=new y.Game({type:y.AUTO,mode:y.Scale.RESIZE,parent:"phaser-container",width:window.innerWidth,height:window.innerHeight,backgroundColor:hr()?"#333":"#DDD",scene:[w,Vt],input:{activePointers:8}}),t=new Fl(n);window.addEventListener("resize",()=>{Rn(n),t.resize()}),n.scene.start(w.key),Rn(n)})),Et.jsx(Et.Fragment,{}));function Il(){return Et.jsx(Bl,{})}fe.createRoot(document.getElementById("root")).render(Et.jsx(Hi.StrictMode,{children:Et.jsx(Il,{})})); diff --git a/index.html b/index.html index 8499375..fa3361f 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 c7415f4..55f07a0 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-EDMudVsa.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:"19a984a305b5692f2e848d3358f404fd"},{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-ARw_YE2y.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:"55c7a5cab0020bb668c7f6b5f248153a"},{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")}));