import{Action as e,Composite as t,Dimensions as n,Easings as r,Equal as i,EventStoreMode as a,Label as o,LabelHorizontalAlignmentMode as s,M2Error as c,M2EventType as l,M2c2KitHelpers as u,MutablePath as d,Scene as f,Shape as p,Sprite as m,Story as h,Timer as g,Transition as _,TransitionDirection as v,WebColors as y}from"@m2c2kit/core";function b(e){"@babel/helpers - typeof";return b=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},b(e)}function x(e,t){if(b(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(b(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function S(e){var t=x(e,`string`);return b(t)==`symbol`?t:t+``}function C(e,t,n){return(t=S(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function T(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?w(Object(n),!0).forEach(function(t){C(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var E=class e extends t{constructor(e){if(super(e),this.compositeType=`Grid`,this._rows=0,this._columns=0,this._gridBackgroundColor=[0,0,255,.25],this._gridLineColor=y.Red,this._gridLineWidth=1,this._gridChildren=[],this.cellContainers=[],e.size)this.size=e.size;else throw new c(`grid size must be specified`);if(e.rows)if(e.rows>=1)this.rows=e.rows;else throw new c(`grid rows must be at least 1`);else throw new c(`grid rows must be specified`);if(e.columns)if(e.columns>=1)this.columns=e.columns;else throw new c(`grid columns must be at least 1`);else throw new c(`grid columns must be specified`);e.backgroundColor&&(this.gridBackgroundColor=e.backgroundColor),e.gridLineColor&&(this.gridLineColor=e.gridLineColor),e.gridLineWidth&&(this.gridLineWidth=e.gridLineWidth),this.cellWidth=this.size.width/this.columns,this.cellHeight=this.size.height/this.rows,this.saveNodeNewEvent()}get completeNodeOptions(){return T(T(T(T({},this.options),this.getNodeOptions()),this.getDrawableOptions()),{},{rows:this.rows,columns:this.columns,size:this.size,backgroundColor:this.gridBackgroundColor,gridLineWidth:this.gridLineWidth,gridLineColor:this.gridLineColor})}initialize(){let e=e=>e.name.startsWith(`__`+this.name+this.uuid+`-gridCellContainer-`),t=(n,r=!1)=>{if(e(n)){[...n.children].forEach(e=>{n.removeChild(e)});return}if(r){var i;(i=n.parent)==null||i.removeChild(n);return}[...n.children].forEach(e=>{t(e)}),n.parent&&(n.parent===this?super.removeChild(n):n.parent.removeChild(n))};[...this.children].forEach(e=>t(e)),this.gridBackground=new p({name:`__`+this.name+this.uuid+`-gridRectangle`,rect:{size:this.size},fillColor:this.gridBackgroundColor,strokeColor:this.gridLineColor,lineWidth:this.gridLineWidth,isUserInteractionEnabled:this.isUserInteractionEnabled,isPartOfComposite:!0}),super.addChild(this.gridBackground),this.gridBackground.isUserInteractionEnabled=this.isUserInteractionEnabled;for(let e=1;e<this.columns;e++){let t=new p({name:`__`+this.name+this.uuid+`-gridVerticalLine-`+(e-1),rect:{size:{width:this.gridLineWidth,height:this.size.height},origin:{x:-this.size.width/2+this.cellWidth*e,y:0}},fillColor:this.gridLineColor,isPartOfComposite:!0});this.gridBackground.addChild(t)}for(let e=1;e<this.rows;e++){let t=new p({name:`__`+this.name+this.uuid+`-gridHorizontalLine-`+(e-1),rect:{size:{width:this.size.width,height:this.gridLineWidth},origin:{x:0,y:-this.size.height/2+this.cellHeight*e}},fillColor:this.gridLineColor,isPartOfComposite:!0});this.gridBackground.addChild(t)}this.cellContainers=Array(this.rows).fill([]).map(()=>Array(this.columns));for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++){let n=new p({name:`__`+this.name+this.uuid+`-gridCellContainer-`+e+`-`+t,rect:{size:{width:this.cellWidth,height:this.cellHeight},origin:{x:-this.size.width/2+this.cellWidth*t+this.cellWidth/2,y:-this.size.height/2+this.cellHeight*e+this.cellHeight/2}},fillColor:y.Transparent,lineWidth:0,isPartOfComposite:!0});this.gridBackground.addChild(n),this.cellContainers[e][t]=n}this.gridChildren.length>0&&this.gridChildren.forEach(e=>{if(!this.cellWidth||!this.cellHeight||!this.gridBackground)throw new c(`cellWidth, cellHeight, or gridBackground undefined or null`);if(this.game.eventStore.mode===a.Replay){var t;let n=[...this.game.nodes,...this.game.materializedNodes].find(t=>t.uuid===e.node);if(!n)throw new c(`grid: child node not found`);n==null||(t=n.parent)==null||t.removeChild(n),this.cellContainers[e.row][e.column].addChild(n)}else{var n;(n=e.node.parent)==null||n.removeChild(e.node),this.cellContainers[e.row][e.column].addChild(e.node)}}),this.needsInitialization=!1}get gridBackground(){if(!this._gridBackground)throw new c(`gridBackground is null or undefined`);return this._gridBackground}set gridBackground(e){this._gridBackground=e}get rows(){return this._rows}set rows(e){i.value(this._rows,e)||(this._rows=e,this.needsInitialization=!0)}get columns(){return this._columns}set columns(e){i.value(this._columns,e)||(this._columns=e,this.needsInitialization=!0)}get gridBackgroundColor(){return this._gridBackgroundColor}set gridBackgroundColor(e){i.value(this._gridBackgroundColor,e)||(this._gridBackgroundColor=e,this.needsInitialization=!0)}get gridLineWidth(){return this._gridLineWidth}set gridLineWidth(e){i.value(this._gridLineWidth,e)||(this._gridLineWidth=e,this.needsInitialization=!0)}get gridLineColor(){return this._gridLineColor}set gridLineColor(e){i.value(this._gridLineColor,e)||(this._gridLineColor=e,this.needsInitialization=!0)}duplicate(t){let n=new e(T(T(T({},this.getNodeOptions()),this.getDrawableOptions()),{},{rows:this.rows,columns:this.columns,size:this.size,backgroundColor:this.gridBackgroundColor,gridLineWidth:this.gridLineWidth,gridLineColor:this.gridLineColor,name:t}));return this.children.length>0&&(n.children=this.children.map(e=>{let t=e.duplicate();return t.parent=n,t})),n}update(){super.update()}draw(e){super.drawChildren(e)}warmup(e){this.initialize(),this.children.filter(e=>e.isDrawable).forEach(t=>{t.warmup(e)})}get gridChildren(){return this._gridChildren}set gridChildren(e){this._gridChildren=e,this.needsInitialization=!0,this.savePropertyChangeEvent(`gridChildren`,this.gridChildren.map(e=>({node:e.node.uuid,row:e.row,column:e.column})))}removeAllGridChildren(){if(this.gridChildren.length!==0){for(;this.gridChildren.length;)this.gridChildren=this.gridChildren.slice(0,-1);this.needsInitialization=!0}}addAtCell(e,t,n){(t<0||t>=this.rows||n<0||n>=this.columns)&&console.warn(`warning: addAtCell() requested to add node at row ${t}, column ${n}. This is outside the bounds of grid ${this.name}, which is size ${this.rows}x${this.columns}. Note that addAtCell() uses zero-based indexing. AddAtCell() will proceed, but may draw nodes outside the grid`),this.gridChildren=[...this.gridChildren,{node:e,row:t,column:n}],this.needsInitialization=!0}removeAllAtCell(e,t){this.gridChildren=this.gridChildren.filter(n=>n.row!==e&&n.column!==t),this.needsInitialization=!0}removeGridChild(e){this.gridChildren=this.gridChildren.filter(t=>t.node!=e),this.needsInitialization=!0}addChild(e){console.warn(`Grid.addChild() was called -- did you mean to call addAtCell() instead?`),super.addChild(e)}removeAllChildren(){console.warn(`Grid.removeAllChildren() was called -- did you mean to call removeAllGridChildren() instead?`),super.removeAllChildren()}removeChild(e){console.warn(`Grid.removeChild() was called -- did you mean to call removeGridChild() instead?`),super.removeChild(e)}removeChildren(e){console.warn(`Grid.removeChildren() was called -- did you mean to call removeGridChild() instead?`),super.removeChildren(e)}};u.registerM2NodeClass(E);var D=class e extends t{constructor(e){super(e),this.compositeType=`Button`,this.isText=!0,this._backgroundColor=y.Black,this._cornerRadius=9,this._fontSize=20,this._text=``,this._fontColor=y.White,this._interpolation={},this._localize=!0,e.text&&(this.text=e.text),e.size?this.size=e.size:this.size={width:200,height:50},e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius),e.fontName&&(this.fontName=e.fontName),e.fontNames&&(this.fontNames=e.fontNames),e.fontSize!==void 0&&(this.fontSize=e.fontSize),e.fontColor&&(this.fontColor=e.fontColor),e.backgroundColor&&(this.backgroundColor=e.backgroundColor),e.interpolation&&(this.interpolation=e.interpolation),e.localize!==void 0&&(this.localize=e.localize),this.saveNodeNewEvent()}get completeNodeOptions(){return T(T(T(T(T({},this.options),this.getNodeOptions()),this.getDrawableOptions()),this.getTextOptions()),{},{size:this.size,cornerRadius:this.cornerRadius,backgroundColor:this.backgroundColor,fontNames:this.fontNames})}initialize(){this.removeAllChildren();let e=new p({name:`__`+this.name+`-buttonRectangle`,rect:{size:this.size},cornerRadius:this.cornerRadius,fillColor:this._backgroundColor,isPartOfComposite:!0});this.addChild(e);let t=new o({name:`__`+this.name+`-buttonLabel`,text:this.text,localize:this.localize,interpolation:this.interpolation,fontName:this.fontName,fontNames:this.fontNames,fontSize:this.fontSize,fontColor:this.fontColor,isPartOfComposite:!0});e.addChild(t),this.needsInitialization=!1}get text(){return this._text}set text(e){i.value(this._text,e)||(this._text=e,this.needsInitialization=!0,this.savePropertyChangeEvent(`text`,e))}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){i.value(this._backgroundColor,e)||(this._backgroundColor=e,this.needsInitialization=!0,this.savePropertyChangeEvent(`backgroundColor`,e))}get fontColor(){return this._fontColor}set fontColor(e){i.value(this._fontColor,e)||(this._fontColor=e,this.needsInitialization=!0,this.savePropertyChangeEvent(`fontColor`,e))}get fontName(){return this._fontName}set fontName(e){this._fontName!==e&&(this._fontName=e,this.needsInitialization=!0,this.savePropertyChangeEvent(`fontName`,e))}get fontNames(){return this._fontNames}set fontNames(e){i.value(this._fontNames,e)||(this._fontNames=e,this.needsInitialization=!0,this.savePropertyChangeEvent(`fontNames`,e))}get cornerRadius(){return this._cornerRadius}set cornerRadius(e){i.value(this._cornerRadius,e)||(this._cornerRadius=e,this.needsInitialization=!0,this.savePropertyChangeEvent(`cornerRadius`,e))}get fontSize(){return this._fontSize}set fontSize(e){i.value(this._fontSize,e)||(this._fontSize=e,this.needsInitialization=!0,this.savePropertyChangeEvent(`fontSize`,e))}get interpolation(){return this._interpolation}set interpolation(e){i.value(this._interpolation,e)||(this._interpolation=e,Object.freeze(this._interpolation),this.needsInitialization=!0,this.savePropertyChangeEvent(`interpolation`,e))}get localize(){return this._localize}set localize(e){i.value(this._localize,e)||(this._localize=e,this.needsInitialization=!0,this.savePropertyChangeEvent(`localize`,e))}duplicate(t){let n=new e(T(T(T(T({},this.getNodeOptions()),this.getDrawableOptions()),this.getTextOptions()),{},{size:this.size,cornerRadius:this.cornerRadius,backgroundColor:this.backgroundColor,fontColor:this.fontColor,name:t,localize:this.localize,interpolation:JSON.parse(JSON.stringify(this.interpolation)),fontName:this.fontName,fontNames:JSON.parse(JSON.stringify(this.fontNames))}));return this.children.length>0&&(n.children=this.children.map(e=>{let t=e.duplicate();return t.parent=n,t})),n}update(){super.update()}draw(e){super.drawChildren(e)}warmup(e){this.initialize(),this.children.filter(e=>e.isDrawable).forEach(t=>{t.warmup(e)})}};u.registerM2NodeClass(D);let O=function(e){return e.Dismiss=`Dismiss`,e.Positive=`Positive`,e.Negative=`Negative`,e}({});var k=class extends t{constructor(e){super(e),this.compositeType=`Dialog`,this._backgroundColor=y.White,this.cornerRadius=9,this.overlayAlpha=.5,this.contentText=``,this.positiveButtonText=``,this.negativeButtonText=``,this._fontColor=y.White,this.zPosition=Number.MAX_VALUE,this.hidden=!0,e&&(e.overlayAlpha&&(this.overlayAlpha=e.overlayAlpha),e.messageText&&(this.contentText=e.messageText),e.positiveButtonText&&(this.positiveButtonText=e.positiveButtonText),e.negativeButtonText&&(this.negativeButtonText=e.negativeButtonText),e.size&&(this.size=e.size),e.cornerRadius&&(this.cornerRadius=e.cornerRadius),e.fontColor&&(this.fontColor=e.fontColor),e.backgroundColor&&(this.backgroundColor=e.backgroundColor))}show(){this.hidden=!1}onDialogResult(e,t){let n={type:l.Composite,compositeType:`DialogResult`,nodeUuid:this.uuid,callback:e};t!=null&&t.replaceExisting&&(this.eventListeners=this.eventListeners.filter(e=>!(e.nodeUuid===n.nodeUuid&&e.type===n.type))),this.eventListeners.push(n)}initialize(){this.removeAllChildren();let e=new p({rect:{width:m2c2Globals.canvasCssWidth,height:m2c2Globals.canvasCssHeight,x:m2c2Globals.canvasCssWidth/2,y:m2c2Globals.canvasCssHeight/2},fillColor:[0,0,0,this.overlayAlpha],zPosition:-1,isUserInteractionEnabled:!0});e.onTapDown(e=>{e.handled=!0,this.hidden=!0,this.eventListeners.length>0&&this.eventListeners.filter(e=>e.type===l.Composite).forEach(e=>{let t={type:l.Composite,target:this,handled:!1,dialogResult:`Dismiss`,timestamp:g.now(),iso8601Timestamp:new Date().toISOString()};e.callback(t)})}),this.addChild(e);let t=new p({rect:{width:300,height:150,x:m2c2Globals.canvasCssWidth/2,y:m2c2Globals.canvasCssHeight/2},cornerRadius:this.cornerRadius,fillColor:this.backgroundColor,isUserInteractionEnabled:!0});t.onTapDown(e=>{e.handled=!0}),this.addChild(t);let n=new o({text:this.contentText,fontSize:24,position:{x:200,y:360}});this.addChild(n);let r=new D({text:this.negativeButtonText,position:{x:120,y:440},size:{width:100,height:40},isUserInteractionEnabled:!0,zPosition:1});r.onTapDown(e=>{e.handled=!0,this.hidden=!0}),r.onTapDown(e=>{e.handled=!0,this.hidden=!0,this.eventListeners.length>0&&this.eventListeners.filter(e=>e.type===l.Composite).forEach(e=>{let t={type:l.Composite,target:this,handled:!1,dialogResult:`Negative`,timestamp:g.now(),iso8601Timestamp:new Date().toISOString()};e.callback(t)})});let i=new D({text:this.positiveButtonText,position:{x:280,y:440},size:{width:100,height:40},isUserInteractionEnabled:!0,zPosition:1});i.onTapDown(e=>{e.handled=!0,this.hidden=!0,this.eventListeners.length>0&&this.eventListeners.filter(e=>e.type===l.Composite).forEach(e=>{let t={type:l.Composite,target:this,handled:!1,dialogResult:`Positive`,timestamp:g.now(),iso8601Timestamp:new Date().toISOString()};e.callback(t)})}),this.addChild(r),this.addChild(i),this.needsInitialization=!1}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=e,this.needsInitialization=!0}get fontColor(){return this._fontColor}set fontColor(e){this._fontColor=e,this.needsInitialization=!0}get hidden(){return this._hidden}set hidden(e){this._hidden=e,this.needsInitialization=!0}duplicate(e){throw new c(`duplicate not implemented. ${e}`)}update(){super.update()}draw(e){super.drawChildren(e)}warmup(e){this.initialize(),this.children.filter(e=>e.isDrawable).forEach(t=>{t.warmup(e)})}};const A={StrokeStart:`StrokeStart`,StrokeMove:`StrokeMove`,StrokeEnd:`StrokeEnd`},j={StrokeEnter:`StrokeEnter`,StrokeLeave:`StrokeLeave`};var M=class extends t{constructor(e){if(super(e),this.compositeType=`DrawPad`,this.resumeDrawingOnReturn=!1,this.continuousDrawingOnly=!1,this._backgroundColor=[0,0,0,0],this._borderColor=y.Black,this._borderWidth=1,this._lineColor=y.Red,this._lineWidth=1,this.isDrawingPointerDown=!1,this.pointerIsDownAndPointerLeftDrawAreaWhenDown=!1,this.currentStrokesNotAllowed=!1,this.strokes=[],this.originalOptions=JSON.parse(JSON.stringify(e)),e.isUserInteractionEnabled===void 0&&(this.isUserInteractionEnabled=!0),!e.size)throw new c(`DrawPad size must be specified`);this.size=e.size,e.lineColor&&(this.lineColor=e.lineColor),e.lineWidth&&(this.lineWidth=e.lineWidth),e.backgroundColor&&(this.backgroundColor=e.backgroundColor),e.borderColor&&(this.borderColor=e.borderColor),e.borderWidth&&(this.borderWidth=e.borderWidth),e.resumeDrawingOnReturn!==void 0&&(this.resumeDrawingOnReturn=e.resumeDrawingOnReturn),e.continuousDrawingOnly!==void 0&&(this.continuousDrawingOnly=e.continuousDrawingOnly),e.continuousDrawingOnlyExceptionDistance!==void 0&&(this.continuousDrawingOnlyExceptionDistance=e.continuousDrawingOnlyExceptionDistance),this.saveNodeNewEvent()}get completeNodeOptions(){return T(T(T(T({},this.options),this.getNodeOptions()),this.getDrawableOptions()),this.originalOptions)}initialize(){this.initializeDrawShape(),this.initializeDrawArea(),this.needsInitialization=!1}initializeDrawShape(){if(!this.drawShape){let e=new d;this.drawShape=new p({path:e,size:this.size,isPartOfComposite:!0}),this.addChild(this.drawShape)}this.drawShape.strokeColor=this.lineColor,this.drawShape.lineWidth=this.lineWidth}initializeDrawArea(){this.drawArea||(this.drawArea=new p({rect:{size:this.size},isUserInteractionEnabled:!0,isPartOfComposite:!0}),this.addChild(this.drawArea),this.drawArea.onTapDown(e=>{this.handleTapDown(e)}),this.drawArea.onPointerMove(e=>{this.handlePointerMove(e)}),this.drawArea.onTapUpAny(()=>{this.handleTapUpAny()}),this.drawArea.onTapLeave(e=>{this.handleTapLeave(e)})),this.drawArea.fillColor=this.backgroundColor,this.drawArea.strokeColor=this.borderColor,this.drawArea.lineWidth=this.borderWidth}dist(e,t){return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)}handleTapDown(e){if(this.isUserInteractionEnabled){var t;if(!((t=this.drawShape)!=null&&t.path))throw new c(`DrawPad.handleTapDown(): no drawShape.path`);let n=this.drawShape.path;if(this.continuousDrawingOnly&&n.subpaths.length!==0){let t=n.subpaths[n.subpaths.length-1][n.subpaths[n.subpaths.length-1].length-1],r=e.point;if(this.continuousDrawingOnlyExceptionDistance===void 0||this.dist(t,r)>this.continuousDrawingOnlyExceptionDistance){this.currentStrokesNotAllowed=!0;return}}this.currentStrokesNotAllowed=!1,this.isDrawingPointerDown=!0,n.move(e.point);let r=T({type:A.StrokeStart,target:this,handled:!1,position:e.point},u.createTimestamps());this.strokes.push([{type:A.StrokeStart,position:e.point,iso8601Timestamp:new Date().toISOString(),interpolated:!1}]),this.raiseDrawPadEvent(r)}}addInterpolatedStrokeMove(e){var t;let n=this.strokes.length,r=this.strokes[n-1].length,i=this.strokes[this.strokes.length-1][r-1].position,a=this.interpolateToDrawPadBorder(e,i,this.size);if(!((t=this.drawShape)!=null&&t.path))throw new c(`DrawPad.addInterpolatedStrokeMove(): no drawShape.path`);this.drawShape.path.addLine(a);let o=T({type:A.StrokeMove,target:this,handled:!1,position:a},u.createTimestamps());return this.strokes[n-1].push({type:A.StrokeMove,position:a,iso8601Timestamp:new Date().toISOString(),interpolated:!0}),this.raiseDrawPadEvent(o),a}handleTapLeave(e){if(this.currentStrokesNotAllowed){this.isDrawingPointerDown=!1;return}if(this.resumeDrawingOnReturn===!1){this.isDrawingPointerDown=!1;let t=this.strokes.length,n=this.strokes[t-1].length,r=!1,i=e.point;this.isPointWithinDrawPad(e.point,this.size)||(i=this.addInterpolatedStrokeMove(e.point),r=!0);let a=T({type:A.StrokeEnd,position:this.strokes[t-1][n-1].position,target:this,handled:!1},u.createTimestamps());this.strokes[t-1].push({type:A.StrokeEnd,position:r?i:this.strokes[t-1][n-1].position,iso8601Timestamp:new Date().toISOString(),interpolated:r}),this.raiseDrawPadEvent(a),this.currentStrokesNotAllowed=!0}else this.pointerIsDownAndPointerLeftDrawAreaWhenDown=!0}handleTapUpAny(){if(this.currentStrokesNotAllowed){this.isDrawingPointerDown=!1;return}if(this.isUserInteractionEnabled){this.isDrawingPointerDown=!1,this.pointerIsDownAndPointerLeftDrawAreaWhenDown=!1;let e=this.strokes.length,t=this.strokes[e-1].length,n=T({type:A.StrokeEnd,position:this.strokes[e-1][t-1].position,target:this,handled:!1},u.createTimestamps());this.strokes[e-1].push({type:A.StrokeEnd,position:this.strokes[e-1][t-1].position,iso8601Timestamp:new Date().toISOString(),interpolated:!1}),this.raiseDrawPadEvent(n)}}handlePointerMove(e){if(this.isUserInteractionEnabled&&this.isDrawingPointerDown){var t;if(!((t=this.drawShape)!=null&&t.path))throw new c(`DrawPad.handlePointerMove(): no drawShape.path`);let n=this.drawShape.path;this.isDrawingPointerDown&&!this.pointerIsDownAndPointerLeftDrawAreaWhenDown&&n.addLine(e.point),this.pointerIsDownAndPointerLeftDrawAreaWhenDown&&(this.pointerIsDownAndPointerLeftDrawAreaWhenDown=!1,n.move(e.point));let r=T({type:A.StrokeMove,target:this,handled:!1,position:e.point},u.createTimestamps()),i=this.strokes.length;this.strokes[i-1].push({type:A.StrokeMove,position:e.point,iso8601Timestamp:new Date().toISOString(),interpolated:!1}),this.raiseDrawPadEvent(r)}}update(){super.update()}draw(e){super.drawChildren(e)}raiseDrawPadEvent(e){this.eventListeners.length>0&&this.eventListeners.filter(t=>t.type===e.type).forEach(t=>{t.callback(e)})}raiseDrawPadItemEvent(e,t){e.eventListeners.length>0&&e.eventListeners.filter(e=>e.type===t.type).forEach(e=>{e.callback(t)})}clear(){var e;if(!((e=this.drawShape)!=null&&e.path))throw new c(`DrawPad.clear(): no drawShape.path`);this.drawShape.path.clear(),this.strokes=[]}warmup(e){this.initialize(),this.children.filter(e=>e.isDrawable).forEach(t=>{t.warmup(e)})}onStrokeStart(e,t){this.addEventListener(A.StrokeStart,e,t)}onStrokeMove(e,t){this.addEventListener(A.StrokeMove,e,t)}onStrokeEnd(e,t){this.addEventListener(A.StrokeEnd,e,t)}addItem(e){return Object.defineProperty(e,"drawPadPosition",{get:function(){let t=e.parent;return{get x(){return e.position.x+t.size.width/2},set x(n){e.position.x=n-t.size.width/2},get y(){return e.position.y+t.size.height/2},set y(n){e.position.y=n-t.size.height/2}}},set:function(t){let n=e.parent;e.position.x=t.x-n.size.width/2,e.position.y=t.y-n.size.height/2}}),Object.defineProperty(e,"onStrokeEnter",{value:function(e,t){this.addEventListener(j.StrokeEnter,e,t)}}),Object.defineProperty(e,"onStrokeLeave",{value:function(e,t){this.addEventListener(j.StrokeLeave,e,t)}}),Object.defineProperty(e,"isStrokeWithinBounds",{value:!1,writable:!0}),e.onPointerDown(()=>{if(this.isDrawingPointerDown&&e.isStrokeWithinBounds===!1){e.isStrokeWithinBounds=!0;let t=T({type:j.StrokeEnter,target:e},u.createTimestamps());this.raiseDrawPadItemEvent(e,t)}}),e.onPointerMove(()=>{if(this.isDrawingPointerDown&&e.isStrokeWithinBounds===!1){e.isStrokeWithinBounds=!0;let t=T({type:j.StrokeEnter,target:e},u.createTimestamps());this.raiseDrawPadItemEvent(e,t)}}),e.onPointerLeave(()=>{if(this.isDrawingPointerDown&&e.isStrokeWithinBounds===!0){e.isStrokeWithinBounds=!1;let t=T({type:j.StrokeLeave,target:e},u.createTimestamps());this.raiseDrawPadItemEvent(e,t)}}),e.onPointerUp(()=>{if(e.isStrokeWithinBounds===!0){e.isStrokeWithinBounds=!1;let t=T({type:j.StrokeLeave,target:e},u.createTimestamps());this.raiseDrawPadItemEvent(e,t)}}),this.addChild(e),e.zPosition=-1,e.position.x=e.position.x-this.size.width/2,e.position.y=e.position.y-this.size.height/2,e.isUserInteractionEnabled=!0,e}takeScreenshot(){let e=this.drawArea;if(!e)throw new c(`DrawPad.takeScreenshot(): no drawArea`);let t=(e.absolutePosition.x-e.size.width/2)*m2c2Globals.canvasScale,n=(e.absolutePosition.y-e.size.height/2)*m2c2Globals.canvasScale,r=e.size.width*m2c2Globals.canvasScale,i=e.size.height*m2c2Globals.canvasScale,a={alphaType:this.game.canvasKit.AlphaType.Unpremul,colorType:this.game.canvasKit.ColorType.RGBA_8888,colorSpace:this.game.canvasKit.ColorSpace.SRGB,width:r,height:i},o=this.game.snapshots[0].readPixels(t,n,a),s=this.game.canvasKit.MakeImage(a,o,o.length/i);if(!s)throw new c(`DrawPad.takeScreenshot(): no croppedImage`);let l=s.encodeToBytes();if(!l)throw new c(`DrawPad.takeScreenshot(): croppedImage.encodeToBytes() failed`);return s.delete(),this.arrayBufferToBase64String(l)}isPointWithinDrawPad(e,t){return e.x>=0&&e.x<=t.width&&e.y>=0&&e.y<=t.height}interpolateToDrawPadBorder(e,t,n){let r=(e.y-t.y)/(e.x-t.x),i=e.y-r*e.x,a={x:0,y:0};if(!Number.isFinite(r)){if(a.x=e.x,e.y-t.y>0)return a.y=n.height,a;if(e.y-t.y<0)return a.y=0,a}let o=r*0+i,s=r*n.width+i;if(o>=0&&o<=n.height&&e.x-t.x<0)return a.x=0,a.y=o,a;if(s>=0&&s<=n.height&&e.x-t.x>0)return a.x=n.width,a.y=s,a;let c=(0-i)/r,l=(n.height-i)/r;return c>=0&&c<=n.width&&e.y-t.y<0?(a.x=c,a.y=0,a):l>=0&&l<=n.width&&e.y-t.y>0?(a.x=l,a.y=n.height,a):e}arrayBufferToBase64String(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.byteLength;e++)t+=String.fromCharCode(n[e]);return window.btoa(t)}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=e,this.needsInitialization=!0}get borderColor(){return this._borderColor}set borderColor(e){this._borderColor=e,this.needsInitialization=!0}get borderWidth(){return this._borderWidth}set borderWidth(e){this._borderWidth=e,this.needsInitialization=!0}get lineColor(){return this._lineColor}set lineColor(e){this._lineColor=e,this.needsInitialization=!0}get lineWidth(){return this._lineWidth}set lineWidth(e){this._lineWidth=e,this.needsInitialization=!0}duplicate(e){throw new c(`DrawPad.duplicate(): Method not implemented. ${e}`)}};u.registerM2NodeClass(M);var N=class extends t{constructor(e){var t,n,r,i,a,o,s,c,l,u,d,f,m,h;super(e),this.compositeType=`VirtualKeyboard`,this.keyboardRows=[],this.shiftActivated=!1,this.keyShapes=[],this.keyLabels=[],this.originalOptions=JSON.parse(JSON.stringify(e)),e.isUserInteractionEnabled===void 0&&(this._isUserInteractionEnabled=!0),this.size=e.size,this.position=(t=e.position)==null?{x:0,y:0}:t,this.keyboardHorizontalPaddingPercent=(n=e.keyboardHorizontalPaddingPercent)==null?.02:n,this.keyboardVerticalPaddingPercent=(r=e.keyboardVerticalPaddingPercent)==null?.025:r,this.keyHorizontalPaddingPercent=(i=e.keyHorizontalPaddingPercent)==null?.1:i,this.keyVerticalPaddingPercent=(a=e.keyVerticalPaddingPercent)==null?.1:a,e.rows!==void 0&&(this.keyboardRows=e.rows.map(e=>e.map(e=>{if(e instanceof Object&&!Array.isArray(e)){let t=e;return e.keyIconShapeOptions&&(e.keyIconShapeOptions.isPartOfComposite=!0,t.keyIcon=new p(e.keyIconShapeOptions),t.keyIconShapeOptions=void 0),t}else return e}))),this.keysPerRow=(o=e.keysPerRow)==null?NaN:o,this.fontSize=(s=e.fontSize)==null?NaN:s,this.fontNames=e.fontNames,this.hiddenKeys=(c=e.hiddenKeys)==null?``:c,this.capitalLettersOnly=(l=e.capitalLettersOnly)==null?!1:l,this.keyColor=(u=e.keyColor)==null?y.White:u,this.keyDownColor=(d=e.keyDownColor)==null?y.Transparent:d,this.specialKeyDownColor=(f=e.specialKeyDownColor)==null?y.LightSteelBlue:f,this.backgroundColor=(m=e.backgroundColor)==null?[242,240,244,1]:m,this.showKeyDownPreview=(h=e.showKeyDownPreview)==null?!0:h,this.saveNodeNewEvent()}get completeNodeOptions(){return T(T(T(T({},this.options),this.getNodeOptions()),this.getDrawableOptions()),this.originalOptions)}initialize(){var e,t;this.game.eventStore.mode===a.Replay&&(this._isUserInteractionEnabled=!1),this.keyboardRows.length===0&&(this.keyboardRows=this.createDefaultKeyboardRows(),this.keysPerRow=this.keyboardRows.reduce((e,t)=>Math.max(e,t.length),0),this.fontSize=this.size.height/this.keyboardRows.length/2.5);let n=new p({rect:{size:this.size},fillColor:this.backgroundColor,isPartOfComposite:!0});this.addChild(n);let r=this.internalKeyboardRowsToInternalKeyboardConfiguration(this.keyboardRows),i={x:-n.size.width/2,y:-n.size.height/2},s=((e=this.keyboardVerticalPaddingPercent)==null?.025:e)*this.size.height,c=((t=this.keyboardHorizontalPaddingPercent)==null?.02:t)*this.size.width,l=(this.size.height-2*s)/r.length,u=(this.size.width-2*c)/this.keysPerRow;this.keyShapes=[];for(let e=0;e<r.length;e++){let t=r[e],a=t.reduce((e,t)=>{var n;return e+((n=t.widthRatio)==null?1:n)},0),_=0;a<this.keysPerRow&&(_=(this.size.width-2*c-u*a)/2);for(let r=0;r<t.length;r++){var d,f,m,h,g;let a=t[r];if((d=this.hiddenKeys)!=null&&d.split(`,`).map(e=>e===` `?` `:e.trim()).includes(a.code))continue;let v=t.slice(0,r).reduce((e,t)=>{var n;return e+((n=t.widthRatio)==null?1:n)},0)*u,b=new p({rect:{size:{width:u*((f=a.widthRatio)==null?1:f),height:l}},fillColor:y.Transparent,strokeColor:y.Transparent,lineWidth:1,position:{x:_+i.x+c+v+((m=a.widthRatio)==null?1:m)*u/2,y:i.y+s+e*l+l/2},isPartOfComposite:!0}),x=new p({rect:{size:{width:u*((h=a.widthRatio)==null?1:h)-2*this.keyHorizontalPaddingPercent*u,height:l-((g=a.heightRatio)==null?1:g)-2*this.keyVerticalPaddingPercent*l}},cornerRadius:4,fillColor:this.keyColor,lineWidth:0,isUserInteractionEnabled:this.isUserInteractionEnabled,isPartOfComposite:!0});x.userData={code:a.code},b.addChild(x),this.keyShapes.push(x);let S=new o({text:a.labelText,fontSize:this.fontSize,fontNames:this.fontNames,isPartOfComposite:!0});S.userData={code:a.code},b.addChild(S),this.keyLabels.push(S),a.keyIcon&&b.addChild(a.keyIcon),n.addChild(b),x.onTapUp(e=>{this.handleKeyShapeTapUp(a,x,e)}),x.onTapDown(e=>{this.handleKeyShapeTapDown(a,x,e)}),x.onTapLeave(e=>{this.handleKeyShapeTapLeave(a,x,e)})}}this.letterCircle=new p({circleOfRadius:28,fillColor:y.Silver,hidden:!0,isPartOfComposite:!0}),n.addChild(this.letterCircle),this.letterCircleLabel=new o({text:``,fontSize:this.fontSize,fontNames:this.fontNames,isPartOfComposite:!0}),this.letterCircle.addChild(this.letterCircleLabel),this.needsInitialization=!1}onKeyDown(e,t){let n={type:l.Composite,compositeEventType:`VirtualKeyboardKeyDown`,compositeType:this.compositeType,nodeUuid:this.uuid,callback:e};this.addVirtualKeyboardEventListener(n,t)}onKeyUp(e,t){let n={type:l.Composite,compositeEventType:`VirtualKeyboardKeyUp`,compositeType:this.compositeType,nodeUuid:this.uuid,callback:e};this.addVirtualKeyboardEventListener(n,t)}onKeyLeave(e,t){let n={type:l.Composite,compositeEventType:`VirtualKeyboardKeyLeave`,compositeType:this.compositeType,nodeUuid:this.uuid,callback:e};this.addVirtualKeyboardEventListener(n,t)}update(){super.update()}draw(e){super.drawChildren(e)}warmup(e){this.initialize(),this.children.filter(e=>e.isDrawable).forEach(t=>{t.warmup(e)})}duplicate(e){throw new c(`Method not implemented. ${e}`)}handleKeyShapeTapDown(e,t,n){e.isShift&&(this.shiftActivated=!this.shiftActivated);let r=this.getKeyAsString(e),i=T({type:l.Composite,compositeType:`VirtualKeyboard`,compositeEventType:`VirtualKeyboardKeyDown`,target:this,handled:!1,key:r,code:e.code,shiftKey:this.shiftActivated,keyTapMetadata:{size:t.size,point:n.point,buttons:n.buttons}},u.createTimestamps());this.handleCompositeEvent(i),this.saveEvent(i),this.eventListeners.length>0&&this.eventListeners.filter(e=>e.type===l.Composite&&e.compositeType===`VirtualKeyboard`&&e.compositeEventType===`VirtualKeyboardKeyDown`).forEach(e=>{e.callback(i)})}handleKeyShapeTapUp(e,t,n){let r=this.getKeyAsString(e),i=T({type:l.Composite,compositeType:`VirtualKeyboard`,compositeEventType:`VirtualKeyboardKeyUp`,target:this,handled:!1,key:r,code:e.code,shiftKey:this.shiftActivated,keyTapMetadata:{size:t.size,point:n.point,buttons:n.buttons}},u.createTimestamps());this.handleCompositeEvent(i),this.saveEvent(i),this.eventListeners.length>0&&this.eventListeners.filter(e=>e.type===l.Composite&&e.compositeType===`VirtualKeyboard`&&e.compositeEventType===`VirtualKeyboardKeyUp`).forEach(e=>{e.callback(i)})}handleKeyShapeTapLeave(e,t,n){let r=this.getKeyAsString(e),i=T({type:l.Composite,compositeType:`VirtualKeyboard`,compositeEventType:`VirtualKeyboardKeyLeave`,target:this,handled:!1,key:r,code:e.code,shiftKey:this.shiftActivated,keyTapMetadata:{size:t.size,point:n.point,buttons:n.buttons}},u.createTimestamps());this.handleCompositeEvent(i),this.saveEvent(i),this.eventListeners.length>0&&this.eventListeners.filter(e=>e.type===l.Composite&&e.compositeType===`VirtualKeyboard`&&e.compositeEventType===`VirtualKeyboardKeyLeave`).forEach(e=>{e.callback(i)})}getKeyAsString(e){if(e.isShift||e.code===` `||e.code===`Backspace`)return e.code;if(this.shiftActivated){var t;return(t=e.labelTextShifted)==null?e.code:t}else{var n;return(n=e.labelText)==null?e.code:n}}internalKeyboardRowsToInternalKeyboardConfiguration(e){return e.map(e=>e.map(e=>{let t=1,n,r,i,a,o=!1;if(typeof e==`string`)n=e,r=this.capitalLettersOnly?n.toUpperCase():n,i=n.toUpperCase();else if(Array.isArray(e))n=e[0],r=n,i=e[1];else{var s,c,l,u;n=e.code,r=(s=e.labelText)==null?``:s,i=(c=e.labelTextShifted)==null?r:c,t=(l=e.widthRatio)==null?1:l,a=e.keyIcon,o=(u=e.isShift)==null?!1:u}return{widthRatio:t,heightRatio:1,code:n,labelText:r,labelTextShifted:i,keyIcon:a,isShift:o}}))}handleCompositeEvent(e){let t=this.internalKeyboardRowsToInternalKeyboardConfiguration(this.keyboardRows),n=this.keyShapes.find(t=>t.userData.code===e.code);if(!n)throw new c(`keyShape is not defined`);switch(this.shiftActivated=e.shiftKey,e.compositeEventType){case`VirtualKeyboardKeyDown`:this.handleKeyDownEvent(e,t,n);break;case`VirtualKeyboardKeyUp`:this.handleKeyUpEvent(e,t,n);break;case`VirtualKeyboardKeyLeave`:this.handleKeyLeaveEvent(e,t,n);break;default:throw new c(`Unknown VirtualKeyboardEvent: ${e.compositeEventType}`)}}handleKeyDownEvent(e,t,n){if(e.code.toLowerCase().includes(`shift`))e.shiftKey?this.showKeyboardShifted(t):this.showKeyboardNotShifted(t);else if(e.code===` `||e.code===`Backspace`)n.fillColor=this.specialKeyDownColor;else if(n.fillColor=this.keyDownColor,this.showKeyDownPreview){var r;if(!this.letterCircle||!this.letterCircleLabel)throw new c(`letterCircle is not defined`);this.letterCircle.hidden=!1;let t=n.parent;if(this.letterCircle.position.x=t.position.x,((r=n.rect)==null||(r=r.size)==null?void 0:r.height)===void 0)throw new c(`keyShape.rect.height is undefined`);this.letterCircle.position.y=t.position.y-n.rect.size.height*1.2;let o=this.internalKeyboardRowsToInternalKeyboardConfiguration(this.keyboardRows),s=u.flat(o).find(t=>t.code===e.code);if(!s)throw new c(`key is not defined`);if(this.shiftActivated){var i;this.letterCircleLabel.text=(i=s.labelTextShifted)==null?s.code:i}else{var a;this.letterCircleLabel.text=(a=s.labelText)==null?s.code:a}}}handleKeyUpEvent(e,t,n){if(!(e.code.toLowerCase().includes(`shift`)&&e.shiftKey)){if(e.code.toLowerCase().includes(`shift`)&&!e.shiftKey){this.shiftActivated=!1,this.showKeyboardNotShifted(t);return}if(n.fillColor=this.keyColor,!this.letterCircle)throw new c(`letterCircle is not defined`);this.letterCircle.hidden=!0,!e.code.toLowerCase().includes(`shift`)&&e.shiftKey&&(this.shiftActivated=!1,this.showKeyboardNotShifted(t))}}handleKeyLeaveEvent(e,t,n){if(e.code.toLowerCase().includes(`shift`)){e.shiftKey?(this.showKeyboardNotShifted(t),this.shiftActivated=!1):(this.showKeyboardShifted(t),this.shiftActivated=!0);return}if(n.fillColor=this.keyColor,!this.letterCircle)throw new c(`letterCircle is not defined`);this.letterCircle.hidden=!0}showKeyboardShifted(e){this.keyShapes.filter(e=>e.userData.code.toLowerCase().includes(`shift`)).forEach(e=>{e.fillColor=this.specialKeyDownColor}),u.flat(e).filter(e=>e.isShift).forEach(e=>{e.keyIcon&&(e.keyIcon.fillColor=y.Black)}),u.flat(e).forEach(e=>{let t=this.keyLabels.find(t=>t.userData.code===e.code);if(!t)throw new c(`keyLabel is not defined`);if(t.text!==void 0){var n;t.text=(n=e.labelTextShifted)==null?``:n}})}showKeyboardNotShifted(e){this.keyShapes.filter(e=>e.userData.code.toLowerCase().includes(`shift`)).forEach(e=>{e.fillColor=this.keyColor}),u.flat(e).filter(e=>e.isShift).forEach(e=>{e.keyIcon&&(e.keyIcon.fillColor=y.Transparent)}),u.flat(e).forEach(e=>{let t=this.keyLabels.find(t=>t.userData.code===e.code);if(!t)throw new c(`keyLabel is not defined`);if(t.text!==void 0){var n;t.text=(n=e.labelText)==null?``:n}})}createDefaultKeyboardRows(){let e=[[`1`,`!`],[`2`,`@`],[`3`,`#`],[`4`,`$`],[`5`,`%`],[`6`,`^`],[`7`,`&`],[`8`,`*`],[`9`,`(`],[`0`,`)`]],t=[`q`,`w`,`e`,`r`,`t`,`y`,`u`,`i`,`o`,`p`],n=[`a`,`s`,`d`,`f`,`g`,`h`,`j`,`k`,`l`],r={path:{pathString:`m288-6.6849e-14 -288 288h144v288h288v-288h144l-288-288z`,width:24},lineWidth:2,strokeColor:y.Black,fillColor:y.Transparent,isPartOfComposite:!0},i={path:{pathString:`M10.625 5.09 0 22.09l10.625 17H44.18v-34H10.625zm31.555 32H11.734l-9.375-15 9.375-15H42.18v30zm-23.293-6.293 7.293-7.293 7.293 7.293 1.414-1.414-7.293-7.293 7.293-7.293-1.414-1.414-7.293 7.293-7.293-7.293-1.414 1.414 7.293 7.293-7.293 7.293`,width:24},lineWidth:1,strokeColor:y.Black,fillColor:y.Red,isPartOfComposite:!0};return[e,t,n,[{code:`Shift`,isShift:!0,widthRatio:1.5,keyIcon:new p(r)},`z`,`x`,`c`,`v`,`b`,`n`,`m`,{code:`Backspace`,widthRatio:1.5,keyIcon:new p(i)}],[{code:` `,labelText:`SPACE`,widthRatio:5}]]}addVirtualKeyboardEventListener(e,t){t!=null&&t.replaceExisting&&(this.eventListeners=this.eventListeners.filter(t=>!(t.nodeUuid===e.nodeUuid&&t.type===e.type&&t.compositeType===e.compositeType))),this.eventListeners.push(e)}get isUserInteractionEnabled(){return this._isUserInteractionEnabled}set isUserInteractionEnabled(e){var t;this._isUserInteractionEnabled=e,(t=this.keyShapes)==null||t.forEach(t=>{t.isUserInteractionEnabled=e})}};u.registerM2NodeClass(N);const P=r.sinusoidalInOut;var F=class extends h{static create(e){let t=[];return e.instructionScenes.forEach((r,i)=>{var a,c,l,u,d,p,h,g,b,x,S,C,w,T,E,O,k,A,j,M,N,F,I,L,R,z,B,V,H,U,ee,te,W,G,K,q,J;let Y=(a=(c=r.nextSceneTransition)==null?e.nextSceneTransition:c)==null?_.slide({direction:v.Left,duration:500,easing:P}):a,ne=(l=(u=r.backSceneTransition)==null?e.backSceneTransition:u)==null?_.slide({direction:v.Right,duration:500,easing:P}):l,re=(d=(p=r.backButtonText)==null?e.backButtonText:p)==null?`Back`:d,ie=(h=r.backButtonTextInterpolation)==null?e.backButtonTextInterpolation:h,ae=(g=(b=r.nextButtonText)==null?e.nextButtonText:b)==null?`Next`:g,oe=(x=r.nextButtonTextInterpolation)==null?e.nextButtonTextInterpolation:x,se=(S=(C=r.backButtonWidth)==null?e.backButtonWidth:C)==null?125:S,ce=(w=(T=r.nextButtonWidth)==null?e.nextButtonWidth:T)==null?125:w,le=(E=(O=r.backButtonHeight)==null?e.backButtonHeight:O)==null?50:E,ue=(k=(A=r.nextButtonHeight)==null?e.nextButtonHeight:A)==null?50:k,de=(j=r.backgroundColor)==null?e.backgroundColor:j,fe=(M=r.imageAboveText)==null?!0:M,pe=(N=r.imageMarginTop)==null?0:N,me=(F=r.imageMarginBottom)==null?0:F,he=(I=r.textMarginStart)==null?48:I,ge=(L=r.textMarginEnd)==null?48:L,_e=(R=r.textAlignmentMode)==null?s.Left:R,ve=(z=r.textFontSize)==null?16:z,ye=(B=r.titleFontSize)==null?16:B,be=(V=r.titleMarginTop)==null?48:V,xe=(H=(U=r.backButtonBackgroundColor)==null?e.backButtonBackgroundColor:U)==null?y.Black:H,Se=(ee=(te=r.backButtonFontColor)==null?e.backButtonFontColor:te)==null?y.White:ee,Ce=(W=(G=r.nextButtonBackgroundColor)==null?e.nextButtonBackgroundColor:G)==null?y.Black:W,we=(K=(q=r.nextButtonFontColor)==null?e.nextButtonFontColor:q)==null?y.White:K,X=(J=e.sceneNamePrefix)==null?`instructions`:J,Z=new f({name:X+`-`+(i+1).toString().padStart(2,`0`),backgroundColor:de}),Te;r.title!==void 0&&(Te=new o({text:r.title,interpolation:r.titleInterpolation,fontSize:ye,layout:{marginTop:be,constraints:{topToTopOf:Z,startToStartOf:Z,endToEndOf:Z}}}),Z.addChild(Te));let Q;if(r.text!==void 0&&(Q=new o({text:r.text,interpolation:r.textInterpolation,preferredMaxLayoutWidth:n.MatchConstraint,horizontalAlignmentMode:_e,fontSize:ve,layout:{marginStart:he,marginEnd:ge,constraints:{topToTopOf:Z,bottomToBottomOf:Z,startToStartOf:Z,endToEndOf:Z,verticalBias:r.textVerticalBias}}}),Z.addChild(Q)),r.imageName!==void 0){let e;e=Q===void 0?new m({imageName:r.imageName,layout:{constraints:{topToTopOf:Z,bottomToBottomOf:Z,verticalBias:r.imageVerticalBias,startToStartOf:Z,endToEndOf:Z}}}):fe?new m({imageName:r.imageName,layout:{marginBottom:me,constraints:{bottomToTopOf:Q,startToStartOf:Z,endToEndOf:Z}}}):new m({imageName:r.imageName,layout:{marginTop:pe,constraints:{topToBottomOf:Q,startToStartOf:Z,endToEndOf:Z}}}),Z.addChild(e)}if(i>0){let e=new D({name:`backButton`,text:re,interpolation:ie,fontColor:Se,backgroundColor:xe,size:{width:se,height:le},layout:{marginStart:32,marginBottom:80,constraints:{bottomToBottomOf:Z,startToStartOf:Z}}});e.isUserInteractionEnabled=!0,e.onTapDown(()=>{Z.game.presentScene(X+`-`+(i+1-1).toString().padStart(2,`0`),ne)}),Z.addChild(e)}let $=new D({name:`nextButton`,text:ae,interpolation:oe,fontColor:we,backgroundColor:Ce,size:{width:ce,height:ue},layout:{marginEnd:32,marginBottom:80,constraints:{bottomToBottomOf:Z,endToEndOf:Z}}});$.isUserInteractionEnabled=!0,i===e.instructionScenes.length-1?e.postInstructionsScene===void 0?$.onTapDown(()=>{let e=Z.game.scenes.indexOf(Z);if(e===-1)console.warn(`warning: postInstructionsScene is not defined, and next scene cannot be determined.`);else{let t=e+1;t<Z.game.scenes.length?Z.game.presentScene(Z.game.scenes[t],Y):console.warn(`warning: postInstructionsScene is not defined, and there is no next scene to present.`)}}):$.onTapDown(()=>{var t;Z.game.presentScene((t=e.postInstructionsScene)==null?``:t,Y)}):$.onTapDown(()=>{Z.game.presentScene(X+`-`+(i+1+1).toString().padStart(2,`0`),Y)}),Z.addChild($),t.push(Z)}),t}static Create(e){return this.create(e)}};const I=r.sinusoidalInOut;var L=class extends f{constructor(t){var n,r,i,a,s,l,u;if(super(t),(t==null?void 0:t.transitionDurationMilliseconds)!==void 0&&t!=null&&t.transition)throw new c(`Both transition and transitionDurationMilliseconds options were provided. Only one should be provided. If using a custom transition, then the duration of that transition must be specified within the custom transition.`);let d;if((t==null||(n=t.timerShape)==null?void 0:n.circle)===void 0&&(t==null||(r=t.timerShape)==null?void 0:r.rectangle)===void 0||(t==null?void 0:t.timerShape.circle)!==void 0){var f,m,h,g,b;d=new p({circleOfRadius:(f=t==null||(m=t.timerShape)==null||(m=m.circle)==null?void 0:m.radius)==null?100:f,layout:{constraints:{topToTopOf:this,bottomToBottomOf:this,startToStartOf:this,endToEndOf:this,verticalBias:(h=t==null?void 0:t.shapeVerticalBias)==null?.5:h}},fillColor:(g=t==null||(b=t.timerShape)==null?void 0:b.fillColor)==null?y.RoyalBlue:g}),this.addChild(d)}else if((t==null?void 0:t.timerShape.rectangle)!==void 0){var x,S,C,w,T,E,D,O;d=new p({rect:{width:(x=t==null||(S=t.timerShape)==null||(S=S.rectangle)==null?void 0:S.width)==null?200:x,height:(C=t==null||(w=t.timerShape)==null||(w=w.rectangle)==null?void 0:w.height)==null?200:C},cornerRadius:t==null||(T=t.timerShape)==null||(T=T.rectangle)==null?void 0:T.cornerRadius,layout:{constraints:{topToTopOf:this,bottomToBottomOf:this,startToStartOf:this,endToEndOf:this,verticalBias:(E=t.shapeVerticalBias)==null?.5:E}},fillColor:(D=t==null||(O=t.timerShape)==null?void 0:O.fillColor)==null?y.RoyalBlue:D}),this.addChild(d)}else throw new c(`Invalid timer shape options.`);let k=Math.floor(t.milliseconds/1e3),A=new o({text:``,fontSize:(i=t==null?void 0:t.timerNumbersFontSize)==null?50:i,fontName:t==null?void 0:t.timerNumbersFontName,fontColor:(a=t==null?void 0:t.timerNumbersFontColor)==null?y.White:a});d.addChild(A);let j=new o({text:(s=t==null?void 0:t.text)==null?`GET READY`:s,fontSize:(l=t==null?void 0:t.textFontSize)==null?50:l,fontName:t==null?void 0:t.textFontName,fontColor:t==null?void 0:t.textFontColor,layout:{marginTop:(u=t==null?void 0:t.textMarginTop)==null?32:u,constraints:{topToBottomOf:d,startToStartOf:this,endToEndOf:this}}});this.addChild(j);let M=[];for(let t=k-1;t>0;t--)M.push(e.wait({duration:1e3})),M.push(e.custom({callback:()=>{A.text=t.toString()}}));M.push(e.wait({duration:1e3})),M.push(e.custom({callback:()=>{var e;A.text=(e=t==null?void 0:t.zeroString)==null?`0`:e}})),(t==null?void 0:t.zeroDwellMilliseconds)!==void 0&&M.push(e.wait({duration:t.zeroDwellMilliseconds})),M.push(e.custom({callback:()=>{var e,n;let r=this.game;r.scenes.indexOf(this)===r.scenes.length-1&&r.end();let i=r.scenes[r.scenes.indexOf(this)+1];r.presentScene(i,(e=t==null?void 0:t.transition)==null?_.slide({direction:v.Left,duration:(n=t==null?void 0:t.transitionDurationMilliseconds)==null?500:n,easing:I}):e)}})),this.onSetup(()=>{A.text=k.toString()}),this.onAppear(()=>{this.run(e.sequence(M))})}},R=class extends t{constructor(e){super(e),this.compositeType=`LocalePicker`,this.DEFAULT_FONT_SIZE=24,this.automaticallyChangeLocale=!0,this._localeOptions=[],this._backgroundColor=y.White,this._fontSize=this.DEFAULT_FONT_SIZE,this._fontColor=y.Black,this._cornerRadius=8,this._overlayAlpha=.5,this._icon={svgString:`<svg xmlns="http://www.w3.org/2000/svg" width="420" height="420" stroke="#000" fill="none"><path stroke-width="26" d="M209 15a195 195 0 1 0 2 0z"/><path stroke-width="18" d="M210 15v390m195-195H15M59 90a260 260 0 0 0 302 0m0 240a260 260 0 0 0-302 0M195 20a250 250 0 0 0 0 382m30 0a250 250 0 0 0 0-382"/></svg>`,height:32,width:32},this._iconPosition={x:32,y:32},this.LEFT_SELECTION_INDICATOR=`«`,this.RIGHT_SELECTION_INDICATOR=`»`,this.zPosition=Number.MAX_VALUE,e&&(e.localeOptions&&(this.localeOptions=e.localeOptions),e.backgroundColor&&(this.backgroundColor=e.backgroundColor),e.overlayAlpha!==void 0&&(this.overlayAlpha=e.overlayAlpha),e.fontSize!==void 0&&(this.fontSize=e.fontSize),e.fontColor&&(this.fontColor=e.fontColor),e.cornerRadius&&(this.cornerRadius=e.cornerRadius),e.currentLocale!==void 0&&(this.currentLocale=e.currentLocale),e.icon&&(this.icon=e.icon),e.automaticallyChangeLocale!==void 0&&(this.automaticallyChangeLocale=e.automaticallyChangeLocale))}onResult(e,t){let n={type:l.Composite,compositeType:`LocalePickerResult`,nodeUuid:this.uuid,callback:e};t!=null&&t.replaceExisting&&(this.eventListeners=this.eventListeners.filter(e=>!(e.nodeUuid===n.nodeUuid&&e.type===`LocalePickerResult`))),this.eventListeners.push(n)}initialize(){if(this.currentLocale===void 0){var e;this.currentLocale=(e=this.game.i18n)==null?void 0:e.locale}if(this.localeOptions.length===0){var t;Object.keys(((t=this.game.i18n)==null?void 0:t.translation)||{}).filter(e=>e!==`configuration`).forEach(e=>{var t,n;this.localeOptions.push({text:((t=this.game.i18n)==null?void 0:t.translation[e].localeName)||e,locale:e,svg:(n=this.game.i18n)==null?void 0:n.translation[e].localeSvg})})}if(this.localeOptions.length===0)throw new c(`No locales available for LocalePicker`);[...this.children].filter(e=>e.name!==`localePickerIcon`).forEach(e=>this.removeChild(e)),this.game.imageManager.loadImages([{imageName:`__localePickerIcon`,svgString:this.icon.svgString,height:this.icon.height,width:this.icon.width}]),this.iconSprite||(this.iconSprite=new m({name:`localePickerIcon`,imageName:`__localePickerIcon`,position:this.iconPosition,isUserInteractionEnabled:!0,isPartOfComposite:!0}),this.addChild(this.iconSprite),this.iconSprite.onTapDown(e=>{e.handled=!0,this.setDialogVisibility(!0)}),this.iconSprite.onTapUp(e=>{e.handled=!0}),this.iconSprite.onTapUpAny(e=>{e.handled=!0}),this.iconSprite.onPointerUp(e=>{e.handled=!0}),this.iconSprite.onPointerDown(e=>{e.handled=!0}));let n=new p({rect:{width:m2c2Globals.canvasCssWidth,height:m2c2Globals.canvasCssHeight,x:m2c2Globals.canvasCssWidth/2,y:m2c2Globals.canvasCssHeight/2},fillColor:[0,0,0,this.overlayAlpha],zPosition:-1,isUserInteractionEnabled:!0,hidden:!0,isPartOfComposite:!0});n.onTapUp(e=>{e.handled=!0,this.eventListeners.length>0&&this.eventListeners.filter(e=>e.type===`LocalePickerResult`).forEach(e=>{let t={type:l.Composite,compositeType:this.compositeType,compositeEventType:`LocalePickerResult`,target:this,handled:!1,result:{locale:void 0},timestamp:g.now(),iso8601Timestamp:new Date().toISOString()};e.callback(t)}),this.setDialogVisibility(!1)}),n.onTapUpAny(e=>{e.handled=!0}),n.onTapDown(e=>{e.handled=!0}),n.onPointerUp(e=>{e.handled=!0}),n.onPointerDown(e=>{e.handled=!0}),this.addChild(n);let r=this.fontSize/this.DEFAULT_FONT_SIZE*50,i=this.localeOptions.length*r,a=m2c2Globals.canvasCssWidth/2,s={x:m2c2Globals.canvasCssWidth/2,y:m2c2Globals.canvasCssHeight/2},u=new p({rect:{width:a,height:i,x:s.x,y:s.y},cornerRadius:this.cornerRadius,fillColor:this.backgroundColor,isUserInteractionEnabled:!0,hidden:!0,isPartOfComposite:!0});u.onTapDown(e=>{e.handled=!0}),u.onTapUp(e=>{e.handled=!0}),u.onTapUpAny(e=>{e.handled=!0}),u.onPointerUp(e=>{e.handled=!0}),u.onPointerDown(e=>{e.handled=!0}),this.addChild(u);for(let e=0;e<this.localeOptions.length;e++){let t=this.localeOptions[e];if(t.svg){this.game.imageManager.loadImages([{imageName:t.text,svgString:t.svg.svgString,height:t.svg.height,width:t.svg.width}]);let n=new m({imageName:t.text,position:{x:s.x,y:s.y+e*r-i/2+r/2},isUserInteractionEnabled:!0,zPosition:1,hidden:!0,isPartOfComposite:!0});if(this.addChild(n),this.currentLocale===t.locale){let n=new o({text:this.LEFT_SELECTION_INDICATOR,fontSize:this.fontSize,fontColor:this.fontColor,position:{x:s.x-t.svg.width/2-this.fontSize/2,y:s.y+e*r-i/2+r/2},hidden:!0,localize:!1,isPartOfComposite:!0});this.addChild(n);let a=new o({text:this.RIGHT_SELECTION_INDICATOR,fontSize:this._fontSize,fontColor:this.fontColor,position:{x:s.x+t.svg.width/2+this.fontSize/2,y:s.y+e*r-i/2+r/2},hidden:!0,localize:!1,isPartOfComposite:!0});this.addChild(a)}n.onTapUp(e=>{e.handled=!0,this.handleLocaleSelection(e,t)}),n.onTapUpAny(e=>{e.handled=!0}),n.onTapDown(e=>{e.handled=!0}),n.onPointerUp(e=>{e.handled=!0}),n.onPointerDown(e=>{e.handled=!0})}else{let n=t.text;this.currentLocale===t.locale&&(n=`${this.LEFT_SELECTION_INDICATOR} ${n} ${this.RIGHT_SELECTION_INDICATOR}`);let a=new o({text:n,fontSize:this.fontSize,fontColor:this.fontColor,position:{x:s.x,y:s.y+e*r-i/2+r/2},isUserInteractionEnabled:!0,zPosition:1,hidden:!0,localize:!1,isPartOfComposite:!0});a.onTapUp(e=>{e.handled=!0,this.handleLocaleSelection(e,t)}),a.onTapUpAny(e=>{e.handled=!0}),a.onTapDown(e=>{e.handled=!0}),a.onPointerUp(e=>{e.handled=!0}),a.onPointerDown(e=>{e.handled=!0}),this.addChild(a)}}this.needsInitialization=!1}handleLocaleSelection(e,t){if(this.eventListeners.length>0&&this.eventListeners.filter(e=>e.type===l.Composite&&e.compositeType===`LocalePickerResult`&&e.nodeUuid==this.uuid).forEach(e=>{let n={type:l.Composite,compositeType:this.compositeType,compositeEventType:`LocalePickerResult`,target:this,handled:!1,result:{locale:t.locale},timestamp:g.now(),iso8601Timestamp:new Date().toISOString()};e.callback(n)}),this.setDialogVisibility(!1),this.automaticallyChangeLocale){var n;(n=this.game.i18n)==null||n.switchToLocale(t.locale),this.currentLocale=t.locale}}setDialogVisibility(e){this.children.filter(e=>e.name!==`localePickerIcon`).forEach(t=>{t.hidden=!e})}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=e,this.needsInitialization=!0}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize=e,this.needsInitialization=!0}get fontColor(){return this._fontColor}set fontColor(e){this._fontColor=e,this.needsInitialization=!0}get cornerRadius(){return this._cornerRadius}set cornerRadius(e){this._cornerRadius=e,this.needsInitialization=!0}get overlayAlpha(){return this._overlayAlpha}set overlayAlpha(e){this._overlayAlpha=e,this.needsInitialization=!0}get icon(){let e=this;return{get svgString(){return e._icon.svgString},set svgString(t){e._icon.svgString=t,e.needsInitialization=!0},get imageName(){return e._icon.imageName},set imageName(t){e._icon.imageName=t,e.needsInitialization=!0},get height(){return e._icon.height},set height(t){e._icon.height=t,e.needsInitialization=!0},get width(){return e._icon.width},set width(t){e._icon.width=t,e.needsInitialization=!0}}}set icon(e){this._icon=e,this.needsInitialization=!0}get iconPosition(){let e=this;return{get x(){return e._iconPosition.x},set x(t){e._iconPosition.x=t,e.iconSprite&&(e.iconSprite.position=e._iconPosition),e.needsInitialization=!0},get y(){return e._iconPosition.y},set y(t){e._iconPosition.y=t,e.iconSprite&&(e.iconSprite.position=e._iconPosition),e.needsInitialization=!0}}}set iconPosition(e){this._iconPosition=e,this.iconSprite&&(this.iconSprite.position=e),this.needsInitialization=!0}get localeOptions(){return this._localeOptions}set localeOptions(e){this._localeOptions=e,this.needsInitialization=!0}get currentLocale(){return this._currentLocale}set currentLocale(e){e!==this.currentLocale&&(this._currentLocale=e,this.needsInitialization=!0)}update(){super.update()}draw(e){super.drawChildren(e)}warmup(e){this.initialize(),this.children.filter(e=>e.isDrawable).forEach(t=>{t.warmup(e)})}duplicate(e){throw new c(`duplicate not implemented. ${e}`)}},z=class extends t{constructor(e){super(e),this.compositeType=`CountdownTimer`,this._milliseconds=3e3,this._tickIntervalMilliseconds=1e3,this._fontSize=50,this._fontColor=y.White,this._zeroString=`0`,this._timerShape={circle:{radius:100},fillColor:y.RoyalBlue},this._textVerticalBias=.5,this.countdownSequence=[],this._isRunning=!1,this.hasStopped=!1,this.originalOptions=JSON.parse(JSON.stringify(e)),e.milliseconds&&(this.milliseconds=e.milliseconds),e.tickIntervalMilliseconds&&(this.tickIntervalMilliseconds=e.tickIntervalMilliseconds),e.fontName&&(this.fontName=e.fontName),e.fontSize!==void 0&&(this.fontSize=e.fontSize),e.fontColor&&(this.fontColor=e.fontColor),e.zeroString!==void 0&&(this.zeroString=e.zeroString),e.timerShape&&(this.timerShape=e.timerShape),e.textVerticalBias!==void 0&&(this.textVerticalBias=e.textVerticalBias),this.saveNodeNewEvent()}get completeNodeOptions(){return T(T(T(T({},this.options),this.getNodeOptions()),this.getDrawableOptions()),this.originalOptions)}initialize(){var t,n,r,i;if(this.removeAllChildren(),this._isRunning=!1,this.hasStopped=!1,((t=this.timerShape)==null?void 0:t.circle)===void 0&&((n=this.timerShape)==null?void 0:n.rectangle)===void 0||((r=this.timerShape)==null?void 0:r.circle)!==void 0){var a,s,d,f;this.timerShapeNode=new p({circleOfRadius:(a=(s=this.timerShape.circle)==null?void 0:s.radius)==null?100:a,fillColor:(d=(f=this.timerShape)==null?void 0:f.fillColor)==null?y.RoyalBlue:d,isPartOfComposite:!0}),this.addChild(this.timerShapeNode)}else if(((i=this.timerShape)==null?void 0:i.rectangle)!==void 0){var m,h,g,_,v,b,x;this.timerShapeNode=new p({rect:{width:(m=(h=this.timerShape)==null||(h=h.rectangle)==null?void 0:h.width)==null?200:m,height:(g=(_=this.timerShape)==null||(_=_.rectangle)==null?void 0:_.height)==null?200:g},cornerRadius:(v=this.timerShape)==null||(v=v.rectangle)==null?void 0:v.cornerRadius,fillColor:(b=(x=this.timerShape)==null?void 0:x.fillColor)==null?y.RoyalBlue:b,isPartOfComposite:!0}),this.addChild(this.timerShapeNode)}else throw new c(`Invalid timer shape options.`);if(this.size=this.timerShapeNode.size,this.milliseconds%1e3!=0)throw new c(`CountdownTimer milliseconds must be a multiple of 1000.`);let S=Math.floor(this.milliseconds/1e3);this.timerNumberLabel=new o({text:S.toString(),fontSize:this.fontSize,fontName:this._fontName,fontColor:this.fontColor,layout:{constraints:{topToTopOf:this.timerShapeNode,bottomToBottomOf:this.timerShapeNode,startToStartOf:this.timerShapeNode,endToEndOf:this.timerShapeNode,verticalBias:this.textVerticalBias}},isPartOfComposite:!0}),this.timerShapeNode.addChild(this.timerNumberLabel),this.countdownSequence=[];for(let t=this.milliseconds;t>this.tickIntervalMilliseconds;t-=this.tickIntervalMilliseconds)this.countdownSequence.push(e.wait({duration:this.tickIntervalMilliseconds})),this.countdownSequence.push(e.custom({callback:()=>{this.tick(t-this.tickIntervalMilliseconds)}}));this.countdownSequence.push(e.wait({duration:this.tickIntervalMilliseconds})),this.countdownSequence.push(e.custom({callback:()=>{this.tick(0);let e=T({type:l.Composite,compositeType:this.compositeType,compositeEventType:`CountdownTimerComplete`,target:this,handled:!1,millisecondsRemaining:0},u.createTimestamps());this.handleCompositeEvent(e),this.saveEvent(e),this.eventListeners.length>0&&this.eventListeners.filter(e=>e.type===l.Composite&&e.compositeType===`CountdownTimer`&&e.compositeEventType===`CountdownTimerComplete`).forEach(t=>{t.callback(e)})}})),this.needsInitialization=!1}tick(e){let t=T({type:l.Composite,compositeType:this.compositeType,compositeEventType:`CountdownTimerTick`,target:this,handled:!1,millisecondsRemaining:e},u.createTimestamps());this.handleCompositeEvent(t),this.saveEvent(t),this.eventListeners.length>0&&this.eventListeners.filter(e=>e.type===l.Composite&&e.compositeType===`CountdownTimer`&&e.compositeEventType===`CountdownTimerTick`).forEach(e=>{e.callback(t)})}start(){if(this.isRunning)throw new c(`CountdownTimer: cannot start. It is already running.`);if(this.hasStopped)throw new c(`CountdownTimer: It has stopped. You cannot start a stopped CountdownTimer. Instead, create a new CountdownTimer or call CountdownTimer.reset() before starting.`);this.needsInitialization&&this.initialize(),this.run(e.sequence(this.countdownSequence),`__countdownSequenceAction`),this._isRunning=!0}stop(){this.isRunning&&(this.removeAction(`__countdownSequenceAction`),this._isRunning=!1,this.hasStopped=!0)}reset(){this.stop(),this.initialize()}get isRunning(){return this._isRunning}handleCompositeEvent(e){if(!this.timerNumberLabel)throw new c(`Timer number label not found.`);switch(e.compositeEventType){case`CountdownTimerTick`:this.timerNumberLabel.text=Math.ceil(e.millisecondsRemaining/1e3).toString();break;case`CountdownTimerComplete`:this.timerNumberLabel.text=this.zeroString;break;default:throw new c(`Invalid TimerCountdown event type: ${e.compositeEventType}`)}}onTick(e,t){let n={type:l.Composite,compositeEventType:`CountdownTimerTick`,compositeType:this.compositeType,nodeUuid:this.uuid,callback:e};this.addCountdownTimerEventListener(n,t)}onComplete(e,t){let n={type:l.Composite,compositeEventType:`CountdownTimerComplete`,compositeType:this.compositeType,nodeUuid:this.uuid,callback:e};this.addCountdownTimerEventListener(n,t)}addCountdownTimerEventListener(e,t){t!=null&&t.replaceExisting&&(this.eventListeners=this.eventListeners.filter(t=>!(t.nodeUuid===e.nodeUuid&&t.type===e.type&&t.compositeType===e.compositeType))),this.eventListeners.push(e)}get milliseconds(){return this._milliseconds}set milliseconds(e){i.value(this._milliseconds,e)||(this._milliseconds=e,this.needsInitialization=!0,this.savePropertyChangeEvent(`milliseconds`,e))}get tickIntervalMilliseconds(){return this._tickIntervalMilliseconds}set tickIntervalMilliseconds(e){i.value(this._tickIntervalMilliseconds,e)||(this._tickIntervalMilliseconds=e,this.needsInitialization=!0,this.savePropertyChangeEvent(`tickIntervalMilliseconds`,e))}get fontColor(){return this._fontColor}set fontColor(e){i.value(this._fontColor,e)||(this._fontColor=e,this.needsInitialization=!0,this.savePropertyChangeEvent(`fontColor`,e))}get fontName(){return this._fontName}set fontName(e){this._fontName!==e&&(this._fontName=e,this.needsInitialization=!0,this.savePropertyChangeEvent(`fontName`,e))}get fontSize(){return this._fontSize}set fontSize(e){i.value(this._fontSize,e)||(this._fontSize=e,this.needsInitialization=!0,this.savePropertyChangeEvent(`fontSize`,e))}get zeroString(){return this._zeroString}set zeroString(e){this._zeroString!==e&&(this._zeroString=e,this.needsInitialization=!0,this.savePropertyChangeEvent(`zeroString`,e))}get timerShape(){return this._timerShape}set timerShape(e){i.value(this._timerShape,e)||(this._timerShape=e,this.needsInitialization=!0,this.savePropertyChangeEvent(`timerShape`,e))}get textVerticalBias(){return this._textVerticalBias}set textVerticalBias(e){i.value(this._textVerticalBias,e)||(this._textVerticalBias=e,this.needsInitialization=!0,this.savePropertyChangeEvent(`textVerticalBias`,e))}duplicate(e){throw new c(`Method not implemented. ${e}`)}update(){super.update()}draw(e){super.drawChildren(e)}warmup(e){this.initialize(),this.children.filter(e=>e.isDrawable).forEach(t=>{t.warmup(e)})}};u.registerM2NodeClass(z);var B=class extends t{get thumbShape(){if(this._thumbShape===void 0)throw new c(`thumbShape is not defined.`);return this._thumbShape}set thumbShape(e){this._thumbShape=e}constructor(e){super(e),this.compositeType=`Slider`,this._trackSize={width:250,height:10},this._trackColor=y.Black,this._thumbSize={width:20,height:40},this._thumbColor=y.DarkGray,this._min=0,this._max=100,this._value=(this.max-this.min)/2,this.originalOptions=JSON.parse(JSON.stringify(e)),e.trackSize&&(this.trackSize=e.trackSize),e.trackColor&&(this.trackColor=e.trackColor),e.thumbSize&&(this.thumbSize=e.thumbSize),e.thumbColor&&(this.thumbColor=e.thumbColor),e.min!==void 0&&(this.min=e.min),e.max!==void 0&&(this.max=e.max),e.value!==void 0&&(this.value=e.value),this.saveNodeNewEvent()}get completeNodeOptions(){return T(T(T(T({},this.options),this.getNodeOptions()),this.getDrawableOptions()),this.originalOptions)}initialize(){this.removeAllChildren();let e=new p({rect:{width:this.trackSize.width,height:this.trackSize.height},cornerRadius:8,fillColor:this.trackColor,isPartOfComposite:!0});this.addChild(e),this.thumbShape=new p({rect:{width:this.thumbSize.width,height:this.thumbSize.height},cornerRadius:8,fillColor:this.thumbColor,isUserInteractionEnabled:!0,draggable:!0,zPosition:1,position:{x:this.value*this.trackSize.width/(this.max-this.min)-this.trackSize.width/2,y:0},isPartOfComposite:!0}),e.addChild(this.thumbShape);let t=new p({rect:{width:this.trackSize.width,height:this.thumbSize.height},alpha:0,isUserInteractionEnabled:!0,zPosition:0,isPartOfComposite:!0});e.addChild(t),t.onTapDown(t=>{this.thumbShape.position.x=t.point.x-e.size.width/2,this.updateThumbLabel()});let n=new p({rect:{width:this.trackSize.width,height:this.parentSceneAsNode.size.height*2},alpha:0,isUserInteractionEnabled:!0,isPartOfComposite:!0});this.addChild(n),n.onPointerMove(()=>{this.thumbShape.draggable=!0}),n.onPointerLeave(()=>{this.thumbShape.draggable=!1}),this.thumbShape.onTapDown(e=>{e.handled=!0,e.point.y!==0&&(this.thumbShape.position.y=0),e.point.x<-this.trackSize.width/2&&(this.thumbShape.position.x=-this.trackSize.width/2),e.point.x>this.trackSize.width/2&&(this.thumbShape.position.x=this.trackSize.width/2),this.updateThumbLabel()}),this.thumbShape.onDrag(e=>{e.position.y!==0&&(this.thumbShape.position.y=0),e.position.x<-this.trackSize.width/2&&(this.thumbShape.position.x=-this.trackSize.width/2),e.position.x>this.trackSize.width/2&&(this.thumbShape.position.x=this.trackSize.width/2),this.updateThumbLabel()}),this.thumbShape.onDragEnd(()=>{let e=Math.round((this.thumbShape.position.x+this.trackSize.width/2)/this.trackSize.width*(this.max-this.min));this.thumbShape.position.x=e/(this.max-this.min)*this.trackSize.width-this.trackSize.width/2,this.updateThumbLabel()}),this.needsInitialization=!1}updateThumbLabel(){let e=(this.thumbShape.position.x+this.trackSize.width/2)/this.trackSize.width*(this.max-this.min);this.thumbLabel||(this.thumbLabel=new o({text:e.toString(),isPartOfComposite:!0}),this.addChild(this.thumbLabel)),this.thumbLabel.text=Math.round(e).toString(),this.thumbLabel.position={x:this.thumbShape.position.x,y:this.thumbShape.position.y-30},this.thumbLabel&&(this.thumbLabel.position={x:this.thumbShape.position.x,y:this.thumbShape.position.y-30});let t=T({type:l.Composite,compositeType:`Slider`,compositeEventType:`SliderValueChanged`,target:this,value:e},u.createTimestamps());this.handleCompositeEvent(t),this.saveEvent(t),this.eventListeners.length>0&&this.eventListeners.filter(e=>e.type===l.Composite&&e.compositeType===this.compositeType&&e.compositeEventType===`SliderValueChanged`).forEach(e=>{e.callback(t)})}onValueChanged(e,t){let n={type:l.Composite,compositeEventType:`SliderValueChanged`,compositeType:this.compositeType,nodeUuid:this.uuid,callback:e};this.addSliderEventListener(n,t)}addSliderEventListener(e,t){t!=null&&t.replaceExisting&&(this.eventListeners=this.eventListeners.filter(t=>!(t.nodeUuid===e.nodeUuid&&t.type===e.type&&t.compositeType===e.compositeType))),this.eventListeners.push(e)}get trackSize(){return this._trackSize}set trackSize(e){this._trackSize=e}get trackColor(){return this._trackColor}set trackColor(e){this._trackColor=e}get thumbSize(){return this._thumbSize}set thumbSize(e){this._thumbSize=e}get thumbColor(){return this._thumbColor}set thumbColor(e){this._thumbColor=e}get value(){return this._value}set value(e){this._value=e}get min(){return this._min}set min(e){this._min=e}get max(){return this._max}set max(e){this._max=e}duplicate(e){throw new c(`Method not implemented. ${e}`)}update(){super.update()}draw(e){super.drawChildren(e)}warmup(e){this.initialize(),this.children.filter(e=>e.isDrawable).forEach(t=>{t.warmup(e)})}};console.log(`⚪ @m2c2kit/addons version 0.3.36 (35887002)`);export{D as Button,L as CountdownScene,z as CountdownTimer,k as Dialog,O as DialogResult,M as DrawPad,A as DrawPadEventType,j as DrawPadItemEventType,E as Grid,F as Instructions,R as LocalePicker,B as Slider,N as VirtualKeyboard};