@ray-js/robot-map-sdk 0.0.13 → 0.0.14-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.rjs.js +1 -1
  3. package/dist-app/assets/{index-BzBtiwcY.js → index-D5NfGFNi.js} +1 -1
  4. package/dist-app/index.html +1 -1
  5. package/dist-docs/404.html +2 -2
  6. package/dist-docs/assets/{app.CoDGIQ53.js → app.BvEA7OUD.js} +1 -1
  7. package/dist-docs/assets/chunks/@localSearchIndexroot.DgSSKtBp.js +1 -0
  8. package/dist-docs/assets/chunks/{BitmapFont.DDRqV796.js → BitmapFont.ZlRh5xJO.js} +1 -1
  9. package/dist-docs/assets/chunks/{BufferResource.aFEHKM_N.js → BufferResource.CdcMCLiG.js} +1 -1
  10. package/dist-docs/assets/chunks/{CanvasRenderer.BefGXFZ-.js → CanvasRenderer.BG9dkLJp.js} +1 -1
  11. package/dist-docs/assets/chunks/{RenderTargetSystem.CsgIm493.js → RenderTargetSystem.DhOKhSsc.js} +1 -1
  12. package/dist-docs/assets/chunks/{VPLocalSearchBox.CVEAMjKj.js → VPLocalSearchBox.DceyzShG.js} +1 -1
  13. package/dist-docs/assets/chunks/{WebGLRenderer.p4DxJ1iF.js → WebGLRenderer.DuuxSWTv.js} +1 -1
  14. package/dist-docs/assets/chunks/{WebGPURenderer.BhOx1ll0.js → WebGPURenderer.CgbaDBMF.js} +1 -1
  15. package/dist-docs/assets/chunks/{browserAll.CXRAifqY.js → browserAll.BDysYc3x.js} +1 -1
  16. package/dist-docs/assets/chunks/{index.Dmmvsq5C.js → index.Bt4MWbdd.js} +5 -5
  17. package/dist-docs/assets/chunks/{theme.Cii0G4Y-.js → theme.CjTS9gFB.js} +3 -3
  18. package/dist-docs/assets/chunks/{webworkerAll.CY0RXZhY.js → webworkerAll.0Br3PwIr.js} +1 -1
  19. package/dist-docs/assets/{guide_getting-started.md.9hcfOAq4.js → guide_getting-started.md.DjSa-UXA.js} +2 -2
  20. package/dist-docs/assets/guide_getting-started.md.DjSa-UXA.lean.js +1 -0
  21. package/dist-docs/assets/{reference_config.md.DHynhVxG.js → reference_config.md.DJFVf513.js} +3 -3
  22. package/dist-docs/assets/{reference_config.md.DHynhVxG.lean.js → reference_config.md.DJFVf513.lean.js} +1 -1
  23. package/dist-docs/guide/advanced-usage.html +3 -3
  24. package/dist-docs/guide/concepts.html +3 -3
  25. package/dist-docs/guide/getting-started.html +5 -5
  26. package/dist-docs/guide/mcp.html +3 -3
  27. package/dist-docs/hashmap.json +1 -1
  28. package/dist-docs/index.html +3 -3
  29. package/dist-docs/plans/2026-03-04-detected-objects-visibility-design.html +3 -3
  30. package/dist-docs/plans/2026-03-04-show-detected-objects-implementation-plan.html +3 -3
  31. package/dist-docs/plans/2026-03-10-simulator-debug-design.html +3 -3
  32. package/dist-docs/plans/2026-03-10-simulator-events-console-design.html +3 -3
  33. package/dist-docs/plans/2026-03-10-simulator-events-console-implementation-plan.html +3 -3
  34. package/dist-docs/plans/2026-03-10-simulator-runtime-controls-design.html +3 -3
  35. package/dist-docs/plans/2026-03-10-simulator-runtime-controls-implementation-plan.html +3 -3
  36. package/dist-docs/plans/2026-03-11-simulator-logger-dump-implementation-plan.html +3 -3
  37. package/dist-docs/records/bugs/2026-02-28-fix-pixi-bindgroup-webgpu-snapshot-whitescreen-bugfix.html +3 -3
  38. package/dist-docs/records/bugs/2026-03-10-events-drawer-toolbar-scroll-bugfix.html +3 -3
  39. package/dist-docs/records/bugs/2026-03-10-simulator-initial-render-layout-bugfix.html +3 -3
  40. package/dist-docs/records/bugs/2026-03-10-simulator-wheel-scroll-leak-bugfix.html +3 -3
  41. package/dist-docs/records/bugs/2026-03-11-docs-server-bin-clean-bugfix.html +3 -3
  42. package/dist-docs/records/bugs/2026-03-11-render-result-runtime-sync-bugfix.html +3 -3
  43. package/dist-docs/records/plans/2026-03-02-furniture-feature-plan.html +3 -3
  44. package/dist-docs/records/plans/2026-03-10-simulator-events-console-plan.html +3 -3
  45. package/dist-docs/records/plans/2026-03-10-simulator-last-successful-combo-cache-plan.html +3 -3
  46. package/dist-docs/records/plans/2026-03-10-simulator-map-parsed-view-plan.html +3 -3
  47. package/dist-docs/records/plans/2026-03-10-simulator-map-playground-refactor-plan.html +3 -3
  48. package/dist-docs/records/plans/2026-03-10-simulator-playground-plan.html +3 -3
  49. package/dist-docs/records/plans/2026-03-10-simulator-runtime-controls-plan.html +3 -3
  50. package/dist-docs/records/plans/2026-03-11-docs-cli-ui-polish-plan.html +3 -3
  51. package/dist-docs/records/plans/2026-03-11-simulator-logger-dump-plan.html +3 -3
  52. package/dist-docs/records/plans/2026-03-11-simulator-src-migration-implementation.html +3 -3
  53. package/dist-docs/records/plans/2026-03-11-simulator-src-migration-plan.html +3 -3
  54. package/dist-docs/records/plans/2026-03-11-simulator-style-tokenization-plan.html +3 -3
  55. package/dist-docs/reference/callbacks.html +3 -3
  56. package/dist-docs/reference/config.html +6 -6
  57. package/dist-docs/reference/data.html +3 -3
  58. package/dist-docs/reference/methods.html +3 -3
  59. package/dist-docs/reference/runtime.html +3 -3
  60. package/dist-docs/reference/types.html +3 -3
  61. package/dist-docs/reference/utils.html +3 -3
  62. package/dist-docs/simulator/index.html +3 -3
  63. package/package.json +1 -1
  64. package/dist-docs/assets/chunks/@localSearchIndexroot.DELY0TLT.js +0 -1
  65. package/dist-docs/assets/guide_getting-started.md.9hcfOAq4.lean.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chunks/browserAll.CXRAifqY.js","assets/chunks/webworkerAll.CY0RXZhY.js","assets/chunks/framework.CBLqO2Q1.js","assets/chunks/mapValues.D2X8cRgC.js","assets/chunks/theme.Cii0G4Y-.js","assets/chunks/WebGPURenderer.BhOx1ll0.js","assets/chunks/BufferResource.aFEHKM_N.js","assets/chunks/RenderTargetSystem.CsgIm493.js","assets/chunks/WebGLRenderer.p4DxJ1iF.js","assets/chunks/CanvasRenderer.BefGXFZ-.js","assets/chunks/BitmapFont.DDRqV796.js"])))=>i.map(i=>d[i]);
2
- var Ac=Object.defineProperty;var Cc=(r,t,e)=>t in r?Ac(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var g=(r,t,e)=>Cc(r,typeof t!="symbol"?t+"":t,e);import{V as _e}from"./framework.CBLqO2Q1.js";import{L as qa,u as Ka,m as $a,G as Pc,E as Mc,d as Re,y as _c,Q as Tc,v as Qa,H as kc,R as Rc,T as Ec,i as or,U as Ja,V as Ic,W as Bc,I as Dc,X as Fc,K as Yr,Y as zc,e as Lc,w as Oc,l as _n,f as Gc,a as Wc,x as Xr,Z as Uc,h as Hc,_ as Vc,j as Nc,$ as th,a0 as jc,a1 as Yc,C as Xc,a2 as Zc,N as Tn,O as qc,P as Kc,M as Zr}from"./mapValues.D2X8cRgC.js";import{N as oe,H as $c,a as Qc}from"./theme.Cii0G4Y-.js";var E=(r=>(r.Application="application",r.WebGLPipes="webgl-pipes",r.WebGLPipesAdaptor="webgl-pipes-adaptor",r.WebGLSystem="webgl-system",r.WebGPUPipes="webgpu-pipes",r.WebGPUPipesAdaptor="webgpu-pipes-adaptor",r.WebGPUSystem="webgpu-system",r.CanvasSystem="canvas-system",r.CanvasPipesAdaptor="canvas-pipes-adaptor",r.CanvasPipes="canvas-pipes",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r.MaskEffect="mask-effect",r.BlendMode="blend-mode",r.TextureSource="texture-source",r.Environment="environment",r.ShapeBuilder="shape-builder",r.Batcher="batcher",r))(E||{});const kn=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){if(!r.extension)throw new Error("Extension class must have an extension object");r={...typeof r.extension!="object"?{type:r.extension}:r.extension,ref:r}}if(typeof r=="object")r={...r};else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},ji=(r,t)=>kn(r).priority??t,$={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(kn).forEach(t=>{t.type.forEach(e=>{var i,s;return(s=(i=this._removeHandlers)[e])==null?void 0:s.call(i,t)})}),this},add(...r){return r.map(kn).forEach(t=>{t.type.forEach(e=>{var n,o;const i=this._addHandlers,s=this._queue;i[e]?(o=i[e])==null||o.call(i,t):(s[e]=s[e]||[],(n=s[e])==null||n.push(t))})}),this},handle(r,t,e){var o;const i=this._addHandlers,s=this._removeHandlers;if(i[r]||s[r])throw new Error(`Extension type ${r} already has a handler`);i[r]=t,s[r]=e;const n=this._queue;return n[r]&&((o=n[r])==null||o.forEach(a=>t(a)),delete n[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(r,t,e=-1){return this.handle(r,i=>{t.findIndex(n=>n.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((n,o)=>ji(o.value,e)-ji(n.value,e)))},i=>{const s=t.findIndex(n=>n.name===i.name);s!==-1&&t.splice(s,1)})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((s,n)=>ji(n,e)-ji(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})},mixin(r,...t){for(const e of t)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(e))}},Jc={extension:{type:E.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await _e(()=>import("./browserAll.CXRAifqY.js"),__vite__mapDeps([0,1,2,3,4]))}},td={extension:{type:E.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await _e(()=>import("./webworkerAll.CY0RXZhY.js"),__vite__mapDeps([1,2,3,4]))}};class ct{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new ct(t??this._observer,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}var eh={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function n(h,l,c,d,u){if(typeof c!="function")throw new TypeError("The listener must be a function");var p=new s(c,d||h,u),f=e?e+l:l;return h._events[f]?h._events[f].fn?h._events[f]=[h._events[f],p]:h._events[f].push(p):(h._events[f]=p,h._eventsCount++),h}function o(h,l){--h._eventsCount===0?h._events=new i:delete h._events[l]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],c,d;if(this._eventsCount===0)return l;for(d in c=this._events)t.call(c,d)&&l.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},a.prototype.listeners=function(l){var c=e?e+l:l,d=this._events[c];if(!d)return[];if(d.fn)return[d.fn];for(var u=0,p=d.length,f=new Array(p);u<p;u++)f[u]=d[u].fn;return f},a.prototype.listenerCount=function(l){var c=e?e+l:l,d=this._events[c];return d?d.fn?1:d.length:0},a.prototype.emit=function(l,c,d,u,p,f){var y=e?e+l:l;if(!this._events[y])return!1;var m=this._events[y],x=arguments.length,S,v;if(m.fn){switch(m.once&&this.removeListener(l,m.fn,void 0,!0),x){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,c),!0;case 3:return m.fn.call(m.context,c,d),!0;case 4:return m.fn.call(m.context,c,d,u),!0;case 5:return m.fn.call(m.context,c,d,u,p),!0;case 6:return m.fn.call(m.context,c,d,u,p,f),!0}for(v=1,S=new Array(x-1);v<x;v++)S[v-1]=arguments[v];m.fn.apply(m.context,S)}else{var b=m.length,P;for(v=0;v<b;v++)switch(m[v].once&&this.removeListener(l,m[v].fn,void 0,!0),x){case 1:m[v].fn.call(m[v].context);break;case 2:m[v].fn.call(m[v].context,c);break;case 3:m[v].fn.call(m[v].context,c,d);break;case 4:m[v].fn.call(m[v].context,c,d,u);break;default:if(!S)for(P=1,S=new Array(x-1);P<x;P++)S[P-1]=arguments[P];m[v].fn.apply(m[v].context,S)}}return!0},a.prototype.on=function(l,c,d){return n(this,l,c,d,!1)},a.prototype.once=function(l,c,d){return n(this,l,c,d,!0)},a.prototype.removeListener=function(l,c,d,u){var p=e?e+l:l;if(!this._events[p])return this;if(!c)return o(this,p),this;var f=this._events[p];if(f.fn)f.fn===c&&(!u||f.once)&&(!d||f.context===d)&&o(this,p);else{for(var y=0,m=[],x=f.length;y<x;y++)(f[y].fn!==c||u&&!f[y].once||d&&f[y].context!==d)&&m.push(f[y]);m.length?this._events[p]=m.length===1?m[0]:m:o(this,p)}return this},a.prototype.removeAllListeners=function(l){var c;return l?(c=e?e+l:l,this._events[c]&&o(this,c)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(eh);var ed=eh.exports;const Yt=qa(ed),id=Math.PI*2,sd=180/Math.PI,nd=Math.PI/180;class tt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new tt(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Us.x=0,Us.y=0,Us}}const Us=new tt;class W{constructor(t=1,e=0,i=0,s=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,s,n,o){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new tt;const i=t.x,s=t.y;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||new tt;const i=this.a,s=this.b,n=this.c,o=this.d,a=this.tx,h=this.ty,l=1/(i*o+n*-s),c=t.x,d=t.y;return e.x=o*l*c+-n*l*d+(h*n-a*o)*l,e.y=i*l*d+-s*l*c+(-h*i+a*s)*l,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,o=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}appendFrom(t,e){const i=t.a,s=t.b,n=t.c,o=t.d,a=t.tx,h=t.ty,l=e.a,c=e.b,d=e.c,u=e.d;return this.a=i*l+s*d,this.b=i*c+s*u,this.c=n*l+o*d,this.d=n*c+o*u,this.tx=a*l+h*d+e.tx,this.ty=a*c+h*u+e.ty,this}setTransform(t,e,i,s,n,o,a,h,l){return this.a=Math.cos(a+l)*n,this.b=Math.sin(a+l)*n,this.c=-Math.sin(a-h)*o,this.d=Math.cos(a-h)*o,this.tx=t-(i*this.a+s*this.c),this.ty=e-(i*this.b+s*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,s=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=s*t.a+this.d*t.c,this.d=s*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,s=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-s,n),h=Math.atan2(i,e),l=Math.abs(a+h);return l<1e-5||Math.abs(id-l)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=h),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(o.x*e+o.y*s),t.position.y=this.ty+(o.x*i+o.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,s=this.d,n=this.tx,o=t*s-e*i;return this.a=s/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-s*n)/o,this.ty=-(t*this.ty-e*n)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new W;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}equals(t){return t.a===this.a&&t.b===this.b&&t.c===this.c&&t.d===this.d&&t.tx===this.tx&&t.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return od.identity()}static get shared(){return rd.identity()}}const rd=new W,od=new W,ve=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],be=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],we=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Ae=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Rn=[],ih=[],Yi=Math.sign;function ad(){for(let r=0;r<16;r++){const t=[];Rn.push(t);for(let e=0;e<16;e++){const i=Yi(ve[r]*ve[e]+we[r]*be[e]),s=Yi(be[r]*ve[e]+Ae[r]*be[e]),n=Yi(ve[r]*we[e]+we[r]*Ae[e]),o=Yi(be[r]*we[e]+Ae[r]*Ae[e]);for(let a=0;a<16;a++)if(ve[a]===i&&be[a]===s&&we[a]===n&&Ae[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new W;t.set(ve[r],be[r],we[r],Ae[r],0,0),ih.push(t)}}ad();const X={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>ve[r],uY:r=>be[r],vX:r=>we[r],vY:r=>Ae[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Rn[r][t],sub:(r,t)=>Rn[r][X.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?X.S:X.N:Math.abs(t)*2<=Math.abs(r)?r>0?X.E:X.W:t>0?r>0?X.SE:X.SW:r>0?X.NE:X.NW,matrixAppendRotationInv:(r,t,e=0,i=0,s=0,n=0)=>{const o=ih[X.inv(t)],a=o.a,h=o.b,l=o.c,c=o.d,d=e-Math.min(0,a*s,l*n,a*s+l*n),u=i-Math.min(0,h*s,c*n,h*s+c*n),p=r.a,f=r.b,y=r.c,m=r.d;r.a=a*p+h*y,r.b=a*f+h*m,r.c=l*p+c*y,r.d=l*f+c*m,r.tx=d*p+u*y+r.tx,r.ty=d*f+u*m+r.ty},transformRectCoords:(r,t,e,i)=>{const{x:s,y:n,width:o,height:a}=r,{x:h,y:l,width:c,height:d}=t;return e===X.E?(i.set(s+h,n+l,o,a),i):e===X.S?i.set(c-n-a+h,s+l,a,o):e===X.W?i.set(c-s-o+h,d-n-a+l,o,a):e===X.N?i.set(n+h,d-s-o+l,a,o):i.set(s+h,n+l,o,a)}},Xi=[new tt,new tt,new tt,new tt];class et{constructor(t=0,e=0,i=0,s=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new et(0,0,0,0)}clone(){return new et(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,i,s=.5){const{width:n,height:o}=this;if(n<=0||o<=0)return!1;const a=this.x,h=this.y,l=i*(1-s),c=i-l,d=a-l,u=a+n+l,p=h-l,f=h+o+l,y=a+c,m=a+n-c,x=h+c,S=h+o-c;return t>=d&&t<=u&&e>=p&&e<=f&&!(t>y&&t<m&&e>x&&e<S)}intersects(t,e){if(!e){const k=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=k)return!1;const T=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>T}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=Xi[0].set(t.left,t.top),h=Xi[1].set(t.left,t.bottom),l=Xi[2].set(t.right,t.top),c=Xi[3].set(t.right,t.bottom);if(l.x<=a.x||h.y<=a.y)return!1;const d=Math.sign(e.a*e.d-e.b*e.c);if(d===0||(e.apply(a,a),e.apply(h,h),e.apply(l,l),e.apply(c,c),Math.max(a.x,h.x,l.x,c.x)<=i||Math.min(a.x,h.x,l.x,c.x)>=s||Math.max(a.y,h.y,l.y,c.y)<=n||Math.min(a.y,h.y,l.y,c.y)>=o))return!1;const u=d*(h.y-a.y),p=d*(a.x-h.x),f=u*i+p*n,y=u*s+p*n,m=u*i+p*o,x=u*s+p*o;if(Math.max(f,y,m,x)<=u*a.x+p*a.y||Math.min(f,y,m,x)>=u*c.x+p*c.y)return!1;const S=d*(a.y-l.y),v=d*(l.x-a.x),b=S*i+v*n,P=S*s+v*n,w=S*i+v*o,C=S*s+v*o;return!(Math.max(b,P,w,C)<=S*a.x+v*a.y||Math.min(b,P,w,C)>=S*c.x+v*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),s=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,s=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=s-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),s=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=s,this.height=n-s,this}getBounds(t){return t||(t=new et),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,i=t.y,s=t.x+t.width,n=t.y+t.height;return e>=this.x&&e<this.x+this.width&&i>=this.y&&i<this.y+this.height&&s>=this.x&&s<this.x+this.width&&n>=this.y&&n<this.y+this.height}set(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Hs={default:-1};function dt(r="default"){return Hs[r]===void 0&&(Hs[r]=-1),++Hs[r]}const qr=new Set,J="8.0.0",hd="8.3.4",He={quiet:!1,noColor:!1},V=(r,t,e=3)=>{if(He.quiet||qr.has(t))return;let i=new Error().stack;const s=`${t}
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chunks/browserAll.BDysYc3x.js","assets/chunks/webworkerAll.0Br3PwIr.js","assets/chunks/framework.CBLqO2Q1.js","assets/chunks/mapValues.D2X8cRgC.js","assets/chunks/theme.CjTS9gFB.js","assets/chunks/WebGPURenderer.CgbaDBMF.js","assets/chunks/BufferResource.CdcMCLiG.js","assets/chunks/RenderTargetSystem.DhOKhSsc.js","assets/chunks/WebGLRenderer.DuuxSWTv.js","assets/chunks/CanvasRenderer.BG9dkLJp.js","assets/chunks/BitmapFont.ZlRh5xJO.js"])))=>i.map(i=>d[i]);
2
+ var Ac=Object.defineProperty;var Cc=(r,t,e)=>t in r?Ac(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var g=(r,t,e)=>Cc(r,typeof t!="symbol"?t+"":t,e);import{V as _e}from"./framework.CBLqO2Q1.js";import{L as qa,u as Ka,m as $a,G as Pc,E as Mc,d as Re,y as _c,Q as Tc,v as Qa,H as kc,R as Rc,T as Ec,i as or,U as Ja,V as Ic,W as Bc,I as Dc,X as Fc,K as Yr,Y as zc,e as Lc,w as Oc,l as _n,f as Gc,a as Wc,x as Xr,Z as Uc,h as Hc,_ as Vc,j as Nc,$ as th,a0 as jc,a1 as Yc,C as Xc,a2 as Zc,N as Tn,O as qc,P as Kc,M as Zr}from"./mapValues.D2X8cRgC.js";import{N as oe,H as $c,a as Qc}from"./theme.CjTS9gFB.js";var E=(r=>(r.Application="application",r.WebGLPipes="webgl-pipes",r.WebGLPipesAdaptor="webgl-pipes-adaptor",r.WebGLSystem="webgl-system",r.WebGPUPipes="webgpu-pipes",r.WebGPUPipesAdaptor="webgpu-pipes-adaptor",r.WebGPUSystem="webgpu-system",r.CanvasSystem="canvas-system",r.CanvasPipesAdaptor="canvas-pipes-adaptor",r.CanvasPipes="canvas-pipes",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r.MaskEffect="mask-effect",r.BlendMode="blend-mode",r.TextureSource="texture-source",r.Environment="environment",r.ShapeBuilder="shape-builder",r.Batcher="batcher",r))(E||{});const kn=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){if(!r.extension)throw new Error("Extension class must have an extension object");r={...typeof r.extension!="object"?{type:r.extension}:r.extension,ref:r}}if(typeof r=="object")r={...r};else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},ji=(r,t)=>kn(r).priority??t,$={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(kn).forEach(t=>{t.type.forEach(e=>{var i,s;return(s=(i=this._removeHandlers)[e])==null?void 0:s.call(i,t)})}),this},add(...r){return r.map(kn).forEach(t=>{t.type.forEach(e=>{var n,o;const i=this._addHandlers,s=this._queue;i[e]?(o=i[e])==null||o.call(i,t):(s[e]=s[e]||[],(n=s[e])==null||n.push(t))})}),this},handle(r,t,e){var o;const i=this._addHandlers,s=this._removeHandlers;if(i[r]||s[r])throw new Error(`Extension type ${r} already has a handler`);i[r]=t,s[r]=e;const n=this._queue;return n[r]&&((o=n[r])==null||o.forEach(a=>t(a)),delete n[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(r,t,e=-1){return this.handle(r,i=>{t.findIndex(n=>n.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((n,o)=>ji(o.value,e)-ji(n.value,e)))},i=>{const s=t.findIndex(n=>n.name===i.name);s!==-1&&t.splice(s,1)})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((s,n)=>ji(n,e)-ji(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})},mixin(r,...t){for(const e of t)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(e))}},Jc={extension:{type:E.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await _e(()=>import("./browserAll.BDysYc3x.js"),__vite__mapDeps([0,1,2,3,4]))}},td={extension:{type:E.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await _e(()=>import("./webworkerAll.0Br3PwIr.js"),__vite__mapDeps([1,2,3,4]))}};class ct{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new ct(t??this._observer,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}var eh={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function n(h,l,c,d,u){if(typeof c!="function")throw new TypeError("The listener must be a function");var p=new s(c,d||h,u),f=e?e+l:l;return h._events[f]?h._events[f].fn?h._events[f]=[h._events[f],p]:h._events[f].push(p):(h._events[f]=p,h._eventsCount++),h}function o(h,l){--h._eventsCount===0?h._events=new i:delete h._events[l]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],c,d;if(this._eventsCount===0)return l;for(d in c=this._events)t.call(c,d)&&l.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},a.prototype.listeners=function(l){var c=e?e+l:l,d=this._events[c];if(!d)return[];if(d.fn)return[d.fn];for(var u=0,p=d.length,f=new Array(p);u<p;u++)f[u]=d[u].fn;return f},a.prototype.listenerCount=function(l){var c=e?e+l:l,d=this._events[c];return d?d.fn?1:d.length:0},a.prototype.emit=function(l,c,d,u,p,f){var y=e?e+l:l;if(!this._events[y])return!1;var m=this._events[y],x=arguments.length,S,v;if(m.fn){switch(m.once&&this.removeListener(l,m.fn,void 0,!0),x){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,c),!0;case 3:return m.fn.call(m.context,c,d),!0;case 4:return m.fn.call(m.context,c,d,u),!0;case 5:return m.fn.call(m.context,c,d,u,p),!0;case 6:return m.fn.call(m.context,c,d,u,p,f),!0}for(v=1,S=new Array(x-1);v<x;v++)S[v-1]=arguments[v];m.fn.apply(m.context,S)}else{var b=m.length,P;for(v=0;v<b;v++)switch(m[v].once&&this.removeListener(l,m[v].fn,void 0,!0),x){case 1:m[v].fn.call(m[v].context);break;case 2:m[v].fn.call(m[v].context,c);break;case 3:m[v].fn.call(m[v].context,c,d);break;case 4:m[v].fn.call(m[v].context,c,d,u);break;default:if(!S)for(P=1,S=new Array(x-1);P<x;P++)S[P-1]=arguments[P];m[v].fn.apply(m[v].context,S)}}return!0},a.prototype.on=function(l,c,d){return n(this,l,c,d,!1)},a.prototype.once=function(l,c,d){return n(this,l,c,d,!0)},a.prototype.removeListener=function(l,c,d,u){var p=e?e+l:l;if(!this._events[p])return this;if(!c)return o(this,p),this;var f=this._events[p];if(f.fn)f.fn===c&&(!u||f.once)&&(!d||f.context===d)&&o(this,p);else{for(var y=0,m=[],x=f.length;y<x;y++)(f[y].fn!==c||u&&!f[y].once||d&&f[y].context!==d)&&m.push(f[y]);m.length?this._events[p]=m.length===1?m[0]:m:o(this,p)}return this},a.prototype.removeAllListeners=function(l){var c;return l?(c=e?e+l:l,this._events[c]&&o(this,c)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(eh);var ed=eh.exports;const Yt=qa(ed),id=Math.PI*2,sd=180/Math.PI,nd=Math.PI/180;class tt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new tt(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Us.x=0,Us.y=0,Us}}const Us=new tt;class W{constructor(t=1,e=0,i=0,s=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,s,n,o){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new tt;const i=t.x,s=t.y;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||new tt;const i=this.a,s=this.b,n=this.c,o=this.d,a=this.tx,h=this.ty,l=1/(i*o+n*-s),c=t.x,d=t.y;return e.x=o*l*c+-n*l*d+(h*n-a*o)*l,e.y=i*l*d+-s*l*c+(-h*i+a*s)*l,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,o=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}appendFrom(t,e){const i=t.a,s=t.b,n=t.c,o=t.d,a=t.tx,h=t.ty,l=e.a,c=e.b,d=e.c,u=e.d;return this.a=i*l+s*d,this.b=i*c+s*u,this.c=n*l+o*d,this.d=n*c+o*u,this.tx=a*l+h*d+e.tx,this.ty=a*c+h*u+e.ty,this}setTransform(t,e,i,s,n,o,a,h,l){return this.a=Math.cos(a+l)*n,this.b=Math.sin(a+l)*n,this.c=-Math.sin(a-h)*o,this.d=Math.cos(a-h)*o,this.tx=t-(i*this.a+s*this.c),this.ty=e-(i*this.b+s*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,s=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=s*t.a+this.d*t.c,this.d=s*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,s=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-s,n),h=Math.atan2(i,e),l=Math.abs(a+h);return l<1e-5||Math.abs(id-l)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=h),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(o.x*e+o.y*s),t.position.y=this.ty+(o.x*i+o.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,s=this.d,n=this.tx,o=t*s-e*i;return this.a=s/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-s*n)/o,this.ty=-(t*this.ty-e*n)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new W;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}equals(t){return t.a===this.a&&t.b===this.b&&t.c===this.c&&t.d===this.d&&t.tx===this.tx&&t.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return od.identity()}static get shared(){return rd.identity()}}const rd=new W,od=new W,ve=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],be=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],we=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Ae=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Rn=[],ih=[],Yi=Math.sign;function ad(){for(let r=0;r<16;r++){const t=[];Rn.push(t);for(let e=0;e<16;e++){const i=Yi(ve[r]*ve[e]+we[r]*be[e]),s=Yi(be[r]*ve[e]+Ae[r]*be[e]),n=Yi(ve[r]*we[e]+we[r]*Ae[e]),o=Yi(be[r]*we[e]+Ae[r]*Ae[e]);for(let a=0;a<16;a++)if(ve[a]===i&&be[a]===s&&we[a]===n&&Ae[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new W;t.set(ve[r],be[r],we[r],Ae[r],0,0),ih.push(t)}}ad();const X={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>ve[r],uY:r=>be[r],vX:r=>we[r],vY:r=>Ae[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Rn[r][t],sub:(r,t)=>Rn[r][X.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?X.S:X.N:Math.abs(t)*2<=Math.abs(r)?r>0?X.E:X.W:t>0?r>0?X.SE:X.SW:r>0?X.NE:X.NW,matrixAppendRotationInv:(r,t,e=0,i=0,s=0,n=0)=>{const o=ih[X.inv(t)],a=o.a,h=o.b,l=o.c,c=o.d,d=e-Math.min(0,a*s,l*n,a*s+l*n),u=i-Math.min(0,h*s,c*n,h*s+c*n),p=r.a,f=r.b,y=r.c,m=r.d;r.a=a*p+h*y,r.b=a*f+h*m,r.c=l*p+c*y,r.d=l*f+c*m,r.tx=d*p+u*y+r.tx,r.ty=d*f+u*m+r.ty},transformRectCoords:(r,t,e,i)=>{const{x:s,y:n,width:o,height:a}=r,{x:h,y:l,width:c,height:d}=t;return e===X.E?(i.set(s+h,n+l,o,a),i):e===X.S?i.set(c-n-a+h,s+l,a,o):e===X.W?i.set(c-s-o+h,d-n-a+l,o,a):e===X.N?i.set(n+h,d-s-o+l,a,o):i.set(s+h,n+l,o,a)}},Xi=[new tt,new tt,new tt,new tt];class et{constructor(t=0,e=0,i=0,s=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new et(0,0,0,0)}clone(){return new et(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,i,s=.5){const{width:n,height:o}=this;if(n<=0||o<=0)return!1;const a=this.x,h=this.y,l=i*(1-s),c=i-l,d=a-l,u=a+n+l,p=h-l,f=h+o+l,y=a+c,m=a+n-c,x=h+c,S=h+o-c;return t>=d&&t<=u&&e>=p&&e<=f&&!(t>y&&t<m&&e>x&&e<S)}intersects(t,e){if(!e){const k=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=k)return!1;const T=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>T}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=Xi[0].set(t.left,t.top),h=Xi[1].set(t.left,t.bottom),l=Xi[2].set(t.right,t.top),c=Xi[3].set(t.right,t.bottom);if(l.x<=a.x||h.y<=a.y)return!1;const d=Math.sign(e.a*e.d-e.b*e.c);if(d===0||(e.apply(a,a),e.apply(h,h),e.apply(l,l),e.apply(c,c),Math.max(a.x,h.x,l.x,c.x)<=i||Math.min(a.x,h.x,l.x,c.x)>=s||Math.max(a.y,h.y,l.y,c.y)<=n||Math.min(a.y,h.y,l.y,c.y)>=o))return!1;const u=d*(h.y-a.y),p=d*(a.x-h.x),f=u*i+p*n,y=u*s+p*n,m=u*i+p*o,x=u*s+p*o;if(Math.max(f,y,m,x)<=u*a.x+p*a.y||Math.min(f,y,m,x)>=u*c.x+p*c.y)return!1;const S=d*(a.y-l.y),v=d*(l.x-a.x),b=S*i+v*n,P=S*s+v*n,w=S*i+v*o,C=S*s+v*o;return!(Math.max(b,P,w,C)<=S*a.x+v*a.y||Math.min(b,P,w,C)>=S*c.x+v*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),s=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,s=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=s-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),s=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=s,this.height=n-s,this}getBounds(t){return t||(t=new et),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,i=t.y,s=t.x+t.width,n=t.y+t.height;return e>=this.x&&e<this.x+this.width&&i>=this.y&&i<this.y+this.height&&s>=this.x&&s<this.x+this.width&&n>=this.y&&n<this.y+this.height}set(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Hs={default:-1};function dt(r="default"){return Hs[r]===void 0&&(Hs[r]=-1),++Hs[r]}const qr=new Set,J="8.0.0",hd="8.3.4",He={quiet:!1,noColor:!1},V=(r,t,e=3)=>{if(He.quiet||qr.has(t))return;let i=new Error().stack;const s=`${t}
3
3
  Deprecated since v${r}`,n=typeof console.groupCollapsed=="function"&&!He.noColor;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",s):(i=i.split(`
4
4
  `).splice(e).join(`
5
5
  `),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",s),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",s),console.warn(i))),qr.add(t)};Object.defineProperties(V,{quiet:{get:()=>He.quiet,set:r=>{He.quiet=r},enumerable:!0,configurable:!1},noColor:{get:()=>He.noColor,set:r=>{He.noColor=r},enumerable:!0,configurable:!1}});const sh=()=>{};function qe(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function Kr(r){return!(r&r-1)&&!!r}function nh(r){const t={};for(const e in r)r[e]!==void 0&&(t[e]=r[e]);return t}const $r=Object.create(null);function ld(r){const t=$r[r];return t===void 0&&($r[r]=dt("resource")),t}const rh=class oh extends Yt{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...oh.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){V(J,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit("change",this)}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=ld(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};rh.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Ke=rh;const ah=class hh extends Yt{constructor(t={}){super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=dt("textureSource"),this._resourceType="textureSource",this._resourceId=dt("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.viewDimension="2d",this.arrayLayerCount=1,this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...hh.defaultOptions,...t},this.label=t.label??"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.viewDimension=t.viewDimension??t.dimensions,this.arrayLayerCount=t.arrayLayerCount,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new Ke(nh(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){var t,e;this._resourceId=dt("resource"),this.emit("change",this),this.emit("unload",this);for(const i in this._gpuData)(e=(t=this._gpuData[i])==null?void 0:t.destroy)==null||e.call(t);this._gpuData=Object.create(null)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){i||(i=this._resolution),t||(t=this.width),e||(e=this.height);const s=Math.round(t*i),n=Math.round(e*i);return this.width=s/i,this.height=n/i,this._resolution=i,this.pixelWidth===s&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=s,this.pixelHeight=n,this.emit("resize",this),this._resourceId=dt("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=Kr(this.pixelWidth)&&Kr(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};ah.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",viewDimension:"2d",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Bt=ah;class ar extends Bt{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(e instanceof Int8Array,i="bgra8unorm")),super({...t,resource:e,format:i}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}ar.extension=E.TextureSource;const Qr=new W;class cd{constructor(t,e){this.mapCoord=new W,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let s=0;s<t.length;s+=2){const n=t[s],o=t[s+1];e[s]=n*i.a+o*i.c+i.tx,e[s+1]=n*i.b+o*i.d+i.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const i=t.orig,s=t.trim;s&&(Qr.set(i.width/s.width,0,0,i.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(Qr));const n=t.source,o=this.uClampFrame,a=this.clampMargin/n._resolution,h=this.clampOffset/n._resolution;return o[0]=(t.frame.x+a+h)/n.width,o[1]=(t.frame.y+a+h)/n.height,o[2]=(t.frame.x+t.frame.width-a+h)/n.width,o[3]=(t.frame.y+t.frame.height-a+h)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=t.frame.width===n.width&&t.frame.height===n.height&&t.rotate===0,!0}}class G extends Yt{constructor({source:t,label:e,frame:i,orig:s,trim:n,defaultAnchor:o,defaultBorders:a,rotate:h,dynamic:l}={}){if(super(),this.uid=dt("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new et,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=(t==null?void 0:t.source)??new Bt,this.noFrame=!i,i)this.frame.copyFrom(i);else{const{width:c,height:d}=this._source;this.frame.width=c,this.frame.height=d}this.orig=s||this.frame,this.trim=n,this.rotate=h??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=l||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new cd(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:i,height:s}=this._source,n=e.x/i,o=e.y/s,a=e.width/i,h=e.height/s;let l=this.rotate;if(l){const c=a/2,d=h/2,u=n+c,p=o+d;l=X.add(l,X.NW),t.x0=u+c*X.uX(l),t.y0=p+d*X.uY(l),l=X.add(l,2),t.x1=u+c*X.uX(l),t.y1=p+d*X.uY(l),l=X.add(l,2),t.x2=u+c*X.uX(l),t.y2=p+d*X.uY(l),l=X.add(l,2),t.x3=u+c*X.uX(l),t.y3=p+d*X.uY(l)}else t.x0=n,t.y0=o,t.x1=n+a,t.y1=o,t.x2=n+a,t.y2=o+h,t.x3=n,t.y3=o+h}destroy(t=!1){this._source&&(this._source.off("resize",this.update,this),t&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return V(J,"Texture.baseTexture is now Texture.source"),this._source}}G.EMPTY=new G({label:"EMPTY",source:new Bt({label:"EMPTY"})});G.EMPTY.destroy=sh;G.WHITE=new G({source:new ar({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});G.WHITE.destroy=sh;function lh(r,t,e){const{width:i,height:s}=e.orig,n=e.trim;if(n){const o=n.width,a=n.height;r.minX=n.x-t._x*i,r.maxX=r.minX+o,r.minY=n.y-t._y*s,r.maxY=r.minY+a}else r.minX=-t._x*i,r.maxX=r.minX+i,r.minY=-t._y*s,r.maxY=r.minY+s}const Jr=new W;class It{constructor(t=1/0,e=1/0,i=-1/0,s=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Jr,this.minX=t,this.minY=e,this.maxX=i,this.maxY=s}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new et);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Jr,this}set(t,e,i,s){this.minX=t,this.minY=e,this.maxX=i,this.maxY=s}addFrame(t,e,i,s,n){n||(n=this.matrix);const o=n.a,a=n.b,h=n.c,l=n.d,c=n.tx,d=n.ty;let u=this.minX,p=this.minY,f=this.maxX,y=this.maxY,m=o*t+h*e+c,x=a*t+l*e+d;m<u&&(u=m),x<p&&(p=x),m>f&&(f=m),x>y&&(y=x),m=o*i+h*e+c,x=a*i+l*e+d,m<u&&(u=m),x<p&&(p=x),m>f&&(f=m),x>y&&(y=x),m=o*t+h*s+c,x=a*t+l*s+d,m<u&&(u=m),x<p&&(p=x),m>f&&(f=m),x>y&&(y=x),m=o*i+h*s+c,x=a*i+l*s+d,m<u&&(u=m),x<p&&(p=x),m>f&&(f=m),x>y&&(y=x),this.minX=u,this.minY=p,this.maxX=f,this.maxY=y}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,i=this.minY,s=this.maxX,n=this.maxY,{a:o,b:a,c:h,d:l,tx:c,ty:d}=t;let u=o*e+h*i+c,p=a*e+l*i+d;this.minX=u,this.minY=p,this.maxX=u,this.maxY=p,u=o*s+h*i+c,p=a*s+l*i+d,this.minX=u<this.minX?u:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=p>this.maxY?p:this.maxY,u=o*e+h*n+c,p=a*e+l*n+d,this.minX=u<this.minX?u:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=p>this.maxY?p:this.maxY,u=o*s+h*n+c,p=a*s+l*n+d,this.minX=u<this.minX?u:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=p>this.maxY?p:this.maxY}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,s){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<i&&(this.minY=i),this.maxY>s&&(this.maxY=s),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new It(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,i,s){let n=this.minX,o=this.minY,a=this.maxX,h=this.maxY;s||(s=this.matrix);const l=s.a,c=s.b,d=s.c,u=s.d,p=s.tx,f=s.ty;for(let y=e;y<i;y+=2){const m=t[y],x=t[y+1],S=l*m+d*x+p,v=c*m+u*x+f;n=S<n?S:n,o=v<o?v:o,a=S>a?S:a,h=v>h?v:h}this.minX=n,this.minY=o,this.maxX=a,this.maxY=h}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(t){return this.minX=t.minX,this.minY=t.minY,this.maxX=t.maxX,this.maxY=t.maxY,this}}var dd={grad:.9,turn:360,rad:360/(2*Math.PI)},Zt=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},St=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},Et=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},ch=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},to=function(r){return{r:Et(r.r,0,255),g:Et(r.g,0,255),b:Et(r.b,0,255),a:Et(r.a)}},Vs=function(r){return{r:St(r.r),g:St(r.g),b:St(r.b),a:St(r.a,3)}},ud=/^#([0-9a-f]{3,8})$/i,Zi=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},dh=function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i),a=o?n===t?(e-i)/o:n===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},uh=function(r){var t=r.h,e=r.s,i=r.v,s=r.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),h=i*(1-(1-t+n)*e),l=n%6;return{r:255*[i,a,o,o,h,i][l],g:255*[h,i,i,a,o,o][l],b:255*[o,o,h,i,i,a][l],a:s}},eo=function(r){return{h:ch(r.h),s:Et(r.s,0,100),l:Et(r.l,0,100),a:Et(r.a)}},io=function(r){return{h:St(r.h),s:St(r.s),l:St(r.l),a:St(r.a,3)}},so=function(r){return uh((e=(t=r).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},bi=function(r){return{h:(t=dh(r)).h,s:(s=(200-(e=t.s))*(i=t.v)/100)>0&&s<200?e*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:t.a};var t,e,i,s},pd=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,fd=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,gd=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,md=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,En={string:[[function(r){var t=ud.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?St(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?St(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=gd.exec(r)||md.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:to({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(r){var t=pd.exec(r)||fd.exec(r);if(!t)return null;var e,i,s=eo({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(dd[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return so(s)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return Zt(t)&&Zt(e)&&Zt(i)?to({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!Zt(t)||!Zt(e)||!Zt(i))return null;var o=eo({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return so(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!Zt(t)||!Zt(e)||!Zt(i))return null;var o=function(a){return{h:ch(a.h),s:Et(a.s,0,100),v:Et(a.v,0,100),a:Et(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return uh(o)},"hsv"]]},no=function(r,t){for(var e=0;e<t.length;e++){var i=t[e][0](r);if(i)return[i,t[e][1]]}return[null,void 0]},yd=function(r){return typeof r=="string"?no(r.trim(),En.string):typeof r=="object"&&r!==null?no(r,En.object):[null,void 0]},Ns=function(r,t){var e=bi(r);return{h:e.h,s:Et(e.s+100*t,0,100),l:e.l,a:e.a}},js=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},ro=function(r,t){var e=bi(r);return{h:e.h,s:e.s,l:Et(e.l+100*t,0,100),a:e.a}},In=function(){function r(t){this.parsed=yd(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return St(js(this.rgba),2)},r.prototype.isDark=function(){return js(this.rgba)<.5},r.prototype.isLight=function(){return js(this.rgba)>=.5},r.prototype.toHex=function(){return t=Vs(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?Zi(St(255*n)):"","#"+Zi(e)+Zi(i)+Zi(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return Vs(this.rgba)},r.prototype.toRgbString=function(){return t=Vs(this.rgba),e=t.r,i=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+s+", "+n+")":"rgb("+e+", "+i+", "+s+")";var t,e,i,s,n},r.prototype.toHsl=function(){return io(bi(this.rgba))},r.prototype.toHslString=function(){return t=io(bi(this.rgba)),e=t.h,i=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+n+")":"hsl("+e+", "+i+"%, "+s+"%)";var t,e,i,s,n},r.prototype.toHsv=function(){return t=dh(this.rgba),{h:St(t.h),s:St(t.s),v:St(t.v),a:St(t.a,3)};var t},r.prototype.invert=function(){return Ut({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),Ut(Ns(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),Ut(Ns(this.rgba,-t))},r.prototype.grayscale=function(){return Ut(Ns(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),Ut(ro(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),Ut(ro(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?Ut({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):St(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=bi(this.rgba);return typeof t=="number"?Ut({h:t,s:e.s,l:e.l,a:e.a}):St(e.h)},r.prototype.isEqual=function(t){return this.toHex()===Ut(t).toHex()},r}(),Ut=function(r){return r instanceof In?r:new In(r)},oo=[],xd=function(r){r.forEach(function(t){oo.indexOf(t)<0&&(t(In,En),oo.push(t))})};function Sd(r,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var s in e)i[e[s]]=s;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,h,l=i[this.toHex()];if(l)return l;if(o!=null&&o.closest){var c=this.toRgb(),d=1/0,u="black";if(!n.length)for(var p in e)n[p]=new r(e[p]).toRgb();for(var f in e){var y=(a=c,h=n[f],Math.pow(a.r-h.r,2)+Math.pow(a.g-h.g,2)+Math.pow(a.b-h.b,2));y<d&&(d=y,u=f)}return u}},t.string.push([function(o){var a=o.toLowerCase(),h=a==="transparent"?"#0000":e[a];return h?new r(h).toRgb():null},"name"])}xd([Sd]);const $e=class mi{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof mi)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}_isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((n,o)=>n===e[o]);if(t!==null&&e!==null){const n=Object.keys(t),o=Object.keys(e);return n.length!==o.length?!1:n.every(a=>t[a]===e[a])}return t===e}toRgba(){const[t,e,i,s]=this._components;return{r:t,g:e,b:i,a:s}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,s]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(s*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,i,s,n]=this._components;return t[0]=e,t[1]=i,t[2]=s,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,i,s]=this._components;return t[0]=e,t[1]=i,t[2]=s,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,s,n]=mi._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=s,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(s<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,i,s,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,s=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,s,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,s,n=255]=t,e/=255,i/=255,s/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=mi.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=Ut(t);o.isValid()&&({r:e,g:i,b:s,a:n}=o.rgba,e/=255,i/=255,s/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=s,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((s,n)=>{t[n]=Math.min(Math.max(s,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof mi||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};$e.shared=new $e;$e._temp=new $e;$e.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let rt=$e;const vd={cullArea:null,cullable:!1,cullableChildren:!0};let Ys=0;const ao=500;function nt(...r){Ys!==ao&&(Ys++,Ys===ao?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...r))}const Oi={_registeredResources:new Set,register(r){this._registeredResources.add(r)},unregister(r){this._registeredResources.delete(r)},release(){this._registeredResources.forEach(r=>r.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(r){return this._registeredResources.has(r)},reset(){this._registeredResources.clear()}};class bd{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){var i;let e;return this._index>0?e=this._pool[--this._index]:(e=new this._classType,this._count++),(i=e.init)==null||i.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t<this._index;t++)this._pool[t].destroy();this._pool.length=0,this._count=0,this._index=0}}class wd{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new bd(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}}const _t=new wd;Oi.register(_t);const Ad={get isCachedAsTexture(){var r;return!!((r=this.renderGroup)!=null&&r.isCachedAsTexture)},cacheAsTexture(r){typeof r=="boolean"&&r===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(r===!0?{}:r))},updateCacheTexture(){var r;(r=this.renderGroup)==null||r.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(r){V("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(r)}};function Cd(r,t,e){const i=r.length;let s;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(s=t;s<n;++s)r[s]=r[s+e];r.length=n}const Pd={allowChildren:!0,removeChildren(r=0,t){var n;const e=t??this.children.length,i=e-r,s=[];if(i>0&&i<=e){for(let a=e-1;a>=r;a--){const h=this.children[a];h&&(s.push(h),h.parent=null)}Cd(this.children,r,e);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(s);for(let a=0;a<s.length;++a){const h=s[a];(n=h.parentRenderLayer)==null||n.detach(h),this.emit("childRemoved",h,this,a),s[a].emit("removed",this)}return s.length>0&&this._didViewChangeTick++,s}else if(i===0&&this.children.length===0)return s;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(r){const t=this.getChildAt(r);return this.removeChild(t)},getChildAt(r){if(r<0||r>=this.children.length)throw new Error(`getChildAt: Index (${r}) does not exist.`);return this.children[r]},setChildIndex(r,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(r),this.addChildAt(r,t)},getChildIndex(r){const t=this.children.indexOf(r);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(r,t){this.allowChildren||V(J,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${r}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(r.parent){const s=r.parent.children.indexOf(r);if(r.parent===this&&s===t)return r;s!==-1&&r.parent.children.splice(s,1)}t===e.length?e.push(r):e.splice(t,0,r),r.parent=this,r.didChange=!0,r._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(r),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",r,this,t),r.emit("added",this),r},swapChildren(r,t){if(r===t)return;const e=this.getChildIndex(r),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=r;const s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)},reparentChild(...r){return r.length===1?this.reparentChildAt(r[0],this.children.length):(r.forEach(t=>this.reparentChildAt(t,this.children.length)),r[0])},reparentChildAt(r,t){if(r.parent===this)return this.setChildIndex(r,t),r;const e=r.worldTransform.clone();r.removeFromParent(),this.addChildAt(r,t);const i=this.worldTransform.clone();return i.invert(),e.prepend(i),r.setFromMatrix(e),r},replaceChild(r,t){r.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(r)),t.setFromMatrix(r.localTransform),t.updateLocalTransform(),this.removeChild(r)}},Md={collectRenderables(r,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(r,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,r):this.collectRenderablesWithEffects(r,t,e))},collectRenderablesSimple(r,t,e){const i=this.children,s=i.length;for(let n=0;n<s;n++)i[n].collectRenderables(r,t,e)},collectRenderablesWithEffects(r,t,e){const{renderPipes:i}=t;for(let s=0;s<this.effects.length;s++){const n=this.effects[s];i[n.pipe].push(n,this,r)}this.collectRenderablesSimple(r,t,e);for(let s=this.effects.length-1;s>=0;s--){const n=this.effects[s];i[n.pipe].pop(n,this,r)}}};class ho{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null}}class _d{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const i=this._tests[e];if(i.test(t))return _t.get(i.maskClass,t)}return t}returnMaskEffect(t){_t.return(t)}}const Bn=new _d;$.handleByList(E.MaskEffect,Bn._effectClasses);const Td={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0)},addEffect(r){this.effects.indexOf(r)===-1&&(this.effects.push(r),this.effects.sort((e,i)=>e.priority-i.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(r){const t=this.effects.indexOf(r);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(r){const t=this._maskEffect;(t==null?void 0:t.mask)!==r&&(t&&(this.removeEffect(t),Bn.returnMaskEffect(t),this._maskEffect=null),r!=null&&(this._maskEffect=Bn.getMaskEffect(r),this.addEffect(this._maskEffect)))},get mask(){var r;return(r=this._maskEffect)==null?void 0:r.mask},setMask(r){this._maskOptions={...this._maskOptions,...r},r.mask&&(this.mask=r.mask),this._markStructureAsChanged()},set filters(r){var n;!Array.isArray(r)&&r&&(r=[r]);const t=this._filterEffect||(this._filterEffect=new ho);r=r;const e=(r==null?void 0:r.length)>0,i=((n=t.filters)==null?void 0:n.length)>0,s=e!==i;r=Array.isArray(r)?r.slice(0):r,t.filters=Object.freeze(r),s&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=r??null))},get filters(){var r;return(r=this._filterEffect)==null?void 0:r.filters},set filterArea(r){this._filterEffect||(this._filterEffect=new ho),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},kd={label:null,get name(){return V(J,"Container.name property has been removed, use Container.label instead"),this.label},set name(r){V(J,"Container.name property has been removed, use Container.label instead"),this.label=r},getChildByName(r,t=!1){return this.getChildByLabel(r,t)},getChildByLabel(r,t=!1){const e=this.children;for(let i=0;i<e.length;i++){const s=e[i];if(s.label===r||r instanceof RegExp&&r.test(s.label))return s}if(t)for(let i=0;i<e.length;i++){const n=e[i].getChildByLabel(r,!0);if(n)return n}return null},getChildrenByLabel(r,t=!1,e=[]){const i=this.children;for(let s=0;s<i.length;s++){const n=i[s];(n.label===r||r instanceof RegExp&&r.test(n.label))&&e.push(n)}if(t)for(let s=0;s<i.length;s++)i[s].getChildrenByLabel(r,!0,e);return e}},Pt=_t.getPool(W),Qt=_t.getPool(It),Rd=new W,Ed={getFastGlobalBounds(r,t){t||(t=new It),t.clear(),this._getGlobalBoundsRecursive(!!r,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);const e=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(e.worldTransform),t},_getGlobalBoundsRecursive(r,t,e){let i=t;if(r&&this.parentRenderLayer&&this.parentRenderLayer!==e||this.localDisplayStatus!==7||!this.measurable)return;const s=!!this.effects.length;if((this.renderGroup||s)&&(i=Qt.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const o=this.bounds;i.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}const n=this.children;for(let o=0;o<n.length;o++)n[o]._getGlobalBoundsRecursive(r,i,e)}if(s){let n=!1;const o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(n||(n=!0,i.applyMatrix(o.worldTransform)),this.effects[a].addBounds(i,!0));n&&i.applyMatrix(o.worldTransform.copyTo(Rd).invert()),t.addBounds(i),Qt.return(i)}else this.renderGroup&&(t.addBounds(i,this.relativeGroupTransform),Qt.return(i))}};function ph(r,t,e){e.clear();let i,s;return r.parent?t?i=r.parent.worldTransform:(s=Pt.get().identity(),i=hr(r,s)):i=W.IDENTITY,fh(r,e,i,t),s&&Pt.return(s),e.isValid||e.set(0,0,0,0),e}function fh(r,t,e,i){var a,h;if(!r.visible||!r.measurable)return;let s;i?s=r.worldTransform:(r.updateLocalTransform(),s=Pt.get(),s.appendFrom(r.localTransform,e));const n=t,o=!!r.effects.length;if(o&&(t=Qt.get().clear()),r.boundsArea)t.addRect(r.boundsArea,s);else{const l=r.bounds;l&&!l.isEmpty()&&(t.matrix=s,t.addBounds(l));for(let c=0;c<r.children.length;c++)fh(r.children[c],t,s,i)}if(o){for(let l=0;l<r.effects.length;l++)(h=(a=r.effects[l]).addBounds)==null||h.call(a,t);n.addBounds(t,W.IDENTITY),Qt.return(t)}i||Pt.return(s)}function hr(r,t){const e=r.parent;return e&&(hr(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}function lr(r,t){if(r===16777215||!t)return t;if(t===16777215||!r)return r;const e=r>>16&255,i=r>>8&255,s=r&255,n=t>>16&255,o=t>>8&255,a=t&255,h=e*n/255|0,l=i*o/255|0,c=s*a/255|0;return(h<<16)+(l<<8)+c}const lo=16777215;function co(r,t){return r===lo?t:t===lo?r:lr(r,t)}function wi(r){return((r&255)<<16)+(r&65280)+(r>>16&255)}const Id={getGlobalAlpha(r){if(r)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,e=this.parent;for(;e;)t*=e.alpha,e=e.parent;return t},getGlobalTransform(r=new W,t){if(t)return r.copyFrom(this.worldTransform);this.updateLocalTransform();const e=hr(this,Pt.get().identity());return r.appendFrom(this.localTransform,e),Pt.return(e),r},getGlobalTint(r){if(r)return this.renderGroup?wi(this.renderGroup.worldColor):this.parentRenderGroup?wi(co(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=co(t,e.localColor),e=e.parent;return wi(t)}};function gh(r,t,e){return t.clear(),e||(e=W.IDENTITY),mh(r,t,e,r,!0),t.isValid||t.set(0,0,0,0),t}function mh(r,t,e,i,s){var h,l;let n;if(s)n=Pt.get(),n=e.copyTo(n);else{if(!r.visible||!r.measurable)return;r.updateLocalTransform();const c=r.localTransform;n=Pt.get(),n.appendFrom(c,e)}const o=t,a=!!r.effects.length;if(a&&(t=Qt.get().clear()),r.boundsArea)t.addRect(r.boundsArea,n);else{r.renderPipeId&&(t.matrix=n,t.addBounds(r.bounds));const c=r.children;for(let d=0;d<c.length;d++)mh(c[d],t,n,i,!1)}if(a){for(let c=0;c<r.effects.length;c++)(l=(h=r.effects[c]).addLocalBounds)==null||l.call(h,t,i);o.addBounds(t,W.IDENTITY),Qt.return(t)}Pt.return(n)}function yh(r,t){const e=r.children;for(let i=0;i<e.length;i++){const s=e[i],n=s.uid,o=(s._didViewChangeTick&65535)<<16|s._didContainerChangeTick&65535,a=t.index;(t.data[a]!==n||t.data[a+1]!==o)&&(t.data[t.index]=n,t.data[t.index+1]=o,t.didChange=!0),t.index=a+2,s.children.length&&yh(s,t)}return t.didChange}const Bd=new W,Dd={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(r,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=r/t*e:this.scale.x=e},_setHeight(r,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=r/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new It});const r=this._localBoundsCacheData;return r.index=1,r.didChange=!1,r.data[0]!==this._didViewChangeTick&&(r.didChange=!0,r.data[0]=this._didViewChangeTick),yh(this,r),r.didChange&&gh(this,r.localBounds,Bd),r.localBounds},getBounds(r,t){return ph(this,r,t||new It)}},Fd={_onRender:null,set onRender(r){const t=this.renderGroup||this.parentRenderGroup;if(!r){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=r},get onRender(){return this._onRender}},zd={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(r){this._zIndex!==r&&(this._zIndex=r,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(Ld))}};function Ld(r,t){return r._zIndex-t._zIndex}const Od={getGlobalPosition(r=new tt,t=!1){return this.parent?this.parent.toGlobal(this._position,r,t):(r.x=this._position.x,r.y=this._position.y),r},toGlobal(r,t,e=!1){const i=this.getGlobalTransform(Pt.get(),e);return t=i.apply(r,t),Pt.return(i),t},toLocal(r,t,e,i){t&&(r=t.toGlobal(r,e,i));const s=this.getGlobalTransform(Pt.get(),i);return e=s.applyInverse(r,e),Pt.return(s),e}};class cr{constructor(){this.uid=dt("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}let Gd=0;class Wd{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new Ke(this.textureOptions)}createTexture(t,e,i){const s=new Bt({...this.textureOptions,width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!1});return new G({source:s,label:`texturePool_${Gd++}`})}getOptimalTexture(t,e,i=1,s){let n=Math.ceil(t*i-1e-6),o=Math.ceil(e*i-1e-6);n=qe(n),o=qe(o);const a=(n<<17)+(o<<1)+(s?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let h=this._texturePool[a].pop();return h||(h=this.createTexture(n,o,s)),h.source._resolution=i,h.source.width=n/i,h.source.height=o/i,h.source.pixelWidth=n,h.source.pixelHeight=o,h.frame.x=0,h.frame.y=0,h.frame.width=t,h.frame.height=e,h.updateUvs(),this._poolKeyHash[h.uid]=a,h}getSameSizeTexture(t,e=!1){const i=t.source;return this.getOptimalTexture(t.width,t.height,i._resolution,e)}returnTexture(t,e=!1){const i=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[i].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const i=this._texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0)}this._texturePool={}}}const Ps=new Wd;Oi.register(Ps);class Ud{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new W,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new cr,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let i=0;i<e.length;i++){const s=e[i];s._updateFlags=15,this.addChild(s)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(Ps.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const t=this._parentCacheAsTextureRenderGroup;t&&!t.textureNeedsUpdate&&t.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let i=0;i<e.length;i++)this.addChild(e[i])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}const e=t.children;for(let i=0;i<e.length;i++)this.removeChild(e[i])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),t.didViewUpdate=!1)}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;e<this._onRenderContainers.length;e++)this._onRenderContainers[e]._onRender(t)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(t=[]){const e=this.root.children;for(let i=0;i<e.length;i++)this._getChildren(e[i],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const i=t.children;for(let s=0;s<i.length;s++)this._getChildren(i[s],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return this._matrixDirty&1?(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new W),this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return this._matrixDirty&2?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new W),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y)):this._textureOffsetInverseTransform}get inverseParentTextureTransform(){if(!(this._matrixDirty&4))return this._inverseParentTextureTransform;this._matrixDirty&=-5;const t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new W),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x,-t._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function Hd(r,t,e={}){for(const i in t)!e[i]&&t[i]!==void 0&&(r[i]=t[i])}const Xs=new ct(null),qi=new ct(null),Zs=new ct(null,1,1),Ki=new ct(null),uo=1,Vd=2,qs=4;class L extends Yt{constructor(t={}){var e,i;super(),this.uid=dt("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new W,this.relativeGroupTransform=new W,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new ct(this,0,0),this._scale=Zs,this._pivot=qi,this._origin=Ki,this._skew=Xs,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],Hd(this,t,{children:!0,parent:!0,effects:!0}),(e=t.children)==null||e.forEach(s=>this.addChild(s)),(i=t.parent)==null||i.addChild(this)}static mixin(t){V("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),$.mixin(L,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(this.allowChildren||V(J,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let s=0;s<t.length;s++)this.addChild(t[s]);return t[0]}const e=t[0],i=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),i&&(i.structureDidChange=!0),e):(e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=!0),e.parent=this,e.didChange=!0,e._updateFlags=15,i&&i.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,e._zIndex!==0&&e.depthOfChildModified(),e)}removeChild(...t){if(t.length>1){for(let s=0;s<t.length;s++)this.removeChild(t[s]);return t[0]}const e=t[0],i=this.children.indexOf(e);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=_t.get(Ud,this),this.groupTransform=W.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),_t.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new W),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*sd}set angle(t){this.rotation=t*nd}get pivot(){return this._pivot===qi&&(this._pivot=new ct(this,0,0)),this._pivot}set pivot(t){this._pivot===qi&&(this._pivot=new ct(this,0,0),this._origin!==Ki&&nt("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Xs&&(this._skew=new ct(this,0,0)),this._skew}set skew(t){this._skew===Xs&&(this._skew=new ct(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Zs&&(this._scale=new ct(this,1,1)),this._scale}set scale(t){this._scale===Zs&&(this._scale=new ct(this,0,0)),typeof t=="string"&&(t=parseFloat(t)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===Ki&&(this._origin=new ct(this,0,0)),this._origin}set origin(t){this._origin===Ki&&(this._origin=new ct(this,0,0),this._pivot!==qi&&nt("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._origin.set(t):this._origin.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const i=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,i.width),e!==void 0&&this._setHeight(e,i.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,i=this._scale,s=this._pivot,n=this._origin,o=this._position,a=i._x,h=i._y,l=s._x,c=s._y,d=-n._x,u=-n._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*h,e.d=this._sy*h,e.tx=o._x-(l*e.a+c*e.c)+(d*e.a+u*e.c)-d,e.ty=o._y-(l*e.b+c*e.d)+(d*e.b+u*e.d)-u}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=uo,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const i=rt.shared.setValue(t??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=uo,this._onUpdate())}get tint(){return wi(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Vd,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=qs,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=qs,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=qs,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var s;if(this.destroyed)return;this.destroyed=!0;let e;if(this.children.length&&(e=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof t=="boolean"?t:t==null?void 0:t.children)&&e)for(let n=0;n<e.length;++n)e[n].destroy(t);(s=this.renderGroup)==null||s.destroy(),this.renderGroup=null}}$.mixin(L,Pd,Ed,Od,Fd,Dd,Td,kd,zd,vd,Ad,Id,Md);class ii extends L{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this._bounds=new It(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=t.autoGarbageCollect??!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:i,y:s}=t;return i>=e.minX&&i<=e.maxX&&s>=e.minY&&s<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(t){this.unload(),super.destroy(t),this._bounds=null}collectRenderablesSimple(t,e,i){const{renderPipes:s}=e;s.blendMode.pushBlendMode(this,this.groupBlendMode,t);const o=s[this.renderPipeId];o!=null&&o.addRenderable&&o.addRenderable(this,t),this.didViewUpdate=!1;const a=this.children,h=a.length;for(let l=0;l<h;l++)a[l].collectRenderables(t,e,i);s.blendMode.popBlendMode(t)}}class jt extends ii{constructor(t=G.EMPTY){t instanceof G&&(t={texture:t});const{texture:e=G.EMPTY,anchor:i,roundPixels:s,width:n,height:o,...a}=t;super({label:"Sprite",...a}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new ct({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=s??!1,n!==void 0&&(this.width=n),o!==void 0&&(this.height=o)}static from(t,e=!1){return t instanceof G?new jt(t):new jt(G.from(t,e))}set texture(t){t||(t=G.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return lh(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return V("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:s,height:n}=e.orig;i.minX=-t._x*s,i.maxX=i.minX+s,i.minY=-t._y*n,i.maxY=i.minY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const Nd=new It;function xh(r,t,e){const i=Nd;r.measurable=!0,ph(r,e,i),t.addBoundsMask(i),r.measurable=!1}function Sh(r,t,e){const i=Qt.get();r.measurable=!0;const s=Pt.get().identity(),n=vh(r,e,s);gh(r,i,n),r.measurable=!1,t.addBoundsMask(i),Pt.return(s),Qt.return(i)}function vh(r,t,e){return r?(r!==t&&(vh(r.parent,t,e),r.updateLocalTransform(),e.append(r.localTransform)),e):(nt("Mask bounds, renderable is not inside the root container"),e)}class bh{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof jt),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(t,e){this.inverse||xh(this.mask,t,e)}addLocalBounds(t,e){Sh(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof jt}}bh.extension=E.MaskEffect;class wh{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}wh.extension=E.MaskEffect;class Ah{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(t,e){xh(this.mask,t,e)}addLocalBounds(t,e){Sh(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof L}}Ah.extension=E.MaskEffect;const jd={createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")};let po=jd;const j={get(){return po},set(r){po=r}};class dr extends Bt{constructor(t){t.resource||(t.resource=j.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,i=this._resolution){const s=super.resize(t,e,i);return s&&this.resizeCanvas(),s}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}dr.extension=E.TextureSource;class Qe extends Bt{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}Qe.extension=E.TextureSource;var Ee=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(Ee||{});class Ks{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=s}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Ch=class Tt{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Ks(null,null,1/0),this.deltaMS=1/Tt.targetFPMS,this.elapsedMS=1/Tt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=Ee.NORMAL){return this._addListener(new Ks(t,e,i))}addOnce(t,e,i=Ee.NORMAL){return this._addListener(new Ks(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*Tt.targetFPMS;const i=this._head;let s=i.next;for(;s;)s=s.emit(this);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,Tt.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!Tt._shared){const t=Tt._shared=new Tt;t.autoStart=!0,t._protected=!0}return Tt._shared}static get system(){if(!Tt._system){const t=Tt._system=new Tt;t.autoStart=!0,t._protected=!0}return Tt._system}};Ch.targetFPMS=.06;let yt=Ch,$s;async function Ph(){return $s??($s=(async()=>{var o;const t=j.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(a=>{const h=document.createElement("video");h.onloadeddata=()=>a(h),h.onerror=()=>a(null),h.autoplay=!1,h.crossOrigin="anonymous",h.preload="auto",h.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",h.load()});if(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const s=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,s),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(s),t.deleteTexture(i),(o=t.getExtension("WEBGL_lose_context"))==null||o.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),$s}const Ms=class Mh extends Bt{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...Mh.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=yt.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await Ph(),this._load=new Promise((i,s)=>{this.isValid?i(this):(this._resolve=i,this._reject=s,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(yt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(yt.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(yt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Ms.extension=E.TextureSource;Ms.defaultOptions={...Bt.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Ms.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Ai=Ms;const zt=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r);class Yd{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||nt(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=zt(t);let s;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.test(e)){s=l.getCacheableAssets(i,e);break}}const n=new Map(Object.entries(s||{}));s||i.forEach(h=>{n.set(h,e)});const o=[...n.keys()],a={cacheKeys:o,keys:i};i.forEach(h=>{this._cacheMap.set(h,a)}),o.forEach(h=>{const l=s?s[h]:e;this._cache.has(h)&&this._cache.get(h)!==l&&nt("[Cache] already has key:",h),this._cache.set(h,n.get(h))})}remove(t){if(!this._cacheMap.has(t)){nt(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(s=>{this._cache.delete(s)}),e.keys.forEach(s=>{this._cacheMap.delete(s)})}get parsers(){return this._parsers}}const xt=new Yd,Dn=[];$.handleByList(E.TextureSource,Dn);function _h(r={}){const t=r&&r.resource,e=t?r.resource:r,i=t?r:{resource:r};for(let s=0;s<Dn.length;s++){const n=Dn[s];if(n.test(e))return new n(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function Xd(r={},t=!1){const e=r&&r.resource,i=e?r.resource:r,s=e?r:{resource:r};if(!t&&xt.has(i))return xt.get(i);const n=new G({source:_h(s)});return n.on("destroy",()=>{xt.has(i)&&xt.remove(i)}),t||xt.set(i,n),n}function Zd(r,t=!1){return typeof r=="string"?xt.get(r):r instanceof Bt?new G({source:r}):Xd(r,t)}G.from=Zd;Bt.from=_h;$.add(bh,wh,Ah,Ai,Qe,dr,ar);var ue=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(ue||{});function Dt(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function oi(r){return r.split("?")[0].split("#")[0]}function qd(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Kd(r,t,e){return r.replace(new RegExp(qd(t),"g"),e)}function $d(r,t){let e="",i=0,s=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a<r.length)o=r.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(s===a-1||n===1))if(s!==a-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",i=0):(e=e.slice(0,h),i=e.length-1-e.lastIndexOf("/")),s=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=a,n=0;continue}}}else e.length>0?e+=`/${r.slice(s+1,a)}`:e=r.slice(s+1,a),i=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const Mt={toPosix(r){return Kd(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){Dt(r),r=this.toPosix(r);const t=/^file:\/\/\//.exec(r);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(r);return e?e[0]:""},toAbsolute(r,t,e){if(Dt(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=oi(this.toPosix(t??j.get().getBaseUrl())),s=oi(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?Mt.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(Dt(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const i=r.endsWith("/");return r=$d(r),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return Dt(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let t;for(let e=0;e<r.length;++e){const i=r[e];if(Dt(i),i.length>0)if(t===void 0)t=i;else{const s=r[e-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(r){if(Dt(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,s=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!s){i=a;break}}else s=!1;return i===-1?e?"/":this.isUrl(o)?n+r:n:e&&i===1?"//":n+r.slice(0,i)},rootname(r){Dt(r),r=this.toPosix(r);let t="";if(r.startsWith("/")?t="/":t=this.getProtocol(r),this.isUrl(r)){const e=r.indexOf("/",t.length);e!==-1?t=r.slice(0,e):t=r,t.endsWith("/")||(t+="/")}return t},basename(r,t){Dt(r),t&&Dt(t),r=oi(this.toPosix(r));let e=0,i=-1,s=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const h=r.charCodeAt(n);if(h===47){if(!s){e=n+1;break}}else a===-1&&(s=!1,a=n+1),o>=0&&(h===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=r.length),r.slice(e,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){e=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(e,i)},extname(r){Dt(r),r=oi(this.toPosix(r));let t=-1,e=0,i=-1,s=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!s){e=o+1;break}continue}i===-1&&(s=!1,i=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){Dt(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=oi(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let s;t.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let n=-1,o=0,a=-1,h=!0,l=r.length-1,c=0;for(;l>=s;--l){if(e=r.charCodeAt(l),e===47){if(!h){o=l+1;break}continue}a===-1&&(h=!1,a=l+1),e===46?n===-1?n=l:c!==1&&(c=1):n!==-1&&(c=-1)}return n===-1||a===-1||c===0||c===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&i?t.base=t.name=r.slice(1,a):t.base=t.name=r.slice(o,a)):(o===0&&i?(t.name=r.slice(1,n),t.base=r.slice(1,a)):(t.name=r.slice(o,n),t.base=r.slice(o,a)),t.ext=r.slice(n,a)),t.dir=this.dirname(r),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function Th(r,t,e,i,s){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?Th(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function Qd(r){const t=/\{(.*?)\}/g,e=r.match(t),i=[];if(e){const s=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");s.push(o)}),Th(r,s,0,e,i)}else i.push(r);return i}const fs=r=>!Array.isArray(r);class si{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return zt(e||i,n=>typeof n=="string"?n:Array.isArray(n)?n.map(o=>(o==null?void 0:o.src)??o):n!=null&&n.src?n.src:n,!0)}addManifest(t){this._manifest&&nt("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];let s=e;Array.isArray(e)||(s=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:{alias:n,...o})),s.forEach(n=>{const o=n.src,a=n.alias;let h;if(typeof a=="string"){const l=this._createBundleAssetId(t,a);i.push(l),h=[a,l]}else{const l=a.map(c=>this._createBundleAssetId(t,c));i.push(...l),h=[...a,...l]}this.add({...n,alias:h,src:o})}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;i=n=>{this.hasKey(n)&&nt(`[Resolver] already has key: ${n} overwriting`)},zt(e).forEach(n=>{const{src:o}=n;let{data:a,format:h,loadParser:l,parser:c}=n;const d=zt(o).map(y=>typeof y=="string"?Qd(y):Array.isArray(y)?y:[y]),u=this.getAlias(n);Array.isArray(u)?u.forEach(i):i(u);const p=[],f=y=>{const m=this._parsers.find(x=>x.test(y));return{src:y,...m==null?void 0:m.parse(y)}};d.forEach(y=>{y.forEach(m=>{let x={};if(typeof m!="object"?x=f(m):(a=m.data??a,h=m.format??h,(m.loadParser||m.parser)&&(l=m.loadParser??l,c=m.parser??c),x={...f(m.src),...m}),!u)throw new Error(`[Resolver] alias is undefined for this asset: ${x.src}`);x=this._buildResolvedAsset(x,{aliases:u,data:a,format:h,loadParser:l,parser:c,progressSize:n.progressSize}),p.push(x)})}),u.forEach(y=>{this._assetMap[y]=p})})}resolveBundle(t){const e=fs(t);t=zt(t);const i={};return t.forEach(s=>{const n=this._bundles[s];if(n){const o=this.resolve(n),a={};for(const h in o){const l=o[h];a[this._extractAssetIdFromBundle(s,h)]=l}i[s]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const s in e)i[s]=e[s].src;return i}return e.src}resolve(t){const e=fs(t);t=zt(t);const i={};return t.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const o=this._getPreferredOrder(n);o==null||o.priority.forEach(a=>{o.params[a].forEach(h=>{const l=n.filter(c=>c[a]?c[a]===h:!1);l.length&&(n=l)})}),this._resolverHash[s]=n[0]}else this._resolverHash[s]=this._buildResolvedAsset({alias:[s],src:s},{});i[s]=this._resolverHash[s]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[e],s=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){const{aliases:i,data:s,loadParser:n,parser:o,format:a,progressSize:h}=e;return(this._basePath||this._rootPath)&&(t.src=Mt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...s||{},...t.data},t.loadParser=n??t.loadParser,t.parser=o??t.parser,t.format=a??t.format??Jd(t.src),h!==void 0&&(t.progressSize=h),t}}si.RETINA_PREFIX=/@([0-9\.]+)x/;function Jd(r){return r.split(".").pop().split("?").shift().split("#").shift()}const Fn=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r},kh=class yi{constructor(t,e){this.linkedSheets=[];let i=t;(t==null?void 0:t.source)instanceof Bt&&(i={texture:t,data:e});const{texture:s,data:n,cachePrefix:o=""}=i;this.cachePrefix=o,this._texture=s instanceof G?s:null,this.textureSource=s.source,this.textures={},this.animations={},this.data=n;const a=parseFloat(n.meta.scale);a?(this.resolution=a,s.source.resolution=this.resolution):this.resolution=s.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=yi.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(t,e=!1){let i=t;const s=e?1/0:yi.BATCH_SIZE;for(;i-t<s&&i<this._frameKeys.length;){const n=this._frameKeys[i],o=this._frames[n],a=o.frame;if(a){let h=null,l=null;const c=o.trimmed!==!1&&o.sourceSize?o.sourceSize:o.frame,d=new et(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);o.rotated?h=new et(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):h=new et(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),o.trimmed!==!1&&o.spriteSourceSize&&(l=new et(Math.floor(o.spriteSourceSize.x)/this.resolution,Math.floor(o.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[n]=new G({source:this.textureSource,frame:h,orig:d,trim:l,rotate:o.rotated?2:0,defaultAnchor:o.anchor,defaultBorders:o.borders,label:n.toString()})}i++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const s=t[e][i];this.animations[e].push(this.textures[s])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*yi.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*yi.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};kh.BATCH_SIZE=1e3;let zn=kh;const tu=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function Rh(r,t,e){const i={};if(r.forEach(s=>{i[s]=t}),Object.keys(t.textures).forEach(s=>{i[`${t.cachePrefix}${s}`]=t.textures[s]}),!e){const s=Mt.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{const a=Rh([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(i,a)})}return i}const eu={extension:E.Asset,cache:{test:r=>r instanceof zn,getCacheableAssets:(r,t)=>Rh(r,t,!1)},resolver:{extension:{type:E.ResolveParser,name:"resolveSpritesheet"},test:r=>{const e=r.split("?")[0].split("."),i=e.pop(),s=e.pop();return i==="json"&&tu.includes(s)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=si.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:E.LoadParser,priority:ue.Normal,name:"spritesheetLoader"},async testParse(r,t){return Mt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var d,u;const{texture:i,imageFilename:s,textureOptions:n,cachePrefix:o}=(t==null?void 0:t.data)??{};let a=Mt.dirname(t.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let h;if(i instanceof G)h=i;else{const p=Fn(a+(s??r.meta.image),t.src);h=(await e.load([{src:p,data:n}]))[p]}const l=new zn({texture:h.source,data:r,cachePrefix:o});await l.parse();const c=(d=r==null?void 0:r.meta)==null?void 0:d.related_multi_packs;if(Array.isArray(c)){const p=[];for(const y of c){if(typeof y!="string")continue;let m=a+y;(u=t.data)!=null&&u.ignoreMultiPack||(m=Fn(m,t.src),p.push(e.load({src:m,data:{textureOptions:n,ignoreMultiPack:!0}})))}const f=await Promise.all(p);l.linkedSheets=f,f.forEach(y=>{y.linkedSheets=[l].concat(l.linkedSheets.filter(m=>m!==y))})}return l},async unload(r,t,e){await e.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};$.add(eu);class iu{constructor(t){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const e=this._canvas.getBoundingClientRect(),i=this._canvas.width,s=this._canvas.height,n=e.width/i*this._renderer.resolution,o=e.height/s*this._renderer.resolution,a=e.left,h=e.top,l=`translate(${a}px, ${h}px) scale(${n}, ${o})`;l!==this._lastTransform&&(this._domElement.style.transform=l,this._lastTransform=l)},this._domElement=t.domElement,this._renderer=t.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(t=>{for(const e of t){if(e.target!==this._canvas)continue;const i=this.canvas.width,s=this.canvas.height,n=e.contentRect.width/i*this._renderer.resolution,o=e.contentRect.height/s*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||yt.shared.add(this.updateTranslation,this,Ee.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&yt.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}class ur{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=ur.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new tt,this.page=new tt,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var Qs=/iPhone/i,fo=/iPod/i,go=/iPad/i,mo=/\biOS-universal(?:.+)Mac\b/i,Js=/\bAndroid(?:.+)Mobile\b/i,yo=/Android/i,Fe=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,$i=/Silk/i,qt=/Windows Phone/i,xo=/\bWindows(?:.+)ARM\b/i,So=/BlackBerry/i,vo=/BB10/i,bo=/Opera Mini/i,wo=/\b(CriOS|Chrome)(?:.+)Mobile/i,Ao=/Mobile(?:.+)Firefox\b/i,Co=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function su(r){return function(t){return t.test(r)}}function Po(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]<"u"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]<"u"&&(e=i[0]);var s=su(e),n={apple:{phone:s(Qs)&&!s(qt),ipod:s(fo),tablet:!s(Qs)&&(s(go)||Co(t))&&!s(qt),universal:s(mo),device:(s(Qs)||s(fo)||s(go)||s(mo)||Co(t))&&!s(qt)},amazon:{phone:s(Fe),tablet:!s(Fe)&&s($i),device:s(Fe)||s($i)},android:{phone:!s(qt)&&s(Fe)||!s(qt)&&s(Js),tablet:!s(qt)&&!s(Fe)&&!s(Js)&&(s($i)||s(yo)),device:!s(qt)&&(s(Fe)||s($i)||s(Js)||s(yo))||s(/\bokhttp\b/i)},windows:{phone:s(qt),tablet:s(xo),device:s(qt)||s(xo)},other:{blackberry:s(So),blackberry10:s(vo),opera:s(bo),firefox:s(Ao),chrome:s(wo),device:s(So)||s(vo)||s(bo)||s(Ao)||s(wo)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const nu=Po.default??Po,Ln=nu(globalThis.navigator),tn=Object.create(null),Mo=Object.create(null);function pr(r,t){let e=Mo[r];return e===void 0&&(tn[t]===void 0&&(tn[t]=1),Mo[r]=e=tn[t]++),e}let ze;function Eh(){return(!ze||ze!=null&&ze.isContextLost())&&(ze=j.get().createCanvas().getContext("webgl",{})),ze}let Qi;function ru(){if(!Qi){Qi="mediump";const r=Eh();r&&r.getShaderPrecisionFormat&&(Qi=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return Qi}function ou(r,t,e){return t?r:e?(r=r.replace("out vec4 finalColor;",""),`
@@ -20,7 +20,7 @@ Deprecated since v${r}`,n=typeof console.groupCollapsed=="function"&&!He.noColor
20
20
  `}function au(r,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(r.substring(0,9)!=="precision"){let s=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return s==="highp"&&i!=="highp"&&(s="mediump"),`precision ${s} float;
21
21
  ${r}`}else if(i!=="highp"&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}function hu(r,t){return t?`#version 300 es
22
22
  ${r}`:r}const lu={},cu={};function du(r,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?lu:cu;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${t}`}
23
- ${r}`}function uu(r,t){return t?r.replace("#version 300 es",""):r}const en={stripVersion:uu,ensurePrecision:au,addProgramDefines:ou,setProgramName:du,insertVersion:hu},ai=Object.create(null),Ih=class On{constructor(t){t={...On.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:ru()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let s=t.fragment,n=t.vertex;Object.keys(en).forEach(o=>{const a=i[o];s=en[o](s,a,!0),n=en[o](n,a,!1)}),this.fragment=s,this.vertex=n,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=pr(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null,ai[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return ai[e]||(ai[e]=new On(t),ai[e]._cacheKey=e),ai[e]}};Ih.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Je=Ih;const _o={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function pu(r){return _o[r]??_o.float32}const fu={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"},To=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function ko(r,t){let e;for(;(e=To.exec(r))!==null;){const i=fu[e[3]]??"float32";t[e[2]]={location:parseInt(e[1],10),format:i,stride:pu(i).stride,offset:0,instance:!1,start:0}}To.lastIndex=0}function gu(r){return r.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function mu({source:r,entryPoint:t}){const e={},i=gu(r),s=i.indexOf(`fn ${t}(`);if(s===-1)return e;const n=i.indexOf("->",s);if(n===-1)return e;const o=i.substring(s,n);if(ko(o,e),Object.keys(e).length===0){const a=o.match(/\(\s*\w+\s*:\s*(\w+)/);if(a){const h=a[1],l=new RegExp(`struct\\s+${h}\\s*\\{([^}]+)\\}`,"s"),c=i.match(l);c&&ko(c[1],e)}}return e}function sn(r){var d,u;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,s=/var(<[^>]+>)? (\w+)/,n=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=(d=r.match(t))==null?void 0:d.map(p=>({group:parseInt(p.match(e)[1],10),binding:parseInt(p.match(i)[1],10),name:p.match(s)[2],isUniform:p.match(s)[1]==="<uniform>",type:p.match(n)[1]}));if(!l)return{groups:[],structs:[]};const c=((u=r.match(o))==null?void 0:u.map(p=>{const f=p.match(h)[1],y=p.match(a).reduce((m,x)=>{const[S,v]=x.split(":");return m[S.trim()]=v.trim(),m},{});return y?{name:f,members:y}:null}).filter(({name:p})=>l.some(f=>f.type===p||f.type.includes(`<${p}>`))))??[];return{groups:l,structs:c}}var Ce=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(Ce||{});function yu({groups:r}){const t=[];for(let e=0;e<r.length;e++){const i=r[e];t[i.group]||(t[i.group]=[]),i.isUniform?t[i.group].push({binding:i.binding,visibility:Ce.VERTEX|Ce.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?t[i.group].push({binding:i.binding,visibility:Ce.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"||i.type.startsWith("texture_2d<")?t[i.group].push({binding:i.binding,visibility:Ce.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):i.type==="texture_2d_array"||i.type.startsWith("texture_2d_array<")?t[i.group].push({binding:i.binding,visibility:Ce.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(i.type==="texture_cube"||i.type.startsWith("texture_cube<"))&&t[i.group].push({binding:i.binding,visibility:Ce.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let e=0;e<t.length;e++)t[e]||(t[e]=[]);return t}function xu({groups:r}){const t=[];for(let e=0;e<r.length;e++){const i=r[e];t[i.group]||(t[i.group]={}),t[i.group][i.name]=i.binding}return t}function Su(r,t){const e=new Set,i=new Set,s=[...r.structs,...t.structs].filter(o=>e.has(o.name)?!1:(e.add(o.name),!0)),n=[...r.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return i.has(a)?!1:(i.add(a),!0)});return{structs:s,groups:n}}const hi=Object.create(null);class ce{constructor(t){var a,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:s,gpuLayout:n,name:o}=t;if(this.name=o,this.fragment=e,this.vertex=i,e.source===i.source){const l=sn(e.source);this.structsAndGroups=l}else{const l=sn(i.source),c=sn(e.source);this.structsAndGroups=Su(l,c)}this.layout=s??xu(this.structsAndGroups),this.gpuLayout=n??yu(this.structsAndGroups),this.autoAssignGlobalUniforms=((a=this.layout[0])==null?void 0:a.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=pr(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=mu(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,hi[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return hi[e]||(hi[e]=new ce(t),hi[e]._cacheKey=e),hi[e]}}const Bh=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>"],vu=Bh.reduce((r,t)=>(r[t]=!0,r),{});function bu(r,t){switch(r){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const Dh=class Fh{constructor(t,e){this._touched=0,this.uid=dt("uniform"),this._resourceType="uniformGroup",this._resourceId=dt("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...Fh.defaultOptions,...e},this.uniformStructures=t;const i={};for(const s in t){const n=t[s];if(n.name=s,n.size=n.size??1,!vu[n.type]){const o=n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){const[,a,h]=o;throw new Error(`Uniform type ${n.type} is not supported. Use type: '${a}', size: ${h} instead.`)}throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${Bh.join(", ")}`)}n.value??(n.value=bu(n.type,n.size)),i[s]=n.value}this.uniforms=i,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=pr(Object.keys(i).map(s=>`${s}-${t[s].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Dh.defaultOptions={ubo:!1,isStatic:!1};let ti=Dh;class Ci{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const s=t[i];this.setResource(s,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var s,n;const i=this.resources[e];t!==i&&(i&&((s=i.off)==null||s.call(i,"change",this.onResourceChange,this)),(n=t.on)==null||n.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t,e){const i=this.resources;for(const s in i)i[s]._gcLastUsed=t,i[s]._touched=e}destroy(){var e;const t=this.resources;for(const i in t){const s=t[i];(e=s==null?void 0:s.off)==null||e.call(s,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}var Ri=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.CANVAS=4]="CANVAS",r[r.BOTH=3]="BOTH",r))(Ri||{});class Ie extends Yt{constructor(t){super(),this.uid=dt("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:i,groups:s,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=i,o===void 0&&(o=0,e&&(o|=Ri.WEBGPU),i&&(o|=Ri.WEBGL)),this.compatibleRenderers=o;const h={};if(!n&&!s&&(n={}),n&&s)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&s&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&s&&a)for(const l in a)for(const c in a[l]){const d=a[l][c];h[d]={group:l,binding:c,name:d}}else if(e&&s&&!a){const l=e.structsAndGroups.groups;a={},l.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,h[c.name]=c})}else if(n){s={},a={},e&&e.structsAndGroups.groups.forEach(d=>{a[d.group]=a[d.group]||{},a[d.group][d.binding]=d.name,h[d.name]=d});let l=0;for(const c in n)h[c]||(s[99]||(s[99]=new Ci,this._ownedBindGroups.push(s[99])),h[c]={group:99,binding:l,name:c},a[99]=a[99]||{},a[99][l]=c,l++);for(const c in n){const d=c;let u=n[c];!u.source&&!u._resourceType&&(u=new ti(u));const p=h[d];p&&(s[p.group]||(s[p.group]=new Ci,this._ownedBindGroups.push(s[p.group])),s[p.group].setResource(u,p.binding))}}this.groups=s,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(s,h)}addResource(t,e,i){var s,n;(s=this._uniformBindMap)[e]||(s[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new Ci,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const s in e){const n=e[s];Object.defineProperty(i,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding)}})}return i}destroy(t=!1){var e,i;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(s=>{s.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){const{gpu:e,gl:i,...s}=t;let n,o;return e&&(n=ce.from(e)),i&&(o=Je.from(i)),new Ie({gpuProgram:n,glProgram:o,...s})}}const wu={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},nn=0,rn=1,on=2,an=3,hn=4,ln=5,Gn=class zh{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<nn)}set blend(t){!!(this.data&1<<nn)!==t&&(this.data^=1<<nn)}get offsets(){return!!(this.data&1<<rn)}set offsets(t){!!(this.data&1<<rn)!==t&&(this.data^=1<<rn)}set cullMode(t){if(t==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=t==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<on)}set culling(t){!!(this.data&1<<on)!==t&&(this.data^=1<<on)}get depthTest(){return!!(this.data&1<<an)}set depthTest(t){!!(this.data&1<<an)!==t&&(this.data^=1<<an)}get depthMask(){return!!(this.data&1<<ln)}set depthMask(t){!!(this.data&1<<ln)!==t&&(this.data^=1<<ln)}get clockwiseFrontFace(){return!!(this.data&1<<hn)}set clockwiseFrontFace(t){!!(this.data&1<<hn)!==t&&(this.data^=1<<hn)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=wu[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const t=new zh;return t.depthTest=!1,t.blend=!0,t}};Gn.default2d=Gn.for2d();let Gi=Gn;const Lh=class Wn extends Ie{constructor(t){t={...Wn.defaultOptions,...t},super(t),this.enabled=!0,this._state=Gi.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired&&this.addResource("uBackTexture",0,3)}apply(t,e,i,s){t.applyFilter(this,e,i,s)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const{gpu:e,gl:i,...s}=t;let n,o;return e&&(n=ce.from(e)),i&&(o=Je.from(i)),new Wn({gpuProgram:n,glProgram:o,...s})}};Lh.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let Au=Lh;const Un=[];$.handleByNamedList(E.Environment,Un);async function Cu(r){if(!r)for(let t=0;t<Un.length;t++){const e=Un[t];if(e.value.test()){await e.value.load();return}}}let li;function Pu(){if(typeof li=="boolean")return li;try{li=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{li=!1}return li}function Ro(r,t,e=2){const i=t&&t.length,s=i?t[0]*e:r.length;let n=Oh(r,0,s,e,!0);const o=[];if(!n||n.next===n.prev)return o;let a,h,l;if(i&&(n=Ru(r,t,n,e)),r.length>80*e){a=r[0],h=r[1];let c=a,d=h;for(let u=e;u<s;u+=e){const p=r[u],f=r[u+1];p<a&&(a=p),f<h&&(h=f),p>c&&(c=p),f>d&&(d=f)}l=Math.max(c-a,d-h),l=l!==0?32767/l:0}return Ei(n,o,e,a,h,l,0),o}function Oh(r,t,e,i,s){let n;if(s===Uu(r,t,e,i)>0)for(let o=t;o<e;o+=i)n=Eo(o/i|0,r[o],r[o+1],n);else for(let o=e-i;o>=t;o-=i)n=Eo(o/i|0,r[o],r[o+1],n);return n&&ei(n,n.next)&&(Bi(n),n=n.next),n}function Be(r,t){if(!r)return r;t||(t=r);let e=r,i;do if(i=!1,!e.steiner&&(ei(e,e.next)||at(e.prev,e,e.next)===0)){if(Bi(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Ei(r,t,e,i,s,n,o){if(!r)return;!o&&n&&Fu(r,i,s,n);let a=r;for(;r.prev!==r.next;){const h=r.prev,l=r.next;if(n?_u(r,i,s,n):Mu(r)){t.push(h.i,r.i,l.i),Bi(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=Tu(Be(r),t),Ei(r,t,e,i,s,n,2)):o===2&&ku(r,t,e,i,s,n):Ei(Be(r),t,e,i,s,n,1);break}}}function Mu(r){const t=r.prev,e=r,i=r.next;if(at(t,e,i)>=0)return!1;const s=t.x,n=e.x,o=i.x,a=t.y,h=e.y,l=i.y,c=Math.min(s,n,o),d=Math.min(a,h,l),u=Math.max(s,n,o),p=Math.max(a,h,l);let f=i.next;for(;f!==t;){if(f.x>=c&&f.x<=u&&f.y>=d&&f.y<=p&&xi(s,a,n,h,o,l,f.x,f.y)&&at(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function _u(r,t,e,i){const s=r.prev,n=r,o=r.next;if(at(s,n,o)>=0)return!1;const a=s.x,h=n.x,l=o.x,c=s.y,d=n.y,u=o.y,p=Math.min(a,h,l),f=Math.min(c,d,u),y=Math.max(a,h,l),m=Math.max(c,d,u),x=Hn(p,f,t,e,i),S=Hn(y,m,t,e,i);let v=r.prevZ,b=r.nextZ;for(;v&&v.z>=x&&b&&b.z<=S;){if(v.x>=p&&v.x<=y&&v.y>=f&&v.y<=m&&v!==s&&v!==o&&xi(a,c,h,d,l,u,v.x,v.y)&&at(v.prev,v,v.next)>=0||(v=v.prevZ,b.x>=p&&b.x<=y&&b.y>=f&&b.y<=m&&b!==s&&b!==o&&xi(a,c,h,d,l,u,b.x,b.y)&&at(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;v&&v.z>=x;){if(v.x>=p&&v.x<=y&&v.y>=f&&v.y<=m&&v!==s&&v!==o&&xi(a,c,h,d,l,u,v.x,v.y)&&at(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=S;){if(b.x>=p&&b.x<=y&&b.y>=f&&b.y<=m&&b!==s&&b!==o&&xi(a,c,h,d,l,u,b.x,b.y)&&at(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Tu(r,t){let e=r;do{const i=e.prev,s=e.next.next;!ei(i,s)&&Wh(i,e,e.next,s)&&Ii(i,s)&&Ii(s,i)&&(t.push(i.i,e.i,s.i),Bi(e),Bi(e.next),e=r=s),e=e.next}while(e!==r);return Be(e)}function ku(r,t,e,i,s,n){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Ou(o,a)){let h=Uh(o,a);o=Be(o,o.next),h=Be(h,h.next),Ei(o,t,e,i,s,n,0),Ei(h,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function Ru(r,t,e,i){const s=[];for(let n=0,o=t.length;n<o;n++){const a=t[n]*i,h=n<o-1?t[n+1]*i:r.length,l=Oh(r,a,h,i,!1);l===l.next&&(l.steiner=!0),s.push(Lu(l))}s.sort(Eu);for(let n=0;n<s.length;n++)e=Iu(s[n],e);return e}function Eu(r,t){let e=r.x-t.x;if(e===0&&(e=r.y-t.y,e===0)){const i=(r.next.y-r.y)/(r.next.x-r.x),s=(t.next.y-t.y)/(t.next.x-t.x);e=i-s}return e}function Iu(r,t){const e=Bu(r,t);if(!e)return t;const i=Uh(e,r);return Be(i,i.next),Be(e,e.next)}function Bu(r,t){let e=t;const i=r.x,s=r.y;let n=-1/0,o;if(ei(r,e))return e;do{if(ei(r,e.next))return e.next;if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){const d=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=i&&d>n&&(n=d,o=e.x<e.next.x?e:e.next,d===i))return o}e=e.next}while(e!==t);if(!o)return null;const a=o,h=o.x,l=o.y;let c=1/0;e=o;do{if(i>=e.x&&e.x>=h&&i!==e.x&&Gh(s<l?i:n,s,h,l,s<l?n:i,s,e.x,e.y)){const d=Math.abs(s-e.y)/(i-e.x);Ii(e,r)&&(d<c||d===c&&(e.x>o.x||e.x===o.x&&Du(o,e)))&&(o=e,c=d)}e=e.next}while(e!==a);return o}function Du(r,t){return at(r.prev,r,t.prev)<0&&at(t.next,r,r.next)<0}function Fu(r,t,e,i){let s=r;do s.z===0&&(s.z=Hn(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,zu(s)}function zu(r){let t,e=1;do{let i=r,s;r=null;let n=null;for(t=0;i;){t++;let o=i,a=0;for(let l=0;l<e&&(a++,o=o.nextZ,!!o);l++);let h=e;for(;a>0||h>0&&o;)a!==0&&(h===0||!o||i.z<=o.z)?(s=i,i=i.nextZ,a--):(s=o,o=o.nextZ,h--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;i=o}n.nextZ=null,e*=2}while(t>1);return r}function Hn(r,t,e,i,s){return r=(r-e)*s|0,t=(t-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function Lu(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function Gh(r,t,e,i,s,n,o,a){return(s-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function xi(r,t,e,i,s,n,o,a){return!(r===o&&t===a)&&Gh(r,t,e,i,s,n,o,a)}function Ou(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Gu(r,t)&&(Ii(r,t)&&Ii(t,r)&&Wu(r,t)&&(at(r.prev,r,t.prev)||at(r,t.prev,t))||ei(r,t)&&at(r.prev,r,r.next)>0&&at(t.prev,t,t.next)>0)}function at(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function ei(r,t){return r.x===t.x&&r.y===t.y}function Wh(r,t,e,i){const s=ts(at(r,t,e)),n=ts(at(r,t,i)),o=ts(at(e,i,r)),a=ts(at(e,i,t));return!!(s!==n&&o!==a||s===0&&Ji(r,e,t)||n===0&&Ji(r,i,t)||o===0&&Ji(e,r,i)||a===0&&Ji(e,t,i))}function Ji(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function ts(r){return r>0?1:r<0?-1:0}function Gu(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&Wh(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Ii(r,t){return at(r.prev,r,r.next)<0?at(r,t,r.next)>=0&&at(r,r.prev,t)>=0:at(r,t,r.prev)<0||at(r,r.next,t)<0}function Wu(r,t){let e=r,i=!1;const s=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function Uh(r,t){const e=Vn(r.i,r.x,r.y),i=Vn(t.i,t.x,t.y),s=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function Eo(r,t,e,i){const s=Vn(r,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Bi(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Vn(r,t,e){return{i:r,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Uu(r,t,e,i){let s=0;for(let n=t,o=e-i;n<e;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}const Hu=Ro.default||Ro;var Hh=(r=>(r[r.NONE=0]="NONE",r[r.COLOR=16384]="COLOR",r[r.STENCIL=1024]="STENCIL",r[r.DEPTH=256]="DEPTH",r[r.COLOR_DEPTH=16640]="COLOR_DEPTH",r[r.COLOR_STENCIL=17408]="COLOR_STENCIL",r[r.DEPTH_STENCIL=1280]="DEPTH_STENCIL",r[r.ALL=17664]="ALL",r))(Hh||{});class Vu{constructor(t){this.items=[],this._name=t}emit(t,e,i,s,n,o,a,h){const{name:l,items:c}=this;for(let d=0,u=c.length;d<u;d++)c[d][l](t,e,i,s,n,o,a,h);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&this.items.splice(e,1),this}contains(t){return this.items.indexOf(t)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}const Nu=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Vh=class Nh extends Yt{constructor(t){super(),this.tick=0,this.uid=dt("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const e=[...Nu,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await Cu(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash)t={...this._systemsHash[i].constructor.defaultOptions,...t};t={...Nh.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let i=0;i<this.runners.init.items.length;i++)await this.runners.init.items[i].init(t);this._initOptions=t}render(t,e){this.tick++;let i=t;if(i instanceof L&&(i={container:i},e&&(V(J,"passing a second argument is deprecated, please use render options instead"),i.target=e.renderTexture)),i.target||(i.target=this.view.renderTarget),i.target===this.view.renderTarget&&(this._lastObjectRendered=i.container,i.clearColor??(i.clearColor=this.background.colorRgba),i.clear??(i.clear=this.background.clearBeforeRender)),i.clearColor){const s=Array.isArray(i.clearColor)&&i.clearColor.length===4;i.clearColor=s?i.clearColor:rt.shared.setValue(i.clearColor).toArray()}i.transform||(i.container.updateLocalTransform(),i.transform=i.container.localTransform),i.container.visible&&(i.container.enableRenderGroup(),this.runners.prerender.emit(i),this.runners.renderStart.emit(i),this.runners.render.emit(i),this.runners.renderEnd.emit(i),this.runners.postrender.emit(i))}resize(t,e,i){const s=this.view.resolution;this.view.resize(t,e,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),i!==void 0&&i!==s&&this.runners.resolutionChange.emit(i)}clear(t={}){const e=this;t.target||(t.target=e.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=Hh.ALL);const{clear:i,clearColor:s,target:n,mipLevel:o,layer:a}=t;rt.shared.setValue(s??this.background.colorRgba),e.renderTarget.clear(n,i,rt.shared.toArray(),o??0,a??0)}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(e=>{this.runners[e]=new Vu(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const s in this.runners)this.runners[s].add(i);return this}_addPipes(t,e){const i=e.reduce((s,n)=>(s[n.name]=n.value,s),{});t.forEach(s=>{const n=s.value,o=s.name,a=i[o];this.renderPipes[o]=new n(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),(t===!0||typeof t=="object"&&t.releaseGlobalResources)&&Oi.release(),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Pu())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};Vh.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let jh=Vh,es;function ju(r){return es!==void 0||(es=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:r??jh.defaultOptions.failIfMajorPerformanceCaveat};try{if(!j.get().getWebGLRenderingContext())return!1;let s=j.get().createCanvas().getContext("webgl",t);const n=!!((e=s==null?void 0:s.getContextAttributes())!=null&&e.stencil);if(s){const o=s.getExtension("WEBGL_lose_context");o&&o.loseContext()}return s=null,n}catch{return!1}})()),es}let is;async function Yu(r={}){return is!==void 0||(is=await(async()=>{const t=j.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(r)).requestDevice(),!0}catch{return!1}})()),is}const Io=["webgl","webgpu","canvas"];async function Xu(r){let t=[];r.preference?(t.push(r.preference),Io.forEach(n=>{n!==r.preference&&t.push(n)})):t=Io.slice();let e,i={};for(let n=0;n<t.length;n++){const o=t[n];if(o==="webgpu"&&await Yu()){const{WebGPURenderer:a}=await _e(async()=>{const{WebGPURenderer:h}=await import("./WebGPURenderer.BhOx1ll0.js");return{WebGPURenderer:h}},__vite__mapDeps([5,6,7,2,3,4]));e=a,i={...r,...r.webgpu};break}else if(o==="webgl"&&ju(r.failIfMajorPerformanceCaveat??jh.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await _e(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer.p4DxJ1iF.js");return{WebGLRenderer:h}},__vite__mapDeps([8,6,7,2,3,4]));e=a,i={...r,...r.webgl};break}else if(o==="canvas"){const{CanvasRenderer:a}=await _e(async()=>{const{CanvasRenderer:h}=await import("./CanvasRenderer.BefGXFZ-.js");return{CanvasRenderer:h}},__vite__mapDeps([9,7,2,3,4]));e=a,i={...r,...r.canvasOptions};break}}if(delete i.webgpu,delete i.webgl,delete i.canvasOptions,!e)throw new Error("No available renderer for the current environment");const s=new e;return await s.init(i),s}const Yh="8.16.0";class Xh{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,Yh)}static destroy(){}}Xh.extension=E.Application;class Zu{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,Yh)}destroy(){this._renderer=null}}Zu.extension={type:[E.WebGLSystem,E.WebGPUSystem],name:"initHook",priority:-10};class Zh{static init(t){Object.defineProperty(this,"resizeTo",{configurable:!0,set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Zh.extension=E.Application;class qh{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{configurable:!0,set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,Ee.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?yt.shared:new yt,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}qh.extension=E.Application;$.add(Zh);$.add(qh);const Kh=class Nn{constructor(...t){this.stage=new L,t[0]!==void 0&&V(J,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.stage||(this.stage=new L),this.renderer=await Xu(t),Nn._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return V(J,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const i=Nn._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Kh._plugins=[];let $h=Kh;$.handleByList(E.Application,$h._plugins);$.add(Xh);const cn={test(r){return typeof r=="string"&&r.startsWith("info face=")},parse(r){const t=r.match(/^[a-z]+\s+.+$/gm),e={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const d in t){const u=t[d].match(/^[a-z]+/gm)[0],p=t[d].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),f={};for(const y in p){const m=p[y].split("="),x=m[0],S=m[1].replace(/"/gm,""),v=parseFloat(S),b=isNaN(v)?S:v;f[x]=b}e[u].push(f)}const i={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[s]=e.info,[n]=e.common,[o]=e.distanceField??[];o&&(i.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),i.fontSize=parseInt(s.size,10),i.fontFamily=s.face,i.lineHeight=parseInt(n.lineHeight,10);const a=e.page;for(let d=0;d<a.length;d++)i.pages.push({id:parseInt(a[d].id,10)||0,file:a[d].file});const h={};i.baseLineOffset=i.lineHeight-parseInt(n.base,10);const l=e.char;for(let d=0;d<l.length;d++){const u=l[d],p=parseInt(u.id,10);let f=u.letter??u.char??String.fromCharCode(p);f==="space"&&(f=" "),h[p]=f,i.chars[f]={id:p,page:parseInt(u.page,10)||0,x:parseInt(u.x,10),y:parseInt(u.y,10),width:parseInt(u.width,10),height:parseInt(u.height,10),xOffset:parseInt(u.xoffset,10),yOffset:parseInt(u.yoffset,10),xAdvance:parseInt(u.xadvance,10),kerning:{}}}const c=e.kerning||[];for(let d=0;d<c.length;d++){const u=parseInt(c[d].first,10),p=parseInt(c[d].second,10),f=parseInt(c[d].amount,10);i.chars[h[p]].kerning[h[u]]=f}return i}},Bo={test(r){const t=r;return typeof t!="string"&&"getElementsByTagName"in t&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(r){const t={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},e=r.getElementsByTagName("info")[0],i=r.getElementsByTagName("common")[0],s=r.getElementsByTagName("distanceField")[0];s&&(t.distanceField={type:s.getAttribute("fieldType"),range:parseInt(s.getAttribute("distanceRange"),10)});const n=r.getElementsByTagName("page"),o=r.getElementsByTagName("char"),a=r.getElementsByTagName("kerning");t.fontSize=parseInt(e.getAttribute("size"),10),t.fontFamily=e.getAttribute("face"),t.lineHeight=parseInt(i.getAttribute("lineHeight"),10);for(let l=0;l<n.length;l++)t.pages.push({id:parseInt(n[l].getAttribute("id"),10)||0,file:n[l].getAttribute("file")});const h={};t.baseLineOffset=t.lineHeight-parseInt(i.getAttribute("base"),10);for(let l=0;l<o.length;l++){const c=o[l],d=parseInt(c.getAttribute("id"),10);let u=c.getAttribute("letter")??c.getAttribute("char")??String.fromCharCode(d);u==="space"&&(u=" "),h[d]=u,t.chars[u]={id:d,page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xOffset:parseInt(c.getAttribute("xoffset"),10),yOffset:parseInt(c.getAttribute("yoffset"),10),xAdvance:parseInt(c.getAttribute("xadvance"),10),kerning:{}}}for(let l=0;l<a.length;l++){const c=parseInt(a[l].getAttribute("first"),10),d=parseInt(a[l].getAttribute("second"),10),u=parseInt(a[l].getAttribute("amount"),10);t.chars[h[d]].kerning[h[c]]=u}return t}},Do={test(r){return typeof r=="string"&&r.match(/<font(\s|>)/)?Bo.test(j.get().parseXML(r)):!1},parse(r){return Bo.parse(j.get().parseXML(r))}},qu=[".xml",".fnt"],Ku={extension:{type:E.CacheParser,name:"cacheBitmapFont"},test:r=>!!(r!=null&&r.pages)&&!!(r!=null&&r.chars)&&typeof(r==null?void 0:r.fontFamily)=="string",getCacheableAssets(r,t){const e={};return r.forEach(i=>{e[i]=t,e[`${i}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},$u={extension:{type:E.LoadParser,priority:ue.Normal},name:"loadBitmapFont",id:"bitmap-font",test(r){return qu.includes(Mt.extname(r).toLowerCase())},async testParse(r){return cn.test(r)||Do.test(r)},async parse(r,t,e){const i=cn.test(r)?cn.parse(r):Do.parse(r),{src:s}=t,{pages:n}=i,o=[],a=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let u=0;u<n.length;++u){const p=n[u].file;let f=Mt.join(Mt.dirname(s),p);f=Fn(f,s),o.push({src:f,data:a})}const[h,{BitmapFont:l}]=await Promise.all([e.load(o),_e(()=>import("./BitmapFont.DDRqV796.js"),__vite__mapDeps([10,2,3,4]))]),c=o.map(u=>h[u.src]);return new l({data:i,textures:c},s)},async load(r,t){return await(await j.get().fetch(r)).text()},async unload(r,t,e){await Promise.all(r.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),r.destroy()}};class Qu{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}const Ju={extension:{type:E.CacheParser,name:"cacheTextureArray"},test:r=>Array.isArray(r)&&r.every(t=>t instanceof G),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};async function Qh(r){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(r)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const tp={extension:{type:E.DetectionParser,priority:1},test:async()=>Qh("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")},Fo=["png","jpg","jpeg"],ep={extension:{type:E.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Fo],remove:async r=>r.filter(t=>!Fo.includes(t))},ip="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function _s(r){return ip?!1:document.createElement("video").canPlayType(r)!==""}const sp={extension:{type:E.DetectionParser,priority:0},test:async()=>_s("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")},np={extension:{type:E.DetectionParser,priority:0},test:async()=>_s("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")},rp={extension:{type:E.DetectionParser,priority:0},test:async()=>_s("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")},op={extension:{type:E.DetectionParser,priority:0},test:async()=>Qh("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")},Jh=class as{constructor(){this.loadOptions={...as.defaultOptions},this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var o,a;let s=null,n=null;if((e.parser||e.loadParser)&&(n=this._parserHash[e.parser||e.loadParser],e.loadParser&&nt(`[Assets] "loadParser" is deprecated, use "parser" instead for ${t}`),n||nt(`[Assets] specified load parser "${e.parser||e.loadParser}" not found while loading ${t}`)),!n){for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.load&&((o=l.test)!=null&&o.call(l,t,e,this))){n=l;break}}if(!n)return nt(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=await n.load(t,e,this),i.parser=n;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];l.parse&&l.parse&&await((a=l.testParse)==null?void 0:a.call(l,s,e,this))&&(s=await l.parse(s,e,this)||s,i.parser=l)}return s})(),i}async load(t,e){this._parsersValidated||this._validateParsers();const i=typeof e=="function"?{...as.defaultOptions,...this.loadOptions,onProgress:e}:{...as.defaultOptions,...this.loadOptions,...e||{}},{onProgress:s,onError:n,strategy:o,retryCount:a,retryDelay:h}=i;let l=0;const c={},d=fs(t),u=zt(t,y=>({alias:[y],src:y,data:{}})),p=u.reduce((y,m)=>y+(m.progressSize||1),0),f=u.map(async y=>{const m=Mt.toAbsolute(y.src);c[y.src]||(await this._loadAssetWithRetry(m,y,{onProgress:s,onError:n,strategy:o,retryCount:a,retryDelay:h},c),l+=y.progressSize||1,s&&s(l/p))});return await Promise.all(f),d?c[u[0].src]:c}async unload(t){const i=zt(t,s=>({alias:[s],src:s})).map(async s=>{var a,h;const n=Mt.toAbsolute(s.src),o=this.promiseCache[n];if(o){const l=await o.promise;delete this.promiseCache[n],await((h=(a=o.parser)==null?void 0:a.unload)==null?void 0:h.call(a,l,s,this))}});await Promise.all(i)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name||t.id).reduce((t,e)=>(!e.name&&!e.id?nt("[Assets] parser should have an id"):(t[e.name]||t[e.id])&&nt(`[Assets] parser id conflict "${e.id}"`),t[e.name]=e,e.id&&(t[e.id]=e),t),{})}async _loadAssetWithRetry(t,e,i,s){let n=0;const{onError:o,strategy:a,retryCount:h,retryDelay:l}=i,c=d=>new Promise(u=>setTimeout(u,d));for(;;)try{this.promiseCache[t]||(this.promiseCache[t]=this._getLoadPromiseAndParser(t,e)),s[e.src]=await this.promiseCache[t].promise;return}catch(d){delete this.promiseCache[t],delete s[e.src],n++;const u=a!=="retry"||n>h;if(a==="retry"&&!u){o&&o(d,e),await c(l);continue}if(a==="skip"){o&&o(d,e);return}o&&o(d,e);const p=new Error(`[Loader.load] Failed to load ${t}.
23
+ ${r}`}function uu(r,t){return t?r.replace("#version 300 es",""):r}const en={stripVersion:uu,ensurePrecision:au,addProgramDefines:ou,setProgramName:du,insertVersion:hu},ai=Object.create(null),Ih=class On{constructor(t){t={...On.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:ru()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let s=t.fragment,n=t.vertex;Object.keys(en).forEach(o=>{const a=i[o];s=en[o](s,a,!0),n=en[o](n,a,!1)}),this.fragment=s,this.vertex=n,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=pr(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null,ai[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return ai[e]||(ai[e]=new On(t),ai[e]._cacheKey=e),ai[e]}};Ih.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Je=Ih;const _o={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function pu(r){return _o[r]??_o.float32}const fu={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"},To=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function ko(r,t){let e;for(;(e=To.exec(r))!==null;){const i=fu[e[3]]??"float32";t[e[2]]={location:parseInt(e[1],10),format:i,stride:pu(i).stride,offset:0,instance:!1,start:0}}To.lastIndex=0}function gu(r){return r.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function mu({source:r,entryPoint:t}){const e={},i=gu(r),s=i.indexOf(`fn ${t}(`);if(s===-1)return e;const n=i.indexOf("->",s);if(n===-1)return e;const o=i.substring(s,n);if(ko(o,e),Object.keys(e).length===0){const a=o.match(/\(\s*\w+\s*:\s*(\w+)/);if(a){const h=a[1],l=new RegExp(`struct\\s+${h}\\s*\\{([^}]+)\\}`,"s"),c=i.match(l);c&&ko(c[1],e)}}return e}function sn(r){var d,u;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,s=/var(<[^>]+>)? (\w+)/,n=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=(d=r.match(t))==null?void 0:d.map(p=>({group:parseInt(p.match(e)[1],10),binding:parseInt(p.match(i)[1],10),name:p.match(s)[2],isUniform:p.match(s)[1]==="<uniform>",type:p.match(n)[1]}));if(!l)return{groups:[],structs:[]};const c=((u=r.match(o))==null?void 0:u.map(p=>{const f=p.match(h)[1],y=p.match(a).reduce((m,x)=>{const[S,v]=x.split(":");return m[S.trim()]=v.trim(),m},{});return y?{name:f,members:y}:null}).filter(({name:p})=>l.some(f=>f.type===p||f.type.includes(`<${p}>`))))??[];return{groups:l,structs:c}}var Ce=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(Ce||{});function yu({groups:r}){const t=[];for(let e=0;e<r.length;e++){const i=r[e];t[i.group]||(t[i.group]=[]),i.isUniform?t[i.group].push({binding:i.binding,visibility:Ce.VERTEX|Ce.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?t[i.group].push({binding:i.binding,visibility:Ce.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"||i.type.startsWith("texture_2d<")?t[i.group].push({binding:i.binding,visibility:Ce.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):i.type==="texture_2d_array"||i.type.startsWith("texture_2d_array<")?t[i.group].push({binding:i.binding,visibility:Ce.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(i.type==="texture_cube"||i.type.startsWith("texture_cube<"))&&t[i.group].push({binding:i.binding,visibility:Ce.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let e=0;e<t.length;e++)t[e]||(t[e]=[]);return t}function xu({groups:r}){const t=[];for(let e=0;e<r.length;e++){const i=r[e];t[i.group]||(t[i.group]={}),t[i.group][i.name]=i.binding}return t}function Su(r,t){const e=new Set,i=new Set,s=[...r.structs,...t.structs].filter(o=>e.has(o.name)?!1:(e.add(o.name),!0)),n=[...r.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return i.has(a)?!1:(i.add(a),!0)});return{structs:s,groups:n}}const hi=Object.create(null);class ce{constructor(t){var a,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:s,gpuLayout:n,name:o}=t;if(this.name=o,this.fragment=e,this.vertex=i,e.source===i.source){const l=sn(e.source);this.structsAndGroups=l}else{const l=sn(i.source),c=sn(e.source);this.structsAndGroups=Su(l,c)}this.layout=s??xu(this.structsAndGroups),this.gpuLayout=n??yu(this.structsAndGroups),this.autoAssignGlobalUniforms=((a=this.layout[0])==null?void 0:a.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=pr(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=mu(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,hi[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return hi[e]||(hi[e]=new ce(t),hi[e]._cacheKey=e),hi[e]}}const Bh=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>"],vu=Bh.reduce((r,t)=>(r[t]=!0,r),{});function bu(r,t){switch(r){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const Dh=class Fh{constructor(t,e){this._touched=0,this.uid=dt("uniform"),this._resourceType="uniformGroup",this._resourceId=dt("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...Fh.defaultOptions,...e},this.uniformStructures=t;const i={};for(const s in t){const n=t[s];if(n.name=s,n.size=n.size??1,!vu[n.type]){const o=n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){const[,a,h]=o;throw new Error(`Uniform type ${n.type} is not supported. Use type: '${a}', size: ${h} instead.`)}throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${Bh.join(", ")}`)}n.value??(n.value=bu(n.type,n.size)),i[s]=n.value}this.uniforms=i,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=pr(Object.keys(i).map(s=>`${s}-${t[s].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Dh.defaultOptions={ubo:!1,isStatic:!1};let ti=Dh;class Ci{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const s=t[i];this.setResource(s,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var s,n;const i=this.resources[e];t!==i&&(i&&((s=i.off)==null||s.call(i,"change",this.onResourceChange,this)),(n=t.on)==null||n.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t,e){const i=this.resources;for(const s in i)i[s]._gcLastUsed=t,i[s]._touched=e}destroy(){var e;const t=this.resources;for(const i in t){const s=t[i];(e=s==null?void 0:s.off)==null||e.call(s,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}var Ri=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.CANVAS=4]="CANVAS",r[r.BOTH=3]="BOTH",r))(Ri||{});class Ie extends Yt{constructor(t){super(),this.uid=dt("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:i,groups:s,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=i,o===void 0&&(o=0,e&&(o|=Ri.WEBGPU),i&&(o|=Ri.WEBGL)),this.compatibleRenderers=o;const h={};if(!n&&!s&&(n={}),n&&s)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&s&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&s&&a)for(const l in a)for(const c in a[l]){const d=a[l][c];h[d]={group:l,binding:c,name:d}}else if(e&&s&&!a){const l=e.structsAndGroups.groups;a={},l.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,h[c.name]=c})}else if(n){s={},a={},e&&e.structsAndGroups.groups.forEach(d=>{a[d.group]=a[d.group]||{},a[d.group][d.binding]=d.name,h[d.name]=d});let l=0;for(const c in n)h[c]||(s[99]||(s[99]=new Ci,this._ownedBindGroups.push(s[99])),h[c]={group:99,binding:l,name:c},a[99]=a[99]||{},a[99][l]=c,l++);for(const c in n){const d=c;let u=n[c];!u.source&&!u._resourceType&&(u=new ti(u));const p=h[d];p&&(s[p.group]||(s[p.group]=new Ci,this._ownedBindGroups.push(s[p.group])),s[p.group].setResource(u,p.binding))}}this.groups=s,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(s,h)}addResource(t,e,i){var s,n;(s=this._uniformBindMap)[e]||(s[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new Ci,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const s in e){const n=e[s];Object.defineProperty(i,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding)}})}return i}destroy(t=!1){var e,i;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(s=>{s.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){const{gpu:e,gl:i,...s}=t;let n,o;return e&&(n=ce.from(e)),i&&(o=Je.from(i)),new Ie({gpuProgram:n,glProgram:o,...s})}}const wu={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},nn=0,rn=1,on=2,an=3,hn=4,ln=5,Gn=class zh{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<nn)}set blend(t){!!(this.data&1<<nn)!==t&&(this.data^=1<<nn)}get offsets(){return!!(this.data&1<<rn)}set offsets(t){!!(this.data&1<<rn)!==t&&(this.data^=1<<rn)}set cullMode(t){if(t==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=t==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<on)}set culling(t){!!(this.data&1<<on)!==t&&(this.data^=1<<on)}get depthTest(){return!!(this.data&1<<an)}set depthTest(t){!!(this.data&1<<an)!==t&&(this.data^=1<<an)}get depthMask(){return!!(this.data&1<<ln)}set depthMask(t){!!(this.data&1<<ln)!==t&&(this.data^=1<<ln)}get clockwiseFrontFace(){return!!(this.data&1<<hn)}set clockwiseFrontFace(t){!!(this.data&1<<hn)!==t&&(this.data^=1<<hn)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=wu[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const t=new zh;return t.depthTest=!1,t.blend=!0,t}};Gn.default2d=Gn.for2d();let Gi=Gn;const Lh=class Wn extends Ie{constructor(t){t={...Wn.defaultOptions,...t},super(t),this.enabled=!0,this._state=Gi.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired&&this.addResource("uBackTexture",0,3)}apply(t,e,i,s){t.applyFilter(this,e,i,s)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const{gpu:e,gl:i,...s}=t;let n,o;return e&&(n=ce.from(e)),i&&(o=Je.from(i)),new Wn({gpuProgram:n,glProgram:o,...s})}};Lh.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let Au=Lh;const Un=[];$.handleByNamedList(E.Environment,Un);async function Cu(r){if(!r)for(let t=0;t<Un.length;t++){const e=Un[t];if(e.value.test()){await e.value.load();return}}}let li;function Pu(){if(typeof li=="boolean")return li;try{li=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{li=!1}return li}function Ro(r,t,e=2){const i=t&&t.length,s=i?t[0]*e:r.length;let n=Oh(r,0,s,e,!0);const o=[];if(!n||n.next===n.prev)return o;let a,h,l;if(i&&(n=Ru(r,t,n,e)),r.length>80*e){a=r[0],h=r[1];let c=a,d=h;for(let u=e;u<s;u+=e){const p=r[u],f=r[u+1];p<a&&(a=p),f<h&&(h=f),p>c&&(c=p),f>d&&(d=f)}l=Math.max(c-a,d-h),l=l!==0?32767/l:0}return Ei(n,o,e,a,h,l,0),o}function Oh(r,t,e,i,s){let n;if(s===Uu(r,t,e,i)>0)for(let o=t;o<e;o+=i)n=Eo(o/i|0,r[o],r[o+1],n);else for(let o=e-i;o>=t;o-=i)n=Eo(o/i|0,r[o],r[o+1],n);return n&&ei(n,n.next)&&(Bi(n),n=n.next),n}function Be(r,t){if(!r)return r;t||(t=r);let e=r,i;do if(i=!1,!e.steiner&&(ei(e,e.next)||at(e.prev,e,e.next)===0)){if(Bi(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Ei(r,t,e,i,s,n,o){if(!r)return;!o&&n&&Fu(r,i,s,n);let a=r;for(;r.prev!==r.next;){const h=r.prev,l=r.next;if(n?_u(r,i,s,n):Mu(r)){t.push(h.i,r.i,l.i),Bi(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=Tu(Be(r),t),Ei(r,t,e,i,s,n,2)):o===2&&ku(r,t,e,i,s,n):Ei(Be(r),t,e,i,s,n,1);break}}}function Mu(r){const t=r.prev,e=r,i=r.next;if(at(t,e,i)>=0)return!1;const s=t.x,n=e.x,o=i.x,a=t.y,h=e.y,l=i.y,c=Math.min(s,n,o),d=Math.min(a,h,l),u=Math.max(s,n,o),p=Math.max(a,h,l);let f=i.next;for(;f!==t;){if(f.x>=c&&f.x<=u&&f.y>=d&&f.y<=p&&xi(s,a,n,h,o,l,f.x,f.y)&&at(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function _u(r,t,e,i){const s=r.prev,n=r,o=r.next;if(at(s,n,o)>=0)return!1;const a=s.x,h=n.x,l=o.x,c=s.y,d=n.y,u=o.y,p=Math.min(a,h,l),f=Math.min(c,d,u),y=Math.max(a,h,l),m=Math.max(c,d,u),x=Hn(p,f,t,e,i),S=Hn(y,m,t,e,i);let v=r.prevZ,b=r.nextZ;for(;v&&v.z>=x&&b&&b.z<=S;){if(v.x>=p&&v.x<=y&&v.y>=f&&v.y<=m&&v!==s&&v!==o&&xi(a,c,h,d,l,u,v.x,v.y)&&at(v.prev,v,v.next)>=0||(v=v.prevZ,b.x>=p&&b.x<=y&&b.y>=f&&b.y<=m&&b!==s&&b!==o&&xi(a,c,h,d,l,u,b.x,b.y)&&at(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;v&&v.z>=x;){if(v.x>=p&&v.x<=y&&v.y>=f&&v.y<=m&&v!==s&&v!==o&&xi(a,c,h,d,l,u,v.x,v.y)&&at(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=S;){if(b.x>=p&&b.x<=y&&b.y>=f&&b.y<=m&&b!==s&&b!==o&&xi(a,c,h,d,l,u,b.x,b.y)&&at(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Tu(r,t){let e=r;do{const i=e.prev,s=e.next.next;!ei(i,s)&&Wh(i,e,e.next,s)&&Ii(i,s)&&Ii(s,i)&&(t.push(i.i,e.i,s.i),Bi(e),Bi(e.next),e=r=s),e=e.next}while(e!==r);return Be(e)}function ku(r,t,e,i,s,n){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Ou(o,a)){let h=Uh(o,a);o=Be(o,o.next),h=Be(h,h.next),Ei(o,t,e,i,s,n,0),Ei(h,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function Ru(r,t,e,i){const s=[];for(let n=0,o=t.length;n<o;n++){const a=t[n]*i,h=n<o-1?t[n+1]*i:r.length,l=Oh(r,a,h,i,!1);l===l.next&&(l.steiner=!0),s.push(Lu(l))}s.sort(Eu);for(let n=0;n<s.length;n++)e=Iu(s[n],e);return e}function Eu(r,t){let e=r.x-t.x;if(e===0&&(e=r.y-t.y,e===0)){const i=(r.next.y-r.y)/(r.next.x-r.x),s=(t.next.y-t.y)/(t.next.x-t.x);e=i-s}return e}function Iu(r,t){const e=Bu(r,t);if(!e)return t;const i=Uh(e,r);return Be(i,i.next),Be(e,e.next)}function Bu(r,t){let e=t;const i=r.x,s=r.y;let n=-1/0,o;if(ei(r,e))return e;do{if(ei(r,e.next))return e.next;if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){const d=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=i&&d>n&&(n=d,o=e.x<e.next.x?e:e.next,d===i))return o}e=e.next}while(e!==t);if(!o)return null;const a=o,h=o.x,l=o.y;let c=1/0;e=o;do{if(i>=e.x&&e.x>=h&&i!==e.x&&Gh(s<l?i:n,s,h,l,s<l?n:i,s,e.x,e.y)){const d=Math.abs(s-e.y)/(i-e.x);Ii(e,r)&&(d<c||d===c&&(e.x>o.x||e.x===o.x&&Du(o,e)))&&(o=e,c=d)}e=e.next}while(e!==a);return o}function Du(r,t){return at(r.prev,r,t.prev)<0&&at(t.next,r,r.next)<0}function Fu(r,t,e,i){let s=r;do s.z===0&&(s.z=Hn(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,zu(s)}function zu(r){let t,e=1;do{let i=r,s;r=null;let n=null;for(t=0;i;){t++;let o=i,a=0;for(let l=0;l<e&&(a++,o=o.nextZ,!!o);l++);let h=e;for(;a>0||h>0&&o;)a!==0&&(h===0||!o||i.z<=o.z)?(s=i,i=i.nextZ,a--):(s=o,o=o.nextZ,h--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;i=o}n.nextZ=null,e*=2}while(t>1);return r}function Hn(r,t,e,i,s){return r=(r-e)*s|0,t=(t-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function Lu(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function Gh(r,t,e,i,s,n,o,a){return(s-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function xi(r,t,e,i,s,n,o,a){return!(r===o&&t===a)&&Gh(r,t,e,i,s,n,o,a)}function Ou(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Gu(r,t)&&(Ii(r,t)&&Ii(t,r)&&Wu(r,t)&&(at(r.prev,r,t.prev)||at(r,t.prev,t))||ei(r,t)&&at(r.prev,r,r.next)>0&&at(t.prev,t,t.next)>0)}function at(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function ei(r,t){return r.x===t.x&&r.y===t.y}function Wh(r,t,e,i){const s=ts(at(r,t,e)),n=ts(at(r,t,i)),o=ts(at(e,i,r)),a=ts(at(e,i,t));return!!(s!==n&&o!==a||s===0&&Ji(r,e,t)||n===0&&Ji(r,i,t)||o===0&&Ji(e,r,i)||a===0&&Ji(e,t,i))}function Ji(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function ts(r){return r>0?1:r<0?-1:0}function Gu(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&Wh(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Ii(r,t){return at(r.prev,r,r.next)<0?at(r,t,r.next)>=0&&at(r,r.prev,t)>=0:at(r,t,r.prev)<0||at(r,r.next,t)<0}function Wu(r,t){let e=r,i=!1;const s=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function Uh(r,t){const e=Vn(r.i,r.x,r.y),i=Vn(t.i,t.x,t.y),s=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function Eo(r,t,e,i){const s=Vn(r,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Bi(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Vn(r,t,e){return{i:r,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Uu(r,t,e,i){let s=0;for(let n=t,o=e-i;n<e;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}const Hu=Ro.default||Ro;var Hh=(r=>(r[r.NONE=0]="NONE",r[r.COLOR=16384]="COLOR",r[r.STENCIL=1024]="STENCIL",r[r.DEPTH=256]="DEPTH",r[r.COLOR_DEPTH=16640]="COLOR_DEPTH",r[r.COLOR_STENCIL=17408]="COLOR_STENCIL",r[r.DEPTH_STENCIL=1280]="DEPTH_STENCIL",r[r.ALL=17664]="ALL",r))(Hh||{});class Vu{constructor(t){this.items=[],this._name=t}emit(t,e,i,s,n,o,a,h){const{name:l,items:c}=this;for(let d=0,u=c.length;d<u;d++)c[d][l](t,e,i,s,n,o,a,h);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&this.items.splice(e,1),this}contains(t){return this.items.indexOf(t)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}const Nu=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Vh=class Nh extends Yt{constructor(t){super(),this.tick=0,this.uid=dt("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const e=[...Nu,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await Cu(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash)t={...this._systemsHash[i].constructor.defaultOptions,...t};t={...Nh.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let i=0;i<this.runners.init.items.length;i++)await this.runners.init.items[i].init(t);this._initOptions=t}render(t,e){this.tick++;let i=t;if(i instanceof L&&(i={container:i},e&&(V(J,"passing a second argument is deprecated, please use render options instead"),i.target=e.renderTexture)),i.target||(i.target=this.view.renderTarget),i.target===this.view.renderTarget&&(this._lastObjectRendered=i.container,i.clearColor??(i.clearColor=this.background.colorRgba),i.clear??(i.clear=this.background.clearBeforeRender)),i.clearColor){const s=Array.isArray(i.clearColor)&&i.clearColor.length===4;i.clearColor=s?i.clearColor:rt.shared.setValue(i.clearColor).toArray()}i.transform||(i.container.updateLocalTransform(),i.transform=i.container.localTransform),i.container.visible&&(i.container.enableRenderGroup(),this.runners.prerender.emit(i),this.runners.renderStart.emit(i),this.runners.render.emit(i),this.runners.renderEnd.emit(i),this.runners.postrender.emit(i))}resize(t,e,i){const s=this.view.resolution;this.view.resize(t,e,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),i!==void 0&&i!==s&&this.runners.resolutionChange.emit(i)}clear(t={}){const e=this;t.target||(t.target=e.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=Hh.ALL);const{clear:i,clearColor:s,target:n,mipLevel:o,layer:a}=t;rt.shared.setValue(s??this.background.colorRgba),e.renderTarget.clear(n,i,rt.shared.toArray(),o??0,a??0)}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(e=>{this.runners[e]=new Vu(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const s in this.runners)this.runners[s].add(i);return this}_addPipes(t,e){const i=e.reduce((s,n)=>(s[n.name]=n.value,s),{});t.forEach(s=>{const n=s.value,o=s.name,a=i[o];this.renderPipes[o]=new n(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),(t===!0||typeof t=="object"&&t.releaseGlobalResources)&&Oi.release(),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Pu())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};Vh.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let jh=Vh,es;function ju(r){return es!==void 0||(es=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:r??jh.defaultOptions.failIfMajorPerformanceCaveat};try{if(!j.get().getWebGLRenderingContext())return!1;let s=j.get().createCanvas().getContext("webgl",t);const n=!!((e=s==null?void 0:s.getContextAttributes())!=null&&e.stencil);if(s){const o=s.getExtension("WEBGL_lose_context");o&&o.loseContext()}return s=null,n}catch{return!1}})()),es}let is;async function Yu(r={}){return is!==void 0||(is=await(async()=>{const t=j.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(r)).requestDevice(),!0}catch{return!1}})()),is}const Io=["webgl","webgpu","canvas"];async function Xu(r){let t=[];r.preference?(t.push(r.preference),Io.forEach(n=>{n!==r.preference&&t.push(n)})):t=Io.slice();let e,i={};for(let n=0;n<t.length;n++){const o=t[n];if(o==="webgpu"&&await Yu()){const{WebGPURenderer:a}=await _e(async()=>{const{WebGPURenderer:h}=await import("./WebGPURenderer.CgbaDBMF.js");return{WebGPURenderer:h}},__vite__mapDeps([5,6,7,2,3,4]));e=a,i={...r,...r.webgpu};break}else if(o==="webgl"&&ju(r.failIfMajorPerformanceCaveat??jh.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await _e(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer.DuuxSWTv.js");return{WebGLRenderer:h}},__vite__mapDeps([8,6,7,2,3,4]));e=a,i={...r,...r.webgl};break}else if(o==="canvas"){const{CanvasRenderer:a}=await _e(async()=>{const{CanvasRenderer:h}=await import("./CanvasRenderer.BG9dkLJp.js");return{CanvasRenderer:h}},__vite__mapDeps([9,7,2,3,4]));e=a,i={...r,...r.canvasOptions};break}}if(delete i.webgpu,delete i.webgl,delete i.canvasOptions,!e)throw new Error("No available renderer for the current environment");const s=new e;return await s.init(i),s}const Yh="8.16.0";class Xh{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,Yh)}static destroy(){}}Xh.extension=E.Application;class Zu{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,Yh)}destroy(){this._renderer=null}}Zu.extension={type:[E.WebGLSystem,E.WebGPUSystem],name:"initHook",priority:-10};class Zh{static init(t){Object.defineProperty(this,"resizeTo",{configurable:!0,set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Zh.extension=E.Application;class qh{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{configurable:!0,set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,Ee.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?yt.shared:new yt,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}qh.extension=E.Application;$.add(Zh);$.add(qh);const Kh=class Nn{constructor(...t){this.stage=new L,t[0]!==void 0&&V(J,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.stage||(this.stage=new L),this.renderer=await Xu(t),Nn._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return V(J,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const i=Nn._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Kh._plugins=[];let $h=Kh;$.handleByList(E.Application,$h._plugins);$.add(Xh);const cn={test(r){return typeof r=="string"&&r.startsWith("info face=")},parse(r){const t=r.match(/^[a-z]+\s+.+$/gm),e={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const d in t){const u=t[d].match(/^[a-z]+/gm)[0],p=t[d].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),f={};for(const y in p){const m=p[y].split("="),x=m[0],S=m[1].replace(/"/gm,""),v=parseFloat(S),b=isNaN(v)?S:v;f[x]=b}e[u].push(f)}const i={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[s]=e.info,[n]=e.common,[o]=e.distanceField??[];o&&(i.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),i.fontSize=parseInt(s.size,10),i.fontFamily=s.face,i.lineHeight=parseInt(n.lineHeight,10);const a=e.page;for(let d=0;d<a.length;d++)i.pages.push({id:parseInt(a[d].id,10)||0,file:a[d].file});const h={};i.baseLineOffset=i.lineHeight-parseInt(n.base,10);const l=e.char;for(let d=0;d<l.length;d++){const u=l[d],p=parseInt(u.id,10);let f=u.letter??u.char??String.fromCharCode(p);f==="space"&&(f=" "),h[p]=f,i.chars[f]={id:p,page:parseInt(u.page,10)||0,x:parseInt(u.x,10),y:parseInt(u.y,10),width:parseInt(u.width,10),height:parseInt(u.height,10),xOffset:parseInt(u.xoffset,10),yOffset:parseInt(u.yoffset,10),xAdvance:parseInt(u.xadvance,10),kerning:{}}}const c=e.kerning||[];for(let d=0;d<c.length;d++){const u=parseInt(c[d].first,10),p=parseInt(c[d].second,10),f=parseInt(c[d].amount,10);i.chars[h[p]].kerning[h[u]]=f}return i}},Bo={test(r){const t=r;return typeof t!="string"&&"getElementsByTagName"in t&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(r){const t={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},e=r.getElementsByTagName("info")[0],i=r.getElementsByTagName("common")[0],s=r.getElementsByTagName("distanceField")[0];s&&(t.distanceField={type:s.getAttribute("fieldType"),range:parseInt(s.getAttribute("distanceRange"),10)});const n=r.getElementsByTagName("page"),o=r.getElementsByTagName("char"),a=r.getElementsByTagName("kerning");t.fontSize=parseInt(e.getAttribute("size"),10),t.fontFamily=e.getAttribute("face"),t.lineHeight=parseInt(i.getAttribute("lineHeight"),10);for(let l=0;l<n.length;l++)t.pages.push({id:parseInt(n[l].getAttribute("id"),10)||0,file:n[l].getAttribute("file")});const h={};t.baseLineOffset=t.lineHeight-parseInt(i.getAttribute("base"),10);for(let l=0;l<o.length;l++){const c=o[l],d=parseInt(c.getAttribute("id"),10);let u=c.getAttribute("letter")??c.getAttribute("char")??String.fromCharCode(d);u==="space"&&(u=" "),h[d]=u,t.chars[u]={id:d,page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xOffset:parseInt(c.getAttribute("xoffset"),10),yOffset:parseInt(c.getAttribute("yoffset"),10),xAdvance:parseInt(c.getAttribute("xadvance"),10),kerning:{}}}for(let l=0;l<a.length;l++){const c=parseInt(a[l].getAttribute("first"),10),d=parseInt(a[l].getAttribute("second"),10),u=parseInt(a[l].getAttribute("amount"),10);t.chars[h[d]].kerning[h[c]]=u}return t}},Do={test(r){return typeof r=="string"&&r.match(/<font(\s|>)/)?Bo.test(j.get().parseXML(r)):!1},parse(r){return Bo.parse(j.get().parseXML(r))}},qu=[".xml",".fnt"],Ku={extension:{type:E.CacheParser,name:"cacheBitmapFont"},test:r=>!!(r!=null&&r.pages)&&!!(r!=null&&r.chars)&&typeof(r==null?void 0:r.fontFamily)=="string",getCacheableAssets(r,t){const e={};return r.forEach(i=>{e[i]=t,e[`${i}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},$u={extension:{type:E.LoadParser,priority:ue.Normal},name:"loadBitmapFont",id:"bitmap-font",test(r){return qu.includes(Mt.extname(r).toLowerCase())},async testParse(r){return cn.test(r)||Do.test(r)},async parse(r,t,e){const i=cn.test(r)?cn.parse(r):Do.parse(r),{src:s}=t,{pages:n}=i,o=[],a=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let u=0;u<n.length;++u){const p=n[u].file;let f=Mt.join(Mt.dirname(s),p);f=Fn(f,s),o.push({src:f,data:a})}const[h,{BitmapFont:l}]=await Promise.all([e.load(o),_e(()=>import("./BitmapFont.ZlRh5xJO.js"),__vite__mapDeps([10,2,3,4]))]),c=o.map(u=>h[u.src]);return new l({data:i,textures:c},s)},async load(r,t){return await(await j.get().fetch(r)).text()},async unload(r,t,e){await Promise.all(r.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),r.destroy()}};class Qu{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}const Ju={extension:{type:E.CacheParser,name:"cacheTextureArray"},test:r=>Array.isArray(r)&&r.every(t=>t instanceof G),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};async function Qh(r){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(r)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const tp={extension:{type:E.DetectionParser,priority:1},test:async()=>Qh("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")},Fo=["png","jpg","jpeg"],ep={extension:{type:E.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Fo],remove:async r=>r.filter(t=>!Fo.includes(t))},ip="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function _s(r){return ip?!1:document.createElement("video").canPlayType(r)!==""}const sp={extension:{type:E.DetectionParser,priority:0},test:async()=>_s("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")},np={extension:{type:E.DetectionParser,priority:0},test:async()=>_s("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")},rp={extension:{type:E.DetectionParser,priority:0},test:async()=>_s("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")},op={extension:{type:E.DetectionParser,priority:0},test:async()=>Qh("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")},Jh=class as{constructor(){this.loadOptions={...as.defaultOptions},this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var o,a;let s=null,n=null;if((e.parser||e.loadParser)&&(n=this._parserHash[e.parser||e.loadParser],e.loadParser&&nt(`[Assets] "loadParser" is deprecated, use "parser" instead for ${t}`),n||nt(`[Assets] specified load parser "${e.parser||e.loadParser}" not found while loading ${t}`)),!n){for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.load&&((o=l.test)!=null&&o.call(l,t,e,this))){n=l;break}}if(!n)return nt(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=await n.load(t,e,this),i.parser=n;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];l.parse&&l.parse&&await((a=l.testParse)==null?void 0:a.call(l,s,e,this))&&(s=await l.parse(s,e,this)||s,i.parser=l)}return s})(),i}async load(t,e){this._parsersValidated||this._validateParsers();const i=typeof e=="function"?{...as.defaultOptions,...this.loadOptions,onProgress:e}:{...as.defaultOptions,...this.loadOptions,...e||{}},{onProgress:s,onError:n,strategy:o,retryCount:a,retryDelay:h}=i;let l=0;const c={},d=fs(t),u=zt(t,y=>({alias:[y],src:y,data:{}})),p=u.reduce((y,m)=>y+(m.progressSize||1),0),f=u.map(async y=>{const m=Mt.toAbsolute(y.src);c[y.src]||(await this._loadAssetWithRetry(m,y,{onProgress:s,onError:n,strategy:o,retryCount:a,retryDelay:h},c),l+=y.progressSize||1,s&&s(l/p))});return await Promise.all(f),d?c[u[0].src]:c}async unload(t){const i=zt(t,s=>({alias:[s],src:s})).map(async s=>{var a,h;const n=Mt.toAbsolute(s.src),o=this.promiseCache[n];if(o){const l=await o.promise;delete this.promiseCache[n],await((h=(a=o.parser)==null?void 0:a.unload)==null?void 0:h.call(a,l,s,this))}});await Promise.all(i)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name||t.id).reduce((t,e)=>(!e.name&&!e.id?nt("[Assets] parser should have an id"):(t[e.name]||t[e.id])&&nt(`[Assets] parser id conflict "${e.id}"`),t[e.name]=e,e.id&&(t[e.id]=e),t),{})}async _loadAssetWithRetry(t,e,i,s){let n=0;const{onError:o,strategy:a,retryCount:h,retryDelay:l}=i,c=d=>new Promise(u=>setTimeout(u,d));for(;;)try{this.promiseCache[t]||(this.promiseCache[t]=this._getLoadPromiseAndParser(t,e)),s[e.src]=await this.promiseCache[t].promise;return}catch(d){delete this.promiseCache[t],delete s[e.src],n++;const u=a!=="retry"||n>h;if(a==="retry"&&!u){o&&o(d,e),await c(l);continue}if(a==="skip"){o&&o(d,e);return}o&&o(d,e);const p=new Error(`[Loader.load] Failed to load ${t}.
24
24
  ${d}`);throw d instanceof Error&&d.stack&&(p.stack=d.stack),p}}};Jh.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let ap=Jh;function pe(r,t){if(Array.isArray(t)){for(const e of t)if(r.startsWith(`data:${e}`))return!0;return!1}return r.startsWith(`data:${t}`)}function ni(r,t){const e=r.split("?")[0],i=Mt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const hp=".json",lp="application/json",cp={extension:{type:E.LoadParser,priority:ue.Low},name:"loadJson",id:"json",test(r){return pe(r,lp)||ni(r,hp)},async load(r){return await(await j.get().fetch(r)).json()}},dp=".txt",up="text/plain",pp={name:"loadTxt",id:"text",extension:{type:E.LoadParser,priority:ue.Low,name:"loadTxt"},test(r){return pe(r,up)||ni(r,dp)},async load(r){return await(await j.get().fetch(r)).text()}},fp=["normal","bold","100","200","300","400","500","600","700","800","900"],gp=[".ttf",".otf",".woff",".woff2"],mp=["font/ttf","font/otf","font/woff","font/woff2"],yp=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function xp(r){const t=Mt.extname(r),s=Mt.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1));let n=s.length>0;for(const a of s)if(!a.match(yp)){n=!1;break}let o=s.join(" ");return n||(o=`"${o.replace(/[\\"]/g,"\\$&")}"`),o}const Sp=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function vp(r){return Sp.test(r)?r:encodeURI(r)}const bp={extension:{type:E.LoadParser,priority:ue.Low},name:"loadWebFont",id:"web-font",test(r){return pe(r,mp)||ni(r,gp)},async load(r,t){var i,s,n;const e=j.get().getFontFaceSet();if(e){const o=[],a=((i=t.data)==null?void 0:i.family)??xp(r),h=((n=(s=t.data)==null?void 0:s.weights)==null?void 0:n.filter(c=>fp.includes(c)))??["normal"],l=t.data??{};for(let c=0;c<h.length;c++){const d=h[c],u=new FontFace(a,`url(${vp(r)})`,{...l,weight:d});await u.load(),e.add(u),o.push(u)}return xt.has(`${a}-and-url`)?xt.get(`${a}-and-url`).entries.push({url:r,faces:o}):xt.set(`${a}-and-url`,{entries:[{url:r,faces:o}]}),o.length===1?o[0]:o}return nt("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(r){const t=Array.isArray(r)?r:[r],e=t[0].family,i=xt.get(`${e}-and-url`),s=i.entries.find(n=>n.faces.some(o=>t.indexOf(o)!==-1));s.faces=s.faces.filter(n=>t.indexOf(n)===-1),s.faces.length===0&&(i.entries=i.entries.filter(n=>n!==s)),t.forEach(n=>{j.get().getFontFaceSet().delete(n)}),i.entries.length===0&&xt.remove(`${e}-and-url`)}};var wp=Cp,dn={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Ap=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function Cp(r){var t=[];return r.replace(Ap,function(e,i,s){var n=i.toLowerCase();for(s=Mp(s),n=="m"&&s.length>2&&(t.push([i].concat(s.splice(0,2))),n="l",i=i=="m"?"l":"L");;){if(s.length==dn[n])return s.unshift(i),t.push(s);if(s.length<dn[n])throw new Error("malformed path data");t.push([i].concat(s.splice(0,dn[n])))}}),t}var Pp=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function Mp(r){var t=r.match(Pp);return t?t.map(Number):[]}const _p=qa(wp);function Tp(r,t){const e=_p(r),i=[];let s=null,n=0,o=0;for(let a=0;a<e.length;a++){const h=e[a],l=h[0],c=h;switch(l){case"M":n=c[1],o=c[2],t.moveTo(n,o);break;case"m":n+=c[1],o+=c[2],t.moveTo(n,o);break;case"H":n=c[1],t.lineTo(n,o);break;case"h":n+=c[1],t.lineTo(n,o);break;case"V":o=c[1],t.lineTo(n,o);break;case"v":o+=c[1],t.lineTo(n,o);break;case"L":n=c[1],o=c[2],t.lineTo(n,o);break;case"l":n+=c[1],o+=c[2],t.lineTo(n,o);break;case"C":n=c[5],o=c[6],t.bezierCurveTo(c[1],c[2],c[3],c[4],n,o);break;case"c":t.bezierCurveTo(n+c[1],o+c[2],n+c[3],o+c[4],n+c[5],o+c[6]),n+=c[5],o+=c[6];break;case"S":n=c[3],o=c[4],t.bezierCurveToShort(c[1],c[2],n,o);break;case"s":t.bezierCurveToShort(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"Q":n=c[3],o=c[4],t.quadraticCurveTo(c[1],c[2],n,o);break;case"q":t.quadraticCurveTo(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"T":n=c[1],o=c[2],t.quadraticCurveToShort(n,o);break;case"t":n+=c[1],o+=c[2],t.quadraticCurveToShort(n,o);break;case"A":n=c[6],o=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"a":n+=c[6],o+=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"Z":case"z":t.closePath(),i.length>0&&(s=i.pop(),s?(n=s.startX,o=s.startY):(n=0,o=0)),s=null;break;default:nt(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&s===null&&(s={startX:n,startY:o},i.push(s))}return t}class Ts{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new Ts(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}strokeContains(t,e,i,s=.5){if(this.radius===0)return!1;const n=this.x-t,o=this.y-e,a=this.radius,h=(1-s)*i,l=Math.sqrt(n*n+o*o);return l<=a+h&&l>a-(i-h)}getBounds(t){return t||(t=new et),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class fr{constructor(t=0,e=0,i=0,s=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=s}clone(){return new fr(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,s=(e-this.y)/this.halfHeight;return i*=i,s*=s,i+s<=1}strokeContains(t,e,i,s=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=i*(1-s),h=i-a,l=n-h,c=o-h,d=n+a,u=o+a,p=t-this.x,f=e-this.y,y=p*p/(l*l)+f*f/(c*c),m=p*p/(d*d)+f*f/(u*u);return y>1&&m<=1}getBounds(t){return t||(t=new et),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function kp(r,t,e,i,s,n){const o=r-e,a=t-i,h=s-e,l=n-i,c=o*h+a*l,d=h*h+l*l;let u=-1;d!==0&&(u=c/d);let p,f;u<0?(p=e,f=i):u>1?(p=s,f=n):(p=e+u*h,f=i+u*l);const y=r-p,m=t-f;return y*y+m*m}let Rp,Ep;class Te{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let s=0,n=e.length;s<n;s++)i.push(e[s].x,e[s].y);e=i}this.points=e,this.closePath=!0}isClockwise(){let t=0;const e=this.points,i=e.length;for(let s=0;s<i;s+=2){const n=e[s],o=e[s+1],a=e[(s+2)%i],h=e[(s+3)%i];t+=(a-n)*(h+o)}return t<0}containsPolygon(t){const e=this.getBounds(Rp),i=t.getBounds(Ep);if(!e.containsRect(i))return!1;const s=t.points;for(let n=0;n<s.length;n+=2){const o=s[n],a=s[n+1];if(!this.contains(o,a))return!1}return!0}clone(){const t=this.points.slice(),e=new Te(t);return e.closePath=this.closePath,e}contains(t,e){let i=!1;const s=this.points.length/2;for(let n=0,o=s-1;n<s;o=n++){const a=this.points[n*2],h=this.points[n*2+1],l=this.points[o*2],c=this.points[o*2+1];h>e!=c>e&&t<(l-a)*((e-h)/(c-h))+a&&(i=!i)}return i}strokeContains(t,e,i,s=.5){const n=i*i,o=n*(1-s),a=n-o,{points:h}=this,l=h.length-(this.closePath?0:2);for(let c=0;c<l;c+=2){const d=h[c],u=h[c+1],p=h[(c+2)%h.length],f=h[(c+3)%h.length],y=kp(t,e,d,u,p,f),m=Math.sign((p-d)*(e-u)-(f-u)*(t-d));if(y<=(m<0?a:o))return!0}return!1}getBounds(t){t||(t=new et);const e=this.points;let i=1/0,s=-1/0,n=1/0,o=-1/0;for(let a=0,h=e.length;a<h;a+=2){const l=e[a],c=e[a+1];i=l<i?l:i,s=l>s?l:s,n=c<n?c:n,o=c>o?c:o}return t.x=i,t.width=s-i,t.y=n,t.height=o-n,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return V("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return V("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const ss=(r,t,e,i,s,n,o)=>{const a=r-e,h=t-i,l=Math.sqrt(a*a+h*h);return l>=s-n&&l<=s+o};class gr{constructor(t=0,e=0,i=0,s=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n}getBounds(t){return t||(t=new et),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new gr(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let s=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(s*s+n*n<=o||(s=t-(this.x+this.width-i),s*s+n*n<=o)||(n=e-(this.y+this.height-i),s*s+n*n<=o)||(s=t-(this.x+i),s*s+n*n<=o))return!0}return!1}strokeContains(t,e,i,s=.5){const{x:n,y:o,width:a,height:h,radius:l}=this,c=i*(1-s),d=i-c,u=n+l,p=o+l,f=a-l*2,y=h-l*2,m=n+a,x=o+h;return(t>=n-c&&t<=n+d||t>=m-d&&t<=m+c)&&e>=p&&e<=p+y||(e>=o-c&&e<=o+d||e>=x-d&&e<=x+c)&&t>=u&&t<=u+f?!0:t<u&&e<p&&ss(t,e,u,p,l,d,c)||t>m-l&&e<p&&ss(t,e,m-l,p,l,d,c)||t>m-l&&e>x-l&&ss(t,e,m-l,x-l,l,d,c)||t<u&&e>x-l&&ss(t,e,u,x-l,l,d,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const tl={};function Ip(r,t,e){let i=2166136261;for(let s=0;s<t;s++)i^=r[s].uid,i=Math.imul(i,16777619),i>>>=0;return tl[i]||Bp(r,t,i,e)}function Bp(r,t,e,i){const s={};let n=0;for(let a=0;a<i;a++){const h=a<t?r[a]:G.EMPTY.source;s[n++]=h.source,s[n++]=h.style}const o=new Ci(s);return tl[e]=o,o}class zo{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this.uint32View=null,this.float32View=null,this.uint16View=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._int32View=null,this._float64Array=null,this._bigUint64Array=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}function Lo(r,t,e,i){if(e??(e=0),i??(i=Math.min(r.byteLength-e,t.byteLength)),!(e&7)&&!(i&7)){const s=i/8;new Float64Array(t,0,s).set(new Float64Array(r,e,s))}else if(!(e&3)&&!(i&3)){const s=i/4;new Float32Array(t,0,s).set(new Float32Array(r,e,s))}else new Uint8Array(t).set(new Uint8Array(r,e,i))}const Dp={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var Fp=(r=>(r[r.DISABLED=0]="DISABLED",r[r.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",r[r.MASK_ACTIVE=2]="MASK_ACTIVE",r[r.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",r[r.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",r[r.NONE=5]="NONE",r))(Fp||{});function gs(r,t){return t.alphaMode==="no-premultiply-alpha"&&Dp[r]||r}const zp=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
25
25
  `);function Lp(r){let t="";for(let e=0;e<r;++e)e>0&&(t+=`
26
26
  else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function Op(r,t){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const i=zp.replace(/%forloop%/gi,Lp(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}}finally{t.deleteShader(e)}return r}let Le=null;function Gp(){var t;if(Le)return Le;const r=Eh();return Le=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),Le=Op(Le,r),(t=r.getExtension("WEBGL_lose_context"))==null||t.loseContext(),Le}class Wp{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}class Up{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Wp,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}}const Pi=[];let ms=0;Oi.register({clear:()=>{if(Pi.length>0)for(const r of Pi)r&&r.destroy();Pi.length=0,ms=0}});function Oo(){return ms>0?Pi[--ms]:new Up}function Go(r){r.elements=null,Pi[ms++]=r}let ci=0;const el=class il{constructor(t){this.uid=dt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...il.defaultOptions,...t},t.maxTextures||(V("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=Gp());const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:s}=t;this.attributeBuffer=new zo(i*4),this.indexBuffer=new Uint16Array(s),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)Go(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const i=t._batch.textures.ids[e._source.uid];return!i&&i!==0?!1:(t._textureId=i,t.texture=e,!0)}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let i=Oo(),s=i.textures;s.clear();const n=e[this.elementStart];let o=gs(n.blendMode,n.texture._source),a=n.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const h=this.attributeBuffer.float32View,l=this.attributeBuffer.uint32View,c=this.indexBuffer;let d=this._batchIndexSize,u=this._batchIndexStart,p="startBatch",f=[];const y=this.maxTextures;for(let m=this.elementStart;m<this.elementSize;++m){const x=e[m];e[m]=null;const v=x.texture._source,b=gs(x.blendMode,v),P=o!==b||a!==x.topology;if(v._batchTick===ci&&!P){x._textureId=v._textureBindLocation,d+=x.indexSize,x.packAsQuad?(this.packQuadAttributes(x,h,l,x._attributeStart,x._textureId),this.packQuadIndex(c,x._indexStart,x._attributeStart/this.vertexSize)):(this.packAttributes(x,h,l,x._attributeStart,x._textureId),this.packIndex(x,c,x._indexStart,x._attributeStart/this.vertexSize)),x._batch=i,f.push(x);continue}v._batchTick=ci,(s.count>=y||P)&&(this._finishBatch(i,u,d-u,s,o,a,t,p,f),p="renderBatch",u=d,o=b,a=x.topology,i=Oo(),s=i.textures,s.clear(),f=[],++ci),x._textureId=v._textureBindLocation=s.count,s.ids[v.uid]=s.count,s.textures[s.count++]=v,x._batch=i,f.push(x),d+=x.indexSize,x.packAsQuad?(this.packQuadAttributes(x,h,l,x._attributeStart,x._textureId),this.packQuadIndex(c,x._indexStart,x._attributeStart/this.vertexSize)):(this.packAttributes(x,h,l,x._attributeStart,x._textureId),this.packIndex(x,c,x._indexStart,x._attributeStart/this.vertexSize))}s.count>0&&(this._finishBatch(i,u,d-u,s,o,a,t,p,f),u=d,++ci),this.elementStart=this.elementSize,this._batchIndexStart=u,this._batchIndexSize=d}_finishBatch(t,e,i,s,n,o,a,h,l){t.gpuBindGroup=null,t.bindGroup=null,t.action=h,t.batcher=this,t.textures=s,t.blendMode=n,t.topology=o,t.start=e,t.size=i,t.elements=l,++ci,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),i=new zo(e);Lo(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const s=i>65535?new Uint32Array(i):new Uint16Array(i);if(s.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n<e.length;n++)s[n]=e[n];else Lo(e.buffer,s.buffer);this.indexBuffer=s}packQuadIndex(t,e,i){t[e]=i+0,t[e+1]=i+1,t[e+2]=i+2,t[e+3]=i+0,t[e+4]=i+2,t[e+5]=i+3}packIndex(t,e,i,s){const n=t.indices,o=t.indexSize,a=t.indexOffset,h=t.attributeOffset;for(let l=0;l<o;l++)e[i++]=s+n[l+a]-h}destroy(t={}){var e;if(this.batches!==null){for(let i=0;i<this.batchIndex;i++)Go(this.batches[i]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,t.shader&&((e=this.shader)==null||e.destroy(),this.shader=null);for(let i=0;i<this._elements.length;i++)this._elements[i]&&(this._elements[i]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};el.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Hp=el;var gt=(r=>(r[r.MAP_READ=1]="MAP_READ",r[r.MAP_WRITE=2]="MAP_WRITE",r[r.COPY_SRC=4]="COPY_SRC",r[r.COPY_DST=8]="COPY_DST",r[r.INDEX=16]="INDEX",r[r.VERTEX=32]="VERTEX",r[r.UNIFORM=64]="UNIFORM",r[r.STORAGE=128]="STORAGE",r[r.INDIRECT=256]="INDIRECT",r[r.QUERY_RESOLVE=512]="QUERY_RESOLVE",r[r.STATIC=1024]="STATIC",r))(gt||{});class le extends Yt{constructor(t){let{data:e,size:i}=t;const{usage:s,label:n,shrinkToFit:o}=t;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=dt("buffer"),this._resourceType="buffer",this._resourceId=dt("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i??(i=e==null?void 0:e.byteLength);const a=!!e;this.descriptor={size:i,usage:s,mappedAtCreation:a,label:n},this.shrinkToFit=o??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&gt.STATIC)}set static(t){t?this.descriptor.usage|=gt.STATIC:this.descriptor.usage&=~gt.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const s=this._data;if(this._data=t,this._dataInt32=null,!s||s.length!==t.length){!this.shrinkToFit&&s&&t.byteLength<s.byteLength?i&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=dt("resource"),this.emit("change",this));return}i&&this.emit("update",this)}update(t){this._updateSize=t??this._updateSize,this._updateID++,this.emit("update",this)}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function sl(r,t){if(!(r instanceof le)){let e=t?gt.INDEX:gt.VERTEX;r instanceof Array&&(t?(r=new Uint32Array(r),e=gt.INDEX|gt.COPY_DST):(r=new Float32Array(r),e=gt.VERTEX|gt.COPY_DST)),r=new le({data:r,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return r}function Vp(r,t,e){const i=r.getAttribute(t);if(!i)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const s=i.buffer.data;let n=1/0,o=1/0,a=-1/0,h=-1/0;const l=s.BYTES_PER_ELEMENT,c=(i.offset||0)/l,d=(i.stride||2*4)/l;for(let u=c;u<s.length;u+=d){const p=s[u],f=s[u+1];p>a&&(a=p),f>h&&(h=f),p<n&&(n=p),f<o&&(o=f)}return e.minX=n,e.minY=o,e.maxX=a,e.maxY=h,e}function Np(r){return(r instanceof le||Array.isArray(r)||r.BYTES_PER_ELEMENT)&&(r={buffer:r}),r.buffer=sl(r.buffer,!1),r}class Di extends Yt{constructor(t={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=dt("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new It,this._boundsDirty=!0;const{attributes:e,indexBuffer:i,topology:s}=t;if(this.buffers=[],this.attributes={},e)for(const n in e)this.addAttribute(n,e[n]);this.instanceCount=t.instanceCount??1,i&&this.addIndex(i),this.topology=s||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}addAttribute(t,e){const i=Np(e);this.buffers.indexOf(i.buffer)===-1&&(this.buffers.push(i.buffer),i.buffer.on("update",this.onBufferUpdate,this),i.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=i}addIndex(t){this.indexBuffer=sl(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,Vp(this,"aPosition",this._bounds)):this._bounds}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(i=>i.destroy()),this.unload(),(e=this.indexBuffer)==null||e.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const jp=new Float32Array(1),Yp=new Uint32Array(1);class Xp extends Di{constructor(){const e=new le({data:jp,label:"attribute-batch-buffer",usage:gt.VERTEX|gt.COPY_DST,shrinkToFit:!1}),i=new le({data:Yp,label:"index-batch-buffer",usage:gt.INDEX|gt.COPY_DST,shrinkToFit:!1}),s=6*4;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:s,offset:0},aUV:{buffer:e,format:"float32x2",stride:s,offset:2*4},aColor:{buffer:e,format:"unorm8x4",stride:s,offset:4*4},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:s,offset:5*4}},indexBuffer:i})}}function Wo(r,t,e){if(r)for(const i in r){const s=i.toLocaleLowerCase(),n=t[s];if(n){let o=r[i];i==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}else nt(`${i} placement hook does not exist in shader`)}}const Zp=/\{\{(.*?)\}\}/g;function Uo(r){var i;const t={};return(((i=r.match(Zp))==null?void 0:i.map(s=>s.replace(/[{()}]/g,"")))??[]).forEach(s=>{t[s]=[]}),t}function Ho(r,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(r))!==null;)t.push(e[1])}function Vo(r,t,e=!1){const i=[];Ho(t,i),r.forEach(a=>{a.header&&Ho(a.header,i)});const s=i;e&&s.sort();const n=s.map((a,h)=>` @location(${h}) ${a},`).join(`
@@ -499,7 +499,7 @@ fn mainFragment(
499
499
  `),i++):t.push(s);continue}e.push(s)}return e.length>0&&t.push(e.join("")),t}function Gl(r,t,e,i){const s=e(r),n=[];for(let o=0;o<s.length;o++){let a=s[o],h=a,l=1;for(;s[o+l];){const c=s[o+l];if(!i(h,c,r,o,t))a+=c,h=c,l++;else break}o+=l-1,n.push(a)}return n}const mm=/\r\n|\r|\n/g;function ym(r,t,e,i,s,n,o,a){var F;const h=lm(r,t);if(Ll(t.whiteSpace))for(let Z=0;Z<h.length;Z++){const R=h[Z];h[Z]={text:R.text.replace(mm," "),style:R.style}}const c=[];let d=[];for(const Z of h){const R=Z.text.split(fm);for(let D=0;D<R.length;D++){const ot=R[D];ot===`\r
500
500
  `||ot==="\r"||ot===`
501
501
  `?(c.push(d),d=[]):ot.length>0&&d.push({text:ot,style:Z.style})}}(d.length>0||c.length===0)&&c.push(d);const u=e?xm(c,t,i,s,o,a):c,p=[],f=[],y=[],m=[],x=[];let S=0;const v=t._fontString,b=n(v);b.fontSize===0&&(b.fontSize=t.fontSize,b.ascent=t.fontSize);let P="",w=!!t.dropShadow;for(const Z of u){let R=0,D=b.ascent,ot=b.descent,z="";for(const Y of Z){const ht=Y.style._fontString,bt=n(ht);ht!==P&&(i.font=ht,P=ht);const wt=s(Y.text,Y.style.letterSpacing,i);R+=wt,D=Math.max(D,bt.ascent),ot=Math.max(ot,bt.descent),z+=Y.text,!w&&Y.style.dropShadow&&(w=!0)}Z.length===0&&(D=b.ascent,ot=b.descent),p.push(R),f.push(D),y.push(ot),x.push(z);const K=t.lineHeight||D+ot;m.push(K+t.leading),S=Math.max(S,R)}const C=((F=t._stroke)==null?void 0:F.width)||0,T=(e&&t.align!=="left"&&t.align!=="justify"?Math.max(S,t.wordWrapWidth):S)+C+(t.dropShadow?t.dropShadow.distance:0);let _=0;for(let Z=0;Z<m.length;Z++)_+=m[Z];_=Math.max(_,m[0]+C);const I=_+(t.dropShadow?t.dropShadow.distance:0),B=t.lineHeight||b.fontSize;return{width:T,height:I,lines:x,lineWidths:p,lineHeight:B+t.leading,maxLineWidth:S,fontProperties:b,runsByLine:u,lineAscents:f,lineDescents:y,lineHeights:m,hasDropShadow:w}}function xm(r,t,e,i,s,n){var m;const{letterSpacing:o,whiteSpace:a,wordWrapWidth:h,breakWords:l}=t,c=zl(a),d=h+o,u={};let p="";const f=(x,S)=>{const v=`${x}|${S.styleKey}`;let b=u[v];if(b===void 0){const P=S._fontString;P!==p&&(e.font=P,p=P),b=i(x,S.letterSpacing,e)+S.letterSpacing,u[v]=b}return b},y=[];for(const x of r){const S=Sm(x),v=y.length,b=I=>{let B=0,F=I;do{const{token:Z,style:R}=S[F];B+=f(Z,R),F++}while(F<S.length&&S[F].continuesFromPrevious);return B},P=I=>{const B=[];let F=I;do B.push({token:S[F].token,style:S[F].style}),F++;while(F<S.length&&S[F].continuesFromPrevious);return B};let w=[],C=0,k=!c,M=null;const T=()=>{M&&M.text.length>0&&w.push(M),M=null},_=()=>{if(T(),w.length>0){const I=w[w.length-1];I.text=Kt(I.text),I.text.length===0&&w.pop()}y.push(w),w=[],C=0,k=!1};for(let I=0;I<S.length;I++){const{token:B,style:F,continuesFromPrevious:Z}=S[I],R=f(B,F);if(c){const z=Lt(B),K=(M==null?void 0:M.text[M.text.length-1])??((m=w[w.length-1])==null?void 0:m.text.slice(-1))??"",Y=K?Lt(K):!1;if(z&&Y)continue}const D=!Z,ot=D?b(I):R;if(ot>d&&D)if(C>0&&_(),l){const z=P(I);for(let K=0;K<z.length;K++){const Y=z[K].token,ht=z[K].style,bt=Gl(Y,l,n,s);for(const wt of bt){const kt=f(wt,ht);kt+C>d&&_(),!M||M.style!==ht?(T(),M={text:wt,style:ht}):M.text+=wt,C+=kt}}I+=z.length-1}else{const z=P(I);T(),y.push(z.map(K=>({text:K.token,style:K.style}))),k=!1,I+=z.length-1}else if(ot+C>d&&D){if(Lt(B)){k=!1;continue}_(),M={text:B,style:F},C=R}else if(Z&&!l)!M||M.style!==F?(T(),M={text:B,style:F}):M.text+=B,C+=R;else{const z=Lt(B);if(C===0&&z&&!k)continue;!M||M.style!==F?(T(),M={text:B,style:F}):M.text+=B,C+=R}}if(T(),w.length>0){const I=w[w.length-1];I.text=Kt(I.text),I.text.length===0&&w.pop()}(w.length>0||y.length===v)&&y.push(w)}return y}function Sm(r){const t=[];let e=!1;for(const i of r){const s=Ol(i.text);let n=!0;for(const o of s){const a=Lt(o)||_r(o),h=n&&e&&!a;t.push({token:o,style:i.style,continuesFromPrevious:h}),e=!a,n=!1}}return t}const vm={willReadFrequently:!0};function wa(r,t,e,i,s){let n=e[r];return typeof n!="number"&&(n=s(r,t,i)+t,e[r]=n),n}function bm(r,t,e,i,s,n,o){const a=e.getContext("2d",vm);a.font=t._fontString;let h=0,l="";const c=[],d=Object.create(null),{letterSpacing:u,whiteSpace:p}=t,f=zl(p),y=Ll(p);let m=!f;const x=t.wordWrapWidth+u,S=Ol(r);for(let b=0;b<S.length;b++){let P=S[b];if(_r(P)){if(!y){c.push(Kt(l)),m=!f,l="",h=0;continue}P=" "}if(f){const C=Lt(P),k=Lt(l[l.length-1]);if(C&&k)continue}const w=wa(P,u,d,a,i);if(w>x)if(l!==""&&(c.push(Kt(l)),l="",h=0),s(P,t.breakWords)){const C=Gl(P,t.breakWords,o,n);for(const k of C){const M=wa(k,u,d,a,i);M+h>x&&(c.push(Kt(l)),m=!1,l="",h=0),l+=k,h+=M}}else l.length>0&&(c.push(Kt(l)),l="",h=0),c.push(Kt(P)),m=!1,l="",h=0;else w+h>x&&(m=!1,c.push(Kt(l)),l="",h=0),(l.length>0||!Lt(P)||m)&&(l+=P,h+=w)}const v=Kt(l);return v.length>0&&c.push(v),c.join(`
502
- `)}const Aa={willReadFrequently:!0},se=class O{static get experimentalLetterSpacingSupported(){let t=O._experimentalLetterSpacingSupported;if(t===void 0){const e=j.get().getCanvasRenderingContext2D().prototype;t=O._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,s,n,o,a,h,l,c){this.text=t,this.style=e,this.width=i,this.height=s,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=h,this.fontProperties=l,c&&(this.runsByLine=c.runsByLine,this.lineAscents=c.lineAscents,this.lineDescents=c.lineDescents,this.lineHeights=c.lineHeights,this.hasDropShadow=c.hasDropShadow)}static measureText(t=" ",e,i=O._canvas,s=e.wordWrap){var P;const n=`${t}-${e.styleKey}-wordWrap-${s}`;if(O._measurementCache.has(n))return O._measurementCache.get(n);if(Dl(e)&&Fl(t)){const w=ym(t,e,s,O._context,O._measureText,O.measureFont,O.canBreakChars,O.wordWrapSplit),C=new O(t,e,w.width,w.height,w.lines,w.lineWidths,w.lineHeight,w.maxLineWidth,w.fontProperties,{runsByLine:w.runsByLine,lineAscents:w.lineAscents,lineDescents:w.lineDescents,lineHeights:w.lineHeights,hasDropShadow:w.hasDropShadow});return O._measurementCache.set(n,C),C}const a=e._fontString,h=O.measureFont(a);h.fontSize===0&&(h.fontSize=e.fontSize,h.ascent=e.fontSize,h.descent=0);const l=O._context;l.font=a;const d=(s?O._wordWrap(t,e,i):t).split(gm),u=new Array(d.length);let p=0;for(let w=0;w<d.length;w++){const C=O._measureText(d[w],e.letterSpacing,l);u[w]=C,p=Math.max(p,C)}const f=((P=e._stroke)==null?void 0:P.width)??0,y=e.lineHeight||h.fontSize,m=O._getAlignWidth(p,e,s),x=O._adjustWidthForStyle(m,e),S=Math.max(y,h.fontSize+f)+(d.length-1)*(y+e.leading),v=O._adjustHeightForStyle(S,e),b=new O(t,e,x,v,d,u,y+e.leading,p,h);return O._measurementCache.set(n,b),b}static _adjustWidthForStyle(t,e){var n;const i=((n=e._stroke)==null?void 0:n.width)||0;let s=t+i;return e.dropShadow&&(s+=e.dropShadow.distance),s}static _adjustHeightForStyle(t,e){let i=t;return e.dropShadow&&(i+=e.dropShadow.distance),i}static _getAlignWidth(t,e,i){return i&&e.align!=="left"&&e.align!=="justify"?Math.max(t,e.wordWrapWidth):t}static _measureText(t,e,i){let s=!1;O.experimentalLetterSpacingSupported&&(O.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,s=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));const n=i.measureText(t);let o=n.width;const a=-(n.actualBoundingBoxLeft??0);let l=(n.actualBoundingBoxRight??0)-a;if(o>0)if(s)o-=e,l-=e;else{const c=(O.graphemeSegmenter(t).length-1)*e;o+=c,l+=c}return Math.max(o,l)}static _wordWrap(t,e,i=O._canvas){return bm(t,e,i,O._measureText,O.canBreakWords,O.canBreakChars,O.wordWrapSplit)}static isBreakingSpace(t,e){return Lt(t)}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,s,n){return!0}static wordWrapSplit(t){return O.graphemeSegmenter(t)}static measureFont(t){if(O._fonts[t])return O._fonts[t];const e=O._context;e.font=t;const i=e.measureText(O.METRICS_STRING+O.BASELINE_SYMBOL),s=i.actualBoundingBoxAscent??0,n=i.actualBoundingBoxDescent??0,o={ascent:s,descent:n,fontSize:s+n};return O._fonts[t]=o,o}static clearMetrics(t=""){t?delete O._fonts[t]:O._fonts={}}static get _canvas(){if(!O.__canvas){let t;try{const e=new OffscreenCanvas(0,0),i=e.getContext("2d",Aa);if(i!=null&&i.measureText)return O.__canvas=e,e;t=j.get().createCanvas()}catch{t=j.get().createCanvas()}t.width=t.height=10,O.__canvas=t}return O.__canvas}static get _context(){return O.__context||(O.__context=O._canvas.getContext("2d",Aa)),O.__context}};se.METRICS_STRING="|ÉqÅ";se.BASELINE_SYMBOL="M";se.BASELINE_MULTIPLIER=1.4;se.HEIGHT_MULTIPLIER=2;se.graphemeSegmenter=r=>[...r];se.experimentalLetterSpacing=!1;se._fonts={};se._measurementCache=am(1e3);let ne=se;const wm=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Qn(r){const t=typeof r.fontSize=="number"?`${r.fontSize}px`:r.fontSize;let e=r.fontFamily;Array.isArray(r.fontFamily)||(e=r.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let s=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!wm.includes(s)&&(s=`"${s}"`),e[i]=s}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} ${e.join(",")}`}const Ca=1e5;function os(r,t,e,i=0,s=0,n=0){if(r.texture===G.WHITE&&!r.fill)return rt.shared.setValue(r.color).setAlpha(r.alpha??1).toHexa();if(r.fill){if(r.fill instanceof Rs){const o=r.fill,a=t.createPattern(o.texture.source.resource,"repeat"),h=o.transform.copyTo(W.shared);return h.scale(o.texture.source.pixelWidth,o.texture.source.pixelHeight),a.setTransform(h),a}else if(r.fill instanceof Ot){const o=r.fill,a=o.type==="linear",h=o.textureSpace==="local";let l=1,c=1;h&&e&&(l=e.width+i,c=e.height+i);let d,u=!1;if(a){const{start:p,end:f}=o;d=t.createLinearGradient(p.x*l+s,p.y*c+n,f.x*l+s,f.y*c+n),u=Math.abs(f.x-p.x)<Math.abs((f.y-p.y)*.1)}else{const{center:p,innerRadius:f,outerCenter:y,outerRadius:m}=o;d=t.createRadialGradient(p.x*l+s,p.y*c+n,f*l,y.x*l+s,y.y*c+n,m*l)}if(u&&h&&e){const p=e.lineHeight/c;for(let f=0;f<e.lines.length;f++){const y=(f*e.lineHeight+i/2)/c;o.colorStops.forEach(m=>{let x=y+m.offset*p;x=Math.max(0,Math.min(1,x)),d.addColorStop(Math.floor(x*Ca)/Ca,rt.shared.setValue(m.color).toHex())})}}else o.colorStops.forEach(p=>{d.addColorStop(p.offset,rt.shared.setValue(p.color).toHex())});return d}}else{const o=t.createPattern(r.texture.source.resource,"repeat"),a=r.matrix.copyTo(W.shared);return a.scale(r.texture.source.pixelWidth,r.texture.source.pixelHeight),o.setTransform(a),o}return nt("FillStyle not recognised",r),"red"}const Pa=new et;class Am{getCanvasAndContext(t){const{text:e,style:i,resolution:s=1}=t,n=i._getFinalPadding(),o=ne.measureText(e||" ",i),a=Math.ceil(Math.ceil(Math.max(1,o.width)+n*2)*s),h=Math.ceil(Math.ceil(Math.max(1,o.height)+n*2)*s),l=$n.getOptimalCanvasAndContext(a,h);this._renderTextToCanvas(i,n,s,l,o);const c=i.trim?rm({canvas:l.canvas,width:a,height:h,resolution:1,output:Pa}):Pa.set(0,0,a,h);return{canvasAndContext:l,frame:c}}returnCanvasAndContext(t){$n.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,i,s,n){var w,C,k;if(n.runsByLine&&n.runsByLine.length>0){this._renderTaggedTextToCanvas(n,t,e,i,s);return}const{canvas:o,context:a}=s,h=Qn(t),l=n.lines,c=n.lineHeight,d=n.lineWidths,u=n.maxLineWidth,p=n.fontProperties,f=o.height;if(a.resetTransform(),a.scale(i,i),a.textBaseline=t.textBaseline,(w=t._stroke)!=null&&w.width){const M=t._stroke;a.lineWidth=M.width,a.miterLimit=M.miterLimit,a.lineJoin=M.join,a.lineCap=M.cap}a.font=h;let y,m;const x=t.dropShadow?2:1,S=t.wordWrap?t.wordWrapWidth:u,b=(((C=t._stroke)==null?void 0:C.width)??0)/2;let P=(c-p.fontSize)/2;c-p.fontSize<0&&(P=0);for(let M=0;M<x;++M){const T=t.dropShadow&&M===0,_=T?Math.ceil(Math.max(1,f)+e*2):0,I=_*i;if(T)this._setupDropShadow(a,t,i,I);else{const B=t._gradientBounds,F=t._gradientOffset;if(B){const Z={width:B.width,height:B.height,lineHeight:B.height,lines:n.lines};this._setFillAndStrokeStyles(a,t,Z,e,b,(F==null?void 0:F.x)??0,(F==null?void 0:F.y)??0)}else F?this._setFillAndStrokeStyles(a,t,n,e,b,F.x,F.y):this._setFillAndStrokeStyles(a,t,n,e,b);a.shadowColor="black"}for(let B=0;B<l.length;B++)y=b,m=b+B*c+p.ascent+P,y+=this._getAlignmentOffset(d[B],S,t.align),(k=t._stroke)!=null&&k.width&&this._drawLetterSpacing(l[B],t,s,y+e,m+e-_,!0),t._fill!==void 0&&this._drawLetterSpacing(l[B],t,s,y+e,m+e-_)}}_renderTaggedTextToCanvas(t,e,i,s,n){var b,P;const{canvas:o,context:a}=n,{runsByLine:h,lineWidths:l,maxLineWidth:c,lineAscents:d,lineHeights:u,hasDropShadow:p}=t,f=o.height;a.resetTransform(),a.scale(s,s),a.textBaseline=e.textBaseline;const y=p?2:1,m=e.wordWrap?e.wordWrapWidth:c,S=(((b=e._stroke)==null?void 0:b.width)??0)/2,v=[];for(let w=0;w<h.length;w++){const C=h[w],k=[];for(const M of C){const T=Qn(M.style);a.font=T,k.push({width:ne._measureText(M.text,M.style.letterSpacing,a),font:T})}v.push(k)}for(let w=0;w<y;++w){const C=p&&w===0,k=C?Math.ceil(Math.max(1,f)+i*2):0,M=k*s;C||(a.shadowColor="black");let T=S;for(let _=0;_<h.length;_++){const I=h[_],B=l[_],F=d[_],Z=u[_],R=v[_];let D=S;D+=this._getAlignmentOffset(B,m,e.align);const ot=T+F;let z=D+i;for(let K=0;K<I.length;K++){const Y=I[K],{width:ht,font:bt}=R[K];if(a.font=bt,a.textBaseline=Y.style.textBaseline,(P=Y.style._stroke)!=null&&P.width){const wt=Y.style._stroke;if(a.lineWidth=wt.width,a.miterLimit=wt.miterLimit,a.lineJoin=wt.join,a.lineCap=wt.cap,C)if(Y.style.dropShadow)this._setupDropShadow(a,Y.style,s,M);else{z+=ht;continue}else{const kt=ne.measureFont(bt),Gt=Y.style.lineHeight||kt.fontSize,Hi={width:ht,height:Gt,lineHeight:Gt,lines:[Y.text]};a.strokeStyle=os(wt,a,Hi,i*2,z-i,T)}this._drawLetterSpacing(Y.text,Y.style,n,z,ot+i-k,!0)}z+=ht}z=D+i;for(let K=0;K<I.length;K++){const Y=I[K],{width:ht,font:bt}=R[K];if(a.font=bt,a.textBaseline=Y.style.textBaseline,Y.style._fill!==void 0){if(C)if(Y.style.dropShadow)this._setupDropShadow(a,Y.style,s,M);else{z+=ht;continue}else{const wt=ne.measureFont(bt),kt=Y.style.lineHeight||wt.fontSize,Gt={width:ht,height:kt,lineHeight:kt,lines:[Y.text]};a.fillStyle=os(Y.style._fill,a,Gt,i*2,z-i,T)}this._drawLetterSpacing(Y.text,Y.style,n,z,ot+i-k,!1)}z+=ht}T+=Z}}}_setFillAndStrokeStyles(t,e,i,s,n,o=0,a=0){var h;if(t.fillStyle=e._fill?os(e._fill,t,i,s*2,o,a):null,(h=e._stroke)!=null&&h.width){const l=n+s*2;t.strokeStyle=os(e._stroke,t,i,l,o,a)}}_setupDropShadow(t,e,i,s){t.fillStyle="black",t.strokeStyle="black";const n=e.dropShadow,o=n.color,a=n.alpha;t.shadowColor=rt.shared.setValue(o).setAlpha(a).toRgbaString();const h=n.blur*i,l=n.distance*i;t.shadowBlur=h,t.shadowOffsetX=Math.cos(n.angle)*l,t.shadowOffsetY=Math.sin(n.angle)*l+s}_getAlignmentOffset(t,e,i){return i==="right"?e-t:i==="center"?(e-t)/2:0}_drawLetterSpacing(t,e,i,s,n,o=!1){const{context:a}=i,h=e.letterSpacing;let l=!1;if(ne.experimentalLetterSpacingSupported&&(ne.experimentalLetterSpacing?(a.letterSpacing=`${h}px`,a.textLetterSpacing=`${h}px`,l=!0):(a.letterSpacing="0px",a.textLetterSpacing="0px")),h===0||l){o?a.strokeText(t,s,n):a.fillText(t,s,n);return}let c=s;const d=ne.graphemeSegmenter(t);let u=a.measureText(t).width,p=0;for(let f=0;f<d.length;++f){const y=d[f];o?a.strokeText(y,c,n):a.fillText(y,c,n);let m="";for(let x=f+1;x<d.length;++x)m+=d[x];p=a.measureText(m).width,c+=u-p+h,u=p}}}const Ve=new Am,Tr=class Pe extends Yt{constructor(t={}){super(),this.uid=dt("textStyle"),this._tick=0,this._cachedFontString=null,Cm(t),t instanceof Pe&&(t=t._toObject());const s={...Pe.defaultTextStyle,...t};for(const n in s){const o=n;this[o]=s[n]}this._tagStyles=t.tagStyles??void 0,this.update(),this._tick=0}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.update())}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(t!==null&&typeof t=="object"?this._dropShadow=this._createProxy({...Pe.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...Pe.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.update())}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.update())}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.update())}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.update())}get filters(){return this._filters}set filters(t){this._filters!==t&&(this._filters=Object.freeze(t),this.update())}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.update())}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy({...mt.defaultFillStyle,...t},()=>{this._fill=Me({...this._originalFill},mt.defaultFillStyle)})),this._fill=Me(t===0?"black":t,mt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...mt.defaultStrokeStyle,...t},()=>{this._stroke=ys({...this._originalStroke},mt.defaultStrokeStyle)})),this._stroke=ys(t,mt.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(t){this._tagStyles!==t&&(this._tagStyles=t??void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){const t=Pe.defaultTextStyle;for(const e in t)this[e]=t[e]}assign(t){for(const e in t){const i=e;this[i]=t[e]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=Qn(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill?{...this._fill}:void 0,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke?{...this._stroke}:void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?{...this._tagStyles}:void 0}}clone(){return new Pe(this._toObject())}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=!1){var i,s,n,o;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const a=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(i=this._fill)!=null&&i.texture&&this._fill.texture.destroy(a),(s=this._originalFill)!=null&&s.texture&&this._originalFill.texture.destroy(a),(n=this._stroke)!=null&&n.texture&&this._stroke.texture.destroy(a),(o=this._originalStroke)!=null&&o.texture&&this._originalStroke.texture.destroy(a)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(i,s,n)=>(i[s]===n||(i[s]=n,e==null||e(s,n),this.update()),!0)})}_isFillStyle(t){return(t??null)!==null&&!(rt.isColorLike(t)||t instanceof Ot||t instanceof Rs)}};Tr.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Tr.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let de=Tr;function Cm(r){const t=r;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=de.defaultDropShadow;r.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){V(J,"strokeThickness is now a part of stroke");const e=t.stroke;let i={};if(rt.isColorLike(e))i.color=e;else if(e instanceof Ot||e instanceof Rs)i.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))i=e;else throw new Error("Invalid stroke value.");r.stroke={...i,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){if(V(J,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(t.fill)||t.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");t.fill.length!==t.fillGradientStops.length&&nt("The number of fill colors must match the number of fill gradient stops.");const e=new Ot({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),i=t.fillGradientStops.slice(),s=t.fill.map(n=>rt.shared.setValue(n).toNumber());i.forEach((n,o)=>{e.addColorStop(n,s[o])}),r.fill={fill:e}}}function Pm(r,t){const{texture:e,bounds:i}=r,s=t._style._getFinalPadding();lh(i,t._anchor,e);const n=t._anchor._x*s*2,o=t._anchor._y*s*2;i.minX-=s-n,i.minY-=s-o,i.maxX-=s-n,i.maxY-=s-o}class Mm{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}class _m extends Mm{}class Wl{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new ri({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e!=null&&e._autoResolution&&e.onViewUpdate()}}validateRenderable(t){const e=this._getGpuText(t),i=t.styleKey;return e.currentKey!==i?!0:t._didTextUpdate}addRenderable(t,e){const i=this._getGpuText(t);if(t._didTextUpdate){const s=t._autoResolution?this._renderer.resolution:t.resolution;(i.currentKey!==t.styleKey||t._resolution!==s)&&this._updateGpuText(t),t._didTextUpdate=!1,Pm(i,t)}this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t.styleKey}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new _m;return e.currentKey="--",e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,this._managedTexts.add(t),e}onTextUnload(t){const e=t._gpuData[this._renderer.uid];if(!e)return;const{canvasText:i}=this._renderer;i.getReferenceCount(e.currentKey)>0?i.decreaseReferenceCount(e.currentKey):e.texture&&i.returnTexture(e.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}Wl.extension={type:[E.WebGLPipes,E.WebGPUPipes,E.CanvasPipes],name:"text"};const Tm=new It;function km(r,t,e,i){const s=Tm;s.minX=0,s.minY=0,s.maxX=r.width/i|0,s.maxY=r.height/i|0;const n=Ps.getOptimalTexture(s.width,s.height,i,!1);return n.source.uploadMethodId="image",n.source.resource=r,n.source.alphaMode="premultiply-alpha-on-upload",n.frame.width=t/i,n.frame.height=e/i,n.source.emit("update",n.source),n.updateUvs(),n}class Ul{constructor(t,e){this._activeTextures={},this._renderer=t,this._retainCanvasContext=e}getTexture(t,e,i,s){typeof t=="string"&&(V("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:i,resolution:e}),t.style instanceof de||(t.style=new de(t.style)),t.textureStyle instanceof Ke||(t.textureStyle=new Ke(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:n,style:o,textureStyle:a}=t,h=t.resolution??this._renderer.resolution,{frame:l,canvasAndContext:c}=Ve.getCanvasAndContext({text:n,style:o,resolution:h}),d=km(c.canvas,l.width,l.height,h);if(a&&(d.source.style=a),o.trim&&(l.pad(o.padding),d.frame.copyFrom(l),d.frame.scale(1/h),d.updateUvs()),o.filters){const u=this._applyFilters(d,o.filters);return this.returnTexture(d),Ve.returnCanvasAndContext(c),u}return this._renderer.texture.initSource(d._source),this._retainCanvasContext||Ve.returnCanvasAndContext(c),d}returnTexture(t){const e=t.source,i=e.resource;if(this._retainCanvasContext&&(i!=null&&i.getContext)){const s=i.getContext("2d");s&&Ve.returnCanvasAndContext({canvas:i,context:s})}e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",Ps.returnTexture(t,!0)}renderTextToCanvas(){V("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const i=this.getTexture({text:t.text,style:t.style,resolution:t._resolution,textureStyle:t.textureStyle});return this._activeTextures[e]={texture:i,usageCount:1},i}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(this.returnTexture(e.texture),this._activeTextures[t]=null))}getReferenceCount(t){var e;return((e=this._activeTextures[t])==null?void 0:e.usageCount)??0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const i=this._renderer.renderTarget.renderTarget,s=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(i,!1),s}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}class Hl extends Ul{constructor(t){super(t,!0)}}Hl.extension={type:[E.CanvasSystem],name:"canvasText"};class Vl extends Ul{constructor(t){super(t,!1)}}Vl.extension={type:[E.WebGLSystem,E.WebGPUSystem],name:"canvasText"};$.add(Hl);$.add(Vl);$.add(Wl);class Es extends em{constructor(...t){const e=im(t,"Text");super(e,de),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof Ke?e.textureStyle:new Ke(e.textureStyle))}updateBounds(){const t=this._bounds,e=this._anchor;let i=0,s=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=Ve.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Ve.returnCanvasAndContext(o),i=n.width,s=n.height}else{const n=ne.measureText(this._text,this._style);i=n.width,s=n.height}t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*s,t.maxY=t.minY+s}}class kr extends G{static create(t){const{dynamic:e,...i}=t;return new kr({source:new Bt(i),dynamic:e??!1})}resize(t,e,i){return this.source.resize(t,e,i),this}}$.add(Jc,td);function Rm(r,t){var e=-1,i=r.length;for(t||(t=Array(i));++e<i;)t[e]=r[e];return t}function Em(r,t,e,i){var s=!e;e||(e={});for(var n=-1,o=t.length;++n<o;){var a=t[n],h=void 0;h===void 0&&(h=r[a]),s?Ka(e,a,h):$a(e,a,h)}return e}function Im(r){return Pc(function(t,e){var i=-1,s=e.length,n=s>1?e[s-1]:void 0,o=s>2?e[2]:void 0;for(n=r.length>3&&typeof n=="function"?(s--,n):void 0,o&&Mc(e[0],e[1],o)&&(n=s<3?void 0:n,s=1),t=Object(t);++i<s;){var a=e[i];a&&r(t,a,i,n)}return t})}function Bm(r){var t=[];if(r!=null)for(var e in Object(r))t.push(e);return t}var Dm=Object.prototype,Fm=Dm.hasOwnProperty;function zm(r){if(!Re(r))return Bm(r);var t=_c(r),e=[];for(var i in r)i=="constructor"&&(t||!Fm.call(r,i))||e.push(i);return e}function Nl(r){return Qa(r)?Tc(r,!0):zm(r)}function Lm(r){var t=r==null?0:r.length;return t?kc(r):[]}function Om(r){return Rc(Ec(r,void 0,Lm),r+"")}var Gm="[object Object]",Wm=Function.prototype,Um=Object.prototype,jl=Wm.toString,Hm=Um.hasOwnProperty,Vm=jl.call(Object);function Nm(r){if(!or(r)||Ja(r)!=Gm)return!1;var t=Ic(r);if(t===null)return!0;var e=Hm.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&jl.call(e)==Vm}var jm=Fc.isFinite,Ym=Math.min;function Xm(r){var t=Math[r];return function(e,i){if(e=Bc(e),i=i==null?0:Ym(Dc(i),292),i&&jm(e)){var s=(Yr(e)+"e").split("e"),n=t(s[0]+"e"+(+s[1]+i));return s=(Yr(n)+"e").split("e"),+(s[0]+"e"+(+s[1]-i))}return t(e)}}function Jn(r,t,e){(e!==void 0&&!zc(r[t],e)||e===void 0&&!(t in r))&&Ka(r,t,e)}function Zm(r){return or(r)&&Qa(r)}function tr(r,t){if(!(t==="constructor"&&typeof r[t]=="function")&&t!="__proto__")return r[t]}function qm(r){return Em(r,Nl(r))}function Km(r,t,e,i,s,n,o){var a=tr(r,e),h=tr(t,e),l=o.get(h);if(l){Jn(r,e,l);return}var c=n?n(a,h,e+"",r,t,o):void 0,d=c===void 0;if(d){var u=_n(h),p=!u&&Lc(h),f=!u&&!p&&Oc(h);c=h,u||p||f?_n(a)?c=a:Zm(a)?c=Rm(a):p?(d=!1,c=Gc(h,!0)):f?(d=!1,c=Wc(h,!0)):c=[]:Nm(h)||Xr(h)?(c=a,Xr(a)?c=qm(a):(!Re(a)||Uc(a))&&(c=Hc(h))):d=!1}d&&(o.set(h,c),s(c,h,i,n,o),o.delete(h)),Jn(r,e,c)}function Yl(r,t,e,i,s){r!==t&&Vc(t,function(n,o){if(s||(s=new Nc),Re(n))Km(r,t,o,e,Yl,i,s);else{var a=i?i(tr(r,o),n,o+"",r,t,s):void 0;a===void 0&&(a=n),Jn(r,o,a)}},Nl)}var $m="[object Number]";function Ma(r){return typeof r=="number"||or(r)&&Ja(r)==$m}var _a=Im(function(r,t,e){Yl(r,t,e)});function Qm(r,t,e,i){if(!Re(r))return r;t=th(t,r);for(var s=-1,n=t.length,o=n-1,a=r;a!=null&&++s<n;){var h=jc(t[s]),l=e;if(h==="__proto__"||h==="constructor"||h==="prototype")return r;if(s!=o){var c=a[h];l=void 0,l===void 0&&(l=Re(c)?c:Yc(t[s+1])?[]:{})}$a(a,h,l),a=a[h]}return r}function Jm(r,t,e){for(var i=-1,s=t.length,n={};++i<s;){var o=t[i],a=Xc(r,o);e(a,o)&&Qm(n,th(o,r),a)}return n}function ty(r,t){return Jm(r,t,function(e,i){return Zc(r,i)})}var wn=Om(function(r,t){return r==null?{}:ty(r,t)}),Ta=Xm("round"),ey="Expected a function";function At(r,t,e){var i=!0,s=!0;if(typeof r!="function")throw new TypeError(ey);return Re(e)&&(i="leading"in e?!!e.leading:i,s="trailing"in e?!!e.trailing:s),Tn(r,t,{leading:i,maxWait:t,trailing:s})}function iy(r){return r<.5?4*r*r*r:(r-1)*(2*r-2)*(2*r-2)+1}function Xl(r,t=2){if(r==null)return r;if(Ma(r))return Ta(r,t);if(_n(r))return qc(r,e=>Xl(e,t));if(Re(r)){const e=["x","y","rotation"];return Kc(r,(i,s)=>Ma(i)&&e.includes(s)?Ta(i,t):i)}return r}let er=null;function sy(r){er=r}function fi(){return er?er():!1}const A={log(r,...t){fi()&&console.log(`%c[ray-2d-laser-map-sdk]%c ${r}`,"background: #2196F3; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #2196F3;",...t)},warn(r,...t){fi()&&console.warn(`%c[ray-2d-laser-map-sdk]%c ${r}`,"background: #FF9800; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #FF9800;",...t)},error(r,...t){fi()&&console.error(`%c[ray-2d-laser-map-sdk]%c ${r}`,"background: #F44336; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #F44336;",...t)},debug(r,...t){fi()&&console.log(`%c[ray-2d-laser-map-sdk:DEBUG]%c ${r}`,"background: #9C27B0; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #9C27B0;",...t)},success(r,...t){fi()&&console.log(`%c[ray-2d-laser-map-sdk]%c ${r}`,"background: #4CAF50; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #4CAF50;",...t)}},ka=r=>{if(r.length<=1)return[...r];const t=ny(r),e=t.slice(1).map((s,n)=>({prev:t[n],current:s})),i=new Map;return e.forEach(({prev:s,current:n})=>{ry(s,n).forEach(a=>{const h=`${a.x},${a.y}`;i.has(h)||i.set(h,a)})}),Array.from(i.values())},ny=r=>{if(r.length<=1)return[...r];const t=r[0],e=r[r.length-1];return t.x===e.x&&t.y===e.y?[...r]:[...r,t]},ry=(r,t)=>{const e=[],i=Math.abs(t.x-r.x),s=Math.abs(t.y-r.y),n=r.x<t.x?1:-1,o=r.y<t.y?1:-1;let a=i-s,h=r.x,l=r.y;for(;e.push({x:h,y:l}),!(h===t.x&&l===t.y);){const c=2*a;c>-s&&(a-=s,h+=n),c<i&&(a+=i,l+=o)}return e},Zl=(r,t)=>{let e=0,i=r.length-1;for(;e<=i;){const s=Math.floor((e+i)/2),n=r[s];if(n===t)return!0;n<t?e=s+1:i=s-1}return!1},oy=(r,t,e=1,i=2e3)=>{const s=[],n=t.x-r.x,o=t.y-r.y,a=Math.sqrt(n*n+o*o);if(a===0)return[r];const h=Math.min(Math.max(Math.ceil(a/e),2),i);for(let l=0;l<=h;l++){const c=l/h,d={x:r.x+c*n,y:r.y+c*o};s.push(d)}return s},Ra=(r,t,e,i,s,n=8)=>{const o=(t+i)/2,a=(e+s)/2,h={x:o,y:a},l=i-t,c=s-e,d=Math.min(n,Math.min(l,c)*.2);return Rt(h,r)&&_i(h,r)>=d?h:ay(r,h,d)},ay=(r,t,e)=>{const{minX:i,minY:s,maxX:n,maxY:o}=vs(r),a=n-i,h=o-s,l=t.x,c=t.y,d=Math.min(.5,Math.min(a,h)*.05),u=[];if(Rt({x:l,y:c},r)){const S=_i({x:l,y:c},r);u.push({point:{x:l,y:c},distance:S,centerDistance:0})}const p=Math.max(a,h)*.6,f=Math.PI/16;let y=0;const m=1e4;let x=!1;for(let S=d;S<=p&&!x;S+=d){const v=f*(1+S/p);for(let b=0;b<2*Math.PI;b+=v){if(y++,y>m){A.error(`[findBestInnerPoint] Iteration limit reached (${y}). Room size: ${a}x${h}`),x=!0;break}const P=l+S*Math.cos(b),w=c+S*Math.sin(b);if(P>=i&&P<=n&&w>=s&&w<=o){const C={x:P,y:w};if(Rt(C,r)){const k=_i(C,r),M=Q({x:P,y:w},{x:l,y:c});k>=e&&u.push({point:C,distance:k,centerDistance:M})}}}if(u.length>=15)break}if(u.length>0){const S=u.map(v=>({...v,score:v.distance*1.5-v.centerDistance*.5}));return S.sort((v,b)=>b.score-v.score),S[0].point}if(u.length===0){let S={x:l,y:c},v=0;const b=d*2;let P=0;const w=5e3;let C=!1;for(let k=i;k<=n&&!C;k+=b)for(let M=s;M<=o;M+=b){if(P++,P>w){A.error(`[findBestInnerPoint] Coarse search iteration limit reached. Room size: ${a}x${h}`),C=!0;break}const T={x:k,y:M};if(Rt(T,r)){const _=_i(T,r);_>v&&(v=_,S=T)}}return S}return{x:l,y:c}},_i=(r,t)=>{let e=1/0;for(let i=0,s=t.length-1;i<t.length;s=i++){const n=t[s],o=t[i],a=Rr(r,n,o);e=Math.min(e,a)}return e},Ea=(r,t)=>t.length===1?Q(r,t[0]):t.length===2?Rr(r,t[0],t[1]):t.length===4?Rt(r,t)?0:_i(r,t):(A.warn(`[Distance] Invalid geometry: expected 1, 2 or 4 points, got ${t.length}`),1/0),Rr=(r,t,e)=>{const i=(t.x-e.x)**2+(t.y-e.y)**2;if(i===0)return Q(r,t);const s=Math.max(0,Math.min(1,((r.x-t.x)*(e.x-t.x)+(r.y-t.y)*(e.y-t.y))/i)),n=t.x+s*(e.x-t.x),o=t.y+s*(e.y-t.y);return Q(r,{x:n,y:o})},Rt=(r,t,e=!1)=>{if(t.length<3)return!1;if(e&&hy(r,t))return!0;let i=!1;for(let s=0,n=t.length-1;s<t.length;n=s++){const o=t[s].x,a=t[s].y,h=t[n].x,l=t[n].y;a>r.y!=l>r.y&&r.x<(h-o)*(r.y-a)/(l-a)+o&&(i=!i)}return i},hy=(r,t)=>{if(t.length<2)return!1;for(let e=0;e<t.length;e++){const i=(e+1)%t.length;if(ly(r,t[e],t[i]))return!0}return!1},ly=(r,t,e,i=.5)=>{if(Rr(r,t,e)>i)return!1;const n=Math.min(t.x,e.x)-i,o=Math.max(t.x,e.x)+i,a=Math.min(t.y,e.y)-i,h=Math.max(t.y,e.y)+i;return r.x>=n&&r.x<=o&&r.y>=a&&r.y<=h},vs=r=>{if(r.length===0)return{minX:0,minY:0,maxX:0,maxY:0};let t=1/0,e=1/0,i=-1/0,s=-1/0;for(const n of r)t=Math.min(t,n.x),e=Math.min(e,n.y),i=Math.max(i,n.x),s=Math.max(s,n.y);return{minX:t,minY:e,maxX:i,maxY:s}},ee=r=>{const t=r.reduce((e,i)=>({x:e.x+i.x,y:e.y+i.y}),{x:0,y:0});return{x:t.x/r.length,y:t.y/r.length}},Ia=(r,t)=>{if(r.length<4)return r;const[e,i,,s]=r,n=Q(e,i),o=Q(e,s);if(n>=t&&o>=t)return r;const a=ee(r),h=pt(q(e,i)),l=pt(q(e,s)),c=Math.max(n,t),d=Math.max(o,t),u=c/2,p=d/2;return[{x:a.x-h.x*u-l.x*p,y:a.y-h.y*u-l.y*p},{x:a.x+h.x*u-l.x*p,y:a.y+h.y*u-l.y*p},{x:a.x+h.x*u+l.x*p,y:a.y+h.y*u+l.y*p},{x:a.x-h.x*u+l.x*p,y:a.y-h.y*u+l.y*p}]},bs=r=>{if(r.length!==4)return r;const t=ee(r),e=Q(r[0],r[1]),i=Q(r[1],r[2]),s=Math.atan2(r[1].y-r[0].y,r[1].x-r[0].x),n=[{x:-e/2,y:-i/2},{x:e/2,y:-i/2},{x:e/2,y:i/2},{x:-e/2,y:i/2}],o=Math.cos(s),a=Math.sin(s);return n.map(h=>({x:h.x*o-h.y*a+t.x,y:h.x*a+h.y*o+t.y}))},he=(r,t,e,i=10)=>{if(e===0)return 1;const n=(r.x*t.x+r.y*t.y)/e/e,o=i/e;return n<=0?o:Math.max(n,o)},Q=(r,t)=>{const e=r.x-t.x,i=r.y-t.y;return Math.sqrt(e*e+i*i)},ie=r=>Math.sqrt(r.x*r.x+r.y*r.y),q=(r,t)=>({x:t.x-r.x,y:t.y-r.y}),pt=r=>{const t=ie(r);return t===0?{x:0,y:0}:{x:r.x/t,y:r.y/t}},ql=(r,t)=>{const e=q(r,t);return pt(e)},Kl=r=>({x:-r.y,y:r.x}),$l=(r,t)=>{const e=ql(r,t);return Kl(e)},Ql=(r,t)=>{const e=pt(r),i=pt(t),s={x:(e.x+i.x)/2,y:(e.y+i.y)/2};return pt(s)},Xe=(r,t,e=0)=>{const i=q(r,t);let s=Math.atan2(i.y,i.x),o=(s+e)%(2*Math.PI);return o>Math.PI&&(o-=2*Math.PI),o<-Math.PI&&(o+=2*Math.PI),(o>Math.PI/2||o<-Math.PI/2)&&(s+=Math.PI),s},Jl=(r,t,e)=>{const i=ee([r,t]),s=$l(r,t);return{x:i.x+s.x*e,y:i.y+s.y*e}},cy=(r,t,e)=>{const i=Math.cos(e),s=Math.sin(e),n=r.x-t.x,o=r.y-t.y;return{x:n*i-o*s+t.x,y:n*s+o*i+t.y}},Er=(r,t,e)=>r.map(i=>cy(i,t,e)),dy=(r,t,e)=>{if(Q(r,t)===0)return[r,r,r,r];const s=ql(r,t),n=Kl(s),o={x:r.x-s.x*e,y:r.y-s.y*e},a={x:t.x+s.x*e,y:t.y+s.y*e};return[{x:o.x+n.x*e,y:o.y+n.y*e},{x:a.x+n.x*e,y:a.y+n.y*e},{x:a.x-n.x*e,y:a.y-n.y*e},{x:o.x-n.x*e,y:o.y-n.y*e}]},Ir=(r,t)=>{if(r.length<3)return r;const e=[];for(let i=0;i<r.length;i++){const s=r[i],n=r[(i+1)%r.length],o=r[(i-1+r.length)%r.length],a=q(s,n);if(ie(a)===0){e.push(s);continue}const l=pt(a),c={x:l.y,y:-l.x},d=q(o,s),u=ie(d);let p={x:0,y:0};if(u>0){const S=pt(d);p={x:S.y,y:-S.x}}const f=Ql(p,c),y=p.x*c.x+p.y*c.y,m=1/Math.max(.1,Math.sqrt((1+y)/2)),x={x:s.x+f.x*t*m,y:s.y+f.y*t*m};e.push(x)}return e},tc=(r,t,e)=>{if(Q(r,t)===0)return[];const s=$l(r,t),n=e/2;return[r.x+s.x*n,r.y+s.y*n,t.x+s.x*n,t.y+s.y*n,t.x-s.x*n,t.y-s.y*n,r.x-s.x*n,r.y-s.y*n]},Is=(r,t,e,i)=>{const s=q(r,t),n=q(r,e),o=Ql(s,n),a={x:-o.x,y:-o.y};return{x:r.x+a.x*i,y:r.y+a.y*i}},uy=(r,t,e,i,s,n)=>{const o=new Set(r),a=py(r,t),h=fy(a,o,t,e,i,s,n);return h||a},py=(r,t)=>{let e=0,i=0;for(let s=0;s<r.length;s++){const n=r[s],o=n%t,a=Math.floor(n/t);e+=o,i+=a}return{x:e/r.length,y:i/r.length}},fy=(r,t,e,i,s,n,o)=>{const a={x:i-10,y:r.y},h={x:n+10,y:r.y},l={x:i,y:s},c={x:i,y:o},d={x:n,y:s},u={x:n,y:o},p=zi(a,h,l,c),f=zi(a,h,d,u);if(!p||!f)return null;const y=[],m=Math.max(i,Math.min(p.x,f.x)),x=Math.min(n,Math.max(p.x,f.x)),S=Math.round(r.y);for(let v=Math.round(m);v<=Math.round(x);v++){const b=S*e+v;t.has(b)&&y.push({x:v,y:S})}if(y.length>=2){const v=gy(y),b={x:(v.min.x+v.max.x)/2,y:(v.min.y+v.max.y)/2},P=Math.round(b.y)*e+Math.round(b.x);if(t.has(P))return b}return null},zi=(r,t,e,i)=>{const s=(r.x-e.x)*(t.y-e.y)-(r.y-e.y)*(t.x-e.x),n=(r.x-i.x)*(t.y-i.y)-(r.y-i.y)*(t.x-i.x);if(s*n>=0)return null;const o=(e.x-r.x)*(i.y-r.y)-(e.y-r.y)*(i.x-r.x),a=o+s-n;if(o*a>=0)return null;const h=o/(n-s),l=h*(t.x-r.x),c=h*(t.y-r.y);return{x:r.x+l,y:r.y+c}},gy=r=>{if(!r||r.length===0)return{min:{x:0,y:0},max:{x:0,y:0}};let t=r[0],e=r[0];const i=s=>s.x-s.y;for(let s=1;s<r.length;s++){const n=r[s];i(n)<i(t)&&(t=n),i(n)>i(e)&&(e=n)}return{min:t,max:e}},An=(r,t)=>({minX:Math.min(r.minX,t.minX),minY:Math.min(r.minY,t.minY),maxX:Math.max(r.maxX,t.maxX),maxY:Math.max(r.maxY,t.maxY)}),my=r=>{if(r.length===0)return{x:0,y:0,width:0,height:0};let t=r[0].x,e=r[0].y,i=r[0].x+r[0].width,s=r[0].y+r[0].height;return r.forEach(n=>{t=Math.min(t,n.x),e=Math.min(e,n.y),i=Math.max(i,n.x+n.width),s=Math.max(s,n.y+n.height)}),{x:t,y:e,width:i-t,height:s-e}},yy=(r,t,e)=>{let i=1/0,s=1/0,n=-1/0,o=-1/0;for(let a=0;a<r.obstacles.length;a++){const h=r.obstacles[a],l=h%t,c=Math.floor(h/t);i=Math.min(i,l),s=Math.min(s,c),n=Math.max(n,l),o=Math.max(o,c)}return r.rooms.forEach(a=>{for(let h=0;h<a.length;h++){const l=a[h],c=l%t,d=Math.floor(l/t);i=Math.min(i,c),s=Math.min(s,d),n=Math.max(n,c),o=Math.max(o,d)}}),i===1/0?{minX:0,minY:0,maxX:t,maxY:e}:{minX:Math.max(0,i),minY:Math.max(0,s),maxX:Math.min(t,n),maxY:Math.min(e,o)}},xy=(r,t,e,i,s,n)=>{const o=e+s,a=i+n,h=Math.min(r.x,t.x),l=Math.max(r.x,t.x),c=Math.min(r.y,t.y),d=Math.max(r.y,t.y);if(l<e||h>o||d<i||c>a)return!1;if(Ba(r,e,i,s,n)||Ba(t,e,i,s,n))return!0;const u=[{x:e,y:i},{x:o,y:i},{x:o,y:a},{x:e,y:a}];for(let p=0;p<4;p++){const f=u[p],y=u[(p+1)%4];if(zi(r,t,f,y))return!0}return!1},Ba=(r,t,e,i,s)=>r.x>=t&&r.x<=t+i&&r.y>=e&&r.y<=e+s,Sy=(r,t,e,i)=>{const s=e/2;return i==="horizontal"?[{x:r-s,y:t},{x:r+s,y:t}]:[{x:r,y:t-s},{x:r,y:t+s}]},vy=(r,t,e)=>{const i={x:t.x-r.x,y:t.y-r.y},s=Math.sqrt(i.x*i.x+i.y*i.y);if(s===0)return[r,t];const n={x:i.x/s,y:i.y/s},o={x:r.x-n.x*e,y:r.y-n.y*e},a={x:t.x+n.x*e,y:t.y+n.y*e};return[o,a]},Da=(r,t,e)=>{const i=vs(r),s=vs(t),n=Math.max(0,Math.max(i.minX,s.minX)-Math.min(i.maxX,s.maxX)),o=Math.max(0,Math.max(i.minY,s.minY)-Math.min(i.maxY,s.maxY));if(n>e||o>e)return!1;let[a,h]=[r,t];t.length>r.length&&([a,h]=[t,r]);const l=Math.max(1,Math.floor(e)),c=new Map;for(const u of a){const p=Math.floor(u.x/l),f=Math.floor(u.y/l),y=`${p},${f}`;c.has(y)||c.set(y,[]),c.get(y).push(u)}const d=e*e;for(const u of h){const p=Math.floor(u.x/l),f=Math.floor(u.y/l);for(let y=-1;y<=1;y++)for(let m=-1;m<=1;m++){const x=`${p+y},${f+m}`,S=c.get(x);if(S)for(const v of S){const b=u.x-v.x,P=u.y-v.y;if(b*b+P*P<=d)return!0}}}return!1},Fa=(r,t,e,i)=>{let[s,n]=[r,t];t.length>r.length&&([s,n]=[t,r]);const o=new Set(s),a=i*i;for(let h=0;h<n.length;h++){const l=n[h],c=l%e,d=Math.floor(l/e);for(let u=-i;u<=i;u++)for(let p=-i;p<=i;p++){const f=c+u,m=(d+p)*e+f;if(o.has(m)&&u*u+p*p<=a)return!0}}return!1},za=(r,t)=>{if(r<=1)return!0;if(t.length===0)return!1;const e=Array.from({length:r},(a,h)=>h),i=Array(r).fill(0),s=a=>(e[a]!==a&&(e[a]=s(e[a])),e[a]),n=(a,h)=>{const l=s(a),c=s(h);l!==c&&(i[l]<i[c]?e[l]=c:i[l]>i[c]?e[c]=l:(e[c]=l,i[l]++))};for(const[a,h]of t)n(a,h);const o=s(0);for(let a=1;a<r;a++)if(s(a)!==o)return!1;return!0},by=(r,t,e,i="priority")=>{const s=new Map;if(r.length===0)return s;if(r.length===1)return s.set(r[0].id,0),s;const n=new Map;for(let h=0;h<r.length;h++){const l=r[h];n.has(l.id)||n.set(l.id,new Set);for(let c=h+1;c<r.length;c++){const d=r[c];t(l,d)&&(n.get(l.id).add(d.id),n.has(d.id)||n.set(d.id,new Set),n.get(d.id).add(l.id))}}const o=new Array(e).fill(0),a=[...r].sort((h,l)=>{const c=(n.get(h.id)||new Set).size,d=(n.get(l.id)||new Set).size,u=r.indexOf(h),p=r.indexOf(l),f=-u*.5+c*.5;return-p*.5+d*.5-f});for(const h of a){const l=n.get(h.id)||new Set,c=new Set;for(const u of l){const p=s.get(u);p!==void 0&&c.add(p)}let d=-1;if(i==="priority"){let u=-1,p=-1/0;for(let f=0;f<e;f++)if(!c.has(f)){const y=e-f,m=o[f]*.7,x=y-m;(x>p||x===p&&f<u)&&(p=x,u=f)}d=u,d===-1&&(d=0),o[d]++}else{const u=[];for(let p=0;p<e;p++)c.has(p)||u.push(p);if(u.length===0){let p=1/0,f=0;for(let y=0;y<e;y++)(o[y]<p||o[y]===p&&y<f)&&(p=o[y],f=y);d=f}else{d=u[0];let p=o[d];for(const f of u)(o[f]<p||o[f]===p&&f<d)&&(d=f,p=o[f])}o[d]++}s.set(h.id,d)}return s},wy=Symbol(),La=Object.getPrototypeOf,ir=new WeakMap,Ay=r=>r&&(ir.has(r)?ir.get(r):La(r)===Object.prototype||La(r)===Array.prototype),Cy=r=>Ay(r)&&r[wy]||null,Oa=(r,t=!0)=>{ir.set(r,t)},ws={},Br=r=>typeof r=="object"&&r!==null,Py=r=>Br(r)&&!Dr.has(r)&&(Array.isArray(r)||!(Symbol.iterator in r))&&!(r instanceof WeakMap)&&!(r instanceof WeakSet)&&!(r instanceof Error)&&!(r instanceof Number)&&!(r instanceof Date)&&!(r instanceof String)&&!(r instanceof RegExp)&&!(r instanceof ArrayBuffer)&&!(r instanceof Promise),ec=(r,t)=>{const e=Ga.get(r);if((e==null?void 0:e[0])===t)return e[1];const i=Array.isArray(r)?[]:Object.create(Object.getPrototypeOf(r));return Oa(i,!0),Ga.set(r,[t,i]),Reflect.ownKeys(r).forEach(s=>{if(Object.getOwnPropertyDescriptor(i,s))return;const n=Reflect.get(r,s),{enumerable:o}=Reflect.getOwnPropertyDescriptor(r,s),a={value:n,enumerable:o,configurable:!0};if(Dr.has(n))Oa(n,!1);else if(De.has(n)){const[h,l]=De.get(n);a.value=ec(h,l())}Object.defineProperty(i,s,a)}),Object.preventExtensions(i)},My=(r,t,e,i)=>({deleteProperty(s,n){const o=Reflect.get(s,n);e(n);const a=Reflect.deleteProperty(s,n);return a&&i(["delete",[n],o]),a},set(s,n,o,a){const h=!r()&&Reflect.has(s,n),l=Reflect.get(s,n,a);if(h&&(Wa(l,o)||As.has(o)&&Wa(l,As.get(o))))return!0;e(n),Br(o)&&(o=Cy(o)||o);const c=!De.has(o)&&Ty(o)?sr(o):o;return t(n,c),Reflect.set(s,n,c,a),i(["set",[n],o,l]),!0}}),De=new WeakMap,Dr=new WeakSet,Ga=new WeakMap,Cn=[1],As=new WeakMap;let Wa=Object.is,_y=(r,t)=>new Proxy(r,t),Ty=Py,ky=ec,Ry=My;function sr(r={}){if(!Br(r))throw new Error("object required");const t=As.get(r);if(t)return t;let e=Cn[0];const i=new Set,s=(m,x=++Cn[0])=>{e!==x&&(n=e=x,i.forEach(S=>S(m,x)))};let n=e;const o=(m=Cn[0])=>(n!==m&&(n=m,h.forEach(([x])=>{const S=x[1](m);S>e&&(e=S)})),e),a=m=>(x,S)=>{const v=[...x];v[1]=[m,...v[1]],s(v,S)},h=new Map,l=(m,x)=>{const S=!Dr.has(x)&&De.get(x);if(S){if((ws?"production":void 0)!=="production"&&h.has(m))throw new Error("prop listener already exists");if(i.size){const v=S[2](a(m));h.set(m,[S,v])}else h.set(m,[S])}},c=m=>{var x;const S=h.get(m);S&&(h.delete(m),(x=S[1])==null||x.call(S))},d=m=>(i.add(m),i.size===1&&h.forEach(([S,v],b)=>{if((ws?"production":void 0)!=="production"&&v)throw new Error("remove already exists");const P=S[2](a(b));h.set(b,[S,P])}),()=>{i.delete(m),i.size===0&&h.forEach(([S,v],b)=>{v&&(v(),h.set(b,[S]))})});let u=!0;const p=Ry(()=>u,l,c,s),f=_y(r,p);As.set(r,f);const y=[r,o,d];return De.set(f,y),Reflect.ownKeys(r).forEach(m=>{const x=Object.getOwnPropertyDescriptor(r,m);"value"in x&&x.writable&&(f[m]=r[m])}),u=!1,f}function Bs(r,t,e){const i=De.get(r);(ws?"production":void 0)!=="production"&&!i&&console.warn("Please use proxy object");let s;const n=[],o=i[2];let a=!1;const l=o(c=>{n.push(c),s||(s=Promise.resolve().then(()=>{s=void 0,a&&t(n.splice(0))}))});return a=!0,()=>{a=!1,l()}}function Ey(r){const t=De.get(r);(ws?"production":void 0)!=="production"&&!t&&console.warn("Please use proxy object");const[e,i]=t;return ky(e,i())}function U(r,t,e,i){let s=r[t];return Bs(r,()=>{const n=r[t];Object.is(s,n)||e(s=n)})}class Iy extends L{constructor(e){super();g(this,"dragStart",null);g(this,"initialTouchDistance",null);g(this,"initialScale",null);g(this,"activeTouches",new Map);g(this,"firstTouchId",null);g(this,"secondTouchId",null);g(this,"taintedPointers",new Set);g(this,"zoomFactor",.8);g(this,"scaleMin",.2);g(this,"scaleMax",5);g(this,"originalPosition",{x:0,y:0});g(this,"targetPosition",{x:0,y:0});g(this,"centerPosition",{x:0,y:0});g(this,"originalScale",{x:1,y:1});g(this,"targetScale",{x:1,y:1});g(this,"defaultScale",{x:1,y:1});g(this,"transitionDuration",500);g(this,"transitionStartTime",null);g(this,"initialPinchCenter",null);g(this,"isGestureValid",!0);g(this,"lastTapTime",0);g(this,"doubleTapDelay",300);g(this,"doubleTapZoomFactor",1.5);g(this,"lastTapPosition",null);g(this,"tapDistanceThreshold",20);g(this,"tapDetectionEnabled",!0);g(this,"mapClickStartPosition",null);g(this,"mapClickStartTime",0);g(this,"mapClickTimeThreshold",300);g(this,"mapClickMoveThreshold",10);g(this,"shouldSuppressMapClick",!1);g(this,"isGestureHijacked",!1);g(this,"hijackedPointerId",null);g(this,"isHijackPaused",!1);g(this,"interactionGraphics");g(this,"viewportBounds");g(this,"boundResetAnimation");g(this,"debouncedStopWheelRender");g(this,"debouncedLogWheelScale");g(this,"interactionState",{isInteracting:!1,isAnimating:!1,interactionTimer:null,renderReasons:new Set});g(this,"throttledAntiScale");g(this,"unsubscribeEnableInteraction",null);g(this,"handleSuppressMapClick",()=>{this.shouldSuppressMapClick=!0});g(this,"handleGestureHijacked",e=>{var n,o;this.isGestureHijacked=!0,this.hijackedPointerId=e.pointerId,this.isHijackPaused=!1,this.clearTouches();const i=e.global.x-this.viewportBounds.x,s=e.global.y-this.viewportBounds.y;this.activeTouches.set(e.pointerId,{x:i,y:s}),this.firstTouchId=e.pointerId,this.dragStart={x:i,y:s},(o=(n=this.appService.events)==null?void 0:n.onGestureStart)==null||o.call(n)});this.appService=e;const i=e.getApp();this.viewportBounds=i.getViewportBounds(),this.eventMode="static",this.unsubscribeEnableInteraction=U(e.runtime,"enableInteraction",s=>{this.updateInteractionMode(s)}),this.updateInteractionMode(e.runtimeSnapshot.enableInteraction),this.interactionGraphics=new H,this.interactionGraphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill({color:"#ffffff",alpha:0}),this.addChild(this.interactionGraphics),this.scaleMax=i.scaleMax,this.scaleMin=i.scaleMin,this.centerPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.originalPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.targetPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.throttledAntiScale=At(s=>{this.appService.emitter.emit("antiScale",s)},16,{leading:!0,trailing:!0}),this.boundResetAnimation=this.resetAnimation.bind(this),this.debouncedStopWheelRender=Tn(()=>{i.stopRender("wheel")},300),this.debouncedLogWheelScale=Tn(s=>{A.debug("[Interaction] 滚轮缩放完成 - Scale:",s.toFixed(3))},500),this.setupInteraction()}updateInteractionMode(e){this.eventMode=e?"static":"none",A.debug(`[Interaction] 交互模式已更新: ${e?"启用":"禁用"}`)}setupInteraction(){this.on("pointerdown",e=>this.onPointerDown(e)),this.on("pointerup",e=>this.onPointerUp(e)),this.on("pointerupoutside",e=>this.onPointerUp(e)),this.on("pointermove",e=>this.onPointerMove(e)),this.on("wheel",e=>this.onWheel(e)),this.appService.emitter.on("gestureHijackStart",this.handleGestureHijacked),this.appService.emitter.on("suppressMapClick",this.handleSuppressMapClick),document.addEventListener("pointercancel",e=>{A.debug("[Interaction] Received global pointercancel"),this.handleGlobalCancel(e)})}handleGlobalCancel(e){const i=this.appService;if(this.isGestureHijacked){A.debug("[Interaction] 系统取消或移出视口,强制结束劫持手势");const s=i.getApp(),n=new fa(s.renderer.events);n.pointerId=e.pointerId,i.emitter.emit("gestureHijackPointerUp",n),this.exitGestureHijacked()}this.clearTouches()}resetPan(e){const i=this.appService,s=i.getApp(),n=i.appContainer;this.transitionStartTime!==null&&(s.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null);const o=this.centerPosition.x-e.x*n.scale.x,a=this.centerPosition.y-e.y*n.scale.y;this.originalPosition={x:n.x,y:n.y},this.targetPosition={x:o,y:a},this.originalScale={x:n.scale.x,y:n.scale.y},this.targetScale={x:n.scale.x,y:n.scale.y};const h=Math.sqrt((n.x-o)**2+(n.y-a)**2),c=(d=>Math.pow(Math.min(1,d/1e3),.5))(h);this.transitionDuration=500+1e3*Math.min(1,Math.pow(c,2)),this.transitionStartTime=s.ticker.lastTime,s.ticker.add(this.boundResetAnimation)}setPanZoom({targetPosition:e,targetScale:i,setCenter:s=!1,setScale:n=!1}={},o=!0){const a=this.appService,h=a.getApp(),l=a.appContainer;if(s&&e&&(this.centerPosition={x:e.x,y:e.y},A.debug("[Interaction] Set center position:",this.centerPosition)),n&&i&&(this.defaultScale={x:i.x,y:i.y},A.debug("[Interaction] Set scale:",this.defaultScale)),this.originalPosition={x:l.x,y:l.y},this.originalScale={x:l.scale.x,y:l.scale.y},e?this.targetPosition=e:this.targetPosition={x:this.centerPosition.x,y:this.centerPosition.y},i?this.targetScale=i:this.targetScale=this.defaultScale,!o){l.position.set(this.targetPosition.x,this.targetPosition.y),l.scale.set(this.targetScale.x,this.targetScale.y),this.antiScale(this.targetScale.x),this.transitionStartTime!==null&&(h.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),A.debug("[Interaction] 直接设置缩放完成 - Scale:",this.targetScale.x.toFixed(3));return}const c=Math.sqrt((l.x-this.targetPosition.x)**2+(l.y-this.targetPosition.y)**2),u=(m=>Math.pow(Math.min(1,m/1e3),.5))(c),f=((m,x)=>Math.pow(Math.min(1,Math.abs(m-x)/Math.abs(.2-1)),.5))(l.scale.x,this.targetScale.x),y=u*.8+f*.2;this.transitionDuration=500+1e3*Math.min(1,Math.pow(y,2)),this.transitionStartTime!==null&&(h.ticker.remove(this.boundResetAnimation),this.interactionState.isAnimating=!1,h.stopRender("animation")),this.interactionState.isAnimating=!0,h.requestRender("animation",!0),this.transitionStartTime=h.ticker.lastTime,h.ticker.add(this.boundResetAnimation)}clearTouches(){var s,n;const i=this.appService.getApp();this.activeTouches.clear(),this.firstTouchId=null,this.secondTouchId=null,this.dragStart=null,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.isGestureValid=!0,this.taintedPointers.clear(),this.transitionStartTime!==null&&(i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),this.interactionState.isInteracting&&(this.interactionState.isInteracting=!1,(n=(s=this.appService.events)==null?void 0:s.onGestureEnd)==null||n.call(s)),i.stopRender("interaction")}checkEventListeners(){return{wheel:this.listenerCount("wheel"),pointerdown:this.listenerCount("pointerdown"),pointerup:this.listenerCount("pointerup"),pointerupoutside:this.listenerCount("pointerupoutside"),pointermove:this.listenerCount("pointermove")}}destroy(){this.checkEventListeners(),this.interactionState.interactionTimer&&clearTimeout(this.interactionState.interactionTimer),this.interactionState.renderReasons.clear(),this.interactionState.isInteracting=!1,this.interactionState.isAnimating=!1,this.debouncedStopWheelRender.cancel(),this.debouncedLogWheelScale.cancel(),this.unsubscribeEnableInteraction&&(this.unsubscribeEnableInteraction(),this.unsubscribeEnableInteraction=null),this.appService.emitter.off("gestureHijackStart",this.handleGestureHijacked),this.appService.emitter.off("suppressMapClick",this.handleSuppressMapClick),super.destroy()}exitGestureHijacked(){var i,s;const e=this.appService;this.hijackedPointerId!==null&&!this.isHijackPaused&&(this.activeTouches.delete(this.hijackedPointerId),this.firstTouchId===this.hijackedPointerId&&(this.firstTouchId=null,this.dragStart=null),this.secondTouchId===this.hijackedPointerId&&(this.secondTouchId=null)),this.isGestureHijacked=!1,this.hijackedPointerId=null,this.isHijackPaused=!1,(s=(i=e.events)==null?void 0:i.onGestureEnd)==null||s.call(i)}forceEndGesture(){if(this.isGestureHijacked){A.debug("[Interaction] 强制结束劫持手势");const e=this.appService.getApp(),i=new fa(e.renderer.events);i.pointerId=this.hijackedPointerId,this.appService.emitter.emit("gestureHijackPointerUp",i),this.exitGestureHijacked()}this.clearTouches()}pauseGestureHijack(){this.isHijackPaused=!0}resumeGestureHijack(){this.isHijackPaused=!1}antiScale(e){this.throttledAntiScale(e)}resetAnimation(){const e=this.appService,i=e.getApp(),s=e.appContainer;if(this.transitionStartTime===null)return;const{targetPosition:n,targetScale:o}=this,a=i.ticker.lastTime,h=Math.min(1,(a-this.transitionStartTime)/this.transitionDuration);if(h>=1)s.position.set(n.x,n.y),s.scale.set(o.x,o.y),this.antiScale(o.x),i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null,this.interactionState.isAnimating=!1,i.stopRender("animation"),A.debug("[Interaction] 动画缩放完成 - Scale:",s.scale.x.toFixed(3));else{const l=iy(h),c=this.originalPosition.x+(n.x-this.originalPosition.x)*l,d=this.originalPosition.y+(n.y-this.originalPosition.y)*l,u=this.originalScale.x+(o.x-this.originalScale.x)*l,p=this.originalScale.y+(o.y-this.originalScale.y)*l;s.position.set(c,d),s.scale.set(u,p),this.antiScale(u)}}onWheel(e){const i=this.appService;if(this.isGestureHijacked){A.warn("⚠️ [onWheel] 被手势劫持阻止执行",{isGestureHijacked:this.isGestureHijacked,hijackedPointerId:this.hijackedPointerId,isHijackPaused:this.isHijackPaused});return}i.getApp().requestRender("wheel",!0),this.debouncedStopWheelRender();const{scaleMin:s,scaleMax:n}=this,o=i.appContainer;e.preventDefault();const a=e.global.x-this.viewportBounds.x,h=e.global.y-this.viewportBounds.y,l=(a-o.x)/o.scale.x,c=(h-o.y)/o.scale.y,d=e.deltaY>0?.95:1.05;let u=o.scale.x*d,p=o.scale.y*d;if(u=Math.max(s,Math.min(n,u)),p=Math.max(s,Math.min(n,p)),!(u!==o.scale.x||p!==o.scale.y))return;const y=a-l*u,m=h-c*p;try{o.scale.set(u,p),o.position.set(y,m),this.antiScale(u),this.debouncedLogWheelScale(u)}catch(x){A.error("❌ [onWheel] 应用缩放时发生错误:",x)}}onPointerDown(e){var l,c;const i=this.appService;this.interactionState.isInteracting||(this.interactionState.isInteracting=!0,i.getApp().requestRender("interaction",!0),(c=(l=i.events)==null?void 0:l.onGestureStart)==null||c.call(l)),this.isGestureHijacked&&e.pointerId!==this.hijackedPointerId&&!this.isHijackPaused&&this.pauseGestureHijack();const s=i.getApp(),n=i.appContainer;this.transitionStartTime!==null&&(s.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),this.activeTouches.size===0&&this.taintedPointers.size>0&&(A.debug("[Interaction] 清除污染指针列表,准备新手势",Array.from(this.taintedPointers)),this.taintedPointers.clear()),this.activeTouches.size===0&&(this.isGestureValid=!0,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.dragStart=null,this.firstTouchId=null,this.secondTouchId=null),this.activeTouches.has(e.pointerId)&&this.activeTouches.size===1&&(this.isGestureValid=!0);const o=e.global.x-this.viewportBounds.x,a=e.global.y-this.viewportBounds.y;this.activeTouches.set(e.pointerId,{x:o,y:a});const h=this.activeTouches.size-this.taintedPointers.size;if(this.taintedPointers.size>0){A.debug("[Interaction] 存在污染指针,阻止多点触摸手势",Array.from(this.taintedPointers)),h===1&&!this.taintedPointers.has(e.pointerId)&&(this.firstTouchId=e.pointerId,this.dragStart={x:o,y:a});return}if(this.activeTouches.size===1)this.firstTouchId=e.pointerId,this.dragStart={x:o,y:a},this.mapClickStartPosition={x:o,y:a},this.mapClickStartTime=performance.now();else if(this.activeTouches.size===2){const d=Array.from(this.activeTouches.keys());this.secondTouchId=d.find(u=>u!==this.firstTouchId)||e.pointerId,this.setInitialScaleAndDistance(n),this.tapDetectionEnabled=!1}}onPointerUp(e){var n,o;const i=this.appService;if(this.taintedPointers.has(e.pointerId)&&(A.debug("[Interaction] 移除污染指针",e.pointerId),this.taintedPointers.delete(e.pointerId)),this.isGestureHijacked)if(e.pointerId===this.hijackedPointerId){i.emitter.emit("gestureHijackPointerUp",e),this.exitGestureHijacked();return}else this.isHijackPaused;if(!this.activeTouches.has(e.pointerId))return;const s=this.initialTouchDistance!==null&&this.initialScale!==null;if(this.activeTouches.delete(e.pointerId),A.debug(`[Interaction] onPointerUp, remaining touches: ${this.activeTouches.size}`),s&&this.activeTouches.size===1){this.isGestureValid=!1;const a=Array.from(this.activeTouches.keys());setTimeout(()=>{var h,l;!this.isGestureValid&&this.activeTouches.size>0&&(A.debug("[Interaction] 100ms 缓冲结束,检测到真正的幽灵指针,标记为污染并清理",a),a.forEach(c=>{this.activeTouches.has(c)&&(this.taintedPointers.add(c),this.activeTouches.delete(c),this.firstTouchId===c&&(this.firstTouchId=null,this.dragStart=null),this.secondTouchId===c&&(this.secondTouchId=null))}),this.activeTouches.size===0&&this.interactionState.isInteracting&&(A.debug("[Interaction] 清理幽灵指针后所有触摸点已释放,结束手势"),this.interactionState.isInteracting=!1,i.getApp().stopRender("interaction"),(l=(h=i.events)==null?void 0:h.onGestureEnd)==null||l.call(h)))},100),this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null}e.pointerId===this.firstTouchId?(this.firstTouchId=null,this.dragStart=null,this.activeTouches.size===0&&this.tapDetectionEnabled&&this.detectDoubleTap(e),this.activeTouches.size===0&&!s&&this.detectMapClick(e)):e.pointerId===this.secondTouchId&&(this.secondTouchId=null),this.isGestureHijacked&&this.isHijackPaused&&this.activeTouches.size===1&&Array.from(this.activeTouches.keys())[0]===this.hijackedPointerId&&this.resumeGestureHijack(),this.activeTouches.size===0&&(this.isGestureValid=!0,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.firstTouchId=null,this.secondTouchId=null,this.dragStart=null,this.tapDetectionEnabled=!0,this.interactionState.isInteracting&&(this.interactionState.isInteracting=!1,i.getApp().stopRender("interaction"),(o=(n=i.events)==null?void 0:n.onGestureEnd)==null||o.call(n)))}detectDoubleTap(e){const i=this.appService,{interactionConfig:s}=i;if(!s.enableDoubleTapZoom)return;const n=performance.now(),o={x:e.global.x-this.viewportBounds.x,y:e.global.y-this.viewportBounds.y};n-this.lastTapTime<this.doubleTapDelay&&this.lastTapPosition&&Q(o,this.lastTapPosition)<this.tapDistanceThreshold?(this.handleDoubleTap(o),this.lastTapTime=0,this.lastTapPosition=null):(this.lastTapTime=n,this.lastTapPosition=o)}detectMapClick(e){var h;const i=this.appService;if(!i.runtimeSnapshot.enableMapClickCapture||!((h=i.events)!=null&&h.onClickMap)||!this.mapClickStartPosition)return;const n=performance.now()-this.mapClickStartTime,o={x:e.global.x-this.viewportBounds.x,y:e.global.y-this.viewportBounds.y},a=Q(this.mapClickStartPosition,o);if(n<=this.mapClickTimeThreshold&&a<=this.mapClickMoveThreshold&&!this.shouldSuppressMapClick){const l=i.appContainer,c=i.mapState,d=(o.x-l.x)/l.scale.x,u=(o.y-l.y)/l.scale.y,p={x:d-((c==null?void 0:c.origin.x)||0),y:u-((c==null?void 0:c.origin.y)||0)};A.debug("[Interaction] 地图点击捕获",{screenPosition:o,containerPosition:{x:d,y:u},origin:c==null?void 0:c.origin,mapPosition:p,clickDuration:n,moveDistance:a}),i.events.onClickMap(p)}this.mapClickStartPosition=null,this.mapClickStartTime=0,this.shouldSuppressMapClick=!1}handleDoubleTap(e){const i=this.appService,s=i.getApp(),n=i.appContainer,{scaleMin:o,scaleMax:a,doubleTapZoomFactor:h}=this,l=e.x,c=e.y,d=(l-n.x)/n.scale.x,u=(c-n.y)/n.scale.y;let p=n.scale.x*h,f=n.scale.y*h;p=Math.max(o,Math.min(a,p)),f=Math.max(o,Math.min(a,f)),this.originalPosition={x:n.x,y:n.y},this.originalScale={x:n.scale.x,y:n.scale.y};const y=l-d*p,m=c-u*f;this.targetPosition={x:y,y:m},this.targetScale={x:p,y:f},this.interactionState.isAnimating=!0,s.requestRender("animation",!0),this.transitionDuration=300,this.transitionStartTime=s.ticker.lastTime,s.ticker.add(this.boundResetAnimation)}onPointerMove(e){if(this.isGestureHijacked&&!this.isHijackPaused)if(e.pointerId===this.hijackedPointerId){const n=e.global.x-this.viewportBounds.x,o=e.global.y-this.viewportBounds.y;this.activeTouches.set(e.pointerId,{x:n,y:o}),this.appService.emitter.emit("gestureHijackPointerMove",e);return}else return;if(!this.activeTouches.has(e.pointerId)||!this.isGestureValid)return;if(this.taintedPointers.size>0&&(this.initialTouchDistance!==null||this.initialScale!==null)){A.debug("[Interaction] 存在污染指针,阻止多点触摸手势移动");return}const i=e.global.x-this.viewportBounds.x,s=e.global.y-this.viewportBounds.y;this.activeTouches.set(e.pointerId,{x:i,y:s}),this.activeTouches.size===2&&this.initialTouchDistance!==null&&this.initialScale!==null&&this.applyPinchZoom(),this.activeTouches.size===1&&(this.initialTouchDistance!==null||this.initialScale!==null)&&(this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.secondTouchId=null),this.activeTouches.size===1&&e.pointerId===this.firstTouchId&&this.dragStart!==null&&!this.taintedPointers.has(e.pointerId)&&this.applyPan(e)}applyPan(e){const i=this.appService,s=this.activeTouches.get(e.pointerId),n=i.appContainer,{x:o,y:a}=this.dragStart;n.position.set(n.x+s.x-o,n.y+s.y-a),this.dragStart={x:s.x,y:s.y}}applyPinchZoom(){const i=this.appService.appContainer,s=Array.from(this.activeTouches.values());if(s.length<2||!this.initialTouchDistance||!this.initialScale||!this.initialPinchCenter)return;const n=Q(s[0],s[1]),o={x:(s[0].x+s[1].x)/2,y:(s[0].y+s[1].y)/2},a={x:(o.x-i.position.x)/i.scale.x,y:(o.y-i.position.y)/i.scale.y},h=(n/this.initialTouchDistance)**this.zoomFactor,l=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.x*h)),c=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.y*h));i.scale.set(l,c);let d=o.x-a.x*l,u=o.y-a.y*c;const p=o.x-this.initialPinchCenter.x,f=o.y-this.initialPinchCenter.y;d+=p,u+=f,i.position.set(d,u),this.antiScale(l),this.initialPinchCenter=o}setInitialScaleAndDistance(e){const i=Array.from(this.activeTouches.values());i.length<2||(this.initialTouchDistance=Q(i[0],i[1]),this.initialScale={x:e.scale.x,y:e.scale.y},this.initialPinchCenter={x:(i[0].x+i[1].x)/2,y:(i[0].y+i[1].y)/2})}}const By="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAaVBMVEUAAAA3yFI4x1E3yFM4x1Q3yFI4x1I3yFM3ylVAz1BEzF44yFI3ylI3yFI2yVNGzF9GzGA3yFM4x1JKzWJY0nB62or///83yFL///+b46hQz2jN8dRp1n1Ey13y+/SC3ZPm+Om06r6n57PA80FIAAAAF3RSTlMA3yC/QO9grzAQ75+PcFDfz8+Ar2AwEAVwkmAAAANrSURBVGje1ZtpktowEEZbkiVvmG1m+Ixg1vsfMqnUVPWPkLG6W+DKu8CrJ7UBG5nEnLrtsQ1h5yIwOLcP45ReerovXWoPuIlrJ0/3wad2wI/Ep1S/PLUoIjQ13X4cUEzcNJW0TYCQUEP9zNpHqr2DHLvajzCwUY9ZcjARJ13uAWaCl3u3DhWI4p0+opTrwk7LlnmHYi74mb2/z0V0nbGAKzZ3DoLgRTFcVzhWUeB9n+daI5Yg4aNEDKRlbwOIgsvE2C7ub5QFl4pjV2WeOZjFgtk2e1/fWGwz7yHiPAvE2P3buwFkwSIxjtaB5mAWW0bb80ALglms3uYARhAsEONwyzuBEQSzWPkJ1kcwgmCZ2Hn1RHOwRoxRPdEcrBLDKyeLg5ViZw5WivFsDFaLgyn4a1aL0RiC82wQB0Pwp0UMr76G82wSj+oPrU+beNCudJ5tYiTlaF2s4vZ7pSHjOpvEPF4JMi42Ma/1EwRwsFbMay2c6YtNzHPtIYCDTWJ08p88F6OYN7mFAA7WinmTHSRc6ogP0quYg5nzDV6xwIleIOEyF3EpmK4kCy7jWnA3M60SjCONAu97tWC0oq+mj2rBCLR/bDCL3SrB2JFbJRiOBhTyWjMYkVDKuWYwQMXBb1WCWRzXCR7IrRPsaPfYYBaHVYKxp7BKMAK1qwRjpOMqwZhou0owEnWrBOOFTljm/fw3X6Zg9EQHqMimYCf+Qc9iU3ArvktlsSUY029xBxVZG8x35gM0ZEtwJFJvcrYEPxGpNzlrg/lRhIeGbAhGT/q1zobgQKRf66wL5ue32rnO+uDY0zcj5GRVMB+UUI9XVgej0TwoZ7E6OKj+GmCxJdiSnC3BzDOkZFMw4yAk24L1g52twdprOSuvYfPpvGz80GISRGRV8EQ3OEBCVn8tGRc7K4Kjp5tsISArghvbQT0Wc7Buopkdisni4H2dQ0ZZEFz1eFPmYInXfpAsy4Jjxw7baGdZcFPtsGAWPgAooIlFYkFw3FY8EJrLg11X8whsLg52ksO3+2VxafDOk4TNorgw+CiQ8oiZcVsS4wPMHDxpmKIxN5GSfgMDo6/7OoroInq4Ojz/vy/h/FFvBGM2jJ7q0Zdmt4lq06enuNDapru91za1Djc5tKmj+9K/pGkMe+cGILpdCO1x251Iyi/g4vimU9Z1kQAAAABJRU5ErkJggg==",Dy="/assets/robot.CSiuukeH.png",Fy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAgH/fIL9gcEDvoBDPsJCPUDD8BuiCAAACCklEQVRo3u3Zza6bMBCG4Y/434aQzP1fbCt14SOZSac+zPQs/C4jwaME7ICN1Wq1Wq1W87VYd0dEe9gy7MqBvuQi9OusHp3PenqMPeiix31uZU5YiVTlB3PCk5jSTXChS9kTV2m3uG/mR0zEtt0Ce7qWKw873FK5livx+VvgRJdyIr6IW9ou5Ux8T2jKgYcrNOXMwwGq8qYM83IqLKws+8rB2jISA+vLkbmr9eUnM1mry819+GO0Hs8ZPdPx3NCzlB16pvKBnqkc0TOVPXqWskPPVH6iZyp79CzlHUM2csSQiewwZCNHDJnIAUM2cgOTosy35CUvecn/W37H83C/C8nbyT6FMhjqcnsE6pnJOdBFTVPu7FiEqvwOxJTAyeN1KrQf8Z/ck9gyZPLL0Z+cF7N+l6yX8rL3r7P0z8tb6jreLV7pLba77K01IWcR/MlNwIycxDsS/Er8lFwFrv/szslBAEeJK5fl8CFx5bIc3jn3AKblQwBzrmuYl5/fgD0wL78EcOEv8Lzsp6cPB3xDDhBUmZlyWpYenZgvPC8Lj27cfta8HCEq0Fi2eN7OzFjSlwMDq8u+MLC6nAYYsJGfw3aWlVyH6cNK3obpw0qOrrsehnLfN9299Zu7j4FKiD97zeBvcgKfqlwaDNukI1JT3mBalyNs26RzgZb8gnlxpxIyVqvVarVarb70C7CyrCEVukMsAAAAAElFTkSuQmCC",zy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMA3yC/EECAYM+f73CQr1Awj6BvNXOp4gAAAlpJREFUaN7s1t1ugzAMhmE7TgghgdL5/u91ndBK11SYfFonTcpzXl7yR0Nd13Vd13Xd/+VWVk6OAD7PzCxDIMCHbtrTQfQbR2o1oD/2q97A6agPBjrPsd4BU+ZZgfLehQcd9acMdKEXF31yoVNYX0uewAewb9mRtfFkmaHZcroDy1qZfMMCweULtEGCHprJlrU2kiXpsRXanPbG9mrJZIjQzxY12O/O0BoVNbFHTiPDe3q32lu6NtnzZAv257Zmn32bGP9LaBgfsh9VwameoCHbXRVgjWtTc1eLEZ71FNfa1WCEIxS2u0wWAcOO9UiknblBphLdTViKTMb7W12mEyJv2cHTLpRRd0PjRLGjU0IecvDVoLLo5ko3IY0yx2prGF2Qi/PI8lVzsj/TvLbg3YMl3cp6oHgC2MddjsMS6Bddnj8NAmQRw/OlJgBZxFUfpNf3Dsme6P1hCqx3k5SloYpO9XA//SWlVPLi6G1Cdev8K/I407Z3fUBweFnQLi5+tmcGOQzCMBA0EBKSllz4/1/b+x6QVXmqVp4PrBDGeHfP7ei7JX9LmXM1nlKHIwUK+JaMQbfHw1C6RCoMTQ57iEUMAkOTIwDiEGsCoGddMYouthdiiNFnmBJtQHQNohkWV7YRYJrol6wZ+DCE05kjBawteK4d0VnAbEGPfF8cTAvhPnAcq0VTHTkWIKwdLySsBQkgDBxBsjHJ2W6qB9zYskDADVbGpSB+Zru+NF4TEHb3UtUi2aHhUqq3aPn9H4XV4MLDU06PWgyhbaCsNlDjrbmcz8wzkyRJkuRDXlF2skMkf3lIAAAAAElFTkSuQmCC",Ly="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMA359AIL+QYBDvMIBwr6CPz1BvDk7raQAAAplJREFUaN7t2tuO3CAMBmDbQALkOOv3f9dKrVbWMiSQTHGqiu96oz94OGeh67qu67rP+JF2ZObdTQb0GMcscAQdnlgoRkfkdxM0ZyVXN5k4b4bGkPOChbb4yAAJreDgoSnkIwaaGpif6V6RjxAktJq8QGMr5zlobUTdYGFRsdTlZAIFRm+dKPewF2iw/CaCioVToMMojyYRdJdFMagsTuVaB9DilacP4RQqXf6REfSMCtuP8uRlQRE2GcTezLQ4t9D0isWFAu1fK+MWmIXbzOlIHuFA3JAZqfq9vgKnAr1nY6nQ23dFIlSZOAu/bNKecJ5L8qi/lSu2n9F2RSRTM97o6vj84PBv8eLMhnxqu5XL7n6D02QzE80WDpj0/f1HDZaq+YV/I59tLnFqLC6zRSSFzHdYs+Seutel05WIjk4Q3myBc3Y456qCY3Zfa8fNnTx1bq8q9fC+JBpCPgXnuCjYZFdNcu3WKFjm3TUJtoHbBn9PkGmpiYv228PYDaPNDjorT51wtzpXGIw/6vwEVcHTjRuOxUDK/5xAVi4yl6fq/P7BrjJl1sx3ePGAwHj4pnYmmqNsss+NFw8I5W1cXTJCkbmUK0a812Cx1vy9IUw3j3a43aXTDsvr+fYxxPRXxxu5ItZvWyFl1szOeIZKdkVmHGJ5yGX3+YP7OffYBvd6dFS01/TnADTLjPe5rXqU/CfH0zkZn2pQ9XZLmGSVVUPpAUFL+Dcu9J67wgygxPFDl6dqH1/KX/gsaHjpfvYRk9732/K2GzWKvfBDya7yEkohWKmHLfXXX206l/oXvvmp/wMxfAShKR/4CLQ1PBVsg26py92LoLWJ9abNcjJGUPB++CcPGtJoZ0CPmdzOzLjT6KHruq7ruo/8Ani9wIJR4hr/AAAAAElFTkSuQmCC",Oy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAIN9A7xC/gGDPn3BQkK8wj6DdtO0oAAADPElEQVRo3u2Z2Y7rIAyGwWYnS8fv/7BHlTpi0gacsuTc8N1VivqDF2yMmEwmk8lk0h9nFJHfohT90HEDIlLG5f810C/GdZJFQwkrznnQH3yPXUtDB0CefkVHbLPuooguKAd649GoaylRUlb0TmjW/cQwlm7fc6RzHleEKdbHFeXYr3ypdK0wUA7D+LgttB3lceLI2nPLQHlAHEHqt2WkEu6KrU2V8EolzBXzqCphQ0XwyteyRthTkfXK11gj/EMJPmRVP2Ekuh5emk7RI5wc+FWCqEJC2dZ8NQliiDKy1kFRi/OUJ3LlxIgGtJRyX34YQzqmhtUjLZRCB5iFtSA/d12OaZCiEw5yB2KoOC5bolwyjU8/9HYq7NhS3I49OxAhoztKGVJo8brtxA8vhqH+TaBK6XJqaYViDBKOaUpHvBTDWNYQdaYHWMVtGEp4FPeBybtR3IBecH9ZHuiJt7pbGDkbjIcnxjwifgwKAF/S1kbsN3BR9M62vB/brrffDJ0T9DF3Vdfk2Q1l8U/lZUz6RCphj/cqKFsuQBqPcVgqot5uGaU4Mb+rW+rv4wl5EPbXGgdsaaZTGV4utHS7/a7VDZQn/QUc2xBtN2NMeESHuD/7YffwXzb3WrGWPtjFpl9lLFd4qIxyL49sf04uIJ6tzdJ+T8GwuD0tlgVa7qYqZvOPhxFWJWtJMU6YsgAymT9IeNUioa0hCDplAg/UmVrhySEDOo3EWEzVHNHLE900PtZADHwV27KlMGE+LjE7b+yloiR6nYsldz2+uMqI/A0bziqEqzi4uOjCfPLA4bmmBH7fBoRS+Gm2nvLJlEtKLFWR5fNprHoAZMsz562QJLYul86Tciu+t5hL7YsXl8BiaDHvHQ4aBk+xEFobF63SQv2F2eYXq3jvyeOubc0sbdMZNzB5gj/wcsUqvx0gKlIbZr3AnwwanXO76MXGZMowPPMoMgzmTXcYO3P+D2D0YLrqnuGHKXPlHhYxGFdxJRsrTFEMZaEcaqyfJdM3j0MVZjJDMUzjPIzI9HPD0IoRHoZlfDwOzzygD0MC/adKIf1tdYL3s9XiFuSriUyd5H3gap7iYFbUYjKZTCaTSRP/AEYn9FrTdrbUAAAAAElFTkSuQmCC",Gy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMA3yCAEGC/759AcFDPkDCvoI+BJCYaAAADo0lEQVRo3u2a2barIAyGCSQMjpX3f9izzunqoYoxbhD3jd9d6/CXEDJA1cPDw8PDw0MNYZkhxgh26VHdBhoXv/Ba3UPn4obljlGjjzlww6BtjL+iTHEfaG1tGxkW1RaIHIyx2wuPiqG1MKimvCJLW/cKvHCvmmJZYVJN0Y4T7lRbJs6/zOY+6vXFY36dEO6HusSlQ5hybzXiHC9VOTMsb6ta2j49Cl5tatKHtnyyx715DvuZxE0/06W190InLmdkwpugLE6j1cfL2SV/LkrWvPtArxJ9/sOSsbhLMr24YNDxF7vioKZPxIiR9y1TnLl85PC8e+Fq/ouGrGOUlZGdR4w5tmDAnLUtNyYqTdYYDzH7k6yPixQqqGCZ0NgztjTFFZkXhJ3eMQwJDjKX1xgJm5sUpJU4KBkXJbpU920GjEMsF44iDpMvrAc8C1aqFI7jZjZJdI+53tRpyHbzVpyF2RFI0yS8J6S0l+a3orMyp2yd7rQ6+XPNFKeMJ4fs6WV9yNdRaZKYkrIbvDHeDkINLen6s/l4/hRa+LFCP67Ew490B1Rn0Z33Y8D1d2TZEXhBt5ik7WJ0b0MHD2BJTmgjqkvQeuX8Fo+bVwjqWug7emg20hhUFwMrR3P3yK6NO+7Xw85eYuSJusV7b/q88vb/PsN6Zj3VDxb7ZciaqGkbPnX3vsnBPJJW1WBnd8MQup32VGuNF83k7LjAaxrubwV7lGperfZttRX28GhosmDIyckV9X//62hSMpXVAO0fFoDv2+qOfDfttssXzQzDfH55kZjk+A7AmoD/t40+XmFKG/PEC9+3LNYSWw8P1nu/Woq+dsCv790Gn7olkVNjHqTHzfdHPCXsUNbVki6t3+ZOKYeKzXCT5+J1i15Z4ZKgS5ulNV01ySSsX8jCdlNh2Lvssl37mrZtYjcgcp+fsr28irMSPPzBeu/rWRaeyk61gNlL9OsNbB5XmCKIiS5u1ejV9m3TQWOtmbjQV0xxwvKGImaVCA4G6hSB7+hn9oqR45bMyL5+EPapK49acWCiFh55TXfBqbaG/WGFw5dOwIbLMmV/dFphmadEXVkZ9KE1jRADTGmpOWih/DRHBZvrSs5NIVWImbuzJ4AE2TlZgTbK/xHIOyiaP3V2UBdhzv7zJfR0RVcjL1Wj2kJ82muLFhJ9O4BPA20xvyWMrqBTaOnXoJpjCpZTO2Wj7oCA2RtuDhIwm7TtCaP9Kw6zCerh4eHh4eFq/gDsgRtLdqAVbwAAAABJRU5ErkJggg==",Wy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA3yBgv58Q74BwQK+PzzBQHgQBUQAAAqhJREFUaN7t2etu8yAMBmBO4ZgQ7v9qv2na+kpVEgKOqfQN/1vK+hRjE9KKGTNmzJgxYwY9VCrOKDE8lCxfIR+SYwjx3ki7le+Qz03iXvrW8hOe7tov9276QnlFJMO+lLuycoDpyyxvvBdyg1iocLk3CyzwU8u83ZKxwAhispdyS8YCYzC1m27JyMy6INn8MhbYCPxD5Jfj78tO4Q+MZZPRSTt6Hz3FJ6fXAr81v2aV0Umb/RmPoYwyOsm9rgfUGqNsfi+Ho2t8MmZ3NNwpLjmXQ0JjA+ORcXk/2Ws9s7yejlassrQY15BsuhwvbmyBUV6vBjvFJ9ujwRqNxiPXTxF6rIyxUg2WNW6Qg2Uke7CMZNvBssYZYayMZKvBsnLYOcfKHvU1WEYzD5YVmnmwjPoaK2OcEYNl/VR9GdUoy2dayhfZKOdHDiPWlWZ5wQDKhEurjJbypAl3yJ56l8Ijy9ZU21aSC9sgaS2yxuftCayWs439LInbl8eEW2QUdiBmOopGORP3TYc9qEVGrl2fm3GEapOR69wFa3RFq7zjQZpQW1k0y5mweSFfVjTLlnQQWVAhbTLqMlG6SYpWGWVt6HBdHgBXZCKM70tFh0wqrhVV3SLTq9pjq26QyX2M7Sf0fweoSXv1IrplRbw79cpOCFJZx145dcL6MtdaVeVAOHOdLlUosipb8imz7xkDbm+unTp6qSKTQp6usikccv1p15fCKWPKbn93eWVMuSR0c4TBJ0u8l1l1jDEsuMQp53IQQ+TwMdl/TE6fku32B+XlD1ZYdJ+SbRosI2K1xozgukte0lJXToCUiOaMTfvV2VPQw4bk3lGXtLo+9UbxSGS9Jim/p7KZVef6eTuIAQGZDNPlKMYF/TcZuiyVGB3Wy7ItSsyYMWPG/xD/AIrSnldXeREbAAAAAElFTkSuQmCC",Uy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEXRSTlMA5cgdcw7XjzlWrIFkup0rSDjdhakAAAKOSURBVGje7ZnbkqQgDEAj95va//+1W7u1NVGpHiEJPHEep0ZPJyYBERaLxWKxWPDRaXPphOnE7S8uwmTM9p9JZvT+YGAG6J1rRu9cM3rnmtE714zeuWb0zjWjl2vme5XaLhQYSLx5tUbz2Bl23r0Ad/MJg9Du4X2YnYYRoAS99R8HYGtFbbYgz1F7a/MB4pjKi2ZCO5MayZ2PYndDmqq+d4AHn2GlbdXvMZW6wOQLy7xVgAcxyvtt84aUERNr/5ZINeAx71Ujvcw1Jd/BoW0FMdJLUmn9gVo20eml9kWTXdo7VCvBAWbd6wNGAmmFfO3P3PXfHliEvlFolVR9paZEIx+hkEP3fbxMyBiws93j1TMCJswiIxFyrgN+R/FDto4yfCM/5HILmBByZJeWoe0LE5DQtIBBc3Nd6mHZ28uRmekAXQRmrt1PpgHpLC/eziMDUHMdWI/4A53gUlFYY8tCJ5aQLORg7J8UVhfj4oPREDunqD1047Eh+sF5yXkHWOIGOC2ROc9YSRSX4rwzJdYM4PTi3BkAmV4glrXfK/QlJlSLBPFq1m9m5CvR9y4WCOzUy60jFTV/zxar2UPdR6Qpu0TE0fbHodqP03PtaZcd/LdUTboqABGFR5ikl3mgEgknskXkYFF1n8hqxygtxPSemFnFChhRt5Pqd+8u9Ykgbk1m9CIBWPir+SXb+uo9RD8ofo9C/mNf2K5k2/gtPUh/nFfxSzFguNj2ImZUlypqjdqqk/gFhrgU9dV6bA88gLQZ5bvPxmSfcFJJejHbHRgQpLhmbwFRTtWmVRqEsbkpzRbkCelNmzDcmeoUYBwhf6syH2AsNvrKrXy0MAMd87Grf8r9yJ8TFovFYrFYcPgDfFESW2IpAiAAAAAASUVORK5CYII=",Hy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgN8g7xBgcECfj6+/zzBQ4swJLwAAAaxJREFUaN7t2lluwzAMBFBq9SLbnfuftigQYD5SZLGpaQPoXWBgiqQdKDYMwzAMw3Wp5dySyVX8yNXEAm5kycy9CabAXG0yc7XJzNUmM1ebzFxtMnPVyczVJzP33mQdVRD132EHHjqsk5TxUE7WRYp4InZJLhFPxWL+Gl7QjPoMkmycK0DCoToySNjabCxxgzW8YTE3E94yeW8s+THveFNUTrD/NB84IWkLTdG9o2ULrGSc4PCGXAESrpEZJO2vDact4gempH1gWsS7g5K2pWkRzzAV7dKiqm0t2k5WGpclbaWpOlRaWOuMy7J4e9ChPWKatGuL1vO/HvTdFeFg9whWfW3CxQj+z2f8Z8G7Y7B+gbRPWpkTHFTtrwiatZ9cVOyEXfuOoFXbW/QlPmLKuCgXO2XRVppmcaUpahc1VfG3LUWX1lLv62AXRO0JU3VoafEsN9cLReVdzCEuNAWcMH3ynQRfzPorr1X8vBTEuTRlvChP5ojzrP+bQAl4QSjmL214oiXrY34Yvc3Wz7xm/Couyfoq8xLvU6tJpBqWPUYgx72Fr2TDMAzDMFzxDf7xFoVjSQNhAAAAAElFTkSuQmCC",Vy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgN8g72AQn0Bwv4+vMM9QQt7wKQAAArJJREFUaN7tmtHOpCAMhbUgoqL2/Z92s5t/0/wtkRE4c8V3eTKZMy2lRZlpMBgMBoNBLS55n5zSdvb7OUFZ+C9+yWpAZv5hedRwvszzfy1mNKCvuNhfA/XFO1tf63IoDeVrXZLSwL7iEkhpYF9xccoZ5mudvdJAvsL285Hbau0snEH3q1lr7Zz8yCmbSmmNOM+PeCelrbQmHHEBcvaT1OwciItQkFpQWj2JPyBlljmBNlJ+O5PSABspv6mc0mo5PStKpT0rDVVYtphIaajCElZJttJes/ErNkm2aP06VnmZqXWZL34JZXYCYXZwfjfvSmseSWWc1JdosETbxK5KA1W0bVZOaS8InqsgJyFXTciDK1kl5Jo2ErkaCbmmvnbmtpCj0tABS3iX0sABS3iL0kC9w4bnlIYqaRteUhpuDwvB5podqGnZVhWUhistYZevUdojgZtxmcQ5cKYlr1Fp6ExLXrVWwnMzPhcBsHsIpx0UHMFLLKfaTWm4tiUc8lZEtPLTQ6fqiu+qi7gDV2ZOXN8wpkwn8gVj7kLuq4YxZo2tsf+asdPaMxfQGN9AUqaBpK+1zMWcAfFDYqkYEpE7ECvGYmCh7YC7aw1f1lfmKEPg5wipLae1EnenJV60hj/t+SC1xaIVWbtkeqLXT22xS6ad0cpQj9E0m9FUZulwtp12rnixSO2lFa2GfEKW4GatwUMmeaugrgjAqxwlZ7akgXs5ZVKWel0olu9iFqWB35NLUklpyJuB8kUM/k4i+MI47DuYZRAkpWGdpUtE6wvINuiPGdvnt6lb5nXVhvuDgL3wOJRWS5g/SnOw82WeGnE7F0jOnhR30eqJj9Z7tDfs+zL1IR6es9DqJu3r1zj1I8SVrOvvwG7/TwtTb9wyrxcRs6crzbdexXs/7nMaDAaDwWDwnj/NQlzrb+J5OQAAAABJRU5ErkJggg==",Ny="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMAYN+fgL9AIO8QcFDPfzCQr49fa1RRAwAAAnlJREFUaN7t2NmumzAQgOHxvhEgnfd/17ZKDhMMSmobz+mR/F1Fraq/jAeywDAMwzAMwzB8N6EfHPBS+ORn4GRxY4CToLCED9jD4bYa8Q3hMOEfU+AMUxdRcYdXfFK8YYWbO2f4hi9uPGHqUpkrHDHziydsMednjrDz21/J7ZXrH3YvNXo9he5h83qV83b1qneYFnren3fsGxYUyjfc9gzTYml40jT6juFtmZaTp6fpFqYDlgE2QdL0O4UdTfV0/t71CdOgE+wkGnaXcKTFyiw07B5hQ3+Sm76GHa4P06QdkPyY79eFJ/iij4M+HoO7LGyy+2YCcjJs1SEMTk2TDh++e4Qrw5/R6mnusKPFZg3TJVveMJ2y4g3Tfe6Zw/TgdLxheq9IvGHaa8EdBnzQPyEsVvO0qr8Mhb3au7sLR33HAvLTjZwKtqKIhXORPukXPHMKxA/PTOgV1u/nNsE/c3oTxVGye+79oizAy3k6YlaKlp7VDWsemLN9ECf0UTjrVl0wlklnXbrgXrfTcW+dwbpfJBYsY7Kfjz1Wfjk3WCjQdkSDxJd1A5ay9NBo+Z0tYSlNO9XQBYWlTPb9sfR86Z8X8ie34RqgkMNyNt9KaWs+X5WL++0wAiqsWG79+k9LxElbqCKxnKeDClBpxhoOmkWsEaGZwRoKmmEVCa0sEtZDXrCOgEYT1lmgTUDCesgJa4XWT8PEKLXuLkotBonX2iNJ0ETu98Vm96rYD1dedsgOq8MGWogsnLK3IJuFLzvkNQuL7AOOexO20MBkYV0QTpeNWh/DkIWve5uIk5TSPCQAoV7cAOD5ctFaR4CotXhIMwzDMAzDMAz/j98ceskaOhA77AAAAABJRU5ErkJggg==",jy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAYJ+Av0Df7xBwIJBQz68wzE7woAAAAVNJREFUaN7t2d1ugzAMhmHHSUj4Kfj+r3asmxrIClKYlwzpe8446XuQgi0gAAAAgNuIxj4ZqmsI8s1RVSwvnmpyKWzpBMIII4zwWdjQCYQRRhhhhBE+hDDCCCOMMHX/IOzpxG3D0fJeSGHHe0b35VKBntSMUqLTvHlKhFZhGUiLsVu9ecNvENxP9MlkfurtzkRaeml0I89SJpKSIGUM6fBSaCQdVgo99J6YTQ45SjFPGiYpNtaexrofox5SLGgc8iDS5pCNJFX3LpYLnOIKXXvvWuSSRWMktjnkWS5hjZHY5JC9XDTUHYmJqTsSE1YciczcycbMHCRxlvU2vin7Kc4eyJ0klrzeMsBZ2GVhdxw2eiPxTXg+Do8KIzGFuyzMWVhr41vycMjCYxZW+3e5LCxZ2B6Gw0S/Mbjuk3tar3lrDfvXhbWeol2ZL5EAAAAAAOCvfQALwYE8tktFzgAAAABJRU5ErkJggg==",Yy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAANlBMVEUAAAD////////////////////////////////////////////////////////////////////xY8b8AAAAEnRSTlMA5VZzrI86yR0O12VHK4GeumR+Sig+AAAB1ElEQVRo3u3aYW+jMAyAYTuExEkItP//z550VHCVOGMzl02an6+b+i4hIRQNnHPOOed+KkoruNmAL7nAnQg3M9wp7OEMDA972MMe9vDvDkdgeNjDHvawhz38Xx72sIc9/H1hasNfLazGPZzDu8R8StG/XFIY4FCPFfERlC+XVBJ3cWZNeNKFA/u3N91S+upcx+2ntShGHDfLeGB4dzTVbxNyI2ImhGEbbnCnvIc7qNAUJFKBQ8+tu2iqZcgoNRIAs6wzKbpJluU/el7v7PSJbcy/tKcwtASqrtZotBP0ikG3ZNSbDMIjXtBOBkPCiba9yBQR61yAF9F6xJQlT0wJLyHBtZvsrzA+gVFFe66iXg3AwZdoPdO5y1bNDIym71YC3iQ5LGZ9OMielWs33kxZ9u2gFetdPIOJaH2z7LGKwos+fLqwPnRCzGePfLIRN9vFlcT/UjChWuKeZcSLr+jDD2ZIHbFOadXLyUVRG4twl0SyvXVhDvxZvAvW53FdhjCld+s8lLDEl4qIXb2hDBYdPdivMyUbh3eF39S9Xm6N/+qHKxe48jZm64Oq8mGgi+Vwfi7H01+5YuBFyVMDjfgJA5yj8LDO1qf8ZYSlVMA555xz7rv9AZlKFXj5dr43AAAAAElFTkSuQmCC",Xy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAQCBggN+/nxDvcM8wkFCwoI+ASc+UAAACfUlEQVRo3u3Z7XajIBCAYWAAAVET7v9iN6my6CR0lmo+Np3nV3vSkzcKQmkFY4wxxhhj78EFfQVOPJDr05cgCpNmVjyQuo3IlEVRPDUsxePEV4UlhzmcfVy44zCHPzkMnx2GV4eHV4X1W4WVKDjMYQ6/fRh+TTiswnJ2TtkoVw7+FLqEVfqeFjecNsl3amc4JoKrnOq93BeWVFgKpEsz7/bdav0lwOzUmw1rI77glIU94XblFnXPDZdJMfw8HBTiBM3n8Eh+xuu4pYycw6MttKovAkZQhku3t4su0xlk8kJcwug5rtwvq8TBZKLKSneDFIeLxIN8BJVFuQCAgMLTkUX7zagPKGzEsxhqtc5gsnBk+ITCorhdtI07aNTLg0qtjJBnfRXo2blbTHZhspIZ8bTua5e0zAVLjBmtLMAeff/DsGrIzu9j18tHlaQ2GmgK+zzI9M6niU82pSYyXwv9G6cKQRLbWIMghCuXXxcVuebT8ArZ5xldv1ibB5eYfG2DPJBXbBIZ7lMjtdqSVf02Do76T08rWA2yrocjeUxq1ZU1p/r2LiWjZ6BqK3krs94nPNSeYWqRMamZ2+wT5jxGtTHfyd7MKuWY2o3EzECTqL+7YwcyQ+8T2O30Dbdhm9rZO+tsDwVu5HuNT1j7Bpk+7MC9M8VIJKh9IvOySvtkHPEwGV++vOjt3+9td+VX+4RvmY31hykot3n6DFpOYfPTU9PksPG2q9AQDShscbjsDU7V0QdMQOEJhU8ofNhfnCYUtv8YDnvDHoV7FB62r/uyT+wjEwobFNbb1w87LgW8geBlbzTLmV2Kq+XcBiB3ht0IMMqL6ARjjDHGGGP/qT+Hf7FSTq027wAAAABJRU5ErkJggg==",Zy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA378ggBAw78+fYECPcFCv86Xy/gAAAk9JREFUaN7t2WlPwzAMgGGnjnP2yP//tWgg0GavaVCOCpH3K1WfHWnjMpjNZrPZbDabzf5cZg8BYXTGq/TIBRgYBpd+8jAoCkt6aYURRZ9EBmQdvliZh77tKr3PQdd0Og16FtNNsL8LVv8OXu6C17tgfJYWNQ6G7ZtRHgEHwhDVJxsIAMAxuG8m7ObdWoMR/TkYg9Y7Qb6o143awto+DrQRMqFKj1ZqB9P34Raz7leOqmG5w6hTmRybLKpguaUqKtj+Yj0sb7dHwZyxNoKP9JyGN4X03NIFThuIjE3PHY3gcDUPI9vtdSOY2HkVigX9kqUy2MJVaJlM2XkuQBms4DLD5CM3OG/QDJayPl8BGlrCYOTbyr+keji/tOWCroelLJc2Oe42h6VMckGv0AOG7VVxyBe0hz4wc0QeKuAK2UEFXCE76gmDrnElXC8rhB6wlKXbHYY143aF4eCuRRgCo7yAx8B0F6w5rMbAxiaeHgGjTTLdB5ajrJS7wNKVbV1g6cpCF1i6sr0HLF2ZNV1gOdmpsDsm94GJMSieqhQ2gqXLH/uRyx1g//byMYnJzWF/csPYuNwY9qf7kWYyNYV1ZrJb+d8awjr7eTomN4Kla03+vuJbwVreG/Py2gaO1/uQ4RtGE/j6Z195UTWBXyeOpejrwBZw2WXq28Ou6MZEruhfbAf78HKFso0PVckFFX4zp6my8QZtyQ17+cWDDzr+EvMDtzL5k5UPaaTt43w7XGQ+347HgpOlA6EkMtEUHbdHhMtMjASz2Ww2m81ms9mIPgCfVZZTXlzW2AAAAABJRU5ErkJggg==",qy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgCDf7xAwz0BwYL+fj1CvJC6qIwAAAtFJREFUaN7tmUlu7CAURelbg9n/av/kKyX7GnjGppRInGmED/AaoMIWi8VisVgsFou/gnE5hOAE+yIi7Lb8YLesGTLBassZFR2bjNjKNXPVmpc6cV64hSwtlGdz4KUHZ8BUL5rne+ebfaERXva6QkSKd+tIQvHw7FxIEczb1ABv4lPaqhx5dcnHj++Hb4s4b8m5nbnpGOUXxYcGnRiwH8xuzk5L3eul/jWvgPU0N3t/TRzKh9ifWpzStTghGAzJPAXd0TjOvatWsWGXxPJB4ZbJ/rEpIp7qHD7azutq+2mYtb3oubmfOBuuGL1FiWbFYqTkz0jTWzHGWCvCEcKvDzhh/4/LrIItHyyk5qkLIKFaFTyqYrkgtZit1VATu8CogZ6LdeybJxvvXiLl6P3EtO8QHhN66Hjrl7E9mQ0m9Ogh45oTFrJ5O+IP7osbTBjM1dQO4B1MLaVZ17xDQoOXRIR66Zl57Q9p/MotGMXsbyc0IlR/KG6pgeToeBELC6aYpcCEtvqON0HwiGb3zOuhUKrkAox7HUSuQXjv0SUU5CrF/Nwrbyaln+ClBYm/4dUSBg+a1T2vhcGDZmVu7bOFwaNmdy++w5NW5wKe40XkSRy/5HWYWjO9OPbD/kXv0HFo1HPvyEXLPfBq8NLNAZrdvZ4zavYPvaNm/qS5x9LCT/NuJ1Hey4HwHW/ALchTvAk2ltwQtideDi8Gmhm9asCLTdLAYrql4B94rSaXJ5ZCGPdKQU+chPeVxK/wWTebDkYytcyu3CCd1KGzV7bxbI/lDrb5cuF4YlWHa7IT16RV9endf52bm+JYD2FEL35fQIiJSIhg5znpK/ddcVOsQEz7ERVDJcdXvHdbIkbEQEUQSZViCrRfNCJuRR9s41u9kDC18XnvFX2j3bHLR/A2zSqzAzpzGh/tYdKy29xFhH9cPsZkxwho5wRbLBaLxWKxWCx+I/8ANf2/u2NhQhAAAAAASUVORK5CYII=",Ky="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAIVBMVEUAAAD////////////////////////////////////////PIev5AAAACnRSTlMA7zC/QN+fgCAQTQcGNgAAAMRJREFUOMvd0jEKwkAURdFPBEkdsLFKyAYk2UIqO1uXYOUSXIJbCCiCqzTDe8Ei3qmDrz3caebH+7tHLLZ6fvZpHfFYhwaPV8jOiZ0zn5QTd3vlwIdGOXGhnDiUIytHdk7sHNk5sXNi53dg5a9lPQxDHc6vQUu5YlqjmFbGv++W1W2V5ctY5+L534vpt37E89lspr9eaKmzIfbVIfvqzJSbKTdjLsZczLkYczHmrZjyXWLKtaDcTLkZc+K2TzsTH/Xu2vkDlC8AMDsTJN8AAAAASUVORK5CYII=",$y="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAG1BMVEUAAAD////////////////////////////////rTT7CAAAACHRSTlMAgL9g36+fQGFJCmkAAADFSURBVDjL3dS7DcJAEIRhniJ1SIgEBSAqQFRARguEJBTgxJqy7cDeX7ZGmtwX+fbu8+t2d7Pqsb99lqHH617XX6mZr26lrrCkdr58ljTxnTRxsHQZJwfBwXqWhoP1rmfDwfrVFA5mO3Ozm4DHRCwmZDExjwlaDPcYDrYcbDnYcrDlYM/BnoM9b+Jyvnl+tfxh+beA4elIwoGmdAjJlFIxJHIqg1hEuQRzAZ9c+dN6jmB4bj2hcYW2F5omLfe6PMH/0HLXPHpWgenjpk040QAAAABJRU5ErkJggg==",Qy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAMAAAANIilAAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA32CAIEAQ779wz4+fUDCvilaH/gAAAZdJREFUSMftltuOxCAIhsWiVqst7/+0m5jsEIUqm72d/64M33BSWvfVP9WgzKZ4wqRyayhWojwbMwlVhfVAdAnrIeHmVK/TGWAvfOJDRAn3cGqSLURc8AJOSrcqcdIrGBT26r8EFd4FbsSBN2kDzgUnnsAOJohKwZSiBZ6PQpBG+5xP6gpWGGRgiksYDhGax0TFrWBAVzn03GqqK7igcwgces46L+DSS/IfuHDWopBBvrNdHBrdaAnuRdlH/p8xzfj7fLutkLr4JN+cyV7P535MqQQDzHnff4eRRu+DZ2dQ4Y4N8GGBK3sPa/mxwJnhoWawwG2EAxlnNXpnbqC5Yzg5Jz41VpgHe3LeVpg3hxebLV7HDgZ+Hi1YiNqmYZX339B/hNXlnpvrOTR2dgFfYlnCh66dXcCPGIwnThxoCSd5A4FYSzhwYLZZ4UO7+pcRTupRBBMciLQPFwQLfL68HTDt4fD2Jr4N8Ply91oSaeuBS9SO7BaOoLMHGeCq15tJwppTyk6qGuBG9KC6Hk6Y9ERRGXj31f/0A2zyPsVxnMRtAAAAAElFTkSuQmCC",Jy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAJFBMVEUAAAD///////////////////////////////////////////+0CY3pAAAAC3RSTlMAYIDvMBDPv4+fcLUOqFYAAAEWSURBVDjLvZW9isJAFIXHkLCw1S5ss9ikt00h2ETyAqn0CaxsbHwCSyvfwN7KEUQ8L2dilJPE4Z5GPFXgy5efOzP3um6i1FkZeYtGQGrJgDflSrfkSjdk6kGZekimHpTHwIZ6Xz5Ngb9JWB8C2QD4KYBrAM9wymscT7AI4GSZuRq74ly6QOZ5g+O1C6fBzHvwd9nHSfu20aKPZ75dsHPZxckSKWVg1cVfgG9XO+/iuK485az/7uKpUyamTpmYOmVi6o18+X3kH9g9r7d3PYKRtJKNeIHFw8WniR8TZRFFFUsiFlRsB7mZ9FZ0g9eNvP/AIdIHWB9/3TwObD1H0bhE2xNNU7Rc0bAN3ethoUeNHlR6zIkheQMcOzccp+sDkgAAAABJRU5ErkJggg==",tx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABGBAMAAACDAP+3AAAALVBMVEUAAAD///////////////////////////////////////////////////////+hSKubAAAADnRSTlMAEN+AIO/Pn2AwUI+/cOwbbqMAAAEBSURBVEjH7dJBTsJAFMbxj0Ci4GZCjF7AdeMJTHXjBdy4afQCRC9gOEHjxj1H8AiewCOwKGmBEL4zwLSEB0x5bweb/nZdzL+vb4pG43w6MSy3LEbQtQbkErobkpkzM+TIzJBDaL5odi7o5c7OzKC4Yun+4DseseOB3gR7elH+KU/t2kxKZk7PtBKSf3qmx7WFmsHl9qBkfhF05GRKbxrcYERvKE1+4NCY3vxoRmbI4m3mHZVws3fAD73CHb3ozHUTyQQG9N4kU6NfjZps3lmrE7G0mb3eEyuSCXWNTCnVM6W2lZE98sX+0/NvaP659gpVX83IHmcwPCdFDMu1Q6NxeivVcQUNhbcOPQAAAABJRU5ErkJggg==",ex="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAUCAYAAACTQC2+AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEYSURBVEiJpZVRccMwEERvgsAMagiBYAiBEAgpAzEwBEEIhEAQBKUIUgavH4pnXM2tJTv7qdm7XelWkpkAMAIJeAF3YHA4AxApeACj6qdEBiDzH8HhhYqTPUNmZiehNZtZ7e7L4dVr47u2DcflgovDvQpuaIlMolC6BOZeY0vBSBl8jdRxCtmpy9ThoAw/dZG1SSU2rIlRbH9qiax6nEWPeSHcBOHWK7ISU0EKhj+Xvoj6Yl448snMfo823YFhe7s70RyD2C7AeYeIuoNxTfLeNvg83on67dsidwh5d/AlTQIXsf0jT9DUcqfCcd1hLLROYWkQneJ4lGem/6NvM3tWaz8Or157vmv7QQnHY3GJ/srvlMEnNhL6B6cIZVSNSYqvAAAAAElFTkSuQmCC",ix="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAaCAYAAAC3g3x9AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEPSURBVEiJ7ZVdbcMwFIWPGYRBA6EMFgYthEEIBDPIGGQMuiGohiAQrCEIhG8PSdTKtW/srY87Ul6i60++5/5Y2hHQAzMQAL8Xb4EaYORRA9DUwlpgSsA2BaAthXVrinsKwHkP5gtAsXyNX5uG9ctpZPOVxa9gBPeFGQSgFXnzA9AlsjkaF7iKdAEmjCpidIGAS/RvKGqHBRz7OjoWM3tJB0mfzrmPUuAKfZX0Iulb0lvN2X+lFRflyzn3XgNgmeeTtqLwOHJ/aZuLMh0fftnYs4CrAT0mYB350ZtKloO/g/VG3C0rnrm+onSes2Aj6Bnbgk0zifVmVdGCmustB21I+zZS+4xGYL/edubuOcjpBwCFxkKYDWbkAAAAAElFTkSuQmCC",sx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAACgCAMAAAC8EZcfAAAAqFBMVEUAAAD////////////////////////////////////////////////09P////+vt//Kzv/f4f/z9P/y8//o6P/HzP/////z9P/i5P/////v8f/t7//k5P/m6P/w8v/q6//o6f/S1f/X2v9gbP/b3/+vs/+Vmv9daP7///+us/+aof7r7P9xe/719f+Fjv7W2f9ncv7Cxv+4vf+kqv57hP7h4/+Ql/7M0P8zzBhqAAAAJ3RSTlMAn4Ag3xC/70Bgz3Aw748gMJ/iv3BeUM+/r5+PYHCvgN+FQBWPQDAOL4ZsAAAGb0lEQVR42s2b2XbaMBCGbWzMvmUpJXuatpJteQXM+79ZOTZkKAeiGdlW9F9zlM+zSTNSrEY0vx9NV97SnUScRxP3zVtNn58cywjNn+xhxC8qunl4nlvfKWfwMuESTeznrvUtcu48jpQ30s84uOUURd5AJ6OzcM/+fpL7QRxvhGBMiE1cBOtsdxaZvY4uRMfmp0r8OGUXlRZ+8t9nLP5aJNXHC7MC4K5A5iEH/Wy79swWJ3T+hqEk/BNvP7bq6DuIvV3BCIoTiMU7qy05N+BawYhKwYxe32pFnU+8gIGUEH9bzct54wf5DKSKuGw8WZ6Oexo4VwkxO0bifTvuDQWrqfhYdaZNFpclr5SnrLbS/Jgr3cbCz8UkB92IN06TfBB99ZXueCm3kdPieALJ25j8w2Fx3ABfj5cKWKMKoiqZaxPOK75wwxrW5kA4r8k3gerSsERYedmplx/A1zzhtsqUGoTdAx9UvzZs6M6UAT2K/dQJPVW+3+3yAWFHje++aiTo+UvP5XulDbhK4Ji1qlg9UTz6/qG+p9zS+UZVT8laV6IWhk6PkiD1EyWiOvkWArBtFVXHrJLBOdOi6gT7RN9CopS1LnCyS29BAqZJATVPuj3IYC3aQZ4QDCiYNonyDy5oBvSZRmVlUfugGJCeIfVN+E4xYMa0KiMk8kh3BIIJB/hTwk6t4d3ExUaom/AGw/dLbZMT6ySE8WGQqpkQ0+M9qtTAYMvPlKxThVPNAwKwTJE16eP9kF9QtKZ9IzJN+uXiKWXlkF9RGJN9LJ8OT6kezjmoN/RWQ5eDcup+Z+M8XFC674OG0/6nF6afkFvRsI//0HYRcXSv7ZzNnGzOqVOdssP7JQF8JXlYRIB3rr53yBVBymPZLcpPSg6nB/uNrtyI9mid/xrT3/UoVTqRNLXjKhR3lB55Ihm3lU4h5a/rSKdjPiUIvx5pPhNCMK4qi4OY3wmCR0byKugjl8NU1nE1fydMGabydjggGHCEax9wUV3Ih3HlwGiDMyBy7yydvMXNuqRHrg/8RhwfHCzVAG/CtPzphyyJQ1wKgzswJsybSeMf+CSO4IiOMeEWHzY/ZGtleA93MYAOvtJksq9+RwOuwcO4JidAx82r7Ljvo791hGwT0UHoy2Y0CzTg7jxaZJG9QwHKJiA22hlbyDdcF5GgA8duBLA8aDk4QAddvILmAMvMtJAqf6wZMIIqo82CkCT0GKwPCDH4ULfMQM3va8/iTht1EPan+nXwmbbUCgdo0z77TvatO/Re3CMMRONG9uI++uCRcnQQ9vGN2FbWus9gLdwkBe3hDH+Gm1lfqPyFwF++ONjTVoEecEXWV1riO5wQaUIPP+0p5GPgFX7y4eNM2OewJMorL/ImMaNcATqYlzchYVTxKC/6W8Kshw8lDqZcS4byQ+aMMqkI5S8pp5SHBSmmzxlCymGnl/bVJbtT0vwtwFyVPFCuwTaH4a9zLf5oL29yzEXEEwQhOgy5O7i4b5Z8hCuNEF4G1A5CqDWVhv2LeKRrXQEhKA3CnPKSspLXOWEcd454UcGw8nGt9h3ULXSmHNSzp53BoDNdlXSQHxQPvyK3zpihlSb8qjJBfcU1s6Rakq+z4yuICeA1OS4bgI9rISYxoyiN4DQtyeNI5c2M8P9j3AVC5e1Mr4s+YIYq1+3B2s8yf13EjK4QTjIyzfU9O6JPlOE6LGRalVBe297rNiEYEKk3zSYEA5pqwjUYECcXtikdSiOKASGRM6ZJOcmAUAv5hmlRrPCI1Znoy5N0W24iM4ukd32vbHO4NqXI1ZHJMENZWlQ5ETzZaFMiUv3fpleuIwzTLTiYqhcdYZhBBpM1gycbrcmv9U9DDm+TEPiisaWoEbHzpm/BqgEI07g2i03A4Ym8qh6BsC2+hVVLD0DYDp9t1dQtELbBd2vVVXcIhM3zDbuWmYQnfEYSnvAZSSjjoxPaB0JD+fY6EppUXy4TmsoHhKbyAaGpfEBoKt8noV/zfAV8xhH653yGEV7gM4rwIp9BhFf4jCG8ymcI4Rd8RhB+yWcAoYTv2wl18wGhqXxAaCofEJrKB4Sm8gGhqXxAaCqfZXWkhD5tftUaoal8QGgqHxCaygeEpvIBoal8QGgqHxCaygeEpvIBoal8QGgqHxCaygeEpvIBoal8n4TG8u0JDefbExrOtyc0nG9PaDjfntBwvj1h03z/ABD9FUIpArU6AAAAAElFTkSuQmCC",nx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIwAAACMCAMAAACZHrEMAAAAeFBMVEUAAAD///////////////////////////////////////////////////////////////////+Kior///+ZmZmRkZHw8PDFxcXT09Onp6fq6uq2trb4+Pjx8fG9vb2goKDi4uLMzMyvr6/39/fg4OC+vr7b29uYmJjRFtxTAAAAEnRSTlMAIN+A778QcGDPMJ9AkKCwUH/CxK06AAAEhUlEQVR42u2biZLaMAyGc5BACEcrxXEOjgW2u+//hjUsRdPJDLEti810+j3BP9Kvw04ccVgu0nKbJDM0zJIiK9Mfy+gbyBfr4iZiQLb+kUcvJP6Z4VOyeRy9hHyeoQXFQl7PqpyhLaWsnNXfQakb3Z8/PxUY1Oex7fVH93e6VhEhJ2X3fmgVEER7eEcik4lOXpKSxgh5xrnZiSZr/vDK+0HBKKp/JCyZR2GJs4eUFixpm4ecWCAsJMWO6o+cWbjg5Gv8Yt+CI+c9frEOlaLiblsNHuigqVomeKOrwItqH07N8m6XExB+wZmxJ/rinqIeGPQXvLEIomVPKWKkiqlmSVrCqGFkKv7yS6eAjeqYvokT0hJADa+mSEtANYXfTrr+8ouCQKi9fy+eD7wbyMVzX/PuKghIdbmZOPY0TA9B6fFK5pckDYE5UaJcq3oPweluiXKrqBKvkGEC26Z0CoxMkmiEuxxhMkpScPaOHl7hlTOI0FJo7APTgBBvTqGJ7d0rH5pSLjAUmtIlMC2I0VKvsVs1OxDkzb4NFzSUhDiQhW2ytFMgiLq14dh2RDYgSoOG1LbJnEGU1jJPOV4BOShP4/X0Aw3vIAfV08JuDT+AMAe71TyT6nhD0xTRGGQZSdStCVudrjsQp6aT94h/P0CcxsbBKe2bomibtreRG0zDE1Q5iWICOKNhazOyjyBOhYbE5lT7CTbIi5mhQYEo1Ggm0fMMeOW/mH9BzKSqKbHvM/I7xFZ+A6YOnE1i0fuz6k3goHLlgw6VI1czNYjT2dxE5PiSeaDQ6qxSSDuY/FvYHVVOIExD/h01zQ6Eqe0ur/LZC3a9Iy0Qz8lkV3LK0tbq4ko+T/X9oDKFPDlc6m3Ez3GN/XXnSrrvVS4XwYWwhTXtMuOk/CtGvn3JwqJ7RO/2oTIVHd21vX1pdPcgQo90CWzFRig0FBjnz4K/wPDtgTGhkSoodQ/MJL6YatfAUK+pIDAVugaGek0DgWn8/qFJJb7HHZHuFV3IE4Eb4Zqmkhur8OWt/X9Jy4J6mP6DYPyL9hbQvVTW7qRhE9WTe30oQiaqGrjXx8NvE0jSlXW4RB0YSaJmEyZR1eWRpO9PVE1J4ibqBEw0JYlDEWJGtchPErW+WrEMQ0liMufb5oN+FeSy5da3HmxUnPrm2eY4+CuZX991xTLMMuLDt01HVR2GzL/baBxcmbFt42viw8AwoR6J7I5+RxOMo6DMvUxc1SMdhjWkOiVkXnkTn3DsEwHzfYZ2LSQyb3gTY++2gM/iSIQFupRUdSHzSpA6lFRVk3ll2KDtcqNqepgiRF7YTqlOqpCGJdWMFrVcIQ0fg+mARc1/JqfHteAyEmeBY+2mRypqaVJ8voYekYpanvRp8ztePLTw2031pNltopdRkJqBlkGDkSb/S81QS5JHXPjvPVXNaTB8NQFfkfLf5QIQTC38XashLQ37jThfzRS0PAZDQ1rYr9X5ak60NLC18NVoAM0YjoGHptY+w1FKzSS0GDUT0mLUTEiLUTMhLUbNhLQYNRPSYtSE0fIbFg3xTdS8kE8AAAAASUVORK5CYII=",rx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIwAAACMCAMAAACZHrEMAAAAdVBMVEUAAAD/////////////////////////////////////////////////////////////////RET/////W1v/6Oj/oqL/ubn/c3P/UFD/8/P/3Nz/ior/0ND/5+f/ra3/f3//T0//lZX/lpb/Z2f/xcX/9PT/aGguCk8uAAAAEXRSTlMAIN+A77+fEHDPMEBgkLBfUGJvpxAAAASDSURBVHja7ZyJkpswDIa5Cbla2WAI5Gqyu+//iCUhjaYzmdhGEst0+j3BP9KvwyZOQGG5jrNtFCWqJ4mKNIt/LoNvIF9vikS9It38zIMJCeNUvSVdhMEk5ItUOVCs5fWsskS5ksnKWf0dlNJU3UnrM/Sc9bXuqo/273StAkROym5/qc/wivqyV0gqE508QyUGhbzkZHaiyVo8vbK/nMHKuXsmLFoEvITpU0oNjtTmKScUCAtKcUP/kZPwBSffqIFDDZ6cDmpgw5Wi4mHbCkZQsaZqGak7rYZR6AOfmuXDLke4QwhOQp7oPx4p6oBA9+g6P1i0HDSQ0AcGNUvUwqOGkKlw8Et7BjJNS/RNGKEWBjW0mkItjGqKcTvpZvDLGZhoDuN78eKNd0kuXow1704DI3p3N3E40jAdsNIN29+4JFXAzBET5VvVB2CnvSfKr6KGfRcNw2ybzCswMknCEe5zhEkxSewcPD28UjdOIEKNoXEPjAEh9l6hCd3dKx+aTC4wGJrMJzA1iFF79Jq16mlBkL17Gy5wKAlxQQu7ZGnXgCDNvQ2HriPSgChG9cSuTeYEotSOecrVDZAD82Svp5+qZw9yYD2t3dbwXyDMxW01T107Ht00RWADLSNJc2/CTqfrFsQp8eRt8e8HiGNcHBzjvilK5dL2MvfBRD9BZbMoJoCT6tm6jOwriKNVT+RyqtXggryYRPU0IAo2mln0vB5147+Yf0HMrKopcu8z8jvEVn4Dxg6czmLR+7PqzeCgcuMDD5WWq5kSxGldbiJyNck8aJTTWaWYxMEnLCarg48gjEH/Wk2zA2FKt8urPJlg17sOC4SddIKV3AxLp531BHkqHweVOeTJ41IvEz/HGffrzpV039M+F8GFsIUr3GXsxPQrRrp90cKie0Tn96EyFh3dpbt9cXR3IEKn8BLYiYwaGnpgkFA9XfPtgelDI1VQzSMws/hiWvkGBnuNBma08g0M9hoDzJhxv6GJJb7HXRXeK/qQRwI3wqVlKlmG9y9+966DEaTcHtaf6F5fwoT5a4/BsvYn5k1Uh+4dQ8GZKG1xr5uH9zNI0o0NX6IuhCRhs+FJlP58Jun7E1VikqiJOgKRCpNEoeCYUbWiJwlbX9mQDINJIrKg2+YDfypIZUut7wo3KjJ5RLPNF9sv/bG+S00yzDKgQ7dNi1XNQ4rdZpxhtgEfeTTWxJc3hqE9Etld/Y8m2GH4WIwysS4tHYY0pNpGyLzyJj4q/ETASxj5nr8ri3npJlad3wKehIEIa+VTUvoTzStB7FFSukTzypAp1+WmGbRsAjnywnVKta6FRC8pYy1qj0IiPwarGIua/kyusmtRy0CctbK1m05hUUsTq/dr6JfCopYnftv8vj4n1ILtRr9pdlkwGQWqea2lCKYjRzUvtUTT/mdG9HLXakpKg6GrYXxFSn+XC4AQtdB3LYNaDPmNOF3NHLQ8B4NBLR6X8VJqjrg0kLXQ1VQAFWE4Mg/NqiIMR3Y1s9DSq5mRll7NjLT0amakpVczIy29mhlp6dXwaPkN5W7InuRCZwAAAAAASUVORK5CYII=",ox="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAPElEQVR4AezXMQoAMAgDwND//9n2B51EhxNcQ7gtJ7NX0wWiAAECBAgQIECAAAECBAgQWCFQb6G3/Sc7FwAA//+f4+OPAAAABklEQVQDAI04ICFaxIVcAAAAAElFTkSuQmCC",ax="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwAgMAAACTeJdcAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAiSURBVDjLY2hgwA5GJUYliJBYhQMwOAwWF45KDEUJXOkKAA7xNyG+w0wTAAAAAElFTkSuQmCC",hx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAABgAgMAAAAm4hnjAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAjSURBVDjLY1gFBg4MQMAExGBqlDPKoS0HkuoGjXNGOcOVAwDBxwm1N3ts8gAAAABJRU5ErkJggg==",lx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAOklEQVR4AeySSQoAMAgDp/3/n9v4ABc8eRCSUyAwmgu8xIp9WYGfFpItgBk3OPpW5HAnMxBE0NciwAcAAP//bVPdOAAAAAZJREFUAwDM4hAZDjaEjwAAAABJRU5ErkJggg==",cx="/assets/doubleBed.CzextF6m.png",dx="/assets/sleep.C_YKDk6M.json",ux="/assets/sleep.CRKZ3XeQ.png",px="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M3%2014H21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M3%2011V14C3%2015.1046%203.89543%2016%205%2016H19C20.1046%2016%2021%2015.1046%2021%2014V11'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M6%2016V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M18%2016V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M4%2011C4%209.34315%205.34315%208%207%208H17C18.6569%208%2020%209.34315%2020%2011'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",fx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='12'%20cy='12'%20r='5'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M5%2010V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M19%2010V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M3%2012H7'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M17%2012H21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",gx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M3%2018V7C3%205.89543%203.89543%205%205%205H19C20.1046%205%2021%205.89543%2021%207V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M3%2014H21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M7%2010H10V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M14%2010H17V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M2%2018H22'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",mx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2018V7C4%205.89543%204.89543%205%206%205H18C19.1046%205%2020%205.89543%2020%207V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M4%2014H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M9%2010H15V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M3%2018H21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",yx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2019.5C4%2018.1193%205.11929%2017%206.5%2017H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M6.5%202H20V22H6.5C5.11929%2022%204%2020.8807%204%2019.5V4.5C4%203.11929%205.11929%202%206.5%202Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M8%206H16'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M8%2010H16'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",xx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6%208V18C6%2019.6569%207.34315%2021%209%2021H15C16.6569%2021%2018%2019.6569%2018%2018V8H6Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M4%208H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M9%205V8'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M15%205V8'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M12%203V8'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Sx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7%207C7%204.23858%209.23858%202%2012%202C14.7614%202%2017%204.23858%2017%207V17H7V7Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M7%2013H17'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3ccircle%20cx='12'%20cy='10'%20r='1'%20fill='white'/%3e%3cpath%20d='M5%2017H19V20C19%2021.1046%2018.1046%2022%2017%2022H7C5.89543%2022%205%2021.1046%205%2020V17Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",vx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='5'%20y='4'%20width='14'%20height='16'%20rx='2'%20stroke='white'%20stroke-width='1.5'/%3e%3ccircle%20cx='12'%20cy='12'%20r='3'%20stroke='white'%20stroke-width='1.5'/%3e%3ccircle%20cx='12'%20cy='7'%20r='1'%20fill='white'/%3e%3c/svg%3e",bx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7%2010H17V15C17%2016.1046%2016.1046%2017%2015%2017H9C7.89543%2017%207%2016.1046%207%2015V10Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linejoin='round'/%3e%3cpath%20d='M5%2010V14C5%2015.1046%205.89543%2016%207%2016'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M19%2010V14C19%2015.1046%2018.1046%2016%2017%2016'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M8%2017V19'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M16%2017V19'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3c/svg%3e",wx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%206H20V18H4V6Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linejoin='round'/%3e%3cpath%20d='M10%206V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M4%2012H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3c/svg%3e",Ax="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='12'%20cy='8'%20r='4'%20stroke='white'%20stroke-width='1.5'/%3e%3cpath%20d='M8%2012L5%2018H19L16%2012'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3ccircle%20cx='9'%20cy='8'%20r='0.5'%20fill='white'/%3e%3ccircle%20cx='15'%20cy='8'%20r='0.5'%20fill='white'/%3e%3c/svg%3e",Cx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%203V5M12%2019V21M21%2012H19M5%2012H3M18.36%205.64L16.95%207.05M7.05%2016.95L5.64%2018.36M18.36%2018.36L16.95%2016.95M7.05%207.05L5.64%205.64M16%2012C16%2014.2091%2014.2091%2016%2012%2016C9.79086%2016%208%2014.2091%208%2012C8%209.79086%209.79086%208%2012%208C14.2091%208%2016%209.79086%2016%2012Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Px="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6%203V21M18%203V21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M6%2012H18'%20stroke='white'%20stroke-width='1.5'%20stroke-dasharray='2%202'/%3e%3c/svg%3e",Mx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2011V17H20V11'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M8%2011V17M12%2011V17M16%2011V17'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M4%2011H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M6%207L18%207'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3c/svg%3e",_x="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6%207H4V17H6V7Z'%20fill='white'/%3e%3cpath%20d='M20%207H18V17H20V7Z'%20fill='white'/%3e%3crect%20x='6'%20y='11'%20width='12'%20height='2'%20fill='white'/%3e%3crect%20x='16'%20y='8'%20width='2'%20height='8'%20fill='white'/%3e%3crect%20x='6'%20y='8'%20width='2'%20height='8'%20fill='white'/%3e%3c/svg%3e",Tx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%205V19'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M8%208H16'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M8%2012H16'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M10%205L12%203L14%205'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",kx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M3%209.5L12%203L21%209.5V20C21%2020.5523%2020.5523%2021%2020%2021H4C3.44772%2021%203%2020.5523%203%2020V9.5Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M9%2021V12H15V21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",gi="system-ui, -apple-system, sans-serif",Rx=["#a8c8f5","#9de5c7","#d4b9f7","#ffd399"],Ex=["#d6e7fc","#d1f4e5","#ece0fb","#fff0d9"],Pn=["#2563b8","#26966b","#7c3fb8","#d97706"],Ua={global:{containerTop:"0px",containerLeft:"0px",containerWidth:"100%",containerHeight:"100%",backgroundColor:"#f6f6f6",backgroundAlpha:1,performanceMode:!1,resolution:window.devicePixelRatio||1,enableLogger:!1},map:{autoPaddingHorizontalPercent:.05,autoPaddingVerticalPercent:.05,adjacencyThreshold:3,originChangeAutoFitThreshold:2,sizeChangeAutoFitThreshold:10,obstacleColor:"#999999",freeColor:"#ebebeb",autoFitOffset:{x:0,y:0}},room:{colors:{sortBy:"index",strategy:"priority",active:[...Rx],inactive:[...Ex],name:[...Pn],propertyTheme:[...Pn],selectionIndicatorBackground:[...Pn],selectionIndicatorIcon:["#ffffff","#ffffff","#ffffff","#ffffff"],[oe.NO_ROOM_DATA]:"#ebebeb",[oe.ROOM_GAP]:"#ebebeb",[oe.OBSTACLE_ROOM]:"#ebebeb",[oe.UNKNOWN_ROOM]:"#ebebeb",[oe.VERSION0_ROOM]:""},nameLabel:{fontSize:12,fontFamily:gi,fontWeight:"500"},type:{assets:[kx,px,fx,gx,mx,yx,xx,Sx,vx,bx,wx,Ax,Cx,Px,Mx,_x,Tx],iconSize:12,gap:4,position:"left",container:{visible:!0,size:16,borderRadius:16}},property:{displayOrders:["cleanMode","suction","cistern","cleanTimes"],iconWidth:14,iconHeight:14,foldable:!0,offsetX:0,offsetY:6,iconGap:0,container:{backgroundColor:"#ffffff",paddingVertical:2,paddingHorizontal:2,borderRadius:16,tailHeight:2,tailWidth:8},suction:{assets:[Fy,zy,Ly,Oy,Gy]},cistern:{assets:[Wy,Uy,Hy,Vy]},cleanMode:{assets:[Ny,jy,Yy,Xy]},cleanTimes:{assets:[Zy,qy]},cleanOrder:{color:"#ffffff",fontFamily:gi,fontWeight:"400",fontSize:10,gapRight:2}},selectionIndicator:{iconSrc:tx,iconWidth:14,iconHeight:14,containerWidth:16,containerHeight:16,strokeWidth:2,strokeColor:"#ffffff",borderRadius:16,offsetY:4,offsetX:0,tailHeight:2,tailWidth:6},floorType:{assets:["",ox,ax,hx],opacity:.1,scale:.2},enableElasticScale:!1,elasticMinScale:.6,elasticMaxScale:1.5},path:{lineWidthFixed:!1,incrementalThreshold:5,commonPath:{visible:!0,color:"#ffffff",width:.5},transitionPath:{visible:!1,color:"#ffffff",width:.5},chargePath:{visible:!1,color:"#ffffff",width:.5},mopPath:{lineVisible:!0,lineColor:"#ffffff",lineWidth:.5,trackVisible:!0,trackColor:"#ffffff",trackAlpha:.4,trackWidth:4}},carpet:{src:lx,opacity:.5,scale:.2},robot:{icon:{sizeFixed:!1,width:8,height:8,src:Dy},speed:0,rotationCorrection:0,sleepAnimation:{jsonSrc:dx,imageSrc:ux,framePrefix:"sleep_",width:16,height:16,sizeFixed:!1,frameCount:96,offsetX:8,offsetY:-8},ring:{size:1,color:"rgba(255, 68, 68, 0.2)",strokeWidth:1,strokeColor:"#ffffff",strokeDashed:!0,strokeDashArray:[4,4]},pulseCircle:{size:12,color:"#4cd964",strokeWidth:0,strokeColor:"#ffffff",duration:1e3,sizeFixed:!1,minScale:.5,maxScale:1,minAlpha:.5,maxAlpha:1}},chargingStation:{icon:{sizeFixed:!1,width:8,height:8,src:By},rotationCorrection:0,ring:{size:1,color:"rgba(255, 68, 68, 0.2)",strokeWidth:1,strokeColor:"#ffffff",strokeDashed:!0,strokeDashArray:[4,4]}},interaction:{zoomRange:{min:.5,max:8},fitMinScale:1,fitMaxScale:4,enable:!0,enableDoubleTapZoom:!0,enableRobotClick:!1,enableChargingStationClick:!1},controls:{iconWrapperWidth:24,iconWrapperHeight:24,iconWrapperBorderRadius:16,iconWidth:12,iconHeight:12,deleteIconSrc:$y,rotateIconSrc:Qy,scaleIconSrc:Ky,moveIconSrc:Jy,horizontalScaleIconSrc:ex,verticalScaleIconSrc:ix,moveButtonOffset:30,textFontSize:12,textFontFamily:gi,textFontWeight:"400",renderOrder:["forbiddenSweepZone","forbiddenMopZone","cleanZone","virtualWall","spot","wayPoint","divider"],forbiddenSweepZone:{minSize:1,iconWrapperFillColor:"#ff4444",strokeColor:"#ff4444",strokeWidth:2,fillColor:"rgba(255, 68, 68, 0.1)",outlineOffset:16,outlineStrokeColor:"#ff4444",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(255, 68, 68, 0.05)",showRotateButton:!0,textColor:"#ff4444",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},forbiddenMopZone:{minSize:1,iconWrapperFillColor:"#fe8a07",strokeColor:"#fe8a07",strokeWidth:2,fillColor:"rgba(254, 138, 7, 0.1)",outlineOffset:16,outlineStrokeColor:"#fe8a07",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(254, 138, 7, 0.05)",showRotateButton:!0,textColor:"#fe8a07",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},carpet:{minSize:1,iconWrapperFillColor:"#5d68fe",strokeColor:"#5d68fe",strokeWidth:2,fillColor:"rgba(93, 104, 254, 0.1)",outlineOffset:30,outlineStrokeColor:"rgba(0, 0, 0, 0.7)",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(93, 104, 254, 0.05)",showRotateButton:!0,enableFreeRotate:!1,textColor:"#5d68fe",textPosition:"bottom",textOffset:20,editing:{isDashed:!0,dashArray:[4,3]},normal:{isDashed:!1,dashArray:[0,0]}},cleanZone:{minSize:1,iconWrapperFillColor:"#5d68fe",strokeColor:"#5d68fe",strokeWidth:2,fillColor:"rgba(93, 104, 254, 0.1)",outlineOffset:16,outlineStrokeColor:"#5d68fe",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(93, 104, 254, 0.05)",showRotateButton:!0,textColor:"#5d68fe",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},virtualWall:{iconWrapperFillColor:"#ff4444",lineWidth:2,lineColor:"#ff4444",hitAreaThickness:30,outlineOffset:16,outlineStrokeColor:"#ff4444",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(255, 68, 68, 0.05)",minWidth:1,textColor:"#ff4444",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},spot:{iconSrc:sx,iconSize:8,iconSizeFixed:!1,size:1,strokeColor:"#5d68fe",strokeWidth:2,fillColor:"rgba(93, 104, 254, 0.1)",showText:!0,textColor:"#5d68fe",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0],showIcon:!0,showFrame:!0},normal:{isDashed:!1,dashArray:[0,0],showIcon:!1,showFrame:!0}},wayPoint:{showOrder:!0,normal:{iconSrc:nx,iconSize:32,orderText:{fontSize:10,fontFamily:gi,fontWeight:"600",color:"#8a8a8a"},orderContainer:{size:12,backgroundColor:"#ffffff",offsetY:20,offsetX:0}},editing:{iconSrc:rx,iconSize:38,orderText:{fontSize:14,fontFamily:gi,fontWeight:"600",color:"#ff4444"},orderContainer:{size:16,backgroundColor:"#ffffff",offsetY:23,offsetX:0}}}},furniture:{assets:[{type:1,src:cx,width:1.8,height:2}],opacity:1,iconWrapperFillColor:"#26a69a",outlineOffset:16,outlineStrokeColor:"#26a69a",outlineStrokeWidth:1.5,outlineFillColor:"rgba(38, 166, 154, 0.05)",outlineDashed:!0,outlineDashArray:[4,3],showSizeText:!0,textColor:"#26a69a",textPosition:"bottom",textOffset:8,minScaleRatio:.5,maxScaleRatio:2,rotateDirection:"cw"},divider:{lineColor:"#ff4444",dashLineWidth:2,dashLineDashArray:[4,3],solidLineWidth:2,endPointSize:12,endPointColor:"#ff4444",endPointStrokeColor:"#ffffff",endPointStrokeWidth:2,hitAreaThickness:30,resetDividerWhenOutOfRoom:!1,defaultExtension:20,defaultDirection:"horizontal"},detectedObject:{height:43,width:38,interactive:!1,anchor:{x:.5,y:.5}},heatmap:{cellSize:2,maxDistance:14,smoothIterations:10,heatmapAlpha:.8,useGradient:!0,colorGradients:["#FF3B30","#FF7A00","#FFA100","#FFD700","#99DD70","#2EC070","#40E0D0","#88D0E9"]},snapshot:{format:"png",quality:1,antialias:!0,resolution:4}},Ix={dividingRoomId:-1,enableRoomSelection:!1,enableInteraction:!0,enableMapClickCapture:!1,editingForbiddenSweepZoneIds:[],editingForbiddenMopZoneIds:[],editingCleanZoneIds:[],editingVirtualWallIds:[],editingSpotIds:[],editingWayPointIds:[],editingCarpetIds:[],editingFurnitureIds:[],roomPropertyFoldIds:[],roomSelectionMode:"checkmark",mapRotation:0,selectRoomIds:[],showRoomProperty:!1,showRoomOrder:!0,showRoomName:!0,showRoomType:!0,showPath:!0,showRobot:!0,showChargingStation:!0,showRoomFloorType:!0,showCarpet:!0,showDetectedObjects:!0,showChargingStationRing:!1,showRobotRing:!1,showRobotSleepAnimation:!1,showRobotPulseCircle:!1,unit:"meter",unitLabel:"m",selectedCarpetIds:[]},Ha="MAIN",re=5e3;function Bx(r){return{all:r=r||new Map,on:function(t,e){var i=r.get(t);i?i.push(e):r.set(t,[e])},off:function(t,e){var i=r.get(t);i&&(e?i.splice(i.indexOf(e)>>>0,1):r.set(t,[]))},emit:function(t,e){var i=r.get(t);i&&i.slice().map(function(s){s(e)}),(i=r.get("*"))&&i.slice().map(function(s){s(t,e)})}}}class ic{constructor(t){this.app=t}getApp(){return this.app}getConfig(){return this.getApp().config}getDebuggerMode(){return!1}getRoomData(t){return this.getApp().managers.roomsManager.getRoomPropertyById(t)}metersToPixels(t){return this.getApp().metersToPixels(t)}pixelsToMeters(t){return this.getApp().pixelsToMeters(t)}metersToDisplayUnit(t){const{unit:e}=this.runtimeSnapshot;switch(e){case"feet":return t*3.28084;case"centimeter":return t*100;case"meter":default:return t}}get ticker(){return this.getApp().ticker}get mapState(){return this.getApp().mapState}get isMapDrawn(){return this.getApp().isMapDrawn}get config(){return this.getConfig()}get gloalConfig(){return this.getConfig().global}get mapConfig(){return this.getConfig().map}get roomConfig(){return this.getConfig().room}get heatMapConfig(){return this.getConfig().heatmap}get pathConfig(){return this.getConfig().path}get carpetConfig(){return this.getConfig().carpet}get robotConfig(){return this.getConfig().robot}get chargingStationConfig(){return this.getConfig().chargingStation}get interactionConfig(){return this.getConfig().interaction}get controlsConfig(){return this.getConfig().controls}get furnitureConfig(){return this.getConfig().furniture}get dividerConfig(){return this.getConfig().divider}get detectedObjectConfig(){return this.getConfig().detectedObject}get snapshotConfig(){return this.getConfig().snapshot}get appContainer(){return this.getApp().components.appContainer}get interaction(){return this.getApp().components.interaction}get viewportContainer(){return this.getApp().components.viewportContainer}get mapManager(){return this.getApp().managers.mapManager}get pathManager(){return this.getApp().managers.pathManager}get heatmapManager(){return this.getApp().managers.heatmapManager}get controlsManager(){return this.getApp().managers.controlsManager}get detectedObjectManager(){return this.getApp().managers.detectedObjectManager}get customElementsManager(){return this.getApp().managers.customElementsManager}get roomsManager(){return this.getApp().managers.roomsManager}get editControlManager(){return this.getApp().managers.editControlManager}get furnitureManager(){return this.getApp().managers.furnitureManager}get runtime(){return this.getApp().runtime}get runtimeSnapshot(){return Ey(this.getApp().runtime)}isInteractionEnabled(){return this.runtimeSnapshot.enableInteraction}fixPrecision(t,e){return Xl(t,e)}get events(){return this.getApp().events}get baseScale(){return this.getApp().components.interaction.targetScale.x}get currentScale(){return this.getApp().components.appContainer.scale.x}get emitter(){return this.getApp().emitter}getChargerPosition(){const t=this.mapState;return t?this.fixPrecision({x:t.charger.x-t.origin.x,y:t.charger.y-t.origin.y}):null}getRobotPosition(){const t=this.pathManager.robot;return t?t.getCurrentPosition():null}}let Dx="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Fx=(r=21)=>{let t="",e=r|0;for(;e--;)t+=Dx[Math.random()*64|0];return t};class zx extends L{constructor(e,i){super();g(this,"viewportBounds",{x:0,y:0,width:0,height:0});g(this,"maskGraphics",null);g(this,"containerElement",null);this.containerElement=i||window,this.calculateViewportBounds(e.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),this.createMask()}calculateViewportBounds(e){const{containerTop:i,containerLeft:s,containerWidth:n,containerHeight:o}=e,{width:a,height:h}=this.getContainerSize(),l=this.parseSize(s,a),c=this.parseSize(i,h),d=this.parseSize(n,a),u=this.parseSize(o,h);this.viewportBounds={x:l,y:c,width:d,height:u}}getContainerSize(){if(!this.containerElement)return{width:window.innerWidth,height:window.innerHeight};if(this.containerElement===window)return{width:window.innerWidth,height:window.innerHeight};const e=this.containerElement;return{width:e.clientWidth||window.innerWidth,height:e.clientHeight||window.innerHeight}}createMask(){this.maskGraphics=new H,this.maskGraphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215),this.addChild(this.maskGraphics),this.mask=this.maskGraphics}parseSize(e,i){if(!isNaN(Number(e)))return Number(e);if(e=e.trim(),e.endsWith("%")){const s=parseFloat(e)/100;return i*s}if(e.endsWith("vw")){const s=parseFloat(e)/100;return window.innerWidth*s}if(e.endsWith("vh")){const s=parseFloat(e)/100;return window.innerHeight*s}if(e.endsWith("rpx")){const s=parseFloat(e),n=window.innerWidth/750;return s*n}return e.endsWith("px")||!isNaN(parseFloat(e))?parseFloat(e):(A.warn(`Cannot parse size value: ${e}`),0)}getViewportBounds(){return{...this.viewportBounds}}updateViewport(e){var i,s;this.calculateViewportBounds(e.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),(i=this.maskGraphics)==null||i.clear(),(s=this.maskGraphics)==null||s.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215)}addContent(e){this.addChild(e)}}const Lx="interaction",sc="roomFill",nc="free",Fr="roomFloorType",rc="carpet",oc="obstacle",ac="heatmap",hc="path",ds="furniture",Ne="controls",lc="roomInfo",We="detectedObject",Si="customElement",vi="customElementGif",cc="chargingStation",dc="robot",us="customCarpet",Ti="editControls",Ox=[Lx,sc,nc,Fr,rc,us,oc,ac,hc,ds,lc,We,Si,vi,cc,dc,Ne,Ti];class Gx extends L{constructor(e){super();g(this,"layers",new Map);g(this,"mapRotation",0);g(this,"backgroundGraphics");g(this,"lastBackgroundState",null);this.appService=e;const s=this.appService.getApp().getViewportBounds();this.position.set(Math.round(s.width/2),Math.round(s.height/2)),this.pivot.set(0,0),this.backgroundGraphics=new H,this.backgroundGraphics.label="snapshotBackground",this.backgroundGraphics.visible=!1,this.addChild(this.backgroundGraphics),this.initializeLayers()}initializeLayers(){Object.values(Ox).forEach(i=>{const s=new L;s.label=i,i===Ne&&(s.isRenderGroup=!0),i===Ti&&(s.isRenderGroup=!0),i===Fr&&(s.eventMode="none"),this.layers.set(i,s),this.addChild(s)})}getLayer(e){return this.layers.get(e)}addToLayer(e,i,s){const n=this.layers.get(e);return n?(s!==void 0&&(i.zIndex=s),n.addChild(i),!0):(A.warn("[AppContainer Debug] Layer not found:",e),!1)}removeFromLayer(e,i){const s=this.layers.get(e);return s&&i.parent===s?(s.removeChild(i),!0):!1}clearLayer(e){const i=this.layers.get(e);return i?(i.removeChildren(),!0):!1}setLayerVisibility(e,i){const s=this.layers.get(e);return s?(s.visible=i,!0):!1}getLayerVisibility(e){const i=this.layers.get(e);return i?i.visible:!1}setMapRotation(e){this.mapRotation=e*Math.PI/180,this.rotation=this.mapRotation}getMapRotation(){return this.mapRotation*180/Math.PI}getMapRotationRadians(){return this.mapRotation}getSnapshotBounds(){this.layers.forEach(s=>{});const e=this.backgroundGraphics.visible;this.backgroundGraphics.visible=!1;const i=this.getLocalBounds();return this.backgroundGraphics.visible=e,new et(i.x,i.y,i.width,i.height)}updateBackground(e,i){if(!i){this.backgroundGraphics.visible=!1,this.lastBackgroundState=null;return}const s=this.getSnapshotBounds(),{x:n,y:o,width:a,height:h}=s;if(this.lastBackgroundState&&this.lastBackgroundState.color===e&&this.lastBackgroundState.width===a&&this.lastBackgroundState.height===h&&this.lastBackgroundState.x===n&&this.lastBackgroundState.y===o){this.backgroundGraphics.visible=!0;return}this.backgroundGraphics.clear(),this.backgroundGraphics.rect(n,o,a,h).fill(e),this.backgroundGraphics.visible=!0,this.lastBackgroundState={color:e,x:n,y:o,width:a,height:h}}}class Xt extends jt{constructor(e,i){super(i);g(this,"throttledUpdateScale");g(this,"fixedWidth",0);g(this,"fixedHeight",0);g(this,"isFixedSizeSet",!1);g(this,"sizeFixed",!0);g(this,"baselineScale",1);this.appService=e,this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=At(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(e,i){this.fixedWidth=e,this.fixedHeight=i,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(e){this.sizeFixed=e,this.baselineScale=1,e&&this.isFixedSizeSet?this.applySize():!e&&this.isFixedSizeSet&&this.applySize()}set width(e){if(this.isFixedSizeSet){A.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置宽度");return}this.setFixedSize(e,this.fixedHeight||e)}set height(e){if(this.isFixedSizeSet){A.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置高度");return}this.setFixedSize(this.fixedWidth||e,e)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(this.destroyed||!this.scale||!this.isFixedSizeSet||!this.texture||this.texture.width===0||this.texture.height===0)return;const e=this.appService,i=this.fixedWidth/this.texture.width,s=this.fixedHeight/this.texture.height;if(this.sizeFixed){const n=e.currentScale;if(n===0)return;const o=i/n,a=s/n;this.scale&&super.scale.set(o,a)}else this.scale&&super.scale.set(i/this.baselineScale,s/this.baselineScale)}updateScale(e){this.destroyed||!this.scale||this.sizeFixed&&(this.isFixedSizeSet?this.applySize():e!==0&&super.scale.set(1/e))}async loadTextureAndSetSize(e,i){try{const s=this.appService,n=await N.load(e);if(this.destroyed||(this.texture=n,this.destroyed)||(i.sizeFixed!==void 0&&this.setSizeFixed(i.sizeFixed),this.setFixedSize(i.width,i.height),this.destroyed))return;s.getApp().renderOnceNextFrame()}catch(s){A.error(`Failed to load texture "${e}":`,s)}}draw(e,i){const{x:s,y:n,rotation:o=0}=e;i&&!this.visible?this.visible=i():!i&&!this.visible&&(this.visible=!0),this.rotation=o,this.position.set(s,n)}set texture(e){super.texture=e,this.isFixedSizeSet&&e&&e.width>0&&e.height>0&&this.applySize()}get texture(){return super.texture}destroy(e){this.appService.emitter.off("antiScale",this.throttledUpdateScale),this.throttledUpdateScale.cancel(),super.destroy(e)}}class Wx extends Xt{constructor(t){super(t),this.appService=t,this.initializeSprite()}async initializeSprite(){const t=this.appService;await this.loadTextureAndSetSize("chargingStation",t.chargingStationConfig.icon)}async draw({x:t,y:e,rotation:i}){const s=this.appService;super.draw({x:t,y:e,rotation:i},()=>s.runtimeSnapshot.showChargingStation)}}class uc extends H{constructor(e,i){super();g(this,"currentPosition",null);g(this,"config");g(this,"handleScaleChange",()=>{this.redraw()});this.appService=e,this.setupAntiScaleListener(),this.config=i.config}setupAntiScaleListener(){this.appService.emitter.on("antiScale",this.handleScaleChange)}draw(e){const i=this.appService;this.currentPosition=e;const{size:s,color:n,strokeWidth:o,strokeColor:a,strokeDashed:h,strokeDashArray:l}=this.config;this.clear();const c=i.metersToPixels(s),d=i.getApp().toFixedSize(o);this.setFillStyle({color:n}),h&&l.length>=2?this.drawDashedCircle(e,c,a,d,l):this.circle(e.x,e.y,c).fill().stroke({color:a,width:d,cap:"round",join:"round"})}drawDashedCircle(e,i,s,n,o){const a=this.appService;this.circle(e.x,e.y,i).fill();const h=a.getApp().toFixedSize(o[0]),l=a.getApp().toFixedSize(o[1]),c=2*Math.PI*i,d=h+l,u=Math.floor(c/d);if(u===0){this.circle(e.x,e.y,i).stroke({color:s,width:n,cap:"round",join:"round"});return}const p=c/u,f=p*(h/d);for(let y=0;y<u;y++){const m=y*p/i,x=(y*p+f)/i,S=Math.max(4,Math.ceil(Math.abs(x-m)*i/2)),v=(x-m)/S;for(let b=0;b<=S;b++){const P=m+v*b,w=e.x+i*Math.cos(P),C=e.y+i*Math.sin(P);b===0?this.moveTo(w,C):this.lineTo(w,C)}}this.stroke({color:s,width:n,cap:"round",join:"round"})}redraw(){this.currentPosition&&this.draw(this.currentPosition)}destroy(){this.appService.emitter.off("antiScale",this.handleScaleChange),super.destroy()}}class vt{constructor(t,e={}){g(this,"target");g(this,"isPointerDown",!1);g(this,"pointerDownPos",null);g(this,"clickThreshold");g(this,"stopPropagation");g(this,"clickCallback",null);this.target=t,this.clickThreshold=e.clickThreshold??10,this.stopPropagation=e.stopPropagation??!1,this.clickCallback=e.onClick||null,this.setup()}setup(){this.target.interactive=!0,this.target.eventMode="static",this.target.on("pointerdown",this.handlePointerDown.bind(this)),this.target.on("pointermove",this.handlePointerMove.bind(this)),this.target.on("pointerup",this.handlePointerUp.bind(this)),this.target.on("pointerupoutside",this.handlePointerUpOutside.bind(this))}handlePointerDown(t){this.stopPropagation&&t.stopPropagation(),this.isPointerDown=!0,this.pointerDownPos={x:t.globalX,y:t.globalY}}handlePointerMove(t){if(this.stopPropagation&&t.stopPropagation(),this.isPointerDown&&this.pointerDownPos){const e=t.globalX-this.pointerDownPos.x,i=t.globalY-this.pointerDownPos.y;Math.sqrt(e*e+i*i)>this.clickThreshold&&(this.isPointerDown=!1,this.pointerDownPos=null)}}handlePointerUp(t){if(this.stopPropagation&&t.stopPropagation(),this.isPointerDown&&this.pointerDownPos){const e=t.globalX-this.pointerDownPos.x,i=t.globalY-this.pointerDownPos.y;Math.sqrt(e*e+i*i)<=this.clickThreshold&&this.clickCallback&&this.clickCallback(t,this.target)}this.isPointerDown=!1,this.pointerDownPos=null}handlePointerUpOutside(){this.isPointerDown=!1,this.pointerDownPos=null}setClickCallback(t){return this.clickCallback=t,this}setClickThreshold(t){return this.clickThreshold=t,this}getTarget(){return this.target}isInteracting(){return this.isPointerDown}destroy(){this.target.off("pointerdown",this.handlePointerDown),this.target.off("pointermove",this.handlePointerMove),this.target.off("pointerup",this.handlePointerUp),this.target.off("pointerupoutside",this.handlePointerUpOutside),this.clickCallback=null}}class Ux extends L{constructor(e){super();g(this,"chargingStation");g(this,"ring");g(this,"unsubscribeFns",[]);g(this,"clickHandler");this.appService=e,e.appContainer.addToLayer(cc,this),this.ring=new uc(this.appService,{config:this.appService.chargingStationConfig.ring}),this.ring.visible=this.appService.runtimeSnapshot.showChargingStationRing,this.addChild(this.ring),this.chargingStation=new Wx(this.appService),this.addChild(this.chargingStation);const i=U(this.appService.runtime,"showChargingStationRing",s=>{A.log(`[runtime] showChargingStationRing: ${s}`),this.ring.visible=s});this.unsubscribeFns.push(i),this.initClickInteraction()}async draw({x:e,y:i,rotation:s}){if(e===0&&i===0){this.visible=!1;return}this.visible=!0,this.ring.draw({x:e,y:i}),await this.chargingStation.draw({x:e,y:i,rotation:s})}initClickInteraction(){const{enableChargingStationClick:e}=this.appService.interactionConfig;e&&(this.clickHandler||(this.clickHandler=new vt(this.chargingStation,{onClick:()=>{var i;if((i=this.appService.events)!=null&&i.onClickChargingStation){const s=this.appService.getChargerPosition()??{x:0,y:0};this.appService.events.onClickChargingStation({rotation:this.chargingStation.rotation,...s})}}})))}destroy(){this.unsubscribeFns.forEach(e=>e()),this.unsubscribeFns=[],this.ring.destroy(),this.clickHandler&&this.clickHandler.destroy(),super.destroy()}}class Hx extends L{constructor(e){super({isRenderGroup:!0});g(this,"carpetSprite",null);g(this,"carpetMask",null);this.appService=e,this.appService.appContainer.addToLayer(rc,this)}async createCarpetFromRasterData(e,i){const s=this.appService;if(!s.runtimeSnapshot.showCarpet||(this.clearCarpet(),e.length===0))return;const{src:n,opacity:o,scale:a}=s.carpetConfig,h=await N.load(n);if(!h){A.warn(`Carpet texture not found: ${n}`);return}const l=this.createCarpetGraphics(e,i),c=l.getLocalBounds();if(c.width===0||c.height===0)return;const d=new Ss({texture:h,width:c.width,height:c.height});d.x=c.x,d.y=c.y,d.alpha=o,d.tileScale.set(a);const u=new L;u.addChild(l),d.mask=u,this.addChild(d),this.carpetSprite=d,this.carpetMask=u,s.getApp().renderOnceNextFrame()}createCarpetGraphics(e,i){const s=new H;for(let n=0;n<e.length;n++){const o=e[n],a=o%i,h=Math.floor(o/i);s.rect(a,h,1,1)}return s.fill(16777215),s}clearCarpet(){this.carpetSprite&&(this.removeChild(this.carpetSprite),this.carpetSprite.destroy(),this.carpetSprite=null),this.carpetMask&&(this.carpetMask.destroy({children:!0}),this.carpetMask=null)}async createCarpetFromStructuredData(e){const i=this.appService;if(!i.runtimeSnapshot.showCarpet||!e||(this.clearCarpet(),e.length===0))return;const{src:s,opacity:n,scale:o}=i.carpetConfig,a=await N.load(s);if(!a){A.warn(`Carpet texture not found: ${s}`);return}const h=this.createCarpetGraphicsFromStructuredData(e),l=h.getLocalBounds();if(l.width===0||l.height===0)return;const c=new Ss({texture:a,width:l.width,height:l.height});c.x=l.x,c.y=l.y,c.alpha=n,c.tileScale.set(o);const d=new L;d.addChild(h),c.mask=d,this.addChild(c),this.carpetSprite=c,this.carpetMask=d,i.getApp().renderOnceNextFrame()}createCarpetGraphicsFromStructuredData(e){const i=new H;for(const s of e){const n=s.coordinates;for(let o=0;o<n.length;o+=2){const a=n[o],h=n[o+1];i.rect(a,h,1,1)}}return i.fill(16777215),i}destroy(){this.clearCarpet(),super.destroy()}}class Va extends H{constructor(t){super(),this.appService=t,this.appService.appContainer.addToLayer(nc,this)}draw(t){const e=this.appService;this.clear(),this.setFillStyle({color:e.mapConfig.freeColor});for(const i of t){const s=i.coordinates;for(let n=0;n<s.length;n+=2){const o=s[n],a=s[n+1];this.rect(o,a,1,1)}}this.fill()}destroy(t){super.destroy(t)}}class Na extends H{constructor(t){super(),this.appService=t,this.appService.appContainer.addToLayer(oc,this)}draw(t){const e=this.appService;this.clear(),this.setFillStyle({color:e.mapConfig.obstacleColor});for(const i of t){const s=i.coordinates;for(let n=0;n<s.length;n+=2){const o=s[n],a=s[n+1];this.rect(o,a,1,1)}}this.fill()}drawRaster(t,e){const i=this.appService;if(this.clear(),t.length!==0){this.setFillStyle({color:i.mapConfig.obstacleColor});for(let s=0;s<t.length;s+=re){const n=Math.min(s+re,t.length);for(let o=s;o<n;o++){const a=t[o],h=a%e,l=Math.floor(a/e);this.rect(h,l,1,1)}this.fill(),n<t.length&&this.setFillStyle({color:i.mapConfig.obstacleColor})}}}destroy(t){super.destroy(t)}}class ja extends L{constructor(e){super({isRenderGroup:!0});g(this,"roomGraphicsMap",new Map);g(this,"roomContextMap",new Map);g(this,"roomClickHandlerMap",new Map);g(this,"unsubscribeFns",[]);g(this,"mapWidth",0);g(this,"rasterRoomDataMap",new Map);g(this,"structuredRoomGeometry",new Map);this.appService=e,this.appService.appContainer.addToLayer(sc,this);const i=Bs(this.appService.config.room.colors,()=>{this.refreshRoomColors()});this.unsubscribeFns.push(i)}draw(e){const i=this.appService;this.clearRooms();const s=i.roomConfig,{selectRoomIds:n,enableRoomSelection:o}=i.runtimeSnapshot;e.forEach(a=>{const h=a.id>=255,l=new H,c=new mt,d=new mt,u=new mt;if(h)c.setFillStyle({color:a.color}),d.setFillStyle({color:a.color}),u.setFillStyle({color:a.color});else{const p=a.colorIndex??0,f=s.colors.active[p%s.colors.active.length],y=s.colors.inactive[p%s.colors.inactive.length],m=(s.colors.normal||s.colors.active)[p%(s.colors.normal||s.colors.active).length];c.setFillStyle({color:f}),d.setFillStyle({color:y}),u.setFillStyle({color:m})}if(c.poly(a.polyPoints).fill(),d.poly(a.polyPoints).fill(),u.poly(a.polyPoints).fill(),a.outlinePoints.forEach(p=>{c.rect(p.x,p.y,1,1).fill(),d.rect(p.x,p.y,1,1).fill(),u.rect(p.x,p.y,1,1).fill()}),h?l.context=c:l.context=o?n.includes(a.id)?c:d:u,!h){const p=new vt(l,{clickThreshold:10,onClick:()=>{this.handleRoomClick(a.id)}});this.roomClickHandlerMap.set(a.id,p),this.structuredRoomGeometry.set(a.id,{polyPoints:a.polyPoints,outlinePoints:a.outlinePoints,colorIndex:a.colorIndex??0})}this.roomGraphicsMap.set(a.id,l),this.roomContextMap.set(a.id,{activeContext:c,inactiveContext:d,normalContext:u}),this.addChild(l)})}drawRaster(e){const i=this.appService;if(this.clearRooms(),this.mapWidth=e.width,e.sortedRooms.length===0)return;const{selectRoomIds:s,enableRoomSelection:n}=i.runtimeSnapshot;e.sortedRooms.forEach(o=>{this.drawRasterRoom(o,n,s)})}drawRasterRoom(e,i,s){const{roomId:n,pixelIndices:o,activeColor:a,inactiveColor:h}=e,c=this.appService.roomConfig;let d=a;const u=typeof n=="number";if(u){const S=e.colorIndex??0;d=(c.colors.normal||c.colors.active)[S%(c.colors.normal||c.colors.active).length]}const p=new H,f=new mt,y=new mt,m=new mt;f.setFillStyle({color:a}),y.setFillStyle({color:h}),m.setFillStyle({color:d}),this.drawPixelPointsInBatches(f,o,re,this.mapWidth),this.drawPixelPointsInBatches(y,o,re,this.mapWidth),this.drawPixelPointsInBatches(m,o,re,this.mapWidth);const x=u&&s.includes(n);if(p.context=i?u&&x?f:y:m,u){const S=new vt(p,{clickThreshold:10,onClick:()=>{this.handleRoomClick(n)}});this.roomClickHandlerMap.set(n,S)}this.roomGraphicsMap.set(n,p),this.roomContextMap.set(n,{activeContext:f,inactiveContext:y,normalContext:m}),this.rasterRoomDataMap.set(n,e),this.addChild(p)}drawPixelPointsInBatches(e,i,s,n){for(let o=0;o<i.length;o+=s){const a=Math.min(o+s,i.length);for(let h=o;h<a;h++){const l=i[h],c=l%n,d=Math.floor(l/n);e.rect(c,d,1,1)}e.fill()}}handleRoomClick(e){var s,n;const i=this.appService;(n=(s=i.events)==null?void 0:s.onClickRoom)==null||n.call(s,i.getRoomData(e)??{id:e})}setRoomStateBySelectIds(e){const i=this.appService,{enableRoomSelection:s}=i.runtimeSnapshot;this.roomGraphicsMap.forEach((n,o)=>{if(typeof o=="number"){const a=this.roomContextMap.get(o);if(a)if(s){const h=e.includes(o);n.context=h?a.activeContext:a.inactiveContext}else n.context=a.normalContext}})}setRoomState(e,i){const s=this.roomGraphicsMap.get(e),n=this.roomContextMap.get(e);if(!s||!n){A.warn(`Room ${e} not found`);return}typeof e=="number"&&(s.context=i?n.activeContext:n.inactiveContext)}setAllRoomsState(e){this.roomGraphicsMap.forEach((i,s)=>{typeof s=="number"&&this.setRoomState(s,e)})}getRoomGraphicsMap(){const e=new Map;return this.roomGraphicsMap.forEach((i,s)=>{typeof s=="number"&&e.set(s,i)}),e}getRasterRoomData(e){return this.rasterRoomDataMap.get(e)||null}getMapWidth(){return this.mapWidth}isWallIntersectsAnyRoom(e){const s=this.appService.getApp().mapState;if(!s)return A.warn("[RoomFill] Map state not available"),!1;if(!e||e.length!==2)return A.warn("[RoomFill] Invalid wall points provided"),!1;const[n,o]=e,a={x:n.x+s.origin.x,y:n.y+s.origin.y},h={x:o.x+s.origin.x,y:o.y+s.origin.y};return s.mapType==="raster"?this.isWallIntersectsAnyRoomRaster(a,h):this.isWallIntersectsAnyRoomStructured(a,h)}isZoneIntersectsAnyRoom(e){const s=this.appService.getApp().mapState;if(!s)return A.warn("[RoomFill] Map state not available"),!1;if(!e||e.length!==4)return A.warn("[RoomFill] Invalid zone points provided"),!1;const n=e.map(o=>({x:o.x+s.origin.x,y:o.y+s.origin.y}));return s.mapType==="raster"?this.isZoneIntersectsAnyRoomRaster(n):this.isZoneIntersectsAnyRoomStructured(n)}isWallIntersectsAnyRoomRaster(e,i){if(this.mapWidth===0||this.rasterRoomDataMap.size===0)return!1;const s=this.getLinePixels(e,i);for(const n of this.rasterRoomDataMap.values())for(const o of s)if(Zl(n.pixelIndices,o))return!0;return!1}isWallIntersectsAnyRoomStructured(e,i){const n=this.appService.mapManager.getAllRooms();for(const o of n)if(!(!o.outlinePoints||o.outlinePoints.length<3)){if(Rt(e,o.outlinePoints,!0)||Rt(i,o.outlinePoints,!0))return!0;for(let a=0;a<o.outlinePoints.length;a++){const h=o.outlinePoints[a],l=o.outlinePoints[(a+1)%o.outlinePoints.length];if(zi(e,i,h,l))return!0}}return!1}isZoneIntersectsAnyRoomRaster(e){if(this.mapWidth===0||this.rasterRoomDataMap.size===0)return!1;const i=[[e[0],e[1]],[e[1],e[2]],[e[2],e[3]],[e[3],e[0]]];for(const[n,o]of i)if(this.isWallIntersectsAnyRoomRaster(n,o))return!0;const s=this.rasterRoomDataMap.values().next().value;if(s&&s.pixelIndices.length>0){const n=s.pixelIndices[0],o=n%this.mapWidth,a=Math.floor(n/this.mapWidth);if(Rt({x:o,y:a},e,!0))return!0}return!1}isZoneIntersectsAnyRoomStructured(e){const s=this.appService.mapManager.getAllRooms(),n=[[e[0],e[1]],[e[1],e[2]],[e[2],e[3]],[e[3],e[0]]];for(const o of s)if(!(!o.outlinePoints||o.outlinePoints.length<3)){for(const a of e)if(Rt(a,o.outlinePoints,!0))return!0;for(const a of o.outlinePoints)if(Rt(a,e,!0))return!0;for(const[a,h]of n)for(let l=0;l<o.outlinePoints.length;l++){const c=o.outlinePoints[l],d=o.outlinePoints[(l+1)%o.outlinePoints.length];if(zi(a,h,c,d))return!0}}return!1}getLinePixels(e,i){const n=this.appService.getApp().mapState;if(!n)return[];const o=n.height,a=[],h=Math.round(e.x),l=Math.round(e.y),c=Math.round(i.x),d=Math.round(i.y),u=Math.abs(c-h),p=Math.abs(d-l),f=h<c?1:-1,y=l<d?1:-1;let m=u-p,x=h,S=l;for(;;){if(x>=0&&x<this.mapWidth&&S>=0&&S<o){const b=S*this.mapWidth+x;a.push(b)}if(x===c&&S===d)break;const v=2*m;v>-p&&(m-=p,x+=f),v<u&&(m+=u,S+=y)}return a}getZonePixels(e,i,s,n){const a=this.appService.getApp().mapState;if(!a)return[];const h=a.height,l=[],c=Math.max(0,Math.floor(e)),d=Math.min(this.mapWidth-1,Math.ceil(s)),u=Math.max(0,Math.floor(i)),p=Math.min(h-1,Math.ceil(n));for(let f=u;f<=p;f++)for(let y=c;y<=d;y++){const m=f*this.mapWidth+y;l.push(m)}return l}refreshRoomColors(){const{selectRoomIds:e,enableRoomSelection:i}=this.appService.runtimeSnapshot,s=this.appService.roomConfig;this.roomGraphicsMap.forEach((n,o)=>{if(typeof o!="number")return;const a=this.roomContextMap.get(o),h=this.structuredRoomGeometry.get(o);if(a&&h){const l=h.colorIndex,c=s.colors.active[l%s.colors.active.length],d=s.colors.inactive[l%s.colors.inactive.length],u=(s.colors.normal||s.colors.active)[l%(s.colors.normal||s.colors.active).length];a.activeContext.clear(),a.activeContext.setFillStyle({color:c}),a.activeContext.poly(h.polyPoints).fill(),h.outlinePoints.forEach(p=>{a.activeContext.rect(p.x,p.y,1,1).fill()}),a.inactiveContext.clear(),a.inactiveContext.setFillStyle({color:d}),a.inactiveContext.poly(h.polyPoints).fill(),h.outlinePoints.forEach(p=>{a.inactiveContext.rect(p.x,p.y,1,1).fill()}),a.normalContext.clear(),a.normalContext.setFillStyle({color:u}),a.normalContext.poly(h.polyPoints).fill(),h.outlinePoints.forEach(p=>{a.normalContext.rect(p.x,p.y,1,1).fill()}),n.context=i?e.includes(o)?a.activeContext:a.inactiveContext:a.normalContext}else if(a){const l=this.rasterRoomDataMap.get(o);if(l){const c=l.colorIndex??0,d=s.colors.active[c%s.colors.active.length],u=s.colors.inactive[c%s.colors.inactive.length],p=(s.colors.normal||s.colors.active)[c%(s.colors.normal||s.colors.active).length];a.activeContext.clear(),a.activeContext.setFillStyle({color:d}),this.drawPixelPointsInBatches(a.activeContext,l.pixelIndices,re,this.mapWidth),a.inactiveContext.clear(),a.inactiveContext.setFillStyle({color:u}),this.drawPixelPointsInBatches(a.inactiveContext,l.pixelIndices,re,this.mapWidth),a.normalContext.clear(),a.normalContext.setFillStyle({color:p}),this.drawPixelPointsInBatches(a.normalContext,l.pixelIndices,re,this.mapWidth),n.context=i?e.includes(o)?a.activeContext:a.inactiveContext:a.normalContext}}}),this.appService.getApp().renderOnceNextFrame()}clearRooms(){this.children.length===0&&this.roomGraphicsMap.size===0||(this.roomGraphicsMap.forEach(e=>{try{e.destroy()}catch(i){A.warn("Error destroying room graphics:",i)}}),this.roomGraphicsMap.clear(),this.roomContextMap.forEach(e=>{try{e.activeContext.destroy(),e.inactiveContext.destroy(),e.normalContext.destroy()}catch(i){A.warn("Error destroying graphics context:",i)}}),this.roomContextMap.clear(),this.roomClickHandlerMap.forEach(e=>{try{e.destroy()}catch(i){A.warn("Error destroying click handler:",i)}}),this.roomClickHandlerMap.clear(),this.removeChildren(),this.rasterRoomDataMap.clear(),this.structuredRoomGeometry.clear())}destroy(){this.unsubscribeFns.forEach(e=>e()),this.unsubscribeFns=[],this.clearRooms(),super.destroy()}}class Vx{constructor(t){g(this,"obstacle");g(this,"free");g(this,"roomFill");g(this,"carpet");g(this,"chargingStation");g(this,"mapBounds",{minX:0,minY:0,maxX:0,maxY:0});g(this,"lastMapId",null);g(this,"lastOrigin",null);g(this,"lastSize",null);g(this,"lastStatus",null);g(this,"roomGeometryMap",new Map);g(this,"rasterRoomPixelsMap",new Map);g(this,"fourColorCache",null);g(this,"carpetData",null);g(this,"unsubscribeFns",[]);this.appService=t,this.obstacle=new Na(this.appService),this.free=new Va(this.appService),this.roomFill=new ja(this.appService),this.carpet=new Hx(this.appService),this.chargingStation=new Ux(this.appService),this.validateColorConfig();const e=U(t.runtime,"enableRoomSelection",o=>{if(A.log(`[runtime] enableRoomSelection: ${o}`),o){this.roomFill.setAllRoomsState(!1);const a=this.appService.runtimeSnapshot.selectRoomIds;this.roomFill.setRoomStateBySelectIds(a)}else this.roomFill.setAllRoomsState(!0)}),i=U(t.runtime,"selectRoomIds",o=>{A.log(`[runtime] selectRoomIds: ${o}`),this.roomFill.setRoomStateBySelectIds(o)}),s=U(t.runtime,"showChargingStation",o=>{A.log(`[runtime] showChargingStation: ${o}`),this.chargingStation.visible=o}),n=U(t.runtime,"showCarpet",o=>{A.log(`[runtime] showCarpet: ${o}`),o?t.getApp().managers.customCarpetManager.getCustomCarpets().length===0&&this.createCarpet():this.carpet.clearCarpet()});this.unsubscribeFns.push(e,i,s,n)}async drawMap(t){const e=this.appService,{id:i,obstacles:s,free:n,rooms:o,charger:a,carpet:h,status:l,origin:c,size:d}=t;this.clearComponents(),this.resetGeometryData();const u=this.processRoomsGeometry(o);this.roomFill.draw(u),n&&this.free.draw(n),s&&this.obstacle.draw(s),this.carpetData=h,this.createCarpet();const p=this.mergeLayerBounds();Zr(p,this.mapBounds)||(A.debug("[Map] Map bounds updated:",p),this.mapBounds=p,this.shouldFitMapToView(i,l===1,{x:c[0],y:c[1]},{x:d[0],y:d[1]})&&(e.getApp().fitMapToView(this.mapBounds),this.lastMapId=i,this.lastOrigin={x:c[0],y:c[1]},this.lastSize={x:d[0],y:d[1]},this.lastStatus=l===1));const f=((t.charger.angle??0)+e.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:a.coordinate[0],y:a.coordinate[1],rotation:f}),await e.roomsManager.refresh(),!0}async drawRasterMap(t,e){const i=this.appService;this.clearComponents();const{id:s,width:n,height:o,charger:a,chargerDirection:h,status:l,origin:c}=e;A.debug("[Map] Parsed Raster Map Data",t),this.obstacle.drawRaster(t.obstacles,n),this.carpetData=this.convertRasterToStructuredData(t.carpet,n),i.getApp().managers.customCarpetManager.getCustomCarpets().length===0&&this.createCarpet();const u=this.processRasterData(t);this.roomFill.drawRaster(u);const p=yy(t,n,o);Zr(p,this.mapBounds)||(A.debug("[Map] Raster map bounds updated:",p),this.mapBounds=p,this.shouldFitMapToView(s,l,c,{x:n,y:o})&&(i.getApp().fitMapToView(this.mapBounds),this.lastMapId=s,this.lastOrigin={...c},this.lastSize={x:n,y:o},this.lastStatus=l));const f=(h+i.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:a.x,y:a.y,rotation:f}),this.generateRoomGeometryFromRaster(t),await i.roomsManager.refresh(),!0}resetGeometryData(){this.roomGeometryMap.clear(),this.rasterRoomPixelsMap.clear(),this.fourColorCache=null,this.mapBounds={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}shouldFitMapToView(t,e,i,s){const n=this.appService,{originChangeAutoFitThreshold:o,sizeChangeAutoFitThreshold:a}=n.getApp().config.map;if(this.lastMapId!==t)return A.debug("[Map] Map ID changed, triggering fitMapToView"),!0;if(this.lastStatus!==null&&this.lastStatus!==e)return A.debug(`[Map] Map status changed (${this.lastStatus} -> ${e}), triggering fitMapToView`),!0;if(this.lastOrigin&&i){const h=Math.abs(i.x-this.lastOrigin.x),l=Math.abs(i.y-this.lastOrigin.y);if(h>o||l>o)return A.debug(`[Map] Origin change exceeded threshold (deltaX: ${h}, deltaY: ${l}, threshold: ${o}), triggering fitMapToView`),!0}if(this.lastSize&&s){const h=Math.abs(s.x-this.lastSize.x),l=Math.abs(s.y-this.lastSize.y);if(h>a||l>a)return A.debug(`[Map] Size change exceeded threshold (deltaX: ${h}, deltaY: ${l}, threshold: ${a}), triggering fitMapToView`),!0}return!1}convertRasterToStructuredData(t,e){if(t.length===0)return[];const i=[];for(let s=0;s<t.length;s++){const n=t[s],o=n%e,a=Math.floor(n/e);i.push(o,a)}return[{coordinates:i}]}async createCarpet(){!this.appService.runtimeSnapshot.showCarpet||!this.carpetData||await this.carpet.createCarpetFromStructuredData(this.carpetData)}processRoomsGeometry(t){if(!t)return[];const e=this.appService,{active:i}=e.roomConfig.colors,s=e.roomConfig.colors[oe.UNKNOWN_ROOM];if(Object.keys(t).length===0)return this.mapBounds={minX:0,minY:0,maxX:0,maxY:0},[];const n=Object.keys(t).sort((u,p)=>Number(u)-Number(p)),o=n.filter(u=>Number(u)<255),a=n.filter(u=>Number(u)>=255),h=[],l=[];o.forEach(u=>{const{coordinates:p}=t[u];if(p.length<4)return;const f=p.filter(_=>!isFinite(_));if(f.length>0){A.error(`[Room ${u}] Contains ${f.length} invalid coordinates (NaN/Infinity)`);return}const y=Number(u);let m=1/0,x=1/0,S=-1/0,v=-1/0;const b=[];for(let _=0;_<p.length;_+=2){const I=p[_],B=p[_+1];m=Math.min(m,I),x=Math.min(x,B),S=Math.max(S,I),v=Math.max(v,B),b.push({x:I,y:B})}const P=S-m,w=v-x;if(P===0||w===0){A.error(`[Room ${u}] Degenerate polygon (${P}x${w}). Skipping.`);return}if(P<2||w<2){A.warn(`[Room ${u}] Room too small (${P}x${w}), skipping`);return}const C=new et(m,x,S-m+1,v-x+1),k=ka(b),M=k.flatMap(_=>[_.x+.5,_.y+.5]),T=Ra(k,m,x,S,v);l.push({id:y,points:b,outlinePoints:k,polyPoints:M,centerPoint:T,boundingBox:C}),this.mapBounds.minX=Math.min(this.mapBounds.minX,m),this.mapBounds.minY=Math.min(this.mapBounds.minY,x),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,S),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,v)});const c=[...l].sort((u,p)=>{if(e.roomConfig.colors.sortBy==="area"){const f=u.outlinePoints.length;return p.outlinePoints.length-f}else return u.id-p.id}),d=this.assignColorsUsingFourColorAlgorithm(c,i.length,"structured");return l.forEach(u=>{const p=d.get(u.id)||0,f=i[p],y={id:u.id,color:f,colorIndex:p,boundingBox:u.boundingBox,points:u.points,outlinePoints:u.outlinePoints,polyPoints:u.polyPoints,centerPoint:u.centerPoint};this.roomGeometryMap.set(u.id,y),h.push(y)}),a.forEach(u=>{const{coordinates:p}=t[u];if(p.length<4)return;const f=Number(u);let y=1/0,m=1/0,x=-1/0,S=-1/0;const v=[];for(let _=0;_<p.length;_+=2){const I=p[_],B=p[_+1];y=Math.min(y,I),m=Math.min(m,B),x=Math.max(x,I),S=Math.max(S,B),v.push({x:I,y:B})}const b=x-y,P=S-m;if(b===0||P===0){A.error(`[Unknown Room ${u}] Degenerate polygon (${b}x${P}). Skipping.`);return}if(b<2||P<2){A.warn(`[Unknown Room ${u}] Room too small (${b}x${P}), skipping`);return}const w=new et(y,m,x-y+1,S-m+1),C=ka(v),k=C.flatMap(_=>[_.x+.5,_.y+.5]),M=Ra(C,y,m,x,S),T={id:f,color:s,boundingBox:w,points:v,outlinePoints:C,polyPoints:k,centerPoint:M};h.push(T),this.mapBounds.minX=Math.min(this.mapBounds.minX,y),this.mapBounds.minY=Math.min(this.mapBounds.minY,m),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,x),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,S)}),h}mergeLayerBounds(){let t={...this.mapBounds};if(this.obstacle.bounds&&(t=An(t,this.obstacle.bounds)),this.free.bounds&&(t=An(t,this.free.bounds)),this.roomFill.children.length>0){const e=this.roomFill.getLocalBounds();e.width>0&&e.height>0&&(t=An(t,{minX:e.x,minY:e.y,maxX:e.x+e.width,maxY:e.y+e.height}))}return t}getRoomById(t){return this.roomGeometryMap.get(t)}getAllRooms(){return Array.from(this.roomGeometryMap.values())}isWallIntersectsAnyRoom(t){return this.roomFill.isWallIntersectsAnyRoom(t)}isZoneIntersectsAnyRoom(t){return this.roomFill.isZoneIntersectsAnyRoom(t)}areRoomsAdjacent(t){const e=this.appService,i=e.mapConfig.adjacencyThreshold;if(!t||t.length===0)return A.warn("[MapManager] No room IDs provided"),!1;if(t.length===1)return!0;const s=Array.from(new Set(t));if(s.length===1)return!0;const n=e.getApp().mapState;return((n==null?void 0:n.mapType)??"structured")==="raster"?this.areRasterRoomsAdjacentInternal(s,i):this.areStructuredRoomsAdjacentInternal(s,i)}areStructuredRoomsAdjacentInternal(t,e){const i=[];for(const n of t){const o=this.getRoomById(n);if(!o)return A.warn(`[MapManager] Room ${n} not found in map`),!1;if(!o.outlinePoints||o.outlinePoints.length===0)return A.warn(`[MapManager] Room ${n} has no outline points`),!1;i.push({id:n,points:o.outlinePoints})}const s=[];for(let n=0;n<i.length;n++)for(let o=n+1;o<i.length;o++){const a=i[n],h=i[o];Da(a.points,h.points,e)&&s.push([n,o])}return za(i.length,s)}areRasterRoomsAdjacentInternal(t,e){const s=this.appService.getApp().mapState;if(!s)return A.warn("[MapManager] Map state not available"),!1;const n=s.width,o=[];for(const h of t){const l=this.getRasterRoomPixels(h);if(!l)return A.warn(`[MapManager] Room ${h} pixel data not found in raster map`),!1;o.push({id:h,pixels:l})}const a=[];for(let h=0;h<o.length;h++)for(let l=h+1;l<o.length;l++){const c=o[h],d=o[l];Fa(c.pixels,d.pixels,n,e)&&a.push([h,l])}return za(o.length,a)}isPointInAnyRoom(t){const i=this.appService.getApp().mapState;return i?(i.mapType??"structured")==="raster"?this.isPointInAnyRoomRasterInternal(t,i):this.isPointInAnyRoomStructuredInternal(t,i):(A.warn("[MapManager] Map state not available"),null)}isPointInAnyRoomStructuredInternal(t,e){const i=t.x+e.origin.x,s=t.y+e.origin.y,n={x:i,y:s},o=this.getAllRooms();for(const a of o)if(a.outlinePoints&&a.outlinePoints.length>=3&&Rt(n,a.outlinePoints)){const l=this.appService.roomsManager.getRoomPropertyById(a.id);return l||(A.warn(`[MapManager] Room ${a.id} found in geometry but not in RoomManager`),null)}return null}isPointInAnyRoomRasterInternal(t,e){const i=e.width,s=e.height,n=t.x+e.origin.x,o=t.y+e.origin.y,a=Math.round(n),h=Math.round(o);if(a<0||a>=i||h<0||h>=s)return A.warn(`[MapManager] Point (${a}, ${h}) is out of map bounds (${i}x${s})`),null;const l=h*i+a,c=this.getAllRooms();for(const d of c){const u=this.getRasterRoomPixels(d.id);if(u&&u.length>0&&Zl(u,l)){const f=this.appService.roomsManager.getRoomPropertyById(d.id);return f||(A.warn(`[MapManager] Room ${d.id} found in geometry but not in RoomManager`),null)}}return null}clearComponents(){this.obstacle.clear(),this.obstacle.destroy(),this.obstacle=new Na(this.appService),this.free.clear(),this.free.destroy(),this.free=new Va(this.appService),this.carpet.clearCarpet(),this.carpetData=null,this.roomFill.clearRooms(),this.roomFill.isRenderGroup&&(this.roomFill.isRenderGroup=!1),this.roomFill.removeChildren(),this.roomFill.destroy(),this.roomFill=new ja(this.appService)}processRasterData(t){const i=this.appService.roomConfig,s=[],n=[];t.rooms.forEach((d,u)=>{typeof u=="number"?s.push([u,d]):n.push([u,d])}),s.sort(([d],[u])=>d-u);const o=s.map(([d,u])=>({id:d,pixels:u})).sort((d,u)=>i.colors.sortBy==="area"?u.pixels.length-d.pixels.length:d.id-u.id),a=this.assignColorsUsingFourColorAlgorithm(o,i.colors.active.length,"raster"),h=s.map(([d,u])=>{const p=a.get(d)||0;return{roomId:d,pixelIndices:u,activeColor:i.colors.active[p],inactiveColor:i.colors.inactive[p%i.colors.inactive.length],colorIndex:p}}),l=n.map(([d,u])=>{let p=i.colors[d];return d===oe.VERSION0_ROOM&&!p&&(p=i.colors[oe.NO_ROOM_DATA]),{roomId:d,pixelIndices:u,activeColor:p,inactiveColor:p}}),c=[...h,...l];return{obstacles:t.obstacles,carpet:t.carpet,sortedRooms:c,width:t.width,height:t.height,totalPixels:t.totalPixels}}generateRoomGeometryFromRaster(t){const e=this.appService;this.roomGeometryMap.clear(),this.rasterRoomPixelsMap.clear();const{active:i}=e.roomConfig.colors,s=[];t.rooms.forEach((h,l)=>{typeof l=="number"&&s.push(l)}),s.sort((h,l)=>h-l);const n=[];s.forEach(h=>{const l=t.rooms.get(h);this.rasterRoomPixelsMap.set(h,l);let c=1/0,d=1/0,u=-1/0,p=-1/0;for(let m=0;m<l.length;m++){const x=l[m],S=x%t.width,v=Math.floor(x/t.width);c=Math.min(c,S),d=Math.min(d,v),u=Math.max(u,S),p=Math.max(p,v)}const f=uy(l,t.width,c,d,u,p),y=new et(c,d,u-c+1,p-d+1);n.push({id:h,pixelIndices:l,boundingBox:y,centerPoint:f})});const o=[...n].sort((h,l)=>e.roomConfig.colors.sortBy==="area"?l.pixelIndices.length-h.pixelIndices.length:h.id-l.id),a=this.assignColorsUsingFourColorAlgorithm(o,i.length,"raster");n.forEach(h=>{const l=a.get(h.id)||0,c=i[l],d={id:h.id,color:c,colorIndex:l,boundingBox:h.boundingBox,points:[],outlinePoints:[],polyPoints:[],centerPoint:h.centerPoint};this.roomGeometryMap.set(h.id,d)})}getRasterRoomPixels(t){return this.rasterRoomPixelsMap.get(t)}validateColorConfig(){const e=this.appService.roomConfig.colors,i=e.active.length,s=e.inactive.length,n=e.name.length,o=e.propertyTheme.length,a=e.selectionIndicatorBackground.length,h=e.selectionIndicatorIcon.length;i<4&&A.warn(`[FourColor] room.colors.active requires at least 4 colors for the four-color theorem, but got ${i}. Adjacent rooms may have the same color.`),s!==i&&A.warn(`[FourColor] room.colors.inactive length (${s}) does not match room.colors.active length (${i}). Using modulo for color assignment.`),n!==i&&A.warn(`[FourColor] room.colors.name length (${n}) does not match room.colors.active length (${i}). Using modulo for color assignment.`),o!==i&&A.warn(`[FourColor] room.colors.propertyTheme length (${o}) does not match room.colors.active length (${i}). Using modulo for color assignment.`),a!==i&&A.warn(`[FourColor] room.colors.selectionIndicatorBackground length (${a}) does not match room.colors.active length (${i}). Using modulo for color assignment.`),h!==i&&A.warn(`[FourColor] room.colors.selectionIndicatorIcon length (${h}) does not match room.colors.active length (${i}). Using modulo for color assignment.`)}assignColorsUsingFourColorAlgorithm(t,e,i){var d;const s=this.appService,n=((d=s.mapState)==null?void 0:d.id)??null;if(this.fourColorCache&&this.fourColorCache.mapId===n&&this.fourColorCache.colorMap.size===t.length)return A.debug("[FourColor] Using cached color map"),this.fourColorCache.colorMap;const o=s.getApp().config.map.adjacencyThreshold||3,a=s.roomConfig.colors.strategy,h=(u,p)=>{var f;if(i==="structured"){const y=u.outlinePoints,m=p.outlinePoints;return!y||!m?!1:Da(y,m,o)}else{const y=u.pixels,m=p.pixels;if(!y||!m)return!1;const x=((f=s.mapState)==null?void 0:f.width)||0;return Fa(y,m,x,o)}};A.debug(`[FourColor] Starting algorithm for ${t.length} rooms with ${e} colors, strategy: ${a}`);const l=by(t,h,e,a);this.fourColorCache={mapId:n,colorMap:l};const c=new Array(e).fill(0);return l.forEach(u=>{c[u]++}),A.debug("[FourColor] Color distribution:",c),l}destroy(){this.obstacle.destroy(),this.free.destroy(),this.roomFill.destroy(),this.carpet.destroy(),this.chargingStation.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.fourColorCache=null}}class Nx extends L{constructor(e){super({isRenderGroup:!0});g(this,"commonPath");g(this,"chargePath");g(this,"transitionsPath");g(this,"mopPath");g(this,"mopPathTrack");g(this,"mopPathTrackContainer");g(this,"debugPoints");g(this,"pathData",null);g(this,"lastPointCount",0);g(this,"lastDrawnPosition",null);g(this,"isRealTimeDrawing",!1);g(this,"throttledUpdateLineWidth");g(this,"throttledHandleRobotPosition");g(this,"unsubscribeFns",[]);g(this,"handleRobotAnimationComplete",()=>{this.isRealTimeDrawing&&this.stopRealTimeDrawing()});this.appService=e,this.appService.appContainer.addToLayer(hc,this),this.eventMode="none",this.commonPath=new H,this.chargePath=new H,this.transitionsPath=new H,this.mopPathTrackContainer=new L,this.mopPathTrackContainer.filters=[new Gg],this.mopPathTrack=new H,this.mopPath=new H,this.debugPoints=new H,this.mopPathTrackContainer.addChild(this.mopPathTrack),this.addChild(this.mopPathTrackContainer),this.addChild(this.commonPath),this.addChild(this.chargePath),this.addChild(this.transitionsPath),this.addChild(this.mopPath),this.addChild(this.debugPoints),this.visible=e.runtimeSnapshot.showPath,this.commonPath.visible=e.pathConfig.commonPath.visible,this.chargePath.visible=e.pathConfig.chargePath.visible,this.transitionsPath.visible=e.pathConfig.transitionPath.visible,this.mopPathTrackContainer.visible=e.pathConfig.mopPath.trackVisible,this.mopPath.visible=e.pathConfig.mopPath.lineVisible,this.throttledUpdateLineWidth=At(()=>{this.updateLineWidth()},50,{leading:!0,trailing:!0}),this.throttledHandleRobotPosition=At(this.handleRobotPositionUpdate.bind(this),0),this.registerEventListeners()}registerEventListeners(){const{emitter:e}=this.appService;e.on("antiScale",this.throttledUpdateLineWidth),e.on("robotPositionUpdate",this.throttledHandleRobotPosition),e.on("robotAnimationComplete",this.handleRobotAnimationComplete);const i=Bs(this.appService.config.path,()=>{this.pathData&&(this.redrawPaths(this.pathData),this.appService.getApp().renderOnceNextFrame())});this.unsubscribeFns.push(i)}handleRobotPositionUpdate(e){if(!this.isRealTimeDrawing||!this.lastDrawnPosition)return;const i=e.pathType||"common";let s=[];switch(i){case"common":s=[this.commonPath];break;case"charge":s=[this.chargePath];break;case"transitions":s=[this.transitionsPath];break;case"mop":s=[this.mopPathTrack,this.mopPath];break;default:s=[this.commonPath]}s.forEach(n=>{n.moveTo(this.lastDrawnPosition.x,this.lastDrawnPosition.y),n.lineTo(e.x,e.y),n.stroke()}),this.lastDrawnPosition={x:e.x,y:e.y}}updateLineWidth(){const e=this.appService;this.pathData&&e.pathConfig.lineWidthFixed&&this.redrawPaths(this.pathData)}redrawPaths(e){const{pathPoints:i}=e;if(!i||i.length===0)return;this.commonPath.clear(),this.chargePath.clear(),this.transitionsPath.clear(),this.mopPathTrack.clear(),this.mopPath.clear(),this.debugPoints.clear(),this.setupPathStyles(),this.drawPathSegments(i),this.commonPath.stroke(),this.chargePath.stroke(),this.transitionsPath.stroke(),this.mopPathTrack.stroke(),this.mopPath.stroke(),this.appService.getDebuggerMode()&&this.drawDebugPoints(i)}setupPathStyles(){var n;const e=this.appService,i=e.pathConfig,s=o=>i.lineWidthFixed?e.getApp().toFixedSize(o):o;this.commonPath.setStrokeStyle({width:s(i.commonPath.width),color:i.commonPath.color,join:"round",cap:"round"}),this.chargePath.setStrokeStyle({width:s(i.chargePath.width),color:i.chargePath.color,join:"round",cap:"round"}),this.transitionsPath.setStrokeStyle({width:s(i.transitionPath.width),color:i.transitionPath.color,join:"round",cap:"round"}),this.mopPathTrack.setStrokeStyle({width:s(i.mopPath.trackWidth),color:i.mopPath.trackColor,alpha:1,join:"round",cap:"round"}),(n=this.mopPathTrackContainer.filters)!=null&&n[0]&&(this.mopPathTrackContainer.filters[0].alpha=i.mopPath.trackAlpha),this.mopPathTrackContainer.visible=i.mopPath.trackVisible,this.mopPath.setStrokeStyle({width:s(i.mopPath.lineWidth),color:i.mopPath.lineColor,join:"round",cap:"round"}),this.mopPath.visible=i.mopPath.lineVisible}drawPathSegments(e){let i=null,s=null;for(let n=0;n<e.length;n++){const o=e[n],a=o.type||"common";let h;switch(a){case"common":h=[this.commonPath];break;case"charge":h=[this.chargePath];break;case"transitions":h=[this.transitionsPath];break;case"mop":h=[this.mopPathTrack,this.mopPath];break;default:h=[this.commonPath]}n===0||a!==i?h.forEach(c=>c.moveTo(o.x,o.y)):s&&h.length===s.length&&h.every((c,d)=>c===s[d])&&h.forEach(c=>c.lineTo(o.x,o.y)),i=a,s=h}}drawDebugPoints(e){const i={common:16711935,charge:65535,transitions:16776960,mop:65280},s=1;for(const n of e){const o=n.type||"common",a=i[o];this.debugPoints.rect(n.x-s/2,n.y-s/2,s,s),this.debugPoints.fill(a)}}updatePositionByOrigin(e,i){this.position.set(e,i)}drawFull(e){var i;A.debug("[Path] Draw Full Path",e),this.pathData=e,this.redrawPaths(e),this.lastPointCount=((i=e.pathPoints)==null?void 0:i.length)||0}drawIncremental(e){var o,a,h,l;const i=this.appService,s=this.lastPointCount,n=((o=e.pathPoints)==null?void 0:o.slice(s))||[];if(n.length>0)if(this.setupPathStyles(),A.debug("[Path] Draw Incremental Path",n),i.robotConfig.speed>0){if(this.isRealTimeDrawing=!0,s>0&&((a=this.pathData)!=null&&a.pathPoints)){const u=this.pathData.pathPoints[s-1];this.lastDrawnPosition={x:u.x,y:u.y}}}else this.drawNewPathSegments(n,s,e.pathPoints,(h=this.pathData)==null?void 0:h.pathPoints);this.pathData=e,this.lastPointCount=((l=e.pathPoints)==null?void 0:l.length)||0}drawNewPathSegments(e,i,s,n){if(!s||e.length===0)return;let o=null;i>0&&(n&&n[i-1]?o=n[i-1]:s[i-1]&&(o=s[i-1]));let a=null,h=null,l=!1;for(let c=0;c<e.length;c++){const d=e[c],u=d.type||"common";let p;switch(u){case"common":p=[this.commonPath];break;case"charge":p=[this.chargePath];break;case"transitions":p=[this.transitionsPath];break;case"mop":p=[this.mopPathTrack,this.mopPath];break;default:p=[this.commonPath]}u!==a||c===0?(h&&l&&h.forEach(y=>y.stroke()),a=u,h=p,l=!0,o&&c===0&&o.type===u?p.forEach(y=>{y.moveTo(o.x,o.y),y.lineTo(d.x,d.y)}):p.forEach(y=>y.moveTo(d.x,d.y))):p.forEach(y=>y.lineTo(d.x,d.y))}h&&l&&h.forEach(c=>c.stroke())}stopRealTimeDrawing(){this.isRealTimeDrawing=!1,this.lastDrawnPosition=null}clear(){this.commonPath.clear(),this.chargePath.clear(),this.transitionsPath.clear(),this.mopPathTrack.clear(),this.mopPath.clear(),this.debugPoints.clear(),this.pathData=null,this.lastPointCount=0,this.lastDrawnPosition=null,this.isRealTimeDrawing=!1}destroy(e){const{emitter:i}=this.appService;i.off("antiScale",this.throttledUpdateLineWidth),i.off("robotPositionUpdate",this.throttledHandleRobotPosition),i.off("robotAnimationComplete",this.handleRobotAnimationComplete),this.unsubscribeFns.forEach(s=>s()),this.unsubscribeFns=[],this.stopRealTimeDrawing(),super.destroy(e)}}class jx extends Xt{constructor(t){super(t),this.appService=t,this.initializeSprite()}async initializeSprite(){await this.loadTextureAndSetSize("robot",this.appService.robotConfig.icon)}async draw({x:t,y:e,rotation:i}){super.draw({x:t,y:e,rotation:i})}}const it=class it extends xs{constructor(e,i){super(i||[]);g(this,"throttledUpdateScale");g(this,"fixedWidth",0);g(this,"fixedHeight",0);g(this,"isFixedSizeSet",!1);g(this,"sizeFixed",!0);g(this,"baselineScale",1);this.appService=e,this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=At(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(e,i){this.fixedWidth=e,this.fixedHeight=i,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(e){this.sizeFixed=e,this.baselineScale=1,e&&this.isFixedSizeSet?this.applySize():!e&&this.isFixedSizeSet&&this.applySize()}set width(e){this.isFixedSizeSet||this.setFixedSize(e,this.fixedHeight||e)}set height(e){this.isFixedSizeSet||this.setFixedSize(this.fixedWidth||e,e)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.textures||this.textures.length===0||!this.textures[0]||this.textures[0].width===0||this.textures[0].height===0)return;const e=this.textures[0],i=this.fixedWidth/e.width,s=this.fixedHeight/e.height;if(this.sizeFixed){const n=this.appService.currentScale;if(n===0||!isFinite(n)){const h=i,l=s;super.scale.set(h,l);return}const o=i/n,a=s/n;super.scale.set(o,a)}else super.scale.set(i/this.baselineScale,s/this.baselineScale)}updateScale(e){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():e!==0&&super.scale.set(1/e))}static async loadAnimationTextures(e,i,s="sleep_",n=96){try{const a=await(await fetch(e)).json();a.meta&&(a.meta.image=i),await N.load(i);const h=G.from(i),l=new zn(h.source,a);await l.parse();const c=[];for(let d=0;d<n;d++){const u=d.toString().padStart(3,"0"),p=`${s}${u}.png`,f=l.textures[p];f?c.push(f):A.warn(`[EnhancedAnimatedSprite] Frame not found: ${p}`)}return c}catch(o){return A.error("[EnhancedAnimatedSprite] Failed to load textures:",o),[]}}setupAnimation(e){e.sizeFixed!==void 0&&this.setSizeFixed(e.sizeFixed),this.setFixedSize(e.width,e.height),this.animationSpeed=.5,this.loop=!0,A.log(`Animation setup complete, visible=${this.visible}, scale=(${this.scale.x.toFixed(3)}, ${this.scale.y.toFixed(3)})`)}draw(e,i){const{x:s,y:n}=e;i&&!this.visible?this.visible=i():!i&&!this.visible&&(this.visible=!0),this.position.set(s,n)}play(){this.textures&&this.textures.length>0&&(super.play(),it.animatedSprites.add(this),it.startAnimationTicker())}stop(){super.stop(),it.animatedSprites.delete(this),it.updateAnimationTicker()}set textures(e){super.textures=e,this.isFixedSizeSet&&e&&e.length>0&&e[0]&&e[0].width>0&&e[0].height>0&&this.applySize()}get textures(){return super.textures}static startAnimationTicker(){var e;(e=it.animationTicker)!=null&&e.started||(it.animationTicker||(it.animationTicker=new yt,it.animationTicker.maxFPS=24,it.animationTicker.add(()=>{const i=it.animatedSprites.values().next().value;i&&it.updateAnimations(i.appService)})),it.animationTicker.start(),A.log("🎬 [AnimationTicker] Started animation ticker"))}static updateAnimationTicker(){it.animatedSprites.size>0?it.startAnimationTicker():it.stopAnimationTicker()}static stopAnimationTicker(){var e;(e=it.animationTicker)!=null&&e.started&&(A.log("⏸️ [AnimationTicker] Stopped animation ticker"),it.animationTicker.stop())}static updateAnimations(e){if(it.animatedSprites.size===0)return;const i=e.getApp();i.renderer.render(i.stage)}destroy(e){it.animatedSprites.delete(this),it.updateAnimationTicker(),this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(e)}};g(it,"animationTicker",null),g(it,"animatedSprites",new Set);let Cs=it;class zr extends Cs{constructor(e,i){super(e,i);g(this,"unsubscribeFns",[]);g(this,"throttledUpdateOffset");g(this,"fixedOffsetX",0);g(this,"fixedOffsetY",0);this.appService=e,this.throttledUpdateOffset=At(this.updateOffset.bind(this),30,{leading:!0,trailing:!0}),this.initializeAnimation()}static async create(e){const i=e.robotConfig,s=await Cs.loadAnimationTextures(i.sleepAnimation.jsonSrc,i.sleepAnimation.imageSrc,i.sleepAnimation.framePrefix,i.sleepAnimation.frameCount);s.length===0&&(A.warn("No textures loaded for sleep animation"),s.push(G.EMPTY));const n=new zr(e,s);return n.setupAnimation({width:i.sleepAnimation.width,height:i.sleepAnimation.height,sizeFixed:i.sleepAnimation.sizeFixed}),n}initializeAnimation(){this.visible=!1,this.fixedOffsetX=this.appService.robotConfig.sleepAnimation.offsetX,this.fixedOffsetY=this.appService.robotConfig.sleepAnimation.offsetY,this.appService.emitter.on("antiScale",this.throttledUpdateOffset);const e=U(this.appService.runtime,"showRobotSleepAnimation",i=>{A.log(`[runtime] showRobotSleepAnimation: ${i}`),this.updateVisibility()});this.unsubscribeFns.push(e)}shouldShow(){const e=this.appService.runtimeSnapshot.showRobotSleepAnimation,i=this.parent,s=i?i.visible:!1,n=i&&(i.x!==0||i.y!==0);return e&&s&&!!n}updateVisibility(){const e=this.shouldShow();e&&!this.visible?(this.visible=!0,this.textures&&this.textures.length>0&&this.play()):!e&&this.visible?(this.visible=!1,this.stop()):!e&&this.playing&&this.stop()}updateOffset(){}draw(e){const i=this.appService.getApp().toFixedSize(this.appService.robotConfig.sleepAnimation.offsetX),s=this.appService.getApp().toFixedSize(this.appService.robotConfig.sleepAnimation.offsetY),n={...e,x:e.x+i,y:e.y+s};super.draw(n,()=>this.shouldShow()),this.updateVisibility()}onRobotVisibilityChanged(){this.updateVisibility()}set visible(e){const i=super.visible;super.visible=e,e&&!i&&this.textures&&this.textures.length>0?this.play():!e&&i&&this.playing&&this.stop()}get visible(){return super.visible}destroy(e){this.appService.emitter.off("antiScale",this.throttledUpdateOffset),this.unsubscribeFns.forEach(i=>i()),this.unsubscribeFns=[],this.stop(),super.destroy(e)}}class Yx extends H{constructor(e){super();g(this,"currentPosition",null);g(this,"animationStartTime",0);g(this,"isAnimating",!1);g(this,"handleScaleChange",()=>{this.redraw()});g(this,"updateAnimation",()=>{if(!this.currentPosition||!this.isAnimating||!this.visible)return;const e=this.appService,i=e.robotConfig.pulseCircle,n=(Date.now()-this.animationStartTime)%i.duration/i.duration,{minScale:o,maxScale:a,minAlpha:h,maxAlpha:l}=i,c=o+(a-o)*(Math.sin(n*Math.PI*2)*.5+.5),d=l-(l-h)*(c-o)/(a-o);super.clear();const{size:u,color:p,strokeWidth:f,strokeColor:y,sizeFixed:m}=i,S=(m?e.getApp().toFixedSize(u/2):u/2)*c,v=e.getApp().toFixedSize(f);this.setFillStyle({color:p,alpha:d}),this.circle(this.currentPosition.x,this.currentPosition.y,S).fill().stroke({color:y,width:v,alpha:d,cap:"round",join:"round"})});this.appService=e,this.setupAntiScaleListener()}setupAntiScaleListener(){this.appService.emitter.on("antiScale",this.handleScaleChange)}draw(e){this.currentPosition=e,this.isAnimating||this.startAnimation(),this.redraw()}startAnimation(){const e=this.appService;this.isAnimating||(this.isAnimating=!0,this.animationStartTime=Date.now(),e.getApp().ticker.add(this.updateAnimation,this),e.getApp().requestRender("pulse-circle-animation",!0))}stopAnimation(){const e=this.appService;this.isAnimating&&(this.isAnimating=!1,e.getApp().ticker.remove(this.updateAnimation,this),e.getApp().stopRender("pulse-circle-animation"))}redraw(){this.currentPosition&&this.isAnimating&&this.updateAnimation()}clearCircle(){super.clear()}remove(){this.stopAnimation(),this.clearCircle(),this.currentPosition=null}destroy(){this.stopAnimation(),this.appService.emitter.off("antiScale",this.handleScaleChange),super.destroy()}}class Xx extends L{constructor(e){super();g(this,"robot");g(this,"ring");g(this,"pulseCircle");g(this,"sleepAnimation",null);g(this,"unsubscribeFns",[]);g(this,"clickHandler");g(this,"targetPosition",null);g(this,"targetRotation",null);g(this,"isMoving",!1);g(this,"pathQueue",[]);g(this,"lastPosition",null);g(this,"currentPathType");g(this,"lastUpdateTime",0);g(this,"isCleared",!1);this.appService=e,e.appContainer.addToLayer(dc,this),this.visible=e.runtime.showRobot,this.ring=new uc(this.appService,{config:this.appService.robotConfig.ring}),this.ring.visible=this.appService.runtime.showRobotRing,this.addChild(this.ring),this.pulseCircle=new Yx(this.appService),this.pulseCircle.visible=e.runtime.showRobotPulseCircle,this.addChild(this.pulseCircle),this.robot=new jx(this.appService),this.addChild(this.robot),this.lastUpdateTime=Date.now(),this.appService.robotConfig.speed>0&&this.appService.getApp().ticker.add(this.update,this);const s=U(this.appService.runtime,"showRobotRing",o=>{A.log(`[runtime] showRobotRing: ${o}`),this.ring.visible=o});this.unsubscribeFns.push(s);const n=U(this.appService.runtime,"showRobotPulseCircle",o=>{A.log(`[runtime] showRobotPulseCircle: ${o}`),o?(this.lastPosition&&this.pulseCircle.draw(this.lastPosition),this.pulseCircle.visible=!0):(this.pulseCircle.remove(),this.pulseCircle.visible=!1)});this.unsubscribeFns.push(n),this.initClickInteraction()}async initializeSleepAnimation(){try{this.sleepAnimation=await zr.create(this.appService),this.addChild(this.sleepAnimation),A.log("Sleep animation added to robot")}catch(e){A.error("Failed to initialize sleep animation:",e)}}updatePositionByOrigin(e,i){this.position.set(e,i)}async draw({x:e,y:i,rotation:s}){this.isCleared&&(this.robot.visible=!0,this.ring.visible=this.appService.runtime.showRobotRing,this.pulseCircle.visible=this.appService.runtime.showRobotPulseCircle,this.sleepAnimation&&(this.sleepAnimation.visible=!0),this.isCleared=!1),this.ring.draw({x:e,y:i}),this.pulseCircle.draw({x:e,y:i}),await this.robot.draw({x:e,y:i,rotation:s}),this.sleepAnimation||await this.initializeSleepAnimation(),this.sleepAnimation.draw({x:e,y:i}),this.lastPosition={x:e,y:i},this.sleepAnimation.draw({x:e,y:i}),this.lastPosition={x:e,y:i}}initClickInteraction(){const{enableRobotClick:e}=this.appService.interactionConfig;e?this.clickHandler||(this.clickHandler=new vt(this.robot,{onClick:()=>{var s;const i=this.getCurrentPosition();i&&((s=this.appService.events)!=null&&s.onClickRobot)&&this.appService.events.onClickRobot({...i,rotation:this.robot.rotation})}})):this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=void 0,this.robot.interactive=!1,this.robot.eventMode="none")}getCurrentPosition(){return this.lastPosition?this.appService.fixPrecision({...this.lastPosition}):null}moveTo(e){this.pathQueue.push(e),this.isMoving||this.processNextPathPoint()}batchProcessQueue(e=!1){if(this.pathQueue.length===0)return;const i=[...this.pathQueue];if(e){const s=i[i.length-1];this.robot.position.set(s.x,s.y),s.rotation!==void 0&&(this.robot.rotation=s.rotation),this.lastPosition={x:s.x,y:s.y},this.pathQueue=[],this.isMoving=!1,this.targetPosition=null}else this.pathQueue.splice(0,i.length),this.pathQueue.length===0?(this.isMoving=!1,this.targetPosition=null):this.processNextPathPoint()}processNextPathPoint(){if(this.pathQueue.length===0){this.isMoving=!1,this.currentPathType=void 0,this.stopRobotAnimation(),this.appService.emitter.emit("robotAnimationComplete");return}this.isMoving||this.startRobotAnimation(),this.isMoving=!0;const e=this.pathQueue[0];this.targetPosition={x:e.x,y:e.y},this.currentPathType=e.type,e.rotation!==void 0&&(this.targetRotation=e.rotation),this.lastPosition||(this.lastPosition={x:this.robot.x,y:this.robot.y})}update(){const e=Date.now();if(this.lastUpdateTime===0){this.lastUpdateTime=e;return}let i=e-this.lastUpdateTime;if(this.lastUpdateTime=e,i>500&&(i=16.67),this.targetPosition){const s=this.targetPosition.x-this.robot.x,n=this.targetPosition.y-this.robot.y,o=Math.sqrt(s*s+n*n),a=this.appService.robotConfig.speed,h=this.appService.getApp().metersToPixels(a);if(a===0){this.robot.position.set(this.targetPosition.x,this.targetPosition.y),this.targetRotation!==null&&(this.robot.rotation=this.targetRotation,this.targetRotation=null),this.targetPosition=null,this.lastPosition={x:this.robot.x,y:this.robot.y},this.pathQueue.shift(),this.processNextPathPoint();return}const l=h*(i/1e3);o<l?(this.robot.position.set(this.targetPosition.x,this.targetPosition.y),this.targetRotation!==null&&(this.robot.rotation=this.targetRotation,this.targetRotation=null),this.targetPosition=null,this.lastPosition={x:this.robot.x,y:this.robot.y},this.pathQueue.shift(),this.processNextPathPoint()):(this.robot.x+=s*(l/o),this.robot.y+=n*(l/o),this.appService.emitter.emit("robotPositionUpdate",{x:this.robot.x,y:this.robot.y,pathType:this.currentPathType}),this.lastPosition={x:this.robot.x,y:this.robot.y})}}startRobotAnimation(){this.appService.getApp().requestRender("robot-animation",!0)}set visible(e){super.visible=e,this.sleepAnimation&&this.sleepAnimation.onRobotVisibilityChanged()}get visible(){return super.visible}stopRobotAnimation(){this.appService.getApp().stopRender("robot-animation")}remove(){this.pathQueue=[],this.isMoving=!1,this.targetPosition=null,this.stopRobotAnimation()}clear(){this.remove(),this.robot.visible=!1,this.ring.visible=!1,this.pulseCircle.remove(),this.sleepAnimation&&(this.sleepAnimation.visible=!1),this.lastPosition=null,this.isCleared=!0}destroy(e){this.unsubscribeFns.forEach(s=>s()),this.unsubscribeFns=[],this.stopRobotAnimation(),this.appService.robotConfig.speed>0&&this.appService.getApp().ticker.remove(this.update,this),this.ring.destroy(),this.pulseCircle.destroy(),this.clickHandler&&this.clickHandler.destroy(),super.destroy(e)}}class Zx{constructor(t){g(this,"path");g(this,"robot");g(this,"unsubscribeFns",[]);g(this,"lastDrawnPathData",null);this.appService=t,this.path=new Nx(this.appService),this.robot=new Xx(this.appService);const e=U(t.runtime,"showPath",s=>{A.log(`[runtime] showPath: ${s}`),this.path.visible=s}),i=U(t.runtime,"showRobot",s=>{A.log(`[runtime] showRobot: ${s}`),this.robot.visible=s});this.unsubscribeFns.push(e,i)}draw(t){var s,n,o;const e=(s=t.pathHeader)==null?void 0:s.pathId,i=(o=(n=this.lastDrawnPathData)==null?void 0:n.pathHeader)==null?void 0:o.pathId;this.lastDrawnPathData&&e!==i&&(this.path.clear(),this.lastDrawnPathData=null),this.shouldUseIncrementalDraw(t)?this.incrementalDraw(t):this.fullDraw(t),this.lastDrawnPathData=t}shouldUseIncrementalDraw(t){var h,l,c,d;if(!this.lastDrawnPathData)return!1;const e=(h=t.pathHeader)==null?void 0:h.pathId,i=(l=this.lastDrawnPathData.pathHeader)==null?void 0:l.pathId;if(e!==i)return!1;const s=((c=t.pathPoints)==null?void 0:c.length)||0,n=((d=this.lastDrawnPathData.pathPoints)==null?void 0:d.length)||0,o=s-n,a=this.appService.pathConfig.incrementalThreshold;return!(o<=0||o>a)}fullDraw(t){if(this.path.stopRealTimeDrawing(),this.path.drawFull(t),t.pathPoints&&t.pathPoints.length>0){const e=t.pathPoints[t.pathPoints.length-1];this.moveRobotToPoint(e,t.pathHeader.direction,!1)}else this.robot.clear()}convertToRobotPoint(t,e){const i=e+this.appService.robotConfig.rotationCorrection;return{x:t.x,y:t.y,rotation:i*Math.PI/180,type:t.type}}moveRobotToPoint(t,e,i=!0){const s=this.convertToRobotPoint(t,e);i?this.robot.moveTo(s):(this.robot.remove(),this.robot.draw(s))}incrementalDraw(t){var o;if(!this.lastDrawnPathData||!t.pathPoints)return;this.path.drawIncremental(t);const e=((o=this.lastDrawnPathData.pathPoints)==null?void 0:o.length)||0,i=t.pathPoints.slice(e);if(i.length===0)return;if(this.appService.robotConfig.speed>0)i.forEach(a=>{this.moveRobotToPoint(a,t.pathHeader.direction,!0)});else{const a=i[i.length-1];this.moveRobotToPoint(a,t.pathHeader.direction,!1)}}batchProcessRobotQueue(t=!1){this.robot.batchProcessQueue(t)}updatePositionByOrigin(t,e){this.path.updatePositionByOrigin(t,e),this.robot.updatePositionByOrigin(t,e)}clear(){this.lastDrawnPathData=null,this.path.clear(),this.robot.clear()}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.path.destroy(),this.robot.destroy()}}class qx extends L{constructor(e){super();g(this,"colorGradients",[]);g(this,"cellSize",2);this.appService=e,this.appService.appContainer.addToLayer(ac,this);const i=this.appService.heatMapConfig;this.colorGradients=i.colorGradients.map(s=>new rt(s).toArray().slice(0,3).join(",")),this.cellSize=i.cellSize}draw(e,i=.8){this.removeChildren();const{useGradient:s}=this.appService.heatMapConfig,n=s?this.gradientDrawing(e):this.gridDrawing(e);this.croppingHeatmap(n),n.alpha=i,this.addChild(n)}croppingHeatmap(e){var a;const i=((a=this.appService.mapState)==null?void 0:a.origin)||{x:0,y:0},n=this.appService.mapManager.roomFill.children.filter(h=>h instanceof H),o=new H;for(const h of n)o.context.instructions.push(...h.context.instructions);o.context.dirty=!0,o.position.set(-i.x,-i.y),e.setMask({mask:o}),this.addChild(o)}gridDrawing(e){const i=[],s=[],n=e.length,o=e[0].length;for(let c=0;c<n;c++)for(let d=0;d<o;d++){const u=e[c][d],p=this.cellSize/2,f=u.x-p,y=u.y-p,m=u.x+p,x=u.y+p;i.push(f,y),s.push(u.signal),i.push(m,y),s.push(u.signal),i.push(m,x),s.push(u.signal),i.push(f,y),s.push(u.signal),i.push(m,x),s.push(u.signal),i.push(f,x),s.push(u.signal)}const a=new Di({attributes:{aPosition:new Float32Array(i),aSignal:new Float32Array(s)}}),h=new Ie({glProgram:new Je({vertex:`
502
+ `)}const Aa={willReadFrequently:!0},se=class O{static get experimentalLetterSpacingSupported(){let t=O._experimentalLetterSpacingSupported;if(t===void 0){const e=j.get().getCanvasRenderingContext2D().prototype;t=O._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,s,n,o,a,h,l,c){this.text=t,this.style=e,this.width=i,this.height=s,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=h,this.fontProperties=l,c&&(this.runsByLine=c.runsByLine,this.lineAscents=c.lineAscents,this.lineDescents=c.lineDescents,this.lineHeights=c.lineHeights,this.hasDropShadow=c.hasDropShadow)}static measureText(t=" ",e,i=O._canvas,s=e.wordWrap){var P;const n=`${t}-${e.styleKey}-wordWrap-${s}`;if(O._measurementCache.has(n))return O._measurementCache.get(n);if(Dl(e)&&Fl(t)){const w=ym(t,e,s,O._context,O._measureText,O.measureFont,O.canBreakChars,O.wordWrapSplit),C=new O(t,e,w.width,w.height,w.lines,w.lineWidths,w.lineHeight,w.maxLineWidth,w.fontProperties,{runsByLine:w.runsByLine,lineAscents:w.lineAscents,lineDescents:w.lineDescents,lineHeights:w.lineHeights,hasDropShadow:w.hasDropShadow});return O._measurementCache.set(n,C),C}const a=e._fontString,h=O.measureFont(a);h.fontSize===0&&(h.fontSize=e.fontSize,h.ascent=e.fontSize,h.descent=0);const l=O._context;l.font=a;const d=(s?O._wordWrap(t,e,i):t).split(gm),u=new Array(d.length);let p=0;for(let w=0;w<d.length;w++){const C=O._measureText(d[w],e.letterSpacing,l);u[w]=C,p=Math.max(p,C)}const f=((P=e._stroke)==null?void 0:P.width)??0,y=e.lineHeight||h.fontSize,m=O._getAlignWidth(p,e,s),x=O._adjustWidthForStyle(m,e),S=Math.max(y,h.fontSize+f)+(d.length-1)*(y+e.leading),v=O._adjustHeightForStyle(S,e),b=new O(t,e,x,v,d,u,y+e.leading,p,h);return O._measurementCache.set(n,b),b}static _adjustWidthForStyle(t,e){var n;const i=((n=e._stroke)==null?void 0:n.width)||0;let s=t+i;return e.dropShadow&&(s+=e.dropShadow.distance),s}static _adjustHeightForStyle(t,e){let i=t;return e.dropShadow&&(i+=e.dropShadow.distance),i}static _getAlignWidth(t,e,i){return i&&e.align!=="left"&&e.align!=="justify"?Math.max(t,e.wordWrapWidth):t}static _measureText(t,e,i){let s=!1;O.experimentalLetterSpacingSupported&&(O.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,s=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));const n=i.measureText(t);let o=n.width;const a=-(n.actualBoundingBoxLeft??0);let l=(n.actualBoundingBoxRight??0)-a;if(o>0)if(s)o-=e,l-=e;else{const c=(O.graphemeSegmenter(t).length-1)*e;o+=c,l+=c}return Math.max(o,l)}static _wordWrap(t,e,i=O._canvas){return bm(t,e,i,O._measureText,O.canBreakWords,O.canBreakChars,O.wordWrapSplit)}static isBreakingSpace(t,e){return Lt(t)}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,s,n){return!0}static wordWrapSplit(t){return O.graphemeSegmenter(t)}static measureFont(t){if(O._fonts[t])return O._fonts[t];const e=O._context;e.font=t;const i=e.measureText(O.METRICS_STRING+O.BASELINE_SYMBOL),s=i.actualBoundingBoxAscent??0,n=i.actualBoundingBoxDescent??0,o={ascent:s,descent:n,fontSize:s+n};return O._fonts[t]=o,o}static clearMetrics(t=""){t?delete O._fonts[t]:O._fonts={}}static get _canvas(){if(!O.__canvas){let t;try{const e=new OffscreenCanvas(0,0),i=e.getContext("2d",Aa);if(i!=null&&i.measureText)return O.__canvas=e,e;t=j.get().createCanvas()}catch{t=j.get().createCanvas()}t.width=t.height=10,O.__canvas=t}return O.__canvas}static get _context(){return O.__context||(O.__context=O._canvas.getContext("2d",Aa)),O.__context}};se.METRICS_STRING="|ÉqÅ";se.BASELINE_SYMBOL="M";se.BASELINE_MULTIPLIER=1.4;se.HEIGHT_MULTIPLIER=2;se.graphemeSegmenter=r=>[...r];se.experimentalLetterSpacing=!1;se._fonts={};se._measurementCache=am(1e3);let ne=se;const wm=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Qn(r){const t=typeof r.fontSize=="number"?`${r.fontSize}px`:r.fontSize;let e=r.fontFamily;Array.isArray(r.fontFamily)||(e=r.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let s=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!wm.includes(s)&&(s=`"${s}"`),e[i]=s}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} ${e.join(",")}`}const Ca=1e5;function os(r,t,e,i=0,s=0,n=0){if(r.texture===G.WHITE&&!r.fill)return rt.shared.setValue(r.color).setAlpha(r.alpha??1).toHexa();if(r.fill){if(r.fill instanceof Rs){const o=r.fill,a=t.createPattern(o.texture.source.resource,"repeat"),h=o.transform.copyTo(W.shared);return h.scale(o.texture.source.pixelWidth,o.texture.source.pixelHeight),a.setTransform(h),a}else if(r.fill instanceof Ot){const o=r.fill,a=o.type==="linear",h=o.textureSpace==="local";let l=1,c=1;h&&e&&(l=e.width+i,c=e.height+i);let d,u=!1;if(a){const{start:p,end:f}=o;d=t.createLinearGradient(p.x*l+s,p.y*c+n,f.x*l+s,f.y*c+n),u=Math.abs(f.x-p.x)<Math.abs((f.y-p.y)*.1)}else{const{center:p,innerRadius:f,outerCenter:y,outerRadius:m}=o;d=t.createRadialGradient(p.x*l+s,p.y*c+n,f*l,y.x*l+s,y.y*c+n,m*l)}if(u&&h&&e){const p=e.lineHeight/c;for(let f=0;f<e.lines.length;f++){const y=(f*e.lineHeight+i/2)/c;o.colorStops.forEach(m=>{let x=y+m.offset*p;x=Math.max(0,Math.min(1,x)),d.addColorStop(Math.floor(x*Ca)/Ca,rt.shared.setValue(m.color).toHex())})}}else o.colorStops.forEach(p=>{d.addColorStop(p.offset,rt.shared.setValue(p.color).toHex())});return d}}else{const o=t.createPattern(r.texture.source.resource,"repeat"),a=r.matrix.copyTo(W.shared);return a.scale(r.texture.source.pixelWidth,r.texture.source.pixelHeight),o.setTransform(a),o}return nt("FillStyle not recognised",r),"red"}const Pa=new et;class Am{getCanvasAndContext(t){const{text:e,style:i,resolution:s=1}=t,n=i._getFinalPadding(),o=ne.measureText(e||" ",i),a=Math.ceil(Math.ceil(Math.max(1,o.width)+n*2)*s),h=Math.ceil(Math.ceil(Math.max(1,o.height)+n*2)*s),l=$n.getOptimalCanvasAndContext(a,h);this._renderTextToCanvas(i,n,s,l,o);const c=i.trim?rm({canvas:l.canvas,width:a,height:h,resolution:1,output:Pa}):Pa.set(0,0,a,h);return{canvasAndContext:l,frame:c}}returnCanvasAndContext(t){$n.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,i,s,n){var w,C,k;if(n.runsByLine&&n.runsByLine.length>0){this._renderTaggedTextToCanvas(n,t,e,i,s);return}const{canvas:o,context:a}=s,h=Qn(t),l=n.lines,c=n.lineHeight,d=n.lineWidths,u=n.maxLineWidth,p=n.fontProperties,f=o.height;if(a.resetTransform(),a.scale(i,i),a.textBaseline=t.textBaseline,(w=t._stroke)!=null&&w.width){const M=t._stroke;a.lineWidth=M.width,a.miterLimit=M.miterLimit,a.lineJoin=M.join,a.lineCap=M.cap}a.font=h;let y,m;const x=t.dropShadow?2:1,S=t.wordWrap?t.wordWrapWidth:u,b=(((C=t._stroke)==null?void 0:C.width)??0)/2;let P=(c-p.fontSize)/2;c-p.fontSize<0&&(P=0);for(let M=0;M<x;++M){const T=t.dropShadow&&M===0,_=T?Math.ceil(Math.max(1,f)+e*2):0,I=_*i;if(T)this._setupDropShadow(a,t,i,I);else{const B=t._gradientBounds,F=t._gradientOffset;if(B){const Z={width:B.width,height:B.height,lineHeight:B.height,lines:n.lines};this._setFillAndStrokeStyles(a,t,Z,e,b,(F==null?void 0:F.x)??0,(F==null?void 0:F.y)??0)}else F?this._setFillAndStrokeStyles(a,t,n,e,b,F.x,F.y):this._setFillAndStrokeStyles(a,t,n,e,b);a.shadowColor="black"}for(let B=0;B<l.length;B++)y=b,m=b+B*c+p.ascent+P,y+=this._getAlignmentOffset(d[B],S,t.align),(k=t._stroke)!=null&&k.width&&this._drawLetterSpacing(l[B],t,s,y+e,m+e-_,!0),t._fill!==void 0&&this._drawLetterSpacing(l[B],t,s,y+e,m+e-_)}}_renderTaggedTextToCanvas(t,e,i,s,n){var b,P;const{canvas:o,context:a}=n,{runsByLine:h,lineWidths:l,maxLineWidth:c,lineAscents:d,lineHeights:u,hasDropShadow:p}=t,f=o.height;a.resetTransform(),a.scale(s,s),a.textBaseline=e.textBaseline;const y=p?2:1,m=e.wordWrap?e.wordWrapWidth:c,S=(((b=e._stroke)==null?void 0:b.width)??0)/2,v=[];for(let w=0;w<h.length;w++){const C=h[w],k=[];for(const M of C){const T=Qn(M.style);a.font=T,k.push({width:ne._measureText(M.text,M.style.letterSpacing,a),font:T})}v.push(k)}for(let w=0;w<y;++w){const C=p&&w===0,k=C?Math.ceil(Math.max(1,f)+i*2):0,M=k*s;C||(a.shadowColor="black");let T=S;for(let _=0;_<h.length;_++){const I=h[_],B=l[_],F=d[_],Z=u[_],R=v[_];let D=S;D+=this._getAlignmentOffset(B,m,e.align);const ot=T+F;let z=D+i;for(let K=0;K<I.length;K++){const Y=I[K],{width:ht,font:bt}=R[K];if(a.font=bt,a.textBaseline=Y.style.textBaseline,(P=Y.style._stroke)!=null&&P.width){const wt=Y.style._stroke;if(a.lineWidth=wt.width,a.miterLimit=wt.miterLimit,a.lineJoin=wt.join,a.lineCap=wt.cap,C)if(Y.style.dropShadow)this._setupDropShadow(a,Y.style,s,M);else{z+=ht;continue}else{const kt=ne.measureFont(bt),Gt=Y.style.lineHeight||kt.fontSize,Hi={width:ht,height:Gt,lineHeight:Gt,lines:[Y.text]};a.strokeStyle=os(wt,a,Hi,i*2,z-i,T)}this._drawLetterSpacing(Y.text,Y.style,n,z,ot+i-k,!0)}z+=ht}z=D+i;for(let K=0;K<I.length;K++){const Y=I[K],{width:ht,font:bt}=R[K];if(a.font=bt,a.textBaseline=Y.style.textBaseline,Y.style._fill!==void 0){if(C)if(Y.style.dropShadow)this._setupDropShadow(a,Y.style,s,M);else{z+=ht;continue}else{const wt=ne.measureFont(bt),kt=Y.style.lineHeight||wt.fontSize,Gt={width:ht,height:kt,lineHeight:kt,lines:[Y.text]};a.fillStyle=os(Y.style._fill,a,Gt,i*2,z-i,T)}this._drawLetterSpacing(Y.text,Y.style,n,z,ot+i-k,!1)}z+=ht}T+=Z}}}_setFillAndStrokeStyles(t,e,i,s,n,o=0,a=0){var h;if(t.fillStyle=e._fill?os(e._fill,t,i,s*2,o,a):null,(h=e._stroke)!=null&&h.width){const l=n+s*2;t.strokeStyle=os(e._stroke,t,i,l,o,a)}}_setupDropShadow(t,e,i,s){t.fillStyle="black",t.strokeStyle="black";const n=e.dropShadow,o=n.color,a=n.alpha;t.shadowColor=rt.shared.setValue(o).setAlpha(a).toRgbaString();const h=n.blur*i,l=n.distance*i;t.shadowBlur=h,t.shadowOffsetX=Math.cos(n.angle)*l,t.shadowOffsetY=Math.sin(n.angle)*l+s}_getAlignmentOffset(t,e,i){return i==="right"?e-t:i==="center"?(e-t)/2:0}_drawLetterSpacing(t,e,i,s,n,o=!1){const{context:a}=i,h=e.letterSpacing;let l=!1;if(ne.experimentalLetterSpacingSupported&&(ne.experimentalLetterSpacing?(a.letterSpacing=`${h}px`,a.textLetterSpacing=`${h}px`,l=!0):(a.letterSpacing="0px",a.textLetterSpacing="0px")),h===0||l){o?a.strokeText(t,s,n):a.fillText(t,s,n);return}let c=s;const d=ne.graphemeSegmenter(t);let u=a.measureText(t).width,p=0;for(let f=0;f<d.length;++f){const y=d[f];o?a.strokeText(y,c,n):a.fillText(y,c,n);let m="";for(let x=f+1;x<d.length;++x)m+=d[x];p=a.measureText(m).width,c+=u-p+h,u=p}}}const Ve=new Am,Tr=class Pe extends Yt{constructor(t={}){super(),this.uid=dt("textStyle"),this._tick=0,this._cachedFontString=null,Cm(t),t instanceof Pe&&(t=t._toObject());const s={...Pe.defaultTextStyle,...t};for(const n in s){const o=n;this[o]=s[n]}this._tagStyles=t.tagStyles??void 0,this.update(),this._tick=0}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.update())}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(t!==null&&typeof t=="object"?this._dropShadow=this._createProxy({...Pe.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...Pe.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.update())}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.update())}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.update())}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.update())}get filters(){return this._filters}set filters(t){this._filters!==t&&(this._filters=Object.freeze(t),this.update())}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.update())}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy({...mt.defaultFillStyle,...t},()=>{this._fill=Me({...this._originalFill},mt.defaultFillStyle)})),this._fill=Me(t===0?"black":t,mt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...mt.defaultStrokeStyle,...t},()=>{this._stroke=ys({...this._originalStroke},mt.defaultStrokeStyle)})),this._stroke=ys(t,mt.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(t){this._tagStyles!==t&&(this._tagStyles=t??void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){const t=Pe.defaultTextStyle;for(const e in t)this[e]=t[e]}assign(t){for(const e in t){const i=e;this[i]=t[e]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=Qn(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill?{...this._fill}:void 0,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke?{...this._stroke}:void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?{...this._tagStyles}:void 0}}clone(){return new Pe(this._toObject())}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=!1){var i,s,n,o;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const a=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(i=this._fill)!=null&&i.texture&&this._fill.texture.destroy(a),(s=this._originalFill)!=null&&s.texture&&this._originalFill.texture.destroy(a),(n=this._stroke)!=null&&n.texture&&this._stroke.texture.destroy(a),(o=this._originalStroke)!=null&&o.texture&&this._originalStroke.texture.destroy(a)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(i,s,n)=>(i[s]===n||(i[s]=n,e==null||e(s,n),this.update()),!0)})}_isFillStyle(t){return(t??null)!==null&&!(rt.isColorLike(t)||t instanceof Ot||t instanceof Rs)}};Tr.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Tr.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let de=Tr;function Cm(r){const t=r;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=de.defaultDropShadow;r.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){V(J,"strokeThickness is now a part of stroke");const e=t.stroke;let i={};if(rt.isColorLike(e))i.color=e;else if(e instanceof Ot||e instanceof Rs)i.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))i=e;else throw new Error("Invalid stroke value.");r.stroke={...i,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){if(V(J,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(t.fill)||t.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");t.fill.length!==t.fillGradientStops.length&&nt("The number of fill colors must match the number of fill gradient stops.");const e=new Ot({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),i=t.fillGradientStops.slice(),s=t.fill.map(n=>rt.shared.setValue(n).toNumber());i.forEach((n,o)=>{e.addColorStop(n,s[o])}),r.fill={fill:e}}}function Pm(r,t){const{texture:e,bounds:i}=r,s=t._style._getFinalPadding();lh(i,t._anchor,e);const n=t._anchor._x*s*2,o=t._anchor._y*s*2;i.minX-=s-n,i.minY-=s-o,i.maxX-=s-n,i.maxY-=s-o}class Mm{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}class _m extends Mm{}class Wl{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new ri({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e!=null&&e._autoResolution&&e.onViewUpdate()}}validateRenderable(t){const e=this._getGpuText(t),i=t.styleKey;return e.currentKey!==i?!0:t._didTextUpdate}addRenderable(t,e){const i=this._getGpuText(t);if(t._didTextUpdate){const s=t._autoResolution?this._renderer.resolution:t.resolution;(i.currentKey!==t.styleKey||t._resolution!==s)&&this._updateGpuText(t),t._didTextUpdate=!1,Pm(i,t)}this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t.styleKey}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new _m;return e.currentKey="--",e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,this._managedTexts.add(t),e}onTextUnload(t){const e=t._gpuData[this._renderer.uid];if(!e)return;const{canvasText:i}=this._renderer;i.getReferenceCount(e.currentKey)>0?i.decreaseReferenceCount(e.currentKey):e.texture&&i.returnTexture(e.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}Wl.extension={type:[E.WebGLPipes,E.WebGPUPipes,E.CanvasPipes],name:"text"};const Tm=new It;function km(r,t,e,i){const s=Tm;s.minX=0,s.minY=0,s.maxX=r.width/i|0,s.maxY=r.height/i|0;const n=Ps.getOptimalTexture(s.width,s.height,i,!1);return n.source.uploadMethodId="image",n.source.resource=r,n.source.alphaMode="premultiply-alpha-on-upload",n.frame.width=t/i,n.frame.height=e/i,n.source.emit("update",n.source),n.updateUvs(),n}class Ul{constructor(t,e){this._activeTextures={},this._renderer=t,this._retainCanvasContext=e}getTexture(t,e,i,s){typeof t=="string"&&(V("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:i,resolution:e}),t.style instanceof de||(t.style=new de(t.style)),t.textureStyle instanceof Ke||(t.textureStyle=new Ke(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:n,style:o,textureStyle:a}=t,h=t.resolution??this._renderer.resolution,{frame:l,canvasAndContext:c}=Ve.getCanvasAndContext({text:n,style:o,resolution:h}),d=km(c.canvas,l.width,l.height,h);if(a&&(d.source.style=a),o.trim&&(l.pad(o.padding),d.frame.copyFrom(l),d.frame.scale(1/h),d.updateUvs()),o.filters){const u=this._applyFilters(d,o.filters);return this.returnTexture(d),Ve.returnCanvasAndContext(c),u}return this._renderer.texture.initSource(d._source),this._retainCanvasContext||Ve.returnCanvasAndContext(c),d}returnTexture(t){const e=t.source,i=e.resource;if(this._retainCanvasContext&&(i!=null&&i.getContext)){const s=i.getContext("2d");s&&Ve.returnCanvasAndContext({canvas:i,context:s})}e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",Ps.returnTexture(t,!0)}renderTextToCanvas(){V("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const i=this.getTexture({text:t.text,style:t.style,resolution:t._resolution,textureStyle:t.textureStyle});return this._activeTextures[e]={texture:i,usageCount:1},i}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(this.returnTexture(e.texture),this._activeTextures[t]=null))}getReferenceCount(t){var e;return((e=this._activeTextures[t])==null?void 0:e.usageCount)??0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const i=this._renderer.renderTarget.renderTarget,s=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(i,!1),s}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}class Hl extends Ul{constructor(t){super(t,!0)}}Hl.extension={type:[E.CanvasSystem],name:"canvasText"};class Vl extends Ul{constructor(t){super(t,!1)}}Vl.extension={type:[E.WebGLSystem,E.WebGPUSystem],name:"canvasText"};$.add(Hl);$.add(Vl);$.add(Wl);class Es extends em{constructor(...t){const e=im(t,"Text");super(e,de),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof Ke?e.textureStyle:new Ke(e.textureStyle))}updateBounds(){const t=this._bounds,e=this._anchor;let i=0,s=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=Ve.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Ve.returnCanvasAndContext(o),i=n.width,s=n.height}else{const n=ne.measureText(this._text,this._style);i=n.width,s=n.height}t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*s,t.maxY=t.minY+s}}class kr extends G{static create(t){const{dynamic:e,...i}=t;return new kr({source:new Bt(i),dynamic:e??!1})}resize(t,e,i){return this.source.resize(t,e,i),this}}$.add(Jc,td);function Rm(r,t){var e=-1,i=r.length;for(t||(t=Array(i));++e<i;)t[e]=r[e];return t}function Em(r,t,e,i){var s=!e;e||(e={});for(var n=-1,o=t.length;++n<o;){var a=t[n],h=void 0;h===void 0&&(h=r[a]),s?Ka(e,a,h):$a(e,a,h)}return e}function Im(r){return Pc(function(t,e){var i=-1,s=e.length,n=s>1?e[s-1]:void 0,o=s>2?e[2]:void 0;for(n=r.length>3&&typeof n=="function"?(s--,n):void 0,o&&Mc(e[0],e[1],o)&&(n=s<3?void 0:n,s=1),t=Object(t);++i<s;){var a=e[i];a&&r(t,a,i,n)}return t})}function Bm(r){var t=[];if(r!=null)for(var e in Object(r))t.push(e);return t}var Dm=Object.prototype,Fm=Dm.hasOwnProperty;function zm(r){if(!Re(r))return Bm(r);var t=_c(r),e=[];for(var i in r)i=="constructor"&&(t||!Fm.call(r,i))||e.push(i);return e}function Nl(r){return Qa(r)?Tc(r,!0):zm(r)}function Lm(r){var t=r==null?0:r.length;return t?kc(r):[]}function Om(r){return Rc(Ec(r,void 0,Lm),r+"")}var Gm="[object Object]",Wm=Function.prototype,Um=Object.prototype,jl=Wm.toString,Hm=Um.hasOwnProperty,Vm=jl.call(Object);function Nm(r){if(!or(r)||Ja(r)!=Gm)return!1;var t=Ic(r);if(t===null)return!0;var e=Hm.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&jl.call(e)==Vm}var jm=Fc.isFinite,Ym=Math.min;function Xm(r){var t=Math[r];return function(e,i){if(e=Bc(e),i=i==null?0:Ym(Dc(i),292),i&&jm(e)){var s=(Yr(e)+"e").split("e"),n=t(s[0]+"e"+(+s[1]+i));return s=(Yr(n)+"e").split("e"),+(s[0]+"e"+(+s[1]-i))}return t(e)}}function Jn(r,t,e){(e!==void 0&&!zc(r[t],e)||e===void 0&&!(t in r))&&Ka(r,t,e)}function Zm(r){return or(r)&&Qa(r)}function tr(r,t){if(!(t==="constructor"&&typeof r[t]=="function")&&t!="__proto__")return r[t]}function qm(r){return Em(r,Nl(r))}function Km(r,t,e,i,s,n,o){var a=tr(r,e),h=tr(t,e),l=o.get(h);if(l){Jn(r,e,l);return}var c=n?n(a,h,e+"",r,t,o):void 0,d=c===void 0;if(d){var u=_n(h),p=!u&&Lc(h),f=!u&&!p&&Oc(h);c=h,u||p||f?_n(a)?c=a:Zm(a)?c=Rm(a):p?(d=!1,c=Gc(h,!0)):f?(d=!1,c=Wc(h,!0)):c=[]:Nm(h)||Xr(h)?(c=a,Xr(a)?c=qm(a):(!Re(a)||Uc(a))&&(c=Hc(h))):d=!1}d&&(o.set(h,c),s(c,h,i,n,o),o.delete(h)),Jn(r,e,c)}function Yl(r,t,e,i,s){r!==t&&Vc(t,function(n,o){if(s||(s=new Nc),Re(n))Km(r,t,o,e,Yl,i,s);else{var a=i?i(tr(r,o),n,o+"",r,t,s):void 0;a===void 0&&(a=n),Jn(r,o,a)}},Nl)}var $m="[object Number]";function Ma(r){return typeof r=="number"||or(r)&&Ja(r)==$m}var _a=Im(function(r,t,e){Yl(r,t,e)});function Qm(r,t,e,i){if(!Re(r))return r;t=th(t,r);for(var s=-1,n=t.length,o=n-1,a=r;a!=null&&++s<n;){var h=jc(t[s]),l=e;if(h==="__proto__"||h==="constructor"||h==="prototype")return r;if(s!=o){var c=a[h];l=void 0,l===void 0&&(l=Re(c)?c:Yc(t[s+1])?[]:{})}$a(a,h,l),a=a[h]}return r}function Jm(r,t,e){for(var i=-1,s=t.length,n={};++i<s;){var o=t[i],a=Xc(r,o);e(a,o)&&Qm(n,th(o,r),a)}return n}function ty(r,t){return Jm(r,t,function(e,i){return Zc(r,i)})}var wn=Om(function(r,t){return r==null?{}:ty(r,t)}),Ta=Xm("round"),ey="Expected a function";function At(r,t,e){var i=!0,s=!0;if(typeof r!="function")throw new TypeError(ey);return Re(e)&&(i="leading"in e?!!e.leading:i,s="trailing"in e?!!e.trailing:s),Tn(r,t,{leading:i,maxWait:t,trailing:s})}function iy(r){return r<.5?4*r*r*r:(r-1)*(2*r-2)*(2*r-2)+1}function Xl(r,t=2){if(r==null)return r;if(Ma(r))return Ta(r,t);if(_n(r))return qc(r,e=>Xl(e,t));if(Re(r)){const e=["x","y","rotation"];return Kc(r,(i,s)=>Ma(i)&&e.includes(s)?Ta(i,t):i)}return r}let er=null;function sy(r){er=r}function fi(){return er?er():!1}const A={log(r,...t){fi()&&console.log(`%c[ray-2d-laser-map-sdk]%c ${r}`,"background: #2196F3; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #2196F3;",...t)},warn(r,...t){fi()&&console.warn(`%c[ray-2d-laser-map-sdk]%c ${r}`,"background: #FF9800; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #FF9800;",...t)},error(r,...t){fi()&&console.error(`%c[ray-2d-laser-map-sdk]%c ${r}`,"background: #F44336; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #F44336;",...t)},debug(r,...t){fi()&&console.log(`%c[ray-2d-laser-map-sdk:DEBUG]%c ${r}`,"background: #9C27B0; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #9C27B0;",...t)},success(r,...t){fi()&&console.log(`%c[ray-2d-laser-map-sdk]%c ${r}`,"background: #4CAF50; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #4CAF50;",...t)}},ka=r=>{if(r.length<=1)return[...r];const t=ny(r),e=t.slice(1).map((s,n)=>({prev:t[n],current:s})),i=new Map;return e.forEach(({prev:s,current:n})=>{ry(s,n).forEach(a=>{const h=`${a.x},${a.y}`;i.has(h)||i.set(h,a)})}),Array.from(i.values())},ny=r=>{if(r.length<=1)return[...r];const t=r[0],e=r[r.length-1];return t.x===e.x&&t.y===e.y?[...r]:[...r,t]},ry=(r,t)=>{const e=[],i=Math.abs(t.x-r.x),s=Math.abs(t.y-r.y),n=r.x<t.x?1:-1,o=r.y<t.y?1:-1;let a=i-s,h=r.x,l=r.y;for(;e.push({x:h,y:l}),!(h===t.x&&l===t.y);){const c=2*a;c>-s&&(a-=s,h+=n),c<i&&(a+=i,l+=o)}return e},Zl=(r,t)=>{let e=0,i=r.length-1;for(;e<=i;){const s=Math.floor((e+i)/2),n=r[s];if(n===t)return!0;n<t?e=s+1:i=s-1}return!1},oy=(r,t,e=1,i=2e3)=>{const s=[],n=t.x-r.x,o=t.y-r.y,a=Math.sqrt(n*n+o*o);if(a===0)return[r];const h=Math.min(Math.max(Math.ceil(a/e),2),i);for(let l=0;l<=h;l++){const c=l/h,d={x:r.x+c*n,y:r.y+c*o};s.push(d)}return s},Ra=(r,t,e,i,s,n=8)=>{const o=(t+i)/2,a=(e+s)/2,h={x:o,y:a},l=i-t,c=s-e,d=Math.min(n,Math.min(l,c)*.2);return Rt(h,r)&&_i(h,r)>=d?h:ay(r,h,d)},ay=(r,t,e)=>{const{minX:i,minY:s,maxX:n,maxY:o}=vs(r),a=n-i,h=o-s,l=t.x,c=t.y,d=Math.min(.5,Math.min(a,h)*.05),u=[];if(Rt({x:l,y:c},r)){const S=_i({x:l,y:c},r);u.push({point:{x:l,y:c},distance:S,centerDistance:0})}const p=Math.max(a,h)*.6,f=Math.PI/16;let y=0;const m=1e4;let x=!1;for(let S=d;S<=p&&!x;S+=d){const v=f*(1+S/p);for(let b=0;b<2*Math.PI;b+=v){if(y++,y>m){A.error(`[findBestInnerPoint] Iteration limit reached (${y}). Room size: ${a}x${h}`),x=!0;break}const P=l+S*Math.cos(b),w=c+S*Math.sin(b);if(P>=i&&P<=n&&w>=s&&w<=o){const C={x:P,y:w};if(Rt(C,r)){const k=_i(C,r),M=Q({x:P,y:w},{x:l,y:c});k>=e&&u.push({point:C,distance:k,centerDistance:M})}}}if(u.length>=15)break}if(u.length>0){const S=u.map(v=>({...v,score:v.distance*1.5-v.centerDistance*.5}));return S.sort((v,b)=>b.score-v.score),S[0].point}if(u.length===0){let S={x:l,y:c},v=0;const b=d*2;let P=0;const w=5e3;let C=!1;for(let k=i;k<=n&&!C;k+=b)for(let M=s;M<=o;M+=b){if(P++,P>w){A.error(`[findBestInnerPoint] Coarse search iteration limit reached. Room size: ${a}x${h}`),C=!0;break}const T={x:k,y:M};if(Rt(T,r)){const _=_i(T,r);_>v&&(v=_,S=T)}}return S}return{x:l,y:c}},_i=(r,t)=>{let e=1/0;for(let i=0,s=t.length-1;i<t.length;s=i++){const n=t[s],o=t[i],a=Rr(r,n,o);e=Math.min(e,a)}return e},Ea=(r,t)=>t.length===1?Q(r,t[0]):t.length===2?Rr(r,t[0],t[1]):t.length===4?Rt(r,t)?0:_i(r,t):(A.warn(`[Distance] Invalid geometry: expected 1, 2 or 4 points, got ${t.length}`),1/0),Rr=(r,t,e)=>{const i=(t.x-e.x)**2+(t.y-e.y)**2;if(i===0)return Q(r,t);const s=Math.max(0,Math.min(1,((r.x-t.x)*(e.x-t.x)+(r.y-t.y)*(e.y-t.y))/i)),n=t.x+s*(e.x-t.x),o=t.y+s*(e.y-t.y);return Q(r,{x:n,y:o})},Rt=(r,t,e=!1)=>{if(t.length<3)return!1;if(e&&hy(r,t))return!0;let i=!1;for(let s=0,n=t.length-1;s<t.length;n=s++){const o=t[s].x,a=t[s].y,h=t[n].x,l=t[n].y;a>r.y!=l>r.y&&r.x<(h-o)*(r.y-a)/(l-a)+o&&(i=!i)}return i},hy=(r,t)=>{if(t.length<2)return!1;for(let e=0;e<t.length;e++){const i=(e+1)%t.length;if(ly(r,t[e],t[i]))return!0}return!1},ly=(r,t,e,i=.5)=>{if(Rr(r,t,e)>i)return!1;const n=Math.min(t.x,e.x)-i,o=Math.max(t.x,e.x)+i,a=Math.min(t.y,e.y)-i,h=Math.max(t.y,e.y)+i;return r.x>=n&&r.x<=o&&r.y>=a&&r.y<=h},vs=r=>{if(r.length===0)return{minX:0,minY:0,maxX:0,maxY:0};let t=1/0,e=1/0,i=-1/0,s=-1/0;for(const n of r)t=Math.min(t,n.x),e=Math.min(e,n.y),i=Math.max(i,n.x),s=Math.max(s,n.y);return{minX:t,minY:e,maxX:i,maxY:s}},ee=r=>{const t=r.reduce((e,i)=>({x:e.x+i.x,y:e.y+i.y}),{x:0,y:0});return{x:t.x/r.length,y:t.y/r.length}},Ia=(r,t)=>{if(r.length<4)return r;const[e,i,,s]=r,n=Q(e,i),o=Q(e,s);if(n>=t&&o>=t)return r;const a=ee(r),h=pt(q(e,i)),l=pt(q(e,s)),c=Math.max(n,t),d=Math.max(o,t),u=c/2,p=d/2;return[{x:a.x-h.x*u-l.x*p,y:a.y-h.y*u-l.y*p},{x:a.x+h.x*u-l.x*p,y:a.y+h.y*u-l.y*p},{x:a.x+h.x*u+l.x*p,y:a.y+h.y*u+l.y*p},{x:a.x-h.x*u+l.x*p,y:a.y-h.y*u+l.y*p}]},bs=r=>{if(r.length!==4)return r;const t=ee(r),e=Q(r[0],r[1]),i=Q(r[1],r[2]),s=Math.atan2(r[1].y-r[0].y,r[1].x-r[0].x),n=[{x:-e/2,y:-i/2},{x:e/2,y:-i/2},{x:e/2,y:i/2},{x:-e/2,y:i/2}],o=Math.cos(s),a=Math.sin(s);return n.map(h=>({x:h.x*o-h.y*a+t.x,y:h.x*a+h.y*o+t.y}))},he=(r,t,e,i=10)=>{if(e===0)return 1;const n=(r.x*t.x+r.y*t.y)/e/e,o=i/e;return n<=0?o:Math.max(n,o)},Q=(r,t)=>{const e=r.x-t.x,i=r.y-t.y;return Math.sqrt(e*e+i*i)},ie=r=>Math.sqrt(r.x*r.x+r.y*r.y),q=(r,t)=>({x:t.x-r.x,y:t.y-r.y}),pt=r=>{const t=ie(r);return t===0?{x:0,y:0}:{x:r.x/t,y:r.y/t}},ql=(r,t)=>{const e=q(r,t);return pt(e)},Kl=r=>({x:-r.y,y:r.x}),$l=(r,t)=>{const e=ql(r,t);return Kl(e)},Ql=(r,t)=>{const e=pt(r),i=pt(t),s={x:(e.x+i.x)/2,y:(e.y+i.y)/2};return pt(s)},Xe=(r,t,e=0)=>{const i=q(r,t);let s=Math.atan2(i.y,i.x),o=(s+e)%(2*Math.PI);return o>Math.PI&&(o-=2*Math.PI),o<-Math.PI&&(o+=2*Math.PI),(o>Math.PI/2||o<-Math.PI/2)&&(s+=Math.PI),s},Jl=(r,t,e)=>{const i=ee([r,t]),s=$l(r,t);return{x:i.x+s.x*e,y:i.y+s.y*e}},cy=(r,t,e)=>{const i=Math.cos(e),s=Math.sin(e),n=r.x-t.x,o=r.y-t.y;return{x:n*i-o*s+t.x,y:n*s+o*i+t.y}},Er=(r,t,e)=>r.map(i=>cy(i,t,e)),dy=(r,t,e)=>{if(Q(r,t)===0)return[r,r,r,r];const s=ql(r,t),n=Kl(s),o={x:r.x-s.x*e,y:r.y-s.y*e},a={x:t.x+s.x*e,y:t.y+s.y*e};return[{x:o.x+n.x*e,y:o.y+n.y*e},{x:a.x+n.x*e,y:a.y+n.y*e},{x:a.x-n.x*e,y:a.y-n.y*e},{x:o.x-n.x*e,y:o.y-n.y*e}]},Ir=(r,t)=>{if(r.length<3)return r;const e=[];for(let i=0;i<r.length;i++){const s=r[i],n=r[(i+1)%r.length],o=r[(i-1+r.length)%r.length],a=q(s,n);if(ie(a)===0){e.push(s);continue}const l=pt(a),c={x:l.y,y:-l.x},d=q(o,s),u=ie(d);let p={x:0,y:0};if(u>0){const S=pt(d);p={x:S.y,y:-S.x}}const f=Ql(p,c),y=p.x*c.x+p.y*c.y,m=1/Math.max(.1,Math.sqrt((1+y)/2)),x={x:s.x+f.x*t*m,y:s.y+f.y*t*m};e.push(x)}return e},tc=(r,t,e)=>{if(Q(r,t)===0)return[];const s=$l(r,t),n=e/2;return[r.x+s.x*n,r.y+s.y*n,t.x+s.x*n,t.y+s.y*n,t.x-s.x*n,t.y-s.y*n,r.x-s.x*n,r.y-s.y*n]},Is=(r,t,e,i)=>{const s=q(r,t),n=q(r,e),o=Ql(s,n),a={x:-o.x,y:-o.y};return{x:r.x+a.x*i,y:r.y+a.y*i}},uy=(r,t,e,i,s,n)=>{const o=new Set(r),a=py(r,t),h=fy(a,o,t,e,i,s,n);return h||a},py=(r,t)=>{let e=0,i=0;for(let s=0;s<r.length;s++){const n=r[s],o=n%t,a=Math.floor(n/t);e+=o,i+=a}return{x:e/r.length,y:i/r.length}},fy=(r,t,e,i,s,n,o)=>{const a={x:i-10,y:r.y},h={x:n+10,y:r.y},l={x:i,y:s},c={x:i,y:o},d={x:n,y:s},u={x:n,y:o},p=zi(a,h,l,c),f=zi(a,h,d,u);if(!p||!f)return null;const y=[],m=Math.max(i,Math.min(p.x,f.x)),x=Math.min(n,Math.max(p.x,f.x)),S=Math.round(r.y);for(let v=Math.round(m);v<=Math.round(x);v++){const b=S*e+v;t.has(b)&&y.push({x:v,y:S})}if(y.length>=2){const v=gy(y),b={x:(v.min.x+v.max.x)/2,y:(v.min.y+v.max.y)/2},P=Math.round(b.y)*e+Math.round(b.x);if(t.has(P))return b}return null},zi=(r,t,e,i)=>{const s=(r.x-e.x)*(t.y-e.y)-(r.y-e.y)*(t.x-e.x),n=(r.x-i.x)*(t.y-i.y)-(r.y-i.y)*(t.x-i.x);if(s*n>=0)return null;const o=(e.x-r.x)*(i.y-r.y)-(e.y-r.y)*(i.x-r.x),a=o+s-n;if(o*a>=0)return null;const h=o/(n-s),l=h*(t.x-r.x),c=h*(t.y-r.y);return{x:r.x+l,y:r.y+c}},gy=r=>{if(!r||r.length===0)return{min:{x:0,y:0},max:{x:0,y:0}};let t=r[0],e=r[0];const i=s=>s.x-s.y;for(let s=1;s<r.length;s++){const n=r[s];i(n)<i(t)&&(t=n),i(n)>i(e)&&(e=n)}return{min:t,max:e}},An=(r,t)=>({minX:Math.min(r.minX,t.minX),minY:Math.min(r.minY,t.minY),maxX:Math.max(r.maxX,t.maxX),maxY:Math.max(r.maxY,t.maxY)}),my=r=>{if(r.length===0)return{x:0,y:0,width:0,height:0};let t=r[0].x,e=r[0].y,i=r[0].x+r[0].width,s=r[0].y+r[0].height;return r.forEach(n=>{t=Math.min(t,n.x),e=Math.min(e,n.y),i=Math.max(i,n.x+n.width),s=Math.max(s,n.y+n.height)}),{x:t,y:e,width:i-t,height:s-e}},yy=(r,t,e)=>{let i=1/0,s=1/0,n=-1/0,o=-1/0;for(let a=0;a<r.obstacles.length;a++){const h=r.obstacles[a],l=h%t,c=Math.floor(h/t);i=Math.min(i,l),s=Math.min(s,c),n=Math.max(n,l),o=Math.max(o,c)}return r.rooms.forEach(a=>{for(let h=0;h<a.length;h++){const l=a[h],c=l%t,d=Math.floor(l/t);i=Math.min(i,c),s=Math.min(s,d),n=Math.max(n,c),o=Math.max(o,d)}}),i===1/0?{minX:0,minY:0,maxX:t,maxY:e}:{minX:Math.max(0,i),minY:Math.max(0,s),maxX:Math.min(t,n),maxY:Math.min(e,o)}},xy=(r,t,e,i,s,n)=>{const o=e+s,a=i+n,h=Math.min(r.x,t.x),l=Math.max(r.x,t.x),c=Math.min(r.y,t.y),d=Math.max(r.y,t.y);if(l<e||h>o||d<i||c>a)return!1;if(Ba(r,e,i,s,n)||Ba(t,e,i,s,n))return!0;const u=[{x:e,y:i},{x:o,y:i},{x:o,y:a},{x:e,y:a}];for(let p=0;p<4;p++){const f=u[p],y=u[(p+1)%4];if(zi(r,t,f,y))return!0}return!1},Ba=(r,t,e,i,s)=>r.x>=t&&r.x<=t+i&&r.y>=e&&r.y<=e+s,Sy=(r,t,e,i)=>{const s=e/2;return i==="horizontal"?[{x:r-s,y:t},{x:r+s,y:t}]:[{x:r,y:t-s},{x:r,y:t+s}]},vy=(r,t,e)=>{const i={x:t.x-r.x,y:t.y-r.y},s=Math.sqrt(i.x*i.x+i.y*i.y);if(s===0)return[r,t];const n={x:i.x/s,y:i.y/s},o={x:r.x-n.x*e,y:r.y-n.y*e},a={x:t.x+n.x*e,y:t.y+n.y*e};return[o,a]},Da=(r,t,e)=>{const i=vs(r),s=vs(t),n=Math.max(0,Math.max(i.minX,s.minX)-Math.min(i.maxX,s.maxX)),o=Math.max(0,Math.max(i.minY,s.minY)-Math.min(i.maxY,s.maxY));if(n>e||o>e)return!1;let[a,h]=[r,t];t.length>r.length&&([a,h]=[t,r]);const l=Math.max(1,Math.floor(e)),c=new Map;for(const u of a){const p=Math.floor(u.x/l),f=Math.floor(u.y/l),y=`${p},${f}`;c.has(y)||c.set(y,[]),c.get(y).push(u)}const d=e*e;for(const u of h){const p=Math.floor(u.x/l),f=Math.floor(u.y/l);for(let y=-1;y<=1;y++)for(let m=-1;m<=1;m++){const x=`${p+y},${f+m}`,S=c.get(x);if(S)for(const v of S){const b=u.x-v.x,P=u.y-v.y;if(b*b+P*P<=d)return!0}}}return!1},Fa=(r,t,e,i)=>{let[s,n]=[r,t];t.length>r.length&&([s,n]=[t,r]);const o=new Set(s),a=i*i;for(let h=0;h<n.length;h++){const l=n[h],c=l%e,d=Math.floor(l/e);for(let u=-i;u<=i;u++)for(let p=-i;p<=i;p++){const f=c+u,m=(d+p)*e+f;if(o.has(m)&&u*u+p*p<=a)return!0}}return!1},za=(r,t)=>{if(r<=1)return!0;if(t.length===0)return!1;const e=Array.from({length:r},(a,h)=>h),i=Array(r).fill(0),s=a=>(e[a]!==a&&(e[a]=s(e[a])),e[a]),n=(a,h)=>{const l=s(a),c=s(h);l!==c&&(i[l]<i[c]?e[l]=c:i[l]>i[c]?e[c]=l:(e[c]=l,i[l]++))};for(const[a,h]of t)n(a,h);const o=s(0);for(let a=1;a<r;a++)if(s(a)!==o)return!1;return!0},by=(r,t,e,i="priority")=>{const s=new Map;if(r.length===0)return s;if(r.length===1)return s.set(r[0].id,0),s;const n=new Map;for(let h=0;h<r.length;h++){const l=r[h];n.has(l.id)||n.set(l.id,new Set);for(let c=h+1;c<r.length;c++){const d=r[c];t(l,d)&&(n.get(l.id).add(d.id),n.has(d.id)||n.set(d.id,new Set),n.get(d.id).add(l.id))}}const o=new Array(e).fill(0),a=[...r].sort((h,l)=>{const c=(n.get(h.id)||new Set).size,d=(n.get(l.id)||new Set).size,u=r.indexOf(h),p=r.indexOf(l),f=-u*.5+c*.5;return-p*.5+d*.5-f});for(const h of a){const l=n.get(h.id)||new Set,c=new Set;for(const u of l){const p=s.get(u);p!==void 0&&c.add(p)}let d=-1;if(i==="priority"){let u=-1,p=-1/0;for(let f=0;f<e;f++)if(!c.has(f)){const y=e-f,m=o[f]*.7,x=y-m;(x>p||x===p&&f<u)&&(p=x,u=f)}d=u,d===-1&&(d=0),o[d]++}else{const u=[];for(let p=0;p<e;p++)c.has(p)||u.push(p);if(u.length===0){let p=1/0,f=0;for(let y=0;y<e;y++)(o[y]<p||o[y]===p&&y<f)&&(p=o[y],f=y);d=f}else{d=u[0];let p=o[d];for(const f of u)(o[f]<p||o[f]===p&&f<d)&&(d=f,p=o[f])}o[d]++}s.set(h.id,d)}return s},wy=Symbol(),La=Object.getPrototypeOf,ir=new WeakMap,Ay=r=>r&&(ir.has(r)?ir.get(r):La(r)===Object.prototype||La(r)===Array.prototype),Cy=r=>Ay(r)&&r[wy]||null,Oa=(r,t=!0)=>{ir.set(r,t)},ws={},Br=r=>typeof r=="object"&&r!==null,Py=r=>Br(r)&&!Dr.has(r)&&(Array.isArray(r)||!(Symbol.iterator in r))&&!(r instanceof WeakMap)&&!(r instanceof WeakSet)&&!(r instanceof Error)&&!(r instanceof Number)&&!(r instanceof Date)&&!(r instanceof String)&&!(r instanceof RegExp)&&!(r instanceof ArrayBuffer)&&!(r instanceof Promise),ec=(r,t)=>{const e=Ga.get(r);if((e==null?void 0:e[0])===t)return e[1];const i=Array.isArray(r)?[]:Object.create(Object.getPrototypeOf(r));return Oa(i,!0),Ga.set(r,[t,i]),Reflect.ownKeys(r).forEach(s=>{if(Object.getOwnPropertyDescriptor(i,s))return;const n=Reflect.get(r,s),{enumerable:o}=Reflect.getOwnPropertyDescriptor(r,s),a={value:n,enumerable:o,configurable:!0};if(Dr.has(n))Oa(n,!1);else if(De.has(n)){const[h,l]=De.get(n);a.value=ec(h,l())}Object.defineProperty(i,s,a)}),Object.preventExtensions(i)},My=(r,t,e,i)=>({deleteProperty(s,n){const o=Reflect.get(s,n);e(n);const a=Reflect.deleteProperty(s,n);return a&&i(["delete",[n],o]),a},set(s,n,o,a){const h=!r()&&Reflect.has(s,n),l=Reflect.get(s,n,a);if(h&&(Wa(l,o)||As.has(o)&&Wa(l,As.get(o))))return!0;e(n),Br(o)&&(o=Cy(o)||o);const c=!De.has(o)&&Ty(o)?sr(o):o;return t(n,c),Reflect.set(s,n,c,a),i(["set",[n],o,l]),!0}}),De=new WeakMap,Dr=new WeakSet,Ga=new WeakMap,Cn=[1],As=new WeakMap;let Wa=Object.is,_y=(r,t)=>new Proxy(r,t),Ty=Py,ky=ec,Ry=My;function sr(r={}){if(!Br(r))throw new Error("object required");const t=As.get(r);if(t)return t;let e=Cn[0];const i=new Set,s=(m,x=++Cn[0])=>{e!==x&&(n=e=x,i.forEach(S=>S(m,x)))};let n=e;const o=(m=Cn[0])=>(n!==m&&(n=m,h.forEach(([x])=>{const S=x[1](m);S>e&&(e=S)})),e),a=m=>(x,S)=>{const v=[...x];v[1]=[m,...v[1]],s(v,S)},h=new Map,l=(m,x)=>{const S=!Dr.has(x)&&De.get(x);if(S){if((ws?"production":void 0)!=="production"&&h.has(m))throw new Error("prop listener already exists");if(i.size){const v=S[2](a(m));h.set(m,[S,v])}else h.set(m,[S])}},c=m=>{var x;const S=h.get(m);S&&(h.delete(m),(x=S[1])==null||x.call(S))},d=m=>(i.add(m),i.size===1&&h.forEach(([S,v],b)=>{if((ws?"production":void 0)!=="production"&&v)throw new Error("remove already exists");const P=S[2](a(b));h.set(b,[S,P])}),()=>{i.delete(m),i.size===0&&h.forEach(([S,v],b)=>{v&&(v(),h.set(b,[S]))})});let u=!0;const p=Ry(()=>u,l,c,s),f=_y(r,p);As.set(r,f);const y=[r,o,d];return De.set(f,y),Reflect.ownKeys(r).forEach(m=>{const x=Object.getOwnPropertyDescriptor(r,m);"value"in x&&x.writable&&(f[m]=r[m])}),u=!1,f}function Bs(r,t,e){const i=De.get(r);(ws?"production":void 0)!=="production"&&!i&&console.warn("Please use proxy object");let s;const n=[],o=i[2];let a=!1;const l=o(c=>{n.push(c),s||(s=Promise.resolve().then(()=>{s=void 0,a&&t(n.splice(0))}))});return a=!0,()=>{a=!1,l()}}function Ey(r){const t=De.get(r);(ws?"production":void 0)!=="production"&&!t&&console.warn("Please use proxy object");const[e,i]=t;return ky(e,i())}function U(r,t,e,i){let s=r[t];return Bs(r,()=>{const n=r[t];Object.is(s,n)||e(s=n)})}class Iy extends L{constructor(e){super();g(this,"dragStart",null);g(this,"initialTouchDistance",null);g(this,"initialScale",null);g(this,"activeTouches",new Map);g(this,"firstTouchId",null);g(this,"secondTouchId",null);g(this,"taintedPointers",new Set);g(this,"zoomFactor",.8);g(this,"scaleMin",.2);g(this,"scaleMax",5);g(this,"originalPosition",{x:0,y:0});g(this,"targetPosition",{x:0,y:0});g(this,"centerPosition",{x:0,y:0});g(this,"originalScale",{x:1,y:1});g(this,"targetScale",{x:1,y:1});g(this,"defaultScale",{x:1,y:1});g(this,"transitionDuration",500);g(this,"transitionStartTime",null);g(this,"initialPinchCenter",null);g(this,"isGestureValid",!0);g(this,"lastTapTime",0);g(this,"doubleTapDelay",300);g(this,"doubleTapZoomFactor",1.5);g(this,"lastTapPosition",null);g(this,"tapDistanceThreshold",20);g(this,"tapDetectionEnabled",!0);g(this,"mapClickStartPosition",null);g(this,"mapClickStartTime",0);g(this,"mapClickTimeThreshold",300);g(this,"mapClickMoveThreshold",10);g(this,"shouldSuppressMapClick",!1);g(this,"isGestureHijacked",!1);g(this,"hijackedPointerId",null);g(this,"isHijackPaused",!1);g(this,"interactionGraphics");g(this,"viewportBounds");g(this,"boundResetAnimation");g(this,"debouncedStopWheelRender");g(this,"debouncedLogWheelScale");g(this,"interactionState",{isInteracting:!1,isAnimating:!1,interactionTimer:null,renderReasons:new Set});g(this,"throttledAntiScale");g(this,"unsubscribeEnableInteraction",null);g(this,"handleSuppressMapClick",()=>{this.shouldSuppressMapClick=!0});g(this,"handleGestureHijacked",e=>{var n,o;this.isGestureHijacked=!0,this.hijackedPointerId=e.pointerId,this.isHijackPaused=!1,this.clearTouches();const i=e.global.x-this.viewportBounds.x,s=e.global.y-this.viewportBounds.y;this.activeTouches.set(e.pointerId,{x:i,y:s}),this.firstTouchId=e.pointerId,this.dragStart={x:i,y:s},(o=(n=this.appService.events)==null?void 0:n.onGestureStart)==null||o.call(n)});this.appService=e;const i=e.getApp();this.viewportBounds=i.getViewportBounds(),this.eventMode="static",this.unsubscribeEnableInteraction=U(e.runtime,"enableInteraction",s=>{this.updateInteractionMode(s)}),this.updateInteractionMode(e.runtimeSnapshot.enableInteraction),this.interactionGraphics=new H,this.interactionGraphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill({color:"#ffffff",alpha:0}),this.addChild(this.interactionGraphics),this.scaleMax=i.scaleMax,this.scaleMin=i.scaleMin,this.centerPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.originalPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.targetPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.throttledAntiScale=At(s=>{this.appService.emitter.emit("antiScale",s)},16,{leading:!0,trailing:!0}),this.boundResetAnimation=this.resetAnimation.bind(this),this.debouncedStopWheelRender=Tn(()=>{i.stopRender("wheel")},300),this.debouncedLogWheelScale=Tn(s=>{A.debug("[Interaction] 滚轮缩放完成 - Scale:",s.toFixed(3))},500),this.setupInteraction()}updateInteractionMode(e){this.eventMode=e?"static":"none",A.debug(`[Interaction] 交互模式已更新: ${e?"启用":"禁用"}`)}setupInteraction(){this.on("pointerdown",e=>this.onPointerDown(e)),this.on("pointerup",e=>this.onPointerUp(e)),this.on("pointerupoutside",e=>this.onPointerUp(e)),this.on("pointermove",e=>this.onPointerMove(e)),this.on("wheel",e=>this.onWheel(e)),this.appService.emitter.on("gestureHijackStart",this.handleGestureHijacked),this.appService.emitter.on("suppressMapClick",this.handleSuppressMapClick),document.addEventListener("pointercancel",e=>{A.debug("[Interaction] Received global pointercancel"),this.handleGlobalCancel(e)})}handleGlobalCancel(e){const i=this.appService;if(this.isGestureHijacked){A.debug("[Interaction] 系统取消或移出视口,强制结束劫持手势");const s=i.getApp(),n=new fa(s.renderer.events);n.pointerId=e.pointerId,i.emitter.emit("gestureHijackPointerUp",n),this.exitGestureHijacked()}this.clearTouches()}resetPan(e){const i=this.appService,s=i.getApp(),n=i.appContainer;this.transitionStartTime!==null&&(s.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null);const o=this.centerPosition.x-e.x*n.scale.x,a=this.centerPosition.y-e.y*n.scale.y;this.originalPosition={x:n.x,y:n.y},this.targetPosition={x:o,y:a},this.originalScale={x:n.scale.x,y:n.scale.y},this.targetScale={x:n.scale.x,y:n.scale.y};const h=Math.sqrt((n.x-o)**2+(n.y-a)**2),c=(d=>Math.pow(Math.min(1,d/1e3),.5))(h);this.transitionDuration=500+1e3*Math.min(1,Math.pow(c,2)),this.transitionStartTime=s.ticker.lastTime,s.ticker.add(this.boundResetAnimation)}setPanZoom({targetPosition:e,targetScale:i,setCenter:s=!1,setScale:n=!1}={},o=!0){const a=this.appService,h=a.getApp(),l=a.appContainer;if(s&&e&&(this.centerPosition={x:e.x,y:e.y},A.debug("[Interaction] Set center position:",this.centerPosition)),n&&i&&(this.defaultScale={x:i.x,y:i.y},A.debug("[Interaction] Set scale:",this.defaultScale)),this.originalPosition={x:l.x,y:l.y},this.originalScale={x:l.scale.x,y:l.scale.y},e?this.targetPosition=e:this.targetPosition={x:this.centerPosition.x,y:this.centerPosition.y},i?this.targetScale=i:this.targetScale=this.defaultScale,!o){l.position.set(this.targetPosition.x,this.targetPosition.y),l.scale.set(this.targetScale.x,this.targetScale.y),this.antiScale(this.targetScale.x),this.transitionStartTime!==null&&(h.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),A.debug("[Interaction] 直接设置缩放完成 - Scale:",this.targetScale.x.toFixed(3));return}const c=Math.sqrt((l.x-this.targetPosition.x)**2+(l.y-this.targetPosition.y)**2),u=(m=>Math.pow(Math.min(1,m/1e3),.5))(c),f=((m,x)=>Math.pow(Math.min(1,Math.abs(m-x)/Math.abs(.2-1)),.5))(l.scale.x,this.targetScale.x),y=u*.8+f*.2;this.transitionDuration=500+1e3*Math.min(1,Math.pow(y,2)),this.transitionStartTime!==null&&(h.ticker.remove(this.boundResetAnimation),this.interactionState.isAnimating=!1,h.stopRender("animation")),this.interactionState.isAnimating=!0,h.requestRender("animation",!0),this.transitionStartTime=h.ticker.lastTime,h.ticker.add(this.boundResetAnimation)}clearTouches(){var s,n;const i=this.appService.getApp();this.activeTouches.clear(),this.firstTouchId=null,this.secondTouchId=null,this.dragStart=null,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.isGestureValid=!0,this.taintedPointers.clear(),this.transitionStartTime!==null&&(i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),this.interactionState.isInteracting&&(this.interactionState.isInteracting=!1,(n=(s=this.appService.events)==null?void 0:s.onGestureEnd)==null||n.call(s)),i.stopRender("interaction")}checkEventListeners(){return{wheel:this.listenerCount("wheel"),pointerdown:this.listenerCount("pointerdown"),pointerup:this.listenerCount("pointerup"),pointerupoutside:this.listenerCount("pointerupoutside"),pointermove:this.listenerCount("pointermove")}}destroy(){this.checkEventListeners(),this.interactionState.interactionTimer&&clearTimeout(this.interactionState.interactionTimer),this.interactionState.renderReasons.clear(),this.interactionState.isInteracting=!1,this.interactionState.isAnimating=!1,this.debouncedStopWheelRender.cancel(),this.debouncedLogWheelScale.cancel(),this.unsubscribeEnableInteraction&&(this.unsubscribeEnableInteraction(),this.unsubscribeEnableInteraction=null),this.appService.emitter.off("gestureHijackStart",this.handleGestureHijacked),this.appService.emitter.off("suppressMapClick",this.handleSuppressMapClick),super.destroy()}exitGestureHijacked(){var i,s;const e=this.appService;this.hijackedPointerId!==null&&!this.isHijackPaused&&(this.activeTouches.delete(this.hijackedPointerId),this.firstTouchId===this.hijackedPointerId&&(this.firstTouchId=null,this.dragStart=null),this.secondTouchId===this.hijackedPointerId&&(this.secondTouchId=null)),this.isGestureHijacked=!1,this.hijackedPointerId=null,this.isHijackPaused=!1,(s=(i=e.events)==null?void 0:i.onGestureEnd)==null||s.call(i)}forceEndGesture(){if(this.isGestureHijacked){A.debug("[Interaction] 强制结束劫持手势");const e=this.appService.getApp(),i=new fa(e.renderer.events);i.pointerId=this.hijackedPointerId,this.appService.emitter.emit("gestureHijackPointerUp",i),this.exitGestureHijacked()}this.clearTouches()}pauseGestureHijack(){this.isHijackPaused=!0}resumeGestureHijack(){this.isHijackPaused=!1}antiScale(e){this.throttledAntiScale(e)}resetAnimation(){const e=this.appService,i=e.getApp(),s=e.appContainer;if(this.transitionStartTime===null)return;const{targetPosition:n,targetScale:o}=this,a=i.ticker.lastTime,h=Math.min(1,(a-this.transitionStartTime)/this.transitionDuration);if(h>=1)s.position.set(n.x,n.y),s.scale.set(o.x,o.y),this.antiScale(o.x),i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null,this.interactionState.isAnimating=!1,i.stopRender("animation"),A.debug("[Interaction] 动画缩放完成 - Scale:",s.scale.x.toFixed(3));else{const l=iy(h),c=this.originalPosition.x+(n.x-this.originalPosition.x)*l,d=this.originalPosition.y+(n.y-this.originalPosition.y)*l,u=this.originalScale.x+(o.x-this.originalScale.x)*l,p=this.originalScale.y+(o.y-this.originalScale.y)*l;s.position.set(c,d),s.scale.set(u,p),this.antiScale(u)}}onWheel(e){const i=this.appService;if(this.isGestureHijacked){A.warn("⚠️ [onWheel] 被手势劫持阻止执行",{isGestureHijacked:this.isGestureHijacked,hijackedPointerId:this.hijackedPointerId,isHijackPaused:this.isHijackPaused});return}i.getApp().requestRender("wheel",!0),this.debouncedStopWheelRender();const{scaleMin:s,scaleMax:n}=this,o=i.appContainer;e.preventDefault();const a=e.global.x-this.viewportBounds.x,h=e.global.y-this.viewportBounds.y,l=(a-o.x)/o.scale.x,c=(h-o.y)/o.scale.y,d=e.deltaY>0?.95:1.05;let u=o.scale.x*d,p=o.scale.y*d;if(u=Math.max(s,Math.min(n,u)),p=Math.max(s,Math.min(n,p)),!(u!==o.scale.x||p!==o.scale.y))return;const y=a-l*u,m=h-c*p;try{o.scale.set(u,p),o.position.set(y,m),this.antiScale(u),this.debouncedLogWheelScale(u)}catch(x){A.error("❌ [onWheel] 应用缩放时发生错误:",x)}}onPointerDown(e){var l,c;const i=this.appService;this.interactionState.isInteracting||(this.interactionState.isInteracting=!0,i.getApp().requestRender("interaction",!0),(c=(l=i.events)==null?void 0:l.onGestureStart)==null||c.call(l)),this.isGestureHijacked&&e.pointerId!==this.hijackedPointerId&&!this.isHijackPaused&&this.pauseGestureHijack();const s=i.getApp(),n=i.appContainer;this.transitionStartTime!==null&&(s.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),this.activeTouches.size===0&&this.taintedPointers.size>0&&(A.debug("[Interaction] 清除污染指针列表,准备新手势",Array.from(this.taintedPointers)),this.taintedPointers.clear()),this.activeTouches.size===0&&(this.isGestureValid=!0,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.dragStart=null,this.firstTouchId=null,this.secondTouchId=null),this.activeTouches.has(e.pointerId)&&this.activeTouches.size===1&&(this.isGestureValid=!0);const o=e.global.x-this.viewportBounds.x,a=e.global.y-this.viewportBounds.y;this.activeTouches.set(e.pointerId,{x:o,y:a});const h=this.activeTouches.size-this.taintedPointers.size;if(this.taintedPointers.size>0){A.debug("[Interaction] 存在污染指针,阻止多点触摸手势",Array.from(this.taintedPointers)),h===1&&!this.taintedPointers.has(e.pointerId)&&(this.firstTouchId=e.pointerId,this.dragStart={x:o,y:a});return}if(this.activeTouches.size===1)this.firstTouchId=e.pointerId,this.dragStart={x:o,y:a},this.mapClickStartPosition={x:o,y:a},this.mapClickStartTime=performance.now();else if(this.activeTouches.size===2){const d=Array.from(this.activeTouches.keys());this.secondTouchId=d.find(u=>u!==this.firstTouchId)||e.pointerId,this.setInitialScaleAndDistance(n),this.tapDetectionEnabled=!1}}onPointerUp(e){var n,o;const i=this.appService;if(this.taintedPointers.has(e.pointerId)&&(A.debug("[Interaction] 移除污染指针",e.pointerId),this.taintedPointers.delete(e.pointerId)),this.isGestureHijacked)if(e.pointerId===this.hijackedPointerId){i.emitter.emit("gestureHijackPointerUp",e),this.exitGestureHijacked();return}else this.isHijackPaused;if(!this.activeTouches.has(e.pointerId))return;const s=this.initialTouchDistance!==null&&this.initialScale!==null;if(this.activeTouches.delete(e.pointerId),A.debug(`[Interaction] onPointerUp, remaining touches: ${this.activeTouches.size}`),s&&this.activeTouches.size===1){this.isGestureValid=!1;const a=Array.from(this.activeTouches.keys());setTimeout(()=>{var h,l;!this.isGestureValid&&this.activeTouches.size>0&&(A.debug("[Interaction] 100ms 缓冲结束,检测到真正的幽灵指针,标记为污染并清理",a),a.forEach(c=>{this.activeTouches.has(c)&&(this.taintedPointers.add(c),this.activeTouches.delete(c),this.firstTouchId===c&&(this.firstTouchId=null,this.dragStart=null),this.secondTouchId===c&&(this.secondTouchId=null))}),this.activeTouches.size===0&&this.interactionState.isInteracting&&(A.debug("[Interaction] 清理幽灵指针后所有触摸点已释放,结束手势"),this.interactionState.isInteracting=!1,i.getApp().stopRender("interaction"),(l=(h=i.events)==null?void 0:h.onGestureEnd)==null||l.call(h)))},100),this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null}e.pointerId===this.firstTouchId?(this.firstTouchId=null,this.dragStart=null,this.activeTouches.size===0&&this.tapDetectionEnabled&&this.detectDoubleTap(e),this.activeTouches.size===0&&!s&&this.detectMapClick(e)):e.pointerId===this.secondTouchId&&(this.secondTouchId=null),this.isGestureHijacked&&this.isHijackPaused&&this.activeTouches.size===1&&Array.from(this.activeTouches.keys())[0]===this.hijackedPointerId&&this.resumeGestureHijack(),this.activeTouches.size===0&&(this.isGestureValid=!0,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.firstTouchId=null,this.secondTouchId=null,this.dragStart=null,this.tapDetectionEnabled=!0,this.interactionState.isInteracting&&(this.interactionState.isInteracting=!1,i.getApp().stopRender("interaction"),(o=(n=i.events)==null?void 0:n.onGestureEnd)==null||o.call(n)))}detectDoubleTap(e){const i=this.appService,{interactionConfig:s}=i;if(!s.enableDoubleTapZoom)return;const n=performance.now(),o={x:e.global.x-this.viewportBounds.x,y:e.global.y-this.viewportBounds.y};n-this.lastTapTime<this.doubleTapDelay&&this.lastTapPosition&&Q(o,this.lastTapPosition)<this.tapDistanceThreshold?(this.handleDoubleTap(o),this.lastTapTime=0,this.lastTapPosition=null):(this.lastTapTime=n,this.lastTapPosition=o)}detectMapClick(e){var h;const i=this.appService;if(!i.runtimeSnapshot.enableMapClickCapture||!((h=i.events)!=null&&h.onClickMap)||!this.mapClickStartPosition)return;const n=performance.now()-this.mapClickStartTime,o={x:e.global.x-this.viewportBounds.x,y:e.global.y-this.viewportBounds.y},a=Q(this.mapClickStartPosition,o);if(n<=this.mapClickTimeThreshold&&a<=this.mapClickMoveThreshold&&!this.shouldSuppressMapClick){const l=i.appContainer,c=i.mapState,d=(o.x-l.x)/l.scale.x,u=(o.y-l.y)/l.scale.y,p={x:d-((c==null?void 0:c.origin.x)||0),y:u-((c==null?void 0:c.origin.y)||0)};A.debug("[Interaction] 地图点击捕获",{screenPosition:o,containerPosition:{x:d,y:u},origin:c==null?void 0:c.origin,mapPosition:p,clickDuration:n,moveDistance:a}),i.events.onClickMap(p)}this.mapClickStartPosition=null,this.mapClickStartTime=0,this.shouldSuppressMapClick=!1}handleDoubleTap(e){const i=this.appService,s=i.getApp(),n=i.appContainer,{scaleMin:o,scaleMax:a,doubleTapZoomFactor:h}=this,l=e.x,c=e.y,d=(l-n.x)/n.scale.x,u=(c-n.y)/n.scale.y;let p=n.scale.x*h,f=n.scale.y*h;p=Math.max(o,Math.min(a,p)),f=Math.max(o,Math.min(a,f)),this.originalPosition={x:n.x,y:n.y},this.originalScale={x:n.scale.x,y:n.scale.y};const y=l-d*p,m=c-u*f;this.targetPosition={x:y,y:m},this.targetScale={x:p,y:f},this.interactionState.isAnimating=!0,s.requestRender("animation",!0),this.transitionDuration=300,this.transitionStartTime=s.ticker.lastTime,s.ticker.add(this.boundResetAnimation)}onPointerMove(e){if(this.isGestureHijacked&&!this.isHijackPaused)if(e.pointerId===this.hijackedPointerId){const n=e.global.x-this.viewportBounds.x,o=e.global.y-this.viewportBounds.y;this.activeTouches.set(e.pointerId,{x:n,y:o}),this.appService.emitter.emit("gestureHijackPointerMove",e);return}else return;if(!this.activeTouches.has(e.pointerId)||!this.isGestureValid)return;if(this.taintedPointers.size>0&&(this.initialTouchDistance!==null||this.initialScale!==null)){A.debug("[Interaction] 存在污染指针,阻止多点触摸手势移动");return}const i=e.global.x-this.viewportBounds.x,s=e.global.y-this.viewportBounds.y;this.activeTouches.set(e.pointerId,{x:i,y:s}),this.activeTouches.size===2&&this.initialTouchDistance!==null&&this.initialScale!==null&&this.applyPinchZoom(),this.activeTouches.size===1&&(this.initialTouchDistance!==null||this.initialScale!==null)&&(this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.secondTouchId=null),this.activeTouches.size===1&&e.pointerId===this.firstTouchId&&this.dragStart!==null&&!this.taintedPointers.has(e.pointerId)&&this.applyPan(e)}applyPan(e){const i=this.appService,s=this.activeTouches.get(e.pointerId),n=i.appContainer,{x:o,y:a}=this.dragStart;n.position.set(n.x+s.x-o,n.y+s.y-a),this.dragStart={x:s.x,y:s.y}}applyPinchZoom(){const i=this.appService.appContainer,s=Array.from(this.activeTouches.values());if(s.length<2||!this.initialTouchDistance||!this.initialScale||!this.initialPinchCenter)return;const n=Q(s[0],s[1]),o={x:(s[0].x+s[1].x)/2,y:(s[0].y+s[1].y)/2},a={x:(o.x-i.position.x)/i.scale.x,y:(o.y-i.position.y)/i.scale.y},h=(n/this.initialTouchDistance)**this.zoomFactor,l=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.x*h)),c=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.y*h));i.scale.set(l,c);let d=o.x-a.x*l,u=o.y-a.y*c;const p=o.x-this.initialPinchCenter.x,f=o.y-this.initialPinchCenter.y;d+=p,u+=f,i.position.set(d,u),this.antiScale(l),this.initialPinchCenter=o}setInitialScaleAndDistance(e){const i=Array.from(this.activeTouches.values());i.length<2||(this.initialTouchDistance=Q(i[0],i[1]),this.initialScale={x:e.scale.x,y:e.scale.y},this.initialPinchCenter={x:(i[0].x+i[1].x)/2,y:(i[0].y+i[1].y)/2})}}const By="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAaVBMVEUAAAA3yFI4x1E3yFM4x1Q3yFI4x1I3yFM3ylVAz1BEzF44yFI3ylI3yFI2yVNGzF9GzGA3yFM4x1JKzWJY0nB62or///83yFL///+b46hQz2jN8dRp1n1Ey13y+/SC3ZPm+Om06r6n57PA80FIAAAAF3RSTlMA3yC/QO9grzAQ75+PcFDfz8+Ar2AwEAVwkmAAAANrSURBVGje1ZtpktowEEZbkiVvmG1m+Ixg1vsfMqnUVPWPkLG6W+DKu8CrJ7UBG5nEnLrtsQ1h5yIwOLcP45ReerovXWoPuIlrJ0/3wad2wI/Ep1S/PLUoIjQ13X4cUEzcNJW0TYCQUEP9zNpHqr2DHLvajzCwUY9ZcjARJ13uAWaCl3u3DhWI4p0+opTrwk7LlnmHYi74mb2/z0V0nbGAKzZ3DoLgRTFcVzhWUeB9n+daI5Yg4aNEDKRlbwOIgsvE2C7ub5QFl4pjV2WeOZjFgtk2e1/fWGwz7yHiPAvE2P3buwFkwSIxjtaB5mAWW0bb80ALglms3uYARhAsEONwyzuBEQSzWPkJ1kcwgmCZ2Hn1RHOwRoxRPdEcrBLDKyeLg5ViZw5WivFsDFaLgyn4a1aL0RiC82wQB0Pwp0UMr76G82wSj+oPrU+beNCudJ5tYiTlaF2s4vZ7pSHjOpvEPF4JMi42Ma/1EwRwsFbMay2c6YtNzHPtIYCDTWJ08p88F6OYN7mFAA7WinmTHSRc6ogP0quYg5nzDV6xwIleIOEyF3EpmK4kCy7jWnA3M60SjCONAu97tWC0oq+mj2rBCLR/bDCL3SrB2JFbJRiOBhTyWjMYkVDKuWYwQMXBb1WCWRzXCR7IrRPsaPfYYBaHVYKxp7BKMAK1qwRjpOMqwZhou0owEnWrBOOFTljm/fw3X6Zg9EQHqMimYCf+Qc9iU3ArvktlsSUY029xBxVZG8x35gM0ZEtwJFJvcrYEPxGpNzlrg/lRhIeGbAhGT/q1zobgQKRf66wL5ue32rnO+uDY0zcj5GRVMB+UUI9XVgej0TwoZ7E6OKj+GmCxJdiSnC3BzDOkZFMw4yAk24L1g52twdprOSuvYfPpvGz80GISRGRV8EQ3OEBCVn8tGRc7K4Kjp5tsISArghvbQT0Wc7Buopkdisni4H2dQ0ZZEFz1eFPmYInXfpAsy4Jjxw7baGdZcFPtsGAWPgAooIlFYkFw3FY8EJrLg11X8whsLg52ksO3+2VxafDOk4TNorgw+CiQ8oiZcVsS4wPMHDxpmKIxN5GSfgMDo6/7OoroInq4Ojz/vy/h/FFvBGM2jJ7q0Zdmt4lq06enuNDapru91za1Djc5tKmj+9K/pGkMe+cGILpdCO1x251Iyi/g4vimU9Z1kQAAAABJRU5ErkJggg==",Dy="/assets/robot.CSiuukeH.png",Fy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAgH/fIL9gcEDvoBDPsJCPUDD8BuiCAAACCklEQVRo3u3Zza6bMBCG4Y/434aQzP1fbCt14SOZSac+zPQs/C4jwaME7ICN1Wq1Wq1W87VYd0dEe9gy7MqBvuQi9OusHp3PenqMPeiix31uZU5YiVTlB3PCk5jSTXChS9kTV2m3uG/mR0zEtt0Ce7qWKw873FK5livx+VvgRJdyIr6IW9ou5Ux8T2jKgYcrNOXMwwGq8qYM83IqLKws+8rB2jISA+vLkbmr9eUnM1mry819+GO0Hs8ZPdPx3NCzlB16pvKBnqkc0TOVPXqWskPPVH6iZyp79CzlHUM2csSQiewwZCNHDJnIAUM2cgOTosy35CUvecn/W37H83C/C8nbyT6FMhjqcnsE6pnJOdBFTVPu7FiEqvwOxJTAyeN1KrQf8Z/ck9gyZPLL0Z+cF7N+l6yX8rL3r7P0z8tb6jreLV7pLba77K01IWcR/MlNwIycxDsS/Er8lFwFrv/szslBAEeJK5fl8CFx5bIc3jn3AKblQwBzrmuYl5/fgD0wL78EcOEv8Lzsp6cPB3xDDhBUmZlyWpYenZgvPC8Lj27cfta8HCEq0Fi2eN7OzFjSlwMDq8u+MLC6nAYYsJGfw3aWlVyH6cNK3obpw0qOrrsehnLfN9299Zu7j4FKiD97zeBvcgKfqlwaDNukI1JT3mBalyNs26RzgZb8gnlxpxIyVqvVarVarb70C7CyrCEVukMsAAAAAElFTkSuQmCC",zy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMA3yC/EECAYM+f73CQr1Awj6BvNXOp4gAAAlpJREFUaN7s1t1ugzAMhmE7TgghgdL5/u91ndBK11SYfFonTcpzXl7yR0Nd13Vd13Xd/+VWVk6OAD7PzCxDIMCHbtrTQfQbR2o1oD/2q97A6agPBjrPsd4BU+ZZgfLehQcd9acMdKEXF31yoVNYX0uewAewb9mRtfFkmaHZcroDy1qZfMMCweULtEGCHprJlrU2kiXpsRXanPbG9mrJZIjQzxY12O/O0BoVNbFHTiPDe3q32lu6NtnzZAv257Zmn32bGP9LaBgfsh9VwameoCHbXRVgjWtTc1eLEZ71FNfa1WCEIxS2u0wWAcOO9UiknblBphLdTViKTMb7W12mEyJv2cHTLpRRd0PjRLGjU0IecvDVoLLo5ko3IY0yx2prGF2Qi/PI8lVzsj/TvLbg3YMl3cp6oHgC2MddjsMS6Bddnj8NAmQRw/OlJgBZxFUfpNf3Dsme6P1hCqx3k5SloYpO9XA//SWlVPLi6G1Cdev8K/I407Z3fUBweFnQLi5+tmcGOQzCMBA0EBKSllz4/1/b+x6QVXmqVp4PrBDGeHfP7ei7JX9LmXM1nlKHIwUK+JaMQbfHw1C6RCoMTQ57iEUMAkOTIwDiEGsCoGddMYouthdiiNFnmBJtQHQNohkWV7YRYJrol6wZ+DCE05kjBawteK4d0VnAbEGPfF8cTAvhPnAcq0VTHTkWIKwdLySsBQkgDBxBsjHJ2W6qB9zYskDADVbGpSB+Zru+NF4TEHb3UtUi2aHhUqq3aPn9H4XV4MLDU06PWgyhbaCsNlDjrbmcz8wzkyRJkuRDXlF2skMkf3lIAAAAAElFTkSuQmCC",Ly="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMA359AIL+QYBDvMIBwr6CPz1BvDk7raQAAAplJREFUaN7t2tuO3CAMBmDbQALkOOv3f9dKrVbWMiSQTHGqiu96oz94OGeh67qu67rP+JF2ZObdTQb0GMcscAQdnlgoRkfkdxM0ZyVXN5k4b4bGkPOChbb4yAAJreDgoSnkIwaaGpif6V6RjxAktJq8QGMr5zlobUTdYGFRsdTlZAIFRm+dKPewF2iw/CaCioVToMMojyYRdJdFMagsTuVaB9DilacP4RQqXf6REfSMCtuP8uRlQRE2GcTezLQ4t9D0isWFAu1fK+MWmIXbzOlIHuFA3JAZqfq9vgKnAr1nY6nQ23dFIlSZOAu/bNKecJ5L8qi/lSu2n9F2RSRTM97o6vj84PBv8eLMhnxqu5XL7n6D02QzE80WDpj0/f1HDZaq+YV/I59tLnFqLC6zRSSFzHdYs+Seutel05WIjk4Q3myBc3Y456qCY3Zfa8fNnTx1bq8q9fC+JBpCPgXnuCjYZFdNcu3WKFjm3TUJtoHbBn9PkGmpiYv228PYDaPNDjorT51wtzpXGIw/6vwEVcHTjRuOxUDK/5xAVi4yl6fq/P7BrjJl1sx3ePGAwHj4pnYmmqNsss+NFw8I5W1cXTJCkbmUK0a812Cx1vy9IUw3j3a43aXTDsvr+fYxxPRXxxu5ItZvWyFl1szOeIZKdkVmHGJ5yGX3+YP7OffYBvd6dFS01/TnADTLjPe5rXqU/CfH0zkZn2pQ9XZLmGSVVUPpAUFL+Dcu9J67wgygxPFDl6dqH1/KX/gsaHjpfvYRk9732/K2GzWKvfBDya7yEkohWKmHLfXXX206l/oXvvmp/wMxfAShKR/4CLQ1PBVsg26py92LoLWJ9abNcjJGUPB++CcPGtJoZ0CPmdzOzLjT6KHruq7ruo/8Ani9wIJR4hr/AAAAAElFTkSuQmCC",Oy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAIN9A7xC/gGDPn3BQkK8wj6DdtO0oAAADPElEQVRo3u2Z2Y7rIAyGwWYnS8fv/7BHlTpi0gacsuTc8N1VivqDF2yMmEwmk8lk0h9nFJHfohT90HEDIlLG5f810C/GdZJFQwkrznnQH3yPXUtDB0CefkVHbLPuooguKAd649GoaylRUlb0TmjW/cQwlm7fc6RzHleEKdbHFeXYr3ypdK0wUA7D+LgttB3lceLI2nPLQHlAHEHqt2WkEu6KrU2V8EolzBXzqCphQ0XwyteyRthTkfXK11gj/EMJPmRVP2Ekuh5emk7RI5wc+FWCqEJC2dZ8NQliiDKy1kFRi/OUJ3LlxIgGtJRyX34YQzqmhtUjLZRCB5iFtSA/d12OaZCiEw5yB2KoOC5bolwyjU8/9HYq7NhS3I49OxAhoztKGVJo8brtxA8vhqH+TaBK6XJqaYViDBKOaUpHvBTDWNYQdaYHWMVtGEp4FPeBybtR3IBecH9ZHuiJt7pbGDkbjIcnxjwifgwKAF/S1kbsN3BR9M62vB/brrffDJ0T9DF3Vdfk2Q1l8U/lZUz6RCphj/cqKFsuQBqPcVgqot5uGaU4Mb+rW+rv4wl5EPbXGgdsaaZTGV4utHS7/a7VDZQn/QUc2xBtN2NMeESHuD/7YffwXzb3WrGWPtjFpl9lLFd4qIxyL49sf04uIJ6tzdJ+T8GwuD0tlgVa7qYqZvOPhxFWJWtJMU6YsgAymT9IeNUioa0hCDplAg/UmVrhySEDOo3EWEzVHNHLE900PtZADHwV27KlMGE+LjE7b+yloiR6nYsldz2+uMqI/A0bziqEqzi4uOjCfPLA4bmmBH7fBoRS+Gm2nvLJlEtKLFWR5fNprHoAZMsz562QJLYul86Tciu+t5hL7YsXl8BiaDHvHQ4aBk+xEFobF63SQv2F2eYXq3jvyeOubc0sbdMZNzB5gj/wcsUqvx0gKlIbZr3AnwwanXO76MXGZMowPPMoMgzmTXcYO3P+D2D0YLrqnuGHKXPlHhYxGFdxJRsrTFEMZaEcaqyfJdM3j0MVZjJDMUzjPIzI9HPD0IoRHoZlfDwOzzygD0MC/adKIf1tdYL3s9XiFuSriUyd5H3gap7iYFbUYjKZTCaTSRP/AEYn9FrTdrbUAAAAAElFTkSuQmCC",Gy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMA3yCAEGC/759AcFDPkDCvoI+BJCYaAAADo0lEQVRo3u2a2barIAyGCSQMjpX3f9izzunqoYoxbhD3jd9d6/CXEDJA1cPDw8PDw0MNYZkhxgh26VHdBhoXv/Ba3UPn4obljlGjjzlww6BtjL+iTHEfaG1tGxkW1RaIHIyx2wuPiqG1MKimvCJLW/cKvHCvmmJZYVJN0Y4T7lRbJs6/zOY+6vXFY36dEO6HusSlQ5hybzXiHC9VOTMsb6ta2j49Cl5tatKHtnyyx715DvuZxE0/06W190InLmdkwpugLE6j1cfL2SV/LkrWvPtArxJ9/sOSsbhLMr24YNDxF7vioKZPxIiR9y1TnLl85PC8e+Fq/ouGrGOUlZGdR4w5tmDAnLUtNyYqTdYYDzH7k6yPixQqqGCZ0NgztjTFFZkXhJ3eMQwJDjKX1xgJm5sUpJU4KBkXJbpU920GjEMsF44iDpMvrAc8C1aqFI7jZjZJdI+53tRpyHbzVpyF2RFI0yS8J6S0l+a3orMyp2yd7rQ6+XPNFKeMJ4fs6WV9yNdRaZKYkrIbvDHeDkINLen6s/l4/hRa+LFCP67Ew490B1Rn0Z33Y8D1d2TZEXhBt5ik7WJ0b0MHD2BJTmgjqkvQeuX8Fo+bVwjqWug7emg20hhUFwMrR3P3yK6NO+7Xw85eYuSJusV7b/q88vb/PsN6Zj3VDxb7ZciaqGkbPnX3vsnBPJJW1WBnd8MQup32VGuNF83k7LjAaxrubwV7lGperfZttRX28GhosmDIyckV9X//62hSMpXVAO0fFoDv2+qOfDfttssXzQzDfH55kZjk+A7AmoD/t40+XmFKG/PEC9+3LNYSWw8P1nu/Woq+dsCv790Gn7olkVNjHqTHzfdHPCXsUNbVki6t3+ZOKYeKzXCT5+J1i15Z4ZKgS5ulNV01ySSsX8jCdlNh2Lvssl37mrZtYjcgcp+fsr28irMSPPzBeu/rWRaeyk61gNlL9OsNbB5XmCKIiS5u1ejV9m3TQWOtmbjQV0xxwvKGImaVCA4G6hSB7+hn9oqR45bMyL5+EPapK49acWCiFh55TXfBqbaG/WGFw5dOwIbLMmV/dFphmadEXVkZ9KE1jRADTGmpOWih/DRHBZvrSs5NIVWImbuzJ4AE2TlZgTbK/xHIOyiaP3V2UBdhzv7zJfR0RVcjL1Wj2kJ82muLFhJ9O4BPA20xvyWMrqBTaOnXoJpjCpZTO2Wj7oCA2RtuDhIwm7TtCaP9Kw6zCerh4eHh4eFq/gDsgRtLdqAVbwAAAABJRU5ErkJggg==",Wy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA3yBgv58Q74BwQK+PzzBQHgQBUQAAAqhJREFUaN7t2etu8yAMBmBO4ZgQ7v9qv2na+kpVEgKOqfQN/1vK+hRjE9KKGTNmzJgxYwY9VCrOKDE8lCxfIR+SYwjx3ki7le+Qz03iXvrW8hOe7tov9276QnlFJMO+lLuycoDpyyxvvBdyg1iocLk3CyzwU8u83ZKxwAhispdyS8YCYzC1m27JyMy6INn8MhbYCPxD5Jfj78tO4Q+MZZPRSTt6Hz3FJ6fXAr81v2aV0Umb/RmPoYwyOsm9rgfUGqNsfi+Ho2t8MmZ3NNwpLjmXQ0JjA+ORcXk/2Ws9s7yejlassrQY15BsuhwvbmyBUV6vBjvFJ9ujwRqNxiPXTxF6rIyxUg2WNW6Qg2Uke7CMZNvBssYZYayMZKvBsnLYOcfKHvU1WEYzD5YVmnmwjPoaK2OcEYNl/VR9GdUoy2dayhfZKOdHDiPWlWZ5wQDKhEurjJbypAl3yJ56l8Ijy9ZU21aSC9sgaS2yxuftCayWs439LInbl8eEW2QUdiBmOopGORP3TYc9qEVGrl2fm3GEapOR69wFa3RFq7zjQZpQW1k0y5mweSFfVjTLlnQQWVAhbTLqMlG6SYpWGWVt6HBdHgBXZCKM70tFh0wqrhVV3SLTq9pjq26QyX2M7Sf0fweoSXv1IrplRbw79cpOCFJZx145dcL6MtdaVeVAOHOdLlUosipb8imz7xkDbm+unTp6qSKTQp6usikccv1p15fCKWPKbn93eWVMuSR0c4TBJ0u8l1l1jDEsuMQp53IQQ+TwMdl/TE6fku32B+XlD1ZYdJ+SbRosI2K1xozgukte0lJXToCUiOaMTfvV2VPQw4bk3lGXtLo+9UbxSGS9Jim/p7KZVef6eTuIAQGZDNPlKMYF/TcZuiyVGB3Wy7ItSsyYMWPG/xD/AIrSnldXeREbAAAAAElFTkSuQmCC",Uy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEXRSTlMA5cgdcw7XjzlWrIFkup0rSDjdhakAAAKOSURBVGje7ZnbkqQgDEAj95va//+1W7u1NVGpHiEJPHEep0ZPJyYBERaLxWKxWPDRaXPphOnE7S8uwmTM9p9JZvT+YGAG6J1rRu9cM3rnmtE714zeuWb0zjWjl2vme5XaLhQYSLx5tUbz2Bl23r0Ad/MJg9Du4X2YnYYRoAS99R8HYGtFbbYgz1F7a/MB4pjKi2ZCO5MayZ2PYndDmqq+d4AHn2GlbdXvMZW6wOQLy7xVgAcxyvtt84aUERNr/5ZINeAx71Ujvcw1Jd/BoW0FMdJLUmn9gVo20eml9kWTXdo7VCvBAWbd6wNGAmmFfO3P3PXfHliEvlFolVR9paZEIx+hkEP3fbxMyBiws93j1TMCJswiIxFyrgN+R/FDto4yfCM/5HILmBByZJeWoe0LE5DQtIBBc3Nd6mHZ28uRmekAXQRmrt1PpgHpLC/eziMDUHMdWI/4A53gUlFYY8tCJ5aQLORg7J8UVhfj4oPREDunqD1047Eh+sF5yXkHWOIGOC2ROc9YSRSX4rwzJdYM4PTi3BkAmV4glrXfK/QlJlSLBPFq1m9m5CvR9y4WCOzUy60jFTV/zxar2UPdR6Qpu0TE0fbHodqP03PtaZcd/LdUTboqABGFR5ikl3mgEgknskXkYFF1n8hqxygtxPSemFnFChhRt5Pqd+8u9Ykgbk1m9CIBWPir+SXb+uo9RD8ofo9C/mNf2K5k2/gtPUh/nFfxSzFguNj2ImZUlypqjdqqk/gFhrgU9dV6bA88gLQZ5bvPxmSfcFJJejHbHRgQpLhmbwFRTtWmVRqEsbkpzRbkCelNmzDcmeoUYBwhf6syH2AsNvrKrXy0MAMd87Grf8r9yJ8TFovFYrFYcPgDfFESW2IpAiAAAAAASUVORK5CYII=",Hy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgN8g7xBgcECfj6+/zzBQ4swJLwAAAaxJREFUaN7t2lluwzAMBFBq9SLbnfuftigQYD5SZLGpaQPoXWBgiqQdKDYMwzAMw3Wp5dySyVX8yNXEAm5kycy9CabAXG0yc7XJzNUmM1ebzFxtMnPVyczVJzP33mQdVRD132EHHjqsk5TxUE7WRYp4InZJLhFPxWL+Gl7QjPoMkmycK0DCoToySNjabCxxgzW8YTE3E94yeW8s+THveFNUTrD/NB84IWkLTdG9o2ULrGSc4PCGXAESrpEZJO2vDact4gempH1gWsS7g5K2pWkRzzAV7dKiqm0t2k5WGpclbaWpOlRaWOuMy7J4e9ChPWKatGuL1vO/HvTdFeFg9whWfW3CxQj+z2f8Z8G7Y7B+gbRPWpkTHFTtrwiatZ9cVOyEXfuOoFXbW/QlPmLKuCgXO2XRVppmcaUpahc1VfG3LUWX1lLv62AXRO0JU3VoafEsN9cLReVdzCEuNAWcMH3ynQRfzPorr1X8vBTEuTRlvChP5ojzrP+bQAl4QSjmL214oiXrY34Yvc3Wz7xm/Couyfoq8xLvU6tJpBqWPUYgx72Fr2TDMAzDMFzxDf7xFoVjSQNhAAAAAElFTkSuQmCC",Vy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgN8g72AQn0Bwv4+vMM9QQt7wKQAAArJJREFUaN7tmtHOpCAMhbUgoqL2/Z92s5t/0/wtkRE4c8V3eTKZMy2lRZlpMBgMBoNBLS55n5zSdvb7OUFZ+C9+yWpAZv5hedRwvszzfy1mNKCvuNhfA/XFO1tf63IoDeVrXZLSwL7iEkhpYF9xccoZ5mudvdJAvsL285Hbau0snEH3q1lr7Zz8yCmbSmmNOM+PeCelrbQmHHEBcvaT1OwciItQkFpQWj2JPyBlljmBNlJ+O5PSABspv6mc0mo5PStKpT0rDVVYtphIaajCElZJttJes/ErNkm2aP06VnmZqXWZL34JZXYCYXZwfjfvSmseSWWc1JdosETbxK5KA1W0bVZOaS8InqsgJyFXTciDK1kl5Jo2ErkaCbmmvnbmtpCj0tABS3iX0sABS3iL0kC9w4bnlIYqaRteUhpuDwvB5podqGnZVhWUhistYZevUdojgZtxmcQ5cKYlr1Fp6ExLXrVWwnMzPhcBsHsIpx0UHMFLLKfaTWm4tiUc8lZEtPLTQ6fqiu+qi7gDV2ZOXN8wpkwn8gVj7kLuq4YxZo2tsf+asdPaMxfQGN9AUqaBpK+1zMWcAfFDYqkYEpE7ECvGYmCh7YC7aw1f1lfmKEPg5wipLae1EnenJV60hj/t+SC1xaIVWbtkeqLXT22xS6ad0cpQj9E0m9FUZulwtp12rnixSO2lFa2GfEKW4GatwUMmeaugrgjAqxwlZ7akgXs5ZVKWel0olu9iFqWB35NLUklpyJuB8kUM/k4i+MI47DuYZRAkpWGdpUtE6wvINuiPGdvnt6lb5nXVhvuDgL3wOJRWS5g/SnOw82WeGnE7F0jOnhR30eqJj9Z7tDfs+zL1IR6es9DqJu3r1zj1I8SVrOvvwG7/TwtTb9wyrxcRs6crzbdexXs/7nMaDAaDwWDwnj/NQlzrb+J5OQAAAABJRU5ErkJggg==",Ny="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMAYN+fgL9AIO8QcFDPfzCQr49fa1RRAwAAAnlJREFUaN7t2NmumzAQgOHxvhEgnfd/17ZKDhMMSmobz+mR/F1Fraq/jAeywDAMwzAMwzB8N6EfHPBS+ORn4GRxY4CToLCED9jD4bYa8Q3hMOEfU+AMUxdRcYdXfFK8YYWbO2f4hi9uPGHqUpkrHDHziydsMednjrDz21/J7ZXrH3YvNXo9he5h83qV83b1qneYFnren3fsGxYUyjfc9gzTYml40jT6juFtmZaTp6fpFqYDlgE2QdL0O4UdTfV0/t71CdOgE+wkGnaXcKTFyiw07B5hQ3+Sm76GHa4P06QdkPyY79eFJ/iij4M+HoO7LGyy+2YCcjJs1SEMTk2TDh++e4Qrw5/R6mnusKPFZg3TJVveMJ2y4g3Tfe6Zw/TgdLxheq9IvGHaa8EdBnzQPyEsVvO0qr8Mhb3au7sLR33HAvLTjZwKtqKIhXORPukXPHMKxA/PTOgV1u/nNsE/c3oTxVGye+79oizAy3k6YlaKlp7VDWsemLN9ECf0UTjrVl0wlklnXbrgXrfTcW+dwbpfJBYsY7Kfjz1Wfjk3WCjQdkSDxJd1A5ay9NBo+Z0tYSlNO9XQBYWlTPb9sfR86Z8X8ie34RqgkMNyNt9KaWs+X5WL++0wAiqsWG79+k9LxElbqCKxnKeDClBpxhoOmkWsEaGZwRoKmmEVCa0sEtZDXrCOgEYT1lmgTUDCesgJa4XWT8PEKLXuLkotBonX2iNJ0ETu98Vm96rYD1dedsgOq8MGWogsnLK3IJuFLzvkNQuL7AOOexO20MBkYV0QTpeNWh/DkIWve5uIk5TSPCQAoV7cAOD5ctFaR4CotXhIMwzDMAzDMAz/j98ceskaOhA77AAAAABJRU5ErkJggg==",jy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAYJ+Av0Df7xBwIJBQz68wzE7woAAAAVNJREFUaN7t2d1ugzAMhmHHSUj4Kfj+r3asmxrIClKYlwzpe8446XuQgi0gAAAAgNuIxj4ZqmsI8s1RVSwvnmpyKWzpBMIII4zwWdjQCYQRRhhhhBE+hDDCCCOMMHX/IOzpxG3D0fJeSGHHe0b35VKBntSMUqLTvHlKhFZhGUiLsVu9ecNvENxP9MlkfurtzkRaeml0I89SJpKSIGUM6fBSaCQdVgo99J6YTQ45SjFPGiYpNtaexrofox5SLGgc8iDS5pCNJFX3LpYLnOIKXXvvWuSSRWMktjnkWS5hjZHY5JC9XDTUHYmJqTsSE1YciczcycbMHCRxlvU2vin7Kc4eyJ0klrzeMsBZ2GVhdxw2eiPxTXg+Do8KIzGFuyzMWVhr41vycMjCYxZW+3e5LCxZ2B6Gw0S/Mbjuk3tar3lrDfvXhbWeol2ZL5EAAAAAAOCvfQALwYE8tktFzgAAAABJRU5ErkJggg==",Yy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAANlBMVEUAAAD////////////////////////////////////////////////////////////////////xY8b8AAAAEnRSTlMA5VZzrI86yR0O12VHK4GeumR+Sig+AAAB1ElEQVRo3u3aYW+jMAyAYTuExEkItP//z550VHCVOGMzl02an6+b+i4hIRQNnHPOOed+KkoruNmAL7nAnQg3M9wp7OEMDA972MMe9vDvDkdgeNjDHvawhz38Xx72sIc9/H1hasNfLazGPZzDu8R8StG/XFIY4FCPFfERlC+XVBJ3cWZNeNKFA/u3N91S+upcx+2ntShGHDfLeGB4dzTVbxNyI2ImhGEbbnCnvIc7qNAUJFKBQ8+tu2iqZcgoNRIAs6wzKbpJluU/el7v7PSJbcy/tKcwtASqrtZotBP0ikG3ZNSbDMIjXtBOBkPCiba9yBQR61yAF9F6xJQlT0wJLyHBtZvsrzA+gVFFe66iXg3AwZdoPdO5y1bNDIym71YC3iQ5LGZ9OMielWs33kxZ9u2gFetdPIOJaH2z7LGKwos+fLqwPnRCzGePfLIRN9vFlcT/UjChWuKeZcSLr+jDD2ZIHbFOadXLyUVRG4twl0SyvXVhDvxZvAvW53FdhjCld+s8lLDEl4qIXb2hDBYdPdivMyUbh3eF39S9Xm6N/+qHKxe48jZm64Oq8mGgi+Vwfi7H01+5YuBFyVMDjfgJA5yj8LDO1qf8ZYSlVMA555xz7rv9AZlKFXj5dr43AAAAAElFTkSuQmCC",Xy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAQCBggN+/nxDvcM8wkFCwoI+ASc+UAAACfUlEQVRo3u3Z7XajIBCAYWAAAVET7v9iN6my6CR0lmo+Np3nV3vSkzcKQmkFY4wxxhhj78EFfQVOPJDr05cgCpNmVjyQuo3IlEVRPDUsxePEV4UlhzmcfVy44zCHPzkMnx2GV4eHV4X1W4WVKDjMYQ6/fRh+TTiswnJ2TtkoVw7+FLqEVfqeFjecNsl3amc4JoKrnOq93BeWVFgKpEsz7/bdav0lwOzUmw1rI77glIU94XblFnXPDZdJMfw8HBTiBM3n8Eh+xuu4pYycw6MttKovAkZQhku3t4su0xlk8kJcwug5rtwvq8TBZKLKSneDFIeLxIN8BJVFuQCAgMLTkUX7zagPKGzEsxhqtc5gsnBk+ITCorhdtI07aNTLg0qtjJBnfRXo2blbTHZhspIZ8bTua5e0zAVLjBmtLMAeff/DsGrIzu9j18tHlaQ2GmgK+zzI9M6niU82pSYyXwv9G6cKQRLbWIMghCuXXxcVuebT8ArZ5xldv1ibB5eYfG2DPJBXbBIZ7lMjtdqSVf02Do76T08rWA2yrocjeUxq1ZU1p/r2LiWjZ6BqK3krs94nPNSeYWqRMamZ2+wT5jxGtTHfyd7MKuWY2o3EzECTqL+7YwcyQ+8T2O30Dbdhm9rZO+tsDwVu5HuNT1j7Bpk+7MC9M8VIJKh9IvOySvtkHPEwGV++vOjt3+9td+VX+4RvmY31hykot3n6DFpOYfPTU9PksPG2q9AQDShscbjsDU7V0QdMQOEJhU8ofNhfnCYUtv8YDnvDHoV7FB62r/uyT+wjEwobFNbb1w87LgW8geBlbzTLmV2Kq+XcBiB3ht0IMMqL6ARjjDHGGGP/qT+Hf7FSTq027wAAAABJRU5ErkJggg==",Zy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA378ggBAw78+fYECPcFCv86Xy/gAAAk9JREFUaN7t2WlPwzAMgGGnjnP2yP//tWgg0GavaVCOCpH3K1WfHWnjMpjNZrPZbDabzf5cZg8BYXTGq/TIBRgYBpd+8jAoCkt6aYURRZ9EBmQdvliZh77tKr3PQdd0Og16FtNNsL8LVv8OXu6C17tgfJYWNQ6G7ZtRHgEHwhDVJxsIAMAxuG8m7ObdWoMR/TkYg9Y7Qb6o143awto+DrQRMqFKj1ZqB9P34Raz7leOqmG5w6hTmRybLKpguaUqKtj+Yj0sb7dHwZyxNoKP9JyGN4X03NIFThuIjE3PHY3gcDUPI9vtdSOY2HkVigX9kqUy2MJVaJlM2XkuQBms4DLD5CM3OG/QDJayPl8BGlrCYOTbyr+keji/tOWCroelLJc2Oe42h6VMckGv0AOG7VVxyBe0hz4wc0QeKuAK2UEFXCE76gmDrnElXC8rhB6wlKXbHYY143aF4eCuRRgCo7yAx8B0F6w5rMbAxiaeHgGjTTLdB5ajrJS7wNKVbV1g6cpCF1i6sr0HLF2ZNV1gOdmpsDsm94GJMSieqhQ2gqXLH/uRyx1g//byMYnJzWF/csPYuNwY9qf7kWYyNYV1ZrJb+d8awjr7eTomN4Kla03+vuJbwVreG/Py2gaO1/uQ4RtGE/j6Z195UTWBXyeOpejrwBZw2WXq28Ou6MZEruhfbAf78HKFso0PVckFFX4zp6my8QZtyQ17+cWDDzr+EvMDtzL5k5UPaaTt43w7XGQ+347HgpOlA6EkMtEUHbdHhMtMjASz2Ww2m81ms9mIPgCfVZZTXlzW2AAAAABJRU5ErkJggg==",qy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgCDf7xAwz0BwYL+fj1CvJC6qIwAAAtFJREFUaN7tmUlu7CAURelbg9n/av/kKyX7GnjGppRInGmED/AaoMIWi8VisVgsFou/gnE5hOAE+yIi7Lb8YLesGTLBassZFR2bjNjKNXPVmpc6cV64hSwtlGdz4KUHZ8BUL5rne+ebfaERXva6QkSKd+tIQvHw7FxIEczb1ABv4lPaqhx5dcnHj++Hb4s4b8m5nbnpGOUXxYcGnRiwH8xuzk5L3eul/jWvgPU0N3t/TRzKh9ifWpzStTghGAzJPAXd0TjOvatWsWGXxPJB4ZbJ/rEpIp7qHD7azutq+2mYtb3oubmfOBuuGL1FiWbFYqTkz0jTWzHGWCvCEcKvDzhh/4/LrIItHyyk5qkLIKFaFTyqYrkgtZit1VATu8CogZ6LdeybJxvvXiLl6P3EtO8QHhN66Hjrl7E9mQ0m9Ogh45oTFrJ5O+IP7osbTBjM1dQO4B1MLaVZ17xDQoOXRIR66Zl57Q9p/MotGMXsbyc0IlR/KG6pgeToeBELC6aYpcCEtvqON0HwiGb3zOuhUKrkAox7HUSuQXjv0SUU5CrF/Nwrbyaln+ClBYm/4dUSBg+a1T2vhcGDZmVu7bOFwaNmdy++w5NW5wKe40XkSRy/5HWYWjO9OPbD/kXv0HFo1HPvyEXLPfBq8NLNAZrdvZ4zavYPvaNm/qS5x9LCT/NuJ1Hey4HwHW/ALchTvAk2ltwQtideDi8Gmhm9asCLTdLAYrql4B94rSaXJ5ZCGPdKQU+chPeVxK/wWTebDkYytcyu3CCd1KGzV7bxbI/lDrb5cuF4YlWHa7IT16RV9endf52bm+JYD2FEL35fQIiJSIhg5znpK/ddcVOsQEz7ERVDJcdXvHdbIkbEQEUQSZViCrRfNCJuRR9s41u9kDC18XnvFX2j3bHLR/A2zSqzAzpzGh/tYdKy29xFhH9cPsZkxwho5wRbLBaLxWKxWCx+I/8ANf2/u2NhQhAAAAAASUVORK5CYII=",Ky="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAIVBMVEUAAAD////////////////////////////////////////PIev5AAAACnRSTlMA7zC/QN+fgCAQTQcGNgAAAMRJREFUOMvd0jEKwkAURdFPBEkdsLFKyAYk2UIqO1uXYOUSXIJbCCiCqzTDe8Ei3qmDrz3caebH+7tHLLZ6fvZpHfFYhwaPV8jOiZ0zn5QTd3vlwIdGOXGhnDiUIytHdk7sHNk5sXNi53dg5a9lPQxDHc6vQUu5YlqjmFbGv++W1W2V5ctY5+L534vpt37E89lspr9eaKmzIfbVIfvqzJSbKTdjLsZczLkYczHmrZjyXWLKtaDcTLkZc+K2TzsTH/Xu2vkDlC8AMDsTJN8AAAAASUVORK5CYII=",$y="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAG1BMVEUAAAD////////////////////////////////rTT7CAAAACHRSTlMAgL9g36+fQGFJCmkAAADFSURBVDjL3dS7DcJAEIRhniJ1SIgEBSAqQFRARguEJBTgxJqy7cDeX7ZGmtwX+fbu8+t2d7Pqsb99lqHH617XX6mZr26lrrCkdr58ljTxnTRxsHQZJwfBwXqWhoP1rmfDwfrVFA5mO3Ozm4DHRCwmZDExjwlaDPcYDrYcbDnYcrDlYM/BnoM9b+Jyvnl+tfxh+beA4elIwoGmdAjJlFIxJHIqg1hEuQRzAZ9c+dN6jmB4bj2hcYW2F5omLfe6PMH/0HLXPHpWgenjpk040QAAAABJRU5ErkJggg==",Qy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAMAAAANIilAAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA32CAIEAQ779wz4+fUDCvilaH/gAAAZdJREFUSMftltuOxCAIhsWiVqst7/+0m5jsEIUqm72d/64M33BSWvfVP9WgzKZ4wqRyayhWojwbMwlVhfVAdAnrIeHmVK/TGWAvfOJDRAn3cGqSLURc8AJOSrcqcdIrGBT26r8EFd4FbsSBN2kDzgUnnsAOJohKwZSiBZ6PQpBG+5xP6gpWGGRgiksYDhGax0TFrWBAVzn03GqqK7igcwgces46L+DSS/IfuHDWopBBvrNdHBrdaAnuRdlH/p8xzfj7fLutkLr4JN+cyV7P535MqQQDzHnff4eRRu+DZ2dQ4Y4N8GGBK3sPa/mxwJnhoWawwG2EAxlnNXpnbqC5Yzg5Jz41VpgHe3LeVpg3hxebLV7HDgZ+Hi1YiNqmYZX339B/hNXlnpvrOTR2dgFfYlnCh66dXcCPGIwnThxoCSd5A4FYSzhwYLZZ4UO7+pcRTupRBBMciLQPFwQLfL68HTDt4fD2Jr4N8Ply91oSaeuBS9SO7BaOoLMHGeCq15tJwppTyk6qGuBG9KC6Hk6Y9ERRGXj31f/0A2zyPsVxnMRtAAAAAElFTkSuQmCC",Jy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAJFBMVEUAAAD///////////////////////////////////////////+0CY3pAAAAC3RSTlMAYIDvMBDPv4+fcLUOqFYAAAEWSURBVDjLvZW9isJAFIXHkLCw1S5ss9ikt00h2ETyAqn0CaxsbHwCSyvfwN7KEUQ8L2dilJPE4Z5GPFXgy5efOzP3um6i1FkZeYtGQGrJgDflSrfkSjdk6kGZekimHpTHwIZ6Xz5Ngb9JWB8C2QD4KYBrAM9wymscT7AI4GSZuRq74ly6QOZ5g+O1C6fBzHvwd9nHSfu20aKPZ75dsHPZxckSKWVg1cVfgG9XO+/iuK485az/7uKpUyamTpmYOmVi6o18+X3kH9g9r7d3PYKRtJKNeIHFw8WniR8TZRFFFUsiFlRsB7mZ9FZ0g9eNvP/AIdIHWB9/3TwObD1H0bhE2xNNU7Rc0bAN3ethoUeNHlR6zIkheQMcOzccp+sDkgAAAABJRU5ErkJggg==",tx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABGBAMAAACDAP+3AAAALVBMVEUAAAD///////////////////////////////////////////////////////+hSKubAAAADnRSTlMAEN+AIO/Pn2AwUI+/cOwbbqMAAAEBSURBVEjH7dJBTsJAFMbxj0Ci4GZCjF7AdeMJTHXjBdy4afQCRC9gOEHjxj1H8AiewCOwKGmBEL4zwLSEB0x5bweb/nZdzL+vb4pG43w6MSy3LEbQtQbkErobkpkzM+TIzJBDaL5odi7o5c7OzKC4Yun+4DseseOB3gR7elH+KU/t2kxKZk7PtBKSf3qmx7WFmsHl9qBkfhF05GRKbxrcYERvKE1+4NCY3vxoRmbI4m3mHZVws3fAD73CHb3ozHUTyQQG9N4kU6NfjZps3lmrE7G0mb3eEyuSCXWNTCnVM6W2lZE98sX+0/NvaP659gpVX83IHmcwPCdFDMu1Q6NxeivVcQUNhbcOPQAAAABJRU5ErkJggg==",ex="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAUCAYAAACTQC2+AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEYSURBVEiJpZVRccMwEERvgsAMagiBYAiBEAgpAzEwBEEIhEAQBKUIUgavH4pnXM2tJTv7qdm7XelWkpkAMAIJeAF3YHA4AxApeACj6qdEBiDzH8HhhYqTPUNmZiehNZtZ7e7L4dVr47u2DcflgovDvQpuaIlMolC6BOZeY0vBSBl8jdRxCtmpy9ThoAw/dZG1SSU2rIlRbH9qiax6nEWPeSHcBOHWK7ISU0EKhj+Xvoj6Yl448snMfo823YFhe7s70RyD2C7AeYeIuoNxTfLeNvg83on67dsidwh5d/AlTQIXsf0jT9DUcqfCcd1hLLROYWkQneJ4lGem/6NvM3tWaz8Or157vmv7QQnHY3GJ/srvlMEnNhL6B6cIZVSNSYqvAAAAAElFTkSuQmCC",ix="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAaCAYAAAC3g3x9AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEPSURBVEiJ7ZVdbcMwFIWPGYRBA6EMFgYthEEIBDPIGGQMuiGohiAQrCEIhG8PSdTKtW/srY87Ul6i60++5/5Y2hHQAzMQAL8Xb4EaYORRA9DUwlpgSsA2BaAthXVrinsKwHkP5gtAsXyNX5uG9ctpZPOVxa9gBPeFGQSgFXnzA9AlsjkaF7iKdAEmjCpidIGAS/RvKGqHBRz7OjoWM3tJB0mfzrmPUuAKfZX0Iulb0lvN2X+lFRflyzn3XgNgmeeTtqLwOHJ/aZuLMh0fftnYs4CrAT0mYB350ZtKloO/g/VG3C0rnrm+onSes2Aj6Bnbgk0zifVmVdGCmustB21I+zZS+4xGYL/edubuOcjpBwCFxkKYDWbkAAAAAElFTkSuQmCC",sx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAACgCAMAAAC8EZcfAAAAqFBMVEUAAAD////////////////////////////////////////////////09P////+vt//Kzv/f4f/z9P/y8//o6P/HzP/////z9P/i5P/////v8f/t7//k5P/m6P/w8v/q6//o6f/S1f/X2v9gbP/b3/+vs/+Vmv9daP7///+us/+aof7r7P9xe/719f+Fjv7W2f9ncv7Cxv+4vf+kqv57hP7h4/+Ql/7M0P8zzBhqAAAAJ3RSTlMAn4Ag3xC/70Bgz3Aw748gMJ/iv3BeUM+/r5+PYHCvgN+FQBWPQDAOL4ZsAAAGb0lEQVR42s2b2XbaMBCGbWzMvmUpJXuatpJteQXM+79ZOTZkKAeiGdlW9F9zlM+zSTNSrEY0vx9NV97SnUScRxP3zVtNn58cywjNn+xhxC8qunl4nlvfKWfwMuESTeznrvUtcu48jpQ30s84uOUURd5AJ6OzcM/+fpL7QRxvhGBMiE1cBOtsdxaZvY4uRMfmp0r8OGUXlRZ+8t9nLP5aJNXHC7MC4K5A5iEH/Wy79swWJ3T+hqEk/BNvP7bq6DuIvV3BCIoTiMU7qy05N+BawYhKwYxe32pFnU+8gIGUEH9bzct54wf5DKSKuGw8WZ6Oexo4VwkxO0bifTvuDQWrqfhYdaZNFpclr5SnrLbS/Jgr3cbCz8UkB92IN06TfBB99ZXueCm3kdPieALJ25j8w2Fx3ABfj5cKWKMKoiqZaxPOK75wwxrW5kA4r8k3gerSsERYedmplx/A1zzhtsqUGoTdAx9UvzZs6M6UAT2K/dQJPVW+3+3yAWFHje++aiTo+UvP5XulDbhK4Ji1qlg9UTz6/qG+p9zS+UZVT8laV6IWhk6PkiD1EyWiOvkWArBtFVXHrJLBOdOi6gT7RN9CopS1LnCyS29BAqZJATVPuj3IYC3aQZ4QDCiYNonyDy5oBvSZRmVlUfugGJCeIfVN+E4xYMa0KiMk8kh3BIIJB/hTwk6t4d3ExUaom/AGw/dLbZMT6ySE8WGQqpkQ0+M9qtTAYMvPlKxThVPNAwKwTJE16eP9kF9QtKZ9IzJN+uXiKWXlkF9RGJN9LJ8OT6kezjmoN/RWQ5eDcup+Z+M8XFC674OG0/6nF6afkFvRsI//0HYRcXSv7ZzNnGzOqVOdssP7JQF8JXlYRIB3rr53yBVBymPZLcpPSg6nB/uNrtyI9mid/xrT3/UoVTqRNLXjKhR3lB55Ihm3lU4h5a/rSKdjPiUIvx5pPhNCMK4qi4OY3wmCR0byKugjl8NU1nE1fydMGabydjggGHCEax9wUV3Ih3HlwGiDMyBy7yydvMXNuqRHrg/8RhwfHCzVAG/CtPzphyyJQ1wKgzswJsybSeMf+CSO4IiOMeEWHzY/ZGtleA93MYAOvtJksq9+RwOuwcO4JidAx82r7Ljvo791hGwT0UHoy2Y0CzTg7jxaZJG9QwHKJiA22hlbyDdcF5GgA8duBLA8aDk4QAddvILmAMvMtJAqf6wZMIIqo82CkCT0GKwPCDH4ULfMQM3va8/iTht1EPan+nXwmbbUCgdo0z77TvatO/Re3CMMRONG9uI++uCRcnQQ9vGN2FbWus9gLdwkBe3hDH+Gm1lfqPyFwF++ONjTVoEecEXWV1riO5wQaUIPP+0p5GPgFX7y4eNM2OewJMorL/ImMaNcATqYlzchYVTxKC/6W8Kshw8lDqZcS4byQ+aMMqkI5S8pp5SHBSmmzxlCymGnl/bVJbtT0vwtwFyVPFCuwTaH4a9zLf5oL29yzEXEEwQhOgy5O7i4b5Z8hCuNEF4G1A5CqDWVhv2LeKRrXQEhKA3CnPKSspLXOWEcd454UcGw8nGt9h3ULXSmHNSzp53BoDNdlXSQHxQPvyK3zpihlSb8qjJBfcU1s6Rakq+z4yuICeA1OS4bgI9rISYxoyiN4DQtyeNI5c2M8P9j3AVC5e1Mr4s+YIYq1+3B2s8yf13EjK4QTjIyzfU9O6JPlOE6LGRalVBe297rNiEYEKk3zSYEA5pqwjUYECcXtikdSiOKASGRM6ZJOcmAUAv5hmlRrPCI1Znoy5N0W24iM4ukd32vbHO4NqXI1ZHJMENZWlQ5ETzZaFMiUv3fpleuIwzTLTiYqhcdYZhBBpM1gycbrcmv9U9DDm+TEPiisaWoEbHzpm/BqgEI07g2i03A4Ym8qh6BsC2+hVVLD0DYDp9t1dQtELbBd2vVVXcIhM3zDbuWmYQnfEYSnvAZSSjjoxPaB0JD+fY6EppUXy4TmsoHhKbyAaGpfEBoKt8noV/zfAV8xhH653yGEV7gM4rwIp9BhFf4jCG8ymcI4Rd8RhB+yWcAoYTv2wl18wGhqXxAaCofEJrKB4Sm8gGhqXxAaCqfZXWkhD5tftUaoal8QGgqHxCaygeEpvIBoal8QGgqHxCaygeEpvIBoal8QGgqHxCaygeEpvIBoal8n4TG8u0JDefbExrOtyc0nG9PaDjfntBwvj1h03z/ABD9FUIpArU6AAAAAElFTkSuQmCC",nx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIwAAACMCAMAAACZHrEMAAAAeFBMVEUAAAD///////////////////////////////////////////////////////////////////+Kior///+ZmZmRkZHw8PDFxcXT09Onp6fq6uq2trb4+Pjx8fG9vb2goKDi4uLMzMyvr6/39/fg4OC+vr7b29uYmJjRFtxTAAAAEnRSTlMAIN+A778QcGDPMJ9AkKCwUH/CxK06AAAEhUlEQVR42u2biZLaMAyGc5BACEcrxXEOjgW2u+//hjUsRdPJDLEti810+j3BP9Kvw04ccVgu0nKbJDM0zJIiK9Mfy+gbyBfr4iZiQLb+kUcvJP6Z4VOyeRy9hHyeoQXFQl7PqpyhLaWsnNXfQakb3Z8/PxUY1Oex7fVH93e6VhEhJ2X3fmgVEER7eEcik4lOXpKSxgh5xrnZiSZr/vDK+0HBKKp/JCyZR2GJs4eUFixpm4ecWCAsJMWO6o+cWbjg5Gv8Yt+CI+c9frEOlaLiblsNHuigqVomeKOrwItqH07N8m6XExB+wZmxJ/rinqIeGPQXvLEIomVPKWKkiqlmSVrCqGFkKv7yS6eAjeqYvokT0hJADa+mSEtANYXfTrr+8ouCQKi9fy+eD7wbyMVzX/PuKghIdbmZOPY0TA9B6fFK5pckDYE5UaJcq3oPweluiXKrqBKvkGEC26Z0CoxMkmiEuxxhMkpScPaOHl7hlTOI0FJo7APTgBBvTqGJ7d0rH5pSLjAUmtIlMC2I0VKvsVs1OxDkzb4NFzSUhDiQhW2ytFMgiLq14dh2RDYgSoOG1LbJnEGU1jJPOV4BOShP4/X0Aw3vIAfV08JuDT+AMAe71TyT6nhD0xTRGGQZSdStCVudrjsQp6aT94h/P0CcxsbBKe2bomibtreRG0zDE1Q5iWICOKNhazOyjyBOhYbE5lT7CTbIi5mhQYEo1Ggm0fMMeOW/mH9BzKSqKbHvM/I7xFZ+A6YOnE1i0fuz6k3goHLlgw6VI1czNYjT2dxE5PiSeaDQ6qxSSDuY/FvYHVVOIExD/h01zQ6Eqe0ur/LZC3a9Iy0Qz8lkV3LK0tbq4ko+T/X9oDKFPDlc6m3Ez3GN/XXnSrrvVS4XwYWwhTXtMuOk/CtGvn3JwqJ7RO/2oTIVHd21vX1pdPcgQo90CWzFRig0FBjnz4K/wPDtgTGhkSoodQ/MJL6YatfAUK+pIDAVugaGek0DgWn8/qFJJb7HHZHuFV3IE4Eb4Zqmkhur8OWt/X9Jy4J6mP6DYPyL9hbQvVTW7qRhE9WTe30oQiaqGrjXx8NvE0jSlXW4RB0YSaJmEyZR1eWRpO9PVE1J4ibqBEw0JYlDEWJGtchPErW+WrEMQ0liMufb5oN+FeSy5da3HmxUnPrm2eY4+CuZX991xTLMMuLDt01HVR2GzL/baBxcmbFt42viw8AwoR6J7I5+RxOMo6DMvUxc1SMdhjWkOiVkXnkTn3DsEwHzfYZ2LSQyb3gTY++2gM/iSIQFupRUdSHzSpA6lFRVk3ll2KDtcqNqepgiRF7YTqlOqpCGJdWMFrVcIQ0fg+mARc1/JqfHteAyEmeBY+2mRypqaVJ8voYekYpanvRp8ztePLTw2031pNltopdRkJqBlkGDkSb/S81QS5JHXPjvPVXNaTB8NQFfkfLf5QIQTC38XashLQ37jThfzRS0PAZDQ1rYr9X5ak60NLC18NVoAM0YjoGHptY+w1FKzSS0GDUT0mLUTEiLUTMhLUbNhLQYNRPSYtSE0fIbFg3xTdS8kE8AAAAASUVORK5CYII=",rx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIwAAACMCAMAAACZHrEMAAAAdVBMVEUAAAD/////////////////////////////////////////////////////////////////RET/////W1v/6Oj/oqL/ubn/c3P/UFD/8/P/3Nz/ior/0ND/5+f/ra3/f3//T0//lZX/lpb/Z2f/xcX/9PT/aGguCk8uAAAAEXRSTlMAIN+A77+fEHDPMEBgkLBfUGJvpxAAAASDSURBVHja7ZyJkpswDIa5Cbla2WAI5Gqyu+//iCUhjaYzmdhGEst0+j3BP9KvwyZOQGG5jrNtFCWqJ4mKNIt/LoNvIF9vikS9It38zIMJCeNUvSVdhMEk5ItUOVCs5fWsskS5ksnKWf0dlNJU3UnrM/Sc9bXuqo/273StAkROym5/qc/wivqyV0gqE508QyUGhbzkZHaiyVo8vbK/nMHKuXsmLFoEvITpU0oNjtTmKScUCAtKcUP/kZPwBSffqIFDDZ6cDmpgw5Wi4mHbCkZQsaZqGak7rYZR6AOfmuXDLke4QwhOQp7oPx4p6oBA9+g6P1i0HDSQ0AcGNUvUwqOGkKlw8Et7BjJNS/RNGKEWBjW0mkItjGqKcTvpZvDLGZhoDuN78eKNd0kuXow1704DI3p3N3E40jAdsNIN29+4JFXAzBET5VvVB2CnvSfKr6KGfRcNw2ybzCswMknCEe5zhEkxSewcPD28UjdOIEKNoXEPjAEh9l6hCd3dKx+aTC4wGJrMJzA1iFF79Jq16mlBkL17Gy5wKAlxQQu7ZGnXgCDNvQ2HriPSgChG9cSuTeYEotSOecrVDZAD82Svp5+qZw9yYD2t3dbwXyDMxW01T107Ht00RWADLSNJc2/CTqfrFsQp8eRt8e8HiGNcHBzjvilK5dL2MvfBRD9BZbMoJoCT6tm6jOwriKNVT+RyqtXggryYRPU0IAo2mln0vB5147+Yf0HMrKopcu8z8jvEVn4Dxg6czmLR+7PqzeCgcuMDD5WWq5kSxGldbiJyNck8aJTTWaWYxMEnLCarg48gjEH/Wk2zA2FKt8urPJlg17sOC4SddIKV3AxLp531BHkqHweVOeTJ41IvEz/HGffrzpV039M+F8GFsIUr3GXsxPQrRrp90cKie0Tn96EyFh3dpbt9cXR3IEKn8BLYiYwaGnpgkFA9XfPtgelDI1VQzSMws/hiWvkGBnuNBma08g0M9hoDzJhxv6GJJb7HXRXeK/qQRwI3wqVlKlmG9y9+966DEaTcHtaf6F5fwoT5a4/BsvYn5k1Uh+4dQ8GZKG1xr5uH9zNI0o0NX6IuhCRhs+FJlP58Jun7E1VikqiJOgKRCpNEoeCYUbWiJwlbX9mQDINJIrKg2+YDfypIZUut7wo3KjJ5RLPNF9sv/bG+S00yzDKgQ7dNi1XNQ4rdZpxhtgEfeTTWxJc3hqE9Etld/Y8m2GH4WIwysS4tHYY0pNpGyLzyJj4q/ETASxj5nr8ri3npJlad3wKehIEIa+VTUvoTzStB7FFSukTzypAp1+WmGbRsAjnywnVKta6FRC8pYy1qj0IiPwarGIua/kyusmtRy0CctbK1m05hUUsTq/dr6JfCopYnftv8vj4n1ILtRr9pdlkwGQWqea2lCKYjRzUvtUTT/mdG9HLXakpKg6GrYXxFSn+XC4AQtdB3LYNaDPmNOF3NHLQ8B4NBLR6X8VJqjrg0kLXQ1VQAFWE4Mg/NqiIMR3Y1s9DSq5mRll7NjLT0amakpVczIy29mhlp6dXwaPkN5W7InuRCZwAAAAAASUVORK5CYII=",ox="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAPElEQVR4AezXMQoAMAgDwND//9n2B51EhxNcQ7gtJ7NX0wWiAAECBAgQIECAAAECBAgQWCFQb6G3/Sc7FwAA//+f4+OPAAAABklEQVQDAI04ICFaxIVcAAAAAElFTkSuQmCC",ax="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwAgMAAACTeJdcAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAiSURBVDjLY2hgwA5GJUYliJBYhQMwOAwWF45KDEUJXOkKAA7xNyG+w0wTAAAAAElFTkSuQmCC",hx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAABgAgMAAAAm4hnjAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAjSURBVDjLY1gFBg4MQMAExGBqlDPKoS0HkuoGjXNGOcOVAwDBxwm1N3ts8gAAAABJRU5ErkJggg==",lx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAOklEQVR4AeySSQoAMAgDp/3/n9v4ABc8eRCSUyAwmgu8xIp9WYGfFpItgBk3OPpW5HAnMxBE0NciwAcAAP//bVPdOAAAAAZJREFUAwDM4hAZDjaEjwAAAABJRU5ErkJggg==",cx="/assets/doubleBed.CzextF6m.png",dx="/assets/sleep.C_YKDk6M.json",ux="/assets/sleep.CRKZ3XeQ.png",px="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M3%2014H21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M3%2011V14C3%2015.1046%203.89543%2016%205%2016H19C20.1046%2016%2021%2015.1046%2021%2014V11'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M6%2016V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M18%2016V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M4%2011C4%209.34315%205.34315%208%207%208H17C18.6569%208%2020%209.34315%2020%2011'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",fx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='12'%20cy='12'%20r='5'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M5%2010V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M19%2010V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M3%2012H7'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M17%2012H21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",gx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M3%2018V7C3%205.89543%203.89543%205%205%205H19C20.1046%205%2021%205.89543%2021%207V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M3%2014H21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M7%2010H10V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M14%2010H17V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M2%2018H22'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",mx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2018V7C4%205.89543%204.89543%205%206%205H18C19.1046%205%2020%205.89543%2020%207V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M4%2014H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M9%2010H15V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M3%2018H21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",yx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2019.5C4%2018.1193%205.11929%2017%206.5%2017H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M6.5%202H20V22H6.5C5.11929%2022%204%2020.8807%204%2019.5V4.5C4%203.11929%205.11929%202%206.5%202Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M8%206H16'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M8%2010H16'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",xx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6%208V18C6%2019.6569%207.34315%2021%209%2021H15C16.6569%2021%2018%2019.6569%2018%2018V8H6Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M4%208H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M9%205V8'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M15%205V8'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M12%203V8'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Sx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7%207C7%204.23858%209.23858%202%2012%202C14.7614%202%2017%204.23858%2017%207V17H7V7Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M7%2013H17'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3ccircle%20cx='12'%20cy='10'%20r='1'%20fill='white'/%3e%3cpath%20d='M5%2017H19V20C19%2021.1046%2018.1046%2022%2017%2022H7C5.89543%2022%205%2021.1046%205%2020V17Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",vx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='5'%20y='4'%20width='14'%20height='16'%20rx='2'%20stroke='white'%20stroke-width='1.5'/%3e%3ccircle%20cx='12'%20cy='12'%20r='3'%20stroke='white'%20stroke-width='1.5'/%3e%3ccircle%20cx='12'%20cy='7'%20r='1'%20fill='white'/%3e%3c/svg%3e",bx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7%2010H17V15C17%2016.1046%2016.1046%2017%2015%2017H9C7.89543%2017%207%2016.1046%207%2015V10Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linejoin='round'/%3e%3cpath%20d='M5%2010V14C5%2015.1046%205.89543%2016%207%2016'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M19%2010V14C19%2015.1046%2018.1046%2016%2017%2016'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M8%2017V19'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M16%2017V19'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3c/svg%3e",wx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%206H20V18H4V6Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linejoin='round'/%3e%3cpath%20d='M10%206V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M4%2012H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3c/svg%3e",Ax="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='12'%20cy='8'%20r='4'%20stroke='white'%20stroke-width='1.5'/%3e%3cpath%20d='M8%2012L5%2018H19L16%2012'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3ccircle%20cx='9'%20cy='8'%20r='0.5'%20fill='white'/%3e%3ccircle%20cx='15'%20cy='8'%20r='0.5'%20fill='white'/%3e%3c/svg%3e",Cx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%203V5M12%2019V21M21%2012H19M5%2012H3M18.36%205.64L16.95%207.05M7.05%2016.95L5.64%2018.36M18.36%2018.36L16.95%2016.95M7.05%207.05L5.64%205.64M16%2012C16%2014.2091%2014.2091%2016%2012%2016C9.79086%2016%208%2014.2091%208%2012C8%209.79086%209.79086%208%2012%208C14.2091%208%2016%209.79086%2016%2012Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Px="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6%203V21M18%203V21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M6%2012H18'%20stroke='white'%20stroke-width='1.5'%20stroke-dasharray='2%202'/%3e%3c/svg%3e",Mx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2011V17H20V11'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M8%2011V17M12%2011V17M16%2011V17'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M4%2011H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M6%207L18%207'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3c/svg%3e",_x="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6%207H4V17H6V7Z'%20fill='white'/%3e%3cpath%20d='M20%207H18V17H20V7Z'%20fill='white'/%3e%3crect%20x='6'%20y='11'%20width='12'%20height='2'%20fill='white'/%3e%3crect%20x='16'%20y='8'%20width='2'%20height='8'%20fill='white'/%3e%3crect%20x='6'%20y='8'%20width='2'%20height='8'%20fill='white'/%3e%3c/svg%3e",Tx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%205V19'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M8%208H16'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M8%2012H16'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M10%205L12%203L14%205'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",kx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M3%209.5L12%203L21%209.5V20C21%2020.5523%2020.5523%2021%2020%2021H4C3.44772%2021%203%2020.5523%203%2020V9.5Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M9%2021V12H15V21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",gi="system-ui, -apple-system, sans-serif",Rx=["#a8c8f5","#9de5c7","#d4b9f7","#ffd399"],Ex=["#d6e7fc","#d1f4e5","#ece0fb","#fff0d9"],Pn=["#2563b8","#26966b","#7c3fb8","#d97706"],Ua={global:{containerTop:"0px",containerLeft:"0px",containerWidth:"100%",containerHeight:"100%",backgroundColor:"#f6f6f6",backgroundAlpha:1,performanceMode:!1,resolution:window.devicePixelRatio||1,enableLogger:!1,rendererPreference:"webgpu"},map:{autoPaddingHorizontalPercent:.05,autoPaddingVerticalPercent:.05,adjacencyThreshold:3,originChangeAutoFitThreshold:2,sizeChangeAutoFitThreshold:10,obstacleColor:"#999999",freeColor:"#ebebeb",autoFitOffset:{x:0,y:0}},room:{colors:{sortBy:"index",strategy:"priority",active:[...Rx],inactive:[...Ex],name:[...Pn],propertyTheme:[...Pn],selectionIndicatorBackground:[...Pn],selectionIndicatorIcon:["#ffffff","#ffffff","#ffffff","#ffffff"],[oe.NO_ROOM_DATA]:"#ebebeb",[oe.ROOM_GAP]:"#ebebeb",[oe.OBSTACLE_ROOM]:"#ebebeb",[oe.UNKNOWN_ROOM]:"#ebebeb",[oe.VERSION0_ROOM]:""},nameLabel:{fontSize:12,fontFamily:gi,fontWeight:"500"},type:{assets:[kx,px,fx,gx,mx,yx,xx,Sx,vx,bx,wx,Ax,Cx,Px,Mx,_x,Tx],iconSize:12,gap:4,position:"left",container:{visible:!0,size:16,borderRadius:16}},property:{displayOrders:["cleanMode","suction","cistern","cleanTimes"],iconWidth:14,iconHeight:14,foldable:!0,offsetX:0,offsetY:6,iconGap:0,container:{backgroundColor:"#ffffff",paddingVertical:2,paddingHorizontal:2,borderRadius:16,tailHeight:2,tailWidth:8},suction:{assets:[Fy,zy,Ly,Oy,Gy]},cistern:{assets:[Wy,Uy,Hy,Vy]},cleanMode:{assets:[Ny,jy,Yy,Xy]},cleanTimes:{assets:[Zy,qy]},cleanOrder:{color:"#ffffff",fontFamily:gi,fontWeight:"400",fontSize:10,gapRight:2}},selectionIndicator:{iconSrc:tx,iconWidth:14,iconHeight:14,containerWidth:16,containerHeight:16,strokeWidth:2,strokeColor:"#ffffff",borderRadius:16,offsetY:4,offsetX:0,tailHeight:2,tailWidth:6},floorType:{assets:["",ox,ax,hx],opacity:.1,scale:.2},enableElasticScale:!1,elasticMinScale:.6,elasticMaxScale:1.5},path:{lineWidthFixed:!1,incrementalThreshold:5,commonPath:{visible:!0,color:"#ffffff",width:.5},transitionPath:{visible:!1,color:"#ffffff",width:.5},chargePath:{visible:!1,color:"#ffffff",width:.5},mopPath:{lineVisible:!0,lineColor:"#ffffff",lineWidth:.5,trackVisible:!0,trackColor:"#ffffff",trackAlpha:.4,trackWidth:4}},carpet:{src:lx,opacity:.5,scale:.2},robot:{icon:{sizeFixed:!1,width:8,height:8,src:Dy},speed:0,rotationCorrection:0,sleepAnimation:{jsonSrc:dx,imageSrc:ux,framePrefix:"sleep_",width:16,height:16,sizeFixed:!1,frameCount:96,offsetX:8,offsetY:-8},ring:{size:1,color:"rgba(255, 68, 68, 0.2)",strokeWidth:1,strokeColor:"#ffffff",strokeDashed:!0,strokeDashArray:[4,4]},pulseCircle:{size:12,color:"#4cd964",strokeWidth:0,strokeColor:"#ffffff",duration:1e3,sizeFixed:!1,minScale:.5,maxScale:1,minAlpha:.5,maxAlpha:1}},chargingStation:{icon:{sizeFixed:!1,width:8,height:8,src:By},rotationCorrection:0,ring:{size:1,color:"rgba(255, 68, 68, 0.2)",strokeWidth:1,strokeColor:"#ffffff",strokeDashed:!0,strokeDashArray:[4,4]}},interaction:{zoomRange:{min:.5,max:8},fitMinScale:1,fitMaxScale:4,enable:!0,enableDoubleTapZoom:!0,enableRobotClick:!1,enableChargingStationClick:!1},controls:{iconWrapperWidth:24,iconWrapperHeight:24,iconWrapperBorderRadius:16,iconWidth:12,iconHeight:12,deleteIconSrc:$y,rotateIconSrc:Qy,scaleIconSrc:Ky,moveIconSrc:Jy,horizontalScaleIconSrc:ex,verticalScaleIconSrc:ix,moveButtonOffset:30,textFontSize:12,textFontFamily:gi,textFontWeight:"400",renderOrder:["forbiddenSweepZone","forbiddenMopZone","cleanZone","virtualWall","spot","wayPoint","divider"],forbiddenSweepZone:{minSize:1,iconWrapperFillColor:"#ff4444",strokeColor:"#ff4444",strokeWidth:2,fillColor:"rgba(255, 68, 68, 0.1)",outlineOffset:16,outlineStrokeColor:"#ff4444",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(255, 68, 68, 0.05)",showRotateButton:!0,textColor:"#ff4444",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},forbiddenMopZone:{minSize:1,iconWrapperFillColor:"#fe8a07",strokeColor:"#fe8a07",strokeWidth:2,fillColor:"rgba(254, 138, 7, 0.1)",outlineOffset:16,outlineStrokeColor:"#fe8a07",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(254, 138, 7, 0.05)",showRotateButton:!0,textColor:"#fe8a07",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},carpet:{minSize:1,iconWrapperFillColor:"#5d68fe",strokeColor:"#5d68fe",strokeWidth:2,fillColor:"rgba(93, 104, 254, 0.1)",outlineOffset:30,outlineStrokeColor:"rgba(0, 0, 0, 0.7)",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(93, 104, 254, 0.05)",showRotateButton:!0,enableFreeRotate:!1,textColor:"#5d68fe",textPosition:"bottom",textOffset:20,editing:{isDashed:!0,dashArray:[4,3]},normal:{isDashed:!1,dashArray:[0,0]}},cleanZone:{minSize:1,iconWrapperFillColor:"#5d68fe",strokeColor:"#5d68fe",strokeWidth:2,fillColor:"rgba(93, 104, 254, 0.1)",outlineOffset:16,outlineStrokeColor:"#5d68fe",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(93, 104, 254, 0.05)",showRotateButton:!0,textColor:"#5d68fe",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},virtualWall:{iconWrapperFillColor:"#ff4444",lineWidth:2,lineColor:"#ff4444",hitAreaThickness:30,outlineOffset:16,outlineStrokeColor:"#ff4444",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(255, 68, 68, 0.05)",minWidth:1,textColor:"#ff4444",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},spot:{iconSrc:sx,iconSize:8,iconSizeFixed:!1,size:1,strokeColor:"#5d68fe",strokeWidth:2,fillColor:"rgba(93, 104, 254, 0.1)",showText:!0,textColor:"#5d68fe",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0],showIcon:!0,showFrame:!0},normal:{isDashed:!1,dashArray:[0,0],showIcon:!1,showFrame:!0}},wayPoint:{showOrder:!0,normal:{iconSrc:nx,iconSize:32,orderText:{fontSize:10,fontFamily:gi,fontWeight:"600",color:"#8a8a8a"},orderContainer:{size:12,backgroundColor:"#ffffff",offsetY:20,offsetX:0}},editing:{iconSrc:rx,iconSize:38,orderText:{fontSize:14,fontFamily:gi,fontWeight:"600",color:"#ff4444"},orderContainer:{size:16,backgroundColor:"#ffffff",offsetY:23,offsetX:0}}}},furniture:{assets:[{type:1,src:cx,width:1.8,height:2}],opacity:1,iconWrapperFillColor:"#26a69a",outlineOffset:16,outlineStrokeColor:"#26a69a",outlineStrokeWidth:1.5,outlineFillColor:"rgba(38, 166, 154, 0.05)",outlineDashed:!0,outlineDashArray:[4,3],showSizeText:!0,textColor:"#26a69a",textPosition:"bottom",textOffset:8,minScaleRatio:.5,maxScaleRatio:2,rotateDirection:"cw"},divider:{lineColor:"#ff4444",dashLineWidth:2,dashLineDashArray:[4,3],solidLineWidth:2,endPointSize:12,endPointColor:"#ff4444",endPointStrokeColor:"#ffffff",endPointStrokeWidth:2,hitAreaThickness:30,resetDividerWhenOutOfRoom:!1,defaultExtension:20,defaultDirection:"horizontal"},detectedObject:{height:43,width:38,interactive:!1,anchor:{x:.5,y:.5}},heatmap:{cellSize:2,maxDistance:14,smoothIterations:10,heatmapAlpha:.8,useGradient:!0,colorGradients:["#FF3B30","#FF7A00","#FFA100","#FFD700","#99DD70","#2EC070","#40E0D0","#88D0E9"]},snapshot:{format:"png",quality:1,antialias:!0,resolution:4}},Ix={dividingRoomId:-1,enableRoomSelection:!1,enableInteraction:!0,enableMapClickCapture:!1,editingForbiddenSweepZoneIds:[],editingForbiddenMopZoneIds:[],editingCleanZoneIds:[],editingVirtualWallIds:[],editingSpotIds:[],editingWayPointIds:[],editingCarpetIds:[],editingFurnitureIds:[],roomPropertyFoldIds:[],roomSelectionMode:"checkmark",mapRotation:0,selectRoomIds:[],showRoomProperty:!1,showRoomOrder:!0,showRoomName:!0,showRoomType:!0,showPath:!0,showRobot:!0,showChargingStation:!0,showRoomFloorType:!0,showCarpet:!0,showDetectedObjects:!0,showChargingStationRing:!1,showRobotRing:!1,showRobotSleepAnimation:!1,showRobotPulseCircle:!1,unit:"meter",unitLabel:"m",selectedCarpetIds:[]},Ha="MAIN",re=5e3;function Bx(r){return{all:r=r||new Map,on:function(t,e){var i=r.get(t);i?i.push(e):r.set(t,[e])},off:function(t,e){var i=r.get(t);i&&(e?i.splice(i.indexOf(e)>>>0,1):r.set(t,[]))},emit:function(t,e){var i=r.get(t);i&&i.slice().map(function(s){s(e)}),(i=r.get("*"))&&i.slice().map(function(s){s(t,e)})}}}class ic{constructor(t){this.app=t}getApp(){return this.app}getConfig(){return this.getApp().config}getDebuggerMode(){return!1}getRoomData(t){return this.getApp().managers.roomsManager.getRoomPropertyById(t)}metersToPixels(t){return this.getApp().metersToPixels(t)}pixelsToMeters(t){return this.getApp().pixelsToMeters(t)}metersToDisplayUnit(t){const{unit:e}=this.runtimeSnapshot;switch(e){case"feet":return t*3.28084;case"centimeter":return t*100;case"meter":default:return t}}get ticker(){return this.getApp().ticker}get mapState(){return this.getApp().mapState}get isMapDrawn(){return this.getApp().isMapDrawn}get config(){return this.getConfig()}get gloalConfig(){return this.getConfig().global}get mapConfig(){return this.getConfig().map}get roomConfig(){return this.getConfig().room}get heatMapConfig(){return this.getConfig().heatmap}get pathConfig(){return this.getConfig().path}get carpetConfig(){return this.getConfig().carpet}get robotConfig(){return this.getConfig().robot}get chargingStationConfig(){return this.getConfig().chargingStation}get interactionConfig(){return this.getConfig().interaction}get controlsConfig(){return this.getConfig().controls}get furnitureConfig(){return this.getConfig().furniture}get dividerConfig(){return this.getConfig().divider}get detectedObjectConfig(){return this.getConfig().detectedObject}get snapshotConfig(){return this.getConfig().snapshot}get appContainer(){return this.getApp().components.appContainer}get interaction(){return this.getApp().components.interaction}get viewportContainer(){return this.getApp().components.viewportContainer}get mapManager(){return this.getApp().managers.mapManager}get pathManager(){return this.getApp().managers.pathManager}get heatmapManager(){return this.getApp().managers.heatmapManager}get controlsManager(){return this.getApp().managers.controlsManager}get detectedObjectManager(){return this.getApp().managers.detectedObjectManager}get customElementsManager(){return this.getApp().managers.customElementsManager}get roomsManager(){return this.getApp().managers.roomsManager}get editControlManager(){return this.getApp().managers.editControlManager}get furnitureManager(){return this.getApp().managers.furnitureManager}get runtime(){return this.getApp().runtime}get runtimeSnapshot(){return Ey(this.getApp().runtime)}isInteractionEnabled(){return this.runtimeSnapshot.enableInteraction}fixPrecision(t,e){return Xl(t,e)}get events(){return this.getApp().events}get baseScale(){return this.getApp().components.interaction.targetScale.x}get currentScale(){return this.getApp().components.appContainer.scale.x}get emitter(){return this.getApp().emitter}getChargerPosition(){const t=this.mapState;return t?this.fixPrecision({x:t.charger.x-t.origin.x,y:t.charger.y-t.origin.y}):null}getRobotPosition(){const t=this.pathManager.robot;return t?t.getCurrentPosition():null}}let Dx="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Fx=(r=21)=>{let t="",e=r|0;for(;e--;)t+=Dx[Math.random()*64|0];return t};class zx extends L{constructor(e,i){super();g(this,"viewportBounds",{x:0,y:0,width:0,height:0});g(this,"maskGraphics",null);g(this,"containerElement",null);this.containerElement=i||window,this.calculateViewportBounds(e.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),this.createMask()}calculateViewportBounds(e){const{containerTop:i,containerLeft:s,containerWidth:n,containerHeight:o}=e,{width:a,height:h}=this.getContainerSize(),l=this.parseSize(s,a),c=this.parseSize(i,h),d=this.parseSize(n,a),u=this.parseSize(o,h);this.viewportBounds={x:l,y:c,width:d,height:u}}getContainerSize(){if(!this.containerElement)return{width:window.innerWidth,height:window.innerHeight};if(this.containerElement===window)return{width:window.innerWidth,height:window.innerHeight};const e=this.containerElement;return{width:e.clientWidth||window.innerWidth,height:e.clientHeight||window.innerHeight}}createMask(){this.maskGraphics=new H,this.maskGraphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215),this.addChild(this.maskGraphics),this.mask=this.maskGraphics}parseSize(e,i){if(!isNaN(Number(e)))return Number(e);if(e=e.trim(),e.endsWith("%")){const s=parseFloat(e)/100;return i*s}if(e.endsWith("vw")){const s=parseFloat(e)/100;return window.innerWidth*s}if(e.endsWith("vh")){const s=parseFloat(e)/100;return window.innerHeight*s}if(e.endsWith("rpx")){const s=parseFloat(e),n=window.innerWidth/750;return s*n}return e.endsWith("px")||!isNaN(parseFloat(e))?parseFloat(e):(A.warn(`Cannot parse size value: ${e}`),0)}getViewportBounds(){return{...this.viewportBounds}}updateViewport(e){var i,s;this.calculateViewportBounds(e.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),(i=this.maskGraphics)==null||i.clear(),(s=this.maskGraphics)==null||s.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215)}addContent(e){this.addChild(e)}}const Lx="interaction",sc="roomFill",nc="free",Fr="roomFloorType",rc="carpet",oc="obstacle",ac="heatmap",hc="path",ds="furniture",Ne="controls",lc="roomInfo",We="detectedObject",Si="customElement",vi="customElementGif",cc="chargingStation",dc="robot",us="customCarpet",Ti="editControls",Ox=[Lx,sc,nc,Fr,rc,us,oc,ac,hc,ds,lc,We,Si,vi,cc,dc,Ne,Ti];class Gx extends L{constructor(e){super();g(this,"layers",new Map);g(this,"mapRotation",0);g(this,"backgroundGraphics");g(this,"lastBackgroundState",null);this.appService=e;const s=this.appService.getApp().getViewportBounds();this.position.set(Math.round(s.width/2),Math.round(s.height/2)),this.pivot.set(0,0),this.backgroundGraphics=new H,this.backgroundGraphics.label="snapshotBackground",this.backgroundGraphics.visible=!1,this.addChild(this.backgroundGraphics),this.initializeLayers()}initializeLayers(){Object.values(Ox).forEach(i=>{const s=new L;s.label=i,i===Ne&&(s.isRenderGroup=!0),i===Ti&&(s.isRenderGroup=!0),i===Fr&&(s.eventMode="none"),this.layers.set(i,s),this.addChild(s)})}getLayer(e){return this.layers.get(e)}addToLayer(e,i,s){const n=this.layers.get(e);return n?(s!==void 0&&(i.zIndex=s),n.addChild(i),!0):(A.warn("[AppContainer Debug] Layer not found:",e),!1)}removeFromLayer(e,i){const s=this.layers.get(e);return s&&i.parent===s?(s.removeChild(i),!0):!1}clearLayer(e){const i=this.layers.get(e);return i?(i.removeChildren(),!0):!1}setLayerVisibility(e,i){const s=this.layers.get(e);return s?(s.visible=i,!0):!1}getLayerVisibility(e){const i=this.layers.get(e);return i?i.visible:!1}setMapRotation(e){this.mapRotation=e*Math.PI/180,this.rotation=this.mapRotation}getMapRotation(){return this.mapRotation*180/Math.PI}getMapRotationRadians(){return this.mapRotation}getSnapshotBounds(){this.layers.forEach(s=>{});const e=this.backgroundGraphics.visible;this.backgroundGraphics.visible=!1;const i=this.getLocalBounds();return this.backgroundGraphics.visible=e,new et(i.x,i.y,i.width,i.height)}updateBackground(e,i){if(!i){this.backgroundGraphics.visible=!1,this.lastBackgroundState=null;return}const s=this.getSnapshotBounds(),{x:n,y:o,width:a,height:h}=s;if(this.lastBackgroundState&&this.lastBackgroundState.color===e&&this.lastBackgroundState.width===a&&this.lastBackgroundState.height===h&&this.lastBackgroundState.x===n&&this.lastBackgroundState.y===o){this.backgroundGraphics.visible=!0;return}this.backgroundGraphics.clear(),this.backgroundGraphics.rect(n,o,a,h).fill(e),this.backgroundGraphics.visible=!0,this.lastBackgroundState={color:e,x:n,y:o,width:a,height:h}}}class Xt extends jt{constructor(e,i){super(i);g(this,"throttledUpdateScale");g(this,"fixedWidth",0);g(this,"fixedHeight",0);g(this,"isFixedSizeSet",!1);g(this,"sizeFixed",!0);g(this,"baselineScale",1);this.appService=e,this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=At(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(e,i){this.fixedWidth=e,this.fixedHeight=i,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(e){this.sizeFixed=e,this.baselineScale=1,e&&this.isFixedSizeSet?this.applySize():!e&&this.isFixedSizeSet&&this.applySize()}set width(e){if(this.isFixedSizeSet){A.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置宽度");return}this.setFixedSize(e,this.fixedHeight||e)}set height(e){if(this.isFixedSizeSet){A.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置高度");return}this.setFixedSize(this.fixedWidth||e,e)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(this.destroyed||!this.scale||!this.isFixedSizeSet||!this.texture||this.texture.width===0||this.texture.height===0)return;const e=this.appService,i=this.fixedWidth/this.texture.width,s=this.fixedHeight/this.texture.height;if(this.sizeFixed){const n=e.currentScale;if(n===0)return;const o=i/n,a=s/n;this.scale&&super.scale.set(o,a)}else this.scale&&super.scale.set(i/this.baselineScale,s/this.baselineScale)}updateScale(e){this.destroyed||!this.scale||this.sizeFixed&&(this.isFixedSizeSet?this.applySize():e!==0&&super.scale.set(1/e))}async loadTextureAndSetSize(e,i){try{const s=this.appService,n=await N.load(e);if(this.destroyed||(this.texture=n,this.destroyed)||(i.sizeFixed!==void 0&&this.setSizeFixed(i.sizeFixed),this.setFixedSize(i.width,i.height),this.destroyed))return;s.getApp().renderOnceNextFrame()}catch(s){A.error(`Failed to load texture "${e}":`,s)}}draw(e,i){const{x:s,y:n,rotation:o=0}=e;i&&!this.visible?this.visible=i():!i&&!this.visible&&(this.visible=!0),this.rotation=o,this.position.set(s,n)}set texture(e){super.texture=e,this.isFixedSizeSet&&e&&e.width>0&&e.height>0&&this.applySize()}get texture(){return super.texture}destroy(e){this.appService.emitter.off("antiScale",this.throttledUpdateScale),this.throttledUpdateScale.cancel(),super.destroy(e)}}class Wx extends Xt{constructor(t){super(t),this.appService=t,this.initializeSprite()}async initializeSprite(){const t=this.appService;await this.loadTextureAndSetSize("chargingStation",t.chargingStationConfig.icon)}async draw({x:t,y:e,rotation:i}){const s=this.appService;super.draw({x:t,y:e,rotation:i},()=>s.runtimeSnapshot.showChargingStation)}}class uc extends H{constructor(e,i){super();g(this,"currentPosition",null);g(this,"config");g(this,"handleScaleChange",()=>{this.redraw()});this.appService=e,this.setupAntiScaleListener(),this.config=i.config}setupAntiScaleListener(){this.appService.emitter.on("antiScale",this.handleScaleChange)}draw(e){const i=this.appService;this.currentPosition=e;const{size:s,color:n,strokeWidth:o,strokeColor:a,strokeDashed:h,strokeDashArray:l}=this.config;this.clear();const c=i.metersToPixels(s),d=i.getApp().toFixedSize(o);this.setFillStyle({color:n}),h&&l.length>=2?this.drawDashedCircle(e,c,a,d,l):this.circle(e.x,e.y,c).fill().stroke({color:a,width:d,cap:"round",join:"round"})}drawDashedCircle(e,i,s,n,o){const a=this.appService;this.circle(e.x,e.y,i).fill();const h=a.getApp().toFixedSize(o[0]),l=a.getApp().toFixedSize(o[1]),c=2*Math.PI*i,d=h+l,u=Math.floor(c/d);if(u===0){this.circle(e.x,e.y,i).stroke({color:s,width:n,cap:"round",join:"round"});return}const p=c/u,f=p*(h/d);for(let y=0;y<u;y++){const m=y*p/i,x=(y*p+f)/i,S=Math.max(4,Math.ceil(Math.abs(x-m)*i/2)),v=(x-m)/S;for(let b=0;b<=S;b++){const P=m+v*b,w=e.x+i*Math.cos(P),C=e.y+i*Math.sin(P);b===0?this.moveTo(w,C):this.lineTo(w,C)}}this.stroke({color:s,width:n,cap:"round",join:"round"})}redraw(){this.currentPosition&&this.draw(this.currentPosition)}destroy(){this.appService.emitter.off("antiScale",this.handleScaleChange),super.destroy()}}class vt{constructor(t,e={}){g(this,"target");g(this,"isPointerDown",!1);g(this,"pointerDownPos",null);g(this,"clickThreshold");g(this,"stopPropagation");g(this,"clickCallback",null);this.target=t,this.clickThreshold=e.clickThreshold??10,this.stopPropagation=e.stopPropagation??!1,this.clickCallback=e.onClick||null,this.setup()}setup(){this.target.interactive=!0,this.target.eventMode="static",this.target.on("pointerdown",this.handlePointerDown.bind(this)),this.target.on("pointermove",this.handlePointerMove.bind(this)),this.target.on("pointerup",this.handlePointerUp.bind(this)),this.target.on("pointerupoutside",this.handlePointerUpOutside.bind(this))}handlePointerDown(t){this.stopPropagation&&t.stopPropagation(),this.isPointerDown=!0,this.pointerDownPos={x:t.globalX,y:t.globalY}}handlePointerMove(t){if(this.stopPropagation&&t.stopPropagation(),this.isPointerDown&&this.pointerDownPos){const e=t.globalX-this.pointerDownPos.x,i=t.globalY-this.pointerDownPos.y;Math.sqrt(e*e+i*i)>this.clickThreshold&&(this.isPointerDown=!1,this.pointerDownPos=null)}}handlePointerUp(t){if(this.stopPropagation&&t.stopPropagation(),this.isPointerDown&&this.pointerDownPos){const e=t.globalX-this.pointerDownPos.x,i=t.globalY-this.pointerDownPos.y;Math.sqrt(e*e+i*i)<=this.clickThreshold&&this.clickCallback&&this.clickCallback(t,this.target)}this.isPointerDown=!1,this.pointerDownPos=null}handlePointerUpOutside(){this.isPointerDown=!1,this.pointerDownPos=null}setClickCallback(t){return this.clickCallback=t,this}setClickThreshold(t){return this.clickThreshold=t,this}getTarget(){return this.target}isInteracting(){return this.isPointerDown}destroy(){this.target.off("pointerdown",this.handlePointerDown),this.target.off("pointermove",this.handlePointerMove),this.target.off("pointerup",this.handlePointerUp),this.target.off("pointerupoutside",this.handlePointerUpOutside),this.clickCallback=null}}class Ux extends L{constructor(e){super();g(this,"chargingStation");g(this,"ring");g(this,"unsubscribeFns",[]);g(this,"clickHandler");this.appService=e,e.appContainer.addToLayer(cc,this),this.ring=new uc(this.appService,{config:this.appService.chargingStationConfig.ring}),this.ring.visible=this.appService.runtimeSnapshot.showChargingStationRing,this.addChild(this.ring),this.chargingStation=new Wx(this.appService),this.addChild(this.chargingStation);const i=U(this.appService.runtime,"showChargingStationRing",s=>{A.log(`[runtime] showChargingStationRing: ${s}`),this.ring.visible=s});this.unsubscribeFns.push(i),this.initClickInteraction()}async draw({x:e,y:i,rotation:s}){if(e===0&&i===0){this.visible=!1;return}this.visible=!0,this.ring.draw({x:e,y:i}),await this.chargingStation.draw({x:e,y:i,rotation:s})}initClickInteraction(){const{enableChargingStationClick:e}=this.appService.interactionConfig;e&&(this.clickHandler||(this.clickHandler=new vt(this.chargingStation,{onClick:()=>{var i;if((i=this.appService.events)!=null&&i.onClickChargingStation){const s=this.appService.getChargerPosition()??{x:0,y:0};this.appService.events.onClickChargingStation({rotation:this.chargingStation.rotation,...s})}}})))}destroy(){this.unsubscribeFns.forEach(e=>e()),this.unsubscribeFns=[],this.ring.destroy(),this.clickHandler&&this.clickHandler.destroy(),super.destroy()}}class Hx extends L{constructor(e){super({isRenderGroup:!0});g(this,"carpetSprite",null);g(this,"carpetMask",null);this.appService=e,this.appService.appContainer.addToLayer(rc,this)}async createCarpetFromRasterData(e,i){const s=this.appService;if(!s.runtimeSnapshot.showCarpet||(this.clearCarpet(),e.length===0))return;const{src:n,opacity:o,scale:a}=s.carpetConfig,h=await N.load(n);if(!h){A.warn(`Carpet texture not found: ${n}`);return}const l=this.createCarpetGraphics(e,i),c=l.getLocalBounds();if(c.width===0||c.height===0)return;const d=new Ss({texture:h,width:c.width,height:c.height});d.x=c.x,d.y=c.y,d.alpha=o,d.tileScale.set(a);const u=new L;u.addChild(l),d.mask=u,this.addChild(d),this.carpetSprite=d,this.carpetMask=u,s.getApp().renderOnceNextFrame()}createCarpetGraphics(e,i){const s=new H;for(let n=0;n<e.length;n++){const o=e[n],a=o%i,h=Math.floor(o/i);s.rect(a,h,1,1)}return s.fill(16777215),s}clearCarpet(){this.carpetSprite&&(this.removeChild(this.carpetSprite),this.carpetSprite.destroy(),this.carpetSprite=null),this.carpetMask&&(this.carpetMask.destroy({children:!0}),this.carpetMask=null)}async createCarpetFromStructuredData(e){const i=this.appService;if(!i.runtimeSnapshot.showCarpet||!e||(this.clearCarpet(),e.length===0))return;const{src:s,opacity:n,scale:o}=i.carpetConfig,a=await N.load(s);if(!a){A.warn(`Carpet texture not found: ${s}`);return}const h=this.createCarpetGraphicsFromStructuredData(e),l=h.getLocalBounds();if(l.width===0||l.height===0)return;const c=new Ss({texture:a,width:l.width,height:l.height});c.x=l.x,c.y=l.y,c.alpha=n,c.tileScale.set(o);const d=new L;d.addChild(h),c.mask=d,this.addChild(c),this.carpetSprite=c,this.carpetMask=d,i.getApp().renderOnceNextFrame()}createCarpetGraphicsFromStructuredData(e){const i=new H;for(const s of e){const n=s.coordinates;for(let o=0;o<n.length;o+=2){const a=n[o],h=n[o+1];i.rect(a,h,1,1)}}return i.fill(16777215),i}destroy(){this.clearCarpet(),super.destroy()}}class Va extends H{constructor(t){super(),this.appService=t,this.appService.appContainer.addToLayer(nc,this)}draw(t){const e=this.appService;this.clear(),this.setFillStyle({color:e.mapConfig.freeColor});for(const i of t){const s=i.coordinates;for(let n=0;n<s.length;n+=2){const o=s[n],a=s[n+1];this.rect(o,a,1,1)}}this.fill()}destroy(t){super.destroy(t)}}class Na extends H{constructor(t){super(),this.appService=t,this.appService.appContainer.addToLayer(oc,this)}draw(t){const e=this.appService;this.clear(),this.setFillStyle({color:e.mapConfig.obstacleColor});for(const i of t){const s=i.coordinates;for(let n=0;n<s.length;n+=2){const o=s[n],a=s[n+1];this.rect(o,a,1,1)}}this.fill()}drawRaster(t,e){const i=this.appService;if(this.clear(),t.length!==0){this.setFillStyle({color:i.mapConfig.obstacleColor});for(let s=0;s<t.length;s+=re){const n=Math.min(s+re,t.length);for(let o=s;o<n;o++){const a=t[o],h=a%e,l=Math.floor(a/e);this.rect(h,l,1,1)}this.fill(),n<t.length&&this.setFillStyle({color:i.mapConfig.obstacleColor})}}}destroy(t){super.destroy(t)}}class ja extends L{constructor(e){super({isRenderGroup:!0});g(this,"roomGraphicsMap",new Map);g(this,"roomContextMap",new Map);g(this,"roomClickHandlerMap",new Map);g(this,"unsubscribeFns",[]);g(this,"mapWidth",0);g(this,"rasterRoomDataMap",new Map);g(this,"structuredRoomGeometry",new Map);this.appService=e,this.appService.appContainer.addToLayer(sc,this);const i=Bs(this.appService.config.room.colors,()=>{this.refreshRoomColors()});this.unsubscribeFns.push(i)}draw(e){const i=this.appService;this.clearRooms();const s=i.roomConfig,{selectRoomIds:n,enableRoomSelection:o}=i.runtimeSnapshot;e.forEach(a=>{const h=a.id>=255,l=new H,c=new mt,d=new mt,u=new mt;if(h)c.setFillStyle({color:a.color}),d.setFillStyle({color:a.color}),u.setFillStyle({color:a.color});else{const p=a.colorIndex??0,f=s.colors.active[p%s.colors.active.length],y=s.colors.inactive[p%s.colors.inactive.length],m=(s.colors.normal||s.colors.active)[p%(s.colors.normal||s.colors.active).length];c.setFillStyle({color:f}),d.setFillStyle({color:y}),u.setFillStyle({color:m})}if(c.poly(a.polyPoints).fill(),d.poly(a.polyPoints).fill(),u.poly(a.polyPoints).fill(),a.outlinePoints.forEach(p=>{c.rect(p.x,p.y,1,1).fill(),d.rect(p.x,p.y,1,1).fill(),u.rect(p.x,p.y,1,1).fill()}),h?l.context=c:l.context=o?n.includes(a.id)?c:d:u,!h){const p=new vt(l,{clickThreshold:10,onClick:()=>{this.handleRoomClick(a.id)}});this.roomClickHandlerMap.set(a.id,p),this.structuredRoomGeometry.set(a.id,{polyPoints:a.polyPoints,outlinePoints:a.outlinePoints,colorIndex:a.colorIndex??0})}this.roomGraphicsMap.set(a.id,l),this.roomContextMap.set(a.id,{activeContext:c,inactiveContext:d,normalContext:u}),this.addChild(l)})}drawRaster(e){const i=this.appService;if(this.clearRooms(),this.mapWidth=e.width,e.sortedRooms.length===0)return;const{selectRoomIds:s,enableRoomSelection:n}=i.runtimeSnapshot;e.sortedRooms.forEach(o=>{this.drawRasterRoom(o,n,s)})}drawRasterRoom(e,i,s){const{roomId:n,pixelIndices:o,activeColor:a,inactiveColor:h}=e,c=this.appService.roomConfig;let d=a;const u=typeof n=="number";if(u){const S=e.colorIndex??0;d=(c.colors.normal||c.colors.active)[S%(c.colors.normal||c.colors.active).length]}const p=new H,f=new mt,y=new mt,m=new mt;f.setFillStyle({color:a}),y.setFillStyle({color:h}),m.setFillStyle({color:d}),this.drawPixelPointsInBatches(f,o,re,this.mapWidth),this.drawPixelPointsInBatches(y,o,re,this.mapWidth),this.drawPixelPointsInBatches(m,o,re,this.mapWidth);const x=u&&s.includes(n);if(p.context=i?u&&x?f:y:m,u){const S=new vt(p,{clickThreshold:10,onClick:()=>{this.handleRoomClick(n)}});this.roomClickHandlerMap.set(n,S)}this.roomGraphicsMap.set(n,p),this.roomContextMap.set(n,{activeContext:f,inactiveContext:y,normalContext:m}),this.rasterRoomDataMap.set(n,e),this.addChild(p)}drawPixelPointsInBatches(e,i,s,n){for(let o=0;o<i.length;o+=s){const a=Math.min(o+s,i.length);for(let h=o;h<a;h++){const l=i[h],c=l%n,d=Math.floor(l/n);e.rect(c,d,1,1)}e.fill()}}handleRoomClick(e){var s,n;const i=this.appService;(n=(s=i.events)==null?void 0:s.onClickRoom)==null||n.call(s,i.getRoomData(e)??{id:e})}setRoomStateBySelectIds(e){const i=this.appService,{enableRoomSelection:s}=i.runtimeSnapshot;this.roomGraphicsMap.forEach((n,o)=>{if(typeof o=="number"){const a=this.roomContextMap.get(o);if(a)if(s){const h=e.includes(o);n.context=h?a.activeContext:a.inactiveContext}else n.context=a.normalContext}})}setRoomState(e,i){const s=this.roomGraphicsMap.get(e),n=this.roomContextMap.get(e);if(!s||!n){A.warn(`Room ${e} not found`);return}typeof e=="number"&&(s.context=i?n.activeContext:n.inactiveContext)}setAllRoomsState(e){this.roomGraphicsMap.forEach((i,s)=>{typeof s=="number"&&this.setRoomState(s,e)})}getRoomGraphicsMap(){const e=new Map;return this.roomGraphicsMap.forEach((i,s)=>{typeof s=="number"&&e.set(s,i)}),e}getRasterRoomData(e){return this.rasterRoomDataMap.get(e)||null}getMapWidth(){return this.mapWidth}isWallIntersectsAnyRoom(e){const s=this.appService.getApp().mapState;if(!s)return A.warn("[RoomFill] Map state not available"),!1;if(!e||e.length!==2)return A.warn("[RoomFill] Invalid wall points provided"),!1;const[n,o]=e,a={x:n.x+s.origin.x,y:n.y+s.origin.y},h={x:o.x+s.origin.x,y:o.y+s.origin.y};return s.mapType==="raster"?this.isWallIntersectsAnyRoomRaster(a,h):this.isWallIntersectsAnyRoomStructured(a,h)}isZoneIntersectsAnyRoom(e){const s=this.appService.getApp().mapState;if(!s)return A.warn("[RoomFill] Map state not available"),!1;if(!e||e.length!==4)return A.warn("[RoomFill] Invalid zone points provided"),!1;const n=e.map(o=>({x:o.x+s.origin.x,y:o.y+s.origin.y}));return s.mapType==="raster"?this.isZoneIntersectsAnyRoomRaster(n):this.isZoneIntersectsAnyRoomStructured(n)}isWallIntersectsAnyRoomRaster(e,i){if(this.mapWidth===0||this.rasterRoomDataMap.size===0)return!1;const s=this.getLinePixels(e,i);for(const n of this.rasterRoomDataMap.values())for(const o of s)if(Zl(n.pixelIndices,o))return!0;return!1}isWallIntersectsAnyRoomStructured(e,i){const n=this.appService.mapManager.getAllRooms();for(const o of n)if(!(!o.outlinePoints||o.outlinePoints.length<3)){if(Rt(e,o.outlinePoints,!0)||Rt(i,o.outlinePoints,!0))return!0;for(let a=0;a<o.outlinePoints.length;a++){const h=o.outlinePoints[a],l=o.outlinePoints[(a+1)%o.outlinePoints.length];if(zi(e,i,h,l))return!0}}return!1}isZoneIntersectsAnyRoomRaster(e){if(this.mapWidth===0||this.rasterRoomDataMap.size===0)return!1;const i=[[e[0],e[1]],[e[1],e[2]],[e[2],e[3]],[e[3],e[0]]];for(const[n,o]of i)if(this.isWallIntersectsAnyRoomRaster(n,o))return!0;const s=this.rasterRoomDataMap.values().next().value;if(s&&s.pixelIndices.length>0){const n=s.pixelIndices[0],o=n%this.mapWidth,a=Math.floor(n/this.mapWidth);if(Rt({x:o,y:a},e,!0))return!0}return!1}isZoneIntersectsAnyRoomStructured(e){const s=this.appService.mapManager.getAllRooms(),n=[[e[0],e[1]],[e[1],e[2]],[e[2],e[3]],[e[3],e[0]]];for(const o of s)if(!(!o.outlinePoints||o.outlinePoints.length<3)){for(const a of e)if(Rt(a,o.outlinePoints,!0))return!0;for(const a of o.outlinePoints)if(Rt(a,e,!0))return!0;for(const[a,h]of n)for(let l=0;l<o.outlinePoints.length;l++){const c=o.outlinePoints[l],d=o.outlinePoints[(l+1)%o.outlinePoints.length];if(zi(a,h,c,d))return!0}}return!1}getLinePixels(e,i){const n=this.appService.getApp().mapState;if(!n)return[];const o=n.height,a=[],h=Math.round(e.x),l=Math.round(e.y),c=Math.round(i.x),d=Math.round(i.y),u=Math.abs(c-h),p=Math.abs(d-l),f=h<c?1:-1,y=l<d?1:-1;let m=u-p,x=h,S=l;for(;;){if(x>=0&&x<this.mapWidth&&S>=0&&S<o){const b=S*this.mapWidth+x;a.push(b)}if(x===c&&S===d)break;const v=2*m;v>-p&&(m-=p,x+=f),v<u&&(m+=u,S+=y)}return a}getZonePixels(e,i,s,n){const a=this.appService.getApp().mapState;if(!a)return[];const h=a.height,l=[],c=Math.max(0,Math.floor(e)),d=Math.min(this.mapWidth-1,Math.ceil(s)),u=Math.max(0,Math.floor(i)),p=Math.min(h-1,Math.ceil(n));for(let f=u;f<=p;f++)for(let y=c;y<=d;y++){const m=f*this.mapWidth+y;l.push(m)}return l}refreshRoomColors(){const{selectRoomIds:e,enableRoomSelection:i}=this.appService.runtimeSnapshot,s=this.appService.roomConfig;this.roomGraphicsMap.forEach((n,o)=>{if(typeof o!="number")return;const a=this.roomContextMap.get(o),h=this.structuredRoomGeometry.get(o);if(a&&h){const l=h.colorIndex,c=s.colors.active[l%s.colors.active.length],d=s.colors.inactive[l%s.colors.inactive.length],u=(s.colors.normal||s.colors.active)[l%(s.colors.normal||s.colors.active).length];a.activeContext.clear(),a.activeContext.setFillStyle({color:c}),a.activeContext.poly(h.polyPoints).fill(),h.outlinePoints.forEach(p=>{a.activeContext.rect(p.x,p.y,1,1).fill()}),a.inactiveContext.clear(),a.inactiveContext.setFillStyle({color:d}),a.inactiveContext.poly(h.polyPoints).fill(),h.outlinePoints.forEach(p=>{a.inactiveContext.rect(p.x,p.y,1,1).fill()}),a.normalContext.clear(),a.normalContext.setFillStyle({color:u}),a.normalContext.poly(h.polyPoints).fill(),h.outlinePoints.forEach(p=>{a.normalContext.rect(p.x,p.y,1,1).fill()}),n.context=i?e.includes(o)?a.activeContext:a.inactiveContext:a.normalContext}else if(a){const l=this.rasterRoomDataMap.get(o);if(l){const c=l.colorIndex??0,d=s.colors.active[c%s.colors.active.length],u=s.colors.inactive[c%s.colors.inactive.length],p=(s.colors.normal||s.colors.active)[c%(s.colors.normal||s.colors.active).length];a.activeContext.clear(),a.activeContext.setFillStyle({color:d}),this.drawPixelPointsInBatches(a.activeContext,l.pixelIndices,re,this.mapWidth),a.inactiveContext.clear(),a.inactiveContext.setFillStyle({color:u}),this.drawPixelPointsInBatches(a.inactiveContext,l.pixelIndices,re,this.mapWidth),a.normalContext.clear(),a.normalContext.setFillStyle({color:p}),this.drawPixelPointsInBatches(a.normalContext,l.pixelIndices,re,this.mapWidth),n.context=i?e.includes(o)?a.activeContext:a.inactiveContext:a.normalContext}}}),this.appService.getApp().renderOnceNextFrame()}clearRooms(){this.children.length===0&&this.roomGraphicsMap.size===0||(this.roomGraphicsMap.forEach(e=>{try{e.destroy()}catch(i){A.warn("Error destroying room graphics:",i)}}),this.roomGraphicsMap.clear(),this.roomContextMap.forEach(e=>{try{e.activeContext.destroy(),e.inactiveContext.destroy(),e.normalContext.destroy()}catch(i){A.warn("Error destroying graphics context:",i)}}),this.roomContextMap.clear(),this.roomClickHandlerMap.forEach(e=>{try{e.destroy()}catch(i){A.warn("Error destroying click handler:",i)}}),this.roomClickHandlerMap.clear(),this.removeChildren(),this.rasterRoomDataMap.clear(),this.structuredRoomGeometry.clear())}destroy(){this.unsubscribeFns.forEach(e=>e()),this.unsubscribeFns=[],this.clearRooms(),super.destroy()}}class Vx{constructor(t){g(this,"obstacle");g(this,"free");g(this,"roomFill");g(this,"carpet");g(this,"chargingStation");g(this,"mapBounds",{minX:0,minY:0,maxX:0,maxY:0});g(this,"lastMapId",null);g(this,"lastOrigin",null);g(this,"lastSize",null);g(this,"lastStatus",null);g(this,"roomGeometryMap",new Map);g(this,"rasterRoomPixelsMap",new Map);g(this,"fourColorCache",null);g(this,"carpetData",null);g(this,"unsubscribeFns",[]);this.appService=t,this.obstacle=new Na(this.appService),this.free=new Va(this.appService),this.roomFill=new ja(this.appService),this.carpet=new Hx(this.appService),this.chargingStation=new Ux(this.appService),this.validateColorConfig();const e=U(t.runtime,"enableRoomSelection",o=>{if(A.log(`[runtime] enableRoomSelection: ${o}`),o){this.roomFill.setAllRoomsState(!1);const a=this.appService.runtimeSnapshot.selectRoomIds;this.roomFill.setRoomStateBySelectIds(a)}else this.roomFill.setAllRoomsState(!0)}),i=U(t.runtime,"selectRoomIds",o=>{A.log(`[runtime] selectRoomIds: ${o}`),this.roomFill.setRoomStateBySelectIds(o)}),s=U(t.runtime,"showChargingStation",o=>{A.log(`[runtime] showChargingStation: ${o}`),this.chargingStation.visible=o}),n=U(t.runtime,"showCarpet",o=>{A.log(`[runtime] showCarpet: ${o}`),o?t.getApp().managers.customCarpetManager.getCustomCarpets().length===0&&this.createCarpet():this.carpet.clearCarpet()});this.unsubscribeFns.push(e,i,s,n)}async drawMap(t){const e=this.appService,{id:i,obstacles:s,free:n,rooms:o,charger:a,carpet:h,status:l,origin:c,size:d}=t;this.clearComponents(),this.resetGeometryData();const u=this.processRoomsGeometry(o);this.roomFill.draw(u),n&&this.free.draw(n),s&&this.obstacle.draw(s),this.carpetData=h,this.createCarpet();const p=this.mergeLayerBounds();Zr(p,this.mapBounds)||(A.debug("[Map] Map bounds updated:",p),this.mapBounds=p,this.shouldFitMapToView(i,l===1,{x:c[0],y:c[1]},{x:d[0],y:d[1]})&&(e.getApp().fitMapToView(this.mapBounds),this.lastMapId=i,this.lastOrigin={x:c[0],y:c[1]},this.lastSize={x:d[0],y:d[1]},this.lastStatus=l===1));const f=((t.charger.angle??0)+e.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:a.coordinate[0],y:a.coordinate[1],rotation:f}),await e.roomsManager.refresh(),!0}async drawRasterMap(t,e){const i=this.appService;this.clearComponents();const{id:s,width:n,height:o,charger:a,chargerDirection:h,status:l,origin:c}=e;A.debug("[Map] Parsed Raster Map Data",t),this.obstacle.drawRaster(t.obstacles,n),this.carpetData=this.convertRasterToStructuredData(t.carpet,n),i.getApp().managers.customCarpetManager.getCustomCarpets().length===0&&this.createCarpet();const u=this.processRasterData(t);this.roomFill.drawRaster(u);const p=yy(t,n,o);Zr(p,this.mapBounds)||(A.debug("[Map] Raster map bounds updated:",p),this.mapBounds=p,this.shouldFitMapToView(s,l,c,{x:n,y:o})&&(i.getApp().fitMapToView(this.mapBounds),this.lastMapId=s,this.lastOrigin={...c},this.lastSize={x:n,y:o},this.lastStatus=l));const f=(h+i.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:a.x,y:a.y,rotation:f}),this.generateRoomGeometryFromRaster(t),await i.roomsManager.refresh(),!0}resetGeometryData(){this.roomGeometryMap.clear(),this.rasterRoomPixelsMap.clear(),this.fourColorCache=null,this.mapBounds={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}shouldFitMapToView(t,e,i,s){const n=this.appService,{originChangeAutoFitThreshold:o,sizeChangeAutoFitThreshold:a}=n.getApp().config.map;if(this.lastMapId!==t)return A.debug("[Map] Map ID changed, triggering fitMapToView"),!0;if(this.lastStatus!==null&&this.lastStatus!==e)return A.debug(`[Map] Map status changed (${this.lastStatus} -> ${e}), triggering fitMapToView`),!0;if(this.lastOrigin&&i){const h=Math.abs(i.x-this.lastOrigin.x),l=Math.abs(i.y-this.lastOrigin.y);if(h>o||l>o)return A.debug(`[Map] Origin change exceeded threshold (deltaX: ${h}, deltaY: ${l}, threshold: ${o}), triggering fitMapToView`),!0}if(this.lastSize&&s){const h=Math.abs(s.x-this.lastSize.x),l=Math.abs(s.y-this.lastSize.y);if(h>a||l>a)return A.debug(`[Map] Size change exceeded threshold (deltaX: ${h}, deltaY: ${l}, threshold: ${a}), triggering fitMapToView`),!0}return!1}convertRasterToStructuredData(t,e){if(t.length===0)return[];const i=[];for(let s=0;s<t.length;s++){const n=t[s],o=n%e,a=Math.floor(n/e);i.push(o,a)}return[{coordinates:i}]}async createCarpet(){!this.appService.runtimeSnapshot.showCarpet||!this.carpetData||await this.carpet.createCarpetFromStructuredData(this.carpetData)}processRoomsGeometry(t){if(!t)return[];const e=this.appService,{active:i}=e.roomConfig.colors,s=e.roomConfig.colors[oe.UNKNOWN_ROOM];if(Object.keys(t).length===0)return this.mapBounds={minX:0,minY:0,maxX:0,maxY:0},[];const n=Object.keys(t).sort((u,p)=>Number(u)-Number(p)),o=n.filter(u=>Number(u)<255),a=n.filter(u=>Number(u)>=255),h=[],l=[];o.forEach(u=>{const{coordinates:p}=t[u];if(p.length<4)return;const f=p.filter(_=>!isFinite(_));if(f.length>0){A.error(`[Room ${u}] Contains ${f.length} invalid coordinates (NaN/Infinity)`);return}const y=Number(u);let m=1/0,x=1/0,S=-1/0,v=-1/0;const b=[];for(let _=0;_<p.length;_+=2){const I=p[_],B=p[_+1];m=Math.min(m,I),x=Math.min(x,B),S=Math.max(S,I),v=Math.max(v,B),b.push({x:I,y:B})}const P=S-m,w=v-x;if(P===0||w===0){A.error(`[Room ${u}] Degenerate polygon (${P}x${w}). Skipping.`);return}if(P<2||w<2){A.warn(`[Room ${u}] Room too small (${P}x${w}), skipping`);return}const C=new et(m,x,S-m+1,v-x+1),k=ka(b),M=k.flatMap(_=>[_.x+.5,_.y+.5]),T=Ra(k,m,x,S,v);l.push({id:y,points:b,outlinePoints:k,polyPoints:M,centerPoint:T,boundingBox:C}),this.mapBounds.minX=Math.min(this.mapBounds.minX,m),this.mapBounds.minY=Math.min(this.mapBounds.minY,x),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,S),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,v)});const c=[...l].sort((u,p)=>{if(e.roomConfig.colors.sortBy==="area"){const f=u.outlinePoints.length;return p.outlinePoints.length-f}else return u.id-p.id}),d=this.assignColorsUsingFourColorAlgorithm(c,i.length,"structured");return l.forEach(u=>{const p=d.get(u.id)||0,f=i[p],y={id:u.id,color:f,colorIndex:p,boundingBox:u.boundingBox,points:u.points,outlinePoints:u.outlinePoints,polyPoints:u.polyPoints,centerPoint:u.centerPoint};this.roomGeometryMap.set(u.id,y),h.push(y)}),a.forEach(u=>{const{coordinates:p}=t[u];if(p.length<4)return;const f=Number(u);let y=1/0,m=1/0,x=-1/0,S=-1/0;const v=[];for(let _=0;_<p.length;_+=2){const I=p[_],B=p[_+1];y=Math.min(y,I),m=Math.min(m,B),x=Math.max(x,I),S=Math.max(S,B),v.push({x:I,y:B})}const b=x-y,P=S-m;if(b===0||P===0){A.error(`[Unknown Room ${u}] Degenerate polygon (${b}x${P}). Skipping.`);return}if(b<2||P<2){A.warn(`[Unknown Room ${u}] Room too small (${b}x${P}), skipping`);return}const w=new et(y,m,x-y+1,S-m+1),C=ka(v),k=C.flatMap(_=>[_.x+.5,_.y+.5]),M=Ra(C,y,m,x,S),T={id:f,color:s,boundingBox:w,points:v,outlinePoints:C,polyPoints:k,centerPoint:M};h.push(T),this.mapBounds.minX=Math.min(this.mapBounds.minX,y),this.mapBounds.minY=Math.min(this.mapBounds.minY,m),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,x),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,S)}),h}mergeLayerBounds(){let t={...this.mapBounds};if(this.obstacle.bounds&&(t=An(t,this.obstacle.bounds)),this.free.bounds&&(t=An(t,this.free.bounds)),this.roomFill.children.length>0){const e=this.roomFill.getLocalBounds();e.width>0&&e.height>0&&(t=An(t,{minX:e.x,minY:e.y,maxX:e.x+e.width,maxY:e.y+e.height}))}return t}getRoomById(t){return this.roomGeometryMap.get(t)}getAllRooms(){return Array.from(this.roomGeometryMap.values())}isWallIntersectsAnyRoom(t){return this.roomFill.isWallIntersectsAnyRoom(t)}isZoneIntersectsAnyRoom(t){return this.roomFill.isZoneIntersectsAnyRoom(t)}areRoomsAdjacent(t){const e=this.appService,i=e.mapConfig.adjacencyThreshold;if(!t||t.length===0)return A.warn("[MapManager] No room IDs provided"),!1;if(t.length===1)return!0;const s=Array.from(new Set(t));if(s.length===1)return!0;const n=e.getApp().mapState;return((n==null?void 0:n.mapType)??"structured")==="raster"?this.areRasterRoomsAdjacentInternal(s,i):this.areStructuredRoomsAdjacentInternal(s,i)}areStructuredRoomsAdjacentInternal(t,e){const i=[];for(const n of t){const o=this.getRoomById(n);if(!o)return A.warn(`[MapManager] Room ${n} not found in map`),!1;if(!o.outlinePoints||o.outlinePoints.length===0)return A.warn(`[MapManager] Room ${n} has no outline points`),!1;i.push({id:n,points:o.outlinePoints})}const s=[];for(let n=0;n<i.length;n++)for(let o=n+1;o<i.length;o++){const a=i[n],h=i[o];Da(a.points,h.points,e)&&s.push([n,o])}return za(i.length,s)}areRasterRoomsAdjacentInternal(t,e){const s=this.appService.getApp().mapState;if(!s)return A.warn("[MapManager] Map state not available"),!1;const n=s.width,o=[];for(const h of t){const l=this.getRasterRoomPixels(h);if(!l)return A.warn(`[MapManager] Room ${h} pixel data not found in raster map`),!1;o.push({id:h,pixels:l})}const a=[];for(let h=0;h<o.length;h++)for(let l=h+1;l<o.length;l++){const c=o[h],d=o[l];Fa(c.pixels,d.pixels,n,e)&&a.push([h,l])}return za(o.length,a)}isPointInAnyRoom(t){const i=this.appService.getApp().mapState;return i?(i.mapType??"structured")==="raster"?this.isPointInAnyRoomRasterInternal(t,i):this.isPointInAnyRoomStructuredInternal(t,i):(A.warn("[MapManager] Map state not available"),null)}isPointInAnyRoomStructuredInternal(t,e){const i=t.x+e.origin.x,s=t.y+e.origin.y,n={x:i,y:s},o=this.getAllRooms();for(const a of o)if(a.outlinePoints&&a.outlinePoints.length>=3&&Rt(n,a.outlinePoints)){const l=this.appService.roomsManager.getRoomPropertyById(a.id);return l||(A.warn(`[MapManager] Room ${a.id} found in geometry but not in RoomManager`),null)}return null}isPointInAnyRoomRasterInternal(t,e){const i=e.width,s=e.height,n=t.x+e.origin.x,o=t.y+e.origin.y,a=Math.round(n),h=Math.round(o);if(a<0||a>=i||h<0||h>=s)return A.warn(`[MapManager] Point (${a}, ${h}) is out of map bounds (${i}x${s})`),null;const l=h*i+a,c=this.getAllRooms();for(const d of c){const u=this.getRasterRoomPixels(d.id);if(u&&u.length>0&&Zl(u,l)){const f=this.appService.roomsManager.getRoomPropertyById(d.id);return f||(A.warn(`[MapManager] Room ${d.id} found in geometry but not in RoomManager`),null)}}return null}clearComponents(){this.obstacle.clear(),this.obstacle.destroy(),this.obstacle=new Na(this.appService),this.free.clear(),this.free.destroy(),this.free=new Va(this.appService),this.carpet.clearCarpet(),this.carpetData=null,this.roomFill.clearRooms(),this.roomFill.isRenderGroup&&(this.roomFill.isRenderGroup=!1),this.roomFill.removeChildren(),this.roomFill.destroy(),this.roomFill=new ja(this.appService)}processRasterData(t){const i=this.appService.roomConfig,s=[],n=[];t.rooms.forEach((d,u)=>{typeof u=="number"?s.push([u,d]):n.push([u,d])}),s.sort(([d],[u])=>d-u);const o=s.map(([d,u])=>({id:d,pixels:u})).sort((d,u)=>i.colors.sortBy==="area"?u.pixels.length-d.pixels.length:d.id-u.id),a=this.assignColorsUsingFourColorAlgorithm(o,i.colors.active.length,"raster"),h=s.map(([d,u])=>{const p=a.get(d)||0;return{roomId:d,pixelIndices:u,activeColor:i.colors.active[p],inactiveColor:i.colors.inactive[p%i.colors.inactive.length],colorIndex:p}}),l=n.map(([d,u])=>{let p=i.colors[d];return d===oe.VERSION0_ROOM&&!p&&(p=i.colors[oe.NO_ROOM_DATA]),{roomId:d,pixelIndices:u,activeColor:p,inactiveColor:p}}),c=[...h,...l];return{obstacles:t.obstacles,carpet:t.carpet,sortedRooms:c,width:t.width,height:t.height,totalPixels:t.totalPixels}}generateRoomGeometryFromRaster(t){const e=this.appService;this.roomGeometryMap.clear(),this.rasterRoomPixelsMap.clear();const{active:i}=e.roomConfig.colors,s=[];t.rooms.forEach((h,l)=>{typeof l=="number"&&s.push(l)}),s.sort((h,l)=>h-l);const n=[];s.forEach(h=>{const l=t.rooms.get(h);this.rasterRoomPixelsMap.set(h,l);let c=1/0,d=1/0,u=-1/0,p=-1/0;for(let m=0;m<l.length;m++){const x=l[m],S=x%t.width,v=Math.floor(x/t.width);c=Math.min(c,S),d=Math.min(d,v),u=Math.max(u,S),p=Math.max(p,v)}const f=uy(l,t.width,c,d,u,p),y=new et(c,d,u-c+1,p-d+1);n.push({id:h,pixelIndices:l,boundingBox:y,centerPoint:f})});const o=[...n].sort((h,l)=>e.roomConfig.colors.sortBy==="area"?l.pixelIndices.length-h.pixelIndices.length:h.id-l.id),a=this.assignColorsUsingFourColorAlgorithm(o,i.length,"raster");n.forEach(h=>{const l=a.get(h.id)||0,c=i[l],d={id:h.id,color:c,colorIndex:l,boundingBox:h.boundingBox,points:[],outlinePoints:[],polyPoints:[],centerPoint:h.centerPoint};this.roomGeometryMap.set(h.id,d)})}getRasterRoomPixels(t){return this.rasterRoomPixelsMap.get(t)}validateColorConfig(){const e=this.appService.roomConfig.colors,i=e.active.length,s=e.inactive.length,n=e.name.length,o=e.propertyTheme.length,a=e.selectionIndicatorBackground.length,h=e.selectionIndicatorIcon.length;i<4&&A.warn(`[FourColor] room.colors.active requires at least 4 colors for the four-color theorem, but got ${i}. Adjacent rooms may have the same color.`),s!==i&&A.warn(`[FourColor] room.colors.inactive length (${s}) does not match room.colors.active length (${i}). Using modulo for color assignment.`),n!==i&&A.warn(`[FourColor] room.colors.name length (${n}) does not match room.colors.active length (${i}). Using modulo for color assignment.`),o!==i&&A.warn(`[FourColor] room.colors.propertyTheme length (${o}) does not match room.colors.active length (${i}). Using modulo for color assignment.`),a!==i&&A.warn(`[FourColor] room.colors.selectionIndicatorBackground length (${a}) does not match room.colors.active length (${i}). Using modulo for color assignment.`),h!==i&&A.warn(`[FourColor] room.colors.selectionIndicatorIcon length (${h}) does not match room.colors.active length (${i}). Using modulo for color assignment.`)}assignColorsUsingFourColorAlgorithm(t,e,i){var d;const s=this.appService,n=((d=s.mapState)==null?void 0:d.id)??null;if(this.fourColorCache&&this.fourColorCache.mapId===n&&this.fourColorCache.colorMap.size===t.length)return A.debug("[FourColor] Using cached color map"),this.fourColorCache.colorMap;const o=s.getApp().config.map.adjacencyThreshold||3,a=s.roomConfig.colors.strategy,h=(u,p)=>{var f;if(i==="structured"){const y=u.outlinePoints,m=p.outlinePoints;return!y||!m?!1:Da(y,m,o)}else{const y=u.pixels,m=p.pixels;if(!y||!m)return!1;const x=((f=s.mapState)==null?void 0:f.width)||0;return Fa(y,m,x,o)}};A.debug(`[FourColor] Starting algorithm for ${t.length} rooms with ${e} colors, strategy: ${a}`);const l=by(t,h,e,a);this.fourColorCache={mapId:n,colorMap:l};const c=new Array(e).fill(0);return l.forEach(u=>{c[u]++}),A.debug("[FourColor] Color distribution:",c),l}destroy(){this.obstacle.destroy(),this.free.destroy(),this.roomFill.destroy(),this.carpet.destroy(),this.chargingStation.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.fourColorCache=null}}class Nx extends L{constructor(e){super({isRenderGroup:!0});g(this,"commonPath");g(this,"chargePath");g(this,"transitionsPath");g(this,"mopPath");g(this,"mopPathTrack");g(this,"mopPathTrackContainer");g(this,"debugPoints");g(this,"pathData",null);g(this,"lastPointCount",0);g(this,"lastDrawnPosition",null);g(this,"isRealTimeDrawing",!1);g(this,"throttledUpdateLineWidth");g(this,"throttledHandleRobotPosition");g(this,"unsubscribeFns",[]);g(this,"handleRobotAnimationComplete",()=>{this.isRealTimeDrawing&&this.stopRealTimeDrawing()});this.appService=e,this.appService.appContainer.addToLayer(hc,this),this.eventMode="none",this.commonPath=new H,this.chargePath=new H,this.transitionsPath=new H,this.mopPathTrackContainer=new L,this.mopPathTrackContainer.filters=[new Gg],this.mopPathTrack=new H,this.mopPath=new H,this.debugPoints=new H,this.mopPathTrackContainer.addChild(this.mopPathTrack),this.addChild(this.mopPathTrackContainer),this.addChild(this.commonPath),this.addChild(this.chargePath),this.addChild(this.transitionsPath),this.addChild(this.mopPath),this.addChild(this.debugPoints),this.visible=e.runtimeSnapshot.showPath,this.commonPath.visible=e.pathConfig.commonPath.visible,this.chargePath.visible=e.pathConfig.chargePath.visible,this.transitionsPath.visible=e.pathConfig.transitionPath.visible,this.mopPathTrackContainer.visible=e.pathConfig.mopPath.trackVisible,this.mopPath.visible=e.pathConfig.mopPath.lineVisible,this.throttledUpdateLineWidth=At(()=>{this.updateLineWidth()},50,{leading:!0,trailing:!0}),this.throttledHandleRobotPosition=At(this.handleRobotPositionUpdate.bind(this),0),this.registerEventListeners()}registerEventListeners(){const{emitter:e}=this.appService;e.on("antiScale",this.throttledUpdateLineWidth),e.on("robotPositionUpdate",this.throttledHandleRobotPosition),e.on("robotAnimationComplete",this.handleRobotAnimationComplete);const i=Bs(this.appService.config.path,()=>{this.pathData&&(this.redrawPaths(this.pathData),this.appService.getApp().renderOnceNextFrame())});this.unsubscribeFns.push(i)}handleRobotPositionUpdate(e){if(!this.isRealTimeDrawing||!this.lastDrawnPosition)return;const i=e.pathType||"common";let s=[];switch(i){case"common":s=[this.commonPath];break;case"charge":s=[this.chargePath];break;case"transitions":s=[this.transitionsPath];break;case"mop":s=[this.mopPathTrack,this.mopPath];break;default:s=[this.commonPath]}s.forEach(n=>{n.moveTo(this.lastDrawnPosition.x,this.lastDrawnPosition.y),n.lineTo(e.x,e.y),n.stroke()}),this.lastDrawnPosition={x:e.x,y:e.y}}updateLineWidth(){const e=this.appService;this.pathData&&e.pathConfig.lineWidthFixed&&this.redrawPaths(this.pathData)}redrawPaths(e){const{pathPoints:i}=e;if(!i||i.length===0)return;this.commonPath.clear(),this.chargePath.clear(),this.transitionsPath.clear(),this.mopPathTrack.clear(),this.mopPath.clear(),this.debugPoints.clear(),this.setupPathStyles(),this.drawPathSegments(i),this.commonPath.stroke(),this.chargePath.stroke(),this.transitionsPath.stroke(),this.mopPathTrack.stroke(),this.mopPath.stroke(),this.appService.getDebuggerMode()&&this.drawDebugPoints(i)}setupPathStyles(){var n;const e=this.appService,i=e.pathConfig,s=o=>i.lineWidthFixed?e.getApp().toFixedSize(o):o;this.commonPath.setStrokeStyle({width:s(i.commonPath.width),color:i.commonPath.color,join:"round",cap:"round"}),this.chargePath.setStrokeStyle({width:s(i.chargePath.width),color:i.chargePath.color,join:"round",cap:"round"}),this.transitionsPath.setStrokeStyle({width:s(i.transitionPath.width),color:i.transitionPath.color,join:"round",cap:"round"}),this.mopPathTrack.setStrokeStyle({width:s(i.mopPath.trackWidth),color:i.mopPath.trackColor,alpha:1,join:"round",cap:"round"}),(n=this.mopPathTrackContainer.filters)!=null&&n[0]&&(this.mopPathTrackContainer.filters[0].alpha=i.mopPath.trackAlpha),this.mopPathTrackContainer.visible=i.mopPath.trackVisible,this.mopPath.setStrokeStyle({width:s(i.mopPath.lineWidth),color:i.mopPath.lineColor,join:"round",cap:"round"}),this.mopPath.visible=i.mopPath.lineVisible}drawPathSegments(e){let i=null,s=null;for(let n=0;n<e.length;n++){const o=e[n],a=o.type||"common";let h;switch(a){case"common":h=[this.commonPath];break;case"charge":h=[this.chargePath];break;case"transitions":h=[this.transitionsPath];break;case"mop":h=[this.mopPathTrack,this.mopPath];break;default:h=[this.commonPath]}n===0||a!==i?h.forEach(c=>c.moveTo(o.x,o.y)):s&&h.length===s.length&&h.every((c,d)=>c===s[d])&&h.forEach(c=>c.lineTo(o.x,o.y)),i=a,s=h}}drawDebugPoints(e){const i={common:16711935,charge:65535,transitions:16776960,mop:65280},s=1;for(const n of e){const o=n.type||"common",a=i[o];this.debugPoints.rect(n.x-s/2,n.y-s/2,s,s),this.debugPoints.fill(a)}}updatePositionByOrigin(e,i){this.position.set(e,i)}drawFull(e){var i;A.debug("[Path] Draw Full Path",e),this.pathData=e,this.redrawPaths(e),this.lastPointCount=((i=e.pathPoints)==null?void 0:i.length)||0}drawIncremental(e){var o,a,h,l;const i=this.appService,s=this.lastPointCount,n=((o=e.pathPoints)==null?void 0:o.slice(s))||[];if(n.length>0)if(this.setupPathStyles(),A.debug("[Path] Draw Incremental Path",n),i.robotConfig.speed>0){if(this.isRealTimeDrawing=!0,s>0&&((a=this.pathData)!=null&&a.pathPoints)){const u=this.pathData.pathPoints[s-1];this.lastDrawnPosition={x:u.x,y:u.y}}}else this.drawNewPathSegments(n,s,e.pathPoints,(h=this.pathData)==null?void 0:h.pathPoints);this.pathData=e,this.lastPointCount=((l=e.pathPoints)==null?void 0:l.length)||0}drawNewPathSegments(e,i,s,n){if(!s||e.length===0)return;let o=null;i>0&&(n&&n[i-1]?o=n[i-1]:s[i-1]&&(o=s[i-1]));let a=null,h=null,l=!1;for(let c=0;c<e.length;c++){const d=e[c],u=d.type||"common";let p;switch(u){case"common":p=[this.commonPath];break;case"charge":p=[this.chargePath];break;case"transitions":p=[this.transitionsPath];break;case"mop":p=[this.mopPathTrack,this.mopPath];break;default:p=[this.commonPath]}u!==a||c===0?(h&&l&&h.forEach(y=>y.stroke()),a=u,h=p,l=!0,o&&c===0&&o.type===u?p.forEach(y=>{y.moveTo(o.x,o.y),y.lineTo(d.x,d.y)}):p.forEach(y=>y.moveTo(d.x,d.y))):p.forEach(y=>y.lineTo(d.x,d.y))}h&&l&&h.forEach(c=>c.stroke())}stopRealTimeDrawing(){this.isRealTimeDrawing=!1,this.lastDrawnPosition=null}clear(){this.commonPath.clear(),this.chargePath.clear(),this.transitionsPath.clear(),this.mopPathTrack.clear(),this.mopPath.clear(),this.debugPoints.clear(),this.pathData=null,this.lastPointCount=0,this.lastDrawnPosition=null,this.isRealTimeDrawing=!1}destroy(e){const{emitter:i}=this.appService;i.off("antiScale",this.throttledUpdateLineWidth),i.off("robotPositionUpdate",this.throttledHandleRobotPosition),i.off("robotAnimationComplete",this.handleRobotAnimationComplete),this.unsubscribeFns.forEach(s=>s()),this.unsubscribeFns=[],this.stopRealTimeDrawing(),super.destroy(e)}}class jx extends Xt{constructor(t){super(t),this.appService=t,this.initializeSprite()}async initializeSprite(){await this.loadTextureAndSetSize("robot",this.appService.robotConfig.icon)}async draw({x:t,y:e,rotation:i}){super.draw({x:t,y:e,rotation:i})}}const it=class it extends xs{constructor(e,i){super(i||[]);g(this,"throttledUpdateScale");g(this,"fixedWidth",0);g(this,"fixedHeight",0);g(this,"isFixedSizeSet",!1);g(this,"sizeFixed",!0);g(this,"baselineScale",1);this.appService=e,this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=At(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(e,i){this.fixedWidth=e,this.fixedHeight=i,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(e){this.sizeFixed=e,this.baselineScale=1,e&&this.isFixedSizeSet?this.applySize():!e&&this.isFixedSizeSet&&this.applySize()}set width(e){this.isFixedSizeSet||this.setFixedSize(e,this.fixedHeight||e)}set height(e){this.isFixedSizeSet||this.setFixedSize(this.fixedWidth||e,e)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.textures||this.textures.length===0||!this.textures[0]||this.textures[0].width===0||this.textures[0].height===0)return;const e=this.textures[0],i=this.fixedWidth/e.width,s=this.fixedHeight/e.height;if(this.sizeFixed){const n=this.appService.currentScale;if(n===0||!isFinite(n)){const h=i,l=s;super.scale.set(h,l);return}const o=i/n,a=s/n;super.scale.set(o,a)}else super.scale.set(i/this.baselineScale,s/this.baselineScale)}updateScale(e){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():e!==0&&super.scale.set(1/e))}static async loadAnimationTextures(e,i,s="sleep_",n=96){try{const a=await(await fetch(e)).json();a.meta&&(a.meta.image=i),await N.load(i);const h=G.from(i),l=new zn(h.source,a);await l.parse();const c=[];for(let d=0;d<n;d++){const u=d.toString().padStart(3,"0"),p=`${s}${u}.png`,f=l.textures[p];f?c.push(f):A.warn(`[EnhancedAnimatedSprite] Frame not found: ${p}`)}return c}catch(o){return A.error("[EnhancedAnimatedSprite] Failed to load textures:",o),[]}}setupAnimation(e){e.sizeFixed!==void 0&&this.setSizeFixed(e.sizeFixed),this.setFixedSize(e.width,e.height),this.animationSpeed=.5,this.loop=!0,A.log(`Animation setup complete, visible=${this.visible}, scale=(${this.scale.x.toFixed(3)}, ${this.scale.y.toFixed(3)})`)}draw(e,i){const{x:s,y:n}=e;i&&!this.visible?this.visible=i():!i&&!this.visible&&(this.visible=!0),this.position.set(s,n)}play(){this.textures&&this.textures.length>0&&(super.play(),it.animatedSprites.add(this),it.startAnimationTicker())}stop(){super.stop(),it.animatedSprites.delete(this),it.updateAnimationTicker()}set textures(e){super.textures=e,this.isFixedSizeSet&&e&&e.length>0&&e[0]&&e[0].width>0&&e[0].height>0&&this.applySize()}get textures(){return super.textures}static startAnimationTicker(){var e;(e=it.animationTicker)!=null&&e.started||(it.animationTicker||(it.animationTicker=new yt,it.animationTicker.maxFPS=24,it.animationTicker.add(()=>{const i=it.animatedSprites.values().next().value;i&&it.updateAnimations(i.appService)})),it.animationTicker.start(),A.log("🎬 [AnimationTicker] Started animation ticker"))}static updateAnimationTicker(){it.animatedSprites.size>0?it.startAnimationTicker():it.stopAnimationTicker()}static stopAnimationTicker(){var e;(e=it.animationTicker)!=null&&e.started&&(A.log("⏸️ [AnimationTicker] Stopped animation ticker"),it.animationTicker.stop())}static updateAnimations(e){if(it.animatedSprites.size===0)return;const i=e.getApp();i.renderer.render(i.stage)}destroy(e){it.animatedSprites.delete(this),it.updateAnimationTicker(),this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(e)}};g(it,"animationTicker",null),g(it,"animatedSprites",new Set);let Cs=it;class zr extends Cs{constructor(e,i){super(e,i);g(this,"unsubscribeFns",[]);g(this,"throttledUpdateOffset");g(this,"fixedOffsetX",0);g(this,"fixedOffsetY",0);this.appService=e,this.throttledUpdateOffset=At(this.updateOffset.bind(this),30,{leading:!0,trailing:!0}),this.initializeAnimation()}static async create(e){const i=e.robotConfig,s=await Cs.loadAnimationTextures(i.sleepAnimation.jsonSrc,i.sleepAnimation.imageSrc,i.sleepAnimation.framePrefix,i.sleepAnimation.frameCount);s.length===0&&(A.warn("No textures loaded for sleep animation"),s.push(G.EMPTY));const n=new zr(e,s);return n.setupAnimation({width:i.sleepAnimation.width,height:i.sleepAnimation.height,sizeFixed:i.sleepAnimation.sizeFixed}),n}initializeAnimation(){this.visible=!1,this.fixedOffsetX=this.appService.robotConfig.sleepAnimation.offsetX,this.fixedOffsetY=this.appService.robotConfig.sleepAnimation.offsetY,this.appService.emitter.on("antiScale",this.throttledUpdateOffset);const e=U(this.appService.runtime,"showRobotSleepAnimation",i=>{A.log(`[runtime] showRobotSleepAnimation: ${i}`),this.updateVisibility()});this.unsubscribeFns.push(e)}shouldShow(){const e=this.appService.runtimeSnapshot.showRobotSleepAnimation,i=this.parent,s=i?i.visible:!1,n=i&&(i.x!==0||i.y!==0);return e&&s&&!!n}updateVisibility(){const e=this.shouldShow();e&&!this.visible?(this.visible=!0,this.textures&&this.textures.length>0&&this.play()):!e&&this.visible?(this.visible=!1,this.stop()):!e&&this.playing&&this.stop()}updateOffset(){}draw(e){const i=this.appService.getApp().toFixedSize(this.appService.robotConfig.sleepAnimation.offsetX),s=this.appService.getApp().toFixedSize(this.appService.robotConfig.sleepAnimation.offsetY),n={...e,x:e.x+i,y:e.y+s};super.draw(n,()=>this.shouldShow()),this.updateVisibility()}onRobotVisibilityChanged(){this.updateVisibility()}set visible(e){const i=super.visible;super.visible=e,e&&!i&&this.textures&&this.textures.length>0?this.play():!e&&i&&this.playing&&this.stop()}get visible(){return super.visible}destroy(e){this.appService.emitter.off("antiScale",this.throttledUpdateOffset),this.unsubscribeFns.forEach(i=>i()),this.unsubscribeFns=[],this.stop(),super.destroy(e)}}class Yx extends H{constructor(e){super();g(this,"currentPosition",null);g(this,"animationStartTime",0);g(this,"isAnimating",!1);g(this,"handleScaleChange",()=>{this.redraw()});g(this,"updateAnimation",()=>{if(!this.currentPosition||!this.isAnimating||!this.visible)return;const e=this.appService,i=e.robotConfig.pulseCircle,n=(Date.now()-this.animationStartTime)%i.duration/i.duration,{minScale:o,maxScale:a,minAlpha:h,maxAlpha:l}=i,c=o+(a-o)*(Math.sin(n*Math.PI*2)*.5+.5),d=l-(l-h)*(c-o)/(a-o);super.clear();const{size:u,color:p,strokeWidth:f,strokeColor:y,sizeFixed:m}=i,S=(m?e.getApp().toFixedSize(u/2):u/2)*c,v=e.getApp().toFixedSize(f);this.setFillStyle({color:p,alpha:d}),this.circle(this.currentPosition.x,this.currentPosition.y,S).fill().stroke({color:y,width:v,alpha:d,cap:"round",join:"round"})});this.appService=e,this.setupAntiScaleListener()}setupAntiScaleListener(){this.appService.emitter.on("antiScale",this.handleScaleChange)}draw(e){this.currentPosition=e,this.isAnimating||this.startAnimation(),this.redraw()}startAnimation(){const e=this.appService;this.isAnimating||(this.isAnimating=!0,this.animationStartTime=Date.now(),e.getApp().ticker.add(this.updateAnimation,this),e.getApp().requestRender("pulse-circle-animation",!0))}stopAnimation(){const e=this.appService;this.isAnimating&&(this.isAnimating=!1,e.getApp().ticker.remove(this.updateAnimation,this),e.getApp().stopRender("pulse-circle-animation"))}redraw(){this.currentPosition&&this.isAnimating&&this.updateAnimation()}clearCircle(){super.clear()}remove(){this.stopAnimation(),this.clearCircle(),this.currentPosition=null}destroy(){this.stopAnimation(),this.appService.emitter.off("antiScale",this.handleScaleChange),super.destroy()}}class Xx extends L{constructor(e){super();g(this,"robot");g(this,"ring");g(this,"pulseCircle");g(this,"sleepAnimation",null);g(this,"unsubscribeFns",[]);g(this,"clickHandler");g(this,"targetPosition",null);g(this,"targetRotation",null);g(this,"isMoving",!1);g(this,"pathQueue",[]);g(this,"lastPosition",null);g(this,"currentPathType");g(this,"lastUpdateTime",0);g(this,"isCleared",!1);this.appService=e,e.appContainer.addToLayer(dc,this),this.visible=e.runtime.showRobot,this.ring=new uc(this.appService,{config:this.appService.robotConfig.ring}),this.ring.visible=this.appService.runtime.showRobotRing,this.addChild(this.ring),this.pulseCircle=new Yx(this.appService),this.pulseCircle.visible=e.runtime.showRobotPulseCircle,this.addChild(this.pulseCircle),this.robot=new jx(this.appService),this.addChild(this.robot),this.lastUpdateTime=Date.now(),this.appService.robotConfig.speed>0&&this.appService.getApp().ticker.add(this.update,this);const s=U(this.appService.runtime,"showRobotRing",o=>{A.log(`[runtime] showRobotRing: ${o}`),this.ring.visible=o});this.unsubscribeFns.push(s);const n=U(this.appService.runtime,"showRobotPulseCircle",o=>{A.log(`[runtime] showRobotPulseCircle: ${o}`),o?(this.lastPosition&&this.pulseCircle.draw(this.lastPosition),this.pulseCircle.visible=!0):(this.pulseCircle.remove(),this.pulseCircle.visible=!1)});this.unsubscribeFns.push(n),this.initClickInteraction()}async initializeSleepAnimation(){try{this.sleepAnimation=await zr.create(this.appService),this.addChild(this.sleepAnimation),A.log("Sleep animation added to robot")}catch(e){A.error("Failed to initialize sleep animation:",e)}}updatePositionByOrigin(e,i){this.position.set(e,i)}async draw({x:e,y:i,rotation:s}){this.isCleared&&(this.robot.visible=!0,this.ring.visible=this.appService.runtime.showRobotRing,this.pulseCircle.visible=this.appService.runtime.showRobotPulseCircle,this.sleepAnimation&&(this.sleepAnimation.visible=!0),this.isCleared=!1),this.ring.draw({x:e,y:i}),this.pulseCircle.draw({x:e,y:i}),await this.robot.draw({x:e,y:i,rotation:s}),this.sleepAnimation||await this.initializeSleepAnimation(),this.sleepAnimation.draw({x:e,y:i}),this.lastPosition={x:e,y:i},this.sleepAnimation.draw({x:e,y:i}),this.lastPosition={x:e,y:i}}initClickInteraction(){const{enableRobotClick:e}=this.appService.interactionConfig;e?this.clickHandler||(this.clickHandler=new vt(this.robot,{onClick:()=>{var s;const i=this.getCurrentPosition();i&&((s=this.appService.events)!=null&&s.onClickRobot)&&this.appService.events.onClickRobot({...i,rotation:this.robot.rotation})}})):this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=void 0,this.robot.interactive=!1,this.robot.eventMode="none")}getCurrentPosition(){return this.lastPosition?this.appService.fixPrecision({...this.lastPosition}):null}moveTo(e){this.pathQueue.push(e),this.isMoving||this.processNextPathPoint()}batchProcessQueue(e=!1){if(this.pathQueue.length===0)return;const i=[...this.pathQueue];if(e){const s=i[i.length-1];this.robot.position.set(s.x,s.y),s.rotation!==void 0&&(this.robot.rotation=s.rotation),this.lastPosition={x:s.x,y:s.y},this.pathQueue=[],this.isMoving=!1,this.targetPosition=null}else this.pathQueue.splice(0,i.length),this.pathQueue.length===0?(this.isMoving=!1,this.targetPosition=null):this.processNextPathPoint()}processNextPathPoint(){if(this.pathQueue.length===0){this.isMoving=!1,this.currentPathType=void 0,this.stopRobotAnimation(),this.appService.emitter.emit("robotAnimationComplete");return}this.isMoving||this.startRobotAnimation(),this.isMoving=!0;const e=this.pathQueue[0];this.targetPosition={x:e.x,y:e.y},this.currentPathType=e.type,e.rotation!==void 0&&(this.targetRotation=e.rotation),this.lastPosition||(this.lastPosition={x:this.robot.x,y:this.robot.y})}update(){const e=Date.now();if(this.lastUpdateTime===0){this.lastUpdateTime=e;return}let i=e-this.lastUpdateTime;if(this.lastUpdateTime=e,i>500&&(i=16.67),this.targetPosition){const s=this.targetPosition.x-this.robot.x,n=this.targetPosition.y-this.robot.y,o=Math.sqrt(s*s+n*n),a=this.appService.robotConfig.speed,h=this.appService.getApp().metersToPixels(a);if(a===0){this.robot.position.set(this.targetPosition.x,this.targetPosition.y),this.targetRotation!==null&&(this.robot.rotation=this.targetRotation,this.targetRotation=null),this.targetPosition=null,this.lastPosition={x:this.robot.x,y:this.robot.y},this.pathQueue.shift(),this.processNextPathPoint();return}const l=h*(i/1e3);o<l?(this.robot.position.set(this.targetPosition.x,this.targetPosition.y),this.targetRotation!==null&&(this.robot.rotation=this.targetRotation,this.targetRotation=null),this.targetPosition=null,this.lastPosition={x:this.robot.x,y:this.robot.y},this.pathQueue.shift(),this.processNextPathPoint()):(this.robot.x+=s*(l/o),this.robot.y+=n*(l/o),this.appService.emitter.emit("robotPositionUpdate",{x:this.robot.x,y:this.robot.y,pathType:this.currentPathType}),this.lastPosition={x:this.robot.x,y:this.robot.y})}}startRobotAnimation(){this.appService.getApp().requestRender("robot-animation",!0)}set visible(e){super.visible=e,this.sleepAnimation&&this.sleepAnimation.onRobotVisibilityChanged()}get visible(){return super.visible}stopRobotAnimation(){this.appService.getApp().stopRender("robot-animation")}remove(){this.pathQueue=[],this.isMoving=!1,this.targetPosition=null,this.stopRobotAnimation()}clear(){this.remove(),this.robot.visible=!1,this.ring.visible=!1,this.pulseCircle.remove(),this.sleepAnimation&&(this.sleepAnimation.visible=!1),this.lastPosition=null,this.isCleared=!0}destroy(e){this.unsubscribeFns.forEach(s=>s()),this.unsubscribeFns=[],this.stopRobotAnimation(),this.appService.robotConfig.speed>0&&this.appService.getApp().ticker.remove(this.update,this),this.ring.destroy(),this.pulseCircle.destroy(),this.clickHandler&&this.clickHandler.destroy(),super.destroy(e)}}class Zx{constructor(t){g(this,"path");g(this,"robot");g(this,"unsubscribeFns",[]);g(this,"lastDrawnPathData",null);this.appService=t,this.path=new Nx(this.appService),this.robot=new Xx(this.appService);const e=U(t.runtime,"showPath",s=>{A.log(`[runtime] showPath: ${s}`),this.path.visible=s}),i=U(t.runtime,"showRobot",s=>{A.log(`[runtime] showRobot: ${s}`),this.robot.visible=s});this.unsubscribeFns.push(e,i)}draw(t){var s,n,o;const e=(s=t.pathHeader)==null?void 0:s.pathId,i=(o=(n=this.lastDrawnPathData)==null?void 0:n.pathHeader)==null?void 0:o.pathId;this.lastDrawnPathData&&e!==i&&(this.path.clear(),this.lastDrawnPathData=null),this.shouldUseIncrementalDraw(t)?this.incrementalDraw(t):this.fullDraw(t),this.lastDrawnPathData=t}shouldUseIncrementalDraw(t){var h,l,c,d;if(!this.lastDrawnPathData)return!1;const e=(h=t.pathHeader)==null?void 0:h.pathId,i=(l=this.lastDrawnPathData.pathHeader)==null?void 0:l.pathId;if(e!==i)return!1;const s=((c=t.pathPoints)==null?void 0:c.length)||0,n=((d=this.lastDrawnPathData.pathPoints)==null?void 0:d.length)||0,o=s-n,a=this.appService.pathConfig.incrementalThreshold;return!(o<=0||o>a)}fullDraw(t){if(this.path.stopRealTimeDrawing(),this.path.drawFull(t),t.pathPoints&&t.pathPoints.length>0){const e=t.pathPoints[t.pathPoints.length-1];this.moveRobotToPoint(e,t.pathHeader.direction,!1)}else this.robot.clear()}convertToRobotPoint(t,e){const i=e+this.appService.robotConfig.rotationCorrection;return{x:t.x,y:t.y,rotation:i*Math.PI/180,type:t.type}}moveRobotToPoint(t,e,i=!0){const s=this.convertToRobotPoint(t,e);i?this.robot.moveTo(s):(this.robot.remove(),this.robot.draw(s))}incrementalDraw(t){var o;if(!this.lastDrawnPathData||!t.pathPoints)return;this.path.drawIncremental(t);const e=((o=this.lastDrawnPathData.pathPoints)==null?void 0:o.length)||0,i=t.pathPoints.slice(e);if(i.length===0)return;if(this.appService.robotConfig.speed>0)i.forEach(a=>{this.moveRobotToPoint(a,t.pathHeader.direction,!0)});else{const a=i[i.length-1];this.moveRobotToPoint(a,t.pathHeader.direction,!1)}}batchProcessRobotQueue(t=!1){this.robot.batchProcessQueue(t)}updatePositionByOrigin(t,e){this.path.updatePositionByOrigin(t,e),this.robot.updatePositionByOrigin(t,e)}clear(){this.lastDrawnPathData=null,this.path.clear(),this.robot.clear()}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.path.destroy(),this.robot.destroy()}}class qx extends L{constructor(e){super();g(this,"colorGradients",[]);g(this,"cellSize",2);this.appService=e,this.appService.appContainer.addToLayer(ac,this);const i=this.appService.heatMapConfig;this.colorGradients=i.colorGradients.map(s=>new rt(s).toArray().slice(0,3).join(",")),this.cellSize=i.cellSize}draw(e,i=.8){this.removeChildren();const{useGradient:s}=this.appService.heatMapConfig,n=s?this.gradientDrawing(e):this.gridDrawing(e);this.croppingHeatmap(n),n.alpha=i,this.addChild(n)}croppingHeatmap(e){var a;const i=((a=this.appService.mapState)==null?void 0:a.origin)||{x:0,y:0},n=this.appService.mapManager.roomFill.children.filter(h=>h instanceof H),o=new H;for(const h of n)o.context.instructions.push(...h.context.instructions);o.context.dirty=!0,o.position.set(-i.x,-i.y),e.setMask({mask:o}),this.addChild(o)}gridDrawing(e){const i=[],s=[],n=e.length,o=e[0].length;for(let c=0;c<n;c++)for(let d=0;d<o;d++){const u=e[c][d],p=this.cellSize/2,f=u.x-p,y=u.y-p,m=u.x+p,x=u.y+p;i.push(f,y),s.push(u.signal),i.push(m,y),s.push(u.signal),i.push(m,x),s.push(u.signal),i.push(f,y),s.push(u.signal),i.push(m,x),s.push(u.signal),i.push(f,x),s.push(u.signal)}const a=new Di({attributes:{aPosition:new Float32Array(i),aSignal:new Float32Array(s)}}),h=new Ie({glProgram:new Je({vertex:`
503
503
  in vec2 aPosition;
504
504
  in float aSignal;
505
505
  uniform mat3 uProjectionMatrix;
@@ -741,4 +741,4 @@ fn mainFragment(
741
741
 
742
742
  return vec4<f32>(color, 1.0);
743
743
  }
744
- `,entryPoint:"main"}})}),l=new xa({geometry:a,shader:h});return l.alpha=.8,l}updatePositionByOrigin(e,i){this.position.set(e,i)}destroy(){this.removeChildren(),this.cacheAsTexture(!1)}}class Kx{constructor(t){g(this,"heatmap");g(this,"pointsTopLeftOrigin",[]);g(this,"signalGrid",[]);g(this,"cellSize",2);g(this,"maxDistance",14);g(this,"smoothIterations",10);g(this,"heatmapAlpha",.8);g(this,"isHeatmapDrawn",!1);g(this,"loadTimer",null);g(this,"pendingPoints",null);this.appService=t,this.heatmap=new qx(t);const e=t.heatMapConfig;this.cellSize=e.cellSize,this.maxDistance=e.maxDistance,this.smoothIterations=e.smoothIterations,this.heatmapAlpha=e.heatmapAlpha}draw(t){const e=this.appService;if(!e.isMapDrawn){this.pendingPoints=t;return}this.pendingPoints=null;const{minX:i,minY:s}=e.mapManager.mapBounds,n=t.map(o=>({x:+(o.x-i).toFixed(0),y:+(o.y-s).toFixed(0),signal:o.signal}));this.signalGrid=this.calculateInterpolatedSignal(n),this.heatmap.draw(this.signalGrid,this.heatmapAlpha),this.isHeatmapDrawn=!0}onMapLoaded(){this.loadTimer||(this.pendingPoints&&this.draw(this.pendingPoints),this.loadTimer=setTimeout(()=>{this.loadTimer=null},200))}calculateInterpolatedSignal(t){var p;const e=this.appService,i=((p=e.mapState)==null?void 0:p.origin)||{x:0,y:0};let{minX:s,minY:n,maxX:o,maxY:a}=e.mapManager.mapBounds;n=n-i.y,s=s-i.x,a=a-i.y,o=o-i.x;const h=Math.ceil((a-n)/this.cellSize),l=Math.ceil((o-s)/this.cellSize),c=Array(h).fill(null).map(()=>Array(l).fill(null));for(let f=0;f<h;f++){const y=n+f*this.cellSize+this.cellSize/2,m=Math.min(this.cellSize,a-(y-this.cellSize/2));for(let x=0;x<l;x++){const S=s+x*this.cellSize+this.cellSize/2,v=Math.min(this.cellSize,o-(S-this.cellSize/2));let b=0,P=!1;for(let w=0;w<t.length;w++){const C=t[w];if(Math.abs(S-C.x)<=v/2&&Math.abs(y-C.y)<=m/2){const k=1-C.signal/7;b=Math.round(Math.max(b,k)*10)/10,P=!0}}c[f][x]={x:S,y,signal:b,hasPoint:P}}}const d=(f,y)=>{if(t.length===0)return 0;let m=0,x=0;for(const S of t){const v=Math.sqrt((f-S.x)**2+(y-S.y)**2);if(v<=this.maxDistance){const b=1/(1+v),P=1-S.signal/7;x+=b*P,m+=b}}return m===0?0:Math.round(x/m*1e3)/1e3},u=(f,y=1)=>{for(let m=0;m<y;m++){const x=f.map(S=>[...S]);for(let S=1;S<h-1;S++)for(let v=1;v<l-1;v++)if(!f[S][v].hasPoint){let b=0,P=0;const w=4;for(let C=-w;C<=w;C++)for(let k=-w;k<=w;k++){if(C===0&&k===0)continue;const M=S+C,T=v+k;if(M>=0&&M<h&&T>=0&&T<l){const I=1/(1+Math.sqrt(C*C+k*k)*.3);b+=f[M][T].signal*I,P+=I}}if(P>0){const C=b/P,k=.6,M=.4;x[S][v].signal=f[S][v].signal*k+C*M,x[S][v].signal>.1&&(x[S][v].signal=Math.max(x[S][v].signal,.2))}}for(let S=0;S<h;S++)for(let v=0;v<l;v++)f[S][v].signal=x[S][v].signal}};for(let f=0;f<h;f++)for(let y=0;y<l;y++){const m=c[f][y];m.hasPoint||(m.signal=d(m.x,m.y))}return u(c,this.smoothIterations),c}updatePositionByOrigin(t,e){this.heatmap.updatePositionByOrigin(t,e)}destroy(){this.heatmap.destroy()}}class pc extends L{constructor(e){super();g(this,"throttledUpdateScale");this.appService=e,this.throttledUpdateScale=At(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.updateScale(this.appService.currentScale),this.registerScaleListener()}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}updateScale(e){e!==0&&this.scale.set(1/e)}destroy(e){this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(e)}}class Wi extends pc{constructor(e,i){super(e);g(this,"background");g(this,"icon");g(this,"options");this.appService=e,this.options=i,this.background=new H,this.addChild(this.background),this.icon=new Xt(e),this.addChild(this.icon),this.eventMode="static",this.render(),this.setupHitArea(),this.setupEvents()}setupHitArea(){const e=this.appService,i=this.options.config||e.controlsConfig,s=8,n=i.iconWrapperWidth+s*2,o=i.iconWrapperHeight+s*2;this.hitArea=new et(-n/2,-o/2,n,o)}async render(){this.renderBackground(),this.renderIcon()}renderBackground(){const e=this.appService,i=this.options.config||e.controlsConfig;this.background.clear(),this.background.roundRect(-i.iconWrapperWidth/2,-i.iconWrapperHeight/2,i.iconWrapperWidth,i.iconWrapperHeight,i.iconWrapperBorderRadius).fill(this.options.backgroundColor)}async renderIcon(){try{const e=this.appService,i=this.options.config||e.controlsConfig;await this.icon.loadTextureAndSetSize(this.options.iconAlias,{width:i.iconWidth,height:i.iconHeight,sizeFixed:!1}),this.icon.visible=!0}catch(e){A.error(`Failed to load icon: ${this.options.iconAlias}`,e)}}destroy(){super.destroy()}}class fc extends Wi{constructor(e,i){super(e,i);g(this,"isRotating",!1);g(this,"hasRotated",!1);g(this,"rotationCenter",{x:0,y:0});g(this,"lastAngle",0);g(this,"clickHandler",null);g(this,"handleRotationPointerMove",e=>{var o,a;if(!this.isRotating)return;this.hasRotated=!0;const i=this.parent.toLocal(e.global),s=Math.atan2(i.y-this.rotationCenter.y,i.x-this.rotationCenter.x),n=s-this.lastAngle;(a=(o=this.options).onRotationMove)==null||a.call(o,n),this.lastAngle=s});g(this,"handleRotationPointerUp",()=>{var e,i;this.isRotating&&(this.isRotating=!1,this.hasRotated&&((i=(e=this.options).onRotationEnd)==null||i.call(e)),this.hasRotated=!1)});g(this,"handleRotationCancel",()=>{var e,i;this.isRotating&&(this.isRotating=!1,this.hasRotated&&((i=(e=this.options).onRotationEnd)==null||i.call(e)),this.hasRotated=!1)});this.appService=e,this.setupRotationEventListeners()}setupRotationEventListeners(){const{emitter:e}=this.appService;this.appService.emitter.on("gestureHijackPointerMove",this.handleRotationPointerMove),e.on("gestureHijackPointerUp",this.handleRotationPointerUp),e.on("gestureHijackCancel",this.handleRotationCancel)}cleanupRotationEventListeners(){const{emitter:e}=this.appService;e.off("gestureHijackPointerMove",this.handleRotationPointerMove),e.off("gestureHijackPointerUp",this.handleRotationPointerUp),e.off("gestureHijackCancel",this.handleRotationCancel)}setupEvents(){this.options.onClick&&(this.clickHandler=new vt(this,{onClick:()=>{var e,i;this.hasRotated||(i=(e=this.options).onClick)==null||i.call(e)},stopPropagation:!1})),this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(e){e.stopPropagation(),this.startRotation(e)}startRotation(e){var n,o;this.isRotating=!0,this.hasRotated=!1;const i=this.options.getTargetPoints();this.rotationCenter=ee(i);const s=this.parent.toLocal(e.global);this.lastAngle=Math.atan2(s.y-this.rotationCenter.y,s.x-this.rotationCenter.x),(o=(n=this.options).onRotationStart)==null||o.call(n,this.rotationCenter),this.appService.emitter.emit("gestureHijackStart",e)}isCurrentlyRotating(){return this.isRotating}stopRotation(){var e,i;this.isRotating&&(this.isRotating=!1,this.hasRotated&&((i=(e=this.options).onRotationEnd)==null||i.call(e)),this.hasRotated=!1)}destroy(){var e;this.stopRotation(),(e=this.clickHandler)==null||e.destroy(),this.cleanupRotationEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Ds extends Wi{constructor(e,i){super(e,i);g(this,"clickHandler",null);this.appService=e}setupEvents(){this.clickHandler=new vt(this,{onClick:this.options.onClick,stopPropagation:!0})}destroy(){var e;(e=this.clickHandler)==null||e.destroy(),super.destroy()}}class Ze extends Wi{constructor(e,i){super(e,i);g(this,"isScaling",!1);g(this,"initialButtonPosition",null);g(this,"dragStartPosition",null);g(this,"handleScalePointerMove",e=>{var o,a;if(!this.isScaling||!this.initialButtonPosition||!this.dragStartPosition)return;const i=this.parent.toLocal(e.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y;(a=(o=this.options).onScaleMove)==null||a.call(o,{deltaX:s,deltaY:n})});g(this,"handleScalePointerUp",()=>{var e,i;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,(i=(e=this.options).onScaleEnd)==null||i.call(e))});g(this,"handleScaleCancel",()=>{var e,i;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,(i=(e=this.options).onScaleEnd)==null||i.call(e))});this.appService=e,this.setupScaleEventListeners()}setupScaleEventListeners(){const{emitter:e}=this.appService;e.on("gestureHijackPointerMove",this.handleScalePointerMove),e.on("gestureHijackPointerUp",this.handleScalePointerUp),e.on("gestureHijackCancel",this.handleScaleCancel)}cleanupScaleEventListeners(){const{emitter:e}=this.appService;e.off("gestureHijackPointerMove",this.handleScalePointerMove),e.off("gestureHijackPointerUp",this.handleScalePointerUp),e.off("gestureHijackCancel",this.handleScaleCancel)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(e){e.stopPropagation(),this.startScaling(e)}startScaling(e){var i,s,n,o;if(this.isScaling=!0,this.dragStartPosition=this.parent.toLocal(e.global),"initialButtonPosition"in this.options)this.initialButtonPosition={x:this.position.x,y:this.position.y},(s=(i=this.options).onScaleStart)==null||s.call(i);else{const a=this.options.getTargetPoints(),h=this.options.getButtonIndex();h>=0&&h<a.length&&(this.initialButtonPosition={...a[h]}),(o=(n=this.options).onScaleStart)==null||o.call(n,h)}this.appService.emitter.emit("gestureHijackStart",e)}isCurrentlyScaling(){return this.isScaling}stopScaling(){var e,i;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,(i=(e=this.options).onScaleEnd)==null||i.call(e))}destroy(){this.stopScaling(),this.cleanupScaleEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Fs extends Wi{constructor(e,i){super(e,i);g(this,"isMoving",!1);g(this,"dragStartPosition",null);g(this,"handleMovePointerMove",e=>{var i,s;!this.isMoving||!this.dragStartPosition||(s=(i=this.options).onMoveMove)==null||s.call(i,e)});g(this,"handleMovePointerUp",()=>{var e,i;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,(i=(e=this.options).onMoveEnd)==null||i.call(e))});g(this,"handleMoveCancel",()=>{var e,i;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,(i=(e=this.options).onMoveEnd)==null||i.call(e))});this.appService=e,this.setupMoveEventListeners()}setupMoveEventListeners(){const{emitter:e}=this.appService;e.on("gestureHijackPointerMove",this.handleMovePointerMove),e.on("gestureHijackPointerUp",this.handleMovePointerUp),e.on("gestureHijackCancel",this.handleMoveCancel)}cleanupMoveEventListeners(){const{emitter:e}=this.appService;e.off("gestureHijackPointerMove",this.handleMovePointerMove),e.off("gestureHijackPointerUp",this.handleMovePointerUp),e.off("gestureHijackCancel",this.handleMoveCancel)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(e){e.stopPropagation(),this.startMoving(e)}startMoving(e){var i,s;this.isMoving=!0,this.dragStartPosition=this.parent.toLocal(e.global),(s=(i=this.options).onMoveStart)==null||s.call(i),this.appService.emitter.emit("gestureHijackStart",e)}isCurrentlyMoving(){return this.isMoving}getDragStartPosition(){return this.dragStartPosition?{...this.dragStartPosition}:null}stopMoving(){var e,i;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,(i=(e=this.options).onMoveEnd)==null||i.call(e))}destroy(){this.stopMoving(),this.cleanupMoveEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Lr extends H{constructor(e,i){super();g(this,"fillOptions");g(this,"isDragging",!1);g(this,"dragStartPosition",null);g(this,"handlePointerDown",e=>{e.stopPropagation(),this.startDragging(e)});g(this,"handleDragPointerMove",e=>{var i,s;!this.isDragging||!this.dragStartPosition||(s=(i=this.fillOptions).onDragMove)==null||s.call(i,e)});g(this,"handleDragPointerUp",()=>{var e,i;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,(i=(e=this.fillOptions).onDragEnd)==null||i.call(e))});g(this,"handleDragCancel",()=>{var e,i;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,(i=(e=this.fillOptions).onDragEnd)==null||i.call(e))});this.appService=e,this.fillOptions=i,this.setupInteraction(),this.setupDragEventListeners(),this.draw()}setupInteraction(){this.fillOptions.enableInteraction&&(this.eventMode="static",this.on("pointerdown",this.handlePointerDown))}setupDragEventListeners(){const{emitter:e}=this.appService;e.on("gestureHijackPointerMove",this.handleDragPointerMove),e.on("gestureHijackPointerUp",this.handleDragPointerUp),e.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:e}=this.appService;e.off("gestureHijackPointerMove",this.handleDragPointerMove),e.off("gestureHijackPointerUp",this.handleDragPointerUp),e.off("gestureHijackCancel",this.handleDragCancel)}startDragging(e){var s,n;this.isDragging=!0;const i=this.parent.toLocal(e.global);this.dragStartPosition={x:i.x,y:i.y},(n=(s=this.fillOptions).onDragStart)==null||n.call(s,e),this.appService.emitter.emit("gestureHijackStart",e)}draw(){const{points:e,fillColor:i}=this.fillOptions;if(e.length<3)return;this.clear();const s=e.flatMap(n=>[n.x,n.y]);this.setFillStyle({color:i}).poly(s).fill()}getDragStartPosition(){return this.dragStartPosition}updateOptions(e){this.fillOptions={...this.fillOptions,...e},e.enableInteraction!==void 0&&(this.off("pointerdown",this.handlePointerDown),this.setupInteraction()),this.draw()}updatePoints(e){this.fillOptions.points=e,this.draw()}updateFillColor(e){this.fillOptions.fillColor=e,this.draw()}stopDragging(){this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null)}isCurrentlyDragging(){return this.isDragging}setInteractionEnabled(e){this.fillOptions.enableInteraction=e,e?(this.eventMode="static",this.on("pointerdown",this.handlePointerDown)):(this.eventMode="auto",this.off("pointerdown",this.handlePointerDown),this.isDragging&&this.stopDragging())}destroy(){this.stopDragging(),this.cleanupDragEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Nt extends L{constructor(e,i){super();g(this,"borderOptions");g(this,"solidLine",null);g(this,"dashGraphics",null);g(this,"fillGraphics",null);g(this,"handleAntiScale",()=>{this.drawBorder()});this.appService=e,this.borderOptions={...i},this.drawBorder(),this.setupAntiScaleListener(),this.eventMode="none"}setupAntiScaleListener(){this.appService.emitter.on("antiScale",this.handleAntiScale)}drawBorder(){const{points:e=[],closePath:i=!1,style:s}=this.borderOptions;e.length<2||(this.clearBorder(),s.fillColor!==void 0&&i&&this.drawFill(e,s),s.isDashed?this.drawContinuousDashedBorder(e,i,s):this.drawSolidBorder(e,i,s))}drawFill(e,i){if(!(!i.fillColor||e.length<3)){this.fillGraphics&&(this.removeChild(this.fillGraphics),this.fillGraphics.destroy()),this.fillGraphics=new H,this.fillGraphics.setFillStyle({color:i.fillColor}),this.fillGraphics.moveTo(e[0].x,e[0].y);for(let s=1;s<e.length;s++)this.fillGraphics.lineTo(e[s].x,e[s].y);this.fillGraphics.closePath(),this.fillGraphics.fill(),this.addChild(this.fillGraphics)}}drawSolidBorder(e,i,s){const n=this.appService;this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy()),this.solidLine=new H;const o=n.getApp().toFixedSize(s.width);this.solidLine.setStrokeStyle({color:s.color,width:o}),this.solidLine.moveTo(e[0].x,e[0].y);for(let a=1;a<e.length;a++)this.solidLine.lineTo(e[a].x,e[a].y);i&&this.solidLine.lineTo(e[0].x,e[0].y),this.solidLine.stroke(),this.addChild(this.solidLine)}drawContinuousDashedBorder(e,i,s){if(e.length<2)return;if(!s.dashArray||s.dashArray.length!==2||s.dashArray[0]<=0||s.dashArray[1]<=0){A.warn("Invalid dashArray:",s.dashArray);return}const n=this.appService;this.dashGraphics=new H;const o=n.getApp().toFixedSize(s.width);this.dashGraphics.setStrokeStyle({color:s.color,width:o});const a=Math.max(n.getApp().toFixedSize(s.dashArray[0]),1),h=Math.max(n.getApp().toFixedSize(s.dashArray[1]),1),l=i?[...e,e[0]]:e;this.drawContinuousPathDashes(this.dashGraphics,l,a,h),this.dashGraphics.stroke(),this.addChild(this.dashGraphics)}drawContinuousPathDashes(e,i,s,n){if(i.length<2)return;if(s<=0||n<=0){A.warn("Invalid dash parameters:",{dashLength:s,gapLength:n});return}const o=this.calculatePathSegments(i),a=o.reduce((c,d)=>c+d.length,0);if(a===0)return;const h=s+n;let l=0;for(;l<a;){const c=l+s;c<=a?this.drawContinuousDashSegment(e,o,l,c):this.drawContinuousDashSegment(e,o,l,a),l+=h}}calculatePathSegments(e){const i=[];for(let s=0;s<e.length-1;s++){const n=e[s],o=e[s+1],a=o.x-n.x,h=o.y-n.y,l=Math.sqrt(a*a+h*h);i.push({start:n,end:o,length:l})}return i}drawContinuousDashSegment(e,i,s,n){if(s>=n)return;let o=0,a=!1,h=null;for(const l of i){const c=o,d=o+l.length;if(d>s&&c<n){const u=Math.max(s,c),p=Math.min(n,d),f=(u-c)/l.length,y=(p-c)/l.length,m={x:l.start.x+(l.end.x-l.start.x)*f,y:l.start.y+(l.end.y-l.start.y)*f},x={x:l.start.x+(l.end.x-l.start.x)*y,y:l.start.y+(l.end.y-l.start.y)*y};a?h&&Math.sqrt(Math.pow(m.x-h.x,2)+Math.pow(m.y-h.y,2))>.1&&e.lineTo(m.x,m.y):(e.moveTo(m.x,m.y),a=!0),e.lineTo(x.x,x.y),h=x}if(o+=l.length,o>=n)break}}clearBorder(){this.fillGraphics&&(this.removeChild(this.fillGraphics),this.fillGraphics.destroy(),this.fillGraphics=null),this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy(),this.solidLine=null),this.dashGraphics&&(this.removeChild(this.dashGraphics),this.dashGraphics.destroy(),this.dashGraphics=null)}updateStyle(e){this.borderOptions.style={...this.borderOptions.style,...e},this.drawBorder()}updatePoints(e){this.borderOptions.points=e,this.drawBorder()}setClosePath(e){this.borderOptions.closePath=e,this.drawBorder()}getOptions(){return{...this.borderOptions}}destroy(){this.appService.emitter.off("antiScale",this.handleAntiScale),this.clearBorder(),super.destroy()}}class Ui extends Es{constructor(e,{text:i,style:s}){super({text:i,style:s});g(this,"throttledUpdateScale");this.appService=e,this.throttledUpdateScale=At(this.updateScale.bind(this),20,{leading:!0,trailing:!0}),this.registerScaleListener(),this.updateScale(this.appService.currentScale)}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}updateScale(e){e<=0||this.scale.set(1/e)}setBaseFontSize(e){this.style.fontSize=e}updateText(e){this.text=e}destroy(e){this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(e)}}const Ct=class Ct extends L{constructor(e){super();g(this,"appService");g(this,"zoneData");g(this,"zoneType");g(this,"zoneConfig");g(this,"controlsConfig");g(this,"zoneEvents");g(this,"controlFill");g(this,"zoneBorder");g(this,"outlineBorder");g(this,"moveLine");g(this,"sizeText");g(this,"controlButtons");g(this,"deleteButton",null);g(this,"rotateButton",null);g(this,"scaleButton",null);g(this,"moveButton",null);g(this,"totalRotationAngle",0);g(this,"rotationCenter",null);g(this,"initialZonePoints",[]);g(this,"initialButtonPosition",null);g(this,"dragStartPosition",null);g(this,"clickHandler",null);g(this,"throttledUpdateOutline");g(this,"handleDragStart",e=>{this.isEditingEnabled()&&(this.initialZonePoints=this.zoneData.points.map(i=>({...i})),this.dragStartPosition=this.parent.toLocal(e.global),this.appService.getApp().requestRender("zone-drag",!0))});g(this,"handleDragMove",e=>{if(!this.isEditingEnabled()||this.initialZonePoints.length===0||!this.dragStartPosition)return;const i=this.parent.toLocal(e.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y;this.applyTranslation(s,n)});g(this,"handleDragEnd",()=>{var e,i;this.initialZonePoints=[],this.dragStartPosition=null,this.appService.getApp().stopRender("zone-drag"),(i=(e=this.zoneEvents).onUpdate)==null||i.call(e,this.getZoneData())});g(this,"handleRotationStart",e=>{this.totalRotationAngle=0,this.rotationCenter=e,this.initialZonePoints=this.zoneData.points.map(i=>({...i})),this.appService.getApp().requestRender("zone-rotate",!0)});g(this,"handleRotationMove",e=>{this.totalRotationAngle+=e,this.applyRotation(this.totalRotationAngle)});g(this,"handleRotationEnd",()=>{var e,i;this.rotationCenter=null,this.totalRotationAngle=0,this.initialZonePoints=[],this.appService.getApp().stopRender("zone-rotate"),(i=(e=this.zoneEvents).onUpdate)==null||i.call(e,this.getZoneData())});g(this,"handleScaleStart",()=>{this.initialZonePoints=this.zoneData.points.map(i=>({...i}));const e=Ct.BUTTON_INDICES.SCALE;e<this.zoneData.points.length&&(this.initialButtonPosition={...this.zoneData.points[e]}),this.appService.getApp().requestRender("zone-scale",!0)});g(this,"handleScaleMove",({deltaX:e,deltaY:i})=>{if(this.initialZonePoints.length===0||!this.initialButtonPosition)return;const s={x:this.initialButtonPosition.x+e,y:this.initialButtonPosition.y+i};this.applyEdgeBasedScale(s)});g(this,"handleScaleEnd",()=>{var e,i;this.initialZonePoints=[],this.initialButtonPosition=null,this.appService.getApp().stopRender("zone-scale"),(i=(e=this.zoneEvents).onUpdate)==null||i.call(e,this.getZoneData())});g(this,"handleMoveStart",()=>{this.initialZonePoints=this.zoneData.points.map(e=>({...e})),this.appService.getApp().requestRender("zone-move",!0)});g(this,"handleMove",e=>{var a;if(!this.isEditingEnabled()||this.initialZonePoints.length===0)return;const i=this.parent.toLocal(e.global),s=(a=this.moveButton)==null?void 0:a.getDragStartPosition();if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.applyTranslation(n,o)});g(this,"handleMoveEnd",()=>{var e,i;this.initialZonePoints=[],this.appService.getApp().stopRender("zone-move"),(i=(e=this.zoneEvents).onUpdate)==null||i.call(e,this.getZoneData())});g(this,"handleDelete",()=>{var e,i;(i=(e=this.zoneEvents).onRemove)==null||i.call(e,this.zoneData.id)});const{appService:i,zoneData:s,zoneType:n,events:o={}}=e;this.appService=i,this.zoneType=n,this.zoneEvents=o,this.zoneConfig=this.getZoneConfig(),this.controlsConfig=this.getControlsConfig();const a=this.validateAndCorrectZoneSize(s.points),h=bs(a);this.zoneData={...s,points:h},this.throttledUpdateOutline=At(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.createControlButtons(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateOutline),this.appService.emitter.on("mapRotationUpdate",this.throttledUpdateOutline)}updateOutlineForScale(){this.isEditingEnabled()&&(this.updateOutlineBorder(),this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition())}getZoneConfig(){const{controls:e}=this.appService.getConfig();return e[this.zoneType]}getControlsConfig(){const{controls:e}=this.appService.getConfig();return e}validateAndCorrectZoneSize(e){if(e.length<4)return e;const i=this.appService.metersToPixels(this.zoneConfig.minSize),[s,n,,o]=e,a=Q(s,n),h=Q(s,o);if(a>=i&&h>=i)return e;const l=ee(e),c=pt(q(s,n)),d=pt(q(s,o)),u=Math.max(a,i),p=Math.max(h,i),f=u/2,y=p/2;return[{x:l.x-c.x*f-d.x*y,y:l.y-c.y*f-d.y*y},{x:l.x+c.x*f-d.x*y,y:l.y+c.y*f-d.y*y},{x:l.x+c.x*f+d.x*y,y:l.y+c.y*f+d.y*y},{x:l.x-c.x*f+d.x*y,y:l.y-c.y*f+d.y*y}]}getEditingIdsKey(){switch(this.zoneType){case"forbiddenSweepZone":return"editingForbiddenSweepZoneIds";case"forbiddenMopZone":return"editingForbiddenMopZoneIds";case"cleanZone":return"editingCleanZoneIds";default:return"editingForbiddenSweepZoneIds"}}isEditingEnabled(){const e=this.getEditingIdsKey();return this.appService.runtimeSnapshot[e].includes(this.zoneData.id)}initializeComponents(){this.outlineBorder=this.createOutlineBorder(),this.addChild(this.outlineBorder),this.controlFill=this.createControlFill(),this.addChild(this.controlFill),this.zoneBorder=this.createBorder(),this.addChild(this.zoneBorder),this.moveLine=this.createMoveLine(),this.addChild(this.moveLine),this.sizeText=this.createSizeText(),this.addChild(this.sizeText),this.controlButtons=new L,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.drawZone()}createControlButtons(){const e=this.calculateOutlinePoints();if(e.length<4)return;this.deleteButton=new Ds(this.appService,{iconAlias:"deleteIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onClick:this.handleDelete}),this.deleteButton.position.set(e[Ct.BUTTON_INDICES.REMOVE].x,e[Ct.BUTTON_INDICES.REMOVE].y),this.zoneConfig.showRotateButton&&(this.rotateButton=new fc(this.appService,{iconAlias:"rotateIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,onRotationStart:this.handleRotationStart,onRotationMove:this.handleRotationMove,onRotationEnd:this.handleRotationEnd}),this.rotateButton.position.set(e[Ct.BUTTON_INDICES.ROTATE].x,e[Ct.BUTTON_INDICES.ROTATE].y)),this.scaleButton=new Ze(this.appService,{iconAlias:"scaleIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,getButtonIndex:()=>Ct.BUTTON_INDICES.SCALE,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(e[Ct.BUTTON_INDICES.SCALE].x,e[Ct.BUTTON_INDICES.SCALE].y);const i=this.calculateMoveButtonPosition();this.moveButton=new Fs(this.appService,{iconAlias:"moveIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(i.x,i.y),this.controlButtons.addChild(this.deleteButton),this.rotateButton&&this.controlButtons.addChild(this.rotateButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton)}createControlFill(){const e=this.isEditingEnabled();return new Lr(this.appService,{points:this.zoneData.points,fillColor:this.zoneConfig.fillColor,enableInteraction:e,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createBorder(){const i=this.isEditingEnabled()?this.zoneConfig.editing:this.zoneConfig.normal;return new Nt(this.appService,{points:this.zoneData.points,closePath:!0,style:{color:this.zoneConfig.strokeColor,width:this.zoneConfig.strokeWidth,isDashed:i.isDashed,dashArray:i.dashArray}})}createOutlineBorder(){const e=this.calculateOutlinePoints();return new Nt(this.appService,{points:e,closePath:!0,style:{color:this.zoneConfig.outlineStrokeColor,width:this.zoneConfig.outlineStrokeWidth,isDashed:this.zoneConfig.outlineDashed,dashArray:this.zoneConfig.outlineDashArray,fillColor:this.zoneConfig.outlineFillColor}})}createMoveLine(){const e=this.calculateOutlinePoints(),i=this.calculateMoveLinePoints(e);return new Nt(this.appService,{points:i,closePath:!1,style:{color:this.zoneConfig.outlineStrokeColor,width:this.zoneConfig.outlineStrokeWidth,isDashed:this.zoneConfig.outlineDashed,dashArray:this.zoneConfig.outlineDashArray}})}calculateOutlinePoints(){const{points:e}=this.zoneData;if(e.length<4)return e;const i=this.appService.getApp().toFixedSize(this.zoneConfig.outlineOffset);return Ir(e,i)}calculateMoveLinePoints(e){if(e.length<4)return[];const i=e[Ct.BUTTON_INDICES.MOVE],s=this.calculateMoveButtonPosition();return[i,s]}createSizeText(){const e=this.calculateZoneSizeText(),i=new Ui(this.appService,{text:e,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.zoneConfig.textColor,align:"center"}});i.anchor.set(.5);const s=this.calculateSizeTextPosition();i.position.set(s.x,s.y);const n=this.calculateSizeTextRotation();return i.rotation=n,i.eventMode="none",i}calculateZoneSizeText(){const{points:e}=this.zoneData;if(e.length<4)return"0m*0m";const[i,s,,n]=e,o=Q(i,s),a=Q(i,n),h=this.appService.pixelsToMeters(o),l=this.appService.pixelsToMeters(a),c=this.appService.metersToDisplayUnit(h),d=this.appService.metersToDisplayUnit(l),u=this.appService.runtimeSnapshot.unitLabel;return`${c.toFixed(1)}${u}*${d.toFixed(1)}${u}`}calculateSizeTextPosition(){const{points:e}=this.zoneData;if(e.length<4)return{x:0,y:0};const[i,s,n,o]=e,{textPosition:a,textOffset:h}=this.zoneConfig,l=this.appService.getApp().toFixedSize(h);let c,d;switch(a){case"top":{c={x:(i.x+s.x)/2,y:(i.y+s.y)/2};const u=pt(q(s,i)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}case"right":{c={x:(s.x+n.x)/2,y:(s.y+n.y)/2};const u=pt(q(s,n)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}case"bottom":{c={x:(o.x+n.x)/2,y:(o.y+n.y)/2};const u=pt(q(o,n)),p={x:-u.y,y:u.x};d={x:p.x*l,y:p.y*l};break}case"left":{c={x:(i.x+o.x)/2,y:(i.y+o.y)/2};const u=pt(q(o,i)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}default:c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},d={x:0,y:l};break}return{x:c.x+d.x,y:c.y+d.y}}calculateSizeTextRotation(){const{points:e}=this.zoneData;if(e.length<4)return 0;const[i,s,n,o]=e,{textPosition:a}=this.zoneConfig;let h,l;switch(a){case"top":h=i,l=s;break;case"right":h=s,l=n;break;case"bottom":h=n,l=o;break;case"left":h=o,l=i;break;default:h=i,l=s;break}const c=this.appService.appContainer.getMapRotationRadians();return Xe(h,l,c)}calculateMoveButtonPosition(){const e=this.calculateOutlinePoints();if(e.length<4)return{x:0,y:0};const{controls:i}=this.appService.getConfig(),s=e[Ct.BUTTON_INDICES.MOVE],n=e[2],o=e[0],a=this.appService.getApp().toFixedSize(i.moveButtonOffset);return Is(s,n,o,a)}applyTranslation(e,i){this.zoneData.points=this.initialZonePoints.map(s=>({x:s.x+e,y:s.y+i})),this.drawZone(),this.updateControlButtonsPosition()}applyRotation(e){!this.rotationCenter||this.initialZonePoints.length===0||(this.zoneData.points=Er(this.initialZonePoints,this.rotationCenter,e),this.drawZone(!1),this.updateControlButtonsPosition())}applyEdgeBasedScale(e){if(this.initialZonePoints.length<4)return;const{FIXED:i}=Ct.BUTTON_INDICES,{x:s,y:n}=this.initialZonePoints[i],[,o,,a]=this.initialZonePoints,h={x:s,y:n},l=q(h,o),c=q(h,a),d=q(h,e),u=ie(l),p=ie(c);if(u===0||p===0)return;const f=this.appService.metersToPixels(this.zoneConfig.minSize),[y,m]=[he(d,l,u,f),he(d,c,p,f)];this.zoneData.points=[h,{x:s+l.x*y,y:n+l.y*y},{x:s+l.x*y+c.x*m,y:n+l.y*y+c.y*m},{x:s+c.x*m,y:n+c.y*m}],this.drawZone(),this.updateControlButtonsPosition()}setupClickHandler(){this.clickHandler=new vt(this,{onClick:()=>{var e,i;this.isEditingEnabled()||(i=(e=this.zoneEvents)==null?void 0:e.onClick)==null||i.call(e,this.getZoneData())},stopPropagation:!1})}drawZone(e=!0){const{points:i}=this.zoneData;i.length<4||(this.controlFill.updatePoints(i),this.zoneBorder.updatePoints(i),this.updateOutlineBorder(),this.updateMoveLine(),this.updateSizeText(e))}updateOutlineBorder(){const e=this.calculateOutlinePoints();this.outlineBorder.updatePoints(e)}updateMoveLine(){const e=this.calculateOutlinePoints(),i=this.calculateMoveLinePoints(e);this.moveLine.updatePoints(i)}updateSizeText(e=!0){if(this.sizeText){if(e){const i=this.calculateZoneSizeText();this.sizeText.updateText(i)}this.updateSizeTextPosition()}}updateSizeTextPosition(){if(!this.sizeText)return;const e=this.calculateSizeTextPosition();this.sizeText.position.set(e.x,e.y);const i=this.calculateSizeTextRotation();this.sizeText.rotation=i}updateControlButtonsPosition(){if(!this.deleteButton||!this.scaleButton||!this.moveButton)return;const e=this.calculateOutlinePoints();if(e.length<4)return;const{REMOVE:i,ROTATE:s,SCALE:n}=Ct.BUTTON_INDICES,o=this.calculateMoveButtonPosition(),a=[{button:this.deleteButton,point:e[i]},{button:this.scaleButton,point:e[n]},{button:this.moveButton,point:o}];this.rotateButton&&a.push({button:this.rotateButton,point:e[s]}),a.forEach(({button:h,point:l})=>h.position.set(l.x,l.y))}updateEditState(){const e=this.isEditingEnabled();this.controlButtons.visible=e,!e&&this.getCurrentOperationState().hasAnyOperation&&this.stopAllOperations(),this.outlineBorder.visible=e,this.moveLine.visible=e,this.sizeText&&(this.sizeText.visible=e),e&&(this.updateOutlineBorder(),this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition()),this.controlFill.setInteractionEnabled(e),this.updateBorderStyle(e?this.zoneConfig.editing:this.zoneConfig.normal),this.zIndex=e?1e3:0}updateBorderStyle(e){this.zoneBorder.updateStyle({isDashed:e.isDashed,dashArray:e.dashArray})}getCurrentOperationState(){var o,a,h;const e=this.controlFill.isCurrentlyDragging(),i=((o=this.scaleButton)==null?void 0:o.isCurrentlyScaling())||!1,s=((a=this.rotateButton)==null?void 0:a.isCurrentlyRotating())||!1,n=((h=this.moveButton)==null?void 0:h.isCurrentlyMoving())||!1;return{isDragging:e,isScaling:i,isRotating:s,isMoving:n,hasAnyOperation:e||i||s||n}}stopAllOperations(){var e,i,s;this.controlFill.stopDragging(),(e=this.scaleButton)==null||e.stopScaling(),(i=this.rotateButton)==null||i.stopRotation(),(s=this.moveButton)==null||s.stopMoving()}stopDragging(){this.controlFill.stopDragging()}stopScaling(){var e;(e=this.scaleButton)==null||e.stopScaling()}stopRotating(){var e;(e=this.rotateButton)==null||e.stopRotation()}stopMoving(){var e;(e=this.moveButton)==null||e.stopMoving()}isCurrentlyDragging(){return this.controlFill.isCurrentlyDragging()}isCurrentlyScaling(){var e;return((e=this.scaleButton)==null?void 0:e.isCurrentlyScaling())||!1}isCurrentlyRotating(){var e;return((e=this.rotateButton)==null?void 0:e.isCurrentlyRotating())||!1}isCurrentlyMoving(){var e;return((e=this.moveButton)==null?void 0:e.isCurrentlyMoving())||!1}updateZoneData(e){const i=this.validateAndCorrectZoneSize(e.points),s=bs(i);this.zoneData={...e,points:s},this.drawZone(),this.updateControlButtonsPosition(),this.updateEditState()}getZoneData(){return{...this.zoneData}}refreshDisplay(){this.drawZone()}destroy(){var e,i,s,n,o,a,h,l,c,d,u;this.appService.emitter.off("antiScale",this.throttledUpdateOutline),this.appService.emitter.off("mapRotationUpdate",this.throttledUpdateOutline),(e=this.clickHandler)==null||e.destroy(),this.clickHandler=null,(i=this.deleteButton)==null||i.destroy(),(s=this.rotateButton)==null||s.destroy(),(n=this.scaleButton)==null||n.destroy(),(o=this.moveButton)==null||o.destroy(),this.deleteButton=null,this.rotateButton=null,this.scaleButton=null,this.moveButton=null,(a=this.zoneBorder)==null||a.destroy(),(h=this.outlineBorder)==null||h.destroy(),(l=this.moveLine)==null||l.destroy(),(c=this.sizeText)==null||c.destroy(),(d=this.controlFill)==null||d.destroy(),(u=this.controlButtons)==null||u.destroy(),super.destroy()}};g(Ct,"BUTTON_INDICES",{REMOVE:0,ROTATE:1,SCALE:2,MOVE:3,FIXED:0});let Li=Ct;class Or extends Li{constructor(t,e){super({appService:t,zoneData:e.zoneData,zoneType:"forbiddenSweepZone",events:{onRemove:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onRemoveForbiddenSweepZone)==null||n.call(s,i)},onUpdate:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onUpdateForbiddenSweepZone)==null||n.call(s,i)},onClick:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onClickForbiddenSweepZone)==null||n.call(s,i)}}})}static create(t,e){return new Or(t,{zoneData:e})}}class Gr extends Li{constructor(t,e){super({appService:t,zoneData:e.zoneData,zoneType:"forbiddenMopZone",events:{onRemove:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onRemoveForbiddenMopZone)==null||n.call(s,i)},onUpdate:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onUpdateForbiddenMopZone)==null||n.call(s,i)},onClick:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onClickForbiddenMopZone)==null||n.call(s,i)}}})}static create(t,e){return new Gr(t,{zoneData:e})}}class Wr extends Li{constructor(t,e){super({appService:t,zoneData:e.zoneData,zoneType:"cleanZone",events:{onRemove:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onRemoveCleanZone)==null||n.call(s,i)},onUpdate:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onUpdateCleanZone)==null||n.call(s,i)},onClick:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onClickCleanZone)==null||n.call(s,i)}}})}static create(t,e){return new Wr(t,{zoneData:e})}}class Ue extends H{constructor(e,i){super();g(this,"lineOptions");g(this,"strokeContext",null);g(this,"drawDashLine",()=>{const{start:e,end:i,style:s}=this.lineOptions;this.clear(),this.strokeContext&&this.strokeContext.destroy();const n=this.appService;this.strokeContext=new mt;const o=n.getApp().toFixedSize(s.width);this.strokeContext.setStrokeStyle({color:s.color,width:o}),this.drawDashedLineToContext(this.strokeContext,e.x,e.y,i.x,i.y,s.dashArray[0],s.dashArray[1]),this.strokeContext.stroke(),this.context=this.strokeContext});this.appService=e,this.lineOptions={...i},this.eventMode="static",this.drawDashLine(),this.setupAntiScaleListener()}setupAntiScaleListener(){this.appService.emitter.on("antiScale",this.drawDashLine)}drawDashedLineToContext(e,i,s,n,o,a,h){const l=n-i,c=o-s,d=Math.sqrt(l*l+c*c);if(d===0)return;const u=this.appService,p=u.getApp().toFixedSize(a),f=u.getApp().toFixedSize(h),y=p+f,m=d/y,x=Math.round(m);if(x===0){e.moveTo(i,s),e.lineTo(n,o);return}const S=d/x,v=S*(p/y),b=l/d,P=c/d;for(let w=0;w<x;w++){const C=w*S,k=C+v;if(C>=d)break;const M=Math.min(k,d),T=i+C*b,_=s+C*P,I=i+M*b,B=s+M*P;e.moveTo(T,_),e.lineTo(I,B)}}updatePoints(e,i){this.lineOptions.start=e,this.lineOptions.end=i,this.drawDashLine()}updateStyle(e){this.lineOptions.style={...this.lineOptions.style,...e},this.drawDashLine()}getOptions(){return{...this.lineOptions}}destroy(){this.appService.emitter.off("antiScale",this.drawDashLine),this.strokeContext&&this.strokeContext.destroy(),super.destroy()}}const Vt=class Vt extends L{constructor(e){super();g(this,"wallData");g(this,"wallConfig");g(this,"controlsConfig");g(this,"wallEvents");g(this,"appService");g(this,"wallLine");g(this,"outlineBorder");g(this,"moveLine");g(this,"lengthText");g(this,"controlButtons");g(this,"removeButton",null);g(this,"scaleButton",null);g(this,"moveButton",null);g(this,"initialWallPoints",[]);g(this,"initialButtonPosition",null);g(this,"isDragging",!1);g(this,"dragStartPosition",null);g(this,"throttledUpdateOutline");g(this,"throttledHandleScaleChange");g(this,"wallLineClickHandler",null);g(this,"handleRemove",()=>{var e,i;(i=(e=this.wallEvents).onRemove)==null||i.call(e,this.wallData.id)});g(this,"initializeOperation",()=>{this.initialWallPoints=this.wallData.points.map(e=>({...e}))});g(this,"finalizeOperation",()=>{var e,i;this.initialWallPoints=[],(i=(e=this.wallEvents).onUpdate)==null||i.call(e,this.getWallData())});g(this,"handleScaleStart",()=>{this.initializeOperation();const e=this.calculateOutlinePoints();e.length>Vt.BUTTON_INDICES.SCALE&&(this.initialButtonPosition={...e[Vt.BUTTON_INDICES.SCALE]}),this.appService.getApp().requestRender("virtualwall-scale",!0)});g(this,"handleScaleMove",({deltaX:e,deltaY:i})=>{if(this.initialWallPoints.length===0||!this.initialButtonPosition)return;const s={x:this.initialButtonPosition.x+e,y:this.initialButtonPosition.y+i};this.applyScaleAndRotation(s)});g(this,"handleScaleEnd",()=>{this.finalizeOperation(),this.initialButtonPosition=null,this.appService.getApp().stopRender("virtualwall-scale")});g(this,"handleMoveStart",()=>{this.initializeOperation(),this.appService.getApp().requestRender("virtualwall-move",!0)});g(this,"handleMove",e=>{var a;if(this.initialWallPoints.length===0)return;const i=this.parent.toLocal(e.global),s=this.getDragStartPosition()||((a=this.moveButton)==null?void 0:a.getDragStartPosition());if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.applyTranslation(n,o)});g(this,"handleMoveEnd",()=>{this.finalizeOperation(),this.appService.getApp().stopRender("virtualwall-move")});g(this,"handleScaleChange",()=>{this.redrawSolidLine(),this.setupWallLineHitArea()});g(this,"handleWallLinePointerDown",e=>{this.isEditingEnabled()&&(e.stopPropagation(),this.startDragging(e))});g(this,"handleDragPointerMove",e=>{!this.isDragging||!this.dragStartPosition||this.handleMove(e)});g(this,"handleDragPointerUp",()=>{this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.appService.getApp().stopRender("virtualwall-drag"),this.finalizeOperation())});g(this,"handleDragCancel",()=>{this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.appService.getApp().stopRender("virtualwall-drag"),this.handleMoveEnd())});const{appService:i,wallData:s,events:n={}}=e;this.appService=i,this.wallEvents=n,this.wallConfig=this.appService.controlsConfig.virtualWall,this.controlsConfig=this.appService.controlsConfig,this.wallData={...s,points:this.validateAndCorrectWallLength(s.points)},this.throttledHandleScaleChange=At(this.handleScaleChange.bind(this),30,{leading:!0,trailing:!0}),this.throttledUpdateOutline=At(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.registerScaleListener(),this.setupDragEventListeners()}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateOutline),this.appService.emitter.on("antiScale",this.throttledHandleScaleChange),this.appService.emitter.on("mapRotationUpdate",this.throttledUpdateOutline)}validateAndCorrectWallLength(e){if(e.length<2)return e;const[i,s]=e,n=this.appService.metersToPixels(this.wallConfig.minWidth),o=Q(i,s);if(o>=n)return e;if(o===0)return[i,{x:i.x+n,y:i.y}];const a=pt(q(i,s));return[i,{x:i.x+a.x*n,y:i.y+a.y*n}]}isEditingEnabled(){return this.appService.runtimeSnapshot.editingVirtualWallIds.includes(this.wallData.id)}updateOutlineForScale(){this.isEditingEnabled()&&(this.updateOutlineComponents(),this.updateControlButtonsPosition(),this.updateLengthTextPosition())}initializeComponents(){this.outlineBorder=this.createOutlineBorder(),this.addChild(this.outlineBorder),this.createWallLine(!1),this.addChild(this.wallLine),this.lengthText=this.createLengthText(),this.addChild(this.lengthText),this.moveLine=this.createMoveLine(),this.addChild(this.moveLine),this.controlButtons=new L,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.createControlButtons()}createWallLine(e=!0){const{points:i}=this.wallData;if(i.length<2)return;const{lineWidth:s,lineColor:n,editing:o,normal:a}=this.wallConfig,l=this.isEditingEnabled()?o:a;l.isDashed?this.wallLine=new Ue(this.appService,{start:i[0],end:i[1],style:{color:n.toString(),width:s,dashArray:l.dashArray}}):this.wallLine=this.createSolidLine(i[0],i[1],s,n.toString()),e&&this.setupWallLineInteraction()}createLengthText(){const e=this.calculateWallLengthInMeters(),i=this.formatLengthText(e),s=new Ui(this.appService,{text:i,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.wallConfig.textColor,align:"center"}});s.anchor.set(.5);const n=this.calculateTextPosition();s.position.set(n.x,n.y);const o=this.calculateTextRotation();return s.rotation=o,s.eventMode="none",s}calculateWallLengthInMeters(){const{points:e}=this.wallData;if(e.length<2)return 0;const i=Q(e[0],e[1]);return this.appService.pixelsToMeters(i)}formatLengthText(e){const i=this.appService.metersToDisplayUnit(e),s=this.appService.runtimeSnapshot.unitLabel;return`${i.toFixed(1)}${s}`}calculateTextPosition(){const{points:e}=this.wallData;if(e.length<2)return{x:0,y:0};const[i,s]=e,n=this.appService.getApp().toFixedSize(this.wallConfig.textOffset);return Jl(i,s,n)}calculateTextRotation(){const{points:e}=this.wallData;if(e.length<2)return 0;const[i,s]=e,n=this.appService.appContainer.getMapRotationRadians();return Xe(i,s,n)}getOutlineStyle(){return{color:this.wallConfig.outlineStrokeColor,width:this.wallConfig.outlineStrokeWidth,isDashed:this.wallConfig.outlineDashed,dashArray:this.wallConfig.outlineDashArray,fillColor:this.wallConfig.outlineFillColor}}createOutlineBorder(){const e=this.calculateOutlinePoints();return new Nt(this.appService,{points:e,closePath:!0,style:this.getOutlineStyle()})}createMoveLine(){const e=this.calculateOutlinePoints(),i=this.calculateMoveLinePoints(e);return new Nt(this.appService,{points:i,closePath:!1,style:this.getOutlineStyle()})}calculateOutlinePoints(e){const i=e||this.wallData.points;if(i.length<2)return i;const s=this.appService.getApp().toFixedSize(this.wallConfig.outlineOffset),n=dy(i[0],i[1],s);return[n[3],n[2],n[1],n[0]]}calculateMoveLinePoints(e){if(e.length<4)return[];const{MOVE:i}=Vt.BUTTON_INDICES,s=e[i],n=this.calculateMoveButtonPosition();return[s,n]}calculateMoveButtonPosition(){const{moveButtonOffset:e}=this.controlsConfig,i=this.calculateOutlinePoints();if(i.length<4)return{x:0,y:0};const{MOVE:s}=Vt.BUTTON_INDICES,n=i[s],o=i[(s+3)%4],a=i[(s+1)%4],h=this.appService.getApp().toFixedSize(e);return Is(n,a,o,h)}createControlButtons(){const e=this.calculateOutlinePoints();if(e.length<4)return;const{REMOVE:i,SCALE:s}=Vt.BUTTON_INDICES;this.removeButton=new Ds(this.appService,{iconAlias:"deleteIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onClick:this.handleRemove}),this.removeButton.position.set(e[i].x,e[i].y),this.scaleButton=new Ze(this.appService,{iconAlias:"scaleIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,getTargetPoints:()=>this.calculateOutlinePoints(),getButtonIndex:()=>s,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(e[s].x,e[s].y);const n=this.calculateMoveButtonPosition();this.moveButton=new Fs(this.appService,{iconAlias:"moveIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(n.x,n.y),this.controlButtons.addChild(this.removeButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton)}applyScaleAndRotation(e){if(this.initialWallPoints.length<2)return;const[i,s]=this.initialWallPoints,n=i,o=this.calculateOutlinePoints(this.initialWallPoints);if(o.length<4)return;const a=o[Vt.BUTTON_INDICES.SCALE],l=q(s,a),c={x:e.x-l.x,y:e.y-l.y},d=q(n,c),u=Q(n,c),p=this.appService.metersToPixels(this.wallConfig.minWidth);let f;if(u<p)if(u===0)f={x:n.x+p,y:n.y};else{const y=pt(d);f={x:n.x+y.x*p,y:n.y+y.y*p}}else f=c;this.wallData.points=[n,f],this.drawVirtualWall(),this.updateControlButtonsPosition()}applyTranslation(e,i){this.wallData.points=this.initialWallPoints.map(s=>({x:s.x+e,y:s.y+i})),this.drawVirtualWall(),this.updateControlButtonsPosition()}drawVirtualWall(){this.updateWallLine(),this.updateLengthText(),this.updateOutlineComponents()}updateWallLine(){const{points:e}=this.wallData;e.length<2||(this.wallLine instanceof Ue?this.wallLine.updatePoints(e[0],e[1]):this.redrawSolidLine(),this.setupWallLineHitArea())}updateLengthText(){if(!this.lengthText)return;const e=this.calculateWallLengthInMeters(),i=this.formatLengthText(e);this.lengthText.updateText(i),this.updateLengthTextPosition()}updateLengthTextPosition(){if(!this.lengthText)return;const e=this.calculateTextPosition();this.lengthText.position.set(e.x,e.y);const i=this.calculateTextRotation();this.lengthText.rotation=i}updateOutlineComponents(){const e=this.calculateOutlinePoints();this.outlineBorder.updatePoints(e);const i=this.calculateMoveLinePoints(e);this.moveLine.updatePoints(i)}updateControlButtonsPosition(){if(!this.removeButton||!this.scaleButton||!this.moveButton)return;const e=this.calculateOutlinePoints();if(e.length<4)return;const{REMOVE:i,SCALE:s}=Vt.BUTTON_INDICES,n=this.calculateMoveButtonPosition();this.removeButton.position.set(e[i].x,e[i].y),this.scaleButton.position.set(e[s].x,e[s].y),this.moveButton.position.set(n.x,n.y)}updateEditState(){const e=this.isEditingEnabled();this.controlButtons.visible=e,this.outlineBorder.visible=e,this.moveLine.visible=e,this.lengthText&&(this.lengthText.visible=e),e&&(this.updateOutlineComponents(),this.updateControlButtonsPosition(),this.updateLengthTextPosition()),this.updateWallLineStyle(),this.setupWallLineInteraction(),this.zIndex=e?1e3:0}createSolidLine(e,i,s,n){const o=new H;o.eventMode="static";const a=this.appService.getApp().toFixedSize(s);return o.moveTo(e.x,e.y),o.lineTo(i.x,i.y),o.stroke({color:n,width:a}),o}updateWallLineStyle(){const e=this.isEditingEnabled(),{editing:i,normal:s,lineWidth:n,lineColor:o}=this.wallConfig,a=e?i:s;this.wallLine instanceof Ue!==a.isDashed?(this.removeChild(this.wallLine),this.wallLine.destroy(),this.createWallLine(!1),this.addChild(this.wallLine)):this.wallLine instanceof Ue?this.wallLine.updateStyle({color:o.toString(),width:n,dashArray:a.dashArray}):this.redrawSolidLine()}redrawSolidLine(){const e=this.appService;if(!this.wallLine||this.wallLine instanceof Ue)return;const{points:i}=this.wallData;if(i.length<2)return;const{lineWidth:s,lineColor:n}=this.wallConfig,o=e.getApp().toFixedSize(s);this.wallLine.clear(),this.wallLine.setStrokeStyle({color:n.toString(),width:o}).moveTo(i[0].x,i[0].y).lineTo(i[1].x,i[1].y).stroke()}setupWallLineInteraction(){var i;if(!this.wallLine)return;this.setupWallLineHitArea();const e=this.isEditingEnabled();(i=this.wallLineClickHandler)==null||i.destroy(),this.wallLineClickHandler=null,this.wallLine.off("pointerdown",this.handleWallLinePointerDown),e?this.wallLine.on("pointerdown",this.handleWallLinePointerDown):this.wallLineClickHandler=new vt(this.wallLine,{onClick:()=>{var s,n;this.appService.emitter.emit("suppressMapClick"),(n=(s=this.wallEvents)==null?void 0:s.onClick)==null||n.call(s,this.getWallData())},stopPropagation:!1})}setupDragEventListeners(){const{emitter:e}=this.appService;e.on("gestureHijackPointerMove",this.handleDragPointerMove),e.on("gestureHijackPointerUp",this.handleDragPointerUp),e.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:e}=this.appService;e.off("gestureHijackPointerMove",this.handleDragPointerMove),e.off("gestureHijackPointerUp",this.handleDragPointerUp),e.off("gestureHijackCancel",this.handleDragCancel)}startDragging(e){const i=this.appService;this.isDragging=!0;const s=this.parent.toLocal(e.global);this.dragStartPosition={x:s.x,y:s.y},this.initializeOperation(),i.getApp().requestRender("virtualwall-drag",!0),this.appService.emitter.emit("gestureHijackStart",e)}getDragStartPosition(){return this.dragStartPosition}setupWallLineHitArea(){if(!this.wallLine)return;const{points:e}=this.wallData;if(e.length<2)return;const{hitAreaThickness:i}=this.wallConfig,s=this.appService.getApp().toFixedSize(i),n=tc(e[0],e[1],s);if(n.length===0)return;const o=new Te(n);this.wallLine.hitArea=o}getWallData(){return{...this.wallData}}updateWallData(e){this.wallData={...e,points:this.validateAndCorrectWallLength(e.points)},this.drawVirtualWall(),this.updateControlButtonsPosition()}updateEditingState(){this.updateEditState()}refreshDisplay(){this.drawVirtualWall()}destroy(){var e,i,s,n,o,a,h,l,c;this.appService.emitter.off("antiScale",this.throttledUpdateOutline),this.appService.emitter.off("antiScale",this.throttledHandleScaleChange),this.appService.emitter.off("mapRotationUpdate",this.throttledUpdateOutline),this.cleanupDragEventListeners(),this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.wallLine&&this.wallLine.off("pointerdown",this.handleWallLinePointerDown),(e=this.wallLineClickHandler)==null||e.destroy(),this.wallLineClickHandler=null,(i=this.wallLine)==null||i.destroy(),(s=this.lengthText)==null||s.destroy(),(n=this.outlineBorder)==null||n.destroy(),(o=this.moveLine)==null||o.destroy(),(a=this.controlButtons)==null||a.destroy(),(h=this.removeButton)==null||h.destroy(),(l=this.scaleButton)==null||l.destroy(),(c=this.moveButton)==null||c.destroy(),this.removeButton=null,this.scaleButton=null,this.moveButton=null,super.destroy()}};g(Vt,"BUTTON_INDICES",{REMOVE:0,SCALE:2,MOVE:3});let nr=Vt;class Ur extends L{constructor(e){super();g(this,"spotData");g(this,"spotConfig");g(this,"controlsConfig");g(this,"spotEvents");g(this,"appService");g(this,"controlFill");g(this,"spotBorder");g(this,"centerIcon");g(this,"sizeText");g(this,"clickHandler",null);g(this,"initialSpotPoint",null);g(this,"dragStartMousePosition",null);g(this,"throttledUpdateScale");g(this,"unsubscribeMapRotation",null);g(this,"handleDragStart",e=>{this.isEditingEnabled()&&(this.initialSpotPoint={...this.spotData.point},this.dragStartMousePosition=this.parent.toLocal(e.global),this.appService.getApp().requestRender("spot-drag",!0))});g(this,"handleDragMove",e=>{if(!this.isEditingEnabled()||!this.initialSpotPoint||!this.dragStartMousePosition||!this.controlFill)return;const i=this.parent.toLocal(e.global),s=i.x-this.dragStartMousePosition.x,n=i.y-this.dragStartMousePosition.y;this.applyTranslation(s,n)});g(this,"handleDragEnd",()=>{var e,i;this.initialSpotPoint=null,this.dragStartMousePosition=null,this.appService.getApp().stopRender("spot-drag"),(i=(e=this.spotEvents).onUpdate)==null||i.call(e,this.getSpotData())});const{appService:i,spotData:s,events:n={}}=e;this.appService=i,this.spotData=s,this.spotEvents=n,this.controlsConfig=this.appService.controlsConfig,this.spotConfig=this.appService.controlsConfig.spot,this.position.set(s.point.x,s.point.y),this.throttledUpdateScale=At(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}updateScale(){this.isEditingEnabled()&&this.sizeText&&this.updateSizeTextPosition()}isEditingEnabled(){return this.appService.runtimeSnapshot.editingSpotIds.includes(this.spotData.id)}shouldShowIcon(){return(this.isEditingEnabled()?this.spotConfig.editing:this.spotConfig.normal).showIcon}calculateRectanglePoints(){const{size:e}=this.spotConfig;if(e===0)return[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}];const s=this.appService.metersToPixels(e)/2;return[{x:-s,y:-s},{x:s,y:-s},{x:s,y:s},{x:-s,y:s}]}initializeComponents(){const e=this.calculateRectanglePoints();this.spotConfig.size>0&&(this.controlFill=this.createControlFill(e),this.addChild(this.controlFill),this.spotBorder=this.createBorder(e),this.addChild(this.spotBorder)),this.centerIcon=this.createCenterIcon(),this.addChild(this.centerIcon),this.spotConfig.showText&&(this.sizeText=this.createSizeText(),this.addChild(this.sizeText)),this.drawSpot()}createControlFill(e){const i=this.isEditingEnabled();return new Lr(this.appService,{points:e,fillColor:this.spotConfig.fillColor,enableInteraction:i,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createBorder(e){const s=this.isEditingEnabled()?this.spotConfig.editing:this.spotConfig.normal;return new Nt(this.appService,{points:e,closePath:!0,style:{color:this.spotConfig.strokeColor,width:this.spotConfig.strokeWidth,isDashed:s.isDashed,dashArray:s.dashArray}})}createCenterIcon(){const e=new Xt(this.appService);return this.loadIconTexture(e),e.position.set(0,0),e.eventMode="static",this.setupIconDrag(e),e.visible=!1,e}async loadIconTexture(e){const{iconSize:i,iconSizeFixed:s}=this.spotConfig;await e.loadTextureAndSetSize("spotIcon",{width:i,height:i,sizeFixed:s}),this.applyAntiRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation||(this.unsubscribeMapRotation=U(this.appService.runtime,"mapRotation",n=>{this.applyAntiRotation(n)})),e.visible=this.shouldShowIcon()}applyAntiRotation(e){const i=-e*Math.PI/180;this.rotation=i}setupIconDrag(e){let i=null,s=!1;const n=h=>{if(!s||!this.initialSpotPoint||!i)return;const l=this.parent.toLocal(h.global),c=l.x-i.x,d=l.y-i.y;this.applyTranslation(c,d)},o=()=>{s&&(s=!1,this.initialSpotPoint=null,i=null,this.appService.getApp().stopRender("spot-drag"),this.appService.emitter.off("gestureHijackPointerMove",n),this.appService.emitter.off("gestureHijackPointerUp",a),this.appService.emitter.off("gestureHijackCancel",o))},a=()=>{var h,l;s&&(s=!1,this.initialSpotPoint=null,i=null,this.appService.getApp().stopRender("spot-drag"),(l=(h=this.spotEvents).onUpdate)==null||l.call(h,this.getSpotData()),this.appService.emitter.off("gestureHijackPointerMove",n),this.appService.emitter.off("gestureHijackPointerUp",a),this.appService.emitter.off("gestureHijackCancel",o))};e.on("pointerdown",h=>{this.isEditingEnabled()&&(h.stopPropagation(),s=!0,this.initialSpotPoint={...this.spotData.point},i=this.parent.toLocal(h.global),this.appService.getApp().requestRender("spot-drag",!0),this.appService.emitter.emit("gestureHijackStart",h),this.appService.emitter.on("gestureHijackPointerMove",n),this.appService.emitter.on("gestureHijackPointerUp",a),this.appService.emitter.on("gestureHijackCancel",o))})}createSizeText(){const e=this.calculateSpotSizeText(),i=new Ui(this.appService,{text:e,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.spotConfig.textColor,align:"center"}});i.anchor.set(.5);const s=this.calculateSizeTextPosition();return i.position.set(s.x,s.y),i.eventMode="none",i}calculateSpotSizeText(){const{size:e}=this.spotConfig,i=this.appService.metersToDisplayUnit(e),s=this.appService.runtimeSnapshot.unitLabel;return`${i.toFixed(1)}${s}*${i.toFixed(1)}${s}`}calculateSizeTextPosition(){const e=this.calculateRectanglePoints();if(e.length<4)return{x:0,y:0};const[i,s,n,o]=e,{textPosition:a,textOffset:h}=this.spotConfig,l=this.appService.getApp().toFixedSize(h);let c,d;switch(a){case"top":{c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},d={x:c.x,y:c.y+l};break}case"right":{c={x:(s.x+n.x)/2,y:(s.y+n.y)/2},d={x:c.x+l,y:c.y};break}case"bottom":{c={x:(o.x+n.x)/2,y:(o.y+n.y)/2},d={x:c.x,y:c.y+l};break}case"left":{c={x:(i.x+o.x)/2,y:(i.y+o.y)/2},d={x:c.x-l,y:c.y};break}default:{c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},d={x:c.x,y:c.y+l};break}}return d}applyTranslation(e,i){this.initialSpotPoint&&(this.spotData.point={x:this.initialSpotPoint.x+e,y:this.initialSpotPoint.y+i},this.drawSpot())}setupClickHandler(){const e=this.spotConfig.size>0?this:this.centerIcon;this.clickHandler=new vt(e,{onClick:()=>{var i,s;this.isEditingEnabled()||(this.appService.emitter.emit("suppressMapClick"),(s=(i=this.spotEvents)==null?void 0:i.onClick)==null||s.call(i,this.getSpotData()))},stopPropagation:!1}),this.eventMode="static"}drawSpot(){const e=this.calculateRectanglePoints();this.position.set(this.spotData.point.x,this.spotData.point.y),this.spotConfig.size>0&&(this.controlFill&&this.controlFill.updatePoints(e),this.spotBorder&&this.spotBorder.updatePoints(e)),this.spotConfig.showText&&this.sizeText&&this.updateSizeText()}updateSizeText(){if(!this.sizeText)return;const e=this.calculateSpotSizeText();this.sizeText.updateText(e),this.updateSizeTextPosition()}updateSizeTextPosition(){if(!this.sizeText)return;const e=this.calculateSizeTextPosition();this.sizeText.position.set(e.x,e.y)}updateEditState(){const e=this.isEditingEnabled(),i=e?this.spotConfig.editing:this.spotConfig.normal;this.sizeText&&(this.sizeText.visible=e&&this.spotConfig.showText),this.centerIcon&&(this.centerIcon.visible=this.shouldShowIcon()),this.controlFill&&(this.controlFill.setInteractionEnabled(e),this.controlFill.visible=i.showFrame),this.spotBorder&&(this.spotBorder.updateStyle({isDashed:i.isDashed,dashArray:i.dashArray}),this.spotBorder.visible=i.showFrame),this.zIndex=e?1e3:0}updateSpotData(e){this.spotData={...e},this.drawSpot(),this.updateEditState()}getSpotData(){return{...this.spotData}}refreshDisplay(){this.drawSpot()}destroy(){var e,i,s,n,o;this.appService.emitter.off("antiScale",this.throttledUpdateScale),this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),(e=this.clickHandler)==null||e.destroy(),this.clickHandler=null,this.centerIcon&&this.spotConfig.size===0&&this.centerIcon.removeAllListeners(),(i=this.controlFill)==null||i.destroy(),(s=this.spotBorder)==null||s.destroy(),(n=this.centerIcon)==null||n.destroy(),(o=this.sizeText)==null||o.destroy(),super.destroy()}static create(e,i){return new Ur({appService:e,spotData:i,events:{onUpdate:s=>{var n,o;(o=(n=e.events)==null?void 0:n.onUpdateSpot)==null||o.call(n,s)},onClick:s=>{var n,o;(o=(n=e.events)==null?void 0:n.onClickSpot)==null||o.call(n,s)}}})}}class $x extends pc{constructor(e){const{appService:i,wayPointData:s,order:n,events:o={}}=e;super(i);g(this,"wayPointData");g(this,"order");g(this,"wayPointConfig");g(this,"controlsConfig");g(this,"wayPointEvents");g(this,"icon");g(this,"orderContainer");g(this,"orderBackground");g(this,"orderText");g(this,"clickHandler",null);g(this,"initialWayPointPoint",null);g(this,"unsubscribeMapRotation",null);this.wayPointData=s,this.order=n,this.wayPointEvents=o,this.controlsConfig=this.appService.controlsConfig,this.wayPointConfig=this.appService.controlsConfig.wayPoint,this.position.set(s.point.x,s.point.y),this.initializeComponents(),this.updateEditState(),this.setupClickHandler()}isEditingEnabled(){return(this.appService.runtimeSnapshot.editingWayPointIds||[]).includes(this.wayPointData.id)}initializeComponents(){this.icon=this.createIcon(),this.addChild(this.icon),this.wayPointConfig.showOrder&&(this.createOrderContainer(),this.addChild(this.orderContainer))}createIcon(){const e=new Xt(this.appService);return this.loadIconTexture(e),e.position.set(0,0),e.anchor.set(.5,1),e.eventMode="static",this.setupIconDrag(e),e}async loadIconTexture(e){const i=this.isEditingEnabled(),s=i?this.wayPointConfig.editing:this.wayPointConfig.normal,{iconSize:n}=s,o=i?"wayPointActive":"wayPoint";await e.loadTextureAndSetSize(o,{width:n,height:n,sizeFixed:!1}),this.applyAntiRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation||(this.unsubscribeMapRotation=U(this.appService.runtime,"mapRotation",a=>{this.applyAntiRotation(a)})),e.visible=!0,this.orderContainer&&this.updateOrderPosition()}applyAntiRotation(e){const i=-e*Math.PI/180;this.rotation=i}createOrderContainer(){const i=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal,{orderContainer:s,orderText:n}=i;this.orderContainer=new L,this.orderBackground=new H,this.orderText=new Es({text:this.order.toString(),style:new de({fontSize:n.fontSize,fontFamily:n.fontFamily,fontWeight:n.fontWeight,fill:n.color,align:"center",trim:!0})}),this.orderBackground.clear(),this.orderBackground.circle(0,0,s.size/2),this.orderBackground.fill({color:s.backgroundColor}),this.orderText.anchor.set(.5,.5),this.orderContainer.addChild(this.orderBackground),this.orderContainer.addChild(this.orderText),this.orderContainer.eventMode="none",this.orderContainer.visible=this.wayPointConfig.showOrder,this.updateOrderPosition()}updateOrderPosition(){if(!this.orderContainer)return;const i=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal,{offsetX:s,offsetY:n}=i.orderContainer;this.orderContainer.position.set(s,-n)}setupIconDrag(e){let i=null,s=null,n=!1;const o=h=>{if(!(!n||!i||!s)&&this.parent){const l=this.parent.toLocal(h.global),c=l.x-i.x,d=l.y-i.y,u={x:s.x+c,y:s.y+d};this.wayPointData.point=u,this.position.set(u.x,u.y),this.orderContainer&&this.updateOrderPosition()}},a=()=>{var h,l;n&&(n=!1,i=null,s=null,(l=(h=this.wayPointEvents).onUpdate)==null||l.call(h,this.wayPointData),this.appService.emitter.off("gestureHijackPointerMove",o),this.appService.emitter.off("gestureHijackPointerUp",a),this.appService.emitter.emit("gestureHijackCancel"))};e.on("pointerdown",h=>{this.isEditingEnabled()&&(h.stopPropagation(),s={...this.wayPointData.point},this.parent&&(i=this.parent.toLocal(h.global)),n=!0,this.parent&&(this.appService.emitter.emit("gestureHijackStart",h),this.appService.emitter.on("gestureHijackPointerMove",o),this.appService.emitter.on("gestureHijackPointerUp",a)))})}setupClickHandler(){this.clickHandler=new vt(this.icon,{stopPropagation:!1,onClick:()=>{var e,i;this.appService.emitter.emit("suppressMapClick"),(i=(e=this.wayPointEvents).onClick)==null||i.call(e,this.wayPointData)}})}updateWayPoint(e){this.wayPointData=e,this.drawWayPoint()}updateOrder(e){this.order=e,this.orderText&&(this.orderText.text=e.toString())}getWayPointData(){return{...this.wayPointData}}drawWayPoint(){this.position.set(this.wayPointData.point.x,this.wayPointData.point.y),this.orderContainer&&this.updateOrderPosition()}updateEditState(){if(this.loadIconTexture(this.icon),this.orderContainer&&this.orderText&&this.orderBackground){const i=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal;this.orderText.style=new de({fontSize:i.orderText.fontSize,fontFamily:i.orderText.fontFamily,fontWeight:i.orderText.fontWeight,fill:i.orderText.color,align:"center",trim:!0});const{size:s,backgroundColor:n}=i.orderContainer;this.orderBackground.clear(),this.orderBackground.circle(0,0,s/2).fill(n),this.orderContainer.visible=this.wayPointConfig.showOrder,this.updateOrderPosition()}}onEditStateChange(){this.updateEditState()}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.icon&&this.icon.removeAllListeners(),super.destroy()}}class Ya extends H{constructor(e,i){super();g(this,"isDragging",!1);g(this,"dragStartPosition",null);g(this,"initialPosition");g(this,"handleDragPointerMove",e=>{var a,h;if(!this.isDragging||!this.dragStartPosition)return;const i=this.parent.toLocal(e.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y,o={x:this.initialPosition.x+s,y:this.initialPosition.y+n};this.position.set(o.x,o.y),(h=(a=this.options).onDragMove)==null||h.call(a,o)});g(this,"handleDragPointerUp",()=>{var i,s;if(!this.isDragging)return;const e=this.appService;this.isDragging=!1,this.dragStartPosition=null,e.getApp().stopRender("endpoint-drag"),(s=(i=this.options).onDragEnd)==null||s.call(i)});g(this,"handleDragCancel",()=>{var i,s;if(!this.isDragging)return;const e=this.appService;this.isDragging=!1,this.dragStartPosition=null,e.getApp().stopRender("endpoint-drag"),(s=(i=this.options).onDragEnd)==null||s.call(i)});this.appService=e,this.options=i,this.initialPosition={...i.position},this.position.set(i.position.x,i.position.y),this.eventMode="static",this.cursor="pointer",this.setupEvents(),this.draw(),this.setupDragEventListeners()}draw(){const e=this.appService,{config:i}=this.options,s=e.getApp().toFixedSize(i.endPointSize),n=e.getApp().toFixedSize(i.endPointStrokeWidth);this.clear(),this.circle(0,0,s/2),this.fill({color:i.endPointColor}),this.stroke({color:i.endPointStrokeColor,width:n}),this.setupHitArea()}setupHitArea(){const e=this.appService,{config:i}=this.options,s=Math.max(i.endPointSize/2+10,20),n=e.getApp().toFixedSize(s);this.hitArea=new Ts(0,0,n)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}setupDragEventListeners(){const{emitter:e}=this.appService;e.on("gestureHijackPointerMove",this.handleDragPointerMove),e.on("gestureHijackPointerUp",this.handleDragPointerUp),e.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:e}=this.appService;e.off("gestureHijackPointerMove",this.handleDragPointerMove),e.off("gestureHijackPointerUp",this.handleDragPointerUp),e.off("gestureHijackCancel",this.handleDragCancel)}handlePointerDown(e){e.stopPropagation(),this.startDragging(e)}startDragging(e){var s,n;const i=this.appService;this.isDragging=!0,this.dragStartPosition=this.parent.toLocal(e.global),this.initialPosition={x:this.x,y:this.y},(n=(s=this.options).onDragStart)==null||n.call(s),i.getApp().requestRender("endpoint-drag",!0),this.appService.emitter.emit("gestureHijackStart",e)}updatePosition(e){this.position.set(e.x,e.y),this.initialPosition={...e}}getPosition(){return{x:this.x,y:this.y}}redraw(){this.draw()}destroy(){this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.cleanupDragEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Qx extends L{constructor(e){super();g(this,"endPoints");g(this,"dividerConfig");g(this,"dividerEvents");g(this,"roomId");g(this,"appService");g(this,"roomGeometry",null);g(this,"dashLine");g(this,"solidLine",null);g(this,"startEndPoint");g(this,"endEndPoint");g(this,"solidLinePoints",null);g(this,"initialDividerPoints",[]);g(this,"isDragging",!1);g(this,"dragStartPosition",null);g(this,"throttledHandleScaleChange");g(this,"handleEndPointDragStart",()=>{this.initialDividerPoints=this.endPoints.map(e=>({...e})),this.clearSolidLine(),this.appService.getApp().requestRender("divider-endpoint-drag",!0)});g(this,"handleEndPointDragMove",(e,i)=>{this.initialDividerPoints.length!==0&&(this.endPoints[e]=i,this.updateDashLine(),this.updateSolidLine(),this.setupDashLineHitArea())});g(this,"handleEndPointDragEnd",()=>{var e,i;this.initialDividerPoints=[],this.appService.getApp().stopRender("divider-endpoint-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),(i=(e=this.dividerEvents).onUpdate)==null||i.call(e,this.getDividerEndPoints())});g(this,"handleDashLinePointerDown",e=>{e.stopPropagation(),this.startDragging(e)});g(this,"handleDragPointerMove",e=>{if(!this.isDragging||!this.dragStartPosition||this.initialDividerPoints.length===0)return;const i=this.parent.toLocal(e.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y;this.endPoints=this.initialDividerPoints.map(o=>({x:o.x+s,y:o.y+n})),this.updateAllComponents()});g(this,"handleDragPointerUp",()=>{var e,i;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],this.appService.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),(i=(e=this.dividerEvents).onUpdate)==null||i.call(e,this.getDividerEndPoints()))});g(this,"handleDragCancel",()=>{var e,i;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],this.appService.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),(i=(e=this.dividerEvents).onUpdate)==null||i.call(e,this.getDividerEndPoints()))});g(this,"handleScaleChange",()=>{var e,i;(e=this.startEndPoint)==null||e.redraw(),(i=this.endEndPoint)==null||i.redraw(),this.updateSolidLine(),this.setupDashLineHitArea()});const{appService:i,endPoints:s,roomId:n,events:o={}}=e;this.appService=i,this.dividerEvents=o,this.roomId=n,this.dividerConfig=this.appService.dividerConfig,this.roomGeometry=this.appService.mapManager.getRoomById(this.roomId)||null,s?this.endPoints=this.validateDividerPoints(s):this.endPoints=this.createDefaultdividerPoints(),this.throttledHandleScaleChange=At(this.handleScaleChange.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.calculateAndCreateSolidLine(),this.registerScaleListener(),this.setupDragEventListeners()}validateDividerPoints(e){if(e.length>=2)return e.slice(0,2);const i=e[0]||{x:0,y:0},s={x:i.x+50,y:i.y};return[i,s]}createDefaultdividerPoints(){if(!this.roomGeometry)return A.warn("Room geometry not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const e=this.appService.getApp().mapState;if(!e)return A.warn("Map state not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const{boundingBox:i}=this.roomGeometry,s=this.appService.getApp().toFixedSize(this.dividerConfig.defaultExtension),n=this.dividerConfig.defaultDirection,o=i.x+i.width/2,a=i.y+i.height/2,h=n==="horizontal"?i.width+2*s:i.height+2*s;return Sy(o,a,h,n).map(c=>({x:c.x-e.origin.x,y:c.y-e.origin.y}))}initializeComponents(){this.createDashLine(),this.addChild(this.dashLine),this.createEndPoints(),this.addChild(this.startEndPoint),this.addChild(this.endEndPoint),this.setupDashLineInteraction()}createDashLine(){const e=this.endPoints;if(e.length<2)return;const{dashLineWidth:i,dashLineDashArray:s,lineColor:n}=this.dividerConfig;this.dashLine=new Ue(this.appService,{start:e[0],end:e[1],style:{color:n.toString(),width:i,dashArray:s}})}createEndPoints(){const e=this.endPoints;this.startEndPoint=new Ya(this.appService,{position:e[0],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:i=>this.handleEndPointDragMove(0,i),onDragEnd:this.handleEndPointDragEnd}),this.endEndPoint=new Ya(this.appService,{position:e[1],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:i=>this.handleEndPointDragMove(1,i),onDragEnd:this.handleEndPointDragEnd})}setupDashLineInteraction(){this.dashLine&&(this.setupDashLineHitArea(),this.dashLine.off("pointerdown",this.handleDashLinePointerDown),this.dashLine.on("pointerdown",this.handleDashLinePointerDown))}setupDashLineHitArea(){if(!this.dashLine)return;const e=this.endPoints;if(e.length<2)return;const{hitAreaThickness:i}=this.dividerConfig,s=this.appService.getApp().toFixedSize(i),n=tc(e[0],e[1],s);if(n.length===0)return;const o=new Te(n);this.dashLine.hitArea=o}startDragging(e){this.isDragging=!0;const i=this.parent.toLocal(e.global);this.dragStartPosition={x:i.x,y:i.y},this.initialDividerPoints=this.endPoints.map(s=>({...s})),this.clearSolidLine(),this.appService.getApp().requestRender("divider-drag",!0),this.appService.emitter.emit("gestureHijackStart",e)}setupDragEventListeners(){const{emitter:e}=this.appService;e.on("gestureHijackPointerMove",this.handleDragPointerMove),e.on("gestureHijackPointerUp",this.handleDragPointerUp),e.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:e}=this.appService;e.off("gestureHijackPointerMove",this.handleDragPointerMove),e.off("gestureHijackPointerUp",this.handleDragPointerUp),e.off("gestureHijackCancel",this.handleDragCancel)}updateAllComponents(){this.updateDashLine(),this.updateSolidLine(),this.updateEndPoints(),this.setupDashLineHitArea()}updateDashLine(){const e=this.endPoints;e.length<2||!this.dashLine||this.dashLine.updatePoints(e[0],e[1])}updateSolidLine(){if(!this.solidLine||!this.solidLinePoints)return;const{solidLineWidth:e,lineColor:i}=this.dividerConfig,s=this.appService.getApp().toFixedSize(e);this.solidLine.clear(),this.solidLine.setStrokeStyle({color:i.toString(),width:s}).moveTo(this.solidLinePoints[0].x,this.solidLinePoints[0].y).lineTo(this.solidLinePoints[1].x,this.solidLinePoints[1].y).stroke()}updateEndPoints(){const e=this.endPoints;this.startEndPoint&&this.startEndPoint.updatePosition(e[0]),this.endEndPoint&&this.endEndPoint.updatePosition(e[1])}registerScaleListener(){const{emitter:e}=this.appService;e.on("antiScale",this.throttledHandleScaleChange)}getDividerEndPoints(){return[...this.endPoints]}getEffectiveDividerPoints(){return this.solidLinePoints?[...this.solidLinePoints]:null}calculateAndCreateSolidLine(){if(this.clearSolidLine(),typeof this.roomId!="number"||!this.getRoomGraphics())return;const i=this.calculateLineRoomIntersection();i&&i.length>=2&&(this.solidLinePoints=[i[0],i[i.length-1]],this.createSolidLine())}getRoomGraphics(){const e=this.appService.mapManager.roomFill;return!e||typeof this.roomId!="number"?null:e.getRoomGraphicsMap().get(this.roomId)||null}calculateLineRoomIntersection(){const e=this.endPoints;if(e.length<2||typeof this.roomId!="number")return null;const[i,s]=e,n=this.isPointInRoomFill(i),o=this.isPointInRoomFill(s);if(n||o)return null;const a=oy(i,s),h=[];for(const p of a)this.isPointInRoomFill(p)&&h.push(p);if(h.length===0)return null;const l=h[0],c=h[h.length-1];return Q(l,c)<3?null:vy(l,c,.5)}isPointInRoomFill(e){if(typeof this.roomId!="number")return!1;const i=this.appService.getApp().mapState;if(!i)return!1;const s={x:e.x+i.origin.x,y:e.y+i.origin.y};return i.mapType==="raster"?this.isPointInRasterRoomFill(s):this.isPointInStructuredRoomFill(s)}isPointInRasterRoomFill(e){e.x-=.5,e.y-=.5;const i=this.appService.getApp().mapState,s=this.appService.mapManager.roomFill;if(!i||!s)return!1;const n=s.getRasterRoomData(this.roomId);if(!n)return!1;const o=s.getMapWidth();if(o===0)return!1;const a=Math.round(e.x),h=Math.round(e.y);if(a<0||h<0||a>=o)return!1;const l=h*o+a;for(let c=0;c<n.pixelIndices.length;c++)if(n.pixelIndices[c]===l)return!0;return!1}isPointInStructuredRoomFill(e){const i={x:Math.round(e.x),y:Math.round(e.y)},s=this.appService.getApp().mapState,n=this.appService.mapManager.getRoomById(this.roomId);return!s||!n||!n.outlinePoints?!1:Rt(i,n.outlinePoints,!0)}isDividerCompletelyOutOfRoom(){if(!this.roomGeometry)return!1;const{boundingBox:e}=this.roomGeometry,i=this.endPoints;if(i.length<2)return!1;const s=this.appService.getApp().mapState;if(!s)return!1;const n={x:i[0].x+s.origin.x,y:i[0].y+s.origin.y},o={x:i[1].x+s.origin.x,y:i[1].y+s.origin.y};return!xy(n,o,e.x,e.y,e.width,e.height)}checkAndResetIfOutOfRoom(){const{resetDividerWhenOutOfRoom:e}=this.appService.dividerConfig;e&&this.isDividerCompletelyOutOfRoom()&&this.resetToDefaultState()}resetToDefaultState(){var e,i;this.endPoints=this.createDefaultdividerPoints(),this.calculateAndCreateSolidLine(),this.updateComponents(),(i=(e=this.dividerEvents).onUpdate)==null||i.call(e,this.endPoints)}updateComponents(){const e=this.endPoints;e.length>=2&&(this.dashLine.updatePoints(e[0],e[1]),this.startEndPoint.position.set(e[0].x,e[0].y),this.endEndPoint.position.set(e[1].x,e[1].y),this.setupDashLineInteraction())}createSolidLine(){if(!this.solidLinePoints)return;const{solidLineWidth:e,lineColor:i}=this.dividerConfig;this.solidLine=new H,this.solidLine.eventMode="none";const s=this.appService.getApp().toFixedSize(e);this.solidLine.setStrokeStyle({color:i.toString(),width:s}).moveTo(this.solidLinePoints[0].x,this.solidLinePoints[0].y).lineTo(this.solidLinePoints[1].x,this.solidLinePoints[1].y).stroke(),this.addChildAt(this.solidLine,0)}clearSolidLine(){this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy(),this.solidLine=null),this.solidLinePoints=null}updatedividerPoints(e){this.endPoints=this.validateDividerPoints(e),this.updateAllComponents(),this.calculateAndCreateSolidLine()}destroy(){var e,i,s;this.appService.emitter.off("antiScale",this.throttledHandleScaleChange),this.cleanupDragEventListeners(),this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[]),this.dashLine&&this.dashLine.off("pointerdown",this.handleDashLinePointerDown),this.clearSolidLine(),(e=this.dashLine)==null||e.destroy(),(i=this.startEndPoint)==null||i.destroy(),(s=this.endEndPoint)==null||s.destroy(),super.destroy()}}const ps=["forbiddenSweepZone","forbiddenMopZone","cleanZone","virtualWall","spot","wayPoint","divider"];function Jx(r){if(!r||r.length===0)return[...ps];const t=new Set,e=[];for(const i of r){if(!ps.includes(i)){A.warn(`[ControlsManager] Unknown control render order item: ${i}`);continue}t.has(i)||(t.add(i),e.push(i))}for(const i of ps)t.has(i)||e.push(i);return e}class t0{constructor(t){g(this,"forbiddenSweepZoneMap",new Map);g(this,"forbiddenMopZoneMap",new Map);g(this,"cleanZoneMap",new Map);g(this,"virtualWallMap",new Map);g(this,"spotMap",new Map);g(this,"wayPointMap",new Map);g(this,"divider",null);g(this,"controlContainers",new Map);g(this,"unsubscribeFns",[]);this.appService=t,this.initializeControlContainers();const e=U(t.runtime,"editingForbiddenSweepZoneIds",d=>{A.log(`[runtime] editingForbiddenSweepZoneIds: ${d}`),this.updateZonesEditState(this.forbiddenSweepZoneMap)}),i=U(t.runtime,"editingForbiddenMopZoneIds",d=>{A.log(`[runtime] editingForbiddenMopZoneIds: ${d}`),this.updateZonesEditState(this.forbiddenMopZoneMap)}),s=U(t.runtime,"editingCleanZoneIds",d=>{A.log(`[runtime] editingCleanZoneIds: ${d}`),this.updateZonesEditState(this.cleanZoneMap)}),n=U(t.runtime,"editingVirtualWallIds",d=>{A.log(`[runtime] editingVirtualWallIds: ${d}`),this.updateVirtualWallsEditState(this.virtualWallMap)}),o=U(t.runtime,"editingSpotIds",d=>{A.log(`[runtime] editingSpotIds: ${d}`),this.updateSpotsEditState(this.spotMap)}),a=U(t.runtime,"editingWayPointIds",d=>{A.log(`[runtime] editingWayPointIds: ${d}`),this.updateWayPointsEditState(this.wayPointMap)}),h=U(t.runtime,"dividingRoomId",d=>{A.log(`[runtime] dividingRoomId: ${d}`),this.handleDividingRoomIdChange(d)}),l=U(t.runtime,"unit",d=>{A.log(`[runtime] unit changed: ${d}`),this.handleUnitChange()}),c=U(t.runtime,"unitLabel",d=>{A.log(`[runtime] unitLabel changed: ${d}`),this.handleUnitChange()});this.unsubscribeFns.push(e,i,s,n,o,a,h,l,c)}updatePositionByOrigin(t,e){const s=this.appService.appContainer.getLayer(Ne);s&&s.position.set(t,e)}updateRenderOrder(){this.applyRenderOrder()}initializeControlContainers(){const t=this.appService.appContainer.getLayer(Ne);if(!t){A.warn("[ControlsManager] LAYER_CONTROLS not found during init");return}for(const e of ps){const i=new L;i.label=`controls:${e}`,this.controlContainers.set(e,i),t.addChild(i)}this.applyRenderOrder()}applyRenderOrder(){const t=this.appService.appContainer.getLayer(Ne);if(!t)return;Jx(this.appService.getConfig().controls.renderOrder).forEach((i,s)=>{const n=this.controlContainers.get(i);n&&(n.zIndex=s)}),t.sortableChildren=!0,t.sortChildren()}addToControlLayer(t,e){let i=this.controlContainers.get(t);if(!i){const s=this.appService.appContainer.getLayer(Ne);if(!s){A.warn("[ControlsManager] LAYER_CONTROLS not found");return}i=new L,i.label=`controls:${t}`,this.controlContainers.set(t,i),s.addChild(i),this.applyRenderOrder()}i.addChild(e)}drawForbiddenSweepZones(t){this.drawZones(t,this.forbiddenSweepZoneMap,e=>Or.create(this.appService,e),"forbiddenSweepZone")}getForbiddenSweepZones(){return this.getZonesData(this.forbiddenSweepZoneMap)}clearAllForbiddenSweepZones(){this.clearAllZones(this.forbiddenSweepZoneMap)}drawForbiddenMopZones(t){this.drawZones(t,this.forbiddenMopZoneMap,e=>Gr.create(this.appService,e),"forbiddenMopZone")}getForbiddenMopZones(){return this.getZonesData(this.forbiddenMopZoneMap)}clearAllForbiddenMopZones(){this.clearAllZones(this.forbiddenMopZoneMap)}drawCleanZones(t){this.drawZones(t,this.cleanZoneMap,e=>Wr.create(this.appService,e),"cleanZone")}getCleanZones(){return this.getZonesData(this.cleanZoneMap)}clearAllCleanZones(){this.clearAllZones(this.cleanZoneMap)}drawVirtualWalls(t){var n;const e=this.appService,i=this.virtualWallMap,s=new Set(t.map(o=>o.id));for(const[o,a]of i)s.has(o)||((n=a.parent)==null||n.removeChild(a),a.destroy(),i.delete(o));t.forEach(o=>{const a=i.get(o.id);if(a)this.isWallDataEqual(a.getWallData(),o)||a.updateWallData(o);else{const h=new nr({appService:e,wallData:o,events:{onRemove:l=>{var c,d;(d=(c=e.events)==null?void 0:c.onRemoveVirtualWall)==null||d.call(c,l)},onUpdate:l=>{var c,d;(d=(c=e.events)==null?void 0:c.onUpdateVirtualWall)==null||d.call(c,l)},onClick:l=>{var c,d;(d=(c=e.events)==null?void 0:c.onClickVirtualWall)==null||d.call(c,l)}}});i.set(o.id,h),this.addToControlLayer("virtualWall",h)}})}getVirtualWalls(){return this.getWallsData(this.virtualWallMap)}clearAllVirtualWalls(){this.clearAllWalls(this.virtualWallMap)}drawSpots(t){const e=this.spotMap;if(!t||t.length===0){this.clearAllSpotsInternal(e);return}const i=new Set(e.keys()),s=new Set(t.map(n=>n.id));for(const n of i)s.has(n)||this.removeSpot(n,e);t.forEach(n=>{const o=e.get(n.id);o?this.isSpotDataEqual(o.getSpotData(),n)||o.updateSpotData(n):this.addNewSpot(n,e)})}getSpots(){return this.getSpotsData(this.spotMap)}clearAllSpots(){this.clearAllSpotsInternal(this.spotMap)}drawZones(t,e,i,s){if(!t||t.length===0){this.clearAllZones(e);return}const n=new Set(e.keys()),o=new Set(t.map(a=>a.id));for(const a of n)o.has(a)||this.removeZone(a,e);t.forEach(a=>{const h=e.get(a.id);h?this.isZoneDataEqual(h.getZoneData(),a)||h.updateZoneData(a):this.addNewZone(a,e,i,s)})}addNewZone(t,e,i,s){const n=i(t);e.set(t.id,n),this.addToControlLayer(s,n)}removeZone(t,e){var s;const i=e.get(t);i&&((s=i.parent)==null||s.removeChild(i),i.destroy(),e.delete(t))}getZonesData(t){const e=[];return t.forEach(i=>{e.push(i.getZoneData())}),e}clearAllZones(t){t.forEach((e,i)=>{var n;const s=t.get(i);s&&((n=s.parent)==null||n.removeChild(s),s.destroy())}),t.clear()}updateZonesEditState(t){t.forEach(e=>{e.updateEditState()})}updateVirtualWallsEditState(t){t.forEach(e=>{e.updateEditingState()})}isZoneDataEqual(t,e){if(t.id!==e.id||t.points.length!==e.points.length)return!1;for(let i=0;i<t.points.length;i++){const s=t.points[i],n=e.points[i];if(Math.abs(s.x-n.x)>.1||Math.abs(s.y-n.y)>.1)return!1}return!0}getWallsData(t){return Array.from(t.values()).map(e=>e.getWallData())}clearAllWalls(t){for(const e of t.values())e.destroy();t.clear()}isWallDataEqual(t,e){if(t.id!==e.id||t.points.length!==e.points.length)return!1;for(let i=0;i<t.points.length;i++){const s=t.points[i],n=e.points[i];if(Math.abs(s.x-n.x)>.1||Math.abs(s.y-n.y)>.1)return!1}return!0}addNewSpot(t,e){const i=Ur.create(this.appService,t);e.set(t.id,i),this.addToControlLayer("spot",i)}removeSpot(t,e){var s;const i=e.get(t);i&&((s=i.parent)==null||s.removeChild(i),i.destroy(),e.delete(t))}getSpotsData(t){const e=[];return t.forEach(i=>{e.push(i.getSpotData())}),e}clearAllSpotsInternal(t){t.forEach((e,i)=>{var n;const s=t.get(i);s&&((n=s.parent)==null||n.removeChild(s),s.destroy())}),t.clear()}updateSpotsEditState(t){t.forEach(e=>{e.updateEditState()})}isSpotDataEqual(t,e){if(t.id!==e.id)return!1;const i=t.point,s=e.point;return!(Math.abs(i.x-s.x)>.1||Math.abs(i.y-s.y)>.1)}drawWayPoints(t){A.log("[ControlsManager] drawWayPoints",t);const e=Array.from(this.wayPointMap.keys()),i=t.map(n=>n.id);e.filter(n=>!i.includes(n)).forEach(n=>{this.removeWayPoint(n,this.wayPointMap)}),t.forEach((n,o)=>{const a=o+1,h=this.wayPointMap.get(n.id);h?(this.isWayPointDataEqual(h.getWayPointData(),n)||h.updateWayPoint(n),h.updateOrder(a)):this.addNewWayPoint(n,a,this.wayPointMap)})}clearAllWayPoints(){A.log("[ControlsManager] clearAllWayPoints"),this.clearAllWayPointsInternal(this.wayPointMap)}getWayPoints(){return this.getWayPointsData(this.wayPointMap)}addNewWayPoint(t,e,i){var o,a;const s=this.appService,n=new $x({appService:s,wayPointData:t,order:e,events:{onUpdate:(o=s.events)==null?void 0:o.onUpdateWayPoint,onClick:(a=s.events)==null?void 0:a.onClickWayPoint}});i.set(t.id,n),this.addToControlLayer("wayPoint",n)}removeWayPoint(t,e){var s;const i=e.get(t);i&&((s=i.parent)==null||s.removeChild(i),i.destroy(),e.delete(t))}getWayPointsData(t){const e=[];return t.forEach(i=>{e.push(i.getWayPointData())}),e}clearAllWayPointsInternal(t){t.forEach((e,i)=>{var n;const s=t.get(i);s&&((n=s.parent)==null||n.removeChild(s),s.destroy())}),t.clear()}updateWayPointsEditState(t){t.forEach(e=>{e.onEditStateChange()})}isWayPointDataEqual(t,e){if(t.id!==e.id)return!1;const i=t.point,s=e.point;return!(Math.abs(i.x-s.x)>.1||Math.abs(i.y-s.y)>.1)}handleDividingRoomIdChange(t){if(t==null||t===-1){this.clearDivider();return}if(!this.getRoomGeometry(t)){this.clearDivider();return}this.createDefaultDivider(t)}getRoomGeometry(t){return this.appService.mapManager.getRoomById(t)}createDefaultDivider(t){const e=this.appService;this.clearDivider(),this.divider=new Qx({appService:this.appService,roomId:t,events:{onUpdate:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onUpdateDivider)==null||n.call(s,i)}}}),this.addToControlLayer("divider",this.divider)}clearDivider(){var t;this.divider&&((t=this.divider.parent)==null||t.removeChild(this.divider),this.divider.destroy(),this.divider=null)}getDividerEndPoints(){return this.divider?this.divider.getDividerEndPoints():null}getEffectiveDividerPoints(){return this.divider?this.divider.getEffectiveDividerPoints():null}handleUnitChange(){A.debug("[ControlsManager] Unit changed, refreshing all size texts"),this.forbiddenSweepZoneMap.forEach(t=>{t.refreshDisplay()}),this.forbiddenMopZoneMap.forEach(t=>{t.refreshDisplay()}),this.cleanZoneMap.forEach(t=>{t.refreshDisplay()}),this.virtualWallMap.forEach(t=>{t.refreshDisplay()}),this.spotMap.forEach(t=>{t.refreshDisplay()})}destroy(){this.clearAllForbiddenSweepZones(),this.clearAllForbiddenMopZones(),this.clearAllCleanZones(),this.clearAllVirtualWalls(),this.clearAllSpots(),this.clearDivider(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.controlContainers.forEach(t=>{t.removeFromParent(),t.destroy({children:!0})}),this.controlContainers.clear()}}class e0 extends Xt{constructor(e,i){super(e);g(this,"objectData");g(this,"clickHandler",null);g(this,"unsubscribeMapRotation",null);this.appService=e,this.objectData=i}async initializeSprite(){const e=this.appService.detectedObjectConfig,i=this.objectData.width||e.width,s=this.objectData.height||e.height;await this.loadTextureAndSetSize(this.objectData.src,{width:i,height:s}),this.anchor.set(e.anchor.x,e.anchor.y),this.position.set(this.objectData.x,this.objectData.y),this.visible=!0,this.applyAntiRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=U(this.appService.runtime,"mapRotation",n=>{this.applyAntiRotation(n)}),e.interactive?this.setupClickHandler():this.eventMode="none"}applyAntiRotation(e){const i=-e*Math.PI/180;this.rotation=i}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new vt(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var e,i;(i=(e=this.appService.events)==null?void 0:e.onClickDetectedObject)==null||i.call(e,this.getObjectData())}getObjectData(){return{...this.objectData}}async updateObjectData(e){const i=this.objectData;this.objectData=e;const s=this.appService.detectedObjectConfig;if(i.src!==e.src){const n=e.width||s.width,o=e.height||s.height;await this.loadTextureAndSetSize(e.src,{width:n,height:o})}if(i.width!==e.width||i.height!==e.height){const n=e.width||s.width,o=e.height||s.height;this.setFixedSize(n,o)}this.position.set(e.x,e.y),s.interactive?this.clickHandler||this.setupClickHandler():this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null)}isSameData(e){return this.objectData.id===e.id&&this.objectData.src===e.src&&this.objectData.x===e.x&&this.objectData.y===e.y&&this.objectData.width===e.width&&this.objectData.height===e.height}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class i0{constructor(t){g(this,"detectedObjectMap",new Map);g(this,"unsubscribeShowDetectedObjects",null);this.appService=t,this.applyLayerVisibility(this.appService.runtime.showDetectedObjects),this.unsubscribeShowDetectedObjects=U(this.appService.runtime,"showDetectedObjects",e=>{this.applyLayerVisibility(e)})}updatePositionByOrigin(t,e){const s=this.appService.appContainer.getLayer(We);s&&s.position.set(t,e)}async drawDetectedObjects(t){if(!t||t.length===0){this.clearAllDetectedObjects();return}const e=new Set(t.map(s=>s.id)),i=Array.from(this.detectedObjectMap.keys());for(const s of i)e.has(s)||this.removeDetectedObject(s);for(const s of t){const n=this.detectedObjectMap.get(s.id);n?n.isSameData(s)||await n.updateObjectData(s):await this.addNewDetectedObject(s)}}applyLayerVisibility(t){const e=this.appService.appContainer.getLayer(We);e&&(e.visible=t)}clearAllDetectedObjects(){const t=this.appService;this.detectedObjectMap.forEach(e=>{t.appContainer.removeFromLayer(We,e),e.destroy()}),this.detectedObjectMap.clear()}async addNewDetectedObject(t){const e=this.appService,i=new e0(this.appService,t);await i.initializeSprite(),this.detectedObjectMap.set(t.id,i),e.appContainer.addToLayer(We,i)}removeDetectedObject(t){const e=this.appService,i=this.detectedObjectMap.get(t);i&&(e.appContainer.removeFromLayer(We,i),i.destroy(),this.detectedObjectMap.delete(t))}destroy(){this.unsubscribeShowDetectedObjects&&(this.unsubscribeShowDetectedObjects(),this.unsubscribeShowDetectedObjects=null),this.clearAllDetectedObjects()}}var ke={},gc={},te={};Object.defineProperty(te,"__esModule",{value:!0});te.loop=te.conditional=te.parse=void 0;var s0=function r(t,e){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i;if(Array.isArray(e))e.forEach(function(o){return r(t,o,i,s)});else if(typeof e=="function")e(t,i,s,r);else{var n=Object.keys(e)[0];Array.isArray(e[n])?(s[n]={},r(t,e[n],i,s[n])):s[n]=e[n](t,i,s,r)}return i};te.parse=s0;var n0=function(t,e){return function(i,s,n,o){e(i,s,n)&&o(i,t,s,n)}};te.conditional=n0;var r0=function(t,e){return function(i,s,n,o){for(var a=[],h=i.pos;e(i,s,n);){var l={};if(o(i,t,s,l),i.pos===h)break;h=i.pos,a.push(l)}return a}};te.loop=r0;var ut={};Object.defineProperty(ut,"__esModule",{value:!0});ut.readBits=ut.readArray=ut.readUnsigned=ut.readString=ut.peekBytes=ut.readBytes=ut.peekByte=ut.readByte=ut.buildStream=void 0;var o0=function(t){return{data:t,pos:0}};ut.buildStream=o0;var mc=function(){return function(t){return t.data[t.pos++]}};ut.readByte=mc;var a0=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(e){return e.data[e.pos+t]}};ut.peekByte=a0;var zs=function(t){return function(e){return e.data.subarray(e.pos,e.pos+=t)}};ut.readBytes=zs;var h0=function(t){return function(e){return e.data.subarray(e.pos,e.pos+t)}};ut.peekBytes=h0;var l0=function(t){return function(e){return Array.from(zs(t)(e)).map(function(i){return String.fromCharCode(i)}).join("")}};ut.readString=l0;var c0=function(t){return function(e){var i=zs(2)(e);return t?(i[1]<<8)+i[0]:(i[0]<<8)+i[1]}};ut.readUnsigned=c0;var d0=function(t,e){return function(i,s,n){for(var o=typeof e=="function"?e(i,s,n):e,a=zs(t),h=new Array(o),l=0;l<o;l++)h[l]=a(i);return h}};ut.readArray=d0;var u0=function(t,e,i){for(var s=0,n=0;n<i;n++)s+=t[e+n]&&Math.pow(2,i-n-1);return s},p0=function(t){return function(e){for(var i=mc()(e),s=new Array(8),n=0;n<8;n++)s[7-n]=!!(i&1<<n);return Object.keys(t).reduce(function(o,a){var h=t[a];return h.length?o[a]=u0(s,h.index,h.length):o[a]=s[h.index],o},{})}};ut.readBits=p0;(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var t=te,e=ut,i={blocks:function(u){for(var p=0,f=[],y=u.data.length,m=0,x=(0,e.readByte)()(u);x!==p&&x;x=(0,e.readByte)()(u)){if(u.pos+x>=y){var S=y-u.pos;f.push((0,e.readBytes)(S)(u)),m+=S;break}f.push((0,e.readBytes)(x)(u)),m+=x}for(var v=new Uint8Array(m),b=0,P=0;P<f.length;P++)v.set(f[P],b),b+=f[P].length;return v}},s=(0,t.conditional)({gce:[{codes:(0,e.readBytes)(2)},{byteSize:(0,e.readByte)()},{extras:(0,e.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,e.readUnsigned)(!0)},{transparentColorIndex:(0,e.readByte)()},{terminator:(0,e.readByte)()}]},function(d){var u=(0,e.peekBytes)(2)(d);return u[0]===33&&u[1]===249}),n=(0,t.conditional)({image:[{code:(0,e.readByte)()},{descriptor:[{left:(0,e.readUnsigned)(!0)},{top:(0,e.readUnsigned)(!0)},{width:(0,e.readUnsigned)(!0)},{height:(0,e.readUnsigned)(!0)},{lct:(0,e.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,t.conditional)({lct:(0,e.readArray)(3,function(d,u,p){return Math.pow(2,p.descriptor.lct.size+1)})},function(d,u,p){return p.descriptor.lct.exists}),{data:[{minCodeSize:(0,e.readByte)()},i]}]},function(d){return(0,e.peekByte)()(d)===44}),o=(0,t.conditional)({text:[{codes:(0,e.readBytes)(2)},{blockSize:(0,e.readByte)()},{preData:function(u,p,f){return(0,e.readBytes)(f.text.blockSize)(u)}},i]},function(d){var u=(0,e.peekBytes)(2)(d);return u[0]===33&&u[1]===1}),a=(0,t.conditional)({application:[{codes:(0,e.readBytes)(2)},{blockSize:(0,e.readByte)()},{id:function(u,p,f){return(0,e.readString)(f.blockSize)(u)}},i]},function(d){var u=(0,e.peekBytes)(2)(d);return u[0]===33&&u[1]===255}),h=(0,t.conditional)({comment:[{codes:(0,e.readBytes)(2)},i]},function(d){var u=(0,e.peekBytes)(2)(d);return u[0]===33&&u[1]===254}),l=[{header:[{signature:(0,e.readString)(3)},{version:(0,e.readString)(3)}]},{lsd:[{width:(0,e.readUnsigned)(!0)},{height:(0,e.readUnsigned)(!0)},{gct:(0,e.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,e.readByte)()},{pixelAspectRatio:(0,e.readByte)()}]},(0,t.conditional)({gct:(0,e.readArray)(3,function(d,u){return Math.pow(2,u.lsd.gct.size+1)})},function(d,u){return u.lsd.gct.exists}),{frames:(0,t.loop)([s,a,h,n,o],function(d){var u=(0,e.peekByte)()(d);return u===33||u===44})}],c=l;r.default=c})(gc);var Ls={};Object.defineProperty(Ls,"__esModule",{value:!0});Ls.deinterlace=void 0;var f0=function(t,e){for(var i=new Array(t.length),s=t.length/e,n=function(u,p){var f=t.slice(p*e,(p+1)*e);i.splice.apply(i,[u*e,e].concat(f))},o=[0,4,2,1],a=[8,8,4,2],h=0,l=0;l<4;l++)for(var c=o[l];c<s;c+=a[l])n(c,h),h++;return i};Ls.deinterlace=f0;var Os={};Object.defineProperty(Os,"__esModule",{value:!0});Os.lzw=void 0;var g0=function(t,e,i){var s=4096,n=-1,o=i,a,h,l,c,d,u,p,w,f,y,P,m,C,k,T,M,x=new Array(i),S=new Array(s),v=new Array(s),b=new Array(s+1);for(m=t,h=1<<m,d=h+1,a=h+2,p=n,c=m+1,l=(1<<c)-1,f=0;f<h;f++)S[f]=0,v[f]=f;var P,w,C,k,M,T;for(P=w=C=k=M=T=0,y=0;y<o;){if(k===0){if(w<c){P+=e[T]<<w,w+=8,T++;continue}if(f=P&l,P>>=c,w-=c,f>a||f==d)break;if(f==h){c=m+1,l=(1<<c)-1,a=h+2,p=n;continue}if(p==n){b[k++]=v[f],p=f,C=f;continue}for(u=f,f==a&&(b[k++]=C,f=p);f>h;)b[k++]=v[f],f=S[f];C=v[f]&255,b[k++]=C,a<s&&(S[a]=p,v[a]=C,a++,!(a&l)&&a<s&&(c++,l+=a)),p=u}k--,x[M++]=b[k],y++}for(y=M;y<o;y++)x[y]=0;return x};Os.lzw=g0;Object.defineProperty(ke,"__esModule",{value:!0});var yc=ke.decompressFrames=ke.decompressFrame=xc=ke.parseGIF=void 0,m0=b0(gc),y0=te,x0=ut,S0=Ls,v0=Os;function b0(r){return r&&r.__esModule?r:{default:r}}var w0=function(t){var e=new Uint8Array(t);return(0,y0.parse)((0,x0.buildStream)(e),m0.default)},xc=ke.parseGIF=w0,A0=function(t){for(var e=t.pixels.length,i=new Uint8ClampedArray(e*4),s=0;s<e;s++){var n=s*4,o=t.pixels[s],a=t.colorTable[o]||[0,0,0];i[n]=a[0],i[n+1]=a[1],i[n+2]=a[2],i[n+3]=o!==t.transparentIndex?255:0}return i},Sc=function(t,e,i){if(!t.image){console.warn("gif frame does not have associated image.");return}var s=t.image,n=s.descriptor.width*s.descriptor.height,o=(0,v0.lzw)(s.data.minCodeSize,s.data.blocks,n);s.descriptor.lct.interlaced&&(o=(0,S0.deinterlace)(o,s.descriptor.width));var a={pixels:o,dims:{top:t.image.descriptor.top,left:t.image.descriptor.left,width:t.image.descriptor.width,height:t.image.descriptor.height}};return s.descriptor.lct&&s.descriptor.lct.exists?a.colorTable=s.lct:a.colorTable=e,t.gce&&(a.delay=(t.gce.delay||10)*10,a.disposalType=t.gce.extras.disposal,t.gce.extras.transparentColorGiven&&(a.transparentIndex=t.gce.transparentColorIndex)),i&&(a.patch=A0(a)),a};ke.decompressFrame=Sc;var C0=function(t,e){return t.frames.filter(function(i){return i.image}).map(function(i){return Sc(i,t.gct,e)})};yc=ke.decompressFrames=C0;class Gs{constructor(t){if(!t||!t.length)throw new Error("Invalid frames");const[{texture:{width:e,height:i}}]=t;this.width=e,this.height=i,this.frames=t,this.textures=this.frames.map(s=>s.texture),this.totalFrames=this.frames.length,this.duration=this.frames[this.totalFrames-1].end}destroy(){for(const t of this.textures)t.destroy(!0);for(const t of this.frames)t.texture=null;this.frames.length=0,this.textures.length=0,Object.assign(this,{frames:null,textures:null,width:0,height:0,duration:0,totalFrames:0})}static from(t,e){if(!t||t.byteLength===0)throw new Error("Invalid buffer");const i=S=>{let v=null;for(const b of S.frames)v=b.gce??v,"image"in b&&!("gce"in b)&&(b.gce=v)},s=xc(t);i(s);const n=yc(s,!0),o=[],a=s.lsd.width,h=s.lsd.height,l=j.get().createCanvas(a,h),c=l.getContext("2d",{willReadFrequently:!0}),d=j.get().createCanvas(),u=d.getContext("2d");let p=0,f=null;const{fps:y=30,...m}=e??{},x=1e3/y;for(let S=0;S<n.length;S++){const{disposalType:v=2,delay:b=x,patch:P,dims:{width:w,height:C,left:k,top:M}}=n[S];d.width=w,d.height=C,u.clearRect(0,0,w,C);const T=u.createImageData(w,C);T.data.set(P),u.putImageData(T,0,0),v===3&&(f=c.getImageData(0,0,a,h)),c.drawImage(d,k,M);const _=c.getImageData(0,0,a,h);v===2?c.clearRect(0,0,a,h):v===3&&c.putImageData(f,0,0);const I=j.get().createCanvas(_.width,_.height);I.getContext("2d").putImageData(_,0,0),o.push({start:p,end:p+b,texture:new G({source:new dr({resource:I,...m})})}),p+=b}return l.width=l.height=0,d.width=d.height=0,new Gs(o)}}const P0={extension:E.Asset,detection:{test:async()=>!0,add:async r=>[...r,"gif"],remove:async r=>r.filter(t=>t!=="gif")},loader:{name:"gifLoader",id:"gif",test:r=>Mt.extname(r)===".gif"||r.startsWith("data:image/gif"),load:async(r,t)=>{const i=await(await j.get().fetch(r)).arrayBuffer();return Gs.from(i,t==null?void 0:t.data)},unload:async r=>{r.destroy()}}},vc=class rr extends jt{constructor(...t){const e=t[0]instanceof Gs?{source:t[0]}:t[0],{source:i,fps:s,loop:n,animationSpeed:o,autoPlay:a,autoUpdate:h,onComplete:l,onFrameChange:c,onLoop:d,...u}=Object.assign({},rr.defaultOptions,e);super({texture:G.EMPTY,...u}),this.animationSpeed=1,this.loop=!0,this.duration=0,this.autoPlay=!0,this.dirty=!1,this._currentFrame=0,this._autoUpdate=!1,this._isConnectedToTicker=!1,this._playing=!1,this._currentTime=0,this.onRender=()=>this._updateFrame(),this.texture=i.textures[0],this.duration=i.frames[i.frames.length-1].end,this._source=i,this._playing=!1,this._currentTime=0,this._isConnectedToTicker=!1,Object.assign(this,{fps:s,loop:n,animationSpeed:o,autoPlay:a,autoUpdate:h,onComplete:l,onFrameChange:c,onLoop:d}),this.currentFrame=0,a&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(yt.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(yt.shared.add(this.update,this,Ee.HIGH),this._isConnectedToTicker=!0),!this.loop&&this.currentFrame===this._source.frames.length-1&&(this._currentTime=0))}get progress(){return this._currentTime/this.duration}get playing(){return this._playing}update(t){var o,a;if(!this._playing)return;const e=this.animationSpeed*t.deltaTime/yt.targetFPMS,i=this._currentTime+e,s=i%this.duration,n=this._source.frames.findIndex(h=>h.start<=s&&h.end>s);i>=this.duration?this.loop?(this._currentTime=s,this._updateFrameIndex(n),(o=this.onLoop)==null||o.call(this)):(this._currentTime=this.duration,this._updateFrameIndex(this.totalFrames-1),(a=this.onComplete)==null||a.call(this),this.stop()):(this._currentTime=s,this._updateFrameIndex(n))}_updateFrame(){this.dirty&&(this.texture=this._source.frames[this._currentFrame].texture,this.dirty=!1)}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(yt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(yt.shared.add(this.update,this),this._isConnectedToTicker=!0))}get currentFrame(){return this._currentFrame}set currentFrame(t){this._updateFrameIndex(t),this._currentTime=this._source.frames[t].start}get source(){return this._source}_updateFrameIndex(t){var e;if(t<0||t>=this.totalFrames)throw new Error(`Frame index out of range, expecting 0 to ${this.totalFrames}, got ${t}`);this._currentFrame!==t&&(this._currentFrame=t,this.dirty=!0,(e=this.onFrameChange)==null||e.call(this,t))}get totalFrames(){return this._source.totalFrames}destroy(t=!1){this.stop(),super.destroy(),t&&this._source.destroy();const e=null;this._source=e,this.onComplete=e,this.onFrameChange=e,this.onLoop=e}clone(){const t=new rr({source:this._source,autoUpdate:this._autoUpdate,loop:this.loop,autoPlay:this.autoPlay,animationSpeed:this.animationSpeed,onComplete:this.onComplete,onFrameChange:this.onFrameChange,onLoop:this.onLoop});return t.dirty=!0,t}};vc.defaultOptions={fps:30,loop:!0,animationSpeed:1,autoPlay:!0,autoUpdate:!0,onComplete:null,onFrameChange:null,onLoop:null};let M0=vc;$.add(P0);class Hr extends M0{constructor(e,i){super(i);g(this,"throttledUpdateScale");g(this,"fixedWidth",0);g(this,"fixedHeight",0);g(this,"isFixedSizeSet",!1);g(this,"sizeFixed",!0);g(this,"baselineScale",1);this.appService=e,this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=At(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(e,i){this.fixedWidth=e,this.fixedHeight=i,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(e){this.sizeFixed=e,this.baselineScale=1,e&&this.isFixedSizeSet?this.applySize():!e&&this.isFixedSizeSet&&this.applySize()}set width(e){if(this.isFixedSizeSet){A.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置宽度");return}this.setFixedSize(e,this.fixedHeight||e)}set height(e){if(this.isFixedSizeSet){A.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置高度");return}this.setFixedSize(this.fixedWidth||e,e)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.texture||this.texture.width===0||this.texture.height===0)return;const e=this.fixedWidth/this.texture.width,i=this.fixedHeight/this.texture.height;if(this.sizeFixed){const s=this.appService.currentScale;if(s===0)return;const n=e/s,o=i/s;super.scale.set(n,o)}else super.scale.set(e/this.baselineScale,i/this.baselineScale)}updateScale(e){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():e!==0&&super.scale.set(1/e))}static async createFromSrc(e,i,s){try{const n=await N.load(i),o=new Hr(e,{source:n});return s.sizeFixed!==void 0&&o.setSizeFixed(s.sizeFixed),o.setFixedSize(s.width,s.height),o}catch(n){throw A.error(`Failed to load GIF "${i}":`,n),n}}draw(e,i){const{x:s,y:n,rotation:o=0}=e;i&&!this.visible?this.visible=i():!i&&!this.visible&&(this.visible=!0),this.rotation=o,this.position.set(s,n)}destroy(e){this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(e)}}class Ge extends Hr{constructor(e,i,s){super(e,{source:i});g(this,"elementData");g(this,"clickHandler",null);g(this,"unsubscribeMapRotation",null);g(this,"userRotation",0);this.elementData=s}async initialize(){this.elementData.sizeFixed!==void 0&&this.setSizeFixed(this.elementData.sizeFixed),this.setFixedSize(this.elementData.width,this.elementData.height);const e=this.elementData.anchor||{x:.5,y:.5};this.anchor.set(e.x,e.y),this.position.set(this.elementData.x,this.elementData.y),this.elementData.rotation!==void 0&&(this.userRotation=this.elementData.rotation),this.elementData.opacity!==void 0&&(this.alpha=this.elementData.opacity),this.applyRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=U(this.appService.runtime,"mapRotation",i=>{this.applyRotation(i)}),this.visible=!0,this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(e){const i=-e*Math.PI/180;this.rotation=this.userRotation+i}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new vt(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var e,i;(i=(e=this.appService.events)==null?void 0:e.onClickCustomElement)==null||i.call(e,this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(e){const i=this.elementData;if(this.elementData=e,i.src!==e.src)throw new Error("GIF source change requires recreation of instance");i.sizeFixed!==e.sizeFixed&&e.sizeFixed!==void 0&&this.setSizeFixed(e.sizeFixed),(i.width!==e.width||i.height!==e.height)&&this.setFixedSize(e.width,e.height);const s=e.anchor||{x:.5,y:.5},n=i.anchor||{x:.5,y:.5};(s.x!==n.x||s.y!==n.y)&&this.anchor.set(s.x,s.y),this.position.set(e.x,e.y),e.rotation!==void 0&&(this.userRotation=e.rotation,this.applyRotation(this.appService.runtime.mapRotation)),e.opacity!==void 0&&(this.alpha=e.opacity),e.interactive?this.clickHandler||this.setupClickHandler():(this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.eventMode="none")}isSameData(e){const i=this.elementData.anchor||{x:.5,y:.5},s=e.anchor||{x:.5,y:.5};return this.elementData.id===e.id&&this.elementData.type===e.type&&this.elementData.src===e.src&&this.elementData.x===e.x&&this.elementData.y===e.y&&this.elementData.width===e.width&&this.elementData.height===e.height&&this.elementData.rotation===e.rotation&&this.elementData.opacity===e.opacity&&this.elementData.interactive===e.interactive&&this.elementData.sizeFixed===e.sizeFixed&&i.x===s.x&&i.y===s.y}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class Mn extends Xt{constructor(e,i){super(e);g(this,"elementData");g(this,"clickHandler",null);g(this,"unsubscribeMapRotation",null);g(this,"userRotation",0);this.appService=e,this.elementData=i}async initialize(){await this.loadTextureAndSetSize(this.elementData.src,{width:this.elementData.width,height:this.elementData.height,sizeFixed:this.elementData.sizeFixed});const e=this.elementData.anchor||{x:.5,y:.5};this.anchor.set(e.x,e.y),this.position.set(this.elementData.x,this.elementData.y),this.elementData.rotation!==void 0&&(this.userRotation=this.elementData.rotation),this.elementData.opacity!==void 0&&(this.alpha=this.elementData.opacity),this.applyRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=U(this.appService.runtime,"mapRotation",i=>{this.applyRotation(i)}),this.visible=!0,this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(e){const i=-e*Math.PI/180;this.rotation=this.userRotation+i}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new vt(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var e,i;(i=(e=this.appService.events)==null?void 0:e.onClickCustomElement)==null||i.call(e,this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(e){const i=this.elementData;this.elementData=e,i.src!==e.src?await this.loadTextureAndSetSize(e.src,{width:e.width,height:e.height,sizeFixed:e.sizeFixed}):(i.sizeFixed!==e.sizeFixed&&e.sizeFixed!==void 0&&this.setSizeFixed(e.sizeFixed),(i.width!==e.width||i.height!==e.height)&&this.setFixedSize(e.width,e.height));const s=e.anchor||{x:.5,y:.5},n=i.anchor||{x:.5,y:.5};(s.x!==n.x||s.y!==n.y)&&this.anchor.set(s.x,s.y),this.position.set(e.x,e.y),e.rotation!==void 0&&(this.userRotation=e.rotation,this.applyRotation(this.appService.runtime.mapRotation)),e.opacity!==void 0&&(this.alpha=e.opacity),e.interactive?this.clickHandler||this.setupClickHandler():(this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.eventMode="none")}isSameData(e){const i=this.elementData.anchor||{x:.5,y:.5},s=e.anchor||{x:.5,y:.5};return this.elementData.id===e.id&&this.elementData.type===e.type&&this.elementData.src===e.src&&this.elementData.x===e.x&&this.elementData.y===e.y&&this.elementData.width===e.width&&this.elementData.height===e.height&&this.elementData.rotation===e.rotation&&this.elementData.opacity===e.opacity&&this.elementData.interactive===e.interactive&&this.elementData.sizeFixed===e.sizeFixed&&i.x===s.x&&i.y===s.y}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class _0 extends Fg{constructor(e,i){super(i);g(this,"throttledUpdateScale");g(this,"fixedWidth",0);g(this,"fixedHeight",0);g(this,"isFixedSizeSet",!1);g(this,"userCenterX",0);g(this,"userCenterY",0);g(this,"sizeFixed",!0);this.appService=e,this.anchor.set(0,0),this.throttledUpdateScale=At(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(e,i){this.fixedWidth=e,this.fixedHeight=i,this.isFixedSizeSet=!0,this.applyFixedSize(),this.updatePositionFromCenter()}setCenterPosition(e,i){this.userCenterX=e,this.userCenterY=i,this.updatePositionFromCenter()}setSizeFixed(e){this.sizeFixed=e,this.isFixedSizeSet&&(this.applyFixedSize(),this.updatePositionFromCenter())}getIsFixedSizeSet(){return this.isFixedSizeSet}updatePositionFromCenter(){if(!this.isFixedSizeSet){this.position.set(this.userCenterX,this.userCenterY);return}const i=this.appService.currentScale;let s,n;this.sizeFixed?(s=this.fixedWidth/2/i,n=this.fixedHeight/2/i):(s=this.fixedWidth/2,n=this.fixedHeight/2),this.position.set(this.userCenterX-s,this.userCenterY-n)}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}applyFixedSize(){if(!this.isFixedSizeSet)return;const i=this.appService.currentScale;if(i!==0){if(this.sizeFixed){const s=1/i;this.scale.set(s)}else this.scale.set(1);this.element&&(this.element.style.width=`${this.fixedWidth}px`,this.element.style.height=`${this.fixedHeight}px`)}}updateScale(e){this.isFixedSizeSet&&e!==0&&(this.applyFixedSize(),this.updatePositionFromCenter())}updateTransform(e){return super.updateTransform(e)}destroy(e){this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(e)}}class ki extends _0{constructor(e,i){const s=document.createElement("div");ki.setupDefaultStyles(s,i),s.innerHTML=i.htmlContent;super(e,{element:s});g(this,"elementData");g(this,"domClickHandler",null);g(this,"resizeObserver",null);g(this,"debugMarker",null);g(this,"unsubscribeMapRotation",null);g(this,"userRotation",0);this.elementData=i}async initialize(){this.alpha=0,this.elementData.width&&this.elementData.height?(this.setFixedSize(this.elementData.width,this.elementData.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),this.waitForElementInsertion()):(this.position.set(this.elementData.x,this.elementData.y),this.setupAutoSize()),this.elementData.rotation!==void 0&&(this.userRotation=this.elementData.rotation),this.applyRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=U(this.appService.runtime,"mapRotation",e=>{this.applyRotation(e)}),this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(e){const i=-e*Math.PI/180;this.rotation=this.userRotation+i}setupAutoSize(){this.element&&(this.element.style.width="auto",this.element.style.height="auto",this.waitForElementDimensions())}waitForElementInsertion(){if(!this.element)return;const e=()=>{this.element&&(this.element.isConnected?this.showElement():requestAnimationFrame(e))};requestAnimationFrame(e)}waitForElementDimensions(){this.element&&(typeof ResizeObserver<"u"?(this.resizeObserver=new ResizeObserver(e=>{var s;const i=e[0];i&&i.contentRect.width>0&&i.contentRect.height>0&&(this.setFixedSize(i.contentRect.width,i.contentRect.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),this.alpha===0&&this.showElement(),(s=this.resizeObserver)==null||s.disconnect(),this.resizeObserver=null)}),this.resizeObserver.observe(this.element)):this.pollForElementDimensions())}pollForElementDimensions(){if(!this.element)return;const e=()=>{if(!this.element)return;if(!this.element.isConnected){requestAnimationFrame(e);return}const i=this.element.getBoundingClientRect();i.width>0&&i.height>0?(this.setFixedSize(i.width,i.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),this.alpha===0&&this.showElement()):requestAnimationFrame(e)};requestAnimationFrame(e)}showElement(){this.alpha=this.elementData.opacity??1,this.element.style.pointerEvents=this.elementData.interactive?"auto":"none",this.interactive=this.elementData.interactive??!1,this.elementData.interactive&&this.element&&(this.element.style.setProperty("-webkit-tap-highlight-color","transparent"),this.element.style.setProperty("-webkit-touch-callout","none")),this.appService.getApp().renderOnceNextFrame()}setupClickHandler(){this.element&&(this.domClickHandler=e=>{e.preventDefault(),e.stopPropagation(),this.handleClick()},this.element.addEventListener("click",this.domClickHandler))}handleClick(){var e,i;(i=(e=this.appService.events)==null?void 0:e.onClickCustomElement)==null||i.call(e,this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(e){const i=this.elementData;this.elementData=e,i.htmlContent!==e.htmlContent&&this.element&&(this.element.innerHTML=e.htmlContent,(!e.width||!e.height)&&this.waitForElementDimensions()),(i.width!==e.width||i.height!==e.height)&&(e.width&&e.height?(this.setFixedSize(e.width,e.height),this.element&&(this.element.style.width=`${e.width}px`,this.element.style.height=`${e.height}px`)):this.setupAutoSize()),e.width&&e.height?this.setCenterPosition(e.x,e.y):this.getIsFixedSizeSet()?this.setCenterPosition(e.x,e.y):this.position.set(e.x,e.y),i.sizeFixed!==e.sizeFixed&&e.sizeFixed!==void 0&&this.setSizeFixed(e.sizeFixed),this.userRotation=e.rotation??0,this.applyRotation(this.appService.runtime.mapRotation),this.alpha=e.opacity??1,e.interactive?this.domClickHandler||this.setupClickHandler():(this.eventMode="none",this.domClickHandler&&this.element&&(this.element.removeEventListener("click",this.domClickHandler),this.domClickHandler=null))}isSameData(e){return this.elementData.id===e.id&&this.elementData.type===e.type&&this.elementData.htmlContent===e.htmlContent&&this.elementData.x===e.x&&this.elementData.y===e.y&&this.elementData.width===e.width&&this.elementData.height===e.height&&this.elementData.rotation===e.rotation&&this.elementData.opacity===e.opacity&&this.elementData.interactive===e.interactive&&this.elementData.sizeFixed===e.sizeFixed}static setupDefaultStyles(e,i){const s={position:"relative",boxSizing:"border-box",webkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",background:"transparent",userSelect:"auto",webkitUserSelect:"auto"};i.width&&i.height?(s.width=`${i.width}px`,s.height=`${i.height}px`,s.overflow="hidden"):(s.width=i.width?`${i.width}px`:"auto",s.height=i.height?`${i.height}px`:"auto",s.overflow="visible"),Object.assign(e.style,s),e.style.setProperty("-webkit-tap-highlight-color","transparent"),e.style.setProperty("-webkit-touch-callout","none")}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.domClickHandler&&this.element&&(this.element.removeEventListener("click",this.domClickHandler),this.domClickHandler=null),this.debugMarker&&(this.debugMarker.destroy(),this.debugMarker=null),super.destroy()}}class T0{constructor(t){g(this,"customElementsMap",new Map);g(this,"gifTicker",null);g(this,"gifElements",new Set);this.appService=t}updatePositionByOrigin(t,e){const i=this.appService,s=i.appContainer.getLayer(Si),n=i.appContainer.getLayer(vi);s&&s.position.set(t,e),n&&n.position.set(t,e)}async drawCustomElements(t){if(!t||t.length===0){this.clearAllCustomElements();return}const e=new Set(t.map(n=>n.id)),i=Array.from(this.customElementsMap.keys());for(const n of i)e.has(n)||this.removeCustomElement(n);const s=t.map(async n=>{const o=this.customElementsMap.get(n.id);o?this.isSameData(o,n)||(n.type==="gif"&&o.getElementData().src!==n.src?(this.removeCustomElement(n.id),await this.addNewCustomElement(n)):await this.updateElementData(o,n)):await this.addNewCustomElement(n)});await Promise.all(s),this.updateGifTicker()}clearAllCustomElements(){const t=this.appService;this.customElementsMap.forEach(e=>{e instanceof Ge?t.appContainer.removeFromLayer(vi,e):t.appContainer.removeFromLayer(Si,e),e.destroy()}),this.customElementsMap.clear(),this.gifElements.clear(),this.stopGifTicker()}async addNewCustomElement(t){const e=this.appService;let i;switch(t.type){case"image":i=new Mn(this.appService,t);break;case"gif":{const s=await N.load(t.src);i=new Ge(this.appService,s,t);break}case"html":i=new ki(this.appService,t);break;default:throw new Error(`Unsupported custom element type: ${t.type}`)}await i.initialize(),this.customElementsMap.set(t.id,i),i instanceof Ge?(e.appContainer.addToLayer(vi,i),this.gifElements.add(i)):e.appContainer.addToLayer(Si,i)}removeCustomElement(t){const e=this.appService,i=this.customElementsMap.get(t);i&&(i instanceof Ge?(this.gifElements.delete(i),e.appContainer.removeFromLayer(vi,i)):e.appContainer.removeFromLayer(Si,i),i.destroy(),this.customElementsMap.delete(t))}isSameData(t,e){return t.getElementData().type!==e.type?!1:e.type==="image"&&t instanceof Mn||e.type==="gif"&&t instanceof Ge||e.type==="html"&&t instanceof ki?t.isSameData(e):!1}async updateElementData(t,e){if(e.type==="image"&&t instanceof Mn)await t.updateElementData(e);else if(e.type==="gif"&&t instanceof Ge)await t.updateElementData(e);else if(e.type==="html"&&t instanceof ki)await t.updateElementData(e);else throw new Error("Element type mismatch during update")}updateGifTicker(){this.gifElements.size>0?this.startGifTicker():this.stopGifTicker()}startGifTicker(){var t;(t=this.gifTicker)!=null&&t.started||(this.gifTicker?this.gifTicker.maxFPS=1:(this.gifTicker=new yt,this.gifTicker.maxFPS=1,this.gifTicker.add(()=>{this.renderGifContainer()})),this.gifTicker.start())}stopGifTicker(){var t;(t=this.gifTicker)!=null&&t.started&&(A.log("⏸️ [GifTicker] 停止 GIF 专用渲染"),this.gifTicker.stop())}renderGifContainer(){const t=this.appService;if(this.gifElements.size===0)return;const e=t.getApp();e.renderer.render(e.stage)}destroy(){this.stopGifTicker(),this.gifTicker&&(this.gifTicker.destroy(),this.gifTicker=null),this.clearAllCustomElements()}}class k0 extends L{constructor(e,i){super();g(this,"roomId");g(this,"roomIndex");g(this,"appService");g(this,"nameText");g(this,"iconSprite",null);g(this,"iconWrapper",null);g(this,"iconBg",null);this.appService=e,this.roomId=i.id,this.roomIndex=i.index;const{nameLabel:s,type:n}=e.roomConfig,{showRoomType:o}=e.runtime,a=i.colorIndex??i.index,h=this.getRoomNameColor(a),l=new de({fontSize:s.fontSize,fontFamily:s.fontFamily,fontWeight:s.fontWeight,fill:h,align:"center"}),c=i.name||"Unknown";this.nameText=new Es({text:c,style:l}),this.nameText.anchor.set(.5),o&&i.type!=null&&(n!=null&&n.assets)&&n.assets[i.type]&&this.createIcon(i.type,h),this.addChild(this.nameText),this.layout()}createIcon(e,i){const{type:s}=this.appService.roomConfig,n=s.iconSize||14;this.iconWrapper||(this.iconWrapper=new L,this.addChild(this.iconWrapper)),s.container.visible?(this.iconBg||(this.iconBg=new H,this.iconWrapper.addChild(this.iconBg)),this.drawIconBg(i)):this.iconBg&&(this.iconBg.destroy(),this.iconBg=null),this.iconSprite||(this.iconSprite=new Xt(this.appService),this.iconSprite.anchor.set(.5),this.iconWrapper.addChild(this.iconSprite)),this.iconSprite.visible=!0,this.iconSprite.tint=s.container.visible?"#ffffff":i,this.iconSprite.setFixedSize(n,n),this.iconSprite.loadTextureAndSetSize(s.assets[e],{width:n,height:n,sizeFixed:!1}).then(()=>{this.iconSprite&&(this.iconSprite.visible=this.appService.runtime.showRoomType,this.layout())}),s.container&&this.iconSprite.position.set(0,0)}drawIconBg(e){const{type:i}=this.appService.roomConfig;if(!this.iconBg||!i.container.visible)return;const{size:s,borderRadius:n}=i.container;this.iconBg.clear().roundRect(-s/2,-s/2,s,s,n).fill(e)}layout(){if(!this.iconWrapper||!this.iconWrapper.visible){this.nameText.position.set(0,0);return}if(!(this.iconSprite&&this.iconSprite.visible||this.iconBg&&this.iconBg.visible)){this.nameText.position.set(0,0);return}const{gap:i=4,position:s="left"}=this.appService.roomConfig.type,n=this.nameText.width,o=this.iconWrapper.width,h=-(o+i+n)/2;s==="left"?(this.iconWrapper.x=h+o/2,this.nameText.x=h+o+i+n/2):(this.nameText.x=h+n/2,this.iconWrapper.x=h+n+i+o/2),this.iconWrapper.y=0,this.nameText.y=0}updateName(e){this.nameText.text=e,this.layout()}refreshColor(e){const{type:i}=this.appService.roomConfig,s=this.appService.getRoomData(this.roomId),n=(s==null?void 0:s.colorIndex)??this.roomIndex,o=this.getRoomNameColor(n,e);this.nameText.style.fill=o,this.iconBg&&this.drawIconBg(o),this.iconSprite&&(this.iconSprite.tint=i.container.visible?"#ffffff":o)}getRoomNameColor(e,i){const{colors:s}=this.appService.roomConfig,{enableRoomSelection:n,selectRoomIds:o}=this.appService.runtime;if(i)return i;if(n)return!o.includes(this.roomId)&&s.nameInactive?s.nameInactive[e%s.nameInactive.length]:s.name[e%s.name.length];const a=s.nameNormal||s.name;return a[e%a.length]}async updateRoomType(e){const{type:i}=this.appService.roomConfig;if(!this.appService.runtime.showRoomType||e==null||!(i!=null&&i.assets)||!i.assets[e])this.iconWrapper&&(this.iconWrapper.visible=!1);else{const n=this.appService.getRoomData(this.roomId),o=(n==null?void 0:n.colorIndex)??this.roomIndex,a=this.getRoomNameColor(o);this.createIcon(e,a),this.iconWrapper&&(this.iconWrapper.visible=!0)}this.layout()}updateRoomTypeVisibility(e){if(this.iconWrapper)this.iconWrapper.visible=e,this.layout();else if(e){const i=this.appService.getRoomData(this.roomId);i&&this.updateRoomType(i.type??null)}}destroy(e){this.iconBg&&(this.iconBg.destroy(),this.iconBg=null),this.iconSprite&&(this.iconSprite.destroy(),this.iconSprite=null),this.iconWrapper&&(this.iconWrapper.destroy(),this.iconWrapper=null),super.destroy(e)}}class R0 extends L{constructor(e,i){super();g(this,"background");g(this,"foldedIndicator");g(this,"propertyIcons",new Map);g(this,"orderContainer");g(this,"orderBackground");g(this,"orderText");g(this,"isFolded",!1);g(this,"roomId");g(this,"roomIndex");g(this,"isDestroyed",!1);this.appService=e;const s=this.appService.roomConfig;this.roomId=i.id,this.roomIndex=i.index,this.background=new H,this.foldedIndicator=new H,this.foldedIndicator.visible=!1;const{property:n}=s,o=i.colorIndex??i.index,a=this.getIconColor(o);this.initializePropertyIcons(n.displayOrders,a);const h=n.cleanOrder.color==="auto"?s.colors.active[o%s.colors.active.length]:n.cleanOrder.color;this.orderContainer=new L,this.orderBackground=new H,this.orderText=new Es({text:"",style:new de({fontSize:n.cleanOrder.fontSize,fontFamily:n.cleanOrder.fontFamily,fontWeight:n.cleanOrder.fontWeight,fill:h,align:"center",trim:!0})}),this.orderText.anchor.set(.5,.5),this.orderContainer.addChild(this.orderBackground),this.orderContainer.addChild(this.orderText),this.addChild(this.background),this.addChild(this.foldedIndicator),this.propertyIcons.forEach(({sprite:l})=>{this.addChild(l)}),this.addChild(this.orderContainer),this.visible=this.appService.runtimeSnapshot.showRoomProperty}initializePropertyIcons(e,i){const s=["cleanMode","suction","cistern","cleanTimes"];e.forEach(n=>{const o=s.includes(n),a=new Xt(this.appService);a.tint=i,a.anchor.set(0,0),this.propertyIcons.set(n,{fieldName:n,sprite:a,isBuiltin:o})})}async updateProperty(e){this.isDestroyed||this.destroyed||(await this.updateIcons(e),!(this.isDestroyed||this.destroyed)&&this.updateBackground())}getFieldValue(e,i){if(["cleanMode","suction","cistern","cleanTimes"].includes(i))return e[i]??null;if(e.customData&&i in e.customData){const n=e.customData[i];return typeof n=="number"?n:null}return null}getAssetAlias(e,i){const s={cleanMode:n=>`cleanMode_${n}`,suction:n=>`fan_${n}`,cistern:n=>`water_${n}`,cleanTimes:n=>`cleanTimes${n}`};return e in s?s[e](i):`custom_${e}_${i}`}shouldShowField(e,i,s){const{showRoomProperty:n}=this.appService.runtimeSnapshot;return!(s===null||!n||i==="cleanTimes"&&s<=0)}getDisplayElements(e){const{displayOrders:i}=this.appService.roomConfig.property,{showRoomOrder:s}=this.appService.runtimeSnapshot,n=e.order||0,o=s&&n>0,a=[];return o&&a.push({element:this.orderContainer,show:!0,isOrder:!0,fieldName:"order"}),i.forEach(h=>{const l=this.propertyIcons.get(h);if(!l||!l.sprite)return;const c=this.getFieldValue(e,h);this.shouldShowField(e,h,c)&&c!==null&&a.push({element:l.sprite,show:!0,isOrder:!1,fieldName:h,value:c})}),{elementsToShow:a,orderValue:n}}async updateIcons(e){if(this.isDestroyed||this.destroyed||this.isFolded)return;const{iconWidth:i,iconHeight:s,container:n,cleanOrder:o,iconGap:a}=this.appService.roomConfig.property,{paddingHorizontal:h,paddingVertical:l}=n,{elementsToShow:c,orderValue:d}=this.getDisplayElements(e);this.orderContainer.visible=!1,this.propertyIcons.forEach(({sprite:f})=>{f.visible=!1});const u=[];if(c.forEach(f=>{if(f.isOrder){this.orderContainer.visible=!0,this.orderText.text=d.toString();const y=e.colorIndex??this.roomIndex,m=this.getIconColor(y);this.orderBackground.clear(),this.orderBackground.setFillStyle({color:m}),this.orderBackground.circle(i/2,s/2,i/2).fill();const x=this.resolveOrderTextColor(y);this.orderText.style.fill=x,this.orderText.position.set(i/2,s/2)}else{const y=this.propertyIcons.get(f.fieldName);if(y&&y.sprite){y.sprite.visible=!0;const m=this.getAssetAlias(f.fieldName,f.value);u.push(y.sprite.loadTextureAndSetSize(m,{width:i,height:s,sizeFixed:!1}))}}}),await Promise.all(u),this.isDestroyed||this.destroyed)return;let p=h;c.forEach((f,y)=>{const{element:m,isOrder:x}=f;!m||!m.position||(m.position.set(p,l),p+=i,y<c.length-1&&(x?p+=o.gapRight:p+=a))})}updateBackground(){if(this.isDestroyed||this.destroyed)return;const e=this.appService.roomConfig,{container:i,foldable:s}=e.property,{borderRadius:n,tailHeight:o,tailWidth:a,backgroundColor:h}=i,l=this.calculateContentWidth(),c=this.calculateContentHeight(),d=Math.min(n,l/2,c/2),u=d*.8,p=Math.max(l-u*2,a*.5),f=Math.min(a,l/2,p);if(this.background.clear(),this.background.setFillStyle({color:h}),s){const y=(l-f)/2,m=c+o;this.background.moveTo(d,0),this.background.lineTo(l-d,0),this.background.arcTo(l,0,l,d,d),this.background.lineTo(l,c-d),this.background.arcTo(l,c,l-d,c,d),this.background.lineTo(y+f,c),this.background.lineTo(y+f/2,m),this.background.lineTo(y,c),this.background.lineTo(d,c),this.background.arcTo(0,c,0,c-d,d),this.background.lineTo(0,d),this.background.arcTo(0,0,d,0,d),this.background.closePath()}else this.background.roundRect(0,0,l,c,d);this.background.fill()}calculateContentWidth(){const{iconWidth:e,container:i,cleanOrder:s,iconGap:n}=this.appService.roomConfig.property,{paddingHorizontal:o}=i,a=this.appService.getRoomData(this.roomId);if(!a)return o*2;const{elementsToShow:h}=this.getDisplayElements(a);let l=o;return h.forEach((c,d)=>{const{isOrder:u}=c;l+=e,d<h.length-1&&(u?l+=s.gapRight:l+=n)}),l+=o,l}calculateContentHeight(){const e=this.appService.roomConfig,{iconHeight:i,container:s}=e.property;return s.paddingVertical+i+s.paddingVertical}getTotalHeight(){const{foldable:e,container:i}=this.appService.roomConfig.property,{tailHeight:s}=i;return this.isFolded?s:this.calculateContentHeight()+(e?s:0)}getTotalWidth(){if(this.isFolded){const{tailWidth:i}=this.appService.roomConfig.property.container,s=this.calculateContentWidth();return Math.min(i,s/2)}return this.calculateContentWidth()}async setFolded(e){const{foldable:i}=this.appService.roomConfig.property;if(i)if(this.isFolded=e,e)this.background.visible=!1,this.orderContainer.visible=!1,this.propertyIcons.forEach(({sprite:s})=>{s.visible=!1}),this.foldedIndicator.visible=!0,this.updateFoldedIndicator();else{this.background.visible=!0,this.foldedIndicator.visible=!1,this.foldedIndicator.position.set(0,0),this.updateBackground();const s=this.appService.getRoomData(this.roomId);s&&await this.updateIcons(s)}}isFoldedState(){const{foldable:e}=this.appService.roomConfig.property;return e?this.isFolded:!1}updateFoldedIndicator(){const e=this.appService.roomConfig,{tailHeight:i,tailWidth:s,backgroundColor:n}=e.property.container,o=this.calculateContentWidth(),a=Math.min(s,o/2);this.foldedIndicator.clear(),this.foldedIndicator.setFillStyle({color:n}),this.foldedIndicator.poly([0,i,a,i,a/2,0]).fill(),this.foldedIndicator.position.set(0,0)}resolveOrderTextColor(e){const{property:i,colors:s}=this.appService.roomConfig,{enableRoomSelection:n}=this.appService.runtime;if(i.cleanOrder.color==="auto"){const o=n?s.active:s.normal||s.active;return o[e%o.length]}return i.cleanOrder.color}getIconColor(e){const{colors:i}=this.appService.roomConfig,{propertyTheme:s,propertyThemeInactive:n,propertyThemeNormal:o}=i,{enableRoomSelection:a,selectRoomIds:h}=this.appService.runtime;if(a)return!h.includes(this.roomId)&&n?n[e%n.length]:s[e%s.length];const l=o||s;return l[e%l.length]}refreshColor(){const e=this.appService.getRoomData(this.roomId),i=(e==null?void 0:e.colorIndex)??this.roomIndex,s=this.getIconColor(i);if(this.propertyIcons.forEach(({sprite:n})=>{n.tint=s}),this.orderBackground&&this.orderBackground.visible){const{property:n}=this.appService.roomConfig,o=n.iconWidth,a=n.iconHeight;this.orderBackground.clear(),this.orderBackground.setFillStyle({color:s}),this.orderBackground.circle(o/2,a/2,o/2).fill();const h=this.resolveOrderTextColor(i);this.orderText.style.fill=h}}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.propertyIcons.forEach(({sprite:e})=>{e.destroy()}),this.propertyIcons.clear(),super.destroy({children:!0}))}}class E0 extends L{constructor(e,i){super();g(this,"background");g(this,"checkmarkIcon");g(this,"bubble");g(this,"roomIndex");g(this,"roomId");this.appService=e;const s=this.appService.roomConfig;this.roomId=i.id,this.roomIndex=i.index,this.background=new H,this.bubble=new H;const{colors:{selectionIndicatorIcon:n}}=s;this.checkmarkIcon=new Xt(this.appService);const o=i.colorIndex??i.index;this.checkmarkIcon.tint=n[o%n.length],this.checkmarkIcon.anchor.set(0,0),this.addChild(this.background),this.addChild(this.bubble),this.addChild(this.checkmarkIcon)}async updateIndicator(e){const{roomSelectionMode:i,enableRoomSelection:s,selectRoomIds:n}=this.appService.runtimeSnapshot;if(!s||i!=="checkmark"){this.visible=!1;return}const o=n.includes(e.id);await this.showCheckmarkMode(o),this.updateBackground()}async showCheckmarkMode(e){const{selectionIndicator:i}=this.appService.roomConfig,{iconWidth:s,iconHeight:n}=i;if(e){this.visible=!0,this.checkmarkIcon.visible=!0,await this.checkmarkIcon.loadTextureAndSetSize("checkmark",{width:s,height:n,sizeFixed:!1});const o=i.containerWidth/2,a=i.containerHeight/2;this.checkmarkIcon.position.set(o-s/2,a-n/2)}else this.visible=!1}updateBackground(){const{selectionIndicator:e,colors:i}=this.appService.roomConfig,{containerWidth:s,containerHeight:n,strokeWidth:o,strokeColor:a,borderRadius:h,tailHeight:l,tailWidth:c}=e,d=this.appService.getRoomData(this.roomId),u=(d==null?void 0:d.colorIndex)??this.roomIndex,p=i.selectionIndicatorBackground[u%i.selectionIndicatorBackground.length],f=a==="auto"?p:a;if(this.checkmarkIcon.tint=i.selectionIndicatorIcon[u%i.selectionIndicatorIcon.length],this.background.clear(),this.bubble.clear(),this.background.setFillStyle({color:p}).roundRect(0,0,s,n,h).fill().setStrokeStyle({color:f,width:o,alignment:0}).stroke(),l>0&&c>0){const y=(s-c)/2;this.bubble.setFillStyle({color:f});const m=n+o;this.bubble.poly([y,m-1,y+c,m-1,y+c/2,m+l]).fill()}}getTotalHeight(){const{selectionIndicator:e}=this.appService.roomConfig,{containerHeight:i,tailHeight:s,strokeWidth:n}=e;return i+n+(s>0?s:0)}getTotalWidth(){const{selectionIndicator:e}=this.appService.roomConfig;return e.containerWidth}async refreshColor(){const e=this.appService.getRoomData(this.roomId);e&&await this.updateIndicator(e)}destroy(){var e;(e=this.checkmarkIcon)==null||e.destroy(),super.destroy({children:!0})}}class I0 extends L{constructor(e,i){super();g(this,"roomId");g(this,"roomName");g(this,"roomProperty",null);g(this,"roomSelectionIndicator",null);g(this,"clickHandler",null);g(this,"unsubscribeMapRotation",null);g(this,"targetElasticScale",1);g(this,"currentElasticScale",1);g(this,"isAnimatingScale",!1);g(this,"scaleAnimationBound",null);g(this,"updateScaleBound",null);this.appService=e,this.enableRenderGroup(),this.roomId=i.id,this.initializeElasticScale(e.currentScale),this.updateScaleBound=s=>this.updateScale(s),this.appService.emitter.on("antiScale",this.updateScaleBound),this.updateScale(this.appService.currentScale),i.centerPoint&&this.position.set(i.centerPoint.x,i.centerPoint.y),this.roomName=new k0(this.appService,i),this.roomName.visible=this.appService.runtimeSnapshot.showRoomName,this.applyAntiRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=U(this.appService.runtime,"mapRotation",s=>{this.applyAntiRotation(s)}),this.clickHandler=new vt(this,{onClick:()=>{var s,n;(n=(s=this.appService.events)==null?void 0:s.onClickRoomProperties)==null||n.call(s,i)}})}async initialize(e){await this.createRoomProperty(e),await this.createRoomSelectionIndicator(e),this.updateLayout()}applyAntiRotation(e){const i=-e*Math.PI/180;this.rotation=i}initializeElasticScale(e){const{enableElasticScale:i,elasticMinScale:s,elasticMaxScale:n}=this.appService.roomConfig;if(!i)return;const o=1,a=5;let h;e<=o?h=s:e>=a?h=n:h=1,this.targetElasticScale=h,this.currentElasticScale=h}updateScale(e){const{enableElasticScale:i,elasticMinScale:s,elasticMaxScale:n}=this.appService.roomConfig;if(!i){e!==0&&this.scale.set(1/e);return}if(e===0)return;const o=1,a=5;let h;e<=o?h=s:e>=a?h=n:h=1;const c=1/e*h;Math.abs(this.targetElasticScale-h)>.01?(this.targetElasticScale=h,this.startScaleAnimation()):this.scale.set(c)}startScaleAnimation(){this.scaleAnimationBound||(this.scaleAnimationBound=this.animateScale.bind(this)),this.isAnimatingScale||(this.isAnimatingScale=!0,this.appService.getApp().ticker.add(this.scaleAnimationBound))}animateScale(){this.currentElasticScale+=(this.targetElasticScale-this.currentElasticScale)*.3;const n=1/this.appService.currentScale*this.currentElasticScale;this.scale.set(n),Math.abs(this.currentElasticScale-this.targetElasticScale)<.001&&(this.currentElasticScale=this.targetElasticScale,this.isAnimatingScale=!1,this.scaleAnimationBound&&this.appService.getApp().ticker.remove(this.scaleAnimationBound))}shouldShowRoomProperty(){const{showRoomOrder:e,showRoomProperty:i,selectRoomIds:s,enableRoomSelection:n,roomSelectionMode:o}=this.appService.runtimeSnapshot,a=this.appService.getRoomData(this.roomId);if(!a||n&&o==="checkmark"&&s.includes(this.roomId))return!1;const h=e&&(a.order||0)>0;let l=!1;if(i){const{displayOrders:c}=this.appService.roomConfig.property;l=c.some(d=>!!(d==="suction"&&a.suction!=null||d==="cistern"&&a.cistern!=null||d==="cleanMode"&&a.cleanMode!=null||d==="cleanTimes"&&a.cleanTimes>0||a.customData&&d in a.customData&&typeof a.customData[d]=="number"&&a.customData[d]!=null))}return h||l}shouldShowRoomSelectionIndicator(){const{enableRoomSelection:e,roomSelectionMode:i}=this.appService.runtimeSnapshot;return e&&i==="checkmark"}async updateRoomPropertyVisibility(){if(!this.roomProperty)return;if(!this.shouldShowRoomProperty())this.roomProperty.visible=!1;else{this.roomProperty.visible=!0;const i=this.appService.runtimeSnapshot.roomPropertyFoldIds.includes(this.roomId);await this.roomProperty.setFolded(i);const s=this.appService.getRoomData(this.roomId);s&&await this.roomProperty.updateProperty(s)}this.updateLayout()}async updateRoomSelectionIndicatorVisibility(){if(!this.roomSelectionIndicator)return;if(this.shouldShowRoomSelectionIndicator()){const i=this.appService.getRoomData(this.roomId);i&&await this.roomSelectionIndicator.updateIndicator(i)}else this.roomSelectionIndicator.visible=!1;this.updateLayout()}async createRoomProperty(e){this.roomProperty&&(this.removeChild(this.roomProperty),this.roomProperty.destroy()),this.roomProperty=new R0(this.appService,e),await this.roomProperty.updateProperty(e),this.addChild(this.roomProperty),this.addChild(this.roomName),await this.updateRoomPropertyVisibility(),this.updateLayout()}async createRoomSelectionIndicator(e){this.roomSelectionIndicator&&(this.removeChild(this.roomSelectionIndicator),this.roomSelectionIndicator.destroy()),this.roomSelectionIndicator=new E0(this.appService,e),await this.updateRoomSelectionIndicatorVisibility(),this.addChild(this.roomSelectionIndicator)}updateLayout(){var l,c,d,u,p,f;if(this.destroyed)return;const{property:{offsetY:e,offsetX:i},selectionIndicator:{offsetY:s,offsetX:n}}=this.appService.roomConfig,o=((l=this.roomProperty)==null?void 0:l.visible)||!1,a=((c=this.roomName)==null?void 0:c.visible)||!1,h=((d=this.roomSelectionIndicator)==null?void 0:d.visible)||!1;if(o&&this.roomProperty){const y=this.roomProperty.getTotalHeight(),m=this.roomProperty.getTotalWidth();if(this.roomProperty.isFoldedState()){const S=-m/2+i,v=-y/2-e;this.roomProperty.position.set(S,v)}else a&&((u=this.roomName)!=null&&u.position)?(this.roomProperty.position.set(-m/2+i,-e-y),this.roomName.position.set(0,0)):this.roomProperty.position.set(-m/2+i,-y/2-e)}if(h&&this.roomSelectionIndicator){const y=this.roomSelectionIndicator.getTotalHeight(),m=this.roomSelectionIndicator.getTotalWidth();a&&((p=this.roomName)!=null&&p.position)?(this.roomSelectionIndicator.position.set(-m/2+n,-s-y),this.roomName.position.set(0,0)):this.roomSelectionIndicator.position.set(-m/2+n,-y/2-s)}a&&!o&&!h&&((f=this.roomName)!=null&&f.position)&&this.roomName.position.set(0,0)}updateName(e){this.roomName.updateName(e)}async updateRoomType(e){await this.roomName.updateRoomType(e),this.updateLayout()}updateRoomNameVisibility(e){this.roomName.visible=e,this.updateLayout()}updateRoomTypeVisibility(e){this.roomName.updateRoomTypeVisibility(e),this.updateLayout()}updatePosition(e){this.position.set(e.x,e.y)}async refreshColor(){this.roomName&&this.roomName.refreshColor(),this.roomProperty&&this.roomProperty.refreshColor(),this.roomSelectionIndicator&&await this.roomSelectionIndicator.refreshColor()}destroy(){var e,i,s,n;(e=this.clickHandler)==null||e.destroy(),this.clickHandler=null,this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.isAnimatingScale&&this.scaleAnimationBound&&(this.appService.getApp().ticker.remove(this.scaleAnimationBound),this.isAnimatingScale=!1),this.scaleAnimationBound=null,this.updateScaleBound&&(this.appService.emitter.off("antiScale",this.updateScaleBound),this.updateScaleBound=null),(i=this.roomProperty)==null||i.destroy(),this.roomProperty=null,(s=this.roomSelectionIndicator)==null||s.destroy(),this.roomSelectionIndicator=null,(n=this.roomName)==null||n.destroy(),super.destroy()}}class B0 extends L{constructor(e){super({isRenderGroup:!0});g(this,"floorTypeMap",new Map);g(this,"floorTypeMasks",new Map);g(this,"floorTypeContexts",new Map);g(this,"floorTypeToRooms",new Map);this.appService=e,this.appService.appContainer.addToLayer(Fr,this)}async createFloorTypes(e){if(!this.appService.runtimeSnapshot.showRoomFloorType)return;this.clearFloorTypes();const s=this.groupRoomsByFloorType(e),n=[];for(const[o,a]of s)n.push(this.createMergedFloorType(o,a));await Promise.all(n)}groupRoomsByFloorType(e){const i=new Map,s=this.appService;return e.forEach((n,o)=>{const a=s.getRoomData(o),h=(a==null?void 0:a.floorType)||0;h>=0&&(i.has(h)||i.set(h,[]),i.get(h).push({roomId:o,graphics:n}))}),i}async createMergedFloorType(e,i){const s=this.appService,{assets:n,opacity:o,scale:a}=s.roomConfig.floorType,h=e%n.length,l=`floorType${h}`;if(!n[h]){A.warn(`No texture asset configured for floorType: ${e}`);return}const c=await N.load(l);if(!c){A.warn(`Floor material texture not found: ${l}`);return}const d=i.map(({graphics:m})=>m.getLocalBounds()),u=my(d),p=new Ss({texture:c,width:u.width,height:u.height});p.x=u.x,p.y=u.y,p.alpha=o,p.tileScale.set(a);const{maskContainer:f,contexts:y}=this.createMergedMask(i.map(({graphics:m})=>m));p.mask=f,this.addChild(p),this.floorTypeMap.set(e,p),this.floorTypeMasks.set(e,f),this.floorTypeContexts.set(e,y),this.floorTypeToRooms.set(e,new Set(i.map(({roomId:m})=>m)))}createMergedMask(e){const i=new L,s=[];return e.forEach(n=>{const o=new H,a=n.context.clone();o.context=a,s.push(a),i.addChild(o)}),{maskContainer:i,contexts:s}}clearFloorTypes(){this.floorTypeMasks.forEach(e=>{try{e.destroy({children:!0})}catch(i){A.warn("Error destroying floor mask:",i)}}),this.floorTypeMasks.clear(),this.floorTypeContexts.forEach(e=>{try{e.forEach(i=>{try{i.destroy()}catch(s){A.warn("Error destroying cloned graphics context:",s)}})}catch(i){A.warn("Error destroying graphics contexts:",i)}}),this.floorTypeContexts.clear(),this.floorTypeMap.forEach(e=>{try{this.removeChild(e),e.destroy()}catch(i){A.warn("Error destroying floor material:",i)}}),this.floorTypeMap.clear(),this.floorTypeToRooms.clear()}destroy(){this.clearFloorTypes(),super.destroy()}}class D0{constructor(t){g(this,"unsubscribeFns",[]);g(this,"roomInfoContainer",new L);g(this,"roomInfoMap",new Map);g(this,"roomDisplayMap",new Map);g(this,"roomFloorType");this.appService=t,this.roomFloorType=new B0(t),t.appContainer.addToLayer(lc,this.roomInfoContainer);const e=U(t.runtime,"showRoomFloorType",d=>{A.log(`[runtime] showRoomFloorType: ${d}`),d?this.updateFloorTypes():this.roomFloorType.clearFloorTypes()}),i=U(t.runtime,"showRoomProperty",d=>{A.log(`[runtime] showRoomProperty: ${d}`),this.updateAllRoomPropertyVisibility()}),s=U(t.runtime,"showRoomOrder",d=>{A.log(`[runtime] showRoomOrder: ${d}`),this.updateAllRoomPropertyVisibility()}),n=U(t.runtime,"roomPropertyFoldIds",d=>{A.log(`[runtime] roomPropertyFoldIds: ${d}`),this.updateAllRoomPropertyVisibility()}),o=U(t.runtime,"showRoomName",d=>{A.log(`[runtime] showRoomName: ${d}`),this.updateAllRoomNameVisibility(d)}),a=U(t.runtime,"showRoomType",d=>{A.log(`[runtime] showRoomType: ${d}`),this.updateAllRoomTypeVisibility(d)}),h=U(t.runtime,"enableRoomSelection",d=>{A.log(`[runtime] enableRoomSelection: ${d}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility(),this.refreshAllRoomColors()}),l=U(t.runtime,"selectRoomIds",d=>{A.log(`[runtime] selectRoomIds: ${d}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility(),this.refreshAllRoomColors()}),c=U(t.runtime,"roomSelectionMode",d=>{A.log(`[runtime] roomSelectionMode: ${d}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility(),this.refreshAllRoomColors()});this.unsubscribeFns.push(e,i,s,n,o,a,h,l,c)}async drawRoomProperty(t){const e=this.appService;return this.roomDisplayMap.clear(),t.forEach((i,s)=>{const n=e.mapManager.getRoomById(i.id),o={...i,centerPoint:(n==null?void 0:n.centerPoint)||null,index:s,colorIndex:n==null?void 0:n.colorIndex};this.roomDisplayMap.set(i.id,o)}),await this.updateRoomInfoDisplay(),await this.updateFloorTypes(),!0}async updateRoomInfoDisplay(){if(this.roomDisplayMap.size===0){this.appService.mapManager.getAllRooms().length===0&&this.clearRoomInfos();return}const t=Array.from(this.roomDisplayMap.values()).filter(e=>e.centerPoint!==null);this.clearRoomInfos(),await Promise.all(t.map(e=>this.createRoomInfo(e)))}async createRoomInfo(t){const e=new I0(this.appService,t);this.roomInfoContainer.addChild(e),this.roomInfoMap.set(t.id,e),await e.initialize(t)}updateRoomName(t,e){const i=this.roomInfoMap.get(t);i&&i.updateName(e)}async updateRoomType(t,e){const i=this.roomDisplayMap.get(t);i&&(i.type=e);const s=this.roomInfoMap.get(t);s&&await s.updateRoomType(e)}updateRoomPosition(t,e){const i=this.roomDisplayMap.get(t);i&&(i.centerPoint=e);const s=this.roomInfoMap.get(t);s&&s.updatePosition(e)}clearRoomInfos(){if(this.roomInfoMap.size===0)return;const t=Array.from(this.roomInfoMap.values());this.roomInfoContainer.removeChildren(),t.forEach(e=>{try{e.destroy()}catch(i){A.warn(`[RoomManager] Error destroying RoomInfo for room ${e.roomId}:`,i)}}),this.roomInfoMap.clear()}getRoomPropertyById(t){return this.roomDisplayMap.get(t)}async refresh(){const t=this.appService;this.roomFloorType.clearFloorTypes(),this.roomDisplayMap.forEach((e,i)=>{const s=t.mapManager.getRoomById(i),n=(s==null?void 0:s.centerPoint)||null;if(e.centerPoint!==n){e.centerPoint=n;const a=this.roomInfoMap.get(i);a&&n&&a.updatePosition(n)}const o=s==null?void 0:s.colorIndex;if(e.colorIndex!==o&&o!==void 0){e.colorIndex=o;const a=this.roomInfoMap.get(i);a&&a.refreshColor()}}),await this.updateRoomInfoDisplay(),await this.updateFloorTypes()}async updateAllRoomPropertyVisibility(){this.roomInfoMap.size!==0&&await Promise.all(Array.from(this.roomInfoMap.values()).map(async t=>{try{await t.updateRoomPropertyVisibility()}catch(e){console.warn(`[RoomManager] Failed to update room property visibility for room ${t.roomId}`,e)}}))}updateAllRoomNameVisibility(t){this.roomInfoMap.size!==0&&this.roomInfoMap.forEach(e=>{e.updateRoomNameVisibility(t)})}updateAllRoomTypeVisibility(t){this.roomInfoMap.size!==0&&this.roomInfoMap.forEach(e=>{e.updateRoomTypeVisibility(t)})}updateAllRoomSelectionIndicatorVisibility(){this.roomInfoMap.size!==0&&this.roomInfoMap.forEach(t=>{t.updateRoomSelectionIndicatorVisibility()})}refreshAllRoomColors(){this.roomInfoMap.size!==0&&this.roomInfoMap.forEach(t=>{t.refreshColor()})}async updateFloorTypes(){const t=this.appService,e=t.mapManager.roomFill.getRoomGraphicsMap();e.size>0?(await this.roomFloorType.createFloorTypes(e),t.getApp().renderOnceNextFrame()):t.mapManager.getAllRooms().length===0&&this.roomFloorType.clearFloorTypes()}clear(){this.clearRoomInfos(),this.roomInfoContainer.removeChildren(),this.roomInfoMap.clear(),this.roomDisplayMap.clear(),this.roomFloorType.clearFloorTypes()}destroy(){this.clearRoomInfos(),this.roomInfoContainer.destroy(),this.roomFloorType.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}var Xa,Za;(Xa=navigator==null?void 0:navigator.userAgent)!=null&&Xa.includes("tuya-ark-ide")||((Za=navigator==null?void 0:navigator.userAgent)==null||Za.includes("miniProgram"));const F0=()=>{var i,s;if(!Ln.any)return!0;const r=navigator.userAgent.toLowerCase(),t=()=>{const n=navigator.deviceMemory;return n?n>=4:!0};let e=!1;if(/iphone|ipad|ipod/.test(r)){const n=(i=r.match(/os (\d+)_/))==null?void 0:i[1];e=(n?parseInt(n):0)>=12}else if(/android/.test(r)){const n=(s=r.match(/android (\d+)/))==null?void 0:s[1];e=(n?parseInt(n):0)>=10}return e&&t()};class z0 extends L{constructor(e,i,s){super();g(this,"graphics");g(this,"sprite",null);g(this,"viewportBounds");g(this,"lastConfig",null);g(this,"onImageLoaded");this.label="background",this.viewportBounds=i,this.onImageLoaded=s,this.graphics=new H,this.graphics.label="backgroundGraphics",this.addChild(this.graphics),this.render(e)}async render(e){if(this.lastConfig=e,this.clear(),e.backgroundImage){await this.renderImage(e.backgroundImage,e.backgroundAlpha);return}if(e.backgroundGradient){this.renderGradient(e.backgroundGradient);return}if(e.backgroundColor!==void 0){this.renderSolidColor(e.backgroundColor,e.backgroundAlpha);return}A.warn("[Background] No background configuration provided")}clear(){this.graphics.clear(),this.sprite&&(this.removeChild(this.sprite),this.sprite.destroy(),this.sprite=null)}renderSolidColor(e,i){this.graphics.clear(),this.graphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill({color:e,alpha:i}),A.debug("[Background] Rendered solid color background",{color:e,alpha:i})}renderGradient(e){const{width:i,height:s}=this.viewportBounds;if(this.graphics.clear(),e.type==="linear"){const n=e.x0??0,o=e.y0??0,a=e.x1??1,h=e.y1??1,l=new Ot({type:"linear",start:{x:n,y:o},end:{x:a,y:h},colorStops:e.colorStops});this.graphics.rect(0,0,i,s).fill(l),A.debug("[Background] Rendered linear gradient background",{x0:n,y0:o,x1:a,y1:h,colorStops:e.colorStops.length})}else if(e.type==="radial"){const n=e.cx??.5,o=e.cy??.5,a=e.r??.5,h=new Ot({type:"radial",center:{x:n,y:o},innerRadius:0,outerCenter:{x:n,y:o},outerRadius:a,colorStops:e.colorStops});this.graphics.rect(0,0,i,s).fill(h),A.debug("[Background] Rendered radial gradient background",{cx:n,cy:o,r:a,colorStops:e.colorStops.length})}}async renderImage(e,i){var s,n,o,a;try{const h=await N.load(e.src);if(!h){A.error("[Background] Failed to load image:",e.src),(s=this.lastConfig)!=null&&s.backgroundColor&&this.renderSolidColor(this.lastConfig.backgroundColor,i);return}this.sprite=new jt(h),this.sprite.label="backgroundSprite",this.sprite.alpha=i;const{width:l,height:c}=this.viewportBounds,d=e.fit||"cover",u=((n=e.position)==null?void 0:n.x)??.5,p=((o=e.position)==null?void 0:o.y)??.5,f=h.width,y=h.height,m=f/y,x=l/c;switch(d){case"fill":this.sprite.width=l,this.sprite.height=c,this.sprite.x=0,this.sprite.y=0;break;case"contain":m>x?(this.sprite.width=l,this.sprite.height=l/m):(this.sprite.height=c,this.sprite.width=c*m),this.sprite.x=(l-this.sprite.width)*u,this.sprite.y=(c-this.sprite.height)*p;break;case"cover":m>x?(this.sprite.height=c,this.sprite.width=c*m):(this.sprite.width=l,this.sprite.height=l/m),this.sprite.x=(l-this.sprite.width)*u,this.sprite.y=(c-this.sprite.height)*p;break;case"none":this.sprite.width=f,this.sprite.height=y,this.sprite.x=(l-f)*u,this.sprite.y=(c-y)*p;break}e.repeat&&A.warn("[Background] Repeat mode not yet implemented"),this.addChild(this.sprite),A.debug("[Background] Rendered image background",{src:e.src,fit:d,position:{x:u,y:p},spriteSize:{width:this.sprite.width,height:this.sprite.height}}),this.onImageLoaded&&this.onImageLoaded()}catch(h){A.error("[Background] Error loading background image:",h),(a=this.lastConfig)!=null&&a.backgroundColor&&this.renderSolidColor(this.lastConfig.backgroundColor,i)}}async update(e){await this.render(e)}destroy(){this.clear(),super.destroy()}}class L0 extends L{constructor(e){super();g(this,"carpetData");g(this,"carpetConfig");g(this,"controlsConfig");g(this,"carpetEvents");g(this,"appService");g(this,"controlFill");g(this,"editControlLayer");g(this,"clickHandler",null);g(this,"maskContainer",null);g(this,"maskGraphics",null);g(this,"texture",null);g(this,"textureMap",new Map);g(this,"tilingSprite",null);g(this,"initialZonePoints",[]);g(this,"unsubscribeFns",[]);g(this,"handleDragStart",()=>{this.isEditingEnabled()&&(this.carpetData.points&&this.carpetData.points.length>0?this.initialZonePoints=this.carpetData.points.map(e=>({...e})):this.initialZonePoints=[],this.appService.getApp().requestRender("zone-drag",!0))});g(this,"handleDragMove",e=>{if(!this.isEditingEnabled()||this.initialZonePoints.length===0||this.carpetData.shape==="custom")return;const i=this.parent.toLocal(e.global),s=this.controlFill.getDragStartPosition();if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.applyTranslation(n,o)});g(this,"handleDragEnd",()=>{var e,i;this.initialZonePoints=[],this.appService.getApp().stopRender("zone-drag"),(i=(e=this.carpetEvents).onUpdate)==null||i.call(e,this.getCarpetData())});g(this,"handleMoveStart",()=>{this.carpetData.points&&this.carpetData.points.length>0?this.initialZonePoints=this.carpetData.points.map(e=>({...e})):this.initialZonePoints=[],this.appService.getApp().requestRender("zone-move",!0)});g(this,"handleMove",e=>{var a,h;if(!this.isEditingEnabled()||this.initialZonePoints.length===0)return;const i=this.parent.toLocal(e.global),s=(h=(a=this.editControlLayer)==null?void 0:a.getMoveButton())==null?void 0:h.getDragStartPosition();if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.applyTranslation(n,o)});g(this,"handleMoveEnd",()=>{var e,i;this.initialZonePoints=[],this.appService.getApp().stopRender("zone-move"),(i=(e=this.carpetEvents).onUpdate)==null||i.call(e,this.getCarpetData())});g(this,"handleRotationStart",()=>{this.appService.getApp().requestRender("zone-rotate",!0)});g(this,"handleRotationMove",e=>{e&&(this.carpetData.points=e,this.drawCarpet())});g(this,"handleRotationEnd",()=>{var e,i;this.appService.getApp().stopRender("zone-rotate"),(i=(e=this.carpetEvents).onUpdate)==null||i.call(e,this.getCarpetData())});g(this,"handleScaleStart",()=>{this.appService.getApp().requestRender("zone-scale",!0)});g(this,"handleScaleMove",e=>{e&&(this.carpetData.points=e,this.drawCarpet())});g(this,"handleScaleMoveHorizontal",e=>{e&&(this.carpetData.points=e,this.drawCarpet())});g(this,"handleScaleMoveVertical",e=>{e&&(this.carpetData.points=e,this.drawCarpet())});g(this,"handleScaleEnd",()=>{var e,i;this.appService.getApp().stopRender("zone-scale"),(i=(e=this.carpetEvents).onUpdate)==null||i.call(e,this.getCarpetData())});g(this,"handleDelete",()=>{var e,i;(i=(e=this.carpetEvents).onRemove)==null||i.call(e,this.carpetData.id)});g(this,"handleClick",()=>{var e,i;this.isEditingEnabled()||(i=(e=this.carpetEvents)==null?void 0:e.onClick)==null||i.call(e,this.getCarpetData())});g(this,"handlePointsUpdate",e=>{this.carpetData.points=e,this.drawCarpet()});const{appService:i,carpetData:s,events:n={},textureMap:o}=e;this.appService=i,this.textureMap=o,this.carpetEvents=n,this.controlsConfig=this.getControlsConfig(),this.carpetConfig=this.controlsConfig.carpet,this.processCarpetData(s),this.initializeComponents(),this.createEditControlLayer(),this.setupClickHandler(),this.setupEnableRoomSelectionListener(),this.updateEditState(),this.loadTexture()}processCarpetData(e){if(e.points&&e.points.length>=2)if(e.shape==="custom")this.carpetData={...e,points:e.points};else{const s=Ia(e.points,this.appService.metersToPixels(this.carpetConfig.minSize)),n=bs(s);this.carpetData={...e,points:n}}else this.carpetData={...e,points:[],shape:e.shape||"rectangle"}}getControlsConfig(){const{controls:e}=this.appService.getConfig();return e}isEditingEnabled(){return this.appService.runtimeSnapshot.editingCarpetIds.includes(this.carpetData.id)}isSelected(){return this.appService.runtimeSnapshot.selectedCarpetIds.includes(this.carpetData.id)}shouldShowEditControl(){return this.isEditingEnabled()||this.isSelected()}initializeComponents(){this.maskContainer=this.createMaskContainer(),this.controlFill=this.createControlFill(),this.addChild(this.maskContainer),this.addChild(this.controlFill),this.drawCarpet()}createMaskContainer(){const e=new L;return this.maskGraphics=new H,this.updateMaskShape(),e.addChild(this.maskGraphics),e.mask=this.maskGraphics,e}createControlFill(){const e=this.isEditingEnabled();return new Lr(this.appService,{points:this.carpetData.points||[],fillColor:this.carpetConfig.fillColor,enableInteraction:e,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createEditControlLayer(){const e=this.isEditingEnabled(),i=this.carpetData.shape==="custom",s={...wn(this.carpetConfig,["outlineStrokeWidth","outlineDashed","outlineDashArray","outlineFillColor","outlineOffset","outlineStrokeColor"]),...wn(this.carpetConfig,["textColor","textPosition","textOffset"]),...wn(this.controlsConfig,["textFontSize","textFontFamily","textFontWeight"]),showRotateButton:!!e&&!i,showScaleButton:!!e&&!i,showDeleteButton:!!e,showMoveButton:!!e&&!i,showRadialScaleButton:!!e&&!i,iconWrapperFillColor:this.carpetConfig.iconWrapperFillColor,moveButtonOffset:this.controlsConfig.moveButtonOffset},n=i?this.calculateBoundingRectanglePoints():this.carpetData.points||[];this.editControlLayer=this.appService.editControlManager.registerEditControl(this.carpetData.id,{config:s,zonePoints:n,minSize:this.carpetConfig.minSize,events:{onRemove:this.handleDelete,onRotateStart:this.handleRotationStart,onRotateMove:this.handleRotationMove,onRotateEnd:this.handleRotationEnd,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleMoveHorizontal:this.handleScaleMoveHorizontal,onScaleMoveVertical:this.handleScaleMoveVertical,onScaleEnd:this.handleScaleEnd,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd,onClick:this.handleClick,onPointsUpdate:this.handlePointsUpdate}})}setupClickHandler(){this.interactiveChildren=!0,this.clickHandler=new vt(this,{onClick:()=>{var e,i;this.isEditingEnabled()||(i=(e=this.carpetEvents)==null?void 0:e.onClick)==null||i.call(e,this.getCarpetData())},stopPropagation:!1})}setupEnableRoomSelectionListener(){const e=U(this.appService.runtime,"enableRoomSelection",s=>{this.updateClickHandlerState(s)});this.unsubscribeFns.push(e);const i=this.appService.runtimeSnapshot.enableRoomSelection;this.updateClickHandlerState(i)}isRoomSelectionEnabled(){return this.appService.runtimeSnapshot.enableRoomSelection}updateClickHandlerState(e){if(e){if(this.eventMode="none",this.clickHandler){const i=this.clickHandler.getTarget();i.eventMode="none"}}else if(this.eventMode="static",this.clickHandler){const i=this.clickHandler.getTarget();i.eventMode="static"}}calculateBounds(){const{points:e}=this.carpetData;let i=1/0,s=1/0,n=-1/0,o=-1/0;if(e&&e.length>0)for(const a of e)i=Math.min(i,a.x),s=Math.min(s,a.y),n=Math.max(n,a.x),o=Math.max(o,a.y);return{minX:i,minY:s,maxX:n,maxY:o}}calculateBoundingRectanglePoints(){const{points:e}=this.carpetData;if(!e||e.length===0)return[];const{minX:i,minY:s,maxX:n,maxY:o}=vs(e);return[{x:i,y:s},{x:n,y:s},{x:n,y:o},{x:i,y:o}]}updateMaskShape(){if(!this.maskGraphics)return;this.maskGraphics.clear();const{points:e,shape:i}=this.carpetData;if(!(!e||!Array.isArray(e)||e.length<2)){if(i==="round"){if(e.length<4)return;const n=ee(e),[o,a,,h]=e,l=Q(o,a),c=Q(o,h),d=Math.atan2(a.y-o.y,a.x-o.x);this.maskGraphics.position.set(n.x,n.y),this.maskGraphics.rotation=d,this.maskGraphics.ellipse(0,0,l/2,c/2)}else{const n=e.flatMap(o=>[o.x,o.y]);this.maskGraphics.poly(n),this.maskGraphics.position.set(0,0),this.maskGraphics.rotation=0}this.maskGraphics.fill(16777215)}}async loadTexture(){const{opacity:e,scale:i}=this.appService.carpetConfig,{type:s}=this.carpetData;try{this.texture=this.textureMap.get(s)||this.textureMap.get(-1)||null,this.texture&&this.maskContainer&&(this.createTilingSprite(i,e),this.appService.getApp().renderOnce())}catch(n){console.warn("Failed to load carpet texture:",n)}}createTilingSprite(e,i){if(!this.texture||!this.maskContainer)return;const s=this.calculateBounds();this.tilingSprite=new Ss({texture:this.texture,width:s.maxX-s.minX+100,height:s.maxY-s.minY+100}),this.tilingSprite.position.set(s.minX-50,s.minY-50),this.tilingSprite.tileScale.set(e),this.tilingSprite.alpha=i,this.maskContainer.addChild(this.tilingSprite)}updateTilingSprite(){if(!this.tilingSprite)return;const e=this.calculateBounds();this.tilingSprite.position.set(e.minX-50,e.minY-50),this.tilingSprite.width=e.maxX-e.minX+100,this.tilingSprite.height=e.maxY-e.minY+100}applyTranslation(e,i){this.carpetData.points=this.initialZonePoints.map(s=>({x:s.x+e,y:s.y+i})),this.drawCarpet()}drawCarpet(){const{points:e}=this.carpetData;if(!(!e||e.length<2)&&(this.updateMaskShape(),this.updateTilingSprite(),this.controlFill.updatePoints(e),this.editControlLayer)){const n=this.carpetData.shape==="custom"?this.calculateBoundingRectanglePoints():e;this.editControlLayer.updatePoints(n)}}updateEditState(){const e=this.isEditingEnabled(),i=this.isSelected(),s=this.shouldShowEditControl();if(this.controlFill.setInteractionEnabled(e),this.editControlLayer)if(i&&!e)this.appService.editControlManager.updateEditState(this.carpetData.id,{showRotateButton:!1,showScaleButton:!1,showDeleteButton:!1,showMoveButton:!1,showBorder:!0,showSizeText:!1,borderStyle:this.carpetConfig.normal});else if(e){const n=this.carpetData.shape==="custom";this.appService.editControlManager.updateEditState(this.carpetData.id,{showRotateButton:!n,showScaleButton:!n,showDeleteButton:!0,showMoveButton:!n,showBorder:!0,showSizeText:!0,borderStyle:this.carpetConfig.editing,showRadialScaleButton:!n})}else this.appService.editControlManager.updateEditState(this.carpetData.id,{showRotateButton:!1,showScaleButton:!1,showDeleteButton:!1,showMoveButton:!1,showBorder:!1,showSizeText:!1});this.zIndex=s?1e3:0}updateCarpetData(e){if(e.points&&e.points.length>=2)if(e.shape==="custom")this.carpetData={...e,points:e.points};else{const s=Ia(e.points,this.appService.metersToPixels(this.carpetConfig.minSize)),n=bs(s);this.carpetData={...e,points:n}}else this.carpetData={...e,points:e.points||[]};this.drawCarpet(),this.updateEditState()}getCarpetData(){return{...this.carpetData}}refreshDisplay(){this.drawCarpet()}destroy(){var e,i,s,n,o;this.appService.editControlManager.unregisterEditControl(this.carpetData.id),this.unsubscribeFns.forEach(a=>a()),this.unsubscribeFns=[],(e=this.tilingSprite)==null||e.destroy(),(i=this.maskGraphics)==null||i.destroy(),(s=this.maskContainer)==null||s.destroy(),this.tilingSprite=null,this.maskGraphics=null,this.maskContainer=null,this.texture=null,(n=this.controlFill)==null||n.destroy(),(o=this.clickHandler)==null||o.destroy(),super.destroy()}}class O0{constructor(t){g(this,"customCarpetMap",new Map);g(this,"unsubscribeFns",[]);g(this,"textureMap",new Map);g(this,"texturesLoaded",!1);g(this,"texturesLoadingPromise",null);this.appService=t;const e=U(t.runtime,"editingCarpetIds",s=>{A.log(`[runtime] editingCarpetIds: ${s}`),this.updateCarpetsEditState()}),i=U(t.runtime,"selectedCarpetIds",s=>{A.log(`[runtime] selectedCarpetIds: ${s}`),this.updateCarpetsEditState()});this.unsubscribeFns.push(e,i)}async loadTextures(){if(!this.texturesLoaded){if(this.texturesLoadingPromise)return this.texturesLoadingPromise;this.texturesLoadingPromise=this._loadTextures(),await this.texturesLoadingPromise,this.texturesLoaded=!0,this.texturesLoadingPromise=null}}async _loadTextures(){const t=this.appService,{material:e,src:i}=t.carpetConfig;if(e)for(const s of e){const n=await N.load(s.src);this.textureMap.set(s.type,n)}if(i){const s=await N.load(i);this.textureMap.set(-1,s)}}updatePositionByOrigin(t,e){const s=this.appService.appContainer.getLayer(us);s&&s.position.set(t,e)}async drawCustomCarpets(t){if(await this.loadTextures(),!t||t.length===0){this.clearAllCustomCarpets();return}const e=new Set(this.customCarpetMap.keys()),i=new Set(t.map(s=>s.id));for(const s of e)i.has(s)||this.removeCustomCarpet(s);t.forEach(s=>{const n=this.customCarpetMap.get(s.id.toString());n?this.isCarpetDataEqual(n.getCarpetData(),s)||n.updateCarpetData(s):this.addNewCustomCarpet(s)})}getCustomCarpets(){const t=[];return this.customCarpetMap.forEach(e=>{t.push(e.getCarpetData())}),t}getCustomCarpetById(t){return this.customCarpetMap.get(t)}clearAllCustomCarpets(){this.customCarpetMap.forEach((t,e)=>{var s;const i=this.customCarpetMap.get(e);i&&((s=i.parent)==null||s.removeChild(i),i.destroy())}),this.customCarpetMap.clear()}addNewCustomCarpet(t){const e=this.appService,i=new L0({appService:e,carpetData:t,textureMap:this.textureMap,events:{onRemove:s=>{var n,o;(o=(n=e.events)==null?void 0:n.onDeleteCustomCarpet)==null||o.call(n,{id:s})},onUpdate:s=>{var n,o;(o=(n=e.events)==null?void 0:n.onUpdateCustomCarpet)==null||o.call(n,s)},onClick:s=>{var n,o;(o=(n=e.events)==null?void 0:n.onClickCarpet)==null||o.call(n,{id:s.id})}}});this.customCarpetMap.set(t.id.toString(),i),e.appContainer.addToLayer(us,i)}removeCustomCarpet(t){const e=this.appService,i=this.customCarpetMap.get(t);i&&(e.appContainer.removeFromLayer(us,i),i.destroy(),this.customCarpetMap.delete(t))}updateCarpetsEditState(){this.customCarpetMap.forEach(t=>{t.updateEditState()})}isCarpetDataEqual(t,e){if(t.id!==e.id||t.type!==e.type||t.shape!==e.shape)return!1;const i=t.points||[],s=e.points||[];if(i.length!==s.length)return!1;for(let n=0;n<i.length;n++){const o=i[n],a=s[n];if(Math.abs(o.x-a.x)>.1||Math.abs(o.y-a.y)>.1)return!1}return!0}refreshDisplay(){this.customCarpetMap.forEach(t=>{t.refreshDisplay()})}destroy(){this.clearAllCustomCarpets(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}class G0 extends Wi{constructor(t,e){super(t,e),this.cursor="pointer"}setupEvents(){this.on("pointertap",()=>{var t,e;(e=(t=this.options).onClick)==null||e.call(t)})}destroy(){this.removeAllListeners(),super.destroy()}}const Ft={REMOVE:0,ROTATE:1,SCALE:2,MOVE:3,FIXED:0};class W0 extends L{constructor(e){super();g(this,"appService");g(this,"data");g(this,"furnitureEvents");g(this,"textureAlias");g(this,"sprite");g(this,"controlButtons");g(this,"outlineBorder");g(this,"moveLine");g(this,"deleteButton",null);g(this,"rotateButton",null);g(this,"scaleButton",null);g(this,"moveButton",null);g(this,"sizeText",null);g(this,"isEditing",!1);g(this,"dragStartPosition",null);g(this,"initialPoints",[]);g(this,"clickHandler",null);g(this,"isDragging",!1);g(this,"initialScalePoints",[]);g(this,"initialButtonPosition",null);g(this,"rotationCount",0);g(this,"onDragStart",e=>{var s,n;if(!this.isEditing||!this.parent||e.target!==this)return;(n=(s=this.appService.events)==null?void 0:s.onGestureStart)==null||n.call(s),this.appService.getApp().requestRender("furniture-drag",!0);const i=this.parent.toLocal(e.global);this.dragStartPosition={x:i.x,y:i.y},this.initialPoints=this.data.points.map(o=>({...o})),this.isDragging=!1});g(this,"onDragMove",e=>{if(!this.isEditing||!this.dragStartPosition||!this.parent)return;const i=this.parent.toLocal(e.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y;!this.isDragging&&Math.abs(s)+Math.abs(n)<3||(this.isDragging=!0,this.data.points=this.initialPoints.map(o=>({x:o.x+s,y:o.y+n})),this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText())});g(this,"onDragEnd",()=>{var e,i,s,n;!this.isEditing||!this.dragStartPosition||(this.isDragging&&((i=(e=this.furnitureEvents).onUpdate)==null||i.call(e,this.getData())),this.dragStartPosition=null,this.initialPoints=[],this.isDragging=!1,this.appService.getApp().stopRender("furniture-drag"),(n=(s=this.appService.events)==null?void 0:s.onGestureEnd)==null||n.call(s))});g(this,"handleScaleStart",()=>{this.initialScalePoints=this.data.points.map(i=>({...i}));const e=this.getVisualIndex(Ft.SCALE);e>=0&&e<this.data.points.length&&(this.initialButtonPosition={...this.data.points[e]}),this.appService.getApp().requestRender("furniture-scale",!0)});g(this,"handleScaleMove",({deltaX:e,deltaY:i})=>{if(this.initialScalePoints.length===0||!this.initialButtonPosition)return;const s={x:this.initialButtonPosition.x+e,y:this.initialButtonPosition.y+i};this.applyEdgeBasedScale(s)});g(this,"handleScaleEnd",()=>{var e,i;this.initialScalePoints=[],this.initialButtonPosition=null,this.appService.getApp().stopRender("furniture-scale"),(i=(e=this.furnitureEvents).onUpdate)==null||i.call(e,this.getData())});g(this,"handleMoveStart",()=>{this.initialPoints=this.data.points.map(e=>({...e})),this.appService.getApp().requestRender("furniture-move",!0)});g(this,"handleMoveMove",e=>{var a;if(!this.isEditing||this.initialPoints.length===0||!this.parent)return;const i=this.parent.toLocal(e.global),s=(a=this.moveButton)==null?void 0:a.getDragStartPosition();if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.data.points=this.initialPoints.map(h=>({x:h.x+n,y:h.y+o})),this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText()});g(this,"handleMoveEnd",()=>{var e,i;this.initialPoints=[],this.appService.getApp().stopRender("furniture-move"),(i=(e=this.furnitureEvents).onUpdate)==null||i.call(e,this.getData())});const{appService:i,data:s,textureAlias:n,events:o={}}=e;this.appService=i,this.data={...s,points:s.points.map(a=>({...a}))},this.textureAlias=n,this.furnitureEvents=o,this.createSprite(),this.updateSpriteTransform(),this.createEditControls(),this.eventMode="static",this.cursor="pointer",this.setupInteraction()}get config(){return this.appService.furnitureConfig}getVisualIndex(e){return(e+4-this.rotationCount)%4}getVisualPoints(){const e=this.data.points;return[e[this.getVisualIndex(0)],e[this.getVisualIndex(1)],e[this.getVisualIndex(2)],e[this.getVisualIndex(3)]]}createSprite(){const e=N.get(this.textureAlias);this.sprite=new jt(e),this.sprite.anchor.set(.5),this.sprite.alpha=this.config.opacity,this.sprite.eventMode="none",this.addChild(this.sprite)}updateSpriteTransform(){const e=this.data.points;if(e.length<4)return;const i=ee(e),s=e[1].x-e[0].x,n=e[1].y-e[0].y,o=Math.atan2(n,s),a=Q(e[0],e[1]),h=Q(e[1],e[2]);this.sprite.position.set(i.x,i.y),this.sprite.rotation=o,this.sprite.width=a,this.sprite.height=h}createEditControls(){const e=this.calculateOutlinePoints();this.outlineBorder=new Nt(this.appService,{points:e,closePath:!0,style:{color:this.config.outlineStrokeColor,width:this.config.outlineStrokeWidth,isDashed:this.config.outlineDashed,dashArray:this.config.outlineDashArray,fillColor:this.config.outlineFillColor}}),this.outlineBorder.visible=!1,this.addChild(this.outlineBorder);const i=this.calculateMoveLinePoints(e);this.moveLine=new Nt(this.appService,{points:i,closePath:!1,style:{color:this.config.outlineStrokeColor,width:this.config.outlineStrokeWidth,isDashed:this.config.outlineDashed,dashArray:this.config.outlineDashArray}}),this.moveLine.visible=!1,this.addChild(this.moveLine),this.controlButtons=new L,this.controlButtons.visible=!1,this.addChild(this.controlButtons),this.createControlButtons()}createControlButtons(){const e=this.calculateOutlinePoints();if(e.length<4)return;const{iconWrapperFillColor:i}=this.config,s=this.getVisualIndex(Ft.REMOVE),n=this.getVisualIndex(Ft.ROTATE),o=this.getVisualIndex(Ft.SCALE);this.deleteButton=new Ds(this.appService,{iconAlias:"deleteIcon",backgroundColor:i,onClick:()=>{var h,l;return(l=(h=this.furnitureEvents).onRemove)==null?void 0:l.call(h,this.data.id)}}),this.deleteButton.position.set(e[s].x,e[s].y),this.rotateButton=new G0(this.appService,{iconAlias:"rotateIcon",backgroundColor:i,onClick:()=>this.handleTapRotate()}),this.rotateButton.position.set(e[n].x,e[n].y),this.scaleButton=new Ze(this.appService,{iconAlias:"scaleIcon",backgroundColor:i,getTargetPoints:()=>this.data.points,getButtonIndex:()=>this.getVisualIndex(Ft.SCALE),onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(e[o].x,e[o].y);const a=this.calculateMoveButtonPosition(e);this.moveButton=new Fs(this.appService,{iconAlias:"moveIcon",backgroundColor:i,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMoveMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(a.x,a.y),this.controlButtons.addChild(this.deleteButton),this.controlButtons.addChild(this.rotateButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton),this.config.showSizeText&&(this.sizeText=this.createSizeText(),this.controlButtons.addChild(this.sizeText))}calculateOutlinePoints(){const{points:e}=this.data;if(e.length<4)return e;const i=this.appService.getApp().toFixedSize(this.config.outlineOffset);return Ir(e,i)}calculateMoveButtonPosition(e){const i=e??this.calculateOutlinePoints();if(i.length<4)return{x:0,y:0};const{controls:s}=this.appService.getConfig(),n=this.getVisualIndex(Ft.MOVE),o=this.getVisualIndex(2),a=this.getVisualIndex(0),h=this.appService.getApp().toFixedSize(s.moveButtonOffset);return Is(i[n],i[o],i[a],h)}calculateMoveLinePoints(e,i){if(e.length<4)return[];const s=this.getVisualIndex(Ft.MOVE),n=i??this.calculateMoveButtonPosition(e);return[e[s],n]}createSizeText(){const e=this.calculateSizeTextContent(),i=this.appService.controlsConfig,s=new Ui(this.appService,{text:e,style:{fontSize:i.textFontSize,fontFamily:i.textFontFamily,fontWeight:i.textFontWeight,fill:this.config.textColor,align:"center"}});s.anchor.set(.5);const n=this.calculateSizeTextPosition();s.position.set(n.x,n.y);const o=this.calculateSizeTextRotation();return s.rotation=o,s.eventMode="none",s}calculateSizeTextContent(){const{points:e}=this.data;if(e.length<4)return"0m*0m";const[i,s,,n]=this.getVisualPoints(),o=Q(i,s),a=Q(i,n),h=this.appService.pixelsToMeters(o),l=this.appService.pixelsToMeters(a),c=this.appService.metersToDisplayUnit(h),d=this.appService.metersToDisplayUnit(l),u=this.appService.runtimeSnapshot.unitLabel;return`${c.toFixed(1)}${u}*${d.toFixed(1)}${u}`}calculateSizeTextPosition(){const{points:e}=this.data;if(e.length<4)return{x:0,y:0};const[i,s,n,o]=this.getVisualPoints(),{textPosition:a,textOffset:h}=this.config,l=this.appService.getApp().toFixedSize(h);let c,d;switch(a){case"top":{c={x:(i.x+s.x)/2,y:(i.y+s.y)/2};const u=pt(q(s,i)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}case"right":{c={x:(s.x+n.x)/2,y:(s.y+n.y)/2};const u=pt(q(s,n)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}case"bottom":{c={x:(o.x+n.x)/2,y:(o.y+n.y)/2};const u=pt(q(o,n)),p={x:-u.y,y:u.x};d={x:p.x*l,y:p.y*l};break}case"left":{c={x:(i.x+o.x)/2,y:(i.y+o.y)/2};const u=pt(q(o,i)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}default:c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},d={x:0,y:l};break}return{x:c.x+d.x,y:c.y+d.y}}calculateSizeTextRotation(){const{points:e}=this.data;if(e.length<4)return 0;const[i,s,n,o]=this.getVisualPoints(),{textPosition:a}=this.config;let h,l;switch(a){case"top":h=i,l=s;break;case"right":h=s,l=n;break;case"bottom":h=n,l=o;break;case"left":h=o,l=i;break;default:h=i,l=s;break}const c=this.appService.appContainer.getMapRotationRadians();return Xe(h,l,c)}setupInteraction(){this.clickHandler=new vt(this,{onClick:()=>{var e,i;this.isDragging||(i=(e=this.furnitureEvents).onClick)==null||i.call(e,this.getData())}}),this.on("pointerdown",this.onDragStart,this),this.on("pointermove",this.onDragMove,this),this.on("pointerup",this.onDragEnd,this),this.on("pointerupoutside",this.onDragEnd,this)}handleTapRotate(){var n,o;const e=this.config.rotateDirection!=="ccw",i=e?Math.PI/2:-Math.PI/2,s=ee(this.data.points);this.data.points=Er(this.data.points,s,i),this.rotationCount=(this.rotationCount+(e?1:3))%4,this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText(),(o=(n=this.furnitureEvents).onUpdate)==null||o.call(n,this.getData())}applyEdgeBasedScale(e){if(this.initialScalePoints.length<4)return;const i=this.getVisualIndex(Ft.FIXED),s=this.getVisualIndex(1),n=this.getVisualIndex(3),{x:o,y:a}=this.initialScalePoints[i],h=this.initialScalePoints[s],l=this.initialScalePoints[n],c={x:o,y:a},d=q(c,h),u=q(c,l),p=q(c,e),f=ie(d),y=ie(u);if(f===0||y===0)return;const{minScaleRatio:m,maxScaleRatio:x}=this.config;let S=he(p,d,f,0),v=he(p,u,y,0);S=Math.max(m,Math.min(x,S)),v=Math.max(m,Math.min(x,v));const b=[c,{x:o+d.x*S,y:a+d.y*S},{x:o+d.x*S+u.x*v,y:a+d.y*S+u.y*v},{x:o+u.x*v,y:a+u.y*v}],P=new Array(4);for(let w=0;w<4;w++)P[this.getVisualIndex(w)]=b[w];this.data.points=P,this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText(!0)}updateEditControls(){var h;const e=this.calculateOutlinePoints();if(e.length<4)return;this.outlineBorder.updatePoints(e);const i=this.calculateMoveButtonPosition(e),s=this.calculateMoveLinePoints(e,i);if(this.moveLine.updatePoints(s),!this.deleteButton||!this.rotateButton||!this.scaleButton)return;const n=this.getVisualIndex(Ft.REMOVE),o=this.getVisualIndex(Ft.ROTATE),a=this.getVisualIndex(Ft.SCALE);this.deleteButton.position.set(e[n].x,e[n].y),this.rotateButton.position.set(e[o].x,e[o].y),this.scaleButton.position.set(e[a].x,e[a].y),(h=this.moveButton)==null||h.position.set(i.x,i.y)}updateSizeText(e=!1){if(!this.sizeText)return;if(e){const n=this.calculateSizeTextContent();this.sizeText.updateText(n)}const i=this.calculateSizeTextPosition();this.sizeText.position.set(i.x,i.y);const s=this.calculateSizeTextRotation();this.sizeText.rotation=s}getData(){return{id:this.data.id,furnitureType:this.data.furnitureType,points:this.data.points.map(e=>({...e}))}}updateData(e){this.data={...e,points:e.points.map(i=>({...i}))},this.rotationCount=0,this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText(!0)}updateEditState(e){this.isEditing!==e&&(this.isEditing=e,this.outlineBorder.visible=e,this.moveLine.visible=e,this.controlButtons.visible=e)}destroy(){var e;(e=this.clickHandler)==null||e.destroy(),this.clickHandler=null,super.destroy({children:!0})}}class U0{constructor(t){g(this,"furnitureMap",new Map);g(this,"unsubscribeFns",[]);this.appService=t;const e=U(t.runtime,"editingFurnitureIds",i=>{A.log(`[runtime] editingFurnitureIds: ${i}`),this.updateEditState()});this.unsubscribeFns.push(e)}updatePositionByOrigin(t,e){const i=this.appService.appContainer.getLayer(ds);i&&i.position.set(t,e)}async drawFurnitures(t){if(!t||t.length===0){this.clearAll();return}const e=new Set(this.furnitureMap.keys()),i=new Set(t.map(n=>n.id));for(const n of e)i.has(n)||this.removeFurniture(n);const s=[];for(const n of t){const o=this.furnitureMap.get(n.id);o?this.isDataEqual(o.getData(),n)||o.updateData(n):s.push(this.addFurniture(n))}await Promise.all(s)}async addFurniture(t){const e=this.appService;if(!e.furnitureConfig.assets.find(h=>h.type===t.furnitureType)){A.warn(`[FurnitureManager] No asset found for furnitureType: ${t.furnitureType}`);return}const n=`furniture_${t.furnitureType}`;await N.load(n);const o=new W0({appService:e,data:t,textureAlias:n,events:{onRemove:h=>{var l,c;(c=(l=e.events)==null?void 0:l.onRemoveFurniture)==null||c.call(l,h)},onUpdate:h=>{var l,c;(c=(l=e.events)==null?void 0:l.onUpdateFurniture)==null||c.call(l,h)},onClick:h=>{var l,c;(c=(l=e.events)==null?void 0:l.onClickFurniture)==null||c.call(l,h)}}});this.furnitureMap.set(t.id,o),e.appContainer.addToLayer(ds,o),e.runtime.editingFurnitureIds.includes(t.id)&&o.updateEditState(!0)}removeFurniture(t){const e=this.furnitureMap.get(t);e&&(this.appService.appContainer.removeFromLayer(ds,e),e.destroy(),this.furnitureMap.delete(t))}clearAll(){var t;for(const[,e]of this.furnitureMap)(t=e.parent)==null||t.removeChild(e),e.destroy();this.furnitureMap.clear()}updateEditState(){const t=this.appService.runtime.editingFurnitureIds;this.furnitureMap.forEach((e,i)=>{e.updateEditState(t.includes(i))})}isDataEqual(t,e){if(t.id!==e.id||t.furnitureType!==e.furnitureType||t.points.length!==e.points.length)return!1;for(let i=0;i<t.points.length;i++)if(Math.abs(t.points[i].x-e.points[i].x)>.1||Math.abs(t.points[i].y-e.points[i].y)>.1)return!1;return!0}destroy(){this.clearAll(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}const ft={REMOVE:0,ROTATE:1,SCALE:2,MOVE:3};class H0 extends L{constructor(e,i){super();g(this,"config");g(this,"events");g(this,"zonePoints",[]);g(this,"outlinePoints");g(this,"minSize",.1);g(this,"initialZonePoints",[]);g(this,"scaleCache",null);g(this,"rotationCache",null);g(this,"outlineBorder");g(this,"moveLine");g(this,"sizeText");g(this,"controlButtons");g(this,"deleteButton",null);g(this,"rotateButton",null);g(this,"scaleButton",null);g(this,"moveButton",null);g(this,"horizontalScaleButton",null);g(this,"verticalScaleButton",null);g(this,"horizontalScaleInitialPosition",null);g(this,"verticalScaleInitialPosition",null);g(this,"clickHandler",null);g(this,"throttledUpdateOutline");this.appService=e,this.zonePoints=i.zonePoints,this.config={...i.config,showScaleButton:i.config.showScaleButton!==void 0?i.config.showScaleButton:!0,showRadialScaleButton:i.config.showRadialScaleButton!==void 0?i.config.showRadialScaleButton:!0,showDeleteButton:i.config.showDeleteButton!==void 0?i.config.showDeleteButton:!0,showMoveButton:i.config.showMoveButton!==void 0?i.config.showMoveButton:!0,showRotateButton:i.config.showRotateButton!==void 0?i.config.showRotateButton:!0},this.events=i.events||{},this.minSize=i.minSize??.1,this.throttledUpdateOutline=At(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.registerScaleListener()}initializeComponents(){this.outlinePoints=this.calculateOutlinePoints(),this.outlineBorder=this.createOutlineBorder(),this.addChild(this.outlineBorder),this.moveLine=this.createMoveLine(),this.addChild(this.moveLine),this.moveLine.visible=this.config.showMoveButton||!1,this.sizeText=this.createSizeText(),this.addChild(this.sizeText),this.controlButtons=new L,this.addChild(this.controlButtons),this.createControlButtons(),this.setupClickHandler()}createOutlineBorder(){const{outlineStrokeColor:e,outlineStrokeWidth:i,outlineDashed:s,outlineDashArray:n,outlineFillColor:o}=this.config;return new Nt(this.appService,{points:this.outlinePoints,closePath:!0,style:{color:e,width:i,isDashed:s,dashArray:n,fillColor:o}})}createMoveLine(){const{outlineStrokeColor:e,outlineStrokeWidth:i,outlineDashed:s,outlineDashArray:n}=this.config,o=this.calculateMoveLinePoints();return new Nt(this.appService,{points:o,closePath:!1,style:{color:e,width:i,isDashed:s,dashArray:n}})}createSizeText(){const e=this.calculateSizeText(),i=new Ui(this.appService,{text:e,style:{fontSize:this.config.textFontSize,fontFamily:this.config.textFontFamily,fontWeight:this.config.textFontWeight,fill:this.config.textColor,align:"center"}});i.anchor.set(.5);const s=this.calculateSizeTextPosition();i.position.set(s.x,s.y);const n=this.calculateSizeTextRotation();return i.rotation=n,i.eventMode="none",i}createDeleteButton(){const e=new Ds(this.appService,{iconAlias:"deleteIcon",backgroundColor:"red",onClick:()=>{var i,s;return(s=(i=this.events).onRemove)==null?void 0:s.call(i)}});return e.position.set(this.outlinePoints[ft.REMOVE].x,this.outlinePoints[ft.REMOVE].y),e}createRotateButton(){const e=new fc(this.appService,{iconAlias:"rotateIcon",backgroundColor:this.config.iconWrapperFillColor,getTargetPoints:()=>this.zonePoints,onRotationStart:i=>{var s,n;this.initializeRotationCache(i),(n=(s=this.events).onRotateStart)==null||n.call(s,i)},onClick:()=>{var n,o;const i=Math.PI/2,s=this.onClickRotateButton(i);(o=(n=this.events).onRotateMove)==null||o.call(n,s??void 0)},onRotationEnd:()=>{var i,s;this.resetRotationState(),(s=(i=this.events).onRotateEnd)==null||s.call(i)}});return e.position.set(this.outlinePoints[ft.ROTATE].x,this.outlinePoints[ft.ROTATE].y),e}onClickRotateButton(e){const i=this.handleInternalRotationMove(e)??[];return this.resetRotationState(),i}createScaleButton(){const e=new Ze(this.appService,{iconAlias:"scaleIcon",backgroundColor:this.config.iconWrapperFillColor,initialButtonPosition:this.outlinePoints[ft.SCALE],onScaleStart:()=>{var i,s;this.initializeScaleCache(),(s=(i=this.events).onScaleStart)==null||s.call(i)},onScaleMove:({deltaX:i,deltaY:s})=>{var o,a;const n=this.handleInternalScaleMove(i,s);(a=(o=this.events).onScaleMove)==null||a.call(o,n??void 0)},onScaleEnd:()=>{var i,s;this.resetScaleState(),this.initialZonePoints=[],(s=(i=this.events).onScaleEnd)==null||s.call(i)}});return e.position.set(this.outlinePoints[ft.SCALE].x,this.outlinePoints[ft.SCALE].y),e}createHorizontalScaleButton(){const[,e,i]=this.outlinePoints,s=this.getEdgeCenter(e,i),n=new Ze(this.appService,{iconAlias:"horizontalScaleIcon",backgroundColor:this.config.iconWrapperFillColor,config:{iconWrapperWidth:18,iconWrapperHeight:18,iconWrapperBorderRadius:18,iconWidth:10,iconHeight:8},initialButtonPosition:s,onScaleStart:()=>{var h,l;const[,o,a]=this.zonePoints;this.horizontalScaleInitialPosition=this.getEdgeCenter(o,a),this.initializeScaleCache(),(l=(h=this.events).onScaleStart)==null||l.call(h)},onScaleMove:({deltaX:o,deltaY:a})=>{var l,c;const h=this.handleInternalHorizontalScaleMove(o,a);(c=(l=this.events).onScaleMoveHorizontal)==null||c.call(l,h??void 0)},onScaleEnd:()=>{var o,a;this.resetScaleState(),this.initialZonePoints=[],this.horizontalScaleInitialPosition=null,(a=(o=this.events).onScaleEnd)==null||a.call(o)}});return n.position.set(s.x,s.y),n}createVerticalScaleButton(){const[,,e,i]=this.outlinePoints,s=this.getEdgeCenter(e,i),n=new Ze(this.appService,{iconAlias:"verticalScaleIcon",backgroundColor:this.config.iconWrapperFillColor,config:{iconWrapperWidth:18,iconWrapperHeight:18,iconWrapperBorderRadius:18,iconWidth:8,iconHeight:10},initialButtonPosition:s,onScaleStart:()=>{var h,l;const[,,o,a]=this.zonePoints;this.verticalScaleInitialPosition=this.getEdgeCenter(o,a),this.initializeScaleCache(),(l=(h=this.events).onScaleStart)==null||l.call(h)},onScaleMove:({deltaX:o,deltaY:a})=>{var l,c;const h=this.handleInternalVerticalScaleMove(o,a);(c=(l=this.events).onScaleMoveVertical)==null||c.call(l,h??void 0)},onScaleEnd:()=>{var o,a;this.resetScaleState(),this.initialZonePoints=[],this.verticalScaleInitialPosition=null,(a=(o=this.events).onScaleEnd)==null||a.call(o)}});return n.position.set(s.x,s.y),n}createMoveButton(){const e=this.calculateMoveButtonPosition(),i=new Fs(this.appService,{iconAlias:"moveIcon",backgroundColor:this.config.iconWrapperFillColor,onMoveStart:()=>{var s,n;return(n=(s=this.events).onMoveStart)==null?void 0:n.call(s)},onMoveMove:s=>{var n,o;return(o=(n=this.events).onMoveMove)==null?void 0:o.call(n,s)},onMoveEnd:()=>{var s,n;return(n=(s=this.events).onMoveEnd)==null?void 0:n.call(s)}});return i.position.set(e.x,e.y),i}createAndAddButton(e,i){return e.visible=i,this.controlButtons.addChild(e),e}createControlButtons(){this.outlinePoints.length<4||(this.deleteButton=this.createAndAddButton(this.createDeleteButton(),this.config.showDeleteButton??!1),this.moveButton=this.createAndAddButton(this.createMoveButton(),this.config.showMoveButton??!1),this.rotateButton=this.createAndAddButton(this.createRotateButton(),this.config.showRotateButton??!1),this.scaleButton=this.createAndAddButton(this.createScaleButton(),this.config.showScaleButton??!1),console.log("this.config.showRadialScaleButton",this.config.showRadialScaleButton),this.horizontalScaleButton=this.createAndAddButton(this.createHorizontalScaleButton(),this.config.showRadialScaleButton??!1),this.verticalScaleButton=this.createAndAddButton(this.createVerticalScaleButton(),this.config.showRadialScaleButton??!1))}calculateOutlinePoints(){const e=this.zonePoints;if(e.length<4)return e;const s=this.appService.getApp().toFixedSize(this.config.outlineOffset);return Ir(e,s)}calculateMoveButtonPosition(){const e=this.calculateOutlinePoints();if(e.length<4)return{x:0,y:0};const s=this.appService.getApp().toFixedSize(this.config.moveButtonOffset),n=e[ft.MOVE],o=e[ft.SCALE],a=e[ft.REMOVE];return Is(n,o,a,s)}calculateMoveLinePoints(){const e=this.calculateOutlinePoints();if(e.length<4)return[];const i=e[ft.MOVE],s=this.calculateMoveButtonPosition();return[i,s]}calculateSizeText(){const e=this.zonePoints;if(e.length<4)return"0m*0m";const[i,s,,n]=e,o=Q(i,s),a=Q(i,n),h=this.appService,l=h.pixelsToMeters(o),c=h.pixelsToMeters(a),d=h.metersToDisplayUnit(l),u=h.metersToDisplayUnit(c),p=h.runtimeSnapshot.unitLabel;return`${d.toFixed(1)}${p}*${u.toFixed(1)}${p}`}getEdgeCenter(e,i){return{x:(e.x+i.x)/2,y:(e.y+i.y)/2}}calculatePerpendicularOffset(e,i,s,n=!1){const o=pt(q(i,e)),a=n?{x:-o.y,y:o.x}:{x:o.y,y:-o.x};return{x:a.x*s,y:a.y*s}}calculateSizeTextPosition(){if(this.zonePoints.length<4)return{x:0,y:0};const i=this.calculateOutlinePoints(),[s,n,o,a]=i,{textPosition:h,textOffset:l}=this.config,d=this.appService.getApp().toFixedSize(l);let u,p;switch(h){case"top":u=this.getEdgeCenter(s,n),p=this.calculatePerpendicularOffset(n,s,d);break;case"right":u=this.getEdgeCenter(n,o),p=this.calculatePerpendicularOffset(n,o,d);break;case"bottom":u=this.getEdgeCenter(a,o),p=this.calculatePerpendicularOffset(a,o,d,!0);break;case"left":u=this.getEdgeCenter(s,a),p=this.calculatePerpendicularOffset(a,s,d);break;default:u=this.getEdgeCenter(s,n),p={x:0,y:d};break}return{x:u.x+p.x,y:u.y+p.y}}calculateSizeTextRotation(){const e=this.zonePoints;if(e.length<4)return 0;const[i,s,n,o]=e,{textPosition:a}=this.config;let h,l;switch(a){case"top":h=i,l=s;break;case"right":h=s,l=n;break;case"bottom":h=n,l=o;break;case"left":h=o,l=i;break;default:h=i,l=s;break}const c=this.appService.appContainer.getMapRotationRadians();return Xe(h,l,c)}calculateHorizontalScaleButtonRotation(){const e=this.zonePoints;if(e.length<4)return 0;const[,i,s]=e,n=this.appService.appContainer.getMapRotationRadians();return Xe(i,s,n)+Math.PI/2}calculateVerticalScaleButtonRotation(){const e=this.zonePoints;if(e.length<4)return 0;const[,,i,s]=e,n=this.appService.appContainer.getMapRotationRadians();return Xe(s,i,n)}updatePoints(e,i=!0){this.zonePoints=e,this.updateOutlineBorder(),this.moveLine&&this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeText(i)}updateOutlineBorder(){const e=this.calculateOutlinePoints();this.outlinePoints=e,this.outlineBorder.updatePoints(e)}updateMoveLine(){if(!this.moveLine)return;const e=this.calculateMoveLinePoints();this.moveLine.updatePoints(e)}updateSizeText(e=!0){if(this.sizeText){if(e){const i=this.calculateSizeText();this.sizeText.updateText(i)}this.updateSizeTextPosition()}}updateSizeTextPosition(){if(!this.sizeText)return;const e=this.calculateSizeTextPosition();this.sizeText.position.set(e.x,e.y);const i=this.calculateSizeTextRotation();this.sizeText.rotation=i}updateControlButtonsPosition(){if(!this.deleteButton||!this.scaleButton||!this.moveButton)return;const e=this.calculateOutlinePoints();if(e.length<4)return;const i=this.calculateMoveButtonPosition(),s=[{button:this.deleteButton,point:e[ft.REMOVE]},{button:this.scaleButton,point:e[ft.SCALE]},{button:this.moveButton,point:i}];if(this.rotateButton&&s.push({button:this.rotateButton,point:e[ft.ROTATE]}),this.horizontalScaleButton){const n=e[ft.ROTATE],o=e[ft.SCALE],a=Jl(n,o,0);s.push({button:this.horizontalScaleButton,point:a})}if(this.verticalScaleButton){const n=e[ft.SCALE],o=e[ft.MOVE],a=this.getEdgeCenter(n,o);s.push({button:this.verticalScaleButton,point:a})}s.forEach(({button:n,point:o})=>n.position.set(o.x,o.y)),this.horizontalScaleButton&&(this.horizontalScaleButton.rotation=this.calculateHorizontalScaleButtonRotation()),this.verticalScaleButton&&(this.verticalScaleButton.rotation=this.calculateVerticalScaleButtonRotation()),this.scaleButton&&this.scaleButton.visible&&(this.scaleButton.rotation=this.calculateVerticalScaleButtonRotation())}setupClickHandler(){this.clickHandler=new vt(this,{onClick:()=>{var e,i;(i=(e=this.events).onClick)==null||i.call(e)},stopPropagation:!1})}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateOutline),this.appService.emitter.on("mapRotationUpdate",this.throttledUpdateOutline)}updateOutlineForScale(){(this.outlineBorder.visible||this.controlButtons.visible)&&(this.updateOutlineBorder(),this.moveLine&&this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition())}initializeScaleCache(){if(this.initialZonePoints.length===0&&(this.initialZonePoints=this.zonePoints.map(p=>({...p}))),this.initialZonePoints.length<4)return;const e={...this.initialZonePoints[ft.SCALE]};if(!e)return;const i=ft.REMOVE,{x:s,y:n}=this.initialZonePoints[i],[,o,,a]=this.initialZonePoints,h={x:s,y:n},l=q(h,o),c=q(h,a),d=ie(l),u=ie(c);d===0||u===0||(this.scaleCache={fixedPoint:h,edge1:l,edge2:c,edge1Len:d,edge2Len:u,initialButtonPosition:e})}handleInternalScaleMove(e,i){if(this.initialZonePoints.length!==4||!this.scaleCache)return null;const s=this.appService.metersToPixels(this.minSize),{fixedPoint:n,edge1:o,edge2:a,edge1Len:h,edge2Len:l,initialButtonPosition:c}=this.scaleCache,d={x:c.x+e,y:c.y+i},u=q(n,d),p=he(u,o,h,s),f=he(u,a,l,s);return this.calculatePointsFromScale(n,o,a,p,f)}resetScaleState(){this.scaleCache=null}handleInternalHorizontalScaleMove(e,i){if(this.initialZonePoints.length!==4||!this.scaleCache||!this.horizontalScaleInitialPosition)return null;const{fixedPoint:s,edge1:n,edge2:o,edge1Len:a}=this.scaleCache,h=this.appService.metersToPixels(this.minSize),l={x:this.horizontalScaleInitialPosition.x+e,y:this.horizontalScaleInitialPosition.y+i},c=q(s,l),d=he(c,n,a,h);return this.calculatePointsFromScale(s,n,o,d,1)}handleInternalVerticalScaleMove(e,i){if(this.initialZonePoints.length!==4||!this.scaleCache||!this.verticalScaleInitialPosition)return null;const{fixedPoint:s,edge1:n,edge2:o,edge2Len:a}=this.scaleCache,h=this.appService.metersToPixels(this.minSize),l={x:this.verticalScaleInitialPosition.x+e,y:this.verticalScaleInitialPosition.y+i},c=q(s,l),d=1,u=he(c,o,a,h);return this.calculatePointsFromScale(s,n,o,d,u)}calculatePointsFromScale(e,i,s,n,o){const{x:a,y:h}=e;return[e,{x:a+i.x*n,y:h+i.y*n},{x:a+i.x*n+s.x*o,y:h+i.y*n+s.y*o},{x:a+s.x*o,y:h+s.y*o}]}initializeRotationCache(e){this.zonePoints.length<3||(this.rotationCache={rotationCenter:e,initialPoints:this.zonePoints.map(i=>({...i})),totalAngle:0})}handleInternalRotationMove(e){if(!this.rotationCache||this.rotationCache.initialPoints.length<3)return null;const{rotationCenter:i,initialPoints:s}=this.rotationCache;return this.rotationCache.totalAngle+=e,Er(s,i,this.rotationCache.totalAngle)}resetRotationState(){this.rotationCache=null}calculateRotationCenter(){return this.zonePoints.length===0?{x:0,y:0}:ee(this.zonePoints)}updateEditState({showRotateButton:e=!1,showScaleButton:i=!1,showRadialScaleButton:s=!1,showDeleteButton:n=!1,showMoveButton:o=!1,showBorder:a=!1,showSizeText:h=!1,borderStyle:l}){this.rotateButton&&(this.rotateButton.visible=e),this.scaleButton&&(this.scaleButton.visible=i),this.horizontalScaleButton&&(this.horizontalScaleButton.visible=s),this.verticalScaleButton&&(this.verticalScaleButton.visible=s),this.deleteButton&&(this.deleteButton.visible=n),this.moveButton&&(this.moveButton.visible=o);const c=e||i||s||n||o;this.controlButtons.visible=c,!c&&this.getOperationState().hasAnyOperation&&this.stopAllOperations(),this.outlineBorder.visible=a,this.moveLine&&(this.moveLine.visible=o),this.sizeText&&(this.sizeText.visible=h),a&&(this.updateOutlineBorder(),c&&(this.moveLine&&o&&this.updateMoveLine(),this.updateControlButtonsPosition()),h&&this.updateSizeTextPosition()),l&&this.outlineBorder.updateStyle({isDashed:l.isDashed,dashArray:l.dashArray})}getOperationState(){var n,o,a;const e=((n=this.scaleButton)==null?void 0:n.isCurrentlyScaling())||!1,i=((o=this.rotateButton)==null?void 0:o.isCurrentlyRotating())||!1,s=((a=this.moveButton)==null?void 0:a.isCurrentlyMoving())||!1;return{isDragging:!1,isScaling:e,isRotating:i,isMoving:s,hasAnyOperation:e||i||s}}stopAllOperations(){var e,i,s;(e=this.scaleButton)==null||e.stopScaling(),(i=this.rotateButton)==null||i.stopRotation(),(s=this.moveButton)==null||s.stopMoving()}getControlButtonsContainer(){return this.controlButtons}getMoveButton(){return this.moveButton}calculateEdgeMidpoint(e,i){const s=this.calculateOutlinePoints();if(s.length<4)return{x:0,y:0};const n=s[e],o=s[i];return{x:(n.x+o.x)/2,y:(n.y+o.y)/2}}destroy(){var e,i,s,n,o,a,h,l,c,d,u;this.appService.emitter.off("antiScale",this.throttledUpdateOutline),this.appService.emitter.off("mapRotationUpdate",this.throttledUpdateOutline),(e=this.clickHandler)==null||e.destroy(),this.clickHandler=null,(i=this.deleteButton)==null||i.destroy(),(s=this.rotateButton)==null||s.destroy(),(n=this.scaleButton)==null||n.destroy(),(o=this.moveButton)==null||o.destroy(),(a=this.horizontalScaleButton)==null||a.destroy(),(h=this.verticalScaleButton)==null||h.destroy(),this.deleteButton=null,this.rotateButton=null,this.scaleButton=null,this.moveButton=null,this.horizontalScaleButton=null,this.verticalScaleButton=null,(l=this.outlineBorder)==null||l.destroy(),(c=this.moveLine)==null||c.destroy(),(d=this.sizeText)==null||d.destroy(),(u=this.controlButtons)==null||u.destroy(),super.destroy()}}class V0{constructor(t){g(this,"editControlLayers",new Map);this.appService=t}registerEditControl(t,e){const i=this.appService;this.editControlLayers.has(t)&&this.unregisterEditControl(t);const s=new H0(i,e);if(!i.appContainer.addToLayer(Ti,s))throw A.warn(`[EditControlManager] Failed to add edit control layer for id: ${t}`),s.destroy(),new Error(`Failed to register edit control for id: ${t}`);return this.editControlLayers.set(t,s),s}unregisterEditControl(t){const e=this.editControlLayers.get(t);if(!e)return;this.appService.appContainer.removeFromLayer(Ti,e),e.destroy(),this.editControlLayers.delete(t)}getEditControl(t){return this.editControlLayers.get(t)}updateEditState(t,e){const i=this.editControlLayers.get(t);i&&i.updateEditState(e)}clearAll(){Array.from(this.editControlLayers.keys()).forEach(e=>this.unregisterEditControl(e))}getAllEditControls(){return Array.from(this.editControlLayers.values())}updatePositionByOrigin(t,e){const s=this.appService.appContainer.getLayer(Ti);s&&s.position.set(t,e)}hasEditControl(t){return this.editControlLayers.has(t)}}class Vr extends $h{constructor(e=Ha){super();g(this,"mapState",null);g(this,"components",{});g(this,"managers",{});g(this,"config",Ua);g(this,"runtime");g(this,"appService");g(this,"scaleMin",.5);g(this,"scaleMax",5);g(this,"events",{});g(this,"instanceKey");g(this,"containerElement");g(this,"emitter",Bx());g(this,"tickerState",{renderReasons:new Set,renderTimer:null});g(this,"pendingAsyncRender",!1);g(this,"isFirstMapDraw",!0);g(this,"isMapDrawn",!1);g(this,"onVisibilityChange",()=>{var i;document.visibilityState==="visible"||(i=this.components.interaction)==null||i.clearTouches()});this.instanceKey=e,this.appService=new ic(this),globalThis.__PIXI_APP__=this}async initialize(e){const{resizeTo:i,events:s,config:n,runtime:o={},...a}=e;this.config=sr(_a({},Ua,n??{})),sy(()=>this.config.global.enableLogger),A.log("Applying config",this.config,n),this.runtime=sr(Object.assign({},Ix,o));const h=this.instanceKey===Ha;this.containerElement=i;const l=h&&this.config.interaction.enable,c=this.config.global.performanceMode||!h,d={textureGCMaxIdle:c?60:Ln.any?180:3600,textureGCCheckCountMax:c?10:Ln.any?100:50,autoStart:!1,sharedTicker:c,eventFeatures:{move:l,globalMove:!1,click:l,wheel:l}};await this.init({resizeTo:h?i:void 0,preference:"webgpu",resolution:this.config.global.resolution,antialias:c?!1:F0(),depth:!c,autoDensity:!0,backgroundColor:0,backgroundAlpha:0,...d,...a}),A.log(`[Pixi] Renderer initialized: ${this.renderer.type===Ri.WEBGPU?"WebGPU":"WebGL"} ${this.renderer.type}`),this.preloadAssets(),this.scaleMax=this.config.interaction.zoomRange.max,this.scaleMin=this.config.interaction.zoomRange.min,this.events=s,this.initializeViewportContainer(),this.initializeInteraction(),this.initializeAppContainer(),this.managers.mapManager=new Vx(this.appService),this.managers.heatmapManager=new Kx(this.appService),this.managers.pathManager=new Zx(this.appService),this.managers.controlsManager=new t0(this.appService),this.managers.detectedObjectManager=new i0(this.appService),this.managers.customElementsManager=new T0(this.appService),this.managers.roomsManager=new D0(this.appService),this.managers.customCarpetManager=new O0(this.appService),this.managers.furnitureManager=new U0(this.appService),this.managers.editControlManager=new V0(this.appService),this.setupMapRotationListener(),document.addEventListener("visibilitychange",this.onVisibilityChange)}async drawMap(e){var a,h,l,c,d,u,p;this.isMapDrawn=!1,A.log("[Map] drawMap",e);const{size:i,resolution:s,origin:n,id:o}=e;((a=this.mapState)==null?void 0:a.id)!==void 0&&this.mapState.id!==o&&this.managers.pathManager.clear(),(n[0]!==((h=this.mapState)==null?void 0:h.origin.x)||n[1]!==((l=this.mapState)==null?void 0:l.origin.y))&&(this.managers.pathManager.updatePositionByOrigin(...n),this.managers.controlsManager.updatePositionByOrigin(...n),this.managers.detectedObjectManager.updatePositionByOrigin(...n),this.managers.customElementsManager.updatePositionByOrigin(...n),this.managers.customCarpetManager.updatePositionByOrigin(...n),this.managers.furnitureManager.updatePositionByOrigin(...n),this.managers.editControlManager.updatePositionByOrigin(...n),this.managers.heatmapManager.updatePositionByOrigin(...n)),this.mapState={id:e.id,status:e.status===1,origin:{x:n[0],y:n[1]},charger:{x:e.charger.coordinate[0],y:e.charger.coordinate[1]},chargerDirection:e.charger.angle??0,resolution:s,width:i[0],height:i[1],mapType:"structured"},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,(d=(c=this.events)==null?void 0:c.onMapFirstDrawed)==null||d.call(c,this.mapState)),(p=(u=this.events)==null?void 0:u.onMapDrawed)==null||p.call(u,this.mapState),await this.managers.mapManager.drawMap(e),i[0]===0||i[1]===0?(A.log("[Map] Map cleared, clearing path and room data"),this.managers.pathManager.clear(),this.managers.roomsManager.clear(),this.isMapDrawn=!1):(this.isMapDrawn=!0,this.managers.heatmapManager.onMapLoaded()),this.renderOnce()}async drawRasterMap(e){var a,h,l,c,d,u;this.isMapDrawn=!1,A.log("[Map] drawRasterMap",e);const{mapHeader:i,mapData:s}=e,{originX:n,originY:o}=i;(n!==((a=this.mapState)==null?void 0:a.origin.x)||o!==((h=this.mapState)==null?void 0:h.origin.y))&&(this.managers.pathManager.updatePositionByOrigin(n,o),this.managers.controlsManager.updatePositionByOrigin(n,o),this.managers.editControlManager.updatePositionByOrigin(n,o),this.managers.furnitureManager.updatePositionByOrigin(n,o),this.managers.detectedObjectManager.updatePositionByOrigin(n,o),this.managers.customElementsManager.updatePositionByOrigin(n,o),this.managers.heatmapManager.updatePositionByOrigin(n,o)),this.mapState={id:i.id,status:i.mapStable,origin:{x:n,y:o},charger:{x:i.chargeX,y:i.chargeY},chargerDirection:i.chargeDirection??0,resolution:i.mapResolution*100,width:i.mapWidth,height:i.mapHeight,version:i.version,mapType:"raster"},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,(c=(l=this.events)==null?void 0:l.onMapFirstDrawed)==null||c.call(l,this.mapState)),(u=(d=this.events)==null?void 0:d.onMapDrawed)==null||u.call(d,this.mapState),await this.managers.mapManager.drawRasterMap(s.parsed,this.mapState),i.mapWidth===0||i.mapHeight===0?(A.log("[Map] Map cleared, clearing path and room data"),this.managers.pathManager.clear(),this.managers.roomsManager.clear(),this.isMapDrawn=!1):(this.isMapDrawn=!0,this.managers.heatmapManager.onMapLoaded()),this.renderOnce()}drawPath(e){var i,s;A.log("[Path] drawPath",e),(s=(i=this.events)==null?void 0:i.onPathDrawed)==null||s.call(i,{id:e.pathHeader.pathId,type:e.pathHeader.type,direction:e.pathHeader.direction,count:e.pathHeader.count,initFlag:e.pathHeader.initFlag,robotPosition:e.pathPoints[e.pathPoints.length-1]??null}),this.managers.pathManager.draw(e),this.renderOnce()}async drawRoomProperty(e){var i,s;A.log("[Room] drawRoomProperty",e),(s=(i=this.events)==null?void 0:i.onRoomPropertiesDrawed)==null||s.call(i,e),await this.managers.roomsManager.drawRoomProperty(e),this.renderOnceNextFrame()}async drawCustomCarpets(e){A.log("[CustomCarpets] drawCustomCarpets",e),await this.managers.customCarpetManager.drawCustomCarpets(e),this.renderOnceNextFrame()}async drawFurnitures(e){A.log("[Furniture] drawFurnitures",e),await this.managers.furnitureManager.drawFurnitures(e),this.renderOnceNextFrame()}drawHeatmap(e){A.log("[Heatmap] drawHeatmap",e),this.managers.heatmapManager.draw(e),this.renderOnce()}drawForbiddenSweepZones(e){A.log("[Controls] drawForbiddenSweepZones",e),this.managers.controlsManager.drawForbiddenSweepZones(e),this.renderOnceNextFrame()}drawForbiddenMopZones(e){A.log("[Controls] drawForbiddenMopZones",e),this.managers.controlsManager.drawForbiddenMopZones(e),this.renderOnceNextFrame()}drawCleanZones(e){A.log("[Controls] drawCleanZones",e),this.managers.controlsManager.drawCleanZones(e),this.renderOnceNextFrame()}drawVirtualWalls(e){A.log("[Controls] drawVirtualWalls",e),this.managers.controlsManager.drawVirtualWalls(e),this.renderOnceNextFrame()}drawSpots(e){A.log("[Controls] drawSpots",e),this.managers.controlsManager.drawSpots(e),this.renderOnceNextFrame()}drawWayPoints(e){A.log("[Controls] drawWayPoints",e),this.managers.controlsManager.drawWayPoints(e),this.renderOnceNextFrame()}async drawDetectedObjects(e){A.log("[DetectedObject] drawDetectedObjects",e),await this.managers.detectedObjectManager.drawDetectedObjects(e),this.renderOnceNextFrame()}drawCustomCarpet(e){A.log("[CustomCarpet] drawCustomCarpet",e),this.managers.customCarpetManager.drawCustomCarpets(e),this.renderOnceNextFrame()}async drawCustomElements(e){A.log("[CustomElements] drawCustomElements",e),await this.managers.customElementsManager.drawCustomElements(e),this.renderOnceNextFrame()}getForbiddenSweepZones(){return this.managers.controlsManager.getForbiddenSweepZones()}getForbiddenMopZones(){return this.managers.controlsManager.getForbiddenMopZones()}getCleanZones(){return this.managers.controlsManager.getCleanZones()}getVirtualWalls(){return this.managers.controlsManager.getVirtualWalls()}getSpots(){return this.managers.controlsManager.getSpots()}getWayPoints(){return this.managers.controlsManager.getWayPoints()}getEffectiveDividerPoints(){return this.managers.controlsManager.getEffectiveDividerPoints()}getCustomCarpets(){return this.managers.customCarpetManager.getCustomCarpets()}getDividerEndPoints(){return this.managers.controlsManager.getDividerEndPoints()}resetPanZoom(){this.components.interaction.setPanZoom()}forceEndGesture(){A.log("[Map] forceEndGesture"),this.components.interaction.forceEndGesture()}fitMapToView(e,i=!1){if(!e||e.minX===e.maxX||e.minY===e.maxY)return;const s=this.config.map.autoPaddingVerticalPercent,n=this.config.map.autoPaddingHorizontalPercent,o=this.getViewportBounds(),a=this.components.appContainer.getMapRotationRadians(),h=this.calculateRotatedBounds(e,a),l=h.maxX-h.minX,c=h.maxY-h.minY,d=o.width,u=o.height,p=d*(1-n*2),f=u*(1-s*2),y=p/l,m=f/c,x=Math.min(y,m),S=Math.max(this.config.interaction.fitMinScale,this.scaleMin),v=Math.min(this.config.interaction.fitMaxScale,this.scaleMax),b=Math.max(S,Math.min(v,x)),P=e.minX+(e.maxX-e.minX)/2,w=e.minY+(e.maxY-e.minY)/2,C=this.config.map.autoFitOffset||{x:0,y:0},k=d/2+(C.x||0),M=u/2+(C.y||0),T=Math.cos(a),_=Math.sin(a),I=P*T-w*_,B=P*_+w*T,F=k-I*b,Z=M-B*b;A.debug("[MapApplication] fitMapToView calculated:",{rotation:this.components.appContainer.getMapRotation(),originalBounds:e,rotatedBounds:h,finalScale:b,position:{x:F,y:Z}}),this.components.interaction.setPanZoom({targetPosition:{x:F,y:Z},targetScale:{x:b,y:b},setCenter:!0,setScale:!0},i)}calculateRotatedBounds(e,i){if(i===0)return e;const s=(e.minX+e.maxX)/2,n=(e.minY+e.maxY)/2,o=[{x:e.minX-s,y:e.minY-n},{x:e.maxX-s,y:e.minY-n},{x:e.maxX-s,y:e.maxY-n},{x:e.minX-s,y:e.maxY-n}],a=Math.cos(i),h=Math.sin(i),l=o.map(f=>({x:f.x*a-f.y*h,y:f.x*h+f.y*a}));let c=1/0,d=1/0,u=-1/0,p=-1/0;return l.forEach(f=>{c=Math.min(c,f.x),d=Math.min(d,f.y),u=Math.max(u,f.x),p=Math.max(p,f.y)}),{minX:c+s,minY:d+n,maxX:u+s,maxY:p+n}}getViewportBounds(){var e;return((e=this.components.viewportContainer)==null?void 0:e.getViewportBounds())||{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}updateRuntime(e){Object.assign(this.runtime,e),A.log("[runtime] runtime updated",e),this.renderOnceNextFrame()}updateConfig(e){var i;_a(this.config,e),(i=this.managers.controlsManager)==null||i.updateRenderOrder(),A.log("[Config] Configuration updated",e),this.renderOnceNextFrame()}metersToPixels(e){var n;if(!((n=this.mapState)!=null&&n.resolution))return A.warn("Map resolution not available, using default resolution (5cm/pixel)"),e*20;const s=1/(this.mapState.resolution/100);return e*s}pixelsToMeters(e){var s;if(!((s=this.mapState)!=null&&s.resolution))return A.warn("Map resolution not available, using default resolution (5cm/pixel)"),e*.05;const i=this.mapState.resolution/100;return e*i}toFixedSize(e,i){const s=i??this.components.appContainer.scale.x;return e/s}fromFixedSize(e,i){const s=i??this.components.appContainer.scale.x;return e*s}getViewportCenterPoint(){if(!this.mapState)return A.warn("Map state not available, cannot calculate center point"),null;const e=this.getViewportBounds(),i=e.x+e.width/2,s=e.y+e.height/2,n=this.components.appContainer,o=n.scale.x,a=n.getMapRotationRadians(),h=i-n.x,l=s-n.y,c=h/o,d=l/o,u=Math.cos(a),p=Math.sin(a),f=c*u+d*p,y=-c*p+d*u,m=f-this.mapState.origin.x,x=y-this.mapState.origin.y;return{x:m,y:x}}getMapCenterPoint(){if(!this.mapState)return A.warn("Map state not available, cannot calculate map center point"),null;const e=this.managers.mapManager.mapBounds;if(e.minX===1/0||e.minY===1/0||e.maxX===-1/0||e.maxY===-1/0)return A.warn("Invalid map bounds, cannot calculate map center point"),null;const i=(e.minX+e.maxX)/2,s=(e.minY+e.maxY)/2,n=i-this.mapState.origin.x,o=s-this.mapState.origin.y;return{x:n,y:o}}getWallPointsByViewportCenter(e){var f;const{width:i=this.config.controls.virtualWall.minWidth,direction:s="horizontal",offsetX:n=0,offsetY:o=0}=e||{},a=this.getViewportCenterPoint()||{x:0,y:0},l=this.metersToPixels(i)/2,c=((f=this.components.appContainer)==null?void 0:f.getMapRotationRadians())||0,d=Math.cos(c),u=Math.sin(c);let p;return s==="horizontal"?p=[{vx:-l+n,vy:o},{vx:l+n,vy:o}]:p=[{vx:n,vy:-l+o},{vx:n,vy:l+o}],p.map(y=>({x:a.x+y.vx*d+y.vy*u,y:a.y-y.vx*u+y.vy*d}))}getForbiddenSweepZonePointsByViewportCenter(e){const i=this.config.controls.forbiddenSweepZone,{size:s=i.minSize,offsetX:n=0,offsetY:o=0}=e||{};return this.generateZonePoints(s,n,o)}getForbiddenMopZonePointsByViewportCenter(e){const i=this.config.controls.forbiddenMopZone,{size:s=i.minSize,offsetX:n=0,offsetY:o=0}=e||{};return this.generateZonePoints(s,n,o)}getCleanZonePointsByViewportCenter(e){const i=this.config.controls.cleanZone,{size:s=i.minSize,offsetX:n=0,offsetY:o=0}=e||{};return this.generateZonePoints(s,n,o)}getSpotPointByViewportCenter(e){const{offsetX:i=0,offsetY:s=0}=e||{},n=this.getViewportCenterPoint()||{x:0,y:0},o=n.x+i,a=n.y+s;return{x:o,y:a}}getFurniturePointsByViewportCenter(e){var x;const{furnitureType:i=1,offsetX:s=0,offsetY:n=0}=e||{},a=this.config.furniture.assets.find(S=>S.type===i),h=this.metersToPixels((a==null?void 0:a.width)??1.8),l=this.metersToPixels((a==null?void 0:a.height)??2),c=h/2,d=l/2,u=this.getViewportCenterPoint()||{x:0,y:0},p=((x=this.components.appContainer)==null?void 0:x.getMapRotationRadians())||0,f=Math.cos(p),y=Math.sin(p);return[{vx:-c+s,vy:-d+n},{vx:c+s,vy:-d+n},{vx:c+s,vy:d+n},{vx:-c+s,vy:d+n}].map(S=>({x:u.x+S.vx*f+S.vy*y,y:u.y-S.vx*y+S.vy*f}))}areRoomsAdjacent(e){return!e||e.length===0?(A.warn("[Room] No room IDs provided"),!1):this.managers.mapManager.areRoomsAdjacent(e)}isPointInAnyRoom(e){return!e||typeof e.x!="number"||typeof e.y!="number"?(A.warn("[Room] Invalid point provided"),null):this.mapState?this.managers.mapManager.isPointInAnyRoom(e):(A.warn("[Room] Map state not available"),null)}isWallIntersectsAnyRoom(e){return!e||e.length!==2||!e[0]||!e[1]||typeof e[0].x!="number"||typeof e[0].y!="number"||typeof e[1].x!="number"||typeof e[1].y!="number"?(A.warn("[Room] Invalid wall points provided"),!1):this.mapState?this.managers.mapManager.isWallIntersectsAnyRoom(e):(A.warn("[Room] Map state not available"),!1)}isZoneIntersectsAnyRoom(e){return!e||e.length!==4||!e[0]||!e[1]||!e[2]||!e[3]||typeof e[0].x!="number"||typeof e[0].y!="number"||typeof e[1].x!="number"||typeof e[1].y!="number"||typeof e[2].x!="number"||typeof e[2].y!="number"||typeof e[3].x!="number"||typeof e[3].y!="number"?(A.warn("[Room] Invalid zone points provided"),!1):this.mapState?this.managers.mapManager.isZoneIntersectsAnyRoom(e):(A.warn("[Room] Map state not available"),!1)}isNearChargerOrRobot(e,i,s){var h,l;if(!e||e.length<1)return A.warn("[Distance] Invalid points array: must have at least 1 point"),!1;if(e.length!==1&&e.length!==2&&e.length!==4)return A.warn("[Distance] Invalid points array: must have exactly 1 (point), 2 (wall) or 4 (zone) points"),!1;if(i<=0)return A.warn("[Distance] Invalid threshold: must be greater than 0"),!1;if(!this.mapState)return A.warn("[Distance] Map state not available"),!1;const{checkCharger:n=!0,checkRobot:o=!1}=s||{};if(!n&&!o)return A.warn("[Distance] At least one of checkCharger or checkRobot must be true"),!1;const a=this.metersToPixels(i);if(n){const c=this.appService.getChargerPosition();if(c){const d=(h=this.mapState)==null?void 0:h.charger.x,u=(l=this.mapState)==null?void 0:l.charger.y;if(d===0&&u===0)return A.warn("[Distance] Charger position not available"),!1;const p=Ea(c,e);if(p<=a)return A.log(`[Distance] Too close to charger: ${p.toFixed(2)} pixels (threshold: ${a.toFixed(2)} pixels)`),!0}else A.warn("[Distance] Charger position not available")}if(o){const c=this.appService.getRobotPosition();if(c){const d=Ea(c,e);if(d<=a)return A.log(`[Distance] Too close to robot: ${d.toFixed(2)} pixels (threshold: ${a.toFixed(2)} pixels)`),!0}else A.warn("[Distance] Robot position not available")}return!1}async snapshot(e){this.render();const{snapshot:i,global:s}=this.config,n=(e==null?void 0:e.backgroundColor)??s.backgroundColor,o=this.components.appContainer,a=o.getSnapshotBounds(),h=Math.floor(a.x),l=Math.floor(a.y),c=Math.ceil(a.x+a.width)-h,d=Math.ceil(a.y+a.height)-l;if(c<=0||d<=0)return A.error("[MapApplication] Snapshot failed: invalid bounds",a),"";const u=i.resolution||window.devicePixelRatio||2,p=kr.create({width:c,height:d,resolution:u}),f=new H;f.rect(0,0,c,d).fill(n);const y=new W;y.translate(-h,-l);try{return this.renderer.render({container:f,target:p}),this.renderer.render({container:o,target:p,transform:y,clear:!1}),await this.renderer.extract.base64({target:p,format:i.format,quality:i.quality,antialias:i.antialias})}catch(m){return A.error("[MapApplication] Snapshot failed:",m),""}finally{f.destroy(),p.destroy(!0)}}async snapshotByData({map:e,path:i,roomProperties:s,customElements:n,forbiddenSweepZones:o,forbiddenMopZones:a,virtualWalls:h,detectedObjects:l,furnitures:c},d={},u){const p=`SNAPSHOT_${Fx()}`;A.log(`[MapApplication] ${p} snapshot start`);const f=new Vr(p);try{if(await f.initialize({config:this.config,runtime:d}),!e)throw new Error("Map data is required");if(e.startsWith("7b22")){const m=$c(e);await f.drawMap(m)}else{const m=Qc(e,{pointsStructured:!0});if(m)await f.drawRasterMap(m);else throw new Error("Failed to decode raster map data")}if(i){const{decodePath:m}=await _e(async()=>{const{decodePath:S}=await import("./theme.Cii0G4Y-.js").then(v=>v.i);return{decodePath:S}},__vite__mapDeps([4,2])),x=m(i);f.drawPath(x)}s&&s.length>0&&await f.drawRoomProperty(s),o&&o.length>0&&f.drawForbiddenSweepZones(o),a&&a.length>0&&f.drawForbiddenMopZones(a),h&&h.length>0&&f.drawVirtualWalls(h),c&&c.length>0&&await f.drawFurnitures(c),l&&l.length>0&&await f.drawDetectedObjects(l),n&&n.length>0&&await f.drawCustomElements(n);const y=await f.snapshot(u);return A.log(`[MapApplication] ${p} snapshot completed successfully`),y}catch(y){throw A.error(`[MapApplication] ${p} snapshot other map failed:`,y),y}finally{A.log(`[MapApplication] ${p} destroy`),f.destroy()}}renderOnce(){A.log("[Pixi] renderOnce"),this.render()}renderOnceNextFrame(){this.pendingAsyncRender||(this.pendingAsyncRender=!0,requestAnimationFrame(()=>{A.log("[Pixi] renderOnceNextFrame"),this.render(),this.pendingAsyncRender=!1}))}requestRender(e,i=!1){if(!i){this.renderOnceNextFrame();return}this.tickerState.renderReasons.add(e),this.ticker.started||(A.debug(`🎬 [Ticker] START: ${e}`),this.ticker.start())}stopRender(e){this.tickerState.renderReasons.delete(e),this.tickerState.renderReasons.size===0&&this.scheduleStopRender("final",100)}destroy(){var e;A.log("[MapApplication] destroy"),this.tickerState.renderTimer&&(clearTimeout(this.tickerState.renderTimer),this.tickerState.renderTimer=null),this.tickerState.renderReasons.clear(),this.emitter.all.clear(),document.removeEventListener("visibilitychange",this.onVisibilityChange),this.managers.pathManager.destroy(),this.managers.mapManager.destroy(),this.managers.controlsManager.destroy(),this.managers.furnitureManager.destroy(),this.managers.detectedObjectManager.destroy(),this.managers.customElementsManager.destroy(),this.managers.roomsManager.destroy(),this.components.interaction.destroy(),(e=this.components.background)==null||e.destroy(),this.components.viewportContainer.destroy(),this.components.appContainer.destroy(),this.managers.heatmapManager.destroy(),super.destroy()}initializeViewportContainer(){this.components.viewportContainer=new zx(this.config,this.containerElement),this.stage.addChild(this.components.viewportContainer);const e=this.getViewportBounds();this.components.background=new z0(this.config.global,e,()=>{this.renderOnceNextFrame()}),this.components.viewportContainer.addChild(this.components.background),this.components.viewportContainer.setChildIndex(this.components.background,0),Bs(this.config.global,()=>{var i;(i=this.components.background)==null||i.update(this.config.global)})}initializeAppContainer(){this.components.appContainer=new Gx(this.appService),this.components.interaction.addChild(this.components.appContainer)}initializeInteraction(){this.components.interaction=new Iy(this.appService),this.components.viewportContainer.addChild(this.components.interaction)}scheduleStopRender(e,i){this.tickerState.renderTimer&&clearTimeout(this.tickerState.renderTimer),this.tickerState.renderTimer=setTimeout(()=>{this.tickerState.renderReasons.delete(e),this.tickerState.renderReasons.size===0&&(A.debug("⏸️ [Ticker] STOP"),this.ticker&&this.ticker.stop())},i)}generateZonePoints(e,i,s){var u;const n=this.getViewportCenterPoint()||{x:0,y:0},a=this.metersToPixels(e)/2,h=((u=this.components.appContainer)==null?void 0:u.getMapRotationRadians())||0,l=Math.cos(h),c=Math.sin(h);return[{vx:-a+i,vy:-a+s},{vx:a+i,vy:-a+s},{vx:a+i,vy:a+s},{vx:-a+i,vy:a+s}].map(p=>({x:n.x+p.vx*l+p.vy*c,y:n.y-p.vx*c+p.vy*l}))}preloadAssets(){const e=this.config.robot.icon.src,i=this.config.chargingStation.icon.src,s=[];N.add({alias:"robot",src:e}),s.push("robot"),N.add({alias:"chargingStation",src:i}),s.push("chargingStation"),N.add({alias:"deleteIcon",src:this.config.controls.deleteIconSrc}),s.push("deleteIcon"),N.add({alias:"rotateIcon",src:this.config.controls.rotateIconSrc}),s.push("rotateIcon"),N.add({alias:"scaleIcon",src:this.config.controls.scaleIconSrc}),s.push("scaleIcon"),N.add({alias:"moveIcon",src:this.config.controls.moveIconSrc}),s.push("moveIcon"),N.add({alias:"checkmark",src:this.config.room.selectionIndicator.iconSrc}),s.push("checkmark"),N.add({alias:"spotIcon",src:this.config.controls.spot.iconSrc}),s.push("spotIcon"),N.add({alias:"wayPoint",src:this.config.controls.wayPoint.normal.iconSrc}),s.push("wayPoint"),N.add({alias:"wayPointActive",src:this.config.controls.wayPoint.editing.iconSrc}),s.push("wayPointActive"),N.add({alias:"horizontalScaleIcon",src:this.config.controls.horizontalScaleIconSrc}),s.push("horizontalScaleIcon"),N.add({alias:"verticalScaleIcon",src:this.config.controls.verticalScaleIconSrc}),s.push("verticalScaleIcon"),this.config.room.property.cleanMode.assets.forEach((n,o)=>{const a=`cleanMode_${o}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.property.suction.assets.forEach((n,o)=>{const a=`fan_${o}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.property.cistern.assets.forEach((n,o)=>{const a=`water_${o}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.property.cleanTimes.assets.forEach((n,o)=>{const a=`cleanTimes${o+1}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.floorType.assets.forEach((n,o)=>{if(!n)return;const a=`floorType${o}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.property.customAssets&&Object.entries(this.config.room.property.customAssets).forEach(([n,o])=>{o.forEach((a,h)=>{const l=`custom_${n}_${h}`;N.add({alias:l,src:a}),s.push(l)})}),this.config.furniture.assets.forEach(n=>{const o=`furniture_${n.type}`;N.add({alias:o,src:n.src}),s.push(o)}),N.backgroundLoad(s)}setupMapRotationListener(){this.applyMapRotation(this.runtime.mapRotation),U(this.runtime,"mapRotation",e=>{this.applyMapRotation(e)})}applyMapRotation(e){const i=(e%360+360)%360;A.log(`[MapApplication] Applying map rotation: ${i}°`),this.components.appContainer.setMapRotation(i);const s=this.managers.mapManager.mapBounds;s&&s.minX!==1/0&&s.maxX!==-1/0&&this.fitMapToView(s,!1),this.emitter.emit("mapRotationUpdate",i),this.renderOnce()}}const $0=Object.freeze(Object.defineProperty({__proto__:null,AppService:ic,MapApplication:Vr},Symbol.toStringTag,{value:"Module"}));export{Lo as $,wi as A,le as B,ne as C,lr as D,Yt as E,ur as F,H as G,jg as H,Qe as I,Bf as J,ks as K,Cf as L,W as M,Ot as N,Rs as O,tt as P,dr as Q,et as R,Fp as S,G as T,Ee as U,j as V,jh as W,Ri as X,Gi as Y,Ip as Z,ri as _,Ke as a,Ci as a0,pr as a1,Hh as a2,Bt as a3,ti as a4,ol as a5,lf as a6,pf as a7,K0 as a8,hl as a9,Di as aA,Op as aB,al as aC,cf as aD,gf as aE,Yg as aF,ll as aG,mf as aH,Lg as aI,$0 as aJ,Ie as aa,hs as ab,Au as ac,cd as ad,ce as ae,Je as af,yf as ag,_t as ah,ph as ai,It as aj,Ps as ak,ho as al,jt as am,Mm as an,Ud as ao,co as ap,qs as aq,uo as ar,Vd as as,gh as at,kr as au,Pr as av,Yh as aw,Oi as ax,Zu as ay,Vu as az,$n as b,rt as c,V as d,de as e,Qn as f,os as g,xt as h,X as i,pu as j,gt as k,am as l,dt as m,Ln as n,iu as o,E as p,yt as q,Cd as r,zg as s,fa as t,Pu as u,J as v,nt as w,$ as x,L as y,st as z};
744
+ `,entryPoint:"main"}})}),l=new xa({geometry:a,shader:h});return l.alpha=.8,l}updatePositionByOrigin(e,i){this.position.set(e,i)}destroy(){this.removeChildren(),this.cacheAsTexture(!1)}}class Kx{constructor(t){g(this,"heatmap");g(this,"pointsTopLeftOrigin",[]);g(this,"signalGrid",[]);g(this,"cellSize",2);g(this,"maxDistance",14);g(this,"smoothIterations",10);g(this,"heatmapAlpha",.8);g(this,"isHeatmapDrawn",!1);g(this,"loadTimer",null);g(this,"pendingPoints",null);this.appService=t,this.heatmap=new qx(t);const e=t.heatMapConfig;this.cellSize=e.cellSize,this.maxDistance=e.maxDistance,this.smoothIterations=e.smoothIterations,this.heatmapAlpha=e.heatmapAlpha}draw(t){const e=this.appService;if(!e.isMapDrawn){this.pendingPoints=t;return}this.pendingPoints=null;const{minX:i,minY:s}=e.mapManager.mapBounds,n=t.map(o=>({x:+(o.x-i).toFixed(0),y:+(o.y-s).toFixed(0),signal:o.signal}));this.signalGrid=this.calculateInterpolatedSignal(n),this.heatmap.draw(this.signalGrid,this.heatmapAlpha),this.isHeatmapDrawn=!0}onMapLoaded(){this.loadTimer||(this.pendingPoints&&this.draw(this.pendingPoints),this.loadTimer=setTimeout(()=>{this.loadTimer=null},200))}calculateInterpolatedSignal(t){var p;const e=this.appService,i=((p=e.mapState)==null?void 0:p.origin)||{x:0,y:0};let{minX:s,minY:n,maxX:o,maxY:a}=e.mapManager.mapBounds;n=n-i.y,s=s-i.x,a=a-i.y,o=o-i.x;const h=Math.ceil((a-n)/this.cellSize),l=Math.ceil((o-s)/this.cellSize),c=Array(h).fill(null).map(()=>Array(l).fill(null));for(let f=0;f<h;f++){const y=n+f*this.cellSize+this.cellSize/2,m=Math.min(this.cellSize,a-(y-this.cellSize/2));for(let x=0;x<l;x++){const S=s+x*this.cellSize+this.cellSize/2,v=Math.min(this.cellSize,o-(S-this.cellSize/2));let b=0,P=!1;for(let w=0;w<t.length;w++){const C=t[w];if(Math.abs(S-C.x)<=v/2&&Math.abs(y-C.y)<=m/2){const k=1-C.signal/7;b=Math.round(Math.max(b,k)*10)/10,P=!0}}c[f][x]={x:S,y,signal:b,hasPoint:P}}}const d=(f,y)=>{if(t.length===0)return 0;let m=0,x=0;for(const S of t){const v=Math.sqrt((f-S.x)**2+(y-S.y)**2);if(v<=this.maxDistance){const b=1/(1+v),P=1-S.signal/7;x+=b*P,m+=b}}return m===0?0:Math.round(x/m*1e3)/1e3},u=(f,y=1)=>{for(let m=0;m<y;m++){const x=f.map(S=>[...S]);for(let S=1;S<h-1;S++)for(let v=1;v<l-1;v++)if(!f[S][v].hasPoint){let b=0,P=0;const w=4;for(let C=-w;C<=w;C++)for(let k=-w;k<=w;k++){if(C===0&&k===0)continue;const M=S+C,T=v+k;if(M>=0&&M<h&&T>=0&&T<l){const I=1/(1+Math.sqrt(C*C+k*k)*.3);b+=f[M][T].signal*I,P+=I}}if(P>0){const C=b/P,k=.6,M=.4;x[S][v].signal=f[S][v].signal*k+C*M,x[S][v].signal>.1&&(x[S][v].signal=Math.max(x[S][v].signal,.2))}}for(let S=0;S<h;S++)for(let v=0;v<l;v++)f[S][v].signal=x[S][v].signal}};for(let f=0;f<h;f++)for(let y=0;y<l;y++){const m=c[f][y];m.hasPoint||(m.signal=d(m.x,m.y))}return u(c,this.smoothIterations),c}updatePositionByOrigin(t,e){this.heatmap.updatePositionByOrigin(t,e)}destroy(){this.heatmap.destroy()}}class pc extends L{constructor(e){super();g(this,"throttledUpdateScale");this.appService=e,this.throttledUpdateScale=At(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.updateScale(this.appService.currentScale),this.registerScaleListener()}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}updateScale(e){e!==0&&this.scale.set(1/e)}destroy(e){this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(e)}}class Wi extends pc{constructor(e,i){super(e);g(this,"background");g(this,"icon");g(this,"options");this.appService=e,this.options=i,this.background=new H,this.addChild(this.background),this.icon=new Xt(e),this.addChild(this.icon),this.eventMode="static",this.render(),this.setupHitArea(),this.setupEvents()}setupHitArea(){const e=this.appService,i=this.options.config||e.controlsConfig,s=8,n=i.iconWrapperWidth+s*2,o=i.iconWrapperHeight+s*2;this.hitArea=new et(-n/2,-o/2,n,o)}async render(){this.renderBackground(),this.renderIcon()}renderBackground(){const e=this.appService,i=this.options.config||e.controlsConfig;this.background.clear(),this.background.roundRect(-i.iconWrapperWidth/2,-i.iconWrapperHeight/2,i.iconWrapperWidth,i.iconWrapperHeight,i.iconWrapperBorderRadius).fill(this.options.backgroundColor)}async renderIcon(){try{const e=this.appService,i=this.options.config||e.controlsConfig;await this.icon.loadTextureAndSetSize(this.options.iconAlias,{width:i.iconWidth,height:i.iconHeight,sizeFixed:!1}),this.icon.visible=!0}catch(e){A.error(`Failed to load icon: ${this.options.iconAlias}`,e)}}destroy(){super.destroy()}}class fc extends Wi{constructor(e,i){super(e,i);g(this,"isRotating",!1);g(this,"hasRotated",!1);g(this,"rotationCenter",{x:0,y:0});g(this,"lastAngle",0);g(this,"clickHandler",null);g(this,"handleRotationPointerMove",e=>{var o,a;if(!this.isRotating)return;this.hasRotated=!0;const i=this.parent.toLocal(e.global),s=Math.atan2(i.y-this.rotationCenter.y,i.x-this.rotationCenter.x),n=s-this.lastAngle;(a=(o=this.options).onRotationMove)==null||a.call(o,n),this.lastAngle=s});g(this,"handleRotationPointerUp",()=>{var e,i;this.isRotating&&(this.isRotating=!1,this.hasRotated&&((i=(e=this.options).onRotationEnd)==null||i.call(e)),this.hasRotated=!1)});g(this,"handleRotationCancel",()=>{var e,i;this.isRotating&&(this.isRotating=!1,this.hasRotated&&((i=(e=this.options).onRotationEnd)==null||i.call(e)),this.hasRotated=!1)});this.appService=e,this.setupRotationEventListeners()}setupRotationEventListeners(){const{emitter:e}=this.appService;this.appService.emitter.on("gestureHijackPointerMove",this.handleRotationPointerMove),e.on("gestureHijackPointerUp",this.handleRotationPointerUp),e.on("gestureHijackCancel",this.handleRotationCancel)}cleanupRotationEventListeners(){const{emitter:e}=this.appService;e.off("gestureHijackPointerMove",this.handleRotationPointerMove),e.off("gestureHijackPointerUp",this.handleRotationPointerUp),e.off("gestureHijackCancel",this.handleRotationCancel)}setupEvents(){this.options.onClick&&(this.clickHandler=new vt(this,{onClick:()=>{var e,i;this.hasRotated||(i=(e=this.options).onClick)==null||i.call(e)},stopPropagation:!1})),this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(e){e.stopPropagation(),this.startRotation(e)}startRotation(e){var n,o;this.isRotating=!0,this.hasRotated=!1;const i=this.options.getTargetPoints();this.rotationCenter=ee(i);const s=this.parent.toLocal(e.global);this.lastAngle=Math.atan2(s.y-this.rotationCenter.y,s.x-this.rotationCenter.x),(o=(n=this.options).onRotationStart)==null||o.call(n,this.rotationCenter),this.appService.emitter.emit("gestureHijackStart",e)}isCurrentlyRotating(){return this.isRotating}stopRotation(){var e,i;this.isRotating&&(this.isRotating=!1,this.hasRotated&&((i=(e=this.options).onRotationEnd)==null||i.call(e)),this.hasRotated=!1)}destroy(){var e;this.stopRotation(),(e=this.clickHandler)==null||e.destroy(),this.cleanupRotationEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Ds extends Wi{constructor(e,i){super(e,i);g(this,"clickHandler",null);this.appService=e}setupEvents(){this.clickHandler=new vt(this,{onClick:this.options.onClick,stopPropagation:!0})}destroy(){var e;(e=this.clickHandler)==null||e.destroy(),super.destroy()}}class Ze extends Wi{constructor(e,i){super(e,i);g(this,"isScaling",!1);g(this,"initialButtonPosition",null);g(this,"dragStartPosition",null);g(this,"handleScalePointerMove",e=>{var o,a;if(!this.isScaling||!this.initialButtonPosition||!this.dragStartPosition)return;const i=this.parent.toLocal(e.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y;(a=(o=this.options).onScaleMove)==null||a.call(o,{deltaX:s,deltaY:n})});g(this,"handleScalePointerUp",()=>{var e,i;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,(i=(e=this.options).onScaleEnd)==null||i.call(e))});g(this,"handleScaleCancel",()=>{var e,i;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,(i=(e=this.options).onScaleEnd)==null||i.call(e))});this.appService=e,this.setupScaleEventListeners()}setupScaleEventListeners(){const{emitter:e}=this.appService;e.on("gestureHijackPointerMove",this.handleScalePointerMove),e.on("gestureHijackPointerUp",this.handleScalePointerUp),e.on("gestureHijackCancel",this.handleScaleCancel)}cleanupScaleEventListeners(){const{emitter:e}=this.appService;e.off("gestureHijackPointerMove",this.handleScalePointerMove),e.off("gestureHijackPointerUp",this.handleScalePointerUp),e.off("gestureHijackCancel",this.handleScaleCancel)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(e){e.stopPropagation(),this.startScaling(e)}startScaling(e){var i,s,n,o;if(this.isScaling=!0,this.dragStartPosition=this.parent.toLocal(e.global),"initialButtonPosition"in this.options)this.initialButtonPosition={x:this.position.x,y:this.position.y},(s=(i=this.options).onScaleStart)==null||s.call(i);else{const a=this.options.getTargetPoints(),h=this.options.getButtonIndex();h>=0&&h<a.length&&(this.initialButtonPosition={...a[h]}),(o=(n=this.options).onScaleStart)==null||o.call(n,h)}this.appService.emitter.emit("gestureHijackStart",e)}isCurrentlyScaling(){return this.isScaling}stopScaling(){var e,i;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,(i=(e=this.options).onScaleEnd)==null||i.call(e))}destroy(){this.stopScaling(),this.cleanupScaleEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Fs extends Wi{constructor(e,i){super(e,i);g(this,"isMoving",!1);g(this,"dragStartPosition",null);g(this,"handleMovePointerMove",e=>{var i,s;!this.isMoving||!this.dragStartPosition||(s=(i=this.options).onMoveMove)==null||s.call(i,e)});g(this,"handleMovePointerUp",()=>{var e,i;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,(i=(e=this.options).onMoveEnd)==null||i.call(e))});g(this,"handleMoveCancel",()=>{var e,i;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,(i=(e=this.options).onMoveEnd)==null||i.call(e))});this.appService=e,this.setupMoveEventListeners()}setupMoveEventListeners(){const{emitter:e}=this.appService;e.on("gestureHijackPointerMove",this.handleMovePointerMove),e.on("gestureHijackPointerUp",this.handleMovePointerUp),e.on("gestureHijackCancel",this.handleMoveCancel)}cleanupMoveEventListeners(){const{emitter:e}=this.appService;e.off("gestureHijackPointerMove",this.handleMovePointerMove),e.off("gestureHijackPointerUp",this.handleMovePointerUp),e.off("gestureHijackCancel",this.handleMoveCancel)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(e){e.stopPropagation(),this.startMoving(e)}startMoving(e){var i,s;this.isMoving=!0,this.dragStartPosition=this.parent.toLocal(e.global),(s=(i=this.options).onMoveStart)==null||s.call(i),this.appService.emitter.emit("gestureHijackStart",e)}isCurrentlyMoving(){return this.isMoving}getDragStartPosition(){return this.dragStartPosition?{...this.dragStartPosition}:null}stopMoving(){var e,i;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,(i=(e=this.options).onMoveEnd)==null||i.call(e))}destroy(){this.stopMoving(),this.cleanupMoveEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Lr extends H{constructor(e,i){super();g(this,"fillOptions");g(this,"isDragging",!1);g(this,"dragStartPosition",null);g(this,"handlePointerDown",e=>{e.stopPropagation(),this.startDragging(e)});g(this,"handleDragPointerMove",e=>{var i,s;!this.isDragging||!this.dragStartPosition||(s=(i=this.fillOptions).onDragMove)==null||s.call(i,e)});g(this,"handleDragPointerUp",()=>{var e,i;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,(i=(e=this.fillOptions).onDragEnd)==null||i.call(e))});g(this,"handleDragCancel",()=>{var e,i;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,(i=(e=this.fillOptions).onDragEnd)==null||i.call(e))});this.appService=e,this.fillOptions=i,this.setupInteraction(),this.setupDragEventListeners(),this.draw()}setupInteraction(){this.fillOptions.enableInteraction&&(this.eventMode="static",this.on("pointerdown",this.handlePointerDown))}setupDragEventListeners(){const{emitter:e}=this.appService;e.on("gestureHijackPointerMove",this.handleDragPointerMove),e.on("gestureHijackPointerUp",this.handleDragPointerUp),e.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:e}=this.appService;e.off("gestureHijackPointerMove",this.handleDragPointerMove),e.off("gestureHijackPointerUp",this.handleDragPointerUp),e.off("gestureHijackCancel",this.handleDragCancel)}startDragging(e){var s,n;this.isDragging=!0;const i=this.parent.toLocal(e.global);this.dragStartPosition={x:i.x,y:i.y},(n=(s=this.fillOptions).onDragStart)==null||n.call(s,e),this.appService.emitter.emit("gestureHijackStart",e)}draw(){const{points:e,fillColor:i}=this.fillOptions;if(e.length<3)return;this.clear();const s=e.flatMap(n=>[n.x,n.y]);this.setFillStyle({color:i}).poly(s).fill()}getDragStartPosition(){return this.dragStartPosition}updateOptions(e){this.fillOptions={...this.fillOptions,...e},e.enableInteraction!==void 0&&(this.off("pointerdown",this.handlePointerDown),this.setupInteraction()),this.draw()}updatePoints(e){this.fillOptions.points=e,this.draw()}updateFillColor(e){this.fillOptions.fillColor=e,this.draw()}stopDragging(){this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null)}isCurrentlyDragging(){return this.isDragging}setInteractionEnabled(e){this.fillOptions.enableInteraction=e,e?(this.eventMode="static",this.on("pointerdown",this.handlePointerDown)):(this.eventMode="auto",this.off("pointerdown",this.handlePointerDown),this.isDragging&&this.stopDragging())}destroy(){this.stopDragging(),this.cleanupDragEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Nt extends L{constructor(e,i){super();g(this,"borderOptions");g(this,"solidLine",null);g(this,"dashGraphics",null);g(this,"fillGraphics",null);g(this,"handleAntiScale",()=>{this.drawBorder()});this.appService=e,this.borderOptions={...i},this.drawBorder(),this.setupAntiScaleListener(),this.eventMode="none"}setupAntiScaleListener(){this.appService.emitter.on("antiScale",this.handleAntiScale)}drawBorder(){const{points:e=[],closePath:i=!1,style:s}=this.borderOptions;e.length<2||(this.clearBorder(),s.fillColor!==void 0&&i&&this.drawFill(e,s),s.isDashed?this.drawContinuousDashedBorder(e,i,s):this.drawSolidBorder(e,i,s))}drawFill(e,i){if(!(!i.fillColor||e.length<3)){this.fillGraphics&&(this.removeChild(this.fillGraphics),this.fillGraphics.destroy()),this.fillGraphics=new H,this.fillGraphics.setFillStyle({color:i.fillColor}),this.fillGraphics.moveTo(e[0].x,e[0].y);for(let s=1;s<e.length;s++)this.fillGraphics.lineTo(e[s].x,e[s].y);this.fillGraphics.closePath(),this.fillGraphics.fill(),this.addChild(this.fillGraphics)}}drawSolidBorder(e,i,s){const n=this.appService;this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy()),this.solidLine=new H;const o=n.getApp().toFixedSize(s.width);this.solidLine.setStrokeStyle({color:s.color,width:o}),this.solidLine.moveTo(e[0].x,e[0].y);for(let a=1;a<e.length;a++)this.solidLine.lineTo(e[a].x,e[a].y);i&&this.solidLine.lineTo(e[0].x,e[0].y),this.solidLine.stroke(),this.addChild(this.solidLine)}drawContinuousDashedBorder(e,i,s){if(e.length<2)return;if(!s.dashArray||s.dashArray.length!==2||s.dashArray[0]<=0||s.dashArray[1]<=0){A.warn("Invalid dashArray:",s.dashArray);return}const n=this.appService;this.dashGraphics=new H;const o=n.getApp().toFixedSize(s.width);this.dashGraphics.setStrokeStyle({color:s.color,width:o});const a=Math.max(n.getApp().toFixedSize(s.dashArray[0]),1),h=Math.max(n.getApp().toFixedSize(s.dashArray[1]),1),l=i?[...e,e[0]]:e;this.drawContinuousPathDashes(this.dashGraphics,l,a,h),this.dashGraphics.stroke(),this.addChild(this.dashGraphics)}drawContinuousPathDashes(e,i,s,n){if(i.length<2)return;if(s<=0||n<=0){A.warn("Invalid dash parameters:",{dashLength:s,gapLength:n});return}const o=this.calculatePathSegments(i),a=o.reduce((c,d)=>c+d.length,0);if(a===0)return;const h=s+n;let l=0;for(;l<a;){const c=l+s;c<=a?this.drawContinuousDashSegment(e,o,l,c):this.drawContinuousDashSegment(e,o,l,a),l+=h}}calculatePathSegments(e){const i=[];for(let s=0;s<e.length-1;s++){const n=e[s],o=e[s+1],a=o.x-n.x,h=o.y-n.y,l=Math.sqrt(a*a+h*h);i.push({start:n,end:o,length:l})}return i}drawContinuousDashSegment(e,i,s,n){if(s>=n)return;let o=0,a=!1,h=null;for(const l of i){const c=o,d=o+l.length;if(d>s&&c<n){const u=Math.max(s,c),p=Math.min(n,d),f=(u-c)/l.length,y=(p-c)/l.length,m={x:l.start.x+(l.end.x-l.start.x)*f,y:l.start.y+(l.end.y-l.start.y)*f},x={x:l.start.x+(l.end.x-l.start.x)*y,y:l.start.y+(l.end.y-l.start.y)*y};a?h&&Math.sqrt(Math.pow(m.x-h.x,2)+Math.pow(m.y-h.y,2))>.1&&e.lineTo(m.x,m.y):(e.moveTo(m.x,m.y),a=!0),e.lineTo(x.x,x.y),h=x}if(o+=l.length,o>=n)break}}clearBorder(){this.fillGraphics&&(this.removeChild(this.fillGraphics),this.fillGraphics.destroy(),this.fillGraphics=null),this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy(),this.solidLine=null),this.dashGraphics&&(this.removeChild(this.dashGraphics),this.dashGraphics.destroy(),this.dashGraphics=null)}updateStyle(e){this.borderOptions.style={...this.borderOptions.style,...e},this.drawBorder()}updatePoints(e){this.borderOptions.points=e,this.drawBorder()}setClosePath(e){this.borderOptions.closePath=e,this.drawBorder()}getOptions(){return{...this.borderOptions}}destroy(){this.appService.emitter.off("antiScale",this.handleAntiScale),this.clearBorder(),super.destroy()}}class Ui extends Es{constructor(e,{text:i,style:s}){super({text:i,style:s});g(this,"throttledUpdateScale");this.appService=e,this.throttledUpdateScale=At(this.updateScale.bind(this),20,{leading:!0,trailing:!0}),this.registerScaleListener(),this.updateScale(this.appService.currentScale)}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}updateScale(e){e<=0||this.scale.set(1/e)}setBaseFontSize(e){this.style.fontSize=e}updateText(e){this.text=e}destroy(e){this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(e)}}const Ct=class Ct extends L{constructor(e){super();g(this,"appService");g(this,"zoneData");g(this,"zoneType");g(this,"zoneConfig");g(this,"controlsConfig");g(this,"zoneEvents");g(this,"controlFill");g(this,"zoneBorder");g(this,"outlineBorder");g(this,"moveLine");g(this,"sizeText");g(this,"controlButtons");g(this,"deleteButton",null);g(this,"rotateButton",null);g(this,"scaleButton",null);g(this,"moveButton",null);g(this,"totalRotationAngle",0);g(this,"rotationCenter",null);g(this,"initialZonePoints",[]);g(this,"initialButtonPosition",null);g(this,"dragStartPosition",null);g(this,"clickHandler",null);g(this,"throttledUpdateOutline");g(this,"handleDragStart",e=>{this.isEditingEnabled()&&(this.initialZonePoints=this.zoneData.points.map(i=>({...i})),this.dragStartPosition=this.parent.toLocal(e.global),this.appService.getApp().requestRender("zone-drag",!0))});g(this,"handleDragMove",e=>{if(!this.isEditingEnabled()||this.initialZonePoints.length===0||!this.dragStartPosition)return;const i=this.parent.toLocal(e.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y;this.applyTranslation(s,n)});g(this,"handleDragEnd",()=>{var e,i;this.initialZonePoints=[],this.dragStartPosition=null,this.appService.getApp().stopRender("zone-drag"),(i=(e=this.zoneEvents).onUpdate)==null||i.call(e,this.getZoneData())});g(this,"handleRotationStart",e=>{this.totalRotationAngle=0,this.rotationCenter=e,this.initialZonePoints=this.zoneData.points.map(i=>({...i})),this.appService.getApp().requestRender("zone-rotate",!0)});g(this,"handleRotationMove",e=>{this.totalRotationAngle+=e,this.applyRotation(this.totalRotationAngle)});g(this,"handleRotationEnd",()=>{var e,i;this.rotationCenter=null,this.totalRotationAngle=0,this.initialZonePoints=[],this.appService.getApp().stopRender("zone-rotate"),(i=(e=this.zoneEvents).onUpdate)==null||i.call(e,this.getZoneData())});g(this,"handleScaleStart",()=>{this.initialZonePoints=this.zoneData.points.map(i=>({...i}));const e=Ct.BUTTON_INDICES.SCALE;e<this.zoneData.points.length&&(this.initialButtonPosition={...this.zoneData.points[e]}),this.appService.getApp().requestRender("zone-scale",!0)});g(this,"handleScaleMove",({deltaX:e,deltaY:i})=>{if(this.initialZonePoints.length===0||!this.initialButtonPosition)return;const s={x:this.initialButtonPosition.x+e,y:this.initialButtonPosition.y+i};this.applyEdgeBasedScale(s)});g(this,"handleScaleEnd",()=>{var e,i;this.initialZonePoints=[],this.initialButtonPosition=null,this.appService.getApp().stopRender("zone-scale"),(i=(e=this.zoneEvents).onUpdate)==null||i.call(e,this.getZoneData())});g(this,"handleMoveStart",()=>{this.initialZonePoints=this.zoneData.points.map(e=>({...e})),this.appService.getApp().requestRender("zone-move",!0)});g(this,"handleMove",e=>{var a;if(!this.isEditingEnabled()||this.initialZonePoints.length===0)return;const i=this.parent.toLocal(e.global),s=(a=this.moveButton)==null?void 0:a.getDragStartPosition();if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.applyTranslation(n,o)});g(this,"handleMoveEnd",()=>{var e,i;this.initialZonePoints=[],this.appService.getApp().stopRender("zone-move"),(i=(e=this.zoneEvents).onUpdate)==null||i.call(e,this.getZoneData())});g(this,"handleDelete",()=>{var e,i;(i=(e=this.zoneEvents).onRemove)==null||i.call(e,this.zoneData.id)});const{appService:i,zoneData:s,zoneType:n,events:o={}}=e;this.appService=i,this.zoneType=n,this.zoneEvents=o,this.zoneConfig=this.getZoneConfig(),this.controlsConfig=this.getControlsConfig();const a=this.validateAndCorrectZoneSize(s.points),h=bs(a);this.zoneData={...s,points:h},this.throttledUpdateOutline=At(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.createControlButtons(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateOutline),this.appService.emitter.on("mapRotationUpdate",this.throttledUpdateOutline)}updateOutlineForScale(){this.isEditingEnabled()&&(this.updateOutlineBorder(),this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition())}getZoneConfig(){const{controls:e}=this.appService.getConfig();return e[this.zoneType]}getControlsConfig(){const{controls:e}=this.appService.getConfig();return e}validateAndCorrectZoneSize(e){if(e.length<4)return e;const i=this.appService.metersToPixels(this.zoneConfig.minSize),[s,n,,o]=e,a=Q(s,n),h=Q(s,o);if(a>=i&&h>=i)return e;const l=ee(e),c=pt(q(s,n)),d=pt(q(s,o)),u=Math.max(a,i),p=Math.max(h,i),f=u/2,y=p/2;return[{x:l.x-c.x*f-d.x*y,y:l.y-c.y*f-d.y*y},{x:l.x+c.x*f-d.x*y,y:l.y+c.y*f-d.y*y},{x:l.x+c.x*f+d.x*y,y:l.y+c.y*f+d.y*y},{x:l.x-c.x*f+d.x*y,y:l.y-c.y*f+d.y*y}]}getEditingIdsKey(){switch(this.zoneType){case"forbiddenSweepZone":return"editingForbiddenSweepZoneIds";case"forbiddenMopZone":return"editingForbiddenMopZoneIds";case"cleanZone":return"editingCleanZoneIds";default:return"editingForbiddenSweepZoneIds"}}isEditingEnabled(){const e=this.getEditingIdsKey();return this.appService.runtimeSnapshot[e].includes(this.zoneData.id)}initializeComponents(){this.outlineBorder=this.createOutlineBorder(),this.addChild(this.outlineBorder),this.controlFill=this.createControlFill(),this.addChild(this.controlFill),this.zoneBorder=this.createBorder(),this.addChild(this.zoneBorder),this.moveLine=this.createMoveLine(),this.addChild(this.moveLine),this.sizeText=this.createSizeText(),this.addChild(this.sizeText),this.controlButtons=new L,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.drawZone()}createControlButtons(){const e=this.calculateOutlinePoints();if(e.length<4)return;this.deleteButton=new Ds(this.appService,{iconAlias:"deleteIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onClick:this.handleDelete}),this.deleteButton.position.set(e[Ct.BUTTON_INDICES.REMOVE].x,e[Ct.BUTTON_INDICES.REMOVE].y),this.zoneConfig.showRotateButton&&(this.rotateButton=new fc(this.appService,{iconAlias:"rotateIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,onRotationStart:this.handleRotationStart,onRotationMove:this.handleRotationMove,onRotationEnd:this.handleRotationEnd}),this.rotateButton.position.set(e[Ct.BUTTON_INDICES.ROTATE].x,e[Ct.BUTTON_INDICES.ROTATE].y)),this.scaleButton=new Ze(this.appService,{iconAlias:"scaleIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,getButtonIndex:()=>Ct.BUTTON_INDICES.SCALE,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(e[Ct.BUTTON_INDICES.SCALE].x,e[Ct.BUTTON_INDICES.SCALE].y);const i=this.calculateMoveButtonPosition();this.moveButton=new Fs(this.appService,{iconAlias:"moveIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(i.x,i.y),this.controlButtons.addChild(this.deleteButton),this.rotateButton&&this.controlButtons.addChild(this.rotateButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton)}createControlFill(){const e=this.isEditingEnabled();return new Lr(this.appService,{points:this.zoneData.points,fillColor:this.zoneConfig.fillColor,enableInteraction:e,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createBorder(){const i=this.isEditingEnabled()?this.zoneConfig.editing:this.zoneConfig.normal;return new Nt(this.appService,{points:this.zoneData.points,closePath:!0,style:{color:this.zoneConfig.strokeColor,width:this.zoneConfig.strokeWidth,isDashed:i.isDashed,dashArray:i.dashArray}})}createOutlineBorder(){const e=this.calculateOutlinePoints();return new Nt(this.appService,{points:e,closePath:!0,style:{color:this.zoneConfig.outlineStrokeColor,width:this.zoneConfig.outlineStrokeWidth,isDashed:this.zoneConfig.outlineDashed,dashArray:this.zoneConfig.outlineDashArray,fillColor:this.zoneConfig.outlineFillColor}})}createMoveLine(){const e=this.calculateOutlinePoints(),i=this.calculateMoveLinePoints(e);return new Nt(this.appService,{points:i,closePath:!1,style:{color:this.zoneConfig.outlineStrokeColor,width:this.zoneConfig.outlineStrokeWidth,isDashed:this.zoneConfig.outlineDashed,dashArray:this.zoneConfig.outlineDashArray}})}calculateOutlinePoints(){const{points:e}=this.zoneData;if(e.length<4)return e;const i=this.appService.getApp().toFixedSize(this.zoneConfig.outlineOffset);return Ir(e,i)}calculateMoveLinePoints(e){if(e.length<4)return[];const i=e[Ct.BUTTON_INDICES.MOVE],s=this.calculateMoveButtonPosition();return[i,s]}createSizeText(){const e=this.calculateZoneSizeText(),i=new Ui(this.appService,{text:e,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.zoneConfig.textColor,align:"center"}});i.anchor.set(.5);const s=this.calculateSizeTextPosition();i.position.set(s.x,s.y);const n=this.calculateSizeTextRotation();return i.rotation=n,i.eventMode="none",i}calculateZoneSizeText(){const{points:e}=this.zoneData;if(e.length<4)return"0m*0m";const[i,s,,n]=e,o=Q(i,s),a=Q(i,n),h=this.appService.pixelsToMeters(o),l=this.appService.pixelsToMeters(a),c=this.appService.metersToDisplayUnit(h),d=this.appService.metersToDisplayUnit(l),u=this.appService.runtimeSnapshot.unitLabel;return`${c.toFixed(1)}${u}*${d.toFixed(1)}${u}`}calculateSizeTextPosition(){const{points:e}=this.zoneData;if(e.length<4)return{x:0,y:0};const[i,s,n,o]=e,{textPosition:a,textOffset:h}=this.zoneConfig,l=this.appService.getApp().toFixedSize(h);let c,d;switch(a){case"top":{c={x:(i.x+s.x)/2,y:(i.y+s.y)/2};const u=pt(q(s,i)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}case"right":{c={x:(s.x+n.x)/2,y:(s.y+n.y)/2};const u=pt(q(s,n)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}case"bottom":{c={x:(o.x+n.x)/2,y:(o.y+n.y)/2};const u=pt(q(o,n)),p={x:-u.y,y:u.x};d={x:p.x*l,y:p.y*l};break}case"left":{c={x:(i.x+o.x)/2,y:(i.y+o.y)/2};const u=pt(q(o,i)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}default:c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},d={x:0,y:l};break}return{x:c.x+d.x,y:c.y+d.y}}calculateSizeTextRotation(){const{points:e}=this.zoneData;if(e.length<4)return 0;const[i,s,n,o]=e,{textPosition:a}=this.zoneConfig;let h,l;switch(a){case"top":h=i,l=s;break;case"right":h=s,l=n;break;case"bottom":h=n,l=o;break;case"left":h=o,l=i;break;default:h=i,l=s;break}const c=this.appService.appContainer.getMapRotationRadians();return Xe(h,l,c)}calculateMoveButtonPosition(){const e=this.calculateOutlinePoints();if(e.length<4)return{x:0,y:0};const{controls:i}=this.appService.getConfig(),s=e[Ct.BUTTON_INDICES.MOVE],n=e[2],o=e[0],a=this.appService.getApp().toFixedSize(i.moveButtonOffset);return Is(s,n,o,a)}applyTranslation(e,i){this.zoneData.points=this.initialZonePoints.map(s=>({x:s.x+e,y:s.y+i})),this.drawZone(),this.updateControlButtonsPosition()}applyRotation(e){!this.rotationCenter||this.initialZonePoints.length===0||(this.zoneData.points=Er(this.initialZonePoints,this.rotationCenter,e),this.drawZone(!1),this.updateControlButtonsPosition())}applyEdgeBasedScale(e){if(this.initialZonePoints.length<4)return;const{FIXED:i}=Ct.BUTTON_INDICES,{x:s,y:n}=this.initialZonePoints[i],[,o,,a]=this.initialZonePoints,h={x:s,y:n},l=q(h,o),c=q(h,a),d=q(h,e),u=ie(l),p=ie(c);if(u===0||p===0)return;const f=this.appService.metersToPixels(this.zoneConfig.minSize),[y,m]=[he(d,l,u,f),he(d,c,p,f)];this.zoneData.points=[h,{x:s+l.x*y,y:n+l.y*y},{x:s+l.x*y+c.x*m,y:n+l.y*y+c.y*m},{x:s+c.x*m,y:n+c.y*m}],this.drawZone(),this.updateControlButtonsPosition()}setupClickHandler(){this.clickHandler=new vt(this,{onClick:()=>{var e,i;this.isEditingEnabled()||(i=(e=this.zoneEvents)==null?void 0:e.onClick)==null||i.call(e,this.getZoneData())},stopPropagation:!1})}drawZone(e=!0){const{points:i}=this.zoneData;i.length<4||(this.controlFill.updatePoints(i),this.zoneBorder.updatePoints(i),this.updateOutlineBorder(),this.updateMoveLine(),this.updateSizeText(e))}updateOutlineBorder(){const e=this.calculateOutlinePoints();this.outlineBorder.updatePoints(e)}updateMoveLine(){const e=this.calculateOutlinePoints(),i=this.calculateMoveLinePoints(e);this.moveLine.updatePoints(i)}updateSizeText(e=!0){if(this.sizeText){if(e){const i=this.calculateZoneSizeText();this.sizeText.updateText(i)}this.updateSizeTextPosition()}}updateSizeTextPosition(){if(!this.sizeText)return;const e=this.calculateSizeTextPosition();this.sizeText.position.set(e.x,e.y);const i=this.calculateSizeTextRotation();this.sizeText.rotation=i}updateControlButtonsPosition(){if(!this.deleteButton||!this.scaleButton||!this.moveButton)return;const e=this.calculateOutlinePoints();if(e.length<4)return;const{REMOVE:i,ROTATE:s,SCALE:n}=Ct.BUTTON_INDICES,o=this.calculateMoveButtonPosition(),a=[{button:this.deleteButton,point:e[i]},{button:this.scaleButton,point:e[n]},{button:this.moveButton,point:o}];this.rotateButton&&a.push({button:this.rotateButton,point:e[s]}),a.forEach(({button:h,point:l})=>h.position.set(l.x,l.y))}updateEditState(){const e=this.isEditingEnabled();this.controlButtons.visible=e,!e&&this.getCurrentOperationState().hasAnyOperation&&this.stopAllOperations(),this.outlineBorder.visible=e,this.moveLine.visible=e,this.sizeText&&(this.sizeText.visible=e),e&&(this.updateOutlineBorder(),this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition()),this.controlFill.setInteractionEnabled(e),this.updateBorderStyle(e?this.zoneConfig.editing:this.zoneConfig.normal),this.zIndex=e?1e3:0}updateBorderStyle(e){this.zoneBorder.updateStyle({isDashed:e.isDashed,dashArray:e.dashArray})}getCurrentOperationState(){var o,a,h;const e=this.controlFill.isCurrentlyDragging(),i=((o=this.scaleButton)==null?void 0:o.isCurrentlyScaling())||!1,s=((a=this.rotateButton)==null?void 0:a.isCurrentlyRotating())||!1,n=((h=this.moveButton)==null?void 0:h.isCurrentlyMoving())||!1;return{isDragging:e,isScaling:i,isRotating:s,isMoving:n,hasAnyOperation:e||i||s||n}}stopAllOperations(){var e,i,s;this.controlFill.stopDragging(),(e=this.scaleButton)==null||e.stopScaling(),(i=this.rotateButton)==null||i.stopRotation(),(s=this.moveButton)==null||s.stopMoving()}stopDragging(){this.controlFill.stopDragging()}stopScaling(){var e;(e=this.scaleButton)==null||e.stopScaling()}stopRotating(){var e;(e=this.rotateButton)==null||e.stopRotation()}stopMoving(){var e;(e=this.moveButton)==null||e.stopMoving()}isCurrentlyDragging(){return this.controlFill.isCurrentlyDragging()}isCurrentlyScaling(){var e;return((e=this.scaleButton)==null?void 0:e.isCurrentlyScaling())||!1}isCurrentlyRotating(){var e;return((e=this.rotateButton)==null?void 0:e.isCurrentlyRotating())||!1}isCurrentlyMoving(){var e;return((e=this.moveButton)==null?void 0:e.isCurrentlyMoving())||!1}updateZoneData(e){const i=this.validateAndCorrectZoneSize(e.points),s=bs(i);this.zoneData={...e,points:s},this.drawZone(),this.updateControlButtonsPosition(),this.updateEditState()}getZoneData(){return{...this.zoneData}}refreshDisplay(){this.drawZone()}destroy(){var e,i,s,n,o,a,h,l,c,d,u;this.appService.emitter.off("antiScale",this.throttledUpdateOutline),this.appService.emitter.off("mapRotationUpdate",this.throttledUpdateOutline),(e=this.clickHandler)==null||e.destroy(),this.clickHandler=null,(i=this.deleteButton)==null||i.destroy(),(s=this.rotateButton)==null||s.destroy(),(n=this.scaleButton)==null||n.destroy(),(o=this.moveButton)==null||o.destroy(),this.deleteButton=null,this.rotateButton=null,this.scaleButton=null,this.moveButton=null,(a=this.zoneBorder)==null||a.destroy(),(h=this.outlineBorder)==null||h.destroy(),(l=this.moveLine)==null||l.destroy(),(c=this.sizeText)==null||c.destroy(),(d=this.controlFill)==null||d.destroy(),(u=this.controlButtons)==null||u.destroy(),super.destroy()}};g(Ct,"BUTTON_INDICES",{REMOVE:0,ROTATE:1,SCALE:2,MOVE:3,FIXED:0});let Li=Ct;class Or extends Li{constructor(t,e){super({appService:t,zoneData:e.zoneData,zoneType:"forbiddenSweepZone",events:{onRemove:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onRemoveForbiddenSweepZone)==null||n.call(s,i)},onUpdate:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onUpdateForbiddenSweepZone)==null||n.call(s,i)},onClick:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onClickForbiddenSweepZone)==null||n.call(s,i)}}})}static create(t,e){return new Or(t,{zoneData:e})}}class Gr extends Li{constructor(t,e){super({appService:t,zoneData:e.zoneData,zoneType:"forbiddenMopZone",events:{onRemove:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onRemoveForbiddenMopZone)==null||n.call(s,i)},onUpdate:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onUpdateForbiddenMopZone)==null||n.call(s,i)},onClick:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onClickForbiddenMopZone)==null||n.call(s,i)}}})}static create(t,e){return new Gr(t,{zoneData:e})}}class Wr extends Li{constructor(t,e){super({appService:t,zoneData:e.zoneData,zoneType:"cleanZone",events:{onRemove:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onRemoveCleanZone)==null||n.call(s,i)},onUpdate:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onUpdateCleanZone)==null||n.call(s,i)},onClick:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onClickCleanZone)==null||n.call(s,i)}}})}static create(t,e){return new Wr(t,{zoneData:e})}}class Ue extends H{constructor(e,i){super();g(this,"lineOptions");g(this,"strokeContext",null);g(this,"drawDashLine",()=>{const{start:e,end:i,style:s}=this.lineOptions;this.clear(),this.strokeContext&&this.strokeContext.destroy();const n=this.appService;this.strokeContext=new mt;const o=n.getApp().toFixedSize(s.width);this.strokeContext.setStrokeStyle({color:s.color,width:o}),this.drawDashedLineToContext(this.strokeContext,e.x,e.y,i.x,i.y,s.dashArray[0],s.dashArray[1]),this.strokeContext.stroke(),this.context=this.strokeContext});this.appService=e,this.lineOptions={...i},this.eventMode="static",this.drawDashLine(),this.setupAntiScaleListener()}setupAntiScaleListener(){this.appService.emitter.on("antiScale",this.drawDashLine)}drawDashedLineToContext(e,i,s,n,o,a,h){const l=n-i,c=o-s,d=Math.sqrt(l*l+c*c);if(d===0)return;const u=this.appService,p=u.getApp().toFixedSize(a),f=u.getApp().toFixedSize(h),y=p+f,m=d/y,x=Math.round(m);if(x===0){e.moveTo(i,s),e.lineTo(n,o);return}const S=d/x,v=S*(p/y),b=l/d,P=c/d;for(let w=0;w<x;w++){const C=w*S,k=C+v;if(C>=d)break;const M=Math.min(k,d),T=i+C*b,_=s+C*P,I=i+M*b,B=s+M*P;e.moveTo(T,_),e.lineTo(I,B)}}updatePoints(e,i){this.lineOptions.start=e,this.lineOptions.end=i,this.drawDashLine()}updateStyle(e){this.lineOptions.style={...this.lineOptions.style,...e},this.drawDashLine()}getOptions(){return{...this.lineOptions}}destroy(){this.appService.emitter.off("antiScale",this.drawDashLine),this.strokeContext&&this.strokeContext.destroy(),super.destroy()}}const Vt=class Vt extends L{constructor(e){super();g(this,"wallData");g(this,"wallConfig");g(this,"controlsConfig");g(this,"wallEvents");g(this,"appService");g(this,"wallLine");g(this,"outlineBorder");g(this,"moveLine");g(this,"lengthText");g(this,"controlButtons");g(this,"removeButton",null);g(this,"scaleButton",null);g(this,"moveButton",null);g(this,"initialWallPoints",[]);g(this,"initialButtonPosition",null);g(this,"isDragging",!1);g(this,"dragStartPosition",null);g(this,"throttledUpdateOutline");g(this,"throttledHandleScaleChange");g(this,"wallLineClickHandler",null);g(this,"handleRemove",()=>{var e,i;(i=(e=this.wallEvents).onRemove)==null||i.call(e,this.wallData.id)});g(this,"initializeOperation",()=>{this.initialWallPoints=this.wallData.points.map(e=>({...e}))});g(this,"finalizeOperation",()=>{var e,i;this.initialWallPoints=[],(i=(e=this.wallEvents).onUpdate)==null||i.call(e,this.getWallData())});g(this,"handleScaleStart",()=>{this.initializeOperation();const e=this.calculateOutlinePoints();e.length>Vt.BUTTON_INDICES.SCALE&&(this.initialButtonPosition={...e[Vt.BUTTON_INDICES.SCALE]}),this.appService.getApp().requestRender("virtualwall-scale",!0)});g(this,"handleScaleMove",({deltaX:e,deltaY:i})=>{if(this.initialWallPoints.length===0||!this.initialButtonPosition)return;const s={x:this.initialButtonPosition.x+e,y:this.initialButtonPosition.y+i};this.applyScaleAndRotation(s)});g(this,"handleScaleEnd",()=>{this.finalizeOperation(),this.initialButtonPosition=null,this.appService.getApp().stopRender("virtualwall-scale")});g(this,"handleMoveStart",()=>{this.initializeOperation(),this.appService.getApp().requestRender("virtualwall-move",!0)});g(this,"handleMove",e=>{var a;if(this.initialWallPoints.length===0)return;const i=this.parent.toLocal(e.global),s=this.getDragStartPosition()||((a=this.moveButton)==null?void 0:a.getDragStartPosition());if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.applyTranslation(n,o)});g(this,"handleMoveEnd",()=>{this.finalizeOperation(),this.appService.getApp().stopRender("virtualwall-move")});g(this,"handleScaleChange",()=>{this.redrawSolidLine(),this.setupWallLineHitArea()});g(this,"handleWallLinePointerDown",e=>{this.isEditingEnabled()&&(e.stopPropagation(),this.startDragging(e))});g(this,"handleDragPointerMove",e=>{!this.isDragging||!this.dragStartPosition||this.handleMove(e)});g(this,"handleDragPointerUp",()=>{this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.appService.getApp().stopRender("virtualwall-drag"),this.finalizeOperation())});g(this,"handleDragCancel",()=>{this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.appService.getApp().stopRender("virtualwall-drag"),this.handleMoveEnd())});const{appService:i,wallData:s,events:n={}}=e;this.appService=i,this.wallEvents=n,this.wallConfig=this.appService.controlsConfig.virtualWall,this.controlsConfig=this.appService.controlsConfig,this.wallData={...s,points:this.validateAndCorrectWallLength(s.points)},this.throttledHandleScaleChange=At(this.handleScaleChange.bind(this),30,{leading:!0,trailing:!0}),this.throttledUpdateOutline=At(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.registerScaleListener(),this.setupDragEventListeners()}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateOutline),this.appService.emitter.on("antiScale",this.throttledHandleScaleChange),this.appService.emitter.on("mapRotationUpdate",this.throttledUpdateOutline)}validateAndCorrectWallLength(e){if(e.length<2)return e;const[i,s]=e,n=this.appService.metersToPixels(this.wallConfig.minWidth),o=Q(i,s);if(o>=n)return e;if(o===0)return[i,{x:i.x+n,y:i.y}];const a=pt(q(i,s));return[i,{x:i.x+a.x*n,y:i.y+a.y*n}]}isEditingEnabled(){return this.appService.runtimeSnapshot.editingVirtualWallIds.includes(this.wallData.id)}updateOutlineForScale(){this.isEditingEnabled()&&(this.updateOutlineComponents(),this.updateControlButtonsPosition(),this.updateLengthTextPosition())}initializeComponents(){this.outlineBorder=this.createOutlineBorder(),this.addChild(this.outlineBorder),this.createWallLine(!1),this.addChild(this.wallLine),this.lengthText=this.createLengthText(),this.addChild(this.lengthText),this.moveLine=this.createMoveLine(),this.addChild(this.moveLine),this.controlButtons=new L,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.createControlButtons()}createWallLine(e=!0){const{points:i}=this.wallData;if(i.length<2)return;const{lineWidth:s,lineColor:n,editing:o,normal:a}=this.wallConfig,l=this.isEditingEnabled()?o:a;l.isDashed?this.wallLine=new Ue(this.appService,{start:i[0],end:i[1],style:{color:n.toString(),width:s,dashArray:l.dashArray}}):this.wallLine=this.createSolidLine(i[0],i[1],s,n.toString()),e&&this.setupWallLineInteraction()}createLengthText(){const e=this.calculateWallLengthInMeters(),i=this.formatLengthText(e),s=new Ui(this.appService,{text:i,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.wallConfig.textColor,align:"center"}});s.anchor.set(.5);const n=this.calculateTextPosition();s.position.set(n.x,n.y);const o=this.calculateTextRotation();return s.rotation=o,s.eventMode="none",s}calculateWallLengthInMeters(){const{points:e}=this.wallData;if(e.length<2)return 0;const i=Q(e[0],e[1]);return this.appService.pixelsToMeters(i)}formatLengthText(e){const i=this.appService.metersToDisplayUnit(e),s=this.appService.runtimeSnapshot.unitLabel;return`${i.toFixed(1)}${s}`}calculateTextPosition(){const{points:e}=this.wallData;if(e.length<2)return{x:0,y:0};const[i,s]=e,n=this.appService.getApp().toFixedSize(this.wallConfig.textOffset);return Jl(i,s,n)}calculateTextRotation(){const{points:e}=this.wallData;if(e.length<2)return 0;const[i,s]=e,n=this.appService.appContainer.getMapRotationRadians();return Xe(i,s,n)}getOutlineStyle(){return{color:this.wallConfig.outlineStrokeColor,width:this.wallConfig.outlineStrokeWidth,isDashed:this.wallConfig.outlineDashed,dashArray:this.wallConfig.outlineDashArray,fillColor:this.wallConfig.outlineFillColor}}createOutlineBorder(){const e=this.calculateOutlinePoints();return new Nt(this.appService,{points:e,closePath:!0,style:this.getOutlineStyle()})}createMoveLine(){const e=this.calculateOutlinePoints(),i=this.calculateMoveLinePoints(e);return new Nt(this.appService,{points:i,closePath:!1,style:this.getOutlineStyle()})}calculateOutlinePoints(e){const i=e||this.wallData.points;if(i.length<2)return i;const s=this.appService.getApp().toFixedSize(this.wallConfig.outlineOffset),n=dy(i[0],i[1],s);return[n[3],n[2],n[1],n[0]]}calculateMoveLinePoints(e){if(e.length<4)return[];const{MOVE:i}=Vt.BUTTON_INDICES,s=e[i],n=this.calculateMoveButtonPosition();return[s,n]}calculateMoveButtonPosition(){const{moveButtonOffset:e}=this.controlsConfig,i=this.calculateOutlinePoints();if(i.length<4)return{x:0,y:0};const{MOVE:s}=Vt.BUTTON_INDICES,n=i[s],o=i[(s+3)%4],a=i[(s+1)%4],h=this.appService.getApp().toFixedSize(e);return Is(n,a,o,h)}createControlButtons(){const e=this.calculateOutlinePoints();if(e.length<4)return;const{REMOVE:i,SCALE:s}=Vt.BUTTON_INDICES;this.removeButton=new Ds(this.appService,{iconAlias:"deleteIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onClick:this.handleRemove}),this.removeButton.position.set(e[i].x,e[i].y),this.scaleButton=new Ze(this.appService,{iconAlias:"scaleIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,getTargetPoints:()=>this.calculateOutlinePoints(),getButtonIndex:()=>s,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(e[s].x,e[s].y);const n=this.calculateMoveButtonPosition();this.moveButton=new Fs(this.appService,{iconAlias:"moveIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(n.x,n.y),this.controlButtons.addChild(this.removeButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton)}applyScaleAndRotation(e){if(this.initialWallPoints.length<2)return;const[i,s]=this.initialWallPoints,n=i,o=this.calculateOutlinePoints(this.initialWallPoints);if(o.length<4)return;const a=o[Vt.BUTTON_INDICES.SCALE],l=q(s,a),c={x:e.x-l.x,y:e.y-l.y},d=q(n,c),u=Q(n,c),p=this.appService.metersToPixels(this.wallConfig.minWidth);let f;if(u<p)if(u===0)f={x:n.x+p,y:n.y};else{const y=pt(d);f={x:n.x+y.x*p,y:n.y+y.y*p}}else f=c;this.wallData.points=[n,f],this.drawVirtualWall(),this.updateControlButtonsPosition()}applyTranslation(e,i){this.wallData.points=this.initialWallPoints.map(s=>({x:s.x+e,y:s.y+i})),this.drawVirtualWall(),this.updateControlButtonsPosition()}drawVirtualWall(){this.updateWallLine(),this.updateLengthText(),this.updateOutlineComponents()}updateWallLine(){const{points:e}=this.wallData;e.length<2||(this.wallLine instanceof Ue?this.wallLine.updatePoints(e[0],e[1]):this.redrawSolidLine(),this.setupWallLineHitArea())}updateLengthText(){if(!this.lengthText)return;const e=this.calculateWallLengthInMeters(),i=this.formatLengthText(e);this.lengthText.updateText(i),this.updateLengthTextPosition()}updateLengthTextPosition(){if(!this.lengthText)return;const e=this.calculateTextPosition();this.lengthText.position.set(e.x,e.y);const i=this.calculateTextRotation();this.lengthText.rotation=i}updateOutlineComponents(){const e=this.calculateOutlinePoints();this.outlineBorder.updatePoints(e);const i=this.calculateMoveLinePoints(e);this.moveLine.updatePoints(i)}updateControlButtonsPosition(){if(!this.removeButton||!this.scaleButton||!this.moveButton)return;const e=this.calculateOutlinePoints();if(e.length<4)return;const{REMOVE:i,SCALE:s}=Vt.BUTTON_INDICES,n=this.calculateMoveButtonPosition();this.removeButton.position.set(e[i].x,e[i].y),this.scaleButton.position.set(e[s].x,e[s].y),this.moveButton.position.set(n.x,n.y)}updateEditState(){const e=this.isEditingEnabled();this.controlButtons.visible=e,this.outlineBorder.visible=e,this.moveLine.visible=e,this.lengthText&&(this.lengthText.visible=e),e&&(this.updateOutlineComponents(),this.updateControlButtonsPosition(),this.updateLengthTextPosition()),this.updateWallLineStyle(),this.setupWallLineInteraction(),this.zIndex=e?1e3:0}createSolidLine(e,i,s,n){const o=new H;o.eventMode="static";const a=this.appService.getApp().toFixedSize(s);return o.moveTo(e.x,e.y),o.lineTo(i.x,i.y),o.stroke({color:n,width:a}),o}updateWallLineStyle(){const e=this.isEditingEnabled(),{editing:i,normal:s,lineWidth:n,lineColor:o}=this.wallConfig,a=e?i:s;this.wallLine instanceof Ue!==a.isDashed?(this.removeChild(this.wallLine),this.wallLine.destroy(),this.createWallLine(!1),this.addChild(this.wallLine)):this.wallLine instanceof Ue?this.wallLine.updateStyle({color:o.toString(),width:n,dashArray:a.dashArray}):this.redrawSolidLine()}redrawSolidLine(){const e=this.appService;if(!this.wallLine||this.wallLine instanceof Ue)return;const{points:i}=this.wallData;if(i.length<2)return;const{lineWidth:s,lineColor:n}=this.wallConfig,o=e.getApp().toFixedSize(s);this.wallLine.clear(),this.wallLine.setStrokeStyle({color:n.toString(),width:o}).moveTo(i[0].x,i[0].y).lineTo(i[1].x,i[1].y).stroke()}setupWallLineInteraction(){var i;if(!this.wallLine)return;this.setupWallLineHitArea();const e=this.isEditingEnabled();(i=this.wallLineClickHandler)==null||i.destroy(),this.wallLineClickHandler=null,this.wallLine.off("pointerdown",this.handleWallLinePointerDown),e?this.wallLine.on("pointerdown",this.handleWallLinePointerDown):this.wallLineClickHandler=new vt(this.wallLine,{onClick:()=>{var s,n;this.appService.emitter.emit("suppressMapClick"),(n=(s=this.wallEvents)==null?void 0:s.onClick)==null||n.call(s,this.getWallData())},stopPropagation:!1})}setupDragEventListeners(){const{emitter:e}=this.appService;e.on("gestureHijackPointerMove",this.handleDragPointerMove),e.on("gestureHijackPointerUp",this.handleDragPointerUp),e.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:e}=this.appService;e.off("gestureHijackPointerMove",this.handleDragPointerMove),e.off("gestureHijackPointerUp",this.handleDragPointerUp),e.off("gestureHijackCancel",this.handleDragCancel)}startDragging(e){const i=this.appService;this.isDragging=!0;const s=this.parent.toLocal(e.global);this.dragStartPosition={x:s.x,y:s.y},this.initializeOperation(),i.getApp().requestRender("virtualwall-drag",!0),this.appService.emitter.emit("gestureHijackStart",e)}getDragStartPosition(){return this.dragStartPosition}setupWallLineHitArea(){if(!this.wallLine)return;const{points:e}=this.wallData;if(e.length<2)return;const{hitAreaThickness:i}=this.wallConfig,s=this.appService.getApp().toFixedSize(i),n=tc(e[0],e[1],s);if(n.length===0)return;const o=new Te(n);this.wallLine.hitArea=o}getWallData(){return{...this.wallData}}updateWallData(e){this.wallData={...e,points:this.validateAndCorrectWallLength(e.points)},this.drawVirtualWall(),this.updateControlButtonsPosition()}updateEditingState(){this.updateEditState()}refreshDisplay(){this.drawVirtualWall()}destroy(){var e,i,s,n,o,a,h,l,c;this.appService.emitter.off("antiScale",this.throttledUpdateOutline),this.appService.emitter.off("antiScale",this.throttledHandleScaleChange),this.appService.emitter.off("mapRotationUpdate",this.throttledUpdateOutline),this.cleanupDragEventListeners(),this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.wallLine&&this.wallLine.off("pointerdown",this.handleWallLinePointerDown),(e=this.wallLineClickHandler)==null||e.destroy(),this.wallLineClickHandler=null,(i=this.wallLine)==null||i.destroy(),(s=this.lengthText)==null||s.destroy(),(n=this.outlineBorder)==null||n.destroy(),(o=this.moveLine)==null||o.destroy(),(a=this.controlButtons)==null||a.destroy(),(h=this.removeButton)==null||h.destroy(),(l=this.scaleButton)==null||l.destroy(),(c=this.moveButton)==null||c.destroy(),this.removeButton=null,this.scaleButton=null,this.moveButton=null,super.destroy()}};g(Vt,"BUTTON_INDICES",{REMOVE:0,SCALE:2,MOVE:3});let nr=Vt;class Ur extends L{constructor(e){super();g(this,"spotData");g(this,"spotConfig");g(this,"controlsConfig");g(this,"spotEvents");g(this,"appService");g(this,"controlFill");g(this,"spotBorder");g(this,"centerIcon");g(this,"sizeText");g(this,"clickHandler",null);g(this,"initialSpotPoint",null);g(this,"dragStartMousePosition",null);g(this,"throttledUpdateScale");g(this,"unsubscribeMapRotation",null);g(this,"handleDragStart",e=>{this.isEditingEnabled()&&(this.initialSpotPoint={...this.spotData.point},this.dragStartMousePosition=this.parent.toLocal(e.global),this.appService.getApp().requestRender("spot-drag",!0))});g(this,"handleDragMove",e=>{if(!this.isEditingEnabled()||!this.initialSpotPoint||!this.dragStartMousePosition||!this.controlFill)return;const i=this.parent.toLocal(e.global),s=i.x-this.dragStartMousePosition.x,n=i.y-this.dragStartMousePosition.y;this.applyTranslation(s,n)});g(this,"handleDragEnd",()=>{var e,i;this.initialSpotPoint=null,this.dragStartMousePosition=null,this.appService.getApp().stopRender("spot-drag"),(i=(e=this.spotEvents).onUpdate)==null||i.call(e,this.getSpotData())});const{appService:i,spotData:s,events:n={}}=e;this.appService=i,this.spotData=s,this.spotEvents=n,this.controlsConfig=this.appService.controlsConfig,this.spotConfig=this.appService.controlsConfig.spot,this.position.set(s.point.x,s.point.y),this.throttledUpdateScale=At(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}updateScale(){this.isEditingEnabled()&&this.sizeText&&this.updateSizeTextPosition()}isEditingEnabled(){return this.appService.runtimeSnapshot.editingSpotIds.includes(this.spotData.id)}shouldShowIcon(){return(this.isEditingEnabled()?this.spotConfig.editing:this.spotConfig.normal).showIcon}calculateRectanglePoints(){const{size:e}=this.spotConfig;if(e===0)return[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}];const s=this.appService.metersToPixels(e)/2;return[{x:-s,y:-s},{x:s,y:-s},{x:s,y:s},{x:-s,y:s}]}initializeComponents(){const e=this.calculateRectanglePoints();this.spotConfig.size>0&&(this.controlFill=this.createControlFill(e),this.addChild(this.controlFill),this.spotBorder=this.createBorder(e),this.addChild(this.spotBorder)),this.centerIcon=this.createCenterIcon(),this.addChild(this.centerIcon),this.spotConfig.showText&&(this.sizeText=this.createSizeText(),this.addChild(this.sizeText)),this.drawSpot()}createControlFill(e){const i=this.isEditingEnabled();return new Lr(this.appService,{points:e,fillColor:this.spotConfig.fillColor,enableInteraction:i,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createBorder(e){const s=this.isEditingEnabled()?this.spotConfig.editing:this.spotConfig.normal;return new Nt(this.appService,{points:e,closePath:!0,style:{color:this.spotConfig.strokeColor,width:this.spotConfig.strokeWidth,isDashed:s.isDashed,dashArray:s.dashArray}})}createCenterIcon(){const e=new Xt(this.appService);return this.loadIconTexture(e),e.position.set(0,0),e.eventMode="static",this.setupIconDrag(e),e.visible=!1,e}async loadIconTexture(e){const{iconSize:i,iconSizeFixed:s}=this.spotConfig;await e.loadTextureAndSetSize("spotIcon",{width:i,height:i,sizeFixed:s}),this.applyAntiRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation||(this.unsubscribeMapRotation=U(this.appService.runtime,"mapRotation",n=>{this.applyAntiRotation(n)})),e.visible=this.shouldShowIcon()}applyAntiRotation(e){const i=-e*Math.PI/180;this.rotation=i}setupIconDrag(e){let i=null,s=!1;const n=h=>{if(!s||!this.initialSpotPoint||!i)return;const l=this.parent.toLocal(h.global),c=l.x-i.x,d=l.y-i.y;this.applyTranslation(c,d)},o=()=>{s&&(s=!1,this.initialSpotPoint=null,i=null,this.appService.getApp().stopRender("spot-drag"),this.appService.emitter.off("gestureHijackPointerMove",n),this.appService.emitter.off("gestureHijackPointerUp",a),this.appService.emitter.off("gestureHijackCancel",o))},a=()=>{var h,l;s&&(s=!1,this.initialSpotPoint=null,i=null,this.appService.getApp().stopRender("spot-drag"),(l=(h=this.spotEvents).onUpdate)==null||l.call(h,this.getSpotData()),this.appService.emitter.off("gestureHijackPointerMove",n),this.appService.emitter.off("gestureHijackPointerUp",a),this.appService.emitter.off("gestureHijackCancel",o))};e.on("pointerdown",h=>{this.isEditingEnabled()&&(h.stopPropagation(),s=!0,this.initialSpotPoint={...this.spotData.point},i=this.parent.toLocal(h.global),this.appService.getApp().requestRender("spot-drag",!0),this.appService.emitter.emit("gestureHijackStart",h),this.appService.emitter.on("gestureHijackPointerMove",n),this.appService.emitter.on("gestureHijackPointerUp",a),this.appService.emitter.on("gestureHijackCancel",o))})}createSizeText(){const e=this.calculateSpotSizeText(),i=new Ui(this.appService,{text:e,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.spotConfig.textColor,align:"center"}});i.anchor.set(.5);const s=this.calculateSizeTextPosition();return i.position.set(s.x,s.y),i.eventMode="none",i}calculateSpotSizeText(){const{size:e}=this.spotConfig,i=this.appService.metersToDisplayUnit(e),s=this.appService.runtimeSnapshot.unitLabel;return`${i.toFixed(1)}${s}*${i.toFixed(1)}${s}`}calculateSizeTextPosition(){const e=this.calculateRectanglePoints();if(e.length<4)return{x:0,y:0};const[i,s,n,o]=e,{textPosition:a,textOffset:h}=this.spotConfig,l=this.appService.getApp().toFixedSize(h);let c,d;switch(a){case"top":{c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},d={x:c.x,y:c.y+l};break}case"right":{c={x:(s.x+n.x)/2,y:(s.y+n.y)/2},d={x:c.x+l,y:c.y};break}case"bottom":{c={x:(o.x+n.x)/2,y:(o.y+n.y)/2},d={x:c.x,y:c.y+l};break}case"left":{c={x:(i.x+o.x)/2,y:(i.y+o.y)/2},d={x:c.x-l,y:c.y};break}default:{c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},d={x:c.x,y:c.y+l};break}}return d}applyTranslation(e,i){this.initialSpotPoint&&(this.spotData.point={x:this.initialSpotPoint.x+e,y:this.initialSpotPoint.y+i},this.drawSpot())}setupClickHandler(){const e=this.spotConfig.size>0?this:this.centerIcon;this.clickHandler=new vt(e,{onClick:()=>{var i,s;this.isEditingEnabled()||(this.appService.emitter.emit("suppressMapClick"),(s=(i=this.spotEvents)==null?void 0:i.onClick)==null||s.call(i,this.getSpotData()))},stopPropagation:!1}),this.eventMode="static"}drawSpot(){const e=this.calculateRectanglePoints();this.position.set(this.spotData.point.x,this.spotData.point.y),this.spotConfig.size>0&&(this.controlFill&&this.controlFill.updatePoints(e),this.spotBorder&&this.spotBorder.updatePoints(e)),this.spotConfig.showText&&this.sizeText&&this.updateSizeText()}updateSizeText(){if(!this.sizeText)return;const e=this.calculateSpotSizeText();this.sizeText.updateText(e),this.updateSizeTextPosition()}updateSizeTextPosition(){if(!this.sizeText)return;const e=this.calculateSizeTextPosition();this.sizeText.position.set(e.x,e.y)}updateEditState(){const e=this.isEditingEnabled(),i=e?this.spotConfig.editing:this.spotConfig.normal;this.sizeText&&(this.sizeText.visible=e&&this.spotConfig.showText),this.centerIcon&&(this.centerIcon.visible=this.shouldShowIcon()),this.controlFill&&(this.controlFill.setInteractionEnabled(e),this.controlFill.visible=i.showFrame),this.spotBorder&&(this.spotBorder.updateStyle({isDashed:i.isDashed,dashArray:i.dashArray}),this.spotBorder.visible=i.showFrame),this.zIndex=e?1e3:0}updateSpotData(e){this.spotData={...e},this.drawSpot(),this.updateEditState()}getSpotData(){return{...this.spotData}}refreshDisplay(){this.drawSpot()}destroy(){var e,i,s,n,o;this.appService.emitter.off("antiScale",this.throttledUpdateScale),this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),(e=this.clickHandler)==null||e.destroy(),this.clickHandler=null,this.centerIcon&&this.spotConfig.size===0&&this.centerIcon.removeAllListeners(),(i=this.controlFill)==null||i.destroy(),(s=this.spotBorder)==null||s.destroy(),(n=this.centerIcon)==null||n.destroy(),(o=this.sizeText)==null||o.destroy(),super.destroy()}static create(e,i){return new Ur({appService:e,spotData:i,events:{onUpdate:s=>{var n,o;(o=(n=e.events)==null?void 0:n.onUpdateSpot)==null||o.call(n,s)},onClick:s=>{var n,o;(o=(n=e.events)==null?void 0:n.onClickSpot)==null||o.call(n,s)}}})}}class $x extends pc{constructor(e){const{appService:i,wayPointData:s,order:n,events:o={}}=e;super(i);g(this,"wayPointData");g(this,"order");g(this,"wayPointConfig");g(this,"controlsConfig");g(this,"wayPointEvents");g(this,"icon");g(this,"orderContainer");g(this,"orderBackground");g(this,"orderText");g(this,"clickHandler",null);g(this,"initialWayPointPoint",null);g(this,"unsubscribeMapRotation",null);this.wayPointData=s,this.order=n,this.wayPointEvents=o,this.controlsConfig=this.appService.controlsConfig,this.wayPointConfig=this.appService.controlsConfig.wayPoint,this.position.set(s.point.x,s.point.y),this.initializeComponents(),this.updateEditState(),this.setupClickHandler()}isEditingEnabled(){return(this.appService.runtimeSnapshot.editingWayPointIds||[]).includes(this.wayPointData.id)}initializeComponents(){this.icon=this.createIcon(),this.addChild(this.icon),this.wayPointConfig.showOrder&&(this.createOrderContainer(),this.addChild(this.orderContainer))}createIcon(){const e=new Xt(this.appService);return this.loadIconTexture(e),e.position.set(0,0),e.anchor.set(.5,1),e.eventMode="static",this.setupIconDrag(e),e}async loadIconTexture(e){const i=this.isEditingEnabled(),s=i?this.wayPointConfig.editing:this.wayPointConfig.normal,{iconSize:n}=s,o=i?"wayPointActive":"wayPoint";await e.loadTextureAndSetSize(o,{width:n,height:n,sizeFixed:!1}),this.applyAntiRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation||(this.unsubscribeMapRotation=U(this.appService.runtime,"mapRotation",a=>{this.applyAntiRotation(a)})),e.visible=!0,this.orderContainer&&this.updateOrderPosition()}applyAntiRotation(e){const i=-e*Math.PI/180;this.rotation=i}createOrderContainer(){const i=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal,{orderContainer:s,orderText:n}=i;this.orderContainer=new L,this.orderBackground=new H,this.orderText=new Es({text:this.order.toString(),style:new de({fontSize:n.fontSize,fontFamily:n.fontFamily,fontWeight:n.fontWeight,fill:n.color,align:"center",trim:!0})}),this.orderBackground.clear(),this.orderBackground.circle(0,0,s.size/2),this.orderBackground.fill({color:s.backgroundColor}),this.orderText.anchor.set(.5,.5),this.orderContainer.addChild(this.orderBackground),this.orderContainer.addChild(this.orderText),this.orderContainer.eventMode="none",this.orderContainer.visible=this.wayPointConfig.showOrder,this.updateOrderPosition()}updateOrderPosition(){if(!this.orderContainer)return;const i=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal,{offsetX:s,offsetY:n}=i.orderContainer;this.orderContainer.position.set(s,-n)}setupIconDrag(e){let i=null,s=null,n=!1;const o=h=>{if(!(!n||!i||!s)&&this.parent){const l=this.parent.toLocal(h.global),c=l.x-i.x,d=l.y-i.y,u={x:s.x+c,y:s.y+d};this.wayPointData.point=u,this.position.set(u.x,u.y),this.orderContainer&&this.updateOrderPosition()}},a=()=>{var h,l;n&&(n=!1,i=null,s=null,(l=(h=this.wayPointEvents).onUpdate)==null||l.call(h,this.wayPointData),this.appService.emitter.off("gestureHijackPointerMove",o),this.appService.emitter.off("gestureHijackPointerUp",a),this.appService.emitter.emit("gestureHijackCancel"))};e.on("pointerdown",h=>{this.isEditingEnabled()&&(h.stopPropagation(),s={...this.wayPointData.point},this.parent&&(i=this.parent.toLocal(h.global)),n=!0,this.parent&&(this.appService.emitter.emit("gestureHijackStart",h),this.appService.emitter.on("gestureHijackPointerMove",o),this.appService.emitter.on("gestureHijackPointerUp",a)))})}setupClickHandler(){this.clickHandler=new vt(this.icon,{stopPropagation:!1,onClick:()=>{var e,i;this.appService.emitter.emit("suppressMapClick"),(i=(e=this.wayPointEvents).onClick)==null||i.call(e,this.wayPointData)}})}updateWayPoint(e){this.wayPointData=e,this.drawWayPoint()}updateOrder(e){this.order=e,this.orderText&&(this.orderText.text=e.toString())}getWayPointData(){return{...this.wayPointData}}drawWayPoint(){this.position.set(this.wayPointData.point.x,this.wayPointData.point.y),this.orderContainer&&this.updateOrderPosition()}updateEditState(){if(this.loadIconTexture(this.icon),this.orderContainer&&this.orderText&&this.orderBackground){const i=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal;this.orderText.style=new de({fontSize:i.orderText.fontSize,fontFamily:i.orderText.fontFamily,fontWeight:i.orderText.fontWeight,fill:i.orderText.color,align:"center",trim:!0});const{size:s,backgroundColor:n}=i.orderContainer;this.orderBackground.clear(),this.orderBackground.circle(0,0,s/2).fill(n),this.orderContainer.visible=this.wayPointConfig.showOrder,this.updateOrderPosition()}}onEditStateChange(){this.updateEditState()}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.icon&&this.icon.removeAllListeners(),super.destroy()}}class Ya extends H{constructor(e,i){super();g(this,"isDragging",!1);g(this,"dragStartPosition",null);g(this,"initialPosition");g(this,"handleDragPointerMove",e=>{var a,h;if(!this.isDragging||!this.dragStartPosition)return;const i=this.parent.toLocal(e.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y,o={x:this.initialPosition.x+s,y:this.initialPosition.y+n};this.position.set(o.x,o.y),(h=(a=this.options).onDragMove)==null||h.call(a,o)});g(this,"handleDragPointerUp",()=>{var i,s;if(!this.isDragging)return;const e=this.appService;this.isDragging=!1,this.dragStartPosition=null,e.getApp().stopRender("endpoint-drag"),(s=(i=this.options).onDragEnd)==null||s.call(i)});g(this,"handleDragCancel",()=>{var i,s;if(!this.isDragging)return;const e=this.appService;this.isDragging=!1,this.dragStartPosition=null,e.getApp().stopRender("endpoint-drag"),(s=(i=this.options).onDragEnd)==null||s.call(i)});this.appService=e,this.options=i,this.initialPosition={...i.position},this.position.set(i.position.x,i.position.y),this.eventMode="static",this.cursor="pointer",this.setupEvents(),this.draw(),this.setupDragEventListeners()}draw(){const e=this.appService,{config:i}=this.options,s=e.getApp().toFixedSize(i.endPointSize),n=e.getApp().toFixedSize(i.endPointStrokeWidth);this.clear(),this.circle(0,0,s/2),this.fill({color:i.endPointColor}),this.stroke({color:i.endPointStrokeColor,width:n}),this.setupHitArea()}setupHitArea(){const e=this.appService,{config:i}=this.options,s=Math.max(i.endPointSize/2+10,20),n=e.getApp().toFixedSize(s);this.hitArea=new Ts(0,0,n)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}setupDragEventListeners(){const{emitter:e}=this.appService;e.on("gestureHijackPointerMove",this.handleDragPointerMove),e.on("gestureHijackPointerUp",this.handleDragPointerUp),e.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:e}=this.appService;e.off("gestureHijackPointerMove",this.handleDragPointerMove),e.off("gestureHijackPointerUp",this.handleDragPointerUp),e.off("gestureHijackCancel",this.handleDragCancel)}handlePointerDown(e){e.stopPropagation(),this.startDragging(e)}startDragging(e){var s,n;const i=this.appService;this.isDragging=!0,this.dragStartPosition=this.parent.toLocal(e.global),this.initialPosition={x:this.x,y:this.y},(n=(s=this.options).onDragStart)==null||n.call(s),i.getApp().requestRender("endpoint-drag",!0),this.appService.emitter.emit("gestureHijackStart",e)}updatePosition(e){this.position.set(e.x,e.y),this.initialPosition={...e}}getPosition(){return{x:this.x,y:this.y}}redraw(){this.draw()}destroy(){this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.cleanupDragEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Qx extends L{constructor(e){super();g(this,"endPoints");g(this,"dividerConfig");g(this,"dividerEvents");g(this,"roomId");g(this,"appService");g(this,"roomGeometry",null);g(this,"dashLine");g(this,"solidLine",null);g(this,"startEndPoint");g(this,"endEndPoint");g(this,"solidLinePoints",null);g(this,"initialDividerPoints",[]);g(this,"isDragging",!1);g(this,"dragStartPosition",null);g(this,"throttledHandleScaleChange");g(this,"handleEndPointDragStart",()=>{this.initialDividerPoints=this.endPoints.map(e=>({...e})),this.clearSolidLine(),this.appService.getApp().requestRender("divider-endpoint-drag",!0)});g(this,"handleEndPointDragMove",(e,i)=>{this.initialDividerPoints.length!==0&&(this.endPoints[e]=i,this.updateDashLine(),this.updateSolidLine(),this.setupDashLineHitArea())});g(this,"handleEndPointDragEnd",()=>{var e,i;this.initialDividerPoints=[],this.appService.getApp().stopRender("divider-endpoint-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),(i=(e=this.dividerEvents).onUpdate)==null||i.call(e,this.getDividerEndPoints())});g(this,"handleDashLinePointerDown",e=>{e.stopPropagation(),this.startDragging(e)});g(this,"handleDragPointerMove",e=>{if(!this.isDragging||!this.dragStartPosition||this.initialDividerPoints.length===0)return;const i=this.parent.toLocal(e.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y;this.endPoints=this.initialDividerPoints.map(o=>({x:o.x+s,y:o.y+n})),this.updateAllComponents()});g(this,"handleDragPointerUp",()=>{var e,i;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],this.appService.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),(i=(e=this.dividerEvents).onUpdate)==null||i.call(e,this.getDividerEndPoints()))});g(this,"handleDragCancel",()=>{var e,i;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],this.appService.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),(i=(e=this.dividerEvents).onUpdate)==null||i.call(e,this.getDividerEndPoints()))});g(this,"handleScaleChange",()=>{var e,i;(e=this.startEndPoint)==null||e.redraw(),(i=this.endEndPoint)==null||i.redraw(),this.updateSolidLine(),this.setupDashLineHitArea()});const{appService:i,endPoints:s,roomId:n,events:o={}}=e;this.appService=i,this.dividerEvents=o,this.roomId=n,this.dividerConfig=this.appService.dividerConfig,this.roomGeometry=this.appService.mapManager.getRoomById(this.roomId)||null,s?this.endPoints=this.validateDividerPoints(s):this.endPoints=this.createDefaultdividerPoints(),this.throttledHandleScaleChange=At(this.handleScaleChange.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.calculateAndCreateSolidLine(),this.registerScaleListener(),this.setupDragEventListeners()}validateDividerPoints(e){if(e.length>=2)return e.slice(0,2);const i=e[0]||{x:0,y:0},s={x:i.x+50,y:i.y};return[i,s]}createDefaultdividerPoints(){if(!this.roomGeometry)return A.warn("Room geometry not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const e=this.appService.getApp().mapState;if(!e)return A.warn("Map state not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const{boundingBox:i}=this.roomGeometry,s=this.appService.getApp().toFixedSize(this.dividerConfig.defaultExtension),n=this.dividerConfig.defaultDirection,o=i.x+i.width/2,a=i.y+i.height/2,h=n==="horizontal"?i.width+2*s:i.height+2*s;return Sy(o,a,h,n).map(c=>({x:c.x-e.origin.x,y:c.y-e.origin.y}))}initializeComponents(){this.createDashLine(),this.addChild(this.dashLine),this.createEndPoints(),this.addChild(this.startEndPoint),this.addChild(this.endEndPoint),this.setupDashLineInteraction()}createDashLine(){const e=this.endPoints;if(e.length<2)return;const{dashLineWidth:i,dashLineDashArray:s,lineColor:n}=this.dividerConfig;this.dashLine=new Ue(this.appService,{start:e[0],end:e[1],style:{color:n.toString(),width:i,dashArray:s}})}createEndPoints(){const e=this.endPoints;this.startEndPoint=new Ya(this.appService,{position:e[0],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:i=>this.handleEndPointDragMove(0,i),onDragEnd:this.handleEndPointDragEnd}),this.endEndPoint=new Ya(this.appService,{position:e[1],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:i=>this.handleEndPointDragMove(1,i),onDragEnd:this.handleEndPointDragEnd})}setupDashLineInteraction(){this.dashLine&&(this.setupDashLineHitArea(),this.dashLine.off("pointerdown",this.handleDashLinePointerDown),this.dashLine.on("pointerdown",this.handleDashLinePointerDown))}setupDashLineHitArea(){if(!this.dashLine)return;const e=this.endPoints;if(e.length<2)return;const{hitAreaThickness:i}=this.dividerConfig,s=this.appService.getApp().toFixedSize(i),n=tc(e[0],e[1],s);if(n.length===0)return;const o=new Te(n);this.dashLine.hitArea=o}startDragging(e){this.isDragging=!0;const i=this.parent.toLocal(e.global);this.dragStartPosition={x:i.x,y:i.y},this.initialDividerPoints=this.endPoints.map(s=>({...s})),this.clearSolidLine(),this.appService.getApp().requestRender("divider-drag",!0),this.appService.emitter.emit("gestureHijackStart",e)}setupDragEventListeners(){const{emitter:e}=this.appService;e.on("gestureHijackPointerMove",this.handleDragPointerMove),e.on("gestureHijackPointerUp",this.handleDragPointerUp),e.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:e}=this.appService;e.off("gestureHijackPointerMove",this.handleDragPointerMove),e.off("gestureHijackPointerUp",this.handleDragPointerUp),e.off("gestureHijackCancel",this.handleDragCancel)}updateAllComponents(){this.updateDashLine(),this.updateSolidLine(),this.updateEndPoints(),this.setupDashLineHitArea()}updateDashLine(){const e=this.endPoints;e.length<2||!this.dashLine||this.dashLine.updatePoints(e[0],e[1])}updateSolidLine(){if(!this.solidLine||!this.solidLinePoints)return;const{solidLineWidth:e,lineColor:i}=this.dividerConfig,s=this.appService.getApp().toFixedSize(e);this.solidLine.clear(),this.solidLine.setStrokeStyle({color:i.toString(),width:s}).moveTo(this.solidLinePoints[0].x,this.solidLinePoints[0].y).lineTo(this.solidLinePoints[1].x,this.solidLinePoints[1].y).stroke()}updateEndPoints(){const e=this.endPoints;this.startEndPoint&&this.startEndPoint.updatePosition(e[0]),this.endEndPoint&&this.endEndPoint.updatePosition(e[1])}registerScaleListener(){const{emitter:e}=this.appService;e.on("antiScale",this.throttledHandleScaleChange)}getDividerEndPoints(){return[...this.endPoints]}getEffectiveDividerPoints(){return this.solidLinePoints?[...this.solidLinePoints]:null}calculateAndCreateSolidLine(){if(this.clearSolidLine(),typeof this.roomId!="number"||!this.getRoomGraphics())return;const i=this.calculateLineRoomIntersection();i&&i.length>=2&&(this.solidLinePoints=[i[0],i[i.length-1]],this.createSolidLine())}getRoomGraphics(){const e=this.appService.mapManager.roomFill;return!e||typeof this.roomId!="number"?null:e.getRoomGraphicsMap().get(this.roomId)||null}calculateLineRoomIntersection(){const e=this.endPoints;if(e.length<2||typeof this.roomId!="number")return null;const[i,s]=e,n=this.isPointInRoomFill(i),o=this.isPointInRoomFill(s);if(n||o)return null;const a=oy(i,s),h=[];for(const p of a)this.isPointInRoomFill(p)&&h.push(p);if(h.length===0)return null;const l=h[0],c=h[h.length-1];return Q(l,c)<3?null:vy(l,c,.5)}isPointInRoomFill(e){if(typeof this.roomId!="number")return!1;const i=this.appService.getApp().mapState;if(!i)return!1;const s={x:e.x+i.origin.x,y:e.y+i.origin.y};return i.mapType==="raster"?this.isPointInRasterRoomFill(s):this.isPointInStructuredRoomFill(s)}isPointInRasterRoomFill(e){e.x-=.5,e.y-=.5;const i=this.appService.getApp().mapState,s=this.appService.mapManager.roomFill;if(!i||!s)return!1;const n=s.getRasterRoomData(this.roomId);if(!n)return!1;const o=s.getMapWidth();if(o===0)return!1;const a=Math.round(e.x),h=Math.round(e.y);if(a<0||h<0||a>=o)return!1;const l=h*o+a;for(let c=0;c<n.pixelIndices.length;c++)if(n.pixelIndices[c]===l)return!0;return!1}isPointInStructuredRoomFill(e){const i={x:Math.round(e.x),y:Math.round(e.y)},s=this.appService.getApp().mapState,n=this.appService.mapManager.getRoomById(this.roomId);return!s||!n||!n.outlinePoints?!1:Rt(i,n.outlinePoints,!0)}isDividerCompletelyOutOfRoom(){if(!this.roomGeometry)return!1;const{boundingBox:e}=this.roomGeometry,i=this.endPoints;if(i.length<2)return!1;const s=this.appService.getApp().mapState;if(!s)return!1;const n={x:i[0].x+s.origin.x,y:i[0].y+s.origin.y},o={x:i[1].x+s.origin.x,y:i[1].y+s.origin.y};return!xy(n,o,e.x,e.y,e.width,e.height)}checkAndResetIfOutOfRoom(){const{resetDividerWhenOutOfRoom:e}=this.appService.dividerConfig;e&&this.isDividerCompletelyOutOfRoom()&&this.resetToDefaultState()}resetToDefaultState(){var e,i;this.endPoints=this.createDefaultdividerPoints(),this.calculateAndCreateSolidLine(),this.updateComponents(),(i=(e=this.dividerEvents).onUpdate)==null||i.call(e,this.endPoints)}updateComponents(){const e=this.endPoints;e.length>=2&&(this.dashLine.updatePoints(e[0],e[1]),this.startEndPoint.position.set(e[0].x,e[0].y),this.endEndPoint.position.set(e[1].x,e[1].y),this.setupDashLineInteraction())}createSolidLine(){if(!this.solidLinePoints)return;const{solidLineWidth:e,lineColor:i}=this.dividerConfig;this.solidLine=new H,this.solidLine.eventMode="none";const s=this.appService.getApp().toFixedSize(e);this.solidLine.setStrokeStyle({color:i.toString(),width:s}).moveTo(this.solidLinePoints[0].x,this.solidLinePoints[0].y).lineTo(this.solidLinePoints[1].x,this.solidLinePoints[1].y).stroke(),this.addChildAt(this.solidLine,0)}clearSolidLine(){this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy(),this.solidLine=null),this.solidLinePoints=null}updatedividerPoints(e){this.endPoints=this.validateDividerPoints(e),this.updateAllComponents(),this.calculateAndCreateSolidLine()}destroy(){var e,i,s;this.appService.emitter.off("antiScale",this.throttledHandleScaleChange),this.cleanupDragEventListeners(),this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[]),this.dashLine&&this.dashLine.off("pointerdown",this.handleDashLinePointerDown),this.clearSolidLine(),(e=this.dashLine)==null||e.destroy(),(i=this.startEndPoint)==null||i.destroy(),(s=this.endEndPoint)==null||s.destroy(),super.destroy()}}const ps=["forbiddenSweepZone","forbiddenMopZone","cleanZone","virtualWall","spot","wayPoint","divider"];function Jx(r){if(!r||r.length===0)return[...ps];const t=new Set,e=[];for(const i of r){if(!ps.includes(i)){A.warn(`[ControlsManager] Unknown control render order item: ${i}`);continue}t.has(i)||(t.add(i),e.push(i))}for(const i of ps)t.has(i)||e.push(i);return e}class t0{constructor(t){g(this,"forbiddenSweepZoneMap",new Map);g(this,"forbiddenMopZoneMap",new Map);g(this,"cleanZoneMap",new Map);g(this,"virtualWallMap",new Map);g(this,"spotMap",new Map);g(this,"wayPointMap",new Map);g(this,"divider",null);g(this,"controlContainers",new Map);g(this,"unsubscribeFns",[]);this.appService=t,this.initializeControlContainers();const e=U(t.runtime,"editingForbiddenSweepZoneIds",d=>{A.log(`[runtime] editingForbiddenSweepZoneIds: ${d}`),this.updateZonesEditState(this.forbiddenSweepZoneMap)}),i=U(t.runtime,"editingForbiddenMopZoneIds",d=>{A.log(`[runtime] editingForbiddenMopZoneIds: ${d}`),this.updateZonesEditState(this.forbiddenMopZoneMap)}),s=U(t.runtime,"editingCleanZoneIds",d=>{A.log(`[runtime] editingCleanZoneIds: ${d}`),this.updateZonesEditState(this.cleanZoneMap)}),n=U(t.runtime,"editingVirtualWallIds",d=>{A.log(`[runtime] editingVirtualWallIds: ${d}`),this.updateVirtualWallsEditState(this.virtualWallMap)}),o=U(t.runtime,"editingSpotIds",d=>{A.log(`[runtime] editingSpotIds: ${d}`),this.updateSpotsEditState(this.spotMap)}),a=U(t.runtime,"editingWayPointIds",d=>{A.log(`[runtime] editingWayPointIds: ${d}`),this.updateWayPointsEditState(this.wayPointMap)}),h=U(t.runtime,"dividingRoomId",d=>{A.log(`[runtime] dividingRoomId: ${d}`),this.handleDividingRoomIdChange(d)}),l=U(t.runtime,"unit",d=>{A.log(`[runtime] unit changed: ${d}`),this.handleUnitChange()}),c=U(t.runtime,"unitLabel",d=>{A.log(`[runtime] unitLabel changed: ${d}`),this.handleUnitChange()});this.unsubscribeFns.push(e,i,s,n,o,a,h,l,c)}updatePositionByOrigin(t,e){const s=this.appService.appContainer.getLayer(Ne);s&&s.position.set(t,e)}updateRenderOrder(){this.applyRenderOrder()}initializeControlContainers(){const t=this.appService.appContainer.getLayer(Ne);if(!t){A.warn("[ControlsManager] LAYER_CONTROLS not found during init");return}for(const e of ps){const i=new L;i.label=`controls:${e}`,this.controlContainers.set(e,i),t.addChild(i)}this.applyRenderOrder()}applyRenderOrder(){const t=this.appService.appContainer.getLayer(Ne);if(!t)return;Jx(this.appService.getConfig().controls.renderOrder).forEach((i,s)=>{const n=this.controlContainers.get(i);n&&(n.zIndex=s)}),t.sortableChildren=!0,t.sortChildren()}addToControlLayer(t,e){let i=this.controlContainers.get(t);if(!i){const s=this.appService.appContainer.getLayer(Ne);if(!s){A.warn("[ControlsManager] LAYER_CONTROLS not found");return}i=new L,i.label=`controls:${t}`,this.controlContainers.set(t,i),s.addChild(i),this.applyRenderOrder()}i.addChild(e)}drawForbiddenSweepZones(t){this.drawZones(t,this.forbiddenSweepZoneMap,e=>Or.create(this.appService,e),"forbiddenSweepZone")}getForbiddenSweepZones(){return this.getZonesData(this.forbiddenSweepZoneMap)}clearAllForbiddenSweepZones(){this.clearAllZones(this.forbiddenSweepZoneMap)}drawForbiddenMopZones(t){this.drawZones(t,this.forbiddenMopZoneMap,e=>Gr.create(this.appService,e),"forbiddenMopZone")}getForbiddenMopZones(){return this.getZonesData(this.forbiddenMopZoneMap)}clearAllForbiddenMopZones(){this.clearAllZones(this.forbiddenMopZoneMap)}drawCleanZones(t){this.drawZones(t,this.cleanZoneMap,e=>Wr.create(this.appService,e),"cleanZone")}getCleanZones(){return this.getZonesData(this.cleanZoneMap)}clearAllCleanZones(){this.clearAllZones(this.cleanZoneMap)}drawVirtualWalls(t){var n;const e=this.appService,i=this.virtualWallMap,s=new Set(t.map(o=>o.id));for(const[o,a]of i)s.has(o)||((n=a.parent)==null||n.removeChild(a),a.destroy(),i.delete(o));t.forEach(o=>{const a=i.get(o.id);if(a)this.isWallDataEqual(a.getWallData(),o)||a.updateWallData(o);else{const h=new nr({appService:e,wallData:o,events:{onRemove:l=>{var c,d;(d=(c=e.events)==null?void 0:c.onRemoveVirtualWall)==null||d.call(c,l)},onUpdate:l=>{var c,d;(d=(c=e.events)==null?void 0:c.onUpdateVirtualWall)==null||d.call(c,l)},onClick:l=>{var c,d;(d=(c=e.events)==null?void 0:c.onClickVirtualWall)==null||d.call(c,l)}}});i.set(o.id,h),this.addToControlLayer("virtualWall",h)}})}getVirtualWalls(){return this.getWallsData(this.virtualWallMap)}clearAllVirtualWalls(){this.clearAllWalls(this.virtualWallMap)}drawSpots(t){const e=this.spotMap;if(!t||t.length===0){this.clearAllSpotsInternal(e);return}const i=new Set(e.keys()),s=new Set(t.map(n=>n.id));for(const n of i)s.has(n)||this.removeSpot(n,e);t.forEach(n=>{const o=e.get(n.id);o?this.isSpotDataEqual(o.getSpotData(),n)||o.updateSpotData(n):this.addNewSpot(n,e)})}getSpots(){return this.getSpotsData(this.spotMap)}clearAllSpots(){this.clearAllSpotsInternal(this.spotMap)}drawZones(t,e,i,s){if(!t||t.length===0){this.clearAllZones(e);return}const n=new Set(e.keys()),o=new Set(t.map(a=>a.id));for(const a of n)o.has(a)||this.removeZone(a,e);t.forEach(a=>{const h=e.get(a.id);h?this.isZoneDataEqual(h.getZoneData(),a)||h.updateZoneData(a):this.addNewZone(a,e,i,s)})}addNewZone(t,e,i,s){const n=i(t);e.set(t.id,n),this.addToControlLayer(s,n)}removeZone(t,e){var s;const i=e.get(t);i&&((s=i.parent)==null||s.removeChild(i),i.destroy(),e.delete(t))}getZonesData(t){const e=[];return t.forEach(i=>{e.push(i.getZoneData())}),e}clearAllZones(t){t.forEach((e,i)=>{var n;const s=t.get(i);s&&((n=s.parent)==null||n.removeChild(s),s.destroy())}),t.clear()}updateZonesEditState(t){t.forEach(e=>{e.updateEditState()})}updateVirtualWallsEditState(t){t.forEach(e=>{e.updateEditingState()})}isZoneDataEqual(t,e){if(t.id!==e.id||t.points.length!==e.points.length)return!1;for(let i=0;i<t.points.length;i++){const s=t.points[i],n=e.points[i];if(Math.abs(s.x-n.x)>.1||Math.abs(s.y-n.y)>.1)return!1}return!0}getWallsData(t){return Array.from(t.values()).map(e=>e.getWallData())}clearAllWalls(t){for(const e of t.values())e.destroy();t.clear()}isWallDataEqual(t,e){if(t.id!==e.id||t.points.length!==e.points.length)return!1;for(let i=0;i<t.points.length;i++){const s=t.points[i],n=e.points[i];if(Math.abs(s.x-n.x)>.1||Math.abs(s.y-n.y)>.1)return!1}return!0}addNewSpot(t,e){const i=Ur.create(this.appService,t);e.set(t.id,i),this.addToControlLayer("spot",i)}removeSpot(t,e){var s;const i=e.get(t);i&&((s=i.parent)==null||s.removeChild(i),i.destroy(),e.delete(t))}getSpotsData(t){const e=[];return t.forEach(i=>{e.push(i.getSpotData())}),e}clearAllSpotsInternal(t){t.forEach((e,i)=>{var n;const s=t.get(i);s&&((n=s.parent)==null||n.removeChild(s),s.destroy())}),t.clear()}updateSpotsEditState(t){t.forEach(e=>{e.updateEditState()})}isSpotDataEqual(t,e){if(t.id!==e.id)return!1;const i=t.point,s=e.point;return!(Math.abs(i.x-s.x)>.1||Math.abs(i.y-s.y)>.1)}drawWayPoints(t){A.log("[ControlsManager] drawWayPoints",t);const e=Array.from(this.wayPointMap.keys()),i=t.map(n=>n.id);e.filter(n=>!i.includes(n)).forEach(n=>{this.removeWayPoint(n,this.wayPointMap)}),t.forEach((n,o)=>{const a=o+1,h=this.wayPointMap.get(n.id);h?(this.isWayPointDataEqual(h.getWayPointData(),n)||h.updateWayPoint(n),h.updateOrder(a)):this.addNewWayPoint(n,a,this.wayPointMap)})}clearAllWayPoints(){A.log("[ControlsManager] clearAllWayPoints"),this.clearAllWayPointsInternal(this.wayPointMap)}getWayPoints(){return this.getWayPointsData(this.wayPointMap)}addNewWayPoint(t,e,i){var o,a;const s=this.appService,n=new $x({appService:s,wayPointData:t,order:e,events:{onUpdate:(o=s.events)==null?void 0:o.onUpdateWayPoint,onClick:(a=s.events)==null?void 0:a.onClickWayPoint}});i.set(t.id,n),this.addToControlLayer("wayPoint",n)}removeWayPoint(t,e){var s;const i=e.get(t);i&&((s=i.parent)==null||s.removeChild(i),i.destroy(),e.delete(t))}getWayPointsData(t){const e=[];return t.forEach(i=>{e.push(i.getWayPointData())}),e}clearAllWayPointsInternal(t){t.forEach((e,i)=>{var n;const s=t.get(i);s&&((n=s.parent)==null||n.removeChild(s),s.destroy())}),t.clear()}updateWayPointsEditState(t){t.forEach(e=>{e.onEditStateChange()})}isWayPointDataEqual(t,e){if(t.id!==e.id)return!1;const i=t.point,s=e.point;return!(Math.abs(i.x-s.x)>.1||Math.abs(i.y-s.y)>.1)}handleDividingRoomIdChange(t){if(t==null||t===-1){this.clearDivider();return}if(!this.getRoomGeometry(t)){this.clearDivider();return}this.createDefaultDivider(t)}getRoomGeometry(t){return this.appService.mapManager.getRoomById(t)}createDefaultDivider(t){const e=this.appService;this.clearDivider(),this.divider=new Qx({appService:this.appService,roomId:t,events:{onUpdate:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onUpdateDivider)==null||n.call(s,i)}}}),this.addToControlLayer("divider",this.divider)}clearDivider(){var t;this.divider&&((t=this.divider.parent)==null||t.removeChild(this.divider),this.divider.destroy(),this.divider=null)}getDividerEndPoints(){return this.divider?this.divider.getDividerEndPoints():null}getEffectiveDividerPoints(){return this.divider?this.divider.getEffectiveDividerPoints():null}handleUnitChange(){A.debug("[ControlsManager] Unit changed, refreshing all size texts"),this.forbiddenSweepZoneMap.forEach(t=>{t.refreshDisplay()}),this.forbiddenMopZoneMap.forEach(t=>{t.refreshDisplay()}),this.cleanZoneMap.forEach(t=>{t.refreshDisplay()}),this.virtualWallMap.forEach(t=>{t.refreshDisplay()}),this.spotMap.forEach(t=>{t.refreshDisplay()})}destroy(){this.clearAllForbiddenSweepZones(),this.clearAllForbiddenMopZones(),this.clearAllCleanZones(),this.clearAllVirtualWalls(),this.clearAllSpots(),this.clearDivider(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.controlContainers.forEach(t=>{t.removeFromParent(),t.destroy({children:!0})}),this.controlContainers.clear()}}class e0 extends Xt{constructor(e,i){super(e);g(this,"objectData");g(this,"clickHandler",null);g(this,"unsubscribeMapRotation",null);this.appService=e,this.objectData=i}async initializeSprite(){const e=this.appService.detectedObjectConfig,i=this.objectData.width||e.width,s=this.objectData.height||e.height;await this.loadTextureAndSetSize(this.objectData.src,{width:i,height:s}),this.anchor.set(e.anchor.x,e.anchor.y),this.position.set(this.objectData.x,this.objectData.y),this.visible=!0,this.applyAntiRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=U(this.appService.runtime,"mapRotation",n=>{this.applyAntiRotation(n)}),e.interactive?this.setupClickHandler():this.eventMode="none"}applyAntiRotation(e){const i=-e*Math.PI/180;this.rotation=i}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new vt(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var e,i;(i=(e=this.appService.events)==null?void 0:e.onClickDetectedObject)==null||i.call(e,this.getObjectData())}getObjectData(){return{...this.objectData}}async updateObjectData(e){const i=this.objectData;this.objectData=e;const s=this.appService.detectedObjectConfig;if(i.src!==e.src){const n=e.width||s.width,o=e.height||s.height;await this.loadTextureAndSetSize(e.src,{width:n,height:o})}if(i.width!==e.width||i.height!==e.height){const n=e.width||s.width,o=e.height||s.height;this.setFixedSize(n,o)}this.position.set(e.x,e.y),s.interactive?this.clickHandler||this.setupClickHandler():this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null)}isSameData(e){return this.objectData.id===e.id&&this.objectData.src===e.src&&this.objectData.x===e.x&&this.objectData.y===e.y&&this.objectData.width===e.width&&this.objectData.height===e.height}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class i0{constructor(t){g(this,"detectedObjectMap",new Map);g(this,"unsubscribeShowDetectedObjects",null);this.appService=t,this.applyLayerVisibility(this.appService.runtime.showDetectedObjects),this.unsubscribeShowDetectedObjects=U(this.appService.runtime,"showDetectedObjects",e=>{this.applyLayerVisibility(e)})}updatePositionByOrigin(t,e){const s=this.appService.appContainer.getLayer(We);s&&s.position.set(t,e)}async drawDetectedObjects(t){if(!t||t.length===0){this.clearAllDetectedObjects();return}const e=new Set(t.map(s=>s.id)),i=Array.from(this.detectedObjectMap.keys());for(const s of i)e.has(s)||this.removeDetectedObject(s);for(const s of t){const n=this.detectedObjectMap.get(s.id);n?n.isSameData(s)||await n.updateObjectData(s):await this.addNewDetectedObject(s)}}applyLayerVisibility(t){const e=this.appService.appContainer.getLayer(We);e&&(e.visible=t)}clearAllDetectedObjects(){const t=this.appService;this.detectedObjectMap.forEach(e=>{t.appContainer.removeFromLayer(We,e),e.destroy()}),this.detectedObjectMap.clear()}async addNewDetectedObject(t){const e=this.appService,i=new e0(this.appService,t);await i.initializeSprite(),this.detectedObjectMap.set(t.id,i),e.appContainer.addToLayer(We,i)}removeDetectedObject(t){const e=this.appService,i=this.detectedObjectMap.get(t);i&&(e.appContainer.removeFromLayer(We,i),i.destroy(),this.detectedObjectMap.delete(t))}destroy(){this.unsubscribeShowDetectedObjects&&(this.unsubscribeShowDetectedObjects(),this.unsubscribeShowDetectedObjects=null),this.clearAllDetectedObjects()}}var ke={},gc={},te={};Object.defineProperty(te,"__esModule",{value:!0});te.loop=te.conditional=te.parse=void 0;var s0=function r(t,e){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i;if(Array.isArray(e))e.forEach(function(o){return r(t,o,i,s)});else if(typeof e=="function")e(t,i,s,r);else{var n=Object.keys(e)[0];Array.isArray(e[n])?(s[n]={},r(t,e[n],i,s[n])):s[n]=e[n](t,i,s,r)}return i};te.parse=s0;var n0=function(t,e){return function(i,s,n,o){e(i,s,n)&&o(i,t,s,n)}};te.conditional=n0;var r0=function(t,e){return function(i,s,n,o){for(var a=[],h=i.pos;e(i,s,n);){var l={};if(o(i,t,s,l),i.pos===h)break;h=i.pos,a.push(l)}return a}};te.loop=r0;var ut={};Object.defineProperty(ut,"__esModule",{value:!0});ut.readBits=ut.readArray=ut.readUnsigned=ut.readString=ut.peekBytes=ut.readBytes=ut.peekByte=ut.readByte=ut.buildStream=void 0;var o0=function(t){return{data:t,pos:0}};ut.buildStream=o0;var mc=function(){return function(t){return t.data[t.pos++]}};ut.readByte=mc;var a0=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(e){return e.data[e.pos+t]}};ut.peekByte=a0;var zs=function(t){return function(e){return e.data.subarray(e.pos,e.pos+=t)}};ut.readBytes=zs;var h0=function(t){return function(e){return e.data.subarray(e.pos,e.pos+t)}};ut.peekBytes=h0;var l0=function(t){return function(e){return Array.from(zs(t)(e)).map(function(i){return String.fromCharCode(i)}).join("")}};ut.readString=l0;var c0=function(t){return function(e){var i=zs(2)(e);return t?(i[1]<<8)+i[0]:(i[0]<<8)+i[1]}};ut.readUnsigned=c0;var d0=function(t,e){return function(i,s,n){for(var o=typeof e=="function"?e(i,s,n):e,a=zs(t),h=new Array(o),l=0;l<o;l++)h[l]=a(i);return h}};ut.readArray=d0;var u0=function(t,e,i){for(var s=0,n=0;n<i;n++)s+=t[e+n]&&Math.pow(2,i-n-1);return s},p0=function(t){return function(e){for(var i=mc()(e),s=new Array(8),n=0;n<8;n++)s[7-n]=!!(i&1<<n);return Object.keys(t).reduce(function(o,a){var h=t[a];return h.length?o[a]=u0(s,h.index,h.length):o[a]=s[h.index],o},{})}};ut.readBits=p0;(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var t=te,e=ut,i={blocks:function(u){for(var p=0,f=[],y=u.data.length,m=0,x=(0,e.readByte)()(u);x!==p&&x;x=(0,e.readByte)()(u)){if(u.pos+x>=y){var S=y-u.pos;f.push((0,e.readBytes)(S)(u)),m+=S;break}f.push((0,e.readBytes)(x)(u)),m+=x}for(var v=new Uint8Array(m),b=0,P=0;P<f.length;P++)v.set(f[P],b),b+=f[P].length;return v}},s=(0,t.conditional)({gce:[{codes:(0,e.readBytes)(2)},{byteSize:(0,e.readByte)()},{extras:(0,e.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,e.readUnsigned)(!0)},{transparentColorIndex:(0,e.readByte)()},{terminator:(0,e.readByte)()}]},function(d){var u=(0,e.peekBytes)(2)(d);return u[0]===33&&u[1]===249}),n=(0,t.conditional)({image:[{code:(0,e.readByte)()},{descriptor:[{left:(0,e.readUnsigned)(!0)},{top:(0,e.readUnsigned)(!0)},{width:(0,e.readUnsigned)(!0)},{height:(0,e.readUnsigned)(!0)},{lct:(0,e.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,t.conditional)({lct:(0,e.readArray)(3,function(d,u,p){return Math.pow(2,p.descriptor.lct.size+1)})},function(d,u,p){return p.descriptor.lct.exists}),{data:[{minCodeSize:(0,e.readByte)()},i]}]},function(d){return(0,e.peekByte)()(d)===44}),o=(0,t.conditional)({text:[{codes:(0,e.readBytes)(2)},{blockSize:(0,e.readByte)()},{preData:function(u,p,f){return(0,e.readBytes)(f.text.blockSize)(u)}},i]},function(d){var u=(0,e.peekBytes)(2)(d);return u[0]===33&&u[1]===1}),a=(0,t.conditional)({application:[{codes:(0,e.readBytes)(2)},{blockSize:(0,e.readByte)()},{id:function(u,p,f){return(0,e.readString)(f.blockSize)(u)}},i]},function(d){var u=(0,e.peekBytes)(2)(d);return u[0]===33&&u[1]===255}),h=(0,t.conditional)({comment:[{codes:(0,e.readBytes)(2)},i]},function(d){var u=(0,e.peekBytes)(2)(d);return u[0]===33&&u[1]===254}),l=[{header:[{signature:(0,e.readString)(3)},{version:(0,e.readString)(3)}]},{lsd:[{width:(0,e.readUnsigned)(!0)},{height:(0,e.readUnsigned)(!0)},{gct:(0,e.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,e.readByte)()},{pixelAspectRatio:(0,e.readByte)()}]},(0,t.conditional)({gct:(0,e.readArray)(3,function(d,u){return Math.pow(2,u.lsd.gct.size+1)})},function(d,u){return u.lsd.gct.exists}),{frames:(0,t.loop)([s,a,h,n,o],function(d){var u=(0,e.peekByte)()(d);return u===33||u===44})}],c=l;r.default=c})(gc);var Ls={};Object.defineProperty(Ls,"__esModule",{value:!0});Ls.deinterlace=void 0;var f0=function(t,e){for(var i=new Array(t.length),s=t.length/e,n=function(u,p){var f=t.slice(p*e,(p+1)*e);i.splice.apply(i,[u*e,e].concat(f))},o=[0,4,2,1],a=[8,8,4,2],h=0,l=0;l<4;l++)for(var c=o[l];c<s;c+=a[l])n(c,h),h++;return i};Ls.deinterlace=f0;var Os={};Object.defineProperty(Os,"__esModule",{value:!0});Os.lzw=void 0;var g0=function(t,e,i){var s=4096,n=-1,o=i,a,h,l,c,d,u,p,w,f,y,P,m,C,k,T,M,x=new Array(i),S=new Array(s),v=new Array(s),b=new Array(s+1);for(m=t,h=1<<m,d=h+1,a=h+2,p=n,c=m+1,l=(1<<c)-1,f=0;f<h;f++)S[f]=0,v[f]=f;var P,w,C,k,M,T;for(P=w=C=k=M=T=0,y=0;y<o;){if(k===0){if(w<c){P+=e[T]<<w,w+=8,T++;continue}if(f=P&l,P>>=c,w-=c,f>a||f==d)break;if(f==h){c=m+1,l=(1<<c)-1,a=h+2,p=n;continue}if(p==n){b[k++]=v[f],p=f,C=f;continue}for(u=f,f==a&&(b[k++]=C,f=p);f>h;)b[k++]=v[f],f=S[f];C=v[f]&255,b[k++]=C,a<s&&(S[a]=p,v[a]=C,a++,!(a&l)&&a<s&&(c++,l+=a)),p=u}k--,x[M++]=b[k],y++}for(y=M;y<o;y++)x[y]=0;return x};Os.lzw=g0;Object.defineProperty(ke,"__esModule",{value:!0});var yc=ke.decompressFrames=ke.decompressFrame=xc=ke.parseGIF=void 0,m0=b0(gc),y0=te,x0=ut,S0=Ls,v0=Os;function b0(r){return r&&r.__esModule?r:{default:r}}var w0=function(t){var e=new Uint8Array(t);return(0,y0.parse)((0,x0.buildStream)(e),m0.default)},xc=ke.parseGIF=w0,A0=function(t){for(var e=t.pixels.length,i=new Uint8ClampedArray(e*4),s=0;s<e;s++){var n=s*4,o=t.pixels[s],a=t.colorTable[o]||[0,0,0];i[n]=a[0],i[n+1]=a[1],i[n+2]=a[2],i[n+3]=o!==t.transparentIndex?255:0}return i},Sc=function(t,e,i){if(!t.image){console.warn("gif frame does not have associated image.");return}var s=t.image,n=s.descriptor.width*s.descriptor.height,o=(0,v0.lzw)(s.data.minCodeSize,s.data.blocks,n);s.descriptor.lct.interlaced&&(o=(0,S0.deinterlace)(o,s.descriptor.width));var a={pixels:o,dims:{top:t.image.descriptor.top,left:t.image.descriptor.left,width:t.image.descriptor.width,height:t.image.descriptor.height}};return s.descriptor.lct&&s.descriptor.lct.exists?a.colorTable=s.lct:a.colorTable=e,t.gce&&(a.delay=(t.gce.delay||10)*10,a.disposalType=t.gce.extras.disposal,t.gce.extras.transparentColorGiven&&(a.transparentIndex=t.gce.transparentColorIndex)),i&&(a.patch=A0(a)),a};ke.decompressFrame=Sc;var C0=function(t,e){return t.frames.filter(function(i){return i.image}).map(function(i){return Sc(i,t.gct,e)})};yc=ke.decompressFrames=C0;class Gs{constructor(t){if(!t||!t.length)throw new Error("Invalid frames");const[{texture:{width:e,height:i}}]=t;this.width=e,this.height=i,this.frames=t,this.textures=this.frames.map(s=>s.texture),this.totalFrames=this.frames.length,this.duration=this.frames[this.totalFrames-1].end}destroy(){for(const t of this.textures)t.destroy(!0);for(const t of this.frames)t.texture=null;this.frames.length=0,this.textures.length=0,Object.assign(this,{frames:null,textures:null,width:0,height:0,duration:0,totalFrames:0})}static from(t,e){if(!t||t.byteLength===0)throw new Error("Invalid buffer");const i=S=>{let v=null;for(const b of S.frames)v=b.gce??v,"image"in b&&!("gce"in b)&&(b.gce=v)},s=xc(t);i(s);const n=yc(s,!0),o=[],a=s.lsd.width,h=s.lsd.height,l=j.get().createCanvas(a,h),c=l.getContext("2d",{willReadFrequently:!0}),d=j.get().createCanvas(),u=d.getContext("2d");let p=0,f=null;const{fps:y=30,...m}=e??{},x=1e3/y;for(let S=0;S<n.length;S++){const{disposalType:v=2,delay:b=x,patch:P,dims:{width:w,height:C,left:k,top:M}}=n[S];d.width=w,d.height=C,u.clearRect(0,0,w,C);const T=u.createImageData(w,C);T.data.set(P),u.putImageData(T,0,0),v===3&&(f=c.getImageData(0,0,a,h)),c.drawImage(d,k,M);const _=c.getImageData(0,0,a,h);v===2?c.clearRect(0,0,a,h):v===3&&c.putImageData(f,0,0);const I=j.get().createCanvas(_.width,_.height);I.getContext("2d").putImageData(_,0,0),o.push({start:p,end:p+b,texture:new G({source:new dr({resource:I,...m})})}),p+=b}return l.width=l.height=0,d.width=d.height=0,new Gs(o)}}const P0={extension:E.Asset,detection:{test:async()=>!0,add:async r=>[...r,"gif"],remove:async r=>r.filter(t=>t!=="gif")},loader:{name:"gifLoader",id:"gif",test:r=>Mt.extname(r)===".gif"||r.startsWith("data:image/gif"),load:async(r,t)=>{const i=await(await j.get().fetch(r)).arrayBuffer();return Gs.from(i,t==null?void 0:t.data)},unload:async r=>{r.destroy()}}},vc=class rr extends jt{constructor(...t){const e=t[0]instanceof Gs?{source:t[0]}:t[0],{source:i,fps:s,loop:n,animationSpeed:o,autoPlay:a,autoUpdate:h,onComplete:l,onFrameChange:c,onLoop:d,...u}=Object.assign({},rr.defaultOptions,e);super({texture:G.EMPTY,...u}),this.animationSpeed=1,this.loop=!0,this.duration=0,this.autoPlay=!0,this.dirty=!1,this._currentFrame=0,this._autoUpdate=!1,this._isConnectedToTicker=!1,this._playing=!1,this._currentTime=0,this.onRender=()=>this._updateFrame(),this.texture=i.textures[0],this.duration=i.frames[i.frames.length-1].end,this._source=i,this._playing=!1,this._currentTime=0,this._isConnectedToTicker=!1,Object.assign(this,{fps:s,loop:n,animationSpeed:o,autoPlay:a,autoUpdate:h,onComplete:l,onFrameChange:c,onLoop:d}),this.currentFrame=0,a&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(yt.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(yt.shared.add(this.update,this,Ee.HIGH),this._isConnectedToTicker=!0),!this.loop&&this.currentFrame===this._source.frames.length-1&&(this._currentTime=0))}get progress(){return this._currentTime/this.duration}get playing(){return this._playing}update(t){var o,a;if(!this._playing)return;const e=this.animationSpeed*t.deltaTime/yt.targetFPMS,i=this._currentTime+e,s=i%this.duration,n=this._source.frames.findIndex(h=>h.start<=s&&h.end>s);i>=this.duration?this.loop?(this._currentTime=s,this._updateFrameIndex(n),(o=this.onLoop)==null||o.call(this)):(this._currentTime=this.duration,this._updateFrameIndex(this.totalFrames-1),(a=this.onComplete)==null||a.call(this),this.stop()):(this._currentTime=s,this._updateFrameIndex(n))}_updateFrame(){this.dirty&&(this.texture=this._source.frames[this._currentFrame].texture,this.dirty=!1)}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(yt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(yt.shared.add(this.update,this),this._isConnectedToTicker=!0))}get currentFrame(){return this._currentFrame}set currentFrame(t){this._updateFrameIndex(t),this._currentTime=this._source.frames[t].start}get source(){return this._source}_updateFrameIndex(t){var e;if(t<0||t>=this.totalFrames)throw new Error(`Frame index out of range, expecting 0 to ${this.totalFrames}, got ${t}`);this._currentFrame!==t&&(this._currentFrame=t,this.dirty=!0,(e=this.onFrameChange)==null||e.call(this,t))}get totalFrames(){return this._source.totalFrames}destroy(t=!1){this.stop(),super.destroy(),t&&this._source.destroy();const e=null;this._source=e,this.onComplete=e,this.onFrameChange=e,this.onLoop=e}clone(){const t=new rr({source:this._source,autoUpdate:this._autoUpdate,loop:this.loop,autoPlay:this.autoPlay,animationSpeed:this.animationSpeed,onComplete:this.onComplete,onFrameChange:this.onFrameChange,onLoop:this.onLoop});return t.dirty=!0,t}};vc.defaultOptions={fps:30,loop:!0,animationSpeed:1,autoPlay:!0,autoUpdate:!0,onComplete:null,onFrameChange:null,onLoop:null};let M0=vc;$.add(P0);class Hr extends M0{constructor(e,i){super(i);g(this,"throttledUpdateScale");g(this,"fixedWidth",0);g(this,"fixedHeight",0);g(this,"isFixedSizeSet",!1);g(this,"sizeFixed",!0);g(this,"baselineScale",1);this.appService=e,this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=At(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(e,i){this.fixedWidth=e,this.fixedHeight=i,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(e){this.sizeFixed=e,this.baselineScale=1,e&&this.isFixedSizeSet?this.applySize():!e&&this.isFixedSizeSet&&this.applySize()}set width(e){if(this.isFixedSizeSet){A.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置宽度");return}this.setFixedSize(e,this.fixedHeight||e)}set height(e){if(this.isFixedSizeSet){A.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置高度");return}this.setFixedSize(this.fixedWidth||e,e)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.texture||this.texture.width===0||this.texture.height===0)return;const e=this.fixedWidth/this.texture.width,i=this.fixedHeight/this.texture.height;if(this.sizeFixed){const s=this.appService.currentScale;if(s===0)return;const n=e/s,o=i/s;super.scale.set(n,o)}else super.scale.set(e/this.baselineScale,i/this.baselineScale)}updateScale(e){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():e!==0&&super.scale.set(1/e))}static async createFromSrc(e,i,s){try{const n=await N.load(i),o=new Hr(e,{source:n});return s.sizeFixed!==void 0&&o.setSizeFixed(s.sizeFixed),o.setFixedSize(s.width,s.height),o}catch(n){throw A.error(`Failed to load GIF "${i}":`,n),n}}draw(e,i){const{x:s,y:n,rotation:o=0}=e;i&&!this.visible?this.visible=i():!i&&!this.visible&&(this.visible=!0),this.rotation=o,this.position.set(s,n)}destroy(e){this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(e)}}class Ge extends Hr{constructor(e,i,s){super(e,{source:i});g(this,"elementData");g(this,"clickHandler",null);g(this,"unsubscribeMapRotation",null);g(this,"userRotation",0);this.elementData=s}async initialize(){this.elementData.sizeFixed!==void 0&&this.setSizeFixed(this.elementData.sizeFixed),this.setFixedSize(this.elementData.width,this.elementData.height);const e=this.elementData.anchor||{x:.5,y:.5};this.anchor.set(e.x,e.y),this.position.set(this.elementData.x,this.elementData.y),this.elementData.rotation!==void 0&&(this.userRotation=this.elementData.rotation),this.elementData.opacity!==void 0&&(this.alpha=this.elementData.opacity),this.applyRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=U(this.appService.runtime,"mapRotation",i=>{this.applyRotation(i)}),this.visible=!0,this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(e){const i=-e*Math.PI/180;this.rotation=this.userRotation+i}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new vt(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var e,i;(i=(e=this.appService.events)==null?void 0:e.onClickCustomElement)==null||i.call(e,this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(e){const i=this.elementData;if(this.elementData=e,i.src!==e.src)throw new Error("GIF source change requires recreation of instance");i.sizeFixed!==e.sizeFixed&&e.sizeFixed!==void 0&&this.setSizeFixed(e.sizeFixed),(i.width!==e.width||i.height!==e.height)&&this.setFixedSize(e.width,e.height);const s=e.anchor||{x:.5,y:.5},n=i.anchor||{x:.5,y:.5};(s.x!==n.x||s.y!==n.y)&&this.anchor.set(s.x,s.y),this.position.set(e.x,e.y),e.rotation!==void 0&&(this.userRotation=e.rotation,this.applyRotation(this.appService.runtime.mapRotation)),e.opacity!==void 0&&(this.alpha=e.opacity),e.interactive?this.clickHandler||this.setupClickHandler():(this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.eventMode="none")}isSameData(e){const i=this.elementData.anchor||{x:.5,y:.5},s=e.anchor||{x:.5,y:.5};return this.elementData.id===e.id&&this.elementData.type===e.type&&this.elementData.src===e.src&&this.elementData.x===e.x&&this.elementData.y===e.y&&this.elementData.width===e.width&&this.elementData.height===e.height&&this.elementData.rotation===e.rotation&&this.elementData.opacity===e.opacity&&this.elementData.interactive===e.interactive&&this.elementData.sizeFixed===e.sizeFixed&&i.x===s.x&&i.y===s.y}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class Mn extends Xt{constructor(e,i){super(e);g(this,"elementData");g(this,"clickHandler",null);g(this,"unsubscribeMapRotation",null);g(this,"userRotation",0);this.appService=e,this.elementData=i}async initialize(){await this.loadTextureAndSetSize(this.elementData.src,{width:this.elementData.width,height:this.elementData.height,sizeFixed:this.elementData.sizeFixed});const e=this.elementData.anchor||{x:.5,y:.5};this.anchor.set(e.x,e.y),this.position.set(this.elementData.x,this.elementData.y),this.elementData.rotation!==void 0&&(this.userRotation=this.elementData.rotation),this.elementData.opacity!==void 0&&(this.alpha=this.elementData.opacity),this.applyRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=U(this.appService.runtime,"mapRotation",i=>{this.applyRotation(i)}),this.visible=!0,this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(e){const i=-e*Math.PI/180;this.rotation=this.userRotation+i}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new vt(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var e,i;(i=(e=this.appService.events)==null?void 0:e.onClickCustomElement)==null||i.call(e,this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(e){const i=this.elementData;this.elementData=e,i.src!==e.src?await this.loadTextureAndSetSize(e.src,{width:e.width,height:e.height,sizeFixed:e.sizeFixed}):(i.sizeFixed!==e.sizeFixed&&e.sizeFixed!==void 0&&this.setSizeFixed(e.sizeFixed),(i.width!==e.width||i.height!==e.height)&&this.setFixedSize(e.width,e.height));const s=e.anchor||{x:.5,y:.5},n=i.anchor||{x:.5,y:.5};(s.x!==n.x||s.y!==n.y)&&this.anchor.set(s.x,s.y),this.position.set(e.x,e.y),e.rotation!==void 0&&(this.userRotation=e.rotation,this.applyRotation(this.appService.runtime.mapRotation)),e.opacity!==void 0&&(this.alpha=e.opacity),e.interactive?this.clickHandler||this.setupClickHandler():(this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.eventMode="none")}isSameData(e){const i=this.elementData.anchor||{x:.5,y:.5},s=e.anchor||{x:.5,y:.5};return this.elementData.id===e.id&&this.elementData.type===e.type&&this.elementData.src===e.src&&this.elementData.x===e.x&&this.elementData.y===e.y&&this.elementData.width===e.width&&this.elementData.height===e.height&&this.elementData.rotation===e.rotation&&this.elementData.opacity===e.opacity&&this.elementData.interactive===e.interactive&&this.elementData.sizeFixed===e.sizeFixed&&i.x===s.x&&i.y===s.y}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class _0 extends Fg{constructor(e,i){super(i);g(this,"throttledUpdateScale");g(this,"fixedWidth",0);g(this,"fixedHeight",0);g(this,"isFixedSizeSet",!1);g(this,"userCenterX",0);g(this,"userCenterY",0);g(this,"sizeFixed",!0);this.appService=e,this.anchor.set(0,0),this.throttledUpdateScale=At(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(e,i){this.fixedWidth=e,this.fixedHeight=i,this.isFixedSizeSet=!0,this.applyFixedSize(),this.updatePositionFromCenter()}setCenterPosition(e,i){this.userCenterX=e,this.userCenterY=i,this.updatePositionFromCenter()}setSizeFixed(e){this.sizeFixed=e,this.isFixedSizeSet&&(this.applyFixedSize(),this.updatePositionFromCenter())}getIsFixedSizeSet(){return this.isFixedSizeSet}updatePositionFromCenter(){if(!this.isFixedSizeSet){this.position.set(this.userCenterX,this.userCenterY);return}const i=this.appService.currentScale;let s,n;this.sizeFixed?(s=this.fixedWidth/2/i,n=this.fixedHeight/2/i):(s=this.fixedWidth/2,n=this.fixedHeight/2),this.position.set(this.userCenterX-s,this.userCenterY-n)}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}applyFixedSize(){if(!this.isFixedSizeSet)return;const i=this.appService.currentScale;if(i!==0){if(this.sizeFixed){const s=1/i;this.scale.set(s)}else this.scale.set(1);this.element&&(this.element.style.width=`${this.fixedWidth}px`,this.element.style.height=`${this.fixedHeight}px`)}}updateScale(e){this.isFixedSizeSet&&e!==0&&(this.applyFixedSize(),this.updatePositionFromCenter())}updateTransform(e){return super.updateTransform(e)}destroy(e){this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(e)}}class ki extends _0{constructor(e,i){const s=document.createElement("div");ki.setupDefaultStyles(s,i),s.innerHTML=i.htmlContent;super(e,{element:s});g(this,"elementData");g(this,"domClickHandler",null);g(this,"resizeObserver",null);g(this,"debugMarker",null);g(this,"unsubscribeMapRotation",null);g(this,"userRotation",0);this.elementData=i}async initialize(){this.alpha=0,this.elementData.width&&this.elementData.height?(this.setFixedSize(this.elementData.width,this.elementData.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),this.waitForElementInsertion()):(this.position.set(this.elementData.x,this.elementData.y),this.setupAutoSize()),this.elementData.rotation!==void 0&&(this.userRotation=this.elementData.rotation),this.applyRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=U(this.appService.runtime,"mapRotation",e=>{this.applyRotation(e)}),this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(e){const i=-e*Math.PI/180;this.rotation=this.userRotation+i}setupAutoSize(){this.element&&(this.element.style.width="auto",this.element.style.height="auto",this.waitForElementDimensions())}waitForElementInsertion(){if(!this.element)return;const e=()=>{this.element&&(this.element.isConnected?this.showElement():requestAnimationFrame(e))};requestAnimationFrame(e)}waitForElementDimensions(){this.element&&(typeof ResizeObserver<"u"?(this.resizeObserver=new ResizeObserver(e=>{var s;const i=e[0];i&&i.contentRect.width>0&&i.contentRect.height>0&&(this.setFixedSize(i.contentRect.width,i.contentRect.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),this.alpha===0&&this.showElement(),(s=this.resizeObserver)==null||s.disconnect(),this.resizeObserver=null)}),this.resizeObserver.observe(this.element)):this.pollForElementDimensions())}pollForElementDimensions(){if(!this.element)return;const e=()=>{if(!this.element)return;if(!this.element.isConnected){requestAnimationFrame(e);return}const i=this.element.getBoundingClientRect();i.width>0&&i.height>0?(this.setFixedSize(i.width,i.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),this.alpha===0&&this.showElement()):requestAnimationFrame(e)};requestAnimationFrame(e)}showElement(){this.alpha=this.elementData.opacity??1,this.element.style.pointerEvents=this.elementData.interactive?"auto":"none",this.interactive=this.elementData.interactive??!1,this.elementData.interactive&&this.element&&(this.element.style.setProperty("-webkit-tap-highlight-color","transparent"),this.element.style.setProperty("-webkit-touch-callout","none")),this.appService.getApp().renderOnceNextFrame()}setupClickHandler(){this.element&&(this.domClickHandler=e=>{e.preventDefault(),e.stopPropagation(),this.handleClick()},this.element.addEventListener("click",this.domClickHandler))}handleClick(){var e,i;(i=(e=this.appService.events)==null?void 0:e.onClickCustomElement)==null||i.call(e,this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(e){const i=this.elementData;this.elementData=e,i.htmlContent!==e.htmlContent&&this.element&&(this.element.innerHTML=e.htmlContent,(!e.width||!e.height)&&this.waitForElementDimensions()),(i.width!==e.width||i.height!==e.height)&&(e.width&&e.height?(this.setFixedSize(e.width,e.height),this.element&&(this.element.style.width=`${e.width}px`,this.element.style.height=`${e.height}px`)):this.setupAutoSize()),e.width&&e.height?this.setCenterPosition(e.x,e.y):this.getIsFixedSizeSet()?this.setCenterPosition(e.x,e.y):this.position.set(e.x,e.y),i.sizeFixed!==e.sizeFixed&&e.sizeFixed!==void 0&&this.setSizeFixed(e.sizeFixed),this.userRotation=e.rotation??0,this.applyRotation(this.appService.runtime.mapRotation),this.alpha=e.opacity??1,e.interactive?this.domClickHandler||this.setupClickHandler():(this.eventMode="none",this.domClickHandler&&this.element&&(this.element.removeEventListener("click",this.domClickHandler),this.domClickHandler=null))}isSameData(e){return this.elementData.id===e.id&&this.elementData.type===e.type&&this.elementData.htmlContent===e.htmlContent&&this.elementData.x===e.x&&this.elementData.y===e.y&&this.elementData.width===e.width&&this.elementData.height===e.height&&this.elementData.rotation===e.rotation&&this.elementData.opacity===e.opacity&&this.elementData.interactive===e.interactive&&this.elementData.sizeFixed===e.sizeFixed}static setupDefaultStyles(e,i){const s={position:"relative",boxSizing:"border-box",webkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",background:"transparent",userSelect:"auto",webkitUserSelect:"auto"};i.width&&i.height?(s.width=`${i.width}px`,s.height=`${i.height}px`,s.overflow="hidden"):(s.width=i.width?`${i.width}px`:"auto",s.height=i.height?`${i.height}px`:"auto",s.overflow="visible"),Object.assign(e.style,s),e.style.setProperty("-webkit-tap-highlight-color","transparent"),e.style.setProperty("-webkit-touch-callout","none")}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.domClickHandler&&this.element&&(this.element.removeEventListener("click",this.domClickHandler),this.domClickHandler=null),this.debugMarker&&(this.debugMarker.destroy(),this.debugMarker=null),super.destroy()}}class T0{constructor(t){g(this,"customElementsMap",new Map);g(this,"gifTicker",null);g(this,"gifElements",new Set);this.appService=t}updatePositionByOrigin(t,e){const i=this.appService,s=i.appContainer.getLayer(Si),n=i.appContainer.getLayer(vi);s&&s.position.set(t,e),n&&n.position.set(t,e)}async drawCustomElements(t){if(!t||t.length===0){this.clearAllCustomElements();return}const e=new Set(t.map(n=>n.id)),i=Array.from(this.customElementsMap.keys());for(const n of i)e.has(n)||this.removeCustomElement(n);const s=t.map(async n=>{const o=this.customElementsMap.get(n.id);o?this.isSameData(o,n)||(n.type==="gif"&&o.getElementData().src!==n.src?(this.removeCustomElement(n.id),await this.addNewCustomElement(n)):await this.updateElementData(o,n)):await this.addNewCustomElement(n)});await Promise.all(s),this.updateGifTicker()}clearAllCustomElements(){const t=this.appService;this.customElementsMap.forEach(e=>{e instanceof Ge?t.appContainer.removeFromLayer(vi,e):t.appContainer.removeFromLayer(Si,e),e.destroy()}),this.customElementsMap.clear(),this.gifElements.clear(),this.stopGifTicker()}async addNewCustomElement(t){const e=this.appService;let i;switch(t.type){case"image":i=new Mn(this.appService,t);break;case"gif":{const s=await N.load(t.src);i=new Ge(this.appService,s,t);break}case"html":i=new ki(this.appService,t);break;default:throw new Error(`Unsupported custom element type: ${t.type}`)}await i.initialize(),this.customElementsMap.set(t.id,i),i instanceof Ge?(e.appContainer.addToLayer(vi,i),this.gifElements.add(i)):e.appContainer.addToLayer(Si,i)}removeCustomElement(t){const e=this.appService,i=this.customElementsMap.get(t);i&&(i instanceof Ge?(this.gifElements.delete(i),e.appContainer.removeFromLayer(vi,i)):e.appContainer.removeFromLayer(Si,i),i.destroy(),this.customElementsMap.delete(t))}isSameData(t,e){return t.getElementData().type!==e.type?!1:e.type==="image"&&t instanceof Mn||e.type==="gif"&&t instanceof Ge||e.type==="html"&&t instanceof ki?t.isSameData(e):!1}async updateElementData(t,e){if(e.type==="image"&&t instanceof Mn)await t.updateElementData(e);else if(e.type==="gif"&&t instanceof Ge)await t.updateElementData(e);else if(e.type==="html"&&t instanceof ki)await t.updateElementData(e);else throw new Error("Element type mismatch during update")}updateGifTicker(){this.gifElements.size>0?this.startGifTicker():this.stopGifTicker()}startGifTicker(){var t;(t=this.gifTicker)!=null&&t.started||(this.gifTicker?this.gifTicker.maxFPS=1:(this.gifTicker=new yt,this.gifTicker.maxFPS=1,this.gifTicker.add(()=>{this.renderGifContainer()})),this.gifTicker.start())}stopGifTicker(){var t;(t=this.gifTicker)!=null&&t.started&&(A.log("⏸️ [GifTicker] 停止 GIF 专用渲染"),this.gifTicker.stop())}renderGifContainer(){const t=this.appService;if(this.gifElements.size===0)return;const e=t.getApp();e.renderer.render(e.stage)}destroy(){this.stopGifTicker(),this.gifTicker&&(this.gifTicker.destroy(),this.gifTicker=null),this.clearAllCustomElements()}}class k0 extends L{constructor(e,i){super();g(this,"roomId");g(this,"roomIndex");g(this,"appService");g(this,"nameText");g(this,"iconSprite",null);g(this,"iconWrapper",null);g(this,"iconBg",null);this.appService=e,this.roomId=i.id,this.roomIndex=i.index;const{nameLabel:s,type:n}=e.roomConfig,{showRoomType:o}=e.runtime,a=i.colorIndex??i.index,h=this.getRoomNameColor(a),l=new de({fontSize:s.fontSize,fontFamily:s.fontFamily,fontWeight:s.fontWeight,fill:h,align:"center"}),c=i.name||"Unknown";this.nameText=new Es({text:c,style:l}),this.nameText.anchor.set(.5),o&&i.type!=null&&(n!=null&&n.assets)&&n.assets[i.type]&&this.createIcon(i.type,h),this.addChild(this.nameText),this.layout()}createIcon(e,i){const{type:s}=this.appService.roomConfig,n=s.iconSize||14;this.iconWrapper||(this.iconWrapper=new L,this.addChild(this.iconWrapper)),s.container.visible?(this.iconBg||(this.iconBg=new H,this.iconWrapper.addChild(this.iconBg)),this.drawIconBg(i)):this.iconBg&&(this.iconBg.destroy(),this.iconBg=null),this.iconSprite||(this.iconSprite=new Xt(this.appService),this.iconSprite.anchor.set(.5),this.iconWrapper.addChild(this.iconSprite)),this.iconSprite.visible=!0,this.iconSprite.tint=s.container.visible?"#ffffff":i,this.iconSprite.setFixedSize(n,n),this.iconSprite.loadTextureAndSetSize(s.assets[e],{width:n,height:n,sizeFixed:!1}).then(()=>{this.iconSprite&&(this.iconSprite.visible=this.appService.runtime.showRoomType,this.layout())}),s.container&&this.iconSprite.position.set(0,0)}drawIconBg(e){const{type:i}=this.appService.roomConfig;if(!this.iconBg||!i.container.visible)return;const{size:s,borderRadius:n}=i.container;this.iconBg.clear().roundRect(-s/2,-s/2,s,s,n).fill(e)}layout(){if(!this.iconWrapper||!this.iconWrapper.visible){this.nameText.position.set(0,0);return}if(!(this.iconSprite&&this.iconSprite.visible||this.iconBg&&this.iconBg.visible)){this.nameText.position.set(0,0);return}const{gap:i=4,position:s="left"}=this.appService.roomConfig.type,n=this.nameText.width,o=this.iconWrapper.width,h=-(o+i+n)/2;s==="left"?(this.iconWrapper.x=h+o/2,this.nameText.x=h+o+i+n/2):(this.nameText.x=h+n/2,this.iconWrapper.x=h+n+i+o/2),this.iconWrapper.y=0,this.nameText.y=0}updateName(e){this.nameText.text=e,this.layout()}refreshColor(e){const{type:i}=this.appService.roomConfig,s=this.appService.getRoomData(this.roomId),n=(s==null?void 0:s.colorIndex)??this.roomIndex,o=this.getRoomNameColor(n,e);this.nameText.style.fill=o,this.iconBg&&this.drawIconBg(o),this.iconSprite&&(this.iconSprite.tint=i.container.visible?"#ffffff":o)}getRoomNameColor(e,i){const{colors:s}=this.appService.roomConfig,{enableRoomSelection:n,selectRoomIds:o}=this.appService.runtime;if(i)return i;if(n)return!o.includes(this.roomId)&&s.nameInactive?s.nameInactive[e%s.nameInactive.length]:s.name[e%s.name.length];const a=s.nameNormal||s.name;return a[e%a.length]}async updateRoomType(e){const{type:i}=this.appService.roomConfig;if(!this.appService.runtime.showRoomType||e==null||!(i!=null&&i.assets)||!i.assets[e])this.iconWrapper&&(this.iconWrapper.visible=!1);else{const n=this.appService.getRoomData(this.roomId),o=(n==null?void 0:n.colorIndex)??this.roomIndex,a=this.getRoomNameColor(o);this.createIcon(e,a),this.iconWrapper&&(this.iconWrapper.visible=!0)}this.layout()}updateRoomTypeVisibility(e){if(this.iconWrapper)this.iconWrapper.visible=e,this.layout();else if(e){const i=this.appService.getRoomData(this.roomId);i&&this.updateRoomType(i.type??null)}}destroy(e){this.iconBg&&(this.iconBg.destroy(),this.iconBg=null),this.iconSprite&&(this.iconSprite.destroy(),this.iconSprite=null),this.iconWrapper&&(this.iconWrapper.destroy(),this.iconWrapper=null),super.destroy(e)}}class R0 extends L{constructor(e,i){super();g(this,"background");g(this,"foldedIndicator");g(this,"propertyIcons",new Map);g(this,"orderContainer");g(this,"orderBackground");g(this,"orderText");g(this,"isFolded",!1);g(this,"roomId");g(this,"roomIndex");g(this,"isDestroyed",!1);this.appService=e;const s=this.appService.roomConfig;this.roomId=i.id,this.roomIndex=i.index,this.background=new H,this.foldedIndicator=new H,this.foldedIndicator.visible=!1;const{property:n}=s,o=i.colorIndex??i.index,a=this.getIconColor(o);this.initializePropertyIcons(n.displayOrders,a);const h=n.cleanOrder.color==="auto"?s.colors.active[o%s.colors.active.length]:n.cleanOrder.color;this.orderContainer=new L,this.orderBackground=new H,this.orderText=new Es({text:"",style:new de({fontSize:n.cleanOrder.fontSize,fontFamily:n.cleanOrder.fontFamily,fontWeight:n.cleanOrder.fontWeight,fill:h,align:"center",trim:!0})}),this.orderText.anchor.set(.5,.5),this.orderContainer.addChild(this.orderBackground),this.orderContainer.addChild(this.orderText),this.addChild(this.background),this.addChild(this.foldedIndicator),this.propertyIcons.forEach(({sprite:l})=>{this.addChild(l)}),this.addChild(this.orderContainer),this.visible=this.appService.runtimeSnapshot.showRoomProperty}initializePropertyIcons(e,i){const s=["cleanMode","suction","cistern","cleanTimes"];e.forEach(n=>{const o=s.includes(n),a=new Xt(this.appService);a.tint=i,a.anchor.set(0,0),this.propertyIcons.set(n,{fieldName:n,sprite:a,isBuiltin:o})})}async updateProperty(e){this.isDestroyed||this.destroyed||(await this.updateIcons(e),!(this.isDestroyed||this.destroyed)&&this.updateBackground())}getFieldValue(e,i){if(["cleanMode","suction","cistern","cleanTimes"].includes(i))return e[i]??null;if(e.customData&&i in e.customData){const n=e.customData[i];return typeof n=="number"?n:null}return null}getAssetAlias(e,i){const s={cleanMode:n=>`cleanMode_${n}`,suction:n=>`fan_${n}`,cistern:n=>`water_${n}`,cleanTimes:n=>`cleanTimes${n}`};return e in s?s[e](i):`custom_${e}_${i}`}shouldShowField(e,i,s){const{showRoomProperty:n}=this.appService.runtimeSnapshot;return!(s===null||!n||i==="cleanTimes"&&s<=0)}getDisplayElements(e){const{displayOrders:i}=this.appService.roomConfig.property,{showRoomOrder:s}=this.appService.runtimeSnapshot,n=e.order||0,o=s&&n>0,a=[];return o&&a.push({element:this.orderContainer,show:!0,isOrder:!0,fieldName:"order"}),i.forEach(h=>{const l=this.propertyIcons.get(h);if(!l||!l.sprite)return;const c=this.getFieldValue(e,h);this.shouldShowField(e,h,c)&&c!==null&&a.push({element:l.sprite,show:!0,isOrder:!1,fieldName:h,value:c})}),{elementsToShow:a,orderValue:n}}async updateIcons(e){if(this.isDestroyed||this.destroyed||this.isFolded)return;const{iconWidth:i,iconHeight:s,container:n,cleanOrder:o,iconGap:a}=this.appService.roomConfig.property,{paddingHorizontal:h,paddingVertical:l}=n,{elementsToShow:c,orderValue:d}=this.getDisplayElements(e);this.orderContainer.visible=!1,this.propertyIcons.forEach(({sprite:f})=>{f.visible=!1});const u=[];if(c.forEach(f=>{if(f.isOrder){this.orderContainer.visible=!0,this.orderText.text=d.toString();const y=e.colorIndex??this.roomIndex,m=this.getIconColor(y);this.orderBackground.clear(),this.orderBackground.setFillStyle({color:m}),this.orderBackground.circle(i/2,s/2,i/2).fill();const x=this.resolveOrderTextColor(y);this.orderText.style.fill=x,this.orderText.position.set(i/2,s/2)}else{const y=this.propertyIcons.get(f.fieldName);if(y&&y.sprite){y.sprite.visible=!0;const m=this.getAssetAlias(f.fieldName,f.value);u.push(y.sprite.loadTextureAndSetSize(m,{width:i,height:s,sizeFixed:!1}))}}}),await Promise.all(u),this.isDestroyed||this.destroyed)return;let p=h;c.forEach((f,y)=>{const{element:m,isOrder:x}=f;!m||!m.position||(m.position.set(p,l),p+=i,y<c.length-1&&(x?p+=o.gapRight:p+=a))})}updateBackground(){if(this.isDestroyed||this.destroyed)return;const e=this.appService.roomConfig,{container:i,foldable:s}=e.property,{borderRadius:n,tailHeight:o,tailWidth:a,backgroundColor:h}=i,l=this.calculateContentWidth(),c=this.calculateContentHeight(),d=Math.min(n,l/2,c/2),u=d*.8,p=Math.max(l-u*2,a*.5),f=Math.min(a,l/2,p);if(this.background.clear(),this.background.setFillStyle({color:h}),s){const y=(l-f)/2,m=c+o;this.background.moveTo(d,0),this.background.lineTo(l-d,0),this.background.arcTo(l,0,l,d,d),this.background.lineTo(l,c-d),this.background.arcTo(l,c,l-d,c,d),this.background.lineTo(y+f,c),this.background.lineTo(y+f/2,m),this.background.lineTo(y,c),this.background.lineTo(d,c),this.background.arcTo(0,c,0,c-d,d),this.background.lineTo(0,d),this.background.arcTo(0,0,d,0,d),this.background.closePath()}else this.background.roundRect(0,0,l,c,d);this.background.fill()}calculateContentWidth(){const{iconWidth:e,container:i,cleanOrder:s,iconGap:n}=this.appService.roomConfig.property,{paddingHorizontal:o}=i,a=this.appService.getRoomData(this.roomId);if(!a)return o*2;const{elementsToShow:h}=this.getDisplayElements(a);let l=o;return h.forEach((c,d)=>{const{isOrder:u}=c;l+=e,d<h.length-1&&(u?l+=s.gapRight:l+=n)}),l+=o,l}calculateContentHeight(){const e=this.appService.roomConfig,{iconHeight:i,container:s}=e.property;return s.paddingVertical+i+s.paddingVertical}getTotalHeight(){const{foldable:e,container:i}=this.appService.roomConfig.property,{tailHeight:s}=i;return this.isFolded?s:this.calculateContentHeight()+(e?s:0)}getTotalWidth(){if(this.isFolded){const{tailWidth:i}=this.appService.roomConfig.property.container,s=this.calculateContentWidth();return Math.min(i,s/2)}return this.calculateContentWidth()}async setFolded(e){const{foldable:i}=this.appService.roomConfig.property;if(i)if(this.isFolded=e,e)this.background.visible=!1,this.orderContainer.visible=!1,this.propertyIcons.forEach(({sprite:s})=>{s.visible=!1}),this.foldedIndicator.visible=!0,this.updateFoldedIndicator();else{this.background.visible=!0,this.foldedIndicator.visible=!1,this.foldedIndicator.position.set(0,0),this.updateBackground();const s=this.appService.getRoomData(this.roomId);s&&await this.updateIcons(s)}}isFoldedState(){const{foldable:e}=this.appService.roomConfig.property;return e?this.isFolded:!1}updateFoldedIndicator(){const e=this.appService.roomConfig,{tailHeight:i,tailWidth:s,backgroundColor:n}=e.property.container,o=this.calculateContentWidth(),a=Math.min(s,o/2);this.foldedIndicator.clear(),this.foldedIndicator.setFillStyle({color:n}),this.foldedIndicator.poly([0,i,a,i,a/2,0]).fill(),this.foldedIndicator.position.set(0,0)}resolveOrderTextColor(e){const{property:i,colors:s}=this.appService.roomConfig,{enableRoomSelection:n}=this.appService.runtime;if(i.cleanOrder.color==="auto"){const o=n?s.active:s.normal||s.active;return o[e%o.length]}return i.cleanOrder.color}getIconColor(e){const{colors:i}=this.appService.roomConfig,{propertyTheme:s,propertyThemeInactive:n,propertyThemeNormal:o}=i,{enableRoomSelection:a,selectRoomIds:h}=this.appService.runtime;if(a)return!h.includes(this.roomId)&&n?n[e%n.length]:s[e%s.length];const l=o||s;return l[e%l.length]}refreshColor(){const e=this.appService.getRoomData(this.roomId),i=(e==null?void 0:e.colorIndex)??this.roomIndex,s=this.getIconColor(i);if(this.propertyIcons.forEach(({sprite:n})=>{n.tint=s}),this.orderBackground&&this.orderBackground.visible){const{property:n}=this.appService.roomConfig,o=n.iconWidth,a=n.iconHeight;this.orderBackground.clear(),this.orderBackground.setFillStyle({color:s}),this.orderBackground.circle(o/2,a/2,o/2).fill();const h=this.resolveOrderTextColor(i);this.orderText.style.fill=h}}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.propertyIcons.forEach(({sprite:e})=>{e.destroy()}),this.propertyIcons.clear(),super.destroy({children:!0}))}}class E0 extends L{constructor(e,i){super();g(this,"background");g(this,"checkmarkIcon");g(this,"bubble");g(this,"roomIndex");g(this,"roomId");this.appService=e;const s=this.appService.roomConfig;this.roomId=i.id,this.roomIndex=i.index,this.background=new H,this.bubble=new H;const{colors:{selectionIndicatorIcon:n}}=s;this.checkmarkIcon=new Xt(this.appService);const o=i.colorIndex??i.index;this.checkmarkIcon.tint=n[o%n.length],this.checkmarkIcon.anchor.set(0,0),this.addChild(this.background),this.addChild(this.bubble),this.addChild(this.checkmarkIcon)}async updateIndicator(e){const{roomSelectionMode:i,enableRoomSelection:s,selectRoomIds:n}=this.appService.runtimeSnapshot;if(!s||i!=="checkmark"){this.visible=!1;return}const o=n.includes(e.id);await this.showCheckmarkMode(o),this.updateBackground()}async showCheckmarkMode(e){const{selectionIndicator:i}=this.appService.roomConfig,{iconWidth:s,iconHeight:n}=i;if(e){this.visible=!0,this.checkmarkIcon.visible=!0,await this.checkmarkIcon.loadTextureAndSetSize("checkmark",{width:s,height:n,sizeFixed:!1});const o=i.containerWidth/2,a=i.containerHeight/2;this.checkmarkIcon.position.set(o-s/2,a-n/2)}else this.visible=!1}updateBackground(){const{selectionIndicator:e,colors:i}=this.appService.roomConfig,{containerWidth:s,containerHeight:n,strokeWidth:o,strokeColor:a,borderRadius:h,tailHeight:l,tailWidth:c}=e,d=this.appService.getRoomData(this.roomId),u=(d==null?void 0:d.colorIndex)??this.roomIndex,p=i.selectionIndicatorBackground[u%i.selectionIndicatorBackground.length],f=a==="auto"?p:a;if(this.checkmarkIcon.tint=i.selectionIndicatorIcon[u%i.selectionIndicatorIcon.length],this.background.clear(),this.bubble.clear(),this.background.setFillStyle({color:p}).roundRect(0,0,s,n,h).fill().setStrokeStyle({color:f,width:o,alignment:0}).stroke(),l>0&&c>0){const y=(s-c)/2;this.bubble.setFillStyle({color:f});const m=n+o;this.bubble.poly([y,m-1,y+c,m-1,y+c/2,m+l]).fill()}}getTotalHeight(){const{selectionIndicator:e}=this.appService.roomConfig,{containerHeight:i,tailHeight:s,strokeWidth:n}=e;return i+n+(s>0?s:0)}getTotalWidth(){const{selectionIndicator:e}=this.appService.roomConfig;return e.containerWidth}async refreshColor(){const e=this.appService.getRoomData(this.roomId);e&&await this.updateIndicator(e)}destroy(){var e;(e=this.checkmarkIcon)==null||e.destroy(),super.destroy({children:!0})}}class I0 extends L{constructor(e,i){super();g(this,"roomId");g(this,"roomName");g(this,"roomProperty",null);g(this,"roomSelectionIndicator",null);g(this,"clickHandler",null);g(this,"unsubscribeMapRotation",null);g(this,"targetElasticScale",1);g(this,"currentElasticScale",1);g(this,"isAnimatingScale",!1);g(this,"scaleAnimationBound",null);g(this,"updateScaleBound",null);this.appService=e,this.enableRenderGroup(),this.roomId=i.id,this.initializeElasticScale(e.currentScale),this.updateScaleBound=s=>this.updateScale(s),this.appService.emitter.on("antiScale",this.updateScaleBound),this.updateScale(this.appService.currentScale),i.centerPoint&&this.position.set(i.centerPoint.x,i.centerPoint.y),this.roomName=new k0(this.appService,i),this.roomName.visible=this.appService.runtimeSnapshot.showRoomName,this.applyAntiRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=U(this.appService.runtime,"mapRotation",s=>{this.applyAntiRotation(s)}),this.clickHandler=new vt(this,{onClick:()=>{var s,n;(n=(s=this.appService.events)==null?void 0:s.onClickRoomProperties)==null||n.call(s,i)}})}async initialize(e){await this.createRoomProperty(e),await this.createRoomSelectionIndicator(e),this.updateLayout()}applyAntiRotation(e){const i=-e*Math.PI/180;this.rotation=i}initializeElasticScale(e){const{enableElasticScale:i,elasticMinScale:s,elasticMaxScale:n}=this.appService.roomConfig;if(!i)return;const o=1,a=5;let h;e<=o?h=s:e>=a?h=n:h=1,this.targetElasticScale=h,this.currentElasticScale=h}updateScale(e){const{enableElasticScale:i,elasticMinScale:s,elasticMaxScale:n}=this.appService.roomConfig;if(!i){e!==0&&this.scale.set(1/e);return}if(e===0)return;const o=1,a=5;let h;e<=o?h=s:e>=a?h=n:h=1;const c=1/e*h;Math.abs(this.targetElasticScale-h)>.01?(this.targetElasticScale=h,this.startScaleAnimation()):this.scale.set(c)}startScaleAnimation(){this.scaleAnimationBound||(this.scaleAnimationBound=this.animateScale.bind(this)),this.isAnimatingScale||(this.isAnimatingScale=!0,this.appService.getApp().ticker.add(this.scaleAnimationBound))}animateScale(){this.currentElasticScale+=(this.targetElasticScale-this.currentElasticScale)*.3;const n=1/this.appService.currentScale*this.currentElasticScale;this.scale.set(n),Math.abs(this.currentElasticScale-this.targetElasticScale)<.001&&(this.currentElasticScale=this.targetElasticScale,this.isAnimatingScale=!1,this.scaleAnimationBound&&this.appService.getApp().ticker.remove(this.scaleAnimationBound))}shouldShowRoomProperty(){const{showRoomOrder:e,showRoomProperty:i,selectRoomIds:s,enableRoomSelection:n,roomSelectionMode:o}=this.appService.runtimeSnapshot,a=this.appService.getRoomData(this.roomId);if(!a||n&&o==="checkmark"&&s.includes(this.roomId))return!1;const h=e&&(a.order||0)>0;let l=!1;if(i){const{displayOrders:c}=this.appService.roomConfig.property;l=c.some(d=>!!(d==="suction"&&a.suction!=null||d==="cistern"&&a.cistern!=null||d==="cleanMode"&&a.cleanMode!=null||d==="cleanTimes"&&a.cleanTimes>0||a.customData&&d in a.customData&&typeof a.customData[d]=="number"&&a.customData[d]!=null))}return h||l}shouldShowRoomSelectionIndicator(){const{enableRoomSelection:e,roomSelectionMode:i}=this.appService.runtimeSnapshot;return e&&i==="checkmark"}async updateRoomPropertyVisibility(){if(!this.roomProperty)return;if(!this.shouldShowRoomProperty())this.roomProperty.visible=!1;else{this.roomProperty.visible=!0;const i=this.appService.runtimeSnapshot.roomPropertyFoldIds.includes(this.roomId);await this.roomProperty.setFolded(i);const s=this.appService.getRoomData(this.roomId);s&&await this.roomProperty.updateProperty(s)}this.updateLayout()}async updateRoomSelectionIndicatorVisibility(){if(!this.roomSelectionIndicator)return;if(this.shouldShowRoomSelectionIndicator()){const i=this.appService.getRoomData(this.roomId);i&&await this.roomSelectionIndicator.updateIndicator(i)}else this.roomSelectionIndicator.visible=!1;this.updateLayout()}async createRoomProperty(e){this.roomProperty&&(this.removeChild(this.roomProperty),this.roomProperty.destroy()),this.roomProperty=new R0(this.appService,e),await this.roomProperty.updateProperty(e),this.addChild(this.roomProperty),this.addChild(this.roomName),await this.updateRoomPropertyVisibility(),this.updateLayout()}async createRoomSelectionIndicator(e){this.roomSelectionIndicator&&(this.removeChild(this.roomSelectionIndicator),this.roomSelectionIndicator.destroy()),this.roomSelectionIndicator=new E0(this.appService,e),await this.updateRoomSelectionIndicatorVisibility(),this.addChild(this.roomSelectionIndicator)}updateLayout(){var l,c,d,u,p,f;if(this.destroyed)return;const{property:{offsetY:e,offsetX:i},selectionIndicator:{offsetY:s,offsetX:n}}=this.appService.roomConfig,o=((l=this.roomProperty)==null?void 0:l.visible)||!1,a=((c=this.roomName)==null?void 0:c.visible)||!1,h=((d=this.roomSelectionIndicator)==null?void 0:d.visible)||!1;if(o&&this.roomProperty){const y=this.roomProperty.getTotalHeight(),m=this.roomProperty.getTotalWidth();if(this.roomProperty.isFoldedState()){const S=-m/2+i,v=-y/2-e;this.roomProperty.position.set(S,v)}else a&&((u=this.roomName)!=null&&u.position)?(this.roomProperty.position.set(-m/2+i,-e-y),this.roomName.position.set(0,0)):this.roomProperty.position.set(-m/2+i,-y/2-e)}if(h&&this.roomSelectionIndicator){const y=this.roomSelectionIndicator.getTotalHeight(),m=this.roomSelectionIndicator.getTotalWidth();a&&((p=this.roomName)!=null&&p.position)?(this.roomSelectionIndicator.position.set(-m/2+n,-s-y),this.roomName.position.set(0,0)):this.roomSelectionIndicator.position.set(-m/2+n,-y/2-s)}a&&!o&&!h&&((f=this.roomName)!=null&&f.position)&&this.roomName.position.set(0,0)}updateName(e){this.roomName.updateName(e)}async updateRoomType(e){await this.roomName.updateRoomType(e),this.updateLayout()}updateRoomNameVisibility(e){this.roomName.visible=e,this.updateLayout()}updateRoomTypeVisibility(e){this.roomName.updateRoomTypeVisibility(e),this.updateLayout()}updatePosition(e){this.position.set(e.x,e.y)}async refreshColor(){this.roomName&&this.roomName.refreshColor(),this.roomProperty&&this.roomProperty.refreshColor(),this.roomSelectionIndicator&&await this.roomSelectionIndicator.refreshColor()}destroy(){var e,i,s,n;(e=this.clickHandler)==null||e.destroy(),this.clickHandler=null,this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.isAnimatingScale&&this.scaleAnimationBound&&(this.appService.getApp().ticker.remove(this.scaleAnimationBound),this.isAnimatingScale=!1),this.scaleAnimationBound=null,this.updateScaleBound&&(this.appService.emitter.off("antiScale",this.updateScaleBound),this.updateScaleBound=null),(i=this.roomProperty)==null||i.destroy(),this.roomProperty=null,(s=this.roomSelectionIndicator)==null||s.destroy(),this.roomSelectionIndicator=null,(n=this.roomName)==null||n.destroy(),super.destroy()}}class B0 extends L{constructor(e){super({isRenderGroup:!0});g(this,"floorTypeMap",new Map);g(this,"floorTypeMasks",new Map);g(this,"floorTypeContexts",new Map);g(this,"floorTypeToRooms",new Map);this.appService=e,this.appService.appContainer.addToLayer(Fr,this)}async createFloorTypes(e){if(!this.appService.runtimeSnapshot.showRoomFloorType)return;this.clearFloorTypes();const s=this.groupRoomsByFloorType(e),n=[];for(const[o,a]of s)n.push(this.createMergedFloorType(o,a));await Promise.all(n)}groupRoomsByFloorType(e){const i=new Map,s=this.appService;return e.forEach((n,o)=>{const a=s.getRoomData(o),h=(a==null?void 0:a.floorType)||0;h>=0&&(i.has(h)||i.set(h,[]),i.get(h).push({roomId:o,graphics:n}))}),i}async createMergedFloorType(e,i){const s=this.appService,{assets:n,opacity:o,scale:a}=s.roomConfig.floorType,h=e%n.length,l=`floorType${h}`;if(!n[h]){A.warn(`No texture asset configured for floorType: ${e}`);return}const c=await N.load(l);if(!c){A.warn(`Floor material texture not found: ${l}`);return}const d=i.map(({graphics:m})=>m.getLocalBounds()),u=my(d),p=new Ss({texture:c,width:u.width,height:u.height});p.x=u.x,p.y=u.y,p.alpha=o,p.tileScale.set(a);const{maskContainer:f,contexts:y}=this.createMergedMask(i.map(({graphics:m})=>m));p.mask=f,this.addChild(p),this.floorTypeMap.set(e,p),this.floorTypeMasks.set(e,f),this.floorTypeContexts.set(e,y),this.floorTypeToRooms.set(e,new Set(i.map(({roomId:m})=>m)))}createMergedMask(e){const i=new L,s=[];return e.forEach(n=>{const o=new H,a=n.context.clone();o.context=a,s.push(a),i.addChild(o)}),{maskContainer:i,contexts:s}}clearFloorTypes(){this.floorTypeMasks.forEach(e=>{try{e.destroy({children:!0})}catch(i){A.warn("Error destroying floor mask:",i)}}),this.floorTypeMasks.clear(),this.floorTypeContexts.forEach(e=>{try{e.forEach(i=>{try{i.destroy()}catch(s){A.warn("Error destroying cloned graphics context:",s)}})}catch(i){A.warn("Error destroying graphics contexts:",i)}}),this.floorTypeContexts.clear(),this.floorTypeMap.forEach(e=>{try{this.removeChild(e),e.destroy()}catch(i){A.warn("Error destroying floor material:",i)}}),this.floorTypeMap.clear(),this.floorTypeToRooms.clear()}destroy(){this.clearFloorTypes(),super.destroy()}}class D0{constructor(t){g(this,"unsubscribeFns",[]);g(this,"roomInfoContainer",new L);g(this,"roomInfoMap",new Map);g(this,"roomDisplayMap",new Map);g(this,"roomFloorType");this.appService=t,this.roomFloorType=new B0(t),t.appContainer.addToLayer(lc,this.roomInfoContainer);const e=U(t.runtime,"showRoomFloorType",d=>{A.log(`[runtime] showRoomFloorType: ${d}`),d?this.updateFloorTypes():this.roomFloorType.clearFloorTypes()}),i=U(t.runtime,"showRoomProperty",d=>{A.log(`[runtime] showRoomProperty: ${d}`),this.updateAllRoomPropertyVisibility()}),s=U(t.runtime,"showRoomOrder",d=>{A.log(`[runtime] showRoomOrder: ${d}`),this.updateAllRoomPropertyVisibility()}),n=U(t.runtime,"roomPropertyFoldIds",d=>{A.log(`[runtime] roomPropertyFoldIds: ${d}`),this.updateAllRoomPropertyVisibility()}),o=U(t.runtime,"showRoomName",d=>{A.log(`[runtime] showRoomName: ${d}`),this.updateAllRoomNameVisibility(d)}),a=U(t.runtime,"showRoomType",d=>{A.log(`[runtime] showRoomType: ${d}`),this.updateAllRoomTypeVisibility(d)}),h=U(t.runtime,"enableRoomSelection",d=>{A.log(`[runtime] enableRoomSelection: ${d}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility(),this.refreshAllRoomColors()}),l=U(t.runtime,"selectRoomIds",d=>{A.log(`[runtime] selectRoomIds: ${d}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility(),this.refreshAllRoomColors()}),c=U(t.runtime,"roomSelectionMode",d=>{A.log(`[runtime] roomSelectionMode: ${d}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility(),this.refreshAllRoomColors()});this.unsubscribeFns.push(e,i,s,n,o,a,h,l,c)}async drawRoomProperty(t){const e=this.appService;return this.roomDisplayMap.clear(),t.forEach((i,s)=>{const n=e.mapManager.getRoomById(i.id),o={...i,centerPoint:(n==null?void 0:n.centerPoint)||null,index:s,colorIndex:n==null?void 0:n.colorIndex};this.roomDisplayMap.set(i.id,o)}),await this.updateRoomInfoDisplay(),await this.updateFloorTypes(),!0}async updateRoomInfoDisplay(){if(this.roomDisplayMap.size===0){this.appService.mapManager.getAllRooms().length===0&&this.clearRoomInfos();return}const t=Array.from(this.roomDisplayMap.values()).filter(e=>e.centerPoint!==null);this.clearRoomInfos(),await Promise.all(t.map(e=>this.createRoomInfo(e)))}async createRoomInfo(t){const e=new I0(this.appService,t);this.roomInfoContainer.addChild(e),this.roomInfoMap.set(t.id,e),await e.initialize(t)}updateRoomName(t,e){const i=this.roomInfoMap.get(t);i&&i.updateName(e)}async updateRoomType(t,e){const i=this.roomDisplayMap.get(t);i&&(i.type=e);const s=this.roomInfoMap.get(t);s&&await s.updateRoomType(e)}updateRoomPosition(t,e){const i=this.roomDisplayMap.get(t);i&&(i.centerPoint=e);const s=this.roomInfoMap.get(t);s&&s.updatePosition(e)}clearRoomInfos(){if(this.roomInfoMap.size===0)return;const t=Array.from(this.roomInfoMap.values());this.roomInfoContainer.removeChildren(),t.forEach(e=>{try{e.destroy()}catch(i){A.warn(`[RoomManager] Error destroying RoomInfo for room ${e.roomId}:`,i)}}),this.roomInfoMap.clear()}getRoomPropertyById(t){return this.roomDisplayMap.get(t)}async refresh(){const t=this.appService;this.roomFloorType.clearFloorTypes(),this.roomDisplayMap.forEach((e,i)=>{const s=t.mapManager.getRoomById(i),n=(s==null?void 0:s.centerPoint)||null;if(e.centerPoint!==n){e.centerPoint=n;const a=this.roomInfoMap.get(i);a&&n&&a.updatePosition(n)}const o=s==null?void 0:s.colorIndex;if(e.colorIndex!==o&&o!==void 0){e.colorIndex=o;const a=this.roomInfoMap.get(i);a&&a.refreshColor()}}),await this.updateRoomInfoDisplay(),await this.updateFloorTypes()}async updateAllRoomPropertyVisibility(){this.roomInfoMap.size!==0&&await Promise.all(Array.from(this.roomInfoMap.values()).map(async t=>{try{await t.updateRoomPropertyVisibility()}catch(e){console.warn(`[RoomManager] Failed to update room property visibility for room ${t.roomId}`,e)}}))}updateAllRoomNameVisibility(t){this.roomInfoMap.size!==0&&this.roomInfoMap.forEach(e=>{e.updateRoomNameVisibility(t)})}updateAllRoomTypeVisibility(t){this.roomInfoMap.size!==0&&this.roomInfoMap.forEach(e=>{e.updateRoomTypeVisibility(t)})}updateAllRoomSelectionIndicatorVisibility(){this.roomInfoMap.size!==0&&this.roomInfoMap.forEach(t=>{t.updateRoomSelectionIndicatorVisibility()})}refreshAllRoomColors(){this.roomInfoMap.size!==0&&this.roomInfoMap.forEach(t=>{t.refreshColor()})}async updateFloorTypes(){const t=this.appService,e=t.mapManager.roomFill.getRoomGraphicsMap();e.size>0?(await this.roomFloorType.createFloorTypes(e),t.getApp().renderOnceNextFrame()):t.mapManager.getAllRooms().length===0&&this.roomFloorType.clearFloorTypes()}clear(){this.clearRoomInfos(),this.roomInfoContainer.removeChildren(),this.roomInfoMap.clear(),this.roomDisplayMap.clear(),this.roomFloorType.clearFloorTypes()}destroy(){this.clearRoomInfos(),this.roomInfoContainer.destroy(),this.roomFloorType.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}var Xa,Za;(Xa=navigator==null?void 0:navigator.userAgent)!=null&&Xa.includes("tuya-ark-ide")||((Za=navigator==null?void 0:navigator.userAgent)==null||Za.includes("miniProgram"));const F0=()=>{var i,s;if(!Ln.any)return!0;const r=navigator.userAgent.toLowerCase(),t=()=>{const n=navigator.deviceMemory;return n?n>=4:!0};let e=!1;if(/iphone|ipad|ipod/.test(r)){const n=(i=r.match(/os (\d+)_/))==null?void 0:i[1];e=(n?parseInt(n):0)>=12}else if(/android/.test(r)){const n=(s=r.match(/android (\d+)/))==null?void 0:s[1];e=(n?parseInt(n):0)>=10}return e&&t()};class z0 extends L{constructor(e,i,s){super();g(this,"graphics");g(this,"sprite",null);g(this,"viewportBounds");g(this,"lastConfig",null);g(this,"onImageLoaded");this.label="background",this.viewportBounds=i,this.onImageLoaded=s,this.graphics=new H,this.graphics.label="backgroundGraphics",this.addChild(this.graphics),this.render(e)}async render(e){if(this.lastConfig=e,this.clear(),e.backgroundImage){await this.renderImage(e.backgroundImage,e.backgroundAlpha);return}if(e.backgroundGradient){this.renderGradient(e.backgroundGradient);return}if(e.backgroundColor!==void 0){this.renderSolidColor(e.backgroundColor,e.backgroundAlpha);return}A.warn("[Background] No background configuration provided")}clear(){this.graphics.clear(),this.sprite&&(this.removeChild(this.sprite),this.sprite.destroy(),this.sprite=null)}renderSolidColor(e,i){this.graphics.clear(),this.graphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill({color:e,alpha:i}),A.debug("[Background] Rendered solid color background",{color:e,alpha:i})}renderGradient(e){const{width:i,height:s}=this.viewportBounds;if(this.graphics.clear(),e.type==="linear"){const n=e.x0??0,o=e.y0??0,a=e.x1??1,h=e.y1??1,l=new Ot({type:"linear",start:{x:n,y:o},end:{x:a,y:h},colorStops:e.colorStops});this.graphics.rect(0,0,i,s).fill(l),A.debug("[Background] Rendered linear gradient background",{x0:n,y0:o,x1:a,y1:h,colorStops:e.colorStops.length})}else if(e.type==="radial"){const n=e.cx??.5,o=e.cy??.5,a=e.r??.5,h=new Ot({type:"radial",center:{x:n,y:o},innerRadius:0,outerCenter:{x:n,y:o},outerRadius:a,colorStops:e.colorStops});this.graphics.rect(0,0,i,s).fill(h),A.debug("[Background] Rendered radial gradient background",{cx:n,cy:o,r:a,colorStops:e.colorStops.length})}}async renderImage(e,i){var s,n,o,a;try{const h=await N.load(e.src);if(!h){A.error("[Background] Failed to load image:",e.src),(s=this.lastConfig)!=null&&s.backgroundColor&&this.renderSolidColor(this.lastConfig.backgroundColor,i);return}this.sprite=new jt(h),this.sprite.label="backgroundSprite",this.sprite.alpha=i;const{width:l,height:c}=this.viewportBounds,d=e.fit||"cover",u=((n=e.position)==null?void 0:n.x)??.5,p=((o=e.position)==null?void 0:o.y)??.5,f=h.width,y=h.height,m=f/y,x=l/c;switch(d){case"fill":this.sprite.width=l,this.sprite.height=c,this.sprite.x=0,this.sprite.y=0;break;case"contain":m>x?(this.sprite.width=l,this.sprite.height=l/m):(this.sprite.height=c,this.sprite.width=c*m),this.sprite.x=(l-this.sprite.width)*u,this.sprite.y=(c-this.sprite.height)*p;break;case"cover":m>x?(this.sprite.height=c,this.sprite.width=c*m):(this.sprite.width=l,this.sprite.height=l/m),this.sprite.x=(l-this.sprite.width)*u,this.sprite.y=(c-this.sprite.height)*p;break;case"none":this.sprite.width=f,this.sprite.height=y,this.sprite.x=(l-f)*u,this.sprite.y=(c-y)*p;break}e.repeat&&A.warn("[Background] Repeat mode not yet implemented"),this.addChild(this.sprite),A.debug("[Background] Rendered image background",{src:e.src,fit:d,position:{x:u,y:p},spriteSize:{width:this.sprite.width,height:this.sprite.height}}),this.onImageLoaded&&this.onImageLoaded()}catch(h){A.error("[Background] Error loading background image:",h),(a=this.lastConfig)!=null&&a.backgroundColor&&this.renderSolidColor(this.lastConfig.backgroundColor,i)}}async update(e){await this.render(e)}destroy(){this.clear(),super.destroy()}}class L0 extends L{constructor(e){super();g(this,"carpetData");g(this,"carpetConfig");g(this,"controlsConfig");g(this,"carpetEvents");g(this,"appService");g(this,"controlFill");g(this,"editControlLayer");g(this,"clickHandler",null);g(this,"maskContainer",null);g(this,"maskGraphics",null);g(this,"texture",null);g(this,"textureMap",new Map);g(this,"tilingSprite",null);g(this,"initialZonePoints",[]);g(this,"unsubscribeFns",[]);g(this,"handleDragStart",()=>{this.isEditingEnabled()&&(this.carpetData.points&&this.carpetData.points.length>0?this.initialZonePoints=this.carpetData.points.map(e=>({...e})):this.initialZonePoints=[],this.appService.getApp().requestRender("zone-drag",!0))});g(this,"handleDragMove",e=>{if(!this.isEditingEnabled()||this.initialZonePoints.length===0||this.carpetData.shape==="custom")return;const i=this.parent.toLocal(e.global),s=this.controlFill.getDragStartPosition();if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.applyTranslation(n,o)});g(this,"handleDragEnd",()=>{var e,i;this.initialZonePoints=[],this.appService.getApp().stopRender("zone-drag"),(i=(e=this.carpetEvents).onUpdate)==null||i.call(e,this.getCarpetData())});g(this,"handleMoveStart",()=>{this.carpetData.points&&this.carpetData.points.length>0?this.initialZonePoints=this.carpetData.points.map(e=>({...e})):this.initialZonePoints=[],this.appService.getApp().requestRender("zone-move",!0)});g(this,"handleMove",e=>{var a,h;if(!this.isEditingEnabled()||this.initialZonePoints.length===0)return;const i=this.parent.toLocal(e.global),s=(h=(a=this.editControlLayer)==null?void 0:a.getMoveButton())==null?void 0:h.getDragStartPosition();if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.applyTranslation(n,o)});g(this,"handleMoveEnd",()=>{var e,i;this.initialZonePoints=[],this.appService.getApp().stopRender("zone-move"),(i=(e=this.carpetEvents).onUpdate)==null||i.call(e,this.getCarpetData())});g(this,"handleRotationStart",()=>{this.appService.getApp().requestRender("zone-rotate",!0)});g(this,"handleRotationMove",e=>{e&&(this.carpetData.points=e,this.drawCarpet())});g(this,"handleRotationEnd",()=>{var e,i;this.appService.getApp().stopRender("zone-rotate"),(i=(e=this.carpetEvents).onUpdate)==null||i.call(e,this.getCarpetData())});g(this,"handleScaleStart",()=>{this.appService.getApp().requestRender("zone-scale",!0)});g(this,"handleScaleMove",e=>{e&&(this.carpetData.points=e,this.drawCarpet())});g(this,"handleScaleMoveHorizontal",e=>{e&&(this.carpetData.points=e,this.drawCarpet())});g(this,"handleScaleMoveVertical",e=>{e&&(this.carpetData.points=e,this.drawCarpet())});g(this,"handleScaleEnd",()=>{var e,i;this.appService.getApp().stopRender("zone-scale"),(i=(e=this.carpetEvents).onUpdate)==null||i.call(e,this.getCarpetData())});g(this,"handleDelete",()=>{var e,i;(i=(e=this.carpetEvents).onRemove)==null||i.call(e,this.carpetData.id)});g(this,"handleClick",()=>{var e,i;this.isEditingEnabled()||(i=(e=this.carpetEvents)==null?void 0:e.onClick)==null||i.call(e,this.getCarpetData())});g(this,"handlePointsUpdate",e=>{this.carpetData.points=e,this.drawCarpet()});const{appService:i,carpetData:s,events:n={},textureMap:o}=e;this.appService=i,this.textureMap=o,this.carpetEvents=n,this.controlsConfig=this.getControlsConfig(),this.carpetConfig=this.controlsConfig.carpet,this.processCarpetData(s),this.initializeComponents(),this.createEditControlLayer(),this.setupClickHandler(),this.setupEnableRoomSelectionListener(),this.updateEditState(),this.loadTexture()}processCarpetData(e){if(e.points&&e.points.length>=2)if(e.shape==="custom")this.carpetData={...e,points:e.points};else{const s=Ia(e.points,this.appService.metersToPixels(this.carpetConfig.minSize)),n=bs(s);this.carpetData={...e,points:n}}else this.carpetData={...e,points:[],shape:e.shape||"rectangle"}}getControlsConfig(){const{controls:e}=this.appService.getConfig();return e}isEditingEnabled(){return this.appService.runtimeSnapshot.editingCarpetIds.includes(this.carpetData.id)}isSelected(){return this.appService.runtimeSnapshot.selectedCarpetIds.includes(this.carpetData.id)}shouldShowEditControl(){return this.isEditingEnabled()||this.isSelected()}initializeComponents(){this.maskContainer=this.createMaskContainer(),this.controlFill=this.createControlFill(),this.addChild(this.maskContainer),this.addChild(this.controlFill),this.drawCarpet()}createMaskContainer(){const e=new L;return this.maskGraphics=new H,this.updateMaskShape(),e.addChild(this.maskGraphics),e.mask=this.maskGraphics,e}createControlFill(){const e=this.isEditingEnabled();return new Lr(this.appService,{points:this.carpetData.points||[],fillColor:this.carpetConfig.fillColor,enableInteraction:e,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createEditControlLayer(){const e=this.isEditingEnabled(),i=this.carpetData.shape==="custom",s={...wn(this.carpetConfig,["outlineStrokeWidth","outlineDashed","outlineDashArray","outlineFillColor","outlineOffset","outlineStrokeColor"]),...wn(this.carpetConfig,["textColor","textPosition","textOffset"]),...wn(this.controlsConfig,["textFontSize","textFontFamily","textFontWeight"]),showRotateButton:!!e&&!i,showScaleButton:!!e&&!i,showDeleteButton:!!e,showMoveButton:!!e&&!i,showRadialScaleButton:!!e&&!i,iconWrapperFillColor:this.carpetConfig.iconWrapperFillColor,moveButtonOffset:this.controlsConfig.moveButtonOffset},n=i?this.calculateBoundingRectanglePoints():this.carpetData.points||[];this.editControlLayer=this.appService.editControlManager.registerEditControl(this.carpetData.id,{config:s,zonePoints:n,minSize:this.carpetConfig.minSize,events:{onRemove:this.handleDelete,onRotateStart:this.handleRotationStart,onRotateMove:this.handleRotationMove,onRotateEnd:this.handleRotationEnd,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleMoveHorizontal:this.handleScaleMoveHorizontal,onScaleMoveVertical:this.handleScaleMoveVertical,onScaleEnd:this.handleScaleEnd,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd,onClick:this.handleClick,onPointsUpdate:this.handlePointsUpdate}})}setupClickHandler(){this.interactiveChildren=!0,this.clickHandler=new vt(this,{onClick:()=>{var e,i;this.isEditingEnabled()||(i=(e=this.carpetEvents)==null?void 0:e.onClick)==null||i.call(e,this.getCarpetData())},stopPropagation:!1})}setupEnableRoomSelectionListener(){const e=U(this.appService.runtime,"enableRoomSelection",s=>{this.updateClickHandlerState(s)});this.unsubscribeFns.push(e);const i=this.appService.runtimeSnapshot.enableRoomSelection;this.updateClickHandlerState(i)}isRoomSelectionEnabled(){return this.appService.runtimeSnapshot.enableRoomSelection}updateClickHandlerState(e){if(e){if(this.eventMode="none",this.clickHandler){const i=this.clickHandler.getTarget();i.eventMode="none"}}else if(this.eventMode="static",this.clickHandler){const i=this.clickHandler.getTarget();i.eventMode="static"}}calculateBounds(){const{points:e}=this.carpetData;let i=1/0,s=1/0,n=-1/0,o=-1/0;if(e&&e.length>0)for(const a of e)i=Math.min(i,a.x),s=Math.min(s,a.y),n=Math.max(n,a.x),o=Math.max(o,a.y);return{minX:i,minY:s,maxX:n,maxY:o}}calculateBoundingRectanglePoints(){const{points:e}=this.carpetData;if(!e||e.length===0)return[];const{minX:i,minY:s,maxX:n,maxY:o}=vs(e);return[{x:i,y:s},{x:n,y:s},{x:n,y:o},{x:i,y:o}]}updateMaskShape(){if(!this.maskGraphics)return;this.maskGraphics.clear();const{points:e,shape:i}=this.carpetData;if(!(!e||!Array.isArray(e)||e.length<2)){if(i==="round"){if(e.length<4)return;const n=ee(e),[o,a,,h]=e,l=Q(o,a),c=Q(o,h),d=Math.atan2(a.y-o.y,a.x-o.x);this.maskGraphics.position.set(n.x,n.y),this.maskGraphics.rotation=d,this.maskGraphics.ellipse(0,0,l/2,c/2)}else{const n=e.flatMap(o=>[o.x,o.y]);this.maskGraphics.poly(n),this.maskGraphics.position.set(0,0),this.maskGraphics.rotation=0}this.maskGraphics.fill(16777215)}}loadTexture(){const{opacity:e,scale:i}=this.appService.carpetConfig,{type:s}=this.carpetData;try{this.texture=this.textureMap.get(s)||this.textureMap.get(-1)||null,this.texture&&this.maskContainer&&(this.tilingSprite&&(this.maskContainer.removeChild(this.tilingSprite),this.tilingSprite.destroy(),this.tilingSprite=null),this.createTilingSprite(i,e),this.appService.getApp().renderOnce())}catch(n){console.warn("Failed to load carpet texture:",n)}}createTilingSprite(e,i){if(!this.texture||!this.maskContainer)return;const s=this.calculateBounds();this.tilingSprite=new Ss({texture:this.texture,width:s.maxX-s.minX+100,height:s.maxY-s.minY+100}),this.tilingSprite.position.set(s.minX-50,s.minY-50),this.tilingSprite.tileScale.set(e),this.tilingSprite.alpha=i,this.maskContainer.addChild(this.tilingSprite)}updateTilingSprite(){if(!this.tilingSprite)return;const e=this.calculateBounds();this.tilingSprite.position.set(e.minX-50,e.minY-50),this.tilingSprite.width=e.maxX-e.minX+100,this.tilingSprite.height=e.maxY-e.minY+100}applyTranslation(e,i){this.carpetData.points=this.initialZonePoints.map(s=>({x:s.x+e,y:s.y+i})),this.drawCarpet()}drawCarpet(){const{points:e}=this.carpetData;if(!(!e||e.length<2)&&(this.updateMaskShape(),this.updateTilingSprite(),this.controlFill.updatePoints(e),this.editControlLayer)){const n=this.carpetData.shape==="custom"?this.calculateBoundingRectanglePoints():e;this.editControlLayer.updatePoints(n)}}updateEditState(){const e=this.isEditingEnabled(),i=this.isSelected(),s=this.shouldShowEditControl();if(this.controlFill.setInteractionEnabled(e),this.editControlLayer)if(i&&!e)this.appService.editControlManager.updateEditState(this.carpetData.id,{showRotateButton:!1,showScaleButton:!1,showDeleteButton:!1,showMoveButton:!1,showBorder:!0,showSizeText:!1,borderStyle:this.carpetConfig.normal});else if(e){const n=this.carpetData.shape==="custom";this.appService.editControlManager.updateEditState(this.carpetData.id,{showRotateButton:!n,showScaleButton:!n,showDeleteButton:!0,showMoveButton:!n,showBorder:!0,showSizeText:!0,borderStyle:this.carpetConfig.editing,showRadialScaleButton:!n})}else this.appService.editControlManager.updateEditState(this.carpetData.id,{showRotateButton:!1,showScaleButton:!1,showDeleteButton:!1,showMoveButton:!1,showBorder:!1,showSizeText:!1});this.zIndex=s?1e3:0}updateCarpetData(e){const s=this.carpetData.type;if(e.points&&e.points.length>=2)if(e.shape==="custom")this.carpetData={...e,points:e.points};else{const n=Ia(e.points,this.appService.metersToPixels(this.carpetConfig.minSize)),o=bs(n);this.carpetData={...e,points:o}}else this.carpetData={...e,points:e.points||[]};s!==this.carpetData.type&&this.loadTexture(),this.drawCarpet(),this.updateEditState()}getCarpetData(){return{...this.carpetData}}refreshDisplay(){this.drawCarpet()}destroy(){var e,i,s,n,o;this.appService.editControlManager.unregisterEditControl(this.carpetData.id),this.unsubscribeFns.forEach(a=>a()),this.unsubscribeFns=[],(e=this.tilingSprite)==null||e.destroy(),(i=this.maskGraphics)==null||i.destroy(),(s=this.maskContainer)==null||s.destroy(),this.tilingSprite=null,this.maskGraphics=null,this.maskContainer=null,this.texture=null,(n=this.controlFill)==null||n.destroy(),(o=this.clickHandler)==null||o.destroy(),super.destroy()}}class O0{constructor(t){g(this,"customCarpetMap",new Map);g(this,"unsubscribeFns",[]);g(this,"textureMap",new Map);g(this,"texturesLoaded",!1);g(this,"texturesLoadingPromise",null);this.appService=t;const e=U(t.runtime,"editingCarpetIds",s=>{A.log(`[runtime] editingCarpetIds: ${s}`),this.updateCarpetsEditState()}),i=U(t.runtime,"selectedCarpetIds",s=>{A.log(`[runtime] selectedCarpetIds: ${s}`),this.updateCarpetsEditState()});this.unsubscribeFns.push(e,i)}async loadTextures(){if(!this.texturesLoaded){if(this.texturesLoadingPromise)return this.texturesLoadingPromise;this.texturesLoadingPromise=this._loadTextures(),await this.texturesLoadingPromise,this.texturesLoaded=!0,this.texturesLoadingPromise=null}}async _loadTextures(){const t=this.appService,{material:e,src:i}=t.carpetConfig;if(e)for(const s of e){const n=await N.load(s.src);this.textureMap.set(s.type,n)}if(i){const s=await N.load(i);this.textureMap.set(-1,s)}}updatePositionByOrigin(t,e){const s=this.appService.appContainer.getLayer(us);s&&s.position.set(t,e)}async drawCustomCarpets(t){if(await this.loadTextures(),!t||t.length===0){this.clearAllCustomCarpets();return}const e=new Set(this.customCarpetMap.keys()),i=new Set(t.map(s=>s.id));for(const s of e)i.has(s)||this.removeCustomCarpet(s);t.forEach(s=>{const n=this.customCarpetMap.get(s.id.toString());n?this.isCarpetDataEqual(n.getCarpetData(),s)||n.updateCarpetData(s):this.addNewCustomCarpet(s)})}getCustomCarpets(){const t=[];return this.customCarpetMap.forEach(e=>{t.push(e.getCarpetData())}),t}getCustomCarpetById(t){return this.customCarpetMap.get(t)}clearAllCustomCarpets(){this.customCarpetMap.forEach((t,e)=>{var s;const i=this.customCarpetMap.get(e);i&&((s=i.parent)==null||s.removeChild(i),i.destroy())}),this.customCarpetMap.clear()}addNewCustomCarpet(t){const e=this.appService,i=new L0({appService:e,carpetData:t,textureMap:this.textureMap,events:{onRemove:s=>{var n,o;(o=(n=e.events)==null?void 0:n.onDeleteCustomCarpet)==null||o.call(n,{id:s})},onUpdate:s=>{var n,o;(o=(n=e.events)==null?void 0:n.onUpdateCustomCarpet)==null||o.call(n,s)},onClick:s=>{var n,o;(o=(n=e.events)==null?void 0:n.onClickCarpet)==null||o.call(n,{id:s.id})}}});this.customCarpetMap.set(t.id.toString(),i),e.appContainer.addToLayer(us,i)}removeCustomCarpet(t){const e=this.appService,i=this.customCarpetMap.get(t);i&&(e.appContainer.removeFromLayer(us,i),i.destroy(),this.customCarpetMap.delete(t))}updateCarpetsEditState(){this.customCarpetMap.forEach(t=>{t.updateEditState()})}isCarpetDataEqual(t,e){if(t.id!==e.id||t.type!==e.type||t.shape!==e.shape)return!1;const i=t.points||[],s=e.points||[];if(i.length!==s.length)return!1;for(let n=0;n<i.length;n++){const o=i[n],a=s[n];if(Math.abs(o.x-a.x)>.1||Math.abs(o.y-a.y)>.1)return!1}return!0}refreshDisplay(){this.customCarpetMap.forEach(t=>{t.refreshDisplay()})}destroy(){this.clearAllCustomCarpets(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}class G0 extends Wi{constructor(t,e){super(t,e),this.cursor="pointer"}setupEvents(){this.on("pointertap",()=>{var t,e;(e=(t=this.options).onClick)==null||e.call(t)})}destroy(){this.removeAllListeners(),super.destroy()}}const Ft={REMOVE:0,ROTATE:1,SCALE:2,MOVE:3,FIXED:0};class W0 extends L{constructor(e){super();g(this,"appService");g(this,"data");g(this,"furnitureEvents");g(this,"textureAlias");g(this,"sprite");g(this,"controlButtons");g(this,"outlineBorder");g(this,"moveLine");g(this,"deleteButton",null);g(this,"rotateButton",null);g(this,"scaleButton",null);g(this,"moveButton",null);g(this,"sizeText",null);g(this,"isEditing",!1);g(this,"dragStartPosition",null);g(this,"initialPoints",[]);g(this,"clickHandler",null);g(this,"isDragging",!1);g(this,"initialScalePoints",[]);g(this,"initialButtonPosition",null);g(this,"rotationCount",0);g(this,"onDragStart",e=>{var s,n;if(!this.isEditing||!this.parent||e.target!==this)return;(n=(s=this.appService.events)==null?void 0:s.onGestureStart)==null||n.call(s),this.appService.getApp().requestRender("furniture-drag",!0);const i=this.parent.toLocal(e.global);this.dragStartPosition={x:i.x,y:i.y},this.initialPoints=this.data.points.map(o=>({...o})),this.isDragging=!1});g(this,"onDragMove",e=>{if(!this.isEditing||!this.dragStartPosition||!this.parent)return;const i=this.parent.toLocal(e.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y;!this.isDragging&&Math.abs(s)+Math.abs(n)<3||(this.isDragging=!0,this.data.points=this.initialPoints.map(o=>({x:o.x+s,y:o.y+n})),this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText())});g(this,"onDragEnd",()=>{var e,i,s,n;!this.isEditing||!this.dragStartPosition||(this.isDragging&&((i=(e=this.furnitureEvents).onUpdate)==null||i.call(e,this.getData())),this.dragStartPosition=null,this.initialPoints=[],this.isDragging=!1,this.appService.getApp().stopRender("furniture-drag"),(n=(s=this.appService.events)==null?void 0:s.onGestureEnd)==null||n.call(s))});g(this,"handleScaleStart",()=>{this.initialScalePoints=this.data.points.map(i=>({...i}));const e=this.getVisualIndex(Ft.SCALE);e>=0&&e<this.data.points.length&&(this.initialButtonPosition={...this.data.points[e]}),this.appService.getApp().requestRender("furniture-scale",!0)});g(this,"handleScaleMove",({deltaX:e,deltaY:i})=>{if(this.initialScalePoints.length===0||!this.initialButtonPosition)return;const s={x:this.initialButtonPosition.x+e,y:this.initialButtonPosition.y+i};this.applyEdgeBasedScale(s)});g(this,"handleScaleEnd",()=>{var e,i;this.initialScalePoints=[],this.initialButtonPosition=null,this.appService.getApp().stopRender("furniture-scale"),(i=(e=this.furnitureEvents).onUpdate)==null||i.call(e,this.getData())});g(this,"handleMoveStart",()=>{this.initialPoints=this.data.points.map(e=>({...e})),this.appService.getApp().requestRender("furniture-move",!0)});g(this,"handleMoveMove",e=>{var a;if(!this.isEditing||this.initialPoints.length===0||!this.parent)return;const i=this.parent.toLocal(e.global),s=(a=this.moveButton)==null?void 0:a.getDragStartPosition();if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.data.points=this.initialPoints.map(h=>({x:h.x+n,y:h.y+o})),this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText()});g(this,"handleMoveEnd",()=>{var e,i;this.initialPoints=[],this.appService.getApp().stopRender("furniture-move"),(i=(e=this.furnitureEvents).onUpdate)==null||i.call(e,this.getData())});const{appService:i,data:s,textureAlias:n,events:o={}}=e;this.appService=i,this.data={...s,points:s.points.map(a=>({...a}))},this.textureAlias=n,this.furnitureEvents=o,this.createSprite(),this.updateSpriteTransform(),this.createEditControls(),this.eventMode="static",this.cursor="pointer",this.setupInteraction()}get config(){return this.appService.furnitureConfig}getVisualIndex(e){return(e+4-this.rotationCount)%4}getVisualPoints(){const e=this.data.points;return[e[this.getVisualIndex(0)],e[this.getVisualIndex(1)],e[this.getVisualIndex(2)],e[this.getVisualIndex(3)]]}createSprite(){const e=N.get(this.textureAlias);this.sprite=new jt(e),this.sprite.anchor.set(.5),this.sprite.alpha=this.config.opacity,this.sprite.eventMode="none",this.addChild(this.sprite)}updateSpriteTransform(){const e=this.data.points;if(e.length<4)return;const i=ee(e),s=e[1].x-e[0].x,n=e[1].y-e[0].y,o=Math.atan2(n,s),a=Q(e[0],e[1]),h=Q(e[1],e[2]);this.sprite.position.set(i.x,i.y),this.sprite.rotation=o,this.sprite.width=a,this.sprite.height=h}createEditControls(){const e=this.calculateOutlinePoints();this.outlineBorder=new Nt(this.appService,{points:e,closePath:!0,style:{color:this.config.outlineStrokeColor,width:this.config.outlineStrokeWidth,isDashed:this.config.outlineDashed,dashArray:this.config.outlineDashArray,fillColor:this.config.outlineFillColor}}),this.outlineBorder.visible=!1,this.addChild(this.outlineBorder);const i=this.calculateMoveLinePoints(e);this.moveLine=new Nt(this.appService,{points:i,closePath:!1,style:{color:this.config.outlineStrokeColor,width:this.config.outlineStrokeWidth,isDashed:this.config.outlineDashed,dashArray:this.config.outlineDashArray}}),this.moveLine.visible=!1,this.addChild(this.moveLine),this.controlButtons=new L,this.controlButtons.visible=!1,this.addChild(this.controlButtons),this.createControlButtons()}createControlButtons(){const e=this.calculateOutlinePoints();if(e.length<4)return;const{iconWrapperFillColor:i}=this.config,s=this.getVisualIndex(Ft.REMOVE),n=this.getVisualIndex(Ft.ROTATE),o=this.getVisualIndex(Ft.SCALE);this.deleteButton=new Ds(this.appService,{iconAlias:"deleteIcon",backgroundColor:i,onClick:()=>{var h,l;return(l=(h=this.furnitureEvents).onRemove)==null?void 0:l.call(h,this.data.id)}}),this.deleteButton.position.set(e[s].x,e[s].y),this.rotateButton=new G0(this.appService,{iconAlias:"rotateIcon",backgroundColor:i,onClick:()=>this.handleTapRotate()}),this.rotateButton.position.set(e[n].x,e[n].y),this.scaleButton=new Ze(this.appService,{iconAlias:"scaleIcon",backgroundColor:i,getTargetPoints:()=>this.data.points,getButtonIndex:()=>this.getVisualIndex(Ft.SCALE),onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(e[o].x,e[o].y);const a=this.calculateMoveButtonPosition(e);this.moveButton=new Fs(this.appService,{iconAlias:"moveIcon",backgroundColor:i,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMoveMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(a.x,a.y),this.controlButtons.addChild(this.deleteButton),this.controlButtons.addChild(this.rotateButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton),this.config.showSizeText&&(this.sizeText=this.createSizeText(),this.controlButtons.addChild(this.sizeText))}calculateOutlinePoints(){const{points:e}=this.data;if(e.length<4)return e;const i=this.appService.getApp().toFixedSize(this.config.outlineOffset);return Ir(e,i)}calculateMoveButtonPosition(e){const i=e??this.calculateOutlinePoints();if(i.length<4)return{x:0,y:0};const{controls:s}=this.appService.getConfig(),n=this.getVisualIndex(Ft.MOVE),o=this.getVisualIndex(2),a=this.getVisualIndex(0),h=this.appService.getApp().toFixedSize(s.moveButtonOffset);return Is(i[n],i[o],i[a],h)}calculateMoveLinePoints(e,i){if(e.length<4)return[];const s=this.getVisualIndex(Ft.MOVE),n=i??this.calculateMoveButtonPosition(e);return[e[s],n]}createSizeText(){const e=this.calculateSizeTextContent(),i=this.appService.controlsConfig,s=new Ui(this.appService,{text:e,style:{fontSize:i.textFontSize,fontFamily:i.textFontFamily,fontWeight:i.textFontWeight,fill:this.config.textColor,align:"center"}});s.anchor.set(.5);const n=this.calculateSizeTextPosition();s.position.set(n.x,n.y);const o=this.calculateSizeTextRotation();return s.rotation=o,s.eventMode="none",s}calculateSizeTextContent(){const{points:e}=this.data;if(e.length<4)return"0m*0m";const[i,s,,n]=this.getVisualPoints(),o=Q(i,s),a=Q(i,n),h=this.appService.pixelsToMeters(o),l=this.appService.pixelsToMeters(a),c=this.appService.metersToDisplayUnit(h),d=this.appService.metersToDisplayUnit(l),u=this.appService.runtimeSnapshot.unitLabel;return`${c.toFixed(1)}${u}*${d.toFixed(1)}${u}`}calculateSizeTextPosition(){const{points:e}=this.data;if(e.length<4)return{x:0,y:0};const[i,s,n,o]=this.getVisualPoints(),{textPosition:a,textOffset:h}=this.config,l=this.appService.getApp().toFixedSize(h);let c,d;switch(a){case"top":{c={x:(i.x+s.x)/2,y:(i.y+s.y)/2};const u=pt(q(s,i)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}case"right":{c={x:(s.x+n.x)/2,y:(s.y+n.y)/2};const u=pt(q(s,n)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}case"bottom":{c={x:(o.x+n.x)/2,y:(o.y+n.y)/2};const u=pt(q(o,n)),p={x:-u.y,y:u.x};d={x:p.x*l,y:p.y*l};break}case"left":{c={x:(i.x+o.x)/2,y:(i.y+o.y)/2};const u=pt(q(o,i)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}default:c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},d={x:0,y:l};break}return{x:c.x+d.x,y:c.y+d.y}}calculateSizeTextRotation(){const{points:e}=this.data;if(e.length<4)return 0;const[i,s,n,o]=this.getVisualPoints(),{textPosition:a}=this.config;let h,l;switch(a){case"top":h=i,l=s;break;case"right":h=s,l=n;break;case"bottom":h=n,l=o;break;case"left":h=o,l=i;break;default:h=i,l=s;break}const c=this.appService.appContainer.getMapRotationRadians();return Xe(h,l,c)}setupInteraction(){this.clickHandler=new vt(this,{onClick:()=>{var e,i;this.isDragging||(i=(e=this.furnitureEvents).onClick)==null||i.call(e,this.getData())}}),this.on("pointerdown",this.onDragStart,this),this.on("pointermove",this.onDragMove,this),this.on("pointerup",this.onDragEnd,this),this.on("pointerupoutside",this.onDragEnd,this)}handleTapRotate(){var n,o;const e=this.config.rotateDirection!=="ccw",i=e?Math.PI/2:-Math.PI/2,s=ee(this.data.points);this.data.points=Er(this.data.points,s,i),this.rotationCount=(this.rotationCount+(e?1:3))%4,this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText(),(o=(n=this.furnitureEvents).onUpdate)==null||o.call(n,this.getData())}applyEdgeBasedScale(e){if(this.initialScalePoints.length<4)return;const i=this.getVisualIndex(Ft.FIXED),s=this.getVisualIndex(1),n=this.getVisualIndex(3),{x:o,y:a}=this.initialScalePoints[i],h=this.initialScalePoints[s],l=this.initialScalePoints[n],c={x:o,y:a},d=q(c,h),u=q(c,l),p=q(c,e),f=ie(d),y=ie(u);if(f===0||y===0)return;const{minScaleRatio:m,maxScaleRatio:x}=this.config;let S=he(p,d,f,0),v=he(p,u,y,0);S=Math.max(m,Math.min(x,S)),v=Math.max(m,Math.min(x,v));const b=[c,{x:o+d.x*S,y:a+d.y*S},{x:o+d.x*S+u.x*v,y:a+d.y*S+u.y*v},{x:o+u.x*v,y:a+u.y*v}],P=new Array(4);for(let w=0;w<4;w++)P[this.getVisualIndex(w)]=b[w];this.data.points=P,this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText(!0)}updateEditControls(){var h;const e=this.calculateOutlinePoints();if(e.length<4)return;this.outlineBorder.updatePoints(e);const i=this.calculateMoveButtonPosition(e),s=this.calculateMoveLinePoints(e,i);if(this.moveLine.updatePoints(s),!this.deleteButton||!this.rotateButton||!this.scaleButton)return;const n=this.getVisualIndex(Ft.REMOVE),o=this.getVisualIndex(Ft.ROTATE),a=this.getVisualIndex(Ft.SCALE);this.deleteButton.position.set(e[n].x,e[n].y),this.rotateButton.position.set(e[o].x,e[o].y),this.scaleButton.position.set(e[a].x,e[a].y),(h=this.moveButton)==null||h.position.set(i.x,i.y)}updateSizeText(e=!1){if(!this.sizeText)return;if(e){const n=this.calculateSizeTextContent();this.sizeText.updateText(n)}const i=this.calculateSizeTextPosition();this.sizeText.position.set(i.x,i.y);const s=this.calculateSizeTextRotation();this.sizeText.rotation=s}getData(){return{id:this.data.id,furnitureType:this.data.furnitureType,points:this.data.points.map(e=>({...e}))}}updateData(e){this.data={...e,points:e.points.map(i=>({...i}))},this.rotationCount=0,this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText(!0)}updateEditState(e){this.isEditing!==e&&(this.isEditing=e,this.outlineBorder.visible=e,this.moveLine.visible=e,this.controlButtons.visible=e)}destroy(){var e;(e=this.clickHandler)==null||e.destroy(),this.clickHandler=null,super.destroy({children:!0})}}class U0{constructor(t){g(this,"furnitureMap",new Map);g(this,"unsubscribeFns",[]);this.appService=t;const e=U(t.runtime,"editingFurnitureIds",i=>{A.log(`[runtime] editingFurnitureIds: ${i}`),this.updateEditState()});this.unsubscribeFns.push(e)}updatePositionByOrigin(t,e){const i=this.appService.appContainer.getLayer(ds);i&&i.position.set(t,e)}async drawFurnitures(t){if(!t||t.length===0){this.clearAll();return}const e=new Set(this.furnitureMap.keys()),i=new Set(t.map(n=>n.id));for(const n of e)i.has(n)||this.removeFurniture(n);const s=[];for(const n of t){const o=this.furnitureMap.get(n.id);o?this.isDataEqual(o.getData(),n)||o.updateData(n):s.push(this.addFurniture(n))}await Promise.all(s)}async addFurniture(t){const e=this.appService;if(!e.furnitureConfig.assets.find(h=>h.type===t.furnitureType)){A.warn(`[FurnitureManager] No asset found for furnitureType: ${t.furnitureType}`);return}const n=`furniture_${t.furnitureType}`;await N.load(n);const o=new W0({appService:e,data:t,textureAlias:n,events:{onRemove:h=>{var l,c;(c=(l=e.events)==null?void 0:l.onRemoveFurniture)==null||c.call(l,h)},onUpdate:h=>{var l,c;(c=(l=e.events)==null?void 0:l.onUpdateFurniture)==null||c.call(l,h)},onClick:h=>{var l,c;(c=(l=e.events)==null?void 0:l.onClickFurniture)==null||c.call(l,h)}}});this.furnitureMap.set(t.id,o),e.appContainer.addToLayer(ds,o),e.runtime.editingFurnitureIds.includes(t.id)&&o.updateEditState(!0)}removeFurniture(t){const e=this.furnitureMap.get(t);e&&(this.appService.appContainer.removeFromLayer(ds,e),e.destroy(),this.furnitureMap.delete(t))}clearAll(){var t;for(const[,e]of this.furnitureMap)(t=e.parent)==null||t.removeChild(e),e.destroy();this.furnitureMap.clear()}updateEditState(){const t=this.appService.runtime.editingFurnitureIds;this.furnitureMap.forEach((e,i)=>{e.updateEditState(t.includes(i))})}isDataEqual(t,e){if(t.id!==e.id||t.furnitureType!==e.furnitureType||t.points.length!==e.points.length)return!1;for(let i=0;i<t.points.length;i++)if(Math.abs(t.points[i].x-e.points[i].x)>.1||Math.abs(t.points[i].y-e.points[i].y)>.1)return!1;return!0}destroy(){this.clearAll(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}const ft={REMOVE:0,ROTATE:1,SCALE:2,MOVE:3};class H0 extends L{constructor(e,i){super();g(this,"config");g(this,"events");g(this,"zonePoints",[]);g(this,"outlinePoints");g(this,"minSize",.1);g(this,"initialZonePoints",[]);g(this,"scaleCache",null);g(this,"rotationCache",null);g(this,"outlineBorder");g(this,"moveLine");g(this,"sizeText");g(this,"controlButtons");g(this,"deleteButton",null);g(this,"rotateButton",null);g(this,"scaleButton",null);g(this,"moveButton",null);g(this,"horizontalScaleButton",null);g(this,"verticalScaleButton",null);g(this,"horizontalScaleInitialPosition",null);g(this,"verticalScaleInitialPosition",null);g(this,"clickHandler",null);g(this,"throttledUpdateOutline");this.appService=e,this.zonePoints=i.zonePoints,this.config={...i.config,showScaleButton:i.config.showScaleButton!==void 0?i.config.showScaleButton:!0,showRadialScaleButton:i.config.showRadialScaleButton!==void 0?i.config.showRadialScaleButton:!0,showDeleteButton:i.config.showDeleteButton!==void 0?i.config.showDeleteButton:!0,showMoveButton:i.config.showMoveButton!==void 0?i.config.showMoveButton:!0,showRotateButton:i.config.showRotateButton!==void 0?i.config.showRotateButton:!0},this.events=i.events||{},this.minSize=i.minSize??.1,this.throttledUpdateOutline=At(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.registerScaleListener()}initializeComponents(){this.outlinePoints=this.calculateOutlinePoints(),this.outlineBorder=this.createOutlineBorder(),this.addChild(this.outlineBorder),this.moveLine=this.createMoveLine(),this.addChild(this.moveLine),this.moveLine.visible=this.config.showMoveButton||!1,this.sizeText=this.createSizeText(),this.addChild(this.sizeText),this.controlButtons=new L,this.addChild(this.controlButtons),this.createControlButtons(),this.setupClickHandler()}createOutlineBorder(){const{outlineStrokeColor:e,outlineStrokeWidth:i,outlineDashed:s,outlineDashArray:n,outlineFillColor:o}=this.config;return new Nt(this.appService,{points:this.outlinePoints,closePath:!0,style:{color:e,width:i,isDashed:s,dashArray:n,fillColor:o}})}createMoveLine(){const{outlineStrokeColor:e,outlineStrokeWidth:i,outlineDashed:s,outlineDashArray:n}=this.config,o=this.calculateMoveLinePoints();return new Nt(this.appService,{points:o,closePath:!1,style:{color:e,width:i,isDashed:s,dashArray:n}})}createSizeText(){const e=this.calculateSizeText(),i=new Ui(this.appService,{text:e,style:{fontSize:this.config.textFontSize,fontFamily:this.config.textFontFamily,fontWeight:this.config.textFontWeight,fill:this.config.textColor,align:"center"}});i.anchor.set(.5);const s=this.calculateSizeTextPosition();i.position.set(s.x,s.y);const n=this.calculateSizeTextRotation();return i.rotation=n,i.eventMode="none",i}createDeleteButton(){const e=new Ds(this.appService,{iconAlias:"deleteIcon",backgroundColor:"red",onClick:()=>{var i,s;return(s=(i=this.events).onRemove)==null?void 0:s.call(i)}});return e.position.set(this.outlinePoints[ft.REMOVE].x,this.outlinePoints[ft.REMOVE].y),e}createRotateButton(){const e=new fc(this.appService,{iconAlias:"rotateIcon",backgroundColor:this.config.iconWrapperFillColor,getTargetPoints:()=>this.zonePoints,onRotationStart:i=>{var s,n;this.initializeRotationCache(i),(n=(s=this.events).onRotateStart)==null||n.call(s,i)},onClick:()=>{var n,o;const i=Math.PI/2,s=this.onClickRotateButton(i);(o=(n=this.events).onRotateMove)==null||o.call(n,s??void 0)},onRotationEnd:()=>{var i,s;this.resetRotationState(),(s=(i=this.events).onRotateEnd)==null||s.call(i)}});return e.position.set(this.outlinePoints[ft.ROTATE].x,this.outlinePoints[ft.ROTATE].y),e}onClickRotateButton(e){const i=this.handleInternalRotationMove(e)??[];return this.resetRotationState(),i}createScaleButton(){const e=new Ze(this.appService,{iconAlias:"scaleIcon",backgroundColor:this.config.iconWrapperFillColor,initialButtonPosition:this.outlinePoints[ft.SCALE],onScaleStart:()=>{var i,s;this.initializeScaleCache(),(s=(i=this.events).onScaleStart)==null||s.call(i)},onScaleMove:({deltaX:i,deltaY:s})=>{var o,a;const n=this.handleInternalScaleMove(i,s);(a=(o=this.events).onScaleMove)==null||a.call(o,n??void 0)},onScaleEnd:()=>{var i,s;this.resetScaleState(),this.initialZonePoints=[],(s=(i=this.events).onScaleEnd)==null||s.call(i)}});return e.position.set(this.outlinePoints[ft.SCALE].x,this.outlinePoints[ft.SCALE].y),e}createHorizontalScaleButton(){const[,e,i]=this.outlinePoints,s=this.getEdgeCenter(e,i),n=new Ze(this.appService,{iconAlias:"horizontalScaleIcon",backgroundColor:this.config.iconWrapperFillColor,config:{iconWrapperWidth:18,iconWrapperHeight:18,iconWrapperBorderRadius:18,iconWidth:10,iconHeight:8},initialButtonPosition:s,onScaleStart:()=>{var h,l;const[,o,a]=this.zonePoints;this.horizontalScaleInitialPosition=this.getEdgeCenter(o,a),this.initializeScaleCache(),(l=(h=this.events).onScaleStart)==null||l.call(h)},onScaleMove:({deltaX:o,deltaY:a})=>{var l,c;const h=this.handleInternalHorizontalScaleMove(o,a);(c=(l=this.events).onScaleMoveHorizontal)==null||c.call(l,h??void 0)},onScaleEnd:()=>{var o,a;this.resetScaleState(),this.initialZonePoints=[],this.horizontalScaleInitialPosition=null,(a=(o=this.events).onScaleEnd)==null||a.call(o)}});return n.position.set(s.x,s.y),n}createVerticalScaleButton(){const[,,e,i]=this.outlinePoints,s=this.getEdgeCenter(e,i),n=new Ze(this.appService,{iconAlias:"verticalScaleIcon",backgroundColor:this.config.iconWrapperFillColor,config:{iconWrapperWidth:18,iconWrapperHeight:18,iconWrapperBorderRadius:18,iconWidth:8,iconHeight:10},initialButtonPosition:s,onScaleStart:()=>{var h,l;const[,,o,a]=this.zonePoints;this.verticalScaleInitialPosition=this.getEdgeCenter(o,a),this.initializeScaleCache(),(l=(h=this.events).onScaleStart)==null||l.call(h)},onScaleMove:({deltaX:o,deltaY:a})=>{var l,c;const h=this.handleInternalVerticalScaleMove(o,a);(c=(l=this.events).onScaleMoveVertical)==null||c.call(l,h??void 0)},onScaleEnd:()=>{var o,a;this.resetScaleState(),this.initialZonePoints=[],this.verticalScaleInitialPosition=null,(a=(o=this.events).onScaleEnd)==null||a.call(o)}});return n.position.set(s.x,s.y),n}createMoveButton(){const e=this.calculateMoveButtonPosition(),i=new Fs(this.appService,{iconAlias:"moveIcon",backgroundColor:this.config.iconWrapperFillColor,onMoveStart:()=>{var s,n;return(n=(s=this.events).onMoveStart)==null?void 0:n.call(s)},onMoveMove:s=>{var n,o;return(o=(n=this.events).onMoveMove)==null?void 0:o.call(n,s)},onMoveEnd:()=>{var s,n;return(n=(s=this.events).onMoveEnd)==null?void 0:n.call(s)}});return i.position.set(e.x,e.y),i}createAndAddButton(e,i){return e.visible=i,this.controlButtons.addChild(e),e}createControlButtons(){this.outlinePoints.length<4||(this.deleteButton=this.createAndAddButton(this.createDeleteButton(),this.config.showDeleteButton??!1),this.moveButton=this.createAndAddButton(this.createMoveButton(),this.config.showMoveButton??!1),this.rotateButton=this.createAndAddButton(this.createRotateButton(),this.config.showRotateButton??!1),this.scaleButton=this.createAndAddButton(this.createScaleButton(),this.config.showScaleButton??!1),console.log("this.config.showRadialScaleButton",this.config.showRadialScaleButton),this.horizontalScaleButton=this.createAndAddButton(this.createHorizontalScaleButton(),this.config.showRadialScaleButton??!1),this.verticalScaleButton=this.createAndAddButton(this.createVerticalScaleButton(),this.config.showRadialScaleButton??!1))}calculateOutlinePoints(){const e=this.zonePoints;if(e.length<4)return e;const s=this.appService.getApp().toFixedSize(this.config.outlineOffset);return Ir(e,s)}calculateMoveButtonPosition(){const e=this.calculateOutlinePoints();if(e.length<4)return{x:0,y:0};const s=this.appService.getApp().toFixedSize(this.config.moveButtonOffset),n=e[ft.MOVE],o=e[ft.SCALE],a=e[ft.REMOVE];return Is(n,o,a,s)}calculateMoveLinePoints(){const e=this.calculateOutlinePoints();if(e.length<4)return[];const i=e[ft.MOVE],s=this.calculateMoveButtonPosition();return[i,s]}calculateSizeText(){const e=this.zonePoints;if(e.length<4)return"0m*0m";const[i,s,,n]=e,o=Q(i,s),a=Q(i,n),h=this.appService,l=h.pixelsToMeters(o),c=h.pixelsToMeters(a),d=h.metersToDisplayUnit(l),u=h.metersToDisplayUnit(c),p=h.runtimeSnapshot.unitLabel;return`${d.toFixed(1)}${p}*${u.toFixed(1)}${p}`}getEdgeCenter(e,i){return{x:(e.x+i.x)/2,y:(e.y+i.y)/2}}calculatePerpendicularOffset(e,i,s,n=!1){const o=pt(q(i,e)),a=n?{x:-o.y,y:o.x}:{x:o.y,y:-o.x};return{x:a.x*s,y:a.y*s}}calculateSizeTextPosition(){if(this.zonePoints.length<4)return{x:0,y:0};const i=this.calculateOutlinePoints(),[s,n,o,a]=i,{textPosition:h,textOffset:l}=this.config,d=this.appService.getApp().toFixedSize(l);let u,p;switch(h){case"top":u=this.getEdgeCenter(s,n),p=this.calculatePerpendicularOffset(n,s,d);break;case"right":u=this.getEdgeCenter(n,o),p=this.calculatePerpendicularOffset(n,o,d);break;case"bottom":u=this.getEdgeCenter(a,o),p=this.calculatePerpendicularOffset(a,o,d,!0);break;case"left":u=this.getEdgeCenter(s,a),p=this.calculatePerpendicularOffset(a,s,d);break;default:u=this.getEdgeCenter(s,n),p={x:0,y:d};break}return{x:u.x+p.x,y:u.y+p.y}}calculateSizeTextRotation(){const e=this.zonePoints;if(e.length<4)return 0;const[i,s,n,o]=e,{textPosition:a}=this.config;let h,l;switch(a){case"top":h=i,l=s;break;case"right":h=s,l=n;break;case"bottom":h=n,l=o;break;case"left":h=o,l=i;break;default:h=i,l=s;break}const c=this.appService.appContainer.getMapRotationRadians();return Xe(h,l,c)}calculateHorizontalScaleButtonRotation(){const e=this.zonePoints;if(e.length<4)return 0;const[,i,s]=e,n=this.appService.appContainer.getMapRotationRadians();return Xe(i,s,n)+Math.PI/2}calculateVerticalScaleButtonRotation(){const e=this.zonePoints;if(e.length<4)return 0;const[,,i,s]=e,n=this.appService.appContainer.getMapRotationRadians();return Xe(s,i,n)}updatePoints(e,i=!0){this.zonePoints=e,this.updateOutlineBorder(),this.moveLine&&this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeText(i)}updateOutlineBorder(){const e=this.calculateOutlinePoints();this.outlinePoints=e,this.outlineBorder.updatePoints(e)}updateMoveLine(){if(!this.moveLine)return;const e=this.calculateMoveLinePoints();this.moveLine.updatePoints(e)}updateSizeText(e=!0){if(this.sizeText){if(e){const i=this.calculateSizeText();this.sizeText.updateText(i)}this.updateSizeTextPosition()}}updateSizeTextPosition(){if(!this.sizeText)return;const e=this.calculateSizeTextPosition();this.sizeText.position.set(e.x,e.y);const i=this.calculateSizeTextRotation();this.sizeText.rotation=i}updateControlButtonsPosition(){if(!this.deleteButton||!this.scaleButton||!this.moveButton)return;const e=this.calculateOutlinePoints();if(e.length<4)return;const i=this.calculateMoveButtonPosition(),s=[{button:this.deleteButton,point:e[ft.REMOVE]},{button:this.scaleButton,point:e[ft.SCALE]},{button:this.moveButton,point:i}];if(this.rotateButton&&s.push({button:this.rotateButton,point:e[ft.ROTATE]}),this.horizontalScaleButton){const n=e[ft.ROTATE],o=e[ft.SCALE],a=Jl(n,o,0);s.push({button:this.horizontalScaleButton,point:a})}if(this.verticalScaleButton){const n=e[ft.SCALE],o=e[ft.MOVE],a=this.getEdgeCenter(n,o);s.push({button:this.verticalScaleButton,point:a})}s.forEach(({button:n,point:o})=>n.position.set(o.x,o.y)),this.horizontalScaleButton&&(this.horizontalScaleButton.rotation=this.calculateHorizontalScaleButtonRotation()),this.verticalScaleButton&&(this.verticalScaleButton.rotation=this.calculateVerticalScaleButtonRotation()),this.scaleButton&&this.scaleButton.visible&&(this.scaleButton.rotation=this.calculateVerticalScaleButtonRotation())}setupClickHandler(){this.clickHandler=new vt(this,{onClick:()=>{var e,i;(i=(e=this.events).onClick)==null||i.call(e)},stopPropagation:!1})}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateOutline),this.appService.emitter.on("mapRotationUpdate",this.throttledUpdateOutline)}updateOutlineForScale(){(this.outlineBorder.visible||this.controlButtons.visible)&&(this.updateOutlineBorder(),this.moveLine&&this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition())}initializeScaleCache(){if(this.initialZonePoints.length===0&&(this.initialZonePoints=this.zonePoints.map(p=>({...p}))),this.initialZonePoints.length<4)return;const e={...this.initialZonePoints[ft.SCALE]};if(!e)return;const i=ft.REMOVE,{x:s,y:n}=this.initialZonePoints[i],[,o,,a]=this.initialZonePoints,h={x:s,y:n},l=q(h,o),c=q(h,a),d=ie(l),u=ie(c);d===0||u===0||(this.scaleCache={fixedPoint:h,edge1:l,edge2:c,edge1Len:d,edge2Len:u,initialButtonPosition:e})}handleInternalScaleMove(e,i){if(this.initialZonePoints.length!==4||!this.scaleCache)return null;const s=this.appService.metersToPixels(this.minSize),{fixedPoint:n,edge1:o,edge2:a,edge1Len:h,edge2Len:l,initialButtonPosition:c}=this.scaleCache,d={x:c.x+e,y:c.y+i},u=q(n,d),p=he(u,o,h,s),f=he(u,a,l,s);return this.calculatePointsFromScale(n,o,a,p,f)}resetScaleState(){this.scaleCache=null}handleInternalHorizontalScaleMove(e,i){if(this.initialZonePoints.length!==4||!this.scaleCache||!this.horizontalScaleInitialPosition)return null;const{fixedPoint:s,edge1:n,edge2:o,edge1Len:a}=this.scaleCache,h=this.appService.metersToPixels(this.minSize),l={x:this.horizontalScaleInitialPosition.x+e,y:this.horizontalScaleInitialPosition.y+i},c=q(s,l),d=he(c,n,a,h);return this.calculatePointsFromScale(s,n,o,d,1)}handleInternalVerticalScaleMove(e,i){if(this.initialZonePoints.length!==4||!this.scaleCache||!this.verticalScaleInitialPosition)return null;const{fixedPoint:s,edge1:n,edge2:o,edge2Len:a}=this.scaleCache,h=this.appService.metersToPixels(this.minSize),l={x:this.verticalScaleInitialPosition.x+e,y:this.verticalScaleInitialPosition.y+i},c=q(s,l),d=1,u=he(c,o,a,h);return this.calculatePointsFromScale(s,n,o,d,u)}calculatePointsFromScale(e,i,s,n,o){const{x:a,y:h}=e;return[e,{x:a+i.x*n,y:h+i.y*n},{x:a+i.x*n+s.x*o,y:h+i.y*n+s.y*o},{x:a+s.x*o,y:h+s.y*o}]}initializeRotationCache(e){this.zonePoints.length<3||(this.rotationCache={rotationCenter:e,initialPoints:this.zonePoints.map(i=>({...i})),totalAngle:0})}handleInternalRotationMove(e){if(!this.rotationCache||this.rotationCache.initialPoints.length<3)return null;const{rotationCenter:i,initialPoints:s}=this.rotationCache;return this.rotationCache.totalAngle+=e,Er(s,i,this.rotationCache.totalAngle)}resetRotationState(){this.rotationCache=null}calculateRotationCenter(){return this.zonePoints.length===0?{x:0,y:0}:ee(this.zonePoints)}updateEditState({showRotateButton:e=!1,showScaleButton:i=!1,showRadialScaleButton:s=!1,showDeleteButton:n=!1,showMoveButton:o=!1,showBorder:a=!1,showSizeText:h=!1,borderStyle:l}){this.rotateButton&&(this.rotateButton.visible=e),this.scaleButton&&(this.scaleButton.visible=i),this.horizontalScaleButton&&(this.horizontalScaleButton.visible=s),this.verticalScaleButton&&(this.verticalScaleButton.visible=s),this.deleteButton&&(this.deleteButton.visible=n),this.moveButton&&(this.moveButton.visible=o);const c=e||i||s||n||o;this.controlButtons.visible=c,!c&&this.getOperationState().hasAnyOperation&&this.stopAllOperations(),this.outlineBorder.visible=a,this.moveLine&&(this.moveLine.visible=o),this.sizeText&&(this.sizeText.visible=h),a&&(this.updateOutlineBorder(),c&&(this.moveLine&&o&&this.updateMoveLine(),this.updateControlButtonsPosition()),h&&this.updateSizeTextPosition()),l&&this.outlineBorder.updateStyle({isDashed:l.isDashed,dashArray:l.dashArray})}getOperationState(){var n,o,a;const e=((n=this.scaleButton)==null?void 0:n.isCurrentlyScaling())||!1,i=((o=this.rotateButton)==null?void 0:o.isCurrentlyRotating())||!1,s=((a=this.moveButton)==null?void 0:a.isCurrentlyMoving())||!1;return{isDragging:!1,isScaling:e,isRotating:i,isMoving:s,hasAnyOperation:e||i||s}}stopAllOperations(){var e,i,s;(e=this.scaleButton)==null||e.stopScaling(),(i=this.rotateButton)==null||i.stopRotation(),(s=this.moveButton)==null||s.stopMoving()}getControlButtonsContainer(){return this.controlButtons}getMoveButton(){return this.moveButton}calculateEdgeMidpoint(e,i){const s=this.calculateOutlinePoints();if(s.length<4)return{x:0,y:0};const n=s[e],o=s[i];return{x:(n.x+o.x)/2,y:(n.y+o.y)/2}}destroy(){var e,i,s,n,o,a,h,l,c,d,u;this.appService.emitter.off("antiScale",this.throttledUpdateOutline),this.appService.emitter.off("mapRotationUpdate",this.throttledUpdateOutline),(e=this.clickHandler)==null||e.destroy(),this.clickHandler=null,(i=this.deleteButton)==null||i.destroy(),(s=this.rotateButton)==null||s.destroy(),(n=this.scaleButton)==null||n.destroy(),(o=this.moveButton)==null||o.destroy(),(a=this.horizontalScaleButton)==null||a.destroy(),(h=this.verticalScaleButton)==null||h.destroy(),this.deleteButton=null,this.rotateButton=null,this.scaleButton=null,this.moveButton=null,this.horizontalScaleButton=null,this.verticalScaleButton=null,(l=this.outlineBorder)==null||l.destroy(),(c=this.moveLine)==null||c.destroy(),(d=this.sizeText)==null||d.destroy(),(u=this.controlButtons)==null||u.destroy(),super.destroy()}}class V0{constructor(t){g(this,"editControlLayers",new Map);this.appService=t}registerEditControl(t,e){const i=this.appService;this.editControlLayers.has(t)&&this.unregisterEditControl(t);const s=new H0(i,e);if(!i.appContainer.addToLayer(Ti,s))throw A.warn(`[EditControlManager] Failed to add edit control layer for id: ${t}`),s.destroy(),new Error(`Failed to register edit control for id: ${t}`);return this.editControlLayers.set(t,s),s}unregisterEditControl(t){const e=this.editControlLayers.get(t);if(!e)return;this.appService.appContainer.removeFromLayer(Ti,e),e.destroy(),this.editControlLayers.delete(t)}getEditControl(t){return this.editControlLayers.get(t)}updateEditState(t,e){const i=this.editControlLayers.get(t);i&&i.updateEditState(e)}clearAll(){Array.from(this.editControlLayers.keys()).forEach(e=>this.unregisterEditControl(e))}getAllEditControls(){return Array.from(this.editControlLayers.values())}updatePositionByOrigin(t,e){const s=this.appService.appContainer.getLayer(Ti);s&&s.position.set(t,e)}hasEditControl(t){return this.editControlLayers.has(t)}}class Vr extends $h{constructor(e=Ha){super();g(this,"mapState",null);g(this,"components",{});g(this,"managers",{});g(this,"config",Ua);g(this,"runtime");g(this,"appService");g(this,"scaleMin",.5);g(this,"scaleMax",5);g(this,"events",{});g(this,"instanceKey");g(this,"containerElement");g(this,"emitter",Bx());g(this,"tickerState",{renderReasons:new Set,renderTimer:null});g(this,"pendingAsyncRender",!1);g(this,"isFirstMapDraw",!0);g(this,"isMapDrawn",!1);g(this,"onVisibilityChange",()=>{var i;document.visibilityState==="visible"||(i=this.components.interaction)==null||i.clearTouches()});this.instanceKey=e,this.appService=new ic(this),globalThis.__PIXI_APP__=this}async initialize(e){const{resizeTo:i,events:s,config:n,runtime:o={},...a}=e;this.config=sr(_a({},Ua,n??{})),sy(()=>this.config.global.enableLogger),A.log("Applying config",this.config,n),this.runtime=sr(Object.assign({},Ix,o));const h=this.instanceKey===Ha;this.containerElement=i;const l=h&&this.config.interaction.enable,c=this.config.global.performanceMode||!h,d={textureGCMaxIdle:c?60:Ln.any?180:3600,textureGCCheckCountMax:c?10:Ln.any?100:50,autoStart:!1,sharedTicker:c,eventFeatures:{move:l,globalMove:!1,click:l,wheel:l}};await this.init({resizeTo:h?i:void 0,preference:this.config.global.rendererPreference,resolution:this.config.global.resolution,antialias:c?!1:F0(),depth:!c,autoDensity:!0,backgroundColor:0,backgroundAlpha:0,...d,...a}),A.log(`[Pixi] Renderer initialized: ${this.renderer.type===Ri.WEBGPU?"WebGPU":"WebGL"} ${this.renderer.type}`),this.preloadAssets(),this.scaleMax=this.config.interaction.zoomRange.max,this.scaleMin=this.config.interaction.zoomRange.min,this.events=s,this.initializeViewportContainer(),this.initializeInteraction(),this.initializeAppContainer(),this.managers.mapManager=new Vx(this.appService),this.managers.heatmapManager=new Kx(this.appService),this.managers.pathManager=new Zx(this.appService),this.managers.controlsManager=new t0(this.appService),this.managers.detectedObjectManager=new i0(this.appService),this.managers.customElementsManager=new T0(this.appService),this.managers.roomsManager=new D0(this.appService),this.managers.customCarpetManager=new O0(this.appService),this.managers.furnitureManager=new U0(this.appService),this.managers.editControlManager=new V0(this.appService),this.setupMapRotationListener(),document.addEventListener("visibilitychange",this.onVisibilityChange)}async drawMap(e){var a,h,l,c,d,u,p;this.isMapDrawn=!1,A.log("[Map] drawMap",e);const{size:i,resolution:s,origin:n,id:o}=e;((a=this.mapState)==null?void 0:a.id)!==void 0&&this.mapState.id!==o&&this.managers.pathManager.clear(),(n[0]!==((h=this.mapState)==null?void 0:h.origin.x)||n[1]!==((l=this.mapState)==null?void 0:l.origin.y))&&(this.managers.pathManager.updatePositionByOrigin(...n),this.managers.controlsManager.updatePositionByOrigin(...n),this.managers.detectedObjectManager.updatePositionByOrigin(...n),this.managers.customElementsManager.updatePositionByOrigin(...n),this.managers.customCarpetManager.updatePositionByOrigin(...n),this.managers.furnitureManager.updatePositionByOrigin(...n),this.managers.editControlManager.updatePositionByOrigin(...n),this.managers.heatmapManager.updatePositionByOrigin(...n)),this.mapState={id:e.id,status:e.status===1,origin:{x:n[0],y:n[1]},charger:{x:e.charger.coordinate[0],y:e.charger.coordinate[1]},chargerDirection:e.charger.angle??0,resolution:s,width:i[0],height:i[1],mapType:"structured"},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,(d=(c=this.events)==null?void 0:c.onMapFirstDrawed)==null||d.call(c,this.mapState)),(p=(u=this.events)==null?void 0:u.onMapDrawed)==null||p.call(u,this.mapState),await this.managers.mapManager.drawMap(e),i[0]===0||i[1]===0?(A.log("[Map] Map cleared, clearing path and room data"),this.managers.pathManager.clear(),this.managers.roomsManager.clear(),this.isMapDrawn=!1):(this.isMapDrawn=!0,this.managers.heatmapManager.onMapLoaded()),this.renderOnce()}async drawRasterMap(e){var a,h,l,c,d,u;this.isMapDrawn=!1,A.log("[Map] drawRasterMap",e);const{mapHeader:i,mapData:s}=e,{originX:n,originY:o}=i;(n!==((a=this.mapState)==null?void 0:a.origin.x)||o!==((h=this.mapState)==null?void 0:h.origin.y))&&(this.managers.pathManager.updatePositionByOrigin(n,o),this.managers.controlsManager.updatePositionByOrigin(n,o),this.managers.editControlManager.updatePositionByOrigin(n,o),this.managers.furnitureManager.updatePositionByOrigin(n,o),this.managers.detectedObjectManager.updatePositionByOrigin(n,o),this.managers.customElementsManager.updatePositionByOrigin(n,o),this.managers.heatmapManager.updatePositionByOrigin(n,o)),this.mapState={id:i.id,status:i.mapStable,origin:{x:n,y:o},charger:{x:i.chargeX,y:i.chargeY},chargerDirection:i.chargeDirection??0,resolution:i.mapResolution*100,width:i.mapWidth,height:i.mapHeight,version:i.version,mapType:"raster"},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,(c=(l=this.events)==null?void 0:l.onMapFirstDrawed)==null||c.call(l,this.mapState)),(u=(d=this.events)==null?void 0:d.onMapDrawed)==null||u.call(d,this.mapState),await this.managers.mapManager.drawRasterMap(s.parsed,this.mapState),i.mapWidth===0||i.mapHeight===0?(A.log("[Map] Map cleared, clearing path and room data"),this.managers.pathManager.clear(),this.managers.roomsManager.clear(),this.isMapDrawn=!1):(this.isMapDrawn=!0,this.managers.heatmapManager.onMapLoaded()),this.renderOnce()}drawPath(e){var i,s;A.log("[Path] drawPath",e),(s=(i=this.events)==null?void 0:i.onPathDrawed)==null||s.call(i,{id:e.pathHeader.pathId,type:e.pathHeader.type,direction:e.pathHeader.direction,count:e.pathHeader.count,initFlag:e.pathHeader.initFlag,robotPosition:e.pathPoints[e.pathPoints.length-1]??null}),this.managers.pathManager.draw(e),this.renderOnce()}async drawRoomProperty(e){var i,s;A.log("[Room] drawRoomProperty",e),(s=(i=this.events)==null?void 0:i.onRoomPropertiesDrawed)==null||s.call(i,e),await this.managers.roomsManager.drawRoomProperty(e),this.renderOnceNextFrame()}async drawCustomCarpets(e){A.log("[CustomCarpets] drawCustomCarpets",e),await this.managers.customCarpetManager.drawCustomCarpets(e),this.renderOnceNextFrame()}async drawFurnitures(e){A.log("[Furniture] drawFurnitures",e),await this.managers.furnitureManager.drawFurnitures(e),this.renderOnceNextFrame()}drawHeatmap(e){A.log("[Heatmap] drawHeatmap",e),this.managers.heatmapManager.draw(e),this.renderOnce()}drawForbiddenSweepZones(e){A.log("[Controls] drawForbiddenSweepZones",e),this.managers.controlsManager.drawForbiddenSweepZones(e),this.renderOnceNextFrame()}drawForbiddenMopZones(e){A.log("[Controls] drawForbiddenMopZones",e),this.managers.controlsManager.drawForbiddenMopZones(e),this.renderOnceNextFrame()}drawCleanZones(e){A.log("[Controls] drawCleanZones",e),this.managers.controlsManager.drawCleanZones(e),this.renderOnceNextFrame()}drawVirtualWalls(e){A.log("[Controls] drawVirtualWalls",e),this.managers.controlsManager.drawVirtualWalls(e),this.renderOnceNextFrame()}drawSpots(e){A.log("[Controls] drawSpots",e),this.managers.controlsManager.drawSpots(e),this.renderOnceNextFrame()}drawWayPoints(e){A.log("[Controls] drawWayPoints",e),this.managers.controlsManager.drawWayPoints(e),this.renderOnceNextFrame()}async drawDetectedObjects(e){A.log("[DetectedObject] drawDetectedObjects",e),await this.managers.detectedObjectManager.drawDetectedObjects(e),this.renderOnceNextFrame()}drawCustomCarpet(e){A.log("[CustomCarpet] drawCustomCarpet",e),this.managers.customCarpetManager.drawCustomCarpets(e),this.renderOnceNextFrame()}async drawCustomElements(e){A.log("[CustomElements] drawCustomElements",e),await this.managers.customElementsManager.drawCustomElements(e),this.renderOnceNextFrame()}getForbiddenSweepZones(){return this.managers.controlsManager.getForbiddenSweepZones()}getForbiddenMopZones(){return this.managers.controlsManager.getForbiddenMopZones()}getCleanZones(){return this.managers.controlsManager.getCleanZones()}getVirtualWalls(){return this.managers.controlsManager.getVirtualWalls()}getSpots(){return this.managers.controlsManager.getSpots()}getWayPoints(){return this.managers.controlsManager.getWayPoints()}getEffectiveDividerPoints(){return this.managers.controlsManager.getEffectiveDividerPoints()}getCustomCarpets(){return this.managers.customCarpetManager.getCustomCarpets()}getDividerEndPoints(){return this.managers.controlsManager.getDividerEndPoints()}resetPanZoom(){this.components.interaction.setPanZoom()}forceEndGesture(){A.log("[Map] forceEndGesture"),this.components.interaction.forceEndGesture()}fitMapToView(e,i=!1){if(!e||e.minX===e.maxX||e.minY===e.maxY)return;const s=this.config.map.autoPaddingVerticalPercent,n=this.config.map.autoPaddingHorizontalPercent,o=this.getViewportBounds(),a=this.components.appContainer.getMapRotationRadians(),h=this.calculateRotatedBounds(e,a),l=h.maxX-h.minX,c=h.maxY-h.minY,d=o.width,u=o.height,p=d*(1-n*2),f=u*(1-s*2),y=p/l,m=f/c,x=Math.min(y,m),S=Math.max(this.config.interaction.fitMinScale,this.scaleMin),v=Math.min(this.config.interaction.fitMaxScale,this.scaleMax),b=Math.max(S,Math.min(v,x)),P=e.minX+(e.maxX-e.minX)/2,w=e.minY+(e.maxY-e.minY)/2,C=this.config.map.autoFitOffset||{x:0,y:0},k=d/2+(C.x||0),M=u/2+(C.y||0),T=Math.cos(a),_=Math.sin(a),I=P*T-w*_,B=P*_+w*T,F=k-I*b,Z=M-B*b;A.debug("[MapApplication] fitMapToView calculated:",{rotation:this.components.appContainer.getMapRotation(),originalBounds:e,rotatedBounds:h,finalScale:b,position:{x:F,y:Z}}),this.components.interaction.setPanZoom({targetPosition:{x:F,y:Z},targetScale:{x:b,y:b},setCenter:!0,setScale:!0},i)}calculateRotatedBounds(e,i){if(i===0)return e;const s=(e.minX+e.maxX)/2,n=(e.minY+e.maxY)/2,o=[{x:e.minX-s,y:e.minY-n},{x:e.maxX-s,y:e.minY-n},{x:e.maxX-s,y:e.maxY-n},{x:e.minX-s,y:e.maxY-n}],a=Math.cos(i),h=Math.sin(i),l=o.map(f=>({x:f.x*a-f.y*h,y:f.x*h+f.y*a}));let c=1/0,d=1/0,u=-1/0,p=-1/0;return l.forEach(f=>{c=Math.min(c,f.x),d=Math.min(d,f.y),u=Math.max(u,f.x),p=Math.max(p,f.y)}),{minX:c+s,minY:d+n,maxX:u+s,maxY:p+n}}getViewportBounds(){var e;return((e=this.components.viewportContainer)==null?void 0:e.getViewportBounds())||{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}updateRuntime(e){Object.assign(this.runtime,e),A.log("[runtime] runtime updated",e),this.renderOnceNextFrame()}updateConfig(e){var i;_a(this.config,e),(i=this.managers.controlsManager)==null||i.updateRenderOrder(),A.log("[Config] Configuration updated",e),this.renderOnceNextFrame()}metersToPixels(e){var n;if(!((n=this.mapState)!=null&&n.resolution))return A.warn("Map resolution not available, using default resolution (5cm/pixel)"),e*20;const s=1/(this.mapState.resolution/100);return e*s}pixelsToMeters(e){var s;if(!((s=this.mapState)!=null&&s.resolution))return A.warn("Map resolution not available, using default resolution (5cm/pixel)"),e*.05;const i=this.mapState.resolution/100;return e*i}toFixedSize(e,i){const s=i??this.components.appContainer.scale.x;return e/s}fromFixedSize(e,i){const s=i??this.components.appContainer.scale.x;return e*s}getViewportCenterPoint(){if(!this.mapState)return A.warn("Map state not available, cannot calculate center point"),null;const e=this.getViewportBounds(),i=e.x+e.width/2,s=e.y+e.height/2,n=this.components.appContainer,o=n.scale.x,a=n.getMapRotationRadians(),h=i-n.x,l=s-n.y,c=h/o,d=l/o,u=Math.cos(a),p=Math.sin(a),f=c*u+d*p,y=-c*p+d*u,m=f-this.mapState.origin.x,x=y-this.mapState.origin.y;return{x:m,y:x}}getMapCenterPoint(){if(!this.mapState)return A.warn("Map state not available, cannot calculate map center point"),null;const e=this.managers.mapManager.mapBounds;if(e.minX===1/0||e.minY===1/0||e.maxX===-1/0||e.maxY===-1/0)return A.warn("Invalid map bounds, cannot calculate map center point"),null;const i=(e.minX+e.maxX)/2,s=(e.minY+e.maxY)/2,n=i-this.mapState.origin.x,o=s-this.mapState.origin.y;return{x:n,y:o}}getWallPointsByViewportCenter(e){var f;const{width:i=this.config.controls.virtualWall.minWidth,direction:s="horizontal",offsetX:n=0,offsetY:o=0}=e||{},a=this.getViewportCenterPoint()||{x:0,y:0},l=this.metersToPixels(i)/2,c=((f=this.components.appContainer)==null?void 0:f.getMapRotationRadians())||0,d=Math.cos(c),u=Math.sin(c);let p;return s==="horizontal"?p=[{vx:-l+n,vy:o},{vx:l+n,vy:o}]:p=[{vx:n,vy:-l+o},{vx:n,vy:l+o}],p.map(y=>({x:a.x+y.vx*d+y.vy*u,y:a.y-y.vx*u+y.vy*d}))}getForbiddenSweepZonePointsByViewportCenter(e){const i=this.config.controls.forbiddenSweepZone,{size:s=i.minSize,offsetX:n=0,offsetY:o=0}=e||{};return this.generateZonePoints(s,n,o)}getForbiddenMopZonePointsByViewportCenter(e){const i=this.config.controls.forbiddenMopZone,{size:s=i.minSize,offsetX:n=0,offsetY:o=0}=e||{};return this.generateZonePoints(s,n,o)}getCleanZonePointsByViewportCenter(e){const i=this.config.controls.cleanZone,{size:s=i.minSize,offsetX:n=0,offsetY:o=0}=e||{};return this.generateZonePoints(s,n,o)}getSpotPointByViewportCenter(e){const{offsetX:i=0,offsetY:s=0}=e||{},n=this.getViewportCenterPoint()||{x:0,y:0},o=n.x+i,a=n.y+s;return{x:o,y:a}}getFurniturePointsByViewportCenter(e){var x;const{furnitureType:i=1,offsetX:s=0,offsetY:n=0}=e||{},a=this.config.furniture.assets.find(S=>S.type===i),h=this.metersToPixels((a==null?void 0:a.width)??1.8),l=this.metersToPixels((a==null?void 0:a.height)??2),c=h/2,d=l/2,u=this.getViewportCenterPoint()||{x:0,y:0},p=((x=this.components.appContainer)==null?void 0:x.getMapRotationRadians())||0,f=Math.cos(p),y=Math.sin(p);return[{vx:-c+s,vy:-d+n},{vx:c+s,vy:-d+n},{vx:c+s,vy:d+n},{vx:-c+s,vy:d+n}].map(S=>({x:u.x+S.vx*f+S.vy*y,y:u.y-S.vx*y+S.vy*f}))}areRoomsAdjacent(e){return!e||e.length===0?(A.warn("[Room] No room IDs provided"),!1):this.managers.mapManager.areRoomsAdjacent(e)}isPointInAnyRoom(e){return!e||typeof e.x!="number"||typeof e.y!="number"?(A.warn("[Room] Invalid point provided"),null):this.mapState?this.managers.mapManager.isPointInAnyRoom(e):(A.warn("[Room] Map state not available"),null)}isWallIntersectsAnyRoom(e){return!e||e.length!==2||!e[0]||!e[1]||typeof e[0].x!="number"||typeof e[0].y!="number"||typeof e[1].x!="number"||typeof e[1].y!="number"?(A.warn("[Room] Invalid wall points provided"),!1):this.mapState?this.managers.mapManager.isWallIntersectsAnyRoom(e):(A.warn("[Room] Map state not available"),!1)}isZoneIntersectsAnyRoom(e){return!e||e.length!==4||!e[0]||!e[1]||!e[2]||!e[3]||typeof e[0].x!="number"||typeof e[0].y!="number"||typeof e[1].x!="number"||typeof e[1].y!="number"||typeof e[2].x!="number"||typeof e[2].y!="number"||typeof e[3].x!="number"||typeof e[3].y!="number"?(A.warn("[Room] Invalid zone points provided"),!1):this.mapState?this.managers.mapManager.isZoneIntersectsAnyRoom(e):(A.warn("[Room] Map state not available"),!1)}isNearChargerOrRobot(e,i,s){var h,l;if(!e||e.length<1)return A.warn("[Distance] Invalid points array: must have at least 1 point"),!1;if(e.length!==1&&e.length!==2&&e.length!==4)return A.warn("[Distance] Invalid points array: must have exactly 1 (point), 2 (wall) or 4 (zone) points"),!1;if(i<=0)return A.warn("[Distance] Invalid threshold: must be greater than 0"),!1;if(!this.mapState)return A.warn("[Distance] Map state not available"),!1;const{checkCharger:n=!0,checkRobot:o=!1}=s||{};if(!n&&!o)return A.warn("[Distance] At least one of checkCharger or checkRobot must be true"),!1;const a=this.metersToPixels(i);if(n){const c=this.appService.getChargerPosition();if(c){const d=(h=this.mapState)==null?void 0:h.charger.x,u=(l=this.mapState)==null?void 0:l.charger.y;if(d===0&&u===0)return A.warn("[Distance] Charger position not available"),!1;const p=Ea(c,e);if(p<=a)return A.log(`[Distance] Too close to charger: ${p.toFixed(2)} pixels (threshold: ${a.toFixed(2)} pixels)`),!0}else A.warn("[Distance] Charger position not available")}if(o){const c=this.appService.getRobotPosition();if(c){const d=Ea(c,e);if(d<=a)return A.log(`[Distance] Too close to robot: ${d.toFixed(2)} pixels (threshold: ${a.toFixed(2)} pixels)`),!0}else A.warn("[Distance] Robot position not available")}return!1}async snapshot(e){this.render();const{snapshot:i,global:s}=this.config,n=(e==null?void 0:e.backgroundColor)??s.backgroundColor,o=this.components.appContainer,a=o.getSnapshotBounds(),h=Math.floor(a.x),l=Math.floor(a.y),c=Math.ceil(a.x+a.width)-h,d=Math.ceil(a.y+a.height)-l;if(c<=0||d<=0)return A.error("[MapApplication] Snapshot failed: invalid bounds",a),"";const u=i.resolution||window.devicePixelRatio||2,p=kr.create({width:c,height:d,resolution:u}),f=new H;f.rect(0,0,c,d).fill(n);const y=new W;y.translate(-h,-l);try{return this.renderer.render({container:f,target:p}),this.renderer.render({container:o,target:p,transform:y,clear:!1}),await this.renderer.extract.base64({target:p,format:i.format,quality:i.quality,antialias:i.antialias})}catch(m){return A.error("[MapApplication] Snapshot failed:",m),""}finally{f.destroy(),p.destroy(!0)}}async snapshotByData({map:e,path:i,roomProperties:s,customElements:n,forbiddenSweepZones:o,forbiddenMopZones:a,virtualWalls:h,detectedObjects:l,furnitures:c},d={},u){const p=`SNAPSHOT_${Fx()}`;A.log(`[MapApplication] ${p} snapshot start`);const f=new Vr(p);try{if(await f.initialize({config:this.config,runtime:d}),!e)throw new Error("Map data is required");if(e.startsWith("7b22")){const m=$c(e);await f.drawMap(m)}else{const m=Qc(e,{pointsStructured:!0});if(m)await f.drawRasterMap(m);else throw new Error("Failed to decode raster map data")}if(i){const{decodePath:m}=await _e(async()=>{const{decodePath:S}=await import("./theme.CjTS9gFB.js").then(v=>v.i);return{decodePath:S}},__vite__mapDeps([4,2])),x=m(i);f.drawPath(x)}s&&s.length>0&&await f.drawRoomProperty(s),o&&o.length>0&&f.drawForbiddenSweepZones(o),a&&a.length>0&&f.drawForbiddenMopZones(a),h&&h.length>0&&f.drawVirtualWalls(h),c&&c.length>0&&await f.drawFurnitures(c),l&&l.length>0&&await f.drawDetectedObjects(l),n&&n.length>0&&await f.drawCustomElements(n);const y=await f.snapshot(u);return A.log(`[MapApplication] ${p} snapshot completed successfully`),y}catch(y){throw A.error(`[MapApplication] ${p} snapshot other map failed:`,y),y}finally{A.log(`[MapApplication] ${p} destroy`),f.destroy()}}renderOnce(){A.log("[Pixi] renderOnce"),this.render()}renderOnceNextFrame(){this.pendingAsyncRender||(this.pendingAsyncRender=!0,requestAnimationFrame(()=>{A.log("[Pixi] renderOnceNextFrame"),this.render(),this.pendingAsyncRender=!1}))}requestRender(e,i=!1){if(!i){this.renderOnceNextFrame();return}this.tickerState.renderReasons.add(e),this.ticker.started||(A.debug(`🎬 [Ticker] START: ${e}`),this.ticker.start())}stopRender(e){this.tickerState.renderReasons.delete(e),this.tickerState.renderReasons.size===0&&this.scheduleStopRender("final",100)}destroy(){var e;A.log("[MapApplication] destroy"),this.tickerState.renderTimer&&(clearTimeout(this.tickerState.renderTimer),this.tickerState.renderTimer=null),this.tickerState.renderReasons.clear(),this.emitter.all.clear(),document.removeEventListener("visibilitychange",this.onVisibilityChange),this.managers.pathManager.destroy(),this.managers.mapManager.destroy(),this.managers.controlsManager.destroy(),this.managers.furnitureManager.destroy(),this.managers.detectedObjectManager.destroy(),this.managers.customElementsManager.destroy(),this.managers.roomsManager.destroy(),this.components.interaction.destroy(),(e=this.components.background)==null||e.destroy(),this.components.viewportContainer.destroy(),this.components.appContainer.destroy(),this.managers.heatmapManager.destroy(),super.destroy()}initializeViewportContainer(){this.components.viewportContainer=new zx(this.config,this.containerElement),this.stage.addChild(this.components.viewportContainer);const e=this.getViewportBounds();this.components.background=new z0(this.config.global,e,()=>{this.renderOnceNextFrame()}),this.components.viewportContainer.addChild(this.components.background),this.components.viewportContainer.setChildIndex(this.components.background,0),Bs(this.config.global,()=>{var i;(i=this.components.background)==null||i.update(this.config.global)})}initializeAppContainer(){this.components.appContainer=new Gx(this.appService),this.components.interaction.addChild(this.components.appContainer)}initializeInteraction(){this.components.interaction=new Iy(this.appService),this.components.viewportContainer.addChild(this.components.interaction)}scheduleStopRender(e,i){this.tickerState.renderTimer&&clearTimeout(this.tickerState.renderTimer),this.tickerState.renderTimer=setTimeout(()=>{this.tickerState.renderReasons.delete(e),this.tickerState.renderReasons.size===0&&(A.debug("⏸️ [Ticker] STOP"),this.ticker&&this.ticker.stop())},i)}generateZonePoints(e,i,s){var u;const n=this.getViewportCenterPoint()||{x:0,y:0},a=this.metersToPixels(e)/2,h=((u=this.components.appContainer)==null?void 0:u.getMapRotationRadians())||0,l=Math.cos(h),c=Math.sin(h);return[{vx:-a+i,vy:-a+s},{vx:a+i,vy:-a+s},{vx:a+i,vy:a+s},{vx:-a+i,vy:a+s}].map(p=>({x:n.x+p.vx*l+p.vy*c,y:n.y-p.vx*c+p.vy*l}))}preloadAssets(){const e=this.config.robot.icon.src,i=this.config.chargingStation.icon.src,s=[];N.add({alias:"robot",src:e}),s.push("robot"),N.add({alias:"chargingStation",src:i}),s.push("chargingStation"),N.add({alias:"deleteIcon",src:this.config.controls.deleteIconSrc}),s.push("deleteIcon"),N.add({alias:"rotateIcon",src:this.config.controls.rotateIconSrc}),s.push("rotateIcon"),N.add({alias:"scaleIcon",src:this.config.controls.scaleIconSrc}),s.push("scaleIcon"),N.add({alias:"moveIcon",src:this.config.controls.moveIconSrc}),s.push("moveIcon"),N.add({alias:"checkmark",src:this.config.room.selectionIndicator.iconSrc}),s.push("checkmark"),N.add({alias:"spotIcon",src:this.config.controls.spot.iconSrc}),s.push("spotIcon"),N.add({alias:"wayPoint",src:this.config.controls.wayPoint.normal.iconSrc}),s.push("wayPoint"),N.add({alias:"wayPointActive",src:this.config.controls.wayPoint.editing.iconSrc}),s.push("wayPointActive"),N.add({alias:"horizontalScaleIcon",src:this.config.controls.horizontalScaleIconSrc}),s.push("horizontalScaleIcon"),N.add({alias:"verticalScaleIcon",src:this.config.controls.verticalScaleIconSrc}),s.push("verticalScaleIcon"),this.config.room.property.cleanMode.assets.forEach((n,o)=>{const a=`cleanMode_${o}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.property.suction.assets.forEach((n,o)=>{const a=`fan_${o}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.property.cistern.assets.forEach((n,o)=>{const a=`water_${o}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.property.cleanTimes.assets.forEach((n,o)=>{const a=`cleanTimes${o+1}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.floorType.assets.forEach((n,o)=>{if(!n)return;const a=`floorType${o}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.property.customAssets&&Object.entries(this.config.room.property.customAssets).forEach(([n,o])=>{o.forEach((a,h)=>{const l=`custom_${n}_${h}`;N.add({alias:l,src:a}),s.push(l)})}),this.config.furniture.assets.forEach(n=>{const o=`furniture_${n.type}`;N.add({alias:o,src:n.src}),s.push(o)}),N.backgroundLoad(s)}setupMapRotationListener(){this.applyMapRotation(this.runtime.mapRotation),U(this.runtime,"mapRotation",e=>{this.applyMapRotation(e)})}applyMapRotation(e){const i=(e%360+360)%360;A.log(`[MapApplication] Applying map rotation: ${i}°`),this.components.appContainer.setMapRotation(i);const s=this.managers.mapManager.mapBounds;s&&s.minX!==1/0&&s.maxX!==-1/0&&this.fitMapToView(s,!1),this.emitter.emit("mapRotationUpdate",i),this.renderOnce()}}const $0=Object.freeze(Object.defineProperty({__proto__:null,AppService:ic,MapApplication:Vr},Symbol.toStringTag,{value:"Module"}));export{Lo as $,wi as A,le as B,ne as C,lr as D,Yt as E,ur as F,H as G,jg as H,Qe as I,Bf as J,ks as K,Cf as L,W as M,Ot as N,Rs as O,tt as P,dr as Q,et as R,Fp as S,G as T,Ee as U,j as V,jh as W,Ri as X,Gi as Y,Ip as Z,ri as _,Ke as a,Ci as a0,pr as a1,Hh as a2,Bt as a3,ti as a4,ol as a5,lf as a6,pf as a7,K0 as a8,hl as a9,Di as aA,Op as aB,al as aC,cf as aD,gf as aE,Yg as aF,ll as aG,mf as aH,Lg as aI,$0 as aJ,Ie as aa,hs as ab,Au as ac,cd as ad,ce as ae,Je as af,yf as ag,_t as ah,ph as ai,It as aj,Ps as ak,ho as al,jt as am,Mm as an,Ud as ao,co as ap,qs as aq,uo as ar,Vd as as,gh as at,kr as au,Pr as av,Yh as aw,Oi as ax,Zu as ay,Vu as az,$n as b,rt as c,V as d,de as e,Qn as f,os as g,xt as h,X as i,pu as j,gt as k,am as l,dt as m,Ln as n,iu as o,E as p,yt as q,Cd as r,zg as s,fa as t,Pu as u,J as v,nt as w,$ as x,L as y,st as z};