@mxtommy/kip 4.7.0 → 4.8.0

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 (50) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/LICENSE +3 -0
  3. package/README.md +37 -29
  4. package/package.json +23 -34
  5. package/plugin/history-series.service.js +108 -11
  6. package/plugin/index.js +170 -44
  7. package/plugin/kip-series-contract.js +18 -1
  8. package/plugin/openApi.json +75 -7
  9. package/public/3rdpartylicenses.txt +0 -26
  10. package/public/assets/help-docs/contributing-widgets.md +40 -0
  11. package/public/assets/help-docs/dashboards.md +8 -0
  12. package/public/assets/help-docs/menu.json +4 -2
  13. package/public/assets/svg/icons.svg +48 -1
  14. package/public/assets/svg/symbols.svg +68 -0
  15. package/public/{chunk-PKB75FW2.js → chunk-2TP7C66X.js} +1 -1
  16. package/public/chunk-3SJSLBCV.js +6 -0
  17. package/public/chunk-5SMHTIVS.js +50 -0
  18. package/public/{chunk-E3ROX3JL.js → chunk-6ISGIPNP.js} +1 -1
  19. package/public/chunk-6ZR3M3IQ.js +3 -0
  20. package/public/{chunk-6LPU67GV.js → chunk-ACY7HYMZ.js} +1 -1
  21. package/public/{chunk-E3VC75HO.js → chunk-C23GLDFH.js} +1 -1
  22. package/public/{chunk-W5RYIISE.js → chunk-CB4E7PPA.js} +1 -1
  23. package/public/{chunk-JL7DODKZ.js → chunk-DNM5XUIF.js} +1 -1
  24. package/public/{chunk-2BKBAKG4.js → chunk-GSM7FZE2.js} +2 -2
  25. package/public/{chunk-OBMTAHXF.js → chunk-HF7V6XFA.js} +1 -1
  26. package/public/{chunk-2BY2XRFX.js → chunk-HUCDJ6CS.js} +7 -7
  27. package/public/{chunk-CSJ2TU72.js → chunk-ILQQCGMJ.js} +1 -1
  28. package/public/chunk-IXUKD73N.js +5 -0
  29. package/public/{chunk-BMEO4VRV.js → chunk-JMZYPL54.js} +1 -1
  30. package/public/chunk-KG4C6HZC.js +1 -0
  31. package/public/{chunk-UBBLNNPA.js → chunk-LEY6MANN.js} +13 -13
  32. package/public/chunk-NS2OV2OW.js +9 -0
  33. package/public/{chunk-3JK476CX.js → chunk-O5BTKN5D.js} +1 -1
  34. package/public/{chunk-PDJFHMII.js → chunk-Q32FSCUX.js} +1 -1
  35. package/public/{chunk-3B5RVPSS.js → chunk-SHJMXSDM.js} +1 -1
  36. package/public/{chunk-GWAFO3MC.js → chunk-T4VTC6GW.js} +1 -1
  37. package/public/{chunk-GHPW4BPE.js → chunk-VFJD3XKT.js} +1 -1
  38. package/public/{chunk-KHZPPOSI.js → chunk-VFZSH4TC.js} +1 -1
  39. package/public/{chunk-S4UHQERA.js → chunk-W6MCE3GH.js} +1 -1
  40. package/public/index.html +1 -1
  41. package/public/main-UBENKC2D.js +1 -0
  42. package/public/polyfills-BWA36QKG.js +1 -0
  43. package/public/chunk-B2CYEVGO.js +0 -9
  44. package/public/chunk-HIXACNNV.js +0 -6
  45. package/public/chunk-QN4XMV3X.js +0 -50
  46. package/public/chunk-U5QHLGHD.js +0 -1
  47. package/public/chunk-WYC65OAX.js +0 -5
  48. package/public/chunk-XFHXLFTX.js +0 -3
  49. package/public/main-WGYSOKJC.js +0 -1
  50. package/public/polyfills-L4FJGPOC.js +0 -2
