var m=Object.defineProperty;var u=(t,e)=>{for(var i in e)m(t,i,{get:e[i],enumerable:!0})};var c={};u(c,{BoundsManager:()=>a,StateChangedEvent:()=>s,onChange:()=>l,removeListener:()=>d});import*as r from"./../../models/trace/trace.js";var o=null,s=class t extends Event{state;updateType;options;static eventName="traceboundsstatechanged";constructor(e,i,n={shouldAnimate:!1}){super(t.eventName,{composed:!0,bubbles:!0}),this.state=e,this.updateType=i,this.options=n}};function l(t){a.instance().addEventListener(s.eventName,t)}function d(t){a.instance().removeEventListener(s.eventName,t)}var a=class t extends EventTarget{static instance(e={forceNew:null}){let i=!!e.forceNew;return(!o||i)&&(o=new t),o}static removeInstance(){o=null}#e=null;constructor(){super()}resetWithNewBounds(e){return this.#e={entireTraceBounds:e,minimapTraceBounds:e,timelineTraceWindow:e},this.dispatchEvent(new s(this.state(),"RESET")),this}state(){if(this.#e===null)return null;let e=r.Helpers.Timing.traceWindowMilliSeconds(this.#e.entireTraceBounds),i=r.Helpers.Timing.traceWindowMilliSeconds(this.#e.minimapTraceBounds),n=r.Helpers.Timing.traceWindowMilliSeconds(this.#e.timelineTraceWindow);return{micro:this.#e,milli:{entireTraceBounds:e,minimapTraceBounds:i,timelineTraceWindow:n}}}setMiniMapBounds(e){if(!this.#e){console.error("TraceBounds.setMiniMapBounds could not set bounds because there is no existing trace window set.");return}let i=this.#e.minimapTraceBounds;e.min===i.min&&e.max===i.max||e.range<1e3||(this.#e.minimapTraceBounds=e,this.dispatchEvent(new s(this.state(),"MINIMAP_BOUNDS")))}setTimelineVisibleWindow(e,i={shouldAnimate:!1,ignoreMiniMapBounds:!1}){if(!this.#e){console.error("TraceBounds.setTimelineVisibleWindow could not set bounds because there is no existing trace window set.");return}let n=this.#e.timelineTraceWindow;e.range<1e3||e.min===n.min&&e.max===n.max||(i.ignoreMiniMapBounds||(e.min=r.Types.Timing.Micro(Math.max(this.#e.minimapTraceBounds.min,e.min)),e.max=r.Types.Timing.Micro(Math.min(this.#e.minimapTraceBounds.max,e.max))),!(e.min===n.min&&e.max===n.max)&&(this.#e.timelineTraceWindow=e,this.dispatchEvent(new s(this.state(),"VISIBLE_WINDOW",{shouldAnimate:i.shouldAnimate}))))}};export{c as TraceBounds};
//# sourceMappingURL=trace_bounds.js.map
