@3deye-toolkit/core 0.0.1-alpha.3 → 0.0.1-alpha.30

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.
package/dist/core.js CHANGED
@@ -1,29 +1 @@
1
- import{observable as e,computed as t,action as n,runInAction as r,reaction as i,when as s}from"mobx";import{Observable as a,empty as o,of as c,throwError as l,timer as u,Subject as h,BehaviorSubject as d}from"rxjs";import{switchMap as f,flatMap as p,retryWhen as v,catchError as m,startWith as b,pairwise as y,filter as g,concatMap as T,delay as E,take as I,takeUntil as O,shareReplay as _,map as w,tap as A,skip as C,share as R}from"rxjs/operators";import S from"jqueryless-signalr";import j from"crossfilter2";
2
- /*! *****************************************************************************
3
- Copyright (c) Microsoft Corporation. All rights reserved.
4
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
5
- this file except in compliance with the License. You may obtain a copy of the
6
- License at http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
10
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
11
- MERCHANTABLITY OR NON-INFRINGEMENT.
12
-
13
- See the Apache Version 2.0 License for specific language governing permissions
14
- and limitations under the License.
15
- ***************************************************************************** */function k(e,t,n,r){var i,s=arguments.length,a=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(a=(s<3?i(a):s>3?i(t,n,a):i(t,n))||a);return s>3&&a&&Object.defineProperty(t,n,a),a}function N(e){return null!=e}function B(){return e=>e.pipe(g(N))}const D={archives:{PopulateArchive:null,GetArchives:null,GetClips:null,UpdateClip:null,DeleteClip:null,SaveClip:null,SaveTimelaps:null,SaveArchive:null,DeleteArchive:null},cameras:{GetCameras:null,GetMotionEvents:null,MoveCamera:null,GoHomePtzCamera:null,SetHomePtzCamera:null,GetSensorDataSchema:null,GetSensorEvents:null},camgroups:{GetCamgroups:null,DeleteCamgroup:null,AddCamgroup:null,UpdateCamgroup:null},sound:{GetPushSoundServiceUrl:null},thumbnails:{GetThumbnailsInfo:null,GetThumbnailInfo:null,GetHeatMapsInfo:null},users:{GetUser:null,UserUpdateProfile:null}},U={cameras:[{name:"OnCameraMotionEvent",explicit:!0},{name:"OnCameraAdded"},{name:"OnCameraUpdated"},{name:"OnSystemCameraUpdated"},{name:"OnCameraDeleted"}],users:[{name:"OnUserUpdateProfile"}],camgroups:[{name:"OnAdd"},{name:"OnUpdate"},{name:"OnDelete"}],archives:[{name:"OnTimelapsAdded"},{name:"OnClipAdded"},{name:"OnClipUpdated"},{name:"OnClipDeleted"},{name:"OnArchiveAdded"},{name:"OnArchiveUpdated"},{name:"OnArchiveDeleted"},{name:"OnArchiveRecordCreated"}]};var P,F;!function(e){e[e.CONNECTING=0]="CONNECTING",e[e.CONNECTED=1]="CONNECTED",e[e.RECONNECTING=2]="RECONNECTING",e[e.DISCONNECTED=3]="DISCONNECTED"}(P||(P={}));class q{constructor(e,t,n){this.connectionShutdown$=new h,this.connection$=new d(null),this.events=new h,this.logging=!1,this.apiConfig=e,this.init(),this.createConnection=n,this.authStore=t,i(()=>t.token,e=>{if(!e)return void this.shutdownConnection();if(e.invalid)return;if(!e.accessToken)return;const t=this.connection$.getValue();t&&t.state!==P.DISCONNECTED?t.qs.access_token=e.accessToken:this.connect(e)}),this.connection$.pipe(f(e=>null!==e?o():!t.isAuthenticated||t.token&&t.token.invalid?o():(this.logging&&console.warn("disconnected by some reason"),u(5e3))),g(()=>t.isAuthenticated&&!!t.token&&!t.token.invalid)).subscribe(()=>{this.connect(t.token),this.logging&&console.warn("attempting to reconnect")}),this.connection$.pipe(B(),E(100)).subscribe(this.subscribeToEvents)}static create(e,t,n){return new q(null!==e?e:D,t,n)}connect(e){if(this.connection$.getValue()&&this.connection$.getValue().state===P.CONNECTED)return;const{accessToken:t}=e,n=this.createConnection(t);Object.keys(this.apiConfig).forEach(e=>n.createHubProxy(e)),Object.entries(U).forEach(([e,t])=>{t&&n.proxies[e]&&t.forEach(({name:t})=>{n.proxies[e].on(t,n=>this.events.next({hub:e,event:t,data:n}))})}),n.start().done(()=>{this.logging&&console.warn("connected"),this.connection$.next(n)}).fail(e=>{if(401===e.source.status||403===e.source.status||409===e.source.status)return this.authStore.invalidateToken()}),n.error(e=>{if(e.source&&(401===e.source.status||403===e.source.status||409===e.source.status))return this.logging&&console.warn("authentication error, invalidating token"),this.authStore.invalidateToken()}),n.disconnected(()=>{this.connection$.getValue()?this.logging&&console.warn("disconnected",this.connection$.getValue().lastError):this.logging&&console.warn("disconnected. this connection is already null"),this.connection$.next(null)}),n.reconnecting(()=>console.log("reconnecting")),n.reconnected(()=>{this.connection$.getValue()===n&&(this.logging&&console.warn("reconnected"),this.connection$.next(n))})}shutdownConnection(){const e=this.connection$.getValue();e&&e.stop(),this.connectionShutdown$.next(null)}init(){Object.keys(this.apiConfig).forEach(e=>{this[e]={},Object.keys(this.apiConfig[e]).forEach(t=>{this[e][t]=this.createHubMethod(e,t)})})}createHubMethod(e,t){const n=this;return function r(...i){return n.connection$.pipe(B(),g(e=>e.state===P.CONNECTED),I(1)).pipe(p(n=>new Promise((r,s)=>{n.proxies[e].invoke(t,...i).done(e=>r(e)).fail(e=>s(e))})),m(e=>!e.message||"Connection started reconnecting before invocation result was received."!==e.message&&"Connection was disconnected before invocation result was received."!==e.message?e.message&&e.message.startsWith("Caller is not authorized to invoke the ")?(console.warn(e.message),n.connection$.getValue().stop(),n.authStore.invalidateToken(),r(...i)):l(e):(console.warn(e.message),r(...i))),O(n.connectionShutdown$))}}subscribeToEvents(e){Object.entries(U).forEach(([t,n])=>{n&&e.proxies[t]&&n.filter(({explicit:e})=>e).forEach(({name:n})=>{e.proxies[t].invoke("SubscribeToEvent",n)})})}}
16
- /*! *****************************************************************************
17
- Copyright (c) Microsoft Corporation. All rights reserved.
18
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
19
- this file except in compliance with the License. You may obtain a copy of the
20
- License at http://www.apache.org/licenses/LICENSE-2.0
21
-
22
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
24
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
25
- MERCHANTABLITY OR NON-INFRINGEMENT.
26
-
27
- See the Apache Version 2.0 License for specific language governing permissions
28
- and limitations under the License.
29
- ***************************************************************************** */function L(e,t,n,r){var i,s=arguments.length,a=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(a=(s<3?i(a):s>3?i(t,n,a):i(t,n))||a);return s>3&&a&&Object.defineProperty(t,n,a),a}function M(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}class x{constructor(e){this.json=e,this.accessToken=e.access_token,this.accessTokenExpires=new Date(e.access_token_expires),this.accessTokenIssued=new Date(e.access_token_issued),this.clientId=e.client_id,this.expiresIn=e.expires_in,this.refreshToken=e.refresh_token,this.refreshTokenExpires=new Date(e.refresh_token_expires),this.refreshTokenIssued=new Date(e.refresh_token_issued),this.tokenType=e.token_type,this.userName=e.userName,this.widgetId=e.widgetId,this.widgetToken=e.widgetToken,this.invalid=!1}}function G(e,n=!1){const r=t(e);return a.create(e=>r.observe(({newValue:t})=>e.next(t),n))}class z{constructor({tokenServiceUrl:e,widgetTokenServiceUrl:t,storage:n,tokenStorageKey:i,deviceInfo:s,clientId:a}){this.token=null,this.isAuthenticating=!1,this.signOut=()=>{this.isAuthenticating||(this.token=null)},this.signIn=({username:e,password:t,tokenToKick:n,agreedWithTerms:i})=>{if(this.isAuthenticating)return;r(()=>this.isAuthenticating=!0);const s={username:e,password:t};return n&&(s.kick_refresh_token=n),i&&(s.agree_with_terms=!0),this.fetchTokenBy("password",s).then(e=>(r(()=>{this.token=e,this.isAuthenticating=!1}),e)).catch(e=>{throw r(()=>{this.isAuthenticating=!1}),e})},this.invalidateToken=()=>{this.token&&(this.token=Object.assign(Object.assign({},this.token),{invalid:!0}))},this.isAuthenticating=!0,this.storage=n,this.tokenServiceUrl=e,this.widgetTokenServiceUrl=t,this.tokenStorageKey=i,this.deviceInfo=s,this.clientId=a,this.getInitialToken().then(e=>{this.token=e,this.isAuthenticating=!1});const h=G(()=>this.token),d=h.pipe(f(e=>{if(null===e)return o();const t=c(e).pipe(p(e=>e.widgetId?this.fetchWidgetToken(e):this.fetchTokenBy("refresh_token",{refresh_token:e.refreshToken})),v(e=>e.pipe(p(e=>!e.status||401!==e.status&&403!==e.status&&409!==e.status?e.error&&"refresh_token_error"===e.error||"invalid_grant"===e.error?l(e):u(5e3):l(e)))));if(!e.invalid){const n=Math.max(.75*(+e.accessTokenExpires-Date.now()),0);return u(n).pipe(p(()=>t))}return t}),m(e=>(console.error(e),this.token=null,d)));d.subscribe(e=>{this.token=e,console.warn("token updated")}),h.pipe(b(null),y(),g(([e,t])=>!!(t||!t&&e)),T(([,e])=>this.storeToken(e))).subscribe()}get isAuthenticated(){return Boolean(this.token&&!this.isAuthenticating)}async getTokenFromStorage(){const e=await this.storage.getItem(this.tokenStorageKey);return e?new x(JSON.parse(e)):null}async storeToken(e){return!e||e.invalid?this.storage.removeItem(this.tokenStorageKey):this.storage.setItem(this.tokenStorageKey,JSON.stringify(e.json))}async getInitialToken(){const e=await this.getTokenFromStorage();if(!e)return null;if(+e.accessTokenExpires>Date.now())return e;if(e.widgetId&&e.widgetToken)return e;if(+e.refreshTokenExpires>Date.now())try{const{refreshToken:t}=e;return await this.fetchTokenBy("refresh_token",{refresh_token:t})}catch(e){this.token=null,this.storeToken(null),console.error("refresh token error",e)}return null}async fetchTokenBy(e,t){const n=Object.assign({grant_type:e,client_id:this.clientId,device:this.deviceInfo},t),r=Object.keys(n).map(e=>`${e}=${encodeURIComponent(n[e])}`).join("&"),i=new Headers;i.append("Content-Type","application/x-www-form-urlencoded"),i.append("accept","application/json");const s=await fetch(this.tokenServiceUrl,{method:"POST",headers:i,body:r});try{const e=await s.json();return 200!==s.status?Promise.reject({status:s.status,data:e}):new x(e)}catch(e){return Promise.reject(s)}}async fetchWidgetToken(e){const{widgetId:t,widgetToken:n}=e;if(!t||!n)throw new Error("token must contain widgetId and widgetToken");if(!this.widgetTokenServiceUrl)throw new Error("please set widgetTokenServiceUrl");const r={widgetId:t,userKey:n},i=new Headers;i.append("Content-Type","application/x-www-form-urlencoded"),i.append("accept","application/json");const s=Object.keys(r).map(e=>`${e}=${encodeURIComponent(r[e])}`).join("&"),a=await fetch(this.widgetTokenServiceUrl,{method:"POST",headers:i,body:s});try{const e=await a.json();return 200!==a.status?Promise.reject({status:a.status,data:e}):new x(Object.assign({widgetId:t,widgetToken:n},e))}catch(e){return Promise.reject(a)}}}L([e,M("design:type",Object)],z.prototype,"token",void 0),L([e,M("design:type",Boolean)],z.prototype,"isAuthenticating",void 0),L([t,M("design:type",Boolean),M("design:paramtypes",[])],z.prototype,"isAuthenticated",null),L([n,M("design:type",Object)],z.prototype,"signOut",void 0),L([n,M("design:type",Object)],z.prototype,"invalidateToken",void 0),function(e){e.Motion="Motion",e.Tampering="Tampering",e.PanTiltZoom="PanTiltZoom",e.CrossLine="CrossLine",e.Start="Start",e.Stop="Stop",e.Restart="Restart",e.Audio="Audio",e.Analytic="Analytic",e.Unknown="Unknown"}(F||(F={}));class H{constructor(){this.values=new Map}getItem(e){return this.values.get(e)||null}setItem(e,t){this.values.set(e,t)}removeItem(e){this.values.delete(e)}}var $="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function W(e,t){return e(t={exports:{}},t.exports),t.exports}var V=W((function(e,t){var n={};n[t.ACCEPTED=202]="Accepted",n[t.BAD_GATEWAY=502]="Bad Gateway",n[t.BAD_REQUEST=400]="Bad Request",n[t.CONFLICT=409]="Conflict",n[t.CONTINUE=100]="Continue",n[t.CREATED=201]="Created",n[t.EXPECTATION_FAILED=417]="Expectation Failed",n[t.FAILED_DEPENDENCY=424]="Failed Dependency",n[t.FORBIDDEN=403]="Forbidden",n[t.GATEWAY_TIMEOUT=504]="Gateway Timeout",n[t.GONE=410]="Gone",n[t.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP Version Not Supported",n[t.IM_A_TEAPOT=418]="I'm a teapot",n[t.INSUFFICIENT_SPACE_ON_RESOURCE=419]="Insufficient Space on Resource",n[t.INSUFFICIENT_STORAGE=507]="Insufficient Storage",n[t.INTERNAL_SERVER_ERROR=500]="Server Error",n[t.LENGTH_REQUIRED=411]="Length Required",n[t.LOCKED=423]="Locked",n[t.METHOD_FAILURE=420]="Method Failure",n[t.METHOD_NOT_ALLOWED=405]="Method Not Allowed",n[t.MOVED_PERMANENTLY=301]="Moved Permanently",n[t.MOVED_TEMPORARILY=302]="Moved Temporarily",n[t.MULTI_STATUS=207]="Multi-Status",n[t.MULTIPLE_CHOICES=300]="Multiple Choices",n[t.NETWORK_AUTHENTICATION_REQUIRED=511]="Network Authentication Required",n[t.NO_CONTENT=204]="No Content",n[t.NON_AUTHORITATIVE_INFORMATION=203]="Non Authoritative Information",n[t.NOT_ACCEPTABLE=406]="Not Acceptable",n[t.NOT_FOUND=404]="Not Found",n[t.NOT_IMPLEMENTED=501]="Not Implemented",n[t.NOT_MODIFIED=304]="Not Modified",n[t.OK=200]="OK",n[t.PARTIAL_CONTENT=206]="Partial Content",n[t.PAYMENT_REQUIRED=402]="Payment Required",n[t.PERMANENT_REDIRECT=308]="Permanent Redirect",n[t.PRECONDITION_FAILED=412]="Precondition Failed",n[t.PRECONDITION_REQUIRED=428]="Precondition Required",n[t.PROCESSING=102]="Processing",n[t.PROXY_AUTHENTICATION_REQUIRED=407]="Proxy Authentication Required",n[t.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="Request Header Fields Too Large",n[t.REQUEST_TIMEOUT=408]="Request Timeout",n[t.REQUEST_TOO_LONG=413]="Request Entity Too Large",n[t.REQUEST_URI_TOO_LONG=414]="Request-URI Too Long",n[t.REQUESTED_RANGE_NOT_SATISFIABLE=416]="Requested Range Not Satisfiable",n[t.RESET_CONTENT=205]="Reset Content",n[t.SEE_OTHER=303]="See Other",n[t.SERVICE_UNAVAILABLE=503]="Service Unavailable",n[t.SWITCHING_PROTOCOLS=101]="Switching Protocols",n[t.TEMPORARY_REDIRECT=307]="Temporary Redirect",n[t.TOO_MANY_REQUESTS=429]="Too Many Requests",n[t.UNAUTHORIZED=401]="Unauthorized",n[t.UNPROCESSABLE_ENTITY=422]="Unprocessable Entity",n[t.UNSUPPORTED_MEDIA_TYPE=415]="Unsupported Media Type",n[t.USE_PROXY=305]="Use Proxy",t.getStatusText=function(e){if(n.hasOwnProperty(e))return n[e];throw new Error("Status code does not exist: "+e)},t.getStatusCode=function(e){for(key in n)if(n[key]===e)return parseInt(key,10);throw new Error("Reason phrase does not exist: "+e)}}));V.ACCEPTED,V.BAD_GATEWAY,V.BAD_REQUEST,V.CONFLICT,V.CONTINUE,V.CREATED,V.EXPECTATION_FAILED,V.FAILED_DEPENDENCY,V.FORBIDDEN,V.GATEWAY_TIMEOUT,V.GONE,V.HTTP_VERSION_NOT_SUPPORTED,V.IM_A_TEAPOT,V.INSUFFICIENT_SPACE_ON_RESOURCE,V.INSUFFICIENT_STORAGE,V.INTERNAL_SERVER_ERROR,V.LENGTH_REQUIRED,V.LOCKED,V.METHOD_FAILURE,V.METHOD_NOT_ALLOWED,V.MOVED_PERMANENTLY,V.MOVED_TEMPORARILY,V.MULTI_STATUS,V.MULTIPLE_CHOICES,V.NETWORK_AUTHENTICATION_REQUIRED,V.NO_CONTENT,V.NON_AUTHORITATIVE_INFORMATION,V.NOT_ACCEPTABLE,V.NOT_FOUND,V.NOT_IMPLEMENTED,V.NOT_MODIFIED,V.OK,V.PARTIAL_CONTENT,V.PAYMENT_REQUIRED,V.PERMANENT_REDIRECT,V.PRECONDITION_FAILED,V.PRECONDITION_REQUIRED,V.PROCESSING,V.PROXY_AUTHENTICATION_REQUIRED,V.REQUEST_HEADER_FIELDS_TOO_LARGE,V.REQUEST_TIMEOUT,V.REQUEST_TOO_LONG,V.REQUEST_URI_TOO_LONG,V.REQUESTED_RANGE_NOT_SATISFIABLE,V.RESET_CONTENT,V.SEE_OTHER,V.SERVICE_UNAVAILABLE,V.SWITCHING_PROTOCOLS,V.TEMPORARY_REDIRECT,V.TOO_MANY_REQUESTS,V.UNAUTHORIZED,V.UNPROCESSABLE_ENTITY,V.UNSUPPORTED_MEDIA_TYPE,V.USE_PROXY,V.getStatusText,V.getStatusCode;let Q=[];function Y(){return Array.isArray(Q)?Q[0]:Q}class K{initWith(e){this.api=e,this.afterInit&&this.afterInit()}}class J extends K{constructor(e){super(),this.notification=e,this.user=null,this.camerasPermissions=new Map,s(()=>!!this.user,()=>this.fetchPermissions())}get userDisplayName(){return this.user?this.user.firstName&&this.user.firstName.trim()||this.user.lastName&&this.user.lastName.trim()?[this.user.firstName,this.user.lastName].filter(Boolean).join(" ").trim():this.user.email:null}afterInit(){this.api.users.GetUser().subscribe(e=>this.user=e.resultItems[0])}setAuthStore(e){this.auth=e}async updateUserPassword(e){var t,n;const r=Y().changePasswordUrl,i=null===(n=null===(t=this.auth)||void 0===t?void 0:t.token)||void 0===n?void 0:n.accessToken,s=JSON.stringify({currentPassword:e.previous,newPassword:e.new}),a=new Headers;a.append("content-type","application/json"),a.append("accept","application/json"),a.append("authorization",`bearer ${i}`);const o=await fetch(r,{method:"PUT",headers:a,body:s}),{status:c}=o;if(c!==V.OK){const e=await o.json();throw new Error(e.errors[0].message)}}async fetchPermissions(){var e,t;if(!Y())return;const n=Y().userPermissionsUrl;if(!n)return console.warn("user permissions URL is missing in config");const r=null===(t=null===(e=this.auth)||void 0===e?void 0:e.token)||void 0===t?void 0:t.accessToken,i=new Headers;i.append("content-type","application/json"),i.append("accept","application/json"),i.append("authorization",`bearer ${r}`);const s=await fetch(n,{headers:i}),{status:a}=s;if(a!==V.OK){const e=await s.json();throw new Error(e.errors[0].message)}(await s.json()).securables.forEach(e=>{"camera"===e.securableType&&this.camerasPermissions.set(e.securableId,e.permissions)})}updateUserSettings({firstName:e,lastName:t}){if(!this.user)return l("user is not initialized");const n={id:this.user.id,firstName:e,lastName:t,version:this.user.version},r=this.api.users.UserUpdateProfile(n).pipe(p(e=>e.success?c(e.resultItems[0]):l(e.error)),_());return r.subscribe(e=>{this.user=e}),r}setDefaultGroup(e){if(!this.user)return;const t={id:this.user.id,layoutStartId:e,layoutStartType:"camgroup",version:this.user.version},n=this.api.users.UserUpdateProfile(t).pipe(p(e=>e.success?c(e.resultItems[0]):l(e.error)),_());return n.subscribe(e=>{var t;this.user=e,null===(t=this.notification)||void 0===t||t.success("Successfully set default group")},e=>{var t;console.error(e),null===(t=this.notification)||void 0===t||t.error(e.message)}),n}}k([e.ref],J.prototype,"user",void 0),k([e],J.prototype,"camerasPermissions",void 0),k([t],J.prototype,"userDisplayName",null);class X{constructor(e){this.isLive=!1,this.json=JSON.stringify(e,null,2),this.startTime=new Date(e.startTime),this.endTime=new Date(e.endTime),this.streamUrl=e.streamUrl,this.cameraId=e.cameraId,this.duration=e.duration,this.id=e.id}}window.ArchiveChunk=X;class Z extends K{constructor(){super(),this.chunksById=new Map,this.knownIntervals=new Map,this.updates=0,this.data=j(),this.chunksByCameraId=this.data.dimension(e=>e.cameraId),this.chunksByStart=this.data.dimension(e=>+e.startTime),this.chunksByEnd=this.data.dimension(e=>+e.endTime),this.pendingRequests=j(),this.pendingRequestsByStart=this.pendingRequests.dimension(e=>+e.startTime),this.pendingRequestsByEnd=this.pendingRequests.dimension(e=>+e.endTime),this.pendingRequestsByCameraId=this.pendingRequests.dimension(e=>e.cameraId)}fetch(e,t,n){this.pendingRequestsByCameraId.filter(e),this.pendingRequestsByStart.filter(t),this.pendingRequestsByEnd.filter(n);const r=this.pendingRequests.allFiltered()[0];if(this.pendingRequestsByCameraId.filterAll(),this.pendingRequestsByStart.filterAll(),this.pendingRequestsByEnd.filterAll(),r)return r.request;if(this.knownIntervals.has(e)){const[r,i]=this.knownIntervals.get(e);if(r<=t&&i>=n)return c(this.getChunks({cameraId:e,from:t,to:n}));r<=t&&i<n&&(t=i),r>t&&i>=n&&(n=r),n<r&&(n=r),t>i&&(t=i)}const i=this.api.archives.PopulateArchive({cameraId:e,startTime:t,endTime:n}).pipe(w(e=>e.resultItems[0].chunks.map(e=>new X(e))),A(this.add),A(t=>this.extendKnownInterval(e,t)),_());return this.pendingRequests.add([{cameraId:e,startTime:t,endTime:n,request:i}]),i.pipe(A(()=>this.pendingRequests.remove(e=>e.request===i))).subscribe(),i}extendKnownInterval(e,t){const n=new Date(Math.min(...t.map(e=>+e.startTime))),r=new Date(Math.max(...t.map(e=>+e.endTime)));if(this.knownIntervals.has(e)){const t=this.knownIntervals.get(e);n<t[0]&&(t[0]=n),r>t[1]&&(t[1]=r)}else this.knownIntervals.set(e,[n,r])}add(e){const t=e.filter(e=>!this.chunksById.has(e.id));t.forEach(e=>this.chunksById.set(e.id,e)),this.data.add(t),t.length&&this.updates++}getChunks({cameraId:e,from:t,to:n}){this.chunksByStart.filter([-1/0,+n+5e-4]),this.chunksByEnd.filter([t,1/0]),e&&this.chunksByCameraId.filter(e);const r=this.chunksByStart.top(1/0);return e&&this.chunksByCameraId.filterAll(),this.chunksByStart.filterAll(),this.chunksByEnd.filterAll(),r}findClosestChunk({cameraId:e,time:t}){this.chunksByCameraId.filter(e),this.chunksByEnd.filter([t,1/0]);const n=this.chunksByStart.bottom(1);return this.chunksByCameraId.filterAll(),this.chunksByEnd.filterAll(),n[0]}afterInit(){this.api.events.pipe(g(({hub:e,event:t})=>"archives"===e&&"OnArchiveChunksCreated"===t)).subscribe(({data:e})=>{this.add(e.resultItems.map(e=>new X(e)))})}}var ee,te;k([e],Z.prototype,"updates",void 0),k([n.bound],Z.prototype,"add",null);var ne=0;function re(e){return e>=48&&e<=57}function ie(e,t){for(var n=(e+="").length,r=(t+="").length,i=0,s=0;i<n&&s<r;){var a=e.charCodeAt(i),o=t.charCodeAt(s);if(re(a)){if(!re(o))return a-o;for(var c=i,l=s;48===a&&++c<n;)a=e.charCodeAt(c);for(;48===o&&++l<r;)o=t.charCodeAt(l);for(var u=c,h=l;u<n&&re(e.charCodeAt(u));)++u;for(;h<r&&re(t.charCodeAt(h));)++h;var d=u-c-h+l;if(d)return d;for(;c<u;)if(d=e.charCodeAt(c++)-t.charCodeAt(l++))return d;i=u,s=h}else{if(a!==o)return a<ne&&o<ne&&-1!==te[a]&&-1!==te[o]?te[a]-te[o]:a-o;++i,++s}}return i>=n&&s<r&&n>=r?-1:s>=r&&i<n&&r>=n?1:n-r}ie.caseInsensitive=ie.i=function(e,t){return ie((""+e).toLowerCase(),(""+t).toLowerCase())},Object.defineProperties(ie,{alphabet:{get:function(){return ee},set:function(e){te=[];var t=0;if(ee=e)for(;t<ee.length;t++)te[ee.charCodeAt(t)]=t;for(ne=te.length,t=0;t<ne;t++)void 0===te[t]&&(te[t]=-1)}}});var se,ae=ie;class oe{constructor(e){this.update(e)}get isOnline(){return this.enabled&&"Started"===this.state}get supportsWebRTC(){return!!this.webRtcUrl}update(e){this.raw=e,this.id=e.id,this.name=e.name,this.isPtz=e.isPTZ,this.isMicEnabled=e.isMicEnabled,this.imageUrl=e.imageUrl,this.address=e.cameraAddress?JSON.parse(e.cameraAddress):null,this.streamUrl=e.dashStreamUrl,this.enabled=e.enabled,this.state=this.raw.cameraState,this.dvrWindowLength=e.dvrWindowLength?1e3*e.dvrWindowLength:e.dvrWindowLength,this.archiveDuration=e.archiveDuration,this.pin=e.pin,this.webRtcUrl=e.webRtcUrl,this.stateUpdatedAt=new Date(e.cameraStateChangedTime)}}k([e],oe.prototype,"name",void 0),k([e],oe.prototype,"streamUrl",void 0),k([e],oe.prototype,"enabled",void 0),k([e],oe.prototype,"isMicEnabled",void 0),k([e],oe.prototype,"state",void 0),k([e],oe.prototype,"pin",void 0),k([e],oe.prototype,"webRtcUrl",void 0),k([t],oe.prototype,"isOnline",null),k([n.bound],oe.prototype,"update",null);class ce extends K{constructor(){super(),this.camerasById=new Map,this.data=[],this.loading=!0,this.sync=()=>{const e=this.data.reduce((e,t)=>Math.max(e,+t.stateUpdatedAt),0);e&&this.api.cameras.GetCameras({},new Date(1e3*(Math.floor(e/1e3)+1))).pipe(w(e=>e.resultItems)).subscribe(e=>this.add(e))},s(()=>!this.loading,()=>{this.api.connection$.pipe(C(1)).subscribe(this.sync)})}fetch(){const e=this.api.cameras.GetCameras({},null).pipe(w(e=>e.resultItems),R());return e.subscribe(e=>{r(()=>{this.add(e),this.loading=!1})}),e}add(e){e.forEach(e=>{this.camerasById.has(e.id)?this.camerasById.get(e.id).update(e):this.camerasById.set(e.id,new oe(e))}),this.data=Array.from(this.camerasById.values()).sort((e,t)=>ae.caseInsensitive(e.name,t.name))}afterInit(){this.api.events.pipe(g(({hub:e,event:t})=>"cameras"===e&&("OnCameraUpdated"===t||"OnSystemCameraUpdated"===t)),w(({data:e})=>e.resultItems?e.resultItems[0]:e)).subscribe(e=>{const t=this.camerasById.get(e.id);if(!t)return console.warn("got update for unknown camera:",e.id);t.update(e)})}}k([e.ref],ce.prototype,"data",void 0),k([e],ce.prototype,"loading",void 0),k([n.bound],ce.prototype,"add",null),function(e){e.Default="Default",e.Analytic="Analytic"}(se||(se={}));class le{constructor(e){if(this.raw=e,this.id=e.id,this.startTime=new Date(e.startTime),e.endTime&&(this.endTime=new Date(e.endTime)),this.cameraId=e.cameraId,e.data.startsWith("{"))try{const t=JSON.parse(e.data);t.FoundObjects&&(this.type=se.Analytic,"ColorClusters"in t.FoundObjects[0]&&t.FoundObjects.forEach(e=>{e.Colors=e.ColorClusters.map(e=>({Color:e.ColorName}))}),this.foundObjects=t.FoundObjects),t.Faces&&(this.type=se.Analytic,this.faces=t.Faces),this.thumbnailUrl=t.ThumbnailUrl}catch(t){console.warn("invalid data",e.data),this.type=se.Default}else this.type=se.Default;this.type===se.Default&&+this.endTime-+this.startTime==0&&Date.now()-+this.startTime>6e5&&(this.endTime=new Date(+this.startTime+12e4)),this.foundObjects||(this.foundObjects=[])}get isLive(){return this.type===se.Default&&+this.startTime==+this.endTime}}k([e],le.prototype,"endTime",void 0);class ue{constructor(e){this.eventsStore=e,this.data=[],this.cameraFilters=[],this.objectFilters=[],this.loading=!1,this.probabilityThreshold=.5,this.facesProbabilityThreshold=.7,this.onlyFaces=!1,this.totalCount=0,this.facesCount=0,this.title="menu.events",this.pendingData=[],this.paused=!1,this.updates=0,this.colors=new Set,this.flushUpdates=()=>{this.pendingData=[],this.updates++},this.isAboveThreshold=e=>{if(e.type!==se.Analytic)return!0;if(!this.objectFilters.length)return!0;const t=this.objectFilters.map(e=>e.id);return!(!e.faces||!e.faces.some(e=>e.Probability>=this.probabilityThreshold))||e.foundObjects.some(e=>{const n=t.includes(e.Type)&&e.Probability>=this.probabilityThreshold;return this.colors.size?n&&e.Colors.some(e=>this.colors.has(e.Color)):n})},this.hasFacesAboveThreshold=e=>!(!e.faces||!e.faces.length)&&e.faces.some(e=>e.Probability>=this.facesProbabilityThreshold),this.getProbabilityTreshold=()=>this.probabilityThreshold,this.setProbabilityTreshold=e=>{this.probabilityThreshold=e},this.getFacesProbabilityTreshold=()=>this.facesProbabilityThreshold,this.setFacesProbabilityTreshold=e=>{this.facesProbabilityThreshold=e},G(()=>this.paused,!0).pipe(f(t=>G(t?()=>({updates:this.updates,from:this.from,to:this.to,filters:this.filters,onlyFaces:this.onlyFaces,probabilityThreshold:this.probabilityThreshold,facesProbabilityThreshold:this.facesProbabilityThreshold,colors:this.colors}):()=>({updates:e.updates,from:this.from,to:this.to,filters:this.filters,onlyFaces:this.onlyFaces,probabilityThreshold:this.probabilityThreshold,facesProbabilityThreshold:this.facesProbabilityThreshold,colors:this.colors})))).subscribe(({from:t,to:n,onlyFaces:i,colors:s})=>{const a=this.cameraFilters.map(e=>e.id),o=this.objectFilters.map(e=>e.id),c={from:t,to:n};a.length&&(c.cameraIds=a);const l={};o.length&&(l.objectType=o,s.size&&(l.colors=s)),r(()=>{if(i){const t=e.getEvents(Object.assign(Object.assign({},c),l)).filter(this.isAboveThreshold);this.totalCount=t.length,this.data=e.getEvents(c).filter(e=>e.faces&&e.faces.length).filter(this.hasFacesAboveThreshold),this.facesCount=this.data.length}else this.data=e.getEvents(Object.assign(Object.assign({},c),l)).filter(this.isAboveThreshold),this.totalCount=this.data.length,this.facesCount=e.getEvents(c).filter(this.hasFacesAboveThreshold).length})}),G(()=>this.paused,!0).pipe(f(t=>t?G(()=>e.recentAdditions):o())).subscribe(t=>{const n=t.map(t=>e.eventsById.get(t)).filter(Boolean),{from:r,to:i,onlyFaces:s}=this,a=this.cameraFilters.map(e=>e.id);let o=n;a&&(o=o.filter(e=>a.includes(e.cameraId))),r&&(o=o.filter(e=>e.startTime>=r)),i&&(o=o.filter(e=>e.endTime<=i)),s?o=o.filter(this.hasFacesAboveThreshold):this.objectFilters.length&&(o=o.filter(this.isAboveThreshold),this.colors.size&&o.filter(e=>e.foundObjects.some(e=>e.Colors.some(e=>this.colors.has(e.Color))))),o.length&&(this.pendingData=this.pendingData.concat(o))}),G(()=>({from:this.from,to:this.to})).pipe(f(({from:e,to:t})=>(this.loading=!0,this.eventsStore.fetchEvents(-1,e,t)))).subscribe(()=>{this.loading=!1})}get someAnalyticsFilterSelected(){return!!this.objectFilters.length}get filters(){return this.onlyFaces?this.cameraFilters:this.objectFilters.concat(this.cameraFilters)}toggleFaces(){this.onlyFaces=!this.onlyFaces}load(){this.from=new Date(Date.now()-864e5),this.to=null,this.loading=!1}setFilters(e){this.cameraFilters=e?e.filter(e=>!("isEventType"in e)):[],this.onlyFaces||(this.objectFilters=e?e.filter(e=>"isEventType"in e):[])}toggleColor(e){const t=new Set(this.colors);this.colors.has(e)?t.delete(e):t.add(e),this.colors=t}clearColors(){this.colors=new Set}}k([e.ref],ue.prototype,"data",void 0),k([e.ref],ue.prototype,"cameraFilters",void 0),k([e.ref],ue.prototype,"objectFilters",void 0),k([e],ue.prototype,"to",void 0),k([e],ue.prototype,"from",void 0),k([e],ue.prototype,"loading",void 0),k([e],ue.prototype,"probabilityThreshold",void 0),k([e],ue.prototype,"facesProbabilityThreshold",void 0),k([e],ue.prototype,"onlyFaces",void 0),k([e],ue.prototype,"totalCount",void 0),k([e],ue.prototype,"facesCount",void 0),k([e.ref],ue.prototype,"pendingData",void 0),k([e],ue.prototype,"paused",void 0),k([e],ue.prototype,"updates",void 0),k([e.ref],ue.prototype,"colors",void 0),k([t],ue.prototype,"someAnalyticsFilterSelected",null),k([t],ue.prototype,"filters",null),k([n],ue.prototype,"flushUpdates",void 0),k([n.bound],ue.prototype,"toggleFaces",null),k([n],ue.prototype,"load",null),k([n.bound],ue.prototype,"toggleColor",null),k([n.bound],ue.prototype,"clearColors",null);var he={red:{50:"#ffebee",100:"#ffcdd2",200:"#ef9a9a",300:"#e57373",400:"#ef5350",500:"#f44336",600:"#e53935",700:"#d32f2f",800:"#c62828",900:"#b71c1c",a100:"#ff8a80",a200:"#ff5252",a400:"#ff1744",a700:"#d50000"},pink:{50:"#fce4ec",100:"#f8bbd0",200:"#f48fb1",300:"#f06292",400:"#ec407a",500:"#e91e63",600:"#d81b60",700:"#c2185b",800:"#ad1457",900:"#880e4f",a100:"#ff80ab",a200:"#ff4081",a400:"#f50057",a700:"#c51162"},purple:{50:"#f3e5f5",100:"#e1bee7",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",600:"#8e24aa",700:"#7b1fa2",800:"#6a1b9a",900:"#4a148c",a100:"#ea80fc",a200:"#e040fb",a400:"#d500f9",a700:"#aa00ff"},deepPurple:{50:"#ede7f6",100:"#d1c4e9",200:"#b39ddb",300:"#9575cd",400:"#7e57c2",500:"#673ab7",600:"#5e35b1",700:"#512da8",800:"#4527a0",900:"#311b92",a100:"#b388ff",a200:"#7c4dff",a400:"#651fff",a700:"#6200ea"},indigo:{50:"#e8eaf6",100:"#c5cae9",200:"#9fa8da",300:"#7986cb",400:"#5c6bc0",500:"#3f51b5",600:"#3949ab",700:"#303f9f",800:"#283593",900:"#1a237e",a100:"#8c9eff",a200:"#536dfe",a400:"#3d5afe",a700:"#304ffe"},blue:{50:"#e3f2fd",100:"#bbdefb",200:"#90caf9",300:"#64b5f6",400:"#42a5f5",500:"#2196f3",600:"#1e88e5",700:"#1976d2",800:"#1565c0",900:"#0d47a1",a100:"#82b1ff",a200:"#448aff",a400:"#2979ff",a700:"#2962ff"},lightBlue:{50:"#e1f5fe",100:"#b3e5fc",200:"#81d4fa",300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",600:"#039be5",700:"#0288d1",800:"#0277bd",900:"#01579b",a100:"#80d8ff",a200:"#40c4ff",a400:"#00b0ff",a700:"#0091ea"},cyan:{50:"#e0f7fa",100:"#b2ebf2",200:"#80deea",300:"#4dd0e1",400:"#26c6da",500:"#00bcd4",600:"#00acc1",700:"#0097a7",800:"#00838f",900:"#006064",a100:"#84ffff",a200:"#18ffff",a400:"#00e5ff",a700:"#00b8d4"},teal:{50:"#e0f2f1",100:"#b2dfdb",200:"#80cbc4",300:"#4db6ac",400:"#26a69a",500:"#009688",600:"#00897b",700:"#00796b",800:"#00695c",900:"#004d40",a100:"#a7ffeb",a200:"#64ffda",a400:"#1de9b6",a700:"#00bfa5"},green:{50:"#e8f5e9",100:"#c8e6c9",200:"#a5d6a7",300:"#81c784",400:"#66bb6a",500:"#4caf50",600:"#43a047",700:"#388e3c",800:"#2e7d32",900:"#1b5e20",a100:"#b9f6ca",a200:"#69f0ae",a400:"#00e676",a700:"#00c853"},lightGreen:{50:"#f1f8e9",100:"#dcedc8",200:"#c5e1a5",300:"#aed581",400:"#9ccc65",500:"#8bc34a",600:"#7cb342",700:"#689f38",800:"#558b2f",900:"#33691e",a100:"#ccff90",a200:"#b2ff59",a400:"#76ff03",a700:"#64dd17"},lime:{50:"#f9fbe7",100:"#f0f4c3",200:"#e6ee9c",300:"#dce775",400:"#d4e157",500:"#cddc39",600:"#c0ca33",700:"#afb42b",800:"#9e9d24",900:"#827717",a100:"#f4ff81",a200:"#eeff41",a400:"#c6ff00",a700:"#aeea00"},yellow:{50:"#fffde7",100:"#fff9c4",200:"#fff59d",300:"#fff176",400:"#ffee58",500:"#ffeb3b",600:"#fdd835",700:"#fbc02d",800:"#f9a825",900:"#f57f17",a100:"#ffff8d",a200:"#ffff00",a400:"#ffea00",a700:"#ffd600"},amber:{50:"#fff8e1",100:"#ffecb3",200:"#ffe082",300:"#ffd54f",400:"#ffca28",500:"#ffc107",600:"#ffb300",700:"#ffa000",800:"#ff8f00",900:"#ff6f00",a100:"#ffe57f",a200:"#ffd740",a400:"#ffc400",a700:"#ffab00"},orange:{50:"#fff3e0",100:"#ffe0b2",200:"#ffcc80",300:"#ffb74d",400:"#ffa726",500:"#ff9800",600:"#fb8c00",700:"#f57c00",800:"#ef6c00",900:"#e65100",a100:"#ffd180",a200:"#ffab40",a400:"#ff9100",a700:"#ff6d00"},deepOrange:{50:"#fbe9e7",100:"#ffccbc",200:"#ffab91",300:"#ff8a65",400:"#ff7043",500:"#ff5722",600:"#f4511e",700:"#e64a19",800:"#d84315",900:"#bf360c",a100:"#ff9e80",a200:"#ff6e40",a400:"#ff3d00",a700:"#dd2c00"},brown:{50:"#efebe9",100:"#d7ccc8",200:"#bcaaa4",300:"#a1887f",400:"#8d6e63",500:"#795548",600:"#6d4c41",700:"#5d4037",800:"#4e342e",900:"#3e2723"},grey:{50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121"},blueGrey:{50:"#eceff1",100:"#cfd8dc",200:"#b0bec5",300:"#90a4ae",400:"#78909c",500:"#607d8b",600:"#546e7a",700:"#455a64",800:"#37474f",900:"#263238"},darkText:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.54)",disabled:"rgba(0, 0, 0, 0.38)",dividers:"rgba(0, 0, 0, 0.12)"},lightText:{primary:"rgba(255, 255, 255, 1)",secondary:"rgba(255, 255, 255, 0.7)",disabled:"rgba(255, 255, 255, 0.5)",dividers:"rgba(255, 255, 255, 0.12)"},darkIcons:{active:"rgba(0, 0, 0, 0.54)",inactive:"rgba(0, 0, 0, 0.38)"},lightIcons:{active:"rgba(255, 255, 255, 1)",inactive:"rgba(255, 255, 255, 0.5)"},white:"#ffffff",black:"#000000"};const de={Person:"red",Car:"green",Animal:"blue"},fe=["green","red","blue","purple","teal","amber","pink","blueGrey","cyan","yellow","lightGreen","brown","lime","deepOrange","grey","indigo","orange","deepPurple","lightBlue"];class pe extends K{constructor(){super(...arguments),this.schemaDescription=[],this.fetchAnalyticEventSchema=()=>{this.api.cameras.GetSensorDataSchema(F.Analytic).subscribe(e=>{e.success?this.schemaDescription=e.resultItems:console.error(e)},console.error)}}get foundObjectTypes(){if(!this.schemaDescription.length)return[];const e=this.schemaDescription.filter(e=>"filter"===e.parameterType&&"Type"===e.fieldName&&e.eventType===F.Analytic)[0];return e?e.valueSet.split(", "):[]}get foundObjectTypesForSelect(){const e=Object.entries(de).filter(([e])=>this.foundObjectTypes.includes(e)).map(([,e])=>e),t=fe.filter(t=>!e.includes(t));return this.foundObjectTypes.map((e,n)=>{const r=e in de?de[e]:t[n],i=he[r],s=he[r];return{id:e,name:e.toLowerCase(),color:i[500],highlightColor:s.a400,isEventType:!0}})}get colorsByFoundObjectType(){const e=new Map;return this.foundObjectTypesForSelect.forEach(t=>{e.set(t.id,t.highlightColor)}),e}afterInit(){this.fetchAnalyticEventSchema()}}k([e.ref],pe.prototype,"schemaDescription",void 0),k([t],pe.prototype,"foundObjectTypes",null),k([t],pe.prototype,"foundObjectTypesForSelect",null),k([t],pe.prototype,"colorsByFoundObjectType",null);var ve=function(e,t,n,r){for(var i=-1,s=null==e?0:e.length;++i<s;){var a=e[i];t(r,a,n(a),e)}return r};var me=function(e){return function(t,n,r){for(var i=-1,s=Object(t),a=r(t),o=a.length;o--;){var c=a[e?o:++i];if(!1===n(s[c],c,s))break}return t}}();var be=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r},ye="object"==typeof $&&$&&$.Object===Object&&$,ge="object"==typeof self&&self&&self.Object===Object&&self,Te=ye||ge||Function("return this")(),Ee=Te.Symbol,Ie=Object.prototype,Oe=Ie.hasOwnProperty,_e=Ie.toString,we=Ee?Ee.toStringTag:void 0;var Ae=function(e){var t=Oe.call(e,we),n=e[we];try{e[we]=void 0;var r=!0}catch(e){}var i=_e.call(e);return r&&(t?e[we]=n:delete e[we]),i},Ce=Object.prototype.toString;var Re=function(e){return Ce.call(e)},Se=Ee?Ee.toStringTag:void 0;var je=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Se&&Se in Object(e)?Ae(e):Re(e)};var ke=function(e){return null!=e&&"object"==typeof e};var Ne=function(e){return ke(e)&&"[object Arguments]"==je(e)},Be=Object.prototype,De=Be.hasOwnProperty,Ue=Be.propertyIsEnumerable,Pe=Ne(function(){return arguments}())?Ne:function(e){return ke(e)&&De.call(e,"callee")&&!Ue.call(e,"callee")},Fe=Array.isArray;var qe=function(){return!1},Le=W((function(e,t){var n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,i=r&&r.exports===n?Te.Buffer:void 0,s=(i?i.isBuffer:void 0)||qe;e.exports=s})),Me=/^(?:0|[1-9]\d*)$/;var xe=function(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&Me.test(e))&&e>-1&&e%1==0&&e<t};var Ge=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991},ze={};ze["[object Float32Array]"]=ze["[object Float64Array]"]=ze["[object Int8Array]"]=ze["[object Int16Array]"]=ze["[object Int32Array]"]=ze["[object Uint8Array]"]=ze["[object Uint8ClampedArray]"]=ze["[object Uint16Array]"]=ze["[object Uint32Array]"]=!0,ze["[object Arguments]"]=ze["[object Array]"]=ze["[object ArrayBuffer]"]=ze["[object Boolean]"]=ze["[object DataView]"]=ze["[object Date]"]=ze["[object Error]"]=ze["[object Function]"]=ze["[object Map]"]=ze["[object Number]"]=ze["[object Object]"]=ze["[object RegExp]"]=ze["[object Set]"]=ze["[object String]"]=ze["[object WeakMap]"]=!1;var He=function(e){return ke(e)&&Ge(e.length)&&!!ze[je(e)]};var $e=function(e){return function(t){return e(t)}},We=W((function(e,t){var n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,i=r&&r.exports===n&&ye.process,s=function(){try{var e=r&&r.require&&r.require("util").types;return e||i&&i.binding&&i.binding("util")}catch(e){}}();e.exports=s})),Ve=We&&We.isTypedArray,Qe=Ve?$e(Ve):He,Ye=Object.prototype.hasOwnProperty;var Ke=function(e,t){var n=Fe(e),r=!n&&Pe(e),i=!n&&!r&&Le(e),s=!n&&!r&&!i&&Qe(e),a=n||r||i||s,o=a?be(e.length,String):[],c=o.length;for(var l in e)!t&&!Ye.call(e,l)||a&&("length"==l||i&&("offset"==l||"parent"==l)||s&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||xe(l,c))||o.push(l);return o},Je=Object.prototype;var Xe=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Je)};var Ze=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object),et=Object.prototype.hasOwnProperty;var tt=function(e){if(!Xe(e))return Ze(e);var t=[];for(var n in Object(e))et.call(e,n)&&"constructor"!=n&&t.push(n);return t};var nt=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};var rt=function(e){if(!nt(e))return!1;var t=je(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t};var it=function(e){return null!=e&&Ge(e.length)&&!rt(e)};var st=function(e){return it(e)?Ke(e):tt(e)};var at=function(e,t){return function(n,r){if(null==n)return n;if(!it(n))return e(n,r);for(var i=n.length,s=t?i:-1,a=Object(n);(t?s--:++s<i)&&!1!==r(a[s],s,a););return n}}((function(e,t){return e&&me(e,t,st)}));var ot=function(e,t,n,r){return at(e,(function(e,i,s){t(r,e,n(e),s)})),r};var ct=function(){this.__data__=[],this.size=0};var lt=function(e,t){return e===t||e!=e&&t!=t};var ut=function(e,t){for(var n=e.length;n--;)if(lt(e[n][0],t))return n;return-1},ht=Array.prototype.splice;var dt=function(e){var t=this.__data__,n=ut(t,e);return!(n<0)&&(n==t.length-1?t.pop():ht.call(t,n,1),--this.size,!0)};var ft=function(e){var t=this.__data__,n=ut(t,e);return n<0?void 0:t[n][1]};var pt=function(e){return ut(this.__data__,e)>-1};var vt=function(e,t){var n=this.__data__,r=ut(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};function mt(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}mt.prototype.clear=ct,mt.prototype.delete=dt,mt.prototype.get=ft,mt.prototype.has=pt,mt.prototype.set=vt;var bt=mt;var yt=function(){this.__data__=new bt,this.size=0};var gt=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n};var Tt=function(e){return this.__data__.get(e)};var Et,It=function(e){return this.__data__.has(e)},Ot=Te["__core-js_shared__"],_t=(Et=/[^.]+$/.exec(Ot&&Ot.keys&&Ot.keys.IE_PROTO||""))?"Symbol(src)_1."+Et:"";var wt=function(e){return!!_t&&_t in e},At=Function.prototype.toString;var Ct=function(e){if(null!=e){try{return At.call(e)}catch(e){}try{return e+""}catch(e){}}return""},Rt=/^\[object .+?Constructor\]$/,St=Function.prototype,jt=Object.prototype,kt=St.toString,Nt=jt.hasOwnProperty,Bt=RegExp("^"+kt.call(Nt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var Dt=function(e){return!(!nt(e)||wt(e))&&(rt(e)?Bt:Rt).test(Ct(e))};var Ut=function(e,t){return null==e?void 0:e[t]};var Pt=function(e,t){var n=Ut(e,t);return Dt(n)?n:void 0},Ft=Pt(Te,"Map"),qt=Pt(Object,"create");var Lt=function(){this.__data__=qt?qt(null):{},this.size=0};var Mt=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},xt=Object.prototype.hasOwnProperty;var Gt=function(e){var t=this.__data__;if(qt){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return xt.call(t,e)?t[e]:void 0},zt=Object.prototype.hasOwnProperty;var Ht=function(e){var t=this.__data__;return qt?void 0!==t[e]:zt.call(t,e)};var $t=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=qt&&void 0===t?"__lodash_hash_undefined__":t,this};function Wt(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Wt.prototype.clear=Lt,Wt.prototype.delete=Mt,Wt.prototype.get=Gt,Wt.prototype.has=Ht,Wt.prototype.set=$t;var Vt=Wt;var Qt=function(){this.size=0,this.__data__={hash:new Vt,map:new(Ft||bt),string:new Vt}};var Yt=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var Kt=function(e,t){var n=e.__data__;return Yt(t)?n["string"==typeof t?"string":"hash"]:n.map};var Jt=function(e){var t=Kt(this,e).delete(e);return this.size-=t?1:0,t};var Xt=function(e){return Kt(this,e).get(e)};var Zt=function(e){return Kt(this,e).has(e)};var en=function(e,t){var n=Kt(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};function tn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}tn.prototype.clear=Qt,tn.prototype.delete=Jt,tn.prototype.get=Xt,tn.prototype.has=Zt,tn.prototype.set=en;var nn=tn;var rn=function(e,t){var n=this.__data__;if(n instanceof bt){var r=n.__data__;if(!Ft||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new nn(r)}return n.set(e,t),this.size=n.size,this};function sn(e){var t=this.__data__=new bt(e);this.size=t.size}sn.prototype.clear=yt,sn.prototype.delete=gt,sn.prototype.get=Tt,sn.prototype.has=It,sn.prototype.set=rn;var an=sn;var on=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this};var cn=function(e){return this.__data__.has(e)};function ln(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new nn;++t<n;)this.add(e[t])}ln.prototype.add=ln.prototype.push=on,ln.prototype.has=cn;var un=ln;var hn=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1};var dn=function(e,t){return e.has(t)};var fn=function(e,t,n,r,i,s){var a=1&n,o=e.length,c=t.length;if(o!=c&&!(a&&c>o))return!1;var l=s.get(e);if(l&&s.get(t))return l==t;var u=-1,h=!0,d=2&n?new un:void 0;for(s.set(e,t),s.set(t,e);++u<o;){var f=e[u],p=t[u];if(r)var v=a?r(p,f,u,t,e,s):r(f,p,u,e,t,s);if(void 0!==v){if(v)continue;h=!1;break}if(d){if(!hn(t,(function(e,t){if(!dn(d,t)&&(f===e||i(f,e,n,r,s)))return d.push(t)}))){h=!1;break}}else if(f!==p&&!i(f,p,n,r,s)){h=!1;break}}return s.delete(e),s.delete(t),h},pn=Te.Uint8Array;var vn=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n};var mn=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n},bn=Ee?Ee.prototype:void 0,yn=bn?bn.valueOf:void 0;var gn=function(e,t,n,r,i,s,a){switch(n){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!s(new pn(e),new pn(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return lt(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var o=vn;case"[object Set]":var c=1&r;if(o||(o=mn),e.size!=t.size&&!c)return!1;var l=a.get(e);if(l)return l==t;r|=2,a.set(e,t);var u=fn(o(e),o(t),r,i,s,a);return a.delete(e),u;case"[object Symbol]":if(yn)return yn.call(e)==yn.call(t)}return!1};var Tn=function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e};var En=function(e,t,n){var r=t(e);return Fe(e)?r:Tn(r,n(e))};var In=function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,s=[];++n<r;){var a=e[n];t(a,n,e)&&(s[i++]=a)}return s};var On=function(){return[]},_n=Object.prototype.propertyIsEnumerable,wn=Object.getOwnPropertySymbols,An=wn?function(e){return null==e?[]:(e=Object(e),In(wn(e),(function(t){return _n.call(e,t)})))}:On;var Cn=function(e){return En(e,st,An)},Rn=Object.prototype.hasOwnProperty;var Sn=function(e,t,n,r,i,s){var a=1&n,o=Cn(e),c=o.length;if(c!=Cn(t).length&&!a)return!1;for(var l=c;l--;){var u=o[l];if(!(a?u in t:Rn.call(t,u)))return!1}var h=s.get(e);if(h&&s.get(t))return h==t;var d=!0;s.set(e,t),s.set(t,e);for(var f=a;++l<c;){var p=e[u=o[l]],v=t[u];if(r)var m=a?r(v,p,u,t,e,s):r(p,v,u,e,t,s);if(!(void 0===m?p===v||i(p,v,n,r,s):m)){d=!1;break}f||(f="constructor"==u)}if(d&&!f){var b=e.constructor,y=t.constructor;b!=y&&"constructor"in e&&"constructor"in t&&!("function"==typeof b&&b instanceof b&&"function"==typeof y&&y instanceof y)&&(d=!1)}return s.delete(e),s.delete(t),d},jn=Pt(Te,"DataView"),kn=Pt(Te,"Promise"),Nn=Pt(Te,"Set"),Bn=Pt(Te,"WeakMap"),Dn=Ct(jn),Un=Ct(Ft),Pn=Ct(kn),Fn=Ct(Nn),qn=Ct(Bn),Ln=je;(jn&&"[object DataView]"!=Ln(new jn(new ArrayBuffer(1)))||Ft&&"[object Map]"!=Ln(new Ft)||kn&&"[object Promise]"!=Ln(kn.resolve())||Nn&&"[object Set]"!=Ln(new Nn)||Bn&&"[object WeakMap]"!=Ln(new Bn))&&(Ln=function(e){var t=je(e),n="[object Object]"==t?e.constructor:void 0,r=n?Ct(n):"";if(r)switch(r){case Dn:return"[object DataView]";case Un:return"[object Map]";case Pn:return"[object Promise]";case Fn:return"[object Set]";case qn:return"[object WeakMap]"}return t});var Mn=Ln,xn=Object.prototype.hasOwnProperty;var Gn=function(e,t,n,r,i,s){var a=Fe(e),o=Fe(t),c=a?"[object Array]":Mn(e),l=o?"[object Array]":Mn(t),u="[object Object]"==(c="[object Arguments]"==c?"[object Object]":c),h="[object Object]"==(l="[object Arguments]"==l?"[object Object]":l),d=c==l;if(d&&Le(e)){if(!Le(t))return!1;a=!0,u=!1}if(d&&!u)return s||(s=new an),a||Qe(e)?fn(e,t,n,r,i,s):gn(e,t,c,n,r,i,s);if(!(1&n)){var f=u&&xn.call(e,"__wrapped__"),p=h&&xn.call(t,"__wrapped__");if(f||p){var v=f?e.value():e,m=p?t.value():t;return s||(s=new an),i(v,m,n,r,s)}}return!!d&&(s||(s=new an),Sn(e,t,n,r,i,s))};var zn=function e(t,n,r,i,s){return t===n||(null==t||null==n||!ke(t)&&!ke(n)?t!=t&&n!=n:Gn(t,n,r,i,e,s))};var Hn=function(e,t,n,r){var i=n.length,s=i,a=!r;if(null==e)return!s;for(e=Object(e);i--;){var o=n[i];if(a&&o[2]?o[1]!==e[o[0]]:!(o[0]in e))return!1}for(;++i<s;){var c=(o=n[i])[0],l=e[c],u=o[1];if(a&&o[2]){if(void 0===l&&!(c in e))return!1}else{var h=new an;if(r)var d=r(l,u,c,e,t,h);if(!(void 0===d?zn(u,l,3,r,h):d))return!1}}return!0};var $n=function(e){return e==e&&!nt(e)};var Wn=function(e){for(var t=st(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,$n(i)]}return t};var Vn=function(e,t){return function(n){return null!=n&&(n[e]===t&&(void 0!==t||e in Object(n)))}};var Qn=function(e){var t=Wn(e);return 1==t.length&&t[0][2]?Vn(t[0][0],t[0][1]):function(n){return n===e||Hn(n,e,t)}};var Yn=function(e){return"symbol"==typeof e||ke(e)&&"[object Symbol]"==je(e)},Kn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Jn=/^\w*$/;var Xn=function(e,t){if(Fe(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!Yn(e))||(Jn.test(e)||!Kn.test(e)||null!=t&&e in Object(t))};function Zn(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],s=n.cache;if(s.has(i))return s.get(i);var a=e.apply(this,r);return n.cache=s.set(i,a)||s,a};return n.cache=new(Zn.Cache||nn),n}Zn.Cache=nn;var er=Zn;var tr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,nr=/\\(\\)?/g,rr=function(e){var t=er(e,(function(e){return 500===n.size&&n.clear(),e})),n=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(tr,(function(e,n,r,i){t.push(r?i.replace(nr,"$1"):n||e)})),t}));var ir=function(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i},sr=Ee?Ee.prototype:void 0,ar=sr?sr.toString:void 0;var or=function e(t){if("string"==typeof t)return t;if(Fe(t))return ir(t,e)+"";if(Yn(t))return ar?ar.call(t):"";var n=t+"";return"0"==n&&1/t==-1/0?"-0":n};var cr=function(e){return null==e?"":or(e)};var lr=function(e,t){return Fe(e)?e:Xn(e,t)?[e]:rr(cr(e))};var ur=function(e){if("string"==typeof e||Yn(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t};var hr=function(e,t){for(var n=0,r=(t=lr(t,e)).length;null!=e&&n<r;)e=e[ur(t[n++])];return n&&n==r?e:void 0};var dr=function(e,t,n){var r=null==e?void 0:hr(e,t);return void 0===r?n:r};var fr=function(e,t){return null!=e&&t in Object(e)};var pr=function(e,t,n){for(var r=-1,i=(t=lr(t,e)).length,s=!1;++r<i;){var a=ur(t[r]);if(!(s=null!=e&&n(e,a)))break;e=e[a]}return s||++r!=i?s:!!(i=null==e?0:e.length)&&Ge(i)&&xe(a,i)&&(Fe(e)||Pe(e))};var vr=function(e,t){return null!=e&&pr(e,t,fr)};var mr=function(e,t){return Xn(e)&&$n(t)?Vn(ur(e),t):function(n){var r=dr(n,e);return void 0===r&&r===t?vr(n,e):zn(t,r,3)}};var br=function(e){return e};var yr=function(e){return function(t){return null==t?void 0:t[e]}};var gr=function(e){return function(t){return hr(t,e)}};var Tr=function(e){return Xn(e)?yr(ur(e)):gr(e)};var Er=function(e){return"function"==typeof e?e:null==e?br:"object"==typeof e?Fe(e)?mr(e[0],e[1]):Qn(e):Tr(e)};var Ir=function(e,t){return function(n,r){var i=Fe(n)?ve:ot,s=t?t():{};return i(n,e,Er(r),s)}}((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]}));var Or=function(e,t,n,r){for(var i=e.length,s=n+(r?1:-1);r?s--:++s<i;)if(t(e[s],s,e))return s;return-1};var _r=function(e){return e!=e};var wr=function(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1};var Ar=function(e,t,n){return t==t?wr(e,t,n):Or(e,_r,n)};var Cr=function(e,t){return!!(null==e?0:e.length)&&Ar(e,t,0)>-1};var Rr=function(e,t,n){for(var r=-1,i=null==e?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1};var Sr=function(){},jr=Nn&&1/mn(new Nn([,-0]))[1]==1/0?function(e){return new Nn(e)}:Sr;var kr=function(e,t,n){var r=-1,i=Cr,s=e.length,a=!0,o=[],c=o;if(n)a=!1,i=Rr;else if(s>=200){var l=t?null:jr(e);if(l)return mn(l);a=!1,i=dn,c=new un}else c=t?[]:o;e:for(;++r<s;){var u=e[r],h=t?t(u):u;if(u=n||0!==u?u:0,a&&h==h){for(var d=c.length;d--;)if(c[d]===h)continue e;t&&c.push(h),o.push(u)}else i(c,h,n)||(c!==o&&c.push(h),o.push(u))}return o};var Nr=function(e,t){return e&&e.length?kr(e,Er(t)):[]};function Br(e){if(e.length<2)return e;const t=[e[0]];for(let n=1;n<e.length;n++){const r=t.length-1,i=t[r],s=e[n];s[0]>i[1]?t.push(s):t[r]=[i[0],new Date(Math.max(+i[1],+s[1]))]}return t}class Dr extends K{constructor(e){super(),this.camerasStore=e,this.knownIntervals=j(),this.eventsById=new Map,this.updates=0,this.recentAdditions=[],this.processNewEvents=({data:e})=>{const t=Nr(e.filter(e=>this.camerasStore.camerasById.has(e.cameraId)).reverse(),"id").map(e=>new le(e)),[n,r]=Ir(t,e=>this.eventsById.has(e.id));this.update(n),this.add(r),r.length&&(this.recentAdditions=r.map(e=>e.id))},this.data=j(),this.eventsByCameraId=this.data.dimension(e=>e.cameraId),this.eventsByStart=this.data.dimension(e=>+e.startTime),this.eventsByEnd=this.data.dimension(e=>+e.endTime),this.eventsByType=this.data.dimension(e=>e.type),this.eventsByFoundObjects=this.data.dimension(e=>e.foundObjects.map(e=>e.Type),!0),this.eventsByColor=this.data.dimension(e=>e.foundObjects.reduce((e,t)=>e.concat(...t.Colors.map(e=>e.Color)),[]),!0),this.eventsByLiveliness=this.data.dimension(e=>e.isLive),this.pendingRequests=j(),this.pendingRequestsByStart=this.pendingRequests.dimension(e=>+e.startTime),this.pendingRequestsByEnd=this.pendingRequests.dimension(e=>+e.endTime),this.pendingRequestsByCameraId=this.pendingRequests.dimension(e=>e.cameraId),this.knownIntervalsByCameraId=this.knownIntervals.dimension(e=>e.cameraId),this.knownIntervalsByStart=this.knownIntervals.dimension(e=>+e.from),this.knownIntervalsByEnd=this.knownIntervals.dimension(e=>+e.to)}fetchEvents(e,t,n){n&&n>new Date&&(n=null);const r=null===n?new Date(Date.now()-6e5):n;-1===e?this.knownIntervalsByCameraId.filter(-1):this.knownIntervalsByCameraId.filter(t=>-1===t||t===e),this.knownIntervalsByStart.filter([-1/0,r]),this.knownIntervalsByEnd.filter([t,1/0]);const i=this.knownIntervalsByStart.bottom(1/0),s=[];if(this.knownIntervalsByCameraId.filterAll(),this.knownIntervalsByStart.filterAll(),this.knownIntervalsByEnd.filterAll(),i.length){const a=Br(i.map(e=>[e.from,e.to]));a[0][0]>t&&s.push([t,a[0][0]]);for(let e=0;e<a.length-1;e++)s.push([a[e][1],a[e+1][0]]);a[Br.length-1][1]<r&&s.push([a[Br.length-1][1],r]),s.length&&(t=s[0][0],+s[s.length-1][1]<=+r&&(n=s[s.length-1][1]),this.knownIntervals.add([{cameraId:e,from:t,to:r}]))}else this.knownIntervals.add([{cameraId:e,from:t,to:r}]);this.pendingRequestsByCameraId.filter(e),this.pendingRequestsByStart.filter(t),this.pendingRequestsByEnd.filter(r);const a=this.pendingRequests.allFiltered()[0];if(this.pendingRequestsByCameraId.filterAll(),this.pendingRequestsByStart.filterAll(),this.pendingRequestsByEnd.filterAll(),a)return a.request;if(i.length&&!s.length)return c([]);const o=this.api.cameras.GetMotionEvents({cameraId:e,startTime:t,endTime:n}).pipe(w(e=>e.motionEventItems.map(e=>new le(e))),R());return this.pendingRequests.add([{cameraId:e,startTime:t,endTime:n||new Date,request:o}]),o.pipe(A(()=>this.pendingRequests.remove(e=>e.request===o))).subscribe(this.add),o}update(e){e.forEach(e=>{const t=this.eventsById.get(e.id);t&&(t.endTime=e.endTime,this.data.remove(t=>t.id===e.id),this.data.add([t]))})}add(e){const t=e.filter(e=>!this.eventsById.has(e.id));t.forEach(e=>this.eventsById.set(e.id,e)),this.data.add(t),t.length&&this.updates++}getEvents({cameraIds:e,from:t,to:n,objectType:r,colors:i}){this.eventsByStart.filter([+t,n?+n+5e-4:1/0]),r&&this.eventsByFoundObjects.filter(e=>r.includes(e)),e&&this.eventsByCameraId.filter(t=>e.includes(t)),i&&this.eventsByColor.filter(e=>i.has(e));const s=this.eventsByStart.top(1/0);return e&&this.eventsByCameraId.filterAll(),r&&this.eventsByFoundObjects.filterAll(),i&&this.eventsByColor.filterAll(),this.eventsByStart.filterAll(),s}getOverlappedEvents({cameraId:e,from:t,to:n}){this.eventsByCameraId.filter(e),this.eventsByStart.filter([-1/0,+n+5e-4]),this.eventsByLiveliness.filterExact(!0);const r=this.eventsByStart.top(1/0);this.eventsByLiveliness.filterAll(),this.eventsByEnd.filter([+t,1/0]);const i=this.eventsByStart.top(1/0);return this.eventsByCameraId.filterAll(),this.eventsByStart.filterAll(),this.eventsByStart.filterAll(),i.concat(r)}getLastBefore({cameraId:e,date:t}){this.eventsByCameraId.filter(e),this.eventsByEnd.filter([-1/0,+t]),this.eventsByLiveliness.filter(!1),this.eventsByType.filter(se.Default);const n=this.eventsByEnd.top(1);return this.eventsByCameraId.filterAll(),this.eventsByEnd.filterAll(),this.eventsByLiveliness.filterAll(),this.eventsByType.filterAll(),n[0]}getFirstAfter({cameraId:e,date:t}){this.eventsByCameraId.filter(e),this.eventsByStart.filter([+t+5e-4,1/0]),this.eventsByType.filter(se.Default);const n=this.eventsByEnd.bottom(1);return this.eventsByCameraId.filterAll(),this.eventsByStart.filterAll(),this.eventsByType.filterAll(),n[0]}afterInit(){this.api.events.pipe(g(({hub:e,event:t})=>"cameras"===e&&"OnCameraMotionEvent"===t)).subscribe(this.processNewEvents)}}k([e],Dr.prototype,"updates",void 0),k([e.ref],Dr.prototype,"recentAdditions",void 0),k([n.bound],Dr.prototype,"update",null),k([n.bound],Dr.prototype,"add",null);class Ur extends K{constructor(){super(),this.toThumbnail=e=>({realtimestamp:t,url:n,width:r,height:i})=>({cameraId:e,url:n,width:r,height:i,timestamp:new Date(t)}),this.thumbnails=j(),this.thumbnailsByCameraId=this.thumbnails.dimension(e=>e.cameraId),this.thumbnailsByDate=this.thumbnails.dimension(e=>+e.timestamp),this.pendingRequests=j(),this.pendingRequestsByStart=this.pendingRequests.dimension(e=>+e.from),this.pendingRequestsByEnd=this.pendingRequests.dimension(e=>+e.to),this.pendingRequestsByCameraId=this.pendingRequests.dimension(e=>e.cameraId),this.pendingRequestsByCount=this.pendingRequests.dimension(e=>e.count)}fetchThumbnails(e,t,n,r){this.pendingRequestsByCameraId.filter(e),this.pendingRequestsByStart.filter(t),this.pendingRequestsByEnd.filter(n),this.pendingRequestsByCount.filter(r);const i=this.pendingRequests.allFiltered()[0];if(this.pendingRequestsByCameraId.filterAll(),this.pendingRequestsByStart.filterAll(),this.pendingRequestsByEnd.filterAll(),this.pendingRequestsByCount.filterAll(),i)return i.request;const s=this.api.thumbnails.GetThumbnailsInfo({cameraId:e,from:t,to:n,count:r}).pipe(w(e=>e.resultItems),_());return this.pendingRequests.add([{cameraId:e,from:t,to:n,count:r,request:s}]),s.subscribe(t=>{const n=t.filter(e=>e.url).map(this.toThumbnail(e));this.thumbnails.add(n),this.pendingRequests.remove(e=>e.request===s)}),s}getIntervalState(e,t,n){const r=this.getThumbnail({cameraId:e,from:t,to:n});if(r)return{state:"fullfilled",data:r};this.pendingRequestsByCameraId.filter(e),this.pendingRequestsByStart.filter([-1/0,+n+5e-4]),this.pendingRequestsByEnd.filter([t,1/0]);let i=this.pendingRequests.allFiltered();return this.pendingRequestsByCameraId.filterAll(),this.pendingRequestsByStart.filterAll(),this.pendingRequestsByEnd.filterAll(),i=i.filter(e=>1===e.count?+e.from==+t&&+e.to==+n:Math.abs((+e.to-+e.from)/e.count-(+n-+t))<=1),i.length?{state:"pending",request:i[0].request}:null}fetchThumbnail(e,t,n){const r=this.getIntervalState(e,t,n);if(null!==r){if("fullfilled"===r.state)return c(r.data);if("pending"===r.state)return r.request.pipe(w(()=>this.getThumbnail({cameraId:e,from:t,to:n})))}const i=this.api.thumbnails.GetThumbnailInfo({cameraId:e,from:t,to:n}).pipe(w(e=>e.resultItems),_());return i.subscribe(t=>{const n=t.filter(e=>e.url).map(this.toThumbnail(e));this.thumbnails.add(n),this.pendingRequests.remove(e=>e.request===i)}),this.pendingRequests.add([{cameraId:e,from:t,to:n,count:1,request:i}]),i.pipe(w(()=>this.getThumbnail({cameraId:e,from:t,to:n})))}getThumbnail({cameraId:e,from:t,to:n}){this.thumbnailsByCameraId.filter(e),this.thumbnailsByDate.filter([+t,+n+(+t==+n?5e-4:0)]);const r=this.thumbnails.allFiltered()[0];return this.thumbnailsByDate.filterAll(),this.thumbnailsByCameraId.filterAll(),r}getThumbnails({cameraId:e,from:t,to:n}){this.thumbnailsByCameraId.filter(e),this.thumbnailsByDate.filter([+t,+n+5e-4]);const r=this.thumbnails.allFiltered();return this.thumbnailsByDate.filterAll(),this.thumbnailsByCameraId.filterAll(),r}}class Pr{constructor(){this.cameras=new ce,this.archives=new Z,this.events=new Dr(this.cameras),this.eventSchema=new pe,this.thumbnails=new Ur,this.account=new J,this.eventList=new ue(this.events),this.searchParams=new URLSearchParams(location.search),s(()=>!!this.account.user,()=>{this.cameras.fetch()}),s(()=>!this.cameras.loading,()=>{this.eventList.load()})}init({widgetId:e,widgetToken:t,apiUrl:n,tokenServiceUrl:r}){const i=new H;i.setItem("token",JSON.stringify({widgetId:e,widgetToken:t})),this.auth=new z({widgetTokenServiceUrl:r,tokenServiceUrl:r,tokenStorageKey:"token",storage:i,clientId:"Toolkit",deviceInfo:null}),this.api=q.create(D,this.auth,e=>S(n,{qs:{access_token:e}})),this.cameras.initWith(this.api),this.archives.initWith(this.api),this.events.initWith(this.api),this.eventSchema.initWith(this.api),this.thumbnails.initWith(this.api),this.account.initWith(this.api),this.account.setAuthStore(this.auth)}}k([e],Pr.prototype,"isFullscreen",void 0);const Fr=new Pr;window.app=Fr;export{Fr as app};
1
+ import{reaction as e,computed as t,runInAction as r,makeObservable as n,observable as i,action as a,when as s}from"mobx";import{Subject as o,BehaviorSubject as l,switchMap as u,EMPTY as c,timer as d,filter as h,delay as f,take as b,mergeMap as p,catchError as v,throwError as m,takeUntil as y,Observable as g,of as w,retryWhen as j,startWith as O,pairwise as I,concatMap as k,Subscription as P,share as A,shareReplay as T,skip as C,exhaustMap as B,map as S}from"rxjs";import _ from"jqueryless-signalr";import{StatusCodes as E}from"http-status-codes";import{mergeMap as R,shareReplay as q,retry as U,filter as D,map as x,tap as N,expand as M,last as F,share as z}from"rxjs/operators";import G from"crossfilter2";import L from"string-natural-compare";import $ from"react";const W={archives:{PopulateArchive:null,GetArchives:null,GetClips:null,UpdateClip:null,DeleteClip:null,SaveClip:null,SaveTimelaps:null,SaveArchive:null,DeleteArchive:null,ShareClip:null,GetSharedClips:null,UpdateSharedClip:null,DeleteSharedClip:null},cameras:{GetCameras:null,GetSensorDataSchema:null,GetSensorEvents:null,GetSensorEventsPage:null,AddUserSensorEvent:null,AcknowledgeSensorEvent:null,MoveCamera:null,MoveCameraContinuousStart:null,MoveCameraContinuousStop:null,GoHomePtzCamera:null,SetHomePtzCamera:null},camgroups:{GetCamgroups:null,DeleteCamgroup:null,AddCamgroup:null,UpdateCamgroup:null},sound:{GetPushSoundServiceUrl:null},thumbnails:{GetThumbnailsInfo:null,GetThumbnailInfo:null,GetHeatMapsInfo:null},users:{GetUser:null,UserUpdateProfile:null}},V={cameras:[{name:"OnCameraMotionEvent",explicit:!0},{name:"OnCameraAdded"},{name:"OnCameraUpdated"},{name:"OnSystemCameraUpdated"},{name:"OnCameraDeleted"}],users:[{name:"OnUserUpdateProfile"}],camgroups:[{name:"OnAdd"},{name:"OnUpdate"},{name:"OnDelete"}],archives:[{name:"OnTimelapsAdded"},{name:"OnClipAdded"},{name:"OnClipUpdated"},{name:"OnClipDeleted"},{name:"OnArchiveAdded"},{name:"OnArchiveUpdated"},{name:"OnArchiveDeleted"},{name:"OnArchiveRecordCreated"}]};var H,J;!function(e){e[e.CONNECTING=0]="CONNECTING",e[e.CONNECTED=1]="CONNECTED",e[e.RECONNECTING=2]="RECONNECTING",e[e.DISCONNECTED=3]="DISCONNECTED"}(H||(H={}));class K{constructor(t,r,n){Object.defineProperty(this,"connectionShutdown$",{enumerable:!0,configurable:!0,writable:!0,value:new o}),Object.defineProperty(this,"connection$",{enumerable:!0,configurable:!0,writable:!0,value:new l(null)}),Object.defineProperty(this,"events",{enumerable:!0,configurable:!0,writable:!0,value:new o}),Object.defineProperty(this,"logging",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"authStore",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"createConnection",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"apiConfig",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.apiConfig=t,this.init(),this.createConnection=n,this.authStore=r,e((()=>r.token),(e=>{if(!e)return void this.shutdownConnection();if(e.invalid)return;if(!e.accessToken)return;const t=this.connection$.getValue();t&&t.state!==H.DISCONNECTED?t.qs.access_token=e.accessToken:this.connect(e)})),this.connection$.pipe(u((e=>null!==e||!r.isAuthenticated||r.token&&r.token.invalid?c:(this.logging&&console.warn("disconnected by some reason"),d(5e3)))),h((()=>r.isAuthenticated&&!!r.token&&!r.token.invalid))).subscribe((()=>{this.connect(r.token),this.logging&&console.warn("attempting to reconnect")})),this.connection$.pipe(h(Boolean),f(100)).subscribe(this.subscribeToEvents)}static create(e,t,r){return new K(null!==e?e:W,t,r)}connect(e){if(this.connection$.getValue()&&this.connection$.getValue().state===H.CONNECTED)return;const{accessToken:t}=e,r=this.createConnection(t);Object.keys(this.apiConfig).forEach((e=>r.createHubProxy(e))),Object.entries(V).forEach((([e,t])=>{t&&r.proxies[e]&&t.forEach((({name:t})=>{r.proxies[e].on(t,(r=>this.events.next({hub:e,event:t,data:r})))}))})),r.start().done((()=>{this.logging&&console.warn("connected"),this.connection$.next(r)})).fail((e=>{var t,r,n;401!==(null===(t=e.source)||void 0===t?void 0:t.status)&&403!==(null===(r=e.source)||void 0===r?void 0:r.status)&&409!==(null===(n=e.source)||void 0===n?void 0:n.status)||this.authStore.invalidateToken()})),r.error((e=>{if(e.source&&(401===e.source.status||403===e.source.status||409===e.source.status))return this.logging&&console.warn("authentication error, invalidating token"),this.authStore.invalidateToken()})),r.disconnected((()=>{this.connection$.getValue()?this.logging&&console.warn("disconnected",this.connection$.getValue().lastError):this.logging&&console.warn("disconnected. this connection is already null"),this.connection$.next(null)})),r.reconnecting((()=>console.log("reconnecting"))),r.reconnected((()=>{this.connection$.getValue()===r&&(this.logging&&console.warn("reconnected"),this.connection$.next(r))}))}shutdownConnection(){const e=this.connection$.getValue();e&&e.stop(),this.connectionShutdown$.next(null)}init(){Object.keys(this.apiConfig).forEach((e=>{this[e]={},Object.keys(this.apiConfig[e]).forEach((t=>{this[e][t]=this.createHubMethod(e,t)}))}))}createHubMethod(e,t){const r=this;return function n(...i){return r.connection$.pipe(h(Boolean),h((e=>e.state===H.CONNECTED)),b(1)).pipe(p((r=>new Promise(((n,a)=>{r.proxies[e].invoke(t,...i).done((e=>n(e))).fail((e=>a(e)))})))),v((e=>!e.message||"Connection started reconnecting before invocation result was received."!==e.message&&"Connection was disconnected before invocation result was received."!==e.message?e.message&&e.message.startsWith("Caller is not authorized to invoke the ")?(console.warn(e.message),r.connection$.getValue().stop(),r.authStore.invalidateToken(),n(...i)):m(e):(console.warn(e.message),n(...i)))),y(r.connectionShutdown$))}}subscribeToEvents(e){Object.entries(V).forEach((([t,r])=>{r&&e.proxies[t]&&e.state===H.CONNECTED&&r.filter((({explicit:e})=>e)).forEach((({name:r})=>{e.proxies[t].invoke("SubscribeToEvent",r)}))}))}}class Z{constructor(e){Object.defineProperty(this,"accessToken",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"accessTokenExpires",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"accessTokenIssued",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"expiresIn",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"refreshToken",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"refreshTokenExpires",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"refreshTokenIssued",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tokenType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"userName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"invalid",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"widgetId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"widgetToken",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"json",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.json=e,this.accessToken=e.access_token||e.accessToken,this.accessTokenExpires=new Date(e.access_token_expires||e.accessTokenExpires),this.accessTokenIssued=new Date(e.access_token_issued||e.accessTokenIssued),this.clientId=e.client_id||e.clientId,this.expiresIn=e.expires_in||e.expiresIn,this.refreshToken=e.refresh_token||e.refreshToken,this.refreshTokenExpires=new Date(e.refresh_token_expires||e.refreshTokenExpires),this.refreshTokenIssued=new Date(e.refresh_token_issued||e.refreshTokenIssued),this.tokenType=e.token_type||e.tokenType,this.userName=e.userName,this.widgetId=e.widgetId,this.widgetToken=e.widgetToken,this.invalid=!1}}class Y{constructor({tokenServiceUrl:e,storage:s,tokenStorageKey:o,deviceInfo:l,clientId:f}){Object.defineProperty(this,"token",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"isAuthenticating",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"storage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tokenServiceUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tokenStorageKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"deviceInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pendingUpdateTokenRequest",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"signOut",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.isAuthenticating||r((()=>this.token=null))}}),Object.defineProperty(this,"signIn",{enumerable:!0,configurable:!0,writable:!0,value:e=>{if(this.isAuthenticating)return;r((()=>this.isAuthenticating=!0)),!1===e.agreedWithTerms&&(e={...e,agreedWithTerms:void 0});return this.fetchToken(e).then((e=>(r((()=>{this.token=e,this.isAuthenticating=!1})),e))).catch((e=>{throw r((()=>{this.isAuthenticating=!1})),e}))}}),Object.defineProperty(this,"invalidateToken",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.token&&r((()=>{this.token={...this.token,invalid:!0}}))}}),n(this,{token:i.ref,isAuthenticating:i,isAuthenticated:t,signOut:a,invalidateToken:a}),this.isAuthenticating=!0,this.storage=s,this.tokenServiceUrl=e,this.tokenStorageKey=o,this.deviceInfo=l,this.clientId=f;const b=function(e,r=!1){const n=t(e);return new g((e=>{const t=n.observe_((({newValue:t})=>e.next(t)),r);return()=>t()}))}((()=>this.token)),y=b.pipe(u((e=>{if(null===e)return c;const t=w(e).pipe(p((e=>e.widgetId?this.fetchWidgetToken(e):this.updateToken(e.refreshToken))),j((e=>e.pipe(p(((e,t)=>e.status&&![500,502,503,504].includes(e.status)?m((()=>e)):d(2**Math.min(t+1,6)*1e3)))))));if(!e.invalid){const r=Math.max(.75*(+e.accessTokenExpires-Date.now()),0);return d(r).pipe(p((()=>t)))}return t})),v((e=>(console.error(e),r((()=>this.token=null)),y))));y.subscribe((e=>{r((()=>this.token=e))})),b.pipe(O(null),I(),h((([e,t])=>!!(t||!t&&e))),k((([,e])=>this.storeToken(e)))).subscribe(),this.getInitialToken().then((e=>{r((()=>{this.token=e,this.isAuthenticating=!1}))}))}get isAuthenticated(){return Boolean(this.token&&!this.isAuthenticating)}async getTokenFromStorage(){const e=await this.storage.getItem(this.tokenStorageKey);return e?new Z(JSON.parse(e)):null}async storeToken(e){return!e||e.invalid?this.storage.removeItem(this.tokenStorageKey):this.storage.setItem(this.tokenStorageKey,JSON.stringify(e.json))}async getInitialToken(){const e=await this.getTokenFromStorage();return e||null}async fetchToken(e){const t={clientId:this.clientId,device:this.deviceInfo,...e},r=new Headers;r.append("Content-Type","application/json"),r.append("accept","application/json");const n=await fetch(this.tokenServiceUrl,{method:"POST",headers:r,body:JSON.stringify(t)});try{const e=await n.json();return 200!==n.status?Promise.reject({status:n.status,data:e}):new Z(e)}catch(e){return Promise.reject(n)}}async updateToken(e){var t;try{return this.pendingUpdateTokenRequest&&this.pendingUpdateTokenRequest.refreshToken===e||(this.pendingUpdateTokenRequest={refreshToken:e,request:this.fetchToken({refreshToken:e})}),await this.pendingUpdateTokenRequest.request}finally{(null===(t=this.pendingUpdateTokenRequest)||void 0===t?void 0:t.refreshToken)===e&&(this.pendingUpdateTokenRequest=null)}}async fetchWidgetToken(e){const{widgetId:t,widgetToken:r}=e;if(!t||!r)throw new Error("token must contain widgetId and widgetToken");const n={widgetId:t,widgetToken:r},i=new Headers;i.append("Content-Type","application/json"),i.append("accept","application/json");const a=await fetch(this.tokenServiceUrl,{method:"POST",headers:i,body:JSON.stringify(n)});try{const e=await a.json();return 200!==a.status?Promise.reject({status:a.status,data:e}):new Z({widgetId:t,widgetToken:r,...e})}catch(e){return Promise.reject(a)}}}!function(e){e[e.Motion=0]="Motion",e[e.Tampering=1]="Tampering",e[e.PanTiltZoom=2]="PanTiltZoom",e[e.CrossLine=3]="CrossLine",e[e.Intrusion=4]="Intrusion",e[e.LicensePlate=5]="LicensePlate",e[e.FaceDetection=6]="FaceDetection",e[e.Audio=7]="Audio",e[e.Analytic=8]="Analytic",e[e.SpeedDetection=9]="SpeedDetection",e[e.PeopleCounter=10]="PeopleCounter",e[e.Temperature=11]="Temperature",e[e.PoS=12]="PoS",e[e.GPS=13]="GPS",e[e.DigitalInput=14]="DigitalInput",e[e.Normal=15]="Normal",e[e.Suspicious=16]="Suspicious",e[e.Loitering=17]="Loitering",e[e.Vandalism=18]="Vandalism",e[e.Trespass=19]="Trespass",e[e.Emergency=20]="Emergency",e[e.LifeInDanger=21]="LifeInDanger",e[e.ErroneousAlert=22]="ErroneousAlert",e[e.Misidentification=23]="Misidentification",e[e.Fire=24]="Fire",e[e.MedicalDuress=25]="MedicalDuress",e[e.HoldUp=26]="HoldUp",e[e.CheckIn=27]="CheckIn",e[e.CheckOut=28]="CheckOut",e[e.ClockIn=29]="ClockIn",e[e.ClockOut=30]="ClockOut",e[e.ParkingStart=31]="ParkingStart",e[e.ParkingEnd=32]="ParkingEnd",e[e.ParkingViolation=33]="ParkingViolation",e[e.GateAccess=34]="GateAccess",e[e.DoorAccess=35]="DoorAccess",e[e.TemperatureCheck=36]="TemperatureCheck",e[e.IDCheck=37]="IDCheck",e[e.PPECheck=38]="PPECheck",e[e.WelfareCheck=39]="WelfareCheck",e[e.Uncategorized=40]="Uncategorized",e[e.Unknown=999]="Unknown"}(J||(J={}));class Q{constructor(){Object.defineProperty(this,"values",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}getItem(e){return this.values.get(e)||null}setItem(e,t){this.values.set(e,t)}removeItem(e){this.values.delete(e)}}let X=[];class ee{constructor(){Object.defineProperty(this,"api",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disposables",{enumerable:!0,configurable:!0,writable:!0,value:[]})}initWith(e){this.api=e,this.afterInit&&this.afterInit()}dispose(){this.disposables.forEach((e=>{e instanceof P?e.closed||e.unsubscribe():e()}))}}var te;!function(e){e.DEFAULT_VIDEO_RESIZE_MODE="defaultVideoResizeMode",e.RESIZE_MODE_PER_CAMERA="camerasResizeMode",e.FISHEYE_CAMERAS="fisheyeCameras"}(te||(te={}));class re extends ee{constructor(e){super(),Object.defineProperty(this,"notification",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"user",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"auth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"setUser",{enumerable:!0,configurable:!0,writable:!0,value:e=>{this.user=e}}),Object.defineProperty(this,"updateCustomPreferences",{enumerable:!0,configurable:!0,writable:!0,value:e=>{const t=w(null).pipe(R((()=>{if(!this.user)return m((()=>"user is not initialized"));const t={id:this.user.id,jsonField:JSON.stringify({...JSON.parse(this.user.jsonField||"{}"),...e}),version:this.user.version};return this.api.users.UserUpdateProfile(t)})),R((e=>e.success?w(e.resultItems[0]):m((()=>e.error)))),this.retryOnVersionMismatch(),q());return t.subscribe((e=>{this.setUser(e)})),t}}),Object.defineProperty(this,"getPreference",{enumerable:!0,configurable:!0,writable:!0,value:e=>{var t;try{return JSON.parse((null===(t=this.user)||void 0===t?void 0:t.jsonField)||"{}")[e]}catch{return null}}}),Object.defineProperty(this,"retryOnVersionMismatch",{enumerable:!0,configurable:!0,writable:!0,value:()=>U({delay:(e,t)=>t>1?m((()=>e)):-4===e.code?this.loadUser$():m((()=>e))})}),n(this,{user:i.ref,setUser:a,userDisplayName:t})}get userDisplayName(){return this.user?this.user.firstName&&this.user.firstName.trim()||this.user.lastName&&this.user.lastName.trim()?[this.user.firstName,this.user.lastName].filter(Boolean).join(" ").trim():this.user.email:null}afterInit(){this.disposables.push(this.api.events.pipe(D((({hub:e,event:t})=>"users"===e&&"OnUserUpdateProfile"===t)),x((({data:e})=>e.resultItems[0]))).subscribe(this.setUser))}loadUser$(){return this.api.users.GetUser().pipe(R((e=>e.success?w(e.resultItems[0]):m((()=>e.error)))),N(this.setUser),q(1))}setAuthStore(t){this.auth=t,this.disposables.push(e((()=>this.auth.isAuthenticated),(()=>{this.auth.isAuthenticated&&this.loadUser$().subscribe()})))}async updateUserPassword(e){var t,r;const n=(Array.isArray(X)?X[0]:X).changePasswordUrl,i=null===(r=null===(t=this.auth)||void 0===t?void 0:t.token)||void 0===r?void 0:r.accessToken,a=JSON.stringify({currentPassword:e.previous,newPassword:e.new}),s=new Headers;s.append("content-type","application/json"),s.append("accept","application/json"),s.append("authorization",`bearer ${i}`);const o=await fetch(n,{method:"PUT",headers:s,body:a}),{status:l}=o;if(l!==E.OK){const e=await o.json();throw new Error(e.errors[0].message)}}updateUserSettings({firstName:e,lastName:t}){const r=w(null).pipe(R((()=>{if(!this.user)throw new Error("user is not initialized");return this.api.users.UserUpdateProfile({id:this.user.id,firstName:e,lastName:t,version:this.user.version})})),R((e=>e.success?w(e.resultItems[0]):m((()=>e.error)))),this.retryOnVersionMismatch(),q());return r.subscribe((e=>{this.setUser(e)})),r}setDefaultGroup(e){const t=w(null).pipe(R((()=>{if(!this.user)return m((()=>"user is not initialized"));const t={id:this.user.id,layoutStartId:e,layoutStartType:"camgroup",version:this.user.version};return this.api.users.UserUpdateProfile(t)})),R((e=>e.success?w(e.resultItems[0]):m((()=>e.error)))),this.retryOnVersionMismatch(),q());return t.subscribe({next:e=>{var t;this.setUser(e),null===(t=this.notification)||void 0===t||t.success("Successfully set default group")},error:e=>{var t;console.error(e),null===(t=this.notification)||void 0===t||t.error(e.message)}}),t}}class ne{constructor(e){Object.defineProperty(this,"json",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"startTime",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"endTime",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"streamUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"duration",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLive",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"cameraId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.json=JSON.stringify(e,null,2),this.startTime=new Date(e.startTime),this.endTime=new Date(e.endTime),this.streamUrl=e.streamUrl,this.cameraId=e.cameraId,this.duration=e.duration,this.id=e.id}}class ie extends ee{constructor(e){super(),Object.defineProperty(this,"camerasStore",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"chunksByCameraId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"chunksByStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"chunksByEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"chunksById",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"pendingRequests",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pendingRequestsByEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pendingRequestsByStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pendingRequestsByCameraId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"knownIntervals",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"updates",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"getClosestChunkRight",{enumerable:!0,configurable:!0,writable:!0,value:({cameraId:e,time:t})=>{this.chunksByCameraId.filter(e),this.chunksByEnd.filter([t,1/0]);const r=this.chunksByStart.bottom(1);return this.chunksByCameraId.filterAll(),this.chunksByEnd.filterAll(),r[0]}}),Object.defineProperty(this,"getClosestChunkLeft",{enumerable:!0,configurable:!0,writable:!0,value:({cameraId:e,time:t})=>{this.chunksByCameraId.filter(e),this.chunksByStart.filter([-1/0,+t+5e-4]);const r=this.chunksByStart.top(1);return this.chunksByCameraId.filterAll(),this.chunksByEnd.filterAll(),r[0]}}),Object.defineProperty(this,"fetchNextChunk",{enumerable:!0,configurable:!0,writable:!0,value:({cameraId:e,time:t})=>{if(this.knownIntervals.has(e)){const[r,n]=this.knownIntervals.get(e);if(r<=t&&n>=t){const r=this.getClosestChunkRight({cameraId:e,time:t});if(r)return w(r)}}return w({result:[],time:t}).pipe(M((({result:t,time:r})=>{if(t.length||r>=new Date)return c;const n=new Date(+r+36e5);return this.fetch(e,r,n).pipe(x((e=>({result:e,time:n}))))})),F(),x((()=>this.getClosestChunkRight({cameraId:e,time:t}))))}}),Object.defineProperty(this,"fetchPrevChunk",{enumerable:!0,configurable:!0,writable:!0,value:({cameraId:e,time:t})=>{if(this.knownIntervals.has(e)){const[r,n]=this.knownIntervals.get(e);if(r<=t&&n>=t){const r=this.getClosestChunkLeft({cameraId:e,time:t});if(r)return w(r)}}const r=this.camerasStore.camerasById.get(e);if(!r)return w(void 0);const n=new Date(Date.now()-3600*r.archiveDuration*1e3);return this.knownIntervals.get(e)&&this.knownIntervals.get(e)[0]<=n?w(void 0):w({result:[],time:t}).pipe(M((({result:t,time:r})=>{if(t.length||r<=n)return c;const i=new Date(Math.max(+r-36e5,+n));return this.fetch(e,i,r).pipe(x((e=>({result:e,time:i}))))})),F(),x((()=>this.getClosestChunkRight({cameraId:e,time:t}))))}}),n(this,{updates:i,add:a.bound}),this.data=G(),this.chunksByCameraId=this.data.dimension((e=>e.cameraId)),this.chunksByStart=this.data.dimension((e=>+e.startTime)),this.chunksByEnd=this.data.dimension((e=>+e.endTime)),this.pendingRequests=G(),this.pendingRequestsByStart=this.pendingRequests.dimension((e=>+e.startTime)),this.pendingRequestsByEnd=this.pendingRequests.dimension((e=>+e.endTime)),this.pendingRequestsByCameraId=this.pendingRequests.dimension((e=>e.cameraId))}fetch(e,t,r){this.pendingRequestsByCameraId.filter(e),this.pendingRequestsByStart.filter(t),this.pendingRequestsByEnd.filter(r);const n=this.pendingRequests.allFiltered()[0];if(this.pendingRequestsByCameraId.filterAll(),this.pendingRequestsByStart.filterAll(),this.pendingRequestsByEnd.filterAll(),n)return n.request;if(this.knownIntervals.has(e)){const[n,i]=this.knownIntervals.get(e);if(n<=t&&i>=r)return w(this.getChunks({cameraId:e,from:t,to:r}));n<=t&&i<r&&(t=i),n>t&&i>=r&&(r=n),r<n&&(r=n),t>i&&(t=i)}const i=this.api.archives.PopulateArchive({cameraId:e,startTime:t,endTime:r}).pipe(x((e=>e.resultItems[0].chunks.map((e=>new ne(e))))),N(this.add),N((r=>this.extendKnownInterval(e,t,r))),q());return this.pendingRequests.add([{cameraId:e,startTime:t,endTime:r,request:i}]),i.pipe(N((()=>this.pendingRequests.remove((e=>e.request===i))))).subscribe(),i}extendKnownInterval(e,t,r){t=new Date(Math.min(+t,...r.map((e=>+e.startTime))));const n=new Date(Math.max(...r.map((e=>+e.endTime))));if(this.knownIntervals.has(e)){const r=this.knownIntervals.get(e);t<r[0]&&(r[0]=t),n>r[1]&&(r[1]=n)}else this.knownIntervals.set(e,[t,n])}add(e){const t=e.filter((e=>!this.chunksById.has(e.id)));t.forEach((e=>this.chunksById.set(e.id,e))),this.data.add(t),t.length&&this.updates++}getChunks({cameraId:e,from:t,to:r}){this.chunksByStart.filter([-1/0,+r+5e-4]),this.chunksByEnd.filter([t,1/0]),e&&this.chunksByCameraId.filter(e);const n=this.chunksByStart.top(1/0);return e&&this.chunksByCameraId.filterAll(),this.chunksByStart.filterAll(),this.chunksByEnd.filterAll(),n}afterInit(){this.api.events.pipe(D((({hub:e,event:t})=>"archives"===e&&"OnArchiveChunksCreated"===t))).subscribe((({data:e})=>{this.add(e.resultItems.map((e=>new ne(e))))}))}}class ae{constructor(e){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"imageUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"streamUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"dashStreamUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"address",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"archiveDuration",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"dvrWindowLength",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"stateUpdatedAt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"enabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isMicEnabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"webRtcUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isPtz",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"permissions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"update",{enumerable:!0,configurable:!0,writable:!0,value:e=>{this.raw=e,this.id=e.id,this.name=e.name,this.isPtz=e.isPTZ,this.isMicEnabled=e.isMicEnabled,this.imageUrl=e.imageUrl,this.address=e.cameraAddress?JSON.parse(e.cameraAddress):null,this.streamUrl=e.streamUrl,this.dashStreamUrl=e.dashStreamUrl,this.enabled=e.enabled,this.state=this.raw.cameraState,this.dvrWindowLength=e.dvrWindowLength?1e3*e.dvrWindowLength:e.dvrWindowLength,this.archiveDuration=e.archiveDuration,this.pin=e.pin,this.webRtcUrl=e.webRtcUrl,this.permissions=e.permissions||0,this.stateUpdatedAt=new Date(e.cameraStateChangedTime)}}),n(this,{name:i,streamUrl:i,dashStreamUrl:i,enabled:i,isMicEnabled:i,state:i,pin:i,webRtcUrl:i,permissions:i,isOnline:t,update:a}),this.update(e)}get isOnline(){return this.enabled&&"Started"===this.state}get supportsWebRTC(){return!!this.webRtcUrl}}class se extends ee{constructor(){super(),Object.defineProperty(this,"camerasById",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"loading",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"loaded",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"load",{enumerable:!0,configurable:!0,writable:!0,value:()=>{if(this.loaded)return;r((()=>this.loading=!0));const e=this.api.cameras.GetCameras({},null).pipe(p((e=>e.success?w(e.resultItems):(console.error(e.error),m((()=>e.error))))),A());return e.subscribe((e=>{r((()=>{this.add(e),this.loading=!1,this.loaded=!0}))})),e}}),Object.defineProperty(this,"add",{enumerable:!0,configurable:!0,writable:!0,value:e=>{e.forEach((e=>{this.camerasById.has(e.id)?this.camerasById.get(e.id).update(e):this.camerasById.set(e.id,new ae(e))})),this.data=Array.from(this.camerasById.values()).sort(((e,t)=>L(e.name,t.name,{caseInsensitive:!0})))}}),Object.defineProperty(this,"sync",{enumerable:!0,configurable:!0,writable:!0,value:()=>{const e=this.data.reduce(((e,t)=>Math.max(e,+t.stateUpdatedAt)),0);if(!e)return c;const t=this.api.cameras.GetCameras({},new Date(1e3*(Math.floor(e/1e3)+1))).pipe(p((e=>e.success?w(e.resultItems):(console.error(e.error),m((()=>e.error))))),T(1));return t.subscribe((e=>this.add(e))),t}}),n(this,{data:i.ref,loading:i,loaded:i,add:a}),this.disposables.push(s((()=>this.loaded),(()=>{this.api.connection$.pipe(C(1),B((()=>this.sync()))).subscribe()})))}afterInit(){this.disposables.push(this.api.events.pipe(h((({hub:e,event:t})=>"cameras"===e&&("OnCameraUpdated"===t||"OnSystemCameraUpdated"===t))),S((({data:e,event:t})=>e.resultItems?{data:e.resultItems[0],event:t}:{data:e,event:t}))).subscribe((({data:e,event:t})=>{const r=this.camerasById.get(e.id);if(!r)return console.warn("got update for unknown camera:",e.id);if("OnSystemCameraUpdated"===t){const t=r.raw;for(const[r,n]of Object.entries(e))null===n&&(e[r]=t[r])}r.update(e)})))}dispose(){super.dispose(),this.camerasById.clear(),this.data=[]}}const oe={amber:{50:"#fff8e1",100:"#ffecb3",200:"#ffe082",300:"#ffd54f",400:"#ffca28",500:"#ffc107",600:"#ffb300",700:"#ffa000",800:"#ff8f00",900:"#ff6f00",A100:"#ffe57f",A200:"#ffd740",A400:"#ffc400",A700:"#ffab00"},blue:{50:"#e3f2fd",100:"#bbdefb",200:"#90caf9",300:"#64b5f6",400:"#42a5f5",500:"#2196f3",600:"#1e88e5",700:"#1976d2",800:"#1565c0",900:"#0d47a1",A100:"#82b1ff",A200:"#448aff",A400:"#2979ff",A700:"#2962ff"},blueGrey:{50:"#eceff1",100:"#cfd8dc",200:"#b0bec5",300:"#90a4ae",400:"#78909c",500:"#607d8b",600:"#546e7a",700:"#455a64",800:"#37474f",900:"#263238",A100:"#cfd8dc",A200:"#b0bec5",A400:"#78909c",A700:"#455a64"},brown:{50:"#efebe9",100:"#d7ccc8",200:"#bcaaa4",300:"#a1887f",400:"#8d6e63",500:"#795548",600:"#6d4c41",700:"#5d4037",800:"#4e342e",900:"#3e2723",A100:"#d7ccc8",A200:"#bcaaa4",A400:"#8d6e63",A700:"#5d4037"},cyan:{50:"#e0f7fa",100:"#b2ebf2",200:"#80deea",300:"#4dd0e1",400:"#26c6da",500:"#00bcd4",600:"#00acc1",700:"#0097a7",800:"#00838f",900:"#006064",A100:"#84ffff",A200:"#18ffff",A400:"#00e5ff",A700:"#00b8d4"},deepOrange:{50:"#fbe9e7",100:"#ffccbc",200:"#ffab91",300:"#ff8a65",400:"#ff7043",500:"#ff5722",600:"#f4511e",700:"#e64a19",800:"#d84315",900:"#bf360c",A100:"#ff9e80",A200:"#ff6e40",A400:"#ff3d00",A700:"#dd2c00"},deepPurple:{50:"#ede7f6",100:"#d1c4e9",200:"#b39ddb",300:"#9575cd",400:"#7e57c2",500:"#673ab7",600:"#5e35b1",700:"#512da8",800:"#4527a0",900:"#311b92",A100:"#b388ff",A200:"#7c4dff",A400:"#651fff",A700:"#6200ea"},green:{50:"#e8f5e9",100:"#c8e6c9",200:"#a5d6a7",300:"#81c784",400:"#66bb6a",500:"#4caf50",600:"#43a047",700:"#388e3c",800:"#2e7d32",900:"#1b5e20",A100:"#b9f6ca",A200:"#69f0ae",A400:"#00e676",A700:"#00c853"},grey:{50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"},indigo:{50:"#e8eaf6",100:"#c5cae9",200:"#9fa8da",300:"#7986cb",400:"#5c6bc0",500:"#3f51b5",600:"#3949ab",700:"#303f9f",800:"#283593",900:"#1a237e",A100:"#8c9eff",A200:"#536dfe",A400:"#3d5afe",A700:"#304ffe"},lightBlue:{50:"#e1f5fe",100:"#b3e5fc",200:"#81d4fa",300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",600:"#039be5",700:"#0288d1",800:"#0277bd",900:"#01579b",A100:"#80d8ff",A200:"#40c4ff",A400:"#00b0ff",A700:"#0091ea"},lightGreen:{50:"#f1f8e9",100:"#dcedc8",200:"#c5e1a5",300:"#aed581",400:"#9ccc65",500:"#8bc34a",600:"#7cb342",700:"#689f38",800:"#558b2f",900:"#33691e",A100:"#ccff90",A200:"#b2ff59",A400:"#76ff03",A700:"#64dd17"},lime:{50:"#f9fbe7",100:"#f0f4c3",200:"#e6ee9c",300:"#dce775",400:"#d4e157",500:"#cddc39",600:"#c0ca33",700:"#afb42b",800:"#9e9d24",900:"#827717",A100:"#f4ff81",A200:"#eeff41",A400:"#c6ff00",A700:"#aeea00"},orange:{50:"#fff3e0",100:"#ffe0b2",200:"#ffcc80",300:"#ffb74d",400:"#ffa726",500:"#ff9800",600:"#fb8c00",700:"#f57c00",800:"#ef6c00",900:"#e65100",A100:"#ffd180",A200:"#ffab40",A400:"#ff9100",A700:"#ff6d00"},pink:{50:"#fce4ec",100:"#f8bbd0",200:"#f48fb1",300:"#f06292",400:"#ec407a",500:"#e91e63",600:"#d81b60",700:"#c2185b",800:"#ad1457",900:"#880e4f",A100:"#ff80ab",A200:"#ff4081",A400:"#f50057",A700:"#c51162"},purple:{50:"#f3e5f5",100:"#e1bee7",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",600:"#8e24aa",700:"#7b1fa2",800:"#6a1b9a",900:"#4a148c",A100:"#ea80fc",A200:"#e040fb",A400:"#d500f9",A700:"#aa00ff"},red:{50:"#ffebee",100:"#ffcdd2",200:"#ef9a9a",300:"#e57373",400:"#ef5350",500:"#f44336",600:"#e53935",700:"#d32f2f",800:"#c62828",900:"#b71c1c",A100:"#ff8a80",A200:"#ff5252",A400:"#ff1744",A700:"#d50000"},teal:{50:"#e0f2f1",100:"#b2dfdb",200:"#80cbc4",300:"#4db6ac",400:"#26a69a",500:"#009688",600:"#00897b",700:"#00796b",800:"#00695c",900:"#004d40",A100:"#a7ffeb",A200:"#64ffda",A400:"#1de9b6",A700:"#00bfa5"},yellow:{50:"#fffde7",100:"#fff9c4",200:"#fff59d",300:"#fff176",400:"#ffee58",500:"#ffeb3b",600:"#fdd835",700:"#fbc02d",800:"#f9a825",900:"#f57f17",A100:"#ffff8d",A200:"#ffff00",A400:"#ffea00",A700:"#ffd600"}},le={Person:"red",Car:"green",Animal:"blue",LicensePlate:"cyan"},ue=["green","red","blue","purple","teal","amber","pink","cyan","lightGreen","deepOrange","deepPurple","lime","indigo","orange","lightBlue"];class ce extends ee{constructor(){super(),Object.defineProperty(this,"schemaDescription",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"fetchAnalyticEventSchema",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.api.cameras.GetSensorDataSchema("Analytic").subscribe({next:e=>{e.success?r((()=>{this.schemaDescription=e.resultItems})):console.error(e)},error:console.error})}}),n(this,{schemaDescription:i.ref,foundObjectTypes:t,foundObjectTypesForSelect:t,colorsByFoundObjectType:t})}get foundObjectTypes(){if(!this.schemaDescription.length)return[];const e=this.schemaDescription.filter((e=>"filter"===e.parameterType&&"Type"===e.fieldName&&"Analytic"===e.eventType))[0];return e?e.valueSet.includes("LicensePlate")?e.valueSet.split(", "):e.valueSet.split(", ").concat(["LicensePlate"]):[]}get foundObjectTypesForSelect(){const e=Object.entries(le).filter((([e])=>this.foundObjectTypes.includes(e))).map((([,e])=>e)),t=ue.filter((t=>!e.includes(t)));let r=0;return this.foundObjectTypes.map((e=>{const n=e in le?le[e]:t[r++],i=oe[n];return{id:e,name:e.toLowerCase(),color:i[500],highlightColor:i.A400,type:"detectedObject"}}))}get colorsByFoundObjectType(){const e=new Map;return this.foundObjectTypesForSelect.forEach((t=>{e.set(t.id,t.highlightColor)})),e}afterInit(){this.fetchAnalyticEventSchema()}dispose(){super.dispose(),this.schemaDescription=[]}}var de="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var he=function(e,t,r,n){for(var i=-1,a=null==e?0:e.length;++i<a;){var s=e[i];t(n,s,r(s),e)}return n};var fe=function(e){return function(t,r,n){for(var i=-1,a=Object(t),s=n(t),o=s.length;o--;){var l=s[e?o:++i];if(!1===r(a[l],l,a))break}return t}}();var be=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n},pe="object"==typeof de&&de&&de.Object===Object&&de,ve=pe,me="object"==typeof self&&self&&self.Object===Object&&self,ye=ve||me||Function("return this")(),ge=ye.Symbol,we=ge,je=Object.prototype,Oe=je.hasOwnProperty,Ie=je.toString,ke=we?we.toStringTag:void 0;var Pe=function(e){var t=Oe.call(e,ke),r=e[ke];try{e[ke]=void 0;var n=!0}catch(e){}var i=Ie.call(e);return n&&(t?e[ke]=r:delete e[ke]),i},Ae=Object.prototype.toString;var Te=Pe,Ce=function(e){return Ae.call(e)},Be=ge?ge.toStringTag:void 0;var Se=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Be&&Be in Object(e)?Te(e):Ce(e)};var _e=function(e){return null!=e&&"object"==typeof e},Ee=Se,Re=_e;var qe=function(e){return Re(e)&&"[object Arguments]"==Ee(e)},Ue=_e,De=Object.prototype,xe=De.hasOwnProperty,Ne=De.propertyIsEnumerable,Me=qe(function(){return arguments}())?qe:function(e){return Ue(e)&&xe.call(e,"callee")&&!Ne.call(e,"callee")},Fe=Array.isArray,ze={exports:{}};var Ge=function(){return!1};!function(e,t){var r=ye,n=Ge,i=t&&!t.nodeType&&t,a=i&&e&&!e.nodeType&&e,s=a&&a.exports===i?r.Buffer:void 0,o=(s?s.isBuffer:void 0)||n;e.exports=o}(ze,ze.exports);var Le=/^(?:0|[1-9]\d*)$/;var $e=function(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&Le.test(e))&&e>-1&&e%1==0&&e<t};var We=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991},Ve=Se,He=We,Je=_e,Ke={};Ke["[object Float32Array]"]=Ke["[object Float64Array]"]=Ke["[object Int8Array]"]=Ke["[object Int16Array]"]=Ke["[object Int32Array]"]=Ke["[object Uint8Array]"]=Ke["[object Uint8ClampedArray]"]=Ke["[object Uint16Array]"]=Ke["[object Uint32Array]"]=!0,Ke["[object Arguments]"]=Ke["[object Array]"]=Ke["[object ArrayBuffer]"]=Ke["[object Boolean]"]=Ke["[object DataView]"]=Ke["[object Date]"]=Ke["[object Error]"]=Ke["[object Function]"]=Ke["[object Map]"]=Ke["[object Number]"]=Ke["[object Object]"]=Ke["[object RegExp]"]=Ke["[object Set]"]=Ke["[object String]"]=Ke["[object WeakMap]"]=!1;var Ze=function(e){return Je(e)&&He(e.length)&&!!Ke[Ve(e)]};var Ye=function(e){return function(t){return e(t)}},Qe={exports:{}};!function(e,t){var r=pe,n=t&&!t.nodeType&&t,i=n&&e&&!e.nodeType&&e,a=i&&i.exports===n&&r.process,s=function(){try{var e=i&&i.require&&i.require("util").types;return e||a&&a.binding&&a.binding("util")}catch(e){}}();e.exports=s}(Qe,Qe.exports);var Xe=Ze,et=Ye,tt=Qe.exports,rt=tt&&tt.isTypedArray,nt=rt?et(rt):Xe,it=be,at=Me,st=Fe,ot=ze.exports,lt=$e,ut=nt,ct=Object.prototype.hasOwnProperty;var dt=function(e,t){var r=st(e),n=!r&&at(e),i=!r&&!n&&ot(e),a=!r&&!n&&!i&&ut(e),s=r||n||i||a,o=s?it(e.length,String):[],l=o.length;for(var u in e)!t&&!ct.call(e,u)||s&&("length"==u||i&&("offset"==u||"parent"==u)||a&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||lt(u,l))||o.push(u);return o},ht=Object.prototype;var ft=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||ht)};var bt=function(e,t){return function(r){return e(t(r))}}(Object.keys,Object),pt=ft,vt=bt,mt=Object.prototype.hasOwnProperty;var yt=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},gt=Se,wt=yt;var jt=function(e){if(!wt(e))return!1;var t=gt(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},Ot=jt,It=We;var kt=function(e){return null!=e&&It(e.length)&&!Ot(e)},Pt=dt,At=function(e){if(!pt(e))return vt(e);var t=[];for(var r in Object(e))mt.call(e,r)&&"constructor"!=r&&t.push(r);return t},Tt=kt;var Ct=function(e){return Tt(e)?Pt(e):At(e)},Bt=fe,St=Ct;var _t=kt;var Et=function(e,t){return function(r,n){if(null==r)return r;if(!_t(r))return e(r,n);for(var i=r.length,a=t?i:-1,s=Object(r);(t?a--:++a<i)&&!1!==n(s[a],a,s););return r}}((function(e,t){return e&&Bt(e,t,St)}));var Rt=function(e,t,r,n){return Et(e,(function(e,i,a){t(n,e,r(e),a)})),n};var qt=function(){this.__data__=[],this.size=0};var Ut=function(e,t){return e===t||e!=e&&t!=t},Dt=Ut;var xt=function(e,t){for(var r=e.length;r--;)if(Dt(e[r][0],t))return r;return-1},Nt=xt,Mt=Array.prototype.splice;var Ft=xt;var zt=xt;var Gt=xt;var Lt=qt,$t=function(e){var t=this.__data__,r=Nt(t,e);return!(r<0)&&(r==t.length-1?t.pop():Mt.call(t,r,1),--this.size,!0)},Wt=function(e){var t=this.__data__,r=Ft(t,e);return r<0?void 0:t[r][1]},Vt=function(e){return zt(this.__data__,e)>-1},Ht=function(e,t){var r=this.__data__,n=Gt(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};function Jt(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Jt.prototype.clear=Lt,Jt.prototype.delete=$t,Jt.prototype.get=Wt,Jt.prototype.has=Vt,Jt.prototype.set=Ht;var Kt=Jt,Zt=Kt;var Yt=function(){this.__data__=new Zt,this.size=0};var Qt=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r};var Xt=function(e){return this.__data__.get(e)};var er,tr=function(e){return this.__data__.has(e)},rr=ye["__core-js_shared__"],nr=(er=/[^.]+$/.exec(rr&&rr.keys&&rr.keys.IE_PROTO||""))?"Symbol(src)_1."+er:"";var ir=function(e){return!!nr&&nr in e},ar=Function.prototype.toString;var sr=function(e){if(null!=e){try{return ar.call(e)}catch(e){}try{return e+""}catch(e){}}return""},or=jt,lr=ir,ur=yt,cr=sr,dr=/^\[object .+?Constructor\]$/,hr=Function.prototype,fr=Object.prototype,br=hr.toString,pr=fr.hasOwnProperty,vr=RegExp("^"+br.call(pr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var mr=function(e){return!(!ur(e)||lr(e))&&(or(e)?vr:dr).test(cr(e))},yr=function(e,t){return null==e?void 0:e[t]};var gr=function(e,t){var r=yr(e,t);return mr(r)?r:void 0},wr=gr(ye,"Map"),jr=gr(Object,"create"),Or=jr;var Ir=function(){this.__data__=Or?Or(null):{},this.size=0};var kr=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Pr=jr,Ar=Object.prototype.hasOwnProperty;var Tr=function(e){var t=this.__data__;if(Pr){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return Ar.call(t,e)?t[e]:void 0},Cr=jr,Br=Object.prototype.hasOwnProperty;var Sr=jr;var _r=Ir,Er=kr,Rr=Tr,qr=function(e){var t=this.__data__;return Cr?void 0!==t[e]:Br.call(t,e)},Ur=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Sr&&void 0===t?"__lodash_hash_undefined__":t,this};function Dr(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Dr.prototype.clear=_r,Dr.prototype.delete=Er,Dr.prototype.get=Rr,Dr.prototype.has=qr,Dr.prototype.set=Ur;var xr=Dr,Nr=Kt,Mr=wr;var Fr=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var zr=function(e,t){var r=e.__data__;return Fr(t)?r["string"==typeof t?"string":"hash"]:r.map},Gr=zr;var Lr=zr;var $r=zr;var Wr=zr;var Vr=function(){this.size=0,this.__data__={hash:new xr,map:new(Mr||Nr),string:new xr}},Hr=function(e){var t=Gr(this,e).delete(e);return this.size-=t?1:0,t},Jr=function(e){return Lr(this,e).get(e)},Kr=function(e){return $r(this,e).has(e)},Zr=function(e,t){var r=Wr(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};function Yr(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Yr.prototype.clear=Vr,Yr.prototype.delete=Hr,Yr.prototype.get=Jr,Yr.prototype.has=Kr,Yr.prototype.set=Zr;var Qr=Yr,Xr=Kt,en=wr,tn=Qr;var rn=Kt,nn=Yt,an=Qt,sn=Xt,on=tr,ln=function(e,t){var r=this.__data__;if(r instanceof Xr){var n=r.__data__;if(!en||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new tn(n)}return r.set(e,t),this.size=r.size,this};function un(e){var t=this.__data__=new rn(e);this.size=t.size}un.prototype.clear=nn,un.prototype.delete=an,un.prototype.get=sn,un.prototype.has=on,un.prototype.set=ln;var cn=un;var dn=Qr,hn=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},fn=function(e){return this.__data__.has(e)};function bn(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new dn;++t<r;)this.add(e[t])}bn.prototype.add=bn.prototype.push=hn,bn.prototype.has=fn;var pn=bn;var vn=function(e,t){return e.has(t)},mn=pn,yn=function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1},gn=vn;var wn=function(e,t,r,n,i,a){var s=1&r,o=e.length,l=t.length;if(o!=l&&!(s&&l>o))return!1;var u=a.get(e),c=a.get(t);if(u&&c)return u==t&&c==e;var d=-1,h=!0,f=2&r?new mn:void 0;for(a.set(e,t),a.set(t,e);++d<o;){var b=e[d],p=t[d];if(n)var v=s?n(p,b,d,t,e,a):n(b,p,d,e,t,a);if(void 0!==v){if(v)continue;h=!1;break}if(f){if(!yn(t,(function(e,t){if(!gn(f,t)&&(b===e||i(b,e,r,n,a)))return f.push(t)}))){h=!1;break}}else if(b!==p&&!i(b,p,r,n,a)){h=!1;break}}return a.delete(e),a.delete(t),h};var jn=function(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r};var On=function(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r},In=ye.Uint8Array,kn=Ut,Pn=wn,An=jn,Tn=On,Cn=ge?ge.prototype:void 0,Bn=Cn?Cn.valueOf:void 0;var Sn=function(e,t,r,n,i,a,s){switch(r){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!a(new In(e),new In(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return kn(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var o=An;case"[object Set]":var l=1&n;if(o||(o=Tn),e.size!=t.size&&!l)return!1;var u=s.get(e);if(u)return u==t;n|=2,s.set(e,t);var c=Pn(o(e),o(t),n,i,a,s);return s.delete(e),c;case"[object Symbol]":if(Bn)return Bn.call(e)==Bn.call(t)}return!1};var _n=function(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e},En=Fe;var Rn=function(e,t,r){var n=t(e);return En(e)?n:_n(n,r(e))};var qn=function(e,t){for(var r=-1,n=null==e?0:e.length,i=0,a=[];++r<n;){var s=e[r];t(s,r,e)&&(a[i++]=s)}return a},Un=function(){return[]},Dn=Object.prototype.propertyIsEnumerable,xn=Object.getOwnPropertySymbols,Nn=Rn,Mn=xn?function(e){return null==e?[]:(e=Object(e),qn(xn(e),(function(t){return Dn.call(e,t)})))}:Un,Fn=Ct;var zn=function(e){return Nn(e,Fn,Mn)},Gn=Object.prototype.hasOwnProperty;var Ln=function(e,t,r,n,i,a){var s=1&r,o=zn(e),l=o.length;if(l!=zn(t).length&&!s)return!1;for(var u=l;u--;){var c=o[u];if(!(s?c in t:Gn.call(t,c)))return!1}var d=a.get(e),h=a.get(t);if(d&&h)return d==t&&h==e;var f=!0;a.set(e,t),a.set(t,e);for(var b=s;++u<l;){var p=e[c=o[u]],v=t[c];if(n)var m=s?n(v,p,c,t,e,a):n(p,v,c,e,t,a);if(!(void 0===m?p===v||i(p,v,r,n,a):m)){f=!1;break}b||(b="constructor"==c)}if(f&&!b){var y=e.constructor,g=t.constructor;y==g||!("constructor"in e)||!("constructor"in t)||"function"==typeof y&&y instanceof y&&"function"==typeof g&&g instanceof g||(f=!1)}return a.delete(e),a.delete(t),f},$n=gr(ye,"DataView"),Wn=gr(ye,"Promise"),Vn=gr(ye,"Set"),Hn=$n,Jn=wr,Kn=Wn,Zn=Vn,Yn=gr(ye,"WeakMap"),Qn=Se,Xn=sr,ei=Xn(Hn),ti=Xn(Jn),ri=Xn(Kn),ni=Xn(Zn),ii=Xn(Yn),ai=Qn;(Hn&&"[object DataView]"!=ai(new Hn(new ArrayBuffer(1)))||Jn&&"[object Map]"!=ai(new Jn)||Kn&&"[object Promise]"!=ai(Kn.resolve())||Zn&&"[object Set]"!=ai(new Zn)||Yn&&"[object WeakMap]"!=ai(new Yn))&&(ai=function(e){var t=Qn(e),r="[object Object]"==t?e.constructor:void 0,n=r?Xn(r):"";if(n)switch(n){case ei:return"[object DataView]";case ti:return"[object Map]";case ri:return"[object Promise]";case ni:return"[object Set]";case ii:return"[object WeakMap]"}return t});var si=cn,oi=wn,li=Sn,ui=Ln,ci=ai,di=Fe,hi=ze.exports,fi=nt,bi="[object Object]",pi=Object.prototype.hasOwnProperty;var vi=function(e,t,r,n,i,a){var s=di(e),o=di(t),l=s?"[object Array]":ci(e),u=o?"[object Array]":ci(t),c=(l="[object Arguments]"==l?bi:l)==bi,d=(u="[object Arguments]"==u?bi:u)==bi,h=l==u;if(h&&hi(e)){if(!hi(t))return!1;s=!0,c=!1}if(h&&!c)return a||(a=new si),s||fi(e)?oi(e,t,r,n,i,a):li(e,t,l,r,n,i,a);if(!(1&r)){var f=c&&pi.call(e,"__wrapped__"),b=d&&pi.call(t,"__wrapped__");if(f||b){var p=f?e.value():e,v=b?t.value():t;return a||(a=new si),i(p,v,r,n,a)}}return!!h&&(a||(a=new si),ui(e,t,r,n,i,a))},mi=_e;var yi=function e(t,r,n,i,a){return t===r||(null==t||null==r||!mi(t)&&!mi(r)?t!=t&&r!=r:vi(t,r,n,i,e,a))},gi=cn,wi=yi;var ji=yt;var Oi=function(e){return e==e&&!ji(e)},Ii=Oi,ki=Ct;var Pi=function(e,t){return function(r){return null!=r&&(r[e]===t&&(void 0!==t||e in Object(r)))}},Ai=function(e,t,r,n){var i=r.length,a=i,s=!n;if(null==e)return!a;for(e=Object(e);i--;){var o=r[i];if(s&&o[2]?o[1]!==e[o[0]]:!(o[0]in e))return!1}for(;++i<a;){var l=(o=r[i])[0],u=e[l],c=o[1];if(s&&o[2]){if(void 0===u&&!(l in e))return!1}else{var d=new gi;if(n)var h=n(u,c,l,e,t,d);if(!(void 0===h?wi(c,u,3,n,d):h))return!1}}return!0},Ti=function(e){for(var t=ki(e),r=t.length;r--;){var n=t[r],i=e[n];t[r]=[n,i,Ii(i)]}return t},Ci=Pi;var Bi=function(e){var t=Ti(e);return 1==t.length&&t[0][2]?Ci(t[0][0],t[0][1]):function(r){return r===e||Ai(r,e,t)}},Si=Se,_i=_e;var Ei=function(e){return"symbol"==typeof e||_i(e)&&"[object Symbol]"==Si(e)},Ri=Fe,qi=Ei,Ui=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Di=/^\w*$/;var xi=function(e,t){if(Ri(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!qi(e))||(Di.test(e)||!Ui.test(e)||null!=t&&e in Object(t))},Ni=Qr;function Mi(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],a=r.cache;if(a.has(i))return a.get(i);var s=e.apply(this,n);return r.cache=a.set(i,s)||a,s};return r.cache=new(Mi.Cache||Ni),r}Mi.Cache=Ni;var Fi=Mi;var zi=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Gi=/\\(\\)?/g,Li=function(e){var t=Fi(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(zi,(function(e,r,n,i){t.push(n?i.replace(Gi,"$1"):r||e)})),t}));var $i=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i},Wi=Fe,Vi=Ei,Hi=ge?ge.prototype:void 0,Ji=Hi?Hi.toString:void 0;var Ki=function e(t){if("string"==typeof t)return t;if(Wi(t))return $i(t,e)+"";if(Vi(t))return Ji?Ji.call(t):"";var r=t+"";return"0"==r&&1/t==-Infinity?"-0":r},Zi=Ki;var Yi=Fe,Qi=xi,Xi=Li,ea=function(e){return null==e?"":Zi(e)};var ta=function(e,t){return Yi(e)?e:Qi(e,t)?[e]:Xi(ea(e))},ra=Ei;var na=function(e){if("string"==typeof e||ra(e))return e;var t=e+"";return"0"==t&&1/e==-Infinity?"-0":t},ia=ta,aa=na;var sa=function(e,t){for(var r=0,n=(t=ia(t,e)).length;null!=e&&r<n;)e=e[aa(t[r++])];return r&&r==n?e:void 0},oa=sa;var la=ta,ua=Me,ca=Fe,da=$e,ha=We,fa=na;var ba=function(e,t){return null!=e&&t in Object(e)},pa=function(e,t,r){for(var n=-1,i=(t=la(t,e)).length,a=!1;++n<i;){var s=fa(t[n]);if(!(a=null!=e&&r(e,s)))break;e=e[s]}return a||++n!=i?a:!!(i=null==e?0:e.length)&&ha(i)&&da(s,i)&&(ca(e)||ua(e))};var va=yi,ma=function(e,t,r){var n=null==e?void 0:oa(e,t);return void 0===n?r:n},ya=function(e,t){return null!=e&&pa(e,t,ba)},ga=xi,wa=Oi,ja=Pi,Oa=na;var Ia=sa;var ka=function(e){return function(t){return null==t?void 0:t[e]}},Pa=function(e){return function(t){return Ia(t,e)}},Aa=xi,Ta=na;var Ca=Bi,Ba=function(e,t){return ga(e)&&wa(t)?ja(Oa(e),t):function(r){var n=ma(r,e);return void 0===n&&n===t?ya(r,e):va(t,n,3)}},Sa=function(e){return e},_a=Fe,Ea=function(e){return Aa(e)?ka(Ta(e)):Pa(e)};var Ra=function(e){return"function"==typeof e?e:null==e?Sa:"object"==typeof e?_a(e)?Ba(e[0],e[1]):Ca(e):Ea(e)},qa=he,Ua=Rt,Da=Ra,xa=Fe;var Na=function(e,t){return function(r,n){var i=xa(r)?qa:Ua,a=t?t():{};return i(r,e,Da(n),a)}}((function(e,t,r){e[r?0:1].push(t)}),(function(){return[[],[]]}));var Ma=function(e,t,r,n){for(var i=e.length,a=r+(n?1:-1);n?a--:++a<i;)if(t(e[a],a,e))return a;return-1},Fa=function(e){return e!=e},za=function(e,t,r){for(var n=r-1,i=e.length;++n<i;)if(e[n]===t)return n;return-1};var Ga=function(e,t,r){return t==t?za(e,t,r):Ma(e,Fa,r)};var La=function(e,t){return!!(null==e?0:e.length)&&Ga(e,t,0)>-1};var $a=function(e,t,r){for(var n=-1,i=null==e?0:e.length;++n<i;)if(r(t,e[n]))return!0;return!1};var Wa=Vn,Va=function(){},Ha=Wa&&1/On(new Wa([,-0]))[1]==1/0?function(e){return new Wa(e)}:Va,Ja=pn,Ka=La,Za=$a,Ya=vn,Qa=Ha,Xa=On;var es=function(e,t,r){var n=-1,i=Ka,a=e.length,s=!0,o=[],l=o;if(r)s=!1,i=Za;else if(a>=200){var u=t?null:Qa(e);if(u)return Xa(u);s=!1,i=Ya,l=new Ja}else l=t?[]:o;e:for(;++n<a;){var c=e[n],d=t?t(c):c;if(c=r||0!==c?c:0,s&&d==d){for(var h=l.length;h--;)if(l[h]===d)continue e;t&&l.push(d),o.push(c)}else i(l,d,r)||(l!==o&&l.push(d),o.push(c))}return o},ts=Ra,rs=es;var ns=function(e,t){return e&&e.length?rs(e,ts(t)):[]};const is=new Set(["LicensePlate","FaceDetection","Analytic","SpeedDetection","Temperature","PoS","GPS","DigitalInput"]);class as{constructor(e){if(Object.defineProperty(this,"cameraId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"thumbnailUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"detectedObjects",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"faces",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"instant",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n(this,{id:t,startTime:t,endTime:t,acknowledged:t,isLive:t,raw:i.ref}),this.raw=e,this.type=e.eventType,this.cameraId=e.sensorId,("Analytic"===this.type||"FaceDetection"===this.type)&&e.data)try{const t=JSON.parse(e.data);t.FoundObjects&&(this.type="Analytic",this.detectedObjects=t.FoundObjects),t.Faces&&(this.type="FaceDetection",this.faces=t.Faces),this.thumbnailUrl=t.ThumbnailUrl}catch{console.warn("invalid data",e.data),this.type="Motion"}this.instant=is.has(this.type),this.detectedObjects||(this.detectedObjects=[])}get id(){return this.raw.id}get startTime(){return new Date(this.raw.startTime)}get endTime(){return new Date(this.raw.endTime)}get isLive(){return!is.has(this.type)&&+this.startTime==+this.endTime}get acknowledged(){return"sensorId"in this.raw&&!!this.raw.ackEventType}}function ss(e){if(e.length<2)return e;const t=[e[0]];for(let r=1;r<e.length;r++){const n=t.length-1,i=t[n],a=e[r];a[0]>i[1]?t.push(a):t[n]=[i[0],new Date(Math.max(+i[1],+a[1]))]}return t}const os=()=>!0;/Mac|iPod|iPhone|iPad/.test(window.navigator.platform);class ls extends ee{constructor(e){super(),Object.defineProperty(this,"camerasStore",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"eventsByCameraId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"eventsByStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"eventsByEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"eventsByType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"eventsByFoundObjects",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"eventsByColor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"eventsByLiveliness",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pendingRequests",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pendingRequestsByEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pendingRequestsByStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pendingRequestsByCameraId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"knownIntervals",{enumerable:!0,configurable:!0,writable:!0,value:G()}),Object.defineProperty(this,"knownIntervalsByCameraId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"knownIntervalsByStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"knownIntervalsByEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"eventsById",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"updates",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"recentAdditions",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"update",{enumerable:!0,configurable:!0,writable:!0,value:e=>{e.forEach((e=>{const t=this.eventsById.get(e.id);t&&(t.raw=e.raw,this.data.remove((t=>t.id===e.id)),this.data.add([t]))}))}}),Object.defineProperty(this,"add",{enumerable:!0,configurable:!0,writable:!0,value:e=>{const t=e.filter((e=>!this.eventsById.has(e.id)));t.forEach((e=>this.eventsById.set(e.id,e))),this.data.add(t),t.length&&this.updates++}}),Object.defineProperty(this,"processNewEvents",{enumerable:!0,configurable:!0,writable:!0,value:({data:e})=>{const t=ns(e.filter((e=>this.camerasStore.camerasById.has(e.sensorId))).reverse(),"id").map((e=>new as(e))),[r,n]=Na(t,(e=>this.eventsById.has(e.id)));this.update(r),this.add(n),n.length&&(this.recentAdditions=n.map((e=>e.id)))}}),n(this,{updates:i,recentAdditions:i.ref,processNewEvents:a,update:a,add:a,dispose:a}),this.data=G(),this.eventsByCameraId=this.data.dimension((e=>e.cameraId)),this.eventsByStart=this.data.dimension((e=>+e.startTime)),this.eventsByEnd=this.data.dimension((e=>+e.endTime)),this.eventsByType=this.data.dimension((e=>e.type)),this.eventsByFoundObjects=this.data.dimension((e=>e.detectedObjects.map((e=>e.Type))),!0),this.eventsByColor=this.data.dimension((e=>e.detectedObjects.reduce(((e,t)=>{var r,n;return e.concat(...null!==(n=null===(r=t.Colors)||void 0===r?void 0:r.map((e=>e.Color)))&&void 0!==n?n:[])}),[])),!0),this.eventsByLiveliness=this.data.dimension((e=>e.isLive)),this.pendingRequests=G(),this.pendingRequestsByStart=this.pendingRequests.dimension((e=>+e.startTime)),this.pendingRequestsByEnd=this.pendingRequests.dimension((e=>+e.endTime)),this.pendingRequestsByCameraId=this.pendingRequests.dimension((e=>e.cameraId)),this.knownIntervalsByCameraId=this.knownIntervals.dimension((e=>e.cameraId)),this.knownIntervalsByStart=this.knownIntervals.dimension((e=>+e.from)),this.knownIntervalsByEnd=this.knownIntervals.dimension((e=>+e.to))}populateEvents(e,t,r){const n=null===r?new Date(Date.now()-6e5):r;-1===e?this.knownIntervalsByCameraId.filter(-1):this.knownIntervalsByCameraId.filter((t=>-1===t||t===e)),this.knownIntervalsByStart.filter([-1/0,n]),this.knownIntervalsByEnd.filter([t,1/0]);const i=this.knownIntervalsByStart.bottom(1/0),a=[];if(this.knownIntervalsByCameraId.filterAll(),this.knownIntervalsByStart.filterAll(),this.knownIntervalsByEnd.filterAll(),i.length){const s=ss(i.map((e=>[e.from,e.to])));s[0][0]>t&&a.push([t,s[0][0]]);for(let e=0;e<s.length-1;e++)a.push([s[e][1],s[e+1][0]]);s[ss.length-1][1]<n&&a.push([s[ss.length-1][1],n]),a.length&&(t=a[0][0],+a[a.length-1][1]<=+n&&(r=a[a.length-1][1]),this.knownIntervals.add([{cameraId:e,from:t,to:n}]))}else this.knownIntervals.add([{cameraId:e,from:t,to:n}]);this.pendingRequestsByCameraId.filter(e),this.pendingRequestsByStart.filter(t),this.pendingRequestsByEnd.filter(n);const s=this.pendingRequests.allFiltered()[0];if(this.pendingRequestsByCameraId.filterAll(),this.pendingRequestsByStart.filterAll(),this.pendingRequestsByEnd.filterAll(),s)return;if(i.length&&!a.length)return;const o=n=>this.api.cameras.GetSensorEventsPage({sensorIds:[e],sensorType:"camera",sensorEventTypes:[],startTime:t,endTime:r,rowsLimit:100,isDescending:!0,pageToken:n},null,[]).pipe(R((e=>e.success?w(e):(console.error(e.error),m((()=>e.error)))))),l=o().pipe(M((e=>e.pageInfo.haveMore?o(e.pageInfo.nextPageToken):c)),x((e=>e.resultItems.map((e=>new as(e))))),z());this.pendingRequests.add([{cameraId:e,startTime:t,endTime:r||new Date,request:l}]),l.subscribe({next:this.add,error:e=>{console.error(e),this.pendingRequests.remove((e=>e.request===l))},complete:()=>{this.pendingRequests.remove((e=>e.request===l))}})}getEvents({cameraIds:e,from:t,to:r,detectedObjectTypes:n,eventTypes:i,colors:a,probability:s}){this.eventsByStart.filter([+t,r?+r+5e-4:1/0]),(null==e?void 0:e.length)&&this.eventsByCameraId.filter((t=>e.includes(t))),(null==i?void 0:i.length)&&this.eventsByType.filter((e=>i.includes(e))),(null==n?void 0:n.length)&&this.eventsByFoundObjects.filter((e=>n.includes(e))),(null==a?void 0:a.size)&&this.eventsByColor.filter((e=>a.has(e)));let o=this.eventsByStart.top(1/0);return(null==i?void 0:i.length)&&this.eventsByType.filterAll(),(null==e?void 0:e.length)&&this.eventsByCameraId.filterAll(),(null==n?void 0:n.length)&&this.eventsByFoundObjects.filterAll(),(null==a?void 0:a.size)&&this.eventsByColor.filterAll(),this.eventsByStart.filterAll(),void 0!==s&&(null==n?void 0:n.length)&&(o=o.filter((e=>e.detectedObjects.some((e=>e.Probability>=s&&n.includes(e.Type)))))),o}getOverlappedEvents({cameraId:e,from:t,to:r}){this.eventsByCameraId.filter(e),this.eventsByStart.filter([-1/0,+r+5e-4]),this.eventsByEnd.filter([+t,1/0]);const n=this.eventsByStart.top(1/0);return this.eventsByCameraId.filterAll(),this.eventsByStart.filterAll(),this.eventsByStart.filterAll(),n}getLastNonAnalyticEventBefore({cameraId:e,date:t}){this.eventsByCameraId.filter(e),this.eventsByStart.filter([-1/0,+t]),this.eventsByType.filter((e=>"Analytic"!==e));const r=this.eventsByStart.top(1);return this.eventsByType.filterAll(),this.eventsByStart.filterAll(),this.eventsByCameraId.filterAll(),r[0]}getLastObjectBefore({cameraId:e,date:t,objectFilters:r}){this.eventsByCameraId.filter(e),this.eventsByStart.filter([-1/0,+t]),this.eventsByType.filter((e=>"Analytic"===e));const{cars:n,people:i,misc:a}=r;i&&n&&a||this.eventsByFoundObjects.filter((e=>a?i||n?!(!i||!n)||(i?"Car"!==e:"Person"!==e):"Person"!==e&&"Car"!==e:i&&n?"Person"===e||"Car"===e:i?"Person"===e:"Car"===e));const s=this.eventsByStart.top(1);return this.eventsByFoundObjects.filterAll(),this.eventsByType.filterAll(),this.eventsByStart.filterAll(),this.eventsByCameraId.filterAll(),s[0]}getFirstNonAnalyticEventAfter({cameraId:e,date:t}){this.eventsByCameraId.filter(e),this.eventsByStart.filter([+t+5e-4,1/0]),this.eventsByType.filter((e=>"Analytic"!==e));const r=this.eventsByEnd.bottom(1);return this.eventsByType.filterAll(),this.eventsByCameraId.filterAll(),this.eventsByStart.filterAll(),r[0]}getFirstObjectAfter({cameraId:e,date:t,objectFilters:r}){this.eventsByCameraId.filter(e),this.eventsByStart.filter([+t+5e-4,1/0]),this.eventsByType.filter((e=>"Analytic"===e));const{cars:n,people:i,misc:a}=r;i&&n&&a||this.eventsByFoundObjects.filter((e=>a?i||n?!(!i||!n)||(i?"Car"!==e:"Person"!==e):"Person"!==e&&"Car"!==e:i&&n?"Person"===e||"Car"===e:i?"Person"===e:"Car"===e));const s=this.eventsByStart.bottom(1);return this.eventsByFoundObjects.filterAll(),this.eventsByType.filterAll(),this.eventsByStart.filterAll(),this.eventsByCameraId.filterAll(),s[0]}afterInit(){this.api.events.pipe(D((({hub:e,event:t})=>"cameras"===e&&"OnCameraMotionEvent"===t))).subscribe(this.processNewEvents)}dispose(){super.dispose(),this.data.remove(os),this.updates++}}class us extends ee{constructor(){super(),Object.defineProperty(this,"thumbnails",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"thumbnailsByCameraId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"thumbnailsByDate",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pendingRequests",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pendingRequestsByEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pendingRequestsByStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pendingRequestsByCameraId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pendingRequestsByCount",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"toThumbnail",{enumerable:!0,configurable:!0,writable:!0,value:e=>({realtimestamp:t,url:r,width:n,height:i})=>({cameraId:e,url:r,width:n,height:i,timestamp:new Date(t)})}),this.thumbnails=G(),this.thumbnailsByCameraId=this.thumbnails.dimension((e=>e.cameraId)),this.thumbnailsByDate=this.thumbnails.dimension((e=>+e.timestamp)),this.pendingRequests=G(),this.pendingRequestsByStart=this.pendingRequests.dimension((e=>+e.from)),this.pendingRequestsByEnd=this.pendingRequests.dimension((e=>+e.to)),this.pendingRequestsByCameraId=this.pendingRequests.dimension((e=>e.cameraId)),this.pendingRequestsByCount=this.pendingRequests.dimension((e=>e.count))}fetchThumbnails(e,t,r,n){this.pendingRequestsByCameraId.filter(e),this.pendingRequestsByStart.filter(t),this.pendingRequestsByEnd.filter(r),this.pendingRequestsByCount.filter(n);const i=this.pendingRequests.allFiltered()[0];if(this.pendingRequestsByCameraId.filterAll(),this.pendingRequestsByStart.filterAll(),this.pendingRequestsByEnd.filterAll(),this.pendingRequestsByCount.filterAll(),i)return i.request;const a=this.api.thumbnails.GetThumbnailsInfo({cameraId:e,from:t,to:r,count:n}).pipe(x((t=>t.resultItems.filter((e=>e.url)).map(this.toThumbnail(e)))),q());return this.pendingRequests.add([{cameraId:e,from:t,to:r,count:n,request:a}]),a.subscribe((e=>{this.thumbnails.add(e),this.pendingRequests.remove((e=>e.request===a))})),a}getIntervalState(e,t,r){const n=this.getThumbnail({cameraId:e,from:t,to:r});if(n)return{state:"fullfilled",data:n};this.pendingRequestsByCameraId.filter(e),this.pendingRequestsByStart.filter([-1/0,+r+5e-4]),this.pendingRequestsByEnd.filter([t,1/0]);let i=this.pendingRequests.allFiltered();return this.pendingRequestsByCameraId.filterAll(),this.pendingRequestsByStart.filterAll(),this.pendingRequestsByEnd.filterAll(),i=i.filter((e=>1===e.count?+e.from==+t&&+e.to==+r:Math.abs((+e.to-+e.from)/e.count-(+r-+t))<=1)),i.length?{state:"pending",request:i[0].request}:null}fetchThumbnail(e,t,r){const n=this.getIntervalState(e,t,r);if(null!==n){if("fullfilled"===n.state)return w(n.data);if("pending"===n.state)return n.request.pipe(x((()=>this.getThumbnail({cameraId:e,from:t,to:r}))))}const i=this.api.thumbnails.GetThumbnailInfo({cameraId:e,from:t,to:r}).pipe(x((e=>e.resultItems)),q());return i.subscribe((t=>{const r=t.filter((e=>e.url)).map(this.toThumbnail(e));this.thumbnails.add(r),this.pendingRequests.remove((e=>e.request===i))})),this.pendingRequests.add([{cameraId:e,from:t,to:r,count:1,request:i}]),i.pipe(x((()=>this.getThumbnail({cameraId:e,from:t,to:r}))))}getThumbnail({cameraId:e,from:t,to:r}){this.thumbnailsByCameraId.filter(e),this.thumbnailsByDate.filter([+t,+r+(+t==+r?5e-4:0)]);const n=this.thumbnails.allFiltered()[0];return this.thumbnailsByDate.filterAll(),this.thumbnailsByCameraId.filterAll(),n}getThumbnails({cameraId:e,from:t,to:r}){this.thumbnailsByCameraId.filter(e),this.thumbnailsByDate.filter([+t,+r+5e-4]);const n=this.thumbnails.allFiltered();return this.thumbnailsByDate.filterAll(),this.thumbnailsByCameraId.filterAll(),n}}class cs{constructor(e){Object.defineProperty(this,"notifier",{enumerable:!0,configurable:!0,writable:!0,value:e})}error(e){this.notifier.error(e)}success(e,t){this.notifier.success(e,t)}warn(e){this.notifier.warn(e)}}const ds=new Map;class hs{constructor(t){Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"initialized",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"cameras",{enumerable:!0,configurable:!0,writable:!0,value:new se}),Object.defineProperty(this,"archives",{enumerable:!0,configurable:!0,writable:!0,value:new ie(this.cameras)}),Object.defineProperty(this,"events",{enumerable:!0,configurable:!0,writable:!0,value:new ls(this.cameras)}),Object.defineProperty(this,"eventSchema",{enumerable:!0,configurable:!0,writable:!0,value:new ce}),Object.defineProperty(this,"thumbnails",{enumerable:!0,configurable:!0,writable:!0,value:new us}),Object.defineProperty(this,"account",{enumerable:!0,configurable:!0,writable:!0,value:new re}),Object.defineProperty(this,"notification",{enumerable:!0,configurable:!0,writable:!0,value:new cs({success:console.log,warn:console.warn,error:console.error})}),Object.defineProperty(this,"auth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"api",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disposables",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"tokenUpdateReactions",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.disposables.forEach((e=>{e instanceof P?e.closed||e.unsubscribe():e()})),this.tokenUpdateReactions.forEach((e=>e())),this.tokenUpdateReactions.clear(),this.auth.signOut(),this.cameras.dispose(),this.events.dispose(),this.thumbnails.dispose(),this.eventSchema.dispose(),this.account.dispose(),ds.delete(this.name)}}),Object.defineProperty(this,"onTokenUpdate",{enumerable:!0,configurable:!0,writable:!0,value:t=>{if(!this.auth)throw new Error("app has to be inited first");const r=e((()=>this.auth.token),(e=>t((null==e?void 0:e.json)||null)));return this.tokenUpdateReactions.add(r),()=>{r(),this.tokenUpdateReactions.delete(r)}}}),n(this,{initialized:i}),this.disposables.push(s((()=>!!this.account.user),(()=>{this.cameras.load()})))}init({token:e,tokenStorage:t=new Q,tokenStorageKey:n,apiUrl:i="https://services.3deye.me/reactiveapi",tokenServiceUrl:a="https://admin.3deye.me/webapi/v3/auth/token"},s="default"){if(n||(n=`@3deye-toolkit/${s}/token`),ds.has(s))return console.warn("Can`t init two apps with the same name"),ds.get(s);if(this.auth&&s===this.name)return console.warn("Can`t init already inited app"),this;if(this.auth||"default"===this.name&&"default"!==s)return new hs(s).init({token:e,tokenStorage:t,tokenStorageKey:n,apiUrl:i,tokenServiceUrl:a},s);const o=e&&"clientId"in e?e.clientId:"WebApp";return e&&t.setItem(n,JSON.stringify(e)),this.auth=new Y({tokenServiceUrl:a,tokenStorageKey:n,storage:t,clientId:o,deviceInfo:null}),this.api=K.create(W,this.auth,(e=>_(i,{qs:{access_token:e}}))),this.cameras.initWith(this.api),this.archives.initWith(this.api),this.events.initWith(this.api),this.eventSchema.initWith(this.api),this.thumbnails.initWith(this.api),this.account.initWith(this.api),this.account.setAuthStore(this.auth),r((()=>{this.initialized=!0})),ds.set(s,this),this}}const fs=new hs("default"),bs=$.createContext(null);export{bs as AppContext,fs as app};
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.28.3"
9
+ }
10
+ ]
11
+ }
package/package.json CHANGED
@@ -1,15 +1,24 @@
1
1
  {
2
2
  "name": "@3deye-toolkit/core",
3
- "version": "0.0.1-alpha.3",
3
+ "version": "0.0.1-alpha.30",
4
4
  "module": "dist/core.js",
5
- "files": ["dist/core.js"],
5
+ "types": "dist/core.d.ts",
6
+ "files": [
7
+ "dist"
8
+ ],
6
9
  "dependencies": {
7
- "rxjs": "^6.5.4",
8
- "mobx": "^5.15.1",
9
- "crossfilter2": "^1.5.2",
10
- "jqueryless-signalr": "github:3deye/jqueryless-signalr",
11
- "object-assign": "4.1.1"
10
+ "crossfilter2": "^1.5.4",
11
+ "http-status-codes": "^2.2.0",
12
+ "jqueryless-signalr": "1.0.0",
13
+ "lodash": "4.17.21",
14
+ "mobx": "^6.3.13",
15
+ "rxjs": "^7.5.3",
16
+ "string-natural-compare": "^3.0.1"
17
+ },
18
+ "peerDependencies": {
19
+ "react": "^16.8.0 || ^17 || ^18",
20
+ "react-dom": "^16.8.0 || ^17 || ^18"
12
21
  },
13
22
  "sideEffects": false,
14
23
  "license": "mit"
15
- }
24
+ }