@@ -1 +0,0 @@
1
- import{b as B}from"./chunk-XFHXLFTX.js";import{b as U,j as q}from"./chunk-QN4XMV3X.js";import"./chunk-B2CYEVGO.js";import"./chunk-S4UHQERA.js";import"./chunk-BMEO4VRV.js";import"./chunk-6LPU67GV.js";import"./chunk-WYC65OAX.js";import"./chunk-GHPW4BPE.js";import"./chunk-OBMTAHXF.js";import"./chunk-CSJ2TU72.js";import{m as F}from"./chunk-PKB75FW2.js";import{Bc as u,Db as w,Ea as x,Eb as s,Fb as c,Ga as r,Gb as h,Gc as D,Ha as l,Nb as y,Pb as O,Qe as S,Rb as g,Se as V,Te as Z,Wa as d,Wd as I,Xc as T,Zb as z,_b as E,ac as m,bc as R,ed as N,gb as W,je as X,ke as L,qa as a,uc as k,va as v,wa as C,wd as A,xb as b,yb as P}from"./chunk-UBBLNNPA.js";var G=["panel"],Q=(i,f)=>[i,f];function j(i,f){if(i&1&&h(0,"div",7),i&2){let t=g();m("transform",t.ghostTransform())}}function H(i,f){if(i&1){let t=y();s(0,"div",8),O("pointerdown",function(e){v(t);let o=g();return C(o.startResize(e))}),s(1,"button",9),O("pointerdown",function(e){v(t);let o=g();return C(o.startResize(e))}),h(2,"mat-icon",10),c()()}}var ct=(()=>{class i{panelEl=D.required("panel");_settings=a(F);_dashboard=a(U);breakpointObserver=a(A);ngZone=a(x);side=r(this._settings.getSplitShellSide());panelRatio=r(this._settings.getSplitShellWidth());originalPanelRatio=null;panelWidth=r(0);panelCollapsed=u(()=>!!this._dashboard.dashboards()[this._dashboard.activeDashboard()]?.collapseSplitShell);fskShellSwipeDisabled=S(this._settings.getSplitShellSwipeDisabledAsO());handset$=this.breakpointObserver.observe(I.HandsetPortrait);handset=S(this.handset$,{initialValue:{matches:!1,breakpoints:{}}});freeboardWidgetStub={uuid:"persistent-freeboard-shell",type:"widget-freeboardsk",config:{}};chartplotterModeInPortrait=u(()=>this.handset().matches&&!this.panelCollapsed());canResize=u(()=>!this._dashboard.isDashboardStatic()&&!this.panelCollapsed());resizing=!1;startX=0;startW=0;boundMove=t=>this.onMove(t);boundUp=()=>this.onUp();static MIN_DELTA_PX=1;ghostActive=r(!1);ghostTransform=r("");ghostWidth=0;recomputeWidth=()=>{let t=this.panelEl()?.nativeElement.parentElement;if(!t)return;let n=t.clientWidth;this.panelWidth.set(Math.round(n*this.panelRatio()))};constructor(){window.addEventListener("resize",this.recomputeWidth,{passive:!0}),queueMicrotask(this.recomputeWidth),l(()=>{this.chartplotterModeInPortrait(),this.panelRatio(),this.recomputeWidth(),setTimeout(()=>window.dispatchEvent(new Event("resize")),0)}),l(()=>{let t=this._dashboard.isDashboardStatic();t||this.originalPanelRatio===null&&(this.originalPanelRatio=this.panelRatio()),t&&this.originalPanelRatio}),l(()=>{if(this._dashboard.layoutEditSaved(),this.originalPanelRatio!==null){let t=this.panelRatio();this._settings.setSplitShellWidth(t),this.originalPanelRatio=null}}),l(()=>{if(this._dashboard.layoutEditCanceled(),this.originalPanelRatio!==null){let t=this.originalPanelRatio;this.panelRatio.set(t),queueMicrotask(()=>this.recomputeWidth()),this.originalPanelRatio=null}})}startResize(t){this.canResize()&&(this.resizing=!0,this.startX=t.clientX,this.startW=this.panelWidth(),this.ghostWidth=this.startW,this.ghostActive.set(!0),this.updateGhostTransform(this.startW),t.target.setPointerCapture(t.pointerId),this.ngZone.runOutsideAngular(()=>{window.addEventListener("pointermove",this.boundMove,{passive:!0}),window.addEventListener("pointerup",this.boundUp,{passive:!0})}))}onMove(t){if(!this.resizing)return;let n=this.side()==="left"?t.clientX-this.startX:this.startX-t.clientX,o=this.panelEl()?.nativeElement.parentElement?.clientWidth??1,p=this.startW+n,_=o*.1,$=o*.9,M=Math.min($,Math.max(_,p));Math.abs(M-this.ghostWidth)<i.MIN_DELTA_PX||(this.ghostWidth=M,this.ngZone.runOutsideAngular(()=>this.updateGhostTransform(M)))}onUp(){if(!this.resizing)return;this.resizing=!1,window.removeEventListener("pointermove",this.boundMove),window.removeEventListener("pointerup",this.boundUp);let t=this.ghostWidth;this.ghostActive.set(!1);let n=this.panelEl();n&&!this.panelCollapsed()&&(n.nativeElement.style.width=t+"px"),this.ngZone.run(()=>{this.panelWidth.set(t);let o=this.panelEl()?.nativeElement.parentElement?.clientWidth??t,p=o?t/o:.3,_=this.panelRatio();Math.abs(p-_)>5e-4&&this.panelRatio.set(p)})}updateGhostTransform(t){this.side()==="left"?this.ghostTransform.set(`translateX(${t}px)`):this.ghostTransform.set(`translateX(-${t}px)`)}ngOnDestroy(){window.removeEventListener("resize",this.recomputeWidth),this.resizing&&(window.removeEventListener("pointermove",this.boundMove),window.removeEventListener("pointerup",this.boundUp))}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=W({type:i,selectors:[["split-shell"]],viewQuery:function(n,e){n&1&&z(e.panelEl,G,5),n&2&&E()},decls:8,vars:18,consts:[["panel",""],[1,"split-root",3,"ngClass"],[1,"resize-ghost",3,"transform"],[1,"fsk-shell"],["role","separator","aria-label","Resize Freeboard chartplotter panel","aria-orientation","vertical",1,"drag-handle"],[1,"fsk-iframe",3,"type","id","swipeDisabled","disableWidgetShell"],[1,"dash-container"],[1,"resize-ghost"],["role","separator","aria-label","Resize Freeboard chartplotter panel","aria-orientation","vertical",1,"drag-handle",3,"pointerdown"],["mat-mini-fab","","tabindex","-1","aria-hidden","true",1,"drag-fab",3,"pointerdown"],["fontIcon","drag_indicator"]],template:function(n,e){n&1&&(s(0,"div",1),b(1,j,1,2,"div",2),s(2,"div",3,0),b(4,H,3,0,"div",4),h(5,"widget-freeboardsk",5),c(),s(6,"div",6),h(7,"dashboard"),c()()),n&2&&(m("--panel-ratio",e.panelRatio()),w("ngClass",k(15,Q,e.side()==="left"?"side-left":"side-right",e.chartplotterModeInPortrait()?"portrait-column":"")),d(),P(e.ghostActive()?1:-1),d(),m("width",e.chartplotterModeInPortrait()?null:e.panelWidth(),"px"),R("collapsed",e.panelCollapsed())("drag-disabled",!e.canResize()),d(2),P(e.canResize()?4:-1),d(),w("type",e.freeboardWidgetStub.type)("id",e.freeboardWidgetStub.uuid)("swipeDisabled",e.fskShellSwipeDisabled())("disableWidgetShell",!0))},dependencies:[N,T,q,B,L,X,Z,V],styles:[".split-root[_ngcontent-%COMP%]{position:relative;width:100%;height:100%;display:flex;overflow:hidden}.split-root.side-left[_ngcontent-%COMP%]{flex-direction:row}.split-root.side-right[_ngcontent-%COMP%]{flex-direction:row-reverse}.split-root.portrait-column[_ngcontent-%COMP%]{flex-direction:column}.split-root.portrait-column[_ngcontent-%COMP%] .fsk-shell[_ngcontent-%COMP%], .split-root.portrait-column[_ngcontent-%COMP%] .dash-container[_ngcontent-%COMP%]{width:100%!important;min-height:0}.split-root.portrait-column[_ngcontent-%COMP%] .fsk-shell[_ngcontent-%COMP%]{flex:0 0 calc(var(--panel-ratio, .3) * 100%)}.split-root.portrait-column[_ngcontent-%COMP%] .dash-container[_ngcontent-%COMP%]{flex:1 1 auto;min-height:0;overflow:hidden}.split-root.side-left.portrait-column[_ngcontent-%COMP%] .dash-container[_ngcontent-%COMP%]{order:2}.split-root.side-left.portrait-column[_ngcontent-%COMP%] .fsk-shell[_ngcontent-%COMP%]{order:1}.split-root.side-right.portrait-column[_ngcontent-%COMP%] .fsk-shell[_ngcontent-%COMP%]{order:2}.split-root.side-right.portrait-column[_ngcontent-%COMP%] .dash-container[_ngcontent-%COMP%]{order:1}.split-root.portrait-column[_ngcontent-%COMP%] .fsk-shell.collapsed[_ngcontent-%COMP%]{flex:0 0 0!important}.split-root.portrait-column[_ngcontent-%COMP%] .drag-handle[_ngcontent-%COMP%], .split-root.portrait-column[_ngcontent-%COMP%] .resize-ghost[_ngcontent-%COMP%]{display:none}.fsk-shell[_ngcontent-%COMP%]{position:relative;height:100%;display:flex;flex-direction:column;background:var(--mat-sys-surface-container, #111);transition:width .2s ease}.fsk-shell.collapsed[_ngcontent-%COMP%]{width:1px!important;visibility:hidden;opacity:0;pointer-events:none}.fsk-iframe[_ngcontent-%COMP%]{flex:1 1 auto;min-width:0}.dash-container[_ngcontent-%COMP%]{flex:1 1 auto;min-width:0;height:100%}.drag-handle[_ngcontent-%COMP%]{position:absolute;top:0;bottom:0;width:3px;cursor:col-resize;background:var(--mat-sys-inverse-primary);z-index:5}.drag-handle[_ngcontent-%COMP%] .drag-fab[_ngcontent-%COMP%]{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:28px;height:28px;min-width:28px;cursor:col-resize;pointer-events:auto}.drag-handle[_ngcontent-%COMP%] .drag-fab[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px;line-height:20px}.side-left[_ngcontent-%COMP%] .drag-handle[_ngcontent-%COMP%]{right:-2px}.side-right[_ngcontent-%COMP%] .drag-handle[_ngcontent-%COMP%]{left:-2px}.drag-handle[_ngcontent-%COMP%]:hover{background:var(--mat-sys-error-container)}.side-left[_ngcontent-%COMP%] .collapse-toggle[_ngcontent-%COMP%]{left:.25rem}.side-right[_ngcontent-%COMP%] .collapse-toggle[_ngcontent-%COMP%]{right:.25rem}.fsk-shell.drag-disabled[_ngcontent-%COMP%] .drag-handle[_ngcontent-%COMP%]{cursor:not-allowed;opacity:.4}.resize-ghost[_ngcontent-%COMP%]{position:absolute;top:0;bottom:0;width:2px;background:var(--mat-sys-error-container);opacity:.9;pointer-events:none;z-index:30;will-change:transform;transition:none}.side-left[_ngcontent-%COMP%] .resize-ghost[_ngcontent-%COMP%]{left:0}.side-right[_ngcontent-%COMP%] .resize-ghost[_ngcontent-%COMP%]{right:0}"]})}return i})();export{ct as SplitShellComponent};
@@ -1,5 +0,0 @@
1
- import{d as O,f as Re,g as v,h as Ae,i as We,k as Ie}from"./chunk-PKB75FW2.js";import{A as he,Ba as R,Da as ue,Db as N,Ea as fe,Eb as q,Fb as G,G as pe,Ga as ge,Gb as P,Hb as ke,I as me,Ib as Se,K as z,Kc as Te,La as be,Mc as J,Ob as K,Od as X,Pb as ve,Pd as Ce,Pe as u,Rb as F,Sb as C,Tb as k,Vb as ye,Wa as E,Wb as xe,Xb as De,Yd as Oe,bc as S,be as ee,ce as $e,ec as Q,fe as U,g as re,gb as _,gc as Z,ge as te,h as ce,hb as A,j as w,k as d,l as le,la as T,m as b,ma as $,n as M,oa as H,pb as _e,qa as m,s as de,sc as Me,sd as Ee,td as we,ue as V,vb as Y,xb as W,yb as I,z as L}from"./chunk-UBBLNNPA.js";var ze={url:"",deserializer:s=>JSON.parse(s.data),serializer:s=>JSON.stringify(s)},He="WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }",j=class s extends le{constructor(n,e){if(super(),this._socket=null,n instanceof w)this.destination=e,this.source=n;else{let t=this._config=Object.assign({},ze);if(this._output=new d,typeof n=="string")t.url=n;else for(let i in n)n.hasOwnProperty(i)&&(t[i]=n[i]);if(!t.WebSocketCtor&&WebSocket)t.WebSocketCtor=WebSocket;else if(!t.WebSocketCtor)throw new Error("no WebSocket constructor can be found");this.destination=new M}}lift(n){let e=new s(this._config,this.destination);return e.operator=n,e.source=this,e}_resetState(){this._socket=null,this.source||(this.destination=new M),this._output=new d}multiplex(n,e,t){let i=this;return new w(a=>{try{i.next(n())}catch(r){a.error(r)}let o=i.subscribe({next:r=>{try{t(r)&&a.next(r)}catch(c){a.error(c)}},error:r=>a.error(r),complete:()=>a.complete()});return()=>{try{i.next(e())}catch(r){a.error(r)}o.unsubscribe()}})}_connectSocket(){let{WebSocketCtor:n,protocol:e,url:t,binaryType:i}=this._config,a=this._output,o=null;try{o=e?new n(t,e):new n(t),this._socket=o,i&&(this._socket.binaryType=i)}catch(c){a.error(c);return}let r=new re(()=>{this._socket=null,o&&o.readyState===1&&o.close()});o.onopen=c=>{let{_socket:l}=this;if(!l){o.close(),this._resetState();return}let{openObserver:h}=this._config;h&&h.next(c);let g=this.destination;this.destination=ce.create(p=>{if(o.readyState===1)try{let{serializer:f}=this._config;o.send(f(p))}catch(f){this.destination.error(f)}},p=>{let{closingObserver:f}=this._config;f&&f.next(void 0),p&&p.code?o.close(p.code,p.reason):a.error(new TypeError(He)),this._resetState()},()=>{let{closingObserver:p}=this._config;p&&p.next(void 0),o.close(),this._resetState()}),g&&g instanceof M&&r.add(g.subscribe(this.destination))},o.onerror=c=>{this._resetState(),a.error(c)},o.onclose=c=>{o===this._socket&&this._resetState();let{closeObserver:l}=this._config;l&&l.next(c),c.wasClean?a.complete():a.error(c)},o.onmessage=c=>{try{let{deserializer:l}=this._config;a.next(l(c))}catch(l){a.error(l)}}}_subscribe(n){let{source:e}=this;return e?e.subscribe(n):(this._socket||this._connectSocket(),this._output.subscribe(n),n.add(()=>{let{_socket:t}=this;this._output.observers.length===0&&(t&&(t.readyState===1||t.readyState===0)&&t.close(),this._resetState())}),n)}unsubscribe(){let{_socket:n}=this;n&&(n.readyState===1||n.readyState===0)&&n.close(),this._resetState(),super.unsubscribe()}};function ie(s){return new j(s)}var Ne=(()=>{class s{_destroyRef=m(R);_skRequests$=new d;_skNotificationsMsg$=new d;_skValue$=new d;_skMetadata$=new d;_vesselSelfUrn$=new d;_selfUrn=void 0;streamEndpoint={operation:0,message:"Not connected",hasToken:!1};streamEndpoint$=new b(this.streamEndpoint);endpointWS=null;SubscriptionType="self";WS_CONNECTION_SUBSCRIBE="?subscribe=";WS_CONNECTION_META="&sendMeta=all";socketWS$;socketWSCloseEvent$=new d;socketWSOpenEvent$=new d;authToken=null;server=m(We);auth=m(Ie);connectionStateMachine=m(Ae);zones=m(fe);FLATTEN_CONFIG={maxDepth:3,maxObjectSize:20,enableFlattening:!0};DO_NOT_FLATTEN_PATHS=["displays."];constructor(){this.connectionStateMachine.setWebSocketRetryCallback(()=>{console.log("[Delta Service] Executing WebSocket retry via callback"),this.retryWebSocketConnection()}),this.server.serverServiceEndpoint$.pipe(u(this._destroyRef)).subscribe(e=>{e.operation===2&&(this.endpointWS=e.WsServiceUrl,e.subscribeAll?this.SubscriptionType="all":this.SubscriptionType="self")}),this.connectionStateMachine.state$.pipe(u(this._destroyRef)).subscribe(e=>{switch(e){case v.WebSocketConnecting:this.handleWebSocketConnecting();break;case v.Connected:break;case v.Disconnected:case v.WebSocketError:case v.PermanentFailure:this.handleDisconnection();break}}),this.auth.authToken$.pipe(u(this._destroyRef)).subscribe(e=>{this.authToken!=e&&(this.authToken=e,this.socketWS$&&this.connectionStateMachine.isFullyConnected()&&(this.closeWS("Token changed"),this.connectionStateMachine.startWebSocketConnection()))}),this.socketWSOpenEvent$.pipe(u(this._destroyRef)).subscribe(()=>{this.streamEndpoint.message="Connected",this.streamEndpoint.operation=2,this.authToken?console.log("[Delta Service] WebSocket connected with Authorization Token"):console.log("[Delta Service] WebSocket connected without Authorization Token"),this.streamEndpoint$.next(this.streamEndpoint),this.connectionStateMachine.onWebSocketConnected()}),this.socketWSCloseEvent$.pipe(u(this._destroyRef)).subscribe(e=>{e.wasClean?(console.log("[Delta Service] WebSocket closed cleanly"),this.streamEndpoint.message="WebSocket closed",this.streamEndpoint.operation=0):(console.log("[Delta Service] WebSocket terminated due to socket error"),this.streamEndpoint.message="WebSocket error",this.streamEndpoint.operation=3,this.connectionStateMachine.onWebSocketError("WebSocket connection lost")),this.streamEndpoint$.next(this.streamEndpoint)}),pe(document,"visibilitychange").pipe(u(this._destroyRef)).subscribe(()=>{document.visibilityState==="visible"?(console.log("[Delta Service] App resumed, checking WebSocket connection..."),this.checkAndReconnect("App resumed")):document.visibilityState==="hidden"&&console.log("[Delta Service] App suspended")})}connectWS(e){this.streamEndpoint.message="Connecting",this.streamEndpoint.operation=1,console.log(`[Delta Service] ${e}: WebSocket opening...`),this.streamEndpoint$.next(this.streamEndpoint),this.socketWS$=this.getNewWebSocket(),this.zones.runOutsideAngular(()=>{this.socketWS$.pipe(u(this._destroyRef)).subscribe({next:t=>this.processWebsocketMessage(t),error:t=>{console.error("[Delta Service] WebSocket error:",t)}})})}retryWebSocketConnection(){if(console.log("[Delta Service] Retrying WebSocket connection"),!this.endpointWS){console.warn("[Delta Service] No WebSocket endpoint available for retry"),this.connectionStateMachine.onWebSocketError("No WebSocket endpoint available");return}this.socketWS$&&this.closeWS("Retrying connection"),this.connectWS("WebSocket retry attempt")}handleWebSocketConnecting(){if(!this.endpointWS){console.warn("[Delta Service] No WebSocket endpoint available"),this.connectionStateMachine.onWebSocketError("No WebSocket endpoint available");return}this.socketWS$&&this.closeWS("Starting new connection"),this.connectWS("ConnectionStateMachine request")}handleDisconnection(){this.socketWS$&&this.closeWS("ConnectionStateMachine disconnection"),this.streamEndpoint.message="Not connected",this.streamEndpoint.operation=0,this.streamEndpoint$.next(this.streamEndpoint)}getNewWebSocket(){let e=this.WS_CONNECTION_SUBSCRIBE+this.SubscriptionType+this.WS_CONNECTION_META;return this.authToken!=null?(e+="&token="+this.authToken.token,this.streamEndpoint.hasToken=!0):this.streamEndpoint.hasToken=!1,ie({url:this.endpointWS+e,closeObserver:this.socketWSCloseEvent$,openObserver:this.socketWSOpenEvent$})}closeWS(e){this.socketWS$&&(this.streamEndpoint.operation=4,console.log("[Delta Service] "+e+": WebSocket closing..."),this.socketWS$.complete())}publishDelta(e){this.socketWS$?this.socketWS$.next(e):console.log("[Delta Service] No WebSocket present to send message - dropping message")}processWebsocketMessage(e){if(e.updates){this.parseUpdates(e.updates,e.context);return}if(e.requestId){this._skRequests$.next(e);return}if(e.errorMessage){console.warn("[Delta Service] Service received stream error message: "+e.errorMessage);return}if(e.self){this._selfUrn=e.self,this._vesselSelfUrn$.next(e.self),this.server.setServerInfo(e.name,e.version,e.roles);return}console.warn("[Delta Service] Unknown message type. Message content:"+e)}parseUpdates(e,t){e.forEach(i=>{i.meta!==void 0&&i.meta.forEach(a=>this.parseSkMeta(a,t)),i.values!==void 0&&i.values.forEach(a=>{if(a.path.startsWith("notifications."))this._skNotificationsMsg$.next(a);else if(typeof a.value=="object"&&a.value!==null)if(this.DO_NOT_FLATTEN_PATHS.some(o=>a.path.includes(o))){let o={context:t,path:a.path,source:i.$source,timestamp:i.timestamp,value:a.value};this._skValue$.next(o)}else this.FLATTEN_CONFIG.enableFlattening&&this.canFlattenCompletely(a.value,this.FLATTEN_CONFIG.maxDepth,this.FLATTEN_CONFIG.maxObjectSize)?this.flattenObjectValue(a.value,a.path).forEach(r=>{let c={context:t,path:r.path,source:i.$source,timestamp:i.timestamp,value:r.value};this._skValue$.next(c)}):Object.keys(a.value).forEach(o=>{let r={context:t,path:`${a.path}.${o}`,source:i.$source,timestamp:i.timestamp,value:a.value[o]};this._skValue$.next(r)});else{let o={context:t,path:a.path,source:i.$source,timestamp:i.timestamp,value:a.value};this._skValue$.next(o)}})})}canFlattenCompletely(e,t,i,a=0){if(a>=t)return!1;if(typeof e!="object"||e===null)return!0;let o=Object.keys(e);if(o.length>i)return!1;for(let r of o)if(!this.canFlattenCompletely(e[r],t,i,a+1))return!1;return!0}flattenObjectValue(e,t,i=0){let a=[];if(typeof e!="object"||e===null||i>=this.FLATTEN_CONFIG.maxDepth)return[{path:t,value:e}];let o=Object.keys(e);for(let r of o){let c=t?`${t}.${r}`:r,l=this.flattenObjectValue(e[r],c,i+1);a.push(...l)}return a}parseSkMeta(e,t){e.value.properties!==void 0?Object.keys(e.value.properties).forEach(i=>{this._skMetadata$.next({context:t,path:`${e.path}.${i}`,meta:e.value.properties[i]})}):this._skMetadata$.next({context:t,path:e.path,meta:e.value})}getDataStreamStatusAsO(){return this.streamEndpoint$.asObservable()}subscribeRequestUpdates(){return this._skRequests$.asObservable()}subscribeNotificationsUpdates(){return this._skNotificationsMsg$.asObservable()}subscribeDataPathsUpdates(){return this._skValue$.asObservable()}subscribeMetadataUpdates(){return this._skMetadata$.asObservable()}subscribeSelfUpdates(){return this._vesselSelfUrn$.asObservable()}checkAndReconnect(e){this.connectionStateMachine.isFullyConnected()?console.log(`[Delta Service] ${e}: Connection is active.`):this.connectionStateMachine.isHTTPConnected()&&this.connectionStateMachine.currentState!==v.WebSocketRetrying?(console.log(`[Delta Service] ${e}: WebSocket disconnected, requesting reconnection...`),this.connectionStateMachine.startWebSocketConnection()):console.log(`[Delta Service] ${e}: HTTP not connected, cannot start WebSocket`)}ngOnDestroy(){this.closeWS("App terminated"),this._skRequests$.complete(),this._skNotificationsMsg$.complete(),this._skValue$.complete(),this._skMetadata$.complete(),this._vesselSelfUrn$.complete(),this.streamEndpoint$.complete(),this.socketWSOpenEvent$.complete(),this.socketWSCloseEvent$.complete(),this.socketWS$?.complete()}static \u0275fac=function(t){return new(t||s)};static \u0275prov=T({token:s,factory:s.\u0275fac,providedIn:"root"})}return s})();var x=(function(s){return s.Normal="normal",s.Nominal="nominal",s.Alert="alert",s.Warn="warn",s.Alarm="alarm",s.Emergency="emergency",s})(x||{});var Ye=(function(s){return s.Visual="visual",s.Sound="sound",s})(Ye||{});var qe="self",Pe=s=>isFinite(+(s instanceof Date?s:new Date(s)))?!!new RegExp("^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(.[0-9]+)?(([Zz])|([+|-]([01][0-9]|2[0-3]):[0-5][0-9]))$").test(s):!1,Fe=s=>{if(s)return s==="RFC 3339 (UTC)"?"Date":"number"},Ft=(()=>{class s{delta=m(Ne);_destroyRef=m(R);_deltaUpdatesCounter=0;_deltaUpdatesSubject=new M(10);_isSkDataFullTreeActive=!1;_skDataSubject$=new b([]);_skDataEmitTimer=null;_skDataEmitIntervalMs=200;_dataServiceMeta=[];_dataServiceMetaByPath=new Map;_isSkMetaFullTreeActive=!1;_dataServiceMetaSubject$=new b([]);_skNotificationMsg$=new d;_skNotificationMeta$=new d;_isReset=new d;_pathUpdates$=new d;_selfUrn="self";_skData=new Map;_pendingPathStates=new Map;_skDataArrayCache=[];_skDataIndexByPath=new Map;_pathRegister=[];_pathRegisterByPath=new Map;constructor(){me(1e3).pipe(u(this._destroyRef)).subscribe(()=>{let e={timestamp:Date.now(),value:this._deltaUpdatesCounter};this._deltaUpdatesSubject.next(e),this._deltaUpdatesCounter=0}),this.delta.subscribeDataPathsUpdates().pipe(u(this._destroyRef)).subscribe(e=>{this.updatePathData(e)}),this.delta.subscribeMetadataUpdates().pipe(u(this._destroyRef)).subscribe(e=>{this.setMeta(e)}),this.delta.subscribeNotificationsUpdates().pipe(u(this._destroyRef)).subscribe(e=>{let t=e.path.replace("notifications.","self."),i=e.value.state,a=this._skData.get(t);if(a&&a.state!==i){a.state=i,this._pathUpdates$.next({fullPath:t,kind:"state"});let o=this._pathRegisterByPath.get(t);if(o?.length)for(let r of o)r._pathState$.next(a.state)}else a||this._pendingPathStates.set(t,i);this._skNotificationMsg$.next(e)}),this.delta.subscribeSelfUpdates().pipe(u(this._destroyRef)).subscribe(e=>{this.setSelfUrn(e)})}getSignalkDeltaUpdateStatistics(){return this._deltaUpdatesSubject.asObservable()}resetSignalKData(){this._skData=new Map,this._pendingPathStates.clear(),this._skDataArrayCache=[],this._skDataIndexByPath.clear(),this._selfUrn="self",this._isReset.next(!0)}unsubscribePath(e){let t=this._pathRegister.findIndex(i=>i.path===e);if(t!==-1){let i=this._pathRegister[t];i.combinedSub?.unsubscribe(),i._pathData$?.complete(),i._pathState$?.complete(),i.pathDataUpdate$?.complete(),i.pathMeta$?.complete(),this._pathRegister.splice(t,1);let a=this._pathRegisterByPath.get(e);if(a){let o=a.filter(r=>r!==i);o.length?this._pathRegisterByPath.set(e,o):this._pathRegisterByPath.delete(e)}}}subscribePath(e,t){let i=this._pathRegisterByPath.get(e),a=i?.find(D=>D.path===e&&D.source===t);if(a)return a.pathDataUpdate$;let o=null,r=null,c=null,l=x.Normal,h={data:{value:null,timestamp:null},state:l},g=null,p=this._skData.get(e);p&&(o=t==="default"?p.pathValue:p.sources?.[t]?.sourceValue??null,r=t==="default"?p.pathTimestamp:p.sources?.[t]?.sourceTimestamp??null,c=r?new Date(r):null,h={data:{value:o,timestamp:c},state:p.state||l},l=p.state||l,g=p.meta||null);let f={path:e,source:t,_pathData$:new b(h.data),_pathState$:new b(h.state),pathDataUpdate$:new b(h),pathMeta$:new b(g?O(g):null)},Be=he([f._pathData$,f._pathState$]).pipe(L(([D,Le])=>({data:D,state:Le})));return f.combinedSub=Be.subscribe(D=>f.pathDataUpdate$.next(D)),this._pathRegister.push(f),i?i.push(f):this._pathRegisterByPath.set(e,[f]),f.pathDataUpdate$}subscribePathTree(e,t="default"){let i=this.subscribePathTreeWithInitial(e,t);return new w(a=>{for(let r of i.initial)a.next(r);let o=i.live$.subscribe(a);return()=>o.unsubscribe()}).pipe(u(this._destroyRef))}subscribePathTreeWithInitial(e,t="default"){let i=this.normalizePathPrefix(e),a=[];for(let r of this._skData.values())r.path.startsWith(i)&&a.push({path:r.path,update:this.buildPathUpdate(r,t)});let o=this._pathUpdates$.pipe(z(r=>r.fullPath.startsWith(i)),L(r=>{let c=this._skData.get(r.fullPath);return c?{path:c.path,update:this.buildPathUpdate(c,t)}:null}),z(r=>r!==null),u(this._destroyRef));return{initial:a,live$:o}}updatePathData(e){this._deltaUpdatesCounter++;let t=this.setPathContext(e.context,e.path),i=this._pendingPathStates.get(t),a=this._skData.get(t);if(a)a.defaultSource===void 0&&(a.defaultSource=e.source),a.type===void 0&&e.value!==null&&(a.type=typeof e.value,a.type==="string"&&Pe(e.value)&&(a.type="Date")),a.pathValue=e.value,a.pathTimestamp=e.timestamp,a.sources[e.source]={sourceTimestamp:e.timestamp,sourceValue:e.value};else{let r=e.value===null?void 0:typeof e.value;r==="string"&&Pe(e.value)&&(r="Date"),a={path:t,pathValue:e.value,pathTimestamp:e.timestamp,defaultSource:e.source,type:r,state:i??x.Normal,sources:{[e.source]:{sourceTimestamp:e.timestamp,sourceValue:e.value}}},this._skData.set(t,a),i!==void 0&&this._pendingPathStates.delete(t)}let o=this._pathRegisterByPath.get(t)??[];if(o.length){let r={value:a.pathValue,timestamp:a.pathTimestamp?new Date(a.pathTimestamp):null},c=o.find(h=>h.source==="default");c&&c._pathData$.next(r);let l=o.find(h=>h.source===e.source);l&&l._pathData$.next(r)}this._isSkDataFullTreeActive&&(this.upsertSkDataCache(a),this.scheduleSkDataFullTreeEmit()),this._pathUpdates$.next({fullPath:t,kind:"data",update:e})}setMeta(e){if(e.path.startsWith("notifications."))this._skNotificationMeta$.next(e);else{let t=this.setPathContext(e.context,e.path),i=this._pendingPathStates.get(t),a=this._skData.get(t);a?(a.type==="object"&&e.meta.units&&(a.type=Fe(e.meta.units)),a.meta=Re({},a.meta,e.meta)):(a={path:t,pathValue:void 0,pathTimestamp:void 0,type:Fe(e.meta.units),state:i??x.Normal,defaultSource:void 0,sources:{},meta:e.meta?O(e.meta):null},this._skData.set(t,a),i!==void 0&&this._pendingPathStates.delete(t),this._isSkDataFullTreeActive&&(this.upsertSkDataCache(a),this.scheduleSkDataFullTreeEmit()));let o=this._pathRegisterByPath.get(t);if(o?.length)for(let r of o)r.pathMeta$.next(a.meta?O(a.meta):null);this._isSkMetaFullTreeActive&&(this._dataServiceMetaByPath.set(t,{path:t,meta:a.meta}),this._dataServiceMeta=Array.from(this._dataServiceMetaByPath.values()),this._dataServiceMetaSubject$.next(this._dataServiceMeta))}}startSkMetaFullTree(){this._isSkMetaFullTreeActive=!0,this._dataServiceMetaByPath.clear();for(let e of this.getSkDataArray())e.meta!==void 0&&e.path.startsWith("self.")&&this._dataServiceMetaByPath.set(e.path,{path:e.path,meta:e.meta});return this._dataServiceMeta=Array.from(this._dataServiceMetaByPath.values()),this._dataServiceMetaSubject$.next(this._dataServiceMeta),this._dataServiceMetaSubject$}stopSkMetaFullTree(){this._isSkMetaFullTreeActive=!1,this._dataServiceMetaSubject$.next([]),this._dataServiceMeta=[],this._dataServiceMetaByPath.clear()}startSkDataFullTree(){return this._isSkDataFullTreeActive=!0,this.refreshSkDataCache(),this.emitSkDataFullTree(),this._skDataSubject$}getSkDataArray(){return this._isSkDataFullTreeActive?this._skDataArrayCache:Array.from(this._skData.values())}observePathUpdates(){return this._pathUpdates$.asObservable()}stopSkDataFullTree(){this._isSkDataFullTreeActive=!1,this._skDataEmitTimer&&(clearTimeout(this._skDataEmitTimer),this._skDataEmitTimer=null),this._skDataArrayCache=[],this._skDataIndexByPath.clear()}scheduleSkDataFullTreeEmit(){!this._isSkDataFullTreeActive||this._skDataEmitTimer||(this._skDataEmitTimer=setTimeout(()=>{this._skDataEmitTimer=null,this.emitSkDataFullTree()},this._skDataEmitIntervalMs))}emitSkDataFullTree(){this._isSkDataFullTreeActive&&this._skDataSubject$.next(this._skDataArrayCache)}refreshSkDataCache(){this._skDataArrayCache=Array.from(this._skData.values()),this._skDataIndexByPath.clear(),this._skDataArrayCache.forEach((e,t)=>this._skDataIndexByPath.set(e.path,t))}upsertSkDataCache(e){let t=this._skDataIndexByPath.get(e.path);t===void 0?(this._skDataIndexByPath.set(e.path,this._skDataArrayCache.length),this._skDataArrayCache.push(e)):this._skDataArrayCache[t]=e}setSelfUrn(e){e!==""&&e!==null?(console.debug("[Signal K Data Service] Setting self to: "+e),this._selfUrn=e):console.error("[Signal K Data Service] Invalid self URN: "+e)}setPathContext(e,t){return e!==this._selfUrn?`${e}.${t}`:`${qe}.${t}`}normalizePathPrefix(e){let t=e?.trim()??"";return(t.endsWith(".*")||t.endsWith(":*")||t.endsWith("*"))&&(t=t.slice(0,-1)),t&&!t.endsWith(".")&&!t.endsWith(":")&&(t=`${t}.`),t}buildPathUpdate(e,t){let i=t==="default",a=i?e.pathValue:e.sources?.[t]?.sourceValue??null,o=i?e.pathTimestamp:e.sources?.[t]?.sourceTimestamp??null;return{data:{value:a,timestamp:o?new Date(o):null},state:e.state||x.Normal}}getPathsByType(e,t){return this.getSkDataArray().filter(i=>i.type===e&&(!t||i.path.startsWith("self"))).map(i=>i.path)}getCachedPaths(e=!1){return this.getSkDataArray().map(t=>t.path).filter(t=>!e||t.startsWith("self."))}getPathsAndMetaByType(e,t=!1,i=!1,a=!0){return this.getSkDataArray().filter(o=>{let c=["string","number","boolean","object","undefined","function","symbol","bigint","Date"].includes(e)?o.type===e:o.meta?.type===e,l=!a||o.path.startsWith("self"),h=t===!0?o.meta?.supportsPut===!0:!0,g=i===!0?Array.isArray(o.meta?.zones)&&o.meta.zones.length>0:!0;return c&&l&&h&&g}).map(o=>({path:o.path,meta:o.meta}))}getPathObject(e){return O(this._skData.get(e))||null}getPathUnitType(e){return this._skData.get(e)?.meta?.units||null}timeoutPathObservable(e,t){let i=this._pathRegister.find(a=>a.path==e);if(i){let a;["string","Date","number","multiple"].includes(t)&&(a={data:{value:null,timestamp:null},state:x.Normal}),i.pathDataUpdate$.next(a)}}getNotificationMsgObservable(){return this._skNotificationMsg$.asObservable()}getNotificationMetaObservable(){return this._skNotificationMeta$.asObservable()}getPathMetaObservable(e){return this._pathRegisterByPath.get(e)?.[0]?.pathMeta$.asObservable()||de(null)}getPathMeta(e){return this._skData.get(e)?.meta||null}isResetService(){return this._isReset.asObservable()}ngOnDestroy(){this._skDataEmitTimer&&(clearTimeout(this._skDataEmitTimer),this._skDataEmitTimer=null),this._deltaUpdatesSubject?.complete(),this._skNotificationMsg$?.complete(),this._skNotificationMeta$?.complete(),this._isReset?.complete(),this._skDataSubject$?.complete(),this._dataServiceMetaSubject$?.complete(),this._pathUpdates$?.complete()}static \u0275fac=function(t){return new(t||s)};static \u0275prov=T({token:s,factory:s.\u0275fac,providedIn:"root"})}return s})();var Ue=(()=>{class s{_animationsDisabled=Oe();state="unchecked";disabled=!1;appearance="full";constructor(){}static \u0275fac=function(t){return new(t||s)};static \u0275cmp=_({type:s,selectors:[["mat-pseudo-checkbox"]],hostAttrs:[1,"mat-pseudo-checkbox"],hostVars:12,hostBindings:function(t,i){t&2&&S("mat-pseudo-checkbox-indeterminate",i.state==="indeterminate")("mat-pseudo-checkbox-checked",i.state==="checked")("mat-pseudo-checkbox-disabled",i.disabled)("mat-pseudo-checkbox-minimal",i.appearance==="minimal")("mat-pseudo-checkbox-full",i.appearance==="full")("_mat-animation-noopable",i._animationsDisabled)},inputs:{state:"state",disabled:"disabled",appearance:"appearance"},decls:0,vars:0,template:function(t,i){},styles:[`.mat-pseudo-checkbox{border-radius:2px;cursor:pointer;display:inline-block;vertical-align:middle;box-sizing:border-box;position:relative;flex-shrink:0;transition:border-color 90ms cubic-bezier(0, 0, 0.2, 0.1),background-color 90ms cubic-bezier(0, 0, 0.2, 0.1)}.mat-pseudo-checkbox::after{position:absolute;opacity:0;content:"";border-bottom:2px solid currentColor;transition:opacity 90ms cubic-bezier(0, 0, 0.2, 0.1)}.mat-pseudo-checkbox._mat-animation-noopable{transition:none !important;animation:none !important}.mat-pseudo-checkbox._mat-animation-noopable::after{transition:none}.mat-pseudo-checkbox-disabled{cursor:default}.mat-pseudo-checkbox-indeterminate::after{left:1px;opacity:1;border-radius:2px}.mat-pseudo-checkbox-checked::after{left:1px;border-left:2px solid currentColor;transform:rotate(-45deg);opacity:1;box-sizing:content-box}.mat-pseudo-checkbox-minimal.mat-pseudo-checkbox-checked::after,.mat-pseudo-checkbox-minimal.mat-pseudo-checkbox-indeterminate::after{color:var(--mat-pseudo-checkbox-minimal-selected-checkmark-color, var(--mat-sys-primary))}.mat-pseudo-checkbox-minimal.mat-pseudo-checkbox-checked.mat-pseudo-checkbox-disabled::after,.mat-pseudo-checkbox-minimal.mat-pseudo-checkbox-indeterminate.mat-pseudo-checkbox-disabled::after{color:var(--mat-pseudo-checkbox-minimal-disabled-selected-checkmark-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-pseudo-checkbox-full{border-color:var(--mat-pseudo-checkbox-full-unselected-icon-color, var(--mat-sys-on-surface-variant));border-width:2px;border-style:solid}.mat-pseudo-checkbox-full.mat-pseudo-checkbox-disabled{border-color:var(--mat-pseudo-checkbox-full-disabled-unselected-icon-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-pseudo-checkbox-full.mat-pseudo-checkbox-checked,.mat-pseudo-checkbox-full.mat-pseudo-checkbox-indeterminate{background-color:var(--mat-pseudo-checkbox-full-selected-icon-color, var(--mat-sys-primary));border-color:rgba(0,0,0,0)}.mat-pseudo-checkbox-full.mat-pseudo-checkbox-checked::after,.mat-pseudo-checkbox-full.mat-pseudo-checkbox-indeterminate::after{color:var(--mat-pseudo-checkbox-full-selected-checkmark-color, var(--mat-sys-on-primary))}.mat-pseudo-checkbox-full.mat-pseudo-checkbox-checked.mat-pseudo-checkbox-disabled,.mat-pseudo-checkbox-full.mat-pseudo-checkbox-indeterminate.mat-pseudo-checkbox-disabled{background-color:var(--mat-pseudo-checkbox-full-disabled-selected-icon-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-pseudo-checkbox-full.mat-pseudo-checkbox-checked.mat-pseudo-checkbox-disabled::after,.mat-pseudo-checkbox-full.mat-pseudo-checkbox-indeterminate.mat-pseudo-checkbox-disabled::after{color:var(--mat-pseudo-checkbox-full-disabled-selected-checkmark-color, var(--mat-sys-surface))}.mat-pseudo-checkbox{width:18px;height:18px}.mat-pseudo-checkbox-minimal.mat-pseudo-checkbox-checked::after{width:14px;height:6px;transform-origin:center;top:-4.2426406871px;left:0;bottom:0;right:0;margin:auto}.mat-pseudo-checkbox-minimal.mat-pseudo-checkbox-indeterminate::after{top:8px;width:16px}.mat-pseudo-checkbox-full.mat-pseudo-checkbox-checked::after{width:10px;height:4px;transform-origin:center;top:-2.8284271247px;left:0;bottom:0;right:0;margin:auto}.mat-pseudo-checkbox-full.mat-pseudo-checkbox-indeterminate::after{top:6px;width:12px}
2
- `],encapsulation:2,changeDetection:0})}return s})();var Qe=["*",[["mat-option"],["ng-container"]]],Ze=["*","mat-option, ng-container"],Je=["text"],Xe=[[["mat-icon"]],"*"],et=["mat-icon","*"];function tt(s,n){if(s&1&&P(0,"mat-pseudo-checkbox",1),s&2){let e=F();N("disabled",e.disabled)("state",e.selected?"checked":"unchecked")}}function it(s,n){if(s&1&&P(0,"mat-pseudo-checkbox",3),s&2){let e=F();N("disabled",e.disabled)}}function at(s,n){if(s&1&&(q(0,"span",4),Q(1),G()),s&2){let e=F();E(),Z("(",e.group.label,")")}}var ae=new H("MAT_OPTION_PARENT_COMPONENT"),se=new H("MatOptgroup"),st=(()=>{class s{label;disabled=!1;_labelId=m(X).getId("mat-optgroup-label-");_inert;constructor(){let e=m(ae,{optional:!0});this._inert=e?.inertGroups??!1}static \u0275fac=function(t){return new(t||s)};static \u0275cmp=_({type:s,selectors:[["mat-optgroup"]],hostAttrs:[1,"mat-mdc-optgroup"],hostVars:3,hostBindings:function(t,i){t&2&&Y("role",i._inert?null:"group")("aria-disabled",i._inert?null:i.disabled.toString())("aria-labelledby",i._inert?null:i._labelId)},inputs:{label:"label",disabled:[2,"disabled","disabled",J]},exportAs:["matOptgroup"],features:[Me([{provide:se,useExisting:s}])],ngContentSelectors:Ze,decls:5,vars:4,consts:[["role","presentation",1,"mat-mdc-optgroup-label",3,"id"],[1,"mdc-list-item__primary-text"]],template:function(t,i){t&1&&(C(Qe),ke(0,"span",0)(1,"span",1),Q(2),k(3),Se()(),k(4,1)),t&2&&(S("mdc-list-item--disabled",i.disabled),K("id",i._labelId),E(2),Z("",i.label," "))},styles:[`.mat-mdc-optgroup{color:var(--mat-optgroup-label-text-color, var(--mat-sys-on-surface-variant));font-family:var(--mat-optgroup-label-text-font, var(--mat-sys-title-small-font));line-height:var(--mat-optgroup-label-text-line-height, var(--mat-sys-title-small-line-height));font-size:var(--mat-optgroup-label-text-size, var(--mat-sys-title-small-size));letter-spacing:var(--mat-optgroup-label-text-tracking, var(--mat-sys-title-small-tracking));font-weight:var(--mat-optgroup-label-text-weight, var(--mat-sys-title-small-weight))}.mat-mdc-optgroup-label{display:flex;position:relative;align-items:center;justify-content:flex-start;overflow:hidden;min-height:48px;padding:0 16px;outline:none}.mat-mdc-optgroup-label.mdc-list-item--disabled{opacity:.38}.mat-mdc-optgroup-label .mdc-list-item__primary-text{font-size:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;font-family:inherit;text-decoration:inherit;text-transform:inherit;white-space:normal;color:inherit}
3
- `],encapsulation:2,changeDetection:0})}return s})(),B=class{source;isUserInput;constructor(n,e=!1){this.source=n,this.isUserInput=e}},ne=(()=>{class s{_element=m(be);_changeDetectorRef=m(Te);_parent=m(ae,{optional:!0});group=m(se,{optional:!0});_signalDisableRipple=!1;_selected=!1;_active=!1;_mostRecentViewValue="";get multiple(){return this._parent&&this._parent.multiple}get selected(){return this._selected}value;id=m(X).getId("mat-option-");get disabled(){return this.group&&this.group.disabled||this._disabled()}set disabled(e){this._disabled.set(e)}_disabled=ge(!1);get disableRipple(){return this._signalDisableRipple?this._parent.disableRipple():!!this._parent?.disableRipple}get hideSingleSelectionIndicator(){return!!(this._parent&&this._parent.hideSingleSelectionIndicator)}onSelectionChange=new ue;_text;_stateChanges=new d;constructor(){let e=m(Ee);e.load($e),e.load(we),this._signalDisableRipple=!!this._parent&&_e(this._parent.disableRipple)}get active(){return this._active}get viewValue(){return(this._text?.nativeElement.textContent||"").trim()}select(e=!0){this._selected||(this._selected=!0,this._changeDetectorRef.markForCheck(),e&&this._emitSelectionChangeEvent())}deselect(e=!0){this._selected&&(this._selected=!1,this._changeDetectorRef.markForCheck(),e&&this._emitSelectionChangeEvent())}focus(e,t){let i=this._getHostElement();typeof i.focus=="function"&&i.focus(t)}setActiveStyles(){this._active||(this._active=!0,this._changeDetectorRef.markForCheck())}setInactiveStyles(){this._active&&(this._active=!1,this._changeDetectorRef.markForCheck())}getLabel(){return this.viewValue}_handleKeydown(e){(e.keyCode===13||e.keyCode===32)&&!Ce(e)&&(this._selectViaInteraction(),e.preventDefault())}_selectViaInteraction(){this.disabled||(this._selected=this.multiple?!this._selected:!0,this._changeDetectorRef.markForCheck(),this._emitSelectionChangeEvent(!0))}_getTabIndex(){return this.disabled?"-1":"0"}_getHostElement(){return this._element.nativeElement}ngAfterViewChecked(){if(this._selected){let e=this.viewValue;e!==this._mostRecentViewValue&&(this._mostRecentViewValue&&this._stateChanges.next(),this._mostRecentViewValue=e)}}ngOnDestroy(){this._stateChanges.complete()}_emitSelectionChangeEvent(e=!1){this.onSelectionChange.emit(new B(this,e))}static \u0275fac=function(t){return new(t||s)};static \u0275cmp=_({type:s,selectors:[["mat-option"]],viewQuery:function(t,i){if(t&1&&ye(Je,7),t&2){let a;xe(a=De())&&(i._text=a.first)}},hostAttrs:["role","option",1,"mat-mdc-option","mdc-list-item"],hostVars:11,hostBindings:function(t,i){t&1&&ve("click",function(){return i._selectViaInteraction()})("keydown",function(o){return i._handleKeydown(o)}),t&2&&(K("id",i.id),Y("aria-selected",i.selected)("aria-disabled",i.disabled.toString()),S("mdc-list-item--selected",i.selected)("mat-mdc-option-multiple",i.multiple)("mat-mdc-option-active",i.active)("mdc-list-item--disabled",i.disabled))},inputs:{value:"value",id:"id",disabled:[2,"disabled","disabled",J]},outputs:{onSelectionChange:"onSelectionChange"},exportAs:["matOption"],ngContentSelectors:et,decls:8,vars:5,consts:[["text",""],["aria-hidden","true",1,"mat-mdc-option-pseudo-checkbox",3,"disabled","state"],[1,"mdc-list-item__primary-text"],["state","checked","aria-hidden","true","appearance","minimal",1,"mat-mdc-option-pseudo-checkbox",3,"disabled"],[1,"cdk-visually-hidden"],["aria-hidden","true","mat-ripple","",1,"mat-mdc-option-ripple","mat-focus-indicator",3,"matRippleTrigger","matRippleDisabled"]],template:function(t,i){t&1&&(C(Xe),W(0,tt,1,2,"mat-pseudo-checkbox",1),k(1),q(2,"span",2,0),k(4,1),G(),W(5,it,1,1,"mat-pseudo-checkbox",3),W(6,at,2,1,"span",4),P(7,"div",5)),t&2&&(I(i.multiple?0:-1),E(5),I(!i.multiple&&i.selected&&!i.hideSingleSelectionIndicator?5:-1),E(),I(i.group&&i.group._inert?6:-1),E(),N("matRippleTrigger",i._getHostElement())("matRippleDisabled",i.disabled||i.disableRipple))},dependencies:[Ue,ee],styles:[`.mat-mdc-option{-webkit-user-select:none;user-select:none;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:flex;position:relative;align-items:center;justify-content:flex-start;overflow:hidden;min-height:48px;padding:0 16px;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0);color:var(--mat-option-label-text-color, var(--mat-sys-on-surface));font-family:var(--mat-option-label-text-font, var(--mat-sys-label-large-font));line-height:var(--mat-option-label-text-line-height, var(--mat-sys-label-large-line-height));font-size:var(--mat-option-label-text-size, var(--mat-sys-body-large-size));letter-spacing:var(--mat-option-label-text-tracking, var(--mat-sys-label-large-tracking));font-weight:var(--mat-option-label-text-weight, var(--mat-sys-body-large-weight))}.mat-mdc-option:hover:not(.mdc-list-item--disabled){background-color:var(--mat-option-hover-state-layer-color, color-mix(in srgb, var(--mat-sys-on-surface) calc(var(--mat-sys-hover-state-layer-opacity) * 100%), transparent))}.mat-mdc-option:focus.mdc-list-item,.mat-mdc-option.mat-mdc-option-active.mdc-list-item{background-color:var(--mat-option-focus-state-layer-color, color-mix(in srgb, var(--mat-sys-on-surface) calc(var(--mat-sys-focus-state-layer-opacity) * 100%), transparent));outline:0}.mat-mdc-option.mdc-list-item--selected:not(.mdc-list-item--disabled):not(.mat-mdc-option-active,.mat-mdc-option-multiple,:focus,:hover){background-color:var(--mat-option-selected-state-layer-color, var(--mat-sys-secondary-container))}.mat-mdc-option.mdc-list-item--selected:not(.mdc-list-item--disabled):not(.mat-mdc-option-active,.mat-mdc-option-multiple,:focus,:hover) .mdc-list-item__primary-text{color:var(--mat-option-selected-state-label-text-color, var(--mat-sys-on-secondary-container))}.mat-mdc-option .mat-pseudo-checkbox{--mat-pseudo-checkbox-minimal-selected-checkmark-color: var(--mat-option-selected-state-label-text-color, var(--mat-sys-on-secondary-container))}.mat-mdc-option.mdc-list-item{align-items:center;background:rgba(0,0,0,0)}.mat-mdc-option.mdc-list-item--disabled{cursor:default;pointer-events:none}.mat-mdc-option.mdc-list-item--disabled .mat-mdc-option-pseudo-checkbox,.mat-mdc-option.mdc-list-item--disabled .mdc-list-item__primary-text,.mat-mdc-option.mdc-list-item--disabled>mat-icon{opacity:.38}.mat-mdc-optgroup .mat-mdc-option:not(.mat-mdc-option-multiple){padding-left:32px}[dir=rtl] .mat-mdc-optgroup .mat-mdc-option:not(.mat-mdc-option-multiple){padding-left:16px;padding-right:32px}.mat-mdc-option .mat-icon,.mat-mdc-option .mat-pseudo-checkbox-full{margin-right:16px;flex-shrink:0}[dir=rtl] .mat-mdc-option .mat-icon,[dir=rtl] .mat-mdc-option .mat-pseudo-checkbox-full{margin-right:0;margin-left:16px}.mat-mdc-option .mat-pseudo-checkbox-minimal{margin-left:16px;flex-shrink:0}[dir=rtl] .mat-mdc-option .mat-pseudo-checkbox-minimal{margin-right:16px;margin-left:0}.mat-mdc-option .mat-mdc-option-ripple{top:0;left:0;right:0;bottom:0;position:absolute;pointer-events:none}.mat-mdc-option .mdc-list-item__primary-text{white-space:normal;font-size:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;font-family:inherit;text-decoration:inherit;text-transform:inherit;margin-right:auto}[dir=rtl] .mat-mdc-option .mdc-list-item__primary-text{margin-right:0;margin-left:auto}@media(forced-colors: active){.mat-mdc-option.mdc-list-item--selected:not(:has(.mat-mdc-option-pseudo-checkbox))::after{content:"";position:absolute;top:50%;right:16px;transform:translateY(-50%);width:10px;height:0;border-bottom:solid 10px;border-radius:10px}[dir=rtl] .mat-mdc-option.mdc-list-item--selected:not(:has(.mat-mdc-option-pseudo-checkbox))::after{right:auto;left:16px}}.mat-mdc-option-multiple{--mat-list-list-item-selected-container-color: var(--mat-list-list-item-container-color, transparent)}.mat-mdc-option-active .mat-focus-indicator::before{content:""}
4
- `],encapsulation:2,changeDetection:0})}return s})();function nt(s,n,e){if(e.length){let t=n.toArray(),i=e.toArray(),a=0;for(let o=0;o<s+1;o++)t[o].group&&t[o].group===i[a]&&a++;return a}return 0}function ot(s,n,e,t){return s<e?s:s+n>e+t?Math.max(0,s-t+n):e}var oe=class{_multiple;_emitChanges;compareWith;_selection=new Set;_deselectedToEmit=[];_selectedToEmit=[];_selected=null;get selected(){return this._selected||(this._selected=Array.from(this._selection.values())),this._selected}changed=new d;constructor(n=!1,e,t=!0,i){this._multiple=n,this._emitChanges=t,this.compareWith=i,e&&e.length&&(n?e.forEach(a=>this._markSelected(a)):this._markSelected(e[0]),this._selectedToEmit.length=0)}select(...n){this._verifyValueAssignment(n),n.forEach(t=>this._markSelected(t));let e=this._hasQueuedChanges();return this._emitChangeEvent(),e}deselect(...n){this._verifyValueAssignment(n),n.forEach(t=>this._unmarkSelected(t));let e=this._hasQueuedChanges();return this._emitChangeEvent(),e}setSelection(...n){this._verifyValueAssignment(n);let e=this.selected,t=new Set(n.map(a=>this._getConcreteValue(a)));n.forEach(a=>this._markSelected(a)),e.filter(a=>!t.has(this._getConcreteValue(a,t))).forEach(a=>this._unmarkSelected(a));let i=this._hasQueuedChanges();return this._emitChangeEvent(),i}toggle(n){return this.isSelected(n)?this.deselect(n):this.select(n)}clear(n=!0){this._unmarkAll();let e=this._hasQueuedChanges();return n&&this._emitChangeEvent(),e}isSelected(n){return this._selection.has(this._getConcreteValue(n))}isEmpty(){return this._selection.size===0}hasValue(){return!this.isEmpty()}sort(n){this._multiple&&this.selected&&this._selected.sort(n)}isMultipleSelection(){return this._multiple}_emitChangeEvent(){this._selected=null,(this._selectedToEmit.length||this._deselectedToEmit.length)&&(this.changed.next({source:this,added:this._selectedToEmit,removed:this._deselectedToEmit}),this._deselectedToEmit=[],this._selectedToEmit=[])}_markSelected(n){n=this._getConcreteValue(n),this.isSelected(n)||(this._multiple||this._unmarkAll(),this.isSelected(n)||this._selection.add(n),this._emitChanges&&this._selectedToEmit.push(n))}_unmarkSelected(n){n=this._getConcreteValue(n),this.isSelected(n)&&(this._selection.delete(n),this._emitChanges&&this._deselectedToEmit.push(n))}_unmarkAll(){this.isEmpty()||this._selection.forEach(n=>this._unmarkSelected(n))}_verifyValueAssignment(n){n.length>1&&this._multiple}_hasQueuedChanges(){return!!(this._deselectedToEmit.length||this._selectedToEmit.length)}_getConcreteValue(n,e){if(this.compareWith){e=e??this._selection;for(let t of e)if(this.compareWith(n,t))return t;return n}else return n}};var rt=(()=>{class s{_listeners=[];notify(e,t){for(let i of this._listeners)i(e,t)}listen(e){return this._listeners.push(e),()=>{this._listeners=this._listeners.filter(t=>e!==t)}}ngOnDestroy(){this._listeners=[]}static \u0275fac=function(t){return new(t||s)};static \u0275prov=T({token:s,factory:s.\u0275fac,providedIn:"root"})}return s})();var Ve=class{applyChanges(n,e,t,i,a){n.forEachOperation((o,r,c)=>{let l,h;if(o.previousIndex==null){let g=t(o,r,c);l=e.createEmbeddedView(g.templateRef,g.context,g.index),h=V.INSERTED}else c==null?(e.remove(r),h=V.REMOVED):(l=e.get(r),e.move(l,c),h=V.MOVED);a&&a({context:l?.context,operation:h,record:o})})}detach(){}};var je=(()=>{class s{static \u0275fac=function(t){return new(t||s)};static \u0275mod=A({type:s});static \u0275inj=$({imports:[U]})}return s})();var ct=(()=>{class s{static \u0275fac=function(t){return new(t||s)};static \u0275mod=A({type:s});static \u0275inj=$({imports:[te,je,ne,U]})}return s})();var lt=["mat-internal-form-field",""],dt=["*"],xi=(()=>{class s{labelPosition="after";static \u0275fac=function(t){return new(t||s)};static \u0275cmp=_({type:s,selectors:[["div","mat-internal-form-field",""]],hostAttrs:[1,"mdc-form-field","mat-internal-form-field"],hostVars:2,hostBindings:function(t,i){t&2&&S("mdc-form-field--align-end",i.labelPosition==="before")},inputs:{labelPosition:"labelPosition"},attrs:lt,ngContentSelectors:dt,decls:1,vars:0,template:function(t,i){t&1&&(C(),k(0))},styles:[`.mat-internal-form-field{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:inline-flex;align-items:center;vertical-align:middle}.mat-internal-form-field>label{margin-left:0;margin-right:auto;padding-left:4px;padding-right:0;order:0}[dir=rtl] .mat-internal-form-field>label{margin-left:auto;margin-right:0;padding-left:0;padding-right:4px}.mdc-form-field--align-end>label{margin-left:auto;margin-right:0;padding-left:0;padding-right:4px;order:-1}[dir=rtl] .mdc-form-field--align-end .mdc-form-field--align-end label{margin-left:0;margin-right:auto;padding-left:4px;padding-right:0}
5
- `],encapsulation:2,changeDetection:0})}return s})();export{Ue as a,ae as b,se as c,st as d,B as e,ne as f,nt as g,ot as h,rt as i,Ve as j,oe as k,je as l,ct as m,xi as n,x as o,Ye as p,Ne as q,Ft as r};
@@ -1,3 +0,0 @@
1
- import{a as te,b as $,d as q,e as ze,f as Nt,g as At,h as Me,n as Oe,p as oe,q as Wt,r as Pe,s as ne,t as Lt,u as He}from"./chunk-QN4XMV3X.js";import{c as Ot,g as re}from"./chunk-B2CYEVGO.js";import{a as Pt,b as Ht,e as Ne,f as Ae,h as We,i as It,j as Le}from"./chunk-S4UHQERA.js";import{e as zt}from"./chunk-GHPW4BPE.js";import{a as ke,d as F,i as Te,m as Rt,n as Mt}from"./chunk-PKB75FW2.js";import{Ac as fe,Ba as Q,Bb as dt,Bc as _t,Cb as ht,Cd as Dt,Da as P,Db as B,Eb as b,Ec as vt,Fb as _,Fc as U,Ga as _e,Gb as xe,Gc as wt,Ha as W,Hb as J,Ib as pe,Jb as ct,La as ce,Mb as ut,Nb as V,Pb as x,Pc as Ct,Pe as me,Qe as Re,Rb as H,Sb as Je,Se as ie,Tb as Ee,Te as se,Ua as ot,Ub as pt,V as rt,Va as Ye,Vb as ge,Wa as M,Wb as Z,Xb as ee,Zb as gt,Zc as xt,_b as ft,a as m,ab as Xe,ac as De,b as E,cb as ve,db as ue,ec as v,f as D,fc as mt,gb as k,gc as yt,he as St,ib as nt,ie as kt,kb as we,ke as Tt,la as X,lb as Ce,mb as at,nb as lt,nc as bt,oc as Ze,pc as Se,qa as y,va as N,wa as A,wb as Qe,x as be,xb as L,yb as I,yc as et,zd as Et}from"./chunk-UBBLNNPA.js";var h=class l{static getElements(o,e=document){if(typeof o=="string"){let t="getElementById"in e?e:void 0;if(t&&!isNaN(+o[0])){let s=t.getElementById(o);return s?[s]:[]}let i=e.querySelectorAll(o);if(!i.length&&o[0]!=="."&&o[0]!=="#"&&(i=e.querySelectorAll("."+o),i.length||(i=e.querySelectorAll("#"+o)),!i.length)){let s=e.querySelector(`[gs-id="${o}"]`);return s?[s]:[]}return Array.from(i)}return[o]}static getElement(o,e=document){if(typeof o=="string"){let t="getElementById"in e?e:void 0;if(!o.length)return null;if(t&&o[0]==="#")return t.getElementById(o.substring(1));if(o[0]==="#"||o[0]==="."||o[0]==="[")return e.querySelector(o);if(t&&!isNaN(+o[0]))return t.getElementById(o);let i=e.querySelector(o);return t&&!i&&(i=t.getElementById(o)),i||(i=e.querySelector("."+o)),i}return o}static lazyLoad(o){return o.lazyLoad||o.grid?.opts?.lazyLoad&&o.lazyLoad!==!1}static createDiv(o,e){let t=document.createElement("div");return o.forEach(i=>{i&&t.classList.add(i)}),e?.appendChild(t),t}static shouldSizeToContent(o,e=!1){return o?.grid&&(e?o.sizeToContent===!0||o.grid.opts.sizeToContent===!0&&o.sizeToContent===void 0:!!o.sizeToContent||o.grid.opts.sizeToContent&&o.sizeToContent!==!1)}static isIntercepted(o,e){return!(o.y>=e.y+e.h||o.y+o.h<=e.y||o.x+o.w<=e.x||o.x>=e.x+e.w)}static isTouching(o,e){return l.isIntercepted(o,{x:e.x-.5,y:e.y-.5,w:e.w+1,h:e.h+1})}static areaIntercept(o,e){let t=o.x>e.x?o.x:e.x,i=o.x+o.w<e.x+e.w?o.x+o.w:e.x+e.w;if(i<=t)return 0;let s=o.y>e.y?o.y:e.y,r=o.y+o.h<e.y+e.h?o.y+o.h:e.y+e.h;return r<=s?0:(i-t)*(r-s)}static area(o){return o.w*o.h}static sort(o,e=1){return o.sort((i,s)=>{let r=e*((i.y??1e4)-(s.y??1e4));return r===0?e*((i.x??1e4)-(s.x??1e4)):r})}static find(o,e){return e?o.find(t=>t.id===e):void 0}static toBool(o){return typeof o=="boolean"?o:typeof o=="string"?(o=o.toLowerCase(),!(o===""||o==="no"||o==="false"||o==="0")):!!o}static toNumber(o){return o===null||o.length===0?void 0:Number(o)}static parseHeight(o){let e,t="px";if(typeof o=="string")if(o==="auto"||o==="")e=0;else{let i=o.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%|cm|mm)?$/);if(!i)throw new Error(`Invalid height val = ${o}`);t=i[2]||"px",e=parseFloat(i[1])}else e=o;return{h:e,unit:t}}static defaults(o,...e){return e.forEach(t=>{for(let i in t){if(!t.hasOwnProperty(i))return;o[i]===null||o[i]===void 0?o[i]=t[i]:typeof t[i]=="object"&&typeof o[i]=="object"&&l.defaults(o[i],t[i])}}),o}static same(o,e){if(typeof o!="object")return o==e;if(typeof o!=typeof e||Object.keys(o).length!==Object.keys(e).length)return!1;for(let t in o)if(o[t]!==e[t])return!1;return!0}static copyPos(o,e,t=!1){return e.x!==void 0&&(o.x=e.x),e.y!==void 0&&(o.y=e.y),e.w!==void 0&&(o.w=e.w),e.h!==void 0&&(o.h=e.h),t&&(e.minW&&(o.minW=e.minW),e.minH&&(o.minH=e.minH),e.maxW&&(o.maxW=e.maxW),e.maxH&&(o.maxH=e.maxH)),o}static samePos(o,e){return o&&e&&o.x===e.x&&o.y===e.y&&(o.w||1)===(e.w||1)&&(o.h||1)===(e.h||1)}static sanitizeMinMax(o){o.minW||delete o.minW,o.minH||delete o.minH,o.maxW||delete o.maxW,o.maxH||delete o.maxH}static removeInternalAndSame(o,e){if(!(typeof o!="object"||typeof e!="object")&&!(Array.isArray(o)||Array.isArray(e)))for(let t in o){let i=o[t],s=e[t];t[0]==="_"||i===s?delete o[t]:i&&typeof i=="object"&&s!==void 0&&(l.removeInternalAndSame(i,s),Object.keys(i).length||delete o[t])}}static removeInternalForSave(o,e=!0){for(let t in o)(t[0]==="_"||o[t]===null||o[t]===void 0)&&delete o[t];delete o.grid,e&&delete o.el,o.autoPosition||delete o.autoPosition,o.noResize||delete o.noResize,o.noMove||delete o.noMove,o.locked||delete o.locked,(o.w===1||o.w===o.minW)&&delete o.w,(o.h===1||o.h===o.minH)&&delete o.h}static throttle(o,e){let t=!1;return(...i)=>{t||(t=!0,setTimeout(()=>{o(...i),t=!1},e))}}static removePositioningStyles(o){let e=o.style;e.position&&e.removeProperty("position"),e.left&&e.removeProperty("left"),e.top&&e.removeProperty("top"),e.width&&e.removeProperty("width"),e.height&&e.removeProperty("height")}static getScrollElement(o){if(!o)return document.scrollingElement||document.documentElement;let e=getComputedStyle(o);return/(auto|scroll)/.test(e.overflow+e.overflowY)?o:l.getScrollElement(o.parentElement)}static updateScrollPosition(o,e,t){let i=l.getScrollElement(o);if(!i)return;let s=o.getBoundingClientRect(),r=i.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight,a=s.bottom-Math.min(r.bottom,n),u=s.top-Math.max(r.top,0),c=i.scrollTop;u<0&&t<0?o.offsetHeight>r.height?i.scrollTop+=t:i.scrollTop+=Math.abs(u)>Math.abs(t)?t:u:a>0&&t>0&&(o.offsetHeight>r.height?i.scrollTop+=t:i.scrollTop+=a>t?t:a),e.top+=i.scrollTop-c}static updateScrollResize(o,e,t){let i=l.getScrollElement(e),s=i.clientHeight,r=i===l.getScrollElement()?0:i.getBoundingClientRect().top,n=o.clientY-r,a=n<t,u=n>s-t;a?i.scrollBy({behavior:"smooth",top:n-t}):u&&i.scrollBy({behavior:"smooth",top:t-(s-n)})}static clone(o){return o==null||typeof o!="object"?o:o instanceof Array?[...o]:m({},o)}static cloneDeep(o){let e=["parentGrid","el","grid","subGrid","engine"],t=l.clone(o);for(let i in t)t.hasOwnProperty(i)&&typeof t[i]=="object"&&i.substring(0,2)!=="__"&&!e.find(s=>s===i)&&(t[i]=l.cloneDeep(o[i]));return t}static cloneNode(o){let e=o.cloneNode(!0);return e.removeAttribute("id"),e}static appendTo(o,e){let t;typeof e=="string"?t=l.getElement(e):t=e,t&&t.appendChild(o)}static addElStyles(o,e){if(e instanceof Object)for(let t in e)e.hasOwnProperty(t)&&(Array.isArray(e[t])?e[t].forEach(i=>{o.style[t]=i}):o.style[t]=e[t])}static initEvent(o,e){let t={type:e.type},i={button:0,which:0,buttons:1,bubbles:!0,cancelable:!0,target:e.target?e.target:o.target};return["altKey","ctrlKey","metaKey","shiftKey"].forEach(s=>t[s]=o[s]),["pageX","pageY","clientX","clientY","screenX","screenY"].forEach(s=>t[s]=o[s]),m(m({},t),i)}static simulateMouseEvent(o,e,t){let i=o,s=new MouseEvent(e,{bubbles:!0,composed:!0,cancelable:!0,view:window,detail:1,screenX:o.screenX,screenY:o.screenY,clientX:o.clientX,clientY:o.clientY,ctrlKey:i.ctrlKey??!1,altKey:i.altKey??!1,shiftKey:i.shiftKey??!1,metaKey:i.metaKey??!1,button:0,relatedTarget:o.target});(t||o.target).dispatchEvent(s)}static getValuesFromTransformedElement(o){let e=document.createElement("div");l.addElStyles(e,{opacity:"0",position:"fixed",top:"0px",left:"0px",width:"1px",height:"1px",zIndex:"-999999"}),o.appendChild(e);let t=e.getBoundingClientRect();return o.removeChild(e),e.remove(),{xScale:1/t.width,yScale:1/t.height,xOffset:t.left,yOffset:t.top}}static swap(o,e,t){if(!o)return;let i=o[e];o[e]=o[t],o[t]=i}static canBeRotated(o){return!(!o||o.w===o.h||o.locked||o.noResize||o.grid?.opts.disableResize||o.minW&&o.minW===o.maxW||o.minH&&o.minH===o.maxH)}};var tt=(()=>{class l{constructor(e={}){this.addedNodes=[],this.removedNodes=[],this.defaultColumn=12,this.column=e.column||this.defaultColumn,this.column>this.defaultColumn&&(this.defaultColumn=this.column),this.maxRow=e.maxRow,this._float=e.float,this.nodes=e.nodes||[],this.onChange=e.onChange}batchUpdate(e=!0,t=!0){return!!this.batchMode===e?this:(this.batchMode=e,e?(this._prevFloat=this._float,this._float=!0,this.cleanNodes(),this.saveInitial()):(this._float=this._prevFloat,delete this._prevFloat,t&&this._packNodes(),this._notify()),this)}_useEntireRowArea(e,t){return(!this.float||this.batchMode&&!this._prevFloat)&&!this._hasLocked&&(!e._moving||e._skipDown||t.y<=e.y)}_fixCollisions(e,t=e,i,s={}){if(this.sortNodes(-1),i=i||this.collide(e,t),!i)return!1;if(e._moving&&!s.nested&&!this.float&&this.swap(e,i))return!0;let r=t;!this._loading&&this._useEntireRowArea(e,t)&&(r={x:0,w:this.column,y:t.y,h:t.h},i=this.collide(e,r,s.skip));let n=!1,a={nested:!0,pack:!1},u=0;for(;i=i||this.collide(e,r,s.skip);){if(u++>this.nodes.length*2)throw new Error("Infinite collide check");let c;if(i.locked||this._loading||e._moving&&!e._skipDown&&t.y>e.y&&!this.float&&(!this.collide(i,E(m({},i),{y:e.y}),e)||!this.collide(i,E(m({},i),{y:t.y-i.h}),e))){e._skipDown=e._skipDown||t.y>e.y;let d=m(E(m({},t),{y:i.y+i.h}),a);c=this._loading&&h.samePos(e,d)?!0:this.moveNode(e,d),(i.locked||this._loading)&&c?h.copyPos(t,e):!i.locked&&c&&s.pack&&(this._packNodes(),t.y=i.y+i.h,h.copyPos(e,t)),n=n||c}else c=this.moveNode(i,m(E(m({},i),{y:t.y+t.h,skip:e}),a));if(!c)return n;i=void 0}return n}collide(e,t=e,i){let s=e._id,r=i?._id;return this.nodes.find(n=>n._id!==s&&n._id!==r&&h.isIntercepted(n,t))}collideAll(e,t=e,i){let s=e._id,r=i?._id;return this.nodes.filter(n=>n._id!==s&&n._id!==r&&h.isIntercepted(n,t))}directionCollideCoverage(e,t,i){if(!t.rect||!e._rect)return;let s=e._rect,r=m({},t.rect);r.y>s.y?(r.h+=r.y-s.y,r.y=s.y):r.h+=s.y-r.y,r.x>s.x?(r.w+=r.x-s.x,r.x=s.x):r.w+=s.x-r.x;let n,a=.5;for(let u of i){if(u.locked||!u._rect)break;let c=u._rect,d=Number.MAX_VALUE,p=Number.MAX_VALUE;s.y<c.y?d=(r.y+r.h-c.y)/c.h:s.y+s.h>c.y+c.h&&(d=(c.y+c.h-r.y)/c.h),s.x<c.x?p=(r.x+r.w-c.x)/c.w:s.x+s.w>c.x+c.w&&(p=(c.x+c.w-r.x)/c.w);let g=Math.min(p,d);g>a&&(a=g,n=u)}return t.collide=n,n}cacheRects(e,t,i,s,r,n){return this.nodes.forEach(a=>a._rect={y:a.y*t+i,x:a.x*e+n,w:a.w*e-n-s,h:a.h*t-i-r}),this}swap(e,t){if(!t||t.locked||!e||e.locked)return!1;function i(){let r=t.x,n=t.y;return t.x=e.x,t.y=e.y,e.h!=t.h?(e.x=r,e.y=t.y+t.h):e.w!=t.w?(e.x=t.x+t.w,e.y=n):(e.x=r,e.y=n),e._dirty=t._dirty=!0,!0}let s;if(e.w===t.w&&e.h===t.h&&(e.x===t.x||e.y===t.y)&&(s=h.isTouching(e,t)))return i();if(s!==!1){if(e.w===t.w&&e.x===t.x&&(s||(s=h.isTouching(e,t)))){if(t.y<e.y){let r=e;e=t,t=r}return i()}if(s!==!1){if(e.h===t.h&&e.y===t.y&&(s||(s=h.isTouching(e,t)))){if(t.x<e.x){let r=e;e=t,t=r}return i()}return!1}}}isAreaEmpty(e,t,i,s){let r={x:e||0,y:t||0,w:i||1,h:s||1};return!this.collide(r)}compact(e="compact",t=!0){if(this.nodes.length===0)return this;t&&this.sortNodes();let i=this.batchMode;i||this.batchUpdate();let s=this._inColumnResize;s||(this._inColumnResize=!0);let r=this.nodes;return this.nodes=[],r.forEach((n,a,u)=>{let c;n.locked||(n.autoPosition=!0,e==="list"&&a&&(c=u[a-1])),this.addNode(n,!1,c)}),s||delete this._inColumnResize,i||this.batchUpdate(!1),this}set float(e){this._float!==e&&(this._float=e||!1,e||this._packNodes()._notify())}get float(){return this._float||!1}sortNodes(e=1){return this.nodes=h.sort(this.nodes,e),this}_packNodes(){return this.batchMode?this:(this.sortNodes(),this.float?this.nodes.forEach(e=>{if(e._updating||e._orig===void 0||e.y===e._orig.y)return;let t=e.y;for(;t>e._orig.y;)--t,this.collide(e,{x:e.x,y:t,w:e.w,h:e.h})||(e._dirty=!0,e.y=t)}):this.nodes.forEach((e,t)=>{if(!e.locked)for(;e.y>0;){let i=t===0?0:e.y-1;if(!(t===0||!this.collide(e,{x:e.x,y:i,w:e.w,h:e.h})))break;e._dirty=e.y!==i,e.y=i}}),this)}prepareNode(e,t){e._id=e._id??l._idSeq++;let i=e.id;if(i){let r=1;for(;this.nodes.find(n=>n.id===e.id&&n!==e);)e.id=i+"_"+r++}(e.x===void 0||e.y===void 0||e.x===null||e.y===null)&&(e.autoPosition=!0);let s={x:0,y:0,w:1,h:1};return h.defaults(e,s),e.autoPosition||delete e.autoPosition,e.noResize||delete e.noResize,e.noMove||delete e.noMove,h.sanitizeMinMax(e),typeof e.x=="string"&&(e.x=Number(e.x)),typeof e.y=="string"&&(e.y=Number(e.y)),typeof e.w=="string"&&(e.w=Number(e.w)),typeof e.h=="string"&&(e.h=Number(e.h)),isNaN(e.x)&&(e.x=s.x,e.autoPosition=!0),isNaN(e.y)&&(e.y=s.y,e.autoPosition=!0),isNaN(e.w)&&(e.w=s.w),isNaN(e.h)&&(e.h=s.h),this.nodeBoundFix(e,t),e}nodeBoundFix(e,t){let i=e._orig||h.copyPos({},e);if(e.maxW&&(e.w=Math.min(e.w||1,e.maxW)),e.maxH&&(e.h=Math.min(e.h||1,e.maxH)),e.minW&&(e.w=Math.max(e.w||1,e.minW)),e.minH&&(e.h=Math.max(e.h||1,e.minH)),(e.x||0)+(e.w||1)>this.column&&this.column<this.defaultColumn&&!this._inColumnResize&&!this.skipCacheUpdate&&e._id!=null&&this.findCacheLayout(e,this.defaultColumn)===-1){let r=m({},e);r.autoPosition||r.x===void 0?(delete r.x,delete r.y):r.x=Math.min(this.defaultColumn-1,r.x),r.w=Math.min(this.defaultColumn,r.w||1),this.cacheOneLayout(r,this.defaultColumn)}return e.w>this.column?e.w=this.column:e.w<1&&(e.w=1),this.maxRow&&e.h>this.maxRow?e.h=this.maxRow:e.h<1&&(e.h=1),e.x<0&&(e.x=0),e.y<0&&(e.y=0),e.x+e.w>this.column&&(t?e.w=this.column-e.x:e.x=this.column-e.w),this.maxRow&&e.y+e.h>this.maxRow&&(t?e.h=this.maxRow-e.y:e.y=this.maxRow-e.h),h.samePos(e,i)||(e._dirty=!0),this}getDirtyNodes(e){return e?this.nodes.filter(t=>t._dirty&&!h.samePos(t,t._orig)):this.nodes.filter(t=>t._dirty)}_notify(e){if(this.batchMode||!this.onChange)return this;let t=(e||[]).concat(this.getDirtyNodes());return this.onChange(t),this}cleanNodes(){return this.batchMode?this:(this.nodes.forEach(e=>{delete e._dirty,delete e._lastTried}),this)}saveInitial(){return this.nodes.forEach(e=>{e._orig=h.copyPos({},e),delete e._dirty}),this._hasLocked=this.nodes.some(e=>e.locked),this}restoreInitial(){return this.nodes.forEach(e=>{!e._orig||h.samePos(e,e._orig)||(h.copyPos(e,e._orig),e._dirty=!0)}),this._notify(),this}findEmptyPosition(e,t=this.nodes,i=this.column,s){let r=s?s.y*i+(s.x+s.w):0,n=!1;for(let a=r;!n;++a){let u=a%i,c=Math.floor(a/i);if(u+e.w>i)continue;let d={x:u,y:c,w:e.w,h:e.h};t.find(p=>h.isIntercepted(d,p))||((e.x!==u||e.y!==c)&&(e._dirty=!0),e.x=u,e.y=c,delete e.autoPosition,n=!0)}return n}addNode(e,t=!1,i){let s=this.nodes.find(n=>n._id===e._id);if(s)return s;this._inColumnResize?this.nodeBoundFix(e):this.prepareNode(e),delete e._temporaryRemoved,delete e._removeDOM;let r;return e.autoPosition&&this.findEmptyPosition(e,this.nodes,this.column,i)&&(delete e.autoPosition,r=!0),this.nodes.push(e),t&&this.addedNodes.push(e),r||this._fixCollisions(e),this.batchMode||this._packNodes()._notify(),e}removeNode(e,t=!0,i=!1){return this.nodes.find(s=>s._id===e._id)?(i&&this.removedNodes.push(e),t&&(e._removeDOM=!0),this.nodes=this.nodes.filter(s=>s._id!==e._id),e._isAboutToRemove||this._packNodes(),this._notify([e]),this):this}removeAll(e=!0,t=!0){if(delete this._layouts,!this.nodes.length)return this;e&&this.nodes.forEach(s=>s._removeDOM=!0);let i=this.nodes;return this.removedNodes=t?i:[],this.nodes=[],this._notify(i)}moveNodeCheck(e,t){if(!this.changedPosConstrain(e,t))return!1;if(t.pack=!0,!this.maxRow)return this.moveNode(e,t);let i,s=new l({column:this.column,float:this.float,nodes:this.nodes.map(n=>n._id===e._id?(i=m({},n),i):m({},n))});if(!i)return!1;let r=s.moveNode(i,t)&&s.getRow()<=Math.max(this.getRow(),this.maxRow);if(!r&&!t.resizing&&t.collide){let n=t.collide.el.gridstackNode;if(this.swap(e,n))return this._notify(),!0}return r?(s.nodes.filter(n=>n._dirty).forEach(n=>{let a=this.nodes.find(u=>u._id===n._id);a&&(h.copyPos(a,n),a._dirty=!0)}),this._notify(),!0):!1}willItFit(e){if(delete e._willFitPos,!this.maxRow)return!0;let t=new l({column:this.column,float:this.float,nodes:this.nodes.map(s=>m({},s))}),i=m({},e);return this.cleanupNode(i),delete i.el,delete i._id,delete i.content,delete i.grid,t.addNode(i),t.getRow()<=this.maxRow?(e._willFitPos=h.copyPos({},i),!0):!1}changedPosConstrain(e,t){return t.w=t.w||e.w,t.h=t.h||e.h,e.x!==t.x||e.y!==t.y?!0:(e.maxW&&(t.w=Math.min(t.w,e.maxW)),e.maxH&&(t.h=Math.min(t.h,e.maxH)),e.minW&&(t.w=Math.max(t.w,e.minW)),e.minH&&(t.h=Math.max(t.h,e.minH)),e.w!==t.w||e.h!==t.h)}moveNode(e,t){if(!e||!t)return!1;let i;t.pack===void 0&&!this.batchMode&&(i=t.pack=!0),typeof t.x!="number"&&(t.x=e.x),typeof t.y!="number"&&(t.y=e.y),typeof t.w!="number"&&(t.w=e.w),typeof t.h!="number"&&(t.h=e.h);let s=e.w!==t.w||e.h!==t.h,r=h.copyPos({},e,!0);if(h.copyPos(r,t),this.nodeBoundFix(r,s),h.copyPos(t,r),!t.forceCollide&&h.samePos(e,t))return!1;let n=h.copyPos({},e),a=this.collideAll(e,r,t.skip),u=!0;if(a.length){let c=e._moving&&!t.nested,d=c?this.directionCollideCoverage(e,t,a):a[0];if(c&&d&&e.grid?.opts?.subGridDynamic&&!e.grid._isTemp){let p=h.areaIntercept(t.rect,d._rect),g=h.area(t.rect),w=h.area(d._rect);p/(g<w?g:w)>.8&&(d.grid.makeSubGrid(d.el,void 0,e),d=void 0)}d?u=!this._fixCollisions(e,r,d,t):(u=!1,i&&delete t.pack)}return u&&!h.samePos(e,r)&&(e._dirty=!0,h.copyPos(e,r)),t.pack&&this._packNodes()._notify(),!h.samePos(e,n)}getRow(){return this.nodes.reduce((e,t)=>Math.max(e,t.y+t.h),0)}beginUpdate(e){return e._updating||(e._updating=!0,delete e._skipDown,this.batchMode||this.saveInitial()),this}endUpdate(){let e=this.nodes.find(t=>t._updating);return e&&(delete e._updating,delete e._skipDown),this}save(e=!0,t,i){let s=this._layouts?.length||0,r;s&&(i?i!==this.column&&(r=this._layouts[i]):this.column!==s-1&&(r=this._layouts[s-1]));let n=[];return this.sortNodes(),this.nodes.forEach(a=>{let u=r?.find(d=>d._id===a._id),c=m(m({},a),u||{});h.removeInternalForSave(c,!e),t&&t(a,c),n.push(c)}),n}layoutsNodesChange(e){return!this._layouts||this._inColumnResize?this:(this._layouts.forEach((t,i)=>{if(!t||i===this.column)return this;if(i<this.column)this._layouts[i]=void 0;else{let s=i/this.column;e.forEach(r=>{if(!r._orig)return;let n=t.find(a=>a._id===r._id);n&&(n.y>=0&&r.y!==r._orig.y&&(n.y+=r.y-r._orig.y,n.y<0&&(n.y=0)),r.x!==r._orig.x&&(n.x=Math.round(r.x*s),n.x<0&&(n.x=0)),r.w!==r._orig.w&&(n.w=Math.round(r.w*s),n.w<1&&(n.w=1)))})}}),this)}columnChanged(e,t,i="moveScale"){if(!this.nodes.length||!t||e===t)return this;let s=i==="compact"||i==="list";s&&this.sortNodes(1),t<e&&this.cacheLayout(this.nodes,e),this.batchUpdate();let r=[],n=s?this.nodes:h.sort(this.nodes,-1);if(t>e&&this._layouts){let a=this._layouts[t]||[],u=this._layouts.length-1;!a.length&&e!==u&&this._layouts[u]?.length&&(e=u,this._layouts[u].forEach(c=>{let d=n.find(p=>p._id===c._id);d&&(!s&&!c.autoPosition&&(d.x=c.x??d.x,d.y=c.y??d.y),d.w=c.w??d.w,(c.x==null||c.y===void 0)&&(d.autoPosition=!0))})),a.forEach(c=>{let d=n.findIndex(p=>p._id===c._id);if(d!==-1){let p=n[d];if(s){p.w=c.w;return}(c.autoPosition||isNaN(c.x)||isNaN(c.y))&&this.findEmptyPosition(c,r),c.autoPosition||(p.x=c.x??p.x,p.y=c.y??p.y,p.w=c.w??p.w,r.push(p)),n.splice(d,1)}})}if(s)this.compact(i,!1);else{if(n.length)if(typeof i=="function")i(t,e,r,n);else{let a=s||i==="none"?1:t/e,u=i==="move"||i==="moveScale",c=i==="scale"||i==="moveScale";n.forEach(d=>{d.x=t===1?0:u?Math.round(d.x*a):Math.min(d.x,t-1),d.w=t===1||e===1?1:c?Math.round(d.w*a)||1:Math.min(d.w,t),r.push(d)}),n=[]}r=h.sort(r,-1),this._inColumnResize=!0,this.nodes=[],r.forEach(a=>{this.addNode(a,!1),delete a._orig})}return this.nodes.forEach(a=>delete a._orig),this.batchUpdate(!1,!s),delete this._inColumnResize,this}cacheLayout(e,t,i=!1){let s=[];return e.forEach((r,n)=>{if(r._id===void 0){let a=r.id?this.nodes.find(u=>u.id===r.id):void 0;r._id=a?._id??l._idSeq++}s[n]={x:r.x,y:r.y,w:r.w,_id:r._id}}),this._layouts=i?[]:this._layouts||[],this._layouts[t]=s,this}cacheOneLayout(e,t){e._id=e._id??l._idSeq++;let i={x:e.x,y:e.y,w:e.w,_id:e._id};(e.autoPosition||e.x===void 0)&&(delete i.x,delete i.y,e.autoPosition&&(i.autoPosition=!0)),this._layouts=this._layouts||[],this._layouts[t]=this._layouts[t]||[];let s=this.findCacheLayout(e,t);return s===-1?this._layouts[t].push(i):this._layouts[t][s]=i,this}findCacheLayout(e,t){return this._layouts?.[t]?.findIndex(i=>i._id===e._id)??-1}removeNodeFromLayoutCache(e){if(this._layouts)for(let t=0;t<this._layouts.length;t++){let i=this.findCacheLayout(e,t);i!==-1&&this._layouts[t].splice(i,1)}}cleanupNode(e){for(let t in e)t[0]==="_"&&t!=="_id"&&delete e[t];return this}}return l._idSeq=0,l})();var O={alwaysShowResizeHandle:"mobile",animate:!0,auto:!0,cellHeight:"auto",cellHeightThrottle:100,cellHeightUnit:"px",column:12,draggable:{handle:".grid-stack-item-content",appendTo:"body",scroll:!0},handle:".grid-stack-item-content",itemClass:"grid-stack-item",margin:10,marginUnit:"px",maxRow:0,minRow:0,placeholderClass:"grid-stack-placeholder",placeholderText:"",removableOptions:{accept:"grid-stack-item",decline:"grid-stack-non-removable"},resizable:{handles:"se"},rtl:"auto"};var f=class{};var T=typeof window<"u"&&typeof document<"u"&&("ontouchstart"in document||"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0),S=class{};function Ie(l,o){l.touches.length>1||(l.cancelable&&l.preventDefault(),h.simulateMouseEvent(l.changedTouches[0],o))}function Bt(l,o){l.cancelable&&l.preventDefault(),h.simulateMouseEvent(l,o)}function ae(l){S.touchHandled||(S.touchHandled=!0,Ie(l,"mousedown"))}function le(l){S.touchHandled&&Ie(l,"mousemove")}function de(l){if(!S.touchHandled)return;S.pointerLeaveTimeout&&(window.clearTimeout(S.pointerLeaveTimeout),delete S.pointerLeaveTimeout);let o=!!f.dragElement;Ie(l,"mouseup"),o||Ie(l,"click"),S.touchHandled=!1}function he(l){l.pointerType!=="mouse"&&l.target.releasePointerCapture(l.pointerId)}function it(l){f.dragElement&&l.pointerType!=="mouse"&&Bt(l,"mouseenter")}function st(l){f.dragElement&&l.pointerType!=="mouse"&&(S.pointerLeaveTimeout=window.setTimeout(()=>{delete S.pointerLeaveTimeout,Bt(l,"mouseleave")},10))}var Ft=(()=>{class l{constructor(e,t,i){this.host=e,this.dir=t,this.option=i,this.moving=!1,this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this._init()}_init(){if(this.option.element)try{this.el=this.option.element instanceof HTMLElement?this.option.element:this.host.querySelector(this.option.element)}catch(e){this.option.element=void 0,console.error("Query for resizeable handle failed, falling back",e)}return this.el||(this.el=document.createElement("div"),this.host.appendChild(this.el)),this.el.classList.add("ui-resizable-handle"),this.el.classList.add(`${l.prefix}${this.dir}`),this.el.style.zIndex="100",this.el.style.userSelect="none",this.el.addEventListener("mousedown",this._mouseDown),T&&(this.el.addEventListener("touchstart",ae),this.el.addEventListener("pointerdown",he)),this}destroy(){return this.moving&&this._mouseUp(this.mouseDownEvent),this.el.removeEventListener("mousedown",this._mouseDown),T&&(this.el.removeEventListener("touchstart",ae),this.el.removeEventListener("pointerdown",he)),this.option.element||this.host.removeChild(this.el),delete this.el,delete this.host,this}_mouseDown(e){this.mouseDownEvent=e,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),T&&(this.el.addEventListener("touchmove",le),this.el.addEventListener("touchend",de)),e.stopPropagation(),e.preventDefault()}_mouseMove(e){let t=this.mouseDownEvent;this.moving?this._triggerEvent("move",e):Math.abs(e.x-t.x)+Math.abs(e.y-t.y)>2&&(this.moving=!0,this._triggerEvent("start",this.mouseDownEvent),this._triggerEvent("move",e),document.addEventListener("keydown",this._keyEvent)),e.stopPropagation()}_mouseUp(e){this.moving&&(this._triggerEvent("stop",e),document.removeEventListener("keydown",this._keyEvent)),document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),T&&(this.el.removeEventListener("touchmove",le),this.el.removeEventListener("touchend",de)),delete this.moving,delete this.mouseDownEvent,e.stopPropagation(),e.preventDefault()}_keyEvent(e){e.key==="Escape"&&(this.host.gridstackNode?.grid?.engine.restoreInitial(),this._mouseUp(this.mouseDownEvent))}_triggerEvent(e,t){return this.option[e]&&this.option[e](t),this}}return l.prefix="ui-resizable-",l})();var K=class{constructor(){this._eventRegister={}}get disabled(){return this._disabled}on(o,e){this._eventRegister[o]=e}off(o){delete this._eventRegister[o]}enable(){this._disabled=!1}disable(){this._disabled=!0}destroy(){delete this._eventRegister}triggerEvent(o,e){if(!this.disabled&&this._eventRegister&&this._eventRegister[o])return this._eventRegister[o](e)}};var Gt=(()=>{class l extends K{constructor(e,t={}){super(),this.el=e,this.option=t,this.rectScale={x:1,y:1},this._ui=()=>{let s=this.el.parentElement.getBoundingClientRect(),r={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},n=this.temporalRect||r;return{position:{left:(n.left-s.left)*this.rectScale.x,top:(n.top-s.top)*this.rectScale.y},size:{width:n.width*this.rectScale.x,height:n.height*this.rectScale.y}}},this._mouseOver=this._mouseOver.bind(this),this._mouseOut=this._mouseOut.bind(this),this.enable(),this._setupAutoHide(this.option.autoHide),this._setupHandlers()}on(e,t){super.on(e,t)}off(e){super.off(e)}enable(){super.enable(),this.el.classList.remove("ui-resizable-disabled"),this._setupAutoHide(this.option.autoHide)}disable(){super.disable(),this.el.classList.add("ui-resizable-disabled"),this._setupAutoHide(!1)}destroy(){this._removeHandlers(),this._setupAutoHide(!1),delete this.el,super.destroy()}updateOption(e){let t=e.handles&&e.handles!==this.option.handles,i=e.autoHide&&e.autoHide!==this.option.autoHide;return Object.keys(e).forEach(s=>this.option[s]=e[s]),t&&(this._removeHandlers(),this._setupHandlers()),i&&this._setupAutoHide(this.option.autoHide),this}_setupAutoHide(e){return e?(this.el.classList.add("ui-resizable-autohide"),this.el.addEventListener("mouseover",this._mouseOver),this.el.addEventListener("mouseout",this._mouseOut)):(this.el.classList.remove("ui-resizable-autohide"),this.el.removeEventListener("mouseover",this._mouseOver),this.el.removeEventListener("mouseout",this._mouseOut),f.overResizeElement===this&&delete f.overResizeElement),this}_mouseOver(e){f.overResizeElement||f.dragElement||(f.overResizeElement=this,this.el.classList.remove("ui-resizable-autohide"))}_mouseOut(e){f.overResizeElement===this&&(delete f.overResizeElement,this.el.classList.add("ui-resizable-autohide"))}_setupHandlers(){return this.handlers=this.option.handles.split(",").map(e=>e.trim()).map(e=>new Ft(this.el,e,{element:this.option.element,start:t=>this._resizeStart(t),stop:t=>this._resizeStop(t),move:t=>this._resizing(t,e)})),this}_resizeStart(e){this.sizeToContent=h.shouldSizeToContent(this.el.gridstackNode,!0),this.originalRect=this.el.getBoundingClientRect(),this.scrollEl=h.getScrollElement(this.el),this.scrollY=this.scrollEl.scrollTop,this.scrolled=0,this.startEvent=e,this._setupHelper(),this._applyChange();let t=h.initEvent(e,{type:"resizestart",target:this.el});return this.option.start&&this.option.start(t,this._ui()),this.el.classList.add("ui-resizable-resizing"),this.triggerEvent("resizestart",t),this}_resizing(e,t){this.scrolled=this.scrollEl.scrollTop-this.scrollY,this.temporalRect=this._getChange(e,t),this._applyChange();let i=h.initEvent(e,{type:"resize",target:this.el});return this.option.resize&&this.option.resize(i,this._ui()),this.triggerEvent("resize",i),this}_resizeStop(e){let t=h.initEvent(e,{type:"resizestop",target:this.el});return this._cleanHelper(),this.option.stop&&this.option.stop(t),this.el.classList.remove("ui-resizable-resizing"),this.triggerEvent("resizestop",t),delete this.startEvent,delete this.originalRect,delete this.temporalRect,delete this.scrollY,delete this.scrolled,this}_setupHelper(){this.elOriginStyleVal=l._originStyleProp.map(i=>this.el.style[i]),this.parentOriginStylePosition=this.el.parentElement.style.position;let e=this.el.parentElement,t=h.getValuesFromTransformedElement(e);return this.rectScale={x:t.xScale,y:t.yScale},getComputedStyle(this.el.parentElement).position.match(/static/)&&(this.el.parentElement.style.position="relative"),this.el.style.position="absolute",this.el.style.opacity="0.8",this}_cleanHelper(){return l._originStyleProp.forEach((e,t)=>{this.el.style[e]=this.elOriginStyleVal[t]||null}),this.el.parentElement.style.position=this.parentOriginStylePosition||null,this}_getChange(e,t){let i=this.startEvent,s={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},r=e.clientX-i.clientX,n=this.sizeToContent?0:e.clientY-i.clientY,a,u;t.indexOf("e")>-1?s.width+=r:t.indexOf("w")>-1&&(s.width-=r,s.left+=r,a=!0),t.indexOf("s")>-1?s.height+=n:t.indexOf("n")>-1&&(s.height-=n,s.top+=n,u=!0);let c=this._constrainSize(s.width,s.height,a,u);return Math.round(s.width)!==Math.round(c.width)&&(t.indexOf("w")>-1&&(s.left+=s.width-c.width),s.width=c.width),Math.round(s.height)!==Math.round(c.height)&&(t.indexOf("n")>-1&&(s.top+=s.height-c.height),s.height=c.height),s}_constrainSize(e,t,i,s){let r=this.option,n=(i?r.maxWidthMoveLeft:r.maxWidth)||Number.MAX_SAFE_INTEGER,a=r.minWidth/this.rectScale.x||e,u=(s?r.maxHeightMoveUp:r.maxHeight)||Number.MAX_SAFE_INTEGER,c=r.minHeight/this.rectScale.y||t,d=Math.min(n,Math.max(a,e)),p=Math.min(u,Math.max(c,t));return{width:d,height:p}}_applyChange(){let e={left:0,top:0,width:0,height:0};if(this.el.style.position==="absolute"){let t=this.el.parentElement,{left:i,top:s}=t.getBoundingClientRect();e={left:i,top:s,width:0,height:0}}return this.temporalRect?(Object.keys(this.temporalRect).forEach(t=>{let i=this.temporalRect[t],s=t==="width"||t==="left"?this.rectScale.x:t==="height"||t==="top"?this.rectScale.y:1;this.el.style[t]=(i-e[t])*s+"px"}),this):this}_removeHandlers(){return this.handlers.forEach(e=>e.destroy()),delete this.handlers,this}}return l._originStyleProp=["width","height","position","left","top","opacity","zIndex"],l})();var si='input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle',Ut=(()=>{class l extends K{constructor(e,t={}){super(),this.el=e,this.option=t,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0};let i=t?.handle?.substring(1),s=e.gridstackNode;this.dragEls=!i||e.classList.contains(i)?[e]:s?.subGrid?[e.querySelector(t.handle)||e]:Array.from(e.querySelectorAll(t.handle)),this.dragEls.length===0&&(this.dragEls=[e]),this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this.enable()}on(e,t){super.on(e,t)}off(e){super.off(e)}enable(){this.disabled!==!1&&(super.enable(),this.dragEls.forEach(e=>{e.addEventListener("mousedown",this._mouseDown),T&&(e.addEventListener("touchstart",ae),e.addEventListener("pointerdown",he))}),this.el.classList.remove("ui-draggable-disabled"))}disable(e=!1){this.disabled!==!0&&(super.disable(),this.dragEls.forEach(t=>{t.removeEventListener("mousedown",this._mouseDown),T&&(t.removeEventListener("touchstart",ae),t.removeEventListener("pointerdown",he))}),e||this.el.classList.add("ui-draggable-disabled"))}destroy(){this.dragTimeout&&window.clearTimeout(this.dragTimeout),delete this.dragTimeout,this.mouseDownEvent&&this._mouseUp(this.mouseDownEvent),this.disable(!0),delete this.el,delete this.helper,delete this.option,super.destroy()}updateOption(e){return Object.keys(e).forEach(t=>this.option[t]=e[t]),this}_mouseDown(e){if(S.touchHandled&&e.isTrusted&&(S.touchHandled=!1),!f.mouseHandled)return e.button!==0||!this.dragEls.find(t=>t===e.target)&&e.target.closest(si)||this.option.cancel&&e.target.closest(this.option.cancel)||(this.mouseDownEvent=e,delete this.dragging,delete f.dragElement,delete f.dropElement,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),T&&(e.currentTarget.addEventListener("touchmove",le),e.currentTarget.addEventListener("touchend",de)),e.preventDefault(),document.activeElement&&document.activeElement.blur(),f.mouseHandled=!0),!0}_callDrag(e){if(!this.dragging)return;let t=h.initEvent(e,{target:this.el,type:"drag"});this.option.drag&&this.option.drag(t,this.ui()),this.triggerEvent("drag",t)}_mouseMove(e){let t=this.mouseDownEvent;if(this.lastDrag=e,this.dragging)if(this._dragFollow(e),f.pauseDrag){let i=Number.isInteger(f.pauseDrag)?f.pauseDrag:100;this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>this._callDrag(e),i)}else this._callDrag(e);else if(Math.abs(e.x-t.x)+Math.abs(e.y-t.y)>3){this.dragging=!0,f.dragElement=this;let i=this.el.gridstackNode?.grid;i?f.dropElement=i.el.ddElement.ddDroppable:delete f.dropElement,this.helper=this._createHelper(),this._setupHelperContainmentStyle(),this.dragTransform=h.getValuesFromTransformedElement(this.helperContainment),this.dragOffset=this._getDragOffset(e,this.el,this.helperContainment),this._setupHelperStyle(e);let s=h.initEvent(e,{target:this.el,type:"dragstart"});this.option.start&&this.option.start(s,this.ui()),this.triggerEvent("dragstart",s),document.addEventListener("keydown",this._keyEvent)}return!0}_mouseUp(e){if(document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),T&&e.currentTarget&&(e.currentTarget.removeEventListener("touchmove",le,!0),e.currentTarget.removeEventListener("touchend",de,!0)),this.dragging){delete this.dragging,delete this.el.gridstackNode?._origRotate,document.removeEventListener("keydown",this._keyEvent),f.dropElement?.el===this.el.parentElement&&delete f.dropElement,this.helperContainment.style.position=this.parentOriginStylePosition||null,this.helper!==this.el&&this.helper.remove(),this._removeHelperStyle();let t=h.initEvent(e,{target:this.el,type:"dragstop"});this.option.stop&&this.option.stop(t),this.triggerEvent("dragstop",t),f.dropElement&&f.dropElement.drop(e)}delete this.helper,delete this.mouseDownEvent,delete f.dragElement,delete f.dropElement,delete f.mouseHandled,e.preventDefault()}_keyEvent(e){let t=this.el.gridstackNode,i=t?.grid||f.dropElement?.el?.gridstack;if(e.key==="Escape")t&&t._origRotate&&(t._orig=t._origRotate,delete t._origRotate),i?.cancelDrag(),this._mouseUp(this.mouseDownEvent);else if(t&&i&&(e.key==="r"||e.key==="R")){if(!h.canBeRotated(t))return;t._origRotate=t._origRotate||m({},t._orig),delete t._moving,i.setAnimation(!1).rotate(t.el,{top:-this.dragOffset.offsetTop,left:-this.dragOffset.offsetLeft}).setAnimation(),t._moving=!0,this.dragOffset=this._getDragOffset(this.lastDrag,t.el,this.helperContainment),this.helper.style.width=this.dragOffset.width+"px",this.helper.style.height=this.dragOffset.height+"px",h.swap(t._orig,"w","h"),delete t._rect,this._mouseMove(this.lastDrag)}}_createHelper(){let e=this.el;return typeof this.option.helper=="function"?e=this.option.helper(this.el):this.option.helper==="clone"&&(e=h.cloneNode(this.el)),e.parentElement||h.appendTo(e,this.option.appendTo==="parent"?this.el.parentElement:this.option.appendTo),this.dragElementOriginStyle=l.originStyleProp.map(t=>this.el.style[t]),e}_setupHelperStyle(e){this.helper.classList.add("ui-draggable-dragging"),this.el.gridstackNode?.grid?.el.classList.add("grid-stack-dragging");let t=this.helper.style;return t.pointerEvents="none",t.width=this.dragOffset.width+"px",t.height=this.dragOffset.height+"px",t.willChange="left, top",t.position="fixed",this._dragFollow(e),t.transition="none",setTimeout(()=>{this.helper&&(t.transition=null)},0),this}_removeHelperStyle(){if(this.helper.classList.remove("ui-draggable-dragging"),this.el.gridstackNode?.grid?.el.classList.remove("grid-stack-dragging"),!this.helper?.gridstackNode?._isAboutToRemove&&this.dragElementOriginStyle){let t=this.helper,i=this.dragElementOriginStyle.transition||null;t.style.transition=this.dragElementOriginStyle.transition="none",l.originStyleProp.forEach(s=>t.style[s]=this.dragElementOriginStyle[s]||null),setTimeout(()=>t.style.transition=i,50)}return delete this.dragElementOriginStyle,this}_dragFollow(e){let t={left:0,top:0},i=this.helper.style,s=this.dragOffset;i.left=(e.clientX+s.offsetLeft-t.left)*this.dragTransform.xScale+"px",i.top=(e.clientY+s.offsetTop-t.top)*this.dragTransform.yScale+"px"}_setupHelperContainmentStyle(){return this.helperContainment=this.helper.parentElement,this.helper.style.position!=="fixed"&&(this.parentOriginStylePosition=this.helperContainment.style.position,getComputedStyle(this.helperContainment).position.match(/static/)&&(this.helperContainment.style.position="relative")),this}_getDragOffset(e,t,i){let s=0,r=0;i&&(s=this.dragTransform.xOffset,r=this.dragTransform.yOffset);let n=t.getBoundingClientRect();return{left:n.left,top:n.top,offsetLeft:-e.clientX+n.left-s,offsetTop:-e.clientY+n.top-r,width:n.width*this.dragTransform.xScale,height:n.height*this.dragTransform.yScale}}ui(){let t=this.el.parentElement.getBoundingClientRect(),i=this.helper.getBoundingClientRect();return{position:{top:(i.top-t.top)*this.dragTransform.yScale,left:(i.left-t.left)*this.dragTransform.xScale}}}}return l.originStyleProp=["width","height","transform","transform-origin","transition","pointerEvents","position","left","top","minWidth","willChange"],l})();var Be=class extends K{constructor(o,e={}){super(),this.el=o,this.option=e,this._mouseEnter=this._mouseEnter.bind(this),this._mouseLeave=this._mouseLeave.bind(this),this.enable(),this._setupAccept()}on(o,e){super.on(o,e)}off(o){super.off(o)}enable(){this.disabled!==!1&&(super.enable(),this.el.classList.add("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),this.el.addEventListener("mouseenter",this._mouseEnter),this.el.addEventListener("mouseleave",this._mouseLeave),T&&(this.el.addEventListener("pointerenter",it),this.el.addEventListener("pointerleave",st)))}disable(o=!1){this.disabled!==!0&&(super.disable(),this.el.classList.remove("ui-droppable"),o||this.el.classList.add("ui-droppable-disabled"),this.el.removeEventListener("mouseenter",this._mouseEnter),this.el.removeEventListener("mouseleave",this._mouseLeave),T&&(this.el.removeEventListener("pointerenter",it),this.el.removeEventListener("pointerleave",st)))}destroy(){this.disable(!0),this.el.classList.remove("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),super.destroy()}updateOption(o){return Object.keys(o).forEach(e=>this.option[e]=o[e]),this._setupAccept(),this}_mouseEnter(o){if(!f.dragElement||S.touchHandled&&o.isTrusted||!this._canDrop(f.dragElement.el))return;o.preventDefault(),o.stopPropagation(),f.dropElement&&f.dropElement!==this&&f.dropElement._mouseLeave(o,!0),f.dropElement=this;let e=h.initEvent(o,{target:this.el,type:"dropover"});this.option.over&&this.option.over(e,this._ui(f.dragElement)),this.triggerEvent("dropover",e),this.el.classList.add("ui-droppable-over")}_mouseLeave(o,e=!1){if(!f.dragElement||f.dropElement!==this)return;o.preventDefault(),o.stopPropagation();let t=h.initEvent(o,{target:this.el,type:"dropout"});if(this.option.out&&this.option.out(t,this._ui(f.dragElement)),this.triggerEvent("dropout",t),f.dropElement===this&&(delete f.dropElement,!e)){let i,s=this.el.parentElement;for(;!i&&s;)i=s.ddElement?.ddDroppable,s=s.parentElement;i&&i._mouseEnter(o)}}drop(o){o.preventDefault();let e=h.initEvent(o,{target:this.el,type:"drop"});this.option.drop&&this.option.drop(e,this._ui(f.dragElement)),this.triggerEvent("drop",e)}_canDrop(o){return o&&(!this.accept||this.accept(o))}_setupAccept(){return this.option.accept?(typeof this.option.accept=="string"?this.accept=o=>o.classList.contains(this.option.accept)||o.matches(this.option.accept):this.accept=this.option.accept,this):this}_ui(o){return m({draggable:o.el},o.ui())}};var Fe=class l{static init(o){return o.ddElement||(o.ddElement=new l(o)),o.ddElement}constructor(o){this.el=o}on(o,e){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(o)>-1?this.ddDraggable.on(o,e):this.ddDroppable&&["drop","dropover","dropout"].indexOf(o)>-1?this.ddDroppable.on(o,e):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(o)>-1&&this.ddResizable.on(o,e),this}off(o){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(o)>-1?this.ddDraggable.off(o):this.ddDroppable&&["drop","dropover","dropout"].indexOf(o)>-1?this.ddDroppable.off(o):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(o)>-1&&this.ddResizable.off(o),this}setupDraggable(o){return this.ddDraggable?this.ddDraggable.updateOption(o):this.ddDraggable=new Ut(this.el,o),this}cleanDraggable(){return this.ddDraggable&&(this.ddDraggable.destroy(),delete this.ddDraggable),this}setupResizable(o){return this.ddResizable?this.ddResizable.updateOption(o):this.ddResizable=new Gt(this.el,o),this}cleanResizable(){return this.ddResizable&&(this.ddResizable.destroy(),delete this.ddResizable),this}setupDroppable(o){return this.ddDroppable?this.ddDroppable.updateOption(o):this.ddDroppable=new Be(this.el,o),this}cleanDroppable(){return this.ddDroppable&&(this.ddDroppable.destroy(),delete this.ddDroppable),this}};var Ge=class{resizable(o,e,t,i){return this._getDDElements(o,e).forEach(s=>{if(e==="disable"||e==="enable")s.ddResizable&&s.ddResizable[e]();else if(e==="destroy")s.ddResizable&&s.cleanResizable();else if(e==="option")s.setupResizable({[t]:i});else{let n=s.el.gridstackNode.grid,a=s.el.getAttribute("gs-resize-handles")||n.opts.resizable.handles||"e,s,se";a==="all"&&(a="n,e,s,w,se,sw,ne,nw");let u=!n.opts.alwaysShowResizeHandle;s.setupResizable(E(m({},n.opts.resizable),{handles:a,autoHide:u,start:e.start,stop:e.stop,resize:e.resize}))}}),this}draggable(o,e,t,i){return this._getDDElements(o,e).forEach(s=>{if(e==="disable"||e==="enable")s.ddDraggable&&s.ddDraggable[e]();else if(e==="destroy")s.ddDraggable&&s.cleanDraggable();else if(e==="option")s.setupDraggable({[t]:i});else{let r=s.el.gridstackNode.grid;s.setupDraggable(E(m({},r.opts.draggable),{start:e.start,stop:e.stop,drag:e.drag}))}}),this}dragIn(o,e){return this._getDDElements(o).forEach(t=>t.setupDraggable(e)),this}droppable(o,e,t,i){return typeof e.accept=="function"&&!e._accept&&(e._accept=e.accept,e.accept=s=>e._accept(s)),this._getDDElements(o,e).forEach(s=>{e==="disable"||e==="enable"?s.ddDroppable&&s.ddDroppable[e]():e==="destroy"?s.ddDroppable&&s.cleanDroppable():e==="option"?s.setupDroppable({[t]:i}):s.setupDroppable(e)}),this}isDroppable(o){return!!(o?.ddElement?.ddDroppable&&!o.ddElement.ddDroppable.disabled)}isDraggable(o){return!!(o?.ddElement?.ddDraggable&&!o.ddElement.ddDraggable.disabled)}isResizable(o){return!!(o?.ddElement?.ddResizable&&!o.ddElement.ddResizable.disabled)}on(o,e,t){return this._getDDElements(o).forEach(i=>i.on(e,s=>{t(s,f.dragElement?f.dragElement.el:s.target,f.dragElement?f.dragElement.helper:null)})),this}off(o,e){return this._getDDElements(o).forEach(t=>t.off(e)),this}_getDDElements(o,e){let t=o.gridstack||e!=="destroy"&&e!=="disable",i=h.getElements(o);return i.length?i.map(r=>r.ddElement||(t?Fe.init(r):null)).filter(r=>r):[]}};var R=new Ge,j=(()=>{class l{static init(e={},t=".grid-stack"){if(typeof document>"u")return null;let i=l.getGridElement(t);return i?(i.gridstack||(i.gridstack=new l(i,h.cloneDeep(e))),i.gridstack):(console.error(typeof t=="string"?'GridStack.initAll() no grid was found with selector "'+t+`" - element missing or wrong selector ?
2
- Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`:"GridStack.init() no grid element was passed."),null)}static initAll(e={},t=".grid-stack"){let i=[];return typeof document>"u"||(l.getGridElements(t).forEach(s=>{s.gridstack||(s.gridstack=new l(s,h.cloneDeep(e))),i.push(s.gridstack)}),i.length===0&&console.error('GridStack.initAll() no grid was found with selector "'+t+`" - element missing or wrong selector ?
3
- Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`)),i}static addGrid(e,t={}){if(!e)return null;let i=e;if(i.gridstack){let n=i.gridstack;return t&&(n.opts=m(m({},n.opts),t)),t.children!==void 0&&n.load(t.children),n}return(!e.classList.contains("grid-stack")||l.addRemoveCB)&&(l.addRemoveCB?i=l.addRemoveCB(e,t,!0,!0):i=h.createDiv(["grid-stack",t.class],e)),l.init(t,i)}static registerEngine(e){l.engineClass=e}get placeholder(){if(!this._placeholder){this._placeholder=h.createDiv([this.opts.placeholderClass,O.itemClass,this.opts.itemClass]);let e=h.createDiv(["placeholder-content"],this._placeholder);this.opts.placeholderText&&(e.textContent=this.opts.placeholderText)}return this._placeholder}constructor(e,t={}){this.el=e,this.opts=t,this.animationDelay=310,this._gsEventHandler={},this._extraDragRow=0,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0},e.gridstack=this,this.opts=t=t||{},e.classList.contains("grid-stack")||this.el.classList.add("grid-stack"),t.row&&(t.minRow=t.maxRow=t.row,delete t.row);let i=h.toNumber(e.getAttribute("gs-row"));t.column==="auto"&&delete t.column,t.alwaysShowResizeHandle!==void 0&&(t._alwaysShowResizeHandle=t.alwaysShowResizeHandle);let s=t.columnOpts;if(s){let c=s.breakpoints;!s.columnWidth&&!c?.length?delete t.columnOpts:(s.columnMax=s.columnMax||12,c?.length>1&&c.sort((d,p)=>(p.w||0)-(d.w||0)))}let r=E(m({},h.cloneDeep(O)),{column:h.toNumber(e.getAttribute("gs-column"))||O.column,minRow:i||h.toNumber(e.getAttribute("gs-min-row"))||O.minRow,maxRow:i||h.toNumber(e.getAttribute("gs-max-row"))||O.maxRow,staticGrid:h.toBool(e.getAttribute("gs-static"))||O.staticGrid,sizeToContent:h.toBool(e.getAttribute("gs-size-to-content"))||void 0,draggable:{handle:(t.handleClass?"."+t.handleClass:t.handle?t.handle:"")||O.draggable.handle},removableOptions:{accept:t.itemClass||O.removableOptions.accept,decline:O.removableOptions.decline}});e.getAttribute("gs-animate")&&(r.animate=h.toBool(e.getAttribute("gs-animate"))),t=h.defaults(t,r),this._initMargin(),this.checkDynamicColumn(),this._updateColumnVar(t),t.rtl==="auto"&&(t.rtl=e.style.direction==="rtl"),t.rtl&&this.el.classList.add("grid-stack-rtl");let a=this.el.closest("."+O.itemClass)?.gridstackNode;if(a&&(a.subGrid=this,this.parentGridNode=a,this.el.classList.add("grid-stack-nested"),a.el.classList.add("grid-stack-sub-grid")),this._isAutoCellHeight=t.cellHeight==="auto",this._isAutoCellHeight||t.cellHeight==="initial")this.cellHeight(void 0);else{typeof t.cellHeight=="number"&&t.cellHeightUnit&&t.cellHeightUnit!==O.cellHeightUnit&&(t.cellHeight=t.cellHeight+t.cellHeightUnit,delete t.cellHeightUnit);let c=t.cellHeight;delete t.cellHeight,this.cellHeight(c)}t.alwaysShowResizeHandle==="mobile"&&(t.alwaysShowResizeHandle=T),this._setStaticClass();let u=t.engineClass||l.engineClass||tt;if(this.engine=new u({column:this.getColumn(),float:t.float,maxRow:t.maxRow,onChange:c=>{c.forEach(d=>{let p=d.el;p&&(d._removeDOM?(p&&p.remove(),delete d._removeDOM):this._writePosAttr(p,d))}),this._updateContainerHeight()}}),t.auto&&(this.batchUpdate(),this.engine._loading=!0,this.getGridItems().forEach(c=>this._prepareElement(c)),delete this.engine._loading,this.batchUpdate(!1)),t.children){let c=t.children;delete t.children,c.length&&this.load(c)}this.setAnimation(),t.subGridDynamic&&!f.pauseDrag&&(f.pauseDrag=!0),t.draggable?.pause!==void 0&&(f.pauseDrag=t.draggable.pause),this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateResizeEvent()}_updateColumnVar(e=this.opts){this.el.classList.add("gs-"+e.column),typeof e.column=="number"&&this.el.style.setProperty("--gs-column-width",`${100/e.column}%`)}addWidget(e){if(!e)return;if(typeof e=="string"){console.error("V11: GridStack.addWidget() does not support string anymore. see #2736");return}if(e.ELEMENT_NODE)return console.error("V11: GridStack.addWidget() does not support HTMLElement anymore. use makeWidget()"),this.makeWidget(e);let t,i=e;if(i.grid=this,i.el?t=i.el:l.addRemoveCB?t=l.addRemoveCB(this.el,e,!0,!1):t=this.createWidgetDivs(i),!t)return;if(i=t.gridstackNode,i&&t.parentElement===this.el&&this.engine.nodes.find(r=>r._id===i._id))return t;let s=this._readAttr(t);return h.defaults(e,s),this.engine.prepareNode(e),this.el.appendChild(t),this.makeWidget(t,e),t}createWidgetDivs(e){let t=h.createDiv(["grid-stack-item",this.opts.itemClass]),i=h.createDiv(["grid-stack-item-content"],t);return h.lazyLoad(e)?e.visibleObservable||(e.visibleObservable=new IntersectionObserver(([s])=>{s.isIntersecting&&(e.visibleObservable?.disconnect(),delete e.visibleObservable,l.renderCB(i,e),e.grid?.prepareDragDrop(e.el))}),window.setTimeout(()=>e.visibleObservable?.observe(t))):l.renderCB(i,e),t}makeSubGrid(e,t,i,s=!0){let r=e.gridstackNode;if(r||(r=this.makeWidget(e).gridstackNode),r.subGrid?.el)return r.subGrid;let n,a=this;for(;a&&!n;)n=a.opts?.subGridOpts,a=a.parentGridNode?.grid;t=h.cloneDeep(m(m(E(m({},this.opts),{id:void 0,children:void 0,column:"auto",columnOpts:void 0,layout:"list",subGridOpts:void 0}),n||{}),t||r.subGridOpts||{})),r.subGridOpts=t;let u;t.column==="auto"&&(u=!0,t.column=Math.max(r.w||1,i?.w||1),delete t.columnOpts);let c=r.el.querySelector(".grid-stack-item-content"),d,p;if(s&&(this._removeDD(r.el),p=E(m({},r),{x:0,y:0}),h.removeInternalForSave(p),delete p.subGridOpts,r.content&&(p.content=r.content,delete r.content),l.addRemoveCB?d=l.addRemoveCB(this.el,p,!0,!1):(d=h.createDiv(["grid-stack-item"]),d.appendChild(c),c=h.createDiv(["grid-stack-item-content"],r.el)),this.prepareDragDrop(r.el)),i){let w=u?t.column:r.w,C=r.h+i.h,z=r.el.style;z.transition="none",this.update(r.el,{w,h:C}),setTimeout(()=>z.transition=null)}let g=r.subGrid=l.addGrid(c,t);return i?._moving&&(g._isTemp=!0),u&&(g._autoColumn=!0),s&&g.makeWidget(d,p),i&&(i._moving?window.setTimeout(()=>h.simulateMouseEvent(i._event,"mouseenter",g.el),0):g.makeWidget(r.el,r)),this.resizeToContentCheck(!1,r),g}removeAsSubGrid(e){let t=this.parentGridNode?.grid;t&&(t.batchUpdate(),t.removeWidget(this.parentGridNode.el,!0,!0),this.engine.nodes.forEach(i=>{i.x+=this.parentGridNode.x,i.y+=this.parentGridNode.y,t.makeWidget(i.el,i)}),t.batchUpdate(!1),this.parentGridNode&&delete this.parentGridNode.subGrid,delete this.parentGridNode,e&&window.setTimeout(()=>h.simulateMouseEvent(e._event,"mouseenter",t.el),0))}save(e=!0,t=!1,i=l.saveCB,s){let r=this.engine.save(e,i,s);if(r.forEach(n=>{if(e&&n.el&&!n.subGrid&&!i){let a=n.el.querySelector(".grid-stack-item-content");n.content=a?.innerHTML,n.content||delete n.content}else if(!e&&!i&&delete n.content,n.subGrid?.el){let a=n.w||n.subGrid.getColumn(),u=n.subGrid.save(e,t,i,a);n.subGridOpts=t?u:{children:u},delete n.subGrid}delete n.el}),t){let n=h.cloneDeep(this.opts);n.marginBottom===n.marginTop&&n.marginRight===n.marginLeft&&n.marginTop===n.marginRight&&(n.margin=n.marginTop,delete n.marginTop,delete n.marginRight,delete n.marginBottom,delete n.marginLeft),n.rtl===(this.el.style.direction==="rtl")&&(n.rtl="auto"),this._isAutoCellHeight&&(n.cellHeight="auto"),this._autoColumn&&(n.column="auto");let a=n._alwaysShowResizeHandle;return delete n._alwaysShowResizeHandle,a!==void 0?n.alwaysShowResizeHandle=a:delete n.alwaysShowResizeHandle,h.removeInternalAndSame(n,O),n.children=r,n}return r}load(e,t=l.addRemoveCB||!0){e=h.cloneDeep(e);let i=this.getColumn();e.forEach(d=>{d.w=d.w||d.minW||1,d.h=d.h||d.minH||1}),e=h.sort(e),this.engine.skipCacheUpdate=this._ignoreLayoutsNodeChange=!0;let s=0;e.forEach(d=>{s=Math.max(s,(d.x||0)+d.w)}),s>this.engine.defaultColumn&&(this.engine.defaultColumn=s),s>i&&(this.engine.nodes.length===0&&this.responseLayout?(this.engine.nodes=e,this.engine.columnChanged(s,i,this.responseLayout),e=this.engine.nodes,this.engine.nodes=[],delete this.responseLayout):this.engine.cacheLayout(e,s,!0));let r=l.addRemoveCB;typeof t=="function"&&(l.addRemoveCB=t);let n=[];this.batchUpdate();let a=!this.engine.nodes.length,u=a&&this.opts.animate;u&&this.setAnimation(!1),!a&&t&&[...this.engine.nodes].forEach(p=>{if(!p.id)return;h.find(e,p.id)||(l.addRemoveCB&&l.addRemoveCB(this.el,p,!1,!1),n.push(p),this.removeWidget(p.el,!0,!1))}),this.engine._loading=!0;let c=[];return this.engine.nodes=this.engine.nodes.filter(d=>h.find(e,d.id)?(c.push(d),!1):!0),e.forEach(d=>{let p=h.find(c,d.id);if(p){if(h.shouldSizeToContent(p)&&(d.h=p.h),this.engine.nodeBoundFix(d),(d.autoPosition||d.x===void 0||d.y===void 0)&&(d.w=d.w||p.w,d.h=d.h||p.h,this.engine.findEmptyPosition(d)),this.engine.nodes.push(p),h.samePos(p,d)&&this.engine.nodes.length>1&&(this.moveNode(p,E(m({},d),{forceCollide:!0})),h.copyPos(d,p)),this.update(p.el,d),d.subGridOpts?.children){let g=p.el.querySelector(".grid-stack");g&&g.gridstack&&g.gridstack.load(d.subGridOpts.children)}}else t&&this.addWidget(d)}),delete this.engine._loading,this.engine.removedNodes=n,this.batchUpdate(!1),delete this._ignoreLayoutsNodeChange,delete this.engine.skipCacheUpdate,r?l.addRemoveCB=r:delete l.addRemoveCB,u&&this.setAnimation(!0,!0),this}batchUpdate(e=!0){return this.engine.batchUpdate(e),e||(this._updateContainerHeight(),this._triggerRemoveEvent(),this._triggerAddEvent(),this._triggerChangeEvent()),this}getCellHeight(e=!1){if(this.opts.cellHeight&&this.opts.cellHeight!=="auto"&&(!e||!this.opts.cellHeightUnit||this.opts.cellHeightUnit==="px"))return this.opts.cellHeight;if(this.opts.cellHeightUnit==="rem")return this.opts.cellHeight*parseFloat(getComputedStyle(document.documentElement).fontSize);if(this.opts.cellHeightUnit==="em")return this.opts.cellHeight*parseFloat(getComputedStyle(this.el).fontSize);if(this.opts.cellHeightUnit==="cm")return this.opts.cellHeight*(96/2.54);if(this.opts.cellHeightUnit==="mm")return this.opts.cellHeight*(96/2.54)/10;let t=this.el.querySelector("."+this.opts.itemClass);if(t){let s=h.toNumber(t.getAttribute("gs-h"))||1;return Math.round(t.offsetHeight/s)}let i=parseInt(this.el.getAttribute("gs-current-row"));return i?Math.round(this.el.getBoundingClientRect().height/i):this.opts.cellHeight}cellHeight(e){if(e!==void 0&&this._isAutoCellHeight!==(e==="auto")&&(this._isAutoCellHeight=e==="auto",this._updateResizeEvent()),(e==="initial"||e==="auto")&&(e=void 0),e===void 0){let i=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;e=this.cellWidth()+i}let t=h.parseHeight(e);return this.opts.cellHeightUnit===t.unit&&this.opts.cellHeight===t.h?this:(this.opts.cellHeightUnit=t.unit,this.opts.cellHeight=t.h,this.el.style.setProperty("--gs-cell-height",`${this.opts.cellHeight}${this.opts.cellHeightUnit}`),this._updateContainerHeight(),this.resizeToContentCheck(),this)}cellWidth(){return this._widthOrContainer()/this.getColumn()}_widthOrContainer(e=!1){return e&&this.opts.columnOpts?.breakpointForWindow?window.innerWidth:this.el.clientWidth||this.el.parentElement.clientWidth||window.innerWidth}checkDynamicColumn(){let e=this.opts.columnOpts;if(!e||!e.columnWidth&&!e.breakpoints?.length)return!1;let t=this.getColumn(),i=t,s=this._widthOrContainer(!0);if(e.columnWidth)i=Math.min(Math.round(s/e.columnWidth)||1,e.columnMax);else{i=e.columnMax;let r=0;for(;r<e.breakpoints.length&&s<=e.breakpoints[r].w;)i=e.breakpoints[r++].c||t}if(i!==t){let r=e.breakpoints?.find(n=>n.c===i);return this.column(i,r?.layout||e.layout),!0}return!1}compact(e="compact",t=!0){return this.engine.compact(e,t),this._triggerChangeEvent(),this}column(e,t="moveScale"){if(!e||e<1||this.opts.column===e)return this;let i=this.getColumn();return this.opts.column=e,this.engine?(this.engine.column=e,this.el.classList.remove("gs-"+i),this._updateColumnVar(),this.engine.columnChanged(i,e,t),this._isAutoCellHeight&&this.cellHeight(),this.resizeToContentCheck(!0),this._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,this):(this.responseLayout=t,this)}getColumn(){return this.opts.column}getGridItems(){return Array.from(this.el.children).filter(e=>e.matches("."+this.opts.itemClass)&&!e.matches("."+this.opts.placeholderClass))}isIgnoreChangeCB(){return this._ignoreLayoutsNodeChange}destroy(e=!0){if(this.el)return this.offAll(),this._updateResizeEvent(!0),this.setStatic(!0,!1),this.setAnimation(!1),e?this.el.parentNode.removeChild(this.el):(this.removeAll(e),this.el.removeAttribute("gs-current-row")),this.parentGridNode&&delete this.parentGridNode.subGrid,delete this.parentGridNode,delete this.opts,delete this._placeholder?.gridstackNode,delete this._placeholder,delete this.engine,delete this.el.gridstack,delete this.el,this}float(e){return this.opts.float!==e&&(this.opts.float=this.engine.float=e,this._triggerChangeEvent()),this}getFloat(){return this.engine.float}getCellFromPixel(e,t=!1){let i=this.el.getBoundingClientRect(),s;t?s={top:i.top+document.documentElement.scrollTop,left:i.left}:s={top:this.el.offsetTop,left:this.el.offsetLeft};let r=e.left-s.left,n=e.top-s.top,a=i.width/this.getColumn(),u=i.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(r/a),y:Math.floor(n/u)}}getRow(){return Math.max(this.engine.getRow(),this.opts.minRow||0)}isAreaEmpty(e,t,i,s){return this.engine.isAreaEmpty(e,t,i,s)}makeWidget(e,t){let i=l.getElement(e);if(!i||i.gridstackNode)return i;i.parentElement||this.el.appendChild(i),this._prepareElement(i,!0,t);let s=i.gridstackNode;this._updateContainerHeight(),s.subGridOpts&&this.makeSubGrid(i,s.subGridOpts,void 0,!1);let r;return this.opts.column===1&&!this._ignoreLayoutsNodeChange&&(r=this._ignoreLayoutsNodeChange=!0),this._triggerAddEvent(),this._triggerChangeEvent(),r&&delete this._ignoreLayoutsNodeChange,i}on(e,t){return e.indexOf(" ")!==-1?(e.split(" ").forEach(s=>this.on(s,t)),this):(e==="change"||e==="added"||e==="removed"||e==="enable"||e==="disable"?(e==="enable"||e==="disable"?this._gsEventHandler[e]=s=>t(s):this._gsEventHandler[e]=s=>{s.detail&&t(s,s.detail)},this.el.addEventListener(e,this._gsEventHandler[e])):e==="drag"||e==="dragstart"||e==="dragstop"||e==="resizestart"||e==="resize"||e==="resizestop"||e==="dropped"||e==="resizecontent"?this._gsEventHandler[e]=t:console.error("GridStack.on("+e+") event not supported"),this)}off(e){return e.indexOf(" ")!==-1?(e.split(" ").forEach(i=>this.off(i)),this):((e==="change"||e==="added"||e==="removed"||e==="enable"||e==="disable")&&this._gsEventHandler[e]&&this.el.removeEventListener(e,this._gsEventHandler[e]),delete this._gsEventHandler[e],this)}offAll(){return Object.keys(this._gsEventHandler).forEach(e=>this.off(e)),this}removeWidget(e,t=!0,i=!0){return e?(l.getElements(e).forEach(s=>{if(s.parentElement&&s.parentElement!==this.el)return;let r=s.gridstackNode;r||(r=this.engine.nodes.find(n=>s===n.el)),r&&(t&&l.addRemoveCB&&l.addRemoveCB(this.el,r,!1,!1),delete s.gridstackNode,this._removeDD(s),this.engine.removeNode(r,t,i),t&&s.parentElement&&s.remove())}),i&&(this._triggerRemoveEvent(),this._triggerChangeEvent()),this):(console.error("Error: GridStack.removeWidget(undefined) called"),this)}removeAll(e=!0,t=!0){return this.engine.nodes.forEach(i=>{e&&l.addRemoveCB&&l.addRemoveCB(this.el,i,!1,!1),delete i.el.gridstackNode,this.opts.staticGrid||this._removeDD(i.el)}),this.engine.removeAll(e,t),t&&this._triggerRemoveEvent(),this}setAnimation(e=this.opts.animate,t){return t?setTimeout(()=>{this.opts&&this.setAnimation(e)}):e?this.el.classList.add("grid-stack-animate"):this.el.classList.remove("grid-stack-animate"),this.opts.animate=e,this}hasAnimationCSS(){return this.el.classList.contains("grid-stack-animate")}setStatic(e,t=!0,i=!0){return!!this.opts.staticGrid===e?this:(e?this.opts.staticGrid=!0:delete this.opts.staticGrid,this._setupRemoveDrop(),this._setupAcceptWidget(),this.engine.nodes.forEach(s=>{this.prepareDragDrop(s.el),s.subGrid&&i&&s.subGrid.setStatic(e,t,i)}),t&&this._setStaticClass(),this)}updateOptions(e){let t=this.opts;return e===t?this:(e.acceptWidgets!==void 0&&(t.acceptWidgets=e.acceptWidgets,this._setupAcceptWidget()),e.animate!==void 0&&this.setAnimation(e.animate),e.cellHeight&&this.cellHeight(e.cellHeight),e.class!==void 0&&e.class!==t.class&&(t.class&&this.el.classList.remove(t.class),e.class&&this.el.classList.add(e.class)),e.columnOpts?(this.opts.columnOpts=e.columnOpts,this.checkDynamicColumn()):e.columnOpts===null&&this.opts.columnOpts?(delete this.opts.columnOpts,this._updateResizeEvent()):typeof e.column=="number"&&this.column(e.column),e.margin!==void 0&&this.margin(e.margin),e.staticGrid!==void 0&&this.setStatic(e.staticGrid),e.disableDrag!==void 0&&!e.staticGrid&&this.enableMove(!e.disableDrag),e.disableResize!==void 0&&!e.staticGrid&&this.enableResize(!e.disableResize),e.float!==void 0&&this.float(e.float),e.row!==void 0?(t.minRow=t.maxRow=t.row=e.row,this._updateContainerHeight()):(e.minRow!==void 0&&(t.minRow=e.minRow,this._updateContainerHeight()),e.maxRow!==void 0&&(t.maxRow=e.maxRow)),e.lazyLoad!==void 0&&(t.lazyLoad=e.lazyLoad),e.children?.length&&this.load(e.children),this)}update(e,t){return l.getElements(e).forEach(i=>{let s=i?.gridstackNode;if(!s)return;let r=m(m({},h.copyPos({},s)),h.cloneDeep(t));this.engine.nodeBoundFix(r),delete r.autoPosition;let n=["x","y","w","h"],a;if(n.some(d=>r[d]!==void 0&&r[d]!==s[d])&&(a={},n.forEach(d=>{a[d]=r[d]!==void 0?r[d]:s[d],delete r[d]})),!a&&(r.minW||r.minH||r.maxW||r.maxH)&&(a={}),r.content!==void 0){let d=i.querySelector(".grid-stack-item-content");d&&d.textContent!==r.content&&(s.content=r.content,l.renderCB(d,r),s.subGrid?.el&&(d.appendChild(s.subGrid.el),s.subGrid._updateContainerHeight())),delete r.content}let u=!1,c=!1;for(let d in r)d[0]!=="_"&&s[d]!==r[d]&&(s[d]=r[d],u=!0,c=c||!this.opts.staticGrid&&(d==="noResize"||d==="noMove"||d==="locked"));if(h.sanitizeMinMax(s),a){let d=a.w!==void 0&&a.w!==s.w;this.moveNode(s,a),d&&s.subGrid?s.subGrid.onResize(this.hasAnimationCSS()?s.w:void 0):this.resizeToContentCheck(d,s),delete s._orig}(a||u)&&this._writeAttr(i,s),c&&this.prepareDragDrop(s.el),l.updateCB&&l.updateCB(s)}),this}moveNode(e,t){let i=e._updating;i||this.engine.cleanNodes().beginUpdate(e),this.engine.moveNode(e,t),this._updateContainerHeight(),i||(this._triggerChangeEvent(),this.engine.endUpdate())}resizeToContent(e){if(!e||(e.classList.remove("size-to-content-max"),!e.clientHeight))return;let t=e.gridstackNode;if(!t)return;let i=t.grid;if(!i||e.parentElement!==i.el)return;let s=i.getCellHeight(!0);if(!s)return;let r=t.h?t.h*s:e.clientHeight,n;if(t.resizeToContentParent&&(n=e.querySelector(t.resizeToContentParent)),n||(n=e.querySelector(l.resizeToContentParent)),!n)return;let a=e.clientHeight-n.clientHeight,u=t.h?t.h*s-a:n.clientHeight,c;if(t.subGrid){c=t.subGrid.getRow()*t.subGrid.getCellHeight(!0);let g=t.subGrid.el.getBoundingClientRect(),w=e.getBoundingClientRect();c+=g.top-w.top}else{if(t.subGridOpts?.children?.length)return;{let g=n.firstElementChild;if(!g){console.error(`Error: GridStack.resizeToContent() widget id:${t.id} '${l.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);return}c=g.getBoundingClientRect().height||u}}if(u===c)return;r+=c-u;let d=Math.ceil(r/s),p=Number.isInteger(t.sizeToContent)?t.sizeToContent:0;p&&d>p&&(d=p,e.classList.add("size-to-content-max")),t.minH&&d<t.minH?d=t.minH:t.maxH&&d>t.maxH&&(d=t.maxH),d!==t.h&&(i._ignoreLayoutsNodeChange=!0,i.moveNode(t,{h:d}),delete i._ignoreLayoutsNodeChange)}resizeToContentCBCheck(e){l.resizeToContentCB?l.resizeToContentCB(e):this.resizeToContent(e)}rotate(e,t){return l.getElements(e).forEach(i=>{let s=i.gridstackNode;if(!h.canBeRotated(s))return;let r={w:s.h,h:s.w,minH:s.minW,minW:s.minH,maxH:s.maxW,maxW:s.maxH};if(t){let a=t.left>0?Math.floor(t.left/this.cellWidth()):0,u=t.top>0?Math.floor(t.top/this.opts.cellHeight):0;r.x=s.x+a-(s.h-(u+1)),r.y=s.y+u-a}Object.keys(r).forEach(a=>{r[a]===void 0&&delete r[a]});let n=s._orig;this.update(i,r),s._orig=n}),this}margin(e){if(!(typeof e=="string"&&e.split(" ").length>1)){let i=h.parseHeight(e);if(this.opts.marginUnit===i.unit&&this.opts.margin===i.h)return}return this.opts.margin=e,this.opts.marginTop=this.opts.marginBottom=this.opts.marginLeft=this.opts.marginRight=void 0,this._initMargin(),this}getMargin(){return this.opts.margin}willItFit(e){return this.engine.willItFit(e)}_triggerChangeEvent(){if(this.engine.batchMode)return this;let e=this.engine.getDirtyNodes(!0);return e&&e.length&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(e),this._triggerEvent("change",e)),this.engine.saveInitial(),this}_triggerAddEvent(){if(this.engine.batchMode)return this;if(this.engine.addedNodes?.length){this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(this.engine.addedNodes),this.engine.addedNodes.forEach(t=>{delete t._dirty});let e=[...this.engine.addedNodes];this.engine.addedNodes=[],this._triggerEvent("added",e)}return this}_triggerRemoveEvent(){if(this.engine.batchMode)return this;if(this.engine.removedNodes?.length){let e=[...this.engine.removedNodes];this.engine.removedNodes=[],this._triggerEvent("removed",e)}return this}_triggerEvent(e,t){let i=t?new CustomEvent(e,{bubbles:!1,detail:t}):new Event(e),s=this;for(;s.parentGridNode;)s=s.parentGridNode.grid;return s.el.dispatchEvent(i),this}_updateContainerHeight(){if(!this.engine||this.engine.batchMode)return this;let e=this.parentGridNode,t=this.getRow()+this._extraDragRow,i=this.opts.cellHeight,s=this.opts.cellHeightUnit;if(!i)return this;if(!e&&!this.opts.minRow){let r=h.parseHeight(getComputedStyle(this.el).minHeight);if(r.h>0&&r.unit===s){let n=Math.floor(r.h/i);t<n&&(t=n)}}return this.el.setAttribute("gs-current-row",String(t)),this.el.style.removeProperty("min-height"),this.el.style.removeProperty("height"),t&&(this.el.style[e?"minHeight":"height"]=t*i+s),e&&h.shouldSizeToContent(e)&&e.grid.resizeToContentCBCheck(e.el),this}_prepareElement(e,t=!1,i){i=i||this._readAttr(e),e.gridstackNode=i,i.el=e,i.grid=this,i=this.engine.addNode(i,t),this._writeAttr(e,i),e.classList.add(O.itemClass,this.opts.itemClass);let s=h.shouldSizeToContent(i);return s?e.classList.add("size-to-content"):e.classList.remove("size-to-content"),s&&this.resizeToContentCheck(!1,i),h.lazyLoad(i)||this.prepareDragDrop(i.el),this}_writePosAttr(e,t){return(!t._moving&&!t._resizing||this._placeholder===e)&&(e.style.top=t.y?t.y===1?"var(--gs-cell-height)":`calc(${t.y} * var(--gs-cell-height))`:null,e.style.left=t.x?t.x===1?"var(--gs-column-width)":`calc(${t.x} * var(--gs-column-width))`:null,e.style.width=t.w>1?`calc(${t.w} * var(--gs-column-width))`:null,e.style.height=t.h>1?`calc(${t.h} * var(--gs-cell-height))`:null),e.setAttribute("gs-x",String(t.x)),e.setAttribute("gs-y",String(t.y)),t.w>1?e.setAttribute("gs-w",String(t.w)):e.removeAttribute("gs-w"),t.h>1?e.setAttribute("gs-h",String(t.h)):e.removeAttribute("gs-h"),this}_writeAttr(e,t){if(!t)return this;this._writePosAttr(e,t);let i={noResize:"gs-no-resize",noMove:"gs-no-move",locked:"gs-locked",id:"gs-id",sizeToContent:"gs-size-to-content"};for(let s in i)t[s]?e.setAttribute(i[s],String(t[s])):e.removeAttribute(i[s]);return this}_readAttr(e,t=!0){let i={};i.x=h.toNumber(e.getAttribute("gs-x")),i.y=h.toNumber(e.getAttribute("gs-y")),i.w=h.toNumber(e.getAttribute("gs-w")),i.h=h.toNumber(e.getAttribute("gs-h")),i.autoPosition=h.toBool(e.getAttribute("gs-auto-position")),i.noResize=h.toBool(e.getAttribute("gs-no-resize")),i.noMove=h.toBool(e.getAttribute("gs-no-move")),i.locked=h.toBool(e.getAttribute("gs-locked"));let s=e.getAttribute("gs-size-to-content");s&&(s==="true"||s==="false"?i.sizeToContent=h.toBool(s):i.sizeToContent=parseInt(s,10)),i.id=e.getAttribute("gs-id"),i.maxW=h.toNumber(e.getAttribute("gs-max-w")),i.minW=h.toNumber(e.getAttribute("gs-min-w")),i.maxH=h.toNumber(e.getAttribute("gs-max-h")),i.minH=h.toNumber(e.getAttribute("gs-min-h")),t&&(i.w===1&&e.removeAttribute("gs-w"),i.h===1&&e.removeAttribute("gs-h"),i.maxW&&e.removeAttribute("gs-max-w"),i.minW&&e.removeAttribute("gs-min-w"),i.maxH&&e.removeAttribute("gs-max-h"),i.minH&&e.removeAttribute("gs-min-h"));for(let r in i){if(!i.hasOwnProperty(r))return;!i[r]&&i[r]!==0&&r!=="sizeToContent"&&delete i[r]}return i}_setStaticClass(){let e=["grid-stack-static"];return this.opts.staticGrid?(this.el.classList.add(...e),this.el.setAttribute("gs-static","true")):(this.el.classList.remove(...e),this.el.removeAttribute("gs-static")),this}onResize(e=this.el?.clientWidth){if(!e||this.prevWidth===e)return;this.prevWidth=e,this.batchUpdate();let t=!1;return this._autoColumn&&this.parentGridNode?this.opts.column!==this.parentGridNode.w&&(this.column(this.parentGridNode.w,this.opts.layout||"list"),t=!0):t=this.checkDynamicColumn(),this._isAutoCellHeight&&this.cellHeight(),this.engine.nodes.forEach(i=>{i.subGrid&&i.subGrid.onResize()}),this._skipInitialResize||this.resizeToContentCheck(t),delete this._skipInitialResize,this.batchUpdate(!1),this}resizeToContentCheck(e=!1,t=void 0){if(this.engine){if(e&&this.hasAnimationCSS())return setTimeout(()=>this.resizeToContentCheck(!1,t),this.animationDelay);if(t)h.shouldSizeToContent(t)&&this.resizeToContentCBCheck(t.el);else if(this.engine.nodes.some(i=>h.shouldSizeToContent(i))){let i=[...this.engine.nodes];this.batchUpdate(),i.forEach(s=>{h.shouldSizeToContent(s)&&this.resizeToContentCBCheck(s.el)}),this._ignoreLayoutsNodeChange=!0,this.batchUpdate(!1),this._ignoreLayoutsNodeChange=!1}this._gsEventHandler.resizecontent&&this._gsEventHandler.resizecontent(null,t?[t]:this.engine.nodes)}}_updateResizeEvent(e=!1){let t=!this.parentGridNode&&(this._isAutoCellHeight||this.opts.sizeToContent||this.opts.columnOpts||this.engine.nodes.find(i=>i.sizeToContent));return!e&&t&&!this.resizeObserver?(this._sizeThrottle=h.throttle(()=>this.onResize(),this.opts.cellHeightThrottle),this.resizeObserver=new ResizeObserver(()=>this._sizeThrottle()),this.resizeObserver.observe(this.el),this._skipInitialResize=!0):(e||!t)&&this.resizeObserver&&(this.resizeObserver.disconnect(),delete this.resizeObserver,delete this._sizeThrottle),this}static getElement(e=".grid-stack-item"){return h.getElement(e)}static getElements(e=".grid-stack-item"){return h.getElements(e)}static getGridElement(e){return l.getElement(e)}static getGridElements(e){return h.getElements(e)}_initMargin(){let e,t=0,i=[];typeof this.opts.margin=="string"&&(i=this.opts.margin.split(" ")),i.length===2?(this.opts.marginTop=this.opts.marginBottom=i[0],this.opts.marginLeft=this.opts.marginRight=i[1]):i.length===4?(this.opts.marginTop=i[0],this.opts.marginRight=i[1],this.opts.marginBottom=i[2],this.opts.marginLeft=i[3]):(e=h.parseHeight(this.opts.margin),this.opts.marginUnit=e.unit,t=this.opts.margin=e.h),["marginTop","marginRight","marginBottom","marginLeft"].forEach(n=>{this.opts[n]===void 0?this.opts[n]=t:(e=h.parseHeight(this.opts[n]),this.opts[n]=e.h,delete this.opts.margin)}),this.opts.marginUnit=e.unit,this.opts.marginTop===this.opts.marginBottom&&this.opts.marginLeft===this.opts.marginRight&&this.opts.marginTop===this.opts.marginRight&&(this.opts.margin=this.opts.marginTop);let r=this.el.style;return r.setProperty("--gs-item-margin-top",`${this.opts.marginTop}${this.opts.marginUnit}`),r.setProperty("--gs-item-margin-bottom",`${this.opts.marginBottom}${this.opts.marginUnit}`),r.setProperty("--gs-item-margin-right",`${this.opts.marginRight}${this.opts.marginUnit}`),r.setProperty("--gs-item-margin-left",`${this.opts.marginLeft}${this.opts.marginUnit}`),this}static getDD(){return R}static setupDragIn(e,t,i,s=document){t?.pause!==void 0&&(f.pauseDrag=t.pause),t=m({appendTo:"body",helper:"clone"},t||{}),(typeof e=="string"?h.getElements(e,s):e).forEach((n,a)=>{R.isDraggable(n)||R.dragIn(n,t),i?.[a]&&(n.gridstackNode=i[a])})}movable(e,t){return this.opts.staticGrid?this:(l.getElements(e).forEach(i=>{let s=i.gridstackNode;s&&(t?delete s.noMove:s.noMove=!0,this.prepareDragDrop(s.el))}),this)}resizable(e,t){return this.opts.staticGrid?this:(l.getElements(e).forEach(i=>{let s=i.gridstackNode;s&&(t?delete s.noResize:s.noResize=!0,this.prepareDragDrop(s.el))}),this)}disable(e=!0){if(!this.opts.staticGrid)return this.enableMove(!1,e),this.enableResize(!1,e),this._triggerEvent("disable"),this}enable(e=!0){if(!this.opts.staticGrid)return this.enableMove(!0,e),this.enableResize(!0,e),this._triggerEvent("enable"),this}enableMove(e,t=!0){return this.opts.staticGrid?this:(e?delete this.opts.disableDrag:this.opts.disableDrag=!0,this.engine.nodes.forEach(i=>{this.prepareDragDrop(i.el),i.subGrid&&t&&i.subGrid.enableMove(e,t)}),this)}enableResize(e,t=!0){return this.opts.staticGrid?this:(e?delete this.opts.disableResize:this.opts.disableResize=!0,this.engine.nodes.forEach(i=>{this.prepareDragDrop(i.el),i.subGrid&&t&&i.subGrid.enableResize(e,t)}),this)}cancelDrag(){let e=this._placeholder?.gridstackNode;e&&(e._isExternal?(e._isAboutToRemove=!0,this.engine.removeNode(e)):e._isAboutToRemove&&l._itemRemoving(e.el,!1),this.engine.restoreInitial())}_removeDD(e){return R.draggable(e,"destroy").resizable(e,"destroy"),e.gridstackNode&&delete e.gridstackNode._initDD,delete e.ddElement,this}_setupAcceptWidget(){if(this.opts.staticGrid||!this.opts.acceptWidgets&&!this.opts.removable)return R.droppable(this.el,"destroy"),this;let e,t,i=(s,r,n)=>{n=n||r;let a=n.gridstackNode;if(!a)return;if(!a.grid?.el){n.style.transform=`scale(${1/this.dragTransform.xScale},${1/this.dragTransform.yScale})`;let g=n.getBoundingClientRect();n.style.left=g.x+(this.dragTransform.xScale-1)*(s.clientX-g.x)/this.dragTransform.xScale+"px",n.style.top=g.y+(this.dragTransform.yScale-1)*(s.clientY-g.y)/this.dragTransform.yScale+"px",n.style.transformOrigin="0px 0px"}let{top:u,left:c}=n.getBoundingClientRect(),d=this.el.getBoundingClientRect();c-=d.left,u-=d.top;let p={position:{top:u*this.dragTransform.xScale,left:c*this.dragTransform.yScale}};if(a._temporaryRemoved){if(a.x=Math.max(0,Math.round(c/t)),a.y=Math.max(0,Math.round(u/e)),delete a.autoPosition,this.engine.nodeBoundFix(a),!this.engine.willItFit(a)){if(a.autoPosition=!0,!this.engine.willItFit(a)){R.off(r,"drag");return}a._willFitPos&&(h.copyPos(a,a._willFitPos),delete a._willFitPos)}this._onStartMoving(n,s,p,a,t,e)}else this._dragOrResize(n,s,p,a,t,e)};return R.droppable(this.el,{accept:s=>{let r=s.gridstackNode||this._readAttr(s,!1);if(r?.grid===this)return!0;if(!this.opts.acceptWidgets)return!1;let n=!0;if(typeof this.opts.acceptWidgets=="function")n=this.opts.acceptWidgets(s);else{let a=this.opts.acceptWidgets===!0?".grid-stack-item":this.opts.acceptWidgets;n=s.matches(a)}if(n&&r&&this.opts.maxRow){let a={w:r.w,h:r.h,minW:r.minW,minH:r.minH};n=this.engine.willItFit(a)}return n}}).on(this.el,"dropover",(s,r,n)=>{let a=n?.gridstackNode||r.gridstackNode;if(a?.grid===this&&!a._temporaryRemoved)return!1;if(a?._sidebarOrig&&(a.w=a._sidebarOrig.w,a.h=a._sidebarOrig.h),a?.grid&&a.grid!==this&&!a._temporaryRemoved&&a.grid._leave(r,n),n=n||r,t=this.cellWidth(),e=this.getCellHeight(!0),!a){let d=n.getAttribute("data-gs-widget")||n.getAttribute("gridstacknode");if(d){try{a=JSON.parse(d)}catch(p){console.error("Gridstack dropover: Bad JSON format: ",d)}n.removeAttribute("data-gs-widget"),n.removeAttribute("gridstacknode")}a||(a=this._readAttr(n)),a._sidebarOrig={w:a.w,h:a.h}}a.grid||(a.el||(a=m({},a)),a._isExternal=!0,n.gridstackNode=a);let u=a.w||Math.round(n.offsetWidth/t)||1,c=a.h||Math.round(n.offsetHeight/e)||1;return a.grid&&a.grid!==this?(r._gridstackNodeOrig||(r._gridstackNodeOrig=a),r.gridstackNode=a=E(m({},a),{w:u,h:c,grid:this}),delete a.x,delete a.y,this.engine.cleanupNode(a).nodeBoundFix(a),a._initDD=a._isExternal=a._temporaryRemoved=!0):(a.w=u,a.h=c,a._temporaryRemoved=!0),l._itemRemoving(a.el,!1),R.on(r,"drag",i),i(s,r,n),!1}).on(this.el,"dropout",(s,r,n)=>{let a=n?.gridstackNode||r.gridstackNode;return a&&(!a.grid||a.grid===this)&&(this._leave(r,n),this._isTemp&&this.removeAsSubGrid(a)),!1}).on(this.el,"drop",(s,r,n)=>{let a=n?.gridstackNode||r.gridstackNode;if(a?.grid===this&&!a._isExternal)return!1;let u=!!this.placeholder.parentElement,c=r!==n;this.placeholder.remove(),delete this.placeholder.gridstackNode,u&&this.opts.animate&&(this.setAnimation(!1),this.setAnimation(!0,!0));let d=r._gridstackNodeOrig;if(delete r._gridstackNodeOrig,u&&d?.grid&&d.grid!==this){let g=d.grid;g.engine.removeNodeFromLayoutCache(d),g.engine.removedNodes.push(d),g._triggerRemoveEvent()._triggerChangeEvent(),g.parentGridNode&&!g.engine.nodes.length&&g.opts.subGridDynamic&&g.removeAsSubGrid()}if(!a||(u&&(this.engine.cleanupNode(a),a.grid=this),delete a.grid?._isTemp,R.off(r,"drag"),n!==r?(n.remove(),r=n):r.remove(),this._removeDD(r),!u))return!1;let p=a.subGrid?.el?.gridstack;return h.copyPos(a,this._readAttr(this.placeholder)),h.removePositioningStyles(r),c&&(a.content||a.subGridOpts||l.addRemoveCB)?(delete a.el,r=this.addWidget(a)):(this._prepareElement(r,!0,a),this.el.appendChild(r),this.resizeToContentCheck(!1,a),p&&(p.parentGridNode=a),this._updateContainerHeight()),this.engine.addedNodes.push(a),this._triggerAddEvent(),this._triggerChangeEvent(),this.engine.endUpdate(),this._gsEventHandler.dropped&&this._gsEventHandler.dropped(E(m({},s),{type:"dropped"}),d&&d.grid?d:void 0,a),!1}),this}static _itemRemoving(e,t){if(!e)return;let i=e?e.gridstackNode:void 0;!i?.grid||e.classList.contains(i.grid.opts.removableOptions.decline)||(t?i._isAboutToRemove=!0:delete i._isAboutToRemove,t?e.classList.add("grid-stack-item-removing"):e.classList.remove("grid-stack-item-removing"))}_setupRemoveDrop(){if(typeof this.opts.removable!="string")return this;let e=document.querySelector(this.opts.removable);return e?(!this.opts.staticGrid&&!R.isDroppable(e)&&R.droppable(e,this.opts.removableOptions).on(e,"dropover",(t,i)=>l._itemRemoving(i,!0)).on(e,"dropout",(t,i)=>l._itemRemoving(i,!1)),this):this}prepareDragDrop(e,t=!1){let i=e?.gridstackNode;if(!i)return;let s=i.noMove||this.opts.disableDrag,r=i.noResize||this.opts.disableResize,n=this.opts.staticGrid||s&&r;if((t||n)&&(i._initDD&&(this._removeDD(e),delete i._initDD),n&&e.classList.add("ui-draggable-disabled","ui-resizable-disabled"),!t))return this;if(!i._initDD){let a,u,c=(g,w)=>{this.triggerEvent(g,g.target),a=this.cellWidth(),u=this.getCellHeight(!0),this._onStartMoving(e,g,w,i,a,u)},d=(g,w)=>{this._dragOrResize(e,g,w,i,a,u)},p=g=>{this.placeholder.remove(),delete this.placeholder.gridstackNode,delete i._moving,delete i._resizing,delete i._event,delete i._lastTried;let w=i.w!==i._orig.w,C=g.target;if(!(!C.gridstackNode||C.gridstackNode.grid!==this)){if(i.el=C,i._isAboutToRemove){let z=e.gridstackNode.grid;z._gsEventHandler[g.type]&&z._gsEventHandler[g.type](g,C),z.engine.nodes.push(i),z.removeWidget(e,!0,!0)}else h.removePositioningStyles(C),i._temporaryRemoved?(this._writePosAttr(C,i),this.engine.addNode(i)):this._writePosAttr(C,i),this.triggerEvent(g,C);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate(),g.type==="resizestop"&&(Number.isInteger(i.sizeToContent)&&(i.sizeToContent=i.h),this.resizeToContentCheck(w,i))}};R.draggable(e,{start:c,stop:p,drag:d}).resizable(e,{start:c,stop:p,resize:d}),i._initDD=!0}return R.draggable(e,s?"disable":"enable").resizable(e,r?"disable":"enable"),this}_onStartMoving(e,t,i,s,r,n){if(this.engine.cleanNodes().beginUpdate(s),this._writePosAttr(this.placeholder,s),this.el.appendChild(this.placeholder),this.placeholder.gridstackNode=s,s.grid?.el)this.dragTransform=h.getValuesFromTransformedElement(e);else if(this.placeholder&&this.placeholder.closest(".grid-stack")){let a=this.placeholder.closest(".grid-stack");this.dragTransform=h.getValuesFromTransformedElement(a)}else this.dragTransform={xScale:1,xOffset:0,yScale:1,yOffset:0};if(s.el=this.placeholder,s._lastUiPosition=i.position,s._prevYPix=i.position.top,s._moving=t.type==="dragstart",s._resizing=t.type==="resizestart",delete s._lastTried,t.type==="dropover"&&s._temporaryRemoved&&(this.engine.addNode(s),s._moving=!0),this.engine.cacheRects(r,n,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),t.type==="resizestart"){let a=this.getColumn()-s.x,u=(this.opts.maxRow||Number.MAX_SAFE_INTEGER)-s.y;R.resizable(e,"option","minWidth",r*Math.min(s.minW||1,a)).resizable(e,"option","minHeight",n*Math.min(s.minH||1,u)).resizable(e,"option","maxWidth",r*Math.min(s.maxW||Number.MAX_SAFE_INTEGER,a)).resizable(e,"option","maxWidthMoveLeft",r*Math.min(s.maxW||Number.MAX_SAFE_INTEGER,s.x+s.w)).resizable(e,"option","maxHeight",n*Math.min(s.maxH||Number.MAX_SAFE_INTEGER,u)).resizable(e,"option","maxHeightMoveUp",n*Math.min(s.maxH||Number.MAX_SAFE_INTEGER,s.y+s.h))}}_dragOrResize(e,t,i,s,r,n){let a=m({},s._orig),u,c=this.opts.marginLeft,d=this.opts.marginRight,p=this.opts.marginTop,g=this.opts.marginBottom,w=Math.round(n*.1),C=Math.round(r*.1);if(c=Math.min(c,C),d=Math.min(d,C),p=Math.min(p,w),g=Math.min(g,w),t.type==="drag"){if(s._temporaryRemoved)return;let Y=i.position.top-s._prevYPix;s._prevYPix=i.position.top,this.opts.draggable.scroll!==!1&&h.updateScrollPosition(e,i.position,Y);let Ke=i.position.left+(i.position.left>s._lastUiPosition.left?-d:c),ti=i.position.top+(i.position.top>s._lastUiPosition.top?-g:p);a.x=Math.round(Ke/r),a.y=Math.round(ti/n);let ii=this._extraDragRow;if(this.engine.collide(s,a)){let je=this.getRow(),Ve=Math.max(0,a.y+s.h-je);this.opts.maxRow&&je+Ve>this.opts.maxRow&&(Ve=Math.max(0,this.opts.maxRow-je)),this._extraDragRow=Ve}else this._extraDragRow=0;if(this._extraDragRow!==ii&&this._updateContainerHeight(),s.x===a.x&&s.y===a.y)return}else if(t.type==="resize"){if(a.x<0||(h.updateScrollResize(t,e,n),a.w=Math.round((i.size.width-c)/r),a.h=Math.round((i.size.height-p)/n),s.w===a.w&&s.h===a.h)||s._lastTried&&s._lastTried.w===a.w&&s._lastTried.h===a.h)return;let Y=i.position.left+c,Ke=i.position.top+p;a.x=Math.round(Y/r),a.y=Math.round(Ke/n),u=!0}s._event=t,s._lastTried=a;let z={x:i.position.left+c,y:i.position.top+p,w:(i.size?i.size.width:s.w*r)-c-d,h:(i.size?i.size.height:s.h*n)-p-g};if(this.engine.moveNodeCheck(s,E(m({},a),{cellWidth:r,cellHeight:n,rect:z,resizing:u}))){s._lastUiPosition=i.position,this.engine.cacheRects(r,n,p,d,g,c),delete s._skipDown,u&&s.subGrid&&s.subGrid.onResize(),this._extraDragRow=0,this._updateContainerHeight();let Y=t.target;s._sidebarOrig||this._writePosAttr(Y,s),this.triggerEvent(t,Y)}}triggerEvent(e,t){let i=this;for(;i.parentGridNode;)i=i.parentGridNode.grid;i._gsEventHandler[e.type]&&i._gsEventHandler[e.type](e,t)}_leave(e,t){t=t||e;let i=t.gridstackNode;if(!i||(t.style.transform=t.style.transformOrigin=null,R.off(e,"drag"),i._temporaryRemoved))return;i._temporaryRemoved=!0,this.engine.removeNode(i),i.el=i._isExternal&&t?t:e;let s=i._sidebarOrig;i._isExternal&&this.engine.cleanupNode(i),i._sidebarOrig=s,this.opts.removable===!0&&l._itemRemoving(e,!0),e._gridstackNodeOrig?(e.gridstackNode=e._gridstackNodeOrig,delete e._gridstackNodeOrig):i._isExternal&&this.engine.restoreInitial()}}return l.renderCB=(o,e)=>{o&&e?.content&&(o.textContent=e.content)},l.resizeToContentParent=".grid-stack-item-content",l.Utils=h,l.Engine=tt,l.GDRev="12.4.2",l})();var $t=["container"],ri=["*"];function oi(l,o){}var ni=["*",[["","empty-content",""]]],ai=["*","[empty-content]"];function li(l,o){l&1&&Ee(0,1,["*ngIf","isEmpty"])}function di(l,o){}var Ue=(()=>{class l{serialize(){}deserialize(e){this.widgetItem=e,e&&e.input&&Object.assign(this,e.input)}}return l.\u0275fac=function(e){return new(e||l)},l.\u0275prov=X({token:l,factory:l.\u0275fac}),l})(),qt=(()=>{class l{constructor(e){this.elementRef=e,this.el._gridItemComp=this}set options(e){let t=this.el.gridstackNode?.grid;t?t.update(this.el,e):this._options=E(m({},e),{el:this.el})}get options(){return this.el.gridstackNode||this._options||{el:this.el}}get el(){return this.elementRef.nativeElement}clearOptions(){delete this._options}ngOnDestroy(){this.clearOptions(),delete this.childWidget,delete this.el._gridItemComp,delete this.container,delete this.ref}}return l.\u0275fac=function(e){return new(e||l)(Xe(ce))},l.\u0275cmp=k({type:l,selectors:[["gridstack-item"]],viewQuery:function(e,t){if(e&1&&ge($t,7,ue),e&2){let i;Z(i=ee())&&(t.container=i.first)}},inputs:{options:"options"},ngContentSelectors:ri,decls:5,vars:1,consts:[["container",""],[1,"grid-stack-item-content"]],template:function(e,t){e&1&&(Je(),J(0,"div",1),lt(1,oi,0,0,"ng-template",null,0,et),Ee(3),v(4),pe()),e&2&&(M(4),yt(" ",t.options.content," "))},styles:["[_nghost-%COMP%]{display:block}"]}),l})(),ye=(()=>{class l{constructor(e){this.elementRef=e,this.addedCB=new P,this.changeCB=new P,this.disableCB=new P,this.dragCB=new P,this.dragStartCB=new P,this.dragStopCB=new P,this.droppedCB=new P,this.enableCB=new P,this.removedCB=new P,this.resizeCB=new P,this.resizeStartCB=new P,this.resizeStopCB=new P,j.addRemoveCB||(j.addRemoveCB=hi),j.saveCB||(j.saveCB=ci),j.updateCB||(j.updateCB=ui),this.el._gridComp=this}set options(e){this._grid?this._grid.updateOptions(e):this._options=e}get options(){return this._grid?.opts||this._options||{}}get el(){return this.elementRef.nativeElement}get grid(){return this._grid}static addComponentToSelectorType(e){e.forEach(t=>l.selectorToType[l.getSelector(t)]=t)}static getSelector(e){return Ct(e).selector}ngOnInit(){this.loaded=!!this.options?.children?.length,this._grid=j.init(this._options,this.el),delete this._options,this.checkEmpty()}ngAfterContentInit(){this._sub=this.gridstackItems?.changes.subscribe(()=>this.updateAll()),this.loaded||this.updateAll(),this.hookEvents(this.grid)}ngOnDestroy(){this.unhookEvents(this._grid),this._sub?.unsubscribe(),this._grid?.destroy(),delete this._grid,delete this.el._gridComp,delete this.container,delete this.ref}updateAll(){if(!this.grid)return;let e=[];this.gridstackItems?.forEach(t=>{e.push(t.options),t.clearOptions()}),this.grid.load(e)}checkEmpty(){this.grid&&(this.isEmpty=!this.grid.engine.nodes.length)}hookEvents(e){e&&(e.parentGridNode||e.on("added",(t,i)=>{(i[0].grid?.el._gridComp||this).checkEmpty(),this.addedCB.emit({event:t,nodes:i})}).on("change",(t,i)=>this.changeCB.emit({event:t,nodes:i})).on("disable",t=>this.disableCB.emit({event:t})).on("drag",(t,i)=>this.dragCB.emit({event:t,el:i})).on("dragstart",(t,i)=>this.dragStartCB.emit({event:t,el:i})).on("dragstop",(t,i)=>this.dragStopCB.emit({event:t,el:i})).on("dropped",(t,i,s)=>this.droppedCB.emit({event:t,previousNode:i,newNode:s})).on("enable",t=>this.enableCB.emit({event:t})).on("removed",(t,i)=>{(i[0].grid?.el._gridComp||this).checkEmpty(),this.removedCB.emit({event:t,nodes:i})}).on("resize",(t,i)=>this.resizeCB.emit({event:t,el:i})).on("resizestart",(t,i)=>this.resizeStartCB.emit({event:t,el:i})).on("resizestop",(t,i)=>this.resizeStopCB.emit({event:t,el:i})))}unhookEvents(e){e&&(e.parentGridNode||e.off("added change disable drag dragstart dragstop dropped enable removed resize resizestart resizestop"))}}return l.selectorToType={},l.\u0275fac=function(e){return new(e||l)(Xe(ce))},l.\u0275cmp=k({type:l,selectors:[["gridstack"]],contentQueries:function(e,t,i){if(e&1&&pt(i,qt,4),e&2){let s;Z(s=ee())&&(t.gridstackItems=s)}},viewQuery:function(e,t){if(e&1&&ge($t,7,ue),e&2){let i;Z(i=ee())&&(t.container=i.first)}},inputs:{options:"options",isEmpty:"isEmpty"},outputs:{addedCB:"addedCB",changeCB:"changeCB",disableCB:"disableCB",dragCB:"dragCB",dragStartCB:"dragStartCB",dragStopCB:"dragStopCB",droppedCB:"droppedCB",enableCB:"enableCB",removedCB:"removedCB",resizeCB:"resizeCB",resizeStartCB:"resizeStartCB",resizeStopCB:"resizeStopCB"},ngContentSelectors:ai,decls:4,vars:1,consts:[["container",""],[4,"ngIf"]],template:function(e,t){e&1&&(Je(ni),at(0,li,1,0,"ng-content",1)(1,di,0,0,"ng-template",null,0,et),Ee(3)),e&2&&B("ngIf",t.isEmpty)},dependencies:[xt],styles:["[_nghost-%COMP%]{display:block}"]}),l})();function hi(l,o,e,t){if(e){if(!l)return;if(t){let i=l.parentElement?._gridItemComp;if(!i)return;let r=(i.childWidget?.container||i.container)?.createComponent(ye),n=r?.instance;return n?(n.ref=r,n.options=o,n.el):void 0}else{let s=l._gridComp?.container?.createComponent(qt),r=s?.instance;if(!r)return;r.ref=s;let n=o.selector,a=n?ye.selectorToType[n]:void 0;if(a){let u=()=>{let d=r.container?.createComponent(a)?.instance;d&&typeof d.serialize=="function"&&typeof d.deserialize=="function"&&(r.childWidget=d,d.deserialize(o))};o.lazyLoad||o.grid?.opts?.lazyLoad&&o.lazyLoad!==!1?o.visibleObservable||(o.visibleObservable=new IntersectionObserver(([d])=>{d.isIntersecting&&(o.visibleObservable?.disconnect(),delete o.visibleObservable,u())}),window.setTimeout(()=>o.visibleObservable?.observe(r.el))):u()}return r.el}}else if(t){let i=o.el?._gridComp;i?.ref?i.ref.destroy():i?.ngOnDestroy()}else{let i=o.el?._gridItemComp;i?.ref?i.ref.destroy():i?.ngOnDestroy()}}function ci(l,o){let e=l.el?._gridItemComp;if(e){let i=e.childWidget?.serialize();i&&(o.input=i);return}let t=l.el?._gridComp}function ui(l){let o=l,e=l.el?._gridItemComp;e?.childWidget&&o.input&&e.childWidget.deserialize(o)}var pi=(l,o)=>o.id;function gi(l,o){if(l&1&&ct(0,"div",4),l&2){let e=o.$index;H(2);let t=Se(0);De("background-color",t===e?"var(--mat-sys-on-surface)":"var(--mat-sys-inverse-on-surface)")}}function fi(l,o){if(l&1&&(J(0,"div",0),Qe("fade-toast"),J(1,"span",1),v(2),pe()(),J(3,"div",2),Qe("fade-toast"),dt(4,gi,1,2,"div",3,pi),pe()),l&2){H();let e=Se(0),t=Se(1);M(2),mt(t[e].name),M(2),ht(t)}}var Kt=(()=>{class l{activePage=U();dashboards=U();visible=_e(!1);constructor(){W(()=>{let e=this.activePage();if(e==null){this.visible.set(!1);return}this.visible.set(!1),queueMicrotask(()=>this.visible.set(!0))})}static \u0275fac=function(t){return new(t||l)};static \u0275cmp=k({type:l,selectors:[["dashboard-scroller"]],inputs:{activePage:[1,"activePage"],dashboards:[1,"dashboards"]},decls:3,vars:3,consts:[[1,"page-scroll-title","page-scroll-container"],[1,"page-label"],[1,"page-scroll-page-number","page-scroll-container","fade-toast"],[1,"page-marker",3,"background-color"],[1,"page-marker"]],template:function(t,i){t&1&&(bt(0)(1),L(2,fi,6,1)),t&2&&(Ze(i.activePage()),M(),Ze(i.dashboards()),M(),I(i.visible()?2:-1))},styles:["[_nghost-%COMP%]{pointer-events:none}.page-scroll-title[_ngcontent-%COMP%]{position:absolute;top:50%;right:54px;transform:translateY(-50%);z-index:100;cursor:default;text-align:center;padding:10px;color:var(--mat-sys-inverse-surface)}.page-scroll-page-number[_ngcontent-%COMP%]{position:absolute;top:50%;right:15px;transform:translateY(-50%);z-index:100;cursor:default;display:grid;padding:0}.page-scroll-container[_ngcontent-%COMP%]{opacity:0;background-color:var(--mat-sys-tertiary-fixed-dim);border-radius:10px;border:1px solid var(--mat-sys-inverse-surface)}.page-label[_ngcontent-%COMP%]{color:var(--mat-sys-on-surface);text-shadow:1px 1px 0 var(--mat-sys-outline),-1px 1px 0 var(--mat-sys-outline),-1px -1px 0 var(--mat-sys-outline),1px -1px 0 var(--mat-sys-outline);font-size:x-large}.page-marker[_ngcontent-%COMP%]{height:20px;width:20px;margin:4px;border-radius:50%;border:1px solid var(--mat-sys-outline)}@keyframes _ngcontent-%COMP%_fadeInHoldFadeOut{0%{opacity:0}7.407%{opacity:1}25.926%{opacity:1}to{opacity:0}}.fade-toast[_ngcontent-%COMP%]{opacity:0;animation:_ngcontent-%COMP%_fadeInHoldFadeOut 1.35s linear forwards}"]})}return l})();var jt=(()=>{class l{twoFingerTapEnabled=U(!0);twoFingerTapMaxDurationMs=U(450);twoFingerTapMoveThresholdPx=U(24);twoFingerTapPreventDefault=U(!0);twoFingerTap=vt();pointers=new Map;candidate=!1;moved=!1;startedAtMs=0;blocked=!1;onPointerDown(e){if(!(!this.twoFingerTapEnabled()||e.pointerType!=="touch")){if(this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.pointers.size===2&&!this.blocked){this.candidate=!0,this.moved=!1,this.startedAtMs=Date.now();return}this.pointers.size>2&&(this.blocked=!0,this.resetTracking(!1))}}onPointerMove(e){if(!this.candidate||e.pointerType!=="touch")return;let t=this.pointers.get(e.pointerId);if(!t)return;let i=e.clientX-t.x,s=e.clientY-t.y;Math.hypot(i,s)>this.twoFingerTapMoveThresholdPx()&&(this.moved=!0)}onPointerUp(e){if(e.pointerType!=="touch")return;if(this.pointers.delete(e.pointerId),this.blocked){this.pointers.size===0&&(this.blocked=!1);return}if(!this.candidate||this.pointers.size>0)return;let t=Date.now()-this.startedAtMs,i=!this.moved&&t<=this.twoFingerTapMaxDurationMs();this.resetTracking(!1),i&&(this.twoFingerTapPreventDefault()&&(e.preventDefault(),e.stopPropagation()),this.twoFingerTap.emit(e))}onPointerCancel(e){e.pointerType==="touch"&&(this.pointers.delete(e.pointerId),this.pointers.size===0&&this.resetTracking(!0))}resetTracking(e){this.pointers.clear(),this.candidate=!1,this.moved=!1,this.startedAtMs=0,e||(this.blocked=!1)}static \u0275fac=function(t){return new(t||l)};static \u0275dir=nt({type:l,selectors:[["","twoFingerTap",""]],hostBindings:function(t,i){t&1&&x("pointerdown",function(r){return i.onPointerDown(r)})("pointermove",function(r){return i.onPointerMove(r)})("pointerup",function(r){return i.onPointerUp(r)})("pointercancel",function(r){return i.onPointerCancel(r)})},inputs:{twoFingerTapEnabled:[1,"twoFingerTapEnabled"],twoFingerTapMaxDurationMs:[1,"twoFingerTapMaxDurationMs"],twoFingerTapMoveThresholdPx:[1,"twoFingerTapMoveThresholdPx"],twoFingerTapPreventDefault:[1,"twoFingerTapPreventDefault"]},outputs:{twoFingerTap:"twoFingerTap"}})}return l})();function yi(l,o){if(l&1){let e=V();b(0,"button",0),x("click",function(){N(e);let i=H();return A(i.clickAction("cancel"))}),b(1,"mat-icon",1),v(2,"close"),_(),b(3,"span"),v(4,"Close"),_()()}}var $e=(()=>{class l{_bottomSheetRef=y(Pe);data=y(Wt);showCancel=!!(this.data&&this.data.showCancel);clickAction(e){this._bottomSheetRef.dismiss(e)}static \u0275fac=function(t){return new(t||l)};static \u0275cmp=k({type:l,selectors:[["widget-host-bottom-sheet"]],decls:22,vars:1,consts:[["mat-list-item","",3,"click"],["matListItemIcon",""],["mat-list-item",""]],template:function(t,i){t&1&&(b(0,"mat-action-list")(1,"button",0),x("click",function(){return i.clickAction("duplicate")}),b(2,"mat-icon",1),v(3,"add_to_photos"),_(),b(4,"span"),v(5,"Duplicate"),_()(),b(6,"button",0),x("click",function(){return i.clickAction("copy")}),b(7,"mat-icon",1),v(8,"content_copy"),_(),b(9,"span"),v(10,"Copy"),_()(),b(11,"button",0),x("click",function(){return i.clickAction("cut")}),b(12,"mat-icon",1),v(13,"content_cut"),_(),b(14,"span"),v(15,"Cut"),_()(),b(16,"button",0),x("click",function(){return i.clickAction("delete")}),b(17,"mat-icon",1),v(18,"delete_forever"),_(),b(19,"span"),v(20,"Delete"),_()(),L(21,yi,5,0,"button",2),_()),t&2&&(M(21),I(i.showCancel?21:-1))},dependencies:[Le,Ae,We,Ne,se,ie],encapsulation:2})}return l})();var qe=(()=>{class l{http=y(Dt);connection=y(Te);pluginConfig=y(re);destroyRef=y(Q);kipPluginServiceUrl=null;constructor(){this.connection.serverServiceEndpoint$.pipe(me(this.destroyRef)).subscribe(e=>{let t=e?.httpServiceUrl||null;this.kipPluginServiceUrl=this.resolveKipPluginServiceUrl(t)})}resolveKipPluginServiceUrl(e){let t=this.connection.signalKURL?.url?.trim();return t?`${t.endsWith("/")?t.slice(0,-1):t}/plugins/kip/`:e?`${(e.endsWith("/")?e.slice(0,-1):e).replace(/\/signalk\/v2\/api$/,"").replace(/\/signalk\/v1\/api$/,"").replace(/\/signalk\/v2$/,"").replace(/\/signalk\/v1$/,"").replace(/\/signalk$/,"")}/plugins/kip/`:null}reconcileSeries(e){return D(this,null,function*(){try{if(!(yield this.pluginConfig.getKipRuntimeModeConfigCached("kip")).historySeriesServiceEnabled)return console.warn("[KipSeriesApiClientService] Reconcile skipped because history-series service is disabled in KIP plugin settings"),null;if(!this.kipPluginServiceUrl)return console.warn("[KipSeriesApiClientService] No KIP plugin endpoint available for series reconcile"),null;let i=`${this.kipPluginServiceUrl}series/reconcile`;console.log(`[KipSeriesApiClientService] POST ${i} (${e.length} series)`);let s=yield be(this.http.post(i,e));return console.log(`[KipSeriesApiClientService] Series reconcile successful (created=${s.created}, updated=${s.updated}, deleted=${s.deleted}, total=${s.total})`),s}catch(t){return console.error("[KipSeriesApiClientService] Series reconcile request failed:",t),null}})}getSeriesDefinitions(){return D(this,null,function*(){try{if(!(yield this.pluginConfig.getKipRuntimeModeConfigCached("kip")).historySeriesServiceEnabled)return console.warn("[KipSeriesApiClientService] Series list skipped because history-series service is disabled in KIP plugin settings"),null;if(!this.kipPluginServiceUrl)return console.warn("[KipSeriesApiClientService] No KIP plugin endpoint available for series list"),null;let t=`${this.kipPluginServiceUrl}series`;return yield be(this.http.get(t))}catch(e){return console.error("[KipSeriesApiClientService] Series list request failed:",e),null}})}getValues(e){return D(this,null,function*(){try{if(!this.kipPluginServiceUrl)return console.warn("[HistoryApiClientService] No HTTP service URL available"),null;let t=`${this.kipPluginServiceUrl}history/values`,i=new Et;i=i.set("paths",e.paths),e.context&&(i=i.set("context",e.context)),e.from&&(i=i.set("from",e.from)),e.to&&(i=i.set("to",e.to)),e.duration&&(i=i.set("duration",e.duration.toString())),e.resolution!==void 0&&e.resolution!==null&&(i=i.set("resolution",e.resolution.toString()));let s=`${t}?${i.toString()}`;console.log(`[HistoryApiClientService] GET ${s}`);let r=yield be(this.http.get(t,{params:i}));return console.log(`[HistoryApiClientService] History fetch successful, received ${r.data?.length??0} data points`),r}catch(t){return console.error("[HistoryApiClientService] History API request failed:",t),null}})}static \u0275fac=function(t){return new(t||l)};static \u0275prov=X({token:l,factory:l.\u0275fac,providedIn:"root"})}return l})();var Yt=(()=>{class l{dashboard=y($);kipSeries=y(qe);destroyRef=y(Q);connection=y(Te);pluginConfig=y(re);widgetService=y(Oe);serverEndpoint=Re(this.connection.serverServiceEndpoint$,{initialValue:null});RECONCILE_DEBOUNCE_MS=750;AUTO_RETENTION_MS=1440*60*1e3;reconcileTimer=null;lastSubmittedSignature=null;pendingSignature=null;pendingSeries=[];constructor(){W(()=>{let e=this.serverEndpoint(),t=this.dashboard.dashboards();if(e?.httpServiceUrl)try{let i=this.extractSeriesFromDashboards(t);this.scheduleReconcile(i)}catch(i){console.error("[DashboardHistorySeriesSyncService] Error extracting series from dashboards:",i)}}),this.destroyRef.onDestroy(()=>{this.reconcileTimer!==null&&(clearTimeout(this.reconcileTimer),this.reconcileTimer=null)})}scheduleReconcile(e){let t=this.getCanonicalSeriesSignature(e);t!==this.lastSubmittedSignature&&(this.pendingSeries=e,this.pendingSignature=t,this.reconcileTimer!==null&&clearTimeout(this.reconcileTimer),this.reconcileTimer=window.setTimeout(()=>{this.flushReconcile()},this.RECONCILE_DEBOUNCE_MS))}flushReconcile(){return D(this,null,function*(){if(!this.pendingSignature)return;let e=this.pendingSignature,t=this.pendingSeries;if(this.pendingSignature=null,this.reconcileTimer=null,!(yield this.pluginConfig.getKipRuntimeModeConfigCached("kip")).historySeriesServiceEnabled){console.warn("[DashboardHistorySeriesSyncService] Reconcile skipped because history series service mode is disabled"),this.lastSubmittedSignature=e;return}try{yield this.kipSeries.reconcileSeries(t),this.lastSubmittedSignature=e}catch(s){console.error("[DashboardHistorySeriesSyncService] Reconcile failed:",s)}})}extractSeriesFromDashboards(e){let t=[];return e.forEach(i=>{let s=this.coerceNodeList(i.configuration);this.collectSeriesFromNodes(s,t)}),t.sort((i,s)=>i.seriesId.localeCompare(s.seriesId))}resolveSeriesForWidget(e){let t=e?.type,i=e?.uuid,s=this.resolveWidgetConfig(t,e?.config);if(!t||!i||s?.supportAutomaticHistoricalSeries===!1)return[];if(t==="widget-data-chart"){let r=this.mapDataChartWidget(i,t,s);return r?[r]:[]}return t==="widget-windtrends-chart"?this.mapWindTrendsWidget(i,t,s):t==="widget-bms"?this.mapBmsWidget(i,t,s):this.mapAutomaticHistorySeries(i,t,s)}resolveWidgetConfig(e,t){if(!e)return t;let i=this.getDefaultConfigForType(e);return i?t?E(m(m({},i),t),{paths:t.paths??i.paths}):i:t}getDefaultConfigForType(e){try{return this.widgetService.getComponentType(e)?.DEFAULT_CONFIG}catch(t){return}}collectSeriesFromNodes(e,t){e.forEach(i=>{let s=i?.input?.widgetProperties;t.push(...this.resolveSeriesForWidget(s));let r=this.coerceNodeList(i?.subGridOpts?.children);r.length>0&&this.collectSeriesFromNodes(r,t)})}mapDataChartWidget(e,t,i){let s=this.normalizeString(i?.datachartPath);return s?{seriesId:`${e}:datachart`,datasetUuid:e,ownerWidgetUuid:e,ownerWidgetSelector:t,path:s,context:null,source:this.normalizeString(i?.datachartSource),timeScale:this.normalizeString(i?.timeScale),period:this.normalizeNumber(i?.period),retentionDurationMs:null,sampleTime:null,enabled:!0}:null}mapWindTrendsWidget(e,t,i){let s={ownerWidgetUuid:e,ownerWidgetSelector:t,context:null,source:"default",timeScale:this.normalizeString(i?.timeScale),period:30,retentionDurationMs:null,sampleTime:null,enabled:!0};return[E(m({},s),{seriesId:`${e}:wind-direction`,datasetUuid:`${e}-twd`,path:"self.environment.wind.directionTrue"}),E(m({},s),{seriesId:`${e}:wind-speed`,datasetUuid:`${e}-tws`,path:"self.environment.wind.speedTrue"})]}mapBmsWidget(e,t,i){let s=this.resolveBmsAllowedBatteryIds(i);return[{seriesId:`${e}:bms-template`,datasetUuid:`${e}:bms-template`,ownerWidgetUuid:e,ownerWidgetSelector:"widget-bms",path:"self.electrical.batteries.*",expansionMode:"bms-battery-tree",allowedBatteryIds:s.length>0?[...s]:null,context:null,source:"default",timeScale:this.normalizeString(i?.timeScale),period:this.normalizeNumber(i?.period),retentionDurationMs:this.AUTO_RETENTION_MS,sampleTime:null,enabled:!0}]}resolveBmsAllowedBatteryIds(e){let t=e?.bms;if(!t)return[];let i=Array.isArray(t.trackedBatteryIds)?t.trackedBatteryIds:[];if(i.length===0)return[];let s=new Set;return i.forEach(n=>{if(typeof n!="string")return;let a=n.trim();a.length>0&&s.add(a)}),(Array.isArray(t.banks)?t.banks:[]).forEach(n=>{(Array.isArray(n?.batteryIds)?n.batteryIds:[]).forEach(u=>{if(typeof u!="string")return;let c=u.trim();c.length>0&&s.add(c)})}),[...s].sort((n,a)=>n.localeCompare(a))}mapAutomaticHistorySeries(e,t,i){let s=this.extractWidgetPaths(i?.paths),r=new Map;return s.forEach(n=>{if(n.pathType!=="number")return;let a=this.normalizeString(n.path);if(!a)return;let u=this.normalizeString(n.source),c=`${a}|${u??"default"}`;if(r.has(c))return;let d=this.slugify(a),p=this.slugify(u??"default"),g=this.normalizeNumber(n.sampleTime);r.set(c,{seriesId:`${e}:auto:${d}:${p}`,datasetUuid:`${e}:${d}:${p}`,ownerWidgetUuid:e,ownerWidgetSelector:t,path:a,context:null,source:u,timeScale:this.normalizeString(i?.timeScale),period:this.normalizeNumber(i?.period),retentionDurationMs:this.AUTO_RETENTION_MS,sampleTime:g,enabled:!0})}),[...r.values()]}extractWidgetPaths(e){return e?Array.isArray(e)?e:Object.values(e):[]}slugify(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}normalizeString(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}normalizeNumber(e){return typeof e!="number"||!Number.isFinite(e)?null:e}coerceNodeList(e){return Array.isArray(e)?e:[]}getCanonicalSeriesSignature(e){let t=e.map(i=>({seriesId:i.seriesId,datasetUuid:i.datasetUuid,ownerWidgetUuid:i.ownerWidgetUuid,ownerWidgetSelector:i.ownerWidgetSelector,path:i.path,expansionMode:i.expansionMode??null,allowedBatteryIds:Array.isArray(i.allowedBatteryIds)?[...i.allowedBatteryIds].sort():null,context:i.context??null,source:i.source??null,timeScale:i.timeScale??null,period:i.period??null,retentionDurationMs:i.retentionDurationMs??null,sampleTime:i.sampleTime??null,enabled:i.enabled}));return JSON.stringify(t)}static \u0275fac=function(t){return new(t||l)};static \u0275prov=X({token:l,factory:l.\u0275fac,providedIn:"root"})}return l})();function Xt(l){return l.expansionMode==="bms-battery-tree"}function Qt(l){return l.enabled}var _i=["childOutlet"],Jt=(()=>{class l extends Ue{widgetProperties;outlet;dialog=y(oe);dashboard=y($);bottomSheet=y(ne);streams=y(ze,{optional:!0});meta=y(Me,{optional:!0});runtime=y(q,{optional:!0});widgetService=y(Oe);app=y(Ot);historySync=y(Yt);kipSeries=y(qe);_uiEvent=y(He);settings=y(Rt);theme=Re(this.app.cssThemeColorRoles$,{requireSync:!0});childRef=null;compType;_hasInitialized=!1;openOverlays=new Set;isDebugEnabled(){try{return typeof localStorage<"u"&&localStorage.getItem("kip:gesturesDebug")==="1"}catch(e){return!1}}debug(...e){this.isDebugEnabled()&&console.debug("[Host2]",...e)}acquireOverlay(e){return this.openOverlays.has(e)?(this.debug(`${e} already open; ignoring`,{widgetId:this.widgetProperties?.uuid}),!1):(this.openOverlays.add(e),!0)}releaseOverlay(e){this.openOverlays.delete(e)}constructor(){super(),W(()=>{let e=this.dashboard.layoutEditCanceled();!this._hasInitialized||!e||fe(()=>{this.reinitFromSavedConfig()})})}ngOnInit(){let e=this.widgetProperties.type;if(!e)return;let t=this.widgetProperties.autoOpenOptionsOnCreate===!0;t&&delete this.widgetProperties.autoOpenOptionsOnCreate,this.compType=this.widgetService.getComponentType(e);let i=this.getDefaultConfig();this.runtime?.initialize?.(i,this.widgetProperties.config);let s=this.runtime?.options();s&&(this.widgetProperties.config=s),this.streams?.applyStreamsConfigDiff?.(s),this.meta?.applyMetaConfigDiff?.(s),this.outlet&&this.compType&&(this.childRef=this.outlet.createComponent(this.compType,{bindings:[ve("id",()=>this.widgetProperties.uuid),ve("type",()=>this.widgetProperties.type),ve("theme",this.theme)]})),this._hasInitialized=!0,t&&queueMicrotask(()=>this.openWidgetOptions(new Event("kip:auto-open-options")))}ngOnDestroy(){this.childRef?.destroy(),this.childRef=null,this.openOverlays.clear()}serialize(){let e=this.runtime?.options();return e?this.widgetProperties.config=e:this.widgetProperties.config||(this.widgetProperties.config={}),{widgetProperties:this.widgetProperties}}applyRuntimeConfig(e){e&&this.runtime?.setRuntimeConfig?.(e);let t=this.runtime?.options();t&&(this.widgetProperties.config=t),this.streams?.applyStreamsConfigDiff?.(t),this.meta?.applyMetaConfigDiff?.(t)}reinitFromSavedConfig(){try{let e=this.getSavedConfigForSelf(),t=this.getDefaultConfig();this.runtime?.initialize?.(t,F(e));let i=this.runtime?.options();i&&(this.widgetProperties.config=i),this.streams?.applyStreamsConfigDiff?.(i),this.meta?.applyMetaConfigDiff?.(i)}catch(e){console.error("[Host2] failed to reinitialize saved config",{widgetId:this.widgetProperties?.uuid,error:e})}}getSavedConfigForSelf(){try{let e=this.dashboard.dashboards(),t=this.dashboard.activeDashboard(),r=(e?.[t]?.configuration??[]).find(n=>n?.id===this.widgetProperties.uuid);return r?.input?.widgetProperties?.config??r?.widgetProperties?.config??void 0}catch(e){return}}getDefaultConfig(){let e=this.compType&&this.compType.DEFAULT_CONFIG;if(!e&&this.compType&&this.outlet){let t=this.outlet.createComponent(this.compType);e=t.instance.defaultConfig,t.destroy()}return e}openWidgetOptions(e){if(e.stopPropagation(),this.debug("openWidgetOptions invoked",{widgetId:this.widgetProperties?.uuid,static:this.dashboard.isDashboardStatic()}),!this.dashboard.isDashboardStatic()){if(!this.acquireOverlay("options"))return;if(!this.widgetProperties){this.releaseOverlay("options");return}try{this.dialog.openWidgetOptions({title:"Widget Options",config:this.widgetProperties.config,confirmBtnText:"Save",cancelBtnText:"Cancel"}).afterClosed().subscribe(t=>{this.releaseOverlay("options"),t&&(this.debug("options saved",{widgetId:this.widgetProperties?.uuid}),this.applyRuntimeConfig(t))})}catch(t){this.releaseOverlay("options"),console.error("[Host2] failed to open widget options",{widgetId:this.widgetProperties?.uuid,error:t})}}}openBottomSheet(e){if(e.stopPropagation(),this.debug("openBottomSheet invoked",{widgetId:this.widgetProperties?.uuid,static:this.dashboard.isDashboardStatic()}),!this.dashboard.isDashboardStatic()){if(this._uiEvent.isDragging()){this.debug("bottom sheet suppressed during drag",{widgetId:this.widgetProperties?.uuid});return}if(!this.acquireOverlay("sheet"))return;let t=typeof navigator<"u"&&/Linux/.test(navigator.platform)&&/Firefox/.test(navigator.userAgent);try{this.bottomSheet.open($e,t?{disableClose:!0,data:{showCancel:!0}}:{}).afterDismissed().subscribe(s=>{switch(this.releaseOverlay("sheet"),this.debug("bottom sheet dismissed",{widgetId:this.widgetProperties?.uuid,action:s}),s){case"delete":this.dashboard.deleteWidget(this.widgetProperties.uuid);break;case"duplicate":this.dashboard.duplicateWidget(this.widgetProperties.uuid);break;case"copy":this.dashboard.copyWidget(this.widgetProperties.uuid);break;case"cut":this.dashboard.cutWidget(this.widgetProperties.uuid);break;default:break}})}catch(i){this.releaseOverlay("sheet"),console.error("[Host2] failed to open bottom sheet",{widgetId:this.widgetProperties?.uuid,error:i})}}}openWidgetHistoryDialog(e){e.preventDefault(),e.stopPropagation(),this.openWidgetHistoryDialogInternal()}onHistoryTwoFingerTap(e){e.preventDefault(),e.stopPropagation(),this.openWidgetHistoryDialogInternal()}openWidgetHistoryDialogInternal(){return D(this,null,function*(){if(!this.settings.getWidgetHistoryDisabled()&&this.dashboard.isDashboardStatic()&&this.acquireOverlay("history"))try{let e=yield this.resolveEffectiveSeriesDefinitions();if(!this.isHistoryDialogEligible(this.widgetProperties,e)){this.releaseOverlay("history");return}let t=this.widgetProperties?.config?.displayName||(this.widgetProperties?.type==="widget-bms"?"Battery Monitor":"Widget History");this.dialog.openWidgetHistoryDialog({title:t,widget:this.widgetProperties,seriesDefinitions:e}).afterClosed().subscribe(()=>{this.releaseOverlay("history")})}catch(e){this.releaseOverlay("history"),console.error("[Host2] failed to open history dialog",{widgetId:this.widgetProperties?.uuid,error:e})}})}resolveEffectiveSeriesDefinitions(){return D(this,null,function*(){let e=this.historySync.resolveSeriesForWidget(this.widgetProperties);if(!e.some(Xt))return e;let i=yield this.kipSeries.getSeriesDefinitions();if(!i)return e;let s=this.widgetProperties?.uuid;if(!s)return e;let r=new Set(["electrical.batteries","self.electrical.batteries"]);return i.filter(n=>{if(n.ownerWidgetUuid!==s||!Qt(n))return!1;let a=(n.path??"").trim();return a.length?Array.from(r).some(u=>a.startsWith(`${u}.`)):!1})})}isHistoryDialogEligible(e,t){if(!e?.config||e.config.supportAutomaticHistoricalSeries===!1)return!1;if(e.type==="widget-bms")return t.some(s=>s.enabled===!0);let i=this.extractNumericPaths(e.config.paths);return i.length?t.some(s=>{let r=typeof s.path=="string"?s.path.trim():"";return i.includes(r)?s.enabled===!0:!1}):!1}extractNumericPaths(e){if(!e)return[];let t=Array.isArray(e)?e:Object.values(e),i=new Set;return t.forEach(s=>{if(s?.pathType!=="number")return;let r=typeof s.path=="string"?s.path.trim():"";r.length&&i.add(r)}),[...i]}static \u0275fac=function(t){return new(t||l)};static \u0275cmp=k({type:l,selectors:[["widget-host2"]],viewQuery:function(t,i){if(t&1&&ge(_i,7,ue),t&2){let s;Z(s=ee())&&(i.outlet=s.first)}},inputs:{widgetProperties:"widgetProperties"},features:[we([ze,Me,q]),Ce],decls:3,vars:3,consts:[["childOutlet",""],["kipGestures","","mode","press","appearance","raised","twoFingerTap","",1,"widget-container","kip-widget-card-colors",3,"twoFingerTap","doubletap","press","contextmenu","twoFingerTapEnabled"]],template:function(t,i){t&1&&(b(0,"mat-card",1),x("twoFingerTap",function(r){return i.onHistoryTwoFingerTap(r)})("doubletap",function(r){return i.openWidgetOptions(r)})("press",function(r){return i.openBottomSheet(r)})("contextmenu",function(r){return i.openWidgetHistoryDialog(r)}),ut(1,null,0),_()),t&2&&(De("border",i.dashboard.isDashboardStatic()?"1px dashed transparent":"1px dashed var(--mat-sys-outline)"),B("twoFingerTapEnabled",i.dashboard.isDashboardStatic()))},dependencies:[Ht,Pt,Lt,te,jt],styles:["[_nghost-%COMP%]{width:100%;height:100%;display:block;overflow:hidden}.widget-container[_ngcontent-%COMP%]{display:block;width:100%;height:100%;margin:0;padding:0}.kip-widget-card-colors[_ngcontent-%COMP%]{background-color:var(--kip-widget-card-background-color)}"],changeDetection:0})}return l})();function vi(l,o){if(l&1){let e=V();b(0,"div",2),x("doubletap",function(i){N(e);let s=H();return A(s.openWidgetOptions(i))})("press",function(i){N(e);let s=H();return A(s.openBottomSheet(i))}),_()}}var Zt=(()=>{class l extends Ue{widgetProperties;dashboard=y($);_dialog=y(oe);_bottomSheet=y(ne);runtime=y(q);static DEFAULT_CONFIG={displayName:"Gauge Label",color:"contrast"};_sheetOpen=!1;_optionsOpen=!1;constructor(){super()}ngOnInit(){let e=this.widgetProperties.autoOpenOptionsOnCreate===!0;e&&delete this.widgetProperties.autoOpenOptionsOnCreate,this.runtime?.initialize?.(l.DEFAULT_CONFIG,this.widgetProperties.config),e&&queueMicrotask(()=>this.openWidgetOptions(new Event("kip:auto-open-options")))}serialize(){let e=this.runtime?.options();return e?this.widgetProperties.config=e:this.widgetProperties.config||(this.widgetProperties.config={}),{widgetProperties:this.widgetProperties}}openWidgetOptions(e){if(e.stopPropagation(),!this.dashboard.isDashboardStatic()){if(this._optionsOpen)return;this._optionsOpen=!0,this._dialog.openWidgetOptions({title:"Widget Options",config:F(this.runtime.options()),confirmBtnText:"Save",cancelBtnText:"Cancel"}).afterClosed().subscribe(t=>{this._optionsOpen=!1,t&&this.runtime.setRuntimeConfig(t)})}}openBottomSheet(e){if(e.stopPropagation(),!this.dashboard.isDashboardStatic()){if(this._sheetOpen)return;this._sheetOpen=!0;let t=typeof navigator<"u"&&/Linux/.test(navigator.platform)&&/Firefox/.test(navigator.userAgent);this._bottomSheet.open($e,t?{disableClose:!0,data:{showCancel:!0}}:{}).afterDismissed().subscribe(s=>{this._sheetOpen=!1,s==="delete"&&this.dashboard.deleteWidget(this.widgetProperties.uuid)})}}static \u0275fac=function(t){return new(t||l)};static \u0275cmp=k({type:l,selectors:[["group-widget"]],inputs:{widgetProperties:"widgetProperties"},features:[we([q]),Ce],decls:2,vars:3,consts:[[3,"text","color"],["kipGestures","","mode","press",1,"widgetOverlay"],["kipGestures","","mode","press",1,"widgetOverlay",3,"doubletap","press"]],template:function(t,i){t&1&&(xe(0,"widget-title",0),L(1,vi,1,0,"div",1)),t&2&&(B("text",i.runtime.options().displayName)("color",i.runtime.options().color),M(),I(i.dashboard.isDashboardStatic()?-1:1))},dependencies:[At,te],styles:["[_nghost-%COMP%]{display:block;height:15%}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:15%;right:0;top:0;color:transparent;z-index:21}"],changeDetection:0})}return l})();var ei=(()=>{class l{_bottomSheetRef=y(Pe);clickAction(e){this._bottomSheetRef.dismiss(e)}static \u0275fac=function(t){return new(t||l)};static \u0275cmp=k({type:l,selectors:[["dashboard-clipboard-bottom-sheet"]],decls:20,vars:0,consts:[["mat-subheader",""],["mat-list-item","",3,"click"],["matListItemIcon",""]],template:function(t,i){t&1&&(b(0,"mat-action-list")(1,"div",0),v(2,"Clipboard"),_(),b(3,"button",1),x("click",function(){return i.clickAction("paste")}),b(4,"mat-icon",2),v(5,"content_paste"),_(),b(6,"span"),v(7,"Paste"),_()(),b(8,"button",1),x("click",function(){return i.clickAction("clear")}),b(9,"mat-icon",2),v(10,"clear"),_(),b(11,"span"),v(12,"Clear"),_()(),b(13,"div",0),v(14,"New Widget"),_(),b(15,"button",1),x("click",function(){return i.clickAction("add")}),b(16,"mat-icon",2),v(17,"add_circle"),_(),b(18,"span"),v(19,"Add"),_()()())},dependencies:[Le,Ae,We,Ne,It,se,ie],styles:["[_nghost-%COMP%]{display:block}"],changeDetection:0})}return l})();var wi=["grid"];function Ci(l,o){l&1&&(b(0,"p",9)(1,"strong"),v(2,"Long press/click and hold anywhere"),_(),v(3," to add widgets"),_(),b(4,"mat-icon",10),v(5,"touch_app"),_())}function xi(l,o){if(l&1){let e=V();b(0,"p",9),v(1,"This empty dashboard is ready to be customized."),_(),b(2,"button",11),x("click",function(){N(e);let i=H();return A(i.editDashboard())}),b(3,"mat-icon"),v(4,"lock_open"),_(),v(5," Unlock and Customize "),_()}}function Ei(l,o){if(l&1){let e=V();b(0,"div",7)(1,"button",12),x("click",function(){N(e);let i=H();return A(i.cancelLayoutChanges())}),b(2,"mat-icon"),v(3,"close"),_()(),b(4,"button",13),x("click",function(){N(e);let i=H();return A(i.saveLayoutChanges())}),b(5,"mat-icon"),v(6,"done"),_()()()}}function Di(l,o){if(l&1&&xe(0,"dashboard-scroller",8),l&2){let e=H();B("activePage",e.dashboard.activeDashboard())("dashboards",e.dashboard.dashboards())}}var qo=(()=>{class l{toast=y(Mt);_dialog=y(oe);_bottomSheet=y(ne);dashboard=y($);_destroyRef=y(Q);_uiEvent=y(He);datasetLifecycle=y(Nt);_pluginConfig=y(re);_router=y(zt);_hostEl=y(ce);isDashboardStatic=_t(()=>this.dashboard.isDashboardStatic());_gridstack=wt.required("grid");_previousIsStaticState=!0;_suppressDrag=!1;subGridOptions={cellHeight:"auto",column:"auto",acceptWidgets:!0,subGridDynamic:!1,class:"group-container"};gridOptions=_e({column:24,row:24,margin:4,float:!0,resizable:{handles:"all"},acceptWidgets:!0,subGridDynamic:!1,subGridOpts:this.subGridOptions,children:[]});_boundHandleKeyDown=this.handleKeyDown.bind(this);_resizeObserver;_pendingResizeRaf=null;_lastContainerHeight=0;_lastCellHeight=0;_addDialogOpen=!1;_clipboardSheetOpen=!1;constructor(){ye.addComponentToSelectorType([Jt,Zt]),W(()=>{let e=this.dashboard.isDashboardStatic();fe(()=>{if(this._previousIsStaticState!==e){this._previousIsStaticState=e;try{this._gridstack().grid.setStatic(e)}catch(t){}}})}),W(()=>{let e=this.dashboard.activeDashboard();fe(()=>{this.loadDashboard(e)})})}ngAfterViewInit(){this._gridstack().grid?.setStatic(this._previousIsStaticState),this.resizeGridColumns(),this.setupResizeObserver(),this._uiEvent.addHotkeyListener(this._boundHandleKeyDown,{ctrlKey:!0,keys:["arrowdown","arrowup"]});try{let e=this._gridstack().grid;e&&typeof e.on=="function"&&(e.on("dragstart",()=>{this._uiEvent.isDragging.set(!0)}),e.on("dragstop",()=>{setTimeout(()=>this._uiEvent.isDragging.set(!1),0)}),e.on("resizestart",()=>{this._uiEvent.isDragging.set(!0)}),e.on("resizestop",()=>{setTimeout(()=>this._uiEvent.isDragging.set(!1),0)}))}catch(e){}this.dashboard.widgetAction$.pipe(me(this._destroyRef)).subscribe(e=>{e&&this._gridstack().grid.getGridItems().forEach(t=>{if(t.gridstackNode.id===e.id)switch(e.operation){case"delete":this.deleteWidget(t);break;case"duplicate":this.duplicateWidget(t);break;case"copy":this.dashboard.setWidgetClipboardFromNode(t.gridstackNode);break;case"cut":this.dashboard.setWidgetClipboardFromNode(t.gridstackNode),this.deleteWidget(t);break;default:break}})})}setupResizeObserver(){if(this._resizeObserver)return;let e=this._hostEl.nativeElement;try{this._resizeObserver=new ResizeObserver(()=>{this._pendingResizeRaf===null&&(this._pendingResizeRaf=requestAnimationFrame(()=>{this._pendingResizeRaf=null,this.resizeGridColumns()}))}),this._resizeObserver.observe(e)}catch(t){}}handleKeyDown(e){e==="arrowdown"?this.previousDashboard():e==="arrowup"&&this.nextDashboard()}resizeGridColumns(){try{let t=this._gridstack().grid;if(!t)return;let i=t,s=this._hostEl.nativeElement.clientHeight||window.innerHeight;if(s===this._lastContainerHeight&&this._lastCellHeight>0)return;let r=i.getRow?i.getRow():0;if(r>0&&i.cellHeight){let n=Number(r)||0,a=n>0?s/n:1;if(a=Math.max(1,Math.round(a*100)/100),this._lastCellHeight===a&&this._lastContainerHeight===s)return;i.cellHeight(a),i.batchUpdate&&(i.batchUpdate(),i.batchUpdate(!1)),this._lastContainerHeight=s,this._lastCellHeight=a}}catch(e){}}loadDashboard(e){let t=F(this.dashboard.dashboards()[e]),i=this._gridstack();if(!i?.grid){queueMicrotask(()=>this.loadDashboard(e));return}i.grid.batchUpdate(),i.grid.load(t.configuration),i.grid.batchUpdate(!1)}saveDashboard(){let e=this._gridstack().grid.save(!1,!1)||null,t=F(e);this.dashboard.updateConfiguration(this.dashboard.activeDashboard(),t)}saveLayoutChanges(){this.dashboard.setStaticDashboard(!0),this.saveDashboard(),this.dashboard.notifyLayoutEditSaved()}cancelLayoutChanges(){this.loadDashboard(this.dashboard.activeDashboard()),this.dashboard.setStaticDashboard(!0),this.dashboard.notifyLayoutEditCanceled()}addNewWidget(e){if(!this.dashboard.isDashboardStatic()&&e.detail!==void 0){if(this._addDialogOpen||this._clipboardSheetOpen)return;let t=e.detail||{},i=t.center?.x??t.x??0,s=t.center?.y??t.y??0,r=this._gridstack().grid.getCellFromPixel({left:i,top:s});if(this._gridstack().grid.isAreaEmpty(r.x,r.y,1,2)){if(this.dashboard.widgetClipboard()){this.openClipboardBottomSheet(r.x,r.y);return}this.openAddWidgetDialog(r.x,r.y)}else this.toast.show("Not enough free space at the selected location to add a widget. Please reorganize the dashboard to free up space or try a larger empty area.",0,!1,"error")}}openClipboardBottomSheet(e,t){if(this._clipboardSheetOpen)return;this._clipboardSheetOpen=!0,this._bottomSheet.open(ei).afterDismissed().subscribe(s=>{switch(this._clipboardSheetOpen=!1,s){case"paste":this.pasteCopiedWidget(e,t);break;case"clear":this.dashboard.clearWidgetClipboard();break;case"add":this.openAddWidgetDialog(e,t);break;default:break}})}openAddWidgetDialog(e,t){this._addDialogOpen=!0,this._dialog.openFrameDialog({title:"Add Widget",component:"select-widget"},!0).pipe(rt(()=>{this._addDialogOpen=!1})).subscribe(i=>D(this,null,function*(){if(!i||typeof i!="object")return;let s=i;yield this.tryAddWidgetWithDependencyChecks(s,e,t)}))}tryAddWidgetWithDependencyChecks(e,t,i){return D(this,null,function*(){let s=yield this.getDisabledRequiredPlugins(e.requiredPlugins??[]);if(s.length>0){this.promptEnableRequiredPlugins(e,t,i,s);return}let r=yield this.getAnyOfPluginActivationState(e.anyOfPlugins??[]),n=r.installed.length>0,a=r.enabled.length>0;if(n&&!a){this.notifyAnyOfPluginsRequireManualActivation(e,r.installed);return}this.addWidgetToGrid(e,t,i)})}getDisabledRequiredPlugins(e){return D(this,null,function*(){if(!e?.length)return[];let t=[...new Set(e)];return(yield Promise.all(t.map(s=>D(this,null,function*(){let r=yield this._pluginConfig.getPlugin(s);return{pluginId:s,enabled:r.ok&&r.data.state.enabled}})))).filter(s=>!s.enabled).map(s=>s.pluginId)})}getAnyOfPluginActivationState(e){return D(this,null,function*(){if(!e?.length)return{installed:[],enabled:[]};let t=[...new Set(e)],i=yield Promise.all(t.map(s=>D(this,null,function*(){let r=yield this._pluginConfig.getPlugin(s);return{pluginId:s,installed:r.ok,enabled:r.ok&&r.data.state.enabled}})));return{installed:i.filter(s=>s.installed).map(s=>s.pluginId),enabled:i.filter(s=>s.enabled).map(s=>s.pluginId)}})}notifyAnyOfPluginsRequireManualActivation(e,t){let i=t.join(", ");this.toast.show(`Cannot add "${e.name}" yet. Any-of plugin${t.length>1?"s are":" is"} installed (${i}) but none ${t.length>1?"are":"is"} active. Please manually activate and configure one or all in Signal K Plugin Config, then come back and add the widget.`,0,!1,"warn")}promptEnableRequiredPlugins(e,t,i,s){let r=s.join(", ");this.toast.show(`Cannot add "${e.name}" widget until required plugin${s.length>1?"s are":" is"} enabled: ${r}.`,0,!1,"warn","Enable").onAction().pipe(me(this._destroyRef)).subscribe(()=>{this.enableRequiredPluginsAndAddWidget(e,t,i,s)})}enableRequiredPluginsAndAddWidget(e,t,i,s){return D(this,null,function*(){let r=[...new Set(s)],a=(yield Promise.all(r.map(u=>D(this,null,function*(){return{pluginId:u,result:yield this._pluginConfig.setPluginEnabled(u,!0)}})))).filter(u=>!u.result.ok).map(u=>u.pluginId);if(a.length>0){this.toast.show(`Failed to enable required plugin${a.length>1?"s":""}: ${a.join(", ")}.`,0,!1,"error");return}this.toast.show(`Enabled required plugin${r.length>1?"s":""}: ${r.join(", ")}.`,3e3,!0,"success"),yield this.tryAddWidgetWithDependencyChecks(e,t,i)})}addWidgetToGrid(e,t,i){let s=ke.create(),r={};e.selector==="group-widget"?r={x:t,y:i,w:3,h:4,id:s,selector:"group-widget",input:{widgetProperties:{type:e.selector,uuid:s,config:{displayName:"Group Widget",color:"contrast"},autoOpenOptionsOnCreate:!0}},subGridOpts:{children:[]}}:r={x:t,y:i,w:e.defaultWidth,h:e.defaultHeight,minW:e.minWidth,minH:e.minHeight,id:s,selector:"widget-host2",input:{widgetProperties:{type:e.selector,uuid:s,autoOpenOptionsOnCreate:!0}}};let n=this._gridstack().grid,a=Number(e.minWidth??1),u=Number(e.minHeight??2),c=Number(e.defaultWidth??a),d=Number(e.defaultHeight??u);if(!(n.isAreaEmpty(t,i,c,d)&&n.willItFit({x:t,y:i,w:c,h:d}))){let w=this.findBestWidgetSizeAtCell(n,t,i,a,u,c,d);if(!w){this.toast.show(`Not enough free space to add "${e.name}" widget at the selected location. Please reorganize the dashboard to free up space or try a larger empty area.`,0,!1,"error");return}r.w=w.w,r.h=w.h}let g=this._gridstack().grid.addWidget(r);g.gridstackNode.subGrid&&(g.gridstackNode.subGridOpts.row=g.gridstackNode.subGridOpts.minRow=g.gridstackNode.subGridOpts.maxRow=g.gridstackNode.h)}findBestWidgetSizeAtCell(e,t,i,s,r,n,a){let u=Math.max(1,Math.floor(s)),c=Math.max(1,Math.floor(r)),d=Math.max(u,Math.floor(n)),p=Math.max(c,Math.floor(a)),g=null;for(let w=u;w<=d;w++)for(let C=c;C<=p;C++){if(!e.isAreaEmpty(t,i,w,C)||!e.willItFit({x:t,y:i,w,h:C}))continue;let z=w*C;(!g||z>g.area||z===g.area&&C>g.h||z===g.area&&C===g.h&&w>g.w)&&(g={w,h:C,area:z})}return g?{w:g.w,h:g.h}:null}cancelPointerSequence(){if(!this._suppressDrag){this._suppressDrag=!0;try{this._gridstack().grid.setStatic(!0)}catch(e){}["pointerup","mouseup","touchend"].forEach(e=>{document.dispatchEvent(new Event(e,{bubbles:!0}))})}}onPointerRelease(){if(this._suppressDrag&&(this._suppressDrag=!1,!this.dashboard.isDashboardStatic()))try{this._gridstack().grid.setStatic(!1)}catch(e){}}duplicateWidget(e){let t=ke.create(),i=e.gridstackNode,s={w:i.w,h:i.h,id:t,selector:i.selector,input:{widgetProperties:{type:i.input.widgetProperties.type,uuid:t,config:F(i.input.widgetProperties.config)}}},r=this._gridstack();r.grid.willItFit(s)?r.grid.addWidget(s):(s.h=2,s.w=1,r.grid.willItFit(s)?r.grid.addWidget(s):this.toast.show("Insufficient space on the dashboard. Please reorganize to free up space.",0,!1,"error"))}pasteCopiedWidget(e,t){if(this.dashboard.isDashboardStatic())return;let i=this.dashboard.widgetClipboard(),s=i?.input?.widgetProperties;if(!i||!s?.type)return;let r=ke.create(),n={w:i.w,h:i.h,id:r,selector:i.selector,input:{widgetProperties:{type:s.type,uuid:r,config:F(s.config)}}};typeof e=="number"&&typeof t=="number"&&(n.x=e,n.y=t);let a=this._gridstack();a.grid.willItFit(n)?(a.grid.addWidget(n),this.dashboard.clearWidgetClipboard()):(n.h=2,n.w=1,a.grid.willItFit(n)?(a.grid.addWidget(n),this.dashboard.clearWidgetClipboard()):this.toast.show("Insufficient space on the dashboard. Please reorganize to free up space.",0,!1,"error"))}deleteWidget(e){let t=e.gridstackNode;this._gridstack().grid.removeWidget(e),t?.id&&this.datasetLifecycle.removeOwnedDatasets(t.id,!0)}nextDashboard(){this.dashboard.isDashboardStatic()&&this.dashboard.navigateToNextDashboard()}previousDashboard(){this.dashboard.isDashboardStatic()&&this.dashboard.navigateToPreviousDashboard()}editDashboard(){this.dashboard.isDashboardStatic.set(!1)}navigateToHelp(){this._router.navigate(["/help"])}ngOnDestroy(){let e=this._gridstack();if(e?.grid&&(e.grid.offAll(),e.grid.destroy()),this._resizeObserver){try{this._resizeObserver.disconnect()}catch(t){}this._resizeObserver=void 0}this._pendingResizeRaf!==null&&(cancelAnimationFrame(this._pendingResizeRaf),this._pendingResizeRaf=null),this._uiEvent.removeHotkeyListener(this._boundHandleKeyDown)}static \u0275fac=function(t){return new(t||l)};static \u0275cmp=k({type:l,selectors:[["dashboard"]],viewQuery:function(t,i){t&1&&gt(i._gridstack,wi,5),t&2&&ft()},hostBindings:function(t,i){t&1&&x("mouseup",function(){return i.onPointerRelease()},Ye)("touchend",function(){return i.onPointerRelease()},Ye)},decls:16,vars:6,consts:[["grid",""],["kipGestures","",3,"swipeup","swipedown","press","resize","mode","enablePress","enableDoubleTap","options"],["empty-content","",1,"dashboard-empty-state-container"],[1,"dashboard-empty-state-action"],[1,"empty-state-icon"],[1,"empty-state-help"],["mat-button","",1,"empty-state-help-button",3,"click"],[1,"edit-layout-close-icon"],[3,"activePage","dashboards"],[1,"empty-state-text"],[1,"touch-icon"],["mat-flat-button","",1,"empty-state-button",3,"click"],["mat-fab","",1,"cancel",2,"margin-right","10px",3,"click"],["mat-fab","",1,"save",3,"click"]],template:function(t,i){if(t&1&&(b(0,"gridstack",1,0),x("swipeup",function(){return i.previousDashboard()})("swipedown",function(){return i.nextDashboard()})("press",function(r){return i.addNewWidget(r)})("resize",function(){return i.resizeGridColumns()},ot),b(2,"div",2)(3,"div",3)(4,"mat-icon",4),v(5,"dashboard"),_(),L(6,Ci,6,0)(7,xi,6,0),_(),b(8,"div")(9,"div",5)(10,"button",6),x("click",function(){return i.navigateToHelp()}),b(11,"mat-icon"),v(12,"help"),_(),v(13," Get Help "),_()()()()(),L(14,Ei,7,0,"div",7)(15,Di,1,2,"dashboard-scroller",8)),t&2){let s=i.dashboard.isDashboardStatic();B("mode",s?"dashboard":"editor")("enablePress",!s)("enableDoubleTap",!1)("options",i.gridOptions()),M(6),I(s?7:6),M(8),I(s?15:14)}},dependencies:[ye,Kt,se,ie,Tt,St,kt,te],styles:["[_nghost-%COMP%]{display:flex;flex-direction:row;flex-wrap:nowrap;height:100%;width:100%;overflow:hidden}.grid-stack[_ngcontent-%COMP%]{width:100%;height:100%;box-sizing:border-box;position:relative} .grid-stack-sub-grid{border:1px solid var(--mat-sys-outline);border-radius:8px} .grid-stack-sub-grid div{display:flex;flex-direction:column} .grid-stack-sub-grid div .grid-stack{flex:1 1 auto;min-height:500px}.edit-layout-close-icon[_ngcontent-%COMP%]{position:absolute;bottom:20px;right:20px;cursor:pointer;z-index:100}.cancel[_ngcontent-%COMP%]{--mat-fab-container-color: var(--mat-sys-primary);--mat-fab-foreground-color: var(--mat-sys-background)}.save[_ngcontent-%COMP%]{--mat-fab-container-color: var(--mat-sys-primary-fixed);--mat-fab-foreground-color: var(--mat-sys-background)}.dashboard-empty-state-container[_ngcontent-%COMP%]{position:absolute;inset:0;display:flex;flex-direction:column;flex-wrap:nowrap;align-items:center;justify-content:space-around;padding:1.5rem;text-align:center;box-sizing:border-box;overflow:hidden;pointer-events:auto}@media(orientation:landscape)and (max-height:420px){.dashboard-empty-state-container[_ngcontent-%COMP%]{padding:.75rem}.empty-state-icon[_ngcontent-%COMP%]{font-size:3.25rem;width:3.25rem;height:3.25rem}}.dashboard-empty-state-action[_ngcontent-%COMP%]{max-width:500px;color:var(--mat-sys-outline-variant)}.dashboard-empty-state-action[_ngcontent-%COMP%] .touch-icon[_ngcontent-%COMP%]{font-size:2rem;width:2rem;height:2rem;color:var(--mat-sys-outline-variant);margin-top:.5rem;animation:_ngcontent-%COMP%_bounce 2s infinite}.empty-state-icon[_ngcontent-%COMP%]{font-size:4rem;width:4rem;height:4rem;color:var(--mat-sys-outline-variant);margin-bottom:1rem}.empty-state-button[_ngcontent-%COMP%]{--mat-button-filled-label-text-color: var(--kip-widget-card-background-color);--mat-button-filled-container-color: var(--mat-sys-outline-variant);--mat-button-filled-hover-state-layer-opacity: .7;--mat-button-filled-state-layer-color: var(--mat-sys-primary-fixed-dim)}.empty-state-help-button[_ngcontent-%COMP%]{--mat-button-text-label-text-color: var(--mat-sys-outline-variant);--mat-button-text-hover-state-layer-opacity: .7;--mat-button-text-state-layer-color: var(--mat-sys-primary-fixed-dim)}.empty-state-text[_ngcontent-%COMP%]{color:var(--mat-sys-outline-variant);font-style:italic}@keyframes _ngcontent-%COMP%_bounce{0%,20%,50%,80%,to{transform:translateY(0)}40%{transform:translateY(-10px)}60%{transform:translateY(-5px)}}"]})}return l})();export{Yt as a,qo as b};
@@ -1 +0,0 @@
1
- import{a as xe,b as bt}from"./chunk-XFHXLFTX.js";import{a as Ft,b as T,c as $,i as he,k as E,l as _e,m as dt,o as ve,p as be,s as Ce,u as pt}from"./chunk-QN4XMV3X.js";import{a as Ie}from"./chunk-JL7DODKZ.js";import{c as le}from"./chunk-B2CYEVGO.js";import{a as Oe,b as Pe,c as Ne,d as De,e as Te,f as Ae}from"./chunk-W5RYIISE.js";import{a as ke}from"./chunk-3B5RVPSS.js";import{c as pe,d as Se,g as ye,h as we,j as Me}from"./chunk-S4UHQERA.js";import{b as Ee}from"./chunk-E3VC75HO.js";import{e as ge}from"./chunk-BMEO4VRV.js";import{c as de,d as me,e as fe,f as ue}from"./chunk-6LPU67GV.js";import{o as ct,p as lt,q as z,r as H}from"./chunk-WYC65OAX.js";import{a as Zt,b as st,d as te,e as x,g as ee,h as ie,i as oe}from"./chunk-GHPW4BPE.js";import{a as ce}from"./chunk-OBMTAHXF.js";import{f as ae,g as re,t as se}from"./chunk-CSJ2TU72.js";import{c as Lt,e as Xt,g as nt,h as V,i as at,k as D,l as rt,m as M,n as ne}from"./chunk-PKB75FW2.js";import{$b as Pt,A as yt,Ac as W,Ba as J,Bb as K,Bc as Et,Bd as Ht,Cb as L,Db as w,Dd as $t,Eb as a,Ed as qt,Fb as s,Fc as Rt,Fe as ot,Ga as kt,Gb as k,Gc as et,Ha as y,Ic as vt,Ja as It,Jc as Ut,K as F,Le as Yt,Nb as S,Oe as Jt,Pb as f,Pe as U,Qe as h,Rb as u,Se as B,Te as A,U as wt,Wa as p,Wd as jt,Zb as Z,_b as tt,a as Ct,bc as Nt,c as St,ca as Mt,dd as Kt,de as Wt,ec as l,f as q,fc as j,gb as P,gc as Dt,he as it,ie as Gt,kc as ht,ke as N,la as C,lc as gt,le as Qt,m as ft,mc as _t,qa as n,rb as ut,sa as xt,va as g,vb as Ot,vc as Tt,wa as _,wd as Vt,xb as v,xc as At,xd as Bt,yb as b,yd as zt,z as Q,za as Y,zb as X}from"./chunk-UBBLNNPA.js";var mt=(i,c)=>{let t=n(M),e=n(x),o=t.getSplitShellEnabled(),r="/"+c.map(O=>O.path).join("/"),d=o?"chartplotter":"dashboard",m=r.startsWith("/chartplotter"),R=r.startsWith("/dashboard");if(c.length===0)return e.createUrlTree([d,"0"]);if(c.length===1&&(c[0].path==="chartplotter"||c[0].path==="dashboard"))return e.createUrlTree([d,"0"]);if(o&&R&&!m){let O=c.length>1?c[1].path:void 0;return e.createUrlTree(["chartplotter",O??""])}if(!o&&m){let O=c.length>1?c[1].path:void 0;return e.createUrlTree(["dashboard",O??""])}return!0};var Re=[{path:"dashboard/:id",component:bt,canMatch:[mt]},{path:"chartplotter/:id",loadComponent:()=>import("./chunk-U5QHLGHD.js").then(i=>i.SplitShellComponent),canMatch:[mt]},{path:"settings",loadComponent:()=>import("./chunk-2BKBAKG4.js").then(i=>i.SettingsComponent),title:"KIP - Settings"},{path:"options",loadComponent:()=>import("./chunk-2BY2XRFX.js").then(i=>i.TabsComponent),title:"KIP - Options"},{path:"remote",loadComponent:()=>import("./chunk-KHZPPOSI.js").then(i=>i.RemoteControlComponent),title:"KIP - Remote Control"},{path:"help/:page",loadComponent:()=>import("./chunk-GWAFO3MC.js").then(i=>i.AppHelpComponent),title:"KIP - Help"},{path:"help",loadComponent:()=>import("./chunk-GWAFO3MC.js").then(i=>i.AppHelpComponent),title:"KIP - Help"},{path:"data",loadComponent:()=>import("./chunk-HIXACNNV.js").then(i=>i.DataInspectorComponent),title:"KIP - Data Inspector"},{path:"login",loadComponent:()=>import("./chunk-PDJFHMII.js").then(i=>i.WidgetLoginComponent),title:"Login"},{path:"**",component:bt,canMatch:[mt]}];var Ue={production:!0};var Ye=(i,c)=>c.path;function Je(i,c){i&1&&(a(0,"mat-icon"),l(1,"info"),s())}function Xe(i,c){i&1&&(a(0,"mat-icon"),l(1,"info"),s())}function Ze(i,c){i&1&&(a(0,"mat-icon",3),l(1,"report"),s())}function ti(i,c){i&1&&(a(0,"mat-icon",4),l(1,"warning"),s())}function ei(i,c){i&1&&(a(0,"mat-icon",5),l(1,"error"),s())}function ii(i,c){i&1&&(a(0,"mat-icon",6),l(1,"emergency_home"),s())}function oi(i,c){if(i&1){let t=S();a(0,"div",2),v(1,Je,2,0,"mat-icon")(2,Xe,2,0,"mat-icon")(3,Ze,2,0,"mat-icon",3)(4,ti,2,0,"mat-icon",4)(5,ei,2,0,"mat-icon",5)(6,ii,2,0,"mat-icon",6),a(7,"div",7),l(8),s(),a(9,"div",8),l(10),Tt(11,"slice"),s(),a(12,"div",9),l(13),s(),a(14,"button",10),f("click",function(){let o=g(t).$implicit,r=u();return _(r.silence(o.path))}),a(15,"mat-icon"),l(16,"music_off"),s()(),a(17,"button",11),f("click",function(){let o=g(t).$implicit,r=u();return _(r.clear(o.path))}),a(18,"mat-icon"),l(19,"published_with_changes"),s()()(),k(20,"mat-divider",12)}if(i&2){let t,e=c.$implicit;p(),b((t=e.value.state)==="nominal"?1:t==="normal"?2:t==="alert"?3:t==="warn"?4:t==="alarm"?5:t==="emergency"?6:-1),p(7),j(e.value.state),p(2),Dt(" ",At(11,5,e.path,14)," "),p(3),j(e.value.message),p(),w("disabled",!(e.value.method!=null&&e.value.method.includes("sound")))}}function ni(i,c){i&1&&(a(0,"mat-list-item",13)(1,"span",15),l(2,"Notifications Disabled"),s(),a(3,"span")(4,"i"),l(5,"*Enable notifications in Settings."),s()()())}function ai(i,c){i&1&&(a(0,"mat-list-item",14)(1,"i"),l(2,'"No Notification"'),s()())}function ri(i,c){if(i&1&&v(0,ni,6,0,"mat-list-item",13)(1,ai,3,0,"mat-list-item",14),i&2){let t=u();b(t.notificationConfig().disableNotifications?0:1)}}function si(i,c){if(i&1){let t=S();a(0,"button",17),f("click",function(){g(t);let o=u(2);return _(o.mutePlayer(!o.isMuted))}),a(1,"span",18),l(2,"volume_up"),s(),l(3," Unmute Audio "),s()}}function ci(i,c){if(i&1){let t=S();a(0,"button",17),f("click",function(){g(t);let o=u(2);return _(o.mutePlayer(!o.isMuted))}),a(1,"span",18),l(2,"volume_off"),s(),l(3," Mute Audio "),s()}}function li(i,c){if(i&1&&v(0,si,4,0,"button",16)(1,ci,4,0,"button",16),i&2){let t=u();b(t.isMuted?0:1)}}var Le=(()=>{class i{_notificationsService=n(E);_notifications$=this._notificationsService.observeNotifications();notificationConfig=h(this._notificationsService.observeNotificationConfiguration(),{requireSync:!0});menuNotifications=h(yt([this._notifications$,this._notificationsService.observeNotificationConfiguration()]).pipe(Q(([t,e])=>{let o=[];return e.devices.showNormalState||o.push(ct.Normal),e.devices.showNominalState||o.push(ct.Nominal),t.filter(r=>r.value&&r.value.state&&!o.includes(r.value.state)).filter(r=>{let d=r.value?.method;return d?.length?d.includes(lt.Visual)||d.includes(lt.Sound):!1})})),{requireSync:!0,equal:Xt});isMuted=!1;mutePlayer(t){this.isMuted=t,this._notificationsService.mutePlayer(t)}silence(t){this._notificationsService.setSkMethod(t,[lt.Visual])}clear(t){this._notificationsService.setSkState(t,ct.Normal)}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=P({type:i,selectors:[["menu-notifications"]],decls:6,vars:2,consts:[[1,"menu-item-container"],[1,"actions-container","actions-bottom-container"],[1,"notification-container"],[1,"icon-alert-color"],[1,"icon-warn-color"],[1,"icon-alarm-color"],[1,"icon-emergency-color"],[1,"notification-title"],[1,"notification-path","scrollable-text"],[1,"notification-text"],["mat-icon-button","",1,"notification-action-btn",3,"click","disabled"],["mat-icon-button","",1,"notification-action-btn",3,"click"],[1,"notification-divider"],["lines","3","disabled","true",2,"text-align","center"],["disabled","true",2,"text-align","center"],["matListItemTitle",""],["mat-flat-button","","matTooltip","Temporally toggle all notification audio. To permanently disable/enable notification audio, use the configuration settings option",1,"action-button"],["mat-flat-button","","matTooltip","Temporally toggle all notification audio. To permanently disable/enable notification audio, use the configuration settings option",1,"action-button",3,"click"],[1,"material-icons"]],template:function(e,o){e&1&&(a(0,"mat-list",0),K(1,oi,21,8,null,null,Ye,!1,ri,2,1),s(),a(4,"div",1),v(5,li,2,1),s()),e&2&&(p(),L(o.menuNotifications()),p(4),b(o.notificationConfig().disableNotifications?-1:5))},dependencies:[Me,ye,we,ce,Se,N,it,Wt,dt,ue,fe,A,B,Kt],styles:[".notification-container[_ngcontent-%COMP%]{display:flex;flex-direction:row;flex-wrap:wrap;justify-content:space-evenly;padding:2px 10px 7px;scroll-behavior:smooth}mat-icon[_ngcontent-%COMP%]{margin-right:10px}.scrollable-text[_ngcontent-%COMP%]{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.scrollable-text[_ngcontent-%COMP%]:hover{overflow:auto;white-space:normal;word-wrap:break-word}.notification-title[_ngcontent-%COMP%]{text-transform:capitalize;font-size:var(--mat-sys-headline-small-size);width:calc(100% - 34px)}.notification-path[_ngcontent-%COMP%]{font-size:var(--mat-sys-body-small-size);word-break:break-all;width:100%}.notification-text[_ngcontent-%COMP%]{font-size:var(--mat-sys-body-small-line-height);font-style:italic;width:100%;overflow:auto;white-space:normal;word-wrap:break-word}.notification-action-btn[_ngcontent-%COMP%]{background-color:var(--mat-sys-surface-container)}.notification-btn-container[_ngcontent-%COMP%]{display:inline-block;width:50%;height:48px;text-align:center}.menu-item-container[_ngcontent-%COMP%]{width:230px;overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch;height:calc(100% - 48px)}.notification-bottom-container[_ngcontent-%COMP%]{position:absolute;bottom:0;width:100%;background-color:var(--mat-sys-surface-container)}.actions-container[_ngcontent-%COMP%]{display:grid;grid-auto-flow:column}.actions-bottom-container[_ngcontent-%COMP%]{position:absolute;bottom:0;width:100%;height:48px}.action-button[_ngcontent-%COMP%]{border-radius:0;height:48px;border-bottom-right-radius:var(--mat-sidenav-container-shape, var(--mat-sys-corner-large))}.icon-alert-color[_ngcontent-%COMP%]{color:var(--kip-zone-alert-color)}.icon-warn-color[_ngcontent-%COMP%]{color:var(--kip-zone-warn-color)}.icon-alarm-color[_ngcontent-%COMP%]{color:var(--kip-zone-alarm-color)}.icon-emergency-color[_ngcontent-%COMP%]{color:var(--kip-zone-emergency-color)}.alarm-emergency-blink[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_blinking-emergency 1.5s infinite}@keyframes _ngcontent-%COMP%_blinking-emergency{0%{background-color:var(--kip-zone-alarm-color)}50%{background-color:transparent}to{background-color:var(--kip-zone-alarm-color)}}.warn[_ngcontent-%COMP%]{color:var(--kip-zone-warn-color)}.notification-divider[_ngcontent-%COMP%]{padding-top:10px}"],changeDetection:0})}return i})();var di=["badgeButton"],Ve=(()=>{class i{badgeButton=et.required("badgeButton");_notifications=n(E);notificationsInfo=h(this._notifications.observerNotificationsInfo());openNotificationMenu(){let t=new Event("openRightSidenav",{bubbles:!0,cancelable:!0});window.document.dispatchEvent(t)}onKeyDown(t){let e=t.key?.toLowerCase();(e==="enter"||e===" "||e==="spacebar")&&(t.preventDefault(),this.openNotificationMenu())}focus(){try{let t=this.badgeButton&&this.badgeButton(),e=t&&t.nativeElement;e&&typeof e.focus=="function"&&e.focus()}catch(t){}}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=P({type:i,selectors:[["notification-badge"]],viewQuery:function(e,o){e&1&&Z(o.badgeButton,di,5),e&2&&tt()},decls:5,vars:7,consts:[["badgeButton",""],["mat-fab","","role","button","aria-label","Open notifications",1,"layout-action-btn",3,"click","keydown"],["aria-hidden","false","matBadgeSize","large","matBadgePosition","after","matBadgeOverlap","true",1,"icon-alert-color",3,"matBadgeHidden","matBadge"]],template:function(e,o){e&1&&(a(0,"div")(1,"button",1,0),f("click",function(){return o.openNotificationMenu()})("keydown",function(d){return o.onKeyDown(d)}),a(3,"mat-icon",2),l(4,"notifications "),s()()()),e&2&&(p(),Nt("warn",o.notificationsInfo().isWarn)("alarm-emergency-blink",o.notificationsInfo().isAlarmEmergency),Ot("aria-haspopup",!0),p(2),w("matBadgeHidden",!o.notificationsInfo().alarmCount)("matBadge",o.notificationsInfo().alarmCount))},dependencies:[N,Gt,A,B,dt,_e],styles:["[_nghost-%COMP%]{display:block}.layout-action-btn[_ngcontent-%COMP%]{color:var(--mat-sys-on-primary);background-color:var(--mat-sys-primary)}.icon-alert-color[_ngcontent-%COMP%]{--mat-list-list-item-leading-icon-color: var(--kip-zone-alert-color)}.icon-warn-color[_ngcontent-%COMP%]{--mat-list-list-item-leading-icon-color: var(--kip-zone-warn-color)}.icon-alarm-color[_ngcontent-%COMP%]{--mat-list-list-item-leading-icon-color: var(--kip-zone-alarm-color)}.icon-emergency-color[_ngcontent-%COMP%]{--mat-list-list-item-leading-icon-color: var(--kip-zone-emergency-color)}.alarm-emergency-blink[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_blinking-emergency 1.5s infinite}@keyframes _ngcontent-%COMP%_blinking-emergency{0%{background-color:var(--kip-zone-alarm-color)}50%{background-color:var(--mat-sys-primary)}to{background-color:var(--kip-zone-alarm-color)}}.warn[_ngcontent-%COMP%]{color:var(--kip-zone-warn-color)}"]})}return i})();var Be=(()=>{class i{overlayRef=null;overlay=n(Yt);injector=n(Y);open(){if(this.overlayRef)return;this.overlayRef=this.overlay.create({hasBackdrop:!1,panelClass:"notification-overlay-panel",positionStrategy:this.overlay.position().global().bottom("20px").left("20px"),scrollStrategy:this.overlay.scrollStrategies.reposition()});let t=new Qt(Ve,null,this.injector),e=this.overlayRef.attach(t);try{let o=e&&e.instance;if(o&&typeof o.focus=="function")o.focus();else{let r=this.overlayRef.overlayElement,d=r&&r.querySelector("button[mat-fab], .layout-action-btn");d&&typeof d.focus=="function"&&d.focus()}}catch(o){}}close(){try{this.overlayRef&&this.overlayRef.dispose()}catch(t){console.warn("[NotificationOverlayService] dispose failed",t)}finally{this.overlayRef=null}}toggle(t){t?this.open():this.close()}isOpen(){return!!this.overlayRef}ngOnDestroy(){try{this.overlayRef&&this.overlayRef.dispose()}catch(t){}finally{this.overlayRef=null}}static \u0275fac=function(e){return new(e||i)};static \u0275prov=C({token:i,factory:i.\u0275fac,providedIn:"root"})}return i})();function pi(i,c){if(i&1){let t=S();a(0,"button",12),f("click",function(){g(t);let o=u(2);return _(o.onActionItem("toggleFullScreen"))}),a(1,"span",10),l(2,"fullscreen"),s()()}}function mi(i,c){if(i&1){let t=S();a(0,"button",12),f("click",function(){g(t);let o=u(2);return _(o.onActionItem("toggleFullScreen"))}),a(1,"span",10),l(2,"close_fullscreen"),s()()}}function fi(i,c){if(i&1&&v(0,pi,3,0,"button",11)(1,mi,3,0,"button",11),i&2){let t=u();b(t.uiEvent.fullscreenStatus()?1:0)}}function ui(i,c){if(i&1){let t=S();a(0,"button",14),f("click",function(){g(t);let o=u(2);return _(o.onActionItem("nightMode"))}),a(1,"span",10),l(2,"mode_night"),s()()}}function hi(i,c){if(i&1){let t=S();a(0,"button",14),f("click",function(){g(t);let o=u(2);return _(o.onActionItem("nightMode"))}),a(1,"span",10),l(2,"light_mode"),s()()}}function gi(i,c){if(i&1&&v(0,ui,3,0,"button",13)(1,hi,3,0,"button",13),i&2){let t=u();b(t.app.isNightMode()?1:0)}}function _i(i,c){if(i&1){let t=S();a(0,"tile-large-icon",15,1),f("click",function(){let o=g(t).$index,r=u();return _(r.navigateToDashboard(o))}),s()}if(i&2){let t=c.$implicit;w("active",t.active)("svgIcon",t.svgIcon)("iconSize",t.iconSize)("label",t.label)}}var ze=(()=>{class i{actionsSidenav=Rt.required();_router=n(x);uiEvent=n(pt);dashboard=n(T);app=n(le);_settings=n(M);isAutoNightMode=h(this._settings.getAutoNightModeAsO(),{requireSync:!0});_initialDashboardMatch=(()=>{let e=this._router.parseUrl(this._router.url).root.children.primary,o=e?e.segments.map(r=>r.path):[];return o.length===0||o[0]==="dashboard"||o[0]==="chartplotter"})();isDashboardContext=h(this._router.events.pipe(F(t=>t instanceof st),Mt(null),Q(()=>{let e=this._router.parseUrl(this._router.url).root.children.primary,o=e?e.segments.map(r=>r.path):[];return o.length===0||o[0]==="dashboard"||o[0]==="chartplotter"}),wt()),{initialValue:this._initialDashboardMatch});menuItems=Et(()=>{let t=this.dashboard.dashboards(),e=this.dashboard.activeDashboard();return t.map((o,r)=>({id:Number(o.id),active:r===e,pinned:!1,svgIcon:o.icon||"dashboard-dashboard",iconSize:60,label:o.name||`Dashboard ${r+1}`}))});ngAfterViewInit(){this.uiEvent.addHotkeyListener((t,e)=>this.handleKeyDown(t,e),{ctrlKey:!0,shiftKey:!0,keys:["e","f","n"]})}ngOnDestroy(){this.uiEvent.removeHotkeyListener(this.handleKeyDown.bind(this))}handleKeyDown(t,e){switch(t){case"e":this.onActionItem("layout");break;case"f":this.onActionItem("toggleFullScreen");break;case"n":this.onActionItem("nightMode");break;default:break}}onActionItem(t){switch(this.actionsSidenav().close(),t){case"toggleFullScreen":this.uiEvent.toggleFullScreen();break;case"settings":this._router.navigate(["/settings"]);break;case"layout":this.dashboard.setStaticDashboard(!1);break;case"nightMode":this.app.isNightMode.set(!this.app.isNightMode()),this.app.toggleDayNightMode();break;default:break}}navigateToDashboard(t){this.actionsSidenav().close(),this._router.navigate([`dashboard/${t}`])}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=P({type:i,selectors:[["menu-actions"]],inputs:{actionsSidenav:[1,"actionsSidenav"]},decls:14,vars:3,consts:[["tileContainer",""],["tile",""],[1,"actions-container"],[1,"actions-top-container"],["mat-flat-button","","tabindex","0",1,"action-button","home-btn",3,"click"],["height","24px","width","24px","svgIcon","kip","aria-hidden","false",1,"home-icon",2,"height","24px","width","24px"],[1,"menu-item-container"],[3,"active","svgIcon","iconSize","label"],[1,"actions-bottom-container"],["mat-flat-button","",1,"action-button",2,"width","135px",3,"click","disabled"],[1,"material-icons"],["mat-flat-button","","tabindex","0",1,"action-button"],["mat-flat-button","","tabindex","0",1,"action-button",3,"click"],["mat-flat-button","",1,"action-button"],["mat-flat-button","",1,"action-button",3,"click"],[3,"click","active","svgIcon","iconSize","label"]],template:function(e,o){e&1&&(a(0,"div",2)(1,"div",3),v(2,fi,2,1),v(3,gi,2,1),a(4,"button",4),f("click",function(){return o.onActionItem("settings")}),k(5,"mat-icon",5),s()(),a(6,"div",6,0),K(8,_i,2,4,"tile-large-icon",7,X),s(),a(10,"div",8)(11,"button",9),f("click",function(){return o.onActionItem("layout")}),a(12,"span",10),l(13,"lock_open"),s()()()()),e&2&&(p(2),b(o.uiEvent.fullscreenSupported()?2:-1),p(),b(o.isAutoNightMode()?-1:3),p(5),L(o.menuItems()),p(3),w("disabled",!o.isDashboardContext()))},dependencies:[A,B,N,it,ke],styles:[".actions-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;width:135px}.actions-top-container[_ngcontent-%COMP%]{display:flex;flex-direction:row;flex-wrap:wrap;width:100%}.actions-bottom-container[_ngcontent-%COMP%]{height:48px;width:100%}.action-button[_ngcontent-%COMP%]{border-radius:0;height:48px;flex:1 1 48px;min-height:0;overflow:hidden;border:1px solid var(--mat-sidenav-container-background-color, var(--mat-sys-surface))}.home-btn[_ngcontent-%COMP%]{--mat-icon-button-icon-size: 24px;--mat-button-filled-icon-offset: 0px;--mat-button-filled-icon-spacing: 0px;--mat-button-filled-label-text-size: 0px}.home-icon[_ngcontent-%COMP%] .mat-mdc-unelevated-button[_ngcontent-%COMP%] > .mat-icon[_ngcontent-%COMP%]{font-size:0px}.full-size[_ngcontent-%COMP%]{width:135px}.menu-item-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex-wrap:nowrap;padding:3px 1px;gap:5px;width:135px;overflow-y:auto;scrollbar-width:none;overflow-x:hidden;scroll-behavior:smooth;flex:1 1 auto;min-height:0}"]})}return i})();var He=(()=>{class i{COMMAND_SET_DISPLAY_PATH="self.kip.remote.setDisplay";COMMAND_SET_SCREEN_INDEX_PATH="self.kip.remote.setScreenIndex";COMMAND_REQUEST_ACTIVE_SCREEN_PATH="self.kip.remote.requestActiveScreen";settings=n(M);dashboard=n(T);data=n(H);requests=n(pe);KIP_UUID=this.settings.KipUUID;ACTIVE_SCREEN_PATH=`self.displays.${this.KIP_UUID}.screenIndex`;CHANGE_SCREEN_PATH=`self.displays.${this.KIP_UUID}.activeScreen`;displayName=h(this.settings.getInstanceNameAsO());isRemoteControl=h(this.settings.getIsRemoteControlAsO());remoteScreenPosition=h(this.data.subscribePath(this.ACTIVE_SCREEN_PATH,"default"));changeDashboardTo=h(this.data.subscribePath(this.CHANGE_SCREEN_PATH,"default"));previousIsRemoteControl=!1;constructor(){this.setActiveDashboardOnRemote(this.KIP_UUID,null),this.setScreensOnRemote(this.KIP_UUID,null),this.clearActiveScreenOnRemote(this.KIP_UUID,null),console.log("[Remote Dashboards] Cleaning paths on server"),y(()=>{let t=this.isRemoteControl(),e=this.displayName();W(()=>{if(!t&&!this.previousIsRemoteControl)return;this.previousIsRemoteControl=t;let o;t?(o=this.getScreensPayload(this.dashboard.dashboards()),this.dashboard.activeDashboard()!==null&&this.setActiveDashboardOnRemote(this.KIP_UUID,this.dashboard.activeDashboard())):(o=null,this.clearActiveDashboardOnServer()),this.shareScreens(o)})}),y(()=>{let t=this.dashboard.dashboards();W(()=>{if(!this.isRemoteControl())return;let e=this.getScreensPayload(t);this.shareScreens(e)})}),y(()=>{let t=this.dashboard.activeDashboard();W(()=>{this.isRemoteControl()&&t!==null&&(this.setActiveDashboardOnRemote(this.KIP_UUID,t),console.log(`[Remote Dashboards] Sent new dashboard highlight index ${t} to server.`))})}),y(()=>{let t=this.changeDashboardTo();W(()=>{if(!this.isRemoteControl()||t.data.value==null)return;let e=Number(t.data.value);!isNaN(e)&&e>=0&&e<this.dashboard.dashboards().length&&this.dashboard.activeDashboard()!==e&&(this.dashboard.navigateTo(e),console.log(`[Remote Dashboards] Executed remote request to change active dashboard to: ${e}`))})})}clearActiveDashboardOnServer(){this.setActiveDashboardOnRemote(this.KIP_UUID,null),console.log("[Remote Dashboards] Disabled: Cleared active dashboard on server")}getScreensPayload(t){let e=this.displayName(),o=t.map(m=>{var R=m,{configuration:r}=R,d=St(R,["configuration"]);return d});return{displayName:e,screens:o}}shareScreens(t){this.setScreensOnRemote(this.KIP_UUID,t),console.log("[Remote Dashboards] Sending dashboard configurations to server.")}setActiveDashboardOnRemote(t,e){let o={displayId:t,screenIdx:e};this.requests.putRequest(this.COMMAND_SET_SCREEN_INDEX_PATH,o,this.KIP_UUID)||console.error("[Remote Dashboards] Error sharing active dashboard: request was not accepted")}setScreensOnRemote(t,e){let o={displayId:t,display:e===null?null:Ct({},e)};this.requests.putRequest(this.COMMAND_SET_DISPLAY_PATH,o,this.KIP_UUID)||console.error("[Remote Dashboards] Error sharing screen configuration: request was not accepted")}clearActiveScreenOnRemote(t,e){let o={displayId:t,screenIdx:e};this.requests.putRequest(this.COMMAND_REQUEST_ACTIVE_SCREEN_PATH,o,this.KIP_UUID)||console.error("[Remote Dashboards] Error clearing active screen request path: request was not accepted")}static \u0275fac=function(e){return new(e||i)};static \u0275prov=C({token:i,factory:i.\u0275fac,providedIn:"root"})}return i})();var $e=11,qe="connectionConfig",G=(()=>{class i{config;isLoggedIn=null;loggedInSubscription=null;connection=n(at);auth=n(D);connectionStateMachine=n(V);router=n(x);delta=n(z);data=n(H);storage=n(rt);internetReachability=n(Ie);injector=n(Y);datasetService=null;_bootstrapStatus$=new ft("starting");_bootstrapIssue$=new ft({reason:"none"});constructor(){this.loggedInSubscription=this.auth.isLoggedIn$.subscribe(t=>{this.isLoggedIn=t})}initNetworkServices(){return q(this,null,function*(){let t=!1;this.loadLocalStorageConfig(),this.preloadFonts(),this.internetReachability.start();try{if(this.config?.signalKUrl!==void 0&&this.config.signalKUrl!==null&&(yield this.connection.initializeConnection({url:this.config.signalKUrl,new:!1},this.config.proxyEnabled,this.config.signalKSubscribeAll)),!this.isLoggedIn&&this.config?.signalKUrl&&this.config?.useSharedConfig&&this.config?.loginName&&this.config?.loginPassword&&(yield this.login()),this.isLoggedIn&&this.config?.useSharedConfig)if(yield this.storage.waitUntilReady()){let o=yield this.storage.getConfig("user",this.config.sharedConfigName,$e),r={sharedConfigName:this.config.sharedConfigName,configFileVersion:$e,initConfig:o};this.storage.bootstrapRemoteContext(r)}else throw new Error("[AppInit Network Service] StorageService did not become ready in time. Cannot bootstrap remote configuration.");this._bootstrapIssue$.next({reason:"none"}),yield this.getDatasetService().waitUntilReady(),!this.isLoggedIn&&this.config?.signalKUrl&&this.config?.useSharedConfig&&this.router.navigate(["/login"])}catch(e){if(t=!0,e?.status===404&&this.config?.useSharedConfig){let o=yield this.probeLegacyUpgradeAvailability(this.config.sharedConfigName);this._bootstrapIssue$.next({reason:"missing-shared-config",statusCode:404,sharedConfigName:this.config.sharedConfigName,legacyUpgradeAvailable:o})}else e?.status===0?this._bootstrapIssue$.next({reason:"network-unreachable",statusCode:0}):e?.status===401?this._bootstrapIssue$.next({reason:"unauthorized",statusCode:401}):this._bootstrapIssue$.next({reason:"unknown",statusCode:e?.status});e.status===0?(yield this.waitForHttpRetryCompletion())===nt.HTTPConnected||this.connectionStateMachine.isHTTPConnected()?console.warn("[AppInit Network Service] Initial connection recovered during retry cycle. Skipping fallback route."):(console.warn("[AppInit Network Service] Initialization failed after HTTP retries. Redirecting to settings page."),yield this.router.navigate(["/options"])):e.status===401?(console.warn("[AppInit Network Service] Initialization failed. Unauthorized access. Redirecting to login page."),yield this.router.navigate(["/login"])):(console.warn("[AppInit Network Service] Initialization failed. Error: ",JSON.stringify(e)),yield this.router.navigate(["/options"])),console.warn("[AppInit Network Service] Startup continuing in degraded mode to allow UI feedback."),this._bootstrapStatus$.next("degraded");return}finally{t||this._bootstrapStatus$.next("ready"),console.log("[AppInit Network Service] Initialization completed"),this.connectionStateMachine.enableWebSocketMode(),this.connectionStateMachine.isHTTPConnected()&&(console.log("[AppInit Network Service] Starting WebSocket connection after initialization"),this.connectionStateMachine.startWebSocketConnection())}})}get bootstrapStatus$(){return this._bootstrapStatus$.asObservable()}get bootstrapIssue$(){return this._bootstrapIssue$.asObservable()}getDatasetService(){return this.datasetService||(this.datasetService=this.injector.get($)),this.datasetService}waitForHttpRetryCompletion(t){return q(this,null,function*(){let e=t??this.connectionStateMachine.getHttpRetryWindowMs(2e3),o=new Set([nt.HTTPConnected,nt.PermanentFailure]),r=this.connectionStateMachine.currentState;return o.has(r)?r:new Promise(d=>{let m=window.setTimeout(()=>{R.unsubscribe(),d(null)},e),R=this.connectionStateMachine.state$.subscribe(O=>{o.has(O)&&(clearTimeout(m),R.unsubscribe(),d(O))})})})}probeLegacyUpgradeAvailability(t){return q(this,null,function*(){if(!t)return!1;try{return(yield this.storage.getConfig("user",t,9))?.app?.configVersion===10}catch(e){return!1}})}login(){return q(this,null,function*(){if(!this.isLoggedIn&&this.config.useSharedConfig&&this.config.loginName&&this.config.loginPassword)try{yield this.auth.login({usr:this.config.loginName,pwd:this.config.loginPassword})}catch(t){throw t.status===0?this.router.navigate(["/settings"]):t.status===401&&this.router.navigate(["/login"]),t}})}setLocalStorageConfig(){localStorage.setItem(qe,JSON.stringify(this.config))}loadLocalStorageConfig(){this.config=JSON.parse(localStorage.getItem(qe)),this.config?this.config.signalKUrl||(this.config.signalKUrl=window.location.origin,this.setLocalStorageConfig(),console.log(`[AppInit Network Service] Config found with no server URL. Setting Auto-Discovery URL: ${this.config.signalKUrl}`)):(this.config=Lt,this.config.signalKUrl=window.location.origin,console.log(`[AppInit Network Service] Connection Configuration not found. Creating configuration using Auto-Discovery URL: ${this.config.signalKUrl}`),this.setLocalStorageConfig()),this.config.configVersion==9&&(this.config.configVersion=10,this.setLocalStorageConfig(),console.log("[AppInit Network Service] Upgrading Connection version from 9 to 10")),this.config.configVersion==10&&(this.config.configVersion=11,this.setLocalStorageConfig(),console.log("[AppInit Network Service] Upgrading Connection version from 10 to 11")),this.config.configVersion==11&&(this.config.configVersion=12,this.setLocalStorageConfig(),console.log("[AppInit Network Service] Upgrading Connection version from 11 to 12"))}preloadFonts(){let t=[{family:"Roboto",src:"url(./assets/google-fonts/KFOlCnqEu92Fr1MmSU5fChc4AMP6lbBP.woff2)",options:{weight:"300",style:"normal"}},{family:"Roboto",src:"url(./assets/google-fonts/KFOlCnqEu92Fr1MmSU5fBBc4AMP6lQ.woff2)",options:{weight:"300",style:"normal"}},{family:"Roboto",src:"url(./assets/google-fonts/KFOmCnqEu92Fr1Mu7GxKKTU1Kvnz.woff2)",options:{weight:"400",style:"normal"}},{family:"Roboto",src:"url(./assets/google-fonts/KFOmCnqEu92Fr1Mu4mxKKTU1Kg.woff2)",options:{weight:"400",style:"normal"}},{family:"Roboto",src:"url(./assets/google-fonts/KFOlCnqEu92Fr1MmEU9fChc4AMP6lbBP.woff2)",options:{weight:"500",style:"normal"}},{family:"Roboto",src:"url(./assets/google-fonts/KFOlCnqEu92Fr1MmEU9fBBc4AMP6lQ.woff2)",options:{weight:"500",style:"normal"}}];for(let{family:e,src:o,options:r}of t){let d=new FontFace(e,o,r);d.load().then(()=>document.fonts.add(d)).catch(m=>console.log(`[AppInit Network Service] Error loading fonts: ${m}`))}}ngOnDestroy(){this.loggedInSubscription?.unsubscribe()}static \u0275fac=function(e){return new(e||i)};static \u0275prov=C({token:i,factory:i.\u0275fac})}return i})();var vi=["upgradeMessages"];function bi(i,c){if(i&1&&(a(0,"li"),l(1),s()),i&2){let t=c.$implicit;p(),j(t)}}function Ci(i,c){if(i&1&&(a(0,"ul",11,1),K(2,bi,2,1,"li",null,X),s()),i&2){let t=u(2);p(2),L(t.upgrade.messages())}}function Si(i,c){if(i&1&&(a(0,"div",7)(1,"div",8),k(2,"mat-progress-spinner",9),a(3,"div",10)(4,"h3"),l(5,"Upgrading Configuration\u2026"),s(),a(6,"p"),l(7,"Please wait a moment while we migrate your dashboards and widgets."),s(),v(8,Ci,4,0,"ul",11),s()()()),i&2){let t=u();p(8),b(t.upgrade.messages().length?8:-1)}}var je=(()=>{class i{_deltaService=n(z);_connectionStateMachine=n(V);_appNetworkInit=n(G);_historySeriesReconcile=n(xe);authenticationService=n(D);_dataSet=n($);_dashboard=n(T);_remoteControl=n(He);toast=n(ne);_notifications=n(E);_uiEvent=n(pt);_dialog=n(be);settings=n(M);_responsive=n(Vt);_destroyRef=n(J);_notificationOverlay=n(Be);_router=n(x);upgrade=n(ve);upgradeMessagesRef=et("upgradeMessages");_upgradeShown=!1;actionsSidenavOpened=vt(!1);notificationsSidenavOpened=vt(!1);notificationsInfo=h(this._notifications.observerNotificationsInfo());bootstrapStatus=h(this._appNetworkInit.bootstrapStatus$,{initialValue:"starting"});bootstrapIssue=h(this._appNetworkInit.bootstrapIssue$,{initialValue:{reason:"none"}});dashboardVisible=kt(!1);isPhonePortrait;scheduledOpen=null;OPEN_DELAY_MS=300;missingConfigPromptShown=!1;_swipeLeftHandler=()=>this.onSwipeLeft();_swipeRightHandler=()=>this.onSwipeRight();_hotkeyHandler=t=>this.handleKeyDown(t);constructor(){y(()=>{if(this.settings.configUpgrade()){let t=this.settings.getConfigVersion();t===11&&this.upgrade.runUpgrade(t),t||this._upgradeShown||(this._upgradeShown=!0,this._dialog.openFrameDialog({title:"Upgrade Instructions",component:"upgrade-config"},!0).pipe(U(this._destroyRef)).subscribe())}}),y(()=>{let t=this.upgrade.messages();if(this.upgrade.upgrading()&&t.length&&this.upgradeMessagesRef()){let e=this.upgradeMessagesRef().nativeElement;e.scrollTop=e.scrollHeight}});try{this.dashboardVisible.set(this.isUrlDashboard(this._router.url))}catch(t){}this._router.events.pipe(F(t=>t instanceof st),U(this._destroyRef)).subscribe(t=>{try{this.dashboardVisible.set(this.isUrlDashboard(t.urlAfterRedirects||t.url))}catch(e){}}),y(()=>{let t=this.dashboardVisible()&&this._dashboard.isDashboardStatic()&&this.notificationsInfo().alarmCount>0;if(this.notificationsSidenavOpened()){this.scheduledOpen&&(clearTimeout(this.scheduledOpen),this.scheduledOpen=null);try{this._notificationOverlay.close()}catch(o){}return}if(t){if(this.scheduledOpen)return;this.scheduledOpen=window.setTimeout(()=>{this.scheduledOpen=null;try{this._notificationOverlay.open()}catch(o){}},this.OPEN_DELAY_MS)}else{this.scheduledOpen&&(clearTimeout(this.scheduledOpen),this.scheduledOpen=null);try{this._notificationOverlay.close()}catch(o){}}}),y(()=>{if(this.notificationsSidenavOpened())try{this._notificationOverlay.close()}catch(e){}}),this.isPhonePortrait=h(this._responsive.observe(jt.HandsetPortrait)),this._connectionStateMachine.status$.pipe(U(this._destroyRef)).subscribe(t=>this.displayConnectionsStatusNotification(t)),y(()=>{let t=this.bootstrapIssue();if(t.reason!=="missing-shared-config"||this.missingConfigPromptShown)return;this.missingConfigPromptShown=!0;let e=t.sharedConfigName||"default",o=t.legacyUpgradeAvailable===!0,r=o?"Upgrade":"Create",d=o?`Server is reachable, but no current version shared configuration '${e}' exists for this user. A legacy configuration was found and can be upgraded. Upgrade now?`:`Server is reachable, but no shared configuration '${e}' exists for this user. Create a default configuration now?`;this.toast.show(d,0,!0,"warn",r).onAction().pipe(U(this._destroyRef)).subscribe(()=>{o?this.upgrade.runUpgrade():this.settings.resetSettings()})})}isUrlDashboard(t){if(!t)return!1;let e=t.split("?")[0].replace(/\/+$/,"");return e==="/"||e==="/dashboard"||/^\/dashboard(\/\d+)?$/.test(e)||e==="/chartplotter"||/^\/chartplotter(\/\d+)?$/.test(e)}ngOnInit(){this._uiEvent.addGestureListeners(this._swipeLeftHandler,this._swipeRightHandler)}ngAfterViewInit(){this._uiEvent.addHotkeyListener(this._hotkeyHandler,{ctrlKey:!0,keys:["arrowright","arrowleft"]})}handleKeyDown(t){switch(t){case"arrowright":this.onSwipeRight();break;case"arrowleft":this.onSwipeLeft();break;case"escape":this.backdropClicked();break}}escapeKeyPressed(t){t=t.toLowerCase(),t==="escape"&&this.backdropClicked()}displayConnectionsStatusNotification(t){let e=t.message,o=this.bootstrapStatus()!=="ready";switch(t.operation){case 0:this.toast.show(e,5e3,!0);break;case 1:case 2:break;case 3:this.toast.show(e,3e3,o,"warn");break;case 4:this.toast.show(e,3e3,!0,"info");break;case 5:this.toast.show(e,0,o);break;default:console.error("[AppComponent] Unknown operation code:",t.operation),this.toast.show(`Unknown connection status: ${t.state}`,0,o,"error")}}onSwipeRight(){this._dashboard.isDashboardStatic()&&!this._uiEvent.isDragging()&&(this.isPhonePortrait().matches?(this.actionsSidenavOpened.set(!1),this.notificationsSidenavOpened.set(!0)):(this.actionsSidenavOpened.set(!1),this.notificationsSidenavOpened.update(t=>!t)))}backdropClicked(){this.notificationsSidenavOpened.update(t=>t?!t:!1),this.actionsSidenavOpened.update(t=>t?!t:!1)}onSwipeLeft(){this._dashboard.isDashboardStatic()&&!this._uiEvent.isDragging()&&(this.isPhonePortrait().matches?(this.notificationsSidenavOpened.set(!1),this.actionsSidenavOpened.set(!0)):(this.notificationsSidenavOpened.set(!1),this.actionsSidenavOpened.update(t=>!t)))}ngOnDestroy(){this._uiEvent.removeGestureListeners(this._swipeLeftHandler,this._swipeRightHandler),this._uiEvent.removeHotkeyListener(this._hotkeyHandler),this.scheduledOpen&&(clearTimeout(this.scheduledOpen),this.scheduledOpen=null)}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=P({type:i,selectors:[["app-root"]],viewQuery:function(e,o){e&1&&Z(o.upgradeMessagesRef,vi,5),e&2&&tt()},inputs:{actionsSidenavOpened:[1,"actionsSidenavOpened"],notificationsSidenavOpened:[1,"notificationsSidenavOpened"]},outputs:{actionsSidenavOpened:"actionsSidenavOpenedChange",notificationsSidenavOpened:"notificationsSidenavOpenedChange"},decls:9,vars:6,consts:[["actionsSidenav",""],["upgradeMessages",""],["kipGestures","",1,"sidenav-container",3,"swipeleft","swiperight","backdropClick","mode","bridgeUiEvents"],["mode","over","position","start","autoFocus","true","disableClose","",1,"sidenav-notifications",3,"openedChange","keydown","opened"],["mode","over","position","end","autoFocus","true","disableClose","",1,"sidenav-actions",3,"openedChange","keydown","opened"],[3,"actionsSidenav"],[1,"router-outlet-container"],["role","alert","aria-live","polite",1,"config-upgrade-overlay"],[1,"config-upgrade-card"],["diameter","46","mode","indeterminate"],[1,"config-upgrade-text"],[1,"config-upgrade-messages"]],template:function(e,o){if(e&1){let r=S();a(0,"mat-sidenav-container",2),f("swipeleft",function(){return o.onSwipeLeft()})("swiperight",function(){return o.onSwipeRight()})("backdropClick",function(){return o.backdropClicked()}),a(1,"mat-sidenav",3),_t("openedChange",function(m){return g(r),gt(o.notificationsSidenavOpened,m)||(o.notificationsSidenavOpened=m),_(m)}),f("keydown",function(m){return o.escapeKeyPressed(m.key)}),k(2,"menu-notifications"),s(),a(3,"mat-sidenav",4,0),_t("openedChange",function(m){return g(r),gt(o.actionsSidenavOpened,m)||(o.actionsSidenavOpened=m),_(m)}),f("keydown",function(m){return o.escapeKeyPressed(m.key)}),k(5,"menu-actions",5),s(),a(6,"mat-sidenav-content"),k(7,"router-outlet",6),s()(),v(8,Si,9,1,"div",7)}if(e&2){let r=Pt(4);w("mode","horizontal")("bridgeUiEvents",!0),p(),ht("opened",o.notificationsSidenavOpened),p(2),ht("opened",o.actionsSidenavOpened),p(2),w("actionsSidenav",r),p(3),b(o.upgrade.upgrading()?8:-1)}},dependencies:[Le,ze,N,ge,A,oe,te,De,Pe,Ne,Oe,Ft,Jt,Ae,Te],styles:[".sidenav-container[_ngcontent-%COMP%]{height:100%;width:100%;--mat-sidenav-scrim-color: color-mix(in srgb, var(--mat-sys-neutral-variant20) 70%, transparent)}mat-sidenav-content[_ngcontent-%COMP%]{overflow-y:hidden;overflow-x:hidden}mat-sidenav[_ngcontent-%COMP%]{box-shadow:0 0 1px 0 var(--kip-contrast-color)}mat-sidenav.sidenav-notifications[_ngcontent-%COMP%]{width:230px;z-index:1200}mat-sidenav.sidenav-actions[_ngcontent-%COMP%]{width:135px;z-index:1200;overflow-x:hidden}.config-upgrade-overlay[_ngcontent-%COMP%]{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:#00000073;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);z-index:2000;pointer-events:all}.config-upgrade-card[_ngcontent-%COMP%]{display:flex;flex-direction:row;align-items:center;gap:18px;padding:20px 24px;width:clamp(300px,60vw,640px);background:var(--kip-background, #1f1f1f);border:1px solid rgba(255,255,255,.18);border-radius:14px;color:var(--kip-contrast-color, #fff);box-shadow:0 6px 22px #0000008c}.config-upgrade-text[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0 0 4px;font-size:1.05rem;font-weight:600;letter-spacing:.5px}.config-upgrade-text[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0 0 10px;font-size:.8rem;opacity:.85}.config-upgrade-messages[_ngcontent-%COMP%]{list-style:disc;margin:0;padding-left:18px;max-height:180px;font-size:.68rem;line-height:1.25;scrollbar-width:thin;overflow-y:auto}.config-upgrade-messages[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{margin-bottom:2px}"]})}return i})();var We=(()=>{class i{auth=n(D);authToken=null;authTokenSubscription=null;constructor(){this.authTokenSubscription=this.auth.authToken$.subscribe(t=>{this.authToken=t})}intercept(t,e){let o=t.clone();return this.authToken&&(o=t.clone({headers:t.headers.set("authorization","JWT "+this.authToken.token)})),e.handle(o)}ngOnDestroy(){this.authTokenSubscription?.unsubscribe()}static \u0275fac=function(e){return new(e||i)};static \u0275prov=C({token:i,factory:i.\u0275fac})}return i})();var Ge=(()=>{class i extends ot{_createContainer(){let t=document.createElement("div");t.classList.add("cdk-overlay-container"),(document.getElementById("app-filter-wrapper")||document.querySelector("app-root")||document.body).appendChild(t),this._containerElement=t}static \u0275fac=(()=>{let t;return function(o){return(t||(t=It(i)))(o||i)}})();static \u0275prov=C({token:i,factory:i.\u0275fac})}return i})();var Qe=(()=>{class i{_router=n(x);_dialog=n(re);_bottomSheet=n(Ce);_destroyRef=n(J);constructor(){this._router.events.pipe(F(t=>t instanceof Zt),U(this._destroyRef)).subscribe(()=>{this._dialog.openDialogs.length>0&&this._dialog.closeAll(),this._bottomSheet.dismiss()})}static \u0275fac=function(e){return new(e||i)};static \u0275prov=C({token:i,factory:i.\u0275fac,providedIn:"root"})}return i})();Ue.production&&void 0;Bt(je,{providers:[Ut(),xt(zt),{provide:Ht,useClass:We,multi:!0},{provide:ae,useValue:{hasBackdrop:!0,disableClose:!1,autoFocus:"first-tabbable",delayFocusTrap:!0,backdropClass:"dialogBackdrop"}},{provide:se,useValue:{appearance:"outline",floatLabel:"always",subscriptSizing:"dynamic"}},{provide:me,useValue:{showDelay:1500,hideDelay:0}},D,H,at,z,V,$,T,de,G,M,E,he,rt,Ee(),$t(qt()),ee(Re,ie()),{provide:ot,useClass:Ge},ut(()=>n(G).initNetworkServices()),ut(()=>{n(Qe)})]});