"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[179],{70419:(e,t,n)=>{var a=n(66204),s=n(6279),r=n(59379);const i="MSP Operator",o=["SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY"],l=()=>o.map((e=>({name:e,symbol:e[0]}))),c="notif-sound-default",d=["notif-sound-1","notif-sound-2","notif-sound-3","notif-sound-4","notif-sound-5"],u={getAccessToken:()=>Promise.reject(),logout:()=>({})},m=(0,a.createContext)(u);function h(){return(0,a.useContext)(m)}const x=()=>Promise.reject("Unexpected use of HttpClient before initialization"),p=(0,a.createContext)(x);function g(){return(0,a.useContext)(p)}const f={id:"",email:"",name:"",roles:[],permissions:[],userIntercomHash:"",mspTenants:[],mspLocations:[],visionTenants:[],enabled:!0,tenant:{id:"",name:""}},v=(0,a.createContext)(f);function j(){return(0,a.useContext)(v)}var b=n(78296),y=n(3996);const k="An error occurred",w="Missing error cause in response";async function N(e){if(!e.ok){let n;try{n=await e.json()}catch(t){throw y.Tb(new Error(String(t))),new Error(k)}if(!n.message)throw y.Tb(new Error(w),n),new Error(k);throw new Error(n.message)}return e}function C(e,t){return async(n,a={})=>{var s;const{noAuth:r=!1}=a,i=await async function(e,t,n){if(n)return new Request(e);{let n="";try{n=await t()}catch(a){throw Error("Failed to perform authenticated request")}const s=new Request(e);return s.headers.set("Authorization",`Bearer ${n}`),s}}(n,e,r),o=null!=(s=null==a?void 0:a.responseModifier)?s:e=>e.json();function l(e){return a.tap&&a.tap(e.clone()),e}return r?fetch(i).then(N).then(l).then(o):fetch(i).then(function(e){return async t=>(t.ok||401!==t.status||((0,b.mc)(),e({returnTo:window.location.origin})),t)}(t)).then(N).then(l).then(o)}}let S;const T=async()=>{if(!S){const e=await n.e(792).then(n.t.bind(n,70792,23));S=e.default.sanitize}return S},E=(e,t,n=1)=>Array.from({length:(t-e)/n+1},((t,a)=>e+a*n));function A(e,t){let n;return function(...a){n&&clearTimeout(n),n=window.setTimeout((()=>{e(...a),n=null}),t)}}const _=(e,t)=>{if(e===t)return!0;if(typeof e!=typeof t||null==e||null==t)return!1;if("object"!=typeof e)return e===t;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!_(e[n],t[n]))return!1}else{const n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;for(const s of n)if(!Object.prototype.hasOwnProperty.call(t,s)||!_(e[s],t[s]))return!1}return!0};function I(){return!!window.Notification&&("serviceWorker"in navigator&&"PushManager"in window)}const L=e=>e.charAt(0).toUpperCase()+e.slice(1);function R(e,t){const[n,s]=(0,a.useState)(e);return(0,a.useEffect)((()=>{const n=setTimeout((()=>s(e)),t||500);return()=>{clearTimeout(n)}}),[e,t]),n}function D(e){const[t,n]=(0,a.useState)(!1),s=(0,a.useCallback)((()=>{const t=e.current;document.fullscreenElement?document.exitFullscreen():t&&t.requestFullscreen()}),[e]);return(0,a.useEffect)((()=>{const t=e.current,a=()=>{n(!!document.fullscreenElement)};return t&&t.addEventListener("fullscreenchange",a),()=>{t&&(null==t||t.removeEventListener("fullscreenchange",a))}}),[e,s]),{isFullScreen:t,toggleFullScreen:s}}function P(){const{roles:e}=j();return e.includes("Hakimo Support")||e.includes("MSP Manager")}function M(e,t){const[n,s]=(0,a.useState)((()=>{try{const n=window.localStorage.getItem(e);return n?JSON.parse(n):(void 0!==t&&window.localStorage.setItem(e,JSON.stringify(t)),t)}catch(n){return console.error(`Error initializing localStorage key \u201c${e}\u201d:`,n),y.Tb(new Error(`Error initializing localStorage key \u201c${e}\u201d`),{extra:{error:n}}),t}}));return[n,t=>{try{window.localStorage.setItem(e,JSON.stringify(t))}catch(n){console.error(`Error setting localStorage key \u201c${e}\u201d:`,n),y.Tb(new Error(`Error setting localStorage key \u201c${e}\u201d`),{extra:{error:n}})}s(t)},()=>{try{window.localStorage.removeItem(e)}catch(t){console.error(`Error removing localStorage key \u201c${e}\u201d:`,t),y.Tb(new Error(`Error removing localStorage key \u201c${e}\u201d:`),{extra:{error:t}})}s(void 0)},()=>{try{const t=window.localStorage.getItem(e);if(t)return JSON.parse(t)}catch(n){console.error(`Error getting localStorage key \u201c${e}\u201d:`,n),y.Tb(new Error(`Error getting localStorage key \u201c${e}\u201d`),{extra:{error:n}})}return t}]}function O(e){const t=(0,a.useRef)(void 0);return(0,a.useEffect)((()=>{t.current=e}),[e]),t.current}let F=function(e){return e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED",e.ERROR="ERROR",e}({});function Z({url:e,onMessage:t,onOpen:n,onClose:s,onError:r,getAccessToken:i}){const[o,l]=(0,a.useState)(F.CONNECTING),c=(0,a.useRef)(null),d=(0,a.useRef)(!1),u=(0,a.useCallback)((async()=>{if(c.current)return;const a=i?await i():"";c.current=new WebSocket(e,[a]),l(F.CONNECTING),c.current.onopen=e=>{l(F.OPEN),n&&n(e)},c.current.onmessage=e=>{t&&t(e)},c.current.onclose=e=>{l(F.CLOSED),s&&s(e)},c.current.onerror=e=>{l(F.ERROR),r&&r(e)}}),[i,e,n,t,s,r]);(0,a.useEffect)((()=>(u(),()=>{c.current&&c.current.close()})),[u]);return{socketStatus:o,sendMessage:(0,a.useCallback)((e=>{c.current&&c.current.readyState===WebSocket.OPEN?c.current.send(JSON.stringify(e)):console.error("WebSocket is not open. Unable to send message.")}),[]),closeConnection:(0,a.useCallback)((()=>{d.current=!0,c.current&&c.current.close()}),[])}}var q=n(21315),U=n(91310),V=n(51206),$=n(64609),z=n(53583),H=n(43188);function B(e){const{children:t,type:n="info",className:a}=e;let s;switch(n){case"success":s=q.Z;break;case"error":s=U.Z;break;case"warning":s=V.Z;break;default:s=$.Z}return(0,H.jsx)("div",{className:(0,z.Z)("rounded-md p-4","success"===n&&"bg-green-50 dark:bg-green-900","error"===n&&"bg-red-50 dark:bg-red-900","warning"===n&&"bg-yellow-50 dark:bg-yellow-900","info"===n&&"bg-blue-50 dark:bg-blue-900",...a||""),children:(0,H.jsxs)("div",{className:"flex",children:[(0,H.jsx)("div",{className:"flex-shrink-0",children:(0,H.jsx)(s,{className:(0,z.Z)("h-5 w-5","success"===n&&"text-green-400 dark:text-green-200","error"===n&&"text-red-400 dark:text-red-100","warning"===n&&"text-yellow-400 dark:text-yellow-200","info"===n&&"text-blue-400 dark:text-blue-200"),"aria-hidden":"true"})}),(0,H.jsx)("div",{className:"ml-3 flex-1 md:flex md:justify-between",children:(0,H.jsx)("p",{className:(0,z.Z)("text-sm","success"===n&&"text-green-700 dark:text-green-200","error"===n&&"text-red-700 dark:text-red-100","warning"===n&&"text-yellow-700 dark:text-yellow-200","info"===n&&"text-blue-700 dark:text-blue-200"),children:t})})]})})}function W(e){return(0,H.jsxs)("svg",Object.assign({className:"h-5 w-5 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},e,{children:[(0,H.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,H.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}))}const G=W;function K(e){return(0,H.jsx)("span",Object.assign({className:"dark:text-hakimo-yellow text-primary-700"},e,{children:(0,H.jsx)(G,{})}))}const Y=K;function Q(e){const{children:t,variant:n="outline",disabled:a=!1,block:s=!1,badge:r=!1,insetRing:i=!1,loading:o=!1,dataTestid:l,type:c="button",title:d,autoFocus:u,classNames:m,onClick:h,onSideEffect:x}=e,p="icon"===n&&r;return(0,H.jsxs)("button",{type:c,title:d,autoFocus:u,className:(0,z.Z)("focus-visible:ring-primary-500 dark:ring-offset-dark-bg inline-flex items-center justify-center border text-sm font-medium focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",("primary"===n||"success"===n||"outline"===n||"error"===n)&&"rounded-md px-4 py-2","primary"===n&&"bg-primary-800 enabled:hover:bg-primary-900 dark:enabled:hover:bg-primary-700 border-transparent text-white","error"===n&&"border-transparent bg-red-700 text-white enabled:hover:bg-red-600 dark:bg-red-800 dark:text-red-100 dark:enabled:hover:bg-red-700","outline"===n&&"dark:text-dark-text border-gray-300 text-gray-700 enabled:hover:bg-gray-200 dark:border-gray-700 dark:enabled:hover:bg-gray-700","icon"===n&&"dark:text-ondark-text-1 text-onlight-text-2 rounded-full border-transparent p-1 enabled:hover:bg-slate-200 dark:enabled:hover:bg-slate-700","link"===n&&"text-ondark-primary rounded border-transparent px-2 enabled:hover:underline","success"===n&&"border-transparent bg-green-500 text-white enabled:hover:bg-green-800 dark:enabled:hover:bg-green-700",a&&"disabled:opacity-75",s&&"w-full",(p||o)&&"relative",i&&"ring-inset focus:ring-offset-0",m||""),disabled:a,onClick:e=>{x&&x(),h&&h(e)},"data-testid":l,children:[t,o&&(0,H.jsx)("span",{className:"absolute inset-0 inline-flex items-center justify-center bg-inherit",children:(0,H.jsx)(Y,{})}),p&&(0,H.jsx)("span",{className:"bg-primary-500 absolute top-1 right-1 h-2 w-2 rounded-full ring-1 ring-white","aria-hidden":"true"})]})}const X=Q;function J(e){const{label:t,checked:n,disabled:s=!1,onChange:r}=e,i=(0,a.useId)();return(0,H.jsxs)("div",{className:"flex items-start",children:[(0,H.jsx)("div",{className:"flex h-5 items-center",children:(0,H.jsx)("input",{id:i,type:"checkbox",className:(0,z.Z)("text-primary-600 focus:ring-primary-500 focus:ring-offset-dark-bg h-4 w-4 rounded border-gray-300 disabled:bg-gray-100 dark:border-gray-600 dark:disabled:bg-gray-600",!n&&"dark:bg-dark-bg"),checked:n,onChange:e=>r&&r(e.target.checked),disabled:s,onClick:e=>e.stopPropagation()})}),t&&(0,H.jsx)("div",{className:"ml-3 text-sm",children:(0,H.jsx)("label",{htmlFor:i,className:s?"text-gray-400 dark:text-gray-500":"text-gray-700: dark:text-dark-text",children:t})})]})}const ee=J;function te(e){const{items:t,value:n,onChange:a}=e;return(0,H.jsx)(H.Fragment,{children:t.map((e=>(0,H.jsx)("div",{className:"mt-2",children:(0,H.jsx)(ee,{label:e.label,checked:n.some((t=>t.id===e.id)),disabled:e.disabled,onChange:t=>((e,t)=>{const s=n.filter((t=>t.id!==e.id));t&&s.push(e),a(s)})(e,t)})},e.id)))})}var ne=n(88389);function ae(e){const{error:t=!1,errorText:n,label:s,placeholder:r,autoFocus:i=!1}=e,o=(0,a.useId)();return(0,H.jsxs)("div",{className:"w-full",children:[s&&(0,H.jsx)("label",{htmlFor:o,className:"dark:text-dark-secondary-text mb-1 block text-sm text-gray-700",children:s}),(0,H.jsxs)("div",{className:"relative rounded-md shadow-sm",children:[(0,H.jsx)("input",Object.assign({name:o,id:o,className:(0,z.Z)("dark:bg-dark-bg dark:text-dark-text dark:border-dark-border-surface block w-full rounded-md border-gray-300 focus:outline-none sm:text-sm",t&&"border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500 dark:border-red-700 dark:text-red-200 dark:placeholder-red-600 dark:focus:ring-red-600"),placeholder:r||"","aria-invalid":t?"true":"false",autoFocus:i},e)),t&&(0,H.jsx)("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:(0,H.jsx)(ne.Z,{className:"h-5 w-5 text-red-500","aria-hidden":"true"})})]}),t&&(0,H.jsx)("p",{className:"dark: mt-2 text-sm text-red-600 dark:text-red-400",id:`${o}-error`,children:n||""})]})}function se(e){const{items:t,selectedItem:n,onChange:a}=e;return(0,H.jsx)("nav",{className:"flex space-x-4","aria-label":"Tabs",children:t.map((e=>{const s=e.icon;return(0,H.jsxs)("button",{onClick:(r=e.id,()=>{const e=t.find((e=>e.id===r));e&&a(e)}),className:(0,z.Z)((null==n?void 0:n.id)===e.id?"bg-primary-200 text-primary-700 dark:bg-primary-800 dark:text-primary-200":"text-onlight-text-3 hover:text-onlight-text-2 dark:text-ondark-text-2 dark:hover:text-ondark-text-1","flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium"),children:[s&&(0,H.jsx)(s,{className:"h-5 w-5"}),e.name,e.extra]},e.id);var r}))})}function re(e){var t;const{text:n,type:a="default",removable:s=!1,children:r,small:i,onClickRemove:o}=e;return(0,H.jsxs)("span",{className:(0,z.Z)("inline-flex items-center rounded-3xl font-medium",{"bg-gray-100 text-gray-800 dark:bg-gray-200/10 dark:text-gray-400":"default"===a,"bg-blue-100 text-blue-800 dark:bg-blue-800/20 dark:text-blue-600":"info"===a,"bg-green-100 text-green-800 dark:bg-green-800/20 dark:text-green-600":"success"===a,"bg-yellow-100 text-yellow-800 dark:bg-yellow-800/20 dark:text-yellow-600":"warning"===a,"bg-red-100 text-red-800 dark:bg-red-700/20 dark:text-red-600":"error"===a},i?"px-3 py-0.5 text-xs":"px-3.5 py-0.5 text-sm"),children:[null!=(t=null!=n?n:r)?t:null,s&&(0,H.jsxs)("button",{type:"button",className:"hover:text-status-red ml-0.5 inline-flex flex-shrink-0 items-center justify-center rounded-full p-1 focus:outline-none",onClick:o,children:[(0,H.jsx)("span",{className:"sr-only",children:"remove option"}),(0,H.jsx)("svg",{className:"h-2.5 w-2.5",stroke:"currentColor",fill:"none",viewBox:"0 0 8 8",children:(0,H.jsx)("path",{strokeLinecap:"round",strokeWidth:"1.5",d:"M1 1l6 6m0-6L1 7"})})]})]})}var ie=n(55660),oe=n(44485),le=n(52323);function ce(e){const{open:t,onClose:n,children:s,title:r,footer:i,closable:o=!0}=e;return(0,H.jsx)(ie.u.Root,{show:t,as:a.Fragment,children:(0,H.jsxs)(oe.V,{as:"div",className:"relative z-10",onClose:n,static:!o,children:[(0,H.jsx)(ie.u.Child,{as:a.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,H.jsx)("div",{className:"fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"})}),(0,H.jsx)("div",{className:"fixed inset-0 z-10 overflow-y-auto",children:(0,H.jsx)("div",{className:"flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0",children:(0,H.jsx)(ie.u.Child,{as:a.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",children:(0,H.jsxs)(oe.V.Panel,{className:"dark:bg-dark-bg dark:text-dark-text relative transform rounded-lg bg-white text-left shadow-xl transition-all",children:[o&&(0,H.jsx)("div",{className:"absolute top-4 right-8",children:(0,H.jsx)(X,{variant:"icon",onClick:n,children:(0,H.jsx)(le.Z,{className:"w-5"})})}),r&&(0,H.jsx)("div",{className:"flex items-center justify-between border-b px-8 py-4 dark:border-gray-600",children:(0,H.jsx)("h1",{className:"text-lg text-gray-800 dark:text-gray-200",children:r})}),s,i&&(0,H.jsx)("div",{className:"flex gap-2 border-t px-8 py-4 dark:border-gray-600",children:i})]})})})})]})})}var de=n(44051);function ue(e){const{value:t,items:n,label:a,onChange:s,displayValue:r,id:i}=e;return(0,H.jsxs)("div",{children:[a&&(0,H.jsx)("label",{className:"dark:text-dark-secondary-text mb-1 block text-sm text-gray-700",children:a}),(0,H.jsx)(de.E,{value:t,onChange:s,children:(0,H.jsx)("div",{className:"dark:bg-dark-bg relative -space-y-px rounded-md bg-white",children:n.map(((e,t)=>(0,H.jsx)(de.E.Option,{value:e,className:({checked:e})=>(0,z.Z)(0===t?"rounded-tl-md rounded-tr-md":"",t===n.length-1?"rounded-bl-md rounded-br-md":"",e?"border-primary-200 bg-primary-50 dark:bg-primary-900/30 dark:border-primary-800":"border-gray-200 dark:border-gray-600","relative flex w-full cursor-pointer flex-col border p-4 focus:outline-none"),children:({active:t,checked:n})=>(0,H.jsxs)("span",{className:"flex items-center text-sm",children:[(0,H.jsx)("span",{className:(0,z.Z)(n?"bg-primary-600 dark:bg-primary-700 border-transparent":"dark:bg-dark-bg border-gray-300 bg-white dark:border-gray-700",t?"ring-primary-500 dark:ring-primary-700 ring-2 ring-offset-2 dark:ring-offset-gray-900":"","flex h-4 w-4 items-center justify-center rounded-full border"),"aria-hidden":"true",children:(0,H.jsx)("span",{className:"dark:bg-dark-bg h-1.5 w-1.5 rounded-full bg-white"})}),(0,H.jsx)(de.E.Label,{as:"span",className:(0,z.Z)(n?"text-primary-900 dark:text-primary-200":"dark:text-dark-text text-gray-900","ml-3 font-medium"),children:r(e)})]})},i?i(e):t)))})})]})}const me=(e,t)=>!(!e||!t)&&(null==e?void 0:e.id)===(null==t?void 0:t.id);function he(e){const{options:t,selected:n,onChange:a,label:s}=e;return(0,H.jsxs)(de.E,{value:n,onChange:a,by:me,children:[(0,H.jsxs)(de.E.Label,{className:"sr-only",children:[" ",s," "]}),(0,H.jsx)("div",{className:"mt-4 space-y-4",children:t.map((e=>(0,H.jsx)(de.E.Option,{value:e,className:({checked:e,active:t})=>(0,z.Z)(e?"dark:border-dark-border-bg border-transparent":"border-onlight-bg-3 dark:border-dark-border-surface",t&&"border-onlight-primary ring-onlight-primary ring-2","hover:dark:bg-dark-hover-bg hover:bg-onlight-bg-2 bg-onlight-bg-1 dark:bg-ondark-bg-2 relative block cursor-pointer rounded-lg border px-6 py-4 shadow-sm focus:outline-none sm:flex sm:justify-between"),children:({active:t,checked:n})=>(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("span",{className:"flex items-center",children:(0,H.jsxs)("span",{className:"flex flex-col text-sm",children:[(0,H.jsx)(de.E.Label,{as:"span",className:"text-onlight-text-1 dark:text-ondark-text-1 font-medium",children:e.name}),e.description&&(0,H.jsx)(de.E.Description,{as:"span",className:"text-onlight-text-2 dark:text-ondark-text-2",children:(0,H.jsx)("span",{className:"block sm:inline",children:e.description})})]})}),e.additional&&(0,H.jsx)(de.E.Description,{as:"span",className:"mt-2 flex text-sm sm:mt-0 sm:ml-4 sm:flex-col sm:text-right",children:(0,H.jsx)("span",{className:"text-onlight-text-1 dark:text-ondark-text-1 font-medium",children:e.additional})}),(0,H.jsx)("span",{className:(0,z.Z)(t?"border":"border-2",n?"border-onlight-primary":"border-transparent","pointer-events-none absolute -inset-px rounded-lg"),"aria-hidden":"true"})]})},e.name)))})]})}function xe(e){const{items:t,activeTabId:n,onChange:a}=e,s=t.find((e=>e.id===n));return(0,H.jsxs)("div",{children:[(0,H.jsxs)("div",{className:"sm:hidden",children:[(0,H.jsx)("label",{htmlFor:"tabs",className:"sr-only",children:"Select a tab"}),(0,H.jsx)("select",{id:"tabs",name:"tabs",className:"focus:border-primary-500 focus:ring-primary-500 dark:bg-dark-bg dark:border-dark-border-bg block w-full rounded-md border-gray-300 py-2 pl-3 pr-10 text-base focus:outline-none sm:text-sm",defaultValue:null==s?void 0:s.id,onChange:e=>{const n=t.find((t=>t.id===e.target.value));n&&a(n.id)},children:t.map((e=>(0,H.jsx)("option",{value:e.id,children:e.name},e.id)))})]}),(0,H.jsx)("div",{className:"hidden sm:block",children:(0,H.jsx)("div",{className:"dark:border-ondark-line-2 border-onlight-line-2 border-b",children:(0,H.jsx)("nav",{className:"-mb-px flex space-x-8","aria-label":"Tabs",children:t.map((e=>(0,H.jsx)("button",{className:(0,z.Z)(e.id===n?"border-primary-700 text-primary-700 dark:text-primary-400 dark:border-primary-400":"dark:hover:text-dark-text dark:text-dark-secondary-text border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700","focus-visible:ring-primary-500 dark:focus-visible:ring-offset-dark-bg whitespace-nowrap border-b-2 py-2 px-1 text-sm font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2"),"aria-current":e.id===n?"page":void 0,onClick:()=>(e=>{a(e.id)})(e),children:e.name},e.id)))})})})]})}function pe(e){const t=(0,a.useId)(),{value:n,label:s,rows:r=4,onChange:i,placeholder:o}=e;return(0,H.jsxs)("label",{className:"block",htmlFor:t,children:[s&&(0,H.jsx)("span",{className:"dark:text-dark-secondary-text mb-1 text-sm text-gray-700",children:s}),(0,H.jsx)("textarea",{rows:r,id:t,className:"focus:border-primary-500 focus:ring-primary-500 dark:bg-dark-bg dark:border-dark-border-surface block w-full rounded-md border-gray-300 shadow-sm sm:text-sm",value:n,onChange:e=>i(e.target.value),placeholder:o})]})}var ge=n(27726);function fe(e){const{isRunning:t}=e,[n,s]=(0,a.useState)(0);(0,a.useEffect)((()=>{let e;return t&&(e=window.setInterval((()=>{s((e=>e+1))}),1e3)),()=>{e&&clearInterval(e)}}),[t]);return(0,H.jsxs)("div",{className:"flex flex-col items-center justify-center gap-1 text-xs",children:[(0,H.jsx)(ge.Z,{className:"h-4 w-4"}),(0,H.jsx)("span",{children:(e=>{const t=e%60;return`${Math.floor(e/60).toString().padStart(2,"0")}:${t.toString().padStart(2,"0")}`})(n)})]})}var ve=n(42683),je=n(56041),be=n(25383);function ye(e){const{text:t,children:n,position:a="top",always:s=!1,rounded:r=!0,noShadow:i=!0,colorModifier:o,size:l}=e;return(0,H.jsx)("span",{className:(0,z.Z)("hover:after:whitespace-pre-line hover:after:content-[attr(aria-label)]",`hint--${a}`,s&&"hint--always",r&&"hint--rounded",i&&"hint--no-shadow",o&&`hint--${o}`,l&&`hint--${l}`),"aria-label":t,children:n})}const ke=ye;function we(e){const{enabled:t,EnabledIcon:n,DisabledIcon:a,type:s="positive",label:r,disabledIconClassName:i,onChange:o,onSideEffect:l,infoText:c}=e,d=(0,H.jsx)(le.Z,{className:"text-primary-600 h-3 w-3"}),u=(0,H.jsx)(je.Z,{className:"text-primary-600 h-3 w-3"}),m="positive"===s;return(0,H.jsxs)(ve.r.Group,{as:"div",className:"flex items-center gap-3",children:[(0,H.jsxs)(ve.r,{checked:t,onChange:e=>{l&&l(),o&&o(e)},className:(0,z.Z)(t&&(m?"bg-primary-600 dark:bg-primary-500":"bg-red-600 dark:bg-red-900"),!t&&(m?"bg-gray-300 dark:bg-gray-700":"dark:bg-dark-border-surface bg-gray-300"),"focus:ring-primary-500 relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2"),children:[(0,H.jsx)("span",{className:"sr-only",children:"Toggle"}),(0,H.jsxs)("span",{className:(0,z.Z)(t?"translate-x-5":"translate-x-0","dark:ring-dark-border-surface pointer-events-none relative inline-block h-5 w-5 transform rounded-full border-2 shadow ring-0 transition duration-200 ease-in-out",m?"bg-white":"bg-dark-text"),children:[(0,H.jsx)("span",{className:(0,z.Z)(t?"opacity-0 duration-100 ease-out":"opacity-100 duration-200 ease-in","absolute inset-0 flex h-full w-full items-center justify-center transition-opacity"),"aria-hidden":"true",children:a?(0,H.jsx)(a,{className:`text-primary-600 h-3 w-3 ${i}`}):m?d:u}),(0,H.jsx)("span",{className:(0,z.Z)(t?"opacity-100 duration-200 ease-in":"opacity-0 duration-100 ease-out","absolute inset-0 flex h-full w-full items-center justify-center transition-opacity"),"aria-hidden":"true",children:n?(0,H.jsx)(n,{className:"text-primary-600 h-3 w-3"}):m?u:d})]})]}),r&&(0,H.jsxs)("span",{className:"dark:text-dark-secondary-text flex items-center gap-2 text-sm text-gray-500",children:[(0,H.jsx)(ve.r.Label,{children:r}),c&&(0,H.jsx)(ke,{text:c,colorModifier:"info",position:"top-right",size:"medium",children:(0,H.jsx)(be.Z,{className:"h-4 w-4"})})]})]})}function Ne(){const[,e]=(0,a.useState)([0,0]);(0,a.useLayoutEffect)((()=>{function t(){e([window.innerWidth,window.innerHeight])}return window.addEventListener("resize",t),t(),()=>window.removeEventListener("resize",t)}),[])}var Ce=n(20202),Se=n(90221),Te=n(995),Ee=n(94011),Ae=n(75915);function _e(e){const{enabled:t,audioFileName:n=c}=e,[s,r]=(0,a.useState)(1),i=(0,a.createRef)(),o=(0,a.useCallback)((()=>{r((e=>e+1)),window.removeEventListener("click",o)}),[]);return(0,a.useEffect)((()=>{null!==i.current&&(i.current.addEventListener("canplaythrough",(()=>{var e;t&&(null==(e=i.current)||e.play().catch((e=>{window.addEventListener("click",o),y.uT(e)})))})),i.current.addEventListener("ended",(()=>{var e;t&&(null==(e=i.current)||e.play().catch((e=>{y.uT(e)})))})))}),[i,t,o]),(0,H.jsx)("audio",{ref:i,src:`assets/notif-sounds/${n}.mp3`,autoPlay:!0},s)}const Ie=e=>{Ae.ZP.dismiss(e)},Le=(e,t)=>{var n;let a;switch(null==t?void 0:t.type){case"success":a=Ce.Z;break;case"warning":a=Se.Z;break;case"error":a=Te.Z;break;default:a=be.Z}Ae.ZP.custom((n=>(0,H.jsx)(ie.u,{appear:!0,show:n.visible,className:"ml-auto w-full max-w-sm",enter:"transform transition ease-in-out duration-300",enterFrom:"translate-x-full",enterTo:"translate-x-0",leave:"transform transition ease-in-out duration-300",leaveFrom:"translate-x-0",leaveTo:"translate-x-full",children:(0,H.jsx)("div",{className:"dark:bg-dark-surface pointer-events-auto overflow-hidden rounded-lg bg-white shadow-lg ring-1 ring-black ring-opacity-5",children:(0,H.jsx)("div",{className:"p-4",children:(0,H.jsxs)("div",{className:"flex items-center",children:[(0,H.jsx)("div",{className:"flex-shrink-0",children:(0,H.jsx)(a,{className:(0,z.Z)("h-6 w-6",("info"===(null==t?void 0:t.type)||void 0===(null==t?void 0:t.type))&&"text-blue-400","success"===(null==t?void 0:t.type)&&"text-green-400","warning"===(null==t?void 0:t.type)&&"text-yellow-400","error"===(null==t?void 0:t.type)&&"text-red-400"),"aria-hidden":"true"})}),(0,H.jsx)("div",{className:"ml-3 w-0 flex-1 pt-0.5",children:(0,H.jsx)("p",{className:"dark:text-dark-text text-sm text-gray-900",children:e})}),(null==t?void 0:t.audio)&&(0,H.jsxs)("div",{className:"dark:text-dark-text flex-shrink-0 pt-0.5",children:[(0,H.jsx)(Ee.Z,{className:"h-5 w-5"}),(0,H.jsx)(_e,{enabled:n.visible&&t.audio,audioFileName:t.audioFileName})]}),(0,H.jsx)("div",{className:"ml-4 flex flex-shrink-0",children:(0,H.jsxs)(Q,{variant:"icon",onClick:()=>Ae.ZP.dismiss(n.id),children:[(0,H.jsx)("span",{className:"sr-only",children:"Close"}),(0,H.jsx)(le.Z,{className:"h-5 w-5","aria-hidden":"true"})]})})]})})})})),{duration:null!=(n=null==t?void 0:t.duration)?n:5e3,id:null==t?void 0:t.id})};let Re=function(e){return e.PERSON="PERSON",e.VEHICLE="MOVING VEHICLE",e}({});let De=function(e){return e.RESOLVED="Resolved",e.IN_PROGRESS="In Progress",e.PENDING="Pending",e}({});const Pe=[De.RESOLVED,De.IN_PROGRESS,De.PENDING];let Me=function(e){return e.ALL_TIME="All Time",e.PAST_MINUTE="Past Minute",e.PAST_HALF_HOUR="Past Half Hour",e.PAST_HOUR="Past Hour",e.PAST_SIX_HOURS="Past 6 Hours",e.PAST_12_HOURS="Past 12 Hours",e.PAST_24_HOURS="Past 24 Hours",e.PAST_WEEK="Past Week",e.PAST_MONTH="Past Month",e.PAST_THREE_MONTHS="Past 3 Months",e.CUSTOM_RANGE="Custom Range",e.CUSTOM_TIME="Custom Time",e}({});const Oe=["AXIS","ACS","ONVIF","AXIS_SIREN"];let Fe=function(e){return e.ignore="ignore",e.P0="P0",e.default="default",e}({});let Ze=function(e){return e.PENDING="Pending",e.IN_PROGRESS="In Progress",e.RESOLVED="Resolved",e}({}),qe=function(e){return e.MANUAL_TALKDOWN="Manual audio talkdown",e.CALL_SMS_LOGS="Call SMS logs",e.CHANGE_STATUS="Change status",e}({});let Ue=function(e){return e.TWILIO_CALLS="Twilio calls",e.Twilio_SMS="Twilio sms",e}({}),Ve=function(e){return e.SUCCESS="SUCCESS",e.PENDING="PENDING",e.FAILED="FAILED",e}({}),$e=function(e){return e.MANUAL="manual",e.AUTOMATED="automated",e}({}),ze=function(e){return e.ADD_EVENT="Add new event",e.CHANGE_STATUS="Change Status",e.UPDATE_TAP="Update TAP",e.ADD_COMMENT="Add comment",e.VIEW_ALARM="View alarm",e.MANUAL_TALKDOWN="Manual audio talkdown",e.CALL_SMS_LOGS="Call SMS logs",e}({}),He=function(e){return e.STATIC="static",e.DYANMIC="dynamic",e}({}),Be=function(e){return e.OFF="off",e.INACTIVE="inactive",e.ALWAYS="always",e}({});function We(e,t,n=c,a){if(e===Be.INACTIVE&&"hidden"===document.visibilityState||e===Be.ALWAYS){const e=new Notification("Notification from Hakimo",{body:t,icon:"/assets/hakimo.svg",silent:!0}),s=new Audio;s.src=`assets/notif-sounds/${n}.mp3`,s.load(),s.play().catch((e=>y.uT(e))),e.onclick=function(t){e.close(),a&&a(this,t),window.focus()}}}function Ge(e,t){return e.permissions.includes(t)}function Ke(){return Ge(j(),"camera/live:view")}function Ye(){return Ge(j(),"audio_devices:modify")}function Qe(){return Ge(j(),"location_alarm:update")}function Xe(){return Ge(j(),"audio_devices/mappings:modify")}function Je(){return Ge(j(),"camera:update/armed")}function et(){return Ge(j(),"camera:update")}const tt=function(){return(0,H.jsx)("div",{className:"p-4",children:(0,H.jsx)(B,{children:"You are not authorized to view this content"})})};function nt(e,t,n){return a=>(0,H.jsx)(at,{permissions:t,fallback:n,children:(0,H.jsx)(e,Object.assign({},a))})}function at(e){const{children:t,permissions:n,fallback:a}=e,{permissions:s}=j();return n.every((e=>s.includes(e)))?t:a||(0,H.jsx)(tt,{})}const st={filterPredicate:(e,t)=>t.name.toLowerCase().includes(e.toLowerCase()),isEqual:(e,t)=>e===t.name,customItemBuilder:(e,t)=>({id:`custom-option-${t.length+1}`,name:e}),isCustomItem:e=>e.id.startsWith("custom-option-")};function rt(e,t,n,a,s){if(null==s||!s.customItemBuilder){if(null==s||!s.staticItems)throw Error("staticItems is required if customItemBuilder is not provided");return s.staticItems.filter((t=>n(e,t)))}if(null==s||!s.isCustomItem)throw Error("isCustomItem is required if customItemBuilder is provided");const r=null!=s&&s.staticItems?null==s?void 0:s.staticItems.concat(t.filter(s.isCustomItem)):t;if(""===e)return r;const i=r.filter((t=>n(e,t)));return r.some((t=>a(e,t)))?i:i.concat(s.customItemBuilder(e,r))}const{filterPredicate:it,isEqual:ot,customItemBuilder:lt,isCustomItem:ct}=st;function dt(e,t,n){return rt(e,t,it,ot,{customItemBuilder:lt,isCustomItem:ct,staticItems:n})}function ut(e,t,n){return function(e,t,n,a,s){if(null==s||!s.customItemBuilder){if(null==s||!s.staticItems)throw Error("staticItems is required if customItemBuilder is not provided");return s.staticItems.filter((n=>t(e,n)))}if(null==s||!s.isCustomItem)throw Error("isCustomItem is required if customItemBuilder is provided");const r=(null==s?void 0:s.staticItems)||[],i=a&&s.isCustomItem(a)?r.concat(a):r;if(""===e)return i;const o=i.filter((n=>t(e,n)));return a&&n(e,a)?o:o.concat(s.customItemBuilder(e,i))}(e,it,ot,t,{customItemBuilder:lt,isCustomItem:ct,staticItems:n})}var mt=n(95619);function ht(e,t){return mt.Pf(e,{showDialog:!0,fallback:t||(0,H.jsx)("div",{className:"p-4",children:(0,H.jsxs)(B,{children:["An error occurred."," ",(0,H.jsx)("a",{href:window.location.pathname,className:"hover:text-primary-500 underline",children:"Click here to reload"})," ","this page."]})})})}var xt=n(65058),pt=n(87809);const gt=(0,xt.cn)(null),ft=(0,xt.cn)(null),vt=(0,pt.O4)("alarmAudioNotification",!1),jt=(0,pt.O4)("systemNotification",Be.OFF),bt=(0,xt.cn)(void 0);function yt(e){return(t,n)=>{kt(e,t,n)}}function kt(e,t,n){(0,b.j)(e,t,n)}function wt(e){0!==Object.keys(e).length&&kt("use_filters",{filters:e})}function Nt(){const e=g();return t=>e(`/v2/orm/alarm_type/names?name=${t}`,{responseModifier:async e=>(await e.json()).payload})}var Ct=n(21067);const St=function(e,t){const n=g();return(0,Ct.useQuery)(Object.assign({retry:!1,refetchOnWindowFocus:!1,queryFn:async function(){return n(e,{noAuth:null==t?void 0:t.noAuth,responseModifier:null==t?void 0:t.responseModifier})}},t))};function Tt(e){const t=new Request("/v2/orm/location_alarms/pending");return St(t,{queryKey:["location_alarms","pending"],responseModifier:async e=>{const t=await e.json();return t.payload&&t.payload.length>0?String(t.payload[0]):void 0},enabled:!1,cacheTime:0,onSuccess:e})}function Et(e){const t=new Request("/v2/orm/location_alarms/pending/count");return St(t,{queryKey:["location_alarms","count"],responseModifier:async e=>(await e.json()).payload,cacheTime:0,refetchInterval:e,refetchIntervalInBackground:!0})}function At(e){const t=new Request(`/v2/orm/alarm/${e}`);return St(t,{queryKey:["alarms",e],responseModifier:async e=>(await e.json()).payload})}function _t(e){const{id:t,debug:n=!1,sharedToken:a,isSharedLocationAlarm:s,refetchInterval:r,boxes:i}=e,o=new Request(s?i?`/shared/v2/location_alarm/media?sharedToken=${a}&id=${t}&includeBoxes=true`:`/shared/v2/location_alarm/media?sharedToken=${a}&id=${t}`:a?`/shared/v2/alarm/media?sharedToken=${a}`:n?`/v2/orm/alarm/debug-media/${t}`:i?`/v2/orm/alarm/media/${t}?includeBoxes=true`:`/v2/orm/alarm/media/${t}`);return St(o,{queryKey:["alarms","media",n,t],responseModifier:async e=>(await e.json()).payload,refetchInterval:r,cacheTime:0,noAuth:"string"==typeof a})}function It(e,t,n){const a=new Request(`/v2/orm/alarm/update/${e}?${t}`);return St(a,{queryKey:["alarm_updates",e,{searchParams:t}],responseModifier:async e=>(await e.json()).payload,refetchInterval:n})}function Lt(e,t,n,a=!1,s=!1){const r=new Request(`/v2/orm/alarm?${e}`);return St(r,{queryKey:["alarms",{searchParams:e}],responseModifier:async e=>(await e.json()).payload,refetchInterval:t,refetchIntervalInBackground:!0,onSuccess:n,enabled:!a,keepPreviousData:s})}function Rt(e){const t=new Request(`/v2/orm/camera/livestream/${e}`);return St(t,{queryKey:["livestream-url",e],responseModifier:async e=>(await e.json()).payload,cacheTime:0,refetchInterval:6e5})}function Dt(e){const t=new Request(e?`/v2/orm/tenant/comments?searchString=${e}`:"/v2/orm/tenant/comments");return St(t,{queryKey:["comments"],responseModifier:async e=>(await e.json()).payload.map(((e,t)=>({id:String(t),name:e})))})}function Pt(e,t){const n=new Request(`/v2/orm/location_alarms/status/${e}`);return St(n,{queryKey:["location_alarm_updates",e],responseModifier:async e=>(await e.json()).payload,refetchInterval:t})}function Mt(e,t,n,a=!1,s=!1){const r=new Request(`/v2/orm/location_alarms?${e}`);return St(r,{queryKey:["locationAlarms",{searchParams:e}],responseModifier:async e=>(await e.json()).payload,refetchInterval:t,refetchIntervalInBackground:!0,onSuccess:n,enabled:!a,keepPreviousData:s})}function Ot(e,t,n){const a=new Request(`/v2/orm/alarm/neighbors/${e}?${t}`);return St(a,{queryKey:["alarm-neighbors",e,{searchParams:t}],responseModifier:async e=>(await e.json()).payload,refetchInterval:n})}const Ft=function(e,t={}){const n=(0,Ct.useQueryClient)(),a=g(),{responseModifier:s,getBody:r,onSuccess:i,onSuccessInvalidationKeys:o}=t;return(0,Ct.useMutation)((async n=>{const i=new Request(e,{body:r?r(n):JSON.stringify(n)});return a(i,{noAuth:null==t?void 0:t.noAuth,responseModifier:s})}),Object.assign({},t,{onSuccess:(e,t,a)=>{null==o||o.forEach((e=>{n.invalidateQueries(e)})),i&&i(e,t,a)}}))};function Zt(e,t){const n=new Request(`/v2/orm/alarm/bug/${e}`,{method:"POST"});return Ft(n,{onSuccess:t})}function qt(e,t,n){const a=new URLSearchParams;"alarmId"in e?a.set("alarm_id",e.alarmId):a.set("location_id",e.locationId);const s=`/v2/orm/sop/find?${a.toString()}`,r=new Request(s);return St(r,{queryKey:["sop",e],responseModifier:async e=>{const t=(await e.json()).payload;try{const e=JSON.parse(t.sop_text);return{sop_text:e.sop_overview,sop_workflow:e.sop_workflow,id:t.id,scan_sop:e.scan_sop}}catch(n){return{sop_text:t.sop_text,id:t.id}}},onSuccess:t,onError:n})}function Ut(e,t,n,a,s){const r=new URLSearchParams;t&&r.append("alarmId",t),n&&r.append("locationAlarmId",n),s&&r.append("escalationId",s);const i=`/v2/orm/camera/audio/${e}?${r.toString()}`,o=new Request(i,{method:"POST"});return Ft(o,{onSuccess:a,getBody:e=>e,onSuccessInvalidationKeys:[["alarm_updates",null!=t?t:"",null!=n?n:""]]})}function Vt(e){const t=new Request(`/shared/v2/alarm?sharedToken=${e}`);return St(t,{queryKey:["alarms","shared",e],responseModifier:async e=>(await e.json()).payload,noAuth:!0})}function $t(e,t,n){const a=new Request(`/shared/v2/alarm/neighbors?sharedToken=${e}&${t}`);return St(a,{queryKey:["alarm-neighbors","shared",e,{searchParams:t}],responseModifier:async e=>(await e.json()).payload,refetchInterval:n,noAuth:!0})}function zt(e,t,n){const a=new Request(`/shared/v2/alarm/updates?sharedToken=${e}&${t}`);return St(a,{queryKey:["alarm_updates","shared",e,{searchParams:t}],responseModifier:async e=>(await e.json()).payload,refetchInterval:n,noAuth:!0})}function Ht(e){const t=new Request(`/shared/v2/location_alarm?sharedToken=${e}`);return St(t,{queryKey:["locationAlarms","shared",e],responseModifier:async e=>(await e.json()).payload,noAuth:!0})}function Bt(e,t,n,a){const s=function(e,t,n,a){let s="",r="";switch(t){case"alarm":s="alarm";break;case"location-alarm":s="location_alarm";break;case"live-view":s="live_view"}return r=`/v2/orm/shared/${s}/token/${e}?duration=${n}&durationUnit=${a}`,r}(e,a,t,n),r=new Request(s);return St(r,{responseModifier:async e=>(await e.json()).payload,enabled:!1,cacheTime:0})}function Wt(e,t){const n=new Request(`/v2/orm/location_alarms/${e}`);return St(n,{queryKey:["locationAlarms",e],responseModifier:async e=>(await e.json()).payload,refetchInterval:null!=t&&t})}function Gt(e,t){const n=new Request(`/v2/orm/alarm/update/${e}`,{method:"PATCH"});return Ft(n,{onSuccessInvalidationKeys:[["alarms"],["alarm",e],["alarm_updates",e]],onSuccess:t})}function Kt(e,t){const n=new Request(`/v2/orm/location_alarms/update/${e}`,{method:"POST"});return Ft(n,{onSuccessInvalidationKeys:[["locationAlarms"],["locationAlarms",e],["location_alarm_updates"]],onSuccess:t})}function Yt(e,t,n){const a=new Request(`/v2/orm/sop/update/${e}`,{method:"POST",headers:{"Content-Type":"application/json"}});return Ft(a,{onSuccessInvalidationKeys:[["sop"]],onSuccess:t,onError:n})}function Qt(e){const t=new Request("/v2/orm/location_alarms/view",{method:"POST"});return Ft(t,{onSuccessInvalidationKeys:[["locationAlarms"],["location_alarm_updates"]],onSuccess:e})}function Xt(e,t){const n=new Request("/v2/orm/audio_devices",{method:"POST"});return Ft(n,{onSuccess:e,onSuccessInvalidationKeys:[["audio"]],onError:t})}function Jt(e){const t=new Request("/v2/orm/audio_devices/mapping",{method:"POST"});return Ft(t,{onSuccess:e,onSuccessInvalidationKeys:[["audio"]]})}function en(e){const t=new Request("/v2/orm/audio_devices/mapping",{method:"DELETE"});return Ft(t,{onSuccess:e,onSuccessInvalidationKeys:[["audio"]]})}function tn(e){const t=e.length>0?`?${e}`:"",n=new Request(`/v2/orm/audio_devices${t}`);return St(n,{queryKey:["audio",{searchParams:e}],responseModifier:async e=>(await e.json()).payload})}function nn(e,t){const n=new Request("/v2/orm/audio_devices",{method:"PATCH"});return Ft(n,{onSuccess:e,onSuccessInvalidationKeys:[["audio"]],onError:t})}function an(e){const t=new Request("/auth/login",{method:"POST"});return Ft(t,{onSuccess:e,noAuth:!0})}function sn(e){const t=new Request("/v2/orm/camera",{method:"POST"});return Ft(t,{onSuccessInvalidationKeys:[["cameras"]],onSuccess:e})}function rn(e,t){const n=new Request(`/v2/orm/camera/${e}`);return St(n,{queryKey:["cameras",e],responseModifier:async e=>(await e.json()).payload,onSuccess:t,staleTime:6048e5})}function on(e){const t=e.length>0?`?${e}`:"",n=new Request(`/v2/orm/camera${t}`);return St(n,{queryKey:["cameras",{searchParams:e}],responseModifier:async e=>(await e.json()).payload})}function ln(e){const t=g();return n=>t(`/v2/orm/camera/names?name=${n}${e?`&${e}`:""}`,{responseModifier:async e=>(await e.json()).payload})}function cn(e){const t=g();return n=>t(`/shared/v2/camera/wss?sharedToken=${n}`,{responseModifier:async e=>(await e.json()).payload,tap:e})}function dn(e,t){const n=g();return()=>n(`/v2/orm/camera/videoPlayback/${e}/${t}`,{responseModifier:async e=>(await e.json()).playlist_url})}function un(e,t,n){const a=new Request(`/v2/orm/camera/videoPlayback/${e}/${t}`);return St(a,{queryKey:[e,t],cacheTime:0,responseModifier:async e=>(await e.json()).playlist_url,onSuccess:n})}function mn(e,t,n,a){const s=new Request(`/v2/orm/camera/${e}`,{method:"PATCH"});return Ft(s,{onSuccessInvalidationKeys:a?[["cameras"]]:[["cameras"],["cameras",e]],onSuccess:t,onError:n})}function hn(e,t,n,a){const s=new Request(`/v2/orm/camera/${e}`,{method:"PATCH"});return Ft(s,{onSuccessInvalidationKeys:a?[["cameras"]]:[["cameras"],["cameras",e]],onSuccess:t,onError:n})}function xn(e,t,n){const a=new Request(`/v2/orm/camera/${e}/${t}`,{method:"PATCH"});return Ft(a,{onSuccessInvalidationKeys:[["cameras",e]],onSuccess:n})}function pn(e){const t=new Request("/v2/orm/dcp",{method:"POST"});return Ft(t,{onSuccessInvalidationKeys:[["dcps"],["doors"]],onSuccess:e})}function gn(e){const t=new Request(`/v2/orm/dcp/${e}`);return St(t,{queryKey:["dcp",e],responseModifier:async e=>(await e.json()).payload})}function fn(e){const t=new Request(`/v2/orm/dcp/${e}/image-url`);return St(t,{responseModifier:async e=>(await e.json()).payload})}function vn(e,t){const n=new Request(`/v2/orm/dcp/${e}`,{method:"DELETE"});return Ft(n,{onSuccessInvalidationKeys:[["doors"]],onSuccess:t})}function jn(e,t){const n=new Request(`/v2/orm/dcp/${e}`,{method:"PATCH"});return Ft(n,{onSuccessInvalidationKeys:[["dcps"],["dcp",e]],onSuccess:t})}function bn(e){const t=new Request("/v2/orm/door_groups",{method:"POST"});return Ft(t,{onSuccessInvalidationKeys:[["door_groups"]],onSuccess:e})}function yn(e){const t=`/v2/orm/door_groups/${e.doorGroupId}/doors`,n=new Request(t,{method:"PATCH"});return Ft(n,{onSuccessInvalidationKeys:[["doors"]],onSuccess:e.onSuccess})}function kn(e,t){const n=new Request(`/v2/orm/door_groups/${e}`,{method:"DELETE"});return Ft(n,{onSuccessInvalidationKeys:[["door_groups"]],onSuccess:t})}function wn(e){const t=new Request(`/v2/orm/door_groups?${e}`);return St(t,{queryKey:["door_groups",{searchParams:e}],responseModifier:async e=>(await e.json()).payload})}function Nn(e){const t=g();return n=>t(`/v2/orm/door_groups?name=${n}`,{responseModifier:async e=>(await e.json()).payload.items.map((e=>({id:String(e.id),name:e.name}))),tap:e})}function Cn(e){const t=new Request("/v2/orm/door_groups/doors",{method:"DELETE"});return Ft(t,{onSuccessInvalidationKeys:[["doors"],["door_groups"]],onSuccess:e})}function Sn(e,t){const n=new Request(`/v2/orm/door_groups/${e}`,{method:"PUT"});return Ft(n,{onSuccessInvalidationKeys:[["door_groups"]],onSuccess:t})}function Tn(e,t){const n=`/v2/orm/door_groups/${String(e)}/procConfigs`,a=new Request(n,{method:"PATCH"});return Ft(a,{onSuccessInvalidationKeys:[["door_groups"],["door_groups",String(e)]],onSuccess:t})}function En(e){const t=new Request(`/v2/orm/door?${e}`);return St(t,{queryKey:["doors",{searchParams:e}],responseModifier:async e=>(await e.json()).payload})}function An(){const e=g();return t=>e(`/v2/orm/door/names?name=${t}`,{responseModifier:async e=>(await e.json()).payload})}function _n(){const e=g();return t=>e(`/v2/orm/employee/names?name=${t}`,{responseModifier:async e=>(await e.json()).payload})}function In(){const e=new Request("/v2/orm/tenant/tableau");return St(e,{queryKey:["insights","tableau"],responseModifier:async e=>(await e.json()).payload})}function Ln(e,t){const n=new Request("/v2/orm/location_incidents/",{method:"POST",headers:{"Content-Type":"application/json"}});return Ft(n,{onSuccessInvalidationKeys:[["locationAlarms"]],onSuccess:e,onError:t})}function Rn(e,t){const n=new Request("/v2/orm/location_incidents/resolve",{method:"PUT",headers:{"Content-Type":"application/json"}});return Ft(n,{onSuccess:e,onError:t})}function Dn(e){const t=`/v2/orm/locations/${e.locationId}/door`,n=new Request(t,{method:"PATCH"});return Ft(n,{onSuccessInvalidationKeys:[["doors"]],onSuccess:e.onSuccess})}function Pn(e){const t=new Request("/v2/orm/locations",{method:"POST"});return Ft(t,{onSuccessInvalidationKeys:[["locations"]],onSuccess:e})}function Mn(e,t,n,a){const s=new Request(`/v2/orm/locations/${e}/${t}/contacts/${n}`,{method:"DELETE"});return Ft(s,{onSuccessInvalidationKeys:[["location-contacts"]],onSuccess:a})}function On(e){const t=new Request(`/v2/orm/locations/${e}`);return St(t,{queryKey:["locationId",e],responseModifier:async e=>(await e.json()).payload})}function Fn(e){const t=new Request(`/v2/orm/locations/${e}/contacts`);return St(t,{queryKey:["location-contacts",{locationId:e}],responseModifier:async e=>(await e.json()).payload})}function Zn(e){const t=new Request(`/v2/orm/locations?${e}`);return St(t,{queryKey:["locations",{searchParams:e}],responseModifier:async e=>(await e.json()).payload})}function qn(e){const t=g();return n=>t(`/v2/orm/locations?name=${n}`,{responseModifier:async e=>(await e.json()).payload.items.map((e=>({id:String(e.id),name:e.name}))),tap:e})}function Un(e,t){const n=new Request(`/v2/orm/tenant/monitoring/window?location_id=${e}&tenant_id=${t}`);return St(n,{queryKey:["tenant_monitoring_window",{locationId:e,tenantId:t}],responseModifier:async e=>(await e.json()).payload[t]})}function Vn(e,t){const n=new Request(`/v2/orm/locations/${t}`,{method:"PATCH"});return Ft(n,{onSuccessInvalidationKeys:[["locationId",t.toString()]],onSuccess:e})}function $n(e,t){const n=new Request(`/v2/orm/locations/${e}/contacts`,{method:"POST"});return Ft(n,{onSuccessInvalidationKeys:[["location-contacts"]],onSuccess:t})}function zn(e){const t=new Request("/v2/orm/tenant/monitoring/window",{method:"PATCH"});return Ft(t,{onSuccess:e,onSuccessInvalidationKeys:[["tenant_monitoring_window"]]})}function Hn(e,t){const n=new Request(`/v2/orm/locations/${e}/floorplan`,{method:"PUT"});return Ft(n,{onSuccess:t,onSuccessInvalidationKeys:[["locationId",e]],getBody:e=>e})}function Bn(){const e=new Request("/v2/orm/escalations",{method:"POST"});return Ft(e,{onSuccessInvalidationKeys:[["scan-escalations"]]})}function Wn(e,t){const n=new Request(`/v2/orm/escalations/${e}/events`);return St(n,{queryKey:["escalation_events",e],responseModifier:async e=>(await e.json()).payload,refetchInterval:t})}function Gn(e){const t=new Request(`/v2/orm/escalations?${e}`);return St(t,{queryKey:["scan-escalations",{searchParams:e}],responseModifier:async e=>(await e.json()).payload})}function Kn(e){const t=new Request(`/v2/orm/escalations/${e}`,{method:"PUT"});return Ft(t,{onSuccessInvalidationKeys:[["scan-escalations"]]})}const Yn="^^^",Qn="!HAKIMO_NEGATIVE!";function Xn(e,t){const n=new Request(`/v2/orm/tenant/audit-logs?${e}`);return St(n,{queryKey:["audit-logs",{searchParams:e}],responseModifier:async e=>(await e.json()).payload,refetchInterval:t})}function Jn(){const e=new Request("/v2/orm/tenant/sourceSystems");return St(e,{queryKey:["sourceSystems"],responseModifier:async e=>(await e.json()).payload.map((e=>({id:e,name:e})))})}function ea(e){const t=g();return n=>t(`/v2/orm/timezones?query=${n}`,{responseModifier:async e=>(await e.json()).payload,tap:e})}function ta(){const e=g();return t=>e(`/v2/orm/source_entity/names?name=${t}`,{responseModifier:async e=>(await e.json()).payload})}function na(e,t){const n=new Request(`/v2/orm/tenant/${e}`);return St(n,{queryKey:["tenant",e],responseModifier:async e=>(await e.json()).payload,onSuccess:t})}function aa(e){const t=new Request("/v2/orm/tenant/monitoring/disarm",{method:"PATCH"});return Ft(t,{onSuccessInvalidationKeys:[["tenant_monitoring_window"]],onSuccess:e})}const sa="VR6AewLTigWG4xSOukaG",ra="https://api.elevenlabs.io/v1/text-to-speech";function ia(e,t){const n=g(),[s,r]=(0,a.useState)(!1);return{fetchAudio:a=>{r(!0);const s={text:a,model_id:"eleven_multilingual_v2",voice_settings:{similarity_boost:.5,stability:.75,use_speaker_boost:!0}},i=new Request(`${ra}/${sa}`,{method:"POST",headers:{"Content-Type":"application/json","xi-api-key":e,Accept:"audio/mpeg"},body:JSON.stringify(s)});return n(i,{responseModifier:async e=>{r(!1);const t=await e.blob();return{audioUrl:URL.createObjectURL(t),file:new File([t],Date.now()+".mpeg")}},noAuth:!0,tap:t})},isLoading:s}}function oa(e){const t=new Request("/v2/orm/user/sso",{method:"POST"});return Ft(t,{onSuccessInvalidationKeys:[["users"],["user","profile"]],onSuccess:e})}function la(e){const t=new Request("/v2/orm/user",{method:"PATCH"});return Ft(t,{onSuccessInvalidationKeys:[["users"],["user","profile"]],onSuccess:e})}function ca(){const e=new Request("/v2/orm/user/profile");return St(e,{queryKey:["user","profile"],responseModifier:async e=>(await e.json()).payload})}function da(e,t){const n=new Request(`/v2/orm/user?${e}`);return St(n,{queryKey:["users",e],responseModifier:async e=>(await e.json()).payload,onSuccess:t})}function ua(){const e=new Request("/v2/orm/user/roleOptions");return St(e,{queryKey:["roles"],responseModifier:async e=>(await e.json()).payload})}function ma(e={}){const{page:t,pageSize:n,filters:a,tenants:s}=e,r=new URLSearchParams;return a&&(r.append("emails",a.emails.join(Yn)),r.append("names",a.names.join(Yn)),r.append("roles",a.roles.join(Yn)),r.append("enabled",function(e){const t=[];e.showEnabled&&t.push("true");e.showNotEnabled&&t.push("false");return t.join(Yn)}(a.enabled))),t&&r.append("page",String(t)),n&&r.append("pageSize",String(n)),s&&r.append("listByTenants",s.join(Yn)),r.toString()}function ha(e,t){const n=new Request(`/v2/orm/alarm_type/notifications/${e}`,{method:"DELETE"});return Ft(n,{onSuccessInvalidationKeys:[["alarm-notification-preference"]],onSuccess:t})}function xa(){const e=new Request("/v2/orm/alarm_type/notifications");return St(e,{queryKey:["alarm-notification-preference"],responseModifier:async e=>{const t=await e.json();return{default_notification_sound:t.default.notification_sound,alarm_notification_mapping:t.payload}}})}function pa(e){const t=new Request("/v2/orm/alarm_type/notifications",{method:"PUT"});return Ft(t,{onSuccessInvalidationKeys:[["alarm-notification-preference"]],responseModifier:async e=>(await e.json()).payload,onSuccess:e})}function ga(e){const t=new Request(`/v2/orm/voice/twilio/call_details/${e}`);return St(t,{queryKey:["twilio_call_details",e],responseModifier:async e=>(await e.json()).payload})}function fa(e,t,n){let a="/v2/orm/voice/twilio/token";e&&(a+=`?location_tenant_id=${e}`);const s=new Request(a);return St(s,{queryKey:["voice-twilio-token"],responseModifier:async e=>(await e.json()).token,onSuccess:t,onError:n,cacheTime:0,refetchInterval:33e5})}function va(e){const{title:t,subtitle:n,children:a,secondary:s}=e;return(0,H.jsxs)("div",{className:"flex flex-col overflow-hidden rounded-xl",children:[(0,H.jsxs)("div",{className:"flex h-16 items-center justify-between bg-white dark:bg-gray-800",children:[(0,H.jsxs)("div",{className:"px-6",children:[(0,H.jsx)("h3",{className:"dark:text-dark-text font-medium leading-6 text-gray-800 dark:bg-gray-800",children:t}),n&&(0,H.jsx)("p",{className:"mt-1 max-w-2xl text-sm text-gray-500 dark:text-gray-400",children:n})]}),s&&(0,H.jsx)("div",{children:s})]}),(0,H.jsx)("div",{className:"min-h-[4rem] flex-1 overflow-auto bg-white dark:bg-gray-800",children:a})]})}const ja=function(e){const{children:t}=e;return(0,H.jsx)("div",{className:"flex h-full items-center justify-center",children:t})};function ba(e){const{items:t,align:n="horizontal"}=e;return(0,H.jsx)("dl",{className:"dark:divide-dark-border-bg dark:border-dark-border-bg divide-y divide-gray-200",children:t.map(((e,t)=>(0,H.jsxs)("div",{className:(0,z.Z)("py-4","horizontal"===n&&"sm:grid sm:grid-cols-2 sm:gap-4"),children:[(0,H.jsxs)("dt",{className:"dark:text-dark-secondary-text flex gap-2 text-sm font-medium text-gray-500",children:[e.name,e.infoText&&(0,H.jsx)(ye,{text:e.infoText,colorModifier:"info",position:"top-right",size:"large",children:(0,H.jsx)($.Z,{className:"h-5 w-5"})})]}),(0,H.jsx)("dd",{className:(0,z.Z)("dark:text-dark-text mt-1 whitespace-pre-wrap text-sm text-gray-900","horizontal"===n&&"sm:mt-0 sm:justify-self-end"),children:e.value})]},t)))})}function ya(){return(0,H.jsx)("span",{className:"mx-2 h-1 w-1 bg-gray-400 dark:bg-gray-600","aria-hidden":"true"})}var ka=n(99828),wa=n(24183);function Na(e){switch(e){case"yellow":return"hakimo-yellow";case"red":return"status-red";case"green":return"status-green";case"orange":return"status-orange";case"emerald":return"status-emerald";default:return"primary-700"}}function Ca(e){const{title:t,onToggle:n,isExpanded:a,tagColor:s}=e;return(0,H.jsxs)("div",{children:[(0,H.jsxs)("div",{className:"bg-onlight-bg-2 dark:bg-ondark-bg-3 relative flex items-center justify-between rounded p-2",children:[s&&(0,H.jsx)(ka.Z,{className:`absolute top-0 left-0 h-5 w-5 text-${Na(s)}`}),(0,H.jsx)("h2",{className:"dark:text-dark-text pl-5 font-medium text-gray-800",children:t}),(0,H.jsx)(Q,{variant:"icon",title:(0,z.Z)(a?"Collapse":"Expand"),onClick:()=>n(),children:(0,H.jsx)(wa.Z,{className:(0,z.Z)("h-5 w-5 transition duration-300",a&&"rotate-90 transform")})})]}),a&&(0,H.jsx)("div",{children:e.children})]})}function Sa(e){const{full:t=!1,lg:n=!1}=e;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("span",{className:"hidden dark:inline-block",children:(0,H.jsx)("img",{className:(0,z.Z)("w-auto",n?"h-16":"h-8"),src:`assets/hakimo${t?"-full":""}-dark.svg`,alt:"Hakimo logo"})}),(0,H.jsx)("span",{className:"inline-block dark:hidden",children:(0,H.jsx)("img",{className:(0,z.Z)("w-auto",n?"h-16":"h-8"),src:`assets/hakimo${t?"-full":""}.svg`,alt:"Hakimo logo"})})]})}const Ta=Sa;var Ea=n(77350),Aa=n(11569),_a=n(92215);function Ia(){return(0,H.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[(0,H.jsx)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),(0,H.jsx)("path",{fill:"currentColor",d:"M6 2v6h.01L6 8.01 10 12l-4 4 .01.01H6V22h12v-5.99h-.01L18 16l-4-4 4-3.99-.01-.01H18V2H6zm10 14.5V20H8v-3.5l4-4 4 4zm-4-5-4-4V4h8v3.5l-4 4z"})]})}function La(e){return(0,H.jsx)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 96 960 960"},e,{children:(0,H.jsx)("path",{d:"M570 936q-24 0-42-18t-18-42V276q0-24 18-42t42-18h210q24 0 42 18t18 42v600q0 24-18 42t-42 18H570Zm-390 0q-24 0-42-18t-18-42V276q0-24 18-42t42-18h210q24 0 42 18t18 42v600q0 24-18 42t-42 18H180Zm0-660v600h210V276H180Zm210 600H180h210Z"})}))}function Ra(e){return(0,H.jsx)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 96 960 960",fill:"currentColor"},e,{children:(0,H.jsx)("path",{d:"M130 626q-20 0-35-15t-15-35q0-20 15-35t35-15q20 0 35 15t15 35q0 20-15 35t-35 15Zm73 269-43-43 173-173 43 43-173 173Zm130-424L161 299l43-43 172 172-43 43Zm147 505q-20 0-35-15t-15-35q0-20 15-35t35-15q20 0 35 15t15 35q0 20-15 35t-35 15Zm0-700q-20 0-35-15t-15-35q0-20 15-35t35-15q20 0 35 15t15 35q0 20-15 35t-35 15Zm147 195-43-43 172-172 43 43-172 172Zm129 423L584 722l43-43 172 172-43 43Zm74-268q-20 0-35-15t-15-35q0-20 15-35t35-15q20 0 35 15t15 35q0 20-15 35t-35 15Z"})}))}function Da(e){return(0,H.jsx)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 96 960 960",fill:"currentColor"},e,{children:(0,H.jsx)("path",{d:"M197 859q-54-54-85.5-126.5T80 576q0-84 31.5-156.5T197 293l43 43q-46 46-73 107.5T140 576q0 71 26.5 132T240 816l-43 43Zm113-113q-32-32-51-75.5T240 576q0-51 19-94.5t51-75.5l43 43q-24 24-38.5 56.5T300 576q0 38 14 70t39 57l-43 43Zm170-90q-33 0-56.5-23.5T400 576q0-33 23.5-56.5T480 496q33 0 56.5 23.5T560 576q0 33-23.5 56.5T480 656Zm170 90-43-43q24-24 38.5-56.5T660 576q0-38-14-70t-39-57l43-43q32 32 51 75.5t19 94.5q0 50-19 93.5T650 746Zm113 113-43-43q46-46 73-107.5T820 576q0-71-26.5-132T720 336l43-43q54 55 85.5 127.5T880 576q0 83-31.5 155.5T763 859Z"})}))}function Pa(e){return(0,H.jsx)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -960 960 960"},e,{children:(0,H.jsx)("path",{d:"M166-234q-38-45-59.5-100.5T81-450h62q5 47 22 91t47 80l-46 45ZM81-530q2-60 24.5-115T166-746l46 45q-29 38-46.5 81T143-530H81ZM441-89q-59-8-114-28t-102-55l46-48q38 26 81 44.5t89 26.5v60ZM273-760l-48-48q48-36 103.5-55.5T444-891v60q-47 8-90 25.5T273-760Zm114 441v-342l268 171-268 171ZM524-89v-60q128-19 212-115.5T820-490q0-129-84-225.5T524-831v-60q154 15 255 130.5T880-490q0 155-101 270T524-89Z"})}))}function Ma(e){return(0,H.jsx)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -960 960 960"},e,{children:(0,H.jsx)("path",{d:"M200-200v-193h60v133h133v60H200Zm0-367v-193h193v60H260v133h-60Zm367 367v-60h133v-133h60v193H567Zm133-367v-133H567v-60h193v193h-60Z"})}))}function Oa(e){return(0,H.jsx)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -960 960 960"},e,{children:(0,H.jsx)("path",{d:"M333-200v-133H200v-60h193v193h-60Zm234 0v-193h193v60H627v133h-60ZM200-567v-60h133v-133h60v193H200Zm367 0v-193h60v133h133v60H567Z"})}))}function Fa(e){return(0,H.jsx)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -960 960 960"},e,{children:(0,H.jsx)("path",{d:"M360-310v-212h-54v-49h104v261h-50Zm147 0q-18.7 0-31.35-12.65Q463-335.3 463-354v-173q0-18.7 12.65-31.35Q488.3-571 507-571h83q18.7 0 31.35 12.65Q634-545.7 634-527v173q0 18.7-12.65 31.35Q608.7-310 590-310h-83Zm6-50h71v-162h-71v162ZM480-80q-75 0-140.5-28T225-185q-49-49-77-114.5T120-440q0-75 28-140.5T225-695q49-49 114.5-77T480-800h21l-78-78 41-41 147 147-147 147-41-41 74-74h-17q-125.357 0-212.679 87.321Q180-565.357 180-440t87.321 212.679Q354.643-140 480-140t212.679-87.321Q780-314.643 780-440h60q0 75-28 140.5T735-185q-49 49-114.5 77T480-80Z"})}))}function Za(e){return(0,H.jsx)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -960 960 960"},e,{children:(0,H.jsx)("path",{d:"M480-80q-75 0-140.5-28T225-185q-49-49-77-114.5T120-440h60q0 125 87.321 212.5Q354.643-140 480-140t212.679-87.321Q780-314.643 780-440t-85-212.679Q610-740 485-740h-22l73 73-42 42-147-147 147-147 41 41-78 78h23q75 0 140.5 28T735-695q49 49 77 114.5T840-440q0 75-28 140.5T735-185q-49 49-114.5 77T480-80ZM360-310v-212h-54v-49h104v261h-50Zm147 0q-18.7 0-31.35-12.65Q463-335.3 463-354v-173q0-18.7 12.65-31.35Q488.3-571 507-571h83q18.7 0 31.35 12.65Q634-545.7 634-527v173q0 18.7-12.65 31.35Q608.7-310 590-310h-83Zm6-50h71v-162h-71v162Z"})}))}function qa(e){return(0,H.jsx)("svg",Object.assign({viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"none"},e,{children:(0,H.jsx)("path",{d:"M12.5 14L9.81494 17.0207C9.27003 17.6337 8.25949 17.3662 8.0893 16.5638L5.56782 4.67685C5.37436 3.76482 6.42406 3.1076 7.15999 3.67999L16.8784 11.2388C17.5366 11.7507 17.316 12.796 16.507 12.9983L12.5 14ZM12.5 14L16.5 20",strokeWidth:"1.5",strokeLinecap:"round"})}))}function Ua(e){return(0,H.jsxs)("svg",Object.assign({viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},e,{children:[(0,H.jsx)("rect",{width:"16",height:"16",id:"icon-bound",fill:"none"}),(0,H.jsx)("path",{d:"M8,8L8,1C8,0.448 8.448,0 9,0C9.552,0 10,0.448 10,1L10,8L11,8L11,2C11,1.448 11.448,1 12,1C12.552,1 13,1.448 13,2L13,8L14,8L14,5C14,4.448 14.448,4 15,4C15.552,4 16,4.448 16,5L16,9L16,9.001L16,14C16,14.53 15.789,15.039 15.414,15.414C15.039,15.789 14.53,16 14,16C11.883,16 8.628,16 7,16C6.37,16 5.778,15.704 5.4,15.2C3.88,13.174 0,8 0,8C0,8 0,8 0,8C0.574,7.426 1.482,7.362 2.131,7.848L5,10L5,3C5,2.448 5.448,2 6,2C6.552,2 7,2.448 7,3L7,8L8,8Z"})]}))}function Va(e){return(0,H.jsx)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -960 960 960"},e,{children:(0,H.jsx)("path",{d:"M440-80q-50-5-96-24.5T256-156l56-58q29 21 61.5 34t66.5 18v82Zm80 0v-82q104-15 172-93.5T760-438q0-117-81.5-198.5T480-718h-8l64 64-56 56-160-160 160-160 56 58-62 62h6q75 0 140.5 28.5t114 77q48.5 48.5 77 114T840-438q0 137-91 238.5T520-80ZM198-214q-32-42-51.5-88T122-398h82q5 34 18 66.5t34 61.5l-58 56Zm-76-264q6-51 25-98t51-86l58 56q-21 29-34 61.5T204-478h-82Z"})}))}function $a(e){return(0,H.jsxs)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 8 12",fill:"currentColor"},e,{children:[(0,H.jsx)("rect",{width:"2",height:"2",rx:"1"}),(0,H.jsx)("rect",{width:"2",height:"2",rx:"1",y:"5"}),(0,H.jsx)("rect",{width:"2",height:"2",rx:"1",y:"10"}),(0,H.jsx)("rect",{width:"2",height:"2",rx:"1",x:"6"}),(0,H.jsx)("rect",{width:"2",height:"2",rx:"1",x:"6",y:"5"}),(0,H.jsx)("rect",{width:"2",height:"2",rx:"1",x:"6",y:"10"})]}))}function za(e){return(0,H.jsx)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -960 960 960",fill:"#5f6368",height:"24",width:"24"},e,{children:(0,H.jsx)("path",{d:"M660-521q-17 0-28.5-11.5T620-561q0-17 11.5-28.5T660-601q17 0 28.5 11.5T700-561q0 17-11.5 28.5T660-521Zm-100-98-42-42q29-29 65.5-44.5T660-721q40 0 76.5 15.5T802-661l-42 42q-20-20-45.5-31T660-661q-29 0-54.5 11T560-619Zm-84-86-42-42q45-45 103.5-69.5T660-841q64 0 122.5 24.5T886-747l-42 42q-37-37-84.5-56.5T660-781q-52 0-99 20t-85 56Zm322 585q-125 0-247-54.5T329-329Q229-429 174.5-551T120-798q0-18 12-30t30-12h162q14 0 25 9.5t13 22.5l26 140q2 16-1 27t-11 19l-97 98q20 37 47.5 71.5T387-386q31 31 65 57.5t72 48.5l94-94q9-9 23.5-13.5T670-390l138 28q14 4 23 14.5t9 23.5v162q0 18-12 30t-30 12ZM241-600l66-66-17-94h-89q5 41 14 81t26 79Zm358 358q39 17 79.5 27t81.5 13v-88l-94-19-67 67ZM241-600Zm358 358Z"})}))}function Ha(e){return(0,H.jsx)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -960 960 960",fill:"#5f6368"},e,{children:(0,H.jsx)("path",{d:"m136-304-92-90q-12-12-12-28t12-28q88-95 203-142.5T480-640q118 0 232.5 47.5T916-450q12 12 12 28t-12 28l-92 90q-11 11-25.5 12t-26.5-8l-116-88q-8-6-12-14t-4-18v-114q-38-12-78-19t-82-7q-42 0-82 7t-78 19v114q0 10-4 18t-12 14l-116 88q-12 9-26.5 8T136-304Zm104-198q-29 15-56 34.5T128-424l40 40 72-56v-62Zm480 2v60l72 56 40-38q-29-26-56-45t-56-33Zm-480-2Zm480 2Z"})}))}function Ba(e){return(0,H.jsx)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -960 960 960",fill:"#5f6368"},e,{children:(0,H.jsx)("path",{d:"M480-40q-33 0-56.5-23.5T400-120q0-33 23.5-56.5T480-200q33 0 56.5 23.5T560-120q0 33-23.5 56.5T480-40ZM240-760q-33 0-56.5-23.5T160-840q0-33 23.5-56.5T240-920q33 0 56.5 23.5T320-840q0 33-23.5 56.5T240-760Zm0 240q-33 0-56.5-23.5T160-600q0-33 23.5-56.5T240-680q33 0 56.5 23.5T320-600q0 33-23.5 56.5T240-520Zm0 240q-33 0-56.5-23.5T160-360q0-33 23.5-56.5T240-440q33 0 56.5 23.5T320-360q0 33-23.5 56.5T240-280Zm480-480q-33 0-56.5-23.5T640-840q0-33 23.5-56.5T720-920q33 0 56.5 23.5T800-840q0 33-23.5 56.5T720-760ZM480-280q-33 0-56.5-23.5T400-360q0-33 23.5-56.5T480-440q33 0 56.5 23.5T560-360q0 33-23.5 56.5T480-280Zm240 0q-33 0-56.5-23.5T640-360q0-33 23.5-56.5T720-440q33 0 56.5 23.5T800-360q0 33-23.5 56.5T720-280Zm0-240q-33 0-56.5-23.5T640-600q0-33 23.5-56.5T720-680q33 0 56.5 23.5T800-600q0 33-23.5 56.5T720-520Zm-240 0q-33 0-56.5-23.5T400-600q0-33 23.5-56.5T480-680q33 0 56.5 23.5T560-600q0 33-23.5 56.5T480-520Zm0-240q-33 0-56.5-23.5T400-840q0-33 23.5-56.5T480-920q33 0 56.5 23.5T560-840q0 33-23.5 56.5T480-760Z"})}))}function Wa(e){return(0,H.jsx)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 80",x:"0px",y:"0px",fill:"currentColor"},e,{children:(0,H.jsxs)("g",{children:[(0,H.jsx)("path",{d:"M59,2H5A3,3,0,0,0,2,5V35a3,3,0,0,0,3,3H28v2.764l-2.895,5.789A1,1,0,0,0,26,48H38a1,1,0,0,0,.9-1.447L36,40.764V38H59a3,3,0,0,0,3-3V5A3,3,0,0,0,59,2ZM34.1,41.447,36.382,46H27.618L29.9,41.447A1,1,0,0,0,30,41V38h4v3A1,1,0,0,0,34.1,41.447ZM60,35a1,1,0,0,1-1,1H5a1,1,0,0,1-1-1V5A1,1,0,0,1,5,4H59a1,1,0,0,1,1,1Z"}),(0,H.jsx)("path",{d:"M58,5H6A1,1,0,0,0,5,6V34a1,1,0,0,0,1,1H58a1,1,0,0,0,1-1V6A1,1,0,0,0,58,5Zm-1,7H46V7H57ZM33,12V7H44v5Zm11,2v5H33V14ZM31,12H20V7H31Zm0,2v5H20V14ZM18,19H7V14H18Zm0,2v5H7V21Zm2,0H31v5H20Zm11,7v5H20V28Zm2,0H44v5H33Zm0-2V21H44v5Zm13-5H57v5H46Zm0-2V14H57v5ZM18,7v5H7V7ZM7,28H18v5H7Zm39,5V28H57v5Z"}),(0,H.jsx)("path",{d:"M43.929,50.629A1,1,0,0,0,43,50H21a1,1,0,0,0-.929.629l-4,10A1,1,0,0,0,17,62H47a1,1,0,0,0,.929-1.371ZM18.477,60l3.2-8H42.323l3.2,8Z"}),(0,H.jsx)("rect",{x:"24",y:"53",width:"2",height:"2"}),(0,H.jsx)("rect",{x:"22",y:"56",width:"2",height:"2"}),(0,H.jsx)("rect",{x:"27",y:"53",width:"2",height:"2"}),(0,H.jsx)("rect",{x:"25",y:"56",width:"2",height:"2"}),(0,H.jsx)("rect",{x:"28",y:"56",width:"2",height:"2"}),(0,H.jsx)("polygon",{points:"39.168 52.445 37.465 55 36 55 36 57 40 57 40 55 39.868 55 40.832 53.555 39.168 52.445"})]})}))}function Ga(){return(0,H.jsx)("svg",{viewBox:"0 0 32 32",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:(0,H.jsx)("path",{d:"M 12.341 14.977 L 27.684 14.977 C 28.144 14.977 28.451 15.285 28.451 15.749 C 28.451 16.211 28.144 16.521 27.684 16.521 L 12.341 16.521 C 11.881 16.521 11.575 16.211 11.575 15.749 C 11.575 15.285 11.881 14.977 12.341 14.977 Z M 4.67 5.72 L 27.684 5.72 C 28.144 5.72 28.451 6.027 28.451 6.492 C 28.451 6.955 28.144 7.263 27.684 7.263 L 4.67 7.263 C 4.209 7.263 3.903 6.955 3.903 6.492 C 3.903 6.027 4.209 5.72 4.67 5.72 Z M 4.67 24.235 L 27.684 24.235 C 28.144 24.235 28.451 24.543 28.451 25.006 C 28.451 25.469 28.144 25.778 27.684 25.778 L 4.67 25.778 C 4.209 25.778 3.903 25.469 3.903 25.006 C 3.903 24.543 4.209 24.235 4.67 24.235 Z M 9.811 20.145 C 10.117 19.837 10.117 19.376 9.811 19.065 L 6.511 15.749 L 9.811 12.431 C 10.117 12.123 10.117 11.66 9.811 11.352 C 9.503 11.042 9.043 11.042 8.736 11.352 L 4.363 15.749 L 8.736 20.145 C 8.89 20.301 9.043 20.377 9.273 20.377 C 9.503 20.377 9.657 20.301 9.811 20.145 Z"})})}function Ka(e){return(0,H.jsx)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",height:"16",viewBox:"0 0 16 16",width:"16",focusable:"false","aria-hidden":"true"},e,{children:(0,H.jsx)("path",{d:"M9 8c0 .55-.45 1-1 1s-1-.45-1-1 .45-1 1-1 1 .45 1 1Zm1.11 2.13.71.71C11.55 10.11 12 9.11 12 8c0-1.11-.45-2.11-1.18-2.84l-.71.71c.55.55.89 1.3.89 2.13 0 .83-.34 1.58-.89 2.13Zm-4.93.71.71-.71C5.34 9.58 5 8.83 5 8c0-.83.34-1.58.89-2.13l-.71-.71C4.45 5.89 4 6.89 4 8c0 1.11.45 2.11 1.18 2.84Zm7.05 1.41.71.71C14.21 11.69 15 9.94 15 8s-.79-3.69-2.06-4.96l-.71.71C13.32 4.84 14 6.34 14 8c0 1.66-.68 3.16-1.77 4.25Zm-9.17.71.71-.71C2.68 11.16 2 9.66 2 8c0-1.66.68-3.16 1.77-4.25l-.71-.71C1.79 4.31 1 6.06 1 8s.79 3.69 2.06 4.96Z"})}))}const Ya=(0,H.jsx)("span",{className:"flex h-8 w-8 items-center justify-center rounded-full",children:(0,H.jsx)(Ta,{})}),Qa=(0,H.jsx)("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-green-500",children:(0,H.jsx)(je.Z,{className:"w-5 text-white","aria-hidden":"true"})}),Xa=(0,H.jsx)("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-yellow-500",children:(0,H.jsx)(ge.Z,{className:"w-5 text-white","aria-hidden":"true"})}),Ja=(0,H.jsx)("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-red-500",children:(0,H.jsx)(Se.Z,{className:"w-5 text-white","aria-hidden":"true"})}),es=(0,H.jsx)("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-blue-500",children:(0,H.jsx)(Ee.Z,{className:"w-5 text-white","aria-hidden":"true"})}),ts=(0,H.jsx)("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-blue-500",children:(0,H.jsx)(Ea.Z,{className:"w-5 text-white","aria-hidden":"true"})}),ns=(0,H.jsx)("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-blue-500",children:(0,H.jsx)(Aa.Z,{className:"w-5 text-white","aria-hidden":"true"})}),as=(0,H.jsx)("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-yellow-500",children:(0,H.jsx)(_a.Z,{className:"w-5 text-white","aria-hidden":"true"})});var ss=n(3803),rs=n(42834);const is=function(e){const{style:t,className:n,onClick:a}=e;return(0,H.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:t,className:n,onClick:a,children:[(0,H.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2"}),(0,H.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor"})]})};function os(e){return[ls(e[0]),ls(e[1])]}function ls(e){return Math.max(0,Math.ceil(e))}function cs(e){return e?`${ls(e[0])}, ${ls(e[1])}`:"-"}function ds(e,t,n,a){const s=(0,ss.Z)().domain([0,e[0]]).range([0,t[0]]),r=(0,ss.Z)().domain([0,e[1]]).range([0,t[1]]),i=[a.point[0]-n[0],a.point[1]-n[1]];return Object.assign({},a,{point:[s(i[0]),r(i[1])]})}function us(e,t,n){const a=(0,ss.Z)().domain([0,t[0]]).range([0,e[0]]),s=(0,ss.Z)().domain([0,t[1]]).range([0,e[1]]),r=[a(n.point[0]),s(n.point[1])];return Object.assign({},n,{point:[r[0],r[1]]})}function ms(e){switch(e){case"small":return[6,"w-6"];case"large":return[16,"w-16"];default:return[12,"w-12"]}}function hs(e,t){return e.map(((e,n)=>e.points.map(((a,s)=>{const[r,i]=ms(e.pointSize);return(0,H.jsx)(is,{style:{left:a[0]-2*r,top:a[1]-2*r},className:(0,z.Z)("absolute",i,`text-${Na(e.color)}`),onClick:t},`${n}-${s}`)}))))}const xs=(0,rs.Z)();function ps(e){const t=e.map((e=>{var t;return{path:null!=(t=e.points?xs(e.points)+(void 0===e.closed||e.closed?"z":""):"")?t:"",color:e.color,tag:e.tag,tagCoord:[Math.max(...e.points.map((e=>e[0]))),Math.min(...e.points.map((e=>e[1])))]}}));return(0,H.jsx)("svg",{className:"pointer-events-none absolute left-0 top-0 h-full w-full",children:t.map(((e,t)=>(0,H.jsxs)("g",{children:[(0,H.jsx)("path",{d:e.path,className:(0,z.Z)("fill-transparent stroke-2",`stroke-${Na(e.color)}`)}),e.tag&&(0,H.jsx)("text",{x:e.tagCoord[0],y:e.tagCoord[1],textAnchor:"end",dx:0,dy:-4,className:`fill-${Na(e.color)} text-[10px]`,children:e.tag})]},String(t))))})}function gs(e,t){return null==e?void 0:e.map(((e,n)=>{const[a,s]=ms(e.size);return(0,H.jsx)(is,{style:{left:e.point[0]-2*a,top:e.point[1]-2*a},className:(0,z.Z)("absolute",s,"text-"+Na(e.color)),onClick:t},String(n))}))}function fs(e){var t;const{imgUrl:n,polygons:s,markers:r,onClickImage:i,onClickShape:o,onImageLoadCallback:l}=e,c=(0,a.useRef)(null),d=null==(t=c.current)?void 0:t.getBoundingClientRect();Ne();const u=(0,a.useMemo)((()=>d&&c.current&&s?s.map((e=>Object.assign({},e,{points:e.points.map((e=>c.current?us([d.width,d.height],[c.current.naturalWidth,c.current.naturalHeight],{point:e}).point:e))}))):[]),[d,c,s]),m=(0,a.useMemo)((()=>{if(r)return d&&c.current?r.map((e=>c.current?us([d.width,d.height],[c.current.naturalWidth,c.current.naturalHeight],e):e)):[]}),[c,d,r]);return(0,H.jsxs)("div",{className:"relative cursor-crosshair",children:[(0,H.jsx)("img",{src:n,ref:c,alt:"camera view                                                                            ",onLoad:e=>{const t=[e.currentTarget.naturalWidth,e.currentTarget.naturalHeight],n=e.currentTarget.getBoundingClientRect();l(t,[n.width,n.height],[n.left,n.top])},className:"w-full",onClick:i,onContextMenu:i}),hs(u,o),ps(u),gs(m,o)]})}function vs(e){const t=[];let n,a,s=!1;function r(){e.currentTime>e.buffered.end(e.buffered.length-1)&&(e.currentTime=e.buffered.end(e.buffered.length-1)-.1,e.play())}function i(){if(!n.updating)if(t.length>0){const e=t.shift();e&&n.appendBuffer(e)}else s=!1;e.buffered.length>0&&void 0!==document.hidden&&document.hidden&&(e.currentTime=e.buffered.end(e.buffered.length-1)-.5)}return e.addEventListener("pause",r),{startPlay:function(r){const o=new MediaSource;e.src=window.URL.createObjectURL(o),o.addEventListener("sourceopen",(function(){a=new WebSocket(r),a.binaryType="arraybuffer",a.onmessage=function(e){const a=new Uint8Array(e.data);if(9===a[0]){const e=a.slice(1),t=new TextDecoder("utf-8").decode(e);n=o.addSourceBuffer('video/mp4; codecs="'+t+'"'),n.mode="segments",n.addEventListener("updateend",i)}else!function(e){if(!s)return n.appendBuffer(e),void(s=!0);t.push(e),n.updating||i()}(e.data)}}),!1)},stopPlay:function(){a&&a.close(),e.removeEventListener("pause",r)}}}function js(e){const{mseUrl:t,lockAspectRatio:n}=e,s=(0,a.useRef)(null),[r,i]=(0,a.useState)({isError:!1,message:""});return(0,a.useEffect)((()=>{let e;if(s.current)try{e=vs(s.current),e.startPlay(t)}catch(n){i({isError:!0,message:"Live video is not supported in this browser. Please use desktop/laptop browser"})}return()=>{e&&e.stopPlay()}}),[t]),r.isError?(0,H.jsx)("div",{children:r.message}):(0,H.jsx)("video",{ref:s,className:(0,z.Z)("dark:bg-ondark-bg-2 bg-onlight-bg-2 w-full object-fill",n&&"aspect-video"),autoPlay:!0,muted:!0,playsInline:!0,controls:!0})}function bs(e){const{livestreamUrl:t}=e;return(0,H.jsx)("iframe",{src:t,title:"live view",allowFullScreen:!0,className:"aspect-video w-full"})}function ys(e){const{text:t}=e;return(0,H.jsxs)("div",{className:"flex items-center gap-2",children:[(0,H.jsx)("div",{"data-testid":"spinner-container",children:(0,H.jsx)(K,{})}),(0,H.jsx)("span",{className:"dark:text-dark-text text-gray-500","data-testid":"text-container",children:null!=t?t:"Loading..."})]})}const ks=ys;function ws(e){const{text:t}=e;return(0,H.jsx)("div",{className:"dark:bg-dark-bg flex h-screen items-center justify-center",children:(0,H.jsx)(ks,{text:t})})}var Ns=n(43541);function Cs(e){const{menuButton:t,items:n,menuButtonTrackingEvent:s}=e;let r={};return r=n.reduce(((e,t)=>{const n=t.group||"default";return e[n]=e[n]||[],e[n].push(t),e}),r),(0,H.jsxs)(Ns.v,{as:"div",className:"relative",children:[(0,H.jsx)(Ns.v.Button,{as:"div",children:(0,H.jsx)(Q,{variant:"icon",onSideEffect:s&&yt(s),children:t})}),(0,H.jsx)(ie.u,{as:a.Fragment,enter:"transition ease-out duration-100",enterFrom:"transform opacity-0 scale-95",enterTo:"transform opacity-100 scale-100",leave:"transition ease-in duration-75",leaveFrom:"transform opacity-100 scale-100",leaveTo:"transform opacity-0 scale-95",children:(0,H.jsx)(Ns.v.Items,{className:"dark:bg-dark-bg absolute right-0 z-10 mt-2 w-48 origin-top-right divide-y divide-gray-100 rounded-md bg-white py-1 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:divide-gray-600 dark:ring-gray-600",children:Object.entries(r).map((([e,t])=>(0,H.jsx)("div",{children:t.map((e=>!e.hidden&&(0,H.jsx)(Ns.v.Item,{"data-testid":e.dataTestId,children:({active:t})=>(0,H.jsxs)("div",{onClick:e.onClick,className:(0,z.Z)(t?"bg-gray-100 hover:dark:bg-gray-700":"","dark:text-dark-text dark:bg-dark-bg block py-2 px-4 text-sm text-gray-700","group flex cursor-pointer items-center"),children:[(0,H.jsx)("span",{className:(0,z.Z)("mr-4",!e.icon&&"hidden"),children:e.icon||null}),(0,H.jsx)("span",{children:e.name})]})},e.name)))},e)))})})]})}var Ss=n(45485);function Ts(e){const{children:t}=e;return(0,H.jsxs)(H.Fragment,{children:[" ",t," "]})}const Es=Ts;function As(e){const{message:t}=e;return(0,H.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,H.jsxs)("div",{className:"dark:border-dark-border-bg flex flex-col items-center gap-2 rounded border p-16",children:[(0,H.jsx)("span",{role:"img","aria-label":"emoji eyes",className:"text-4xl",children:"\ud83d\udc40"}),(0,H.jsx)("span",{className:"dark:text-dark-text",children:t||"We couldn't find what you are looking for!"}),(0,H.jsxs)("span",{className:"dark:text-dark-secondary-text text-sm text-gray-500",children:["Click",(0,H.jsx)(Es,{children:(0,H.jsx)(Ss.rU,{to:"/",className:"text-primary-700 hover:text-primary-500",children:"here"})}),"to go back home"]})]})})}function _s(e){const{open:t,onClose:n,title:s,children:r}=e;return(0,H.jsx)(ie.u.Root,{show:t,as:a.Fragment,children:(0,H.jsxs)(oe.V,{as:"div",className:"relative z-10",onClose:n,children:[(0,H.jsx)(ie.u.Child,{as:a.Fragment,enter:"transition-opacity ease-in-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"transition-opacity ease-in-out duration-300",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,H.jsx)("div",{className:"fixed inset-0 bg-gray-600 bg-opacity-75"})}),(0,H.jsx)("div",{className:"fixed inset-0 overflow-hidden",children:(0,H.jsx)("div",{className:"absolute inset-0 overflow-hidden",children:(0,H.jsx)("div",{className:"pointer-events-none fixed inset-y-0 right-0 flex max-w-full pl-10",children:(0,H.jsx)(ie.u.Child,{as:a.Fragment,enter:"transform transition ease-in-out duration-300",enterFrom:"translate-x-full",enterTo:"translate-x-0",leave:"transform transition ease-in-out duration-300",leaveFrom:"translate-x-0",leaveTo:"translate-x-full",children:(0,H.jsx)(oe.V.Panel,{className:"pointer-events-auto w-screen max-w-xs",children:(0,H.jsxs)("div",{className:"dark:bg-dark-bg flex h-full flex-col overflow-y-scroll bg-white py-6 shadow",children:[(0,H.jsx)("div",{className:"px-4 sm:px-6",children:(0,H.jsxs)("div",{className:"flex items-start justify-between",children:[(0,H.jsx)(oe.V.Title,{className:"dark:text-dark-text text-lg font-medium text-gray-800",children:s}),(0,H.jsx)("div",{className:"ml-3 flex h-7 items-center",children:(0,H.jsxs)(Q,{variant:"icon",onClick:n,children:[(0,H.jsx)("span",{className:"sr-only",children:"Close panel"}),(0,H.jsx)(le.Z,{className:"h-5 w-5","aria-hidden":"true"})]})})]})}),(0,H.jsx)("div",{className:"relative mt-6 flex-1 px-4 sm:px-6",children:(0,H.jsx)("div",{className:"absolute inset-0 px-4 sm:px-6",children:r})})]})})})})})})]})})}function Is(e){var t;const{queryResult:{isLoading:n,error:a,data:s,isRefetching:r},children:i,loadingText:o,keepCurrentContentOnRefetch:l=!0,errorFormatter:c}=e,d=(0,H.jsx)(ja,{children:(0,H.jsx)(ks,{text:o})});return(0,H.jsxs)("div",{className:"relative h-full bg-inherit",children:[r&&l&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"dark:bg-dark-bg absolute inset-0 z-10 bg-gray-300 opacity-50"}),(0,H.jsx)("div",{className:"absolute inset-0 z-10",children:d})]}),n||r&&!l?d:null!==a?c?c(a):(0,H.jsx)("div",{className:"mx-auto max-w-screen-2xl p-6",children:(0,H.jsx)(B,{type:"error",children:null!=(t=a.message)?t:""})}):s?i(s):d]})}var Ls=n(55374),Rs=n(94085),Ds=n(95762);function Ps(e){const{label:t,items:n,value:s,onChange:r,displayValue:i,id:o,placeholder:l}=e;return(0,H.jsx)(Ls.R,{value:s,onChange:r,children:({open:e})=>(0,H.jsxs)("div",{className:"w-full",children:[t&&(0,H.jsx)(Ls.R.Label,{className:"dark:text-dark-text mb-1 block text-xs text-gray-700",children:t}),(0,H.jsxs)("div",{className:"relative",children:[(0,H.jsxs)(Ls.R.Button,{className:"focus:border-primary-500 focus:ring-primary-500 dark:bg-dark-bg relative min-h-[2rem] w-full cursor-default rounded border border-gray-400 bg-white py-2 pl-3 pr-10 text-left focus:outline-none focus:ring-1 dark:border-gray-600 dark:text-white sm:text-sm",children:[(0,H.jsx)("span",{className:"block truncate",children:i(s)}),!i(s)&&l&&(0,H.jsx)("span",{className:"text-sm opacity-30",children:"Select a comment"}),(0,H.jsx)("span",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2",children:(0,H.jsx)(Rs.Z,{className:"dark:text-dark-text h-5 w-5 text-gray-700","aria-hidden":"true"})})]}),(0,H.jsx)(ie.u,{show:e,as:a.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,H.jsx)(Ls.R.Options,{className:"dark:bg-dark-bg absolute z-10 mt-1 max-h-60 w-auto overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:text-white dark:shadow-gray-700 sm:text-sm",children:n.map(((e,t)=>(0,H.jsx)(Ls.R.Option,{className:({active:e})=>(0,z.Z)(e?"bg-primary-600 text-white":"dark:text-dark-text text-gray-700","relative cursor-default select-none py-2 pl-3 pr-9"),value:e,children:({selected:t,active:n})=>(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("span",{className:(0,z.Z)(t?"font-semibold":"font-normal","block truncate"),children:i(e)}),t?(0,H.jsx)("span",{className:(0,z.Z)(n?"text-white":"text-primary-600","absolute inset-y-0 right-0 flex items-center pr-4"),children:(0,H.jsx)(Ds.Z,{className:"h-5 w-5","aria-hidden":"true"})}):null]})},o?o(e):t)))})})]})]})})}var Ms=n(113);const Os=function(e){const{item:t,displayValue:n,disabled:a}=e;return(0,H.jsx)(Ms.h.Option,{value:t,disabled:a,className:({active:e})=>(0,z.Z)("relative cursor-default select-none py-2 pl-3 pr-9",e?"bg-primary-600 dark:bg-primary-800 text-white":"dark:text-dark-text text-gray-700",a&&"pointer-events-none opacity-50"),children:({active:e,selected:a})=>(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("span",{className:(0,z.Z)("block truncate",a&&"font-semibold"),children:n(t)}),a&&(0,H.jsx)("span",{className:(0,z.Z)("absolute inset-y-0 right-0 flex items-center pr-4",e?"text-white":"text-primary-600"),children:(0,H.jsx)(Ds.Z,{className:"h-5 w-5","aria-hidden":"true"})})]})})};function Fs(e){const{label:t,value:n,onChange:s,displayValue:r,getItems:i,id:o,customSelectedRenderer:l,disabled:c}=e,[d,u]=(0,a.useState)(""),[m,h]=(0,a.useState)([]);(0,a.useEffect)((()=>{h(i(d))}),[d,i]);return(0,H.jsxs)(Ms.h,{as:"div",value:n,onChange:s,multiple:!0,children:[t&&(0,H.jsx)(Ms.h.Label,{className:"dark:text-dark-text mb-1 block text-xs text-gray-700",children:t}),n.length>0&&(0,H.jsx)("div",{className:"mb-2 flex flex-wrap gap-1",children:l?l(n):n.map(((e,t)=>(0,H.jsx)("span",{children:(0,H.jsx)(re,{text:r(e),removable:!0,onClickRemove:()=>{return e=t,void s([...n.slice(0,e),...n.slice(e+1)]);var e}})},o?o(e):t)))}),(0,H.jsxs)("div",{className:"relative",children:[(0,H.jsx)(Ms.h.Input,{className:"focus:border-primary-500 focus:ring-primary-500 dark:text-dark-text dark:bg-dark-bg w-full rounded border-gray-400 text-sm dark:border-gray-600",onChange:e=>u(e.target.value),displayValue:()=>d}),(0,H.jsx)(Ms.h.Button,{className:"absolute inset-y-0 right-0 flex items-center rounded-r-md px-2 focus:outline-none focus:ring-1",children:(0,H.jsx)(Rs.Z,{className:"h-5 w-5 text-gray-400","aria-hidden":"true"})}),m.length>0&&(0,H.jsx)(Ms.h.Options,{className:"dark:bg-dark-bg dark:text-dark-text absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:ring-gray-600 sm:text-sm",children:m.map(((e,t)=>(0,H.jsx)(Os,{item:e,displayValue:r,disabled:c&&c(e)},o?o(e):t)))})]})]})}const Zs=500;function qs(e){const{label:t,value:n,debounceDelay:s,onChange:r,displayValue:i,onChangeQuery:o,id:l,customSelectedRenderer:c}=e,[d,u]=(0,a.useState)([]),[m,h]=(0,a.useState)(!1),x=(0,a.useRef)();return(0,H.jsxs)(Ms.h,{value:n,onChange:r,multiple:!0,by:(e,t)=>l?Boolean(l(e)===l(t)):Boolean(e===t),children:[(0,H.jsx)(Ms.h.Label,{className:"dark:text-dark-text mb-1 block text-xs text-gray-700",children:t}),n.length>0&&(0,H.jsx)("div",{className:"mb-2",children:c?c(n):n.map(((e,t)=>(0,H.jsx)("span",{className:"mr-1",children:(0,H.jsx)(re,{text:i(e),removable:!0,onClickRemove:()=>{return e=t,void r([...n.slice(0,e),...n.slice(e+1)]);var e}})},l?l(e):t)))}),(0,H.jsxs)("div",{className:"relative",children:[(0,H.jsx)(Ms.h.Input,{className:"focus:border-primary-500 focus:ring-primary-500 dark:text-dark-text dark:bg-dark-bg w-full rounded border-gray-400 text-sm dark:border-gray-600",onChange:e=>{return t=e.target.value,window.clearTimeout(x.current),void(x.current=window.setTimeout((()=>{h(!0),o(t).then((e=>{u(e)})).finally((()=>{h(!1)}))}),s||Zs));var t},displayValue:i}),(0,H.jsx)(Ms.h.Button,{className:"absolute inset-y-0 right-0 flex items-center rounded-r-md px-2 focus:outline-none focus:ring-1",children:(0,H.jsx)(Rs.Z,{className:"h-5 w-5 text-gray-400","aria-hidden":"true"})}),m&&(0,H.jsx)("span",{className:"absolute right-8 translate-y-1/2",children:(0,H.jsx)(K,{})}),!m&&d.length>0&&(0,H.jsx)(Ms.h.Options,{className:"dark:bg-dark-bg dark:text-dark-text absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:ring-gray-600 sm:text-sm",children:d.map(((e,t)=>(0,H.jsx)(Os,{item:e,displayValue:i},l?l(e):t)))})]})]})}function Us(e){const{label:t,value:n,onChange:s,displayValue:r,getItems:i,id:o,onChangeQuery:l,onKeyUp:c,placeholder:d,disabled:u}=e,[m,h]=(0,a.useState)(""),[x,p]=(0,a.useState)([]),g=(0,a.useRef)(null);(0,a.useEffect)((()=>{p(i(m))}),[m,i]);return(0,H.jsxs)(Ms.h,{as:"div",value:n,onChange:e=>{s(e),g.current&&g.current.focus()},nullable:!0,children:[t&&(0,H.jsx)(Ms.h.Label,{className:"dark:text-dark-text mb-1 block text-xs text-gray-700",children:t}),(0,H.jsxs)("div",{className:"relative",children:[(0,H.jsx)(Ms.h.Input,{className:"focus:border-primary-500 focus:ring-primary-500 dark:bg-dark-bg dark:text-dark-text w-full rounded border-gray-400 text-sm dark:border-gray-600",onChange:e=>{var t;t=e.target.value,h(t),l&&l(t)},displayValue:r,autoFocus:!0,ref:g,onKeyUp:c,placeholder:d}),(0,H.jsx)(Ms.h.Button,{className:" absolute inset-y-0 right-0 flex items-center rounded-r-md px-2 focus:outline-none",children:(0,H.jsx)(Rs.Z,{className:"h-5 w-5 text-gray-400","aria-hidden":"true"})}),x.length>0&&(0,H.jsx)(Ms.h.Options,{hold:!0,className:"dark:bg-dark-hover-bg absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm",children:x.map(((e,t)=>(0,H.jsx)(Os,{item:e,displayValue:r,disabled:u&&u(e)},o?o(e):t)))})]})]})}function Vs(e){const{label:t,value:n,debounceDelay:s,onChange:r,displayValue:i,onChangeQuery:o,id:l,placeholder:c,infoTooltip:d}=e,[u,m]=(0,a.useState)([]),[h,x]=(0,a.useState)(!1),p=(0,a.useRef)();return(0,H.jsx)(Ms.h,{as:"div",value:n,onChange:r,children:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{className:"flex items-center gap-2",children:[t&&(0,H.jsx)(Ms.h.Label,{className:"dark:text-dark-text mb-1 block text-xs text-gray-700",children:t}),d&&(0,H.jsx)("span",{children:(0,H.jsx)(ye,{text:d,colorModifier:"info",position:"top-right",size:"medium",children:(0,H.jsx)(be.Z,{className:"h-4 w-4"})})})]}),(0,H.jsxs)("div",{className:"relative",children:[(0,H.jsx)(Ms.h.Input,{placeholder:c,className:"focus:border-primary-500 focus:ring-primary-500 dark:bg-dark-bg w-full rounded border-gray-400 text-sm dark:border-gray-600",onChange:e=>{return t=e.target.value,window.clearTimeout(p.current),void(p.current=window.setTimeout((()=>{x(!0),o(t).then((e=>{m(e)})).finally((()=>{x(!1)}))}),s||Zs));var t},displayValue:i}),(0,H.jsx)(Ms.h.Button,{className:" absolute inset-y-0 right-0 flex items-center rounded-r-md px-2 focus:outline-none",children:(0,H.jsx)(Rs.Z,{className:"h-5 w-5 text-gray-400","aria-hidden":"true"})}),h&&(0,H.jsx)("span",{className:"absolute right-8 translate-y-1/2",children:(0,H.jsx)(K,{})}),!h&&u.length>0&&(0,H.jsx)(Ms.h.Options,{className:"dark:bg-dark-hover-bg absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white  py-1  text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm",children:u.map(((e,t)=>(0,H.jsx)(Os,{item:e,displayValue:i},l?l(e):t)))})]})]})})}function $s(e){return e.children}const zs=(0,a.forwardRef)((function(e,t){const{children:n,classnames:a=""}=e;return(0,H.jsxs)("div",{ref:t,className:(0,z.Z)("bg-onlight-bg-1 dark:bg-ondark-bg-1 flex h-full divide-x overflow-y-auto dark:divide-white/10",a),children:[(0,H.jsx)("div",{className:"overflow-y-auto",children:n[0]}),(0,H.jsx)("div",{className:"flex-1 overflow-auto",children:n[1]})]})}));function Hs(e){const{children:t,initialLeftWidth:n=300}=e,s=(0,a.useRef)(null),[r,i]=t;return(0,H.jsxs)("div",{className:"flex h-full w-full overflow-auto",children:[(0,H.jsx)("div",{ref:s,className:"overflow-auto",style:{width:`${n}px`},children:r}),(0,H.jsx)("div",{className:"bg-onlight-line-2 dark:bg-ondark-line-2 w-0.5 cursor-ew-resize",onMouseDown:e=>{if(!s.current)return;const t=s.current,n=e.clientX,{width:a}=t.getBoundingClientRect(),r=e=>{const s=e.clientX-n;t.style.width=`${a+s}px`},i=()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",i)};document.addEventListener("mousemove",r),document.addEventListener("mouseup",i)}}),(0,H.jsx)("div",{className:"flex-1 overflow-auto",children:i})]})}function Bs(e){const{content:t,onCloseCb:n,open:a}=e,s=(0,H.jsx)(Q,{onClick:n,children:"Close"});return(0,H.jsx)(ce,{open:a,onClose:n,title:"Talkdown Status",footer:s,children:(0,H.jsx)("div",{className:"p-8",children:t})})}function Ws(e){const{events:t}=e,[n,s]=(0,a.useState)(null);return(0,H.jsxs)("div",{className:"flow-root p-6",children:[(0,H.jsx)("ul",{children:t.map(((e,n)=>{return(0,H.jsx)("li",{className:"group",children:(0,H.jsxs)("div",{className:" relative pb-8 group-last:pb-0",children:[n!==t.length-1?(0,H.jsx)("div",{className:"absolute top-10 left-4 bottom-2 -ml-px w-0.5 bg-gray-200 dark:bg-gray-500","aria-hidden":"true"}):null,(0,H.jsxs)("div",{className:"relative flex space-x-3",children:[(0,H.jsx)("div",{className:"flex-shrink-0",children:e.icon}),(0,H.jsxs)("div",{className:"flex-1",children:[(0,H.jsx)("div",{className:"dark:text-dark-secondary-text basis-5/12 text-xs font-medium text-gray-500",children:e.time}),(0,H.jsxs)("div",{className:"basis-7/12 pt-1 text-sm text-gray-700 dark:text-gray-200",children:[e.description,e.audio_url?(0,H.jsx)("audio",{src:e.audio_url,className:"h-7",controls:!0}):null,(0,H.jsxs)("span",{className:"flex items-center",children:[null==e?void 0:e.extraDetails,e.extraDetailsModalContent&&(0,H.jsx)("button",{className:"text-ondark-primary rounded border-transparent px-2 text-xs enabled:hover:underline",onClick:(a=e.extraDetailsModalContent,()=>{s(a)}),children:"view details"})]})]})]})]})]})},n);var a}))}),n&&(0,H.jsx)(Bs,{content:n,onCloseCb:()=>s(null),open:null!==n})]})}const Gs=e=>{const t={iceUfrag:"",icePwd:"",medias:[]};for(const n of e.split("\r\n"))n.startsWith("m=")?t.medias.push(n.slice("m=".length)):""===t.iceUfrag&&n.startsWith("a=ice-ufrag:")?t.iceUfrag=n.slice("a=ice-ufrag:".length):""===t.icePwd&&n.startsWith("a=ice-pwd:")&&(t.icePwd=n.slice("a=ice-pwd:".length));return t},Ks=(e,t)=>{if(void 0===t)throw new Error("No sdp");const n=t.split("m=");for(let a=0;a<n.length;a++)if(n[a].startsWith("audio")){n[a]=rr(n[a]),e.includes("pcma/8000/2")&&(n[a]=nr(n[a])),e.includes("multiopus/48000/6")&&(n[a]=ar(n[a])),e.includes("L16/48000/2")&&(n[a]=sr(n[a]));break}return n.join("m=")},Ys=async()=>(await Promise.all([["pcma/8000/2"],["multiopus/48000/6","channel_mapping=0,4,1,2,3,5;num_streams=4;coupled_streams=2"],["L16/48000/2"]].map((e=>or(e[0],e[1]).then((t=>t?e[0]:"false")))))).filter((e=>"false"!==e)),Qs=async(e,t,n)=>{const a=await fetch(e,{method:"PATCH",headers:{"Content-Type":"application/trickle-ice-sdpfrag","If-Match":"*"},body:ir(t,n)});switch(a.status){case 204:break;case 404:throw new Error("stream not found");default:throw new Error(`bad status code ${a.status}`)}},Xs=async e=>{try{const t=await fetch(new URL("whep",e),{method:"OPTIONS"});if(!t.ok)throw new Error(`bad status code ${t.status}`);const n=t.headers.get("Link"),a=new RTCPeerConnection({iceServers:tr(n),sdpSemantics:"unified-plan"}),s="sendrecv";return a.addTransceiver("video",{direction:s}),a.addTransceiver("audio",{direction:s}),a}catch(t){throw new Error(`Failed to get ICE servers: ${t}`)}},Js=async(e,t)=>fetch(new URL("whep",t),{method:"POST",headers:{"Content-Type":"application/sdp"},body:e}).then((async e=>{switch(e.status){case 201:break;case 404:throw new Error("stream not found");case 400:return e.json().then((e=>{throw new Error(e.error)}));default:throw new Error(`bad status code ${e.status}`)}const n=e.headers.get("location");if(null===n)throw new Error("Missing location header");const a=new URL(n,t).toString();return e.text().then((e=>({sdpReply:e,sessionUrl:a})))})).catch((e=>{throw new Error(`Failed to send offer: ${e}`)})),er=e=>JSON.parse(`"${e}"`),tr=e=>null===e?[]:e.split(", ").map((e=>{const t=e.match(/^<(.+?)>; rel="ice-server"(; username="(.*?)"; credential="(.*?)"; credential-type="password")?/i);if(null===t)throw new Error(`Invalid link: ${e}`);const n={urls:[t[1]]};return void 0!==t[3]&&(n.username=er(t[3]),n.credential=er(t[4])),n})),nr=e=>{const t=e.split("\r\n");return t[0]+=" 118",t.splice(t.length-1,0,"a=rtpmap:118 PCMU/8000/2"),t.splice(t.length-1,0,"a=rtcp-fb:118 transport-cc"),t[0]+=" 119",t.splice(t.length-1,0,"a=rtpmap:119 PCMA/8000/2"),t.splice(t.length-1,0,"a=rtcp-fb:119 transport-cc"),t.join("\r\n")},ar=e=>{const t=e.split("\r\n");return t[0]+=" 112",t.splice(t.length-1,0,"a=rtpmap:112 multiopus/48000/3"),t.splice(t.length-1,0,"a=fmtp:112 channel_mapping=0,2,1;num_streams=2;coupled_streams=1"),t.splice(t.length-1,0,"a=rtcp-fb:112 transport-cc"),t[0]+=" 113",t.splice(t.length-1,0,"a=rtpmap:113 multiopus/48000/4"),t.splice(t.length-1,0,"a=fmtp:113 channel_mapping=0,1,2,3;num_streams=2;coupled_streams=2"),t.splice(t.length-1,0,"a=rtcp-fb:113 transport-cc"),t[0]+=" 114",t.splice(t.length-1,0,"a=rtpmap:114 multiopus/48000/5"),t.splice(t.length-1,0,"a=fmtp:114 channel_mapping=0,4,1,2,3;num_streams=3;coupled_streams=2"),t.splice(t.length-1,0,"a=rtcp-fb:114 transport-cc"),t[0]+=" 115",t.splice(t.length-1,0,"a=rtpmap:115 multiopus/48000/6"),t.splice(t.length-1,0,"a=fmtp:115 channel_mapping=0,4,1,2,3,5;num_streams=4;coupled_streams=2"),t.splice(t.length-1,0,"a=rtcp-fb:115 transport-cc"),t[0]+=" 116",t.splice(t.length-1,0,"a=rtpmap:116 multiopus/48000/7"),t.splice(t.length-1,0,"a=fmtp:116 channel_mapping=0,4,1,2,3,5,6;num_streams=4;coupled_streams=4"),t.splice(t.length-1,0,"a=rtcp-fb:116 transport-cc"),t[0]+=" 117",t.splice(t.length-1,0,"a=rtpmap:117 multiopus/48000/8"),t.splice(t.length-1,0,"a=fmtp:117 channel_mapping=0,6,1,4,5,2,3,7;num_streams=5;coupled_streams=4"),t.splice(t.length-1,0,"a=rtcp-fb:117 transport-cc"),t.join("\r\n")},sr=e=>{const t=e.split("\r\n");return t[0]+=" 120",t.splice(t.length-1,0,"a=rtpmap:120 L16/8000/2"),t.splice(t.length-1,0,"a=rtcp-fb:120 transport-cc"),t[0]+=" 121",t.splice(t.length-1,0,"a=rtpmap:121 L16/16000/2"),t.splice(t.length-1,0,"a=rtcp-fb:121 transport-cc"),t[0]+=" 122",t.splice(t.length-1,0,"a=rtpmap:122 L16/48000/2"),t.splice(t.length-1,0,"a=rtcp-fb:122 transport-cc"),t.join("\r\n")},rr=e=>{let t="";const n=e.split("\r\n");for(let a=0;a<n.length;a++)if(n[a].startsWith("a=rtpmap:")&&n[a].toLowerCase().includes("opus/")){t=n[a].slice("a=rtpmap:".length).split(" ")[0];break}if(""===t)return e;for(let a=0;a<n.length;a++)n[a].startsWith("a=fmtp:"+t+" ")&&(n[a].includes("stereo")||(n[a]+=";stereo=1"),n[a].includes("sprop-stereo")||(n[a]+=";sprop-stereo=1"));return n.join("\r\n")},ir=(e,t)=>{const n={};for(const r of t){const e=r.sdpMLineIndex;if(null===e)throw new Error("Invalid candidate");void 0===n[e]&&(n[e]=[]),n[e].push(r)}let a="a=ice-ufrag:"+e.iceUfrag+"\r\na=ice-pwd:"+e.icePwd+"\r\n",s=0;for(const r of e.medias){if(void 0!==n[s]){a+="m="+r+"\r\na=mid:"+s+"\r\n";for(const e of n[s])a+="a="+e.candidate+"\r\n"}s++}return a},or=(e,t)=>new Promise((n=>{const a=new RTCPeerConnection({iceServers:[]});a.addTransceiver("audio",{direction:"recvonly"}),a.createOffer().then((s=>{if(void 0===s.sdp)throw new Error("No sdp");if(s.sdp.includes(" "+e))return void n(!1);const r=s.sdp.split("m=audio"),i=r[1].split("\r\n");return i[0]+=" 118",i.splice(i.length-1,0,"a=rtpmap:118 "+e),void 0!==t&&i.splice(i.length-1,0,"a=fmtp:118 "+t),r[1]=i.join("\r\n"),s.sdp=r.join("m=audio"),a.setLocalDescription(s)})).then((()=>a.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:"v=0\r\no=- 6539324223450680508 0 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=fingerprint:sha-256 0D:9F:78:15:42:B5:4B:E6:E2:94:3E:5B:37:78:E1:4B:54:59:A3:36:3A:E5:05:EB:27:EE:8F:D2:2D:41:29:25\r\nm=audio 9 UDP/TLS/RTP/SAVPF 118\r\nc=IN IP4 0.0.0.0\r\na=ice-pwd:7c3bf4770007e7432ee4ea4d697db675\r\na=ice-ufrag:29e036dc\r\na=sendonly\r\na=rtcp-mux\r\na=rtpmap:118 "+e+"\r\n"+(void 0!==t?"a=fmtp:118 "+t+"\r\n":"")})))).then((()=>{n(!0)})).catch((()=>{n(!1)})).finally((()=>{a.close()}))}));function lr(e,t,n){const a=2e3;let s=[],r=null,i=null,o="",l=null,c=[];function d(e){null===i&&(n(e+", retrying in some seconds"),null!==r&&(r.close(),r=null),i=window.setTimeout((async()=>{i=null,p()}),a),""!==o&&fetch(o,{method:"DELETE"}),o="",c=[])}function u(){null===i&&null!==r&&"disconnected"===r.iceConnectionState&&d("peer connection closed")}async function m(e){null===i&&null!==e.candidate&&(""===o?c.push(e.candidate):null!==l&&await Qs(o,l,[e.candidate]))}async function h(){if(!r)return;const t=await r.createOffer();t.sdp=Ks(s,t.sdp),l=Gs(t.sdp),await r.setLocalDescription(t);const{sdpReply:n,sessionUrl:a}=await Js(t.sdp,e);o=a,await async function(e){if(null!==i)return;if(null===r)return;await r.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:e})),0!==c.length&&null!==l&&(await Qs(o,l,c),c=[])}(n)}function x(e){null!==t.current&&(n(""),t.current.srcObject=e.streams[0])}async function p(){try{s=await Ys(),await async function(){r=await Xs(e),r.onicecandidate=m,r.oniceconnectionstatechange=u,r.ontrack=x,await h()}()}catch(t){d(t instanceof Error?t.message:"An error occurred")}}return{init:p,cleanup:function(){null!==r&&(r.close(),r=null)}}}function cr(e){const{url:t,showControls:n=!0}=e,s=t.endsWith("/")?t:`${t}/`,[r,i]=(0,a.useState)(null),o=(0,a.useRef)(null),l=(0,a.useMemo)((()=>lr(s,o,i)),[s]);return(0,a.useEffect)((()=>(l.init(),()=>{l.cleanup()})),[l]),(0,H.jsxs)("div",{className:"bg-ondark-bg-2 relative flex h-full w-full",children:[(0,H.jsx)("video",{ref:o,controls:n,muted:!0,playsInline:!0,autoPlay:!0,className:"aspect-video w-full"}),r&&(0,H.jsx)("div",{className:"pointer-events-none absolute inset-0 box-border flex items-center justify-center p-5 text-center text-xs font-bold text-white [text-shadow:0_0_5px_black]",children:r})]})}var dr=n(90245),ur=n(752);function mr(e){const{title:t,subtitle:n,children:s,secondary:r,fullWidth:i=!1,onClickBack:o}=e,l=(0,ur.b9)(gt),c=(0,a.useMemo)((()=>(0,H.jsx)("div",{className:"flex items-center justify-between",children:(0,H.jsxs)("div",{className:"flex items-center py-6",children:[o&&(0,H.jsx)("div",{className:"mr-4",children:(0,H.jsx)(Q,{variant:"icon",onClick:o,onSideEffect:yt("navigate_back_page"),children:(0,H.jsx)(dr.Z,{className:"w-6"})})}),(0,H.jsxs)("div",{children:[(0,H.jsx)("h1",{className:"dark:text-dark-text text-2xl leading-8 text-gray-800",children:t}),(0,H.jsx)("h2",{className:"pt-1 text-base text-gray-600 dark:text-gray-300",children:n})]})]})})),[o,n,t]);return(0,a.useEffect)((()=>{l(c)}),[l,c]),(0,H.jsx)("main",{className:"dark:bg-ondark-bg-1 dark:text-dark-text bg-onlight-bg-1 h-full overflow-y-auto pt-8",children:(0,H.jsx)("div",{className:(0,z.Z)("mx-auto h-full px-4 sm:px-6 md:px-8",!i&&"max-w-container"),children:(0,H.jsxs)("div",{className:"flex h-full flex-col",children:[r&&(0,H.jsx)("div",{className:"mb-2 flex justify-end",children:r}),(0,H.jsx)("div",{className:"flex min-h-0 flex-1 flex-col pb-8",children:s})]})})})}var hr=n(48656);const xr=function(e){const{short:t}=e;return(0,H.jsx)(Ss.rU,{to:"/",className:"focus-visible:ring-primary-500 dark:focus:ring-offset-dark-surface block rounded focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",children:(0,H.jsx)(Sa,{full:!t})})};var pr=n(87466),gr=n(70666);const fr=function(){const{logout:e,profilePic:t}=h(),{name:n}=j(),a=(0,r.s0)(),s=[{name:"Profile and Settings",onClick:()=>{a("/profile/general")}},{name:"Logout",onClick:()=>{(0,b.mc)(),e({returnTo:window.location.origin})}}],i=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("span",{className:"sr-only",children:"Open user menu"}),t?(0,H.jsx)("img",{className:"h-8 w-8 rounded-full",src:t,alt:"user avatar"}):(0,H.jsx)(pr.Z,{className:"h-8 w-8"}),(0,H.jsxs)("span",{className:"mx-2 hidden lg:flex lg:items-center",children:[(0,H.jsx)("span",{className:"text-sm leading-6","aria-hidden":"true",children:n}),(0,H.jsx)(gr.Z,{className:"ml-2 h-4 w-4","aria-hidden":"true"})]})]});return(0,H.jsx)(Cs,{items:s,menuButton:i})};function vr({expandSidebar:e}){const t=(0,ur.Dv)(gt),s=(0,ur.b9)(jt);return(0,a.useEffect)((()=>{I()&&"granted"!==n.g.Notification.permission&&s(Be.OFF)}),[s]),(0,H.jsxs)("div",{className:"dark:bg-ondark-bg-1 dark:text-dark-text bg-onlight-bg-2 border-onlight-line-1 dark:border-ondark-line-1 sticky top-0 z-10 flex h-20 items-center border-b px-4 sm:px-6 md:px-8",children:[(0,H.jsx)("div",{className:"mr-4",children:(0,H.jsxs)(Q,{type:"button",variant:"icon",onClick:e,children:[(0,H.jsx)("span",{className:"sr-only",children:"Open sidebar"}),(0,H.jsx)(hr.Z,{className:"h-6 w-6 rounded-full","aria-hidden":"true"})]})}),(0,H.jsxs)("div",{className:"dark:text-dark-text flex flex-1 items-center justify-between lg:w-full lg:px-0",children:[(0,H.jsx)("span",{className:"sm:max-w-xs lg:max-w-max",children:t}),(0,H.jsx)("span",{className:"absolute left-1/2 -translate-x-1/2",children:(0,H.jsx)("span",{className:"hidden sm:block",children:(0,H.jsx)(xr,{})})}),(0,H.jsx)("div",{className:"flex-shrink-0 pr-4",children:(0,H.jsx)(fr,{})})]})]})}const jr=function(e){const{items:t,short:n,onClick:a=(()=>null)}=e;return(0,H.jsx)("nav",{children:(0,H.jsx)("div",{className:"space-y-1",children:t.map((e=>(0,H.jsx)(Ss.OL,{to:e.href,title:e.name,className:({isActive:e})=>(0,z.Z)(e?"dark:text-dark-text bg-gray-200 text-gray-700 dark:bg-gray-700 ":"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300","focus-visible:ring-primary-500 dark:focus:ring-offset-dark-surface group flex items-center rounded-md px-3 py-2 text-sm font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2"),onClick:a,children:({isActive:t})=>(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(e.icon,{className:(0,z.Z)(t?"dark:text-dark-text text-gray-700":"text-gray-500 group-hover:text-gray-700 dark:group-hover:text-gray-300","mr-3 h-6 w-6 flex-shrink-0"),"aria-hidden":"true"}),n?"":e.name]})},e.name)))})})};var br=n(68218);const yr=function(e){const{collapsed:t,onClick:n}=e,a=t?"expand_sidebar":"collapse_sidebar";return(0,H.jsxs)(Q,{title:a.split("_").join(" "),variant:"icon",onClick:n,onSideEffect:yt(a),children:[(0,H.jsx)("span",{className:"sr-only",children:a}),t?(0,H.jsx)(br.Z,{className:"h-6 text-gray-700 dark:text-gray-400","aria-hidden":"true"}):(0,H.jsx)("span",{className:"inline-block h-6 w-6 flex-shrink-0",children:(0,H.jsx)(Ga,{"aria-hidden":"true"})})]})};const kr=function(e){const{collapsed:t,navItems:n,onClick:a=(()=>null),toggleSidebar:s,isMobile:r}=e,i=j(),o=n.filter((e=>e.requiredPermissions.every((e=>Ge(i,e)))));return(0,H.jsxs)("div",{className:(0,z.Z)(t?"space-y-8 px-2 text-center":"space-y-8 px-8"),children:[r&&(0,H.jsx)(xr,{}),s&&(t?(0,H.jsxs)("div",{className:"border-onlight-line-2 dark:border-ondark-line-2 border-b",children:[(0,H.jsx)(xr,{short:!0}),(0,H.jsx)("div",{className:"py-4",children:(0,H.jsx)(yr,{collapsed:!0,onClick:s})})]}):(0,H.jsxs)("div",{className:"border-onlight-line-2 dark:border-ondark-line-2 flex h-20 items-center justify-between border-b",children:[(0,H.jsx)(xr,{}),(0,H.jsx)(yr,{onClick:s})]})),t?(0,H.jsx)(jr,{short:!0,items:o,onClick:a}):(0,H.jsx)("div",{className:"-mx-3 space-y-4",children:(0,H.jsx)(jr,{items:o,onClick:a})})]})};function wr(e){const{open:t,navItems:n,onClose:s}=e;return(0,H.jsx)(ie.u.Root,{show:t,as:a.Fragment,children:(0,H.jsxs)(oe.V,{as:"div",className:"relative z-40",onClose:s,children:[(0,H.jsx)(ie.u.Child,{as:a.Fragment,enter:"transition-opacity ease-linear duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"transition-opacity ease-linear duration-300",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,H.jsx)("div",{className:"fixed inset-0 bg-gray-600 bg-opacity-75"})}),(0,H.jsx)("div",{className:"fixed inset-0 z-40",children:(0,H.jsx)(ie.u.Child,{as:a.Fragment,enter:"transition ease-in-out duration-300 transform",enterFrom:"-translate-x-full",enterTo:"translate-x-0",leave:"transition ease-in-out duration-300 transform",leaveFrom:"translate-x-0",leaveTo:"-translate-x-full",children:(0,H.jsxs)(oe.V.Panel,{className:"relative h-full max-w-xs bg-gray-100 py-4 dark:bg-gray-800",children:[(0,H.jsx)("div",{className:"absolute top-4 right-4",children:(0,H.jsxs)(Q,{variant:"icon",onClick:s,onSideEffect:yt("close_sidebar_mobile"),children:[(0,H.jsx)("span",{className:"sr-only",children:"Close sidebar"}),(0,H.jsx)(le.Z,{className:"h-6 w-6","aria-hidden":"true"})]})}),(0,H.jsx)(kr,{isMobile:!0,navItems:n,onClick:s})]})})})]})})}function Nr(e){const{children:t,navItems:n}=e,[s,r]=(0,a.useState)(!1),i=(0,ur.Dv)(ft);return(0,H.jsxs)("div",{className:"dark:bg-dark-bg h-full dark:text-white",children:[(0,H.jsx)(wr,{open:s,navItems:n,onClose:()=>r(!1)}),(0,H.jsxs)("div",{className:"flex flex-col lg:h-full","data-testid":"page-container",children:[(0,H.jsx)(vr,{expandSidebar:()=>{r(!0)}}),(0,H.jsx)("div",{className:"flex-1 overflow-y-auto",children:t}),i]})]})}const Cr=["LOCAL","DEV","STAGING","DEMO","PROD","AIRGAP"],Sr=["local","auth0"];function Tr(e){var t,n;return null!=(t=null==(n=window._APP_ENV_)?void 0:n[e])?t:"UNKNOWN"}function Er(e,t){const n=Tr(e),a=t(n);if(null===a)throw new Error(`Invalid value "${n}" for environment variable "${e}"`);return a}const Ar={auth0:{domain:Tr("AUTH0_DOMAIN"),clientId:Tr("AUTH0_CLIENT_ID"),audience:Tr("AUTH0_AUDIENCE")},release:Tr("RELEASE_NAME"),name:Er("ENVIRONMENT",(function(e){return Cr.includes(e)?e:null})),authMode:Er("AUTH_MODE",(function(e){return Sr.includes(e)?e:null})),amplitudeApiKey:Tr("AMPLITUDE_API_KEY"),elevenLabsApiKey:Tr("ELEVEN_LABS_API_KEY")};function _r(e){const{onChange:t,alarmTypes:n,isEditing:s,disabledTypes:r,label:i}=e,[o,l]=(0,a.useState)([]);na(j().tenant.id,(e=>{var t;l((null==(t=e.alarmProcessingConfig)?void 0:t.alarm_types)||[])}));const c=e=>e;return(0,H.jsxs)("div",{className:"mt-4 flex w-full items-center gap-x-4 pb-2",children:[(0,H.jsx)("span",{className:"text-onlight-text-2 dark:text-ondark-text-2 text-sm",children:i}),s?(0,H.jsx)(Fs,{value:n,getItems:e=>o.filter((t=>t.toLowerCase().includes(e.toLowerCase()))),displayValue:c,onChange:t,customSelectedRenderer:e=>(0,H.jsx)(H.Fragment,{children:e.map(((e,a)=>(0,H.jsx)("span",{className:"mr-1",children:(0,H.jsx)(re,{text:e,removable:s,onClickRemove:()=>(e=>{const a=[...n];a.splice(e,1),t(a)})(a),type:"info"})},e)))}),disabled:e=>!(!r||!r.includes(e))}):(0,H.jsx)("div",{className:"flex flex-wrap",children:n.map((e=>(0,H.jsx)("span",{className:"mr-1 mb-1",children:(0,H.jsx)(re,{text:e,type:"info"})})))})]})}var Ir=n(20109),Lr=n(71377),Rr=n(96602),Dr=n(6079);function Pr(e){const t=e%60;return`${Math.floor(e/60).toString().padStart(1,"0")}:${t.toFixed(0).padStart(2,"0")}`}function Mr(e){const{isLoading:t,src:n}=e,s=(0,a.useRef)(null),[r,i]=(0,a.useState)(!1),[o,l]=(0,a.useState)(0);(0,a.useEffect)((()=>{let e;return r&&(e=window.setInterval((()=>{var e;l((null==(e=s.current)?void 0:e.currentTime)||0)}),1e3)),()=>{e&&window.clearInterval(e)}}),[r]),(0,a.useEffect)((()=>{const e=s.current,t=()=>{i(!1)};return e&&e.addEventListener("ended",t),()=>{e&&e.removeEventListener("ended",t)}}),[]);return(0,H.jsxs)("div",{className:(0,z.Z)("dark:bg-ondark-bg-2 bg-onlight-bg-3 dark:text-ondark-text-1 text-onlight-text-1 dark:border-ondark-line-2 border-onlight-line-2 flex items-center gap-2 rounded-xl border px-6 py-1",""===n&&"pointer-events-none opacity-75"),tabIndex:1,onClick:()=>{var e,t;(i((e=>!e)),r)?null==(e=s.current)||e.pause():null==(t=s.current)||t.play()},children:[r?(0,H.jsx)(Rr.Z,{className:"h-3 w-3"}):(0,H.jsx)(Dr.Z,{className:"h-3 w-3"}),(0,H.jsx)("span",{className:"text-xs",children:Pr(o)}),t&&(0,H.jsx)("span",{className:"text-onlight-text-3",children:(0,H.jsx)(W,{})}),(0,H.jsx)("audio",{ref:s,src:n,className:"inline-block h-12 scale-75"})]})}const Or=Mr,Fr=[{text:"The premises is currently closed. This area is under video surveillance and you are being recorded. Please leave the area.",prefetch:!0},{text:"Person in , You are being recorded. Please leave the area or police will be dispatched.",prefetch:!1,inputAfterWordCount:2,placeholder:"eg: Red shirt"},{text:"",prefetch:!1,inputAfterWordCount:0,placeholder:"Write your custom message here.."}];function Zr(e,t,n){if(void 0!==t&&n){const a=e.split(" ");return a.splice(t,0,n),a.join(" ")}return e}function qr(e){const{text:t,prefetch:n,inputAfterWordCount:s,updateAudioFile:r,placeholder:i,updateFinalTemplateText:o,isInputValueInvalid:l,showFetchAction:c=!0,alignment:d="horizontal"}=e,[u,m]=(0,a.useState)(""),[h,x]=(0,a.useState)(""),{isLoading:p,fetchAudio:g}=ia(Ar.elevenLabsApiKey),f=(0,a.useRef)(!1),v=e=>{m(e.currentTarget.value),o&&o(Zr(t,s,e.currentTarget.value))};let j,b="",y="";if(void 0!==s){const e=t.split(" "),n=(0,H.jsx)(ae,{type:"text",required:!0,error:l,onChange:v,value:u,placeholder:i});e.length>1?(b=e.slice(0,s).join(" "),y=e.slice(s).join(" "),j=(0,H.jsxs)(H.Fragment,{children:[b," ",(0,H.jsx)("span",{className:"mx-2 max-w-[8rem]",children:n})," ",y]})):j=(0,H.jsx)("span",{className:"w-[40rem]",children:n})}else j=t;const k=(0,a.useCallback)((async()=>{const e=await g(Zr(t,s,u));if(!(e instanceof Error)){const{audioUrl:t,file:n}=e;x(t),r(n)}}),[g,s,u,t,r]);(0,a.useEffect)((()=>{n&&!f.current&&(f.current=!0,k())}),[k,n]);return(0,H.jsxs)("div",{className:(0,z.Z)("horizontal"===d&&"grid w-[62rem] grid-cols-8 justify-items-center","vertical"===d&&"flex flex-col items-center space-y-3"),children:[(0,H.jsx)("div",{className:"col-span-6 flex items-center justify-self-start",children:j}),(0,H.jsx)("span",{className:"flex items-center",children:(0,H.jsx)(Or,{src:h,isLoading:p})}),c&&(0,H.jsx)(Q,{onClick:e=>{e.stopPropagation(),e.nativeEvent.stopImmediatePropagation(),k()},loading:p,disabled:void 0!==s&&""===u,children:(0,H.jsxs)("span",{className:"text-xs",children:[h?"Refetch":"Fetch"," Audio"]})})]})}const Ur=(0,a.memo)(qr);const Vr=function(e){const{onClose:t,open:n,cameraName:s,onSubmitAudio:r}=e,[i,o]=(0,a.useState)(new Array(Fr.length)),[l,c]=(0,a.useState)(0),{isLoading:d,fetchAudio:u}=ia(Ar.elevenLabsApiKey),[m,h]=(0,a.useState)(Fr.map((e=>e.text))),[x,p]=(0,a.useState)({isValid:!0,message:""}),[g,f]=(0,a.useState)({isError:!1,message:""}),v=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:async()=>{if(void 0===Fr[l].inputAfterWordCount||Fr[l].text!==m[l]){if(p({isValid:!0,message:""}),i[l])r(i[l]);else{const e=m[l],t=await u(e);if(t instanceof Error)return void f({isError:!0,message:t.message});const{file:n}=t;r(n)}t()}else p({isValid:!1,message:"Provide a valid value in the input field"})},onSideEffect:()=>yt("submit_text_to_speech_camera_talkdown")({message:m[l],cameraName:s}),loading:d,children:"Send audio"}),(0,H.jsx)(Q,{onClick:t,children:"Cancel"})]}),j=(0,a.useCallback)((e=>t=>{const n=[...i];n[e]=t,o(n),c(e)}),[i]),b=Fr.map(((e,t)=>{return Object.assign({},e,{node:(0,H.jsx)(Ur,{prefetch:e.prefetch,text:e.text,updateAudioFile:j(t),inputAfterWordCount:e.inputAfterWordCount,placeholder:e.placeholder,updateFinalTemplateText:(n=t,e=>{const t=[...m];t[n]=e,h(t),p({isValid:!0,message:""})}),isInputValueInvalid:!x.isValid&&l===t}),index:t});var n})),y=e=>{c(+e.target.id||0),p({isValid:!0,message:""})};return(0,H.jsx)(ce,{onClose:t,open:n,closable:!0,footer:v,title:`Live talkdown for ${s}`,children:(0,H.jsxs)("div",{className:"p-8",children:[!x.isValid&&(0,H.jsx)(B,{type:"warning",children:x.message}),g.isError&&(0,H.jsx)(B,{type:"error",children:g.message}),(0,H.jsxs)("fieldset",{children:[(0,H.jsx)("legend",{className:"sr-only",children:"Theme"}),(0,H.jsx)("div",{className:"flex flex-col space-y-4 rounded-md",children:b.map((e=>{const t=e.index===l;return(0,H.jsxs)("div",{className:(0,z.Z)("flex items-center p-2",t?"border-primary-200 bg-primary-50 dark:bg-primary-900/30 dark:border-primary-800":"border-gray-200 dark:border-gray-600"),children:[(0,H.jsx)("input",{id:`${e.index}`,name:"notification-method",type:"radio",defaultChecked:t,className:"text-primary-600 focus:ring-primary-500 dark:checked:bg-primary-500 dark:focus:ring-primary-600 h-4 w-4 border-gray-300 bg-gray-100 focus:ring-2 dark:border-none dark:bg-gray-700 dark:ring-offset-gray-800",onChange:y}),(0,H.jsx)("label",{htmlFor:`${e.index}`,className:(0,z.Z)("ml-3 block text-sm font-medium",t?"text-primary-900 dark:text-primary-200":"dark:text-dark-text text-gray-900"),children:e.node})]},e.index)}))})]})]})})};var $r=n(84609),zr=n(960);const Hr=function(e){const{onClose:t,onChangeAudio:n,onSubmitAudio:s}=e,r=(0,a.useRef)(null),[i,o]=(0,a.useState)(!0),[l,c]=(0,a.useState)(),d=(0,a.useCallback)((e=>{if(e.data.size>0){const t=r.current;if(t){t.src=URL.createObjectURL(e.data);const a=new File([e.data],Date.now()+".webm");n(a)}}}),[n]);return(0,a.useEffect)((()=>{navigator.mediaDevices.getUserMedia({audio:!0,video:!1}).then((e=>{const t=new AudioContext,n=t.createMediaStreamSource(e),a=t.createGain(),s=t.createMediaStreamDestination();a.gain.value=2,n.connect(a),a.connect(s);const r=s.stream,i=new MediaRecorder(r,{mimeType:'audio/webm;codecs="opus"'});c(i),o(!0)})).catch((e=>{Le("Unable to access microphone",{type:"error"}),y.uT("Unable to access microphone",{extra:{error:e}}),t()}))}),[t]),(0,a.useEffect)((()=>(null==l||l.addEventListener("dataavailable",d),()=>{null==l||l.removeEventListener("dataavailable",d),null==l||l.stream.getTracks().forEach((e=>e.stop()))})),[l,d]),(0,a.useEffect)((()=>{i?null==l||l.start():null==l||l.stop()}),[l,i]),(0,H.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-4",children:[(0,H.jsxs)("div",{className:"flex items-center justify-center",children:[!i&&(0,H.jsx)("span",{className:"-mr-10",children:(0,H.jsx)(Q,{variant:"icon",onClick:()=>{t()},children:(0,H.jsx)($r.Z,{className:"w-5"})})}),i?(0,H.jsxs)("div",{className:"flex items-center gap-2",children:[(0,H.jsxs)("span",{className:"inline-flex h-3 w-3",children:[(0,H.jsx)("span",{className:"absolute inline-flex h-3 w-3 animate-ping rounded-full bg-red-400 opacity-75"}),(0,H.jsx)("span",{className:"relative inline-flex h-3 w-3 rounded-full bg-red-500"})]}),(0,H.jsx)("span",{className:"dark:text-dark-secondary-text text-gray-500",children:"Recording audio..."})]}):(0,H.jsx)("audio",{ref:r,className:"inline-block h-12 scale-75",controls:!0})]}),i?(0,H.jsx)(Q,{variant:"icon",onClick:()=>{o(!1)},children:(0,H.jsx)(zr.Z,{className:"w-5"})}):(0,H.jsx)("span",{className:"-ml-10",children:(0,H.jsx)(Q,{variant:"icon",onClick:()=>{o(!0)},children:(0,H.jsx)(Lr.Z,{className:"w-5 text-red-500"})})}),!i&&(0,H.jsx)(Q,{variant:"primary",onClick:()=>{s(),t()},onSideEffect:yt("submit_manual_camera_audio_talkdown"),children:"Send audio"})]})};function Br(e){const{cameraId:t,alarmId:n,onTalkdown:s,onToggle:r,locAlarmId:i,escalationId:o,cameraName:l=""}=e,[c,d]=(0,a.useState)(!1),[u,m]=(0,a.useState)(),[h,x]=(0,a.useState)(!1),p=Ut(t,n,i,(()=>{s(t,n||i||o),Le("Audio sent to camera successfully")}),o),g=(0,a.useCallback)((e=>{const t=new FormData;t.append("audio",e||""),p.mutate(t)}),[p]),f=(0,a.useCallback)((()=>{d(!1),r&&r(!1)}),[r]);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"flex items-center justify-end",children:c?(0,H.jsx)(Hr,{onClose:f,onChangeAudio:m,onSubmitAudio:()=>g(u)}):(0,H.jsxs)("span",{className:"flex items-center gap-2",children:[(0,H.jsx)(Q,{variant:"icon",onClick:()=>x(!0),title:"Audio talkdown audio upload",children:(0,H.jsx)(Ir.Z,{className:"h-5 w-5"})}),(0,H.jsx)(Q,{variant:"icon",onClick:()=>{d(!0),r&&r(!0)},title:"Live camera audio talkdown",children:(0,H.jsx)(Lr.Z,{className:"h-5 w-5"})})]})}),h&&(0,H.jsx)(Vr,{onClose:()=>x(!1),open:h,cameraName:l,onSubmitAudio:g})]})}function Wr(e){const{text:t,performTalkdown:n,isLoading:s}=e,[r,i]=(0,a.useState)();return(0,H.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4",children:[(0,H.jsx)(qr,{text:t,updateAudioFile:e=>{i(e)},prefetch:!0,showFetchAction:!1,alignment:"vertical"}),(0,H.jsx)(Q,{variant:"primary",onClick:()=>{r&&n(r)},loading:s,children:"Send audio"})]})}function Gr(){const[e,t]=(0,a.useState)(""),[n,s]=(0,a.useState)(""),i=(0,r.s0)(),o=(0,r.TH)(),[l,c]=M("token"),d=an((async({token:e})=>{Le("Login successful",{type:"success"}),c(e);const t=new URLSearchParams(o.search);i(t.get("redirectTo")||"/")}));return l?(0,H.jsx)(r.Fg,{to:"/"}):(0,H.jsxs)("div",{className:"relative flex min-h-full items-center justify-center py-12 px-4 sm:px-6 lg:px-8",children:[(0,H.jsx)("img",{className:"absolute right-0 top-0 block h-64 w-64",src:"/assets/hakimo-arc.svg",alt:"Hakimo arc"}),(0,H.jsxs)("div",{className:"w-full max-w-md space-y-8",children:[(0,H.jsx)("div",{children:(0,H.jsx)("div",{className:"flex justify-center",children:(0,H.jsx)(Sa,{full:!0,lg:!0})})}),d.isError&&(0,H.jsx)(B,{type:"error",children:d.error.message}),(0,H.jsxs)("form",{className:"mt-8 space-y-6",onSubmit:t=>{t.preventDefault(),d.mutate({email:e,password:n})},children:[(0,H.jsxs)("div",{className:"space-y-4 rounded-md shadow-sm",children:[(0,H.jsx)("div",{children:(0,H.jsx)(ae,{label:"Email",type:"email",value:e,onChange:e=>t(e.target.value),autoComplete:"email",required:!0})}),(0,H.jsx)("div",{children:(0,H.jsx)(ae,{label:"Password",type:"password",value:n,onChange:e=>s(e.target.value),autoComplete:"current-password",required:!0})})]}),(0,H.jsx)("div",{children:(0,H.jsx)(Q,{block:!0,type:"submit",variant:"primary",loading:d.isLoading,disabled:d.isLoading,children:"Sign In"})}),(0,H.jsx)("div",{className:"flex justify-center",children:(0,H.jsx)(Q,{variant:"link",disabled:!0,children:"Forgot your password?"})})]})]})]})}var Kr=n(48389),Yr=n(9406);const Qr=[{id:2,name:"2x"},{id:1.5,name:"1.5x"},{id:1,name:"Normal"},{id:.75,name:"0.75x"},{id:.5,name:"0.5x"}];const Xr=function(e){const{onChange:t,selectedId:n}=e,s=Qr.find((e=>e.id===n));return(0,H.jsx)("div",{className:"flex items-center justify-center",children:(0,H.jsx)(Ls.R,{value:s,onChange:e=>t(e.id),children:({open:e})=>(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Ls.R.Label,{className:"sr-only",children:"Change playback speed"}),(0,H.jsxs)("div",{className:"relative flex",children:[(0,H.jsx)(Ls.R.Button,{className:"rounded-full border-transparent p-1 hover:bg-slate-800/50",children:(0,H.jsx)(Pa,{className:"fill-dark-text h-6 w-6"})}),(0,H.jsx)(ie.u,{show:e,as:a.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,H.jsx)(Ls.R.Options,{className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 absolute bottom-6 -left-14 z-10 mt-1 w-24 overflow-auto rounded-md py-1 text-xs shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none",children:Qr.map((e=>(0,H.jsx)(Ls.R.Option,{className:({active:e})=>(0,z.Z)(e?"bg-onlight-primary dark:bg-ondark-primary text-white":"text-onlight-text-1 dark:text-ondark-text-1","relative cursor-default select-none px-3 py-1"),value:e,children:({selected:t,active:n})=>(0,H.jsx)("div",{className:"flex w-full flex-col",children:(0,H.jsxs)("div",{className:"flex justify-between",children:[(0,H.jsx)("p",{className:t?"font-bold":"font-normal",children:e.name}),t?(0,H.jsx)("span",{className:n?"text-white":"text-onlight-primary dark:text-ondark-primary",children:(0,H.jsx)(Ds.Z,{className:"h-4 w-4","aria-hidden":"true"})}):null]})})},e.id)))})})]})]})})})};function Jr(e){const{videoRef:t,videoPath:n}=e,[s,r]=(0,a.useState)(!0),i=null==t?void 0:t.current;return(0,a.useEffect)((()=>{const e=()=>r(!0),t=()=>r(!1);return null==i||i.addEventListener("waiting",e),null==i||i.addEventListener("playing",t),()=>{null==i||i.removeEventListener("waiting",e),null==i||i.removeEventListener("playing",t)}}),[i]),(0,a.useEffect)((()=>{r(!0)}),[n]),s?(0,H.jsx)("div",{className:"bg-dark-bg/25 absolute inset-0 z-[5] flex items-center justify-center",children:(0,H.jsx)(K,{className:"text-hakimo-yellow"})}):null}const ei=0,ti=50,ni=e=>{const t=Math.floor(e%60),n=Math.floor(e/60)%60,a=Math.floor(e/3600),s=t<10?`0${t}`:t,r=n<10?`0${n}`:n;return 0===a?`${r}:${s}`:`${a<10?`0${a}`:a}:${r}:${s}`};function ai(e){const{currentTime:t,duration:n,onSeekVideo:s}=e,r=(0,a.useRef)(null),[i,o]=(0,a.useState)(0),[l,c]=(0,a.useState)("");let d=0;t&&n&&(d=t/n*100);return(0,H.jsx)("div",{className:"video-timeline h-2 w-full cursor-pointer",onMouseMove:e=>{var t;const a=null==(t=r.current)?void 0:t.clientWidth;if(n&&a){let t=e.nativeEvent.offsetX-ei;t=t<ei?ei:t>a-ti?a-ti:t,o(t);const s=Math.floor(n/a*t);c(ni(s))}},onMouseLeave:()=>c(""),ref:r,onClick:e=>{var t;const a=e.nativeEvent.offsetX-ei,i=null==(t=r.current)?void 0:t.clientWidth;if(n&&i){s(n/i*a)}},children:(0,H.jsxs)("div",{className:"progress-area bg-ondark-bg-3 relative h-1",children:[(0,H.jsx)("span",{className:"text-onlight-bg-2 pointer-events-none absolute -top-6 text-sm",style:{left:`${i}px`},children:l}),(0,H.jsx)("div",{className:"bg-ondark-text-1 h-full transition-all duration-700 ease-in-out",style:{width:`${d}%`}})]})})}var si=n(35421),ri=n(5921);function ii(e){const{video:t}=e,[n,s]=(0,a.useState)(1),r=(0,a.useRef)(),[i,o]=(0,a.useState)(!1);(0,a.useEffect)((()=>{i?(t.style.cursor="grab",r.current=function(e){const t=e.parentElement;if(!t)return;let n=!1,a=[],s=[0,0];const r=t=>{n=!0,e.style.cursor="grabbing",a=[t.offsetX-s[0],t.offsetY-s[1]]},i=t=>{n&&(n=!1,e.style.cursor="grab",s=[t.offsetX-a[0],t.offsetY-a[1]],t.stopPropagation())},o=t=>{if(!n)return;const s=t.offsetX,r=t.offsetY;e.style.translate=`${s-a[0]}px ${r-a[1]}px`};return e.addEventListener("mousedown",r),t.addEventListener("mousemove",o),t.addEventListener("mouseup",i,!0),t.addEventListener("mouseout",i),()=>{e.removeEventListener("mousedown",r),t.removeEventListener("mousemove",o),t.removeEventListener("mouseup",i),t.removeEventListener("mouseout",i)}}(t)):(t.style.cursor="auto",r.current&&r.current())}),[i,t]);return(0,H.jsxs)("div",{className:(0,z.Z)("group/zoom from-dark-bg/80 flex items-center justify-center gap-2 rounded-bl-md bg-gradient-to-l to-zinc-500/50 p-1 pr-2"),children:[(0,H.jsx)(Q,{variant:"icon",onClick:()=>{o(!1)},title:"Pointer",classNames:(0,z.Z)("hidden group-hover/zoom:block focus:ring-offset-0",i?"enabled:hover:bg-slate-800":"bg-primary-600/50 enabled:hover:bg-primary-700/80 dark:enabled:hover:bg-primary-700/80"),children:(0,H.jsx)(qa,{className:"fill-dark-text stroke-dark-text h-5 w-5"})}),(0,H.jsx)(Q,{variant:"icon",onClick:()=>o(!i),title:"Pan",classNames:(0,z.Z)("hidden group-hover/zoom:block focus:ring-offset-0",i?"bg-primary-600/50 enabled:hover:bg-primary-700/80 dark:enabled:hover:bg-primary-700/80":"enabled:hover:bg-slate-800"),children:(0,H.jsx)(Ua,{className:"fill-dark-text hover:fill-ondark-text-1 h-5 w-5 pr-1"})}),(0,H.jsx)(Q,{variant:"icon",onClick:()=>{t.style.transform="scale(1)",t.style.translate="0px 0px",o(!1),s(1)},title:"Reset",classNames:"group-hover/zoom:block hidden enabled:hover:bg-slate-800 focus:ring-offset-0",children:(0,H.jsx)(Va,{className:"fill-dark-text hover:fill-ondark-text-1 h-5 w-5"})}),(0,H.jsx)(Q,{variant:"icon",onClick:()=>{const e=n+.1;t.style.transform="scale("+e+")",s(e),o(!0)},title:"Zoom In",classNames:"enabled:hover:bg-slate-800 focus:ring-offset-0",children:(0,H.jsx)(si.Z,{className:"stroke-dark-text hover:stroke-ondark-text-1 h-5 w-5"})}),(0,H.jsx)(Q,{variant:"icon",onClick:()=>{if(n>1){const e=n-.1;t.style.transform="scale("+e+")",s(e)}},disabled:n<=1,title:"Zoom Out",classNames:"enabled:hover:bg-slate-800 focus:ring-offset-0",children:(0,H.jsx)(ri.Z,{className:"stroke-dark-text hover:stroke-ondark-text-1 h-5 w-5"})})]})}function oi(e){const{videoPath:t,videoRef:n,containerRef:s,isFullScreen:r,onFullScreen:i,time:o,controlsList:l}=e,[c,d]=(0,a.useState)(0),[u,m]=(0,a.useState)(!1),[h,x]=(0,a.useState)(1),p=null==n?void 0:n.current,[g,f]=(0,a.useState)(),[v,j]=(0,a.useState)(),[b,y]=(0,a.useState)(0),k=(0,a.useCallback)((()=>{!p||p.currentTime<0||(p.paused?p.play():p.pause(),m(p.paused))}),[p]);(0,a.useEffect)((()=>{const e=()=>m(!1);return p&&(p.addEventListener("mouseup",k),p.addEventListener("playing",e)),()=>{null==p||p.removeEventListener("mouseup",k),null==p||p.removeEventListener("playing",e)}}),[i,k,p]),(0,a.useEffect)((()=>{const e=()=>{if(!p)return;const{currentTime:e,duration:t}=p;f(e),j(t)};return p&&p.addEventListener("timeupdate",e),()=>{p&&p.removeEventListener("timeupdate",e)}}),[p]),(0,a.useEffect)((()=>{const e=()=>m(!0);return p&&p.addEventListener("ended",e),()=>{p&&p.removeEventListener("ended",e)}}),[p]),(0,a.useEffect)((()=>{const e=()=>y(100),t=()=>y(0),n=null==s?void 0:s.current;return n&&(n.addEventListener("mouseenter",e),n.addEventListener("mouseleave",t)),()=>{n&&(n.removeEventListener("mouseenter",e),n.removeEventListener("mouseleave",t))}}),[s]);const w=e=>{p&&(p.volume=e,p.muted=!1,d(e))},N=e=>!l||!l.includes(e);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{className:(0,z.Z)("from-dark-surface absolute left-0 right-0 bottom-0 bg-gradient-to-t p-1 pt-2 transition-opacity duration-500",r&&"px-4 pb-6 pt-8",`opacity-${b}`),children:[N("noVideoTimeline")&&(0,H.jsx)(ai,{currentTime:g,duration:v,onSeekVideo:e=>{p&&(p.currentTime=e)}}),(0,H.jsxs)("ul",{className:"grid grid-cols-3",children:[(0,H.jsxs)("li",{className:"flex items-center justify-start",children:[N("noAudio")&&(0,H.jsxs)("div",{className:"group/audio relative",children:[(0,H.jsx)(Q,{variant:"icon",classNames:"text-dark-text enabled:hover:bg-slate-800/50 focus:ring-offset-0",onClick:()=>w(0===c?.5:0),children:0===c?(0,H.jsx)(Kr.Z,{className:"h-6 w-6"}):(0,H.jsx)(Yr.Z,{className:"h-6 w-6"})}),(0,H.jsx)("input",{className:"accent-ondark-primary absolute -top-10 -left-6 ml-1 hidden h-1 max-w-[75px] -rotate-90 group-hover/audio:block",type:"range",min:"0",max:"1",onChange:e=>w(+e.target.value),value:c,step:"any"})]}),(0,H.jsx)("div",{className:"text-dark-text ml-2 text-xs",children:o||(0,H.jsxs)("span",{className:"ml-4 whitespace-nowrap",children:[ni(g||0)," / ",ni(v||0)]})})]}),(0,H.jsxs)("li",{className:"flex justify-center",children:[N("noForwardBackward")&&(0,H.jsx)(Q,{variant:"icon",onClick:()=>{p&&(p.currentTime-=10)},classNames:"text-dark-text enabled:hover:bg-slate-800/50 focus:ring-offset-0",children:(0,H.jsx)(Za,{className:"fill-dark-text h-7 w-7"})}),N("noPlayPause")&&(0,H.jsx)(Q,{variant:"icon",onClick:k,classNames:"text-dark-text enabled:hover:bg-slate-800/50 focus:ring-offset-0",children:u?(0,H.jsx)(Dr.Z,{className:"h-6 w-6"}):(0,H.jsx)(Rr.Z,{className:"h-6 w-6"})}),N("noForwardBackward")&&(0,H.jsx)(Q,{variant:"icon",onClick:()=>{p&&(p.currentTime+=10)},classNames:"text-dark-text enabled:hover:bg-slate-800/50 focus:ring-offset-0",children:(0,H.jsx)(Fa,{className:"fill-dark-text h-7 w-7"})})]}),(0,H.jsxs)("li",{className:"flex items-center justify-end",children:[N("noPlaybackRate")&&(0,H.jsx)(Xr,{onChange:e=>{p&&(p.playbackRate=e,x(e))},selectedId:h}),N("noFullscreen")&&(0,H.jsx)(Q,{variant:"icon",onClick:i,classNames:"enabled:hover:bg-slate-800/50 focus:ring-offset-0",children:r?(0,H.jsx)(Oa,{className:"fill-dark-text h-7 w-7"}):(0,H.jsx)(Ma,{className:"fill-dark-text h-7 w-7"})})]})]})]}),N("noLoader")&&(0,H.jsx)(Jr,{videoRef:n,videoPath:t}),(null==n?void 0:n.current)&&(0,H.jsx)("div",{className:(0,z.Z)("absolute top-0 right-0 z-10 transition-opacity",`opacity-${b}`),children:(0,H.jsx)(ii,{video:n.current})})]})}const li=oi;const ci=function(e){const{children:t}=e,n=(0,a.useRef)(null),s=n.current?n.current.clientWidth:200,[r,i]=(0,a.useState)({top:0,left:window.innerWidth-s}),[o,l]=(0,a.useState)(!1),c=(0,a.useRef)({x:0,y:0}),d=(0,a.useCallback)((e=>{if(!o)return;let t=e.clientX-c.current.x,n=e.clientY-c.current.y;const a=window.innerWidth-s,r=window.innerHeight-s;t<0&&(t=0),n<0&&(n=0),t>a&&(t=a),n>r&&(n=r),i({left:t,top:n})}),[o,s]),u=()=>{l(!1)};return(0,a.useEffect)((()=>(o?(document.addEventListener("mousemove",d),document.addEventListener("mouseup",u)):(document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",u)),()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",u)})),[o,d]),(0,H.jsxs)("div",{className:"overflow-hidden rounded-md shadow-2xl shadow-gray-400 dark:shadow-gray-700",ref:n,style:{position:"fixed",top:`${r.top}px`,left:`${r.left}px`,zIndex:1e3},children:[(0,H.jsx)("div",{className:"bg-onlight-bg-3 dark:bg-ondark-bg-3 flex h-8 items-center justify-start",style:{cursor:o?"grabbing":"grab"},onMouseDown:e=>{l(!0),c.current={x:e.clientX-r.left,y:e.clientY-r.top}},children:(0,H.jsx)($a,{className:"fill-onlight-text-2 dark:fill-ondark-text-2 ml-2 h-5 w-5"})}),t]})};var di=n(15878);const ui=["hls","timeZone","controlsList"];function mi(e){const{hls:t,timeZone:n,controlsList:s}=e,r=(0,di.Z)(e,ui),[i,o]=(0,a.useState)();return(0,a.useEffect)((()=>{const e=window.setInterval((()=>{t&&t.playingDate&&o(t.playingDate)}),1e3);return()=>{e&&clearInterval(e)}}),[t]),null!=s&&s.includes("onlyTime")?i&&(0,H.jsx)("div",{className:"from-dark-surface text-dark-text absolute left-0 right-0 bottom-0 ml-2 bg-gradient-to-t p-1 pt-2 text-xs",children:i.toLocaleString("en-US",{timeZone:n})}):(0,H.jsx)(li,Object.assign({time:null==i?void 0:i.toLocaleString("en-US",{timeZone:n}),controlsList:s},r))}var hi=n(69818);function xi(e,t,s,r,i,o){const{getAccessToken:l}=h(),[c,d]=(0,a.useState)(),u=(0,a.useRef)(t);return(0,a.useEffect)((()=>{if(!t)return;if(u.current===t&&i)return;u.current=t;const a=e.current;if(!a)return;let c;if(a.canPlayType("application/vnd.apple.mpegurl"))a.src=t;else{let i;try{i=new URL(t)}catch(m){throw m instanceof Error&&(m.message=m.message+`: ${t}`),m}c=async function(e,t){const a=t?await t():void 0;return Promise.resolve().then(n.bind(n,69818)).then((t=>{const n=t.default;if(n.isSupported())return new n({startFragPrefetch:!0,fLoader:class CustomLoader extends n.DefaultConfig.loader{load(t,n,a){t.url=t.url+e,super.load(t,n,a)}},xhrSetup:function(e){a&&e.setRequestHeader("Authorization",`Bearer ${a}`)}})}))}(i.search,s?l:null).then((e=>(e&&(e.loadSource(t),e.attachMedia(a),d(e)),e))),c.then((t=>{t&&o&&o(t,e),null==t||t.on(hi.default.Events.ERROR,((e,t)=>{t.fatal&&r&&r(new Error(`${e}-${t.type}-${t.details}`))}))}))}return()=>{c&&function(e){e.then((e=>{e&&e.destroy()}))}(c)}}),[e,t,l,s,r,i,o]),c}const pi=e=>{const{videoPath:t,lockAspectRatio:n=!1,authRequired:s=!1,onError:r,timeZone:i="UTC",isPlayback:o,controlsList:l=[],onInit:c}=e,d=(0,a.useRef)(null),u=(0,a.useRef)(null),m=xi(d,t,s,r,o,c),{isFullScreen:h,toggleFullScreen:x}=D(u),p=(0,a.useMemo)((()=>["noLoader",...l]),[l]);return(0,H.jsxs)("div",{className:"relative min-h-0 overflow-hidden",ref:u,children:[(0,H.jsx)("video",{ref:d,autoPlay:!0,className:(0,z.Z)("dark:bg-ondark-bg-2 before:border-hakimo-yellow h-full w-full bg-gray-200",n&&"aspect-video"),muted:!0,children:(0,H.jsx)(B,{children:"Your browser cannot play the provided video file."})}),(0,H.jsx)(Jr,{videoRef:d,videoPath:t}),!l.includes("none")&&(0,H.jsx)(mi,{videoRef:d,containerRef:u,videoPath:t,timeZone:i,hls:m,isFullScreen:!!h,onFullScreen:x,controlsList:p})]})},gi=pi;function fi(e){return(0,H.jsx)("div",{className:"p-6",children:(0,H.jsx)(B,{children:e})})}var vi=n(30022),ji=n(79860),bi=n(86483),yi=n(12139);const ki=(e,t,n,a)=>{if((a?3+n:7+n)>=e)return E(1,e);const s=Math.max(t-n,1),r=Math.min(t+n,e),i=s>2,o=a?r<e-1:r<e-2;if(!i&&o){return[...E(1,(a?1+n:3+2*n)+1),"...",e]}if(i&&!o){return[1,"...",...E(e-(a?1+n:3+2*n),e)]}return[1,"...",...a?E(t,t+1):E(s,r+1),"...",e]};function wi(e){const{from:t,to:n,total:a,pageSize:s,disabled:r,onChangePage:i}=e,o=Math.ceil((n-1)/s),l=Math.ceil(a/s),c=ki(l,o,1,!1),d=ki(l,o,1,!0),u=e=>{"number"==typeof e&&(yt("move_to_page_by_number"),i(e))};return(0,H.jsxs)("nav",{className:"@container flex items-center justify-between","aria-label":"Pagination",children:[(0,H.jsxs)("div",{className:" flex flex-1 items-center justify-center",children:[(0,H.jsx)("div",{className:"@md:block hidden",children:(0,H.jsx)(Q,{onClick:()=>u(1),disabled:r||0===a||1===t,onSideEffect:yt("move_first_page"),variant:"icon",title:"First Page",children:(0,H.jsx)(yi.Z,{"data-testid":"First Page",className:"h-5 w-5"})})}),(0,H.jsx)("div",{className:"@sm:pl-2 pl-1",children:(0,H.jsx)(Q,{onClick:()=>u(o-1),disabled:r||0===a||1===t,onSideEffect:yt("move_previous_page"),variant:"icon",title:"Previous Page",children:(0,H.jsx)(vi.Z,{"data-testid":"Previous",className:"h-5 w-5"})})}),(0,H.jsx)("div",{className:"@lg:flex hidden items-center justify-center",children:c.map(((e,t)=>(0,H.jsx)("ul",{className:"pl-1",children:o===e?(0,H.jsxs)("span",{className:"bg-primary-600 relative inline-flex rounded-full border border-blue-600 py-1 px-2 text-sm text-white",children:[(0,H.jsx)("span",{className:"sr-only",children:"You're on page"})," ",e]}):(0,H.jsx)("button",{className:(0,z.Z)("..."===e&&"pointer-events-none","dark:text-ondark-text-2 text-onlight-text-3 rounded-full py-1 px-2 text-sm transition-colors duration-150 ease-in enabled:hover:bg-slate-200 dark:enabled:hover:bg-slate-700"),onClick:()=>u(e),"aria-label":`Page ${e}`,children:e})},t)))}),(0,H.jsx)("div",{className:"@lg:hidden flex items-center justify-center",children:d.map(((e,t)=>(0,H.jsx)("ul",{className:"pl-1",children:o===e?(0,H.jsxs)("span",{className:"bg-primary-600 relative inline-flex rounded-full border border-blue-600 py-1 px-2 text-sm text-white",children:[(0,H.jsx)("span",{className:"sr-only",children:"You're on page"})," ",e]}):(0,H.jsx)("button",{className:(0,z.Z)("..."===e&&"pointer-events-none","dark:text-ondark-text-2 text-onlight-text-3 rounded-full py-1 px-2 text-sm transition-colors duration-150 ease-in enabled:hover:bg-slate-200 dark:enabled:hover:bg-slate-700"),onClick:()=>u(e),"aria-label":`Page ${e}`,children:e})},t)))}),(0,H.jsx)("div",{className:"pl-1 sm:pl-2",children:(0,H.jsx)(Q,{onClick:()=>u(o+1),disabled:r||0===a||n===a,onSideEffect:yt("move_next_page"),variant:"icon",title:"Next Page",children:(0,H.jsx)(ji.Z,{"data-testid":"Next",className:"h-5 w-5"})})}),(0,H.jsx)("div",{className:"@md:block @md:pl-2 hidden pl-1",children:(0,H.jsx)(Q,{onClick:()=>u(l),disabled:r||0===a||n===a,onSideEffect:yt("move_last_page"),variant:"icon",title:"Last Page",children:(0,H.jsx)(bi.Z,{"data-testid":"Last Page",className:"h-5 w-5"})})})]}),(0,H.jsxs)("p",{className:"@sm:block ml-auto hidden text-xs text-gray-500 dark:text-gray-400",children:[a>0&&(0,H.jsxs)("span",{children:["Showing",(0,H.jsx)(Ts,{children:(0,H.jsx)("span",{className:"font-medium",children:t})}),"to",(0,H.jsx)(Ts,{children:(0,H.jsx)("span",{className:"font-medium",children:n})}),"of"]}),(0,H.jsx)(Ts,{children:(0,H.jsx)("span",{className:"font-medium",children:a})}),"results"]}),(0,H.jsxs)("p",{className:"@sm:hidden block text-xs text-gray-500 dark:text-gray-400",children:[t,"-",n," of ",a]})]})}const Ni=function(e){const{type:t,breakpoint:n,align:a="left",children:s}=e,r="header"===t?"th":"td";return(0,H.jsx)(r,{className:(0,z.Z)("whitespace-nowrap px-3 text-sm sm:pl-6","header"===t&&"dark:text-ondark-text-1 text-onlight-text-1 sticky top-0 bg-gray-100 py-3 font-semibold dark:bg-gray-800","data"===t&&"dark:text-ondark-text-2 text-onlight-text-2 group-focus-visible:border-primary-500 py-2 group-focus-visible:border-y-2 first:group-focus-visible:border-l-2 last:group-focus-visible:border-r-2","sm"===n&&"hidden sm:table-cell","md"===n&&"hidden md:table-cell","lg"===n&&"hidden lg:table-cell","xl"===n&&"hidden xl:table-cell","2xl"===n&&"hidden 2xl:table-cell","left"===a&&"text-left","center"===a&&"text-center"),scope:"header"===t?"col":void 0,children:s})};function Ci(e){const{cellIndex:t,row:n,columns:s}=e,r=n.cells[t],i=0===t,o=s[t],l=s.reduce(((e,t,n)=>(void 0!==t.showAtBreakpoint&&e.push(n),e)),[]);return i?(0,H.jsxs)(Ni,{type:"data",align:r.align,children:[r.value,(0,H.jsx)("dl",{className:"font-normal",children:l.map((e=>{const t=s[e];return 0===e?null:(0,H.jsxs)(a.Fragment,{children:[(0,H.jsx)("dt",{className:"sr-only",children:t.name}),(0,H.jsx)("dd",{className:(0,z.Z)("mt-1 truncate",{"sm:hidden":"sm"===t.showAtBreakpoint,"md:hidden":"md"===t.showAtBreakpoint,"lg:hidden":"lg"===t.showAtBreakpoint,"xl:hidden":"xl"===t.showAtBreakpoint,"2xl:hidden":"2xl"===t.showAtBreakpoint}),children:n.cells[e].value})]},t.id)}))})]}):(0,H.jsx)(Ni,{type:"data",breakpoint:o.showAtBreakpoint,align:r.align,children:r.value})}Ci.Selectable=function(e){const{rowSelection:t,rowId:n}=e;return(0,H.jsx)(Ni,{type:"data",children:(0,H.jsx)(J,{checked:t.selected.includes(n),onChange:e=>{e?t.onChangeSelected(t.selected.concat(n)):t.onChangeSelected(t.selected.filter((e=>e!==n)))}})})};const Si=Ci;function Ti(e){const{column:t}=e;return(0,H.jsx)(Ni,{type:"header",breakpoint:t.showAtBreakpoint,align:t.align,children:t.name})}Ti.Selectable=function(e){const{rowIds:t,rowSelection:n}=e;return(0,H.jsx)(Ni,{type:"header",children:(0,H.jsx)(J,{checked:t.length>0&&n.selected.length===t.length,onChange:e=>{e?n.onChangeSelected(t):n.onChangeSelected([])}})})};const Ei=Ti;function Ai(e){const{data:{columns:t,rows:n},loading:s=!1,embedded:r=!1,header:i,footer:o,scrollResetKey:l,rowSelection:c,renderExpandedRow:d,disableHoverHighlight:u=!1}=e,m=void 0!==c,h=(e,t)=>{setTimeout((()=>{const n=window.getSelection();"Range"!==(null==n?void 0:n.type)&&e.onClick&&e.onClick(t)}))},x=(0,a.useRef)(null),[p,g]=(0,a.useState)("");(0,a.useEffect)((()=>{var e;x.current&&(null==(e=x.current)||e.scroll(0,0))}),[l]);return(0,H.jsxs)("div",{className:(0,z.Z)("relative",!r&&"flex max-h-full flex-col border dark:border-gray-800 md:rounded-lg"),children:[i,s&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"dark:bg-dark-bg/70 absolute inset-0 z-10 bg-white/70"}),(0,H.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:(0,H.jsx)(K,{})})]}),(0,H.jsx)("div",{className:"overflow-auto scroll-smooth",ref:x,children:(0,H.jsxs)("table",{className:"min-w-full",children:[(0,H.jsx)("thead",{children:(0,H.jsxs)("tr",{children:[d&&(0,H.jsx)(Ni,{type:"header",children:" "}),m&&(0,H.jsx)(Ei.Selectable,{rowIds:n.map((e=>e.id)),rowSelection:c}),t.map((e=>(0,H.jsx)(Ei,{column:e},e.id)))]})}),(0,H.jsx)("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-800",children:n.map((e=>{return(0,H.jsxs)(a.Fragment,{children:[(0,H.jsxs)("tr",{onClick:t=>h(e,t),onKeyDown:t=>((e,t)=>{"Enter"===t.key&&h(e,t)})(e,t),className:(0,z.Z)(!u&&"dark:hover:bg-dark-hover-bg group hover:bg-gray-200 focus-visible:outline-none",e.onClick&&"cursor-pointer",e.highlighted&&"bg-hakimo-yellow/20 font-semibold"),tabIndex:e.onClick?0:-1,children:[d&&(0,H.jsx)(Ni,{type:"data",children:(0,H.jsx)(Q,{variant:"icon",children:(0,H.jsx)(wa.Z,{onClick:(n=e.id,()=>g(p===n?"":n)),className:(0,z.Z)("h-5 w-5 transition duration-300",p===e.id&&"rotate-90 transform")})})}),m&&(0,H.jsx)(Si.Selectable,{rowSelection:c,rowId:e.id}),e.cells.map(((n,a)=>(0,H.jsx)(Si,{cellIndex:a,columns:t,row:e},a)))]}),p===e.id&&(0,H.jsx)("tr",{children:(0,H.jsx)("td",{colSpan:t.length+1,children:d?d(e.id):null})},`${e.id}-expanded`)]},e.id);var n}))})]})}),o]})}var _i=n(59679),Ii=n(16881);function Li(e){const{shownColumns:t,options:n,onChangeShownColumns:s}=e,r=n.map((e=>({id:e.id,value:e.id,label:e.name}))),i=r.filter((e=>t.includes(e.id))),[o,l]=(0,a.useState)(i),c=[{name:"Show All",action:()=>{const e=n.map((e=>e.id));s(e),l(r)}},{name:"Hide All",action:()=>{s([]),l([])}}];return(0,H.jsxs)(_i.J,{className:"relative",children:[(0,H.jsx)(_i.J.Button,{as:"span",children:(0,H.jsxs)(Q,{variant:"icon",onSideEffect:yt("update_visible_columns"),children:[(0,H.jsx)("span",{className:"sr-only",children:"Open hidden/shown columns menu"}),(0,H.jsx)(Ii.Z,{className:"h-6 w-6","aria-hidden":"true"})]})}),(0,H.jsx)(_i.J.Panel,{className:"container absolute top-9 right-1 z-10 mx-auto inline w-44",children:(0,H.jsxs)("div",{className:"dark:bg-dark-bg rounded-md bg-white py-2 px-2 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:divide-gray-700 dark:shadow-gray-700 dark:ring-gray-700",children:[(0,H.jsx)("h3",{className:"dark:text-dark-text mb-2 text-center text-sm font-semibold text-gray-800",children:"Show Columns"}),(0,H.jsx)("div",{className:"pl-1",children:(0,H.jsx)(te,{items:r,value:o,onChange:e=>{const t=e.map((e=>e.id));s([...t]),l(e)}})}),(0,H.jsx)("div",{className:"mt-3 flex justify-center",children:(0,H.jsx)("span",{className:"w-full text-center",children:c.map((e=>(0,H.jsx)(Q,{variant:"link",onClick:e.action,children:e.name},e.name)))})})]})})]})}function Ri(e){const{items:t,total:n,page:s,pageSize:r,onChangePage:i,renderListItem:o}=e,l=(s-1)*r,c=Math.min(s*r,n)-1;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"space-y-1",children:t.map((e=>(0,H.jsx)(a.Fragment,{children:o(e)},e.id)))}),(0,H.jsx)("div",{className:"pt-4",children:(0,H.jsx)(wi,{from:l+1,to:c+1,pageSize:r,total:n,onChangePage:e=>i(e)})})]})}const Di=e=>{const{cameraId:t,open:n,lockAspectRatio:s=!1,renderAlert:r,controlsList:i}=e,{error:o,data:l}=Rt(t),c=(0,a.useMemo)((()=>["noVideoTimeline","noPlaybackRate",...i||[]]),[i]),[d,u]=(0,a.useState)();(0,a.useEffect)((()=>{if(!d||!d.videoRef)return;const e=d.videoRef.current,t=window.setInterval((()=>{if(e){const t=e.duration;t-e.currentTime>6&&(e.currentTime=t-2)}}),1e4);return()=>{t&&window.clearInterval(t)}}),[d]);const m=(0,a.useCallback)((e=>{y.uT(`hlserror-live-view-${String(e)}`)}),[]),h=(0,a.useCallback)(((e,t)=>{u({hls:e,videoRef:t});const n=()=>{var t;const a=null==(t=e.levels[0].details)?void 0:t.totalduration;a&&(e.config.startPosition=a-2),e.off(hi.default.Events.MANIFEST_PARSED,n)};e.on(hi.default.Events.MANIFEST_PARSED,n)}),[]);return n?(0,H.jsxs)(H.Fragment,{children:[o&&(r||fi)(o.message),(0,H.jsx)(gi,{videoPath:l,onInit:h,lockAspectRatio:s,onError:m,controlsList:c})]}):null},Pi=function(e){const{cameraId:t,open:n,lockAspectRatio:a=!1,renderAlert:s,controlsList:r}=e;return null!==t?(0,H.jsx)(Di,{cameraId:t,open:n,renderAlert:s,lockAspectRatio:a,controlsList:r}):n?(s||fi)("Live streaming not enabled"):null};function Mi(e){const{camera:t,controlsList:n,lockAspectRatio:a=!1}=e,s=(0,H.jsx)(Pi,{cameraId:t.id,renderAlert:Oi,open:!0,lockAspectRatio:a,controlsList:n});return t.livestreamUrl?t.livestreamUrl.startsWith("ws")?(0,H.jsx)(js,{mseUrl:t.livestreamUrl,lockAspectRatio:!0}):t.livestreamUrl.includes("live.hakimo.ai")||t.livestreamUrl.includes("mediamtx.hakimo.ai")||t.livestreamUrl.includes("sharpvue-vpn.hakimo.ai")?(0,H.jsx)(bs,{livestreamUrl:t.livestreamUrl}):s:s}function Oi(e){return(0,H.jsx)(B,{children:e})}function Fi(e){var t;const{locationId:n,onChange:a,label:s}=e,r=qn(),i=null==(t=Zn("").data)||null==(t=t.items.find((e=>n&&e.id===+n)))?void 0:t.name;return(0,H.jsx)(Vs,{value:{id:n||"unknown",name:i||""},label:s,placeholder:"Type to search ...",onChange:e=>a(e.id),onChangeQuery:r,displayValue:e=>(null==e?void 0:e.name)||"",id:e=>String(e.id)})}var Zi=n(76648);const qi=function(e){var t,n;const{children:a}=e,s=(0,r.s0)(),i=new URLSearchParams(window.location.search);return(0,H.jsx)(Zi.tw,{domain:Ar.auth0.domain,clientId:Ar.auth0.clientId,redirectUri:window.location.origin,onRedirectCallback:e=>{s(e&&e.returnTo||window.location.pathname)},audience:Ar.auth0.audience,invitation:null!=(t=i.get("invitation"))?t:void 0,organization:null!=(n=i.get("organization"))?n:void 0,useRefreshTokens:!0,children:a})},Ui=e=>{const{children:t,authUtils:n}=e;return(0,H.jsx)(m.Provider,{value:n,children:t})},Vi=new n.g.BroadcastChannel("sync-sessions"),$i=()=>{Vi.postMessage({type:"logout"})},zi=e=>{Vi.addEventListener("message",(t=>{"logout"===t.data.type&&e({returnTo:window.location.origin})}))},Hi=e=>{const{children:t}=e,[,,n,a]=M("token"),s=(0,r.s0)(),i={getAccessToken:()=>{const e=a();return e?Promise.resolve(e):Promise.reject()},logout:()=>{n(),s("/login")}};return"auth0"===Ar.authMode?(0,H.jsx)(qi,{children:(0,H.jsx)(Bi,{children:t})}):(0,H.jsx)(Ui,{authUtils:i,children:t})};function Bi({children:e}){const{getAccessTokenSilently:t,logout:n,user:s}=(0,Zi.D3)();(0,a.useEffect)((()=>{zi(n)}),[n]);return(0,H.jsx)(Ui,{authUtils:{getAccessToken:t,logout:e=>{n(e),$i()},profilePic:null==s?void 0:s.picture},children:e})}function Wi(e){const{children:t}=e,{getAccessToken:n,logout:a}=h(),s=C(n,a);return(0,H.jsx)(p.Provider,{value:s,children:t})}function Gi(){const[e,t]=(0,a.useState)(""),n=la((()=>null)),s=(0,H.jsx)(Q,{variant:"primary",onClick:()=>n.mutate({name:e}),loading:n.isLoading,children:"Let's go!"});return(0,H.jsx)("div",{className:"dark:bg-dark-bg dark:text-dark-text flex h-screen items-center justify-center",children:(0,H.jsx)(ce,{open:!0,onClose:()=>null,closable:!1,footer:s,title:"Welcome to Hakimo",children:(0,H.jsxs)("div",{className:"w-96",children:[(0,H.jsx)("div",{className:"mb-2 px-8 py-4",children:(0,H.jsx)("h1",{children:"Tell us about yourself"})}),(0,H.jsx)("div",{className:"dark:text-dark-text mb-2 px-8 py-4",children:(0,H.jsx)(ae,{value:e,onChange:e=>t(e.target.value),placeholder:"John Doe",label:"Name",type:"text"})}),(0,H.jsx)("div",{className:"dark:text-dark-text mb-2 px-8 py-4 text-sm",children:"We've set you up as a GSOC Operator. Please contact an Admin at your company if this is not the right role."})]})})})}const Ki="Invalid user";function Yi(e){const{children:t}=e,n=ca(),s=oa((()=>null));(0,a.useEffect)((()=>{!n.isError||s.isLoading||s.isSuccess||s.isError||s.mutate(null)}),[n,s]);return(0,H.jsx)("div",{className:"dark:bg-dark-bg h-full",children:(0,H.jsx)(Is,{queryResult:n,loadingText:"Loading user...",errorFormatter:e=>{var t;return e.message===Ki?(0,H.jsx)(ws,{text:"Setting up user..."}):(0,H.jsx)("div",{className:"mx-auto max-w-screen-2xl px-4 py-6 sm:px-6 md:px-8",children:(0,H.jsx)(B,{type:"error",children:null!=(t=e.message)?t:""})})},children:e=>{return(n=e).name&&(null==(a=n.name)?void 0:a.length)>0?(0,H.jsx)(v.Provider,{value:e,children:t}):(0,H.jsx)(Gi,{});var n,a}})})}const Qi=function(e){return t=>{const[n]=M("token");return"string"==typeof n?(0,H.jsx)(e,Object.assign({},t)):(0,H.jsx)(r.Fg,{to:`/login?redirectTo=${window.location.pathname}`})}};function Xi(e){const{children:t}=e;return t}const Ji="auth0"===Ar.authMode?(0,Zi.u3)(Xi,{onRedirecting:()=>(0,H.jsx)(ws,{})}):Qi(Xi);var eo=n(53330),to=n(22551);var no=n(23837),ao=n(16524);const so=function(e){const{options:{sentryDsn:t,sentryEnabled:n,intercomAppId:s,intercomEnabled:i,intercomSource:o,amplitudeEnabled:l}}=e,c=j();return function(e,t){const n=(0,r.TH)();(0,a.useEffect)((()=>{b.S1(Ar.amplitudeApiKey,void 0,{optOut:!t,defaultTracking:{pageViews:{trackHistoryChanges:"all"},sessions:!0}});const e={name:"addEnvironmentNamePlugin",type:eo.z.ENRICHMENT,async setup(){},execute:async e=>(e.event_properties=Object.assign({},e.event_properties,{environment_name:Ar.name}),e)};b.IH(e)}),[t]),(0,a.useEffect)((()=>{const e=function(e){switch(e){case"/alarms":return"navigate_alarms";case"/location-alarms":return"navigate_location_alarms";case"/doors":return"navigate_doors";case"/cameras":return"navigate_cameras";case"/locations":return"navigate_locations";case"/doorgroups":return"navigate_door_groups";case"/users":return"navigate_users";case"/audit-log":return"navigate_audit_log";case"/insights":return"navigate_insights";case"/monitoring":return"navigate_monitoring";default:return}}(n.pathname);e&&b.j(e)}),[n.pathname]),(0,a.useEffect)((()=>{var t,n;b.Iv(e.email);const a=new to.h;a.set("role",e.roles[0]),a.set("tenant_name",e.tenant.name),a.set("msp_tenants",null!=(t=null==(n=e.mspTenants)?void 0:n.map((e=>e.name)))?t:[]),a.set("is_hakimo_user",e.email.endsWith("@hakimo.ai")),b.yV(a)}),[e])}(c,l),function(e,t,n,s){(0,a.useEffect)((()=>{var a;n&&window.Intercom("boot",{app_id:t,email:e.email,user_id:e.id,name:null!=(a=e.name)?a:"Unknown",user_hash:e.userIntercomHash,source_app:s})}),[e,t,n,s])}(c,s,i,o),function(e,t,n){(0,a.useEffect)((()=>{var a;ao.S({dsn:t,integrations:[new no.gE],tracesSampleRate:1,enabled:n,environment:Ar.name,release:Ar.release}),y.av({id:e.id,email:e.email,username:null!=(a=e.name)?a:"Unknown"})}),[e,t,n])}(c,t,n),null},ro=5;const io=function(){const{toasts:e}=(0,Ae.TB)();return(0,a.useEffect)((()=>{e.filter((e=>e.visible)).filter(((e,t)=>t>=ro)).forEach((e=>Ae.Am.dismiss(e.id)))}),[e]),(0,H.jsx)(Ae.x7,{})};function oo(e){const{navItems:t,appInitOptions:n}=e;return(0,H.jsx)(Ji,{children:(0,H.jsxs)(Yi,{children:[(0,H.jsx)(so,{options:n}),(0,H.jsx)(Nr,{navItems:t,children:(0,H.jsxs)("div",{className:"dark:bg-dark-bg h-full bg-white",children:[(0,H.jsx)(r.j3,{}),(0,H.jsx)(io,{})]})})]})})}var lo=n(14290),co=n.n(lo),uo=n(20957),mo=n.n(uo),ho=n(36481),xo=n.n(ho);co().extend(xo()),co().extend(mo());let po=function(e){return e.DAILY="daily",e.WEEKLY="weekly",e.THREE_DAY="3day",e}({});const go=(e,t,n,a)=>{const s=[],r=new Date(e);let i=0;for(;r<t&&(i++,!(i>100));){const e=co()(r).tz(a);let t=+e.format("HH");const i=+e.format("mm"),o=t>=12?"PM":"AM";t%=12,t=t||12,s.push({text:`${t}${i>0?`:${i}`:""} ${o}`,date:r.toLocaleDateString("en-US",{day:"numeric",month:"long",year:"numeric"}),isMidnight:12===t&&"AM"===o&&0===i}),n===po.DAILY&&r.setMinutes(r.getMinutes()+30),n===po.THREE_DAY&&r.setHours(r.getHours()+1),n===po.WEEKLY&&r.setHours(r.getHours()+2)}return s},fo=(e,t,n,a)=>new Date(e.getTime()+t/n*(24/_o[a].perDayTicks)*60*60*1e3),vo=(e,t,n,a)=>t*(a.getTime()-e.getTime())/(60*_o[n].perTickEquivalentHours*60*1e3),jo=(e,t,n,a,s,r,i)=>{let o=co()(s.toString()).tz(i);o=o.set("hour",0).set("minute",0).set("second",0).set("millisecond",0);const l=co()(r.toString()).tz(i);let c=co()(n.toString()).tz(i);c=c.set("hour",0).set("minute",0).set("second",0).set("millisecond",0);let d=co()(a.toString()).tz(i);if(d=d.set("hour",23).set("minute",59).set("second",0).set("millisecond",0),c=c.subtract(e,"day"),d=d.add(t,"day"),d.unix()>l.unix()){const e=d.diff(l,"day");d=l,c=c.subtract(e,"day")}else if(c.unix()<o.unix()){const e=o.diff(c,"day");c=o,d=d.add(e,"day")}return[c.toDate(),d.toDate()]},bo=(e,t,n,a,s)=>{let r=new Date(a),i=new Date(a);if(e===po.DAILY){let e=co()(r.toString()).tz(s);e=e.set("hour",0).set("minute",0).set("second",0).set("millisecond",0),r=e.toDate();let t=co()(i.toString()).tz(s);t=t.set("hour",23).set("minute",59).set("second",0).set("millisecond",0),i=t.toDate(),i=n<i?n:i}else e===po.THREE_DAY?[r,i]=jo(1,1,r,i,t,n,s):e===po.WEEKLY&&([r,i]=jo(3,3,r,i,t,n,s));return{startDate:r,endDate:i}},yo=(e,t,n)=>{if(e+1>t-_o[n].perDayTicks||t<_o[n].perDayTicks){const a=t-e+1;return(n===po.WEEKLY||n===po.THREE_DAY)&&a<=5?_o[n].perDayTicks:a}return _o[n].perDayTicks},ko=(e,t,n,a,s)=>{const r=e.getTime(),i=t.getTime();let o=[];return o=n.reduce(((t,n)=>{const o=n[0],l=n[1];return o>=r&&l<=i&&t.push({start:vo(e,a,s,new Date(o)),end:vo(e,a,s,new Date(l))}),t}),o),o},wo=36e5,No=900,Co=150,So=1200,To={left:10,right:30},Eo=30,Ao=60,_o={[po.DAILY]:{frequency:2,perDayTicks:48,perTickEquivalentHours:.5,numberOfDays:1},[po.THREE_DAY]:{frequency:6,perDayTicks:24,perTickEquivalentHours:1,numberOfDays:3},[po.WEEKLY]:{frequency:4,perDayTicks:12,perTickEquivalentHours:2,numberOfDays:7}};function Io(e){const{svgWidth:t,shownDates:n,startDate:a,endDate:s,timeZone:r,zoomMode:i,onChangeShownDates:o}=e,l=e=>()=>{let t=new Date(n.startDate),l=new Date(n.endDate);[t,l]=jo("left"===e?_o[i].numberOfDays:-_o[i].numberOfDays,"left"===e?-_o[i].numberOfDays:_o[i].numberOfDays,t,l,a,s,r),o({startDate:t,endDate:l})};return(0,H.jsx)("g",{id:"timeline-actions",children:(0,H.jsxs)("g",{id:"navigate-action",className:"dark:text-ondark-text-2 stroke-current",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,H.jsxs)("g",{transform:`translate(${t/2-10}, 125)`,onClick:l("left"),className:(0,z.Z)("group",co()(n.startDate).tz(r).format("D")===co()(a).tz(r).format("D")&&"pointer-events-none opacity-50"),children:[(0,H.jsx)("path",{d:"M15 18l-6-6 6-6",className:"group-hover:stroke-ondark-primary"}),(0,H.jsx)("rect",{x:"0",y:"0",width:"24",height:"24",opacity:"0",fill:"transparent"})]}),(0,H.jsxs)("g",{transform:`translate(${t/2+10}, 125)`,onClick:l("right"),className:(0,z.Z)("group",co()(n.endDate).tz(r).format("D")===co()(s).tz(r).format("D")&&"pointer-events-none opacity-50"),children:[(0,H.jsx)("path",{d:"M9 18l6-6-6-6",className:"group-hover:stroke-ondark-primary"}),(0,H.jsx)("rect",{x:"0",y:"0",width:"24",height:"24",opacity:"0",fill:"transparent"})]})]})})}co().extend(xo()),co().extend(mo());const Lo=(0,a.memo)(Io);const Ro=function(e){const{shownStartDate:t,shownEndDate:n,tickGap:a,zoomMode:s,seekerTime:r,timeZone:i,playbackMotionMarkers:o}=e,l=vo(t,a,s,r);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Po,{playbackMotionMarkers:o,shownEndDate:n,shownStartDate:t,tickGap:a,zoomMode:s}),(0,H.jsxs)("g",{id:"seeker",fill:"none",transform:`translate(${To.left+l}, 50)`,children:[(0,H.jsx)("line",{x1:"0",y1:"0",x2:"0",y2:"50",className:"stroke-onlight-primary"}),(0,H.jsx)("polygon",{points:"0,48 -5,58 5,58",className:"fill-onlight-primary"}),(0,H.jsx)("text",{x:"-23",y:"70",className:"dark:fill-ondark-text-1 fill-onlight-text-1 text-[10px]",children:r.toLocaleTimeString("en-US",{timeZone:i,hour12:!0})})]})]})};function Do(e){const{shownStartDate:t,shownEndDate:n,tickGap:s,zoomMode:r,playbackMotionMarkers:i}=e,o=(0,a.useMemo)((()=>ko(t,n,i,s,r)),[i,n,t,s,r]);return(0,H.jsx)("g",{id:"motion-rect",children:o.map(((e,t)=>(0,H.jsx)("rect",{x:To.left+e.start,y:Ao,width:e.end-e.start,height:Eo,className:"fill-status-red stroke-status-red pointer-events-none stroke-1 opacity-50 transition-opacity dark:opacity-100"},`${e.start}-${e.end}-${t}`)))})}const Po=(0,a.memo)(Do);function Mo(e){const{svgWidth:t,allTicks:n,tickGap:s,zoomMode:r}=e,i=t-To.right;return(0,H.jsxs)("g",{id:"ticks-container",children:[(0,H.jsx)("line",{x1:To.left,x2:t-To.right,y1:"50",y2:"50",className:"stroke-status-gray stroke-1"}),n.map(((e,t,n)=>(0,H.jsxs)(a.Fragment,{children:[(0,H.jsx)("line",{x1:s*t+To.left,x2:s*t+To.left,y1:"50",y2:t%_o[r].frequency==0?40:45,className:"stroke-status-gray stroke-1"}),t%_o[r].frequency==0&&(0,H.jsx)("text",{x:s*t,y:35,className:"dark:fill-ondark-text-1 fill-onlight-text-1 text-[10px]",children:e.text}),e.isMidnight&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("line",{x1:s*t+To.left,x2:s*t+To.left,y1:"25",y2:"5",className:"stroke-status-gray stroke-1"}),(0,H.jsx)("text",{x:i<s*t+s*yo(t,n.length,r)/2-20?2*i:s*t+s*yo(t,n.length,r)/2-20,y:8,className:"dark:fill-ondark-text-1 fill-onlight-text-1 text-[10px]",children:e.date}),(0,H.jsx)("line",{x1:Math.min(s*t+To.left,i),x2:Math.min(s*t+s*yo(t,n.length,r)/2-25,i),y1:"5",y2:"5",className:"stroke-status-gray stroke-1"}),(0,H.jsx)("line",{x1:Math.min(s*t+s*yo(t,n.length,r)/2+50,i),x2:Math.min(s*(t+yo(t,n.length,r))+To.left,i),y1:"5",y2:"5",className:"stroke-status-gray stroke-1"})]})]},`${e.date}-${t}`)))]})}const Oo=(0,a.memo)(Mo);const Fo=function(e){const{zoomMode:t,startDate:n,endDate:a,seekerTime:s,timeZone:r,onChangeZoomMode:i,onChangeShownDates:o}=e;return(0,H.jsxs)("g",{id:"zoom-action",className:"dark:text-ondark-text-2 stroke-current stroke-[1.5] ",fill:"none",style:{pointerEvents:"all"},stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,H.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",onClick:()=>{const e=t===po.WEEKLY?po.THREE_DAY:po.DAILY;i(e),o(bo(e,n,a,s,r))},viewBox:"0 0 24 24",className:(0,z.Z)("hover:stroke-ondark-primary ",t===po.DAILY&&"pointer-events-none opacity-50"),x:"15",y:"125",height:"20px",width:"20px",children:(0,H.jsx)("path",{d:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607zM10.5 7.5v6m3-3h-6"})}),(0,H.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",onClick:()=>{const e=t===po.DAILY?po.THREE_DAY:po.WEEKLY;i(e);const l=bo(e,n,a,s,r);o(l)},className:(0,z.Z)("hover:stroke-ondark-primary",t===po.WEEKLY&&"pointer-events-none opacity-50"),x:"40",y:"125",height:"20px",width:"20px",children:(0,H.jsx)("path",{d:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607zM13.5 10.5h-6"})})]})};function Zo(e){const{timeZone:t,startDate:n,endDate:s,seekerTime:r,onMarkerChange:i,playbackMotionMarkers:o}=e,l=(0,a.useRef)(null),[c,d]=(0,a.useState)(po.THREE_DAY),[u,m]=(0,a.useState)((()=>bo(c,n,s,r,t))),h=(0,a.useMemo)((()=>go(u.startDate,u.endDate,c,t)),[u.endDate,u.startDate,t,c]),x=l.current?l.current.clientWidth:So,p=(x-To.left-To.right)/h.length;return(0,H.jsx)("div",{className:"mt-4",ref:l,children:(0,H.jsxs)("svg",{width:x,height:Co,version:"1.1",className:"select-none",xmlns:"http://www.w3.org/2000/svg",children:[(0,H.jsx)(Oo,{allTicks:h,svgWidth:x,tickGap:p,zoomMode:c}),(0,H.jsxs)("g",{id:"rect-box",children:[(0,H.jsx)("rect",{x:To.left,y:"60",width:x-To.right-To.left,height:"30",className:"fill-status-gray stroke-status-gray cursor-pointer stroke-1 opacity-50 transition-opacity dark:opacity-100",onClick:e=>(e=>{const t=e.target;if(t){const n=t.getBoundingClientRect(),a=e.clientX-n.left,s=fo(u.startDate,a,p,c);i(s)}})(e.nativeEvent)}),(0,H.jsx)("line",{x1:To.left,x2:x-To.right,y1:"100",y2:"100",className:"stroke-status-gray stroke-1"})]}),(0,H.jsx)(Ro,{seekerTime:r,shownStartDate:u.startDate,shownEndDate:u.endDate,tickGap:p,timeZone:t,zoomMode:c,playbackMotionMarkers:o}),(0,H.jsx)(Fo,{endDate:s,seekerTime:r,onChangeShownDates:m,onChangeZoomMode:d,startDate:n,timeZone:t,zoomMode:c}),(0,H.jsx)(Lo,{endDate:s,onChangeShownDates:m,shownDates:u,startDate:n,svgWidth:x,timeZone:t,zoomMode:c})]},`${c}`)},`${c}`)}const qo=(0,a.memo)(Zo);function Uo(e){const{timeZone:t,cameraHlsAndRef:n,requestNewVideoUrl:s,onRetry:r,playbackPeriod:i,playbackMotionMarkers:o}=e,[l,c]=(0,a.useState)(),[d]=(0,a.useState)((()=>{const e=new Date;return e.setDate(e.getDate()-i),e})),[u]=(0,a.useState)((()=>new Date)),m=(0,a.useRef)({playbackStatus:null,marker:null});!function(e,t,n,s){(0,a.useEffect)((()=>{const a=e.videoRef.current,r=()=>{if(e.hls&&e.hls.playingDate&&e.hls.playingDate.getTime()<n.getTime()-4e3){const e=n.getTime()+wo;s(new Date(e)),t.current&&Object.assign(t.current,{marker:null,playbackStatus:"completed"})}};return null==a||a.addEventListener("ended",r),()=>null==a?void 0:a.removeEventListener("ended",r)}),[n,e.hls,t,s,e.videoRef])}(n,m,u,s),function(e,t,n){(0,a.useEffect)((()=>{const a=window.setInterval((()=>{n&&n.playingDate&&e.current&&"seeking"!==e.current.playbackStatus&&t(n.playingDate)}),1e3);return()=>{a&&clearInterval(a)}}),[n,e,t])}(m,c,n.hls),function(e,t){(0,a.useEffect)((()=>{const n=e.current;if(t&&n){let a;null===n.playbackStatus?a=()=>{var e;const n=null==(e=t.levels[0].details)?void 0:e.totalduration;n&&(t.config.startPosition=n-No),t.off(hi.default.Events.MANIFEST_PARSED,a)}:"seeking"===n.playbackStatus&&(a=()=>{var s;const r=null==(s=t.levels[0].details)?void 0:s.startSN;if(n.marker&&r){const e=(n.marker.getTime()-1e3*r)/1e3;t.config.startPosition=e}t.off(hi.default.Events.MANIFEST_PARSED,a),e.current&&Object.assign(e.current,{marker:null,playbackStatus:null})}),a&&t.on(hi.default.Events.MANIFEST_PARSED,a)}}),[t,e])}(m,n.hls);const h=(0,a.useCallback)(function(e,t,n,a,s){const r=A((n=>{if(e.videoRef.current&&e.hls&&e.hls.playingDate){const t=(n.getTime()-e.hls.playingDate.getTime())/1e3,a=e.videoRef.current.currentTime+t;(a>=e.videoRef.current.duration||a<0)&&s(n),e.videoRef.current.currentTime+=t}else e.videoRef.current&&e.hls&&(t&&t(),s(n))}),1e3);return e=>{n(e),a.current={playbackStatus:"seeking",marker:e},r(e)}}(n,r,c,m,s),[n,r,c,m,s]),x=new Date;return x.setSeconds(x.getSeconds()-No),(0,H.jsx)(qo,{timeZone:t,startDate:d,endDate:u,seekerTime:l||x,playbackMotionMarkers:o,onMarkerChange:h})}var Vo=n(44184);const $o=function(e){const{onClick:t}=e,[n,s]=(0,a.useState)(!1);return n?(0,H.jsx)(ye,{text:"Copied!",colorModifier:"success",position:"bottom",always:!0,children:(0,H.jsx)(Q,{variant:"icon",disabled:!0,children:(0,H.jsx)(je.Z,{className:"w-4 text-green-500"})})}):(0,H.jsx)(Q,{variant:"icon",onClick:async()=>{t(),s(!0),await async function(e){return new Promise((t=>setTimeout(t,e)))}(3e3),s(!1)},children:(0,H.jsx)(Vo.Z,{className:"w-5"})})};const zo=[{unit:"hour",allowedValues:E(1,12)}],Ho=[{unit:"hour",allowedValues:E(1,23)},{unit:"day",allowedValues:E(1,6)},{unit:"week",allowedValues:E(1,3)}];function Bo(e){const{resourceId:t,resourceType:n,onClose:s}=e,r=function(e){return"live-view"===e?zo:Ho}(n),[i,o]=(0,a.useState)(1),[l,c]=(0,a.useState)([]),[d,u]=(0,a.useState)("live-view"===n?"hour":"week"),{data:m,isFetching:h,isError:x,error:p,refetch:g}=Bt(t,i,d,n);(0,a.useEffect)((()=>{var e,t;const n=null!=(e=null==(t=r.find((e=>e.unit===d)))?void 0:t.allowedValues)?e:[];c(n),o((e=>n.includes(e)?e:1))}),[d,r]);const f=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("span",{className:"mr-2",children:(0,H.jsx)(Q,{variant:"primary",onSideEffect:yt("generate_share_alarm_link"),onClick:()=>g(),loading:h,disabled:h,children:"Generate Link"})}),(0,H.jsx)(Q,{onClick:s,onSideEffect:yt("close_generate_share_alarm_link_modal"),children:"Close"})]}),v=e=>{const t=function(e,t){let n="",a="";switch(e){case"alarm":a="alarm";break;case"location-alarm":a="location-alarm";break;case"live-view":a="live-view"}return n=`/shared/${a}?sharedToken=${t}`,n}(n,e);return`${window.location.origin}${t}`},j=r.map((e=>e.unit));return(0,H.jsx)(ce,{open:!0,onClose:s,title:"Generate Shareable Link",footer:f,children:(0,H.jsxs)("div",{className:"w-[36rem] px-8 py-4",children:[x&&(0,H.jsx)("div",{className:"mb-4",children:(0,H.jsx)(B,{type:"error",children:p.message})}),(0,H.jsx)("h2",{children:"Link Expiry Time"}),(0,H.jsxs)("div",{className:"mt-4 flex gap-4",children:[(0,H.jsx)(Ps,{label:"Duration",items:l,displayValue:e=>"number"==typeof e?String(e):"--Select--",value:i,onChange:e=>o(e)}),(0,H.jsx)(Ps,{label:"Duration Unit",items:j,displayValue:e=>"string"==typeof e?L(e)+(i>1?"s":""):"--Select--",value:d,onChange:e=>u(e)})]}),m&&(0,H.jsxs)("div",{className:"mt-4 flex items-center gap-2 text-lg",children:[(0,H.jsx)("div",{className:"dark:border-dark-border-bg dark:bg-dark-surface overflow-x-scroll whitespace-nowrap break-words rounded border p-4 align-middle font-mono text-sm",children:v(m.accessToken)}),(0,H.jsx)($o,{onClick:()=>{return e=v(m.accessToken),void navigator.clipboard.writeText(e);var e}})]})]})})}const Wo=4;function Go(e){var t,n,s;const{locationId:r,locationName:i,initialCameraIds:o=[],onClose:l}=e,[c,d]=(0,a.useState)([]),[u,m]=(0,a.useState)(""),[h,x]=(0,a.useState)([]),p=new URLSearchParams;p.append("locations",i);const{isFetching:g,isError:f,error:v,data:j}=on(p.toString()),b=On(r);(0,a.useEffect)((()=>{if(j){const e=j.items;x(e);let t=[];o.length>0&&(t=e.filter((e=>o.includes(e.id))));for(const n of e)if(o.includes(n.id)||t.push(n),t.length>=Wo)break;d(t)}}),[j,o.length]),(0,a.useEffect)((()=>{const e=[...(null==j?void 0:j.items)||[]].filter((e=>e.name.toLowerCase().includes(u.toLowerCase())));x(e)}),[u,null==j?void 0:j.items]);const y=e=>()=>{let t=[...c];t.find((t=>t.id===e.id))?t=t.filter((t=>t.id!==e.id)):t.push(e),d(t)},k=c.length;return(0,H.jsxs)("div",{className:"relative flex h-full flex-col justify-between p-4 pt-6",children:[(0,H.jsx)(Q,{classNames:"absolute right-1 top-0",variant:"icon",onClick:l,children:(0,H.jsx)(le.Z,{className:"h-8 w-8"})}),(0,H.jsxs)("div",{className:(0,z.Z)("grid h-[80%] gap-5 overflow-auto py-4 px-8",k<=4&&"grid-cols-2",k>4&&k<=8&&"grid-cols-3",c.length>8&&"grid-cols-4"),children:[0===k&&(0,H.jsx)("span",{className:"col-span-2 row-span-2 text-center",children:"Select cameras from below list to view their live feed"}),c.map((e=>(0,H.jsxs)("div",{className:"relative max-h-full",children:[(0,H.jsx)("span",{className:"bg-ondark-bg-1/80 absolute top-1 right-1 rounded-md p-1 text-xs text-white",children:e.name}),(0,H.jsx)("div",{className:"h-full",children:(0,H.jsx)(Mi,{camera:e})})]},e.id)))]}),(0,H.jsxs)("div",{className:"dark:border-ondark-line-2 bg-onlight-bg-1 dark:bg-ondark-bg-1 relative flex items-center gap-5 rounded-md border p-2",children:[(null==(t=b.data)?void 0:t.floor_plan)&&(0,H.jsx)("img",{src:null==(n=b.data)?void 0:n.floor_plan,alt:"Floorplan",className:"bottom-0 z-10 h-32 w-32 rounded transition-all duration-300 ease-in-out hover:absolute hover:h-[70vh] hover:w-[70vh]"}),(0,H.jsxs)("div",{className:"h-full p-2",children:[(0,H.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[f&&(0,H.jsx)(B,{type:"error",children:v.message}),(0,H.jsxs)("span",{className:"text-onlight-text-1 dark:text-ondark-text-1 mb-2",children:["Nearby Cameras at ",i]}),(0,H.jsx)("div",{className:"flex w-[30%]",children:(0,H.jsx)(ae,{label:"",onChange:e=>{const t=e.target.value;m(t)},value:u,type:"search",placeholder:"Search with camera name..."})}),g&&(0,H.jsx)("div",{children:(0,H.jsx)(K,{})})]}),(0,H.jsx)("div",{className:(0,z.Z)("flex items-center gap-6 overflow-auto pb-4",null!=(s=b.data)&&s.floor_plan?"w-[86vw]":"w-[95vw]"),children:null==h?void 0:h.map((e=>(0,H.jsx)("div",{className:(0,z.Z)("min-w-32 flex h-20 cursor-pointer items-center whitespace-pre rounded border p-2 text-center text-sm shadow-md",c.find((t=>t.id===e.id))?"border-primary-500 bg-primary-500 text-onlight-line-1 hover:bg-primary-700 border-2":"border-onlight-text-2 dark:border-ondark-text-3 hover:bg-onlight-bg-3 dark:hover:bg-ondark-bg-3"),tabIndex:1,onClick:y(e),children:e.name},e.id)))})]})]})]})}var Ko=n(26840),Yo=n(41036);function Qo(e){const{items:t,onChange:n}=e,a=e=>()=>{const a=[...t];a.splice(e,1),n(a)};return(0,H.jsxs)("div",{className:"col-span-2 space-y-4",children:[t.map(((e,s)=>{return(0,H.jsxs)("div",{className:"flex items-center gap-4",children:[(0,H.jsx)(ae,{value:e,type:"text",onChange:(r=s,e=>{const a=e.target.value,s=[...t];s[r]=a,n(s)})}),(0,H.jsx)(Q,{variant:"icon",onClick:a(s),children:(0,H.jsx)(Yo.Z,{className:"h-5 w-5"})})]});var r})),(0,H.jsx)("div",{children:(0,H.jsx)(Q,{onClick:()=>{const e=[...t];e.push(""),n(e)},children:"Add item"})})]})}const Xo=function(e){const{talkdown:t,onChange:n}=e,a=[{id:He.STATIC,name:"Static"},{id:He.DYANMIC,name:"Dynamic"}];return(0,H.jsxs)("div",{className:"col-span-2 grid grid-cols-2 gap-2",children:[(0,H.jsxs)("span",{className:"flex items-center gap-2",children:[(0,H.jsx)("span",{children:"Talkdown type:"}),(0,H.jsx)(ye,{text:el,colorModifier:"info",position:"top-right",size:"large",children:(0,H.jsx)(be.Z,{className:"h-5 w-5"})})]}),(0,H.jsx)(se,{items:a,onChange:e=>{const a=Object.assign({},t,{type:e.id});n(a)},selectedItem:a.find((e=>e.id===t.type))}),(0,H.jsx)("span",{children:"Talkdown text:"}),(0,H.jsx)(pe,{placeholder:"Provide talkdown text",onChange:e=>{const a=Object.assign({},t,{text:e});n(a)},value:t.text,rows:3})]})},Jo=[{title:"Site address",id:"siteAddress",inputType:"string"},{title:"Site Google map location",id:"siteGoogleMapLocation",inputType:"link"},{title:"Site Exceptions",id:"exceptions",inputType:"list"},{title:"Notes",id:"notes",inputType:"list"},{title:"Quick Resolve Actions",id:"quickResolveActions",inputType:"list",info:"These actions will come in 2nd step of SOP workflow. Below mentioned text will be considered as Button text and will resolve the alarm on one click"},{title:"Talkdown Enabled",id:"isTalkdownEnabled",inputType:"boolean"},{title:"First Talkdown",id:"firstTalkdown",inputType:"talkdown"},{title:"Second Talkdown",id:"secondTalkdown",inputType:"talkdown"},{title:"Points to remember while escalation",id:"escalationPoints",inputType:"list"},{title:"Escalation Protocol",id:"escalationProtocol",inputType:"list"}],el="Static Talkdown: Delivers full sentences with immediate text-to-speech playback, requiring no user input.\n\nDynamic Talkdown: Requires user input, such as shirt color, to customize responses. Supports both text-to-speech and recorded delivery.",tl=(e,t,n)=>(e?t.isTalkdownEnabled:null==n?void 0:n.isTalkdownEnabled)?Jo:Jo.filter((e=>"talkdown"!==e.inputType)),nl=(e,t,n,a,s,r)=>e?((e,t,n,a)=>{const s=(t,n)=>{const s=Object.assign({},e,{[t]:n});a(s)};switch(n){case"boolean":{const n=e[t];return(0,H.jsx)(J,{checked:n,onChange:e=>s(t,e)})}case"list":{const n=e[t];return(0,H.jsx)(Qo,{items:n,onChange:e=>s(t,e)})}case"talkdown":{const n=e[t];return(0,H.jsx)(Xo,{talkdown:n,onChange:e=>s(t,e)})}default:{const n=e[t];return(0,H.jsx)(ae,{type:"text",value:n,onChange:e=>s(t,e.target.value)})}}})(a,t,n,s):r?((e,t,n)=>{switch(n){case"link":{const n=e[t];return(0,H.jsx)("a",{href:n,target:"_blank",rel:"noreferrer",className:"text-primary-500 break-words",children:n})}case"boolean":{const n=e[t];return(0,H.jsx)(J,{checked:n})}case"list":{const n=e[t];return n.length>0?(0,H.jsx)("div",{className:"col-span-2 space-y-2",children:n.map(((e,t)=>(0,H.jsx)("li",{children:e},t)))}):(0,H.jsx)("div",{children:"Not applicable"})}case"talkdown":{const n=e[t];return(0,H.jsxs)("div",{className:"col-span-2 space-y-2 ",children:[(0,H.jsxs)("span",{className:"flex items-center gap-2",children:[(0,H.jsx)(re,{small:!0,text:`${n.type.toUpperCase()} Talkdown`,type:"info"}),(0,H.jsx)(ye,{text:el,colorModifier:"info",position:"top-right",size:"large",children:(0,H.jsx)(be.Z,{className:"h-5 w-5"})})]}),(0,H.jsx)("div",{children:n.text})]})}default:return(0,H.jsx)("span",{children:e[t]})}})(r,t,n):"",al=()=>({exceptions:[""],firstTalkdown:{type:He.STATIC,text:""},secondTalkdown:{type:He.DYANMIC,text:""},siteAddress:"",siteGoogleMapLocation:"",escalationPoints:[""],isTalkdownEnabled:!0,notes:[""],escalationProtocol:[""],quickResolveActions:[""]}),sl={REQUIRED_SITE_ADDRESS:"Site address is required",REQUIRED_GOOGLE_MAP:"Site Google map location is required",REQUIRED_TALKDOWN_TEXT:"First talkdown text is required",REQUIRED_TALKDOWN_TEXT_SECOND:"Second talkdown text is required",REQUIRED_ESCALATION_POINTS:"Escalation points are required. Add at least one.",EMPTY_ESCALATION_POINT:"Escalation point should not be empty. Provide info or delete the empty ones.",REQUIRED_EXCEPTION_POINTS:"Exceptions points are required. Add at least one.",EMPTY_EXCEPTION_POINT:"Exceptions point should not be empty. Provide info or delete the empty ones."},rl=e=>{if(!e)return{isValid:!1,message:void 0};let t;return e.siteAddress?e.siteGoogleMapLocation?il("Exception",e.exceptions).isValid?e.isTalkdownEnabled&&!e.firstTalkdown.text?t=sl.REQUIRED_TALKDOWN_TEXT:e.isTalkdownEnabled&&!e.secondTalkdown.text?t=sl.REQUIRED_TALKDOWN_TEXT_SECOND:il("Escalation",e.escalationPoints).isValid||(t=il("Escalation",e.escalationPoints).message):t=il("Exception",e.exceptions).message:t=sl.REQUIRED_GOOGLE_MAP:t=sl.REQUIRED_SITE_ADDRESS,{isValid:!t,message:t}},il=(e,t)=>0===t.length&&"Escalation"===e?{isValid:!1,message:sl[`REQUIRED_${e.toUpperCase()}_POINTS`]}:t.some((e=>""===e))?{isValid:!1,message:sl[`EMPTY_${e.toUpperCase()}_POINT`]}:{isValid:!0,message:""};function ol(e){const{sopWorkflow:t,sopId:n,showTitle:s=!0}=e,[r,i]=(0,a.useState)(!1),[o,l]=(0,a.useState)(t),[c,d]=(0,a.useState)({isValid:!0,message:""}),u=Yt(n,(()=>{i(!1),Le("SOP workflow updated successfully",{type:"success"})}));(0,a.useEffect)((()=>{r||l(t)}),[r,t]);const m=()=>{const e=al();l(e),i(!0)};if(!o)return(0,H.jsxs)("div",{className:"pl-4",children:[s&&(0,H.jsx)("div",{className:"border-onlight-line-2 dark:border-ondark-line-2 mb-2 border-b p-2 pb-3.5 font-bold",children:"Standard Operating procedure (SOP) Workflow"}),(0,H.jsxs)("div",{className:"mt-16 flex flex-col items-center justify-center gap-4",children:[(0,H.jsx)("div",{children:"SOP workflow is not enabled for this location."}),s&&(0,H.jsx)(Q,{variant:"primary",onClick:m,children:"Enable Workflow"})]})]});const h=tl(r,o,t);return(0,H.jsxs)("div",{className:"w-full p-2",children:[s&&(0,H.jsxs)("div",{className:"border-onlight-line-2 dark:border-ondark-line-2 mb-2 flex items-center justify-between border-b p-2",children:[(0,H.jsx)("span",{className:"font-bold",children:"Standard Operating procedure (SOP) Workflow"}),(0,H.jsx)(Q,{onClick:()=>i((e=>!e)),variant:"icon",children:r?(0,H.jsx)(le.Z,{className:"h-5 w-5"}):(0,H.jsxs)("span",{className:"flex gap-2",children:[(0,H.jsx)(Ko.Z,{className:"h-5 w-5"}),"Edit"]})})]}),u.isError&&(0,H.jsx)(B,{type:"error",children:u.error.message}),!c.isValid&&(0,H.jsx)(B,{type:"warning",children:c.message}),(0,H.jsxs)("div",{className:"flex flex-col gap-4 p-4",children:[h.map((e=>(0,H.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,H.jsxs)("div",{className:"flex items-center gap-2",children:[(0,H.jsxs)("span",{className:"font-bold",children:[e.title,":"]}),e.info&&(0,H.jsx)(ye,{text:e.info,size:"large",colorModifier:"info",children:(0,H.jsx)(be.Z,{className:"h-5 w-5"})})]}),nl(r,e.id,e.inputType,o,l,t)]},e.id))),r&&(0,H.jsxs)("div",{className:"border-onlight-line-2 dark:border-ondark-line-2 flex gap-4 border-t px-2 py-4",children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{const{isValid:e,message:t}=rl(o);if(!e)return void d({isValid:e,message:t||""});d({isValid:e,message:""});const n={sop_workflow:o};u.mutate({sop_text:JSON.stringify(n)})},loading:u.isLoading,children:"Submit"}),(0,H.jsx)(Q,{onClick:()=>i(!1),children:"Cancel"})]})]})]})}function ll(e){const{value:t,onChange:n}=e,a=ea();return(0,H.jsx)(Vs,{label:"Timezone",placeholder:"Search timezones...",onChangeQuery:a,value:t,onChange:n,displayValue:e=>e||"",infoTooltip:"Search for timezone. For eg: America/Los_Angeles"})}var cl=n(83019);function dl(e){let t;switch(e){case"success":case Ve.SUCCESS:t=(0,H.jsx)(Ce.Z,{className:"h-5 w-5 text-green-400 dark:text-green-200"});break;case"warning":t=(0,H.jsx)(Te.Z,{className:"h-5 w-5 text-yellow-400 dark:text-yellow-200"});break;case"error":case Ve.FAILED:t=(0,H.jsx)(cl.Z,{className:"h-5 w-5 text-red-400 dark:text-red-300"});break;default:t=null}return t}const ul=[{id:"rawAlarmId",name:"Raw Alarm Id"},{id:"rawAlarmAddedTime",name:"Raw Alarm Added Time"},{id:"status",name:"Talkdown Status"},{id:"ingestedTalkdown",name:"Relayed Talkdown"},{id:"talkdownTime",name:"Talkdown Completed Time"},{id:"comments",name:"Comments"}],ml=e=>e.map((e=>(0,H.jsx)("div",{className:"dark:text-ondark-text-1 font-bold text-gray-600",children:e.name},e.id)));const hl=e=>{if(!e)return"-";const t=new Date(e);return co()(t).format("DD/MM/YYYY, HH:mm:ss")};const xl=e=>{const{twilioSsid:t,twilioCallingToName:n,userName:a}=e,s=ga(t);return(0,H.jsx)("div",{children:(0,H.jsx)(Is,{queryResult:s,loadingText:"Loading call details",children:e=>(0,H.jsxs)("div",{children:[(0,H.jsxs)("div",{children:[a?`${a} made a call to `:"Call was made to ",n?`${n}(${e.callTo||"-"})`:e.callTo||"-"]}),e.mediaUrl?(0,H.jsx)("audio",{preload:"auto",src:e.mediaUrl,className:"h-7",controls:!0}):"Call recording not found."]})})})},pl=(e,t,n)=>(0,H.jsx)(xl,{twilioSsid:e,twilioCallingToName:t,userName:n});var gl=n(24430);function fl(e){const{digit:t,subText:n,onClick:a}=e;return(0,H.jsx)("button",{className:(0,z.Z)("inline-flex items-center justify-center rounded-md text-sm font-medium","focus:ring-primary-500 dark:ring-offset-ondark-bg-1 focus:outline-none focus:ring-2 focus:ring-offset-2","bg-primary-500 enabled:hover:bg-primary-600 dark:enabled:hover:bg-primary-700"),onClick:a,children:(0,H.jsxs)("div",{className:"mt-2 grid grid-rows-2",children:[(0,H.jsx)("div",{className:"text-ondark-text-1",children:t}),(0,H.jsx)("div",{className:"text-ondark-text-2 text-xs",children:n})]})})}const vl=function(e){const{onKeypadButtonClick:t}=e;return(0,H.jsx)("div",{className:"grid grid-cols-3 gap-2 pt-4",children:[{digit:"1"},{digit:"2",subText:"ABC"},{digit:"3",subText:"DEF"},{digit:"4",subText:"GHI"},{digit:"5",subText:"JKL"},{digit:"6",subText:"MNO"},{digit:"7",subText:"PQRS"},{digit:"8",subText:"TUV"},{digit:"9",subText:"WXYZ"},{digit:"*"},{digit:"0"},{digit:"#"}].map((e=>(0,H.jsx)(fl,{digit:e.digit,subText:e.subText,onClick:()=>t(e.digit)},e.digit)))})};function jl(e){const{toName:t,toNumber:s,onCloseCb:r,locationTenantId:i,onCallInitiated:o,onCallDisconnected:l,onErrorCb:c}=e,[d,u]=(0,a.useState)(!1),[m,h]=(0,a.useState)(),[x,p]=(0,a.useState)(),[g,f]=(0,a.useState)(""),[v,j]=(0,a.useState)(!1),[b,y]=(0,a.useState)(!1);fa(i,(e=>f(e)),(e=>{Le("Couldn't connect call - "+e.message,{type:"error"}),c&&c(e),r()})),(0,a.useEffect)((()=>{g&&(m?(m.updateToken(g),null==m||m.on("error",((e,t)=>{null==t||t.disconnect()}))):Promise.resolve().then(n.bind(n,24430)).then((e=>{h(new e.Device(g,{codecPreferences:[gl.Call.Codec.Opus,gl.Call.Codec.PCMU]}))})))}),[m,h,g]),(0,a.useEffect)((()=>{if(!m||b)return;b||y(!0),null==x||x.disconnect();const e={To:s};y(!0),null==m||m.connect({params:e}).then((e=>{p(e),null==e||e.on("accept",(()=>{j(!0),o&&o(e)})),null==e||e.on("disconnect",(()=>{j(!1),Le("Call ended"),l&&l(e),r()}))}))}),[x,m,b,l,o,r,t,s]);return(0,H.jsx)(ci,{children:(0,H.jsxs)("div",{className:"bg-onlight-bg-2 dark:bg-ondark-bg-2 dark:divide-ondark-line-2 space-y-4 divide-y py-4 px-6",children:[(0,H.jsxs)("div",{className:"flex items-center gap-4",children:[(0,H.jsx)(za,{className:"dark:fill-ondark-text-1 h-8 w-8"}),(0,H.jsxs)("div",{className:"flex flex-col gap-2 text-sm",children:[(0,H.jsx)("span",{children:t}),(0,H.jsx)("span",{className:"text-xs",children:s})]})]}),v?(0,H.jsxs)("div",{className:"flex justify-evenly pt-4",children:[(0,H.jsx)(Q,{variant:"icon",onClick:()=>u((e=>!e)),title:(d?"Hide":"Show")+" Keypad",children:(0,H.jsx)(Ba,{className:"dark:fill-ondark-text-1 h-8 w-8"})}),(0,H.jsx)(Q,{variant:"icon",title:"End call",onClick:()=>{null==x||x.disconnect(),r()},children:(0,H.jsx)(Ha,{className:"h-10 w-10 fill-red-500"})})]}):(0,H.jsxs)("div",{className:"flex h-24 flex-col items-center justify-center gap-2",children:[(0,H.jsx)(K,{}),(0,H.jsx)("span",{className:"animate-pulse",children:"Calling..."})]}),d&&(0,H.jsx)("div",{children:(0,H.jsx)(vl,{onKeypadButtonClick:e=>null==x?void 0:x.sendDigits(e)})})]})})}function bl(e){const{cameraId:t}=e,n=rn(t);return(0,H.jsx)(Is,{queryResult:n,children:e=>(0,H.jsx)(Mi,{camera:e})})}var yl=n(72638),kl=n(71001);const wl=function(e){const{cameraId:t,alarmId:n,debug:s,live:r,sharedToken:i,onToggleDebug:o,onToggleLive:l,onTalkdown:c}=e,d=Ge(j(),"alarm/debug-media:view"),u=Ke(),[m,h]=(0,a.useState)(!1);return(0,H.jsxs)("div",{className:"mr-8 flex items-center gap-4",children:[!m&&(0,H.jsxs)(H.Fragment,{children:[d&&!i&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("span",{className:"dark:text-dark-text",children:"Debug Mode"}),(0,H.jsx)(we,{enabled:s,onSideEffect:yt("toggle_debug_mode"),onChange:o,EnabledIcon:kl.Z,DisabledIcon:kl.Z})]}),u&&(0,H.jsxs)(H.Fragment,{children:[r&&(0,H.jsx)("span",{className:"text-red-500",children:"LIVE"}),(0,H.jsx)(we,{enabled:r,onSideEffect:yt("toggle_live_mode"),onChange:l,EnabledIcon:_a.Z,DisabledIcon:yl.Z})]})]}),r&&t&&(0,H.jsx)(Br,{cameraId:t,alarmId:n,onToggle:h,onTalkdown:c})]})};const Nl=function(e){const{imagePath:t}=e;return(0,H.jsx)("img",{src:t,alt:"Alarm media",className:"dark:bg-dark-bg/70 max-h-[48rem] w-full bg-gray-200"})};const Cl=function(e){const{markers:t,activeMarker:n,onTimestampClick:a,timer:s}=e;return(0,H.jsxs)("div",{className:"flex items-center justify-between",children:[(0,H.jsx)("div",{className:"space-x-3 px-4 py-4",children:t&&t.sort(((e,t)=>e.timestamp-t.timestamp)).map(((e,t)=>(0,H.jsx)("span",{className:(0,z.Z)("inline-flex items-center rounded-full bg-opacity-30",e===n&&("Warning"===(null==e?void 0:e.type)?"bg-hakimo-yellow":"Info"===(null==e?void 0:e.type)?"bg-primary-400 dark:bg-primary-800":"Error"===(null==e?void 0:e.type)?"bg-red-400 dark:bg-red-800":"")),children:(0,H.jsx)(Q,{variant:"link",onClick:()=>a(e.timestamp),children:e.label})},t)))}),s]})},Sl=1e3;async function Tl(e,t){var n;e.currentTime=Math.max(t,0),(n=e).currentTime>0&&!n.paused&&!n.ended&&(e.pause(),await new Promise((e=>setTimeout(e,Sl))),e.play().catch((e=>{Le("Can not play media. Try again after reloading the page.",{type:"error"}),y.uT("Failed to play media on marker click",{extra:{error:e}})})))}function El(e){const t=function(e){const t=new URL(e).searchParams.get("Expires");return t?1e3*Number(t):null}(e);return!!t&&t-Date.now()}const Al=1;const _l=function(e){const{videoPath:t,videoDetails:n,onErrorLoadingVideo:s}=e,[r,i]=(0,a.useState)(!1),[o,l]=(0,a.useState)(),c=(0,a.createRef)(),d=(0,a.createRef)(),u=null==n?void 0:n.markers;(0,a.useEffect)((()=>{const e=c.current;if(!e)return;const t=()=>{const t=d.current;t&&"string"==typeof(null==n?void 0:n.startTime)&&(t.textContent=function(e,t){const n=new Date(e).getTime()+1e3*t;return new Intl.DateTimeFormat("en-US",{timeStyle:"medium"}).format(n)}(n.startTime,e.currentTime)),l(null==u?void 0:u.find((t=>Math.abs(e.currentTime-t.timestamp)<Al)))};return e.addEventListener("timeupdate",t),()=>{e.removeEventListener("timeupdate",t)}}),[c,u,d,n]);const m=(0,H.jsx)("span",{ref:d,className:"dark:text-dark-text mr-4 text-sm font-medium text-gray-900"});return(0,H.jsxs)(H.Fragment,{children:[r?(0,H.jsx)("div",{className:"p-6",children:(0,H.jsx)(B,{children:"Cannot play video"})}):(0,H.jsxs)("div",{className:"relative",children:[(0,H.jsxs)("video",{ref:c,controls:!0,className:"dark:bg-dark-bg/70 before:border-hakimo-yellow max-h-[48rem] w-full bg-gray-200",children:[(0,H.jsx)("source",{src:t,type:"video/mp4",onError:()=>{i(!0),s()}}),(0,H.jsx)(B,{children:"Your browser cannot play the provided video file."})]},t),o&&(0,H.jsx)("div",{className:(0,z.Z)("pointer-events-none absolute inset-1 z-10 border-4","Warning"===(null==o?void 0:o.type)&&"border-hakimo-yellow","Info"===(null==o?void 0:o.type)&&"border-primary-800 dark:border-primary-200","Error"===(null==o?void 0:o.type)&&"border-red-800 dark:border-red-200")})]}),(0,H.jsx)(Cl,{markers:u,activeMarker:o,onTimestampClick:e=>{const t=c.current;t&&Tl(t,e)},timer:m})]})},Il="AIRGAP"===Ar.name;const Ll=function(e){var t;const{alarm:n,sharedToken:s,onTalkdown:r}=e,[i,o]=(0,a.useState)(!1),l=Ke(),c=_t({id:n.id,debug:i,sharedToken:s,refetchInterval:e=>!Il&&(!(null==e||!e.videoPath)&&El(null==e?void 0:e.videoPath))}),[d,u]=(0,a.useState)(!1),m=()=>{y.uT("Error loading video",{extra:{alarm:n}})},h="CAMERA"===(null==(t=n.sourceEntity)?void 0:t.type)?n.sourceEntity.id:null,x=(0,H.jsxs)(H.Fragment,{children:[h&&l&&d&&(0,H.jsx)(bl,{cameraId:h}),!d&&(0,H.jsx)(Is,{queryResult:c,children:e=>e.videoPath?(0,H.jsx)(_l,{videoPath:e.videoPath,videoDetails:e.videoDetails,onErrorLoadingVideo:m}):e.imagePath?(0,H.jsx)(Nl,{imagePath:e.imagePath}):fi("Media not available")})]}),p=(0,H.jsx)(wl,{cameraId:h,alarmId:n.id,debug:i,live:d,sharedToken:s,onToggleDebug:o,onToggleLive:u,onTalkdown:r});return(0,H.jsx)(va,{title:"Alarm Media",secondary:p,children:x})},Rl=Pe.map(((e,t)=>({id:`${t}`,name:e}))),Dl=["#118D3F","#139310","#439D0B","#82A608","#AB9507","#B16A07","#B16A07","#B16A07","#AA2B1C","#AA2B1C"],Pl="audio-notify-new-alarm",Ml=1e4;function Ol(e){switch(e){case De.RESOLVED:return"success";case De.IN_PROGRESS:return"warning";case De.PENDING:return"error"}}function Fl(e){switch(e){case"Resolved Manually":case"Resolved by Hakimo":case"Alarm Acknowledged via ACS":case"Resolved":return"success";case"Analyzing":return"info";case"In Progress":return"warning";case"Pending":return"error";default:return"default"}}function Zl(e){switch(e){case"Resolved by Hakimo":case"Resolved Manually":case"Alarm Acknowledged via ACS":case"Resolved":return De.RESOLVED;case"Analyzing":case"Pending":return De.PENDING;case"In Progress":return De.IN_PROGRESS}}function ql(e){return e.location&&e.location.values.length>0||e.sourceSystem&&e.sourceSystem.length>0||e.sourceEntity&&e.sourceEntity.values.length>0||e.type&&e.type.values.length>0||e.employee&&e.employee.values.length>0||e.status&&e.status.values.length>0||e.tenant&&e.tenant.values.length>0||e.time&&e.time.period!==Me.ALL_TIME||e.camera&&e.camera.values.length>0||!1}function Ul(e,t,n,a,s,r,i){if(0===$l(e)&&$l(t)>0&&1===n){const e=function(e,t,n){let a="notif-sound-default";if("alarm"===e&&t&&t.length>0){a=function(e,t){if(t){const n=Object.values(t.alarm_notification_mapping).find((t=>t.alarm_types.includes(e)));return n?n.notification_sound:t.default_notification_sound.split(".")[0]}switch(e){case"Badge Unauthorised":case"Invalid Badge":case"Inactive Badge":return"notif-sound-1";case"Critical - Duress":case"Access Denied Under Duress":case"Access Granted Under Duress":return"notif-sound-2";case"Critical - AED Active":return"notif-sound-3";case"Critical - Secure Environment":return"notif-sound-4";case"Invalid PIN Number":return"notif-sound-5";default:return c}}(t.filter((e=>e.tap&&e.tap>50&&"Resolved"!==Zl(e.status)))[0].type,n)}return a}(a,t,i);We(r,Vl(a),e),Le(Vl(a),{audio:s,duration:1/0,id:Pl,audioFileName:e})}else 0===$l(t)&&Ie(Pl)}function Vl(e){return"locationAlarm"===e?"New unresolved location alarm":"New unresolved alarm"}function $l(e){return e?e.filter((e=>e.tap&&e.tap>50&&"Resolved"!==Zl(e.status))).length:0}const zl=e=>{const{status:t,small:n}=e,a=Fl(t);return(0,H.jsx)(re,{type:a,text:t,small:n})};function Hl(e){const{open:t,alarm:n,onCloseCb:s,onResolveCb:r}=e,[i,o]=(0,a.useState)(null),[l,c]=(0,a.useState)(),d=Zl(n.status),{data:u}=Dt(),m=Gt(n.id,((e,t)=>{(null==t?void 0:t.newStatus)===Pe.find((e=>"Resolved"===e))&&r&&r(),Le("Alarm status updated",{type:"success"}),s()})),[h,x]=(0,a.useState)((()=>Rl.find((e=>d===e.name)))),p=(g=d,f=null==h?void 0:h.name,!Ge(j(),"alarm/update:change-status-no-comment")&&("Pending"!==g||"In Progress"!==f));var g,f;const v=Boolean(h&&d!==h.name),b=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{if(h&&(!p||i)){const e={newStatus:h.name,timestamp:(new Date).toISOString(),comment:null==i?void 0:i.name};m.mutate(e)}},disabled:!v||p&&!i||""!==l&&l!==(null==i?void 0:i.name),onSideEffect:yt("submit_alarm_status_update"),loading:m.isLoading,children:"Submit"}),(0,H.jsx)(Q,{onClick:s,onSideEffect:yt("cancel_alarm_status_update"),children:"Cancel"})]});return(0,H.jsx)(ce,{open:t,onClose:s,title:"Update Status",footer:b,children:(0,H.jsx)("div",{className:"w-96",children:(0,H.jsxs)("div",{className:"p-8",children:[(0,H.jsx)("h2",{className:"mb-1 block text-xs text-gray-700 dark:text-gray-400",children:"Status"}),m.isError?(0,H.jsx)("div",{className:"py-2",children:(0,H.jsx)(B,{type:"error",children:"Error updating alarm status. Please try again."})}):null,(0,H.jsx)(ue,{items:Rl,value:h,onChange:x,id:e=>e.id,displayValue:e=>e.name}),(0,H.jsx)("div",{className:"mt-4",children:(0,H.jsx)(Us,{label:"Comment",value:i,displayValue:e=>{var t;return null!=(t=null==e?void 0:e.name)?t:""},getItems:e=>ut(e,i,u),onChange:o,id:e=>e.id,onChangeQuery:c})})]})})})}const Bl=function(e){const{alarm:t,onResolve:n}=e,s=Ge(j(),"alarm/update:change-status"),[r,i]=(0,a.useState)(!1);return(0,H.jsxs)(va,{title:"Status",children:[(0,H.jsxs)("div",{className:"flex items-center justify-between p-6",children:[(0,H.jsx)(zl,{status:t.status}),s&&(0,H.jsx)(Q,{variant:"primary",onClick:()=>i(!0),onSideEffect:yt("open_alarm_status_update_modal"),children:"Update"})]}),r&&(0,H.jsx)(Hl,{open:!0,alarm:t,onCloseCb:()=>{i(!1)},onResolveCb:n})]})},Wl=["True Alarm Probability","Alarm Type","Alarm Time","Source Entity","Employee","Employee Phone Number","Location","Alarm Local Time","Alarm Source System","Resolved At","Time To Remediation (Seconds)","Camera","Access Card Number"];function Gl(e){return Wl.map((t=>({name:t,value:Kl(e,t)}))).filter((e=>e.value))}function Kl(e,t){var n,a,s,r,i,o,l,c;switch(t){case"True Alarm Probability":return null!=(n=e.tap)?n:"-";case"Alarm Time":return new Date(e.timestamp).toLocaleString();case"Alarm Local Time":return e.localTime?new Date(e.localTime).toLocaleString():void 0;case"Time To Remediation (Seconds)":return e.timeToRemediationInSeconds;case"Resolved At":return e.resolvedAt?new Date(e.resolvedAt).toLocaleString():void 0;case"Location":var d,u,m;return null!=(a=e.location)&&a.name&&null!=(s=e.location)&&s.description?`${null==(d=e.location)?void 0:d.name}\n${null==(u=e.location)?void 0:u.description}`:null!=(r=e.location)&&r.name?null==(m=e.location)?void 0:m.name:void 0;case"Source Entity":return null==(i=e.sourceEntity)?void 0:i.name;case"Alarm Type":return e.type;case"Alarm Source System":return e.sourceSystem;case"Camera":return e.camera;case"Employee":return null==(o=e.employee)?void 0:o.name;case"Employee Phone Number":return null==(l=e.employee)?void 0:l.phoneNumber;case"Access Card Number":return null==(c=e.metadata)?void 0:c.badgeNumber;default:return}}const Yl=function(e){const{alarm:t}=e;return(0,H.jsx)(va,{title:"Overview",children:(0,H.jsx)("div",{className:"min-h-[20rem] px-6 pb-4",children:(0,H.jsx)(ba,{items:Gl(t),align:"vertical"})})})};var Ql=n(16450);function Xl(e){let t;switch(e){case"success":case Ve.SUCCESS:t=(0,H.jsx)(Ce.Z,{className:"h-5 w-5 text-green-400 dark:text-green-200"});break;case"warning":t=(0,H.jsx)(Te.Z,{className:"h-5 w-5 text-yellow-400 dark:text-yellow-200"});break;case"error":case Ve.FAILED:t=(0,H.jsx)(cl.Z,{className:"h-5 w-5 text-red-400 dark:text-red-300"});break;default:t=null}return t}const Jl=[{id:"rawAlarmId",name:"Raw Alarm Id"},{id:"rawAlarmAddedTime",name:"Raw Alarm Added Time"},{id:"status",name:"Talkdown Status"},{id:"ingestedTalkdown",name:"Relayed Talkdown"},{id:"talkdownTime",name:"Talkdown Completed Time"},{id:"comments",name:"Comments"}],ec=e=>e.map((e=>(0,H.jsx)("div",{className:"dark:text-ondark-text-1 font-bold text-gray-600",children:e.name},e.id)));const tc="Hakimo AI Engine",nc="Added a comment",ac="ACS Alarm Acknowledgment",sc="Responded via speaker talk-down",rc="Hakimo AI Engine";function ic(){return(new URLSearchParams).toString()}function oc(e){var t;if((null==(t=e.user)?void 0:t.name)===tc||null===e.user)return Ya;if(e.status)switch(Zl(e.status)){case"Resolved":return Qa;case"In Progress":return Xa;case"Pending":return Ja}switch(e.event){case sc:case ze.MANUAL_TALKDOWN:return es;case ze.VIEW_ALARM:return as;case ze.CALL_SMS_LOGS:return ts;default:return ns}}function lc(e,t=!1){var n,a,s,r,i,o,l,c,d,u,m,h;if(e.status){var x;let n="";var p,g;if(t)n=`${null!=(p=null==(g=e.user)?void 0:g.name)?p:rc} changed status to ${e.status}`;else if(void 0!==(null==(x=e.user)?void 0:x.name)){var f;n=`${null==(f=e.user)?void 0:f.name} changed status to ${e.status}`}else n=`Status changed to ${e.status}`;return e.comment&&(n+=`: ${e.comment}`),n}return e.event===nc||e.event===ze.ADD_COMMENT?t?`${null!=(s=null==(r=e.user)?void 0:r.name)?s:rc}: "${e.comment}"`:void 0!==(null==(a=e.user)?void 0:a.name)?`${null==(i=e.user)?void 0:i.name}: "${e.comment}"`:`"${e.comment}"`:e.event===ac?`Alarm Acknowledged via ACS: ${e.comment}`:e.event===sc||e.event===ze.MANUAL_TALKDOWN?t?`${null!=(l=null==(c=e.user)?void 0:c.name)?l:rc} responded via speaker talk-down`:void 0!==(null==(o=e.user)?void 0:o.name)?`${null==(d=e.user)?void 0:d.name} responded via speaker talk-down`:"Speaker talk-down conducted":e.event===ze.VIEW_ALARM?void 0!==(null==(u=e.user)?void 0:u.name)?`${null==(m=e.user)?void 0:m.name} viewed the alarm`:"Alarm was viewed":e.event===ze.CALL_SMS_LOGS?e.twilio_ssid?pl(e.twilio_ssid,e.twilio_calling_to_name,null==(h=e.user)?void 0:h.name):"Twilio SSID not found":`${null==(n=e.user)?void 0:n.name} added feedback: ${e.comment}`}function cc(e){return e.items.map((e=>{const t={icon:oc(e),description:lc(e),time:new Date(e.timestamp).toLocaleString(),audio_url:e.audio_url};return e.event===sc&&(t.extraDetails=function(e){var t;const n=null==e||null==(t=e.talkdown)?void 0:t[0];if(!n)return null;let a="";const s=n.status;switch(s){case Ve.SUCCESS:a="Talkdown transmitted successfully";break;case Ve.FAILED:a="Talkdown tranmission failed";break;case Ve.PENDING:a="Talkdown yet to be relayed"}return(0,H.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[a,Xl(s)]})}(e),t.extraDetailsModalContent=function(e){var t;const n=null==e||null==(t=e.talkdown)?void 0:t[0];if(!n)return null;const a=Jl.filter((e=>!["rawAlarmId","rawAlarmAddedTime"].includes(e.id)));return(0,H.jsxs)("div",{className:"grid grid-cols-4 gap-2 text-sm",children:[ec(a),(0,H.jsxs)("span",{className:"flex items-center gap-2",children:[Xl(n.status),n.status]}),(0,H.jsx)("span",{children:n.ingested_talkdown_audio?(0,H.jsx)("span",{className:"flex",children:(0,H.jsx)(Mr,{src:n.ingested_talkdown_audio,isLoading:!1})}):"NA"}),(0,H.jsx)("span",{children:n.talkdown_completed_utc?co()(new Date(n.talkdown_completed_utc)).format("DD/MM/YYYY, HH:mm:ss"):"-"}),(0,H.jsx)("span",{children:n.custom_message||"-"})]})}(e)),t}))}const dc=6e4;const uc=function(e){const{alarmId:t,children:n}=e;return n(It(t,ic(),dc))},mc=6e4;const hc=function(e){const{sharedToken:t,children:n}=e;return n(zt(t,ic(),mc))};function xc(e){const{open:t,onClose:n,alarm:s}=e,[r,i]=(0,a.useState)(null),{data:o}=Dt(),l=Gt(s.id,(()=>{n(),i(null),l.reset()})),c=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("span",{className:"mr-2",children:(0,H.jsx)(Q,{variant:"primary",loading:l.isLoading,disabled:l.isLoading||!(null!=r&&r.name.length),onClick:()=>{r&&l.mutate({comment:null==r?void 0:r.name,timestamp:(new Date).toISOString()})},onSideEffect:yt("submit_add_alarm_comment"),children:"Submit"})}),(0,H.jsx)(Q,{onClick:n,onSideEffect:yt("cancel_add_alarm_comment"),children:"Cancel"})]});return(0,H.jsxs)(ce,{open:t,onClose:n,title:"Add Comment",footer:c,children:[l.isError?(0,H.jsx)("div",{className:"w-96 px-8 py-2",children:(0,H.jsx)(B,{type:"error",children:"Error adding comment. Please try again."})}):null,(0,H.jsx)("div",{className:(0,z.Z)("w-96",l.isError?"px-8 py-2":"p-8"),children:(0,H.jsx)(Us,{label:"Comment",getItems:e=>ut(e,r,o),value:r,displayValue:e=>{var t;return null!=(t=null==e?void 0:e.name)?t:""},onChange:i,id:e=>e.id})})]})}const pc=function(e){const{alarm:t,sharedToken:n}=e,[s,r]=(0,a.useState)(!1),i=Ge(j(),"alarm/update:add-comment")?(0,H.jsx)("div",{className:"mr-6",children:(0,H.jsx)(ye,{text:"Add comment",position:"left",children:(0,H.jsx)(Q,{variant:"icon",onClick:()=>r(!0),onSideEffect:yt("open_add_alarm_comment_modal"),children:(0,H.jsx)(Ql.Z,{className:"w-5"})})})}):null,o=e=>(0,H.jsx)(Is,{queryResult:e,children:e=>{const n=cc(e);return(0,H.jsxs)("div",{className:"max-h-[30rem] overflow-auto",children:[n.length>0?(0,H.jsx)(Ws,{events:n}):(0,H.jsx)("div",{className:"p-6",children:(0,H.jsx)(B,{children:"No updates"})}),s&&(0,H.jsx)(xc,{open:!0,onClose:()=>r(!1),alarm:t})]})}});return(0,H.jsx)(va,{title:"Alarm Updates",secondary:i,children:n?(0,H.jsx)(hc,{sharedToken:n,children:o}):(0,H.jsx)(uc,{alarmId:t.id,children:o})})};const gc=function(e){const{tags:t}=e;return(0,H.jsx)(va,{title:"Alarm Tags",children:t&&t.length>0?(0,H.jsx)("div",{className:"flex flex-wrap gap-2 bg-white p-6 dark:bg-gray-800",children:t.map(((e,t)=>(0,H.jsx)("span",{children:(0,H.jsx)(re,{text:e})},t)))}):(0,H.jsx)("div",{className:"p-6",children:(0,H.jsx)(B,{children:"No tags are assigned to this alarm"})})})};const fc=function(e){const{alarm:t}=e;return(0,H.jsx)(va,{title:"Floorplan",children:t.floorplanPath?(0,H.jsx)("div",{className:"flex justify-center bg-gray-200 dark:bg-gray-900",children:(0,H.jsx)("img",{src:t.floorplanPath,alt:"Floorplan",className:"max-h-[48rem]"})}):(0,H.jsx)("div",{className:"p-6",children:(0,H.jsx)(B,{children:"Floorplan not available"})})})};var vc=n(88969);const jc=function(e){const{toName:t,toNumber:n}=e,[s,r]=(0,a.useState)(!1),[i,o]=(0,a.useState)(""),l=()=>r(!1),c=function(e){const t=new Request("/v2/orm/sms/twilio",{method:"POST"});return Ft(t,{onSuccess:e})}((()=>{Le("Message sent successfully",{type:"success"}),l()})),d=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{c.mutate({to_number:n,message:i})},loading:c.isLoading,onSideEffect:yt("sms_location_contact"),children:"Send"}),(0,H.jsx)(Q,{variant:"outline",onClick:l,disabled:c.isLoading,children:"Close"})]});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(Q,{onClick:()=>r(!0),children:[(0,H.jsx)(vc.Z,{className:"mr-2 h-4 w-4"}),"SMS"]}),s&&(0,H.jsx)(ce,{open:!0,onClose:l,title:"Message",footer:d,children:(0,H.jsxs)("div",{className:"w-[30rem] p-4",children:[c.isError&&(0,H.jsx)("div",{className:"px-8 pt-2",children:(0,H.jsx)(B,{type:"error",children:c.error.message})}),(0,H.jsxs)("div",{className:"mb-4",children:["To: ",t," ",(0,H.jsx)("span",{className:"text-xs",children:n})]}),(0,H.jsx)(pe,{rows:3,value:i,onChange:e=>o(e),placeholder:"Write your message here..."})]})})]})};var bc=n(44335);function yc(e){const{toName:t,toNumber:n,onCloseCb:a,locationAlarmId:s,locationTenantId:r}=e,i=Kt(s||"");return(0,H.jsx)(jl,{toName:t,toNumber:n,onCloseCb:a,onCallInitiated:e=>{s&&e.parameters.CallSid&&i.mutate({twilio_log_type:Ue.TWILIO_CALLS,twilio_ssid:e.parameters.CallSid,twilio_calling_to_name:t})},locationTenantId:r})}function kc(e){const{toNumber:t,toName:n,locationAlarmId:a,locationTenantId:s}=e,r=(0,ur.b9)(ft),i=()=>{r(null)};return(0,H.jsxs)(Q,{onClick:()=>{r((0,H.jsx)(yc,{onCloseCb:i,toName:n,toNumber:t,locationAlarmId:a,locationTenantId:s}))},onSideEffect:yt("call_location_contact"),children:[(0,H.jsx)(bc.Z,{className:"mr-2 h-4 w-4"}),"Call"]})}const wc=function(e){const{toNumber:t,toName:n,locationAlarmId:a,locationTenantId:s}=e;return(0,H.jsxs)("div",{className:"p-2",children:[(0,H.jsx)("div",{className:"text-start",children:n}),(0,H.jsx)("div",{className:"text-xs",children:t}),(0,H.jsxs)("div",{className:"mt-2 flex justify-end gap-2",children:[(0,H.jsx)(kc,{toNumber:t,toName:n,locationAlarmId:a,locationTenantId:s}),(0,H.jsx)(jc,{toNumber:t,toName:n})]})]})};const Nc=function(e){const{location:t}=e,n=Fn(t.id);return(0,H.jsx)(Is,{queryResult:n,children:e=>{const n=e.sort(((e,t)=>t.priority-e.priority));return(0,H.jsx)(va,{title:"Location Contacts",children:(0,H.jsx)("div",{className:"dark:divide-ondark-line-2 divide-onlight-line-2 divide-y p-4",children:n.map((e=>(0,H.jsx)(wc,{toNumber:e.phoneNumber,toName:e.name,locationTenantId:t.tenant_id},e.id)))})})}})};function Cc(e,t,n){const a=e.items.slice();a.splice(e.curIdx,0,t);return{columns:[{id:"alarmType",name:"Type"},{id:"timestamp",name:"Time"}],rows:a.map(((t,a)=>({onClick:n&&(e=>n(t,e)),id:`${t.id}`,highlighted:a===e.curIdx,cells:[{value:t.type},{value:new Date(t.timestamp).toLocaleString()}]})))}}const Sc=3e4;const Tc=function(e){const{alarm:t,searchParams:n,children:s}=e,i=(0,r.s0)(),o=(0,a.useCallback)(((e,t)=>{const n=`/alarms/${e.id}`;t.ctrlKey||t.metaKey?window.open(n,"_blank","noopener,noreferrer"):i(n)}),[i]),l=Ot(t.id,n,Sc);return(0,H.jsx)(Is,{queryResult:l,children:e=>s(Cc(e,t,o))})},Ec=3e4;const Ac=function(e){const{alarm:t,searchParams:n,sharedToken:a,children:s}=e,r=$t(a,n,Ec);return(0,H.jsx)(Is,{queryResult:r,children:e=>s(Cc(e,t))})};const _c=function(e,t){const n=new URLSearchParams;return n.append("alarmsBefore",String(e)),n.append("alarmsAfter",String(t)),n.toString()}(5,5);const Ic=function(e){const{alarm:t,sharedToken:n}=e,a=e=>(0,H.jsx)("div",{className:"pb-6",children:(0,H.jsx)(Ai,{data:e,embedded:!0})});return(0,H.jsx)(va,{title:"Neighboring Events",children:n?(0,H.jsx)(Ac,{alarm:t,sharedToken:n,searchParams:_c,children:a}):(0,H.jsx)(Tc,{alarm:t,searchParams:_c,children:a})})};var Lc=n(80652);const Rc=[{id:"missing-tag",value:"missingTag",label:"Missing Tag"},{id:"extra-tag",value:"extraTag",label:"Extra Tag"},{id:"tap-too-high",value:"tapTooHigh",label:"True Alarm Probability is too high"},{id:"tap-too-low",value:"tapTooLow",label:"True Alarm Probability is too low"}],Dc=[{id:"correct",name:"Correct"},{id:"incorrect",name:"Incorrect"}];function Pc(e,t){return e.length>0||t.length>0}const Mc=function(e){const{alarmId:t,onClose:n}=e,[s,r]=(0,a.useState)(Dc[0]),[i,o]=(0,a.useState)(""),[l,c]=(0,a.useState)([]),[d,u]=(0,a.useState)(),m=Gt(t,(()=>{Le("Feedback added",{type:"success"}),n()})),h=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{const e=function(e,t,n){return{timestamp:(new Date).toISOString(),feedback:{hakimoOutput:e.id,extraFeedback:n.map((e=>e.value))},comment:t}}(s,i,l);m.mutate(e)},loading:m.isLoading,disabled:m.isLoading||!Pc(l,i),onSideEffect:yt("submit_add_alarm_feedback"),children:"Submit"}),(0,H.jsx)(Q,{onClick:n,onSideEffect:yt("cancel_add_alarm_feedback"),children:"Cancel"})]}),x=Rc.map((e=>Object.assign({},e,{disabled:e.value===d})));return(0,H.jsxs)(ce,{open:!0,onClose:n,title:"Add Feedback",footer:h,children:[m.isError&&(0,H.jsx)("div",{className:"px-8 pt-2",children:(0,H.jsx)(B,{type:"error",children:m.error.message})}),(0,H.jsxs)("div",{className:"w-[30rem] p-8",children:[(0,H.jsx)("h2",{className:"dark:text-dark-text mb-1 text-sm text-gray-700",children:"Hakimo output"}),(0,H.jsx)(ue,{items:Dc,value:s,onChange:e=>{"correct"===e.id&&(c([]),u(void 0)),o(""),r(e)},id:e=>e.id,displayValue:e=>e.name}),"incorrect"===s.id&&(0,H.jsxs)("div",{className:"mt-6",children:[(0,H.jsx)("h2",{className:"dark:text-dark-text mb-1 text-sm text-gray-700",children:"Additional Feedback"}),(0,H.jsx)(te,{items:x,value:l,onChange:e=>{e.some((e=>"tapTooHigh"===e.value))?u("tapTooLow"):e.some((e=>"tapTooLow"===e.value))?u("tapTooHigh"):u(void 0),c(e)}})]}),(0,H.jsx)("div",{className:"mt-6",children:(0,H.jsx)(pe,{label:"Add your feedback",value:i,onChange:e=>o(e)})})]})]})};function Oc(e,t){return 0!==e.length&&!!t}const Fc=[{id:"low",name:"Low"},{id:"medium",name:"Medium"},{id:"high",name:"High"}];const Zc=function(e){const{alarmId:t,onClose:n}=e,s=Zt(t,(()=>{Le("Bug report submitted",{type:"success"}),n()})),[r,i]=(0,a.useState)(""),[o,l]=(0,a.useState)(),[c,d]=(0,a.useState)(),u=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{var e;if(!Oc(r,null==o?void 0:o.id))return;const t=function(e,t,n){return{description:e,severity:t,bugReporter:n}}(r,null!=(e=null==o?void 0:o.id)?e:"high",c);s.mutate(t)},loading:s.isLoading,disabled:s.isLoading||!Oc(r,null==o?void 0:o.id),onSideEffect:yt("submit_add_bug_report"),children:"Submit"}),(0,H.jsx)(Q,{onClick:n,onSideEffect:yt("cancel_add_bug_report"),children:"Cancel"})]});return(0,H.jsxs)(ce,{title:"Bug Report",footer:u,open:!0,onClose:n,children:[s.isError&&(0,H.jsx)("div",{className:"px-8 pt-2",children:(0,H.jsx)(B,{type:"error",children:s.error.message})}),(0,H.jsxs)("div",{className:"w-[30rem] p-8",children:[(0,H.jsx)("h2",{className:"dark:bg-dark-bg mb-1 block text-xs text-gray-700 dark:text-gray-300",children:"Hakimo output"}),(0,H.jsx)(ue,{items:Fc,value:o,onChange:l,id:e=>e.id,displayValue:e=>e.name}),(0,H.jsxs)("div",{className:"mt-6",children:[(0,H.jsx)("label",{htmlFor:"feedback",className:"mb-1 block text-xs text-gray-700 dark:text-gray-300",children:"Add your feedback"}),(0,H.jsx)("div",{className:"mt-1",children:(0,H.jsx)("textarea",{rows:4,name:"feedback",id:"feedback",className:"focus:border-primary-500 focus:ring-primary-500 dark:bg-dark-bg block w-full rounded-md border-gray-300 shadow-sm dark:border-gray-500 sm:text-sm",value:r,onChange:e=>i(e.target.value)})})]}),(0,H.jsxs)("div",{className:"mt-6",children:[(0,H.jsx)("label",{htmlFor:"bug-hunter-name",className:"mb-1 block text-xs text-gray-700 dark:text-gray-300",children:"Bug Hunter Name"}),(0,H.jsx)("div",{className:"mt-1",children:(0,H.jsx)("textarea",{rows:1,name:"bug-hunter-name",id:"bug-hunter-name",className:"focus:border-primary-500 focus:ring-primary-500 dark:bg-dark-bg block w-full rounded-md border-gray-300 shadow-sm dark:border-gray-500 sm:text-sm",value:c,onChange:e=>d(e.target.value)})})]})]})]})};var qc=n(39312);const Uc=function(e){const{onOpenFeedback:t,onOpenShareAlarm:n,onOpenBugReport:a}=e,s=Ge(j(),"alarm/bug-report:create"),r=[{name:"Share alarm",onClick:n},{name:"Add feedback",onClick:t,hidden:!Ge(j(),"alarm/update:add-feedback")},{name:"Report bug",onClick:a,hidden:!s}],i=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("span",{className:"sr-only",children:"Open options"}),(0,H.jsx)(qc.Z,{className:"h-5 w-5","aria-hidden":"true"})]});return(0,H.jsx)("div",{className:"flex items-center gap-2",children:(0,H.jsx)(Cs,{items:r,menuButton:i,menuButtonTrackingEvent:"open_alarm_actions_menu"})})};const Vc=function(e){const{alarmId:t,sharedToken:n,onRefresh:s}=e,[r,i]=(0,a.useState)(!1),[o,l]=(0,a.useState)(!1),[c,d]=(0,a.useState)(!1);return(0,H.jsxs)("div",{className:"flex",children:[(0,H.jsx)(Q,{variant:"icon",onClick:s,children:(0,H.jsx)(Lc.Z,{className:"h-5 w-5"})}),!n&&(0,H.jsxs)("div",{children:[(0,H.jsx)(Uc,{onOpenFeedback:()=>i(!0),onOpenShareAlarm:()=>l(!0),onOpenBugReport:()=>d(!0)}),r&&(0,H.jsx)(Mc,{alarmId:t,onClose:()=>i(!1)}),o&&(0,H.jsx)(Bo,{resourceId:t,resourceType:"alarm",onClose:()=>l(!1)}),c&&(0,H.jsx)(Zc,{alarmId:t,onClose:()=>d(!1)})]})]})},$c=(0,xt.cn)({});const zc=function(e){var t,n;const{alarm:s,sharedToken:i,onRefresh:o}=e,{onTrackResolve:l,onTrackTalkdown:c}=function(e){const t=(0,a.useRef)((new Date).getTime()),n=(0,a.useCallback)((t=>t[e]),[e]),s=(0,ur.Dv)((0,pt.kv)($c,n));return(0,a.useEffect)((()=>{void 0!==s&&kt("view_alarm_details",{alarm_id:e,time_to_view:t.current-s})}),[e,s,t]),{onTrackResolve:function(){kt("resolve_alarm",{alarm_id:e,time_to_resolve:(new Date).getTime()-t.current})},onTrackTalkdown:function(n){kt("submit_audio_recording",{camera_id:n,alarm_id:e,time_to_talkdown:(new Date).getTime()-t.current})}}}(s.id),d=(0,r.s0)(),[u]=M("alarmReturnPostResolve"),m=Ge(j(),"voice-call"),h=(0,H.jsxs)("span",{className:"dark:text-dark-secondary-text inline-flex max-w-[65%] items-center text-xs text-gray-500 xl:max-w-full",children:[s.type,(0,H.jsx)(ya,{}),null!=(t=null==(n=s.sourceEntity)?void 0:n.name)?t:"Unknown",(0,H.jsxs)("span",{title:s.id,className:"hidden items-center sm:inline-flex",children:[(0,H.jsx)(ya,{}),s.id]})]}),x=()=>{d("/alarms")};return(0,H.jsx)(mr,{title:"Alarm Details",subtitle:h,secondary:(0,H.jsx)(Vc,{alarmId:s.id,sharedToken:i,onRefresh:o}),onClickBack:i?void 0:x,children:(0,H.jsxs)("div",{className:"lg:grid-cols-3/4-1/4 grid grid-cols-1 items-start gap-6 pb-8",children:[(0,H.jsxs)("div",{className:"grid gap-6",children:[(0,H.jsx)(Ll,{alarm:s,sharedToken:i,onTalkdown:c}),(0,H.jsxs)("div",{className:"grid grid-cols-2 gap-6",children:[(0,H.jsx)(Bl,{alarm:s,onResolve:()=>{l(),u&&x()}}),(0,H.jsx)(gc,{tags:s.tags||[]}),(0,H.jsx)(Ic,{alarm:s,sharedToken:i}),(0,H.jsx)(pc,{alarm:s,sharedToken:i})]}),(0,H.jsx)(fc,{alarm:s})]}),(0,H.jsxs)("div",{className:"sticky top-6 z-0",children:[(0,H.jsx)(Yl,{alarm:s}),(0,H.jsx)("div",{className:"mt-4"}),m&&s.location&&(0,H.jsx)(Nc,{location:s.location})]})]})})};function Hc(e){const{sharedToken:t}=e,n=Vt(t),{refetch:a}=n;return(0,H.jsx)(Is,{queryResult:n,children:e=>(0,H.jsx)(zc,{alarm:e,sharedToken:t,onRefresh:()=>a()})})}function Bc(){const[e]=(0,Ss.lr)(),t=e.get("sharedToken");return null===t?(0,H.jsx)(As,{message:"Missing shared token in shared alarm URL"}):(0,H.jsx)(Hc,{sharedToken:t})}function Wc(e){const{alarmId:t}=e,n=At(t),{refetch:a}=n;return(0,H.jsx)(Is,{queryResult:n,children:e=>(0,H.jsx)(zc,{alarm:e,onRefresh:()=>a()})})}const Gc=nt(ht((function(){const{alarmId:e}=(0,r.UO)();return void 0===e?(0,H.jsx)(As,{}):(0,H.jsx)(Wc,{alarmId:e})})),["alarm/details:view"]);var Kc=n(31216);function Yc(e){const{value:t,label:n,enableNegativeFilters:a=!1,debounceDelay:s,onChange:r,getOptions:i}=e,o=e=>{r({values:e,negative:t.negative})},l=e=>e?null==e?void 0:e.name:"";return(0,H.jsxs)(H.Fragment,{children:[a&&(0,H.jsx)("div",{className:"pb-2",children:(0,H.jsx)(we,{enabled:t.negative,onChange:e=>{r(Object.assign({},t,{negative:e}))},type:"negative",EnabledIcon:Kc.Z,label:"Negative Filtering"})}),(0,H.jsx)(qs,{value:t.values,label:n,debounceDelay:s,onChange:o,onChangeQuery:i,displayValue:e=>(null==e?void 0:e.name)||"",customSelectedRenderer:e=>(0,H.jsx)(H.Fragment,{children:e.map(((e,n)=>(0,H.jsx)("span",{className:"mr-1",children:(0,H.jsx)(re,{text:l(e),removable:!0,onClickRemove:()=>{return e=n,void o([...t.values.slice(0,e),...t.values.slice(e+1)]);var e},type:t.negative?"error":"default"})},(e=>e.id)(e)||n)))}),id:e=>e.id})]})}const Qc=Yc;const Xc=function(e){const{value:t,label:n,enableNegativeFilters:a=!1,onChange:s,selectedLocations:r}=e,i=ln(function(e){const t=new URLSearchParams;if(e&&e.values.length>0){const n=e.values.map((e=>e.name));t.append("locations",n.join(Yn))}return t.toString()}(r)),o=(0,H.jsx)(Qc,{value:t,label:n,enableNegativeFilters:a,onChange:s,getOptions:i});return(0,H.jsx)("div",{children:r&&0===r.values.length?(0,H.jsx)("div",{className:"m-1 mt-2",children:(0,H.jsx)(B,{type:"info",children:"Select a location to enable filtering by cameras"})}):o})},Jc=Object.entries(Me).map((([e,t])=>({id:e,name:t}))),ed=[Me.PAST_MINUTE,Me.PAST_HOUR,Me.PAST_SIX_HOURS,Me.PAST_24_HOURS,Me.ALL_TIME],td=Jc.filter((e=>ed.includes(e.name))),nd=[Me.ALL_TIME,Me.PAST_HALF_HOUR,Me.PAST_HOUR,Me.PAST_12_HOURS,Me.PAST_24_HOURS,Me.CUSTOM_TIME],ad=Jc.filter((e=>nd.includes(e.name)));function sd(e){const{value:t,label:n,enableNegativeFilters:a=!1,onChange:s}=e,r=An();return(0,H.jsx)(Qc,{value:t,label:n,enableNegativeFilters:a,onChange:s,getOptions:r})}function rd(e){const{trackingEventNameApply:t,trackingEventNameReset:n,onApply:a,onReset:s}=e;return(0,H.jsxs)("div",{className:"space-y-3",children:[(0,H.jsx)(Q,{block:!0,variant:"primary",onClick:a,onSideEffect:yt(t),children:"Apply"}),(0,H.jsx)(Q,{block:!0,variant:"outline",onClick:s,onSideEffect:yt(n),children:"Reset"})]})}const id=rd;var od=n(35699),ld=n(34319),cd=n(7565);function dd(e){const{title:t,content:n,hasFilterApplied:a=!1,negativeApplied:s=!1,info:r}=e;return(0,H.jsx)(od.p,{as:"div",className:"py-2",children:({open:e})=>(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(od.p.Button,{className:"dark:bg-dark-bg dark:text-dark-text focus-visible:ring-primary-500 dark:focus-visible:ring-offset-dark-bg flex w-full items-center justify-between rounded py-3 text-gray-800 hover:text-gray-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 hover:dark:text-gray-400",children:[(0,H.jsxs)("span",{className:"flex items-center gap-2 text-sm",children:[t,a&&(0,H.jsx)("span",{className:(0,z.Z)("h-2 w-2 rounded-full",s?"bg-red-500":"bg-primary-500"),"aria-hidden":"true"}),r&&(0,H.jsx)(ye,{colorModifier:"info",text:r,size:"medium",children:(0,H.jsx)(be.Z,{className:"h-5 w-5"})})]}),e?(0,H.jsx)(ld.Z,{className:"w-4"}):(0,H.jsx)(cd.Z,{className:"w-4"})]}),(0,H.jsx)(od.p.Panel,{className:"pt-4 pb-6",unmount:!1,children:n})]})})}const ud=dd;const md=function(e){const{value:t,onChange:n}=e,a=ad.find((e=>e.name===t.name));return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Ps,{label:"Period",items:ad,value:a,onChange:e=>{n({id:e.id,name:e.name})},displayValue:e=>e?e.name:"--Select--"}),(null==a?void 0:a.name)===Me.CUSTOM_TIME&&(0,H.jsx)("div",{className:"mt-2",children:(0,H.jsx)(ae,{type:"number",label:"Custom time in minutes",value:t.customTime||"",onChange:e=>{n(Object.assign({},t,{customTime:e.target.value}))}})})]})};const hd=function(e){const{value:t,label:n,enableNegativeFilters:a=!1,onChange:s}=e,r=Nt();return(0,H.jsx)(Yc,{value:t,label:n,enableNegativeFilters:a,onChange:s,getOptions:r})};const xd=function(e){const{employees:t,onChange:n,label:a}=e,s=_n();return(0,H.jsx)(Yc,{value:t,label:a,enableNegativeFilters:!1,onChange:n,getOptions:s})};const pd=function(e){const{value:t,onChange:n}=e,{data:a}=Jn();return(0,H.jsx)(Fs,{label:"Alarm Source System",value:t,onChange:n,getItems:e=>{const{filterPredicate:n,isEqual:s}=st;return rt(e,t,n,s,{staticItems:a||[]})},displayValue:e=>null==e?void 0:e.name,id:e=>e.id})};const gd=function(e){const{options:t,value:n,onChange:a,enableNegativeFilters:s}=e,r=t.filter((e=>n.values.includes(e.name))),i=e=>{a({negative:n.negative,values:e.map((e=>e.name))})},o=e=>null==e?void 0:e.name,l=e=>e.id;return(0,H.jsxs)(H.Fragment,{children:[s&&(0,H.jsx)("div",{className:"pb-2",children:(0,H.jsx)(we,{enabled:n.negative,onChange:e=>{a(Object.assign({},n,{negative:e}))},type:"negative",EnabledIcon:yl.Z,label:"Negative Filtering"})}),(0,H.jsx)(Fs,{label:"Alarm Status",value:r,onChange:i,getItems:e=>{const{filterPredicate:n,isEqual:a}=st;return rt(e,r,n,a,{staticItems:t})},displayValue:o,id:l,customSelectedRenderer:e=>(0,H.jsx)("div",{className:"flex flex-wrap gap-1",children:e.map(((e,t)=>(0,H.jsx)("span",{children:(0,H.jsx)(re,{text:o(e),removable:!0,onClickRemove:()=>{return e=t,void i([...r.slice(0,e),...r.slice(e+1)]);var e},type:n.negative?"error":"default"})},l(e)||t)))})})]})};const fd=function(e){const{value:t,onChange:n}=e,a=Jc.find((e=>e.name===t.period));return(0,H.jsxs)("div",{children:[(0,H.jsx)(Ps,{label:"Period",items:Jc,value:a,onChange:e=>{n({period:e.name,customRangeStart:"",customRangeEnd:""})},displayValue:e=>e?e.name:"--Select--"}),(null==a?void 0:a.name)===Me.CUSTOM_RANGE&&(0,H.jsxs)("div",{className:"space-y-1",children:[(0,H.jsxs)("label",{className:"block",children:[(0,H.jsx)("span",{className:"dark:text-dark-text text-xs text-gray-700",children:"Start Date"}),(0,H.jsx)("input",{type:"datetime-local",className:"dark:bg-dark-bg mt-1 block w-full rounded border-gray-400 text-sm dark:border-gray-600 dark:text-white dark:[color-scheme:dark]",value:t.customRangeStart,onChange:e=>{n(Object.assign({},t,{customRangeStart:e.target.value}))}})]}),(0,H.jsxs)("label",{className:"block",children:[(0,H.jsx)("span",{className:"dark:text-dark-text text-xs text-gray-700",children:"End Date"}),(0,H.jsx)("input",{type:"datetime-local",className:"dark:bg-dark-bg mt-1 block w-full rounded border-gray-400 text-sm dark:border-gray-600 dark:text-white dark:[color-scheme:dark]",value:t.customRangeEnd,onChange:e=>{n(Object.assign({},t,{customRangeEnd:e.target.value}))}})]})]})]})};function vd(e){const{value:t,label:n,enableNegativeFilters:a=!1,onChange:s,cameraFilterValue:r,onCameraChange:i}=e,o=qn();return(0,H.jsx)(Qc,{value:t,label:n,enableNegativeFilters:a,onChange:e=>{const n=t;if(r&&r.values.length>0&&i){const t=n.values.filter((t=>!e.values.includes(t))).map((e=>e.id))[0];if(void 0!==t){const n=[...r.values].filter((e=>void 0!==e.location_id&&!t.includes(e.location_id))),a=Object.assign({},r,{values:n});return void i(a,e)}}s(e)},getOptions:o})}const jd=vd;const bd=function(e){const{value:t,label:n,enableNegativeFilters:a=!1,onChange:s}=e,r=ta();return(0,H.jsx)(Qc,{value:t,label:n,enableNegativeFilters:a,onChange:s,getOptions:r})};const yd=function(e){var t;const{value:n,label:a,enableNegativeFilters:s=!1,onChange:r}=e,i=null!=(t=j().mspTenants)?t:[];return(0,H.jsx)(Qc,{value:n,label:a,enableNegativeFilters:s,onChange:r,getOptions:e=>Promise.resolve(i.filter((t=>st.filterPredicate(e,t))))})};const kd=function(e){const{configs:t,values:n,onChange:a,enableNegativeFilters:s}=e;return(0,H.jsx)(H.Fragment,{children:t.map((e=>{const t=t=>{a(Object.assign({},n,{[e.type]:t}))},r=(e,t)=>{const s=Object.assign({},n,{camera:e,location:t});a(s)};switch(e.type){case"status":{var i;const a=n[e.type];return(0,H.jsx)(ud,{title:null!=(i=e.label)?i:"Status",content:(0,H.jsx)(gd,{options:e.options,value:a,onChange:t,enableNegativeFilters:s}),hasFilterApplied:a.values.length>0,negativeApplied:a.negative},e.type)}case"time":{var o;const a=n[e.type];return(0,H.jsx)(ud,{title:null!=(o=e.label)?o:"Time",content:(0,H.jsx)(fd,{value:a,onChange:t}),hasFilterApplied:a.period!==Me.ALL_TIME},e.type)}case"agedAlarm":{var l;const a=n[e.type];return(0,H.jsx)(ud,{title:null!=(l=e.label)?l:"Aged Alarms",info:"This filter retrieves alarms that have existed for a specified duration or longer.",content:(0,H.jsx)(md,{value:a,onChange:t}),hasFilterApplied:(null==a?void 0:a.id)!==Me.ALL_TIME},e.type)}case"sourceSystem":{var c;const a=n[e.type];return(0,H.jsx)(ud,{title:null!=(c=e.label)?c:"Source System",content:(0,H.jsx)(pd,{value:a,onChange:t}),hasFilterApplied:a.length>0},e.type)}case"location":{var d;const a=n[e.type],i=n.camera;return(0,H.jsx)(ud,{title:"Location",content:(0,H.jsx)(jd,{label:null!=(d=e.label)?d:"Alarm Location",value:a,onChange:t,enableNegativeFilters:s,cameraFilterValue:i,onCameraChange:r}),hasFilterApplied:a.values.length>0,negativeApplied:a.negative},e.type)}case"type":{var u;const a=n[e.type];return(0,H.jsx)(ud,{title:"Type",content:(0,H.jsx)(hd,{label:null!=(u=e.label)?u:"Alarm Type",value:a,onChange:t,enableNegativeFilters:s}),hasFilterApplied:a.values.length>0,negativeApplied:a.negative},e.type)}case"sourceEntity":{var m;const a=n[e.type];return(0,H.jsx)(ud,{title:"Source Entity",content:(0,H.jsx)(bd,{label:null!=(m=e.label)?m:"Source Entity Name",value:a,onChange:t,enableNegativeFilters:s}),hasFilterApplied:a.values.length>0,negativeApplied:a.negative},e.type)}case"employee":{var h;const a=n[e.type];return(0,H.jsx)(ud,{title:"Employee",content:(0,H.jsx)(xd,{label:null!=(h=e.label)?h:"Employee Name",onChange:t,employees:a}),hasFilterApplied:a.values.length>0},e.type)}case"tenant":{var x;const a=n[e.type];return(0,H.jsx)(ud,{title:"Tenant",content:(0,H.jsx)(yd,{value:a,label:null!=(x=e.label)?x:"Tenant",onChange:t,enableNegativeFilters:s}),hasFilterApplied:a.values.length>0,negativeApplied:a.negative},e.type)}case"camera":{var p;const a=n[e.type],r=n.location;return(0,H.jsx)(ud,{title:"Camera",content:(0,H.jsx)(Xc,{label:null!=(p=e.label)?p:"Camera",value:a,onChange:t,enableNegativeFilters:s,selectedLocations:r}),hasFilterApplied:a.values.length>0,negativeApplied:a.negative},e.type)}default:throw new Error("Unknown filter type")}}))})};function wd(e){const{open:t,title:n,filterConfigs:s,initialFilterValues:r,trackingEventNameApply:i,trackingEventNameReset:o,onClose:l,onApply:c,enableNegativeFilters:d=!1}=e,[u,m]=(0,a.useState)(r);return(0,a.useEffect)((()=>m(r)),[r]),(0,H.jsx)(_s,{title:n,open:t,onClose:l,children:(0,H.jsxs)("div",{className:"flex h-full flex-col space-y-6",children:[(0,H.jsx)("div",{className:"dark:divide-dark-border-bg dark:border-dark-border-bg flex-shrink-0 divide-y border-t border-b",children:(0,H.jsx)(kd,{configs:s,values:u,onChange:m,enableNegativeFilters:d})}),(0,H.jsx)("div",{className:"w-full grow"}),(0,H.jsx)("div",{className:"flex-shrink-0",children:(0,H.jsx)(id,{onApply:()=>c(u),onReset:()=>m(s.reduce(((e,t)=>Object.assign({},e,{[t.type]:t.defaultValue})),{})),trackingEventNameApply:i,trackingEventNameReset:o})})]})})}var Nd=n(50255),Cd=n(38910);const Sd=e=>{const{period:t,onChange:n}=e,s=P()?td:td.filter((e=>e.name!==Me.ALL_TIME)),r=s.find((e=>e.name===t));return(0,H.jsx)("div",{className:"flex items-center gap-2",children:(0,H.jsx)(Ls.R,{value:r,onChange:e=>n(e.name),children:({open:e})=>(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Ls.R.Label,{className:"sr-only",children:"Change time period"}),(0,H.jsxs)("div",{className:"relative",children:[(0,H.jsxs)("div",{className:"inline-flex items-center gap-2",children:[(0,H.jsxs)("div",{className:"dark:text-ondark-text-2 text-onlight-text-2 inline-flex items-center",children:[(0,H.jsx)(ge.Z,{className:"h-5 w-5","aria-hidden":"true"}),(0,H.jsx)("p",{className:"ml-2.5 text-sm font-medium",children:null==r?void 0:r.name})]}),(0,H.jsxs)(Ls.R.Button,{className:"dark:hover:bg-ondark-bg-2 hover:bg-onlight-bg-2 dark:focus:ring-ondark-primary focus:ring-onlight-primary dark:focus:ring-offset-ondark-bg-1 focus:ring-offset-onlight-bg-1 inline-flex items-center rounded-md p-1 text-sm font-medium focus:outline-none focus:ring-2 focus:ring-offset-2",children:[(0,H.jsx)("span",{className:"sr-only",children:"Change time period"}),(0,H.jsx)(Nd.Z,{className:"dark:text-ondark-text-2 text-onlight-text-2 h-5 w-5","aria-hidden":"true"})]})]}),(0,H.jsx)(ie.u,{show:e,as:a.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,H.jsx)(Ls.R.Options,{className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 absolute z-10 mt-1 w-full overflow-auto rounded-md py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm",children:s.map((e=>(0,H.jsx)(Ls.R.Option,{className:({active:e})=>(0,z.Z)(e?"bg-onlight-primary dark:bg-ondark-primary text-white":"text-onlight-text-1 dark:text-ondark-text-1","relative cursor-default select-none px-3 py-2"),value:e,children:({selected:t,active:n})=>(0,H.jsx)("div",{className:"flex w-full flex-col",children:(0,H.jsxs)("div",{className:"flex justify-between",children:[(0,H.jsx)("p",{className:t?"font-bold":"font-normal",children:e.name}),t?(0,H.jsx)("span",{className:n?"text-white":"text-onlight-primary dark:text-ondark-primary",children:(0,H.jsx)(Cd.Z,{className:"h-5 w-5","aria-hidden":"true"})}):null]})})},e.id)))})})]})]})})})};function Td(e,t,n,a){const s=new URLSearchParams;if(s.append("page",String(e)),s.append("pageSize",String(t)),n.location&&n.location.values.length>0){const e=Ad(n.location.values.map((e=>e.id)),n.location.negative);s.append("locationIds",e)}if(n.camera&&n.camera.values.length>0){const e=Ad(n.camera.values.map((e=>e.id)),n.camera.negative);s.append("camera_ids",e)}if(n.sourceEntity&&n.sourceEntity.values.length>0){const e=Ad(n.sourceEntity.values.map((e=>e.name)),n.sourceEntity.negative);s.append("sourceEntities",e)}if(n.type&&n.type.values.length>0){const e=Ad(n.type.values.map((e=>e.name)),n.type.negative);s.append("types",e)}if(n.tenant&&n.tenant.values.length>0){const e=Ad(n.tenant.values.map((e=>e.id)),n.tenant.negative);s.append("tenants",e)}if(n.status&&n.status.values.length>0){const e=Ad([...n.status.values],n.status.negative);s.append("statuses",e)}if(n.employee&&n.employee.values.length>0){const e=Ad(n.employee.values.map((e=>e.id)),!1);s.append("employeeIds",e)}if(n.sourceSystem&&n.sourceSystem.length>0){const e=Ad(n.sourceSystem.map((e=>e.name)),!1);s.append("sourceSystems",e)}if(n.time&&n.time.period!==Me.ALL_TIME)if(n.time.period===Me.CUSTOM_RANGE){const[e,t]=function(e){let t,n;e.period===Me.CUSTOM_RANGE?(n=new Date(e.customRangeStart).getTime(),t=new Date(e.customRangeEnd).getTime()):(t=Date.now(),n=e.period===Me.PAST_MINUTE?t-6e4:e.period===Me.PAST_HOUR?t-36e5:e.period===Me.PAST_SIX_HOURS?t-216e5:e.period===Me.PAST_24_HOURS?t-864e5:e.period===Me.PAST_WEEK?t-6048e5:e.period===Me.PAST_MONTH?t-2592e6:t-7776e6);return[n,t]}(n.time);s.append("dateFrom",String(e)),s.append("dateTo",String(t))}else{const[e,t]=Ed(n.time.period);t&&s.append("relativeTimeHours",String(t)),e&&s.append("relativeTimeMinutes",String(e))}if(n.agedAlarm&&n.agedAlarm.name!==Me.ALL_TIME){let e=0;if(n.agedAlarm.name===Me.CUSTOM_TIME&&void 0!==n.agedAlarm.customTime){var r;e=+(null==(r=n.agedAlarm)?void 0:r.customTime)}else{const[t,a]=Ed(n.agedAlarm.name);e=60*a+t}s.append("agedAlarmTimeMinutes",String(e))}return a&&s.append("tenants",a.map((e=>e.id)).join(Yn)),s.toString()}function Ed(e){switch(e){case Me.PAST_MINUTE:return[1,0];case Me.PAST_HALF_HOUR:return[0,.5];case Me.PAST_HOUR:return[0,1];case Me.PAST_SIX_HOURS:return[0,6];case Me.PAST_12_HOURS:return[0,12];case Me.PAST_24_HOURS:return[0,24];case Me.PAST_WEEK:return[0,168];case Me.PAST_MONTH:return[0,720];case Me.PAST_THREE_MONTHS:return[0,2160];default:return[0,0]}}function Ad(e,t){const n=e;return t&&n.push(Qn),n.join(Yn)}var _d=n(92159);const Id=function(e){const{user:t}=e,[n,s]=(0,ur.KO)(bt),r=(0,a.useMemo)((()=>function(e){const t=[e.tenant];return e.mspTenants&&e.mspTenants.forEach((n=>{n.id!==e.tenant.id&&t.push(n)})),t.sort()}(t)),[t]);return(0,H.jsx)(Ps,{items:r,value:n,onChange:s,displayValue:e=>{var t;return null!=(t=null==e?void 0:e.name)?t:""}})};const Ld=function(e){const{selectableColumns:t,alarmListShownColumns:n,filterValues:a,onOpenFilterPanel:s,onChangeShownColumns:r}=e,i=j();return(0,H.jsxs)("div",{className:"flex items-center justify-end gap-4",children:[i.mspTenants&&i.mspTenants.length>0&&(0,H.jsx)(Id,{user:i}),(0,H.jsx)(Li,{options:t,shownColumns:n,onChangeShownColumns:r}),(0,H.jsxs)(Q,{variant:"icon",badge:ql(a),onClick:s,onSideEffect:yt("open_alarm_filters_panel"),children:[(0,H.jsx)("span",{className:"sr-only",children:"Open filters panel"}),(0,H.jsx)(_d.Z,{className:"h-5 w-5","aria-hidden":"true"})]})]})},Rd=50,Dd=5e3,Pd=[{type:"status",defaultValue:{values:[],negative:!1},options:[{id:"analyzing",name:"Analyzing"},{id:"pending",name:"Pending"},{id:"resolvedByHakimo",name:"Resolved by Hakimo"},{id:"resolvedManually",name:"Resolved Manually"},{id:"acsAck",name:"Alarm Acknowledged via ACS"},{id:"inProgress",name:"In Progress"}]},{type:"time",defaultValue:{period:Me.PAST_24_HOURS,customRangeStart:"",customRangeEnd:""}},{type:"agedAlarm",defaultValue:{id:Me.ALL_TIME,name:Me.ALL_TIME}},{type:"sourceSystem",defaultValue:[]},{type:"location",defaultValue:{values:[],negative:!1}},{type:"type",defaultValue:{values:[],negative:!1}},{type:"sourceEntity",defaultValue:{values:[],negative:!1}},{type:"employee",defaultValue:{values:[],negative:!1}},{type:"tenant",defaultValue:{values:[],negative:!1}}],Md=["rgb(22, 163, 74)","rgb(19, 171, 18)","rgb(78, 180, 15)","rgb(146, 189, 10)","rgb(197, 172, 6)","rgb(200, 123, 7)","rgb(197, 95, 12)","rgb(193, 70, 17)","rgb(189, 48, 23)","rgb(185, 28, 28)"],Od=[{id:"timestamp",name:"Time"},{id:"status",name:"Status",showAtBreakpoint:"xl"},{id:"tap",name:"TAP",showAtBreakpoint:"xl"},{id:"type",name:"Type",showAtBreakpoint:"md"},{id:"sourceSystem",name:"Source System",showAtBreakpoint:"lg"},{id:"location",name:"Location",showAtBreakpoint:"lg"},{id:"sourceEntity",name:"Source Entity",showAtBreakpoint:"md"},{id:"employee",name:"Employee",showAtBreakpoint:"lg"},{id:"tenant",name:"Tenant",showAtBreakpoint:"lg"}],Fd={timestamp:e=>({value:new Date(e.timestamp).toLocaleString()}),status:e=>({value:(0,H.jsx)(re,{text:e.status,type:Fl(e.status)})}),tap:e=>{const t=e.tap?Md[Math.min(Math.floor(e.tap/10),9)]:null;return{value:t?(0,H.jsxs)("div",{children:[(0,H.jsx)("span",{className:"inline-block h-4 w-4 rounded-full align-middle",style:{backgroundColor:t}}),(0,H.jsx)("span",{className:"px-2 py-1 text-xs font-medium",children:e.tap})]}):"-"}},type:e=>({value:e.type}),sourceSystem:e=>({value:e.sourceSystem}),location:e=>{var t,n;return{value:null!=(t=null==(n=e.location)?void 0:n.name)?t:"Unknown Location"}},sourceEntity:e=>{var t,n;return{value:null!=(t=e.sourceEntity)&&t.name?null==(n=e.sourceEntity)?void 0:n.name:"Unknown"}},employee:e=>{var t;return{value:null==(t=e.employee)?void 0:t.name}},tenant:e=>({value:e.tenant.name})};const Zd=function(e){const{tableData:t,canViewTenantColumn:n,shownColumns:a,isLoading:s,isRefetching:r,total:i,page:o,pageSize:l,filterValues:c,onChangeShownColumns:d,onOpenFilterPanel:u,onChangePage:m}=e,h=Od.filter((e=>"tenant"!==e.id||n)),x=(o-1)*l,p=Math.min(o*l,i)-1,g=(0,H.jsxs)("div",{className:"dark:bg-dark-bg flex items-center justify-end gap-4 border-b bg-white p-4 dark:border-0",children:[r&&(0,H.jsx)(K,{}),(0,H.jsx)(Ld,{selectableColumns:h,filterValues:c,alarmListShownColumns:a,onOpenFilterPanel:u,onChangeShownColumns:e=>{d(e)}})]}),f=(0,H.jsx)("div",{className:"dark:bg-dark-bg border-t bg-white p-4 dark:border-gray-800",children:(0,H.jsx)(wi,{from:x+1,to:p+1,pageSize:l,total:i,disabled:s,onChangePage:m})});return(0,H.jsx)("div",{className:"dark:bg-dark-bg -mx-4 flex min-h-0 flex-1 flex-col justify-start overflow-y-hidden sm:-mx-6 md:mx-0 md:rounded-lg",children:(0,H.jsx)(Ai,{data:t,loading:s,header:g,footer:f,scrollResetKey:o})})},qd=e=>Pd.filter((t=>"tenant"!==t.type||e)),Ud=e=>qd(e).reduce(((e,t)=>Object.assign({},e,{[t.type]:t.defaultValue})),{}),Vd=(e,t)=>{const n=Ud(t);return Object.keys(n).reduce(((t,a)=>Object.assign({},t,{[a]:e[a]||n[a]})),{})},$d=(0,xt.cn)(1);const zd=function(){const e=(0,ur.Dv)(bt),t=(0,a.useMemo)((()=>e?[e]:[]),[e]),n=Ge(j(),"multi-tenant:view"),[s]=(0,a.useState)((()=>(0,pt.O4)("rawAlarms/filters",Ud(n)))),[i,o]=(0,ur.KO)($d),[l,c]=(0,ur.KO)(s),[d,u]=(0,a.useState)(0),[m,h]=(0,a.useState)(Td(i,Rd,l,t)),x=(0,ur.Dv)(vt),[p,g]=(0,a.useState)(!1),f=qd(n),v=(0,ur.Dv)(jt),b=(0,a.useMemo)((()=>Od.filter((e=>"tenant"!==e.id||n)).map((e=>e.id))),[n]),[y,k]=(0,a.useState)({columns:Od,rows:[]}),w=(0,a.useRef)(),[N,C]=M("alarm-list-shown-columns",b);(0,a.useEffect)((()=>{c((e=>Vd(e,n)))}),[c,n]),(0,a.useEffect)((()=>{h(Td(i,Rd,l,t))}),[i,l,t]);const{isLoading:S,isError:T,error:E,data:A,isRefetching:_}=Lt(m,Dd),I=function(){const e=(0,r.s0)();return(0,a.useCallback)(((t,n)=>{const a=`/alarms/${t.id}`;n.ctrlKey||n.metaKey?window.open(a,"_blank","noopener,noreferrer"):e(a)}),[e])}();!function(e){const t=(0,ur.b9)($c);(0,a.useEffect)((()=>{if(!e)return;const{items:n}=e,a=(new Date).getTime();t((e=>n.reduce(((t,n)=>{var s;return Object.assign({},t,{[n.id]:null!=(s=e[n.id])?s:a})}),{})))}),[e,t])}(A);const{data:L}=xa();return(0,a.useEffect)((()=>{if(A){var e;const{items:t,total:a}=A,s=function(e,t,n,a){const s=Od.filter((e=>a.includes(e.id))).filter((e=>"tenant"!==e.id||n)),r=e.map((e=>({onClick:n=>t(e,n),id:e.id,cells:s.map((t=>{const n=t.id;return Fd[n](e)}))})));return{columns:s,rows:r}}(t,I,n,null!=N?N:b);Ul(null==(e=w.current)?void 0:e.items,A.items,i,"alarm",x,v,L),w.current=A,k(s),u(a)}}),[A,I,n,N,b,i,x,v,L]),(0,H.jsxs)(mr,{title:"Alarms",children:[T&&(0,H.jsx)("div",{className:"mb-2",children:(0,H.jsx)(B,{type:"error",children:E.message})}),(0,H.jsx)(wd,{title:"Alarm Filters",open:p,filterConfigs:f,initialFilterValues:l,trackingEventNameApply:"apply_alarms_filters",trackingEventNameReset:"reset_alarms_filters",onClose:()=>g(!1),onApply:e=>{c(e),wt(e),g(!1),o(1)},enableNegativeFilters:!0}),(0,H.jsx)(Zd,{tableData:y,canViewTenantColumn:n,shownColumns:null!=N?N:b,isLoading:(S||_)&&!y,isRefetching:_||S,total:d,page:i,pageSize:Rd,filterValues:l,onChangeShownColumns:C,onOpenFilterPanel:()=>g(!0),onChangePage:e=>o(e)})]})};const Hd=nt(ht((function(){const[e,t]=(0,ur.KO)(bt),n=j();return(0,a.useEffect)((()=>{e||t(n.tenant)}),[e,t,n]),e?(0,H.jsx)(zd,{}):(0,H.jsx)(ws,{})})),["alarm:view"]);const Bd=function(){return(0,H.jsxs)(r.Z5,{children:[(0,H.jsx)(r.AW,{path:"/",element:(0,H.jsx)(Hd,{})}),(0,H.jsx)(r.AW,{path:":alarmId",element:(0,H.jsx)(Gc,{})})]})};function Wd(){return(0,H.jsx)(Bd,{})}const Gd=function(e){const{period:t,onChangePeriod:n,onClickOpenFilterPanel:a,filterValues:s,isLoading:r}=e;return(0,H.jsxs)("div",{className:"flex h-12 flex-shrink-0 items-center justify-between gap-4 pl-1",children:[(0,H.jsx)(Sd,{period:t,onChange:n}),(0,H.jsxs)("div",{className:"flex items-center justify-end gap-4 pl-1",children:[r&&(0,H.jsx)(K,{}),(0,H.jsx)("span",{className:"pr-4",children:(0,H.jsx)(Q,{variant:"icon",onClick:a,badge:ql(s),children:(0,H.jsx)(_d.Z,{className:"dark:text-ondark-text-2 h-5 w-5"})})})]})]})};const Kd=[{type:"status",defaultValue:{values:[],negative:!1},options:[{id:"pending",name:"Pending"},{id:"resolved",name:"Resolved"},{id:"inProgress",name:"In Progress"}]},{type:"location",defaultValue:{values:[],negative:!1}},{type:"camera",defaultValue:{values:[],negative:!1}}],Yd=Kd.reduce(((e,t)=>Object.assign({},e,{[t.type]:t.defaultValue})),{}),Qd=(0,pt.O4)("locationAlarms/timePeriod",Me.PAST_24_HOURS),Xd=(0,pt.O4)("alarmReturnPostResolve",!1),Jd=(0,xt.cn)(1),eu=(0,xt.cn)(30),tu=(0,pt.O4)("locationAlarms/viewMode","split"),nu=(0,pt.O4)("locationAlarms/filters",Yd),au=(0,xt.cn)({});const su=function(e){const{beginTime:t,endTime:n}=e;return(0,H.jsxs)("div",{className:"h-9",children:[(0,H.jsx)("h2",{children:"Events"}),(0,H.jsxs)("h3",{className:"text-onlight-text-2 dark:text-ondark-text-2 text-xs",children:[new Date(t).toLocaleString()," -"," ",new Date(n).toLocaleTimeString()]})]})};var ru=n(72888);const iu=e=>{if(!e)return"-";const t=new Date(e);return co()(t).format("DD/MM/YYYY, HH:mm:ss")};function ou(e,t){const n=e.length,a=e.every((e=>!e.raw_alarm_id)),s=t.filter((e=>e.talkdown_type===$e.AUTOMATED));if(a||0===s.length)return null;let r=0;for(let l=0;l<e.length;l++){const t=e[l].raw_alarm_id;s.some((e=>e.raw_alarm_id===t&&e.status===Ve.SUCCESS))&&r++}let i="",o="info";n===r?(i=(n>1?"All ":"")+"Automated talkdown were succcssfully transmitted",o="success"):0===r?(i=(n>1?"All ":"")+"Automated talkdown tranmission failed",o="error"):n>r&&(i=(n>1?"Some ":"")+"Automated talkdowns tranmission failed",o="warning");return(0,H.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[i,Xl(o)]})}function lu(e,t,n){const a=e.every((e=>!e.raw_alarm_id)),s=t.filter((e=>e.talkdown_type===$e.AUTOMATED));if(a||0===s.length)return null;const r=[];e.reduce(((e,t)=>{const n=t.raw_alarm_id,a=s.find((e=>e.raw_alarm_id===n));return a&&e.push({rawAlarmId:null==a?void 0:a.raw_alarm_id,rawAlarmAddedTime:t.update_time,ingestedTalkdownAudio:a.ingested_talkdown_audio,customMessage:a.custom_message,status:a.status,sentTalkdownAudio:a.talkdown_audio,completedTimeUtc:a.talkdown_completed_utc}),e}),r);const i=Jl;return(0,H.jsxs)("div",{className:"text-sm",children:[(0,H.jsx)("div",{className:"grid grid-cols-6 gap-2",children:ec(i)}),(0,H.jsx)("div",{className:"max-h-[70vh] overflow-auto",children:r.map((e=>{return(0,H.jsxs)("div",{className:"hover:bg-onlight-bg-2 dark:hover:bg-ondark-bg-2 grid grid-cols-6 gap-2 rounded py-6",children:[(0,H.jsxs)("div",{className:"flex items-center gap-2",children:[(0,H.jsx)("span",{className:"w-[8rem] overflow-hidden text-ellipsis whitespace-nowrap",children:e.rawAlarmId}),n&&(0,H.jsx)(Q,{variant:"icon",onClick:(t=e.rawAlarmId,()=>{if(n&&t){const e=`/alarms/${t}`;window.open(e,"_blank","noopener,noreferrer")}}),children:(0,H.jsx)(ru.Z,{className:"text-primary-400 h-3 w-3"})})]}),(0,H.jsx)("span",{children:iu(e.rawAlarmAddedTime)}),(0,H.jsxs)("span",{className:"flex gap-2",children:[Xl(e.status),e.status]}),(0,H.jsx)("span",{children:e.ingestedTalkdownAudio?(0,H.jsx)("span",{className:"flex",children:(0,H.jsx)(Mr,{src:e.ingestedTalkdownAudio,isLoading:!1})}):"NA"}),(0,H.jsx)("span",{children:iu(e.completedTimeUtc)}),(0,H.jsx)("span",{children:e.customMessage||"-"})]},e.rawAlarmId);var t}))})]})}function cu(e,t){const n=[],a=e.talkdowns||[],s=[...e.items].filter((e=>e.update_type===ze.ADD_EVENT)).sort(((e,t)=>new Date(e.update_time).getTime()-new Date(t.update_time).getTime()));if(s&&s.length>0){const e=s[0],t=new Date(e.update_time);n.push({icon:Ya,description:"Location alarm created",time:t.toLocaleString(),timestamp:t.getTime()-1})}const[r,i]=e.items.reduce(((e,t)=>(t.update_type===ze.ADD_EVENT?e[0][e[0].length-1].push(t):(e[1].push(t),e[0].push([])),e)),[[[]],[]]);r.forEach((e=>{if(e.length>0){const s=new Date(e[e.length-1].update_time);n.push({icon:Ya,description:`Added ${e.length} new alarm${e.length>1?"s":""}`,time:s.toLocaleString(),timestamp:s.getTime(),extraDetails:ou(e,a||[]),extraDetailsModalContent:lu(e,a||[],t)})}}));const[o,l]=i.reduce(((e,t)=>{var n,a;t.update_type===ze.VIEW_ALARM?0===e[0][e[0].length-1].length||(null==(n=t.user)?void 0:n.id)===(null==(a=e[0][e[0].length-1][0].user)?void 0:a.id)?e[0][e[0].length-1].push(t):e[0].push([t]):(e[1].push(t),e[0].push([]));return e}),[[[]],[]]);return o.forEach((e=>{if(e.length>0){const t=new Date(e[e.length-1].update_time),a=e[0].user;n.push({icon:as,description:`${null==a?void 0:a.name} viewed this alarm ${e.length} time${e.length>1?"s":""}`,time:t.toLocaleString(),timestamp:t.getTime()})}})),n.push(...l.map((e=>{const t={user:e.user,status:e.update_status,event:e.update_type,comment:e.update_text,twilio_ssid:e.twilio_ssid,twilio_calling_to_name:e.twilio_calling_to_name},n=new Date(e.update_time),s={icon:oc(t),description:lc(t,!0),time:n.toLocaleString(),timestamp:n.getTime(),audio_url:e.audio_url};return e.update_type===ze.MANUAL_TALKDOWN&&(s.extraDetails=function(e,t){let n=e.audio_url;if(!n)return null;n=n.split("?")[0];const a=t.find((e=>e.talkdown_type===$e.MANUAL&&n&&e.talkdown_audio.includes(n)));let s="",r=null;switch(null==a?void 0:a.status){case Ve.SUCCESS:s="Talkdown transmitted successfully",r=Xl("success");break;case Ve.PENDING:s="Talkdown yet to be relayed";break;case Ve.FAILED:s="Talkdown tranmission failed",r=Xl("error")}return(0,H.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[s,r]})}(e,a),s.extraDetailsModalContent=function(e,t){let n=e.audio_url;if(!n)return null;if(n=n.split("?")[0].split("audio")[1],!n)return;const a=t.find((e=>e.talkdown_type===$e.MANUAL&&n&&e.talkdown_audio.includes(n)));if(!a)return null;const s=Jl.filter((e=>!["rawAlarmId","rawAlarmAddedTime"].includes(e.id)));return(0,H.jsxs)("div",{className:"grid grid-cols-4 gap-2 text-sm",children:[ec(s),(0,H.jsxs)("span",{className:"flex gap-2",children:[Xl(a.status),a.status]}),(0,H.jsx)("span",{children:a.ingested_talkdown_audio?(0,H.jsx)("span",{className:"flex",children:(0,H.jsx)(Mr,{src:a.ingested_talkdown_audio,isLoading:!1})}):"NA"}),(0,H.jsx)("span",{children:iu(a.talkdown_completed_utc)}),(0,H.jsx)("span",{children:a.custom_message||"-"})]})}(e,a)),s}))),n.sort(((e,t)=>t.timestamp-e.timestamp)).map((e=>({icon:e.icon,description:e.description,time:e.time,audio_url:e.audio_url,extraDetails:e.extraDetails,extraDetailsModalContent:e.extraDetailsModalContent})))}const du=6e4;const uu=function(e){const{locationAlarmId:t}=e,n=Pt(t,du),a=P();return(0,H.jsxs)("div",{className:"space-y-1",children:[(0,H.jsx)("h2",{className:"flex h-9 items-center",children:"Alarm Updates"}),(0,H.jsx)(Is,{queryResult:n,loadingText:"",children:e=>{const t=cu(e,a);return(0,H.jsx)("div",{className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 max-h-[30rem] overflow-auto",children:t.length>0?(0,H.jsx)(Ws,{events:t}):(0,H.jsx)("div",{className:"p-6",children:(0,H.jsx)(B,{children:"No updates"})})})}})]})};var mu=n(21163),hu=n(43669);const xu=e=>e.reduce(((e,t)=>e.concat(t)),[]);function pu(e){switch(e){case Re.PERSON:return"Person";case Re.VEHICLE:return"Vehicle";default:return""}}const gu=e=>e.map((e=>{const[t,n,a,s]=e.coords,r=[[t,n],[t+a,n],[t+a,n+s],[t,n+s]];return{color:e.type===Re.VEHICLE?"red":"yellow",pointSize:"small",closed:!0,points:r,tag:pu(e.type)}}));function fu(e,t){return e.onStatusChange===t.onStatusChange&&_(e.alarm,t.alarm)}const vu=(e,t,n,a,s)=>{const r=new URLSearchParams;if(e&&e.length>0){const t=e.join(Yn);r.append("sourceEntityIds",t)}if(a&&r.append("locationIds",a),t&&r.append("dateFrom",String(t)),n&&r.append("dateTo",String(n)),s&&s.length>0){const e=s.join(Yn);r.append("statuses",e)}return r.toString()};const ju=function(e){const{boxes:t=[],videoRect:n,videoHeight:s,videoWidth:r,videoRef:i}=e,o=(0,a.useRef)(null);(0,a.useEffect)((()=>{const e=null==i?void 0:i.current;let t;return e&&(t=new MutationObserver((function(t){t.forEach((function(){const t=e.style.transform,n=e.style.translate;if(o.current){const e=o.current.children[0];e.style.transform=t,e.style.translate=n}}))})),t.observe(e,{attributes:!0,attributeFilter:["style"]})),()=>{t&&t.disconnect()}}),[i]);const l=(0,a.useMemo)((()=>gu(t)),[t]),c=(0,a.useMemo)((()=>n&&l?l.map((e=>Object.assign({},e,{points:e.points.map((e=>s&&r?us([n.width,n.height],[r,s],{point:e}).point:e))}))):[]),[n,l,s,r]);return(0,H.jsx)("div",{ref:o,children:ps(c)})};const bu=function(e){var t,n,s;const{videoPath:r,startTime:i=0,hasNext:o,hasPrevious:l,onNext:c,onPrevious:d,boxes:u}=e,m=(0,a.useRef)(null),h=(0,a.useRef)(null),[x,p]=(0,a.useState)(!1),{isFullScreen:g,toggleFullScreen:f}=D(h);return Ne(),(0,a.useEffect)((()=>{if(!m.current)return;const e=m.current,t=()=>{p(!0),e.play().catch((e=>{y.uT("Failed to play video",{extra:{videoPath:r,error:e}})}))};return r&&(e.load(),e.currentTime=i,e.addEventListener("loadedmetadata",t)),()=>{p(!1),e.removeEventListener("loadedmetadata",t)}}),[r,i]),(0,a.useEffect)((()=>{if(!m.current)return;const e=m.current,t=()=>{c()};return r&&e.addEventListener("ended",t),()=>{e.removeEventListener("ended",t)}}),[c,r]),(0,H.jsx)("div",{className:"relative space-y-3",children:(0,H.jsxs)("div",{className:"group relative overflow-hidden",ref:h,children:[(0,H.jsx)("video",{ref:m,className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 peer aspect-video w-full object-fill",muted:!0,children:(0,H.jsx)("source",{src:r,type:"video/mp4"})}),(0,H.jsx)(oi,{isFullScreen:g,onFullScreen:f,videoRef:m,containerRef:h}),l&&(0,H.jsx)("div",{className:"invisible absolute top-1/2 left-2 -translate-y-1/2 group-hover:visible",children:(0,H.jsx)(Q,{variant:"icon",onClick:d,children:(0,H.jsx)(mu.Z,{className:"w-5"})})}),o&&(0,H.jsx)("div",{className:"invisible absolute top-1/2 right-2 -translate-y-1/2 group-hover:visible",children:(0,H.jsx)(Q,{variant:"icon",onClick:c,children:(0,H.jsx)(hu.Z,{className:"w-5"})})}),x&&(0,H.jsx)(ju,{boxes:u,videoRef:m,videoHeight:null==(t=m.current)?void 0:t.videoHeight,videoWidth:null==(n=m.current)?void 0:n.videoWidth,videoRect:null==(s=m.current)?void 0:s.getBoundingClientRect()})]})})},yu=20,ku=10,wu=5,Nu={top:30,bottom:45,right:30},Cu=100,Su=150;function Tu(e){const{visibleContentWidth:t,height:n}=e;return(0,H.jsxs)("defs",{children:[(0,H.jsxs)("filter",{id:"right-shadow",children:[(0,H.jsx)("feGaussianBlur",{in:"SourceAlpha",stdDeviation:"3",result:"blur"}),(0,H.jsx)("feOffset",{in:"blur",dx:"1",dy:"",result:"offsetBlur"}),(0,H.jsx)("feFlood",{floodColor:"rgba(0,0,0,0.5)",result:"shadowColor"}),(0,H.jsx)("feComposite",{in:"shadowColor",in2:"offsetBlur",operator:"in",result:"shadow"}),(0,H.jsxs)("feMerge",{children:[(0,H.jsx)("feMergeNode",{in:"shadow"}),(0,H.jsx)("feMergeNode",{in:"SourceGraphic"})]})]}),(0,H.jsx)("clipPath",{id:"label-clip",children:(0,H.jsx)("rect",{x:0,y:0,width:2*Su,height:yu})}),(0,H.jsx)("clipPath",{id:"main-clip",children:(0,H.jsx)("rect",{x:Su,y:0,width:t,height:n})})]})}const Eu=function(e){const{x1:t,x2:n,selected:a,onClick:s,colorClass:r}=e;return(0,H.jsx)("rect",{className:(0,z.Z)("dark:focus-visible:outline-ondark-primary focus-visible:outline-onlight-primary outline-none focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2","animate-highlight dark:animate-dark-highlight",a?"dark:fill-ondark-primary fill-onlight-primary":r||"fill-status-gray cursor-pointer opacity-40 transition-opacity hover:opacity-70"),x:t,y:0,width:n-t,height:yu,pointerEvents:"bounding-box",rx:"3",tabIndex:a?-1:0,onClick:s})};function Au(e){const{sources:t,selected:n,map:a,onChangeSelected:s}=e,r=P();return(0,H.jsx)("g",{className:"timelines",children:t.map(((e,t)=>(0,H.jsx)("g",{className:"timeline",transform:`translate(0, ${(yu+ku)*t})`,children:e.events.map((t=>{const{timespan:[i,o]}=t,l=a(i),c=a(o),d=new Date(i).toLocaleTimeString(),u=new Date(o).toLocaleTimeString();return(0,H.jsxs)("g",{children:[(0,H.jsxs)("title",{children:[d," - ",u]}),(0,H.jsx)(Eu,{selected:n===t.id,x1:l,x2:c,onClick:(m=t.id,h=e.id,e=>{if(r&&(e.metaKey||e.ctrlKey)){const e=`/alarms/${m}`;window.open(e,"_blank","noopener,noreferrer")}else s(m,h)}),colorClass:t.colorClass})]},t.id);var m,h}))},e.id)))})}function _u(e){const{onLoadNearbyAlarms:t,isFetchingAlarms:n,containerWidth:a}=e;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("g",{onClick:()=>t&&t(-30),cursor:"pointer",children:[(0,H.jsx)("title",{children:"Load previous 30 seconds alarms"}),(0,H.jsx)("rect",{x:Su-30,y:ku/2-1,width:"24",height:"24",className:"fill-status-yellow",rx:"40",ry:"40"}),(0,H.jsx)("text",{x:Su-18,y:2+Nu.top/2,fontSize:"9",fill:"white",textAnchor:"middle",alignmentBaseline:"middle",children:"-30s"})]}),n&&(0,H.jsx)("foreignObject",{width:12,height:12,x:a/2,y:ku/2,children:(0,H.jsx)(W,{className:"dark:text-hakimo-yellow text-primary-700 h-3 w-3 animate-spin"})}),(0,H.jsxs)("g",{onClick:()=>t&&t(30),cursor:"pointer",children:[(0,H.jsx)("title",{children:"Load next 30 seconds alarms"}),(0,H.jsx)("rect",{x:a+4,y:ku/2-1,width:"25",height:"25",className:"fill-status-yellow",rx:"40",ry:"40"}),(0,H.jsx)("text",{x:a+16,y:2+Nu.top/2,fontSize:"9",fill:"white",textAnchor:"middle",alignmentBaseline:"middle",children:"+30s"})]})]})}function Iu(e){const{height:t,hasLeft:n,hasRight:a,visibleContentWidth:s,onShowLeft:r,onShowRight:i}=e;return n||a?(0,H.jsxs)("g",{transform:`translate(${Su+s/2},${t-24})`,className:"timeline-navigation dark:text-ondark-text-2 stroke-current",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,H.jsxs)("g",{transform:"translate(-24, 0)",onClick:r,className:(0,z.Z)("group",!n&&"pointer-events-none opacity-50"),children:[(0,H.jsx)("path",{d:"M15 18l-6-6 6-6",className:"group-hover:stroke-ondark-primary"}),(0,H.jsx)("rect",{x:"0",y:"0",width:"24",height:"24",opacity:"0",fill:"transparent"})]}),(0,H.jsxs)("g",{onClick:i,className:(0,z.Z)("group",!a&&"pointer-events-none opacity-50"),children:[(0,H.jsx)("path",{d:"M9 18l6-6-6-6",className:"group-hover:stroke-ondark-primary"}),(0,H.jsx)("rect",{x:"0",y:"0",width:"24",height:"24",opacity:"0",fill:"transparent"})]})]}):null}function Lu(e){const{sources:t,liveSourceId:n}=e,a=P();return(0,H.jsx)("g",{className:"sidebar",transform:`translate(0,${Nu.top})`,children:t.map(((e,t)=>{return(0,H.jsxs)("g",{className:"label",transform:`translate(0,${t*(yu+ku)})`,clipPath:"url(#label-clip)",onClick:(s=e.id,e=>{if(a&&(e.metaKey||e.ctrlKey)){const e=`/cameras/?camId=${s}`;window.open(e,"_blank","noopener,noreferrer")}}),children:[(0,H.jsx)("rect",{width:Su,height:yu,className:"dark:fill-ondark-bg-2 fill-onlight-bg-2",filter:"url(#right-shadow)"}),(0,H.jsxs)("text",{x:wu,y:yu/2,dominantBaseline:"central",className:"dark:fill-ondark-text-2 fill-onlight-text-2 text-xs",children:[e.name.length>20?e.name.slice(0,10)+"..."+e.name.slice(-10):e.name,(0,H.jsx)("title",{children:e.name})]}),e.id===n&&(0,H.jsx)("circle",{cx:Su-10,cy:yu/2,r:3,className:"fill-status-red"})]},e.id);var s}))})}const Ru=function(e){const{min:t,max:n,contentWidth:a}=e;return(0,H.jsxs)("g",{children:[(0,H.jsx)("text",{x:0,y:Nu.top/2,className:"dark:fill-ondark-text-2 fill-onlight-text-2 cursor-default text-xs",dominantBaseline:"central",children:(0,H.jsx)("tspan",{children:new Date(t).toLocaleTimeString()})}),(0,H.jsx)("text",{x:a,y:Nu.top/2,className:"dark:fill-ondark-text-2 fill-onlight-text-2 cursor-default text-xs",dominantBaseline:"central",textAnchor:"end",children:(0,H.jsx)("tspan",{children:new Date(n).toLocaleTimeString()})})]})};function Du(e){const{sources:t,width:n}=e;return(0,H.jsx)("g",{className:"tracks",transform:`translate(${Su},${Nu.top})`,children:t.map(((e,t)=>(0,H.jsx)("g",{className:"timeline",transform:`translate(0, ${(yu+ku)*t})`,children:(0,H.jsx)("rect",{x:"0",y:"0",width:n,height:yu,className:"dark:fill-ondark-bg-2 fill-onlight-bg-3 opacity-40"})},e.id)))})}const Pu=(e,t,n)=>{const a=[];let s=e;if(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n))return a;for(;s<=t;)a.push(s),s+=n;return a};function Mu(e){const t=Math.floor(e/3600),n=Math.floor((e-3600*t)/60),a=e-3600*t-60*n,s=[];return t>0&&s.push(`${t}h`),n>0&&s.push(`${n}m`),a>0&&s.push(`${a}s`),s.join(" ")}const Ou=function(e){let{positions:t}=e;const{height:n,interval:s}=e;return t=t.slice(1),(0,H.jsx)("g",{children:t.map(((e,t)=>(0,H.jsxs)(a.Fragment,{children:[(0,H.jsx)("line",{x1:e,x2:e,y1:Nu.top,y2:n-Nu.bottom,className:"stroke-black/10 dark:stroke-white/10",strokeDasharray:"2 2",strokeWidth:1}),(0,H.jsxs)("text",{x:e,y:n-Nu.bottom+wu,className:"dark:fill-ondark-text-2 fill-onlight-text-2 text-xs",dominantBaseline:"hanging",textAnchor:"middle",children:["+",Mu(s*(t+1))]})]},t)))})};function Fu(e){const{sources:t,selected:n,liveSourceId:s,onChangeSelected:r,onLoadNearbyAlarms:i,isFetchingAlarms:o,rawAlarmsInterval:{startTime:l,endTime:c},showExtraActions:d}=e,u=(0,a.useRef)(null),[m,h]=(0,a.useState)(1e3),[x,p]=(0,a.useState)(0),g=m-Su,f=t.length*yu+(t.length-1)*ku+Nu.top+Nu.bottom,v=c-l>3e4?30:5,j=1e3*v,b=Math.max(g,(c-l)/j*Cu),y=[-b+Su+g,Su],k=function(e,t){const n=(t[1]-t[0])/(e[1]-e[0]),a=t[0]-n*e[0];return function(e){return n*e+a}}([l,c],[0,b]),w=Pu(l,c,j).map(k);(0,a.useLayoutEffect)((()=>{const e=u.current;if(!e)return;let t=e.getBoundingClientRect();h(t.width-Nu.right),p(t.width-b-Nu.right);const n=new ResizeObserver((()=>{t=e.getBoundingClientRect(),h(t.width-Nu.right),p(t.width-b-Nu.right)}));return n.observe(e),()=>{n.disconnect()}}),[b]);return(0,H.jsx)("div",{ref:u,children:(0,H.jsxs)("svg",{width:"100%",height:f,children:[(0,H.jsx)(Tu,{visibleContentWidth:g,height:f}),(0,H.jsx)(Iu,{height:f,visibleContentWidth:g,hasLeft:x-Su<0,hasRight:x>m-b,onShowLeft:()=>{p(Math.min(x+g,y[1]))},onShowRight:()=>{p(Math.max(x-g,y[0]))}}),(0,H.jsx)(Du,{sources:t,width:g}),(0,H.jsx)("g",{className:"main",clipPath:"url(#main-clip)",children:(0,H.jsxs)("g",{className:"transition-transform",transform:`translate(${x},0)`,children:[(0,H.jsx)(Ru,{min:l,max:c,contentWidth:b}),(0,H.jsx)("g",{transform:`translate(0,${Nu.top})`,children:(0,H.jsx)(Au,{sources:t,selected:n,map:k,onChangeSelected:r})}),(0,H.jsx)(Ou,{positions:w,height:f,interval:v})]})}),d&&(0,H.jsx)("g",{className:"load-nearby-alarms",children:(0,H.jsx)(_u,{onLoadNearbyAlarms:i,isFetchingAlarms:o,containerWidth:m})}),(0,H.jsx)(Lu,{sources:t,liveSourceId:s})]})})}var Zu=n(83841),qu=n(61188);const Uu=function(e){const{viewMode:t,onCopyLink:n,onShare:a,onChangeViewMode:s}=e,r=[{dataTestId:"btn-share-location-alarm",name:"Copy link",onClick:n,icon:(0,H.jsx)(Zu.Z,{className:"h-4 w-4"})},{dataTestId:"btn-show-split-view",name:"Split view",onClick:()=>s("split"),group:"viewMode",icon:(0,H.jsx)(La,{className:"h-4 w-4 flex-shrink-0"})},{dataTestId:"btn-show-events-view",name:"Events view",onClick:()=>s("events"),group:"viewMode",icon:(0,H.jsx)(Da,{className:"h-4 w-4 flex-shrink-0"})},{dataTestId:"btn-show-live-view",name:"Live view",onClick:()=>s("live"),group:"viewMode",icon:(0,H.jsx)(Ra,{className:"h-4 w-4 flex-shrink-0"})}];if(Ge(j(),"location_alarm/details:share")){const e={dataTestId:"btn-public-share-location-alarm",name:"Share alarm",onClick:a,icon:(0,H.jsx)(qu.Z,{className:"h-4 w-4"})};r.splice(1,0,e)}const i=r.filter((e=>!e.dataTestId.includes(t))),o=(0,H.jsx)(qc.Z,{className:"h-5 w-5","data-testid":"menu-button"});return(0,H.jsx)("span",{className:"mr-1",children:(0,H.jsx)(Cs,{items:i,menuButton:o})})};const Vu=function(e){const{statusType:t,labelType:n,onChange:a}=e,s=Qe();return(0,H.jsxs)("div",{className:"flex items-center gap-4",children:[(0,H.jsx)(re,{type:n,children:t}),t!==De.RESOLVED&&s&&(0,H.jsx)(Q,{title:"Resolve",variant:"success",onClick:()=>a(De.RESOLVED),children:"Resolve"})]})};let $u=function(e){return e.PERSON="person",e.VEHICLE="vehicle",e.INCORRECT_DETECTION="incorrect detection",e}({});const zu={[$u.PERSON]:["Authorized Employee(s)/Cleaner(s)","Authorized Security Guard","Authorized Resident","Law Enforcement on site","Person Off-site","Deterred with Talkdown","Other"],[$u.VEHICLE]:["Employee Vehicle","Security Vehicle","Law Enforcement Vehicle","Delivery Truck","Vehicle Off-site","Deterred with Talkdown","Other"],[$u.INCORRECT_DETECTION]:["No Person","No Vehicle movement / Stationary Vehicle","Animal onsite","Other"]},Hu=e=>zu[e].map((e=>({id:String(e),name:e}))),Bu=e=>{switch(e){case $u.PERSON:return"Person Present";case $u.VEHICLE:return"Moving Vehicle";case $u.INCORRECT_DETECTION:return"False Positive";default:return""}};const Wu=function(e){const{detectionType:t,onSubmit:n,isSubmitInProgress:s}=e,[r,i]=(0,a.useState)({id:"blank",name:""}),[o,l]=(0,a.useState)(!1);return(0,H.jsxs)("div",{className:"flex flex-wrap items-center gap-6",children:[(0,H.jsx)(re,{small:!0,type:"info",children:t.toUpperCase()}),(0,H.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,H.jsx)("span",{children:"Comment:"}),(0,H.jsx)("div",{className:"flex gap-4",children:(0,H.jsx)("div",{className:"w-56 flex-1",children:o?(0,H.jsx)(ae,{label:"",onChange:e=>{i({id:e.target.value,name:e.target.value})},type:"text",value:(null==r?void 0:r.name)||"",placeholder:"Please specify",autoFocus:!0}):(0,H.jsx)(Ps,{value:r,items:Hu(t),displayValue:e=>{var t;return null!=(t=null==e?void 0:e.name)?t:""},onChange:e=>{"Other"===e.name?(l(!0),i({id:"blank",name:""})):i(e)},id:e=>(null==e?void 0:e.id)||""})})})]}),(0,H.jsx)(Q,{title:"Confirm",variant:"primary",loading:s,disabled:"blank"===r.id,onClick:()=>{var e;return n(null!=(e=null==r?void 0:r.name)?e:"")},onSideEffect:yt("add_status_update_comment"),children:"Confirm"})]})};const Gu=function({onSubmit:e}){const t=t=>()=>e(t);return(0,H.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,H.jsx)("span",{children:"What did you see?"}),(0,H.jsxs)("div",{className:"flex flex-wrap gap-4",children:[(0,H.jsx)(Q,{onClick:t($u.PERSON),title:"Person",variant:"outline",onSideEffect:yt("person_detected"),autoFocus:!0,children:"Person"}),(0,H.jsx)(Q,{onClick:t($u.VEHICLE),title:"Vehicle",onSideEffect:yt("vehicle_detected"),children:"Vehicle"}),(0,H.jsx)(Q,{onClick:t($u.INCORRECT_DETECTION),title:"Incorrect Detection",onSideEffect:yt("incorrect_detection"),children:"Incorrect Detection"})]})]})};const Ku=function(e){const{onSubmit:t,onClose:n,isSubmitInProgress:s,initialDetectionType:r}=e,i={step:r?1:0,comment:"",detectionType:r},[o,l]=(0,a.useState)(i);return(0,H.jsxs)("div",{className:"flex w-full items-center gap-8",children:[0===o.step&&(0,H.jsx)(Gu,{onSubmit:e=>{l(Object.assign({},o,{step:1,detectionType:e}))}}),o.step>0&&o.detectionType&&(0,H.jsx)(Wu,{detectionType:o.detectionType,onSubmit:e=>{const n=Bu(o.detectionType);t(`${n} - ${e}`)},isSubmitInProgress:s}),(0,H.jsx)("div",{className:"self-start",children:(0,H.jsx)(Q,{title:"Cancel",variant:"icon",onClick:n,onSideEffect:yt("cancel_status_stepper"),children:(0,H.jsx)(U.Z,{className:"h-5 w-5","aria-hidden":"true"})})})]})};const Yu=function(e){const{alarm:t,onStatusChange:n,onChangeEditStatus:s,isEdit:r}=e,[i,o]=(0,a.useState)(Zl(t.status)),l=Ol(i);(0,a.useEffect)((()=>{o(Zl(t.status))}),[t.status]);const c=Kt(t.id,(()=>{s(!1),Le("Alarm status updated",{type:"success"}),n&&n(i)}));return(0,H.jsx)("div",{className:"flex w-full items-center",children:r?(0,H.jsx)(Ku,{onSubmit:e=>{c.mutate({status:i,comment:e})},onClose:()=>{s(!1),o(Zl(t.status))},isSubmitInProgress:c.isLoading}):(0,H.jsx)(Vu,{statusType:i,labelType:l,onChange:e=>{o(e),s(!0)}})})};const Qu=function(e){const{locationAlarmId:t,locationIncident:n,onClose:s,onStatusChange:r}=e,[i,o]=(0,a.useState)(""),l=j(),c=Qe(),d=Kt(t,(()=>{r&&r(De.RESOLVED)})),u=Rn(),m=(0,H.jsxs)(H.Fragment,{children:[c&&(0,H.jsx)(Q,{title:"Resolve",variant:"primary",disabled:""===i,onClick:()=>{const e={incident_id:n.id,incident_end_time_utc:co()().utc().format("YYYY-MM-DDTHH:mm:ss"),resolved_by:l.id,resolution_comment:i};u.mutate(e);const t={status:De.RESOLVED,comment:`Escalation - ${i}`};d.mutate(t)},loading:d.isLoading||u.isLoading,onSideEffect:yt("close_and_resolve_active_location_incident"),children:"Resolve"}),(0,H.jsx)(Q,{onClick:s,children:"Cancel"})]});return(0,H.jsx)(ce,{title:"Resolve Incident",onClose:s,open:!0,closable:!0,footer:m,children:(0,H.jsxs)("div",{className:"space-y-4 p-8",children:[d.isError||u.isError&&(0,H.jsx)(B,{type:"error",children:"Error submitting and resolving the incident"}),(0,H.jsx)(B,{type:"info",children:"Alarm should only be resolved once site POC and PD are alerted about the incident."}),(0,H.jsx)("div",{children:"Provide a brief comment on the escalation"}),(0,H.jsx)(pe,{value:i,rows:4,placeholder:"Describe the incident and the actions taken",onChange:e=>o(e)})]})})};const Xu=function(e){const{incident:t,locationAlarmId:n,onStatusChange:s}=e,{title:r,description:i,incidentStartTimeUtc:o}=t,[l,c]=(0,a.useState)(!1),d=o?new Date(o).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"medium"}):"";return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{className:"grid grid-cols-12 rounded-md border border-red-200 bg-red-50 px-4 py-2 text-sm text-red-800 dark:border-red-500/50 dark:bg-red-700/50 dark:text-red-200",children:[(0,H.jsx)("div",{className:"col-span-1",children:(0,H.jsx)(Te.Z,{className:"h-10 w-10"})}),(0,H.jsxs)("div",{className:"col-span-9",children:[(0,H.jsxs)("div",{className:"flex gap-4",children:[(0,H.jsx)("span",{className:"font-bold",children:r}),(0,H.jsx)("span",{children:i})]}),(0,H.jsxs)("div",{className:"text-xs",children:["Reported at: ",d]})]}),(0,H.jsx)("div",{className:"col-span-2 text-end",children:(0,H.jsx)(Q,{onClick:()=>c(!0),variant:"error",children:"Reported to POC & PD"})})]}),l&&(0,H.jsx)(Qu,{locationAlarmId:n,locationIncident:t,onClose:()=>c(!1),onStatusChange:s})]})};const Ju=function(e){var t,n;const{alarm:s,viewMode:r,onChangeViewMode:i,onStatusChange:o,showResolveAction:l=!0}=e,[c,d]=(0,a.useState)(!1),[u,m]=(0,a.useState)(!1),h=s.locationIncidents?s.locationIncidents[0]:null;return(0,H.jsxs)(H.Fragment,{children:[h&&(0,H.jsx)(Xu,{incident:h,locationAlarmId:s.id,onStatusChange:o}),(0,H.jsxs)("div",{className:"flex h-12 flex-shrink-0 items-center justify-between",children:[(0,H.jsxs)("div",{className:"flex items-center gap-4 px-4",children:[!c&&(0,H.jsxs)("span",{className:"flex flex-shrink-0 flex-col",children:[(0,H.jsx)("span",{title:`#${s.id} - ${null==(t=s.location)?void 0:t.name}`,children:null==(n=s.location)?void 0:n.name}),(0,H.jsx)("span",{className:"dark:text-ondark-text-2 text-onlight-text-2 text-xs",children:s.location.description})]}),!c&&(0,H.jsx)("div",{className:"h-4 border-l border-black/20 dark:border-white/20"}),l?(0,H.jsx)(Yu,{isEdit:c,onChangeEditStatus:d,alarm:s,onStatusChange:o}):(0,H.jsx)(re,{type:Ol(Zl(s.status)),children:Zl(s.status)})]}),!c&&(0,H.jsx)(Uu,{onChangeViewMode:i,onCopyLink:async()=>{const e=`${window.location.origin}/location-alarms/${s.id}`;try{await navigator.clipboard.writeText(e),Le("Location alarm link copied to clipboard")}catch(t){y.uT("Error copying text to clipboard")}},onShare:()=>{m(!0)},viewMode:r}),u&&(0,H.jsx)(Bo,{resourceId:s.id,resourceType:"location-alarm",onClose:()=>m(!1)})]})]})};const em=function(e){const{location:t,initalCameraIds:n}=e,s=(0,a.useRef)(null),{isFullScreen:r,toggleFullScreen:i}=D(s);return(0,H.jsx)("div",{ref:s,className:"bg-onlight-bg-1 dark:bg-ondark-bg-1 overflow-auto",children:r?(0,H.jsx)(Go,{locationId:String(t.id),locationName:t.name,initialCameraIds:n,onClose:i}):(0,H.jsx)(Q,{variant:"icon",onClick:i,title:"Site Watch survilliance",children:(0,H.jsx)(Wa,{className:"h-6 w-6"})})})};const tm=function(e){const{alarms:t,locationAlarmId:n,selectedCameraId:s,onChangeSelectedCameraId:r,onTalkdown:i,location:o}=e,[l,c]=(0,a.useState)(!1),d=(0,a.useMemo)((()=>t.reduce(((e,t)=>{var n,a;e.find((e=>e.id===t.sourceEntity.id))||e.push({id:t.sourceEntity.id,name:null!=(n=t.sourceEntity.name)?n:t.sourceEntity.id,isAudioSupported:(null!=(a=t.sourceEntity.audio_devices)?a:[]).length>0,livestreamUrl:t.sourceEntity.livestreamUrl});return e}),[])),[t]),u=d.find((e=>e.id===s)),m=null==u?void 0:u.isAudioSupported;return(0,H.jsxs)("div",{className:"flex h-full flex-col space-y-3",children:[(0,H.jsxs)("div",{className:"relative flex h-9 items-center justify-between",children:[!l&&(0,H.jsxs)("div",{className:"flex items-center gap-2",children:[(0,H.jsxs)("h2",{className:"flex items-center gap-2",children:[(0,H.jsx)("span",{className:"bg-status-red h-1.5 w-1.5 animate-pulse rounded-full"}),(0,H.jsx)("span",{children:"Live"})]}),(0,H.jsx)(Ps,{items:d,value:u,displayValue:e=>(null==e?void 0:e.name)||"",onChange:e=>r(e.id)})]}),(0,H.jsxs)("div",{className:"flex gap-4",children:[(0,H.jsx)(em,{location:o,initalCameraIds:d.map((e=>e.id))}),m&&(0,H.jsx)("div",{className:"",children:(0,H.jsx)(Br,{locAlarmId:n,cameraId:s,onTalkdown:i,onToggle:c,cameraName:(null==u?void 0:u.name)||""})})]})]}),u&&(0,H.jsx)(Mi,{camera:u})]})};function nm(e){const{locationId:t,locationAlarmId:n,locationTenantId:a}=e,s=Fn(t);return(0,H.jsxs)("div",{className:"min-h-[15rem] space-y-1",children:[(0,H.jsx)("h2",{className:"flex h-9 items-center",children:"Location Contacts"}),(0,H.jsx)(Is,{queryResult:s,children:e=>{const t=e.sort(((e,t)=>t.priority-e.priority));return(0,H.jsx)("div",{className:"dark:divide-ondark-line-2 dark:bg-ondark-bg-2 bg-onlight-bg-2 divide-onlight-line-2 divide-y p-4",children:t.map((e=>(0,H.jsx)(wc,{toNumber:e.phoneNumber,toName:e.name,locationAlarmId:n,locationTenantId:a},e.id)))})}})]})}const am=function(e){const{locationId:t}=e,n=(0,a.useRef)(null),s=On(t),{isFullScreen:r,toggleFullScreen:i}=D(n);return(0,H.jsxs)("div",{className:"group min-h-[15rem] space-y-1",children:[(0,H.jsx)("h2",{className:"flex h-9 items-center",children:"Location Floorplan"}),(0,H.jsx)("div",{ref:n,className:"relative",children:(0,H.jsx)(Is,{queryResult:s,children:e=>(0,H.jsxs)(H.Fragment,{children:[e.floor_plan&&(0,H.jsx)("div",{className:"invisible absolute top-1 right-1 group-hover:visible",children:(0,H.jsx)(Q,{variant:"icon",onClick:i,classNames:"dark:bg-ondark-bg-3 bg-onlight-text-3 enabled:hover:bg-onlight-text-2/90 dark:enabled:hover:bg-ondark-bg-2 focus:ring-offset-0",children:r?(0,H.jsx)(Oa,{className:"fill-dark-text h-7 w-7"}):(0,H.jsx)(Ma,{className:"fill-dark-text h-7 w-7"})})}),e.floor_plan?(0,H.jsx)("div",{className:"flex h-full justify-center bg-gray-200 dark:bg-gray-900",children:(0,H.jsx)("img",{src:e.floor_plan,alt:"Floorplan",className:(0,z.Z)(r?"max-h-[100vh]":"max-h-[48rem]")})}):(0,H.jsx)("div",{className:"p-6",children:(0,H.jsx)(B,{children:"Floorplan not available"})})]})})})]})};const sm=function(e){const{locationId:t}=e,[n,s]=(0,a.useState)(),r=qt({locationId:t},(async({sop_text:e,sop_workflow:t,id:n})=>{const a=await T();s({id:n,overviewData:a(e),workflowData:t})}));let i=null==n?void 0:n.workflowData;var o,l,c;return i&&(i=Object.assign({},i,{notes:null!=(o=i.notes)?o:[],escalationProtocol:null!=(l=i.escalationProtocol)?l:[],quickResolveActions:null!=(c=i.quickResolveActions)?c:[]})),(0,H.jsxs)("div",{children:[(0,H.jsx)("h2",{className:"flex h-9 items-center",children:"Standard Operating Procedure"}),(0,H.jsx)(Is,{queryResult:r,loadingText:"",children:()=>{var e;return i?(0,H.jsx)("div",{className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 overflow-hidden",children:(0,H.jsx)(ol,{showTitle:!1,sopId:(null==n?void 0:n.id)||"",sopWorkflow:i})}):(0,H.jsx)("ul",{className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 mt-1 space-y-4 p-3",children:(0,H.jsx)("div",{className:"whitespace-pre-wrap text-sm",dangerouslySetInnerHTML:{__html:null!=(e=null==n?void 0:n.overviewData)?e:""}})})}})]})};function rm(e,t){if(!t.sourceEntity)return e;const n=e.get(t.sourceEntity.id)||function(e){var t,n,a,s;return{id:(null==e||null==(t=e.sourceEntity)?void 0:t.id)||"",name:null!=(n=null==e||null==(a=e.sourceEntity)?void 0:a.name)?n:(null==e||null==(s=e.sourceEntity)?void 0:s.id)||"",events:[]}}(t);return e.set(t.sourceEntity.id,function(e,t){if(t.videoStartTime&&t.videoEndTime){let n="fill-orange-300 hover:fill-orange-400";t.status&&"pending"!==t.status.toLowerCase()&&(n="fill-green-300 hover:fill-green-400"),e.events.push({id:t.id,timespan:[new Date(t.videoStartTime).getTime(),new Date(t.videoEndTime).getTime()],status:t.status||"",colorClass:n})}return e}(n,t)),e}function im(e){var t;const{alarm:n,onStatusChange:s,sharedToken:r,showSOP:i=!0,showContacts:o=!0,showResolveAction:l=!0}=e,c=(0,a.useMemo)((()=>n.rawAlarms.sort(((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()))),[n]),{onTrackResolve:d,onTrackTalkdown:u}=function(e){const t=(0,a.useRef)((new Date).getTime()),n=(0,a.useCallback)((t=>t[e]),[e]),s=(0,ur.Dv)((0,pt.kv)(au,n));return(0,a.useEffect)((()=>{void 0!==s&&kt("view_location_alarm_details",{alarm_id:e,time_to_view:t.current-s})}),[e,s,t]),{onTrackResolve:function(){kt("resolve_location_alarm",{alarm_id:e,time_to_resolve:(new Date).getTime()-t.current})},onTrackTalkdown:function(n){kt("submit_location_alarm_audio_recording",{camera_id:n,alarm_id:e,time_to_talkdown:(new Date).getTime()-t.current})}}}(n.id),m=c[n.rawAlarms.length-1],[h,x]=(0,a.useState)({sourceId:m.sourceEntity.id,eventId:m.id}),[p,g]=(0,a.useState)(m.sourceEntity.id),[f,v]=(0,a.useState)([]),[j,b]=(0,ur.KO)(tu),y=!!r,{data:k}=_t({id:h.eventId,boxes:!0,sharedToken:r,isSharedLocationAlarm:y}),w=(N=c,(0,a.useMemo)((()=>Array.from(N.reduce(rm,new Map).values())),[N]));var N;const[C,S]=function(e){const t=e.reduce(((e,t)=>[...e,...xu(t.events.map((e=>e.timespan)))]),[]);return[Math.min(...t),Math.max(...t)]}(w),T=w.map((e=>e.id)),E=String(null==(t=n.location)?void 0:t.id)||"",[A,_]=(0,a.useState)({startTime:C,endTime:S}),I=(0,a.useMemo)((()=>A.startTime!==C||A.endTime!==S),[C,S,A.endTime,A.startTime]);(0,a.useEffect)((()=>{A.endTime<S&&_((e=>Object.assign({},e,{endTime:S})))}),[S,A.endTime]);const L=vu(T,A.startTime,A.endTime,E,I?["Resolved by Hakimo","Pending"]:["Resolved by Hakimo"]),{data:R,isFetching:D}=Lt(L);(0,a.useEffect)((()=>{const e=(null==R?void 0:R.items)||[];let t=[];if(t=y?[...n.rawAlarms]:I?e:[...n.rawAlarms,...e],t){const e=[...t].sort(((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime())),n=Array.from(e.reduce(rm,new Map).values());v(n)}}),[n.rawAlarms,null==R?void 0:R.items,y,I]);const P=(0,a.useCallback)((()=>{const e=f.find((e=>h.sourceId===e.id)),t=null==e?void 0:e.events.filter((e=>"pending"===e.status.toLowerCase())),n=null==t?void 0:t.findIndex((e=>e.id===h.eventId));if(t&&void 0!==n&&e)if(n<(null==t?void 0:t.length)-1){const a=t[n+1];x({eventId:a.id,sourceId:null==e?void 0:e.id})}else{const e=f.findIndex((e=>h.sourceId===e.id));e<f.length-1&&x({sourceId:f[e+1].id,eventId:f[e+1].events[0].id})}}),[f,h.eventId,h.sourceId]),M=(0,a.useMemo)((()=>{var e,t;return!y&&(null!=(e=null==R||null==(t=R.items)?void 0:t.length)?e:0)>0}),[y,null==R?void 0:R.items]);return(0,H.jsxs)("div",{className:"sticky top-0 flex h-full w-full flex-col divide-y dark:divide-white/10",children:[!y&&(0,H.jsx)(Ju,{alarm:n,viewMode:j,onChangeViewMode:b,onStatusChange:e=>{d(),s&&s(e)},showResolveAction:l}),(0,H.jsx)("div",{className:"space-y-4 pt-4 pl-4 pb-4",children:(0,H.jsxs)("div",{className:(0,z.Z)("flex flex-col gap-4","split"===j&&!y&&"xl:grid xl:grid-cols-2"),children:[(0,H.jsxs)("div",{className:"order-0 flex-1 space-y-3 xl:order-none",hidden:"live"===j&&!y,children:[(0,H.jsx)(su,{beginTime:C,endTime:S}),(0,H.jsx)(bu,{videoPath:null==k?void 0:k.videoPath,boxes:null==k?void 0:k.boxes,onNext:P,onPrevious:()=>{const e=f.find((e=>h.sourceId===e.id)),t=null==e?void 0:e.events.filter((e=>"pending"===e.status.toLowerCase())),n=null==t?void 0:t.findIndex((e=>e.id===h.eventId));if(t&&void 0!==n&&e)if(n>0){const a=t[n-1];x({eventId:a.id,sourceId:null==e?void 0:e.id})}else{const e=f.findIndex((e=>h.sourceId===e.id));e>0&&x({sourceId:f[e-1].id,eventId:f[e-1].events[0].id})}},hasPrevious:c.findIndex((e=>e.id===h.eventId))>0,hasNext:c.findIndex((e=>e.id===h.eventId))<c.length-1})]}),!y&&(0,H.jsx)("div",{className:"order-2 flex-1 space-y-4 xl:order-none",hidden:"events"===j,children:p&&(0,H.jsx)(tm,{alarms:c,locationAlarmId:n.id,selectedCameraId:p,onChangeSelectedCameraId:g,onTalkdown:u,location:n.location})}),(0,H.jsx)("div",{className:"order-1 col-span-2 xl:order-none",hidden:"live"===j&&!y,children:f.length>0?(0,H.jsx)(Fu,{sources:f,selected:h.eventId,liveSourceId:p,isFetchingAlarms:D,onChangeSelected:(e,t)=>x({eventId:e,sourceId:t}),onLoadNearbyAlarms:e=>{const t=e<0?"startTime":"endTime",n=new Date(A[t]);n.setSeconds(n.getSeconds()+e);const a=n.getTime();_((e=>Object.assign({},e,{[t]:a})))},rawAlarmsInterval:A,showExtraActions:M}):(0,H.jsx)("div",{className:"flex justify-center",children:(0,H.jsx)(K,{})})}),!y&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"order-3 xl:order-none",children:(0,H.jsx)(am,{locationId:String(n.location.id)})}),i&&(0,H.jsx)("div",{className:"order-4 xl:order-none",children:(0,H.jsx)(sm,{locationId:String(n.location.id)})}),o&&(0,H.jsx)("div",{className:"order-5 xl:order-none",children:(0,H.jsx)(nm,{locationId:n.location.id,locationAlarmId:n.id,locationTenantId:n.location.tenant_id})}),(0,H.jsx)("div",{className:"order-6 xl:order-none",children:(0,H.jsx)(uu,{locationAlarmId:n.id})})]})]})})]})}const om=(0,a.memo)(nt(im,["location_alarm/detail:view"]),fu),lm=(0,a.memo)(im,fu);var cm=n(76665);const dm=function(e){var t,n;const{alarm:s,selected:r,onClick:i}=e;!function(e){const t=(0,ur.b9)(au);(0,a.useEffect)((()=>(t((t=>Object.assign({},t,{[e]:(new Date).getTime()}))),()=>{t((t=>(0,cm.ZP)(t,(t=>{delete t[e]}))))})),[e,t])}(s.id);const o=s.tap?Dl[Math.min(Math.floor(s.tap/10),9)]:null;return(0,H.jsx)("button",{onClick:i,className:(0,z.Z)("dark:bg-ondark-bg-2 bg-onlight-bg-2 hover:bg-onlight-bg-3 dark:hover:bg-ondark-bg-3 relative w-full cursor-pointer items-center outline-none",r&&"dark:outline-ondark-primary outline-onlight-primary outline outline-offset-2","animate-highlight dark:animate-dark-highlight"),children:(0,H.jsxs)("div",{className:"flex items-stretch",children:[(0,H.jsx)("div",{className:"font-oswald flex w-16 flex-shrink-0 items-center justify-center text-center text-3xl font-light text-white",style:{backgroundColor:o||"inherit"},children:o?(0,H.jsx)("span",{children:s.tap}):(0,H.jsx)("span",{className:"inline-block h-5 w-5 flex-shrink-0",children:(0,H.jsx)(Ia,{})})}),(0,H.jsxs)("div",{className:"flex flex-1 flex-col gap-2 truncate px-4 py-3",children:[(0,H.jsxs)("span",{className:"text-onlight-text-1 dark:text-ondark-text-1 flex items-center justify-between truncate text-sm font-medium",title:null==(t=s.location)?void 0:t.name,children:[null==(n=s.location)?void 0:n.name,(0,H.jsx)(re,{small:!0,children:s.rawAlarms.length})]}),(0,H.jsxs)("span",{className:"flex items-center justify-between",children:[(0,H.jsxs)("span",{className:"dark:text-ondark-text-2 text-onlight-text-2 flex items-center gap-2 text-left text-sm",children:[(0,H.jsx)("span",{className:"font-medium",children:new Date(s.alarmTime).toLocaleTimeString()}),(0,H.jsx)("span",{className:"opacity-70",children:new Date(s.alarmTime).toLocaleDateString()})]}),(0,H.jsx)(zl,{status:s.status,small:!0})]})]})]})})};const um=nt((function(){const[e,t]=(0,ur.KO)(Jd),n=(0,ur.Dv)(eu),[s,r]=(0,ur.KO)(Qd),[i,o]=(0,a.useState)(!1),[l,c]=(0,a.useState)(0),[d,u]=(0,a.useState)(),[m,h]=(0,ur.KO)(nu),x=function(e,t){return(0,a.useMemo)((()=>Object.assign({time:{period:t,customRangeStart:"",customRangeEnd:""}},e)),[e,t])}(m,s),p=(0,a.useRef)(),g=(0,ur.Dv)(vt),f=(0,ur.Dv)(Xd),v=(0,a.useRef)(null),[j,b]=(0,a.useState)([]),y=Qt(),k=(0,ur.Dv)(jt),w=e=>{u(e?e.id:void 0),e&&e.id!==d&&y.mutate({alarmId:e.id})},{data:N}=xa();(0,a.useEffect)((()=>{void 0===m.camera&&h(Yd)}));const{error:C,isFetching:S}=Mt(Td(e,n,x),Ml,(t=>{var n;if(c(t.total),b(t.items),Ul(null==(n=p.current)?void 0:n.items,t.items,e,"locationAlarm",g,k,N),p.current=t,d){t.items.some((e=>e.id===d))||(Le("Selected alarm may have moved to next page or is not available any more. Selecting the latest alarm"),E(t.items))}else E(t.items)}),!1,!0),T=(0,a.useCallback)((e=>{"Resolved"===e&&f&&u(void 0)}),[f]),E=e=>{var t;e.length>0&&w(e[0]),v&&(null==(t=v.current)||t.scrollTo(0,0))},A=j.find((e=>e.id===d));return(0,H.jsx)(mr,{title:"Location Alarms",fullWidth:!0,children:C?(0,H.jsx)(B,{type:"error",children:" Error getting location alarms "}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(zs,{children:[(0,H.jsx)($s,{children:(0,H.jsxs)("div",{className:"flex max-h-full w-[24rem] flex-col divide-y dark:divide-white/10",children:[(0,H.jsx)(Gd,{period:s,onChangePeriod:r,onClickOpenFilterPanel:()=>o(!0),filterValues:m,isLoading:S}),(0,H.jsx)("div",{ref:v,className:"overflow-auto scroll-smooth py-4 pr-4 pb-4 pl-1",children:(0,H.jsx)(Ri,{items:j,total:l,page:e,pageSize:n,onChangePage:e=>{t(e),w(void 0)},renderListItem:e=>(0,H.jsx)(dm,{alarm:e,selected:e.id===d,onClick:()=>w(e)})})})]})}),(0,H.jsx)($s,{children:(0,H.jsx)("div",{children:A&&(0,H.jsx)(om,{alarm:A,onStatusChange:T},d)})})]}),(0,H.jsx)(wd,{title:"Location Alarm Filters",open:i,filterConfigs:Kd,initialFilterValues:m,trackingEventNameApply:"apply_location_alarms_filters",trackingEventNameReset:"reset_location_alarms_filters",onClose:()=>o(!1),onApply:e=>{h(e),wt(e),t(1),o(!1)}})]})})}),["location_alarm:view"]);function mm(e){const{locationAlarmId:t}=e,n=Wt(t);return(0,H.jsx)(Is,{queryResult:n,children:e=>(0,H.jsx)(im,{alarm:e})})}const hm=nt(ht((function(){const{locationAlarmId:e}=(0,r.UO)();return void 0===e?(0,H.jsx)(As,{}):(0,H.jsx)("div",{className:"m-8",children:(0,H.jsx)(mm,{locationAlarmId:e})})})),["location_alarm/detail:view"]);const xm=function(){return(0,H.jsxs)(r.Z5,{children:[(0,H.jsx)(r.AW,{path:"/",element:(0,H.jsx)(um,{})}),(0,H.jsx)(r.AW,{path:":locationAlarmId",element:(0,H.jsx)(hm,{})})]})};function pm(){return(0,H.jsx)(xm,{})}function gm(e){const{sharedToken:t}=e,n=Ht(t);return(0,H.jsx)(Is,{queryResult:n,children:e=>(0,H.jsx)("div",{className:"container mx-auto",children:(0,H.jsx)(lm,{alarm:e,sharedToken:t})})})}function fm(){const[e]=(0,Ss.lr)(),t=e.get("sharedToken");return null===t?(0,H.jsx)(As,{message:"Missing shared token in shared location alarm URL"}):(0,H.jsx)(gm,{sharedToken:t})}function vm(e){const{onClose:t,isQuickResolve:n,onSubmitResolveAction:a,isLoading:s}=e;return(0,H.jsxs)("div",{className:"divide-onlight-line-3 dark:divide-ondark-line-3 space-y-6 divide-y",children:[(0,H.jsx)("span",{children:"Resolve the alarm"}),(0,H.jsx)("div",{className:"pt-5",children:(0,H.jsx)(Ku,{onClose:t,onSubmit:a,isSubmitInProgress:s,initialDetectionType:n?$u.INCORRECT_DETECTION:void 0})})]})}function jm(e){const{sopItem:t,locationAlarmId:n,stepNumber:a}=e;return(0,H.jsxs)("div",{className:"flex items-center justify-around gap-2 pt-5",children:[(0,H.jsx)(Q,{onClick:()=>{kt("sop_workflow_step_action_yes",{locationAlarmId:n,stepNumber:a,stepTitle:t.title,stepType:t.type}),t.yesCallback()},variant:"outline",children:"Yes"}),(0,H.jsx)(Q,{onClick:()=>{kt("sop_workflow_step_action_no",{locationAlarmId:n,stepNumber:a,stepTitle:t.title,stepType:t.type}),t.noCallback()},variant:"outline",children:"No"})]})}let bm=function(e){return e.PRE_ESCALATE="pre_escalation",e.ESCALATION="escalation",e}({}),ym=function(e){return e.ESCALATE="escalate_alarm",e.RESOLVE="resolve_alarm",e.STEPS="workflow_steps",e}({}),km=function(e){return e.QUESTION="question",e.STATIC_TALKDOWN="staticTalkdown",e.DYANMIC_TALKDOWN="dynamicTalkdown",e}({});const wm=(0,xt.cn)(0),Nm=(0,xt.cn)(!0),Cm=(e,t,n,a,s,r,i)=>{var o,l;const c=[{type:km.QUESTION,title:"Do you see any person or moving vehicle?",yesCallback:e,noCallback:()=>t(!0)},{type:km.QUESTION,title:n.exceptions.length>0?`Review the exceptions${(null==n||null==(o=n.notes)?void 0:o.length)>0?" and notes":""} above. Does the activity pose a security threat?`:"Did the person or vehicle appear to pose a security threat?",exceptions:n.exceptions.length>0&&a,notes:(null==n||null==(l=n.notes)?void 0:l.length)>0&&s,yesCallback:e,noCallback:t}],d=[];n.isTalkdownEnabled&&i&&(n.firstTalkdown&&d.push({type:km.STATIC_TALKDOWN,title:"Did the person or vehicle move away from the premises?",talkdownText:n.firstTalkdown.text,yesCallback:t,noCallback:e}),n.secondTalkdown&&d.push({type:km.DYANMIC_TALKDOWN,title:"Did they move away from the premises?",talkdownText:n.secondTalkdown.text,yesCallback:t,noCallback:e}),c.splice(2,0,...d),c[c.length-1].noCallback=r);const u=c[c.length-1];return u.type===km.QUESTION&&(u.yesCallback=r),c};let Sm=function(e){return e.SOP_WORKFLOW="sopWorkflow",e.SOP_TEXT="sop_text",e}({});Sm.SOP_WORKFLOW,Sm.SOP_TEXT;function Tm(e){const{sopItem:t,performTalkdown:n,cameraId:a,logTalkdown:s,cameraName:r,isTalkdownInProcess:i}=e,o=t.type===km.QUESTION?t.exceptions?"Exceptions":"":"Perform the talkdown";return(0,H.jsxs)("div",{className:"py-2",children:[(0,H.jsx)("div",{className:"text-primary-800 dark:text-primary-400 my-2",children:o}),t.type===km.QUESTION&&(0,H.jsxs)("div",{children:[(0,H.jsx)("div",{children:t.exceptions&&(0,H.jsx)("div",{className:"text-onlight-text-2 dark:text-ondark-text-2 my-2 space-y-1 text-sm italic",children:t.exceptions})}),(0,H.jsx)("div",{children:t.notes&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"text-primary-800 dark:text-primary-400 my-2",children:"Notes"}),(0,H.jsx)("div",{className:"text-onlight-text-2 dark:text-ondark-text-2 my-2 space-y-1 text-sm italic",children:t.notes})]})})]}),t.type===km.STATIC_TALKDOWN&&(0,H.jsx)("div",{className:"text-sm italic",children:(0,H.jsx)(Wr,{text:t.talkdownText||"",performTalkdown:n,isLoading:i})}),t.type===km.DYANMIC_TALKDOWN&&(0,H.jsxs)("div",{className:"flex flex-wrap items-center justify-around gap-2 text-sm",children:[(0,H.jsx)("div",{className:"text-primary-800 dark:text-primary-400 my-2",children:"Assess identification details such as clothes color and perform the talkdown."}),(0,H.jsx)("span",{className:"italic",children:t.talkdownText||""}),(0,H.jsx)(Br,{cameraId:a,cameraName:r,onTalkdown:s})]})]})}const Em=function(e){const{totalSteps:t,currentStep:n,isTimerRunning:a,onStepChange:s}=e,r=new Array(t).fill(null);return(0,H.jsxs)("div",{className:"space-y-8",children:[(0,H.jsx)("nav",{className:"flex items-center justify-center","aria-label":"Progress",children:(0,H.jsx)("ol",{className:"flex items-center space-x-5",children:r.map(((e,t)=>{return(0,H.jsx)("li",{className:(0,z.Z)(t===n&&"relative"),children:t===n?(0,H.jsxs)("span",{className:"relative flex items-center justify-center","aria-current":"step",children:[(0,H.jsx)("span",{className:"absolute flex h-5 w-5 p-px","aria-hidden":"true",children:(0,H.jsx)("span",{className:"h-full w-full rounded-full bg-indigo-200 dark:bg-indigo-400"})}),(0,H.jsx)("span",{className:"bg-primary-500 dark:bg-primary-600 relative block h-2.5 w-2.5 rounded-full","aria-hidden":"true"})]}):(0,H.jsx)("span",{onClick:t<=n?(a=t,()=>s(a)):void 0,className:(0,z.Z)("block h-2.5 w-2.5 rounded-full",t>n&&"bg-onlight-text-3 dark:bg-ondark-text-2 dark:hover:bg-ondark-text-3 hover:bg-onlight-text-2",t<=n&&"bg-primary-500 dark:bg-primary-600 dark:hover:bg-primary-800 hover:bg-primary-700")})},t);var a}))})}),a&&(0,H.jsx)("div",{className:"absolute -top-16 -left-4",children:(0,H.jsx)(fe,{isRunning:a})})]})};function Am(e){const{navigateToEscalate:t,navigateToResolve:n,sopWorkflow:s,alarmCameras:r,locationAlarmId:i,onQuickResolve:o,isResolveSubmitting:l}=e,[c,d]=(0,ur.KO)(wm),[u,m]=(0,a.useState)(!1),[h,x]=(0,a.useState)(!1),p=(0,a.useMemo)((()=>function(e){const t=e.filter((e=>e.isTalkdownEnabled));return t.length>0?t[0]:null}(r)),[r]),g=s.exceptions.map(((e,t)=>(0,H.jsx)("li",{children:e},t))),f=((null==s?void 0:s.notes)||[]).map(((e,t)=>(0,H.jsx)("li",{children:e},t))),v=(0,a.useCallback)((e=>{kt("submit_camera_details_audio_talkdown",{camera_id:e,locationAlarmId:i}),x(!0)}),[i]),j=Ut(p?p.id:null,void 0,i,(()=>{v(p?p.id:""),Le("Audio sent to camera successfully")})),b=(0,a.useCallback)((e=>{const t=new FormData;t.append("audio",e||""),j.mutate(t),v(p?p.id:"")}),[p,v,j]),y=Cm((()=>{0===c&&m(!0),d((e=>e+1)),x(!1)}),n,s,g,f,(()=>{kt("sop_workflow_escalate_location_alarm_step_count",{locationAlarmId:i,escalated_after_step_count:c}),t()}),null!==p),k=y[c],w=k.exceptions||k.talkdownText,N=k.type===km.QUESTION||h,C=e=>()=>o(e);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{className:"divide-onlight-line-3 dark:divide-ondark-line-3 relative space-y-6 divide-y",children:[(0,H.jsx)(Em,{totalSteps:y.length,currentStep:c,isTimerRunning:u,onStepChange:e=>{d(e),x(!1)}}),w&&(0,H.jsx)(Tm,{sopItem:k,cameraId:(null==p?void 0:p.id)||"",cameraName:(null==p?void 0:p.name)||"",logTalkdown:v,performTalkdown:b,isTalkdownInProcess:j.isLoading}),N&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"pt-4 font-bold",children:k.title}),(0,H.jsx)(jm,{sopItem:k,locationAlarmId:i,stepNumber:c})]})]}),(null==s?void 0:s.quickResolveActions)&&s.quickResolveActions.length>0&&1===c&&(0,H.jsx)("div",{className:"mt-auto grid grid-cols-2 items-center gap-2",children:s.quickResolveActions.map(((e,t)=>(0,H.jsx)(Q,{onClick:C(e),disabled:l,children:e},t)))})]})}var _m=n(81152);const Im=function(e){const{siteAddress:t,escalationPoints:n,escalationProtocol:a,siteGoogleMapLocation:s,locationId:r,locationAlarmId:i,locationTenantId:o}=e;return(0,H.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,H.jsx)("h2",{className:"text-center font-bold text-red-700/80 dark:text-red-400/80",children:"Escalate now to concerned authorities"}),(0,H.jsxs)("div",{className:"flex gap-2",children:[(0,H.jsx)("span",{className:"font-bold",children:"Site address:"}),(0,H.jsx)("span",{children:t})]}),(0,H.jsxs)("div",{className:"flex items-center gap-2",children:[(0,H.jsx)("span",{className:"font-bold",children:"Google map:"}),(0,H.jsx)(Q,{variant:"icon",onClick:()=>{window.open(s,"_blank","noopener,noreferrer")},children:(0,H.jsx)(_m.Z,{className:"h-5 w-5"})})]}),a.length>0&&(0,H.jsxs)("div",{className:"space-y-2",children:[(0,H.jsx)("div",{className:"font-bold",children:"Escalation Protocol:"}),(0,H.jsx)("ol",{className:"list-decimal space-y-1 text-sm",children:a.map(((e,t)=>(0,H.jsx)("li",{children:e},t)))})]}),(0,H.jsxs)("div",{className:"space-y-2",children:[(0,H.jsx)("div",{className:"font-bold",children:"Mention below necessary details on the call:"}),(0,H.jsx)("ol",{className:"list-decimal space-y-1 text-sm",children:n.map(((e,t)=>(0,H.jsx)("li",{children:e},t)))})]}),(0,H.jsx)("div",{className:"border-onlight-line-3 dark:border-ondark-line-3 mt-4 border-t pt-2",children:(0,H.jsx)(nm,{locationId:+r,locationAlarmId:i,locationTenantId:o})})]})};const Lm=function(e){const{locationId:t,locationAlarmId:n,navToEscalation:s,onCancel:r}=e,[i,o]=(0,a.useState)(""),l=On(t).data,c=j(),d=Ln((()=>{Le(`Alarm is being escalated at ${null==l?void 0:l.name}`,{type:"success"})}));return(0,H.jsxs)("div",{className:"divide-onlight-line-3 dark:divide-ondark-line-3 space-y-6 divide-y",children:[(0,H.jsx)("div",{className:"pt-4 font-bold",children:"This is being escalated. Please provide a brief update on the current situation."}),(0,H.jsx)("div",{className:"pt-6",children:(0,H.jsx)(pe,{onChange:e=>o(e),value:i,rows:4,placeholder:"Even a 10 word insight would do the work. (Optional)"})}),(0,H.jsxs)("div",{className:"space-x-4 pt-6 text-center",children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{const e={location_id:+t,location_alarm_id:n,tenant_id:null==l?void 0:l.tenant_id,title:`Escalation alert: Ongoing incident at ${null==l?void 0:l.name}`,created_by:c.id,description:i,incident_start_time_utc:co()().utc().format("YYYY-MM-DDTHH:mm:ss")};d.mutate(e),s()},onSideEffect:yt("create_location_incident"),children:"Proceed"}),(0,H.jsx)(Q,{variant:"outline",onClick:r,children:"Cancel"})]})]})};function Rm(e){const{siteAddress:t,escalationPoints:n,escalationProtocol:s,locationId:r,siteGoogleMapLocation:i,locationAlarmId:o,isEscalated:l,locationTenantId:c,onCancel:d}=e,[u,m]=(0,a.useState)(l?bm.ESCALATION:bm.PRE_ESCALATE);return(0,H.jsxs)(H.Fragment,{children:[u===bm.PRE_ESCALATE&&(0,H.jsx)(Lm,{locationId:r,locationAlarmId:o,navToEscalation:(h=bm.ESCALATION,()=>m(h)),onCancel:d}),u===bm.ESCALATION&&(0,H.jsx)(Im,{locationId:r,locationAlarmId:o,siteAddress:t,escalationPoints:n,escalationProtocol:s,siteGoogleMapLocation:i,locationTenantId:c})]});var h}function Dm(e){var t;const{locationId:n,locationAlarmId:s,alarmCameras:r,onAlarmResolve:i,locationAlarmIncident:o,locationAlarmStatus:l,locationTenantId:c}=e,[d,u]=(0,a.useState)(),[m,h]=(0,a.useState)(!1),x=Kt(s,(()=>{Le("Alarm status updated",{type:"success"}),i(De.RESOLVED)})),p=e=>{x.mutate({status:De.RESOLVED,comment:e})},{isLoading:g,isRefetching:f,isError:v,error:j}=qt({locationId:n},(async({sop_workflow:e})=>{u(e)})),b=o&&o.initiatingLocationAlarmId===s,[y,k]=(0,a.useState)(b?ym.ESCALATE:ym.STEPS),w=(0,ur.b9)(wm);(0,a.useEffect)((()=>{w(0)}),[w,s]),(0,a.useEffect)((()=>{"Resolved"===l&&k(void 0)}),[l]);const N=e=>()=>{k(e)};return(0,H.jsxs)("div",{className:"relative mt-4 min-h-[40rem] p-5",children:[(v||void 0===d)&&(0,H.jsxs)("div",{className:"mx-auto max-w-screen-2xl p-6",children:[(null==j?void 0:j.message)&&(0,H.jsx)(B,{type:"error",children:null!=(t=j.message)?t:""}),!(g||f)&&(0,H.jsx)("span",{children:"Please ask your admin to update the SOP."})]}),(g||f)&&(0,H.jsx)("div",{className:"absolute -top-6 left-[40%] flex justify-center p-2",children:(0,H.jsx)(K,{})}),d&&(0,H.jsxs)("div",{className:(0,z.Z)(y===ym.STEPS&&"flex min-h-[35rem] flex-col items-center justify-between gap-8"),children:["Resolved"===l&&(0,H.jsx)("div",{children:"This location alarm is already resolved"}),y===ym.STEPS&&r.length>0&&(0,H.jsx)(Am,{navigateToEscalate:N(ym.ESCALATE),navigateToResolve:e=>{N(ym.RESOLVE)(),h(!0===e)},sopWorkflow:d,alarmCameras:r,locationAlarmId:s,locationId:n,onQuickResolve:p,isResolveSubmitting:x.isLoading}),y===ym.RESOLVE&&(0,H.jsx)(vm,{onClose:N(ym.STEPS),isQuickResolve:m,onSubmitResolveAction:p,isLoading:x.isLoading}),y===ym.ESCALATE&&(0,H.jsx)(Rm,{escalationPoints:d.escalationPoints,escalationProtocol:d.escalationProtocol||[],isEscalated:!!o,locationAlarmId:s,locationId:n,siteAddress:d.siteAddress,siteGoogleMapLocation:d.siteGoogleMapLocation,locationTenantId:c,onCancel:N(ym.STEPS)}),y===ym.STEPS&&(0,H.jsx)(Q,{variant:"error",onClick:N(ym.ESCALATE),children:"Escalate"})]})]})}let Pm=function(e){return e.SOP="sop",e.FLOORPLAN="floorplan",e.LOCATION_CONTACTS="locationContacts",e}({});const Mm=[{id:Pm.SOP,title:"Standard Operating Procedure (SOP)",icon:{component:function(e){return(0,H.jsx)("svg",Object.assign({viewBox:"0 0 612 612",xmlns:"http://www.w3.org/2000/svg"},e,{children:(0,H.jsxs)("g",{transform:"matrix(0.09936400502920151, 0, 0, -0.098921999335289, 0.2945280075073313, 611.5023193359375)",fill:"currentColor",stroke:"none",children:[(0,H.jsx)("path",{d:"M2845 5653 c-354 -32 -692 -130 -995 -289 -146 -77 -359 -220 -370 -249 -5 -12 -13 -24 -19 -26 -17 -6 -1 -49 18 -46 9 1 59 32 111 69 202 140 397 245 572 308 56 20 98 41 98 48 0 9 10 12 28 10 15 -1 86 12 157 30 239 59 340 69 747 76 160 2 222 7 233 16 12 10 19 10 28 1 9 -9 9 -14 -3 -21 -11 -7 -7 -10 17 -10 18 0 36 -6 40 -13 4 -7 54 -23 111 -35 57 -13 150 -38 208 -57 57 -18 107 -29 110 -24 8 14 27 10 21 -4 -4 -10 21 -24 76 -47 45 -18 129 -57 186 -87 81 -42 106 -51 117 -42 11 9 14 8 14 -5 0 -9 11 -21 25 -26 14 -5 25 -14 25 -19 0 -6 33 -33 74 -60 195 -132 448 -369 584 -548 253 -334 422 -716 488 -1107 14 -79 22 -106 33 -106 12 0 12 -3 3 -12 -14 -14 -16 -88 -2 -88 5 0 14 9 20 20 8 15 17 19 31 15 10 -4 19 -4 19 -1 0 3 -7 54 -16 113 -66 454 -257 893 -543 1248 -168 210 -483 495 -529 481 -31 -10 -54 4 -48 28 4 18 -8 30 -81 76 -194 123 -467 243 -670 294 -57 15 -63 15 -91 -1 -25 -14 -34 -15 -56 -5 -30 13 -35 32 -8 32 14 1 15 2 2 9 -19 11 -186 38 -310 51 -89 9 -367 11 -455 3z m-155 -72 c0 -5 -7 -11 -15 -15 -9 -3 -15 0 -15 9 0 8 7 15 15 15 8 0 15 -4 15 -9z m-855 -251 c-3 -5 -10 -10 -16 -10 -5 0 -9 5 -9 10 0 6 7 10 16 10 8 0 12 -4 9 -10z m2835 -240 c0 -5 -5 -10 -11 -10 -5 0 -7 5 -4 10 3 6 8 10 11 10 2 0 4 -4 4 -10z m90 -130 c0 -5 -4 -10 -10 -10 -5 0 -10 5 -10 10 0 6 5 10 10 10 6 0 10 -4 10 -10z m490 -590 c0 -5 -2 -10 -4 -10 -3 0 -8 5 -11 10 -3 6 -1 10 4 10 6 0 11 -4 11 -10z"}),(0,H.jsx)("path",{d:"M2850 5519 c-129 -11 -330 -46 -347 -60 -6 -6 -16 -8 -22 -5 -12 8 -214 -53 -343 -105 -209 -82 -548 -281 -548 -321 0 -10 4 -18 9 -18 5 0 60 34 122 75 342 227 716 357 1144 396 149 13 433 5 538 -16 25 -5 37 -4 37 4 0 18 38 13 59 -8 10 -10 40 -22 67 -26 66 -10 268 -69 360 -105 41 -17 85 -30 99 -30 13 0 28 -6 32 -14 4 -7 45 -32 90 -55 45 -22 117 -62 160 -87 43 -26 83 -47 90 -47 7 0 10 -4 8 -8 -3 -4 1 -9 8 -12 6 -2 51 -34 100 -71 48 -36 89 -66 92 -66 3 0 5 10 5 23 0 16 -23 39 -90 87 -348 251 -743 408 -1160 460 -124 15 -389 20 -510 9z"}),(0,H.jsx)("path",{d:"M1418 5005 c-16 -13 -28 -27 -28 -30 0 -13 29 -3 48 18 39 42 24 51 -20 12z"}),(0,H.jsx)("path",{d:"M1228 4903 c-65 -65 -147 -154 -183 -198 -69 -82 -208 -287 -264 -386 l-31 -57 31 -11 c18 -6 35 -11 40 -11 4 0 24 30 45 68 78 139 261 390 338 461 14 14 26 31 26 39 0 22 41 74 55 69 6 -3 25 6 41 19 24 20 27 25 14 34 -8 5 -23 10 -33 10 -29 0 -14 22 24 35 32 11 46 34 24 42 -6 2 -63 -50 -127 -114z"}),(0,H.jsx)("path",{d:"M1492 4967 c-22 -23 -30 -57 -14 -57 14 0 88 69 75 70 -6 0 -18 2 -25 5 -8 3 -24 -5 -36 -18z"}),(0,H.jsx)("path",{d:"M1350 4834 c-45 -45 -45 -45 -15 -38 30 7 104 62 105 77 0 4 -10 7 -23 7 -14 0 -40 -18 -67 -46z"}),(0,H.jsx)("path",{d:"M4703 4872 c-7 -5 29 -49 95 -118 59 -61 132 -143 162 -182 50 -66 78 -83 87 -57 2 6 -13 28 -32 49 -19 21 -35 41 -35 43 0 15 -223 248 -251 263 -8 5 -20 5 -26 2z"}),(0,H.jsx)("path",{d:"M1238 4722 c-67 -70 -158 -184 -158 -199 0 -7 -4 -13 -10 -13 -18 0 -152 -217 -225 -365 -142 -288 -223 -587 -232 -857 -3 -87 -9 -158 -14 -158 -13 0 -11 -58 2 -66 8 -4 10 -28 6 -70 -4 -37 -2 -66 3 -69 6 -4 10 -60 10 -125 0 -301 139 -719 353 -1057 34 -55 58 -83 70 -83 13 0 17 -5 13 -18 -11 -34 263 -348 395 -453 32 -25 38 -27 43 -12 5 12 -21 43 -99 116 -117 110 -229 240 -331 384 -75 106 -90 131 -169 285 -382 746 -344 1664 97 2372 56 90 193 273 264 353 33 38 43 56 37 67 -7 13 -17 7 -55 -32z"}),(0,H.jsx)("path",{d:"M 2925.122 5330.458 C 2723.1 5316.441 2455.137 5260.373 2293.797 5200.101 C 2128.248 5137.024 2000.58 5071.145 2008.998 5051.52 C 2013.207 5040.307 2010.4 5031.896 2001.983 5031.896 C 1993.564 5031.896 1985.148 5038.905 1982.342 5047.315 C 1975.327 5069.741 1698.945 4881.917 1558.65 4757.165 C 1415.55 4631.014 1386.087 4594.569 1373.46 4532.894 C 1366.447 4492.245 1380.475 4503.46 1523.578 4645.031 C 2147.89 5256.168 3023.331 5441.193 3851.071 5134.222 C 4295.806 4970.222 4698.453 4632.415 4956.596 4209.105 C 5022.535 4101.174 5141.785 3847.469 5141.785 3815.228 C 5141.785 3808.218 5151.604 3797.006 5164.232 3792.8 C 5176.858 3787.192 5183.874 3774.579 5178.263 3763.364 C 5174.053 3750.748 5185.277 3677.862 5204.918 3600.768 C 5254.021 3396.123 5273.662 3202.688 5263.841 2992.433 C 5256.826 2831.24 5228.769 2627.994 5203.515 2546.697 C 5196.501 2524.27 5199.305 2520.065 5217.545 2527.07 C 5249.813 2539.689 5245.603 2513.057 5211.933 2494.834 C 5197.903 2486.423 5178.263 2455.586 5169.843 2424.748 C 5148.801 2349.06 5040.772 2092.548 5004.296 2032.275 C 4987.46 2005.643 4973.43 1976.206 4973.43 1966.394 C 4973.43 1957.984 4960.805 1935.558 4945.372 1917.336 C 4931.343 1900.515 4880.836 1834.636 4834.539 1772.962 C 4788.241 1711.289 4734.929 1644.005 4715.288 1622.98 C 4695.648 1601.956 4678.811 1572.522 4678.811 1555.701 C 4678.811 1540.282 4668.991 1527.666 4656.365 1527.666 C 4645.142 1527.666 4583.411 1482.812 4520.279 1428.144 C 4227.06 1174.438 3886.145 1003.432 3517.169 923.537 C 3417.559 902.511 3308.129 892.7 3111.716 887.091 C 2853.574 880.084 2842.349 878.682 2856.38 853.452 C 2869.006 829.623 2888.648 826.818 3055.6 826.818 C 3158.014 826.818 3303.922 836.632 3381.083 847.844 C 3552.243 871.674 3797.758 934.751 3811.788 957.177 C 3817.399 966.989 3823.011 969.794 3823.011 964.186 C 3823.011 948.767 3947.874 999.228 4095.185 1073.518 C 4239.688 1146.404 4462.757 1294.984 4483.802 1332.829 C 4490.818 1348.25 4504.846 1359.463 4514.668 1359.463 C 4534.308 1359.463 4757.378 1583.734 4842.956 1688.861 C 5113.724 2023.866 5290.498 2493.43 5318.557 2953.187 C 5331.183 3150.826 5315.751 3349.866 5287.693 3349.866 C 5272.26 3349.866 5270.857 3355.474 5284.885 3376.497 C 5314.349 3424.156 5262.438 3649.829 5160.024 3921.755 C 5131.963 3991.84 5103.907 4050.712 5098.294 4050.712 C 5091.279 4050.712 5085.667 4061.925 5085.667 4075.943 C 5085.667 4115.191 4925.732 4366.092 4810.689 4509.064 C 4507.651 4880.514 4090.976 5145.433 3622.391 5264.578 C 3545.228 5284.202 3479.289 5296.817 3475.081 5292.611 C 3470.871 5288.407 3461.05 5289.808 3452.633 5296.817 C 3435.798 5310.833 3125.747 5341.673 3041.569 5337.466 C 3012.107 5336.064 2960.198 5333.262 2925.122 5330.458 Z"}),(0,H.jsx)("path",{d:"M5048 4492 c-25 -5 -23 -13 15 -54 17 -20 33 -42 35 -50 6 -22 19 -30 36 -21 13 7 11 14 -12 51 -15 23 -32 42 -39 42 -6 0 -13 8 -15 18 -2 11 -10 16 -20 14z"}),(0,H.jsx)("path",{d:"M5135 4340 c-3 -5 5 -27 19 -48 41 -66 136 -261 166 -343 16 -43 33 -86 39 -96 24 -46 111 -427 111 -487 0 -6 7 0 17 13 14 21 15 33 4 105 -15 98 -65 296 -77 305 -5 3 -10 17 -11 31 -2 45 -75 223 -85 208 -5 -8 -7 -4 -3 12 5 20 -1 32 -25 55 -20 19 -30 38 -30 59 0 34 -87 196 -106 196 -7 0 -15 -4 -19 -10z"}),(0,H.jsx)("path",{d:"M725 4210 c-68 -132 -135 -318 -135 -376 0 -30 -6 -49 -19 -61 -11 -10 -26 -46 -35 -79 -19 -73 -19 -74 -6 -74 6 0 10 14 10 30 0 39 10 38 34 -3 l19 -32 14 50 c34 126 108 340 153 440 28 60 46 113 42 116 -4 4 -19 11 -34 14 -23 6 -29 2 -43 -25z"}),(0,H.jsx)("path",{d:"M 1234.569 4401.136 C 1132.152 4260.965 1088.662 4175.463 1097.081 4130.609 C 1104.095 4094.164 1109.707 4099.773 1179.854 4214.708 C 1220.541 4281.99 1254.212 4349.272 1255.613 4361.887 C 1255.613 4374.503 1268.24 4408.146 1285.075 4434.776 C 1331.374 4513.272 1304.715 4493.646 1234.569 4401.136 Z"}),(0,H.jsx)("path",{d:"M 1011.5 4015.67 C 862.788 3682.066 792.64 3317.627 812.28 2967.204 C 826.311 2710.695 864.19 2529.875 956.786 2280.374 C 1001.678 2159.828 1010.097 2144.411 1028.335 2162.633 C 1040.963 2175.248 1043.768 2190.666 1036.753 2201.881 C 1031.143 2213.094 1024.125 2229.913 1022.724 2242.529 C 1021.322 2253.744 1000.277 2319.622 976.426 2388.304 C 815.088 2853.667 830.519 3407.337 1018.515 3890.921 C 1062.005 4000.251 1070.426 4040.901 1060.604 4066.13 C 1049.38 4096.968 1045.17 4094.164 1011.5 4015.67 Z"}),(0,H.jsx)("path",{d:"M503 3540 c-50 -268 -53 -736 -7 -927 4 -15 11 -20 22 -17 16 5 16 5 0 -8 -14 -12 -15 -20 -5 -64 7 -28 18 -58 26 -67 7 -9 10 -24 7 -33 -9 -24 30 -156 102 -339 41 -106 64 -155 140 -293 46 -82 61 -102 77 -100 16 3 19 -2 17 -24 -5 -50 147 -251 336 -441 105 -106 239 -224 246 -216 2 2 5 20 7 39 3 34 -5 44 -173 210 -112 112 -205 215 -259 288 -66 90 -88 112 -108 113 -25 1 -25 1 -3 7 l22 7 -24 35 c-133 196 -271 530 -327 792 -12 57 -24 110 -27 118 -3 8 -7 31 -8 50 -2 19 -11 94 -20 165 -23 193 -27 256 -16 279 6 12 13 72 17 135 3 63 8 126 11 140 l6 26 -21 -25 -20 -25 -3 120 -3 120 -12 -65z m77 -1140 c0 -5 -4 -10 -10 -10 -5 0 -10 5 -10 10 0 6 5 10 10 10 6 0 10 -4 10 -10z"}),(0,H.jsx)("path",{d:"M 1680.706 3700.289 C 1596.529 3682.066 1519.369 3638.614 1468.862 3581.145 C 1398.714 3502.652 1379.073 3440.976 1384.685 3326.037 C 1388.896 3240.534 1395.909 3216.705 1432.386 3164.84 C 1491.31 3080.741 1617.574 3019.065 1780.318 2992.433 C 2003.387 2955.99 2060.907 2920.948 2052.491 2824.231 C 2045.474 2735.925 1997.774 2712.096 1833.629 2713.496 C 1691.93 2713.496 1637.217 2730.318 1527.785 2801.804 L 1485.698 2831.24 L 1447.818 2791.993 L 1409.938 2751.343 L 1454.831 2758.351 L 1501.131 2765.361 L 1466.055 2727.515 C 1440.803 2699.481 1423.968 2692.472 1395.909 2698.079 C 1369.254 2703.688 1352.416 2698.079 1334.178 2678.456 C 1310.328 2651.823 1310.328 2650.421 1370.656 2606.969 C 1517.966 2499.038 1641.426 2459.791 1823.809 2461.191 C 1966.909 2462.595 2095.981 2496.235 2145.084 2545.294 C 2156.308 2556.506 2171.74 2564.919 2180.157 2564.919 C 2199.799 2564.919 2265.737 2654.627 2265.737 2681.259 C 2265.737 2693.873 2272.752 2707.891 2279.766 2712.096 C 2288.185 2716.302 2293.797 2735.925 2293.797 2755.548 C 2293.797 2782.18 2286.782 2789.188 2257.321 2789.188 C 2211.023 2789.188 2215.231 2834.043 2262.932 2845.257 C 2281.17 2849.462 2295.201 2856.469 2295.201 2863.478 C 2293.797 2869.087 2292.393 2890.112 2292.393 2912.539 C 2290.99 2934.967 2288.185 2940.57 2283.977 2926.554 C 2275.559 2895.717 2229.26 2892.914 2218.037 2923.751 C 2205.411 2955.99 2206.814 2957.393 2246.097 2957.393 C 2288.185 2957.393 2285.378 2975.614 2234.873 3048.502 C 2163.323 3150.826 2037.056 3211.098 1826.613 3241.935 C 1661.066 3267.166 1620.381 3289.594 1620.381 3356.874 C 1620.381 3391.916 1630.202 3411.54 1659.663 3433.968 C 1693.334 3462 1710.169 3464.805 1816.794 3459.199 C 1900.971 3454.993 1952.879 3443.78 1992.162 3424.156 C 2062.309 3387.712 2084.758 3396.123 2171.74 3487.231 L 2237.679 3557.317 L 2157.71 3607.778 C 2112.815 3635.812 2045.474 3668.05 2006.19 3680.665 C 1917.807 3707.298 1757.869 3717.108 1680.706 3700.289 Z M 2065.115 3571.335 C 2060.907 3560.116 2056.697 3564.327 2056.697 3579.745 C 2055.294 3595.162 2059.504 3603.572 2063.712 3597.966 C 2067.921 3593.761 2069.324 3581.145 2065.115 3571.335 Z M 1684.917 3212.502 C 1676.498 3198.485 1620.381 3194.278 1620.381 3208.293 C 1620.381 3211.098 1631.606 3222.311 1645.634 3232.124 C 1670.886 3250.345 1700.348 3236.33 1684.917 3212.502 Z M 2195.59 2629.395 C 2195.59 2618.182 2189.978 2604.165 2181.562 2599.961 C 2174.545 2595.754 2167.531 2604.165 2167.531 2619.583 C 2167.531 2636.404 2174.545 2649.019 2181.562 2649.019 C 2189.978 2649.019 2195.59 2640.608 2195.59 2629.395 Z M 1828.017 2597.157 C 1821.002 2562.115 1788.733 2557.91 1788.733 2591.549 C 1788.733 2608.372 1797.153 2620.984 1811.181 2620.984 C 1823.809 2620.984 1830.823 2611.174 1828.017 2597.157 Z"}),(0,H.jsx)("path",{d:"M 2911.094 3693.282 C 2675.399 3627.402 2546.327 3414.343 2546.327 3093.354 C 2546.327 2940.57 2564.566 2842.455 2609.46 2737.327 C 2648.743 2650.421 2773.606 2515.858 2804.471 2527.07 C 2818.5 2532.68 2826.918 2528.473 2826.918 2517.26 C 2826.918 2507.448 2853.574 2492.03 2885.841 2482.217 C 3104.701 2416.337 3324.965 2483.62 3440.005 2653.225 C 3512.96 2762.557 3543.825 2863.478 3552.243 3023.27 C 3564.87 3261.56 3518.571 3421.352 3396.514 3555.915 C 3274.459 3690.476 3089.268 3742.34 2911.094 3693.282 Z M 3194.491 3425.558 C 3223.951 3407.337 3252.011 3391.916 3257.623 3391.916 C 3278.668 3391.916 3309.531 3246.14 3315.144 3122.791 C 3320.754 2982.623 3298.309 2881.7 3240.788 2796.197 L 3204.31 2742.932 L 3236.579 2752.746 C 3254.818 2758.351 3294.1 2765.361 3324.965 2769.568 C 3375.471 2775.172 3378.277 2773.771 3346.009 2759.754 C 3296.906 2737.327 3128.552 2706.489 3047.181 2706.489 C 2936.348 2705.087 2861.99 2762.557 2811.485 2887.309 C 2782.023 2960.197 2784.828 3212.502 2817.097 3295.198 C 2878.826 3456.394 3052.792 3516.668 3194.491 3425.558 Z M 3268.847 3447.985 C 3273.056 3440.976 3270.25 3433.968 3263.234 3433.968 C 3254.818 3433.968 3247.802 3440.976 3247.802 3447.985 C 3247.802 3456.394 3250.608 3462 3253.413 3462 C 3257.623 3462 3264.638 3456.394 3268.847 3447.985 Z M 2748.353 2908.333 C 2752.562 2897.119 2749.755 2887.309 2742.741 2887.309 C 2734.324 2887.309 2728.711 2897.119 2728.711 2908.333 C 2728.711 2919.548 2731.516 2929.358 2734.324 2929.358 C 2737.129 2929.358 2742.741 2919.548 2748.353 2908.333 Z M 2797.455 2674.251 C 2798.858 2660.234 2793.246 2649.019 2787.634 2649.019 C 2782.023 2649.019 2776.411 2660.234 2775.008 2674.251 C 2773.606 2686.865 2769.396 2723.31 2765.186 2754.146 L 2756.77 2810.215 L 2776.411 2754.146 C 2787.634 2723.31 2797.455 2686.865 2797.455 2674.251 Z"}),(0,H.jsx)("path",{d:"M 3837.041 3295.198 C 3837.041 2984.025 3841.25 2887.309 3855.279 2883.103 C 3869.309 2877.495 3869.309 2874.693 3855.279 2874.693 C 3841.25 2873.292 3837.041 2824.231 3837.041 2677.054 L 3837.041 2480.815 L 3956.293 2480.815 L 4075.543 2480.815 L 4075.543 2706.489 L 4075.543 2933.563 L 4016.619 2923.751 C 3977.336 2916.743 3961.905 2918.145 3970.322 2927.957 C 3992.77 2948.981 4085.363 2961.595 4095.185 2944.775 C 4107.811 2923.751 4429.087 2923.751 4524.485 2944.775 C 4782.63 2999.442 4901.88 3307.815 4750.362 3532.086 C 4694.245 3614.786 4612.874 3666.647 4506.248 3684.87 C 4457.147 3693.282 4285.985 3700.289 4127.452 3700.289 L 3837.041 3700.289 L 3837.041 3295.198 Z M 4482.399 3616.19 C 4482.399 3609.177 4476.788 3602.172 4468.369 3602.172 C 4461.353 3602.172 4454.339 3609.177 4454.339 3616.19 C 4454.339 3624.596 4461.353 3630.204 4468.369 3630.204 C 4476.788 3630.204 4482.399 3624.596 4482.399 3616.19 Z M 4539.92 3407.337 C 4569.382 3376.497 4580.604 3352.67 4580.604 3314.824 C 4580.604 3276.977 4569.382 3253.149 4539.92 3222.311 L 4499.233 3181.661 L 4287.388 3181.661 L 4075.543 3181.661 L 4075.543 3314.824 L 4075.543 3447.985 L 4287.388 3447.985 L 4499.233 3447.985 L 4539.92 3407.337 Z M 4624.097 3340.054 C 4612.874 3319.029 4610.066 3319.029 4608.664 3337.251 C 4608.664 3361.079 4622.694 3382.107 4633.917 3372.292 C 4636.722 3368.087 4632.514 3354.071 4624.097 3340.054 Z M 3925.427 3312.02 C 3915.606 3309.218 3898.77 3309.218 3890.354 3312.02 C 3880.532 3316.225 3887.548 3319.029 3907.189 3319.029 C 3926.83 3319.029 3933.846 3316.225 3925.427 3312.02 Z M 4321.058 3014.862 C 4301.417 2998.041 4103.6 2944.775 4103.6 2957.393 C 4103.6 2962.998 4149.899 2979.821 4206.017 2995.237 C 4328.074 3030.281 4337.895 3031.681 4321.058 3014.862 Z M 3907.189 2901.325 C 3907.189 2894.316 3901.578 2887.309 3894.562 2887.309 C 3886.145 2887.309 3876.324 2894.316 3872.114 2901.325 C 3867.907 2909.735 3873.518 2915.342 3884.742 2915.342 C 3897.369 2915.342 3907.189 2909.735 3907.189 2901.325 Z"}),(0,H.jsx)("path",{d:"M5483 3226 c4 -55 7 -152 5 -214 -2 -94 -1 -112 12 -110 8 2 17 14 21 28 9 31 9 189 1 299 -6 72 -10 85 -27 91 -20 8 -20 6 -12 -94z"}),(0,H.jsx)("path",{d:"M5593 3273 c-10 -3 -13 -53 -13 -201 0 -108 -5 -237 -11 -287 -26 -222 -83 -454 -159 -648 -45 -114 -151 -330 -194 -394 -15 -23 -29 -48 -30 -57 -1 -9 -9 -22 -18 -28 -9 -7 -51 -60 -94 -118 -91 -123 -354 -390 -469 -477 -124 -93 -226 -159 -350 -227 -63 -35 -111 -67 -107 -71 4 -5 -1 -5 -11 -2 -23 9 -57 -9 -57 -28 0 -8 -8 -16 -17 -16 -55 -4 -80 -11 -203 -52 -74 -25 -161 -51 -194 -58 -48 -11 -56 -15 -42 -24 24 -18 19 -25 -19 -25 -19 0 -35 4 -35 10 0 5 -18 7 -42 5 -24 -3 -96 -12 -161 -20 -65 -8 -144 -16 -175 -16 -31 -1 -49 -3 -39 -6 19 -5 21 -12 8 -32 -8 -12 -12 -12 -25 -2 -8 7 -12 19 -9 27 7 18 -57 20 -75 2 -10 -10 -17 -10 -32 0 -11 6 -48 12 -83 12 -189 0 -561 76 -773 157 -11 4 -14 -4 -14 -35 0 -39 1 -40 57 -61 76 -30 295 -86 408 -105 243 -41 597 -46 820 -11 459 72 862 243 1217 517 68 53 76 62 63 75 -22 21 -7 38 16 17 17 -16 24 -11 145 107 144 141 240 256 346 414 92 136 192 321 184 340 -3 8 0 14 6 12 18 -3 22 35 4 45 -11 6 -14 17 -9 41 7 38 16 45 47 40 16 -3 25 1 29 14 3 10 19 56 36 103 61 170 111 400 131 605 11 113 13 386 4 434 -6 31 -26 39 -61 24z m-353 -1583 c0 -5 -2 -10 -4 -10 -3 0 -8 5 -11 10 -3 6 -1 10 4 10 6 0 11 -4 11 -10z m-1520 -1110 c0 -5 -2 -10 -4 -10 -3 0 -8 5 -11 10 -3 6 -1 10 4 10 6 0 11 -4 11 -10z"}),(0,H.jsx)("path",{d:"M5496 2837 c-11 -8 -20 -36 -27 -87 -8 -60 -29 -176 -53 -295 -20 -93 -117 -348 -186 -484 -29 -58 -54 -123 -56 -145 -4 -39 -3 -40 11 -21 9 11 49 88 90 170 72 146 121 274 163 422 19 68 19 74 4 83 -15 9 -15 10 4 16 19 5 24 21 43 132 26 160 34 222 29 222 -2 0 -12 -6 -22 -13z"}),(0,H.jsx)("path",{d:"M 1087.26 1994.428 C 1171.438 1836.038 1344 1611.768 1491.31 1468.795 C 1618.978 1342.643 1648.439 1325.822 1648.439 1372.078 C 1648.439 1405.718 1613.366 1435.155 1585.307 1425.341 C 1574.084 1419.735 1561.457 1422.537 1557.247 1429.547 C 1551.635 1437.958 1555.846 1443.565 1564.263 1443.565 C 1574.084 1443.565 1539.009 1489.82 1487.1 1545.887 C 1421.162 1615.973 1384.685 1645.409 1365.044 1642.605 C 1342.595 1638.399 1338.388 1644.005 1345.403 1665.032 C 1352.416 1686.057 1334.178 1719.697 1283.673 1788.383 C 1244.39 1841.644 1198.093 1907.524 1182.661 1936.959 C 1167.228 1964.994 1140.572 1991.625 1125.138 1995.831 C 1108.306 2000.038 1101.289 2009.847 1105.498 2022.464 C 1109.707 2035.078 1095.678 2056.105 1070.426 2074.326 L 1026.934 2106.565 L 1087.26 1994.428 Z"}),(0,H.jsx)("path",{d:"M 1663.872 1341.24 C 1651.245 1325.822 1670.886 1304.796 1757.869 1243.122 C 1895.358 1145.004 2066.519 1046.886 2083.353 1058.098 C 2114.219 1077.722 2091.771 1102.953 2000.58 1153.415 C 1947.268 1181.448 1856.076 1240.317 1795.748 1282.371 C 1736.825 1324.421 1686.319 1359.463 1684.917 1359.463 C 1682.11 1359.463 1672.29 1351.052 1663.872 1341.24 Z"}),(0,H.jsx)("path",{d:"M5067 1693 c-56 -81 -159 -212 -196 -250 -27 -28 -26 -33 3 -33 19 0 43 23 106 101 141 175 189 259 150 259 -4 0 -33 -35 -63 -77z"}),(0,H.jsx)("path",{d:"M 2111.413 1074.92 C 2112.815 1031.467 2163.323 1003.432 2355.526 938.955 C 2434.091 913.724 2453.733 910.92 2463.553 926.34 C 2478.987 951.569 2469.165 958.577 2377.973 988.013 C 2335.885 1002.031 2258.723 1031.467 2206.814 1052.492 C 2145.084 1077.722 2111.413 1086.132 2111.413 1074.92 Z"}),(0,H.jsx)("path",{d:"M 2494.418 930.546 C 2490.208 919.331 2490.208 906.717 2494.418 901.111 C 2505.643 889.896 2772.203 836.632 2779.218 845.04 C 2793.246 859.058 2765.186 896.903 2737.129 902.511 C 2721.696 906.717 2661.37 917.929 2605.251 929.143 C 2515.462 947.365 2501.433 947.365 2494.418 930.546 Z"}),(0,H.jsx)("path",{d:"M4649 1223 c-35 -30 -95 -77 -132 -106 -61 -46 -65 -52 -46 -59 28 -11 105 44 130 94 15 30 25 38 47 38 19 0 39 11 60 33 36 37 38 43 19 50 -8 3 -42 -20 -78 -50z"}),(0,H.jsx)("path",{d:"M1574 1115 c-9 -22 0 -30 119 -109 152 -101 341 -199 367 -191 28 9 61 -4 58 -22 -2 -11 13 -21 50 -34 50 -17 53 -17 50 -1 -2 9 -13 18 -26 20 -12 2 -22 8 -22 14 0 6 -3 9 -6 5 -3 -3 -11 -1 -18 4 -6 5 -78 43 -161 83 -82 41 -208 112 -278 160 -95 64 -129 82 -133 71z"}),(0,H.jsx)("path",{d:"M1540 1030 c0 -5 -10 -20 -21 -31 -12 -12 -17 -24 -13 -28 90 -66 289 -187 393 -239 l133 -66 19 25 c14 18 21 21 27 12 7 -10 12 -10 25 0 15 10 7 16 -60 46 -120 52 -237 117 -363 200 -63 42 -121 80 -127 84 -8 5 -13 4 -13 -3z"}),(0,H.jsx)("path",{d:"M4270 955 c-52 -30 -99 -56 -103 -58 -5 -1 -7 -13 -5 -25 3 -22 8 -20 117 42 132 76 130 74 111 86 -21 13 -14 16 -120 -45z"}),(0,H.jsx)("path",{d:"M3998 821 c-83 -34 -102 -51 -77 -66 18 -12 190 66 187 83 -5 24 -17 22 -110 -17z"}),(0,H.jsx)("path",{d:"M3776 739 c-185 -59 -395 -94 -618 -105 -128 -7 -138 -9 -138 -27 0 -18 6 -19 123 -13 227 12 345 29 363 54 10 13 15 14 27 4 13 -11 31 -9 99 7 121 28 285 83 268 89 -8 2 -19 8 -25 12 -5 4 -50 -6 -99 -21z"}),(0,H.jsx)("path",{d:"M2271 736 c-23 -27 350 -116 549 -131 47 -3 104 -8 128 -11 23 -3 42 -2 42 3 -1 25 -25 33 -135 43 -147 14 -351 51 -465 85 -99 29 -104 29 -119 11z"})]})}))},className:"h-10 w-10 sop-quick-action"}},{id:Pm.FLOORPLAN,title:"Floor Plan",icon:{component:function(e){return(0,H.jsx)("svg",Object.assign({viewBox:"0 0 122.88 110.81",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},e,{children:(0,H.jsx)("path",{d:"M 86.276 72.172 C 84.849 72.172 83.957 70.62 84.671 69.378 C 85.002 68.802 85.614 68.446 86.276 68.446 L 89.829 68.446 L 89.829 54.393 L 86.388 54.393 C 84.96 54.393 84.068 52.841 84.782 51.599 C 85.113 51.023 85.725 50.668 86.388 50.668 L 89.829 50.668 L 89.829 30.937 L 75.277 30.937 L 75.277 50.705 L 78.726 50.705 C 80.153 50.705 81.045 52.257 80.332 53.499 C 80.001 54.076 79.388 54.431 78.726 54.431 L 75.277 54.431 L 75.277 58.29 C 75.277 59.724 73.732 60.621 72.496 59.904 C 71.922 59.571 71.569 58.956 71.569 58.29 L 71.569 30.937 L 46.715 30.937 L 46.715 44.223 L 58.893 44.223 C 59.912 44.218 60.74 45.047 60.74 46.07 L 60.74 68.461 L 71.524 68.461 L 71.524 65.004 C 71.524 63.57 73.069 62.674 74.306 63.391 C 74.879 63.724 75.233 64.338 75.233 65.004 L 75.233 68.461 L 79.601 68.461 C 81.029 68.461 81.921 70.014 81.207 71.256 C 80.876 71.832 80.264 72.187 79.601 72.187 L 44.868 72.187 C 43.848 72.187 43.021 71.356 43.021 70.332 L 43.021 29.059 C 43.025 28.036 43.85 27.208 44.868 27.204 L 91.713 27.204 C 92.717 27.228 93.519 28.051 93.523 29.059 L 93.523 70.317 C 93.523 71.327 92.718 72.152 91.713 72.172 L 86.276 72.172 Z M 19.999 64.974 L 20.207 64.825 C 20.585 64.489 20.987 64.18 21.408 63.901 C 22.266 63.336 23.19 62.88 24.16 62.545 C 25.012 62.248 25.885 62.014 26.771 61.845 L 26.771 7.525 C 19.903 8.583 19.947 15.513 19.984 21.966 C 20.162 30.907 19.584 54.468 19.984 64.974 L 19.999 64.974 Z M 30.383 63.439 C 30.354 63.837 30.201 64.215 29.945 64.52 C 29.66 64.852 29.265 65.069 28.833 65.131 C 27.829 65.274 26.838 65.49 25.866 65.779 C 25.003 66.031 24.181 66.407 23.426 66.897 C 22.697 67.39 22.055 68.002 21.527 68.707 C 20.887 69.576 20.363 70.526 19.969 71.531 C 19.898 72.9 20.001 74.272 20.274 75.615 C 20.506 76.775 20.968 77.877 21.631 78.856 C 22.317 79.816 23.212 80.607 24.249 81.166 C 25.561 81.866 26.984 82.335 28.454 82.552 L 103.513 82.552 L 103.513 17.883 L 30.42 17.883 L 30.42 63.439 L 30.383 63.439 Z M 30.383 14.261 L 104.552 14.261 C 104.895 14.263 105.235 14.331 105.553 14.462 C 106.199 14.734 106.714 15.251 106.984 15.9 C 107.115 16.222 107.183 16.566 107.185 16.914 L 107.185 83.669 C 107.183 84.014 107.115 84.356 106.984 84.675 C 106.849 84.994 106.655 85.285 106.413 85.532 C 106.167 85.775 105.878 85.97 105.56 86.106 C 105.243 86.24 104.903 86.309 104.559 86.307 L 28.358 86.307 C 26.491 86.209 24.673 85.668 23.055 84.727 C 21.334 83.828 19.834 82.556 18.664 81.002 C 17.736 79.653 17.081 78.134 16.736 76.531 C 16.372 74.768 16.242 72.964 16.35 71.166 C 16.35 55.153 15.697 37.8 16.35 21.988 C 16.35 17.741 16.298 13.322 17.774 9.887 C 19.25 6.452 22.328 3.844 28.402 3.725 L 28.595 3.725 C 29.603 3.725 30.42 4.546 30.42 5.558 L 30.42 14.239 L 30.383 14.261 Z M 46.7 47.948 L 46.7 68.461 L 57.046 68.461 L 57.046 47.926 L 46.7 47.948 Z",transform:"matrix(1, 0, 0, 1, 8.881784197001252e-16, 8.881784197001252e-16)"})}))},className:"h-10 w-10 floorplan-quick-action"}},{id:Pm.LOCATION_CONTACTS,title:"Contacts",icon:{component:function(e){return(0,H.jsx)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",height:"24",viewBox:"0 -960 960 960",width:"24",fill:"currentColor"},e,{children:(0,H.jsx)("path",{d:"M160-40v-80h640v80H160Zm0-800v-80h640v80H160Zm320 400q50 0 85-35t35-85q0-50-35-85t-85-35q-50 0-85 35t-35 85q0 50 35 85t85 35ZM160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v480q0 33-23.5 56.5T800-160H160Zm70-80q45-56 109-88t141-32q77 0 141 32t109 88h70v-480H160v480h70Zm118 0h264q-29-20-62.5-30T480-280q-36 0-69.5 10T348-240Zm132-280q-17 0-28.5-11.5T440-560q0-17 11.5-28.5T480-600q17 0 28.5 11.5T520-560q0 17-11.5 28.5T480-520Zm0 40Z"})}))},className:"h-7 w-7 contacts-quick-action"}}];const Om=function(e){const{selected:t,onChange:n}=e;return(0,H.jsx)("div",{className:"bg-onlight-bg-2 dark:bg-ondark-bg-2 flex flex-col gap-8 rounded p-1",children:Mm.map((e=>{const a=e.icon.component,s=e.icon.className;return(0,H.jsx)(Q,{variant:"icon",onClick:(r=e.id,()=>n(r)),classNames:(0,z.Z)(t===e.id&&"ring-primary ring-1 ring-inset bg-primary-100/50 dark:bg-primary-100/20"),title:e.title,children:(0,H.jsx)(a,{className:s})},e.id);var r}))})};var Fm=n(66667);const Zm=function(){const[e,t]=M("showQuickActionsTour",!0);return(0,H.jsx)(Fm.ZP,{steps:[{target:".quick-actions-panel",content:"This is Quick Actions Panel to check out actions without letting live view going out of your sight.",placement:"left",disableBeacon:!0},{target:".sop-quick-action",content:"Check out Standard Operating Procedure (SOP) from here",placement:"left"},{target:".floorplan-quick-action",content:"Look at premises floor plan over here.",placement:"left"},{target:".contacts-quick-action",content:"Check location contacts over here",placement:"left"}],callback:e=>{const{status:n}=e;n!==Fm.Q_.FINISHED&&n!==Fm.Q_.SKIPPED||t(!1)},run:e,continuous:!0,showSkipButton:!0,showProgress:!0,disableScrollParentFix:!0,locale:{last:"Close"}})};const qm=function(e){const{locationAlarm:{id:t,location:{id:n,tenant_id:s},rawAlarms:r,status:i,locationIncidents:o},onAlarmResolve:l}=e,[c,d]=(0,a.useState)(Pm.SOP),[u,m]=(0,a.useState)([]);return(0,a.useEffect)((()=>{m(function(e){return[...e].sort(((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime())).map((e=>({id:e.sourceEntity.id,name:e.sourceEntity.name,livestreamUrl:e.sourceEntity.livestreamUrl,isTalkdownEnabled:!!(e.sourceEntity.audio_devices&&e.sourceEntity.audio_devices.length>0)})))}(r))}),[r]),(0,H.jsxs)("div",{className:"quick-actions-panel flex max-h-[85vh] translate-x-4 gap-1",children:[(0,H.jsx)(Om,{selected:c,onChange:d}),(0,H.jsx)(ie.u.Root,{show:void 0!==c,children:(0,H.jsx)("div",{className:"z-10 hidden lg:block lg:w-[23vw]",children:(0,H.jsx)(ie.u.Child,{as:a.Fragment,enter:"transition-transform ease-in duration-500",enterFrom:"translate-x-3/4",enterTo:"translate-x-0",leave:"transition-transform ease-out duration-200",leaveFrom:"translate-x-0",leaveTo:"translate-x-3/4",children:(0,H.jsxs)("div",{className:"relative max-h-[85vh] overflow-auto rounded p-2 lg:w-[23vw] lg:border-r lg:border-gray-200 lg:bg-gray-100 dark:lg:border-gray-800 lg:dark:bg-gray-800",children:[(0,H.jsx)(Q,{variant:"icon",onClick:()=>d(void 0),title:"Close",classNames:"absolute top-3 right-2 z-20",children:(0,H.jsx)(le.Z,{className:"h-5 w-5"})}),c===Pm.SOP&&(0,H.jsx)(Dm,{locationAlarmId:t,locationId:String(n),alarmCameras:u,onAlarmResolve:l,locationAlarmStatus:i,locationAlarmIncident:null==o?void 0:o[0],locationTenantId:s}),c===Pm.FLOORPLAN&&(0,H.jsx)(am,{locationId:String(n)}),c===Pm.LOCATION_CONTACTS&&(0,H.jsx)(nm,{locationId:n,locationAlarmId:t,locationTenantId:s})]})})})}),(0,H.jsx)(Zm,{})]})};function Um(e){var t;const{locationAlarmId:n}=e,s=(0,r.s0)(),[i,o]=(0,a.useState)(!1),l=Wt(n,2e3),c=(0,ur.Dv)(Nm),d=e=>{"Resolved"===e&&(o(!0),setTimeout((()=>s("/monitoring"))))};return(0,a.useEffect)((()=>{var e;"Resolved"===(null==(e=l.data)?void 0:e.status)&&o(!0)}),[null==(t=l.data)?void 0:t.status]),(0,Ss.kz)({when:!i,message:"If you leave now, this alarm will be dropped!"}),l.data?(0,H.jsx)(mr,{title:"Location Alarm",children:(0,H.jsxs)("div",{className:"flex",children:[(0,H.jsx)("div",{className:"flex-1",children:(0,H.jsx)(im,{alarm:l.data,onStatusChange:d,showContacts:!1,showSOP:!1,showResolveAction:!c})}),(0,H.jsx)("div",{className:"flex-0",children:(0,H.jsx)(qm,{locationAlarm:l.data,onAlarmResolve:d})})]})}):(0,H.jsx)(ws,{})}const Vm=nt(ht((function(){const{locationAlarmId:e}=(0,r.UO)();return void 0===e?(0,H.jsx)(As,{}):(0,H.jsx)(Um,{locationAlarmId:e})})),["location_alarm/detail:view"]);function $m(){return(0,H.jsxs)("div",{className:"my-auto flex-col",children:[(0,H.jsx)("div",{className:"text-status-green mx-auto flex flex-auto justify-center",children:(0,H.jsx)(q.Z,{className:"max-h-[24rem]"})}),(0,H.jsx)("div",{className:"text-onlight-text-2 dark:text-ondark-text-2 mx-auto flex justify-center text-6xl",children:"No pending alarms!"})]})}function zm(e){const{count:t,onGetPending:n,isLoading:a}=e;return(0,H.jsxs)("div",{className:"my-auto flex-col",children:[(0,H.jsx)("div",{className:"text-status-red mx-auto flex flex-auto justify-center motion-safe:animate-bounce",children:(0,H.jsx)(ne.Z,{className:"max-h-[24rem]"})}),(0,H.jsxs)("div",{className:"text-onlight-text-2 dark:text-ondark-text-2 mx-auto flex justify-center text-4xl",children:[String(t)," alarms pending"]}),(0,H.jsx)("div",{className:"mx-auto mt-4 flex flex-auto justify-center rounded-md",children:(0,H.jsx)(Q,{variant:"primary",onClick:n,loading:a,disabled:a,onSideEffect:yt("get_monitoring_alarm"),children:(0,H.jsx)("div",{className:"text-6xl",children:"Get alarm"})})})]})}const Hm=2e3;function Bm(){const e=(0,r.s0)(),[t,n]=(0,a.useState)(0),s=Et(Hm),i=(0,ur.Dv)(jt),o=(0,ur.Dv)(vt),l=Tt((t=>{Ie(Pl),kt("on_new_monitoring_alarm_load",{locationAlarmId:t}),void 0!==t?e(`/monitoring/${t}`):Le("Alarm already picked up by operator")}));return(0,a.useEffect)((()=>{void 0!==s.data&&n(s.data)}),[s.data]),(0,a.useEffect)((()=>{void 0!==t&&t>0?(We(i,Vl("locationAlarm")),Le("New pending alarm",{audio:o,duration:1/0,id:Pl})):0===t&&Ie(Pl)}),[t,o,i]),(0,H.jsxs)(mr,{title:"Monitoring",children:[l.isError&&(0,H.jsx)(B,{type:"error",children:l.error.message}),s.isLoading?(0,H.jsx)(ws,{text:"Initializing monitoring..."}):s.error?(0,H.jsx)(B,{type:"error",children:"Connection is not live"}):void 0!==t&&(0===t?(0,H.jsx)($m,{}):(0,H.jsx)(zm,{count:t,onGetPending:()=>{l.refetch()},isLoading:l.isRefetching||l.isLoading}))]})}nt(Bm,["location_alarms/monitoring:count"]);function Wm(){return(0,H.jsxs)(r.Z5,{children:[(0,H.jsx)(r.AW,{path:"/",element:(0,H.jsx)(Bm,{})}),(0,H.jsx)(r.AW,{path:":locationAlarmId",element:(0,H.jsx)(Vm,{})})]})}const Gm=(0,xt.cn)({page:1,pageSize:20}),Km=[{type:"location",label:"Audio Device Location",defaultValue:{values:[],negative:!1}}],Ym=(0,pt.O4)("cameraFilters",{location:{values:[],negative:!1}});const Qm=function(e){const{audioDevice:t,onClose:n}=e,[s,r]=(0,a.useState)({id:"",name:""}),i=ln(),o=Jt((()=>{Le("Audio Device Added",{type:"success"}),n()})),l=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{s.id&&o.mutate({audioDeviceId:t.id,cameraId:s.id})},disabled:o.isLoading||void 0===s.id,onSideEffect:yt("submit_add_audio_cam_mapping"),loading:o.isLoading,children:"Submit"}),(0,H.jsx)(Q,{onClick:n,onSideEffect:yt("cancel_add_audio_cam_mapping"),children:"Cancel"})]});return(0,H.jsxs)(ce,{title:"Add New Audio Device Camera Mapping",open:!0,onClose:n,footer:l,children:[o.isError&&(0,H.jsx)("div",{className:"mt-4 px-8",children:(0,H.jsx)(B,{type:"error",children:o.error.message})}),(0,H.jsxs)("div",{className:"w-[36rem] space-y-4 p-8",children:[(0,H.jsx)("div",{className:"px-4",children:"Adding camera to "}),(0,H.jsx)("span",{className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 mx-4 whitespace-pre rounded-md px-2 py-1 font-bold",children:t.url}),(0,H.jsx)("div",{className:"p-4",children:(0,H.jsx)(Vs,{value:s,label:"Camera",onChange:r,onChangeQuery:i,displayValue:e=>(null==e?void 0:e.name)||"",id:e=>e.id})})]})]})};const Xm={deviceType:Oe[0],enableAutomatedTalkdown:!0};const Jm=function(e){var t,n,s,r,i,o;const{onClose:l}=e,[c,d]=(0,a.useState)(Xm),[u,m]=(0,a.useState)(),[h,x]=(0,a.useState)({isValid:!0,message:""}),p=qn((async e=>{const t=(await e.json()).payload;m(t.items)})),g=Xt((()=>{Le("Audio Device Added",{type:"success"}),l()})),f=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{const{isValid:e,message:t}=function(e){var t;let n=!0,a="";return e.url&&""!==(null==(t=e.url)?void 0:t.trim())?e.deviceType?void 0===e.location&&(a="Select a valid location for the audio device",n=!1):(a="Select a valid device type for the audio device",n=!1):(a="Provide a valid URL for the audio device",n=!1),{isValid:n,message:a}}(c);if(x({isValid:e,message:t}),!e)return;const n=null==u?void 0:u.find((e=>{var t;return e.id===(null==(t=c.location)?void 0:t.id)})),a=Object.assign({},c,{tenantId:null==n?void 0:n.tenant_id});g.mutate([a])},disabled:g.isLoading,onSideEffect:yt("submit_add_audio_device"),loading:g.isLoading,children:"Submit"}),(0,H.jsx)(Q,{onClick:l,onSideEffect:yt("cancel_add_audio_device"),children:"Cancel"})]}),v=e=>t=>{d((n=>Object.assign({},n,{[e]:"string"==typeof t?t:t.target.value})))};return(0,H.jsxs)(ce,{title:"Add New Audio Device",open:!0,onClose:l,footer:f,children:[g.isError&&(0,H.jsx)("div",{className:"mt-4 px-8",children:(0,H.jsx)(B,{type:"error",children:g.error.message})}),!h.isValid&&(0,H.jsx)("div",{className:"mt-4 px-8",children:(0,H.jsx)(B,{type:"warning",children:h.message})}),(0,H.jsxs)("div",{className:"w-[36rem] space-y-4 p-8",children:[(0,H.jsx)(ae,{type:"text",label:"URL",value:null!=(t=c.url)?t:"",onChange:v("url")}),(0,H.jsx)(Ps,{onChange:v("deviceType"),items:Oe,value:c.deviceType,displayValue:e=>null!=e?e:"Unknown"}),(0,H.jsx)(Vs,{value:{id:null!=(n=c.location)&&n.id?String(c.location.id):"unknown",name:(null==(s=c.location)?void 0:s.name)||""},label:"Location",onChange:e=>d((t=>{var n;return Object.assign({},t,{location:{id:Number(e.id),name:null!=(n=e.name)?n:"unknown"}})})),onChangeQuery:p,displayValue:e=>(null==e?void 0:e.name)||"",id:e=>String(e.id)}),(0,H.jsx)(ae,{type:"text",label:"Username",value:null!=(r=c.userName)?r:"",onChange:v("userName")}),(0,H.jsx)(ae,{type:"text",label:"Password File",value:null!=(i=c.passwordFilePath)?i:"",onChange:v("passwordFilePath")}),(0,H.jsx)(we,{enabled:null==(o=c.enableAutomatedTalkdown)||o,onChange:e=>d((t=>Object.assign({},t,{enableAutomatedTalkdown:e}))),label:"Automated Talkdown"})]})]})};const eh=function(e){const{audioDevice:t}=e,n=en((()=>Le("Audio Device Mapping Removed",{type:"success"}))),a=Xe();return(0,H.jsxs)("div",{className:"p-4 text-xs",children:[t.cameras.map((e=>(0,H.jsx)("div",{className:"m-2 inline-flex gap-4 rounded-xl px-2",children:(0,H.jsx)(re,{text:e.name,removable:a,onClickRemove:()=>a&&n.mutate({audioDeviceId:t.id,cameraId:e.id})})},e.id))),0===t.cameras.length&&(0,H.jsx)("div",{className:"text-center text-gray-600 dark:text-gray-400",children:"No cameras attached to this audio device"})]})};const th=function(e){const{canAddAudioDevice:t,isLoading:n,onClickAddAudioDevice:a,hasCustomFiltersApplied:s,onClickFilter:r}=e;return(0,H.jsxs)("div",{className:(0,z.Z)("dark:bg-dark-bg flex items-center border-b bg-white p-4 dark:border-0",t?"justify-between":"justify-end"),children:[t&&(0,H.jsxs)(Q,{variant:"primary",onClick:a,disabled:n,onSideEffect:yt("open_add_audio_device_modal"),children:["Add Audio Device",(0,H.jsx)("span",{className:"sr-only",children:"Add Audio Device"})]}),(0,H.jsx)("div",{children:(0,H.jsxs)(Q,{variant:"icon",badge:s,onClick:r,disabled:n,onSideEffect:yt("open_audio_devices_filters_panel"),children:[(0,H.jsx)("span",{className:"sr-only",children:"Open filters panel"}),(0,H.jsx)(_d.Z,{className:"h-5 w-5","aria-hidden":"true"})]})})]})};var nh=n(29797);const ah=function(e){const{enableAutomatedTalkdown:t,id:n,cameras:s,tenantId:r,location:i}=e.audioDevice,[o,l]=(0,a.useState)(!1),c=()=>l(!1),d=Ye(),[u,m]=(0,a.useState)(t),h=nn((()=>{Le("Automated talkdown updated",{type:"success"}),c(),m((e=>!e))}),(()=>{Le("Failed to update automated talkdown",{type:"error"}),c()}));(0,a.useEffect)((()=>{m(t)}),[t]);const x=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{const e={id:n,tenantId:r,enableAutomatedTalkdown:!t,location:i};h.mutate(e)},disabled:h.isLoading,onSideEffect:yt("update_automated_talkdown"),loading:h.isLoading,children:u?"Disable":"Enable"}),(0,H.jsx)(Q,{onClick:c,children:"Cancel"})]});return d?(0,H.jsxs)("div",{children:[(0,H.jsx)(we,{enabled:u,onChange:()=>l(!0)}),o&&(0,H.jsx)(ce,{onClose:c,title:"Automated talkdown",open:o,footer:x,children:(0,H.jsxs)("div",{className:"p-6 leading-8",children:[(0,H.jsx)("div",{children:"Associated Cameras"}),(0,H.jsx)("ul",{className:"list-disc pl-4",children:s.map((e=>(0,H.jsx)("li",{children:e.name})))}),(0,H.jsxs)("div",{children:["You are about to",(0,H.jsx)("span",{className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 whitespace-pre rounded-md py-1 px-2 font-bold",children:u?"disable":"enable"}),"automated talkdown for this audio device. Are you sure ?"]})]})})]}):u?(0,H.jsx)("div",{className:"text-status-green h-5 w-5",children:(0,H.jsx)(Ce.Z,{})}):(0,H.jsx)("div",{className:"text-status-red h-5 w-5",children:(0,H.jsx)(cl.Z,{})})},sh=[{id:"url",name:"URL"},{id:"location",name:"Location",showAtBreakpoint:"sm"},{id:"enabled",name:"Auto Talkdown Enabled",showAtBreakpoint:"sm"},{id:"action",name:"",showAtBreakpoint:"sm"}];const rh=nt(ht((function(){const[e,t]=(0,ur.KO)(Gm),{page:n,pageSize:s}=e,[r,i]=(0,a.useState)(!1),[o,l]=(0,ur.KO)(Ym),[c,d]=(0,a.useState)({columns:sh,rows:[]}),[u,m]=(0,a.useState)([]),[h,x]=(0,a.useState)(void 0),[p,g]=(0,a.useState)(!1),[f,v]=(0,a.useState)(0),[j,b]=(0,a.useState)(!1),{isLoading:y,isError:k,error:w,data:N}=tn(function(e,t,n){const a=new URLSearchParams;return a.append("page",String(e)),a.append("pageSize",String(t)),n.location.values.length>0&&a.append("locationIds",n.location.values.map((e=>e.id)).join(Yn)),a.toString()}(n,s,o)),C=(n-1)*s,S=Math.min(n*s,f)-1,T=Ye(),E=Xe();(0,a.useEffect)((()=>{if(N){const{items:e,total:t}=N;d(function(e,t,n){return{rows:e.map((e=>({id:String(e.id),cells:[{value:e.url},{value:e.location.name},{value:(0,H.jsx)(ah,{audioDevice:e})},{value:t&&n?(0,H.jsx)(Q,{variant:"icon",onClick:()=>n(e),children:(0,H.jsx)(nh.Z,{className:"h-5 w-5"})}):null}]}))),columns:sh}}(e,E,(e=>{x(e),g(!0)}))),m(e),v(t)}}),[N,E]);const A=(0,H.jsx)(th,{canAddAudioDevice:T,isLoading:y,onClickAddAudioDevice:()=>b(!0),hasCustomFiltersApplied:o.location.values.length>0,onClickFilter:()=>i(!0)}),_=(0,H.jsx)("div",{className:"dark:bg-dark-bg border-t bg-white p-4 dark:border-gray-800",children:(0,H.jsx)(wi,{from:C+1,to:S+1,pageSize:s,total:f,disabled:y,onChangePage:e=>t((t=>Object.assign({},t,{page:e})))})});return(0,H.jsxs)(mr,{title:"Audio Devices",children:[k&&(0,H.jsx)("div",{className:"mb-2",children:(0,H.jsx)(B,{type:"error",children:w.message})}),j&&(0,H.jsx)(Jm,{onClose:()=>b(!1)}),p&&h&&(0,H.jsx)(Qm,{audioDevice:h,onClose:()=>{x(void 0),g(!1)}}),(0,H.jsx)("div",{className:"dark:bg-dark-bg -mx-4 flex min-h-0 flex-1 flex-col justify-start overflow-y-hidden sm:-mx-6 md:mx-0 md:rounded-lg",children:(0,H.jsx)(Ai,{data:c,header:A,footer:_,loading:y,renderExpandedRow:e=>{const t=u.find((t=>String(t.id)===e));return t?(0,H.jsx)(eh,{audioDevice:t}):null}})}),(0,H.jsx)(wd,{open:r,title:"Audio Device Filters",filterConfigs:Km,initialFilterValues:o,trackingEventNameApply:"apply_audio_filters",trackingEventNameReset:"reset_audio_filters",onClose:()=>i(!1),onApply:e=>{l(e),wt(e),t((e=>Object.assign({},e,{page:1}))),i(!1)}})]})})),["audio_devices:view"]);function ih(){return(0,H.jsx)(r.Z5,{children:(0,H.jsx)(r.AW,{path:"/",element:(0,H.jsx)(rh,{})})})}const oh={auditLogPage:1,auditLogPageSize:30},lh={state:oh,dispatch:()=>null},ch=(0,a.createContext)(lh),dh=(0,cm.ZP)(((e,t)=>{if("SET_PAGE"!==t.type)throw new Error;e.auditLogPage=t.payload}));function uh(e){const{children:t}=e,[n,s]=(0,a.useReducer)(dh,oh);return(0,H.jsx)(ch.Provider,{value:{state:n,dispatch:s},children:t})}const mh="SET_PAGE";const hh=[{id:"activity",name:"Activity"},{id:"timestamp",name:"Timestamp",showAtBreakpoint:"lg"}];const xh=nt(ht((function(){const{auditLogPage:e,auditLogPageSize:t}=function(){const{state:e}=(0,a.useContext)(ch);return e}(),n=function(){const{dispatch:e}=(0,a.useContext)(ch);return e}(),[s,r]=(0,a.useState)({columns:hh,rows:[]}),[i,o]=(0,a.useState)(0),{data:l,isLoading:c}=Xn(function(e,t){const n=new URLSearchParams;return n.append("page",String(e)),n.append("pageSize",String(t)),n.toString()}(e,t),2e4),d=(e-1)*t,u=Math.min(e*t,i)-1;(0,a.useEffect)((()=>{if(l){const{items:e,total:t}=l;r(function(e){return{columns:hh,rows:e.map((e=>({id:e.id,cells:[{value:e.activity},{value:e.timestamp}]})))}}(e)),o(t)}}),[l]);const m=(0,H.jsx)("div",{className:"dark:bg-dark-bg border-t bg-white p-4 dark:border-gray-800",children:(0,H.jsx)(wi,{from:d+1,to:u+1,pageSize:t,total:i,onChangePage:e=>{n({type:mh,payload:e})}})});return(0,H.jsx)(mr,{title:"Audit Log",children:(0,H.jsx)("div",{className:"dark:bg-dark-bg -mx-4 flex min-h-0 flex-1 flex-col justify-start overflow-y-hidden sm:-mx-6 md:mx-0 md:rounded-lg",children:(0,H.jsx)(Ai,{data:s,loading:c,footer:m,scrollResetKey:e})})})})),["audit-log:view"]);const ph=function(){return(0,H.jsx)(r.Z5,{children:(0,H.jsx)(r.AW,{path:"/",element:(0,H.jsx)(xh,{})})})};function gh(){return(0,H.jsx)(uh,{children:(0,H.jsx)(ph,{})})}var fh=n(91984),vh=n(6692),jh=n(66574);let bh=function(e){return e.RTSP="RTSP",e.AVIGILON="AVIGILON",e.GENETEC="GENETEC",e.EXACQVISION="EXACQVISION",e.MILESTONE="MILESTONE",e}({}),yh=function(e){return e.SPECIAL_ZONES="specialZones",e.LIVE="live",e.PLAYBACK="playback",e.SETTINGS="settings",e}({}),kh=function(e){return e.LIST_VIEW="listView",e.GRID_VIEW="gridView",e}({}),wh=function(e){return e.LIVE="live",e.PLAYBACK="playback",e}({});const Nh=15,Ch=[{type:"location",label:"Camera Location",defaultValue:{values:[],negative:!1}}];var Sh=n(40452);const Th=function(e){var t,n;const{camera:a,selected:s,onClick:r,disabled:i}=e;return(0,H.jsxs)("button",{onClick:r&&r,className:(0,z.Z)("dark:bg-ondark-bg-2 bg-onlight-bg-2 hover:bg-onlight-bg-3 dark:hover:bg-ondark-bg-3 flex w-full cursor-pointer items-center justify-between rounded-md px-4 outline-none",s&&"dark:outline-ondark-primary outline-onlight-primary bg-onlight-bg-3 dark:bg-ondark-bg-3 outline outline-offset-2",i&&"bg-onlight-bg-3/70 dark:bg-ondark-bg-3/70 pointer-events-none disabled:opacity-75"),children:[(0,H.jsxs)("div",{className:"grid grid-cols-1 grid-rows-2 gap-2 p-2",children:[(0,H.jsx)("span",{className:"overflow-hidden overflow-ellipsis whitespace-nowrap text-start",children:a.name}),(0,H.jsxs)("div",{className:"flex items-center gap-1 text-xs",children:[(0,H.jsx)("span",{children:(0,H.jsx)(_m.Z,{className:"h-3 w-3","aria-hidden":"true"})}),(0,H.jsx)("span",{children:(null==(t=a.location)?void 0:t.name)||"-"})]})]}),(0,H.jsxs)("span",{className:"flex flex-col items-end gap-2",title:`Integration type - ${a.integrationType}`,children:[(0,H.jsxs)("span",{className:"flex items-center gap-1",title:"Speaker mapped",children:[a.audioDevices&&(null==(n=a.audioDevices)?void 0:n.length)>0&&(0,H.jsx)(Ee.Z,{className:"text-onlight-text-2 dark:text-ondark-text-2 w-5","aria-hidden":"true"}),(0,H.jsx)(re,{small:!0,type:"info",children:a.integrationType})]}),(0,H.jsx)(re,{small:!0,text:a.armStatus.isArmed?"Armed":"Disarmed",type:a.armStatus.isArmed?"success":"error"})]})]})};function Eh(e){const{cam:t,viewMode:n}=e,a=n===wh.PLAYBACK&&!t.isPlaybackEnabled,{attributes:s,listeners:r,setNodeRef:i}=(0,jh.O1)({id:`draggable-${t.id}`,data:t,disabled:a});return(0,H.jsxs)("div",Object.assign({className:(0,z.Z)(a&&"relative cursor-auto"),ref:i},s,r,{children:[a&&(0,H.jsx)("span",{className:"absolute top-6 left-1",children:(0,H.jsx)(ye,{position:"right",size:"medium",text:"Playback not enabled for this camera.",colorModifier:"info",children:(0,H.jsx)(Sh.Z,{className:"h-4 w-4 text-orange-700"})})}),(0,H.jsx)(Th,{camera:t,disabled:a})]}))}const Ah=function(e){const{cameras:t,isFetching:n,viewMode:s}=e,[r,i]=(0,a.useState)(""),[o,l]=(0,a.useState)(t);return(0,a.useEffect)((()=>{l(t)}),[t]),(0,H.jsxs)("div",{className:"mt-2 mr-4 flex w-[24rem] flex-col space-y-1 overflow-y-auto",children:[(0,H.jsx)("div",{className:"px-1",children:(0,H.jsx)(ae,{label:"",onChange:e=>{const n=e.target.value;i(n);const a=[...t].filter((e=>{var t;return e.name.toLowerCase().includes(n.toLowerCase())||(null==e||null==(t=e.location)?void 0:t.name.toLowerCase().includes(n.toLowerCase()))}));l(a)},value:r,type:"search",placeholder:"Search..."})}),n&&0===t.length?(0,H.jsx)("div",{className:"flex justify-center",children:(0,H.jsx)(K,{})}):o.map((e=>(0,H.jsx)(Eh,{cam:e,viewMode:s},e.id)))]})};var _h=n(6937);const Ih=function(e){const{cameraCount:t,isFullScreen:n,viewMode:a,timezone:s,allTimezones:r,addCamera:i,toggleFullScreen:o,onChangeItemsSwitch:l,updateTimezone:c}=e,d=[{id:wh.LIVE,name:"Live",icon:_a.Z,extra:a===wh.LIVE?(0,H.jsx)("span",{className:"bg-status-red h-1.5 w-1.5 animate-pulse rounded-full"}):null},{id:wh.PLAYBACK,name:"Playback",icon:_h.Z}];return(0,H.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,H.jsx)(se,{items:d,onChange:l,selectedItem:d.find((e=>e.id===a))}),(0,H.jsxs)("div",{className:"flex items-center gap-2",children:[s&&a===wh.PLAYBACK&&(0,H.jsx)(Us,{displayValue:e=>e||"",value:s,getItems:()=>r,label:"",onChange:c}),t<4&&(0,H.jsxs)(Q,{variant:"icon",onClick:i,children:[(0,H.jsx)(nh.Z,{className:"mr-2 h-5 w-5"}),"Add Camera"]}),(0,H.jsx)(Q,{variant:"icon",onClick:o,onSideEffect:yt("toggle_camera_grid_view_fullscreen"),children:(0,H.jsxs)("span",{className:"dark:text-dark-secondary-text text-onlight-text-3 flex items-center",children:[n?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Oa,{className:"dark:fill-dark-text h-7 w-7"}),"Exit"," "]}):(0,H.jsx)(Ma,{className:"dark:fill-dark-text h-7 w-7"}),"Fullscreen"]})})]})]})};const Lh=function(e){const{selectedCamera:t,cameras:n,onChange:s}=e,[r,i]=(0,a.useState)(n);return(0,H.jsx)(Us,{getItems:()=>r,value:t,onChange:e=>{e&&s(e)},displayValue:e=>{return(null==e?void 0:e.id)===(null==t?void 0:t.id)?(null==e?void 0:e.name)||"":e?`${e.name} - ${(null==(n=e.location)?void 0:n.name)||""}`:"";var n},onChangeQuery:e=>{const t=n.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())));i(t)},placeholder:"Select a camera"})};const Rh=function(e){var t,n;const{allCameras:a,onRemoveCamera:s,isClosedHidden:r,selectedCamera:i,onCameraChange:o,index:l,children:c}=e,{isOver:d,setNodeRef:u}=(0,jh.Zj)({id:`droppable-${l}`,data:{index:l}});return(0,H.jsxs)("div",{ref:u,className:(0,z.Z)("border-onlight-line-2 dark:border-ondark-line-2 flex h-full min-h-[20rem] border",i?"flex-col":"relative flex-col items-center justify-center gap-2",d?"bg-onlight-bg-2 dark:bg-ondark-bg-3/50":"bg-onlight-bg-1 dark:bg-ondark-bg-2"),children:[!i&&(0,H.jsx)("div",{className:"text-onlight-text-2 dark:text-ondark-text-2 text-sm",children:"Drag and drop a camera from the list or"}),(0,H.jsxs)("div",{className:(0,z.Z)("flex justify-between p-1",i&&"border-b-ondark-text-2 border-b"),children:[(0,H.jsx)(Lh,{cameras:a,onChange:o,selectedCamera:i}),i&&(0,H.jsx)("div",{className:"flex gap-4",children:(0,H.jsxs)("div",{className:"dark:text-dark-text mr-1 flex items-center gap-2 text-xs",children:[(0,H.jsx)("span",{title:(null==(t=i.location)?void 0:t.name)||"-",children:(0,H.jsx)(_m.Z,{xlinkTitle:"",className:"h-5 w-5","aria-hidden":"true"})}),(0,H.jsx)("span",{children:(null==(n=i.location)?void 0:n.name)||"-"})]})}),!r&&(0,H.jsx)("div",{className:(0,z.Z)(!i&&"absolute top-0 right-0"),children:(0,H.jsx)(Q,{title:"Remove",variant:"icon",onClick:s,children:(0,H.jsx)(cl.Z,{className:"h-6 w-6","aria-hidden":"true"})})})]}),i&&c]})};function Dh(e){const{cameraId:t,cameraTimeZone:n,triggerTime:s,updatePlayStatus:r}=e,[i,o]=(0,a.useState)(""),[l,c]=(0,a.useState)(),[d,u]=(0,a.useState)(!1),m=dn(t,s/1e3),h=O(s);(0,a.useEffect)((()=>{let e=!1;if(h){const t=new Date(s);new Date(h).getUTCDay()!==t.getUTCDay()&&(e=!0)}else e=!0;e&&s&&m().then((e=>{u(!1),o(e),r(!1)}))}),[m,h,s,r]),function(e,t,n){(0,a.useEffect)((()=>{const a=null==n?void 0:n.current;if(t&&a){const n=t.playingDate;if(n){const t=(e-n.getTime())/1e3;Math.abs(t)>10&&(a.currentTime+=t)}else{const n=()=>{var a;const s=null==(a=t.levels[0].details)?void 0:a.startSN;if(s){const n=(e-1e3*s)/1e3;t.config.startPosition=n}t.off(hi.default.Events.MANIFEST_PARSED,n)};t.on(hi.default.Events.MANIFEST_PARSED,n)}}}),[e,t,n])}(s,null==l?void 0:l.hls,null==l?void 0:l.videoRef),function(e,t){(0,a.useEffect)((()=>{const n=null==t?void 0:t.current,a=()=>e(!1),s=()=>e(!0);return n&&(n.addEventListener("waiting",a),n.addEventListener("canplay",s)),()=>{n&&(n.removeEventListener("waiting",a),n.removeEventListener("canplay",s))}}),[t,e])}(r,null==l?void 0:l.videoRef);const x=(0,a.useCallback)(((e,t)=>{c({hls:e,videoRef:t})}),[]),p=(0,a.useCallback)((e=>{u(!0),y.uT(String(e))}),[]);return(0,H.jsxs)(H.Fragment,{children:[d&&(0,H.jsx)(B,{children:"Unable to load current playback."}),(0,H.jsx)(pi,{onInit:x,videoPath:i,lockAspectRatio:!0,onError:p,timeZone:n,authRequired:!0,isPlayback:!0,controlsList:["onlyTime"]})]})}const Ph=(0,a.memo)(Dh);const Mh=function(e){const{seekerTime:t,timeZone:n,updateSeekerTime:s}=e,[r]=(0,a.useState)((()=>{const e=new Date;return e.setDate(e.getDate()-Nh),e})),[i]=(0,a.useState)((()=>new Date));return(0,H.jsx)(Zo,{timeZone:n,startDate:r,endDate:i,seekerTime:t,playbackMotionMarkers:[],onMarkerChange:s})};const Oh=function(e){const{items:t,viewMode:n,allCameras:s=[],updateItems:r,timezone:i,isFetching:o}=e,[l,c]=(0,a.useState)(),[d,u]=(0,a.useState)([]),m=t.length,[h,x]=(0,a.useState)([]),p=(0,a.useRef)();(0,a.useEffect)((()=>{if(n===wh.PLAYBACK){let e=p.current;if(!e){const t=new Date;t.setMinutes(t.getMinutes()-15),e=t.getTime()}c(new Date(e)),u(new Array(t.length).fill(e))}else c(void 0)}),[t,n]),(0,a.useEffect)((()=>{let e;const t=h.some((e=>!0===e));return n===wh.PLAYBACK&&i&&t&&(e=window.setInterval((()=>{c((e=>{if(void 0!==e){const t=new Date(e.getTime());return t.setSeconds(t.getSeconds()+1),p.current=t.getTime(),t}return e}))}),1e3)),()=>{e&&window.clearInterval(e)}}),[h,i,n]),(0,a.useEffect)((()=>{const e=window.setInterval((()=>{u((e=>{const t=e.length;return p.current?new Array(t).fill(p.current):e}))}),1e4);return()=>{window.clearInterval(e)}}),[]);const g=e=>n=>{const a=[...t];a[e]=n,r(a)},f=A((e=>{u(new Array(t.length).fill(e.getTime()))}),1e3),v=(0,a.useCallback)((e=>t=>{x((n=>{const a=[...n];return a[e]=t,a}))}),[]);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:(0,z.Z)("grid gap-2",1===m?"sm:grid-cols-1":"sm:grid-cols-1 lg:grid-cols-2"),children:t.map(((e,a)=>((e,a)=>{if(o&&0===s.length)return(0,H.jsx)(Fh,{},e?e.id:a);let i=null;return n===wh.LIVE&&e?i=(0,H.jsx)(Mi,{camera:e,controlsList:["noForwardBackward","noPlayPause"],lockAspectRatio:!0}):n===wh.PLAYBACK&&e&&(i=(0,H.jsx)(Ph,{cameraId:e.id,cameraTimeZone:e.location.timezone,triggerTime:d[a],updatePlayStatus:v(a)})),(0,H.jsx)(Rh,{index:a,isClosedHidden:1===m,allCameras:s,onRemoveCamera:(l=a,()=>{const e=[...t];e.splice(l,1),r(e)}),selectedCamera:e,onCameraChange:g(a),children:e&&i},e?`${e.id}-${a} `:a);var l})(e,a)))}),l&&i&&(0,H.jsx)(Mh,{seekerTime:l,timeZone:i,updateSeekerTime:e=>{c(e),f(e)}})]})};function Fh(){return(0,H.jsx)("div",{className:"border-onlight-line-2 dark:border-ondark-line-2 flex min-h-[20rem] items-center justify-center border",children:(0,H.jsx)(K,{})})}const Zh=function(){const{isFetching:e,isError:t,error:n,data:s}=on(""),r=(0,a.useRef)(null),{isFullScreen:i,toggleFullScreen:o}=D(r),[l,c]=(0,a.useState)((()=>new Array(4).fill(null))),[d,u]=(0,a.useState)(),[m,h]=(0,a.useState)(wh.LIVE),[x,p]=(0,a.useState)(),[g,f]=(0,a.useState)([]);return(0,a.useEffect)((()=>{let e=[];e=l.reduce(((e,t)=>{var n;return t&&e.push((null==t||null==(n=t.location)?void 0:n.timezone)||"UTC"),e}),e);const t=Array.from(new Set(e));f(t),t.length>0&&p(t[0]);l.every((e=>null===e))&&p(void 0)}),[l]),(0,H.jsx)(jh.LB,{onDragEnd:e=>{const{active:t,over:n}=e,a=t.data.current,s=null==n?void 0:n.data.current;if(a&&s){const e=s.index,t=[...l];t[e]=a,c(t)}u(void 0)},onDragStart:e=>{u(e.active.data.current)},children:(0,H.jsxs)(zs,{ref:r,classnames:"p-1",children:[(0,H.jsx)($s,{children:(0,H.jsx)(Ah,{cameras:(null==s?void 0:s.items)||[],isFetching:e,viewMode:m})}),(0,H.jsx)($s,{children:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{className:"h-full w-full pl-4",children:[t&&(0,H.jsx)("div",{className:"mb-2",children:(0,H.jsx)(B,{type:"error",children:n.message})}),(0,H.jsx)(Ih,{addCamera:()=>{const e=[...l,null];c(e)},cameraCount:l.length,isFullScreen:i,onChangeItemsSwitch:e=>{if(h(e.id),e.id===wh.PLAYBACK){const e=l.map((e=>e&&!e.isPlaybackEnabled?null:e));c(e)}},toggleFullScreen:o,viewMode:m,timezone:x,allTimezones:g,updateTimezone:e=>e&&p(e)}),(0,H.jsx)(Oh,{items:l,allCameras:null==s?void 0:s.items,isFetching:e,updateItems:e=>c(e),viewMode:m,timezone:x})]}),(0,H.jsx)(jh.y9,{children:d&&(0,H.jsx)(Eh,{cam:d,viewMode:m})})]})})]})})};var qh=n(17470);const Uh=function(e){const{onShare:t}=e,n=[{name:"Share live view",onClick:t,icon:(0,H.jsx)(qu.Z,{className:"h-4 w-4"})}],a=(0,H.jsx)(qc.Z,{className:"h-5 w-5","data-testid":"menu-button"});return(0,H.jsx)("span",{className:"mr-1",children:(0,H.jsx)(Cs,{items:n,menuButton:a})})},Vh=((0,xt.cn)(void 0),(0,xt.cn)(void 0),(0,xt.cn)(void 0),(0,xt.cn)(void 0)),$h=(0,xt.cn)(void 0),zh=(0,xt.cn)(void 0);let Hh=function(e){return e.DeadZone="deadZones",e.VehicleParkingZone="vehicleParkingZones",e.ActiveZones="activeZones",e}({});const Bh=[Hh.DeadZone,Hh.VehicleParkingZone,Hh.ActiveZones],Wh=e=>{switch(e){case Hh.DeadZone:return"blue";case Hh.VehicleParkingZone:return"emerald";case Hh.ActiveZones:return"orange";default:return"blue"}};const Gh=e=>({deadZones:[...e.deadZones||[]],vehicleParkingZones:[...e.vehicleParkingZones||[]],activeZones:[...e.activeZones||[]]}),Kh=e=>{const t=[];return e.deadZones.map((e=>t.push({point:e,zoneType:Hh.DeadZone}))),e.vehicleParkingZones.map((e=>t.push({point:e,zoneType:Hh.VehicleParkingZone}))),e.activeZones.map((e=>t.push({point:e,zoneType:Hh.ActiveZones}))),t},Yh=(e,t,n)=>{if(!t)return"0";const a=parseInt(e),s=Bh.indexOf(t);let r=a;for(let i=0;i<s;i++)r+=n[Bh[i]].length;return String(r)},Qh=.03;const Xh=function(e){const{allZones:t,partialZone:n,selectedZone:a,imageUrl:s,imageResolution:r,canUpdateZone:i,updateImageResolution:o,onImageClick:l,onShapeClick:c}=e,[d,u]=(0,ur.KO)($h),[m,h]=(0,ur.KO)(zh),[x,p]=function(e,t,n){const a=[];e&&a.push(...e.map(((e,t)=>({points:e.point,color:String(t)===n?"yellow":Wh(e.zoneType),pointSize:"small",closed:!0}))));const s=[];return t&&t.length>1?a.push({points:t,pointSize:"small",color:"red",closed:!1}):t&&s.push(...t.map((e=>({point:e,color:"red",size:"small"})))),[a,s]}(t,n,a);return(0,H.jsx)("div",{className:"basis-4/5",children:(0,H.jsx)(fs,{polygons:x,markers:p,imgUrl:s,onClickImage:e=>{if(!r||!n)return;const t=e.currentTarget.getBoundingClientRect();u([t.width,t.height]),h([t.left,t.top]);const a=ds([t.width,t.height],[r[0],r[1]],[t.left,t.top],{point:[e.clientX,e.clientY]});l(a)},onClickShape:e=>{if(!(n&&r&&d&&m&&i))return;const t=ds([d[0],d[1]],[r[0],r[1]],[m[0],m[1]],{point:[e.clientX,e.clientY]});c(t)},onImageLoadCallback:(e,t,n)=>{o(e),u(t),h(n)}})})};const Jh=function(e){const{isLoading:t,onClickClear:n,onClickReset:a,onClickSave:s}=e;return(0,H.jsx)("div",{className:"mt-6 space-y-3",children:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{disabled:t,variant:"primary",block:!0,onClick:s,loading:t,onSideEffect:yt("save_camera_deadzones"),children:"Save"}),(0,H.jsx)(Q,{onClick:a,disabled:t,block:!0,onSideEffect:yt("reset_camera_deadzones"),children:"Reset"}),(0,H.jsx)(Q,{onClick:n,disabled:t,variant:"error",block:!0,onSideEffect:yt("clear_camera_deadzones"),children:"Clear Label"})]})})};const ex=function(e){const{zones:t,onClickReset:n,onClickClear:a,onClickSave:s,onNewZone:r,isLoading:i,selected:o,onSelect:l,onDeleteZone:c,partialZone:d,canUpdateZones:u,label:m}=e,h=function(e,t,n,a){return e.map(((e,s)=>({id:String(s),name:`${a} ${s}`,additional:n?(0,H.jsx)(Q,{variant:"icon",onClick:()=>t(String(s)),children:(0,H.jsx)(Yo.Z,{className:"w-5 "})}):void 0})))}(t,c,u,m),x=o?h.find((e=>e.id===o)):void 0;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{className:"mb-6",children:[(0,H.jsx)(he,{label:m,options:h,selected:x,onChange:e=>{l(e.id)}}),u&&(0,H.jsx)("div",{className:"mt-6",children:(0,H.jsx)(Q,{onClick:r,disabled:i,block:!0,children:d?"Labelling":(0,H.jsx)(cd.Z,{className:"w-5"})})})]}),u&&(0,H.jsx)(Jh,{isLoading:i,onClickSave:s,onClickReset:n,onClickClear:a})]})};const tx=function(e){const{cam:t,isDisabled:n}=e,[s,r]=(0,a.useState)(Hh.DeadZone),i=Ge(j(),"camera:update/deadzone"),o=Ge(j(),"camera:update/vehicleparkingzone"),l=Ge(j(),"camera:update/activezone"),[c,d]=(0,ur.KO)(Vh),[u,m]=(0,a.useState)(),[h,x]=(0,a.useState)("0"),[p,g]=(0,a.useState)(Gh(t));(0,a.useEffect)((()=>{m(void 0)}),[t.id]);const f=xn(t.id,"deadzone",(()=>Le("Deadzones updated",{type:"success"}))),v=xn(t.id,"vehicleparkingzone",(()=>Le("Vehicle parking zones updated",{type:"success"}))),b=xn(t.id,"activezone",(()=>Le("Active zones updated",{type:"success"}))),y=function(e,t,n,a){return e===Hh.DeadZone?t:e===Hh.VehicleParkingZone?n:e===Hh.ActiveZones&&a}(s,i,o,l),k=()=>{y&&(m(void 0),g(Gh(t)))},w=()=>{y&&m([])},N=e=>()=>{void 0!==p[e]&&c&&y&&(e===Hh.DeadZone&&f.mutate({deadZones:{deadZones:[...p.deadZones],labellingResolution:c}}),e===Hh.VehicleParkingZone&&v.mutate({vehicleParkingZones:{vehicleParkingZones:[...p.vehicleParkingZones],labellingResolution:c}}),e===Hh.ActiveZones&&b.mutate({activeZones:{activeZones:[...p.activeZones],labellingResolution:c}}))},C=e=>t=>{const n=parseInt(t),a=[...p.deadZones],s=[...p.vehicleParkingZones],r=[...p.activeZones];e===Hh.DeadZone?a.splice(n,1):e===Hh.VehicleParkingZone?s.splice(n,1):e===Hh.ActiveZones&&r.splice(n,1),g({deadZones:a,vehicleParkingZones:s,activeZones:r});const i=n>0?String(n-1):"0";x(i)},S=Kh(p),T=[{id:Hh.DeadZone,title:"Dead Zone"},{id:Hh.VehicleParkingZone,title:"Vehicle Parking Zone"},{id:Hh.ActiveZones,title:"Active zones"}];return(0,H.jsxs)(H.Fragment,{children:[n&&(0,H.jsx)(B,{type:"info",children:"Editing special zones is being handled at camera level and cannot be edited here. This config can be updated in respective location. Please contact admin for more info."}),(0,H.jsxs)("div",{tabIndex:n?-1:0,className:(0,z.Z)("relative flex flex-col gap-6 lg:flex-row",n&&"pointer-events-none"),children:[n&&(0,H.jsx)("div",{tabIndex:-1,className:"absolute inset-0 z-10 rounded-lg bg-gray-500/30 bg-opacity-50"}),(0,H.jsx)(Xh,{allZones:S,canUpdateZone:y,imageResolution:c,updateImageResolution:d,imageUrl:t.imageUrl,partialZone:u,selectedZone:Yh(h,s,p),onImageClick:e=>{const t=function(e,t){const n=Object.assign({},e,{point:[...e.point]});if(t){const[a,s]=t,r=a*Qh,i=s*Qh,[o,l]=e.point;a-o<=r?n.point[0]=a:o<=r&&(n.point[0]=0),s-l<=i?n.point[1]=s:l<=i&&(n.point[1]=0)}return n}(e,c);m((e=>e?[...e,t.point]:[t.point]))},onShapeClick:e=>{var t,n,a;u&&u.length>2&&(t=e.point,n=u[0],a=10,Math.abs(t[0]-n[0])<=a&&Math.abs(t[1]-n[1])<=a)&&((e=>{const t=Object.assign({},p);s===Hh.DeadZone?t.deadZones.push(e):s===Hh.VehicleParkingZone?t.vehicleParkingZones.push(e):s===Hh.ActiveZones&&t.activeZones.push(e),g(t),s&&x(String(t[s].length-1))})(u),m(void 0))}}),(0,H.jsx)("div",{className:"dark:divide-ondark-line-2 divide-onlight-line-2 basis-1/5 space-y-6 divide-y",children:T.map((e=>{var t,n,a;return(0,H.jsx)("div",{className:"w-full self-start pt-2",children:(0,H.jsx)(Ca,{title:e.title,isExpanded:s===e.id,onToggle:(a=e.id,()=>{k(),x("0"),r(a===s?void 0:a)}),tagColor:Wh(e.id),children:(0,H.jsx)(ex,{label:e.title,zones:null!=(t=p[e.id])?t:[],partialZone:u,isLoading:f.isLoading||v.isLoading||b.isLoading,selected:h,onClickReset:k,onClickClear:(n=e.id,()=>{m(void 0);const e=Object.assign({},p);e[n]=[],g(e)}),onClickSave:N(e.id),onSelect:x,onDeleteZone:C(e.id),onNewZone:w,canUpdateZones:y})})},e.id)}))})]})]})};const nx=function(e){const{cameraId:t,cameraTimeZone:n}=e,[s,r]=(0,a.useState)(new Date),[i,o]=(0,a.useState)(!1),[l,c]=(0,a.useState)(""),[d,u]=(0,a.useState)([]),[m]=(0,a.useState)((()=>{const e=new Date,t=new Date;return t.setDate(t.getDate()-Nh),{start:t.getTime(),end:e.getTime()}})),[h,x]=(0,a.useState)();un(t,Math.floor(s.getTime()/1e3),(e=>{c(e)})),function(e,t,n,a){const s=new Request(`/v2/orm/camera/alarmMarkers/${e}?startTS=${t}&endTS=${n}`);St(s,{responseModifier:async e=>await e.json(),onSuccess:a})}(t,m.start,m.end,(e=>u(e)));const p=(0,a.useCallback)((e=>{o(!0),y.uT(String(e))}),[]),g=(0,a.useCallback)((e=>r(e)),[]),f=(0,a.useCallback)(((e,t)=>x({hls:e,videoRef:t})),[]);return(0,H.jsxs)(H.Fragment,{children:[i&&(0,H.jsx)("div",{className:"pb-1",children:(0,H.jsx)(B,{children:"Unable to load current playback. Try selecting an alternative date / time."})}),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(pi,{onInit:f,videoPath:l,lockAspectRatio:!0,onError:p,timeZone:n,authRequired:!0,isPlayback:!0,controlsList:["noVideoTimeline"]}),h&&(0,H.jsx)(Uo,{timeZone:n||"UTC",cameraHlsAndRef:h,requestNewVideoUrl:g,playbackPeriod:Nh,onRetry:()=>o(!1),playbackMotionMarkers:d})]})]})};function ax(e){const{name:t,value:n,onClickUpdate:a}=e;return n?(0,H.jsxs)("div",{className:"pt-6 sm:flex",children:[(0,H.jsx)("dt",{className:"font-medium sm:w-64 sm:flex-none sm:pr-6",children:t}),(0,H.jsxs)("dd",{className:"mt-1 flex justify-between gap-x-6 sm:mt-0 sm:flex-auto",children:[(0,H.jsx)("div",{children:n}),(0,H.jsx)(Q,{variant:"link",onClick:a,children:"Update"})]})]}):(0,H.jsxs)("div",{className:"flex justify-between gap-x-6 pt-6",children:[(0,H.jsx)("div",{className:"font-medium",children:t}),(0,H.jsx)(Q,{variant:"link",onClick:a,children:"Update"})]})}function sx(e){const{name:t,value:n=!1,onToggle:a}=e;return(0,H.jsxs)("div",{className:"flex justify-between gap-x-6 pt-6",children:[(0,H.jsx)("div",{className:"font-medium",children:t}),(0,H.jsx)(we,{enabled:n,onChange:a})]})}function rx(e){const{name:t,infoText:n,children:a}=e;return(0,H.jsxs)("div",{children:[(0,H.jsx)("h2",{className:"text-base font-semibold leading-7",children:t}),n&&(0,H.jsx)("p",{className:"text-onlight-text-2 dark:text-ondark-text-2 mt-1 text-sm leading-6",children:n}),(0,H.jsx)("dl",{className:"dark:divide-ondark-line-1 divide-onlight-line-1 border-onlight-line-2 dark:border-ondark-line-2 mt-6 space-y-6 divide-y border-t text-sm leading-6",children:a})]})}const ix=[{id:"arm",name:"Arm"},{id:"disarm",name:"Disarm"}],ox="YYYY-MM-DDTHH:mm";const lx=function(e){const{value:t,minDate:n,onChange:a}=e,{status:s,startTime:r,endTime:i}=t;return(0,H.jsxs)("div",{className:"space-y-4",children:[(0,H.jsx)(ue,{label:"Status",items:ix,id:e=>e.id,displayValue:e=>e.name,onChange:e=>a(Object.assign({},t,{status:e})),value:s}),(0,H.jsx)(ae,{type:"datetime-local",label:"Start Time",value:r,min:n,onChange:e=>a(Object.assign({},t,{startTime:e.target.value}))}),(0,H.jsx)(ae,{type:"datetime-local",label:"End Time",value:i,min:r,onChange:e=>a(Object.assign({},t,{endTime:e.target.value}))})]})};const cx=function(e){const{isArming:t,fromDate:n,toDate:a}=e;return(0,H.jsxs)("div",{className:"leading-8",children:["You are about to"," ",(0,H.jsx)("span",{className:(0,z.Z)("font-bold",t?"text-status-green":"text-status-red"),children:t?"Arm":"Disarm"})," ","the camera from"," ",(0,H.jsx)("span",{className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 whitespace-pre rounded-md py-1 px-2 font-bold",children:n.toLocaleString()})," ","to"," ",(0,H.jsx)("span",{className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 whitespace-pre rounded-md py-1 px-2 font-bold",children:a.toLocaleString()}),". Are you sure?"]})};function dx(e){const{cameraId:t,isArmed:n,onClose:s}=e,[r,i]=(0,a.useState)(!1),o=co()(),[l,c]=(0,a.useState)({status:n?ix[1]:ix[0],startTime:o.format(ox),endTime:o.add(1,"hour").format(ox)}),d=function(e,t){const n=new Request(`/v2/orm/camera/${e}/armedStatus`,{method:"PATCH"});return Ft(n,{onSuccessInvalidationKeys:[["cameras"]],onSuccess:t})}(t,(()=>{Le("Camera is "+("arm"===l.status.id?"armed!":"disarmed!"),{type:"success"}),s()})),u=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("span",{className:"mr-2",children:r?(0,H.jsx)(Q,{loading:d.isLoading,disabled:d.isLoading,variant:"primary",onClick:()=>{d.mutate({isArmed:"arm"===l.status.id,activation_window_start:co()(l.startTime).unix(),activation_window_end:co()(l.endTime).unix()})},children:"Confirm"}):(0,H.jsx)(Q,{variant:"primary",onClick:()=>i(!0),children:"Submit"})}),(0,H.jsx)(Q,{onClick:()=>{r?i(!1):s()},children:r?"Back":"Cancel"})]});return(0,H.jsx)(ce,{open:!0,onClose:s,title:"Arm/Disarm Camera",footer:u,children:(0,H.jsxs)("div",{className:"w-[28rem] px-8 py-4",children:[d.isError&&(0,H.jsx)(B,{type:"error",children:d.error.message}),r?(0,H.jsx)(cx,{isArming:"arm"===l.status.id,fromDate:co()(l.startTime).toDate(),toDate:co()(l.endTime).toDate()}):(0,H.jsx)(lx,{value:l,minDate:o.format(ox),onChange:c})]})})}const ux=[{id:yh.SPECIAL_ZONES,name:"Special Zones"},{id:yh.LIVE,name:"Live"},{id:yh.PLAYBACK,name:"Playback"},{id:yh.SETTINGS,name:"Settings"}],mx=e=>{const[t,n]=e.split(":").map(Number);return 60*t+n};const hx=function(e){const{startTime:t,endTime:n,plusOneDay:a,timezone:s}=e;return(0,H.jsxs)("div",{className:"leading-8",children:["You are about to update automated talkdown window of the camera from"," ",(0,H.jsxs)("span",{className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 whitespace-pre rounded-md py-1 px-2 font-bold",children:[t," ",s]})," ","to"," ",(0,H.jsxs)("span",{className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 whitespace-pre rounded-md py-1 px-2 font-bold",children:[n," ",a&&"(Next Day) "," ",s]}),". Are you sure?"]})};const xx=function(e){const{onClose:t,open:n,camera:s,timezone:r}=e,[i,o]=(0,a.useState)(!1),[l,c]=(0,a.useState)(s.automatedTalkdownStartTimeUTC||""),[d,u]=(0,a.useState)(s.automatedTalkdownEndTimeUTC||""),m=mx(l)>mx(d),h=mn(s.id,(()=>{Le(`Camera ${s.name} automated talkdown window updated!`,{type:"success"}),t()})),x=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{onClick:()=>{i?o(!1):t()},children:i?"Back":"Cancel"}),(0,H.jsx)("span",{children:i?(0,H.jsx)(Q,{variant:"primary",onClick:()=>{""!==l.trim()&&""!==d.trim()?h.mutate({automatedTalkdownEndTimeUTC:d,automatedTalkdownStartTimeUTC:l}):Le("Please provide valid start and end times",{type:"error"})},loading:h.isLoading,onSideEffect:yt("update_automated_talkdown_time"),children:"Submit"}):(0,H.jsx)(Q,{variant:"primary",onClick:()=>o(!0),children:"Save"})})]});return(0,H.jsx)(ce,{title:"Automated Talkdown",open:n,onClose:t,footer:x,children:(0,H.jsxs)("div",{className:"mx-4 flex max-w-[28rem] flex-col px-4 py-4",children:[(0,H.jsxs)(B,{type:"info",children:["All times are referenced in ",r," timezone"]}),(0,H.jsx)("div",{className:"my-4 flex flex-row gap-4 py-4",children:i?(0,H.jsx)(hx,{startTime:l,endTime:d,plusOneDay:m,timezone:r}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"w-32 ",children:(0,H.jsx)(ae,{label:"Start time",onChange:e=>{c(e.target.value)},type:"time",value:l,required:!0})}),(0,H.jsxs)("div",{className:"relative w-32",children:[m&&(0,H.jsx)("span",{className:"text-onlight-text-3 dark:text-ondark-text-2 absolute top-1 right-2 text-xs",children:"+1 Day"}),(0,H.jsx)(ae,{label:"End time",onChange:e=>{u(e.target.value)},type:"time",value:d})]})]})})]})})};function px(e){var t;const{camera:n}=e,[s,r]=(0,a.useState)(!1),[i,o]=(0,a.useState)(!1),l=Je(),c=et(),[d,u]=function(e,t){const[n,s]=(0,a.useState)(t),r=hn(e,(()=>{Le(`Playback ${n?"enabled":"disabled"}!`,{type:"success"})}),(()=>{Le("Update failed!",{type:"error"}),s(!n)})),i=(0,a.useCallback)((()=>{s(!n),setTimeout((()=>{r.mutate({enablePlayback:!n})}))}),[r,n]);return[n,i]}(n.id,null!=(t=n.isPlaybackEnabled)&&t),m="UTC",h=n.armStatus.endTimeText?n.armStatus.endTimeText:n.armStatus.isArmed?(0,H.jsx)("span",{className:"text-status-green",children:"Armed"}):(0,H.jsx)("span",{className:"text-status-red",children:"Disarmed"});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(rx,{name:"Actions",children:[c?(0,H.jsx)(sx,{name:"Playback",value:d,onToggle:u}):null,l?(0,H.jsx)(ax,{name:"Status",value:h,onClickUpdate:()=>r(!0)}):null,c?(0,H.jsx)(ax,{name:"Automated Talkdown",value:(()=>{if(!n.automatedTalkdownEndTimeUTC&&!n.automatedTalkdownStartTimeUTC)return(0,H.jsx)("span",{children:"As per location's monitoring window"});const e=n.automatedTalkdownStartTimeUTC?n.automatedTalkdownStartTimeUTC:"",t=n.automatedTalkdownEndTimeUTC?n.automatedTalkdownEndTimeUTC:"",a=mx(e)>mx(t),s=""!==e?e:"NOT SET",r=""!==t?t:"NOT SET";return(0,H.jsxs)("div",{className:"flex flex-col",children:[(0,H.jsxs)("span",{children:["Start Time: ",s," ",n.automatedTalkdownStartTimeUTC&&m]}),(0,H.jsxs)("span",{children:["End Time: ",r," ",n.automatedTalkdownEndTimeUTC&&m," ",a&&"(Next Day)"]})]})})(),onClickUpdate:()=>o(!0)}):null]}),s&&(0,H.jsx)(dx,{cameraId:n.id,isArmed:n.armStatus.isArmed,onClose:()=>r(!1)}),i&&(0,H.jsx)(xx,{open:i,camera:n,timezone:m,onClose:()=>o(!1)})]})}const gx=function(e){var t;const{camera:n}=e,a=n.audioDeviceMapped&&n.audioDevices&&n.audioDevices.length>0;return(0,H.jsx)(rx,{name:"Associated Audio Devices",children:a?(0,H.jsx)("ul",{className:"",children:null==(t=n.audioDevices)?void 0:t.map((e=>(0,H.jsxs)("li",{className:"flex items-center gap-6 space-x-4 py-4",children:[(0,H.jsxs)("div",{className:"flex items-center gap-x-3",children:[(0,H.jsx)("div",{className:"dark:text-ondark-text-2 text-onlight-text-3 flex-none rounded-full p-1",children:(0,H.jsx)("div",{className:"h-2 w-2 rounded-full bg-current"})}),(0,H.jsx)("h2",{className:"min-w-0 text-sm font-semibold leading-6",children:e.url})]}),(0,H.jsx)(re,{type:"info",children:e.deviceType})]},e.id)))}):(0,H.jsx)("div",{className:"pt-4",children:"No current audio device integration."})})};function fx(e){const{cameraId:t,name:n,displayName:s,currentValue:r="",onClose:i}=e,[o,l]=(0,a.useState)(r),c=hn(t,(()=>{Le(`Camera ${s} updated!`,{type:"success"}),i()})),d=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("span",{className:"mr-2",children:(0,H.jsx)(Q,{variant:"primary",onClick:()=>{c.mutate({[n]:o})},children:"Submit"})}),(0,H.jsx)(Q,{onClick:i,children:"Cancel"})]});return(0,H.jsx)(ce,{open:!0,onClose:i,title:`Update Camera ${s}`,footer:d,children:(0,H.jsxs)("div",{className:"w-[28rem] space-y-2 px-8 py-4",children:[c.isError&&(0,H.jsx)(B,{type:"error",children:c.error.message}),(0,H.jsx)(ae,{type:"text",label:s,value:o,onChange:e=>l(e.target.value)})]})})}function vx(e){const{cameraId:t,onClose:n,passwordFile:a}=e;return(0,H.jsx)(fx,{cameraId:t,name:"passwordFilePath",displayName:"Password File Path",currentValue:a,onClose:n})}function jx(e){const{cameraId:t,onClose:n,userId:a}=e;return(0,H.jsx)(fx,{cameraId:t,name:"userId",displayName:"User ID",currentValue:a,onClose:n})}function bx(e){const{camera:t}=e,[n,s]=(0,a.useState)(!1),[r,i]=(0,a.useState)(!1);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(rx,{name:"Credentials",children:[(0,H.jsx)(ax,{name:"User ID",value:t.camUserId,onClickUpdate:()=>s(!0)}),(0,H.jsx)(ax,{name:"Password File Path",value:t.camPasswordFilePath,onClickUpdate:()=>i(!0)})]}),n&&(0,H.jsx)(jx,{cameraId:t.id,userId:t.camUserId,onClose:()=>s(!1)}),r&&(0,H.jsx)(vx,{cameraId:t.id,passwordFile:t.camPasswordFilePath,onClose:()=>i(!1)})]})}function yx(e){const{onConfirm:t,onClose:n}=e,a=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("span",{className:"mr-2",children:(0,H.jsx)(Q,{variant:"error",onClick:t,children:"Confirm"})}),(0,H.jsx)(Q,{onClick:n,children:"Cancel"})]});return(0,H.jsx)(ce,{title:"Confirmation",open:!0,onClose:n,footer:a,children:(0,H.jsx)("div",{className:"w-96 px-8 py-4 text-sm",children:"Do you really want to delete this camera?"})})}function kx(e){const{children:t}=e;return(0,H.jsx)("div",{className:"pt-6",children:t})}const wx="No longer want to use this camera for monitoring? You can delete the camera here.";function Nx(e){const{camera:t,onDeleted:n}=e,[s,r]=(0,a.useState)(!1),i=hn(t.id,(()=>{Le(`${t.name} deleted!`,{type:"success"}),n()}),(()=>{Le(`Failed to delete ${t.name}!`,{type:"error"})}),!0);return(0,H.jsx)(rx,{name:"Delete",infoText:wx,children:(0,H.jsxs)(kx,{children:[(0,H.jsx)(Q,{variant:"error",onClick:()=>r(!0),loading:i.isLoading,disabled:i.isLoading,children:"Delete Camera"}),s&&(0,H.jsx)(yx,{onClose:()=>r(!1),onConfirm:()=>{r(!1),i.mutate({isEnabled:!1})}})]})})}function Cx(e){const{cameraId:t,onClose:n,livestreamUrl:a}=e;return(0,H.jsx)(fx,{cameraId:t,name:"livestreamUrl",displayName:"Livestream URL",currentValue:a,onClose:n})}const Sx=function(e){const{cameraId:t,locationId:n,onClose:s}=e,[r,i]=(0,a.useState)(n),o=hn(t,(()=>{Le("Camera location updated!",{type:"success"}),s()})),l=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("span",{className:"mr-2",children:(0,H.jsx)(Q,{variant:"primary",onClick:()=>{o.mutate({locationId:r})},loading:o.isLoading,children:"Submit"})}),(0,H.jsx)(Q,{onClick:s,children:"Cancel"})]});return(0,H.jsx)(ce,{open:!0,onClose:s,title:"Update Camera Location",footer:l,children:(0,H.jsxs)("div",{className:"w-[28rem] space-y-2 px-8 py-4",children:[o.isError&&(0,H.jsx)(B,{type:"error",children:o.error.message}),(0,H.jsx)(Fi,{locationId:r,onChange:e=>{i(e)},label:"Location"})]})})};function Tx(e){const{cameraId:t,onClose:n,name:a}=e;return(0,H.jsx)(fx,{cameraId:t,name:"name",displayName:"Name",currentValue:a,onClose:n})}function Ex(e){const{cameraId:t,onClose:n,rtspUrl:a}=e;return(0,H.jsx)(fx,{cameraId:t,name:"rtspUrl",displayName:"RTSP URL",currentValue:a,onClose:n})}function Ax(e){var t;const{camera:n}=e,[s,r]=(0,a.useState)(!1),[i,o]=(0,a.useState)(!1),[l,c]=(0,a.useState)(!1),[d,u]=(0,a.useState)(!1);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(rx,{name:"Details",children:[(0,H.jsx)(ax,{name:"Name",value:n.name,onClickUpdate:()=>r(!0)}),(0,H.jsx)(ax,{name:"RTSP URL",value:n.rtspUrl,onClickUpdate:()=>o(!0)}),(0,H.jsx)(ax,{name:"Livestream URL",value:n.livestreamUrl,onClickUpdate:()=>c(!0)}),(0,H.jsx)(ax,{name:"Location",value:(()=>{if(!n.location)return"Not specified";const{name:e,city:t,state:a,country:s}=n.location;return[e,t,a,s].filter(Boolean).join(", ")})(),onClickUpdate:()=>u(!0)})]}),s&&(0,H.jsx)(Tx,{cameraId:n.id,name:n.name,onClose:()=>r(!1)}),i&&(0,H.jsx)(Ex,{cameraId:n.id,rtspUrl:n.rtspUrl,onClose:()=>o(!1)}),l&&(0,H.jsx)(Cx,{cameraId:n.id,livestreamUrl:n.livestreamUrl,onClose:()=>c(!1)}),d&&(0,H.jsx)(Sx,{cameraId:n.id,locationId:String(null==(t=n.location)?void 0:t.id)||"",onClose:()=>u(!1)})]})}function _x(e){const{children:t}=e;return(0,H.jsx)("div",{className:"mx-auto max-w-2xl space-y-16 sm:space-y-20",children:t})}function Ix(e){const{camera:t,onDeletedCamera:n}=e,a=et(),s=Je();return(0,H.jsxs)(_x,{children:[(a||s)&&(0,H.jsx)(px,{camera:t}),a&&(0,H.jsx)(Ax,{camera:t}),(0,H.jsx)(gx,{camera:t}),a&&(0,H.jsx)(bx,{camera:t}),a&&(0,H.jsx)(Nx,{camera:t,onDeleted:n})]})}function Lx(e){var t,n,s;const{camId:r,camType:i,camera:o,onDeletedCamera:l}=e,c=Je(),d=et(),u=(0,a.useMemo)((()=>{let e=ux;return c||d||(e=e.filter((e=>e.id!==yh.SETTINGS))),i!==bh.RTSP&&(e=e.filter((e=>e.id!==yh.LIVE&&e.id!==yh.PLAYBACK))),o.isPlaybackEnabled||(e=e.filter((e=>e.id!==yh.PLAYBACK))),e}),[i,o.isPlaybackEnabled,c,d]),[m,h]=(0,a.useState)(u[0].id),[x,p]=(0,a.useState)(!1);return(0,H.jsxs)("div",{className:"px-4",children:[(0,H.jsxs)("div",{className:"dark:border-dark-border-bg mb-2 flex items-center justify-between border-b border-gray-300 py-2",children:[(0,H.jsxs)("div",{className:"flex flex-col justify-between gap-1",children:[(0,H.jsx)("h2",{className:"text-onlight-text-1 dark:text-ondark-text-1 pt-1 text-base",children:o.name}),(0,H.jsx)("div",{className:"text-onlight-text-2 dark:text-ondark-text-2 inline-flex items-center text-xs",children:o.location&&(0,H.jsx)("span",{children:null==(t=o.location)?void 0:t.name})})]}),(0,H.jsx)(Uh,{onShare:()=>{p(!0)}}),x&&(0,H.jsx)(Bo,{resourceId:o.id,resourceType:"live-view",onClose:()=>p(!1)})]}),(0,H.jsx)(xe,{items:u,activeTabId:m,onChange:e=>h(e)}),(0,H.jsxs)("div",{className:"py-6",children:[m===yh.SPECIAL_ZONES&&(0,H.jsx)(tx,{cam:o,isDisabled:!!o.location&&!(null!=(n=o.location)&&n.isDeadzoneEnabled)}),m===yh.LIVE&&(0,H.jsxs)("div",{children:[o.audioDeviceMapped&&(0,H.jsx)(Br,{cameraId:r,onTalkdown:e=>{kt("submit_camera_details_audio_talkdown",{camera_id:e})},cameraName:o.name}),(0,H.jsx)(Mi,{camera:o})]}),m===yh.PLAYBACK&&(0,H.jsx)(nx,{cameraId:r,cameraTimeZone:(null==(s=o.location)?void 0:s.timezone)||"UTC"}),m===yh.SETTINGS&&(0,H.jsx)(Ix,{camera:o,onDeletedCamera:l})]})]})}const Rx=function(e){const{camId:t,camType:n,onDeletedCamera:a}=e,{data:s,isFetching:r,isError:i,error:o}=rn(t);return(0,H.jsxs)(H.Fragment,{children:[r&&!s&&(0,H.jsx)("div",{className:"flex h-full w-full items-center justify-center",children:(0,H.jsx)(ys,{})}),s&&(0,H.jsx)(Lx,{camId:t,camType:n,camera:s,onDeletedCamera:a}),i&&(0,H.jsx)(B,{type:"error",children:o.message})]})},Dx=(0,xt.cn)(1),Px=(0,xt.cn)(30),Mx=(0,pt.O4)("cameraFilters",{location:{values:[],negative:!1}});function Ox(e){const{value:t,onChange:n}=e;return(0,H.jsxs)("label",{className:"grid h-14 grid-cols-12 items-center justify-between",children:[(0,H.jsx)("span",{className:"col-span-4",children:"Location"}),(0,H.jsx)("span",{className:"col-span-8",children:(0,H.jsx)(Fi,{locationId:t,onChange:n})})]})}function Fx(e){const{label:t,value:n,onChange:a}=e;return(0,H.jsxs)("label",{className:"grid h-14 grid-cols-12 items-center justify-between",children:[(0,H.jsx)("span",{className:"col-span-4",children:t}),(0,H.jsx)("span",{className:"col-span-8",children:(0,H.jsx)(ae,{type:"text",value:n,onChange:e=>a(e.target.value)})})]})}function Zx(e){const{label:t,value:n,onChange:a}=e;return(0,H.jsxs)("label",{className:"grid h-14 grid-cols-12 items-center justify-between",children:[(0,H.jsx)("span",{className:"col-span-4",children:t}),(0,H.jsx)("span",{className:"col-span-8 justify-self-end",children:(0,H.jsx)(we,{enabled:n,onChange:a})})]})}function qx(e){const{tenantId:t}=(0,r.UO)(),{onClose:n}=e,s=j().tenant.id,[i,o]=(0,a.useState)({enableMotionDetection:!0,enablePlayback:!1,name:"",passwordFilePath:"/secure/rtsp_password",userId:"",isEnabled:!0,rtspUrl:"",livestreamUrl:"",tenantId:null!=t?t:s,locationId:""}),l=sn((()=>{Le(`${i.name} added!`,{type:"success"}),n()})),c=i.name&&i.userId&&i.passwordFilePath&&i.rtspUrl,d=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("span",{className:"mr-2",children:(0,H.jsx)(Q,{variant:"primary",onClick:()=>{l.mutate(i)},disabled:!c||l.isLoading,loading:l.isLoading,children:"Submit"})}),(0,H.jsx)(Q,{onClick:n,children:"Cancel"})]});return(0,H.jsx)(ce,{title:"Add New Camera",footer:d,open:!0,onClose:n,children:(0,H.jsxs)("div",{className:"dark:divide-ondark-line-1 divide-onlight-line-1 w-[36rem] divide-y px-8 py-4 text-sm",children:[l.isError&&(0,H.jsx)(B,{type:"error",children:l.error.message}),(0,H.jsx)(Fx,{label:"Name*",value:i.name,onChange:e=>o(Object.assign({},i,{name:e}))}),(0,H.jsx)(Fx,{label:"User ID*",value:i.userId,onChange:e=>o(Object.assign({},i,{userId:e}))}),(0,H.jsx)(Fx,{label:"Password File Path*",value:i.passwordFilePath,onChange:e=>o(Object.assign({},i,{passwordFilePath:e}))}),(0,H.jsx)(Fx,{label:"RTSP URL*",value:i.rtspUrl,onChange:e=>o(Object.assign({},i,{rtspUrl:e}))}),(0,H.jsx)(Fx,{label:"Livestream URL",value:i.livestreamUrl,onChange:e=>o(Object.assign({},i,{livestreamUrl:e}))}),(0,H.jsx)(Ox,{value:i.locationId,onChange:e=>o(Object.assign({},i,{locationId:e}))}),(0,H.jsx)(Zx,{label:"Motion Detection",value:i.enableMotionDetection,onChange:e=>o(Object.assign({},i,{enableMotionDetection:e}))}),(0,H.jsx)(Zx,{label:"Playback",value:i.enablePlayback,onChange:e=>o(Object.assign({},i,{enablePlayback:e}))})]})})}const Ux=function(e){const{isLoading:t,onClickOpenFilterPanel:n,isDefault:s,onSearch:r}=e,[i,o]=(0,a.useState)(!1),l=Ge(j(),"camera:add"),[c,d]=(0,a.useState)(""),u=R(c,400);return(0,a.useEffect)((()=>{r(u)}),[u,r]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{className:"flex flex-shrink-0 flex-col gap-4  py-1 pr-4 pl-1",children:[(0,H.jsxs)("div",{className:"flex flex-row items-center justify-between",children:[(0,H.jsxs)("div",{className:"flex flex-row items-center gap-4",children:[(0,H.jsx)(Q,{onClick:()=>o(!0),children:"Add Camera"}),t&&(0,H.jsx)(K,{})]}),(0,H.jsx)("div",{className:"",children:(0,H.jsx)(Q,{variant:"icon",onClick:n,badge:!s,children:(0,H.jsx)(_d.Z,{className:"dark:text-ondark-text-2 h-5 w-5"})})})]}),(0,H.jsx)("div",{className:" flex flex-row items-start justify-start gap-4",children:(0,H.jsx)(ae,{label:"",onChange:e=>{d(e.target.value)},value:c,type:"search",placeholder:"Search camera..."})})]}),l&&i&&(0,H.jsx)(qx,{onClose:()=>o(!1)})]})};function Vx(e){return!(e.location.values.length>0)}function $x(e,t){if(!e||!t||t.length<=1)return;const n=t.findIndex((t=>t.id===e));return-1!==n?n===t.length-1?t[0].id:t[n+1].id:void 0}const zx=nt(ht((function(e){var t;const{tenantIds:n}=e,[s,r]=(0,ur.KO)(Dx),[i]=(0,ur.KO)(Px),[o,l]=(0,Ss.lr)(),c=o.get("camId"),[d,u]=(0,a.useState)(""),[m,h]=(0,a.useState)((()=>c||void 0)),[x,p]=(0,a.useState)(),[g,f]=(0,a.useState)(0),[v,j]=(0,ur.KO)(Mx),[b,y]=(0,a.useState)(!1),{isFetching:k,isError:w,error:N,data:C}=on(function(e,t,n,a,s){const r=new URLSearchParams;return r.append("page",String(e)),r.append("pageSize",String(t)),n.location.values.length>0&&r.append("locations",n.location.values.map((e=>e.name)).join(Yn)),s&&s.length>0&&r.append("name",s),a&&r.append("tenants",a.join(Yn)),r.toString()}(s,i,v,n,d)),S=(0,a.useCallback)((e=>{h(e.id),p($x(e.id,null==C?void 0:C.items)),l([["camId",e.id]])}),[null==C?void 0:C.items,l]);(0,a.useEffect)((()=>{if(C){const{total:e}=C;f(e)}}),[C]);const T=null==C||null==(t=C.items.find((e=>e.id===m)))?void 0:t.integrationType;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(Hs,{initialLeftWidth:360,children:[(0,H.jsxs)(H.Fragment,{children:[w&&(0,H.jsx)("div",{className:"mb-2",children:(0,H.jsx)(B,{type:"error",children:N.message})}),(0,H.jsx)(Ux,{onClickOpenFilterPanel:()=>y(!0),isDefault:Vx(v),isLoading:k,onSearch:e=>{u(e)}}),(0,H.jsx)("div",{className:"py-4 pr-4 pl-1",children:(0,H.jsx)(Ri,{items:(null==C?void 0:C.items)||[],total:g,page:s,pageSize:i,onChangePage:r,renderListItem:e=>(0,H.jsx)(Th,{camera:e,selected:e.id===m,onClick:()=>S(e)},e.id)})})]}),m?(0,H.jsx)(Rx,{camId:m,camType:T,onDeletedCamera:()=>{h(x),p($x(x,null==C?void 0:C.items))}},m):(0,H.jsxs)("div",{className:"text-onlight-text-3 dark:text-ondark-text-3 border-onlight-line-2 dark:border-ondark-line-2 ml-4 flex h-full flex-col items-center justify-center border-2 border-dashed",children:[(0,H.jsx)(qh.Z,{className:"text-onlight-text-3 dark:text-ondark-text-3 h-8 w-8"}),(0,H.jsx)("div",{children:"Select a camera to check its details"})]})]}),(0,H.jsx)(wd,{open:b,title:"Camera Filters",filterConfigs:Ch,initialFilterValues:v,trackingEventNameApply:"apply_cam_filters",trackingEventNameReset:"reset_cam_filters",onClose:()=>y(!1),onApply:e=>{j(e),wt(e),r(1),y(!1)}})]})})),["camera:view"]);function Hx(){const[e,t]=(0,a.useState)(kh.LIST_VIEW),[n,s]=(0,Ss.lr)();return(0,H.jsxs)(mr,{title:"Cameras",fullWidth:!0,children:[(0,H.jsx)("div",{className:"flex justify-end gap-4 pb-1",children:(0,H.jsx)(we,{enabled:e===kh.GRID_VIEW,onChange:e=>{t(e?kh.GRID_VIEW:kh.LIST_VIEW),e&&s([])},DisabledIcon:fh.Z,EnabledIcon:vh.Z,label:"Multi Cam View"})}),(0,H.jsxs)(H.Fragment,{children:[e===kh.LIST_VIEW&&(0,H.jsx)(zx,{}),e===kh.GRID_VIEW&&(0,H.jsx)(Zh,{})]})]})}function Bx(e){const{sharedToken:t}=e,[n,s]=(0,a.useState)(void 0),r=cn();(0,a.useEffect)((()=>{r(t).then((e=>{s(e)})).catch((()=>{s(void 0)}))}),[r,t]);const i=`${window.location.origin}/shared/v2/camera/live/index.m3u8?sharedToken=${t}`;return(0,H.jsxs)("div",{className:"container mx-auto",children:[(0,H.jsxs)("h2",{className:"mt-2 flex items-center gap-2",children:[(0,H.jsx)("span",{className:"bg-status-red h-1.5 w-1.5 animate-pulse rounded-full"}),(0,H.jsx)("span",{children:"Live"})]}),void 0!==n?(0,H.jsx)(js,{mseUrl:n,lockAspectRatio:!0}):(0,H.jsx)(pi,{videoPath:i,lockAspectRatio:!0,controlsList:["noVideoTimeline","noPlaybackRate"]})]})}function Wx(){const[e]=(0,Ss.lr)(),t=e.get("sharedToken");return null===t?(0,H.jsx)(As,{message:"Missing shared token in shared location alarm URL"}):(0,H.jsx)(Bx,{sharedToken:t})}const Gx={name:"",description:""};const Kx=function(e){const{onClose:t}=e,[n,s]=(0,a.useState)(Gx),r=bn((()=>{Le("Door Group Added",{type:"success"}),t()})),i=Object.entries(n).some((([e,t])=>""===t)),o=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{r.mutate(n)},disabled:i||r.isLoading,onSideEffect:yt("submit_add_door_group"),loading:r.isLoading,children:"Submit"}),(0,H.jsx)(Q,{onClick:t,onSideEffect:yt("cancel_add_door_group"),children:"Cancel"})]}),l=e=>t=>{s((n=>Object.assign({},n,{[e]:"string"==typeof t?t:t.target.value})))};return(0,H.jsxs)(ce,{title:"Add New Door Group",open:!0,onClose:t,footer:o,children:[r.isError&&(0,H.jsx)("div",{className:"mt-4 px-8",children:(0,H.jsx)(B,{type:"error",children:r.error.message})}),(0,H.jsxs)("div",{className:"w-[36rem] space-y-4 p-8",children:[(0,H.jsx)(ae,{type:"text",label:"Name",value:n.name,onChange:l("name")}),(0,H.jsx)(pe,{rows:2,label:"Description",value:n.description,onChange:l("description")})]})]})},Yx=(0,xt.cn)({filters:{name:{values:[],negative:!1}},page:1,pageSize:20});function Qx(e){const{doorGroup:t,onRemoveDoor:n,deleteDisabled:a}=e;return(0,H.jsxs)("div",{className:"p-4 text-xs",children:[t.doors.map((e=>(0,H.jsxs)("div",{className:"m-2 inline-flex w-52 items-center justify-center gap-4 rounded-xl border-2 p-2 dark:border-gray-600",children:[(0,H.jsx)("span",{title:e.name,className:"overflow-hidden overflow-ellipsis whitespace-nowrap",children:e.name}),(0,H.jsx)(Q,{variant:"icon",onClick:n(e.id),title:"Remove door from door group",onSideEffect:yt("submit_remove_door_from_door_group"),disabled:a,loading:a,children:(0,H.jsx)($r.Z,{className:"h-4 w-4 hover:text-red-500"})})]},e.id))),0===t.doors.length&&(0,H.jsx)("div",{className:"text-center text-gray-600 dark:text-gray-400",children:"No doors attached to this door group"})]})}const Xx=function(e){const{doorGroup:t}=e,n=Cn((function(){Le("Removed door from door group successfully",{type:"success"})}));return(0,H.jsx)(Qx,{onRemoveDoor:e=>()=>{n.mutate({doors:[{door_group_id:String(t.id),doors:[e]}]})},doorGroup:t,deleteDisabled:n.isLoading})};const Jx=function(e){const{canAddDoorGroup:t,hasCustomFiltersApplied:n,isLoading:a,onClickAddLocation:s,onClickFilter:r}=e;return(0,H.jsxs)("div",{className:(0,z.Z)("dark:bg-dark-bg flex items-center border-b bg-white p-4 dark:border-0",t?"justify-between":"justify-end"),children:[t&&(0,H.jsxs)(Q,{variant:"primary",onClick:s,disabled:a,onSideEffect:yt("open_add_door_group_modal"),children:["Add Door Group",(0,H.jsx)("span",{className:"sr-only",children:"Add Door Group"})]}),(0,H.jsxs)(Q,{variant:"icon",badge:n,onClick:r,disabled:a,onSideEffect:yt("open_door_group_filters_panel"),children:[(0,H.jsx)("span",{className:"sr-only",children:"Open filters panel"}),(0,H.jsx)(_d.Z,{className:"h-5 w-5","aria-hidden":"true"})]})]})},ep={values:[],negative:!1};const tp=function(e){const{doorGroupFilterValue:t,onChangeDoorGroupFilterValue:n,onApplyFilters:a,onResetFilters:s}=e,r=Nn();return(0,H.jsxs)("div",{className:"space-y-6",children:[(0,H.jsx)("div",{className:"dark:divide-dark-border-bg dark:border-dark-border-bg divide-y border-t border-b",children:(0,H.jsx)(dd,{title:"Door Groups",content:(0,H.jsx)(Yc,{value:t,label:"Name",onChange:n,enableNegativeFilters:!0,getOptions:r}),hasFilterApplied:t.values.length>0})}),(0,H.jsx)(rd,{onApply:a,onReset:s,trackingEventNameApply:"apply_door_groups_filters",trackingEventNameReset:"reset_door_groups_filters"})]})};const np=function(e){const{open:t,onClose:n,filters:s,onApplyFilters:r}=e,[i,o]=(0,a.useState)(s.name);return(0,H.jsx)(_s,{title:"Door Groups Filters",open:t,onClose:n,children:(0,H.jsx)(tp,{doorGroupFilterValue:i,onChangeDoorGroupFilterValue:o,onApplyFilters:()=>{r({name:i}),n()},onResetFilters:()=>{o(ep)}})})};var ap=n(31380);const sp={id:-1,name:"New config",description:"New config description",updated:!0,enableTailgating:!1,processVideo:!1,activeLocalTimeStart:"00:00:00",activeLocalTimeEnd:"00:00:00",priority:Fe.default,activeDays:[!0,!0,!0,!0,!0,!0,!0],isNew:!0,deleted:!1,isEditing:!1,enableForAllAlarmType:!0,alarm_types:null,enableUnauthorizedEntryAlarm:!1},rp="Error modifying processing configurations. Please double check that configurations are valid.";function ip(e){const{isAdding:t,onStartAdd:n,onCancelAdd:s,onAddNew:r}=e,[i,o]=(0,a.useState)(sp);return(0,H.jsxs)(H.Fragment,{children:[!t&&(0,H.jsxs)(Q,{variant:"icon",onClick:n,children:[(0,H.jsx)(nh.Z,{className:"mr-2 h-5 w-5"}),"Add new processing config"]}),t&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{children:"New processing configuration"}),(0,H.jsx)(op,{onCancel:()=>{s(),o(sp)},config:i,onChange:e=>o((t=>Object.assign({},t,e))),onSubmit:()=>r(i)})]})]})}function op(e){const{config:t,onChange:n,onCancel:a,onSubmit:s}=e;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"mt-2",children:(0,H.jsx)(ae,{value:t.name,onChange:e=>n({name:e.currentTarget.value}),label:"Processing Configuration Name",type:"text"})}),(0,H.jsx)("div",{className:"mt-2",children:(0,H.jsx)(ae,{value:t.description,onChange:e=>n({description:e.currentTarget.value}),label:"Processing Configuration Description",type:"text"})}),(0,H.jsxs)("div",{className:"mt-2 flex gap-x-2",children:[(0,H.jsx)(Q,{variant:"icon",onClick:s,children:(0,H.jsxs)("span",{className:"flex gap-x-2",children:[(0,H.jsx)(Ce.Z,{className:"text-status-green h-5 w-5"}),"Submit"]})}),(0,H.jsx)(Q,{variant:"icon",onClick:a,children:(0,H.jsxs)("span",{className:"flex gap-x-2",children:[(0,H.jsx)(ap.Z,{className:"text-status-red h-5 w-5"}),"Cancel"]})})]})]})}var lp=n(59186);const cp=()=>Object.values(Fe),dp=e=>{switch(e){case Fe.ignore:return"Ignore";case Fe.P0:return"P0";default:return"Default"}};function up(e){const{expanded:t,onChange:n,config:a}=e;return(0,H.jsxs)("div",{className:(0,z.Z)("m-2 flex w-3/4 max-w-[58%] flex-wrap gap-x-4",!t&&"mb-4"),children:[(0,H.jsxs)("div",{className:"mt-1 overflow-x-auto text-base font-semibold leading-6",children:[a.isEditing?(0,H.jsx)(ae,{value:a.name,onChange:e=>n({name:e.currentTarget.value}),label:"Name",type:"text"}):(0,H.jsx)("span",{children:a.name}),(0,H.jsx)("div",{className:"text-onlight-text-2 mt-2 flex text-xs font-semibold leading-6",children:a.isEditing?(0,H.jsx)(ae,{value:a.description,onChange:e=>n({description:e.currentTarget.value}),label:"Description",type:"text"}):(0,H.jsx)("span",{children:a.description})})]}),(0,H.jsx)("div",{className:"mt-1 block max-w-[10rem] text-base font-semibold leading-6",children:a.isEditing?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"dark:text-ondark-text-2 text-onlight-text-2 mb-1 text-sm font-semibold",children:"Priority"}),(0,H.jsx)(Us,{getItems:cp,value:Fe[a.priority],onChange:e=>e&&n({priority:null!=e?e:Fe.default}),displayValue:dp})]}):(0,H.jsx)(re,{text:dp(a.priority),type:"info"})})]})}var mp=n(68438);function hp(e){const{time:t,title:n,onChange:a,tooltipText:s,isEditing:r}=e,i=new Date(`2000-01-01 ${t}`).toLocaleTimeString();return(0,H.jsxs)("label",{className:"my-2 inline",children:[(0,H.jsx)(ye,{text:s,children:(0,H.jsx)("span",{className:"dark:text-ondark-text-1 text-onlight-text-2 text-xs",children:n})}),r?(0,H.jsx)("input",{type:"time",step:"1",className:"dark:bg-ondark-bg-1 border-onlight-line-3 dark:border-ondark-line-3 dark:text-ondark-text-1 mt-1 block w-full rounded text-sm dark:[color-scheme:dark]",value:t,onChange:e=>a(e.currentTarget.value)}):(0,H.jsx)("div",{children:i})]})}function xp(e){const{value:t,title:n,onChange:a,isEditing:s}=e,r=s?a:()=>null;return(0,H.jsxs)("div",{className:"mt-4 flex w-full gap-x-4 px-6",children:[(0,H.jsx)("div",{className:"flex-none",children:(0,H.jsx)("span",{className:"text-onlight-text-2 dark:text-ondark-text-2 text-sm",children:n})}),(0,H.jsx)("div",{className:"text-onlight-text-3 dark:text-ondark-text-3 mb-4 flex w-full flex-wrap gap-x-4 text-sm",children:(0,H.jsx)(we,{enabled:t,onChange:r})})]})}const pp=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];function gp(e){const{config:t,onChange:n,isEditing:a}=e,s=pp.map(((e,n)=>{var a;return{id:e,value:null!=(a=t.activeDays.at(n))&&a,label:e}}));return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{className:"border-onlight-line-3 dark:border-ondark-line-3 mt-2 flex w-full flex-none gap-x-4 border-t px-6 pt-6",children:[(0,H.jsxs)("div",{className:"m-auto flex align-middle",children:[(0,H.jsx)("span",{className:"sr-only",children:"Client"}),(0,H.jsx)(ge.Z,{className:"text-onlight-text-2 dark:text-ondark-text-2 h-5 w-5","aria-hidden":"true"})]}),(0,H.jsxs)("div",{className:"flex w-full gap-x-8 text-sm font-medium leading-6",children:[(0,H.jsx)(hp,{title:"Active Start Time",time:t.activeLocalTimeStart,onChange:e=>n({activeLocalTimeStart:e}),isEditing:a,tooltipText:"Local Time at which this configuration will start being active"}),(0,H.jsx)(hp,{title:"Active End Time",time:t.activeLocalTimeEnd,onChange:e=>n({activeLocalTimeEnd:e}),isEditing:a,tooltipText:"Local Time at which this configuration will end being active"})]})]}),(0,H.jsxs)("div",{className:"mt-4 flex w-full gap-x-4 px-6",children:[(0,H.jsxs)("div",{className:"m-auto flex align-middle",children:[(0,H.jsx)("span",{className:"sr-only",children:"Active Days"}),(0,H.jsx)(mp.Z,{className:"text-onlight-text-2 dark:text-ondark-text-2 h-6 w-5","aria-hidden":"true"})]}),(0,H.jsx)("div",{className:"dark:text-ondark-text-1 text-onlight-text-1 m-auto flex w-full flex-wrap gap-x-4 text-sm",children:a?(0,H.jsx)(te,{items:s,value:s.filter((e=>e.value)),onChange:e=>n({activeDays:pp.map((t=>e.filter((e=>e.id===t)).length>0))})}):s.filter((e=>e.value)).map((e=>(0,H.jsx)("span",{children:e.id},e.id)))})]}),(0,H.jsx)(xp,{value:t.processVideo,title:"Video Processing",onChange:e=>{n({processVideo:e,enableTailgating:e&&t.enableTailgating})},isEditing:a}),(0,H.jsx)(xp,{value:t.enableTailgating,title:"Tailgating Detection",onChange:e=>{n({enableTailgating:e,processVideo:t.processVideo||e})},isEditing:a}),(0,H.jsx)(xp,{value:!!t.enableUnauthorizedEntryAlarm,title:"Unauthorised Entry Detection",onChange:e=>{n({enableUnauthorizedEntryAlarm:e})},isEditing:a}),(0,H.jsx)(xp,{value:!t.enableForAllAlarmType,title:"Enable For Specific Alarms",onChange:e=>{n({enableForAllAlarmType:!e,alarm_types:e?t.alarm_types:null})},isEditing:a}),!t.enableForAllAlarmType&&(0,H.jsx)("div",{className:"px-6",children:(0,H.jsx)(_r,{alarmTypes:t.alarm_types||[],isEditing:a,onChange:e=>{n({alarm_types:e})},label:"Alarm Types"})})]})}function fp(e){const{config:t,onChange:n,onResetConfig:s}=e,[r,i]=(0,a.useState)(!1);return(0,H.jsxs)("div",{className:"bg-onlight-bg-2 dark:bg-ondark-bg-2 text-onlight-text-1 dark:text-ondark-text-1 rounded-lg shadow-sm",children:[(0,H.jsxs)("div",{className:"flex justify-start",children:[(0,H.jsx)("div",{className:"m-2 my-auto align-middle",children:(0,H.jsx)(Q,{variant:"icon",onClick:()=>i((e=>!e)),children:r?(0,H.jsx)(lp.Z,{className:"text-onlight-text-2 dark:text-ondark-text-2 h-5 w-5"}):(0,H.jsx)(wa.Z,{className:"text-onlight-text-2 dark:text-ondark-text-2 h-5 w-5"})})}),(0,H.jsx)(up,{expanded:r,onChange:n,config:t}),(0,H.jsxs)("div",{className:"flex justify-start",children:[!t.deleted&&(0,H.jsx)("span",{className:"my-auto ml-10 mr-2 flex gap-x-2 align-middle",children:t.isEditing?(0,H.jsxs)(Q,{variant:"icon",onClick:()=>n({isEditing:!1}),children:[(0,H.jsx)(Ce.Z,{className:"h-5 w-5"}),(0,H.jsx)("span",{className:"ml-1",children:"Done"})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"icon",onClick:()=>n({deleted:!0,isEditing:!1}),children:(0,H.jsx)(Yo.Z,{className:"h-5 w-5"})}),(0,H.jsx)(Q,{variant:"icon",onClick:()=>{n({isEditing:!0}),i(!0)},children:(0,H.jsx)(Ko.Z,{className:"h-5 w-5"})})]})}),(0,H.jsx)("span",{className:"my-auto mr-2 inline-block align-middle",children:t.isNew?(0,H.jsx)(re,{text:"New",type:"success"}):t.deleted?(0,H.jsx)(re,{text:"Deleted",type:"error",removable:!0,onClickRemove:()=>n({deleted:!1})}):t.updated?(0,H.jsx)(re,{text:"Modified",type:"warning",removable:!0,onClickRemove:s}):null})]})]}),(0,H.jsx)("div",{children:r&&(0,H.jsx)(gp,{config:t,onChange:n,isEditing:t.isEditing})})]})}function vp(e){const{procConfigs:t,onChangeSingleConfig:n,onResetConfig:a,isAdding:s}=e;return(0,H.jsxs)(H.Fragment,{children:[t.sort(((e,t)=>e.id<0?1/0:t.id<0?-1/0:e.id-t.id)).map((e=>(0,H.jsx)(fp,{config:e,onChange:t=>n(e.id,t),onResetConfig:()=>a(e.id)},e.id))),0===t.length&&!s&&(0,H.jsx)(B,{children:"No processing configurations attached to this door group"})]})}const jp=["updated","deleted","isNew","isEditing"];const bp=function(e){const{doorGroup:t,onClose:n}=e,[s,r]=(0,a.useState)(!1),[i,o]=(0,a.useState)(t.processingConfigs.map((e=>Object.assign({},e,{updated:!1,isNew:!1,deleted:!1,isEditing:!1})))),[l,c]=(0,a.useState)(rp),[d,u]=(0,a.useState)(1),m=Tn(t.id,(()=>{Le("Processing Schedules modified",{type:"success"}),n()})),h=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{m.mutate({processingConfigs:i.filter((e=>!e.deleted))},{onError:e=>{c(e.message)}})},disabled:!i.some((e=>e.updated||e.isNew||e.deleted))||i.some((e=>e.isEditing)),onSideEffect:yt("submit_modify_processing_config"),loading:m.isLoading,children:"Submit"}),(0,H.jsx)(Q,{onClick:n,onSideEffect:yt("cancel_modify_processing_config"),children:"Cancel"})]}),x=(e,n)=>{m.reset(),o((a=>{const s=a.filter((t=>t.id!==e));if(void 0===n)return s;const r=a.find((t=>t.id===e));if(r){const a=Object.assign({},r,n),i=t.processingConfigs.find((t=>t.id===e)),{deleted:o,isNew:l}=a,c=(0,di.Z)(a,jp);l&&o||(a.updated=!_(i,c),s.push(a))}else s.push(Object.assign({},sp,n,{id:-1-d,isNew:!0})),u((e=>e+1));return s}))};return(0,H.jsx)(ce,{title:"Processing Configuration",open:!0,onClose:n,footer:h,children:(0,H.jsxs)("div",{className:"max-h-[70vh] w-[48rem] space-y-4 overflow-y-auto p-8",children:[m.isError&&(0,H.jsx)(B,{type:"error",children:l}),(0,H.jsx)(ip,{isAdding:s,onStartAdd:()=>r(!0),onCancelAdd:()=>r(!1),onAddNew:e=>{x(-1,e),r(!1)}}),(0,H.jsx)(vp,{procConfigs:i,onChangeSingleConfig:x,onResetConfig:e=>{o((n=>{const a=n.filter((t=>t.id!==e)),s=t.processingConfigs.find((t=>t.id===e));return s&&a.push(Object.assign({},s,{updated:!1,isNew:!1,deleted:!1,isEditing:!1})),a}))},isAdding:s})]})})};var yp=n(22467);const kp=function(e){const{doorGroup:t,onClose:n}=e,a=kn(t.id,(()=>{Le("Door Group removed successfully",{type:"success"}),n()})),s=(0,H.jsxs)("div",{className:"flex flex-row gap-4",children:[(0,H.jsx)(Q,{variant:"error",onClick:()=>{a.mutate({})},loading:a.isLoading,children:"Delete"}),(0,H.jsx)(Q,{variant:"outline",onClick:n,children:"Cancel"})]});return(0,H.jsx)(ce,{open:!0,onClose:n,footer:s,title:"Delete door group",children:(0,H.jsx)("div",{className:"w-[36rem] p-8",children:(0,H.jsx)("div",{className:"space-y-4",children:(0,H.jsxs)("p",{children:["Are you sure you want to delete the door group named"," ",(0,H.jsx)("span",{className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 whitespace-pre rounded-md py-1 px-2 font-bold",children:t.name})," ","having description"," ",(0,H.jsx)("span",{className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 whitespace-pre rounded-md py-1 px-2 font-bold",children:t.description})," ","?"]})})})})};const wp=function(e){const{doorGroup:t,onClose:n}=e,s={name:t.name,description:t.description},[r,i]=(0,a.useState)(s),o=Sn(t.id,(()=>{Le("Door Group Details Updated",{type:"success"}),n()})),l=Object.entries(r).some((([e,t])=>""===t)),c=e=>t=>{i((n=>Object.assign({},n,{[e]:"string"==typeof t?t:t.target.value})))},d=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{o.mutate(r)},disabled:l||o.isLoading,onSideEffect:yt("submit_update_door_group_details"),loading:o.isLoading,children:"Submit"}),(0,H.jsx)(Q,{onClick:n,onSideEffect:yt("cancel_update_door_group_details"),children:"Cancel"})]});return(0,H.jsxs)(ce,{title:"Edit Door Group Details",open:!0,onClose:n,footer:d,children:[o.isError&&(0,H.jsx)("div",{className:"mt-4 px-8",children:(0,H.jsx)(B,{type:"error",children:o.error.message})}),(0,H.jsxs)("div",{className:"w-[36rem] space-y-4 p-8",children:[(0,H.jsx)(ae,{type:"text",label:"Name",value:r.name,onChange:c("name")}),(0,H.jsx)(pe,{rows:2,label:"Description",value:r.description,onChange:c("description")})]})]})};function Np(e){const{doorGroup:t}=e,[n,s]=(0,a.useState)(!1),[r,i]=(0,a.useState)(!1),[o,l]=(0,a.useState)(!1);return(0,a.useEffect)((()=>{t&&(0===t.doors.length&&0===t.processingConfigs.length?l(!0):l(!1))}),[t]),(0,H.jsxs)("div",{className:"flex flex-row gap-4",children:[(0,H.jsxs)(Q,{variant:"icon",onClick:()=>{s(!0)},children:[(0,H.jsx)(yp.Z,{className:"mr-1 h-5 w-5"}),"Edit Door Group"]}),n&&(0,H.jsx)(wp,{doorGroup:t,onClose:()=>s(!1)}),(0,H.jsxs)(Q,{variant:"icon",onClick:()=>i(!0),disabled:!o,title:o?"":"There are associated doors and processing configurations with this door group",children:[" ",(0,H.jsx)(Yo.Z,{className:"h-5 w-5"})]}),r&&(0,H.jsx)(kp,{doorGroup:t,onClose:()=>i(!1)})]})}const Cp=[{id:"name",name:"Name"},{id:"description",name:"Description",showAtBreakpoint:"sm"},{id:"process-config",name:"Processing Configuration",showAtBreakpoint:"sm"},{id:"actions",name:"",showAtBreakpoint:"sm"}];function Sp(){const[e,t]=(0,ur.KO)(Yx),{filters:n,page:s,pageSize:r}=e,[i,o]=(0,a.useState)({columns:Cp,rows:[]}),[l,c]=(0,a.useState)([]),[d,u]=(0,a.useState)(0),[m,h]=(0,a.useState)(!1),[x,p]=(0,a.useState)(!1),[g,f]=(0,a.useState)(!1),[v,b]=(0,a.useState)(),{isLoading:y,isError:k,error:w,data:N}=wn(function(e,t,n){const a=new URLSearchParams;return a.append("page",String(e)),a.append("pageSize",String(n)),t.name.values.length>0&&a.append("name",t.name.values.map((e=>e.name)).join(Yn)),a.toString()}(s,n,r)),C=(s-1)*r,S=Math.min(s*r,d)-1;(0,a.useEffect)((()=>{if(N){const{items:e,total:t}=N;o(function(e,t){return{rows:e.map((e=>({id:String(e.id),cells:[{value:e.name},{value:e.description},{value:(0,H.jsx)(Q,{onClick:t(e.id),variant:"icon",children:(0,H.jsx)(mp.Z,{className:"h-5 w-5"})})},{value:(0,H.jsx)(Np,{doorGroup:e})}]}))),columns:Cp}}(e,(t=>()=>{f(!0),b(e.find((e=>e.id===t)))}))),c(e),u(t)}}),[N]);const T=Ge(j(),"door_group:create"),E=(0,H.jsx)(Jx,{canAddDoorGroup:T,hasCustomFiltersApplied:n.name.values.length>0,isLoading:y,onClickAddLocation:()=>p(!0),onClickFilter:()=>h(!0)}),A=(0,H.jsx)("div",{className:"dark:bg-dark-bg border-t bg-white p-4 dark:border-gray-800",children:(0,H.jsx)(wi,{from:C+1,to:S+1,pageSize:r,total:d,disabled:y,onChangePage:e=>{t((t=>Object.assign({},t,{page:e})))}})});return(0,H.jsxs)(mr,{title:"Door Groups",children:[k&&(0,H.jsx)("div",{className:"mb-2",children:(0,H.jsx)(B,{type:"error",children:w.message})}),x&&(0,H.jsx)(Kx,{onClose:()=>p(!1)}),g&&v&&(0,H.jsx)(bp,{onClose:()=>f(!1),doorGroup:v}),(0,H.jsx)(np,{open:m,filters:n,onApplyFilters:e=>{t((t=>Object.assign({},t,{filters:e,page:1})))},onClose:()=>h(!1)}),(0,H.jsx)("div",{className:"dark:bg-dark-bg -mx-4 flex min-h-0 flex-1 flex-col justify-start overflow-y-hidden sm:-mx-6 md:mx-0 md:rounded-lg",children:(0,H.jsx)(Ai,{data:i,header:E,footer:A,loading:y,renderExpandedRow:e=>{const t=l.find((t=>String(t.id)===e));return t?(0,H.jsx)(Xx,{doorGroup:t}):null}})})]})}nt(ht(Sp),["door_group:view"]);function Tp(){return(0,H.jsx)(r.Z5,{children:(0,H.jsx)(r.AW,{path:"/",element:(0,H.jsx)(Sp,{})})})}const Ep=150,Ap=15,_p="This door might not meet specifications. Please contact support for more details",Ip=(0,xt.cn)(null),Lp=(0,xt.cn)(null),Rp=(0,xt.cn)("unknown"),Dp=(0,xt.cn)(void 0),Pp=(0,xt.cn)((e=>({doorMarkers:e(Ip),floorMarker:e(Lp),cameraPosition:e(Rp),labellingResolution:e(Dp)})));function Mp(e){const{doorMarkers:t,labellingResolution:n}=e,a=(null==n?void 0:n.at(1))||0;if(t&&4!==t.length||!a)return!0;const s=function(e){return[...e].sort(((e,t)=>t[1]-e[1])).slice(0,2)}(t||[]),r=function(e,t){const n=t*Ap/100;return!e.some((e=>{const[,a]=e;return t-a<n}))}(s,a),i=function(e){const t=[...e];if(0===t.length)return!0;const[,n]=t.sort(((e,t)=>e[1]-t[1]))[0],[,a]=t.sort(((e,t)=>t[1]-e[1]))[0];return a-n>Ep}(t||[]);return r&&i}const Op=function(e){const{dcpId:t,doorMarkers:n,floorMarker:a,onAddDoorMarker:s,onAddFloorMarker:r}=e,[i,o]=(0,ur.KO)(Dp),l=e=>{if(!e.currentTarget||void 0===i)return;const t=e.currentTarget.getBoundingClientRect(),o=ds([t.width,t.height],[i[0],i[1]],[t.left,t.top],{point:[e.clientX,e.clientY]});!n||n.length<4?s(o.point):a||r(o.point)},c=n?function(e){let t=[];return e&&4===e.length?t.push({points:e}):e&&(t=[]),t}(n):[],d=function(e,t){const n=[];return e&&e.length<4&&n.push(...e.map((e=>({point:e})))),t&&n.push({point:t}),n}(n,a),u=fn(t);return(0,H.jsx)(Is,{queryResult:u,loadingText:"Loading Image...",errorFormatter:e=>(0,H.jsx)(B,{type:"error",children:e.message}),keepCurrentContentOnRefetch:!1,children:e=>(0,H.jsx)(fs,{imgUrl:e.url,polygons:c,markers:d,onClickImage:l,onClickShape:l,onImageLoadCallback:o})})};const Fp=function(e){const{canUpdate:t,isLoading:n,isValid:a,onClickClear:s,onClickReset:r,onClickSave:i}=e;return(0,H.jsx)("div",{className:"mt-6 space-y-3",children:t&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{disabled:n||!a,variant:"primary",block:!0,onClick:i,loading:n,onSideEffect:yt("save_door_label_details"),children:"Save"}),(0,H.jsx)(Q,{onClick:r,disabled:n,block:!0,onSideEffect:yt("reset_door_label_details"),children:"Reset"}),(0,H.jsx)(Q,{onClick:s,disabled:n,variant:"error",block:!0,onSideEffect:yt("clear_door_label_details"),children:"Clear Label"})]})})},Zp=[{id:"secure",name:"On Secure Side"},{id:"unsecure",name:"On Unsecure Side"}];const qp=function(e){var t,n,a,s;const{label:r,isLoading:i,onClickReset:o,onClickClear:l,onChangeCameraPosition:c,onClickSave:d}=e,u=null!=(t=null==r?void 0:r.doorMarkers)?t:[],m=null==r?void 0:r.floorMarker,h=null!=(n=null==r?void 0:r.cameraPosition)?n:"unknown",x=Ge(j(),"dcp/details:update"),p=function(e){return!(e.doorMarkers&&e.doorMarkers.length>0)||Boolean(e.floorMarker&&4===e.doorMarkers.length&&("secure"===e.cameraPosition||"unsecure"===e.cameraPosition))}(r),g=null!=(a=Zp.find((e=>e.id===h)))?a:{id:"unknown",name:""};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{children:[(0,H.jsx)("h2",{className:"dark:text-dark-text font-medium text-gray-800",children:"Door Markers"}),(0,H.jsx)("dl",{className:"dark:divide-dark-border-bg dark:border-dark-border-bg mt-2 divide-y divide-gray-200 border-t border-b border-gray-200",children:Array(4).fill(null).map(((e,t)=>(0,H.jsxs)("div",{className:"flex justify-between py-2 text-sm font-medium",children:[(0,H.jsx)("dt",{className:"dark:text-dark-text text-gray-500",children:t+1}),(0,H.jsx)("dd",{className:"dark:text-dark-text text-gray-700",children:cs(u[t])})]},t)))})]}),(0,H.jsxs)("div",{className:"mt-6",children:[(0,H.jsx)("h2",{className:"dark:text-dark-text font-medium text-gray-800",children:"Floor Marker"}),(0,H.jsx)("dl",{className:"dark:divide-dark-border-bg dark:border-dark-border-bg mt-2 divide-y divide-gray-200 border-t border-b border-gray-200",children:(0,H.jsxs)("div",{className:"flex justify-between py-2 text-sm font-medium",children:[(0,H.jsx)("dt",{className:"dark:text-dark-text text-gray-500",children:"1"}),(0,H.jsx)("dd",{className:"dark:text-dark-text text-gray-700",children:cs(m)})]})})]}),(0,H.jsxs)("div",{className:"mt-6",children:[(0,H.jsx)("h2",{className:"dark:text-dark-text font-medium text-gray-800",children:"Camera Position"}),(0,H.jsx)("div",{className:"dark:text-dark-text mt-2 text-gray-700",children:x?(0,H.jsx)(ue,{items:Zp,value:g,onChange:e=>{x&&c(e.id)},id:e=>e.id,displayValue:e=>e.name}):(0,H.jsx)(re,{type:"default",text:null!=(s=null==g?void 0:g.name)?s:"Unknown"})})]}),(0,H.jsx)(Fp,{canUpdate:x,isLoading:i,isValid:p,onClickSave:d,onClickReset:o,onClickClear:l})]})};const Up=function(e){const{dcp:t}=e,n=jn(t.id,(()=>{Le("Label saved",{type:"success"})})),s=(0,r.s0)(),[i,o]=(0,ur.KO)(Ip),l=(0,ur.b9)(Rp),[c,d]=(0,ur.KO)(Lp),u=(0,ur.Dv)(Pp);(0,a.useEffect)((()=>{var e,n,a,s,r,i;o(null!=(e=null==(n=t.label)?void 0:n.doorMarkers)?e:null),d(null!=(a=null==(s=t.label)?void 0:s.floorMarker)?a:null),l(null!=(r=null==(i=t.label)?void 0:i.cameraPosition)?r:"unknown")}),[t,o,d,l]);const[m,h]=(0,a.useState)(!0);(0,a.useEffect)((()=>{h(Mp(u))}),[u]);const x=(0,H.jsxs)("span",{className:"inline-flex items-center text-xs text-gray-500",children:[t.doorName,(0,H.jsx)(ya,{}),t.id]});return(0,H.jsx)(mr,{title:"Door Details",subtitle:x,onClickBack:()=>s("/doors"),children:(0,H.jsxs)("div",{className:"space-y-4 pb-8",children:[n.isError&&(0,H.jsx)(B,{type:"error",children:n.error.message}),!m&&(0,H.jsx)(B,{type:"warning",children:_p}),(0,H.jsxs)("div",{className:"flex flex-col gap-6 lg:flex-row",children:[(0,H.jsx)("div",{className:"basis-4/5",children:(0,H.jsx)(Op,{dcpId:t.id,doorMarkers:i,floorMarker:c,onAddDoorMarker:e=>{o((t=>t?[...t,e]:[e]))},onAddFloorMarker:d})}),(0,H.jsx)("div",{className:"sticky top-4 w-full basis-1/5 self-start",children:(0,H.jsx)(qp,{label:u,isLoading:n.isLoading,onChangeCameraPosition:l,onClickReset:()=>{var e,n,a,s,r,i;l(null!=(e=null==(n=t.label)?void 0:n.cameraPosition)?e:"unknown"),o(null!=(a=null==(s=t.label)?void 0:s.doorMarkers)?a:null),d(null!=(r=null==(i=t.label)?void 0:i.floorMarker)?r:null)},onClickClear:()=>{o(null),d(null),l("unknown")},onClickSave:()=>{var e;n.mutate(null===(e=u)?null:Object.assign({},e,{doorMarkers:e.doorMarkers?e.doorMarkers.map(os):null,floorMarker:e.floorMarker?os(e.floorMarker):null}))}})})]})]})})};const Vp=ht((function(e){const{dcpId:t}=e,n=gn(t);return(0,H.jsx)(Is,{queryResult:n,loadingText:"Loading Door Details...",keepCurrentContentOnRefetch:!1,children:e=>(0,H.jsx)(Up,{dcp:e},e.id)})}));function $p(){const{dcpId:e}=(0,r.UO)();return void 0===e?(0,H.jsx)(As,{}):(0,H.jsx)(Vp,{dcpId:e})}nt($p,["dcp/details:view"]);const zp={showLabeled:!0,showUnlabeled:!0},Hp={values:[],negative:!1},Bp={values:[],negative:!1},Wp={id:"null",name:"Show doors without location"};const Gp=function(e){const{locationFilterValue:t,onChangeLocationFilterValue:n}=e,[s,r]=(0,a.useState)(t.values.some((e=>e.id===Wp.id)));return(0,a.useEffect)((()=>{const e=t.values.some((e=>e.id===Wp.id));r(e)}),[t.values]),(0,H.jsxs)("div",{className:"space-y-4",children:[(0,H.jsx)(we,{enabled:s,label:"Show doors without location",onChange:e=>{r(e);let a=[...t.values];e?a.push(Wp):a=a.filter((e=>e.id!==Wp.id)),n(Object.assign({},t,{values:a}))}}),(0,H.jsx)(vd,{label:"Door Location",value:t,onChange:n})]})},Kp={id:"completed",name:"Completed"},Yp={id:"pending",name:"Pending"},Qp=[Kp,Yp];const Xp=function(e){const{value:t,onChangeCb:n}=e,a=Qp.filter((e=>"Completed"===e.name&&t.showLabeled||"Pending"===e.name&&t.showUnlabeled));return(0,H.jsx)(Fs,{label:"Labelling Status",value:a,onChange:e=>{n({showLabeled:e.includes(Kp),showUnlabeled:e.includes(Yp)})},getItems:e=>{const{filterPredicate:t,isEqual:n}=st;return rt(e,a,t,n,{staticItems:Qp})},displayValue:e=>e.name,id:e=>e.id})};const Jp=function(e){const{labelStatusFilterValue:t,locationFilterValue:n,doorFilterValue:a,onChangeLabelStatusFilterValue:s,onChangeLocationFilterValue:r,onChangeDoorFilterValue:i,onApplyFilters:o,onResetFilters:l}=e;return(0,H.jsxs)("div",{className:"space-y-6",children:[(0,H.jsxs)("div",{className:"dark:divide-dark-border-bg dark:border-dark-border-bg divide-y border-t border-b",children:[(0,H.jsx)(dd,{title:"Label Status",content:(0,H.jsx)(Xp,{value:t,onChangeCb:s}),hasFilterApplied:!t.showLabeled||!t.showUnlabeled}),(0,H.jsx)(dd,{title:"Location",content:(0,H.jsx)(Gp,{locationFilterValue:n,onChangeLocationFilterValue:r}),hasFilterApplied:n.values.length>0}),(0,H.jsx)(dd,{title:"Door",content:(0,H.jsx)(sd,{label:"Door Name",value:a,onChange:i}),hasFilterApplied:a.values.length>0})]}),(0,H.jsx)(rd,{onApply:o,onReset:l,trackingEventNameApply:"apply_doors_filters",trackingEventNameReset:"reset_doors_filters"})]})};const eg=function(e){const{open:t,onClose:n,filters:s,onApplyFilters:r}=e,[i,o]=(0,a.useState)(s.labelStatus),[l,c]=(0,a.useState)(s.location),[d,u]=(0,a.useState)(s.door);return(0,H.jsx)(_s,{title:"Door Filters",open:t,onClose:n,children:(0,H.jsx)(Jp,{labelStatusFilterValue:i,locationFilterValue:l,doorFilterValue:d,onChangeLabelStatusFilterValue:o,onChangeLocationFilterValue:c,onChangeDoorFilterValue:u,onApplyFilters:()=>{r({labelStatus:i,location:l,door:d}),n()},onResetFilters:()=>{o(zp),c(Hp),u(Bp)}})})},tg={doorListFilters:{labelStatus:{showLabeled:!0,showUnlabeled:!0},location:{values:[],negative:!1},door:{values:[],negative:!1}},doorListPage:1,doorPageSize:20},ng={state:tg,dispatch:()=>null},ag=(0,a.createContext)(ng),sg=(0,cm.ZP)(((e,t)=>{switch(t.type){case"UPDATE_FILTERS":e.doorListFilters=t.payload;break;case"UPDATE_PAGE":e.doorListPage=t.payload;break;default:throw new Error}}));function rg(){const{dispatch:e}=(0,a.useContext)(ag);return e}const ig=function(e){const{children:t}=e,[n,s]=(0,a.useReducer)(sg,tg);return(0,H.jsx)(ag.Provider,{value:{state:n,dispatch:s},children:t})},og="UPDATE_FILTERS",lg="UPDATE_PAGE";function cg(e){return{type:lg,payload:e}}var dg=n(86501);const ug=function(e){const{open:t=!1,onClose:n,inputDoor:s}=e,[r,i]=(0,a.useState)({id:"",name:""}),[o,l]=(0,a.useState)({id:"",name:""}),c=pn((()=>{n(),Le("Mapping added",{type:"success"})})),d=An(),u=ln();(0,a.useEffect)((()=>{s&&i({id:s.id,name:s.name})}),[s]);const m=()=>{n(),c.reset(),i({id:"",name:""}),l({id:"",name:""})},h=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{c.mutate({doorName:(null==r?void 0:r.name)||"",cameraName:(null==o?void 0:o.name)||""})},disabled:!r||!o||""===r.id||""===o.id,loading:c.isLoading,onSideEffect:yt("submit_add_door_camera_mapping"),children:"Submit"}),(0,H.jsx)(Q,{onClick:m,onSideEffect:yt("cancel_add_door_camera_mapping"),children:"Cancel"})]});return(0,H.jsx)(ce,{title:"Add Mapping",open:t,onClose:m,footer:h,children:(0,H.jsxs)("div",{className:"w-[36rem] p-8",children:[c.isError?(0,H.jsx)("div",{className:"py-4 px-8",children:(0,H.jsxs)(B,{type:"error",children:[c.error.message," "]})}):null,(0,H.jsxs)("div",{className:"space-y-4",children:[(0,H.jsx)(Vs,{label:"Door",value:r,onChange:i,onChangeQuery:d,displayValue:e=>e?e.name:"",id:e=>e.id}),(0,H.jsx)(Vs,{label:"Camera",value:o,onChange:l,onChangeQuery:u,displayValue:e=>e?e.name:"",id:e=>e.id})]})]})})};var mg=n(25746);const hg=function(e){var t;const{selectedDoors:n=[],onClose:s}=e,[r,i]=(0,a.useState)(null),[o,l]=(0,a.useState)([]),c=Nn((async e=>{const t=(await e.json()).payload;l(t.items)})),d=yn({doorGroupId:null!=(t=null==r?void 0:r.id)?t:"",onSuccess:()=>{Le(`Door${n.length>1?"s":""} added to Door Group successfully`),s()}}),u=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{d.mutate({doors:n,operation:"update"})},disabled:!r||d.isLoading,onSideEffect:yt("submit_add_doors_to_door_group"),loading:d.isLoading,children:"Submit"}),(0,H.jsx)(Q,{onClick:s,onSideEffect:yt("cancel_add_doors_to_door_group"),children:"Cancel"})]}),m=o.find((e=>String(e.id)===(null==r?void 0:r.id)));return(0,H.jsx)(ce,{title:`Add Door${n.length>1?"s":""} to Door Group`,open:!0,onClose:s,footer:u,children:(0,H.jsxs)("div",{className:"w-[30rem] space-y-4 p-8",children:[(0,H.jsx)(Vs,{label:"Door Group",placeholder:"Type here to search door groups...",onChangeQuery:c,value:r,onChange:i,displayValue:e=>(null==e?void 0:e.name)||""}),m&&(0,H.jsxs)("div",{className:"dark:border-dark-border-bg dark:bg-dark-surface mt-4 flex items-start justify-between gap-2 rounded border-gray-300 bg-gray-100 p-4",children:[(0,H.jsx)("div",{className:"flex flex-col gap-1",children:(0,H.jsx)("div",{className:"mb-1 text-sm",children:m.name})}),(0,H.jsx)(mg.Z,{className:"dark:text-dark-secondary-text h-5 w-5 text-gray-500"})]})]})})};const xg=function(e){var t;const{selectedDoors:n=[],onClose:s}=e,[r,i]=(0,a.useState)(null),[o,l]=(0,a.useState)([]),c=qn((async e=>{const t=(await e.json()).payload;l(t.items)})),d=Dn({locationId:null!=(t=null==r?void 0:r.id)?t:"",onSuccess:()=>{Le(`Door${n.length>1?"s":""} added to location successfully`),s()}}),u=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{d.mutate({doors:n})},disabled:!r||d.isLoading,onSideEffect:yt("submit_add_doors_to_location"),loading:d.isLoading,children:"Submit"}),(0,H.jsx)(Q,{onClick:s,onSideEffect:yt("cancel_add_doors_to_location"),children:"Cancel"})]}),m=o.find((e=>String(e.id)===(null==r?void 0:r.id)));return(0,H.jsx)(ce,{title:`Add Door${n.length>1?"s":""} to Location`,open:!0,onClose:s,footer:u,children:(0,H.jsxs)("div",{className:"w-[30rem] space-y-4 p-8",children:[(0,H.jsx)(Vs,{label:"Location",placeholder:"Type here to search locations...",onChangeQuery:c,value:r,onChange:i,displayValue:e=>(null==e?void 0:e.name)||""}),m&&(0,H.jsxs)("div",{className:"dark:border-dark-border-bg dark:bg-dark-surface mt-4 flex items-start justify-between gap-2 rounded border-gray-300 bg-gray-100 p-4",children:[(0,H.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,H.jsx)("div",{className:"mb-1 text-sm",children:m.name}),(0,H.jsx)("div",{className:"dark:text-dark-secondary-text text-xs text-gray-500",children:`${[m.city,m.state,m.country].join(", ")}`}),(0,H.jsx)("div",{className:"dark:text-dark-secondary-text text-xs text-gray-500",children:m.timezone})]}),(0,H.jsx)(mg.Z,{className:"dark:text-dark-secondary-text h-5 w-5 text-gray-500"})]})]})})};const pg=function(e){const{open:t=!1,onClose:n,allDoors:s=[],selectedDoors:r=[]}=e,[i]=(0,a.useState)((()=>r.map((e=>{var t,n;const a=s.find((t=>t.id===e));return{doorName:null==a?void 0:a.name,doorId:null==a?void 0:a.id,doorGroupId:null==a||null==(t=a.doorGroup)?void 0:t.id,doorGroupName:null==a||null==(n=a.doorGroup)?void 0:n.name}})).filter((e=>!!e.doorGroupId)))),o=Cn((function(){Le("Removed Doors from Door Group Successfully",{type:"success"}),n()})),l=()=>{n(),o.reset()},c=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"error",onClick:()=>{const e={doors:[]};i.reduce(((e,t)=>{const n=e.find((e=>e.door_group_id===String(t.doorGroupId)));return n?n.doors.push(String(t.doorId)):e.push({door_group_id:String(t.doorGroupId),doors:[String(t.doorId)]}),e}),e.doors),o.mutate(e)},onSideEffect:yt("submit_remove_door_from_door_group"),disabled:o.isLoading||0===i.length,loading:o.isLoading,children:"Remove door/s from door group"}),(0,H.jsx)(Q,{onClick:l,onSideEffect:yt("cancel_remove_door_from_door_group"),children:"Cancel"})]});return(0,H.jsx)(ce,{title:"Remove Door/s from Door Groups",open:t,onClose:l,footer:c,children:(0,H.jsx)("div",{className:"w-[36rem] p-8",children:(0,H.jsxs)("div",{className:"space-y-4",children:[(0,H.jsx)("p",{children:"Are you sure you want to remove below door/s from respective door group?"}),(0,H.jsxs)("div",{className:"justify-center",children:[(0,H.jsxs)("div",{className:"grid grid-cols-2 py-3 text-left font-semibold text-gray-700 dark:text-gray-400",children:[(0,H.jsx)("span",{children:"Door Name"}),(0,H.jsx)("span",{children:"Door Group"})]}),i.map((e=>(0,H.jsxs)("div",{className:"grid grid-cols-2 text-sm",children:[(0,H.jsx)("span",{children:e.doorName}),(0,H.jsx)("span",{children:e.doorGroupName})]},`${e.doorGroupId}-${e.doorId}`))),0===i.length&&(0,H.jsx)("div",{className:"text-center text-xs text-gray-600 dark:text-gray-400",children:"All selected doors are not associated with door group"})]})]})})})};const gg=function(e){var t,n,a;const{open:s=!1,onClose:r,inputDoor:i}=e,o=vn(i?null==(t=i.dcp)?void 0:t.id:"",(function(){Le("Removed Mapping Successfully",{type:"success"}),r()})),l=()=>{r(),o.reset()},c=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"error",onClick:()=>o.mutate({}),loading:o.isLoading,disabled:!i||!(null!=(n=i.dcp)&&n.id),onSideEffect:yt("submit_delete_door_camera_mapping"),children:"Delete Mapping"}),(0,H.jsx)(Q,{onClick:l,onSideEffect:yt("cancel_delete_door_camera_mapping"),children:"Cancel"})]});return(0,H.jsx)(ce,{title:"Remove Mapping",open:s,onClose:l,footer:c,children:(0,H.jsxs)("div",{className:"w-[36rem] p-8",children:[o.isError?(0,H.jsx)("div",{className:"py-4 px-8",children:(0,H.jsxs)(B,{type:"error",children:[o.error.message," "]})}):null,(0,H.jsx)("div",{className:"space-y-4",children:(0,H.jsxs)("p",{children:["Are you sure you want to remove the mapping between"," ",(0,H.jsx)("b",{children:null==i?void 0:i.name})," and ",(0,H.jsx)("b",{children:null==i||null==(a=i.dcp)?void 0:a.cameraName})]})})]})})};function fg(e){return!e.labelStatus.showLabeled||!e.labelStatus.showUnlabeled||e.location.values.length>0||e.door.values.length>0}const vg=e=>{const{location:t,door:n,labelStatus:a}=e,s={};return t.values.length>0&&(s.location={value:t.values.map((e=>e.name)),negative:t.negative}),n.values.length>0&&(s.door={value:n.values.map((e=>e.name)),negative:n.negative}),s.labelStatus=a,s};const jg=[{id:"door",name:"Door"},{id:"camera",name:"Camera",showAtBreakpoint:"xl"},{id:"location",name:"Location",showAtBreakpoint:"lg"},{id:"doorGroup",name:"Door Group",showAtBreakpoint:"lg"},{id:"label",name:"Label",align:"center",showAtBreakpoint:"md"},{id:"sourceSystem",name:"Source System",showAtBreakpoint:"lg"},{id:"action",name:"",align:"center",showAtBreakpoint:"md"}];let bg=function(e){return e.ADD_MAPPING="addMapping",e.ADD_TO_LOCATION="addToLocation",e.REMOVE_MAPPING="removeMapping",e.ADD_DOOR_GROUP="addDoorGroup",e.REMOVE_DOOR_FROM_DOOR_GROUP="removeDoorFromDoorGroup",e}({});const yg=()=>[{id:bg.ADD_MAPPING,Modal:ug},{id:bg.ADD_TO_LOCATION,Modal:xg},{id:bg.REMOVE_MAPPING,Modal:gg},{id:bg.ADD_DOOR_GROUP,Modal:hg},{id:bg.REMOVE_DOOR_FROM_DOOR_GROUP,Modal:pg}];function kg(e){const{selectedMapping:t,selectedDoorIds:n,onClose:a,activeModal:s,allDoors:r,doorToMap:i}=e,o=yg().find((e=>e.id===s)),l={selectedDoors:n,onClose:a,allDoors:r,dcp:t,open:!0,inputDoor:i};return o?(0,H.jsx)(o.Modal,Object.assign({},l)):null}function wg(e){const{selectedDoors:t,filters:n,isLoading:a,onClickFilter:s,onClickAddToLocation:r,onClickAddToDoorGroup:i,onClickRemoveFromDoorGroup:o}=e,l=Ge(j(),"door/location:update"),c=Ge(j(),"door/group:update");return(0,H.jsx)("div",{className:"dark:bg-dark-bg border-b bg-white p-4 dark:border-0",children:(0,H.jsxs)("div",{className:"flex h-10 items-center",children:[(0,H.jsxs)("div",{className:"flex flex-1",children:[(0,H.jsx)("div",{className:"ml-0",children:l&&t.length>0&&(0,H.jsxs)(Q,{variant:"primary",onSideEffect:yt("open_add_doors_to_location_modal"),onClick:r,children:["Add ",t.length," door",1===t.length?"":"s"," to location",(0,H.jsx)("span",{className:"sr-only",children:"Add to Location"})]})}),(0,H.jsx)("div",{className:"ml-2",children:c&&t.length>0&&(0,H.jsxs)(Q,{variant:"primary",onSideEffect:yt("open_add_doors_to_door_group_modal"),onClick:i,children:["Add ",t.length," door",1===t.length?"":"s"," to door group",(0,H.jsx)("span",{className:"sr-only",children:"Add to Door Group"})]})}),(0,H.jsx)("div",{className:"ml-2",children:c&&t.length>0&&(0,H.jsxs)(Q,{variant:"error",onSideEffect:yt("remove_door_from_door_group"),onClick:o,children:["Remove ",t.length," door",1===t.length?"":"s"," from door group",(0,H.jsx)("span",{className:"sr-only",children:"Remove from Door Group"})]})})]}),(0,H.jsxs)(Q,{variant:"icon",badge:fg(n),onClick:s,disabled:a,onSideEffect:yt("open_door_filters_panel"),children:[(0,H.jsx)("span",{className:"sr-only",children:"Open filters panel"}),(0,H.jsx)(_d.Z,{className:"h-5 w-5","aria-hidden":"true"})]})]})})}const Ng=function(e){const{selected:t,tableData:n,loading:a,fromIndex:s,toIndex:r,pageSize:i,total:o,page:l,filters:c,onChangeSelected:d,onClickOpenFilter:u,onClickAddToLocation:m,onClickAddToDoorGroup:h,onClickRemoveFromDoorGroup:x}=e,p=rg(),g=(0,H.jsx)("div",{className:"dark:bg-dark-bg border-t bg-white p-4 dark:border-gray-800",children:(0,H.jsx)(wi,{from:s+1,to:r+1,pageSize:i,total:o,disabled:a,onChangePage:e=>{p(cg(e))}})});return(0,H.jsx)(Ai,{data:n,loading:a,header:(0,H.jsx)(wg,{selectedDoors:t,filters:c,isLoading:a,onClickFilter:u,onClickAddToLocation:m,onClickAddToDoorGroup:h,onClickRemoveFromDoorGroup:x}),footer:g,scrollResetKey:l,rowSelection:{selected:t,onChangeSelected:d}})};const Cg=nt(ht((function(){const e=function(){const{state:e}=(0,a.useContext)(ag);return e}(),t=rg(),{doorListFilters:n,doorListPage:s,doorPageSize:i}=e,[o,l]=(0,a.useState)({columns:jg,rows:[]}),[c,d]=(0,a.useState)([]),[u,m]=(0,a.useState)(0),[h,x]=(0,a.useState)(!1),[p,g]=(0,a.useState)([]),[f,v]=(0,a.useState)(),[b,y]=(0,a.useState)(),{isFetching:k,isError:w,error:N,data:C}=En(function(e,t,n){const a=new URLSearchParams;a.append("page",String(e)),a.append("pageSize",String(n));const s=[];return t.labelStatus.showLabeled&&s.push("completed"),t.labelStatus.showUnlabeled&&s.push("pending"),s.length>0&&a.append("labelStatus",s.join(Yn)),t.location.values.length>0&&a.append("locationIds",t.location.values.map((e=>e.id)).join(Yn)),t.door.values.length>0&&a.append("doors",t.door.values.map((e=>e.name)).join(Yn)),a.toString()}(s,n,i)),S=(s-1)*i,T=Math.min(s*i,u)-1,E=(0,r.s0)(),A=Ge(j(),"dcp/details:view"),_=(0,a.useCallback)((e=>{var t;e.dcp&&A&&E(`/doors/${null==(t=e.dcp)?void 0:t.id}`)}),[E,A]),I=Ge(j(),"dcp:add"),L=Ge(j(),"dcp:delete"),R=(0,a.useCallback)(((e,t)=>{L&&(e.stopPropagation(),t&&(v(t),y(bg.REMOVE_MAPPING)))}),[L]),D=(0,a.useCallback)(((e,t)=>{I&&(e.stopPropagation(),t&&(v(t),y(bg.ADD_MAPPING)))}),[I]);return(0,a.useEffect)((()=>{if(C){const{items:e,total:t}=C;l(function(e,t,n,a,s,r){const i=e.map((e=>{var i,o,l,c,d;return{id:e.id,onClick:()=>{e.dcp&&t(e)},cells:[{value:(0,H.jsx)("div",{className:"truncate",children:e.name})},{value:null==(i=e.dcp)?void 0:i.cameraName},{value:null==(o=e.location)?void 0:o.name},{value:null==(l=e.doorGroup)?void 0:l.name},{value:(d=e.dcp,null!=d&&null!=d.label&&null!==d.label.doorMarkers&&4===d.label.doorMarkers.length&&"unknown"!==d.label.cameraPosition?(0,H.jsx)(re,{text:"Completed",type:"success"}):(0,H.jsx)(re,{text:"Pending",type:"error"})),align:"center"},{value:e.sourceSystem},{value:e.dcp&&s?(0,H.jsx)(Q,{variant:"icon",onClick:t=>n(t,e),children:(0,H.jsx)(Yo.Z,{className:"w-4"})}):null!=(c=e.dcp)&&c.cameraName||!r?(0,H.jsx)("span",{}):(0,H.jsx)(Q,{variant:"icon",onClick:t=>a(t,e),children:(0,H.jsx)(dg.Z,{className:"w-4"})})}]}}));return{columns:jg,rows:i}}(e,_,R,D,L,I)),d(e),m(t)}}),[C,_,R,D,L,I]),(0,H.jsxs)(mr,{title:"Doors",children:[w&&(0,H.jsx)("div",{className:"mb-2",children:(0,H.jsx)(B,{type:"error",children:N.message})}),b&&(0,H.jsx)(kg,{activeModal:b,onClose:()=>y(null),selectedDoorIds:p,allDoors:c,doorToMap:f}),I?(0,H.jsx)("div",{className:"mb-2 flex justify-end",children:(0,H.jsxs)(Q,{variant:"primary",onClick:()=>y(bg.ADD_MAPPING),disabled:k,onSideEffect:yt("open_add_door_camera_mapping_modal"),children:["Add Mapping",(0,H.jsx)("span",{className:"sr-only",children:"Add Mapping"})]})}):null,(0,H.jsx)(eg,{open:h,filters:n,onApplyFilters:e=>{t({type:og,payload:e}),t(cg(1)),wt(vg(e))},onClose:()=>x(!1)}),(0,H.jsx)("div",{className:"dark:bg-dark-bg -mx-4 flex min-h-0 flex-1 flex-col justify-start overflow-y-hidden sm:-mx-6 md:mx-0 md:rounded-lg",children:(0,H.jsx)(Ng,{selected:p,filters:n,fromIndex:S,toIndex:T,page:s,pageSize:i,total:u,loading:k,tableData:o,onChangeSelected:g,onClickOpenFilter:()=>x(!0),onClickAddToLocation:()=>y(bg.ADD_TO_LOCATION),onClickAddToDoorGroup:()=>y(bg.ADD_DOOR_GROUP),onClickRemoveFromDoorGroup:()=>y(bg.REMOVE_DOOR_FROM_DOOR_GROUP)})})]})})),["door:view"]);const Sg=function(){return(0,H.jsxs)(r.Z5,{children:[(0,H.jsx)(r.AW,{path:"/",element:(0,H.jsx)(Cg,{})}),(0,H.jsx)(r.AW,{path:":dcpId",element:(0,H.jsx)($p,{})})]})};function Tg(){return(0,H.jsx)(ig,{children:(0,H.jsx)(Sg,{})})}function Eg(){const e=In();return(0,H.jsx)(Is,{queryResult:e,children:e=>(0,H.jsx)(mr,{title:"Insights",children:(0,H.jsx)("div",{className:"flex h-full",children:(0,H.jsx)("iframe",{frameBorder:"0",allowFullScreen:!0,title:"Data Visualization",marginHeight:0,marginWidth:0,src:e.tableauUrl,width:"100%"})})})})}const Ag=({id:e,children:t,onFileUpload:n})=>{const{setNodeRef:a}=(0,jh.Zj)({id:e}),s=e=>{const t="drop"===e.type?e.dataTransfer.files:e.target.files;t&&n(t[0])};return(0,H.jsxs)("div",{ref:a,onDrop:s,className:"border-onlight-line-2 dark:border-ondark-line-2 flex h-64 cursor-pointer items-center justify-center border-4 border-dashed",children:[(0,H.jsx)("input",{type:"file",onChange:s,accept:"image/*",className:"absolute h-64 cursor-pointer opacity-0"}),t]})},_g=e=>{const{onClose:t,locationId:n,locationName:s}=e,[r,i]=(0,a.useState)(),o=Hn(n,(()=>{Le("Floorplan uploaded successfully"),t()})),l=!!r&&r.size/1024/1024<10;const c=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{disabled:!l,loading:o.isLoading,variant:"primary",onClick:()=>{const e=new FormData;e.append("floorplan",r||""),o.mutate(e)},children:"Submit"}),(0,H.jsx)(Q,{variant:"outline",onClick:t,children:"Cancel"})]});return(0,H.jsx)(ce,{open:!0,onClose:t,closable:!0,footer:c,title:`Upload floorplan for ${s}`,children:(0,H.jsxs)("div",{className:"p-8",children:[o.isError&&(0,H.jsx)(B,{type:"error",children:o.error.message}),r?(0,H.jsxs)(H.Fragment,{children:[!l&&(0,H.jsxs)(B,{type:"warning",children:["File size should be less than ",10," MB"]}),(0,H.jsxs)("div",{className:"flex items-center gap-5 text-sm italic",children:[(0,H.jsxs)("div",{className:"space-y-2 text-center",children:[(0,H.jsx)("span",{children:r.name}),(0,H.jsx)("img",{src:URL.createObjectURL(r),alt:"Floorplan preview",className:"h-60 w-60"})]}),(0,H.jsx)(Q,{variant:"icon",title:"Remove file",onClick:()=>i(void 0),children:(0,H.jsx)(Yo.Z,{className:"h-5 w-5"})})]})]}):(0,H.jsxs)(jh.LB,{children:[(0,H.jsx)(Ag,{id:"droppable",onFileUpload:e=>i(e),children:(0,H.jsx)("div",{className:"text-onlight-text-3 dark:text-ondark-text-3 px-2 text-center text-sm",children:"Drag 'n' drop the file here, or click to browse"})}),(0,H.jsx)(jh.y9,{children:(0,H.jsx)("div",{className:"bg-primary-500 p-2 text-white",children:"Drop the files here..."})})]})]})})};function Ig(e){const{location:t}=e,[n,s]=(0,a.useState)(!1);return(0,H.jsxs)("div",{children:[(0,H.jsx)("div",{className:"pb-4 text-end",children:(0,H.jsx)(Q,{onClick:()=>s(!0),variant:"primary",children:"Upload Floorplan"})}),t.floor_plan?(0,H.jsx)("div",{className:"bg-onlight-bg-2 dark:bg-dark-bg flex justify-center",children:(0,H.jsx)("img",{src:t.floor_plan,alt:"Floorplan"})}):(0,H.jsx)("div",{className:"p-6",children:(0,H.jsx)(B,{children:"Floorplan not available"})}),n&&(0,H.jsx)(_g,{locationId:t.id.toString(),locationName:t.name,onClose:()=>s(!1)})]})}var Lg=n(23463);const Rg="contact-add-",Dg=()=>[{id:"priority",name:"Priority"},{id:"name",name:"Name"},{id:"phoneNumber",name:"Phone Number"},{id:"email",name:"Email"},{id:"action",name:"Actions"}];const Pg=function(e){const{oldData:t,newData:n,onAddNewContact:s,locationId:r,tenantId:i}=e,o=(0,a.useMemo)((()=>{const e=[...t].sort(((e,t)=>t.priority-e.priority));return!_(e,n)}),[t,n]),l=$n(r,(()=>{Le("Location contacts updated successfully",{type:"success"})}));return(0,H.jsxs)("div",{className:"mt-4 space-x-4",children:[l.isError&&(0,H.jsx)(B,{type:"error",children:l.error.message}),o&&(0,H.jsx)(Q,{variant:"primary",onClick:()=>{const e=n.map((e=>{const t={name:e.name,email:e.email,phoneNumber:e.phoneNumber,priority:e.priority};return String(e.id).startsWith(Rg)||(t.id=e.id),t})),t={locationId:r,tenantId:i,contacts:e};l.mutate(t)},disabled:l.isLoading,loading:l.isLoading,children:"Save Changes"}),(0,H.jsx)(Q,{variant:"outline",onClick:s,disabled:l.isLoading,children:"Add new Contact"})]})};const Mg=function(e){const{onClose:t,contact:n}=e,a=Mn(n.tenantId,n.locationId,String(n.id),(()=>{Le("Location contacts deleted successfully",{type:"success"}),t()})),s=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"error",onClick:()=>{a.mutate({})},loading:a.isLoading,disabled:a.isLoading,children:"Delete"}),(0,H.jsx)(Q,{onClick:t,disabled:a.isLoading,children:"Cancel"})]});return(0,H.jsx)(ce,{title:"Delete Contact",open:!0,onClose:t,footer:s,children:(0,H.jsxs)("div",{className:"space-y-4 p-8",children:["Are you sure you want to delete the below contact:",(0,H.jsxs)("div",{className:"mt-4",children:["Name: ",n.name]}),(0,H.jsxs)("div",{children:["Phone Number: ",n.phoneNumber]})]})})};var Og=n(4598),Fg=n(89294);const Zg=function(e){const{contact:t,onEdit:n,onDelete:a}=e,{attributes:s,listeners:r,setNodeRef:i,transform:o,transition:l,isDragging:c}=(0,Lg.nB)({id:t.id}),d={transform:Og.ux.Transform.toString(o),transition:l,cursor:c?"grabbing":"grab"};return(0,H.jsxs)("div",Object.assign({ref:i,style:d},s,r,{className:"hover:bg-onlight-bg-2 dark:hover:bg-ondark-bg-2 border-onlight-line-2 dark:border-ondark-line-2 grid grid-cols-5 border px-4 py-6",children:[(0,H.jsxs)("div",{className:"flex items-center gap-4",children:[(0,H.jsx)($a,{className:"fill-onlight-text-2 dark:fill-ondark-text-2 ml-2 h-4 w-4"}),(0,H.jsx)("span",{children:t.priority})]}),(0,H.jsx)("div",{children:t.name}),(0,H.jsx)("div",{children:t.phoneNumber}),(0,H.jsx)("div",{children:t.email||"-"}),(0,H.jsxs)("div",{className:"space-x-4",children:[(0,H.jsx)(Q,{variant:"icon",onClick:n,title:"Edit contact details",children:(0,H.jsx)(Fg.Z,{className:"h-5 w-5"})}),(0,H.jsx)(Q,{variant:"icon",onClick:a,title:"Delete contact",children:(0,H.jsx)(Yo.Z,{className:"h-5 w-5"})})]})]}))};function qg(e){const{mode:t,onClose:n,onSubmitCb:s,contact:r}=e,[i,o]=(0,a.useState)({isValid:!0,message:""}),l=(0,a.useId)(),[c,d]=(0,a.useState)((()=>r||{id:Rg+l,name:"",email:"",phoneNumber:""})),u=e=>t=>{const n=t.target.value;d((t=>Object.assign({},t,{[e]:n}))),o({isValid:!0,message:""})},m=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{const{isValid:e,message:t}=function(e){let t="";return""===e.name?t="Contact name should be provided":""===e.phoneNumber&&(t="Contact phone number should be provided"),{isValid:!t,message:t}}(c);o({isValid:e,message:t}),e&&s(c)},children:"Submit"}),(0,H.jsx)(Q,{onClick:n,children:"Cancel"})]});return(0,H.jsx)(ce,{title:"add"===t?"Add contact":"Edit contact",open:!0,onClose:n,footer:m,children:(0,H.jsxs)("div",{className:"min-w-[30rem] space-y-6 py-8 px-12",children:[!i.isValid&&(0,H.jsx)(B,{type:"warning",children:i.message}),(0,H.jsx)(ae,{type:"text",value:c.name||"",onChange:u("name"),label:"Name",placeholder:"Enter contact name..."}),(0,H.jsx)(ae,{type:"text",value:c.phoneNumber||"",onChange:u("phoneNumber"),label:"Phone Number",placeholder:"Enter contact phone number..."}),(0,H.jsx)(ae,{type:"email",value:c.email||"",onChange:u("email"),label:"Email",placeholder:"Enter contact email..."})]})})}function Ug(e){const{locationId:t,tenantId:n}=e,[s,r]=(0,a.useState)([]),{data:i,isLoading:o}=Fn(t),[l,c]=(0,a.useState)({mode:""}),[d,u]=(0,a.useState)({showModal:!1,contact:void 0}),m=Dg();(0,a.useEffect)((()=>{if(i){const e=[...i];e.sort(((e,t)=>t.priority-e.priority)),r(e)}}),[i]);const h=e=>()=>{c({mode:"edit",contact:e})},x=()=>c({contact:void 0,mode:""}),p=(0,jh.VT)(jh.we,{activationConstraint:{distance:1}}),g=(0,jh.VT)(jh.MA),f=(0,jh.VT)(jh.LO),v=(0,jh.VT)(jh.Lg),j=(0,jh.Dy)(g,f,v,p);return(0,H.jsxs)(jh.LB,{collisionDetection:jh.pE,onDragEnd:e=>{const{active:t,over:n}=e;n&&t.id!==n.id&&r((e=>{const a=e.findIndex((e=>e.id===t.id)),s=e.findIndex((e=>e.id===n.id)),r=(0,Lg.Rp)(e,a,s),i=r.length;return r.map(((e,t)=>Object.assign({},e,{priority:i-t-1})))}))},sensors:j,children:[(0,H.jsxs)("div",{className:"relative px-8 text-sm",children:[(0,H.jsx)("div",{className:"mb-2",children:(0,H.jsx)(B,{type:"info",children:"Higher priority contacts are displayed first. Drag and drop to rearrange the order"})}),(0,H.jsx)("div",{className:"text-onlight-text-2 dark:text-ondark-text-2 bg-onlight-bg-2 dark:bg-ondark-bg-2 grid grid-cols-5 px-4 py-6 font-bold",children:m.map((e=>(0,H.jsx)("div",{children:e.name},e.id)))}),o&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"dark:bg-dark-bg/70 absolute inset-0 z-10 bg-white/70"}),(0,H.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:(0,H.jsx)(K,{})})]}),0===s.length&&(0,H.jsx)("div",{className:"text-onlight-text-3 dark:text-ondark-text-3 my-4 text-center text-sm",children:"No contacts found for this location. Go ahead and add one."}),(0,H.jsx)(Lg.Fo,{items:s,strategy:Lg.qw,children:s.map((e=>{return(0,H.jsx)(Zg,{contact:e,onEdit:h(e),onDelete:(t=e,()=>{if(t.id.toString().includes(Rg)){const e=[...s].filter((e=>e.id!==t.id)),n=e.map(((t,n)=>Object.assign({},t,{priority:e.length-n-1})));r(n)}else u({showModal:!0,contact:t})})},e.id);var t}))}),(0,H.jsx)(Pg,{newData:s,oldData:i||[],onAddNewContact:()=>c({mode:"add"}),locationId:t,tenantId:n})]}),l.mode&&(0,H.jsx)(qg,{mode:l.mode,contact:l.contact,onClose:x,onSubmitCb:e=>{if("edit"===l.mode){const t=s.map((t=>(t.id===e.id&&(t=e),t)));r(t)}else if("add"===l.mode){const t=[...s,e],n=t.map(((e,n)=>Object.assign({},e,{priority:t.length-n-1})));r(n)}x()}}),d.showModal&&d.contact&&(0,H.jsx)(Mg,{contact:d.contact,onClose:()=>u({showModal:!1})})]})}const Vg={name:"",description:"",city:"",state:"",country:"",timezone:"",location_code:"",is_manned:!0,isDeadzoneEnabled:!0};const $g=function(e){const{onClose:t,mode:n,location:s}=e,[r,i]=(0,a.useState)("edit"===n&&s?Object.assign({},s):Vg),o=Pn((()=>{Le("Location added",{type:"success"}),t()})),l=Vn((()=>{Le("Location updated",{type:"success"}),t()}),s?s.id:0),c="add"===n?o:l,d=Object.entries(r).some((([e,t])=>(""!==t||"location_code"!==e)&&""===t)),u=e=>t=>{i((n=>Object.assign({},n,{[e]:"string"==typeof t||"boolean"==typeof t?t:t.target.value})))},m=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{c.mutate(r)},disabled:d||c.isLoading,children:"add"===n?"Submit":"Save"}),(0,H.jsx)(Q,{onClick:t,children:"Cancel"})]});return(0,H.jsx)(ce,{title:("add"===n?"Add":"Edit")+" Location",open:!0,onClose:t,footer:m,children:(0,H.jsxs)("div",{className:"w-[36rem] space-y-4 p-8",children:[(0,H.jsx)(ae,{type:"text",label:"Name",value:r.name,onChange:u("name")}),(0,H.jsx)(pe,{rows:2,label:"Description",value:r.description,onChange:u("description")}),(0,H.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,H.jsx)(ae,{type:"text",label:"City",value:r.city,onChange:u("city")}),(0,H.jsx)(ae,{type:"text",label:"State",value:r.state,onChange:u("state")}),(0,H.jsx)(ae,{type:"text",label:"Country",value:r.country,onChange:u("country")}),(0,H.jsx)(ll,{value:r.timezone,onChange:u("timezone")}),(0,H.jsx)(ae,{type:"text",label:"Location Code",value:r.location_code?r.location_code:"",onChange:u("location_code"),placeholder:"(Optional)"})]}),(0,H.jsxs)("div",{className:"flex flex-col gap-6 pt-4",children:[(0,H.jsx)(we,{enabled:!!r.is_manned,label:"Staffed Location",onChange:u("is_manned"),infoText:"Indicate if this location is regularly staffed by personnel"}),(0,H.jsx)(we,{enabled:!!r.isDeadzoneEnabled,label:"Is Deadzone Enabled",onChange:u("isDeadzoneEnabled"),infoText:"Indicate if editing deadzone is allowed for this location"})]})]})})};function zg(e,t){return co().unix(e).tz(t).format("DD MMMM YYYY, h:mm A")}function Hg(e,t){if(e in[0,1])return"";return co().unix(e).tz(t).format("YYYY-MM-DDTHH:mm")}co().extend(xo()),co().extend(mo());const Bg={startTimestamp:0,endTimestamp:1,timezone:"UTC"};const Wg=function(e){const{tenantId:t,siteDisarmWindow:n=Bg,onClose:s,isRelevantWindow:r}=e,[i,o]=(0,a.useState)((()=>({startTime:r?n.startTimestamp:0,endTime:r?n.endTimestamp:0,timezone:n.timezone,tenantId:t}))),[l,c]=(0,a.useState)({isValid:!0,message:""}),[d,u]=(0,a.useState)(!1),m=aa((()=>{Le("Monitoring Disarm window successfully updated"),s()})),h=e=>t=>{const n=t.target.value,a=(s=n,r=i.timezone,co().tz(s,r).unix());var s,r;o((t=>Object.assign({},t,{[e]:a}))),c({isValid:!0,message:""})},x=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{if(d){const e=Object.assign({},i,{startTime:0,endTime:1});return void m.mutate(e)}const{isValid:e,message:t}=function(e){let t="";const{startTime:n,endTime:a}=e;return n>=a&&(t="End Time should not be same or less than start time"),1e3*a<(new Date).getTime()&&(t="End Time should not be less than current time"),{isValid:!t,message:t}}(i);e?m.mutate(i):c({isValid:e,message:t})},disabled:m.isLoading,loading:m.isLoading,onSideEffect:yt("update_monitoring_disarm_window"),children:"Submit"}),!d&&r&&(0,H.jsx)(Q,{variant:"outline",onClick:()=>u(!0),disabled:m.isLoading,children:"Discard Disarm window"}),(0,H.jsx)(Q,{onClick:d?()=>u(!1):s,children:"Cancel"})]}),p=i.endTime-i.startTime>86400;return(0,H.jsx)(ce,{title:"Update Monitoring Disarm Window",open:!0,onClose:s,footer:x,children:(0,H.jsxs)("div",{className:"space-y-4 p-8",children:[m.isError&&(0,H.jsx)(B,{type:"error",children:m.error.message}),!l.isValid&&(0,H.jsx)(B,{type:"warning",children:l.message}),p&&(0,H.jsx)(B,{type:"info",children:"Be aware that time window between start time and end time is more than 24 hours"}),d&&(0,H.jsxs)("p",{className:"leading-relaxed",children:["This will cancel the temporary disarm period, and ",(0,H.jsx)("br",{})," monitoring will resume according to the Site Monitoring Schedule."]}),!d&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(B,{type:"info",children:["Temporarily disarm monitoring for the specified period.",(0,H.jsx)("br",{}),"Otherwise, monitoring will follow the Site Monitoring Schedule."]}),(0,H.jsx)(ll,{value:i.timezone||"UTC",onChange:e=>{o((t=>Object.assign({},t,{timezone:e})))}}),(0,H.jsx)(ae,{label:"Start time",onChange:h("startTime"),type:"datetime-local",value:Hg(i.startTime,i.timezone),required:!0}),(0,H.jsx)(ae,{label:"End time",onChange:h("endTime"),type:"datetime-local",value:Hg(i.endTime,i.timezone),required:!0})]})]})})};const Gg=function(e){const{location:t}=e,[n,s]=(0,a.useState)(),[r,i]=(0,a.useState)(!1),{isLoading:o,isError:l,error:c,data:d}=Un(t.id,t.tenant_id||"");(0,a.useEffect)((()=>{d&&s(d.disarmWindow)}),[d]);const u=n&&1e3*n.endTimestamp>=(new Date).getTime();return(0,H.jsxs)("div",{className:"flex items-center gap-4",children:[o&&(0,H.jsx)("div",{className:"flex h-24 items-center justify-center",children:(0,H.jsx)(K,{})}),l&&(0,H.jsx)(B,{type:"error",children:c.message}),u&&(0,H.jsxs)("div",{className:"flex flex-col text-xs",children:[(0,H.jsxs)("div",{className:"space-x-2",children:[(0,H.jsx)("span",{className:"text-sm font-bold text-red-500",children:"Monitoring Disarmed"}),(0,H.jsxs)("span",{children:["(time in ",n.timezone,")"]})]}),(0,H.jsxs)("span",{children:[(0,H.jsx)("b",{children:"From: "}),zg(n.startTimestamp,n.timezone)]}),(0,H.jsxs)("span",{children:[(0,H.jsx)("b",{children:"Till: "}),zg(n.endTimestamp,n.timezone)]})]}),(0,H.jsx)(Q,{variant:u?"outline":"error",onClick:()=>i(!0),children:u?"Update Disarm Status":"Disarm Monitoring"}),r&&t.tenant_id&&(0,H.jsx)(Wg,{onClose:()=>i(!1),siteDisarmWindow:n,tenantId:t.tenant_id,isRelevantWindow:u})]})};const Kg=function(e){const{location:t}=e,[n,s]=(0,a.useState)(!1);return(0,H.jsxs)("div",{className:"dark:border-dark-border-bg border-onlight-line-3 mb-2 flex items-center justify-between border-b py-2",children:[(0,H.jsxs)("div",{className:"flex items-center gap-4",children:[(0,H.jsxs)("div",{className:"border-onlight-line-3 dark:border-dark-border-bg flex flex-col justify-between gap-1 border-r pr-2",children:[(0,H.jsx)("h2",{className:"text-onlight-text-1 dark:text-ondark-text-1 pt-1 text-base",children:t.name}),(0,H.jsx)("div",{className:"text-onlight-text-2 dark:text-ondark-text-2 inline-flex items-center text-xs",children:`${t.description}, ${t.city}, ${t.state}, ${t.country}`})]}),(0,H.jsxs)("div",{children:[(0,H.jsxs)(Q,{variant:"icon",onClick:()=>s(!0),classNames:"flex gap-2",children:[(0,H.jsx)(Ko.Z,{className:"h-5 w-5"}),"Edit Location"]}),n&&(0,H.jsx)($g,{onClose:()=>{s(!1)},mode:"edit",location:t})]})]}),(0,H.jsx)(Gg,{location:t})]})};co().extend(xo()),co().extend(mo());const Yg=(e,t,n)=>{let a=[...n];const s=n[e],r=t.enabledDays.findIndex(((e,t)=>e!==s.enabledDays[t]));if(-1===r)return a[e]=t,a;return t.enabledDays[r]?a=a.map(((t,n)=>(n!==e&&(t.enabledDays[r]=!1),t))):a[0].enabledDays[r]=!0,a[e]=t,a},Qg=(e,t)=>{const n=[...t],a=n.splice(e,1)[0];return t[0].enabledDays=t[0].enabledDays.map(((e,t)=>(a.enabledDays[t]&&(e=!0),e))),n},Xg=e=>{const[t,n]=e.split(":").map(Number);return 60*t+n},Jg=e=>{const t=Math.floor(e/60),n=e%60;return`${String(t).padStart(2,"0")}:${String(n).padStart(2,"0")}`},ef=e=>{let t=!0,n="";for(let a=0;a<e.length;a++){const s=e[a],r=s.startTime,i=s.endTime;if(""===r||""===i){t=!1,n="Please provide a start time and an end time for every schedule.";break}if(r===i){t=!1,n="Start time and end time should not be same for a schedule.";break}s.enabledDays.every((e=>!1===e))&&(t=!1,n="Ensure at least one day is chosen for each schedule.")}return{isValid:t,message:n}},tf=()=>({startTime:"",endTime:"",enabledDays:new Array(7).fill(!0)});const nf=(e,t)=>(1===t?e.unshift(!!e.pop()):-1===t&&e.push(!!e.shift()),e);const af=e=>{const t=l(),n=t.map((e=>({name:e.name,symbol:e.symbol,ranges:[]})));return e.forEach((e=>{const a=e.enabledDays;for(let s=0;s<a.length;s++)if(a[s]&&e.startTime&&e.endTime){const a=Xg(e.startTime),r=Xg(e.endTime);if(a<=r)n[s].ranges.push({startTime:a,endTime:r});else{n[s].ranges.push({startTime:a,endTime:Xg("23:59")});const e=(s+1)%t.length;n[e].ranges.push({startTime:Xg("00:00"),endTime:r,isOverflow:!0})}}})),n};const sf=function(e){const{schedules:t}=e,[n,s]=(0,a.useState)([]);(0,a.useEffect)((()=>{const e=af(t);s(e)}),[t]);const r=(e,t)=>{const n=t-e;return Math.floor(400*n/1440)},i=e=>400*e/1440;return(0,H.jsxs)("div",{className:"flex flex-col gap-10",children:[(0,H.jsx)("div",{className:"text-center underline",children:"Monitoring overview"}),n.map(((e,t)=>(0,H.jsxs)("div",{className:"flex items-center gap-10",children:[(0,H.jsx)("span",{className:"text-sm",children:e.symbol}),(0,H.jsx)("div",{style:{width:"400px"},className:"dark:border-ondark-line-2 relative h-5 border",children:e.ranges.map((e=>(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{style:{width:`${r(e.startTime,e.endTime)}px`,left:i(e.startTime)},className:"bg-primary-300 dark:bg-primary-700 absolute top-[1px] z-10 h-4"}),(0,H.jsx)("span",{style:{left:i(e.startTime)-8},className:"absolute -top-4 text-xs",children:Jg(e.startTime)}),(0,H.jsx)("span",{style:{left:i(e.endTime)-8},className:"absolute -bottom-4 text-xs",children:Jg(e.endTime)}),(0,H.jsx)("span",{className:"absolute top-1 right-0 z-0 text-[8px]",children:"24:00"}),(0,H.jsx)("span",{className:"absolute top-1 left-0 z-0 text-[8px]",children:"00:00"})]})))})]},`${t}-${e.name}`))),(0,H.jsxs)("div",{className:"dark:border-dark-border-surface flex items-center justify-center gap-4 border-t p-2",children:[(0,H.jsx)("div",{className:"bg-primary-300 dark:bg-primary-700 h-5 w-5"}),(0,H.jsx)("span",{className:"text-xs",children:"Monitored Hours"})]})]})};function rf(e){const{selectedDays:t,updateSelectedDays:n,disableSelectedDays:a}=e,s=e=>()=>{const a=[...t];a[e]=!a[e],n(a)},r=l();return(0,H.jsx)("div",{className:"dark:text-ondark-text-2 bg-on flex items-center justify-center gap-2 ",children:r.map(((e,n)=>(0,H.jsx)(Q,{classNames:(0,z.Z)("w-6",t[n]?"text-ondark-text-1 bg-primary-500 enabled:hover:bg-primary-700 dark:enabled:hover:bg-primary-600":"bg-ondark-text-1 dark:bg-ondark-bg-3 dark:enabled:hover:bg-ondark-text-3 enabled:hover:bg-ondark-text-2"),variant:"icon",disabled:a&&t[n],onClick:s(n),title:e.name,children:e.symbol},e.name)))})}const of=function(e){const{schedule:t,updateSchedule:n,isDeletable:a,onDelete:s,isDefault:r}=e,{startTime:i,endTime:o,enabledDays:l}=t,c=i&&o&&Xg(i)>Xg(o);return(0,H.jsxs)("div",{className:"flex items-center gap-4",children:[(0,H.jsx)("div",{className:"w-32",children:(0,H.jsx)(ae,{label:"Start time",onChange:e=>n(Object.assign({},t,{startTime:e.target.value})),type:"time",value:i,required:!0})}),(0,H.jsxs)("div",{className:"relative w-32",children:[c&&(0,H.jsx)("span",{className:"text-onlight-text-3 dark:text-ondark-text-2 absolute top-1 right-2 text-xs",children:"+1 Day"}),(0,H.jsx)(ae,{label:"End time",onChange:e=>n(Object.assign({},t,{endTime:e.target.value})),type:"time",value:o})]}),(0,H.jsxs)("div",{className:"mt-4 flex gap-6",children:[(0,H.jsx)(rf,{selectedDays:l,updateSelectedDays:e=>n(Object.assign({},t,{enabledDays:e})),disableSelectedDays:!a}),a&&(0,H.jsx)(Q,{variant:"icon",onClick:s,title:"Delete schedule",classNames:"ml-4",children:(0,H.jsx)(Yo.Z,{className:"h-5 w-5"})}),r&&(0,H.jsx)("div",{children:(0,H.jsx)(re,{type:"info",small:!0,text:"Default"})})]})]})};const lf=function(e){const{location:t}=e,[n,s]=(0,a.useState)([tf()]),r=Ge(j(),"tenant_config:update"),[i,l]=(0,a.useState)([]),[c,d]=(0,a.useState)(""),[u,m]=(0,a.useState)(),[h,x]=(0,a.useState)(),p=O(u),{isLoading:g,isError:f,error:v,data:b}=Un(t.id,t.tenant_id||""),[y,k]=(0,a.useState)(!1),w=zn((()=>{Le("Site schedule updated",{type:"success"}),k(!1)}));(0,a.useEffect)((()=>{u&&p&&u!==p&&s(function(e,t,n){return e.map((e=>{const a=e.startTime,s=e.endTime,r="utc"===n.toLowerCase(),[i,o]=a.split(":");let l=r?co().utc():co()().tz(n);l=l.set("hour",+i).set("minute",+o);const[c,d]=s.split(":");let u=r?co().utc():co()().tz(n);u=u.set("hour",+c).set("minute",+d);const m=l.tz(t),h=u.tz(t);if(e.startTime=m.format("HH:mm"),e.endTime=h.format("HH:mm"),u.format("d")!==m.format("d")){let t=parseInt(m.format("d"))-parseInt(u.format("d"));t/=Math.abs(t);const n=nf([...e.enabledDays],t);e.enabledDays=n}return e}))}(n,u,p))}),[u,p,n]),(0,a.useEffect)((()=>{if(b){const e=function(e){const t=[];t.push({startTime:e.start_time,endTime:e.end_time,enabledDays:new Array(7).fill(!0)});const n={};return(e.overrides||[]).forEach((e=>{const a=o.indexOf(e.day_of_week.toUpperCase()),s=`${e.start_time}-${e.end_time}`;n[s]?n[s].push(a):n[s]=[a],t[0].enabledDays[a]=!1})),Object.entries(n).forEach((([e,n])=>{const[a,s]=e.split("-"),r=new Array(7).fill(!1);n.forEach((e=>r[e]=!0)),t.push({startTime:a,endTime:s,enabledDays:r})})),t}(b);s(e),l([...e]),m(b.timezone||"UTC"),x(b.timezone||"UTC")}}),[b]);const N=e=>t=>{d(""),y&&s(Yg(e,t,n))},C=e=>()=>{7===n.length&&d(""),s(Qg(e,n))};return(0,H.jsxs)("div",{className:"mx-auto flex justify-between",children:[(0,H.jsxs)("div",{className:"flex flex-col gap-4 p-10",children:[c&&(0,H.jsx)(B,{type:"warning",children:c}),f&&(0,H.jsx)(B,{type:"error",children:v.message}),w.isError&&(0,H.jsx)(B,{type:"error",children:w.error.message}),g?(0,H.jsx)("div",{className:"flex h-24 items-center justify-center",children:(0,H.jsx)(K,{})}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ll,{value:u||"UTC",onChange:m}),n.map(((e,t)=>(0,H.jsx)("div",{className:(0,z.Z)(!y&&"pointer-events-none"),children:(0,H.jsx)(of,{schedule:e,updateSchedule:N(t),isDeletable:t>0&&y,isDefault:0===t,onDelete:C(t)})},t)))]}),y?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"dark:border-dark-border-surface flex gap-2 border-t px-8"}),(0,H.jsxs)("div",{className:"flex flex-row gap-4 p-4",children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{if(""===u)return void d("Please select a timezone");const{isValid:e,message:a}=ef(n);e?u&&w.mutate(function(e,t,n){const a={start_time:e[0].startTime,end_time:e[0].endTime,overrides:[],timezone:t,tenant_id:n};e.length>1&&e.slice(1).forEach((e=>{e.enabledDays.forEach(((t,n)=>{if(t){const t={start_time:e.startTime,end_time:e.endTime,day_of_week:o[n]};a.overrides?a.overrides.push(t):a.overrides=[t]}}))}));return a}(n,u,t.tenant_id||"")):d(a)},loading:w.isLoading,onSideEffect:yt("save_site_schedule"),children:"Save"}),(0,H.jsx)(Q,{onClick:()=>s([...n,{startTime:"",endTime:"",enabledDays:new Array(7).fill(!1)}]),variant:"outline",title:"Add a custom schedule to have different monitoring windows on specific days",disabled:7===n.length,children:"Add custom schedule"}),(0,H.jsx)(Q,{onClick:()=>{s([...i]),m(h),k(!1)},variant:"outline",children:"Cancel"})]})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"dark:border-dark-border-surface flex gap-2 border-t px-8"}),(0,H.jsx)("div",{className:"px-10 py-4",children:(0,H.jsx)(Q,{onClick:()=>k(!0),variant:"primary",title:"Edit Site Monitoring Schedule",disabled:!r,children:"Edit Schedule"})})]})]}),(0,H.jsx)("div",{className:"mr-10",children:b&&(0,H.jsx)(sf,{schedules:n})})]})};const cf=function(e){const{sopOverview:t,sopId:n,sopWorkflow:s}=e,[r,i]=(0,a.useState)(!1),[o,l]=(0,a.useState)(t),c=Yt(n,(()=>{i(!1),Le("SOP overview updated successfully",{type:"success"})}));return(0,a.useEffect)((()=>{r||l(t)}),[r,t]),(0,H.jsxs)("div",{children:[(0,H.jsxs)("div",{className:"border-onlight-line-2 dark:border-ondark-line-2 mb-2 flex items-center justify-between border-b p-2",children:[(0,H.jsx)("h2",{className:"font-bold",children:"Standard Operating procedure (SOP) Overview"}),(0,H.jsxs)("div",{className:"flex items-center gap-2",children:[(0,H.jsx)(Q,{variant:"icon",onClick:()=>{c.mutate({sop_text:JSON.stringify({sop_workflow:s})})},disabled:c.isLoading,title:"Depreciate SOP Overview",children:(0,H.jsx)($r.Z,{className:"h-5 w-5 text-red-500"})}),(0,H.jsx)(Q,{onClick:()=>i((e=>!e)),variant:"icon",children:r?(0,H.jsx)(le.Z,{className:"h-5 w-5"}):(0,H.jsxs)("span",{className:"flex gap-2",children:[(0,H.jsx)(Ko.Z,{className:"h-5 w-5"}),"Edit"]})})]})]}),r?(0,H.jsxs)(H.Fragment,{children:[c.isError&&(0,H.jsx)(B,{type:"error",children:c.error.message}),(0,H.jsx)(pe,{rows:20,value:o,onChange:e=>l(e),placeholder:"Compose the Standard Operating Procedure (SOP) here. Utilize HTML formatting to structure content seamlessly."}),(0,H.jsxs)("div",{className:"flex gap-4 px-2 py-4",children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{const e={sop_overview:o,sop_workflow:s};c.mutate({sop_text:JSON.stringify(e)})},disabled:t===o,loading:c.isLoading,children:"Submit"}),(0,H.jsx)(Q,{onClick:()=>i(!1),children:"Cancel"})]})]}):(0,H.jsx)("div",{className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 mt-1 space-y-4 whitespace-pre-wrap p-3 text-sm",dangerouslySetInnerHTML:{__html:t}})]})};const df=function(e){const{locationId:t}=e,[n,s]=(0,a.useState)(),{isLoading:r,isRefetching:i,isError:o,error:l}=qt({locationId:t},(async({sop_text:e,sop_workflow:t,id:n})=>{const a=await T();s({sop_text:a(e),sop_workflow:t,id:n})}));if(r||i)return(0,H.jsx)("span",{className:"flex h-[26rem] w-full items-center justify-center",children:(0,H.jsx)(K,{})});let c=null==n?void 0:n.sop_workflow;var d,u,m;return c&&(c=Object.assign({},c,{notes:null!=(d=c.notes)?d:[],escalationProtocol:null!=(u=c.escalationProtocol)?u:[],quickResolveActions:null!=(m=c.quickResolveActions)?m:[]})),(0,H.jsxs)(H.Fragment,{children:[o&&(0,H.jsx)(B,{type:"error",children:l.message}),n&&(0,H.jsxs)("div",{className:"flex gap-4 divide-x",children:[(null==n?void 0:n.sop_text)&&(0,H.jsx)("div",{className:"flex-0",children:(0,H.jsx)(cf,{sopOverview:n.sop_text,sopId:(null==n?void 0:n.id)||"",sopWorkflow:c})}),(0,H.jsx)(ol,{sopWorkflow:c,sopId:(null==n?void 0:n.id)||""})]})]})};let uf=function(e){return e.FLOOR_PLAN="floorPlan",e.SITE_MONITORING_SCHEDULE="siteMonitoringSchedule",e.SOP="Sop",e.LOCATION_CONTACTS="locationContacts",e}({});const mf=[{id:uf.SITE_MONITORING_SCHEDULE,name:"Site Monitoring Schedule"},{id:uf.SOP,name:"SOP"},{id:uf.FLOOR_PLAN,name:"Floor Plan"},{id:uf.LOCATION_CONTACTS,name:"Point of Contact"}];const hf=function(e){const{location:t}=e,[n,s]=(0,a.useState)(mf[0].id),i=(0,r.s0)();return(0,H.jsx)(mr,{title:"Location Details",onClickBack:()=>{i("/locations")},children:(0,H.jsxs)("div",{className:"px-4",children:[(0,H.jsx)(Kg,{location:t}),(0,H.jsx)(xe,{items:mf,activeTabId:n,onChange:e=>s(e)}),(0,H.jsxs)("div",{className:"py-6",children:[n===uf.FLOOR_PLAN&&(0,H.jsx)(Ig,{location:t}),n===uf.SOP&&(0,H.jsx)(df,{locationId:t.id.toString()}),n===uf.SITE_MONITORING_SCHEDULE&&(0,H.jsx)(lf,{location:t}),n===uf.LOCATION_CONTACTS&&(0,H.jsx)(Ug,{locationId:t.id,tenantId:t.tenant_id||""})]})]})})};function xf(e){const{locationId:t}=e,n=On(t);return(0,H.jsx)(Is,{queryResult:n,children:e=>(0,H.jsx)(hf,{location:e})})}const pf=nt(ht((function(){const{locationId:e}=(0,r.UO)();return void 0===e?(0,H.jsx)(As,{}):(0,H.jsx)(xf,{locationId:e})})),["location:update"]);const gf={filters:{name:{values:[],negative:!1}},page:1,pageSize:20},ff={state:gf,dispatch:()=>null},vf=(0,a.createContext)(ff),jf=(0,cm.ZP)(((e,t)=>{switch(t.type){case"UPDATE_FILTERS":e.filters=t.payload;break;case"UPDATE_PAGE":e.page=t.payload;break;default:throw new Error}}));const bf=function(e){const{children:t}=e,[n,s]=(0,a.useReducer)(jf,gf);return(0,H.jsx)(vf.Provider,{value:{state:n,dispatch:s},children:t})},yf="UPDATE_FILTERS",kf="UPDATE_PAGE";function wf(e){return{type:kf,payload:e}}var Nf=n(72054);const Cf=(0,H.jsx)(Nf.Z,{className:" flex h-5 w-5 flex-shrink-0 items-center justify-between"}),Sf=[{id:"location_code",name:"Location Code"},{id:"is_manned",name:"Staffed Location"},{id:"name",name:"Name"},{id:"description",name:"Description",showAtBreakpoint:"sm"},{id:"city",name:"City",showAtBreakpoint:"sm"},{id:"state",name:"State",showAtBreakpoint:"md"},{id:"country",name:"Country",showAtBreakpoint:"lg"},{id:"timeZone",name:"Time Zone",showAtBreakpoint:"xl"},{id:"actions",name:"",showAtBreakpoint:"sm"}];const Tf=[{id:"name",name:"Name"},{id:"city",name:"City"},{id:"state",name:"State"},{id:"country",name:"Country"},{id:"location_code",name:"Location Code"},{id:"is_manned",name:"Is Staffed"}];function Ef(e){const{canAddLocation:t,hasCustomFiltersApplied:n,isLoading:s,onClickFilter:r,onClickAddLocation:i,onSearch:o,filterValue:l,onChangeFilter:c,allColumns:d,onChangeShownColumns:u,shownColumns:m}=e,[h,x]=(0,a.useState)(""),p=R(h,400);(0,a.useEffect)((()=>{o(p)}),[p,o]);const g=(0,a.useMemo)((()=>d.filter((e=>"actions"!==e.id))),[d]),f=[{label:"All Locations",value:""},{label:"Staffed Locations",value:!0},{label:"Unstaffed Locations",value:!1}];return(0,H.jsxs)("div",{className:(0,z.Z)("dark:bg-dark-bg flex items-center border-b bg-white p-4 dark:border-0",t?"justify-between":"justify-end"),children:[t&&(0,H.jsxs)(Q,{variant:"primary",onClick:i,disabled:s,onSideEffect:yt("open_add_location_modal"),children:["Add Location",(0,H.jsx)("span",{className:"sr-only",children:"Add Location"})]}),(0,H.jsxs)("div",{className:"flex flex-row items-center justify-end gap-4 ",children:[(0,H.jsxs)("div",{className:" bg-onlight-bg-2 dark:bg-ondark-bg-2 flex flex-row items-center justify-end gap-2 rounded-md p-1",children:["is_manned"===l.id?(0,H.jsx)(Us,{value:f.find((e=>String(e.value)===h)),placeholder:"Select a relevant option",getItems:()=>f,displayValue:e=>(null==e?void 0:e.label)||"",onChange:e=>x(String(null==e?void 0:e.value)||"")}):(0,H.jsx)(ae,{label:"",onChange:e=>{x(e.target.value)},value:h,type:"search",placeholder:`Filter with ${l.name}...`}),(0,H.jsx)("div",{className:"w-60",children:(0,H.jsx)(Us,{value:l,getItems:()=>Tf,displayValue:e=>e?null==e?void 0:e.name:"",onChange:e=>{e&&c(e),x("")}})})]}),(0,H.jsx)("div",{className:"h-4 border-l border-black/20 dark:border-white/20"}),(0,H.jsx)(Li,{options:g,shownColumns:m,onChangeShownColumns:u}),(0,H.jsxs)(Q,{variant:"icon",badge:n,onClick:r,disabled:s,onSideEffect:yt("open_location_filters_panel"),children:[(0,H.jsx)("span",{className:"sr-only",children:"Open filters panel"}),(0,H.jsx)(_d.Z,{className:"h-5 w-5","aria-hidden":"true"})]})]})]})}const Af={values:[],negative:!1};const _f=function(e){const{locationFilterValue:t,onChangeLocationFilterValue:n,onApplyFilters:a,onResetFilters:s}=e,r=qn();return(0,H.jsxs)("div",{className:"space-y-6",children:[(0,H.jsx)("div",{className:"dark:divide-dark-border-bg dark:border-dark-border-bg divide-y border-t border-b",children:(0,H.jsx)(dd,{title:"Location",content:(0,H.jsx)(Yc,{value:t,label:"Name",onChange:n,enableNegativeFilters:!0,getOptions:r}),hasFilterApplied:t.values.length>0})}),(0,H.jsx)(rd,{onApply:a,onReset:s,trackingEventNameApply:"apply_locations_filters",trackingEventNameReset:"reset_locations_filters"})]})};const If=function(e){const{open:t,onClose:n,filters:s,onApplyFilters:r}=e,[i,o]=(0,a.useState)(s.name);return(0,H.jsx)(_s,{title:"Locations Filters",open:t,onClose:n,children:(0,H.jsx)(_f,{locationFilterValue:i,onChangeLocationFilterValue:o,onApplyFilters:()=>{r({name:i}),n()},onResetFilters:()=>{o(Af)}})})};const Lf=nt(ht((function(){const e=function(){const{state:e}=(0,a.useContext)(vf);return e}(),t=function(){const{dispatch:e}=(0,a.useContext)(vf);return e}(),{filters:n,page:s,pageSize:i}=e,[o,l]=(0,a.useState)({columns:Sf,rows:[]}),[c,d]=(0,a.useState)(0),[u,m]=(0,a.useState)(!1),[h,x]=(0,a.useState)(!1),[p,g]=(0,a.useState)(Tf[0]),[f,v]=(0,a.useState)(""),b=Ge(j(),"location:update"),y=(0,a.useMemo)((()=>b?Sf:Sf.filter((e=>"actions"!==e.id))),[b]),[k,w]=M("location-list-shown-columns",y.map((e=>e.id))),{isLoading:N,isError:C,error:S,data:T}=Zn(function(e,t,n,a,s){const r=new URLSearchParams;return r.append("page",String(e)),r.append("pageSize",String(n)),t.name.values.length>0&&r.append("name",t.name.values.map((e=>e.name)).join(Yn)),""!==a&&r.append(s.id,a),r.toString()}(s,n,i,f,p)),E=(s-1)*i,A=Math.min(s*i,c)-1,_=function(){const e=(0,r.s0)();return(0,a.useCallback)(((t,n)=>{n.ctrlKey||n.metaKey?window.open(t,"_blank","noopener,noreferrer"):e(t)}),[e])}();(0,a.useEffect)((()=>{if(T){const{items:e,total:t}=T;l(function(e,t,n,a){return{rows:e.map((e=>{const s=`/locations/${e.id}`,r=n.reduce(((t,n)=>{if(a.includes(n.id))switch(n.id){case"location_code":t.push({value:e.location_code?e.location_code:"-"});break;case"is_manned":t.push({value:(0,H.jsx)(J,{checked:!!e.is_manned})});break;case"actions":t.push({value:Cf});break;default:t.push({value:e[n.id]})}return t}),[]),i={id:String(e.id),cells:r};return n.some((e=>"actions"===e.id))&&(i.onClick=e=>{t(s,e)}),i})),columns:n.filter((e=>a.includes(e.id)))}}(e,_,y,k||[])),d(t)}}),[T,_,f,y,k]);const I=Ge(j(),"location:create"),L=(0,H.jsx)(Ef,{canAddLocation:I,hasCustomFiltersApplied:n.name.values.length>0,isLoading:N,onClickAddLocation:()=>x(!0),onClickFilter:()=>m(!0),onSearch:e=>{v(e)},filterValue:p,onChangeFilter:e=>{g(e)},allColumns:y,shownColumns:k||[],onChangeShownColumns:e=>w(e)}),R=(0,H.jsx)("div",{className:"dark:bg-dark-bg border-t bg-white p-4 dark:border-gray-800",children:(0,H.jsx)(wi,{from:E+1,to:A+1,pageSize:i,total:c,disabled:N,onChangePage:e=>t(wf(e))})});return(0,H.jsxs)(mr,{title:"Locations",children:[C&&(0,H.jsx)("div",{className:"mb-2",children:(0,H.jsx)(B,{type:"error",children:S.message})}),h&&(0,H.jsx)($g,{onClose:()=>x(!1),mode:"add"}),(0,H.jsx)(If,{open:u,filters:n,onApplyFilters:e=>{t({type:yf,payload:e}),t(wf(1))},onClose:()=>m(!1)}),(0,H.jsx)("div",{className:"dark:bg-dark-bg -mx-4 flex min-h-0 flex-1 flex-col justify-start overflow-y-hidden sm:-mx-6 md:mx-0 md:rounded-lg",children:(0,H.jsx)(Ai,{data:o,header:L,footer:R,loading:N})})]})})),["location:view"]);const Rf=function(){return(0,H.jsxs)(r.Z5,{children:[(0,H.jsx)(r.AW,{path:"/",element:(0,H.jsx)(Lf,{})}),(0,H.jsx)(r.AW,{path:":locationId",element:(0,H.jsx)(pf,{})})]})};function Df(){return(0,H.jsx)(bf,{children:(0,H.jsx)(Rf,{})})}const Pf=({data:e,header:t})=>(0,H.jsxs)("div",{className:"relative overflow-visible",children:[t,(0,H.jsxs)("table",{className:"min-w-full",children:[(0,H.jsx)("thead",{children:(0,H.jsx)("tr",{children:e.columns.map((e=>(0,H.jsx)("th",{className:(0,z.Z)("bg-onlight-bg-3 dark:bg-ondark-bg-2 z-20 px-6 py-3 text-left text-sm font-semibold tracking-wider"),children:e.name},e.id)))})}),(0,H.jsx)("tbody",{className:"dark:divide-ondark-line-1 divide-onlight-line-3  group divide-y focus-visible:outline-none",children:e.rows.map((e=>(0,H.jsx)("tr",{className:"relative overflow-visible",children:e.cells.map(((e,t)=>(0,H.jsx)("td",{className:"align-text-left text-md relative overflow-visible whitespace-nowrap px-6 py-4 font-normal",children:e.value},t)))},e.id)))})]})]});const Mf=function(e){const{item:t,isAdding:n,onChange:s,selectedNotificationSounds:r}=e,[i,o]=(0,a.useState)(t.notificationSound);return(0,H.jsxs)("div",{className:"flex flex-row gap-x-6",children:[n?(0,H.jsx)("div",{className:"w-40",children:(0,H.jsx)(Us,{value:t.notificationSound,displayValue:e=>e||"",placeholder:"Select sound",getItems:e=>(e=>d.filter((t=>t.toLowerCase().includes(e.toLowerCase()))))(e),onChange:e=>e&&(e=>{o(e),s(e)})(e),disabled:e=>!!r.includes(e)})}):(0,H.jsx)("p",{children:t.notificationSound}),(0,H.jsx)("div",{className:(0,z.Z)(""===i&&"pointer-events-none cursor-default","cursor-pointer"),children:(0,H.jsx)(Mr,{src:`assets/notif-sounds/${i}.mp3`,isLoading:!1})})]})};const Of=function(e){var t;const{item:n,onCancelEdit:s}=e,[r,i]=(0,a.useState)(!1),o=()=>{i(!1)},l=pa((()=>{Le("Alarm notification configuration added/updated successfully.",{type:"success"}),o(),s()})),c=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{l.mutate(function(e){return e.id===qf?{notification_sound:e.notificationSound,alarm_types:e.alarmTypes}:{id:e.id,notification_sound:e.notificationSound,alarm_types:e.alarmTypes}}(n))},loading:l.isLoading,children:"Confirm"}),(0,H.jsx)(Q,{variant:"outline",onClick:o,children:"Go Back"})]});return(0,H.jsxs)("div",{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{const e=function(e){let t=!0;(""===e.notificationSound||e.alarmTypes&&0===e.alarmTypes.length)&&(t=!1);return t}(n);e?i(!0):Le("Please select alarm types and notification sound",{type:"error"})},children:"Save"}),(0,H.jsx)(ce,{open:r,onClose:o,footer:c,title:"Add/Update Alarm Notification Configuration",children:(0,H.jsxs)("div",{className:"max-w-3xl p-8",children:[l.isError?(0,H.jsx)("div",{className:"py-2",children:(0,H.jsx)(B,{type:"error",children:null==(t=l.error)?void 0:t.message})}):null,(0,H.jsxs)("div",{className:"space-y-4",children:[(0,H.jsx)("p",{children:"Are you sure you want to add/update the alarm notification with below configuration?"}),(0,H.jsxs)("div",{className:"grid grid-cols-2 py-3 text-left font-semibold text-gray-700 dark:text-gray-400",children:[(0,H.jsx)("span",{children:"Notification Sound"}),(0,H.jsx)("span",{children:"Alarm Types"})]}),(0,H.jsxs)("div",{className:"grid grid-cols-2 text-sm",children:[(0,H.jsx)("span",{children:n.notificationSound}),(0,H.jsx)("div",{children:n.alarmTypes.map(((e,t)=>(0,H.jsxs)("div",{children:[(0,H.jsx)("span",{children:e}),(0,H.jsx)("br",{})," "]},t)))})]})]})]})})]})};const Ff=function(e){const{item:t}=e,[n,s]=(0,a.useState)(!1),r=()=>{s(!1)},i=ha(t.id,(()=>{Le("Alarm notification configuration removed successfully",{type:"success"}),r()})),o=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"error",onClick:()=>{i.mutate({})},loading:i.isLoading,children:"Delete"}),(0,H.jsx)(Q,{variant:"outline",onClick:r,children:"Cancel"})]});return(0,H.jsxs)("div",{children:[(0,H.jsx)(Q,{variant:"icon",onClick:()=>s(!0),children:(0,H.jsx)(Yo.Z,{className:"h-6 w-6"})}),(0,H.jsx)(ce,{open:n,onClose:r,footer:o,title:"Delete Alarm Notification Configuration",children:(0,H.jsxs)("div",{className:"max-w-3xl p-8",children:[i.isError?(0,H.jsx)("div",{className:"py-2",children:(0,H.jsx)(B,{type:"error",children:i.error.message})}):null,(0,H.jsxs)("div",{className:"space-y-4",children:[(0,H.jsx)("p",{children:"Are you sure you want to delete the alarm notification with below configuration?"}),(0,H.jsxs)("div",{className:"grid grid-cols-2 py-3 text-left font-semibold text-gray-700 dark:text-gray-400",children:[(0,H.jsx)("span",{children:"Notification Sound"}),(0,H.jsx)("span",{children:"Alarm Types"})]}),(0,H.jsxs)("div",{className:"grid grid-cols-2 text-sm",children:[(0,H.jsx)("span",{children:t.notificationSound}),(0,H.jsx)("div",{children:t.alarmTypes.map(((e,t)=>(0,H.jsxs)("div",{children:[(0,H.jsx)("span",{children:e}),(0,H.jsx)("br",{})," "]},t)))})]})]})]})})]})};const Zf=function(e){const{isEditing:t,item:n,editingRow:a,onClickEdit:s,onCancelEdit:r}=e;return(0,H.jsx)("div",{children:t&&a===n.id?(0,H.jsxs)("div",{className:"mt-2 flex flex-row gap-x-6",children:[(0,H.jsx)(Of,{item:n,onCancelEdit:r}),(0,H.jsx)(Q,{variant:"outline",onClick:r,children:"Cancel"})]}):(0,H.jsxs)("div",{className:(0,z.Z)(t&&a!==n.id&&"pointer-events-none","mt-2 flex  flex-row gap-x-6"),children:[(0,H.jsxs)(Q,{variant:"icon",onClick:()=>s(n.id),classNames:"gap-1",children:[(0,H.jsx)(yp.Z,{className:"h-6 w-6"}),"Edit"]}),(0,H.jsx)(Ff,{item:n})]})})},qf="-1",Uf=[{id:"alarm-type",name:"Alarm Type",showAtBreakpoint:"sm"},{id:"notification-sound",name:"Notification Sound",showAtBreakpoint:"lg"},{id:"actions",name:"Action",showAtBreakpoint:"md"}];function Vf(){const e=j().tenant.id,[t,n]=(0,a.useState)(!1);na(e,(e=>{var t;null!=(t=e.alarmProcessingConfig)&&t.alarm_types?n(!0):n(!1)}));const{isLoading:s,isError:r,error:i,data:o}=xa(),[l,u]=(0,a.useState)([]),[m,h]=(0,a.useState)([]),[x,p]=(0,a.useState)(!1),[g,f]=(0,a.useState)(""),[v,b]=(0,a.useState)(!1),[y,k]=(0,a.useState)({}),[w,N]=(0,a.useState)([]),C=Ge(j(),"alarm/notifications:update"),[S,T]=(0,a.useState)({columns:Uf,rows:[]}),E=(0,H.jsx)("div",{className:"m-4 flex justify-start",children:(0,H.jsx)(Q,{variant:"primary",onClick:()=>{f(qf),p(!0),h((e=>[...e,{id:qf,alarmTypes:[],notificationSound:""}]))},disabled:x||v,title:v?"All notification sounds have been selected. Edit below to configure.":"",children:"Add Custom Configuration"})}),A=(0,a.useCallback)((e=>{f(e),p(!0)}),[]),_=(0,a.useCallback)((()=>{p(!1),h(l)}),[l]),I=(0,a.useCallback)(((e,t,n)=>{h((()=>m.map((a=>a.id===t?Object.assign({},a,{alarmTypes:e,notificationSound:n}):a))))}),[m]);return(0,a.useEffect)((()=>{if(o){const e=function(e){return e.alarm_notification_mapping.map((e=>({id:e.id,notificationSound:e.notification_sound,alarmTypes:e.alarm_types})))}(o);u(e),h(e),k(function(e){const t=e.flatMap((e=>e.alarmTypes)),n={};return e.forEach((e=>{const a=t.filter((t=>!e.alarmTypes.includes(t)));n[e.id]=a})),n[qf]=t,n}(e));const{isSelected:t,selectedNotifSound:n}=function(e){const t=e.flatMap((e=>e.notificationSound));return{isSelected:d.every((e=>t.includes(e))),selectedNotifSound:t}}(e);b(t),N(n)}}),[o]),(0,a.useEffect)((()=>{T(function(e,t,n,a,s,r,i,o,l){return{columns:Uf,rows:e.map((e=>({id:e.id,cells:[{value:(0,H.jsxs)("div",{className:"flex flex-col",children:[(0,H.jsx)("div",{className:"my-1 justify-start",children:o&&s===e.id&&(0,H.jsx)(re,{text:"Editing",type:"warning"})}),(0,H.jsx)("div",{className:"max-w-2xl",children:(0,H.jsx)(_r,{alarmTypes:e.alarmTypes||[],isEditing:o&&s===e.id,onChange:t=>{a(t,e.id,e.notificationSound)},disabledTypes:i[e.id]})})]})},{value:(0,H.jsx)(Mf,{item:e,isAdding:o&&e.id===qf,onChange:t=>{a(e.alarmTypes,e.id,t)},selectedNotificationSounds:l})},{value:t?(0,H.jsx)(Zf,{isEditing:o,item:e,editingRow:s,onClickEdit:n,onCancelEdit:r}):void 0}]})))}}(m,C,A,I,g,_,y,x,w))}),[l,m,C,A,I,g,_,y,x,w]),(0,H.jsx)("div",{className:"flex flex-col gap-4 p-10",children:r?(0,H.jsx)(B,{type:"error",children:i.message}):s?(0,H.jsx)("div",{className:"flex h-24 items-center justify-center",children:(0,H.jsx)(K,{})}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(B,{type:"info",children:(0,H.jsxs)("div",{className:"flex flex-row gap-4",children:[(0,H.jsxs)("span",{children:["Default sound for all alarm type is: ",c]}),(0,H.jsx)("div",{className:"w-24 cursor-pointer",children:(0,H.jsx)(Mr,{src:`assets/notif-sounds/${c}.mp3`,isLoading:!1})})]})}),t&&(0,H.jsx)("div",{className:"dark:bg-dark-bg dark:border-ondark-line-1 border-onlight-line-3 m-8 mx-4 min-h-0 justify-start border sm:-mx-6 md:mx-0 md:rounded-lg",children:(0,H.jsx)(Pf,{data:S,header:C&&E})})]})})}nt(ht(Vf),["alarm/notifications:view"]);const $f=function(e){const{title:t,content:n}=e;return(0,H.jsxs)("div",{className:"dark:divide-dark-border-bg mt-6 divide-y divide-gray-200 sm:mt-10",children:[(0,H.jsx)("h3",{className:"dark:text-dark-text text-lg font-medium leading-6 text-gray-900",children:t}),(0,H.jsx)("div",{className:"mt-6",children:n})]})};const zf=function(e){var t;const{user:n}=e,a=[{name:"Name",value:null!=(t=n.name)?t:"-"},{name:"Email",value:n.email},{name:"Roles",value:n.roles.join(", ")},{name:"Tenant",value:n.tenant.name}],s=(0,H.jsx)(ba,{items:a});return(0,H.jsx)("div",{className:"mx-auto w-full max-w-2xl",children:(0,H.jsx)($f,{title:"Account",content:s})})};var Hf=function(e){return e.dark="dark",e.light="light",e.system="system",e}(Hf||{});const Bf=[{id:Hf.dark,title:"Dark"},{id:Hf.light,title:"Light"},{id:Hf.system,title:"System"}],Wf=[{id:"enabled",title:"Enabled"},{id:"disabled",title:"Disabled"}];const Gf=function(){const[e,t,n]=M("theme"),[a,s]=M("alarmReturnPostResolve",!0),r=e=>{if("enabled"===e.target.id)s(!0);else s(!1)},i=e=>{switch(e.target.id){case Hf.dark:t(Hf.dark),document.documentElement.classList.add("dark");break;case Hf.light:t(Hf.light),document.documentElement.classList.remove("dark");break;default:n(),window.matchMedia("(prefers-color-scheme: dark)").matches?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")}},o=[{name:"Theme",value:(0,H.jsx)("span",{className:"flex flex-shrink-0 items-start space-x-4",children:(0,H.jsxs)("fieldset",{children:[(0,H.jsx)("legend",{className:"sr-only",children:"Theme"}),(0,H.jsx)("div",{className:"space-y-4 sm:flex sm:items-center sm:space-y-0 sm:space-x-10",children:Bf.map((t=>(0,H.jsxs)("div",{className:"flex items-center",children:[(0,H.jsx)("input",{id:t.id,name:"notification-method",type:"radio",defaultChecked:t.id===e||t.id===Hf.system&&void 0===e,className:"text-primary-600 focus:ring-primary-500 dark:checked:bg-primary-500 dark:focus:ring-primary-600 h-4 w-4 border-gray-300 bg-gray-100 focus:ring-2 dark:border-none dark:bg-gray-700 dark:ring-offset-gray-800",onChange:i}),(0,H.jsx)("label",{htmlFor:t.id,className:"dark:text-dark-text ml-3 block text-sm font-medium text-gray-700",children:t.title})]},t.id)))})]})})},{name:"Return To Alarm List On Alarm Resolution",value:(0,H.jsx)("span",{className:"flex flex-shrink-0 items-start space-x-4",children:(0,H.jsxs)("fieldset",{children:[(0,H.jsx)("legend",{className:"sr-only",children:"Theme"}),(0,H.jsx)("div",{className:"space-y-4 sm:flex sm:items-center sm:space-y-0 sm:space-x-10",children:Wf.map((e=>(0,H.jsxs)("div",{className:"flex items-center",children:[(0,H.jsx)("input",{id:e.id,name:"alarm-list-return",type:"radio",defaultChecked:"enabled"===e.id&&a||"disabled"===e.id&&!a,className:"text-primary-600 focus:ring-primary-500 dark:checked:bg-primary-500 dark:focus:ring-primary-600 h-4 w-4 border-gray-300 bg-gray-100 focus:ring-2 dark:border-none dark:bg-gray-700 dark:ring-offset-gray-800",onChange:r}),(0,H.jsx)("label",{htmlFor:e.id,className:"dark:text-dark-text ml-3 block text-sm font-medium text-gray-700",children:e.title})]},e.id)))})]})})}];return(0,H.jsx)(ba,{items:o})};const Kf=[{id:"general",name:"General"},{id:"preferences",name:"Preferences"},{id:"alarm-notifications",name:"Alarm Notifications"}],Yf=[{id:Be.OFF,title:"Off"},{id:Be.INACTIVE,title:"When inactive"},{id:Be.ALWAYS,title:"Always"}],Qf={firefox:"about:preferences#privacy",edge:"edge://settings/content/notifications",chrome:"chrome://settings/content/notifications",safari:"Safari > Settings > Websites > Notifications"},Xf=()=>{const e=(()=>{const e=navigator.userAgent.toLowerCase();let t;return e.match(/chrome|chromium|crios/i)?t="chrome":e.match(/firefox|fxios/i)?t="firefox":e.match(/safari/i)?t="safari":e.match(/edg/i)&&(t="edge"),t})();return e&&Qf[e]};const Jf=function(){const[e,t]=(0,ur.KO)(vt),[s,r]=(0,ur.KO)(jt),[i,o]=(0,a.useState)(I()?n.g.Notification.permission:"notSupported");(0,a.useEffect)((()=>{I()&&"granted"!==Notification.permission&&r(Be.OFF)}),[r]);const l=async e=>{const t=e.target.id;if(t!==Be.OFF){const e=await Notification.requestPermission();"granted"===e?r(t):"denied"!==e&&Le('You must click "Allow" in the prompt to grant permission'),o(e)}else r(t)},c=[{name:"Audio Notification",value:(0,H.jsx)(ve.r,{checked:e,onChange:t,className:(0,z.Z)(e?"bg-primary-600":"dark:bg-dark-surface bg-gray-200","focus:ring-primary-500 dark:focus:ring-offset-dark-bg relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-offset-2 sm:ml-auto"),children:(0,H.jsx)("span",{"aria-hidden":"true",className:(0,z.Z)(e?"translate-x-5":"translate-x-0","inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out")})})},{name:"System Notification",infoText:"System notifications are OS-level alerts, make sure to enable browser notifications for full functionality.\n\n        Off: No notification will be shown.\n        When inactive: Recieve notifications when not actively using the app.\n        Always: Always recieve notifications",value:(0,H.jsx)("span",{className:"flex flex-shrink-0 items-start space-x-4",children:(0,H.jsxs)("fieldset",{children:[(0,H.jsx)("legend",{className:"sr-only",children:"System Notification"}),(0,H.jsx)("div",{className:"space-y-4 sm:flex sm:items-center sm:space-y-0 sm:space-x-10",children:Yf.map((e=>(0,H.jsxs)("div",{className:"flex items-center",children:[(0,H.jsx)("input",{id:e.id,name:"system-notification",type:"radio",disabled:"notSupported"===i,checked:s===e.id,className:"text-primary-600 focus:ring-primary-500 dark:checked:bg-primary-500 dark:focus:ring-primary-600 h-4 w-4 border-gray-300 bg-gray-100 focus:ring-2 dark:border-none dark:bg-gray-700 dark:ring-offset-gray-800",onChange:l}),(0,H.jsx)("label",{htmlFor:e.id,className:"dark:text-dark-text ml-3 block flex-shrink-0 text-sm font-medium text-gray-700",children:e.title})]},e.id)))})]})})}],d=Xf();return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ba,{items:c}),"denied"===i&&(0,H.jsx)(B,{children:(0,H.jsxs)("div",{className:"flex flex-col",children:[(0,H.jsx)("span",{children:"Notification permission has been denied. Please go to your browser settings and enable notifications for this website."}),d&&(0,H.jsxs)("span",{className:"",children:["Go to ",d]})]})}),"notSupported"===i&&(0,H.jsx)(B,{children:(0,H.jsx)("div",{className:"flex flex-col",children:(0,H.jsx)("span",{children:"Web Notifications are not supported in this browser / device."})})})]})};const ev=function(){return(0,H.jsxs)("div",{className:"mx-auto w-full max-w-2xl",children:[(0,H.jsx)($f,{title:"Application",content:(0,H.jsx)(Gf,{})}),(0,H.jsx)($f,{title:"Notifications",content:(0,H.jsx)(Jf,{})})]})};function tv(){const e=j(),t=(0,r.s0)(),n=function(){switch((0,r.TH)().pathname){case"/profile/general":default:return"general";case"/profile/preferences":return"preferences";case"/profile/alarm-notifications":return"alarm-notifications"}}(),[s,i]=(0,a.useState)(n);(0,a.useEffect)((()=>{i(n)}),[n]);return(0,H.jsxs)(mr,{title:"Profile",children:[(0,H.jsx)(xe,{items:Kf,activeTabId:s,onChange:e=>{t(`/profile/${e}`)}}),(0,H.jsx)("div",{className:"mx-auto w-full",children:(0,H.jsxs)(r.Z5,{children:[(0,H.jsx)(r.AW,{path:"/",element:(0,H.jsx)(r.Fg,{to:"general"})}),(0,H.jsx)(r.AW,{path:"general",element:(0,H.jsx)(zf,{user:e})}),(0,H.jsx)(r.AW,{path:"preferences",element:(0,H.jsx)(ev,{})}),(0,H.jsx)(r.AW,{path:"alarm-notifications",element:(0,H.jsx)(Vf,{})})]})})]})}const nv={names:[],emails:[],roles:[],enabled:{showEnabled:!0,showNotEnabled:!1}},av={userListFilters:nv,userListPage:1,userListPageSize:30},sv={state:av,dispatch:()=>null},rv=(0,a.createContext)(sv),iv=(0,cm.ZP)(((e,t)=>{switch(t.type){case"UPDATE_FILTERS":e.userListFilters=t.payload;break;case"SET_PAGE":e.userListPage=t.payload;break;default:throw new Error}}));const ov=function(e){const{children:t}=e,[n,s]=(0,a.useReducer)(iv,av);return(0,H.jsx)(rv.Provider,{value:{state:n,dispatch:s},children:t})},lv="UPDATE_FILTERS",cv="SET_PAGE";function dv(e){return{type:cv,payload:e}}const uv=/^(?=.*[0-9])(?=.*[!@#$%^&*])[a-zA-Z0-9!@#$%^&*]{6,16}$/;function mv(e,t,n,a,s){return!!e&&(!!hv(t)&&(!(s&&!xv(a))&&function(e){return null!==e}(n)))}function hv(e){return/\S+@\S+\.\S+/.test(e)}function xv(e){return!!e&&(!(e.length<14)&&!!uv.test(e))}function pv(e){const{open:t,onClose:n}=e,[s,r]=(0,a.useState)(""),[i,o]=(0,a.useState)(""),l=ua(),[c,d]=(0,a.useState)(null),[u,m]=(0,a.useState)(""),h=()=>{r(""),o(""),d(null)},x=function(e){const t=new Request("/v2/orm/user",{method:"POST"});return Ft(t,{onSuccessInvalidationKeys:[["users"]],onSuccess:e})}((()=>{h(),n(),Le("User added",{type:"success"})})),p=()=>{h(),n(),x.reset()},g=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{c&&x.mutate({name:s,email:i,roles:[c],password:"local"===Ar.authMode?u:void 0})},disabled:!mv(s,i,c,u,"local"===Ar.authMode),loading:x.isLoading,children:"Submit"}),(0,H.jsx)(Q,{onClick:p,children:"Cancel"})]});return(0,H.jsx)(ce,{title:"Add User",open:t,onClose:p,footer:g,children:(0,H.jsxs)("div",{className:"w-96",children:[x.isError?(0,H.jsx)("div",{className:"py-4 px-8",children:(0,H.jsxs)(B,{type:"error",children:[x.error.message," "]})}):null,(0,H.jsx)("div",{className:"mb-2 px-8 py-4",children:(0,H.jsx)(ae,{onChange:e=>r(e.target.value),label:"Name",type:"text",value:s})}),(0,H.jsx)("div",{className:"mb-2 px-8 py-4",children:(0,H.jsx)(ae,{onChange:e=>o(e.target.value),label:"Email",type:"email",error:!hv(i)&&i.length>0,errorText:"Invalid email",value:i})}),"local"===Ar.authMode&&(0,H.jsx)("div",{className:"mb-2 px-8 py-4",children:(0,H.jsx)(ae,{onChange:e=>m(e.target.value),label:"Password",type:"password",error:!xv(u),errorText:"Password must be at least 14 characters long and contain one uppercase letter, one lowercase letter, one digit and one special character",value:u})}),(0,H.jsx)("div",{className:"mb-2 px-8 py-4",children:(0,H.jsx)(Is,{queryResult:l,children:e=>(0,H.jsx)(ue,{items:e,value:c,onChange:d,displayValue:e=>null!=e?e:""})})})]})})}const gv=function(e){var t;const{selectedLocationIds:n,label:a,onChange:s}=e,r=null==(t=Zn("").data)?void 0:t.items;return(0,H.jsx)(Fs,{label:a,value:n,onChange:s,getItems:e=>{const t=e?null==r?void 0:r.filter((t=>t.name.toLowerCase().includes(e.toLowerCase()))):r;return(null==t?void 0:t.map((e=>e.id)))||[]},displayValue:e=>{var t;return(null==r||null==(t=r.find((t=>t.id==e)))?void 0:t.name)||""},id:e=>String(e)})};const fv=function(e){const{selectedUsers:t,onClose:n}=e,[s,r]=(0,a.useState)([]),i=function(e){const t=new Request("/v2/orm/user/mspLocations",{method:"PATCH"});return Ft(t,{onSuccessInvalidationKeys:[["users"]],onSuccess:e})}((()=>{Le("MSP locations assigned successfully"),n()})),o=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>{const e={users:t.map((e=>e.id)),mspLocations:s};i.mutate(e)},loading:i.isLoading,children:"Submit"}),(0,H.jsx)(Q,{onClick:n,children:"Cancel"})]});return(0,H.jsx)(ce,{open:!0,onClose:n,closable:!0,footer:o,title:"Assign MSP Locations",children:(0,H.jsxs)("div",{className:"space-y-6 p-4 px-8 text-sm",children:[i.isError&&(0,H.jsx)(B,{type:"error",children:i.error.message}),(0,H.jsx)(B,{type:"info",children:"If a user has no assigned MSP location, they will have access to alarms for all locations."}),(0,H.jsxs)("div",{children:[(0,H.jsx)("div",{className:"my-2 italic",children:"Selected Users:"}),(0,H.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,H.jsx)("span",{className:"font-bold",children:"Name"}),(0,H.jsx)("span",{className:"font-bold",children:"Email Id"}),t.map((e=>(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("span",{children:e.name}),(0,H.jsx)("span",{children:e.email})]})))]})]}),(0,H.jsx)("div",{className:"mt-4",children:(0,H.jsx)(gv,{onChange:e=>r(e),selectedLocationIds:s,label:"MSP Locations"})})]})})};function vv(e){const{currentUserData:t,onClose:n}=e,{id:s,role:r,email:i}=t,[o,l]=(0,a.useState)(r),c=Boolean(s&&o&&r!==o),d=()=>{n(),u.reset()},u=function(e,t){const n=new Request(`/v2/orm/user/${e}`,{method:"PATCH"});return Ft(n,{onSuccessInvalidationKeys:[["users"]],onSuccess:t})}(s,(()=>{d(),Le("User updated",{type:"success"})})),m=function(e,t){const n=new Request(`/v2/orm/user/${e}`,{method:"DELETE"});return Ft(n,{onSuccessInvalidationKeys:[["users"],["user",e]],onSuccess:t})}(s,(()=>{d(),Le("User deleted",{type:"success"})})),h=ua(),x=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{variant:"primary",onClick:()=>u.mutate({roles:[o]}),disabled:!c,loading:m.isLoading||u.isLoading,children:"Submit"}),(0,H.jsx)(Q,{onClick:d,children:"Cancel"})]});return(0,H.jsx)(ce,{title:"Edit User",open:!0,onClose:d,footer:x,children:(0,H.jsxs)("div",{className:"w-96",children:[u.isError?(0,H.jsx)("div",{className:"py-4 px-8",children:(0,H.jsx)(B,{type:"error",children:u.error.message})}):null,m.isError?(0,H.jsx)("div",{className:"py-4 px-8",children:(0,H.jsx)(B,{type:"error",children:m.error.message})}):null,(0,H.jsx)("div",{className:"mb-2 px-8 py-4",children:(0,H.jsx)(Is,{queryResult:h,children:e=>(0,H.jsx)(ue,{items:null!=e?e:[],value:o,onChange:l,displayValue:e=>e})})}),(0,H.jsx)("div",{className:"mb-2 px-8 py-4",children:(0,H.jsxs)(Q,{variant:"error",onClick:()=>m.mutate({enabled:!1}),loading:m.isLoading||u.isLoading,children:["Delete User ",i]})})]})})}const jv=function(e){const{value:t,onChange:n}=e;return(0,H.jsx)(Fs,{label:"Email",value:t,onChange:n,getItems:e=>dt(e,t),displayValue:e=>null==e?void 0:e.name,id:e=>e.id})},bv={id:"enabled",name:"Enabled"},yv={id:"notEnabled",name:"Not Enabled"},kv=[bv,yv];const wv=function(e){const{value:t,onChange:n}=e,a=kv.filter((e=>"Enabled"===e.name&&t.showEnabled||"Not Enabled"===e.name&&t.showNotEnabled));return(0,H.jsx)(Fs,{label:"User Enabled",value:a,onChange:e=>{n({showEnabled:e.includes(bv),showNotEnabled:e.includes(yv)})},getItems:e=>{const{filterPredicate:t,isEqual:n}=st;return rt(e,a,t,n,{staticItems:kv})},displayValue:e=>null==e?void 0:e.name,id:e=>e.id})};const Nv=function(e){const{value:t,onChange:n}=e;return(0,H.jsx)(Fs,{label:"Name",value:t,onChange:n,getItems:e=>dt(e,t),displayValue:e=>null==e?void 0:e.name,id:e=>e.id})};const Cv=function(e){const{filters:t,onApplyFilters:n}=e,[s,r]=(0,a.useState)(t);return(0,H.jsxs)("div",{className:"space-y-6",children:[(0,H.jsxs)("div",{className:"dark:divide-dark-border-bg dark:border-dark-border-bg divide-y border-t border-b",children:[(0,H.jsx)(dd,{title:"Name",content:(0,H.jsx)(Nv,{onChange:e=>r(Object.assign({},s,{names:e.map((e=>e.name))})),value:s.names.map((e=>({name:e,id:e})))}),hasFilterApplied:s.names.length>0}),(0,H.jsx)(dd,{title:"Email",content:(0,H.jsx)(jv,{onChange:e=>r(Object.assign({},s,{emails:e.map((e=>e.name))})),value:s.emails.map((e=>({name:e,id:e})))}),hasFilterApplied:s.emails.length>0}),(0,H.jsx)(dd,{title:"Enabled",content:(0,H.jsx)(wv,{onChange:e=>r(Object.assign({},s,{enabled:e})),value:s.enabled}),hasFilterApplied:!s.enabled.showEnabled||s.enabled.showNotEnabled})]}),(0,H.jsx)(rd,{onApply:()=>n(s),onReset:()=>r(nv),trackingEventNameApply:"apply_users_filters",trackingEventNameReset:"reset_users_filters"})]})};const Sv=function(e){const{open:t,onClose:n,onApplyFilters:a,filters:s}=e;return(0,H.jsx)(_s,{title:"User Filters",open:t,onClose:n,children:(0,H.jsx)(Cv,{filters:s,onApplyFilters:a})})};const Tv=function(e){const{fromIndex:t,toIndex:n,pageSize:a,total:s,onChangePage:r}=e;return(0,H.jsx)("div",{className:"dark:bg-dark-bg border-t bg-white p-4 dark:border-gray-800",children:(0,H.jsx)(wi,{from:t+1,to:n+1,pageSize:a,total:s,onChangePage:e=>r(e)})})},Ev=[{id:"name",name:"Name"},{id:"email",name:"E-Mail",showAtBreakpoint:"lg"},{id:"role",name:"Role",showAtBreakpoint:"md"},{id:"mspLocations",name:"MSP Locations",showAtBreakpoint:"md"},{id:"action",name:"",showAtBreakpoint:"sm"}];const Av=e=>{const{emails:t,names:n,roles:a,enabled:s}=e,r={};return t.length>0&&(r.emails=t),n.length>0&&(r.names=n),a.length>0&&(r.roles=a),r.enabled=s,r};const _v=function(e){const{isRefetching:t,isRowsSelected:n,userListFilters:a,onOpenFilterPanel:s,onOpenAddUserModal:r,onOpenMSPLocationModal:i,canUpdateMSPLocations:o}=e,l=Ge(j(),"user:add");return(0,H.jsxs)("div",{className:"dark:bg-dark-bg flex items-center justify-between border-b bg-white p-4 dark:border-0",children:[(0,H.jsxs)("span",{children:[l&&(0,H.jsxs)(Q,{variant:"primary",onClick:r,children:["Add User",(0,H.jsx)("span",{className:"sr-only",children:"Add User"})]}),o&&(0,H.jsxs)(Q,{variant:"primary",onClick:i,disabled:!n,classNames:"ml-2",children:["Assign MSP Locations",(0,H.jsx)("span",{className:"sr-only",children:"Assign MSP locations"})]})]}),(0,H.jsxs)("div",{className:"flex items-center gap-2",children:[t&&(0,H.jsx)(K,{}),(0,H.jsxs)(Q,{variant:"icon",badge:(c=a,c.emails.length>0||c.names.length>0||c.roles.length>0||!c.enabled.showEnabled||c.enabled.showNotEnabled),onClick:s,children:[(0,H.jsx)("span",{className:"sr-only",children:"Open filters panel"}),(0,H.jsx)(_d.Z,{className:"h-5 w-5","aria-hidden":"true"})]})]})]});var c};const Iv=nt(ht((function(){const{userListPage:e,userListPageSize:t,userListFilters:n}=function(){const{state:e}=(0,a.useContext)(rv);return e}(),[s,r]=(0,a.useState)({columns:Ev,rows:[]}),i=function(){const{dispatch:e}=(0,a.useContext)(rv);return e}(),[o,l]=(0,a.useState)(0),[c,d]=(0,a.useState)(!1),[u,m]=(0,a.useState)(!1),[h,x]=(0,a.useState)(!1),[p,g]=(0,a.useState)(!1),[f,v]=(0,a.useState)({id:"",role:"",email:""}),[b,y]=(0,a.useState)([]),k=Ge(j(),"user/msp-locations:update"),[w,N]=(0,a.useState)([]),C=(0,a.useMemo)((()=>ma({page:e,pageSize:t,filters:n})),[e,t,n]),{isLoading:S,isError:T,error:E,data:A,isRefetching:_}=da(C),I=(e-1)*t,L=Math.min(e*t,o)-1,R=Ge(j(),"user:update"),D=(0,a.useCallback)((e=>{const t=w.find((({id:t})=>t===e));t&&(v(Object.assign({},t,{role:t.roles[0]})),x(!0))}),[w]);(0,a.useEffect)((()=>{if(A){const{items:e,total:t}=A;N(e),r(function(e,t,n){return{columns:Ev,rows:e.map((e=>({id:e.id,cells:e.enabled||void 0===e.enabled?[{value:e.name},{value:e.email},{value:e.roles[0]},{value:e.mspLocations&&e.mspLocations.length>0?(0,H.jsx)("div",{className:"flex flex-wrap gap-2",children:e.mspLocations.map((e=>(0,H.jsx)(re,{small:!0,text:e.name},e.id)))}):"-"},{value:t?(0,H.jsx)(Q,{variant:"icon",onClick:()=>n(e.id),children:(0,H.jsx)(Fg.Z,{className:"w-4"})}):void 0}]:[{value:(0,H.jsxs)("span",{className:"italic",children:[" ",e.name," (Disabled) "]})},{value:(0,H.jsxs)("span",{className:"italic",children:[" ",e.email," "]})},{value:(0,H.jsxs)("span",{className:"italic",children:[" ",e.roles[0]," "]})},{value:e.mspLocations&&e.mspLocations.length>0?(0,H.jsx)("div",{className:"flex flex-wrap gap-2",children:e.mspLocations.map((e=>(0,H.jsx)(re,{small:!0,text:e.name},e.id)))}):"-"},{value:void 0}]})))}}(e,R,D)),l(t)}}),[A,R,D]);const P=(0,H.jsx)(_v,{userListFilters:n,isLoading:S,onOpenFilterPanel:()=>d(!0),onOpenAddUserModal:()=>m(!0),isRefetching:_,isRowsSelected:b.length>0,onOpenMSPLocationModal:()=>g(!0),canUpdateMSPLocations:k}),M=(0,H.jsx)(Tv,{fromIndex:I,toIndex:L,pageSize:t,total:o,onChangePage:e=>{i(dv(e))}});return(0,H.jsxs)(mr,{title:"Users",children:[T&&(0,H.jsx)("div",{className:"mb-2",children:(0,H.jsx)(B,{type:"error",children:E.message})}),(0,H.jsx)(pv,{open:u,onClose:()=>m(!1)}),h&&(0,H.jsx)(vv,{currentUserData:f,onClose:()=>x(!1)}),p&&(0,H.jsx)(fv,{onClose:()=>g(!1),selectedUsers:w.filter((e=>b.includes(e.id)))}),(0,H.jsx)(Sv,{open:c,filters:n,onClose:()=>d(!1),onApplyFilters:e=>{d(!1),i({type:lv,payload:e}),i(dv(1)),wt(Av(e))}}),(0,H.jsx)("div",{className:"dark:bg-dark-bg -mx-4 flex min-h-0 flex-1 flex-col justify-start overflow-y-hidden sm:-mx-6 md:mx-0 md:rounded-lg",children:(0,H.jsx)(Ai,{data:s,loading:S,header:P,footer:M,scrollResetKey:e,rowSelection:k?{selected:b,onChangeSelected:y}:void 0})})]})})),["user:view"]);const Lv=function(){return(0,H.jsx)(r.Z5,{children:(0,H.jsx)(r.AW,{path:"/",element:(0,H.jsx)(Iv,{})})})};function Rv(){return(0,H.jsx)(ov,{children:(0,H.jsx)(Lv,{})})}const Dv=()=>[{id:"GUARD",name:"Guards intervention"},{id:"PD",name:"PD intervention"},{id:"PERSON_LEFT",name:"Person left the site"},{id:"FALSE",name:"False escalation"},{id:"OTHERS",name:"Others"}];function Pv(e){const{onResolve:t,isLoading:n,onClickResolveAction:s,onCancelResolve:r}=e,[i,o]=(0,a.useState)(!1),[l,c]=(0,a.useState)(!1),[d,u]=(0,a.useState)({id:"",name:""}),m=()=>{o(!0),s&&s()};return i?(0,H.jsxs)("div",{className:"flex items-center gap-2",children:[l?(0,H.jsx)(ae,{label:"",onChange:e=>u({id:"",name:e.target.value}),type:"text",value:(null==d?void 0:d.name)||"",placeholder:"Please specify",autoFocus:!0}):(0,H.jsx)(Ps,{value:d,placeholder:"Select a comment",items:Dv(),displayValue:e=>{var t;return null!=(t=null==e?void 0:e.name)?t:""},onChange:e=>{"OTHERS"===e.id?(c(!0),u({id:"",name:""})):u(e)},id:e=>(null==e?void 0:e.id)||""}),(0,H.jsx)(Q,{title:"Confirm",variant:"primary",loading:n,disabled:"blank"===d.id||n,onClick:()=>{var e;return t(null!=(e=null==d?void 0:d.name)?e:"")},onSideEffect:yt("resolve_apartment_monitoring_escalation"),children:"Confirm"}),(0,H.jsx)(Q,{variant:"icon",onClick:()=>{o(!1),c(!1),u({id:"",name:""}),r&&r()},children:(0,H.jsx)(U.Z,{className:"h-5 w-5"})})]}):(0,H.jsx)("div",{className:"text-center",children:(0,H.jsx)(Q,{variant:"success",onClick:m,children:"Resolve"})})}const Mv="Hakimo AI Engine",Ov="Responded via speaker talk-down";function Fv(e){switch(e){case"Resolved":return"success";case"In Progress":return"warning";case"Pending":return"error"}}function Zv(e){var t;if((null==(t=e.user)?void 0:t.name)===Mv||null===e.user)return Ya;if(e.status)switch(e.status){case Ze.RESOLVED:return Qa;case Ze.IN_PROGRESS:return Xa;case Ze.PENDING:return Ja}switch(e.event){case Ov:case qe.MANUAL_TALKDOWN:return es;case qe.CALL_SMS_LOGS:return ts;default:return ns}}const qv=(e,t=!1)=>{var n,a,s,r,i,o;return e.event===qe.MANUAL_TALKDOWN?t?`${null!=(s=null==(r=e.user)?void 0:r.name)?s:Mv} responded via speaker talk-down`:void 0!==(null==(a=e.user)?void 0:a.name)?`${null==(i=e.user)?void 0:i.name} responded via speaker talk-down`:"Speaker talk-down conducted":e.event===qe.CALL_SMS_LOGS?e.twilio_ssid?pl(e.twilio_ssid,e.twilio_calling_to_name,null==(o=e.user)?void 0:o.name):"Twilio SSID not found":`${null==(n=e.user)?void 0:n.name} added feedback: ${e.comment}`},Uv=(e,t)=>{const n=[],a=t.talkdowns||[],s=t.items||[];return n.push({icon:Ya,description:"Escalation created",time:new Date(e.createdAt).toLocaleString(),timestamp:new Date(e.createdAt).getTime()}),n.push(...s.map((e=>{const t={user:e.user,status:e.update_status,event:e.update_type,comment:e.update_text,twilio_ssid:e.twilio_ssid,twilio_calling_to_name:e.twilio_calling_to_name},n=new Date(e.update_time),s={icon:Zv(t),description:qv(t,!0),time:n.toLocaleString(),timestamp:n.getTime(),audio_url:e.audio_url};return e.update_type===qe.MANUAL_TALKDOWN&&(s.extraDetails=function(e,t){let n=e.audio_url;if(!n)return null;n=n.split("?")[0];const a=t.find((e=>e.talkdown_type===$e.MANUAL&&n&&e.talkdown_audio.includes(n)));let s="",r=null;switch(null==a?void 0:a.status){case Ve.SUCCESS:s="Talkdown transmitted successfully",r=dl("success");break;case Ve.PENDING:s="Talkdown yet to be relayed";break;case Ve.FAILED:s="Talkdown tranmission failed",r=dl("error")}return(0,H.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[s,r]})}(e,a),s.extraDetailsModalContent=function(e,t){let n=e.audio_url;if(!n)return null;if(n=n.split("?")[0].split("audio")[1],!n)return;const a=t.find((e=>e.talkdown_type===$e.MANUAL&&n&&e.talkdown_audio.includes(n)));if(!a)return null;const s=ul.filter((e=>!["rawAlarmId","rawAlarmAddedTime"].includes(e.id)));return(0,H.jsxs)("div",{className:"grid grid-cols-4 gap-2 text-sm",children:[ml(s),(0,H.jsxs)("span",{className:"flex gap-2",children:[dl(a.status),a.status]}),(0,H.jsx)("span",{children:a.ingested_talkdown_audio?(0,H.jsx)("span",{className:"flex",children:(0,H.jsx)(Or,{src:a.ingested_talkdown_audio,isLoading:!1})}):"NA"}),(0,H.jsx)("span",{children:hl(a.talkdown_completed_utc)}),(0,H.jsx)("span",{children:a.custom_message||"-"})]})}(e,a)),s}))),n.sort(((e,t)=>t.timestamp-e.timestamp)).map((e=>({icon:e.icon,description:e.description,time:e.time,audio_url:e.audio_url,extraDetails:e.extraDetails,extraDetailsModalContent:e.extraDetailsModalContent})))};const Vv=function(e){var t,n;const{escalation:s}=e,[r,i]=(0,a.useState)(!1),{isSuccess:o,mutate:l,isLoading:c}=Kn(s.id);return(0,a.useEffect)((()=>{o&&Le("Escalation resolved successfully")}),[o]),(0,H.jsxs)("div",{className:"flex h-12 items-center gap-4 px-4",children:[!r&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("span",{className:"flex flex-shrink-0 flex-col",children:[(0,H.jsx)("span",{title:`#${s.id} - ${null==(t=s.location)?void 0:t.name}`,children:null==(n=s.location)?void 0:n.name}),(0,H.jsx)("span",{className:"dark:text-ondark-text-2 text-onlight-text-2 text-xs",children:s.location.description})]}),(0,H.jsx)("div",{className:"h-4 border-l border-black/20 dark:border-white/20"})]}),(0,H.jsx)(re,{type:Fv(s.status),children:s.status}),"Resolved"!==s.status&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"h-4 border-l border-black/20 dark:border-white/20"}),(0,H.jsx)(Pv,{onResolve:e=>{i(!1);const t={escalation_id:s.id,resolution_comment:e,status:"Resolved"};l(t)},isLoading:c,onClickResolveAction:()=>i(!0),onCancelResolve:()=>i(!1)})]}),(0,H.jsxs)("div",{className:"ml-auto text-sm",children:["Escalated by: ",s.createdByUserId]})]})};const $v=function(e){const{escalation:t}=e,n=Wn(t.id,6e4);return(0,H.jsxs)("div",{className:"space-y-1",children:[(0,H.jsx)("h2",{className:"dark:border-ondark-line-2 flex h-9 items-center border-b p-2",children:"Escalation Events"}),(0,H.jsx)(Is,{queryResult:n,loadingText:"",children:e=>{const n=Uv(t,e);return(0,H.jsx)("div",{className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 max-h-[30rem] overflow-auto",children:n.length>0?(0,H.jsx)(Ws,{events:n}):(0,H.jsx)("div",{className:"p-6",children:(0,H.jsx)(B,{children:"No updates"})})})}})]})};const zv=function(e){const{escalation:t}=e;return(0,H.jsxs)("div",{className:"divide-y dark:divide-white/10",children:[(0,H.jsx)(Vv,{escalation:t}),(0,H.jsx)("div",{className:"flex flex-col gap-4",children:(0,H.jsxs)("div",{className:"p-4",children:[(0,H.jsx)("h2",{className:"dark:border-ondark-line-2 border-b p-2",children:"Escalation Media"}),(0,H.jsxs)("div",{className:"flex items-center gap-4 p-4",children:[0===t.media.length&&(0,H.jsx)("div",{className:"bg-onlight-bg-2 dark:bg-ondark-bg-2 flex h-20 w-full items-center justify-center rounded-md",children:(0,H.jsx)("span",{children:"No Media attached to this escalation yet"})}),t.media.map((e=>(0,H.jsx)("video",{src:e.mediaUrl,autoPlay:!0,controls:!0,className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 peer aspect-video w-full object-fill"},e.createdAtUTC)))]}),(0,H.jsx)("div",{children:(0,H.jsx)($v,{escalation:t})})]})})]})},Hv=e=>{switch(e){case"Resolved":return"success";case"In Progress":return"warning";case"Pending":return"error";default:return"default"}},Bv=[{type:"status",defaultValue:{values:[],negative:!1},options:[{id:"pending",name:"Pending"},{id:"resolved",name:"Resolved"},{id:"inProgress",name:"In Progress"}]},{type:"location",defaultValue:{values:[],negative:!1}}],Wv=Bv.reduce(((e,t)=>Object.assign({},e,{[t.type]:t.defaultValue})),{});const Gv=function(e){const{period:t,onChangePeriod:n,onClickOpenFilterPanel:a,filterValues:s,isLoading:r}=e;return(0,H.jsxs)("div",{className:"flex h-12 flex-shrink-0 items-center justify-between gap-4 pl-1",children:[(0,H.jsx)(Sd,{period:t,onChange:n}),(0,H.jsxs)("div",{className:"flex items-center justify-end gap-4 pl-1",children:[r&&(0,H.jsx)(K,{}),(0,H.jsx)("span",{className:"pr-4",children:(0,H.jsx)(Q,{variant:"icon",onClick:a,badge:(i=s,i.location&&i.location.values.length>0||i.sourceSystem&&i.sourceSystem.length>0||i.sourceEntity&&i.sourceEntity.values.length>0||i.type&&i.type.values.length>0||i.employee&&i.employee.values.length>0||i.status&&i.status.values.length>0||i.tenant&&i.tenant.values.length>0||i.time&&i.time.period!==Me.ALL_TIME||i.camera&&i.camera.values.length>0||!1),children:(0,H.jsx)(_d.Z,{className:"dark:text-ondark-text-2 h-5 w-5"})})})]})]});var i};const Kv=function(e){var t,n;const{selected:a,escalation:s,onClick:r}=e;return(0,H.jsx)("button",{onClick:r,className:(0,z.Z)("dark:bg-ondark-bg-2 bg-onlight-bg-2 hover:bg-onlight-bg-3 dark:hover:bg-ondark-bg-3 relative w-full cursor-pointer items-center outline-none",a&&"dark:outline-ondark-primary outline-onlight-primary outline outline-offset-2","animate-highlight dark:animate-dark-highlight"),children:(0,H.jsx)("div",{className:"flex items-stretch",children:(0,H.jsxs)("div",{className:"flex flex-1 flex-col gap-2 truncate px-4 py-3",children:[(0,H.jsx)("span",{className:"text-onlight-text-1 dark:text-ondark-text-1 flex items-center justify-between truncate text-sm font-medium",title:null==(t=s.location)?void 0:t.name,children:null==(n=s.location)?void 0:n.name}),(0,H.jsxs)("span",{className:"flex items-center justify-between",children:[(0,H.jsxs)("span",{className:"dark:text-ondark-text-2 text-onlight-text-2 flex items-center gap-2 text-left text-sm",children:[(0,H.jsx)("span",{className:"font-medium",children:new Date(s.createdAt).toLocaleTimeString()}),(0,H.jsx)("span",{className:"opacity-70",children:new Date(s.createdAt).toLocaleDateString()})]}),(0,H.jsx)(re,{type:Hv(s.status),text:s.status,small:!0})]})]})})})};function Yv(e,t){const n=e;return t&&n.push(Qn),n.join(Yn)}const Qv=(e,t,n)=>{const a=new URLSearchParams;if(a.append("page",String(e)),a.append("pageSize",String(t)),n.location&&n.location.values.length>0){const e=Yv(n.location.values.map((e=>e.id)),n.location.negative);a.append("locationIds",e)}if(n.status&&n.status.values.length>0){const e=Yv([...n.status.values],n.status.negative);a.append("statuses",e)}if(n.time&&n.time.period!==Me.ALL_TIME)if(n.time.period===Me.CUSTOM_RANGE){const[e,t]=function(e){let t,n;return e.period===Me.CUSTOM_RANGE?(n=new Date(e.customRangeStart).getTime(),t=new Date(e.customRangeEnd).getTime()):(t=Date.now(),n=e.period===Me.PAST_MINUTE?t-6e4:e.period===Me.PAST_HOUR?t-36e5:e.period===Me.PAST_SIX_HOURS?t-216e5:e.period===Me.PAST_24_HOURS?t-864e5:e.period===Me.PAST_WEEK?t-6048e5:e.period===Me.PAST_MONTH?t-2592e6:t-7776e6),[n,t]}(n.time);a.append("dateFrom",String(e)),a.append("dateTo",String(t))}else{const[e,t]=(s=n.time.period)===Me.PAST_MINUTE?[1,0]:s===Me.PAST_HOUR?[0,1]:s===Me.PAST_SIX_HOURS?[0,6]:s===Me.PAST_24_HOURS?[0,24]:s===Me.PAST_WEEK?[0,168]:s===Me.PAST_MONTH?[0,720]:s===Me.PAST_THREE_MONTHS?[0,2160]:[0,0];t&&a.append("relativeTimeHours",String(t)),e&&a.append("relativeTimeMinutes",String(e))}var s;return a.toString()};const Xv=(0,xt.cn)(1),Jv=(0,xt.cn)(30),ej=(0,pt.O4)("escalationList/timePeriod",Me.PAST_24_HOURS),tj=(0,pt.O4)("escalationList/filters",Wv);function nj(){const[e,t]=(0,ur.KO)(Xv),n=(0,ur.Dv)(Jv),[s,r]=(0,ur.KO)(ej),[i,o]=(0,a.useState)(!1),[l,c]=(0,a.useState)(),[d,u]=(0,ur.KO)(tj),m=function(e,t){return(0,a.useMemo)((()=>Object.assign({time:{period:t,customRangeStart:"",customRangeEnd:""}},e)),[e,t])}(d,s),h=Qv(e,n,m),{data:x,error:p,isError:g,isFetching:f}=Gn(h);(0,a.useEffect)((()=>{if(!x)return;const{items:e}=x;if(void 0===e||0===e.length)return;(!l||!e.some((e=>e.id===l)))&&c(e[0].id)}),[x,l]);const v=null==x?void 0:x.items.find((e=>e.id===l));return(0,H.jsxs)(H.Fragment,{children:[g&&(0,H.jsxs)(B,{type:"error",children:["Error getting scan esclations. ",p.message]}),(0,H.jsxs)(zs,{children:[(0,H.jsx)($s,{children:(0,H.jsxs)("div",{className:"flex max-h-full w-[20rem] flex-col divide-y dark:divide-white/10",children:[(0,H.jsx)(Gv,{period:s,onChangePeriod:r,onClickOpenFilterPanel:()=>o(!0),filterValues:d,isLoading:f}),(0,H.jsx)("div",{className:"overflow-auto scroll-smooth py-4 pr-4 pb-4 pl-1",children:(0,H.jsx)(Ri,{items:(null==x?void 0:x.items)||[],total:(null==x?void 0:x.total)||1e3,page:e,pageSize:n,onChangePage:e=>{t(e)},renderListItem:e=>(0,H.jsx)(Kv,{escalation:e,selected:e.id===l,onClick:()=>(e=>{c(e.id)})(e)})})})]})}),(0,H.jsx)($s,{children:v?(0,H.jsx)(zv,{escalation:v}):(0,H.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,H.jsx)(K,{})})})]}),(0,H.jsx)(wd,{title:"Escalations Filters",open:i,filterConfigs:Bv,initialFilterValues:d,trackingEventNameApply:"apply_escalation_list_filters",trackingEventNameReset:"reset_escalation_list_filters",onClose:()=>o(!1),onApply:e=>{u(e),wt(e),t(1),o(!1)}})]})}function aj(){const e=j();return(0,H.jsx)(mr,{title:"Scan Esclations",children:e.visionTenants&&e.visionTenants.length>0?(0,H.jsx)(nj,{}):(0,H.jsx)(B,{type:"info",children:"You do not currently have access to this page. Please contact the system administrator to request access permissions. Thank you!"})})}let sj=function(e){return e.MONITORING="monitoroing",e.ESCALATION="escalation",e}({}),rj=function(e){return e.SNOOZE="snooze",e.SAFE="safe",e.ESCALATE="escalate",e}({}),ij=function(e){return e.DETECTION="detection",e.HISTORY="history",e}({}),oj=function(e){return e.SAFE="safe",e.ESCALATION_OPEN="escalation_open",e.ESCALATION_CLOSE="escalation_close",e.HISTORY="history",e}({}),lj=function(e){return e.PD="pd",e.GUARD="guard",e}({});var cj=n(31520);const dj=function(e){const{address:t,contacts:n,onCancel:a,onCallInitiated:s}=e,r=(0,ur.b9)(ft),i=()=>{r(null)},o=e=>()=>{r((0,H.jsx)(jl,{onCloseCb:i,toName:e.name,toNumber:e.phoneNumber,onCallInitiated:t=>{t.parameters.CallSid&&s(t.parameters.CallSid,e.name)}}))};return(0,H.jsxs)("div",{className:"mt-2",children:[(0,H.jsxs)("h2",{className:"my-4 flex items-center gap-2 font-bold text-red-700/80 dark:text-red-400/80",children:[(0,H.jsx)(Q,{variant:"icon",onClick:a,children:(0,H.jsx)(dr.Z,{className:"h-5 w-5"})}),"Escalate now to concerned authorities"]}),(0,H.jsxs)("div",{className:"my-2 flex items-center gap-2",children:[(0,H.jsx)("span",{className:"font-bold",children:"Address:"}),(0,H.jsx)("span",{className:"text-sm italic",children:t})]}),(0,H.jsxs)("div",{className:"space-y-2",children:[(0,H.jsx)("div",{className:"font-bold",children:"Mention below necessary details on the call:"}),(0,H.jsxs)("ol",{className:"ml-4 list-decimal space-y-1 text-sm",children:[(0,H.jsx)("li",{children:"Location of the incident"}),(0,H.jsx)("li",{children:"Your location and role (How do you know)"}),(0,H.jsx)("li",{children:"Description of the individual(s) involved, if applicable"}),(0,H.jsx)("li",{children:"Description of any vehicles involved, if applicable"}),(0,H.jsx)("li",{children:"Situation assessment (e.g., trespassing, theft, etc.)"}),(0,H.jsx)("li",{children:"Hakimo's SOC phone number for follow-ups: +1 (650) 600-6975"})]})]}),(0,H.jsx)("div",{className:"dark:border-ondark-line-2 mt-8 flex max-h-60 flex-col gap-3 divide-y overflow-auto rounded-md border-2 px-4 py-2 dark:divide-white/10",children:n.map((e=>(0,H.jsxs)("div",{className:"flex items-center justify-between pt-1",children:[(0,H.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,H.jsx)("span",{className:"text-sm",children:e.name}),(0,H.jsx)("span",{children:e.phoneNumber}),e.role&&(0,H.jsxs)("span",{children:["(",e.role,")"]})]}),(0,H.jsx)(Q,{variant:"icon",onClick:o(e),onSideEffect:yt("call_apartment_contact"),children:(0,H.jsx)(cj.Z,{className:"text-primary-500 mr-2 h-4 w-4"})})]},e.phoneNumber)))})]})};const uj=function(e){const{address:t,emergencySituations:n,exceptions:a,nonEmergencySituations:s}=e;return(0,H.jsxs)("div",{className:"mt-2 space-y-4",children:[(0,H.jsxs)("div",{className:"flex items-center gap-4",children:[(0,H.jsx)("span",{className:"font-bold",children:"Address:"}),(0,H.jsx)("span",{className:"text-sm italic",children:t})]}),(0,H.jsx)("h3",{className:"font-bold",children:"Emergency Situations:"}),(0,H.jsx)("ul",{className:"ml-4 list-inside list-disc text-sm",children:n.map(((e,t)=>(0,H.jsx)("li",{children:e},t)))}),(0,H.jsx)("h3",{className:"font-bold",children:"Non - Emergency Situations:"}),(0,H.jsx)("ul",{className:"ml-4 list-inside list-disc text-sm",children:s.map(((e,t)=>(0,H.jsx)("li",{children:e},t)))}),(0,H.jsx)("h3",{className:"font-bold",children:"Exceptions:"}),(0,H.jsx)("ul",{className:"ml-4 list-inside list-disc text-sm",children:a.map(((e,t)=>(0,H.jsx)("li",{children:e},t)))})]})};const mj=function(e){const{onResolveEscalation:t,escalationId:n,locationId:s,onCancel:r,escalatedCamId:i}=e,[o,l]=(0,a.useState)(void 0),[c,d]=(0,a.useState)("StatusUpdate"),{data:u,isLoading:m,isError:h,error:x}=qt({locationId:s}),[p,g]=(0,a.useState)(void 0),{isSuccess:f,mutate:v,isError:j,error:b,isLoading:y}=Kn(n);return(0,a.useEffect)((()=>{f&&"StatusUpdate"===c&&(Le("Escalation resolved successfully"),t())}),[f,t,c]),(0,a.useEffect)((()=>{u&&u.scan_sop&&l(u.scan_sop)}),[u]),(0,H.jsxs)("div",{className:"dark:bg-ondark-bg-2 bg-onlight-bg-2 relative mt-2 max-h-full min-h-[30rem] overflow-auto rounded p-4",children:[(0,H.jsx)("div",{className:"absolute top-1 right-1",children:(0,H.jsx)(Q,{variant:"icon",onClick:r,children:(0,H.jsx)(le.Z,{className:"h-5 w-5"})})}),(0,H.jsx)("h2",{className:"text-center font-bold",children:"Standard Operating Procedure (SOP)"}),j&&(0,H.jsx)(B,{type:"error",children:b.message}),h&&(0,H.jsx)(B,{type:"error",children:x.message}),m&&(0,H.jsx)("div",{className:"my-4 flex h-full w-full items-center justify-center",children:(0,H.jsx)(ys,{})}),!p&&o&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(uj,{address:o.address,emergencySituations:o.emergencySituations,exceptions:o.exceptions,nonEmergencySituations:o.nonEmergencySituations}),o.isTalkdownEnabled&&(0,H.jsxs)("div",{className:"my-4 flex items-center justify-between rounded-md border p-2",children:[(0,H.jsx)("span",{className:"text-sm",children:"Perform talkdown:"}),(0,H.jsx)(Br,{cameraId:i,escalationId:n,onTalkdown:(e,t)=>{kt("talkdown_submitted_for_escalation",{cameraId:e,escalationId:t})}})]}),(0,H.jsxs)("div",{className:"my-4 flex items-center justify-around",children:[(0,H.jsx)(Q,{onClick:()=>g(lj.PD),variant:"error",children:"Dispatch PD"}),(0,H.jsx)(Q,{onClick:()=>g(lj.GUARD),variant:"outline",children:"Notify Security"})]})]}),p&&o&&(0,H.jsx)(dj,{address:o.address,contacts:(p===lj.PD?null==o?void 0:o.emergencyContact:null==o?void 0:o.nonEmergencyContact)||[],onCancel:()=>g(void 0),onCallInitiated:(e,t)=>{d("TwilioLog");const a={escalation_id:n,twilio_log_type:Ue.TWILIO_CALLS,twilio_ssid:e,twilio_calling_to_name:t,update_type:"Call SMS logs"};v(a)}}),o&&(0,H.jsx)("div",{className:"my-12",children:(0,H.jsx)(Pv,{onResolve:e=>{d("StatusUpdate");v({escalation_id:n,resolution_comment:e,status:"Resolved"})},isLoading:y})})]})};var hj=n(16634),xj=n(19534),pj=n(15527),gj=n(84070);const fj=60,vj=12,jj=24,bj=(e,t,n,a,s=!0)=>{const r=[...e];if(s){const e=a*n;r.splice(e,n)}else for(let i=t-1;i>=0;i--){const e=i*n+a;r.splice(e,1)}return r},yj=e=>{const t=["#40C4FF","#81C784","#4DD0E1","#FF8A65","#FFE57F","#FF8A65","#FF80AB","#FFD54F","#4DB6AC"];return t[e.split("").reduce(((e,t)=>t.charCodeAt(0)+e),0)%t.length]},kj=e=>{if(!e)return"";const t=e.match(/.{1,2}/g);if(!t)return"";const n=new Uint8Array(t.map((e=>parseInt(e,16)))),a=new Blob([n],{type:"image/webp"});return URL.createObjectURL(a)};const wj=function(e){const{eventHistory:t,playbackUrl:n,isLiveMode:s,onChangeLiveMode:r,camName:i,tenantName:o,onChangeVideoSrc:l,isFullScreen:c,toggleFullscreen:d,showSeeker:u}=e,m=(0,a.useRef)(null),[h,x]=(0,a.useState)(null),[p,g]=(0,a.useState)(null),[f,v]=(0,a.useState)(),j=new Date((new Date).getTime()-6e5),b=e=>(e.createdTime-j.getTime())/6e5*100,y=t.filter((e=>e.createdTime>j.getTime())),k=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),w=e=>t=>{if(m.current){const n=m.current.getBoundingClientRect(),a=(t.clientX-n.left)/n.width*100;x(a),v(e)}},N=e=>{if(m.current){const t=m.current.getBoundingClientRect(),n=(e.clientX-t.left)/t.width*100;g(n)}},C=e=>{if(!m.current||null===e)return"50%";const t=m.current.offsetWidth,n=t/2,a=e/100*t;return a<n/2?"0%":a>t-n/2?"100%":"50%"},S=()=>x(null);return(0,H.jsxs)("div",{className:"from-dark-surface absolute right-0 bottom-0 left-0 cursor-pointer bg-gradient-to-t",children:[h&&f&&(0,H.jsxs)("div",{className:"absolute z-10 w-1/2",style:{left:`${h}%`,bottom:`${vj+jj}px`,transform:`translateX(-${C(h)})`},children:[(0,H.jsx)("span",{className:"bg-ondark-bg-2 absolute top-1 left-1 rounded-md px-2 text-xs text-white",children:k(new Date(f.createdTime))}),(0,H.jsx)("img",{src:f.frame,alt:"event frame",className:"border-ondark-text-1 rounded-md border"})]}),p&&(0,H.jsx)("div",{className:"bg-ondark-bg-3/70 absolute cursor-pointer rounded px-2 text-[9px] text-white",style:{left:`${p}%`,transform:`translateX(-${C(p)})`,bottom:`${vj+jj}px`},children:(e=>{if(null===e)return null;const t=new Date(j.getTime()+e/100*10*60*1e3);return k(t)})(p)}),(0,H.jsxs)("div",{ref:m,className:(0,z.Z)("relative cursor-pointer rounded bg-gray-900/80",u?"block":"hidden"),style:{height:`${vj}px`},onMouseMoveCapture:N,onMouseOverCapture:N,onMouseLeave:()=>g(null),onClick:e=>{if(m.current){const t=m.current.getBoundingClientRect(),a=(e.clientX-t.left)/t.width*100,s=new Date(j.getTime()+a/100*10*60*1e3),i=s.toISOString(),o=Math.floor((Date.now()-s.getTime())/1e3),c=new URLSearchParams;c.append("start",i),c.append("duration",String(o)),l(`${n}&${c.toString()}`),r(!1)}},children:[y.map(((e,t)=>(0,H.jsx)("div",{onMouseOverCapture:w(e),onMouseLeave:S,className:"absolute top-0 h-full w-[0.12rem] bg-red-500 transition-transform",style:{left:`${b(e)}%`}},t))),p&&(0,H.jsx)("div",{className:"bg-primary-500 pointer-events-none absolute z-10 w-[0.12rem]",style:{left:`${p}%`,height:`${vj}px`}})]}),(0,H.jsxs)("div",{className:"flex items-center justify-between px-1 py-[1px]",children:[(0,H.jsxs)("button",{disabled:s,className:(0,z.Z)("flex items-center gap-1 rounded-sm px-2 text-xs text-white",s?"bg-red-500":"bg-gray-500"),onClick:()=>{l(""),r(!0)},title:s?"":"Switch to live feed",children:[s&&(0,H.jsx)(Ka,{className:"h-4 w-4 animate-pulse fill-white"}),(0,H.jsx)("span",{children:"LIVE"})]}),(0,H.jsx)("span",{title:o,className:"truncate text-xs",style:{color:yj(o||"")},children:o}),(0,H.jsx)("span",{title:i,className:"truncate text-xs",style:{color:yj(o||"")},children:i}),(0,H.jsx)("button",{onClick:d,className:"rounded-md focus:ring-offset-0 enabled:hover:bg-slate-800/50",children:c?(0,H.jsx)(Oa,{className:"fill-dark-text h-5 w-5"}):(0,H.jsx)(Ma,{className:"fill-dark-text h-5 w-5"})})]})]})};const Nj=function(e){const{playbackUrl:t,videoSrc:n,onChangeVideoSrc:a}=e;return(0,H.jsxs)(H.Fragment,{children:[!t&&(0,H.jsx)("div",{children:"Playback Url is not available for this camera"}),n&&(0,H.jsx)("video",{autoPlay:!0,className:"dark:bg-ondark-bg-2 bg-onlight-bg-1 h-full w-full",onEnded:e=>{const n=e.target.currentSrc.split("?")[1],s=new URLSearchParams(n),r=s.get("start")||"",i=parseInt(s.get("duration")||""),o=new Date(new Date(r).getTime()+1e3*i),l=Math.floor((Date.now()-o.getTime())/1e3),c=new URLSearchParams;c.append("start",o.toISOString()),c.append("duration",String(l)),a(`${t}&${c.toString()}`)},children:(0,H.jsx)("source",{src:n,type:"video/mp4"})},n)]})};function Cj(e){const{text:t,onClick:n,icon:a,hideText:s}=e,r=a;return(0,H.jsxs)("button",{onClick:n,title:t,className:"flex items-center gap-1 rounded bg-black/50 px-3 py-1 text-xs font-semibold text-white transition-colors hover:bg-black/80",children:[(0,H.jsx)(r,{className:"h-5 w-5 text-white"}),!s&&t]})}const Sj=e=>{const{name:t,livestreamUrl:n,hideActions:s,tenantName:r,onClickSafe:i,onClickSnooze:o,onClickEscalate:l,eventHistory:c=[],playbackUrl:d}=e,[u,m]=(0,a.useState)(!0),h=(0,a.useRef)(null),[x,p]=(0,a.useState)({width:0,height:0}),[g,f]=(0,a.useState)(),[v,j]=(0,a.useState)(!1),{isFullScreen:b,toggleFullScreen:y}=D(h);(0,a.useLayoutEffect)((()=>{const e=new ResizeObserver((e=>{if(e.length>0){const t=e[0].target;p({width:t?t.clientWidth-4:0,height:t?t.clientHeight-4:0})}}));if(h.current){const t=h.current.parentElement;t&&e.observe(t)}return()=>{if(h.current){const t=h.current.parentElement;t&&e.unobserve(t)}}}),[]);const k=h.current&&h.current.clientWidth<280,w=e=>f(e);return(0,H.jsxs)("div",{className:(0,z.Z)("group/feed relative max-h-full max-w-full flex-grow",b&&""),ref:h,onDoubleClick:()=>y(),onMouseOver:()=>j(!0),onMouseOut:()=>j(!1),style:{width:x.width,height:x.height},children:[(0,H.jsx)("div",{className:(0,z.Z)("h-full",u?"visible":"hidden"),children:(0,H.jsx)(cr,{url:n,showControls:!1})}),(0,H.jsx)("div",{className:"h-full",children:(0,H.jsx)(Nj,{onChangeVideoSrc:w,videoSrc:g,playbackUrl:d})}),(0,H.jsx)(wj,{eventHistory:c,playbackUrl:d,isLiveMode:u,onChangeLiveMode:e=>m(e),camName:t,onChangeVideoSrc:w,tenantName:r,isFullScreen:b,toggleFullscreen:y,showSeeker:v}),!s&&(0,H.jsx)("div",{className:"absolute top-1/2 left-1/2 hidden -translate-x-1/2 -translate-y-1/2 group-hover/feed:block",children:(0,H.jsxs)("div",{className:"flex gap-2",children:[(0,H.jsx)(Cj,{icon:pj.Z,text:"Safe",onClick:i,hideText:!!k}),(0,H.jsx)(Cj,{icon:gj.Z,text:"Snooze",onClick:o,hideText:!!k}),(0,H.jsx)(Cj,{icon:Te.Z,text:"Escalate",onClick:l,hideText:!!k})]})})]})},Tj=(0,a.forwardRef)(((e,t)=>{const{onCameraAction:n,scanMode:s,escalationCamId:r,camsEventHistoryMap:i,isFullScreen:o}=e,[l,c]=(0,a.useState)([]),[d,u]=(0,a.useState)({rows:0,cols:0}),m=(0,a.useRef)(null),[h,x]=(0,a.useState)({width:0,height:0}),p=()=>{m.current&&x({width:m.current.offsetWidth,height:m.current.offsetHeight})};(0,a.useEffect)((()=>(p(),m.current&&window.addEventListener("resize",p),()=>window.removeEventListener("resize",p))),[r,o]);const g=e=>{try{const t=d.rows,n=d.cols,{rows:a,cols:s}=((e,t,n)=>{for(;t*n<e;)n>t?t++:n++;return{rows:t,cols:n}})(l.filter(Boolean).length+e.length,t,n);let r=[...l];if(s>n)for(let e=0;e<t;e++)for(let t=n;t<s;t++)r.splice(e*s+t,0,null);if(a>t){const e=new Array((a-t)*s).fill(null);r=[...r,...e]}for(const i of e){const e=r.findIndex((e=>null===e));-1!==e&&(r[e]=i)}u({rows:a,cols:s}),c(r)}catch(t){}},f=e=>{const t=l.findIndex((t=>(null==t?void 0:t.id)===e.id));let n=[...l];n[t]=null;const{nullRow:a,nullCol:s}=((e,t,n)=>{const a=[],s=[];for(let r=0;r<t;r++){const t=r*n,s=t+n;e.slice(t,s).every((e=>null===e))&&a.push(r)}for(let r=0;r<n;r++){let a=!0;for(let s=0;s<t;s++)if(null!==e[s*n+r]){a=!1;break}a&&s.push(r)}return{nullRow:a.length>0?a[0]:void 0,nullCol:s.length>0?s[0]:void 0}})(n,d.rows,d.cols);let r=d.rows,i=d.cols;void 0!==a&&(n=bj(n,d.rows,d.cols,a,!0),r-=1),void 0!==s&&(n=bj(n,d.rows,d.cols,s,!1),i-=1),u({rows:r,cols:i}),c(n)},v=()=>l.filter(Boolean),j=()=>{const e=[...l].filter(Boolean),t=e.reduce(((e,t)=>{const n=t.tenantId||"unknown";return e[n]||(e[n]=[]),e[n].push(t),e}),{}),n=Object.keys(t).sort(((e,n)=>t[n].length-t[e].length)),a=e.length,s=Math.ceil(Math.sqrt(a)),r=Math.ceil(a/s),i=Array(r).fill(null).map((()=>Array(s).fill(null)));let o=0,d=0;for(const l of n){const e=t[l];for(;e.length>0&&(i[d][o]=e.shift()||null,d++,!(d>=r&&(d=0,o++,o>=s))););if(o>=s)break}const m=i.flat();for(;m.length<s*r;)m.push(null);u({rows:r,cols:s}),c(m)};(0,a.useImperativeHandle)(t,(()=>({addCameras:g,removeCamera:f,getActiveCameras:v,arrangeSmartly:j})));const b=e=>()=>{kt("event_marked_safe",{cameraId:e.id,tenantId:e.tenantId}),f(e),n(rj.SAFE,e.id)},y=e=>()=>{kt("event_snoozed",{cameraId:e.id,tenantId:e.tenantId}),f(e),n(rj.SNOOZE,e.id),setTimeout((()=>p()),0)},k=e=>()=>{kt("event_escalated",{cameraId:e.id,tenantId:e.tenantId}),n(rj.ESCALATE,e.id)},w=(0,a.useCallback)((e=>{const{rows:t,cols:n}=d,a=16/9;let s=h.width/n,r=h.height/t;s/r>a?s=r*a:r=s/a;const i=(h.width-s*n)/(n+1),o=(h.height-r*t)/(t+1);return{left:`${i+e%n*(s+i)}px`,top:`${o+Math.floor(e/n)*(r+o)}px`,width:`${s}px`,height:`${r}px`}}),[d,h]);return(0,H.jsx)("div",{className:(0,z.Z)("relative h-[calc(100%)] max-h-full flex-grow"),ref:m,children:(0,H.jsx)(hj.M,{mode:"popLayout",children:l.map(((e,t)=>e?(0,H.jsx)(xj.E.div,{layout:!0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.4},className:(0,z.Z)("absolute flex flex-col overflow-hidden rounded-md p-[2px]"),style:Object.assign({},w(t)),children:(0,H.jsx)(Sj,{name:e.name,tenantName:e.tenantId||"",livestreamUrl:e.livestreamUrl||"",playbackUrl:e.visionPlaybackUrl,hideActions:s===sj.ESCALATION&&e.id===r,onClickSafe:b(e),onClickSnooze:y(e),onClickEscalate:k(e),eventHistory:i[e.id]||[]})},(null==e?void 0:e.id)||t):null))})})}));var Ej=n(26349);const Aj=function(e){const{toggleFullScreen:t,isFullScreen:n,onArrangeSmartly:a}=e;return(0,H.jsxs)("div",{className:"flex flex-grow items-center justify-end gap-2",children:[(0,H.jsx)(Q,{variant:"icon",onClick:a,title:"Smart Rearrange",children:(0,H.jsx)(Ej.Z,{className:"h-5 w-5"})}),(0,H.jsx)(Q,{variant:"icon",onClick:t,children:n?(0,H.jsx)(Oa,{className:"dark:fill-ondark-text-1 h-7 w-7"}):(0,H.jsx)(Ma,{className:"dark:fill-ondark-text-1 h-7 w-7"})})]})};var _j=n(94508),Ij=n(19114);const Lj=(0,a.forwardRef)(((e,t)=>{const{duration:n=60,size:s=200,strokeWidth:r=15,resetDuration:i=.5}=e,[o,l]=(0,a.useState)(100),c=(0,a.useRef)(null),d=(0,a.useRef)(100),u=(0,a.useRef)(!1),m=(0,a.useRef)(null),h=(0,a.useRef)(null),x=(0,a.useRef)(null),p=(0,a.useRef)(null),g=(s-r)/2,f=2*g*Math.PI,v=(0,a.useCallback)((e=>{let t;if(m.current||(m.current=e),u.current){var a,s;h.current||(h.current=e,x.current=d.current);const n=(e-h.current)/(1e3*i)*(100-(null!=(a=x.current)?a:100));t=Math.min(100,(null!=(s=x.current)?s:100)+n)}else{const a=e-m.current;t=Math.max(0,100-a/(1e3*n)*100)}d.current=t;const r=c.current;r&&(r.style.strokeDashoffset=""+(f-t/100*f),r.style.stroke=(0,Ij.ZP)("#ef4444","#3b82f6")(t/100)),Math.abs(t-o)>1&&l(Math.round(t)),u.current&&t<100||!u.current&&t>0?p.current=requestAnimationFrame(v):u.current&&t>=100&&(u.current=!1,m.current=null,h.current=null,x.current=null,p.current=requestAnimationFrame(v))}),[n,i,o,f]);(0,a.useEffect)((()=>(p.current=requestAnimationFrame(v),()=>{p.current&&cancelAnimationFrame(p.current)})),[v]);const j=(0,a.useCallback)((()=>{u.current=!0,h.current=null,x.current=null,p.current&&cancelAnimationFrame(p.current),p.current=requestAnimationFrame(v)}),[v]);return(0,a.useImperativeHandle)(t,(()=>({reset:j}))),(0,H.jsx)("div",{className:"relative flex items-center justify-center",children:(0,H.jsxs)("svg",{width:s,height:s,className:"-rotate-90 transform",children:[(0,H.jsx)("circle",{cx:s/2,cy:s/2,r:g,fill:"none",strokeWidth:.9*r,className:"stroke-white"}),(0,H.jsx)("circle",{ref:c,cx:s/2,cy:s/2,r:g,fill:"none",strokeWidth:r,strokeDasharray:f,strokeDashoffset:0})]})})}));function Rj(e){const{cameras:t,unSnoozeCam:n,camsEventHistoryMap:a}=e,s=e=>{const t=a[e];if(t&&t.length>0){return t[t.length-1].frame}return""};return(0,H.jsxs)("div",{className:"dark:border-ondark-line-2 flex max-h-32 max-w-[80%] items-center gap-2 overflow-auto border p-2",children:[(0,H.jsx)("div",{className:"text-sm",children:"Snoozed Cams"}),(0,H.jsx)("div",{className:"flex gap-2 overflow-x-scroll",children:t.map((e=>{return(0,H.jsxs)("div",{className:"relative w-32 flex-shrink-0 rounded-md",children:[(0,H.jsx)("div",{className:"pointer-events-none ",children:s(e.id)?(0,H.jsx)("img",{src:s(e.id),alt:"frame",className:"aspect-video"}):e.name}),(0,H.jsx)("div",{className:"absolute top-1 right-1",children:(0,H.jsx)(Lj,{duration:fj,size:15,strokeWidth:2})}),(0,H.jsx)("button",{onClick:(t=e.id,()=>n(t)),className:"bg-ondark-bg-2/60 pointer-events-auto absolute top-1 left-1 rounded-full",children:(0,H.jsx)(_j.Z,{className:"text-ondark-text-1 h-4 w-4"})})]},e.id);var t}))})]})}const Dj=(0,a.forwardRef)(((e,t)=>{const{isFullScreen:n,toggleFullScreen:s,scanMode:r,visionTenants:i,onEscalate:o,escalatedCamId:l,onCloseWs:c,onErrorWs:d}=e,[u,m]=(0,a.useState)([]),x=(0,a.useRef)(null),[p,g]=(0,a.useState)({}),f=(0,a.useRef)({}),v=(0,a.useRef)({}),{getAccessToken:j}=h(),{data:b}=on(((e,t)=>{const n=new URLSearchParams;if(e&&e.length>0){const a=e.map((e=>e.id));n.append(t,a.join(Yn))}return n.toString()})(i,"tenants")),y=(0,a.useMemo)((()=>(null==b?void 0:b.items)||[]),[null==b?void 0:b.items]),k=(0,a.useCallback)((e=>{const t=e.map((e=>e.camera_id)),n=Array.from(new Set(t)),a=x.current;if(!a)return;const s=a.getActiveCameras(),r=[];for(const l of n){const e=s.some((e=>e.id===l)),t=u.some((e=>e===l));if(!e&&!t){const e=null==y?void 0:y.find((e=>e.id===l));e&&r.push(e),r.length>0&&a.addCameras(r);const t=f.current;t[l]||(f.current=Object.assign({},t,{[l]:{isHistoryFetched:!1,tenantId:null==e?void 0:e.tenantId}}))}}const i=v.current,o=Object.assign({},i);e.forEach((e=>{o[e.camera_id]||(o[e.camera_id]=[]),o[e.camera_id]=e.metadata.persons})),v.current=o}),[y,u]),w=(0,a.useMemo)((()=>{const e=i.map((e=>e.id)).join(",");return`wss://event-flow-${window.location.hostname}/events?tenants=${e}`}),[i]),{sendMessage:N}=function(e,t,n,s,r,i){const o=(0,a.useRef)([]),l=(0,a.useRef)([]);(0,a.useEffect)((()=>{const e=window.setInterval((()=>{n(o.current),o.current=[]}),1e3);return()=>{window.clearInterval(e)}}),[n]),(0,a.useEffect)((()=>{const e=window.setInterval((()=>{s(l.current),l.current=[]}),1e3);return()=>{window.clearInterval(e)}}),[s]);const c=(0,a.useCallback)((e=>{const t=JSON.parse(e.data);t.event_type===ij.DETECTION?o.current=[...o.current,t]:t.event_type===ij.HISTORY&&(l.current=[...l.current,t])}),[]),{sendMessage:d}=Z({url:e,onMessage:c,getAccessToken:t,onClose:r,onError:i});return{sendMessage:d}}(w,j,k,(e=>{const t=Object.assign({},p);e.forEach((e=>{const n=e.id,a=t[n]?[...t[n]]:[],s={createdTime:e.timestamp_utc,frame:kj(e.metadata.frame),id:e.id,cameraId:e.camera_id,cameraName:e.camera_name,personIds:(r=e.metadata,r&&r.persons&&0!==r.persons.length?r.persons.map((e=>e.person_id)):[])};var r;t[n]=[...a,s]})),g(t),((e,t)=>{setTimeout((()=>{const n=Date.now(),a={};let s=!1;for(const[t,r]of Object.entries(e)){const e=r.findIndex((e=>n-e.createdTime<=6e5));-1===e?s=!0:e>0?(a[t]=r.slice(e),s=!0):a[t]=r}s&&t(a)}),5)})(p,g)}),c,d);(0,a.useEffect)((()=>{Object.keys(f.current).forEach((e=>{const t=f.current,n=t[e];if(!n.isHistoryFetched){N({camera_id:e,tenant_id:n.tenantId||"",event_type:oj.HISTORY});const a=Object.assign({},n,{isHistoryFetched:!0});f.current=Object.assign({},t,{[e]:a})}}))}),[N,f.current]);const C=e=>{N(e)};(0,a.useImperativeHandle)(t,(()=>({sendMessageInWebSocket:C})));const S=y.filter((e=>u.includes(e.id)));return(0,H.jsxs)("div",{className:(0,z.Z)("flex flex-col",n?"h-[calc(100vh-2rem)]":"h-[calc(100%-8px)]"),children:[(0,H.jsx)("div",{className:"w-full flex-grow",children:(0,H.jsx)(Tj,{ref:x,scanMode:r,isFullScreen:n,onCameraAction:(e,t)=>{switch(e){case rj.SNOOZE:m((e=>[...e,t])),setTimeout((()=>{m((e=>{const n=[...e],a=n.findIndex((e=>e===t));return a>-1&&n.splice(a,1),n}))}),1e3*fj);break;case rj.ESCALATE:{const e=y.find((e=>e.id===t));if(!e)return;o(e),N({camera_id:(null==e?void 0:e.id)||"",tenant_id:(null==e?void 0:e.tenantId)||"",event_type:oj.ESCALATION_OPEN});break}case rj.SAFE:{const e=y.find((e=>e.id===t)),n=v.current[t].map((e=>e.person_id));N({camera_id:(null==e?void 0:e.id)||"",tenant_id:(null==e?void 0:e.tenantId)||"",event_type:oj.SAFE,person_ids:null!=n?n:[]});const a=Object.assign({},f.current);delete a[t],f.current=a;const s=Object.assign({},p);s[t]=[],g(s);break}}},escalationCamId:l,camsEventHistoryMap:p})}),(0,H.jsxs)("div",{className:"mr-14 flex max-w-[calc(100vw-24px)] items-center gap-2",children:[(0,H.jsx)(Rj,{cameras:S||[],unSnoozeCam:e=>{const t=[...u],n=t.findIndex((t=>t===e));n>-1&&t.splice(n,1),m(t)},camsEventHistoryMap:p}),(0,H.jsx)(Aj,{toggleFullScreen:s,isFullScreen:n,onArrangeSmartly:()=>{const e=x.current;e&&e.arrangeSmartly()}})]})]})}));function Pj(e){const{visionTenants:t}=e,n=(0,a.useRef)(null),[s,r]=(0,a.useState)(sj.MONITORING),i=(0,a.useRef)(null),{isFullScreen:o,toggleFullScreen:l}=D(n),[c,d]=(0,a.useState)(!1),[u,m]=(0,a.useState)({escalationId:"",locationId:"",cameraId:"",tenantId:""}),{data:h,isSuccess:x,mutate:p,isError:g,error:f}=Bn();(0,a.useEffect)((()=>{x&&(h&&m((e=>Object.assign({},e,{escalationId:h.escalation_id}))),Le("Incident escalated successfully"))}),[h,x]);const v=()=>{r(sj.MONITORING);const e=i.current;null==e||e.sendMessageInWebSocket({camera_id:u.cameraId,event_type:oj.ESCALATION_CLOSE,tenant_id:u.tenantId}),m({cameraId:"",escalationId:"",locationId:"",tenantId:""})},j=(0,a.useCallback)((()=>d(!0)),[]);return c?(0,H.jsx)(B,{className:"m-4",type:"error",children:"Scan connection terminated. This may be due to a connection error or login from another location. Refresh to use Scan in this window."}):(0,H.jsxs)("div",{ref:n,className:(0,z.Z)("bg-onlight-bg-1 dark:bg-ondark-bg-1 fixed bottom-0 left-0 right-0 flex overflow-hidden p-4",o?"top-0":"top-20"),children:[g&&(0,H.jsx)(B,{className:"m-4",type:"error",children:f.message}),(0,H.jsx)("div",{className:"flex-grow",children:(0,H.jsx)(Dj,{ref:i,visionTenants:t,isFullScreen:o,escalatedCamId:u.cameraId,scanMode:s,toggleFullScreen:l,onEscalate:e=>{var t;r(sj.ESCALATION);const n=e.id,a=String(null==(t=e.location)?void 0:t.id)||"";p({camera_id:n,location_id:a}),m((t=>Object.assign({},t,{cameraId:n,locationId:a,tenantId:e.tenantId||""})))},onCloseWs:j,onErrorWs:j})}),s===sj.ESCALATION&&(0,H.jsx)("div",{className:"w-1/4",children:(0,H.jsx)(mj,{onResolveEscalation:v,escalationId:u.escalationId,locationId:u.locationId,escalatedCamId:u.cameraId,onCancel:v})})]})}function Mj(){const e=j();return(0,H.jsx)(mr,{title:"Scan",fullWidth:!0,children:e.visionTenants&&e.visionTenants.length>0?(0,H.jsx)(Pj,{visionTenants:e.visionTenants}):(0,H.jsx)(B,{type:"info",children:"You do not currently have access to this page. Please contact the system administrator to request access permissions. Thank you!"})})}const Oj="https://ae154f496153468cb6731cabe68b499c@o1288507.ingest.sentry.io/6557709",Fj="LOCAL"===Ar.name||"AIRGAP"===Ar.name;function Zj(){const e=j(),t=Ge(j(),"location_alarm:view");return e.roles[0]===i?(0,H.jsx)(r.Fg,{to:"/monitoring",replace:!0}):t?(0,H.jsx)(r.Fg,{to:"/location-alarms",replace:!0}):(0,H.jsx)(r.Fg,{to:"/alarms",replace:!0})}var qj=n(39104),Uj=n(76782),Vj=n(97775),$j=n(95450),zj=n(83184),Hj=n(55153),Bj=n(65522),Wj=n(68025),Gj=n(33332),Kj=n(84294);const Yj=[{id:"monitoring",name:"Monitoring",href:"/monitoring",icon:_a.Z,requiredPermissions:["location_alarms/monitoring:count","location_alarms/monitoring:get_pending"]},{id:"alarms",name:"Alarms",href:"/alarms",icon:qj.Z,requiredPermissions:["alarm:view"]},{id:"location-alarms",name:"Location Alarms",href:"/location-alarms",icon:Uj.Z,requiredPermissions:["location_alarm:view"]},{id:"doors",name:"Doors",href:"/doors",icon:Vj.Z,requiredPermissions:["door:view"]},{id:"cameras",name:"Cameras",href:"/cameras",icon:$j.Z,requiredPermissions:["camera:view"]},{id:"audiodevices",name:"Audio Devices",href:"/audiodevices",icon:Ee.Z,requiredPermissions:["audio_devices:view"]},{id:"locations",name:"Locations",href:"/locations",icon:zj.Z,requiredPermissions:["location:view"]},{id:"door_groups",name:"Door Groups",href:"/doorgroups",icon:function(){return(0,H.jsx)("svg",{viewBox:"0 96 960 960",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",className:"mr-3 h-6 w-6 flex-shrink-0",children:(0,H.jsx)("path",{d:"M120 936v-60h92V216h390v45h147v261h-60V321h-87v272h-60V276H272v600h206v60H120Zm575 40-5-48q-20-6-41-17.5T615 885l-42 20-35-54 38-30q-5-23-5-41.5t5-41.5l-38-30 35-55 42 20q13-12 34-24t41-18l5-49h60l6 49q20 6 41 18t34 24l42-20 35 55-38 30q5 23 5 41.5t-5 41.5l38 30-35 54-42-20q-13 14-34 25.5T761 928l-6 48h-60Zm30-95q44 0 73-29t29-73q0-44-29-73t-73-29q-44 0-73 29t-29 73q0 44 29 73t73 29ZM451 616q-17 0-28.5-11.5T411 576q0-17 11.5-28.5T451 536q17 0 28.5 11.5T491 576q0 17-11.5 28.5T451 616ZM272 876V276v600Z"})})},requiredPermissions:["door_group:view"]},{id:"users",name:"Users",href:"/users",icon:Hj.Z,requiredPermissions:["user:view"]},{id:"auditLog",name:"Audit Log",href:"/audit-log",icon:Bj.Z,requiredPermissions:["audit-log:view"]},{id:"insights",name:"Insights",href:"/insights",icon:Wj.Z,requiredPermissions:["insights:view"]},{id:"scan",name:"Scan",href:"/scan",icon:Gj.Z,requiredPermissions:["scan:view"]},{id:"scan",name:"Scan Escalations",href:"/scan-escalations",icon:Kj.Z,requiredPermissions:["scan-escalation:view"]}];function Qj(){const e=new Ct.QueryClient;return(0,H.jsx)(Hi,{children:(0,H.jsx)(Ct.QueryClientProvider,{client:e,children:(0,H.jsx)(Wi,{children:(0,H.jsx)(r.j3,{})})})})}const Xj=function(){const e={sentryDsn:Oj,sentryEnabled:!Fj,amplitudeEnabled:!Fj,intercomAppId:INTERCOM_APP_ID,intercomEnabled:!Fj,intercomSource:"hakimo"};return(0,Ss.aj)((0,r.i7)((0,H.jsxs)(r.AW,{element:(0,H.jsx)(Qj,{}),children:[(0,H.jsx)(r.AW,{path:"/shared/alarm",element:(0,H.jsx)(Bc,{})}),(0,H.jsx)(r.AW,{path:"/shared/location-alarm",element:(0,H.jsx)(fm,{})}),(0,H.jsx)(r.AW,{path:"/shared/live-view",element:(0,H.jsx)(Wx,{})}),(0,H.jsx)(r.AW,{path:"/login",element:(0,H.jsx)(Gr,{})}),(0,H.jsxs)(r.AW,{element:(0,H.jsx)(oo,{navItems:Yj,appInitOptions:e}),children:[(0,H.jsx)(r.AW,{path:"/",element:(0,H.jsx)(Zj,{})}),(0,H.jsx)(r.AW,{path:"/location-alarms/*",element:(0,H.jsx)(pm,{})}),(0,H.jsx)(r.AW,{path:"/monitoring/*",element:(0,H.jsx)(Wm,{})}),(0,H.jsx)(r.AW,{path:"/alarms/*",element:(0,H.jsx)(Wd,{})}),(0,H.jsx)(r.AW,{path:"/doors/*",element:(0,H.jsx)(Tg,{})}),(0,H.jsx)(r.AW,{path:"/cameras/*",element:(0,H.jsx)(Hx,{})}),(0,H.jsx)(r.AW,{path:"/users/*",element:(0,H.jsx)(Rv,{})}),(0,H.jsx)(r.AW,{path:"/insights/*",element:(0,H.jsx)(Eg,{})}),(0,H.jsx)(r.AW,{path:"/profile/*",element:(0,H.jsx)(tv,{})}),(0,H.jsx)(r.AW,{path:"/audit-log/*",element:(0,H.jsx)(gh,{})}),(0,H.jsx)(r.AW,{path:"/locations/*",element:(0,H.jsx)(Df,{})}),(0,H.jsx)(r.AW,{path:"/doorgroups/*",element:(0,H.jsx)(Tp,{})}),(0,H.jsx)(r.AW,{path:"/audiodevices/*",element:(0,H.jsx)(ih,{})}),(0,H.jsx)(r.AW,{path:"/scan/*",element:(0,H.jsx)(Mj,{})}),(0,H.jsx)(r.AW,{path:"/scan-escalations",element:(0,H.jsx)(aj,{})}),(0,H.jsx)(r.AW,{path:"*",element:(0,H.jsx)(As,{})})]})]})))};s.s(document.getElementById("root")).render((0,H.jsx)(a.StrictMode,{children:(0,H.jsx)(r.pG,{router:Xj()})}))}},e=>{var t=t=>e(e.s=t);e.O(0,[736],(()=>(t(26275),t(70419))));e.O()}]);
//# sourceMappingURL=main.3dee4452d660e49d.js.map