@ssgc/alert-console 2.9.8 → 2.9.10
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 +2365 -2379
- 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"),f=require("antd"),ht=require("@ant-design/icons"),we=require("react-toastify"),yt=require("@tanstack/react-query"),Sa="#FF3B30",xa="#FF9500",va="#FFCC00",wa="#34C759",qt={critical:Sa,high:xa,medium:va,low:wa},cn={Critical:qt.critical,High:qt.high,Medium:qt.medium,Low:qt.low};function Aa(t){return cn[t]||cn.Low}function un(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),c=Number.parseFloat(r||"0"),l=Number.isFinite(a)?a:0,u=Number.isFinite(o)?o:0,m=Number.isFinite(c)?c:0;return l*3600+u*60+m}function dn(t){const e=t.thirdPartyIds??t.ThirdPartyIds??t.thirdPartyId??t.ThirdPartyId??"",s=Array.isArray(e)?e.join(","):String(e??"");if(!s||!s.trim())return[];const n=s.split(",").map(o=>parseInt(String(o).trim(),10)).filter(o=>Number.isFinite(o)),r=new Set,a=[];return n.forEach(o=>{r.has(o)||(r.add(o),a.push(o))}),a}function ls(t){return t.toLowerCase().replaceAll("'","").replaceAll("‘","").replaceAll("’","")}const Jn="",Ta=Jn,Na="",ba="",ka="",Ia="",mn={snl:{alerts:Jn,rules:Ta},schools:{alerts:Na,rules:ba},transit:{alerts:ka,rules:Ia}};function Ue(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ea(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Gt(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 Le(t,e){const s={...e.headers,...Ea()},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 Ma(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=Ue(t.baseUrl,"/api/Alert"),n=await Le(s,{method:"GET",headers:e});return Array.isArray(n)?n:[]},async getAlertStatusList(){const s=Ue(t.baseUrl,"/api/Alert/AlertStatusList"),n=await Le(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=Ue(t.baseUrl,"/Alerts/GetAlertsReport"),r=Gt(n,s),a=await Le(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Ue(t.baseUrl,"/api/Alert/status");return Le(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=Ue(t.baseUrl,"/api/Alert/GetAdminSettings"),n=await Le(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=Ue(t.baseUrl,"/api/Alert/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Le(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Ue(t.baseUrl,"/api/Alert/GetPreferenceSettings"),n=await Le(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=Ue(t.baseUrl,"/api/Alert/SetPreferenceSettings"),r=await Le(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=Ue(t.baseUrl,"/api/Alert/GetNotifications"),r=Gt(n,{alertId:s}),a=await Le(r,{method:"GET",headers:e});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]},async notifyFamilyMembers(s){const n=Ue(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=Gt(n,{alertId:s});return Le(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const a=Ue(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),o=Gt(a,{alertId:s,isEmail:n,isSMS:r});return Le(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Ue(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Le(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Ue(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Le(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null}}}function fn(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Oa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Yt(t,e){const s={...e.headers,...Oa()},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 ja(t){const e={"Content-Type":"application/json",...t.headers||{}},s=fn(t.baseUrl,"/api/Rules"),n=fn(t.baseUrl,"/api/Rules/lookups");return{async getRules(){const r=await Yt(s,{method:"GET",headers:e});return Array.isArray(r)?r:[]},async setEscalationSettings(r){return Yt(s,{method:"POST",headers:e,body:JSON.stringify(r??{})})},async getLookups(){return Yt(n,{method:"GET",headers:e})},async updateRule(r,a){const o=`${s}/${r}`;return Yt(o,{method:"PUT",headers:e,body:JSON.stringify(a??{})})}}}function Ca(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var rs={exports:{}},Da=rs.exports,hn;function Ra(){return hn||(hn=1,(function(t,e){(function(s,n){t.exports=n()})(Da,(function(){var s=1e3,n=6e4,r=36e5,a="millisecond",o="second",c="minute",l="hour",u="day",m="week",h="month",v="quarter",g="year",k="date",D="Invalid Date",R=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,G=/\[([^\]]+)]|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,q={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(j){var N=["th","st","nd","rd"],x=j%100;return"["+j+(N[(x-20)%10]||N[x]||N[0])+"]"}},P=function(j,N,x){var E=String(j);return!E||E.length>=N?j:""+Array(N+1-E.length).join(x)+j},S={s:P,z:function(j){var N=-j.utcOffset(),x=Math.abs(N),E=Math.floor(x/60),T=x%60;return(N<=0?"+":"-")+P(E,2,"0")+":"+P(T,2,"0")},m:function j(N,x){if(N.date()<x.date())return-j(x,N);var E=12*(x.year()-N.year())+(x.month()-N.month()),T=N.clone().add(E,h),F=x-T<0,C=N.clone().add(E+(F?-1:1),h);return+(-(E+(x-T)/(F?T-C:C-T))||0)},a:function(j){return j<0?Math.ceil(j)||0:Math.floor(j)},p:function(j){return{M:h,y:g,w:m,d:u,D:k,h:l,m:c,s:o,ms:a,Q:v}[j]||String(j||"").toLowerCase().replace(/s$/,"")},u:function(j){return j===void 0}},M="en",$={};$[M]=q;var U="$isDayjsObject",Z=function(j){return j instanceof ie||!(!j||!j[U])},p=function j(N,x,E){var T;if(!N)return M;if(typeof N=="string"){var F=N.toLowerCase();$[F]&&(T=F),x&&($[F]=x,T=F);var C=N.split("-");if(!T&&C.length>1)return j(C[0])}else{var _=N.name;$[_]=N,T=_}return!E&&T&&(M=T),T||!E&&M},w=function(j,N){if(Z(j))return j.clone();var x=typeof N=="object"?N:{};return x.date=j,x.args=arguments,new ie(x)},O=S;O.l=p,O.i=Z,O.w=function(j,N){return w(j,{locale:N.$L,utc:N.$u,x:N.$x,$offset:N.$offset})};var ie=(function(){function j(x){this.$L=p(x.locale,null,!0),this.parse(x),this.$x=this.$x||x.x||{},this[U]=!0}var N=j.prototype;return N.parse=function(x){this.$d=(function(E){var T=E.date,F=E.utc;if(T===null)return new Date(NaN);if(O.u(T))return new Date;if(T instanceof Date)return new Date(T);if(typeof T=="string"&&!/Z$/i.test(T)){var C=T.match(R);if(C){var _=C[2]-1||0,J=(C[7]||"0").substring(0,3);return F?new Date(Date.UTC(C[1],_,C[3]||1,C[4]||0,C[5]||0,C[6]||0,J)):new Date(C[1],_,C[3]||1,C[4]||0,C[5]||0,C[6]||0,J)}}return new Date(T)})(x),this.init()},N.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()},N.$utils=function(){return O},N.isValid=function(){return this.$d.toString()!==D},N.isSame=function(x,E){var T=w(x);return this.startOf(E)<=T&&T<=this.endOf(E)},N.isAfter=function(x,E){return w(x)<this.startOf(E)},N.isBefore=function(x,E){return this.endOf(E)<w(x)},N.$g=function(x,E,T){return O.u(x)?this[E]:this.set(T,x)},N.unix=function(){return Math.floor(this.valueOf()/1e3)},N.valueOf=function(){return this.$d.getTime()},N.startOf=function(x,E){var T=this,F=!!O.u(E)||E,C=O.p(x),_=function(ge,ue){var ae=O.w(T.$u?Date.UTC(T.$y,ue,ge):new Date(T.$y,ue,ge),T);return F?ae:ae.endOf(u)},J=function(ge,ue){return O.w(T.toDate()[ge].apply(T.toDate("s"),(F?[0,0,0,0]:[23,59,59,999]).slice(ue)),T)},se=this.$W,X=this.$M,oe=this.$D,Se="set"+(this.$u?"UTC":"");switch(C){case g:return F?_(1,0):_(31,11);case h:return F?_(1,X):_(0,X+1);case m:var ce=this.$locale().weekStart||0,ee=(se<ce?se+7:se)-ce;return _(F?oe-ee:oe+(6-ee),X);case u:case k:return J(Se+"Hours",0);case l:return J(Se+"Minutes",1);case c:return J(Se+"Seconds",2);case o:return J(Se+"Milliseconds",3);default:return this.clone()}},N.endOf=function(x){return this.startOf(x,!1)},N.$set=function(x,E){var T,F=O.p(x),C="set"+(this.$u?"UTC":""),_=(T={},T[u]=C+"Date",T[k]=C+"Date",T[h]=C+"Month",T[g]=C+"FullYear",T[l]=C+"Hours",T[c]=C+"Minutes",T[o]=C+"Seconds",T[a]=C+"Milliseconds",T)[F],J=F===u?this.$D+(E-this.$W):E;if(F===h||F===g){var se=this.clone().set(k,1);se.$d[_](J),se.init(),this.$d=se.set(k,Math.min(this.$D,se.daysInMonth())).$d}else _&&this.$d[_](J);return this.init(),this},N.set=function(x,E){return this.clone().$set(x,E)},N.get=function(x){return this[O.p(x)]()},N.add=function(x,E){var T,F=this;x=Number(x);var C=O.p(E),_=function(X){var oe=w(F);return O.w(oe.date(oe.date()+Math.round(X*x)),F)};if(C===h)return this.set(h,this.$M+x);if(C===g)return this.set(g,this.$y+x);if(C===u)return _(1);if(C===m)return _(7);var J=(T={},T[c]=n,T[l]=r,T[o]=s,T)[C]||1,se=this.$d.getTime()+x*J;return O.w(se,this)},N.subtract=function(x,E){return this.add(-1*x,E)},N.format=function(x){var E=this,T=this.$locale();if(!this.isValid())return T.invalidDate||D;var F=x||"YYYY-MM-DDTHH:mm:ssZ",C=O.z(this),_=this.$H,J=this.$m,se=this.$M,X=T.weekdays,oe=T.months,Se=T.meridiem,ce=function(ue,ae,Ae,Ce){return ue&&(ue[ae]||ue(E,F))||Ae[ae].slice(0,Ce)},ee=function(ue){return O.s(_%12||12,ue,"0")},ge=Se||function(ue,ae,Ae){var Ce=ue<12?"AM":"PM";return Ae?Ce.toLowerCase():Ce};return F.replace(G,(function(ue,ae){return ae||(function(Ae){switch(Ae){case"YY":return String(E.$y).slice(-2);case"YYYY":return O.s(E.$y,4,"0");case"M":return se+1;case"MM":return O.s(se+1,2,"0");case"MMM":return ce(T.monthsShort,se,oe,3);case"MMMM":return ce(oe,se);case"D":return E.$D;case"DD":return O.s(E.$D,2,"0");case"d":return String(E.$W);case"dd":return ce(T.weekdaysMin,E.$W,X,2);case"ddd":return ce(T.weekdaysShort,E.$W,X,3);case"dddd":return X[E.$W];case"H":return String(_);case"HH":return O.s(_,2,"0");case"h":return ee(1);case"hh":return ee(2);case"a":return ge(_,J,!0);case"A":return ge(_,J,!1);case"m":return String(J);case"mm":return O.s(J,2,"0");case"s":return String(E.$s);case"ss":return O.s(E.$s,2,"0");case"SSS":return O.s(E.$ms,3,"0");case"Z":return C}return null})(ue)||C.replace(":","")}))},N.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},N.diff=function(x,E,T){var F,C=this,_=O.p(E),J=w(x),se=(J.utcOffset()-this.utcOffset())*n,X=this-J,oe=function(){return O.m(C,J)};switch(_){case g:F=oe()/12;break;case h:F=oe();break;case v:F=oe()/3;break;case m:F=(X-se)/6048e5;break;case u:F=(X-se)/864e5;break;case l:F=X/r;break;case c:F=X/n;break;case o:F=X/s;break;default:F=X}return T?F:O.a(F)},N.daysInMonth=function(){return this.endOf(h).$D},N.$locale=function(){return $[this.$L]},N.locale=function(x,E){if(!x)return this.$L;var T=this.clone(),F=p(x,E,!0);return F&&(T.$L=F),T},N.clone=function(){return O.w(this.$d,this)},N.toDate=function(){return new Date(this.valueOf())},N.toJSON=function(){return this.isValid()?this.toISOString():null},N.toISOString=function(){return this.$d.toISOString()},N.toString=function(){return this.$d.toUTCString()},j})(),me=ie.prototype;return w.prototype=me,[["$ms",a],["$s",o],["$m",c],["$H",l],["$W",u],["$M",h],["$y",g],["$D",k]].forEach((function(j){me[j[1]]=function(N){return this.$g(N,j[0],j[1])}})),w.extend=function(j,N){return j.$i||(j(N,ie,w),j.$i=!0),w},w.locale=p,w.isDayjs=Z,w.unix=function(j){return w(1e3*j)},w.en=$[M],w.Ls=$,w.p={},w}))})(rs)),rs.exports}var Ua=Ra();const La=Ca(Ua);function Kn(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 Qn(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 yn(t){const{hours:e,minutes:s,seconds:n}=Qn(t);return La().hour(e).minute(s).second(n).millisecond(0)}function Oe(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Fa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function _t(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 je(t,e){const s={...e.headers,...Fa()},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 de=(...t)=>t.find(e=>e!=null);function Ut(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 $a(t){return Array.isArray(t)?t.map(e=>Ut(e,["alertLogId","alertId","status","description","actionNotes","createdDate","createdBy","modifiedDate","modifiedBy"])):t}function Pa(t){return{id:String(de(t?.AlertId,t?.alertId)??""),alertNumber:de(t?.AlertNumber,t?.alertNumber),priority:de(t?.Priority,t?.priority,"Low"),timestamp:de(t?.UpdatedUtc,t?.timestamp,""),statusType:de(t?.Status,t?.statusType,""),description:de(t?.Description,t?.description,""),eventName:de(t?.EventName,t?.eventName),ruleName:de(t?.RuleName,t?.ruleName),spaceId:de(t?.SpaceId,t?.spaceId),spaceName:de(t?.SpaceName,t?.spaceName),anomalyId:de(t?.AnomalyId,t?.anomalyId),severityId:de(t?.SeverityId,t?.severityId),assignTeam:de(t?.AssignTeam,t?.assignTeam),cameraName:de(t?.CameraName,t?.cameraName),type:de(t?.Type,t?.type),mediaDetails:de(t?.MediaDetails,t?.mediaDetails,t?.MediaUrls,t?.mediaUrls),additionalMedia:de(t?.AdditionalMedia,t?.additionalMedia),timeElapsed:de(t?.TimeElapsed,t?.timeElapsed),timeRemaining:de(t?.TimeRemaining,t?.timeRemaining),anomalyName:de(t?.AnomalyName,t?.anomalyName),alertDetails:de(t?.AlertDetails,t?.alertDetails),statusHistory:$a(de(t?.StatusHistory,t?.statusHistory)),isEmailSent:de(t?.IsEmailSent,t?.isEmailSent),isSMSSent:de(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:de(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function Wa(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Oe(t.baseUrl,"/api/detectionpolicy/alerts"),r=_t(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 je(r,{method:"GET",headers:e});return{items:Array.isArray(a?.Items)?a.Items.map(Pa):[],total:a?.Total}},async getAlertStatusList(){const s=Oe(t.baseUrl,"/api/detectionpolicy/alerts/StatusList"),n=await je(s,{method:"GET",headers:e});return(Array.isArray(n)?n:[]).map(a=>Ut(a,["alertStatusId","value","statusName"]))},async getAlertsReport(s){const n=Oe(t.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),r=_t(n,s),a=await je(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Oe(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 je(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getAdminSettings(){const s=Oe(t.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),n=await je(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n.Data??n;if(r&&typeof r=="object")return Ut(r,["userId","isAdminSetting","sortBy"],{sortBy:"SortOption"})}return null},async setAdminSettings(s){const n=Oe(t.baseUrl,"/api/detectionpolicy/alerts/SetAdminSettings"),r={Settings:{UserId:0,IsAdminSetting:!0,SortOption:s?.sortBy??"",GroupBy:s?.groupBy??null}};return je(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Oe(t.baseUrl,"/api/detectionpolicy/alerts/GetPreferenceSettings"),n=await je(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=Oe(t.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),r=u=>{const{hours:m,minutes:h,seconds:v}=Qn(u);return(m*3600+h*60+v)*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 je(n,{method:"POST",headers:e,body:JSON.stringify(a)}),c=o?.responseStatus??!0,l=o?.data??o?.message??"Preferences updated successfully.";return{responseStatus:c,errorMessage:c?"":o?.errorMessage??o?.Message??o?.message??"",statusCode:200,data:l}},async sendSMSorEmailNotifications(s,n,r){const a=Oe(t.baseUrl,"/api/detectionpolicy/alerts/SendSMSorEmailNotifications"),o=_t(a,{alertId:s,isEmail:n,isSMS:r});return je(o,{method:"POST",headers:e})},async getAlertNotifications(s){const n=Oe(t.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),r=_t(n,{alertId:s}),a=await je(r,{method:"GET",headers:e});let o=[];return Array.isArray(a)?o=a:Array.isArray(a?.data)&&(o=a.data),o.map(c=>Ut(c,["alertNotificationSentId","alertId","notificationType","receipientName","receipentPhoneNumber","messageSID","messageStatus","receipientEmail","notificationReceipientType","sentAt"]))},async getTimeZoneMasters(){const s=Oe(t.baseUrl,"/api/TimeZoneMaster"),n=await je(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n.Data:[]).map(a=>Ut(a,["timeZoneUniqueId","ianaTimeZoneId","timeZoneName","offset"]))},async getAllSpaces(){const s=t.spacesBaseUrl||t.baseUrl,n=Oe(s,"/api/AllSpaces"),r=await je(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=Oe(t.baseUrl,"/MyProfile"),n=await je(s,{method:"GET",headers:e}),r=n?.data?.userGuid??n?.Data?.userGuid??n?.userGuid;if(!r)return null;const a=Oe(t.baseUrl,`/api/GetMyAppPreferences/${r}`),o=await je(a,{method:"GET",headers:e});if(o&&typeof o=="object"){const c=o.data??o.Data??o,l=c?.timeZoneUniqueId??c?.TimeZoneUniqueId;if(l)return{timeZoneUniqueId:l}}return null}}}function Va(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function tt(t,e){const s={...e.headers,...Va()},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 Ba(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/api/detectionpolicy/rules",t.baseUrl).toString();return{async getRules(){const n=await tt(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 tt(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=p=>new URL(p,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[tt(n("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:e}),tt(n("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:e}),tt(n("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:e}),tt(n("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:e}),tt(n("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:e}),tt(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,c,l,u,m,h]=await Promise.allSettled(a),v=p=>{if(p.status!=="fulfilled")return[];const w=p.value;return Array.isArray(w)?w:Array.isArray(w?.Data)?w.Data:Array.isArray(w?.data)?w.data:[]},g=v(o),k=v(c),D=v(l),R=v(u),G=v(m),q=h.status==="fulfilled"?h.value:null;let P=[];Array.isArray(q)?P=q:Array.isArray(q?.Data)?P=q.Data:Array.isArray(q?.data)&&(P=q.data);const S=g.map(p=>({actionTypeId:Number(p?.ActionTypeId),name:p?.DisplayName??p?.Name??""})),M=k.map(p=>({recordId:p?.AnomalyId,anomalyName:p?.DisplayName??p?.Name??""})),$=D.map(p=>({thirdPartyId:Number(p?.ThirdPartyId),thirdPartyName:p?.ThirdPartyName??p?.Name??""})),U=P.map(p=>({userRoleId:p.UserRoleId??p.userRoleId??p.Id??p.id??0,userRoleName:p.UserRoleName??p.userRoleName??p.Name??p.name??""})),Z={actionTypes:S,anomalies:M,thirdParties:$};return R.length&&(Z.severities=R.map(p=>({severityId:p?.SeverityId??p?.severityId,severityName:p?.DisplayName??p?.SeverityName??p?.Name??p?.name??""}))),G.length&&(Z.scheduleTypes=G),U.length&&(Z.userRoles=U),Z},async updateRule(n,r){const a=`${s}/${n}`,{escalationSettings:o,Anomaly:c,Severity:l,...u}=r??{};return tt(a,{method:"PUT",headers:e,body:JSON.stringify({...u,CustomerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",Version:{DeDupWindowSeconds:0,IncludeSubjectInHash:!0},AnomalyId:c?.AnomalyId,SeverityId:l?.SeverityId,EscalationSettings:o?{...o,ThirdPartyIds:o.thirdPartyId??[]}:{}})})}}}function Za(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function it(t,e){const s={...e.headers,...Za()},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 za(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/list-rule",t.baseUrl).toString();return{async getRules(){const n=await it(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 it(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=[it(n("/api/ActionTypeMaster/GetAll"),{method:"GET",headers:e}),it(n("/api/anomaly/anomaly-list"),{method:"POST",headers:e,body:JSON.stringify({RuleLevel:1})}),it(n("/api/Lookup/ThirdParties"),{method:"GET",headers:e}),it(n("/api/anomaly/severity-list"),{method:"GET",headers:e}),it(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,c,l,u,m]=await Promise.allSettled(a),h=U=>{if(U.status!=="fulfilled")return[];const Z=U.value;return Array.isArray(Z)?Z:Array.isArray(Z?.data)?Z.data:[]},v=h(o),g=h(c),k=h(l),D=h(u),R=m.status==="fulfilled"?m.value:null,G=v.map(U=>({actionTypeId:U?.ActionTypeUniqueId,name:U?.Name??""})),q=g.map(U=>({recordId:U?.AnomalyId,anomalyName:U?.DisplayName??U?.Name??""})),P=k.map(U=>({thirdPartyId:Number(U?.ThirdPartyId),thirdPartyName:U?.ThirdPartyName??U?.Name??""}));let S=[];Array.isArray(R)?S=R:Array.isArray(R?.Data)?S=R.Data:Array.isArray(R?.data)&&(S=R.data);const M=S.map(U=>({userRoleId:U.userRoleId??0,userRoleName:U.userRoleName??""})),$={actionTypes:G,anomalies:q,thirdParties:P};return D.length&&($.severities=D.map(U=>({SeverityId:U.SeverityId,DisplayName:U.SeverityName??U.DisplayName??""}))),M.length&&($.userRoles=M),$},async updateRule(n,r){const a=new URL("/update-rule",t.baseUrl).toString(),{escalationSettings:o,ruleId:c,ruleName:l,ruleDesc:u,...m}=r??{},h=o??{},v=(h.escalationSettingsActionTypeIds??[]).filter(k=>k!=null&&!Number.isNaN(k)),g={Level1UserRoleId:h.level1UserRoleId??0,Level1PostAssistTime:h.level1PostAssistTime??0,Level2UserRoleId:h.level2UserRoleId??0,Level2PostAssistTime:h.level2PostAssistTime??0,Level3UserRoleId:h.level3UserRoleId??0,Level3PostAssistTime:h.level3PostAssistTime??0,EscalationSettingsActionTypeIds:v,ThirdPartyIds:h.thirdPartyId??[],HumanLoop:h.humanLoop??!1};return it(a,{method:"POST",headers:e,body:JSON.stringify({...m,RuleId:c??m.RuleId??n,RuleName:l??m.RuleName,RuleDesc:u??m.RuleDesc??null,ActionTypeUniqueIdList:v,EscalationSettings:g})})}}}function Pe(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ha(){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 We(t,e){const s={...e.headers,...Ha()},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 qa(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Pe(t.baseUrl,"/api/Alerts"),r=Jt(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=Jt(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=Jt(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=Jt(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 Xn=d.createContext(null);function er({tenant:t="snl",override:e,timeZone:s,userManagementDomain:n,spacesBaseUrl:r,children:a}){const o=d.useMemo(()=>{const l=e?.alertsBaseUrl?.trim()||mn[t]?.alerts||"";let u=e?.rulesBaseUrl?.trim()||mn[t]?.rules||"";t==="snl"&&(u=l);const m=e?.headers;return{tenant:t,alertsBaseUrl:l,rulesBaseUrl:u,headers:m,timeZone:s,userManagementDomain:n,spacesBaseUrl:r}},[t,e?.alertsBaseUrl,e?.rulesBaseUrl,JSON.stringify(e?.headers||{}),s,n,r]),c=d.useMemo(()=>{const l={baseUrl:o.alertsBaseUrl,headers:o.headers},u={baseUrl:o.rulesBaseUrl,headers:o.headers},m={schools:()=>Wa({...l,spacesBaseUrl:o.spacesBaseUrl}),transit:()=>qa(l),snl:()=>Ma(l)},h={schools:()=>Ba({...u,userManagementBaseUrl:o.userManagementDomain}),transit:()=>za({...u,userManagementBaseUrl:o.userManagementDomain}),snl:()=>ja({baseUrl:o.alertsBaseUrl,headers:o.headers})};return{config:o,alerts:m[o.tenant](),rules:h[o.tenant]()}},[o]);return i.jsx(Xn.Provider,{value:c,children:a})}function Me(){const t=d.useContext(Xn);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}const Ga={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Ya={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},_s=6,Js=7;function pn(t,e,s){const n=t===_s,r=t===Js,a=e.isEmailSent??!1,o=e.isSMSSent??!1,c=n&&a||r&&o,l=n?"Send Email":r?"Send SMS":s,u=n&&a?"Email sent":r&&o?"SMS sent":l,m=n&&a?"Email sent":r&&o?"SMS sent":`Click to ${l}`;return{isDisabled:c,buttonText:u,tooltipTitle:m}}function tr(t,e){const s=e==="anomalyDisplayName"?t.anomalyDisplayName:t.anomalyName;return typeof s=="string"&&s.trim().length>0?s.trim():""}function _a(t,e="anomalyName"){const s=new Set;(t||[]).forEach(r=>{const a=tr(r,e);a&&s.add(a)});const n=Array.from(s).map(r=>({label:r,value:r}));return[{label:"All Types",value:"All"},...n]}function Ja(t,e=!1){const s=new Set;(t||[]).forEach(r=>{const a=e?r.spaceNumber??r.spaceName:r.spaceName;typeof a=="string"&&a.trim().length>0&&s.add(a.trim())});const n=Array.from(s).map(r=>({label:r,value:r}));return[{label:"All",value:"All"},...n]}function Ns(t,e){return`${t}-${e?"email":"sms"}`}function Kt(t){return t===_s||t===Js}function hs({value:t,onChange:e,options:s,className:n,dropdownWidth:r}){return i.jsx(f.Select,{className:n,options:s,value:t,onChange:e,dropdownMatchSelectWidth:r??260})}const Ka=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function Qa({value:t,onChange:e,options:s}){return i.jsx(hs,{className:"w-[140px]",value:t,onChange:e,options:s||Ka})}const Xa=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function ei({value:t,onChange:e,options:s}){return i.jsx(hs,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||Xa})}function ti({value:t,onChange:e,options:s}){return i.jsx(hs,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const si=[{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 ni({value:t,onChange:e,options:s}){return i.jsx(hs,{className:"w-[130px]",value:t,onChange:e,options:s||si})}function sr({columns:t,data:e,loading:s=!1,pageSize:n=10,total:r,currentPage:a,rowKey:o="id",toolbar:c,tableProps:l,onPageChange:u}){const h=r===void 0&&a!==void 0?e.length===n?a*n+1:(a-1)*n+e.length:void 0;return i.jsxs("div",{children:[c,i.jsx(f.Table,{rowKey:o,dataSource:e,columns:t,loading:s,pagination:{pageSize:n,current:a,total:r??h,showSizeChanger:!1,showTotal:v=>`Total: ${v}`,onChange:u},bordered:!0,...l})]})}function ri(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 Ls(t){const e=(t?.mediaType||t?.type||"").toString().toLowerCase();return e==="video"||e==="mp4"?!0:ri(t?.mediaUrl||t)}function ai(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 nr(t){const e=t;return e?(Array.isArray(e)?e:[e]).flatMap(ai):[]}const ii=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),oi=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),gn=t=>{const e=oi(t);return e.charAt(0).toUpperCase()+e.slice(1)},rr=(...t)=>t.filter((e,s,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===s).join(" ").trim(),li=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var ci={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 ui=d.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:a,iconNode:o,...c},l)=>d.createElement("svg",{ref:l,...ci,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:rr("lucide",r),...!a&&!li(c)&&{"aria-hidden":"true"},...c},[...o.map(([u,m])=>d.createElement(u,m)),...Array.isArray(a)?a:[a]]));const ys=(t,e)=>{const s=d.forwardRef(({className:n,...r},a)=>d.createElement(ui,{ref:a,iconNode:e,className:rr(`lucide-${ii(gn(t))}`,`lucide-${t}`,n),...r}));return s.displayName=gn(t),s};const di=[["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"}]],ar=ys("image-off",di);const mi=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],fi=ys("loader-circle",mi);const hi=[["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"}]],ir=ys("maximize-2",hi);const yi=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],pi=ys("minimize-2",yi),or=({isOpen:t,onClose:e,src:s,type:n="image"})=>{const[r,a]=d.useState(!1),[o,c]=d.useState(!1);return d.useEffect(()=>{t&&c(!1)},[t,s]),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:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),e())},onTouchStart:e,children:i.jsxs("div",{className:`relative ${r?"w-full h-full":"max-w-5xl max-h-[90vh] w-full"} flex items-center justify-center`,onClick:l=>l.stopPropagation(),children:[n==="image"?i.jsx("img",{src:s,alt:"preview",className:`object-contain rounded-lg shadow-lg ${r?"w-full h-full":"max-w-full max-h-[90vh]"}`,onError:()=>c(!0)}):i.jsx("video",{src:s,controls:!0,className:`object-contain rounded-lg shadow-lg ${r?"w-full h-full":"max-w-full max-h-[90vh]"}`,onError:()=>c(!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:"✕"}),i.jsx("button",{onClick:()=>a(!r),className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:r?i.jsx(pi,{size:20}):i.jsx(ir,{size:20})})]})}):null};function gi(t){const s=nr(t.mediaDetails)[0];if(!s)return null;const n=s.mediaUrl??s;return typeof n!="string"||!n.length?null:{url:n,item:s}}function lr({record:t}){const e=d.useMemo(()=>gi(t),[t]),[s,n]=d.useState(!1),[r,a]=d.useState(!1);if(d.useEffect(()=>{a(!1)},[e?.url]),!e)return i.jsx("span",{className:"text-gray-400 text-sm",children:"—"});const{url:o,item:c}=e,l=Ls(c),u=l?"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(ar,{size:20,"aria-hidden":!0})}):l?i.jsx("video",{src:o,className:m,muted:!0,playsInline:!0,preload:"metadata",onError:()=>a(!0)}):i.jsx("img",{src:o,alt:"",className:m,onError:()=>a(!0)})}),i.jsx(or,{isOpen:s,onClose:()=>n(!1),src:o,type:u})]})}const cr=["completed","false positive","face doesn't match name","safe","supervised exit","elopement confirmed"];function Si(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 Ks({data:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,columns:a,severityOptions:o,anomalyOptions:c,spaceOptions:l,renderActions:u,onAlertIdClick:m,onAlertView:h,onRefetch:v,onPageChange:g,onFilterChange:k,excludeCompleted:D=!0,resetKey:R,serverSideFilters:G=!1}){const[q,P]=d.useState("All"),[S,M]=d.useState("All"),[$,U]=d.useState("All"),[Z,p]=d.useState("All"),[w,O]=d.useState(""),[ie,me]=d.useState(r??1);d.useEffect(()=>{R!==void 0&&(P("All"),M("All"),U("All"),p("All"),O(""),me(1))},[R]),d.useEffect(()=>{r!==void 0&&me(r)},[r]);const[j,N]=d.useState([{label:"All",value:"All"}]),[x,E]=d.useState([]),[T,F]=d.useState([]),[C,_]=d.useState([]),[J,se]=d.useState(new Set),{rules:X,alerts:oe,config:Se}=Me(),ce=Se.tenant==="schools",ee=Se.tenant==="transit",ge=Se.tenant==="snl"?"anomalyDisplayName":"anomalyName",ue=Si(w,600),ae=ce&&ue.trim()?100:s,Ae={6:{title:"Email",kind:"icon",icon:i.jsx(ht.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:i.jsx(ht.MessageOutlined,{})}},Ce=d.useMemo(()=>_a(t,ge),[t,ge]),Je=d.useMemo(()=>Ja(t,ee),[t,ee]);d.useEffect(()=>{if(!oe.getAllSpaces)return;let Y=!0;return(async()=>{try{const z=await oe.getAllSpaces();if(Y){const ve=z.map(fe=>({label:ee?String(fe.spaceNumber??fe.spaceName??""):fe.spaceName,value:String(ee?fe.spaceNumber??fe.spaceId:fe.spaceId)}));E([{label:"All",value:"All"},...ve])}}catch(z){console.error("Error loading space options",z)}})(),()=>{Y=!1}},[oe,ee]),d.useEffect(()=>{let Y=!0;return(async()=>{try{const z=await X.getLookups(),fe=(Array.isArray(z.thirdParties)?z.thirdParties:[]).map(I=>({label:I.thirdPartyName,value:String(I.thirdPartyId)})),De=(Array.isArray(z.anomalies)?z.anomalies:[]).map(I=>({label:I.anomalyName,value:String(I.recordId)})),Re=(Array.isArray(z.severities)?z.severities:[]).map(I=>({label:I.severityName,value:String(I.severityId)}));Y&&(N([{label:"All",value:"All"},...fe]),De.length&&F([{label:"All Types",value:"All"},...De]),Re.length&&_([{label:"All levels",value:"All"},...Re]))}catch(z){console.error("Error loading filter options",z)}})(),()=>{Y=!1}},[X]);const Ke=d.useMemo(()=>(t||[]).some(Y=>dn(Y).length>0),[t]);d.useEffect(()=>{if(!k)return;const Y={anomalyId:T.length>1&&S!=="All"?S:void 0,spaceId:!ee&&x.length>1&&$!=="All"?Number($):void 0,spaceNumber:ee&&x.length>1&&$!=="All"?$:void 0,severityId:C.length>1&&q!=="All"?Number(q):void 0,thirdPartyIds:Z==="All"?void 0:[Number(Z)],searchText:ce&&ue.trim()||void 0};k(Y),g?.(1)},[S,$,q,Z,ue,T.length,x.length,C.length,ee,ce]);const be=d.useMemo(()=>{const Y=G;return(t||[]).filter(z=>{const ve=Y||q==="All"||z.priority===q,fe=`${z.id} ${z.alertNumber} ${z.description} ${z.statusType}`.toLowerCase(),ke=!w||fe.includes(w.toLowerCase()),De=Y||S==="All"||tr(z,ge).toLowerCase()===S.toLowerCase(),$e=Y||$==="All"||(z.spaceName||"").toLowerCase()===$.toLowerCase(),Re=Y||!Ke||Z==="All"||dn(z).includes(Number(Z)),I=ls(String(z.statusType||"")),K=!D||!cr.some(H=>I.includes(ls(H)));return ve&&ke&&De&&$e&&Re&&K})},[t,q,w,S,$,Z,Ke,D,G,ge]),jt=Y=>{me(Y),g?.(Y)},Xe=d.useMemo(()=>{if(G)return be;const Y=(ie-1)*ae;return be.slice(Y,Y+ae)},[be,ie,ae,G]),at=d.useRef(h);d.useEffect(()=>{at.current=h},[h]),d.useEffect(()=>{at.current&&at.current(Xe.map(Y=>({personName:Y.personName,faceId:Y.faceId,mediaDetails:Y.mediaDetails})))},[Xe]);const Ct=c?.length?c:Ce,gt=G&&T.length>1?T:Ct,Dt=l?.length?l:Je,St=G&&x.length>1?x:Dt,ze=G&&C.length>1?C:o,xt=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:Y=>i.jsx(f.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Ya[Y]}`,backgroundColor:Ga[Y]},children:Y})},{title:"Tracker",key:"tracker",width:140,render:(Y,z)=>i.jsx("a",{onClick:ve=>{ve.preventDefault(),m?.(z,{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:(Y,z)=>{if(u)return i.jsx(i.Fragment,{children:u(z)});const ve=async(A,L)=>{const he=Ns(z.id,A);se(ne=>new Set(ne).add(he));try{const ne=await oe.sendSMSorEmailNotifications?.(z.id,A,L);ne?.responseStatus||ne?.Success||ne?.success?(we.toast.success(ne?.message||ne.data||(A?"Email sent successfully":"SMS sent successfully")),v?.()):we.toast.error(ne?.message||ne?.data||ne?.errorMessage||"Failed to send notification")}catch(ne){we.toast.error(ne?.message||"Failed to send notification")}finally{se(ne=>{const le=new Set(ne);return le.delete(he),le})}},fe=_s,ke=Js,De=Ae[fe],$e=Ae[ke],Re=pn(fe,z,De?.title),I=pn(ke,z,$e?.title),K=Ns(z.id,!0),H=Ns(z.id,!1),W=Kt(fe)&&J.has(K),y=Kt(ke)&&J.has(H);return i.jsxs(f.Space,{size:"middle",children:[i.jsx(f.Tooltip,{title:Re.tooltipTitle,children:i.jsx(f.Button,{size:"small",disabled:Re.isDisabled,loading:W,onClick:Kt(fe)?()=>ve(!0,!1):void 0,icon:!W&&De?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:Re.buttonText})},String(fe)),i.jsx(f.Tooltip,{title:I.tooltipTitle,children:i.jsx(f.Button,{size:"small",disabled:I.isDisabled,loading:y,onClick:Kt(ke)?()=>ve(!1,!0):void 0,icon:!y&&$e?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:I.buttonText})},String(ke))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(Y,z)=>{const ve=z?.timeElapsed,fe=z?.timeRemaining,ke=ve?un(ve):0,De=fe?un(fe):0,$e=Math.round(ke/(ke+De)*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:ve??"-"})]}),i.jsx(f.Progress,{percent:$e,showInfo:!1,size:"small",strokeColor:Aa(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:fe??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(Y,z)=>i.jsxs("div",{children:[i.jsx("a",{onClick:ve=>{ve.preventDefault(),m?.(z,{sourceTab:"active"})},className:"inline-block mb-1 text-blue-600",children:z.alertNumber}),i.jsx("div",{className:"text-black/65",children:Y})]})},{title:"Preview",key:"preview",width:100,align:"center",render:(Y,z)=>i.jsx(lr,{record:z})}],Ht=a&&a.length?a:xt;return i.jsx("div",{children:i.jsx(sr,{rowKey:"id",data:be,columns:Ht,loading:e,pageSize:ae,total:!G&&Se.tenant==="snl"?be.length:n,currentPage:ie,onPageChange:jt,toolbar:i.jsxs(f.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[i.jsx(f.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Severity"}),i.jsx(Qa,{value:q,onChange:P,options:ze})]})}),i.jsx(f.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Anomaly type"}),i.jsx(ei,{value:S,onChange:M,options:gt})]})}),i.jsx(f.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:ee?"Bus Number":"Space"}),i.jsx(ti,{value:$,onChange:U,options:St})]})}),i.jsx(f.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Action Taken"}),i.jsx(ni,{value:Z,onChange:p,options:j})]})}),i.jsx(f.Col,{flex:"auto"}),i.jsx(f.Col,{flex:"none",children:i.jsx(f.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:O,onChange:Y=>O(Y.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}function Qs(){const{alerts:t}=Me(),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 xi extends pt{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class vi extends pt{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class wi extends pt{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class Tt extends pt{}class ur extends pt{constructor(e){super(`Invalid unit ${e}`)}}class Te extends pt{}class ot extends pt{constructor(){super("Zone is an abstract class")}}const b="numeric",_e="short",Fe="long",cs={year:b,month:b,day:b},dr={year:b,month:_e,day:b},Ai={year:b,month:_e,day:b,weekday:_e},mr={year:b,month:Fe,day:b},fr={year:b,month:Fe,day:b,weekday:Fe},hr={hour:b,minute:b},yr={hour:b,minute:b,second:b},pr={hour:b,minute:b,second:b,timeZoneName:_e},gr={hour:b,minute:b,second:b,timeZoneName:Fe},Sr={hour:b,minute:b,hourCycle:"h23"},xr={hour:b,minute:b,second:b,hourCycle:"h23"},vr={hour:b,minute:b,second:b,hourCycle:"h23",timeZoneName:_e},wr={hour:b,minute:b,second:b,hourCycle:"h23",timeZoneName:Fe},Ar={year:b,month:b,day:b,hour:b,minute:b},Tr={year:b,month:b,day:b,hour:b,minute:b,second:b},Nr={year:b,month:_e,day:b,hour:b,minute:b},br={year:b,month:_e,day:b,hour:b,minute:b,second:b},Ti={year:b,month:_e,day:b,weekday:_e,hour:b,minute:b},kr={year:b,month:Fe,day:b,hour:b,minute:b,timeZoneName:_e},Ir={year:b,month:Fe,day:b,hour:b,minute:b,second:b,timeZoneName:_e},Er={year:b,month:Fe,day:b,weekday:Fe,hour:b,minute:b,timeZoneName:Fe},Mr={year:b,month:Fe,day:b,weekday:Fe,hour:b,minute:b,second:b,timeZoneName:Fe};class Vt{get type(){throw new ot}get name(){throw new ot}get ianaName(){return this.name}get isUniversal(){throw new ot}offsetName(e,s){throw new ot}formatOffset(e,s){throw new ot}offset(e){throw new ot}equals(e){throw new ot}get isValid(){throw new ot}}let bs=null;class ps extends Vt{static get instance(){return bs===null&&(bs=new ps),bs}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Wr(e,s,n)}formatOffset(e,s){return Pt(this.offset(e),s)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}}const Fs=new Map;function Ni(t){let e=Fs.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"}),Fs.set(t,e)),e}const bi={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function ki(t,e){const s=t.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(s),[,r,a,o,c,l,u,m]=n;return[o,r,a,c,l,u,m]}function Ii(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:a,value:o}=s[r],c=bi[a];a==="era"?n[c]=o:B(c)||(n[c]=parseInt(o,10))}return n}const ks=new Map;class rt extends Vt{static create(e){let s=ks.get(e);return s===void 0&&ks.set(e,s=new rt(e)),s}static resetCache(){ks.clear(),Fs.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=rt.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Wr(e,s,n,this.name)}formatOffset(e,s){return Pt(this.offset(e),s)}offset(e){if(!this.valid)return NaN;const s=new Date(e);if(isNaN(s))return NaN;const n=Ni(this.name);let[r,a,o,c,l,u,m]=n.formatToParts?Ii(n,s):ki(n,s);c==="BC"&&(r=-Math.abs(r)+1);const v=Ss({year:r,month:a,day:o,hour:l===24?0:l,minute:u,second:m,millisecond:0});let g=+s;const k=g%1e3;return g-=k>=0?k:1e3+k,(v-g)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let Sn={};function Ei(t,e={}){const s=JSON.stringify([t,e]);let n=Sn[s];return n||(n=new Intl.ListFormat(t,e),Sn[s]=n),n}const $s=new Map;function Ps(t,e={}){const s=JSON.stringify([t,e]);let n=$s.get(s);return n===void 0&&(n=new Intl.DateTimeFormat(t,e),$s.set(s,n)),n}const Ws=new Map;function Mi(t,e={}){const s=JSON.stringify([t,e]);let n=Ws.get(s);return n===void 0&&(n=new Intl.NumberFormat(t,e),Ws.set(s,n)),n}const Vs=new Map;function Oi(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 Lt=null;function ji(){return Lt||(Lt=new Intl.DateTimeFormat().resolvedOptions().locale,Lt)}const Bs=new Map;function Or(t){let e=Bs.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),Bs.set(t,e)),e}const Zs=new Map;function Ci(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={...jr,...e}),Zs.set(t,e)}return e}function Di(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=Ps(t).resolvedOptions(),r=t}catch{const l=t.substring(0,s);n=Ps(l).resolvedOptions(),r=l}const{numberingSystem:a,calendar:o}=n;return[r,a,o]}}function Ri(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function Ui(t){const e=[];for(let s=1;s<=12;s++){const n=V.utc(2009,s,1);e.push(t(n))}return e}function Li(t){const e=[];for(let s=1;s<=7;s++){const n=V.utc(2016,11,13+s);e.push(t(n))}return e}function Qt(t,e,s,n){const r=t.listingMode();return r==="error"?null:r==="en"?s(e):n(e)}function Fi(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||Or(t.locale).numberingSystem==="latn"}class $i{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 c={useGrouping:!1,...n};n.padTo>0&&(c.minimumIntegerDigits=n.padTo),this.inf=Mi(e,c)}}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):nn(e,3);return xe(s,this.padTo)}}}class Pi{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),c=o>=0?`Etc/GMT+${o}`:`Etc/GMT${o}`;e.offset!==0&&rt.create(c).valid?(r=c,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=Ps(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 Wi{constructor(e,s,n){this.opts={style:"long",...n},!s&&$r()&&(this.rtf=Oi(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):lo(s,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,s){return this.rtf?this.rtf.formatToParts(e,s):[]}}const jr={firstDay:1,minimalDays:4,weekend:[6,7]};class re{static fromOpts(e){return re.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,s,n,r,a=!1){const o=e||pe.defaultLocale,c=o||(a?"en-US":ji()),l=s||pe.defaultNumberingSystem,u=n||pe.defaultOutputCalendar,m=Hs(r)||pe.defaultWeekSettings;return new re(c,l,u,m,o)}static resetCache(){Lt=null,$s.clear(),Ws.clear(),Vs.clear(),Bs.clear(),Zs.clear()}static fromObject({locale:e,numberingSystem:s,outputCalendar:n,weekSettings:r}={}){return re.create(e,s,n,r)}constructor(e,s,n,r,a){const[o,c,l]=Di(e);this.locale=o,this.numberingSystem=s||c||null,this.outputCalendar=n||l||null,this.weekSettings=r,this.intl=Ri(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=Fi(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:re.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,Hs(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 Qt(this,e,Zr,()=>{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?c=>this.dtFormatter(c,r).format():c=>this.extract(c,r,"month");this.monthsCache[a][e]=Ui(o)}return this.monthsCache[a][e]})}weekdays(e,s=!1){return Qt(this,e,qr,()=>{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]=Li(a=>this.extract(a,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return Qt(this,void 0,()=>Gr,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[V.utc(2016,11,13,9),V.utc(2016,11,13,19)].map(s=>this.extract(s,e,"dayperiod"))}return this.meridiemCache})}eras(e){return Qt(this,e,Yr,()=>{const s={era:e};return this.eraCache[e]||(this.eraCache[e]=[V.utc(-40,1,1),V.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(c=>c.type.toLowerCase()===n);return o?o.value:null}numberFormatter(e={}){return new $i(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new Pi(e,this.intl,s)}relFormatter(e={}){return new Wi(this.intl,this.isEnglish(),e)}listFormatter(e={}){return Ei(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||Or(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:Pr()?Ci(this.locale):jr}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 Is=null;class Ee extends Vt{static get utcInstance(){return Is===null&&(Is=new Ee(0)),Is}static instance(e){return e===0?Ee.utcInstance:new Ee(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new Ee(xs(s[1],s[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Pt(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Pt(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,s){return Pt(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 Vi extends Vt{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 ct(t,e){if(B(t)||t===null)return e;if(t instanceof Vt)return t;if(Gi(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?ps.instance:s==="utc"||s==="gmt"?Ee.utcInstance:Ee.parseSpecifier(s)||rt.create(t)}else return ut(t)?Ee.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new Vi(t)}const Xs={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},xn={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]},Bi=Xs.hanidec.replace(/[\[|\]]/g,"").split("");function Zi(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(Xs.hanidec)!==-1)e+=Bi.indexOf(t[s]);else for(const r in xn){const[a,o]=xn[r];n>=a&&n<=o&&(e+=n-a)}}return parseInt(e,10)}else return e}const zs=new Map;function zi(){zs.clear()}function qe({numberingSystem:t},e=""){const s=t||"latn";let n=zs.get(s);n===void 0&&(n=new Map,zs.set(s,n));let r=n.get(e);return r===void 0&&(r=new RegExp(`${Xs[s]}${e}`),n.set(e,r)),r}let vn=()=>Date.now(),wn="system",An=null,Tn=null,Nn=null,bn=60,kn,In=null;class pe{static get now(){return vn}static set now(e){vn=e}static set defaultZone(e){wn=e}static get defaultZone(){return ct(wn,ps.instance)}static get defaultLocale(){return An}static set defaultLocale(e){An=e}static get defaultNumberingSystem(){return Tn}static set defaultNumberingSystem(e){Tn=e}static get defaultOutputCalendar(){return Nn}static set defaultOutputCalendar(e){Nn=e}static get defaultWeekSettings(){return In}static set defaultWeekSettings(e){In=Hs(e)}static get twoDigitCutoffYear(){return bn}static set twoDigitCutoffYear(e){bn=e%100}static get throwOnInvalid(){return kn}static set throwOnInvalid(e){kn=e}static resetCaches(){re.resetCache(),rt.resetCache(),V.resetCache(),zi()}}class Ye{constructor(e,s){this.reason=e,this.explanation=s}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const Cr=[0,31,59,90,120,151,181,212,243,273,304,334],Dr=[0,31,60,91,121,152,182,213,244,274,305,335];function Be(t,e){return new Ye("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function en(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 Rr(t,e,s){return s+(Bt(t)?Dr:Cr)[e-1]}function Ur(t,e){const s=Bt(t)?Dr:Cr,n=s.findIndex(a=>a<e),r=e-s[n];return{month:n+1,day:r}}function tn(t,e){return(t-e+7)%7+1}function us(t,e=4,s=1){const{year:n,month:r,day:a}=t,o=Rr(n,r,a),c=tn(en(n,r,a),s);let l=Math.floor((o-c+14-e)/7),u;return l<1?(u=n-1,l=Wt(u,e,s)):l>Wt(n,e,s)?(u=n+1,l=1):u=n,{weekYear:u,weekNumber:l,weekday:c,...vs(t)}}function En(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:a}=t,o=tn(en(n,1,e),s),c=Nt(n);let l=r*7+a-o-7+e,u;l<1?(u=n-1,l+=Nt(u)):l>c?(u=n+1,l-=Nt(n)):u=n;const{month:m,day:h}=Ur(u,l);return{year:u,month:m,day:h,...vs(t)}}function Es(t){const{year:e,month:s,day:n}=t,r=Rr(e,s,n);return{year:e,ordinal:r,...vs(t)}}function Mn(t){const{year:e,ordinal:s}=t,{month:n,day:r}=Ur(e,s);return{year:e,month:n,day:r,...vs(t)}}function On(t,e){if(!B(t.localWeekday)||!B(t.localWeekNumber)||!B(t.localWeekYear)){if(!B(t.weekday)||!B(t.weekNumber)||!B(t.weekYear))throw new Tt("Cannot mix locale-based week fields with ISO-based week fields");return B(t.localWeekday)||(t.weekday=t.localWeekday),B(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),B(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 Hi(t,e=4,s=1){const n=gs(t.weekYear),r=Ze(t.weekNumber,1,Wt(t.weekYear,e,s)),a=Ze(t.weekday,1,7);return n?r?a?!1:Be("weekday",t.weekday):Be("week",t.weekNumber):Be("weekYear",t.weekYear)}function qi(t){const e=gs(t.year),s=Ze(t.ordinal,1,Nt(t.year));return e?s?!1:Be("ordinal",t.ordinal):Be("year",t.year)}function Lr(t){const e=gs(t.year),s=Ze(t.month,1,12),n=Ze(t.day,1,ds(t.year,t.month));return e?s?n?!1:Be("day",t.day):Be("month",t.month):Be("year",t.year)}function Fr(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),c=Ze(n,0,59),l=Ze(r,0,999);return a?o?c?l?!1:Be("millisecond",r):Be("second",n):Be("minute",s):Be("hour",e)}function B(t){return typeof t>"u"}function ut(t){return typeof t=="number"}function gs(t){return typeof t=="number"&&t%1===0}function Gi(t){return typeof t=="string"}function Yi(t){return Object.prototype.toString.call(t)==="[object Date]"}function $r(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function Pr(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function _i(t){return Array.isArray(t)?t:[t]}function jn(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 Ji(t,e){return e.reduce((s,n)=>(s[n]=t[n],s),{})}function kt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Hs(t){if(t==null)return null;if(typeof t!="object")throw new Te("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 Te("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function Ze(t,e,s){return gs(t)&&t>=e&&t<=s}function Ki(t,e){return t-e*Math.floor(t/e)}function xe(t,e=2){const s=t<0;let n;return s?n="-"+(""+-t).padStart(e,"0"):n=(""+t).padStart(e,"0"),n}function lt(t){if(!(B(t)||t===null||t===""))return parseInt(t,10)}function dt(t){if(!(B(t)||t===null||t===""))return parseFloat(t)}function sn(t){if(!(B(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function nn(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 Bt(t){return t%4===0&&(t%100!==0||t%400===0)}function Nt(t){return Bt(t)?366:365}function ds(t,e){const s=Ki(e-1,12)+1,n=t+(e-s)/12;return s===2?Bt(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][s-1]}function Ss(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-tn(en(t,1,e),s)+e-1}function Wt(t,e=4,s=1){const n=Cn(t,e,s),r=Cn(t+1,e,s);return(Nt(t)-n+r)/7}function qs(t){return t>99?t:t>pe.twoDigitCutoffYear?1900+t:2e3+t}function Wr(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},c=new Intl.DateTimeFormat(s,o).formatToParts(r).find(l=>l.type.toLowerCase()==="timezonename");return c?c.value:null}function xs(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 Vr(t){const e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new Te(`Invalid unit value ${t}`);return e}function ms(t,e){const s={};for(const n in t)if(kt(t,n)){const r=t[n];if(r==null)continue;s[e(n)]=Vr(r)}return s}function Pt(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}${xe(s,2)}:${xe(n,2)}`;case"narrow":return`${r}${s}${n>0?`:${n}`:""}`;case"techie":return`${r}${xe(s,2)}${xe(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function vs(t){return Ji(t,["hour","minute","second","millisecond"])}const Qi=["January","February","March","April","May","June","July","August","September","October","November","December"],Br=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Xi=["J","F","M","A","M","J","J","A","S","O","N","D"];function Zr(t){switch(t){case"narrow":return[...Xi];case"short":return[...Br];case"long":return[...Qi];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 zr=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Hr=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],eo=["M","T","W","T","F","S","S"];function qr(t){switch(t){case"narrow":return[...eo];case"short":return[...Hr];case"long":return[...zr];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const Gr=["AM","PM"],to=["Before Christ","Anno Domini"],so=["BC","AD"],no=["B","A"];function Yr(t){switch(t){case"narrow":return[...no];case"short":return[...so];case"long":return[...to];default:return null}}function ro(t){return Gr[t.hour<12?0:1]}function ao(t,e){return qr(e)[t.weekday-1]}function io(t,e){return Zr(e)[t.month-1]}function oo(t,e){return Yr(e)[t.year<0?0:1]}function lo(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 h=t==="days";switch(e){case 1:return h?"tomorrow":`next ${r[t][0]}`;case-1:return h?"yesterday":`last ${r[t][0]}`;case 0:return h?"today":`this ${r[t][0]}`}}const o=Object.is(e,-0)||e<0,c=Math.abs(e),l=c===1,u=r[t],m=n?l?u[1]:u[2]||u[1]:l?r[t][0]:t;return o?`${c} ${m} ago`:`in ${c} ${m}`}function Dn(t,e){let s="";for(const n of t)n.literal?s+=n.val:s+=e(n.val);return s}const co={D:cs,DD:dr,DDD:mr,DDDD:fr,t:hr,tt:yr,ttt:pr,tttt:gr,T:Sr,TT:xr,TTT:vr,TTTT:wr,f:Ar,ff:Nr,fff:kr,ffff:Er,F:Tr,FF:br,FFF:Ir,FFFF:Mr};class Ne{static create(e,s={}){return new Ne(e,s)}static parseFormat(e){let s=null,n="",r=!1;const a=[];for(let o=0;o<e.length;o++){const c=e.charAt(o);c==="'"?((n.length>0||r)&&a.push({literal:r||/^\s+$/.test(n),val:n===""?"'":n}),s=null,n="",r=!r):r||c===s?n+=c:(n.length>0&&a.push({literal:/^\s+$/.test(n),val:n}),n=c,s=c)}return n.length>0&&a.push({literal:r||/^\s+$/.test(n),val:n}),a}static macroTokenToFormatOpts(e){return co[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 xe(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,k)=>this.loc.extract(e,g,k),o=g=>e.isOffsetFixed&&e.offset===0&&g.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,g.format):"",c=()=>n?ro(e):a({hour:"numeric",hourCycle:"h12"},"dayperiod"),l=(g,k)=>n?io(e,g):a(k?{month:g}:{month:g,day:"numeric"},"month"),u=(g,k)=>n?ao(e,g):a(k?{weekday:g}:{weekday:g,month:"long",day:"numeric"},"weekday"),m=g=>{const k=Ne.macroTokenToFormatOpts(g);return k?this.formatWithSystemDefault(e,k):g},h=g=>n?oo(e,g):a({era:g},"era"),v=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 c();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 l("short",!0);case"LLLL":return l("long",!0);case"LLLLL":return l("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 l("short",!1);case"MMMM":return l("long",!1);case"MMMMM":return l("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 h("short");case"GG":return h("long");case"GGGGG":return h("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 m(g)}};return Dn(Ne.parseFormat(s),v)}formatDurationFromString(e,s){const n=this.opts.signMode==="negativeLargestOnly"?-1:1,r=m=>{switch(m[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=(m,h)=>v=>{const g=r(v);if(g){const k=h.isNegativeDuration&&g!==h.largestUnit?n:1;let D;return this.opts.signMode==="negativeLargestOnly"&&g!==h.largestUnit?D="never":this.opts.signMode==="all"?D="always":D="auto",this.num(m.get(g)*k,v.length,D)}else return v},o=Ne.parseFormat(s),c=o.reduce((m,{literal:h,val:v})=>h?m:m.concat(v),[]),l=e.shiftTo(...c.map(r).filter(m=>m)),u={isNegativeDuration:l<0,largestUnit:Object.keys(l.values)[0]};return Dn(o,a(l,u))}}const _r=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function It(...t){const e=t.reduce((s,n)=>s+n.source,"");return RegExp(`^${e}$`)}function Et(...t){return e=>t.reduce(([s,n,r],a)=>{const[o,c,l]=a(e,r);return[{...s,...o},c||n,l]},[{},null,1]).slice(0,2)}function Mt(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 Jr(...t){return(e,s)=>{const n={};let r;for(r=0;r<t.length;r++)n[t[r]]=lt(e[s+r]);return[n,null,s+r]}}const Kr=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,uo=`(?:${Kr.source}?(?:\\[(${_r.source})\\])?)?`,rn=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Qr=RegExp(`${rn.source}${uo}`),an=RegExp(`(?:[Tt]${Qr.source})?`),mo=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,fo=/(\d{4})-?W(\d\d)(?:-?(\d))?/,ho=/(\d{4})-?(\d{3})/,yo=Jr("weekYear","weekNumber","weekDay"),po=Jr("year","ordinal"),go=/(\d{4})-(\d\d)-(\d\d)/,Xr=RegExp(`${rn.source} ?(?:${Kr.source}|(${_r.source}))?`),So=RegExp(`(?: ${Xr.source})?`);function bt(t,e,s){const n=t[e];return B(n)?s:lt(n)}function xo(t,e){return[{year:bt(t,e),month:bt(t,e+1,1),day:bt(t,e+2,1)},null,e+3]}function Ot(t,e){return[{hours:bt(t,e,0),minutes:bt(t,e+1,0),seconds:bt(t,e+2,0),milliseconds:sn(t[e+3])},null,e+4]}function Zt(t,e){const s=!t[e]&&!t[e+1],n=xs(t[e+1],t[e+2]),r=s?null:Ee.instance(n);return[{},r,e+3]}function zt(t,e){const s=t[e]?rt.create(t[e]):null;return[{},s,e+1]}const vo=RegExp(`^T?${rn.source}$`),wo=/^-?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 Ao(t){const[e,s,n,r,a,o,c,l,u]=t,m=e[0]==="-",h=l&&l[0]==="-",v=(g,k=!1)=>g!==void 0&&(k||g&&m)?-g:g;return[{years:v(dt(s)),months:v(dt(n)),weeks:v(dt(r)),days:v(dt(a)),hours:v(dt(o)),minutes:v(dt(c)),seconds:v(dt(l),l==="-0"),milliseconds:v(sn(u),h)}]}const To={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function on(t,e,s,n,r,a,o){const c={year:e.length===2?qs(lt(e)):lt(e),month:Br.indexOf(s)+1,day:lt(n),hour:lt(r),minute:lt(a)};return o&&(c.second=lt(o)),t&&(c.weekday=t.length>3?zr.indexOf(t)+1:Hr.indexOf(t)+1),c}const No=/^(?:(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 bo(t){const[,e,s,n,r,a,o,c,l,u,m,h]=t,v=on(e,r,n,s,a,o,c);let g;return l?g=To[l]:u?g=0:g=xs(m,h),[v,new Ee(g)]}function ko(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const Io=/^(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$/,Eo=/^(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$/,Mo=/^(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 Rn(t){const[,e,s,n,r,a,o,c]=t;return[on(e,r,n,s,a,o,c),Ee.utcInstance]}function Oo(t){const[,e,s,n,r,a,o,c]=t;return[on(e,c,s,n,r,a,o),Ee.utcInstance]}const jo=It(mo,an),Co=It(fo,an),Do=It(ho,an),Ro=It(Qr),ea=Et(xo,Ot,Zt,zt),Uo=Et(yo,Ot,Zt,zt),Lo=Et(po,Ot,Zt,zt),Fo=Et(Ot,Zt,zt);function $o(t){return Mt(t,[jo,ea],[Co,Uo],[Do,Lo],[Ro,Fo])}function Po(t){return Mt(ko(t),[No,bo])}function Wo(t){return Mt(t,[Io,Rn],[Eo,Rn],[Mo,Oo])}function Vo(t){return Mt(t,[wo,Ao])}const Bo=Et(Ot);function Zo(t){return Mt(t,[vo,Bo])}const zo=It(go,So),Ho=It(Xr),qo=Et(Ot,Zt,zt);function Go(t){return Mt(t,[zo,ea],[Ho,qo])}const Un="Invalid Duration",ta={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}},Yo={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},...ta},Ve=146097/400,vt=146097/4800,_o={years:{quarters:4,months:12,weeks:Ve/7,days:Ve,hours:Ve*24,minutes:Ve*24*60,seconds:Ve*24*60*60,milliseconds:Ve*24*60*60*1e3},quarters:{months:3,weeks:Ve/28,days:Ve/4,hours:Ve*24/4,minutes:Ve*24*60/4,seconds:Ve*24*60*60/4,milliseconds:Ve*24*60*60*1e3/4},months:{weeks:vt/7,days:vt,hours:vt*24,minutes:vt*24*60,seconds:vt*24*60*60,milliseconds:vt*24*60*60*1e3},...ta},ft=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Jo=ft.slice(0).reverse();function st(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 sa(t,e){let s=e.milliseconds??0;for(const n of Jo.slice(1))e[n]&&(s+=e[n]*t[n].milliseconds);return s}function Ln(t,e){const s=sa(t,e)<0?-1:1;ft.reduceRight((n,r)=>{if(B(e[r]))return n;if(n){const a=e[n]*s,o=t[r][n],c=Math.floor(a/o);e[r]+=c*s,e[n]-=c*o*s}return r},null),ft.reduce((n,r)=>{if(B(e[r]))return n;if(n){const a=e[n]%1;e[n]-=a,e[r]+=a*t[n][r]}return r},null)}function Fn(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?_o:Yo;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||re.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 Te(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new Q({values:ms(e,Q.normalizeUnit),loc:re.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(ut(e))return Q.fromMillis(e);if(Q.isDuration(e))return e;if(typeof e=="object")return Q.fromObject(e);throw new Te(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,s){const[n]=Vo(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]=Zo(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 Te("need to specify a reason the Duration is invalid");const n=e instanceof Ye?e:new Ye(e,s);if(pe.throwOnInvalid)throw new wi(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 ur(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?Ne.create(this.loc,n).formatDurationFromString(this,e):Un}toHuman(e={}){if(!this.isValid)return Un;const s=e.showZeros!==!1,n=ft.map(r=>{const a=this.values[r];return B(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+=nn(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},V.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?sa(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)(kt(s.values,r)||kt(this.values,r))&&(n[r]=s.get(r)+this.get(r));return st(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]=Vr(e(this.values[n],n));return st(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 st(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 st(this,o)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return Ln(this.matrix,e),st(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=Fn(this.normalize().shiftToAll().toObject());return st(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 c=0;for(const u in n)c+=this.matrix[u][o]*n[u],n[u]=0;ut(r[o])&&(c+=r[o]);const l=Math.trunc(c);s[o]=l,n[o]=(c*1e3-l*1e3)/1e3}else ut(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 Ln(this.matrix,s),st(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 st(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=Fn(this.values);return st(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 wt="Invalid Interval";function Ko(t,e){return!t||!t.isValid?ye.invalid("missing or invalid start"):!e||!e.isValid?ye.invalid("missing or invalid end"):e<t?ye.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 ye{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 Te("need to specify a reason the Interval is invalid");const n=e instanceof Ye?e:new Ye(e,s);if(pe.throwOnInvalid)throw new vi(n);return new ye({invalid:n})}static fromDateTimes(e,s){const n=Rt(e),r=Rt(s),a=Ko(n,r);return a??new ye({start:n,end:r})}static after(e,s){const n=Q.fromDurationLike(s),r=Rt(e);return ye.fromDateTimes(r,r.plus(n))}static before(e,s){const n=Q.fromDurationLike(s),r=Rt(e);return ye.fromDateTimes(r.minus(n),r)}static fromISO(e,s){const[n,r]=(e||"").split("/",2);if(n&&r){let a,o;try{a=V.fromISO(n,s),o=a.isValid}catch{o=!1}let c,l;try{c=V.fromISO(r,s),l=c.isValid}catch{l=!1}if(o&&l)return ye.fromDateTimes(a,c);if(o){const u=Q.fromISO(r,s);if(u.isValid)return ye.after(a,u)}else if(l){const u=Q.fromISO(n,s);if(u.isValid)return ye.before(c,u)}}return ye.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?ye.fromDateTimes(e||this.s,s||this.e):this}splitAt(...e){if(!this.isValid)return[];const s=e.map(Rt).filter(o=>this.contains(o)).sort((o,c)=>o.toMillis()-c.toMillis()),n=[];let{s:r}=this,a=0;for(;r<this.e;){const o=s[a]||this.e,c=+o>+this.e?this.e:o;n.push(ye.fromDateTimes(r,c)),r=c,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 c=this.start.plus(s.mapUnits(l=>l*r));a=+c>+this.e?this.e:c,o.push(ye.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:ye.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 ye.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(l=>[{time:l.s,type:"s"},{time:l.e,type:"e"}]),o=Array.prototype.concat(...a),c=o.sort((l,u)=>l.time-u.time);for(const l of c)n+=l.type==="s"?1:-1,n===1?s=l.time:(s&&+s!=+l.time&&r.push(ye.fromDateTimes(s,l.time)),s=null);return ye.merge(r)}difference(...e){return ye.xor([this].concat(e)).map(s=>this.intersection(s)).filter(s=>s&&!s.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:wt}[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?Ne.create(this.s.loc.clone(s),e).formatInterval(this):wt}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:wt}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:wt}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:wt}toFormat(e,{separator:s=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${s}${this.e.toFormat(e)}`:wt}toDuration(e,s){return this.isValid?this.e.diff(this.s,e,s):Q.invalid(this.invalidReason)}mapEndpoints(e){return ye.fromDateTimes(e(this.s),e(this.e))}}class Xt{static hasDST(e=pe.defaultZone){const s=V.now().setZone(e).set({month:12});return!e.isUniversal&&s.offset!==s.set({month:6}).offset}static isValidIANAZone(e){return rt.isValidZone(e)}static normalizeZone(e){return ct(e,pe.defaultZone)}static getStartOfWeek({locale:e=null,locObj:s=null}={}){return(s||re.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:s=null}={}){return(s||re.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:s=null}={}){return(s||re.create(e)).getWeekendDays().slice()}static months(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||re.create(s,n,a)).months(e)}static monthsFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||re.create(s,n,a)).months(e,!0)}static weekdays(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||re.create(s,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||re.create(s,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return re.create(e).meridiems()}static eras(e="short",{locale:s=null}={}){return re.create(s,null,"gregory").eras(e)}static features(){return{relative:$r(),localeWeek:Pr()}}}function $n(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 Qo(t,e,s){const n=[["years",(l,u)=>u.year-l.year],["quarters",(l,u)=>u.quarter-l.quarter+(u.year-l.year)*4],["months",(l,u)=>u.month-l.month+(u.year-l.year)*12],["weeks",(l,u)=>{const m=$n(l,u);return(m-m%7)/7}],["days",$n]],r={},a=t;let o,c;for(const[l,u]of n)s.indexOf(l)>=0&&(o=l,r[l]=u(t,e),c=a.plus(r),c>e?(r[l]--,t=a.plus(r),t>e&&(c=t,r[l]--,t=a.plus(r))):t=c);return[t,r,c,o]}function Xo(t,e,s,n){let[r,a,o,c]=Qo(t,e,s);const l=e-r,u=s.filter(h=>["hours","minutes","seconds","milliseconds"].indexOf(h)>=0);u.length===0&&(o<e&&(o=r.plus({[c]:1})),o!==r&&(a[c]=(a[c]||0)+l/(o-r)));const m=Q.fromObject(a,n);return u.length>0?Q.fromMillis(l,n).shiftTo(...u).plus(m):m}const el="missing Intl.DateTimeFormat.formatToParts support";function te(t,e=s=>s){return{regex:t,deser:([s])=>e(Zi(s))}}const tl=" ",na=`[ ${tl}]`,ra=new RegExp(na,"g");function sl(t){return t.replace(/\./g,"\\.?").replace(ra,na)}function Pn(t){return t.replace(/\./g,"").replace(ra," ").toLowerCase()}function Ge(t,e){return t===null?null:{regex:RegExp(t.map(sl).join("|")),deser:([s])=>t.findIndex(n=>Pn(s)===Pn(n))+e}}function Wn(t,e){return{regex:t,deser:([,s,n])=>xs(s,n),groups:e}}function es(t){return{regex:t,deser:([e])=>e}}function nl(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function rl(t,e){const s=qe(e),n=qe(e,"{2}"),r=qe(e,"{3}"),a=qe(e,"{4}"),o=qe(e,"{6}"),c=qe(e,"{1,2}"),l=qe(e,"{1,3}"),u=qe(e,"{1,6}"),m=qe(e,"{1,9}"),h=qe(e,"{2,4}"),v=qe(e,"{4,6}"),g=R=>({regex:RegExp(nl(R.val)),deser:([G])=>G,literal:!0}),D=(R=>{if(t.literal)return g(R);switch(R.val){case"G":return Ge(e.eras("short"),0);case"GG":return Ge(e.eras("long"),0);case"y":return te(u);case"yy":return te(h,qs);case"yyyy":return te(a);case"yyyyy":return te(v);case"yyyyyy":return te(o);case"M":return te(c);case"MM":return te(n);case"MMM":return Ge(e.months("short",!0),1);case"MMMM":return Ge(e.months("long",!0),1);case"L":return te(c);case"LL":return te(n);case"LLL":return Ge(e.months("short",!1),1);case"LLLL":return Ge(e.months("long",!1),1);case"d":return te(c);case"dd":return te(n);case"o":return te(l);case"ooo":return te(r);case"HH":return te(n);case"H":return te(c);case"hh":return te(n);case"h":return te(c);case"mm":return te(n);case"m":return te(c);case"q":return te(c);case"qq":return te(n);case"s":return te(c);case"ss":return te(n);case"S":return te(l);case"SSS":return te(r);case"u":return es(m);case"uu":return es(c);case"uuu":return te(s);case"a":return Ge(e.meridiems(),0);case"kkkk":return te(a);case"kk":return te(h,qs);case"W":return te(c);case"WW":return te(n);case"E":case"c":return te(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 Wn(new RegExp(`([+-]${c.source})(?::(${n.source}))?`),2);case"ZZZ":return Wn(new RegExp(`([+-]${c.source})(${n.source})?`),2);case"z":return es(/[a-z_+-/]{1,256}?/i);case" ":return es(/[^\S\n\r]/);default:return g(R)}})(t)||{invalidReason:el};return D.token=t,D}const al={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 il(t,e,s){const{type:n,value:r}=t;if(n==="literal"){const l=/^\s+$/.test(r);return{literal:!l,val:l?" ":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 c=al[o];if(typeof c=="object"&&(c=c[a]),c)return{literal:!1,val:c}}function ol(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function ll(t,e,s){const n=t.match(e);if(n){const r={};let a=1;for(const o in s)if(kt(s,o)){const c=s[o],l=c.groups?c.groups+1:1;!c.literal&&c.token&&(r[c.token.val[0]]=c.deser(n.slice(a,a+l))),a+=l}return[n,r]}else return[n,{}]}function cl(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 B(t.z)||(s=rt.create(t.z)),B(t.Z)||(s||(s=new Ee(t.Z)),n=t.Z),B(t.q)||(t.M=(t.q-1)*3+1),B(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),B(t.u)||(t.S=sn(t.u)),[Object.keys(t).reduce((a,o)=>{const c=e(o);return c&&(a[c]=t[o]),a},{}),s,n]}let Ms=null;function ul(){return Ms||(Ms=V.fromMillis(1555555555555)),Ms}function dl(t,e){if(t.literal)return t;const s=Ne.macroTokenToFormatOpts(t.val),n=la(s,e);return n==null||n.includes(void 0)?t:n}function aa(t,e){return Array.prototype.concat(...t.map(s=>dl(s,e)))}class ia{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=aa(Ne.parseFormat(s),e),this.units=this.tokens.map(n=>rl(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=ol(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=ll(e,this.regex,this.handlers),[r,a,o]=n?cl(n):[null,null,void 0];if(kt(n,"a")&&kt(n,"H"))throw new Tt("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 oa(t,e,s){return new ia(t,s).explainFromTokens(e)}function ml(t,e,s){const{result:n,zone:r,specificOffset:a,invalidReason:o}=oa(t,e,s);return[n,r,a,o]}function la(t,e){if(!t)return null;const n=Ne.create(e,t).dtFormatter(ul()),r=n.formatToParts(),a=n.resolvedOptions();return r.map(o=>il(o,t,a))}const Os="Invalid DateTime",Vn=864e13;function Ft(t){return new Ye("unsupported zone",`the zone "${t.name}" is not supported`)}function js(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 V({...s,...e,old:s})}function ca(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 ts(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 as(t,e,s){return ca(Ss(t),e,s)}function Bn(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"),c=Ss(a);let[l,u]=ca(c,s,t.zone);return o!==0&&(l+=o,u=t.zone.offset(l)),{ts:l,o:u}}function At(t,e,s,n,r,a){const{setZone:o,zone:c}=s;if(t&&Object.keys(t).length!==0||e){const l=e||c,u=V.fromObject(t,{...s,zone:l,specificOffset:a});return o?u:u.setZone(c)}else return V.invalid(new Ye("unparsable",`the input "${r}" can't be parsed as ${n}`))}function ss(t,e,s=!0){return t.isValid?Ne.create(re.create("en-US"),{allowZ:s,forceSimple:!0}).formatDateTimeFromString(t,e):null}function Ds(t,e,s){const n=t.c.year>9999||t.c.year<0;let r="";if(n&&t.c.year>=0&&(r+="+"),r+=xe(t.c.year,n?6:4),s==="year")return r;if(e){if(r+="-",r+=xe(t.c.month),s==="month")return r;r+="-"}else if(r+=xe(t.c.month),s==="month")return r;return r+=xe(t.c.day),r}function Zn(t,e,s,n,r,a,o){let c=!s||t.c.millisecond!==0||t.c.second!==0,l="";switch(o){case"day":case"month":case"year":break;default:if(l+=xe(t.c.hour),o==="hour")break;if(e){if(l+=":",l+=xe(t.c.minute),o==="minute")break;c&&(l+=":",l+=xe(t.c.second))}else{if(l+=xe(t.c.minute),o==="minute")break;c&&(l+=xe(t.c.second))}if(o==="second")break;c&&(!n||t.c.millisecond!==0)&&(l+=".",l+=xe(t.c.millisecond,3))}return r&&(t.isOffsetFixed&&t.offset===0&&!a?l+="Z":t.o<0?(l+="-",l+=xe(Math.trunc(-t.o/60)),l+=":",l+=xe(Math.trunc(-t.o%60))):(l+="+",l+=xe(Math.trunc(t.o/60)),l+=":",l+=xe(Math.trunc(t.o%60)))),a&&(l+="["+t.zone.ianaName+"]"),l}const ua={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},fl={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},hl={ordinal:1,hour:0,minute:0,second:0,millisecond:0},is=["year","month","day","hour","minute","second","millisecond"],yl=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],pl=["year","ordinal","hour","minute","second","millisecond"];function os(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 ur(t);return e}function zn(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return os(t)}}function gl(t){if($t===void 0&&($t=pe.now()),t.type!=="iana")return t.offset($t);const e=t.name;let s=Gs.get(e);return s===void 0&&(s=t.offset($t),Gs.set(e,s)),s}function Hn(t,e){const s=ct(e.zone,pe.defaultZone);if(!s.isValid)return V.invalid(Ft(s));const n=re.fromObject(e);let r,a;if(B(t.year))r=pe.now();else{for(const l of is)B(t[l])&&(t[l]=ua[l]);const o=Lr(t)||Fr(t);if(o)return V.invalid(o);const c=gl(s);[r,a]=as(t,c,s)}return new V({ts:r,zone:s,loc:n,o:a})}function qn(t,e,s){const n=B(s.round)?!0:s.round,r=B(s.rounding)?"trunc":s.rounding,a=(c,l)=>(c=nn(c,n||s.calendary?0:2,s.calendary?"round":r),e.loc.clone(s).relFormatter(s).format(c,l)),o=c=>s.calendary?e.hasSame(t,c)?0:e.startOf(c).diff(t.startOf(c),c).get(c):e.diff(t,c).get(c);if(s.unit)return a(o(s.unit),s.unit);for(const c of s.units){const l=o(c);if(Math.abs(l)>=1)return a(l,c)}return a(t>e?-0:0,s.units[s.units.length-1])}function Gn(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 $t;const Gs=new Map;class V{constructor(e){const s=e.zone||pe.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Ye("invalid input"):null)||(s.isValid?null:Ft(s));this.ts=B(e.ts)?pe.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 c=ut(e.o)&&!e.old?e.o:s.offset(this.ts);r=ts(this.ts,c),n=Number.isNaN(r.year)?new Ye("invalid input"):null,r=n?null:r,a=n?null:c}this._zone=s,this.loc=e.loc||re.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=a,this.isLuxonDateTime=!0}static now(){return new V({})}static local(){const[e,s]=Gn(arguments),[n,r,a,o,c,l,u]=s;return Hn({year:n,month:r,day:a,hour:o,minute:c,second:l,millisecond:u},e)}static utc(){const[e,s]=Gn(arguments),[n,r,a,o,c,l,u]=s;return e.zone=Ee.utcInstance,Hn({year:n,month:r,day:a,hour:o,minute:c,second:l,millisecond:u},e)}static fromJSDate(e,s={}){const n=Yi(e)?e.valueOf():NaN;if(Number.isNaN(n))return V.invalid("invalid input");const r=ct(s.zone,pe.defaultZone);return r.isValid?new V({ts:n,zone:r,loc:re.fromObject(s)}):V.invalid(Ft(r))}static fromMillis(e,s={}){if(ut(e))return e<-Vn||e>Vn?V.invalid("Timestamp out of range"):new V({ts:e,zone:ct(s.zone,pe.defaultZone),loc:re.fromObject(s)});throw new Te(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,s={}){if(ut(e))return new V({ts:e*1e3,zone:ct(s.zone,pe.defaultZone),loc:re.fromObject(s)});throw new Te("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=ct(s.zone,pe.defaultZone);if(!n.isValid)return V.invalid(Ft(n));const r=re.fromObject(s),a=ms(e,zn),{minDaysInFirstWeek:o,startOfWeek:c}=On(a,r),l=pe.now(),u=B(s.specificOffset)?n.offset(l):s.specificOffset,m=!B(a.ordinal),h=!B(a.year),v=!B(a.month)||!B(a.day),g=h||v,k=a.weekYear||a.weekNumber;if((g||m)&&k)throw new Tt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(v&&m)throw new Tt("Can't mix ordinal dates with month/day");const D=k||a.weekday&&!g;let R,G,q=ts(l,u);D?(R=yl,G=fl,q=us(q,o,c)):m?(R=pl,G=hl,q=Es(q)):(R=is,G=ua);let P=!1;for(const w of R){const O=a[w];B(O)?P?a[w]=G[w]:a[w]=q[w]:P=!0}const S=D?Hi(a,o,c):m?qi(a):Lr(a),M=S||Fr(a);if(M)return V.invalid(M);const $=D?En(a,o,c):m?Mn(a):a,[U,Z]=as($,u,n),p=new V({ts:U,zone:n,o:Z,loc:r});return a.weekday&&g&&e.weekday!==p.weekday?V.invalid("mismatched weekday",`you can't specify both a weekday of ${a.weekday} and a date of ${p.toISO()}`):p.isValid?p:V.invalid(p.invalid)}static fromISO(e,s={}){const[n,r]=$o(e);return At(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=Po(e);return At(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=Wo(e);return At(n,r,s,"HTTP",s)}static fromFormat(e,s,n={}){if(B(e)||B(s))throw new Te("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:a=null}=n,o=re.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0}),[c,l,u,m]=ml(o,e,s);return m?V.invalid(m):At(c,l,n,`format ${s}`,e,u)}static fromString(e,s,n={}){return V.fromFormat(e,s,n)}static fromSQL(e,s={}){const[n,r]=Go(e);return At(n,r,s,"SQL",e)}static invalid(e,s=null){if(!e)throw new Te("need to specify a reason the DateTime is invalid");const n=e instanceof Ye?e:new Ye(e,s);if(pe.throwOnInvalid)throw new xi(n);return new V({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,s={}){const n=la(e,re.fromObject(s));return n?n.map(r=>r?r.val:null).join(""):null}static expandFormat(e,s={}){return aa(Ne.parseFormat(e),re.fromObject(s)).map(r=>r.val).join("")}static resetCache(){$t=void 0,Gs.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?js(this).weekYear:NaN}get weekNumber(){return this.isValid?js(this).weekNumber:NaN}get weekday(){return this.isValid?js(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?Es(this.c).ordinal:NaN}get monthShort(){return this.isValid?Xt.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Xt.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Xt.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Xt.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=Ss(this.c),r=this.zone.offset(n-e),a=this.zone.offset(n+e),o=this.zone.offset(n-r*s),c=this.zone.offset(n-a*s);if(o===c)return[this];const l=n-o*s,u=n-c*s,m=ts(l,o),h=ts(u,c);return m.hour===h.hour&&m.minute===h.minute&&m.second===h.second&&m.millisecond===h.millisecond?[mt(this,{ts:l}),mt(this,{ts:u})]:[this]}get isInLeapYear(){return Bt(this.year)}get daysInMonth(){return ds(this.year,this.month)}get daysInYear(){return this.isValid?Nt(this.year):NaN}get weeksInWeekYear(){return this.isValid?Wt(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Wt(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:s,numberingSystem:n,calendar:r}=Ne.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:s,numberingSystem:n,outputCalendar:r}}toUTC(e=0,s={}){return this.setZone(Ee.instance(e),s)}toLocal(){return this.setZone(pe.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=ct(e,pe.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]=as(o,a,e)}return mt(this,{ts:r,zone:e})}else return V.invalid(Ft(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,zn),{minDaysInFirstWeek:n,startOfWeek:r}=On(s,this.loc),a=!B(s.weekYear)||!B(s.weekNumber)||!B(s.weekday),o=!B(s.ordinal),c=!B(s.year),l=!B(s.month)||!B(s.day),u=c||l,m=s.weekYear||s.weekNumber;if((u||o)&&m)throw new Tt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(l&&o)throw new Tt("Can't mix ordinal dates with month/day");let h;a?h=En({...us(this.c,n,r),...s},n,r):B(s.ordinal)?(h={...this.toObject(),...s},B(s.day)&&(h.day=Math.min(ds(h.year,h.month),h.day))):h=Mn({...Es(this.c),...s});const[v,g]=as(h,this.o,this.zone);return mt(this,{ts:v,o:g})}plus(e){if(!this.isValid)return this;const s=Q.fromDurationLike(e);return mt(this,Bn(this,s))}minus(e){if(!this.isValid)return this;const s=Q.fromDurationLike(e).negate();return mt(this,Bn(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?Ne.create(this.loc.redefaultToEN(s)).formatDateTimeFromString(this,e):Os}toLocaleString(e=cs,s={}){return this.isValid?Ne.create(this.loc.clone(s),e).formatDateTime(this):Os}toLocaleParts(e={}){return this.isValid?Ne.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=os(o);const c=e==="extended";let l=Ds(this,c,o);return is.indexOf(o)>=3&&(l+="T"),l+=Zn(this,c,s,n,r,a,o),l}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?Ds(this,e==="extended",os(s)):null}toISOWeekDate(){return ss(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:c="milliseconds"}={}){return this.isValid?(c=os(c),(r&&is.indexOf(c)>=3?"T":"")+Zn(this,o==="extended",s,e,n,a,c)):null}toRFC2822(){return ss(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return ss(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?Ds(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")),ss(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=_i(s).map(Q.normalizeUnit),o=e.valueOf()>this.valueOf(),c=o?this:e,l=o?e:this,u=Xo(c,l,a,r);return o?u.negate():u}diffNow(e="milliseconds",s={}){return this.diff(V.now(),e,s)}until(e){return this.isValid?ye.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||V.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),qn(s,this.plus(n),{...e,numeric:"always",units:r,unit:a})}toRelativeCalendar(e={}){return this.isValid?qn(e.base||V.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(V.isDateTime))throw new Te("min requires all arguments be DateTimes");return jn(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every(V.isDateTime))throw new Te("max requires all arguments be DateTimes");return jn(e,s=>s.valueOf(),Math.max)}static fromFormatExplain(e,s,n={}){const{locale:r=null,numberingSystem:a=null}=n,o=re.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});return oa(o,e,s)}static fromStringExplain(e,s,n={}){return V.fromFormatExplain(e,s,n)}static buildFormatParser(e,s={}){const{locale:n=null,numberingSystem:r=null}=s,a=re.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new ia(a,e)}static fromFormatParser(e,s,n={}){if(B(e)||B(s))throw new Te("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:a=null}=n,o=re.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});if(!o.equals(s.locale))throw new Te(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${s.locale}`);const{result:c,zone:l,specificOffset:u,invalidReason:m}=s.explainFromTokens(e);return m?V.invalid(m):At(c,l,n,`format ${s.format}`,e,u)}static get DATE_SHORT(){return cs}static get DATE_MED(){return dr}static get DATE_MED_WITH_WEEKDAY(){return Ai}static get DATE_FULL(){return mr}static get DATE_HUGE(){return fr}static get TIME_SIMPLE(){return hr}static get TIME_WITH_SECONDS(){return yr}static get TIME_WITH_SHORT_OFFSET(){return pr}static get TIME_WITH_LONG_OFFSET(){return gr}static get TIME_24_SIMPLE(){return Sr}static get TIME_24_WITH_SECONDS(){return xr}static get TIME_24_WITH_SHORT_OFFSET(){return vr}static get TIME_24_WITH_LONG_OFFSET(){return wr}static get DATETIME_SHORT(){return Ar}static get DATETIME_SHORT_WITH_SECONDS(){return Tr}static get DATETIME_MED(){return Nr}static get DATETIME_MED_WITH_SECONDS(){return br}static get DATETIME_MED_WITH_WEEKDAY(){return Ti}static get DATETIME_FULL(){return kr}static get DATETIME_FULL_WITH_SECONDS(){return Ir}static get DATETIME_HUGE(){return Er}static get DATETIME_HUGE_WITH_SECONDS(){return Mr}}function Rt(t){if(V.isDateTime(t))return t;if(t&&t.valueOf&&ut(t.valueOf()))return V.fromJSDate(t);if(t&&typeof t=="object")return V.fromObject(t);throw new Te(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function Sl(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function xl(t,e){try{const s=V.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 vl(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()),c=s(e.getMinutes()),l=s(e.getSeconds());return`${n}/${r}/${a} ${o}:${c}:${l}`}catch{return"-"}}function fs(t,e="UTC"){if(!t)return"-";const s=V.fromISO(t,{zone:"utc"}).setZone(e);if(!s.isValid)return"-";const n=s.offsetNameShort,r=s.toFormat("ZZZZ"),a=n.startsWith("GMT")||n===r?r:`${n}/${r}`;return`${s.toFormat("MM/dd/yyyy, hh:mm:ss a")} (${a})`}const wl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Al={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function da({alerts:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,severityOptions:a,anomalyOptions:o,spaceOptions:c,onAlertIdClick:l,onAlertView:u,onFilterChange:m,onPageChange:h,onRefetch:v,resetKey:g,serverSideFilters:k}){const D=Qs(),R=async P=>{try{const S=await D.mutateAsync({alertUniqueId:P.alertId??P.id,alertId:P.id,status:"Reopen",notes:"Reopened",modifiedBy:0});if(S?.responseStatus||S?.Success){const M=S?.Message||S?.data||"Alert reopened successfully.";we.toast.success(M)}else{const M=S?.errorMessage||S?.Message||"Failed to reopen alert";we.toast.error(M)}}catch{we.toast.error("Failed to reopen alert. Please try again.")}},G=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:P=>i.jsx(f.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${wl[P]}`,backgroundColor:Al[String(P)]},children:P})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:P=>vl(P)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(P,S)=>i.jsxs("div",{children:[i.jsx("a",{onClick:M=>{M.preventDefault(),l?.(S,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:S.alertNumber}),i.jsx("div",{className:"text-black/65",children:P})]})},{title:"Preview",key:"preview",width:100,align:"center",render:(P,S)=>i.jsx(lr,{record:S})},{title:"",key:"menu",width:60,align:"right",render:(P,S)=>i.jsx(f.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:M})=>{M==="reopen"&&R(S)}},children:i.jsx(f.Button,{type:"text",icon:i.jsx(ht.MoreOutlined,{})})})}],q=m&&k?t:(t||[]).filter(P=>{const S=ls(P.statusType||"");return cr.some(M=>S.includes(ls(M)))});return i.jsx(Ks,{data:q,loading:e,pageSize:s,total:n,currentPage:r,columns:G,severityOptions:a,anomalyOptions:o,spaceOptions:c,renderActions:void 0,onAlertIdClick:l,onAlertView:u,onFilterChange:m,onPageChange:h,onRefetch:v,resetKey:g,serverSideFilters:k,excludeCompleted:!1})}function Tl({size:t=120,time:e,timeZone:s="America/New_York"}){const{hours:n,minutes:r,seconds:a}=d.useMemo(()=>{const h=new Intl.DateTimeFormat("en-US",{timeZone:s,hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(e);return{hours:parseInt(h.find(v=>v.type==="hour")?.value||"0",10),minutes:parseInt(h.find(v=>v.type==="minute")?.value||"0",10),seconds:parseInt(h.find(v=>v.type==="second")?.value||"0",10)}},[e,s]),o=a*6,c=r*6+a*.1,l=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((m,h)=>{const v=h*30,g=6,k=u-4,D=k-g,R=(v-90)*(Math.PI/180),G=u+D*Math.cos(R),q=u+D*Math.sin(R),P=u+k*Math.cos(R),S=u+k*Math.sin(R);return i.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:i.jsx("line",{x1:G,y1:q,x2:P,y2:S,stroke:"#9CA3AF",strokeWidth:h%3===0?2:1,strokeLinecap:"round"})},h)}),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*.25,stroke:"#1F2937",strokeWidth:4,strokeLinecap:"round"})}),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*.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 ma({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(()=>Sl(r,e),[r,e]),{abbr:c,offset:l}=d.useMemo(()=>xl(r,e),[r,e]);return i.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[i.jsx(Tl,{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}),c&&i.jsxs("span",{className:"p-2 rounded-md border text-[10px] leading-none text-gray-600 bg-gray-50",children:[c," ",l]})]}),i.jsx("div",{className:"text-2xl font-semibold text-gray-700 tracking-wide",children:o})]})]})}const{Text:Nl}=f.Typography;function bl({sortBy:t,onChange:e,showActions:s,onSave:n,onClear:r,saving:a}){return i.jsxs(f.Row,{gutter:[16,16],align:"middle",children:[i.jsx(f.Col,{xs:24,md:8,lg:5,children:i.jsxs(f.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[i.jsx(Nl,{className:"text-gray-600 whitespace-nowrap",children:"Sort By:"}),i.jsx(f.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(f.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?i.jsxs(f.Space,{className:"w-full",direction:"horizontal",size:8,children:[i.jsx(f.Button,{onClick:r,disabled:a,children:"Clear"}),i.jsx(f.Button,{type:"primary",onClick:n,loading:a,children:"Save"})]}):null})]})}const Ys=t=>i.jsxs(f.Tag,{children:[i.jsx(ht.PlusOutlined,{})," ",t.length," more"]}),{Text:nt}=f.Typography;function kl(t){const{selectedRule:e,setSelectedRule:s,ruleOptions:n,minsOptions:r,roleOptions:a,l1mins:o,setL1mins:c,l1role:l,setL1role:u,l2mins:m,setL2mins:h,l2role:v,setL2role:g,l3mins:k,setL3mins:D,l3role:R,setL3role:G,actions:q,setActions:P,thirdPartyIds:S,setThirdPartyIds:M,humanLoop:$,setHumanLoop:U,isAutoExpire:Z,setAutoExpire:p,onClear:w,onSave:O,saving:ie,onActionTypesLoaded:me}=t,{rules:j,config:N}=Me(),x=N.tenant==="schools",[E,T]=d.useState([]),[F,C]=d.useState([]),[_,J]=d.useState(!1);d.useEffect(()=>{let ce=!1;return(async()=>{try{J(!0);const ee=await j.getLookups();if(ce||!ee||!Array.isArray(ee.actionTypes))return;const ge=ee.actionTypes.map(ae=>({label:ae.name,value:String(ae.actionTypeId)}));T(ge),me&&me(ee.actionTypes);const ue=Array.isArray(ee.thirdParties)?ee.thirdParties.map(ae=>({label:ae.thirdPartyName,value:ae.thirdPartyIds??ae.thirdPartyId})):[];C(ue)}catch(ee){console.error("Error loading lookups",ee)}finally{ce||J(!1)}})(),()=>{ce=!0}},[]);const se=typeof o=="number"||typeof l=="number",X=typeof m=="number"||typeof v=="number",oe=typeof o=="number"||typeof l=="number"||typeof m=="number"||typeof v=="number"||typeof k=="number"||typeof R=="number"||Array.isArray(q)&&q.length>0||Array.isArray(S)&&S.length>0||!!$||!!Z,Se=!!e&&oe&&!ie;return i.jsxs(f.Spin,{spinning:!!ie||_,children:[i.jsxs(f.Row,{gutter:[16,16],align:"bottom",children:[i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(nt,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(f.Select,{placeholder:"Rules",value:e,onChange:s,options:n,className:"w-full"})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(nt,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),i.jsx(f.Col,{span:14,children:i.jsx(nt,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(f.Select,{className:"w-full",placeholder:"Mins",value:o,onChange:c,options:r})}),i.jsx(f.Col,{span:14,children:i.jsx(f.Select,{placeholder:"Escalate to",className:"w-full",value:l,onChange:u,options:a})})]})]})}),se&&i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(nt,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),i.jsx(f.Col,{span:14,children:i.jsx(nt,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(f.Select,{className:"w-full",placeholder:"Mins",value:m,onChange:h,options:r})}),i.jsx(f.Col,{span:14,children:i.jsx(f.Select,{placeholder:"Escalate to",className:"w-full",value:v,onChange:g,options:a})})]})]})}),X&&i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(nt,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),i.jsx(f.Col,{span:14,children:i.jsx(nt,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(f.Select,{className:"w-full",placeholder:"Mins",value:k,onChange:D,options:r})}),i.jsx(f.Col,{span:14,children:i.jsx(f.Select,{placeholder:"Escalate to",className:"w-full",value:R,onChange:G,options:a})})]})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(nt,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),i.jsx(f.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:q,onChange:P,options:E,maxTagCount:1,maxTagPlaceholder:Ys})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(nt,{className:"text-gray-700 font-medium block mb-1",children:"Notify"}),i.jsx(f.Select,{mode:"multiple",placeholder:"Notify",className:"w-full",value:S,onChange:M,options:F,maxCount:2,maxTagPlaceholder:Ys})]})})]}),i.jsxs(f.Row,{gutter:[16,16],align:"bottom",className:"mt-4 items-center",children:[i.jsx(f.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(f.Checkbox,{checked:$,onChange:ce=>U(ce.target.checked),className:"w-full",children:"Human-In-The-Loop"}),i.jsx(f.Checkbox,{checked:Z,onChange:ce=>p(ce.target.checked),className:"w-full",children:"Auto-expire in 5 minutes"})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(f.Button,{onClick:w,children:"Clear"}),i.jsx(f.Button,{type:"primary",onClick:O,loading:!!ie,disabled:!Se,children:"Save"})]})})]})]})}function Il({entries:t,userRoles:e,onEdit:s,loading:n}){const{config:r}=Me(),a=r.tenant==="schools",o=new Map(e.map(l=>[l.userRoleId,l.userRoleName])),c=l=>l.map(u=>o.get(u)||String(u)).join(", ");return i.jsx(f.Table,{rowKey:"id",dataSource:t,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(l,u)=>`${u[0]}-${u[1]} of ${l} items`},loading:n,columns:[{title:"Rule",dataIndex:"ruleOrSeverityLabel",key:"rule"},{title:"Level 1",key:"l1",render:(l,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 (${c(u.l1.roles)})`:""]})},{title:"Level 2",key:"l2",render:(l,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 (${c(u.l2.roles)})`:""]})},{title:"Level 3",key:"l3",render:(l,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 (${c(u.l3.roles)})`:""]})},{title:"Pick Actions",key:"actionsCol",render:(l,u)=>u.actions?.length?u.actions.join(", "):"-"},{title:"Notify",key:"notify",render:(l,u)=>u.notify?.length?u.notify.join(", "):"-"},...a?[]:[{title:"Human-In-The-Loop",key:"humanLoop",render:(l,u)=>u.humanLoop?"Yes":"No"}],{title:"Auto Expire",key:"isAutoExpire",render:(l,u)=>u.isAutoExpire?"Yes":"No"},{title:"Actions",key:"ops",render:(l,u)=>i.jsx(f.Button,{type:"text",onClick:()=>s(u.id),children:i.jsx(ht.EditOutlined,{})})}]})}const{Title:El,Text:Rs}=f.Typography;function fa({userRoles:t,rules:e,rawRules:s}){const{rules:n}=Me(),[r,a]=d.useState(!1),[o,c]=d.useState(!1),[l,u]=d.useState(s),[m,h]=d.useState(),[v,g]=d.useState([]),k=d.useMemo(()=>t.map(S=>({label:S.userRoleName,value:S.userRoleId})),[t]),D=d.useMemo(()=>(e||[]).map(S=>({label:S.Name||"-",value:S.RuleId||S.Name||""})),[e]),R=d.useMemo(()=>(e||[]).map((S,M)=>({key:S.RuleId||S.Name||String(M),ruleName:S.Name||"-",ruleDesc:S.Description||""})),[e]);d.useEffect(()=>{let S=!1;return(async()=>{try{a(!0);const M=await n.getRules();S||u(Array.isArray(M)?M:[])}catch{!S&&Array.isArray(s)&&u(s)}finally{S||a(!1)}})(),()=>{S=!0}},[]),d.useEffect(()=>{!l&&Array.isArray(s)&&u(s)},[s]),d.useEffect(()=>{if(!m||!Array.isArray(l)){g([]);return}const S=l.find($=>$?.ruleId===m||$?.RuleId===m||$?.ruleName===m),M=S?.userRoleIds??S?.UserRoleIds;g(Array.isArray(M)?M:[])},[m,l]);const G=d.useMemo(()=>{if(!Array.isArray(l)||!l.length)return{};const S={};for(const M of R){const $=l.find(p=>p?.ruleId===M.key||p?.ruleName===M.key||p?.RuleId===M.key||p?.ruleName===M.ruleName||p?.Name===M.ruleName),U=$?.userRoleIds??$?.UserRoleIds,Z=Array.isArray(U)?U:[];Z.length&&(S[M.key]=Z)}return S},[l,R]),q=()=>{h(void 0),g([])},P=async()=>{if(!m){we.toast.info("Please select a rule");return}try{c(!0);const S=Array.isArray(l)?l.find(p=>p?.ruleId===m||p?.RuleId===m||p?.ruleName===m):void 0,M=typeof S?.recordId=="number"?S.recordId:S?.ruleId||S?.RuleId||void 0;if(!S||!M)throw new Error(`Unable to find rule identifier for rule ${m}`);const $=v.map(p=>{const w=t.find(O=>O.userRoleId===p);return{id:p,name:w?.userRoleName??String(p)}}),U={...S,ruleId:m,userRoleIds:v,userRoles:$},Z=await n.updateRule(M,U);if(!Z?.responseStatus&&!Z?.Success&&!Z?.success)we.toast.error(Z?.errorMessage||Z?.Message||"Error saving Alert Assignment");else{we.toast.success("Alert assignment saved"),h(void 0),g([]);try{const p=await n.getRules();u(Array.isArray(p)?p:[])}catch(p){console.error("Failed to refresh rules after save",p)}}}catch(S){console.error("Failed to save alert assignment",S),we.toast.error(S instanceof Error?S.message:"Error saving Alert Assignment")}finally{c(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(El,{level:4,className:"!mb-4",children:"Alert Assignment"}),i.jsx(f.Spin,{spinning:o||r,children:i.jsxs(f.Row,{gutter:[16,16],align:"bottom",className:"mb-6",children:[i.jsx(f.Col,{xs:24,sm:12,md:8,lg:6,children:i.jsxs("div",{children:[i.jsx(Rs,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(f.Select,{placeholder:"Rules",value:m,onChange:h,options:D,className:"w-full"})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:8,children:i.jsxs("div",{children:[i.jsx(Rs,{className:"text-gray-700 font-medium block mb-1",children:"Alert Notification To"}),i.jsx(f.Select,{mode:"multiple",placeholder:"Select roles",className:"w-full",value:v,onChange:g,options:k,maxTagCount:1,maxTagPlaceholder:Ys})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(f.Button,{onClick:q,disabled:o,children:"Cancel"}),i.jsx(f.Button,{type:"primary",onClick:P,loading:o,disabled:o||!m,children:"Save"})]})})]})}),i.jsx(f.Table,{rowKey:"key",dataSource:R,loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(S,M)=>`${M[0]}-${M[1]} of ${S} items`},columns:[{title:"Rule Name",dataIndex:"ruleName",key:"ruleName"},{title:"Description",dataIndex:"ruleDesc",key:"ruleDesc"},{title:"Alert Notification To",key:"assign",render:(S,M)=>{const $=G[M.key]??[];return $.length?i.jsx("div",{className:"flex flex-wrap gap-1",children:$.map(U=>{const Z=t.find(p=>p.userRoleId===U);return i.jsx(f.Tag,{children:Z?.userRoleName??String(U)},U)})}):i.jsx(Rs,{type:"secondary",children:"—"})}}]})]})}const{Title:Yn}=f.Typography;function Us(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 ha({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r,onSave:a}){const{rules:o,alerts:c}=Me(),[l,u]=d.useState("By Severity"),[m,h]=d.useState("By severity"),[v,g]=d.useState("By Severity"),[k,D]=d.useState(!1),[R,G]=d.useState(!1),[q,P]=d.useState(!1),[S,M]=d.useState(null),[$,U]=d.useState("rules"),[Z,p]=d.useState(),[w,O]=d.useState(),[ie,me]=d.useState(),[j,N]=d.useState(),[x,E]=d.useState(),[T,F]=d.useState(),[C,_]=d.useState(),[J,se]=d.useState(),[X,oe]=d.useState([]),[Se,ce]=d.useState([]),[ee,ge]=d.useState(!1),[ue,ae]=d.useState(!1),[Ae,Ce]=d.useState({}),[Je,Ke]=d.useState({}),[be,jt]=d.useState(s||[]),[Xe,at]=d.useState([]),[Ct,gt]=d.useState(!1),[Dt,St]=d.useState(!1),[ze,xt]=d.useState(n||[]);d.useEffect(()=>{n&&n.length&&xt(n)},[n]),d.useEffect(()=>{if(!ze||!ze.length)return;const I=Object.keys(Ae).length>0||Object.keys(Je).length>0;if(Xe.length&&!I)return;const K=ze.map((H,W)=>{const y=e.find(Ie=>Ie.RuleId===(H.ruleId||H.ruleName))?.Name||H.ruleName||H.Name||"-",A=Us(H.escalationSettings),L=typeof A.level1UserRoleId=="number"&&A.level1UserRoleId>0?[A.level1UserRoleId]:[],he=typeof A.level2UserRoleId=="number"&&A.level2UserRoleId>0?[A.level2UserRoleId]:[],ne=typeof A.level3UserRoleId=="number"&&A.level3UserRoleId>0?[A.level3UserRoleId]:[],He=(Array.isArray(A.escalationSettingsActionTypeIds)?A.escalationSettingsActionTypeIds:[]).map(Ie=>Ae[Ie]||String(Ie)),Qe=(Array.isArray(A.thirdPartyId)?A.thirdPartyId:[]).map(Ie=>Je[Ie]||String(Ie)),As=typeof A.humanLoop=="boolean"?A.humanLoop:null,Ts=typeof A.isAutoExpire=="boolean"?A.isAutoExpire:null;return{id:String(H.ruleId||H.ruleName||W),ruleOrSeverityLabel:y,l1:{minutes:A.level1PostAssistTime??void 0,roles:L},l2:{minutes:A.level2PostAssistTime??void 0,roles:he},l3:{minutes:A.level3PostAssistTime??void 0,roles:ne},actions:He,notify:Qe,humanLoop:As,isAutoExpire:Ts}});at(K)},[ze,e,Ae,Je]);const Ht=d.useMemo(()=>t.map(I=>({label:I.DisplayName,value:I.SeverityId})),[t]),Y=d.useMemo(()=>e.map(I=>({label:I.Name,value:I.RuleId})),[e]),z=d.useMemo(()=>be.map(I=>({label:I.userRoleName,value:I.userRoleId})),[be]),ve=d.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(I=>({label:`${I}`,value:I})),[]);d.useEffect(()=>{let I=!1;async function K(){try{P(!0),M(null);const H=await c.getAdminSettings();if(!I&&H){const W=Kn(H.sortBy);u(W),g(W),D(!1)}}catch(H){if(!I){const W=H instanceof Error?H.message:"Failed to load admin settings";M(W)}}finally{I||P(!1)}}return K(),()=>{I=!0}},[]),d.useEffect(()=>{if(!w)return;const I=y=>{const A=Number(y);return!isNaN(A)&&A>0?A:void 0},K=y=>{const A=Number(y);return!isNaN(A)&&A>0?A:void 0},H=(ze||[]).find(y=>y?.ruleId===w||y?.ruleName===w||y?.RuleId===w),W=Us(H?.escalationSettings);if(W&&typeof W=="object"){me(K(W.level1PostAssistTime)),N(I(W.level1UserRoleId)),E(K(W.level2PostAssistTime)),F(I(W.level2UserRoleId)),_(K(W.level3PostAssistTime)),se(I(W.level3UserRoleId));const y=Array.isArray(W.escalationSettingsActionTypeIds)?W.escalationSettingsActionTypeIds:[];oe(y.map(A=>String(A))),ce(Array.isArray(W.thirdPartyId)?W.thirdPartyId:[]),ge(!!W.humanLoop),ae(!!W.isAutoExpire)}},[$,w,ze]);const fe=async()=>{try{St(!0);const I=await o.getRules(),K=Array.isArray(I)?I:Array.isArray(I?.data)?I.data:[];xt(K);const H=K.map((W,y)=>{const A=e.find(Ie=>Ie.RuleId===(W.ruleId||W.ruleName))?.Name||W.ruleName||W.Name||"-",L=Us(W.escalationSettings??W.EscalationSettings),he=typeof L.level1UserRoleId=="number"&&L.level1UserRoleId>0?[L.level1UserRoleId]:[],ne=typeof L.level2UserRoleId=="number"&&L.level2UserRoleId>0?[L.level2UserRoleId]:[],le=typeof L.level3UserRoleId=="number"&&L.level3UserRoleId>0?[L.level3UserRoleId]:[],et=(Array.isArray(L.escalationSettingsActionTypeIds)?L.escalationSettingsActionTypeIds:[]).map(Ie=>Ae[Ie]||String(Ie)),As=(Array.isArray(L.thirdPartyId)?L.thirdPartyId:[]).map(Ie=>Je[Ie]||String(Ie)),Ts=typeof L.humanLoop=="boolean"?L.humanLoop:null;return{id:String(W.ruleId||W.ruleName||y),ruleOrSeverityLabel:A,l1:{minutes:L.level1PostAssistTime??void 0,roles:he},l2:{minutes:L.level2PostAssistTime??void 0,roles:ne},l3:{minutes:L.level3PostAssistTime??void 0,roles:le},actions:et,notify:As,humanLoop:Ts}});at(H)}catch(I){console.error("Failed to refetch entries",I)}finally{St(!1)}};d.useEffect(()=>{let I=!1;return(async()=>{try{const K=await o.getLookups();if(I||!K)return;const H={};if(Array.isArray(K.thirdParties))for(const y of K.thirdParties){const A=y.thirdPartyIds??y.thirdPartyId;typeof A=="number"&&(H[A]=y.thirdPartyName)}Ke(H);const W=Array.isArray(K.userRoles)?K.userRoles.map(y=>({userRoleId:y.userRoleId??y.id,userRoleName:y.userRoleName??y.name})):[];I||jt(W.length?W:s||[])}catch(K){console.error("Error loading lookups",K)}})(),()=>{I=!0}},[]);const ke=async()=>{G(!0);try{const I=await c.setAdminSettings({sortBy:l,groupBy:"string"});I?.responseStatus&&I?.data&&we.toast.success(I.data),g(l),D(!1)}catch(I){console.error("Error saving admin settings",I)}finally{G(!1)}},De=()=>{u(v),D(!1)},$e=async()=>{gt(!0),a?.({ruleId:w,levels:[{minutes:ie,role:j},{minutes:x,role:T},{minutes:C,role:J}],actions:X,thirdPartyIds:Se,humanLoop:ee,isAutoExpire:ue});try{if(w){const K=Array.isArray(X)?X.map(L=>Number.isNaN(Number(L))?L:Number(L)):[],H=(ze||[]).find(L=>L?.ruleId===w||L?.ruleName===w||L?.RuleId===w),W=typeof H?.recordId=="number"?H.recordId:H?.ruleId||H?.RuleId||void 0;if(!H||!W){we.toast.error("Unable to find rule identifier for update");return}const y={...H,escalationSettings:{level1UserRoleId:j??0,level1PostAssistTime:ie??0,level2UserRoleId:T??0,level2PostAssistTime:x??0,level3UserRoleId:J??0,level3PostAssistTime:C??0,escalationSettingsActionTypeIds:K,thirdPartyId:Array.isArray(Se)?Se:[],humanLoop:ee,isAutoExpire:ue}},A=await o.updateRule(W,y);A?.responseStatus||A?.Success||A?.success?(we.toast.success("Escalation settings saved"),await fe(),O(void 0),me(void 0),N(void 0),E(void 0),F(void 0),_(void 0),se(void 0),oe([]),ce([]),ge(!1),ae(!1)):we.toast.error(A?.errorMessage||A?.Message||"Error saving Escalation Settings")}}catch(K){console.error("Error saving escalation settings",K)}finally{gt(!1)}},Re=()=>{u("By Severity"),h("By severity"),U("rules"),p(void 0),O(void 0),me(void 0),N(void 0),E(void 0),F(void 0),_(void 0),se(void 0),oe([]),ce([]),ge(!1),ae(!1)};return i.jsxs("div",{className:"w-full",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(Yn,{level:4,className:"!mb-2",children:"Admin Settings"}),i.jsxs(f.Spin,{spinning:q,children:[S?i.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",S]}):null,i.jsx(bl,{sortBy:l,groupBy:m,onChange:I=>{I.sortBy&&(u(I.sortBy),D(!0)),I.groupBy&&(h(I.groupBy),D(!0))},showActions:k,onSave:ke,onClear:De,saving:R})]})]}),i.jsx(f.Divider,{className:"my-6"}),i.jsxs("div",{children:[i.jsx(Yn,{level:4,className:"!mb-4",children:"Escalation Settings"}),i.jsx(kl,{escBasis:$,setEscBasis:U,selectedSeverity:Z,setSelectedSeverity:p,selectedRule:w,setSelectedRule:O,severityOptions:Ht,ruleOptions:Y,minsOptions:ve,roleOptions:z,l1mins:ie,setL1mins:me,l1role:j,setL1role:N,l2mins:x,setL2mins:E,l2role:T,setL2role:F,l3mins:C,setL3mins:_,l3role:J,setL3role:se,actions:X,setActions:oe,thirdPartyIds:Se,setThirdPartyIds:ce,humanLoop:ee,setHumanLoop:ge,onClear:Re,onSave:$e,saving:Ct,onActionTypesLoaded:I=>{const K={};for(const H of I)typeof H.actionTypeId=="number"&&(K[H.actionTypeId]=H.name);Ce(K)},isAutoExpire:ue,setAutoExpire:ae})]}),i.jsx(f.Divider,{className:"my-6"}),i.jsx(Il,{entries:Xe,userRoles:be,loading:Dt||r,onEdit:I=>{U("rules");const K=Xe.find(W=>W.id===I),H=e.find(W=>W.RuleId===I)||(K?e.find(W=>W.Name===K.ruleOrSeverityLabel):void 0);O(H?H.RuleId:I)}}),i.jsx(f.Divider,{className:"my-6"}),i.jsx(fa,{userRoles:be,rules:e,rawRules:n}),i.jsx(f.Divider,{})]})}const{Title:_n,Text:ns}=f.Typography;function Ml({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:a}=Me(),o=[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],[c,l]=d.useState("By Severity"),[u,m]=d.useState(new Set),[h,v]=d.useState(null),[g,k]=d.useState(null),[D,R]=d.useState({inApp:!1,sms:!1,email:!1}),[G,q]=d.useState([]),[P,S]=d.useState(!0),[M,$]=d.useState(!1);d.useEffect(()=>{let p=!1;return(async()=>{try{const w=await a.getPreferenceSettings();if(p||!w)return;R({inApp:!!w.inApp,sms:!!w.sms,email:!!w.email});const O=Kn(w.sortBy);l(O==="By Created Date"?"By Created Date":"By Severity"),v(yn(w.doNotDisturbStart)),k(yn(w.doNotDisturbEnd)),Array.isArray(w.anomalyIds)&&m(new Set(w.anomalyIds.map(ie=>String(ie))))}catch(w){console.error("Error in loading my preferences: ",w)}})(),()=>{p=!0}},[]),d.useEffect(()=>{let p=!1;return(async()=>{try{S(!0);const w=await r.getLookups();if(p||!w)return;const O=Array.isArray(w.anomalies)?w.anomalies:[];q(O)}catch(w){console.error("Failed to load anomalies lookups",w)}finally{p||S(!1)}})(),()=>{p=!0}},[]);const U=p=>{m(w=>{const O=new Set(w);return O.has(p)?O.delete(p):O.add(p),O})},Z=async()=>{s?.({sortBy:c,subscribedRuleIds:Array.from(u),dnd:{from:h,to:g},channels:D});try{$(!0);const p=h?h.format?.("HH:mm:ss")??"00:00:00":"00:00:00",w=g?g.format?.("HH:mm:ss")??"00:00:00":"00:00:00",O=Array.from(u).map(me=>Number(me)).filter(me=>Number.isFinite(me)),ie=await a.setPreferenceSettings({anomalyIds:O,doNotDisturbStart:p,doNotDisturbEnd:w,inApp:!!D.inApp,sms:!!D.sms,email:!!D.email,sortBy:c});ie?.responseStatus&&we.toast.success(ie?.data||"Preferences updated successfully.")}catch(p){console.error("Error in saving my preferences: ",p)}finally{$(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(f.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:i.jsx(f.Col,{xs:24,md:8,children:i.jsxs(f.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(ns,{className:"text-gray-600",children:"Sort By:"}),i.jsx(f.Select,{className:"w-[240px]",value:c,options:o,onChange:l})]})})}),i.jsxs("div",{className:"mb-4",children:[i.jsx(_n,{level:5,className:"!mb-2",children:"Anomalies"}),P?i.jsx("div",{className:"py-4",children:i.jsx(f.Spin,{})}):i.jsx(f.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray(G)?G:[]).map(p=>{const w=String(p.recordId),O=p.anomalyName;return i.jsx(f.Checkbox,{checked:u.has(w),onChange:()=>U(w),children:O},w)})})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx(_n,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),i.jsx(f.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:i.jsx(f.Col,{xs:24,md:12,children:i.jsxs(f.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(ns,{children:"Do Not Disturb mode:"}),i.jsxs(f.Space,{size:12,className:"w-full",children:[i.jsxs(f.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(ns,{children:"From"}),i.jsx(f.TimePicker,{value:h,onChange:p=>v(p),format:"HH:mm"})]}),i.jsxs(f.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(ns,{children:"To"}),i.jsx(f.TimePicker,{value:g,onChange:p=>k(p),format:"HH:mm"})]})]})]})})}),i.jsxs(f.Row,{gutter:[24,12],children:[i.jsx(f.Col,{children:i.jsx(f.Checkbox,{checked:D.inApp,onChange:p=>R({...D,inApp:p.target.checked}),children:"In-app"})}),i.jsx(f.Col,{children:i.jsx(f.Checkbox,{checked:D.sms,onChange:p=>R({...D,sms:p.target.checked}),children:"SMS"})}),i.jsx(f.Col,{children:i.jsx(f.Checkbox,{checked:D.email,onChange:p=>R({...D,email:p.target.checked}),children:"Email"})})]})]}),i.jsx(f.Divider,{}),i.jsxs(f.Space,{className:"gap-3",children:[i.jsx(f.Button,{onClick:n,disabled:M,children:"Cancel"}),i.jsx(f.Button,{type:"primary",onClick:Z,loading:M,children:"Save"})]})]})}function ya({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r}){return i.jsx("div",{className:"w-full",children:i.jsx(ha,{severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r})})}const Ol="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=",jl="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 ws(){const{config:t}=Me();return{timeZoneDetails:d.useMemo(()=>{const s=t.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone;return{timeZoneUniqueId:"",ianaTimeZoneId:s,timeZoneName:s,offset:""}},[t.timeZone]),loading:!1}}function Cl(t){const e=(t.status||"").toLowerCase()==="completed"?i.jsx("img",{src:Ol,alt:"completed",style:{width:20,height:20}}):i.jsx("img",{src:jl,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 Dl({data:t}){const{timeZoneDetails:e}=ws();return console.log("summary",t),i.jsx("div",{className:"w-full",children:i.jsx(f.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:i.jsxs("div",{className:"w-full",style:{maxHeight:"50vh",overflowY:"auto"},children:[i.jsx(f.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(f.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(f.Steps,{direction:"vertical",size:"small",current:1,items:(t.timeline||[]).map(Cl)})})]})]})},{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(f.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("h4",{className:"text-sm text-black font-medium",children:s.channelLabel}),i.jsx("span",{className:"text-xs text-gray-500 mt-1",children:fs(s.sentAt,e?.ianaTimeZoneId)})]}),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 text-xs",children:[i.jsxs("div",{className:"text-black",children:[" ",s.messageTitle]}),s.messageBody?i.jsx("div",{className:"text-gray-600",children:s.messageBody}):null]}),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.jsxs("span",{className:"text-gray-500",children:[r.role," . ",r.phone]})]}),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 Rl=({alertId:t,id:e,priority:s,spaceName:n,alertNumber:r,statusHistory:a,notifGroups:o})=>{const c={alertId:t??String(e??""),incidentId:"-",severity:s||"",location:n||"",alertNumber:r??""},{timeZoneDetails:l}=ws(),u=a?.length?a.map(h=>{const v=(h?.status||h?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",g=h?.createdDate?fs(h.createdDate,l?.ianaTimeZoneId):h?.timestamp?fs(h.timestamp,l?.ianaTimeZoneId):"";return{status:v,title:h?.status||h?.eventStatus||"Status Update",description:h?.description||h?.actionNotes||"",timestamp:g}}):[],m={summary:c,timeline:u,notifications:o??[]};return i.jsx(Dl,{data:m})},Ul={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Ll={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Fl={"elopement attempt":"elopement","elopement completed":"elopement","watchlist person detected":"watchlist","watch list person detected":"watchlist","brandished guns & knives":"weapon","brandished guns and knives":"weapon"},$l=({isModalOpen:t,handleModalClose:e,selectedRow:s,fetchAlertLogs:n,alertStatusList:r=[],alertStatusLoading:a=!1,initialTab:o="details",sourceTab:c,onAlertView:l})=>{const[u,m]=d.useState(),[h,v]=d.useState(""),[g,k]=d.useState(!1),D=d.useRef(null),[R,G]=d.useState("details"),[q,P]=d.useState(void 0),S=Qs(),{alerts:M,rules:$,config:U}=Me(),{timeZoneDetails:Z}=ws(),[p,w]=d.useState(null),[O,ie]=d.useState(!1),[me,j]=d.useState(!1),[N,x]=d.useState(void 0),[E,T]=d.useState(void 0),[F,C]=d.useState({}),[_,J]=d.useState({}),se=(y,A,L)=>{const he=_[y];return F[y]===!1&&!he?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(ar,{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:[he&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg z-10",children:i.jsx(fi,{size:32,className:"animate-spin text-gray-400"})}),i.jsx("img",{src:y,alt:A.caption||`media-${L}`,className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg transition-opacity duration-200 ${he?"opacity-0":"opacity-100"}`,onLoad:()=>J(ne=>({...ne,[y]:!1})),onError:()=>J(ne=>({...ne,[y]:!1}))},y)]})},X=s?.originalData||{},{eventName:oe,eventDisplayName:Se,anomalyName:ce,alertId:ee,timestamp:ge,description:ue,spaceName:ae,assignTeam:Ae,priority:Ce,statusType:Je,id:Ke,alertDetails:be,statusHistory:jt,mediaDetails:Xe,alertNumber:at}=X,Ct=U.tenant==="snl"?Se||oe||"Alert Event":oe||"Alert Event",gt=y=>{const A=String(y||"").toLowerCase();return A==="delivered"||A==="sent"?"Delivered":A==="failed"?"Failed":"Queued"},Dt=y=>({name:y?.receipientName||y?.recipientName||"-",role:y?.receipientRoleName||"",phone:y?.receipentPhoneNumber||y?.recipientPhoneNumber||y?.receipientEmail||y?.recipientEmail||"",status:gt(y?.messageStatus),notificationReceipientType:y?.notificationReceipientType||""}),St=(y,A)=>{const L=A.map(Dt),he=L.filter(et=>et.status==="Delivered").length,ne=A.map(et=>et?.sentAt).filter(Boolean).sort((et,Qe)=>new Date(Qe).getTime()-new Date(et).getTime())[0],He=(A[0]||{})?.severityName||`${y} Notification`;return{channelLabel:`${y} Notification`,sentAt:ne||"",messageTitle:He,messageBody:"",total:L.length,delivered:he,recipients:L}},ze=y=>{const A=new Map;return(y||[]).forEach(L=>{const he=String(L?.notificationType||"Unknown"),ne=A.get(he)||[];ne.push(L),A.set(he,ne)}),Array.from(A.entries()).map(([L,he])=>St(L,he))},xt=async y=>{try{const A=await M.getAlertNotifications(y),L=ze(A);P(L)}catch{P(void 0)}};d.useEffect(()=>{if(R!=="track"||!Ke)return;let y=!1;return xt(Ke).then(()=>{y&&P(void 0)}),()=>{y=!0}},[R,Ke]),d.useEffect(()=>{t?G(o):(m(void 0),v(""))},[t,o]),d.useEffect(()=>{!t||!l||l([{personName:X.personName,faceId:X.faceId,mediaDetails:X.mediaDetails}])},[t]),d.useEffect(()=>{if(!t||U.tenant!=="snl")return;let y=!1;return ie(!0),$.getLookups().then(A=>{y||(w(A.alertStatusTypes??[]),ie(!1))}).catch(()=>{y||(w([]),ie(!1))}),()=>{y=!0}},[t,U.tenant]);const Y=c==="archived"||["completed","false positive"].includes(String(Je||"").toLowerCase()),z=y=>{const A=String(y?.value||"").toLowerCase(),L=String(y?.statusName||"").toLowerCase();return A.includes("reopen")||L.includes("reopen")},ve=String(ce||"").trim().toLowerCase(),fe=Fl[ve]??"general",ke=r.filter(y=>{const A=z(y);return typeof c<"u"?c==="archived"?A:!A:Y?A:!A}).map(y=>({value:y.value,label:y.statusName})),De=p??[],$e=y=>!!y.isWatchListStatus,Re=y=>!!y.isWeapontStatus,I=De.filter(y=>{switch(fe){case"elopement":return y.isElopementStatus;case"watchlist":return $e(y);case"weapon":return Re(y);default:return!y.isElopementStatus&&!$e(y)&&!Re(y)}}).map(y=>({value:y.alertStatusTypeName,label:y.alertStatusTypeName})),K=U.tenant==="snl"&&p!==null?I:ke,H=d.useMemo(()=>nr(Xe),[Xe]);d.useEffect(()=>{let y=!1;const A=new AbortController,L=async le=>{if(le){y||C(He=>({...He,[le]:!1}));try{const He=await fetch(le,{method:"HEAD",signal:A.signal});if(He.ok){y||C(Qe=>({...Qe,[le]:!0}));return}if(He.status===404){y||C(Qe=>({...Qe,[le]:!1}));return}if(!(await fetch(le,{method:"GET",signal:A.signal})).ok)throw new Error("Media not available");y||C(Qe=>({...Qe,[le]:!0}))}catch{y||C(He=>({...He,[le]:!1}))}}};C({});const he=H.filter(le=>!Ls(le)).map(le=>le?.mediaUrl||le).filter(le=>typeof le=="string"&&le.length>0),ne={};return he.forEach(le=>{ne[le]=!0}),J(ne),he.forEach(le=>L(le)),()=>{y=!0,A.abort()}},[H]);const W=async()=>{try{k(!0);const y={alertUniqueId:ee,alertId:Ke,status:u?String(u):void 0,notes:h.trim(),modifiedBy:0},A=await S.mutateAsync(y);if(A?.responseStatus||A?.Success){const L=A?.Message||A?.data||"Alert updated successfully.";we.toast.success(L,{autoClose:1500,onClose:()=>{n(),e()}}),m(void 0),v("")}else{const L=A?.errorMessage||A?.Message||"Failed to update alert status";we.toast.error(L)}}catch(y){console.error("Error updating alert status:",y),we.toast.error("Failed to update alert status. Please try again.")}finally{k(!1)}};return i.jsx(f.Modal,{open:t,onCancel:e,width:1e3,footer:R==="details"?i.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[i.jsx(f.Button,{onClick:e,className:"!bg-[#6C757D] !text-white !border-[#6C757D] hover:!bg-[#5c636a] hover:!text-white hover:!border-[#5c636a]",children:"Cancel"}),i.jsx(f.Button,{type:"primary",onClick:W,loading:g,children:g?"Saving...":"Save Changes"})]}):null,children:s&&i.jsx(f.Tabs,{activeKey:R,onChange:y=>G(y),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:Ct}),be?.firstName?i.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",be?.firstName," ",be?.lastName||""," ",be?.residentId||""]}):null,i.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp: ",fs(ge,Z?.ianaTimeZoneId)]}),i.jsxs("div",{className:"font-sm text-gray-500",children:[i.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",ue||"No description available"]}),ae&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",ae]}),Ae&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",Ae]}),i.jsxs("div",{className:"flex gap-2 justify-start mt-3",children:[i.jsxs(f.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${Ul[String(Ce)]||"#DFE4EA"}`,backgroundColor:Ll[String(Ce)]},children:["Severity: ",Ce||"N/A"]}),i.jsxs(f.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(Je||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",Je||"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(f.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:y=>m(y),value:u,options:K,loading:U.tenant==="snl"?O: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:h,onChange:y=>v(y.target.value)})]})]})})]}),i.jsx("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"}),H.length>1?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>D.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:()=>D.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]}),H.length?i.jsx("div",{className:"w-full",children:i.jsx(f.Carousel,{ref:D,dots:!0,className:"w-full",children:H.map((y,A)=>{const L=y.mediaUrl||y,he=Ls(y);return i.jsxs("div",{className:"flex justify-center items-center relative",children:[he?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:L}),"Your browser does not support the video tag."]}):se(String(L),y,A),y.caption&&i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:y.caption}),!he&&F[String(L)]?i.jsx("button",{onClick:()=>{j(!0),x(L),T(y.type||"image")},className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:i.jsx(ir,{size:20})}):null]},String(L)||A)})})}):null]})}),i.jsx(or,{isOpen:me,onClose:()=>j(!1),src:N||"",type:E||"image"})]})},{key:"track",label:"Track Incident",children:i.jsx(Rl,{alertId:ee,id:Ke,priority:Ce,spaceName:ae,alertNumber:at,statusHistory:jt,notifGroups:q})}]})})};function pa(){const{alerts:t}=Me(),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 ln({alerts:t,loading:e=!1,columns:s,total:n,currentPage:r,onRefetch:a,onPageChange:o,onFilterChange:c,onAlertView:l}){const[u,m]=d.useState(!1),[h,v]=d.useState(null),[g,k]=d.useState("details"),{list:D,loading:R}=pa(),{config:G}=Me(),q=G.tenant==="schools",{timeZoneDetails:P}=ws(),S=P?.timeZoneName??"UTC",M=P?.ianaTimeZoneId??"UTC";function $(me,j){v(me),k(j?.tab??"details"),p(j?.sourceTab??"active"),m(!0)}function U(){m(!1)}const[Z,p]=d.useState("active"),[w,O]=d.useState(0),ie=h?{originalData:{...h,alertId:h.alertId??h.id,mediaDetails:h.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(ma,{label:S,timeZone:M})})]}),i.jsx(f.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:me=>{const j=me==="archived";O(N=>N+1),o?.(1),c?.({isArchived:j})},items:[{key:"active",label:"Active",children:i.jsx(Ks,{data:t,loading:e,pageSize:10,total:n,currentPage:r,columns:s||[],onAlertIdClick:$,onAlertView:l,onRefetch:a,onPageChange:o,onFilterChange:c,resetKey:w,serverSideFilters:q})},{key:"archived",label:"Archived",children:i.jsx(da,{alerts:t,loading:e,columns:s||[],total:n,currentPage:r,onAlertIdClick:$,onAlertView:l,onFilterChange:c,onPageChange:o,onRefetch:a,resetKey:w,serverSideFilters:q})},{key:"settings",label:"Settings",children:i.jsx(Pl,{})}]}),i.jsx($l,{isModalOpen:u,handleModalClose:U,selectedRow:ie,fetchAlertLogs:()=>{},alertStatusList:D,alertStatusLoading:R,initialTab:g,sourceTab:Z,onAlertView:l})]})}function Pl(){const[t,e]=d.useState([]),[s,n]=d.useState([]),[r,a]=d.useState([]),[o,c]=d.useState([]),[l,u]=d.useState(!0),{rules:m}=Me();return d.useEffect(()=>{let h=!0;return(async()=>{try{const v=await m.getRules();if(!h)return;c(Array.isArray(v)?v:[]);const g=(v||[]).map((k,D)=>({RuleId:k.ruleId||k.ruleName||String(D),Name:k.ruleName||k.Name||"-",Description:k.ruleDesc||k.Description||"",SeverityId:0}));e(g);try{const k=await m.getLookups(),D=Array.isArray(k?.userRoles)?k.userRoles.map(R=>({userRoleId:R.userRoleId??R.id,userRoleName:R.userRoleName??R.name})):[];n(D),a(Array.isArray(k?.severities)?k.severities:[])}catch{}}catch{}finally{h&&u(!1)}})(),()=>{h=!1}},[]),i.jsx(ya,{severities:r,rules:t,userRoles:s,rawRules:o,loadingRules:l})}function Wl(t){return Array.isArray(t)?{items:t}:t}function ga(t=1,e){const{alerts:s,config:n}=Me(),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==="transit"?(o.pageNumber=t,o.pageSize=10):n.tenant==="schools"&&(o.pageNumber=t,o.pageSize=r?100:10),s.listAlerts(o).then(Wl)},staleTime:r?0:3e4});return{alerts:a.data?.items??[],total:a.data?.total,loading:a.isLoading,error:a.error,refetch:a.refetch}}function Vl(t){const[e,s]=d.useState(1),[n,r]=d.useState({}),{alerts:a,total:o,loading:c,refetch:l}=ga(e,n),u=m=>{"isArchived"in m?r({isArchived:m.isArchived}):r(h=>({...h,...m}))};return i.jsx(ln,{alerts:a,loading:c,columns:t.columns,total:o,currentPage:e,onRefetch:l,onPageChange:s,onFilterChange:u,onAlertView:t.onAlertView})}function Bl({tenant:t,apiDomain:e,rulesDomain:s,headers:n,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,alerts:c,loading:l,columns:u,onAlertView:m}){const[h]=d.useState(()=>new yt.QueryClient),v=d.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return i.jsx(yt.QueryClientProvider,{client:h,children:i.jsx(er,{tenant:t,override:v,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,children:Array.isArray(c)?i.jsx(ln,{alerts:c,loading:!!l,columns:u,onAlertView:m}):i.jsx(Vl,{columns:u,onAlertView:m})})})}function Zl(t){const{alerts:e}=Me(),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 zl=[{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=fa;exports.AlertConsole=ln;exports.AlertConsoleWidget=Bl;exports.AlertsTable=Ks;exports.ApiProvider=er;exports.ArchivedTable=da;exports.Clock=ma;exports.DataTable=sr;exports.MyPreferencesPanel=Ml;exports.SettingsPanel=ha;exports.SettingsTabs=ya;exports.exampleAlertColumns=zl;exports.useAlertStatusList=pa;exports.useAlerts=ga;exports.useAlertsReport=Zl;exports.useApi=Me;exports.useUpdateAlertStatus=Qs;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),d=require("react"),f=require("antd"),ht=require("@ant-design/icons"),ve=require("react-toastify"),yt=require("@tanstack/react-query"),ya="#FF3B30",pa="#FF9500",ga="#FFCC00",Sa="#34C759",Gt={critical:ya,high:pa,medium:ga,low:Sa},ln={Critical:Gt.critical,High:Gt.high,Medium:Gt.medium,Low:Gt.low};function xa(t){return ln[t]||ln.Low}function cn(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,m=Number.isFinite(l)?l:0;return c*3600+u*60+m}function un(t){return t.toLowerCase().replaceAll("'","").replaceAll("‘","").replaceAll("’","")}const _n="",va=_n,wa="",Aa="",Ta="",Na="",dn={snl:{alerts:_n,rules:va},schools:{alerts:wa,rules:Aa},transit:{alerts:Ta,rules:Na}};function Ce(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function ba(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Ut(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 Re(t,e){const s={...e.headers,...ba()},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}`,l=new Error(o);throw l.status=n.status,l}return a}function ka(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Ce(t.baseUrl,"/api/Alert"),r=Ut(n,{page:s?.pageNumber??1,pageSize:s?.pageSize??10,...s?.anomalyId&&{anomalyId:s.anomalyId},...s?.spaceId&&{spaceId:s.spaceId},...s?.severityId&&{severityId:s.severityId},...s?.thirdPartyIds?.length&&{thirdPartyIds:s.thirdPartyIds.join(",")},...s?.searchText&&{searchText:s.searchText},isArchived:s?.isArchived??!1}),a=await Re(r,{method:"GET",headers:e}),o=Array.isArray(a)?a:[],l=o.length>0?o[0].totalRecords??o.length:0;return{items:o,total:l}},async getAlertStatusList(){const s=Ce(t.baseUrl,"/api/Alert/AlertStatusList"),n=await Re(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=Ce(t.baseUrl,"/Alerts/GetAlertsReport"),r=Ut(n,s),a=await Re(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Ce(t.baseUrl,"/api/Alert/status");return Re(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=Ce(t.baseUrl,"/api/Alert/GetAdminSettings"),n=await Re(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=Ce(t.baseUrl,"/api/Alert/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Re(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Ce(t.baseUrl,"/api/Alert/GetPreferenceSettings"),n=await Re(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=Ce(t.baseUrl,"/api/Alert/SetPreferenceSettings"),r=await Re(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=Ce(t.baseUrl,"/api/Alert/GetNotifications"),r=Ut(n,{alertId:s}),a=await Re(r,{method:"GET",headers:e});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]},async notifyFamilyMembers(s){const n=Ce(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=Ut(n,{alertId:s});return Re(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const a=Ce(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),o=Ut(a,{alertId:s,isEmail:n,isSMS:r});return Re(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Ce(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Re(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Ce(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Re(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null}}}function mn(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ia(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Yt(t,e){const s={...e.headers,...Ia()},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 Ea(t){const e={"Content-Type":"application/json",...t.headers||{}},s=mn(t.baseUrl,"/api/Rules"),n=mn(t.baseUrl,"/api/Rules/lookups");return{async getRules(){const r=await Yt(s,{method:"GET",headers:e});return Array.isArray(r)?r:[]},async setEscalationSettings(r){return Yt(s,{method:"POST",headers:e,body:JSON.stringify(r??{})})},async getLookups(){return Yt(n,{method:"GET",headers:e})},async updateRule(r,a){const o=`${s}/${r}`;return Yt(o,{method:"PUT",headers:e,body:JSON.stringify(a??{})})}}}function Ma(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var rs={exports:{}},Oa=rs.exports,fn;function ja(){return fn||(fn=1,(function(t,e){(function(s,n){t.exports=n()})(Oa,(function(){var s=1e3,n=6e4,r=36e5,a="millisecond",o="second",l="minute",c="hour",u="day",m="week",h="month",x="quarter",g="year",k="date",M="Invalid Date",j=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,Y=/\[([^\]]+)]|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(O){var N=["th","st","nd","rd"],v=O%100;return"["+O+(N[(v-20)%10]||N[v]||N[0])+"]"}},$=function(O,N,v){var I=String(O);return!I||I.length>=N?O:""+Array(N+1-I.length).join(v)+O},S={s:$,z:function(O){var N=-O.utcOffset(),v=Math.abs(N),I=Math.floor(v/60),T=v%60;return(N<=0?"+":"-")+$(I,2,"0")+":"+$(T,2,"0")},m:function O(N,v){if(N.date()<v.date())return-O(v,N);var I=12*(v.year()-N.year())+(v.month()-N.month()),T=N.clone().add(I,h),F=v-T<0,R=N.clone().add(I+(F?-1:1),h);return+(-(I+(v-T)/(F?T-R:R-T))||0)},a:function(O){return O<0?Math.ceil(O)||0:Math.floor(O)},p:function(O){return{M:h,y:g,w:m,d:u,D:k,h:c,m:l,s:o,ms:a,Q:x}[O]||String(O||"").toLowerCase().replace(/s$/,"")},u:function(O){return O===void 0}},E="en",V={};V[E]=H;var C="$isDayjsObject",q=function(O){return O instanceof se||!(!O||!O[C])},y=function O(N,v,I){var T;if(!N)return E;if(typeof N=="string"){var F=N.toLowerCase();V[F]&&(T=F),v&&(V[F]=v,T=F);var R=N.split("-");if(!T&&R.length>1)return O(R[0])}else{var G=N.name;V[G]=N,T=G}return!I&&T&&(E=T),T||!I&&E},w=function(O,N){if(q(O))return O.clone();var v=typeof N=="object"?N:{};return v.date=O,v.args=arguments,new se(v)},D=S;D.l=y,D.i=q,D.w=function(O,N){return w(O,{locale:N.$L,utc:N.$u,x:N.$x,$offset:N.$offset})};var se=(function(){function O(v){this.$L=y(v.locale,null,!0),this.parse(v),this.$x=this.$x||v.x||{},this[C]=!0}var N=O.prototype;return N.parse=function(v){this.$d=(function(I){var T=I.date,F=I.utc;if(T===null)return new Date(NaN);if(D.u(T))return new Date;if(T instanceof Date)return new Date(T);if(typeof T=="string"&&!/Z$/i.test(T)){var R=T.match(j);if(R){var G=R[2]-1||0,J=(R[7]||"0").substring(0,3);return F?new Date(Date.UTC(R[1],G,R[3]||1,R[4]||0,R[5]||0,R[6]||0,J)):new Date(R[1],G,R[3]||1,R[4]||0,R[5]||0,R[6]||0,J)}}return new Date(T)})(v),this.init()},N.init=function(){var v=this.$d;this.$y=v.getFullYear(),this.$M=v.getMonth(),this.$D=v.getDate(),this.$W=v.getDay(),this.$H=v.getHours(),this.$m=v.getMinutes(),this.$s=v.getSeconds(),this.$ms=v.getMilliseconds()},N.$utils=function(){return D},N.isValid=function(){return this.$d.toString()!==M},N.isSame=function(v,I){var T=w(v);return this.startOf(I)<=T&&T<=this.endOf(I)},N.isAfter=function(v,I){return w(v)<this.startOf(I)},N.isBefore=function(v,I){return this.endOf(I)<w(v)},N.$g=function(v,I,T){return D.u(v)?this[I]:this.set(T,v)},N.unix=function(){return Math.floor(this.valueOf()/1e3)},N.valueOf=function(){return this.$d.getTime()},N.startOf=function(v,I){var T=this,F=!!D.u(I)||I,R=D.p(v),G=function(xe,le){var ne=D.w(T.$u?Date.UTC(T.$y,le,xe):new Date(T.$y,le,xe),T);return F?ne:ne.endOf(u)},J=function(xe,le){return D.w(T.toDate()[xe].apply(T.toDate("s"),(F?[0,0,0,0]:[23,59,59,999]).slice(le)),T)},Q=this.$W,X=this.$M,re=this.$D,ae="set"+(this.$u?"UTC":"");switch(R){case g:return F?G(1,0):G(31,11);case h:return F?G(1,X):G(0,X+1);case m:var ie=this.$locale().weekStart||0,oe=(Q<ie?Q+7:Q)-ie;return G(F?re-oe:re+(6-oe),X);case u:case k:return J(ae+"Hours",0);case c:return J(ae+"Minutes",1);case l:return J(ae+"Seconds",2);case o:return J(ae+"Milliseconds",3);default:return this.clone()}},N.endOf=function(v){return this.startOf(v,!1)},N.$set=function(v,I){var T,F=D.p(v),R="set"+(this.$u?"UTC":""),G=(T={},T[u]=R+"Date",T[k]=R+"Date",T[h]=R+"Month",T[g]=R+"FullYear",T[c]=R+"Hours",T[l]=R+"Minutes",T[o]=R+"Seconds",T[a]=R+"Milliseconds",T)[F],J=F===u?this.$D+(I-this.$W):I;if(F===h||F===g){var Q=this.clone().set(k,1);Q.$d[G](J),Q.init(),this.$d=Q.set(k,Math.min(this.$D,Q.daysInMonth())).$d}else G&&this.$d[G](J);return this.init(),this},N.set=function(v,I){return this.clone().$set(v,I)},N.get=function(v){return this[D.p(v)]()},N.add=function(v,I){var T,F=this;v=Number(v);var R=D.p(I),G=function(X){var re=w(F);return D.w(re.date(re.date()+Math.round(X*v)),F)};if(R===h)return this.set(h,this.$M+v);if(R===g)return this.set(g,this.$y+v);if(R===u)return G(1);if(R===m)return G(7);var J=(T={},T[l]=n,T[c]=r,T[o]=s,T)[R]||1,Q=this.$d.getTime()+v*J;return D.w(Q,this)},N.subtract=function(v,I){return this.add(-1*v,I)},N.format=function(v){var I=this,T=this.$locale();if(!this.isValid())return T.invalidDate||M;var F=v||"YYYY-MM-DDTHH:mm:ssZ",R=D.z(this),G=this.$H,J=this.$m,Q=this.$M,X=T.weekdays,re=T.months,ae=T.meridiem,ie=function(le,ne,be,De){return le&&(le[ne]||le(I,F))||be[ne].slice(0,De)},oe=function(le){return D.s(G%12||12,le,"0")},xe=ae||function(le,ne,be){var De=le<12?"AM":"PM";return be?De.toLowerCase():De};return F.replace(Y,(function(le,ne){return ne||(function(be){switch(be){case"YY":return String(I.$y).slice(-2);case"YYYY":return D.s(I.$y,4,"0");case"M":return Q+1;case"MM":return D.s(Q+1,2,"0");case"MMM":return ie(T.monthsShort,Q,re,3);case"MMMM":return ie(re,Q);case"D":return I.$D;case"DD":return D.s(I.$D,2,"0");case"d":return String(I.$W);case"dd":return ie(T.weekdaysMin,I.$W,X,2);case"ddd":return ie(T.weekdaysShort,I.$W,X,3);case"dddd":return X[I.$W];case"H":return String(G);case"HH":return D.s(G,2,"0");case"h":return oe(1);case"hh":return oe(2);case"a":return xe(G,J,!0);case"A":return xe(G,J,!1);case"m":return String(J);case"mm":return D.s(J,2,"0");case"s":return String(I.$s);case"ss":return D.s(I.$s,2,"0");case"SSS":return D.s(I.$ms,3,"0");case"Z":return R}return null})(le)||R.replace(":","")}))},N.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},N.diff=function(v,I,T){var F,R=this,G=D.p(I),J=w(v),Q=(J.utcOffset()-this.utcOffset())*n,X=this-J,re=function(){return D.m(R,J)};switch(G){case g:F=re()/12;break;case h:F=re();break;case x:F=re()/3;break;case m:F=(X-Q)/6048e5;break;case u:F=(X-Q)/864e5;break;case c:F=X/r;break;case l:F=X/n;break;case o:F=X/s;break;default:F=X}return T?F:D.a(F)},N.daysInMonth=function(){return this.endOf(h).$D},N.$locale=function(){return V[this.$L]},N.locale=function(v,I){if(!v)return this.$L;var T=this.clone(),F=y(v,I,!0);return F&&(T.$L=F),T},N.clone=function(){return D.w(this.$d,this)},N.toDate=function(){return new Date(this.valueOf())},N.toJSON=function(){return this.isValid()?this.toISOString():null},N.toISOString=function(){return this.$d.toISOString()},N.toString=function(){return this.$d.toUTCString()},O})(),de=se.prototype;return w.prototype=de,[["$ms",a],["$s",o],["$m",l],["$H",c],["$W",u],["$M",h],["$y",g],["$D",k]].forEach((function(O){de[O[1]]=function(N){return this.$g(N,O[0],O[1])}})),w.extend=function(O,N){return O.$i||(O(N,se,w),O.$i=!0),w},w.locale=y,w.isDayjs=q,w.unix=function(O){return w(1e3*O)},w.en=V[E],w.Ls=V,w.p={},w}))})(rs)),rs.exports}var Da=ja();const Ca=Ma(Da);function Jn(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 Kn(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 hn(t){const{hours:e,minutes:s,seconds:n}=Kn(t);return Ca().hour(e).minute(s).second(n).millisecond(0)}function Me(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ra(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function _t(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 Oe(t,e){const s={...e.headers,...Ra()},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 ce=(...t)=>t.find(e=>e!=null);function Ft(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 Ua(t){return Array.isArray(t)?t.map(e=>Ft(e,["alertLogId","alertId","status","description","actionNotes","createdDate","createdBy","modifiedDate","modifiedBy"])):t}function La(t){return{id:String(ce(t?.AlertId,t?.alertId)??""),alertNumber:ce(t?.AlertNumber,t?.alertNumber),priority:ce(t?.Priority,t?.priority,"Low"),timestamp:ce(t?.UpdatedUtc,t?.timestamp,""),statusType:ce(t?.Status,t?.statusType,""),description:ce(t?.Description,t?.description,""),eventName:ce(t?.EventName,t?.eventName),ruleName:ce(t?.RuleName,t?.ruleName),spaceId:ce(t?.SpaceId,t?.spaceId),spaceName:ce(t?.SpaceName,t?.spaceName),anomalyId:ce(t?.AnomalyId,t?.anomalyId),severityId:ce(t?.SeverityId,t?.severityId),assignTeam:ce(t?.AssignTeam,t?.assignTeam),cameraName:ce(t?.CameraName,t?.cameraName),type:ce(t?.Type,t?.type),mediaDetails:ce(t?.MediaDetails,t?.mediaDetails,t?.MediaUrls,t?.mediaUrls),additionalMedia:ce(t?.AdditionalMedia,t?.additionalMedia),timeElapsed:ce(t?.TimeElapsed,t?.timeElapsed),timeRemaining:ce(t?.TimeRemaining,t?.timeRemaining),anomalyName:ce(t?.AnomalyName,t?.anomalyName),alertDetails:ce(t?.AlertDetails,t?.alertDetails),statusHistory:Ua(ce(t?.StatusHistory,t?.statusHistory)),isEmailSent:ce(t?.IsEmailSent,t?.isEmailSent),isSMSSent:ce(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:ce(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function Fa(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Me(t.baseUrl,"/api/detectionpolicy/alerts"),r=_t(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 Oe(r,{method:"GET",headers:e});return{items:Array.isArray(a?.Items)?a.Items.map(La):[],total:a?.Total}},async getAlertStatusList(){const s=Me(t.baseUrl,"/api/detectionpolicy/alerts/StatusList"),n=await Oe(s,{method:"GET",headers:e});return(Array.isArray(n)?n:[]).map(a=>Ft(a,["alertStatusId","value","statusName"]))},async getAlertsReport(s){const n=Me(t.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),r=_t(n,s),a=await Oe(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Me(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 Oe(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getAdminSettings(){const s=Me(t.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),n=await Oe(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n.Data??n;if(r&&typeof r=="object")return Ft(r,["userId","isAdminSetting","sortBy"],{sortBy:"SortOption"})}return null},async setAdminSettings(s){const n=Me(t.baseUrl,"/api/detectionpolicy/alerts/SetAdminSettings"),r={Settings:{UserId:0,IsAdminSetting:!0,SortOption:s?.sortBy??"",GroupBy:s?.groupBy??null}};return Oe(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Me(t.baseUrl,"/api/detectionpolicy/alerts/GetPreferenceSettings"),n=await Oe(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=Me(t.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),r=u=>{const{hours:m,minutes:h,seconds:x}=Kn(u);return(m*3600+h*60+x)*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 Oe(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=Me(t.baseUrl,"/api/detectionpolicy/alerts/SendSMSorEmailNotifications"),o=_t(a,{alertId:s,isEmail:n,isSMS:r});return Oe(o,{method:"POST",headers:e})},async getAlertNotifications(s){const n=Me(t.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),r=_t(n,{alertId:s}),a=await Oe(r,{method:"GET",headers:e});let o=[];return Array.isArray(a)?o=a:Array.isArray(a?.data)&&(o=a.data),o.map(l=>Ft(l,["alertNotificationSentId","alertId","notificationType","receipientName","receipentPhoneNumber","messageSID","messageStatus","receipientEmail","notificationReceipientType","sentAt"]))},async getTimeZoneMasters(){const s=Me(t.baseUrl,"/api/TimeZoneMaster"),n=await Oe(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n.Data:[]).map(a=>Ft(a,["timeZoneUniqueId","ianaTimeZoneId","timeZoneName","offset"]))},async getAllSpaces(){const s=t.spacesBaseUrl||t.baseUrl,n=Me(s,"/api/AllSpaces"),r=await Oe(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=Me(t.baseUrl,"/MyProfile"),n=await Oe(s,{method:"GET",headers:e}),r=n?.data?.userGuid??n?.Data?.userGuid??n?.userGuid;if(!r)return null;const a=Me(t.baseUrl,`/api/GetMyAppPreferences/${r}`),o=await Oe(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 $a(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Xe(t,e){const s={...e.headers,...$a()},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 Pa(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,m,h]=await Promise.allSettled(a),x=y=>{if(y.status!=="fulfilled")return[];const w=y.value;return Array.isArray(w)?w:Array.isArray(w?.Data)?w.Data:Array.isArray(w?.data)?w.data:[]},g=x(o),k=x(l),M=x(c),j=x(u),Y=x(m),H=h.status==="fulfilled"?h.value:null;let $=[];Array.isArray(H)?$=H:Array.isArray(H?.Data)?$=H.Data:Array.isArray(H?.data)&&($=H.data);const S=g.map(y=>({actionTypeId:Number(y?.ActionTypeId),name:y?.DisplayName??y?.Name??""})),E=k.map(y=>({recordId:y?.AnomalyId,anomalyName:y?.DisplayName??y?.Name??""})),V=M.map(y=>({thirdPartyId:Number(y?.ThirdPartyId),thirdPartyName:y?.ThirdPartyName??y?.Name??""})),C=$.map(y=>({userRoleId:y.UserRoleId??y.userRoleId??y.Id??y.id??0,userRoleName:y.UserRoleName??y.userRoleName??y.Name??y.name??""})),q={actionTypes:S,anomalies:E,thirdParties:V};return j.length&&(q.severities=j.map(y=>({severityId:y?.SeverityId??y?.severityId,severityName:y?.DisplayName??y?.SeverityName??y?.Name??y?.name??""}))),Y.length&&(q.scheduleTypes=Y),C.length&&(q.userRoles=C),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 Wa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function it(t,e){const s={...e.headers,...Wa()},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 Va(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/list-rule",t.baseUrl).toString();return{async getRules(){const n=await it(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 it(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=[it(n("/api/ActionTypeMaster/GetAll"),{method:"GET",headers:e}),it(n("/api/anomaly/anomaly-list"),{method:"POST",headers:e,body:JSON.stringify({RuleLevel:1})}),it(n("/api/Lookup/ThirdParties"),{method:"GET",headers:e}),it(n("/api/anomaly/severity-list"),{method:"GET",headers:e}),it(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,l,c,u,m]=await Promise.allSettled(a),h=C=>{if(C.status!=="fulfilled")return[];const q=C.value;return Array.isArray(q)?q:Array.isArray(q?.data)?q.data:[]},x=h(o),g=h(l),k=h(c),M=h(u),j=m.status==="fulfilled"?m.value:null,Y=x.map(C=>({actionTypeId:C?.ActionTypeUniqueId,name:C?.Name??""})),H=g.map(C=>({recordId:C?.AnomalyId,anomalyName:C?.DisplayName??C?.Name??""})),$=k.map(C=>({thirdPartyId:Number(C?.ThirdPartyId),thirdPartyName:C?.ThirdPartyName??C?.Name??""}));let S=[];Array.isArray(j)?S=j:Array.isArray(j?.Data)?S=j.Data:Array.isArray(j?.data)&&(S=j.data);const E=S.map(C=>({userRoleId:C.userRoleId??0,userRoleName:C.userRoleName??""})),V={actionTypes:Y,anomalies:H,thirdParties:$};return M.length&&(V.severities=M.map(C=>({SeverityId:C.SeverityId,DisplayName:C.SeverityName??C.DisplayName??""}))),E.length&&(V.userRoles=E),V},async updateRule(n,r){const a=new URL("/update-rule",t.baseUrl).toString(),{escalationSettings:o,ruleId:l,ruleName:c,ruleDesc:u,...m}=r??{},h=o??{},x=(h.escalationSettingsActionTypeIds??[]).filter(k=>k!=null&&!Number.isNaN(k)),g={Level1UserRoleId:h.level1UserRoleId??0,Level1PostAssistTime:h.level1PostAssistTime??0,Level2UserRoleId:h.level2UserRoleId??0,Level2PostAssistTime:h.level2PostAssistTime??0,Level3UserRoleId:h.level3UserRoleId??0,Level3PostAssistTime:h.level3PostAssistTime??0,EscalationSettingsActionTypeIds:x,ThirdPartyIds:h.thirdPartyId??[],HumanLoop:h.humanLoop??!1};return it(a,{method:"POST",headers:e,body:JSON.stringify({...m,RuleId:l??m.RuleId??n,RuleName:c??m.RuleName,RuleDesc:u??m.RuleDesc??null,ActionTypeUniqueIdList:x,EscalationSettings:g})})}}}function Fe(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ba(){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 $e(t,e){const s={...e.headers,...Ba()},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 Za(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Fe(t.baseUrl,"/api/Alerts"),r=Jt(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 $e(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=Fe(t.baseUrl,"/api/Alerts/GetAlertStatus"),n=await $e(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=Fe(t.baseUrl,"/Alerts/GetAlertsReport"),r=Jt(n,s),a=await $e(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Fe(t.baseUrl,"/api/Alerts/UpdateAlertLog"),r={alertId:s.alertId,action:s.status,notes:s.notes};return $e(n,{method:"PUT",headers:e,body:JSON.stringify(r??{})})},async getAdminSettings(){const s=Fe(t.baseUrl,"/api/Alerts/GetAdminSettings"),n=await $e(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=Fe(t.baseUrl,"/api/Alerts/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return $e(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Fe(t.baseUrl,"/api/Alerts/GetPreferenceSettings"),n=await $e(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=Fe(t.baseUrl,"/api/Alerts/SetPreferenceSettings"),r=await $e(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=Fe(t.baseUrl,"/api/Alerts/GetNotifications"),r=Jt(n,{alertId:s}),a=await $e(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=Fe(t.baseUrl,"/api/Alerts/SendSMSorEmailNotifications"),o=Jt(a,{alertId:s,isEmail:n,isSMS:r});return $e(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Fe(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await $e(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Fe(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await $e(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 Qn=d.createContext(null);function Xn({tenant:t="snl",override:e,timeZone:s,userManagementDomain:n,spacesBaseUrl:r,children:a}){const o=d.useMemo(()=>{const c=e?.alertsBaseUrl?.trim()||dn[t]?.alerts||"";let u=e?.rulesBaseUrl?.trim()||dn[t]?.rules||"";t==="snl"&&(u=c);const m=e?.headers;return{tenant:t,alertsBaseUrl:c,rulesBaseUrl:u,headers:m,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},m={schools:()=>Fa({...c,spacesBaseUrl:o.spacesBaseUrl}),transit:()=>Za(c),snl:()=>ka(c)},h={schools:()=>Pa({...u,userManagementBaseUrl:o.userManagementDomain}),transit:()=>Va({...u,userManagementBaseUrl:o.userManagementDomain}),snl:()=>Ea({baseUrl:o.alertsBaseUrl,headers:o.headers})};return{config:o,alerts:m[o.tenant](),rules:h[o.tenant]()}},[o]);return i.jsx(Qn.Provider,{value:l,children:a})}function je(){const t=d.useContext(Qn);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}const za={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Ha={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Ys=6,_s=7;function yn(t,e,s){const n=t===Ys,r=t===_s,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,m=n&&a?"Email sent":r&&o?"SMS sent":`Click to ${c}`;return{isDisabled:l,buttonText:u,tooltipTitle:m}}function qa(t,e){const s=e==="anomalyDisplayName"?t.anomalyDisplayName:t.anomalyName;return typeof s=="string"&&s.trim().length>0?s.trim():""}function Ga(t,e="anomalyName"){const s=new Set;(t||[]).forEach(r=>{const a=qa(r,e);a&&s.add(a)});const n=Array.from(s).map(r=>({label:r,value:r}));return[{label:"All Types",value:"All"},...n]}function Ya(t,e=!1){const s=new Set;(t||[]).forEach(r=>{const a=e?r.spaceNumber??r.spaceName:r.spaceName;typeof a=="string"&&a.trim().length>0&&s.add(a.trim())});const n=Array.from(s).map(r=>({label:r,value:r}));return[{label:"All",value:"All"},...n]}function Ts(t,e){return`${t}-${e?"email":"sms"}`}function Kt(t){return t===Ys||t===_s}function fs({value:t,onChange:e,options:s,className:n,dropdownWidth:r}){return i.jsx(f.Select,{className:n,options:s,value:t,onChange:e,dropdownMatchSelectWidth:r??260})}const _a=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function Ja({value:t,onChange:e,options:s}){return i.jsx(fs,{className:"w-[140px]",value:t,onChange:e,options:s||_a})}const Ka=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function Qa({value:t,onChange:e,options:s}){return i.jsx(fs,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||Ka})}function Xa({value:t,onChange:e,options:s}){return i.jsx(fs,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const ei=[{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 ti({value:t,onChange:e,options:s}){return i.jsx(fs,{className:"w-[130px]",value:t,onChange:e,options:s||ei})}function er({columns:t,data:e,loading:s=!1,pageSize:n=10,total:r,currentPage:a,rowKey:o="id",toolbar:l,tableProps:c,onPageChange:u}){const h=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(f.Table,{rowKey:o,dataSource:e,columns:t,loading:s,pagination:{pageSize:n,current:a,total:r??h,showSizeChanger:!1,showTotal:x=>`Total: ${x}`,onChange:u},bordered:!0,...c})]})}function si(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 Us(t){const e=(t?.mediaType||t?.type||"").toString().toLowerCase();return e==="video"||e==="mp4"?!0:si(t?.mediaUrl||t)}function ni(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 tr(t){const e=t;return e?(Array.isArray(e)?e:[e]).flatMap(ni):[]}const ri=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ai=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),pn=t=>{const e=ai(t);return e.charAt(0).toUpperCase()+e.slice(1)},sr=(...t)=>t.filter((e,s,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===s).join(" ").trim(),ii=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var oi={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 li=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,...oi,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:sr("lucide",r),...!a&&!ii(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,m])=>d.createElement(u,m)),...Array.isArray(a)?a:[a]]));const hs=(t,e)=>{const s=d.forwardRef(({className:n,...r},a)=>d.createElement(li,{ref:a,iconNode:e,className:sr(`lucide-${ri(pn(t))}`,`lucide-${t}`,n),...r}));return s.displayName=pn(t),s};const ci=[["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"}]],nr=hs("image-off",ci);const ui=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],di=hs("loader-circle",ui);const mi=[["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"}]],rr=hs("maximize-2",mi);const fi=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],hi=hs("minimize-2",fi),ar=({isOpen:t,onClose:e,src:s,type:n="image"})=>{const[r,a]=d.useState(!1),[o,l]=d.useState(!1);return d.useEffect(()=>{t&&l(!1)},[t,s]),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:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),e())},onTouchStart:e,children:i.jsxs("div",{className:`relative ${r?"w-full h-full":"max-w-5xl max-h-[90vh] w-full"} flex items-center justify-center`,onClick:c=>c.stopPropagation(),children:[n==="image"?i.jsx("img",{src:s,alt:"preview",className:`object-contain rounded-lg shadow-lg ${r?"w-full h-full":"max-w-full max-h-[90vh]"}`,onError:()=>l(!0)}):i.jsx("video",{src:s,controls:!0,className:`object-contain rounded-lg shadow-lg ${r?"w-full h-full":"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:"✕"}),i.jsx("button",{onClick:()=>a(!r),className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:r?i.jsx(hi,{size:20}):i.jsx(rr,{size:20})})]})}):null};function yi(t){const s=tr(t.mediaDetails)[0];if(!s)return null;const n=s.mediaUrl??s;return typeof n!="string"||!n.length?null:{url:n,item:s}}function ir({record:t}){const e=d.useMemo(()=>yi(t),[t]),[s,n]=d.useState(!1),[r,a]=d.useState(!1);if(d.useEffect(()=>{a(!1)},[e?.url]),!e)return i.jsx("span",{className:"text-gray-400 text-sm",children:"—"});const{url:o,item:l}=e,c=Us(l),u=c?"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(nr,{size:20,"aria-hidden":!0})}):c?i.jsx("video",{src:o,className:m,muted:!0,playsInline:!0,preload:"metadata",onError:()=>a(!0)}):i.jsx("img",{src:o,alt:"",className:m,onError:()=>a(!0)})}),i.jsx(ar,{isOpen:s,onClose:()=>n(!1),src:o,type:u})]})}function pi(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 Js({data:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,columns:a,severityOptions:o,anomalyOptions:l,spaceOptions:c,renderActions:u,onAlertIdClick:m,onRefetch:h,onPageChange:x,onFilterChange:g,resetKey:k,serverSideFilters:M=!1}){const[j,Y]=d.useState("All"),[H,$]=d.useState("All"),[S,E]=d.useState("All"),[V,C]=d.useState("All"),[q,y]=d.useState(""),[w,D]=d.useState(r??1);d.useEffect(()=>{k!==void 0&&(Y("All"),$("All"),E("All"),C("All"),y(""),D(1))},[k]),d.useEffect(()=>{r!==void 0&&D(r)},[r]);const[se,de]=d.useState([{label:"All",value:"All"}]),[O,N]=d.useState([]),[v,I]=d.useState([]),[T,F]=d.useState([]),[R,G]=d.useState(new Set),{rules:J,alerts:Q,config:X}=je(),re=X.tenant==="schools",ae=X.tenant==="transit",ie=X.tenant==="snl"?"anomalyDisplayName":"anomalyName",oe=pi(q,600),xe=re&&oe.trim()?100:s,le={6:{title:"Email",kind:"icon",icon:i.jsx(ht.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:i.jsx(ht.MessageOutlined,{})}},ne=d.useMemo(()=>Ga(t,ie),[t,ie]),be=d.useMemo(()=>Ya(t,ae),[t,ae]);d.useEffect(()=>{if(!Q.getAllSpaces)return;let me=!0;return(async()=>{try{const _=await Q.getAllSpaces();if(me){const we=_.map(fe=>({label:ae?String(fe.spaceNumber??fe.spaceName??""):fe.spaceName,value:String(ae?fe.spaceNumber??fe.spaceId:fe.spaceId)}));N([{label:"All",value:"All"},...we])}}catch(_){console.error("Error loading space options",_)}})(),()=>{me=!1}},[Q,ae]),d.useEffect(()=>{let me=!0;return(async()=>{try{const _=await J.getLookups(),fe=(Array.isArray(_.thirdParties)?_.thirdParties:[]).map(Ae=>({label:Ae.thirdPartyName,value:String(Ae.thirdPartyId)})),Le=(Array.isArray(_.anomalies)?_.anomalies:[]).map(Ae=>({label:Ae.anomalyName,value:Ae.anomalyId})),_e=(Array.isArray(_.severities)?_.severities:[]).map(Ae=>({label:Ae.severityName,value:String(Ae.severityId)}));me&&(de([{label:"All",value:"All"},...fe]),Le.length&&I([{label:"All Types",value:"All"},...Le]),_e.length&&F([{label:"All levels",value:"All"},..._e]))}catch(_){console.error("Error loading filter options",_)}})(),()=>{me=!1}},[J]),d.useEffect(()=>{if(!g)return;const me={anomalyId:v.length>1&&H!=="All"?H:void 0,spaceId:!ae&&O.length>1&&S!=="All"?Number(S):void 0,spaceNumber:ae&&O.length>1&&S!=="All"?S:void 0,severityId:T.length>1&&j!=="All"?Number(j):void 0,thirdPartyIds:V==="All"?void 0:[Number(V)],searchText:oe.trim()||void 0};g(me),x?.(1)},[H,S,j,V,oe,v.length,O.length,T.length,ae,re]);const De=l?.length?l:ne,Ye=M&&v.length>1?v:De,Ke=c?.length?c:be,Be=M&&O.length>1?O:Ke,Dt=M&&T.length>1?T:o,nt=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:me=>i.jsx(f.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Ha[me]}`,backgroundColor:za[me]},children:me})},{title:"Tracker",key:"tracker",width:140,render:(me,_)=>i.jsx("a",{onClick:we=>{we.preventDefault(),m?.(_,{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:(me,_)=>{if(u)return i.jsx(i.Fragment,{children:u(_)});const we=async(at,vt)=>{const U=Ts(_.id,at);G(B=>new Set(B).add(U));try{const B=await Q.sendSMSorEmailNotifications?.(_.id,at,vt);B?.responseStatus||B?.Success||B?.success?(ve.toast.success(B?.message||B.data||(at?"Email sent successfully":"SMS sent successfully")),h?.()):ve.toast.error(B?.message||B?.data||B?.errorMessage||"Failed to send notification")}catch(B){ve.toast.error(B?.message||"Failed to send notification")}finally{G(B=>{const z=new Set(B);return z.delete(U),z})}},fe=Ys,Se=_s,Le=le[fe],rt=le[Se],_e=yn(fe,_,Le?.title),Ae=yn(Se,_,rt?.title),Ct=Ts(_.id,!0),Rt=Ts(_.id,!1),St=Kt(fe)&&R.has(Ct),xt=Kt(Se)&&R.has(Rt);return i.jsxs(f.Space,{size:"middle",children:[i.jsx(f.Tooltip,{title:_e.tooltipTitle,children:i.jsx(f.Button,{size:"small",disabled:_e.isDisabled,loading:St,onClick:Kt(fe)?()=>we(!0,!1):void 0,icon:!St&&Le?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:_e.buttonText})},String(fe)),i.jsx(f.Tooltip,{title:Ae.tooltipTitle,children:i.jsx(f.Button,{size:"small",disabled:Ae.isDisabled,loading:xt,onClick:Kt(Se)?()=>we(!1,!0):void 0,icon:!xt&&rt?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:Ae.buttonText})},String(Se))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(me,_)=>{const we=_?.timeElapsed,fe=_?.timeRemaining,Se=we?cn(we):0,Le=fe?cn(fe):0,rt=Math.round(Se/(Se+Le)*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:we??"-"})]}),i.jsx(f.Progress,{percent:rt,showInfo:!1,size:"small",strokeColor:xa(_.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:fe??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(me,_)=>i.jsxs("div",{children:[i.jsx("a",{onClick:we=>{we.preventDefault(),m?.(_,{sourceTab:"active"})},className:"inline-block mb-1 text-blue-600",children:_.alertNumber}),i.jsx("div",{className:"text-black/65",children:me})]})},{title:"Preview",key:"preview",width:100,align:"center",render:(me,_)=>i.jsx(ir,{record:_})}],gt=a&&a.length?a:nt;return i.jsx("div",{children:i.jsx(er,{rowKey:"id",data:t,columns:gt,loading:e,pageSize:xe,total:n,currentPage:w,onPageChange:x,toolbar:i.jsxs(f.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[i.jsx(f.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Severity"}),i.jsx(Ja,{value:j,onChange:Y,options:Dt})]})}),i.jsx(f.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Anomaly type"}),i.jsx(Qa,{value:H,onChange:$,options:Ye})]})}),i.jsx(f.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:ae?"Bus Number":"Space"}),i.jsx(Xa,{value:S,onChange:E,options:Be})]})}),i.jsx(f.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Action Taken"}),i.jsx(ti,{value:V,onChange:C,options:se})]})}),i.jsx(f.Col,{flex:"auto"}),i.jsx(f.Col,{flex:"none",children:i.jsx(f.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:y,onChange:me=>y(me.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}const gi=["completed","false positive","face doesn't match name","safe","supervised exit","elopement confirmed"];function Ks(){const{alerts:t}=je(),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 Si extends pt{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class xi extends pt{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class vi extends pt{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class Nt extends pt{}class or extends pt{constructor(e){super(`Invalid unit ${e}`)}}class Te extends pt{}class ot extends pt{constructor(){super("Zone is an abstract class")}}const b="numeric",Ge="short",Ue="long",ls={year:b,month:b,day:b},lr={year:b,month:Ge,day:b},wi={year:b,month:Ge,day:b,weekday:Ge},cr={year:b,month:Ue,day:b},ur={year:b,month:Ue,day:b,weekday:Ue},dr={hour:b,minute:b},mr={hour:b,minute:b,second:b},fr={hour:b,minute:b,second:b,timeZoneName:Ge},hr={hour:b,minute:b,second:b,timeZoneName:Ue},yr={hour:b,minute:b,hourCycle:"h23"},pr={hour:b,minute:b,second:b,hourCycle:"h23"},gr={hour:b,minute:b,second:b,hourCycle:"h23",timeZoneName:Ge},Sr={hour:b,minute:b,second:b,hourCycle:"h23",timeZoneName:Ue},xr={year:b,month:b,day:b,hour:b,minute:b},vr={year:b,month:b,day:b,hour:b,minute:b,second:b},wr={year:b,month:Ge,day:b,hour:b,minute:b},Ar={year:b,month:Ge,day:b,hour:b,minute:b,second:b},Ai={year:b,month:Ge,day:b,weekday:Ge,hour:b,minute:b},Tr={year:b,month:Ue,day:b,hour:b,minute:b,timeZoneName:Ge},Nr={year:b,month:Ue,day:b,hour:b,minute:b,second:b,timeZoneName:Ge},br={year:b,month:Ue,day:b,weekday:Ue,hour:b,minute:b,timeZoneName:Ue},kr={year:b,month:Ue,day:b,weekday:Ue,hour:b,minute:b,second:b,timeZoneName:Ue};class Zt{get type(){throw new ot}get name(){throw new ot}get ianaName(){return this.name}get isUniversal(){throw new ot}offsetName(e,s){throw new ot}formatOffset(e,s){throw new ot}offset(e){throw new ot}equals(e){throw new ot}get isValid(){throw new ot}}let Ns=null;class ys extends Zt{static get instance(){return Ns===null&&(Ns=new ys),Ns}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Fr(e,s,n)}formatOffset(e,s){return Vt(this.offset(e),s)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}}const Ls=new Map;function Ti(t){let e=Ls.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"}),Ls.set(t,e)),e}const Ni={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function bi(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,m]=n;return[o,r,a,l,c,u,m]}function ki(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:a,value:o}=s[r],l=Ni[a];a==="era"?n[l]=o:W(l)||(n[l]=parseInt(o,10))}return n}const bs=new Map;class st extends Zt{static create(e){let s=bs.get(e);return s===void 0&&bs.set(e,s=new st(e)),s}static resetCache(){bs.clear(),Ls.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=st.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Fr(e,s,n,this.name)}formatOffset(e,s){return Vt(this.offset(e),s)}offset(e){if(!this.valid)return NaN;const s=new Date(e);if(isNaN(s))return NaN;const n=Ti(this.name);let[r,a,o,l,c,u,m]=n.formatToParts?ki(n,s):bi(n,s);l==="BC"&&(r=-Math.abs(r)+1);const x=gs({year:r,month:a,day:o,hour:c===24?0:c,minute:u,second:m,millisecond:0});let g=+s;const k=g%1e3;return g-=k>=0?k:1e3+k,(x-g)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let gn={};function Ii(t,e={}){const s=JSON.stringify([t,e]);let n=gn[s];return n||(n=new Intl.ListFormat(t,e),gn[s]=n),n}const Fs=new Map;function $s(t,e={}){const s=JSON.stringify([t,e]);let n=Fs.get(s);return n===void 0&&(n=new Intl.DateTimeFormat(t,e),Fs.set(s,n)),n}const Ps=new Map;function Ei(t,e={}){const s=JSON.stringify([t,e]);let n=Ps.get(s);return n===void 0&&(n=new Intl.NumberFormat(t,e),Ps.set(s,n)),n}const Ws=new Map;function Mi(t,e={}){const{base:s,...n}=e,r=JSON.stringify([t,n]);let a=Ws.get(r);return a===void 0&&(a=new Intl.RelativeTimeFormat(t,e),Ws.set(r,a)),a}let $t=null;function Oi(){return $t||($t=new Intl.DateTimeFormat().resolvedOptions().locale,$t)}const Vs=new Map;function Ir(t){let e=Vs.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),Vs.set(t,e)),e}const Bs=new Map;function ji(t){let e=Bs.get(t);if(!e){const s=new Intl.Locale(t);e="getWeekInfo"in s?s.getWeekInfo():s.weekInfo,"minimalDays"in e||(e={...Er,...e}),Bs.set(t,e)}return e}function Di(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=$s(t).resolvedOptions(),r=t}catch{const c=t.substring(0,s);n=$s(c).resolvedOptions(),r=c}const{numberingSystem:a,calendar:o}=n;return[r,a,o]}}function Ci(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function Ri(t){const e=[];for(let s=1;s<=12;s++){const n=P.utc(2009,s,1);e.push(t(n))}return e}function Ui(t){const e=[];for(let s=1;s<=7;s++){const n=P.utc(2016,11,13+s);e.push(t(n))}return e}function Qt(t,e,s,n){const r=t.listingMode();return r==="error"?null:r==="en"?s(e):n(e)}function Li(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||Ir(t.locale).numberingSystem==="latn"}class Fi{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=Ei(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 ge(s,this.padTo)}}}class $i{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&&st.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=$s(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 Pi{constructor(e,s,n){this.opts={style:"long",...n},!s&&Ur()&&(this.rtf=Mi(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):oo(s,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,s){return this.rtf?this.rtf.formatToParts(e,s):[]}}const Er={firstDay:1,minimalDays:4,weekend:[6,7]};class te{static fromOpts(e){return te.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,s,n,r,a=!1){const o=e||ye.defaultLocale,l=o||(a?"en-US":Oi()),c=s||ye.defaultNumberingSystem,u=n||ye.defaultOutputCalendar,m=zs(r)||ye.defaultWeekSettings;return new te(l,c,u,m,o)}static resetCache(){$t=null,Fs.clear(),Ps.clear(),Ws.clear(),Vs.clear(),Bs.clear()}static fromObject({locale:e,numberingSystem:s,outputCalendar:n,weekSettings:r}={}){return te.create(e,s,n,r)}constructor(e,s,n,r,a){const[o,l,c]=Di(e);this.locale=o,this.numberingSystem=s||l||null,this.outputCalendar=n||c||null,this.weekSettings=r,this.intl=Ci(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=Li(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:te.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,zs(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 Qt(this,e,Wr,()=>{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]=Ri(o)}return this.monthsCache[a][e]})}weekdays(e,s=!1){return Qt(this,e,Zr,()=>{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]=Ui(a=>this.extract(a,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return Qt(this,void 0,()=>zr,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[P.utc(2016,11,13,9),P.utc(2016,11,13,19)].map(s=>this.extract(s,e,"dayperiod"))}return this.meridiemCache})}eras(e){return Qt(this,e,Hr,()=>{const s={era:e};return this.eraCache[e]||(this.eraCache[e]=[P.utc(-40,1,1),P.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 Fi(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new $i(e,this.intl,s)}relFormatter(e={}){return new Pi(this.intl,this.isEnglish(),e)}listFormatter(e={}){return Ii(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||Ir(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:Lr()?ji(this.locale):Er}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 ks=null;class Ee extends Zt{static get utcInstance(){return ks===null&&(ks=new Ee(0)),ks}static instance(e){return e===0?Ee.utcInstance:new Ee(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new Ee(Ss(s[1],s[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Vt(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Vt(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,s){return Vt(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 Wi 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 ct(t,e){if(W(t)||t===null)return e;if(t instanceof Zt)return t;if(qi(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?ys.instance:s==="utc"||s==="gmt"?Ee.utcInstance:Ee.parseSpecifier(s)||st.create(t)}else return ut(t)?Ee.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new Wi(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"},Sn={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]},Vi=Qs.hanidec.replace(/[\[|\]]/g,"").split("");function Bi(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+=Vi.indexOf(t[s]);else for(const r in Sn){const[a,o]=Sn[r];n>=a&&n<=o&&(e+=n-a)}}return parseInt(e,10)}else return e}const Zs=new Map;function Zi(){Zs.clear()}function ze({numberingSystem:t},e=""){const s=t||"latn";let n=Zs.get(s);n===void 0&&(n=new Map,Zs.set(s,n));let r=n.get(e);return r===void 0&&(r=new RegExp(`${Qs[s]}${e}`),n.set(e,r)),r}let xn=()=>Date.now(),vn="system",wn=null,An=null,Tn=null,Nn=60,bn,kn=null;class ye{static get now(){return xn}static set now(e){xn=e}static set defaultZone(e){vn=e}static get defaultZone(){return ct(vn,ys.instance)}static get defaultLocale(){return wn}static set defaultLocale(e){wn=e}static get defaultNumberingSystem(){return An}static set defaultNumberingSystem(e){An=e}static get defaultOutputCalendar(){return Tn}static set defaultOutputCalendar(e){Tn=e}static get defaultWeekSettings(){return kn}static set defaultWeekSettings(e){kn=zs(e)}static get twoDigitCutoffYear(){return Nn}static set twoDigitCutoffYear(e){Nn=e%100}static get throwOnInvalid(){return bn}static set throwOnInvalid(e){bn=e}static resetCaches(){te.resetCache(),st.resetCache(),P.resetCache(),Zi()}}class qe{constructor(e,s){this.reason=e,this.explanation=s}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const Mr=[0,31,59,90,120,151,181,212,243,273,304,334],Or=[0,31,60,91,121,152,182,213,244,274,305,335];function We(t,e){return new qe("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 jr(t,e,s){return s+(zt(t)?Or:Mr)[e-1]}function Dr(t,e){const s=zt(t)?Or:Mr,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 cs(t,e=4,s=1){const{year:n,month:r,day:a}=t,o=jr(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=Bt(u,e,s)):c>Bt(n,e,s)?(u=n+1,c=1):u=n,{weekYear:u,weekNumber:c,weekday:l,...xs(t)}}function In(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:a}=t,o=en(Xs(n,1,e),s),l=bt(n);let c=r*7+a-o-7+e,u;c<1?(u=n-1,c+=bt(u)):c>l?(u=n+1,c-=bt(n)):u=n;const{month:m,day:h}=Dr(u,c);return{year:u,month:m,day:h,...xs(t)}}function Is(t){const{year:e,month:s,day:n}=t,r=jr(e,s,n);return{year:e,ordinal:r,...xs(t)}}function En(t){const{year:e,ordinal:s}=t,{month:n,day:r}=Dr(e,s);return{year:e,month:n,day:r,...xs(t)}}function Mn(t,e){if(!W(t.localWeekday)||!W(t.localWeekNumber)||!W(t.localWeekYear)){if(!W(t.weekday)||!W(t.weekNumber)||!W(t.weekYear))throw new Nt("Cannot mix locale-based week fields with ISO-based week fields");return W(t.localWeekday)||(t.weekday=t.localWeekday),W(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),W(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 zi(t,e=4,s=1){const n=ps(t.weekYear),r=Ve(t.weekNumber,1,Bt(t.weekYear,e,s)),a=Ve(t.weekday,1,7);return n?r?a?!1:We("weekday",t.weekday):We("week",t.weekNumber):We("weekYear",t.weekYear)}function Hi(t){const e=ps(t.year),s=Ve(t.ordinal,1,bt(t.year));return e?s?!1:We("ordinal",t.ordinal):We("year",t.year)}function Cr(t){const e=ps(t.year),s=Ve(t.month,1,12),n=Ve(t.day,1,us(t.year,t.month));return e?s?n?!1:We("day",t.day):We("month",t.month):We("year",t.year)}function Rr(t){const{hour:e,minute:s,second:n,millisecond:r}=t,a=Ve(e,0,23)||e===24&&s===0&&n===0&&r===0,o=Ve(s,0,59),l=Ve(n,0,59),c=Ve(r,0,999);return a?o?l?c?!1:We("millisecond",r):We("second",n):We("minute",s):We("hour",e)}function W(t){return typeof t>"u"}function ut(t){return typeof t=="number"}function ps(t){return typeof t=="number"&&t%1===0}function qi(t){return typeof t=="string"}function Gi(t){return Object.prototype.toString.call(t)==="[object Date]"}function Ur(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function Lr(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function Yi(t){return Array.isArray(t)?t:[t]}function On(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 _i(t,e){return e.reduce((s,n)=>(s[n]=t[n],s),{})}function It(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function zs(t){if(t==null)return null;if(typeof t!="object")throw new Te("Week settings must be an object");if(!Ve(t.firstDay,1,7)||!Ve(t.minimalDays,1,7)||!Array.isArray(t.weekend)||t.weekend.some(e=>!Ve(e,1,7)))throw new Te("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function Ve(t,e,s){return ps(t)&&t>=e&&t<=s}function Ji(t,e){return t-e*Math.floor(t/e)}function ge(t,e=2){const s=t<0;let n;return s?n="-"+(""+-t).padStart(e,"0"):n=(""+t).padStart(e,"0"),n}function lt(t){if(!(W(t)||t===null||t===""))return parseInt(t,10)}function dt(t){if(!(W(t)||t===null||t===""))return parseFloat(t)}function tn(t){if(!(W(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 zt(t){return t%4===0&&(t%100!==0||t%400===0)}function bt(t){return zt(t)?366:365}function us(t,e){const s=Ji(e-1,12)+1,n=t+(e-s)/12;return s===2?zt(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][s-1]}function gs(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 jn(t,e,s){return-en(Xs(t,1,e),s)+e-1}function Bt(t,e=4,s=1){const n=jn(t,e,s),r=jn(t+1,e,s);return(bt(t)-n+r)/7}function Hs(t){return t>99?t:t>ye.twoDigitCutoffYear?1900+t:2e3+t}function Fr(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 Ss(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 $r(t){const e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new Te(`Invalid unit value ${t}`);return e}function ds(t,e){const s={};for(const n in t)if(It(t,n)){const r=t[n];if(r==null)continue;s[e(n)]=$r(r)}return s}function Vt(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}${ge(s,2)}:${ge(n,2)}`;case"narrow":return`${r}${s}${n>0?`:${n}`:""}`;case"techie":return`${r}${ge(s,2)}${ge(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function xs(t){return _i(t,["hour","minute","second","millisecond"])}const Ki=["January","February","March","April","May","June","July","August","September","October","November","December"],Pr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Qi=["J","F","M","A","M","J","J","A","S","O","N","D"];function Wr(t){switch(t){case"narrow":return[...Qi];case"short":return[...Pr];case"long":return[...Ki];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 Vr=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Br=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Xi=["M","T","W","T","F","S","S"];function Zr(t){switch(t){case"narrow":return[...Xi];case"short":return[...Br];case"long":return[...Vr];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const zr=["AM","PM"],eo=["Before Christ","Anno Domini"],to=["BC","AD"],so=["B","A"];function Hr(t){switch(t){case"narrow":return[...so];case"short":return[...to];case"long":return[...eo];default:return null}}function no(t){return zr[t.hour<12?0:1]}function ro(t,e){return Zr(e)[t.weekday-1]}function ao(t,e){return Wr(e)[t.month-1]}function io(t,e){return Hr(e)[t.year<0?0:1]}function oo(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 h=t==="days";switch(e){case 1:return h?"tomorrow":`next ${r[t][0]}`;case-1:return h?"yesterday":`last ${r[t][0]}`;case 0:return h?"today":`this ${r[t][0]}`}}const o=Object.is(e,-0)||e<0,l=Math.abs(e),c=l===1,u=r[t],m=n?c?u[1]:u[2]||u[1]:c?r[t][0]:t;return o?`${l} ${m} ago`:`in ${l} ${m}`}function Dn(t,e){let s="";for(const n of t)n.literal?s+=n.val:s+=e(n.val);return s}const lo={D:ls,DD:lr,DDD:cr,DDDD:ur,t:dr,tt:mr,ttt:fr,tttt:hr,T:yr,TT:pr,TTT:gr,TTTT:Sr,f:xr,ff:wr,fff:Tr,ffff:br,F:vr,FF:Ar,FFF:Nr,FFFF:kr};class Ne{static create(e,s={}){return new Ne(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 lo[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 ge(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,k)=>this.loc.extract(e,g,k),o=g=>e.isOffsetFixed&&e.offset===0&&g.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,g.format):"",l=()=>n?no(e):a({hour:"numeric",hourCycle:"h12"},"dayperiod"),c=(g,k)=>n?ao(e,g):a(k?{month:g}:{month:g,day:"numeric"},"month"),u=(g,k)=>n?ro(e,g):a(k?{weekday:g}:{weekday:g,month:"long",day:"numeric"},"weekday"),m=g=>{const k=Ne.macroTokenToFormatOpts(g);return k?this.formatWithSystemDefault(e,k):g},h=g=>n?io(e,g):a({era:g},"era"),x=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 h("short");case"GG":return h("long");case"GGGGG":return h("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 m(g)}};return Dn(Ne.parseFormat(s),x)}formatDurationFromString(e,s){const n=this.opts.signMode==="negativeLargestOnly"?-1:1,r=m=>{switch(m[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=(m,h)=>x=>{const g=r(x);if(g){const k=h.isNegativeDuration&&g!==h.largestUnit?n:1;let M;return this.opts.signMode==="negativeLargestOnly"&&g!==h.largestUnit?M="never":this.opts.signMode==="all"?M="always":M="auto",this.num(m.get(g)*k,x.length,M)}else return x},o=Ne.parseFormat(s),l=o.reduce((m,{literal:h,val:x})=>h?m:m.concat(x),[]),c=e.shiftTo(...l.map(r).filter(m=>m)),u={isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]};return Dn(o,a(c,u))}}const qr=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Et(...t){const e=t.reduce((s,n)=>s+n.source,"");return RegExp(`^${e}$`)}function Mt(...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 Gr(...t){return(e,s)=>{const n={};let r;for(r=0;r<t.length;r++)n[t[r]]=lt(e[s+r]);return[n,null,s+r]}}const Yr=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,co=`(?:${Yr.source}?(?:\\[(${qr.source})\\])?)?`,nn=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,_r=RegExp(`${nn.source}${co}`),rn=RegExp(`(?:[Tt]${_r.source})?`),uo=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,mo=/(\d{4})-?W(\d\d)(?:-?(\d))?/,fo=/(\d{4})-?(\d{3})/,ho=Gr("weekYear","weekNumber","weekDay"),yo=Gr("year","ordinal"),po=/(\d{4})-(\d\d)-(\d\d)/,Jr=RegExp(`${nn.source} ?(?:${Yr.source}|(${qr.source}))?`),go=RegExp(`(?: ${Jr.source})?`);function kt(t,e,s){const n=t[e];return W(n)?s:lt(n)}function So(t,e){return[{year:kt(t,e),month:kt(t,e+1,1),day:kt(t,e+2,1)},null,e+3]}function jt(t,e){return[{hours:kt(t,e,0),minutes:kt(t,e+1,0),seconds:kt(t,e+2,0),milliseconds:tn(t[e+3])},null,e+4]}function Ht(t,e){const s=!t[e]&&!t[e+1],n=Ss(t[e+1],t[e+2]),r=s?null:Ee.instance(n);return[{},r,e+3]}function qt(t,e){const s=t[e]?st.create(t[e]):null;return[{},s,e+1]}const xo=RegExp(`^T?${nn.source}$`),vo=/^-?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 wo(t){const[e,s,n,r,a,o,l,c,u]=t,m=e[0]==="-",h=c&&c[0]==="-",x=(g,k=!1)=>g!==void 0&&(k||g&&m)?-g:g;return[{years:x(dt(s)),months:x(dt(n)),weeks:x(dt(r)),days:x(dt(a)),hours:x(dt(o)),minutes:x(dt(l)),seconds:x(dt(c),c==="-0"),milliseconds:x(tn(u),h)}]}const Ao={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?Hs(lt(e)):lt(e),month:Pr.indexOf(s)+1,day:lt(n),hour:lt(r),minute:lt(a)};return o&&(l.second=lt(o)),t&&(l.weekday=t.length>3?Vr.indexOf(t)+1:Br.indexOf(t)+1),l}const To=/^(?:(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 No(t){const[,e,s,n,r,a,o,l,c,u,m,h]=t,x=an(e,r,n,s,a,o,l);let g;return c?g=Ao[c]:u?g=0:g=Ss(m,h),[x,new Ee(g)]}function bo(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const ko=/^(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$/,Io=/^(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$/,Eo=/^(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 Cn(t){const[,e,s,n,r,a,o,l]=t;return[an(e,r,n,s,a,o,l),Ee.utcInstance]}function Mo(t){const[,e,s,n,r,a,o,l]=t;return[an(e,l,s,n,r,a,o),Ee.utcInstance]}const Oo=Et(uo,rn),jo=Et(mo,rn),Do=Et(fo,rn),Co=Et(_r),Kr=Mt(So,jt,Ht,qt),Ro=Mt(ho,jt,Ht,qt),Uo=Mt(yo,jt,Ht,qt),Lo=Mt(jt,Ht,qt);function Fo(t){return Ot(t,[Oo,Kr],[jo,Ro],[Do,Uo],[Co,Lo])}function $o(t){return Ot(bo(t),[To,No])}function Po(t){return Ot(t,[ko,Cn],[Io,Cn],[Eo,Mo])}function Wo(t){return Ot(t,[vo,wo])}const Vo=Mt(jt);function Bo(t){return Ot(t,[xo,Vo])}const Zo=Et(po,go),zo=Et(Jr),Ho=Mt(jt,Ht,qt);function qo(t){return Ot(t,[Zo,Kr],[zo,Ho])}const Rn="Invalid Duration",Qr={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}},Go={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},...Qr},Pe=146097/400,wt=146097/4800,Yo={years:{quarters:4,months:12,weeks:Pe/7,days:Pe,hours:Pe*24,minutes:Pe*24*60,seconds:Pe*24*60*60,milliseconds:Pe*24*60*60*1e3},quarters:{months:3,weeks:Pe/28,days:Pe/4,hours:Pe*24/4,minutes:Pe*24*60/4,seconds:Pe*24*60*60/4,milliseconds:Pe*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},...Qr},ft=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],_o=ft.slice(0).reverse();function et(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 Xr(t,e){let s=e.milliseconds??0;for(const n of _o.slice(1))e[n]&&(s+=e[n]*t[n].milliseconds);return s}function Un(t,e){const s=Xr(t,e)<0?-1:1;ft.reduceRight((n,r)=>{if(W(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(W(e[r]))return n;if(n){const a=e[n]%1;e[n]-=a,e[r]+=a*t[n][r]}return r},null)}function Ln(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?Yo:Go;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||te.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 Te(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new K({values:ds(e,K.normalizeUnit),loc:te.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(ut(e))return K.fromMillis(e);if(K.isDuration(e))return e;if(typeof e=="object")return K.fromObject(e);throw new Te(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,s){const[n]=Wo(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]=Bo(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 Te("need to specify a reason the Duration is invalid");const n=e instanceof qe?e:new qe(e,s);if(ye.throwOnInvalid)throw new vi(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 or(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?Ne.create(this.loc,n).formatDurationFromString(this,e):Rn}toHuman(e={}){if(!this.isValid)return Rn;const s=e.showZeros!==!1,n=ft.map(r=>{const a=this.values[r];return W(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},P.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?Xr(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 ft)(It(s.values,r)||It(this.values,r))&&(n[r]=s.get(r)+this.get(r));return et(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]=$r(e(this.values[n],n));return et(this,{values:s},!0)}get(e){return this[K.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const s={...this.values,...ds(e,K.normalizeUnit)};return et(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 et(this,o)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return Un(this.matrix,e),et(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=Ln(this.normalize().shiftToAll().toObject());return et(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 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;ut(r[o])&&(l+=r[o]);const c=Math.trunc(l);s[o]=c,n[o]=(l*1e3-c*1e3)/1e3}else ut(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 Un(this.matrix,s),et(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 et(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=Ln(this.values);return et(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 Jo(t,e){return!t||!t.isValid?he.invalid("missing or invalid start"):!e||!e.isValid?he.invalid("missing or invalid end"):e<t?he.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 he{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 Te("need to specify a reason the Interval is invalid");const n=e instanceof qe?e:new qe(e,s);if(ye.throwOnInvalid)throw new xi(n);return new he({invalid:n})}static fromDateTimes(e,s){const n=Lt(e),r=Lt(s),a=Jo(n,r);return a??new he({start:n,end:r})}static after(e,s){const n=K.fromDurationLike(s),r=Lt(e);return he.fromDateTimes(r,r.plus(n))}static before(e,s){const n=K.fromDurationLike(s),r=Lt(e);return he.fromDateTimes(r.minus(n),r)}static fromISO(e,s){const[n,r]=(e||"").split("/",2);if(n&&r){let a,o;try{a=P.fromISO(n,s),o=a.isValid}catch{o=!1}let l,c;try{l=P.fromISO(r,s),c=l.isValid}catch{c=!1}if(o&&c)return he.fromDateTimes(a,l);if(o){const u=K.fromISO(r,s);if(u.isValid)return he.after(a,u)}else if(c){const u=K.fromISO(n,s);if(u.isValid)return he.before(l,u)}}return he.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?he.fromDateTimes(e||this.s,s||this.e):this}splitAt(...e){if(!this.isValid)return[];const s=e.map(Lt).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(he.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(he.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:he.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 he.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(he.fromDateTimes(s,c.time)),s=null);return he.merge(r)}difference(...e){return he.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=ls,s={}){return this.isValid?Ne.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):K.invalid(this.invalidReason)}mapEndpoints(e){return he.fromDateTimes(e(this.s),e(this.e))}}class Xt{static hasDST(e=ye.defaultZone){const s=P.now().setZone(e).set({month:12});return!e.isUniversal&&s.offset!==s.set({month:6}).offset}static isValidIANAZone(e){return st.isValidZone(e)}static normalizeZone(e){return ct(e,ye.defaultZone)}static getStartOfWeek({locale:e=null,locObj:s=null}={}){return(s||te.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:s=null}={}){return(s||te.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:s=null}={}){return(s||te.create(e)).getWeekendDays().slice()}static months(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||te.create(s,n,a)).months(e)}static monthsFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||te.create(s,n,a)).months(e,!0)}static weekdays(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||te.create(s,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||te.create(s,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return te.create(e).meridiems()}static eras(e="short",{locale:s=null}={}){return te.create(s,null,"gregory").eras(e)}static features(){return{relative:Ur(),localeWeek:Lr()}}}function Fn(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 Ko(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 m=Fn(c,u);return(m-m%7)/7}],["days",Fn]],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 Qo(t,e,s,n){let[r,a,o,l]=Ko(t,e,s);const c=e-r,u=s.filter(h=>["hours","minutes","seconds","milliseconds"].indexOf(h)>=0);u.length===0&&(o<e&&(o=r.plus({[l]:1})),o!==r&&(a[l]=(a[l]||0)+c/(o-r)));const m=K.fromObject(a,n);return u.length>0?K.fromMillis(c,n).shiftTo(...u).plus(m):m}const Xo="missing Intl.DateTimeFormat.formatToParts support";function ee(t,e=s=>s){return{regex:t,deser:([s])=>e(Bi(s))}}const el=" ",ea=`[ ${el}]`,ta=new RegExp(ea,"g");function tl(t){return t.replace(/\./g,"\\.?").replace(ta,ea)}function $n(t){return t.replace(/\./g,"").replace(ta," ").toLowerCase()}function He(t,e){return t===null?null:{regex:RegExp(t.map(tl).join("|")),deser:([s])=>t.findIndex(n=>$n(s)===$n(n))+e}}function Pn(t,e){return{regex:t,deser:([,s,n])=>Ss(s,n),groups:e}}function es(t){return{regex:t,deser:([e])=>e}}function sl(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function nl(t,e){const s=ze(e),n=ze(e,"{2}"),r=ze(e,"{3}"),a=ze(e,"{4}"),o=ze(e,"{6}"),l=ze(e,"{1,2}"),c=ze(e,"{1,3}"),u=ze(e,"{1,6}"),m=ze(e,"{1,9}"),h=ze(e,"{2,4}"),x=ze(e,"{4,6}"),g=j=>({regex:RegExp(sl(j.val)),deser:([Y])=>Y,literal:!0}),M=(j=>{if(t.literal)return g(j);switch(j.val){case"G":return He(e.eras("short"),0);case"GG":return He(e.eras("long"),0);case"y":return ee(u);case"yy":return ee(h,Hs);case"yyyy":return ee(a);case"yyyyy":return ee(x);case"yyyyyy":return ee(o);case"M":return ee(l);case"MM":return ee(n);case"MMM":return He(e.months("short",!0),1);case"MMMM":return He(e.months("long",!0),1);case"L":return ee(l);case"LL":return ee(n);case"LLL":return He(e.months("short",!1),1);case"LLLL":return He(e.months("long",!1),1);case"d":return ee(l);case"dd":return ee(n);case"o":return ee(c);case"ooo":return ee(r);case"HH":return ee(n);case"H":return ee(l);case"hh":return ee(n);case"h":return ee(l);case"mm":return ee(n);case"m":return ee(l);case"q":return ee(l);case"qq":return ee(n);case"s":return ee(l);case"ss":return ee(n);case"S":return ee(c);case"SSS":return ee(r);case"u":return es(m);case"uu":return es(l);case"uuu":return ee(s);case"a":return He(e.meridiems(),0);case"kkkk":return ee(a);case"kk":return ee(h,Hs);case"W":return ee(l);case"WW":return ee(n);case"E":case"c":return ee(s);case"EEE":return He(e.weekdays("short",!1),1);case"EEEE":return He(e.weekdays("long",!1),1);case"ccc":return He(e.weekdays("short",!0),1);case"cccc":return He(e.weekdays("long",!0),1);case"Z":case"ZZ":return Pn(new RegExp(`([+-]${l.source})(?::(${n.source}))?`),2);case"ZZZ":return Pn(new RegExp(`([+-]${l.source})(${n.source})?`),2);case"z":return es(/[a-z_+-/]{1,256}?/i);case" ":return es(/[^\S\n\r]/);default:return g(j)}})(t)||{invalidReason:Xo};return M.token=t,M}const rl={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 al(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=rl[o];if(typeof l=="object"&&(l=l[a]),l)return{literal:!1,val:l}}function il(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function ol(t,e,s){const n=t.match(e);if(n){const r={};let a=1;for(const o in s)if(It(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 ll(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 W(t.z)||(s=st.create(t.z)),W(t.Z)||(s||(s=new Ee(t.Z)),n=t.Z),W(t.q)||(t.M=(t.q-1)*3+1),W(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),W(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 Es=null;function cl(){return Es||(Es=P.fromMillis(1555555555555)),Es}function ul(t,e){if(t.literal)return t;const s=Ne.macroTokenToFormatOpts(t.val),n=aa(s,e);return n==null||n.includes(void 0)?t:n}function sa(t,e){return Array.prototype.concat(...t.map(s=>ul(s,e)))}class na{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=sa(Ne.parseFormat(s),e),this.units=this.tokens.map(n=>nl(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=il(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=ol(e,this.regex,this.handlers),[r,a,o]=n?ll(n):[null,null,void 0];if(It(n,"a")&&It(n,"H"))throw new Nt("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 ra(t,e,s){return new na(t,s).explainFromTokens(e)}function dl(t,e,s){const{result:n,zone:r,specificOffset:a,invalidReason:o}=ra(t,e,s);return[n,r,a,o]}function aa(t,e){if(!t)return null;const n=Ne.create(e,t).dtFormatter(cl()),r=n.formatToParts(),a=n.resolvedOptions();return r.map(o=>al(o,t,a))}const Ms="Invalid DateTime",Wn=864e13;function Pt(t){return new qe("unsupported zone",`the zone "${t.name}" is not supported`)}function Os(t){return t.weekData===null&&(t.weekData=cs(t.c)),t.weekData}function js(t){return t.localWeekData===null&&(t.localWeekData=cs(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 P({...s,...e,old:s})}function ia(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 ts(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 as(t,e,s){return ia(gs(t),e,s)}function Vn(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,us(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=gs(a);let[c,u]=ia(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=P.fromObject(t,{...s,zone:c,specificOffset:a});return o?u:u.setZone(l)}else return P.invalid(new qe("unparsable",`the input "${r}" can't be parsed as ${n}`))}function ss(t,e,s=!0){return t.isValid?Ne.create(te.create("en-US"),{allowZ:s,forceSimple:!0}).formatDateTimeFromString(t,e):null}function Ds(t,e,s){const n=t.c.year>9999||t.c.year<0;let r="";if(n&&t.c.year>=0&&(r+="+"),r+=ge(t.c.year,n?6:4),s==="year")return r;if(e){if(r+="-",r+=ge(t.c.month),s==="month")return r;r+="-"}else if(r+=ge(t.c.month),s==="month")return r;return r+=ge(t.c.day),r}function Bn(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+=ge(t.c.hour),o==="hour")break;if(e){if(c+=":",c+=ge(t.c.minute),o==="minute")break;l&&(c+=":",c+=ge(t.c.second))}else{if(c+=ge(t.c.minute),o==="minute")break;l&&(c+=ge(t.c.second))}if(o==="second")break;l&&(!n||t.c.millisecond!==0)&&(c+=".",c+=ge(t.c.millisecond,3))}return r&&(t.isOffsetFixed&&t.offset===0&&!a?c+="Z":t.o<0?(c+="-",c+=ge(Math.trunc(-t.o/60)),c+=":",c+=ge(Math.trunc(-t.o%60))):(c+="+",c+=ge(Math.trunc(t.o/60)),c+=":",c+=ge(Math.trunc(t.o%60)))),a&&(c+="["+t.zone.ianaName+"]"),c}const oa={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},ml={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},fl={ordinal:1,hour:0,minute:0,second:0,millisecond:0},is=["year","month","day","hour","minute","second","millisecond"],hl=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],yl=["year","ordinal","hour","minute","second","millisecond"];function os(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 or(t);return e}function Zn(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return os(t)}}function pl(t){if(Wt===void 0&&(Wt=ye.now()),t.type!=="iana")return t.offset(Wt);const e=t.name;let s=qs.get(e);return s===void 0&&(s=t.offset(Wt),qs.set(e,s)),s}function zn(t,e){const s=ct(e.zone,ye.defaultZone);if(!s.isValid)return P.invalid(Pt(s));const n=te.fromObject(e);let r,a;if(W(t.year))r=ye.now();else{for(const c of is)W(t[c])&&(t[c]=oa[c]);const o=Cr(t)||Rr(t);if(o)return P.invalid(o);const l=pl(s);[r,a]=as(t,l,s)}return new P({ts:r,zone:s,loc:n,o:a})}function Hn(t,e,s){const n=W(s.round)?!0:s.round,r=W(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 qn(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 qs=new Map;class P{constructor(e){const s=e.zone||ye.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new qe("invalid input"):null)||(s.isValid?null:Pt(s));this.ts=W(e.ts)?ye.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=ut(e.o)&&!e.old?e.o:s.offset(this.ts);r=ts(this.ts,l),n=Number.isNaN(r.year)?new qe("invalid input"):null,r=n?null:r,a=n?null:l}this._zone=s,this.loc=e.loc||te.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=a,this.isLuxonDateTime=!0}static now(){return new P({})}static local(){const[e,s]=qn(arguments),[n,r,a,o,l,c,u]=s;return zn({year:n,month:r,day:a,hour:o,minute:l,second:c,millisecond:u},e)}static utc(){const[e,s]=qn(arguments),[n,r,a,o,l,c,u]=s;return e.zone=Ee.utcInstance,zn({year:n,month:r,day:a,hour:o,minute:l,second:c,millisecond:u},e)}static fromJSDate(e,s={}){const n=Gi(e)?e.valueOf():NaN;if(Number.isNaN(n))return P.invalid("invalid input");const r=ct(s.zone,ye.defaultZone);return r.isValid?new P({ts:n,zone:r,loc:te.fromObject(s)}):P.invalid(Pt(r))}static fromMillis(e,s={}){if(ut(e))return e<-Wn||e>Wn?P.invalid("Timestamp out of range"):new P({ts:e,zone:ct(s.zone,ye.defaultZone),loc:te.fromObject(s)});throw new Te(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,s={}){if(ut(e))return new P({ts:e*1e3,zone:ct(s.zone,ye.defaultZone),loc:te.fromObject(s)});throw new Te("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=ct(s.zone,ye.defaultZone);if(!n.isValid)return P.invalid(Pt(n));const r=te.fromObject(s),a=ds(e,Zn),{minDaysInFirstWeek:o,startOfWeek:l}=Mn(a,r),c=ye.now(),u=W(s.specificOffset)?n.offset(c):s.specificOffset,m=!W(a.ordinal),h=!W(a.year),x=!W(a.month)||!W(a.day),g=h||x,k=a.weekYear||a.weekNumber;if((g||m)&&k)throw new Nt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(x&&m)throw new Nt("Can't mix ordinal dates with month/day");const M=k||a.weekday&&!g;let j,Y,H=ts(c,u);M?(j=hl,Y=ml,H=cs(H,o,l)):m?(j=yl,Y=fl,H=Is(H)):(j=is,Y=oa);let $=!1;for(const w of j){const D=a[w];W(D)?$?a[w]=Y[w]:a[w]=H[w]:$=!0}const S=M?zi(a,o,l):m?Hi(a):Cr(a),E=S||Rr(a);if(E)return P.invalid(E);const V=M?In(a,o,l):m?En(a):a,[C,q]=as(V,u,n),y=new P({ts:C,zone:n,o:q,loc:r});return a.weekday&&g&&e.weekday!==y.weekday?P.invalid("mismatched weekday",`you can't specify both a weekday of ${a.weekday} and a date of ${y.toISO()}`):y.isValid?y:P.invalid(y.invalid)}static fromISO(e,s={}){const[n,r]=Fo(e);return Tt(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=$o(e);return Tt(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=Po(e);return Tt(n,r,s,"HTTP",s)}static fromFormat(e,s,n={}){if(W(e)||W(s))throw new Te("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:a=null}=n,o=te.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0}),[l,c,u,m]=dl(o,e,s);return m?P.invalid(m):Tt(l,c,n,`format ${s}`,e,u)}static fromString(e,s,n={}){return P.fromFormat(e,s,n)}static fromSQL(e,s={}){const[n,r]=qo(e);return Tt(n,r,s,"SQL",e)}static invalid(e,s=null){if(!e)throw new Te("need to specify a reason the DateTime is invalid");const n=e instanceof qe?e:new qe(e,s);if(ye.throwOnInvalid)throw new Si(n);return new P({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,s={}){const n=aa(e,te.fromObject(s));return n?n.map(r=>r?r.val:null).join(""):null}static expandFormat(e,s={}){return sa(Ne.parseFormat(e),te.fromObject(s)).map(r=>r.val).join("")}static resetCache(){Wt=void 0,qs.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?Os(this).weekYear:NaN}get weekNumber(){return this.isValid?Os(this).weekNumber:NaN}get weekday(){return this.isValid?Os(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?js(this).weekday:NaN}get localWeekNumber(){return this.isValid?js(this).weekNumber:NaN}get localWeekYear(){return this.isValid?js(this).weekYear:NaN}get ordinal(){return this.isValid?Is(this.c).ordinal:NaN}get monthShort(){return this.isValid?Xt.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Xt.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Xt.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Xt.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=gs(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,m=ts(c,o),h=ts(u,l);return m.hour===h.hour&&m.minute===h.minute&&m.second===h.second&&m.millisecond===h.millisecond?[mt(this,{ts:c}),mt(this,{ts:u})]:[this]}get isInLeapYear(){return zt(this.year)}get daysInMonth(){return us(this.year,this.month)}get daysInYear(){return this.isValid?bt(this.year):NaN}get weeksInWeekYear(){return this.isValid?Bt(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Bt(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:s,numberingSystem:n,calendar:r}=Ne.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:s,numberingSystem:n,outputCalendar:r}}toUTC(e=0,s={}){return this.setZone(Ee.instance(e),s)}toLocal(){return this.setZone(ye.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=ct(e,ye.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]=as(o,a,e)}return mt(this,{ts:r,zone:e})}else return P.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=ds(e,Zn),{minDaysInFirstWeek:n,startOfWeek:r}=Mn(s,this.loc),a=!W(s.weekYear)||!W(s.weekNumber)||!W(s.weekday),o=!W(s.ordinal),l=!W(s.year),c=!W(s.month)||!W(s.day),u=l||c,m=s.weekYear||s.weekNumber;if((u||o)&&m)throw new Nt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(c&&o)throw new Nt("Can't mix ordinal dates with month/day");let h;a?h=In({...cs(this.c,n,r),...s},n,r):W(s.ordinal)?(h={...this.toObject(),...s},W(s.day)&&(h.day=Math.min(us(h.year,h.month),h.day))):h=En({...Is(this.c),...s});const[x,g]=as(h,this.o,this.zone);return mt(this,{ts:x,o:g})}plus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e);return mt(this,Vn(this,s))}minus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e).negate();return mt(this,Vn(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?Ne.create(this.loc.redefaultToEN(s)).formatDateTimeFromString(this,e):Ms}toLocaleString(e=ls,s={}){return this.isValid?Ne.create(this.loc.clone(s),e).formatDateTime(this):Ms}toLocaleParts(e={}){return this.isValid?Ne.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=os(o);const l=e==="extended";let c=Ds(this,l,o);return is.indexOf(o)>=3&&(c+="T"),c+=Bn(this,l,s,n,r,a,o),c}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?Ds(this,e==="extended",os(s)):null}toISOWeekDate(){return ss(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=os(l),(r&&is.indexOf(l)>=3?"T":"")+Bn(this,o==="extended",s,e,n,a,l)):null}toRFC2822(){return ss(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return ss(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?Ds(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")),ss(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Ms}[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=Yi(s).map(K.normalizeUnit),o=e.valueOf()>this.valueOf(),l=o?this:e,c=o?e:this,u=Qo(l,c,a,r);return o?u.negate():u}diffNow(e="milliseconds",s={}){return this.diff(P.now(),e,s)}until(e){return this.isValid?he.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||P.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),Hn(s,this.plus(n),{...e,numeric:"always",units:r,unit:a})}toRelativeCalendar(e={}){return this.isValid?Hn(e.base||P.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(P.isDateTime))throw new Te("min requires all arguments be DateTimes");return On(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every(P.isDateTime))throw new Te("max requires all arguments be DateTimes");return On(e,s=>s.valueOf(),Math.max)}static fromFormatExplain(e,s,n={}){const{locale:r=null,numberingSystem:a=null}=n,o=te.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});return ra(o,e,s)}static fromStringExplain(e,s,n={}){return P.fromFormatExplain(e,s,n)}static buildFormatParser(e,s={}){const{locale:n=null,numberingSystem:r=null}=s,a=te.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new na(a,e)}static fromFormatParser(e,s,n={}){if(W(e)||W(s))throw new Te("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:a=null}=n,o=te.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});if(!o.equals(s.locale))throw new Te(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${s.locale}`);const{result:l,zone:c,specificOffset:u,invalidReason:m}=s.explainFromTokens(e);return m?P.invalid(m):Tt(l,c,n,`format ${s.format}`,e,u)}static get DATE_SHORT(){return ls}static get DATE_MED(){return lr}static get DATE_MED_WITH_WEEKDAY(){return wi}static get DATE_FULL(){return cr}static get DATE_HUGE(){return ur}static get TIME_SIMPLE(){return dr}static get TIME_WITH_SECONDS(){return mr}static get TIME_WITH_SHORT_OFFSET(){return fr}static get TIME_WITH_LONG_OFFSET(){return hr}static get TIME_24_SIMPLE(){return yr}static get TIME_24_WITH_SECONDS(){return pr}static get TIME_24_WITH_SHORT_OFFSET(){return gr}static get TIME_24_WITH_LONG_OFFSET(){return Sr}static get DATETIME_SHORT(){return xr}static get DATETIME_SHORT_WITH_SECONDS(){return vr}static get DATETIME_MED(){return wr}static get DATETIME_MED_WITH_SECONDS(){return Ar}static get DATETIME_MED_WITH_WEEKDAY(){return Ai}static get DATETIME_FULL(){return Tr}static get DATETIME_FULL_WITH_SECONDS(){return Nr}static get DATETIME_HUGE(){return br}static get DATETIME_HUGE_WITH_SECONDS(){return kr}}function Lt(t){if(P.isDateTime(t))return t;if(t&&t.valueOf&&ut(t.valueOf()))return P.fromJSDate(t);if(t&&typeof t=="object")return P.fromObject(t);throw new Te(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function gl(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function Sl(t,e){try{const s=P.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 xl(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 ms(t,e="UTC"){if(!t)return"-";const s=P.fromISO(t,{zone:"utc"}).setZone(e);if(!s.isValid)return"-";const n=s.offsetNameShort,r=s.toFormat("ZZZZ"),a=n.startsWith("GMT")||n===r?r:`${n}/${r}`;return`${s.toFormat("MM/dd/yyyy, hh:mm:ss a")} (${a})`}const vl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},wl={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function la({alerts:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,severityOptions:a,anomalyOptions:o,spaceOptions:l,onAlertIdClick:c,onAlertView:u,onFilterChange:m,onPageChange:h,onRefetch:x,resetKey:g,serverSideFilters:k}){const M=Ks(),j=async $=>{try{const S=await M.mutateAsync({alertUniqueId:$.alertId??$.id,alertId:$.id,status:"Reopen",notes:"Reopened",modifiedBy:0});if(S?.responseStatus||S?.Success){const E=S?.Message||S?.data||"Alert reopened successfully.";ve.toast.success(E)}else{const E=S?.errorMessage||S?.Message||"Failed to reopen alert";ve.toast.error(E)}}catch{ve.toast.error("Failed to reopen alert. Please try again.")}},Y=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:$=>i.jsx(f.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${vl[$]}`,backgroundColor:wl[String($)]},children:$})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:$=>xl($)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:($,S)=>i.jsxs("div",{children:[i.jsx("a",{onClick:E=>{E.preventDefault(),c?.(S,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:S.alertNumber}),i.jsx("div",{className:"text-black/65",children:$})]})},{title:"Preview",key:"preview",width:100,align:"center",render:($,S)=>i.jsx(ir,{record:S})},{title:"",key:"menu",width:60,align:"right",render:($,S)=>i.jsx(f.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:E})=>{E==="reopen"&&j(S)}},children:i.jsx(f.Button,{type:"text",icon:i.jsx(ht.MoreOutlined,{})})})}],H=m&&k?t:(t||[]).filter($=>{const S=un($.statusType||"");return gi.some(E=>S.includes(un(E)))});return i.jsx(Js,{data:H,loading:e,pageSize:s,total:n,currentPage:r,columns:Y,severityOptions:a,anomalyOptions:o,spaceOptions:l,renderActions:void 0,onAlertIdClick:c,onAlertView:u,onFilterChange:m,onPageChange:h,onRefetch:x,resetKey:g,serverSideFilters:k,excludeCompleted:!1})}function Al({size:t=120,time:e,timeZone:s="America/New_York"}){const{hours:n,minutes:r,seconds:a}=d.useMemo(()=>{const h=new Intl.DateTimeFormat("en-US",{timeZone:s,hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(e);return{hours:parseInt(h.find(x=>x.type==="hour")?.value||"0",10),minutes:parseInt(h.find(x=>x.type==="minute")?.value||"0",10),seconds:parseInt(h.find(x=>x.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((m,h)=>{const x=h*30,g=6,k=u-4,M=k-g,j=(x-90)*(Math.PI/180),Y=u+M*Math.cos(j),H=u+M*Math.sin(j),$=u+k*Math.cos(j),S=u+k*Math.sin(j);return i.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:i.jsx("line",{x1:Y,y1:H,x2:$,y2:S,stroke:"#9CA3AF",strokeWidth:h%3===0?2:1,strokeLinecap:"round"})},h)}),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 ca({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(()=>gl(r,e),[r,e]),{abbr:l,offset:c}=d.useMemo(()=>Sl(r,e),[r,e]);return i.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[i.jsx(Al,{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:Tl}=f.Typography;function Nl({sortBy:t,onChange:e,showActions:s,onSave:n,onClear:r,saving:a}){return i.jsxs(f.Row,{gutter:[16,16],align:"middle",children:[i.jsx(f.Col,{xs:24,md:8,lg:5,children:i.jsxs(f.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[i.jsx(Tl,{className:"text-gray-600 whitespace-nowrap",children:"Sort By:"}),i.jsx(f.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(f.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?i.jsxs(f.Space,{className:"w-full",direction:"horizontal",size:8,children:[i.jsx(f.Button,{onClick:r,disabled:a,children:"Clear"}),i.jsx(f.Button,{type:"primary",onClick:n,loading:a,children:"Save"})]}):null})]})}const Gs=t=>i.jsxs(f.Tag,{children:[i.jsx(ht.PlusOutlined,{})," ",t.length," more"]}),{Text:tt}=f.Typography;function bl(t){const{selectedRule:e,setSelectedRule:s,ruleOptions:n,minsOptions:r,roleOptions:a,l1mins:o,setL1mins:l,l1role:c,setL1role:u,l2mins:m,setL2mins:h,l2role:x,setL2role:g,l3mins:k,setL3mins:M,l3role:j,setL3role:Y,actions:H,setActions:$,thirdPartyIds:S,setThirdPartyIds:E,humanLoop:V,setHumanLoop:C,isAutoExpire:q,setAutoExpire:y,onClear:w,onSave:D,saving:se,onActionTypesLoaded:de}=t,{rules:O,config:N}=je(),v=N.tenant==="schools",[I,T]=d.useState([]),[F,R]=d.useState([]),[G,J]=d.useState(!1);d.useEffect(()=>{let ie=!1;return(async()=>{try{J(!0);const oe=await O.getLookups();if(ie||!oe||!Array.isArray(oe.actionTypes))return;const xe=oe.actionTypes.map(ne=>({label:ne.name,value:String(ne.actionTypeId)}));T(xe),de&&de(oe.actionTypes);const le=Array.isArray(oe.thirdParties)?oe.thirdParties.map(ne=>({label:ne.thirdPartyName,value:ne.thirdPartyIds??ne.thirdPartyId})):[];R(le)}catch(oe){console.error("Error loading lookups",oe)}finally{ie||J(!1)}})(),()=>{ie=!0}},[]);const Q=typeof o=="number"||typeof c=="number",X=typeof m=="number"||typeof x=="number",re=typeof o=="number"||typeof c=="number"||typeof m=="number"||typeof x=="number"||typeof k=="number"||typeof j=="number"||Array.isArray(H)&&H.length>0||Array.isArray(S)&&S.length>0||!!V||!!q,ae=!!e&&re&&!se;return i.jsxs(f.Spin,{spinning:!!se||G,children:[i.jsxs(f.Row,{gutter:[16,16],align:"bottom",children:[i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(tt,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(f.Select,{placeholder:"Rules",value:e,onChange:s,options:n,className:"w-full"})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(tt,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),i.jsx(f.Col,{span:14,children:i.jsx(tt,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(f.Select,{className:"w-full",placeholder:"Mins",value:o,onChange:l,options:r})}),i.jsx(f.Col,{span:14,children:i.jsx(f.Select,{placeholder:"Escalate to",className:"w-full",value:c,onChange:u,options:a})})]})]})}),Q&&i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(tt,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),i.jsx(f.Col,{span:14,children:i.jsx(tt,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(f.Select,{className:"w-full",placeholder:"Mins",value:m,onChange:h,options:r})}),i.jsx(f.Col,{span:14,children:i.jsx(f.Select,{placeholder:"Escalate to",className:"w-full",value:x,onChange:g,options:a})})]})]})}),X&&i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(tt,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),i.jsx(f.Col,{span:14,children:i.jsx(tt,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(f.Select,{className:"w-full",placeholder:"Mins",value:k,onChange:M,options:r})}),i.jsx(f.Col,{span:14,children:i.jsx(f.Select,{placeholder:"Escalate to",className:"w-full",value:j,onChange:Y,options:a})})]})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(tt,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),i.jsx(f.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:H,onChange:$,options:I,maxTagCount:1,maxTagPlaceholder:Gs})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(tt,{className:"text-gray-700 font-medium block mb-1",children:"Notify"}),i.jsx(f.Select,{mode:"multiple",placeholder:"Notify",className:"w-full",value:S,onChange:E,options:F,maxCount:2,maxTagPlaceholder:Gs})]})})]}),i.jsxs(f.Row,{gutter:[16,16],align:"bottom",className:"mt-4 items-center",children:[i.jsx(f.Col,{xs:24,sm:12,md:8,lg:7,children:i.jsxs("div",{className:"flex items-center h-full gap-8",children:[!v&&i.jsx(f.Checkbox,{checked:V,onChange:ie=>C(ie.target.checked),className:"w-full",children:"Human-In-The-Loop"}),i.jsx(f.Checkbox,{checked:q,onChange:ie=>y(ie.target.checked),className:"w-full",children:"Auto-expire in 5 minutes"})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(f.Button,{onClick:w,children:"Clear"}),i.jsx(f.Button,{type:"primary",onClick:D,loading:!!se,disabled:!ae,children:"Save"})]})})]})]})}function kl({entries:t,userRoles:e,onEdit:s,loading:n}){const{config:r}=je(),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(f.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(f.Button,{type:"text",onClick:()=>s(u.id),children:i.jsx(ht.EditOutlined,{})})}]})}const{Title:Il,Text:Cs}=f.Typography;function ua({userRoles:t,rules:e,rawRules:s}){const{rules:n}=je(),[r,a]=d.useState(!1),[o,l]=d.useState(!1),[c,u]=d.useState(s),[m,h]=d.useState(),[x,g]=d.useState([]),k=d.useMemo(()=>t.map(S=>({label:S.userRoleName,value:S.userRoleId})),[t]),M=d.useMemo(()=>(e||[]).map(S=>({label:S.Name||"-",value:S.RuleId||S.Name||""})),[e]),j=d.useMemo(()=>(e||[]).map((S,E)=>({key:S.RuleId||S.Name||String(E),ruleName:S.Name||"-",ruleDesc:S.Description||""})),[e]);d.useEffect(()=>{let S=!1;return(async()=>{try{a(!0);const E=await n.getRules();S||u(Array.isArray(E)?E:[])}catch{!S&&Array.isArray(s)&&u(s)}finally{S||a(!1)}})(),()=>{S=!0}},[]),d.useEffect(()=>{!c&&Array.isArray(s)&&u(s)},[s]),d.useEffect(()=>{if(!m||!Array.isArray(c)){g([]);return}const S=c.find(V=>V?.ruleId===m||V?.RuleId===m||V?.ruleName===m),E=S?.userRoleIds??S?.UserRoleIds;g(Array.isArray(E)?E:[])},[m,c]);const Y=d.useMemo(()=>{if(!Array.isArray(c)||!c.length)return{};const S={};for(const E of j){const V=c.find(y=>y?.ruleId===E.key||y?.ruleName===E.key||y?.RuleId===E.key||y?.ruleName===E.ruleName||y?.Name===E.ruleName),C=V?.userRoleIds??V?.UserRoleIds,q=Array.isArray(C)?C:[];q.length&&(S[E.key]=q)}return S},[c,j]),H=()=>{h(void 0),g([])},$=async()=>{if(!m){ve.toast.info("Please select a rule");return}try{l(!0);const S=Array.isArray(c)?c.find(y=>y?.ruleId===m||y?.RuleId===m||y?.ruleName===m):void 0,E=typeof S?.recordId=="number"?S.recordId:S?.ruleId||S?.RuleId||void 0;if(!S||!E)throw new Error(`Unable to find rule identifier for rule ${m}`);const V=x.map(y=>{const w=t.find(D=>D.userRoleId===y);return{id:y,name:w?.userRoleName??String(y)}}),C={...S,ruleId:m,userRoleIds:x,userRoles:V},q=await n.updateRule(E,C);if(!q?.responseStatus&&!q?.Success&&!q?.success)ve.toast.error(q?.errorMessage||q?.Message||"Error saving Alert Assignment");else{ve.toast.success("Alert assignment saved"),h(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(S){console.error("Failed to save alert assignment",S),ve.toast.error(S instanceof Error?S.message:"Error saving Alert Assignment")}finally{l(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(Il,{level:4,className:"!mb-4",children:"Alert Assignment"}),i.jsx(f.Spin,{spinning:o||r,children:i.jsxs(f.Row,{gutter:[16,16],align:"bottom",className:"mb-6",children:[i.jsx(f.Col,{xs:24,sm:12,md:8,lg:6,children:i.jsxs("div",{children:[i.jsx(Cs,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(f.Select,{placeholder:"Rules",value:m,onChange:h,options:M,className:"w-full"})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:8,children:i.jsxs("div",{children:[i.jsx(Cs,{className:"text-gray-700 font-medium block mb-1",children:"Alert Notification To"}),i.jsx(f.Select,{mode:"multiple",placeholder:"Select roles",className:"w-full",value:x,onChange:g,options:k,maxTagCount:1,maxTagPlaceholder:Gs})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(f.Button,{onClick:H,disabled:o,children:"Cancel"}),i.jsx(f.Button,{type:"primary",onClick:$,loading:o,disabled:o||!m,children:"Save"})]})})]})}),i.jsx(f.Table,{rowKey:"key",dataSource:j,loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(S,E)=>`${E[0]}-${E[1]} of ${S} items`},columns:[{title:"Rule Name",dataIndex:"ruleName",key:"ruleName"},{title:"Description",dataIndex:"ruleDesc",key:"ruleDesc"},{title:"Alert Notification To",key:"assign",render:(S,E)=>{const V=Y[E.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(f.Tag,{children:q?.userRoleName??String(C)},C)})}):i.jsx(Cs,{type:"secondary",children:"—"})}}]})]})}const{Title:Gn}=f.Typography;function Rs(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 da({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r,onSave:a}){const{rules:o,alerts:l}=je(),[c,u]=d.useState("By Severity"),[m,h]=d.useState("By severity"),[x,g]=d.useState("By Severity"),[k,M]=d.useState(!1),[j,Y]=d.useState(!1),[H,$]=d.useState(!1),[S,E]=d.useState(null),[V,C]=d.useState("rules"),[q,y]=d.useState(),[w,D]=d.useState(),[se,de]=d.useState(),[O,N]=d.useState(),[v,I]=d.useState(),[T,F]=d.useState(),[R,G]=d.useState(),[J,Q]=d.useState(),[X,re]=d.useState([]),[ae,ie]=d.useState([]),[oe,xe]=d.useState(!1),[le,ne]=d.useState(!1),[be,De]=d.useState({}),[Ye,Ke]=d.useState({}),[Be,Dt]=d.useState(s||[]),[nt,gt]=d.useState([]),[me,_]=d.useState(!1),[we,fe]=d.useState(!1),[Se,Le]=d.useState(n||[]);d.useEffect(()=>{n&&n.length&&Le(n)},[n]),d.useEffect(()=>{if(!Se||!Se.length)return;const U=Object.keys(be).length>0||Object.keys(Ye).length>0;if(nt.length&&!U)return;const B=Se.map((z,Z)=>{const p=e.find(Ie=>Ie.RuleId===(z.ruleId||z.ruleName))?.Name||z.ruleName||z.Name||"-",A=Rs(z.escalationSettings),L=typeof A.level1UserRoleId=="number"&&A.level1UserRoleId>0?[A.level1UserRoleId]:[],pe=typeof A.level2UserRoleId=="number"&&A.level2UserRoleId>0?[A.level2UserRoleId]:[],ke=typeof A.level3UserRoleId=="number"&&A.level3UserRoleId>0?[A.level3UserRoleId]:[],Ze=(Array.isArray(A.escalationSettingsActionTypeIds)?A.escalationSettingsActionTypeIds:[]).map(Ie=>be[Ie]||String(Ie)),Je=(Array.isArray(A.thirdPartyId)?A.thirdPartyId:[]).map(Ie=>Ye[Ie]||String(Ie)),ws=typeof A.humanLoop=="boolean"?A.humanLoop:null,As=typeof A.isAutoExpire=="boolean"?A.isAutoExpire:null;return{id:String(z.ruleId||z.ruleName||Z),ruleOrSeverityLabel:p,l1:{minutes:A.level1PostAssistTime??void 0,roles:L},l2:{minutes:A.level2PostAssistTime??void 0,roles:pe},l3:{minutes:A.level3PostAssistTime??void 0,roles:ke},actions:Ze,notify:Je,humanLoop:ws,isAutoExpire:As}});gt(B)},[Se,e,be,Ye]);const rt=d.useMemo(()=>t.map(U=>({label:U.DisplayName,value:U.SeverityId})),[t]),_e=d.useMemo(()=>e.map(U=>({label:U.Name,value:U.RuleId})),[e]),Ae=d.useMemo(()=>Be.map(U=>({label:U.userRoleName,value:U.userRoleId})),[Be]),Ct=d.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(U=>({label:`${U}`,value:U})),[]);d.useEffect(()=>{let U=!1;async function B(){try{$(!0),E(null);const z=await l.getAdminSettings();if(!U&&z){const Z=Jn(z.sortBy);u(Z),g(Z),M(!1)}}catch(z){if(!U){const Z=z instanceof Error?z.message:"Failed to load admin settings";E(Z)}}finally{U||$(!1)}}return B(),()=>{U=!0}},[]),d.useEffect(()=>{if(!w)return;const U=p=>{const A=Number(p);return!isNaN(A)&&A>0?A:void 0},B=p=>{const A=Number(p);return!isNaN(A)&&A>0?A:void 0},z=(Se||[]).find(p=>p?.ruleId===w||p?.ruleName===w||p?.RuleId===w),Z=Rs(z?.escalationSettings);if(Z&&typeof Z=="object"){de(B(Z.level1PostAssistTime)),N(U(Z.level1UserRoleId)),I(B(Z.level2PostAssistTime)),F(U(Z.level2UserRoleId)),G(B(Z.level3PostAssistTime)),Q(U(Z.level3UserRoleId));const p=Array.isArray(Z.escalationSettingsActionTypeIds)?Z.escalationSettingsActionTypeIds:[];re(p.map(A=>String(A))),ie(Array.isArray(Z.thirdPartyId)?Z.thirdPartyId:[]),xe(!!Z.humanLoop),ne(!!Z.isAutoExpire)}},[V,w,Se]);const Rt=async()=>{try{fe(!0);const U=await o.getRules(),B=Array.isArray(U)?U:Array.isArray(U?.data)?U.data:[];Le(B);const z=B.map((Z,p)=>{const A=e.find(Ie=>Ie.RuleId===(Z.ruleId||Z.ruleName))?.Name||Z.ruleName||Z.Name||"-",L=Rs(Z.escalationSettings??Z.EscalationSettings),pe=typeof L.level1UserRoleId=="number"&&L.level1UserRoleId>0?[L.level1UserRoleId]:[],ke=typeof L.level2UserRoleId=="number"&&L.level2UserRoleId>0?[L.level2UserRoleId]:[],ue=typeof L.level3UserRoleId=="number"&&L.level3UserRoleId>0?[L.level3UserRoleId]:[],Qe=(Array.isArray(L.escalationSettingsActionTypeIds)?L.escalationSettingsActionTypeIds:[]).map(Ie=>be[Ie]||String(Ie)),ws=(Array.isArray(L.thirdPartyId)?L.thirdPartyId:[]).map(Ie=>Ye[Ie]||String(Ie)),As=typeof L.humanLoop=="boolean"?L.humanLoop:null;return{id:String(Z.ruleId||Z.ruleName||p),ruleOrSeverityLabel:A,l1:{minutes:L.level1PostAssistTime??void 0,roles:pe},l2:{minutes:L.level2PostAssistTime??void 0,roles:ke},l3:{minutes:L.level3PostAssistTime??void 0,roles:ue},actions:Qe,notify:ws,humanLoop:As}});gt(z)}catch(U){console.error("Failed to refetch entries",U)}finally{fe(!1)}};d.useEffect(()=>{let U=!1;return(async()=>{try{const B=await o.getLookups();if(U||!B)return;const z={};if(Array.isArray(B.thirdParties))for(const p of B.thirdParties){const A=p.thirdPartyIds??p.thirdPartyId;typeof A=="number"&&(z[A]=p.thirdPartyName)}Ke(z);const Z=Array.isArray(B.userRoles)?B.userRoles.map(p=>({userRoleId:p.userRoleId??p.id,userRoleName:p.userRoleName??p.name})):[];U||Dt(Z.length?Z:s||[])}catch(B){console.error("Error loading lookups",B)}})(),()=>{U=!0}},[]);const St=async()=>{Y(!0);try{const U=await l.setAdminSettings({sortBy:c,groupBy:"string"});U?.responseStatus&&U?.data&&ve.toast.success(U.data),g(c),M(!1)}catch(U){console.error("Error saving admin settings",U)}finally{Y(!1)}},xt=()=>{u(x),M(!1)},at=async()=>{_(!0),a?.({ruleId:w,levels:[{minutes:se,role:O},{minutes:v,role:T},{minutes:R,role:J}],actions:X,thirdPartyIds:ae,humanLoop:oe,isAutoExpire:le});try{if(w){const B=Array.isArray(X)?X.map(L=>Number.isNaN(Number(L))?L:Number(L)):[],z=(Se||[]).find(L=>L?.ruleId===w||L?.ruleName===w||L?.RuleId===w),Z=typeof z?.recordId=="number"?z.recordId:z?.ruleId||z?.RuleId||void 0;if(!z||!Z){ve.toast.error("Unable to find rule identifier for update");return}const p={...z,escalationSettings:{level1UserRoleId:O??0,level1PostAssistTime:se??0,level2UserRoleId:T??0,level2PostAssistTime:v??0,level3UserRoleId:J??0,level3PostAssistTime:R??0,escalationSettingsActionTypeIds:B,thirdPartyId:Array.isArray(ae)?ae:[],humanLoop:oe,isAutoExpire:le}},A=await o.updateRule(Z,p);A?.responseStatus||A?.Success||A?.success?(ve.toast.success("Escalation settings saved"),await Rt(),D(void 0),de(void 0),N(void 0),I(void 0),F(void 0),G(void 0),Q(void 0),re([]),ie([]),xe(!1),ne(!1)):ve.toast.error(A?.errorMessage||A?.Message||"Error saving Escalation Settings")}}catch(B){console.error("Error saving escalation settings",B)}finally{_(!1)}},vt=()=>{u("By Severity"),h("By severity"),C("rules"),y(void 0),D(void 0),de(void 0),N(void 0),I(void 0),F(void 0),G(void 0),Q(void 0),re([]),ie([]),xe(!1),ne(!1)};return i.jsxs("div",{className:"w-full",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(Gn,{level:4,className:"!mb-2",children:"Admin Settings"}),i.jsxs(f.Spin,{spinning:H,children:[S?i.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",S]}):null,i.jsx(Nl,{sortBy:c,groupBy:m,onChange:U=>{U.sortBy&&(u(U.sortBy),M(!0)),U.groupBy&&(h(U.groupBy),M(!0))},showActions:k,onSave:St,onClear:xt,saving:j})]})]}),i.jsx(f.Divider,{className:"my-6"}),i.jsxs("div",{children:[i.jsx(Gn,{level:4,className:"!mb-4",children:"Escalation Settings"}),i.jsx(bl,{escBasis:V,setEscBasis:C,selectedSeverity:q,setSelectedSeverity:y,selectedRule:w,setSelectedRule:D,severityOptions:rt,ruleOptions:_e,minsOptions:Ct,roleOptions:Ae,l1mins:se,setL1mins:de,l1role:O,setL1role:N,l2mins:v,setL2mins:I,l2role:T,setL2role:F,l3mins:R,setL3mins:G,l3role:J,setL3role:Q,actions:X,setActions:re,thirdPartyIds:ae,setThirdPartyIds:ie,humanLoop:oe,setHumanLoop:xe,onClear:vt,onSave:at,saving:me,onActionTypesLoaded:U=>{const B={};for(const z of U)typeof z.actionTypeId=="number"&&(B[z.actionTypeId]=z.name);De(B)},isAutoExpire:le,setAutoExpire:ne})]}),i.jsx(f.Divider,{className:"my-6"}),i.jsx(kl,{entries:nt,userRoles:Be,loading:we||r,onEdit:U=>{C("rules");const B=nt.find(Z=>Z.id===U),z=e.find(Z=>Z.RuleId===U)||(B?e.find(Z=>Z.Name===B.ruleOrSeverityLabel):void 0);D(z?z.RuleId:U)}}),i.jsx(f.Divider,{className:"my-6"}),i.jsx(ua,{userRoles:Be,rules:e,rawRules:n}),i.jsx(f.Divider,{})]})}const{Title:Yn,Text:ns}=f.Typography;function El({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:a}=je(),o=[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],[l,c]=d.useState("By Severity"),[u,m]=d.useState(new Set),[h,x]=d.useState(null),[g,k]=d.useState(null),[M,j]=d.useState({inApp:!1,sms:!1,email:!1}),[Y,H]=d.useState([]),[$,S]=d.useState(!0),[E,V]=d.useState(!1);d.useEffect(()=>{let y=!1;return(async()=>{try{const w=await a.getPreferenceSettings();if(y||!w)return;j({inApp:!!w.inApp,sms:!!w.sms,email:!!w.email});const D=Jn(w.sortBy);c(D==="By Created Date"?"By Created Date":"By Severity"),x(hn(w.doNotDisturbStart)),k(hn(w.doNotDisturbEnd)),Array.isArray(w.anomalyIds)&&m(new Set(w.anomalyIds.map(se=>String(se))))}catch(w){console.error("Error in loading my preferences: ",w)}})(),()=>{y=!0}},[]),d.useEffect(()=>{let y=!1;return(async()=>{try{S(!0);const w=await r.getLookups();if(y||!w)return;const D=Array.isArray(w.anomalies)?w.anomalies:[];H(D)}catch(w){console.error("Failed to load anomalies lookups",w)}finally{y||S(!1)}})(),()=>{y=!0}},[]);const C=y=>{m(w=>{const D=new Set(w);return D.has(y)?D.delete(y):D.add(y),D})},q=async()=>{s?.({sortBy:l,subscribedRuleIds:Array.from(u),dnd:{from:h,to:g},channels:M});try{V(!0);const y=h?h.format?.("HH:mm:ss")??"00:00:00":"00:00:00",w=g?g.format?.("HH:mm:ss")??"00:00:00":"00:00:00",D=Array.from(u).map(de=>Number(de)).filter(de=>Number.isFinite(de)),se=await a.setPreferenceSettings({anomalyIds:D,doNotDisturbStart:y,doNotDisturbEnd:w,inApp:!!M.inApp,sms:!!M.sms,email:!!M.email,sortBy:l});se?.responseStatus&&ve.toast.success(se?.data||"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(f.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:i.jsx(f.Col,{xs:24,md:8,children:i.jsxs(f.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(ns,{className:"text-gray-600",children:"Sort By:"}),i.jsx(f.Select,{className:"w-[240px]",value:l,options:o,onChange:c})]})})}),i.jsxs("div",{className:"mb-4",children:[i.jsx(Yn,{level:5,className:"!mb-2",children:"Anomalies"}),$?i.jsx("div",{className:"py-4",children:i.jsx(f.Spin,{})}):i.jsx(f.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray(Y)?Y:[]).map(y=>{const w=String(y.recordId),D=y.anomalyName;return i.jsx(f.Checkbox,{checked:u.has(w),onChange:()=>C(w),children:D},w)})})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx(Yn,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),i.jsx(f.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:i.jsx(f.Col,{xs:24,md:12,children:i.jsxs(f.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(ns,{children:"Do Not Disturb mode:"}),i.jsxs(f.Space,{size:12,className:"w-full",children:[i.jsxs(f.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(ns,{children:"From"}),i.jsx(f.TimePicker,{value:h,onChange:y=>x(y),format:"HH:mm"})]}),i.jsxs(f.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(ns,{children:"To"}),i.jsx(f.TimePicker,{value:g,onChange:y=>k(y),format:"HH:mm"})]})]})]})})}),i.jsxs(f.Row,{gutter:[24,12],children:[i.jsx(f.Col,{children:i.jsx(f.Checkbox,{checked:M.inApp,onChange:y=>j({...M,inApp:y.target.checked}),children:"In-app"})}),i.jsx(f.Col,{children:i.jsx(f.Checkbox,{checked:M.sms,onChange:y=>j({...M,sms:y.target.checked}),children:"SMS"})}),i.jsx(f.Col,{children:i.jsx(f.Checkbox,{checked:M.email,onChange:y=>j({...M,email:y.target.checked}),children:"Email"})})]})]}),i.jsx(f.Divider,{}),i.jsxs(f.Space,{className:"gap-3",children:[i.jsx(f.Button,{onClick:n,disabled:E,children:"Cancel"}),i.jsx(f.Button,{type:"primary",onClick:q,loading:E,children:"Save"})]})]})}function ma({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r}){return i.jsx("div",{className:"w-full",children:i.jsx(da,{severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r})})}const Ml="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=",Ol="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 vs(){const{config:t}=je();return{timeZoneDetails:d.useMemo(()=>{const s=t.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone;return{timeZoneUniqueId:"",ianaTimeZoneId:s,timeZoneName:s,offset:""}},[t.timeZone]),loading:!1}}function jl(t){const e=(t.status||"").toLowerCase()==="completed"?i.jsx("img",{src:Ml,alt:"completed",style:{width:20,height:20}}):i.jsx("img",{src:Ol,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 Dl({data:t}){const{timeZoneDetails:e}=vs();return console.log("summary",t),i.jsx("div",{className:"w-full",children:i.jsx(f.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:i.jsxs("div",{className:"w-full",style:{maxHeight:"50vh",overflowY:"auto"},children:[i.jsx(f.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(f.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(f.Steps,{direction:"vertical",size:"small",current:1,items:(t.timeline||[]).map(jl)})})]})]})},{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(f.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("h4",{className:"text-sm text-black font-medium",children:s.channelLabel}),i.jsx("span",{className:"text-xs text-gray-500 mt-1",children:ms(s.sentAt,e?.ianaTimeZoneId)})]}),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 text-xs",children:[i.jsxs("div",{className:"text-black",children:[" ",s.messageTitle]}),s.messageBody?i.jsx("div",{className:"text-gray-600",children:s.messageBody}):null]}),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.jsxs("span",{className:"text-gray-500",children:[r.role," . ",r.phone]})]}),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 Cl=({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}=vs(),u=a?.length?a.map(h=>{const x=(h?.status||h?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",g=h?.createdDate?ms(h.createdDate,c?.ianaTimeZoneId):h?.timestamp?ms(h.timestamp,c?.ianaTimeZoneId):"";return{status:x,title:h?.status||h?.eventStatus||"Status Update",description:h?.description||h?.actionNotes||"",timestamp:g}}):[],m={summary:l,timeline:u,notifications:o??[]};return i.jsx(Dl,{data:m})},Rl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Ul={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Ll={"elopement attempt":"elopement","elopement completed":"elopement","watchlist person detected":"watchlist","watch list person detected":"watchlist","brandished guns & knives":"weapon","brandished guns and knives":"weapon"},Fl=({isModalOpen:t,handleModalClose:e,selectedRow:s,fetchAlertLogs:n,alertStatusList:r=[],alertStatusLoading:a=!1,initialTab:o="details",sourceTab:l,onAlertView:c})=>{const[u,m]=d.useState(),[h,x]=d.useState(""),[g,k]=d.useState(!1),M=d.useRef(null),[j,Y]=d.useState("details"),[H,$]=d.useState(void 0),S=Ks(),{alerts:E,rules:V,config:C}=je(),{timeZoneDetails:q}=vs(),[y,w]=d.useState(null),[D,se]=d.useState(!1),[de,O]=d.useState(!1),[N,v]=d.useState(void 0),[I,T]=d.useState(void 0),[F,R]=d.useState({}),[G,J]=d.useState({}),Q=(p,A,L)=>{const pe=G[p];return F[p]===!1&&!pe?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(nr,{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:[pe&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg z-10",children:i.jsx(di,{size:32,className:"animate-spin text-gray-400"})}),i.jsx("img",{src:p,alt:A.caption||`media-${L}`,className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg transition-opacity duration-200 ${pe?"opacity-0":"opacity-100"}`,onLoad:()=>J(ke=>({...ke,[p]:!1})),onError:()=>J(ke=>({...ke,[p]:!1}))},p)]})},X=s?.originalData||{},{eventName:re,eventDisplayName:ae,anomalyName:ie,alertId:oe,timestamp:xe,description:le,spaceName:ne,assignTeam:be,priority:De,statusType:Ye,id:Ke,alertDetails:Be,statusHistory:Dt,mediaDetails:nt,alertNumber:gt}=X,me=C.tenant==="snl"?ae||re||"Alert Event":re||"Alert Event",_=p=>{const A=String(p||"").toLowerCase();return A==="delivered"||A==="sent"?"Delivered":A==="failed"?"Failed":"Queued"},we=p=>({name:p?.receipientName||p?.recipientName||"-",role:p?.receipientRoleName||"",phone:p?.receipentPhoneNumber||p?.recipientPhoneNumber||p?.receipientEmail||p?.recipientEmail||"",status:_(p?.messageStatus),notificationReceipientType:p?.notificationReceipientType||""}),fe=(p,A)=>{const L=A.map(we),pe=L.filter(Qe=>Qe.status==="Delivered").length,ke=A.map(Qe=>Qe?.sentAt).filter(Boolean).sort((Qe,Je)=>new Date(Je).getTime()-new Date(Qe).getTime())[0],Ze=(A[0]||{})?.severityName||`${p} Notification`;return{channelLabel:`${p} Notification`,sentAt:ke||"",messageTitle:Ze,messageBody:"",total:L.length,delivered:pe,recipients:L}},Se=p=>{const A=new Map;return(p||[]).forEach(L=>{const pe=String(L?.notificationType||"Unknown"),ke=A.get(pe)||[];ke.push(L),A.set(pe,ke)}),Array.from(A.entries()).map(([L,pe])=>fe(L,pe))},Le=async p=>{try{const A=await E.getAlertNotifications(p),L=Se(A);$(L)}catch{$(void 0)}};d.useEffect(()=>{if(j!=="track"||!Ke)return;let p=!1;return Le(Ke).then(()=>{p&&$(void 0)}),()=>{p=!0}},[j,Ke]),d.useEffect(()=>{t?Y(o):(m(void 0),x(""))},[t,o]),d.useEffect(()=>{!t||!c||c([{personName:X.personName,faceId:X.faceId,mediaDetails:X.mediaDetails}])},[t]),d.useEffect(()=>{if(!t||C.tenant!=="snl")return;let p=!1;return se(!0),V.getLookups().then(A=>{p||(w(A.alertStatusTypes??[]),se(!1))}).catch(()=>{p||(w([]),se(!1))}),()=>{p=!0}},[t,C.tenant]);const _e=l==="archived"||["completed","false positive"].includes(String(Ye||"").toLowerCase()),Ae=p=>{const A=String(p?.value||"").toLowerCase(),L=String(p?.statusName||"").toLowerCase();return A.includes("reopen")||L.includes("reopen")},Ct=String(ie||"").trim().toLowerCase(),Rt=Ll[Ct]??"general",St=r.filter(p=>{const A=Ae(p);return typeof l<"u"?l==="archived"?A:!A:_e?A:!A}).map(p=>({value:p.value,label:p.statusName})),xt=y??[],at=p=>!!p.isWatchListStatus,vt=p=>!!p.isWeapontStatus,U=xt.filter(p=>{switch(Rt){case"elopement":return p.isElopementStatus;case"watchlist":return at(p);case"weapon":return vt(p);default:return!p.isElopementStatus&&!at(p)&&!vt(p)}}).map(p=>({value:p.alertStatusTypeName,label:p.alertStatusTypeName})),B=C.tenant==="snl"&&y!==null?U:St,z=d.useMemo(()=>tr(nt),[nt]);d.useEffect(()=>{let p=!1;const A=new AbortController,L=async ue=>{if(ue){p||R(Ze=>({...Ze,[ue]:!1}));try{const Ze=await fetch(ue,{method:"HEAD",signal:A.signal});if(Ze.ok){p||R(Je=>({...Je,[ue]:!0}));return}if(Ze.status===404){p||R(Je=>({...Je,[ue]:!1}));return}if(!(await fetch(ue,{method:"GET",signal:A.signal})).ok)throw new Error("Media not available");p||R(Je=>({...Je,[ue]:!0}))}catch{p||R(Ze=>({...Ze,[ue]:!1}))}}};R({});const pe=z.filter(ue=>!Us(ue)).map(ue=>ue?.mediaUrl||ue).filter(ue=>typeof ue=="string"&&ue.length>0),ke={};return pe.forEach(ue=>{ke[ue]=!0}),J(ke),pe.forEach(ue=>L(ue)),()=>{p=!0,A.abort()}},[z]);const Z=async()=>{try{k(!0);const p={alertUniqueId:oe,alertId:Ke,status:u?String(u):void 0,notes:h.trim(),modifiedBy:0},A=await S.mutateAsync(p);if(A?.responseStatus||A?.Success){const L=A?.Message||A?.data||"Alert updated successfully.";ve.toast.success(L,{autoClose:1500,onClose:()=>{n(),e()}}),m(void 0),x("")}else{const L=A?.errorMessage||A?.Message||"Failed to update alert status";ve.toast.error(L)}}catch(p){console.error("Error updating alert status:",p),ve.toast.error("Failed to update alert status. Please try again.")}finally{k(!1)}};return i.jsx(f.Modal,{open:t,onCancel:e,width:1e3,footer:j==="details"?i.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[i.jsx(f.Button,{onClick:e,className:"!bg-[#6C757D] !text-white !border-[#6C757D] hover:!bg-[#5c636a] hover:!text-white hover:!border-[#5c636a]",children:"Cancel"}),i.jsx(f.Button,{type:"primary",onClick:Z,loading:g,children:g?"Saving...":"Save Changes"})]}):null,children:s&&i.jsx(f.Tabs,{activeKey:j,onChange:p=>Y(p),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:me}),Be?.firstName?i.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",Be?.firstName," ",Be?.lastName||""," ",Be?.residentId||""]}):null,i.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp: ",ms(xe,q?.ianaTimeZoneId)]}),i.jsxs("div",{className:"font-sm text-gray-500",children:[i.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",le||"No description available"]}),ne&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",ne]}),be&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",be]}),i.jsxs("div",{className:"flex gap-2 justify-start mt-3",children:[i.jsxs(f.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${Rl[String(De)]||"#DFE4EA"}`,backgroundColor:Ul[String(De)]},children:["Severity: ",De||"N/A"]}),i.jsxs(f.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(Ye||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",Ye||"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(f.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:p=>m(p),value:u,options:B,loading:C.tenant==="snl"?D: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:h,onChange:p=>x(p.target.value)})]})]})})]}),i.jsx("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"}),z.length>1?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>M.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:()=>M.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]}),z.length?i.jsx("div",{className:"w-full",children:i.jsx(f.Carousel,{ref:M,dots:!0,className:"w-full",children:z.map((p,A)=>{const L=p.mediaUrl||p,pe=Us(p);return i.jsxs("div",{className:"flex justify-center items-center relative",children:[pe?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:L}),"Your browser does not support the video tag."]}):Q(String(L),p,A),p.caption&&i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:p.caption}),!pe&&F[String(L)]?i.jsx("button",{onClick:()=>{O(!0),v(L),T(p.type||"image")},className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:i.jsx(rr,{size:20})}):null]},String(L)||A)})})}):null]})}),i.jsx(ar,{isOpen:de,onClose:()=>O(!1),src:N||"",type:I||"image"})]})},{key:"track",label:"Track Incident",children:i.jsx(Cl,{alertId:oe,id:Ke,priority:De,spaceName:ne,alertNumber:gt,statusHistory:Dt,notifGroups:H})}]})})};function fa(){const{alerts:t}=je(),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 on({alerts:t,loading:e=!1,columns:s,total:n,currentPage:r,onRefetch:a,onPageChange:o,onFilterChange:l,onAlertView:c}){const[u,m]=d.useState(!1),[h,x]=d.useState(null),[g,k]=d.useState("details"),{list:M,loading:j}=fa(),Y=!0,{timeZoneDetails:H}=vs(),$=H?.timeZoneName??"UTC",S=H?.ianaTimeZoneId??"UTC";function E(se,de){x(se),k(de?.tab??"details"),q(de?.sourceTab??"active"),m(!0)}function V(){m(!1)}const[C,q]=d.useState("active"),[y,w]=d.useState(0),D=h?{originalData:{...h,alertId:h.alertId??h.id,mediaDetails:h.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(ca,{label:$,timeZone:S})})]}),i.jsx(f.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:se=>{const de=se==="archived";w(O=>O+1),o?.(1),l?.({isArchived:de})},items:[{key:"active",label:"Active",children:i.jsx(Js,{data:t,loading:e,pageSize:10,total:n,currentPage:r,columns:s||[],onAlertIdClick:E,onAlertView:c,onRefetch:a,onPageChange:o,onFilterChange:l,resetKey:y,serverSideFilters:Y})},{key:"archived",label:"Archived",children:i.jsx(la,{alerts:t,loading:e,columns:s||[],total:n,currentPage:r,onAlertIdClick:E,onAlertView:c,onFilterChange:l,onPageChange:o,onRefetch:a,resetKey:y,serverSideFilters:Y})},{key:"settings",label:"Settings",children:i.jsx($l,{})}]}),i.jsx(Fl,{isModalOpen:u,handleModalClose:V,selectedRow:D,fetchAlertLogs:()=>{},alertStatusList:M,alertStatusLoading:j,initialTab:g,sourceTab:C,onAlertView:c})]})}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:m}=je();return d.useEffect(()=>{let h=!0;return(async()=>{try{const x=await m.getRules();if(!h)return;l(Array.isArray(x)?x:[]);const g=(x||[]).map((k,M)=>({RuleId:k.ruleId||k.ruleName||String(M),Name:k.ruleName||k.Name||"-",Description:k.ruleDesc||k.Description||"",SeverityId:0}));e(g);try{const k=await m.getLookups(),M=Array.isArray(k?.userRoles)?k.userRoles.map(j=>({userRoleId:j.userRoleId??j.id,userRoleName:j.userRoleName??j.name})):[];n(M),a(Array.isArray(k?.severities)?k.severities:[])}catch{}}catch{}finally{h&&u(!1)}})(),()=>{h=!1}},[]),i.jsx(ma,{severities:r,rules:t,userRoles:s,rawRules:o,loadingRules:c})}function Pl(t){return Array.isArray(t)?{items:t}:t}function ha(t=1,e){const{alerts:s,config:n}=je(),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(Pl)},staleTime:r?0:3e4});return{alerts:a.data?.items??[],total:a.data?.total,loading:a.isLoading,error:a.error,refetch:a.refetch}}function Wl(t){const[e,s]=d.useState(1),[n,r]=d.useState({}),{alerts:a,total:o,loading:l,refetch:c}=ha(e,n);d.useEffect(()=>{!l&&a.length>0&&t.onAlertView?.(a)},[a,l]);const u=m=>{"isArchived"in m?r({isArchived:m.isArchived}):r(h=>({...h,...m}))};return i.jsx(on,{alerts:a,loading:l,columns:t.columns,total:o,currentPage:e,onRefetch:c,onPageChange:s,onFilterChange:u,onAlertView:t.onAlertView})}function Vl({tenant:t,apiDomain:e,rulesDomain:s,headers:n,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,alerts:l,loading:c,columns:u,onAlertView:m}){const[h]=d.useState(()=>new yt.QueryClient({defaultOptions:{queries:{retry:(g,k)=>{const M=k.response?.status??k?.status;return M>=400&&M<=500?!1:g<2},refetchOnWindowFocus:!1}}})),x=d.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return i.jsx(yt.QueryClientProvider,{client:h,children:i.jsx(Xn,{tenant:t,override:x,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,children:Array.isArray(l)?i.jsx(on,{alerts:l,loading:!!c,columns:u,onAlertView:m}):i.jsx(Wl,{columns:u,onAlertView:m})})})}function Bl(t){const{alerts:e}=je(),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 Zl=[{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=ua;exports.AlertConsole=on;exports.AlertConsoleWidget=Vl;exports.AlertsTable=Js;exports.ApiProvider=Xn;exports.ArchivedTable=la;exports.Clock=ca;exports.DataTable=er;exports.MyPreferencesPanel=El;exports.SettingsPanel=da;exports.SettingsTabs=ma;exports.exampleAlertColumns=Zl;exports.useAlertStatusList=fa;exports.useAlerts=ha;exports.useAlertsReport=Bl;exports.useApi=je;exports.useUpdateAlertStatus=Ks;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|