/*! For license information please see main.9f36f9efc9c7f9a926ac.js.LICENSE.txt */ (()=>{"use strict";var e={7775:(e,n,t)=>{var a=t(2604),r=t(4191),s=t(7183),i=t(7149),o=t(4140),c=t(2388),l=t(9664),d=t.n(l),h=t(7358),u=t(5416),m=t(442),p=t(8655),x=t(9575),j=t(5243),f=t(6447),g=t(6741),v=t(6845),y=t(6901),b=t(358),Z=t(5070),w=t(6840);const I="https://api.novitas.company/production-photocam";var S=t(9080),A=t(2050),k=t(5421),T=t(1553);const $=({camera:e})=>{const{sendCommand:n,loading:t}=function(){const{jwt:e}=(0,l.useNovitasAuth)(),[n,t]=(0,r.useState)(!1),[a,s]=(0,r.useState)(void 0);return{loading:n,error:a,sendCommand:function(n){t(!0),fetch(`${I}/cameras/actions/send-command`,{method:"POST",body:JSON.stringify(n),headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}).then((e=>e.json())).then((e=>{e.success||s(!0)})).finally((()=>{t(!1)}))}}}(),s=t||"idle"!==e.cameraJobStatus,i=(Date.now()-e.workerLastOnline)/1e3<=30,o=i&&"online"===e.cameraOnlineStatus,c=!s&&i&&o;return(0,a.jsxs)(j.Z,{style:{maxWidth:"400px",margin:"0 auto"},children:[(0,a.jsx)(f.Z,{title:e.id}),(0,a.jsxs)(g.Z,{children:[(0,a.jsx)(v.Z,{variant:"body1",children:i?(0,a.jsxs)(y.Z,{component:"span",display:"flex",alignItems:"center",mb:1,children:[(0,a.jsx)(k.Z,{}),(0,a.jsx)("span",{style:{marginLeft:"1em"},children:"Device: online"})]}):(0,a.jsxs)(y.Z,{component:"span",display:"flex",alignItems:"center",mb:1,children:[(0,a.jsx)(S.Z,{}),(0,a.jsx)("span",{style:{marginLeft:"1em"},children:"Device: offline"})]})}),(0,a.jsx)(v.Z,{variant:"body1",children:o?(0,a.jsxs)(y.Z,{component:"span",display:"flex",alignItems:"center",mb:1,children:[(0,a.jsx)(T.Z,{}),(0,a.jsx)("span",{style:{marginLeft:"1em"},children:"Camera: available"})]}):(0,a.jsxs)(y.Z,{component:"span",display:"flex",alignItems:"center",mb:1,children:[(0,a.jsx)(A.Z,{}),(0,a.jsx)("span",{style:{marginLeft:"1em"},children:"Camera: standby"})]})}),(0,a.jsxs)(v.Z,{variant:"body1",children:["idle"===e.cameraJobStatus&&(0,a.jsx)("b",{children:"Waiting for jobs..."}),"executing"===e.cameraJobStatus&&(0,a.jsx)("b",{children:"Taking and processing picture..."})]})]}),(0,a.jsx)(b.Z,{children:(0,a.jsx)(Z.Z,{size:"medium",color:"primary",variant:"contained",startIcon:(0,a.jsx)(w.Z,{}),fullWidth:!0,onClick:function(){n({cameraId:e.id,command:{command:"take_photo"}})},disabled:!c,children:s?"Taking photo...":"Take photo"})})]})};function O({fileId:e,jwt:n,size:t="o",nfsApiUrl:a}){return`${a}/download/${e}/?size=${t}&access-jwt=${n}&force-download=false`}var P=t(7206),C=t(666);const U=({image:e})=>{const n=O({fileId:e.nfsFileId,jwt:e.panoImageAccessToken,nfsApiUrl:"https://nfs.novitas.company/v1",size:"s"}),t=new Date(e.createdAt.toString()).toLocaleString();return(0,a.jsx)(o.Link,{to:`/image/${e.nfsFileId}/${e.panoImageAccessToken}`,children:(0,a.jsx)(j.Z,{children:(0,a.jsxs)(P.Z,{children:[(0,a.jsx)(C.Z,{style:{height:"140px"},image:n,title:t}),(0,a.jsx)(g.Z,{children:(0,a.jsx)(v.Z,{variant:"body2",color:"textSecondary",component:"p",style:{textDecoration:"none"},children:t})})]})})})};var z=t(1156);const D=({cameraId:e})=>{const{data:n}=(0,x.default)(`/images?cameraId=${e}`),t=((null==n?void 0:n.items)||[]).sort(((e,n)=>new Date(n.createdAt).getTime()-new Date(e.createdAt).getTime()));return(0,a.jsx)(z.Z,{container:!0,spacing:2,children:t.map((e=>(0,a.jsx)(z.Z,{item:!0,xs:12,sm:6,lg:4,children:(0,a.jsx)(U,{image:e})},e.nfsFileId)))})},F=({camera:e})=>(0,a.jsxs)("div",{children:[(0,a.jsx)($,{camera:e}),(0,a.jsx)(y.Z,{py:2}),(0,a.jsx)(D,{cameraId:e.id})]}),L=h.default.div` padding: 2em; max-width: 1280px; width: 100%; margin: 0 auto; `,N=e=>{const{data:n}=(0,x.default)("/cameras");return(0,a.jsxs)(L,{children:[(0,a.jsx)(v.Z,{variant:"h2",style:{textAlign:"center"},children:"Photocam"}),null==n?void 0:n.items.map((e=>(0,a.jsx)(F,{camera:e},e.id)))]})},W=()=>{const{jwt:e}=(0,l.useNovitasAuth)();return(0,a.jsx)(x.SWRConfig,{value:{suspense:!0,fetcher:n=>fetch(`${I}${n}`,{headers:{Authorization:`Bearer ${e}`}}).then((e=>e.json())),refreshInterval:1e4},children:(0,a.jsx)(N,{})})};function _(){const{loading:e,currentUser:n}=(0,l.useNovitasAuth)();window.NovitasUser=n;const t=!e&&n,r=!n&&!e;return(0,a.jsxs)(c.AW,{path:"/",exact:!0,children:[t&&(0,a.jsx)(W,{}),r&&(0,a.jsx)(c.l_,{to:"/login"})]})}t(230);const J=({panoramaUrl:e})=>{const n=(0,r.useRef)(null);return(0,r.useEffect)((()=>{let t=null;return n.current&&(t=pannellum.viewer(n.current,{type:"equirectangular",panorama:e}),t.loadScene()),()=>{var e;null===(e=t)||void 0===e||e.destroy()}}),[n.current]),(0,a.jsx)("div",{className:"index-module--2ienX",ref:n,id:"pano-viewer"})},M=e=>{const{nfsFileId:n="",accessToken:t=""}=(0,c.UO)(),r=O({fileId:n,jwt:t,nfsApiUrl:"https://nfs.novitas.company/v1"});return(0,a.jsx)("div",{children:(0,a.jsx)(J,{panoramaUrl:r})})},B=(0,u.Z)();s.render((0,a.jsx)(m.ZP,{injectFirst:!0,children:(0,a.jsx)(h.ThemeProvider,{theme:B,children:(0,a.jsxs)(o.BrowserRouter,{children:[(0,a.jsx)(i.ZP,{}),(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)(p.Z,{}),children:(0,a.jsx)(d(),{locizeApiKey:void 0,locizeProjectId:"736f0789-602a-407d-917b-aa20afa45346",novitasAuthApiUrl:"https://api.novitas.company/production-auth",saveMissing:!1,children:(0,a.jsxs)(c.rs,{children:[(0,a.jsx)(c.AW,{path:"/image/:nfsFileId/:accessToken",children:(0,a.jsx)(M,{})}),(0,a.jsx)(_,{})]})})})]})})}),document.querySelector("#app"))}},n={};function t(a){if(n[a])return n[a].exports;var r=n[a]={id:a,loaded:!1,exports:{}};return e[a].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}t.m=e,t.x=e=>{},t.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},t.d=(e,n)=>{for(var a in n)t.o(n,a)&&!t.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:n[a]})},t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),t.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e={179:0},n=[[7775,208]],a=e=>{},r=(r,s)=>{for(var i,o,[c,l,d,h]=s,u=0,m=[];u{}),a}s.forEach(r.bind(null,0)),s.push=r.bind(null,s.push.bind(s));var o=t.x;t.x=()=>(t.x=o||(e=>{}),(a=i)())})(),t.x()})();