diff --git a/desktop/frontend/dist/assets/index-DSNu_2FW.js b/desktop/frontend/dist/assets/index-DSNu_2FW.js deleted file mode 100644 index 1153fa5..0000000 --- a/desktop/frontend/dist/assets/index-DSNu_2FW.js +++ /dev/null @@ -1,40 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const s of l)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(l){const s={};return l.integrity&&(s.integrity=l.integrity),l.referrerPolicy&&(s.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?s.credentials="include":l.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(l){if(l.ep)return;l.ep=!0;const s=n(l);fetch(l.href,s)}})();function Tc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var da={exports:{}},pl={},fa={exports:{}},D={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var lr=Symbol.for("react.element"),Mc=Symbol.for("react.portal"),Rc=Symbol.for("react.fragment"),Dc=Symbol.for("react.strict_mode"),Oc=Symbol.for("react.profiler"),Fc=Symbol.for("react.provider"),Ic=Symbol.for("react.context"),$c=Symbol.for("react.forward_ref"),Uc=Symbol.for("react.suspense"),Ac=Symbol.for("react.memo"),Bc=Symbol.for("react.lazy"),Zi=Symbol.iterator;function Vc(e){return e===null||typeof e!="object"?null:(e=Zi&&e[Zi]||e["@@iterator"],typeof e=="function"?e:null)}var pa={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ha=Object.assign,ma={};function vn(e,t,n){this.props=e,this.context=t,this.refs=ma,this.updater=n||pa}vn.prototype.isReactComponent={};vn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};vn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function va(){}va.prototype=vn.prototype;function ei(e,t,n){this.props=e,this.context=t,this.refs=ma,this.updater=n||pa}var ti=ei.prototype=new va;ti.constructor=ei;ha(ti,vn.prototype);ti.isPureReactComponent=!0;var Ji=Array.isArray,ga=Object.prototype.hasOwnProperty,ni={current:null},ya={key:!0,ref:!0,__self:!0,__source:!0};function xa(e,t,n){var r,l={},s=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(s=""+t.key),t)ga.call(t,r)&&!ya.hasOwnProperty(r)&&(l[r]=t[r]);var a=arguments.length-2;if(a===1)l.children=n;else if(1>>1,te=_[X];if(0>>1;Xl(Tl,R))_tl(cr,Tl)?(_[X]=cr,_[_t]=R,X=_t):(_[X]=Tl,_[Et]=R,X=Et);else if(_tl(cr,R))_[X]=cr,_[_t]=R,X=_t;else break e}}return T}function l(_,T){var R=_.sortIndex-T.sortIndex;return R!==0?R:_.id-T.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();e.unstable_now=function(){return o.now()-a}}var u=[],c=[],p=1,v=null,h=3,g=!1,x=!1,y=!1,z=typeof setTimeout=="function"?setTimeout:null,f=typeof clearTimeout=="function"?clearTimeout:null,d=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function m(_){for(var T=n(c);T!==null;){if(T.callback===null)r(c);else if(T.startTime<=_)r(c),T.sortIndex=T.expirationTime,t(u,T);else break;T=n(c)}}function w(_){if(y=!1,m(_),!x)if(n(u)!==null)x=!0,zl(S);else{var T=n(c);T!==null&&Ll(w,T.startTime-_)}}function S(_,T){x=!1,y&&(y=!1,f(E),E=-1),g=!0;var R=h;try{for(m(T),v=n(u);v!==null&&(!(v.expirationTime>T)||_&&!ge());){var X=v.callback;if(typeof X=="function"){v.callback=null,h=v.priorityLevel;var te=X(v.expirationTime<=T);T=e.unstable_now(),typeof te=="function"?v.callback=te:v===n(u)&&r(u),m(T)}else r(u);v=n(u)}if(v!==null)var ur=!0;else{var Et=n(c);Et!==null&&Ll(w,Et.startTime-T),ur=!1}return ur}finally{v=null,h=R,g=!1}}var P=!1,k=null,E=-1,U=5,M=-1;function ge(){return!(e.unstable_now()-M_||125<_?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<_?Math.floor(1e3/_):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(_){switch(h){case 1:case 2:case 3:var T=3;break;default:T=h}var R=h;h=T;try{return _()}finally{h=R}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(_,T){switch(_){case 1:case 2:case 3:case 4:case 5:break;default:_=3}var R=h;h=_;try{return T()}finally{h=R}},e.unstable_scheduleCallback=function(_,T,R){var X=e.unstable_now();switch(typeof R=="object"&&R!==null?(R=R.delay,R=typeof R=="number"&&0X?(_.sortIndex=R,t(c,_),n(u)===null&&_===n(c)&&(y?(f(E),E=-1):y=!0,Ll(w,R-X))):(_.sortIndex=te,t(u,_),x||g||(x=!0,zl(S))),_},e.unstable_shouldYield=ge,e.unstable_wrapCallback=function(_){var T=h;return function(){var R=h;h=T;try{return _.apply(this,arguments)}finally{h=R}}}})(Na);Sa.exports=Na;var ed=Sa.exports;/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var td=N,_e=ed;function j(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ss=Object.prototype.hasOwnProperty,nd=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,bi={},eo={};function rd(e){return ss.call(eo,e)?!0:ss.call(bi,e)?!1:nd.test(e)?eo[e]=!0:(bi[e]=!0,!1)}function ld(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function sd(e,t,n,r){if(t===null||typeof t>"u"||ld(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function ve(e,t,n,r,l,s,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=o}var ie={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ie[e]=new ve(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];ie[t]=new ve(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ie[e]=new ve(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ie[e]=new ve(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){ie[e]=new ve(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ie[e]=new ve(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ie[e]=new ve(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ie[e]=new ve(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ie[e]=new ve(e,5,!1,e.toLowerCase(),null,!1,!1)});var li=/[\-:]([a-z])/g;function si(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(li,si);ie[t]=new ve(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(li,si);ie[t]=new ve(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(li,si);ie[t]=new ve(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ie[e]=new ve(e,1,!1,e.toLowerCase(),null,!1,!1)});ie.xlinkHref=new ve("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ie[e]=new ve(e,1,!1,e.toLowerCase(),null,!0,!0)});function ii(e,t,n,r){var l=ie.hasOwnProperty(t)?ie[t]:null;(l!==null?l.type!==0:r||!(2a||l[o]!==s[a]){var u=` -`+l[o].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=o&&0<=a);break}}}finally{Dl=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Pn(e):""}function id(e){switch(e.tag){case 5:return Pn(e.type);case 16:return Pn("Lazy");case 13:return Pn("Suspense");case 19:return Pn("SuspenseList");case 0:case 2:case 15:return e=Ol(e.type,!1),e;case 11:return e=Ol(e.type.render,!1),e;case 1:return e=Ol(e.type,!0),e;default:return""}}function us(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Ht:return"Fragment";case Wt:return"Portal";case is:return"Profiler";case oi:return"StrictMode";case os:return"Suspense";case as:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case _a:return(e.displayName||"Context")+".Consumer";case Ea:return(e._context.displayName||"Context")+".Provider";case ai:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ui:return t=e.displayName||null,t!==null?t:us(e.type)||"Memo";case it:t=e._payload,e=e._init;try{return us(e(t))}catch{}}return null}function od(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return us(t);case 8:return t===oi?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function jt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function za(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ad(e){var t=za(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function pr(e){e._valueTracker||(e._valueTracker=ad(e))}function La(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=za(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Wr(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function cs(e,t){var n=t.checked;return Y({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function no(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=jt(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Ta(e,t){t=t.checked,t!=null&&ii(e,"checked",t,!1)}function ds(e,t){Ta(e,t);var n=jt(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?fs(e,t.type,n):t.hasOwnProperty("defaultValue")&&fs(e,t.type,jt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function ro(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function fs(e,t,n){(t!=="number"||Wr(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var zn=Array.isArray;function tn(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=hr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Vn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Mn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ud=["Webkit","ms","Moz","O"];Object.keys(Mn).forEach(function(e){ud.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Mn[t]=Mn[e]})});function Oa(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Mn.hasOwnProperty(e)&&Mn[e]?(""+t).trim():t+"px"}function Fa(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Oa(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var cd=Y({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ms(e,t){if(t){if(cd[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(j(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(j(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(j(61))}if(t.style!=null&&typeof t.style!="object")throw Error(j(62))}}function vs(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var gs=null;function ci(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ys=null,nn=null,rn=null;function io(e){if(e=or(e)){if(typeof ys!="function")throw Error(j(280));var t=e.stateNode;t&&(t=yl(t),ys(e.stateNode,e.type,t))}}function Ia(e){nn?rn?rn.push(e):rn=[e]:nn=e}function $a(){if(nn){var e=nn,t=rn;if(rn=nn=null,io(e),t)for(e=0;e>>=0,e===0?32:31-(jd(e)/kd|0)|0}var mr=64,vr=4194304;function Ln(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Yr(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,s=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~l;a!==0?r=Ln(a):(s&=o,s!==0&&(r=Ln(s)))}else o=n&~l,o!==0?r=Ln(o):s!==0&&(r=Ln(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,s=t&-t,l>=s||l===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function sr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ae(t),e[t]=n}function Ed(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Dn),vo=" ",go=!1;function lu(e,t){switch(e){case"keyup":return ef.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function su(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Qt=!1;function nf(e,t){switch(e){case"compositionend":return su(t);case"keypress":return t.which!==32?null:(go=!0,vo);case"textInput":return e=t.data,e===vo&&go?null:e;default:return null}}function rf(e,t){if(Qt)return e==="compositionend"||!yi&&lu(e,t)?(e=nu(),Dr=mi=ct=null,Qt=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=jo(n)}}function uu(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?uu(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function cu(){for(var e=window,t=Wr();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Wr(e.document)}return t}function xi(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function pf(e){var t=cu(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&uu(n.ownerDocument.documentElement,n)){if(r!==null&&xi(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,s=Math.min(r.start,l);r=r.end===void 0?s:Math.min(r.end,l),!e.extend&&s>r&&(l=r,r=s,s=l),l=ko(n,s);var o=ko(n,r);l&&o&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Kt=null,Ns=null,Fn=null,Cs=!1;function So(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Cs||Kt==null||Kt!==Wr(r)||(r=Kt,"selectionStart"in r&&xi(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Fn&&Gn(Fn,r)||(Fn=r,r=Zr(Ns,"onSelect"),0Xt||(e.current=Ts[Xt],Ts[Xt]=null,Xt--)}function A(e,t){Xt++,Ts[Xt]=e.current,e.current=t}var kt={},ce=Nt(kt),we=Nt(!1),Ot=kt;function cn(e,t){var n=e.type.contextTypes;if(!n)return kt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},s;for(s in n)l[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function je(e){return e=e.childContextTypes,e!=null}function qr(){W(we),W(ce)}function Lo(e,t,n){if(ce.current!==kt)throw Error(j(168));A(ce,t),A(we,n)}function xu(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(j(108,od(e)||"Unknown",l));return Y({},n,r)}function br(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||kt,Ot=ce.current,A(ce,e),A(we,we.current),!0}function To(e,t,n){var r=e.stateNode;if(!r)throw Error(j(169));n?(e=xu(e,t,Ot),r.__reactInternalMemoizedMergedChildContext=e,W(we),W(ce),A(ce,e)):W(we),A(we,n)}var Xe=null,xl=!1,Xl=!1;function wu(e){Xe===null?Xe=[e]:Xe.push(e)}function Cf(e){xl=!0,wu(e)}function Ct(){if(!Xl&&Xe!==null){Xl=!0;var e=0,t=$;try{var n=Xe;for($=1;e>=o,l-=o,Ze=1<<32-Ae(t)+l|n<E?(U=k,k=null):U=k.sibling;var M=h(f,k,m[E],w);if(M===null){k===null&&(k=U);break}e&&k&&M.alternate===null&&t(f,k),d=s(M,d,E),P===null?S=M:P.sibling=M,P=M,k=U}if(E===m.length)return n(f,k),H&&Pt(f,E),S;if(k===null){for(;EE?(U=k,k=null):U=k.sibling;var ge=h(f,k,M.value,w);if(ge===null){k===null&&(k=U);break}e&&k&&ge.alternate===null&&t(f,k),d=s(ge,d,E),P===null?S=ge:P.sibling=ge,P=ge,k=U}if(M.done)return n(f,k),H&&Pt(f,E),S;if(k===null){for(;!M.done;E++,M=m.next())M=v(f,M.value,w),M!==null&&(d=s(M,d,E),P===null?S=M:P.sibling=M,P=M);return H&&Pt(f,E),S}for(k=r(f,k);!M.done;E++,M=m.next())M=g(k,f,E,M.value,w),M!==null&&(e&&M.alternate!==null&&k.delete(M.key===null?E:M.key),d=s(M,d,E),P===null?S=M:P.sibling=M,P=M);return e&&k.forEach(function(L){return t(f,L)}),H&&Pt(f,E),S}function z(f,d,m,w){if(typeof m=="object"&&m!==null&&m.type===Ht&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case fr:e:{for(var S=m.key,P=d;P!==null;){if(P.key===S){if(S=m.type,S===Ht){if(P.tag===7){n(f,P.sibling),d=l(P,m.props.children),d.return=f,f=d;break e}}else if(P.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===it&&Do(S)===P.type){n(f,P.sibling),d=l(P,m.props),d.ref=Nn(f,P,m),d.return=f,f=d;break e}n(f,P);break}else t(f,P);P=P.sibling}m.type===Ht?(d=Dt(m.props.children,f.mode,w,m.key),d.return=f,f=d):(w=Vr(m.type,m.key,m.props,null,f.mode,w),w.ref=Nn(f,d,m),w.return=f,f=w)}return o(f);case Wt:e:{for(P=m.key;d!==null;){if(d.key===P)if(d.tag===4&&d.stateNode.containerInfo===m.containerInfo&&d.stateNode.implementation===m.implementation){n(f,d.sibling),d=l(d,m.children||[]),d.return=f,f=d;break e}else{n(f,d);break}else t(f,d);d=d.sibling}d=rs(m,f.mode,w),d.return=f,f=d}return o(f);case it:return P=m._init,z(f,d,P(m._payload),w)}if(zn(m))return x(f,d,m,w);if(xn(m))return y(f,d,m,w);Sr(f,m)}return typeof m=="string"&&m!==""||typeof m=="number"?(m=""+m,d!==null&&d.tag===6?(n(f,d.sibling),d=l(d,m),d.return=f,f=d):(n(f,d),d=ns(m,f.mode,w),d.return=f,f=d),o(f)):n(f,d)}return z}var fn=Nu(!0),Cu=Nu(!1),nl=Nt(null),rl=null,qt=null,Si=null;function Ni(){Si=qt=rl=null}function Ci(e){var t=nl.current;W(nl),e._currentValue=t}function Ds(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function sn(e,t){rl=e,Si=qt=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(xe=!0),e.firstContext=null)}function De(e){var t=e._currentValue;if(Si!==e)if(e={context:e,memoizedValue:t,next:null},qt===null){if(rl===null)throw Error(j(308));qt=e,rl.dependencies={lanes:0,firstContext:e}}else qt=qt.next=e;return t}var Tt=null;function Ei(e){Tt===null?Tt=[e]:Tt.push(e)}function Eu(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Ei(t)):(n.next=l.next,l.next=n),t.interleaved=n,tt(e,r)}function tt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var ot=!1;function _i(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function _u(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function qe(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function vt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,O&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,tt(e,n)}return l=r.interleaved,l===null?(t.next=t,Ei(r)):(t.next=l.next,l.next=t),r.interleaved=t,tt(e,n)}function Fr(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,fi(e,n)}}function Oo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?l=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?l=s=t:s=s.next=t}else l=s=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ll(e,t,n,r){var l=e.updateQueue;ot=!1;var s=l.firstBaseUpdate,o=l.lastBaseUpdate,a=l.shared.pending;if(a!==null){l.shared.pending=null;var u=a,c=u.next;u.next=null,o===null?s=c:o.next=c,o=u;var p=e.alternate;p!==null&&(p=p.updateQueue,a=p.lastBaseUpdate,a!==o&&(a===null?p.firstBaseUpdate=c:a.next=c,p.lastBaseUpdate=u))}if(s!==null){var v=l.baseState;o=0,p=c=u=null,a=s;do{var h=a.lane,g=a.eventTime;if((r&h)===h){p!==null&&(p=p.next={eventTime:g,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var x=e,y=a;switch(h=t,g=n,y.tag){case 1:if(x=y.payload,typeof x=="function"){v=x.call(g,v,h);break e}v=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=y.payload,h=typeof x=="function"?x.call(g,v,h):x,h==null)break e;v=Y({},v,h);break e;case 2:ot=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,h=l.effects,h===null?l.effects=[a]:h.push(a))}else g={eventTime:g,lane:h,tag:a.tag,payload:a.payload,callback:a.callback,next:null},p===null?(c=p=g,u=v):p=p.next=g,o|=h;if(a=a.next,a===null){if(a=l.shared.pending,a===null)break;h=a,a=h.next,h.next=null,l.lastBaseUpdate=h,l.shared.pending=null}}while(!0);if(p===null&&(u=v),l.baseState=u,l.firstBaseUpdate=c,l.lastBaseUpdate=p,t=l.shared.interleaved,t!==null){l=t;do o|=l.lane,l=l.next;while(l!==t)}else s===null&&(l.shared.lanes=0);$t|=o,e.lanes=o,e.memoizedState=v}}function Fo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Jl.transition;Jl.transition={};try{e(!1),t()}finally{$=n,Jl.transition=r}}function Hu(){return Oe().memoizedState}function zf(e,t,n){var r=yt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Qu(e))Ku(t,n);else if(n=Eu(e,t,n,r),n!==null){var l=pe();Be(n,e,r,l),Yu(n,t,r)}}function Lf(e,t,n){var r=yt(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Qu(e))Ku(t,l);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var o=t.lastRenderedState,a=s(o,n);if(l.hasEagerState=!0,l.eagerState=a,Ve(a,o)){var u=t.interleaved;u===null?(l.next=l,Ei(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=Eu(e,t,l,r),n!==null&&(l=pe(),Be(n,e,r,l),Yu(n,t,r))}}function Qu(e){var t=e.alternate;return e===K||t!==null&&t===K}function Ku(e,t){In=il=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Yu(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,fi(e,n)}}var ol={readContext:De,useCallback:oe,useContext:oe,useEffect:oe,useImperativeHandle:oe,useInsertionEffect:oe,useLayoutEffect:oe,useMemo:oe,useReducer:oe,useRef:oe,useState:oe,useDebugValue:oe,useDeferredValue:oe,useTransition:oe,useMutableSource:oe,useSyncExternalStore:oe,useId:oe,unstable_isNewReconciler:!1},Tf={readContext:De,useCallback:function(e,t){return He().memoizedState=[e,t===void 0?null:t],e},useContext:De,useEffect:$o,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,$r(4194308,4,Uu.bind(null,t,e),n)},useLayoutEffect:function(e,t){return $r(4194308,4,e,t)},useInsertionEffect:function(e,t){return $r(4,2,e,t)},useMemo:function(e,t){var n=He();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=He();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=zf.bind(null,K,e),[r.memoizedState,e]},useRef:function(e){var t=He();return e={current:e},t.memoizedState=e},useState:Io,useDebugValue:Oi,useDeferredValue:function(e){return He().memoizedState=e},useTransition:function(){var e=Io(!1),t=e[0];return e=Pf.bind(null,e[1]),He().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=K,l=He();if(H){if(n===void 0)throw Error(j(407));n=n()}else{if(n=t(),re===null)throw Error(j(349));It&30||Tu(r,t,n)}l.memoizedState=n;var s={value:n,getSnapshot:t};return l.queue=s,$o(Ru.bind(null,r,s,e),[e]),r.flags|=2048,nr(9,Mu.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=He(),t=re.identifierPrefix;if(H){var n=Je,r=Ze;n=(r&~(1<<32-Ae(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=er++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[Qe]=t,e[Jn]=r,rc(e,t,!1,!1),t.stateNode=e;e:{switch(o=vs(n,r),n){case"dialog":V("cancel",e),V("close",e),l=r;break;case"iframe":case"object":case"embed":V("load",e),l=r;break;case"video":case"audio":for(l=0;lmn&&(t.flags|=128,r=!0,Cn(s,!1),t.lanes=4194304)}else{if(!r)if(e=sl(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Cn(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!H)return ae(t),null}else 2*Z()-s.renderingStartTime>mn&&n!==1073741824&&(t.flags|=128,r=!0,Cn(s,!1),t.lanes=4194304);s.isBackwards?(o.sibling=t.child,t.child=o):(n=s.last,n!==null?n.sibling=o:t.child=o,s.last=o)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=Z(),t.sibling=null,n=Q.current,A(Q,r?n&1|2:n&1),t):(ae(t),null);case 22:case 23:return Bi(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Se&1073741824&&(ae(t),t.subtreeFlags&6&&(t.flags|=8192)):ae(t),null;case 24:return null;case 25:return null}throw Error(j(156,t.tag))}function Uf(e,t){switch(ji(t),t.tag){case 1:return je(t.type)&&qr(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return pn(),W(we),W(ce),Li(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return zi(t),null;case 13:if(W(Q),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(j(340));dn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return W(Q),null;case 4:return pn(),null;case 10:return Ci(t.type._context),null;case 22:case 23:return Bi(),null;case 24:return null;default:return null}}var Cr=!1,ue=!1,Af=typeof WeakSet=="function"?WeakSet:Set,C=null;function bt(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){G(e,t,r)}else n.current=null}function Ws(e,t,n){try{n()}catch(r){G(e,t,r)}}var Xo=!1;function Bf(e,t){if(Es=Gr,e=cu(),xi(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,u=-1,c=0,p=0,v=e,h=null;t:for(;;){for(var g;v!==n||l!==0&&v.nodeType!==3||(a=o+l),v!==s||r!==0&&v.nodeType!==3||(u=o+r),v.nodeType===3&&(o+=v.nodeValue.length),(g=v.firstChild)!==null;)h=v,v=g;for(;;){if(v===e)break t;if(h===n&&++c===l&&(a=o),h===s&&++p===r&&(u=o),(g=v.nextSibling)!==null)break;v=h,h=v.parentNode}v=g}n=a===-1||u===-1?null:{start:a,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(_s={focusedElem:e,selectionRange:n},Gr=!1,C=t;C!==null;)if(t=C,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,C=e;else for(;C!==null;){t=C;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var y=x.memoizedProps,z=x.memoizedState,f=t.stateNode,d=f.getSnapshotBeforeUpdate(t.elementType===t.type?y:Ie(t.type,y),z);f.__reactInternalSnapshotBeforeUpdate=d}break;case 3:var m=t.stateNode.containerInfo;m.nodeType===1?m.textContent="":m.nodeType===9&&m.documentElement&&m.removeChild(m.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(j(163))}}catch(w){G(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,C=e;break}C=t.return}return x=Xo,Xo=!1,x}function $n(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var s=l.destroy;l.destroy=void 0,s!==void 0&&Ws(t,n,s)}l=l.next}while(l!==r)}}function kl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Hs(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function ic(e){var t=e.alternate;t!==null&&(e.alternate=null,ic(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Qe],delete t[Jn],delete t[Ls],delete t[Sf],delete t[Nf])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function oc(e){return e.tag===5||e.tag===3||e.tag===4}function Zo(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||oc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Qs(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Jr));else if(r!==4&&(e=e.child,e!==null))for(Qs(e,t,n),e=e.sibling;e!==null;)Qs(e,t,n),e=e.sibling}function Ks(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Ks(e,t,n),e=e.sibling;e!==null;)Ks(e,t,n),e=e.sibling}var le=null,$e=!1;function st(e,t,n){for(n=n.child;n!==null;)ac(e,t,n),n=n.sibling}function ac(e,t,n){if(Ke&&typeof Ke.onCommitFiberUnmount=="function")try{Ke.onCommitFiberUnmount(hl,n)}catch{}switch(n.tag){case 5:ue||bt(n,t);case 6:var r=le,l=$e;le=null,st(e,t,n),le=r,$e=l,le!==null&&($e?(e=le,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):le.removeChild(n.stateNode));break;case 18:le!==null&&($e?(e=le,n=n.stateNode,e.nodeType===8?Gl(e.parentNode,n):e.nodeType===1&&Gl(e,n),Kn(e)):Gl(le,n.stateNode));break;case 4:r=le,l=$e,le=n.stateNode.containerInfo,$e=!0,st(e,t,n),le=r,$e=l;break;case 0:case 11:case 14:case 15:if(!ue&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var s=l,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&Ws(n,t,o),l=l.next}while(l!==r)}st(e,t,n);break;case 1:if(!ue&&(bt(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){G(n,t,a)}st(e,t,n);break;case 21:st(e,t,n);break;case 22:n.mode&1?(ue=(r=ue)||n.memoizedState!==null,st(e,t,n),ue=r):st(e,t,n);break;default:st(e,t,n)}}function Jo(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Af),t.forEach(function(r){var l=Zf.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Fe(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=o),r&=~s}if(r=l,r=Z()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Wf(r/1960))-r,10e?16:e,dt===null)var r=!1;else{if(e=dt,dt=null,cl=0,O&6)throw Error(j(331));var l=O;for(O|=4,C=e.current;C!==null;){var s=C,o=s.child;if(C.flags&16){var a=s.deletions;if(a!==null){for(var u=0;uZ()-Ui?Rt(e,0):$i|=n),ke(e,t)}function vc(e,t){t===0&&(e.mode&1?(t=vr,vr<<=1,!(vr&130023424)&&(vr=4194304)):t=1);var n=pe();e=tt(e,t),e!==null&&(sr(e,t,n),ke(e,n))}function Xf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),vc(e,n)}function Zf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(j(314))}r!==null&&r.delete(t),vc(e,n)}var gc;gc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||we.current)xe=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return xe=!1,If(e,t,n);xe=!!(e.flags&131072)}else xe=!1,H&&t.flags&1048576&&ju(t,tl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ur(e,t),e=t.pendingProps;var l=cn(t,ce.current);sn(t,n),l=Mi(null,t,r,e,l,n);var s=Ri();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,je(r)?(s=!0,br(t)):s=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,_i(t),l.updater=jl,t.stateNode=l,l._reactInternals=t,Fs(t,r,e,n),t=Us(null,t,r,!0,s,n)):(t.tag=0,H&&s&&wi(t),fe(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ur(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=qf(r),e=Ie(r,e),l){case 0:t=$s(null,t,r,e,n);break e;case 1:t=Ko(null,t,r,e,n);break e;case 11:t=Ho(null,t,r,e,n);break e;case 14:t=Qo(null,t,r,Ie(r.type,e),n);break e}throw Error(j(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ie(r,l),$s(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ie(r,l),Ko(e,t,r,l,n);case 3:e:{if(ec(t),e===null)throw Error(j(387));r=t.pendingProps,s=t.memoizedState,l=s.element,_u(e,t),ll(t,r,null,n);var o=t.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){l=hn(Error(j(423)),t),t=Yo(e,t,r,n,l);break e}else if(r!==l){l=hn(Error(j(424)),t),t=Yo(e,t,r,n,l);break e}else for(Ne=mt(t.stateNode.containerInfo.firstChild),Ce=t,H=!0,Ue=null,n=Cu(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(dn(),r===l){t=nt(e,t,n);break e}fe(e,t,r,n)}t=t.child}return t;case 5:return Pu(t),e===null&&Rs(t),r=t.type,l=t.pendingProps,s=e!==null?e.memoizedProps:null,o=l.children,Ps(r,l)?o=null:s!==null&&Ps(r,s)&&(t.flags|=32),bu(e,t),fe(e,t,o,n),t.child;case 6:return e===null&&Rs(t),null;case 13:return tc(e,t,n);case 4:return Pi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=fn(t,null,r,n):fe(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ie(r,l),Ho(e,t,r,l,n);case 7:return fe(e,t,t.pendingProps,n),t.child;case 8:return fe(e,t,t.pendingProps.children,n),t.child;case 12:return fe(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,s=t.memoizedProps,o=l.value,A(nl,r._currentValue),r._currentValue=o,s!==null)if(Ve(s.value,o)){if(s.children===l.children&&!we.current){t=nt(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var u=a.firstContext;u!==null;){if(u.context===r){if(s.tag===1){u=qe(-1,n&-n),u.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var p=c.pending;p===null?u.next=u:(u.next=p.next,p.next=u),c.pending=u}}s.lanes|=n,u=s.alternate,u!==null&&(u.lanes|=n),Ds(s.return,n,t),a.lanes|=n;break}u=u.next}}else if(s.tag===10)o=s.type===t.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(j(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),Ds(o,n,t),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===t){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}fe(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,sn(t,n),l=De(l),r=r(l),t.flags|=1,fe(e,t,r,n),t.child;case 14:return r=t.type,l=Ie(r,t.pendingProps),l=Ie(r.type,l),Qo(e,t,r,l,n);case 15:return Ju(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ie(r,l),Ur(e,t),t.tag=1,je(r)?(e=!0,br(t)):e=!1,sn(t,n),Gu(t,r,l),Fs(t,r,l,n),Us(null,t,r,!0,e,n);case 19:return nc(e,t,n);case 22:return qu(e,t,n)}throw Error(j(156,t.tag))};function yc(e,t){return Qa(e,t)}function Jf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Me(e,t,n,r){return new Jf(e,t,n,r)}function Wi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function qf(e){if(typeof e=="function")return Wi(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ai)return 11;if(e===ui)return 14}return 2}function xt(e,t){var n=e.alternate;return n===null?(n=Me(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Vr(e,t,n,r,l,s){var o=2;if(r=e,typeof e=="function")Wi(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Ht:return Dt(n.children,l,s,t);case oi:o=8,l|=8;break;case is:return e=Me(12,n,t,l|2),e.elementType=is,e.lanes=s,e;case os:return e=Me(13,n,t,l),e.elementType=os,e.lanes=s,e;case as:return e=Me(19,n,t,l),e.elementType=as,e.lanes=s,e;case Pa:return Nl(n,l,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Ea:o=10;break e;case _a:o=9;break e;case ai:o=11;break e;case ui:o=14;break e;case it:o=16,r=null;break e}throw Error(j(130,e==null?e:typeof e,""))}return t=Me(o,n,t,l),t.elementType=e,t.type=r,t.lanes=s,t}function Dt(e,t,n,r){return e=Me(7,e,r,t),e.lanes=n,e}function Nl(e,t,n,r){return e=Me(22,e,r,t),e.elementType=Pa,e.lanes=n,e.stateNode={isHidden:!1},e}function ns(e,t,n){return e=Me(6,e,null,t),e.lanes=n,e}function rs(e,t,n){return t=Me(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function bf(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Il(0),this.expirationTimes=Il(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Il(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Hi(e,t,n,r,l,s,o,a,u){return e=new bf(e,t,n,a,u),t===1?(t=1,s===!0&&(t|=8)):t=0,s=Me(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},_i(s),e}function ep(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(kc)}catch(e){console.error(e)}}kc(),ka.exports=Pe;var sp=ka.exports,Sc,sa=sp;Sc=sa.createRoot,sa.hydrateRoot;const Nc=()=>{var e,t;return(t=(e=window==null?void 0:window.go)==null?void 0:e.main)==null?void 0:t.App},ip=()=>!!Nc();async function F(e,...t){const n=Nc();if(!n||typeof n[e]!="function")throw new Error(`${e} is unavailable — run this inside the Behavision app`);return n[e](...t)}const I={session:()=>F("Session"),login:(e,t)=>F("Login",e,t),logout:()=>F("Logout"),claim:e=>F("Claim",e),runStandalone:()=>F("RunStandalone"),engineStatus:()=>F("EngineStatus"),startEngine:()=>F("StartEngine"),stopEngine:()=>F("StopEngine"),cameras:()=>F("Cameras"),testCamera:e=>F("TestCamera",e),discoverCameras:()=>F("DiscoverCameras"),saveCamera:(e,t)=>F("SaveCamera",e,t),deleteCamera:e=>F("DeleteCamera",e),startPlacement:(e,t)=>F("StartPlacementCheck",e,t),placementResult:e=>F("PlacementResult",e),streamURL:e=>F("StreamURL",e),remoteStreamURL:e=>F("RemoteStreamURL",e),live:()=>F("Live"),pipelineStatus:()=>F("PipelineStatus"),localIdentities:e=>F("LocalIdentities",e),localSightings:e=>F("LocalSightings",e),footfall:(e,t,n)=>F("Footfall",e,t,n),sites:()=>F("Sites"),visitorHistory:(e,t)=>F("VisitorHistory",e,t),visitorPhoto:e=>F("VisitorPhoto",e),forgetCustomer:e=>F("ForgetCustomer",e),sales:(e,t)=>F("Sales",e,t),customers:(e,t)=>F("Customers",e,t),saveProfile:e=>F("SaveProfile",e),ask:e=>F("Ask",e),recordPurchase:(e,t,n,r)=>F("RecordPurchase",e,t,n,r)};function he(e){return e?typeof e=="string"?e:e.message||String(e):"Something went wrong."}function rt(e,t,n=[]){const[r,l]=N.useState(null),[s,o]=N.useState(null),[a,u]=N.useState(!0),c=N.useRef(!0),p=N.useRef(!1),v=N.useCallback(async()=>{if(!p.current){p.current=!0;try{const h=await e();if(!c.current)return;l(h),o(null)}catch(h){c.current&&o(he(h))}finally{p.current=!1,c.current&&u(!1)}}},n);return N.useEffect(()=>{if(c.current=!0,v(),!t)return()=>{c.current=!1};const h=setInterval(v,t);return()=>{c.current=!1,clearInterval(h)}},[v,t]),{data:r,error:s,loading:a,reload:v}}function op(e){if(!e)return"—";const t=typeof e=="number"?new Date(e*1e3):new Date(e);return isNaN(t)?"—":t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function ia(e){if(!e)return"—";const t=typeof e=="number"?new Date(e*1e3):new Date(e);return isNaN(t)?"—":t.toLocaleDateString([],{day:"numeric",month:"short"})}const ls={width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"};function q({size:e,children:t,...n}){return i.jsx("svg",{...ls,...n,width:e??ls.width,height:e??ls.height,children:t})}const ap=e=>i.jsxs(q,{...e,children:[i.jsx("circle",{cx:"12",cy:"12",r:"3.2"}),i.jsx("path",{d:"M5.6 5.6a9 9 0 0 0 0 12.8M18.4 18.4a9 9 0 0 0 0-12.8"})]}),up=e=>i.jsxs(q,{...e,children:[i.jsx("circle",{cx:"9",cy:"8.5",r:"3.2"}),i.jsx("path",{d:"M2.8 19.5a6.4 6.4 0 0 1 12.4 0"}),i.jsx("path",{d:"M16.5 6.2a3.2 3.2 0 0 1 0 6.1M18 19.5a6 6 0 0 0-1.6-4"})]}),cp=e=>i.jsxs(q,{...e,children:[i.jsx("path",{d:"M3 8.5h3.4L8 6h8l1.6 2.5H21v10.2H3z"}),i.jsx("circle",{cx:"12",cy:"13.2",r:"3.1"})]}),Cc=e=>i.jsxs(q,{...e,children:[i.jsx("circle",{cx:"11",cy:"11",r:"6.4"}),i.jsx("path",{d:"M15.8 15.8 20.5 20.5"})]}),oa=e=>i.jsx(q,{...e,children:i.jsx("path",{d:"M12 5.5v13M5.5 12h13"})}),Gi=e=>i.jsx(q,{...e,children:i.jsx("path",{d:"M6.5 6.5l11 11M17.5 6.5l-11 11"})}),Js=e=>i.jsx(q,{...e,children:i.jsx("path",{d:"M5 12.8l4.4 4.2L19 7"})}),qs=e=>i.jsx(q,{...e,children:i.jsx("path",{d:"M8 5.6v12.8L18.5 12z"})}),dp=e=>i.jsx(q,{...e,children:i.jsx("rect",{x:"7",y:"7",width:"10",height:"10",rx:"1.6"})}),Ee=e=>i.jsxs(q,{...e,children:[i.jsx("path",{d:"M12 4.6 21 19.4H3z"}),i.jsx("path",{d:"M12 10v4.1"}),i.jsx("path",{d:"M12 17.1v.01"})]}),aa=e=>i.jsx(q,{...e,children:i.jsx("path",{d:"M5 19.4v-4.2M10.3 19.4v-7.6M15.7 19.4v-11M21 19.4V4.6"})}),Xi=e=>i.jsx(q,{...e,children:i.jsx("path",{d:"M7.2 18.4a4.2 4.2 0 0 1-.6-8.35A6.2 6.2 0 0 1 18.4 9a4.2 4.2 0 0 1 .3 9.4z"})}),Ec=e=>i.jsxs(q,{...e,children:[i.jsx("path",{d:"M7.2 18.4a4.2 4.2 0 0 1-.6-8.35 6.2 6.2 0 0 1 2-3.2M10.6 5.2A6.2 6.2 0 0 1 18.4 9a4.2 4.2 0 0 1 1.9 7.6"}),i.jsx("path",{d:"M3.6 3.6l16.8 16.8"})]}),fp=e=>i.jsx(q,{...e,children:i.jsx("path",{d:"M12 3.8 19.4 6.6v5.2c0 4.2-3 7.4-7.4 8.4-4.4-1-7.4-4.2-7.4-8.4V6.6z"})}),pp=e=>i.jsxs(q,{...e,children:[i.jsx("path",{d:"M10.2 13.8a3.6 3.6 0 0 0 5.2 0l2.8-2.8a3.7 3.7 0 0 0-5.2-5.2l-1.3 1.3"}),i.jsx("path",{d:"M13.8 10.2a3.6 3.6 0 0 0-5.2 0l-2.8 2.8a3.7 3.7 0 0 0 5.2 5.2l1.3-1.3"})]}),hp=e=>i.jsxs(q,{...e,children:[i.jsx("path",{d:"M14.4 7.6V5.4H4.6v13.2h9.8v-2.2"}),i.jsx("path",{d:"M10 12h9.4M16.4 8.8 19.8 12l-3.4 3.2"})]}),ua=e=>i.jsx(q,{...e,children:i.jsx("path",{d:"M14.6 5.6 8 12l6.6 6.4"})}),mp=e=>i.jsx(q,{...e,children:i.jsx("path",{d:"M9.4 5.6 16 12l-6.6 6.4"})}),_c=e=>i.jsxs(q,{...e,strokeWidth:"1.2",children:[i.jsx("path",{d:"M3 8.5h3.4L8 6h8l1.6 2.5H21v10.2H3z"}),i.jsx("circle",{cx:"12",cy:"13.2",r:"3.1"}),i.jsx("path",{d:"M3.6 3.6l16.8 16.8"})]}),Pc=e=>i.jsxs(q,{...e,strokeWidth:"1.2",children:[i.jsx("circle",{cx:"12",cy:"9",r:"3.4"}),i.jsx("path",{d:"M5.4 20a6.8 6.8 0 0 1 13.2 0"})]}),wt=""+new URL("loyaly-mark-Ch-P3VSF.png",import.meta.url).href;function vp({onDone:e}){const[t,n]=N.useState(""),[r,l]=N.useState(""),[s,o]=N.useState(!1),[a,u]=N.useState(null);async function c(p){p.preventDefault(),o(!0),u(null);try{e(await I.login(t.trim(),r))}catch(v){u(he(v))}finally{o(!1)}}return i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsx("h1",{children:"Behavision"}),i.jsx("p",{className:"lead",children:"Sign in to connect this PC to your store."}),i.jsxs("form",{onSubmit:c,children:[a&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),a]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Email"}),i.jsx("input",{type:"email",value:t,autoComplete:"username",required:!0,autoFocus:!0,onChange:p=>n(p.target.value)})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Password"}),i.jsx("input",{type:"password",value:r,autoComplete:"current-password",required:!0,onChange:p=>l(p.target.value)})]}),i.jsx("button",{className:"btn primary",disabled:s||!t||!r,children:s?"Signing in…":"Sign in"})]}),i.jsx("p",{className:"foot",children:"Signing in downloads this store's recognition models and connects it to your account. Nothing is sent until a camera is set up."})]})})}function ca({onDone:e,onCancel:t}){const[n,r]=N.useState(""),[l,s]=N.useState(null),[o,a]=N.useState(null);async function u(h){h.preventDefault(),s("claim"),a(null);try{e(await I.claim(n))}catch(g){a(he(g))}finally{s(null)}}async function c(){s("alone"),a(null);try{e(await I.runStandalone())}catch(h){a(he(h))}finally{s(null)}}const[p,v]=N.useState(t?"code":null);return p===null?i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box wide",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsx("h1",{children:"Welcome to Behavision"}),i.jsx("p",{className:"lead",children:"This PC will watch your shop’s cameras and recognise returning customers. First, one question: is this shop managed from a head office?"}),i.jsxs("div",{className:"choices",children:[i.jsxs("button",{type:"button",className:"choice",onClick:()=>v("code"),children:[i.jsx(Xi,{size:22}),i.jsx("b",{children:"Yes — I have an installation code"}),i.jsxs("span",{children:["Head office gave you a code like ",i.jsx("em",{children:"ABCDEF-123456-…"}),". This PC joins that shop and gets its cameras from there."]})]}),i.jsxs("button",{type:"button",className:"choice",onClick:()=>v("alone"),children:[i.jsx(fp,{size:22}),i.jsx("b",{children:"No — set up on this PC only"}),i.jsx("span",{children:"Cameras, customers and recognition stay on this PC. Nothing is sent anywhere. You can link to a head office later."})]})]})]})}):p==="alone"?i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsx("h1",{children:"On this PC only"}),i.jsx("p",{className:"lead",children:"Behavision will run entirely here. Next you’ll add your camera — it can find it on the network for you — and walk past it once so it can prove it works."}),o&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),o]}),i.jsx("button",{type:"button",className:"btn primary",disabled:!!l,onClick:c,children:l==="alone"?"Setting up…":"Continue"}),i.jsx("div",{className:"alt",children:i.jsxs("button",{type:"button",className:"linkbtn",onClick:()=>v(null),children:[i.jsx(ua,{size:14})," Back"]})})]})}):i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsx("h1",{children:t?"Link to head office":"Join your shop"}),i.jsx("p",{className:"lead",children:"Type the installation code head office gave you. It works once, and this PC becomes that shop."}),i.jsxs("form",{onSubmit:u,children:[o&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),o]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Installation code"}),i.jsx("input",{value:n,autoFocus:!0,required:!0,placeholder:"ABCDEF-123456-GHIJKL-789012",autoComplete:"off",spellCheck:"false",style:{textTransform:"uppercase",letterSpacing:".06em"},onChange:h=>r(h.target.value)})]}),i.jsx("button",{className:"btn primary",disabled:!!l||n.trim().length<6,children:l==="claim"?"Linking…":"Link this PC"})]}),i.jsxs("p",{className:"foot",children:["Don’t have one? Whoever runs head office creates it under the shop: ",i.jsx("em",{children:"Shops → the shop → Set up a shop PC"}),"."]}),i.jsx("div",{className:"alt",children:t?i.jsx("button",{type:"button",className:"linkbtn",onClick:t,children:"Not now — go back"}):i.jsxs("button",{type:"button",className:"linkbtn",onClick:()=>v(null),children:[i.jsx(ua,{size:14})," Back"]})})]})})}function zc({onNavigate:e}){var h,g,x,y;const{data:t,error:n}=rt(()=>I.live(),3e3),{data:r}=rt(()=>I.pipelineStatus(),5e3),l=((h=t==null?void 0:t.stats)==null?void 0:h.cameras)??[],s=((g=t==null?void 0:t.stats)==null?void 0:g.gallery)??{},o=(t==null?void 0:t.events)??[],a=(t==null?void 0:t.viewing)===!0,u=a?((x=t==null?void 0:t.stats)==null?void 0:x.fraction_below_gate)??0:l.reduce((z,f)=>{var m,w;const d=(w=(m=f==null?void 0:f.pipeline)==null?void 0:m.best_quality)==null?void 0:w.fraction_below_gate;return typeof d=="number"&&d>z?d:z},0),c=a?((y=t==null?void 0:t.stats)==null?void 0:y.cameras_up)??0:l.filter(z=>z.connected).length,p=o.filter(z=>z.type==="person.new"||z.type==="person.seen"),v=jp(p[0]);return i.jsxs("div",{className:"page",children:[i.jsxs("header",{children:[i.jsx("h2",{children:"Live"}),i.jsx("p",{children:a?"Your shops, as head office sees them.":"Who is in the shop, and whether it is reaching head office."})]}),n&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),n]}),a&&i.jsxs("div",{className:"viewing",children:[i.jsx(Xi,{size:15}),i.jsxs("span",{children:[i.jsx("b",{children:"Viewing your shops from here."})," This computer is not watching any cameras itself — everything below is what your shop PCs reported. To recognise people on this machine, it has to be on the same network as a camera."]})]}),i.jsx(wp,{pipe:r,cameras:l,up:c}),!a&&i.jsx(gp,{cameras:l,arrivals:p,onNavigate:e}),i.jsxs("div",{className:"panel arrivals-panel",children:[i.jsxs("div",{className:"panelhead",children:[i.jsx("h3",{children:"Who just walked in"}),p.length>0&&i.jsxs("span",{className:"note",children:[p.length," today"]})]}),i.jsx("div",{className:"panelbody flush",children:p.length===0?i.jsxs("div",{className:"empty",children:[i.jsx(Pc,{size:34}),i.jsx("b",{children:"Nobody yet"}),i.jsx("p",{children:"Customers appear here the moment a camera recognises a face."})]}):i.jsx("div",{className:"arrivals",children:p.slice(0,30).map((z,f)=>i.jsx(yp,{e:z,fresh:f===0&&v},`${z.ts}-${f}`))})})]}),i.jsxs("div",{className:"metrics",style:{marginTop:"var(--sp-4)"},children:[i.jsx(Pr,{k:"People known",v:s.identities??"—"}),i.jsx(Pr,{k:"Sightings",v:s.sightings??"—"}),i.jsx(Pr,{k:"Cameras live",v:l.length?`${c}/${l.length}`:"—",tone:l.length?c===0?"bad":c.5?"bad":u>.2?"warn":"ok",s:u>.5?"Most visitors are being missed — move the camera":"Share of faces below the enrolment gate"})]})]})}function gp({cameras:e,arrivals:t,onNavigate:n}){const{data:r}=rt(()=>I.engineStatus(),4e3),[l,s]=N.useState(()=>{try{return localStorage.getItem("bv.gettingStarted")==="done"}catch{return!1}}),o=e.length>0,a=e.some(x=>x.connected),{data:u}=rt(async()=>{const x={};for(const y of e)try{x[y.camera_id]=await I.placementResult(y.camera_id)}catch{}return x},1e4,[e.map(x=>x.camera_id).join("|")]),c=Object.values(u??{}).some(x=>x&&!x.running&&x.verdict==="good"),p=t.length>0;if(l||p)return null;const v=!!(r!=null&&r.reachable&&(r!=null&&r.recognition_model)),h=r==null?void 0:r.progress,g=[{done:v,now:!v,title:v?`Recognition ready (${r.recognition_model})`:h?`Downloading ${h.what}… ${h.percent}%`:"Starting recognition…",text:v?null:"First start downloads about 275 MB of recognition models. A few minutes on a normal connection; nothing to do meanwhile."},{done:o&&a,now:v&&!(o&&a),title:o?a?"Camera connected":"Camera added — not connecting yet":"Add your camera",text:o?a?null:"Check its password and stream path under Cameras → Edit.":"Behavision can find it on the network; you type only its password.",action:o?null:{label:"Add camera",go:"cameras"}},{done:c,now:o&&a&&!c,title:c?"Camera proven — it can recognise faces":"Walk past the camera",text:c?null:"Run Check placement and walk past like a customer for 25 seconds. Only a “good” verdict means it will recognise people.",action:o&&a&&!c?{label:"Check placement",go:"cameras"}:null}];return i.jsxs("section",{className:"panel starter",children:[i.jsxs("div",{className:"panelhead",children:[i.jsx("h3",{children:"Getting started"}),i.jsx("button",{className:"btn sm ghost",onClick:()=>{try{localStorage.setItem("bv.gettingStarted","done")}catch{}s(!0)},children:"Hide"})]}),i.jsx("ol",{className:"steps compact",children:g.map((x,y)=>i.jsxs("li",{className:x.done?"done":x.now?"now":"",children:[i.jsx("b",{children:x.title}),x.text&&i.jsx("span",{children:x.text}),x.action&&i.jsx("button",{className:"btn sm primary",onClick:()=>n==null?void 0:n(x.action.go),children:x.action.label})]},y))}),i.jsx("p",{className:"note",children:"The moment a customer is recognised, this list goes away."})]})}function yp({e,fresh:t}){var o,a,u,c,p,v;const n=e.type==="person.new",r=((o=e.data)==null?void 0:o.label)||"Unrecognised",l=[(a=e.data)==null?void 0:a.gender,((u=e.data)==null?void 0:u.age)??((c=e.data)==null?void 0:c.age_range),(p=e.data)==null?void 0:p.emotion].filter(Boolean),s=typeof((v=e.data)==null?void 0:v.similarity)=="number"?e.data.similarity:null;return i.jsxs("article",{className:`arrival ${n?"is-new":"is-seen"} ${t?"fresh":""}`,children:[i.jsx("div",{className:"avatar",children:xp(r)}),i.jsxs("div",{className:"who",children:[i.jsx("div",{className:"name",children:r}),i.jsxs("div",{className:"meta",children:[e.camera_id,l.length>0&&i.jsxs(i.Fragment,{children:[" · ",l.join(", ")]}),s!==null&&!n&&i.jsxs(i.Fragment,{children:[" · match ",s.toFixed(2)]})]})]}),i.jsxs("div",{className:"right",children:[i.jsx("span",{className:`tag ${n?"new":"seen"}`,children:n?"new":"returning"}),i.jsx("span",{className:"when",children:op(e.ts)})]})]})}function xp(e){var r;const t=/^Visitor (\d+)$/.exec(String(e).trim());if(t)return t[1];const n=String(e).trim().split(/\s+/).filter(Boolean);return n.length?(n[0][0]+(((r=n[1])==null?void 0:r[0])??"")).toUpperCase():"?"}function wp({pipe:e,cameras:t,up:n}){if(!e)return null;if(e.standalone)return i.jsxs("div",{className:"statusbar",children:[i.jsxs("span",{className:"item",children:[i.jsx("i",{className:"dot ok"}),i.jsx("b",{children:"Running on this PC only"})]}),i.jsx("span",{className:"sep"}),i.jsx("span",{className:"item note",children:"Recognition and customers stay here."}),i.jsx("span",{className:"grow"}),i.jsxs("span",{className:"item note",children:[i.jsx(aa,{size:14}),n," of ",t.length," cameras"]})]});const r=e.claimed&&!e.broker_up,l=e.claimed?e.broker_up?"ok":"bad":"idle",s=e.claimed?e.broker_up?"Sending to head office":"Offline — saving locally":"Not linked to head office";return i.jsxs("div",{className:"statusbar",children:[i.jsxs("span",{className:"item",children:[e.broker_up?i.jsx(Xi,{size:15}):i.jsx(Ec,{size:15}),i.jsx("i",{className:`dot ${l}`}),i.jsx("b",{children:s})]}),i.jsx("span",{className:"sep"}),i.jsxs("span",{className:"item note",children:[e.accepted," recorded today"]}),e.queued>0&&i.jsxs("span",{className:`item note ${r?"warn":""}`,children:[e.queued," waiting to send"]}),e.dropped>0&&i.jsxs("span",{className:"item note bad",children:[i.jsx(Ee,{size:14}),e.dropped," lost — this PC was offline too long"]}),i.jsx("span",{className:"grow"}),i.jsxs("span",{className:"item note",children:[i.jsx(aa,{size:14}),n," of ",t.length," cameras"]})]})}function Pr({k:e,v:t,s:n,tone:r}){return i.jsxs("div",{className:`metric ${r??""}`,children:[i.jsx("div",{className:"metric-k",children:e}),i.jsx("div",{className:"metric-v",children:t}),n&&i.jsx("div",{className:"metric-s",children:n})]})}function jp(e){const[t,n]=N.useState(!1),r=N.useRef(null);return N.useEffect(()=>{if(!e||e.ts===r.current)return;const l=r.current===null;if(r.current=e.ts,l)return;n(!0);const s=setTimeout(()=>n(!1),1200);return()=>clearTimeout(s)},[e==null?void 0:e.ts]),t}function kp(e){const[t,n]=N.useState(null);return N.useEffect(()=>{let r=!0;return n(null),I.visitorPhoto(e).then(l=>{r&&n(l)}).catch(()=>{r&&n({available:!1,reason:""})}),()=>{r=!1}},[e]),t}function Sp({photo:e,name:t,customerRef:n,onBroken:r}){return e!=null&&e.available?i.jsx("img",{className:"avatar",src:e.url,alt:`Photo of ${t}`,onError:r}):i.jsx("div",{className:"avatar none",role:"img","aria-label":`No photo of ${t}`,children:i.jsx("span",{children:Np(t,n)})})}function Np(e,t){const n=/^Visitor (\d+)$/.exec(String(e||"").trim());if(n)return n[1];const r=/^V-(\d+)$/.exec(String(t||""));return r?r[1]:String(e||"").split(/\s+/).filter(Boolean).slice(0,2).map(l=>l[0].toUpperCase()).join("")||"?"}function Cp({customer:e}){const{data:t,error:n,loading:r}=rt(()=>I.visitorHistory(e.id,50),0,[e.id]);if(r)return i.jsx("p",{className:"note",children:"Loading visits…"});if(n)return i.jsxs("p",{className:"note",children:["Could not load visits: ",n]});const l=t??[];return l.length===0?i.jsx("p",{className:"note",children:"No recorded visits yet."}):i.jsx("ul",{className:"timeline",children:l.map(s=>i.jsxs("li",{children:[i.jsx("span",{className:"when",children:Ep(s.occurred_at)}),i.jsxs("span",{className:"where",children:[s.site||"this store",s.camera_id?i.jsxs("span",{className:"note",children:[" · ",s.camera_id]}):null]}),s.is_new_visitor&&i.jsx("span",{className:"tag new",children:"first visit"})]},s.id))})}function Ep(e){const t=new Date(e);return isNaN(t)?"—":t.toLocaleString([],{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})}function _p({customer:e,onCancel:t,onDone:n}){const r=e.full_name||e.label,[l,s]=N.useState(""),[o,a]=N.useState(!1),[u,c]=N.useState(null),p=l.trim().toLowerCase()===r.trim().toLowerCase();async function v(){a(!0),c(null);try{await I.forgetCustomer(e.id),n()}catch(h){c(he(h)),a(!1)}}return i.jsxs("div",{className:"confirm",children:[i.jsxs("h4",{children:["Erase ",r,"?"]}),i.jsxs("div",{className:"cols",children:[i.jsxs("div",{children:[i.jsx("p",{className:"lbl bad",children:"Deleted for good"}),i.jsxs("ul",{children:[i.jsx("li",{children:"Their face data — they will not be recognised again"}),i.jsx("li",{children:"Their photo"}),i.jsx("li",{children:"Their name, phone, email and notes"})]})]}),i.jsxs("div",{children:[i.jsx("p",{className:"lbl",children:"Kept"}),i.jsxs("ul",{children:[i.jsx("li",{children:"Past visits, with their name removed — your footfall figures do not change"}),i.jsx("li",{children:"The consent record, marked withdrawn, as proof of what was agreed"})]})]})]}),i.jsx("p",{className:"note",children:"This cannot be undone. If they come back they will be recorded as a new customer."}),u&&i.jsx("div",{className:"err",children:u}),i.jsxs("label",{className:"field",children:[i.jsxs("span",{children:["Type ",i.jsx("b",{children:r})," to confirm"]}),i.jsx("input",{value:l,onChange:h=>s(h.target.value),autoFocus:!0,autoComplete:"off",spellCheck:"false","aria-label":`Type ${r} to confirm erasure`})]}),i.jsxs("div",{className:"row",children:[i.jsx("button",{type:"button",className:"btn danger",disabled:!p||o,onClick:v,children:o?"Erasing…":"Erase permanently"}),i.jsx("button",{type:"button",className:"btn",onClick:t,disabled:o,children:"Cancel"})]})]})}function Pp({customer:e,session:t,onClose:n,onSaved:r}){var P;const[l,s]=N.useState({full_name:e.full_name??"",phone:e.phone??"",email:e.email??"",gender:"",date_of_birth:"",notes:"",consent:e.has_consent??!1}),[o,a]=N.useState({amount:"",items:"",notes:""}),[u,c]=N.useState(!1),[p,v]=N.useState(null),[h,g]=N.useState(!1),[x,y]=N.useState(null),z=kp(e.id),f=x??z,d=(P=t==null?void 0:t.user)==null?void 0:P.role,m=["admin","owner","manager"].includes(d),w=k=>E=>s({...l,[k]:E.target.value});async function S(k){k.preventDefault(),c(!0),v(null);try{await I.saveProfile({visitor_id:e.id,...l});const E=parseFloat(o.amount);if(!isNaN(E)&&E>0){const U=o.items.split(",").map(M=>M.trim()).filter(Boolean);await I.recordPurchase(e.id,E,U,o.notes)}r()}catch(E){v(he(E))}finally{c(!1)}}return i.jsx("div",{className:"drawer",onMouseDown:k=>k.target===k.currentTarget&&n(),children:i.jsxs("div",{className:"sheet",children:[i.jsxs("div",{className:"sheethead who",children:[i.jsx(Sp,{photo:f,name:e.full_name||e.label,customerRef:e.ref,onBroken:()=>y({available:!1,reason:"The photo could not be loaded."})}),i.jsxs("div",{className:"grow",children:[i.jsx("h2",{children:e.full_name||e.label}),i.jsxs("p",{className:"note",children:[e.visit_count," visit",e.visit_count===1?"":"s",e.last_seen_at&&` · last seen ${new Date(e.last_seen_at).toLocaleDateString()}`,f&&!f.available&&f.reason&&` · ${f.reason}`]})]}),i.jsx("button",{type:"button",className:"close",onClick:n,"aria-label":"Close",children:"✕"})]}),i.jsxs("form",{className:"sheetbody",onSubmit:S,children:[p&&i.jsx("div",{className:"err",children:p}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Customer details"}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Full name"}),i.jsx("input",{value:l.full_name,onChange:w("full_name"),autoFocus:!0})]}),i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Phone"}),i.jsx("input",{value:l.phone,onChange:w("phone"),inputMode:"tel"})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Email"}),i.jsx("input",{value:l.email,onChange:w("email"),type:"email"})]})]}),i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Gender"}),i.jsxs("select",{value:l.gender,onChange:w("gender"),children:[i.jsx("option",{value:"",children:"Not recorded"}),i.jsx("option",{children:"Female"}),i.jsx("option",{children:"Male"}),i.jsx("option",{children:"Other"})]})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Date of birth"}),i.jsx("input",{type:"date",value:l.date_of_birth,onChange:w("date_of_birth")})]})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Notes"}),i.jsx("textarea",{value:l.notes,onChange:w("notes"),placeholder:"Preferences, sizes, anything worth remembering"})]})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Purchase (optional)"}),i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Amount"}),i.jsx("input",{value:o.amount,inputMode:"decimal",placeholder:"0.00",onChange:k=>a({...o,amount:k.target.value})})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Items"}),i.jsx("input",{value:o.items,placeholder:"shirt, belt",onChange:k=>a({...o,items:k.target.value})})]})]}),i.jsx("p",{className:"note",children:"Leave the amount blank if they did not buy anything — a visit without a sale is still worth recording."})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Consent"}),i.jsxs("label",{style:{display:"flex",gap:10,alignItems:"flex-start",fontSize:13,cursor:"pointer"},children:[i.jsx("input",{type:"checkbox",checked:l.consent,style:{marginTop:3},onChange:k=>s({...l,consent:k.target.checked})}),i.jsx("span",{children:"This customer agreed to us keeping their details and recognising them on future visits."})]}),i.jsx("p",{className:"note",style:{marginTop:10},children:"Recorded with the date and who collected it. They can withdraw it at any time, which erases their face data."})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Visits"}),i.jsx(Cp,{customer:e})]}),i.jsxs("div",{className:"sheetactions",children:[i.jsx("button",{type:"button",className:"btn",onClick:n,children:"Cancel"}),i.jsx("button",{className:"btn primary",disabled:u,children:u?"Saving…":"Save"})]}),m&&i.jsxs("section",{className:"formsection dangerzone",children:[i.jsx("h4",{children:"At the customer's request"}),h?i.jsx(_p,{customer:e,onCancel:()=>g(!1),onDone:r}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"note",children:"Erase this person's face data, photo and details. Their past visits stay in your footfall figures, without their name."}),i.jsx("button",{type:"button",className:"btn danger",onClick:()=>g(!0),children:"Erase this customer…"})]})]})]})]})})}function zp({session:e}){const[t,n]=N.useState(""),[r,l]=N.useState(null),{data:s,error:o,reload:a}=rt(()=>I.customers(t,200),3e4,[t]),u=s??[],c=u.filter(p=>p.has_profile).length;return i.jsxs("div",{className:"page",children:[i.jsxs("header",{className:"pagehead",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Customers"}),i.jsx("p",{children:"Everyone this business has recognised. Fill in details once and they are known at every store."})]}),i.jsxs("label",{className:"search",children:[i.jsx(Cc,{size:15}),i.jsx("input",{placeholder:"Search by name or phone",value:t,onChange:p=>n(p.target.value)})]})]}),o&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),o]}),i.jsxs("div",{className:"metrics",style:{marginBottom:"var(--sp-4)"},children:[i.jsx(zr,{k:"Known people",v:u.length||"—"}),i.jsx(zr,{k:"With details",v:c||"—",s:u.length?`${Math.round(100*c/u.length)}% captured`:null}),i.jsx(zr,{k:"Returning",v:u.filter(p=>p.visit_count>1).length||"—"}),i.jsx(zr,{k:"With consent",v:u.filter(p=>p.has_consent).length||"—"})]}),i.jsx("div",{className:"panel",children:u.length===0?i.jsxs("div",{className:"empty tall",children:[i.jsx(Pc,{size:34}),i.jsx("b",{children:"No customers yet"}),i.jsx("p",{children:"They appear here the first time a camera recognises them. Click one to add a name and phone number."})]}):i.jsx("div",{className:"tablewrap",children:i.jsxs("table",{children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Customer"}),i.jsx("th",{children:"Phone"}),i.jsx("th",{className:"num",children:"Visits"}),i.jsx("th",{children:"First seen"}),i.jsx("th",{children:"Last seen"}),i.jsx("th",{children:"Details"})]})}),i.jsx("tbody",{children:u.map(p=>i.jsxs("tr",{className:"click",onClick:()=>l(p),children:[i.jsxs("td",{children:[p.full_name||i.jsx("span",{className:"note",children:p.label}),p.full_name&&p.ref&&i.jsxs("span",{className:"note",children:[" · ",p.ref]})]}),i.jsx("td",{className:"mono",children:p.phone||"—"}),i.jsx("td",{className:"num",children:p.visit_count}),i.jsx("td",{children:ia(p.first_seen_at)}),i.jsx("td",{children:ia(p.last_seen_at)}),i.jsx("td",{children:p.has_profile?i.jsxs("span",{className:"pill ok",children:[i.jsx("i",{className:"dot ok"}),"captured"]}):i.jsxs("span",{className:"pill warn",children:[i.jsx("i",{className:"dot warn"}),"needed"]})})]},p.id))})]})})}),r&&i.jsx(Pp,{customer:r,session:e,onClose:()=>l(null),onSaved:()=>{l(null),a()}})]})}function zr({k:e,v:t,s:n}){return i.jsxs("div",{className:"metric",children:[i.jsx("div",{className:"metric-k",children:e}),i.jsx("div",{className:"metric-v",children:t}),n&&i.jsx("div",{className:"metric-s",children:n})]})}const an=[{id:"hikvision",label:"Hikvision",path:"/Streaming/Channels/101",note:"Channel 1, main stream. Use /Streaming/Channels/102 for the lower-quality sub stream."},{id:"dahua",label:"Dahua",path:"/cam/realmonitor?channel=1&subtype=0",note:"Channel 1, main stream. subtype=1 is the sub stream."},{id:"cpplus",label:"CP Plus",path:"/cam/realmonitor?channel=1&subtype=0",note:"CP Plus cameras use the Dahua stream path."},{id:"uniview",label:"Uniview",path:"/media/video1",note:"Some older Uniview models use /video1 instead."},{id:"tplink",label:"TP-Link / Tapo",path:"/stream1",note:"Tapo cameras need a separate camera account created in the Tapo app — your Tapo login will not work."},{id:"reolink",label:"Reolink",path:"/h264Preview_01_main",note:"Use /h264Preview_01_sub for the lower-quality stream."},{id:"amcrest",label:"Amcrest",path:"/cam/realmonitor?channel=1&subtype=0",note:"Amcrest cameras use the Dahua stream path."},{id:"axis",label:"Axis",path:"/axis-media/media.amp",note:""},{id:"onvif",label:"Other (ONVIF)",path:"/onvif1",note:"Many generic cameras answer here. If it does not work, look for “RTSP” in the camera’s own app."},{id:"manual",label:"I know the path",path:"",note:""}],Lr=e=>an.find(t=>t.id===e)||an[an.length-1],bs={id:"",host:"",port:554,path:"",username:"",password:"",max_width:1280},_n="webcam";function Lp(){const{data:e,error:t,reload:n}=rt(()=>I.cameras(),8e3),[r,l]=N.useState(null),[s,o]=N.useState(null),a=e??[],u=a.some(y=>y.remote),c=Mp(u?[]:a),[p,v]=N.useState(null),[h,g]=N.useState("");N.useEffect(()=>{let y=!0;if(!p){g("");return}return I.remoteStreamURL(p).then(z=>{y&&g(z||"")}).catch(()=>{y&&g("")}),()=>{y=!1}},[p]);async function x(y){if(confirm(`Remove ${y.id}? Recognition from it stops immediately.`))try{await I.deleteCamera(y.id),n()}catch(z){alert(he(z))}}return i.jsxs("div",{className:"page",children:[i.jsxs("header",{className:"pagehead",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Cameras"}),i.jsx("p",{children:u?"The cameras across your shops, as the shop computers last reported them.":"Add a camera, then prove it can see faces with a walk-past. Only then is it working."})]}),!u&&i.jsxs("button",{className:"btn primary",onClick:()=>l({...bs}),children:[i.jsx(oa,{size:15}),"Add camera"]})]}),u&&i.jsxs("div",{className:"viewing",children:[i.jsx("b",{children:"Viewing your shops from here."})," These cameras are wired to the shop computers, so they are set up and checked there. Each tile shows that camera's most recent frame; ",i.jsx("b",{children:"Watch live"})," asks the shop computer to send video for as long as you are looking."]}),t&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),t]}),a.length===0?i.jsx("div",{className:"panel",children:i.jsxs("div",{className:"empty tall",children:[i.jsx(_c,{size:40}),i.jsx("b",{children:"No cameras yet"}),i.jsx("p",{children:"Add the camera by its address. Most cameras print it on a label underneath, or show it in their own app."}),i.jsxs("button",{className:"btn primary",onClick:()=>l({...bs}),children:[i.jsx(oa,{size:15}),"Add your first camera"]})]})}):i.jsx("div",{className:"camgrid",children:a.map(y=>i.jsx(Tp,{cam:y,stream:p===y.id?h:c[y.id],watching:p===y.id,onWatch:()=>v(p===y.id?null:y.id),onEdit:()=>l(y),onCheck:()=>o(y.id),onRemove:()=>x(y)},y.id))}),r&&i.jsx(Rp,{cam:r,onClose:()=>l(null),onSaved:()=>{l(null),n()}}),s&&i.jsx(Dp,{id:s,onClose:()=>o(null)})]})}function Tp({cam:e,stream:t,watching:n,onWatch:r,onEdit:l,onCheck:s,onRemove:o}){var v,h,g;const a=e.remote?{connected:{tone:"ok",label:"Connected"},not_connecting:{tone:"bad",label:"Not connecting"},stale:{tone:"warn",label:"Not reporting"}}[e.state]||{tone:"idle",label:"Waiting for the shop computer"}:e.connected===void 0||e.connected===null?{tone:"idle",label:"Engine stopped"}:e.connected?{tone:"ok",label:"Connected"}:{tone:"bad",label:"Not connecting"},{data:u}=rt(()=>e.remote?Promise.resolve(null):I.placementResult(e.id),15e3,[e.id]),c=!u||u.running||!u.verdict||u.verdict==="starting"?{tone:"miss",label:"Not yet proven",text:"Walk past it once and Behavision will tell you if the placement works."}:u.verdict==="good"?{tone:"seen",label:"Proven",text:u.headline||"Faces recognised on a walk-past."}:{tone:"miss",label:"Not proven",text:u.headline||"Move the camera and check again."},p=(v=e.snapshot)!=null&&v.available?e.snapshot.url:"";return i.jsxs("article",{className:"camcard",children:[i.jsxs("div",{className:"camview",children:[t||p?i.jsx("img",{src:t||p,alt:e.id}):i.jsx("div",{className:"placeholder",children:i.jsx(_c,{size:34})}),i.jsxs("span",{className:`pill ${a.tone==="idle"?"":a.tone} over`,children:[i.jsx("i",{className:`dot ${a.tone}`}),a.label]}),e.remote&&i.jsxs("button",{className:`btn sm watch ${n?"on":""}`,onClick:r,children:[i.jsx(qs,{size:13}),n?"Stop watching":"Watch live"]})]}),i.jsxs("div",{className:"cambody",children:[i.jsxs("div",{className:"camtitle",children:[i.jsxs("div",{children:[i.jsx("h3",{children:e.label||e.camera_id||e.id}),i.jsx("span",{className:"mono note",children:e.remote?e.site||e.site_slug||"":`${e.host||e.url}${e.path?` · ${e.path}`:""}`})]}),!e.remote&&i.jsxs("div",{className:"camactions",children:[i.jsx("button",{className:"btn sm",onClick:l,children:"Edit"}),i.jsx("button",{className:"btn sm danger",onClick:o,children:"Remove"})]})]}),e.remote?i.jsx("div",{className:"camproof",children:i.jsx("span",{className:"note",children:e.state_note?e.state_note:n?"Live from the shop computer. It uploads only while you watch.":(h=e.snapshot)!=null&&h.available?"Last picture from the shop computer. Watch live to see it now.":((g=e.snapshot)==null?void 0:g.reason)||"No picture yet from the shop computer."})}):i.jsxs("div",{className:"camproof",children:[i.jsx("span",{className:`tag ${c.tone}`,children:c.label}),i.jsx("span",{className:"note",children:c.text}),i.jsxs("button",{className:`btn sm ${c.tone==="seen"?"":"primary"}`,onClick:s,children:[i.jsx(qs,{size:13}),c.tone==="seen"?"Check again":"Check placement"]})]})]})]})}function Mp(e){const[t,n]=N.useState({});return N.useEffect(()=>{let r=!0;const l=e.filter(s=>!(s.id in t));if(l.length)return(async()=>{const s={};for(const o of l)try{s[o.id]=await I.streamURL(o.id)}catch{s[o.id]=""}r&&n(o=>({...o,...s}))})(),()=>{r=!1}},[e.map(r=>r.id).join("|")]),t}function Rp({cam:e,onClose:t,onSaved:n}){var ge;const r=!e.id,[l,s]=N.useState({...bs,...e,password:"",path:e.path||(r?an[0].path:"")}),[o,a]=N.useState(r?an[0].id:e.webcam!=null?_n:"manual"),[u,c]=N.useState(e.webcam!=null?String(e.webcam):"0"),p=o===_n,[v,h]=N.useState(null),[g,x]=N.useState(null),[y,z]=N.useState(null),f=L=>B=>s({...l,[L]:B.target.value});function d(L){if(L.target.value===_n){a(_n),h(null);return}const B=Lr(L.target.value);a(B.id),s(de=>({...de,path:B.path||de.path}))}function m(){const L={};for(const[B,de]of Object.entries(l))de===""||de===null||de===void 0||(L[B]=B==="port"||B==="max_width"?Number(de):de);if(p){for(const B of["host","path","username","password"])delete L[B];L.webcam=Number(u)||0}return L}async function w(){x("test"),z(null),h(null);try{h(await I.testCamera(m()))}catch(L){z(he(L))}finally{x(null)}}async function S(L){L.preventDefault(),x("save"),z(null);try{await I.saveCamera(r?"":e.id,m()),n()}catch(B){z(he(B))}finally{x(null)}}const P=Lr(o),[k,E]=N.useState(null);async function U(){E("busy");try{E(await I.discoverCameras())}catch(L){E({error:he(L)})}}function M(L){const B=L.make?Lr(L.make):null;s(de=>({...de,host:L.host,path:(B==null?void 0:B.path)||de.path,id:de.id||""})),B&&a(B.id),h(null)}return i.jsx("div",{className:"drawer",onMouseDown:L=>L.target===L.currentTarget&&t(),children:i.jsxs("div",{className:"sheet",children:[i.jsxs("div",{className:"sheethead",children:[i.jsx("h2",{children:r?"Add a camera":`Edit ${e.id}`}),i.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:i.jsx(Gi,{size:16})})]}),i.jsxs("form",{className:"sheetbody",onSubmit:S,autoComplete:"off",children:[i.jsx("p",{className:"lead",children:"Three things from the camera: its address, its make, and its password. Test before you save — a wrong address is the most common mistake."}),y&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),y]}),r&&!p&&i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Find it"}),k===null&&i.jsxs("div",{className:"finder",children:[i.jsx("p",{children:"Behavision can look for cameras on this shop’s network."}),i.jsxs("button",{type:"button",className:"btn primary",onClick:U,children:[i.jsx(Cc,{size:14}),"Find cameras on this network"]})]}),k==="busy"&&i.jsxs("div",{className:"finder busy",children:[i.jsx("span",{className:"spinner"}),"Looking on the network… a few seconds."]}),(k==null?void 0:k.error)&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),k.error]}),(k==null?void 0:k.cameras)&&(k.cameras.length===0?i.jsxs("div",{className:"finder",children:[i.jsxs("p",{children:["Nothing answered on ",((ge=k.networks)==null?void 0:ge.join(", "))||"this network",". The camera may be on a different network, switched off, or not yet connected — check its cable and power, then try again. You can still type its address below."]}),i.jsx("button",{type:"button",className:"btn",onClick:U,children:"Try again"})]}):i.jsxs("ul",{className:"foundlist",children:[k.cameras.map(L=>i.jsx("li",{className:l.host===L.host?"picked":"",children:i.jsxs("button",{type:"button",onClick:()=>M(L),children:[i.jsx("span",{className:"mono",children:L.host}),i.jsx("span",{className:"what",children:L.name||(L.rtsp?"Streams video (RTSP)":"Answers ONVIF")}),L.make&&i.jsx("span",{className:"tag seen",children:Lr(L.make).label}),l.host===L.host&&i.jsx(Js,{size:16})]})},L.host)),i.jsx("li",{className:"rescan",children:i.jsx("button",{type:"button",className:"btn sm",onClick:U,children:"Scan again"})})]}))]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"The camera"}),r&&i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Name"}),i.jsx("input",{value:l.id,onChange:f("id"),placeholder:"entrance",required:!0,autoFocus:!0}),i.jsx("em",{className:"hint",children:"Short, no spaces. It names this camera everywhere and cannot be changed later."})]}),p?i.jsxs("label",{className:"field narrow",children:[i.jsx("span",{children:"Camera number"}),i.jsx("input",{value:u,onChange:L=>{c(L.target.value),h(null)},inputMode:"numeric"}),i.jsx("em",{className:"hint",children:"0 is the built-in camera. Try 1 if a second one is plugged in."})]}):i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Address"}),i.jsx("input",{value:l.host,onChange:f("host"),placeholder:"192.168.1.20",inputMode:"decimal"}),i.jsx("em",{className:"hint",children:"On a label on the camera, or in its own app under “network”."})]}),i.jsxs("label",{className:"field narrow",children:[i.jsx("span",{children:"Port"}),i.jsx("input",{value:l.port,onChange:f("port"),inputMode:"numeric"})]})]})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"The stream"}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Make of camera"}),i.jsxs("select",{value:o,onChange:d,children:[an.map(L=>i.jsx("option",{value:L.id,children:L.label},L.id)),i.jsx("option",{value:_n,children:"This computer’s own camera"})]}),p?i.jsx("em",{className:"hint",children:"Recognition runs on this computer’s built-in or plugged-in camera. Nothing on the network is involved."}):P.note&&i.jsx("em",{className:"hint",children:P.note})]}),!p&&i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Stream path"}),i.jsx("input",{className:"mono",value:l.path,onChange:f("path"),placeholder:"/Streaming/Channels/101"}),i.jsx("em",{className:"hint",children:"Filled in from the make. Change it only if the camera’s own app says something else."})]})]}),!p&&i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Sign-in to the camera"}),i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Username"}),i.jsx("input",{name:"rtsp-account",autoComplete:"off",value:l.username,onChange:f("username"),placeholder:"admin"})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Password"}),i.jsx("input",{type:"password",name:"rtsp-secret",autoComplete:"new-password",value:l.password,onChange:f("password"),placeholder:e.has_password?"(unchanged)":""})]})]})]}),v&&(v.ok?i.jsxs("div",{className:"testresult ok",children:[i.jsx(Js,{size:16}),i.jsxs("div",{children:[i.jsxs("b",{children:["Connected — ",v.width,"×",v.height,v.codec?` · ${String(v.codec).toUpperCase()}`:""]}),v.snapshot&&i.jsx("img",{alt:"Camera preview",src:`data:image/jpeg;base64,${v.snapshot}`})]})]}):i.jsxs("div",{className:"testresult bad",children:[i.jsx(Ee,{size:16}),i.jsxs("div",{children:[i.jsx("b",{children:"Could not connect"}),i.jsx("span",{children:v.error})]})]})),i.jsxs("div",{className:"sheetactions",children:[i.jsx("button",{type:"button",className:"btn",onClick:w,disabled:!!g||!l.host,children:g==="test"?"Connecting…":"Test connection"}),i.jsx("button",{className:"btn primary",disabled:!!g||!l.id||!l.host,children:g==="save"?"Saving…":r?"Add camera":"Save changes"})]})]})]})})}function Dp({id:e,onClose:t}){var p,v;const[n,r]=N.useState({verdict:"starting",advice:[]}),[l,s]=N.useState(null),o=N.useRef(null);N.useEffect(()=>{let h=!0;return(async()=>{try{r(await I.startPlacement(e,25)),o.current=setInterval(async()=>{try{const g=await I.placementResult(e);if(!h)return;r(g),g.running||clearInterval(o.current)}catch(g){h&&s(he(g))}},1e3)}catch(g){h&&s(he(g))}})(),()=>{h=!1,clearInterval(o.current)}},[e]);const a={good:"ok",marginal:"warn",poor:"bad",artifact:"bad",no_faces:"warn",inconclusive:"warn",no_completed_passes:"warn"}[n.verdict],u=n.seconds?Math.min(100,n.elapsed/n.seconds*100):0,c=n.running||n.verdict==="starting";return i.jsx("div",{className:"drawer",onMouseDown:h=>h.target===h.currentTarget&&t(),children:i.jsxs("div",{className:"sheet",children:[i.jsxs("div",{className:"sheethead",children:[i.jsxs("h2",{children:["Check placement · ",e]}),i.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:i.jsx(Gi,{size:16})})]}),i.jsxs("div",{className:"sheetbody",children:[l&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),l]}),i.jsxs("ol",{className:"steps",children:[i.jsxs("li",{className:c?"now":"done",children:[i.jsx("b",{children:"Walk past the camera"}),i.jsx("span",{children:"The way a customer would — in through the door, not looking at the lens. Two or three times, for about 25 seconds."}),c&&i.jsx("div",{className:"progress",children:i.jsx("div",{style:{width:`${u}%`}})})]}),i.jsxs("li",{className:c?"":"now",children:[i.jsx("b",{children:"Behavision judges what it saw"}),i.jsx("span",{children:"Not “were the frames sharp”, but “did a person walking past produce a face worth recognising”."})]})]}),i.jsxs("div",{className:`verdict ${a??""}`,children:[i.jsxs("div",{className:"verdict-head",children:[c?i.jsx("span",{className:"spinner"}):a==="ok"?i.jsx(Js,{size:18}):i.jsx(Ee,{size:18}),i.jsx("b",{children:n.headline||"Watching…"})]}),((p=n.advice)==null?void 0:p.length)>0&&i.jsx("ul",{children:n.advice.map((h,g)=>i.jsx("li",{children:h},g))}),((v=n.quality)==null?void 0:v.n)>0&&i.jsxs("p",{className:"note",children:[n.quality.n," face",n.quality.n===1?"":"s"," seen · median quality ",n.quality.p50," ·"," ",Math.round((n.quality.fraction_below_gate??0)*100),"% too poor to use"]})]}),!c&&i.jsxs("div",{className:"sheetactions",children:[i.jsx("button",{className:"btn",onClick:t,children:"Close"}),i.jsx("button",{className:"btn primary",onClick:()=>{r({verdict:"starting",advice:[]}),I.startPlacement(e,25).then(r).catch(h=>s(he(h)))},children:"Run again"})]})]})]})})}const Op=["Is my shop working right now?","How do I add my camera?","Why has nobody been recognised today?","Who came in this morning?"];function Fp({session:e,onClose:t}){const[n,r]=N.useState([]),[l,s]=N.useState(""),[o,a]=N.useState(!1),[u,c]=N.useState(null),p=N.useRef(null),v=e==null?void 0:e.standalone;N.useEffect(()=>{var g;(g=p.current)==null||g.scrollTo({top:1e9,behavior:"smooth"})},[n,o]);async function h(g){const x=(g??l).trim();if(!x||o)return;const y=[...n,{role:"user",text:x}];r(y),s(""),a(!0),c(null);try{const z=await I.ask(y.map(f=>({role:f.role,text:f.text})));r([...y,{role:"assistant",text:z.text,used:z.used??[]}])}catch(z){const f=he(z);c(/session expired|unauthori[sz]ed/i.test(f)?"You’re signed out of head office, so I can’t look anything up. Sign in again and ask me once more.":f),r(n),s(x)}finally{a(!1)}}return i.jsxs("aside",{className:"helper",role:"dialog","aria-label":"Loya",children:[i.jsxs("header",{className:"helperhead",children:[i.jsx("img",{src:wt,alt:""}),i.jsxs("div",{children:[i.jsx("b",{children:"Loya"}),i.jsx("span",{children:"Your Behavision buddy — knows your cameras, your customers and your numbers."})]}),i.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:i.jsx(Gi,{size:16})})]}),i.jsxs("div",{className:"helperbody",ref:p,children:[v&&i.jsxs("div",{className:"helpernote",children:[i.jsx(Ec,{size:16}),i.jsxs("div",{children:[i.jsx("b",{children:"This PC runs on its own"}),i.jsx("span",{children:"Loya lives at head office. Link this PC to a shop to talk to her; the basics are below."})]})]}),n.length===0&&i.jsxs("div",{className:"helperintro",children:[i.jsx("div",{className:"turn assistant",children:i.jsxs("div",{className:"bubble",children:[Ip(e)," Ask me anything about ",(e==null?void 0:e.site_name)||"this shop"," — what’s happening now, or how to set something up."]})}),i.jsx("div",{className:"chips",children:Op.map(g=>i.jsx("button",{className:"chip",onClick:()=>h(g),disabled:o||v,children:g},g))}),v&&i.jsx($p,{})]}),n.map((g,x)=>{var y;return i.jsxs("div",{className:`turn ${g.role}`,children:[i.jsx("div",{className:"bubble",children:g.text}),((y=g.used)==null?void 0:y.length)>0&&i.jsxs("span",{className:"used",children:["Looked at: ",g.used.join(", ")]})]},x)}),o&&i.jsx("div",{className:"turn assistant",children:i.jsxs("div",{className:"bubble thinking",children:[i.jsx("span",{}),i.jsx("span",{}),i.jsx("span",{})]})}),u&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),u]})]}),i.jsxs("form",{className:"helperask",onSubmit:g=>{g.preventDefault(),h()},children:[i.jsx("input",{value:l,onChange:g=>s(g.target.value),disabled:o||v,placeholder:v?"Link this PC to head office to talk to Loya":"Ask Loya…"}),i.jsx("button",{className:"btn primary",disabled:o||v||!l.trim(),"aria-label":"Ask",children:i.jsx(mp,{size:16})})]})]})}function Ip(e){var l,s;const t=new Date().getHours(),n=t<12?"Morning":t<17?"Afternoon":"Evening",r=(s=(l=e==null?void 0:e.user)==null?void 0:l.full_name)==null?void 0:s.split(" ")[0];return r?`${n}, ${r}.`:`${n}.`}function $p(){return i.jsxs("dl",{className:"quickhelp",children:[i.jsx("dt",{children:"Adding a camera"}),i.jsx("dd",{children:"Cameras → Add camera. The address is on a label on the camera; pick the make and the stream path fills itself in. Test, then save."}),i.jsx("dt",{children:"Proving it works"}),i.jsx("dd",{children:"Press Check placement and walk past the camera like a customer for 25 seconds. Only “good” means it can recognise faces — otherwise move it to head height, facing the way people approach."}),i.jsx("dt",{children:"Nothing showing on Live"}),i.jsx("dd",{children:"Check the camera is Connected and Proven. A camera aimed from above or the side streams fine and recognises nobody."}),i.jsx("dt",{children:"Linking to head office later"}),i.jsx("dd",{children:"Use the link button at the bottom of the sidebar and type an installation code from head office. Nothing recorded here is lost."})]})}const Up=[{id:"live",label:"Live",Glyph:ap,View:zc},{id:"customers",label:"Customers",Glyph:up,View:zp,cloud:!0},{id:"cameras",label:"Cameras",Glyph:cp,View:Lp}];function Ap(){var h,g,x;const[e,t]=N.useState(null),[n,r]=N.useState("live"),[l,s]=N.useState(!0),[o,a]=N.useState(!1),[u,c]=N.useState(!1);if(N.useEffect(()=>{let y=!0;const z=async()=>{try{const d=await I.session();y&&t(m=>JSON.stringify(m)===JSON.stringify(d)?m:d)}catch{y&&t(null)}y&&s(!1)};z();const f=setInterval(z,8e3);return()=>{y=!1,clearInterval(f)}},[]),!ip())return i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsx("h1",{children:"Behavision"}),i.jsx("p",{className:"lead",children:"This is the Behavision window running outside the app, so it has no connection to the recognition engine. Launch the Behavision application instead."})]})});if(l)return i.jsx("div",{className:"login",children:i.jsx("p",{className:"note",children:"Starting…"})});if(!(e!=null&&e.claimed)&&!(e!=null&&e.standalone))return i.jsx(ca,{onDone:t});if(!(e!=null&&e.standalone)&&!(e!=null&&e.logged_in))return i.jsx(vp,{onDone:t});const p=Up.filter(y=>!y.cloud||!e.standalone),v=((h=p.find(y=>y.id===n))==null?void 0:h.View)??zc;return o?i.jsx(ca,{onDone:y=>{a(!1),t(y)},onCancel:()=>a(!1)}):i.jsxs("div",{className:"shell",children:[i.jsxs("aside",{className:"side",children:[i.jsxs("div",{className:"brand",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsxs("div",{className:"id",children:[i.jsx("h1",{children:"Behavision"}),i.jsx("p",{children:e.site_name||((g=e.user)==null?void 0:g.client_name)||"This shop"})]})]}),i.jsx("nav",{className:"nav",children:p.map(({id:y,label:z,Glyph:f})=>i.jsxs("button",{onClick:()=>r(y),"aria-current":y===n?"page":void 0,children:[i.jsx(f,{size:17}),z]},y))}),i.jsx(Bp,{}),i.jsx("div",{className:"who",children:e.standalone?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"id",children:[i.jsx("b",{children:"On its own"}),i.jsx("span",{children:"No head office"})]}),i.jsx("button",{className:"btn sm icon",title:"Link to head office",onClick:()=>a(!0),children:i.jsx(pp,{size:15})})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"id",children:[i.jsx("b",{children:"Signed in"}),i.jsx("span",{children:(x=e.user)==null?void 0:x.email})]}),i.jsx("button",{className:"btn sm icon",title:"Sign out",onClick:async()=>t(await I.logout()),children:i.jsx(hp,{size:15})})]})})]}),i.jsxs("main",{className:"main",children:[i.jsx(v,{session:e,onNavigate:r}),!u&&i.jsxs("button",{className:"loya-fab",onClick:()=>c(!0),"aria-label":"Ask Loya",title:"Ask Loya",children:[i.jsx("img",{src:wt,alt:""}),i.jsx("span",{children:"Loya"})]})]}),u&&i.jsx(Fp,{session:e,onClose:()=>c(!1)})]})}function Bp(){const{data:e,reload:t}=rt(()=>I.engineStatus(),5e3),[n,r]=N.useState(!1),l=e??{state:"stopped"},s=N.useCallback(async v=>{r(!0);try{await v()}catch(h){alert(he(h))}finally{r(!1),t()}},[t]),o=l.state==="running",a=Object.values(l.cameras??{}),u=a.filter(Boolean).length;let c="idle",p="Stopped";return!o&&l.reachable?(c="warn",p="Running outside the app"):l.state==="failed"||l.state==="backoff"?(c="bad",p="Not running"):o&&!l.reachable&&l.progress?(c="warn",p=`Downloading ${l.progress.what}… ${l.progress.percent}%`):o&&!l.reachable?(c="warn",p="Starting…"):o&&a.length===0?(c="warn",p="No cameras"):o&&u===0?(c="bad",p="No camera connected"):o&&us(I.startEngine),children:[i.jsx(qs,{size:13}),"Start"]}),i.jsxs("button",{className:"btn sm",disabled:n||!o,onClick:()=>s(I.stopEngine),children:[i.jsx(dp,{size:13}),"Stop"]})]})]})}Sc(document.getElementById("root")).render(i.jsx(Yc.StrictMode,{children:i.jsx(Ap,{})})); diff --git a/desktop/frontend/dist/assets/index-p8f6baZq.js b/desktop/frontend/dist/assets/index-p8f6baZq.js new file mode 100644 index 0000000..532a159 --- /dev/null +++ b/desktop/frontend/dist/assets/index-p8f6baZq.js @@ -0,0 +1,40 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const s of l)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(l){const s={};return l.integrity&&(s.integrity=l.integrity),l.referrerPolicy&&(s.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?s.credentials="include":l.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(l){if(l.ep)return;l.ep=!0;const s=n(l);fetch(l.href,s)}})();function Tc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var fa={exports:{}},ml={},pa={exports:{}},D={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var ir=Symbol.for("react.element"),Rc=Symbol.for("react.portal"),Mc=Symbol.for("react.fragment"),Dc=Symbol.for("react.strict_mode"),Oc=Symbol.for("react.profiler"),Fc=Symbol.for("react.provider"),Ic=Symbol.for("react.context"),$c=Symbol.for("react.forward_ref"),Uc=Symbol.for("react.suspense"),Ac=Symbol.for("react.memo"),Bc=Symbol.for("react.lazy"),Ji=Symbol.iterator;function Vc(e){return e===null||typeof e!="object"?null:(e=Ji&&e[Ji]||e["@@iterator"],typeof e=="function"?e:null)}var ha={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ma=Object.assign,va={};function yn(e,t,n){this.props=e,this.context=t,this.refs=va,this.updater=n||ha}yn.prototype.isReactComponent={};yn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};yn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function ga(){}ga.prototype=yn.prototype;function ti(e,t,n){this.props=e,this.context=t,this.refs=va,this.updater=n||ha}var ni=ti.prototype=new ga;ni.constructor=ti;ma(ni,yn.prototype);ni.isPureReactComponent=!0;var qi=Array.isArray,ya=Object.prototype.hasOwnProperty,ri={current:null},xa={key:!0,ref:!0,__self:!0,__source:!0};function wa(e,t,n){var r,l={},s=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(s=""+t.key),t)ya.call(t,r)&&!xa.hasOwnProperty(r)&&(l[r]=t[r]);var a=arguments.length-2;if(a===1)l.children=n;else if(1>>1,te=j[G];if(0>>1;Gl(Rl,M))_tl(fr,Rl)?(j[G]=fr,j[_t]=M,G=_t):(j[G]=Rl,j[Et]=M,G=Et);else if(_tl(fr,M))j[G]=fr,j[_t]=M,G=_t;else break e}}return L}function l(j,L){var M=j.sortIndex-L.sortIndex;return M!==0?M:j.id-L.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();e.unstable_now=function(){return o.now()-a}}var u=[],c=[],p=1,v=null,h=3,g=!1,x=!1,y=!1,z=typeof setTimeout=="function"?setTimeout:null,f=typeof clearTimeout=="function"?clearTimeout:null,d=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function m(j){for(var L=n(c);L!==null;){if(L.callback===null)r(c);else if(L.startTime<=j)r(c),L.sortIndex=L.expirationTime,t(u,L);else break;L=n(c)}}function w(j){if(y=!1,m(j),!x)if(n(u)!==null)x=!0,Wt(C);else{var L=n(c);L!==null&&T(w,L.startTime-j)}}function C(j,L){x=!1,y&&(y=!1,f(P),P=-1),g=!0;var M=h;try{for(m(L),v=n(u);v!==null&&(!(v.expirationTime>L)||j&&!je());){var G=v.callback;if(typeof G=="function"){v.callback=null,h=v.priorityLevel;var te=G(v.expirationTime<=L);L=e.unstable_now(),typeof te=="function"?v.callback=te:v===n(u)&&r(u),m(L)}else r(u);v=n(u)}if(v!==null)var dr=!0;else{var Et=n(c);Et!==null&&T(w,Et.startTime-L),dr=!1}return dr}finally{v=null,h=M,g=!1}}var _=!1,S=null,P=-1,U=5,R=-1;function je(){return!(e.unstable_now()-Rj||125G?(j.sortIndex=M,t(c,j),n(u)===null&&j===n(c)&&(y?(f(P),P=-1):y=!0,T(w,M-G))):(j.sortIndex=te,t(u,j),x||g||(x=!0,Wt(C))),j},e.unstable_shouldYield=je,e.unstable_wrapCallback=function(j){var L=h;return function(){var M=h;h=L;try{return j.apply(this,arguments)}finally{h=M}}}})(Ca);Na.exports=Ca;var ed=Na.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var td=N,Ee=ed;function k(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),is=Object.prototype.hasOwnProperty,nd=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,eo={},to={};function rd(e){return is.call(to,e)?!0:is.call(eo,e)?!1:nd.test(e)?to[e]=!0:(eo[e]=!0,!1)}function ld(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function sd(e,t,n,r){if(t===null||typeof t>"u"||ld(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function me(e,t,n,r,l,s,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=o}var ie={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ie[e]=new me(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];ie[t]=new me(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ie[e]=new me(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ie[e]=new me(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){ie[e]=new me(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ie[e]=new me(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ie[e]=new me(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ie[e]=new me(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ie[e]=new me(e,5,!1,e.toLowerCase(),null,!1,!1)});var si=/[\-:]([a-z])/g;function ii(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(si,ii);ie[t]=new me(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(si,ii);ie[t]=new me(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(si,ii);ie[t]=new me(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ie[e]=new me(e,1,!1,e.toLowerCase(),null,!1,!1)});ie.xlinkHref=new me("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ie[e]=new me(e,1,!1,e.toLowerCase(),null,!0,!0)});function oi(e,t,n,r){var l=ie.hasOwnProperty(t)?ie[t]:null;(l!==null?l.type!==0:r||!(2a||l[o]!==s[a]){var u=` +`+l[o].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=o&&0<=a);break}}}finally{Ol=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Ln(e):""}function id(e){switch(e.tag){case 5:return Ln(e.type);case 16:return Ln("Lazy");case 13:return Ln("Suspense");case 19:return Ln("SuspenseList");case 0:case 2:case 15:return e=Fl(e.type,!1),e;case 11:return e=Fl(e.type.render,!1),e;case 1:return e=Fl(e.type,!0),e;default:return""}}function cs(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Kt:return"Fragment";case Qt:return"Portal";case os:return"Profiler";case ai:return"StrictMode";case as:return"Suspense";case us:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Pa:return(e.displayName||"Context")+".Consumer";case _a:return(e._context.displayName||"Context")+".Provider";case ui:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ci:return t=e.displayName||null,t!==null?t:cs(e.type)||"Memo";case it:t=e._payload,e=e._init;try{return cs(e(t))}catch{}}return null}function od(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return cs(t);case 8:return t===ai?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function jt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function La(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ad(e){var t=La(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function mr(e){e._valueTracker||(e._valueTracker=ad(e))}function Ta(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=La(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Qr(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function ds(e,t){var n=t.checked;return K({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ro(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=jt(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Ra(e,t){t=t.checked,t!=null&&oi(e,"checked",t,!1)}function fs(e,t){Ra(e,t);var n=jt(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?ps(e,t.type,n):t.hasOwnProperty("defaultValue")&&ps(e,t.type,jt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function lo(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function ps(e,t,n){(t!=="number"||Qr(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Tn=Array.isArray;function rn(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=vr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Hn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Dn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ud=["Webkit","ms","Moz","O"];Object.keys(Dn).forEach(function(e){ud.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Dn[t]=Dn[e]})});function Fa(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Dn.hasOwnProperty(e)&&Dn[e]?(""+t).trim():t+"px"}function Ia(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Fa(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var cd=K({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function vs(e,t){if(t){if(cd[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(k(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(k(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(k(61))}if(t.style!=null&&typeof t.style!="object")throw Error(k(62))}}function gs(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ys=null;function di(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var xs=null,ln=null,sn=null;function oo(e){if(e=ur(e)){if(typeof xs!="function")throw Error(k(280));var t=e.stateNode;t&&(t=wl(t),xs(e.stateNode,e.type,t))}}function $a(e){ln?sn?sn.push(e):sn=[e]:ln=e}function Ua(){if(ln){var e=ln,t=sn;if(sn=ln=null,oo(e),t)for(e=0;e>>=0,e===0?32:31-(jd(e)/kd|0)|0}var gr=64,yr=4194304;function Rn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Xr(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,s=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~l;a!==0?r=Rn(a):(s&=o,s!==0&&(r=Rn(s)))}else o=n&~l,o!==0?r=Rn(o):s!==0&&(r=Rn(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,s=t&-t,l>=s||l===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function or(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ue(t),e[t]=n}function Ed(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Fn),go=" ",yo=!1;function su(e,t){switch(e){case"keyup":return ef.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function iu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Yt=!1;function nf(e,t){switch(e){case"compositionend":return iu(t);case"keypress":return t.which!==32?null:(yo=!0,go);case"textInput":return e=t.data,e===go&&yo?null:e;default:return null}}function rf(e,t){if(Yt)return e==="compositionend"||!xi&&su(e,t)?(e=ru(),Fr=vi=ct=null,Yt=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ko(n)}}function cu(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?cu(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function du(){for(var e=window,t=Qr();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Qr(e.document)}return t}function wi(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function pf(e){var t=du(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&cu(n.ownerDocument.documentElement,n)){if(r!==null&&wi(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,s=Math.min(r.start,l);r=r.end===void 0?s:Math.min(r.end,l),!e.extend&&s>r&&(l=r,r=s,s=l),l=So(n,s);var o=So(n,r);l&&o&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Gt=null,Cs=null,$n=null,Es=!1;function No(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Es||Gt==null||Gt!==Qr(r)||(r=Gt,"selectionStart"in r&&wi(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),$n&&Zn($n,r)||($n=r,r=qr(Cs,"onSelect"),0Jt||(e.current=Rs[Jt],Rs[Jt]=null,Jt--)}function A(e,t){Jt++,Rs[Jt]=e.current,e.current=t}var kt={},ce=Nt(kt),ye=Nt(!1),Ot=kt;function fn(e,t){var n=e.type.contextTypes;if(!n)return kt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},s;for(s in n)l[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function xe(e){return e=e.childContextTypes,e!=null}function el(){V(ye),V(ce)}function To(e,t,n){if(ce.current!==kt)throw Error(k(168));A(ce,t),A(ye,n)}function wu(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(k(108,od(e)||"Unknown",l));return K({},n,r)}function tl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||kt,Ot=ce.current,A(ce,e),A(ye,ye.current),!0}function Ro(e,t,n){var r=e.stateNode;if(!r)throw Error(k(169));n?(e=wu(e,t,Ot),r.__reactInternalMemoizedMergedChildContext=e,V(ye),V(ce),A(ce,e)):V(ye),A(ye,n)}var Xe=null,jl=!1,Zl=!1;function ju(e){Xe===null?Xe=[e]:Xe.push(e)}function Cf(e){jl=!0,ju(e)}function Ct(){if(!Zl&&Xe!==null){Zl=!0;var e=0,t=$;try{var n=Xe;for($=1;e>=o,l-=o,Ze=1<<32-Ue(t)+l|n<P?(U=S,S=null):U=S.sibling;var R=h(f,S,m[P],w);if(R===null){S===null&&(S=U);break}e&&S&&R.alternate===null&&t(f,S),d=s(R,d,P),_===null?C=R:_.sibling=R,_=R,S=U}if(P===m.length)return n(f,S),W&&Pt(f,P),C;if(S===null){for(;PP?(U=S,S=null):U=S.sibling;var je=h(f,S,R.value,w);if(je===null){S===null&&(S=U);break}e&&S&&je.alternate===null&&t(f,S),d=s(je,d,P),_===null?C=je:_.sibling=je,_=je,S=U}if(R.done)return n(f,S),W&&Pt(f,P),C;if(S===null){for(;!R.done;P++,R=m.next())R=v(f,R.value,w),R!==null&&(d=s(R,d,P),_===null?C=R:_.sibling=R,_=R);return W&&Pt(f,P),C}for(S=r(f,S);!R.done;P++,R=m.next())R=g(S,f,P,R.value,w),R!==null&&(e&&R.alternate!==null&&S.delete(R.key===null?P:R.key),d=s(R,d,P),_===null?C=R:_.sibling=R,_=R);return e&&S.forEach(function(ee){return t(f,ee)}),W&&Pt(f,P),C}function z(f,d,m,w){if(typeof m=="object"&&m!==null&&m.type===Kt&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case hr:e:{for(var C=m.key,_=d;_!==null;){if(_.key===C){if(C=m.type,C===Kt){if(_.tag===7){n(f,_.sibling),d=l(_,m.props.children),d.return=f,f=d;break e}}else if(_.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===it&&Oo(C)===_.type){n(f,_.sibling),d=l(_,m.props),d.ref=En(f,_,m),d.return=f,f=d;break e}n(f,_);break}else t(f,_);_=_.sibling}m.type===Kt?(d=Dt(m.props.children,f.mode,w,m.key),d.return=f,f=d):(w=Hr(m.type,m.key,m.props,null,f.mode,w),w.ref=En(f,d,m),w.return=f,f=w)}return o(f);case Qt:e:{for(_=m.key;d!==null;){if(d.key===_)if(d.tag===4&&d.stateNode.containerInfo===m.containerInfo&&d.stateNode.implementation===m.implementation){n(f,d.sibling),d=l(d,m.children||[]),d.return=f,f=d;break e}else{n(f,d);break}else t(f,d);d=d.sibling}d=ls(m,f.mode,w),d.return=f,f=d}return o(f);case it:return _=m._init,z(f,d,_(m._payload),w)}if(Tn(m))return x(f,d,m,w);if(jn(m))return y(f,d,m,w);Cr(f,m)}return typeof m=="string"&&m!==""||typeof m=="number"?(m=""+m,d!==null&&d.tag===6?(n(f,d.sibling),d=l(d,m),d.return=f,f=d):(n(f,d),d=rs(m,f.mode,w),d.return=f,f=d),o(f)):n(f,d)}return z}var hn=Cu(!0),Eu=Cu(!1),ll=Nt(null),sl=null,en=null,Ni=null;function Ci(){Ni=en=sl=null}function Ei(e){var t=ll.current;V(ll),e._currentValue=t}function Os(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function an(e,t){sl=e,Ni=en=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ge=!0),e.firstContext=null)}function Me(e){var t=e._currentValue;if(Ni!==e)if(e={context:e,memoizedValue:t,next:null},en===null){if(sl===null)throw Error(k(308));en=e,sl.dependencies={lanes:0,firstContext:e}}else en=en.next=e;return t}var Tt=null;function _i(e){Tt===null?Tt=[e]:Tt.push(e)}function _u(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,_i(t)):(n.next=l.next,l.next=n),t.interleaved=n,tt(e,r)}function tt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var ot=!1;function Pi(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Pu(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function qe(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function vt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,O&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,tt(e,n)}return l=r.interleaved,l===null?(t.next=t,_i(r)):(t.next=l.next,l.next=t),r.interleaved=t,tt(e,n)}function $r(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,pi(e,n)}}function Fo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?l=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?l=s=t:s=s.next=t}else l=s=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function il(e,t,n,r){var l=e.updateQueue;ot=!1;var s=l.firstBaseUpdate,o=l.lastBaseUpdate,a=l.shared.pending;if(a!==null){l.shared.pending=null;var u=a,c=u.next;u.next=null,o===null?s=c:o.next=c,o=u;var p=e.alternate;p!==null&&(p=p.updateQueue,a=p.lastBaseUpdate,a!==o&&(a===null?p.firstBaseUpdate=c:a.next=c,p.lastBaseUpdate=u))}if(s!==null){var v=l.baseState;o=0,p=c=u=null,a=s;do{var h=a.lane,g=a.eventTime;if((r&h)===h){p!==null&&(p=p.next={eventTime:g,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var x=e,y=a;switch(h=t,g=n,y.tag){case 1:if(x=y.payload,typeof x=="function"){v=x.call(g,v,h);break e}v=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=y.payload,h=typeof x=="function"?x.call(g,v,h):x,h==null)break e;v=K({},v,h);break e;case 2:ot=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,h=l.effects,h===null?l.effects=[a]:h.push(a))}else g={eventTime:g,lane:h,tag:a.tag,payload:a.payload,callback:a.callback,next:null},p===null?(c=p=g,u=v):p=p.next=g,o|=h;if(a=a.next,a===null){if(a=l.shared.pending,a===null)break;h=a,a=h.next,h.next=null,l.lastBaseUpdate=h,l.shared.pending=null}}while(!0);if(p===null&&(u=v),l.baseState=u,l.firstBaseUpdate=c,l.lastBaseUpdate=p,t=l.shared.interleaved,t!==null){l=t;do o|=l.lane,l=l.next;while(l!==t)}else s===null&&(l.shared.lanes=0);$t|=o,e.lanes=o,e.memoizedState=v}}function Io(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ql.transition;ql.transition={};try{e(!1),t()}finally{$=n,ql.transition=r}}function Qu(){return De().memoizedState}function zf(e,t,n){var r=yt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ku(e))Yu(t,n);else if(n=_u(e,t,n,r),n!==null){var l=fe();Ae(n,e,r,l),Gu(n,t,r)}}function Lf(e,t,n){var r=yt(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ku(e))Yu(t,l);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var o=t.lastRenderedState,a=s(o,n);if(l.hasEagerState=!0,l.eagerState=a,Be(a,o)){var u=t.interleaved;u===null?(l.next=l,_i(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=_u(e,t,l,r),n!==null&&(l=fe(),Ae(n,e,r,l),Gu(n,t,r))}}function Ku(e){var t=e.alternate;return e===Q||t!==null&&t===Q}function Yu(e,t){Un=al=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Gu(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,pi(e,n)}}var ul={readContext:Me,useCallback:oe,useContext:oe,useEffect:oe,useImperativeHandle:oe,useInsertionEffect:oe,useLayoutEffect:oe,useMemo:oe,useReducer:oe,useRef:oe,useState:oe,useDebugValue:oe,useDeferredValue:oe,useTransition:oe,useMutableSource:oe,useSyncExternalStore:oe,useId:oe,unstable_isNewReconciler:!1},Tf={readContext:Me,useCallback:function(e,t){return We().memoizedState=[e,t===void 0?null:t],e},useContext:Me,useEffect:Uo,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ar(4194308,4,Au.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ar(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ar(4,2,e,t)},useMemo:function(e,t){var n=We();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=We();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=zf.bind(null,Q,e),[r.memoizedState,e]},useRef:function(e){var t=We();return e={current:e},t.memoizedState=e},useState:$o,useDebugValue:Fi,useDeferredValue:function(e){return We().memoizedState=e},useTransition:function(){var e=$o(!1),t=e[0];return e=Pf.bind(null,e[1]),We().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Q,l=We();if(W){if(n===void 0)throw Error(k(407));n=n()}else{if(n=t(),re===null)throw Error(k(349));It&30||Ru(r,t,n)}l.memoizedState=n;var s={value:n,getSnapshot:t};return l.queue=s,Uo(Du.bind(null,r,s,e),[e]),r.flags|=2048,lr(9,Mu.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=We(),t=re.identifierPrefix;if(W){var n=Je,r=Ze;n=(r&~(1<<32-Ue(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=nr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[He]=t,e[bn]=r,lc(e,t,!1,!1),t.stateNode=e;e:{switch(o=gs(n,r),n){case"dialog":B("cancel",e),B("close",e),l=r;break;case"iframe":case"object":case"embed":B("load",e),l=r;break;case"video":case"audio":for(l=0;lgn&&(t.flags|=128,r=!0,_n(s,!1),t.lanes=4194304)}else{if(!r)if(e=ol(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),_n(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!W)return ae(t),null}else 2*X()-s.renderingStartTime>gn&&n!==1073741824&&(t.flags|=128,r=!0,_n(s,!1),t.lanes=4194304);s.isBackwards?(o.sibling=t.child,t.child=o):(n=s.last,n!==null?n.sibling=o:t.child=o,s.last=o)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=X(),t.sibling=null,n=H.current,A(H,r?n&1|2:n&1),t):(ae(t),null);case 22:case 23:return Vi(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ke&1073741824&&(ae(t),t.subtreeFlags&6&&(t.flags|=8192)):ae(t),null;case 24:return null;case 25:return null}throw Error(k(156,t.tag))}function Uf(e,t){switch(ki(t),t.tag){case 1:return xe(t.type)&&el(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return mn(),V(ye),V(ce),Ti(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Li(t),null;case 13:if(V(H),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(k(340));pn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return V(H),null;case 4:return mn(),null;case 10:return Ei(t.type._context),null;case 22:case 23:return Vi(),null;case 24:return null;default:return null}}var _r=!1,ue=!1,Af=typeof WeakSet=="function"?WeakSet:Set,E=null;function tn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Y(e,t,r)}else n.current=null}function Hs(e,t,n){try{n()}catch(r){Y(e,t,r)}}var Zo=!1;function Bf(e,t){if(_s=Zr,e=du(),wi(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,u=-1,c=0,p=0,v=e,h=null;t:for(;;){for(var g;v!==n||l!==0&&v.nodeType!==3||(a=o+l),v!==s||r!==0&&v.nodeType!==3||(u=o+r),v.nodeType===3&&(o+=v.nodeValue.length),(g=v.firstChild)!==null;)h=v,v=g;for(;;){if(v===e)break t;if(h===n&&++c===l&&(a=o),h===s&&++p===r&&(u=o),(g=v.nextSibling)!==null)break;v=h,h=v.parentNode}v=g}n=a===-1||u===-1?null:{start:a,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ps={focusedElem:e,selectionRange:n},Zr=!1,E=t;E!==null;)if(t=E,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,E=e;else for(;E!==null;){t=E;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var y=x.memoizedProps,z=x.memoizedState,f=t.stateNode,d=f.getSnapshotBeforeUpdate(t.elementType===t.type?y:Fe(t.type,y),z);f.__reactInternalSnapshotBeforeUpdate=d}break;case 3:var m=t.stateNode.containerInfo;m.nodeType===1?m.textContent="":m.nodeType===9&&m.documentElement&&m.removeChild(m.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(k(163))}}catch(w){Y(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,E=e;break}E=t.return}return x=Zo,Zo=!1,x}function An(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var s=l.destroy;l.destroy=void 0,s!==void 0&&Hs(t,n,s)}l=l.next}while(l!==r)}}function Nl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Qs(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function oc(e){var t=e.alternate;t!==null&&(e.alternate=null,oc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[He],delete t[bn],delete t[Ts],delete t[Sf],delete t[Nf])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function ac(e){return e.tag===5||e.tag===3||e.tag===4}function Jo(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ac(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ks(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=br));else if(r!==4&&(e=e.child,e!==null))for(Ks(e,t,n),e=e.sibling;e!==null;)Ks(e,t,n),e=e.sibling}function Ys(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Ys(e,t,n),e=e.sibling;e!==null;)Ys(e,t,n),e=e.sibling}var le=null,Ie=!1;function st(e,t,n){for(n=n.child;n!==null;)uc(e,t,n),n=n.sibling}function uc(e,t,n){if(Qe&&typeof Qe.onCommitFiberUnmount=="function")try{Qe.onCommitFiberUnmount(vl,n)}catch{}switch(n.tag){case 5:ue||tn(n,t);case 6:var r=le,l=Ie;le=null,st(e,t,n),le=r,Ie=l,le!==null&&(Ie?(e=le,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):le.removeChild(n.stateNode));break;case 18:le!==null&&(Ie?(e=le,n=n.stateNode,e.nodeType===8?Xl(e.parentNode,n):e.nodeType===1&&Xl(e,n),Gn(e)):Xl(le,n.stateNode));break;case 4:r=le,l=Ie,le=n.stateNode.containerInfo,Ie=!0,st(e,t,n),le=r,Ie=l;break;case 0:case 11:case 14:case 15:if(!ue&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var s=l,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&Hs(n,t,o),l=l.next}while(l!==r)}st(e,t,n);break;case 1:if(!ue&&(tn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Y(n,t,a)}st(e,t,n);break;case 21:st(e,t,n);break;case 22:n.mode&1?(ue=(r=ue)||n.memoizedState!==null,st(e,t,n),ue=r):st(e,t,n);break;default:st(e,t,n)}}function qo(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Af),t.forEach(function(r){var l=Zf.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Oe(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=o),r&=~s}if(r=l,r=X()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Wf(r/1960))-r,10e?16:e,dt===null)var r=!1;else{if(e=dt,dt=null,fl=0,O&6)throw Error(k(331));var l=O;for(O|=4,E=e.current;E!==null;){var s=E,o=s.child;if(E.flags&16){var a=s.deletions;if(a!==null){for(var u=0;uX()-Ai?Mt(e,0):Ui|=n),we(e,t)}function gc(e,t){t===0&&(e.mode&1?(t=yr,yr<<=1,!(yr&130023424)&&(yr=4194304)):t=1);var n=fe();e=tt(e,t),e!==null&&(or(e,t,n),we(e,n))}function Xf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),gc(e,n)}function Zf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(k(314))}r!==null&&r.delete(t),gc(e,n)}var yc;yc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ye.current)ge=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ge=!1,If(e,t,n);ge=!!(e.flags&131072)}else ge=!1,W&&t.flags&1048576&&ku(t,rl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Br(e,t),e=t.pendingProps;var l=fn(t,ce.current);an(t,n),l=Mi(null,t,r,e,l,n);var s=Di();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,xe(r)?(s=!0,tl(t)):s=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Pi(t),l.updater=Sl,t.stateNode=l,l._reactInternals=t,Is(t,r,e,n),t=As(null,t,r,!0,s,n)):(t.tag=0,W&&s&&ji(t),de(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Br(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=qf(r),e=Fe(r,e),l){case 0:t=Us(null,t,r,e,n);break e;case 1:t=Yo(null,t,r,e,n);break e;case 11:t=Qo(null,t,r,e,n);break e;case 14:t=Ko(null,t,r,Fe(r.type,e),n);break e}throw Error(k(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Fe(r,l),Us(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Fe(r,l),Yo(e,t,r,l,n);case 3:e:{if(tc(t),e===null)throw Error(k(387));r=t.pendingProps,s=t.memoizedState,l=s.element,Pu(e,t),il(t,r,null,n);var o=t.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){l=vn(Error(k(423)),t),t=Go(e,t,r,n,l);break e}else if(r!==l){l=vn(Error(k(424)),t),t=Go(e,t,r,n,l);break e}else for(Se=mt(t.stateNode.containerInfo.firstChild),Ne=t,W=!0,$e=null,n=Eu(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(pn(),r===l){t=nt(e,t,n);break e}de(e,t,r,n)}t=t.child}return t;case 5:return zu(t),e===null&&Ds(t),r=t.type,l=t.pendingProps,s=e!==null?e.memoizedProps:null,o=l.children,zs(r,l)?o=null:s!==null&&zs(r,s)&&(t.flags|=32),ec(e,t),de(e,t,o,n),t.child;case 6:return e===null&&Ds(t),null;case 13:return nc(e,t,n);case 4:return zi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=hn(t,null,r,n):de(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Fe(r,l),Qo(e,t,r,l,n);case 7:return de(e,t,t.pendingProps,n),t.child;case 8:return de(e,t,t.pendingProps.children,n),t.child;case 12:return de(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,s=t.memoizedProps,o=l.value,A(ll,r._currentValue),r._currentValue=o,s!==null)if(Be(s.value,o)){if(s.children===l.children&&!ye.current){t=nt(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var u=a.firstContext;u!==null;){if(u.context===r){if(s.tag===1){u=qe(-1,n&-n),u.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var p=c.pending;p===null?u.next=u:(u.next=p.next,p.next=u),c.pending=u}}s.lanes|=n,u=s.alternate,u!==null&&(u.lanes|=n),Os(s.return,n,t),a.lanes|=n;break}u=u.next}}else if(s.tag===10)o=s.type===t.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(k(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),Os(o,n,t),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===t){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}de(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,an(t,n),l=Me(l),r=r(l),t.flags|=1,de(e,t,r,n),t.child;case 14:return r=t.type,l=Fe(r,t.pendingProps),l=Fe(r.type,l),Ko(e,t,r,l,n);case 15:return qu(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Fe(r,l),Br(e,t),t.tag=1,xe(r)?(e=!0,tl(t)):e=!1,an(t,n),Xu(t,r,l),Is(t,r,l,n),As(null,t,r,!0,e,n);case 19:return rc(e,t,n);case 22:return bu(e,t,n)}throw Error(k(156,t.tag))};function xc(e,t){return Ka(e,t)}function Jf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Te(e,t,n,r){return new Jf(e,t,n,r)}function Hi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function qf(e){if(typeof e=="function")return Hi(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ui)return 11;if(e===ci)return 14}return 2}function xt(e,t){var n=e.alternate;return n===null?(n=Te(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Hr(e,t,n,r,l,s){var o=2;if(r=e,typeof e=="function")Hi(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Kt:return Dt(n.children,l,s,t);case ai:o=8,l|=8;break;case os:return e=Te(12,n,t,l|2),e.elementType=os,e.lanes=s,e;case as:return e=Te(13,n,t,l),e.elementType=as,e.lanes=s,e;case us:return e=Te(19,n,t,l),e.elementType=us,e.lanes=s,e;case za:return El(n,l,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case _a:o=10;break e;case Pa:o=9;break e;case ui:o=11;break e;case ci:o=14;break e;case it:o=16,r=null;break e}throw Error(k(130,e==null?e:typeof e,""))}return t=Te(o,n,t,l),t.elementType=e,t.type=r,t.lanes=s,t}function Dt(e,t,n,r){return e=Te(7,e,r,t),e.lanes=n,e}function El(e,t,n,r){return e=Te(22,e,r,t),e.elementType=za,e.lanes=n,e.stateNode={isHidden:!1},e}function rs(e,t,n){return e=Te(6,e,null,t),e.lanes=n,e}function ls(e,t,n){return t=Te(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function bf(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=$l(0),this.expirationTimes=$l(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$l(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Qi(e,t,n,r,l,s,o,a,u){return e=new bf(e,t,n,a,u),t===1?(t=1,s===!0&&(t|=8)):t=0,s=Te(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Pi(s),e}function ep(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Sc)}catch(e){console.error(e)}}Sc(),Sa.exports=_e;var sp=Sa.exports,Nc,ia=sp;Nc=ia.createRoot,ia.hydrateRoot;const Cc=()=>{var e,t;return(t=(e=window==null?void 0:window.go)==null?void 0:e.main)==null?void 0:t.App},ip=()=>!!Cc();async function F(e,...t){const n=Cc();if(!n||typeof n[e]!="function")throw new Error(`${e} is unavailable — run this inside the Behavision app`);return n[e](...t)}const I={session:()=>F("Session"),login:(e,t)=>F("Login",e,t),logout:()=>F("Logout"),claim:e=>F("Claim",e),runStandalone:()=>F("RunStandalone"),engineStatus:()=>F("EngineStatus"),startEngine:()=>F("StartEngine"),stopEngine:()=>F("StopEngine"),cameras:()=>F("Cameras"),testCamera:e=>F("TestCamera",e),discoverCameras:()=>F("DiscoverCameras"),saveCamera:(e,t)=>F("SaveCamera",e,t),deleteCamera:e=>F("DeleteCamera",e),startPlacement:(e,t)=>F("StartPlacementCheck",e,t),placementResult:e=>F("PlacementResult",e),streamURL:e=>F("StreamURL",e),remoteStreamURL:e=>F("RemoteStreamURL",e),live:()=>F("Live"),pipelineStatus:()=>F("PipelineStatus"),localIdentities:e=>F("LocalIdentities",e),localSightings:e=>F("LocalSightings",e),footfall:(e,t,n)=>F("Footfall",e,t,n),sites:()=>F("Sites"),visitorHistory:(e,t)=>F("VisitorHistory",e,t),visitorPhoto:e=>F("VisitorPhoto",e),forgetCustomer:e=>F("ForgetCustomer",e),sales:(e,t)=>F("Sales",e,t),customers:(e,t)=>F("Customers",e,t),saveProfile:e=>F("SaveProfile",e),ask:e=>F("Ask",e),recordPurchase:(e,t,n,r)=>F("RecordPurchase",e,t,n,r)};function pe(e){return e?typeof e=="string"?e:e.message||String(e):"Something went wrong."}function rt(e,t,n=[]){const[r,l]=N.useState(null),[s,o]=N.useState(null),[a,u]=N.useState(!0),c=N.useRef(!0),p=N.useRef(!1),v=N.useCallback(async()=>{if(!p.current){p.current=!0;try{const h=await e();if(!c.current)return;l(h),o(null)}catch(h){c.current&&o(pe(h))}finally{p.current=!1,c.current&&u(!1)}}},n);return N.useEffect(()=>{if(c.current=!0,v(),!t)return()=>{c.current=!1};const h=setInterval(v,t);return()=>{c.current=!1,clearInterval(h)}},[v,t]),{data:r,error:s,loading:a,reload:v}}function op(e){if(!e)return"—";const t=typeof e=="number"?new Date(e*1e3):new Date(e);return isNaN(t)?"—":t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function oa(e){if(!e)return"—";const t=typeof e=="number"?new Date(e*1e3):new Date(e);return isNaN(t)?"—":t.toLocaleDateString([],{day:"numeric",month:"short"})}const ss={width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"};function J({size:e,children:t,...n}){return i.jsx("svg",{...ss,...n,width:e??ss.width,height:e??ss.height,children:t})}const ap=e=>i.jsxs(J,{...e,children:[i.jsx("circle",{cx:"12",cy:"12",r:"3.2"}),i.jsx("path",{d:"M5.6 5.6a9 9 0 0 0 0 12.8M18.4 18.4a9 9 0 0 0 0-12.8"})]}),up=e=>i.jsxs(J,{...e,children:[i.jsx("circle",{cx:"9",cy:"8.5",r:"3.2"}),i.jsx("path",{d:"M2.8 19.5a6.4 6.4 0 0 1 12.4 0"}),i.jsx("path",{d:"M16.5 6.2a3.2 3.2 0 0 1 0 6.1M18 19.5a6 6 0 0 0-1.6-4"})]}),cp=e=>i.jsxs(J,{...e,children:[i.jsx("path",{d:"M3 8.5h3.4L8 6h8l1.6 2.5H21v10.2H3z"}),i.jsx("circle",{cx:"12",cy:"13.2",r:"3.1"})]}),Ec=e=>i.jsxs(J,{...e,children:[i.jsx("circle",{cx:"11",cy:"11",r:"6.4"}),i.jsx("path",{d:"M15.8 15.8 20.5 20.5"})]}),aa=e=>i.jsx(J,{...e,children:i.jsx("path",{d:"M12 5.5v13M5.5 12h13"})}),Xi=e=>i.jsx(J,{...e,children:i.jsx("path",{d:"M6.5 6.5l11 11M17.5 6.5l-11 11"})}),qs=e=>i.jsx(J,{...e,children:i.jsx("path",{d:"M5 12.8l4.4 4.2L19 7"})}),bs=e=>i.jsx(J,{...e,children:i.jsx("path",{d:"M8 5.6v12.8L18.5 12z"})}),dp=e=>i.jsx(J,{...e,children:i.jsx("rect",{x:"7",y:"7",width:"10",height:"10",rx:"1.6"})}),Ce=e=>i.jsxs(J,{...e,children:[i.jsx("path",{d:"M12 4.6 21 19.4H3z"}),i.jsx("path",{d:"M12 10v4.1"}),i.jsx("path",{d:"M12 17.1v.01"})]}),ua=e=>i.jsx(J,{...e,children:i.jsx("path",{d:"M5 19.4v-4.2M10.3 19.4v-7.6M15.7 19.4v-11M21 19.4V4.6"})}),Zi=e=>i.jsx(J,{...e,children:i.jsx("path",{d:"M7.2 18.4a4.2 4.2 0 0 1-.6-8.35A6.2 6.2 0 0 1 18.4 9a4.2 4.2 0 0 1 .3 9.4z"})}),_c=e=>i.jsxs(J,{...e,children:[i.jsx("path",{d:"M7.2 18.4a4.2 4.2 0 0 1-.6-8.35 6.2 6.2 0 0 1 2-3.2M10.6 5.2A6.2 6.2 0 0 1 18.4 9a4.2 4.2 0 0 1 1.9 7.6"}),i.jsx("path",{d:"M3.6 3.6l16.8 16.8"})]}),fp=e=>i.jsx(J,{...e,children:i.jsx("path",{d:"M12 3.8 19.4 6.6v5.2c0 4.2-3 7.4-7.4 8.4-4.4-1-7.4-4.2-7.4-8.4V6.6z"})}),pp=e=>i.jsxs(J,{...e,children:[i.jsx("path",{d:"M10.2 13.8a3.6 3.6 0 0 0 5.2 0l2.8-2.8a3.7 3.7 0 0 0-5.2-5.2l-1.3 1.3"}),i.jsx("path",{d:"M13.8 10.2a3.6 3.6 0 0 0-5.2 0l-2.8 2.8a3.7 3.7 0 0 0 5.2 5.2l1.3-1.3"})]}),hp=e=>i.jsxs(J,{...e,children:[i.jsx("path",{d:"M14.4 7.6V5.4H4.6v13.2h9.8v-2.2"}),i.jsx("path",{d:"M10 12h9.4M16.4 8.8 19.8 12l-3.4 3.2"})]}),ca=e=>i.jsx(J,{...e,children:i.jsx("path",{d:"M14.6 5.6 8 12l6.6 6.4"})}),mp=e=>i.jsx(J,{...e,children:i.jsx("path",{d:"M9.4 5.6 16 12l-6.6 6.4"})}),Pc=e=>i.jsxs(J,{...e,strokeWidth:"1.2",children:[i.jsx("path",{d:"M3 8.5h3.4L8 6h8l1.6 2.5H21v10.2H3z"}),i.jsx("circle",{cx:"12",cy:"13.2",r:"3.1"}),i.jsx("path",{d:"M3.6 3.6l16.8 16.8"})]}),zc=e=>i.jsxs(J,{...e,strokeWidth:"1.2",children:[i.jsx("circle",{cx:"12",cy:"9",r:"3.4"}),i.jsx("path",{d:"M5.4 20a6.8 6.8 0 0 1 13.2 0"})]}),wt=""+new URL("loyaly-mark-Ch-P3VSF.png",import.meta.url).href;function vp({onDone:e}){const[t,n]=N.useState(""),[r,l]=N.useState(""),[s,o]=N.useState(!1),[a,u]=N.useState(null);async function c(p){p.preventDefault(),o(!0),u(null);try{e(await I.login(t.trim(),r))}catch(v){u(pe(v))}finally{o(!1)}}return i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsx("h1",{children:"Behavision"}),i.jsx("p",{className:"lead",children:"Sign in to connect this PC to your store."}),i.jsxs("form",{onSubmit:c,children:[a&&i.jsxs("div",{className:"err",children:[i.jsx(Ce,{size:15}),a]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Email"}),i.jsx("input",{type:"email",value:t,autoComplete:"username",required:!0,autoFocus:!0,onChange:p=>n(p.target.value)})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Password"}),i.jsx("input",{type:"password",value:r,autoComplete:"current-password",required:!0,onChange:p=>l(p.target.value)})]}),i.jsx("button",{className:"btn primary",disabled:s||!t||!r,children:s?"Signing in…":"Sign in"})]}),i.jsx("p",{className:"foot",children:"Signing in downloads this store's recognition models and connects it to your account. Nothing is sent until a camera is set up."})]})})}function da({onDone:e,onCancel:t}){const[n,r]=N.useState(""),[l,s]=N.useState(null),[o,a]=N.useState(null);async function u(h){h.preventDefault(),s("claim"),a(null);try{e(await I.claim(n))}catch(g){a(pe(g))}finally{s(null)}}async function c(){s("alone"),a(null);try{e(await I.runStandalone())}catch(h){a(pe(h))}finally{s(null)}}const[p,v]=N.useState(t?"code":null);return p===null?i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box wide",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsx("h1",{children:"Welcome to Behavision"}),i.jsx("p",{className:"lead",children:"This PC will watch your shop’s cameras and recognise returning customers. First, one question: is this shop managed from a head office?"}),i.jsxs("div",{className:"choices",children:[i.jsxs("button",{type:"button",className:"choice",onClick:()=>v("code"),children:[i.jsx(Zi,{size:22}),i.jsx("b",{children:"Yes — I have an installation code"}),i.jsxs("span",{children:["Head office gave you a code like ",i.jsx("em",{children:"ABCDEF-123456-…"}),". This PC joins that shop and gets its cameras from there."]})]}),i.jsxs("button",{type:"button",className:"choice",onClick:()=>v("alone"),children:[i.jsx(fp,{size:22}),i.jsx("b",{children:"No — set up on this PC only"}),i.jsx("span",{children:"Cameras, customers and recognition stay on this PC. Nothing is sent anywhere. You can link to a head office later."})]})]})]})}):p==="alone"?i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsx("h1",{children:"On this PC only"}),i.jsx("p",{className:"lead",children:"Behavision will run entirely here. Next you’ll add your camera — it can find it on the network for you — and walk past it once so it can prove it works."}),o&&i.jsxs("div",{className:"err",children:[i.jsx(Ce,{size:15}),o]}),i.jsx("button",{type:"button",className:"btn primary",disabled:!!l,onClick:c,children:l==="alone"?"Setting up…":"Continue"}),i.jsx("div",{className:"alt",children:i.jsxs("button",{type:"button",className:"linkbtn",onClick:()=>v(null),children:[i.jsx(ca,{size:14})," Back"]})})]})}):i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsx("h1",{children:t?"Link to head office":"Join your shop"}),i.jsx("p",{className:"lead",children:"Type the installation code head office gave you. It works once, and this PC becomes that shop."}),i.jsxs("form",{onSubmit:u,children:[o&&i.jsxs("div",{className:"err",children:[i.jsx(Ce,{size:15}),o]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Installation code"}),i.jsx("input",{value:n,autoFocus:!0,required:!0,placeholder:"ABCDEF-123456-GHIJKL-789012",autoComplete:"off",spellCheck:"false",style:{textTransform:"uppercase",letterSpacing:".06em"},onChange:h=>r(h.target.value)})]}),i.jsx("button",{className:"btn primary",disabled:!!l||n.trim().length<6,children:l==="claim"?"Linking…":"Link this PC"})]}),i.jsxs("p",{className:"foot",children:["Don’t have one? Whoever runs head office creates it under the shop: ",i.jsx("em",{children:"Shops → the shop → Set up a shop PC"}),"."]}),i.jsx("div",{className:"alt",children:t?i.jsx("button",{type:"button",className:"linkbtn",onClick:t,children:"Not now — go back"}):i.jsxs("button",{type:"button",className:"linkbtn",onClick:()=>v(null),children:[i.jsx(ca,{size:14})," Back"]})})]})})}function Lc({onNavigate:e}){var h,g,x,y;const{data:t,error:n}=rt(()=>I.live(),3e3),{data:r}=rt(()=>I.pipelineStatus(),5e3),l=((h=t==null?void 0:t.stats)==null?void 0:h.cameras)??[],s=((g=t==null?void 0:t.stats)==null?void 0:g.gallery)??{},o=(t==null?void 0:t.events)??[],a=(t==null?void 0:t.viewing)===!0,u=a?((x=t==null?void 0:t.stats)==null?void 0:x.fraction_below_gate)??0:l.reduce((z,f)=>{var m,w;const d=(w=(m=f==null?void 0:f.pipeline)==null?void 0:m.best_quality)==null?void 0:w.fraction_below_gate;return typeof d=="number"&&d>z?d:z},0),c=a?((y=t==null?void 0:t.stats)==null?void 0:y.cameras_up)??0:l.filter(z=>z.connected).length,p=o.filter(z=>z.type==="person.new"||z.type==="person.seen"),v=jp(p[0]);return i.jsxs("div",{className:"page",children:[i.jsxs("header",{children:[i.jsx("h2",{children:"Live"}),i.jsx("p",{children:a?"Your shops, as head office sees them.":"Who is in the shop, and whether it is reaching head office."})]}),n&&i.jsxs("div",{className:"err",children:[i.jsx(Ce,{size:15}),n]}),a&&i.jsxs("div",{className:"viewing",children:[i.jsx(Zi,{size:15}),i.jsxs("span",{children:[i.jsx("b",{children:"Viewing your shops from here."})," This computer is not watching any cameras itself — everything below is what your shop PCs reported. To recognise people on this machine, it has to be on the same network as a camera."]})]}),i.jsx(wp,{pipe:r,cameras:l,up:c}),!a&&i.jsx(gp,{cameras:l,arrivals:p,onNavigate:e}),i.jsxs("div",{className:"panel arrivals-panel",children:[i.jsxs("div",{className:"panelhead",children:[i.jsx("h3",{children:"Who just walked in"}),p.length>0&&i.jsxs("span",{className:"note",children:[p.length," today"]})]}),i.jsx("div",{className:"panelbody flush",children:p.length===0?i.jsxs("div",{className:"empty",children:[i.jsx(zc,{size:34}),i.jsx("b",{children:"Nobody yet"}),i.jsx("p",{children:"Customers appear here the moment a camera recognises a face."})]}):i.jsx("div",{className:"arrivals",children:p.slice(0,30).map((z,f)=>i.jsx(yp,{e:z,fresh:f===0&&v},`${z.ts}-${f}`))})})]}),i.jsxs("div",{className:"metrics",style:{marginTop:"var(--sp-4)"},children:[i.jsx(Lr,{k:"People known",v:s.identities??"—"}),i.jsx(Lr,{k:"Sightings",v:s.sightings??"—"}),i.jsx(Lr,{k:"Cameras live",v:l.length?`${c}/${l.length}`:"—",tone:l.length?c===0?"bad":c.5?"bad":u>.2?"warn":"ok",s:u>.5?"Most visitors are being missed — move the camera":"Share of faces below the enrolment gate"})]})]})}function gp({cameras:e,arrivals:t,onNavigate:n}){const{data:r}=rt(()=>I.engineStatus(),4e3),[l,s]=N.useState(()=>{try{return localStorage.getItem("bv.gettingStarted")==="done"}catch{return!1}}),o=e.length>0,a=e.some(x=>x.connected),{data:u}=rt(async()=>{const x={};for(const y of e)try{x[y.camera_id]=await I.placementResult(y.camera_id)}catch{}return x},1e4,[e.map(x=>x.camera_id).join("|")]),c=Object.values(u??{}).some(x=>x&&!x.running&&x.verdict==="good"),p=t.length>0;if(l||p)return null;const v=!!(r!=null&&r.reachable&&(r!=null&&r.recognition_model)),h=r==null?void 0:r.progress,g=[{done:v,now:!v,title:v?`Recognition ready (${r.recognition_model})`:h?`Downloading ${h.what}… ${h.percent}%`:"Starting recognition…",text:v?null:"First start downloads about 275 MB of recognition models. A few minutes on a normal connection; nothing to do meanwhile."},{done:o&&a,now:v&&!(o&&a),title:o?a?"Camera connected":"Camera added — not connecting yet":"Add your camera",text:o?a?null:"Check its password and stream path under Cameras → Edit.":"Behavision can find it on the network; you type only its password.",action:o?null:{label:"Add camera",go:"cameras"}},{done:c,now:o&&a&&!c,title:c?"Camera proven — it can recognise faces":"Walk past the camera",text:c?null:"Run Check placement and walk past like a customer for 25 seconds. Only a “good” verdict means it will recognise people.",action:o&&a&&!c?{label:"Check placement",go:"cameras"}:null}];return i.jsxs("section",{className:"panel starter",children:[i.jsxs("div",{className:"panelhead",children:[i.jsx("h3",{children:"Getting started"}),i.jsx("button",{className:"btn sm ghost",onClick:()=>{try{localStorage.setItem("bv.gettingStarted","done")}catch{}s(!0)},children:"Hide"})]}),i.jsx("ol",{className:"steps compact",children:g.map((x,y)=>i.jsxs("li",{className:x.done?"done":x.now?"now":"",children:[i.jsx("b",{children:x.title}),x.text&&i.jsx("span",{children:x.text}),x.action&&i.jsx("button",{className:"btn sm primary",onClick:()=>n==null?void 0:n(x.action.go),children:x.action.label})]},y))}),i.jsx("p",{className:"note",children:"The moment a customer is recognised, this list goes away."})]})}function yp({e,fresh:t}){var o,a,u,c,p,v;const n=e.type==="person.new",r=((o=e.data)==null?void 0:o.label)||"Unrecognised",l=[(a=e.data)==null?void 0:a.gender,((u=e.data)==null?void 0:u.age)??((c=e.data)==null?void 0:c.age_range),(p=e.data)==null?void 0:p.emotion].filter(Boolean),s=typeof((v=e.data)==null?void 0:v.similarity)=="number"?e.data.similarity:null;return i.jsxs("article",{className:`arrival ${n?"is-new":"is-seen"} ${t?"fresh":""}`,children:[i.jsx("div",{className:"avatar",children:xp(r)}),i.jsxs("div",{className:"who",children:[i.jsx("div",{className:"name",children:r}),i.jsxs("div",{className:"meta",children:[e.camera_id,l.length>0&&i.jsxs(i.Fragment,{children:[" · ",l.join(", ")]}),s!==null&&!n&&i.jsxs(i.Fragment,{children:[" · match ",s.toFixed(2)]})]})]}),i.jsxs("div",{className:"right",children:[i.jsx("span",{className:`tag ${n?"new":"seen"}`,children:n?"new":"returning"}),i.jsx("span",{className:"when",children:op(e.ts)})]})]})}function xp(e){var r;const t=/^Visitor (\d+)$/.exec(String(e).trim());if(t)return t[1];const n=String(e).trim().split(/\s+/).filter(Boolean);return n.length?(n[0][0]+(((r=n[1])==null?void 0:r[0])??"")).toUpperCase():"?"}function wp({pipe:e,cameras:t,up:n}){if(!e)return null;if(e.standalone)return i.jsxs("div",{className:"statusbar",children:[i.jsxs("span",{className:"item",children:[i.jsx("i",{className:"dot ok"}),i.jsx("b",{children:"Running on this PC only"})]}),i.jsx("span",{className:"sep"}),i.jsx("span",{className:"item note",children:"Recognition and customers stay here."}),i.jsx("span",{className:"grow"}),i.jsxs("span",{className:"item note",children:[i.jsx(ua,{size:14}),n," of ",t.length," cameras"]})]});const r=e.claimed&&!e.broker_up,l=e.claimed?e.broker_up?"ok":"bad":"idle",s=e.claimed?e.broker_up?"Sending to head office":"Offline — saving locally":"Not linked to head office";return i.jsxs("div",{className:"statusbar",children:[i.jsxs("span",{className:"item",children:[e.broker_up?i.jsx(Zi,{size:15}):i.jsx(_c,{size:15}),i.jsx("i",{className:`dot ${l}`}),i.jsx("b",{children:s})]}),i.jsx("span",{className:"sep"}),i.jsxs("span",{className:"item note",children:[e.accepted," recorded today"]}),e.queued>0&&i.jsxs("span",{className:`item note ${r?"warn":""}`,children:[e.queued," waiting to send"]}),e.dropped>0&&i.jsxs("span",{className:"item note bad",children:[i.jsx(Ce,{size:14}),e.dropped," lost — this PC was offline too long"]}),i.jsx("span",{className:"grow"}),i.jsxs("span",{className:"item note",children:[i.jsx(ua,{size:14}),n," of ",t.length," cameras"]})]})}function Lr({k:e,v:t,s:n,tone:r}){return i.jsxs("div",{className:`metric ${r??""}`,children:[i.jsx("div",{className:"metric-k",children:e}),i.jsx("div",{className:"metric-v",children:t}),n&&i.jsx("div",{className:"metric-s",children:n})]})}function jp(e){const[t,n]=N.useState(!1),r=N.useRef(null);return N.useEffect(()=>{if(!e||e.ts===r.current)return;const l=r.current===null;if(r.current=e.ts,l)return;n(!0);const s=setTimeout(()=>n(!1),1200);return()=>clearTimeout(s)},[e==null?void 0:e.ts]),t}function kp(e){const[t,n]=N.useState(null);return N.useEffect(()=>{let r=!0;return n(null),I.visitorPhoto(e).then(l=>{r&&n(l)}).catch(()=>{r&&n({available:!1,reason:""})}),()=>{r=!1}},[e]),t}function Sp({photo:e,name:t,customerRef:n,onBroken:r}){return e!=null&&e.available?i.jsx("img",{className:"avatar",src:e.url,alt:`Photo of ${t}`,onError:r}):i.jsx("div",{className:"avatar none",role:"img","aria-label":`No photo of ${t}`,children:i.jsx("span",{children:Np(t,n)})})}function Np(e,t){const n=/^Visitor (\d+)$/.exec(String(e||"").trim());if(n)return n[1];const r=/^V-(\d+)$/.exec(String(t||""));return r?r[1]:String(e||"").split(/\s+/).filter(Boolean).slice(0,2).map(l=>l[0].toUpperCase()).join("")||"?"}function Cp({customer:e}){const{data:t,error:n,loading:r}=rt(()=>I.visitorHistory(e.id,50),0,[e.id]);if(r)return i.jsx("p",{className:"note",children:"Loading visits…"});if(n)return i.jsxs("p",{className:"note",children:["Could not load visits: ",n]});const l=t??[];return l.length===0?i.jsx("p",{className:"note",children:"No recorded visits yet."}):i.jsx("ul",{className:"timeline",children:l.map(s=>i.jsxs("li",{children:[i.jsx("span",{className:"when",children:Ep(s.occurred_at)}),i.jsxs("span",{className:"where",children:[s.site||"this store",s.camera_id?i.jsxs("span",{className:"note",children:[" · ",s.camera_id]}):null]}),s.is_new_visitor&&i.jsx("span",{className:"tag new",children:"first visit"})]},s.id))})}function Ep(e){const t=new Date(e);return isNaN(t)?"—":t.toLocaleString([],{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})}function _p({customer:e,onCancel:t,onDone:n}){const r=e.full_name||e.label,[l,s]=N.useState(""),[o,a]=N.useState(!1),[u,c]=N.useState(null),p=l.trim().toLowerCase()===r.trim().toLowerCase();async function v(){a(!0),c(null);try{await I.forgetCustomer(e.id),n()}catch(h){c(pe(h)),a(!1)}}return i.jsxs("div",{className:"confirm",children:[i.jsxs("h4",{children:["Erase ",r,"?"]}),i.jsxs("div",{className:"cols",children:[i.jsxs("div",{children:[i.jsx("p",{className:"lbl bad",children:"Deleted for good"}),i.jsxs("ul",{children:[i.jsx("li",{children:"Their face data — they will not be recognised again"}),i.jsx("li",{children:"Their photo"}),i.jsx("li",{children:"Their name, phone, email and notes"})]})]}),i.jsxs("div",{children:[i.jsx("p",{className:"lbl",children:"Kept"}),i.jsxs("ul",{children:[i.jsx("li",{children:"Past visits, with their name removed — your footfall figures do not change"}),i.jsx("li",{children:"The consent record, marked withdrawn, as proof of what was agreed"})]})]})]}),i.jsx("p",{className:"note",children:"This cannot be undone. If they come back they will be recorded as a new customer."}),u&&i.jsx("div",{className:"err",children:u}),i.jsxs("label",{className:"field",children:[i.jsxs("span",{children:["Type ",i.jsx("b",{children:r})," to confirm"]}),i.jsx("input",{value:l,onChange:h=>s(h.target.value),autoFocus:!0,autoComplete:"off",spellCheck:"false","aria-label":`Type ${r} to confirm erasure`})]}),i.jsxs("div",{className:"row",children:[i.jsx("button",{type:"button",className:"btn danger",disabled:!p||o,onClick:v,children:o?"Erasing…":"Erase permanently"}),i.jsx("button",{type:"button",className:"btn",onClick:t,disabled:o,children:"Cancel"})]})]})}function Pp({customer:e,session:t,onClose:n,onSaved:r}){var _;const[l,s]=N.useState({full_name:e.full_name??"",phone:e.phone??"",email:e.email??"",gender:"",date_of_birth:"",notes:"",consent:e.has_consent??!1}),[o,a]=N.useState({amount:"",items:"",notes:""}),[u,c]=N.useState(!1),[p,v]=N.useState(null),[h,g]=N.useState(!1),[x,y]=N.useState(null),z=kp(e.id),f=x??z,d=(_=t==null?void 0:t.user)==null?void 0:_.role,m=["admin","owner","manager"].includes(d),w=S=>P=>s({...l,[S]:P.target.value});async function C(S){S.preventDefault(),c(!0),v(null);try{await I.saveProfile({visitor_id:e.id,...l});const P=parseFloat(o.amount);if(!isNaN(P)&&P>0){const U=o.items.split(",").map(R=>R.trim()).filter(Boolean);await I.recordPurchase(e.id,P,U,o.notes)}r()}catch(P){v(pe(P))}finally{c(!1)}}return i.jsx("div",{className:"drawer",onMouseDown:S=>S.target===S.currentTarget&&n(),children:i.jsxs("div",{className:"sheet",children:[i.jsxs("div",{className:"sheethead who",children:[i.jsx(Sp,{photo:f,name:e.full_name||e.label,customerRef:e.ref,onBroken:()=>y({available:!1,reason:"The photo could not be loaded."})}),i.jsxs("div",{className:"grow",children:[i.jsx("h2",{children:e.full_name||e.label}),i.jsxs("p",{className:"note",children:[e.visit_count," visit",e.visit_count===1?"":"s",e.last_seen_at&&` · last seen ${new Date(e.last_seen_at).toLocaleDateString()}`,f&&!f.available&&f.reason&&` · ${f.reason}`]})]}),i.jsx("button",{type:"button",className:"close",onClick:n,"aria-label":"Close",children:"✕"})]}),i.jsxs("form",{className:"sheetbody",onSubmit:C,children:[p&&i.jsx("div",{className:"err",children:p}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Customer details"}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Full name"}),i.jsx("input",{value:l.full_name,onChange:w("full_name"),autoFocus:!0})]}),i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Phone"}),i.jsx("input",{value:l.phone,onChange:w("phone"),inputMode:"tel"})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Email"}),i.jsx("input",{value:l.email,onChange:w("email"),type:"email"})]})]}),i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Gender"}),i.jsxs("select",{value:l.gender,onChange:w("gender"),children:[i.jsx("option",{value:"",children:"Not recorded"}),i.jsx("option",{children:"Female"}),i.jsx("option",{children:"Male"}),i.jsx("option",{children:"Other"})]})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Date of birth"}),i.jsx("input",{type:"date",value:l.date_of_birth,onChange:w("date_of_birth")})]})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Notes"}),i.jsx("textarea",{value:l.notes,onChange:w("notes"),placeholder:"Preferences, sizes, anything worth remembering"})]})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Purchase (optional)"}),i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Amount"}),i.jsx("input",{value:o.amount,inputMode:"decimal",placeholder:"0.00",onChange:S=>a({...o,amount:S.target.value})})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Items"}),i.jsx("input",{value:o.items,placeholder:"shirt, belt",onChange:S=>a({...o,items:S.target.value})})]})]}),i.jsx("p",{className:"note",children:"Leave the amount blank if they did not buy anything — a visit without a sale is still worth recording."})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Consent"}),i.jsxs("label",{style:{display:"flex",gap:10,alignItems:"flex-start",fontSize:13,cursor:"pointer"},children:[i.jsx("input",{type:"checkbox",checked:l.consent,style:{marginTop:3},onChange:S=>s({...l,consent:S.target.checked})}),i.jsx("span",{children:"This customer agreed to us keeping their details and recognising them on future visits."})]}),i.jsx("p",{className:"note",style:{marginTop:10},children:"Recorded with the date and who collected it. They can withdraw it at any time, which erases their face data."})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Visits"}),i.jsx(Cp,{customer:e})]}),i.jsxs("div",{className:"sheetactions",children:[i.jsx("button",{type:"button",className:"btn",onClick:n,children:"Cancel"}),i.jsx("button",{className:"btn primary",disabled:u,children:u?"Saving…":"Save"})]}),m&&i.jsxs("section",{className:"formsection dangerzone",children:[i.jsx("h4",{children:"At the customer's request"}),h?i.jsx(_p,{customer:e,onCancel:()=>g(!1),onDone:r}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"note",children:"Erase this person's face data, photo and details. Their past visits stay in your footfall figures, without their name."}),i.jsx("button",{type:"button",className:"btn danger",onClick:()=>g(!0),children:"Erase this customer…"})]})]})]})]})})}function zp({session:e}){const[t,n]=N.useState(""),[r,l]=N.useState(null),{data:s,error:o,reload:a}=rt(()=>I.customers(t,200),3e4,[t]),u=s??[],c=u.filter(p=>p.has_profile).length;return i.jsxs("div",{className:"page",children:[i.jsxs("header",{className:"pagehead",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Customers"}),i.jsx("p",{children:"Everyone this business has recognised. Fill in details once and they are known at every store."})]}),i.jsxs("label",{className:"search",children:[i.jsx(Ec,{size:15}),i.jsx("input",{placeholder:"Search by name or phone",value:t,onChange:p=>n(p.target.value)})]})]}),o&&i.jsxs("div",{className:"err",children:[i.jsx(Ce,{size:15}),o]}),i.jsxs("div",{className:"metrics",style:{marginBottom:"var(--sp-4)"},children:[i.jsx(Tr,{k:"Known people",v:u.length||"—"}),i.jsx(Tr,{k:"With details",v:c||"—",s:u.length?`${Math.round(100*c/u.length)}% captured`:null}),i.jsx(Tr,{k:"Returning",v:u.filter(p=>p.visit_count>1).length||"—"}),i.jsx(Tr,{k:"With consent",v:u.filter(p=>p.has_consent).length||"—"})]}),i.jsx("div",{className:"panel",children:u.length===0?i.jsxs("div",{className:"empty tall",children:[i.jsx(zc,{size:34}),i.jsx("b",{children:"No customers yet"}),i.jsx("p",{children:"They appear here the first time a camera recognises them. Click one to add a name and phone number."})]}):i.jsx("div",{className:"tablewrap",children:i.jsxs("table",{children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Customer"}),i.jsx("th",{children:"Phone"}),i.jsx("th",{className:"num",children:"Visits"}),i.jsx("th",{children:"First seen"}),i.jsx("th",{children:"Last seen"}),i.jsx("th",{children:"Details"})]})}),i.jsx("tbody",{children:u.map(p=>i.jsxs("tr",{className:"click",onClick:()=>l(p),children:[i.jsxs("td",{children:[p.full_name||i.jsx("span",{className:"note",children:p.label}),p.full_name&&p.ref&&i.jsxs("span",{className:"note",children:[" · ",p.ref]})]}),i.jsx("td",{className:"mono",children:p.phone||"—"}),i.jsx("td",{className:"num",children:p.visit_count}),i.jsx("td",{children:oa(p.first_seen_at)}),i.jsx("td",{children:oa(p.last_seen_at)}),i.jsx("td",{children:p.has_profile?i.jsxs("span",{className:"pill ok",children:[i.jsx("i",{className:"dot ok"}),"captured"]}):i.jsxs("span",{className:"pill warn",children:[i.jsx("i",{className:"dot warn"}),"needed"]})})]},p.id))})]})})}),r&&i.jsx(Pp,{customer:r,session:e,onClose:()=>l(null),onSaved:()=>{l(null),a()}})]})}function Tr({k:e,v:t,s:n}){return i.jsxs("div",{className:"metric",children:[i.jsx("div",{className:"metric-k",children:e}),i.jsx("div",{className:"metric-v",children:t}),n&&i.jsx("div",{className:"metric-s",children:n})]})}const cn=[{id:"hikvision",label:"Hikvision",path:"/Streaming/Channels/101",note:"Channel 1, main stream. Use /Streaming/Channels/102 for the lower-quality sub stream."},{id:"dahua",label:"Dahua",path:"/cam/realmonitor?channel=1&subtype=0",note:"Channel 1, main stream. subtype=1 is the sub stream."},{id:"cpplus",label:"CP Plus",path:"/cam/realmonitor?channel=1&subtype=0",note:"CP Plus cameras use the Dahua stream path."},{id:"uniview",label:"Uniview",path:"/media/video1",note:"Some older Uniview models use /video1 instead."},{id:"tplink",label:"TP-Link / Tapo",path:"/stream1",note:"Tapo cameras need a separate camera account created in the Tapo app — your Tapo login will not work."},{id:"reolink",label:"Reolink",path:"/h264Preview_01_main",note:"Use /h264Preview_01_sub for the lower-quality stream."},{id:"amcrest",label:"Amcrest",path:"/cam/realmonitor?channel=1&subtype=0",note:"Amcrest cameras use the Dahua stream path."},{id:"axis",label:"Axis",path:"/axis-media/media.amp",note:""},{id:"onvif",label:"Other (ONVIF)",path:"/onvif1",note:"Many generic cameras answer here. If it does not work, look for “RTSP” in the camera’s own app."},{id:"manual",label:"I know the path",path:"",note:""}],Rr=e=>cn.find(t=>t.id===e)||cn[cn.length-1];function Lp(e){const t=String(e||"").trim();if(!t)return null;const n=/^[a-z][a-z0-9+.-]*:\/\//i.test(t);if(!n&&!t.includes("/"))return null;const r=n?t:"rtsp://"+t;let l;try{l=new URL(r)}catch{return null}return l.hostname?{host:l.hostname,port:Number(l.port)||554,path:(l.pathname||"")+(l.search||"")||"/",username:decodeURIComponent(l.username||""),password:decodeURIComponent(l.password||"")}:null}const ei={id:"",host:"",port:554,path:"",username:"",password:"",max_width:1280},zn="webcam";function Tp(){const{data:e,error:t,reload:n}=rt(()=>I.cameras(),8e3),[r,l]=N.useState(null),[s,o]=N.useState(null),a=e??[],u=a.some(y=>y.remote),c=Mp(u?[]:a),[p,v]=N.useState(null),[h,g]=N.useState("");N.useEffect(()=>{let y=!0;if(!p){g("");return}return I.remoteStreamURL(p).then(z=>{y&&g(z||"")}).catch(()=>{y&&g("")}),()=>{y=!1}},[p]);async function x(y){if(confirm(`Remove ${y.id}? Recognition from it stops immediately.`))try{await I.deleteCamera(y.id),n()}catch(z){alert(pe(z))}}return i.jsxs("div",{className:"page",children:[i.jsxs("header",{className:"pagehead",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Cameras"}),i.jsx("p",{children:u?"The cameras across your shops, as the shop computers last reported them.":"Add a camera, then prove it can see faces with a walk-past. Only then is it working."})]}),!u&&i.jsxs("button",{className:"btn primary",onClick:()=>l({...ei}),children:[i.jsx(aa,{size:15}),"Add camera"]})]}),u&&i.jsxs("div",{className:"viewing",children:[i.jsx("b",{children:"Viewing your shops from here."})," These cameras are wired to the shop computers, so they are set up and checked there. Each tile shows that camera's most recent frame; ",i.jsx("b",{children:"Watch live"})," asks the shop computer to send video for as long as you are looking."]}),t&&i.jsxs("div",{className:"err",children:[i.jsx(Ce,{size:15}),t]}),a.length===0?i.jsx("div",{className:"panel",children:i.jsxs("div",{className:"empty tall",children:[i.jsx(Pc,{size:40}),i.jsx("b",{children:"No cameras yet"}),i.jsx("p",{children:"Add the camera by its address. Most cameras print it on a label underneath, or show it in their own app."}),i.jsxs("button",{className:"btn primary",onClick:()=>l({...ei}),children:[i.jsx(aa,{size:15}),"Add your first camera"]})]})}):i.jsx("div",{className:"camgrid",children:a.map(y=>i.jsx(Rp,{cam:y,stream:p===y.id?h:c[y.id],watching:p===y.id,onWatch:()=>v(p===y.id?null:y.id),onEdit:()=>l(y),onCheck:()=>o(y.id),onRemove:()=>x(y)},y.id))}),r&&i.jsx(Dp,{cam:r,onClose:()=>l(null),onSaved:()=>{l(null),n()}}),s&&i.jsx(Op,{id:s,onClose:()=>o(null)})]})}function Rp({cam:e,stream:t,watching:n,onWatch:r,onEdit:l,onCheck:s,onRemove:o}){var v,h,g;const a=e.remote?{connected:{tone:"ok",label:"Connected"},not_connecting:{tone:"bad",label:"Not connecting"},stale:{tone:"warn",label:"Not reporting"}}[e.state]||{tone:"idle",label:"Waiting for the shop computer"}:e.connected===void 0||e.connected===null?{tone:"idle",label:"Engine stopped"}:e.connected?{tone:"ok",label:"Connected"}:{tone:"bad",label:"Not connecting"},{data:u}=rt(()=>e.remote?Promise.resolve(null):I.placementResult(e.id),15e3,[e.id]),c=!u||u.running||!u.verdict||u.verdict==="starting"?{tone:"miss",label:"Not yet proven",text:"Walk past it once and Behavision will tell you if the placement works."}:u.verdict==="good"?{tone:"seen",label:"Proven",text:u.headline||"Faces recognised on a walk-past."}:{tone:"miss",label:"Not proven",text:u.headline||"Move the camera and check again."},p=(v=e.snapshot)!=null&&v.available?e.snapshot.url:"";return i.jsxs("article",{className:"camcard",children:[i.jsxs("div",{className:"camview",children:[t||p?i.jsx("img",{src:t||p,alt:e.id}):i.jsx("div",{className:"placeholder",children:i.jsx(Pc,{size:34})}),i.jsxs("span",{className:`pill ${a.tone==="idle"?"":a.tone} over`,children:[i.jsx("i",{className:`dot ${a.tone}`}),a.label]}),e.remote&&i.jsxs("button",{className:`btn sm watch ${n?"on":""}`,onClick:r,children:[i.jsx(bs,{size:13}),n?"Stop watching":"Watch live"]})]}),i.jsxs("div",{className:"cambody",children:[i.jsxs("div",{className:"camtitle",children:[i.jsxs("div",{children:[i.jsx("h3",{children:e.label||e.camera_id||e.id}),i.jsx("span",{className:"mono note",children:e.remote?e.site||e.site_slug||"":`${e.host||e.url}${e.path?` · ${e.path}`:""}`})]}),!e.remote&&i.jsxs("div",{className:"camactions",children:[i.jsx("button",{className:"btn sm",onClick:l,children:"Edit"}),i.jsx("button",{className:"btn sm danger",onClick:o,children:"Remove"})]})]}),e.remote?i.jsx("div",{className:"camproof",children:i.jsx("span",{className:"note",children:e.state_note?e.state_note:n?"Live from the shop computer. It uploads only while you watch.":(h=e.snapshot)!=null&&h.available?"Last picture from the shop computer. Watch live to see it now.":((g=e.snapshot)==null?void 0:g.reason)||"No picture yet from the shop computer."})}):i.jsxs("div",{className:"camproof",children:[i.jsx("span",{className:`tag ${c.tone}`,children:c.label}),i.jsx("span",{className:"note",children:c.text}),i.jsxs("button",{className:`btn sm ${c.tone==="seen"?"":"primary"}`,onClick:s,children:[i.jsx(bs,{size:13}),c.tone==="seen"?"Check again":"Check placement"]})]})]})]})}function Mp(e){const[t,n]=N.useState({});return N.useEffect(()=>{let r=!0;const l=e.filter(s=>!(s.id in t));if(l.length)return(async()=>{const s={};for(const o of l)try{s[o.id]=await I.streamURL(o.id)}catch{s[o.id]=""}r&&n(o=>({...o,...s}))})(),()=>{r=!1}},[e.map(r=>r.id).join("|")]),t}function Dp({cam:e,onClose:t,onSaved:n}){var Wt;const r=!e.id,[l,s]=N.useState({...ei,...e,password:"",path:e.path||(r?cn[0].path:"")}),[o,a]=N.useState(r?cn[0].id:e.webcam!=null?zn:"manual"),[u,c]=N.useState(e.webcam!=null?String(e.webcam):"0"),p=o===zn,[v,h]=N.useState(null),[g,x]=N.useState(null),[y,z]=N.useState(null),f=T=>j=>s({...l,[T]:j.target.value});function d(T){if(T.target.value===zn){a(zn),h(null);return}const j=Rr(T.target.value);a(j.id),s(L=>({...L,path:j.path||L.path}))}function m(){const T={};for(const[j,L]of Object.entries(l))L===""||L===null||L===void 0||(T[j]=j==="port"||j==="max_width"?Number(L):L);if(p){for(const j of["host","path","username","password"])delete T[j];T.webcam=Number(u)||0}return T}async function w(){x("test"),z(null),h(null);try{h(await I.testCamera(m()))}catch(T){z(pe(T))}finally{x(null)}}async function C(T){T.preventDefault(),x("save"),z(null);try{await I.saveCamera(r?"":e.id,m()),n()}catch(j){z(pe(j))}finally{x(null)}}const _=Rr(o),[S,P]=N.useState(""),[U,R]=N.useState("");function je(T){if(P(T),!T.trim()){R("");return}const j=Lp(T);if(!j){R("That does not look like an RTSP address.");return}R(""),h(null),s(L=>({...L,host:j.host,port:j.port,path:j.path,...j.username?{username:j.username}:{},...j.password?{password:j.password}:{}})),a("manual")}const[ee,Ye]=N.useState(null);async function Vt(){Ye("busy");try{Ye(await I.discoverCameras())}catch(T){Ye({error:pe(T)})}}function Tl(T){const j=T.make?Rr(T.make):null;s(L=>({...L,host:T.host,path:(j==null?void 0:j.path)||L.path,id:L.id||""})),j&&a(j.id),h(null)}return i.jsx("div",{className:"drawer",onMouseDown:T=>T.target===T.currentTarget&&t(),children:i.jsxs("div",{className:"sheet",children:[i.jsxs("div",{className:"sheethead",children:[i.jsx("h2",{children:r?"Add a camera":`Edit ${e.id}`}),i.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:i.jsx(Xi,{size:16})})]}),i.jsxs("form",{className:"sheetbody",onSubmit:C,autoComplete:"off",children:[i.jsx("p",{className:"lead",children:"Three things from the camera: its address, its make, and its password. Test before you save — a wrong address is the most common mistake."}),y&&i.jsxs("div",{className:"err",children:[i.jsx(Ce,{size:15}),y]}),r&&!p&&i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Find it"}),ee===null&&i.jsxs("div",{className:"finder",children:[i.jsx("p",{children:"Behavision can look for cameras on this shop’s network."}),i.jsxs("button",{type:"button",className:"btn primary",onClick:Vt,children:[i.jsx(Ec,{size:14}),"Find cameras on this network"]})]}),ee==="busy"&&i.jsxs("div",{className:"finder busy",children:[i.jsx("span",{className:"spinner"}),"Looking on the network… a few seconds."]}),(ee==null?void 0:ee.error)&&i.jsxs("div",{className:"err",children:[i.jsx(Ce,{size:15}),ee.error]}),(ee==null?void 0:ee.cameras)&&(ee.cameras.length===0?i.jsxs("div",{className:"finder",children:[i.jsxs("p",{children:["Nothing answered on ",((Wt=ee.networks)==null?void 0:Wt.join(", "))||"this network",". The camera may be on a different network, switched off, or not yet connected — check its cable and power, then try again. You can still type its address below."]}),i.jsx("button",{type:"button",className:"btn",onClick:Vt,children:"Try again"})]}):i.jsxs("ul",{className:"foundlist",children:[ee.cameras.map(T=>i.jsx("li",{className:l.host===T.host?"picked":"",children:i.jsxs("button",{type:"button",onClick:()=>Tl(T),children:[i.jsx("span",{className:"mono",children:T.host}),i.jsx("span",{className:"what",children:T.name||(T.rtsp?"Streams video (RTSP)":"Answers ONVIF")}),T.make&&i.jsx("span",{className:"tag seen",children:Rr(T.make).label}),l.host===T.host&&i.jsx(qs,{size:16})]})},T.host)),i.jsx("li",{className:"rescan",children:i.jsx("button",{type:"button",className:"btn sm",onClick:Vt,children:"Scan again"})})]}))]}),r&&!p&&i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Paste its address"}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"RTSP address"}),i.jsx("input",{className:"mono",value:S,onChange:T=>je(T.target.value),placeholder:"rtsp://admin:password@192.168.1.20:554/ch0_0.264",autoComplete:"off",name:"rtsp-url",spellCheck:"false"}),i.jsx("em",{className:"hint",children:U||"If the camera’s own app shows an RTSP address, paste it here and the fields below fill in. Otherwise leave this empty and fill them in yourself."})]})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"The camera"}),r&&i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Name"}),i.jsx("input",{value:l.id,onChange:f("id"),placeholder:"entrance",required:!0,autoFocus:!0}),i.jsx("em",{className:"hint",children:"Short, no spaces. It names this camera everywhere and cannot be changed later."})]}),p?i.jsxs("label",{className:"field narrow",children:[i.jsx("span",{children:"Camera number"}),i.jsx("input",{value:u,onChange:T=>{c(T.target.value),h(null)},inputMode:"numeric"}),i.jsx("em",{className:"hint",children:"0 is the built-in camera. Try 1 if a second one is plugged in."})]}):i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Address"}),i.jsx("input",{value:l.host,onChange:f("host"),placeholder:"192.168.1.20",inputMode:"decimal"}),i.jsx("em",{className:"hint",children:"On a label on the camera, or in its own app under “network”."})]}),i.jsxs("label",{className:"field narrow",children:[i.jsx("span",{children:"Port"}),i.jsx("input",{value:l.port,onChange:f("port"),inputMode:"numeric"})]})]})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"The stream"}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Make of camera"}),i.jsxs("select",{value:o,onChange:d,children:[cn.map(T=>i.jsx("option",{value:T.id,children:T.label},T.id)),i.jsx("option",{value:zn,children:"This computer’s own camera"})]}),p?i.jsx("em",{className:"hint",children:"Recognition runs on this computer’s built-in or plugged-in camera. Nothing on the network is involved."}):_.note&&i.jsx("em",{className:"hint",children:_.note})]}),!p&&i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Stream path"}),i.jsx("input",{className:"mono",value:l.path,onChange:f("path"),placeholder:"/Streaming/Channels/101"}),i.jsx("em",{className:"hint",children:"Filled in from the make. Change it only if the camera’s own app says something else."})]})]}),!p&&i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Sign-in to the camera"}),i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Username"}),i.jsx("input",{name:"rtsp-account",autoComplete:"off",value:l.username,onChange:f("username"),placeholder:"admin"})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Password"}),i.jsx("input",{type:"password",name:"rtsp-secret",autoComplete:"new-password",value:l.password,onChange:f("password"),placeholder:e.has_password?"(unchanged)":""})]})]})]}),v&&(v.ok?i.jsxs("div",{className:"testresult ok",children:[i.jsx(qs,{size:16}),i.jsxs("div",{children:[i.jsxs("b",{children:["Connected — ",v.width,"×",v.height,v.codec?` · ${String(v.codec).toUpperCase()}`:""]}),v.snapshot&&i.jsx("img",{alt:"Camera preview",src:`data:image/jpeg;base64,${v.snapshot}`})]})]}):i.jsxs("div",{className:"testresult bad",children:[i.jsx(Ce,{size:16}),i.jsxs("div",{children:[i.jsx("b",{children:"Could not connect"}),i.jsx("span",{children:v.error})]})]})),i.jsxs("div",{className:"sheetactions",children:[i.jsx("button",{type:"button",className:"btn",onClick:w,disabled:!!g||!l.host,children:g==="test"?"Connecting…":"Test connection"}),i.jsx("button",{className:"btn primary",disabled:!!g||!l.id||!l.host,children:g==="save"?"Saving…":r?"Add camera":"Save changes"})]})]})]})})}function Op({id:e,onClose:t}){var p,v;const[n,r]=N.useState({verdict:"starting",advice:[]}),[l,s]=N.useState(null),o=N.useRef(null);N.useEffect(()=>{let h=!0;return(async()=>{try{r(await I.startPlacement(e,25)),o.current=setInterval(async()=>{try{const g=await I.placementResult(e);if(!h)return;r(g),g.running||clearInterval(o.current)}catch(g){h&&s(pe(g))}},1e3)}catch(g){h&&s(pe(g))}})(),()=>{h=!1,clearInterval(o.current)}},[e]);const a={good:"ok",marginal:"warn",poor:"bad",artifact:"bad",no_faces:"warn",inconclusive:"warn",no_completed_passes:"warn"}[n.verdict],u=n.seconds?Math.min(100,n.elapsed/n.seconds*100):0,c=n.running||n.verdict==="starting";return i.jsx("div",{className:"drawer",onMouseDown:h=>h.target===h.currentTarget&&t(),children:i.jsxs("div",{className:"sheet",children:[i.jsxs("div",{className:"sheethead",children:[i.jsxs("h2",{children:["Check placement · ",e]}),i.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:i.jsx(Xi,{size:16})})]}),i.jsxs("div",{className:"sheetbody",children:[l&&i.jsxs("div",{className:"err",children:[i.jsx(Ce,{size:15}),l]}),i.jsxs("ol",{className:"steps",children:[i.jsxs("li",{className:c?"now":"done",children:[i.jsx("b",{children:"Walk past the camera"}),i.jsx("span",{children:"The way a customer would — in through the door, not looking at the lens. Two or three times, for about 25 seconds."}),c&&i.jsx("div",{className:"progress",children:i.jsx("div",{style:{width:`${u}%`}})})]}),i.jsxs("li",{className:c?"":"now",children:[i.jsx("b",{children:"Behavision judges what it saw"}),i.jsx("span",{children:"Not “were the frames sharp”, but “did a person walking past produce a face worth recognising”."})]})]}),i.jsxs("div",{className:`verdict ${a??""}`,children:[i.jsxs("div",{className:"verdict-head",children:[c?i.jsx("span",{className:"spinner"}):a==="ok"?i.jsx(qs,{size:18}):i.jsx(Ce,{size:18}),i.jsx("b",{children:n.headline||"Watching…"})]}),((p=n.advice)==null?void 0:p.length)>0&&i.jsx("ul",{children:n.advice.map((h,g)=>i.jsx("li",{children:h},g))}),((v=n.quality)==null?void 0:v.n)>0&&i.jsxs("p",{className:"note",children:[n.quality.n," face",n.quality.n===1?"":"s"," seen · median quality ",n.quality.p50," ·"," ",Math.round((n.quality.fraction_below_gate??0)*100),"% too poor to use"]})]}),!c&&i.jsxs("div",{className:"sheetactions",children:[i.jsx("button",{className:"btn",onClick:t,children:"Close"}),i.jsx("button",{className:"btn primary",onClick:()=>{r({verdict:"starting",advice:[]}),I.startPlacement(e,25).then(r).catch(h=>s(pe(h)))},children:"Run again"})]})]})]})})}const Fp=["Is my shop working right now?","How do I add my camera?","Why has nobody been recognised today?","Who came in this morning?"];function Ip({session:e,onClose:t}){const[n,r]=N.useState([]),[l,s]=N.useState(""),[o,a]=N.useState(!1),[u,c]=N.useState(null),p=N.useRef(null),v=e==null?void 0:e.standalone;N.useEffect(()=>{var g;(g=p.current)==null||g.scrollTo({top:1e9,behavior:"smooth"})},[n,o]);async function h(g){const x=(g??l).trim();if(!x||o)return;const y=[...n,{role:"user",text:x}];r(y),s(""),a(!0),c(null);try{const z=await I.ask(y.map(f=>({role:f.role,text:f.text})));r([...y,{role:"assistant",text:z.text,used:z.used??[]}])}catch(z){const f=pe(z);c(/session expired|unauthori[sz]ed/i.test(f)?"You’re signed out of head office, so I can’t look anything up. Sign in again and ask me once more.":f),r(n),s(x)}finally{a(!1)}}return i.jsxs("aside",{className:"helper",role:"dialog","aria-label":"Loya",children:[i.jsxs("header",{className:"helperhead",children:[i.jsx("img",{src:wt,alt:""}),i.jsxs("div",{children:[i.jsx("b",{children:"Loya"}),i.jsx("span",{children:"Your Behavision buddy — knows your cameras, your customers and your numbers."})]}),i.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:i.jsx(Xi,{size:16})})]}),i.jsxs("div",{className:"helperbody",ref:p,children:[v&&i.jsxs("div",{className:"helpernote",children:[i.jsx(_c,{size:16}),i.jsxs("div",{children:[i.jsx("b",{children:"This PC runs on its own"}),i.jsx("span",{children:"Loya lives at head office. Link this PC to a shop to talk to her; the basics are below."})]})]}),n.length===0&&i.jsxs("div",{className:"helperintro",children:[i.jsx("div",{className:"turn assistant",children:i.jsxs("div",{className:"bubble",children:[$p(e)," Ask me anything about ",(e==null?void 0:e.site_name)||"this shop"," — what’s happening now, or how to set something up."]})}),i.jsx("div",{className:"chips",children:Fp.map(g=>i.jsx("button",{className:"chip",onClick:()=>h(g),disabled:o||v,children:g},g))}),v&&i.jsx(Up,{})]}),n.map((g,x)=>{var y;return i.jsxs("div",{className:`turn ${g.role}`,children:[i.jsx("div",{className:"bubble",children:g.text}),((y=g.used)==null?void 0:y.length)>0&&i.jsxs("span",{className:"used",children:["Looked at: ",g.used.join(", ")]})]},x)}),o&&i.jsx("div",{className:"turn assistant",children:i.jsxs("div",{className:"bubble thinking",children:[i.jsx("span",{}),i.jsx("span",{}),i.jsx("span",{})]})}),u&&i.jsxs("div",{className:"err",children:[i.jsx(Ce,{size:15}),u]})]}),i.jsxs("form",{className:"helperask",onSubmit:g=>{g.preventDefault(),h()},children:[i.jsx("input",{value:l,onChange:g=>s(g.target.value),disabled:o||v,placeholder:v?"Link this PC to head office to talk to Loya":"Ask Loya…"}),i.jsx("button",{className:"btn primary",disabled:o||v||!l.trim(),"aria-label":"Ask",children:i.jsx(mp,{size:16})})]})]})}function $p(e){var l,s;const t=new Date().getHours(),n=t<12?"Morning":t<17?"Afternoon":"Evening",r=(s=(l=e==null?void 0:e.user)==null?void 0:l.full_name)==null?void 0:s.split(" ")[0];return r?`${n}, ${r}.`:`${n}.`}function Up(){return i.jsxs("dl",{className:"quickhelp",children:[i.jsx("dt",{children:"Adding a camera"}),i.jsx("dd",{children:"Cameras → Add camera. The address is on a label on the camera; pick the make and the stream path fills itself in. Test, then save."}),i.jsx("dt",{children:"Proving it works"}),i.jsx("dd",{children:"Press Check placement and walk past the camera like a customer for 25 seconds. Only “good” means it can recognise faces — otherwise move it to head height, facing the way people approach."}),i.jsx("dt",{children:"Nothing showing on Live"}),i.jsx("dd",{children:"Check the camera is Connected and Proven. A camera aimed from above or the side streams fine and recognises nobody."}),i.jsx("dt",{children:"Linking to head office later"}),i.jsx("dd",{children:"Use the link button at the bottom of the sidebar and type an installation code from head office. Nothing recorded here is lost."})]})}const Ap=[{id:"live",label:"Live",Glyph:ap,View:Lc},{id:"customers",label:"Customers",Glyph:up,View:zp,cloud:!0},{id:"cameras",label:"Cameras",Glyph:cp,View:Tp}];function Bp(){var h,g,x;const[e,t]=N.useState(null),[n,r]=N.useState("live"),[l,s]=N.useState(!0),[o,a]=N.useState(!1),[u,c]=N.useState(!1);if(N.useEffect(()=>{let y=!0;const z=async()=>{try{const d=await I.session();y&&t(m=>JSON.stringify(m)===JSON.stringify(d)?m:d)}catch{y&&t(null)}y&&s(!1)};z();const f=setInterval(z,8e3);return()=>{y=!1,clearInterval(f)}},[]),!ip())return i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsx("h1",{children:"Behavision"}),i.jsx("p",{className:"lead",children:"This is the Behavision window running outside the app, so it has no connection to the recognition engine. Launch the Behavision application instead."})]})});if(l)return i.jsx("div",{className:"login",children:i.jsx("p",{className:"note",children:"Starting…"})});if(!(e!=null&&e.claimed)&&!(e!=null&&e.standalone))return i.jsx(da,{onDone:t});if(!(e!=null&&e.standalone)&&!(e!=null&&e.logged_in))return i.jsx(vp,{onDone:t});const p=Ap.filter(y=>!y.cloud||!e.standalone),v=((h=p.find(y=>y.id===n))==null?void 0:h.View)??Lc;return o?i.jsx(da,{onDone:y=>{a(!1),t(y)},onCancel:()=>a(!1)}):i.jsxs("div",{className:"shell",children:[i.jsxs("aside",{className:"side",children:[i.jsxs("div",{className:"brand",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsxs("div",{className:"id",children:[i.jsx("h1",{children:"Behavision"}),i.jsx("p",{children:e.site_name||((g=e.user)==null?void 0:g.client_name)||"This shop"})]})]}),i.jsx("nav",{className:"nav",children:p.map(({id:y,label:z,Glyph:f})=>i.jsxs("button",{onClick:()=>r(y),"aria-current":y===n?"page":void 0,children:[i.jsx(f,{size:17}),z]},y))}),i.jsx(Vp,{}),i.jsx("div",{className:"who",children:e.standalone?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"id",children:[i.jsx("b",{children:"On its own"}),i.jsx("span",{children:"No head office"})]}),i.jsx("button",{className:"btn sm icon",title:"Link to head office",onClick:()=>a(!0),children:i.jsx(pp,{size:15})})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"id",children:[i.jsx("b",{children:"Signed in"}),i.jsx("span",{children:(x=e.user)==null?void 0:x.email})]}),i.jsx("button",{className:"btn sm icon",title:"Sign out",onClick:async()=>t(await I.logout()),children:i.jsx(hp,{size:15})})]})})]}),i.jsxs("main",{className:"main",children:[i.jsx(v,{session:e,onNavigate:r}),!u&&i.jsxs("button",{className:"loya-fab",onClick:()=>c(!0),"aria-label":"Ask Loya",title:"Ask Loya",children:[i.jsx("img",{src:wt,alt:""}),i.jsx("span",{children:"Loya"})]})]}),u&&i.jsx(Ip,{session:e,onClose:()=>c(!1)})]})}function Vp(){const{data:e,reload:t}=rt(()=>I.engineStatus(),5e3),[n,r]=N.useState(!1),l=e??{state:"stopped"},s=N.useCallback(async v=>{r(!0);try{await v()}catch(h){alert(pe(h))}finally{r(!1),t()}},[t]),o=l.state==="running",a=Object.values(l.cameras??{}),u=a.filter(Boolean).length;let c="idle",p="Stopped";return!o&&l.reachable?(c="warn",p="Running outside the app"):l.state==="failed"||l.state==="backoff"?(c="bad",p="Not running"):o&&!l.reachable&&l.progress?(c="warn",p=`Downloading ${l.progress.what}… ${l.progress.percent}%`):o&&!l.reachable?(c="warn",p="Starting…"):o&&a.length===0?(c="warn",p="No cameras"):o&&u===0?(c="bad",p="No camera connected"):o&&us(I.startEngine),children:[i.jsx(bs,{size:13}),"Start"]}),i.jsxs("button",{className:"btn sm",disabled:n||!o,onClick:()=>s(I.stopEngine),children:[i.jsx(dp,{size:13}),"Stop"]})]})]})}Nc(document.getElementById("root")).render(i.jsx(Yc.StrictMode,{children:i.jsx(Bp,{})})); diff --git a/desktop/frontend/dist/index.html b/desktop/frontend/dist/index.html index 8322aa2..676db29 100644 --- a/desktop/frontend/dist/index.html +++ b/desktop/frontend/dist/index.html @@ -4,7 +4,7 @@ Behavision - + diff --git a/desktop/frontend/src/views/Cameras.jsx b/desktop/frontend/src/views/Cameras.jsx index a786a15..4942544 100644 --- a/desktop/frontend/src/views/Cameras.jsx +++ b/desktop/frontend/src/views/Cameras.jsx @@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from 'react' import { api, message } from '../bridge.js' import { usePolled } from '../hooks.js' import * as Icon from '../ui/icons.jsx' -import { MAKES, makeById } from '../../../../shared/cameraMakes.js' +import { MAKES, makeById, parseRtspUrl } from '../../../../shared/cameraMakes.js' // The camera screen is a picture, not a settings table. // @@ -253,6 +253,27 @@ function CameraSheet({ cam, onClose, onSaved }) { const chosen = makeById(make) + // Paste the whole RTSP URL. It is how people actually hold this + // information - it is what the camera's own app shows and what an installer + // writes down - and splitting it into five fields by eye is exactly where a + // password containing `@` or `/` goes wrong. + const [pasted, setPasted] = useState('') + const [pasteError, setPasteError] = useState('') + function applyUrl(text) { + setPasted(text) + if (!text.trim()) { setPasteError(''); return } + const got = parseRtspUrl(text) + if (!got) { setPasteError('That does not look like an RTSP address.'); return } + setPasteError('') + setTest(null) + // Only what the URL actually carried: a URL with no credentials must not + // wipe a password the operator typed above it. + setF(prev => ({ ...prev, host: got.host, port: got.port, path: got.path, + ...(got.username ? { username: got.username } : {}), + ...(got.password ? { password: got.password } : {}) })) + setMake('manual') + } + // The camera is picked from a scan of the shop's network rather than typed. // Nobody knows their camera's address; the sticker is under the camera and // the menu is different in every make's app. The scan names ONVIF cameras @@ -316,6 +337,20 @@ function CameraSheet({ cam, onClose, onSaved }) { )} + {isNew && !local && ( +
+

Paste its address

+ +
+ )} +

The camera

{isNew && ( diff --git a/server/internal/web/dist/assets/index-BuVkBNdU.js b/server/internal/web/dist/assets/index-BAlXnnln.js similarity index 69% rename from server/internal/web/dist/assets/index-BuVkBNdU.js rename to server/internal/web/dist/assets/index-BAlXnnln.js index d6df532..972c82c 100644 --- a/server/internal/web/dist/assets/index-BuVkBNdU.js +++ b/server/internal/web/dist/assets/index-BAlXnnln.js @@ -1,4 +1,4 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const s of l)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(l){const s={};return l.integrity&&(s.integrity=l.integrity),l.referrerPolicy&&(s.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?s.credentials="include":l.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(l){if(l.ep)return;l.ep=!0;const s=n(l);fetch(l.href,s)}})();var da={exports:{}},pl={},fa={exports:{}},R={};/** +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const s of l)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(l){const s={};return l.integrity&&(s.integrity=l.integrity),l.referrerPolicy&&(s.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?s.credentials="include":l.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(l){if(l.ep)return;l.ep=!0;const s=n(l);fetch(l.href,s)}})();var da={exports:{}},pl={},fa={exports:{}},I={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var tr=Symbol.for("react.element"),_c=Symbol.for("react.portal"),Pc=Symbol.for("react.fragment"),Tc=Symbol.for("react.strict_mode"),zc=Symbol.for("react.profiler"),Lc=Symbol.for("react.provider"),Rc=Symbol.for("react.context"),Oc=Symbol.for("react.forward_ref"),Ic=Symbol.for("react.suspense"),Fc=Symbol.for("react.memo"),Dc=Symbol.for("react.lazy"),Zi=Symbol.iterator;function Mc(e){return e===null||typeof e!="object"?null:(e=Zi&&e[Zi]||e["@@iterator"],typeof e=="function"?e:null)}var pa={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ha=Object.assign,ma={};function dn(e,t,n){this.props=e,this.context=t,this.refs=ma,this.updater=n||pa}dn.prototype.isReactComponent={};dn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};dn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function va(){}va.prototype=dn.prototype;function ei(e,t,n){this.props=e,this.context=t,this.refs=ma,this.updater=n||pa}var ti=ei.prototype=new va;ti.constructor=ei;ha(ti,dn.prototype);ti.isPureReactComponent=!0;var qi=Array.isArray,ya=Object.prototype.hasOwnProperty,ni={current:null},ga={key:!0,ref:!0,__self:!0,__source:!0};function wa(e,t,n){var r,l={},s=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(s=""+t.key),t)ya.call(t,r)&&!ga.hasOwnProperty(r)&&(l[r]=t[r]);var a=arguments.length-2;if(a===1)l.children=n;else if(1>>1,q=E[G];if(0>>1;Gl(Rl,L))wtl(dr,Rl)?(E[G]=dr,E[wt]=L,G=wt):(E[G]=Rl,E[gt]=L,G=gt);else if(wtl(dr,L))E[G]=dr,E[wt]=L,G=wt;else break e}}return z}function l(E,z){var L=E.sortIndex-z.sortIndex;return L!==0?L:E.id-z.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();e.unstable_now=function(){return o.now()-a}}var u=[],c=[],m=1,h=null,v=3,y=!1,x=!1,g=!1,N=typeof setTimeout=="function"?setTimeout:null,f=typeof clearTimeout=="function"?clearTimeout:null,d=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function p(E){for(var z=n(c);z!==null;){if(z.callback===null)r(c);else if(z.startTime<=E)r(c),z.sortIndex=z.expirationTime,t(u,z);else break;z=n(c)}}function w(E){if(g=!1,p(E),!x)if(n(u)!==null)x=!0,zl(S);else{var z=n(c);z!==null&&Ll(w,z.startTime-E)}}function S(E,z){x=!1,g&&(g=!1,f(T),T=-1),y=!0;var L=v;try{for(p(z),h=n(u);h!==null&&(!(h.expirationTime>z)||E&&!Te());){var G=h.callback;if(typeof G=="function"){h.callback=null,v=h.priorityLevel;var q=G(h.expirationTime<=z);z=e.unstable_now(),typeof q=="function"?h.callback=q:h===n(u)&&r(u),p(z)}else r(u);h=n(u)}if(h!==null)var cr=!0;else{var gt=n(c);gt!==null&&Ll(w,gt.startTime-z),cr=!1}return cr}finally{h=null,v=L,y=!1}}var _=!1,P=null,T=-1,K=5,O=-1;function Te(){return!(e.unstable_now()-OE||125G?(E.sortIndex=L,t(c,E),n(u)===null&&E===n(c)&&(g?(f(T),T=-1):g=!0,Ll(w,L-G))):(E.sortIndex=q,t(u,E),x||y||(x=!0,zl(S))),E},e.unstable_shouldYield=Te,e.unstable_wrapCallback=function(E){var z=v;return function(){var L=v;v=z;try{return E.apply(this,arguments)}finally{v=L}}}})(Na);Sa.exports=Na;var Yc=Sa.exports;/** + */(function(e){function t(_,R){var O=_.length;_.push(R);e:for(;0>>1,q=_[G];if(0>>1;Gl(Rl,O))wtl(dr,Rl)?(_[G]=dr,_[wt]=O,G=wt):(_[G]=Rl,_[gt]=O,G=gt);else if(wtl(dr,O))_[G]=dr,_[wt]=O,G=wt;else break e}}return R}function l(_,R){var O=_.sortIndex-R.sortIndex;return O!==0?O:_.id-R.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();e.unstable_now=function(){return o.now()-a}}var u=[],c=[],m=1,p=null,v=3,y=!1,w=!1,g=!1,C=typeof setTimeout=="function"?setTimeout:null,f=typeof clearTimeout=="function"?clearTimeout:null,d=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function h(_){for(var R=n(c);R!==null;){if(R.callback===null)r(c);else if(R.startTime<=_)r(c),R.sortIndex=R.expirationTime,t(u,R);else break;R=n(c)}}function x(_){if(g=!1,h(_),!w)if(n(u)!==null)w=!0,zl(N);else{var R=n(c);R!==null&&Ll(x,R.startTime-_)}}function N(_,R){w=!1,g&&(g=!1,f(S),S=-1),y=!0;var O=v;try{for(h(R),p=n(u);p!==null&&(!(p.expirationTime>R)||_&&!Te());){var G=p.callback;if(typeof G=="function"){p.callback=null,v=p.priorityLevel;var q=G(p.expirationTime<=R);R=e.unstable_now(),typeof q=="function"?p.callback=q:p===n(u)&&r(u),h(R)}else r(u);p=n(u)}if(p!==null)var cr=!0;else{var gt=n(c);gt!==null&&Ll(x,gt.startTime-R),cr=!1}return cr}finally{p=null,v=O,y=!1}}var T=!1,P=null,S=-1,z=5,L=-1;function Te(){return!(e.unstable_now()-L_||125<_?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<_?Math.floor(1e3/_):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(_){switch(v){case 1:case 2:case 3:var R=3;break;default:R=v}var O=v;v=R;try{return _()}finally{v=O}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(_,R){switch(_){case 1:case 2:case 3:case 4:case 5:break;default:_=3}var O=v;v=_;try{return R()}finally{v=O}},e.unstable_scheduleCallback=function(_,R,O){var G=e.unstable_now();switch(typeof O=="object"&&O!==null?(O=O.delay,O=typeof O=="number"&&0G?(_.sortIndex=O,t(c,_),n(u)===null&&_===n(c)&&(g?(f(S),S=-1):g=!0,Ll(x,O-G))):(_.sortIndex=q,t(u,_),w||y||(w=!0,zl(N))),_},e.unstable_shouldYield=Te,e.unstable_wrapCallback=function(_){var R=v;return function(){var O=v;v=R;try{return _.apply(this,arguments)}finally{v=O}}}})(Na);Sa.exports=Na;var Yc=Sa.exports;/** * @license React * react-dom.production.min.js * @@ -30,17 +30,17 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Xc=j,xe=Yc;function k(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),is=Object.prototype.hasOwnProperty,Jc=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,eo={},to={};function Zc(e){return is.call(to,e)?!0:is.call(eo,e)?!1:Jc.test(e)?to[e]=!0:(eo[e]=!0,!1)}function qc(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function bc(e,t,n,r){if(t===null||typeof t>"u"||qc(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function de(e,t,n,r,l,s,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=o}var re={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){re[e]=new de(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];re[t]=new de(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){re[e]=new de(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){re[e]=new de(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){re[e]=new de(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){re[e]=new de(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){re[e]=new de(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){re[e]=new de(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){re[e]=new de(e,5,!1,e.toLowerCase(),null,!1,!1)});var li=/[\-:]([a-z])/g;function si(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(li,si);re[t]=new de(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(li,si);re[t]=new de(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(li,si);re[t]=new de(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){re[e]=new de(e,1,!1,e.toLowerCase(),null,!1,!1)});re.xlinkHref=new de("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){re[e]=new de(e,1,!1,e.toLowerCase(),null,!0,!0)});function ii(e,t,n,r){var l=re.hasOwnProperty(t)?re[t]:null;(l!==null?l.type!==0:r||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),is=Object.prototype.hasOwnProperty,Jc=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,eo={},to={};function Zc(e){return is.call(to,e)?!0:is.call(eo,e)?!1:Jc.test(e)?to[e]=!0:(eo[e]=!0,!1)}function qc(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function bc(e,t,n,r){if(t===null||typeof t>"u"||qc(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function de(e,t,n,r,l,s,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=o}var re={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){re[e]=new de(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];re[t]=new de(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){re[e]=new de(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){re[e]=new de(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){re[e]=new de(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){re[e]=new de(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){re[e]=new de(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){re[e]=new de(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){re[e]=new de(e,5,!1,e.toLowerCase(),null,!1,!1)});var li=/[\-:]([a-z])/g;function si(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(li,si);re[t]=new de(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(li,si);re[t]=new de(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(li,si);re[t]=new de(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){re[e]=new de(e,1,!1,e.toLowerCase(),null,!1,!1)});re.xlinkHref=new de("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){re[e]=new de(e,1,!1,e.toLowerCase(),null,!0,!0)});function ii(e,t,n,r){var l=re.hasOwnProperty(t)?re[t]:null;(l!==null?l.type!==0:r||!(2a||l[o]!==s[a]){var u=` -`+l[o].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=o&&0<=a);break}}}finally{Fl=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Cn(e):""}function ed(e){switch(e.tag){case 5:return Cn(e.type);case 16:return Cn("Lazy");case 13:return Cn("Suspense");case 19:return Cn("SuspenseList");case 0:case 2:case 15:return e=Dl(e.type,!1),e;case 11:return e=Dl(e.type.render,!1),e;case 1:return e=Dl(e.type,!0),e;default:return""}}function cs(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case At:return"Fragment";case Ut:return"Portal";case os:return"Profiler";case oi:return"StrictMode";case as:return"Suspense";case us:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case _a:return(e.displayName||"Context")+".Consumer";case Ea:return(e._context.displayName||"Context")+".Provider";case ai:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ui:return t=e.displayName||null,t!==null?t:cs(e.type)||"Memo";case be:t=e._payload,e=e._init;try{return cs(e(t))}catch{}}return null}function td(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return cs(t);case 8:return t===oi?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function pt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Ta(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function nd(e){var t=Ta(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function hr(e){e._valueTracker||(e._valueTracker=nd(e))}function za(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Ta(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Vr(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function ds(e,t){var n=t.checked;return H({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ro(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=pt(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function La(e,t){t=t.checked,t!=null&&ii(e,"checked",t,!1)}function fs(e,t){La(e,t);var n=pt(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?ps(e,t.type,n):t.hasOwnProperty("defaultValue")&&ps(e,t.type,pt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function lo(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function ps(e,t,n){(t!=="number"||Vr(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var En=Array.isArray;function Zt(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=mr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Un(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Tn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},rd=["Webkit","ms","Moz","O"];Object.keys(Tn).forEach(function(e){rd.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Tn[t]=Tn[e]})});function Fa(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Tn.hasOwnProperty(e)&&Tn[e]?(""+t).trim():t+"px"}function Da(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Fa(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var ld=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function vs(e,t){if(t){if(ld[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(k(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(k(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(k(61))}if(t.style!=null&&typeof t.style!="object")throw Error(k(62))}}function ys(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var gs=null;function ci(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ws=null,qt=null,bt=null;function oo(e){if(e=lr(e)){if(typeof ws!="function")throw Error(k(280));var t=e.stateNode;t&&(t=gl(t),ws(e.stateNode,e.type,t))}}function Ma(e){qt?bt?bt.push(e):bt=[e]:qt=e}function $a(){if(qt){var e=qt,t=bt;if(bt=qt=null,oo(e),t)for(e=0;e>>=0,e===0?32:31-(md(e)/vd|0)|0}var vr=64,yr=4194304;function _n(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Kr(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,s=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~l;a!==0?r=_n(a):(s&=o,s!==0&&(r=_n(s)))}else o=n&~l,o!==0?r=_n(o):s!==0&&(r=_n(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,s=t&-t,l>=s||l===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function nr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ie(t),e[t]=n}function xd(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Ln),yo=" ",go=!1;function lu(e,t){switch(e){case"keyup":return Yd.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function su(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Bt=!1;function Jd(e,t){switch(e){case"compositionend":return su(t);case"keypress":return t.which!==32?null:(go=!0,yo);case"textInput":return e=t.data,e===yo&&go?null:e;default:return null}}function Zd(e,t){if(Bt)return e==="compositionend"||!gi&&lu(e,t)?(e=nu(),Rr=mi=rt=null,Bt=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=jo(n)}}function uu(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?uu(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function cu(){for(var e=window,t=Vr();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Vr(e.document)}return t}function wi(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function of(e){var t=cu(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&uu(n.ownerDocument.documentElement,n)){if(r!==null&&wi(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,s=Math.min(r.start,l);r=r.end===void 0?s:Math.min(r.end,l),!e.extend&&s>r&&(l=r,r=s,s=l),l=So(n,s);var o=So(n,r);l&&o&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Vt=null,Cs=null,On=null,Es=!1;function No(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Es||Vt==null||Vt!==Vr(r)||(r=Vt,"selectionStart"in r&&wi(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),On&&Qn(On,r)||(On=r,r=Xr(Cs,"onSelect"),0Qt||(e.current=Rs[Qt],Rs[Qt]=null,Qt--)}function $(e,t){Qt++,Rs[Qt]=e.current,e.current=t}var ht={},oe=vt(ht),he=vt(!1),Tt=ht;function ln(e,t){var n=e.type.contextTypes;if(!n)return ht;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},s;for(s in n)l[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function me(e){return e=e.childContextTypes,e!=null}function Zr(){A(he),A(oe)}function Lo(e,t,n){if(oe.current!==ht)throw Error(k(168));$(oe,t),$(he,n)}function wu(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(k(108,td(e)||"Unknown",l));return H({},n,r)}function qr(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ht,Tt=oe.current,$(oe,e),$(he,he.current),!0}function Ro(e,t,n){var r=e.stateNode;if(!r)throw Error(k(169));n?(e=wu(e,t,Tt),r.__reactInternalMemoizedMergedChildContext=e,A(he),A(oe),$(oe,e)):A(he),$(he,n)}var We=null,wl=!1,Jl=!1;function xu(e){We===null?We=[e]:We.push(e)}function wf(e){wl=!0,xu(e)}function yt(){if(!Jl&&We!==null){Jl=!0;var e=0,t=M;try{var n=We;for(M=1;e>=o,l-=o,He=1<<32-Ie(t)+l|n<T?(K=P,P=null):K=P.sibling;var O=v(f,P,p[T],w);if(O===null){P===null&&(P=K);break}e&&P&&O.alternate===null&&t(f,P),d=s(O,d,T),_===null?S=O:_.sibling=O,_=O,P=K}if(T===p.length)return n(f,P),B&&xt(f,T),S;if(P===null){for(;TT?(K=P,P=null):K=P.sibling;var Te=v(f,P,O.value,w);if(Te===null){P===null&&(P=K);break}e&&P&&Te.alternate===null&&t(f,P),d=s(Te,d,T),_===null?S=Te:_.sibling=Te,_=Te,P=K}if(O.done)return n(f,P),B&&xt(f,T),S;if(P===null){for(;!O.done;T++,O=p.next())O=h(f,O.value,w),O!==null&&(d=s(O,d,T),_===null?S=O:_.sibling=O,_=O);return B&&xt(f,T),S}for(P=r(f,P);!O.done;T++,O=p.next())O=y(P,f,T,O.value,w),O!==null&&(e&&O.alternate!==null&&P.delete(O.key===null?T:O.key),d=s(O,d,T),_===null?S=O:_.sibling=O,_=O);return e&&P.forEach(function(hn){return t(f,hn)}),B&&xt(f,T),S}function N(f,d,p,w){if(typeof p=="object"&&p!==null&&p.type===At&&p.key===null&&(p=p.props.children),typeof p=="object"&&p!==null){switch(p.$$typeof){case pr:e:{for(var S=p.key,_=d;_!==null;){if(_.key===S){if(S=p.type,S===At){if(_.tag===7){n(f,_.sibling),d=l(_,p.props.children),d.return=f,f=d;break e}}else if(_.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===be&&Fo(S)===_.type){n(f,_.sibling),d=l(_,p.props),d.ref=kn(f,_,p),d.return=f,f=d;break e}n(f,_);break}else t(f,_);_=_.sibling}p.type===At?(d=_t(p.props.children,f.mode,w,p.key),d.return=f,f=d):(w=Ar(p.type,p.key,p.props,null,f.mode,w),w.ref=kn(f,d,p),w.return=f,f=w)}return o(f);case Ut:e:{for(_=p.key;d!==null;){if(d.key===_)if(d.tag===4&&d.stateNode.containerInfo===p.containerInfo&&d.stateNode.implementation===p.implementation){n(f,d.sibling),d=l(d,p.children||[]),d.return=f,f=d;break e}else{n(f,d);break}else t(f,d);d=d.sibling}d=ls(p,f.mode,w),d.return=f,f=d}return o(f);case be:return _=p._init,N(f,d,_(p._payload),w)}if(En(p))return x(f,d,p,w);if(vn(p))return g(f,d,p,w);Nr(f,p)}return typeof p=="string"&&p!==""||typeof p=="number"?(p=""+p,d!==null&&d.tag===6?(n(f,d.sibling),d=l(d,p),d.return=f,f=d):(n(f,d),d=rs(p,f.mode,w),d.return=f,f=d),o(f)):n(f,d)}return N}var on=Nu(!0),Cu=Nu(!1),tl=vt(null),nl=null,Yt=null,Si=null;function Ni(){Si=Yt=nl=null}function Ci(e){var t=tl.current;A(tl),e._currentValue=t}function Fs(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function tn(e,t){nl=e,Si=Yt=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(pe=!0),e.firstContext=null)}function _e(e){var t=e._currentValue;if(Si!==e)if(e={context:e,memoizedValue:t,next:null},Yt===null){if(nl===null)throw Error(k(308));Yt=e,nl.dependencies={lanes:0,firstContext:e}}else Yt=Yt.next=e;return t}var Nt=null;function Ei(e){Nt===null?Nt=[e]:Nt.push(e)}function Eu(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Ei(t)):(n.next=l.next,l.next=n),t.interleaved=n,Xe(e,r)}function Xe(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var et=!1;function _i(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function _u(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ke(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ut(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,I&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,Xe(e,n)}return l=r.interleaved,l===null?(t.next=t,Ei(r)):(t.next=l.next,l.next=t),r.interleaved=t,Xe(e,n)}function Ir(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,fi(e,n)}}function Do(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?l=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?l=s=t:s=s.next=t}else l=s=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function rl(e,t,n,r){var l=e.updateQueue;et=!1;var s=l.firstBaseUpdate,o=l.lastBaseUpdate,a=l.shared.pending;if(a!==null){l.shared.pending=null;var u=a,c=u.next;u.next=null,o===null?s=c:o.next=c,o=u;var m=e.alternate;m!==null&&(m=m.updateQueue,a=m.lastBaseUpdate,a!==o&&(a===null?m.firstBaseUpdate=c:a.next=c,m.lastBaseUpdate=u))}if(s!==null){var h=l.baseState;o=0,m=c=u=null,a=s;do{var v=a.lane,y=a.eventTime;if((r&v)===v){m!==null&&(m=m.next={eventTime:y,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var x=e,g=a;switch(v=t,y=n,g.tag){case 1:if(x=g.payload,typeof x=="function"){h=x.call(y,h,v);break e}h=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=g.payload,v=typeof x=="function"?x.call(y,h,v):x,v==null)break e;h=H({},h,v);break e;case 2:et=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,v=l.effects,v===null?l.effects=[a]:v.push(a))}else y={eventTime:y,lane:v,tag:a.tag,payload:a.payload,callback:a.callback,next:null},m===null?(c=m=y,u=h):m=m.next=y,o|=v;if(a=a.next,a===null){if(a=l.shared.pending,a===null)break;v=a,a=v.next,v.next=null,l.lastBaseUpdate=v,l.shared.pending=null}}while(!0);if(m===null&&(u=h),l.baseState=u,l.firstBaseUpdate=c,l.lastBaseUpdate=m,t=l.shared.interleaved,t!==null){l=t;do o|=l.lane,l=l.next;while(l!==t)}else s===null&&(l.shared.lanes=0);Rt|=o,e.lanes=o,e.memoizedState=h}}function Mo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ql.transition;ql.transition={};try{e(!1),t()}finally{M=n,ql.transition=r}}function Hu(){return Pe().memoizedState}function Sf(e,t,n){var r=dt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Qu(e))Ku(t,n);else if(n=Eu(e,t,n,r),n!==null){var l=ue();Fe(n,e,r,l),Gu(n,t,r)}}function Nf(e,t,n){var r=dt(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Qu(e))Ku(t,l);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var o=t.lastRenderedState,a=s(o,n);if(l.hasEagerState=!0,l.eagerState=a,De(a,o)){var u=t.interleaved;u===null?(l.next=l,Ei(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=Eu(e,t,l,r),n!==null&&(l=ue(),Fe(n,e,r,l),Gu(n,t,r))}}function Qu(e){var t=e.alternate;return e===W||t!==null&&t===W}function Ku(e,t){In=sl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Gu(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,fi(e,n)}}var il={readContext:_e,useCallback:le,useContext:le,useEffect:le,useImperativeHandle:le,useInsertionEffect:le,useLayoutEffect:le,useMemo:le,useReducer:le,useRef:le,useState:le,useDebugValue:le,useDeferredValue:le,useTransition:le,useMutableSource:le,useSyncExternalStore:le,useId:le,unstable_isNewReconciler:!1},Cf={readContext:_e,useCallback:function(e,t){return $e().memoizedState=[e,t===void 0?null:t],e},useContext:_e,useEffect:Uo,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Dr(4194308,4,Uu.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Dr(4194308,4,e,t)},useInsertionEffect:function(e,t){return Dr(4,2,e,t)},useMemo:function(e,t){var n=$e();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=$e();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Sf.bind(null,W,e),[r.memoizedState,e]},useRef:function(e){var t=$e();return e={current:e},t.memoizedState=e},useState:$o,useDebugValue:Fi,useDeferredValue:function(e){return $e().memoizedState=e},useTransition:function(){var e=$o(!1),t=e[0];return e=jf.bind(null,e[1]),$e().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=W,l=$e();if(B){if(n===void 0)throw Error(k(407));n=n()}else{if(n=t(),ee===null)throw Error(k(349));Lt&30||Lu(r,t,n)}l.memoizedState=n;var s={value:n,getSnapshot:t};return l.queue=s,Uo(Ou.bind(null,r,s,e),[e]),r.flags|=2048,bn(9,Ru.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=$e(),t=ee.identifierPrefix;if(B){var n=Qe,r=He;n=(r&~(1<<32-Ie(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Zn++,0")&&(u=u.replace("",e.displayName)),u}while(1<=o&&0<=a);break}}}finally{Fl=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Cn(e):""}function ed(e){switch(e.tag){case 5:return Cn(e.type);case 16:return Cn("Lazy");case 13:return Cn("Suspense");case 19:return Cn("SuspenseList");case 0:case 2:case 15:return e=Dl(e.type,!1),e;case 11:return e=Dl(e.type.render,!1),e;case 1:return e=Dl(e.type,!0),e;default:return""}}function cs(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case At:return"Fragment";case Ut:return"Portal";case os:return"Profiler";case oi:return"StrictMode";case as:return"Suspense";case us:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case _a:return(e.displayName||"Context")+".Consumer";case Ea:return(e._context.displayName||"Context")+".Provider";case ai:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ui:return t=e.displayName||null,t!==null?t:cs(e.type)||"Memo";case be:t=e._payload,e=e._init;try{return cs(e(t))}catch{}}return null}function td(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return cs(t);case 8:return t===oi?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function pt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Ta(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function nd(e){var t=Ta(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function hr(e){e._valueTracker||(e._valueTracker=nd(e))}function za(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Ta(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Vr(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function ds(e,t){var n=t.checked;return Q({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ro(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=pt(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function La(e,t){t=t.checked,t!=null&&ii(e,"checked",t,!1)}function fs(e,t){La(e,t);var n=pt(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?ps(e,t.type,n):t.hasOwnProperty("defaultValue")&&ps(e,t.type,pt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function lo(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function ps(e,t,n){(t!=="number"||Vr(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var En=Array.isArray;function Zt(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=mr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Un(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Tn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},rd=["Webkit","ms","Moz","O"];Object.keys(Tn).forEach(function(e){rd.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Tn[t]=Tn[e]})});function Fa(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Tn.hasOwnProperty(e)&&Tn[e]?(""+t).trim():t+"px"}function Da(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Fa(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var ld=Q({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function vs(e,t){if(t){if(ld[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(k(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(k(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(k(61))}if(t.style!=null&&typeof t.style!="object")throw Error(k(62))}}function ys(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var gs=null;function ci(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ws=null,qt=null,bt=null;function oo(e){if(e=lr(e)){if(typeof ws!="function")throw Error(k(280));var t=e.stateNode;t&&(t=gl(t),ws(e.stateNode,e.type,t))}}function Ma(e){qt?bt?bt.push(e):bt=[e]:qt=e}function $a(){if(qt){var e=qt,t=bt;if(bt=qt=null,oo(e),t)for(e=0;e>>=0,e===0?32:31-(md(e)/vd|0)|0}var vr=64,yr=4194304;function _n(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Kr(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,s=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~l;a!==0?r=_n(a):(s&=o,s!==0&&(r=_n(s)))}else o=n&~l,o!==0?r=_n(o):s!==0&&(r=_n(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,s=t&-t,l>=s||l===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function nr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ie(t),e[t]=n}function xd(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Ln),yo=" ",go=!1;function lu(e,t){switch(e){case"keyup":return Yd.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function su(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Bt=!1;function Jd(e,t){switch(e){case"compositionend":return su(t);case"keypress":return t.which!==32?null:(go=!0,yo);case"textInput":return e=t.data,e===yo&&go?null:e;default:return null}}function Zd(e,t){if(Bt)return e==="compositionend"||!gi&&lu(e,t)?(e=nu(),Rr=mi=rt=null,Bt=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=jo(n)}}function uu(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?uu(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function cu(){for(var e=window,t=Vr();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Vr(e.document)}return t}function wi(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function of(e){var t=cu(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&uu(n.ownerDocument.documentElement,n)){if(r!==null&&wi(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,s=Math.min(r.start,l);r=r.end===void 0?s:Math.min(r.end,l),!e.extend&&s>r&&(l=r,r=s,s=l),l=So(n,s);var o=So(n,r);l&&o&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Vt=null,Cs=null,On=null,Es=!1;function No(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Es||Vt==null||Vt!==Vr(r)||(r=Vt,"selectionStart"in r&&wi(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),On&&Qn(On,r)||(On=r,r=Xr(Cs,"onSelect"),0Qt||(e.current=Rs[Qt],Rs[Qt]=null,Qt--)}function U(e,t){Qt++,Rs[Qt]=e.current,e.current=t}var ht={},oe=vt(ht),he=vt(!1),Tt=ht;function ln(e,t){var n=e.type.contextTypes;if(!n)return ht;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},s;for(s in n)l[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function me(e){return e=e.childContextTypes,e!=null}function Zr(){B(he),B(oe)}function Lo(e,t,n){if(oe.current!==ht)throw Error(k(168));U(oe,t),U(he,n)}function wu(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(k(108,td(e)||"Unknown",l));return Q({},n,r)}function qr(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ht,Tt=oe.current,U(oe,e),U(he,he.current),!0}function Ro(e,t,n){var r=e.stateNode;if(!r)throw Error(k(169));n?(e=wu(e,t,Tt),r.__reactInternalMemoizedMergedChildContext=e,B(he),B(oe),U(oe,e)):B(he),U(he,n)}var We=null,wl=!1,Jl=!1;function xu(e){We===null?We=[e]:We.push(e)}function wf(e){wl=!0,xu(e)}function yt(){if(!Jl&&We!==null){Jl=!0;var e=0,t=$;try{var n=We;for($=1;e>=o,l-=o,He=1<<32-Ie(t)+l|n<S?(z=P,P=null):z=P.sibling;var L=v(f,P,h[S],x);if(L===null){P===null&&(P=z);break}e&&P&&L.alternate===null&&t(f,P),d=s(L,d,S),T===null?N=L:T.sibling=L,T=L,P=z}if(S===h.length)return n(f,P),V&&xt(f,S),N;if(P===null){for(;SS?(z=P,P=null):z=P.sibling;var Te=v(f,P,L.value,x);if(Te===null){P===null&&(P=z);break}e&&P&&Te.alternate===null&&t(f,P),d=s(Te,d,S),T===null?N=Te:T.sibling=Te,T=Te,P=z}if(L.done)return n(f,P),V&&xt(f,S),N;if(P===null){for(;!L.done;S++,L=h.next())L=p(f,L.value,x),L!==null&&(d=s(L,d,S),T===null?N=L:T.sibling=L,T=L);return V&&xt(f,S),N}for(P=r(f,P);!L.done;S++,L=h.next())L=y(P,f,S,L.value,x),L!==null&&(e&&L.alternate!==null&&P.delete(L.key===null?S:L.key),d=s(L,d,S),T===null?N=L:T.sibling=L,T=L);return e&&P.forEach(function(hn){return t(f,hn)}),V&&xt(f,S),N}function C(f,d,h,x){if(typeof h=="object"&&h!==null&&h.type===At&&h.key===null&&(h=h.props.children),typeof h=="object"&&h!==null){switch(h.$$typeof){case pr:e:{for(var N=h.key,T=d;T!==null;){if(T.key===N){if(N=h.type,N===At){if(T.tag===7){n(f,T.sibling),d=l(T,h.props.children),d.return=f,f=d;break e}}else if(T.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===be&&Fo(N)===T.type){n(f,T.sibling),d=l(T,h.props),d.ref=kn(f,T,h),d.return=f,f=d;break e}n(f,T);break}else t(f,T);T=T.sibling}h.type===At?(d=_t(h.props.children,f.mode,x,h.key),d.return=f,f=d):(x=Ar(h.type,h.key,h.props,null,f.mode,x),x.ref=kn(f,d,h),x.return=f,f=x)}return o(f);case Ut:e:{for(T=h.key;d!==null;){if(d.key===T)if(d.tag===4&&d.stateNode.containerInfo===h.containerInfo&&d.stateNode.implementation===h.implementation){n(f,d.sibling),d=l(d,h.children||[]),d.return=f,f=d;break e}else{n(f,d);break}else t(f,d);d=d.sibling}d=ls(h,f.mode,x),d.return=f,f=d}return o(f);case be:return T=h._init,C(f,d,T(h._payload),x)}if(En(h))return w(f,d,h,x);if(vn(h))return g(f,d,h,x);Nr(f,h)}return typeof h=="string"&&h!==""||typeof h=="number"?(h=""+h,d!==null&&d.tag===6?(n(f,d.sibling),d=l(d,h),d.return=f,f=d):(n(f,d),d=rs(h,f.mode,x),d.return=f,f=d),o(f)):n(f,d)}return C}var on=Nu(!0),Cu=Nu(!1),tl=vt(null),nl=null,Yt=null,Si=null;function Ni(){Si=Yt=nl=null}function Ci(e){var t=tl.current;B(tl),e._currentValue=t}function Fs(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function tn(e,t){nl=e,Si=Yt=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(pe=!0),e.firstContext=null)}function _e(e){var t=e._currentValue;if(Si!==e)if(e={context:e,memoizedValue:t,next:null},Yt===null){if(nl===null)throw Error(k(308));Yt=e,nl.dependencies={lanes:0,firstContext:e}}else Yt=Yt.next=e;return t}var Nt=null;function Ei(e){Nt===null?Nt=[e]:Nt.push(e)}function Eu(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Ei(t)):(n.next=l.next,l.next=n),t.interleaved=n,Xe(e,r)}function Xe(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var et=!1;function _i(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function _u(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ke(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ut(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,F&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,Xe(e,n)}return l=r.interleaved,l===null?(t.next=t,Ei(r)):(t.next=l.next,l.next=t),r.interleaved=t,Xe(e,n)}function Ir(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,fi(e,n)}}function Do(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?l=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?l=s=t:s=s.next=t}else l=s=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function rl(e,t,n,r){var l=e.updateQueue;et=!1;var s=l.firstBaseUpdate,o=l.lastBaseUpdate,a=l.shared.pending;if(a!==null){l.shared.pending=null;var u=a,c=u.next;u.next=null,o===null?s=c:o.next=c,o=u;var m=e.alternate;m!==null&&(m=m.updateQueue,a=m.lastBaseUpdate,a!==o&&(a===null?m.firstBaseUpdate=c:a.next=c,m.lastBaseUpdate=u))}if(s!==null){var p=l.baseState;o=0,m=c=u=null,a=s;do{var v=a.lane,y=a.eventTime;if((r&v)===v){m!==null&&(m=m.next={eventTime:y,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var w=e,g=a;switch(v=t,y=n,g.tag){case 1:if(w=g.payload,typeof w=="function"){p=w.call(y,p,v);break e}p=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=g.payload,v=typeof w=="function"?w.call(y,p,v):w,v==null)break e;p=Q({},p,v);break e;case 2:et=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,v=l.effects,v===null?l.effects=[a]:v.push(a))}else y={eventTime:y,lane:v,tag:a.tag,payload:a.payload,callback:a.callback,next:null},m===null?(c=m=y,u=p):m=m.next=y,o|=v;if(a=a.next,a===null){if(a=l.shared.pending,a===null)break;v=a,a=v.next,v.next=null,l.lastBaseUpdate=v,l.shared.pending=null}}while(!0);if(m===null&&(u=p),l.baseState=u,l.firstBaseUpdate=c,l.lastBaseUpdate=m,t=l.shared.interleaved,t!==null){l=t;do o|=l.lane,l=l.next;while(l!==t)}else s===null&&(l.shared.lanes=0);Rt|=o,e.lanes=o,e.memoizedState=p}}function Mo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ql.transition;ql.transition={};try{e(!1),t()}finally{$=n,ql.transition=r}}function Hu(){return Pe().memoizedState}function Sf(e,t,n){var r=dt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Qu(e))Ku(t,n);else if(n=Eu(e,t,n,r),n!==null){var l=ue();Fe(n,e,r,l),Gu(n,t,r)}}function Nf(e,t,n){var r=dt(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Qu(e))Ku(t,l);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var o=t.lastRenderedState,a=s(o,n);if(l.hasEagerState=!0,l.eagerState=a,De(a,o)){var u=t.interleaved;u===null?(l.next=l,Ei(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=Eu(e,t,l,r),n!==null&&(l=ue(),Fe(n,e,r,l),Gu(n,t,r))}}function Qu(e){var t=e.alternate;return e===H||t!==null&&t===H}function Ku(e,t){In=sl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Gu(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,fi(e,n)}}var il={readContext:_e,useCallback:le,useContext:le,useEffect:le,useImperativeHandle:le,useInsertionEffect:le,useLayoutEffect:le,useMemo:le,useReducer:le,useRef:le,useState:le,useDebugValue:le,useDeferredValue:le,useTransition:le,useMutableSource:le,useSyncExternalStore:le,useId:le,unstable_isNewReconciler:!1},Cf={readContext:_e,useCallback:function(e,t){return $e().memoizedState=[e,t===void 0?null:t],e},useContext:_e,useEffect:Uo,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Dr(4194308,4,Uu.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Dr(4194308,4,e,t)},useInsertionEffect:function(e,t){return Dr(4,2,e,t)},useMemo:function(e,t){var n=$e();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=$e();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Sf.bind(null,H,e),[r.memoizedState,e]},useRef:function(e){var t=$e();return e={current:e},t.memoizedState=e},useState:$o,useDebugValue:Fi,useDeferredValue:function(e){return $e().memoizedState=e},useTransition:function(){var e=$o(!1),t=e[0];return e=jf.bind(null,e[1]),$e().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=H,l=$e();if(V){if(n===void 0)throw Error(k(407));n=n()}else{if(n=t(),ee===null)throw Error(k(349));Lt&30||Lu(r,t,n)}l.memoizedState=n;var s={value:n,getSnapshot:t};return l.queue=s,Uo(Ou.bind(null,r,s,e),[e]),r.flags|=2048,bn(9,Ru.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=$e(),t=ee.identifierPrefix;if(V){var n=Qe,r=He;n=(r&~(1<<32-Ie(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Zn++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[Ue]=t,e[Yn]=r,rc(e,t,!1,!1),t.stateNode=e;e:{switch(o=ys(n,r),n){case"dialog":U("cancel",e),U("close",e),l=r;break;case"iframe":case"object":case"embed":U("load",e),l=r;break;case"video":case"audio":for(l=0;lcn&&(t.flags|=128,r=!0,jn(s,!1),t.lanes=4194304)}else{if(!r)if(e=ll(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),jn(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!B)return se(t),null}else 2*Y()-s.renderingStartTime>cn&&n!==1073741824&&(t.flags|=128,r=!0,jn(s,!1),t.lanes=4194304);s.isBackwards?(o.sibling=t.child,t.child=o):(n=s.last,n!==null?n.sibling=o:t.child=o,s.last=o)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=Y(),t.sibling=null,n=V.current,$(V,r?n&1|2:n&1),t):(se(t),null);case 22:case 23:return Bi(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ye&1073741824&&(se(t),t.subtreeFlags&6&&(t.flags|=8192)):se(t),null;case 24:return null;case 25:return null}throw Error(k(156,t.tag))}function Of(e,t){switch(ki(t),t.tag){case 1:return me(t.type)&&Zr(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return an(),A(he),A(oe),zi(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Ti(t),null;case 13:if(A(V),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(k(340));sn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return A(V),null;case 4:return an(),null;case 10:return Ci(t.type._context),null;case 22:case 23:return Bi(),null;case 24:return null;default:return null}}var Er=!1,ie=!1,If=typeof WeakSet=="function"?WeakSet:Set,C=null;function Xt(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Q(e,t,r)}else n.current=null}function Hs(e,t,n){try{n()}catch(r){Q(e,t,r)}}var Jo=!1;function Ff(e,t){if(_s=Gr,e=cu(),wi(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,u=-1,c=0,m=0,h=e,v=null;t:for(;;){for(var y;h!==n||l!==0&&h.nodeType!==3||(a=o+l),h!==s||r!==0&&h.nodeType!==3||(u=o+r),h.nodeType===3&&(o+=h.nodeValue.length),(y=h.firstChild)!==null;)v=h,h=y;for(;;){if(h===e)break t;if(v===n&&++c===l&&(a=o),v===s&&++m===r&&(u=o),(y=h.nextSibling)!==null)break;h=v,v=h.parentNode}h=y}n=a===-1||u===-1?null:{start:a,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ps={focusedElem:e,selectionRange:n},Gr=!1,C=t;C!==null;)if(t=C,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,C=e;else for(;C!==null;){t=C;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var g=x.memoizedProps,N=x.memoizedState,f=t.stateNode,d=f.getSnapshotBeforeUpdate(t.elementType===t.type?g:Le(t.type,g),N);f.__reactInternalSnapshotBeforeUpdate=d}break;case 3:var p=t.stateNode.containerInfo;p.nodeType===1?p.textContent="":p.nodeType===9&&p.documentElement&&p.removeChild(p.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(k(163))}}catch(w){Q(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,C=e;break}C=t.return}return x=Jo,Jo=!1,x}function Fn(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var s=l.destroy;l.destroy=void 0,s!==void 0&&Hs(t,n,s)}l=l.next}while(l!==r)}}function jl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Qs(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function ic(e){var t=e.alternate;t!==null&&(e.alternate=null,ic(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ue],delete t[Yn],delete t[Ls],delete t[yf],delete t[gf])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function oc(e){return e.tag===5||e.tag===3||e.tag===4}function Zo(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||oc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ks(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Jr));else if(r!==4&&(e=e.child,e!==null))for(Ks(e,t,n),e=e.sibling;e!==null;)Ks(e,t,n),e=e.sibling}function Gs(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Gs(e,t,n),e=e.sibling;e!==null;)Gs(e,t,n),e=e.sibling}var te=null,Re=!1;function qe(e,t,n){for(n=n.child;n!==null;)ac(e,t,n),n=n.sibling}function ac(e,t,n){if(Ae&&typeof Ae.onCommitFiberUnmount=="function")try{Ae.onCommitFiberUnmount(hl,n)}catch{}switch(n.tag){case 5:ie||Xt(n,t);case 6:var r=te,l=Re;te=null,qe(e,t,n),te=r,Re=l,te!==null&&(Re?(e=te,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):te.removeChild(n.stateNode));break;case 18:te!==null&&(Re?(e=te,n=n.stateNode,e.nodeType===8?Xl(e.parentNode,n):e.nodeType===1&&Xl(e,n),Wn(e)):Xl(te,n.stateNode));break;case 4:r=te,l=Re,te=n.stateNode.containerInfo,Re=!0,qe(e,t,n),te=r,Re=l;break;case 0:case 11:case 14:case 15:if(!ie&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var s=l,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&Hs(n,t,o),l=l.next}while(l!==r)}qe(e,t,n);break;case 1:if(!ie&&(Xt(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Q(n,t,a)}qe(e,t,n);break;case 21:qe(e,t,n);break;case 22:n.mode&1?(ie=(r=ie)||n.memoizedState!==null,qe(e,t,n),ie=r):qe(e,t,n);break;default:qe(e,t,n)}}function qo(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new If),t.forEach(function(r){var l=Hf.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function ze(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=o),r&=~s}if(r=l,r=Y()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Mf(r/1960))-r,10e?16:e,lt===null)var r=!1;else{if(e=lt,lt=null,ul=0,I&6)throw Error(k(331));var l=I;for(I|=4,C=e.current;C!==null;){var s=C,o=s.child;if(C.flags&16){var a=s.deletions;if(a!==null){for(var u=0;uY()-Ui?Et(e,0):$i|=n),ve(e,t)}function vc(e,t){t===0&&(e.mode&1?(t=yr,yr<<=1,!(yr&130023424)&&(yr=4194304)):t=1);var n=ue();e=Xe(e,t),e!==null&&(nr(e,t,n),ve(e,n))}function Wf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),vc(e,n)}function Hf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(k(314))}r!==null&&r.delete(t),vc(e,n)}var yc;yc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||he.current)pe=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return pe=!1,Lf(e,t,n);pe=!!(e.flags&131072)}else pe=!1,B&&t.flags&1048576&&ku(t,el,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Mr(e,t),e=t.pendingProps;var l=ln(t,oe.current);tn(t,n),l=Ri(null,t,r,e,l,n);var s=Oi();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,me(r)?(s=!0,qr(t)):s=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,_i(t),l.updater=kl,t.stateNode=l,l._reactInternals=t,Ms(t,r,e,n),t=As(null,t,r,!0,s,n)):(t.tag=0,B&&s&&xi(t),ae(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Mr(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Kf(r),e=Le(r,e),l){case 0:t=Us(null,t,r,e,n);break e;case 1:t=Go(null,t,r,e,n);break e;case 11:t=Qo(null,t,r,e,n);break e;case 14:t=Ko(null,t,r,Le(r.type,e),n);break e}throw Error(k(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Le(r,l),Us(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Le(r,l),Go(e,t,r,l,n);case 3:e:{if(ec(t),e===null)throw Error(k(387));r=t.pendingProps,s=t.memoizedState,l=s.element,_u(e,t),rl(t,r,null,n);var o=t.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){l=un(Error(k(423)),t),t=Yo(e,t,r,n,l);break e}else if(r!==l){l=un(Error(k(424)),t),t=Yo(e,t,r,n,l);break e}else for(ge=at(t.stateNode.containerInfo.firstChild),we=t,B=!0,Oe=null,n=Cu(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(sn(),r===l){t=Je(e,t,n);break e}ae(e,t,r,n)}t=t.child}return t;case 5:return Pu(t),e===null&&Is(t),r=t.type,l=t.pendingProps,s=e!==null?e.memoizedProps:null,o=l.children,Ts(r,l)?o=null:s!==null&&Ts(r,s)&&(t.flags|=32),bu(e,t),ae(e,t,o,n),t.child;case 6:return e===null&&Is(t),null;case 13:return tc(e,t,n);case 4:return Pi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=on(t,null,r,n):ae(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Le(r,l),Qo(e,t,r,l,n);case 7:return ae(e,t,t.pendingProps,n),t.child;case 8:return ae(e,t,t.pendingProps.children,n),t.child;case 12:return ae(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,s=t.memoizedProps,o=l.value,$(tl,r._currentValue),r._currentValue=o,s!==null)if(De(s.value,o)){if(s.children===l.children&&!he.current){t=Je(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var u=a.firstContext;u!==null;){if(u.context===r){if(s.tag===1){u=Ke(-1,n&-n),u.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var m=c.pending;m===null?u.next=u:(u.next=m.next,m.next=u),c.pending=u}}s.lanes|=n,u=s.alternate,u!==null&&(u.lanes|=n),Fs(s.return,n,t),a.lanes|=n;break}u=u.next}}else if(s.tag===10)o=s.type===t.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(k(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),Fs(o,n,t),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===t){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}ae(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,tn(t,n),l=_e(l),r=r(l),t.flags|=1,ae(e,t,r,n),t.child;case 14:return r=t.type,l=Le(r,t.pendingProps),l=Le(r.type,l),Ko(e,t,r,l,n);case 15:return Zu(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Le(r,l),Mr(e,t),t.tag=1,me(r)?(e=!0,qr(t)):e=!1,tn(t,n),Yu(t,r,l),Ms(t,r,l,n),As(null,t,r,!0,e,n);case 19:return nc(e,t,n);case 22:return qu(e,t,n)}throw Error(k(156,t.tag))};function gc(e,t){return Qa(e,t)}function Qf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ce(e,t,n,r){return new Qf(e,t,n,r)}function Wi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Kf(e){if(typeof e=="function")return Wi(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ai)return 11;if(e===ui)return 14}return 2}function ft(e,t){var n=e.alternate;return n===null?(n=Ce(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ar(e,t,n,r,l,s){var o=2;if(r=e,typeof e=="function")Wi(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case At:return _t(n.children,l,s,t);case oi:o=8,l|=8;break;case os:return e=Ce(12,n,t,l|2),e.elementType=os,e.lanes=s,e;case as:return e=Ce(13,n,t,l),e.elementType=as,e.lanes=s,e;case us:return e=Ce(19,n,t,l),e.elementType=us,e.lanes=s,e;case Pa:return Nl(n,l,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Ea:o=10;break e;case _a:o=9;break e;case ai:o=11;break e;case ui:o=14;break e;case be:o=16,r=null;break e}throw Error(k(130,e==null?e:typeof e,""))}return t=Ce(o,n,t,l),t.elementType=e,t.type=r,t.lanes=s,t}function _t(e,t,n,r){return e=Ce(7,e,r,t),e.lanes=n,e}function Nl(e,t,n,r){return e=Ce(22,e,r,t),e.elementType=Pa,e.lanes=n,e.stateNode={isHidden:!1},e}function rs(e,t,n){return e=Ce(6,e,null,t),e.lanes=n,e}function ls(e,t,n){return t=Ce(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Gf(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=$l(0),this.expirationTimes=$l(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$l(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Hi(e,t,n,r,l,s,o,a,u){return e=new Gf(e,t,n,a,u),t===1?(t=1,s===!0&&(t|=8)):t=0,s=Ce(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},_i(s),e}function Yf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(jc)}catch(e){console.error(e)}}jc(),ja.exports=ke;var bf=ja.exports,Sc,ia=bf;Sc=ia.createRoot,ia.hydrateRoot;const Nc="bv.access",Yi="bv.refresh";function qs(e){try{return localStorage.getItem(e)||""}catch{return""}}function oa(e,t){try{t?localStorage.setItem(e,t):localStorage.removeItem(e)}catch{}}function ir(){return{access:qs(Nc),refresh:qs(Yi)}}function fl(e,t){oa(Nc,e),oa(Yi,t)}function or(){fl("","")}function ep(){return!!qs(Yi)}class Pt extends Error{constructor(t,n,r){super(r),this.status=t,this.code=n}}let Nn=null;async function Tl(){return Nn||(Nn=(async()=>{const{refresh:e}=ir();if(!e)throw new Pt(401,"unauthorized","Signed out.");const t=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e})});if(!t.ok)throw or(),new Pt(t.status,"unauthorized","Your session has ended. Sign in again.");const n=await t.json();return fl(n.access_token,n.refresh_token),n})().finally(()=>{Nn=null}),Nn)}async function F(e,t,n,r=!0){const{access:l}=ir(),s={};l&&(s.Authorization="Bearer "+l),n!==void 0&&(s["Content-Type"]="application/json");const o=await fetch(t,{method:e,headers:s,body:n===void 0?void 0:JSON.stringify(n)});if(o.status===204)return null;const a=await o.text();let u=null;try{u=a?JSON.parse(a):null}catch{}if(o.ok)return u;const c=(u==null?void 0:u.error)||"";if(c==="token_expired"&&r)return await Tl(),F(e,t,n,!1);throw o.status===401&&or(),new Pt(o.status,c,(u==null?void 0:u.message)||`Something went wrong (${o.status}).`)}async function Cc(e,t=!0){const{access:n}=ir(),r=await fetch(e,{headers:n?{Authorization:"Bearer "+n}:{}});if(r.ok)return URL.createObjectURL(await r.blob());let l=null;try{l=await r.json()}catch{}const s=(l==null?void 0:l.error)||"";if(s==="token_expired"&&t)return await Tl(),Cc(e,!1);throw r.status===401&&or(),new Pt(r.status,s,(l==null?void 0:l.message)||`That picture could not be loaded (${r.status}).`)}function aa(){const e=navigator.userAgent||"",t=/Windows/.test(e)?"Windows":/Mac OS X|Macintosh/.test(e)?"Mac":/Android/.test(e)?"Android":/iPhone|iPad/.test(e)?"iOS":"Unknown";return`${/Edg\//.test(e)?"Edge":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)?"Safari":/Firefox\//.test(e)?"Firefox":"browser"} on ${t}`}const jt=e=>{const t=new URLSearchParams;for(const[r,l]of Object.entries(e||{}))l!=null&&l!==""&&t.set(r,l);const n=t.toString();return n?"?"+n:""},D={async login(e,t){const n=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:t,device:aa()})}),r=await n.json().catch(()=>null);if(!n.ok)throw new Pt(n.status,(r==null?void 0:r.error)||"",(r==null?void 0:r.message)||"Could not sign in.");return fl(r.access_token,r.refresh_token),r.user},async previewInvitation(e){const t=await fetch("/api/auth/invitation"+jt({code:e})),n=await t.json().catch(()=>null);if(!t.ok)throw new Pt(t.status,(n==null?void 0:n.error)||"",(n==null?void 0:n.message)||"That invitation code is not valid.");return n},async register({code:e,full_name:t,password:n}){const r=await fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,full_name:t,password:n,device:aa()})}),l=await r.json().catch(()=>null);if(!r.ok)throw new Pt(r.status,(l==null?void 0:l.error)||"",(l==null?void 0:l.message)||"Could not create the account.");return fl(l.access_token,l.refresh_token),l.user},async logout(){try{await F("POST","/api/auth/logout")}catch{}or()},me:()=>F("GET","/api/auth/me"),sites:()=>F("GET","/api/sites"),createSite:e=>F("POST","/api/sites",e),updateSite:(e,t)=>F("PATCH",`/api/sites/${encodeURIComponent(e)}`,t),deleteSite:e=>F("DELETE",`/api/sites/${encodeURIComponent(e)}`),arrivals:e=>F("GET","/api/visits"+jt(e)),visitors:(e,t=50)=>F("GET","/api/visitors"+jt({q:e,limit:t})),visitorHistory:(e,t=50)=>F("GET",`/api/visitors/${encodeURIComponent(e)}/history`+jt({limit:t})),saveProfile:(e,t)=>F("PUT",`/api/visitors/${encodeURIComponent(e)}/profile`,t),footfall:e=>F("GET","/api/reports/footfall"+jt(e)),conversion:e=>F("GET","/api/reports/conversion"+jt(e)),cameras:()=>F("GET","/api/cameras"),cameraSnapshot:e=>Cc(e),createCamera:(e,t)=>F("POST",`/api/sites/${encodeURIComponent(e)}/cameras`,t),updateCamera:(e,t)=>F("PATCH",`/api/cameras/${encodeURIComponent(e)}`,t),deleteCamera:e=>F("DELETE",`/api/cameras/${encodeURIComponent(e)}`),checkCamera:(e,t,n)=>F("POST",`/api/cameras/${encodeURIComponent(e)}/check`,{kind:t,...n?{seconds:n}:{}}),siteCheck:e=>F("GET",`/api/sites/${encodeURIComponent(e)}/check`),enrolmentCode:(e,t)=>F("POST",`/api/sites/${encodeURIComponent(e)}/enrolment-code`,t||{}),ask:e=>F("POST","/api/assistant",{history:e}),clients:()=>F("GET","/api/admin/clients"),createClient:e=>F("POST","/api/admin/clients",e),team:()=>F("GET","/api/team"),updateMember:(e,t)=>F("PATCH",`/api/team/${encodeURIComponent(e)}`,t),invitations:()=>F("GET","/api/team/invitations"),invite:e=>F("POST","/api/team/invitations",e),revokeInvitation:e=>F("DELETE",`/api/team/invitations/${encodeURIComponent(e)}`),sessions:()=>F("GET","/api/auth/sessions"),revokeSession:e=>F("DELETE",`/api/auth/sessions/${encodeURIComponent(e)}`),signOutOthers:()=>F("POST","/api/auth/sessions/revoke-others")};function tp({cursor:e,siteId:t,onPage:n,onError:r,signal:l}){let s=!1,o=e||"";return(async()=>{for(;!s;){try{const{access:u}=ir(),c=await fetch("/api/visits/stream"+jt({cursor:o,site_id:t}),{headers:{Authorization:"Bearer "+u,Accept:"text/event-stream"},signal:l});if(c.status===401){await Tl();continue}if(!c.ok||!c.body)throw new Error("stream unavailable");const m=c.body.getReader(),h=new TextDecoder;let v="";for(;!s;){const{value:y,done:x}=await m.read();if(x)break;v+=h.decode(y,{stream:!0});let g;for(;(g=v.indexOf(` +`+s.stack}return{value:e,source:t,stack:l,digest:null}}function ts(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function $s(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Pf=typeof WeakMap=="function"?WeakMap:Map;function Xu(e,t,n){n=Ke(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){al||(al=!0,Ys=r),$s(e,t)},n}function Ju(e,t,n){n=Ke(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var l=t.value;n.payload=function(){return r(l)},n.callback=function(){$s(e,t)}}var s=e.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){$s(e,t),typeof r!="function"&&(ct===null?ct=new Set([this]):ct.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function Vo(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Pf;var l=new Set;r.set(t,l)}else l=r.get(t),l===void 0&&(l=new Set,r.set(t,l));l.has(n)||(l.add(n),e=Vf.bind(null,e,t,n),t.then(e,e))}function Wo(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function Ho(e,t,n,r,l){return e.mode&1?(e.flags|=65536,e.lanes=l,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Ke(-1,1),t.tag=2,ut(n,t,1))),n.lanes|=1),e)}var Tf=Ze.ReactCurrentOwner,pe=!1;function ae(e,t,n,r){t.child=e===null?Cu(t,null,n,r):on(t,e.child,n,r)}function Qo(e,t,n,r,l){n=n.render;var s=t.ref;return tn(t,l),r=Ri(e,t,n,r,s,l),n=Oi(),e!==null&&!pe?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,Je(e,t,l)):(V&&n&&xi(t),t.flags|=1,ae(e,t,r,l),t.child)}function Ko(e,t,n,r,l){if(e===null){var s=n.type;return typeof s=="function"&&!Wi(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=s,Zu(e,t,s,r,l)):(e=Ar(n.type,null,r,t,t.mode,l),e.ref=t.ref,e.return=t,t.child=e)}if(s=e.child,!(e.lanes&l)){var o=s.memoizedProps;if(n=n.compare,n=n!==null?n:Qn,n(o,r)&&e.ref===t.ref)return Je(e,t,l)}return t.flags|=1,e=ft(s,r),e.ref=t.ref,e.return=t,t.child=e}function Zu(e,t,n,r,l){if(e!==null){var s=e.memoizedProps;if(Qn(s,r)&&e.ref===t.ref)if(pe=!1,t.pendingProps=r=s,(e.lanes&l)!==0)e.flags&131072&&(pe=!0);else return t.lanes=e.lanes,Je(e,t,l)}return Us(e,t,n,r,l)}function qu(e,t,n){var r=t.pendingProps,l=r.children,s=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},U(Jt,ye),ye|=n;else{if(!(n&1073741824))return e=s!==null?s.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,U(Jt,ye),ye|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,U(Jt,ye),ye|=r}else s!==null?(r=s.baseLanes|n,t.memoizedState=null):r=n,U(Jt,ye),ye|=r;return ae(e,t,l,n),t.child}function bu(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Us(e,t,n,r,l){var s=me(n)?Tt:oe.current;return s=ln(t,s),tn(t,l),n=Ri(e,t,n,r,s,l),r=Oi(),e!==null&&!pe?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,Je(e,t,l)):(V&&r&&xi(t),t.flags|=1,ae(e,t,n,l),t.child)}function Go(e,t,n,r,l){if(me(n)){var s=!0;qr(t)}else s=!1;if(tn(t,l),t.stateNode===null)Mr(e,t),Yu(t,n,r),Ms(t,n,r,l),r=!0;else if(e===null){var o=t.stateNode,a=t.memoizedProps;o.props=a;var u=o.context,c=n.contextType;typeof c=="object"&&c!==null?c=_e(c):(c=me(n)?Tt:oe.current,c=ln(t,c));var m=n.getDerivedStateFromProps,p=typeof m=="function"||typeof o.getSnapshotBeforeUpdate=="function";p||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||u!==c)&&Bo(t,o,r,c),et=!1;var v=t.memoizedState;o.state=v,rl(t,r,o,l),u=t.memoizedState,a!==r||v!==u||he.current||et?(typeof m=="function"&&(Ds(t,n,m,r),u=t.memoizedState),(a=et||Ao(t,n,a,r,v,u,c))?(p||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=u),o.props=r,o.state=u,o.context=c,r=a):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,_u(e,t),a=t.memoizedProps,c=t.type===t.elementType?a:Le(t.type,a),o.props=c,p=t.pendingProps,v=o.context,u=n.contextType,typeof u=="object"&&u!==null?u=_e(u):(u=me(n)?Tt:oe.current,u=ln(t,u));var y=n.getDerivedStateFromProps;(m=typeof y=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==p||v!==u)&&Bo(t,o,r,u),et=!1,v=t.memoizedState,o.state=v,rl(t,r,o,l);var w=t.memoizedState;a!==p||v!==w||he.current||et?(typeof y=="function"&&(Ds(t,n,y,r),w=t.memoizedState),(c=et||Ao(t,n,c,r,v,w,u)||!1)?(m||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,w,u),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,w,u)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&v===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&v===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=w),o.props=r,o.state=w,o.context=u,r=c):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&v===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&v===e.memoizedState||(t.flags|=1024),r=!1)}return As(e,t,n,r,s,l)}function As(e,t,n,r,l,s){bu(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return l&&Ro(t,n,!1),Je(e,t,s);r=t.stateNode,Tf.current=t;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=on(t,e.child,null,s),t.child=on(t,null,a,s)):ae(e,t,a,s),t.memoizedState=r.state,l&&Ro(t,n,!0),t.child}function ec(e){var t=e.stateNode;t.pendingContext?Lo(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Lo(e,t.context,!1),Pi(e,t.containerInfo)}function Yo(e,t,n,r,l){return sn(),ji(l),t.flags|=256,ae(e,t,n,r),t.child}var Bs={dehydrated:null,treeContext:null,retryLane:0};function Vs(e){return{baseLanes:e,cachePool:null,transitions:null}}function tc(e,t,n){var r=t.pendingProps,l=W.current,s=!1,o=(t.flags&128)!==0,a;if((a=o)||(a=e!==null&&e.memoizedState===null?!1:(l&2)!==0),a?(s=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(l|=1),U(W,l&1),e===null)return Is(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,s?(r=t.mode,s=t.child,o={mode:"hidden",children:o},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=o):s=Nl(o,r,0,null),e=_t(e,r,n,null),s.return=t,e.return=t,s.sibling=e,t.child=s,t.child.memoizedState=Vs(n),t.memoizedState=Bs,e):Di(t,o));if(l=e.memoizedState,l!==null&&(a=l.dehydrated,a!==null))return zf(e,t,o,r,a,l,n);if(s){s=r.fallback,o=t.mode,l=e.child,a=l.sibling;var u={mode:"hidden",children:r.children};return!(o&1)&&t.child!==l?(r=t.child,r.childLanes=0,r.pendingProps=u,t.deletions=null):(r=ft(l,u),r.subtreeFlags=l.subtreeFlags&14680064),a!==null?s=ft(a,s):(s=_t(s,o,n,null),s.flags|=2),s.return=t,r.return=t,r.sibling=s,t.child=r,r=s,s=t.child,o=e.child.memoizedState,o=o===null?Vs(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},s.memoizedState=o,s.childLanes=e.childLanes&~n,t.memoizedState=Bs,r}return s=e.child,e=s.sibling,r=ft(s,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Di(e,t){return t=Nl({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Cr(e,t,n,r){return r!==null&&ji(r),on(t,e.child,null,n),e=Di(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function zf(e,t,n,r,l,s,o){if(n)return t.flags&256?(t.flags&=-257,r=ts(Error(k(422))),Cr(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(s=r.fallback,l=t.mode,r=Nl({mode:"visible",children:r.children},l,0,null),s=_t(s,l,o,null),s.flags|=2,r.return=t,s.return=t,r.sibling=s,t.child=r,t.mode&1&&on(t,e.child,null,o),t.child.memoizedState=Vs(o),t.memoizedState=Bs,s);if(!(t.mode&1))return Cr(e,t,o,null);if(l.data==="$!"){if(r=l.nextSibling&&l.nextSibling.dataset,r)var a=r.dgst;return r=a,s=Error(k(419)),r=ts(s,r,void 0),Cr(e,t,o,r)}if(a=(o&e.childLanes)!==0,pe||a){if(r=ee,r!==null){switch(o&-o){case 4:l=2;break;case 16:l=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:l=32;break;case 536870912:l=268435456;break;default:l=0}l=l&(r.suspendedLanes|o)?0:l,l!==0&&l!==s.retryLane&&(s.retryLane=l,Xe(e,l),Fe(r,e,l,-1))}return Vi(),r=ts(Error(k(421))),Cr(e,t,o,r)}return l.data==="$?"?(t.flags|=128,t.child=e.child,t=Wf.bind(null,e),l._reactRetry=t,null):(e=s.treeContext,ge=at(l.nextSibling),we=t,V=!0,Oe=null,e!==null&&(Se[Ne++]=He,Se[Ne++]=Qe,Se[Ne++]=zt,He=e.id,Qe=e.overflow,zt=t),t=Di(t,r.children),t.flags|=4096,t)}function Xo(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Fs(e.return,t,n)}function ns(e,t,n,r,l){var s=e.memoizedState;s===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:l}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=l)}function nc(e,t,n){var r=t.pendingProps,l=r.revealOrder,s=r.tail;if(ae(e,t,r.children,n),r=W.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Xo(e,n,t);else if(e.tag===19)Xo(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(U(W,r),!(t.mode&1))t.memoizedState=null;else switch(l){case"forwards":for(n=t.child,l=null;n!==null;)e=n.alternate,e!==null&&ll(e)===null&&(l=n),n=n.sibling;n=l,n===null?(l=t.child,t.child=null):(l=n.sibling,n.sibling=null),ns(t,!1,l,n,s);break;case"backwards":for(n=null,l=t.child,t.child=null;l!==null;){if(e=l.alternate,e!==null&&ll(e)===null){t.child=l;break}e=l.sibling,l.sibling=n,n=l,l=e}ns(t,!0,n,null,s);break;case"together":ns(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Mr(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Je(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Rt|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(k(153));if(t.child!==null){for(e=t.child,n=ft(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ft(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Lf(e,t,n){switch(t.tag){case 3:ec(t),sn();break;case 5:Pu(t);break;case 1:me(t.type)&&qr(t);break;case 4:Pi(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,l=t.memoizedProps.value;U(tl,r._currentValue),r._currentValue=l;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(U(W,W.current&1),t.flags|=128,null):n&t.child.childLanes?tc(e,t,n):(U(W,W.current&1),e=Je(e,t,n),e!==null?e.sibling:null);U(W,W.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return nc(e,t,n);t.flags|=128}if(l=t.memoizedState,l!==null&&(l.rendering=null,l.tail=null,l.lastEffect=null),U(W,W.current),r)break;return null;case 22:case 23:return t.lanes=0,qu(e,t,n)}return Je(e,t,n)}var rc,Ws,lc,sc;rc=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Ws=function(){};lc=function(e,t,n,r){var l=e.memoizedProps;if(l!==r){e=t.stateNode,Ct(Be.current);var s=null;switch(n){case"input":l=ds(e,l),r=ds(e,r),s=[];break;case"select":l=Q({},l,{value:void 0}),r=Q({},r,{value:void 0}),s=[];break;case"textarea":l=hs(e,l),r=hs(e,r),s=[];break;default:typeof l.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Jr)}vs(n,r);var o;n=null;for(c in l)if(!r.hasOwnProperty(c)&&l.hasOwnProperty(c)&&l[c]!=null)if(c==="style"){var a=l[c];for(o in a)a.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&($n.hasOwnProperty(c)?s||(s=[]):(s=s||[]).push(c,null));for(c in r){var u=r[c];if(a=l!=null?l[c]:void 0,r.hasOwnProperty(c)&&u!==a&&(u!=null||a!=null))if(c==="style")if(a){for(o in a)!a.hasOwnProperty(o)||u&&u.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in u)u.hasOwnProperty(o)&&a[o]!==u[o]&&(n||(n={}),n[o]=u[o])}else n||(s||(s=[]),s.push(c,n)),n=u;else c==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,a=a?a.__html:void 0,u!=null&&a!==u&&(s=s||[]).push(c,u)):c==="children"?typeof u!="string"&&typeof u!="number"||(s=s||[]).push(c,""+u):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&($n.hasOwnProperty(c)?(u!=null&&c==="onScroll"&&A("scroll",e),s||a===u||(s=[])):(s=s||[]).push(c,u))}n&&(s=s||[]).push("style",n);var c=s;(t.updateQueue=c)&&(t.flags|=4)}};sc=function(e,t,n,r){n!==r&&(t.flags|=4)};function jn(e,t){if(!V)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function se(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var l=e.child;l!==null;)n|=l.lanes|l.childLanes,r|=l.subtreeFlags&14680064,r|=l.flags&14680064,l.return=e,l=l.sibling;else for(l=e.child;l!==null;)n|=l.lanes|l.childLanes,r|=l.subtreeFlags,r|=l.flags,l.return=e,l=l.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Rf(e,t,n){var r=t.pendingProps;switch(ki(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return se(t),null;case 1:return me(t.type)&&Zr(),se(t),null;case 3:return r=t.stateNode,an(),B(he),B(oe),zi(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Sr(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Oe!==null&&(Zs(Oe),Oe=null))),Ws(e,t),se(t),null;case 5:Ti(t);var l=Ct(Jn.current);if(n=t.type,e!==null&&t.stateNode!=null)lc(e,t,n,r,l),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(k(166));return se(t),null}if(e=Ct(Be.current),Sr(t)){r=t.stateNode,n=t.type;var s=t.memoizedProps;switch(r[Ue]=t,r[Yn]=s,e=(t.mode&1)!==0,n){case"dialog":A("cancel",r),A("close",r);break;case"iframe":case"object":case"embed":A("load",r);break;case"video":case"audio":for(l=0;l<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[Ue]=t,e[Yn]=r,rc(e,t,!1,!1),t.stateNode=e;e:{switch(o=ys(n,r),n){case"dialog":A("cancel",e),A("close",e),l=r;break;case"iframe":case"object":case"embed":A("load",e),l=r;break;case"video":case"audio":for(l=0;lcn&&(t.flags|=128,r=!0,jn(s,!1),t.lanes=4194304)}else{if(!r)if(e=ll(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),jn(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!V)return se(t),null}else 2*Y()-s.renderingStartTime>cn&&n!==1073741824&&(t.flags|=128,r=!0,jn(s,!1),t.lanes=4194304);s.isBackwards?(o.sibling=t.child,t.child=o):(n=s.last,n!==null?n.sibling=o:t.child=o,s.last=o)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=Y(),t.sibling=null,n=W.current,U(W,r?n&1|2:n&1),t):(se(t),null);case 22:case 23:return Bi(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ye&1073741824&&(se(t),t.subtreeFlags&6&&(t.flags|=8192)):se(t),null;case 24:return null;case 25:return null}throw Error(k(156,t.tag))}function Of(e,t){switch(ki(t),t.tag){case 1:return me(t.type)&&Zr(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return an(),B(he),B(oe),zi(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Ti(t),null;case 13:if(B(W),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(k(340));sn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return B(W),null;case 4:return an(),null;case 10:return Ci(t.type._context),null;case 22:case 23:return Bi(),null;case 24:return null;default:return null}}var Er=!1,ie=!1,If=typeof WeakSet=="function"?WeakSet:Set,E=null;function Xt(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){K(e,t,r)}else n.current=null}function Hs(e,t,n){try{n()}catch(r){K(e,t,r)}}var Jo=!1;function Ff(e,t){if(_s=Gr,e=cu(),wi(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,u=-1,c=0,m=0,p=e,v=null;t:for(;;){for(var y;p!==n||l!==0&&p.nodeType!==3||(a=o+l),p!==s||r!==0&&p.nodeType!==3||(u=o+r),p.nodeType===3&&(o+=p.nodeValue.length),(y=p.firstChild)!==null;)v=p,p=y;for(;;){if(p===e)break t;if(v===n&&++c===l&&(a=o),v===s&&++m===r&&(u=o),(y=p.nextSibling)!==null)break;p=v,v=p.parentNode}p=y}n=a===-1||u===-1?null:{start:a,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ps={focusedElem:e,selectionRange:n},Gr=!1,E=t;E!==null;)if(t=E,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,E=e;else for(;E!==null;){t=E;try{var w=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var g=w.memoizedProps,C=w.memoizedState,f=t.stateNode,d=f.getSnapshotBeforeUpdate(t.elementType===t.type?g:Le(t.type,g),C);f.__reactInternalSnapshotBeforeUpdate=d}break;case 3:var h=t.stateNode.containerInfo;h.nodeType===1?h.textContent="":h.nodeType===9&&h.documentElement&&h.removeChild(h.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(k(163))}}catch(x){K(t,t.return,x)}if(e=t.sibling,e!==null){e.return=t.return,E=e;break}E=t.return}return w=Jo,Jo=!1,w}function Fn(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var s=l.destroy;l.destroy=void 0,s!==void 0&&Hs(t,n,s)}l=l.next}while(l!==r)}}function jl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Qs(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function ic(e){var t=e.alternate;t!==null&&(e.alternate=null,ic(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ue],delete t[Yn],delete t[Ls],delete t[yf],delete t[gf])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function oc(e){return e.tag===5||e.tag===3||e.tag===4}function Zo(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||oc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ks(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Jr));else if(r!==4&&(e=e.child,e!==null))for(Ks(e,t,n),e=e.sibling;e!==null;)Ks(e,t,n),e=e.sibling}function Gs(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Gs(e,t,n),e=e.sibling;e!==null;)Gs(e,t,n),e=e.sibling}var te=null,Re=!1;function qe(e,t,n){for(n=n.child;n!==null;)ac(e,t,n),n=n.sibling}function ac(e,t,n){if(Ae&&typeof Ae.onCommitFiberUnmount=="function")try{Ae.onCommitFiberUnmount(hl,n)}catch{}switch(n.tag){case 5:ie||Xt(n,t);case 6:var r=te,l=Re;te=null,qe(e,t,n),te=r,Re=l,te!==null&&(Re?(e=te,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):te.removeChild(n.stateNode));break;case 18:te!==null&&(Re?(e=te,n=n.stateNode,e.nodeType===8?Xl(e.parentNode,n):e.nodeType===1&&Xl(e,n),Wn(e)):Xl(te,n.stateNode));break;case 4:r=te,l=Re,te=n.stateNode.containerInfo,Re=!0,qe(e,t,n),te=r,Re=l;break;case 0:case 11:case 14:case 15:if(!ie&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var s=l,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&Hs(n,t,o),l=l.next}while(l!==r)}qe(e,t,n);break;case 1:if(!ie&&(Xt(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){K(n,t,a)}qe(e,t,n);break;case 21:qe(e,t,n);break;case 22:n.mode&1?(ie=(r=ie)||n.memoizedState!==null,qe(e,t,n),ie=r):qe(e,t,n);break;default:qe(e,t,n)}}function qo(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new If),t.forEach(function(r){var l=Hf.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function ze(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=o),r&=~s}if(r=l,r=Y()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Mf(r/1960))-r,10e?16:e,lt===null)var r=!1;else{if(e=lt,lt=null,ul=0,F&6)throw Error(k(331));var l=F;for(F|=4,E=e.current;E!==null;){var s=E,o=s.child;if(E.flags&16){var a=s.deletions;if(a!==null){for(var u=0;uY()-Ui?Et(e,0):$i|=n),ve(e,t)}function vc(e,t){t===0&&(e.mode&1?(t=yr,yr<<=1,!(yr&130023424)&&(yr=4194304)):t=1);var n=ue();e=Xe(e,t),e!==null&&(nr(e,t,n),ve(e,n))}function Wf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),vc(e,n)}function Hf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(k(314))}r!==null&&r.delete(t),vc(e,n)}var yc;yc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||he.current)pe=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return pe=!1,Lf(e,t,n);pe=!!(e.flags&131072)}else pe=!1,V&&t.flags&1048576&&ku(t,el,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Mr(e,t),e=t.pendingProps;var l=ln(t,oe.current);tn(t,n),l=Ri(null,t,r,e,l,n);var s=Oi();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,me(r)?(s=!0,qr(t)):s=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,_i(t),l.updater=kl,t.stateNode=l,l._reactInternals=t,Ms(t,r,e,n),t=As(null,t,r,!0,s,n)):(t.tag=0,V&&s&&xi(t),ae(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Mr(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Kf(r),e=Le(r,e),l){case 0:t=Us(null,t,r,e,n);break e;case 1:t=Go(null,t,r,e,n);break e;case 11:t=Qo(null,t,r,e,n);break e;case 14:t=Ko(null,t,r,Le(r.type,e),n);break e}throw Error(k(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Le(r,l),Us(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Le(r,l),Go(e,t,r,l,n);case 3:e:{if(ec(t),e===null)throw Error(k(387));r=t.pendingProps,s=t.memoizedState,l=s.element,_u(e,t),rl(t,r,null,n);var o=t.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){l=un(Error(k(423)),t),t=Yo(e,t,r,n,l);break e}else if(r!==l){l=un(Error(k(424)),t),t=Yo(e,t,r,n,l);break e}else for(ge=at(t.stateNode.containerInfo.firstChild),we=t,V=!0,Oe=null,n=Cu(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(sn(),r===l){t=Je(e,t,n);break e}ae(e,t,r,n)}t=t.child}return t;case 5:return Pu(t),e===null&&Is(t),r=t.type,l=t.pendingProps,s=e!==null?e.memoizedProps:null,o=l.children,Ts(r,l)?o=null:s!==null&&Ts(r,s)&&(t.flags|=32),bu(e,t),ae(e,t,o,n),t.child;case 6:return e===null&&Is(t),null;case 13:return tc(e,t,n);case 4:return Pi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=on(t,null,r,n):ae(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Le(r,l),Qo(e,t,r,l,n);case 7:return ae(e,t,t.pendingProps,n),t.child;case 8:return ae(e,t,t.pendingProps.children,n),t.child;case 12:return ae(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,s=t.memoizedProps,o=l.value,U(tl,r._currentValue),r._currentValue=o,s!==null)if(De(s.value,o)){if(s.children===l.children&&!he.current){t=Je(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var u=a.firstContext;u!==null;){if(u.context===r){if(s.tag===1){u=Ke(-1,n&-n),u.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var m=c.pending;m===null?u.next=u:(u.next=m.next,m.next=u),c.pending=u}}s.lanes|=n,u=s.alternate,u!==null&&(u.lanes|=n),Fs(s.return,n,t),a.lanes|=n;break}u=u.next}}else if(s.tag===10)o=s.type===t.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(k(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),Fs(o,n,t),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===t){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}ae(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,tn(t,n),l=_e(l),r=r(l),t.flags|=1,ae(e,t,r,n),t.child;case 14:return r=t.type,l=Le(r,t.pendingProps),l=Le(r.type,l),Ko(e,t,r,l,n);case 15:return Zu(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Le(r,l),Mr(e,t),t.tag=1,me(r)?(e=!0,qr(t)):e=!1,tn(t,n),Yu(t,r,l),Ms(t,r,l,n),As(null,t,r,!0,e,n);case 19:return nc(e,t,n);case 22:return qu(e,t,n)}throw Error(k(156,t.tag))};function gc(e,t){return Qa(e,t)}function Qf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ce(e,t,n,r){return new Qf(e,t,n,r)}function Wi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Kf(e){if(typeof e=="function")return Wi(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ai)return 11;if(e===ui)return 14}return 2}function ft(e,t){var n=e.alternate;return n===null?(n=Ce(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ar(e,t,n,r,l,s){var o=2;if(r=e,typeof e=="function")Wi(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case At:return _t(n.children,l,s,t);case oi:o=8,l|=8;break;case os:return e=Ce(12,n,t,l|2),e.elementType=os,e.lanes=s,e;case as:return e=Ce(13,n,t,l),e.elementType=as,e.lanes=s,e;case us:return e=Ce(19,n,t,l),e.elementType=us,e.lanes=s,e;case Pa:return Nl(n,l,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Ea:o=10;break e;case _a:o=9;break e;case ai:o=11;break e;case ui:o=14;break e;case be:o=16,r=null;break e}throw Error(k(130,e==null?e:typeof e,""))}return t=Ce(o,n,t,l),t.elementType=e,t.type=r,t.lanes=s,t}function _t(e,t,n,r){return e=Ce(7,e,r,t),e.lanes=n,e}function Nl(e,t,n,r){return e=Ce(22,e,r,t),e.elementType=Pa,e.lanes=n,e.stateNode={isHidden:!1},e}function rs(e,t,n){return e=Ce(6,e,null,t),e.lanes=n,e}function ls(e,t,n){return t=Ce(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Gf(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=$l(0),this.expirationTimes=$l(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$l(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Hi(e,t,n,r,l,s,o,a,u){return e=new Gf(e,t,n,a,u),t===1?(t=1,s===!0&&(t|=8)):t=0,s=Ce(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},_i(s),e}function Yf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(jc)}catch(e){console.error(e)}}jc(),ja.exports=ke;var bf=ja.exports,Sc,ia=bf;Sc=ia.createRoot,ia.hydrateRoot;const Nc="bv.access",Yi="bv.refresh";function qs(e){try{return localStorage.getItem(e)||""}catch{return""}}function oa(e,t){try{t?localStorage.setItem(e,t):localStorage.removeItem(e)}catch{}}function ir(){return{access:qs(Nc),refresh:qs(Yi)}}function fl(e,t){oa(Nc,e),oa(Yi,t)}function or(){fl("","")}function ep(){return!!qs(Yi)}class Pt extends Error{constructor(t,n,r){super(r),this.status=t,this.code=n}}let Nn=null;async function Tl(){return Nn||(Nn=(async()=>{const{refresh:e}=ir();if(!e)throw new Pt(401,"unauthorized","Signed out.");const t=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e})});if(!t.ok)throw or(),new Pt(t.status,"unauthorized","Your session has ended. Sign in again.");const n=await t.json();return fl(n.access_token,n.refresh_token),n})().finally(()=>{Nn=null}),Nn)}async function D(e,t,n,r=!0){const{access:l}=ir(),s={};l&&(s.Authorization="Bearer "+l),n!==void 0&&(s["Content-Type"]="application/json");const o=await fetch(t,{method:e,headers:s,body:n===void 0?void 0:JSON.stringify(n)});if(o.status===204)return null;const a=await o.text();let u=null;try{u=a?JSON.parse(a):null}catch{}if(o.ok)return u;const c=(u==null?void 0:u.error)||"";if(c==="token_expired"&&r)return await Tl(),D(e,t,n,!1);throw o.status===401&&or(),new Pt(o.status,c,(u==null?void 0:u.message)||`Something went wrong (${o.status}).`)}async function Cc(e,t=!0){const{access:n}=ir(),r=await fetch(e,{headers:n?{Authorization:"Bearer "+n}:{}});if(r.ok)return URL.createObjectURL(await r.blob());let l=null;try{l=await r.json()}catch{}const s=(l==null?void 0:l.error)||"";if(s==="token_expired"&&t)return await Tl(),Cc(e,!1);throw r.status===401&&or(),new Pt(r.status,s,(l==null?void 0:l.message)||`That picture could not be loaded (${r.status}).`)}function aa(){const e=navigator.userAgent||"",t=/Windows/.test(e)?"Windows":/Mac OS X|Macintosh/.test(e)?"Mac":/Android/.test(e)?"Android":/iPhone|iPad/.test(e)?"iOS":"Unknown";return`${/Edg\//.test(e)?"Edge":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)?"Safari":/Firefox\//.test(e)?"Firefox":"browser"} on ${t}`}const jt=e=>{const t=new URLSearchParams;for(const[r,l]of Object.entries(e||{}))l!=null&&l!==""&&t.set(r,l);const n=t.toString();return n?"?"+n:""},M={async login(e,t){const n=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:t,device:aa()})}),r=await n.json().catch(()=>null);if(!n.ok)throw new Pt(n.status,(r==null?void 0:r.error)||"",(r==null?void 0:r.message)||"Could not sign in.");return fl(r.access_token,r.refresh_token),r.user},async previewInvitation(e){const t=await fetch("/api/auth/invitation"+jt({code:e})),n=await t.json().catch(()=>null);if(!t.ok)throw new Pt(t.status,(n==null?void 0:n.error)||"",(n==null?void 0:n.message)||"That invitation code is not valid.");return n},async register({code:e,full_name:t,password:n}){const r=await fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,full_name:t,password:n,device:aa()})}),l=await r.json().catch(()=>null);if(!r.ok)throw new Pt(r.status,(l==null?void 0:l.error)||"",(l==null?void 0:l.message)||"Could not create the account.");return fl(l.access_token,l.refresh_token),l.user},async logout(){try{await D("POST","/api/auth/logout")}catch{}or()},me:()=>D("GET","/api/auth/me"),sites:()=>D("GET","/api/sites"),createSite:e=>D("POST","/api/sites",e),updateSite:(e,t)=>D("PATCH",`/api/sites/${encodeURIComponent(e)}`,t),deleteSite:e=>D("DELETE",`/api/sites/${encodeURIComponent(e)}`),arrivals:e=>D("GET","/api/visits"+jt(e)),visitors:(e,t=50)=>D("GET","/api/visitors"+jt({q:e,limit:t})),visitorHistory:(e,t=50)=>D("GET",`/api/visitors/${encodeURIComponent(e)}/history`+jt({limit:t})),saveProfile:(e,t)=>D("PUT",`/api/visitors/${encodeURIComponent(e)}/profile`,t),footfall:e=>D("GET","/api/reports/footfall"+jt(e)),conversion:e=>D("GET","/api/reports/conversion"+jt(e)),cameras:()=>D("GET","/api/cameras"),cameraSnapshot:e=>Cc(e),createCamera:(e,t)=>D("POST",`/api/sites/${encodeURIComponent(e)}/cameras`,t),updateCamera:(e,t)=>D("PATCH",`/api/cameras/${encodeURIComponent(e)}`,t),deleteCamera:e=>D("DELETE",`/api/cameras/${encodeURIComponent(e)}`),checkCamera:(e,t,n)=>D("POST",`/api/cameras/${encodeURIComponent(e)}/check`,{kind:t,...n?{seconds:n}:{}}),siteCheck:e=>D("GET",`/api/sites/${encodeURIComponent(e)}/check`),enrolmentCode:(e,t)=>D("POST",`/api/sites/${encodeURIComponent(e)}/enrolment-code`,t||{}),ask:e=>D("POST","/api/assistant",{history:e}),clients:()=>D("GET","/api/admin/clients"),createClient:e=>D("POST","/api/admin/clients",e),team:()=>D("GET","/api/team"),updateMember:(e,t)=>D("PATCH",`/api/team/${encodeURIComponent(e)}`,t),invitations:()=>D("GET","/api/team/invitations"),invite:e=>D("POST","/api/team/invitations",e),revokeInvitation:e=>D("DELETE",`/api/team/invitations/${encodeURIComponent(e)}`),sessions:()=>D("GET","/api/auth/sessions"),revokeSession:e=>D("DELETE",`/api/auth/sessions/${encodeURIComponent(e)}`),signOutOthers:()=>D("POST","/api/auth/sessions/revoke-others")};function tp({cursor:e,siteId:t,onPage:n,onError:r,signal:l}){let s=!1,o=e||"";return(async()=>{for(;!s;){try{const{access:u}=ir(),c=await fetch("/api/visits/stream"+jt({cursor:o,site_id:t}),{headers:{Authorization:"Bearer "+u,Accept:"text/event-stream"},signal:l});if(c.status===401){await Tl();continue}if(!c.ok||!c.body)throw new Error("stream unavailable");const m=c.body.getReader(),p=new TextDecoder;let v="";for(;!s;){const{value:y,done:w}=await m.read();if(w)break;v+=p.decode(y,{stream:!0});let g;for(;(g=v.indexOf(` -`))!==-1;){const N=v.slice(0,g);v=v.slice(g+2);for(const f of N.split(` -`))if(f.startsWith("id: "))o=f.slice(4).trim();else if(f.startsWith("data: "))try{n(JSON.parse(f.slice(6)))}catch{}}}}catch(u){if(s||l!=null&&l.aborted)return;r==null||r(u)}if(s)return;await new Promise(u=>setTimeout(u,3e3))}})(),()=>{s=!0}}function np({cameraId:e,img:t,onState:n,signal:r}){let l=!1;return(async()=>{for(;!l;){try{const{access:o}=ir(),a=await fetch(`/api/cameras/${e}/live`,{headers:{Authorization:"Bearer "+o,Accept:"text/event-stream"},signal:r});if(a.status===401){await Tl();continue}if(!a.ok||!a.body)throw new Error("live view unavailable");const u=a.body.getReader(),c=new TextDecoder;let m="";for(;!l;){const{value:h,done:v}=await u.read();if(v)break;m+=c.decode(h,{stream:!0});let y;for(;(y=m.indexOf(` +`))!==-1;){const C=v.slice(0,g);v=v.slice(g+2);for(const f of C.split(` +`))if(f.startsWith("id: "))o=f.slice(4).trim();else if(f.startsWith("data: "))try{n(JSON.parse(f.slice(6)))}catch{}}}}catch(u){if(s||l!=null&&l.aborted)return;r==null||r(u)}if(s)return;await new Promise(u=>setTimeout(u,3e3))}})(),()=>{s=!0}}function np({cameraId:e,img:t,onState:n,signal:r}){let l=!1;return(async()=>{for(;!l;){try{const{access:o}=ir(),a=await fetch(`/api/cameras/${e}/live`,{headers:{Authorization:"Bearer "+o,Accept:"text/event-stream"},signal:r});if(a.status===401){await Tl();continue}if(!a.ok||!a.body)throw new Error("live view unavailable");const u=a.body.getReader(),c=new TextDecoder;let m="";for(;!l;){const{value:p,done:v}=await u.read();if(v)break;m+=c.decode(p,{stream:!0});let y;for(;(y=m.indexOf(` -`))!==-1;){const x=m.slice(0,y);m=m.slice(y+2);let g="message",N="";for(const f of x.split(` -`))f.startsWith("event: ")?g=f.slice(7).trim():f.startsWith("data: ")&&(N=f.slice(6));g==="frame"&&N?(t.current&&(t.current.src="data:image/jpeg;base64,"+N),n==null||n("live")):g==="waiting"&&(n==null||n("waiting"))}}}catch{if(l||r!=null&&r.aborted)return;n==null||n("reconnecting")}if(l)return;await new Promise(o=>setTimeout(o,1500))}})(),()=>{l=!0}}function rp({onSignedIn:e}){const[t,n]=j.useState(!1);return t?i.jsx(sp,{onSignedIn:e,onCancel:()=>n(!1)}):i.jsx(lp,{onSignedIn:e,onJoin:()=>n(!0)})}function lp({onSignedIn:e,onJoin:t}){const[n,r]=j.useState(""),[l,s]=j.useState(""),[o,a]=j.useState(""),[u,c]=j.useState(!1),m=async h=>{h.preventDefault(),c(!0),a("");try{await D.login(n.trim(),l),e(await D.me())}catch(v){a(v.message),c(!1)}};return i.jsx("div",{className:"signin",children:i.jsxs("form",{className:"card",onSubmit:m,children:[i.jsx("span",{className:"mark big","aria-hidden":"true"}),i.jsx("h1",{children:"Behavision"}),i.jsx("p",{className:"sub",children:"Sign in to your company account."}),i.jsxs("label",{children:["Email",i.jsx("input",{type:"email",value:n,autoComplete:"username",autoFocus:!0,required:!0,onChange:h=>r(h.target.value),placeholder:"you@company.com"})]}),i.jsxs("label",{children:["Password",i.jsx("input",{type:"password",value:l,autoComplete:"current-password",required:!0,onChange:h=>s(h.target.value)})]}),o&&i.jsx("p",{className:"error",role:"alert",children:o}),i.jsx("button",{className:"primary",disabled:u||!n||!l,children:u?"Signing in…":"Sign in"}),i.jsxs("p",{className:"foot",children:["Been invited? ",i.jsx("button",{type:"button",className:"linkish",onClick:t,children:"Use your invitation code"})]})]})})}function sp({onSignedIn:e,onCancel:t}){const[n,r]=j.useState(""),[l,s]=j.useState(null),[o,a]=j.useState(""),[u,c]=j.useState(""),[m,h]=j.useState(""),[v,y]=j.useState(""),[x,g]=j.useState(!1),N=async d=>{d.preventDefault(),g(!0),y("");try{const p=await D.previewInvitation(n.trim());s(p),a(p.full_name||"")}catch(p){y(p.message)}finally{g(!1)}},f=async d=>{if(d.preventDefault(),u!==m){y("Those two passwords are not the same.");return}g(!0),y("");try{const p=await D.register({code:n.trim(),full_name:o,password:u});e(p)}catch(p){y(p.message),g(!1)}};return i.jsx("div",{className:"signin",children:i.jsxs("form",{className:"card",onSubmit:l?f:N,children:[i.jsx("span",{className:"mark big","aria-hidden":"true"}),i.jsx("h1",{children:l?`Join ${l.client_name}`:"Behavision"}),l?i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"sub",children:["You are joining as ",i.jsx("b",{children:l.role}),", signing in with"," ",i.jsx("code",{children:l.email}),". Choose a password only you know."]}),i.jsxs("label",{children:["Your name",i.jsx("input",{value:o,onChange:d=>a(d.target.value),autoFocus:!0,autoComplete:"name"})]}),i.jsxs("label",{children:["Password",i.jsx("input",{type:"password",value:u,required:!0,minLength:8,autoComplete:"new-password",onChange:d=>c(d.target.value)}),i.jsx("span",{className:"hint",children:"At least 8 characters. Longer is the only thing that helps."})]}),i.jsxs("label",{children:["Password again",i.jsx("input",{type:"password",value:m,required:!0,autoComplete:"new-password",onChange:d=>h(d.target.value)})]}),v&&i.jsx("p",{className:"error",role:"alert",children:v}),i.jsx("button",{className:"primary",disabled:x||!u||!m,children:x?"Creating your account…":"Create account and sign in"})]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"sub",children:"Enter the invitation code you were given."}),i.jsxs("label",{children:["Invitation code",i.jsx("input",{value:n,onChange:d=>r(d.target.value),autoFocus:!0,required:!0,autoComplete:"off",spellCheck:"false",placeholder:"ABCDEF-123456-GHIJKL-789012",className:"codefield"}),i.jsx("span",{className:"hint",children:"Dashes and capitals do not matter."})]}),v&&i.jsx("p",{className:"error",role:"alert",children:v}),i.jsx("button",{className:"primary",disabled:x||!n.trim(),children:x?"Checking…":"Continue"})]}),i.jsx("p",{className:"foot",children:i.jsx("button",{type:"button",className:"linkish",onClick:t,children:"Back to sign in"})})]})})}function It(e,t,n=[]){const[r,l]=j.useState(null),[s,o]=j.useState(null),[a,u]=j.useState(!0),c=j.useRef(!1),m=j.useRef(!0),h=j.useCallback(async()=>{if(!c.current){c.current=!0;try{const v=await e();if(!m.current)return;l(v),o(null)}catch(v){if(!m.current)return;o(v)}finally{c.current=!1,m.current&&u(!1)}}},n);return j.useEffect(()=>{if(m.current=!0,h(),!t)return()=>{m.current=!1};const v=setInterval(h,t);return()=>{m.current=!1,clearInterval(v)}},[h,t]),{data:r,error:s,loading:a,reload:h}}function ip(e){const[t,n]=j.useState(null);return j.useEffect(()=>{if(!e){n(null);return}let r=!0,l=null;return D.cameraSnapshot(e).then(s=>{if(!r){URL.revokeObjectURL(s);return}l=s,n(s)}).catch(()=>{r&&n(null)}),()=>{r=!1,l&&URL.revokeObjectURL(l)}},[e]),t}function Xi({image:e,url:t,alt:n}){const r=e?e.url:t,l=e&&!!e.auth||typeof r=="string"&&r.startsWith("/"),s=ip(l?r:null),o=l?s:r;return o?i.jsx("img",{src:o,alt:n,loading:"lazy"}):null}function op({site:e,user:t,onClose:n,onChanged:r}){const[l,s]=j.useState(null),[o,a]=j.useState(!1),[u,c]=j.useState(""),m=async()=>{a(!0),c(""),s(null);try{s(await D.siteCheck(e.site_id))}catch(h){c(h.message)}finally{a(!1)}};return i.jsx("div",{className:"overlay",onClick:n,children:i.jsxs("aside",{className:"drawer",onClick:h=>h.stopPropagation(),children:[i.jsxs("header",{className:"drawer-head",children:[i.jsxs("div",{children:[i.jsxs("h2",{children:["Is ",e.name," working?"]}),i.jsx("p",{className:"sub",children:"Checks the whole chain, from the shop’s PC to head office."})]}),i.jsx("button",{className:"ghost",onClick:n,children:"Close"})]}),i.jsxs("div",{className:"drawer-body",children:[!l&&!o&&i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"sub",children:"Nothing is changed and no one is disturbed — this reads what the shop has already reported."}),i.jsx("button",{className:"primary",onClick:m,children:"Run the check"})]}),o&&i.jsxs("div",{className:"waiting",children:[i.jsx("span",{className:"spinner","aria-hidden":"true"}),i.jsx("b",{children:"Checking…"})]}),u&&i.jsx("p",{className:"error",role:"alert",children:u}),l&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"banner "+(l.ok?"ok":"warn"),children:i.jsxs("div",{children:[i.jsx("b",{children:l.ok?"This shop is working.":"This shop needs attention."}),!l.ok&&i.jsx(i.Fragment,{children:" Work down the list — the first failure usually explains the rest."})]})}),i.jsx("ol",{className:"checklist",children:l.steps.map(h=>i.jsxs("li",{className:h.status,children:[i.jsx("span",{className:"mark","aria-hidden":"true",children:h.status==="pass"?"✓":h.status==="fail"?"✕":h.status==="warn"?"!":"–"}),i.jsxs("div",{children:[i.jsx("b",{children:h.name}),i.jsx("span",{className:"sub",children:h.detail}),h.advice&&i.jsx("span",{className:"advice-line",children:h.advice})]})]},h.name))}),i.jsx("button",{className:"ghost",onClick:m,children:"Check again"})]}),i.jsx(ap,{site:e}),i.jsx(dp,{site:e,user:t,onChanged:r,onClose:n})]})]})})}function ap({site:e}){const[t,n]=j.useState(null),[r,l]=j.useState(!1),[s,o]=j.useState(""),[a,u]=j.useState(""),c=async()=>{l(!0),o("");try{n(await D.enrolmentCode(e.site_id,{label:a.trim()}))}catch(m){o(m.message)}finally{l(!1)}};return i.jsxs("section",{className:"claim",children:[i.jsx("h3",{children:"Set up a shop PC"}),t?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"code","aria-live":"polite",children:t.code}),i.jsxs("p",{className:"sub",children:["Copy this now — it cannot be shown again. It works once, and stops working ",cp(t.expires_at),"."]}),i.jsxs("div",{className:"row",children:[i.jsx("button",{className:"ghost",onClick:()=>up(t.code),children:"Copy"}),i.jsx("button",{className:"ghost",onClick:()=>n(null),children:"Done"})]})]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"sub",children:"Creates a one-time code to type into Behavision on the shop’s computer. Use one for a new shop, a replacement PC, or a reinstall."}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"What is this PC? (optional)"}),i.jsx("input",{value:a,placeholder:"counter PC",onChange:m=>u(m.target.value)})]}),s&&i.jsx("p",{className:"error",role:"alert",children:s}),i.jsx("button",{className:"ghost",onClick:c,disabled:r,children:r?"Creating…":"Create an installation code"})]})]})}function up(e){var t;try{(t=navigator.clipboard)==null||t.writeText(e)}catch{}}function cp(e){const t=new Date(e).getTime();if(Number.isNaN(t))return"shortly";const n=Math.round((t-Date.now())/864e5);return n<=0?"today":n===1?"tomorrow":`in ${n} days`}function dp({site:e,user:t,onChanged:n,onClose:r}){const[l,s]=j.useState(e.name),[o,a]=j.useState(e.timezone||"Asia/Kolkata"),[u,c]=j.useState(!1),[m,h]=j.useState(""),[v,y]=j.useState(!1),x=(t==null?void 0:t.role)==="owner"||(t==null?void 0:t.role)==="manager",g=(t==null?void 0:t.role)==="owner";if(!x)return null;const N=l.trim()!==e.name||o.trim()!==(e.timezone||"Asia/Kolkata"),f=async p=>{p.preventDefault(),c(!0),h("");try{await D.updateSite(e.slug||e.site_id,{name:l.trim(),timezone:o.trim()}),n==null||n()}catch(w){h(w.message)}finally{c(!1)}},d=async()=>{c(!0),h("");try{await D.deleteSite(e.slug||e.site_id),n==null||n(),r==null||r()}catch(p){h(p.message),y(!1)}finally{c(!1)}};return i.jsxs("section",{className:"claim",children:[i.jsx("h3",{children:"Shop details"}),i.jsxs("form",{onSubmit:f,children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Name"}),i.jsx("input",{value:l,onChange:p=>s(p.target.value),required:!0})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Short name"}),i.jsx("input",{value:e.slug,readOnly:!0}),i.jsx("span",{className:"hint",children:"Fixed: the shop PC and the broker are keyed on it."})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Timezone"}),i.jsx("input",{value:o,onChange:p=>a(p.target.value)})]}),m&&i.jsx("p",{className:"error",role:"alert",children:m}),i.jsxs("div",{className:"row",children:[i.jsx("button",{className:"primary",disabled:u||!N,children:u?"Saving…":"Save"}),g&&!v&&i.jsx("button",{type:"button",className:"ghost danger",onClick:()=>y(!0),children:"Remove this shop…"})]})]}),v&&i.jsxs("div",{className:"banner warn",style:{marginTop:12},children:[i.jsxs("b",{children:["Remove ",e.name,"?"]}),i.jsx("p",{className:"sub",children:"Only possible while it has no cameras and no visits. A shop with history is kept."}),i.jsxs("div",{className:"row",children:[i.jsx("button",{className:"primary",disabled:u,onClick:d,children:u?"Removing…":"Yes, remove it"}),i.jsx("button",{className:"ghost",onClick:()=>y(!1),children:"Keep it"})]})]})]})}function fp({user:e}){const{data:t,error:n,loading:r,reload:l}=It(()=>D.sites(),2e4,[]),{data:s}=It(()=>D.cameras(),6e4,[]),[o,a]=j.useState(null),[u,c]=j.useState(!1),m=t||[],h=(e==null?void 0:e.role)==="owner";if(r&&!t)return i.jsx(ar,{});if(n)return i.jsx(ur,{error:n});if(!m.length&&!u)return i.jsx(xp,{canOpen:h,onOpen:()=>c(!0)});const v=m.map(f=>{const d=(s||[]).filter(p=>p.site_id===f.site_id);return{site:f,cams:d,verdict:hp(f,d)}}),y=f=>v.filter(d=>d.verdict.tone===f).length,x=y("bad"),g=y("warn"),N=y("idle");return i.jsxs(i.Fragment,{children:[i.jsxs("header",{className:"head",children:[i.jsx("h1",{children:"Shops"}),i.jsxs("p",{className:"sub",children:[m.length," ",m.length===1?"shop":"shops",x>0&&i.jsxs(i.Fragment,{children:[" · ",i.jsxs("b",{className:"bad",children:[x," not working"]})]}),g>0&&i.jsxs(i.Fragment,{children:[" · ",i.jsxs("b",{className:"warn",children:[g," needing attention"]})]}),N>0&&i.jsxs(i.Fragment,{children:[" · ",N," not set up yet"]}),!x&&!g&&!N&&i.jsxs(i.Fragment,{children:[" · ",i.jsx("b",{className:"ok",children:"all working"})]})]}),h&&i.jsx("button",{className:"primary",onClick:()=>c(!0),children:"Open a new shop"})]}),i.jsx("div",{className:"grid sites",children:v.map(f=>i.jsx(vp,{site:f.site,cams:f.cams,verdict:f.verdict,onCheck:()=>a(f.site)},f.site.site_id))}),o&&i.jsx(op,{site:o,user:e,onClose:()=>a(null),onChanged:l}),u&&i.jsx(pp,{onClose:()=>c(!1),onCreated:()=>{c(!1),l()}})]})}function pp({onClose:e,onCreated:t}){const[n,r]=j.useState({name:"",slug:"",timezone:"Asia/Kolkata"}),[l,s]=j.useState(!1),[o,a]=j.useState(""),u=m=>h=>r({...n,[m]:h.target.value}),c=async m=>{m.preventDefault(),s(!0),a("");try{t(await D.createSite({name:n.name,slug:n.slug||void 0,timezone:n.timezone}))}catch(h){a(h.message),s(!1)}};return i.jsx("div",{className:"overlay",onClick:e,children:i.jsxs("aside",{className:"drawer narrow",onClick:m=>m.stopPropagation(),children:[i.jsxs("header",{className:"drawer-head",children:[i.jsx("h2",{children:"Open a new shop"}),i.jsx("button",{className:"ghost",onClick:e,children:"Close"})]}),i.jsxs("form",{className:"drawer-body",onSubmit:c,children:[i.jsxs("label",{children:["Shop name",i.jsx("input",{value:n.name,onChange:u("name"),required:!0,autoFocus:!0,placeholder:"TeNext Bengaluru"})]}),i.jsxs("label",{children:["Short name",i.jsx("input",{value:n.slug,onChange:u("slug"),placeholder:"made from the name if left empty"}),i.jsx("span",{className:"hint",children:"Lower-case letters, digits and dashes. It becomes the shop PC’s identity and cannot be changed afterwards."})]}),i.jsxs("label",{children:["Timezone",i.jsx("input",{value:n.timezone,onChange:u("timezone"),required:!0}),i.jsx("span",{className:"hint",children:"Footfall is bucketed by the shop’s own clock, e.g. Asia/Kolkata."})]}),o&&i.jsx("p",{className:"error",role:"alert",children:o}),i.jsx("button",{className:"primary",disabled:l||!n.name.trim(),children:l?"Opening…":"Open shop"})]})]})})}function hp(e,t){const n=e.fraction_below_gate,r=e.cameras_total||t.length;return e.online?e.dropped>0?{tone:"bad",mark:"✕",words:`${e.dropped} visits lost and unrecoverable`}:r===0?{tone:"idle",mark:"+",headline:"Not set up",words:"No cameras set up yet"}:e.cameras_up===0?{tone:"bad",mark:"✕",words:"No cameras connected"}:e.cameras_up.5?{tone:"bad",mark:"✕",words:`${bs(n)} of faces too poor to recognise`}:n>.2?{tone:"warn",mark:"!",words:`${bs(n)} of faces too poor to recognise`}:e.queued>0?{tone:"warn",mark:"!",words:`${e.queued} visits waiting to upload`}:{tone:"ok",mark:"✓",words:`Working — ${r} ${r===1?"camera":"cameras"} connected`}:{tone:"bad",mark:"✕",headline:"Offline",words:`Offline — last heard from ${Ft(e.last_heartbeat_at)}`}}const mp={ok:"Working",warn:"Needs attention",bad:"Not working",idle:"Not set up"};function vp({site:e,cams:t,verdict:n,onCheck:r}){const l=e.fraction_below_gate,s=n.tone,o=n.headline||mp[s],a=yp(t),u=e.cameras_total||t.length;return i.jsxs("article",{className:"card site state-"+s,onClick:r,role:"button",tabIndex:0,onKeyDown:c=>c.key==="Enter"&&r(),children:[i.jsxs("div",{className:"shot",children:[a.url?i.jsx(Xi,{image:a,alt:`View inside ${e.name}`}):i.jsxs("div",{className:"noshot",children:[i.jsx(gp,{}),a.reason&&i.jsx("span",{children:a.reason})]}),i.jsxs("div",{className:"shot-over",children:[i.jsxs("div",{className:"shot-name",children:[i.jsx("b",{children:e.name}),i.jsx("span",{children:u>0?`${u} ${u===1?"camera":"cameras"}`:"No cameras yet"})]}),i.jsxs("span",{className:"status "+s,children:[i.jsx("i",{"aria-hidden":"true"}),o]})]}),a.at&&i.jsx("span",{className:"shot-age",children:Ft(a.at)})]}),i.jsxs("div",{className:"metrics",children:[i.jsx(ss,{label:"Cameras",value:u?`${e.cameras_up}/${u}`:"—",tone:u?e.cameras_up0?bs(1-l):"—",tone:l?l>.5?"bad":l>.2?"warn":"ok":"idle"}),i.jsx(ss,{label:"Last seen",value:Ft(e.last_heartbeat_at),tone:e.online?"ok":"bad"})]}),i.jsxs("div",{className:"verdict "+n.tone,children:[i.jsx("span",{className:"mark","aria-hidden":"true",children:n.mark}),i.jsx("span",{className:"words",children:n.words}),i.jsx("span",{className:"go","aria-hidden":"true",children:"→"})]})]})}function ss({label:e,value:t,tone:n}){return i.jsxs("div",{className:"metric",children:[i.jsx("b",{className:n,children:t}),i.jsx("span",{children:e})]})}function yp(e){var r;if(!e.length)return{};let t=null;for(const l of e)!((r=l.snapshot)!=null&&r.available)||!l.snapshot.url||(!t||(l.snapshot_at||"")>(t.snapshot_at||""))&&(t=l);return t?{...t.snapshot,at:t.snapshot_at}:{reason:e.map(l=>{var s;return(s=l.snapshot)==null?void 0:s.reason}).find(Boolean)||"No picture from this shop yet."}}function gp(){return i.jsxs("svg",{className:"shopmark",viewBox:"0 0 40 32","aria-hidden":"true",children:[i.jsx("path",{d:"M4 12h32v18H4z"}),i.jsx("path",{d:"M2 12l4-8h28l4 8"}),i.jsx("path",{d:"M15 30v-9h10v9"})]})}function bs(e){return`${Math.round(e*100)}%`}function Ft(e){if(!e)return"never";const t=new Date(e).getTime();if(Number.isNaN(t))return"—";const n=Math.max(0,(Date.now()-t)/1e3);if(n<90)return"just now";const r=Math.round(n/60);if(r<60)return`${r} min ago`;const l=Math.round(r/60);return l<48?`${l} h ago`:`${Math.round(l/24)} days ago`}function wp(e){if(!e)return"never";const t=new Date(e).getTime();if(Number.isNaN(t))return"—";const n=(t-Date.now())/1e3;if(n<=0)return"expired";const r=Math.round(n/60);if(r<60)return`in ${r} min`;const l=Math.round(r/60);return l<48?`in ${l} h`:`in ${Math.round(l/24)} days`}function ar(){return i.jsxs("div",{className:"state",children:[i.jsx("span",{className:"spinner","aria-hidden":"true"}),"Loading…"]})}function ur({error:e}){return i.jsx("div",{className:"state",children:i.jsx("p",{className:"error",role:"alert",children:e.message})})}function xp({canOpen:e,onOpen:t}){return i.jsxs("div",{className:"state",children:[i.jsx("h2",{children:"No shops yet"}),i.jsx("p",{className:"sub",children:e?"Open your first shop, then set up its PC and cameras from its card.":"The owner opens shops; they appear here once created."}),e&&i.jsx("button",{className:"primary",onClick:t,children:"Open a new shop"})]})}const ua=60;function kp(){const[e,t]=j.useState([]),[n,r]=j.useState("connecting"),[l,s]=j.useState(null),o=j.useRef(new Set);return j.useEffect(()=>{const a=new AbortController;let u=()=>{};return(async()=>{try{const c=await D.arrivals({limit:30}),m=c.arrivals||[];m.forEach(h=>o.current.add(h.visit_id)),t(m.slice().reverse()),r("live"),u=tp({cursor:c.cursor,signal:a.signal,onPage:h=>{const v=(h.arrivals||[]).filter(y=>!o.current.has(y.visit_id));v.length&&(v.forEach(y=>o.current.add(y.visit_id)),r("live"),t(y=>[...v.reverse(),...y].slice(0,ua)))},onError:()=>r("reconnecting")})}catch(c){s(c)}})(),()=>{a.abort(),u()}},[]),l?i.jsx(ur,{error:l}):n==="connecting"&&!e.length?i.jsx(ar,{}):i.jsxs(i.Fragment,{children:[i.jsxs("header",{className:"head",children:[i.jsx("h1",{children:"Live"}),i.jsxs("p",{className:"sub",children:[i.jsx("span",{className:"dot "+(n==="live"?"ok":"warn"),"aria-hidden":"true"}),n==="live"?"Connected":"Reconnecting…"," · ","last ",ua," arrivals"]})]}),e.length===0?i.jsxs("div",{className:"state",children:[i.jsx("h2",{children:"Nobody yet"}),i.jsx("p",{className:"sub",children:"Arrivals appear here the moment a camera recognises someone."})]}):i.jsx("ul",{className:"arrivals",children:e.map(a=>i.jsx(jp,{a},a.visit_id))})]})}function jp({a:e}){const t=e.name||e.label||"Unidentified";return i.jsxs("li",{className:"card arrival",children:[i.jsx(Sp,{image:e.image,name:t,customerRef:e.visitor_ref}),i.jsxs("div",{className:"who-col",children:[i.jsx("strong",{children:t}),i.jsxs("span",{className:"sub",children:[e.name&&e.visitor_ref?`${e.visitor_ref} · `:"",e.site,e.camera_id?` · ${e.camera_id}`:""," · ",Ft(e.occurred_at)]}),e.attributes&&i.jsx(Ep,{attrs:e.attributes})]}),e.is_new_visitor?i.jsx("span",{className:"pill new",children:"New"}):i.jsx("span",{className:"pill",children:"Returning"})]})}function Sp({image:e,name:t,customerRef:n}){return e!=null&&e.available?i.jsx("span",{className:"face",children:i.jsx(Xi,{image:e,alt:""})}):i.jsx("span",{className:"face initials",title:(e==null?void 0:e.reason)||"","aria-hidden":"true",children:Np(t,n)})}function Np(e,t){const n=/^Visitor (\d+)$/.exec(String(e).trim());if(n)return n[1];if(t){const r=/^V-(\d+)$/.exec(t);if(r)return r[1]}return Cp(e)}function Cp(e){const t=String(e).trim().split(/\s+/).filter(Boolean);return t.length?t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[t.length-1][0]).toUpperCase():"?"}function Ep({attrs:e}){const t=[];return e.gender&&t.push(e.gender),e.age&&t.push(`~${Math.round(e.age)}`),e.emotion&&t.push(e.emotion),t.length?i.jsx("span",{className:"attrs",children:t.join(" · ")}):null}function _p({camera:e,onClose:t}){const n=j.useRef(null),[r,l]=j.useState("waiting"),[s,o]=j.useState(!1);j.useEffect(()=>{const c=new AbortController,m=np({cameraId:e.id,img:n,onState:v=>{l(v),v==="live"&&o(!1)},signal:c.signal}),h=setTimeout(()=>o(!0),12e3);return()=>{m(),c.abort(),clearTimeout(h)}},[e.id]);const a=e.connected===!1?"This camera was not connecting when the shop PC last reported. Check it is powered on and reachable on the shop’s network.":e.connected==null?"The shop PC has not reported on this camera yet. It may still be starting up.":"The shop PC is not sending frames. It may be offline, or its Behavision app may not be running.",u=s&&r!=="live"?a:{waiting:"Asking the shop PC…",live:"Live",reconnecting:"Reconnecting…"}[r];return i.jsx("div",{className:"overlay",onClick:t,children:i.jsxs("aside",{className:"drawer live",onClick:c=>c.stopPropagation(),children:[i.jsxs("header",{className:"drawer-head",children:[i.jsxs("div",{children:[i.jsx("h2",{children:e.label}),i.jsx("p",{className:"sub",children:e.site})]}),i.jsx("button",{className:"ghost",onClick:t,children:"Close"})]}),i.jsxs("div",{className:"drawer-body",children:[i.jsxs("div",{className:"liveshot",children:[i.jsx("img",{ref:n,alt:`Live view from ${e.label}`}),r!=="live"&&i.jsx("div",{className:"livewait",children:i.jsx("span",{children:s?"No picture yet":u})})]}),i.jsx("p",{className:"hint",style:{marginTop:10},children:r==="live"?"Live. The shop only uploads while this view is open.":u})]})]})})}const Br=[{id:"hikvision",label:"Hikvision",path:"/Streaming/Channels/101",note:"Channel 1, main stream. Use /Streaming/Channels/102 for the lower-quality sub stream."},{id:"dahua",label:"Dahua",path:"/cam/realmonitor?channel=1&subtype=0",note:"Channel 1, main stream. subtype=1 is the sub stream."},{id:"cpplus",label:"CP Plus",path:"/cam/realmonitor?channel=1&subtype=0",note:"CP Plus cameras use the Dahua stream path."},{id:"uniview",label:"Uniview",path:"/media/video1",note:"Some older Uniview models use /video1 instead."},{id:"tplink",label:"TP-Link / Tapo",path:"/stream1",note:"Tapo cameras need a separate camera account created in the Tapo app — your Tapo login will not work."},{id:"reolink",label:"Reolink",path:"/h264Preview_01_main",note:"Use /h264Preview_01_sub for the lower-quality stream."},{id:"amcrest",label:"Amcrest",path:"/cam/realmonitor?channel=1&subtype=0",note:"Amcrest cameras use the Dahua stream path."},{id:"axis",label:"Axis",path:"/axis-media/media.amp",note:""},{id:"onvif",label:"Other (ONVIF)",path:"/onvif1",note:"Many generic cameras answer here. If it does not work, look for “RTSP” in the camera’s own app."},{id:"manual",label:"I know the path",path:"",note:""}],ca=e=>Br.find(t=>t.id===e)||Br[Br.length-1],Pp=["Camera","Connection","Test","Walk past"];function Tp({sites:e,existing:t,onClose:n,onSaved:r}){var d;const l=!(t!=null&&t.id),[s,o]=j.useState(l?0:2),[a,u]=j.useState(t!=null&&t.id?t:null),[c,m]=j.useState({site_id:(t==null?void 0:t.site_id)||((d=e[0])==null?void 0:d.site_id)||"",make:"hikvision",label:(t==null?void 0:t.label)||"",host:(t==null?void 0:t.host)||"",port:(t==null?void 0:t.port)||554,path:(t==null?void 0:t.path)||"/Streaming/Channels/101",username:(t==null?void 0:t.username)||"",password:""}),[h,v]=j.useState(!1),[y,x]=j.useState(""),g=p=>w=>m(S=>({...S,[p]:w.target.value})),N=p=>{const w=ca(p.target.value);m(S=>({...S,make:w.id,path:w.path||S.path}))},f=async()=>{v(!0),x("");const p={};for(const[w,S]of Object.entries(c))w==="site_id"||w==="make"||S===""||S==null||(p[w]=w==="port"?Number(S):S);try{const w=a!=null&&a.id?await D.updateCamera(a.id,p):await D.createCamera(c.site_id,p);u(w),o(2),r==null||r(w,{keepOpen:!0})}catch(w){x(w.message)}finally{v(!1)}};return i.jsx("div",{className:"overlay",onClick:n,children:i.jsxs("aside",{className:"drawer wizard",onClick:p=>p.stopPropagation(),children:[i.jsxs("header",{className:"drawer-head",children:[i.jsxs("div",{children:[i.jsx("h2",{children:l?"Set up a camera":(a==null?void 0:a.label)||(t==null?void 0:t.label)}),i.jsx("p",{className:"sub",children:s<2?"The shop’s PC connects to the camera — nothing needs opening to the internet.":"Prove it works before you rely on it."})]}),i.jsx("button",{className:"ghost",onClick:n,children:"Close"})]}),i.jsx("ol",{className:"steps",children:Pp.map((p,w)=>i.jsxs("li",{className:w===s?"now":wi.jsx("option",{value:p.site_id,children:p.name},p.site_id))})]}),i.jsxs("label",{children:["What should staff call it?",i.jsx("input",{value:c.label,onChange:g("label"),placeholder:"Entrance",autoFocus:!0}),i.jsx("span",{className:"hint",children:"Visits are recorded against this name, so it cannot be changed later."})]}),i.jsxs("label",{children:["Make of camera",i.jsx("select",{value:c.make,onChange:N,children:Br.map(p=>i.jsx("option",{value:p.id,children:p.label},p.id))}),i.jsx("span",{className:"hint",children:ca(c.make).note||"This only fills in the stream path for you. You can change it on the next step."})]}),i.jsx("button",{className:"primary",disabled:!c.label.trim(),onClick:()=>o(1),children:"Next"})]}),s===1&&i.jsxs("div",{className:"drawer-body",children:[i.jsxs("label",{children:["Camera’s address on the shop’s network",i.jsx("input",{value:c.host,onChange:g("host"),placeholder:"192.168.0.138",autoFocus:!0}),i.jsx("span",{className:"hint",children:"Not a website address. It usually starts 192.168. — look in the camera’s own app, on its label, or in your router’s device list."})]}),i.jsxs("div",{className:"pair",children:[i.jsxs("label",{children:["Port",i.jsx("input",{type:"number",value:c.port,onChange:g("port")})]}),i.jsxs("label",{children:["Stream path",i.jsx("input",{value:c.path,onChange:g("path")})]})]}),i.jsxs("label",{children:["Camera username",i.jsx("input",{value:c.username,onChange:g("username"),placeholder:"admin",name:"camera-account",autoComplete:"off",autoCorrect:"off",autoCapitalize:"none",spellCheck:"false"}),i.jsx("span",{className:"hint",children:"The camera’s own login, not your Behavision one."})]}),i.jsxs("label",{children:["Camera password",i.jsx("input",{type:"password",value:c.password,onChange:g("password"),name:"camera-secret",autoComplete:"new-password",placeholder:a!=null&&a.has_password?"(unchanged)":""})]}),y&&i.jsx("p",{className:"error",role:"alert",children:y}),i.jsxs("div",{className:"pair",children:[i.jsx("button",{className:"ghost",onClick:()=>o(0),children:"Back"}),i.jsx("button",{className:"primary",disabled:h||!c.host.trim(),onClick:f,children:h?"Saving…":"Save and test"})]})]}),s>=2&&a&&i.jsx(zp,{camera:a,step:s,onStep:o,onUpdated:p=>{u(p),r==null||r(p,{keepOpen:!0})},onEdit:()=>o(1),onDone:n})]})})}function zp({camera:e,step:t,onStep:n,onUpdated:r,onEdit:l,onDone:s}){const[o,a]=j.useState(e),[u,c]=j.useState(!1),[m,h]=j.useState(""),v=j.useRef(null);j.useEffect(()=>a(e),[e]);const y=o.check||{},x=y.state==="requested"||y.state==="running";j.useEffect(()=>{if(!x)return;let f=!0;const d=async()=>{try{const w=(await D.cameras()).find(S=>S.id===o.id);f&&w&&(a(w),r==null||r(w))}catch{}};return v.current=setInterval(d,4e3),()=>{f=!1,clearInterval(v.current)}},[x,o.id]);const g=async(f,d)=>{c(!0),h("");try{const p=await D.checkCamera(o.id,f,d);a(p),r==null||r(p),n(f==="placement"?3:2)}catch(p){h(p.message)}finally{c(!1)}},N=y.kind==="connection"&&y.state==="done"&&y.ok;return i.jsx(i.Fragment,{children:i.jsxs("div",{className:"drawer-body",children:[t===2?i.jsxs(i.Fragment,{children:[i.jsx("h3",{children:"Can the shop’s PC reach this camera?"}),i.jsx("p",{className:"sub",children:"The PC opens the stream once and takes a single picture. Nothing is recorded."})]}):i.jsxs(i.Fragment,{children:[i.jsx("h3",{children:"Can it actually recognise a face?"}),i.jsxs("p",{className:"sub",children:["Someone needs to ",i.jsx("b",{children:"walk through the camera’s view and out of it"}),", the way a customer would. Standing still measures nothing — the check scores the best view of each person as they leave the frame, which is what recognition really uses."]})]}),x&&i.jsxs("div",{className:"waiting",children:[i.jsx("span",{className:"spinner","aria-hidden":"true"}),i.jsxs("div",{children:[i.jsx("b",{children:y.state==="running"?"Running on the shop’s PC…":"Waiting for the shop’s PC…"}),i.jsx("span",{className:"sub",children:y.state==="running"?"This takes about "+(y.seconds||25)+" seconds.":"It picks up the request within a couple of minutes."})]})]}),y.state==="done"&&i.jsx(Lp,{check:y}),m&&i.jsx("p",{className:"error",role:"alert",children:m}),i.jsx("div",{className:"pair",children:t===2?i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"ghost",onClick:l,children:"Change details"}),i.jsx("button",{className:"primary",disabled:u||x,onClick:()=>g("connection"),children:y.state==="done"?"Test again":"Test connection"})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"ghost",onClick:()=>n(2),children:"Back"}),i.jsx("button",{className:"primary",disabled:u||x,onClick:()=>g("placement",25),children:y.state==="done"?"Check again":"Start walk-past check"})]})}),t===2&&N&&!x&&i.jsx("button",{className:"primary",onClick:()=>n(3),children:"Next: prove it can recognise faces"}),t===3&&y.state==="done"&&!x&&i.jsx("button",{className:"ghost",onClick:s,children:"Finish"})]})})}function Lp({check:e}){var n,r,l;const t=e.ok?"ok":e.verdict==="marginal"?"warn":"bad";return i.jsxs("div",{className:"outcome "+t,children:[i.jsxs("div",{className:"outcome-head",children:[i.jsx("span",{className:"pill "+t,children:e.ok?"Working":"Not ready"}),i.jsx("b",{children:e.headline||(e.ok?"Working":"Could not be verified")})]}),((n=e.image)==null?void 0:n.available)&&i.jsx("img",{className:"proof",src:e.image.url,alt:"The view from this camera",loading:"lazy"}),((r=e.advice)==null?void 0:r.length)>0&&i.jsx("ul",{className:"advice",children:e.advice.map((s,o)=>i.jsx("li",{children:s},o))}),((l=e.detail)==null?void 0:l.faces)!=null&&i.jsxs("p",{className:"sub",children:[e.detail.faces," ",e.detail.faces===1?"person":"people"," walked past during the check."]})]})}function Rp(e){const t=e.check||{};return t.state==="requested"||t.state==="running"?{tone:"idle",mark:"…",words:"Checking now"}:t.state!=="done"?{tone:"idle",mark:"?",words:"Not checked yet"}:t.kind==="placement"?t.ok?{tone:"ok",mark:"✓",words:"Recognises faces here"}:{tone:"bad",mark:"✕",words:t.headline||"Cannot recognise faces here"}:t.ok?{tone:"warn",mark:"!",words:"Stream works — faces not checked yet"}:{tone:"bad",mark:"✕",words:t.headline||"Could not reach the camera"}}function Op({user:e}){const{data:t,error:n,loading:r,reload:l}=It(()=>D.cameras(),2e4,[]),{data:s}=It(()=>D.sites(),0,[]),[o,a]=j.useState(null),[u,c]=j.useState(null),m=["admin","owner","manager"].includes(e.role),h=t||[],v=h.filter(N=>N.state==="connected").length,y=h.filter(N=>N.state==="not_connecting").length,x=h.filter(N=>N.state==="waiting").length,g=h.filter(N=>N.state==="stale").length;return i.jsxs(i.Fragment,{children:[i.jsxs("header",{className:"head",children:[i.jsx("h1",{children:"Cameras"}),i.jsxs("p",{className:"sub",children:[h.length," ",h.length===1?"camera":"cameras",v>0&&i.jsxs(i.Fragment,{children:[" · ",i.jsxs("b",{className:"ok",children:[v," connected"]})]}),g>0&&i.jsxs(i.Fragment,{children:[" · ",i.jsxs("b",{className:"warn",children:[g," not reporting"]})]}),y>0&&i.jsxs(i.Fragment,{children:[" · ",i.jsxs("b",{className:"bad",children:[y," down"]})]}),x>0&&i.jsxs(i.Fragment,{children:[" · ",x," waiting for the shop PC"]})]}),m&&i.jsx("button",{className:"primary",onClick:()=>a({}),children:"Set up a camera"})]}),r&&!t?i.jsx(ar,{}):n?i.jsx(ur,{error:n}):h.length===0?i.jsxs("div",{className:"state",children:[i.jsx("h2",{children:"No cameras yet"}),i.jsx("p",{className:"sub",children:"Add one here and the shop’s PC will pick it up within a couple of minutes. Cameras already set up on a shop PC appear here on their own."})]}):i.jsx("div",{className:"grid cams",children:h.map(N=>i.jsx(Ip,{cam:N,canEdit:m,onEdit:()=>a(N),onWatch:()=>c(N)},N.id))}),o&&i.jsx(Tp,{existing:o.id?o:null,sites:s||[],onClose:()=>{a(null),l()},onSaved:(N,f)=>{f!=null&&f.keepOpen||a(null),l()}}),u&&i.jsx(_p,{camera:u,onClose:()=>c(null)})]})}function Ip({cam:e,canEdit:t,onEdit:n,onWatch:r}){var a,u;const l={connected:"ok",not_connecting:"bad",stale:"warn"}[e.state]||"idle",s={connected:"Connected",not_connecting:"Not connecting",stale:"Not reporting"}[e.state]||"Waiting for the shop PC",o=Rp(e);return i.jsxs("article",{className:"card cam state-"+l,onClick:t?n:void 0,role:t?"button":void 0,tabIndex:t?0:void 0,onKeyDown:c=>t&&c.key==="Enter"&&n(),children:[i.jsxs("div",{className:"shot",children:[(a=e.snapshot)!=null&&a.available?i.jsx(Xi,{image:e.snapshot,alt:`View from ${e.label}`}):i.jsxs("div",{className:"noshot",children:[i.jsx("span",{className:"lens","aria-hidden":"true"}),((u=e.snapshot)==null?void 0:u.reason)||"No picture yet."]}),i.jsxs("div",{className:"shot-over",children:[i.jsxs("div",{className:"shot-name",children:[i.jsx("b",{children:e.label||e.camera_id}),i.jsx("span",{children:e.site})]}),i.jsxs("span",{className:"status "+l,children:[i.jsx("i",{"aria-hidden":"true"}),s]})]}),e.snapshot_at&&i.jsx("span",{className:"shot-age",children:Ft(e.snapshot_at)}),i.jsxs("button",{className:"watch",title:"Watch this camera now",onClick:c=>{c.stopPropagation(),r()},children:[i.jsx("i",{"aria-hidden":"true"}),"Live"]})]}),i.jsxs("div",{className:"verdict "+o.tone,children:[i.jsx("span",{className:"mark","aria-hidden":"true",children:o.mark}),i.jsx("span",{className:"words",children:o.words}),t&&i.jsx("span",{className:"go","aria-hidden":"true",children:"→"})]})]})}const Fp=["Is everything working today?","Why is footfall low at Chennai?","How many people came in last week?","Which cameras still need checking?"];function Dp({open:e,onClose:t}){const[n,r]=j.useState([]),[l,s]=j.useState(""),[o,a]=j.useState(!1),[u,c]=j.useState(!1),m=j.useRef(null),h=j.useRef(null);j.useEffect(()=>{var y;e&&((y=h.current)==null||y.focus())},[e]),j.useEffect(()=>{var y;(y=m.current)==null||y.scrollIntoView({behavior:"smooth",block:"end"})},[n,o]);const v=async y=>{const x=(y??l).trim();if(!x||o)return;const g=[...n,{role:"user",text:x}];r(g),s(""),a(!0);try{const N=await D.ask(g);r(f=>[...f,{role:"assistant",text:N.text,used:N.used}])}catch(N){N.code==="assistant_off"?c(!0):r(f=>[...f,{role:"assistant",text:N.message,failed:!0}])}finally{a(!1)}};return e?i.jsxs("aside",{className:"assistant",role:"complementary","aria-label":"Assistant",children:[i.jsxs("header",{className:"assistant-head",children:[i.jsxs("div",{children:[i.jsx("b",{children:"Loya"}),i.jsx("span",{className:"sub",children:"Your Behavision buddy — knows your shops, cameras and numbers."})]}),i.jsx("button",{className:"ghost",onClick:t,"aria-label":"Close assistant",children:"✕"})]}),i.jsxs("div",{className:"assistant-body",children:[u?i.jsx("p",{className:"sub pad",children:"Loya is not switched on for this server."}):n.length===0?i.jsxs("div",{className:"suggest",children:[i.jsx("p",{className:"sub",children:"Try asking:"}),Fp.map(y=>i.jsx("button",{className:"chip",onClick:()=>v(y),children:y},y))]}):n.map((y,x)=>{var g;return i.jsxs("div",{className:"bubble "+y.role+(y.failed?" failed":""),children:[y.text,((g=y.used)==null?void 0:g.length)>0&&i.jsxs("span",{className:"used",children:["looked at: ",y.used.map(Mp).join(", ")]})]},x)}),o&&i.jsxs("div",{className:"bubble assistant-thinking",children:[i.jsx("span",{className:"spinner","aria-hidden":"true"})," Looking…"]}),i.jsx("div",{ref:m})]}),!u&&i.jsxs("form",{className:"assistant-ask",onSubmit:y=>{y.preventDefault(),v()},children:[i.jsx("input",{ref:h,value:l,onChange:y=>s(y.target.value),placeholder:"Ask Loya…",disabled:o}),i.jsx("button",{className:"primary",disabled:o||!l.trim(),children:"Ask"})]})]}):null}function Mp(e){return{list_shops:"your shops",check_shop:"a shop check",list_cameras:"your cameras",check_camera:"a camera check",footfall:"footfall",sales:"sales",find_customer:"customer records"}[e]||e}function $p(){const{data:e,error:t,loading:n,reload:r}=It(()=>D.clients(),0,[]),[l,s]=j.useState(!1),[o,a]=j.useState(null),u=e||[];return i.jsxs(i.Fragment,{children:[i.jsxs("header",{className:"head",children:[i.jsx("h1",{children:"Companies"}),i.jsx("button",{className:"primary",onClick:()=>{a(null),s(!0)},children:"New company"})]}),o&&i.jsx(Ap,{result:o,onDismiss:()=>a(null)}),n&&!e?i.jsx(ar,{}):t?i.jsx(ur,{error:t}):u.length===0?i.jsxs("div",{className:"state",children:[i.jsx("h2",{children:"No companies yet"}),i.jsx("p",{className:"sub",children:"Create one, and its owner can sign in straight away."})]}):i.jsx("div",{className:"tablewrap",children:i.jsxs("table",{className:"rows",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Company"}),i.jsx("th",{children:"Short name"}),i.jsx("th",{children:"Sites"}),i.jsx("th",{children:"People"}),i.jsx("th",{children:"Created"})]})}),i.jsx("tbody",{children:u.map(c=>i.jsxs("tr",{children:[i.jsx("td",{children:i.jsx("strong",{children:c.name})}),i.jsx("td",{children:i.jsx("code",{children:c.slug})}),i.jsx("td",{className:"num",children:c.sites}),i.jsx("td",{className:"num",children:c.users}),i.jsx("td",{className:"sub",children:Ft(c.created_at)})]},c.id))})]})}),l&&i.jsx(Up,{onClose:()=>s(!1),onCreated:c=>{s(!1),a(c),r()}})]})}function Up({onClose:e,onCreated:t}){const[n,r]=j.useState({company_name:"",owner_name:"",owner_email:"",password:""}),[l,s]=j.useState(!1),[o,a]=j.useState(""),u=m=>h=>r({...n,[m]:h.target.value}),c=async m=>{m.preventDefault(),s(!0),a("");try{t(await D.createClient(n))}catch(h){a(h.message),s(!1)}};return i.jsx("div",{className:"overlay",onClick:e,children:i.jsxs("aside",{className:"drawer narrow",onClick:m=>m.stopPropagation(),children:[i.jsxs("header",{className:"drawer-head",children:[i.jsx("h2",{children:"New company"}),i.jsx("button",{className:"ghost",onClick:e,children:"Close"})]}),i.jsxs("form",{className:"drawer-body",onSubmit:c,children:[i.jsxs("label",{children:["Company name",i.jsx("input",{value:n.company_name,onChange:u("company_name"),required:!0,autoFocus:!0})]}),i.jsxs("label",{children:["Owner’s name",i.jsx("input",{value:n.owner_name,onChange:u("owner_name")})]}),i.jsxs("label",{children:["Owner’s email",i.jsx("input",{type:"email",value:n.owner_email,onChange:u("owner_email"),required:!0})]}),i.jsxs("label",{children:["Password",i.jsx("input",{type:"text",value:n.password,onChange:u("password"),placeholder:"Leave empty to generate one"}),i.jsx("span",{className:"hint",children:"Generated is better — a password you invent for someone else ends up weak and sent over chat."})]}),o&&i.jsx("p",{className:"error",role:"alert",children:o}),i.jsx("button",{className:"primary",disabled:l,children:l?"Creating…":"Create company"})]})]})})}function Ap({result:e,onDismiss:t}){return i.jsxs("div",{className:"banner ok credentials",children:[i.jsxs("div",{children:[i.jsxs("b",{children:[e.slug," created."]})," These sign-in details are shown once and cannot be recovered. Send them to the owner now.",i.jsxs("dl",{className:"creds",children:[i.jsxs("div",{children:[i.jsx("dt",{children:"Email"}),i.jsx("dd",{children:i.jsx("code",{children:e.owner_email})})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"Password"}),i.jsx("dd",{children:i.jsx("code",{children:e.password})})]})]})]}),i.jsx("button",{className:"ghost",onClick:t,children:"Done"})]})}function Bp({user:e}){const t=It(()=>D.team(),0,[]),n=It(()=>D.invitations(),0,[]),[r,l]=j.useState(!1),[s,o]=j.useState(null),[a,u]=j.useState(""),[c,m]=j.useState(""),h=e.role==="owner"||e.role==="manager",v=t.data||[],y=n.data||[],x=async(g,N)=>{u(g),m("");try{await D.updateMember(g,N),t.reload()}catch(f){m(f.message)}finally{u("")}};return i.jsxs(i.Fragment,{children:[i.jsxs("header",{className:"head",children:[i.jsx("h1",{children:"Team"}),h&&i.jsx("button",{className:"primary",onClick:()=>{o(null),l(!0)},children:"Invite someone"})]}),s&&i.jsx(Wp,{invite:s,onDismiss:()=>o(null)}),c&&i.jsx("p",{className:"error",role:"alert",children:c}),t.loading&&!t.data?i.jsx(ar,{}):t.error?i.jsx(ur,{error:t.error}):i.jsx("div",{className:"tablewrap",children:i.jsxs("table",{className:"rows",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Name"}),i.jsx("th",{children:"Email"}),i.jsx("th",{children:"Role"}),i.jsx("th",{children:"Last signed in"}),h&&i.jsx("th",{})]})}),i.jsx("tbody",{children:v.map(g=>i.jsxs("tr",{className:g.active?"":"inactive",children:[i.jsxs("td",{children:[i.jsx("strong",{children:g.full_name||"—"}),!g.active&&i.jsx("span",{className:"pill muted",children:"No access"})]}),i.jsx("td",{children:i.jsx("code",{children:g.email})}),i.jsx("td",{children:h&&g.id!==e.id?i.jsxs("select",{value:g.role,disabled:a===g.id,onChange:N=>x(g.id,{role:N.target.value}),children:[i.jsx("option",{value:"staff",children:"Staff"}),i.jsx("option",{value:"manager",children:"Manager"}),e.role==="owner"&&i.jsx("option",{value:"owner",children:"Owner"})]}):i.jsx("span",{className:"role",children:g.role})}),i.jsx("td",{className:"sub",children:g.last_login_at?Ft(g.last_login_at):"Never"}),h&&i.jsx("td",{className:"right",children:g.id===e.id?null:g.active?i.jsx("button",{className:"ghost danger",disabled:a===g.id,onClick:()=>x(g.id,{active:!1}),children:"Remove access"}):i.jsx("button",{className:"ghost",disabled:a===g.id,onClick:()=>x(g.id,{active:!0}),children:"Restore"})})]},g.id))})]})}),h&&y.length>0&&i.jsxs("section",{className:"pending",children:[i.jsx("h2",{children:"Waiting to join"}),i.jsx("ul",{className:"invites",children:y.map(g=>i.jsxs("li",{className:"card invite",children:[i.jsxs("div",{children:[i.jsx("strong",{children:g.email}),i.jsxs("span",{className:"sub",children:["invited as ",g.role,g.invited_by?` by ${g.invited_by}`:""," · expires ",wp(g.expires_at)]})]}),i.jsx("button",{className:"ghost danger",onClick:async()=>{await D.revokeInvitation(g.id),n.reload()},children:"Withdraw"})]},g.id))})]}),r&&i.jsx(Vp,{canMintOwner:e.role==="owner",onClose:()=>l(!1),onDone:g=>{l(!1),o(g),n.reload()}})]})}function Vp({canMintOwner:e,onClose:t,onDone:n}){const[r,l]=j.useState({email:"",full_name:"",role:"staff"}),[s,o]=j.useState(!1),[a,u]=j.useState(""),c=h=>v=>l({...r,[h]:v.target.value}),m=async h=>{h.preventDefault(),o(!0),u("");try{n(await D.invite(r))}catch(v){u(v.message),o(!1)}};return i.jsx("div",{className:"overlay",onClick:t,children:i.jsxs("aside",{className:"drawer narrow",onClick:h=>h.stopPropagation(),children:[i.jsxs("header",{className:"drawer-head",children:[i.jsx("h2",{children:"Invite someone"}),i.jsx("button",{className:"ghost",onClick:t,children:"Close"})]}),i.jsxs("form",{className:"drawer-body",onSubmit:m,children:[i.jsxs("label",{children:["Their email",i.jsx("input",{type:"email",value:r.email,onChange:c("email"),required:!0,autoFocus:!0,autoComplete:"off",name:"invitee"}),i.jsx("span",{className:"hint",children:"This is the address they will sign in with, and it is fixed by the invitation — passing the code on cannot make it somebody else’s account."})]}),i.jsxs("label",{children:["Their name",i.jsx("input",{value:r.full_name,onChange:c("full_name"),autoComplete:"off",name:"invitee-name"})]}),i.jsxs("label",{children:["Role",i.jsxs("select",{value:r.role,onChange:c("role"),children:[i.jsx("option",{value:"staff",children:"Staff — see customers and shops"}),i.jsx("option",{value:"manager",children:"Manager — also set up cameras and invite people"}),e&&i.jsx("option",{value:"owner",children:"Owner — full control"})]})]}),a&&i.jsx("p",{className:"error",role:"alert",children:a}),i.jsx("button",{className:"primary",disabled:s,children:s?"Creating…":"Create invitation"})]})]})})}function Wp({invite:e,onDismiss:t}){return i.jsxs("div",{className:"banner ok credentials",children:[i.jsxs("div",{children:[i.jsxs("b",{children:["Invitation for ",e.email,"."]})," Give them this code. It is shown once, works once, and cannot be recovered.",i.jsxs("dl",{className:"creds",children:[i.jsxs("div",{children:[i.jsx("dt",{children:"Code"}),i.jsx("dd",{children:i.jsx("code",{className:"big",children:e.code})})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"Role"}),i.jsx("dd",{children:e.role})]})]}),i.jsx("p",{className:"sub",children:"They open the app, choose “I have an invitation code”, and pick their own password. Nobody else ever sees it."})]}),i.jsx("button",{className:"ghost",onClick:t,children:"Done"})]})}const Hp=[{id:"sites",label:"Shops",View:fp},{id:"live",label:"Live",View:kp},{id:"cameras",label:"Cameras",View:Op},{id:"team",label:"Team",View:Bp}],Qp=[{id:"clients",label:"Companies",View:$p}];function Kp(){const[e,t]=j.useState(null),[n,r]=j.useState(!0),[l,s]=j.useState("sites"),[o,a]=j.useState(!1);if(j.useEffect(()=>{(async()=>{if(ep())try{t(await D.me())}catch{or()}r(!1)})()},[]),n)return i.jsxs("div",{className:"boot",children:[i.jsx("span",{className:"spinner","aria-hidden":"true"}),"Loading…"]});if(!e)return i.jsx(rp,{onSignedIn:t});const u=e.role==="admin"&&!e.client_id,c=u?Qp:Hp,m=c.find(y=>y.id===l)||c[0],h=m.View,v=async()=>{await D.logout(),t(null)};return i.jsxs("div",{className:"app",children:[i.jsxs("header",{className:"topbar",children:[i.jsxs("div",{className:"brand",children:[i.jsx("span",{className:"mark","aria-hidden":"true"}),i.jsxs("div",{children:[i.jsx("strong",{children:"Behavision"}),i.jsx("span",{className:"org",children:e.client_name||"Loyaly platform"})]})]}),i.jsx("nav",{className:"tabs",children:c.map(y=>i.jsx("button",{onClick:()=>s(y.id),"aria-current":m.id===y.id?"page":void 0,children:y.label},y.id))}),i.jsxs("div",{className:"who",children:[i.jsxs("button",{className:"ask-btn"+(o?" on":""),onClick:()=>a(y=>!y),title:"Ask Loya",children:[i.jsx("span",{className:"mark","aria-hidden":"true"})," Loya"]}),i.jsx("span",{className:"name",children:e.full_name||e.email}),i.jsx("span",{className:"role",children:u?"platform admin":e.role}),i.jsx("button",{className:"ghost",onClick:v,children:"Sign out"})]})]}),i.jsxs("div",{className:"with-assistant"+(o?" open":""),children:[i.jsx("main",{className:"page",children:i.jsx(h,{user:e})}),i.jsx(Dp,{open:o,onClose:()=>a(!1)})]})]})}Sc(document.getElementById("root")).render(i.jsx(Kp,{})); +`))!==-1;){const w=m.slice(0,y);m=m.slice(y+2);let g="message",C="";for(const f of w.split(` +`))f.startsWith("event: ")?g=f.slice(7).trim():f.startsWith("data: ")&&(C=f.slice(6));g==="frame"&&C?(t.current&&(t.current.src="data:image/jpeg;base64,"+C),n==null||n("live")):g==="waiting"&&(n==null||n("waiting"))}}}catch{if(l||r!=null&&r.aborted)return;n==null||n("reconnecting")}if(l)return;await new Promise(o=>setTimeout(o,1500))}})(),()=>{l=!0}}function rp({onSignedIn:e}){const[t,n]=j.useState(!1);return t?i.jsx(sp,{onSignedIn:e,onCancel:()=>n(!1)}):i.jsx(lp,{onSignedIn:e,onJoin:()=>n(!0)})}function lp({onSignedIn:e,onJoin:t}){const[n,r]=j.useState(""),[l,s]=j.useState(""),[o,a]=j.useState(""),[u,c]=j.useState(!1),m=async p=>{p.preventDefault(),c(!0),a("");try{await M.login(n.trim(),l),e(await M.me())}catch(v){a(v.message),c(!1)}};return i.jsx("div",{className:"signin",children:i.jsxs("form",{className:"card",onSubmit:m,children:[i.jsx("span",{className:"mark big","aria-hidden":"true"}),i.jsx("h1",{children:"Behavision"}),i.jsx("p",{className:"sub",children:"Sign in to your company account."}),i.jsxs("label",{children:["Email",i.jsx("input",{type:"email",value:n,autoComplete:"username",autoFocus:!0,required:!0,onChange:p=>r(p.target.value),placeholder:"you@company.com"})]}),i.jsxs("label",{children:["Password",i.jsx("input",{type:"password",value:l,autoComplete:"current-password",required:!0,onChange:p=>s(p.target.value)})]}),o&&i.jsx("p",{className:"error",role:"alert",children:o}),i.jsx("button",{className:"primary",disabled:u||!n||!l,children:u?"Signing in…":"Sign in"}),i.jsxs("p",{className:"foot",children:["Been invited? ",i.jsx("button",{type:"button",className:"linkish",onClick:t,children:"Use your invitation code"})]})]})})}function sp({onSignedIn:e,onCancel:t}){const[n,r]=j.useState(""),[l,s]=j.useState(null),[o,a]=j.useState(""),[u,c]=j.useState(""),[m,p]=j.useState(""),[v,y]=j.useState(""),[w,g]=j.useState(!1),C=async d=>{d.preventDefault(),g(!0),y("");try{const h=await M.previewInvitation(n.trim());s(h),a(h.full_name||"")}catch(h){y(h.message)}finally{g(!1)}},f=async d=>{if(d.preventDefault(),u!==m){y("Those two passwords are not the same.");return}g(!0),y("");try{const h=await M.register({code:n.trim(),full_name:o,password:u});e(h)}catch(h){y(h.message),g(!1)}};return i.jsx("div",{className:"signin",children:i.jsxs("form",{className:"card",onSubmit:l?f:C,children:[i.jsx("span",{className:"mark big","aria-hidden":"true"}),i.jsx("h1",{children:l?`Join ${l.client_name}`:"Behavision"}),l?i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"sub",children:["You are joining as ",i.jsx("b",{children:l.role}),", signing in with"," ",i.jsx("code",{children:l.email}),". Choose a password only you know."]}),i.jsxs("label",{children:["Your name",i.jsx("input",{value:o,onChange:d=>a(d.target.value),autoFocus:!0,autoComplete:"name"})]}),i.jsxs("label",{children:["Password",i.jsx("input",{type:"password",value:u,required:!0,minLength:8,autoComplete:"new-password",onChange:d=>c(d.target.value)}),i.jsx("span",{className:"hint",children:"At least 8 characters. Longer is the only thing that helps."})]}),i.jsxs("label",{children:["Password again",i.jsx("input",{type:"password",value:m,required:!0,autoComplete:"new-password",onChange:d=>p(d.target.value)})]}),v&&i.jsx("p",{className:"error",role:"alert",children:v}),i.jsx("button",{className:"primary",disabled:w||!u||!m,children:w?"Creating your account…":"Create account and sign in"})]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"sub",children:"Enter the invitation code you were given."}),i.jsxs("label",{children:["Invitation code",i.jsx("input",{value:n,onChange:d=>r(d.target.value),autoFocus:!0,required:!0,autoComplete:"off",spellCheck:"false",placeholder:"ABCDEF-123456-GHIJKL-789012",className:"codefield"}),i.jsx("span",{className:"hint",children:"Dashes and capitals do not matter."})]}),v&&i.jsx("p",{className:"error",role:"alert",children:v}),i.jsx("button",{className:"primary",disabled:w||!n.trim(),children:w?"Checking…":"Continue"})]}),i.jsx("p",{className:"foot",children:i.jsx("button",{type:"button",className:"linkish",onClick:t,children:"Back to sign in"})})]})})}function It(e,t,n=[]){const[r,l]=j.useState(null),[s,o]=j.useState(null),[a,u]=j.useState(!0),c=j.useRef(!1),m=j.useRef(!0),p=j.useCallback(async()=>{if(!c.current){c.current=!0;try{const v=await e();if(!m.current)return;l(v),o(null)}catch(v){if(!m.current)return;o(v)}finally{c.current=!1,m.current&&u(!1)}}},n);return j.useEffect(()=>{if(m.current=!0,p(),!t)return()=>{m.current=!1};const v=setInterval(p,t);return()=>{m.current=!1,clearInterval(v)}},[p,t]),{data:r,error:s,loading:a,reload:p}}function ip(e){const[t,n]=j.useState(null);return j.useEffect(()=>{if(!e){n(null);return}let r=!0,l=null;return M.cameraSnapshot(e).then(s=>{if(!r){URL.revokeObjectURL(s);return}l=s,n(s)}).catch(()=>{r&&n(null)}),()=>{r=!1,l&&URL.revokeObjectURL(l)}},[e]),t}function Xi({image:e,url:t,alt:n}){const r=e?e.url:t,l=e&&!!e.auth||typeof r=="string"&&r.startsWith("/"),s=ip(l?r:null),o=l?s:r;return o?i.jsx("img",{src:o,alt:n,loading:"lazy"}):null}function op({site:e,user:t,onClose:n,onChanged:r}){const[l,s]=j.useState(null),[o,a]=j.useState(!1),[u,c]=j.useState(""),m=async()=>{a(!0),c(""),s(null);try{s(await M.siteCheck(e.site_id))}catch(p){c(p.message)}finally{a(!1)}};return i.jsx("div",{className:"overlay",onClick:n,children:i.jsxs("aside",{className:"drawer",onClick:p=>p.stopPropagation(),children:[i.jsxs("header",{className:"drawer-head",children:[i.jsxs("div",{children:[i.jsxs("h2",{children:["Is ",e.name," working?"]}),i.jsx("p",{className:"sub",children:"Checks the whole chain, from the shop’s PC to head office."})]}),i.jsx("button",{className:"ghost",onClick:n,children:"Close"})]}),i.jsxs("div",{className:"drawer-body",children:[!l&&!o&&i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"sub",children:"Nothing is changed and no one is disturbed — this reads what the shop has already reported."}),i.jsx("button",{className:"primary",onClick:m,children:"Run the check"})]}),o&&i.jsxs("div",{className:"waiting",children:[i.jsx("span",{className:"spinner","aria-hidden":"true"}),i.jsx("b",{children:"Checking…"})]}),u&&i.jsx("p",{className:"error",role:"alert",children:u}),l&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"banner "+(l.ok?"ok":"warn"),children:i.jsxs("div",{children:[i.jsx("b",{children:l.ok?"This shop is working.":"This shop needs attention."}),!l.ok&&i.jsx(i.Fragment,{children:" Work down the list — the first failure usually explains the rest."})]})}),i.jsx("ol",{className:"checklist",children:l.steps.map(p=>i.jsxs("li",{className:p.status,children:[i.jsx("span",{className:"mark","aria-hidden":"true",children:p.status==="pass"?"✓":p.status==="fail"?"✕":p.status==="warn"?"!":"–"}),i.jsxs("div",{children:[i.jsx("b",{children:p.name}),i.jsx("span",{className:"sub",children:p.detail}),p.advice&&i.jsx("span",{className:"advice-line",children:p.advice})]})]},p.name))}),i.jsx("button",{className:"ghost",onClick:m,children:"Check again"})]}),i.jsx(ap,{site:e}),i.jsx(dp,{site:e,user:t,onChanged:r,onClose:n})]})]})})}function ap({site:e}){const[t,n]=j.useState(null),[r,l]=j.useState(!1),[s,o]=j.useState(""),[a,u]=j.useState(""),c=async()=>{l(!0),o("");try{n(await M.enrolmentCode(e.site_id,{label:a.trim()}))}catch(m){o(m.message)}finally{l(!1)}};return i.jsxs("section",{className:"claim",children:[i.jsx("h3",{children:"Set up a shop PC"}),t?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"code","aria-live":"polite",children:t.code}),i.jsxs("p",{className:"sub",children:["Copy this now — it cannot be shown again. It works once, and stops working ",cp(t.expires_at),"."]}),i.jsxs("div",{className:"row",children:[i.jsx("button",{className:"ghost",onClick:()=>up(t.code),children:"Copy"}),i.jsx("button",{className:"ghost",onClick:()=>n(null),children:"Done"})]})]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"sub",children:"Creates a one-time code to type into Behavision on the shop’s computer. Use one for a new shop, a replacement PC, or a reinstall."}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"What is this PC? (optional)"}),i.jsx("input",{value:a,placeholder:"counter PC",onChange:m=>u(m.target.value)})]}),s&&i.jsx("p",{className:"error",role:"alert",children:s}),i.jsx("button",{className:"ghost",onClick:c,disabled:r,children:r?"Creating…":"Create an installation code"})]})]})}function up(e){var t;try{(t=navigator.clipboard)==null||t.writeText(e)}catch{}}function cp(e){const t=new Date(e).getTime();if(Number.isNaN(t))return"shortly";const n=Math.round((t-Date.now())/864e5);return n<=0?"today":n===1?"tomorrow":`in ${n} days`}function dp({site:e,user:t,onChanged:n,onClose:r}){const[l,s]=j.useState(e.name),[o,a]=j.useState(e.timezone||"Asia/Kolkata"),[u,c]=j.useState(!1),[m,p]=j.useState(""),[v,y]=j.useState(!1),w=(t==null?void 0:t.role)==="owner"||(t==null?void 0:t.role)==="manager",g=(t==null?void 0:t.role)==="owner";if(!w)return null;const C=l.trim()!==e.name||o.trim()!==(e.timezone||"Asia/Kolkata"),f=async h=>{h.preventDefault(),c(!0),p("");try{await M.updateSite(e.slug||e.site_id,{name:l.trim(),timezone:o.trim()}),n==null||n()}catch(x){p(x.message)}finally{c(!1)}},d=async()=>{c(!0),p("");try{await M.deleteSite(e.slug||e.site_id),n==null||n(),r==null||r()}catch(h){p(h.message),y(!1)}finally{c(!1)}};return i.jsxs("section",{className:"claim",children:[i.jsx("h3",{children:"Shop details"}),i.jsxs("form",{onSubmit:f,children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Name"}),i.jsx("input",{value:l,onChange:h=>s(h.target.value),required:!0})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Short name"}),i.jsx("input",{value:e.slug,readOnly:!0}),i.jsx("span",{className:"hint",children:"Fixed: the shop PC and the broker are keyed on it."})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Timezone"}),i.jsx("input",{value:o,onChange:h=>a(h.target.value)})]}),m&&i.jsx("p",{className:"error",role:"alert",children:m}),i.jsxs("div",{className:"row",children:[i.jsx("button",{className:"primary",disabled:u||!C,children:u?"Saving…":"Save"}),g&&!v&&i.jsx("button",{type:"button",className:"ghost danger",onClick:()=>y(!0),children:"Remove this shop…"})]})]}),v&&i.jsxs("div",{className:"banner warn",style:{marginTop:12},children:[i.jsxs("b",{children:["Remove ",e.name,"?"]}),i.jsx("p",{className:"sub",children:"Only possible while it has no cameras and no visits. A shop with history is kept."}),i.jsxs("div",{className:"row",children:[i.jsx("button",{className:"primary",disabled:u,onClick:d,children:u?"Removing…":"Yes, remove it"}),i.jsx("button",{className:"ghost",onClick:()=>y(!1),children:"Keep it"})]})]})]})}function fp({user:e}){const{data:t,error:n,loading:r,reload:l}=It(()=>M.sites(),2e4,[]),{data:s}=It(()=>M.cameras(),6e4,[]),[o,a]=j.useState(null),[u,c]=j.useState(!1),m=t||[],p=(e==null?void 0:e.role)==="owner";if(r&&!t)return i.jsx(ar,{});if(n)return i.jsx(ur,{error:n});if(!m.length&&!u)return i.jsx(xp,{canOpen:p,onOpen:()=>c(!0)});const v=m.map(f=>{const d=(s||[]).filter(h=>h.site_id===f.site_id);return{site:f,cams:d,verdict:hp(f,d)}}),y=f=>v.filter(d=>d.verdict.tone===f).length,w=y("bad"),g=y("warn"),C=y("idle");return i.jsxs(i.Fragment,{children:[i.jsxs("header",{className:"head",children:[i.jsx("h1",{children:"Shops"}),i.jsxs("p",{className:"sub",children:[m.length," ",m.length===1?"shop":"shops",w>0&&i.jsxs(i.Fragment,{children:[" · ",i.jsxs("b",{className:"bad",children:[w," not working"]})]}),g>0&&i.jsxs(i.Fragment,{children:[" · ",i.jsxs("b",{className:"warn",children:[g," needing attention"]})]}),C>0&&i.jsxs(i.Fragment,{children:[" · ",C," not set up yet"]}),!w&&!g&&!C&&i.jsxs(i.Fragment,{children:[" · ",i.jsx("b",{className:"ok",children:"all working"})]})]}),p&&i.jsx("button",{className:"primary",onClick:()=>c(!0),children:"Open a new shop"})]}),i.jsx("div",{className:"grid sites",children:v.map(f=>i.jsx(vp,{site:f.site,cams:f.cams,verdict:f.verdict,onCheck:()=>a(f.site)},f.site.site_id))}),o&&i.jsx(op,{site:o,user:e,onClose:()=>a(null),onChanged:l}),u&&i.jsx(pp,{onClose:()=>c(!1),onCreated:()=>{c(!1),l()}})]})}function pp({onClose:e,onCreated:t}){const[n,r]=j.useState({name:"",slug:"",timezone:"Asia/Kolkata"}),[l,s]=j.useState(!1),[o,a]=j.useState(""),u=m=>p=>r({...n,[m]:p.target.value}),c=async m=>{m.preventDefault(),s(!0),a("");try{t(await M.createSite({name:n.name,slug:n.slug||void 0,timezone:n.timezone}))}catch(p){a(p.message),s(!1)}};return i.jsx("div",{className:"overlay",onClick:e,children:i.jsxs("aside",{className:"drawer narrow",onClick:m=>m.stopPropagation(),children:[i.jsxs("header",{className:"drawer-head",children:[i.jsx("h2",{children:"Open a new shop"}),i.jsx("button",{className:"ghost",onClick:e,children:"Close"})]}),i.jsxs("form",{className:"drawer-body",onSubmit:c,children:[i.jsxs("label",{children:["Shop name",i.jsx("input",{value:n.name,onChange:u("name"),required:!0,autoFocus:!0,placeholder:"TeNext Bengaluru"})]}),i.jsxs("label",{children:["Short name",i.jsx("input",{value:n.slug,onChange:u("slug"),placeholder:"made from the name if left empty"}),i.jsx("span",{className:"hint",children:"Lower-case letters, digits and dashes. It becomes the shop PC’s identity and cannot be changed afterwards."})]}),i.jsxs("label",{children:["Timezone",i.jsx("input",{value:n.timezone,onChange:u("timezone"),required:!0}),i.jsx("span",{className:"hint",children:"Footfall is bucketed by the shop’s own clock, e.g. Asia/Kolkata."})]}),o&&i.jsx("p",{className:"error",role:"alert",children:o}),i.jsx("button",{className:"primary",disabled:l||!n.name.trim(),children:l?"Opening…":"Open shop"})]})]})})}function hp(e,t){const n=e.fraction_below_gate,r=e.cameras_total||t.length;return e.online?e.dropped>0?{tone:"bad",mark:"✕",words:`${e.dropped} visits lost and unrecoverable`}:r===0?{tone:"idle",mark:"+",headline:"Not set up",words:"No cameras set up yet"}:e.cameras_up===0?{tone:"bad",mark:"✕",words:"No cameras connected"}:e.cameras_up.5?{tone:"bad",mark:"✕",words:`${bs(n)} of faces too poor to recognise`}:n>.2?{tone:"warn",mark:"!",words:`${bs(n)} of faces too poor to recognise`}:e.queued>0?{tone:"warn",mark:"!",words:`${e.queued} visits waiting to upload`}:{tone:"ok",mark:"✓",words:`Working — ${r} ${r===1?"camera":"cameras"} connected`}:{tone:"bad",mark:"✕",headline:"Offline",words:`Offline — last heard from ${Ft(e.last_heartbeat_at)}`}}const mp={ok:"Working",warn:"Needs attention",bad:"Not working",idle:"Not set up"};function vp({site:e,cams:t,verdict:n,onCheck:r}){const l=e.fraction_below_gate,s=n.tone,o=n.headline||mp[s],a=yp(t),u=e.cameras_total||t.length;return i.jsxs("article",{className:"card site state-"+s,onClick:r,role:"button",tabIndex:0,onKeyDown:c=>c.key==="Enter"&&r(),children:[i.jsxs("div",{className:"shot",children:[a.url?i.jsx(Xi,{image:a,alt:`View inside ${e.name}`}):i.jsxs("div",{className:"noshot",children:[i.jsx(gp,{}),a.reason&&i.jsx("span",{children:a.reason})]}),i.jsxs("div",{className:"shot-over",children:[i.jsxs("div",{className:"shot-name",children:[i.jsx("b",{children:e.name}),i.jsx("span",{children:u>0?`${u} ${u===1?"camera":"cameras"}`:"No cameras yet"})]}),i.jsxs("span",{className:"status "+s,children:[i.jsx("i",{"aria-hidden":"true"}),o]})]}),a.at&&i.jsx("span",{className:"shot-age",children:Ft(a.at)})]}),i.jsxs("div",{className:"metrics",children:[i.jsx(ss,{label:"Cameras",value:u?`${e.cameras_up}/${u}`:"—",tone:u?e.cameras_up0?bs(1-l):"—",tone:l?l>.5?"bad":l>.2?"warn":"ok":"idle"}),i.jsx(ss,{label:"Last seen",value:Ft(e.last_heartbeat_at),tone:e.online?"ok":"bad"})]}),i.jsxs("div",{className:"verdict "+n.tone,children:[i.jsx("span",{className:"mark","aria-hidden":"true",children:n.mark}),i.jsx("span",{className:"words",children:n.words}),i.jsx("span",{className:"go","aria-hidden":"true",children:"→"})]})]})}function ss({label:e,value:t,tone:n}){return i.jsxs("div",{className:"metric",children:[i.jsx("b",{className:n,children:t}),i.jsx("span",{children:e})]})}function yp(e){var r;if(!e.length)return{};let t=null;for(const l of e)!((r=l.snapshot)!=null&&r.available)||!l.snapshot.url||(!t||(l.snapshot_at||"")>(t.snapshot_at||""))&&(t=l);return t?{...t.snapshot,at:t.snapshot_at}:{reason:e.map(l=>{var s;return(s=l.snapshot)==null?void 0:s.reason}).find(Boolean)||"No picture from this shop yet."}}function gp(){return i.jsxs("svg",{className:"shopmark",viewBox:"0 0 40 32","aria-hidden":"true",children:[i.jsx("path",{d:"M4 12h32v18H4z"}),i.jsx("path",{d:"M2 12l4-8h28l4 8"}),i.jsx("path",{d:"M15 30v-9h10v9"})]})}function bs(e){return`${Math.round(e*100)}%`}function Ft(e){if(!e)return"never";const t=new Date(e).getTime();if(Number.isNaN(t))return"—";const n=Math.max(0,(Date.now()-t)/1e3);if(n<90)return"just now";const r=Math.round(n/60);if(r<60)return`${r} min ago`;const l=Math.round(r/60);return l<48?`${l} h ago`:`${Math.round(l/24)} days ago`}function wp(e){if(!e)return"never";const t=new Date(e).getTime();if(Number.isNaN(t))return"—";const n=(t-Date.now())/1e3;if(n<=0)return"expired";const r=Math.round(n/60);if(r<60)return`in ${r} min`;const l=Math.round(r/60);return l<48?`in ${l} h`:`in ${Math.round(l/24)} days`}function ar(){return i.jsxs("div",{className:"state",children:[i.jsx("span",{className:"spinner","aria-hidden":"true"}),"Loading…"]})}function ur({error:e}){return i.jsx("div",{className:"state",children:i.jsx("p",{className:"error",role:"alert",children:e.message})})}function xp({canOpen:e,onOpen:t}){return i.jsxs("div",{className:"state",children:[i.jsx("h2",{children:"No shops yet"}),i.jsx("p",{className:"sub",children:e?"Open your first shop, then set up its PC and cameras from its card.":"The owner opens shops; they appear here once created."}),e&&i.jsx("button",{className:"primary",onClick:t,children:"Open a new shop"})]})}const ua=60;function kp(){const[e,t]=j.useState([]),[n,r]=j.useState("connecting"),[l,s]=j.useState(null),o=j.useRef(new Set);return j.useEffect(()=>{const a=new AbortController;let u=()=>{};return(async()=>{try{const c=await M.arrivals({limit:30}),m=c.arrivals||[];m.forEach(p=>o.current.add(p.visit_id)),t(m.slice().reverse()),r("live"),u=tp({cursor:c.cursor,signal:a.signal,onPage:p=>{const v=(p.arrivals||[]).filter(y=>!o.current.has(y.visit_id));v.length&&(v.forEach(y=>o.current.add(y.visit_id)),r("live"),t(y=>[...v.reverse(),...y].slice(0,ua)))},onError:()=>r("reconnecting")})}catch(c){s(c)}})(),()=>{a.abort(),u()}},[]),l?i.jsx(ur,{error:l}):n==="connecting"&&!e.length?i.jsx(ar,{}):i.jsxs(i.Fragment,{children:[i.jsxs("header",{className:"head",children:[i.jsx("h1",{children:"Live"}),i.jsxs("p",{className:"sub",children:[i.jsx("span",{className:"dot "+(n==="live"?"ok":"warn"),"aria-hidden":"true"}),n==="live"?"Connected":"Reconnecting…"," · ","last ",ua," arrivals"]})]}),e.length===0?i.jsxs("div",{className:"state",children:[i.jsx("h2",{children:"Nobody yet"}),i.jsx("p",{className:"sub",children:"Arrivals appear here the moment a camera recognises someone."})]}):i.jsx("ul",{className:"arrivals",children:e.map(a=>i.jsx(jp,{a},a.visit_id))})]})}function jp({a:e}){const t=e.name||e.label||"Unidentified";return i.jsxs("li",{className:"card arrival",children:[i.jsx(Sp,{image:e.image,name:t,customerRef:e.visitor_ref}),i.jsxs("div",{className:"who-col",children:[i.jsx("strong",{children:t}),i.jsxs("span",{className:"sub",children:[e.name&&e.visitor_ref?`${e.visitor_ref} · `:"",e.site,e.camera_id?` · ${e.camera_id}`:""," · ",Ft(e.occurred_at)]}),e.attributes&&i.jsx(Ep,{attrs:e.attributes})]}),e.is_new_visitor?i.jsx("span",{className:"pill new",children:"New"}):i.jsx("span",{className:"pill",children:"Returning"})]})}function Sp({image:e,name:t,customerRef:n}){return e!=null&&e.available?i.jsx("span",{className:"face",children:i.jsx(Xi,{image:e,alt:""})}):i.jsx("span",{className:"face initials",title:(e==null?void 0:e.reason)||"","aria-hidden":"true",children:Np(t,n)})}function Np(e,t){const n=/^Visitor (\d+)$/.exec(String(e).trim());if(n)return n[1];if(t){const r=/^V-(\d+)$/.exec(t);if(r)return r[1]}return Cp(e)}function Cp(e){const t=String(e).trim().split(/\s+/).filter(Boolean);return t.length?t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[t.length-1][0]).toUpperCase():"?"}function Ep({attrs:e}){const t=[];return e.gender&&t.push(e.gender),e.age&&t.push(`~${Math.round(e.age)}`),e.emotion&&t.push(e.emotion),t.length?i.jsx("span",{className:"attrs",children:t.join(" · ")}):null}function _p({camera:e,onClose:t}){const n=j.useRef(null),[r,l]=j.useState("waiting"),[s,o]=j.useState(!1);j.useEffect(()=>{const c=new AbortController,m=np({cameraId:e.id,img:n,onState:v=>{l(v),v==="live"&&o(!1)},signal:c.signal}),p=setTimeout(()=>o(!0),12e3);return()=>{m(),c.abort(),clearTimeout(p)}},[e.id]);const a=e.connected===!1?"This camera was not connecting when the shop PC last reported. Check it is powered on and reachable on the shop’s network.":e.connected==null?"The shop PC has not reported on this camera yet. It may still be starting up.":"The shop PC is not sending frames. It may be offline, or its Behavision app may not be running.",u=s&&r!=="live"?a:{waiting:"Asking the shop PC…",live:"Live",reconnecting:"Reconnecting…"}[r];return i.jsx("div",{className:"overlay",onClick:t,children:i.jsxs("aside",{className:"drawer live",onClick:c=>c.stopPropagation(),children:[i.jsxs("header",{className:"drawer-head",children:[i.jsxs("div",{children:[i.jsx("h2",{children:e.label}),i.jsx("p",{className:"sub",children:e.site})]}),i.jsx("button",{className:"ghost",onClick:t,children:"Close"})]}),i.jsxs("div",{className:"drawer-body",children:[i.jsxs("div",{className:"liveshot",children:[i.jsx("img",{ref:n,alt:`Live view from ${e.label}`}),r!=="live"&&i.jsx("div",{className:"livewait",children:i.jsx("span",{children:s?"No picture yet":u})})]}),i.jsx("p",{className:"hint",style:{marginTop:10},children:r==="live"?"Live. The shop only uploads while this view is open.":u})]})]})})}const Br=[{id:"hikvision",label:"Hikvision",path:"/Streaming/Channels/101",note:"Channel 1, main stream. Use /Streaming/Channels/102 for the lower-quality sub stream."},{id:"dahua",label:"Dahua",path:"/cam/realmonitor?channel=1&subtype=0",note:"Channel 1, main stream. subtype=1 is the sub stream."},{id:"cpplus",label:"CP Plus",path:"/cam/realmonitor?channel=1&subtype=0",note:"CP Plus cameras use the Dahua stream path."},{id:"uniview",label:"Uniview",path:"/media/video1",note:"Some older Uniview models use /video1 instead."},{id:"tplink",label:"TP-Link / Tapo",path:"/stream1",note:"Tapo cameras need a separate camera account created in the Tapo app — your Tapo login will not work."},{id:"reolink",label:"Reolink",path:"/h264Preview_01_main",note:"Use /h264Preview_01_sub for the lower-quality stream."},{id:"amcrest",label:"Amcrest",path:"/cam/realmonitor?channel=1&subtype=0",note:"Amcrest cameras use the Dahua stream path."},{id:"axis",label:"Axis",path:"/axis-media/media.amp",note:""},{id:"onvif",label:"Other (ONVIF)",path:"/onvif1",note:"Many generic cameras answer here. If it does not work, look for “RTSP” in the camera’s own app."},{id:"manual",label:"I know the path",path:"",note:""}],ca=e=>Br.find(t=>t.id===e)||Br[Br.length-1];function Pp(e){const t=String(e||"").trim();if(!t)return null;const n=/^[a-z][a-z0-9+.-]*:\/\//i.test(t);if(!n&&!t.includes("/"))return null;const r=n?t:"rtsp://"+t;let l;try{l=new URL(r)}catch{return null}return l.hostname?{host:l.hostname,port:Number(l.port)||554,path:(l.pathname||"")+(l.search||"")||"/",username:decodeURIComponent(l.username||""),password:decodeURIComponent(l.password||"")}:null}const Tp=["Camera","Connection","Test","Walk past"];function zp({sites:e,existing:t,onClose:n,onSaved:r}){var P;const l=!(t!=null&&t.id),[s,o]=j.useState(l?0:2),[a,u]=j.useState(t!=null&&t.id?t:null),[c,m]=j.useState({site_id:(t==null?void 0:t.site_id)||((P=e[0])==null?void 0:P.site_id)||"",make:"hikvision",label:(t==null?void 0:t.label)||"",host:(t==null?void 0:t.host)||"",port:(t==null?void 0:t.port)||554,path:(t==null?void 0:t.path)||"/Streaming/Channels/101",username:(t==null?void 0:t.username)||"",password:""}),[p,v]=j.useState(!1),[y,w]=j.useState(""),g=S=>z=>m(L=>({...L,[S]:z.target.value})),[C,f]=j.useState(""),[d,h]=j.useState(""),x=S=>{if(f(S),!S.trim()){h("");return}const z=Pp(S);if(!z){h("That does not look like an RTSP address.");return}h(""),m(L=>({...L,make:"manual",host:z.host,port:z.port,path:z.path,...z.username?{username:z.username}:{},...z.password?{password:z.password}:{}}))},N=S=>{const z=ca(S.target.value);m(L=>({...L,make:z.id,path:z.path||L.path}))},T=async()=>{v(!0),w("");const S={};for(const[z,L]of Object.entries(c))z==="site_id"||z==="make"||L===""||L==null||(S[z]=z==="port"?Number(L):L);try{const z=a!=null&&a.id?await M.updateCamera(a.id,S):await M.createCamera(c.site_id,S);u(z),o(2),r==null||r(z,{keepOpen:!0})}catch(z){w(z.message)}finally{v(!1)}};return i.jsx("div",{className:"overlay",onClick:n,children:i.jsxs("aside",{className:"drawer wizard",onClick:S=>S.stopPropagation(),children:[i.jsxs("header",{className:"drawer-head",children:[i.jsxs("div",{children:[i.jsx("h2",{children:l?"Set up a camera":(a==null?void 0:a.label)||(t==null?void 0:t.label)}),i.jsx("p",{className:"sub",children:s<2?"The shop’s PC connects to the camera — nothing needs opening to the internet.":"Prove it works before you rely on it."})]}),i.jsx("button",{className:"ghost",onClick:n,children:"Close"})]}),i.jsx("ol",{className:"steps",children:Tp.map((S,z)=>i.jsxs("li",{className:z===s?"now":zi.jsx("option",{value:S.site_id,children:S.name},S.site_id))})]}),i.jsxs("label",{children:["What should staff call it?",i.jsx("input",{value:c.label,onChange:g("label"),placeholder:"Entrance",autoFocus:!0}),i.jsx("span",{className:"hint",children:"Visits are recorded against this name, so it cannot be changed later."})]}),i.jsxs("label",{children:["Make of camera",i.jsx("select",{value:c.make,onChange:N,children:Br.map(S=>i.jsx("option",{value:S.id,children:S.label},S.id))}),i.jsx("span",{className:"hint",children:ca(c.make).note||"This only fills in the stream path for you. You can change it on the next step."})]}),i.jsx("button",{className:"primary",disabled:!c.label.trim(),onClick:()=>o(1),children:"Next"})]}),s===1&&i.jsxs("div",{className:"drawer-body",children:[i.jsxs("label",{children:["Paste the camera’s RTSP address, if you have one",i.jsx("input",{className:"mono",value:C,onChange:S=>x(S.target.value),placeholder:"rtsp://admin:password@192.168.0.138:554/ch0_0.264",autoComplete:"off",name:"rtsp-url",spellCheck:"false"}),i.jsx("span",{className:"hint",children:d||"Optional. Paste it and the fields below fill in; otherwise fill them in yourself."})]}),i.jsxs("label",{children:["Camera’s address on the shop’s network",i.jsx("input",{value:c.host,onChange:g("host"),placeholder:"192.168.0.138",autoFocus:!0}),i.jsx("span",{className:"hint",children:"Not a website address. It usually starts 192.168. — look in the camera’s own app, on its label, or in your router’s device list."})]}),i.jsxs("div",{className:"pair",children:[i.jsxs("label",{children:["Port",i.jsx("input",{type:"number",value:c.port,onChange:g("port")})]}),i.jsxs("label",{children:["Stream path",i.jsx("input",{value:c.path,onChange:g("path")})]})]}),i.jsxs("label",{children:["Camera username",i.jsx("input",{value:c.username,onChange:g("username"),placeholder:"admin",name:"camera-account",autoComplete:"off",autoCorrect:"off",autoCapitalize:"none",spellCheck:"false"}),i.jsx("span",{className:"hint",children:"The camera’s own login, not your Behavision one."})]}),i.jsxs("label",{children:["Camera password",i.jsx("input",{type:"password",value:c.password,onChange:g("password"),name:"camera-secret",autoComplete:"new-password",placeholder:a!=null&&a.has_password?"(unchanged)":""})]}),y&&i.jsx("p",{className:"error",role:"alert",children:y}),i.jsxs("div",{className:"pair",children:[i.jsx("button",{className:"ghost",onClick:()=>o(0),children:"Back"}),i.jsx("button",{className:"primary",disabled:p||!c.host.trim(),onClick:T,children:p?"Saving…":"Save and test"})]})]}),s>=2&&a&&i.jsx(Lp,{camera:a,step:s,onStep:o,onUpdated:S=>{u(S),r==null||r(S,{keepOpen:!0})},onEdit:()=>o(1),onDone:n})]})})}function Lp({camera:e,step:t,onStep:n,onUpdated:r,onEdit:l,onDone:s}){const[o,a]=j.useState(e),[u,c]=j.useState(!1),[m,p]=j.useState(""),v=j.useRef(null);j.useEffect(()=>a(e),[e]);const y=o.check||{},w=y.state==="requested"||y.state==="running";j.useEffect(()=>{if(!w)return;let f=!0;const d=async()=>{try{const x=(await M.cameras()).find(N=>N.id===o.id);f&&x&&(a(x),r==null||r(x))}catch{}};return v.current=setInterval(d,4e3),()=>{f=!1,clearInterval(v.current)}},[w,o.id]);const g=async(f,d)=>{c(!0),p("");try{const h=await M.checkCamera(o.id,f,d);a(h),r==null||r(h),n(f==="placement"?3:2)}catch(h){p(h.message)}finally{c(!1)}},C=y.kind==="connection"&&y.state==="done"&&y.ok;return i.jsx(i.Fragment,{children:i.jsxs("div",{className:"drawer-body",children:[t===2?i.jsxs(i.Fragment,{children:[i.jsx("h3",{children:"Can the shop’s PC reach this camera?"}),i.jsx("p",{className:"sub",children:"The PC opens the stream once and takes a single picture. Nothing is recorded."})]}):i.jsxs(i.Fragment,{children:[i.jsx("h3",{children:"Can it actually recognise a face?"}),i.jsxs("p",{className:"sub",children:["Someone needs to ",i.jsx("b",{children:"walk through the camera’s view and out of it"}),", the way a customer would. Standing still measures nothing — the check scores the best view of each person as they leave the frame, which is what recognition really uses."]})]}),w&&i.jsxs("div",{className:"waiting",children:[i.jsx("span",{className:"spinner","aria-hidden":"true"}),i.jsxs("div",{children:[i.jsx("b",{children:y.state==="running"?"Running on the shop’s PC…":"Waiting for the shop’s PC…"}),i.jsx("span",{className:"sub",children:y.state==="running"?"This takes about "+(y.seconds||25)+" seconds.":"It picks up the request within a couple of minutes."})]})]}),y.state==="done"&&i.jsx(Rp,{check:y}),m&&i.jsx("p",{className:"error",role:"alert",children:m}),i.jsx("div",{className:"pair",children:t===2?i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"ghost",onClick:l,children:"Change details"}),i.jsx("button",{className:"primary",disabled:u||w,onClick:()=>g("connection"),children:y.state==="done"?"Test again":"Test connection"})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"ghost",onClick:()=>n(2),children:"Back"}),i.jsx("button",{className:"primary",disabled:u||w,onClick:()=>g("placement",25),children:y.state==="done"?"Check again":"Start walk-past check"})]})}),t===2&&C&&!w&&i.jsx("button",{className:"primary",onClick:()=>n(3),children:"Next: prove it can recognise faces"}),t===3&&y.state==="done"&&!w&&i.jsx("button",{className:"ghost",onClick:s,children:"Finish"})]})})}function Rp({check:e}){var n,r,l;const t=e.ok?"ok":e.verdict==="marginal"?"warn":"bad";return i.jsxs("div",{className:"outcome "+t,children:[i.jsxs("div",{className:"outcome-head",children:[i.jsx("span",{className:"pill "+t,children:e.ok?"Working":"Not ready"}),i.jsx("b",{children:e.headline||(e.ok?"Working":"Could not be verified")})]}),((n=e.image)==null?void 0:n.available)&&i.jsx("img",{className:"proof",src:e.image.url,alt:"The view from this camera",loading:"lazy"}),((r=e.advice)==null?void 0:r.length)>0&&i.jsx("ul",{className:"advice",children:e.advice.map((s,o)=>i.jsx("li",{children:s},o))}),((l=e.detail)==null?void 0:l.faces)!=null&&i.jsxs("p",{className:"sub",children:[e.detail.faces," ",e.detail.faces===1?"person":"people"," walked past during the check."]})]})}function Op(e){const t=e.check||{};return t.state==="requested"||t.state==="running"?{tone:"idle",mark:"…",words:"Checking now"}:t.state!=="done"?{tone:"idle",mark:"?",words:"Not checked yet"}:t.kind==="placement"?t.ok?{tone:"ok",mark:"✓",words:"Recognises faces here"}:{tone:"bad",mark:"✕",words:t.headline||"Cannot recognise faces here"}:t.ok?{tone:"warn",mark:"!",words:"Stream works — faces not checked yet"}:{tone:"bad",mark:"✕",words:t.headline||"Could not reach the camera"}}function Ip({user:e}){const{data:t,error:n,loading:r,reload:l}=It(()=>M.cameras(),2e4,[]),{data:s}=It(()=>M.sites(),0,[]),[o,a]=j.useState(null),[u,c]=j.useState(null),m=["admin","owner","manager"].includes(e.role),p=t||[],v=p.filter(C=>C.state==="connected").length,y=p.filter(C=>C.state==="not_connecting").length,w=p.filter(C=>C.state==="waiting").length,g=p.filter(C=>C.state==="stale").length;return i.jsxs(i.Fragment,{children:[i.jsxs("header",{className:"head",children:[i.jsx("h1",{children:"Cameras"}),i.jsxs("p",{className:"sub",children:[p.length," ",p.length===1?"camera":"cameras",v>0&&i.jsxs(i.Fragment,{children:[" · ",i.jsxs("b",{className:"ok",children:[v," connected"]})]}),g>0&&i.jsxs(i.Fragment,{children:[" · ",i.jsxs("b",{className:"warn",children:[g," not reporting"]})]}),y>0&&i.jsxs(i.Fragment,{children:[" · ",i.jsxs("b",{className:"bad",children:[y," down"]})]}),w>0&&i.jsxs(i.Fragment,{children:[" · ",w," waiting for the shop PC"]})]}),m&&i.jsx("button",{className:"primary",onClick:()=>a({}),children:"Set up a camera"})]}),r&&!t?i.jsx(ar,{}):n?i.jsx(ur,{error:n}):p.length===0?i.jsxs("div",{className:"state",children:[i.jsx("h2",{children:"No cameras yet"}),i.jsx("p",{className:"sub",children:"Add one here and the shop’s PC will pick it up within a couple of minutes. Cameras already set up on a shop PC appear here on their own."})]}):i.jsx("div",{className:"grid cams",children:p.map(C=>i.jsx(Fp,{cam:C,canEdit:m,onEdit:()=>a(C),onWatch:()=>c(C)},C.id))}),o&&i.jsx(zp,{existing:o.id?o:null,sites:s||[],onClose:()=>{a(null),l()},onSaved:(C,f)=>{f!=null&&f.keepOpen||a(null),l()}}),u&&i.jsx(_p,{camera:u,onClose:()=>c(null)})]})}function Fp({cam:e,canEdit:t,onEdit:n,onWatch:r}){var a,u;const l={connected:"ok",not_connecting:"bad",stale:"warn"}[e.state]||"idle",s={connected:"Connected",not_connecting:"Not connecting",stale:"Not reporting"}[e.state]||"Waiting for the shop PC",o=Op(e);return i.jsxs("article",{className:"card cam state-"+l,onClick:t?n:void 0,role:t?"button":void 0,tabIndex:t?0:void 0,onKeyDown:c=>t&&c.key==="Enter"&&n(),children:[i.jsxs("div",{className:"shot",children:[(a=e.snapshot)!=null&&a.available?i.jsx(Xi,{image:e.snapshot,alt:`View from ${e.label}`}):i.jsxs("div",{className:"noshot",children:[i.jsx("span",{className:"lens","aria-hidden":"true"}),((u=e.snapshot)==null?void 0:u.reason)||"No picture yet."]}),i.jsxs("div",{className:"shot-over",children:[i.jsxs("div",{className:"shot-name",children:[i.jsx("b",{children:e.label||e.camera_id}),i.jsx("span",{children:e.site})]}),i.jsxs("span",{className:"status "+l,children:[i.jsx("i",{"aria-hidden":"true"}),s]})]}),e.snapshot_at&&i.jsx("span",{className:"shot-age",children:Ft(e.snapshot_at)}),i.jsxs("button",{className:"watch",title:"Watch this camera now",onClick:c=>{c.stopPropagation(),r()},children:[i.jsx("i",{"aria-hidden":"true"}),"Live"]})]}),i.jsxs("div",{className:"verdict "+o.tone,children:[i.jsx("span",{className:"mark","aria-hidden":"true",children:o.mark}),i.jsx("span",{className:"words",children:o.words}),t&&i.jsx("span",{className:"go","aria-hidden":"true",children:"→"})]})]})}const Dp=["Is everything working today?","Why is footfall low at Chennai?","How many people came in last week?","Which cameras still need checking?"];function Mp({open:e,onClose:t}){const[n,r]=j.useState([]),[l,s]=j.useState(""),[o,a]=j.useState(!1),[u,c]=j.useState(!1),m=j.useRef(null),p=j.useRef(null);j.useEffect(()=>{var y;e&&((y=p.current)==null||y.focus())},[e]),j.useEffect(()=>{var y;(y=m.current)==null||y.scrollIntoView({behavior:"smooth",block:"end"})},[n,o]);const v=async y=>{const w=(y??l).trim();if(!w||o)return;const g=[...n,{role:"user",text:w}];r(g),s(""),a(!0);try{const C=await M.ask(g);r(f=>[...f,{role:"assistant",text:C.text,used:C.used}])}catch(C){C.code==="assistant_off"?c(!0):r(f=>[...f,{role:"assistant",text:C.message,failed:!0}])}finally{a(!1)}};return e?i.jsxs("aside",{className:"assistant",role:"complementary","aria-label":"Assistant",children:[i.jsxs("header",{className:"assistant-head",children:[i.jsxs("div",{children:[i.jsx("b",{children:"Loya"}),i.jsx("span",{className:"sub",children:"Your Behavision buddy — knows your shops, cameras and numbers."})]}),i.jsx("button",{className:"ghost",onClick:t,"aria-label":"Close assistant",children:"✕"})]}),i.jsxs("div",{className:"assistant-body",children:[u?i.jsx("p",{className:"sub pad",children:"Loya is not switched on for this server."}):n.length===0?i.jsxs("div",{className:"suggest",children:[i.jsx("p",{className:"sub",children:"Try asking:"}),Dp.map(y=>i.jsx("button",{className:"chip",onClick:()=>v(y),children:y},y))]}):n.map((y,w)=>{var g;return i.jsxs("div",{className:"bubble "+y.role+(y.failed?" failed":""),children:[y.text,((g=y.used)==null?void 0:g.length)>0&&i.jsxs("span",{className:"used",children:["looked at: ",y.used.map($p).join(", ")]})]},w)}),o&&i.jsxs("div",{className:"bubble assistant-thinking",children:[i.jsx("span",{className:"spinner","aria-hidden":"true"})," Looking…"]}),i.jsx("div",{ref:m})]}),!u&&i.jsxs("form",{className:"assistant-ask",onSubmit:y=>{y.preventDefault(),v()},children:[i.jsx("input",{ref:p,value:l,onChange:y=>s(y.target.value),placeholder:"Ask Loya…",disabled:o}),i.jsx("button",{className:"primary",disabled:o||!l.trim(),children:"Ask"})]})]}):null}function $p(e){return{list_shops:"your shops",check_shop:"a shop check",list_cameras:"your cameras",check_camera:"a camera check",footfall:"footfall",sales:"sales",find_customer:"customer records"}[e]||e}function Up(){const{data:e,error:t,loading:n,reload:r}=It(()=>M.clients(),0,[]),[l,s]=j.useState(!1),[o,a]=j.useState(null),u=e||[];return i.jsxs(i.Fragment,{children:[i.jsxs("header",{className:"head",children:[i.jsx("h1",{children:"Companies"}),i.jsx("button",{className:"primary",onClick:()=>{a(null),s(!0)},children:"New company"})]}),o&&i.jsx(Bp,{result:o,onDismiss:()=>a(null)}),n&&!e?i.jsx(ar,{}):t?i.jsx(ur,{error:t}):u.length===0?i.jsxs("div",{className:"state",children:[i.jsx("h2",{children:"No companies yet"}),i.jsx("p",{className:"sub",children:"Create one, and its owner can sign in straight away."})]}):i.jsx("div",{className:"tablewrap",children:i.jsxs("table",{className:"rows",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Company"}),i.jsx("th",{children:"Short name"}),i.jsx("th",{children:"Sites"}),i.jsx("th",{children:"People"}),i.jsx("th",{children:"Created"})]})}),i.jsx("tbody",{children:u.map(c=>i.jsxs("tr",{children:[i.jsx("td",{children:i.jsx("strong",{children:c.name})}),i.jsx("td",{children:i.jsx("code",{children:c.slug})}),i.jsx("td",{className:"num",children:c.sites}),i.jsx("td",{className:"num",children:c.users}),i.jsx("td",{className:"sub",children:Ft(c.created_at)})]},c.id))})]})}),l&&i.jsx(Ap,{onClose:()=>s(!1),onCreated:c=>{s(!1),a(c),r()}})]})}function Ap({onClose:e,onCreated:t}){const[n,r]=j.useState({company_name:"",owner_name:"",owner_email:"",password:""}),[l,s]=j.useState(!1),[o,a]=j.useState(""),u=m=>p=>r({...n,[m]:p.target.value}),c=async m=>{m.preventDefault(),s(!0),a("");try{t(await M.createClient(n))}catch(p){a(p.message),s(!1)}};return i.jsx("div",{className:"overlay",onClick:e,children:i.jsxs("aside",{className:"drawer narrow",onClick:m=>m.stopPropagation(),children:[i.jsxs("header",{className:"drawer-head",children:[i.jsx("h2",{children:"New company"}),i.jsx("button",{className:"ghost",onClick:e,children:"Close"})]}),i.jsxs("form",{className:"drawer-body",onSubmit:c,children:[i.jsxs("label",{children:["Company name",i.jsx("input",{value:n.company_name,onChange:u("company_name"),required:!0,autoFocus:!0})]}),i.jsxs("label",{children:["Owner’s name",i.jsx("input",{value:n.owner_name,onChange:u("owner_name")})]}),i.jsxs("label",{children:["Owner’s email",i.jsx("input",{type:"email",value:n.owner_email,onChange:u("owner_email"),required:!0})]}),i.jsxs("label",{children:["Password",i.jsx("input",{type:"text",value:n.password,onChange:u("password"),placeholder:"Leave empty to generate one"}),i.jsx("span",{className:"hint",children:"Generated is better — a password you invent for someone else ends up weak and sent over chat."})]}),o&&i.jsx("p",{className:"error",role:"alert",children:o}),i.jsx("button",{className:"primary",disabled:l,children:l?"Creating…":"Create company"})]})]})})}function Bp({result:e,onDismiss:t}){return i.jsxs("div",{className:"banner ok credentials",children:[i.jsxs("div",{children:[i.jsxs("b",{children:[e.slug," created."]})," These sign-in details are shown once and cannot be recovered. Send them to the owner now.",i.jsxs("dl",{className:"creds",children:[i.jsxs("div",{children:[i.jsx("dt",{children:"Email"}),i.jsx("dd",{children:i.jsx("code",{children:e.owner_email})})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"Password"}),i.jsx("dd",{children:i.jsx("code",{children:e.password})})]})]})]}),i.jsx("button",{className:"ghost",onClick:t,children:"Done"})]})}function Vp({user:e}){const t=It(()=>M.team(),0,[]),n=It(()=>M.invitations(),0,[]),[r,l]=j.useState(!1),[s,o]=j.useState(null),[a,u]=j.useState(""),[c,m]=j.useState(""),p=e.role==="owner"||e.role==="manager",v=t.data||[],y=n.data||[],w=async(g,C)=>{u(g),m("");try{await M.updateMember(g,C),t.reload()}catch(f){m(f.message)}finally{u("")}};return i.jsxs(i.Fragment,{children:[i.jsxs("header",{className:"head",children:[i.jsx("h1",{children:"Team"}),p&&i.jsx("button",{className:"primary",onClick:()=>{o(null),l(!0)},children:"Invite someone"})]}),s&&i.jsx(Hp,{invite:s,onDismiss:()=>o(null)}),c&&i.jsx("p",{className:"error",role:"alert",children:c}),t.loading&&!t.data?i.jsx(ar,{}):t.error?i.jsx(ur,{error:t.error}):i.jsx("div",{className:"tablewrap",children:i.jsxs("table",{className:"rows",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Name"}),i.jsx("th",{children:"Email"}),i.jsx("th",{children:"Role"}),i.jsx("th",{children:"Last signed in"}),p&&i.jsx("th",{})]})}),i.jsx("tbody",{children:v.map(g=>i.jsxs("tr",{className:g.active?"":"inactive",children:[i.jsxs("td",{children:[i.jsx("strong",{children:g.full_name||"—"}),!g.active&&i.jsx("span",{className:"pill muted",children:"No access"})]}),i.jsx("td",{children:i.jsx("code",{children:g.email})}),i.jsx("td",{children:p&&g.id!==e.id?i.jsxs("select",{value:g.role,disabled:a===g.id,onChange:C=>w(g.id,{role:C.target.value}),children:[i.jsx("option",{value:"staff",children:"Staff"}),i.jsx("option",{value:"manager",children:"Manager"}),e.role==="owner"&&i.jsx("option",{value:"owner",children:"Owner"})]}):i.jsx("span",{className:"role",children:g.role})}),i.jsx("td",{className:"sub",children:g.last_login_at?Ft(g.last_login_at):"Never"}),p&&i.jsx("td",{className:"right",children:g.id===e.id?null:g.active?i.jsx("button",{className:"ghost danger",disabled:a===g.id,onClick:()=>w(g.id,{active:!1}),children:"Remove access"}):i.jsx("button",{className:"ghost",disabled:a===g.id,onClick:()=>w(g.id,{active:!0}),children:"Restore"})})]},g.id))})]})}),p&&y.length>0&&i.jsxs("section",{className:"pending",children:[i.jsx("h2",{children:"Waiting to join"}),i.jsx("ul",{className:"invites",children:y.map(g=>i.jsxs("li",{className:"card invite",children:[i.jsxs("div",{children:[i.jsx("strong",{children:g.email}),i.jsxs("span",{className:"sub",children:["invited as ",g.role,g.invited_by?` by ${g.invited_by}`:""," · expires ",wp(g.expires_at)]})]}),i.jsx("button",{className:"ghost danger",onClick:async()=>{await M.revokeInvitation(g.id),n.reload()},children:"Withdraw"})]},g.id))})]}),r&&i.jsx(Wp,{canMintOwner:e.role==="owner",onClose:()=>l(!1),onDone:g=>{l(!1),o(g),n.reload()}})]})}function Wp({canMintOwner:e,onClose:t,onDone:n}){const[r,l]=j.useState({email:"",full_name:"",role:"staff"}),[s,o]=j.useState(!1),[a,u]=j.useState(""),c=p=>v=>l({...r,[p]:v.target.value}),m=async p=>{p.preventDefault(),o(!0),u("");try{n(await M.invite(r))}catch(v){u(v.message),o(!1)}};return i.jsx("div",{className:"overlay",onClick:t,children:i.jsxs("aside",{className:"drawer narrow",onClick:p=>p.stopPropagation(),children:[i.jsxs("header",{className:"drawer-head",children:[i.jsx("h2",{children:"Invite someone"}),i.jsx("button",{className:"ghost",onClick:t,children:"Close"})]}),i.jsxs("form",{className:"drawer-body",onSubmit:m,children:[i.jsxs("label",{children:["Their email",i.jsx("input",{type:"email",value:r.email,onChange:c("email"),required:!0,autoFocus:!0,autoComplete:"off",name:"invitee"}),i.jsx("span",{className:"hint",children:"This is the address they will sign in with, and it is fixed by the invitation — passing the code on cannot make it somebody else’s account."})]}),i.jsxs("label",{children:["Their name",i.jsx("input",{value:r.full_name,onChange:c("full_name"),autoComplete:"off",name:"invitee-name"})]}),i.jsxs("label",{children:["Role",i.jsxs("select",{value:r.role,onChange:c("role"),children:[i.jsx("option",{value:"staff",children:"Staff — see customers and shops"}),i.jsx("option",{value:"manager",children:"Manager — also set up cameras and invite people"}),e&&i.jsx("option",{value:"owner",children:"Owner — full control"})]})]}),a&&i.jsx("p",{className:"error",role:"alert",children:a}),i.jsx("button",{className:"primary",disabled:s,children:s?"Creating…":"Create invitation"})]})]})})}function Hp({invite:e,onDismiss:t}){return i.jsxs("div",{className:"banner ok credentials",children:[i.jsxs("div",{children:[i.jsxs("b",{children:["Invitation for ",e.email,"."]})," Give them this code. It is shown once, works once, and cannot be recovered.",i.jsxs("dl",{className:"creds",children:[i.jsxs("div",{children:[i.jsx("dt",{children:"Code"}),i.jsx("dd",{children:i.jsx("code",{className:"big",children:e.code})})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"Role"}),i.jsx("dd",{children:e.role})]})]}),i.jsx("p",{className:"sub",children:"They open the app, choose “I have an invitation code”, and pick their own password. Nobody else ever sees it."})]}),i.jsx("button",{className:"ghost",onClick:t,children:"Done"})]})}const Qp=[{id:"sites",label:"Shops",View:fp},{id:"live",label:"Live",View:kp},{id:"cameras",label:"Cameras",View:Ip},{id:"team",label:"Team",View:Vp}],Kp=[{id:"clients",label:"Companies",View:Up}];function Gp(){const[e,t]=j.useState(null),[n,r]=j.useState(!0),[l,s]=j.useState("sites"),[o,a]=j.useState(!1);if(j.useEffect(()=>{(async()=>{if(ep())try{t(await M.me())}catch{or()}r(!1)})()},[]),n)return i.jsxs("div",{className:"boot",children:[i.jsx("span",{className:"spinner","aria-hidden":"true"}),"Loading…"]});if(!e)return i.jsx(rp,{onSignedIn:t});const u=e.role==="admin"&&!e.client_id,c=u?Kp:Qp,m=c.find(y=>y.id===l)||c[0],p=m.View,v=async()=>{await M.logout(),t(null)};return i.jsxs("div",{className:"app",children:[i.jsxs("header",{className:"topbar",children:[i.jsxs("div",{className:"brand",children:[i.jsx("span",{className:"mark","aria-hidden":"true"}),i.jsxs("div",{children:[i.jsx("strong",{children:"Behavision"}),i.jsx("span",{className:"org",children:e.client_name||"Loyaly platform"})]})]}),i.jsx("nav",{className:"tabs",children:c.map(y=>i.jsx("button",{onClick:()=>s(y.id),"aria-current":m.id===y.id?"page":void 0,children:y.label},y.id))}),i.jsxs("div",{className:"who",children:[i.jsxs("button",{className:"ask-btn"+(o?" on":""),onClick:()=>a(y=>!y),title:"Ask Loya",children:[i.jsx("span",{className:"mark","aria-hidden":"true"})," Loya"]}),i.jsx("span",{className:"name",children:e.full_name||e.email}),i.jsx("span",{className:"role",children:u?"platform admin":e.role}),i.jsx("button",{className:"ghost",onClick:v,children:"Sign out"})]})]}),i.jsxs("div",{className:"with-assistant"+(o?" open":""),children:[i.jsx("main",{className:"page",children:i.jsx(p,{user:e})}),i.jsx(Mp,{open:o,onClose:()=>a(!1)})]})]})}Sc(document.getElementById("root")).render(i.jsx(Gp,{})); diff --git a/server/internal/web/dist/index.html b/server/internal/web/dist/index.html index c6d6669..b82d77a 100644 --- a/server/internal/web/dist/index.html +++ b/server/internal/web/dist/index.html @@ -6,7 +6,7 @@ Behavision - + diff --git a/shared/cameraMakes.js b/shared/cameraMakes.js index 72603d7..df53ee2 100644 --- a/shared/cameraMakes.js +++ b/shared/cameraMakes.js @@ -79,3 +79,48 @@ export const MAKES = [ ] export const makeById = (id) => MAKES.find(m => m.id === id) || MAKES[MAKES.length - 1] + +// Paste the camera's RTSP URL, rather than taking it apart by hand. +// +// The engine has always accepted a whole URL (`CameraConfig.url` wins over the +// parts) and no form has ever offered one - the same gap as the webcam option, +// and it costs more here. A URL is how people actually HAVE this information: +// it is what the camera's own app shows, what an installer writes down and +// what gets pasted into a message. Splitting it into five fields by eye is +// where a password containing `@` or `/` goes wrong, and this repository +// already records a whole class of bug from unencoded `@` in RTSP credentials. +// +// Split into fields rather than stored whole, deliberately: everything else on +// the form - Test, the make picker, editing later, and the rule that a +// password is never returned to the browser - works on the parts. A URL kept +// intact would carry the password back out to every screen that reads a +// camera. +export function parseRtspUrl(raw) { + const text = String(raw || '').trim() + if (!text) return null + const hasScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(text) + // A bare `host/path` is a reasonable thing to paste, so the scheme is + // optional - but something has to mark this as a URL rather than a word. + // Without the slash test, `nonsense` parses as a perfectly good hostname + // and silently fills the Address field with it: a wrong answer that looks + // like it worked, which is worse than refusing. + if (!hasScheme && !text.includes('/')) return null + const withScheme = hasScheme ? text : 'rtsp://' + text + let u + try { + u = new URL(withScheme) + } catch { + return null + } + if (!u.hostname) return null + // WHATWG splits user info at the LAST `@`, which is what makes an unencoded + // `@` inside a password parse the way a person means it. + const out = { + host: u.hostname, + port: Number(u.port) || 554, + path: (u.pathname || '') + (u.search || '') || '/', + username: decodeURIComponent(u.username || ''), + password: decodeURIComponent(u.password || ''), + } + return out +} diff --git a/tests/test_rtsp_paste.py b/tests/test_rtsp_paste.py new file mode 100644 index 0000000..c533733 --- /dev/null +++ b/tests/test_rtsp_paste.py @@ -0,0 +1,91 @@ +"""`shared/cameraMakes.js` is imported by BOTH camera forms and has no test +runner of its own. This is the same safety net `test_dashboard.py` provides: +node is driven from pytest and the check is skipped when node is absent, so +the suite stays dependency-light. + +What it guards is the field people actually have. The engine has always +accepted a whole RTSP URL (`CameraConfig.url` wins over the parts) and no form +ever offered one, so an operator holding the address their camera's own app +shows had to take it apart into five fields by eye — which is exactly where a +password containing `@` goes wrong, a class of bug this repository has already +been bitten by once. +""" +import json +import shutil +import subprocess +from pathlib import Path + +import pytest + +ROOT = Path(__file__).resolve().parent.parent +SHARED = ROOT / "shared" / "cameraMakes.js" + +pytestmark = pytest.mark.skipif(shutil.which("node") is None, + reason="node not installed") + + +def parse(text): + out = subprocess.run( + ["node", "--input-type=module", "-e", + f"import {{ parseRtspUrl }} from {json.dumps(str(SHARED))};" + f"console.log(JSON.stringify(parseRtspUrl({json.dumps(text)})))"], + capture_output=True, text=True, timeout=60) + assert out.returncode == 0, out.stderr + return json.loads(out.stdout.strip()) + + +def test_a_plain_url_becomes_the_five_fields(): + assert parse("rtsp://admin:Pass123@192.168.1.121:554/ch0_0.264") == { + "host": "192.168.1.121", "port": 554, "path": "/ch0_0.264", + "username": "admin", "password": "Pass123"} + + +def test_an_at_sign_in_the_password_survives(): + """The one that matters. A URL is split at the LAST `@`, which is what + makes an unencoded `@` inside a password parse the way a person means it - + and an operator splitting this by eye would put `p` in the password box + and `ssw0rd@192.168.1.121` in the address box.""" + got = parse("rtsp://admin:p@ssw0rd@192.168.1.121:554/Streaming/Channels/101") + assert got["password"] == "p@ssw0rd" + assert got["host"] == "192.168.1.121" + + +def test_a_percent_encoded_password_is_decoded(): + """Stored decoded, because CameraConfig.source() percent-encodes when it + rebuilds the URL. Keeping it encoded would double-encode it and the camera + would refuse a password that is correct.""" + assert parse("rtsp://admin:p%40ss@10.0.0.5/live")["password"] == "p@ss" + + +def test_the_default_port_is_filled_in(): + assert parse("rtsp://192.168.1.122/ch0_1.264")["port"] == 554 + + +def test_a_query_string_stays_with_the_path(): + """Some cameras carry the channel in a query. Dropping it opens the wrong + channel, which looks like a camera pointed somewhere unexpected.""" + assert parse("rtsp://cam.local:8554/live?channel=1")["path"] == "/live?channel=1" + + +def test_a_scheme_is_optional_but_structure_is_not(): + assert parse("192.168.1.122/ch0_1.264")["host"] == "192.168.1.122" + # A bare word parses as a perfectly good hostname, so without this it + # would silently fill the Address field with it - a wrong answer that + # looks like it worked, which is worse than refusing. + assert parse("nonsense") is None + assert parse("192.168.1.121") is None, "a bare address is not a URL; the Address field takes it" + + +def test_nothing_is_nothing(): + assert parse("") is None + assert parse(" ") is None + + +def test_both_forms_import_it(): + """Two copies of this would be worse than not offering it, because an + operator trusts a filled-in field. Same rule as the make picker.""" + for form in (ROOT / "desktop/frontend/src/views/Cameras.jsx", + ROOT / "web/src/views/CameraSetup.jsx"): + src = form.read_text(encoding="utf-8") + assert "parseRtspUrl" in src, f"{form.name} does not offer the paste field" + assert "cameraMakes.js" in src, f"{form.name} defines its own parser" diff --git a/web/src/views/CameraSetup.jsx b/web/src/views/CameraSetup.jsx index c3e3caa..cc45631 100644 --- a/web/src/views/CameraSetup.jsx +++ b/web/src/views/CameraSetup.jsx @@ -1,6 +1,6 @@ import { useEffect, useRef, useState } from 'react' import { api } from '../api.js' -import { MAKES, makeById } from '../../../shared/cameraMakes.js' +import { MAKES, makeById, parseRtspUrl } from '../../../shared/cameraMakes.js' // Setting up a camera, for somebody who has never done it. // @@ -30,6 +30,25 @@ export default function CameraSetup({ sites, existing, onClose, onSaved }) { const [error, setError] = useState('') const set = (k) => (e) => setForm(f => ({ ...f, [k]: e.target.value })) + + // Paste the whole RTSP address. It is how people actually hold this + // information - it is what the camera's own app shows and what an installer + // writes down - and splitting it into five fields by eye is where a + // password containing `@` or `/` goes wrong. + const [pasted, setPasted] = useState('') + const [pasteError, setPasteError] = useState('') + const applyUrl = (text) => { + setPasted(text) + if (!text.trim()) { setPasteError(''); return } + const got = parseRtspUrl(text) + if (!got) { setPasteError('That does not look like an RTSP address.'); return } + setPasteError('') + // Only what the URL actually carried: one with no credentials must not + // wipe a password already typed. + setForm(f => ({ ...f, make: 'manual', host: got.host, port: got.port, path: got.path, + ...(got.username ? { username: got.username } : {}), + ...(got.password ? { password: got.password } : {}) })) + } const chooseMake = (e) => { const m = makeById(e.target.value) // Only overwrite the path when the preset has one, so choosing "I know the @@ -115,6 +134,14 @@ export default function CameraSetup({ sites, existing, onClose, onSaved }) { {step === 1 && (
+