@3deye-toolkit/react-event-search 0.0.5 → 0.0.7

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.
@@ -79,7 +79,6 @@ declare class Api<T extends DeepPartial<IApi>> {
79
79
  shutdownConnection(): void;
80
80
  private init;
81
81
  private createHubMethod;
82
- private subscribeToEvents;
83
82
  }
84
83
 
85
84
  declare type ApiPageResult<T> = {
@@ -382,7 +381,7 @@ declare interface Connection {
382
381
  };
383
382
  };
384
383
  createHubProxy: (hubName: string) => void;
385
- lastError: any;
384
+ lastError: unknown;
386
385
  qs: {
387
386
  access_token: string;
388
387
  };
@@ -421,7 +420,6 @@ declare interface DetectedObjectOption {
421
420
  declare const events: {
422
421
  [P in keyof PartialApi]: {
423
422
  name: string;
424
- explicit?: boolean;
425
423
  }[];
426
424
  };
427
425
 
@@ -1378,7 +1376,6 @@ declare class ThumbnailsStore extends ApiStore {
1378
1376
 
1379
1377
  declare class Token {
1380
1378
  accessToken: string;
1381
- accessTokenExpires: Date;
1382
1379
  accessTokenIssued: Date;
1383
1380
  clientId: string;
1384
1381
  expiresIn: number;
@@ -1392,6 +1389,8 @@ declare class Token {
1392
1389
  widgetToken?: string;
1393
1390
  json: RawToken;
1394
1391
  constructor(raw: RawToken);
1392
+ private _exp;
1393
+ get accessTokenExpires(): Date;
1395
1394
  }
1396
1395
 
1397
1396
  declare class ToolkitApp implements App {
@@ -1 +1 @@
1
- import e from"i18next";import{of as t,from as r,Observable as n,Subscription as i,mergeMap as o,throwError as a,catchError as s,startWith as l,switchMap as c,map as h,exhaustMap as d,EMPTY as u,Subject as p}from"rxjs";import{AppContext as f,app as m}from"@3deye-toolkit/core";import{jsx as g,jsxs as v,Fragment as y}from"react/jsx-runtime";import b,{forwardRef as x,memo as w,useState as C,useRef as T,useEffect as M,createContext as _,Component as D,useCallback as L,useMemo as N,cloneElement as I,useContext as k,useLayoutEffect as z}from"react";import{useElementSize as j}from"@mantine/hooks";import{observer as F}from"mobx-react-lite";import O from"clsx";import S from"react-ink";import{useMergeRefs as B,useListItem as P,useFloatingTree as R,useFloating as U,offset as A,flip as H,shift as E,arrow as $,autoUpdate as V,useInteractions as Z,useRole as W,useDismiss as Y,FloatingPortal as q,FloatingFocusManager as G,useId as Q,size as J,useListNavigation as X,useHover as K}from"@floating-ui/react";import ee from"@seznam/compose-react-refs";import{differenceInCalendarDays as te,max as re,min as ne}from"date-fns";import ie from"memoize-one";import{extent as oe,bin as ae,max as se}from"d3-array";import{select as le}from"d3-selection";import{scaleTime as ce,scaleLinear as he}from"d3-scale";import{timeHours as de,timeHour as ue,timeMinute as pe}from"d3-time";import{axisBottom as fe}from"d3-axis";import{brushX as me}from"d3-brush";import{timeFormat as ge}from"d3-time-format";import ve from"resize-observer-polyfill";import{computed as ye,observe as be,makeObservable as xe,observable as we,action as Ce,runInAction as Te,reaction as Me}from"mobx";import{distinctUntilChanged as _e,share as De,switchMap as Le,mergeMap as Ne,catchError as Ie,map as ke}from"rxjs/operators";var ze={selectObjectType:"Select object type",showEvents_one:"show {{count}} new event",showEvents_other:"show {{count}} new events",noEventsFound:"no events found",eventTypes:{Loitering:"Loitering"},filter:"Filter",color:"color",select:{loading:"Loading...",noOptions:"No options"},confidence:"confidence",today:"today",yesterday:"yesterday",button:{ok:"Ok"},peopleCounting:"People Counting",selected:"selected",total:"total",event:{acknowledged:"acknowledged"}};const je={detection:{order:["querystring","htmlTag","navigator"],lookupQuerystring:"lang"},fallbackLng:"en",load:"all",interpolation:{escapeValue:!1}},Fe=e.createInstance(),Oe=([e,t],[r,n],[i,o])=>{const a=(n-t)*(i-r)-(r-e)*(o-n);return 0===a?0:a>0?1:2},Se=([e,t],[r,n],[i,o])=>r<=Math.max(e,i)&&r>=Math.min(e,i)&&n<=Math.max(t,o)&&n>=Math.min(t,o);var Be="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Pe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Re={exports:{}};function Ue(e,t,r){r=r||2;var n,i,o,a,s,l,c,h=t&&t.length,d=h?t[0]*r:e.length,u=Ae(e,0,d,r,!0),p=[];if(!u||u.next===u.prev)return p;if(h&&(u=function(e,t,r,n){var i,o,a,s=[];for(i=0,o=t.length;i<o;i++)(a=Ae(e,t[i]*n,i<o-1?t[i+1]*n:e.length,n,!1))===a.next&&(a.steiner=!0),s.push(Je(a));for(s.sort(Ye),i=0;i<s.length;i++)r=qe(s[i],r);return r}(e,t,u,r)),e.length>80*r){n=o=e[0],i=a=e[1];for(var f=r;f<d;f+=r)(s=e[f])<n&&(n=s),(l=e[f+1])<i&&(i=l),s>o&&(o=s),l>a&&(a=l);c=0!==(c=Math.max(o-n,a-i))?32767/c:0}return Ee(u,p,r,n,i,c,0),p}function Ae(e,t,r,n,i){var o,a;if(i===ht(e,t,r,n)>0)for(o=t;o<r;o+=n)a=st(o,e[o],e[o+1],a);else for(o=r-n;o>=t;o-=n)a=st(o,e[o],e[o+1],a);return a&&tt(a,a.next)&&(lt(a),a=a.next),a}function He(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!tt(n,n.next)&&0!==et(n.prev,n,n.next))n=n.next;else{if(lt(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function Ee(e,t,r,n,i,o,a){if(e){!a&&o&&function(e,t,r,n){var i=e;do{0===i.z&&(i.z=Qe(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,r,n,i,o,a,s,l,c=1;do{for(r=e,e=null,o=null,a=0;r;){for(a++,n=r,s=0,t=0;t<c&&(s++,n=n.nextZ);t++);for(l=c;s>0||l>0&&n;)0!==s&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,l--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;r=n}o.nextZ=null,c*=2}while(a>1)}(i)}(e,n,i,o);for(var s,l,c=e;e.prev!==e.next;)if(s=e.prev,l=e.next,o?Ve(e,n,i,o):$e(e))t.push(s.i/r|0),t.push(e.i/r|0),t.push(l.i/r|0),lt(e),e=l.next,c=l.next;else if((e=l)===c){a?1===a?Ee(e=Ze(He(e),t,r),t,r,n,i,o,2):2===a&&We(e,t,r,n,i,o):Ee(He(e),t,r,n,i,o,1);break}}}function $e(e){var t=e.prev,r=e,n=e.next;if(et(t,r,n)>=0)return!1;for(var i=t.x,o=r.x,a=n.x,s=t.y,l=r.y,c=n.y,h=i<o?i<a?i:a:o<a?o:a,d=s<l?s<c?s:c:l<c?l:c,u=i>o?i>a?i:a:o>a?o:a,p=s>l?s>c?s:c:l>c?l:c,f=n.next;f!==t;){if(f.x>=h&&f.x<=u&&f.y>=d&&f.y<=p&&Xe(i,s,o,l,a,c,f.x,f.y)&&et(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Ve(e,t,r,n){var i=e.prev,o=e,a=e.next;if(et(i,o,a)>=0)return!1;for(var s=i.x,l=o.x,c=a.x,h=i.y,d=o.y,u=a.y,p=s<l?s<c?s:c:l<c?l:c,f=h<d?h<u?h:u:d<u?d:u,m=s>l?s>c?s:c:l>c?l:c,g=h>d?h>u?h:u:d>u?d:u,v=Qe(p,f,t,r,n),y=Qe(m,g,t,r,n),b=e.prevZ,x=e.nextZ;b&&b.z>=v&&x&&x.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==i&&b!==a&&Xe(s,h,l,d,c,u,b.x,b.y)&&et(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==i&&x!==a&&Xe(s,h,l,d,c,u,x.x,x.y)&&et(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;b&&b.z>=v;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==i&&b!==a&&Xe(s,h,l,d,c,u,b.x,b.y)&&et(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;x&&x.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==i&&x!==a&&Xe(s,h,l,d,c,u,x.x,x.y)&&et(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Ze(e,t,r){var n=e;do{var i=n.prev,o=n.next.next;!tt(i,o)&&rt(i,n,n.next,o)&&ot(i,o)&&ot(o,i)&&(t.push(i.i/r|0),t.push(n.i/r|0),t.push(o.i/r|0),lt(n),lt(n.next),n=e=o),n=n.next}while(n!==e);return He(n)}function We(e,t,r,n,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Ke(a,s)){var l=at(a,s);return a=He(a,a.next),l=He(l,l.next),Ee(a,t,r,n,i,o,0),void Ee(l,t,r,n,i,o,0)}s=s.next}a=a.next}while(a!==e)}function Ye(e,t){return e.x-t.x}function qe(e,t){var r=function(e,t){var r,n=t,i=e.x,o=e.y,a=-1/0;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){var s=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>a&&(a=s,r=n.x<n.next.x?n:n.next,s===i))return r}n=n.next}while(n!==t);if(!r)return null;var l,c=r,h=r.x,d=r.y,u=1/0;n=r;do{i>=n.x&&n.x>=h&&i!==n.x&&Xe(o<d?i:a,o,h,d,o<d?a:i,o,n.x,n.y)&&(l=Math.abs(o-n.y)/(i-n.x),ot(n,e)&&(l<u||l===u&&(n.x>r.x||n.x===r.x&&Ge(r,n)))&&(r=n,u=l)),n=n.next}while(n!==c);return r}(e,t);if(!r)return t;var n=at(r,e);return He(n,n.next),He(r,r.next)}function Ge(e,t){return et(e.prev,e,t.prev)<0&&et(t.next,e,e.next)<0}function Qe(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Je(e){var t=e,r=e;do{(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next}while(t!==e);return r}function Xe(e,t,r,n,i,o,a,s){return(i-a)*(t-s)>=(e-a)*(o-s)&&(e-a)*(n-s)>=(r-a)*(t-s)&&(r-a)*(o-s)>=(i-a)*(n-s)}function Ke(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&rt(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(ot(e,t)&&ot(t,e)&&function(e,t){var r=e,n=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&i<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==e);return n}(e,t)&&(et(e.prev,e,t.prev)||et(e,t.prev,t))||tt(e,t)&&et(e.prev,e,e.next)>0&&et(t.prev,t,t.next)>0)}function et(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function tt(e,t){return e.x===t.x&&e.y===t.y}function rt(e,t,r,n){var i=it(et(e,t,r)),o=it(et(e,t,n)),a=it(et(r,n,e)),s=it(et(r,n,t));return i!==o&&a!==s||(!(0!==i||!nt(e,r,t))||(!(0!==o||!nt(e,n,t))||(!(0!==a||!nt(r,e,n))||!(0!==s||!nt(r,t,n)))))}function nt(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function it(e){return e>0?1:e<0?-1:0}function ot(e,t){return et(e.prev,e,e.next)<0?et(e,t,e.next)>=0&&et(e,e.prev,t)>=0:et(e,t,e.prev)<0||et(e,e.next,t)<0}function at(e,t){var r=new ct(e.i,e.x,e.y),n=new ct(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function st(e,t,r,n){var i=new ct(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function lt(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function ct(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ht(e,t,r,n){for(var i=0,o=t,a=r-n;o<r;o+=n)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}Re.exports=Ue,Re.exports.default=Ue,Ue.deviation=function(e,t,r,n){var i=t&&t.length,o=i?t[0]*r:e.length,a=Math.abs(ht(e,0,o,r));if(i)for(var s=0,l=t.length;s<l;s++){var c=t[s]*r,h=s<l-1?t[s+1]*r:e.length;a-=Math.abs(ht(e,c,h,r))}var d=0;for(s=0;s<n.length;s+=3){var u=n[s]*r,p=n[s+1]*r,f=n[s+2]*r;d+=Math.abs((e[u]-e[f])*(e[p+1]-e[u+1])-(e[u]-e[p])*(e[f+1]-e[u+1]))}return 0===a&&0===d?0:Math.abs((d-a)/a)},Ue.flatten=function(e){for(var t=e[0][0].length,r={vertices:[],holes:[],dimensions:t},n=0,i=0;i<e.length;i++){for(var o=0;o<e[i].length;o++)for(var a=0;a<t;a++)r.vertices.push(e[i][o][a]);i>0&&(n+=e[i-1].length,r.holes.push(n))}return r};var dt=Pe(Re.exports);var ut=function(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n<i;)o[n]=e[n+t];return o};var pt=function(e,t){return e===t||e!=e&&t!=t},ft="object"==typeof Be&&Be&&Be.Object===Object&&Be,mt=ft,gt="object"==typeof self&&self&&self.Object===Object&&self,vt=mt||gt||Function("return this")(),yt=vt.Symbol,bt=yt,xt=Object.prototype,wt=xt.hasOwnProperty,Ct=xt.toString,Tt=bt?bt.toStringTag:void 0;var Mt=function(e){var t=wt.call(e,Tt),r=e[Tt];try{e[Tt]=void 0;var n=!0}catch(e){}var i=Ct.call(e);return n&&(t?e[Tt]=r:delete e[Tt]),i},_t=Object.prototype.toString;var Dt=Mt,Lt=function(e){return _t.call(e)},Nt=yt?yt.toStringTag:void 0;var It=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Nt&&Nt in Object(e)?Dt(e):Lt(e)};var kt=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},zt=It,jt=kt;var Ft=function(e){if(!jt(e))return!1;var t=zt(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t};var Ot=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991},St=Ft,Bt=Ot;var Pt=function(e){return null!=e&&Bt(e.length)&&!St(e)},Rt=/^(?:0|[1-9]\d*)$/;var Ut=function(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&Rt.test(e))&&e>-1&&e%1==0&&e<t},At=pt,Ht=Pt,Et=Ut,$t=kt;var Vt=/\s/;var Zt=function(e){for(var t=e.length;t--&&Vt.test(e.charAt(t)););return t},Wt=/^\s+/;var Yt=function(e){return null!=e&&"object"==typeof e},qt=It,Gt=Yt;var Qt=function(e){return e?e.slice(0,Zt(e)+1).replace(Wt,""):e},Jt=kt,Xt=function(e){return"symbol"==typeof e||Gt(e)&&"[object Symbol]"==qt(e)},Kt=/^[-+]0x[0-9a-f]+$/i,er=/^0b[01]+$/i,tr=/^0o[0-7]+$/i,rr=parseInt;var nr=function(e){if("number"==typeof e)return e;if(Xt(e))return NaN;if(Jt(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Jt(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Qt(e);var r=er.test(e);return r||tr.test(e)?rr(e.slice(2),r?2:8):Kt.test(e)?NaN:+e},ir=1/0;var or=function(e){return e?(e=nr(e))===ir||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0};var ar=ut,sr=function(e,t,r){if(!$t(r))return!1;var n=typeof t;return!!("number"==n?Ht(r)&&Et(t,r.length):"string"==n&&t in r)&&At(r[t],e)},lr=function(e){var t=or(e),r=t%1;return t==t?r?t-r:t:0},cr=Math.ceil,hr=Math.max;var dr=function(e,t,r){t=(r?sr(e,t,r):void 0===t)?1:hr(lr(t),0);var n=null==e?0:e.length;if(!n||t<1)return[];for(var i=0,o=0,a=Array(cr(n/t));i<n;)a[o++]=ar(e,i,i+=t);return a},ur=Pe(dr);const pr=(e,t,r)=>!(e<r.x||t<r.y||e>r.x+r.width||t>r.y+r.height),fr=(e,t,r)=>{const n=r.y1*r.x3-r.x1*r.y3+(r.y3-r.y1)*e+(r.x1-r.x3)*t,i=r.x1*r.y2-r.y1*r.x2+(r.y1-r.y2)*e+(r.x2-r.x1)*t;if(n<0!=i<0)return!1;const o=-r.y2*r.x3+r.y1*(r.x3-r.x2)+r.x1*(r.y2-r.y3)+r.x2*r.y3;return o<0?n<=0&&n+i>=o:n>=0&&n+i<=o},mr=(e,t)=>{if(pr(t.x1,t.y1,e))return!0;if(pr(t.x2,t.y2,e))return!0;if(pr(t.x3,t.y3,e))return!0;if(fr(e.x,e.y,t))return!0;if(fr(e.x+e.width,e.y,t))return!0;if(fr(e.x+e.width,e.y+e.height,t))return!0;if(fr(e.x,e.y+e.height,t))return!0;const r=[[[e.x,e.y],[e.x+e.width,e.y]],[[e.x+e.width,e.y],[e.x+e.width,e.y+e.height]],[[e.x,e.y+e.height],[e.x+e.width,e.y+e.height]],[[e.x,e.y],[e.x,e.y+e.height]]];return!![[[t.x1,t.y1],[t.x2,t.y2]],[[t.x1,t.y1],[t.x3,t.y3]]].some((e=>r.some((t=>(([e,t],[r,n])=>{const i=Oe(e,t,r),o=Oe(e,t,n),a=Oe(r,n,e),s=Oe(r,n,t);return i!==o&&a!==s||!(0!==i||!Se(e,r,t))||!(0!==o||!Se(e,n,t))||!(0!==a||!Se(r,e,n))||!(0!==s||!Se(r,t,n))})(t,e)))))},gr=(e,t)=>{const r=e.map((({x:e,y:t})=>[e,t]));return ur(dt(r.flat()),3).some((r=>mr(t,{x1:e[r[0]].x,y1:e[r[0]].y,x2:e[r[1]].x,y2:e[r[1]].y,x3:e[r[2]].x,y3:e[r[2]].y})))};function vr(e,t){const r=new Date(e);return r.setHours(23,59,59,999),t&&r.setUTCHours(23,59,59,999),r}const yr=(e,t,r)=>r?e.getUTCFullYear()===t.getUTCFullYear()&&e.getUTCMonth()===t.getUTCMonth()&&e.getUTCDate()===t.getUTCDate():e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),br=(e,t,r)=>r?e.getUTCFullYear()===t.getUTCFullYear():e.getFullYear()===t.getFullYear();function xr(e,t,r){return function(e,t,r){return r?new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t,e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds())):new Date(e.getFullYear(),e.getMonth(),e.getDate()+t,e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(e,-t,r)}function wr(e,t){return new Date(e.getTime()-60*t*60*1e3)}const Cr=b.createContext(null);function Tr(e,t=!1){const r=ye(e);return new n((e=>{const n=be(r,(({newValue:t})=>e.next(t)),t);return()=>n()}))}var Mr;!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.VehicleBreakIn=40]="VehicleBreakIn",e[e.DrugTrafficking=41]="DrugTrafficking",e[e.Assault=42]="Assault",e[e.PackageDelivery=43]="PackageDelivery",e[e.Uncategorized=999]="Uncategorized"}(Mr||(Mr={}));const _r=new Set(["LicensePlate","FaceDetection","Analytic","SpeedDetection","Temperature","PoS","GPS","DigitalInput","Loitering"]);class Dr{id;cameraId;type;raw;thumbnailUrl;thumbnailWidth=0;thumbnailHeight=0;detectedObjects;faces;instant;get startTime(){return new Date(this.raw.startTime)}get endTime(){return new Date(this.raw.endTime)}get isLive(){return!_r.has(this.type)&&+this.startTime==+this.endTime}get acknowledged(){return"sensorId"in this.raw&&!!this.raw.ackEventType}update=e=>{this.raw=e};constructor(e){if(xe(this,{startTime:ye,endTime:ye,acknowledged:ye,isLive:ye,raw:we.ref,update:Ce}),this.raw=e,this.id=e.id,this.type=e.eventType,this.cameraId=e.sensorId,("Analytic"===this.type||"FaceDetection"===this.type||"Loitering"===this.type)&&e.data)try{const t=JSON.parse(e.data);t.FoundObjects&&(this.detectedObjects=t.FoundObjects),t.Faces&&(this.type="FaceDetection",this.faces=t.Faces),t.ThumbnailSize&&(this.thumbnailWidth=t.ThumbnailSize.Width,this.thumbnailHeight=t.ThumbnailSize.Height),this.thumbnailUrl=t.ThumbnailUrl}catch{console.warn("invalid data",e.data),this.type="Motion"}this.instant=_r.has(this.type),this.detectedObjects||(this.detectedObjects=[])}}const Lr=(e,{locale:t,utc:r=!1,hour12:n=!1,seconds:i,year:o=!1,dayOfWeek:a=!1,day:s=!1})=>{const l={hour:"numeric",minute:"numeric",hour12:n||void 0,hourCycle:n?void 0:"h23"};return r&&(l.timeZone="UTC"),i&&(l.second="numeric"),o&&(l.year="numeric"),a&&(l.weekday="short"),s&&(l.day="numeric",l.month="short"),new Intl.DateTimeFormat(t,l).format(e)},Nr=(e,t)=>t?e.getUTCSeconds():e.getSeconds();function Ir(e,t,{locale:r,utc:n=!1,hour12:i=!1}={}){let o="",a="";const s=Boolean(Nr(e,n)||Nr(t,n)),l={from:!1,to:!1},c={from:!1,to:!1},h={from:!1,to:!1};return br(e,new Date,n)?yr(e,new Date,n)||(yr(e,t,n)?(h.from=!0,c.from=!0):(h.from=!0,c.from=!0,h.to=!0,c.to=!0)):(l.from=!0,h.from=!0,h.to=!0,l.to=!br(e,t,n)),o=Lr(e,{locale:r,utc:n,hour12:i,seconds:s,year:l.from,dayOfWeek:c.from,day:h.from}),+e==+t?o:(a=Lr(t,{locale:r,utc:n,hour12:i,seconds:s,year:l.to,dayOfWeek:c.to,day:h.to}),`${o} - ${a}`)}var kr,zr=vt["__core-js_shared__"],jr=(kr=/[^.]+$/.exec(zr&&zr.keys&&zr.keys.IE_PROTO||""))?"Symbol(src)_1."+kr:"";var Fr=function(e){return!!jr&&jr in e},Or=Function.prototype.toString;var Sr=function(e){if(null!=e){try{return Or.call(e)}catch(e){}try{return e+""}catch(e){}}return""},Br=Ft,Pr=Fr,Rr=kt,Ur=Sr,Ar=/^\[object .+?Constructor\]$/,Hr=Function.prototype,Er=Object.prototype,$r=Hr.toString,Vr=Er.hasOwnProperty,Zr=RegExp("^"+$r.call(Vr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var Wr=function(e){return!(!Rr(e)||Pr(e))&&(Br(e)?Zr:Ar).test(Ur(e))},Yr=function(e,t){return null==e?void 0:e[t]};var qr=function(e,t){var r=Yr(e,t);return Wr(r)?r:void 0},Gr=qr(Object,"create"),Qr=Gr;var Jr=function(){this.__data__=Qr?Qr(null):{},this.size=0};var Xr=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Kr=Gr,en=Object.prototype.hasOwnProperty;var tn=function(e){var t=this.__data__;if(Kr){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return en.call(t,e)?t[e]:void 0},rn=Gr,nn=Object.prototype.hasOwnProperty;var on=function(e){var t=this.__data__;return rn?void 0!==t[e]:nn.call(t,e)},an=Gr;var sn=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=an&&void 0===t?"__lodash_hash_undefined__":t,this},ln=Jr,cn=Xr,hn=tn,dn=on,un=sn;function pn(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])}}pn.prototype.clear=ln,pn.prototype.delete=cn,pn.prototype.get=hn,pn.prototype.has=dn,pn.prototype.set=un;var fn=pn;var mn=function(){this.__data__=[],this.size=0},gn=pt;var vn=function(e,t){for(var r=e.length;r--;)if(gn(e[r][0],t))return r;return-1},yn=vn,bn=Array.prototype.splice;var xn=function(e){var t=this.__data__,r=yn(t,e);return!(r<0)&&(r==t.length-1?t.pop():bn.call(t,r,1),--this.size,!0)},wn=vn;var Cn=function(e){var t=this.__data__,r=wn(t,e);return r<0?void 0:t[r][1]},Tn=vn;var Mn=vn;var _n=function(e,t){var r=this.__data__,n=Mn(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},Dn=mn,Ln=xn,Nn=Cn,In=function(e){return Tn(this.__data__,e)>-1},kn=_n;function zn(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])}}zn.prototype.clear=Dn,zn.prototype.delete=Ln,zn.prototype.get=Nn,zn.prototype.has=In,zn.prototype.set=kn;var jn=zn,Fn=qr(vt,"Map"),On=fn,Sn=jn,Bn=Fn;var Pn=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var Rn=function(e,t){var r=e.__data__;return Pn(t)?r["string"==typeof t?"string":"hash"]:r.map},Un=Rn;var An=Rn;var Hn=Rn;var En=Rn;var $n=function(e,t){var r=En(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},Vn=function(){this.size=0,this.__data__={hash:new On,map:new(Bn||Sn),string:new On}},Zn=function(e){var t=Un(this,e).delete(e);return this.size-=t?1:0,t},Wn=function(e){return An(this,e).get(e)},Yn=function(e){return Hn(this,e).has(e)},qn=$n;function Gn(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])}}Gn.prototype.clear=Vn,Gn.prototype.delete=Zn,Gn.prototype.get=Wn,Gn.prototype.has=Yn,Gn.prototype.set=qn;var Qn=Gn,Jn=Qn;function Xn(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],o=r.cache;if(o.has(i))return o.get(i);var a=e.apply(this,n);return r.cache=o.set(i,a)||o,a};return r.cache=new(Xn.Cache||Jn),r}Xn.Cache=Jn;const Kn=Pe(Xn)((()=>{const e=document.createElement("div");e.style.overflowY="scroll",e.style.position="absolute",e.style.top="-9999px",document.body.append(e);const t=e.offsetWidth;return e.remove(),t}));function ei(e,t,r=!0){if((e=Math.round(e/1e3))<60)return t("duration.ss",{seconds:e});const n=e%60;let i=(e-n)/60;if(i<60)return!n&&r?t("duration.mm",{minutes:i}):t("duration.mmss",{minutes:i,seconds:`${n}`.padStart(2,"0")});const o=Math.floor(i/60);if(i-=60*o,!n&&!i&&r)return t("duration.hh",{hours:o});const a=r?`${i}`:`${i}`.padStart(2,"0");return!n&&i&&r?t("duration.hhmm",{hours:o,minutes:a}):t("duration.hhmmss",{hours:o,minutes:a,seconds:`${n}`.padStart(2,"0")})}const ti=(e,t,r)=>Math.min(Math.max(e,t),r);class ri{api;disposables=[];initWith(e){this.api=e,this.afterInit&&this.afterInit()}dispose(){for(const e of this.disposables)e instanceof i?e.closed||e.unsubscribe():e()}}var ni=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n},ii=It,oi=Yt;var ai=function(e){return oi(e)&&"[object Arguments]"==ii(e)},si=Yt,li=Object.prototype,ci=li.hasOwnProperty,hi=li.propertyIsEnumerable,di=ai(function(){return arguments}())?ai:function(e){return si(e)&&ci.call(e,"callee")&&!hi.call(e,"callee")},ui=Array.isArray,pi={exports:{}};var fi=function(){return!1};!function(e,t){var r=vt,n=fi,i=t&&!t.nodeType&&t,o=i&&e&&!e.nodeType&&e,a=o&&o.exports===i?r.Buffer:void 0,s=(a?a.isBuffer:void 0)||n;e.exports=s}(pi,pi.exports);var mi=pi.exports,gi=It,vi=Ot,yi=Yt,bi={};bi["[object Float32Array]"]=bi["[object Float64Array]"]=bi["[object Int8Array]"]=bi["[object Int16Array]"]=bi["[object Int32Array]"]=bi["[object Uint8Array]"]=bi["[object Uint8ClampedArray]"]=bi["[object Uint16Array]"]=bi["[object Uint32Array]"]=!0,bi["[object Arguments]"]=bi["[object Array]"]=bi["[object ArrayBuffer]"]=bi["[object Boolean]"]=bi["[object DataView]"]=bi["[object Date]"]=bi["[object Error]"]=bi["[object Function]"]=bi["[object Map]"]=bi["[object Number]"]=bi["[object Object]"]=bi["[object RegExp]"]=bi["[object Set]"]=bi["[object String]"]=bi["[object WeakMap]"]=!1;var xi=function(e){return yi(e)&&vi(e.length)&&!!bi[gi(e)]};var wi=function(e){return function(t){return e(t)}},Ci={exports:{}};!function(e,t){var r=ft,n=t&&!t.nodeType&&t,i=n&&e&&!e.nodeType&&e,o=i&&i.exports===n&&r.process,a=function(){try{var e=i&&i.require&&i.require("util").types;return e||o&&o.binding&&o.binding("util")}catch(e){}}();e.exports=a}(Ci,Ci.exports);var Ti=Ci.exports,Mi=xi,_i=wi,Di=Ti&&Ti.isTypedArray,Li=Di?_i(Di):Mi,Ni=ni,Ii=di,ki=ui,zi=mi,ji=Ut,Fi=Li,Oi=Object.prototype.hasOwnProperty;var Si=function(e,t){var r=ki(e),n=!r&&Ii(e),i=!r&&!n&&zi(e),o=!r&&!n&&!i&&Fi(e),a=r||n||i||o,s=a?Ni(e.length,String):[],l=s.length;for(var c in e)!t&&!Oi.call(e,c)||a&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||ji(c,l))||s.push(c);return s},Bi=Object.prototype;var Pi=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Bi)};var Ri=function(e,t){return function(r){return e(t(r))}}(Object.keys,Object),Ui=Pi,Ai=Ri,Hi=Object.prototype.hasOwnProperty;var Ei=Si,$i=function(e){if(!Ui(e))return Ai(e);var t=[];for(var r in Object(e))Hi.call(e,r)&&"constructor"!=r&&t.push(r);return t},Vi=Pt;var Zi=function(e){return Vi(e)?Ei(e):$i(e)},Wi=jn;var Yi=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r};var qi=jn,Gi=Fn,Qi=Qn;var Ji=function(e,t){var r=this.__data__;if(r instanceof qi){var n=r.__data__;if(!Gi||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Qi(n)}return r.set(e,t),this.size=r.size,this},Xi=jn,Ki=function(){this.__data__=new Wi,this.size=0},eo=Yi,to=function(e){return this.__data__.get(e)},ro=function(e){return this.__data__.has(e)},no=Ji;function io(e){var t=this.__data__=new Xi(e);this.size=t.size}io.prototype.clear=Ki,io.prototype.delete=eo,io.prototype.get=to,io.prototype.has=ro,io.prototype.set=no;var oo=io;var ao=Qn,so=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},lo=function(e){return this.__data__.has(e)};function co(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new ao;++t<r;)this.add(e[t])}co.prototype.add=co.prototype.push=so,co.prototype.has=lo;var ho=co,uo=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},po=function(e,t){return e.has(t)};var fo=function(e,t,r,n,i,o){var a=1&r,s=e.length,l=t.length;if(s!=l&&!(a&&l>s))return!1;var c=o.get(e),h=o.get(t);if(c&&h)return c==t&&h==e;var d=-1,u=!0,p=2&r?new ho:void 0;for(o.set(e,t),o.set(t,e);++d<s;){var f=e[d],m=t[d];if(n)var g=a?n(m,f,d,t,e,o):n(f,m,d,e,t,o);if(void 0!==g){if(g)continue;u=!1;break}if(p){if(!uo(t,(function(e,t){if(!po(p,t)&&(f===e||i(f,e,r,n,o)))return p.push(t)}))){u=!1;break}}else if(f!==m&&!i(f,m,r,n,o)){u=!1;break}}return o.delete(e),o.delete(t),u};var mo=function(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r};var go=vt.Uint8Array,vo=pt,yo=fo,bo=mo,xo=function(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r},wo=yt?yt.prototype:void 0,Co=wo?wo.valueOf:void 0;var To=function(e,t,r,n,i,o,a){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||!o(new go(e),new go(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return vo(+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 s=bo;case"[object Set]":var l=1&n;if(s||(s=xo),e.size!=t.size&&!l)return!1;var c=a.get(e);if(c)return c==t;n|=2,a.set(e,t);var h=yo(s(e),s(t),n,i,o,a);return a.delete(e),h;case"[object Symbol]":if(Co)return Co.call(e)==Co.call(t)}return!1};var Mo=function(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e},_o=Mo,Do=ui;var Lo=function(e,t,r){var n=t(e);return Do(e)?n:_o(n,r(e))};var No=function(e,t){for(var r=-1,n=null==e?0:e.length,i=0,o=[];++r<n;){var a=e[r];t(a,r,e)&&(o[i++]=a)}return o},Io=function(){return[]},ko=Object.prototype.propertyIsEnumerable,zo=Object.getOwnPropertySymbols,jo=Lo,Fo=zo?function(e){return null==e?[]:(e=Object(e),No(zo(e),(function(t){return ko.call(e,t)})))}:Io,Oo=Zi;var So=function(e){return jo(e,Oo,Fo)},Bo=Object.prototype.hasOwnProperty;var Po=function(e,t,r,n,i,o){var a=1&r,s=So(e),l=s.length;if(l!=So(t).length&&!a)return!1;for(var c=l;c--;){var h=s[c];if(!(a?h in t:Bo.call(t,h)))return!1}var d=o.get(e),u=o.get(t);if(d&&u)return d==t&&u==e;var p=!0;o.set(e,t),o.set(t,e);for(var f=a;++c<l;){var m=e[h=s[c]],g=t[h];if(n)var v=a?n(g,m,h,t,e,o):n(m,g,h,e,t,o);if(!(void 0===v?m===g||i(m,g,r,n,o):v)){p=!1;break}f||(f="constructor"==h)}if(p&&!f){var y=e.constructor,b=t.constructor;y==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof y&&y instanceof y&&"function"==typeof b&&b instanceof b||(p=!1)}return o.delete(e),o.delete(t),p},Ro=qr(vt,"DataView"),Uo=Fn,Ao=qr(vt,"Promise"),Ho=qr(vt,"Set"),Eo=qr(vt,"WeakMap"),$o=It,Vo=Sr,Zo="[object Map]",Wo="[object Promise]",Yo="[object Set]",qo="[object WeakMap]",Go="[object DataView]",Qo=Vo(Ro),Jo=Vo(Uo),Xo=Vo(Ao),Ko=Vo(Ho),ea=Vo(Eo),ta=$o;(Ro&&ta(new Ro(new ArrayBuffer(1)))!=Go||Uo&&ta(new Uo)!=Zo||Ao&&ta(Ao.resolve())!=Wo||Ho&&ta(new Ho)!=Yo||Eo&&ta(new Eo)!=qo)&&(ta=function(e){var t=$o(e),r="[object Object]"==t?e.constructor:void 0,n=r?Vo(r):"";if(n)switch(n){case Qo:return Go;case Jo:return Zo;case Xo:return Wo;case Ko:return Yo;case ea:return qo}return t});var ra=oo,na=fo,ia=To,oa=Po,aa=ta,sa=ui,la=mi,ca=Li,ha="[object Arguments]",da="[object Array]",ua="[object Object]",pa=Object.prototype.hasOwnProperty;var fa=function(e,t,r,n,i,o){var a=sa(e),s=sa(t),l=a?da:aa(e),c=s?da:aa(t),h=(l=l==ha?ua:l)==ua,d=(c=c==ha?ua:c)==ua,u=l==c;if(u&&la(e)){if(!la(t))return!1;a=!0,h=!1}if(u&&!h)return o||(o=new ra),a||ca(e)?na(e,t,r,n,i,o):ia(e,t,l,r,n,i,o);if(!(1&r)){var p=h&&pa.call(e,"__wrapped__"),f=d&&pa.call(t,"__wrapped__");if(p||f){var m=p?e.value():e,g=f?t.value():t;return o||(o=new ra),i(m,g,r,n,o)}}return!!u&&(o||(o=new ra),oa(e,t,r,n,i,o))},ma=Yt;var ga=function e(t,r,n,i,o){return t===r||(null==t||null==r||!ma(t)&&!ma(r)?t!=t&&r!=r:fa(t,r,n,i,e,o))};class va extends ri{eventsStore;filters;fetcher;transformData;data=[];pendingData=[];liveUpdateMode="auto";disposables=[];pageInfo=null;loading=!1;loadMoreTrigger=0;retryTrigger=0;error=null;loadingInitiated=!1;get isLive(){return"DESC"===this.filters.sortDirection&&!this.filters.to}constructor(e,t,r,n=e=>[{data:e,objectIdx:-1}]){super(),this.eventsStore=e,this.filters=t,this.fetcher=r,this.transformData=n,xe(this,{data:we.ref,pendingData:we.ref,liveUpdateMode:we,setLiveUpdateMode:Ce,flushUpdates:Ce,pageInfo:we.ref,isLive:ye,loading:we,loadMoreTrigger:we,retryTrigger:we,error:we.ref,loadMore:Ce})}flushUpdates=()=>{this.data=[...this.pendingData,...this.data],this.pendingData=[]};setLiveUpdateMode=e=>{this.liveUpdateMode=e};load=()=>{this.loadingInitiated||(this.loadingInitiated=!0,this.initDataLoading(),this.initLiveUpdates())};reload=()=>{this.error&&(this.retryTrigger=+!this.retryTrigger)};loadMore=()=>{this.error=null,this.loadMoreTrigger=+!this.loadMoreTrigger};queryEvents=e=>this.fetcher(this.api,e).pipe(o((e=>e.success?t({events:e.resultItems,pageInfo:e.pageInfo}):a((()=>e.error)))),s((e=>(console.error(e),this.error=e,t({events:[],pageInfo:null})))));initDataLoading(){this.disposables.push(this.filters.updated$.pipe(l(null),c((e=>Tr((()=>this.retryTrigger),!0).pipe(h((()=>e))))),c((()=>(Te((()=>{this.loading=!0,this.pageInfo=null,this.error=null,this.data=[],this.pendingData=[]})),this.queryEvents())))).subscribe((({events:e,pageInfo:t})=>{Te((()=>{if(!t)return;const r=e.map(ya);this.isLive?this.data=this.uniquelyConcat(this.filters.apply(this.eventsStore.getEvents({cameraIds:this.filters.cameras,from:r[0]?.startTime??wr(new Date,1),to:null,probability:this.filters.probabilityThreshold??void 0})),r).flatMap(this.transformData):this.data=r.flatMap(this.transformData),this.eventsStore.add(r),this.pageInfo=t,this.loading=!1}))}))),this.disposables.push(this.filters.updated$.pipe(l(null),c((()=>Tr((()=>this.loadMoreTrigger)).pipe(d((()=>this.queryEvents(this.pageInfo?.nextPageToken))))))).subscribe((({events:e,pageInfo:t})=>{if(!t)return;const r=e.map(ya);this.eventsStore.add(r),Te((()=>{this.data=this.data.concat(r.flatMap(this.transformData)),this.pageInfo=t,this.loading=!1}))})))}initLiveUpdates(){this.disposables.push(Tr((()=>({liveUpdateMode:this.liveUpdateMode,isLive:this.isLive})),!0).pipe(c((({liveUpdateMode:e,isLive:t})=>t&&"auto"===e?Tr((()=>this.eventsStore.recentAdditions)):u))).subscribe((e=>{if(this.loading)return;if(!this.pageInfo&&this.error)return;const t=this.filters.apply(e.map((e=>this.eventsStore.eventsById.get(e))));t.length&&Te((()=>{this.data=[...t.flatMap(this.transformData),...this.data]}))}))),this.disposables.push(Tr((()=>({liveUpdateMode:this.liveUpdateMode,isLive:this.isLive})),!0).pipe(c((({liveUpdateMode:e,isLive:t})=>t&&"manual"===e?Tr((()=>this.eventsStore.recentAdditions)):(this.pendingData&&Te((()=>this.pendingData=[])),u)))).subscribe((e=>{if(!this.data.length)return;const t=this.filters.apply(e.map((e=>this.eventsStore.eventsById.get(e))));t.length&&Te((()=>{this.pendingData=[...t.flatMap(this.transformData),...this.pendingData]}))})))}uniquelyConcat(e,t){if(!e.length)return t.concat();if(!t.length)return e.concat();const r=e=>[e.id,e];return Array.from(new Map([...e.map(r),...t.map(r)]).values())}dispose(){for(const e of this.disposables)e instanceof i?e.closed||e.unsubscribe():e()}}function ya(e){return new Dr(e)}const ba=({forwardedRef:e,children:t,className:r,fullWidth:n,variant:i,type:o,title:a,placement:s,...l})=>{const c=O(r,"x-3deye-button",{"x-3deye-button--fullwidth":n},i?`x-3deye-button--${i}`:void 0),h=v("button",{ref:e,className:c,type:o||"button",...l,children:[t,l.disabled?null:g(S,{})]});return void 0===a?h:g(ks,{label:a,placement:s,disabled:!a,children:h})};var xa=x(((e,t)=>g(ba,{forwardedRef:t,...e})));var wa=e=>{const{className:t,children:r,...n}=e;return g("div",{className:O("x-3deye-button-group",t),...n,children:r})};function Ca(e){return x(((t,r)=>{const{size:n=24,color:i="currentColor",className:o,...a}=t,s=e.viewBox||"0 0 24 24",l=e.svg;return g("svg",{ref:r,preserveAspectRatio:"xMinYMin",className:O("icon",o),width:n,fill:i,viewBox:s,...a,children:l})}))}const Ta=Ca({viewBox:"0 0 24 24",svg:v(y,{children:[g("path",{d:"M5.88 4.12L13.76 12l-7.88 7.88L8 22l10-10L8 2z"}),g("path",{fill:"none",d:"M0 0h24v24H0z"})]})});Ta.displayName="ArrowForwardIcon";var Ma=Ta;const _a=Ca({viewBox:"0 0 24 24",svg:g(y,{children:g("path",{d:"M11.74 13.36L14.14 7.71L13.06 5.5H10.5V4H14L14.73 5.5H21.75L20.75 9H16.44L17.11 10.37C17.69 10.13 18.33 10 19 10C21.76 10 24 12.24 24 15C24 17.76 21.76 20 19 20C16.24 20 14 17.76 14 15C14 13.45 14.71 12.06 15.82 11.15L15 9.5L12.25 16H9.9C9.44 18.28 7.42 20 5 20C2.24 20 0 17.76 0 15C0 12.24 2.24 10 5 10C7.59 10 9.72 11.97 10 14.5H10.58L8.3 9H7.5C7.09 9 6.75 8.66 6.75 8.25C6.75 7.84 7.09 7.5 7.5 7.5H10.25C10.66 7.5 11 7.84 11 8.25C11 8.66 10.66 9 10.25 9H9.97L11.74 13.36M5 11.5C3.07 11.5 1.5 13.07 1.5 15C1.5 16.93 3.07 18.5 5 18.5C6.59 18.5 7.93 17.45 8.36 16H4V14.5H8.47C8.22 12.8 6.76 11.5 5 11.5M19 11.5C18.57 11.5 18.15 11.58 17.77 11.72L19.7 15.68L18.35 16.34L16.5 12.55C15.88 13.18 15.5 14.05 15.5 15C15.5 16.93 17.07 18.5 19 18.5C20.93 18.5 22.5 16.93 22.5 15C22.5 13.07 20.93 11.5 19 11.5Z"})})});_a.displayName="BicycleIcon";var Da=_a;const La=Ca({viewBox:"0 0 24 24",svg:v(y,{children:[g("path",{d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20 21c-1.39 0-2.78-.47-4-1.32-2.44 1.71-5.56 1.71-8 0C6.78 20.53 5.39 21 4 21H2v2h2c1.38 0 2.74-.35 4-.99 2.52 1.29 5.48 1.29 8 0 1.26.65 2.62.99 4 .99h2v-2h-2zM3.95 19H4c1.6 0 3.02-.88 4-2 .98 1.12 2.4 2 4 2s3.02-.88 4-2c.98 1.12 2.4 2 4 2h.05l1.89-6.68c.08-.26.06-.54-.06-.78s-.34-.42-.6-.5L20 10.62V6c0-1.1-.9-2-2-2h-3V1H9v3H6c-1.1 0-2 .9-2 2v4.62l-1.29.42c-.26.08-.48.26-.6.5s-.15.52-.06.78L3.95 19zM6 6h12v3.97L12 8 6 9.97V6z"})]})});La.displayName="BoatIcon";var Na=La;const Ia=Ca({viewBox:"0 0 24 24",svg:v("g",{children:[g("path",{d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M17 10.5V7c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-3.5l4 4v-11l-4 4z"})]})});Ia.displayName="CameraIcon";var ka=Ia;const za=Ca({viewBox:"0 0 24 24",svg:v(y,{children:[g("path",{d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M18.92 6.01C18.72 5.42 18.16 5 17.5 5h-11c-.66 0-1.21.42-1.42 1.01L3 12v8c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-1h12v1c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-8l-2.08-5.99zM6.5 16c-.83 0-1.5-.67-1.5-1.5S5.67 13 6.5 13s1.5.67 1.5 1.5S7.33 16 6.5 16zm11 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zM5 11l1.5-4.5h11L19 11H5z"})]})});za.displayName="CarIcon";var ja=za;const Fa=Ca({viewBox:"0 0 24 24",svg:v("g",{children:[g("path",{d:"M7.41 7.84L12 12.42l4.59-4.58L18 9.25l-6 6-6-6z"}),g("path",{d:"M0-.75h24v24H0z",fill:"none"})]})});Fa.displayName="ChevronDownIcon";var Oa=Fa;const Sa=Ca({viewBox:"0 0 24 24",svg:v("g",{children:[g("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}),g("path",{d:"M0 0h24v24H0z",fill:"none"})]})});Sa.displayName="ChevronRightIcon";var Ba=Sa;const Pa=Ca({viewBox:"0 0 24 24",svg:v("g",{children:[g("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),g("path",{d:"M0 0h24v24H0z",fill:"none"})]})});Pa.displayName="CloseIcon";var Ra=Pa;const Ua=Ca({viewBox:"0 0 24 24",svg:v("g",{children:[g("path",{d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M13.5 5.5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zM9.8 8.9L7 23h2.1l1.8-8 2.1 2v6h2v-7.5l-2.1-2 .6-3C14.8 12 16.8 13 19 13v-2c-1.9 0-3.5-1-4.3-2.4l-1-1.6c-.4-.6-1-1-1.7-1-.3 0-.5.1-.8.1L6 8.3V13h2V9.6l1.8-.7"})]})});Ua.displayName="DirectionsWalkIcon";var Aa=Ua;const Ha=Ca({viewBox:"0 0 24 24",svg:v(y,{children:[g("path",{fill:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"})]})});Ha.displayName="DoneIcon";var Ea=Ha;const $a=Ca({viewBox:"0 0 24 24",svg:v(y,{children:[g("path",{d:"M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"}),g("path",{d:"M0 0h24v24H0z",fill:"none"})]})});$a.displayName="FilterListIcon";var Va=$a;const Za=Ca({viewBox:"0 0 24 24",svg:g(y,{children:g("path",{d:"M19.48,12.35c-1.57-4.08-7.16-4.3-5.81-10.23c0.1-0.44-0.37-0.78-0.75-0.55C9.29,3.71,6.68,8,8.87,13.62 c0.18,0.46-0.36,0.89-0.75,0.59c-1.81-1.37-2-3.34-1.84-4.75c0.06-0.52-0.62-0.77-0.91-0.34C4.69,10.16,4,11.84,4,14.37 c0.38,5.6,5.11,7.32,6.81,7.54c2.43,0.31,5.06-0.14,6.95-1.87C19.84,18.11,20.6,15.03,19.48,12.35z M10.2,17.38 c1.44-0.35,2.18-1.39,2.38-2.31c0.33-1.43-0.96-2.83-0.09-5.09c0.33,1.87,3.27,3.04,3.27,5.08C15.84,17.59,13.1,19.76,10.2,17.38z"})})});Za.displayName="FireIcon";var Wa=Za;const Ya=Ca({viewBox:"0 0 24 24",svg:v("g",{children:[g("path",{d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.13 3.245a1.994 1.994 0 0 0-1.542.992l-5.491 9.53c-.55.954-.23 2.178.723 2.728l8.66 5c.953.55 2.174.216 2.724-.737l5.509-9.521c.335-.58.349-1.265.087-1.832L17.65 2.54z"})]})});Ya.displayName="LabelIcon";var qa=Ya;const Ga=Ca({viewBox:"0 0 24 24",svg:v(y,{children:[g("path",{d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H5Zm0 2h4v2h8V6h4v12H4Z"}),g("path",{d:"M9.923 10 8.43 12.433 10 15h-.8L8 13.036 6.8 15H6l1.602-2.616L6.136 10h.8l1.093 1.781L9.123 10Z"}),g("path",{d:"m13.709 10-1.492 2.433L13.787 15h-.8l-1.2-1.964L10.585 15h-.8l1.603-2.616L9.923 10h.799l1.094 1.781L12.91 10Z"}),g("path",{d:"m17.709 10-1.492 2.433L17.787 15h-.8l-1.2-1.964L14.585 15h-.8l1.603-2.616L13.923 10h.799l1.094 1.781L16.91 10Z"})]})});Ga.displayName="LicensePlateIcon";var Qa=Ga;const Ja=Ca({viewBox:"0 0 24 24",svg:g("path",{d:"M12.703 5.787a2.171 2.171 0 0 0-1.334.438c-.511.788-.8 1.614-1.217 3.267l-3.172.91a.499.499 0 0 0-.341.62l.13.455a.5.5 0 0 0 .62.343l2.328-.67-.377 1.31-3.96 3.827 1.53 6.693h3.78l2.67-10.14 1.29-4.51V7.01l-.32-.48a2.213 2.213 0 0 0-1.627-.743zM5.801 7.771c-.06.008-.12.05-.17.125l-.094.14c-.136.2-.16.57-.055.827l.631 1.535c.106.258.302.305.438.104l.094-.139c.135-.2.158-.57.052-.828l-.63-1.537C6 7.837 5.9 7.758 5.8 7.771zm4.648 7.338-1.5 6.022-.969-3.83 2.47-2.192zM10.756 5.6a2 2 0 0 0 2.33-1.6 2 2 0 0 0-1.6-2.33 2 2 0 0 0-2.33 1.6 2 2 0 0 0 1.6 2.33zM15.971 1.02h2.648v21.96h-2.648z"})});Ja.displayName="LoiteringIcon";var Xa=Ja;const Ka=Ca({viewBox:"0 0 24 24",svg:g("path",{d:"M17,6h-2V3c0-0.55-0.45-1-1-1h-4C9.45,2,9,2.45,9,3v3H7C5.9,6,5,6.9,5,8v11c0,1.1,0.9,2,2,2c0,0.55,0.45,1,1,1 c0.55,0,1-0.45,1-1h6c0,0.55,0.45,1,1,1c0.55,0,1-0.45,1-1c1.1,0,2-0.9,2-2V8C19,6.9,18.1,6,17,6z M9.5,18H8V9h1.5V18z M12.75,18 h-1.5V9h1.5V18z M13.5,6h-3V3.5h3V6z M16,18h-1.5V9H16V18z"})});Ka.displayName="LuggageIcon";var es=Ka;const ts=Ca({viewBox:"0 0 24 24",svg:v(y,{children:[g("path",{d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"4.5",cy:"9.5",r:"2.5"}),g("circle",{cx:"9",cy:"5.5",r:"2.5"}),g("circle",{cx:"15",cy:"5.5",r:"2.5"}),g("circle",{cx:"19.5",cy:"9.5",r:"2.5"}),g("path",{d:"M17.34 14.86c-.87-1.02-1.6-1.89-2.48-2.91-.46-.54-1.05-1.08-1.75-1.32-.11-.04-.22-.07-.33-.09-.25-.04-.52-.04-.78-.04s-.53 0-.79.05c-.11.02-.22.05-.33.09-.7.24-1.28.78-1.75 1.32-.87 1.02-1.6 1.89-2.48 2.91-1.31 1.31-2.92 2.76-2.62 4.79.29 1.02 1.02 2.03 2.33 2.32.73.15 3.06-.44 5.54-.44h.18c2.48 0 4.81.58 5.54.44 1.31-.29 2.04-1.31 2.33-2.32.31-2.04-1.3-3.49-2.61-4.8z"})]})});ts.displayName="PetsIcon";var rs=ts;const ns=Ca({viewBox:"0 0 24 24",svg:v(y,{children:[g("path",{d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 13V5c0-1.66-1.34-3-3-3S9 3.34 9 5v8c-1.21.91-2 2.37-2 4 0 2.76 2.24 5 5 5s5-2.24 5-5c0-1.63-.79-3.09-2-4zm-4-8c0-.55.45-1 1-1s1 .45 1 1h-1v1h1v2h-1v1h1v2h-2V5z"})]})});ns.displayName="ThermostatIcon";var is=ns;const os=[{color:"#f44336",name:"red",highlightColor:"#ffcdd2"},{color:"#4caf50",name:"green",highlightColor:"#c8e6c9"},{color:"#2196f3",name:"blue",highlightColor:"#bbdefb"},{color:"#ffeb3b",name:"yellow",highlightColor:"#f57f17"},{color:"#000",name:"black",highlightColor:"#fff"},{color:"#fff",name:"white",highlightColor:"#000"},{color:"#9e9e9e",name:"dimgrey",highlightColor:"#f5f5f5"}];new Map(os.map((({color:e,name:t})=>[t,e])));const as=F((({value:e,clear:t,toggle:r})=>v("div",{className:"color-selector",children:[g("div",{style:{textTransform:"uppercase"},children:Fe.t("color")}),v("div",{className:"color-selector__items",children:[os.map((({color:t,highlightColor:n,name:i})=>g("button",{type:"button",className:O("color-selector__item",{selected:e.has(i)}),style:{backgroundColor:t},onClick:r.bind(null,i),children:g(Ea,{color:n,size:20})},i))),g(xa,{className:"color-selector__clear",disabled:!e.size,onClick:t,children:g(Ra,{size:20})})]})]})));function ss(e,t,r){return t||r?r?ne(t?[re([e,t]),r]:[r,e]):re([t,e]):new Date(e)}as.displayName="ColorSelector";const ls=ie((e=>new Intl.DateTimeFormat(e,{month:"long",year:"numeric"}))),cs=ie((e=>new Intl.DateTimeFormat(e,{weekday:"short"}))),hs=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),ds=e=>new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())),us=w((function({onChange:e,date:t,minDate:r,maxDate:n,utc:i,startOfWeek:o="sunday"}){const[a]=C((()=>({current:i?ds(new Date):hs(new Date)}))),s=t??a.current,l=T(+s),c=C(0),[,h]=c;M((()=>{l.current=+s,h(0)}),[s?.getTime()]);const d=l.current!==+s?0:c[0],u=i?s.getUTCFullYear():s.getFullYear(),p=(i?s.getUTCMonth():s.getMonth())+d,f=i?new Date(Date.UTC(u,p)):new Date(u,p),m=i?(e=>new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+1,0)).getUTCDate())(f):(e=>new Date(e.getFullYear(),e.getMonth()+1,0).getDate())(f),y=(i?f.getUTCDay():f.getDay())||("monday"===o?7:0),b=y-("monday"===o?1:0),x=i?new Date(Date.UTC(u,p,1-b)):new Date(u,p,1-b),w=t?te(i?new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())):new Date(s.getFullYear(),s.getMonth(),s.getDate()),x):-1,_=r?te(r,x):Number.NEGATIVE_INFINITY,D=n?te(n,x):Number.POSITIVE_INFINITY,L=te(a.current,x);return g("div",{children:v("div",{style:{display:"flex",flexDirection:"column",fontSize:"0.875rem"},children:[v("div",{style:{fontWeight:500,height:"3rem",fontSize:"1.125rem",display:"flex",alignItems:"center"},children:[ls(Fe.language).format(f),g(xa,{style:{marginLeft:"auto"},className:"x-3deye-button--icon x-3deye-datepicker__button--previous-month",disabled:_>=b,onClick:()=>h(d-1),children:g(Ma,{size:16,style:{scale:"-1 1"}})}),g(xa,{className:"x-3deye-button--icon x-3deye-datepicker__button--next-month",disabled:D<b+m,onClick:()=>h(d+1),children:g(Ma,{size:16})})]}),v("div",{style:{flex:1,display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:"0.25rem",placeItems:"center"},children:[Array.from({length:7}).map(((e,t)=>g("div",{style:{color:"oklch(0.7 0 0)"},children:cs(Fe.language).format(new Date(u,p,("monday"===o?2:1)-y+t)).substring(0,2)},t))),Array.from({length:42}).map(((t,o)=>{const a=i?new Date(Date.UTC(u,p,o-b+1)):new Date(u,p,o-b+1),l=o<_||o>D;return g("div",{className:O("x-3deye-datepicker__day",{"x-3deye-datepicker__day--today":o===L,"x-3deye-datepicker__day--disabled":l,"x-3deye-datepicker__day--previous-month":o<b,"x-3deye-datepicker__day--next-month":o>=b+m,"x-3deye-datepicker__day--selected":o===w}),onClick:l?void 0:()=>{if(i){const t=new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds(),s.getUTCMilliseconds()));return e(ss(t,r,n))}const t=new Date(a.getFullYear(),a.getMonth(),a.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds());return e(ss(t,r,n))},children:i?a.getUTCDate():a.getDate()},o)}))]})]})})})),ps=Array.from({length:3}),fs=e=>g("svg",{viewBox:"0 0 100 100",...e,children:ps.map(((e,t)=>g("circle",{fill:"currentColor",stroke:"none",cx:20*t+6,cy:"50",r:"6",children:g("animate",{attributeName:"opacity",dur:"1s",values:"0;1;0",repeatCount:"indefinite",begin:.1*(t+1)})},t)))}),ms=_({reportError:(e,t)=>{}});class gs extends D{static contextType=ms;state={hasError:!1};componentDidCatch(e,t){this.setState({hasError:!0}),this.context?.reportError(e,t),console.error(e),console.log(t)}render(){if(!this.state.hasError)return this.props.children;const{style:e,children:t,...r}=this.props;return v("div",{style:{flex:1,padding:10,display:"grid",placeItems:"center",alignContent:"center",textAlign:"center",...this.props.style},...r,children:[g("h1",{children:"Oops. Something went wrong"}),g("div",{children:"We've been notified about this problem"}),g(xa,{onClick:()=>this.setState({hasError:!1}),children:"retry"})]})}}const vs=b.createContext(null),ys=b.forwardRef((({className:e,children:t,title:r,...n},i)=>{const o=b.useContext(vs);if(!o)return;const{refs:a,isNested:s,isOpen:l,hasFocusInside:c,item:h,parent:d,setHasFocusInside:u,getReferenceProps:p}=o;return v(xa,{ref:B([a.setReference,h.ref,i]),tabIndex:s?d?.activeIndex===h.index?0:-1:void 0,role:s?"menuitem":void 0,"data-open":l?"":void 0,"data-nested":s?"":void 0,"data-focus-inside":c?"":void 0,className:O(e,{"menu-item":s,"menu-button":!s}),title:l?null:r,...p(d?.getItemProps({...n,onFocus(e){n.onFocus?.(e),u(!1),d.setHasFocusInside(!0)}})),children:[t,s&&g(Ba,{style:{marginLeft:"auto"},"aria-hidden":!0,size:20})]})}));ys.displayName="MenuButton";const bs=b.forwardRef((({label:e,disabled:t,className:r,children:n,...i},o)=>{const a=b.useContext(vs),s=P({label:t?null:e}),l=R();if(!a)return null;const c=s.index===a.activeIndex;return g(xa,{...i,ref:B([s.ref,o]),type:"button",role:"menuitem",className:O(r,"menu-item"),tabIndex:c?0:-1,disabled:t,...a.getItemProps({onClick(e){i.onClick?.(e),l?.events.emit("click")},onFocus(e){i.onFocus?.(e),a.setHasFocusInside(!0)}}),children:e||n})}));bs.displayName="MenuItem";const xs=({opened:e,onOpenChange:t,children:r,target:n,placement:i,className:o,style:a,autoDismiss:s=!0,initialFocus:l,withArrow:c=!1})=>{const h=T(null),{x:d,y:u,refs:p,strategy:f,context:m,middlewareData:b,placement:x,update:w}=U({open:e,onOpenChange:t,middleware:[A(5),H(),E(),$({element:h})],placement:i,whileElementsMounted:(e,t,r)=>V(e,t,(()=>{0!==m.elements.domReference?.getBoundingClientRect().width?r():m.onOpenChange(!1)}),{animationFrame:!0})}),{getReferenceProps:C,getFloatingProps:M}=Z([W(m),Y(m,{ancestorScroll:!0,enabled:s})]),_=L((e=>{h.current=e,w()}),[w]),D={top:"bottom",right:"left",bottom:"top",left:"right"}[x?.split("-")[0]??"top"]||"top",N=v("div",{...M({className:O("x-3deye-popover-container",o),ref:p.setFloating,style:{...a,position:f,top:u??0,left:d??0}}),children:[c&&g(Is,{ref:_,width:24,height:8,placement:D,style:{position:"absolute",left:b.arrow?.x,top:b.arrow?.y,[D]:-7}}),r]});return v(y,{children:[I(n,C({ref:p.setReference,...n.props})),v(q,{id:"x-3deye-floating-ui-root",children:[s&&e&&g(G,{context:m,modal:!1,order:["reference","content"],returnFocus:!1,initialFocus:l,children:N}),!s&&e&&N]})]})},ws=({size:e=48})=>v("svg",{role:"graphics-symbol",width:e,height:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100",preserveAspectRatio:"xMidYMid",children:[g("rect",{x:"0",y:"0",width:"100",height:"100",fill:"none",className:"bk"}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(0 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(30 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.08333333333333333s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(60 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.16666666666666666s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(90 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.25s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(120 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.3333333333333333s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(150 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.4166666666666667s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(180 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.5s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(210 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.5833333333333334s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(240 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.6666666666666666s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(270 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.75s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(300 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.8333333333333334s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(330 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.9166666666666666s",repeatCount:"indefinite"})})]});ws.displayName="Preloader";const Cs=x((({active:e,children:t,className:r,style:n,...i},o)=>{const a=Q();return g("div",{ref:o,id:a,className:O("x-3deye-select-option",r),role:"option","aria-selected":e,style:{background:e?"rgb(213, 237, 255)":"none",...n},...i,children:t})})),Ts=({className:e,style:t,children:r,onCloseClick:n,...i})=>v("div",{className:O("x-3deye-select-value",e),style:t,...i,children:[r,g("button",{className:"close-button",type:"button",onClick:n,children:g(Ra,{size:12})})]}),Ms=(e,t,r)=>g(Ts,{...r,children:t.label},e),_s=(e,t,r,n)=>g(Cs,{active:r,...n,children:t.label},e),Ds=({options:e,values:t,inputId:r,inputValue:n,onMenuClose:i,onChange:o,onInputChange:a,onKeyDown:s,isLoading:l,placeholder:c,hideDropdownIcon:h,renderOption:d=_s,renderValue:u=Ms,keyExtractor:p=e=>e.value})=>{const[f,m]=C(!1),[b,x]=C(""),w=n??b,[_,D]=C(null),L=T([]),N=T(null),{refs:I,floatingStyles:k,context:z}=U({whileElementsMounted:V,open:f,onOpenChange:m,middleware:[H({padding:10}),A({mainAxis:5}),J({apply({rects:e,availableHeight:t,elements:r}){Object.assign(r.floating.style,{width:`${e.reference.width}px`,maxHeight:`${Math.min(300,t)}px`})},padding:10})]}),j=W(z,{role:"listbox"}),F=Y(z),S=X(z,{listRef:L,activeIndex:_,onNavigate:D,virtual:!0,loop:!0}),{getReferenceProps:B,getFloatingProps:P,getItemProps:R}=Z([j,F,S]);const E=e?.filter((e=>{const r=p(e);return!t.some((e=>p(e)===r))&&e.label.toLowerCase().includes(w.toLowerCase().trim())}));return M((()=>{f||(x(""),i?.())}),[f,i]),v(y,{children:[v("div",{className:O("x-3deye-select-container",{"x-3deye-select-container--open":f}),ref:I.setReference,onPointerDownCapture:e=>{const t=e.target;"BUTTON"!==t.tagName&&null===t.closest("button")&&(e.preventDefault(),e.stopPropagation(),m((e=>!e)),N.current?.focus())},children:[v("div",{className:"x-3deye-multi-select-body",children:[t.map((e=>u(p(e),e,{onCloseClick:r=>{r.stopPropagation(),o(t.filter((t=>t!==e)),{action:"remove",open:f,option:e}),N.current?.focus()}}))),v("div",{className:"x-3deye-select","data-value":w,children:[t.length||w?null:g("div",{className:"x-3deye-select-placeholder",children:c}),g("input",{ref:N,size:3,id:r||void 0,...B({onChange:function(e){const t=e.target.value;x(t),a?.(t),t?(m(!0),D(0)):m(!1)},value:w,placeholder:"","aria-autocomplete":"list",onKeyDown(e){if(s?.(e),"Enter"===e.key&&null!=_&&E?.[_])return x(""),o(t.concat(E[_]),{open:f,action:"add",option:E[_]}),void D(Math.max(_-1,0));if("Backspace"!==e.key);else if(""===w&&t.length){const e=t.at(-1);if(!e)return;o(t.slice(0,t.length-1),{open:f,action:"remove",option:e})}}})})]})]}),v("div",{className:"x-3deye-select-indicators",style:{marginLeft:"auto",display:"flex",paddingRight:8,alignItems:"center"},children:[l?g(fs,{style:{width:24}}):t.length?g(xa,{className:"x-3deye-button--icon",onClick:()=>{o([],{open:f,action:"clear"})},children:g(Ra,{size:16})}):null,h?null:g(Oa,{size:24})]})]}),g(q,{id:"x-3deye-floating-ui-root",children:f&&E?g(G,{context:z,initialFocus:-1,visuallyHiddenDismiss:!0,children:g("div",{className:"x-3deye-select-menu",...P({ref:I.setFloating,style:{...k,color:"black",overflowY:"auto"}}),children:E.length?E.map(((e,r)=>d(p(e),e,_===r,{...R({ref(e){L.current[r]=e},onClick(r){r.stopPropagation(),x(""),o([...t,e],{open:f,action:"add",option:e}),N.current?.focus()}})}))):g("div",{style:{padding:10,textAlign:"center",fontSize:"0.875rem",color:"#666"},children:l?Fe.t("select.loading"):Fe.t("select.noOptions")})})}):null})]})},Ls=e=>Math.round(e),Ns=x((({value:e,onChange:t,onChangeComplete:r,orientation:n="horizontal",disabled:i=!1,labelFormat:o=e=>`${e}`,style:a},s)=>{const l=T(null),c=T(null),[h,d]=C(!1),[u,p]=C(e);M((()=>{if(!h)return;const e=l.current;if(!e)return;let i=0,o=0;const a=e.getBoundingClientRect();if(!a||!a.width||!a.height)return void d(!1);const s=({clientX:e,clientY:r})=>{if(!c.current)return;let s=0;"horizontal"===n?(i=ti(e-a.x,0,a.width),s=i/a.width*100,c.current.style.transform=`translateX(${i}px)`):(o=a.height-ti(r-a.y,0,a.height),s=o/a.height*100,c.current.style.transform=`translateY(${-o}px)`),p(s),t?.(Ls(s))},u=({clientX:e,clientY:i})=>{if(d(!1),!c.current)return;const o="horizontal"===n?ti(e-a.x,0,a.width)/a.width*100:100*(1-ti(i-a.y,0,a.height)/a.height);c.current.style.transform="",p(o),t?.(Ls(o)),r?.(Ls(o))},f=()=>{if(d(!1),!c.current)return;const e="horizontal"===n?i/a.width*100:o/a.height*100;c.current.style.transform="",t?.(Ls(e)),r?.(Ls(e))};return document.addEventListener("pointercancel",f),document.addEventListener("pointermove",s),document.addEventListener("pointerup",u),()=>{document.removeEventListener("pointercancel",f),document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",u)}}),[h,n,t,r]);const f=L((e=>{if(!l.current||i)return;const{clientX:r,clientY:o}=e;e.preventDefault(),d(!0);const a=l.current.getBoundingClientRect();if(!a)return;if(!c.current)return;let s=0;if("horizontal"===n){const e=ti(r-a.x,0,a.width);s=e/a.width*100,c.current.style.transform=`translateX(${e}px)`}else{const e=a.height-ti(o-a.y,0,a.height);s=e/a.height*100,c.current.style.transform=`translateY(${-e}px)`}p(s),t?.(Ls(s))}),[i]),m=L((n=>{if(i)return;let o=null;"ArrowLeft"===n.code?o=Math.max(e-1,0):"ArrowRight"===n.code?o=Math.min(e+1,100):"ArrowDown"===n.code?o=Math.max(e-1,0):"ArrowUp"===n.code&&(o=Math.min(e+1,100)),null!==o&&(n.stopPropagation(),n.preventDefault(),t?.(o),r?.(o))}),[e,t,r,i]);return v("div",{ref:ee(s,l),tabIndex:0,onKeyDown:m,className:O("x-3deye-slider",n,{disabled:i}),onPointerDown:f,style:a,children:[g("div",{className:"x-3deye-slider__track",children:g("div",{className:"x-3deye-slider__bar",style:{width:"horizontal"===n?`${h?u:e}%`:void 0,height:"vertical"===n?`${h?u:e}%`:void 0}})}),g("div",{ref:c,className:O("x-3deye-slider__thumb",{active:h}),style:{touchAction:"none",userSelect:"none",position:"absolute",left:"horizontal"===n?h?0:`${e}%`:"auto",bottom:"vertical"===n?h?0:`${e}%`:"auto"},children:null!==o&&g("div",{className:"x-3deye-slider__label "+(h?"open":""),children:o(h?Ls(u):e)})})]})}));Ns.displayName="Slider";const Is=b.forwardRef((function({width:e,height:t,placement:r="top",style:n},i){const o=[0,"top"===r?t:0],a=[e,o[1]],s=[e/2,t-o[1]],l=[e/4,t*("top"===r?3:1)/4],c=[.325*e,t-o[1]],h=[e-c[0],c[1]],d=[e-l[0],l[1]],u=e=>e.join(","),p=`M ${u(o)} C ${u(l)} ${u(c)} ${u(s)} ${u(h)} ${u(d)} ${u(a)}`;return v("svg",{ref:i,role:"graphics-symbol",className:"tip",style:n,width:e,height:t,fill:"var(--tip-background, #fff)",children:[g("path",{className:"tip-body",d:`${p} Z`}),g("path",{className:"tip-border",d:p,stroke:"var(--tip-border, transparent)",strokeWidth:1})]})}));var ks=({children:e,label:t,placement:r="bottom",disabled:n})=>{const[i,o]=C(!1),{x:a,y:s,refs:l,strategy:c,context:h}=U({placement:r,open:i,onOpenChange:o,middleware:[A(5),H(),E({padding:8})],whileElementsMounted:(e,t,r)=>V(e,t,r,{animationFrame:!0})}),{getReferenceProps:d,getFloatingProps:u}=Z([K(h,{enabled:!n}),W(h,{role:"tooltip"}),Y(h,{referencePress:!0})]);return v(y,{children:[I(e,d({ref:ee(l.setReference,e.ref),...e.props})),g(q,{id:"x-3deye-floating-ui-root",children:i&&g("div",{...u({ref:l.setFloating,className:"x-3deye-tooltip",style:{position:c,top:s??0,left:a??0}}),children:t})})]})};function zs({count:e,overscan:t=1,itemSize:r,horizontal:n=!1,spacing:i=0}){const[o,a]=C(),[s,l]=C(0),[c,h]=C({width:0,height:0}),d=L((e=>{a(e||void 0)}),[]);M((()=>{if(!o)return;const e=()=>{l(n?o.scrollLeft:o.scrollTop)};return o.addEventListener("scroll",e,{passive:!0,capture:!0}),()=>{o.removeEventListener("scroll",e)}}),[o,n]),M((()=>{if(!o)return;const e=new ResizeObserver((e=>{for(const t of e)t.contentBoxSize?h({width:t.contentBoxSize[0].inlineSize,height:t.contentBoxSize[0].blockSize}):h({width:t.contentRect.width,height:t.contentRect.height})}));return e.observe(o),()=>{e.disconnect()}}),[o]),M((()=>{if(!o)return;const e=o[n?"scrollLeft":"scrollTop"];e!==s&&l(e)}));return{parentRef:d,getItems:()=>{const a=[];if(!o)return a;const{height:l,width:c}=o.getBoundingClientRect(),h=Math.max(0,Math.floor(s/(r+i))-t),d=Math.ceil((n?c:l)/(r+i))+2*t;for(let t=h;t<Math.min(e,h+d);t++)a.push({idx:t,start:t*(r+i),size:r});return a},getTotalSize:()=>r*e+Math.max(e-1,0)*i}}const js=F((({getter:e,setter:t})=>{const[r,n]=C(0),i=T(null),o=Math.floor(100*e());return M((()=>Me(e,(e=>{n(Math.floor(100*e))}),{fireImmediately:!0})),[e]),v("div",{ref:i,style:{paddingLeft:8,paddingRight:8,marginTop:5,marginBottom:10},children:[v("div",{style:{display:"flex",justifyContent:"space-between"},children:[g("div",{style:{textTransform:"uppercase"},children:Fe.t("confidence")}),v("div",{style:{fontSize:"1.1em"},children:[o,"%"]})]}),g("div",{style:{padding:"0 10px"},children:g(Ns,{value:r,labelFormat:e=>`${e}%`,onChangeComplete:e=>{t(e/100)}})})]})}));js.displayName="ProbabilitySlider";const Fs=F((({from:e,to:t})=>{const{account:{preferences:{utc:r,hour12:n}}}=k(Cr);return g(y,{children:Ir(e,t,{locale:Fe.language,utc:r,hour12:n})})}));Fs.displayName="DisplayPeriod";class Os{from=null;to=null;probabilityThreshold=.5;cameras=[];detectedObjects=[];colors=new Set;regions=null;eventTypes=[];sortDirection="DESC";updated$=new p;get regionsWkt(){return this.regions?this.regions.map((e=>this.regionToWktPolygon(e))):[]}constructor(){xe(this,{from:we,to:we,probabilityThreshold:we,cameras:we.struct,detectedObjects:we.struct,regions:we.ref,eventTypes:we.struct,sortDirection:we,colors:we.ref,filterJson:ye}),Me((()=>({from:this.from?+this.from:void 0,to:this.to?+this.to:void 0,sortDirection:this.sortDirection,filter:this.filterJson,cameraFilters:this.cameras,eventTypes:this.eventTypes,regions:this.regions})),(()=>this.updated$.next(null)))}apply(e){let t=e;const{from:r,to:n}=this;if(r&&(t=t.filter((e=>e.startTime>=r))),n&&(t=t.filter((e=>e.startTime<=n))),this.cameras.length&&(t=t.filter((e=>this.cameras.includes(e.cameraId)))),this.eventTypes.length){const e=this.eventTypes.map((e=>Mr[e]));t=t.filter((t=>e.includes(t.type)))}return this.detectedObjects.length&&(t=t.filter((e=>e.detectedObjects.some((e=>{const{probabilityThreshold:t}=this;return!(null!==t&&e.Probability<t)&&(this.colors.size?this.detectedObjects.includes(e.Type)&&"Colors"in e&&e.Colors?.some((e=>this.colors.has(e.Color))):this.detectedObjects.includes(e.Type))}))))),!this.detectedObjects.length&&this.colors.size&&(t=t.filter((e=>e.detectedObjects.some((e=>{const{probabilityThreshold:t}=this;return!(null!==t&&e.Probability<t)&&("Colors"in e&&e.Colors?.some((e=>this.colors.has(e.Color))))}))))),t}get filterJson(){const{probabilityThreshold:e}=this;if(null===e)return null;const t={And:[]};return this.detectedObjects.length&&t.And.push({Or:this.detectedObjects.map((e=>({Type:e})))}),this.colors.size&&t.And.push({Or:[...this.colors].map((e=>({ObjectColors:[e]})))}),t.And.push({Or:[{Probability:e}]}),JSON.stringify(t)}regionToWktPolygon(e){return e.length?"POLYGON (("+e.concat(e[0]).map((({x:e,y:t})=>`${e} ${t}`)).join(", ")+"))":"POLYGON (())"}}const Ss=Ca({viewBox:"0 96 960 960",svg:g(y,{children:g("path",{d:"m513 988-57-18 14-42q3-9 4-17.6 1-8.6 1-17.2 0-17.2-3.912-32.473Q467.176 845.455 456 828q-15.938-26.26-22.969-48.63Q426 757 425 727.844q0-11.844 2.5-27.344Q430 685 434 672l13-42 57 18-14 42q-3 9-4 19t-1 19q0 19 4 32t15 30q15.97 25.948 23.485 49.974Q535 864 535 892.933q0 13.067-2.5 26.567T526 946l-13 42Zm-176 0-57-18 14-42q3-9 4-17.049t1-17.707q0-18.244-4-34.744T280 827q-15.03-21.658-23.015-46.612Q249 755.433 249 728.125 249 714 251 700t7-28l13-42 57 18-14 42q-3 9.771-4 20.086-1 10.314-1 17.914 0 21.065 5.5 36.033Q320 779 328 791q15 22 23 48.5t8 52.802Q359 905 356.5 919t-6.5 27l-13 42Zm348 0-57-18 14-42q3-9 4-17.6 1-8.6 1-17.2 0-17.2-4.5-34.7Q638 841 628 827q-15-21-23-47t-8-52.047q0-13.953 2-27.794 2-13.841 7-28.159l13-42 57 18-14 42q-4 11-4.5 19.438-.5 8.437-.5 18.562 0 18.491 4.471 32.632Q665.941 774.772 676 790q16 23 23.5 48.887 7.5 25.886 7.5 53.69 0 13.423-2.5 26.923Q702 933 698 946l-13 42ZM180 336h600v-60H180v60Zm139 120h322l18-60H301l18 60Zm0 60q-19.5 0-35.25-11.625T262 474l-25-78h-57q-24.75 0-42.375-17.625T120 336V216h720v120q0 25-17.625 42.5T780 396h-57l-30 81q-6.932 17.25-22.338 28.125Q655.257 516 636 516H319ZM180 336v-60 60Z"})})});Ss.displayName="DetectorSmokeIcon";var Bs=Ss;const Ps=({data:e})=>{const t=16;return"eventType"===e.type&&e.value===Mr.Loitering?g(Xa,{size:16}):"camera"===e.type?g(ka,{size:t}):"Luggage"===e.value?g(es,{size:t}):"Car"===e.value?g(ja,{size:t}):"Person"===e.value?g(Aa,{size:t}):"Bicycle"===e.value?g(Da,{size:t}):"Boat"===e.value?g(Na,{size:t}):"Animal"===e.value?g(rs,{size:t}):"LicensePlate"===e.value?g(Qa,{size:t}):"Smoke"===e.value?g(Bs,{size:t}):"Fire"===e.value?g(Wa,{size:t}):g(qa,{size:t})},Rs=(e,t,r,n)=>v(Cs,{style:{color:"detectedObject"===t.type?t.color:"black",display:"camera"===t.type?"flex":"inline-flex",gap:4},...n,active:r,children:["camera"!==t.type?g(Ps,{data:t}):null,t.label]},e),Us=(e,t,r)=>v(Ts,{style:{"--color":"color"in t&&t.color?t.color:void 0,color:"color"in t&&t.color?"white":void 0,"--background-color":"color"in t&&t.color?"rgba(255, 255, 255, 0.7)":void 0},...r,children:[g(Ps,{data:t}),t.label]},e),As=F((({camerasOnly:e,store:t})=>{const{cameras:r,eventSchema:n}=k(Cr),i=(()=>{if(!n)return[];if(e)return r.data.map((e=>({type:"camera",value:e.id,label:e.name})));const t=[{value:Mr.Loitering,label:Fe.t("eventTypes.Loitering").toLowerCase(),type:"eventType"}];return[].concat(n.foundObjectTypesForSelect.map((e=>({...e,label:Fe.t(`analytics.${e.label}`)}))),t,r.data.map((e=>({type:"camera",value:e.id,label:e.name}))))})();return g(Ds,{onChange:(e,r)=>{t.setFilters(e),r.open||"remove"!==r.action&&"clear"!==r.action||t.applyFilters()},onMenuClose:()=>{t.applyFilters()},options:i,renderOption:Rs,values:t.filters,renderValue:Us,keyExtractor:e=>`${e.type}:${e.value}`,placeholder:v(y,{children:[g(Va,{size:16})," ",Fe.t("filter")]})})}));As.displayName="EventGridSelect";const Hs=F((({data:e,children:t,onClick:r,onAuxClick:n,menuComponent:i})=>{const o=T(null),{ref:a,menuContext:s}=function(){const[e,t]=C(!1),[r,n]=C(),i=L((e=>{n(e||void 0)}),[]),[o]=C((()=>new Set)),[a]=C((()=>new Set)),s=N((()=>({subscribe:e=>(o.add(e),()=>o.delete(e)),onOpenChange:e=>(a.add(e),()=>a.delete(e)),setOpened:e=>{t(e);for(const t of a)t(e)}})),[]);return M((()=>{if(r)return r.addEventListener("contextmenu",e),()=>{r.removeEventListener("contextmenu",e)};function e(e){e.preventDefault();for(const t of o)t(e)}}),[r]),{ref:i,menuContext:s,opened:e}}();return v("div",{ref:ee(o,a),onDragStart:t=>{if(!t.dataTransfer)return;t.dataTransfer.setData("x-3deye/event",`${e.id}`),t.dataTransfer.setData("x-3deye/camera",`${e.cameraId}`),t.dataTransfer.setData("x-3deye/starttime",e.startTime.toISOString()),t.dataTransfer.dropEffect="move";const r=o.current?.querySelector("img");if(r){const{x:e,y:n}=r.getBoundingClientRect();t.dataTransfer.setDragImage(r,t.clientX-e,t.clientY-n)}},className:"event-list-item",onClick:()=>r?.(e),onAuxClick:t=>n?.(t,e),draggable:!0,children:[t,i&&g(i,{ctx:s,data:e})]})}));Hs.displayName="EventListItem";const Es=F((({data:e})=>{if("Temperature"!==e.type)return null;const t=Number(e.raw.data);return v("div",{className:"event-list-item__temperature",children:[g(is,{}),v("span",{children:[(t-273.15).toFixed(1),"°C"]})," / ",v("span",{children:[(9*t/5-459.67).toFixed(1)," °F"]})]})}));Es.displayName="Temperature";var $s=Es;const Vs=F((({data:e,cameraNameHidden:t})=>{const r=k(Cr),{cameras:n}=r,i=n.loaded&&n.camerasById.get(e.cameraId)?.name||"...";return v("div",{className:"event-list-item-caption",children:[g("div",{className:"event-list-item__time",children:g(Fs,{from:e.startTime,to:e.endTime})}),t?null:v(y,{children:[g("div",{children:e.type}),g("div",{className:"event-list-item__camera-name",title:i,children:i})]}),+e.endTime-+e.startTime>0&&g("div",{className:"event-list-item__duration",children:ei(+e.endTime-+e.startTime,Fe.t)}),g($s,{data:e})]})}));Vs.displayName="EventListItemCaption";var Zs=F((({url:e,noPreview:t,width:r})=>v(y,{children:[e?g("img",{style:{position:"absolute",width:"100%",height:"100%",top:0,left:0},src:e},e):null,g(S,{radius:r}),t?g("div",{className:"no-preview-overlay"}):null]})));const Ws=({className:e,style:t,box:{Top:r,Left:n,Right:i,Bottom:o}})=>g(y,{children:g("div",{className:e,style:{position:"absolute",top:100*r+"%",left:100*n+"%",bottom:100*(1-o)+"%",right:100*(1-i)+"%",...t}})});function Ys({style:e}){return v("div",{className:"frame",style:e,children:[g("div",{className:"corner-highlight-tl"}),g("div",{className:"corner-highlight-tr"}),g("div",{className:"corner-highlight-br"}),g("div",{className:"corner-highlight-bl"})]})}Ws.displayName="LicensePlateLpr";const qs=w((({value:e})=>e?g(y,{children:e.split("").map(((e,t)=>(e=>{const t=e.charCodeAt(0);return t>=48&&t<=57})(e)?g("span",{className:"digit",children:e},`d${t}${e}`):g("span",{className:"char",children:e},`${t}${e}`)))}):null));qs.displayName="LicensePlateNumber";const Gs=({detectedObject:e,height:t,width:r,url:n,thumbWidth:i,thumbHeight:o})=>{const{Type:a,Box:{Top:s,Left:l,Right:c,Bottom:h},Probability:d,Value:u}=e,p=T(null);z((()=>{if(!p.current)return;const e=p.current.getBoundingClientRect();let n=(l+c)/2*r-e.width/2,i=s*t-e.height-4;i<0&&(i=h*t+4),n<0&&(n=0),n>r-e.width&&(n=r-e.width),p.current.style.top=`${i}px`,p.current.style.left=`${n}px`}));const f={top:2};l>=1-c?f.left=2:f.right=2;const m=100/i/(c-l);return v(y,{children:[v("div",{ref:p,className:"event-list-item__license-plate-label trigger",title:`${a.toLowerCase()} ${Math.floor(100*d)}%`,children:[g("div",{style:{padding:4},children:g(qs,{value:u})}),g("div",{className:"event-list-item__license-plate-label__caption",children:`${Math.floor(100*d)}%`})]}),g(Ws,{className:"event-list-item__license-plate-trigger trigger",box:e.Box}),v("div",{className:"event-list-item__license-plate preview",style:{overflow:"hidden",width:i*(c-l)*m,height:o*(h-s)*m+16,position:"absolute",...f},children:[g("img",{style:{width:i*m,height:o*m,transform:`translate(-${100*l}%, -${100*s}%)`},src:n}),g("div",{className:"plate-number",children:g(qs,{value:u})}),g(Ys,{style:{height:o*(h-s)*m}})]})]})};function Qs(e,t,r,n){return e.Top<-n&&(e.Bottom=e.Bottom-e.Top+n,e.Top=-n),e.Left<-n&&(e.Right=e.Right-e.Left+n,e.Left=-n),e.Right+n>t&&(e.Left=e.Left-(e.Right-t)+n,e.Right=t-n),e.Bottom+n>r&&(e.Top=e.Top-(e.Bottom-r)+n,e.Bottom=r-n),e}function Js({Top:e,Left:t,Bottom:r,Right:n},i,o,a,s){const l=s*e,c=s*r;return l>o?[0,-1]:c>o?[0,1]:a*t>i?[-1,0]:a*n>i?[1,0]:[0,l>c?1:-1]}function Xs(e,t){return{Top:e.Top+t[1],Left:e.Left+t[0],Bottom:e.Bottom+t[1],Right:e.Right+t[0]}}Gs.displayName="LicensePlateHighlight";const Ks=({face:{Name:e,Box:t,Probability:r},url:n,thumbWidth:i,thumbHeight:o,width:a,height:s})=>{const{Top:l,Left:c,Right:h,Bottom:d}=t,u=100/i/(h-c),p={top:2},f=T(null);return z((()=>{if(!f.current)return;const{width:e,height:r}=f.current.getBoundingClientRect(),n=Js(t,e,r,a,s);n[0]=n[0]*(e+(h-c)*a)/2,n[1]=n[1]*(r+(d-l)*s)/2;const i=Qs(Xs({Top:(l+d)/2*s-r/2,Left:(c+h)/2*a-e/2,Bottom:(l+d)/2*s+r/2,Right:(c+h)/2*a+e/2},n),a,s,0);f.current.style.top=`${i.Top+2*Math.sign(n[1])}px`,f.current.style.left=`${i.Left+2*Math.sign(n[0])}px`})),c>=1-h?p.left=2:p.right=2,v(y,{children:[v("div",{ref:f,className:"event-list-item__detected-object-label trigger",title:`${e} ${Math.floor(100*r)}%`,children:[g("div",{style:{padding:4,display:"flex",alignItems:"center",maxWidth:120,whiteSpace:"break-spaces"},children:e}),v("div",{className:"event-list-item__detected-object-label__caption",style:{color:"black",backgroundColor:"orange"},children:[Math.floor(100*r),"%"]})]}),g(Ws,{className:"trigger",box:t,style:{outline:"1px solid orange"}}),v("div",{className:"event-list-item-face preview",style:{overflow:"hidden",width:i*(h-c)*u,height:o*(d-l)*u,...p},children:[g("img",{style:{width:i*u,height:o*u,transform:`translate(-${100*c}%, -${100*l}%)`},src:n}),g(Ys,{})]})]})};function el({Top:e,Left:t,Bottom:r,Right:n}){return[(t+n)/2,(e+r)/2]}function tl(e,t){const[r,n]=el(e),[i,o]=el(t);return[i-r,o-n]}function rl(e,t){return!(e.Left>t.Right||e.Top>t.Bottom||e.Right<t.Left||e.Bottom<t.Top)}function nl([e,t]){const r=Math.sqrt(e*e+t*t);return 0===r?[0,0]:[e/r,t/r]}Ks.displayName="FaceHighlight";const il=F((({data:e,width:t,height:r})=>{const n=T(null),{eventSchema:i}=k(Cr);return z((()=>{if(!n.current)return;const i=[],o=[];for(let a=0;a<e.length;a++){const s=n.current.children[2*a+1],l=e[a].Box;i.push({Top:l.Top*r,Left:l.Left*t,Bottom:l.Bottom*r,Right:l.Right*t});const[c,h]=el(i[a]),{width:d,height:u}=s.getBoundingClientRect(),p=Js(l,d,u,t,r);o.push(Xs({Top:h-u/2-4,Left:c-d/2-4,Bottom:h+u/2+4,Right:c+d/2+4},p))}let a=!0,s=0;for(;a;){if(a=!1,s++>1e3){console.warn("Reached max iterations for label positioning");break}for(let t=0;t<e.length;t++){const r=o[t],n=[0,0];for(let s=0;s<e.length;s++){const e=i[s],l=o[s];if(rl(r,e)){const t=tl(e,r);n[0]=n[0]+t[0],n[1]=n[1]+t[1],a=!0}if(s!==t&&rl(r,l)){const e=tl(l,r);n[0]=n[0]+e[0],n[1]=n[1]+e[1],a=!0}}[n[0],n[1]]=nl(n),r.Top+=n[1],r.Left+=n[0],r.Bottom+=n[1],r.Right+=n[0]}}for(let i=0;i<e.length;i++){const e=n.current.children[2*i+1],{Top:a,Left:s}=Qs(o[i],t,r,4);e.style.top=`${a+4}px`,e.style.left=`${s+4}px`}}),[e,t,r]),g("div",{ref:n,children:e.map(((e,t)=>v(b.Fragment,{children:[g(Ws,{box:e.Box,style:{outline:`2px solid ${i.colorsByFoundObjectType.get(e.Type)??""}`}}),v("div",{className:"event-list-item__detected-object-label",title:`${e.Type.toLowerCase()} ${Math.floor(100*e.Probability)}%`,children:[g("div",{style:{padding:4,lineHeight:"24px"},children:"Car"===e.Type&&"BodyType"in e&&e.BodyType?e.BodyType.toLowerCase():e.Type.toLowerCase()}),v("div",{className:"event-list-item__detected-object-label__caption",style:{backgroundColor:i.colorsByFoundObjectType.get(e.Type)},children:[Math.floor(100*e.Probability),"%"]})]})]},t)))})}));il.displayName="DetectedObjects";var ol=il;const al=F((({data:e,width:t,height:r,cameraNameHidden:n,onClick:i,onAuxClick:o,menuComponent:a})=>{const s=k(Cr),{eventSchema:l}=s,[c,h]=function(e){const[t,r]=C(null),n=k(Cr),{cameras:i,thumbnails:o}=n;M((()=>{if(e.thumbnailUrl)return void r(null);const t=o.fetchThumbnail(e.cameraId,e.startTime,e.startTime).subscribe((e=>{r(e||null)}));return()=>t.unsubscribe()}),[e.id]);let a="",s=!1;return e.thumbnailUrl?a=e.thumbnailUrl:null===t&&i.loaded?(a=i.camerasById.get(e.cameraId)?.imageUrl||"",s=!0):t&&(a=t.url),[a,s]}(e);let d=[],u=null,p=null;if(e.detectedObjects.length){const{thumbnailWidth:n,thumbnailHeight:i}=e;d=e.detectedObjects.filter((({Type:e})=>l.foundObjectTypes.includes(e)&&"LicensePlate"!==e)),u=e.detectedObjects.filter((e=>"LicensePlate"===e.Type)).map(((e,o)=>g(Gs,{detectedObject:e,width:t,height:r,thumbWidth:n,thumbHeight:i,url:c},o)))}if(e.faces){const{thumbnailWidth:n,thumbnailHeight:i}=e;p=e.faces.map(((e,o)=>g(Ks,{face:e,url:c,thumbWidth:n,thumbHeight:i,width:t,height:r},o)))}return g(Hs,{onClick:i,onAuxClick:o,data:e,width:t,height:r,menuComponent:a,children:v("div",{style:{position:"absolute",top:0,left:0,bottom:0,right:0},children:[g(Zs,{url:c,noPreview:h,width:t}),g(ol,{data:d,width:t,height:r}),u,p,e.acknowledged?g("div",{className:"acknowledged-overlay",children:Fe.t("event.acknowledged")}):null,g(Vs,{data:e,cameraNameHidden:n})]})})}));al.displayName="EventItem";const sl=F((({columnIndex:e,rowIndex:t,style:r,store:n,columnCount:i,eventRenderer:o})=>{const a=t*i+e,s=n.data[a];return a===n.data.length?n.error?g("div",{style:r,children:g("div",{style:{position:"absolute",inset:0,display:"grid",placeItems:"center"},children:v("div",{style:{textAlign:"center"},children:[g("div",{children:"Couldn't fetch more data"}),g(xa,{onClick:n.loadMore,children:"Retry"})]})})}):n.pageInfo?.haveMore?g("div",{style:r,children:g("div",{style:{position:"absolute",inset:0,display:"grid",placeItems:"center"},children:g(ws,{size:32})})}):g("div",{style:r}):!s&&n.pageInfo?.haveMore?g("div",{style:r}):g("div",s?{style:r,children:g(gs,{children:o({data:s,width:r.width,height:r.height})})}:{style:r})})),ll=F((({store:e,scrollWidth:t,onClick:r})=>e.pendingData.length?g("div",{style:{position:"absolute",top:0,left:0,right:t,pointerEvents:"none",textAlign:"center",padding:8},children:g(xa,{className:"x-3deye-button--overlay",style:{background:"rgba(0, 0, 0, 0.75)",padding:"8px 16px",backdropFilter:"blur(2px)",borderRadius:32,pointerEvents:"auto"},onClick:r,children:Fe.t("showEvents",{count:e.pendingData.length})})}):null)),cl=F((({store:e,width:t,height:r,captionHeight:n=0,columnsCount:i=0,minColumnWidth:o,aspectRatio:a=16/9,onEventClick:s,onEventAuxClick:l,eventRenderer:c})=>{const h=T(null),d=()=>{h.current&&(e.setLiveUpdateMode("auto"),h.current.scrollTop=0)};if(M((()=>Me((()=>e.loading||!e.data.length),(e=>e&&d()))),[]),e.error&&!e.data.length)return g("div",{style:{flex:1,display:"flex",justifyContent:"center",alignItems:"center"},children:v("div",{style:{textAlign:"center"},children:[g("div",{children:"Couldn't fetch data"}),g(xa,{onClick:e.reload,children:"Retry"})]})});if(e.loading)return g("div",{style:{flex:1,display:"flex",justifyContent:"center",alignItems:"center"},children:g(ws,{})});if(!e.data.length)return g("div",{style:{flex:1,display:"flex",justifyContent:"center",alignItems:"center"},children:Fe.t("noEventsFound")});return g(hl,{...{store:e,width:t,columnsCount:i,minColumnWidth:o,aspectRatio:a,captionHeight:n,height:r,onEventClick:s,onEventAuxClick:l,eventRenderer:c,containerRef:h,resetScroll:d}})}));cl.displayName="EventGrid";const hl=F((({store:e,width:t,height:r,captionHeight:n=0,columnsCount:i=0,minColumnWidth:o=320,aspectRatio:a,containerRef:s,onEventClick:l,onEventAuxClick:c,eventRenderer:h=({data:e,width:t,height:r})=>g(al,{data:e.data,cameraNameHidden:!1,onClick:l,onAuxClick:c,width:t,height:r}),resetScroll:d})=>{const u=Math.floor(t/o)||1,p=t/u/a+n,f=u*Math.floor(r/p)>=e.data.length?0:Kn(),m=Math.min(i,e.data.length)||Math.max(1,Math.floor((t-f)/o));let y=Math.ceil(e.data.length/m);const b=(t-f-2*(m-1))/m,x=b/a+n;e.pageInfo?.haveMore&&y*m===e.data.length&&y++;const{parentRef:w,getItems:C,getTotalSize:T}=zs({count:y,overscan:5,itemSize:x,spacing:2}),{parentRef:_,getItems:D,getTotalSize:L}=zs({count:m,overscan:5,itemSize:b,horizontal:!0,spacing:2}),N=C(),I=D();M((()=>{e.error||e.pageInfo?.haveMore&&(e.loading||N.length&&N.at(-1).idx+1===y&&e.loadMore())}),[e.error,e.pageInfo?.haveMore,N]);const k=N.flatMap((({idx:t,size:r,start:n})=>I.map((({idx:i,size:o,start:a})=>{const s=t*m+i;return s>e.data.length?null:s!==e.data.length||e.pageInfo?.haveMore?g(sl,{columnIndex:i,rowIndex:t,columnCount:m,style:{position:"absolute",top:0,left:0,height:r,width:o,transform:`translate(${a}px, ${n}px)`,display:"flex"},store:e,eventRenderer:h},e.data[s]?`${e.data[s].data.id}-${e.data[s].objectIdx}`:"loading"):null}))));return v("div",{style:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:[g("div",{ref:ee(s,w,_),style:{width:t,height:r,overflow:"auto"},onScroll:t=>{const{scrollTop:r}=t.target;"disabled"!==e.liveUpdateMode&&e.setLiveUpdateMode(r>=1||e.pendingData.length?"manual":"auto")},children:g("div",{style:{position:"relative",height:T(),width:L()},children:k})}),g(ll,{store:e,scrollWidth:f,onClick:()=>{e.flushUpdates(),d()}})]})}));const dl=F((({data:{data:e,objectIdx:t},width:r,height:n,cameraNameHidden:i,onClick:o,onAuxClick:a,menuComponent:s})=>{let l=null;const{thumbnailWidth:c,thumbnailHeight:h}=e;l=e.detectedObjects[t];const{Box:{Bottom:d,Left:u,Right:p,Top:f}}=l,m="Person"===l?.Type?.8:1,{imageTop:y,imageLeft:b,imageScale:x}=function(e,t,r,n,i,o=1){const{top:a,left:s,bottom:l,right:c}=r,h=a*n,d=s*i,u=(l-a)*n,p=(c-s)*i;let f=1,m=0,g=0;return e/t>p/u?(f=t/u*o,m=-h*f+(t-u*f)/2,g=-(d+p/2)*f+e/2):(f=e/p*o,m=-(h+u/2)*f+t/2,g=-d*f),{imageTop:m,imageLeft:g,imageScale:f}}(r,n,{top:f,left:u,bottom:d,right:p},h,c,m);return g(Hs,{onClick:o,onAuxClick:a,data:e,width:r,height:n,cameraNameHidden:i,menuComponent:s,children:v("div",{style:{position:"absolute",top:0,left:0,bottom:0,right:0},children:[g("img",{src:e.thumbnailUrl,style:{position:"absolute",top:y,left:b,width:c*x,height:h*x}},e.thumbnailUrl),g(S,{radius:r}),g(Vs,{data:e,cameraNameHidden:!0})]})})}));dl.displayName="DetectedObjectCell";var ul=ga;var pl=Pe((function(e,t){return ul(e,t)}));const fl={Top:0,Left:0,Bottom:1,Right:1};class ml extends ri{eventSchema;events;account;notification;heatmaps;disposables=[];analyticsEnabled;cameraId=null;date=null;get startTime(){return this.date?(e=this.date,this.account.preferences.utc?new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())):new Date(e.getFullYear(),e.getMonth(),e.getDate())):null;var e}regions=null;filters=[];colors=new Set;peopleCountingDataLoading=!1;heatmapMode="selection";heatmapLoading=!1;data=[];heatmap=null;peopleCountingData=[];probabilityThreshold=.5;brushFilter=null;loadTrigger=0;eventsLoader;loaderFilters;get params(){return this.eventSchema.schemaDescription.filter((e=>"filter"===e.parameterType))}get filteredData(){let e=[];const t=this.filters.map((e=>e.value));t.length?(e=this.data.filter((e=>e.detectedObjects.some((e=>t.includes(e.Type)&&e.Probability>=this.probabilityThreshold)))),this.colors.size&&(e=e.filter((e=>e.detectedObjects.some((e=>"Colors"in e&&e.Colors?.some((e=>this.colors.has(e.Color))))))))):e=this.data.filter((e=>e.detectedObjects.some((e=>e.Probability>=this.probabilityThreshold))));const{brushFilter:r}=this;r&&(e=e.filter((e=>e.startTime>=r[0]&&e.startTime<=r[1]&&e.detectedObjects.some((e=>"Person"===e.Type)))));const{regions:n}=this;return n?.length&&(e=e.filter((e=>e.detectedObjects.some((e=>(!t.length||t.includes(e.Type))&&(!this.colors.size||"Colors"in e&&e.Colors?.some((e=>this.colors.has(e.Color))))&&e.Probability>=this.probabilityThreshold&&n.some((t=>gr(t,{x:e.Box.Left,y:e.Box.Top,width:e.Box.Right-e.Box.Left,height:e.Box.Bottom-e.Box.Top})))))))),e}get filteredPeopleCountingData(){const{regions:e}=this;return e?.length?this.peopleCountingData.filter((t=>e.some((e=>gr(e,{x:t.Left,y:t.Top,width:t.Right-t.Left,height:t.Bottom-t.Top}))))):this.peopleCountingData}constructor(e,t,r,n,i){super(),this.eventSchema=e,this.events=t,this.account=r,this.notification=n,this.heatmaps=i,xe(this,{cameraId:we,date:we,setDate:Ce,startTime:ye,regions:we.ref,filters:we.ref,colors:we.ref,peopleCountingDataLoading:we,heatmapMode:we,heatmapLoading:we,data:we.ref,heatmap:we.ref,peopleCountingData:we.ref,probabilityThreshold:we,brushFilter:we.ref,params:ye,filteredData:ye,filteredPeopleCountingData:ye,setFilters:Ce,setBrushFilter:Ce,setParams:Ce,searchFullFrame:Ce,setRegions:Ce,setHeatmapMode:Ce,toggleColor:Ce,clearColors:Ce,clear:Ce,loadTrigger:we}),this.analyticsEnabled=Boolean(i);const o=new Os;this.loaderFilters=o;const a=(e=>(t,r)=>t.cameras.GetSensorEventsPage({sensorIds:e.cameras,sensorType:"camera",sensorEventTypes:e.eventTypes,startTime:e.from??void 0,endTime:e.to??void 0,isDescending:"DESC"===e.sortDirection,rowsLimit:10,pageToken:r},e.filterJson,e.regionsWkt))(o);this.eventsLoader=new va(t,o,a,(e=>e.detectedObjects.map(((e,t)=>o.detectedObjects.length&&!o.detectedObjects.includes(e.Type)||o.colors.size&&"Colors"in e&&!e.Colors?.some((e=>o.colors.has(e.Color)))||null!==o.probabilityThreshold&&e.Probability<o.probabilityThreshold||o.regions?.length&&!o.regions.some((t=>gr(t,this.boxToAabb(e.Box))))?-1:t)).filter((e=>-1!==e)).map((t=>({data:e,objectIdx:t}))))),this.eventsLoader.liveUpdateMode="disabled",this.initDataFetching()}boxToAabb(e){return{x:e.Left,y:e.Top,width:e.Right-e.Left,height:e.Bottom-e.Top}}setDate=e=>{this.date=e,this.brushFilter=null};setFilters=e=>{this.filters=e};getProbabilityThreshold=()=>this.probabilityThreshold;setProbabilityThreshold=e=>{this.probabilityThreshold=e};setBrushFilter=e=>{this.brushFilter=e};setParams=({cameraId:e,box:t})=>{this.cameraId=e,this.regions=[[{x:t.Left,y:t.Top},{x:t.Right,y:t.Top},{x:t.Right,y:t.Bottom},{x:t.Left,y:t.Bottom}]],this.date||(this.date=new Date)};searchFullFrame=e=>{this.clear(),this.cameraId=e,this.peopleCountingData=[],this.date||(this.date=new Date),this.triggerLoad()};triggerLoad=()=>{this.loadTrigger++};setRegions=e=>{this.regions=e.length?e:null};setHeatmapMode=e=>{this.heatmapMode=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};clear=()=>{this.cameraId=null,this.date=null,this.regions=null,this.brushFilter=null,this.heatmap=null,this.data=[],this.peopleCountingData=[]};initDataFetching=()=>{const e=Tr((()=>({startTime:this.startTime,regions:this.regions,cameraId:this.cameraId,trigger:this.loadTrigger})),!0).pipe(_e(pl),De());this.disposables.push(Tr((()=>({startTime:this.startTime,regions:this.regions,cameraId:this.cameraId,filters:this.filters,brushFilter:this.brushFilter,colors:this.colors,probabilityThreshold:this.probabilityThreshold})),!0).pipe(_e(pl),De()).subscribe((e=>{Te((()=>{if(!e.startTime||!e.cameraId)return;this.loaderFilters.sortDirection="DESC";const{startTime:t}=e,r=vr(t,this.account.preferences.utc);this.loaderFilters.from=t,this.loaderFilters.to=r;const{brushFilter:n}=e;n&&([this.loaderFilters.from,this.loaderFilters.to]=n),this.loaderFilters.regions=[...e.regions||[]],this.loaderFilters.cameras=[e.cameraId],this.loaderFilters.detectedObjects=e.filters.map((e=>e.value)),this.loaderFilters.eventTypes=[Mr.Analytic],this.loaderFilters.colors=e.colors,this.loaderFilters.probabilityThreshold=e.probabilityThreshold,this.eventsLoader.load()}))})));const r=this.heatmaps;r&&(this.disposables.push(e.pipe(Le((e=>{if(!e.startTime||!e.cameraId)return u;Te((()=>{this.peopleCountingDataLoading=!0}));const{startTime:r}=e,n=vr(r,this.account.preferences.utc),i=e.regions?this.boxRegions(e.regions):fl;return this.api.cameras.GetPeopleCountingData(e.cameraId,r,n,i).pipe(Ne((e=>e.success?t(e.resultItems):a((()=>e.error))))).pipe(Ie((e=>(this.notification.error(Fe.t("eventSearchRequestError.peopleCounting")),console.error(e),t([])))))}))).subscribe((e=>{Te((()=>{this.peopleCountingData=e,this.peopleCountingDataLoading=!1}))}))),this.disposables.push(Tr((()=>({startTime:this.startTime,cameraId:this.cameraId,trigger:this.loadTrigger})),!0).pipe(_e(pl),Le((e=>{if(!e.startTime||!e.cameraId)return u;Te((()=>{this.heatmapLoading=!0}));const{startTime:n}=e,i=vr(n,this.account.preferences.utc);return r.fetchHeatmaps(e.cameraId,n,i,1).pipe(ke((e=>e[0]||null))).pipe(Ie((e=>(this.notification.error(Fe.t("eventSearchRequestError.heatmap")),console.error(e),t(null)))))}))).subscribe((e=>{Te((()=>{this.heatmap=e,this.heatmapLoading=!1}))}))))};boxRegions(e){const t=e.flatMap((e=>e.map((({x:e})=>e)))),r=e.flatMap((e=>e.map((({y:e})=>e))));return{Left:Math.min(...t),Right:Math.max(...t),Top:Math.min(...r),Bottom:Math.max(...r)}}afterInit(){this.eventsLoader.initWith(this.api)}}const gl=F((({store:e})=>{const[t,r]=C(!1),{account:n,cameras:i}=k(Cr),{utc:o,hour12:a,startOfWeek:s}=n.preferences,{date:l,setDate:c,cameraId:h}=e,d=h?i.camerasById.get(h):void 0,u=new Date,p=xr(u,1,o),f=l&&yr(l,u,o),m=l&&yr(l,p,o),y=d?wr(u,d.archiveDuration):u,b=N((()=>{const e=new Intl.DateTimeFormat(Fe.language,{weekday:"short",month:"short",day:"numeric"});return t=>e.format(t)}),[o,a]);return v(wa,{children:[g(xa,{className:O({"button-selected":f}),onClick:()=>c(new Date),children:Fe.t("today")}),h&&!yr(new Date,y,o)?g(xa,{className:O({"button-selected":m}),onClick:()=>c(p),children:Fe.t("yesterday")}):null,l&&v(xs,{className:"popover-datepicker",target:g(xa,{className:O("date-button",{"button-selected":!f&&!m}),onClick:()=>r(!t),children:b(l)}),opened:t,withArrow:!0,onOpenChange:r,children:[g(us,{date:l,onChange:c,minDate:y,maxDate:new Date,utc:o,startOfWeek:s}),g("div",{style:{display:"flex"},children:g(xa,{style:{flex:1},onClick:()=>r(!1),variant:"filled",children:Fe.t("button.ok")})})]})]})}));gl.displayName="DateSelector";var vl=gl;const yl=F((({store:e})=>{const t=T(null),r=T(null),n=T(null),i=T([]),[o,a]=C(0),s=100,l=20,c=20,h=30,d=20,{filteredPeopleCountingData:u,brushFilter:p}=e,f=p?i.current.filter((e=>+e.x0>=+p[0]&&+e.x1<=+p[1])).reduce(((e,t)=>e+t.length),0):null;return M((()=>{const e=new ve((e=>{for(const t of e){const e=t.contentRect.width;a(e)}}));return e.observe(t.current),()=>e.disconnect()}),[]),M((()=>{const t=le(r.current);if(!o)return;for(const e of u)e.timestamp=new Date(e.TimeStamp);const a=oe(u,(e=>e.timestamp)),p=de(ue.offset(a[0],-1),ue.offset(a[1],1)),f=me().extent([[d,l],[o-c,s-h]]).on("end",(function({selection:t,sourceEvent:r}){if(!r)return;if(!t)return void e.setBrushFilter(null);const n=pe.every((+i.current[0].x1-+i.current[0].x0)/6e4||30);let[o,a]=t.map((e=>n.round(m.invert(e))));if(+o==+a&&(o=n.floor(m.invert(t[0])),a=n.ceil(m.invert(t[1])),+o==+a))return le(this).transition().call(f.move,null),void e.setBrushFilter(null);e.setBrushFilter([o,a]),le(this).transition().call(f.move,a>o?[o,a].map(m):null)}));n.current=f;const m=ce().domain(oe(p)).nice().range([d,o-c]);i.current=u.length?ae().value((e=>e.timestamp)).domain(m.domain()).thresholds(m.ticks(24))(u):[];const g=he().domain([0,se(i.current,(e=>e.length))]).nice().range([s-h,l]),v=t.select(".bars").selectAll(".bar").data(i.current);v.exit().remove();const y=v.enter().append("g").attr("class","bar");if(y.append("rect").attr("x",(e=>m(e.x0)+1)).attr("width",(e=>Math.max(0,m(e.x1)-m(e.x0)-1))).attr("y",(e=>g(e.length))).attr("height",(e=>g(0)-g(e.length))),v.select("rect").attr("x",(e=>m(e.x0)+1)).attr("width",(e=>Math.max(0,m(e.x1)-m(e.x0)-1))).attr("y",(e=>g(e.length))).attr("height",(e=>g(0)-g(e.length))),y.append("text").attr("dy",".75em").attr("y",(e=>g(e.length)-10)).attr("x",(e=>m(e.x0)+1+Math.max(0,m(e.x1)-m(e.x0)-1)/2)).attr("text-anchor","middle").text((e=>e.length?e.length:"")),v.select("text").attr("dy",".75em").attr("y",(e=>g(e.length)-10)).attr("x",(e=>m(e.x0)+1+Math.max(0,m(e.x1)-m(e.x0)-1)/2)).attr("text-anchor","middle").text((e=>e.length?e.length:"")),u.length){const[r,n]=m.domain(),[i,o]=m.range(),a=(o-i)/(+n-+r)*3600*1e3,s=30,l=fe(m).ticks(ue.every(1)).tickFormat((e=>a>=s?ge("%H:%M")(e):e.getHours()%(Math.floor(s/a)+1)?"":ge("%H:%M")(e)));l.scale(m),t.select(".x-axis").attr("transform","translate(0,70)").call(l),t.select(".brush").call(f),e.brushFilter&&t.select(".brush").call(f.move,e.brushFilter.map(m))}else t.select(".x-axis").html(""),t.select(".brush").call(f),t.select(".brush").html("").call(f.move,null)}),[o,u]),M((()=>{n.current&&(e.brushFilter||le(r.current).select(".brush").call(n.current.move,null))}),[e.brushFilter]),v("div",{ref:t,children:[v("div",{style:{paddingLeft:10,paddingRight:10,display:"flex"},children:[Fe.t("peopleCounting"),v("div",{style:{marginLeft:"auto"},children:[null===f?null:g(ks,{label:Fe.t("selected"),children:g("span",{children:f})}),null===f?null:"/",g(ks,{label:Fe.t("total"),children:g("span",{children:u.length})})]})]}),v("svg",{ref:r,className:"people-histogram",width:o,height:s,viewBox:`0 0 ${o} 100`,role:"graphics-symbol",children:[g("g",{className:"bars"}),g("g",{className:"x-axis"}),g("g",{className:"brush"})]})]})}));var bl=yl;yl.displayName="PeopleHistogram";const xl=F((({store:e,onEventClick:t})=>{if(!e)return null;const{filters:r,setFilters:n}=e,{foundObjectTypesForSelect:i}=e.eventSchema,{ref:o,width:a,height:s}=j();return v(y,{children:[g(vl,{store:e}),g("div",{style:{zIndex:2,padding:"0.5rem"},children:g(Ds,{onChange:n,options:i.map((e=>({...e,label:Fe.t(e.label)}))),placeholder:Fe.t("selectObjectType"),values:r,renderOption:Rs,renderValue:Us})}),g(js,{getter:e.getProbabilityThreshold,setter:e.setProbabilityThreshold}),g(as,{value:e.colors,toggle:e.toggleColor,clear:e.clearColors}),e.analyticsEnabled?g(bl,{store:e}):null,g("div",{ref:o,style:{flex:1,overflow:"hidden"},children:g(cl,{width:a,height:s,minColumnWidth:120,aspectRatio:1,store:e.eventsLoader,eventRenderer:({data:e,width:r,height:n})=>g(dl,{data:e,cameraNameHidden:!0,onClick:t,width:r,height:n})})})]})}));xl.displayName="EventSearch";const wl=e=>{const t=k(f)??m;return g(Cr.Provider,{value:t,children:g(xl,{...e})})};wl.displayName="EventSearch";var Cl=wl;(e=>{if(e&&Object.assign(je,e),Fe.isInitialized){if(je.resources)for(const e of Object.keys(je.resources))Fe.addResourceBundle(e,"translation",je.resources[e].translation,!0);else console.warn("i18n is already initialized");return t(Fe.t)}r(Fe.init(je))})({resources:{en:{translation:ze}}});const Tl=(e=m)=>{const t=new ml(e.eventSchema,e.events,e.account,e.notification);return t.initWith(e.api),t};export{Tl as createEventSearchStore,Cl as default};
1
+ import e from"i18next";import{of as t,from as r,Observable as n,Subscription as i,mergeMap as o,throwError as a,catchError as s,startWith as l,switchMap as c,map as h,exhaustMap as d,EMPTY as u,Subject as p}from"rxjs";import{AppContext as f,app as m}from"@3deye-toolkit/core";import{jsx as g,jsxs as v,Fragment as y}from"react/jsx-runtime";import b,{forwardRef as x,memo as w,useState as C,useRef as T,useEffect as M,createContext as _,Component as D,useCallback as L,useMemo as N,cloneElement as I,useContext as k,useLayoutEffect as z}from"react";import{useElementSize as j}from"@mantine/hooks";import{observer as F}from"mobx-react-lite";import O from"clsx";import S from"react-ink";import{useMergeRefs as B,useListItem as P,useFloatingTree as R,useFloating as U,offset as A,flip as H,shift as E,arrow as $,autoUpdate as V,useInteractions as Z,useRole as W,useDismiss as Y,FloatingPortal as q,FloatingFocusManager as G,useId as Q,size as J,useListNavigation as X,useHover as K}from"@floating-ui/react";import ee from"@seznam/compose-react-refs";import{differenceInCalendarDays as te,max as re,min as ne}from"date-fns";import ie from"memoize-one";import{extent as oe,bin as ae,max as se}from"d3-array";import{select as le}from"d3-selection";import{scaleTime as ce,scaleLinear as he}from"d3-scale";import{timeHours as de,timeHour as ue,timeMinute as pe}from"d3-time";import{axisBottom as fe}from"d3-axis";import{brushX as me}from"d3-brush";import{timeFormat as ge}from"d3-time-format";import ve from"resize-observer-polyfill";import{computed as ye,observe as be,makeObservable as xe,observable as we,action as Ce,runInAction as Te,reaction as Me}from"mobx";import{distinctUntilChanged as _e,share as De,switchMap as Le,mergeMap as Ne,catchError as Ie,map as ke}from"rxjs/operators";var ze={selectObjectType:"Select object type",showEvents_one:"show {{count}} new event",showEvents_other:"show {{count}} new events",noEventsFound:"no events found",eventTypes:{Loitering:"Loitering"},filter:"Filter",color:"color",select:{loading:"Loading...",noOptions:"No options"},confidence:"confidence",today:"today",yesterday:"yesterday",button:{ok:"Ok"},peopleCounting:"People Counting",selected:"selected",total:"total",event:{acknowledged:"acknowledged"}};const je={detection:{order:["querystring","htmlTag","navigator"],lookupQuerystring:"lang"},fallbackLng:"en",load:"all",interpolation:{escapeValue:!1}},Fe=e.createInstance(),Oe=([e,t],[r,n],[i,o])=>{const a=(n-t)*(i-r)-(r-e)*(o-n);return 0===a?0:a>0?1:2},Se=([e,t],[r,n],[i,o])=>r<=Math.max(e,i)&&r>=Math.min(e,i)&&n<=Math.max(t,o)&&n>=Math.min(t,o);var Be="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Pe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Re={exports:{}};function Ue(e,t,r){r=r||2;var n,i,o,a,s,l,c,h=t&&t.length,d=h?t[0]*r:e.length,u=Ae(e,0,d,r,!0),p=[];if(!u||u.next===u.prev)return p;if(h&&(u=function(e,t,r,n){var i,o,a,s=[];for(i=0,o=t.length;i<o;i++)(a=Ae(e,t[i]*n,i<o-1?t[i+1]*n:e.length,n,!1))===a.next&&(a.steiner=!0),s.push(Je(a));for(s.sort(Ye),i=0;i<s.length;i++)r=qe(s[i],r);return r}(e,t,u,r)),e.length>80*r){n=o=e[0],i=a=e[1];for(var f=r;f<d;f+=r)(s=e[f])<n&&(n=s),(l=e[f+1])<i&&(i=l),s>o&&(o=s),l>a&&(a=l);c=0!==(c=Math.max(o-n,a-i))?32767/c:0}return Ee(u,p,r,n,i,c,0),p}function Ae(e,t,r,n,i){var o,a;if(i===ht(e,t,r,n)>0)for(o=t;o<r;o+=n)a=st(o,e[o],e[o+1],a);else for(o=r-n;o>=t;o-=n)a=st(o,e[o],e[o+1],a);return a&&tt(a,a.next)&&(lt(a),a=a.next),a}function He(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!tt(n,n.next)&&0!==et(n.prev,n,n.next))n=n.next;else{if(lt(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function Ee(e,t,r,n,i,o,a){if(e){!a&&o&&function(e,t,r,n){var i=e;do{0===i.z&&(i.z=Qe(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,r,n,i,o,a,s,l,c=1;do{for(r=e,e=null,o=null,a=0;r;){for(a++,n=r,s=0,t=0;t<c&&(s++,n=n.nextZ);t++);for(l=c;s>0||l>0&&n;)0!==s&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,l--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;r=n}o.nextZ=null,c*=2}while(a>1)}(i)}(e,n,i,o);for(var s,l,c=e;e.prev!==e.next;)if(s=e.prev,l=e.next,o?Ve(e,n,i,o):$e(e))t.push(s.i/r|0),t.push(e.i/r|0),t.push(l.i/r|0),lt(e),e=l.next,c=l.next;else if((e=l)===c){a?1===a?Ee(e=Ze(He(e),t,r),t,r,n,i,o,2):2===a&&We(e,t,r,n,i,o):Ee(He(e),t,r,n,i,o,1);break}}}function $e(e){var t=e.prev,r=e,n=e.next;if(et(t,r,n)>=0)return!1;for(var i=t.x,o=r.x,a=n.x,s=t.y,l=r.y,c=n.y,h=i<o?i<a?i:a:o<a?o:a,d=s<l?s<c?s:c:l<c?l:c,u=i>o?i>a?i:a:o>a?o:a,p=s>l?s>c?s:c:l>c?l:c,f=n.next;f!==t;){if(f.x>=h&&f.x<=u&&f.y>=d&&f.y<=p&&Xe(i,s,o,l,a,c,f.x,f.y)&&et(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Ve(e,t,r,n){var i=e.prev,o=e,a=e.next;if(et(i,o,a)>=0)return!1;for(var s=i.x,l=o.x,c=a.x,h=i.y,d=o.y,u=a.y,p=s<l?s<c?s:c:l<c?l:c,f=h<d?h<u?h:u:d<u?d:u,m=s>l?s>c?s:c:l>c?l:c,g=h>d?h>u?h:u:d>u?d:u,v=Qe(p,f,t,r,n),y=Qe(m,g,t,r,n),b=e.prevZ,x=e.nextZ;b&&b.z>=v&&x&&x.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==i&&b!==a&&Xe(s,h,l,d,c,u,b.x,b.y)&&et(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==i&&x!==a&&Xe(s,h,l,d,c,u,x.x,x.y)&&et(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;b&&b.z>=v;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==i&&b!==a&&Xe(s,h,l,d,c,u,b.x,b.y)&&et(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;x&&x.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==i&&x!==a&&Xe(s,h,l,d,c,u,x.x,x.y)&&et(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Ze(e,t,r){var n=e;do{var i=n.prev,o=n.next.next;!tt(i,o)&&rt(i,n,n.next,o)&&ot(i,o)&&ot(o,i)&&(t.push(i.i/r|0),t.push(n.i/r|0),t.push(o.i/r|0),lt(n),lt(n.next),n=e=o),n=n.next}while(n!==e);return He(n)}function We(e,t,r,n,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Ke(a,s)){var l=at(a,s);return a=He(a,a.next),l=He(l,l.next),Ee(a,t,r,n,i,o,0),void Ee(l,t,r,n,i,o,0)}s=s.next}a=a.next}while(a!==e)}function Ye(e,t){return e.x-t.x}function qe(e,t){var r=function(e,t){var r,n=t,i=e.x,o=e.y,a=-1/0;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){var s=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>a&&(a=s,r=n.x<n.next.x?n:n.next,s===i))return r}n=n.next}while(n!==t);if(!r)return null;var l,c=r,h=r.x,d=r.y,u=1/0;n=r;do{i>=n.x&&n.x>=h&&i!==n.x&&Xe(o<d?i:a,o,h,d,o<d?a:i,o,n.x,n.y)&&(l=Math.abs(o-n.y)/(i-n.x),ot(n,e)&&(l<u||l===u&&(n.x>r.x||n.x===r.x&&Ge(r,n)))&&(r=n,u=l)),n=n.next}while(n!==c);return r}(e,t);if(!r)return t;var n=at(r,e);return He(n,n.next),He(r,r.next)}function Ge(e,t){return et(e.prev,e,t.prev)<0&&et(t.next,e,e.next)<0}function Qe(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Je(e){var t=e,r=e;do{(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next}while(t!==e);return r}function Xe(e,t,r,n,i,o,a,s){return(i-a)*(t-s)>=(e-a)*(o-s)&&(e-a)*(n-s)>=(r-a)*(t-s)&&(r-a)*(o-s)>=(i-a)*(n-s)}function Ke(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&rt(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(ot(e,t)&&ot(t,e)&&function(e,t){var r=e,n=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&i<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==e);return n}(e,t)&&(et(e.prev,e,t.prev)||et(e,t.prev,t))||tt(e,t)&&et(e.prev,e,e.next)>0&&et(t.prev,t,t.next)>0)}function et(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function tt(e,t){return e.x===t.x&&e.y===t.y}function rt(e,t,r,n){var i=it(et(e,t,r)),o=it(et(e,t,n)),a=it(et(r,n,e)),s=it(et(r,n,t));return i!==o&&a!==s||(!(0!==i||!nt(e,r,t))||(!(0!==o||!nt(e,n,t))||(!(0!==a||!nt(r,e,n))||!(0!==s||!nt(r,t,n)))))}function nt(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function it(e){return e>0?1:e<0?-1:0}function ot(e,t){return et(e.prev,e,e.next)<0?et(e,t,e.next)>=0&&et(e,e.prev,t)>=0:et(e,t,e.prev)<0||et(e,e.next,t)<0}function at(e,t){var r=new ct(e.i,e.x,e.y),n=new ct(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function st(e,t,r,n){var i=new ct(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function lt(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function ct(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ht(e,t,r,n){for(var i=0,o=t,a=r-n;o<r;o+=n)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}Re.exports=Ue,Re.exports.default=Ue,Ue.deviation=function(e,t,r,n){var i=t&&t.length,o=i?t[0]*r:e.length,a=Math.abs(ht(e,0,o,r));if(i)for(var s=0,l=t.length;s<l;s++){var c=t[s]*r,h=s<l-1?t[s+1]*r:e.length;a-=Math.abs(ht(e,c,h,r))}var d=0;for(s=0;s<n.length;s+=3){var u=n[s]*r,p=n[s+1]*r,f=n[s+2]*r;d+=Math.abs((e[u]-e[f])*(e[p+1]-e[u+1])-(e[u]-e[p])*(e[f+1]-e[u+1]))}return 0===a&&0===d?0:Math.abs((d-a)/a)},Ue.flatten=function(e){for(var t=e[0][0].length,r={vertices:[],holes:[],dimensions:t},n=0,i=0;i<e.length;i++){for(var o=0;o<e[i].length;o++)for(var a=0;a<t;a++)r.vertices.push(e[i][o][a]);i>0&&(n+=e[i-1].length,r.holes.push(n))}return r};var dt=Pe(Re.exports);var ut=function(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n<i;)o[n]=e[n+t];return o};var pt=function(e,t){return e===t||e!=e&&t!=t},ft="object"==typeof Be&&Be&&Be.Object===Object&&Be,mt=ft,gt="object"==typeof self&&self&&self.Object===Object&&self,vt=mt||gt||Function("return this")(),yt=vt.Symbol,bt=yt,xt=Object.prototype,wt=xt.hasOwnProperty,Ct=xt.toString,Tt=bt?bt.toStringTag:void 0;var Mt=function(e){var t=wt.call(e,Tt),r=e[Tt];try{e[Tt]=void 0;var n=!0}catch(e){}var i=Ct.call(e);return n&&(t?e[Tt]=r:delete e[Tt]),i},_t=Object.prototype.toString;var Dt=Mt,Lt=function(e){return _t.call(e)},Nt=yt?yt.toStringTag:void 0;var It=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Nt&&Nt in Object(e)?Dt(e):Lt(e)};var kt=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},zt=It,jt=kt;var Ft=function(e){if(!jt(e))return!1;var t=zt(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t};var Ot=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991},St=Ft,Bt=Ot;var Pt=function(e){return null!=e&&Bt(e.length)&&!St(e)},Rt=/^(?:0|[1-9]\d*)$/;var Ut=function(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&Rt.test(e))&&e>-1&&e%1==0&&e<t},At=pt,Ht=Pt,Et=Ut,$t=kt;var Vt=/\s/;var Zt=function(e){for(var t=e.length;t--&&Vt.test(e.charAt(t)););return t},Wt=/^\s+/;var Yt=function(e){return null!=e&&"object"==typeof e},qt=It,Gt=Yt;var Qt=function(e){return e?e.slice(0,Zt(e)+1).replace(Wt,""):e},Jt=kt,Xt=function(e){return"symbol"==typeof e||Gt(e)&&"[object Symbol]"==qt(e)},Kt=/^[-+]0x[0-9a-f]+$/i,er=/^0b[01]+$/i,tr=/^0o[0-7]+$/i,rr=parseInt;var nr=function(e){if("number"==typeof e)return e;if(Xt(e))return NaN;if(Jt(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Jt(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Qt(e);var r=er.test(e);return r||tr.test(e)?rr(e.slice(2),r?2:8):Kt.test(e)?NaN:+e},ir=1/0;var or=function(e){return e?(e=nr(e))===ir||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0};var ar=ut,sr=function(e,t,r){if(!$t(r))return!1;var n=typeof t;return!!("number"==n?Ht(r)&&Et(t,r.length):"string"==n&&t in r)&&At(r[t],e)},lr=function(e){var t=or(e),r=t%1;return t==t?r?t-r:t:0},cr=Math.ceil,hr=Math.max;var dr=function(e,t,r){t=(r?sr(e,t,r):void 0===t)?1:hr(lr(t),0);var n=null==e?0:e.length;if(!n||t<1)return[];for(var i=0,o=0,a=Array(cr(n/t));i<n;)a[o++]=ar(e,i,i+=t);return a},ur=Pe(dr);const pr=(e,t,r)=>!(e<r.x||t<r.y||e>r.x+r.width||t>r.y+r.height),fr=(e,t,r)=>{const n=r.y1*r.x3-r.x1*r.y3+(r.y3-r.y1)*e+(r.x1-r.x3)*t,i=r.x1*r.y2-r.y1*r.x2+(r.y1-r.y2)*e+(r.x2-r.x1)*t;if(n<0!=i<0)return!1;const o=-r.y2*r.x3+r.y1*(r.x3-r.x2)+r.x1*(r.y2-r.y3)+r.x2*r.y3;return o<0?n<=0&&n+i>=o:n>=0&&n+i<=o},mr=(e,t)=>{if(pr(t.x1,t.y1,e))return!0;if(pr(t.x2,t.y2,e))return!0;if(pr(t.x3,t.y3,e))return!0;if(fr(e.x,e.y,t))return!0;if(fr(e.x+e.width,e.y,t))return!0;if(fr(e.x+e.width,e.y+e.height,t))return!0;if(fr(e.x,e.y+e.height,t))return!0;const r=[[[e.x,e.y],[e.x+e.width,e.y]],[[e.x+e.width,e.y],[e.x+e.width,e.y+e.height]],[[e.x,e.y+e.height],[e.x+e.width,e.y+e.height]],[[e.x,e.y],[e.x,e.y+e.height]]];return!![[[t.x1,t.y1],[t.x2,t.y2]],[[t.x1,t.y1],[t.x3,t.y3]]].some((e=>r.some((t=>(([e,t],[r,n])=>{const i=Oe(e,t,r),o=Oe(e,t,n),a=Oe(r,n,e),s=Oe(r,n,t);return i!==o&&a!==s||!(0!==i||!Se(e,r,t))||!(0!==o||!Se(e,n,t))||!(0!==a||!Se(r,e,n))||!(0!==s||!Se(r,t,n))})(t,e)))))},gr=(e,t)=>{const r=e.map((({x:e,y:t})=>[e,t]));return ur(dt(r.flat()),3).some((r=>mr(t,{x1:e[r[0]].x,y1:e[r[0]].y,x2:e[r[1]].x,y2:e[r[1]].y,x3:e[r[2]].x,y3:e[r[2]].y})))};function vr(e,t){const r=new Date(e);return r.setHours(23,59,59,999),t&&r.setUTCHours(23,59,59,999),r}const yr=(e,t,r)=>r?e.getUTCFullYear()===t.getUTCFullYear()&&e.getUTCMonth()===t.getUTCMonth()&&e.getUTCDate()===t.getUTCDate():e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),br=(e,t,r)=>r?e.getUTCFullYear()===t.getUTCFullYear():e.getFullYear()===t.getFullYear();function xr(e,t,r){return function(e,t,r){return r?new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t,e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds())):new Date(e.getFullYear(),e.getMonth(),e.getDate()+t,e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(e,-t,r)}function wr(e,t){return new Date(e.getTime()-60*t*60*1e3)}const Cr=b.createContext(null);function Tr(e,t=!1){const r=ye(e);return new n((e=>{const n=be(r,(({newValue:t})=>e.next(t)),t);return()=>n()}))}var Mr;!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.VehicleBreakIn=40]="VehicleBreakIn",e[e.DrugTrafficking=41]="DrugTrafficking",e[e.Assault=42]="Assault",e[e.PackageDelivery=43]="PackageDelivery",e[e.Uncategorized=999]="Uncategorized"}(Mr||(Mr={}));const _r=new Set(["LicensePlate","FaceDetection","Analytic","SpeedDetection","Temperature","PoS","GPS","DigitalInput","Loitering"]);class Dr{id;cameraId;type;raw;thumbnailUrl;thumbnailWidth=0;thumbnailHeight=0;detectedObjects;faces;instant;get startTime(){return new Date(this.raw.startTime)}get endTime(){return new Date(this.raw.endTime)}get isLive(){return!_r.has(this.type)&&+this.startTime==+this.endTime}get acknowledged(){return"sensorId"in this.raw&&!!this.raw.ackEventType}update=e=>{this.raw=e};constructor(e){if(xe(this,{startTime:ye,endTime:ye,acknowledged:ye,isLive:ye,raw:we.ref,update:Ce}),this.raw=e,this.id=e.id,this.type=e.eventType,this.cameraId=e.sensorId,("Analytic"===this.type||"FaceDetection"===this.type||"Loitering"===this.type)&&e.data)try{const t=JSON.parse(e.data);t.FoundObjects&&(this.detectedObjects=t.FoundObjects),t.Faces&&(this.type="FaceDetection",this.faces=t.Faces),t.ThumbnailSize&&(this.thumbnailWidth=t.ThumbnailSize.Width,this.thumbnailHeight=t.ThumbnailSize.Height),this.thumbnailUrl=t.ThumbnailUrl}catch{console.warn("invalid data",e.data),this.type="Motion"}this.instant=_r.has(this.type),this.detectedObjects||(this.detectedObjects=[])}}const Lr=(e,{locale:t,utc:r=!1,hour12:n=!1,seconds:i,year:o=!1,dayOfWeek:a=!1,day:s=!1})=>{const l={hour:"numeric",minute:"numeric",hour12:n||void 0,hourCycle:n?void 0:"h23"};return r&&(l.timeZone="UTC"),i&&(l.second="numeric"),o&&(l.year="numeric"),a&&(l.weekday="short"),s&&(l.day="numeric",l.month="short"),new Intl.DateTimeFormat(t,l).format(e)},Nr=(e,t)=>t?e.getUTCSeconds():e.getSeconds();function Ir(e,t,{locale:r,utc:n=!1,hour12:i=!1}={}){let o="",a="";const s=Boolean(Nr(e,n)||Nr(t,n)),l={from:!1,to:!1},c={from:!1,to:!1},h={from:!1,to:!1};return br(e,new Date,n)?yr(e,new Date,n)||(yr(e,t,n)?(h.from=!0,c.from=!0):(h.from=!0,c.from=!0,h.to=!0,c.to=!0)):(l.from=!0,h.from=!0,h.to=!0,l.to=!br(e,t,n)),o=Lr(e,{locale:r,utc:n,hour12:i,seconds:s,year:l.from,dayOfWeek:c.from,day:h.from}),+e==+t?o:(a=Lr(t,{locale:r,utc:n,hour12:i,seconds:s,year:l.to,dayOfWeek:c.to,day:h.to}),`${o} - ${a}`)}var kr,zr=vt["__core-js_shared__"],jr=(kr=/[^.]+$/.exec(zr&&zr.keys&&zr.keys.IE_PROTO||""))?"Symbol(src)_1."+kr:"";var Fr=function(e){return!!jr&&jr in e},Or=Function.prototype.toString;var Sr=function(e){if(null!=e){try{return Or.call(e)}catch(e){}try{return e+""}catch(e){}}return""},Br=Ft,Pr=Fr,Rr=kt,Ur=Sr,Ar=/^\[object .+?Constructor\]$/,Hr=Function.prototype,Er=Object.prototype,$r=Hr.toString,Vr=Er.hasOwnProperty,Zr=RegExp("^"+$r.call(Vr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var Wr=function(e){return!(!Rr(e)||Pr(e))&&(Br(e)?Zr:Ar).test(Ur(e))},Yr=function(e,t){return null==e?void 0:e[t]};var qr=function(e,t){var r=Yr(e,t);return Wr(r)?r:void 0},Gr=qr(Object,"create"),Qr=Gr;var Jr=function(){this.__data__=Qr?Qr(null):{},this.size=0};var Xr=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Kr=Gr,en=Object.prototype.hasOwnProperty;var tn=function(e){var t=this.__data__;if(Kr){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return en.call(t,e)?t[e]:void 0},rn=Gr,nn=Object.prototype.hasOwnProperty;var on=function(e){var t=this.__data__;return rn?void 0!==t[e]:nn.call(t,e)},an=Gr;var sn=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=an&&void 0===t?"__lodash_hash_undefined__":t,this},ln=Jr,cn=Xr,hn=tn,dn=on,un=sn;function pn(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])}}pn.prototype.clear=ln,pn.prototype.delete=cn,pn.prototype.get=hn,pn.prototype.has=dn,pn.prototype.set=un;var fn=pn;var mn=function(){this.__data__=[],this.size=0},gn=pt;var vn=function(e,t){for(var r=e.length;r--;)if(gn(e[r][0],t))return r;return-1},yn=vn,bn=Array.prototype.splice;var xn=function(e){var t=this.__data__,r=yn(t,e);return!(r<0)&&(r==t.length-1?t.pop():bn.call(t,r,1),--this.size,!0)},wn=vn;var Cn=function(e){var t=this.__data__,r=wn(t,e);return r<0?void 0:t[r][1]},Tn=vn;var Mn=vn;var _n=function(e,t){var r=this.__data__,n=Mn(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},Dn=mn,Ln=xn,Nn=Cn,In=function(e){return Tn(this.__data__,e)>-1},kn=_n;function zn(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])}}zn.prototype.clear=Dn,zn.prototype.delete=Ln,zn.prototype.get=Nn,zn.prototype.has=In,zn.prototype.set=kn;var jn=zn,Fn=qr(vt,"Map"),On=fn,Sn=jn,Bn=Fn;var Pn=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var Rn=function(e,t){var r=e.__data__;return Pn(t)?r["string"==typeof t?"string":"hash"]:r.map},Un=Rn;var An=Rn;var Hn=Rn;var En=Rn;var $n=function(e,t){var r=En(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},Vn=function(){this.size=0,this.__data__={hash:new On,map:new(Bn||Sn),string:new On}},Zn=function(e){var t=Un(this,e).delete(e);return this.size-=t?1:0,t},Wn=function(e){return An(this,e).get(e)},Yn=function(e){return Hn(this,e).has(e)},qn=$n;function Gn(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])}}Gn.prototype.clear=Vn,Gn.prototype.delete=Zn,Gn.prototype.get=Wn,Gn.prototype.has=Yn,Gn.prototype.set=qn;var Qn=Gn,Jn=Qn;function Xn(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],o=r.cache;if(o.has(i))return o.get(i);var a=e.apply(this,n);return r.cache=o.set(i,a)||o,a};return r.cache=new(Xn.Cache||Jn),r}Xn.Cache=Jn;const Kn=Pe(Xn)((()=>{const e=document.createElement("div");e.style.overflowY="scroll",e.style.position="absolute",e.style.top="-9999px",document.body.append(e);const t=e.offsetWidth;return e.remove(),t}));function ei(e,t,r=!0){if((e=Math.round(e/1e3))<60)return t("duration.ss",{seconds:e});const n=e%60;let i=(e-n)/60;if(i<60)return!n&&r?t("duration.mm",{minutes:i}):t("duration.mmss",{minutes:i,seconds:`${n}`.padStart(2,"0")});const o=Math.floor(i/60);if(i-=60*o,!n&&!i&&r)return t("duration.hh",{hours:o});const a=r?`${i}`:`${i}`.padStart(2,"0");return!n&&i&&r?t("duration.hhmm",{hours:o,minutes:a}):t("duration.hhmmss",{hours:o,minutes:a,seconds:`${n}`.padStart(2,"0")})}const ti=(e,t,r)=>Math.min(Math.max(e,t),r);class ri{api;disposables=[];initWith(e){this.api=e,this.afterInit&&this.afterInit()}dispose(){for(const e of this.disposables)e instanceof i?e.closed||e.unsubscribe():e()}}var ni=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n},ii=It,oi=Yt;var ai=function(e){return oi(e)&&"[object Arguments]"==ii(e)},si=Yt,li=Object.prototype,ci=li.hasOwnProperty,hi=li.propertyIsEnumerable,di=ai(function(){return arguments}())?ai:function(e){return si(e)&&ci.call(e,"callee")&&!hi.call(e,"callee")},ui=Array.isArray,pi={exports:{}};var fi=function(){return!1};!function(e,t){var r=vt,n=fi,i=t&&!t.nodeType&&t,o=i&&e&&!e.nodeType&&e,a=o&&o.exports===i?r.Buffer:void 0,s=(a?a.isBuffer:void 0)||n;e.exports=s}(pi,pi.exports);var mi=pi.exports,gi=It,vi=Ot,yi=Yt,bi={};bi["[object Float32Array]"]=bi["[object Float64Array]"]=bi["[object Int8Array]"]=bi["[object Int16Array]"]=bi["[object Int32Array]"]=bi["[object Uint8Array]"]=bi["[object Uint8ClampedArray]"]=bi["[object Uint16Array]"]=bi["[object Uint32Array]"]=!0,bi["[object Arguments]"]=bi["[object Array]"]=bi["[object ArrayBuffer]"]=bi["[object Boolean]"]=bi["[object DataView]"]=bi["[object Date]"]=bi["[object Error]"]=bi["[object Function]"]=bi["[object Map]"]=bi["[object Number]"]=bi["[object Object]"]=bi["[object RegExp]"]=bi["[object Set]"]=bi["[object String]"]=bi["[object WeakMap]"]=!1;var xi=function(e){return yi(e)&&vi(e.length)&&!!bi[gi(e)]};var wi=function(e){return function(t){return e(t)}},Ci={exports:{}};!function(e,t){var r=ft,n=t&&!t.nodeType&&t,i=n&&e&&!e.nodeType&&e,o=i&&i.exports===n&&r.process,a=function(){try{var e=i&&i.require&&i.require("util").types;return e||o&&o.binding&&o.binding("util")}catch(e){}}();e.exports=a}(Ci,Ci.exports);var Ti=Ci.exports,Mi=xi,_i=wi,Di=Ti&&Ti.isTypedArray,Li=Di?_i(Di):Mi,Ni=ni,Ii=di,ki=ui,zi=mi,ji=Ut,Fi=Li,Oi=Object.prototype.hasOwnProperty;var Si=function(e,t){var r=ki(e),n=!r&&Ii(e),i=!r&&!n&&zi(e),o=!r&&!n&&!i&&Fi(e),a=r||n||i||o,s=a?Ni(e.length,String):[],l=s.length;for(var c in e)!t&&!Oi.call(e,c)||a&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||ji(c,l))||s.push(c);return s},Bi=Object.prototype;var Pi=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Bi)};var Ri=function(e,t){return function(r){return e(t(r))}}(Object.keys,Object),Ui=Pi,Ai=Ri,Hi=Object.prototype.hasOwnProperty;var Ei=Si,$i=function(e){if(!Ui(e))return Ai(e);var t=[];for(var r in Object(e))Hi.call(e,r)&&"constructor"!=r&&t.push(r);return t},Vi=Pt;var Zi=function(e){return Vi(e)?Ei(e):$i(e)},Wi=jn;var Yi=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r};var qi=jn,Gi=Fn,Qi=Qn;var Ji=function(e,t){var r=this.__data__;if(r instanceof qi){var n=r.__data__;if(!Gi||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Qi(n)}return r.set(e,t),this.size=r.size,this},Xi=jn,Ki=function(){this.__data__=new Wi,this.size=0},eo=Yi,to=function(e){return this.__data__.get(e)},ro=function(e){return this.__data__.has(e)},no=Ji;function io(e){var t=this.__data__=new Xi(e);this.size=t.size}io.prototype.clear=Ki,io.prototype.delete=eo,io.prototype.get=to,io.prototype.has=ro,io.prototype.set=no;var oo=io;var ao=Qn,so=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},lo=function(e){return this.__data__.has(e)};function co(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new ao;++t<r;)this.add(e[t])}co.prototype.add=co.prototype.push=so,co.prototype.has=lo;var ho=co,uo=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},po=function(e,t){return e.has(t)};var fo=function(e,t,r,n,i,o){var a=1&r,s=e.length,l=t.length;if(s!=l&&!(a&&l>s))return!1;var c=o.get(e),h=o.get(t);if(c&&h)return c==t&&h==e;var d=-1,u=!0,p=2&r?new ho:void 0;for(o.set(e,t),o.set(t,e);++d<s;){var f=e[d],m=t[d];if(n)var g=a?n(m,f,d,t,e,o):n(f,m,d,e,t,o);if(void 0!==g){if(g)continue;u=!1;break}if(p){if(!uo(t,(function(e,t){if(!po(p,t)&&(f===e||i(f,e,r,n,o)))return p.push(t)}))){u=!1;break}}else if(f!==m&&!i(f,m,r,n,o)){u=!1;break}}return o.delete(e),o.delete(t),u};var mo=function(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r};var go=vt.Uint8Array,vo=pt,yo=fo,bo=mo,xo=function(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r},wo=yt?yt.prototype:void 0,Co=wo?wo.valueOf:void 0;var To=function(e,t,r,n,i,o,a){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||!o(new go(e),new go(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return vo(+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 s=bo;case"[object Set]":var l=1&n;if(s||(s=xo),e.size!=t.size&&!l)return!1;var c=a.get(e);if(c)return c==t;n|=2,a.set(e,t);var h=yo(s(e),s(t),n,i,o,a);return a.delete(e),h;case"[object Symbol]":if(Co)return Co.call(e)==Co.call(t)}return!1};var Mo=function(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e},_o=Mo,Do=ui;var Lo=function(e,t,r){var n=t(e);return Do(e)?n:_o(n,r(e))};var No=function(e,t){for(var r=-1,n=null==e?0:e.length,i=0,o=[];++r<n;){var a=e[r];t(a,r,e)&&(o[i++]=a)}return o},Io=function(){return[]},ko=Object.prototype.propertyIsEnumerable,zo=Object.getOwnPropertySymbols,jo=Lo,Fo=zo?function(e){return null==e?[]:(e=Object(e),No(zo(e),(function(t){return ko.call(e,t)})))}:Io,Oo=Zi;var So=function(e){return jo(e,Oo,Fo)},Bo=Object.prototype.hasOwnProperty;var Po=function(e,t,r,n,i,o){var a=1&r,s=So(e),l=s.length;if(l!=So(t).length&&!a)return!1;for(var c=l;c--;){var h=s[c];if(!(a?h in t:Bo.call(t,h)))return!1}var d=o.get(e),u=o.get(t);if(d&&u)return d==t&&u==e;var p=!0;o.set(e,t),o.set(t,e);for(var f=a;++c<l;){var m=e[h=s[c]],g=t[h];if(n)var v=a?n(g,m,h,t,e,o):n(m,g,h,e,t,o);if(!(void 0===v?m===g||i(m,g,r,n,o):v)){p=!1;break}f||(f="constructor"==h)}if(p&&!f){var y=e.constructor,b=t.constructor;y==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof y&&y instanceof y&&"function"==typeof b&&b instanceof b||(p=!1)}return o.delete(e),o.delete(t),p},Ro=qr(vt,"DataView"),Uo=Fn,Ao=qr(vt,"Promise"),Ho=qr(vt,"Set"),Eo=qr(vt,"WeakMap"),$o=It,Vo=Sr,Zo="[object Map]",Wo="[object Promise]",Yo="[object Set]",qo="[object WeakMap]",Go="[object DataView]",Qo=Vo(Ro),Jo=Vo(Uo),Xo=Vo(Ao),Ko=Vo(Ho),ea=Vo(Eo),ta=$o;(Ro&&ta(new Ro(new ArrayBuffer(1)))!=Go||Uo&&ta(new Uo)!=Zo||Ao&&ta(Ao.resolve())!=Wo||Ho&&ta(new Ho)!=Yo||Eo&&ta(new Eo)!=qo)&&(ta=function(e){var t=$o(e),r="[object Object]"==t?e.constructor:void 0,n=r?Vo(r):"";if(n)switch(n){case Qo:return Go;case Jo:return Zo;case Xo:return Wo;case Ko:return Yo;case ea:return qo}return t});var ra=oo,na=fo,ia=To,oa=Po,aa=ta,sa=ui,la=mi,ca=Li,ha="[object Arguments]",da="[object Array]",ua="[object Object]",pa=Object.prototype.hasOwnProperty;var fa=function(e,t,r,n,i,o){var a=sa(e),s=sa(t),l=a?da:aa(e),c=s?da:aa(t),h=(l=l==ha?ua:l)==ua,d=(c=c==ha?ua:c)==ua,u=l==c;if(u&&la(e)){if(!la(t))return!1;a=!0,h=!1}if(u&&!h)return o||(o=new ra),a||ca(e)?na(e,t,r,n,i,o):ia(e,t,l,r,n,i,o);if(!(1&r)){var p=h&&pa.call(e,"__wrapped__"),f=d&&pa.call(t,"__wrapped__");if(p||f){var m=p?e.value():e,g=f?t.value():t;return o||(o=new ra),i(m,g,r,n,o)}}return!!u&&(o||(o=new ra),oa(e,t,r,n,i,o))},ma=Yt;var ga=function e(t,r,n,i,o){return t===r||(null==t||null==r||!ma(t)&&!ma(r)?t!=t&&r!=r:fa(t,r,n,i,e,o))};class va extends ri{eventsStore;filters;fetcher;transformData;data=[];pendingData=[];liveUpdateMode="auto";disposables=[];pageInfo=null;loading=!1;loadMoreTrigger=0;retryTrigger=0;error=null;loadingInitiated=!1;get isLive(){return"DESC"===this.filters.sortDirection&&!this.filters.to}constructor(e,t,r,n=e=>[{data:e,objectIdx:-1}]){super(),this.eventsStore=e,this.filters=t,this.fetcher=r,this.transformData=n,xe(this,{data:we.ref,pendingData:we.ref,liveUpdateMode:we,setLiveUpdateMode:Ce,flushUpdates:Ce,pageInfo:we.ref,isLive:ye,loading:we,loadMoreTrigger:we,retryTrigger:we,error:we.ref,loadMore:Ce})}flushUpdates=()=>{this.data=[...this.pendingData,...this.data],this.pendingData=[]};setLiveUpdateMode=e=>{this.liveUpdateMode=e};load=()=>{this.loadingInitiated||(this.loadingInitiated=!0,this.initDataLoading(),this.initLiveUpdates())};reload=()=>{this.error&&(this.retryTrigger=+!this.retryTrigger)};loadMore=()=>{this.error=null,this.loadMoreTrigger=+!this.loadMoreTrigger};queryEvents=e=>this.fetcher(this.api,e).pipe(o((e=>e.success?t({events:e.resultItems,pageInfo:e.pageInfo}):a((()=>e.error)))),s((e=>(console.error(e),this.error=e,t({events:[],pageInfo:null})))));initDataLoading(){this.disposables.push(this.filters.updated$.pipe(l(null),c((e=>Tr((()=>this.retryTrigger),!0).pipe(h((()=>e))))),c((()=>(Te((()=>{this.loading=!0,this.pageInfo=null,this.error=null,this.data=[],this.pendingData=[]})),this.queryEvents())))).subscribe((({events:e,pageInfo:t})=>{Te((()=>{if(!t)return;const r=e.map(ya);this.isLive?this.data=this.uniquelyConcat(this.filters.apply(this.eventsStore.getEvents({cameraIds:this.filters.cameras,from:r[0]?.startTime??wr(new Date,1),to:null,probability:this.filters.probabilityThreshold??void 0})),r).flatMap(this.transformData):this.data=r.flatMap(this.transformData),this.eventsStore.add(r),this.pageInfo=t,this.loading=!1}))}))),this.disposables.push(this.filters.updated$.pipe(l(null),c((()=>Tr((()=>this.loadMoreTrigger)).pipe(d((()=>this.queryEvents(this.pageInfo?.nextPageToken))))))).subscribe((({events:e,pageInfo:t})=>{if(!t)return;const r=e.map(ya);this.eventsStore.add(r),Te((()=>{this.data=this.data.concat(r.flatMap(this.transformData)),this.pageInfo=t,this.loading=!1}))})))}initLiveUpdates(){this.disposables.push(Tr((()=>({liveUpdateMode:this.liveUpdateMode,isLive:this.isLive})),!0).pipe(c((({liveUpdateMode:e,isLive:t})=>t&&"auto"===e?Tr((()=>this.eventsStore.recentAdditions)):u))).subscribe((e=>{if(this.loading)return;if(!this.pageInfo&&this.error)return;const t=this.filters.apply(e.map((e=>this.eventsStore.eventsById.get(e))));t.length&&Te((()=>{this.data=[...t.flatMap(this.transformData),...this.data]}))}))),this.disposables.push(Tr((()=>({liveUpdateMode:this.liveUpdateMode,isLive:this.isLive})),!0).pipe(c((({liveUpdateMode:e,isLive:t})=>t&&"manual"===e?Tr((()=>this.eventsStore.recentAdditions)):(this.pendingData&&Te((()=>this.pendingData=[])),u)))).subscribe((e=>{if(!this.data.length)return;const t=this.filters.apply(e.map((e=>this.eventsStore.eventsById.get(e))));t.length&&Te((()=>{this.pendingData=[...t.flatMap(this.transformData),...this.pendingData]}))})))}uniquelyConcat(e,t){if(!e.length)return t.concat();if(!t.length)return e.concat();const r=e=>[e.id,e];return Array.from(new Map([...e.map(r),...t.map(r)]).values())}dispose(){for(const e of this.disposables)e instanceof i?e.closed||e.unsubscribe():e()}}function ya(e){return new Dr(e)}const ba=({forwardedRef:e,children:t,className:r,fullWidth:n,variant:i,type:o,title:a,placement:s,...l})=>{const c=O(r,"x-3deye-button",{"x-3deye-button--fullwidth":n},i?`x-3deye-button--${i}`:void 0),h=v("button",{ref:e,className:c,type:o||"button",...l,children:[t,l.disabled?null:g(S,{})]});return void 0===a?h:g(ks,{label:a,placement:s,disabled:!a,children:h})};var xa=x(((e,t)=>g(ba,{forwardedRef:t,...e})));var wa=e=>{const{className:t,children:r,...n}=e;return g("div",{className:O("x-3deye-button-group",t),...n,children:r})};function Ca(e){return x(((t,r)=>{const{size:n=24,color:i="currentColor",className:o,...a}=t,s=e.viewBox||"0 0 24 24",l=e.svg;return g("svg",{ref:r,preserveAspectRatio:"xMinYMin",className:O("icon",o),width:n,fill:i,viewBox:s,...a,children:l})}))}const Ta=Ca({viewBox:"0 0 24 24",svg:v(y,{children:[g("path",{d:"M5.88 4.12L13.76 12l-7.88 7.88L8 22l10-10L8 2z"}),g("path",{fill:"none",d:"M0 0h24v24H0z"})]})});Ta.displayName="ArrowForwardIcon";var Ma=Ta;const _a=Ca({viewBox:"0 0 24 24",svg:g(y,{children:g("path",{d:"M11.74 13.36L14.14 7.71L13.06 5.5H10.5V4H14L14.73 5.5H21.75L20.75 9H16.44L17.11 10.37C17.69 10.13 18.33 10 19 10C21.76 10 24 12.24 24 15C24 17.76 21.76 20 19 20C16.24 20 14 17.76 14 15C14 13.45 14.71 12.06 15.82 11.15L15 9.5L12.25 16H9.9C9.44 18.28 7.42 20 5 20C2.24 20 0 17.76 0 15C0 12.24 2.24 10 5 10C7.59 10 9.72 11.97 10 14.5H10.58L8.3 9H7.5C7.09 9 6.75 8.66 6.75 8.25C6.75 7.84 7.09 7.5 7.5 7.5H10.25C10.66 7.5 11 7.84 11 8.25C11 8.66 10.66 9 10.25 9H9.97L11.74 13.36M5 11.5C3.07 11.5 1.5 13.07 1.5 15C1.5 16.93 3.07 18.5 5 18.5C6.59 18.5 7.93 17.45 8.36 16H4V14.5H8.47C8.22 12.8 6.76 11.5 5 11.5M19 11.5C18.57 11.5 18.15 11.58 17.77 11.72L19.7 15.68L18.35 16.34L16.5 12.55C15.88 13.18 15.5 14.05 15.5 15C15.5 16.93 17.07 18.5 19 18.5C20.93 18.5 22.5 16.93 22.5 15C22.5 13.07 20.93 11.5 19 11.5Z"})})});_a.displayName="BicycleIcon";var Da=_a;const La=Ca({viewBox:"0 0 24 24",svg:v(y,{children:[g("path",{d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20 21c-1.39 0-2.78-.47-4-1.32-2.44 1.71-5.56 1.71-8 0C6.78 20.53 5.39 21 4 21H2v2h2c1.38 0 2.74-.35 4-.99 2.52 1.29 5.48 1.29 8 0 1.26.65 2.62.99 4 .99h2v-2h-2zM3.95 19H4c1.6 0 3.02-.88 4-2 .98 1.12 2.4 2 4 2s3.02-.88 4-2c.98 1.12 2.4 2 4 2h.05l1.89-6.68c.08-.26.06-.54-.06-.78s-.34-.42-.6-.5L20 10.62V6c0-1.1-.9-2-2-2h-3V1H9v3H6c-1.1 0-2 .9-2 2v4.62l-1.29.42c-.26.08-.48.26-.6.5s-.15.52-.06.78L3.95 19zM6 6h12v3.97L12 8 6 9.97V6z"})]})});La.displayName="BoatIcon";var Na=La;const Ia=Ca({viewBox:"0 0 24 24",svg:v("g",{children:[g("path",{d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M17 10.5V7c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-3.5l4 4v-11l-4 4z"})]})});Ia.displayName="CameraIcon";var ka=Ia;const za=Ca({viewBox:"0 0 24 24",svg:v(y,{children:[g("path",{d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M18.92 6.01C18.72 5.42 18.16 5 17.5 5h-11c-.66 0-1.21.42-1.42 1.01L3 12v8c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-1h12v1c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-8l-2.08-5.99zM6.5 16c-.83 0-1.5-.67-1.5-1.5S5.67 13 6.5 13s1.5.67 1.5 1.5S7.33 16 6.5 16zm11 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zM5 11l1.5-4.5h11L19 11H5z"})]})});za.displayName="CarIcon";var ja=za;const Fa=Ca({viewBox:"0 0 24 24",svg:v("g",{children:[g("path",{d:"M7.41 7.84L12 12.42l4.59-4.58L18 9.25l-6 6-6-6z"}),g("path",{d:"M0-.75h24v24H0z",fill:"none"})]})});Fa.displayName="ChevronDownIcon";var Oa=Fa;const Sa=Ca({viewBox:"0 0 24 24",svg:v("g",{children:[g("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}),g("path",{d:"M0 0h24v24H0z",fill:"none"})]})});Sa.displayName="ChevronRightIcon";var Ba=Sa;const Pa=Ca({viewBox:"0 0 24 24",svg:v("g",{children:[g("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),g("path",{d:"M0 0h24v24H0z",fill:"none"})]})});Pa.displayName="CloseIcon";var Ra=Pa;const Ua=Ca({viewBox:"0 0 24 24",svg:v("g",{children:[g("path",{d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M13.5 5.5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zM9.8 8.9L7 23h2.1l1.8-8 2.1 2v6h2v-7.5l-2.1-2 .6-3C14.8 12 16.8 13 19 13v-2c-1.9 0-3.5-1-4.3-2.4l-1-1.6c-.4-.6-1-1-1.7-1-.3 0-.5.1-.8.1L6 8.3V13h2V9.6l1.8-.7"})]})});Ua.displayName="DirectionsWalkIcon";var Aa=Ua;const Ha=Ca({viewBox:"0 0 24 24",svg:v(y,{children:[g("path",{fill:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"})]})});Ha.displayName="DoneIcon";var Ea=Ha;const $a=Ca({viewBox:"0 0 24 24",svg:v(y,{children:[g("path",{d:"M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"}),g("path",{d:"M0 0h24v24H0z",fill:"none"})]})});$a.displayName="FilterListIcon";var Va=$a;const Za=Ca({viewBox:"0 0 24 24",svg:g(y,{children:g("path",{d:"M19.48,12.35c-1.57-4.08-7.16-4.3-5.81-10.23c0.1-0.44-0.37-0.78-0.75-0.55C9.29,3.71,6.68,8,8.87,13.62 c0.18,0.46-0.36,0.89-0.75,0.59c-1.81-1.37-2-3.34-1.84-4.75c0.06-0.52-0.62-0.77-0.91-0.34C4.69,10.16,4,11.84,4,14.37 c0.38,5.6,5.11,7.32,6.81,7.54c2.43,0.31,5.06-0.14,6.95-1.87C19.84,18.11,20.6,15.03,19.48,12.35z M10.2,17.38 c1.44-0.35,2.18-1.39,2.38-2.31c0.33-1.43-0.96-2.83-0.09-5.09c0.33,1.87,3.27,3.04,3.27,5.08C15.84,17.59,13.1,19.76,10.2,17.38z"})})});Za.displayName="FireIcon";var Wa=Za;const Ya=Ca({viewBox:"0 0 24 24",svg:v("g",{children:[g("path",{d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.13 3.245a1.994 1.994 0 0 0-1.542.992l-5.491 9.53c-.55.954-.23 2.178.723 2.728l8.66 5c.953.55 2.174.216 2.724-.737l5.509-9.521c.335-.58.349-1.265.087-1.832L17.65 2.54z"})]})});Ya.displayName="LabelIcon";var qa=Ya;const Ga=Ca({viewBox:"0 0 24 24",svg:v(y,{children:[g("path",{d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H5Zm0 2h4v2h8V6h4v12H4Z"}),g("path",{d:"M9.923 10 8.43 12.433 10 15h-.8L8 13.036 6.8 15H6l1.602-2.616L6.136 10h.8l1.093 1.781L9.123 10Z"}),g("path",{d:"m13.709 10-1.492 2.433L13.787 15h-.8l-1.2-1.964L10.585 15h-.8l1.603-2.616L9.923 10h.799l1.094 1.781L12.91 10Z"}),g("path",{d:"m17.709 10-1.492 2.433L17.787 15h-.8l-1.2-1.964L14.585 15h-.8l1.603-2.616L13.923 10h.799l1.094 1.781L16.91 10Z"})]})});Ga.displayName="LicensePlateIcon";var Qa=Ga;const Ja=Ca({viewBox:"0 0 24 24",svg:g("path",{d:"M12.703 5.787a2.171 2.171 0 0 0-1.334.438c-.511.788-.8 1.614-1.217 3.267l-3.172.91a.499.499 0 0 0-.341.62l.13.455a.5.5 0 0 0 .62.343l2.328-.67-.377 1.31-3.96 3.827 1.53 6.693h3.78l2.67-10.14 1.29-4.51V7.01l-.32-.48a2.213 2.213 0 0 0-1.627-.743zM5.801 7.771c-.06.008-.12.05-.17.125l-.094.14c-.136.2-.16.57-.055.827l.631 1.535c.106.258.302.305.438.104l.094-.139c.135-.2.158-.57.052-.828l-.63-1.537C6 7.837 5.9 7.758 5.8 7.771zm4.648 7.338-1.5 6.022-.969-3.83 2.47-2.192zM10.756 5.6a2 2 0 0 0 2.33-1.6 2 2 0 0 0-1.6-2.33 2 2 0 0 0-2.33 1.6 2 2 0 0 0 1.6 2.33zM15.971 1.02h2.648v21.96h-2.648z"})});Ja.displayName="LoiteringIcon";var Xa=Ja;const Ka=Ca({viewBox:"0 0 24 24",svg:g("path",{d:"M17,6h-2V3c0-0.55-0.45-1-1-1h-4C9.45,2,9,2.45,9,3v3H7C5.9,6,5,6.9,5,8v11c0,1.1,0.9,2,2,2c0,0.55,0.45,1,1,1 c0.55,0,1-0.45,1-1h6c0,0.55,0.45,1,1,1c0.55,0,1-0.45,1-1c1.1,0,2-0.9,2-2V8C19,6.9,18.1,6,17,6z M9.5,18H8V9h1.5V18z M12.75,18 h-1.5V9h1.5V18z M13.5,6h-3V3.5h3V6z M16,18h-1.5V9H16V18z"})});Ka.displayName="LuggageIcon";var es=Ka;const ts=Ca({viewBox:"0 0 24 24",svg:v(y,{children:[g("path",{d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"4.5",cy:"9.5",r:"2.5"}),g("circle",{cx:"9",cy:"5.5",r:"2.5"}),g("circle",{cx:"15",cy:"5.5",r:"2.5"}),g("circle",{cx:"19.5",cy:"9.5",r:"2.5"}),g("path",{d:"M17.34 14.86c-.87-1.02-1.6-1.89-2.48-2.91-.46-.54-1.05-1.08-1.75-1.32-.11-.04-.22-.07-.33-.09-.25-.04-.52-.04-.78-.04s-.53 0-.79.05c-.11.02-.22.05-.33.09-.7.24-1.28.78-1.75 1.32-.87 1.02-1.6 1.89-2.48 2.91-1.31 1.31-2.92 2.76-2.62 4.79.29 1.02 1.02 2.03 2.33 2.32.73.15 3.06-.44 5.54-.44h.18c2.48 0 4.81.58 5.54.44 1.31-.29 2.04-1.31 2.33-2.32.31-2.04-1.3-3.49-2.61-4.8z"})]})});ts.displayName="PetsIcon";var rs=ts;const ns=Ca({viewBox:"0 0 24 24",svg:v(y,{children:[g("path",{d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 13V5c0-1.66-1.34-3-3-3S9 3.34 9 5v8c-1.21.91-2 2.37-2 4 0 2.76 2.24 5 5 5s5-2.24 5-5c0-1.63-.79-3.09-2-4zm-4-8c0-.55.45-1 1-1s1 .45 1 1h-1v1h1v2h-1v1h1v2h-2V5z"})]})});ns.displayName="ThermostatIcon";var is=ns;const os=[{color:"#f44336",name:"red",highlightColor:"#ffcdd2"},{color:"#4caf50",name:"green",highlightColor:"#c8e6c9"},{color:"#2196f3",name:"blue",highlightColor:"#bbdefb"},{color:"#ffeb3b",name:"yellow",highlightColor:"#f57f17"},{color:"#000",name:"black",highlightColor:"#fff"},{color:"#fff",name:"white",highlightColor:"#000"},{color:"#9e9e9e",name:"dimgrey",highlightColor:"#f5f5f5"}];new Map(os.map((({color:e,name:t})=>[t,e])));const as=F((({value:e,clear:t,toggle:r})=>v("div",{className:"color-selector",children:[g("div",{style:{textTransform:"uppercase"},children:Fe.t("color")}),v("div",{className:"color-selector__items",children:[os.map((({color:t,highlightColor:n,name:i})=>g("button",{type:"button",className:O("color-selector__item",{selected:e.has(i)}),style:{backgroundColor:t},onClick:r.bind(null,i),children:g(Ea,{color:n,size:20})},i))),g(xa,{className:"color-selector__clear",disabled:!e.size,onClick:t,children:g(Ra,{size:20})})]})]})));function ss(e,t,r){return t||r?r?ne(t?[re([e,t]),r]:[r,e]):re([t,e]):new Date(e)}as.displayName="ColorSelector";const ls=ie((e=>new Intl.DateTimeFormat(e,{month:"long",year:"numeric"}))),cs=ie((e=>new Intl.DateTimeFormat(e,{weekday:"short"}))),hs=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),ds=e=>new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())),us=w((function({onChange:e,date:t,minDate:r,maxDate:n,utc:i,startOfWeek:o="sunday"}){const[a]=C((()=>({current:i?ds(new Date):hs(new Date)}))),s=t??a.current,l=T(+s),c=C(0),[,h]=c;M((()=>{l.current=+s,h(0)}),[s?.getTime()]);const d=l.current!==+s?0:c[0],u=i?s.getUTCFullYear():s.getFullYear(),p=(i?s.getUTCMonth():s.getMonth())+d,f=i?new Date(Date.UTC(u,p)):new Date(u,p),m=i?(e=>new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+1,0)).getUTCDate())(f):(e=>new Date(e.getFullYear(),e.getMonth()+1,0).getDate())(f),y=(i?f.getUTCDay():f.getDay())||("monday"===o?7:0),b=y-("monday"===o?1:0),x=i?new Date(Date.UTC(u,p,1-b)):new Date(u,p,1-b),w=t?te(i?new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())):new Date(s.getFullYear(),s.getMonth(),s.getDate()),x):-1,_=r?te(r,x):Number.NEGATIVE_INFINITY,D=n?te(n,x):Number.POSITIVE_INFINITY,L=te(a.current,x);return g("div",{children:v("div",{style:{display:"flex",flexDirection:"column",fontSize:"0.875rem"},children:[v("div",{style:{fontWeight:500,height:"3rem",fontSize:"1.125rem",display:"flex",alignItems:"center"},children:[ls(Fe.language).format(f),g(xa,{style:{marginLeft:"auto"},className:"x-3deye-button--icon x-3deye-datepicker__button--previous-month",disabled:_>=b,onClick:()=>h(d-1),children:g(Ma,{size:16,style:{scale:"-1 1"}})}),g(xa,{className:"x-3deye-button--icon x-3deye-datepicker__button--next-month",disabled:D<b+m,onClick:()=>h(d+1),children:g(Ma,{size:16})})]}),v("div",{style:{flex:1,display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:"0.25rem",placeItems:"center"},children:[Array.from({length:7}).map(((e,t)=>g("div",{style:{color:"oklch(0.7 0 0)"},children:cs(Fe.language).format(new Date(u,p,("monday"===o?2:1)-y+t)).substring(0,2)},t))),Array.from({length:42}).map(((t,o)=>{const a=i?new Date(Date.UTC(u,p,o-b+1)):new Date(u,p,o-b+1),l=o<_||o>D;return g("div",{className:O("x-3deye-datepicker__day",{"x-3deye-datepicker__day--today":o===L,"x-3deye-datepicker__day--disabled":l,"x-3deye-datepicker__day--previous-month":o<b,"x-3deye-datepicker__day--next-month":o>=b+m,"x-3deye-datepicker__day--selected":o===w}),onClick:l?void 0:()=>{if(i){const t=new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds(),s.getUTCMilliseconds()));return e(ss(t,r,n))}const t=new Date(a.getFullYear(),a.getMonth(),a.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds());return e(ss(t,r,n))},children:i?a.getUTCDate():a.getDate()},o)}))]})]})})})),ps=Array.from({length:3}),fs=e=>g("svg",{viewBox:"0 0 100 100",...e,children:ps.map(((e,t)=>g("circle",{fill:"currentColor",stroke:"none",cx:20*t+6,cy:"50",r:"6",children:g("animate",{attributeName:"opacity",dur:"1s",values:"0;1;0",repeatCount:"indefinite",begin:.1*(t+1)})},t)))}),ms=_({reportError:(e,t)=>{}});class gs extends D{static contextType=ms;state={hasError:!1};componentDidCatch(e,t){this.setState({hasError:!0}),this.context?.reportError(e,t),console.error(e),console.log(t)}render(){if(!this.state.hasError)return this.props.children;const{style:e,children:t,...r}=this.props;return v("div",{style:{flex:1,padding:10,display:"grid",placeItems:"center",alignContent:"center",textAlign:"center",...this.props.style},...r,children:[g("h1",{children:"Oops. Something went wrong"}),g("div",{children:"We've been notified about this problem"}),g(xa,{onClick:()=>this.setState({hasError:!1}),children:"retry"})]})}}const vs=b.createContext(null),ys=b.forwardRef((({className:e,children:t,title:r,...n},i)=>{const o=b.useContext(vs);if(!o)return;const{refs:a,isNested:s,isOpen:l,hasFocusInside:c,item:h,parent:d,setHasFocusInside:u,getReferenceProps:p}=o;return v(xa,{ref:B([a.setReference,h.ref,i]),tabIndex:s?d?.activeIndex===h.index?0:-1:void 0,role:s?"menuitem":void 0,"data-open":l?"":void 0,"data-nested":s?"":void 0,"data-focus-inside":c?"":void 0,className:O(e,{"menu-item":s,"menu-button":!s}),title:l?null:r,...p(d?.getItemProps({...n,onFocus(e){n.onFocus?.(e),u(!1),d.setHasFocusInside(!0)}})),children:[t,s&&g(Ba,{style:{marginLeft:"auto"},"aria-hidden":!0,size:20})]})}));ys.displayName="MenuButton";const bs=b.forwardRef((({label:e,disabled:t,className:r,children:n,...i},o)=>{const a=b.useContext(vs),s=P({label:t?null:e}),l=R();if(!a)return null;const c=s.index===a.activeIndex;return g(xa,{...i,ref:B([s.ref,o]),type:"button",role:"menuitem",className:O(r,"menu-item"),tabIndex:c?0:-1,disabled:t,...a.getItemProps({onClick(e){i.onClick?.(e),l?.events.emit("click")},onFocus(e){i.onFocus?.(e),a.setHasFocusInside(!0)}}),children:e||n})}));bs.displayName="MenuItem";const xs=({opened:e,onOpenChange:t,children:r,target:n,placement:i,className:o,style:a,autoDismiss:s=!0,initialFocus:l,withArrow:c=!1})=>{const h=T(null),{x:d,y:u,refs:p,strategy:f,context:m,middlewareData:b,placement:x,update:w}=U({open:e,onOpenChange:t,middleware:[A(5),H(),E(),$({element:h})],placement:i,whileElementsMounted:(e,t,r)=>V(e,t,(()=>{0!==m.elements.domReference?.getBoundingClientRect().width?r():m.onOpenChange(!1)}),{animationFrame:!0})}),{getReferenceProps:C,getFloatingProps:M}=Z([W(m),Y(m,{ancestorScroll:!0,enabled:s})]),_=L((e=>{h.current=e,w()}),[w]),D={top:"bottom",right:"left",bottom:"top",left:"right"}[x?.split("-")[0]??"top"]||"top",N=v("div",{...M({className:O("x-3deye-popover-container",o),ref:p.setFloating,style:{...a,position:f,top:u??0,left:d??0}}),children:[c&&g(Is,{ref:_,width:24,height:8,placement:D,style:{position:"absolute",left:b.arrow?.x,top:b.arrow?.y,[D]:-7}}),r]});return v(y,{children:[I(n,C({ref:p.setReference,...n.props})),v(q,{id:"x-3deye-floating-ui-root",children:[s&&e&&g(G,{context:m,modal:!1,order:["reference","content"],returnFocus:!1,initialFocus:l,children:N}),!s&&e&&N]})]})},ws=({size:e=48})=>v("svg",{role:"graphics-symbol",width:e,height:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100",preserveAspectRatio:"xMidYMid",children:[g("rect",{x:"0",y:"0",width:"100",height:"100",fill:"none",className:"bk"}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(0 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(30 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.08333333333333333s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(60 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.16666666666666666s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(90 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.25s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(120 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.3333333333333333s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(150 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.4166666666666667s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(180 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.5s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(210 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.5833333333333334s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(240 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.6666666666666666s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(270 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.75s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(300 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.8333333333333334s",repeatCount:"indefinite"})}),g("rect",{x:"46.5",y:"38",width:"7",height:"24",rx:"5",ry:"5",fill:"currentColor",transform:"rotate(330 50 50) translate(0 -30)",children:g("animate",{attributeName:"opacity",from:"1",to:"0",dur:"1s",begin:"0.9166666666666666s",repeatCount:"indefinite"})})]});ws.displayName="Preloader";const Cs=x((({active:e,children:t,className:r,style:n,...i},o)=>{const a=Q();return g("div",{ref:o,id:a,className:O("x-3deye-select-option",r),role:"option","aria-selected":e,style:{background:e?"rgb(213, 237, 255)":"none",...n},...i,children:t})})),Ts=({className:e,style:t,children:r,onCloseClick:n,...i})=>v("div",{className:O("x-3deye-select-value",e),style:t,...i,children:[r,g("button",{className:"close-button",type:"button",onClick:n,children:g(Ra,{size:12})})]}),Ms=(e,t,r)=>g(Ts,{...r,children:t.label},e),_s=(e,t,r,n)=>g(Cs,{active:r,...n,children:t.label},e),Ds=({options:e,values:t,inputId:r,inputValue:n,onMenuClose:i,onChange:o,onInputChange:a,onKeyDown:s,isLoading:l,placeholder:c,hideDropdownIcon:h,renderOption:d=_s,renderValue:u=Ms,keyExtractor:p=e=>e.value})=>{const[f,m]=C(!1),[b,x]=C(""),w=n??b,[_,D]=C(null),L=T([]),N=T(null),{refs:I,floatingStyles:k,context:z}=U({whileElementsMounted:V,open:f,onOpenChange:m,middleware:[H({padding:10}),A({mainAxis:5}),J({apply({rects:e,availableHeight:t,elements:r}){Object.assign(r.floating.style,{width:`${e.reference.width}px`,maxHeight:`${Math.min(300,t)}px`})},padding:10})]}),j=W(z,{role:"listbox"}),F=Y(z),S=X(z,{listRef:L,activeIndex:_,onNavigate:D,virtual:!0,loop:!0}),{getReferenceProps:B,getFloatingProps:P,getItemProps:R}=Z([j,F,S]);const E=e?.filter((e=>{const r=p(e);return!t.some((e=>p(e)===r))&&e.label.toLowerCase().includes(w.toLowerCase().trim())}));return M((()=>{f||(x(""),i?.())}),[f,i]),v(y,{children:[v("div",{className:O("x-3deye-select-container",{"x-3deye-select-container--open":f}),ref:I.setReference,onPointerDownCapture:e=>{const t=e.target;"BUTTON"!==t.tagName&&null===t.closest("button")&&(e.preventDefault(),e.stopPropagation(),m((e=>!e)),N.current?.focus())},children:[v("div",{className:"x-3deye-multi-select-body",children:[t.map((e=>u(p(e),e,{onCloseClick:r=>{r.stopPropagation(),o(t.filter((t=>t!==e)),{action:"remove",open:f,option:e}),N.current?.focus()}}))),v("div",{className:"x-3deye-select","data-value":w,children:[t.length||w?null:g("div",{className:"x-3deye-select-placeholder",children:c}),g("input",{ref:N,size:3,id:r||void 0,...B({onChange:function(e){const t=e.target.value;x(t),a?.(t),t?(m(!0),D(0)):m(!1)},value:w,placeholder:"","aria-autocomplete":"list",onKeyDown(e){if(s?.(e),"Enter"===e.key&&null!=_&&E?.[_])return x(""),o(t.concat(E[_]),{open:f,action:"add",option:E[_]}),void D(Math.max(_-1,0));if("Backspace"!==e.key);else if(""===w&&t.length){const e=t.at(-1);if(!e)return;o(t.slice(0,t.length-1),{open:f,action:"remove",option:e})}}})})]})]}),v("div",{className:"x-3deye-select-indicators",style:{marginLeft:"auto",display:"flex",paddingRight:8,alignItems:"center"},children:[l?g(fs,{style:{width:24}}):t.length?g(xa,{className:"x-3deye-button--icon",onClick:()=>{o([],{open:f,action:"clear"})},children:g(Ra,{size:16})}):null,h?null:g(Oa,{size:24})]})]}),g(q,{id:"x-3deye-floating-ui-root",children:f&&E?g(G,{context:z,initialFocus:-1,visuallyHiddenDismiss:!0,children:g("div",{className:"x-3deye-select-menu",...P({ref:I.setFloating,style:{...k,color:"black",overflowY:"auto"}}),children:E.length?E.map(((e,r)=>d(p(e),e,_===r,{...R({ref(e){L.current[r]=e},onClick(r){r.stopPropagation(),x(""),o([...t,e],{open:f,action:"add",option:e}),N.current?.focus()}})}))):g("div",{style:{padding:10,textAlign:"center",fontSize:"0.875rem",color:"#666"},children:l?Fe.t("select.loading"):Fe.t("select.noOptions")})})}):null})]})},Ls=e=>Math.round(e),Ns=x((({value:e,onChange:t,onChangeComplete:r,orientation:n="horizontal",disabled:i=!1,labelFormat:o=e=>`${e}`,style:a},s)=>{const l=T(null),c=T(null),[h,d]=C(!1),[u,p]=C(e);M((()=>{if(!h)return;const e=l.current;if(!e)return;let i=0,o=0;const a=e.getBoundingClientRect();if(!a||!a.width||!a.height)return void d(!1);const s=({clientX:e,clientY:r})=>{if(!c.current)return;let s=0;"horizontal"===n?(i=ti(e-a.x,0,a.width),s=i/a.width*100,c.current.style.transform=`translateX(${i}px)`):(o=a.height-ti(r-a.y,0,a.height),s=o/a.height*100,c.current.style.transform=`translateY(${-o}px)`),p(s),t?.(Ls(s))},u=({clientX:e,clientY:i})=>{if(d(!1),!c.current)return;const o="horizontal"===n?ti(e-a.x,0,a.width)/a.width*100:100*(1-ti(i-a.y,0,a.height)/a.height);c.current.style.transform="",p(o),t?.(Ls(o)),r?.(Ls(o))},f=()=>{if(d(!1),!c.current)return;const e="horizontal"===n?i/a.width*100:o/a.height*100;c.current.style.transform="",t?.(Ls(e)),r?.(Ls(e))};return document.addEventListener("pointercancel",f),document.addEventListener("pointermove",s),document.addEventListener("pointerup",u),()=>{document.removeEventListener("pointercancel",f),document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",u)}}),[h,n,t,r]);const f=L((e=>{if(!l.current||i)return;const{clientX:r,clientY:o}=e;e.preventDefault(),d(!0);const a=l.current.getBoundingClientRect();if(!a)return;if(!c.current)return;let s=0;if("horizontal"===n){const e=ti(r-a.x,0,a.width);s=e/a.width*100,c.current.style.transform=`translateX(${e}px)`}else{const e=a.height-ti(o-a.y,0,a.height);s=e/a.height*100,c.current.style.transform=`translateY(${-e}px)`}p(s),t?.(Ls(s))}),[i]),m=L((n=>{if(i)return;let o=null;"ArrowLeft"===n.code?o=Math.max(e-1,0):"ArrowRight"===n.code?o=Math.min(e+1,100):"ArrowDown"===n.code?o=Math.max(e-1,0):"ArrowUp"===n.code&&(o=Math.min(e+1,100)),null!==o&&(n.stopPropagation(),n.preventDefault(),t?.(o),r?.(o))}),[e,t,r,i]);return v("div",{ref:ee(s,l),tabIndex:0,onKeyDown:m,className:O("x-3deye-slider",n,{disabled:i}),onPointerDown:f,style:a,children:[g("div",{className:"x-3deye-slider__track",children:g("div",{className:"x-3deye-slider__bar",style:{width:"horizontal"===n?`${h?u:e}%`:void 0,height:"vertical"===n?`${h?u:e}%`:void 0}})}),g("div",{ref:c,className:O("x-3deye-slider__thumb",{active:h}),style:{touchAction:"none",userSelect:"none",position:"absolute",left:"horizontal"===n?h?0:`${e}%`:"auto",bottom:"vertical"===n?h?0:`${e}%`:"auto"},children:null!==o&&g("div",{className:"x-3deye-slider__label "+(h?"open":""),children:o(h?Ls(u):e)})})]})}));Ns.displayName="Slider";const Is=b.forwardRef((function({width:e,height:t,placement:r="top",style:n},i){const o=[0,"top"===r?t:0],a=[e,o[1]],s=[e/2,t-o[1]],l=[e/4,t*("top"===r?3:1)/4],c=[.325*e,t-o[1]],h=[e-c[0],c[1]],d=[e-l[0],l[1]],u=e=>e.join(","),p=`M ${u(o)} C ${u(l)} ${u(c)} ${u(s)} ${u(h)} ${u(d)} ${u(a)}`;return v("svg",{ref:i,role:"graphics-symbol",className:"tip",style:n,width:e,height:t,fill:"var(--tip-background, #fff)",children:[g("path",{className:"tip-body",d:`${p} Z`}),g("path",{className:"tip-border",d:p,stroke:"var(--tip-border, transparent)",strokeWidth:1})]})}));var ks=({children:e,label:t,placement:r="bottom",disabled:n})=>{const[i,o]=C(!1),{x:a,y:s,refs:l,strategy:c,context:h}=U({placement:r,open:i,onOpenChange:o,middleware:[A(5),H(),E({padding:8})],whileElementsMounted:(e,t,r)=>V(e,t,r,{animationFrame:!0})}),{getReferenceProps:d,getFloatingProps:u}=Z([K(h,{enabled:!n}),W(h,{role:"tooltip"}),Y(h,{referencePress:!0})]);return v(y,{children:[I(e,d({ref:ee(l.setReference,e.ref),...e.props})),g(q,{id:"x-3deye-floating-ui-root",children:i&&g("div",{...u({ref:l.setFloating,className:"x-3deye-tooltip",style:{position:c,top:s??0,left:a??0}}),children:t})})]})};function zs({count:e,overscan:t=1,itemSize:r,horizontal:n=!1,spacing:i=0}){const[o,a]=C(),[s,l]=C(0),[c,h]=C({width:0,height:0}),d=L((e=>{a(e||void 0)}),[]);M((()=>{if(!o)return;const e=()=>{l(n?o.scrollLeft:o.scrollTop)};return o.addEventListener("scroll",e,{passive:!0,capture:!0}),()=>{o.removeEventListener("scroll",e)}}),[o,n]),M((()=>{if(!o)return;const e=new ResizeObserver((e=>{for(const t of e)t.contentBoxSize?h({width:t.contentBoxSize[0].inlineSize,height:t.contentBoxSize[0].blockSize}):h({width:t.contentRect.width,height:t.contentRect.height})}));return e.observe(o),()=>{e.disconnect()}}),[o]),M((()=>{if(!o)return;const e=o[n?"scrollLeft":"scrollTop"];e!==s&&l(e)}));return{parentRef:d,getItems:()=>{const a=[];if(!o)return a;const{height:l,width:c}=o.getBoundingClientRect(),h=Math.max(0,Math.floor(s/(r+i))-t),d=Math.ceil((n?c:l)/(r+i))+2*t;for(let t=h;t<Math.min(e,h+d);t++)a.push({idx:t,start:t*(r+i),size:r});return a},getTotalSize:()=>r*e+Math.max(e-1,0)*i}}const js=F((({getter:e,setter:t})=>{const[r,n]=C(0),i=T(null),o=Math.floor(100*e());return M((()=>Me(e,(e=>{n(Math.floor(100*e))}),{fireImmediately:!0})),[e]),v("div",{ref:i,style:{paddingLeft:8,paddingRight:8,marginTop:5,marginBottom:10},children:[v("div",{style:{display:"flex",justifyContent:"space-between"},children:[g("div",{style:{textTransform:"uppercase"},children:Fe.t("confidence")}),v("div",{style:{fontSize:"1.1em"},children:[o,"%"]})]}),g("div",{style:{padding:"0 10px"},children:g(Ns,{value:r,labelFormat:e=>`${e}%`,onChangeComplete:e=>{t(e/100)}})})]})}));js.displayName="ProbabilitySlider";const Fs=F((({from:e,to:t})=>{const{account:{preferences:{utc:r,hour12:n}}}=k(Cr);return g(y,{children:Ir(e,t,{locale:Fe.language,utc:r,hour12:n})})}));Fs.displayName="DisplayPeriod";class Os{from=null;to=null;probabilityThreshold=.5;cameras=[];detectedObjects=[];colors=new Set;regions=null;eventTypes=[];sortDirection="DESC";updated$=new p;get regionsWkt(){return this.regions?this.regions.map((e=>this.regionToWktPolygon(e))):[]}constructor(){xe(this,{from:we,to:we,probabilityThreshold:we,cameras:we.struct,detectedObjects:we.struct,regions:we.ref,eventTypes:we.struct,sortDirection:we,colors:we.ref,filterJson:ye}),Me((()=>({from:this.from?+this.from:void 0,to:this.to?+this.to:void 0,sortDirection:this.sortDirection,filter:this.filterJson,cameraFilters:this.cameras,eventTypes:this.eventTypes,regions:this.regions})),(()=>this.updated$.next(null)))}apply(e){let t=e;const{from:r,to:n}=this;if(r&&(t=t.filter((e=>e.startTime>=r))),n&&(t=t.filter((e=>e.startTime<=n))),this.cameras.length&&(t=t.filter((e=>this.cameras.includes(e.cameraId)))),this.eventTypes.length){const e=this.eventTypes.map((e=>Mr[e]));t=t.filter((t=>e.includes(t.type)))}return this.detectedObjects.length&&(t=t.filter((e=>e.detectedObjects.some((e=>{const{probabilityThreshold:t}=this;return!(null!==t&&e.Probability<t)&&(this.colors.size?this.detectedObjects.includes(e.Type)&&"Colors"in e&&e.Colors?.some((e=>this.colors.has(e.Color))):this.detectedObjects.includes(e.Type))}))))),!this.detectedObjects.length&&this.colors.size&&(t=t.filter((e=>e.detectedObjects.some((e=>{const{probabilityThreshold:t}=this;return!(null!==t&&e.Probability<t)&&("Colors"in e&&e.Colors?.some((e=>this.colors.has(e.Color))))}))))),t}get filterJson(){const{probabilityThreshold:e}=this;if(null===e)return null;const t={And:[]};return this.detectedObjects.length&&t.And.push({Or:this.detectedObjects.map((e=>({Type:e})))}),this.colors.size&&t.And.push({Or:[...this.colors].map((e=>({ObjectColors:[e]})))}),t.And.push({Or:[{Probability:e}]}),JSON.stringify(t)}regionToWktPolygon(e){return e.length?"POLYGON (("+e.concat(e[0]).map((({x:e,y:t})=>`${e} ${t}`)).join(", ")+"))":"POLYGON (())"}}const Ss=Ca({viewBox:"0 96 960 960",svg:g(y,{children:g("path",{d:"m513 988-57-18 14-42q3-9 4-17.6 1-8.6 1-17.2 0-17.2-3.912-32.473Q467.176 845.455 456 828q-15.938-26.26-22.969-48.63Q426 757 425 727.844q0-11.844 2.5-27.344Q430 685 434 672l13-42 57 18-14 42q-3 9-4 19t-1 19q0 19 4 32t15 30q15.97 25.948 23.485 49.974Q535 864 535 892.933q0 13.067-2.5 26.567T526 946l-13 42Zm-176 0-57-18 14-42q3-9 4-17.049t1-17.707q0-18.244-4-34.744T280 827q-15.03-21.658-23.015-46.612Q249 755.433 249 728.125 249 714 251 700t7-28l13-42 57 18-14 42q-3 9.771-4 20.086-1 10.314-1 17.914 0 21.065 5.5 36.033Q320 779 328 791q15 22 23 48.5t8 52.802Q359 905 356.5 919t-6.5 27l-13 42Zm348 0-57-18 14-42q3-9 4-17.6 1-8.6 1-17.2 0-17.2-4.5-34.7Q638 841 628 827q-15-21-23-47t-8-52.047q0-13.953 2-27.794 2-13.841 7-28.159l13-42 57 18-14 42q-4 11-4.5 19.438-.5 8.437-.5 18.562 0 18.491 4.471 32.632Q665.941 774.772 676 790q16 23 23.5 48.887 7.5 25.886 7.5 53.69 0 13.423-2.5 26.923Q702 933 698 946l-13 42ZM180 336h600v-60H180v60Zm139 120h322l18-60H301l18 60Zm0 60q-19.5 0-35.25-11.625T262 474l-25-78h-57q-24.75 0-42.375-17.625T120 336V216h720v120q0 25-17.625 42.5T780 396h-57l-30 81q-6.932 17.25-22.338 28.125Q655.257 516 636 516H319ZM180 336v-60 60Z"})})});Ss.displayName="DetectorSmokeIcon";var Bs=Ss;const Ps=({data:e})=>{const t=16;return"eventType"===e.type&&e.value===Mr.Loitering?g(Xa,{size:16}):"camera"===e.type?g(ka,{size:t}):"Luggage"===e.value?g(es,{size:t}):"Car"===e.value?g(ja,{size:t}):"Person"===e.value?g(Aa,{size:t}):"Bicycle"===e.value?g(Da,{size:t}):"Boat"===e.value?g(Na,{size:t}):"Animal"===e.value?g(rs,{size:t}):"LicensePlate"===e.value?g(Qa,{size:t}):"Smoke"===e.value?g(Bs,{size:t}):"Fire"===e.value?g(Wa,{size:t}):g(qa,{size:t})},Rs=(e,t,r,n)=>v(Cs,{style:{color:"detectedObject"===t.type?t.color:"black",display:"camera"===t.type?"flex":"inline-flex",gap:4},...n,active:r,children:["camera"!==t.type?g(Ps,{data:t}):null,t.label]},e),Us=(e,t,r)=>v(Ts,{style:{"--color":"color"in t&&t.color?t.color:void 0,color:"color"in t&&t.color?"white":void 0,"--background-color":"color"in t&&t.color?"rgba(255, 255, 255, 0.7)":void 0},...r,children:[g(Ps,{data:t}),t.label]},e),As=F((({camerasOnly:e,store:t})=>{const{cameras:r,eventSchema:n}=k(Cr),i=(()=>{if(!n)return[];if(e)return r.data.map((e=>({type:"camera",value:e.id,label:e.name})));const t=[{value:Mr.Loitering,label:Fe.t("eventTypes.Loitering").toLowerCase(),type:"eventType"}];return[].concat(n.foundObjectTypesForSelect.map((e=>({...e,label:Fe.t(`analytics.${e.label}`)}))),t,r.data.map((e=>({type:"camera",value:e.id,label:e.name}))))})();return g(Ds,{onChange:(e,r)=>{t.setFilters(e),r.open||"remove"!==r.action&&"clear"!==r.action||t.applyFilters()},onMenuClose:()=>{t.applyFilters()},options:i,renderOption:Rs,values:t.filters,renderValue:Us,keyExtractor:e=>`${e.type}:${e.value}`,placeholder:v(y,{children:[g(Va,{size:16})," ",Fe.t("filter")]})})}));As.displayName="EventGridSelect";const Hs=F((({data:e,children:t,onClick:r,onAuxClick:n,menuComponent:i})=>{const o=T(null),{ref:a,menuContext:s}=function(){const[e,t]=C(!1),[r,n]=C(),i=L((e=>{n(e||void 0)}),[]),[o]=C((()=>new Set)),[a]=C((()=>new Set)),s=N((()=>({subscribe:e=>(o.add(e),()=>o.delete(e)),onOpenChange:e=>(a.add(e),()=>a.delete(e)),setOpened:e=>{t(e);for(const t of a)t(e)}})),[]);return M((()=>{if(r)return r.addEventListener("contextmenu",e),()=>{r.removeEventListener("contextmenu",e)};function e(e){e.preventDefault();for(const t of o)t(e)}}),[r]),{ref:i,menuContext:s,opened:e}}();return v("div",{ref:ee(o,a),onDragStart:t=>{if(!t.dataTransfer)return;t.dataTransfer.setData("x-3deye/event",`${e.id}`),t.dataTransfer.setData("x-3deye/camera",`${e.cameraId}`),t.dataTransfer.setData("x-3deye/starttime",e.startTime.toISOString()),t.dataTransfer.dropEffect="move";const r=o.current?.querySelector("img");if(r){const{x:e,y:n}=r.getBoundingClientRect();t.dataTransfer.setDragImage(r,t.clientX-e,t.clientY-n)}},className:"event-list-item",onClick:()=>r?.(e),onAuxClick:t=>n?.(t,e),draggable:!0,children:[t,i&&g(i,{ctx:s,data:e})]})}));Hs.displayName="EventListItem";const Es=F((({data:e})=>{if("Temperature"!==e.type)return null;const t=JSON.parse(e.raw.data??"null"),r=Number.isInteger(t)?Number(t):t.t;return v("div",{className:"event-list-item__temperature",children:[g(is,{}),v("span",{children:[(r-273.15).toFixed(1),"°C"]})," / ",v("span",{children:[(9*r/5-459.67).toFixed(1)," °F"]})]})}));Es.displayName="Temperature";var $s=Es;const Vs=F((({data:e,cameraNameHidden:t})=>{const r=k(Cr),{cameras:n}=r,i=n.loaded&&n.camerasById.get(e.cameraId)?.name||"...";return v("div",{className:"event-list-item-caption",children:[g("div",{className:"event-list-item__time",children:g(Fs,{from:e.startTime,to:e.endTime})}),t?null:v(y,{children:[g("div",{children:e.type}),g("div",{className:"event-list-item__camera-name",title:i,children:i})]}),+e.endTime-+e.startTime>0&&g("div",{className:"event-list-item__duration",children:ei(+e.endTime-+e.startTime,Fe.t)}),g($s,{data:e})]})}));Vs.displayName="EventListItemCaption";var Zs=F((({url:e,noPreview:t,width:r})=>v(y,{children:[e?g("img",{style:{position:"absolute",width:"100%",height:"100%",top:0,left:0},src:e},e):null,g(S,{radius:r}),t?g("div",{className:"no-preview-overlay"}):null]})));const Ws=({className:e,style:t,box:{Top:r,Left:n,Right:i,Bottom:o}})=>g(y,{children:g("div",{className:e,style:{position:"absolute",top:100*r+"%",left:100*n+"%",bottom:100*(1-o)+"%",right:100*(1-i)+"%",...t}})});function Ys({style:e}){return v("div",{className:"frame",style:e,children:[g("div",{className:"corner-highlight-tl"}),g("div",{className:"corner-highlight-tr"}),g("div",{className:"corner-highlight-br"}),g("div",{className:"corner-highlight-bl"})]})}Ws.displayName="LicensePlateLpr";const qs=w((({value:e})=>e?g(y,{children:e.split("").map(((e,t)=>(e=>{const t=e.charCodeAt(0);return t>=48&&t<=57})(e)?g("span",{className:"digit",children:e},`d${t}${e}`):g("span",{className:"char",children:e},`${t}${e}`)))}):null));qs.displayName="LicensePlateNumber";const Gs=({detectedObject:e,height:t,width:r,url:n,thumbWidth:i,thumbHeight:o})=>{const{Type:a,Box:{Top:s,Left:l,Right:c,Bottom:h},Probability:d,Value:u}=e,p=T(null);z((()=>{if(!p.current)return;const e=p.current.getBoundingClientRect();let n=(l+c)/2*r-e.width/2,i=s*t-e.height-4;i<0&&(i=h*t+4),n<0&&(n=0),n>r-e.width&&(n=r-e.width),p.current.style.top=`${i}px`,p.current.style.left=`${n}px`}));const f={top:2};l>=1-c?f.left=2:f.right=2;const m=100/i/(c-l);return v(y,{children:[v("div",{ref:p,className:"event-list-item__license-plate-label trigger",title:`${a.toLowerCase()} ${Math.floor(100*d)}%`,children:[g("div",{style:{padding:4},children:g(qs,{value:u})}),g("div",{className:"event-list-item__license-plate-label__caption",children:`${Math.floor(100*d)}%`})]}),g(Ws,{className:"event-list-item__license-plate-trigger trigger",box:e.Box}),v("div",{className:"event-list-item__license-plate preview",style:{overflow:"hidden",width:i*(c-l)*m,height:o*(h-s)*m+16,position:"absolute",...f},children:[g("img",{style:{width:i*m,height:o*m,transform:`translate(-${100*l}%, -${100*s}%)`},src:n}),g("div",{className:"plate-number",children:g(qs,{value:u})}),g(Ys,{style:{height:o*(h-s)*m}})]})]})};function Qs(e,t,r,n){return e.Top<-n&&(e.Bottom=e.Bottom-e.Top+n,e.Top=-n),e.Left<-n&&(e.Right=e.Right-e.Left+n,e.Left=-n),e.Right+n>t&&(e.Left=e.Left-(e.Right-t)+n,e.Right=t-n),e.Bottom+n>r&&(e.Top=e.Top-(e.Bottom-r)+n,e.Bottom=r-n),e}function Js({Top:e,Left:t,Bottom:r,Right:n},i,o,a,s){const l=s*e,c=s*r;return l>o?[0,-1]:c>o?[0,1]:a*t>i?[-1,0]:a*n>i?[1,0]:[0,l>c?1:-1]}function Xs(e,t){return{Top:e.Top+t[1],Left:e.Left+t[0],Bottom:e.Bottom+t[1],Right:e.Right+t[0]}}Gs.displayName="LicensePlateHighlight";const Ks=({face:{Name:e,Box:t,Probability:r},url:n,thumbWidth:i,thumbHeight:o,width:a,height:s})=>{const{Top:l,Left:c,Right:h,Bottom:d}=t,u=100/i/(h-c),p={top:2},f=T(null);return z((()=>{if(!f.current)return;const{width:e,height:r}=f.current.getBoundingClientRect(),n=Js(t,e,r,a,s);n[0]=n[0]*(e+(h-c)*a)/2,n[1]=n[1]*(r+(d-l)*s)/2;const i=Qs(Xs({Top:(l+d)/2*s-r/2,Left:(c+h)/2*a-e/2,Bottom:(l+d)/2*s+r/2,Right:(c+h)/2*a+e/2},n),a,s,0);f.current.style.top=`${i.Top+2*Math.sign(n[1])}px`,f.current.style.left=`${i.Left+2*Math.sign(n[0])}px`})),c>=1-h?p.left=2:p.right=2,v(y,{children:[v("div",{ref:f,className:"event-list-item__detected-object-label trigger",title:`${e} ${Math.floor(100*r)}%`,children:[g("div",{style:{padding:4,display:"flex",alignItems:"center",maxWidth:120,whiteSpace:"break-spaces"},children:e}),v("div",{className:"event-list-item__detected-object-label__caption",style:{color:"black",backgroundColor:"orange"},children:[Math.floor(100*r),"%"]})]}),g(Ws,{className:"trigger",box:t,style:{outline:"1px solid orange"}}),v("div",{className:"event-list-item-face preview",style:{overflow:"hidden",width:i*(h-c)*u,height:o*(d-l)*u,...p},children:[g("img",{style:{width:i*u,height:o*u,transform:`translate(-${100*c}%, -${100*l}%)`},src:n}),g(Ys,{})]})]})};function el({Top:e,Left:t,Bottom:r,Right:n}){return[(t+n)/2,(e+r)/2]}function tl(e,t){const[r,n]=el(e),[i,o]=el(t);return[i-r,o-n]}function rl(e,t){return!(e.Left>t.Right||e.Top>t.Bottom||e.Right<t.Left||e.Bottom<t.Top)}function nl([e,t]){const r=Math.sqrt(e*e+t*t);return 0===r?[0,0]:[e/r,t/r]}Ks.displayName="FaceHighlight";const il=F((({data:e,width:t,height:r})=>{const n=T(null),{eventSchema:i}=k(Cr);return z((()=>{if(!n.current)return;const i=[],o=[];for(let a=0;a<e.length;a++){const s=n.current.children[2*a+1],l=e[a].Box;i.push({Top:l.Top*r,Left:l.Left*t,Bottom:l.Bottom*r,Right:l.Right*t});const[c,h]=el(i[a]),{width:d,height:u}=s.getBoundingClientRect(),p=Js(l,d,u,t,r);o.push(Xs({Top:h-u/2-4,Left:c-d/2-4,Bottom:h+u/2+4,Right:c+d/2+4},p))}let a=!0,s=0;for(;a;){if(a=!1,s++>1e3){console.warn("Reached max iterations for label positioning");break}for(let t=0;t<e.length;t++){const r=o[t],n=[0,0];for(let s=0;s<e.length;s++){const e=i[s],l=o[s];if(rl(r,e)){const t=tl(e,r);n[0]=n[0]+t[0],n[1]=n[1]+t[1],a=!0}if(s!==t&&rl(r,l)){const e=tl(l,r);n[0]=n[0]+e[0],n[1]=n[1]+e[1],a=!0}}[n[0],n[1]]=nl(n),r.Top+=n[1],r.Left+=n[0],r.Bottom+=n[1],r.Right+=n[0]}}for(let i=0;i<e.length;i++){const e=n.current.children[2*i+1],{Top:a,Left:s}=Qs(o[i],t,r,4);e.style.top=`${a+4}px`,e.style.left=`${s+4}px`}}),[e,t,r]),g("div",{ref:n,children:e.map(((e,t)=>v(b.Fragment,{children:[g(Ws,{box:e.Box,style:{outline:`2px solid ${i.colorsByFoundObjectType.get(e.Type)??""}`}}),v("div",{className:"event-list-item__detected-object-label",title:`${e.Type.toLowerCase()} ${Math.floor(100*e.Probability)}%`,children:[g("div",{style:{padding:4,lineHeight:"24px"},children:"Car"===e.Type&&"BodyType"in e&&e.BodyType?e.BodyType.toLowerCase():e.Type.toLowerCase()}),v("div",{className:"event-list-item__detected-object-label__caption",style:{backgroundColor:i.colorsByFoundObjectType.get(e.Type)},children:[Math.floor(100*e.Probability),"%"]})]})]},t)))})}));il.displayName="DetectedObjects";var ol=il;const al=F((({data:e,width:t,height:r,cameraNameHidden:n,onClick:i,onAuxClick:o,menuComponent:a})=>{const s=k(Cr),{eventSchema:l}=s,[c,h]=function(e){const[t,r]=C(null),n=k(Cr),{cameras:i,thumbnails:o}=n;M((()=>{if(e.thumbnailUrl)return void r(null);const t=o.fetchThumbnail(e.cameraId,e.startTime,e.startTime).subscribe((e=>{r(e||null)}));return()=>t.unsubscribe()}),[e.id]);let a="",s=!1;return e.thumbnailUrl?a=e.thumbnailUrl:null===t&&i.loaded?(a=i.camerasById.get(e.cameraId)?.imageUrl||"",s=!0):t&&(a=t.url),[a,s]}(e);let d=[],u=null,p=null;if(e.detectedObjects.length){const{thumbnailWidth:n,thumbnailHeight:i}=e;d=e.detectedObjects.filter((({Type:e})=>l.foundObjectTypes.includes(e)&&"LicensePlate"!==e)),u=e.detectedObjects.filter((e=>"LicensePlate"===e.Type)).map(((e,o)=>g(Gs,{detectedObject:e,width:t,height:r,thumbWidth:n,thumbHeight:i,url:c},o)))}if(e.faces){const{thumbnailWidth:n,thumbnailHeight:i}=e;p=e.faces.map(((e,o)=>g(Ks,{face:e,url:c,thumbWidth:n,thumbHeight:i,width:t,height:r},o)))}return g(Hs,{onClick:i,onAuxClick:o,data:e,width:t,height:r,menuComponent:a,children:v("div",{style:{position:"absolute",top:0,left:0,bottom:0,right:0},children:[g(Zs,{url:c,noPreview:h,width:t}),g(ol,{data:d,width:t,height:r}),u,p,e.acknowledged?g("div",{className:"acknowledged-overlay",children:Fe.t("event.acknowledged")}):null,g(Vs,{data:e,cameraNameHidden:n})]})})}));al.displayName="EventItem";const sl=F((({columnIndex:e,rowIndex:t,style:r,store:n,columnCount:i,eventRenderer:o})=>{const a=t*i+e,s=n.data[a];return a===n.data.length?n.error?g("div",{style:r,children:g("div",{style:{position:"absolute",inset:0,display:"grid",placeItems:"center"},children:v("div",{style:{textAlign:"center"},children:[g("div",{children:"Couldn't fetch more data"}),g(xa,{onClick:n.loadMore,children:"Retry"})]})})}):n.pageInfo?.haveMore?g("div",{style:r,children:g("div",{style:{position:"absolute",inset:0,display:"grid",placeItems:"center"},children:g(ws,{size:32})})}):g("div",{style:r}):!s&&n.pageInfo?.haveMore?g("div",{style:r}):g("div",s?{style:r,children:g(gs,{children:o({data:s,width:r.width,height:r.height})})}:{style:r})})),ll=F((({store:e,scrollWidth:t,onClick:r})=>e.pendingData.length?g("div",{style:{position:"absolute",top:0,left:0,right:t,pointerEvents:"none",textAlign:"center",padding:8},children:g(xa,{className:"x-3deye-button--overlay",style:{background:"rgba(0, 0, 0, 0.75)",padding:"8px 16px",backdropFilter:"blur(2px)",borderRadius:32,pointerEvents:"auto"},onClick:r,children:Fe.t("showEvents",{count:e.pendingData.length})})}):null)),cl=F((({store:e,width:t,height:r,captionHeight:n=0,columnsCount:i=0,minColumnWidth:o,aspectRatio:a=16/9,onEventClick:s,onEventAuxClick:l,eventRenderer:c})=>{const h=T(null),d=()=>{h.current&&(e.setLiveUpdateMode("auto"),h.current.scrollTop=0)};if(M((()=>Me((()=>e.loading||!e.data.length),(e=>e&&d()))),[]),e.error&&!e.data.length)return g("div",{style:{flex:1,display:"flex",justifyContent:"center",alignItems:"center"},children:v("div",{style:{textAlign:"center"},children:[g("div",{children:"Couldn't fetch data"}),g(xa,{onClick:e.reload,children:"Retry"})]})});if(e.loading)return g("div",{style:{flex:1,display:"flex",justifyContent:"center",alignItems:"center"},children:g(ws,{})});if(!e.data.length)return g("div",{style:{flex:1,display:"flex",justifyContent:"center",alignItems:"center"},children:Fe.t("noEventsFound")});return g(hl,{...{store:e,width:t,columnsCount:i,minColumnWidth:o,aspectRatio:a,captionHeight:n,height:r,onEventClick:s,onEventAuxClick:l,eventRenderer:c,containerRef:h,resetScroll:d}})}));cl.displayName="EventGrid";const hl=F((({store:e,width:t,height:r,captionHeight:n=0,columnsCount:i=0,minColumnWidth:o=320,aspectRatio:a,containerRef:s,onEventClick:l,onEventAuxClick:c,eventRenderer:h=({data:e,width:t,height:r})=>g(al,{data:e.data,cameraNameHidden:!1,onClick:l,onAuxClick:c,width:t,height:r}),resetScroll:d})=>{const u=Math.floor(t/o)||1,p=t/u/a+n,f=u*Math.floor(r/p)>=e.data.length?0:Kn(),m=Math.min(i,e.data.length)||Math.max(1,Math.floor((t-f)/o));let y=Math.ceil(e.data.length/m);const b=(t-f-2*(m-1))/m,x=b/a+n;e.pageInfo?.haveMore&&y*m===e.data.length&&y++;const{parentRef:w,getItems:C,getTotalSize:T}=zs({count:y,overscan:5,itemSize:x,spacing:2}),{parentRef:_,getItems:D,getTotalSize:L}=zs({count:m,overscan:5,itemSize:b,horizontal:!0,spacing:2}),N=C(),I=D();M((()=>{e.error||e.pageInfo?.haveMore&&(e.loading||N.length&&N.at(-1).idx+1===y&&e.loadMore())}),[e.error,e.pageInfo?.haveMore,N]);const k=N.flatMap((({idx:t,size:r,start:n})=>I.map((({idx:i,size:o,start:a})=>{const s=t*m+i;return s>e.data.length?null:s!==e.data.length||e.pageInfo?.haveMore?g(sl,{columnIndex:i,rowIndex:t,columnCount:m,style:{position:"absolute",top:0,left:0,height:r,width:o,transform:`translate(${a}px, ${n}px)`,display:"flex"},store:e,eventRenderer:h},e.data[s]?`${e.data[s].data.id}-${e.data[s].objectIdx}`:"loading"):null}))));return v("div",{style:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:[g("div",{ref:ee(s,w,_),style:{width:t,height:r,overflow:"auto"},onScroll:t=>{const{scrollTop:r}=t.target;"disabled"!==e.liveUpdateMode&&e.setLiveUpdateMode(r>=1||e.pendingData.length?"manual":"auto")},children:g("div",{style:{position:"relative",height:T(),width:L()},children:k})}),g(ll,{store:e,scrollWidth:f,onClick:()=>{e.flushUpdates(),d()}})]})}));const dl=F((({data:{data:e,objectIdx:t},width:r,height:n,cameraNameHidden:i,onClick:o,onAuxClick:a,menuComponent:s})=>{let l=null;const{thumbnailWidth:c,thumbnailHeight:h}=e;l=e.detectedObjects[t];const{Box:{Bottom:d,Left:u,Right:p,Top:f}}=l,m="Person"===l?.Type?.8:1,{imageTop:y,imageLeft:b,imageScale:x}=function(e,t,r,n,i,o=1){const{top:a,left:s,bottom:l,right:c}=r,h=a*n,d=s*i,u=(l-a)*n,p=(c-s)*i;let f=1,m=0,g=0;return e/t>p/u?(f=t/u*o,m=-h*f+(t-u*f)/2,g=-(d+p/2)*f+e/2):(f=e/p*o,m=-(h+u/2)*f+t/2,g=-d*f),{imageTop:m,imageLeft:g,imageScale:f}}(r,n,{top:f,left:u,bottom:d,right:p},h,c,m);return g(Hs,{onClick:o,onAuxClick:a,data:e,width:r,height:n,cameraNameHidden:i,menuComponent:s,children:v("div",{style:{position:"absolute",top:0,left:0,bottom:0,right:0},children:[g("img",{src:e.thumbnailUrl,style:{position:"absolute",top:y,left:b,width:c*x,height:h*x}},e.thumbnailUrl),g(S,{radius:r}),g(Vs,{data:e,cameraNameHidden:!0})]})})}));dl.displayName="DetectedObjectCell";var ul=ga;var pl=Pe((function(e,t){return ul(e,t)}));const fl={Top:0,Left:0,Bottom:1,Right:1};class ml extends ri{eventSchema;events;account;notification;heatmaps;disposables=[];analyticsEnabled;cameraId=null;date=null;get startTime(){return this.date?(e=this.date,this.account.preferences.utc?new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())):new Date(e.getFullYear(),e.getMonth(),e.getDate())):null;var e}regions=null;filters=[];colors=new Set;peopleCountingDataLoading=!1;heatmapMode="selection";heatmapLoading=!1;data=[];heatmap=null;peopleCountingData=[];probabilityThreshold=.5;brushFilter=null;loadTrigger=0;eventsLoader;loaderFilters;get params(){return this.eventSchema.schemaDescription.filter((e=>"filter"===e.parameterType))}get filteredData(){let e=[];const t=this.filters.map((e=>e.value));t.length?(e=this.data.filter((e=>e.detectedObjects.some((e=>t.includes(e.Type)&&e.Probability>=this.probabilityThreshold)))),this.colors.size&&(e=e.filter((e=>e.detectedObjects.some((e=>"Colors"in e&&e.Colors?.some((e=>this.colors.has(e.Color))))))))):e=this.data.filter((e=>e.detectedObjects.some((e=>e.Probability>=this.probabilityThreshold))));const{brushFilter:r}=this;r&&(e=e.filter((e=>e.startTime>=r[0]&&e.startTime<=r[1]&&e.detectedObjects.some((e=>"Person"===e.Type)))));const{regions:n}=this;return n?.length&&(e=e.filter((e=>e.detectedObjects.some((e=>(!t.length||t.includes(e.Type))&&(!this.colors.size||"Colors"in e&&e.Colors?.some((e=>this.colors.has(e.Color))))&&e.Probability>=this.probabilityThreshold&&n.some((t=>gr(t,{x:e.Box.Left,y:e.Box.Top,width:e.Box.Right-e.Box.Left,height:e.Box.Bottom-e.Box.Top})))))))),e}get filteredPeopleCountingData(){const{regions:e}=this;return e?.length?this.peopleCountingData.filter((t=>e.some((e=>gr(e,{x:t.Left,y:t.Top,width:t.Right-t.Left,height:t.Bottom-t.Top}))))):this.peopleCountingData}constructor(e,t,r,n,i){super(),this.eventSchema=e,this.events=t,this.account=r,this.notification=n,this.heatmaps=i,xe(this,{cameraId:we,date:we,setDate:Ce,startTime:ye,regions:we.ref,filters:we.ref,colors:we.ref,peopleCountingDataLoading:we,heatmapMode:we,heatmapLoading:we,data:we.ref,heatmap:we.ref,peopleCountingData:we.ref,probabilityThreshold:we,brushFilter:we.ref,params:ye,filteredData:ye,filteredPeopleCountingData:ye,setFilters:Ce,setBrushFilter:Ce,setParams:Ce,searchFullFrame:Ce,setRegions:Ce,setHeatmapMode:Ce,toggleColor:Ce,clearColors:Ce,clear:Ce,loadTrigger:we}),this.analyticsEnabled=Boolean(i);const o=new Os;this.loaderFilters=o;const a=(e=>(t,r)=>t.cameras.GetSensorEventsPage({sensorIds:e.cameras,sensorType:"camera",sensorEventTypes:e.eventTypes,startTime:e.from??void 0,endTime:e.to??void 0,isDescending:"DESC"===e.sortDirection,rowsLimit:10,pageToken:r},e.filterJson,e.regionsWkt))(o);this.eventsLoader=new va(t,o,a,(e=>e.detectedObjects.map(((e,t)=>o.detectedObjects.length&&!o.detectedObjects.includes(e.Type)||o.colors.size&&"Colors"in e&&!e.Colors?.some((e=>o.colors.has(e.Color)))||null!==o.probabilityThreshold&&e.Probability<o.probabilityThreshold||o.regions?.length&&!o.regions.some((t=>gr(t,this.boxToAabb(e.Box))))?-1:t)).filter((e=>-1!==e)).map((t=>({data:e,objectIdx:t}))))),this.eventsLoader.liveUpdateMode="disabled",this.initDataFetching()}boxToAabb(e){return{x:e.Left,y:e.Top,width:e.Right-e.Left,height:e.Bottom-e.Top}}setDate=e=>{this.date=e,this.brushFilter=null};setFilters=e=>{this.filters=e};getProbabilityThreshold=()=>this.probabilityThreshold;setProbabilityThreshold=e=>{this.probabilityThreshold=e};setBrushFilter=e=>{this.brushFilter=e};setParams=({cameraId:e,box:t})=>{this.cameraId=e,this.regions=[[{x:t.Left,y:t.Top},{x:t.Right,y:t.Top},{x:t.Right,y:t.Bottom},{x:t.Left,y:t.Bottom}]],this.date||(this.date=new Date)};searchFullFrame=e=>{this.clear(),this.cameraId=e,this.peopleCountingData=[],this.date||(this.date=new Date),this.triggerLoad()};triggerLoad=()=>{this.loadTrigger++};setRegions=e=>{this.regions=e.length?e:null};setHeatmapMode=e=>{this.heatmapMode=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};clear=()=>{this.cameraId=null,this.date=null,this.regions=null,this.brushFilter=null,this.heatmap=null,this.data=[],this.peopleCountingData=[]};initDataFetching=()=>{const e=Tr((()=>({startTime:this.startTime,regions:this.regions,cameraId:this.cameraId,trigger:this.loadTrigger})),!0).pipe(_e(pl),De());this.disposables.push(Tr((()=>({startTime:this.startTime,regions:this.regions,cameraId:this.cameraId,filters:this.filters,brushFilter:this.brushFilter,colors:this.colors,probabilityThreshold:this.probabilityThreshold})),!0).pipe(_e(pl),De()).subscribe((e=>{Te((()=>{if(!e.startTime||!e.cameraId)return;this.loaderFilters.sortDirection="DESC";const{startTime:t}=e,r=vr(t,this.account.preferences.utc);this.loaderFilters.from=t,this.loaderFilters.to=r;const{brushFilter:n}=e;n&&([this.loaderFilters.from,this.loaderFilters.to]=n),this.loaderFilters.regions=[...e.regions||[]],this.loaderFilters.cameras=[e.cameraId],this.loaderFilters.detectedObjects=e.filters.map((e=>e.value)),this.loaderFilters.eventTypes=[Mr.Analytic],this.loaderFilters.colors=e.colors,this.loaderFilters.probabilityThreshold=e.probabilityThreshold,this.eventsLoader.load()}))})));const r=this.heatmaps;r&&(this.disposables.push(e.pipe(Le((e=>{if(!e.startTime||!e.cameraId)return u;Te((()=>{this.peopleCountingDataLoading=!0}));const{startTime:r}=e,n=vr(r,this.account.preferences.utc),i=e.regions?this.boxRegions(e.regions):fl;return this.api.cameras.GetPeopleCountingData(e.cameraId,r,n,i).pipe(Ne((e=>e.success?t(e.resultItems):a((()=>e.error))))).pipe(Ie((e=>(this.notification.error(Fe.t("eventSearchRequestError.peopleCounting")),console.error(e),t([])))))}))).subscribe((e=>{Te((()=>{this.peopleCountingData=e,this.peopleCountingDataLoading=!1}))}))),this.disposables.push(Tr((()=>({startTime:this.startTime,cameraId:this.cameraId,trigger:this.loadTrigger})),!0).pipe(_e(pl),Le((e=>{if(!e.startTime||!e.cameraId)return u;Te((()=>{this.heatmapLoading=!0}));const{startTime:n}=e,i=vr(n,this.account.preferences.utc);return r.fetchHeatmaps(e.cameraId,n,i,1).pipe(ke((e=>e[0]||null))).pipe(Ie((e=>(this.notification.error(Fe.t("eventSearchRequestError.heatmap")),console.error(e),t(null)))))}))).subscribe((e=>{Te((()=>{this.heatmap=e,this.heatmapLoading=!1}))}))))};boxRegions(e){const t=e.flatMap((e=>e.map((({x:e})=>e)))),r=e.flatMap((e=>e.map((({y:e})=>e))));return{Left:Math.min(...t),Right:Math.max(...t),Top:Math.min(...r),Bottom:Math.max(...r)}}afterInit(){this.eventsLoader.initWith(this.api)}}const gl=F((({store:e})=>{const[t,r]=C(!1),{account:n,cameras:i}=k(Cr),{utc:o,hour12:a,startOfWeek:s}=n.preferences,{date:l,setDate:c,cameraId:h}=e,d=h?i.camerasById.get(h):void 0,u=new Date,p=xr(u,1,o),f=l&&yr(l,u,o),m=l&&yr(l,p,o),y=d?wr(u,d.archiveDuration):u,b=N((()=>{const e=new Intl.DateTimeFormat(Fe.language,{weekday:"short",month:"short",day:"numeric"});return t=>e.format(t)}),[o,a]);return v(wa,{children:[g(xa,{className:O({"button-selected":f}),onClick:()=>c(new Date),children:Fe.t("today")}),h&&!yr(new Date,y,o)?g(xa,{className:O({"button-selected":m}),onClick:()=>c(p),children:Fe.t("yesterday")}):null,l&&v(xs,{className:"popover-datepicker",target:g(xa,{className:O("date-button",{"button-selected":!f&&!m}),onClick:()=>r(!t),children:b(l)}),opened:t,withArrow:!0,onOpenChange:r,children:[g(us,{date:l,onChange:c,minDate:y,maxDate:new Date,utc:o,startOfWeek:s}),g("div",{style:{display:"flex"},children:g(xa,{style:{flex:1},onClick:()=>r(!1),variant:"filled",children:Fe.t("button.ok")})})]})]})}));gl.displayName="DateSelector";var vl=gl;const yl=F((({store:e})=>{const t=T(null),r=T(null),n=T(null),i=T([]),[o,a]=C(0),s=100,l=20,c=20,h=30,d=20,{filteredPeopleCountingData:u,brushFilter:p}=e,f=p?i.current.filter((e=>+e.x0>=+p[0]&&+e.x1<=+p[1])).reduce(((e,t)=>e+t.length),0):null;return M((()=>{const e=new ve((e=>{for(const t of e){const e=t.contentRect.width;a(e)}}));return e.observe(t.current),()=>e.disconnect()}),[]),M((()=>{const t=le(r.current);if(!o)return;for(const e of u)e.timestamp=new Date(e.TimeStamp);const a=oe(u,(e=>e.timestamp)),p=de(ue.offset(a[0],-1),ue.offset(a[1],1)),f=me().extent([[d,l],[o-c,s-h]]).on("end",(function({selection:t,sourceEvent:r}){if(!r)return;if(!t)return void e.setBrushFilter(null);const n=pe.every((+i.current[0].x1-+i.current[0].x0)/6e4||30);let[o,a]=t.map((e=>n.round(m.invert(e))));if(+o==+a&&(o=n.floor(m.invert(t[0])),a=n.ceil(m.invert(t[1])),+o==+a))return le(this).transition().call(f.move,null),void e.setBrushFilter(null);e.setBrushFilter([o,a]),le(this).transition().call(f.move,a>o?[o,a].map(m):null)}));n.current=f;const m=ce().domain(oe(p)).nice().range([d,o-c]);i.current=u.length?ae().value((e=>e.timestamp)).domain(m.domain()).thresholds(m.ticks(24))(u):[];const g=he().domain([0,se(i.current,(e=>e.length))]).nice().range([s-h,l]),v=t.select(".bars").selectAll(".bar").data(i.current);v.exit().remove();const y=v.enter().append("g").attr("class","bar");if(y.append("rect").attr("x",(e=>m(e.x0)+1)).attr("width",(e=>Math.max(0,m(e.x1)-m(e.x0)-1))).attr("y",(e=>g(e.length))).attr("height",(e=>g(0)-g(e.length))),v.select("rect").attr("x",(e=>m(e.x0)+1)).attr("width",(e=>Math.max(0,m(e.x1)-m(e.x0)-1))).attr("y",(e=>g(e.length))).attr("height",(e=>g(0)-g(e.length))),y.append("text").attr("dy",".75em").attr("y",(e=>g(e.length)-10)).attr("x",(e=>m(e.x0)+1+Math.max(0,m(e.x1)-m(e.x0)-1)/2)).attr("text-anchor","middle").text((e=>e.length?e.length:"")),v.select("text").attr("dy",".75em").attr("y",(e=>g(e.length)-10)).attr("x",(e=>m(e.x0)+1+Math.max(0,m(e.x1)-m(e.x0)-1)/2)).attr("text-anchor","middle").text((e=>e.length?e.length:"")),u.length){const[r,n]=m.domain(),[i,o]=m.range(),a=(o-i)/(+n-+r)*3600*1e3,s=30,l=fe(m).ticks(ue.every(1)).tickFormat((e=>a>=s?ge("%H:%M")(e):e.getHours()%(Math.floor(s/a)+1)?"":ge("%H:%M")(e)));l.scale(m),t.select(".x-axis").attr("transform","translate(0,70)").call(l),t.select(".brush").call(f),e.brushFilter&&t.select(".brush").call(f.move,e.brushFilter.map(m))}else t.select(".x-axis").html(""),t.select(".brush").call(f),t.select(".brush").html("").call(f.move,null)}),[o,u]),M((()=>{n.current&&(e.brushFilter||le(r.current).select(".brush").call(n.current.move,null))}),[e.brushFilter]),v("div",{ref:t,children:[v("div",{style:{paddingLeft:10,paddingRight:10,display:"flex"},children:[Fe.t("peopleCounting"),v("div",{style:{marginLeft:"auto"},children:[null===f?null:g(ks,{label:Fe.t("selected"),children:g("span",{children:f})}),null===f?null:"/",g(ks,{label:Fe.t("total"),children:g("span",{children:u.length})})]})]}),v("svg",{ref:r,className:"people-histogram",width:o,height:s,viewBox:`0 0 ${o} 100`,role:"graphics-symbol",children:[g("g",{className:"bars"}),g("g",{className:"x-axis"}),g("g",{className:"brush"})]})]})}));var bl=yl;yl.displayName="PeopleHistogram";const xl=F((({store:e,onEventClick:t})=>{if(!e)return null;const{filters:r,setFilters:n}=e,{foundObjectTypesForSelect:i}=e.eventSchema,{ref:o,width:a,height:s}=j();return v(y,{children:[g(vl,{store:e}),g("div",{style:{zIndex:2,padding:"0.5rem"},children:g(Ds,{onChange:n,options:i.map((e=>({...e,label:Fe.t(e.label)}))),placeholder:Fe.t("selectObjectType"),values:r,renderOption:Rs,renderValue:Us})}),g(js,{getter:e.getProbabilityThreshold,setter:e.setProbabilityThreshold}),g(as,{value:e.colors,toggle:e.toggleColor,clear:e.clearColors}),e.analyticsEnabled?g(bl,{store:e}):null,g("div",{ref:o,style:{flex:1,overflow:"hidden"},children:g(cl,{width:a,height:s,minColumnWidth:120,aspectRatio:1,store:e.eventsLoader,eventRenderer:({data:e,width:r,height:n})=>g(dl,{data:e,cameraNameHidden:!0,onClick:t,width:r,height:n})})})]})}));xl.displayName="EventSearch";const wl=e=>{const t=k(f)??m;return g(Cr.Provider,{value:t,children:g(xl,{...e})})};wl.displayName="EventSearch";var Cl=wl;(e=>{if(e&&Object.assign(je,e),Fe.isInitialized){if(je.resources)for(const e of Object.keys(je.resources))Fe.addResourceBundle(e,"translation",je.resources[e].translation,!0);else console.warn("i18n is already initialized");return t(Fe.t)}r(Fe.init(je))})({resources:{en:{translation:ze}}});const Tl=(e=m)=>{const t=new ml(e.eventSchema,e.events,e.account,e.notification);return t.initWith(e.api),t};export{Tl as createEventSearchStore,Cl as default};
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@3deye-toolkit/react-event-search",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "module": "dist/react-event-search.js",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
8
8
  "types": "dist/react-event-search.d.ts",
9
9
  "dependencies": {
10
- "@3deye-toolkit/core": "0.0.5",
10
+ "@3deye-toolkit/core": "0.0.7",
11
11
  "@floating-ui/react": "^0.25.4",
12
12
  "@mantine/hooks": "^6.0.21",
13
13
  "@seznam/compose-react-refs": "^1.0.6",