(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 * * 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 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=_[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 * * 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 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||!(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 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":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 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 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,{}));