@ssgc/alert-console 2.11.0 → 2.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +7374 -7331
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),d=require("react"),h=require("antd"),ht=require("@ant-design/icons"),Te=require("react-toastify"),yt=require("@tanstack/react-query"),ba="#FF3B30",Ia="#FF9500",ka="#FFCC00",Ea="#34C759",_t={critical:ba,high:Ia,medium:ka,low:Ea},hn={Critical:_t.critical,High:_t.high,Medium:_t.medium,Low:_t.low};function Ma(t){return hn[t]||hn.Low}function yn(t){if(!t||typeof t!="string")return 0;const e=t.trim().split(":");if(e.length!==3)return 0;const[s,n,r]=e,a=Number.parseInt(s,10),o=Number.parseInt(n,10),l=Number.parseFloat(r||"0"),c=Number.isFinite(a)?a:0,u=Number.isFinite(o)?o:0,f=Number.isFinite(l)?l:0;return c*3600+u*60+f}function pn(t){return t.toLowerCase().replaceAll("'","").replaceAll("‘","").replaceAll("’","")}const nr="",ja=nr,Oa="",Da="",Ca="",Ra="",gn={snl:{alerts:nr,rules:ja},schools:{alerts:Oa,rules:Da},transit:{alerts:Ca,rules:Ra}};class Ua extends Error{statusCode;status;envelope;constructor(e){super(e.errorMessage||e.message||`HTTP ${e.statusCode}`),this.name="ApiError",this.statusCode=e.statusCode,this.status=e.statusCode,this.envelope=e}}function ke(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function La(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Lt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}const Fa=["responseStatus","errorMessage","statusCode"];function $a(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Fa.some(e=>e in t)}function Sn(t,e,s){if($a(t)){const r=Number(t.statusCode)||e,a=typeof t.responseStatus=="boolean"?t.responseStatus:s&&r<400,o=t.errorMessage??t.message??"",l="data"in t?t.data:null;return{data:l,errorMessage:o,statusCode:r,responseStatus:a,message:o||(typeof l=="string"?l:""),raw:t}}const n=typeof t=="string"?t:t?.message??"";return{data:t,errorMessage:s?"":n||`HTTP ${e}`,statusCode:e,responseStatus:s,message:n,raw:t}}async function ot(t,e){const s={...e.headers,...La()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return Sn({},n.status,n.ok);const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}return Sn(a,n.status,n.ok)}async function Js(t,e){const s=await ot(t,e);if(!s.responseStatus)throw new Ua(s);return s.data}async function at(t,e){const s=await Js(t,e);return Array.isArray(s)?s:[]}async function Ns(t,e){const s=await Js(t,e);return s&&typeof s=="object"&&!Array.isArray(s)?s:null}function Pa(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=ke(t.baseUrl,"/api/Alert"),r=Lt(n,{page:s?.pageNumber??1,pageSize:s?.pageSize??10,...s?.anomalyId!==void 0&&{anomalyId:s.anomalyId},...s?.spaceId!==void 0&&{spaceId:s.spaceId},...s?.severityName!==void 0&&{severity:s.severityName},...s?.thirdPartyIds?.length&&{thirdPartyIds:s.thirdPartyIds.join(",")},...s?.searchText&&{searchText:s.searchText},isArchived:s?.isArchived??!1}),a=await at(r,{method:"GET",headers:e}),o=a.length>0?a[0].totalRecords??a.length:0;return{items:a,total:o}},async getAlertStatusList(){const s=ke(t.baseUrl,"/api/Alert/AlertStatusList");return at(s,{method:"GET",headers:e})},async getAlertsReport(s){const n=ke(t.baseUrl,"/Alerts/GetAlertsReport"),r=Lt(n,s);return at(r,{method:"GET",headers:e})},async updateAlertStatus(s){const n=ke(t.baseUrl,"/api/Alert/status");return ot(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAlertTimeline(s){const n=ke(t.baseUrl,`/api/Alert/alertTimelines/${s}`);return at(n,{method:"GET",headers:e})},async getAdminSettings(){const s=ke(t.baseUrl,"/api/Alert/GetAdminSettings");return Ns(s,{method:"GET",headers:e})},async setAdminSettings(s){const n=ke(t.baseUrl,"/api/Alert/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return ot(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=ke(t.baseUrl,"/api/Alert/GetPreferenceSettings");return Ns(s,{method:"GET",headers:e})},async setPreferenceSettings(s){const n=ke(t.baseUrl,"/api/Alert/SetPreferenceSettings");return ot(n,{method:"POST",headers:e,body:JSON.stringify(s??{})})},async getAlertNotifications(s){const n=ke(t.baseUrl,"/api/Alert/GetNotifications"),r=Lt(n,{alertId:s});return at(r,{method:"GET",headers:e})},async notifyFamilyMembers(s){const n=ke(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=Lt(n,{alertId:s});return ot(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const a=ke(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),o=Lt(a,{alertId:s,isEmail:n,isSMS:r});return ot(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=ke(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters");return at(s,{method:"GET",headers:e})},async getMyAppPreferences(){const s=ke(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Ns(s,{method:"GET",headers:e});return n?.timeZoneUniqueId?{timeZoneUniqueId:n.timeZoneUniqueId}:null},async getAllSpaces(){const s=ke(t.baseUrl,"/api/Spaces/GetAllSpaces");return(await at(s,{method:"GET",headers:e})).map(r=>({spaceId:r?.spaceId??r?.SpaceId,spaceName:r?.spaceName??r?.SpaceName??""}))}}}function Wa(t){const e={"Content-Type":"application/json",...t.headers||{}},s=ke(t.baseUrl,"/api/Rules"),n=ke(t.baseUrl,"/api/Rules/lookups");return{async getRules(){return at(s,{method:"GET",headers:e})},async setEscalationSettings(r){return ot(s,{method:"POST",headers:e,body:JSON.stringify(r??{})})},async getLookups(){return Js(n,{method:"GET",headers:e})},async updateRule(r,a){const o=`${s}/${r}`;return ot(o,{method:"PUT",headers:e,body:JSON.stringify(a??{})})}}}function Ba(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var as={exports:{}},Va=as.exports,xn;function Za(){return xn||(xn=1,(function(t,e){(function(s,n){t.exports=n()})(Va,(function(){var s=1e3,n=6e4,r=36e5,a="millisecond",o="second",l="minute",c="hour",u="day",f="week",m="month",p="quarter",g="year",v="date",I="Invalid Date",N=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,B=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,H={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(M){var A=["th","st","nd","rd"],x=M%100;return"["+M+(A[(x-20)%10]||A[x]||A[0])+"]"}},K=function(M,A,x){var E=String(M);return!E||E.length>=A?M:""+Array(A+1-E.length).join(x)+M},k={s:K,z:function(M){var A=-M.utcOffset(),x=Math.abs(A),E=Math.floor(x/60),T=x%60;return(A<=0?"+":"-")+K(E,2,"0")+":"+K(T,2,"0")},m:function M(A,x){if(A.date()<x.date())return-M(x,A);var E=12*(x.year()-A.year())+(x.month()-A.month()),T=A.clone().add(E,m),O=x-T<0,U=A.clone().add(E+(O?-1:1),m);return+(-(E+(x-T)/(O?T-U:U-T))||0)},a:function(M){return M<0?Math.ceil(M)||0:Math.floor(M)},p:function(M){return{M:m,y:g,w:f,d:u,D:v,h:c,m:l,s:o,ms:a,Q:p}[M]||String(M||"").toLowerCase().replace(/s$/,"")},u:function(M){return M===void 0}},D="en",V={};V[D]=H;var C="$isDayjsObject",q=function(M){return M instanceof re||!(!M||!M[C])},y=function M(A,x,E){var T;if(!A)return D;if(typeof A=="string"){var O=A.toLowerCase();V[O]&&(T=O),x&&(V[O]=x,T=O);var U=A.split("-");if(!T&&U.length>1)return M(U[0])}else{var Y=A.name;V[Y]=A,T=Y}return!E&&T&&(D=T),T||!E&&D},S=function(M,A){if(q(M))return M.clone();var x=typeof A=="object"?A:{};return x.date=M,x.args=arguments,new re(x)},j=k;j.l=y,j.i=q,j.w=function(M,A){return S(M,{locale:A.$L,utc:A.$u,x:A.$x,$offset:A.$offset})};var re=(function(){function M(x){this.$L=y(x.locale,null,!0),this.parse(x),this.$x=this.$x||x.x||{},this[C]=!0}var A=M.prototype;return A.parse=function(x){this.$d=(function(E){var T=E.date,O=E.utc;if(T===null)return new Date(NaN);if(j.u(T))return new Date;if(T instanceof Date)return new Date(T);if(typeof T=="string"&&!/Z$/i.test(T)){var U=T.match(N);if(U){var Y=U[2]-1||0,G=(U[7]||"0").substring(0,3);return O?new Date(Date.UTC(U[1],Y,U[3]||1,U[4]||0,U[5]||0,U[6]||0,G)):new Date(U[1],Y,U[3]||1,U[4]||0,U[5]||0,U[6]||0,G)}}return new Date(T)})(x),this.init()},A.init=function(){var x=this.$d;this.$y=x.getFullYear(),this.$M=x.getMonth(),this.$D=x.getDate(),this.$W=x.getDay(),this.$H=x.getHours(),this.$m=x.getMinutes(),this.$s=x.getSeconds(),this.$ms=x.getMilliseconds()},A.$utils=function(){return j},A.isValid=function(){return this.$d.toString()!==I},A.isSame=function(x,E){var T=S(x);return this.startOf(E)<=T&&T<=this.endOf(E)},A.isAfter=function(x,E){return S(x)<this.startOf(E)},A.isBefore=function(x,E){return this.endOf(E)<S(x)},A.$g=function(x,E,T){return j.u(x)?this[E]:this.set(T,x)},A.unix=function(){return Math.floor(this.valueOf()/1e3)},A.valueOf=function(){return this.$d.getTime()},A.startOf=function(x,E){var T=this,O=!!j.u(E)||E,U=j.p(x),Y=function(Ne,he){var $=j.w(T.$u?Date.UTC(T.$y,he,Ne):new Date(T.$y,he,Ne),T);return O?$:$.endOf(u)},G=function(Ne,he){return j.w(T.toDate()[Ne].apply(T.toDate("s"),(O?[0,0,0,0]:[23,59,59,999]).slice(he)),T)},_=this.$W,oe=this.$M,ue=this.$D,Ie="set"+(this.$u?"UTC":"");switch(U){case g:return O?Y(1,0):Y(31,11);case m:return O?Y(1,oe):Y(0,oe+1);case f:var ee=this.$locale().weekStart||0,pe=(_<ee?_+7:_)-ee;return Y(O?ue-pe:ue+(6-pe),oe);case u:case v:return G(Ie+"Hours",0);case c:return G(Ie+"Minutes",1);case l:return G(Ie+"Seconds",2);case o:return G(Ie+"Milliseconds",3);default:return this.clone()}},A.endOf=function(x){return this.startOf(x,!1)},A.$set=function(x,E){var T,O=j.p(x),U="set"+(this.$u?"UTC":""),Y=(T={},T[u]=U+"Date",T[v]=U+"Date",T[m]=U+"Month",T[g]=U+"FullYear",T[c]=U+"Hours",T[l]=U+"Minutes",T[o]=U+"Seconds",T[a]=U+"Milliseconds",T)[O],G=O===u?this.$D+(E-this.$W):E;if(O===m||O===g){var _=this.clone().set(v,1);_.$d[Y](G),_.init(),this.$d=_.set(v,Math.min(this.$D,_.daysInMonth())).$d}else Y&&this.$d[Y](G);return this.init(),this},A.set=function(x,E){return this.clone().$set(x,E)},A.get=function(x){return this[j.p(x)]()},A.add=function(x,E){var T,O=this;x=Number(x);var U=j.p(E),Y=function(oe){var ue=S(O);return j.w(ue.date(ue.date()+Math.round(oe*x)),O)};if(U===m)return this.set(m,this.$M+x);if(U===g)return this.set(g,this.$y+x);if(U===u)return Y(1);if(U===f)return Y(7);var G=(T={},T[l]=n,T[c]=r,T[o]=s,T)[U]||1,_=this.$d.getTime()+x*G;return j.w(_,this)},A.subtract=function(x,E){return this.add(-1*x,E)},A.format=function(x){var E=this,T=this.$locale();if(!this.isValid())return T.invalidDate||I;var O=x||"YYYY-MM-DDTHH:mm:ssZ",U=j.z(this),Y=this.$H,G=this.$m,_=this.$M,oe=T.weekdays,ue=T.months,Ie=T.meridiem,ee=function(he,$,P,ye){return he&&(he[$]||he(E,O))||P[$].slice(0,ye)},pe=function(he){return j.s(Y%12||12,he,"0")},Ne=Ie||function(he,$,P){var ye=he<12?"AM":"PM";return P?ye.toLowerCase():ye};return O.replace(B,(function(he,$){return $||(function(P){switch(P){case"YY":return String(E.$y).slice(-2);case"YYYY":return j.s(E.$y,4,"0");case"M":return _+1;case"MM":return j.s(_+1,2,"0");case"MMM":return ee(T.monthsShort,_,ue,3);case"MMMM":return ee(ue,_);case"D":return E.$D;case"DD":return j.s(E.$D,2,"0");case"d":return String(E.$W);case"dd":return ee(T.weekdaysMin,E.$W,oe,2);case"ddd":return ee(T.weekdaysShort,E.$W,oe,3);case"dddd":return oe[E.$W];case"H":return String(Y);case"HH":return j.s(Y,2,"0");case"h":return pe(1);case"hh":return pe(2);case"a":return Ne(Y,G,!0);case"A":return Ne(Y,G,!1);case"m":return String(G);case"mm":return j.s(G,2,"0");case"s":return String(E.$s);case"ss":return j.s(E.$s,2,"0");case"SSS":return j.s(E.$ms,3,"0");case"Z":return U}return null})(he)||U.replace(":","")}))},A.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},A.diff=function(x,E,T){var O,U=this,Y=j.p(E),G=S(x),_=(G.utcOffset()-this.utcOffset())*n,oe=this-G,ue=function(){return j.m(U,G)};switch(Y){case g:O=ue()/12;break;case m:O=ue();break;case p:O=ue()/3;break;case f:O=(oe-_)/6048e5;break;case u:O=(oe-_)/864e5;break;case c:O=oe/r;break;case l:O=oe/n;break;case o:O=oe/s;break;default:O=oe}return T?O:j.a(O)},A.daysInMonth=function(){return this.endOf(m).$D},A.$locale=function(){return V[this.$L]},A.locale=function(x,E){if(!x)return this.$L;var T=this.clone(),O=y(x,E,!0);return O&&(T.$L=O),T},A.clone=function(){return j.w(this.$d,this)},A.toDate=function(){return new Date(this.valueOf())},A.toJSON=function(){return this.isValid()?this.toISOString():null},A.toISOString=function(){return this.$d.toISOString()},A.toString=function(){return this.$d.toUTCString()},M})(),fe=re.prototype;return S.prototype=fe,[["$ms",a],["$s",o],["$m",l],["$H",c],["$W",u],["$M",m],["$y",g],["$D",v]].forEach((function(M){fe[M[1]]=function(A){return this.$g(A,M[0],M[1])}})),S.extend=function(M,A){return M.$i||(M(A,re,S),M.$i=!0),S},S.locale=y,S.isDayjs=q,S.unix=function(M){return S(1e3*M)},S.en=V[D],S.Ls=V,S.p={},S}))})(as)),as.exports}var za=Za();const Ha=Ba(za);function rr(t){if(!t)return"By Severity";const e=t.trim().toLowerCase();return e.includes("created")?"By Created Date":e.includes("updated")||e.includes("modified")?"By Updated Date":"By Severity"}function ar(t){if(!t||typeof t!="string")return{hours:0,minutes:0,seconds:0};const e=t.split(":").map(a=>parseInt(a,10)),s=Number.isFinite(e[0])?e[0]:0,n=Number.isFinite(e[1])?e[1]:0,r=Number.isFinite(e[2])?e[2]:0;return{hours:s,minutes:n,seconds:r}}function vn(t){const{hours:e,minutes:s,seconds:n}=ar(t);return Ha().hour(e).minute(s).second(n).millisecond(0)}function De(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function qa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Jt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Ce(t,e){const s={...e.headers,...qa()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.Message||`HTTP ${n.status}`;throw new Error(o)}return a}const me=(...t)=>t.find(e=>e!=null);function Nt(t,e,s={}){const n={};for(const r of e){const a=s[r]??r.charAt(0).toUpperCase()+r.slice(1);n[r]=t?.[a]??t?.[r]}return n}function Ga(t){return Array.isArray(t)?t.map(e=>Nt(e,["alertLogId","alertId","status","description","actionNotes","createdDate","createdBy","modifiedDate","modifiedBy"])):t}function Ya(t){return{id:String(me(t?.AlertId,t?.alertId)??""),alertNumber:me(t?.AlertNumber,t?.alertNumber),priority:me(t?.Priority,t?.priority,"Low"),timestamp:me(t?.UpdatedUtc,t?.timestamp,""),statusType:me(t?.Status,t?.statusType,""),description:me(t?.Description,t?.description,""),eventName:me(t?.EventName,t?.eventName),ruleName:me(t?.RuleName,t?.ruleName),spaceId:me(t?.SpaceId,t?.spaceId),spaceName:me(t?.SpaceName,t?.spaceName),anomalyId:me(t?.AnomalyId,t?.anomalyId),severityId:me(t?.SeverityId,t?.severityId),assignTeam:me(t?.AssignTeam,t?.assignTeam),cameraName:me(t?.CameraName,t?.cameraName),type:me(t?.Type,t?.type),mediaDetails:me(t?.MediaDetails,t?.mediaDetails,t?.MediaUrls,t?.mediaUrls),additionalMedia:me(t?.AdditionalMedia,t?.additionalMedia),timeElapsed:me(t?.TimeElapsed,t?.timeElapsed),timeRemaining:me(t?.TimeRemaining,t?.timeRemaining),anomalyName:me(t?.AnomalyName,t?.anomalyName),alertDetails:me(t?.AlertDetails,t?.alertDetails),statusHistory:Ga(me(t?.StatusHistory,t?.statusHistory)),isEmailSent:me(t?.IsEmailSent,t?.isEmailSent),isSMSSent:me(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:me(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function _a(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts"),r=Jt(n,{customerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",pageSize:s?.pageSize??10,page:s?.pageNumber??1,...s?.anomalyId!==void 0&&{anomalyId:s.anomalyId},...s?.spaceId!==void 0&&{spaceId:s.spaceId},...s?.severityId!==void 0&&{severityId:s.severityId},...s?.thirdPartyIds?.length&&{ThirdPartyIds:s.thirdPartyIds.join(",")},...s?.searchText&&{searchText:s.searchText},isArchived:s?.isArchived??!1}),a=await Ce(r,{method:"GET",headers:e});return{items:Array.isArray(a?.Items)?a.Items.map(Ya):[],total:a?.Total}},async getAlertStatusList(){const s=De(t.baseUrl,"/api/detectionpolicy/alerts/StatusList"),n=await Ce(s,{method:"GET",headers:e});return(Array.isArray(n)?n:[]).map(a=>Nt(a,["alertStatusId","value","statusName"]))},async getAlertsReport(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),r=Jt(n,s),a=await Ce(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/Log"),r={AlertId:s.alertId??s.alertUniqueId??s.AlertId,Status:s.status??s.Status??"",Notes:s.notes??s.Notes??""};return Ce(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getAlertTimeline(s){const n=De(t.baseUrl,`/api/detectionpolicy/alerts/alertTimelines/${s}`),r=await Ce(n,{method:"GET",headers:e});return(Array.isArray(r)?r:[]).map(o=>Nt(o,["alertUniqueId","timeElapsed","eventName","timeStamp"]))},async getAdminSettings(){const s=De(t.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),n=await Ce(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n.Data??n;if(r&&typeof r=="object")return Nt(r,["userId","isAdminSetting","sortBy"],{sortBy:"SortOption"})}return null},async setAdminSettings(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/SetAdminSettings"),r={Settings:{UserId:0,IsAdminSetting:!0,SortOption:s?.sortBy??"",GroupBy:s?.groupBy??null}};return Ce(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=De(t.baseUrl,"/api/detectionpolicy/alerts/GetPreferenceSettings"),n=await Ce(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),r=u=>{const{hours:f,minutes:m,seconds:p}=ar(u);return(f*3600+m*60+p)*1e7},a={Settings:{UserId:0,AnomalyIds:Array.isArray(s?.anomalyIds)?s.anomalyIds.map(u=>String(u)):[],DoNotDisturbStart:{Ticks:r(s?.doNotDisturbStart)},DoNotDisturbEnd:{Ticks:r(s?.doNotDisturbEnd)},InApp:!!s?.inApp,SMS:!!s?.sms,Email:!!s?.email,SortBy:s?.sortBy??""}},o=await Ce(n,{method:"POST",headers:e,body:JSON.stringify(a)}),l=o?.responseStatus??!0,c=o?.data??o?.message??"Preferences updated successfully.";return{responseStatus:l,errorMessage:l?"":o?.errorMessage??o?.Message??o?.message??"",statusCode:200,data:c}},async sendSMSorEmailNotifications(s,n,r){const a=De(t.baseUrl,"/api/detectionpolicy/alerts/SendSMSorEmailNotifications"),o=Jt(a,{alertId:s,isEmail:n,isSMS:r});return Ce(o,{method:"POST",headers:e})},async getAlertNotifications(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),r=Jt(n,{alertId:s}),a=await Ce(r,{method:"GET",headers:e});let o=[];return Array.isArray(a)?o=a:Array.isArray(a?.data)&&(o=a.data),o.map(l=>Nt(l,["alertNotificationSentId","alertId","notificationType","receipientName","receipentPhoneNumber","messageSID","messageStatus","receipientEmail","notificationReceipientType","sentAt"]))},async getTimeZoneMasters(){const s=De(t.baseUrl,"/api/TimeZoneMaster"),n=await Ce(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n.Data:[]).map(a=>Nt(a,["timeZoneUniqueId","ianaTimeZoneId","timeZoneName","offset"]))},async getAllSpaces(){const s=t.spacesBaseUrl||t.baseUrl,n=De(s,"/api/AllSpaces"),r=await Ce(n,{method:"GET",headers:e});return(Array.isArray(r?.Data)?r.Data:[]).map(o=>({spaceId:o?.SpaceId??o?.spaceId,spaceName:o?.SpaceName??o?.spaceName??""}))},async getMyAppPreferences(){const s=De(t.baseUrl,"/MyProfile"),n=await Ce(s,{method:"GET",headers:e}),r=n?.data?.userGuid??n?.Data?.userGuid??n?.userGuid;if(!r)return null;const a=De(t.baseUrl,`/api/GetMyAppPreferences/${r}`),o=await Ce(a,{method:"GET",headers:e});if(o&&typeof o=="object"){const l=o.data??o.Data??o,c=l?.timeZoneUniqueId??l?.TimeZoneUniqueId;if(c)return{timeZoneUniqueId:c}}return null}}}function Ja(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Ke(t,e){const s={...e.headers,...Ja()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Ka(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/api/detectionpolicy/rules",t.baseUrl).toString();return{async getRules(){const n=await Ke(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n?.Data:[]).map(a=>({...a,ruleId:a.ruleId??a.RuleId,ruleName:a.ruleName??a.RuleName??a.Name,escalationSettings:a.escalationSettings??a.EscalationSettings}))},async setEscalationSettings(n){return Ke(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=y=>new URL(y,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[Ke(n("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:e}),Ke(n("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:e}),Ke(n("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:e}),Ke(n("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:e}),Ke(n("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:e}),Ke(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,l,c,u,f,m]=await Promise.allSettled(a),p=y=>{if(y.status!=="fulfilled")return[];const S=y.value;return Array.isArray(S)?S:Array.isArray(S?.Data)?S.Data:Array.isArray(S?.data)?S.data:[]},g=p(o),v=p(l),I=p(c),N=p(u),B=p(f),H=m.status==="fulfilled"?m.value:null;let K=[];Array.isArray(H)?K=H:Array.isArray(H?.Data)?K=H.Data:Array.isArray(H?.data)&&(K=H.data);const k=g.map(y=>({actionTypeId:Number(y?.ActionTypeId),name:y?.DisplayName??y?.Name??""})),D=v.map(y=>({AnomalyId:y?.AnomalyId,DisplayName:y?.DisplayName??y?.Name??""})),V=I.map(y=>({thirdPartyId:Number(y?.ThirdPartyId),thirdPartyName:y?.ThirdPartyName??y?.Name??""})),C=K.map(y=>({userRoleId:y.UserRoleId??y.userRoleId??y.Id??y.id??0,userRoleName:y.UserRoleName??y.userRoleName??y.Name??y.name??""})),q={actionTypes:k,anomalies:D,thirdParties:V};return N.length&&(q.severities=N.map(y=>({severityId:y?.SeverityId??y?.severityId,severityName:y?.DisplayName??y?.SeverityName??y?.Name??y?.name??""}))),B.length&&(q.scheduleTypes=B),C.length&&(q.userRoles=C),q},async updateRule(n,r){const a=`${s}/${n}`,{escalationSettings:o,Anomaly:l,Severity:c,...u}=r??{};return Ke(a,{method:"PUT",headers:e,body:JSON.stringify({...u,CustomerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",Version:{DeDupWindowSeconds:0,IncludeSubjectInHash:!0},AnomalyId:l?.AnomalyId,SeverityId:c?.SeverityId,EscalationSettings:o?{...o,ThirdPartyIds:o.thirdPartyId??[]}:{}})})}}}function Qa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function tt(t,e){const s={...e.headers,...Qa()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Xa(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/list-rule",t.baseUrl).toString();return{async getRules(){const n=await tt(s,{method:"POST",headers:e,body:JSON.stringify({command:"get-all"})});return(Array.isArray(n?.data)?n.data:[]).map(a=>({...a,ruleId:a.RuleId??a.ruleId,ruleName:a.RuleName??a.ruleName,ruleDesc:a.RuleDesc??a.ruleDesc??null}))},async setEscalationSettings(n){return tt(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=C=>new URL(C,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[tt(n("/api/ActionTypeMaster/GetAll"),{method:"GET",headers:e}),tt(n("/api/anomaly/anomaly-list"),{method:"POST",headers:e,body:JSON.stringify({RuleLevel:1})}),tt(n("/api/Lookup/ThirdParties"),{method:"GET",headers:e}),tt(n("/api/anomaly/severity-list"),{method:"GET",headers:e}),tt(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,l,c,u,f]=await Promise.allSettled(a),m=C=>{if(C.status!=="fulfilled")return[];const q=C.value;return Array.isArray(q)?q:Array.isArray(q?.data)?q.data:[]},p=m(o),g=m(l),v=m(c),I=m(u),N=f.status==="fulfilled"?f.value:null,B=p.map(C=>({actionTypeId:C?.ActionTypeUniqueId,name:C?.Name??""})),H=g.map(C=>({recordId:C?.AnomalyId,anomalyName:C?.DisplayName??C?.Name??""})),K=v.map(C=>({thirdPartyId:Number(C?.ThirdPartyId),thirdPartyName:C?.ThirdPartyName??C?.Name??""}));let k=[];Array.isArray(N)?k=N:Array.isArray(N?.Data)?k=N.Data:Array.isArray(N?.data)&&(k=N.data);const D=k.map(C=>({userRoleId:C.userRoleId??0,userRoleName:C.userRoleName??""})),V={actionTypes:B,anomalies:H,thirdParties:K};return I.length&&(V.severities=I.map(C=>({SeverityId:C.SeverityId,DisplayName:C.SeverityName??C.DisplayName??""}))),D.length&&(V.userRoles=D),V},async updateRule(n,r){const a=new URL("/update-rule",t.baseUrl).toString(),{escalationSettings:o,ruleId:l,ruleName:c,ruleDesc:u,...f}=r??{},m=o??{},p=(m.escalationSettingsActionTypeIds??[]).filter(v=>v!=null&&!Number.isNaN(v)),g={Level1UserRoleId:m.level1UserRoleId??0,Level1PostAssistTime:m.level1PostAssistTime??0,Level2UserRoleId:m.level2UserRoleId??0,Level2PostAssistTime:m.level2PostAssistTime??0,Level3UserRoleId:m.level3UserRoleId??0,Level3PostAssistTime:m.level3PostAssistTime??0,EscalationSettingsActionTypeIds:p,ThirdPartyIds:m.thirdPartyId??[],HumanLoop:m.humanLoop??!1};return tt(a,{method:"POST",headers:e,body:JSON.stringify({...f,RuleId:l??f.RuleId??n,RuleName:c??f.RuleName,RuleDesc:u??f.RuleDesc??null,ActionTypeUniqueIdList:p,EscalationSettings:g})})}}}function Pe(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function ei(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Kt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function We(t,e){const s={...e.headers,...ei()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function ti(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Pe(t.baseUrl,"/api/Alerts"),r=Kt(n,{pageSize:s?.pageSize??10,pageNumber:s?.pageNumber??1,...s?.spaceNumber!==void 0&&{spaceNumber:s.spaceNumber},...s?.anomalyId!==void 0&&{anomalyId:s.anomalyId},...s?.severityId!==void 0&&{severityId:s.severityId},...s?.thirdPartyIds?.length&&{thirdPartyIds:s.thirdPartyIds.join(",")},...s?.isArchived!==void 0&&{isArchived:s.isArchived}}),a=await We(r,{method:"GET",headers:e});if(Array.isArray(a))return a;if(a&&typeof a=="object"){if(Array.isArray(a.items))return{items:a.items,total:typeof a.total=="number"?a.total:void 0};if(Array.isArray(a.data))return{items:a.data,total:typeof a.total=="number"?a.total:void 0};if(Array.isArray(a.alerts))return{items:a.alerts,total:typeof a.total=="number"?a.total:void 0}}return[]},async getAlertStatusList(){const s=Pe(t.baseUrl,"/api/Alerts/GetAlertStatus"),n=await We(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getAlertsReport(s){const n=Pe(t.baseUrl,"/Alerts/GetAlertsReport"),r=Kt(n,s),a=await We(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Pe(t.baseUrl,"/api/Alerts/UpdateAlertLog"),r={alertId:s.alertId,action:s.status,notes:s.notes};return We(n,{method:"PUT",headers:e,body:JSON.stringify(r??{})})},async getAdminSettings(){const s=Pe(t.baseUrl,"/api/Alerts/GetAdminSettings"),n=await We(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("userId"in n)return n}return null},async setAdminSettings(s){const n=Pe(t.baseUrl,"/api/Alerts/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return We(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Pe(t.baseUrl,"/api/Alerts/GetPreferenceSettings"),n=await We(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=Pe(t.baseUrl,"/api/Alerts/SetPreferenceSettings"),r=await We(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,o=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":r?.errorMessage??r?.message??"",statusCode:200,data:o}},async getAlertNotifications(s){const n=Pe(t.baseUrl,"/api/Alerts/GetNotifications"),r=Kt(n,{alertId:s}),a=await We(r,{method:"GET",headers:e});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]},async sendSMSorEmailNotifications(s,n,r){const a=Pe(t.baseUrl,"/api/Alerts/SendSMSorEmailNotifications"),o=Kt(a,{alertId:s,isEmail:n,isSMS:r});return We(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Pe(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await We(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Pe(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await We(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null}}}const ir=d.createContext(null);function or({tenant:t="snl",override:e,timeZone:s,userManagementDomain:n,spacesBaseUrl:r,children:a}){const o=d.useMemo(()=>{const c=e?.alertsBaseUrl?.trim()||gn[t]?.alerts||"";let u=e?.rulesBaseUrl?.trim()||gn[t]?.rules||"";t==="snl"&&(u=c);const f=e?.headers;return{tenant:t,alertsBaseUrl:c,rulesBaseUrl:u,headers:f,timeZone:s,userManagementDomain:n,spacesBaseUrl:r}},[t,e?.alertsBaseUrl,e?.rulesBaseUrl,JSON.stringify(e?.headers||{}),s,n,r]),l=d.useMemo(()=>{const c={baseUrl:o.alertsBaseUrl,headers:o.headers},u={baseUrl:o.rulesBaseUrl,headers:o.headers},f={schools:()=>_a({...c,spacesBaseUrl:o.spacesBaseUrl}),transit:()=>ti(c),snl:()=>Pa(c)},m={schools:()=>Ka({...u,userManagementBaseUrl:o.userManagementDomain}),transit:()=>Xa({...u,userManagementBaseUrl:o.userManagementDomain}),snl:()=>Wa({baseUrl:o.alertsBaseUrl,headers:o.headers})};return{config:o,alerts:f[o.tenant](),rules:m[o.tenant]()}},[o]);return i.jsx(ir.Provider,{value:l,children:a})}function Fe(){const t=d.useContext(ir);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}const si={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},ni={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Ks=6,Qs=7;function wn(t,e,s){const n=t===Ks,r=t===Qs,a=e.isEmailSent??!1,o=e.isSMSSent??!1,l=n&&a||r&&o,c=n?"Send Email":r?"Send SMS":s,u=n&&a?"Email sent":r&&o?"SMS sent":c,f=n&&a?"Email sent":r&&o?"SMS sent":`Click to ${c}`;return{isDisabled:l,buttonText:u,tooltipTitle:f}}function bs(t,e){return`${t}-${e?"email":"sms"}`}function Qt(t){return t===Ks||t===Qs}function fs({value:t,onChange:e,options:s,className:n,dropdownWidth:r}){return i.jsx(h.Select,{className:n,options:s,value:t,onChange:e,dropdownMatchSelectWidth:r??260})}const ri=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function ai({value:t,onChange:e,options:s}){return i.jsx(fs,{className:"w-[140px]",value:t,onChange:e,options:s||ri})}const ii=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function oi({value:t,onChange:e,options:s}){return i.jsx(fs,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||ii})}function li({value:t,onChange:e,options:s}){return i.jsx(fs,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const ci=[{label:"All",value:"All"},{label:"SOS",value:"SOS"},{label:"911",value:"911"},{label:"Aegix",value:"Aegix"},{label:"Eli",value:"Eli"},{label:"Skydio",value:"Skydio"}];function ui({value:t,onChange:e,options:s}){return i.jsx(fs,{className:"w-[130px]",value:t,onChange:e,options:s||ci})}function lr({columns:t,data:e,loading:s=!1,pageSize:n=10,total:r,currentPage:a,rowKey:o="id",toolbar:l,tableProps:c,onPageChange:u}){const m=r===void 0&&a!==void 0?e.length===n?a*n+1:(a-1)*n+e.length:void 0;return i.jsxs("div",{children:[l,i.jsx(h.Table,{rowKey:o,dataSource:e,columns:t,loading:s,pagination:{pageSize:n,current:a,total:r??m,showSizeChanger:!1,showTotal:p=>`Total: ${p}`,onChange:u},bordered:!0,...c})]})}function di(t){if(!t||typeof t!="string")return!1;const e=t.split("?")[0].toLowerCase();return e.endsWith(".mp4")||e.endsWith(".webm")||e.endsWith(".ogg")||e.endsWith(".m3u8")}function Fs(t){const e=(t?.mediaType||t?.type||"").toString().toLowerCase();return e==="video"||e==="mp4"?!0:di(t?.mediaUrl||t)}function mi(t){const e=t?.mediaUrl;let s=null;if(Array.isArray(e))s=e;else if(typeof e=="string")try{const n=JSON.parse(e);Array.isArray(n)&&(s=n)}catch{}return s&&s.length>0?s.map(n=>({...t,mediaUrl:n})):[t]}function cr(t){const e=t;return e?(Array.isArray(e)?e:[e]).flatMap(mi):[]}const st=16,nt=2,An={Low:"#22c55e",Medium:"#fde047",High:"#fb2c36",Critical:"#7a0707"};function ur({boxes:t,priority:e="High"}){const s=An[e]??An.High;return i.jsx(i.Fragment,{children:t.map((n,r)=>i.jsxs("div",{className:"absolute pointer-events-none",style:{left:n.x,top:n.y,width:n.width,height:n.height},children:[i.jsx("div",{className:"absolute left-0 whitespace-nowrap rounded-sm px-2 py-1 text-[10px] font-semibold text-white",style:{backgroundColor:s,transform:"translateY(-100%)"},children:n.label}),i.jsx("div",{className:"absolute top-0 left-0",style:{width:st,height:st,borderTop:`${nt}px solid ${s}`,borderLeft:`${nt}px solid ${s}`}}),i.jsx("div",{className:"absolute top-0 right-0",style:{width:st,height:st,borderTop:`${nt}px solid ${s}`,borderRight:`${nt}px solid ${s}`}}),i.jsx("div",{className:"absolute bottom-0 left-0",style:{width:st,height:st,borderBottom:`${nt}px solid ${s}`,borderLeft:`${nt}px solid ${s}`}}),i.jsx("div",{className:"absolute bottom-0 right-0",style:{width:st,height:st,borderBottom:`${nt}px solid ${s}`,borderRight:`${nt}px solid ${s}`}})]},`${n.label}-${r}`))})}const fi=t=>{if(!t)return[0,0,0,0];if(typeof t=="string")return t.replace(/[()[\]\s]/g,"").split(",").map(Number);if(!Array.isArray(t)||t.length===0)return[0,0,0,0];const e=t[0];return typeof e=="string"?e.replace(/[()[\]\s]/g,"").split(",").map(Number):Array.isArray(e)?e.map(Number):t.map(Number)},dr=(t,e,s,n,r)=>{if(!e||!s||!n||!r)return[];const a=Math.min(n/e,r/s),o=(n-e*a)/2,l=(r-s*a)/2;return t.flatMap(c=>{const[u,f,m,p]=fi(c.bbox_xyxy);return u>e||m>e||f>s||p>s?[]:[{personName:c.personName,x:u*a+o,y:f*a+l,width:(m-u)*a,height:(p-f)*a}]})},Tn={naturalWidth:0,naturalHeight:0,renderedWidth:0,renderedHeight:0};function mr(){const t=d.useRef(null),[e,s]=d.useState(Tn),n=d.useCallback(()=>{const a=t.current;a&&s({naturalWidth:a.naturalWidth,naturalHeight:a.naturalHeight,renderedWidth:a.offsetWidth,renderedHeight:a.offsetHeight})},[]),r=d.useCallback(()=>{s(Tn)},[]);return{imageRef:t,dimensions:e,onLoad:n,resetDimensions:r}}const fr=({isOpen:t,onClose:e,src:s,type:n="image",detections:r=[],priority:a})=>{const[o,l]=d.useState(!1),{imageRef:c,dimensions:u,onLoad:f,resetDimensions:m}=mr(),p=d.useMemo(()=>dr(r,u.naturalWidth,u.naturalHeight,u.renderedWidth,u.renderedHeight),[r,u]),g=d.useMemo(()=>p.map(v=>({...v,label:v.personName||""})),[p]);return d.useEffect(()=>{t&&(l(!1),m())},[t,s,m]),d.useLayoutEffect(()=>{c.current?.complete&&f()},[f]),d.useEffect(()=>{t&&(!s||o)&&e()},[t,s,o,e]),t?i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-70",role:"button",tabIndex:0,"aria-label":"Close media preview",onClick:e,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),e())},onTouchStart:e,children:i.jsx("div",{className:"relative max-w-5xl max-h-[90vh] w-full flex items-center justify-center",onClick:v=>v.stopPropagation(),children:n==="image"?i.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[i.jsx("img",{ref:c,src:s,alt:"preview",className:"object-contain rounded-lg shadow-lg max-w-full max-h-[90vh]",onLoad:f,onError:()=>l(!0)}),i.jsx(ur,{boxes:g,priority:a}),i.jsx("button",{onClick:e,className:"absolute top-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:"✕"})]}):i.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[i.jsx("video",{src:s,controls:!0,className:"object-contain rounded-lg shadow-lg max-w-full max-h-[90vh]",onError:()=>l(!0)}),i.jsx("button",{onClick:e,className:"absolute top-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:"✕"})]})})}):null};const hi=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),yi=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),Nn=t=>{const e=yi(t);return e.charAt(0).toUpperCase()+e.slice(1)},hr=(...t)=>t.filter((e,s,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===s).join(" ").trim(),pi=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var gi={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Si=d.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:a,iconNode:o,...l},c)=>d.createElement("svg",{ref:c,...gi,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:hr("lucide",r),...!a&&!pi(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,f])=>d.createElement(u,f)),...Array.isArray(a)?a:[a]]));const Xs=(t,e)=>{const s=d.forwardRef(({className:n,...r},a)=>d.createElement(Si,{ref:a,iconNode:e,className:hr(`lucide-${hi(Nn(t))}`,`lucide-${t}`,n),...r}));return s.displayName=Nn(t),s};const xi=[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]],yr=Xs("image-off",xi);const vi=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],wi=Xs("loader-circle",vi);const Ai=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Ti=Xs("maximize-2",Ai);function Ni(t){const s=cr(t.mediaDetails)[0];if(!s)return null;const n=s.mediaUrl??s;return typeof n!="string"||!n.length?null:{url:n,item:s}}function pr({record:t}){const e=d.useMemo(()=>Ni(t),[t]),[s,n]=d.useState(!1),[r,a]=d.useState(!1),o=d.useMemo(()=>t.bbox_xyxy?[{bbox_xyxy:t.bbox_xyxy,personName:t.personName}]:[],[t.bbox_xyxy,t.personName]);if(d.useEffect(()=>{a(!1)},[e?.url]),!e)return i.jsx("span",{className:"text-gray-400 text-sm",children:"—"});const{url:l,item:c}=e,u=Fs(c),f=u?"video":"image",m="block w-[72px] h-[54px] object-cover bg-gray-100 border border-gray-200 rounded-sm";return i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",disabled:r,className:"p-0 border-0 bg-transparent rounded-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-1 cursor-pointer disabled:cursor-not-allowed disabled:opacity-60","aria-label":r?"Preview unavailable":"Expand preview",onClick:()=>n(!0),children:r?i.jsx("span",{className:`${m} flex items-center justify-center text-gray-400`,children:i.jsx(yr,{size:20,"aria-hidden":!0})}):u?i.jsx("video",{src:l,className:m,muted:!0,playsInline:!0,preload:"metadata",onError:()=>a(!0)}):i.jsx("img",{src:l,alt:"",className:m,onError:()=>a(!0)})}),i.jsx(fr,{isOpen:s,onClose:()=>n(!1),src:l,type:f,detections:o,priority:t.priority})]})}function bi(t,e){const[s,n]=d.useState(t);return d.useEffect(()=>{const r=window.setTimeout(()=>n(t),e);return()=>window.clearTimeout(r)},[t,e]),s}function en({data:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,columns:a,renderActions:o,onAlertIdClick:l,onRefetch:c,onPageChange:u,onFilterChange:f,resetKey:m}){const[p,g]=d.useState("All"),[v,I]=d.useState("All"),[N,B]=d.useState("All"),[H,K]=d.useState("All"),[k,D]=d.useState(""),[V,C]=d.useState(r??1);d.useEffect(()=>{m!==void 0&&(g("All"),I("All"),B("All"),K("All"),D(""),C(1))},[m]),d.useEffect(()=>{r!==void 0&&C(r)},[r]);const[q,y]=d.useState([{label:"All",value:"All"}]),[S,j]=d.useState([]),[re,fe]=d.useState([]),[M,A]=d.useState([]),[x,E]=d.useState(new Set),{rules:T,alerts:O,config:U}=Fe(),Y=U.tenant==="schools",G=U.tenant==="transit",_=bi(k,600),oe=Y&&_.trim()?100:s,ue={6:{title:"Email",kind:"icon",icon:i.jsx(ht.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:i.jsx(ht.MessageOutlined,{})}};d.useEffect(()=>{if(!O.getAllSpaces)return;let $=!0;return(async()=>{try{const P=await O.getAllSpaces();if($){const ye=P.map(le=>({label:G?String(le.spaceNumber??le.spaceName??""):le.spaceName,value:String(G?le.spaceNumber??le.spaceId:le.spaceId)}));j([{label:"All",value:"All"},...ye])}}catch(P){console.error("Error loading space options",P)}})(),()=>{$=!1}},[O,G]),d.useEffect(()=>{let $=!0;return(async()=>{try{const P=await T.getLookups(),le=(Array.isArray(P.thirdParties)?P.thirdParties:[]).map(ge=>({label:ge.thirdPartyName,value:String(ge.thirdPartyId)})),we=(Array.isArray(P.anomalies)?P.anomalies:[]).map(ge=>({label:ge.anomalyName??ge.DisplayName,value:ge.anomalyId??ge.AnomalyId})),Ee=(Array.isArray(P.severities)?P.severities:[]).map(ge=>({label:ge.severityName,value:String(ge.severityId)}));$&&(y([{label:"All",value:"All"},...le]),we.length&&fe([{label:"All Types",value:"All"},...we]),Ee.length&&A([{label:"All levels",value:"All"},...Ee]))}catch(P){console.error("Error loading filter options",P)}})(),()=>{$=!1}},[T]),d.useEffect(()=>{if(!f)return;const $=M.find(ye=>ye.value===p),P={anomalyId:re.length>1&&v!=="All"?v:void 0,spaceId:!G&&S.length>1&&N!=="All"?N:void 0,spaceNumber:G&&S.length>1&&N!=="All"?N:void 0,severityId:M.length>1&&p!=="All"?p:void 0,severityName:M.length>1&&p!=="All"?$?.label:void 0,thirdPartyIds:H==="All"?void 0:[Number(H)],searchText:_.trim()||void 0};f(P),u?.(1)},[v,N,p,H,_,re.length,S.length,M.length,G,Y]);const Ie=re.length>1?re:void 0,ee=S.length>1?S:void 0,pe=M.length>1?M:void 0,Ne=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:$=>i.jsx(h.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${ni[$]}`,backgroundColor:si[$]},children:$})},{title:"Tracker",key:"tracker",width:140,render:($,P)=>i.jsx("a",{onClick:ye=>{ye.preventDefault(),l?.(P,{tab:"track",sourceTab:"active"})},className:"text-blue-600 hover:underline",children:"Tracker"})},{title:"Call to action/Human in the loop",key:"actions",width:320,render:($,P)=>{if(o)return i.jsx(i.Fragment,{children:o(P)});const ye=async(Le,St)=>{const xt=bs(P.id,Le);E(be=>new Set(be).add(xt));try{const be=await O.sendSMSorEmailNotifications?.(P.id,Le,St);be?.responseStatus||be?.Success||be?.success?(Te.toast.success(be?.message||be.data||(Le?"Email sent successfully":"SMS sent successfully")),c?.()):Te.toast.error(be?.message||be?.data||be?.errorMessage||"Failed to send notification")}catch(be){Te.toast.error(be?.message||"Failed to send notification")}finally{E(be=>{const vt=new Set(be);return vt.delete(xt),vt})}},le=Ks,Ue=Qs,we=ue[le],ze=ue[Ue],Ee=wn(le,P,we?.title),ge=wn(Ue,P,ze?.title),Ct=bs(P.id,!0),ut=bs(P.id,!1),gt=Qt(le)&&x.has(Ct),_e=Qt(Ue)&&x.has(ut);return i.jsxs(h.Space,{size:"middle",children:[i.jsx(h.Tooltip,{title:Ee.tooltipTitle,children:i.jsx(h.Button,{size:"small",disabled:Ee.isDisabled,loading:gt,onClick:Qt(le)?()=>ye(!0,!1):void 0,icon:!gt&&we?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:Ee.buttonText})},String(le)),i.jsx(h.Tooltip,{title:ge.tooltipTitle,children:i.jsx(h.Button,{size:"small",disabled:ge.isDisabled,loading:_e,onClick:Qt(Ue)?()=>ye(!1,!0):void 0,icon:!_e&&ze?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:ge.buttonText})},String(Ue))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:($,P)=>{const ye=P?.timeElapsed,le=P?.timeRemaining,Ue=ye?yn(ye):0,we=le?yn(le):0,ze=Math.round(Ue/(Ue+we)*100);return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-[70px]",children:"Elapsed:"}),i.jsx("span",{className:"font-medium",children:ye??"-"})]}),i.jsx(h.Progress,{percent:ze,showInfo:!1,size:"small",strokeColor:Ma(P.priority)}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-[70px]",children:"Remaining"}),i.jsx("span",{className:"font-medium",children:le??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:($,P)=>i.jsxs("div",{children:[i.jsx("a",{onClick:ye=>{ye.preventDefault(),l?.(P,{sourceTab:"active"})},className:"inline-block mb-1 text-blue-600",children:P.alertNumber}),i.jsx("div",{className:"text-black/65",children:$})]})},{title:"Preview",key:"preview",width:100,align:"center",render:($,P)=>i.jsx(pr,{record:P})}],he=a&&a.length?a:Ne;return i.jsx("div",{children:i.jsx(lr,{rowKey:"id",data:t,columns:he,loading:e,pageSize:oe,total:n,currentPage:V,onPageChange:u,toolbar:i.jsxs(h.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[i.jsx(h.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Severity"}),i.jsx(ai,{value:p,onChange:g,options:pe})]})}),i.jsx(h.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Anomaly type"}),i.jsx(oi,{value:v,onChange:I,options:Ie})]})}),i.jsx(h.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:G?"Bus Number":"Space"}),i.jsx(li,{value:N,onChange:B,options:ee})]})}),i.jsx(h.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Action Taken"}),i.jsx(ui,{value:H,onChange:K,options:q})]})}),i.jsx(h.Col,{flex:"auto"}),i.jsx(h.Col,{flex:"none",children:i.jsx(h.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:D,onChange:$=>D($.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}const Ii=["completed","false positive","face doesn't match name","safe","supervised exit","elopement confirmed"];function tn(){const{alerts:t}=Fe(),e=yt.useQueryClient();return yt.useMutation({mutationFn:s=>t.updateAlertStatus(s),onSuccess:()=>{e.invalidateQueries({queryKey:["alerts","list"]}),e.invalidateQueries({queryKey:["alerts","report"]})}})}class pt extends Error{}class ki extends pt{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class Ei extends pt{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class Mi extends pt{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class bt extends pt{}class gr extends pt{constructor(e){super(`Invalid unit ${e}`)}}class Me extends pt{}class rt extends pt{constructor(){super("Zone is an abstract class")}}const b="numeric",Ye="short",$e="long",cs={year:b,month:b,day:b},Sr={year:b,month:Ye,day:b},ji={year:b,month:Ye,day:b,weekday:Ye},xr={year:b,month:$e,day:b},vr={year:b,month:$e,day:b,weekday:$e},wr={hour:b,minute:b},Ar={hour:b,minute:b,second:b},Tr={hour:b,minute:b,second:b,timeZoneName:Ye},Nr={hour:b,minute:b,second:b,timeZoneName:$e},br={hour:b,minute:b,hourCycle:"h23"},Ir={hour:b,minute:b,second:b,hourCycle:"h23"},kr={hour:b,minute:b,second:b,hourCycle:"h23",timeZoneName:Ye},Er={hour:b,minute:b,second:b,hourCycle:"h23",timeZoneName:$e},Mr={year:b,month:b,day:b,hour:b,minute:b},jr={year:b,month:b,day:b,hour:b,minute:b,second:b},Or={year:b,month:Ye,day:b,hour:b,minute:b},Dr={year:b,month:Ye,day:b,hour:b,minute:b,second:b},Oi={year:b,month:Ye,day:b,weekday:Ye,hour:b,minute:b},Cr={year:b,month:$e,day:b,hour:b,minute:b,timeZoneName:Ye},Rr={year:b,month:$e,day:b,hour:b,minute:b,second:b,timeZoneName:Ye},Ur={year:b,month:$e,day:b,weekday:$e,hour:b,minute:b,timeZoneName:$e},Lr={year:b,month:$e,day:b,weekday:$e,hour:b,minute:b,second:b,timeZoneName:$e};class zt{get type(){throw new rt}get name(){throw new rt}get ianaName(){return this.name}get isUniversal(){throw new rt}offsetName(e,s){throw new rt}formatOffset(e,s){throw new rt}offset(e){throw new rt}equals(e){throw new rt}get isValid(){throw new rt}}let Is=null;class hs extends zt{static get instance(){return Is===null&&(Is=new hs),Is}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Gr(e,s,n)}formatOffset(e,s){return Bt(this.offset(e),s)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}}const $s=new Map;function Di(t){let e=$s.get(t);return e===void 0&&(e=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),$s.set(t,e)),e}const Ci={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function Ri(t,e){const s=t.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(s),[,r,a,o,l,c,u,f]=n;return[o,r,a,l,c,u,f]}function Ui(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:a,value:o}=s[r],l=Ci[a];a==="era"?n[l]=o:F(l)||(n[l]=parseInt(o,10))}return n}const ks=new Map;class et extends zt{static create(e){let s=ks.get(e);return s===void 0&&ks.set(e,s=new et(e)),s}static resetCache(){ks.clear(),$s.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch{return!1}}constructor(e){super(),this.zoneName=e,this.valid=et.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Gr(e,s,n,this.name)}formatOffset(e,s){return Bt(this.offset(e),s)}offset(e){if(!this.valid)return NaN;const s=new Date(e);if(isNaN(s))return NaN;const n=Di(this.name);let[r,a,o,l,c,u,f]=n.formatToParts?Ui(n,s):Ri(n,s);l==="BC"&&(r=-Math.abs(r)+1);const p=ps({year:r,month:a,day:o,hour:c===24?0:c,minute:u,second:f,millisecond:0});let g=+s;const v=g%1e3;return g-=v>=0?v:1e3+v,(p-g)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let bn={};function Li(t,e={}){const s=JSON.stringify([t,e]);let n=bn[s];return n||(n=new Intl.ListFormat(t,e),bn[s]=n),n}const Ps=new Map;function Ws(t,e={}){const s=JSON.stringify([t,e]);let n=Ps.get(s);return n===void 0&&(n=new Intl.DateTimeFormat(t,e),Ps.set(s,n)),n}const Bs=new Map;function Fi(t,e={}){const s=JSON.stringify([t,e]);let n=Bs.get(s);return n===void 0&&(n=new Intl.NumberFormat(t,e),Bs.set(s,n)),n}const Vs=new Map;function $i(t,e={}){const{base:s,...n}=e,r=JSON.stringify([t,n]);let a=Vs.get(r);return a===void 0&&(a=new Intl.RelativeTimeFormat(t,e),Vs.set(r,a)),a}let $t=null;function Pi(){return $t||($t=new Intl.DateTimeFormat().resolvedOptions().locale,$t)}const Zs=new Map;function Fr(t){let e=Zs.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),Zs.set(t,e)),e}const zs=new Map;function Wi(t){let e=zs.get(t);if(!e){const s=new Intl.Locale(t);e="getWeekInfo"in s?s.getWeekInfo():s.weekInfo,"minimalDays"in e||(e={...$r,...e}),zs.set(t,e)}return e}function Bi(t){const e=t.indexOf("-x-");e!==-1&&(t=t.substring(0,e));const s=t.indexOf("-u-");if(s===-1)return[t];{let n,r;try{n=Ws(t).resolvedOptions(),r=t}catch{const c=t.substring(0,s);n=Ws(c).resolvedOptions(),r=c}const{numberingSystem:a,calendar:o}=n;return[r,a,o]}}function Vi(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function Zi(t){const e=[];for(let s=1;s<=12;s++){const n=L.utc(2009,s,1);e.push(t(n))}return e}function zi(t){const e=[];for(let s=1;s<=7;s++){const n=L.utc(2016,11,13+s);e.push(t(n))}return e}function Xt(t,e,s,n){const r=t.listingMode();return r==="error"?null:r==="en"?s(e):n(e)}function Hi(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||Fr(t.locale).numberingSystem==="latn"}class qi{constructor(e,s,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;const{padTo:r,floor:a,...o}=n;if(!s||Object.keys(o).length>0){const l={useGrouping:!1,...n};n.padTo>0&&(l.minimumIntegerDigits=n.padTo),this.inf=Fi(e,l)}}format(e){if(this.inf){const s=this.floor?Math.floor(e):e;return this.inf.format(s)}else{const s=this.floor?Math.floor(e):on(e,3);return ve(s,this.padTo)}}}class Gi{constructor(e,s,n){this.opts=n,this.originalZone=void 0;let r;if(this.opts.timeZone)this.dt=e;else if(e.zone.type==="fixed"){const o=-1*(e.offset/60),l=o>=0?`Etc/GMT+${o}`:`Etc/GMT${o}`;e.offset!==0&&et.create(l).valid?(r=l,this.dt=e):(r="UTC",this.dt=e.offset===0?e:e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type==="system"?this.dt=e:e.zone.type==="iana"?(this.dt=e,r=e.zone.name):(r="UTC",this.dt=e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone);const a={...this.opts};a.timeZone=a.timeZone||r,this.dtf=Ws(s,a)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(s=>{if(s.type==="timeZoneName"){const n=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...s,value:n}}else return s}):e}resolvedOptions(){return this.dtf.resolvedOptions()}}class Yi{constructor(e,s,n){this.opts={style:"long",...n},!s&&Hr()&&(this.rtf=$i(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):go(s,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,s){return this.rtf?this.rtf.formatToParts(e,s):[]}}const $r={firstDay:1,minimalDays:4,weekend:[6,7]};class ne{static fromOpts(e){return ne.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,s,n,r,a=!1){const o=e||xe.defaultLocale,l=o||(a?"en-US":Pi()),c=s||xe.defaultNumberingSystem,u=n||xe.defaultOutputCalendar,f=qs(r)||xe.defaultWeekSettings;return new ne(l,c,u,f,o)}static resetCache(){$t=null,Ps.clear(),Bs.clear(),Vs.clear(),Zs.clear(),zs.clear()}static fromObject({locale:e,numberingSystem:s,outputCalendar:n,weekSettings:r}={}){return ne.create(e,s,n,r)}constructor(e,s,n,r,a){const[o,l,c]=Bi(e);this.locale=o,this.numberingSystem=s||l||null,this.outputCalendar=n||c||null,this.weekSettings=r,this.intl=Vi(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=a,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=Hi(this)),this.fastNumbersCached}listingMode(){const e=this.isEnglish(),s=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return e&&s?"en":"intl"}clone(e){return!e||Object.getOwnPropertyNames(e).length===0?this:ne.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,qs(e.weekSettings)||this.weekSettings,e.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,s=!1){return Xt(this,e,Jr,()=>{const n=this.intl==="ja"||this.intl.startsWith("ja-");s&=!n;const r=s?{month:e,day:"numeric"}:{month:e},a=s?"format":"standalone";if(!this.monthsCache[a][e]){const o=n?l=>this.dtFormatter(l,r).format():l=>this.extract(l,r,"month");this.monthsCache[a][e]=Zi(o)}return this.monthsCache[a][e]})}weekdays(e,s=!1){return Xt(this,e,Xr,()=>{const n=s?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},r=s?"format":"standalone";return this.weekdaysCache[r][e]||(this.weekdaysCache[r][e]=zi(a=>this.extract(a,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return Xt(this,void 0,()=>ea,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[L.utc(2016,11,13,9),L.utc(2016,11,13,19)].map(s=>this.extract(s,e,"dayperiod"))}return this.meridiemCache})}eras(e){return Xt(this,e,ta,()=>{const s={era:e};return this.eraCache[e]||(this.eraCache[e]=[L.utc(-40,1,1),L.utc(2017,1,1)].map(n=>this.extract(n,s,"era"))),this.eraCache[e]})}extract(e,s,n){const r=this.dtFormatter(e,s),a=r.formatToParts(),o=a.find(l=>l.type.toLowerCase()===n);return o?o.value:null}numberFormatter(e={}){return new qi(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new Gi(e,this.intl,s)}relFormatter(e={}){return new Yi(this.intl,this.isEnglish(),e)}listFormatter(e={}){return Li(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||Fr(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:qr()?Wi(this.locale):$r}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let Es=null;class Re extends zt{static get utcInstance(){return Es===null&&(Es=new Re(0)),Es}static instance(e){return e===0?Re.utcInstance:new Re(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new Re(gs(s[1],s[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Bt(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Bt(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,s){return Bt(this.fixed,s)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type==="fixed"&&e.fixed===this.fixed}get isValid(){return!0}}class _i extends zt{constructor(e){super(),this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function lt(t,e){if(F(t)||t===null)return e;if(t instanceof zt)return t;if(to(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?hs.instance:s==="utc"||s==="gmt"?Re.utcInstance:Re.parseSpecifier(s)||et.create(t)}else return ct(t)?Re.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new _i(t)}const sn={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},In={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},Ji=sn.hanidec.replace(/[\[|\]]/g,"").split("");function Ki(t){let e=parseInt(t,10);if(isNaN(e)){e="";for(let s=0;s<t.length;s++){const n=t.charCodeAt(s);if(t[s].search(sn.hanidec)!==-1)e+=Ji.indexOf(t[s]);else for(const r in In){const[a,o]=In[r];n>=a&&n<=o&&(e+=n-a)}}return parseInt(e,10)}else return e}const Hs=new Map;function Qi(){Hs.clear()}function He({numberingSystem:t},e=""){const s=t||"latn";let n=Hs.get(s);n===void 0&&(n=new Map,Hs.set(s,n));let r=n.get(e);return r===void 0&&(r=new RegExp(`${sn[s]}${e}`),n.set(e,r)),r}let kn=()=>Date.now(),En="system",Mn=null,jn=null,On=null,Dn=60,Cn,Rn=null;class xe{static get now(){return kn}static set now(e){kn=e}static set defaultZone(e){En=e}static get defaultZone(){return lt(En,hs.instance)}static get defaultLocale(){return Mn}static set defaultLocale(e){Mn=e}static get defaultNumberingSystem(){return jn}static set defaultNumberingSystem(e){jn=e}static get defaultOutputCalendar(){return On}static set defaultOutputCalendar(e){On=e}static get defaultWeekSettings(){return Rn}static set defaultWeekSettings(e){Rn=qs(e)}static get twoDigitCutoffYear(){return Dn}static set twoDigitCutoffYear(e){Dn=e%100}static get throwOnInvalid(){return Cn}static set throwOnInvalid(e){Cn=e}static resetCaches(){ne.resetCache(),et.resetCache(),L.resetCache(),Qi()}}class Ge{constructor(e,s){this.reason=e,this.explanation=s}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const Pr=[0,31,59,90,120,151,181,212,243,273,304,334],Wr=[0,31,60,91,121,152,182,213,244,274,305,335];function Ve(t,e){return new Ge("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function nn(t,e,s){const n=new Date(Date.UTC(t,e-1,s));t<100&&t>=0&&n.setUTCFullYear(n.getUTCFullYear()-1900);const r=n.getUTCDay();return r===0?7:r}function Br(t,e,s){return s+(Ht(t)?Wr:Pr)[e-1]}function Vr(t,e){const s=Ht(t)?Wr:Pr,n=s.findIndex(a=>a<e),r=e-s[n];return{month:n+1,day:r}}function rn(t,e){return(t-e+7)%7+1}function us(t,e=4,s=1){const{year:n,month:r,day:a}=t,o=Br(n,r,a),l=rn(nn(n,r,a),s);let c=Math.floor((o-l+14-e)/7),u;return c<1?(u=n-1,c=Vt(u,e,s)):c>Vt(n,e,s)?(u=n+1,c=1):u=n,{weekYear:u,weekNumber:c,weekday:l,...Ss(t)}}function Un(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:a}=t,o=rn(nn(n,1,e),s),l=It(n);let c=r*7+a-o-7+e,u;c<1?(u=n-1,c+=It(u)):c>l?(u=n+1,c-=It(n)):u=n;const{month:f,day:m}=Vr(u,c);return{year:u,month:f,day:m,...Ss(t)}}function Ms(t){const{year:e,month:s,day:n}=t,r=Br(e,s,n);return{year:e,ordinal:r,...Ss(t)}}function Ln(t){const{year:e,ordinal:s}=t,{month:n,day:r}=Vr(e,s);return{year:e,month:n,day:r,...Ss(t)}}function Fn(t,e){if(!F(t.localWeekday)||!F(t.localWeekNumber)||!F(t.localWeekYear)){if(!F(t.weekday)||!F(t.weekNumber)||!F(t.weekYear))throw new bt("Cannot mix locale-based week fields with ISO-based week fields");return F(t.localWeekday)||(t.weekday=t.localWeekday),F(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),F(t.localWeekYear)||(t.weekYear=t.localWeekYear),delete t.localWeekday,delete t.localWeekNumber,delete t.localWeekYear,{minDaysInFirstWeek:e.getMinDaysInFirstWeek(),startOfWeek:e.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function Xi(t,e=4,s=1){const n=ys(t.weekYear),r=Ze(t.weekNumber,1,Vt(t.weekYear,e,s)),a=Ze(t.weekday,1,7);return n?r?a?!1:Ve("weekday",t.weekday):Ve("week",t.weekNumber):Ve("weekYear",t.weekYear)}function eo(t){const e=ys(t.year),s=Ze(t.ordinal,1,It(t.year));return e?s?!1:Ve("ordinal",t.ordinal):Ve("year",t.year)}function Zr(t){const e=ys(t.year),s=Ze(t.month,1,12),n=Ze(t.day,1,ds(t.year,t.month));return e?s?n?!1:Ve("day",t.day):Ve("month",t.month):Ve("year",t.year)}function zr(t){const{hour:e,minute:s,second:n,millisecond:r}=t,a=Ze(e,0,23)||e===24&&s===0&&n===0&&r===0,o=Ze(s,0,59),l=Ze(n,0,59),c=Ze(r,0,999);return a?o?l?c?!1:Ve("millisecond",r):Ve("second",n):Ve("minute",s):Ve("hour",e)}function F(t){return typeof t>"u"}function ct(t){return typeof t=="number"}function ys(t){return typeof t=="number"&&t%1===0}function to(t){return typeof t=="string"}function so(t){return Object.prototype.toString.call(t)==="[object Date]"}function Hr(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function qr(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function no(t){return Array.isArray(t)?t:[t]}function $n(t,e,s){if(t.length!==0)return t.reduce((n,r)=>{const a=[e(r),r];return n&&s(n[0],a[0])===n[0]?n:a},null)[1]}function ro(t,e){return e.reduce((s,n)=>(s[n]=t[n],s),{})}function Et(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function qs(t){if(t==null)return null;if(typeof t!="object")throw new Me("Week settings must be an object");if(!Ze(t.firstDay,1,7)||!Ze(t.minimalDays,1,7)||!Array.isArray(t.weekend)||t.weekend.some(e=>!Ze(e,1,7)))throw new Me("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function Ze(t,e,s){return ys(t)&&t>=e&&t<=s}function ao(t,e){return t-e*Math.floor(t/e)}function ve(t,e=2){const s=t<0;let n;return s?n="-"+(""+-t).padStart(e,"0"):n=(""+t).padStart(e,"0"),n}function it(t){if(!(F(t)||t===null||t===""))return parseInt(t,10)}function dt(t){if(!(F(t)||t===null||t===""))return parseFloat(t)}function an(t){if(!(F(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function on(t,e,s="round"){const n=10**e;switch(s){case"expand":return t>0?Math.ceil(t*n)/n:Math.floor(t*n)/n;case"trunc":return Math.trunc(t*n)/n;case"round":return Math.round(t*n)/n;case"floor":return Math.floor(t*n)/n;case"ceil":return Math.ceil(t*n)/n;default:throw new RangeError(`Value rounding ${s} is out of range`)}}function Ht(t){return t%4===0&&(t%100!==0||t%400===0)}function It(t){return Ht(t)?366:365}function ds(t,e){const s=ao(e-1,12)+1,n=t+(e-s)/12;return s===2?Ht(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][s-1]}function ps(t){let e=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second,t.millisecond);return t.year<100&&t.year>=0&&(e=new Date(e),e.setUTCFullYear(t.year,t.month-1,t.day)),+e}function Pn(t,e,s){return-rn(nn(t,1,e),s)+e-1}function Vt(t,e=4,s=1){const n=Pn(t,e,s),r=Pn(t+1,e,s);return(It(t)-n+r)/7}function Gs(t){return t>99?t:t>xe.twoDigitCutoffYear?1900+t:2e3+t}function Gr(t,e,s,n=null){const r=new Date(t),a={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};n&&(a.timeZone=n);const o={timeZoneName:e,...a},l=new Intl.DateTimeFormat(s,o).formatToParts(r).find(c=>c.type.toLowerCase()==="timezonename");return l?l.value:null}function gs(t,e){let s=parseInt(t,10);Number.isNaN(s)&&(s=0);const n=parseInt(e,10)||0,r=s<0||Object.is(s,-0)?-n:n;return s*60+r}function Yr(t){const e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new Me(`Invalid unit value ${t}`);return e}function ms(t,e){const s={};for(const n in t)if(Et(t,n)){const r=t[n];if(r==null)continue;s[e(n)]=Yr(r)}return s}function Bt(t,e){const s=Math.trunc(Math.abs(t/60)),n=Math.trunc(Math.abs(t%60)),r=t>=0?"+":"-";switch(e){case"short":return`${r}${ve(s,2)}:${ve(n,2)}`;case"narrow":return`${r}${s}${n>0?`:${n}`:""}`;case"techie":return`${r}${ve(s,2)}${ve(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function Ss(t){return ro(t,["hour","minute","second","millisecond"])}const io=["January","February","March","April","May","June","July","August","September","October","November","December"],_r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],oo=["J","F","M","A","M","J","J","A","S","O","N","D"];function Jr(t){switch(t){case"narrow":return[...oo];case"short":return[..._r];case"long":return[...io];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const Kr=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Qr=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],lo=["M","T","W","T","F","S","S"];function Xr(t){switch(t){case"narrow":return[...lo];case"short":return[...Qr];case"long":return[...Kr];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const ea=["AM","PM"],co=["Before Christ","Anno Domini"],uo=["BC","AD"],mo=["B","A"];function ta(t){switch(t){case"narrow":return[...mo];case"short":return[...uo];case"long":return[...co];default:return null}}function fo(t){return ea[t.hour<12?0:1]}function ho(t,e){return Xr(e)[t.weekday-1]}function yo(t,e){return Jr(e)[t.month-1]}function po(t,e){return ta(e)[t.year<0?0:1]}function go(t,e,s="always",n=!1){const r={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},a=["hours","minutes","seconds"].indexOf(t)===-1;if(s==="auto"&&a){const m=t==="days";switch(e){case 1:return m?"tomorrow":`next ${r[t][0]}`;case-1:return m?"yesterday":`last ${r[t][0]}`;case 0:return m?"today":`this ${r[t][0]}`}}const o=Object.is(e,-0)||e<0,l=Math.abs(e),c=l===1,u=r[t],f=n?c?u[1]:u[2]||u[1]:c?r[t][0]:t;return o?`${l} ${f} ago`:`in ${l} ${f}`}function Wn(t,e){let s="";for(const n of t)n.literal?s+=n.val:s+=e(n.val);return s}const So={D:cs,DD:Sr,DDD:xr,DDDD:vr,t:wr,tt:Ar,ttt:Tr,tttt:Nr,T:br,TT:Ir,TTT:kr,TTTT:Er,f:Mr,ff:Or,fff:Cr,ffff:Ur,F:jr,FF:Dr,FFF:Rr,FFFF:Lr};class je{static create(e,s={}){return new je(e,s)}static parseFormat(e){let s=null,n="",r=!1;const a=[];for(let o=0;o<e.length;o++){const l=e.charAt(o);l==="'"?((n.length>0||r)&&a.push({literal:r||/^\s+$/.test(n),val:n===""?"'":n}),s=null,n="",r=!r):r||l===s?n+=l:(n.length>0&&a.push({literal:/^\s+$/.test(n),val:n}),n=l,s=l)}return n.length>0&&a.push({literal:r||/^\s+$/.test(n),val:n}),a}static macroTokenToFormatOpts(e){return So[e]}constructor(e,s){this.opts=s,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,s){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...s}).format()}dtFormatter(e,s={}){return this.loc.dtFormatter(e,{...this.opts,...s})}formatDateTime(e,s){return this.dtFormatter(e,s).format()}formatDateTimeParts(e,s){return this.dtFormatter(e,s).formatToParts()}formatInterval(e,s){return this.dtFormatter(e.start,s).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,s){return this.dtFormatter(e,s).resolvedOptions()}num(e,s=0,n=void 0){if(this.opts.forceSimple)return ve(e,s);const r={...this.opts};return s>0&&(r.padTo=s),n&&(r.signDisplay=n),this.loc.numberFormatter(r).format(e)}formatDateTimeFromString(e,s){const n=this.loc.listingMode()==="en",r=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",a=(g,v)=>this.loc.extract(e,g,v),o=g=>e.isOffsetFixed&&e.offset===0&&g.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,g.format):"",l=()=>n?fo(e):a({hour:"numeric",hourCycle:"h12"},"dayperiod"),c=(g,v)=>n?yo(e,g):a(v?{month:g}:{month:g,day:"numeric"},"month"),u=(g,v)=>n?ho(e,g):a(v?{weekday:g}:{weekday:g,month:"long",day:"numeric"},"weekday"),f=g=>{const v=je.macroTokenToFormatOpts(g);return v?this.formatWithSystemDefault(e,v):g},m=g=>n?po(e,g):a({era:g},"era"),p=g=>{switch(g){case"S":return this.num(e.millisecond);case"u":case"SSS":return this.num(e.millisecond,3);case"s":return this.num(e.second);case"ss":return this.num(e.second,2);case"uu":return this.num(Math.floor(e.millisecond/10),2);case"uuu":return this.num(Math.floor(e.millisecond/100));case"m":return this.num(e.minute);case"mm":return this.num(e.minute,2);case"h":return this.num(e.hour%12===0?12:e.hour%12);case"hh":return this.num(e.hour%12===0?12:e.hour%12,2);case"H":return this.num(e.hour);case"HH":return this.num(e.hour,2);case"Z":return o({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return o({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return o({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return l();case"d":return r?a({day:"numeric"},"day"):this.num(e.day);case"dd":return r?a({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return u("short",!0);case"cccc":return u("long",!0);case"ccccc":return u("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return u("short",!1);case"EEEE":return u("long",!1);case"EEEEE":return u("narrow",!1);case"L":return r?a({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?a({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return c("short",!0);case"LLLL":return c("long",!0);case"LLLLL":return c("narrow",!0);case"M":return r?a({month:"numeric"},"month"):this.num(e.month);case"MM":return r?a({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return c("short",!1);case"MMMM":return c("long",!1);case"MMMMM":return c("narrow",!1);case"y":return r?a({year:"numeric"},"year"):this.num(e.year);case"yy":return r?a({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?a({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?a({year:"numeric"},"year"):this.num(e.year,6);case"G":return m("short");case"GG":return m("long");case"GGGGG":return m("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return f(g)}};return Wn(je.parseFormat(s),p)}formatDurationFromString(e,s){const n=this.opts.signMode==="negativeLargestOnly"?-1:1,r=f=>{switch(f[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},a=(f,m)=>p=>{const g=r(p);if(g){const v=m.isNegativeDuration&&g!==m.largestUnit?n:1;let I;return this.opts.signMode==="negativeLargestOnly"&&g!==m.largestUnit?I="never":this.opts.signMode==="all"?I="always":I="auto",this.num(f.get(g)*v,p.length,I)}else return p},o=je.parseFormat(s),l=o.reduce((f,{literal:m,val:p})=>m?f:f.concat(p),[]),c=e.shiftTo(...l.map(r).filter(f=>f)),u={isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]};return Wn(o,a(c,u))}}const sa=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Mt(...t){const e=t.reduce((s,n)=>s+n.source,"");return RegExp(`^${e}$`)}function jt(...t){return e=>t.reduce(([s,n,r],a)=>{const[o,l,c]=a(e,r);return[{...s,...o},l||n,c]},[{},null,1]).slice(0,2)}function Ot(t,...e){if(t==null)return[null,null];for(const[s,n]of e){const r=s.exec(t);if(r)return n(r)}return[null,null]}function na(...t){return(e,s)=>{const n={};let r;for(r=0;r<t.length;r++)n[t[r]]=it(e[s+r]);return[n,null,s+r]}}const ra=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,xo=`(?:${ra.source}?(?:\\[(${sa.source})\\])?)?`,ln=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,aa=RegExp(`${ln.source}${xo}`),cn=RegExp(`(?:[Tt]${aa.source})?`),vo=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,wo=/(\d{4})-?W(\d\d)(?:-?(\d))?/,Ao=/(\d{4})-?(\d{3})/,To=na("weekYear","weekNumber","weekDay"),No=na("year","ordinal"),bo=/(\d{4})-(\d\d)-(\d\d)/,ia=RegExp(`${ln.source} ?(?:${ra.source}|(${sa.source}))?`),Io=RegExp(`(?: ${ia.source})?`);function kt(t,e,s){const n=t[e];return F(n)?s:it(n)}function ko(t,e){return[{year:kt(t,e),month:kt(t,e+1,1),day:kt(t,e+2,1)},null,e+3]}function Dt(t,e){return[{hours:kt(t,e,0),minutes:kt(t,e+1,0),seconds:kt(t,e+2,0),milliseconds:an(t[e+3])},null,e+4]}function qt(t,e){const s=!t[e]&&!t[e+1],n=gs(t[e+1],t[e+2]),r=s?null:Re.instance(n);return[{},r,e+3]}function Gt(t,e){const s=t[e]?et.create(t[e]):null;return[{},s,e+1]}const Eo=RegExp(`^T?${ln.source}$`),Mo=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function jo(t){const[e,s,n,r,a,o,l,c,u]=t,f=e[0]==="-",m=c&&c[0]==="-",p=(g,v=!1)=>g!==void 0&&(v||g&&f)?-g:g;return[{years:p(dt(s)),months:p(dt(n)),weeks:p(dt(r)),days:p(dt(a)),hours:p(dt(o)),minutes:p(dt(l)),seconds:p(dt(c),c==="-0"),milliseconds:p(an(u),m)}]}const Oo={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function un(t,e,s,n,r,a,o){const l={year:e.length===2?Gs(it(e)):it(e),month:_r.indexOf(s)+1,day:it(n),hour:it(r),minute:it(a)};return o&&(l.second=it(o)),t&&(l.weekday=t.length>3?Kr.indexOf(t)+1:Qr.indexOf(t)+1),l}const Do=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function Co(t){const[,e,s,n,r,a,o,l,c,u,f,m]=t,p=un(e,r,n,s,a,o,l);let g;return c?g=Oo[c]:u?g=0:g=gs(f,m),[p,new Re(g)]}function Ro(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const Uo=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,Lo=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,Fo=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function Bn(t){const[,e,s,n,r,a,o,l]=t;return[un(e,r,n,s,a,o,l),Re.utcInstance]}function $o(t){const[,e,s,n,r,a,o,l]=t;return[un(e,l,s,n,r,a,o),Re.utcInstance]}const Po=Mt(vo,cn),Wo=Mt(wo,cn),Bo=Mt(Ao,cn),Vo=Mt(aa),oa=jt(ko,Dt,qt,Gt),Zo=jt(To,Dt,qt,Gt),zo=jt(No,Dt,qt,Gt),Ho=jt(Dt,qt,Gt);function qo(t){return Ot(t,[Po,oa],[Wo,Zo],[Bo,zo],[Vo,Ho])}function Go(t){return Ot(Ro(t),[Do,Co])}function Yo(t){return Ot(t,[Uo,Bn],[Lo,Bn],[Fo,$o])}function _o(t){return Ot(t,[Mo,jo])}const Jo=jt(Dt);function Ko(t){return Ot(t,[Eo,Jo])}const Qo=Mt(bo,Io),Xo=Mt(ia),el=jt(Dt,qt,Gt);function tl(t){return Ot(t,[Qo,oa],[Xo,el])}const Vn="Invalid Duration",la={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},sl={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...la},Be=146097/400,wt=146097/4800,nl={years:{quarters:4,months:12,weeks:Be/7,days:Be,hours:Be*24,minutes:Be*24*60,seconds:Be*24*60*60,milliseconds:Be*24*60*60*1e3},quarters:{months:3,weeks:Be/28,days:Be/4,hours:Be*24/4,minutes:Be*24*60/4,seconds:Be*24*60*60/4,milliseconds:Be*24*60*60*1e3/4},months:{weeks:wt/7,days:wt,hours:wt*24,minutes:wt*24*60,seconds:wt*24*60*60,milliseconds:wt*24*60*60*1e3},...la},ft=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],rl=ft.slice(0).reverse();function Qe(t,e,s=!1){const n={values:s?e.values:{...t.values,...e.values||{}},loc:t.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||t.conversionAccuracy,matrix:e.matrix||t.matrix};return new Q(n)}function ca(t,e){let s=e.milliseconds??0;for(const n of rl.slice(1))e[n]&&(s+=e[n]*t[n].milliseconds);return s}function Zn(t,e){const s=ca(t,e)<0?-1:1;ft.reduceRight((n,r)=>{if(F(e[r]))return n;if(n){const a=e[n]*s,o=t[r][n],l=Math.floor(a/o);e[r]+=l*s,e[n]-=l*o*s}return r},null),ft.reduce((n,r)=>{if(F(e[r]))return n;if(n){const a=e[n]%1;e[n]-=a,e[r]+=a*t[n][r]}return r},null)}function zn(t){const e={};for(const[s,n]of Object.entries(t))n!==0&&(e[s]=n);return e}class Q{constructor(e){const s=e.conversionAccuracy==="longterm"||!1;let n=s?nl:sl;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||ne.create(),this.conversionAccuracy=s?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=n,this.isLuxonDuration=!0}static fromMillis(e,s){return Q.fromObject({milliseconds:e},s)}static fromObject(e,s={}){if(e==null||typeof e!="object")throw new Me(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new Q({values:ms(e,Q.normalizeUnit),loc:ne.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(ct(e))return Q.fromMillis(e);if(Q.isDuration(e))return e;if(typeof e=="object")return Q.fromObject(e);throw new Me(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,s){const[n]=_o(e);return n?Q.fromObject(n,s):Q.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,s){const[n]=Ko(e);return n?Q.fromObject(n,s):Q.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,s=null){if(!e)throw new Me("need to specify a reason the Duration is invalid");const n=e instanceof Ge?e:new Ge(e,s);if(xe.throwOnInvalid)throw new Mi(n);return new Q({invalid:n})}static normalizeUnit(e){const s={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[e&&e.toLowerCase()];if(!s)throw new gr(e);return s}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,s={}){const n={...s,floor:s.round!==!1&&s.floor!==!1};return this.isValid?je.create(this.loc,n).formatDurationFromString(this,e):Vn}toHuman(e={}){if(!this.isValid)return Vn;const s=e.showZeros!==!1,n=ft.map(r=>{const a=this.values[r];return F(a)||a===0&&!s?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:r.slice(0,-1)}).format(a)}).filter(r=>r);return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(n)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e="P";return this.years!==0&&(e+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+"M"),this.weeks!==0&&(e+=this.weeks+"W"),this.days!==0&&(e+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+="T"),this.hours!==0&&(e+=this.hours+"H"),this.minutes!==0&&(e+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(e+=on(this.seconds+this.milliseconds/1e3,3)+"S"),e==="P"&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;const s=this.toMillis();return s<0||s>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e,includeOffset:!1},L.fromMillis(s,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?ca(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const s=Q.fromDurationLike(e),n={};for(const r of ft)(Et(s.values,r)||Et(this.values,r))&&(n[r]=s.get(r)+this.get(r));return Qe(this,{values:n},!0)}minus(e){if(!this.isValid)return this;const s=Q.fromDurationLike(e);return this.plus(s.negate())}mapUnits(e){if(!this.isValid)return this;const s={};for(const n of Object.keys(this.values))s[n]=Yr(e(this.values[n],n));return Qe(this,{values:s},!0)}get(e){return this[Q.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const s={...this.values,...ms(e,Q.normalizeUnit)};return Qe(this,{values:s})}reconfigure({locale:e,numberingSystem:s,conversionAccuracy:n,matrix:r}={}){const o={loc:this.loc.clone({locale:e,numberingSystem:s}),matrix:r,conversionAccuracy:n};return Qe(this,o)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return Zn(this.matrix,e),Qe(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=zn(this.normalize().shiftToAll().toObject());return Qe(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(o=>Q.normalizeUnit(o));const s={},n={},r=this.toObject();let a;for(const o of ft)if(e.indexOf(o)>=0){a=o;let l=0;for(const u in n)l+=this.matrix[u][o]*n[u],n[u]=0;ct(r[o])&&(l+=r[o]);const c=Math.trunc(l);s[o]=c,n[o]=(l*1e3-c*1e3)/1e3}else ct(r[o])&&(n[o]=r[o]);for(const o in n)n[o]!==0&&(s[a]+=o===a?n[o]:n[o]/this.matrix[a][o]);return Zn(this.matrix,s),Qe(this,{values:s},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const e={};for(const s of Object.keys(this.values))e[s]=this.values[s]===0?0:-this.values[s];return Qe(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=zn(this.values);return Qe(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function s(n,r){return n===void 0||n===0?r===void 0||r===0:n===r}for(const n of ft)if(!s(this.values[n],e.values[n]))return!1;return!0}}const At="Invalid Interval";function al(t,e){return!t||!t.isValid?Se.invalid("missing or invalid start"):!e||!e.isValid?Se.invalid("missing or invalid end"):e<t?Se.invalid("end before start",`The end of an interval must be after its start, but you had start=${t.toISO()} and end=${e.toISO()}`):null}class Se{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,s=null){if(!e)throw new Me("need to specify a reason the Interval is invalid");const n=e instanceof Ge?e:new Ge(e,s);if(xe.throwOnInvalid)throw new Ei(n);return new Se({invalid:n})}static fromDateTimes(e,s){const n=Ft(e),r=Ft(s),a=al(n,r);return a??new Se({start:n,end:r})}static after(e,s){const n=Q.fromDurationLike(s),r=Ft(e);return Se.fromDateTimes(r,r.plus(n))}static before(e,s){const n=Q.fromDurationLike(s),r=Ft(e);return Se.fromDateTimes(r.minus(n),r)}static fromISO(e,s){const[n,r]=(e||"").split("/",2);if(n&&r){let a,o;try{a=L.fromISO(n,s),o=a.isValid}catch{o=!1}let l,c;try{l=L.fromISO(r,s),c=l.isValid}catch{c=!1}if(o&&c)return Se.fromDateTimes(a,l);if(o){const u=Q.fromISO(r,s);if(u.isValid)return Se.after(a,u)}else if(c){const u=Q.fromISO(n,s);if(u.isValid)return Se.before(l,u)}}return Se.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(e).get(e):NaN}count(e="milliseconds",s){if(!this.isValid)return NaN;const n=this.start.startOf(e,s);let r;return s?.useLocaleWeeks?r=this.end.reconfigure({locale:n.locale}):r=this.end,r=r.startOf(e,s),Math.floor(r.diff(n,e).get(e))+(r.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:e,end:s}={}){return this.isValid?Se.fromDateTimes(e||this.s,s||this.e):this}splitAt(...e){if(!this.isValid)return[];const s=e.map(Ft).filter(o=>this.contains(o)).sort((o,l)=>o.toMillis()-l.toMillis()),n=[];let{s:r}=this,a=0;for(;r<this.e;){const o=s[a]||this.e,l=+o>+this.e?this.e:o;n.push(Se.fromDateTimes(r,l)),r=l,a+=1}return n}splitBy(e){const s=Q.fromDurationLike(e);if(!this.isValid||!s.isValid||s.as("milliseconds")===0)return[];let{s:n}=this,r=1,a;const o=[];for(;n<this.e;){const l=this.start.plus(s.mapUnits(c=>c*r));a=+l>+this.e?this.e:l,o.push(Se.fromDateTimes(n,a)),n=a,r+=1}return o}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;const s=this.s>e.s?this.s:e.s,n=this.e<e.e?this.e:e.e;return s>=n?null:Se.fromDateTimes(s,n)}union(e){if(!this.isValid)return this;const s=this.s<e.s?this.s:e.s,n=this.e>e.e?this.e:e.e;return Se.fromDateTimes(s,n)}static merge(e){const[s,n]=e.sort((r,a)=>r.s-a.s).reduce(([r,a],o)=>a?a.overlaps(o)||a.abutsStart(o)?[r,a.union(o)]:[r.concat([a]),o]:[r,o],[[],null]);return n&&s.push(n),s}static xor(e){let s=null,n=0;const r=[],a=e.map(c=>[{time:c.s,type:"s"},{time:c.e,type:"e"}]),o=Array.prototype.concat(...a),l=o.sort((c,u)=>c.time-u.time);for(const c of l)n+=c.type==="s"?1:-1,n===1?s=c.time:(s&&+s!=+c.time&&r.push(Se.fromDateTimes(s,c.time)),s=null);return Se.merge(r)}difference(...e){return Se.xor([this].concat(e)).map(s=>this.intersection(s)).filter(s=>s&&!s.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:At}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=cs,s={}){return this.isValid?je.create(this.s.loc.clone(s),e).formatInterval(this):At}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:At}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:At}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:At}toFormat(e,{separator:s=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${s}${this.e.toFormat(e)}`:At}toDuration(e,s){return this.isValid?this.e.diff(this.s,e,s):Q.invalid(this.invalidReason)}mapEndpoints(e){return Se.fromDateTimes(e(this.s),e(this.e))}}class es{static hasDST(e=xe.defaultZone){const s=L.now().setZone(e).set({month:12});return!e.isUniversal&&s.offset!==s.set({month:6}).offset}static isValidIANAZone(e){return et.isValidZone(e)}static normalizeZone(e){return lt(e,xe.defaultZone)}static getStartOfWeek({locale:e=null,locObj:s=null}={}){return(s||ne.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:s=null}={}){return(s||ne.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:s=null}={}){return(s||ne.create(e)).getWeekendDays().slice()}static months(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||ne.create(s,n,a)).months(e)}static monthsFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||ne.create(s,n,a)).months(e,!0)}static weekdays(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||ne.create(s,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||ne.create(s,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return ne.create(e).meridiems()}static eras(e="short",{locale:s=null}={}){return ne.create(s,null,"gregory").eras(e)}static features(){return{relative:Hr(),localeWeek:qr()}}}function Hn(t,e){const s=r=>r.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),n=s(e)-s(t);return Math.floor(Q.fromMillis(n).as("days"))}function il(t,e,s){const n=[["years",(c,u)=>u.year-c.year],["quarters",(c,u)=>u.quarter-c.quarter+(u.year-c.year)*4],["months",(c,u)=>u.month-c.month+(u.year-c.year)*12],["weeks",(c,u)=>{const f=Hn(c,u);return(f-f%7)/7}],["days",Hn]],r={},a=t;let o,l;for(const[c,u]of n)s.indexOf(c)>=0&&(o=c,r[c]=u(t,e),l=a.plus(r),l>e?(r[c]--,t=a.plus(r),t>e&&(l=t,r[c]--,t=a.plus(r))):t=l);return[t,r,l,o]}function ol(t,e,s,n){let[r,a,o,l]=il(t,e,s);const c=e-r,u=s.filter(m=>["hours","minutes","seconds","milliseconds"].indexOf(m)>=0);u.length===0&&(o<e&&(o=r.plus({[l]:1})),o!==r&&(a[l]=(a[l]||0)+c/(o-r)));const f=Q.fromObject(a,n);return u.length>0?Q.fromMillis(c,n).shiftTo(...u).plus(f):f}const ll="missing Intl.DateTimeFormat.formatToParts support";function X(t,e=s=>s){return{regex:t,deser:([s])=>e(Ki(s))}}const cl=" ",ua=`[ ${cl}]`,da=new RegExp(ua,"g");function ul(t){return t.replace(/\./g,"\\.?").replace(da,ua)}function qn(t){return t.replace(/\./g,"").replace(da," ").toLowerCase()}function qe(t,e){return t===null?null:{regex:RegExp(t.map(ul).join("|")),deser:([s])=>t.findIndex(n=>qn(s)===qn(n))+e}}function Gn(t,e){return{regex:t,deser:([,s,n])=>gs(s,n),groups:e}}function ts(t){return{regex:t,deser:([e])=>e}}function dl(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function ml(t,e){const s=He(e),n=He(e,"{2}"),r=He(e,"{3}"),a=He(e,"{4}"),o=He(e,"{6}"),l=He(e,"{1,2}"),c=He(e,"{1,3}"),u=He(e,"{1,6}"),f=He(e,"{1,9}"),m=He(e,"{2,4}"),p=He(e,"{4,6}"),g=N=>({regex:RegExp(dl(N.val)),deser:([B])=>B,literal:!0}),I=(N=>{if(t.literal)return g(N);switch(N.val){case"G":return qe(e.eras("short"),0);case"GG":return qe(e.eras("long"),0);case"y":return X(u);case"yy":return X(m,Gs);case"yyyy":return X(a);case"yyyyy":return X(p);case"yyyyyy":return X(o);case"M":return X(l);case"MM":return X(n);case"MMM":return qe(e.months("short",!0),1);case"MMMM":return qe(e.months("long",!0),1);case"L":return X(l);case"LL":return X(n);case"LLL":return qe(e.months("short",!1),1);case"LLLL":return qe(e.months("long",!1),1);case"d":return X(l);case"dd":return X(n);case"o":return X(c);case"ooo":return X(r);case"HH":return X(n);case"H":return X(l);case"hh":return X(n);case"h":return X(l);case"mm":return X(n);case"m":return X(l);case"q":return X(l);case"qq":return X(n);case"s":return X(l);case"ss":return X(n);case"S":return X(c);case"SSS":return X(r);case"u":return ts(f);case"uu":return ts(l);case"uuu":return X(s);case"a":return qe(e.meridiems(),0);case"kkkk":return X(a);case"kk":return X(m,Gs);case"W":return X(l);case"WW":return X(n);case"E":case"c":return X(s);case"EEE":return qe(e.weekdays("short",!1),1);case"EEEE":return qe(e.weekdays("long",!1),1);case"ccc":return qe(e.weekdays("short",!0),1);case"cccc":return qe(e.weekdays("long",!0),1);case"Z":case"ZZ":return Gn(new RegExp(`([+-]${l.source})(?::(${n.source}))?`),2);case"ZZZ":return Gn(new RegExp(`([+-]${l.source})(${n.source})?`),2);case"z":return ts(/[a-z_+-/]{1,256}?/i);case" ":return ts(/[^\S\n\r]/);default:return g(N)}})(t)||{invalidReason:ll};return I.token=t,I}const fl={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function hl(t,e,s){const{type:n,value:r}=t;if(n==="literal"){const c=/^\s+$/.test(r);return{literal:!c,val:c?" ":r}}const a=e[n];let o=n;n==="hour"&&(e.hour12!=null?o=e.hour12?"hour12":"hour24":e.hourCycle!=null?e.hourCycle==="h11"||e.hourCycle==="h12"?o="hour12":o="hour24":o=s.hour12?"hour12":"hour24");let l=fl[o];if(typeof l=="object"&&(l=l[a]),l)return{literal:!1,val:l}}function yl(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function pl(t,e,s){const n=t.match(e);if(n){const r={};let a=1;for(const o in s)if(Et(s,o)){const l=s[o],c=l.groups?l.groups+1:1;!l.literal&&l.token&&(r[l.token.val[0]]=l.deser(n.slice(a,a+c))),a+=c}return[n,r]}else return[n,{}]}function gl(t){const e=a=>{switch(a){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let s=null,n;return F(t.z)||(s=et.create(t.z)),F(t.Z)||(s||(s=new Re(t.Z)),n=t.Z),F(t.q)||(t.M=(t.q-1)*3+1),F(t.h)||(t.h<12&&t.a===1?t.h+=12:t.h===12&&t.a===0&&(t.h=0)),t.G===0&&t.y&&(t.y=-t.y),F(t.u)||(t.S=an(t.u)),[Object.keys(t).reduce((a,o)=>{const l=e(o);return l&&(a[l]=t[o]),a},{}),s,n]}let js=null;function Sl(){return js||(js=L.fromMillis(1555555555555)),js}function xl(t,e){if(t.literal)return t;const s=je.macroTokenToFormatOpts(t.val),n=ya(s,e);return n==null||n.includes(void 0)?t:n}function ma(t,e){return Array.prototype.concat(...t.map(s=>xl(s,e)))}class fa{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=ma(je.parseFormat(s),e),this.units=this.tokens.map(n=>ml(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=yl(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=pl(e,this.regex,this.handlers),[r,a,o]=n?gl(n):[null,null,void 0];if(Et(n,"a")&&Et(n,"H"))throw new bt("Can't include meridiem when specifying 24-hour format");return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:s,matches:n,result:r,zone:a,specificOffset:o}}else return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function ha(t,e,s){return new fa(t,s).explainFromTokens(e)}function vl(t,e,s){const{result:n,zone:r,specificOffset:a,invalidReason:o}=ha(t,e,s);return[n,r,a,o]}function ya(t,e){if(!t)return null;const n=je.create(e,t).dtFormatter(Sl()),r=n.formatToParts(),a=n.resolvedOptions();return r.map(o=>hl(o,t,a))}const Os="Invalid DateTime",Yn=864e13;function Pt(t){return new Ge("unsupported zone",`the zone "${t.name}" is not supported`)}function Ds(t){return t.weekData===null&&(t.weekData=us(t.c)),t.weekData}function Cs(t){return t.localWeekData===null&&(t.localWeekData=us(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function mt(t,e){const s={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new L({...s,...e,old:s})}function pa(t,e,s){let n=t-e*60*1e3;const r=s.offset(n);if(e===r)return[n,e];n-=(r-e)*60*1e3;const a=s.offset(n);return r===a?[n,r]:[t-Math.min(r,a)*60*1e3,Math.max(r,a)]}function ss(t,e){t+=e*60*1e3;const s=new Date(t);return{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),hour:s.getUTCHours(),minute:s.getUTCMinutes(),second:s.getUTCSeconds(),millisecond:s.getUTCMilliseconds()}}function is(t,e,s){return pa(ps(t),e,s)}function _n(t,e){const s=t.o,n=t.c.year+Math.trunc(e.years),r=t.c.month+Math.trunc(e.months)+Math.trunc(e.quarters)*3,a={...t.c,year:n,month:r,day:Math.min(t.c.day,ds(n,r))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},o=Q.fromObject({years:e.years-Math.trunc(e.years),quarters:e.quarters-Math.trunc(e.quarters),months:e.months-Math.trunc(e.months),weeks:e.weeks-Math.trunc(e.weeks),days:e.days-Math.trunc(e.days),hours:e.hours,minutes:e.minutes,seconds:e.seconds,milliseconds:e.milliseconds}).as("milliseconds"),l=ps(a);let[c,u]=pa(l,s,t.zone);return o!==0&&(c+=o,u=t.zone.offset(c)),{ts:c,o:u}}function Tt(t,e,s,n,r,a){const{setZone:o,zone:l}=s;if(t&&Object.keys(t).length!==0||e){const c=e||l,u=L.fromObject(t,{...s,zone:c,specificOffset:a});return o?u:u.setZone(l)}else return L.invalid(new Ge("unparsable",`the input "${r}" can't be parsed as ${n}`))}function ns(t,e,s=!0){return t.isValid?je.create(ne.create("en-US"),{allowZ:s,forceSimple:!0}).formatDateTimeFromString(t,e):null}function Rs(t,e,s){const n=t.c.year>9999||t.c.year<0;let r="";if(n&&t.c.year>=0&&(r+="+"),r+=ve(t.c.year,n?6:4),s==="year")return r;if(e){if(r+="-",r+=ve(t.c.month),s==="month")return r;r+="-"}else if(r+=ve(t.c.month),s==="month")return r;return r+=ve(t.c.day),r}function Jn(t,e,s,n,r,a,o){let l=!s||t.c.millisecond!==0||t.c.second!==0,c="";switch(o){case"day":case"month":case"year":break;default:if(c+=ve(t.c.hour),o==="hour")break;if(e){if(c+=":",c+=ve(t.c.minute),o==="minute")break;l&&(c+=":",c+=ve(t.c.second))}else{if(c+=ve(t.c.minute),o==="minute")break;l&&(c+=ve(t.c.second))}if(o==="second")break;l&&(!n||t.c.millisecond!==0)&&(c+=".",c+=ve(t.c.millisecond,3))}return r&&(t.isOffsetFixed&&t.offset===0&&!a?c+="Z":t.o<0?(c+="-",c+=ve(Math.trunc(-t.o/60)),c+=":",c+=ve(Math.trunc(-t.o%60))):(c+="+",c+=ve(Math.trunc(t.o/60)),c+=":",c+=ve(Math.trunc(t.o%60)))),a&&(c+="["+t.zone.ianaName+"]"),c}const ga={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},wl={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},Al={ordinal:1,hour:0,minute:0,second:0,millisecond:0},os=["year","month","day","hour","minute","second","millisecond"],Tl=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],Nl=["year","ordinal","hour","minute","second","millisecond"];function ls(t){const e={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[t.toLowerCase()];if(!e)throw new gr(t);return e}function Kn(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return ls(t)}}function bl(t){if(Wt===void 0&&(Wt=xe.now()),t.type!=="iana")return t.offset(Wt);const e=t.name;let s=Ys.get(e);return s===void 0&&(s=t.offset(Wt),Ys.set(e,s)),s}function Qn(t,e){const s=lt(e.zone,xe.defaultZone);if(!s.isValid)return L.invalid(Pt(s));const n=ne.fromObject(e);let r,a;if(F(t.year))r=xe.now();else{for(const c of os)F(t[c])&&(t[c]=ga[c]);const o=Zr(t)||zr(t);if(o)return L.invalid(o);const l=bl(s);[r,a]=is(t,l,s)}return new L({ts:r,zone:s,loc:n,o:a})}function Xn(t,e,s){const n=F(s.round)?!0:s.round,r=F(s.rounding)?"trunc":s.rounding,a=(l,c)=>(l=on(l,n||s.calendary?0:2,s.calendary?"round":r),e.loc.clone(s).relFormatter(s).format(l,c)),o=l=>s.calendary?e.hasSame(t,l)?0:e.startOf(l).diff(t.startOf(l),l).get(l):e.diff(t,l).get(l);if(s.unit)return a(o(s.unit),s.unit);for(const l of s.units){const c=o(l);if(Math.abs(c)>=1)return a(c,l)}return a(t>e?-0:0,s.units[s.units.length-1])}function er(t){let e={},s;return t.length>0&&typeof t[t.length-1]=="object"?(e=t[t.length-1],s=Array.from(t).slice(0,t.length-1)):s=Array.from(t),[e,s]}let Wt;const Ys=new Map;class L{constructor(e){const s=e.zone||xe.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Ge("invalid input"):null)||(s.isValid?null:Pt(s));this.ts=F(e.ts)?xe.now():e.ts;let r=null,a=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(s))[r,a]=[e.old.c,e.old.o];else{const l=ct(e.o)&&!e.old?e.o:s.offset(this.ts);r=ss(this.ts,l),n=Number.isNaN(r.year)?new Ge("invalid input"):null,r=n?null:r,a=n?null:l}this._zone=s,this.loc=e.loc||ne.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=a,this.isLuxonDateTime=!0}static now(){return new L({})}static local(){const[e,s]=er(arguments),[n,r,a,o,l,c,u]=s;return Qn({year:n,month:r,day:a,hour:o,minute:l,second:c,millisecond:u},e)}static utc(){const[e,s]=er(arguments),[n,r,a,o,l,c,u]=s;return e.zone=Re.utcInstance,Qn({year:n,month:r,day:a,hour:o,minute:l,second:c,millisecond:u},e)}static fromJSDate(e,s={}){const n=so(e)?e.valueOf():NaN;if(Number.isNaN(n))return L.invalid("invalid input");const r=lt(s.zone,xe.defaultZone);return r.isValid?new L({ts:n,zone:r,loc:ne.fromObject(s)}):L.invalid(Pt(r))}static fromMillis(e,s={}){if(ct(e))return e<-Yn||e>Yn?L.invalid("Timestamp out of range"):new L({ts:e,zone:lt(s.zone,xe.defaultZone),loc:ne.fromObject(s)});throw new Me(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,s={}){if(ct(e))return new L({ts:e*1e3,zone:lt(s.zone,xe.defaultZone),loc:ne.fromObject(s)});throw new Me("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=lt(s.zone,xe.defaultZone);if(!n.isValid)return L.invalid(Pt(n));const r=ne.fromObject(s),a=ms(e,Kn),{minDaysInFirstWeek:o,startOfWeek:l}=Fn(a,r),c=xe.now(),u=F(s.specificOffset)?n.offset(c):s.specificOffset,f=!F(a.ordinal),m=!F(a.year),p=!F(a.month)||!F(a.day),g=m||p,v=a.weekYear||a.weekNumber;if((g||f)&&v)throw new bt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(p&&f)throw new bt("Can't mix ordinal dates with month/day");const I=v||a.weekday&&!g;let N,B,H=ss(c,u);I?(N=Tl,B=wl,H=us(H,o,l)):f?(N=Nl,B=Al,H=Ms(H)):(N=os,B=ga);let K=!1;for(const S of N){const j=a[S];F(j)?K?a[S]=B[S]:a[S]=H[S]:K=!0}const k=I?Xi(a,o,l):f?eo(a):Zr(a),D=k||zr(a);if(D)return L.invalid(D);const V=I?Un(a,o,l):f?Ln(a):a,[C,q]=is(V,u,n),y=new L({ts:C,zone:n,o:q,loc:r});return a.weekday&&g&&e.weekday!==y.weekday?L.invalid("mismatched weekday",`you can't specify both a weekday of ${a.weekday} and a date of ${y.toISO()}`):y.isValid?y:L.invalid(y.invalid)}static fromISO(e,s={}){const[n,r]=qo(e);return Tt(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=Go(e);return Tt(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=Yo(e);return Tt(n,r,s,"HTTP",s)}static fromFormat(e,s,n={}){if(F(e)||F(s))throw new Me("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:a=null}=n,o=ne.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0}),[l,c,u,f]=vl(o,e,s);return f?L.invalid(f):Tt(l,c,n,`format ${s}`,e,u)}static fromString(e,s,n={}){return L.fromFormat(e,s,n)}static fromSQL(e,s={}){const[n,r]=tl(e);return Tt(n,r,s,"SQL",e)}static invalid(e,s=null){if(!e)throw new Me("need to specify a reason the DateTime is invalid");const n=e instanceof Ge?e:new Ge(e,s);if(xe.throwOnInvalid)throw new ki(n);return new L({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,s={}){const n=ya(e,ne.fromObject(s));return n?n.map(r=>r?r.val:null).join(""):null}static expandFormat(e,s={}){return ma(je.parseFormat(e),ne.fromObject(s)).map(r=>r.val).join("")}static resetCache(){Wt=void 0,Ys.clear()}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?Ds(this).weekYear:NaN}get weekNumber(){return this.isValid?Ds(this).weekNumber:NaN}get weekday(){return this.isValid?Ds(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Cs(this).weekday:NaN}get localWeekNumber(){return this.isValid?Cs(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Cs(this).weekYear:NaN}get ordinal(){return this.isValid?Ms(this.c).ordinal:NaN}get monthShort(){return this.isValid?es.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?es.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?es.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?es.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const e=864e5,s=6e4,n=ps(this.c),r=this.zone.offset(n-e),a=this.zone.offset(n+e),o=this.zone.offset(n-r*s),l=this.zone.offset(n-a*s);if(o===l)return[this];const c=n-o*s,u=n-l*s,f=ss(c,o),m=ss(u,l);return f.hour===m.hour&&f.minute===m.minute&&f.second===m.second&&f.millisecond===m.millisecond?[mt(this,{ts:c}),mt(this,{ts:u})]:[this]}get isInLeapYear(){return Ht(this.year)}get daysInMonth(){return ds(this.year,this.month)}get daysInYear(){return this.isValid?It(this.year):NaN}get weeksInWeekYear(){return this.isValid?Vt(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Vt(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:s,numberingSystem:n,calendar:r}=je.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:s,numberingSystem:n,outputCalendar:r}}toUTC(e=0,s={}){return this.setZone(Re.instance(e),s)}toLocal(){return this.setZone(xe.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=lt(e,xe.defaultZone),e.equals(this.zone))return this;if(e.isValid){let r=this.ts;if(s||n){const a=e.offset(this.ts),o=this.toObject();[r]=is(o,a,e)}return mt(this,{ts:r,zone:e})}else return L.invalid(Pt(e))}reconfigure({locale:e,numberingSystem:s,outputCalendar:n}={}){const r=this.loc.clone({locale:e,numberingSystem:s,outputCalendar:n});return mt(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const s=ms(e,Kn),{minDaysInFirstWeek:n,startOfWeek:r}=Fn(s,this.loc),a=!F(s.weekYear)||!F(s.weekNumber)||!F(s.weekday),o=!F(s.ordinal),l=!F(s.year),c=!F(s.month)||!F(s.day),u=l||c,f=s.weekYear||s.weekNumber;if((u||o)&&f)throw new bt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(c&&o)throw new bt("Can't mix ordinal dates with month/day");let m;a?m=Un({...us(this.c,n,r),...s},n,r):F(s.ordinal)?(m={...this.toObject(),...s},F(s.day)&&(m.day=Math.min(ds(m.year,m.month),m.day))):m=Ln({...Ms(this.c),...s});const[p,g]=is(m,this.o,this.zone);return mt(this,{ts:p,o:g})}plus(e){if(!this.isValid)return this;const s=Q.fromDurationLike(e);return mt(this,_n(this,s))}minus(e){if(!this.isValid)return this;const s=Q.fromDurationLike(e).negate();return mt(this,_n(this,s))}startOf(e,{useLocaleWeeks:s=!1}={}){if(!this.isValid)return this;const n={},r=Q.normalizeUnit(e);switch(r){case"years":n.month=1;case"quarters":case"months":n.day=1;case"weeks":case"days":n.hour=0;case"hours":n.minute=0;case"minutes":n.second=0;case"seconds":n.millisecond=0;break}if(r==="weeks")if(s){const a=this.loc.getStartOfWeek(),{weekday:o}=this;o<a&&(n.weekNumber=this.weekNumber-1),n.weekday=a}else n.weekday=1;if(r==="quarters"){const a=Math.ceil(this.month/3);n.month=(a-1)*3+1}return this.set(n)}endOf(e,s){return this.isValid?this.plus({[e]:1}).startOf(e,s).minus(1):this}toFormat(e,s={}){return this.isValid?je.create(this.loc.redefaultToEN(s)).formatDateTimeFromString(this,e):Os}toLocaleString(e=cs,s={}){return this.isValid?je.create(this.loc.clone(s),e).formatDateTime(this):Os}toLocaleParts(e={}){return this.isValid?je.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:s=!1,suppressMilliseconds:n=!1,includeOffset:r=!0,extendedZone:a=!1,precision:o="milliseconds"}={}){if(!this.isValid)return null;o=ls(o);const l=e==="extended";let c=Rs(this,l,o);return os.indexOf(o)>=3&&(c+="T"),c+=Jn(this,l,s,n,r,a,o),c}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?Rs(this,e==="extended",ls(s)):null}toISOWeekDate(){return ns(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:s=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:a=!1,format:o="extended",precision:l="milliseconds"}={}){return this.isValid?(l=ls(l),(r&&os.indexOf(l)>=3?"T":"")+Jn(this,o==="extended",s,e,n,a,l)):null}toRFC2822(){return ns(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return ns(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?Rs(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:s=!1,includeOffsetSpace:n=!0}={}){let r="HH:mm:ss.SSS";return(s||e)&&(n&&(r+=" "),s?r+="z":e&&(r+="ZZ")),ns(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Os}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};const s={...this.c};return e.includeConfig&&(s.outputCalendar=this.outputCalendar,s.numberingSystem=this.loc.numberingSystem,s.locale=this.loc.locale),s}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,s="milliseconds",n={}){if(!this.isValid||!e.isValid)return Q.invalid("created by diffing an invalid DateTime");const r={locale:this.locale,numberingSystem:this.numberingSystem,...n},a=no(s).map(Q.normalizeUnit),o=e.valueOf()>this.valueOf(),l=o?this:e,c=o?e:this,u=ol(l,c,a,r);return o?u.negate():u}diffNow(e="milliseconds",s={}){return this.diff(L.now(),e,s)}until(e){return this.isValid?Se.fromDateTimes(this,e):this}hasSame(e,s,n){if(!this.isValid)return!1;const r=e.valueOf(),a=this.setZone(e.zone,{keepLocalTime:!0});return a.startOf(s,n)<=r&&r<=a.endOf(s,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;const s=e.base||L.fromObject({},{zone:this.zone}),n=e.padding?this<s?-e.padding:e.padding:0;let r=["years","months","days","hours","minutes","seconds"],a=e.unit;return Array.isArray(e.unit)&&(r=e.unit,a=void 0),Xn(s,this.plus(n),{...e,numeric:"always",units:r,unit:a})}toRelativeCalendar(e={}){return this.isValid?Xn(e.base||L.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(L.isDateTime))throw new Me("min requires all arguments be DateTimes");return $n(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every(L.isDateTime))throw new Me("max requires all arguments be DateTimes");return $n(e,s=>s.valueOf(),Math.max)}static fromFormatExplain(e,s,n={}){const{locale:r=null,numberingSystem:a=null}=n,o=ne.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});return ha(o,e,s)}static fromStringExplain(e,s,n={}){return L.fromFormatExplain(e,s,n)}static buildFormatParser(e,s={}){const{locale:n=null,numberingSystem:r=null}=s,a=ne.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new fa(a,e)}static fromFormatParser(e,s,n={}){if(F(e)||F(s))throw new Me("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:a=null}=n,o=ne.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});if(!o.equals(s.locale))throw new Me(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${s.locale}`);const{result:l,zone:c,specificOffset:u,invalidReason:f}=s.explainFromTokens(e);return f?L.invalid(f):Tt(l,c,n,`format ${s.format}`,e,u)}static get DATE_SHORT(){return cs}static get DATE_MED(){return Sr}static get DATE_MED_WITH_WEEKDAY(){return ji}static get DATE_FULL(){return xr}static get DATE_HUGE(){return vr}static get TIME_SIMPLE(){return wr}static get TIME_WITH_SECONDS(){return Ar}static get TIME_WITH_SHORT_OFFSET(){return Tr}static get TIME_WITH_LONG_OFFSET(){return Nr}static get TIME_24_SIMPLE(){return br}static get TIME_24_WITH_SECONDS(){return Ir}static get TIME_24_WITH_SHORT_OFFSET(){return kr}static get TIME_24_WITH_LONG_OFFSET(){return Er}static get DATETIME_SHORT(){return Mr}static get DATETIME_SHORT_WITH_SECONDS(){return jr}static get DATETIME_MED(){return Or}static get DATETIME_MED_WITH_SECONDS(){return Dr}static get DATETIME_MED_WITH_WEEKDAY(){return Oi}static get DATETIME_FULL(){return Cr}static get DATETIME_FULL_WITH_SECONDS(){return Rr}static get DATETIME_HUGE(){return Ur}static get DATETIME_HUGE_WITH_SECONDS(){return Lr}}function Ft(t){if(L.isDateTime(t))return t;if(t&&t.valueOf&&ct(t.valueOf()))return L.fromJSDate(t);if(t&&typeof t=="object")return L.fromObject(t);throw new Me(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function Il(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function kl(t,e){try{const s=L.fromJSDate(t,{zone:"utc"}).setZone(e),n=s.toJSDate().toLocaleString("en-US",{timeZone:e,timeZoneName:"short"}).split(" ").pop()||void 0,r=s.toFormat("ZZ")||void 0;return{abbr:n,offset:r}}catch{return{}}}function El(t){if(!t)return"-";try{const e=new Date(t),s=u=>String(u).padStart(2,"0"),n=s(e.getMonth()+1),r=s(e.getDate()),a=e.getFullYear(),o=s(e.getHours()),l=s(e.getMinutes()),c=s(e.getSeconds());return`${n}/${r}/${a} ${o}:${l}:${c}`}catch{return"-"}}function Zt(t,e="UTC",s=!1){if(!t)return"-";const n=L.fromISO(t,{zone:"utc"}).setZone(e);if(!n.isValid)return"-";const r=n.offsetNameShort,a=n.toFormat("ZZZZ"),o=r.startsWith("GMT")||r===a?a:`${r}/${a}`,l=s?"MM/dd/yyyy, hh:mm:ss.SSS a":"MM/dd/yyyy, hh:mm:ss a";return`${n.toFormat(l)} (${o})`}const Ml={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},jl={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function Sa({alerts:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,onAlertIdClick:a,onAlertView:o,onFilterChange:l,onPageChange:c,onRefetch:u,resetKey:f}){const m=tn(),p=async I=>{try{const N=await m.mutateAsync({alertUniqueId:I.alertId??I.id,alertId:I.id,status:"Reopen",notes:"Reopened",modifiedBy:0});if(N?.responseStatus||N?.Success){const B=N?.message||N?.Message||"Alert reopened successfully.";Te.toast.success(B)}else{const B=N?.errorMessage||N?.Message||"Failed to reopen alert";Te.toast.error(B)}}catch{Te.toast.error("Failed to reopen alert. Please try again.")}},g=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:I=>i.jsx(h.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Ml[I]}`,backgroundColor:jl[String(I)]},children:I})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:I=>El(I)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(I,N)=>i.jsxs("div",{children:[i.jsx("a",{onClick:B=>{B.preventDefault(),a?.(N,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:N.alertNumber}),i.jsx("div",{className:"text-black/65",children:I})]})},{title:"Preview",key:"preview",width:100,align:"center",render:(I,N)=>i.jsx(pr,{record:N})},{title:"",key:"menu",width:60,align:"right",render:(I,N)=>i.jsx(h.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:B})=>{B==="reopen"&&p(N)}},children:i.jsx(h.Button,{type:"text",icon:i.jsx(ht.MoreOutlined,{})})})}],v=l?t:(t||[]).filter(I=>{const N=pn(I.statusType||"");return Ii.some(B=>N.includes(pn(B)))});return i.jsx(en,{data:v,loading:e,pageSize:s,total:n,currentPage:r,columns:g,renderActions:void 0,onAlertIdClick:a,onAlertView:o,onFilterChange:l,onPageChange:c,onRefetch:u,resetKey:f,excludeCompleted:!1})}function Ol({size:t=120,time:e,timeZone:s="America/New_York"}){const{hours:n,minutes:r,seconds:a}=d.useMemo(()=>{const m=new Intl.DateTimeFormat("en-US",{timeZone:s,hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(e);return{hours:parseInt(m.find(p=>p.type==="hour")?.value||"0",10),minutes:parseInt(m.find(p=>p.type==="minute")?.value||"0",10),seconds:parseInt(m.find(p=>p.type==="second")?.value||"0",10)}},[e,s]),o=a*6,l=r*6+a*.1,c=n%12*30+r*.5,u=t/2;return i.jsxs("div",{className:"relative rounded-full border border-gray-300 bg-white",style:{width:t,height:t},role:"img","aria-label":"Analog Clock",children:[[...Array(12)].map((f,m)=>{const p=m*30,g=6,v=u-4,I=v-g,N=(p-90)*(Math.PI/180),B=u+I*Math.cos(N),H=u+I*Math.sin(N),K=u+v*Math.cos(N),k=u+v*Math.sin(N);return i.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:i.jsx("line",{x1:B,y1:H,x2:K,y2:k,stroke:"#9CA3AF",strokeWidth:m%3===0?2:1,strokeLinecap:"round"})},m)}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${c}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.25,stroke:"#1F2937",strokeWidth:4,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${l}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.35,stroke:"#374151",strokeWidth:3,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${o}deg)`},children:i.jsx("line",{x1:u,y1:u+t*.08,x2:u,y2:u-t*.38,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"})}),i.jsx("div",{className:"absolute bg-gray-900 rounded-full",style:{width:8,height:8,left:u-4,top:u-4}})]})}function xa({label:t="USA",timeZone:e="America/New_York",updateIntervalMs:s=1e3,className:n}){const[r,a]=d.useState(new Date);d.useEffect(()=>{const u=setInterval(()=>a(new Date),s);return()=>clearInterval(u)},[s]);const o=d.useMemo(()=>Il(r,e),[r,e]),{abbr:l,offset:c}=d.useMemo(()=>kl(r,e),[r,e]);return i.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[i.jsx(Ol,{time:r,timeZone:e,size:80}),i.jsxs("div",{className:"flex flex-col items-baseline gap-1",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[i.jsx("span",{className:"uppercase",children:t}),l&&i.jsxs("span",{className:"p-2 rounded-md border text-[10px] leading-none text-gray-600 bg-gray-50",children:[l," ",c]})]}),i.jsx("div",{className:"text-2xl font-semibold text-gray-700 tracking-wide",children:o})]})]})}const{Text:Dl}=h.Typography;function Cl({sortBy:t,onChange:e,showActions:s,onSave:n,onClear:r,saving:a}){return i.jsxs(h.Row,{gutter:[16,16],align:"middle",children:[i.jsx(h.Col,{xs:24,md:8,lg:5,children:i.jsxs(h.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[i.jsx(Dl,{className:"text-gray-600 whitespace-nowrap",children:"Sort By:"}),i.jsx(h.Select,{placeholder:"By Severity",value:t,onChange:o=>e({sortBy:o}),options:[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],className:"w-full",style:{minWidth:"200px"}})]})}),i.jsx(h.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?i.jsxs(h.Space,{className:"w-full",direction:"horizontal",size:8,children:[i.jsx(h.Button,{onClick:r,disabled:a,children:"Clear"}),i.jsx(h.Button,{type:"primary",onClick:n,loading:a,children:"Save"})]}):null})]})}const _s=t=>i.jsxs(h.Tag,{children:[i.jsx(ht.PlusOutlined,{})," ",t.length," more"]}),{Text:Xe}=h.Typography;function Rl(t){const{selectedRule:e,setSelectedRule:s,ruleOptions:n,minsOptions:r,roleOptions:a,l1mins:o,setL1mins:l,l1role:c,setL1role:u,l2mins:f,setL2mins:m,l2role:p,setL2role:g,l3mins:v,setL3mins:I,l3role:N,setL3role:B,actions:H,setActions:K,thirdPartyIds:k,setThirdPartyIds:D,humanLoop:V,setHumanLoop:C,isAutoExpire:q,setAutoExpire:y,onClear:S,onSave:j,saving:re,onActionTypesLoaded:fe}=t,{rules:M,config:A}=Fe(),x=A.tenant==="schools",[E,T]=d.useState([]),[O,U]=d.useState([]),[Y,G]=d.useState(!1);d.useEffect(()=>{let ee=!1;return(async()=>{try{G(!0);const pe=await M.getLookups();if(ee||!pe||!Array.isArray(pe.actionTypes))return;const Ne=pe.actionTypes.map($=>({label:$.name,value:String($.actionTypeId)}));T(Ne),fe&&fe(pe.actionTypes);const he=Array.isArray(pe.thirdParties)?pe.thirdParties.map($=>({label:$.thirdPartyName,value:$.thirdPartyIds??$.thirdPartyId})):[];U(he)}catch(pe){console.error("Error loading lookups",pe)}finally{ee||G(!1)}})(),()=>{ee=!0}},[]);const _=typeof o=="number"||typeof c=="number",oe=typeof f=="number"||typeof p=="number",ue=typeof o=="number"||typeof c=="number"||typeof f=="number"||typeof p=="number"||typeof v=="number"||typeof N=="number"||Array.isArray(H)&&H.length>0||Array.isArray(k)&&k.length>0||!!V||!!q,Ie=!!e&&ue&&!re;return i.jsxs(h.Spin,{spinning:!!re||Y,children:[i.jsxs(h.Row,{gutter:[16,16],align:"bottom",children:[i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(h.Select,{placeholder:"Rules",value:e,onChange:s,options:n,className:"w-full"})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),i.jsx(h.Col,{span:14,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:o,onChange:l,options:r})}),i.jsx(h.Col,{span:14,children:i.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:c,onChange:u,options:a})})]})]})}),_&&i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),i.jsx(h.Col,{span:14,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:f,onChange:m,options:r})}),i.jsx(h.Col,{span:14,children:i.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:p,onChange:g,options:a})})]})]})}),oe&&i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),i.jsx(h.Col,{span:14,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:v,onChange:I,options:r})}),i.jsx(h.Col,{span:14,children:i.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:N,onChange:B,options:a})})]})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),i.jsx(h.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:H,onChange:K,options:E,maxTagCount:1,maxTagPlaceholder:_s})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Notify"}),i.jsx(h.Select,{mode:"multiple",placeholder:"Notify",className:"w-full",value:k,onChange:D,options:O,maxCount:2,maxTagPlaceholder:_s})]})})]}),i.jsxs(h.Row,{gutter:[16,16],align:"bottom",className:"mt-4 items-center",children:[i.jsx(h.Col,{xs:24,sm:12,md:8,lg:7,children:i.jsxs("div",{className:"flex items-center h-full gap-8",children:[!x&&i.jsx(h.Checkbox,{checked:V,onChange:ee=>C(ee.target.checked),className:"w-full",children:"Human-In-The-Loop"}),i.jsx(h.Checkbox,{checked:q,onChange:ee=>y(ee.target.checked),className:"w-full",children:"Auto-expire in 5 minutes"})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(h.Button,{onClick:S,children:"Clear"}),i.jsx(h.Button,{type:"primary",onClick:j,loading:!!re,disabled:!Ie,children:"Save"})]})})]})]})}function Ul({entries:t,userRoles:e,onEdit:s,loading:n}){const{config:r}=Fe(),a=r.tenant==="schools",o=new Map(e.map(c=>[c.userRoleId,c.userRoleName])),l=c=>c.map(u=>o.get(u)||String(u)).join(", ");return i.jsx(h.Table,{rowKey:"id",dataSource:t,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(c,u)=>`${u[0]}-${u[1]} of ${c} items`},loading:n,columns:[{title:"Rule",dataIndex:"ruleOrSeverityLabel",key:"rule"},{title:"Level 1",key:"l1",render:(c,u)=>i.jsxs("span",{children:[u.l1.minutes?`Action taken in (${u.l1.minutes} Mins)`:"No Action taken in 0 Min",u.l1.roles?.length?`, Escalate to (${l(u.l1.roles)})`:""]})},{title:"Level 2",key:"l2",render:(c,u)=>i.jsxs("span",{children:[u.l2.minutes?`Action taken in (${u.l2.minutes} Mins)`:"No Action taken in 0 Min",u.l2.roles?.length?`, Escalate to (${l(u.l2.roles)})`:""]})},{title:"Level 3",key:"l3",render:(c,u)=>i.jsxs("span",{children:[u.l3.minutes?`Action taken in (${u.l3.minutes} Mins)`:"No Action taken in 0 Min",u.l3.roles?.length?`, Escalate to (${l(u.l3.roles)})`:""]})},{title:"Pick Actions",key:"actionsCol",render:(c,u)=>u.actions?.length?u.actions.join(", "):"-"},{title:"Notify",key:"notify",render:(c,u)=>u.notify?.length?u.notify.join(", "):"-"},...a?[]:[{title:"Human-In-The-Loop",key:"humanLoop",render:(c,u)=>u.humanLoop?"Yes":"No"}],{title:"Auto Expire",key:"isAutoExpire",render:(c,u)=>u.isAutoExpire?"Yes":"No"},{title:"Actions",key:"ops",render:(c,u)=>i.jsx(h.Button,{type:"text",onClick:()=>s(u.id),children:i.jsx(ht.EditOutlined,{})})}]})}const{Title:Ll,Text:Us}=h.Typography;function va({userRoles:t,rules:e,rawRules:s}){const{rules:n}=Fe(),[r,a]=d.useState(!1),[o,l]=d.useState(!1),[c,u]=d.useState(s),[f,m]=d.useState(),[p,g]=d.useState([]),v=d.useMemo(()=>t.map(k=>({label:k.userRoleName,value:k.userRoleId})),[t]),I=d.useMemo(()=>(e||[]).map(k=>({label:k.Name||"-",value:k.RuleId||k.Name||""})),[e]),N=d.useMemo(()=>(e||[]).map((k,D)=>({key:k.RuleId||k.Name||String(D),ruleName:k.Name||"-",ruleDesc:k.Description||""})),[e]);d.useEffect(()=>{let k=!1;return(async()=>{try{a(!0);const D=await n.getRules();k||u(Array.isArray(D)?D:[])}catch{!k&&Array.isArray(s)&&u(s)}finally{k||a(!1)}})(),()=>{k=!0}},[]),d.useEffect(()=>{!c&&Array.isArray(s)&&u(s)},[s]),d.useEffect(()=>{if(!f||!Array.isArray(c)){g([]);return}const k=c.find(V=>V?.ruleId===f||V?.RuleId===f||V?.ruleName===f),D=k?.userRoleIds??k?.UserRoleIds;g(Array.isArray(D)?D:[])},[f,c]);const B=d.useMemo(()=>{if(!Array.isArray(c)||!c.length)return{};const k={};for(const D of N){const V=c.find(y=>y?.ruleId===D.key||y?.ruleName===D.key||y?.RuleId===D.key||y?.ruleName===D.ruleName||y?.Name===D.ruleName),C=V?.userRoleIds??V?.UserRoleIds,q=Array.isArray(C)?C:[];q.length&&(k[D.key]=q)}return k},[c,N]),H=()=>{m(void 0),g([])},K=async()=>{if(!f){Te.toast.info("Please select a rule");return}try{l(!0);const k=Array.isArray(c)?c.find(y=>y?.ruleId===f||y?.RuleId===f||y?.ruleName===f):void 0,D=typeof k?.recordId=="number"?k.recordId:k?.ruleId||k?.RuleId||void 0;if(!k||!D)throw new Error(`Unable to find rule identifier for rule ${f}`);const V=p.map(y=>{const S=t.find(j=>j.userRoleId===y);return{id:y,name:S?.userRoleName??String(y)}}),C={...k,ruleId:f,userRoleIds:p,userRoles:V},q=await n.updateRule(D,C);if(!q?.responseStatus&&!q?.Success&&!q?.success)Te.toast.error(q?.errorMessage||q?.Message||"Error saving Alert Assignment");else{Te.toast.success("Alert assignment saved"),m(void 0),g([]);try{const y=await n.getRules();u(Array.isArray(y)?y:[])}catch(y){console.error("Failed to refresh rules after save",y)}}}catch(k){console.error("Failed to save alert assignment",k),Te.toast.error(k instanceof Error?k.message:"Error saving Alert Assignment")}finally{l(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(Ll,{level:4,className:"!mb-4",children:"Alert Assignment"}),i.jsx(h.Spin,{spinning:o||r,children:i.jsxs(h.Row,{gutter:[16,16],align:"bottom",className:"mb-6",children:[i.jsx(h.Col,{xs:24,sm:12,md:8,lg:6,children:i.jsxs("div",{children:[i.jsx(Us,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(h.Select,{placeholder:"Rules",value:f,onChange:m,options:I,className:"w-full"})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:8,children:i.jsxs("div",{children:[i.jsx(Us,{className:"text-gray-700 font-medium block mb-1",children:"Alert Notification To"}),i.jsx(h.Select,{mode:"multiple",placeholder:"Select roles",className:"w-full",value:p,onChange:g,options:v,maxTagCount:1,maxTagPlaceholder:_s})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(h.Button,{onClick:H,disabled:o,children:"Cancel"}),i.jsx(h.Button,{type:"primary",onClick:K,loading:o,disabled:o||!f,children:"Save"})]})})]})}),i.jsx(h.Table,{rowKey:"key",dataSource:N,loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(k,D)=>`${D[0]}-${D[1]} of ${k} items`},columns:[{title:"Rule Name",dataIndex:"ruleName",key:"ruleName"},{title:"Description",dataIndex:"ruleDesc",key:"ruleDesc"},{title:"Alert Notification To",key:"assign",render:(k,D)=>{const V=B[D.key]??[];return V.length?i.jsx("div",{className:"flex flex-wrap gap-1",children:V.map(C=>{const q=t.find(y=>y.userRoleId===C);return i.jsx(h.Tag,{children:q?.userRoleName??String(C)},C)})}):i.jsx(Us,{type:"secondary",children:"—"})}}]})]})}const{Title:tr}=h.Typography;function Ls(t){return!t||typeof t!="object"?{}:{level1UserRoleId:t.level1UserRoleId??t.Level1UserRoleId,level1PostAssistTime:t.level1PostAssistTime??t.Level1PostAssistTime,level2UserRoleId:t.level2UserRoleId??t.Level2UserRoleId,level2PostAssistTime:t.level2PostAssistTime??t.Level2PostAssistTime,level3UserRoleId:t.level3UserRoleId??t.Level3UserRoleId,level3PostAssistTime:t.level3PostAssistTime??t.Level3PostAssistTime,escalationSettingsActionTypeIds:t.escalationSettingsActionTypeIds??t.EscalationSettingsActionTypeIds,thirdPartyId:t.thirdPartyId??t.ThirdPartyId??t.ThirdPartyIds,humanLoop:t.humanLoop??t.HumanLoop,isAutoExpire:t.isAutoExpire??t.IsAutoExpire}}function wa({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r,onSave:a}){const{rules:o,alerts:l}=Fe(),[c,u]=d.useState("By Severity"),[f,m]=d.useState("By severity"),[p,g]=d.useState("By Severity"),[v,I]=d.useState(!1),[N,B]=d.useState(!1),[H,K]=d.useState(!1),[k,D]=d.useState(null),[V,C]=d.useState("rules"),[q,y]=d.useState(),[S,j]=d.useState(),[re,fe]=d.useState(),[M,A]=d.useState(),[x,E]=d.useState(),[T,O]=d.useState(),[U,Y]=d.useState(),[G,_]=d.useState(),[oe,ue]=d.useState([]),[Ie,ee]=d.useState([]),[pe,Ne]=d.useState(!1),[he,$]=d.useState(!1),[P,ye]=d.useState({}),[le,Ue]=d.useState({}),[we,ze]=d.useState(s||[]),[Ee,ge]=d.useState([]),[Ct,ut]=d.useState(!1),[gt,_e]=d.useState(!1),[Le,St]=d.useState(n||[]);d.useEffect(()=>{n&&n.length&&St(n)},[n]),d.useEffect(()=>{if(!Le||!Le.length)return;const R=Object.keys(P).length>0||Object.keys(le).length>0;if(Ee.length&&!R)return;const te=Le.map((J,W)=>{const ce=e.find(ie=>ie.RuleId===(J.ruleId||J.ruleName))?.Name||J.ruleName||J.Name||"-",Z=Ls(J.escalationSettings),se=typeof Z.level1UserRoleId=="number"&&Z.level1UserRoleId>0?[Z.level1UserRoleId]:[],Je=typeof Z.level2UserRoleId=="number"&&Z.level2UserRoleId>0?[Z.level2UserRoleId]:[],Rt=typeof Z.level3UserRoleId=="number"&&Z.level3UserRoleId>0?[Z.level3UserRoleId]:[],z=(Array.isArray(Z.escalationSettingsActionTypeIds)?Z.escalationSettingsActionTypeIds:[]).map(ie=>P[ie]||String(ie)),Ae=(Array.isArray(Z.thirdPartyId)?Z.thirdPartyId:[]).map(ie=>le[ie]||String(ie)),Oe=typeof Z.humanLoop=="boolean"?Z.humanLoop:null,de=typeof Z.isAutoExpire=="boolean"?Z.isAutoExpire:null;return{id:String(J.ruleId||J.ruleName||W),ruleOrSeverityLabel:ce,l1:{minutes:Z.level1PostAssistTime??void 0,roles:se},l2:{minutes:Z.level2PostAssistTime??void 0,roles:Je},l3:{minutes:Z.level3PostAssistTime??void 0,roles:Rt},actions:z,notify:Ae,humanLoop:Oe,isAutoExpire:de}});ge(te)},[Le,e,P,le]);const xt=d.useMemo(()=>t.map(R=>({label:R.DisplayName,value:R.SeverityId})),[t]),be=d.useMemo(()=>e.map(R=>({label:R.Name,value:R.RuleId})),[e]),vt=d.useMemo(()=>we.map(R=>({label:R.userRoleName,value:R.userRoleId})),[we]),xs=d.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(R=>({label:`${R}`,value:R})),[]);d.useEffect(()=>{let R=!1;async function te(){try{K(!0),D(null);const J=await l.getAdminSettings();if(!R&&J){const W=rr(J.sortBy);u(W),g(W),I(!1)}}catch(J){if(!R){const W=J instanceof Error?J.message:"Failed to load admin settings";D(W)}}finally{R||K(!1)}}return te(),()=>{R=!0}},[]),d.useEffect(()=>{if(!S)return;const R=ce=>{const Z=Number(ce);return!isNaN(Z)&&Z>0?Z:void 0},te=ce=>{const Z=Number(ce);return!isNaN(Z)&&Z>0?Z:void 0},J=(Le||[]).find(ce=>ce?.ruleId===S||ce?.ruleName===S||ce?.RuleId===S),W=Ls(J?.escalationSettings);if(W&&typeof W=="object"){fe(te(W.level1PostAssistTime)),A(R(W.level1UserRoleId)),E(te(W.level2PostAssistTime)),O(R(W.level2UserRoleId)),Y(te(W.level3PostAssistTime)),_(R(W.level3UserRoleId));const ce=Array.isArray(W.escalationSettingsActionTypeIds)?W.escalationSettingsActionTypeIds:[];ue(ce.map(Z=>String(Z))),ee(Array.isArray(W.thirdPartyId)?W.thirdPartyId:[]),Ne(!!W.humanLoop),$(!!W.isAutoExpire)}},[V,S,Le]);const vs=async()=>{try{_e(!0);const R=await o.getRules(),te=Array.isArray(R)?R:Array.isArray(R?.data)?R.data:[];St(te);const J=te.map((W,ce)=>{const Z=e.find(ie=>ie.RuleId===(W.ruleId||W.ruleName))?.Name||W.ruleName||W.Name||"-",se=Ls(W.escalationSettings??W.EscalationSettings),Je=typeof se.level1UserRoleId=="number"&&se.level1UserRoleId>0?[se.level1UserRoleId]:[],Rt=typeof se.level2UserRoleId=="number"&&se.level2UserRoleId>0?[se.level2UserRoleId]:[],w=typeof se.level3UserRoleId=="number"&&se.level3UserRoleId>0?[se.level3UserRoleId]:[],ae=(Array.isArray(se.escalationSettingsActionTypeIds)?se.escalationSettingsActionTypeIds:[]).map(ie=>P[ie]||String(ie)),Oe=(Array.isArray(se.thirdPartyId)?se.thirdPartyId:[]).map(ie=>le[ie]||String(ie)),de=typeof se.humanLoop=="boolean"?se.humanLoop:null;return{id:String(W.ruleId||W.ruleName||ce),ruleOrSeverityLabel:Z,l1:{minutes:se.level1PostAssistTime??void 0,roles:Je},l2:{minutes:se.level2PostAssistTime??void 0,roles:Rt},l3:{minutes:se.level3PostAssistTime??void 0,roles:w},actions:ae,notify:Oe,humanLoop:de}});ge(J)}catch(R){console.error("Failed to refetch entries",R)}finally{_e(!1)}};d.useEffect(()=>{let R=!1;return(async()=>{try{const te=await o.getLookups();if(R||!te)return;const J={};if(Array.isArray(te.thirdParties))for(const ce of te.thirdParties){const Z=ce.thirdPartyIds??ce.thirdPartyId;typeof Z=="number"&&(J[Z]=ce.thirdPartyName)}Ue(J);const W=Array.isArray(te.userRoles)?te.userRoles.map(ce=>({userRoleId:ce.userRoleId??ce.id,userRoleName:ce.userRoleName??ce.name})):[];R||ze(W.length?W:s||[])}catch(te){console.error("Error loading lookups",te)}})(),()=>{R=!0}},[]);const mn=async()=>{B(!0);try{const R=await l.setAdminSettings({sortBy:c,groupBy:"string"});R?.responseStatus?Te.toast.success(R?.message||"Admin settings saved"):Te.toast.error(R?.errorMessage||"Error saving admin settings"),g(c),I(!1)}catch(R){console.error("Error saving admin settings",R)}finally{B(!1)}},ws=()=>{u(p),I(!1)},As=async()=>{ut(!0),a?.({ruleId:S,levels:[{minutes:re,role:M},{minutes:x,role:T},{minutes:U,role:G}],actions:oe,thirdPartyIds:Ie,humanLoop:pe,isAutoExpire:he});try{if(S){const te=Array.isArray(oe)?oe.map(se=>Number.isNaN(Number(se))?se:Number(se)):[],J=(Le||[]).find(se=>se?.ruleId===S||se?.ruleName===S||se?.RuleId===S),W=typeof J?.recordId=="number"?J.recordId:J?.ruleId||J?.RuleId||void 0;if(!J||!W){Te.toast.error("Unable to find rule identifier for update");return}const ce={...J,escalationSettings:{level1UserRoleId:M??0,level1PostAssistTime:re??0,level2UserRoleId:T??0,level2PostAssistTime:x??0,level3UserRoleId:G??0,level3PostAssistTime:U??0,escalationSettingsActionTypeIds:te,thirdPartyId:Array.isArray(Ie)?Ie:[],humanLoop:pe,isAutoExpire:he}},Z=await o.updateRule(W,ce);Z?.responseStatus||Z?.Success||Z?.success?(Te.toast.success("Escalation settings saved"),await vs(),j(void 0),fe(void 0),A(void 0),E(void 0),O(void 0),Y(void 0),_(void 0),ue([]),ee([]),Ne(!1),$(!1)):Te.toast.error(Z?.errorMessage||Z?.Message||"Error saving Escalation Settings")}}catch(te){console.error("Error saving escalation settings",te)}finally{ut(!1)}},Ts=()=>{u("By Severity"),m("By severity"),C("rules"),y(void 0),j(void 0),fe(void 0),A(void 0),E(void 0),O(void 0),Y(void 0),_(void 0),ue([]),ee([]),Ne(!1),$(!1)};return i.jsxs("div",{className:"w-full",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(tr,{level:4,className:"!mb-2",children:"Admin Settings"}),i.jsxs(h.Spin,{spinning:H,children:[k?i.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",k]}):null,i.jsx(Cl,{sortBy:c,groupBy:f,onChange:R=>{R.sortBy&&(u(R.sortBy),I(!0)),R.groupBy&&(m(R.groupBy),I(!0))},showActions:v,onSave:mn,onClear:ws,saving:N})]})]}),i.jsx(h.Divider,{className:"my-6"}),i.jsxs("div",{children:[i.jsx(tr,{level:4,className:"!mb-4",children:"Escalation Settings"}),i.jsx(Rl,{escBasis:V,setEscBasis:C,selectedSeverity:q,setSelectedSeverity:y,selectedRule:S,setSelectedRule:j,severityOptions:xt,ruleOptions:be,minsOptions:xs,roleOptions:vt,l1mins:re,setL1mins:fe,l1role:M,setL1role:A,l2mins:x,setL2mins:E,l2role:T,setL2role:O,l3mins:U,setL3mins:Y,l3role:G,setL3role:_,actions:oe,setActions:ue,thirdPartyIds:Ie,setThirdPartyIds:ee,humanLoop:pe,setHumanLoop:Ne,onClear:Ts,onSave:As,saving:Ct,onActionTypesLoaded:R=>{const te={};for(const J of R)typeof J.actionTypeId=="number"&&(te[J.actionTypeId]=J.name);ye(te)},isAutoExpire:he,setAutoExpire:$})]}),i.jsx(h.Divider,{className:"my-6"}),i.jsx(Ul,{entries:Ee,userRoles:we,loading:gt||r,onEdit:R=>{C("rules");const te=Ee.find(W=>W.id===R),J=e.find(W=>W.RuleId===R)||(te?e.find(W=>W.Name===te.ruleOrSeverityLabel):void 0);j(J?J.RuleId:R)}}),i.jsx(h.Divider,{className:"my-6"}),i.jsx(va,{userRoles:we,rules:e,rawRules:n}),i.jsx(h.Divider,{})]})}const{Title:sr,Text:rs}=h.Typography;function Fl({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:a}=Fe(),o=[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],[l,c]=d.useState("By Severity"),[u,f]=d.useState(new Set),[m,p]=d.useState(null),[g,v]=d.useState(null),[I,N]=d.useState({inApp:!1,sms:!1,email:!1}),[B,H]=d.useState([]),[K,k]=d.useState(!0),[D,V]=d.useState(!1);d.useEffect(()=>{let y=!1;return(async()=>{try{const S=await a.getPreferenceSettings();if(y||!S)return;N({inApp:!!S.inApp,sms:!!S.sms,email:!!S.email});const j=rr(S.sortBy);c(j==="By Created Date"?"By Created Date":"By Severity"),p(vn(S.doNotDisturbStart)),v(vn(S.doNotDisturbEnd)),Array.isArray(S.anomalyIds)&&f(new Set(S.anomalyIds.map(re=>String(re))))}catch(S){console.error("Error in loading my preferences: ",S)}})(),()=>{y=!0}},[]),d.useEffect(()=>{let y=!1;return(async()=>{try{k(!0);const S=await r.getLookups();if(y||!S)return;const j=Array.isArray(S.anomalies)?S.anomalies:[];H(j)}catch(S){console.error("Failed to load anomalies lookups",S)}finally{y||k(!1)}})(),()=>{y=!0}},[]);const C=y=>{f(S=>{const j=new Set(S);return j.has(y)?j.delete(y):j.add(y),j})},q=async()=>{s?.({sortBy:l,subscribedRuleIds:Array.from(u),dnd:{from:m,to:g},channels:I});try{V(!0);const y=m?m.format?.("HH:mm:ss")??"00:00:00":"00:00:00",S=g?g.format?.("HH:mm:ss")??"00:00:00":"00:00:00",j=Array.from(u).map(fe=>Number(fe)).filter(fe=>Number.isFinite(fe)),re=await a.setPreferenceSettings({anomalyIds:j,doNotDisturbStart:y,doNotDisturbEnd:S,inApp:!!I.inApp,sms:!!I.sms,email:!!I.email,sortBy:l});re?.responseStatus&&Te.toast.success(re?.message||"Preferences updated successfully.")}catch(y){console.error("Error in saving my preferences: ",y)}finally{V(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(h.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:i.jsx(h.Col,{xs:24,md:8,children:i.jsxs(h.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(rs,{className:"text-gray-600",children:"Sort By:"}),i.jsx(h.Select,{className:"w-[240px]",value:l,options:o,onChange:c})]})})}),i.jsxs("div",{className:"mb-4",children:[i.jsx(sr,{level:5,className:"!mb-2",children:"Anomalies"}),K?i.jsx("div",{className:"py-4",children:i.jsx(h.Spin,{})}):i.jsx(h.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray(B)?B:[]).map(y=>{const S=String(y.recordId),j=y.anomalyName;return i.jsx(h.Checkbox,{checked:u.has(S),onChange:()=>C(S),children:j},S)})})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx(sr,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),i.jsx(h.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:i.jsx(h.Col,{xs:24,md:12,children:i.jsxs(h.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(rs,{children:"Do Not Disturb mode:"}),i.jsxs(h.Space,{size:12,className:"w-full",children:[i.jsxs(h.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(rs,{children:"From"}),i.jsx(h.TimePicker,{value:m,onChange:y=>p(y),format:"HH:mm"})]}),i.jsxs(h.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(rs,{children:"To"}),i.jsx(h.TimePicker,{value:g,onChange:y=>v(y),format:"HH:mm"})]})]})]})})}),i.jsxs(h.Row,{gutter:[24,12],children:[i.jsx(h.Col,{children:i.jsx(h.Checkbox,{checked:I.inApp,onChange:y=>N({...I,inApp:y.target.checked}),children:"In-app"})}),i.jsx(h.Col,{children:i.jsx(h.Checkbox,{checked:I.sms,onChange:y=>N({...I,sms:y.target.checked}),children:"SMS"})}),i.jsx(h.Col,{children:i.jsx(h.Checkbox,{checked:I.email,onChange:y=>N({...I,email:y.target.checked}),children:"Email"})})]})]}),i.jsx(h.Divider,{}),i.jsxs(h.Space,{className:"gap-3",children:[i.jsx(h.Button,{onClick:n,disabled:D,children:"Cancel"}),i.jsx(h.Button,{type:"primary",onClick:q,loading:D,children:"Save"})]})]})}function Aa({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r}){return i.jsx("div",{className:"w-full",children:i.jsx(wa,{severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r})})}const $l="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAIZSURBVHgBnZW/b9NAFMe/z3H6i1ZNJUBFQsL/QQkLCFBtRhhKF1ibhBmpXbtgFlYqsTG0gRGWwgAjMb8EYmjYGN0pCCrVVaX+SBxf37PiqHWcOu5Xsux79+6j77vz3RH66IbdsDTQPCFngmBwqMCPBwVXoe204Fd/2ZfrSWMpHrDshtGCvsY9FlKkFNYD+Es/7EtuX+itp1sLnLrScTWoPMYsfnty/lUPtAOs4syiUgQOoWHJpG9kdBiX11Z+UaZCk1YT+vOzACuzYxgf7hZbyBGvhTi9af+7SkQbyKi7M8N4ZJ5D+eU2dg9UN07KvyNOS8io6UkNFXMMj1/vnACKAuTmNXZpIqME+LF+iIbX7ukjkClODWTQw+ujuGYMYfXzXnICbxSBDrxAUvYDhkrZp6ggUC8+sDI7mpj9YmESb3/uJ5Z9TJ5A3eORvzsBpgs6lufGT2TKPNY3fbxh6Knis0FTSjnx+LP3u5DJicDi/t7MCFadPaRJQTl02/5vKcKnpITluYkwrWjksebs48Pvg3SoUkXtq32hxt+1pITI8Zc/zcGACN59ty/WdWnklV5ukZ+49wU8MUJIF3mBGlqUr3Dv1+wpl20v9UuP75pElyrgc3XK7UJFbLvK4DJiv9ggDmWcjO9G4imWvW00yV/hjvtpOFnpQOVLkcO+0EhyevGrROG1ol1hREFc8ZGxyddIje+v9c4i9+gI5z7MozLxclgAAAAASUVORK5CYII=",Pl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAKeSURBVHgBjVVdbtpAEJ5ZmygPfTBSaVWpUt0bwFuURgJOUG5QeoLACbw+QeAEwA3SGxgJokh9CDeI+xSpTRU/Imw8nbFZx6QQGAl5d2fm229+dkDYI2f6oaUAOwhWExBcPnL4FwFBSLCexpCMf+qPi12++PKgpR/cGOwRa1pwQIjgOoWkf6s/hOVzVd588R+/xWjf5YAY8Y0+ErQrZFfnXg3lK3uGm7A+RISOxfbit5NprqBxxgBoeEIVHehqtI9lSz+5McaaITaA2J17bycFaBayMOS8IaT+zHuv4Ui58P9oAvB4Ga0paUgqbFGswL5idIcIx3P9DCiXrQB7iJawcTiCkMMIUlj7Jo8zr6Yv/EfRXXIqRnzUxnP9u46Id8Q5Sslq3+pqWErHAPKqvxROC/ZMuJwKJ8bkPouUkrYUqgt5IgMDKAxfAYT8nAZnmR2A5J47YSjrFKyOYpZN2SiIJ8YjRqVfASyAFVg9s2F2gXwRsClMXdnYcFpq5PyiQ8KEilaywc79+aEow2i7fdCF46SIpuTvCGi2kWSXjCM4QqS4Zl3yjwQ0UySwrBfGRJNjQKW4ZrmEpL45CxUDTGWdgmoZgxOoDA6zxYgr7ZudhWk3x6Sp4kl0nZmgujQhcH5Cvqy/Hxi5hdL+dgsWxR2rma4FkLeDw+PMM243+t2YB0jDDI9nMBquyWqI3tjmLYguQfqDzxebty/DIcnePr9jfePVfDhSzv2/Hs8LAY3kMmFfTCl+rl3uu1GWF6Jx+X3vkpa+58jeeNyXvY3Pd8N+a0hvgK9ge3hMTmG5CPTnSICWcFpXaDfZUcAck99yOnZM/id3hcmAFV/hgEilU6p0TcH2gpZYS98xc/kXUJ8YImPFzfeLh0cgXbMp8n/yD3ySPZSK0MWKAAAAAElFTkSuQmCC";function Yt(){const{config:t}=Fe();return{timeZoneDetails:d.useMemo(()=>{const s=t.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone;return{timeZoneUniqueId:"",ianaTimeZoneId:s,timeZoneName:s,offset:""}},[t.timeZone]),loading:!1}}function Wl(t){const e=(t.status||"").toLowerCase()==="completed"?i.jsx("img",{src:$l,alt:"completed",style:{width:20,height:20}}):i.jsx("img",{src:Pl,alt:"pending",style:{width:20,height:20}});return{title:i.jsxs("div",{className:"flex flex-col gap-0 min-w-0",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{className:"block text-sm break-words mb-1 overflow-visible whitespace-normal",children:i.jsx("b",{children:t.title})}),t.description?i.jsx("span",{className:"text-gray-500 text-xs",children:t.description}):null]}),t.timestamp?i.jsx("span",{className:"text-gray-500 text-xs",children:t.timestamp}):null]}),icon:e,description:null}}function Bl({data:t}){const{timeZoneDetails:e}=Yt();return i.jsx("div",{className:"w-full",children:i.jsx(h.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:i.jsxs("div",{className:"w-full",style:{maxHeight:"50vh",overflowY:"auto"},children:[i.jsx(h.Card,{className:"mb-4 rounded-md p-4",bordered:!0,children:i.jsxs("div",{className:"grid grid-cols-4 gap-6 text-xs",children:[i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Alert ID"}),i.jsx("span",{className:"text-black",children:t.summary.alertNumber})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Severity"}),i.jsx("span",{className:"text-black",children:t.summary.severity})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Location"}),i.jsx("span",{className:"text-black",children:t.summary.location})]})]})}),i.jsxs(h.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsx("h4",{className:"text-sm text-black font-medium",children:"Response Timeline/ Audit trail/log"})}),i.jsx("div",{className:"mt-2",children:i.jsx(h.Steps,{direction:"vertical",size:"small",current:1,items:(t.timeline||[]).map(Wl)})})]})]})},{key:"notification",label:"Notification Sent",children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",style:{maxHeight:"50vh",overflowY:"auto"},children:[(t.notifications||[]).map((s,n)=>i.jsxs(h.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsx("div",{className:"flex flex-col",children:i.jsx("h4",{className:"text-sm text-black font-medium",children:s.channelLabel})}),i.jsxs("span",{className:"text-[11px] px-2 py-1 rounded-full bg-green-50 text-green-700 border border-green-200",children:[s.delivered,"/",s.total," Delivered"]})]}),i.jsxs("div",{className:"mt-4",children:[i.jsxs("div",{className:"text-xs text-black font-medium",children:["Recipients (",s.total,")"]}),i.jsx("div",{className:"mt-2 flex flex-col gap-3 text-xs",children:(s.recipients||[]).map((r,a)=>{const o=String(r?.notificationReceipientType||"").toLowerCase()==="EscalationNotification".toLowerCase();return i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsxs("span",{className:"text-black",children:[r.name," -"," ",i.jsx("span",{style:{color:o?"#FF3B30":"#FFB86A"},children:o?"Escalation Notification":"Alert Notification"})]}),i.jsx("span",{className:"text-gray-500",children:r.phone}),r.sentAt?i.jsx("span",{className:"text-gray-500",children:Zt(r.sentAt,e?.ianaTimeZoneId,!0)}):null]}),i.jsx("span",{className:`text-[11px] px-3 py-[2px] rounded ${r.status==="Delivered"?"bg-green-50 text-green-700 border border-green-200":"bg-red-50 text-red-700 border border-red-200"}`,children:r.status})]},a)})})]})]},n)),t?.notifications?.length?null:i.jsx("span",{className:"text-gray-500 text-xs",children:"No notifications."})]})}]})})}const Vl=({alertId:t,id:e,priority:s,spaceName:n,alertNumber:r,statusHistory:a,notifGroups:o})=>{const l={alertId:t??String(e??""),incidentId:"-",severity:s||"",location:n||"",alertNumber:r??""},{timeZoneDetails:c}=Yt(),u=a?.length?[...a].reverse().map(m=>{const p=(m?.status||m?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",g=m?.createdDate?Zt(m.createdDate,c?.ianaTimeZoneId):m?.timestamp?Zt(m.timestamp,c?.ianaTimeZoneId):"";return{status:p,title:m?.status||m?.eventStatus||"Status Update",description:m?.actionNotes||m?.description||"",timestamp:g}}):[],f={summary:l,timeline:u,notifications:o??[]};return i.jsx(Bl,{data:f})},Zl=({url:t,alt:e,isLoading:s,priority:n,detections:r,onLoadSuccess:a,onError:o})=>{const{imageRef:l,dimensions:c,onLoad:u}=mr(),f=d.useMemo(()=>dr(r,c.naturalWidth,c.naturalHeight,c.renderedWidth,c.renderedHeight),[r,c]),m=d.useMemo(()=>f.map(p=>({...p,label:p.personName||""})),[f]);return i.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[i.jsx("img",{ref:l,src:t,alt:e,className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg transition-opacity duration-200 ${s?"opacity-0":"opacity-100"}`,onLoad:()=>{u(),a()},onError:o}),i.jsx(ur,{boxes:m,priority:n})]})},zl=({items:t})=>{const{timeZoneDetails:e}=Yt(),s=a=>a?.replace(/([a-z])([A-Z])/g,"$1 $2"),r=(()=>{if(!t?.length||t.length<2)return null;const a=new Date(t[0].timeStamp).getTime(),o=new Date(t[t.length-1].timeStamp).getTime(),l=Math.floor((o-a)/1e3),c=o-a,u=Math.floor(l/3600),f=Math.floor(l%3600/60),m=l%60,p=c%1e3;return[u>0?`${u}h`:null,f>0?`${f}m`:null,`${m}s`,`${p}ms`].filter(Boolean).join(" ")})();return i.jsxs("div",{className:"bg-[#F7F7F7] rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[i.jsx("div",{className:"font-semibold text-base",children:"Alert Timeline"}),r&&i.jsxs(h.Tag,{color:"blue",children:["Total Duration: ",r]})]}),t?.length?i.jsx(h.Timeline,{items:t.map(a=>({dot:i.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-blue-500 bg-white flex items-center justify-center",children:i.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500"})}),children:i.jsxs("div",{className:"pb-4",children:[i.jsx("div",{className:"font-semibold text-[15px] text-[#1F2937]",children:s(a.eventName)}),i.jsxs("div",{className:"text-[#6B7280] text-sm",children:["Timestamp:"," ",Zt(a.timeStamp,e?.ianaTimeZoneId,!0)]}),a.timeElapsed&&i.jsxs("div",{className:"text-[#6B7280] text-sm",children:["Time Elapsed: ",a.timeElapsed,"s"]})]})}))}):i.jsx("div",{className:"text-center text-gray-500 py-8",children:"No Alert Timelines Found"})]})},Hl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},ql={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Gl={"elopement attempt":"elopement","elopement completed":"elopement","watchlist person detected":"watchlist","watch list person detected":"watchlist","brandished guns & knives":"weapon","brandished guns and knives":"weapon"},Yl=({isModalOpen:t,handleModalClose:e,selectedRow:s,fetchAlertLogs:n,alertStatusList:r=[],alertStatusLoading:a=!1,initialTab:o="details",sourceTab:l,onAlertView:c,showAlertTimeline:u})=>{const[f,m]=d.useState(),[p,g]=d.useState(""),[v,I]=d.useState(!1),[N,B]=d.useState([]),H=d.useRef(null),[K,k]=d.useState("details"),[D,V]=d.useState(void 0),C=tn(),{alerts:q,rules:y,config:S}=Fe(),{timeZoneDetails:j}=Yt(),[re,fe]=d.useState(null),[M,A]=d.useState(!1),[x,E]=d.useState(!1),[T,O]=d.useState(void 0),[U,Y]=d.useState(void 0),[G,_]=d.useState({}),[oe,ue]=d.useState({}),Ie=(w,z,ae)=>{const Ae=oe[w];return G[w]===!1&&!Ae?i.jsxs("div",{className:"w-full flex flex-col items-center justify-center min-h-[200px] bg-gray-100 rounded-lg gap-2 text-gray-400",children:[i.jsx(yr,{size:40}),i.jsx("span",{className:"text-sm",children:"Media not available"})]}):i.jsxs("div",{className:"relative w-full flex justify-center items-center min-h-[200px]",children:[Ae&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg z-10",children:i.jsx(wi,{size:32,className:"animate-spin text-gray-400"})}),i.jsx(Zl,{url:w,alt:z.caption||`media-${ae}`,isLoading:Ae,priority:we,detections:Le,onLoadSuccess:()=>ue(Oe=>({...Oe,[w]:!1})),onError:()=>ue(Oe=>({...Oe,[w]:!1}))})]})},ee=s?.originalData||{},{eventName:pe,eventDisplayName:Ne,anomalyName:he,alertId:$,timestamp:P,description:ye,spaceName:le,assignTeam:Ue,priority:we,statusType:ze,id:Ee,alertDetails:ge,statusHistory:Ct,mediaDetails:ut,alertNumber:gt}=ee,_e=ee.bbox_xyxy,Le=d.useMemo(()=>_e?[{bbox_xyxy:_e,personName:ee.personName}]:[],[_e,ee.personName]),St=S.tenant==="snl"?Ne||pe||"Alert Event":pe||"Alert Event",xt=w=>{const z=String(w||"").toLowerCase();return z==="delivered"||z==="sent"?"Delivered":z==="failed"?"Failed":"Queued"},be=w=>({name:w?.receipientName||w?.recipientName||"-",role:w?.receipientRoleName||"",phone:w?.receipentPhoneNumber||w?.recipientPhoneNumber||w?.receipientEmail||w?.recipientEmail||"",status:xt(w?.messageStatus),notificationReceipientType:w?.notificationReceipientType||"",sentAt:w?.sentAt||""}),vt=(w,z)=>{const ae=z.map(be),Ae=ae.filter(ie=>ie.status==="Delivered").length,Oe=z.map(ie=>ie?.sentAt).filter(Boolean).sort((ie,fn)=>new Date(ie).getTime()-new Date(fn).getTime())[0],de=`${w} Notification`;return{channelLabel:`${w} Notification`,sentAt:Oe||"",messageTitle:de,messageBody:"",total:ae.length,delivered:Ae,recipients:ae}},xs=w=>{const z=new Map;return(w||[]).forEach(ae=>{const Ae=String(ae?.notificationType||"Unknown"),Oe=z.get(Ae)||[];Oe.push(ae),z.set(Ae,Oe)}),Array.from(z.entries()).map(([ae,Ae])=>vt(ae,Ae))},vs=async w=>{try{const z=await q.getAlertNotifications(w),ae=xs(z);V(ae)}catch{V(void 0)}};d.useEffect(()=>{if(K!=="track"||!Ee)return;let w=!1;return vs(Ee).then(()=>{w&&V(void 0)}),()=>{w=!0}},[K,Ee]),d.useEffect(()=>{if(!$){B([]);return}(async()=>{try{const z=await q.getAlertTimeline?.(String($));B(z||[])}catch{B([])}})()},[$]),d.useEffect(()=>{t?k(o):(m(void 0),g(""))},[t,o]),d.useEffect(()=>{!t||!c||c([{personName:ee.personName,faceId:ee.faceId,mediaDetails:ee.mediaDetails}])},[t]),d.useEffect(()=>{if(!t||S.tenant!=="snl")return;let w=!1;return A(!0),y.getLookups().then(z=>{w||(fe(z.alertStatusTypes??[]),A(!1))}).catch(()=>{w||(fe([]),A(!1))}),()=>{w=!0}},[t,S.tenant]);const ws=l==="archived"||["completed","false positive"].includes(String(ze||"").toLowerCase()),As=w=>{const z=String(w?.value||"").toLowerCase(),ae=String(w?.statusName||"").toLowerCase();return z.includes("reopen")||ae.includes("reopen")},Ts=String(he||"").trim().toLowerCase(),R=Gl[Ts]??"general",te=r.filter(w=>{const z=As(w);return typeof l<"u"?l==="archived"?z:!z:ws?z:!z}).map(w=>({value:w.value,label:w.statusName})),J=re??[],W=w=>!!w.isWatchListStatus,ce=w=>!!w.isWeapontStatus,Z=J.filter(w=>{switch(R){case"elopement":return w.isElopementStatus;case"watchlist":return W(w);case"weapon":return ce(w);default:return!w.isElopementStatus&&!W(w)&&!ce(w)}}).map(w=>({value:w.alertStatusTypeName,label:w.alertStatusTypeName})),se=S.tenant==="snl"&&re!==null?Z:te,Je=d.useMemo(()=>cr(ut),[ut]);d.useEffect(()=>{let w=!1;const z=new AbortController,ae=async de=>{if(de){w||_(ie=>({...ie,[de]:!1}));try{const ie=await fetch(de,{method:"HEAD",signal:z.signal});if(ie.ok){w||_(Ut=>({...Ut,[de]:!0}));return}if(ie.status===404){w||_(Ut=>({...Ut,[de]:!1}));return}if(!(await fetch(de,{method:"GET",signal:z.signal})).ok)throw new Error("Media not available");w||_(Ut=>({...Ut,[de]:!0}))}catch{w||_(ie=>({...ie,[de]:!1}))}}};_({});const Ae=Je.filter(de=>!Fs(de)).map(de=>de?.mediaUrl||de).filter(de=>typeof de=="string"&&de.length>0),Oe={};return Ae.forEach(de=>{Oe[de]=!0}),ue(Oe),Ae.forEach(de=>ae(de)),()=>{w=!0,z.abort()}},[Je]);const Rt=async()=>{try{I(!0);const w={alertUniqueId:$,alertId:Ee,status:f?String(f):void 0,notes:p.trim(),modifiedBy:0},z=await C.mutateAsync(w);if(z?.responseStatus||z?.Success){const ae=z?.message||z?.Message||"Alert updated successfully.";Te.toast.success(ae,{autoClose:1500,onClose:()=>{n(),e()}}),m(void 0),g("")}else{const ae=z?.errorMessage||z?.Message||"Failed to update alert status";Te.toast.error(ae)}}catch(w){console.error("Error updating alert status:",w),Te.toast.error("Failed to update alert status. Please try again.")}finally{I(!1)}};return i.jsx(h.Modal,{open:t,onCancel:e,width:1e3,closable:!x,maskClosable:!x,footer:K==="details"?i.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[i.jsx(h.Button,{onClick:e,className:"!bg-[#6C757D] !border-[#6C757D] hover:!bg-[#5c636a] hover:!border-[#5c636a]",children:"Cancel"}),i.jsx(h.Button,{type:"primary",onClick:Rt,loading:v,children:v?"Saving...":"Save Changes"})]}):null,children:s&&i.jsx(h.Tabs,{activeKey:K,onChange:w=>k(w),items:[{key:"details",label:"Alert Detail",children:i.jsxs("div",{className:"grid grid-cols-2 gap-2",style:{maxHeight:"50vh",overflowY:"auto"},children:[i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("div",{className:"text-sm font-bold",children:St}),ge?.firstName?i.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",ge?.firstName," ",ge?.lastName||""," "," ",ge?.residentId||""]}):null,i.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp:"," ",Zt(P,j?.ianaTimeZoneId)]}),i.jsxs("div",{className:"font-sm text-gray-500",children:[i.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",ye||"No description available"]}),le&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",le]}),Ue&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",Ue]}),i.jsxs("div",{className:"flex gap-2 justify-start mt-3",children:[i.jsxs(h.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${Hl[String(we)]||"#DFE4EA"}`,backgroundColor:ql[String(we)]},children:["Severity: ",we||"N/A"]}),i.jsxs(h.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(ze||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",ze||"N/A"]})]}),i.jsx("div",{className:"w-full flex flex-col justify-start items-start mt-2 font-bold",children:i.jsxs("div",{className:"w-full mt-4",children:[i.jsx("div",{className:"flex flex-col gap-2",children:i.jsx(h.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:w=>m(w),value:f,options:se,loading:S.tenant==="snl"?M:a})}),i.jsxs("div",{className:"flex flex-col gap-2 mt-3",children:[i.jsx("label",{htmlFor:"action-details-input",className:"text-xs text-gray-500 font-medium",children:"Action Taken (Comments)"}),i.jsx("textarea",{id:"action-details-input",placeholder:"Enter details...",className:"w-full text-gray-500 h-20 border border-grey-500 rounded-md p-2",value:p,onChange:w=>g(w.target.value)})]})]})})]}),i.jsxs("div",{className:"flex flex-col gap-4",children:[i.jsxs("div",{className:"w-full mt-1",children:[i.jsxs("div",{className:"w-full flex items-center justify-between",children:[i.jsx("h3",{className:"text-black font-bold text-sm",children:"Camera Footage"}),Je.length>1?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>H.current?.prev?.(),className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 text-gray-600","aria-label":"Previous media",children:i.jsx(ht.LeftOutlined,{style:{fontSize:12}})}),i.jsx("button",{type:"button",onClick:()=>H.current?.next?.(),className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 text-gray-600","aria-label":"Next media",children:i.jsx(ht.RightOutlined,{style:{fontSize:12}})})]}):null]}),Je.length?i.jsx("div",{className:"w-full",children:i.jsx(h.Carousel,{ref:H,dots:!0,className:"w-full",children:Je.map((w,z)=>{const ae=w.mediaUrl||w,Ae=Fs(w);return i.jsxs("div",{className:"flex justify-center items-center relative",children:[Ae?i.jsxs("video",{width:"240",height:"200",controls:!0,className:"max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg",children:[i.jsx("source",{src:ae}),"Your browser does not support the video tag."]}):Ie(String(ae),w,z),w.caption&&i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:w.caption}),!Ae&&G[String(ae)]?i.jsx("button",{onClick:()=>{E(!0),O(ae),Y(w.type||"image")},className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:i.jsx(Ti,{size:20})}):null]},String(ae)||z)})})}):null]}),u&&i.jsx(zl,{items:N})]}),i.jsx(fr,{isOpen:x,onClose:()=>E(!1),src:T||"",type:U||"image",detections:Le,priority:we})]})},{key:"track",label:"Track Incident",children:i.jsx(Vl,{alertId:$,id:Ee,priority:we,spaceName:le,alertNumber:gt,statusHistory:Ct,notifGroups:D})}]})})};function Ta(){const{alerts:t}=Fe(),e=yt.useQuery({queryKey:["alerts","statusList"],queryFn:()=>t.getAlertStatusList(),staleTime:5*6e4});return{list:e.data??[],loading:e.isLoading,error:e.error,refetch:e.refetch}}function dn({alerts:t,loading:e=!1,columns:s,total:n,currentPage:r,onRefetch:a,onPageChange:o,onFilterChange:l,onAlertView:c,showAlertTimeline:u}){const[f,m]=d.useState(!1),[p,g]=d.useState(null),[v,I]=d.useState("details"),{list:N,loading:B}=Ta(),{timeZoneDetails:H}=Yt(),K=H?.timeZoneName??"UTC",k=H?.ianaTimeZoneId??"UTC";function D(re,fe){g(re),I(fe?.tab??"details"),q(fe?.sourceTab??"active"),m(!0)}function V(){m(!1)}const[C,q]=d.useState("active"),[y,S]=d.useState(0),j=p?{originalData:{...p,alertId:p.alertId??p.id,mediaDetails:p.mediaDetails}}:null;return i.jsxs("div",{className:"p-6 flex flex-col items-start justify-start min-h-screen w-full overflow-auto",children:[i.jsxs("div",{className:"w-full grid grid-cols-3 sm:grid-cols-1 items-center mb-4",children:[i.jsx("h1",{className:"text-xl font-bold text-black",children:"Alert Console"}),i.jsx("div",{className:"flex items-center justify-start sm:justify-center",children:i.jsx(xa,{label:K,timeZone:k})})]}),i.jsx(h.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:re=>{const fe=re==="archived";S(M=>M+1),o?.(1),l?.({isArchived:fe})},items:[{key:"active",label:"Active",children:i.jsx(en,{data:t,loading:e,pageSize:10,total:n,currentPage:r,columns:s||[],onAlertIdClick:D,onAlertView:c,onRefetch:a,onPageChange:o,onFilterChange:l,resetKey:y})},{key:"archived",label:"Archived",children:i.jsx(Sa,{alerts:t,loading:e,columns:s||[],total:n,currentPage:r,onAlertIdClick:D,onAlertView:c,onFilterChange:l,onPageChange:o,onRefetch:a,resetKey:y})},{key:"settings",label:"Settings",children:i.jsx(_l,{})}]}),i.jsx(Yl,{isModalOpen:f,handleModalClose:V,selectedRow:j,fetchAlertLogs:()=>{},alertStatusList:N,alertStatusLoading:B,initialTab:v,sourceTab:C,onAlertView:c,showAlertTimeline:u})]})}function _l(){const[t,e]=d.useState([]),[s,n]=d.useState([]),[r,a]=d.useState([]),[o,l]=d.useState([]),[c,u]=d.useState(!0),{rules:f}=Fe();return d.useEffect(()=>{let m=!0;return(async()=>{try{const p=await f.getRules();if(!m)return;l(Array.isArray(p)?p:[]);const g=(p||[]).map((v,I)=>({RuleId:v.ruleId||v.ruleName||String(I),Name:v.ruleName||v.Name||"-",Description:v.ruleDesc||v.Description||"",SeverityId:0}));e(g);try{const v=await f.getLookups(),I=Array.isArray(v?.userRoles)?v.userRoles.map(N=>({userRoleId:N.userRoleId??N.id,userRoleName:N.userRoleName??N.name})):[];n(I),a(Array.isArray(v?.severities)?v.severities:[])}catch{}}catch{}finally{m&&u(!1)}})(),()=>{m=!1}},[]),i.jsx(Aa,{severities:r,rules:t,userRoles:s,rawRules:o,loadingRules:c})}function Jl(t){return Array.isArray(t)?{items:t}:t}function Na(t=1,e){const{alerts:s,config:n}=Fe(),r=n.tenant==="schools"&&!!String(e?.searchText??"").trim(),a=yt.useQuery({queryKey:["alerts","list",n.tenant,t,e],queryFn:()=>{const o={...e};return n.tenant==="schools"?(o.pageNumber=t,o.pageSize=r?100:10):(o.pageNumber=t,o.pageSize=10),s.listAlerts(o).then(Jl)},staleTime:r?0:3e4});return{alerts:a.data?.items??[],total:a.data?.total,loading:a.isLoading,error:a.error,refetch:a.refetch}}function Kl(t){const[e,s]=d.useState(1),[n,r]=d.useState({}),{alerts:a,total:o,loading:l,refetch:c}=Na(e,n);d.useEffect(()=>{!l&&a.length>0&&t.onAlertView?.(a)},[a,l]);const u=f=>{"isArchived"in f?r({isArchived:f.isArchived}):r(m=>({...m,...f}))};return i.jsx(dn,{alerts:a,loading:l,columns:t.columns,total:o,currentPage:e,onRefetch:c,onPageChange:s,onFilterChange:u,onAlertView:t.onAlertView,showAlertTimeline:t.showAlertTimeline})}function Ql({tenant:t,apiDomain:e,rulesDomain:s,headers:n,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,alerts:l,loading:c,columns:u,onAlertView:f,showAlertTimeline:m}){const[p]=d.useState(()=>new yt.QueryClient({defaultOptions:{queries:{retry:(v,I)=>{const N=I.response?.status??I?.status;return N>=400&&N<=500?!1:v<2},refetchOnWindowFocus:!1}}})),g=d.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return i.jsx(yt.QueryClientProvider,{client:p,children:i.jsx(or,{tenant:t,override:g,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,children:Array.isArray(l)?i.jsx(dn,{alerts:l,loading:!!c,columns:u,onAlertView:f,showAlertTimeline:m}):i.jsx(Kl,{columns:u,onAlertView:f,showAlertTimeline:m})})})}function Xl(t){const{alerts:e}=Fe(),s=yt.useQuery({queryKey:["alerts","report",t],queryFn:()=>e.getAlertsReport(t),staleTime:6e4});return{data:s.data??[],loading:s.isLoading,error:s.error,refetch:s.refetch}}const ec=[{title:"ID",dataIndex:"id",key:"id",width:120},{title:"Priority",dataIndex:"priority",key:"priority",width:120},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:220},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description"}];exports.AlertAssignment=va;exports.AlertConsole=dn;exports.AlertConsoleWidget=Ql;exports.AlertsTable=en;exports.ApiProvider=or;exports.ArchivedTable=Sa;exports.Clock=xa;exports.DataTable=lr;exports.MyPreferencesPanel=Fl;exports.SettingsPanel=wa;exports.SettingsTabs=Aa;exports.exampleAlertColumns=ec;exports.useAlertStatusList=Ta;exports.useAlerts=Na;exports.useAlertsReport=Xl;exports.useApi=Fe;exports.useUpdateAlertStatus=tn;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),d=require("react"),h=require("antd"),St=require("@ant-design/icons"),Ne=require("react-toastify"),xt=require("@tanstack/react-query"),Ia="#FF3B30",Ea="#FF9500",Ma="#FFCC00",ja="#34C759",Xt={critical:Ia,high:Ea,medium:Ma,low:ja},pn={Critical:Xt.critical,High:Xt.high,Medium:Xt.medium,Low:Xt.low};function Oa(t){return pn[t]||pn.Low}function gn(t){if(!t||typeof t!="string")return 0;const e=t.trim().split(":");if(e.length!==3)return 0;const[s,n,r]=e,a=Number.parseInt(s,10),o=Number.parseInt(n,10),l=Number.parseFloat(r||"0"),c=Number.isFinite(a)?a:0,u=Number.isFinite(o)?o:0,f=Number.isFinite(l)?l:0;return c*3600+u*60+f}function Sn(t){return t.toLowerCase().replaceAll("'","").replaceAll("‘","").replaceAll("’","")}class vt extends Error{}class Da extends vt{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class Ca extends vt{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class Ra extends vt{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class It extends vt{}class ar extends vt{constructor(e){super(`Invalid unit ${e}`)}}class Me extends vt{}class rt extends vt{constructor(){super("Zone is an abstract class")}}const T="numeric",_e="short",Pe="long",fs={year:T,month:T,day:T},ir={year:T,month:_e,day:T},Ua={year:T,month:_e,day:T,weekday:_e},or={year:T,month:Pe,day:T},lr={year:T,month:Pe,day:T,weekday:Pe},cr={hour:T,minute:T},ur={hour:T,minute:T,second:T},dr={hour:T,minute:T,second:T,timeZoneName:_e},mr={hour:T,minute:T,second:T,timeZoneName:Pe},fr={hour:T,minute:T,hourCycle:"h23"},hr={hour:T,minute:T,second:T,hourCycle:"h23"},yr={hour:T,minute:T,second:T,hourCycle:"h23",timeZoneName:_e},pr={hour:T,minute:T,second:T,hourCycle:"h23",timeZoneName:Pe},gr={year:T,month:T,day:T,hour:T,minute:T},Sr={year:T,month:T,day:T,hour:T,minute:T,second:T},xr={year:T,month:_e,day:T,hour:T,minute:T},vr={year:T,month:_e,day:T,hour:T,minute:T,second:T},La={year:T,month:_e,day:T,weekday:_e,hour:T,minute:T},wr={year:T,month:Pe,day:T,hour:T,minute:T,timeZoneName:_e},Ar={year:T,month:Pe,day:T,hour:T,minute:T,second:T,timeZoneName:_e},Nr={year:T,month:Pe,day:T,weekday:Pe,hour:T,minute:T,timeZoneName:Pe},Tr={year:T,month:Pe,day:T,weekday:Pe,hour:T,minute:T,second:T,timeZoneName:Pe};class Yt{get type(){throw new rt}get name(){throw new rt}get ianaName(){return this.name}get isUniversal(){throw new rt}offsetName(e,s){throw new rt}formatOffset(e,s){throw new rt}offset(e){throw new rt}equals(e){throw new rt}get isValid(){throw new rt}}let ks=null;class gs extends Yt{static get instance(){return ks===null&&(ks=new gs),ks}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Ur(e,s,n)}formatOffset(e,s){return qt(this.offset(e),s)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}}const Ps=new Map;function Fa(t){let e=Ps.get(t);return e===void 0&&(e=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),Ps.set(t,e)),e}const $a={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function Pa(t,e){const s=t.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(s),[,r,a,o,l,c,u,f]=n;return[o,r,a,l,c,u,f]}function Wa(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:a,value:o}=s[r],l=$a[a];a==="era"?n[l]=o:P(l)||(n[l]=parseInt(o,10))}return n}const Is=new Map;class tt extends Yt{static create(e){let s=Is.get(e);return s===void 0&&Is.set(e,s=new tt(e)),s}static resetCache(){Is.clear(),Ps.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch{return!1}}constructor(e){super(),this.zoneName=e,this.valid=tt.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Ur(e,s,n,this.name)}formatOffset(e,s){return qt(this.offset(e),s)}offset(e){if(!this.valid)return NaN;const s=new Date(e);if(isNaN(s))return NaN;const n=Fa(this.name);let[r,a,o,l,c,u,f]=n.formatToParts?Wa(n,s):Pa(n,s);l==="BC"&&(r=-Math.abs(r)+1);const p=xs({year:r,month:a,day:o,hour:c===24?0:c,minute:u,second:f,millisecond:0});let g=+s;const w=g%1e3;return g-=w>=0?w:1e3+w,(p-g)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let xn={};function Ba(t,e={}){const s=JSON.stringify([t,e]);let n=xn[s];return n||(n=new Intl.ListFormat(t,e),xn[s]=n),n}const Ws=new Map;function Bs(t,e={}){const s=JSON.stringify([t,e]);let n=Ws.get(s);return n===void 0&&(n=new Intl.DateTimeFormat(t,e),Ws.set(s,n)),n}const Vs=new Map;function Va(t,e={}){const s=JSON.stringify([t,e]);let n=Vs.get(s);return n===void 0&&(n=new Intl.NumberFormat(t,e),Vs.set(s,n)),n}const Zs=new Map;function Za(t,e={}){const{base:s,...n}=e,r=JSON.stringify([t,n]);let a=Zs.get(r);return a===void 0&&(a=new Intl.RelativeTimeFormat(t,e),Zs.set(r,a)),a}let Zt=null;function za(){return Zt||(Zt=new Intl.DateTimeFormat().resolvedOptions().locale,Zt)}const zs=new Map;function br(t){let e=zs.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),zs.set(t,e)),e}const Hs=new Map;function Ha(t){let e=Hs.get(t);if(!e){const s=new Intl.Locale(t);e="getWeekInfo"in s?s.getWeekInfo():s.weekInfo,"minimalDays"in e||(e={...kr,...e}),Hs.set(t,e)}return e}function qa(t){const e=t.indexOf("-x-");e!==-1&&(t=t.substring(0,e));const s=t.indexOf("-u-");if(s===-1)return[t];{let n,r;try{n=Bs(t).resolvedOptions(),r=t}catch{const c=t.substring(0,s);n=Bs(c).resolvedOptions(),r=c}const{numberingSystem:a,calendar:o}=n;return[r,a,o]}}function Ga(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function Ya(t){const e=[];for(let s=1;s<=12;s++){const n=$.utc(2009,s,1);e.push(t(n))}return e}function _a(t){const e=[];for(let s=1;s<=7;s++){const n=$.utc(2016,11,13+s);e.push(t(n))}return e}function es(t,e,s,n){const r=t.listingMode();return r==="error"?null:r==="en"?s(e):n(e)}function Ja(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||br(t.locale).numberingSystem==="latn"}class Ka{constructor(e,s,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;const{padTo:r,floor:a,...o}=n;if(!s||Object.keys(o).length>0){const l={useGrouping:!1,...n};n.padTo>0&&(l.minimumIntegerDigits=n.padTo),this.inf=Va(e,l)}}format(e){if(this.inf){const s=this.floor?Math.floor(e):e;return this.inf.format(s)}else{const s=this.floor?Math.floor(e):sn(e,3);return Ae(s,this.padTo)}}}class Qa{constructor(e,s,n){this.opts=n,this.originalZone=void 0;let r;if(this.opts.timeZone)this.dt=e;else if(e.zone.type==="fixed"){const o=-1*(e.offset/60),l=o>=0?`Etc/GMT+${o}`:`Etc/GMT${o}`;e.offset!==0&&tt.create(l).valid?(r=l,this.dt=e):(r="UTC",this.dt=e.offset===0?e:e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type==="system"?this.dt=e:e.zone.type==="iana"?(this.dt=e,r=e.zone.name):(r="UTC",this.dt=e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone);const a={...this.opts};a.timeZone=a.timeZone||r,this.dtf=Bs(s,a)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(s=>{if(s.type==="timeZoneName"){const n=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...s,value:n}}else return s}):e}resolvedOptions(){return this.dtf.resolvedOptions()}}class Xa{constructor(e,s,n){this.opts={style:"long",...n},!s&&Cr()&&(this.rtf=Za(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):wi(s,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,s){return this.rtf?this.rtf.formatToParts(e,s):[]}}const kr={firstDay:1,minimalDays:4,weekend:[6,7]};class ie{static fromOpts(e){return ie.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,s,n,r,a=!1){const o=e||Se.defaultLocale,l=o||(a?"en-US":za()),c=s||Se.defaultNumberingSystem,u=n||Se.defaultOutputCalendar,f=Gs(r)||Se.defaultWeekSettings;return new ie(l,c,u,f,o)}static resetCache(){Zt=null,Ws.clear(),Vs.clear(),Zs.clear(),zs.clear(),Hs.clear()}static fromObject({locale:e,numberingSystem:s,outputCalendar:n,weekSettings:r}={}){return ie.create(e,s,n,r)}constructor(e,s,n,r,a){const[o,l,c]=qa(e);this.locale=o,this.numberingSystem=s||l||null,this.outputCalendar=n||c||null,this.weekSettings=r,this.intl=Ga(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=a,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=Ja(this)),this.fastNumbersCached}listingMode(){const e=this.isEnglish(),s=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return e&&s?"en":"intl"}clone(e){return!e||Object.getOwnPropertyNames(e).length===0?this:ie.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,Gs(e.weekSettings)||this.weekSettings,e.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,s=!1){return es(this,e,$r,()=>{const n=this.intl==="ja"||this.intl.startsWith("ja-");s&=!n;const r=s?{month:e,day:"numeric"}:{month:e},a=s?"format":"standalone";if(!this.monthsCache[a][e]){const o=n?l=>this.dtFormatter(l,r).format():l=>this.extract(l,r,"month");this.monthsCache[a][e]=Ya(o)}return this.monthsCache[a][e]})}weekdays(e,s=!1){return es(this,e,Br,()=>{const n=s?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},r=s?"format":"standalone";return this.weekdaysCache[r][e]||(this.weekdaysCache[r][e]=_a(a=>this.extract(a,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return es(this,void 0,()=>Vr,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[$.utc(2016,11,13,9),$.utc(2016,11,13,19)].map(s=>this.extract(s,e,"dayperiod"))}return this.meridiemCache})}eras(e){return es(this,e,Zr,()=>{const s={era:e};return this.eraCache[e]||(this.eraCache[e]=[$.utc(-40,1,1),$.utc(2017,1,1)].map(n=>this.extract(n,s,"era"))),this.eraCache[e]})}extract(e,s,n){const r=this.dtFormatter(e,s),a=r.formatToParts(),o=a.find(l=>l.type.toLowerCase()===n);return o?o.value:null}numberFormatter(e={}){return new Ka(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new Qa(e,this.intl,s)}relFormatter(e={}){return new Xa(this.intl,this.isEnglish(),e)}listFormatter(e={}){return Ba(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||br(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:Rr()?Ha(this.locale):kr}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let Es=null;class Re extends Yt{static get utcInstance(){return Es===null&&(Es=new Re(0)),Es}static instance(e){return e===0?Re.utcInstance:new Re(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new Re(vs(s[1],s[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${qt(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${qt(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,s){return qt(this.fixed,s)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type==="fixed"&&e.fixed===this.fixed}get isValid(){return!0}}class ei extends Yt{constructor(e){super(),this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function ut(t,e){if(P(t)||t===null)return e;if(t instanceof Yt)return t;if(ii(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?gs.instance:s==="utc"||s==="gmt"?Re.utcInstance:Re.parseSpecifier(s)||tt.create(t)}else return mt(t)?Re.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new ei(t)}const Qs={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},vn={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},ti=Qs.hanidec.replace(/[\[|\]]/g,"").split("");function si(t){let e=parseInt(t,10);if(isNaN(e)){e="";for(let s=0;s<t.length;s++){const n=t.charCodeAt(s);if(t[s].search(Qs.hanidec)!==-1)e+=ti.indexOf(t[s]);else for(const r in vn){const[a,o]=vn[r];n>=a&&n<=o&&(e+=n-a)}}return parseInt(e,10)}else return e}const qs=new Map;function ni(){qs.clear()}function qe({numberingSystem:t},e=""){const s=t||"latn";let n=qs.get(s);n===void 0&&(n=new Map,qs.set(s,n));let r=n.get(e);return r===void 0&&(r=new RegExp(`${Qs[s]}${e}`),n.set(e,r)),r}let wn=()=>Date.now(),An="system",Nn=null,Tn=null,bn=null,kn=60,In,En=null;class Se{static get now(){return wn}static set now(e){wn=e}static set defaultZone(e){An=e}static get defaultZone(){return ut(An,gs.instance)}static get defaultLocale(){return Nn}static set defaultLocale(e){Nn=e}static get defaultNumberingSystem(){return Tn}static set defaultNumberingSystem(e){Tn=e}static get defaultOutputCalendar(){return bn}static set defaultOutputCalendar(e){bn=e}static get defaultWeekSettings(){return En}static set defaultWeekSettings(e){En=Gs(e)}static get twoDigitCutoffYear(){return kn}static set twoDigitCutoffYear(e){kn=e%100}static get throwOnInvalid(){return In}static set throwOnInvalid(e){In=e}static resetCaches(){ie.resetCache(),tt.resetCache(),$.resetCache(),ni()}}class Ye{constructor(e,s){this.reason=e,this.explanation=s}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const Ir=[0,31,59,90,120,151,181,212,243,273,304,334],Er=[0,31,60,91,121,152,182,213,244,274,305,335];function ze(t,e){return new Ye("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function Xs(t,e,s){const n=new Date(Date.UTC(t,e-1,s));t<100&&t>=0&&n.setUTCFullYear(n.getUTCFullYear()-1900);const r=n.getUTCDay();return r===0?7:r}function Mr(t,e,s){return s+(_t(t)?Er:Ir)[e-1]}function jr(t,e){const s=_t(t)?Er:Ir,n=s.findIndex(a=>a<e),r=e-s[n];return{month:n+1,day:r}}function en(t,e){return(t-e+7)%7+1}function hs(t,e=4,s=1){const{year:n,month:r,day:a}=t,o=Mr(n,r,a),l=en(Xs(n,r,a),s);let c=Math.floor((o-l+14-e)/7),u;return c<1?(u=n-1,c=Gt(u,e,s)):c>Gt(n,e,s)?(u=n+1,c=1):u=n,{weekYear:u,weekNumber:c,weekday:l,...ws(t)}}function Mn(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:a}=t,o=en(Xs(n,1,e),s),l=Et(n);let c=r*7+a-o-7+e,u;c<1?(u=n-1,c+=Et(u)):c>l?(u=n+1,c-=Et(n)):u=n;const{month:f,day:m}=jr(u,c);return{year:u,month:f,day:m,...ws(t)}}function Ms(t){const{year:e,month:s,day:n}=t,r=Mr(e,s,n);return{year:e,ordinal:r,...ws(t)}}function jn(t){const{year:e,ordinal:s}=t,{month:n,day:r}=jr(e,s);return{year:e,month:n,day:r,...ws(t)}}function On(t,e){if(!P(t.localWeekday)||!P(t.localWeekNumber)||!P(t.localWeekYear)){if(!P(t.weekday)||!P(t.weekNumber)||!P(t.weekYear))throw new It("Cannot mix locale-based week fields with ISO-based week fields");return P(t.localWeekday)||(t.weekday=t.localWeekday),P(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),P(t.localWeekYear)||(t.weekYear=t.localWeekYear),delete t.localWeekday,delete t.localWeekNumber,delete t.localWeekYear,{minDaysInFirstWeek:e.getMinDaysInFirstWeek(),startOfWeek:e.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function ri(t,e=4,s=1){const n=Ss(t.weekYear),r=He(t.weekNumber,1,Gt(t.weekYear,e,s)),a=He(t.weekday,1,7);return n?r?a?!1:ze("weekday",t.weekday):ze("week",t.weekNumber):ze("weekYear",t.weekYear)}function ai(t){const e=Ss(t.year),s=He(t.ordinal,1,Et(t.year));return e?s?!1:ze("ordinal",t.ordinal):ze("year",t.year)}function Or(t){const e=Ss(t.year),s=He(t.month,1,12),n=He(t.day,1,ys(t.year,t.month));return e?s?n?!1:ze("day",t.day):ze("month",t.month):ze("year",t.year)}function Dr(t){const{hour:e,minute:s,second:n,millisecond:r}=t,a=He(e,0,23)||e===24&&s===0&&n===0&&r===0,o=He(s,0,59),l=He(n,0,59),c=He(r,0,999);return a?o?l?c?!1:ze("millisecond",r):ze("second",n):ze("minute",s):ze("hour",e)}function P(t){return typeof t>"u"}function mt(t){return typeof t=="number"}function Ss(t){return typeof t=="number"&&t%1===0}function ii(t){return typeof t=="string"}function oi(t){return Object.prototype.toString.call(t)==="[object Date]"}function Cr(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function Rr(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function li(t){return Array.isArray(t)?t:[t]}function Dn(t,e,s){if(t.length!==0)return t.reduce((n,r)=>{const a=[e(r),r];return n&&s(n[0],a[0])===n[0]?n:a},null)[1]}function ci(t,e){return e.reduce((s,n)=>(s[n]=t[n],s),{})}function jt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Gs(t){if(t==null)return null;if(typeof t!="object")throw new Me("Week settings must be an object");if(!He(t.firstDay,1,7)||!He(t.minimalDays,1,7)||!Array.isArray(t.weekend)||t.weekend.some(e=>!He(e,1,7)))throw new Me("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function He(t,e,s){return Ss(t)&&t>=e&&t<=s}function ui(t,e){return t-e*Math.floor(t/e)}function Ae(t,e=2){const s=t<0;let n;return s?n="-"+(""+-t).padStart(e,"0"):n=(""+t).padStart(e,"0"),n}function ct(t){if(!(P(t)||t===null||t===""))return parseInt(t,10)}function yt(t){if(!(P(t)||t===null||t===""))return parseFloat(t)}function tn(t){if(!(P(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function sn(t,e,s="round"){const n=10**e;switch(s){case"expand":return t>0?Math.ceil(t*n)/n:Math.floor(t*n)/n;case"trunc":return Math.trunc(t*n)/n;case"round":return Math.round(t*n)/n;case"floor":return Math.floor(t*n)/n;case"ceil":return Math.ceil(t*n)/n;default:throw new RangeError(`Value rounding ${s} is out of range`)}}function _t(t){return t%4===0&&(t%100!==0||t%400===0)}function Et(t){return _t(t)?366:365}function ys(t,e){const s=ui(e-1,12)+1,n=t+(e-s)/12;return s===2?_t(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][s-1]}function xs(t){let e=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second,t.millisecond);return t.year<100&&t.year>=0&&(e=new Date(e),e.setUTCFullYear(t.year,t.month-1,t.day)),+e}function Cn(t,e,s){return-en(Xs(t,1,e),s)+e-1}function Gt(t,e=4,s=1){const n=Cn(t,e,s),r=Cn(t+1,e,s);return(Et(t)-n+r)/7}function Ys(t){return t>99?t:t>Se.twoDigitCutoffYear?1900+t:2e3+t}function Ur(t,e,s,n=null){const r=new Date(t),a={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};n&&(a.timeZone=n);const o={timeZoneName:e,...a},l=new Intl.DateTimeFormat(s,o).formatToParts(r).find(c=>c.type.toLowerCase()==="timezonename");return l?l.value:null}function vs(t,e){let s=parseInt(t,10);Number.isNaN(s)&&(s=0);const n=parseInt(e,10)||0,r=s<0||Object.is(s,-0)?-n:n;return s*60+r}function Lr(t){const e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new Me(`Invalid unit value ${t}`);return e}function ps(t,e){const s={};for(const n in t)if(jt(t,n)){const r=t[n];if(r==null)continue;s[e(n)]=Lr(r)}return s}function qt(t,e){const s=Math.trunc(Math.abs(t/60)),n=Math.trunc(Math.abs(t%60)),r=t>=0?"+":"-";switch(e){case"short":return`${r}${Ae(s,2)}:${Ae(n,2)}`;case"narrow":return`${r}${s}${n>0?`:${n}`:""}`;case"techie":return`${r}${Ae(s,2)}${Ae(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function ws(t){return ci(t,["hour","minute","second","millisecond"])}const di=["January","February","March","April","May","June","July","August","September","October","November","December"],Fr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],mi=["J","F","M","A","M","J","J","A","S","O","N","D"];function $r(t){switch(t){case"narrow":return[...mi];case"short":return[...Fr];case"long":return[...di];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const Pr=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Wr=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],fi=["M","T","W","T","F","S","S"];function Br(t){switch(t){case"narrow":return[...fi];case"short":return[...Wr];case"long":return[...Pr];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const Vr=["AM","PM"],hi=["Before Christ","Anno Domini"],yi=["BC","AD"],pi=["B","A"];function Zr(t){switch(t){case"narrow":return[...pi];case"short":return[...yi];case"long":return[...hi];default:return null}}function gi(t){return Vr[t.hour<12?0:1]}function Si(t,e){return Br(e)[t.weekday-1]}function xi(t,e){return $r(e)[t.month-1]}function vi(t,e){return Zr(e)[t.year<0?0:1]}function wi(t,e,s="always",n=!1){const r={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},a=["hours","minutes","seconds"].indexOf(t)===-1;if(s==="auto"&&a){const m=t==="days";switch(e){case 1:return m?"tomorrow":`next ${r[t][0]}`;case-1:return m?"yesterday":`last ${r[t][0]}`;case 0:return m?"today":`this ${r[t][0]}`}}const o=Object.is(e,-0)||e<0,l=Math.abs(e),c=l===1,u=r[t],f=n?c?u[1]:u[2]||u[1]:c?r[t][0]:t;return o?`${l} ${f} ago`:`in ${l} ${f}`}function Rn(t,e){let s="";for(const n of t)n.literal?s+=n.val:s+=e(n.val);return s}const Ai={D:fs,DD:ir,DDD:or,DDDD:lr,t:cr,tt:ur,ttt:dr,tttt:mr,T:fr,TT:hr,TTT:yr,TTTT:pr,f:gr,ff:xr,fff:wr,ffff:Nr,F:Sr,FF:vr,FFF:Ar,FFFF:Tr};class je{static create(e,s={}){return new je(e,s)}static parseFormat(e){let s=null,n="",r=!1;const a=[];for(let o=0;o<e.length;o++){const l=e.charAt(o);l==="'"?((n.length>0||r)&&a.push({literal:r||/^\s+$/.test(n),val:n===""?"'":n}),s=null,n="",r=!r):r||l===s?n+=l:(n.length>0&&a.push({literal:/^\s+$/.test(n),val:n}),n=l,s=l)}return n.length>0&&a.push({literal:r||/^\s+$/.test(n),val:n}),a}static macroTokenToFormatOpts(e){return Ai[e]}constructor(e,s){this.opts=s,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,s){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...s}).format()}dtFormatter(e,s={}){return this.loc.dtFormatter(e,{...this.opts,...s})}formatDateTime(e,s){return this.dtFormatter(e,s).format()}formatDateTimeParts(e,s){return this.dtFormatter(e,s).formatToParts()}formatInterval(e,s){return this.dtFormatter(e.start,s).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,s){return this.dtFormatter(e,s).resolvedOptions()}num(e,s=0,n=void 0){if(this.opts.forceSimple)return Ae(e,s);const r={...this.opts};return s>0&&(r.padTo=s),n&&(r.signDisplay=n),this.loc.numberFormatter(r).format(e)}formatDateTimeFromString(e,s){const n=this.loc.listingMode()==="en",r=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",a=(g,w)=>this.loc.extract(e,g,w),o=g=>e.isOffsetFixed&&e.offset===0&&g.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,g.format):"",l=()=>n?gi(e):a({hour:"numeric",hourCycle:"h12"},"dayperiod"),c=(g,w)=>n?xi(e,g):a(w?{month:g}:{month:g,day:"numeric"},"month"),u=(g,w)=>n?Si(e,g):a(w?{weekday:g}:{weekday:g,month:"long",day:"numeric"},"weekday"),f=g=>{const w=je.macroTokenToFormatOpts(g);return w?this.formatWithSystemDefault(e,w):g},m=g=>n?vi(e,g):a({era:g},"era"),p=g=>{switch(g){case"S":return this.num(e.millisecond);case"u":case"SSS":return this.num(e.millisecond,3);case"s":return this.num(e.second);case"ss":return this.num(e.second,2);case"uu":return this.num(Math.floor(e.millisecond/10),2);case"uuu":return this.num(Math.floor(e.millisecond/100));case"m":return this.num(e.minute);case"mm":return this.num(e.minute,2);case"h":return this.num(e.hour%12===0?12:e.hour%12);case"hh":return this.num(e.hour%12===0?12:e.hour%12,2);case"H":return this.num(e.hour);case"HH":return this.num(e.hour,2);case"Z":return o({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return o({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return o({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return l();case"d":return r?a({day:"numeric"},"day"):this.num(e.day);case"dd":return r?a({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return u("short",!0);case"cccc":return u("long",!0);case"ccccc":return u("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return u("short",!1);case"EEEE":return u("long",!1);case"EEEEE":return u("narrow",!1);case"L":return r?a({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?a({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return c("short",!0);case"LLLL":return c("long",!0);case"LLLLL":return c("narrow",!0);case"M":return r?a({month:"numeric"},"month"):this.num(e.month);case"MM":return r?a({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return c("short",!1);case"MMMM":return c("long",!1);case"MMMMM":return c("narrow",!1);case"y":return r?a({year:"numeric"},"year"):this.num(e.year);case"yy":return r?a({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?a({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?a({year:"numeric"},"year"):this.num(e.year,6);case"G":return m("short");case"GG":return m("long");case"GGGGG":return m("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return f(g)}};return Rn(je.parseFormat(s),p)}formatDurationFromString(e,s){const n=this.opts.signMode==="negativeLargestOnly"?-1:1,r=f=>{switch(f[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},a=(f,m)=>p=>{const g=r(p);if(g){const w=m.isNegativeDuration&&g!==m.largestUnit?n:1;let j;return this.opts.signMode==="negativeLargestOnly"&&g!==m.largestUnit?j="never":this.opts.signMode==="all"?j="always":j="auto",this.num(f.get(g)*w,p.length,j)}else return p},o=je.parseFormat(s),l=o.reduce((f,{literal:m,val:p})=>m?f:f.concat(p),[]),c=e.shiftTo(...l.map(r).filter(f=>f)),u={isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]};return Rn(o,a(c,u))}}const zr=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Dt(...t){const e=t.reduce((s,n)=>s+n.source,"");return RegExp(`^${e}$`)}function Ct(...t){return e=>t.reduce(([s,n,r],a)=>{const[o,l,c]=a(e,r);return[{...s,...o},l||n,c]},[{},null,1]).slice(0,2)}function Rt(t,...e){if(t==null)return[null,null];for(const[s,n]of e){const r=s.exec(t);if(r)return n(r)}return[null,null]}function Hr(...t){return(e,s)=>{const n={};let r;for(r=0;r<t.length;r++)n[t[r]]=ct(e[s+r]);return[n,null,s+r]}}const qr=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,Ni=`(?:${qr.source}?(?:\\[(${zr.source})\\])?)?`,nn=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Gr=RegExp(`${nn.source}${Ni}`),rn=RegExp(`(?:[Tt]${Gr.source})?`),Ti=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,bi=/(\d{4})-?W(\d\d)(?:-?(\d))?/,ki=/(\d{4})-?(\d{3})/,Ii=Hr("weekYear","weekNumber","weekDay"),Ei=Hr("year","ordinal"),Mi=/(\d{4})-(\d\d)-(\d\d)/,Yr=RegExp(`${nn.source} ?(?:${qr.source}|(${zr.source}))?`),ji=RegExp(`(?: ${Yr.source})?`);function Mt(t,e,s){const n=t[e];return P(n)?s:ct(n)}function Oi(t,e){return[{year:Mt(t,e),month:Mt(t,e+1,1),day:Mt(t,e+2,1)},null,e+3]}function Ut(t,e){return[{hours:Mt(t,e,0),minutes:Mt(t,e+1,0),seconds:Mt(t,e+2,0),milliseconds:tn(t[e+3])},null,e+4]}function Jt(t,e){const s=!t[e]&&!t[e+1],n=vs(t[e+1],t[e+2]),r=s?null:Re.instance(n);return[{},r,e+3]}function Kt(t,e){const s=t[e]?tt.create(t[e]):null;return[{},s,e+1]}const Di=RegExp(`^T?${nn.source}$`),Ci=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function Ri(t){const[e,s,n,r,a,o,l,c,u]=t,f=e[0]==="-",m=c&&c[0]==="-",p=(g,w=!1)=>g!==void 0&&(w||g&&f)?-g:g;return[{years:p(yt(s)),months:p(yt(n)),weeks:p(yt(r)),days:p(yt(a)),hours:p(yt(o)),minutes:p(yt(l)),seconds:p(yt(c),c==="-0"),milliseconds:p(tn(u),m)}]}const Ui={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function an(t,e,s,n,r,a,o){const l={year:e.length===2?Ys(ct(e)):ct(e),month:Fr.indexOf(s)+1,day:ct(n),hour:ct(r),minute:ct(a)};return o&&(l.second=ct(o)),t&&(l.weekday=t.length>3?Pr.indexOf(t)+1:Wr.indexOf(t)+1),l}const Li=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function Fi(t){const[,e,s,n,r,a,o,l,c,u,f,m]=t,p=an(e,r,n,s,a,o,l);let g;return c?g=Ui[c]:u?g=0:g=vs(f,m),[p,new Re(g)]}function $i(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const Pi=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,Wi=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,Bi=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function Un(t){const[,e,s,n,r,a,o,l]=t;return[an(e,r,n,s,a,o,l),Re.utcInstance]}function Vi(t){const[,e,s,n,r,a,o,l]=t;return[an(e,l,s,n,r,a,o),Re.utcInstance]}const Zi=Dt(Ti,rn),zi=Dt(bi,rn),Hi=Dt(ki,rn),qi=Dt(Gr),_r=Ct(Oi,Ut,Jt,Kt),Gi=Ct(Ii,Ut,Jt,Kt),Yi=Ct(Ei,Ut,Jt,Kt),_i=Ct(Ut,Jt,Kt);function Ji(t){return Rt(t,[Zi,_r],[zi,Gi],[Hi,Yi],[qi,_i])}function Ki(t){return Rt($i(t),[Li,Fi])}function Qi(t){return Rt(t,[Pi,Un],[Wi,Un],[Bi,Vi])}function Xi(t){return Rt(t,[Ci,Ri])}const eo=Ct(Ut);function to(t){return Rt(t,[Di,eo])}const so=Dt(Mi,ji),no=Dt(Yr),ro=Ct(Ut,Jt,Kt);function ao(t){return Rt(t,[so,_r],[no,ro])}const Ln="Invalid Duration",Jr={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},io={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...Jr},Be=146097/400,Nt=146097/4800,oo={years:{quarters:4,months:12,weeks:Be/7,days:Be,hours:Be*24,minutes:Be*24*60,seconds:Be*24*60*60,milliseconds:Be*24*60*60*1e3},quarters:{months:3,weeks:Be/28,days:Be/4,hours:Be*24/4,minutes:Be*24*60/4,seconds:Be*24*60*60/4,milliseconds:Be*24*60*60*1e3/4},months:{weeks:Nt/7,days:Nt,hours:Nt*24,minutes:Nt*24*60,seconds:Nt*24*60*60,milliseconds:Nt*24*60*60*1e3},...Jr},gt=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],lo=gt.slice(0).reverse();function Qe(t,e,s=!1){const n={values:s?e.values:{...t.values,...e.values||{}},loc:t.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||t.conversionAccuracy,matrix:e.matrix||t.matrix};return new K(n)}function Kr(t,e){let s=e.milliseconds??0;for(const n of lo.slice(1))e[n]&&(s+=e[n]*t[n].milliseconds);return s}function Fn(t,e){const s=Kr(t,e)<0?-1:1;gt.reduceRight((n,r)=>{if(P(e[r]))return n;if(n){const a=e[n]*s,o=t[r][n],l=Math.floor(a/o);e[r]+=l*s,e[n]-=l*o*s}return r},null),gt.reduce((n,r)=>{if(P(e[r]))return n;if(n){const a=e[n]%1;e[n]-=a,e[r]+=a*t[n][r]}return r},null)}function $n(t){const e={};for(const[s,n]of Object.entries(t))n!==0&&(e[s]=n);return e}class K{constructor(e){const s=e.conversionAccuracy==="longterm"||!1;let n=s?oo:io;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||ie.create(),this.conversionAccuracy=s?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=n,this.isLuxonDuration=!0}static fromMillis(e,s){return K.fromObject({milliseconds:e},s)}static fromObject(e,s={}){if(e==null||typeof e!="object")throw new Me(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new K({values:ps(e,K.normalizeUnit),loc:ie.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(mt(e))return K.fromMillis(e);if(K.isDuration(e))return e;if(typeof e=="object")return K.fromObject(e);throw new Me(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,s){const[n]=Xi(e);return n?K.fromObject(n,s):K.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,s){const[n]=to(e);return n?K.fromObject(n,s):K.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,s=null){if(!e)throw new Me("need to specify a reason the Duration is invalid");const n=e instanceof Ye?e:new Ye(e,s);if(Se.throwOnInvalid)throw new Ra(n);return new K({invalid:n})}static normalizeUnit(e){const s={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[e&&e.toLowerCase()];if(!s)throw new ar(e);return s}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,s={}){const n={...s,floor:s.round!==!1&&s.floor!==!1};return this.isValid?je.create(this.loc,n).formatDurationFromString(this,e):Ln}toHuman(e={}){if(!this.isValid)return Ln;const s=e.showZeros!==!1,n=gt.map(r=>{const a=this.values[r];return P(a)||a===0&&!s?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:r.slice(0,-1)}).format(a)}).filter(r=>r);return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(n)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e="P";return this.years!==0&&(e+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+"M"),this.weeks!==0&&(e+=this.weeks+"W"),this.days!==0&&(e+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+="T"),this.hours!==0&&(e+=this.hours+"H"),this.minutes!==0&&(e+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(e+=sn(this.seconds+this.milliseconds/1e3,3)+"S"),e==="P"&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;const s=this.toMillis();return s<0||s>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e,includeOffset:!1},$.fromMillis(s,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?Kr(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e),n={};for(const r of gt)(jt(s.values,r)||jt(this.values,r))&&(n[r]=s.get(r)+this.get(r));return Qe(this,{values:n},!0)}minus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e);return this.plus(s.negate())}mapUnits(e){if(!this.isValid)return this;const s={};for(const n of Object.keys(this.values))s[n]=Lr(e(this.values[n],n));return Qe(this,{values:s},!0)}get(e){return this[K.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const s={...this.values,...ps(e,K.normalizeUnit)};return Qe(this,{values:s})}reconfigure({locale:e,numberingSystem:s,conversionAccuracy:n,matrix:r}={}){const o={loc:this.loc.clone({locale:e,numberingSystem:s}),matrix:r,conversionAccuracy:n};return Qe(this,o)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return Fn(this.matrix,e),Qe(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=$n(this.normalize().shiftToAll().toObject());return Qe(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(o=>K.normalizeUnit(o));const s={},n={},r=this.toObject();let a;for(const o of gt)if(e.indexOf(o)>=0){a=o;let l=0;for(const u in n)l+=this.matrix[u][o]*n[u],n[u]=0;mt(r[o])&&(l+=r[o]);const c=Math.trunc(l);s[o]=c,n[o]=(l*1e3-c*1e3)/1e3}else mt(r[o])&&(n[o]=r[o]);for(const o in n)n[o]!==0&&(s[a]+=o===a?n[o]:n[o]/this.matrix[a][o]);return Fn(this.matrix,s),Qe(this,{values:s},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const e={};for(const s of Object.keys(this.values))e[s]=this.values[s]===0?0:-this.values[s];return Qe(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=$n(this.values);return Qe(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function s(n,r){return n===void 0||n===0?r===void 0||r===0:n===r}for(const n of gt)if(!s(this.values[n],e.values[n]))return!1;return!0}}const Tt="Invalid Interval";function co(t,e){return!t||!t.isValid?ge.invalid("missing or invalid start"):!e||!e.isValid?ge.invalid("missing or invalid end"):e<t?ge.invalid("end before start",`The end of an interval must be after its start, but you had start=${t.toISO()} and end=${e.toISO()}`):null}class ge{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,s=null){if(!e)throw new Me("need to specify a reason the Interval is invalid");const n=e instanceof Ye?e:new Ye(e,s);if(Se.throwOnInvalid)throw new Ca(n);return new ge({invalid:n})}static fromDateTimes(e,s){const n=Bt(e),r=Bt(s),a=co(n,r);return a??new ge({start:n,end:r})}static after(e,s){const n=K.fromDurationLike(s),r=Bt(e);return ge.fromDateTimes(r,r.plus(n))}static before(e,s){const n=K.fromDurationLike(s),r=Bt(e);return ge.fromDateTimes(r.minus(n),r)}static fromISO(e,s){const[n,r]=(e||"").split("/",2);if(n&&r){let a,o;try{a=$.fromISO(n,s),o=a.isValid}catch{o=!1}let l,c;try{l=$.fromISO(r,s),c=l.isValid}catch{c=!1}if(o&&c)return ge.fromDateTimes(a,l);if(o){const u=K.fromISO(r,s);if(u.isValid)return ge.after(a,u)}else if(c){const u=K.fromISO(n,s);if(u.isValid)return ge.before(l,u)}}return ge.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(e).get(e):NaN}count(e="milliseconds",s){if(!this.isValid)return NaN;const n=this.start.startOf(e,s);let r;return s?.useLocaleWeeks?r=this.end.reconfigure({locale:n.locale}):r=this.end,r=r.startOf(e,s),Math.floor(r.diff(n,e).get(e))+(r.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:e,end:s}={}){return this.isValid?ge.fromDateTimes(e||this.s,s||this.e):this}splitAt(...e){if(!this.isValid)return[];const s=e.map(Bt).filter(o=>this.contains(o)).sort((o,l)=>o.toMillis()-l.toMillis()),n=[];let{s:r}=this,a=0;for(;r<this.e;){const o=s[a]||this.e,l=+o>+this.e?this.e:o;n.push(ge.fromDateTimes(r,l)),r=l,a+=1}return n}splitBy(e){const s=K.fromDurationLike(e);if(!this.isValid||!s.isValid||s.as("milliseconds")===0)return[];let{s:n}=this,r=1,a;const o=[];for(;n<this.e;){const l=this.start.plus(s.mapUnits(c=>c*r));a=+l>+this.e?this.e:l,o.push(ge.fromDateTimes(n,a)),n=a,r+=1}return o}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;const s=this.s>e.s?this.s:e.s,n=this.e<e.e?this.e:e.e;return s>=n?null:ge.fromDateTimes(s,n)}union(e){if(!this.isValid)return this;const s=this.s<e.s?this.s:e.s,n=this.e>e.e?this.e:e.e;return ge.fromDateTimes(s,n)}static merge(e){const[s,n]=e.sort((r,a)=>r.s-a.s).reduce(([r,a],o)=>a?a.overlaps(o)||a.abutsStart(o)?[r,a.union(o)]:[r.concat([a]),o]:[r,o],[[],null]);return n&&s.push(n),s}static xor(e){let s=null,n=0;const r=[],a=e.map(c=>[{time:c.s,type:"s"},{time:c.e,type:"e"}]),o=Array.prototype.concat(...a),l=o.sort((c,u)=>c.time-u.time);for(const c of l)n+=c.type==="s"?1:-1,n===1?s=c.time:(s&&+s!=+c.time&&r.push(ge.fromDateTimes(s,c.time)),s=null);return ge.merge(r)}difference(...e){return ge.xor([this].concat(e)).map(s=>this.intersection(s)).filter(s=>s&&!s.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:Tt}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=fs,s={}){return this.isValid?je.create(this.s.loc.clone(s),e).formatInterval(this):Tt}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:Tt}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Tt}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:Tt}toFormat(e,{separator:s=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${s}${this.e.toFormat(e)}`:Tt}toDuration(e,s){return this.isValid?this.e.diff(this.s,e,s):K.invalid(this.invalidReason)}mapEndpoints(e){return ge.fromDateTimes(e(this.s),e(this.e))}}class ts{static hasDST(e=Se.defaultZone){const s=$.now().setZone(e).set({month:12});return!e.isUniversal&&s.offset!==s.set({month:6}).offset}static isValidIANAZone(e){return tt.isValidZone(e)}static normalizeZone(e){return ut(e,Se.defaultZone)}static getStartOfWeek({locale:e=null,locObj:s=null}={}){return(s||ie.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:s=null}={}){return(s||ie.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:s=null}={}){return(s||ie.create(e)).getWeekendDays().slice()}static months(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||ie.create(s,n,a)).months(e)}static monthsFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||ie.create(s,n,a)).months(e,!0)}static weekdays(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||ie.create(s,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||ie.create(s,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return ie.create(e).meridiems()}static eras(e="short",{locale:s=null}={}){return ie.create(s,null,"gregory").eras(e)}static features(){return{relative:Cr(),localeWeek:Rr()}}}function Pn(t,e){const s=r=>r.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),n=s(e)-s(t);return Math.floor(K.fromMillis(n).as("days"))}function uo(t,e,s){const n=[["years",(c,u)=>u.year-c.year],["quarters",(c,u)=>u.quarter-c.quarter+(u.year-c.year)*4],["months",(c,u)=>u.month-c.month+(u.year-c.year)*12],["weeks",(c,u)=>{const f=Pn(c,u);return(f-f%7)/7}],["days",Pn]],r={},a=t;let o,l;for(const[c,u]of n)s.indexOf(c)>=0&&(o=c,r[c]=u(t,e),l=a.plus(r),l>e?(r[c]--,t=a.plus(r),t>e&&(l=t,r[c]--,t=a.plus(r))):t=l);return[t,r,l,o]}function mo(t,e,s,n){let[r,a,o,l]=uo(t,e,s);const c=e-r,u=s.filter(m=>["hours","minutes","seconds","milliseconds"].indexOf(m)>=0);u.length===0&&(o<e&&(o=r.plus({[l]:1})),o!==r&&(a[l]=(a[l]||0)+c/(o-r)));const f=K.fromObject(a,n);return u.length>0?K.fromMillis(c,n).shiftTo(...u).plus(f):f}const fo="missing Intl.DateTimeFormat.formatToParts support";function se(t,e=s=>s){return{regex:t,deser:([s])=>e(si(s))}}const ho=" ",Qr=`[ ${ho}]`,Xr=new RegExp(Qr,"g");function yo(t){return t.replace(/\./g,"\\.?").replace(Xr,Qr)}function Wn(t){return t.replace(/\./g,"").replace(Xr," ").toLowerCase()}function Ge(t,e){return t===null?null:{regex:RegExp(t.map(yo).join("|")),deser:([s])=>t.findIndex(n=>Wn(s)===Wn(n))+e}}function Bn(t,e){return{regex:t,deser:([,s,n])=>vs(s,n),groups:e}}function ss(t){return{regex:t,deser:([e])=>e}}function po(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function go(t,e){const s=qe(e),n=qe(e,"{2}"),r=qe(e,"{3}"),a=qe(e,"{4}"),o=qe(e,"{6}"),l=qe(e,"{1,2}"),c=qe(e,"{1,3}"),u=qe(e,"{1,6}"),f=qe(e,"{1,9}"),m=qe(e,"{2,4}"),p=qe(e,"{4,6}"),g=E=>({regex:RegExp(po(E.val)),deser:([C])=>C,literal:!0}),j=(E=>{if(t.literal)return g(E);switch(E.val){case"G":return Ge(e.eras("short"),0);case"GG":return Ge(e.eras("long"),0);case"y":return se(u);case"yy":return se(m,Ys);case"yyyy":return se(a);case"yyyyy":return se(p);case"yyyyyy":return se(o);case"M":return se(l);case"MM":return se(n);case"MMM":return Ge(e.months("short",!0),1);case"MMMM":return Ge(e.months("long",!0),1);case"L":return se(l);case"LL":return se(n);case"LLL":return Ge(e.months("short",!1),1);case"LLLL":return Ge(e.months("long",!1),1);case"d":return se(l);case"dd":return se(n);case"o":return se(c);case"ooo":return se(r);case"HH":return se(n);case"H":return se(l);case"hh":return se(n);case"h":return se(l);case"mm":return se(n);case"m":return se(l);case"q":return se(l);case"qq":return se(n);case"s":return se(l);case"ss":return se(n);case"S":return se(c);case"SSS":return se(r);case"u":return ss(f);case"uu":return ss(l);case"uuu":return se(s);case"a":return Ge(e.meridiems(),0);case"kkkk":return se(a);case"kk":return se(m,Ys);case"W":return se(l);case"WW":return se(n);case"E":case"c":return se(s);case"EEE":return Ge(e.weekdays("short",!1),1);case"EEEE":return Ge(e.weekdays("long",!1),1);case"ccc":return Ge(e.weekdays("short",!0),1);case"cccc":return Ge(e.weekdays("long",!0),1);case"Z":case"ZZ":return Bn(new RegExp(`([+-]${l.source})(?::(${n.source}))?`),2);case"ZZZ":return Bn(new RegExp(`([+-]${l.source})(${n.source})?`),2);case"z":return ss(/[a-z_+-/]{1,256}?/i);case" ":return ss(/[^\S\n\r]/);default:return g(E)}})(t)||{invalidReason:fo};return j.token=t,j}const So={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function xo(t,e,s){const{type:n,value:r}=t;if(n==="literal"){const c=/^\s+$/.test(r);return{literal:!c,val:c?" ":r}}const a=e[n];let o=n;n==="hour"&&(e.hour12!=null?o=e.hour12?"hour12":"hour24":e.hourCycle!=null?e.hourCycle==="h11"||e.hourCycle==="h12"?o="hour12":o="hour24":o=s.hour12?"hour12":"hour24");let l=So[o];if(typeof l=="object"&&(l=l[a]),l)return{literal:!1,val:l}}function vo(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function wo(t,e,s){const n=t.match(e);if(n){const r={};let a=1;for(const o in s)if(jt(s,o)){const l=s[o],c=l.groups?l.groups+1:1;!l.literal&&l.token&&(r[l.token.val[0]]=l.deser(n.slice(a,a+c))),a+=c}return[n,r]}else return[n,{}]}function Ao(t){const e=a=>{switch(a){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let s=null,n;return P(t.z)||(s=tt.create(t.z)),P(t.Z)||(s||(s=new Re(t.Z)),n=t.Z),P(t.q)||(t.M=(t.q-1)*3+1),P(t.h)||(t.h<12&&t.a===1?t.h+=12:t.h===12&&t.a===0&&(t.h=0)),t.G===0&&t.y&&(t.y=-t.y),P(t.u)||(t.S=tn(t.u)),[Object.keys(t).reduce((a,o)=>{const l=e(o);return l&&(a[l]=t[o]),a},{}),s,n]}let js=null;function No(){return js||(js=$.fromMillis(1555555555555)),js}function To(t,e){if(t.literal)return t;const s=je.macroTokenToFormatOpts(t.val),n=na(s,e);return n==null||n.includes(void 0)?t:n}function ea(t,e){return Array.prototype.concat(...t.map(s=>To(s,e)))}class ta{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=ea(je.parseFormat(s),e),this.units=this.tokens.map(n=>go(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=vo(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=wo(e,this.regex,this.handlers),[r,a,o]=n?Ao(n):[null,null,void 0];if(jt(n,"a")&&jt(n,"H"))throw new It("Can't include meridiem when specifying 24-hour format");return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:s,matches:n,result:r,zone:a,specificOffset:o}}else return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function sa(t,e,s){return new ta(t,s).explainFromTokens(e)}function bo(t,e,s){const{result:n,zone:r,specificOffset:a,invalidReason:o}=sa(t,e,s);return[n,r,a,o]}function na(t,e){if(!t)return null;const n=je.create(e,t).dtFormatter(No()),r=n.formatToParts(),a=n.resolvedOptions();return r.map(o=>xo(o,t,a))}const Os="Invalid DateTime",Vn=864e13;function zt(t){return new Ye("unsupported zone",`the zone "${t.name}" is not supported`)}function Ds(t){return t.weekData===null&&(t.weekData=hs(t.c)),t.weekData}function Cs(t){return t.localWeekData===null&&(t.localWeekData=hs(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function pt(t,e){const s={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new $({...s,...e,old:s})}function ra(t,e,s){let n=t-e*60*1e3;const r=s.offset(n);if(e===r)return[n,e];n-=(r-e)*60*1e3;const a=s.offset(n);return r===a?[n,r]:[t-Math.min(r,a)*60*1e3,Math.max(r,a)]}function ns(t,e){t+=e*60*1e3;const s=new Date(t);return{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),hour:s.getUTCHours(),minute:s.getUTCMinutes(),second:s.getUTCSeconds(),millisecond:s.getUTCMilliseconds()}}function cs(t,e,s){return ra(xs(t),e,s)}function Zn(t,e){const s=t.o,n=t.c.year+Math.trunc(e.years),r=t.c.month+Math.trunc(e.months)+Math.trunc(e.quarters)*3,a={...t.c,year:n,month:r,day:Math.min(t.c.day,ys(n,r))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},o=K.fromObject({years:e.years-Math.trunc(e.years),quarters:e.quarters-Math.trunc(e.quarters),months:e.months-Math.trunc(e.months),weeks:e.weeks-Math.trunc(e.weeks),days:e.days-Math.trunc(e.days),hours:e.hours,minutes:e.minutes,seconds:e.seconds,milliseconds:e.milliseconds}).as("milliseconds"),l=xs(a);let[c,u]=ra(l,s,t.zone);return o!==0&&(c+=o,u=t.zone.offset(c)),{ts:c,o:u}}function bt(t,e,s,n,r,a){const{setZone:o,zone:l}=s;if(t&&Object.keys(t).length!==0||e){const c=e||l,u=$.fromObject(t,{...s,zone:c,specificOffset:a});return o?u:u.setZone(l)}else return $.invalid(new Ye("unparsable",`the input "${r}" can't be parsed as ${n}`))}function rs(t,e,s=!0){return t.isValid?je.create(ie.create("en-US"),{allowZ:s,forceSimple:!0}).formatDateTimeFromString(t,e):null}function Rs(t,e,s){const n=t.c.year>9999||t.c.year<0;let r="";if(n&&t.c.year>=0&&(r+="+"),r+=Ae(t.c.year,n?6:4),s==="year")return r;if(e){if(r+="-",r+=Ae(t.c.month),s==="month")return r;r+="-"}else if(r+=Ae(t.c.month),s==="month")return r;return r+=Ae(t.c.day),r}function zn(t,e,s,n,r,a,o){let l=!s||t.c.millisecond!==0||t.c.second!==0,c="";switch(o){case"day":case"month":case"year":break;default:if(c+=Ae(t.c.hour),o==="hour")break;if(e){if(c+=":",c+=Ae(t.c.minute),o==="minute")break;l&&(c+=":",c+=Ae(t.c.second))}else{if(c+=Ae(t.c.minute),o==="minute")break;l&&(c+=Ae(t.c.second))}if(o==="second")break;l&&(!n||t.c.millisecond!==0)&&(c+=".",c+=Ae(t.c.millisecond,3))}return r&&(t.isOffsetFixed&&t.offset===0&&!a?c+="Z":t.o<0?(c+="-",c+=Ae(Math.trunc(-t.o/60)),c+=":",c+=Ae(Math.trunc(-t.o%60))):(c+="+",c+=Ae(Math.trunc(t.o/60)),c+=":",c+=Ae(Math.trunc(t.o%60)))),a&&(c+="["+t.zone.ianaName+"]"),c}const aa={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},ko={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},Io={ordinal:1,hour:0,minute:0,second:0,millisecond:0},us=["year","month","day","hour","minute","second","millisecond"],Eo=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],Mo=["year","ordinal","hour","minute","second","millisecond"];function ds(t){const e={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[t.toLowerCase()];if(!e)throw new ar(t);return e}function Hn(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return ds(t)}}function jo(t){if(Ht===void 0&&(Ht=Se.now()),t.type!=="iana")return t.offset(Ht);const e=t.name;let s=_s.get(e);return s===void 0&&(s=t.offset(Ht),_s.set(e,s)),s}function qn(t,e){const s=ut(e.zone,Se.defaultZone);if(!s.isValid)return $.invalid(zt(s));const n=ie.fromObject(e);let r,a;if(P(t.year))r=Se.now();else{for(const c of us)P(t[c])&&(t[c]=aa[c]);const o=Or(t)||Dr(t);if(o)return $.invalid(o);const l=jo(s);[r,a]=cs(t,l,s)}return new $({ts:r,zone:s,loc:n,o:a})}function Gn(t,e,s){const n=P(s.round)?!0:s.round,r=P(s.rounding)?"trunc":s.rounding,a=(l,c)=>(l=sn(l,n||s.calendary?0:2,s.calendary?"round":r),e.loc.clone(s).relFormatter(s).format(l,c)),o=l=>s.calendary?e.hasSame(t,l)?0:e.startOf(l).diff(t.startOf(l),l).get(l):e.diff(t,l).get(l);if(s.unit)return a(o(s.unit),s.unit);for(const l of s.units){const c=o(l);if(Math.abs(c)>=1)return a(c,l)}return a(t>e?-0:0,s.units[s.units.length-1])}function Yn(t){let e={},s;return t.length>0&&typeof t[t.length-1]=="object"?(e=t[t.length-1],s=Array.from(t).slice(0,t.length-1)):s=Array.from(t),[e,s]}let Ht;const _s=new Map;class ${constructor(e){const s=e.zone||Se.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Ye("invalid input"):null)||(s.isValid?null:zt(s));this.ts=P(e.ts)?Se.now():e.ts;let r=null,a=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(s))[r,a]=[e.old.c,e.old.o];else{const l=mt(e.o)&&!e.old?e.o:s.offset(this.ts);r=ns(this.ts,l),n=Number.isNaN(r.year)?new Ye("invalid input"):null,r=n?null:r,a=n?null:l}this._zone=s,this.loc=e.loc||ie.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=a,this.isLuxonDateTime=!0}static now(){return new $({})}static local(){const[e,s]=Yn(arguments),[n,r,a,o,l,c,u]=s;return qn({year:n,month:r,day:a,hour:o,minute:l,second:c,millisecond:u},e)}static utc(){const[e,s]=Yn(arguments),[n,r,a,o,l,c,u]=s;return e.zone=Re.utcInstance,qn({year:n,month:r,day:a,hour:o,minute:l,second:c,millisecond:u},e)}static fromJSDate(e,s={}){const n=oi(e)?e.valueOf():NaN;if(Number.isNaN(n))return $.invalid("invalid input");const r=ut(s.zone,Se.defaultZone);return r.isValid?new $({ts:n,zone:r,loc:ie.fromObject(s)}):$.invalid(zt(r))}static fromMillis(e,s={}){if(mt(e))return e<-Vn||e>Vn?$.invalid("Timestamp out of range"):new $({ts:e,zone:ut(s.zone,Se.defaultZone),loc:ie.fromObject(s)});throw new Me(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,s={}){if(mt(e))return new $({ts:e*1e3,zone:ut(s.zone,Se.defaultZone),loc:ie.fromObject(s)});throw new Me("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=ut(s.zone,Se.defaultZone);if(!n.isValid)return $.invalid(zt(n));const r=ie.fromObject(s),a=ps(e,Hn),{minDaysInFirstWeek:o,startOfWeek:l}=On(a,r),c=Se.now(),u=P(s.specificOffset)?n.offset(c):s.specificOffset,f=!P(a.ordinal),m=!P(a.year),p=!P(a.month)||!P(a.day),g=m||p,w=a.weekYear||a.weekNumber;if((g||f)&&w)throw new It("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(p&&f)throw new It("Can't mix ordinal dates with month/day");const j=w||a.weekday&&!g;let E,C,O=ns(c,u);j?(E=Eo,C=ko,O=hs(O,o,l)):f?(E=Mo,C=Io,O=Ms(O)):(E=us,C=aa);let W=!1;for(const S of E){const M=a[S];P(M)?W?a[S]=C[S]:a[S]=O[S]:W=!0}const b=j?ri(a,o,l):f?ai(a):Or(a),R=b||Dr(a);if(R)return $.invalid(R);const B=j?Mn(a,o,l):f?jn(a):a,[U,q]=cs(B,u,n),y=new $({ts:U,zone:n,o:q,loc:r});return a.weekday&&g&&e.weekday!==y.weekday?$.invalid("mismatched weekday",`you can't specify both a weekday of ${a.weekday} and a date of ${y.toISO()}`):y.isValid?y:$.invalid(y.invalid)}static fromISO(e,s={}){const[n,r]=Ji(e);return bt(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=Ki(e);return bt(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=Qi(e);return bt(n,r,s,"HTTP",s)}static fromFormat(e,s,n={}){if(P(e)||P(s))throw new Me("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:a=null}=n,o=ie.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0}),[l,c,u,f]=bo(o,e,s);return f?$.invalid(f):bt(l,c,n,`format ${s}`,e,u)}static fromString(e,s,n={}){return $.fromFormat(e,s,n)}static fromSQL(e,s={}){const[n,r]=ao(e);return bt(n,r,s,"SQL",e)}static invalid(e,s=null){if(!e)throw new Me("need to specify a reason the DateTime is invalid");const n=e instanceof Ye?e:new Ye(e,s);if(Se.throwOnInvalid)throw new Da(n);return new $({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,s={}){const n=na(e,ie.fromObject(s));return n?n.map(r=>r?r.val:null).join(""):null}static expandFormat(e,s={}){return ea(je.parseFormat(e),ie.fromObject(s)).map(r=>r.val).join("")}static resetCache(){Ht=void 0,_s.clear()}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?Ds(this).weekYear:NaN}get weekNumber(){return this.isValid?Ds(this).weekNumber:NaN}get weekday(){return this.isValid?Ds(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Cs(this).weekday:NaN}get localWeekNumber(){return this.isValid?Cs(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Cs(this).weekYear:NaN}get ordinal(){return this.isValid?Ms(this.c).ordinal:NaN}get monthShort(){return this.isValid?ts.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?ts.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?ts.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?ts.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const e=864e5,s=6e4,n=xs(this.c),r=this.zone.offset(n-e),a=this.zone.offset(n+e),o=this.zone.offset(n-r*s),l=this.zone.offset(n-a*s);if(o===l)return[this];const c=n-o*s,u=n-l*s,f=ns(c,o),m=ns(u,l);return f.hour===m.hour&&f.minute===m.minute&&f.second===m.second&&f.millisecond===m.millisecond?[pt(this,{ts:c}),pt(this,{ts:u})]:[this]}get isInLeapYear(){return _t(this.year)}get daysInMonth(){return ys(this.year,this.month)}get daysInYear(){return this.isValid?Et(this.year):NaN}get weeksInWeekYear(){return this.isValid?Gt(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Gt(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:s,numberingSystem:n,calendar:r}=je.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:s,numberingSystem:n,outputCalendar:r}}toUTC(e=0,s={}){return this.setZone(Re.instance(e),s)}toLocal(){return this.setZone(Se.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=ut(e,Se.defaultZone),e.equals(this.zone))return this;if(e.isValid){let r=this.ts;if(s||n){const a=e.offset(this.ts),o=this.toObject();[r]=cs(o,a,e)}return pt(this,{ts:r,zone:e})}else return $.invalid(zt(e))}reconfigure({locale:e,numberingSystem:s,outputCalendar:n}={}){const r=this.loc.clone({locale:e,numberingSystem:s,outputCalendar:n});return pt(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const s=ps(e,Hn),{minDaysInFirstWeek:n,startOfWeek:r}=On(s,this.loc),a=!P(s.weekYear)||!P(s.weekNumber)||!P(s.weekday),o=!P(s.ordinal),l=!P(s.year),c=!P(s.month)||!P(s.day),u=l||c,f=s.weekYear||s.weekNumber;if((u||o)&&f)throw new It("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(c&&o)throw new It("Can't mix ordinal dates with month/day");let m;a?m=Mn({...hs(this.c,n,r),...s},n,r):P(s.ordinal)?(m={...this.toObject(),...s},P(s.day)&&(m.day=Math.min(ys(m.year,m.month),m.day))):m=jn({...Ms(this.c),...s});const[p,g]=cs(m,this.o,this.zone);return pt(this,{ts:p,o:g})}plus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e);return pt(this,Zn(this,s))}minus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e).negate();return pt(this,Zn(this,s))}startOf(e,{useLocaleWeeks:s=!1}={}){if(!this.isValid)return this;const n={},r=K.normalizeUnit(e);switch(r){case"years":n.month=1;case"quarters":case"months":n.day=1;case"weeks":case"days":n.hour=0;case"hours":n.minute=0;case"minutes":n.second=0;case"seconds":n.millisecond=0;break}if(r==="weeks")if(s){const a=this.loc.getStartOfWeek(),{weekday:o}=this;o<a&&(n.weekNumber=this.weekNumber-1),n.weekday=a}else n.weekday=1;if(r==="quarters"){const a=Math.ceil(this.month/3);n.month=(a-1)*3+1}return this.set(n)}endOf(e,s){return this.isValid?this.plus({[e]:1}).startOf(e,s).minus(1):this}toFormat(e,s={}){return this.isValid?je.create(this.loc.redefaultToEN(s)).formatDateTimeFromString(this,e):Os}toLocaleString(e=fs,s={}){return this.isValid?je.create(this.loc.clone(s),e).formatDateTime(this):Os}toLocaleParts(e={}){return this.isValid?je.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:s=!1,suppressMilliseconds:n=!1,includeOffset:r=!0,extendedZone:a=!1,precision:o="milliseconds"}={}){if(!this.isValid)return null;o=ds(o);const l=e==="extended";let c=Rs(this,l,o);return us.indexOf(o)>=3&&(c+="T"),c+=zn(this,l,s,n,r,a,o),c}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?Rs(this,e==="extended",ds(s)):null}toISOWeekDate(){return rs(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:s=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:a=!1,format:o="extended",precision:l="milliseconds"}={}){return this.isValid?(l=ds(l),(r&&us.indexOf(l)>=3?"T":"")+zn(this,o==="extended",s,e,n,a,l)):null}toRFC2822(){return rs(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return rs(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?Rs(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:s=!1,includeOffsetSpace:n=!0}={}){let r="HH:mm:ss.SSS";return(s||e)&&(n&&(r+=" "),s?r+="z":e&&(r+="ZZ")),rs(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Os}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};const s={...this.c};return e.includeConfig&&(s.outputCalendar=this.outputCalendar,s.numberingSystem=this.loc.numberingSystem,s.locale=this.loc.locale),s}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,s="milliseconds",n={}){if(!this.isValid||!e.isValid)return K.invalid("created by diffing an invalid DateTime");const r={locale:this.locale,numberingSystem:this.numberingSystem,...n},a=li(s).map(K.normalizeUnit),o=e.valueOf()>this.valueOf(),l=o?this:e,c=o?e:this,u=mo(l,c,a,r);return o?u.negate():u}diffNow(e="milliseconds",s={}){return this.diff($.now(),e,s)}until(e){return this.isValid?ge.fromDateTimes(this,e):this}hasSame(e,s,n){if(!this.isValid)return!1;const r=e.valueOf(),a=this.setZone(e.zone,{keepLocalTime:!0});return a.startOf(s,n)<=r&&r<=a.endOf(s,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;const s=e.base||$.fromObject({},{zone:this.zone}),n=e.padding?this<s?-e.padding:e.padding:0;let r=["years","months","days","hours","minutes","seconds"],a=e.unit;return Array.isArray(e.unit)&&(r=e.unit,a=void 0),Gn(s,this.plus(n),{...e,numeric:"always",units:r,unit:a})}toRelativeCalendar(e={}){return this.isValid?Gn(e.base||$.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every($.isDateTime))throw new Me("min requires all arguments be DateTimes");return Dn(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every($.isDateTime))throw new Me("max requires all arguments be DateTimes");return Dn(e,s=>s.valueOf(),Math.max)}static fromFormatExplain(e,s,n={}){const{locale:r=null,numberingSystem:a=null}=n,o=ie.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});return sa(o,e,s)}static fromStringExplain(e,s,n={}){return $.fromFormatExplain(e,s,n)}static buildFormatParser(e,s={}){const{locale:n=null,numberingSystem:r=null}=s,a=ie.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new ta(a,e)}static fromFormatParser(e,s,n={}){if(P(e)||P(s))throw new Me("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:a=null}=n,o=ie.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});if(!o.equals(s.locale))throw new Me(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${s.locale}`);const{result:l,zone:c,specificOffset:u,invalidReason:f}=s.explainFromTokens(e);return f?$.invalid(f):bt(l,c,n,`format ${s.format}`,e,u)}static get DATE_SHORT(){return fs}static get DATE_MED(){return ir}static get DATE_MED_WITH_WEEKDAY(){return Ua}static get DATE_FULL(){return or}static get DATE_HUGE(){return lr}static get TIME_SIMPLE(){return cr}static get TIME_WITH_SECONDS(){return ur}static get TIME_WITH_SHORT_OFFSET(){return dr}static get TIME_WITH_LONG_OFFSET(){return mr}static get TIME_24_SIMPLE(){return fr}static get TIME_24_WITH_SECONDS(){return hr}static get TIME_24_WITH_SHORT_OFFSET(){return yr}static get TIME_24_WITH_LONG_OFFSET(){return pr}static get DATETIME_SHORT(){return gr}static get DATETIME_SHORT_WITH_SECONDS(){return Sr}static get DATETIME_MED(){return xr}static get DATETIME_MED_WITH_SECONDS(){return vr}static get DATETIME_MED_WITH_WEEKDAY(){return La}static get DATETIME_FULL(){return wr}static get DATETIME_FULL_WITH_SECONDS(){return Ar}static get DATETIME_HUGE(){return Nr}static get DATETIME_HUGE_WITH_SECONDS(){return Tr}}function Bt(t){if($.isDateTime(t))return t;if(t&&t.valueOf&&mt(t.valueOf()))return $.fromJSDate(t);if(t&&typeof t=="object")return $.fromObject(t);throw new Me(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function Oo(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function Do(t,e){try{const s=$.fromJSDate(t,{zone:"utc"}).setZone(e),n=s.toJSDate().toLocaleString("en-US",{timeZone:e,timeZoneName:"short"}).split(" ").pop()||void 0,r=s.toFormat("ZZ")||void 0;return{abbr:n,offset:r}}catch{return{}}}function Co(t){if(!t)return"-";try{const e=new Date(t),s=u=>String(u).padStart(2,"0"),n=s(e.getMonth()+1),r=s(e.getDate()),a=e.getFullYear(),o=s(e.getHours()),l=s(e.getMinutes()),c=s(e.getSeconds());return`${n}/${r}/${a} ${o}:${l}:${c}`}catch{return"-"}}function Ot(t,e="UTC",s=!1){if(!t)return"-";const n=$.fromISO(t,{zone:"utc"}).setZone(e);if(!n.isValid)return"-";const r=n.offsetNameShort,a=n.toFormat("ZZZZ"),o=r.startsWith("GMT")||r===a?a:`${r}/${a}`,l=s?"MM/dd/yyyy, hh:mm:ss.SSS a":"MM/dd/yyyy, hh:mm:ss a";return`${n.toFormat(l)} (${o})`}const ia="",Ro=ia,Uo="",Lo="",Fo="",$o="",_n={snl:{alerts:ia,rules:Ro},schools:{alerts:Uo,rules:Lo},transit:{alerts:Fo,rules:$o}};class Po extends Error{statusCode;status;envelope;constructor(e){super(e.errorMessage||e.message||`HTTP ${e.statusCode}`),this.name="ApiError",this.statusCode=e.statusCode,this.status=e.statusCode,this.envelope=e}}function Ee(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Wo(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Vt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}const Bo=["responseStatus","errorMessage","statusCode"];function Vo(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Bo.some(e=>e in t)}function Jn(t,e,s){if(Vo(t)){const r=Number(t.statusCode)||e,a=typeof t.responseStatus=="boolean"?t.responseStatus:s&&r<400,o=t.errorMessage??t.message??"",l="data"in t?t.data:null;return{data:l,errorMessage:o,statusCode:r,responseStatus:a,message:o||(typeof l=="string"?l:""),raw:t}}const n=typeof t=="string"?t:t?.message??"";return{data:t,errorMessage:s?"":n||`HTTP ${e}`,statusCode:e,responseStatus:s,message:n,raw:t}}async function dt(t,e){const s={...e.headers,...Wo()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return Jn({},n.status,n.ok);const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}return Jn(a,n.status,n.ok)}async function on(t,e){const s=await dt(t,e);if(!s.responseStatus)throw new Po(s);return s.data}async function lt(t,e){const s=await on(t,e);return Array.isArray(s)?s:[]}async function Us(t,e){const s=await on(t,e);return s&&typeof s=="object"&&!Array.isArray(s)?s:null}function Zo(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Ee(t.baseUrl,"/api/Alert"),r=Vt(n,{page:s?.pageNumber??1,pageSize:s?.pageSize??10,...s?.anomalyId!==void 0&&{anomalyId:s.anomalyId},...s?.spaceId!==void 0&&{spaceId:s.spaceId},...s?.severityName!==void 0&&{severity:s.severityName},...s?.thirdPartyIds?.length&&{thirdPartyIds:s.thirdPartyIds.join(",")},...s?.searchText&&{searchText:s.searchText},isArchived:s?.isArchived??!1}),a=await lt(r,{method:"GET",headers:e}),o=a.length>0?a[0].totalRecords??a.length:0;return{items:a,total:o}},async getAlertStatusList(){const s=Ee(t.baseUrl,"/api/Alert/AlertStatusList");return lt(s,{method:"GET",headers:e})},async getAlertsReport(s){const n=Ee(t.baseUrl,"/Alerts/GetAlertsReport"),r=Vt(n,s);return lt(r,{method:"GET",headers:e})},async updateAlertStatus(s){const n=Ee(t.baseUrl,"/api/Alert/status");return dt(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAlertTimeline(s){const n=Ee(t.baseUrl,`/api/Alert/alertTimelines/${s}`);return lt(n,{method:"GET",headers:e})},async getAdminSettings(){const s=Ee(t.baseUrl,"/api/Alert/GetAdminSettings");return Us(s,{method:"GET",headers:e})},async setAdminSettings(s){const n=Ee(t.baseUrl,"/api/Alert/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return dt(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Ee(t.baseUrl,"/api/Alert/GetPreferenceSettings");return Us(s,{method:"GET",headers:e})},async setPreferenceSettings(s){const n=Ee(t.baseUrl,"/api/Alert/SetPreferenceSettings");return dt(n,{method:"POST",headers:e,body:JSON.stringify(s??{})})},async getAlertNotifications(s){const n=Ee(t.baseUrl,"/api/Alert/GetNotifications"),r=Vt(n,{alertId:s});return lt(r,{method:"GET",headers:e})},async notifyFamilyMembers(s){const n=Ee(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=Vt(n,{alertId:s});return dt(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const a=Ee(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),o=Vt(a,{alertId:s,isEmail:n,isSMS:r});return dt(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Ee(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters");return lt(s,{method:"GET",headers:e})},async getMyAppPreferences(){const s=Ee(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Us(s,{method:"GET",headers:e});return n?.timeZoneUniqueId?{timeZoneUniqueId:n.timeZoneUniqueId}:null},async getAllSpaces(){const s=Ee(t.baseUrl,"/api/Spaces/GetAllSpaces");return(await lt(s,{method:"GET",headers:e})).map(r=>({spaceId:r?.spaceId??r?.SpaceId,spaceName:r?.spaceName??r?.SpaceName??""}))}}}function zo(t){const e={"Content-Type":"application/json",...t.headers||{}},s=Ee(t.baseUrl,"/api/Rules"),n=Ee(t.baseUrl,"/api/Rules/lookups");return{async getRules(){return lt(s,{method:"GET",headers:e})},async setEscalationSettings(r){return dt(s,{method:"POST",headers:e,body:JSON.stringify(r??{})})},async getLookups(){return on(n,{method:"GET",headers:e})},async updateRule(r,a){const o=`${s}/${r}`;return dt(o,{method:"PUT",headers:e,body:JSON.stringify(a??{})})}}}function Ho(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ms={exports:{}},qo=ms.exports,Kn;function Go(){return Kn||(Kn=1,(function(t,e){(function(s,n){t.exports=n()})(qo,(function(){var s=1e3,n=6e4,r=36e5,a="millisecond",o="second",l="minute",c="hour",u="day",f="week",m="month",p="quarter",g="year",w="date",j="Invalid Date",E=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,C=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,O={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(I){var A=["th","st","nd","rd"],x=I%100;return"["+I+(A[(x-20)%10]||A[x]||A[0])+"]"}},W=function(I,A,x){var k=String(I);return!k||k.length>=A?I:""+Array(A+1-k.length).join(x)+I},b={s:W,z:function(I){var A=-I.utcOffset(),x=Math.abs(A),k=Math.floor(x/60),N=x%60;return(A<=0?"+":"-")+W(k,2,"0")+":"+W(N,2,"0")},m:function I(A,x){if(A.date()<x.date())return-I(x,A);var k=12*(x.year()-A.year())+(x.month()-A.month()),N=A.clone().add(k,m),D=x-N<0,L=A.clone().add(k+(D?-1:1),m);return+(-(k+(x-N)/(D?N-L:L-N))||0)},a:function(I){return I<0?Math.ceil(I)||0:Math.floor(I)},p:function(I){return{M:m,y:g,w:f,d:u,D:w,h:c,m:l,s:o,ms:a,Q:p}[I]||String(I||"").toLowerCase().replace(/s$/,"")},u:function(I){return I===void 0}},R="en",B={};B[R]=O;var U="$isDayjsObject",q=function(I){return I instanceof oe||!(!I||!I[U])},y=function I(A,x,k){var N;if(!A)return R;if(typeof A=="string"){var D=A.toLowerCase();B[D]&&(N=D),x&&(B[D]=x,N=D);var L=A.split("-");if(!N&&L.length>1)return I(L[0])}else{var Y=A.name;B[Y]=A,N=Y}return!k&&N&&(R=N),N||!k&&R},S=function(I,A){if(q(I))return I.clone();var x=typeof A=="object"?A:{};return x.date=I,x.args=arguments,new oe(x)},M=b;M.l=y,M.i=q,M.w=function(I,A){return S(I,{locale:A.$L,utc:A.$u,x:A.$x,$offset:A.$offset})};var oe=(function(){function I(x){this.$L=y(x.locale,null,!0),this.parse(x),this.$x=this.$x||x.x||{},this[U]=!0}var A=I.prototype;return A.parse=function(x){this.$d=(function(k){var N=k.date,D=k.utc;if(N===null)return new Date(NaN);if(M.u(N))return new Date;if(N instanceof Date)return new Date(N);if(typeof N=="string"&&!/Z$/i.test(N)){var L=N.match(E);if(L){var Y=L[2]-1||0,J=(L[7]||"0").substring(0,3);return D?new Date(Date.UTC(L[1],Y,L[3]||1,L[4]||0,L[5]||0,L[6]||0,J)):new Date(L[1],Y,L[3]||1,L[4]||0,L[5]||0,L[6]||0,J)}}return new Date(N)})(x),this.init()},A.init=function(){var x=this.$d;this.$y=x.getFullYear(),this.$M=x.getMonth(),this.$D=x.getDate(),this.$W=x.getDay(),this.$H=x.getHours(),this.$m=x.getMinutes(),this.$s=x.getSeconds(),this.$ms=x.getMilliseconds()},A.$utils=function(){return M},A.isValid=function(){return this.$d.toString()!==j},A.isSame=function(x,k){var N=S(x);return this.startOf(k)<=N&&N<=this.endOf(k)},A.isAfter=function(x,k){return S(x)<this.startOf(k)},A.isBefore=function(x,k){return this.endOf(k)<S(x)},A.$g=function(x,k,N){return M.u(x)?this[k]:this.set(N,x)},A.unix=function(){return Math.floor(this.valueOf()/1e3)},A.valueOf=function(){return this.$d.getTime()},A.startOf=function(x,k){var N=this,D=!!M.u(k)||k,L=M.p(x),Y=function(Te,he){var le=M.w(N.$u?Date.UTC(N.$y,he,Te):new Date(N.$y,he,Te),N);return D?le:le.endOf(u)},J=function(Te,he){return M.w(N.toDate()[Te].apply(N.toDate("s"),(D?[0,0,0,0]:[23,59,59,999]).slice(he)),N)},G=this.$W,Q=this.$M,ce=this.$D,ke="set"+(this.$u?"UTC":"");switch(L){case g:return D?Y(1,0):Y(31,11);case m:return D?Y(1,Q):Y(0,Q+1);case f:var ee=this.$locale().weekStart||0,ye=(G<ee?G+7:G)-ee;return Y(D?ce-ye:ce+(6-ye),Q);case u:case w:return J(ke+"Hours",0);case c:return J(ke+"Minutes",1);case l:return J(ke+"Seconds",2);case o:return J(ke+"Milliseconds",3);default:return this.clone()}},A.endOf=function(x){return this.startOf(x,!1)},A.$set=function(x,k){var N,D=M.p(x),L="set"+(this.$u?"UTC":""),Y=(N={},N[u]=L+"Date",N[w]=L+"Date",N[m]=L+"Month",N[g]=L+"FullYear",N[c]=L+"Hours",N[l]=L+"Minutes",N[o]=L+"Seconds",N[a]=L+"Milliseconds",N)[D],J=D===u?this.$D+(k-this.$W):k;if(D===m||D===g){var G=this.clone().set(w,1);G.$d[Y](J),G.init(),this.$d=G.set(w,Math.min(this.$D,G.daysInMonth())).$d}else Y&&this.$d[Y](J);return this.init(),this},A.set=function(x,k){return this.clone().$set(x,k)},A.get=function(x){return this[M.p(x)]()},A.add=function(x,k){var N,D=this;x=Number(x);var L=M.p(k),Y=function(Q){var ce=S(D);return M.w(ce.date(ce.date()+Math.round(Q*x)),D)};if(L===m)return this.set(m,this.$M+x);if(L===g)return this.set(g,this.$y+x);if(L===u)return Y(1);if(L===f)return Y(7);var J=(N={},N[l]=n,N[c]=r,N[o]=s,N)[L]||1,G=this.$d.getTime()+x*J;return M.w(G,this)},A.subtract=function(x,k){return this.add(-1*x,k)},A.format=function(x){var k=this,N=this.$locale();if(!this.isValid())return N.invalidDate||j;var D=x||"YYYY-MM-DDTHH:mm:ssZ",L=M.z(this),Y=this.$H,J=this.$m,G=this.$M,Q=N.weekdays,ce=N.months,ke=N.meridiem,ee=function(he,le,Le,X){return he&&(he[le]||he(k,D))||Le[le].slice(0,X)},ye=function(he){return M.s(Y%12||12,he,"0")},Te=ke||function(he,le,Le){var X=he<12?"AM":"PM";return Le?X.toLowerCase():X};return D.replace(C,(function(he,le){return le||(function(Le){switch(Le){case"YY":return String(k.$y).slice(-2);case"YYYY":return M.s(k.$y,4,"0");case"M":return G+1;case"MM":return M.s(G+1,2,"0");case"MMM":return ee(N.monthsShort,G,ce,3);case"MMMM":return ee(ce,G);case"D":return k.$D;case"DD":return M.s(k.$D,2,"0");case"d":return String(k.$W);case"dd":return ee(N.weekdaysMin,k.$W,Q,2);case"ddd":return ee(N.weekdaysShort,k.$W,Q,3);case"dddd":return Q[k.$W];case"H":return String(Y);case"HH":return M.s(Y,2,"0");case"h":return ye(1);case"hh":return ye(2);case"a":return Te(Y,J,!0);case"A":return Te(Y,J,!1);case"m":return String(J);case"mm":return M.s(J,2,"0");case"s":return String(k.$s);case"ss":return M.s(k.$s,2,"0");case"SSS":return M.s(k.$ms,3,"0");case"Z":return L}return null})(he)||L.replace(":","")}))},A.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},A.diff=function(x,k,N){var D,L=this,Y=M.p(k),J=S(x),G=(J.utcOffset()-this.utcOffset())*n,Q=this-J,ce=function(){return M.m(L,J)};switch(Y){case g:D=ce()/12;break;case m:D=ce();break;case p:D=ce()/3;break;case f:D=(Q-G)/6048e5;break;case u:D=(Q-G)/864e5;break;case c:D=Q/r;break;case l:D=Q/n;break;case o:D=Q/s;break;default:D=Q}return N?D:M.a(D)},A.daysInMonth=function(){return this.endOf(m).$D},A.$locale=function(){return B[this.$L]},A.locale=function(x,k){if(!x)return this.$L;var N=this.clone(),D=y(x,k,!0);return D&&(N.$L=D),N},A.clone=function(){return M.w(this.$d,this)},A.toDate=function(){return new Date(this.valueOf())},A.toJSON=function(){return this.isValid()?this.toISOString():null},A.toISOString=function(){return this.$d.toISOString()},A.toString=function(){return this.$d.toUTCString()},I})(),fe=oe.prototype;return S.prototype=fe,[["$ms",a],["$s",o],["$m",l],["$H",c],["$W",u],["$M",m],["$y",g],["$D",w]].forEach((function(I){fe[I[1]]=function(A){return this.$g(A,I[0],I[1])}})),S.extend=function(I,A){return I.$i||(I(A,oe,S),I.$i=!0),S},S.locale=y,S.isDayjs=q,S.unix=function(I){return S(1e3*I)},S.en=B[R],S.Ls=B,S.p={},S}))})(ms)),ms.exports}var Yo=Go();const _o=Ho(Yo);function oa(t){if(!t)return"By Severity";const e=t.trim().toLowerCase();return e.includes("created")?"By Created Date":e.includes("updated")||e.includes("modified")?"By Updated Date":"By Severity"}function la(t){if(!t||typeof t!="string")return{hours:0,minutes:0,seconds:0};const e=t.split(":").map(a=>parseInt(a,10)),s=Number.isFinite(e[0])?e[0]:0,n=Number.isFinite(e[1])?e[1]:0,r=Number.isFinite(e[2])?e[2]:0;return{hours:s,minutes:n,seconds:r}}function Qn(t){const{hours:e,minutes:s,seconds:n}=la(t);return _o().hour(e).minute(s).second(n).millisecond(0)}function De(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Jo(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function as(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Ce(t,e){const s={...e.headers,...Jo()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.Message||`HTTP ${n.status}`;throw new Error(o)}return a}const me=(...t)=>t.find(e=>e!=null);function kt(t,e,s={}){const n={};for(const r of e){const a=s[r]??r.charAt(0).toUpperCase()+r.slice(1);n[r]=t?.[a]??t?.[r]}return n}function Ko(t){return Array.isArray(t)?t.map(e=>kt(e,["alertLogId","alertId","status","description","actionNotes","createdDate","createdBy","modifiedDate","modifiedBy"])):t}function Qo(t){return{id:String(me(t?.AlertId,t?.alertId)??""),alertNumber:me(t?.AlertNumber,t?.alertNumber),priority:me(t?.Priority,t?.priority,"Low"),timestamp:me(t?.UpdatedUtc,t?.timestamp,""),statusType:me(t?.Status,t?.statusType,""),description:me(t?.Description,t?.description,""),eventName:me(t?.EventName,t?.eventName),ruleName:me(t?.RuleName,t?.ruleName),spaceId:me(t?.SpaceId,t?.spaceId),spaceName:me(t?.SpaceName,t?.spaceName),anomalyId:me(t?.AnomalyId,t?.anomalyId),severityId:me(t?.SeverityId,t?.severityId),assignTeam:me(t?.AssignTeam,t?.assignTeam),cameraName:me(t?.CameraName,t?.cameraName),type:me(t?.Type,t?.type),mediaDetails:me(t?.MediaDetails,t?.mediaDetails,t?.MediaUrls,t?.mediaUrls),additionalMedia:me(t?.AdditionalMedia,t?.additionalMedia),timeElapsed:me(t?.TimeElapsed,t?.timeElapsed),timeRemaining:me(t?.TimeRemaining,t?.timeRemaining),anomalyName:me(t?.AnomalyName,t?.anomalyName),alertDetails:me(t?.AlertDetails,t?.alertDetails),statusHistory:Ko(me(t?.StatusHistory,t?.statusHistory)),isEmailSent:me(t?.IsEmailSent,t?.isEmailSent),isSMSSent:me(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:me(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function Xo(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts"),r=as(n,{customerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",pageSize:s?.pageSize??10,page:s?.pageNumber??1,...s?.anomalyId!==void 0&&{anomalyId:s.anomalyId},...s?.spaceId!==void 0&&{spaceId:s.spaceId},...s?.severityId!==void 0&&{severityId:s.severityId},...s?.thirdPartyIds?.length&&{ThirdPartyIds:s.thirdPartyIds.join(",")},...s?.searchText&&{searchText:s.searchText},isArchived:s?.isArchived??!1}),a=await Ce(r,{method:"GET",headers:e});return{items:Array.isArray(a?.Items)?a.Items.map(Qo):[],total:a?.Total}},async getAlertStatusList(){const s=De(t.baseUrl,"/api/detectionpolicy/alerts/StatusList"),n=await Ce(s,{method:"GET",headers:e});return(Array.isArray(n)?n:[]).map(a=>kt(a,["alertStatusId","value","statusName"]))},async getAlertsReport(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),r=as(n,s),a=await Ce(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/Log"),r={AlertId:s.alertId??s.alertUniqueId??s.AlertId,Status:s.status??s.Status??"",Notes:s.notes??s.Notes??""};return Ce(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getAlertTimeline(s){const n=De(t.baseUrl,`/api/detectionpolicy/alerts/alertTimelines/${s}`),r=await Ce(n,{method:"GET",headers:e});return(Array.isArray(r)?r:[]).map(o=>kt(o,["alertUniqueId","timeElapsed","eventName","timeStamp"]))},async getAdminSettings(){const s=De(t.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),n=await Ce(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n.Data??n;if(r&&typeof r=="object")return kt(r,["userId","isAdminSetting","sortBy"],{sortBy:"SortOption"})}return null},async setAdminSettings(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/SetAdminSettings"),r={Settings:{UserId:0,IsAdminSetting:!0,SortOption:s?.sortBy??"",GroupBy:s?.groupBy??null}};return Ce(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=De(t.baseUrl,"/api/detectionpolicy/alerts/GetPreferenceSettings"),n=await Ce(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),r=u=>{const{hours:f,minutes:m,seconds:p}=la(u);return(f*3600+m*60+p)*1e7},a={Settings:{UserId:0,AnomalyIds:Array.isArray(s?.anomalyIds)?s.anomalyIds.map(u=>String(u)):[],DoNotDisturbStart:{Ticks:r(s?.doNotDisturbStart)},DoNotDisturbEnd:{Ticks:r(s?.doNotDisturbEnd)},InApp:!!s?.inApp,SMS:!!s?.sms,Email:!!s?.email,SortBy:s?.sortBy??""}},o=await Ce(n,{method:"POST",headers:e,body:JSON.stringify(a)}),l=o?.responseStatus??!0,c=o?.data??o?.message??"Preferences updated successfully.";return{responseStatus:l,errorMessage:l?"":o?.errorMessage??o?.Message??o?.message??"",statusCode:200,data:c}},async sendSMSorEmailNotifications(s,n,r){const a=De(t.baseUrl,"/api/detectionpolicy/alerts/SendSMSorEmailNotifications"),o=as(a,{alertId:s,isEmail:n,isSMS:r});return Ce(o,{method:"POST",headers:e})},async getAlertNotifications(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),r=as(n,{alertId:s}),a=await Ce(r,{method:"GET",headers:e});let o=[];return Array.isArray(a)?o=a:Array.isArray(a?.data)&&(o=a.data),o.map(l=>kt(l,["alertNotificationSentId","alertId","notificationType","receipientName","receipentPhoneNumber","messageSID","messageStatus","receipientEmail","notificationReceipientType","sentAt"]))},async getTimeZoneMasters(){const s=De(t.baseUrl,"/api/TimeZoneMaster"),n=await Ce(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n.Data:[]).map(a=>kt(a,["timeZoneUniqueId","ianaTimeZoneId","timeZoneName","offset"]))},async getAllSpaces(){const s=t.spacesBaseUrl||t.baseUrl,n=De(s,"/api/AllSpaces"),r=await Ce(n,{method:"GET",headers:e});return(Array.isArray(r?.Data)?r.Data:[]).map(o=>({spaceId:o?.SpaceId??o?.spaceId,spaceName:o?.SpaceName??o?.spaceName??""}))},async getMyAppPreferences(){const s=De(t.baseUrl,"/MyProfile"),n=await Ce(s,{method:"GET",headers:e}),r=n?.data?.userGuid??n?.Data?.userGuid??n?.userGuid;if(!r)return null;const a=De(t.baseUrl,`/api/GetMyAppPreferences/${r}`),o=await Ce(a,{method:"GET",headers:e});if(o&&typeof o=="object"){const l=o.data??o.Data??o,c=l?.timeZoneUniqueId??l?.TimeZoneUniqueId;if(c)return{timeZoneUniqueId:c}}return null}}}function el(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Xe(t,e){const s={...e.headers,...el()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function tl(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/api/detectionpolicy/rules",t.baseUrl).toString();return{async getRules(){const n=await Xe(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n?.Data:[]).map(a=>({...a,ruleId:a.ruleId??a.RuleId,ruleName:a.ruleName??a.RuleName??a.Name,escalationSettings:a.escalationSettings??a.EscalationSettings}))},async setEscalationSettings(n){return Xe(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=y=>new URL(y,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[Xe(n("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:e}),Xe(n("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:e}),Xe(n("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:e}),Xe(n("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:e}),Xe(n("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:e}),Xe(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,l,c,u,f,m]=await Promise.allSettled(a),p=y=>{if(y.status!=="fulfilled")return[];const S=y.value;return Array.isArray(S)?S:Array.isArray(S?.Data)?S.Data:Array.isArray(S?.data)?S.data:[]},g=p(o),w=p(l),j=p(c),E=p(u),C=p(f),O=m.status==="fulfilled"?m.value:null;let W=[];Array.isArray(O)?W=O:Array.isArray(O?.Data)?W=O.Data:Array.isArray(O?.data)&&(W=O.data);const b=g.map(y=>({actionTypeId:Number(y?.ActionTypeId),name:y?.DisplayName??y?.Name??""})),R=w.map(y=>({AnomalyId:y?.AnomalyId,DisplayName:y?.DisplayName??y?.Name??""})),B=j.map(y=>({thirdPartyId:Number(y?.ThirdPartyId),thirdPartyName:y?.ThirdPartyName??y?.Name??""})),U=W.map(y=>({userRoleId:y.UserRoleId??y.userRoleId??y.Id??y.id??0,userRoleName:y.UserRoleName??y.userRoleName??y.Name??y.name??""})),q={actionTypes:b,anomalies:R,thirdParties:B};return E.length&&(q.severities=E.map(y=>({severityId:y?.SeverityId??y?.severityId,severityName:y?.DisplayName??y?.SeverityName??y?.Name??y?.name??""}))),C.length&&(q.scheduleTypes=C),U.length&&(q.userRoles=U),q},async updateRule(n,r){const a=`${s}/${n}`,{escalationSettings:o,Anomaly:l,Severity:c,...u}=r??{};return Xe(a,{method:"PUT",headers:e,body:JSON.stringify({...u,CustomerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",Version:{DeDupWindowSeconds:0,IncludeSubjectInHash:!0},AnomalyId:l?.AnomalyId,SeverityId:c?.SeverityId,EscalationSettings:o?{...o,ThirdPartyIds:o.thirdPartyId??[]}:{}})})}}}function sl(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function at(t,e){const s={...e.headers,...sl()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function nl(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/list-rule",t.baseUrl).toString();return{async getRules(){const n=await at(s,{method:"POST",headers:e,body:JSON.stringify({command:"get-all"})});return(Array.isArray(n?.data)?n.data:[]).map(a=>({...a,ruleId:a.RuleId??a.ruleId,ruleName:a.RuleName??a.ruleName,ruleDesc:a.RuleDesc??a.ruleDesc??null}))},async setEscalationSettings(n){return at(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=U=>new URL(U,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[at(n("/api/ActionTypeMaster/GetAll"),{method:"GET",headers:e}),at(n("/api/anomaly/anomaly-list"),{method:"POST",headers:e,body:JSON.stringify({RuleLevel:1})}),at(n("/api/Lookup/ThirdParties"),{method:"GET",headers:e}),at(n("/api/anomaly/severity-list"),{method:"GET",headers:e}),at(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,l,c,u,f]=await Promise.allSettled(a),m=U=>{if(U.status!=="fulfilled")return[];const q=U.value;return Array.isArray(q)?q:Array.isArray(q?.data)?q.data:[]},p=m(o),g=m(l),w=m(c),j=m(u),E=f.status==="fulfilled"?f.value:null,C=p.map(U=>({actionTypeId:U?.ActionTypeUniqueId,name:U?.Name??""})),O=g.map(U=>({recordId:U?.AnomalyId,anomalyName:U?.DisplayName??U?.Name??""})),W=w.map(U=>({thirdPartyId:Number(U?.ThirdPartyId),thirdPartyName:U?.ThirdPartyName??U?.Name??""}));let b=[];Array.isArray(E)?b=E:Array.isArray(E?.Data)?b=E.Data:Array.isArray(E?.data)&&(b=E.data);const R=b.map(U=>({userRoleId:U.userRoleId??0,userRoleName:U.userRoleName??""})),B={actionTypes:C,anomalies:O,thirdParties:W};return j.length&&(B.severities=j.map(U=>({SeverityId:U.SeverityId,DisplayName:U.SeverityName??U.DisplayName??""}))),R.length&&(B.userRoles=R),B},async updateRule(n,r){const a=new URL("/update-rule",t.baseUrl).toString(),{escalationSettings:o,ruleId:l,ruleName:c,ruleDesc:u,...f}=r??{},m=o??{},p=(m.escalationSettingsActionTypeIds??[]).filter(w=>w!=null&&!Number.isNaN(w)),g={Level1UserRoleId:m.level1UserRoleId??0,Level1PostAssistTime:m.level1PostAssistTime??0,Level2UserRoleId:m.level2UserRoleId??0,Level2PostAssistTime:m.level2PostAssistTime??0,Level3UserRoleId:m.level3UserRoleId??0,Level3PostAssistTime:m.level3PostAssistTime??0,EscalationSettingsActionTypeIds:p,ThirdPartyIds:m.thirdPartyId??[],HumanLoop:m.humanLoop??!1};return at(a,{method:"POST",headers:e,body:JSON.stringify({...f,RuleId:l??f.RuleId??n,RuleName:c??f.RuleName,RuleDesc:u??f.RuleDesc??null,ActionTypeUniqueIdList:p,EscalationSettings:g})})}}}function Ve(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function rl(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function is(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Ze(t,e){const s={...e.headers,...rl()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function al(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Ve(t.baseUrl,"/api/Alerts"),r=is(n,{pageSize:s?.pageSize??10,pageNumber:s?.pageNumber??1,...s?.spaceNumber!==void 0&&{spaceNumber:s.spaceNumber},...s?.anomalyId!==void 0&&{anomalyId:s.anomalyId},...s?.severityId!==void 0&&{severityId:s.severityId},...s?.thirdPartyIds?.length&&{thirdPartyIds:s.thirdPartyIds.join(",")},...s?.isArchived!==void 0&&{isArchived:s.isArchived}}),a=await Ze(r,{method:"GET",headers:e});if(Array.isArray(a))return a;if(a&&typeof a=="object"){if(Array.isArray(a.items))return{items:a.items,total:typeof a.total=="number"?a.total:void 0};if(Array.isArray(a.data))return{items:a.data,total:typeof a.total=="number"?a.total:void 0};if(Array.isArray(a.alerts))return{items:a.alerts,total:typeof a.total=="number"?a.total:void 0}}return[]},async getAlertStatusList(){const s=Ve(t.baseUrl,"/api/Alerts/GetAlertStatus"),n=await Ze(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getAlertsReport(s){const n=Ve(t.baseUrl,"/Alerts/GetAlertsReport"),r=is(n,s),a=await Ze(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Ve(t.baseUrl,"/api/Alerts/UpdateAlertLog"),r={alertId:s.alertId,action:s.status,notes:s.notes};return Ze(n,{method:"PUT",headers:e,body:JSON.stringify(r??{})})},async getAdminSettings(){const s=Ve(t.baseUrl,"/api/Alerts/GetAdminSettings"),n=await Ze(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("userId"in n)return n}return null},async setAdminSettings(s){const n=Ve(t.baseUrl,"/api/Alerts/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Ze(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Ve(t.baseUrl,"/api/Alerts/GetPreferenceSettings"),n=await Ze(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=Ve(t.baseUrl,"/api/Alerts/SetPreferenceSettings"),r=await Ze(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,o=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":r?.errorMessage??r?.message??"",statusCode:200,data:o}},async getAlertNotifications(s){const n=Ve(t.baseUrl,"/api/Alerts/GetNotifications"),r=is(n,{alertId:s}),a=await Ze(r,{method:"GET",headers:e});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]},async sendSMSorEmailNotifications(s,n,r){const a=Ve(t.baseUrl,"/api/Alerts/SendSMSorEmailNotifications"),o=is(a,{alertId:s,isEmail:n,isSMS:r});return Ze(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Ve(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Ze(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Ve(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Ze(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null}}}const ca=d.createContext(null);function ua({tenant:t="snl",override:e,timeZone:s,userManagementDomain:n,spacesBaseUrl:r,children:a}){const o=d.useMemo(()=>{const c=e?.alertsBaseUrl?.trim()||_n[t]?.alerts||"";let u=e?.rulesBaseUrl?.trim()||_n[t]?.rules||"";t==="snl"&&(u=c);const f=e?.headers;return{tenant:t,alertsBaseUrl:c,rulesBaseUrl:u,headers:f,timeZone:s,userManagementDomain:n,spacesBaseUrl:r}},[t,e?.alertsBaseUrl,e?.rulesBaseUrl,JSON.stringify(e?.headers||{}),s,n,r]),l=d.useMemo(()=>{const c={baseUrl:o.alertsBaseUrl,headers:o.headers},u={baseUrl:o.rulesBaseUrl,headers:o.headers},f={schools:()=>Xo({...c,spacesBaseUrl:o.spacesBaseUrl}),transit:()=>al(c),snl:()=>Zo(c)},m={schools:()=>tl({...u,userManagementBaseUrl:o.userManagementDomain}),transit:()=>nl({...u,userManagementBaseUrl:o.userManagementDomain}),snl:()=>zo({baseUrl:o.alertsBaseUrl,headers:o.headers})};return{config:o,alerts:f[o.tenant](),rules:m[o.tenant]()}},[o]);return i.jsx(ca.Provider,{value:l,children:a})}function Ue(){const t=d.useContext(ca);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}function Lt(){const{config:t}=Ue();return{timeZoneDetails:d.useMemo(()=>{const s=t.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone;return{timeZoneUniqueId:"",ianaTimeZoneId:s,timeZoneName:s,offset:""}},[t.timeZone]),loading:!1}}const il={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},ol={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},ln=6,cn=7;function Xn(t,e,s){const n=t===ln,r=t===cn,a=e.isEmailSent??!1,o=e.isSMSSent??!1,l=n&&a||r&&o,c=n?"Send Email":r?"Send SMS":s,u=n&&a?"Email sent":r&&o?"SMS sent":c,f=n&&a?"Email sent":r&&o?"SMS sent":`Click to ${c}`;return{isDisabled:l,buttonText:u,tooltipTitle:f}}function Ls(t,e){return`${t}-${e?"email":"sms"}`}function os(t){return t===ln||t===cn}function As({value:t,onChange:e,options:s,className:n,dropdownWidth:r}){return i.jsx(h.Select,{className:n,options:s,value:t,onChange:e,dropdownMatchSelectWidth:r??260})}const ll=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function cl({value:t,onChange:e,options:s}){return i.jsx(As,{className:"w-[140px]",value:t,onChange:e,options:s||ll})}const ul=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function dl({value:t,onChange:e,options:s}){return i.jsx(As,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||ul})}function ml({value:t,onChange:e,options:s}){return i.jsx(As,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const fl=[{label:"All",value:"All"},{label:"SOS",value:"SOS"},{label:"911",value:"911"},{label:"Aegix",value:"Aegix"},{label:"Eli",value:"Eli"},{label:"Skydio",value:"Skydio"}];function hl({value:t,onChange:e,options:s}){return i.jsx(As,{className:"w-[130px]",value:t,onChange:e,options:s||fl})}function da({columns:t,data:e,loading:s=!1,pageSize:n=10,total:r,currentPage:a,rowKey:o="id",toolbar:l,tableProps:c,onPageChange:u}){const m=r===void 0&&a!==void 0?e.length===n?a*n+1:(a-1)*n+e.length:void 0;return i.jsxs("div",{children:[l,i.jsx(h.Table,{rowKey:o,dataSource:e,columns:t,loading:s,pagination:{pageSize:n,current:a,total:r??m,showSizeChanger:!1,showTotal:p=>`Total: ${p}`,onChange:u},bordered:!0,...c})]})}function yl(t){if(!t||typeof t!="string")return!1;const e=t.split("?")[0].toLowerCase();return e.endsWith(".mp4")||e.endsWith(".webm")||e.endsWith(".ogg")||e.endsWith(".m3u8")}function Js(t){const e=(t?.mediaType||t?.type||"").toString().toLowerCase();return e==="video"||e==="mp4"?!0:yl(t?.mediaUrl||t)}function pl(t){const e=t?.mediaUrl;let s=null;if(Array.isArray(e))s=e;else if(typeof e=="string")try{const n=JSON.parse(e);Array.isArray(n)&&(s=n)}catch{}return s&&s.length>0?s.map(n=>({...t,mediaUrl:n})):[t]}function ma(t){const e=t;return e?(Array.isArray(e)?e:[e]).flatMap(pl):[]}const it=16,ot=2,er={Low:"#22c55e",Medium:"#fde047",High:"#fb2c36",Critical:"#7a0707"};function fa({boxes:t,priority:e="High"}){const s=er[e]??er.High;return i.jsx(i.Fragment,{children:t.map((n,r)=>i.jsxs("div",{className:"absolute pointer-events-none",style:{left:n.x,top:n.y,width:n.width,height:n.height},children:[i.jsx("div",{className:"absolute left-0 whitespace-nowrap rounded-sm px-2 py-1 text-[10px] font-semibold text-white",style:{backgroundColor:s,transform:"translateY(-100%)"},children:n.label}),i.jsx("div",{className:"absolute top-0 left-0",style:{width:it,height:it,borderTop:`${ot}px solid ${s}`,borderLeft:`${ot}px solid ${s}`}}),i.jsx("div",{className:"absolute top-0 right-0",style:{width:it,height:it,borderTop:`${ot}px solid ${s}`,borderRight:`${ot}px solid ${s}`}}),i.jsx("div",{className:"absolute bottom-0 left-0",style:{width:it,height:it,borderBottom:`${ot}px solid ${s}`,borderLeft:`${ot}px solid ${s}`}}),i.jsx("div",{className:"absolute bottom-0 right-0",style:{width:it,height:it,borderBottom:`${ot}px solid ${s}`,borderRight:`${ot}px solid ${s}`}})]},`${n.label}-${r}`))})}const gl=t=>{if(!t)return[0,0,0,0];if(typeof t=="string")return t.replace(/[()[\]\s]/g,"").split(",").map(Number);if(!Array.isArray(t)||t.length===0)return[0,0,0,0];const e=t[0];return typeof e=="string"?e.replace(/[()[\]\s]/g,"").split(",").map(Number):Array.isArray(e)?e.map(Number):t.map(Number)},ha=(t,e,s,n,r)=>{if(!e||!s||!n||!r)return[];const a=Math.min(n/e,r/s),o=(n-e*a)/2,l=(r-s*a)/2;return t.flatMap(c=>{const[u,f,m,p]=gl(c.bbox_xyxy);return u>e||m>e||f>s||p>s?[]:[{personName:c.personName,x:u*a+o,y:f*a+l,width:(m-u)*a,height:(p-f)*a}]})},tr={naturalWidth:0,naturalHeight:0,renderedWidth:0,renderedHeight:0};function ya(){const t=d.useRef(null),[e,s]=d.useState(tr),n=d.useCallback(()=>{const a=t.current;a&&s({naturalWidth:a.naturalWidth,naturalHeight:a.naturalHeight,renderedWidth:a.offsetWidth,renderedHeight:a.offsetHeight})},[]),r=d.useCallback(()=>{s(tr)},[]);return{imageRef:t,dimensions:e,onLoad:n,resetDimensions:r}}const pa=({isOpen:t,onClose:e,src:s,type:n="image",detections:r=[],priority:a})=>{const[o,l]=d.useState(!1),{imageRef:c,dimensions:u,onLoad:f,resetDimensions:m}=ya(),p=d.useMemo(()=>ha(r,u.naturalWidth,u.naturalHeight,u.renderedWidth,u.renderedHeight),[r,u]),g=d.useMemo(()=>p.map(w=>({...w,label:w.personName||""})),[p]);return d.useEffect(()=>{t&&(l(!1),m())},[t,s,m]),d.useLayoutEffect(()=>{c.current?.complete&&f()},[f]),d.useEffect(()=>{t&&(!s||o)&&e()},[t,s,o,e]),t?i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-70",role:"button",tabIndex:0,"aria-label":"Close media preview",onClick:e,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),e())},onTouchStart:e,children:i.jsx("div",{className:"relative max-w-5xl max-h-[90vh] w-full flex items-center justify-center",onClick:w=>w.stopPropagation(),children:n==="image"?i.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[i.jsx("img",{ref:c,src:s,alt:"preview",className:"object-contain rounded-lg shadow-lg max-w-full max-h-[90vh]",onLoad:f,onError:()=>l(!0)}),i.jsx(fa,{boxes:g,priority:a}),i.jsx("button",{onClick:e,className:"absolute top-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:"✕"})]}):i.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[i.jsx("video",{src:s,controls:!0,className:"object-contain rounded-lg shadow-lg max-w-full max-h-[90vh]",onError:()=>l(!0)}),i.jsx("button",{onClick:e,className:"absolute top-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:"✕"})]})})}):null};const Sl=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),xl=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),sr=t=>{const e=xl(t);return e.charAt(0).toUpperCase()+e.slice(1)},ga=(...t)=>t.filter((e,s,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===s).join(" ").trim(),vl=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var wl={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Al=d.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:a,iconNode:o,...l},c)=>d.createElement("svg",{ref:c,...wl,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:ga("lucide",r),...!a&&!vl(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,f])=>d.createElement(u,f)),...Array.isArray(a)?a:[a]]));const un=(t,e)=>{const s=d.forwardRef(({className:n,...r},a)=>d.createElement(Al,{ref:a,iconNode:e,className:ga(`lucide-${Sl(sr(t))}`,`lucide-${t}`,n),...r}));return s.displayName=sr(t),s};const Nl=[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]],Sa=un("image-off",Nl);const Tl=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],bl=un("loader-circle",Tl);const kl=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Il=un("maximize-2",kl);function El(t){const s=ma(t.mediaDetails)[0];if(!s)return null;const n=s.mediaUrl??s;return typeof n!="string"||!n.length?null:{url:n,item:s}}function xa({record:t}){const e=d.useMemo(()=>El(t),[t]),[s,n]=d.useState(!1),[r,a]=d.useState(!1),o=d.useMemo(()=>t.bbox_xyxy?[{bbox_xyxy:t.bbox_xyxy,personName:t.personName}]:[],[t.bbox_xyxy,t.personName]);if(d.useEffect(()=>{a(!1)},[e?.url]),!e)return i.jsx("span",{className:"text-gray-400 text-sm",children:"—"});const{url:l,item:c}=e,u=Js(c),f=u?"video":"image",m="block w-[72px] h-[54px] object-cover bg-gray-100 border border-gray-200 rounded-sm";return i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",disabled:r,className:"p-0 border-0 bg-transparent rounded-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-1 cursor-pointer disabled:cursor-not-allowed disabled:opacity-60","aria-label":r?"Preview unavailable":"Expand preview",onClick:()=>n(!0),children:r?i.jsx("span",{className:`${m} flex items-center justify-center text-gray-400`,children:i.jsx(Sa,{size:20,"aria-hidden":!0})}):u?i.jsx("video",{src:l,className:m,muted:!0,playsInline:!0,preload:"metadata",onError:()=>a(!0)}):i.jsx("img",{src:l,alt:"",className:m,onError:()=>a(!0)})}),i.jsx(pa,{isOpen:s,onClose:()=>n(!1),src:l,type:f,detections:o,priority:t.priority})]})}function Ml(t,e){const[s,n]=d.useState(t);return d.useEffect(()=>{const r=window.setTimeout(()=>n(t),e);return()=>window.clearTimeout(r)},[t,e]),s}function dn({data:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,columns:a,renderActions:o,onAlertIdClick:l,onRefetch:c,onPageChange:u,onFilterChange:f,resetKey:m}){const[p,g]=d.useState("All"),[w,j]=d.useState("All"),[E,C]=d.useState("All"),[O,W]=d.useState("All"),[b,R]=d.useState(""),[B,U]=d.useState(r??1);d.useEffect(()=>{m!==void 0&&(g("All"),j("All"),C("All"),W("All"),R(""),U(1))},[m]),d.useEffect(()=>{r!==void 0&&U(r)},[r]);const[q,y]=d.useState([{label:"All",value:"All"}]),[S,M]=d.useState([]),[oe,fe]=d.useState([]),[I,A]=d.useState([]),[x,k]=d.useState(new Set),{rules:N,alerts:D,config:L}=Ue(),{timeZoneDetails:Y}=Lt(),J=L.tenant==="schools",G=L.tenant==="transit",Q=L.tenant==="snl",ce=Ml(b,600),ke=J&&ce.trim()?100:s,ee={6:{title:"Email",kind:"icon",icon:i.jsx(St.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:i.jsx(St.MessageOutlined,{})}};d.useEffect(()=>{if(!D.getAllSpaces)return;let X=!0;return(async()=>{try{const z=await D.getAllSpaces();if(X){const xe=z.map(ne=>({label:G?String(ne.spaceNumber??ne.spaceName??""):ne.spaceName,value:String(G?ne.spaceNumber??ne.spaceId:ne.spaceId)}));M([{label:"All",value:"All"},...xe])}}catch(z){console.error("Error loading space options",z)}})(),()=>{X=!1}},[D,G]),d.useEffect(()=>{let X=!0;return(async()=>{try{const z=await N.getLookups(),ne=(Array.isArray(z.thirdParties)?z.thirdParties:[]).map(ve=>({label:ve.thirdPartyName,value:String(ve.thirdPartyId)})),Ie=(Array.isArray(z.anomalies)?z.anomalies:[]).map(ve=>({label:ve.anomalyName??ve.DisplayName,value:ve.anomalyId??ve.AnomalyId})),Je=(Array.isArray(z.severities)?z.severities:[]).map(ve=>({label:ve.severityName,value:String(ve.severityId)}));X&&(y([{label:"All",value:"All"},...ne]),Ie.length&&fe([{label:"All Types",value:"All"},...Ie]),Je.length&&A([{label:"All levels",value:"All"},...Je]))}catch(z){console.error("Error loading filter options",z)}})(),()=>{X=!1}},[N]),d.useEffect(()=>{if(!f)return;const X=I.find(xe=>xe.value===p),z={anomalyId:oe.length>1&&w!=="All"?w:void 0,spaceId:!G&&S.length>1&&E!=="All"?E:void 0,spaceNumber:G&&S.length>1&&E!=="All"?E:void 0,severityId:I.length>1&&p!=="All"?p:void 0,severityName:I.length>1&&p!=="All"?X?.label:void 0,thirdPartyIds:O==="All"?void 0:[Number(O)],searchText:ce.trim()||void 0};f(z),u?.(1)},[w,E,p,O,ce,oe.length,S.length,I.length,G,J]);const ye=oe.length>1?oe:void 0,Te=S.length>1?S:void 0,he=I.length>1?I:void 0,le=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:X=>i.jsx(h.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${ol[X]}`,backgroundColor:il[X]},children:X})},{title:"Tracker",key:"tracker",width:Q?100:140,render:(X,z)=>i.jsx("a",{onClick:xe=>{xe.preventDefault(),l?.(z,{tab:"track",sourceTab:"active"})},className:"text-blue-600 hover:underline",children:"Tracker"})},{title:"Call to action/Human in the loop",key:"actions",width:Q?240:320,render:(X,z)=>{if(o)return i.jsx(i.Fragment,{children:o(z)});const xe=async(st,Ft)=>{const wt=Ls(z.id,st);k(be=>new Set(be).add(wt));try{const be=await D.sendSMSorEmailNotifications?.(z.id,st,Ft);be?.responseStatus||be?.Success||be?.success?(Ne.toast.success(be?.message||be.data||(st?"Email sent successfully":"SMS sent successfully")),c?.()):Ne.toast.error(be?.message||be?.data||be?.errorMessage||"Failed to send notification")}catch(be){Ne.toast.error(be?.message||"Failed to send notification")}finally{k(be=>{const At=new Set(be);return At.delete(wt),At})}},ne=ln,Oe=cn,Ie=ee[ne],Fe=ee[Oe],Je=Xn(ne,z,Ie?.title),ve=Xn(Oe,z,Fe?.title),ft=Ls(z.id,!0),ht=Ls(z.id,!1),$e=os(ne)&&x.has(ft),Ke=os(Oe)&&x.has(ht);return i.jsxs(h.Space,{size:"middle",children:[i.jsx(h.Tooltip,{title:Je.tooltipTitle,children:i.jsx(h.Button,{size:"small",disabled:Je.isDisabled,loading:$e,onClick:os(ne)?()=>xe(!0,!1):void 0,icon:!$e&&Ie?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:Je.buttonText})},String(ne)),i.jsx(h.Tooltip,{title:ve.tooltipTitle,children:i.jsx(h.Button,{size:"small",disabled:ve.isDisabled,loading:Ke,onClick:os(Oe)?()=>xe(!1,!0):void 0,icon:!Ke&&Fe?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:ve.buttonText})},String(Oe))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:Q?300:220,render:(X,z)=>{const xe=z?.timeElapsed,ne=z?.timeRemaining,Oe=xe?gn(xe):0,Ie=ne?gn(ne):0,Fe=Math.round(Oe/(Oe+Ie)*100);return i.jsxs("div",{children:[Q?i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("span",{className:"w-[70px] shrink-0 !text-black",style:{color:"#000000"},children:"Alerted:"}),i.jsx("span",{className:"font-medium !text-black",style:{color:"#000000"},children:Ot(z.timestamp,Y?.ianaTimeZoneId)})]}):null,i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-[70px]",children:"Elapsed:"}),i.jsx("span",{className:"font-medium",children:xe??"-"})]}),i.jsx(h.Progress,{percent:Fe,showInfo:!1,size:"small",strokeColor:Oa(z.priority)}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-[70px]",children:"Remaining"}),i.jsx("span",{className:"font-medium",children:ne??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},...Q?[{title:"Space",dataIndex:"spaceName",key:"spaceName",width:180,render:X=>i.jsx("span",{className:"whitespace-normal break-words",children:X?.trim()||"-"})},{title:"Resident",dataIndex:"personName",key:"personName",width:160,render:X=>X?.trim()||"-"}]:[],{title:"Description",dataIndex:"description",key:"description",width:Q?280:void 0,render:(X,z)=>i.jsxs("div",{children:[i.jsx("a",{onClick:xe=>{xe.preventDefault(),l?.(z,{sourceTab:"active"})},className:"inline-block mb-1 text-blue-600",children:z.alertNumber}),i.jsx("div",{className:"text-black/65",children:X})]})},{title:"Preview",key:"preview",width:100,align:"center",render:(X,z)=>i.jsx(xa,{record:z})}],Le=a&&a.length?a:le;return i.jsx("div",{children:i.jsx(da,{rowKey:"id",data:t,columns:Le,loading:e,pageSize:ke,total:n,currentPage:B,onPageChange:u,toolbar:i.jsxs(h.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[i.jsx(h.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Severity"}),i.jsx(cl,{value:p,onChange:g,options:he})]})}),i.jsx(h.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Anomaly type"}),i.jsx(dl,{value:w,onChange:j,options:ye})]})}),i.jsx(h.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:G?"Bus Number":"Space"}),i.jsx(ml,{value:E,onChange:C,options:Te})]})}),i.jsx(h.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Action Taken"}),i.jsx(hl,{value:O,onChange:W,options:q})]})}),i.jsx(h.Col,{flex:"auto"}),i.jsx(h.Col,{flex:"none",children:i.jsx(h.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:R,onChange:X=>R(X.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}const jl=["completed","false positive","face doesn't match name","safe","supervised exit","elopement confirmed"];function mn(){const{alerts:t}=Ue(),e=xt.useQueryClient();return xt.useMutation({mutationFn:s=>t.updateAlertStatus(s),onSuccess:()=>{e.invalidateQueries({queryKey:["alerts","list"]}),e.invalidateQueries({queryKey:["alerts","report"]})}})}const Ol={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Dl={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function va({alerts:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,onAlertIdClick:a,onAlertView:o,onFilterChange:l,onPageChange:c,onRefetch:u,resetKey:f}){const{config:m}=Ue(),p=m.tenant==="snl",g=mn(),w=async C=>{try{const O=await g.mutateAsync({alertUniqueId:C.alertId??C.id,alertId:C.id,status:"Reopen",notes:"Reopened",modifiedBy:0});if(O?.responseStatus||O?.Success){const W=O?.message||O?.Message||"Alert reopened successfully.";Ne.toast.success(W)}else{const W=O?.errorMessage||O?.Message||"Failed to reopen alert";Ne.toast.error(W)}}catch{Ne.toast.error("Failed to reopen alert. Please try again.")}},j=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:C=>i.jsx(h.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Ol[C]}`,backgroundColor:Dl[String(C)]},children:C})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:C=>Co(C)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},...p?[{title:"Space",dataIndex:"spaceName",key:"spaceName",width:180,render:C=>i.jsx("span",{className:"whitespace-normal break-words",children:C?.trim()||"-"})},{title:"Resident",dataIndex:"personName",key:"personName",width:160,render:C=>C?.trim()||"-"}]:[],{title:"Description",dataIndex:"description",key:"description",render:(C,O)=>i.jsxs("div",{children:[i.jsx("a",{onClick:W=>{W.preventDefault(),a?.(O,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:O.alertNumber}),i.jsx("div",{className:"text-black/65",children:C})]})},{title:"Preview",key:"preview",width:100,align:"center",render:(C,O)=>i.jsx(xa,{record:O})},{title:"",key:"menu",width:60,align:"right",render:(C,O)=>i.jsx(h.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:W})=>{W==="reopen"&&w(O)}},children:i.jsx(h.Button,{type:"text",icon:i.jsx(St.MoreOutlined,{})})})}],E=l?t:(t||[]).filter(C=>{const O=Sn(C.statusType||"");return jl.some(W=>O.includes(Sn(W)))});return i.jsx(dn,{data:E,loading:e,pageSize:s,total:n,currentPage:r,columns:j,renderActions:void 0,onAlertIdClick:a,onAlertView:o,onFilterChange:l,onPageChange:c,onRefetch:u,resetKey:f,excludeCompleted:!1})}function Cl({size:t=120,time:e,timeZone:s="America/New_York"}){const{hours:n,minutes:r,seconds:a}=d.useMemo(()=>{const m=new Intl.DateTimeFormat("en-US",{timeZone:s,hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(e);return{hours:parseInt(m.find(p=>p.type==="hour")?.value||"0",10),minutes:parseInt(m.find(p=>p.type==="minute")?.value||"0",10),seconds:parseInt(m.find(p=>p.type==="second")?.value||"0",10)}},[e,s]),o=a*6,l=r*6+a*.1,c=n%12*30+r*.5,u=t/2;return i.jsxs("div",{className:"relative rounded-full border border-gray-300 bg-white",style:{width:t,height:t},role:"img","aria-label":"Analog Clock",children:[[...Array(12)].map((f,m)=>{const p=m*30,g=6,w=u-4,j=w-g,E=(p-90)*(Math.PI/180),C=u+j*Math.cos(E),O=u+j*Math.sin(E),W=u+w*Math.cos(E),b=u+w*Math.sin(E);return i.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:i.jsx("line",{x1:C,y1:O,x2:W,y2:b,stroke:"#9CA3AF",strokeWidth:m%3===0?2:1,strokeLinecap:"round"})},m)}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${c}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.25,stroke:"#1F2937",strokeWidth:4,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${l}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.35,stroke:"#374151",strokeWidth:3,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${o}deg)`},children:i.jsx("line",{x1:u,y1:u+t*.08,x2:u,y2:u-t*.38,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"})}),i.jsx("div",{className:"absolute bg-gray-900 rounded-full",style:{width:8,height:8,left:u-4,top:u-4}})]})}function wa({label:t="USA",timeZone:e="America/New_York",updateIntervalMs:s=1e3,className:n}){const[r,a]=d.useState(new Date);d.useEffect(()=>{const u=setInterval(()=>a(new Date),s);return()=>clearInterval(u)},[s]);const o=d.useMemo(()=>Oo(r,e),[r,e]),{abbr:l,offset:c}=d.useMemo(()=>Do(r,e),[r,e]);return i.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[i.jsx(Cl,{time:r,timeZone:e,size:80}),i.jsxs("div",{className:"flex flex-col items-baseline gap-1",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[i.jsx("span",{className:"uppercase",children:t}),l&&i.jsxs("span",{className:"p-2 rounded-md border text-[10px] leading-none text-gray-600 bg-gray-50",children:[l," ",c]})]}),i.jsx("div",{className:"text-2xl font-semibold text-gray-700 tracking-wide",children:o})]})]})}const{Text:Rl}=h.Typography;function Ul({sortBy:t,onChange:e,showActions:s,onSave:n,onClear:r,saving:a}){return i.jsxs(h.Row,{gutter:[16,16],align:"middle",children:[i.jsx(h.Col,{xs:24,md:8,lg:5,children:i.jsxs(h.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[i.jsx(Rl,{className:"text-gray-600 whitespace-nowrap",children:"Sort By:"}),i.jsx(h.Select,{placeholder:"By Severity",value:t,onChange:o=>e({sortBy:o}),options:[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],className:"w-full",style:{minWidth:"200px"}})]})}),i.jsx(h.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?i.jsxs(h.Space,{className:"w-full",direction:"horizontal",size:8,children:[i.jsx(h.Button,{onClick:r,disabled:a,children:"Clear"}),i.jsx(h.Button,{type:"primary",onClick:n,loading:a,children:"Save"})]}):null})]})}const Ks=t=>i.jsxs(h.Tag,{children:[i.jsx(St.PlusOutlined,{})," ",t.length," more"]}),{Text:et}=h.Typography;function Ll(t){const{selectedRule:e,setSelectedRule:s,ruleOptions:n,minsOptions:r,roleOptions:a,l1mins:o,setL1mins:l,l1role:c,setL1role:u,l2mins:f,setL2mins:m,l2role:p,setL2role:g,l3mins:w,setL3mins:j,l3role:E,setL3role:C,actions:O,setActions:W,thirdPartyIds:b,setThirdPartyIds:R,humanLoop:B,setHumanLoop:U,isAutoExpire:q,setAutoExpire:y,onClear:S,onSave:M,saving:oe,onActionTypesLoaded:fe}=t,{rules:I,config:A}=Ue(),x=A.tenant==="schools",[k,N]=d.useState([]),[D,L]=d.useState([]),[Y,J]=d.useState(!1);d.useEffect(()=>{let ee=!1;return(async()=>{try{J(!0);const ye=await I.getLookups();if(ee||!ye||!Array.isArray(ye.actionTypes))return;const Te=ye.actionTypes.map(le=>({label:le.name,value:String(le.actionTypeId)}));N(Te),fe&&fe(ye.actionTypes);const he=Array.isArray(ye.thirdParties)?ye.thirdParties.map(le=>({label:le.thirdPartyName,value:le.thirdPartyIds??le.thirdPartyId})):[];L(he)}catch(ye){console.error("Error loading lookups",ye)}finally{ee||J(!1)}})(),()=>{ee=!0}},[]);const G=typeof o=="number"||typeof c=="number",Q=typeof f=="number"||typeof p=="number",ce=typeof o=="number"||typeof c=="number"||typeof f=="number"||typeof p=="number"||typeof w=="number"||typeof E=="number"||Array.isArray(O)&&O.length>0||Array.isArray(b)&&b.length>0||!!B||!!q,ke=!!e&&ce&&!oe;return i.jsxs(h.Spin,{spinning:!!oe||Y,children:[i.jsxs(h.Row,{gutter:[16,16],align:"bottom",children:[i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(h.Select,{placeholder:"Rules",value:e,onChange:s,options:n,className:"w-full"})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),i.jsx(h.Col,{span:14,children:i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:o,onChange:l,options:r})}),i.jsx(h.Col,{span:14,children:i.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:c,onChange:u,options:a})})]})]})}),G&&i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),i.jsx(h.Col,{span:14,children:i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:f,onChange:m,options:r})}),i.jsx(h.Col,{span:14,children:i.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:p,onChange:g,options:a})})]})]})}),Q&&i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),i.jsx(h.Col,{span:14,children:i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:w,onChange:j,options:r})}),i.jsx(h.Col,{span:14,children:i.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:E,onChange:C,options:a})})]})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),i.jsx(h.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:O,onChange:W,options:k,maxTagCount:1,maxTagPlaceholder:Ks})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Notify"}),i.jsx(h.Select,{mode:"multiple",placeholder:"Notify",className:"w-full",value:b,onChange:R,options:D,maxCount:2,maxTagPlaceholder:Ks})]})})]}),i.jsxs(h.Row,{gutter:[16,16],align:"bottom",className:"mt-4 items-center",children:[i.jsx(h.Col,{xs:24,sm:12,md:8,lg:7,children:i.jsxs("div",{className:"flex items-center h-full gap-8",children:[!x&&i.jsx(h.Checkbox,{checked:B,onChange:ee=>U(ee.target.checked),className:"w-full",children:"Human-In-The-Loop"}),i.jsx(h.Checkbox,{checked:q,onChange:ee=>y(ee.target.checked),className:"w-full",children:"Auto-expire in 5 minutes"})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(h.Button,{onClick:S,children:"Clear"}),i.jsx(h.Button,{type:"primary",onClick:M,loading:!!oe,disabled:!ke,children:"Save"})]})})]})]})}function Fl({entries:t,userRoles:e,onEdit:s,loading:n}){const{config:r}=Ue(),a=r.tenant==="schools",o=new Map(e.map(c=>[c.userRoleId,c.userRoleName])),l=c=>c.map(u=>o.get(u)||String(u)).join(", ");return i.jsx(h.Table,{rowKey:"id",dataSource:t,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(c,u)=>`${u[0]}-${u[1]} of ${c} items`},loading:n,columns:[{title:"Rule",dataIndex:"ruleOrSeverityLabel",key:"rule"},{title:"Level 1",key:"l1",render:(c,u)=>i.jsxs("span",{children:[u.l1.minutes?`Action taken in (${u.l1.minutes} Mins)`:"No Action taken in 0 Min",u.l1.roles?.length?`, Escalate to (${l(u.l1.roles)})`:""]})},{title:"Level 2",key:"l2",render:(c,u)=>i.jsxs("span",{children:[u.l2.minutes?`Action taken in (${u.l2.minutes} Mins)`:"No Action taken in 0 Min",u.l2.roles?.length?`, Escalate to (${l(u.l2.roles)})`:""]})},{title:"Level 3",key:"l3",render:(c,u)=>i.jsxs("span",{children:[u.l3.minutes?`Action taken in (${u.l3.minutes} Mins)`:"No Action taken in 0 Min",u.l3.roles?.length?`, Escalate to (${l(u.l3.roles)})`:""]})},{title:"Pick Actions",key:"actionsCol",render:(c,u)=>u.actions?.length?u.actions.join(", "):"-"},{title:"Notify",key:"notify",render:(c,u)=>u.notify?.length?u.notify.join(", "):"-"},...a?[]:[{title:"Human-In-The-Loop",key:"humanLoop",render:(c,u)=>u.humanLoop?"Yes":"No"}],{title:"Auto Expire",key:"isAutoExpire",render:(c,u)=>u.isAutoExpire?"Yes":"No"},{title:"Actions",key:"ops",render:(c,u)=>i.jsx(h.Button,{type:"text",onClick:()=>s(u.id),children:i.jsx(St.EditOutlined,{})})}]})}const{Title:$l,Text:Fs}=h.Typography;function Aa({userRoles:t,rules:e,rawRules:s}){const{rules:n}=Ue(),[r,a]=d.useState(!1),[o,l]=d.useState(!1),[c,u]=d.useState(s),[f,m]=d.useState(),[p,g]=d.useState([]),w=d.useMemo(()=>t.map(b=>({label:b.userRoleName,value:b.userRoleId})),[t]),j=d.useMemo(()=>(e||[]).map(b=>({label:b.Name||"-",value:b.RuleId||b.Name||""})),[e]),E=d.useMemo(()=>(e||[]).map((b,R)=>({key:b.RuleId||b.Name||String(R),ruleName:b.Name||"-",ruleDesc:b.Description||""})),[e]);d.useEffect(()=>{let b=!1;return(async()=>{try{a(!0);const R=await n.getRules();b||u(Array.isArray(R)?R:[])}catch{!b&&Array.isArray(s)&&u(s)}finally{b||a(!1)}})(),()=>{b=!0}},[]),d.useEffect(()=>{!c&&Array.isArray(s)&&u(s)},[s]),d.useEffect(()=>{if(!f||!Array.isArray(c)){g([]);return}const b=c.find(B=>B?.ruleId===f||B?.RuleId===f||B?.ruleName===f),R=b?.userRoleIds??b?.UserRoleIds;g(Array.isArray(R)?R:[])},[f,c]);const C=d.useMemo(()=>{if(!Array.isArray(c)||!c.length)return{};const b={};for(const R of E){const B=c.find(y=>y?.ruleId===R.key||y?.ruleName===R.key||y?.RuleId===R.key||y?.ruleName===R.ruleName||y?.Name===R.ruleName),U=B?.userRoleIds??B?.UserRoleIds,q=Array.isArray(U)?U:[];q.length&&(b[R.key]=q)}return b},[c,E]),O=()=>{m(void 0),g([])},W=async()=>{if(!f){Ne.toast.info("Please select a rule");return}try{l(!0);const b=Array.isArray(c)?c.find(y=>y?.ruleId===f||y?.RuleId===f||y?.ruleName===f):void 0,R=typeof b?.recordId=="number"?b.recordId:b?.ruleId||b?.RuleId||void 0;if(!b||!R)throw new Error(`Unable to find rule identifier for rule ${f}`);const B=p.map(y=>{const S=t.find(M=>M.userRoleId===y);return{id:y,name:S?.userRoleName??String(y)}}),U={...b,ruleId:f,userRoleIds:p,userRoles:B},q=await n.updateRule(R,U);if(!q?.responseStatus&&!q?.Success&&!q?.success)Ne.toast.error(q?.errorMessage||q?.Message||"Error saving Alert Assignment");else{Ne.toast.success("Alert assignment saved"),m(void 0),g([]);try{const y=await n.getRules();u(Array.isArray(y)?y:[])}catch(y){console.error("Failed to refresh rules after save",y)}}}catch(b){console.error("Failed to save alert assignment",b),Ne.toast.error(b instanceof Error?b.message:"Error saving Alert Assignment")}finally{l(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx($l,{level:4,className:"!mb-4",children:"Alert Assignment"}),i.jsx(h.Spin,{spinning:o||r,children:i.jsxs(h.Row,{gutter:[16,16],align:"bottom",className:"mb-6",children:[i.jsx(h.Col,{xs:24,sm:12,md:8,lg:6,children:i.jsxs("div",{children:[i.jsx(Fs,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(h.Select,{placeholder:"Rules",value:f,onChange:m,options:j,className:"w-full"})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:8,children:i.jsxs("div",{children:[i.jsx(Fs,{className:"text-gray-700 font-medium block mb-1",children:"Alert Notification To"}),i.jsx(h.Select,{mode:"multiple",placeholder:"Select roles",className:"w-full",value:p,onChange:g,options:w,maxTagCount:1,maxTagPlaceholder:Ks})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(h.Button,{onClick:O,disabled:o,children:"Cancel"}),i.jsx(h.Button,{type:"primary",onClick:W,loading:o,disabled:o||!f,children:"Save"})]})})]})}),i.jsx(h.Table,{rowKey:"key",dataSource:E,loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(b,R)=>`${R[0]}-${R[1]} of ${b} items`},columns:[{title:"Rule Name",dataIndex:"ruleName",key:"ruleName"},{title:"Description",dataIndex:"ruleDesc",key:"ruleDesc"},{title:"Alert Notification To",key:"assign",render:(b,R)=>{const B=C[R.key]??[];return B.length?i.jsx("div",{className:"flex flex-wrap gap-1",children:B.map(U=>{const q=t.find(y=>y.userRoleId===U);return i.jsx(h.Tag,{children:q?.userRoleName??String(U)},U)})}):i.jsx(Fs,{type:"secondary",children:"—"})}}]})]})}const{Title:nr}=h.Typography;function $s(t){return!t||typeof t!="object"?{}:{level1UserRoleId:t.level1UserRoleId??t.Level1UserRoleId,level1PostAssistTime:t.level1PostAssistTime??t.Level1PostAssistTime,level2UserRoleId:t.level2UserRoleId??t.Level2UserRoleId,level2PostAssistTime:t.level2PostAssistTime??t.Level2PostAssistTime,level3UserRoleId:t.level3UserRoleId??t.Level3UserRoleId,level3PostAssistTime:t.level3PostAssistTime??t.Level3PostAssistTime,escalationSettingsActionTypeIds:t.escalationSettingsActionTypeIds??t.EscalationSettingsActionTypeIds,thirdPartyId:t.thirdPartyId??t.ThirdPartyId??t.ThirdPartyIds,humanLoop:t.humanLoop??t.HumanLoop,isAutoExpire:t.isAutoExpire??t.IsAutoExpire}}function Na({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r,onSave:a}){const{rules:o,alerts:l}=Ue(),[c,u]=d.useState("By Severity"),[f,m]=d.useState("By severity"),[p,g]=d.useState("By Severity"),[w,j]=d.useState(!1),[E,C]=d.useState(!1),[O,W]=d.useState(!1),[b,R]=d.useState(null),[B,U]=d.useState("rules"),[q,y]=d.useState(),[S,M]=d.useState(),[oe,fe]=d.useState(),[I,A]=d.useState(),[x,k]=d.useState(),[N,D]=d.useState(),[L,Y]=d.useState(),[J,G]=d.useState(),[Q,ce]=d.useState([]),[ke,ee]=d.useState([]),[ye,Te]=d.useState(!1),[he,le]=d.useState(!1),[Le,X]=d.useState({}),[z,xe]=d.useState({}),[ne,Oe]=d.useState(s||[]),[Ie,Fe]=d.useState([]),[Je,ve]=d.useState(!1),[ft,ht]=d.useState(!1),[$e,Ke]=d.useState(n||[]);d.useEffect(()=>{n&&n.length&&Ke(n)},[n]),d.useEffect(()=>{if(!$e||!$e.length)return;const F=Object.keys(Le).length>0||Object.keys(z).length>0;if(Ie.length&&!F)return;const re=$e.map((_,V)=>{const de=e.find(ue=>ue.RuleId===(_.ruleId||_.ruleName))?.Name||_.ruleName||_.Name||"-",Z=$s(_.escalationSettings),te=typeof Z.level1UserRoleId=="number"&&Z.level1UserRoleId>0?[Z.level1UserRoleId]:[],$t=typeof Z.level2UserRoleId=="number"&&Z.level2UserRoleId>0?[Z.level2UserRoleId]:[],Pt=typeof Z.level3UserRoleId=="number"&&Z.level3UserRoleId>0?[Z.level3UserRoleId]:[],Qt=(Array.isArray(Z.escalationSettingsActionTypeIds)?Z.escalationSettingsActionTypeIds:[]).map(ue=>Le[ue]||String(ue)),H=(Array.isArray(Z.thirdPartyId)?Z.thirdPartyId:[]).map(ue=>z[ue]||String(ue)),ae=typeof Z.humanLoop=="boolean"?Z.humanLoop:null,we=typeof Z.isAutoExpire=="boolean"?Z.isAutoExpire:null;return{id:String(_.ruleId||_.ruleName||V),ruleOrSeverityLabel:de,l1:{minutes:Z.level1PostAssistTime??void 0,roles:te},l2:{minutes:Z.level2PostAssistTime??void 0,roles:$t},l3:{minutes:Z.level3PostAssistTime??void 0,roles:Pt},actions:Qt,notify:H,humanLoop:ae,isAutoExpire:we}});Fe(re)},[$e,e,Le,z]);const st=d.useMemo(()=>t.map(F=>({label:F.DisplayName,value:F.SeverityId})),[t]),Ft=d.useMemo(()=>e.map(F=>({label:F.Name,value:F.RuleId})),[e]),wt=d.useMemo(()=>ne.map(F=>({label:F.userRoleName,value:F.userRoleId})),[ne]),be=d.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(F=>({label:`${F}`,value:F})),[]);d.useEffect(()=>{let F=!1;async function re(){try{W(!0),R(null);const _=await l.getAdminSettings();if(!F&&_){const V=oa(_.sortBy);u(V),g(V),j(!1)}}catch(_){if(!F){const V=_ instanceof Error?_.message:"Failed to load admin settings";R(V)}}finally{F||W(!1)}}return re(),()=>{F=!0}},[]),d.useEffect(()=>{if(!S)return;const F=de=>{const Z=Number(de);return!isNaN(Z)&&Z>0?Z:void 0},re=de=>{const Z=Number(de);return!isNaN(Z)&&Z>0?Z:void 0},_=($e||[]).find(de=>de?.ruleId===S||de?.ruleName===S||de?.RuleId===S),V=$s(_?.escalationSettings);if(V&&typeof V=="object"){fe(re(V.level1PostAssistTime)),A(F(V.level1UserRoleId)),k(re(V.level2PostAssistTime)),D(F(V.level2UserRoleId)),Y(re(V.level3PostAssistTime)),G(F(V.level3UserRoleId));const de=Array.isArray(V.escalationSettingsActionTypeIds)?V.escalationSettingsActionTypeIds:[];ce(de.map(Z=>String(Z))),ee(Array.isArray(V.thirdPartyId)?V.thirdPartyId:[]),Te(!!V.humanLoop),le(!!V.isAutoExpire)}},[B,S,$e]);const At=async()=>{try{ht(!0);const F=await o.getRules(),re=Array.isArray(F)?F:Array.isArray(F?.data)?F.data:[];Ke(re);const _=re.map((V,de)=>{const Z=e.find(ue=>ue.RuleId===(V.ruleId||V.ruleName))?.Name||V.ruleName||V.Name||"-",te=$s(V.escalationSettings??V.EscalationSettings),$t=typeof te.level1UserRoleId=="number"&&te.level1UserRoleId>0?[te.level1UserRoleId]:[],Pt=typeof te.level2UserRoleId=="number"&&te.level2UserRoleId>0?[te.level2UserRoleId]:[],nt=typeof te.level3UserRoleId=="number"&&te.level3UserRoleId>0?[te.level3UserRoleId]:[],v=(Array.isArray(te.escalationSettingsActionTypeIds)?te.escalationSettingsActionTypeIds:[]).map(ue=>Le[ue]||String(ue)),ae=(Array.isArray(te.thirdPartyId)?te.thirdPartyId:[]).map(ue=>z[ue]||String(ue)),we=typeof te.humanLoop=="boolean"?te.humanLoop:null;return{id:String(V.ruleId||V.ruleName||de),ruleOrSeverityLabel:Z,l1:{minutes:te.level1PostAssistTime??void 0,roles:$t},l2:{minutes:te.level2PostAssistTime??void 0,roles:Pt},l3:{minutes:te.level3PostAssistTime??void 0,roles:nt},actions:v,notify:ae,humanLoop:we}});Fe(_)}catch(F){console.error("Failed to refetch entries",F)}finally{ht(!1)}};d.useEffect(()=>{let F=!1;return(async()=>{try{const re=await o.getLookups();if(F||!re)return;const _={};if(Array.isArray(re.thirdParties))for(const de of re.thirdParties){const Z=de.thirdPartyIds??de.thirdPartyId;typeof Z=="number"&&(_[Z]=de.thirdPartyName)}xe(_);const V=Array.isArray(re.userRoles)?re.userRoles.map(de=>({userRoleId:de.userRoleId??de.id,userRoleName:de.userRoleName??de.name})):[];F||Oe(V.length?V:s||[])}catch(re){console.error("Error loading lookups",re)}})(),()=>{F=!0}},[]);const Ns=async()=>{C(!0);try{const F=await l.setAdminSettings({sortBy:c,groupBy:"string"});F?.responseStatus?Ne.toast.success(F?.message||"Admin settings saved"):Ne.toast.error(F?.errorMessage||"Error saving admin settings"),g(c),j(!1)}catch(F){console.error("Error saving admin settings",F)}finally{C(!1)}},Ts=()=>{u(p),j(!1)},hn=async()=>{ve(!0),a?.({ruleId:S,levels:[{minutes:oe,role:I},{minutes:x,role:N},{minutes:L,role:J}],actions:Q,thirdPartyIds:ke,humanLoop:ye,isAutoExpire:he});try{if(S){const re=Array.isArray(Q)?Q.map(te=>Number.isNaN(Number(te))?te:Number(te)):[],_=($e||[]).find(te=>te?.ruleId===S||te?.ruleName===S||te?.RuleId===S),V=typeof _?.recordId=="number"?_.recordId:_?.ruleId||_?.RuleId||void 0;if(!_||!V){Ne.toast.error("Unable to find rule identifier for update");return}const de={..._,escalationSettings:{level1UserRoleId:I??0,level1PostAssistTime:oe??0,level2UserRoleId:N??0,level2PostAssistTime:x??0,level3UserRoleId:J??0,level3PostAssistTime:L??0,escalationSettingsActionTypeIds:re,thirdPartyId:Array.isArray(ke)?ke:[],humanLoop:ye,isAutoExpire:he}},Z=await o.updateRule(V,de);Z?.responseStatus||Z?.Success||Z?.success?(Ne.toast.success("Escalation settings saved"),await At(),M(void 0),fe(void 0),A(void 0),k(void 0),D(void 0),Y(void 0),G(void 0),ce([]),ee([]),Te(!1),le(!1)):Ne.toast.error(Z?.errorMessage||Z?.Message||"Error saving Escalation Settings")}}catch(re){console.error("Error saving escalation settings",re)}finally{ve(!1)}},bs=()=>{u("By Severity"),m("By severity"),U("rules"),y(void 0),M(void 0),fe(void 0),A(void 0),k(void 0),D(void 0),Y(void 0),G(void 0),ce([]),ee([]),Te(!1),le(!1)};return i.jsxs("div",{className:"w-full",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(nr,{level:4,className:"!mb-2",children:"Admin Settings"}),i.jsxs(h.Spin,{spinning:O,children:[b?i.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",b]}):null,i.jsx(Ul,{sortBy:c,groupBy:f,onChange:F=>{F.sortBy&&(u(F.sortBy),j(!0)),F.groupBy&&(m(F.groupBy),j(!0))},showActions:w,onSave:Ns,onClear:Ts,saving:E})]})]}),i.jsx(h.Divider,{className:"my-6"}),i.jsxs("div",{children:[i.jsx(nr,{level:4,className:"!mb-4",children:"Escalation Settings"}),i.jsx(Ll,{escBasis:B,setEscBasis:U,selectedSeverity:q,setSelectedSeverity:y,selectedRule:S,setSelectedRule:M,severityOptions:st,ruleOptions:Ft,minsOptions:be,roleOptions:wt,l1mins:oe,setL1mins:fe,l1role:I,setL1role:A,l2mins:x,setL2mins:k,l2role:N,setL2role:D,l3mins:L,setL3mins:Y,l3role:J,setL3role:G,actions:Q,setActions:ce,thirdPartyIds:ke,setThirdPartyIds:ee,humanLoop:ye,setHumanLoop:Te,onClear:bs,onSave:hn,saving:Je,onActionTypesLoaded:F=>{const re={};for(const _ of F)typeof _.actionTypeId=="number"&&(re[_.actionTypeId]=_.name);X(re)},isAutoExpire:he,setAutoExpire:le})]}),i.jsx(h.Divider,{className:"my-6"}),i.jsx(Fl,{entries:Ie,userRoles:ne,loading:ft||r,onEdit:F=>{U("rules");const re=Ie.find(V=>V.id===F),_=e.find(V=>V.RuleId===F)||(re?e.find(V=>V.Name===re.ruleOrSeverityLabel):void 0);M(_?_.RuleId:F)}}),i.jsx(h.Divider,{className:"my-6"}),i.jsx(Aa,{userRoles:ne,rules:e,rawRules:n}),i.jsx(h.Divider,{})]})}const{Title:rr,Text:ls}=h.Typography;function Pl({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:a}=Ue(),o=[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],[l,c]=d.useState("By Severity"),[u,f]=d.useState(new Set),[m,p]=d.useState(null),[g,w]=d.useState(null),[j,E]=d.useState({inApp:!1,sms:!1,email:!1}),[C,O]=d.useState([]),[W,b]=d.useState(!0),[R,B]=d.useState(!1);d.useEffect(()=>{let y=!1;return(async()=>{try{const S=await a.getPreferenceSettings();if(y||!S)return;E({inApp:!!S.inApp,sms:!!S.sms,email:!!S.email});const M=oa(S.sortBy);c(M==="By Created Date"?"By Created Date":"By Severity"),p(Qn(S.doNotDisturbStart)),w(Qn(S.doNotDisturbEnd)),Array.isArray(S.anomalyIds)&&f(new Set(S.anomalyIds.map(oe=>String(oe))))}catch(S){console.error("Error in loading my preferences: ",S)}})(),()=>{y=!0}},[]),d.useEffect(()=>{let y=!1;return(async()=>{try{b(!0);const S=await r.getLookups();if(y||!S)return;const M=Array.isArray(S.anomalies)?S.anomalies:[];O(M)}catch(S){console.error("Failed to load anomalies lookups",S)}finally{y||b(!1)}})(),()=>{y=!0}},[]);const U=y=>{f(S=>{const M=new Set(S);return M.has(y)?M.delete(y):M.add(y),M})},q=async()=>{s?.({sortBy:l,subscribedRuleIds:Array.from(u),dnd:{from:m,to:g},channels:j});try{B(!0);const y=m?m.format?.("HH:mm:ss")??"00:00:00":"00:00:00",S=g?g.format?.("HH:mm:ss")??"00:00:00":"00:00:00",M=Array.from(u).map(fe=>Number(fe)).filter(fe=>Number.isFinite(fe)),oe=await a.setPreferenceSettings({anomalyIds:M,doNotDisturbStart:y,doNotDisturbEnd:S,inApp:!!j.inApp,sms:!!j.sms,email:!!j.email,sortBy:l});oe?.responseStatus&&Ne.toast.success(oe?.message||"Preferences updated successfully.")}catch(y){console.error("Error in saving my preferences: ",y)}finally{B(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(h.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:i.jsx(h.Col,{xs:24,md:8,children:i.jsxs(h.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(ls,{className:"text-gray-600",children:"Sort By:"}),i.jsx(h.Select,{className:"w-[240px]",value:l,options:o,onChange:c})]})})}),i.jsxs("div",{className:"mb-4",children:[i.jsx(rr,{level:5,className:"!mb-2",children:"Anomalies"}),W?i.jsx("div",{className:"py-4",children:i.jsx(h.Spin,{})}):i.jsx(h.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray(C)?C:[]).map(y=>{const S=String(y.recordId),M=y.anomalyName;return i.jsx(h.Checkbox,{checked:u.has(S),onChange:()=>U(S),children:M},S)})})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx(rr,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),i.jsx(h.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:i.jsx(h.Col,{xs:24,md:12,children:i.jsxs(h.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(ls,{children:"Do Not Disturb mode:"}),i.jsxs(h.Space,{size:12,className:"w-full",children:[i.jsxs(h.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(ls,{children:"From"}),i.jsx(h.TimePicker,{value:m,onChange:y=>p(y),format:"HH:mm"})]}),i.jsxs(h.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(ls,{children:"To"}),i.jsx(h.TimePicker,{value:g,onChange:y=>w(y),format:"HH:mm"})]})]})]})})}),i.jsxs(h.Row,{gutter:[24,12],children:[i.jsx(h.Col,{children:i.jsx(h.Checkbox,{checked:j.inApp,onChange:y=>E({...j,inApp:y.target.checked}),children:"In-app"})}),i.jsx(h.Col,{children:i.jsx(h.Checkbox,{checked:j.sms,onChange:y=>E({...j,sms:y.target.checked}),children:"SMS"})}),i.jsx(h.Col,{children:i.jsx(h.Checkbox,{checked:j.email,onChange:y=>E({...j,email:y.target.checked}),children:"Email"})})]})]}),i.jsx(h.Divider,{}),i.jsxs(h.Space,{className:"gap-3",children:[i.jsx(h.Button,{onClick:n,disabled:R,children:"Cancel"}),i.jsx(h.Button,{type:"primary",onClick:q,loading:R,children:"Save"})]})]})}function Ta({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r}){return i.jsx("div",{className:"w-full",children:i.jsx(Na,{severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r})})}const Wl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAIZSURBVHgBnZW/b9NAFMe/z3H6i1ZNJUBFQsL/QQkLCFBtRhhKF1ibhBmpXbtgFlYqsTG0gRGWwgAjMb8EYmjYGN0pCCrVVaX+SBxf37PiqHWcOu5Xsux79+6j77vz3RH66IbdsDTQPCFngmBwqMCPBwVXoe204Fd/2ZfrSWMpHrDshtGCvsY9FlKkFNYD+Es/7EtuX+itp1sLnLrScTWoPMYsfnty/lUPtAOs4syiUgQOoWHJpG9kdBiX11Z+UaZCk1YT+vOzACuzYxgf7hZbyBGvhTi9af+7SkQbyKi7M8N4ZJ5D+eU2dg9UN07KvyNOS8io6UkNFXMMj1/vnACKAuTmNXZpIqME+LF+iIbX7ukjkClODWTQw+ujuGYMYfXzXnICbxSBDrxAUvYDhkrZp6ggUC8+sDI7mpj9YmESb3/uJ5Z9TJ5A3eORvzsBpgs6lufGT2TKPNY3fbxh6Knis0FTSjnx+LP3u5DJicDi/t7MCFadPaRJQTl02/5vKcKnpITluYkwrWjksebs48Pvg3SoUkXtq32hxt+1pITI8Zc/zcGACN59ty/WdWnklV5ukZ+49wU8MUJIF3mBGlqUr3Dv1+wpl20v9UuP75pElyrgc3XK7UJFbLvK4DJiv9ggDmWcjO9G4imWvW00yV/hjvtpOFnpQOVLkcO+0EhyevGrROG1ol1hREFc8ZGxyddIje+v9c4i9+gI5z7MozLxclgAAAAASUVORK5CYII=",Bl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAKeSURBVHgBjVVdbtpAEJ5ZmygPfTBSaVWpUt0bwFuURgJOUG5QeoLACbw+QeAEwA3SGxgJokh9CDeI+xSpTRU/Imw8nbFZx6QQGAl5d2fm229+dkDYI2f6oaUAOwhWExBcPnL4FwFBSLCexpCMf+qPi12++PKgpR/cGOwRa1pwQIjgOoWkf6s/hOVzVd588R+/xWjf5YAY8Y0+ErQrZFfnXg3lK3uGm7A+RISOxfbit5NprqBxxgBoeEIVHehqtI9lSz+5McaaITaA2J17bycFaBayMOS8IaT+zHuv4Ui58P9oAvB4Ga0paUgqbFGswL5idIcIx3P9DCiXrQB7iJawcTiCkMMIUlj7Jo8zr6Yv/EfRXXIqRnzUxnP9u46Id8Q5Sslq3+pqWErHAPKqvxROC/ZMuJwKJ8bkPouUkrYUqgt5IgMDKAxfAYT8nAZnmR2A5J47YSjrFKyOYpZN2SiIJ8YjRqVfASyAFVg9s2F2gXwRsClMXdnYcFpq5PyiQ8KEilaywc79+aEow2i7fdCF46SIpuTvCGi2kWSXjCM4QqS4Zl3yjwQ0UySwrBfGRJNjQKW4ZrmEpL45CxUDTGWdgmoZgxOoDA6zxYgr7ZudhWk3x6Sp4kl0nZmgujQhcH5Cvqy/Hxi5hdL+dgsWxR2rma4FkLeDw+PMM243+t2YB0jDDI9nMBquyWqI3tjmLYguQfqDzxebty/DIcnePr9jfePVfDhSzv2/Hs8LAY3kMmFfTCl+rl3uu1GWF6Jx+X3vkpa+58jeeNyXvY3Pd8N+a0hvgK9ge3hMTmG5CPTnSICWcFpXaDfZUcAck99yOnZM/id3hcmAFV/hgEilU6p0TcH2gpZYS98xc/kXUJ8YImPFzfeLh0cgXbMp8n/yD3ySPZSK0MWKAAAAAElFTkSuQmCC";function Vl(t){const e=(t.status||"").toLowerCase()==="completed"?i.jsx("img",{src:Wl,alt:"completed",style:{width:20,height:20}}):i.jsx("img",{src:Bl,alt:"pending",style:{width:20,height:20}});return{title:i.jsxs("div",{className:"flex flex-col gap-0 min-w-0",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{className:"block text-sm break-words mb-1 overflow-visible whitespace-normal",children:i.jsx("b",{children:t.title})}),t.description?i.jsx("span",{className:"text-gray-500 text-xs",children:t.description}):null]}),t.timestamp?i.jsx("span",{className:"text-gray-500 text-xs",children:t.timestamp}):null]}),icon:e,description:null}}function Zl({data:t}){const{timeZoneDetails:e}=Lt();return i.jsx("div",{className:"w-full",children:i.jsx(h.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:i.jsxs("div",{className:"w-full",style:{maxHeight:"50vh",overflowY:"auto"},children:[i.jsx(h.Card,{className:"mb-4 rounded-md p-4",bordered:!0,children:i.jsxs("div",{className:"grid grid-cols-4 gap-6 text-xs",children:[i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Alert ID"}),i.jsx("span",{className:"text-black",children:t.summary.alertNumber})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Severity"}),i.jsx("span",{className:"text-black",children:t.summary.severity})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Location"}),i.jsx("span",{className:"text-black",children:t.summary.location})]})]})}),i.jsxs(h.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsx("h4",{className:"text-sm text-black font-medium",children:"Response Timeline/ Audit trail/log"})}),i.jsx("div",{className:"mt-2",children:i.jsx(h.Steps,{direction:"vertical",size:"small",current:1,items:(t.timeline||[]).map(Vl)})})]})]})},{key:"notification",label:"Notification Sent",children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",style:{maxHeight:"50vh",overflowY:"auto"},children:[(t.notifications||[]).map((s,n)=>i.jsxs(h.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsx("div",{className:"flex flex-col",children:i.jsx("h4",{className:"text-sm text-black font-medium",children:s.channelLabel})}),i.jsxs("span",{className:"text-[11px] px-2 py-1 rounded-full bg-green-50 text-green-700 border border-green-200",children:[s.delivered,"/",s.total," Delivered"]})]}),i.jsxs("div",{className:"mt-4",children:[i.jsxs("div",{className:"text-xs text-black font-medium",children:["Recipients (",s.total,")"]}),i.jsx("div",{className:"mt-2 flex flex-col gap-3 text-xs",children:(s.recipients||[]).map((r,a)=>{const o=String(r?.notificationReceipientType||"").toLowerCase()==="EscalationNotification".toLowerCase();return i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsxs("span",{className:"text-black",children:[r.name," -"," ",i.jsx("span",{style:{color:o?"#FF3B30":"#FFB86A"},children:o?"Escalation Notification":"Alert Notification"})]}),i.jsx("span",{className:"text-gray-500",children:r.phone}),r.sentAt?i.jsx("span",{className:"text-gray-500",children:Ot(r.sentAt,e?.ianaTimeZoneId,!0)}):null]}),i.jsx("span",{className:`text-[11px] px-3 py-[2px] rounded ${r.status==="Delivered"?"bg-green-50 text-green-700 border border-green-200":"bg-red-50 text-red-700 border border-red-200"}`,children:r.status})]},a)})})]})]},n)),t?.notifications?.length?null:i.jsx("span",{className:"text-gray-500 text-xs",children:"No notifications."})]})}]})})}const zl=({alertId:t,id:e,priority:s,spaceName:n,alertNumber:r,statusHistory:a,notifGroups:o})=>{const l={alertId:t??String(e??""),incidentId:"-",severity:s||"",location:n||"",alertNumber:r??""},{timeZoneDetails:c}=Lt(),u=a?.length?[...a].reverse().map(m=>{const p=(m?.status||m?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",g=m?.createdDate?Ot(m.createdDate,c?.ianaTimeZoneId):m?.timestamp?Ot(m.timestamp,c?.ianaTimeZoneId):"";return{status:p,title:m?.status||m?.eventStatus||"Status Update",description:m?.actionNotes||m?.description||"",timestamp:g}}):[],f={summary:l,timeline:u,notifications:o??[]};return i.jsx(Zl,{data:f})},Hl=({url:t,alt:e,isLoading:s,priority:n,detections:r,onLoadSuccess:a,onError:o})=>{const{imageRef:l,dimensions:c,onLoad:u}=ya(),f=d.useMemo(()=>ha(r,c.naturalWidth,c.naturalHeight,c.renderedWidth,c.renderedHeight),[r,c]),m=d.useMemo(()=>f.map(p=>({...p,label:p.personName||""})),[f]);return i.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[i.jsx("img",{ref:l,src:t,alt:e,className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg transition-opacity duration-200 ${s?"opacity-0":"opacity-100"}`,onLoad:()=>{u(),a()},onError:o}),i.jsx(fa,{boxes:m,priority:n})]})},ql=({items:t})=>{const{timeZoneDetails:e}=Lt(),s=a=>a?.replace(/([a-z])([A-Z])/g,"$1 $2"),r=(()=>{if(!t?.length||t.length<2)return null;const a=new Date(t[0].timeStamp).getTime(),o=new Date(t[t.length-1].timeStamp).getTime(),l=Math.floor((o-a)/1e3),c=o-a,u=Math.floor(l/3600),f=Math.floor(l%3600/60),m=l%60,p=c%1e3;return[u>0?`${u}h`:null,f>0?`${f}m`:null,`${m}s`,`${p}ms`].filter(Boolean).join(" ")})();return i.jsxs("div",{className:"bg-[#F7F7F7] rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[i.jsx("div",{className:"font-semibold text-base",children:"Alert Timeline"}),r&&i.jsxs(h.Tag,{color:"blue",children:["Total Duration: ",r]})]}),t?.length?i.jsx(h.Timeline,{items:t.map(a=>({dot:i.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-blue-500 bg-white flex items-center justify-center",children:i.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500"})}),children:i.jsxs("div",{className:"pb-4",children:[i.jsx("div",{className:"font-semibold text-[15px] text-[#1F2937]",children:s(a.eventName)}),i.jsxs("div",{className:"text-[#6B7280] text-sm",children:["Timestamp:"," ",Ot(a.timeStamp,e?.ianaTimeZoneId,!0)]}),a.timeElapsed&&i.jsxs("div",{className:"text-[#6B7280] text-sm",children:["Time Elapsed: ",a.timeElapsed,"s"]})]})}))}):i.jsx("div",{className:"text-center text-gray-500 py-8",children:"No Alert Timelines Found"})]})},Gl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Yl={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},_l={"elopement attempt":"elopement","elopement completed":"elopement","watchlist person detected":"watchlist","watch list person detected":"watchlist","brandished guns & knives":"weapon","brandished guns and knives":"weapon"},Jl=({isModalOpen:t,handleModalClose:e,selectedRow:s,fetchAlertLogs:n,alertStatusList:r=[],alertStatusLoading:a=!1,initialTab:o="details",sourceTab:l,onAlertView:c,showAlertTimeline:u})=>{const[f,m]=d.useState(),[p,g]=d.useState(""),[w,j]=d.useState(!1),[E,C]=d.useState([]),O=d.useRef(null),[W,b]=d.useState("details"),[R,B]=d.useState(void 0),U=mn(),{alerts:q,rules:y,config:S}=Ue(),{timeZoneDetails:M}=Lt(),[oe,fe]=d.useState(null),[I,A]=d.useState(!1),[x,k]=d.useState(!1),[N,D]=d.useState(void 0),[L,Y]=d.useState(void 0),[J,G]=d.useState({}),[Q,ce]=d.useState({}),ke=(v,H,ae)=>{const we=Q[v];return J[v]===!1&&!we?i.jsxs("div",{className:"w-full flex flex-col items-center justify-center min-h-[200px] bg-gray-100 rounded-lg gap-2 text-gray-400",children:[i.jsx(Sa,{size:40}),i.jsx("span",{className:"text-sm",children:"Media not available"})]}):i.jsxs("div",{className:"relative w-full flex justify-center items-center min-h-[200px]",children:[we&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg z-10",children:i.jsx(bl,{size:32,className:"animate-spin text-gray-400"})}),i.jsx(Hl,{url:v,alt:H.caption||`media-${ae}`,isLoading:we,priority:ne,detections:st,onLoadSuccess:()=>ce(ue=>({...ue,[v]:!1})),onError:()=>ce(ue=>({...ue,[v]:!1}))})]})},ee=s?.originalData||{},{eventName:ye,eventDisplayName:Te,anomalyName:he,alertId:le,timestamp:Le,description:X,spaceName:z,assignTeam:xe,priority:ne,statusType:Oe,id:Ie,alertDetails:Fe,statusHistory:Je,mediaDetails:ve,alertNumber:ft,personName:ht}=ee,$e=S.tenant==="snl",Ke=ee.bbox_xyxy,st=d.useMemo(()=>Ke?[{bbox_xyxy:Ke,personName:ee.personName}]:[],[Ke,ee.personName]),Ft=S.tenant==="snl"?Te||ye||"Alert Event":ye||"Alert Event",wt=v=>{const H=String(v||"").toLowerCase();return H==="delivered"||H==="sent"?"Delivered":H==="failed"?"Failed":"Queued"},be=v=>({name:v?.receipientName||v?.recipientName||"-",role:v?.receipientRoleName||"",phone:v?.receipentPhoneNumber||v?.recipientPhoneNumber||v?.receipientEmail||v?.recipientEmail||"",status:wt(v?.messageStatus),notificationReceipientType:v?.notificationReceipientType||"",sentAt:v?.sentAt||""}),At=(v,H)=>{const ae=H.map(be),we=ae.filter(We=>We.status==="Delivered").length,ue=H.map(We=>We?.sentAt).filter(Boolean).sort((We,yn)=>new Date(We).getTime()-new Date(yn).getTime())[0],pe=`${v} Notification`;return{channelLabel:`${v} Notification`,sentAt:ue||"",messageTitle:pe,messageBody:"",total:ae.length,delivered:we,recipients:ae}},Ns=v=>{const H=new Map;return(v||[]).forEach(ae=>{const we=String(ae?.notificationType||"Unknown"),ue=H.get(we)||[];ue.push(ae),H.set(we,ue)}),Array.from(H.entries()).map(([ae,we])=>At(ae,we))},Ts=async v=>{try{const H=await q.getAlertNotifications(v),ae=Ns(H);B(ae)}catch{B(void 0)}};d.useEffect(()=>{if(W!=="track"||!Ie)return;let v=!1;return Ts(Ie).then(()=>{v&&B(void 0)}),()=>{v=!0}},[W,Ie]),d.useEffect(()=>{if(!le){C([]);return}(async()=>{try{const H=await q.getAlertTimeline?.(String(le));C(H||[])}catch{C([])}})()},[le]),d.useEffect(()=>{t?b(o):(m(void 0),g(""))},[t,o]),d.useEffect(()=>{!t||!c||c([{personName:ee.personName,faceId:ee.faceId,mediaDetails:ee.mediaDetails}])},[t]),d.useEffect(()=>{if(!t||S.tenant!=="snl")return;let v=!1;return A(!0),y.getLookups().then(H=>{v||(fe(H.alertStatusTypes??[]),A(!1))}).catch(()=>{v||(fe([]),A(!1))}),()=>{v=!0}},[t,S.tenant]);const bs=l==="archived"||["completed","false positive"].includes(String(Oe||"").toLowerCase()),F=v=>{const H=String(v?.value||"").toLowerCase(),ae=String(v?.statusName||"").toLowerCase();return H.includes("reopen")||ae.includes("reopen")},re=String(he||"").trim().toLowerCase(),_=_l[re]??"general",V=r.filter(v=>{const H=F(v);return typeof l<"u"?l==="archived"?H:!H:bs?H:!H}).map(v=>({value:v.value,label:v.statusName})),de=oe??[],Z=v=>!!v.isWatchListStatus,te=v=>!!v.isWeapontStatus,$t=de.filter(v=>{switch(_){case"elopement":return v.isElopementStatus;case"watchlist":return Z(v);case"weapon":return te(v);default:return!v.isElopementStatus&&!Z(v)&&!te(v)}}).map(v=>({value:v.alertStatusTypeName,label:v.alertStatusTypeName})),Pt=S.tenant==="snl"&&oe!==null?$t:V,nt=d.useMemo(()=>ma(ve),[ve]);d.useEffect(()=>{let v=!1;const H=new AbortController,ae=async pe=>{if(pe){v||G(We=>({...We,[pe]:!1}));try{const We=await fetch(pe,{method:"HEAD",signal:H.signal});if(We.ok){v||G(Wt=>({...Wt,[pe]:!0}));return}if(We.status===404){v||G(Wt=>({...Wt,[pe]:!1}));return}if(!(await fetch(pe,{method:"GET",signal:H.signal})).ok)throw new Error("Media not available");v||G(Wt=>({...Wt,[pe]:!0}))}catch{v||G(We=>({...We,[pe]:!1}))}}};G({});const we=nt.filter(pe=>!Js(pe)).map(pe=>pe?.mediaUrl||pe).filter(pe=>typeof pe=="string"&&pe.length>0),ue={};return we.forEach(pe=>{ue[pe]=!0}),ce(ue),we.forEach(pe=>ae(pe)),()=>{v=!0,H.abort()}},[nt]);const Qt=async()=>{try{j(!0);const v={alertUniqueId:le,alertId:Ie,status:f?String(f):void 0,notes:p.trim(),modifiedBy:0},H=await U.mutateAsync(v);if(H?.responseStatus||H?.Success){const ae=H?.message||H?.Message||"Alert updated successfully.";Ne.toast.success(ae,{autoClose:1500,onClose:()=>{n(),e()}}),m(void 0),g("")}else{const ae=H?.errorMessage||H?.Message||"Failed to update alert status";Ne.toast.error(ae)}}catch(v){console.error("Error updating alert status:",v),Ne.toast.error("Failed to update alert status. Please try again.")}finally{j(!1)}};return i.jsx(h.Modal,{open:t,onCancel:e,width:1e3,closable:!x,maskClosable:!x,footer:W==="details"?i.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[i.jsx(h.Button,{onClick:e,className:"!bg-[#6C757D] !border-[#6C757D] hover:!bg-[#5c636a] hover:!border-[#5c636a]",children:"Cancel"}),i.jsx(h.Button,{type:"primary",onClick:Qt,loading:w,children:w?"Saving...":"Save Changes"})]}):null,children:s&&i.jsxs("div",{className:"relative",children:[$e&&ft?i.jsx("div",{className:"pointer-events-none absolute left-1/2 top-2 z-10 -translate-x-1/2",children:i.jsx("span",{className:"text-lg font-semibold text-black",children:ft})}):null,i.jsx(h.Tabs,{activeKey:W,onChange:v=>b(v),items:[{key:"details",label:"Alert Detail",children:i.jsxs("div",{className:"grid grid-cols-2 gap-2",style:{maxHeight:"50vh",overflowY:"auto"},children:[i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("div",{className:"text-sm font-bold",children:Ft}),Fe?.firstName?i.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",Fe?.firstName," ",Fe?.lastName||""," "," ",Fe?.residentId||""]}):null,i.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp:"," ",Ot(Le,M?.ianaTimeZoneId)]}),$e&&ht?.trim()?i.jsxs("div",{className:"font-sm text-gray-500",children:[i.jsx("b",{className:"text-black text-sm/6",children:"Resident:"})," ",ht.trim()]}):null,i.jsxs("div",{className:"font-sm text-gray-500",children:[i.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",X||"No description available"]}),z&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",z]}),xe&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",xe]}),i.jsxs("div",{className:"flex gap-2 justify-start mt-3",children:[i.jsxs(h.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${Gl[String(ne)]||"#DFE4EA"}`,backgroundColor:Yl[String(ne)]},children:["Severity: ",ne||"N/A"]}),i.jsxs(h.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(Oe||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",Oe||"N/A"]})]}),i.jsx("div",{className:"w-full flex flex-col justify-start items-start mt-2 font-bold",children:i.jsxs("div",{className:"w-full mt-4",children:[i.jsx("div",{className:"flex flex-col gap-2",children:i.jsx(h.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:v=>m(v),value:f,options:Pt,loading:S.tenant==="snl"?I:a})}),i.jsxs("div",{className:"flex flex-col gap-2 mt-3",children:[i.jsx("label",{htmlFor:"action-details-input",className:"text-xs text-gray-500 font-medium",children:"Action Taken (Comments)"}),i.jsx("textarea",{id:"action-details-input",placeholder:"Enter details...",className:"w-full text-gray-500 h-20 border border-grey-500 rounded-md p-2",value:p,onChange:v=>g(v.target.value)})]})]})})]}),i.jsxs("div",{className:"flex flex-col gap-4",children:[i.jsxs("div",{className:"w-full mt-1",children:[i.jsxs("div",{className:"w-full flex items-center justify-between",children:[i.jsx("h3",{className:"text-black font-bold text-sm",children:"Camera Footage"}),nt.length>1?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>O.current?.prev?.(),className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 text-gray-600","aria-label":"Previous media",children:i.jsx(St.LeftOutlined,{style:{fontSize:12}})}),i.jsx("button",{type:"button",onClick:()=>O.current?.next?.(),className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 text-gray-600","aria-label":"Next media",children:i.jsx(St.RightOutlined,{style:{fontSize:12}})})]}):null]}),nt.length?i.jsx("div",{className:"w-full",children:i.jsx(h.Carousel,{ref:O,dots:!0,className:"w-full",children:nt.map((v,H)=>{const ae=v.mediaUrl||v,we=Js(v);return i.jsxs("div",{className:"flex justify-center items-center relative",children:[we?i.jsxs("video",{width:"240",height:"200",controls:!0,className:"max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg",children:[i.jsx("source",{src:ae}),"Your browser does not support the video tag."]}):ke(String(ae),v,H),v.caption&&i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:v.caption}),!we&&J[String(ae)]?i.jsx("button",{onClick:()=>{k(!0),D(ae),Y(v.type||"image")},className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:i.jsx(Il,{size:20})}):null]},String(ae)||H)})})}):null]}),u&&i.jsx(ql,{items:E})]}),i.jsx(pa,{isOpen:x,onClose:()=>k(!1),src:N||"",type:L||"image",detections:st,priority:ne})]})},{key:"track",label:"Track Incident",children:i.jsx(zl,{alertId:le,id:Ie,priority:ne,spaceName:z,alertNumber:ft,statusHistory:Je,notifGroups:R})}]})]})})};function ba(){const{alerts:t}=Ue(),e=xt.useQuery({queryKey:["alerts","statusList"],queryFn:()=>t.getAlertStatusList(),staleTime:5*6e4});return{list:e.data??[],loading:e.isLoading,error:e.error,refetch:e.refetch}}function fn({alerts:t,loading:e=!1,columns:s,total:n,currentPage:r,onRefetch:a,onPageChange:o,onFilterChange:l,onAlertView:c,showAlertTimeline:u}){const[f,m]=d.useState(!1),[p,g]=d.useState(null),[w,j]=d.useState("details"),{list:E,loading:C}=ba(),{timeZoneDetails:O}=Lt(),W=O?.timeZoneName??"UTC",b=O?.ianaTimeZoneId??"UTC";function R(oe,fe){g(oe),j(fe?.tab??"details"),q(fe?.sourceTab??"active"),m(!0)}function B(){m(!1)}const[U,q]=d.useState("active"),[y,S]=d.useState(0),M=p?{originalData:{...p,alertId:p.alertId??p.id,mediaDetails:p.mediaDetails}}:null;return i.jsxs("div",{className:"p-6 flex flex-col items-start justify-start min-h-screen w-full overflow-auto",children:[i.jsxs("div",{className:"w-full grid grid-cols-3 sm:grid-cols-1 items-center mb-4",children:[i.jsx("h1",{className:"text-xl font-bold text-black",children:"Alert Console"}),i.jsx("div",{className:"flex items-center justify-start sm:justify-center",children:i.jsx(wa,{label:W,timeZone:b})})]}),i.jsx(h.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:oe=>{const fe=oe==="archived";S(I=>I+1),o?.(1),l?.({isArchived:fe})},items:[{key:"active",label:"Active",children:i.jsx(dn,{data:t,loading:e,pageSize:10,total:n,currentPage:r,columns:s||[],onAlertIdClick:R,onAlertView:c,onRefetch:a,onPageChange:o,onFilterChange:l,resetKey:y})},{key:"archived",label:"Archived",children:i.jsx(va,{alerts:t,loading:e,columns:s||[],total:n,currentPage:r,onAlertIdClick:R,onAlertView:c,onFilterChange:l,onPageChange:o,onRefetch:a,resetKey:y})},{key:"settings",label:"Settings",children:i.jsx(Kl,{})}]}),i.jsx(Jl,{isModalOpen:f,handleModalClose:B,selectedRow:M,fetchAlertLogs:()=>{},alertStatusList:E,alertStatusLoading:C,initialTab:w,sourceTab:U,onAlertView:c,showAlertTimeline:u})]})}function Kl(){const[t,e]=d.useState([]),[s,n]=d.useState([]),[r,a]=d.useState([]),[o,l]=d.useState([]),[c,u]=d.useState(!0),{rules:f}=Ue();return d.useEffect(()=>{let m=!0;return(async()=>{try{const p=await f.getRules();if(!m)return;l(Array.isArray(p)?p:[]);const g=(p||[]).map((w,j)=>({RuleId:w.ruleId||w.ruleName||String(j),Name:w.ruleName||w.Name||"-",Description:w.ruleDesc||w.Description||"",SeverityId:0}));e(g);try{const w=await f.getLookups(),j=Array.isArray(w?.userRoles)?w.userRoles.map(E=>({userRoleId:E.userRoleId??E.id,userRoleName:E.userRoleName??E.name})):[];n(j),a(Array.isArray(w?.severities)?w.severities:[])}catch{}}catch{}finally{m&&u(!1)}})(),()=>{m=!1}},[]),i.jsx(Ta,{severities:r,rules:t,userRoles:s,rawRules:o,loadingRules:c})}function Ql(t){return Array.isArray(t)?{items:t}:t}function ka(t=1,e){const{alerts:s,config:n}=Ue(),r=n.tenant==="schools"&&!!String(e?.searchText??"").trim(),a=xt.useQuery({queryKey:["alerts","list",n.tenant,t,e],queryFn:()=>{const o={...e};return n.tenant==="schools"?(o.pageNumber=t,o.pageSize=r?100:10):(o.pageNumber=t,o.pageSize=10),s.listAlerts(o).then(Ql)},staleTime:r?0:3e4});return{alerts:a.data?.items??[],total:a.data?.total,loading:a.isLoading,error:a.error,refetch:a.refetch}}function Xl(t){const[e,s]=d.useState(1),[n,r]=d.useState({}),{alerts:a,total:o,loading:l,refetch:c}=ka(e,n);d.useEffect(()=>{!l&&a.length>0&&t.onAlertView?.(a)},[a,l]);const u=f=>{"isArchived"in f?r({isArchived:f.isArchived}):r(m=>({...m,...f}))};return i.jsx(fn,{alerts:a,loading:l,columns:t.columns,total:o,currentPage:e,onRefetch:c,onPageChange:s,onFilterChange:u,onAlertView:t.onAlertView,showAlertTimeline:t.showAlertTimeline})}function ec({tenant:t,apiDomain:e,rulesDomain:s,headers:n,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,alerts:l,loading:c,columns:u,onAlertView:f,showAlertTimeline:m}){const[p]=d.useState(()=>new xt.QueryClient({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1}}})),g=d.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return i.jsx(xt.QueryClientProvider,{client:p,children:i.jsx(ua,{tenant:t,override:g,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,children:Array.isArray(l)?i.jsx(fn,{alerts:l,loading:!!c,columns:u,onAlertView:f,showAlertTimeline:m}):i.jsx(Xl,{columns:u,onAlertView:f,showAlertTimeline:m})})})}function tc(t){const{alerts:e}=Ue(),s=xt.useQuery({queryKey:["alerts","report",t],queryFn:()=>e.getAlertsReport(t),staleTime:6e4});return{data:s.data??[],loading:s.isLoading,error:s.error,refetch:s.refetch}}const sc=[{title:"ID",dataIndex:"id",key:"id",width:120},{title:"Priority",dataIndex:"priority",key:"priority",width:120},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:220},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description"}];exports.AlertAssignment=Aa;exports.AlertConsole=fn;exports.AlertConsoleWidget=ec;exports.AlertsTable=dn;exports.ApiProvider=ua;exports.ArchivedTable=va;exports.Clock=wa;exports.DataTable=da;exports.MyPreferencesPanel=Pl;exports.SettingsPanel=Na;exports.SettingsTabs=Ta;exports.exampleAlertColumns=sc;exports.useAlertStatusList=ba;exports.useAlerts=ka;exports.useAlertsReport=tc;exports.useApi=Ue;exports.useUpdateAlertStatus=mn;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|