@ssgc/alert-console 2.6.1 → 2.6.3

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 CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),f=require("react"),d=require("antd"),it=require("@ant-design/icons"),Te=require("react-toastify"),ot=require("@tanstack/react-query"),ca="#FF3B30",ua="#FF9500",da="#FFCC00",ma="#34C759",Lt={critical:ca,high:ua,medium:da,low:ma},Ks={Critical:Lt.critical,High:Lt.high,Medium:Lt.medium,Low:Lt.low};function fa(t){return Ks[t]||Ks.Low}function Xs(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),i=Number.parseInt(n,10),l=Number.parseFloat(r||"0"),c=Number.isFinite(a)?a:0,u=Number.isFinite(i)?i:0,h=Number.isFinite(l)?l:0;return c*3600+u*60+h}function en(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(i=>parseInt(String(i).trim(),10)).filter(i=>Number.isFinite(i)),r=new Set,a=[];return n.forEach(i=>{r.has(i)||(r.add(i),a.push(i))}),a}const Bn="",ha=Bn,ya="",ga="",pa="",Sa="",tn={snl:{alerts:Bn,rules:ha},schools:{alerts:ya,rules:ga},transit:{alerts:pa,rules:Sa}};function Ie(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function xa(){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 Me(t,e){const s={...e.headers,...xa()},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 i=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(i)}return a}function wa(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=Ie(t.baseUrl,"/api/Alert"),n=await Me(s,{method:"GET",headers:e});return Array.isArray(n)?n:[]},async getAlertStatusList(){const s=Ie(t.baseUrl,"/api/Alert/AlertStatusList"),n=await Me(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=Ie(t.baseUrl,"/Alerts/GetAlertsReport"),r=Ut(n,s),a=await Me(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Ie(t.baseUrl,"/api/Alert/status");return Me(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=Ie(t.baseUrl,"/api/Alert/GetAdminSettings"),n=await Me(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=Ie(t.baseUrl,"/api/Alert/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Me(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Ie(t.baseUrl,"/api/Alert/GetPreferenceSettings"),n=await Me(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=Ie(t.baseUrl,"/api/Alert/SetPreferenceSettings"),r=await Me(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,i=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":r?.errorMessage??r?.message??"",statusCode:200,data:i}},async getAlertNotifications(s){const n=Ie(t.baseUrl,"/api/Alert/GetNotifications"),r=Ut(n,{alertId:s}),a=await Me(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=Ie(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=Ut(n,{alertId:s});return Me(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const a=Ie(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),i=Ut(a,{alertId:s,isEmail:n,isSMS:r});return Me(i,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Ie(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Me(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Ie(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Me(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 sn(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function va(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Ft(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 i=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(i)}return a}function Ta(t){const e={"Content-Type":"application/json",...t.headers||{}},s=sn(t.baseUrl,"/api/Rules"),n=sn(t.baseUrl,"/api/Rules/lookups");return{async getRules(){const r=await Ft(s,{method:"GET",headers:e});return Array.isArray(r)?r:[]},async setEscalationSettings(r){return Ft(s,{method:"POST",headers:e,body:JSON.stringify(r??{})})},async getLookups(){return Ft(n,{method:"GET",headers:e})},async updateRule(r,a){const i=`${s}/${r}`;return Ft(i,{method:"PUT",headers:e,body:JSON.stringify(a??{})})}}}function Aa(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var qt={exports:{}},Na=qt.exports,nn;function ba(){return nn||(nn=1,(function(t,e){(function(s,n){t.exports=n()})(Na,(function(){var s=1e3,n=6e4,r=36e5,a="millisecond",i="second",l="minute",c="hour",u="day",h="week",m="month",g="quarter",y="year",A="date",x="Invalid Date",p=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,B=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,F={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(C){var v=["th","st","nd","rd"],S=C%100;return"["+C+(v[(S-20)%10]||v[S]||v[0])+"]"}},Z=function(C,v,S){var I=String(C);return!I||I.length>=v?C:""+Array(v+1-I.length).join(S)+C},J={s:Z,z:function(C){var v=-C.utcOffset(),S=Math.abs(v),I=Math.floor(S/60),T=S%60;return(v<=0?"+":"-")+Z(I,2,"0")+":"+Z(T,2,"0")},m:function C(v,S){if(v.date()<S.date())return-C(S,v);var I=12*(S.year()-v.year())+(S.month()-v.month()),T=v.clone().add(I,m),D=S-T<0,N=v.clone().add(I+(D?-1:1),m);return+(-(I+(S-T)/(D?T-N:N-T))||0)},a:function(C){return C<0?Math.ceil(C)||0:Math.floor(C)},p:function(C){return{M:m,y,w:h,d:u,D:A,h:c,m:l,s:i,ms:a,Q:g}[C]||String(C||"").toLowerCase().replace(/s$/,"")},u:function(C){return C===void 0}},K="en",G={};G[K]=F;var j="$isDayjsObject",se=function(C){return C instanceof he||!(!C||!C[j])},w=function C(v,S,I){var T;if(!v)return K;if(typeof v=="string"){var D=v.toLowerCase();G[D]&&(T=D),S&&(G[D]=S,T=D);var N=v.split("-");if(!T&&N.length>1)return C(N[0])}else{var M=v.name;G[M]=v,T=M}return!I&&T&&(K=T),T||!I&&K},k=function(C,v){if(se(C))return C.clone();var S=typeof v=="object"?v:{};return S.date=C,S.args=arguments,new he(S)},O=J;O.l=w,O.i=se,O.w=function(C,v){return k(C,{locale:v.$L,utc:v.$u,x:v.$x,$offset:v.$offset})};var he=(function(){function C(S){this.$L=w(S.locale,null,!0),this.parse(S),this.$x=this.$x||S.x||{},this[j]=!0}var v=C.prototype;return v.parse=function(S){this.$d=(function(I){var T=I.date,D=I.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 N=T.match(p);if(N){var M=N[2]-1||0,$=(N[7]||"0").substring(0,3);return D?new Date(Date.UTC(N[1],M,N[3]||1,N[4]||0,N[5]||0,N[6]||0,$)):new Date(N[1],M,N[3]||1,N[4]||0,N[5]||0,N[6]||0,$)}}return new Date(T)})(S),this.init()},v.init=function(){var S=this.$d;this.$y=S.getFullYear(),this.$M=S.getMonth(),this.$D=S.getDate(),this.$W=S.getDay(),this.$H=S.getHours(),this.$m=S.getMinutes(),this.$s=S.getSeconds(),this.$ms=S.getMilliseconds()},v.$utils=function(){return O},v.isValid=function(){return this.$d.toString()!==x},v.isSame=function(S,I){var T=k(S);return this.startOf(I)<=T&&T<=this.endOf(I)},v.isAfter=function(S,I){return k(S)<this.startOf(I)},v.isBefore=function(S,I){return this.endOf(I)<k(S)},v.$g=function(S,I,T){return O.u(S)?this[I]:this.set(T,S)},v.unix=function(){return Math.floor(this.valueOf()/1e3)},v.valueOf=function(){return this.$d.getTime()},v.startOf=function(S,I){var T=this,D=!!O.u(I)||I,N=O.p(S),M=function(ce,ue){var xe=O.w(T.$u?Date.UTC(T.$y,ue,ce):new Date(T.$y,ue,ce),T);return D?xe:xe.endOf(u)},$=function(ce,ue){return O.w(T.toDate()[ce].apply(T.toDate("s"),(D?[0,0,0,0]:[23,59,59,999]).slice(ue)),T)},P=this.$W,W=this.$M,z=this.$D,Q="set"+(this.$u?"UTC":"");switch(N){case y:return D?M(1,0):M(31,11);case m:return D?M(1,W):M(0,W+1);case h:var le=this.$locale().weekStart||0,Se=(P<le?P+7:P)-le;return M(D?z-Se:z+(6-Se),W);case u:case A:return $(Q+"Hours",0);case c:return $(Q+"Minutes",1);case l:return $(Q+"Seconds",2);case i:return $(Q+"Milliseconds",3);default:return this.clone()}},v.endOf=function(S){return this.startOf(S,!1)},v.$set=function(S,I){var T,D=O.p(S),N="set"+(this.$u?"UTC":""),M=(T={},T[u]=N+"Date",T[A]=N+"Date",T[m]=N+"Month",T[y]=N+"FullYear",T[c]=N+"Hours",T[l]=N+"Minutes",T[i]=N+"Seconds",T[a]=N+"Milliseconds",T)[D],$=D===u?this.$D+(I-this.$W):I;if(D===m||D===y){var P=this.clone().set(A,1);P.$d[M]($),P.init(),this.$d=P.set(A,Math.min(this.$D,P.daysInMonth())).$d}else M&&this.$d[M]($);return this.init(),this},v.set=function(S,I){return this.clone().$set(S,I)},v.get=function(S){return this[O.p(S)]()},v.add=function(S,I){var T,D=this;S=Number(S);var N=O.p(I),M=function(W){var z=k(D);return O.w(z.date(z.date()+Math.round(W*S)),D)};if(N===m)return this.set(m,this.$M+S);if(N===y)return this.set(y,this.$y+S);if(N===u)return M(1);if(N===h)return M(7);var $=(T={},T[l]=n,T[c]=r,T[i]=s,T)[N]||1,P=this.$d.getTime()+S*$;return O.w(P,this)},v.subtract=function(S,I){return this.add(-1*S,I)},v.format=function(S){var I=this,T=this.$locale();if(!this.isValid())return T.invalidDate||x;var D=S||"YYYY-MM-DDTHH:mm:ssZ",N=O.z(this),M=this.$H,$=this.$m,P=this.$M,W=T.weekdays,z=T.months,Q=T.meridiem,le=function(ue,xe,Ae,Ce){return ue&&(ue[xe]||ue(I,D))||Ae[xe].slice(0,Ce)},Se=function(ue){return O.s(M%12||12,ue,"0")},ce=Q||function(ue,xe,Ae){var Ce=ue<12?"AM":"PM";return Ae?Ce.toLowerCase():Ce};return D.replace(B,(function(ue,xe){return xe||(function(Ae){switch(Ae){case"YY":return String(I.$y).slice(-2);case"YYYY":return O.s(I.$y,4,"0");case"M":return P+1;case"MM":return O.s(P+1,2,"0");case"MMM":return le(T.monthsShort,P,z,3);case"MMMM":return le(z,P);case"D":return I.$D;case"DD":return O.s(I.$D,2,"0");case"d":return String(I.$W);case"dd":return le(T.weekdaysMin,I.$W,W,2);case"ddd":return le(T.weekdaysShort,I.$W,W,3);case"dddd":return W[I.$W];case"H":return String(M);case"HH":return O.s(M,2,"0");case"h":return Se(1);case"hh":return Se(2);case"a":return ce(M,$,!0);case"A":return ce(M,$,!1);case"m":return String($);case"mm":return O.s($,2,"0");case"s":return String(I.$s);case"ss":return O.s(I.$s,2,"0");case"SSS":return O.s(I.$ms,3,"0");case"Z":return N}return null})(ue)||N.replace(":","")}))},v.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},v.diff=function(S,I,T){var D,N=this,M=O.p(I),$=k(S),P=($.utcOffset()-this.utcOffset())*n,W=this-$,z=function(){return O.m(N,$)};switch(M){case y:D=z()/12;break;case m:D=z();break;case g:D=z()/3;break;case h:D=(W-P)/6048e5;break;case u:D=(W-P)/864e5;break;case c:D=W/r;break;case l:D=W/n;break;case i:D=W/s;break;default:D=W}return T?D:O.a(D)},v.daysInMonth=function(){return this.endOf(m).$D},v.$locale=function(){return G[this.$L]},v.locale=function(S,I){if(!S)return this.$L;var T=this.clone(),D=w(S,I,!0);return D&&(T.$L=D),T},v.clone=function(){return O.w(this.$d,this)},v.toDate=function(){return new Date(this.valueOf())},v.toJSON=function(){return this.isValid()?this.toISOString():null},v.toISOString=function(){return this.$d.toISOString()},v.toString=function(){return this.$d.toUTCString()},C})(),oe=he.prototype;return k.prototype=oe,[["$ms",a],["$s",i],["$m",l],["$H",c],["$W",u],["$M",m],["$y",y],["$D",A]].forEach((function(C){oe[C[1]]=function(v){return this.$g(v,C[0],C[1])}})),k.extend=function(C,v){return C.$i||(C(v,he,k),C.$i=!0),k},k.locale=w,k.isDayjs=se,k.unix=function(C){return k(1e3*C)},k.en=G[K],k.Ls=G,k.p={},k}))})(qt)),qt.exports}var ka=ba();const Ia=Aa(ka);function Zn(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 zn(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 rn(t){const{hours:e,minutes:s,seconds:n}=zn(t);return Ia().hour(e).minute(s).second(n).millisecond(0)}function je(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ma(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function an(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 De(t,e){const s={...e.headers,...Ma()},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 i=a?.Message||`HTTP ${n.status}`;throw new Error(i)}return a}const de=(...t)=>t.find(e=>e!=null);function Nt(t,e,s={}){const n={};for(const r of e){const a=s[r]??r.charAt(0).toUpperCase()+r.slice(1);n[r]=t?.[a]??t?.[r]}return n}function Ea(t){return Array.isArray(t)?t.map(e=>Nt(e,["alertLogId","alertId","status","description","actionNotes","createdDate","createdBy","modifiedDate","modifiedBy"])):t}function Oa(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),spaceName:de(t?.SpaceName,t?.spaceName),assignTeam:de(t?.AssignTeam,t?.assignTeam),cameraName:de(t?.CameraName,t?.cameraName),type:de(t?.Type,t?.type),mediaDetails:de(t?.MediaDetails,t?.mediaDetails),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:Ea(de(t?.StatusHistory,t?.statusHistory)),isEmailSent:de(t?.IsEmailSent,t?.isEmailSent),isSMSSent:de(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:de(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function Ca(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=je(t.baseUrl,"/api/detectionpolicy/alerts?customerId=99e5c8b5-b9d4-4d35-8885-7f121c532664"),n=await De(s,{method:"GET",headers:e});return Array.isArray(n?.Items)?(n?.Items).map(Oa):[]},async getAlertStatusList(){const s=je(t.baseUrl,"/api/detectionpolicy/alerts/StatusList"),n=await De(s,{method:"GET",headers:e});return(Array.isArray(n)?n:[]).map(a=>Nt(a,["alertStatusId","value","statusName"]))},async getAlertsReport(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),r=an(n,s),a=await De(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=je(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 De(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getAdminSettings(){const s=je(t.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),n=await De(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n.Data??n;if(r&&typeof r=="object")return Nt(r,["userId","isAdminSetting","sortBy"],{sortBy:"SortOption"})}return null},async setAdminSettings(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/SetAdminSettings"),r={Settings:{UserId:0,IsAdminSetting:!0,SortOption:s?.sortBy??"",GroupBy:s?.groupBy??null}};return De(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=je(t.baseUrl,"/api/detectionpolicy/alerts/GetPreferenceSettings"),n=await De(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=je(t.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),r=u=>{const{hours:h,minutes:m,seconds:g}=zn(u);return(h*3600+m*60+g)*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??""}},i=await De(n,{method:"POST",headers:e,body:JSON.stringify(a)}),l=i?.responseStatus??!0,c=i?.data??i?.message??"Preferences updated successfully.";return{responseStatus:l,errorMessage:l?"":i?.errorMessage??i?.Message??i?.message??"",statusCode:200,data:c}},async getAlertNotifications(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),r=an(n,{alertId:s}),a=await De(r,{method:"GET",headers:e});let i=[];return Array.isArray(a)?i=a:Array.isArray(a?.data)&&(i=a.data),i.map(l=>Nt(l,["alertNotificationSentId","alertId","notificationType","receipientName","receipentPhoneNumber","messageSID","messageStatus","receipientEmail","notificationReceipientType","sentAt"]))},async getTimeZoneMasters(){const s=je(t.baseUrl,"/api/TimeZoneMaster"),n=await De(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n.Data:[]).map(a=>Nt(a,["timeZoneUniqueId","ianaTimeZoneId","timeZoneName","offset"]))},async getMyAppPreferences(){const s=je(t.baseUrl,"/MyProfile"),n=await De(s,{method:"GET",headers:e}),r=n?.data?.userGuid??n?.Data?.userGuid??n?.userGuid;if(!r)return null;const a=je(t.baseUrl,`/api/GetMyAppPreferences/${r}`),i=await De(a,{method:"GET",headers:e});if(i&&typeof i=="object"){const l=i.data??i.Data??i,c=l?.timeZoneUniqueId??l?.TimeZoneUniqueId;if(c)return{timeZoneUniqueId:c}}return null}}}function ja(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function He(t,e){const s={...e.headers,...ja()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const i=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(i)}return a}function Da(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/api/detectionpolicy/rules",t.baseUrl).toString();return{async getRules(){const n=await He(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}))},async setEscalationSettings(n){return He(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=w=>new URL(w,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[He(n("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:e}),He(n("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:e}),He(n("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:e}),He(n("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:e}),He(n("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:e}),He(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[i,l,c,u,h,m]=await Promise.allSettled(a),g=w=>w.status==="fulfilled"&&Array.isArray(w.value)?w.value:[],y=g(i),A=g(l),x=g(c),p=g(u),B=g(h),F=m.status==="fulfilled"?m.value:null;let Z=[];Array.isArray(F)?Z=F:Array.isArray(F?.Data)?Z=F.Data:Array.isArray(F?.data)&&(Z=F.data);const J=y.map(w=>({actionTypeId:Number(w?.ActionTypeId),name:w?.DisplayName??w?.Name??""})),K=A.map(w=>({recordId:w?.AnomalyId,anomalyName:w?.DisplayName??w?.Name??""})),G=x.map(w=>({thirdPartyId:Number(w?.ThirdPartyId),thirdPartyName:w?.ThirdPartyName??w?.Name??""})),j=Z.map(w=>({userRoleId:w.UserRoleId??w.userRoleId??w.Id??w.id??0,userRoleName:w.UserRoleName??w.userRoleName??w.Name??w.name??""})),se={actionTypes:J,anomalies:K,thirdParties:G};return p.length&&(se.severities=p),B.length&&(se.scheduleTypes=B),j.length&&(se.userRoles=j),se},async updateRule(n,r){const a=`${s}/${n}`,{escalationSettings:i,...l}=r??{};return He(a,{method:"PUT",headers:e,body:JSON.stringify({...l,CustomerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",EscalationSettings:i??{}})})}}}function Ra(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Ke(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 i=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(i)}return a}function La(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/list-rule",t.baseUrl).toString();return{async getRules(){const n=await Ke(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 Ke(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=j=>new URL(j,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[Ke(n("/api/ActionTypeMaster/GetAll"),{method:"GET",headers:e}),Ke(n("/api/anomaly/anomaly-list"),{method:"POST",headers:e,body:JSON.stringify({RuleLevel:1})}),Ke(n("/api/Lookup/ThirdParties"),{method:"GET",headers:e}),Ke(n("/api/anomaly/severity-list"),{method:"GET",headers:e}),Ke(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[i,l,c,u,h]=await Promise.allSettled(a),m=j=>{if(j.status!=="fulfilled")return[];const se=j.value;return Array.isArray(se)?se:Array.isArray(se?.data)?se.data:[]},g=m(i),y=m(l),A=m(c),x=m(u),p=h.status==="fulfilled"?h.value:null,B=g.map(j=>({actionTypeId:j?.ActionTypeUniqueId,name:j?.Name??""})),F=y.map(j=>({recordId:j?.AnomalyId,anomalyName:j?.DisplayName??j?.Name??""})),Z=A.map(j=>({thirdPartyId:Number(j?.ThirdPartyId),thirdPartyName:j?.ThirdPartyName??j?.Name??""}));let J=[];Array.isArray(p)?J=p:Array.isArray(p?.Data)?J=p.Data:Array.isArray(p?.data)&&(J=p.data);const K=J.map(j=>({userRoleId:j.userRoleId??0,userRoleName:j.userRoleName??""})),G={actionTypes:B,anomalies:F,thirdParties:Z};return x.length&&(G.severities=x.map(j=>({SeverityId:j.SeverityId,DisplayName:j.SeverityName??j.DisplayName??""}))),K.length&&(G.userRoles=K),G},async updateRule(n,r){const a=new URL("/update-rule",t.baseUrl).toString(),{escalationSettings:i,ruleId:l,ruleName:c,ruleDesc:u,...h}=r??{},m=i??{},g=(m.escalationSettingsActionTypeIds??[]).filter(A=>A!=null&&!Number.isNaN(A)),y={Level1UserRoleId:m.level1UserRoleId??0,Level1PostAssistTime:m.level1PostAssistTime??0,Level2UserRoleId:m.level2UserRoleId??0,Level2PostAssistTime:m.level2PostAssistTime??0,Level3UserRoleId:m.level3UserRoleId??0,Level3PostAssistTime:m.level3PostAssistTime??0,EscalationSettingsActionTypeIds:g,ThirdPartyIds:m.thirdPartyId??[],HumanLoop:m.humanLoop??!1};return Ke(a,{method:"POST",headers:e,body:JSON.stringify({...h,RuleId:l??h.RuleId??n,RuleName:c??h.RuleName,RuleDesc:u??h.RuleDesc??null,ActionTypeUniqueIdList:g,EscalationSettings:y})})}}}function Re(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ua(){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 Le(t,e){const s={...e.headers,...Ua()},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 i=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(i)}return a}function Fa(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Re(t.baseUrl,"/api/Alerts"),r=$t(n,{pageSize:s?.pageSize??10,pageNumber:s?.pageNumber??1}),a=await Le(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async getAlertStatusList(){const s=Re(t.baseUrl,"/api/Alerts/GetAlertStatus"),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=Re(t.baseUrl,"/Alerts/GetAlertsReport"),r=$t(n,s),a=await Le(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Re(t.baseUrl,"/api/Alerts/UpdateAlertLog"),r={alertId:s.alertId,action:s.status,notes:s.notes};return Le(n,{method:"PUT",headers:e,body:JSON.stringify(r??{})})},async getAdminSettings(){const s=Re(t.baseUrl,"/api/Alerts/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=Re(t.baseUrl,"/api/Alerts/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=Re(t.baseUrl,"/api/Alerts/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=Re(t.baseUrl,"/api/Alerts/SetPreferenceSettings"),r=await Le(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,i=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":r?.errorMessage??r?.message??"",statusCode:200,data:i}},async getAlertNotifications(s){const n=Re(t.baseUrl,"/api/Alerts/GetNotifications"),r=$t(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 sendSMSorEmailNotifications(s,n,r){const a=Re(t.baseUrl,"/api/Alerts/SendSMSorEmailNotifications"),i=$t(a,{alertId:s,isEmail:n,isSMS:r});return Le(i,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Re(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=Re(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}}}const Hn=f.createContext(null);function qn({tenant:t="snl",override:e,timeZone:s,userManagementDomain:n,children:r}){const a=f.useMemo(()=>{const l=e?.alertsBaseUrl?.trim()||tn[t]?.alerts||"";let c=e?.rulesBaseUrl?.trim()||tn[t]?.rules||"";t==="snl"&&(c=l);const u=e?.headers;return{tenant:t,alertsBaseUrl:l,rulesBaseUrl:c,headers:u,timeZone:s,userManagementDomain:n}},[t,e?.alertsBaseUrl,e?.rulesBaseUrl,JSON.stringify(e?.headers||{}),s,n]),i=f.useMemo(()=>{const l={baseUrl:a.alertsBaseUrl,headers:a.headers},c={baseUrl:a.rulesBaseUrl,headers:a.headers},u={schools:()=>Ca(l),transit:()=>Fa(l),snl:()=>wa(l)},h={schools:()=>Da({...c,userManagementBaseUrl:a.userManagementDomain}),transit:()=>La({...c,userManagementBaseUrl:a.userManagementDomain}),snl:()=>Ta({baseUrl:a.alertsBaseUrl,headers:a.headers})};return{config:a,alerts:u[a.tenant](),rules:h[a.tenant]()}},[a]);return o.jsx(Hn.Provider,{value:i,children:r})}function Oe(){const t=f.useContext(Hn);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}const $a={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Pa={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Rs=6,Ls=7;function on(t,e,s){const n=t===Rs,r=t===Ls,a=e.isEmailSent??!1,i=e.isSMSSent??!1,l=n&&a||r&&i,c=n?"Send Email":r?"Send SMS":s,u=n&&a?"Email sent":r&&i?"SMS sent":c,h=n&&a?"Email sent":r&&i?"SMS sent":`Click to ${c}`;return{isDisabled:l,buttonText:u,tooltipTitle:h}}function Wa(t){const e=new Set;(t||[]).forEach(n=>{const r=n.anomalyName;typeof r=="string"&&r.trim().length>0&&e.add(r.trim())});const s=Array.from(e).map(n=>({label:n,value:n}));return[{label:"All Types",value:"All"},...s]}function Va(t){const e=new Set;(t||[]).forEach(n=>{const r=n.spaceName;typeof r=="string"&&r.trim().length>0&&e.add(r.trim())});const s=Array.from(e).map(n=>({label:n,value:n}));return[{label:"All",value:"All"},...s]}function ms(t,e){return`${t}-${e?"email":"sms"}`}function Pt(t){return t===Rs||t===Ls}function ts({value:t,onChange:e,options:s,className:n,dropdownWidth:r}){return o.jsx(d.Select,{className:n,options:s,value:t,onChange:e,dropdownMatchSelectWidth:r??260})}const Ba=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function Za({value:t,onChange:e,options:s}){return o.jsx(ts,{className:"w-[140px]",value:t,onChange:e,options:s||Ba})}const za=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function Ha({value:t,onChange:e,options:s}){return o.jsx(ts,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||za})}function qa({value:t,onChange:e,options:s}){return o.jsx(ts,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const Ga=[{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 Ya({value:t,onChange:e,options:s}){return o.jsx(ts,{className:"w-[130px]",value:t,onChange:e,options:s||Ga})}function Gn({columns:t,data:e,loading:s=!1,pageSize:n=10,rowKey:r="id",toolbar:a,tableProps:i,onPageChange:l}){return o.jsxs("div",{children:[a,o.jsx(d.Table,{rowKey:r,dataSource:e,columns:t,loading:s,pagination:{pageSize:n,showSizeChanger:!0,showTotal:c=>`Total: ${c}`,onChange:l},bordered:!0,...i})]})}function Us({data:t,loading:e=!1,pageSize:s=10,columns:n,severityOptions:r,spaceOptions:a,renderActions:i,onAlertIdClick:l,onRefetch:c,onPageChange:u,excludeCompleted:h=!0}){const[m,g]=f.useState("All"),[y,A]=f.useState("All"),[x,p]=f.useState("All"),[B,F]=f.useState("All"),[Z,J]=f.useState(""),[K,G]=f.useState([{label:"All",value:"All"}]),[j,se]=f.useState(new Set),{rules:w,alerts:k}=Oe(),O={6:{title:"Email",kind:"icon",icon:o.jsx(it.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:o.jsx(it.MessageOutlined,{})}},he=f.useMemo(()=>Wa(t),[t]),oe=f.useMemo(()=>Va(t),[t]);f.useEffect(()=>{let N=!0;return(async()=>{try{const M=await w.getLookups(),P=(Array.isArray(M.thirdParties)?M.thirdParties:[]).map(W=>({label:W.thirdPartyName,value:String(W.thirdPartyId)}));N&&G([{label:"All",value:"All"},...P])}catch(M){console.error("Error loading third party options",M)}})(),()=>{N=!1}},[w]);const C=f.useMemo(()=>(t||[]).some(N=>en(N).length>0),[t]),v=f.useMemo(()=>(t||[]).filter(N=>{const M=m==="All"||N.priority===m,$=`${N.id} ${N.description} ${N.statusType}`.toLowerCase(),P=!Z||$.includes(Z.toLowerCase()),W=y==="All"||(N.anomalyName||"").toLowerCase()===y.toLowerCase(),z=x==="All"||(N.spaceName||"").toLowerCase()===x.toLowerCase(),Q=!C||B==="All"||en(N).includes(Number(B)),le=!h||!["completed","false positive"].includes(String(N.statusType||"").toLowerCase());return M&&P&&W&&z&&Q&&le}),[t,m,Z,y,x,B,C,h]),S=he,I=a?.length?a:oe,T=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:N=>o.jsx(d.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Pa[N]}`,backgroundColor:$a[N]},children:N})},{title:"Tracker",key:"tracker",width:140,render:(N,M)=>o.jsx("a",{onClick:$=>{$.preventDefault(),l?.(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:(N,M)=>{if(i)return o.jsx(o.Fragment,{children:i(M)});const $=async(Ce,_e)=>{const vt=ms(M.id,Ce);se(ye=>new Set(ye).add(vt));try{const ye=await k.sendSMSorEmailNotifications?.(M.id,Ce,_e);ye?.responseStatus||ye?.Success||ye?.success?(Te.toast.success(ye?.message||ye.data||(Ce?"Email sent successfully":"SMS sent successfully")),c?.()):Te.toast.error(ye?.message||ye?.data||ye?.errorMessage||"Failed to send notification")}catch(ye){Te.toast.error(ye?.message||"Failed to send notification")}finally{se(ye=>{const ct=new Set(ye);return ct.delete(vt),ct})}},P=Rs,W=Ls,z=O[P],Q=O[W],le=on(P,M,z?.title),Se=on(W,M,Q?.title),ce=ms(M.id,!0),ue=ms(M.id,!1),xe=Pt(P)&&j.has(ce),Ae=Pt(W)&&j.has(ue);return o.jsxs(d.Space,{size:"middle",children:[o.jsx(d.Tooltip,{title:le.tooltipTitle,children:o.jsx(d.Button,{size:"small",disabled:le.isDisabled,loading:xe,onClick:Pt(P)?()=>$(!0,!1):void 0,icon:!xe&&z?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:le.buttonText})},String(P)),o.jsx(d.Tooltip,{title:Se.tooltipTitle,children:o.jsx(d.Button,{size:"small",disabled:Se.isDisabled,loading:Ae,onClick:Pt(W)?()=>$(!1,!0):void 0,icon:!Ae&&Q?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:Se.buttonText})},String(W))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(N,M)=>{const $=M?.timeElapsed,P=M?.timeRemaining,W=$?Xs($):0,z=P?Xs(P):0,Q=Math.round(W/(W+z)*100);return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-[70px]",children:"Elapsed:"}),o.jsx("span",{className:"font-medium",children:$??"-"})]}),o.jsx(d.Progress,{percent:Q,showInfo:!1,size:"small",strokeColor:fa(M.priority)}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-[70px]",children:"Remaining"}),o.jsx("span",{className:"font-medium",children:P??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(N,M)=>o.jsxs("div",{children:[o.jsx("a",{onClick:$=>{$.preventDefault(),l?.(M,{sourceTab:"active"})},className:"inline-block mb-1 text-blue-600",children:M.alertNumber}),o.jsx("div",{className:"text-black/65",children:N})]})}],D=n&&n.length?n:T;return o.jsx("div",{children:o.jsx(Gn,{rowKey:"id",data:v,columns:D,loading:e,pageSize:s,onPageChange:u,toolbar:o.jsxs(d.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[o.jsx(d.Col,{flex:"none",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{children:"Severity"}),o.jsx(Za,{value:m,onChange:g,options:r})]})}),o.jsx(d.Col,{flex:"none",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{children:"Anomaly type"}),o.jsx(Ha,{value:y,onChange:A,options:S})]})}),o.jsx(d.Col,{flex:"none",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{children:"Space"}),o.jsx(qa,{value:x,onChange:p,options:I})]})}),o.jsx(d.Col,{flex:"none",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{children:"Action Taken"}),o.jsx(Ya,{value:B,onChange:F,options:K})]})}),o.jsx(d.Col,{flex:"auto"}),o.jsx(d.Col,{flex:"none",children:o.jsx(d.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:J,onChange:N=>J(N.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}function Fs(){const{alerts:t}=Oe(),e=ot.useQueryClient();return ot.useMutation({mutationFn:s=>t.updateAlertStatus(s),onSuccess:()=>{e.invalidateQueries({queryKey:["alerts","list"]}),e.invalidateQueries({queryKey:["alerts","report"]})}})}class lt extends Error{}class _a extends lt{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class Ja extends lt{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class Qa extends lt{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class ft extends lt{}class Yn extends lt{constructor(e){super(`Invalid unit ${e}`)}}class we extends lt{}class Xe extends lt{constructor(){super("Zone is an abstract class")}}const b="numeric",Be="short",Ee="long",Jt={year:b,month:b,day:b},_n={year:b,month:Be,day:b},Ka={year:b,month:Be,day:b,weekday:Be},Jn={year:b,month:Ee,day:b},Qn={year:b,month:Ee,day:b,weekday:Ee},Kn={hour:b,minute:b},Xn={hour:b,minute:b,second:b},er={hour:b,minute:b,second:b,timeZoneName:Be},tr={hour:b,minute:b,second:b,timeZoneName:Ee},sr={hour:b,minute:b,hourCycle:"h23"},nr={hour:b,minute:b,second:b,hourCycle:"h23"},rr={hour:b,minute:b,second:b,hourCycle:"h23",timeZoneName:Be},ar={hour:b,minute:b,second:b,hourCycle:"h23",timeZoneName:Ee},ir={year:b,month:b,day:b,hour:b,minute:b},or={year:b,month:b,day:b,hour:b,minute:b,second:b},lr={year:b,month:Be,day:b,hour:b,minute:b},cr={year:b,month:Be,day:b,hour:b,minute:b,second:b},Xa={year:b,month:Be,day:b,weekday:Be,hour:b,minute:b},ur={year:b,month:Ee,day:b,hour:b,minute:b,timeZoneName:Be},dr={year:b,month:Ee,day:b,hour:b,minute:b,second:b,timeZoneName:Be},mr={year:b,month:Ee,day:b,weekday:Ee,hour:b,minute:b,timeZoneName:Ee},fr={year:b,month:Ee,day:b,weekday:Ee,hour:b,minute:b,second:b,timeZoneName:Ee};class Ot{get type(){throw new Xe}get name(){throw new Xe}get ianaName(){return this.name}get isUniversal(){throw new Xe}offsetName(e,s){throw new Xe}formatOffset(e,s){throw new Xe}offset(e){throw new Xe}equals(e){throw new Xe}get isValid(){throw new Xe}}let fs=null;class ss extends Ot{static get instance(){return fs===null&&(fs=new ss),fs}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Nr(e,s,n)}formatOffset(e,s){return Mt(this.offset(e),s)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}}const Ts=new Map;function ei(t){let e=Ts.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"}),Ts.set(t,e)),e}const ti={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function si(t,e){const s=t.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(s),[,r,a,i,l,c,u,h]=n;return[i,r,a,l,c,u,h]}function ni(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:a,value:i}=s[r],l=ti[a];a==="era"?n[l]=i:U(l)||(n[l]=parseInt(i,10))}return n}const hs=new Map;class Ye extends Ot{static create(e){let s=hs.get(e);return s===void 0&&hs.set(e,s=new Ye(e)),s}static resetCache(){hs.clear(),Ts.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=Ye.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Nr(e,s,n,this.name)}formatOffset(e,s){return Mt(this.offset(e),s)}offset(e){if(!this.valid)return NaN;const s=new Date(e);if(isNaN(s))return NaN;const n=ei(this.name);let[r,a,i,l,c,u,h]=n.formatToParts?ni(n,s):si(n,s);l==="BC"&&(r=-Math.abs(r)+1);const g=rs({year:r,month:a,day:i,hour:c===24?0:c,minute:u,second:h,millisecond:0});let y=+s;const A=y%1e3;return y-=A>=0?A:1e3+A,(g-y)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let ln={};function ri(t,e={}){const s=JSON.stringify([t,e]);let n=ln[s];return n||(n=new Intl.ListFormat(t,e),ln[s]=n),n}const As=new Map;function Ns(t,e={}){const s=JSON.stringify([t,e]);let n=As.get(s);return n===void 0&&(n=new Intl.DateTimeFormat(t,e),As.set(s,n)),n}const bs=new Map;function ai(t,e={}){const s=JSON.stringify([t,e]);let n=bs.get(s);return n===void 0&&(n=new Intl.NumberFormat(t,e),bs.set(s,n)),n}const ks=new Map;function ii(t,e={}){const{base:s,...n}=e,r=JSON.stringify([t,n]);let a=ks.get(r);return a===void 0&&(a=new Intl.RelativeTimeFormat(t,e),ks.set(r,a)),a}let bt=null;function oi(){return bt||(bt=new Intl.DateTimeFormat().resolvedOptions().locale,bt)}const Is=new Map;function hr(t){let e=Is.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),Is.set(t,e)),e}const Ms=new Map;function li(t){let e=Ms.get(t);if(!e){const s=new Intl.Locale(t);e="getWeekInfo"in s?s.getWeekInfo():s.weekInfo,"minimalDays"in e||(e={...yr,...e}),Ms.set(t,e)}return e}function ci(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=Ns(t).resolvedOptions(),r=t}catch{const c=t.substring(0,s);n=Ns(c).resolvedOptions(),r=c}const{numberingSystem:a,calendar:i}=n;return[r,a,i]}}function ui(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function di(t){const e=[];for(let s=1;s<=12;s++){const n=L.utc(2009,s,1);e.push(t(n))}return e}function mi(t){const e=[];for(let s=1;s<=7;s++){const n=L.utc(2016,11,13+s);e.push(t(n))}return e}function Wt(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")||hr(t.locale).numberingSystem==="latn"}class hi{constructor(e,s,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;const{padTo:r,floor:a,...i}=n;if(!s||Object.keys(i).length>0){const l={useGrouping:!1,...n};n.padTo>0&&(l.minimumIntegerDigits=n.padTo),this.inf=ai(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):Bs(e,3);return pe(s,this.padTo)}}}class yi{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 i=-1*(e.offset/60),l=i>=0?`Etc/GMT+${i}`:`Etc/GMT${i}`;e.offset!==0&&Ye.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=Ns(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 gi{constructor(e,s,n){this.opts={style:"long",...n},!s&&Tr()&&(this.rtf=ii(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):$i(s,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,s){return this.rtf?this.rtf.formatToParts(e,s):[]}}const yr={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 i=e||fe.defaultLocale,l=i||(a?"en-US":oi()),c=s||fe.defaultNumberingSystem,u=n||fe.defaultOutputCalendar,h=Os(r)||fe.defaultWeekSettings;return new te(l,c,u,h,i)}static resetCache(){bt=null,As.clear(),bs.clear(),ks.clear(),Is.clear(),Ms.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[i,l,c]=ci(e);this.locale=i,this.numberingSystem=s||l||null,this.outputCalendar=n||c||null,this.weekSettings=r,this.intl=ui(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:te.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,Os(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 Wt(this,e,Ir,()=>{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 i=n?l=>this.dtFormatter(l,r).format():l=>this.extract(l,r,"month");this.monthsCache[a][e]=di(i)}return this.monthsCache[a][e]})}weekdays(e,s=!1){return Wt(this,e,Or,()=>{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]=mi(a=>this.extract(a,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return Wt(this,void 0,()=>Cr,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[L.utc(2016,11,13,9),L.utc(2016,11,13,19)].map(s=>this.extract(s,e,"dayperiod"))}return this.meridiemCache})}eras(e){return Wt(this,e,jr,()=>{const s={era:e};return this.eraCache[e]||(this.eraCache[e]=[L.utc(-40,1,1),L.utc(2017,1,1)].map(n=>this.extract(n,s,"era"))),this.eraCache[e]})}extract(e,s,n){const r=this.dtFormatter(e,s),a=r.formatToParts(),i=a.find(l=>l.type.toLowerCase()===n);return i?i.value:null}numberFormatter(e={}){return new hi(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new yi(e,this.intl,s)}relFormatter(e={}){return new gi(this.intl,this.isEnglish(),e)}listFormatter(e={}){return ri(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||hr(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:Ar()?li(this.locale):yr}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 ys=null;class be extends Ot{static get utcInstance(){return ys===null&&(ys=new be(0)),ys}static instance(e){return e===0?be.utcInstance:new be(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new be(as(s[1],s[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Mt(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Mt(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,s){return Mt(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 pi extends Ot{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 tt(t,e){if(U(t)||t===null)return e;if(t instanceof Ot)return t;if(Ai(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?ss.instance:s==="utc"||s==="gmt"?be.utcInstance:be.parseSpecifier(s)||Ye.create(t)}else return st(t)?be.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new pi(t)}const $s={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},cn={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]},Si=$s.hanidec.replace(/[\[|\]]/g,"").split("");function xi(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($s.hanidec)!==-1)e+=Si.indexOf(t[s]);else for(const r in cn){const[a,i]=cn[r];n>=a&&n<=i&&(e+=n-a)}}return parseInt(e,10)}else return e}const Es=new Map;function wi(){Es.clear()}function Pe({numberingSystem:t},e=""){const s=t||"latn";let n=Es.get(s);n===void 0&&(n=new Map,Es.set(s,n));let r=n.get(e);return r===void 0&&(r=new RegExp(`${$s[s]}${e}`),n.set(e,r)),r}let un=()=>Date.now(),dn="system",mn=null,fn=null,hn=null,yn=60,gn,pn=null;class fe{static get now(){return un}static set now(e){un=e}static set defaultZone(e){dn=e}static get defaultZone(){return tt(dn,ss.instance)}static get defaultLocale(){return mn}static set defaultLocale(e){mn=e}static get defaultNumberingSystem(){return fn}static set defaultNumberingSystem(e){fn=e}static get defaultOutputCalendar(){return hn}static set defaultOutputCalendar(e){hn=e}static get defaultWeekSettings(){return pn}static set defaultWeekSettings(e){pn=Os(e)}static get twoDigitCutoffYear(){return yn}static set twoDigitCutoffYear(e){yn=e%100}static get throwOnInvalid(){return gn}static set throwOnInvalid(e){gn=e}static resetCaches(){te.resetCache(),Ye.resetCache(),L.resetCache(),wi()}}class Ve{constructor(e,s){this.reason=e,this.explanation=s}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const gr=[0,31,59,90,120,151,181,212,243,273,304,334],pr=[0,31,60,91,121,152,182,213,244,274,305,335];function Fe(t,e){return new Ve("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function Ps(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 Sr(t,e,s){return s+(Ct(t)?pr:gr)[e-1]}function xr(t,e){const s=Ct(t)?pr:gr,n=s.findIndex(a=>a<e),r=e-s[n];return{month:n+1,day:r}}function Ws(t,e){return(t-e+7)%7+1}function Qt(t,e=4,s=1){const{year:n,month:r,day:a}=t,i=Sr(n,r,a),l=Ws(Ps(n,r,a),s);let c=Math.floor((i-l+14-e)/7),u;return c<1?(u=n-1,c=Et(u,e,s)):c>Et(n,e,s)?(u=n+1,c=1):u=n,{weekYear:u,weekNumber:c,weekday:l,...is(t)}}function Sn(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:a}=t,i=Ws(Ps(n,1,e),s),l=ht(n);let c=r*7+a-i-7+e,u;c<1?(u=n-1,c+=ht(u)):c>l?(u=n+1,c-=ht(n)):u=n;const{month:h,day:m}=xr(u,c);return{year:u,month:h,day:m,...is(t)}}function gs(t){const{year:e,month:s,day:n}=t,r=Sr(e,s,n);return{year:e,ordinal:r,...is(t)}}function xn(t){const{year:e,ordinal:s}=t,{month:n,day:r}=xr(e,s);return{year:e,month:n,day:r,...is(t)}}function wn(t,e){if(!U(t.localWeekday)||!U(t.localWeekNumber)||!U(t.localWeekYear)){if(!U(t.weekday)||!U(t.weekNumber)||!U(t.weekYear))throw new ft("Cannot mix locale-based week fields with ISO-based week fields");return U(t.localWeekday)||(t.weekday=t.localWeekday),U(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),U(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 vi(t,e=4,s=1){const n=ns(t.weekYear),r=$e(t.weekNumber,1,Et(t.weekYear,e,s)),a=$e(t.weekday,1,7);return n?r?a?!1:Fe("weekday",t.weekday):Fe("week",t.weekNumber):Fe("weekYear",t.weekYear)}function Ti(t){const e=ns(t.year),s=$e(t.ordinal,1,ht(t.year));return e?s?!1:Fe("ordinal",t.ordinal):Fe("year",t.year)}function wr(t){const e=ns(t.year),s=$e(t.month,1,12),n=$e(t.day,1,Kt(t.year,t.month));return e?s?n?!1:Fe("day",t.day):Fe("month",t.month):Fe("year",t.year)}function vr(t){const{hour:e,minute:s,second:n,millisecond:r}=t,a=$e(e,0,23)||e===24&&s===0&&n===0&&r===0,i=$e(s,0,59),l=$e(n,0,59),c=$e(r,0,999);return a?i?l?c?!1:Fe("millisecond",r):Fe("second",n):Fe("minute",s):Fe("hour",e)}function U(t){return typeof t>"u"}function st(t){return typeof t=="number"}function ns(t){return typeof t=="number"&&t%1===0}function Ai(t){return typeof t=="string"}function Ni(t){return Object.prototype.toString.call(t)==="[object Date]"}function Tr(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function Ar(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function bi(t){return Array.isArray(t)?t:[t]}function vn(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 ki(t,e){return e.reduce((s,n)=>(s[n]=t[n],s),{})}function gt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Os(t){if(t==null)return null;if(typeof t!="object")throw new we("Week settings must be an object");if(!$e(t.firstDay,1,7)||!$e(t.minimalDays,1,7)||!Array.isArray(t.weekend)||t.weekend.some(e=>!$e(e,1,7)))throw new we("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function $e(t,e,s){return ns(t)&&t>=e&&t<=s}function Ii(t,e){return t-e*Math.floor(t/e)}function pe(t,e=2){const s=t<0;let n;return s?n="-"+(""+-t).padStart(e,"0"):n=(""+t).padStart(e,"0"),n}function et(t){if(!(U(t)||t===null||t===""))return parseInt(t,10)}function nt(t){if(!(U(t)||t===null||t===""))return parseFloat(t)}function Vs(t){if(!(U(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function Bs(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 Ct(t){return t%4===0&&(t%100!==0||t%400===0)}function ht(t){return Ct(t)?366:365}function Kt(t,e){const s=Ii(e-1,12)+1,n=t+(e-s)/12;return s===2?Ct(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][s-1]}function rs(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 Tn(t,e,s){return-Ws(Ps(t,1,e),s)+e-1}function Et(t,e=4,s=1){const n=Tn(t,e,s),r=Tn(t+1,e,s);return(ht(t)-n+r)/7}function Cs(t){return t>99?t:t>fe.twoDigitCutoffYear?1900+t:2e3+t}function Nr(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 i={timeZoneName:e,...a},l=new Intl.DateTimeFormat(s,i).formatToParts(r).find(c=>c.type.toLowerCase()==="timezonename");return l?l.value:null}function as(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 br(t){const e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new we(`Invalid unit value ${t}`);return e}function Xt(t,e){const s={};for(const n in t)if(gt(t,n)){const r=t[n];if(r==null)continue;s[e(n)]=br(r)}return s}function Mt(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}${pe(s,2)}:${pe(n,2)}`;case"narrow":return`${r}${s}${n>0?`:${n}`:""}`;case"techie":return`${r}${pe(s,2)}${pe(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function is(t){return ki(t,["hour","minute","second","millisecond"])}const Mi=["January","February","March","April","May","June","July","August","September","October","November","December"],kr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ei=["J","F","M","A","M","J","J","A","S","O","N","D"];function Ir(t){switch(t){case"narrow":return[...Ei];case"short":return[...kr];case"long":return[...Mi];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 Mr=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Er=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Oi=["M","T","W","T","F","S","S"];function Or(t){switch(t){case"narrow":return[...Oi];case"short":return[...Er];case"long":return[...Mr];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const Cr=["AM","PM"],Ci=["Before Christ","Anno Domini"],ji=["BC","AD"],Di=["B","A"];function jr(t){switch(t){case"narrow":return[...Di];case"short":return[...ji];case"long":return[...Ci];default:return null}}function Ri(t){return Cr[t.hour<12?0:1]}function Li(t,e){return Or(e)[t.weekday-1]}function Ui(t,e){return Ir(e)[t.month-1]}function Fi(t,e){return jr(e)[t.year<0?0:1]}function $i(t,e,s="always",n=!1){const r={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},a=["hours","minutes","seconds"].indexOf(t)===-1;if(s==="auto"&&a){const m=t==="days";switch(e){case 1:return m?"tomorrow":`next ${r[t][0]}`;case-1:return m?"yesterday":`last ${r[t][0]}`;case 0:return m?"today":`this ${r[t][0]}`}}const i=Object.is(e,-0)||e<0,l=Math.abs(e),c=l===1,u=r[t],h=n?c?u[1]:u[2]||u[1]:c?r[t][0]:t;return i?`${l} ${h} ago`:`in ${l} ${h}`}function An(t,e){let s="";for(const n of t)n.literal?s+=n.val:s+=e(n.val);return s}const Pi={D:Jt,DD:_n,DDD:Jn,DDDD:Qn,t:Kn,tt:Xn,ttt:er,tttt:tr,T:sr,TT:nr,TTT:rr,TTTT:ar,f:ir,ff:lr,fff:ur,ffff:mr,F:or,FF:cr,FFF:dr,FFFF:fr};class ve{static create(e,s={}){return new ve(e,s)}static parseFormat(e){let s=null,n="",r=!1;const a=[];for(let i=0;i<e.length;i++){const l=e.charAt(i);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 Pi[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 pe(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=(y,A)=>this.loc.extract(e,y,A),i=y=>e.isOffsetFixed&&e.offset===0&&y.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,y.format):"",l=()=>n?Ri(e):a({hour:"numeric",hourCycle:"h12"},"dayperiod"),c=(y,A)=>n?Ui(e,y):a(A?{month:y}:{month:y,day:"numeric"},"month"),u=(y,A)=>n?Li(e,y):a(A?{weekday:y}:{weekday:y,month:"long",day:"numeric"},"weekday"),h=y=>{const A=ve.macroTokenToFormatOpts(y);return A?this.formatWithSystemDefault(e,A):y},m=y=>n?Fi(e,y):a({era:y},"era"),g=y=>{switch(y){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 i({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return i({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return i({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return l();case"d":return r?a({day:"numeric"},"day"):this.num(e.day);case"dd":return r?a({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return u("short",!0);case"cccc":return u("long",!0);case"ccccc":return u("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return u("short",!1);case"EEEE":return u("long",!1);case"EEEEE":return u("narrow",!1);case"L":return r?a({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?a({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return c("short",!0);case"LLLL":return c("long",!0);case"LLLLL":return c("narrow",!0);case"M":return r?a({month:"numeric"},"month"):this.num(e.month);case"MM":return r?a({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return c("short",!1);case"MMMM":return c("long",!1);case"MMMMM":return c("narrow",!1);case"y":return r?a({year:"numeric"},"year"):this.num(e.year);case"yy":return r?a({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?a({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?a({year:"numeric"},"year"):this.num(e.year,6);case"G":return m("short");case"GG":return m("long");case"GGGGG":return m("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return h(y)}};return An(ve.parseFormat(s),g)}formatDurationFromString(e,s){const n=this.opts.signMode==="negativeLargestOnly"?-1:1,r=h=>{switch(h[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=(h,m)=>g=>{const y=r(g);if(y){const A=m.isNegativeDuration&&y!==m.largestUnit?n:1;let x;return this.opts.signMode==="negativeLargestOnly"&&y!==m.largestUnit?x="never":this.opts.signMode==="all"?x="always":x="auto",this.num(h.get(y)*A,g.length,x)}else return g},i=ve.parseFormat(s),l=i.reduce((h,{literal:m,val:g})=>m?h:h.concat(g),[]),c=e.shiftTo(...l.map(r).filter(h=>h)),u={isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]};return An(i,a(c,u))}}const Dr=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function pt(...t){const e=t.reduce((s,n)=>s+n.source,"");return RegExp(`^${e}$`)}function St(...t){return e=>t.reduce(([s,n,r],a)=>{const[i,l,c]=a(e,r);return[{...s,...i},l||n,c]},[{},null,1]).slice(0,2)}function xt(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 Rr(...t){return(e,s)=>{const n={};let r;for(r=0;r<t.length;r++)n[t[r]]=et(e[s+r]);return[n,null,s+r]}}const Lr=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,Wi=`(?:${Lr.source}?(?:\\[(${Dr.source})\\])?)?`,Zs=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Ur=RegExp(`${Zs.source}${Wi}`),zs=RegExp(`(?:[Tt]${Ur.source})?`),Vi=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,Bi=/(\d{4})-?W(\d\d)(?:-?(\d))?/,Zi=/(\d{4})-?(\d{3})/,zi=Rr("weekYear","weekNumber","weekDay"),Hi=Rr("year","ordinal"),qi=/(\d{4})-(\d\d)-(\d\d)/,Fr=RegExp(`${Zs.source} ?(?:${Lr.source}|(${Dr.source}))?`),Gi=RegExp(`(?: ${Fr.source})?`);function yt(t,e,s){const n=t[e];return U(n)?s:et(n)}function Yi(t,e){return[{year:yt(t,e),month:yt(t,e+1,1),day:yt(t,e+2,1)},null,e+3]}function wt(t,e){return[{hours:yt(t,e,0),minutes:yt(t,e+1,0),seconds:yt(t,e+2,0),milliseconds:Vs(t[e+3])},null,e+4]}function jt(t,e){const s=!t[e]&&!t[e+1],n=as(t[e+1],t[e+2]),r=s?null:be.instance(n);return[{},r,e+3]}function Dt(t,e){const s=t[e]?Ye.create(t[e]):null;return[{},s,e+1]}const _i=RegExp(`^T?${Zs.source}$`),Ji=/^-?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 Qi(t){const[e,s,n,r,a,i,l,c,u]=t,h=e[0]==="-",m=c&&c[0]==="-",g=(y,A=!1)=>y!==void 0&&(A||y&&h)?-y:y;return[{years:g(nt(s)),months:g(nt(n)),weeks:g(nt(r)),days:g(nt(a)),hours:g(nt(i)),minutes:g(nt(l)),seconds:g(nt(c),c==="-0"),milliseconds:g(Vs(u),m)}]}const Ki={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Hs(t,e,s,n,r,a,i){const l={year:e.length===2?Cs(et(e)):et(e),month:kr.indexOf(s)+1,day:et(n),hour:et(r),minute:et(a)};return i&&(l.second=et(i)),t&&(l.weekday=t.length>3?Mr.indexOf(t)+1:Er.indexOf(t)+1),l}const Xi=/^(?:(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 eo(t){const[,e,s,n,r,a,i,l,c,u,h,m]=t,g=Hs(e,r,n,s,a,i,l);let y;return c?y=Ki[c]:u?y=0:y=as(h,m),[g,new be(y)]}function to(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const so=/^(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$/,no=/^(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$/,ro=/^(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 Nn(t){const[,e,s,n,r,a,i,l]=t;return[Hs(e,r,n,s,a,i,l),be.utcInstance]}function ao(t){const[,e,s,n,r,a,i,l]=t;return[Hs(e,l,s,n,r,a,i),be.utcInstance]}const io=pt(Vi,zs),oo=pt(Bi,zs),lo=pt(Zi,zs),co=pt(Ur),$r=St(Yi,wt,jt,Dt),uo=St(zi,wt,jt,Dt),mo=St(Hi,wt,jt,Dt),fo=St(wt,jt,Dt);function ho(t){return xt(t,[io,$r],[oo,uo],[lo,mo],[co,fo])}function yo(t){return xt(to(t),[Xi,eo])}function go(t){return xt(t,[so,Nn],[no,Nn],[ro,ao])}function po(t){return xt(t,[Ji,Qi])}const So=St(wt);function xo(t){return xt(t,[_i,So])}const wo=pt(qi,Gi),vo=pt(Fr),To=St(wt,jt,Dt);function Ao(t){return xt(t,[wo,$r],[vo,To])}const bn="Invalid Duration",Pr={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}},No={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},...Pr},Ue=146097/400,ut=146097/4800,bo={years:{quarters:4,months:12,weeks:Ue/7,days:Ue,hours:Ue*24,minutes:Ue*24*60,seconds:Ue*24*60*60,milliseconds:Ue*24*60*60*1e3},quarters:{months:3,weeks:Ue/28,days:Ue/4,hours:Ue*24/4,minutes:Ue*24*60/4,seconds:Ue*24*60*60/4,milliseconds:Ue*24*60*60*1e3/4},months:{weeks:ut/7,days:ut,hours:ut*24,minutes:ut*24*60,seconds:ut*24*60*60,milliseconds:ut*24*60*60*1e3},...Pr},at=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],ko=at.slice(0).reverse();function qe(t,e,s=!1){const n={values:s?e.values:{...t.values,...e.values||{}},loc:t.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||t.conversionAccuracy,matrix:e.matrix||t.matrix};return new _(n)}function Wr(t,e){let s=e.milliseconds??0;for(const n of ko.slice(1))e[n]&&(s+=e[n]*t[n].milliseconds);return s}function kn(t,e){const s=Wr(t,e)<0?-1:1;at.reduceRight((n,r)=>{if(U(e[r]))return n;if(n){const a=e[n]*s,i=t[r][n],l=Math.floor(a/i);e[r]+=l*s,e[n]-=l*i*s}return r},null),at.reduce((n,r)=>{if(U(e[r]))return n;if(n){const a=e[n]%1;e[n]-=a,e[r]+=a*t[n][r]}return r},null)}function In(t){const e={};for(const[s,n]of Object.entries(t))n!==0&&(e[s]=n);return e}class _{constructor(e){const s=e.conversionAccuracy==="longterm"||!1;let n=s?bo:No;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 _.fromObject({milliseconds:e},s)}static fromObject(e,s={}){if(e==null||typeof e!="object")throw new we(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new _({values:Xt(e,_.normalizeUnit),loc:te.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(st(e))return _.fromMillis(e);if(_.isDuration(e))return e;if(typeof e=="object")return _.fromObject(e);throw new we(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,s){const[n]=po(e);return n?_.fromObject(n,s):_.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,s){const[n]=xo(e);return n?_.fromObject(n,s):_.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,s=null){if(!e)throw new we("need to specify a reason the Duration is invalid");const n=e instanceof Ve?e:new Ve(e,s);if(fe.throwOnInvalid)throw new Qa(n);return new _({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 Yn(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?ve.create(this.loc,n).formatDurationFromString(this,e):bn}toHuman(e={}){if(!this.isValid)return bn;const s=e.showZeros!==!1,n=at.map(r=>{const a=this.values[r];return U(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+=Bs(this.seconds+this.milliseconds/1e3,3)+"S"),e==="P"&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;const s=this.toMillis();return s<0||s>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e,includeOffset:!1},L.fromMillis(s,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?Wr(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const s=_.fromDurationLike(e),n={};for(const r of at)(gt(s.values,r)||gt(this.values,r))&&(n[r]=s.get(r)+this.get(r));return qe(this,{values:n},!0)}minus(e){if(!this.isValid)return this;const s=_.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]=br(e(this.values[n],n));return qe(this,{values:s},!0)}get(e){return this[_.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const s={...this.values,...Xt(e,_.normalizeUnit)};return qe(this,{values:s})}reconfigure({locale:e,numberingSystem:s,conversionAccuracy:n,matrix:r}={}){const i={loc:this.loc.clone({locale:e,numberingSystem:s}),matrix:r,conversionAccuracy:n};return qe(this,i)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return kn(this.matrix,e),qe(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=In(this.normalize().shiftToAll().toObject());return qe(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(i=>_.normalizeUnit(i));const s={},n={},r=this.toObject();let a;for(const i of at)if(e.indexOf(i)>=0){a=i;let l=0;for(const u in n)l+=this.matrix[u][i]*n[u],n[u]=0;st(r[i])&&(l+=r[i]);const c=Math.trunc(l);s[i]=c,n[i]=(l*1e3-c*1e3)/1e3}else st(r[i])&&(n[i]=r[i]);for(const i in n)n[i]!==0&&(s[a]+=i===a?n[i]:n[i]/this.matrix[a][i]);return kn(this.matrix,s),qe(this,{values:s},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const e={};for(const s of Object.keys(this.values))e[s]=this.values[s]===0?0:-this.values[s];return qe(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=In(this.values);return qe(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function s(n,r){return n===void 0||n===0?r===void 0||r===0:n===r}for(const n of at)if(!s(this.values[n],e.values[n]))return!1;return!0}}const dt="Invalid Interval";function Io(t,e){return!t||!t.isValid?me.invalid("missing or invalid start"):!e||!e.isValid?me.invalid("missing or invalid end"):e<t?me.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 me{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 we("need to specify a reason the Interval is invalid");const n=e instanceof Ve?e:new Ve(e,s);if(fe.throwOnInvalid)throw new Ja(n);return new me({invalid:n})}static fromDateTimes(e,s){const n=At(e),r=At(s),a=Io(n,r);return a??new me({start:n,end:r})}static after(e,s){const n=_.fromDurationLike(s),r=At(e);return me.fromDateTimes(r,r.plus(n))}static before(e,s){const n=_.fromDurationLike(s),r=At(e);return me.fromDateTimes(r.minus(n),r)}static fromISO(e,s){const[n,r]=(e||"").split("/",2);if(n&&r){let a,i;try{a=L.fromISO(n,s),i=a.isValid}catch{i=!1}let l,c;try{l=L.fromISO(r,s),c=l.isValid}catch{c=!1}if(i&&c)return me.fromDateTimes(a,l);if(i){const u=_.fromISO(r,s);if(u.isValid)return me.after(a,u)}else if(c){const u=_.fromISO(n,s);if(u.isValid)return me.before(l,u)}}return me.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?me.fromDateTimes(e||this.s,s||this.e):this}splitAt(...e){if(!this.isValid)return[];const s=e.map(At).filter(i=>this.contains(i)).sort((i,l)=>i.toMillis()-l.toMillis()),n=[];let{s:r}=this,a=0;for(;r<this.e;){const i=s[a]||this.e,l=+i>+this.e?this.e:i;n.push(me.fromDateTimes(r,l)),r=l,a+=1}return n}splitBy(e){const s=_.fromDurationLike(e);if(!this.isValid||!s.isValid||s.as("milliseconds")===0)return[];let{s:n}=this,r=1,a;const i=[];for(;n<this.e;){const l=this.start.plus(s.mapUnits(c=>c*r));a=+l>+this.e?this.e:l,i.push(me.fromDateTimes(n,a)),n=a,r+=1}return i}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:me.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 me.fromDateTimes(s,n)}static merge(e){const[s,n]=e.sort((r,a)=>r.s-a.s).reduce(([r,a],i)=>a?a.overlaps(i)||a.abutsStart(i)?[r,a.union(i)]:[r.concat([a]),i]:[r,i],[[],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"}]),i=Array.prototype.concat(...a),l=i.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(me.fromDateTimes(s,c.time)),s=null);return me.merge(r)}difference(...e){return me.xor([this].concat(e)).map(s=>this.intersection(s)).filter(s=>s&&!s.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:dt}[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=Jt,s={}){return this.isValid?ve.create(this.s.loc.clone(s),e).formatInterval(this):dt}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:dt}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:dt}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:dt}toFormat(e,{separator:s=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${s}${this.e.toFormat(e)}`:dt}toDuration(e,s){return this.isValid?this.e.diff(this.s,e,s):_.invalid(this.invalidReason)}mapEndpoints(e){return me.fromDateTimes(e(this.s),e(this.e))}}class Vt{static hasDST(e=fe.defaultZone){const s=L.now().setZone(e).set({month:12});return!e.isUniversal&&s.offset!==s.set({month:6}).offset}static isValidIANAZone(e){return Ye.isValidZone(e)}static normalizeZone(e){return tt(e,fe.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:Tr(),localeWeek:Ar()}}}function Mn(t,e){const s=r=>r.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),n=s(e)-s(t);return Math.floor(_.fromMillis(n).as("days"))}function Mo(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 h=Mn(c,u);return(h-h%7)/7}],["days",Mn]],r={},a=t;let i,l;for(const[c,u]of n)s.indexOf(c)>=0&&(i=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,i]}function Eo(t,e,s,n){let[r,a,i,l]=Mo(t,e,s);const c=e-r,u=s.filter(m=>["hours","minutes","seconds","milliseconds"].indexOf(m)>=0);u.length===0&&(i<e&&(i=r.plus({[l]:1})),i!==r&&(a[l]=(a[l]||0)+c/(i-r)));const h=_.fromObject(a,n);return u.length>0?_.fromMillis(c,n).shiftTo(...u).plus(h):h}const Oo="missing Intl.DateTimeFormat.formatToParts support";function ee(t,e=s=>s){return{regex:t,deser:([s])=>e(xi(s))}}const Co=" ",Vr=`[ ${Co}]`,Br=new RegExp(Vr,"g");function jo(t){return t.replace(/\./g,"\\.?").replace(Br,Vr)}function En(t){return t.replace(/\./g,"").replace(Br," ").toLowerCase()}function We(t,e){return t===null?null:{regex:RegExp(t.map(jo).join("|")),deser:([s])=>t.findIndex(n=>En(s)===En(n))+e}}function On(t,e){return{regex:t,deser:([,s,n])=>as(s,n),groups:e}}function Bt(t){return{regex:t,deser:([e])=>e}}function Do(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Ro(t,e){const s=Pe(e),n=Pe(e,"{2}"),r=Pe(e,"{3}"),a=Pe(e,"{4}"),i=Pe(e,"{6}"),l=Pe(e,"{1,2}"),c=Pe(e,"{1,3}"),u=Pe(e,"{1,6}"),h=Pe(e,"{1,9}"),m=Pe(e,"{2,4}"),g=Pe(e,"{4,6}"),y=p=>({regex:RegExp(Do(p.val)),deser:([B])=>B,literal:!0}),x=(p=>{if(t.literal)return y(p);switch(p.val){case"G":return We(e.eras("short"),0);case"GG":return We(e.eras("long"),0);case"y":return ee(u);case"yy":return ee(m,Cs);case"yyyy":return ee(a);case"yyyyy":return ee(g);case"yyyyyy":return ee(i);case"M":return ee(l);case"MM":return ee(n);case"MMM":return We(e.months("short",!0),1);case"MMMM":return We(e.months("long",!0),1);case"L":return ee(l);case"LL":return ee(n);case"LLL":return We(e.months("short",!1),1);case"LLLL":return We(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 Bt(h);case"uu":return Bt(l);case"uuu":return ee(s);case"a":return We(e.meridiems(),0);case"kkkk":return ee(a);case"kk":return ee(m,Cs);case"W":return ee(l);case"WW":return ee(n);case"E":case"c":return ee(s);case"EEE":return We(e.weekdays("short",!1),1);case"EEEE":return We(e.weekdays("long",!1),1);case"ccc":return We(e.weekdays("short",!0),1);case"cccc":return We(e.weekdays("long",!0),1);case"Z":case"ZZ":return On(new RegExp(`([+-]${l.source})(?::(${n.source}))?`),2);case"ZZZ":return On(new RegExp(`([+-]${l.source})(${n.source})?`),2);case"z":return Bt(/[a-z_+-/]{1,256}?/i);case" ":return Bt(/[^\S\n\r]/);default:return y(p)}})(t)||{invalidReason:Oo};return x.token=t,x}const Lo={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 Uo(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 i=n;n==="hour"&&(e.hour12!=null?i=e.hour12?"hour12":"hour24":e.hourCycle!=null?e.hourCycle==="h11"||e.hourCycle==="h12"?i="hour12":i="hour24":i=s.hour12?"hour12":"hour24");let l=Lo[i];if(typeof l=="object"&&(l=l[a]),l)return{literal:!1,val:l}}function Fo(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function $o(t,e,s){const n=t.match(e);if(n){const r={};let a=1;for(const i in s)if(gt(s,i)){const l=s[i],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 Po(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 U(t.z)||(s=Ye.create(t.z)),U(t.Z)||(s||(s=new be(t.Z)),n=t.Z),U(t.q)||(t.M=(t.q-1)*3+1),U(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),U(t.u)||(t.S=Vs(t.u)),[Object.keys(t).reduce((a,i)=>{const l=e(i);return l&&(a[l]=t[i]),a},{}),s,n]}let ps=null;function Wo(){return ps||(ps=L.fromMillis(1555555555555)),ps}function Vo(t,e){if(t.literal)return t;const s=ve.macroTokenToFormatOpts(t.val),n=qr(s,e);return n==null||n.includes(void 0)?t:n}function Zr(t,e){return Array.prototype.concat(...t.map(s=>Vo(s,e)))}class zr{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=Zr(ve.parseFormat(s),e),this.units=this.tokens.map(n=>Ro(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=Fo(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=$o(e,this.regex,this.handlers),[r,a,i]=n?Po(n):[null,null,void 0];if(gt(n,"a")&&gt(n,"H"))throw new ft("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:i}}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 Hr(t,e,s){return new zr(t,s).explainFromTokens(e)}function Bo(t,e,s){const{result:n,zone:r,specificOffset:a,invalidReason:i}=Hr(t,e,s);return[n,r,a,i]}function qr(t,e){if(!t)return null;const n=ve.create(e,t).dtFormatter(Wo()),r=n.formatToParts(),a=n.resolvedOptions();return r.map(i=>Uo(i,t,a))}const Ss="Invalid DateTime",Cn=864e13;function kt(t){return new Ve("unsupported zone",`the zone "${t.name}" is not supported`)}function xs(t){return t.weekData===null&&(t.weekData=Qt(t.c)),t.weekData}function ws(t){return t.localWeekData===null&&(t.localWeekData=Qt(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function rt(t,e){const s={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new L({...s,...e,old:s})}function Gr(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 Zt(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 Gt(t,e,s){return Gr(rs(t),e,s)}function jn(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,Kt(n,r))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},i=_.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=rs(a);let[c,u]=Gr(l,s,t.zone);return i!==0&&(c+=i,u=t.zone.offset(c)),{ts:c,o:u}}function mt(t,e,s,n,r,a){const{setZone:i,zone:l}=s;if(t&&Object.keys(t).length!==0||e){const c=e||l,u=L.fromObject(t,{...s,zone:c,specificOffset:a});return i?u:u.setZone(l)}else return L.invalid(new Ve("unparsable",`the input "${r}" can't be parsed as ${n}`))}function zt(t,e,s=!0){return t.isValid?ve.create(te.create("en-US"),{allowZ:s,forceSimple:!0}).formatDateTimeFromString(t,e):null}function vs(t,e,s){const n=t.c.year>9999||t.c.year<0;let r="";if(n&&t.c.year>=0&&(r+="+"),r+=pe(t.c.year,n?6:4),s==="year")return r;if(e){if(r+="-",r+=pe(t.c.month),s==="month")return r;r+="-"}else if(r+=pe(t.c.month),s==="month")return r;return r+=pe(t.c.day),r}function Dn(t,e,s,n,r,a,i){let l=!s||t.c.millisecond!==0||t.c.second!==0,c="";switch(i){case"day":case"month":case"year":break;default:if(c+=pe(t.c.hour),i==="hour")break;if(e){if(c+=":",c+=pe(t.c.minute),i==="minute")break;l&&(c+=":",c+=pe(t.c.second))}else{if(c+=pe(t.c.minute),i==="minute")break;l&&(c+=pe(t.c.second))}if(i==="second")break;l&&(!n||t.c.millisecond!==0)&&(c+=".",c+=pe(t.c.millisecond,3))}return r&&(t.isOffsetFixed&&t.offset===0&&!a?c+="Z":t.o<0?(c+="-",c+=pe(Math.trunc(-t.o/60)),c+=":",c+=pe(Math.trunc(-t.o%60))):(c+="+",c+=pe(Math.trunc(t.o/60)),c+=":",c+=pe(Math.trunc(t.o%60)))),a&&(c+="["+t.zone.ianaName+"]"),c}const Yr={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},Zo={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},zo={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Yt=["year","month","day","hour","minute","second","millisecond"],Ho=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],qo=["year","ordinal","hour","minute","second","millisecond"];function _t(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 Yn(t);return e}function Rn(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return _t(t)}}function Go(t){if(It===void 0&&(It=fe.now()),t.type!=="iana")return t.offset(It);const e=t.name;let s=js.get(e);return s===void 0&&(s=t.offset(It),js.set(e,s)),s}function Ln(t,e){const s=tt(e.zone,fe.defaultZone);if(!s.isValid)return L.invalid(kt(s));const n=te.fromObject(e);let r,a;if(U(t.year))r=fe.now();else{for(const c of Yt)U(t[c])&&(t[c]=Yr[c]);const i=wr(t)||vr(t);if(i)return L.invalid(i);const l=Go(s);[r,a]=Gt(t,l,s)}return new L({ts:r,zone:s,loc:n,o:a})}function Un(t,e,s){const n=U(s.round)?!0:s.round,r=U(s.rounding)?"trunc":s.rounding,a=(l,c)=>(l=Bs(l,n||s.calendary?0:2,s.calendary?"round":r),e.loc.clone(s).relFormatter(s).format(l,c)),i=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(i(s.unit),s.unit);for(const l of s.units){const c=i(l);if(Math.abs(c)>=1)return a(c,l)}return a(t>e?-0:0,s.units[s.units.length-1])}function Fn(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 It;const js=new Map;class L{constructor(e){const s=e.zone||fe.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Ve("invalid input"):null)||(s.isValid?null:kt(s));this.ts=U(e.ts)?fe.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=st(e.o)&&!e.old?e.o:s.offset(this.ts);r=Zt(this.ts,l),n=Number.isNaN(r.year)?new Ve("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 L({})}static local(){const[e,s]=Fn(arguments),[n,r,a,i,l,c,u]=s;return Ln({year:n,month:r,day:a,hour:i,minute:l,second:c,millisecond:u},e)}static utc(){const[e,s]=Fn(arguments),[n,r,a,i,l,c,u]=s;return e.zone=be.utcInstance,Ln({year:n,month:r,day:a,hour:i,minute:l,second:c,millisecond:u},e)}static fromJSDate(e,s={}){const n=Ni(e)?e.valueOf():NaN;if(Number.isNaN(n))return L.invalid("invalid input");const r=tt(s.zone,fe.defaultZone);return r.isValid?new L({ts:n,zone:r,loc:te.fromObject(s)}):L.invalid(kt(r))}static fromMillis(e,s={}){if(st(e))return e<-Cn||e>Cn?L.invalid("Timestamp out of range"):new L({ts:e,zone:tt(s.zone,fe.defaultZone),loc:te.fromObject(s)});throw new we(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,s={}){if(st(e))return new L({ts:e*1e3,zone:tt(s.zone,fe.defaultZone),loc:te.fromObject(s)});throw new we("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=tt(s.zone,fe.defaultZone);if(!n.isValid)return L.invalid(kt(n));const r=te.fromObject(s),a=Xt(e,Rn),{minDaysInFirstWeek:i,startOfWeek:l}=wn(a,r),c=fe.now(),u=U(s.specificOffset)?n.offset(c):s.specificOffset,h=!U(a.ordinal),m=!U(a.year),g=!U(a.month)||!U(a.day),y=m||g,A=a.weekYear||a.weekNumber;if((y||h)&&A)throw new ft("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(g&&h)throw new ft("Can't mix ordinal dates with month/day");const x=A||a.weekday&&!y;let p,B,F=Zt(c,u);x?(p=Ho,B=Zo,F=Qt(F,i,l)):h?(p=qo,B=zo,F=gs(F)):(p=Yt,B=Yr);let Z=!1;for(const k of p){const O=a[k];U(O)?Z?a[k]=B[k]:a[k]=F[k]:Z=!0}const J=x?vi(a,i,l):h?Ti(a):wr(a),K=J||vr(a);if(K)return L.invalid(K);const G=x?Sn(a,i,l):h?xn(a):a,[j,se]=Gt(G,u,n),w=new L({ts:j,zone:n,o:se,loc:r});return a.weekday&&y&&e.weekday!==w.weekday?L.invalid("mismatched weekday",`you can't specify both a weekday of ${a.weekday} and a date of ${w.toISO()}`):w.isValid?w:L.invalid(w.invalid)}static fromISO(e,s={}){const[n,r]=ho(e);return mt(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=yo(e);return mt(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=go(e);return mt(n,r,s,"HTTP",s)}static fromFormat(e,s,n={}){if(U(e)||U(s))throw new we("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:a=null}=n,i=te.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0}),[l,c,u,h]=Bo(i,e,s);return h?L.invalid(h):mt(l,c,n,`format ${s}`,e,u)}static fromString(e,s,n={}){return L.fromFormat(e,s,n)}static fromSQL(e,s={}){const[n,r]=Ao(e);return mt(n,r,s,"SQL",e)}static invalid(e,s=null){if(!e)throw new we("need to specify a reason the DateTime is invalid");const n=e instanceof Ve?e:new Ve(e,s);if(fe.throwOnInvalid)throw new _a(n);return new L({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,s={}){const n=qr(e,te.fromObject(s));return n?n.map(r=>r?r.val:null).join(""):null}static expandFormat(e,s={}){return Zr(ve.parseFormat(e),te.fromObject(s)).map(r=>r.val).join("")}static resetCache(){It=void 0,js.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?xs(this).weekYear:NaN}get weekNumber(){return this.isValid?xs(this).weekNumber:NaN}get weekday(){return this.isValid?xs(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?ws(this).weekday:NaN}get localWeekNumber(){return this.isValid?ws(this).weekNumber:NaN}get localWeekYear(){return this.isValid?ws(this).weekYear:NaN}get ordinal(){return this.isValid?gs(this.c).ordinal:NaN}get monthShort(){return this.isValid?Vt.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Vt.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Vt.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Vt.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=rs(this.c),r=this.zone.offset(n-e),a=this.zone.offset(n+e),i=this.zone.offset(n-r*s),l=this.zone.offset(n-a*s);if(i===l)return[this];const c=n-i*s,u=n-l*s,h=Zt(c,i),m=Zt(u,l);return h.hour===m.hour&&h.minute===m.minute&&h.second===m.second&&h.millisecond===m.millisecond?[rt(this,{ts:c}),rt(this,{ts:u})]:[this]}get isInLeapYear(){return Ct(this.year)}get daysInMonth(){return Kt(this.year,this.month)}get daysInYear(){return this.isValid?ht(this.year):NaN}get weeksInWeekYear(){return this.isValid?Et(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Et(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:s,numberingSystem:n,calendar:r}=ve.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:s,numberingSystem:n,outputCalendar:r}}toUTC(e=0,s={}){return this.setZone(be.instance(e),s)}toLocal(){return this.setZone(fe.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=tt(e,fe.defaultZone),e.equals(this.zone))return this;if(e.isValid){let r=this.ts;if(s||n){const a=e.offset(this.ts),i=this.toObject();[r]=Gt(i,a,e)}return rt(this,{ts:r,zone:e})}else return L.invalid(kt(e))}reconfigure({locale:e,numberingSystem:s,outputCalendar:n}={}){const r=this.loc.clone({locale:e,numberingSystem:s,outputCalendar:n});return rt(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const s=Xt(e,Rn),{minDaysInFirstWeek:n,startOfWeek:r}=wn(s,this.loc),a=!U(s.weekYear)||!U(s.weekNumber)||!U(s.weekday),i=!U(s.ordinal),l=!U(s.year),c=!U(s.month)||!U(s.day),u=l||c,h=s.weekYear||s.weekNumber;if((u||i)&&h)throw new ft("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(c&&i)throw new ft("Can't mix ordinal dates with month/day");let m;a?m=Sn({...Qt(this.c,n,r),...s},n,r):U(s.ordinal)?(m={...this.toObject(),...s},U(s.day)&&(m.day=Math.min(Kt(m.year,m.month),m.day))):m=xn({...gs(this.c),...s});const[g,y]=Gt(m,this.o,this.zone);return rt(this,{ts:g,o:y})}plus(e){if(!this.isValid)return this;const s=_.fromDurationLike(e);return rt(this,jn(this,s))}minus(e){if(!this.isValid)return this;const s=_.fromDurationLike(e).negate();return rt(this,jn(this,s))}startOf(e,{useLocaleWeeks:s=!1}={}){if(!this.isValid)return this;const n={},r=_.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:i}=this;i<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?ve.create(this.loc.redefaultToEN(s)).formatDateTimeFromString(this,e):Ss}toLocaleString(e=Jt,s={}){return this.isValid?ve.create(this.loc.clone(s),e).formatDateTime(this):Ss}toLocaleParts(e={}){return this.isValid?ve.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:i="milliseconds"}={}){if(!this.isValid)return null;i=_t(i);const l=e==="extended";let c=vs(this,l,i);return Yt.indexOf(i)>=3&&(c+="T"),c+=Dn(this,l,s,n,r,a,i),c}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?vs(this,e==="extended",_t(s)):null}toISOWeekDate(){return zt(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:s=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:a=!1,format:i="extended",precision:l="milliseconds"}={}){return this.isValid?(l=_t(l),(r&&Yt.indexOf(l)>=3?"T":"")+Dn(this,i==="extended",s,e,n,a,l)):null}toRFC2822(){return zt(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return zt(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?vs(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")),zt(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Ss}[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 _.invalid("created by diffing an invalid DateTime");const r={locale:this.locale,numberingSystem:this.numberingSystem,...n},a=bi(s).map(_.normalizeUnit),i=e.valueOf()>this.valueOf(),l=i?this:e,c=i?e:this,u=Eo(l,c,a,r);return i?u.negate():u}diffNow(e="milliseconds",s={}){return this.diff(L.now(),e,s)}until(e){return this.isValid?me.fromDateTimes(this,e):this}hasSame(e,s,n){if(!this.isValid)return!1;const r=e.valueOf(),a=this.setZone(e.zone,{keepLocalTime:!0});return a.startOf(s,n)<=r&&r<=a.endOf(s,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;const s=e.base||L.fromObject({},{zone:this.zone}),n=e.padding?this<s?-e.padding:e.padding:0;let r=["years","months","days","hours","minutes","seconds"],a=e.unit;return Array.isArray(e.unit)&&(r=e.unit,a=void 0),Un(s,this.plus(n),{...e,numeric:"always",units:r,unit:a})}toRelativeCalendar(e={}){return this.isValid?Un(e.base||L.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(L.isDateTime))throw new we("min requires all arguments be DateTimes");return vn(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every(L.isDateTime))throw new we("max requires all arguments be DateTimes");return vn(e,s=>s.valueOf(),Math.max)}static fromFormatExplain(e,s,n={}){const{locale:r=null,numberingSystem:a=null}=n,i=te.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});return Hr(i,e,s)}static fromStringExplain(e,s,n={}){return L.fromFormatExplain(e,s,n)}static buildFormatParser(e,s={}){const{locale:n=null,numberingSystem:r=null}=s,a=te.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new zr(a,e)}static fromFormatParser(e,s,n={}){if(U(e)||U(s))throw new we("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:a=null}=n,i=te.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});if(!i.equals(s.locale))throw new we(`fromFormatParser called with a locale of ${i}, but the format parser was created for ${s.locale}`);const{result:l,zone:c,specificOffset:u,invalidReason:h}=s.explainFromTokens(e);return h?L.invalid(h):mt(l,c,n,`format ${s.format}`,e,u)}static get DATE_SHORT(){return Jt}static get DATE_MED(){return _n}static get DATE_MED_WITH_WEEKDAY(){return Ka}static get DATE_FULL(){return Jn}static get DATE_HUGE(){return Qn}static get TIME_SIMPLE(){return Kn}static get TIME_WITH_SECONDS(){return Xn}static get TIME_WITH_SHORT_OFFSET(){return er}static get TIME_WITH_LONG_OFFSET(){return tr}static get TIME_24_SIMPLE(){return sr}static get TIME_24_WITH_SECONDS(){return nr}static get TIME_24_WITH_SHORT_OFFSET(){return rr}static get TIME_24_WITH_LONG_OFFSET(){return ar}static get DATETIME_SHORT(){return ir}static get DATETIME_SHORT_WITH_SECONDS(){return or}static get DATETIME_MED(){return lr}static get DATETIME_MED_WITH_SECONDS(){return cr}static get DATETIME_MED_WITH_WEEKDAY(){return Xa}static get DATETIME_FULL(){return ur}static get DATETIME_FULL_WITH_SECONDS(){return dr}static get DATETIME_HUGE(){return mr}static get DATETIME_HUGE_WITH_SECONDS(){return fr}}function At(t){if(L.isDateTime(t))return t;if(t&&t.valueOf&&st(t.valueOf()))return L.fromJSDate(t);if(t&&typeof t=="object")return L.fromObject(t);throw new we(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function Yo(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function _o(t,e){try{const s=L.fromJSDate(t,{zone:"utc"}).setZone(e),n=s.toJSDate().toLocaleString("en-US",{timeZone:e,timeZoneName:"short"}).split(" ").pop()||void 0,r=s.toFormat("ZZ")||void 0;return{abbr:n,offset:r}}catch{return{}}}function Jo(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(),i=s(e.getHours()),l=s(e.getMinutes()),c=s(e.getSeconds());return`${n}/${r}/${a} ${i}:${l}:${c}`}catch{return"-"}}function es(t,e="UTC"){if(!t)return"-";const s=L.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 Qo={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Ko={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function _r({alerts:t,loading:e=!1,pageSize:s=10,severityOptions:n,anomalyOptions:r,spaceOptions:a,onAlertIdClick:i}){const l=Fs(),c=["completed","false positive"],u=async g=>{try{const y=await l.mutateAsync({alertUniqueId:g.alertId??g.id,alertId:g.id,status:"Reopen",notes:"Reopened",modifiedBy:0});if(y?.responseStatus||y?.Success){const A=y?.Message||y?.data||"Alert reopened successfully.";Te.toast.success(A)}else{const A=y?.errorMessage||y?.Message||"Failed to reopen alert";Te.toast.error(A)}}catch{Te.toast.error("Failed to reopen alert. Please try again.")}},h=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:g=>o.jsx(d.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Qo[g]}`,backgroundColor:Ko[String(g)]},children:g})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:g=>Jo(g)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(g,y)=>o.jsxs("div",{children:[o.jsx("a",{onClick:A=>{A.preventDefault(),i?.(y,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:y.alertNumber}),o.jsx("div",{className:"text-black/65",children:g})]})},{title:"",key:"menu",width:60,align:"right",render:(g,y)=>o.jsx(d.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:A})=>{A==="reopen"&&u(y)}},children:o.jsx(d.Button,{type:"text",icon:o.jsx(it.MoreOutlined,{})})})}],m=(t||[]).filter(g=>c.includes((g.statusType||"").toLowerCase()));return o.jsx(Us,{data:m,loading:e,pageSize:s,columns:h,severityOptions:n,anomalyOptions:r,spaceOptions:a,renderActions:void 0,onAlertIdClick:i,excludeCompleted:!1})}function Xo({size:t=120,time:e,timeZone:s="America/New_York"}){const{hours:n,minutes:r,seconds:a}=f.useMemo(()=>{const m=new Intl.DateTimeFormat("en-US",{timeZone:s,hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(e);return{hours:parseInt(m.find(g=>g.type==="hour")?.value||"0",10),minutes:parseInt(m.find(g=>g.type==="minute")?.value||"0",10),seconds:parseInt(m.find(g=>g.type==="second")?.value||"0",10)}},[e,s]),i=a*6,l=r*6+a*.1,c=n%12*30+r*.5,u=t/2;return o.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((h,m)=>{const g=m*30,y=6,A=u-4,x=A-y,p=(g-90)*(Math.PI/180),B=u+x*Math.cos(p),F=u+x*Math.sin(p),Z=u+A*Math.cos(p),J=u+A*Math.sin(p);return o.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:o.jsx("line",{x1:B,y1:F,x2:Z,y2:J,stroke:"#9CA3AF",strokeWidth:m%3===0?2:1,strokeLinecap:"round"})},m)}),o.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${c}deg)`},children:o.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.25,stroke:"#1F2937",strokeWidth:4,strokeLinecap:"round"})}),o.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${l}deg)`},children:o.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.35,stroke:"#374151",strokeWidth:3,strokeLinecap:"round"})}),o.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${i}deg)`},children:o.jsx("line",{x1:u,y1:u+t*.08,x2:u,y2:u-t*.38,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"})}),o.jsx("div",{className:"absolute bg-gray-900 rounded-full",style:{width:8,height:8,left:u-4,top:u-4}})]})}function Jr({label:t="USA",timeZone:e="America/New_York",updateIntervalMs:s=1e3,className:n}){const[r,a]=f.useState(new Date);f.useEffect(()=>{const u=setInterval(()=>a(new Date),s);return()=>clearInterval(u)},[s]);const i=f.useMemo(()=>Yo(r,e),[r,e]),{abbr:l,offset:c}=f.useMemo(()=>_o(r,e),[r,e]);return o.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[o.jsx(Xo,{time:r,timeZone:e,size:80}),o.jsxs("div",{className:"flex flex-col items-baseline gap-1",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[o.jsx("span",{className:"uppercase",children:t}),l&&o.jsxs("span",{className:"p-2 rounded-md border text-[10px] leading-none text-gray-600 bg-gray-50",children:[l," ",c]})]}),o.jsx("div",{className:"text-2xl font-semibold text-gray-700 tracking-wide",children:i})]})]})}const{Text:el}=d.Typography;function tl({sortBy:t,onChange:e,showActions:s,onSave:n,onClear:r,saving:a}){return o.jsxs(d.Row,{gutter:[16,16],align:"middle",children:[o.jsx(d.Col,{xs:24,md:8,lg:5,children:o.jsxs(d.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[o.jsx(el,{className:"text-gray-600 whitespace-nowrap",children:"Sort By:"}),o.jsx(d.Select,{placeholder:"By Severity",value:t,onChange:i=>e({sortBy:i}),options:[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],className:"w-full",style:{minWidth:"200px"}})]})}),o.jsx(d.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?o.jsxs(d.Space,{className:"w-full",direction:"horizontal",size:8,children:[o.jsx(d.Button,{onClick:r,disabled:a,children:"Clear"}),o.jsx(d.Button,{type:"primary",onClick:n,loading:a,children:"Save"})]}):null})]})}const Ds=t=>o.jsxs(d.Tag,{children:[o.jsx(it.PlusOutlined,{})," ",t.length," more"]}),{Text:Ge}=d.Typography;function sl(t){const{selectedRule:e,setSelectedRule:s,ruleOptions:n,minsOptions:r,roleOptions:a,l1mins:i,setL1mins:l,l1role:c,setL1role:u,l2mins:h,setL2mins:m,l2role:g,setL2role:y,l3mins:A,setL3mins:x,l3role:p,setL3role:B,actions:F,setActions:Z,thirdPartyIds:J,setThirdPartyIds:K,humanLoop:G,setHumanLoop:j,isAutoExpire:se,setAutoExpire:w,onClear:k,onSave:O,saving:he,onActionTypesLoaded:oe}=t,{rules:C}=Oe(),[v,S]=f.useState([]),[I,T]=f.useState([]),[D,N]=f.useState(!1);f.useEffect(()=>{let z=!1;return(async()=>{try{N(!0);const Q=await C.getLookups();if(z||!Q||!Array.isArray(Q.actionTypes))return;const le=Q.actionTypes.map(ce=>({label:ce.name,value:String(ce.actionTypeId)}));S(le),oe&&oe(Q.actionTypes);const Se=Array.isArray(Q.thirdParties)?Q.thirdParties.map(ce=>({label:ce.thirdPartyName,value:ce.thirdPartyId})):[];T(Se)}catch(Q){console.error("Error loading lookups",Q)}finally{z||N(!1)}})(),()=>{z=!0}},[]);const M=typeof i=="number"||typeof c=="number",$=typeof h=="number"||typeof g=="number",P=typeof i=="number"||typeof c=="number"||typeof h=="number"||typeof g=="number"||typeof A=="number"||typeof p=="number"||Array.isArray(F)&&F.length>0||Array.isArray(J)&&J.length>0||!!G||!!se,W=!!e&&P&&!he;return o.jsxs(d.Spin,{spinning:!!he||D,children:[o.jsxs(d.Row,{gutter:[16,16],align:"bottom",children:[o.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:o.jsxs("div",{children:[o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),o.jsx(d.Select,{placeholder:"Rules",value:e,onChange:s,options:n,className:"w-full"})]})}),o.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:o.jsxs("div",{children:[o.jsxs(d.Row,{gutter:8,children:[o.jsx(d.Col,{span:10,children:o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),o.jsx(d.Col,{span:14,children:o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),o.jsxs(d.Row,{gutter:8,children:[o.jsx(d.Col,{span:10,children:o.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:i,onChange:l,options:r})}),o.jsx(d.Col,{span:14,children:o.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:c,onChange:u,options:a})})]})]})}),M&&o.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:o.jsxs("div",{children:[o.jsxs(d.Row,{gutter:8,children:[o.jsx(d.Col,{span:10,children:o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),o.jsx(d.Col,{span:14,children:o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),o.jsxs(d.Row,{gutter:8,children:[o.jsx(d.Col,{span:10,children:o.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:h,onChange:m,options:r})}),o.jsx(d.Col,{span:14,children:o.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:g,onChange:y,options:a})})]})]})}),$&&o.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:o.jsxs("div",{children:[o.jsxs(d.Row,{gutter:8,children:[o.jsx(d.Col,{span:10,children:o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),o.jsx(d.Col,{span:14,children:o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),o.jsxs(d.Row,{gutter:8,children:[o.jsx(d.Col,{span:10,children:o.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:A,onChange:x,options:r})}),o.jsx(d.Col,{span:14,children:o.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:p,onChange:B,options:a})})]})]})}),o.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:o.jsxs("div",{children:[o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),o.jsx(d.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:F,onChange:Z,options:v,maxTagCount:1,maxTagPlaceholder:Ds})]})}),o.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:o.jsxs("div",{children:[o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Third Party App"}),o.jsx(d.Select,{mode:"multiple",placeholder:"Third Party app",className:"w-full",value:J,onChange:K,options:I,maxCount:2,maxTagPlaceholder:Ds})]})})]}),o.jsxs(d.Row,{gutter:[16,16],align:"bottom",className:"mt-4 items-center",children:[o.jsx(d.Col,{xs:24,sm:12,md:8,lg:7,children:o.jsxs("div",{className:"flex items-center h-full gap-8",children:[o.jsx(d.Checkbox,{checked:G,onChange:z=>j(z.target.checked),className:"w-full",children:"Human-In-The-Loop"}),o.jsx(d.Checkbox,{checked:se,onChange:z=>w(z.target.checked),className:"w-full",children:"Auto-expire in 5 minutes"})]})}),o.jsx(d.Col,{xs:24,sm:12,md:8,children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(d.Button,{onClick:k,children:"Clear"}),o.jsx(d.Button,{type:"primary",onClick:O,loading:!!he,disabled:!W,children:"Save"})]})})]})]})}function nl({entries:t,userRoles:e,onEdit:s,loading:n}){const r=new Map(e.map(i=>[i.userRoleId,i.userRoleName])),a=i=>i.map(l=>r.get(l)||String(l)).join(", ");return o.jsx(d.Table,{rowKey:"id",dataSource:t,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(i,l)=>`${l[0]}-${l[1]} of ${i} items`},loading:n,columns:[{title:"Rule",dataIndex:"ruleOrSeverityLabel",key:"rule"},{title:"Level 1",key:"l1",render:(i,l)=>o.jsxs("span",{children:[l.l1.minutes?`Action taken in (${l.l1.minutes} Mins)`:"No Action taken in 0 Min",l.l1.roles?.length?`, Escalate to (${a(l.l1.roles)})`:""]})},{title:"Level 2",key:"l2",render:(i,l)=>o.jsxs("span",{children:[l.l2.minutes?`Action taken in (${l.l2.minutes} Mins)`:"No Action taken in 0 Min",l.l2.roles?.length?`, Escalate to (${a(l.l2.roles)})`:""]})},{title:"Level 3",key:"l3",render:(i,l)=>o.jsxs("span",{children:[l.l3.minutes?`Action taken in (${l.l3.minutes} Mins)`:"No Action taken in 0 Min",l.l3.roles?.length?`, Escalate to (${a(l.l3.roles)})`:""]})},{title:"Pick Actions",key:"actionsCol",render:(i,l)=>l.actions?.length?l.actions.join(", "):"-"},{title:"Notify",key:"notify",render:(i,l)=>l.notify?.length?l.notify.join(", "):"-"},{title:"Human-In-The-Loop",key:"humanLoop",render:(i,l)=>l.humanLoop?"Yes":"No"},{title:"Auto Expire",key:"isAutoExpire",render:(i,l)=>l.isAutoExpire?"Yes":"No"},{title:"Actions",key:"ops",render:(i,l)=>o.jsx(d.Button,{type:"text",onClick:()=>s(l.id),children:o.jsx(it.EditOutlined,{})})}]})}const{Title:rl}=d.Typography;function Qr({userRoles:t,rules:e,rawRules:s}){const{rules:n}=Oe(),[r,a]=f.useState(!1),[i,l]=f.useState(s),[c,u]=f.useState({}),h=f.useMemo(()=>t.map(x=>({label:x.userRoleName,value:x.userRoleId})),[t]),m=f.useMemo(()=>(e||[]).map((x,p)=>({key:x.RuleId||x.Name||String(p),ruleName:x.Name||"-",ruleDesc:x.Description||""})),[e]);f.useEffect(()=>{let x=!1;return(async()=>{try{a(!0);const p=await n.getRules();x||(l(Array.isArray(p)?p:[]),u({}))}catch{!x&&Array.isArray(s)&&l(s)}finally{x||a(!1)}})(),()=>{x=!0}},[]),f.useEffect(()=>{!i&&Array.isArray(s)&&l(s)},[s]);const g=f.useMemo(()=>{if(!Array.isArray(i)||!i.length)return{};const x={};for(const p of m){const B=i.find(Z=>Z?.ruleId===p.key||Z?.ruleName===p.key||Z?.RuleId===p.key||Z?.ruleName===p.ruleName||Z?.Name===p.ruleName),F=Array.isArray(B?.userRoleIds)?B.userRoleIds:[];F.length&&(x[p.key]=F)}return x},[i,m]),y=()=>{u({})},A=async()=>{try{if(!i||!Array.isArray(i)||Object.keys(c).length===0){Te.toast.info("No changes to save");return}a(!0);const x=Object.entries(c).map(async([p,B])=>{const F=i.find(j=>j?.ruleId===p||j?.ruleName===p||j?.RuleId===p),Z=typeof F?.recordId=="number"?F.recordId:F?.ruleId||F?.RuleId||void 0;if(!F||!Z)throw new Error(`Unable to find rule identifier for rule ${p}`);const J=Array.isArray(B)?B:[],K=J.map(j=>{const se=t.find(w=>w.userRoleId===j);return{id:j,name:se?.userRoleName??String(j)}}),G={...F,ruleId:p,userRoleIds:J,userRoles:K};return n.updateRule(Z,G)});await Promise.all(x),Te.toast.success("Alert assignment saved");try{const p=await n.getRules();l(Array.isArray(p)?p:[]),u({})}catch(p){console.error("Failed to refresh rules after save",p)}}catch(x){console.error("Failed to save alert assignment",x)}finally{a(!1)}};return o.jsxs("div",{className:"w-full",children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsx(rl,{level:4,className:"!mb-4",children:"Alert Assignment"})}),o.jsx(d.Table,{rowKey:"key",dataSource:m,loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(x,p)=>`${p[0]}-${p[1]} of ${x} items`},columns:[{title:"Rule Name",dataIndex:"ruleName",key:"ruleName"},{title:"Description",dataIndex:"ruleDesc",key:"ruleDesc"},{title:"Alert Notification To",key:"assign",render:(x,p)=>o.jsx(d.Select,{mode:"multiple",placeholder:"Dropdown with Multi select",className:"w-full",value:c[p.key]??g[p.key]??[],onChange:B=>u(F=>({...F,[p.key]:B})),options:h,maxTagCount:1,maxTagPlaceholder:Ds})}]}),o.jsxs(d.Space,{className:"mt-4",children:[o.jsx(d.Button,{onClick:y,disabled:r,children:"Clear"}),o.jsx(d.Button,{type:"primary",onClick:A,loading:r,disabled:r||Object.keys(c).length===0,children:"Save"})]})]})}const{Title:$n}=d.Typography;function Kr({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r,onSave:a}){const{rules:i,alerts:l}=Oe(),[c,u]=f.useState("By Severity"),[h,m]=f.useState("By severity"),[g,y]=f.useState("By Severity"),[A,x]=f.useState(!1),[p,B]=f.useState(!1),[F,Z]=f.useState(!1),[J,K]=f.useState(null),[G,j]=f.useState("rules"),[se,w]=f.useState(),[k,O]=f.useState(),[he,oe]=f.useState(),[C,v]=f.useState(),[S,I]=f.useState(),[T,D]=f.useState(),[N,M]=f.useState(),[$,P]=f.useState(),[W,z]=f.useState([]),[Q,le]=f.useState([]),[Se,ce]=f.useState(!1),[ue,xe]=f.useState(!1),[Ae,Ce]=f.useState({}),[_e,vt]=f.useState({}),[ye,ct]=f.useState(s||[]),[Tt,Je]=f.useState([]),[Rt,E]=f.useState(!1),[q,X]=f.useState(!1),[ge,ke]=f.useState(n||[]);f.useEffect(()=>{n&&n.length&&ke(n)},[n]),f.useEffect(()=>{if(!ge||!ge.length)return;const R=Object.keys(Ae).length>0||Object.keys(_e).length>0;if(Tt.length&&!R)return;const re=ge.map((Y,V)=>{const ie=e.find(Ne=>Ne.RuleId===(Y.ruleId||Y.ruleName))?.Name||Y.ruleName||Y.Name||"-",H=Y.escalationSettings||{},ae=typeof H.level1UserRoleId=="number"&&H.level1UserRoleId>0?[H.level1UserRoleId]:[],ls=typeof H.level2UserRoleId=="number"&&H.level2UserRoleId>0?[H.level2UserRoleId]:[],cs=typeof H.level3UserRoleId=="number"&&H.level3UserRoleId>0?[H.level3UserRoleId]:[],_s=(Array.isArray(H.escalationSettingsActionTypeIds)?H.escalationSettingsActionTypeIds:[]).map(Ne=>Ae[Ne]||String(Ne)),Qs=(Array.isArray(H.thirdPartyId)?H.thirdPartyId:[]).map(Ne=>_e[Ne]||String(Ne)),us=typeof H.humanLoop=="boolean"?H.humanLoop:null,ds=typeof H.isAutoExpire=="boolean"?H.isAutoExpire:null;return{id:String(Y.ruleId||Y.ruleName||V),ruleOrSeverityLabel:ie,l1:{minutes:H.level1PostAssistTime??void 0,roles:ae},l2:{minutes:H.level2PostAssistTime??void 0,roles:ls},l3:{minutes:H.level3PostAssistTime??void 0,roles:cs},actions:_s,notify:Qs,humanLoop:us,isAutoExpire:ds}});Je(re)},[ge,e,Ae,_e]);const ne=f.useMemo(()=>t.map(R=>({label:R.DisplayName,value:R.SeverityId})),[t]),Ze=f.useMemo(()=>e.map(R=>({label:R.Name,value:R.RuleId})),[e]),Qe=f.useMemo(()=>ye.map(R=>({label:R.userRoleName,value:R.userRoleId})),[ye]),ze=f.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(R=>({label:`${R}`,value:R})),[]);f.useEffect(()=>{let R=!1;async function re(){try{Z(!0),K(null);const Y=await l.getAdminSettings();if(!R&&Y){const V=Zn(Y.sortBy);u(V),y(V),x(!1)}}catch(Y){if(!R){const V=Y instanceof Error?Y.message:"Failed to load admin settings";K(V)}}finally{R||Z(!1)}}return re(),()=>{R=!0}},[]),f.useEffect(()=>{if(!k)return;const R=ie=>{const H=Number(ie);return!isNaN(H)&&H>0?H:void 0},re=ie=>{const H=Number(ie);return!isNaN(H)&&H>0?H:void 0},V=(ge||[]).find(ie=>ie?.ruleId===k||ie?.ruleName===k||ie?.RuleId===k)?.escalationSettings;if(V&&typeof V=="object"){oe(re(V.level1PostAssistTime)),v(R(V.level1UserRoleId)),I(re(V.level2PostAssistTime)),D(R(V.level2UserRoleId)),M(re(V.level3PostAssistTime)),P(R(V.level3UserRoleId));const ie=Array.isArray(V.escalationSettingsActionTypeIds)?V.escalationSettingsActionTypeIds:[];z(ie.map(H=>String(H))),le(Array.isArray(V.thirdPartyId)?V.thirdPartyId:[]),ce(!!V.humanLoop),xe(!!V.isAutoExpire)}},[G,k,ge]);const ra=async()=>{try{X(!0);const R=await i.getRules(),re=Array.isArray(R)?R:Array.isArray(R?.data)?R.data:[];ke(re);const Y=re.map((V,ie)=>{const H=e.find(Ne=>Ne.RuleId===(V.ruleId||V.ruleName))?.Name||V.ruleName||V.Name||"-",ae=V.escalationSettings||{},ls=typeof ae.level1UserRoleId=="number"&&ae.level1UserRoleId>0?[ae.level1UserRoleId]:[],cs=typeof ae.level2UserRoleId=="number"&&ae.level2UserRoleId>0?[ae.level2UserRoleId]:[],Ys=typeof ae.level3UserRoleId=="number"&&ae.level3UserRoleId>0?[ae.level3UserRoleId]:[],Js=(Array.isArray(ae.escalationSettingsActionTypeIds)?ae.escalationSettingsActionTypeIds:[]).map(Ne=>Ae[Ne]||String(Ne)),us=(Array.isArray(ae.thirdPartyId)?ae.thirdPartyId:[]).map(Ne=>_e[Ne]||String(Ne)),ds=typeof ae.humanLoop=="boolean"?ae.humanLoop:null;return{id:String(V.ruleId||V.ruleName||ie),ruleOrSeverityLabel:H,l1:{minutes:ae.level1PostAssistTime??void 0,roles:ls},l2:{minutes:ae.level2PostAssistTime??void 0,roles:cs},l3:{minutes:ae.level3PostAssistTime??void 0,roles:Ys},actions:Js,notify:us,humanLoop:ds}});Je(Y)}catch(R){console.error("Failed to refetch entries",R)}finally{X(!1)}};f.useEffect(()=>{let R=!1;return(async()=>{try{const re=await i.getLookups();if(R||!re)return;const Y={};if(Array.isArray(re.thirdParties))for(const ie of re.thirdParties)typeof ie.thirdPartyId=="number"&&(Y[ie.thirdPartyId]=ie.thirdPartyName);vt(Y);const V=Array.isArray(re.userRoles)?re.userRoles.map(ie=>({userRoleId:ie.userRoleId??ie.id,userRoleName:ie.userRoleName??ie.name})):[];R||ct(V.length?V:s||[])}catch(re){console.error("Error loading lookups",re)}})(),()=>{R=!0}},[]);const aa=async()=>{B(!0);try{const R=await l.setAdminSettings({sortBy:c,groupBy:"string"});R?.responseStatus&&R?.data&&Te.toast.success(R.data),y(c),x(!1)}catch(R){console.error("Error saving admin settings",R)}finally{B(!1)}},ia=()=>{u(g),x(!1)},oa=async()=>{E(!0),a?.({ruleId:k,levels:[{minutes:he,role:C},{minutes:S,role:T},{minutes:N,role:$}],actions:W,thirdPartyIds:Q,humanLoop:Se,isAutoExpire:ue});try{if(k){const re=Array.isArray(W)?W.map(ae=>Number.isNaN(Number(ae))?ae:Number(ae)):[],Y=(ge||[]).find(ae=>ae?.ruleId===k||ae?.ruleName===k||ae?.RuleId===k),V=typeof Y?.recordId=="number"?Y.recordId:Y?.ruleId||Y?.RuleId||void 0;if(!Y||!V){Te.toast.error("Unable to find rule identifier for update");return}const ie={...Y,escalationSettings:{level1UserRoleId:C??0,level1PostAssistTime:he??0,level2UserRoleId:T??0,level2PostAssistTime:S??0,level3UserRoleId:$??0,level3PostAssistTime:N??0,escalationSettingsActionTypeIds:re,thirdPartyId:Array.isArray(Q)?Q:[],humanLoop:Se,isAutoExpire:ue}},H=await i.updateRule(V,ie);H?.responseStatus||H?.Success||H?.success?(Te.toast.success("Escalation settings saved"),await ra(),O(void 0),oe(void 0),v(void 0),I(void 0),D(void 0),M(void 0),P(void 0),z([]),le([]),ce(!1),xe(!1)):Te.toast.error(H?.errorMessage||"Error saving Escalation Settings")}}catch(re){console.error("Error saving escalation settings",re)}finally{E(!1)}},la=()=>{u("By Severity"),m("By severity"),j("rules"),w(void 0),O(void 0),oe(void 0),v(void 0),I(void 0),D(void 0),M(void 0),P(void 0),z([]),le([]),ce(!1),xe(!1)};return o.jsxs("div",{className:"w-full",children:[o.jsxs("div",{className:"mb-6",children:[o.jsx($n,{level:4,className:"!mb-2",children:"Admin Settings"}),o.jsxs(d.Spin,{spinning:F,children:[J?o.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",J]}):null,o.jsx(tl,{sortBy:c,groupBy:h,onChange:R=>{R.sortBy&&(u(R.sortBy),x(!0)),R.groupBy&&(m(R.groupBy),x(!0))},showActions:A,onSave:aa,onClear:ia,saving:p})]})]}),o.jsx(d.Divider,{className:"my-6"}),o.jsxs("div",{children:[o.jsx($n,{level:4,className:"!mb-4",children:"Escalation Settings"}),o.jsx(sl,{escBasis:G,setEscBasis:j,selectedSeverity:se,setSelectedSeverity:w,selectedRule:k,setSelectedRule:O,severityOptions:ne,ruleOptions:Ze,minsOptions:ze,roleOptions:Qe,l1mins:he,setL1mins:oe,l1role:C,setL1role:v,l2mins:S,setL2mins:I,l2role:T,setL2role:D,l3mins:N,setL3mins:M,l3role:$,setL3role:P,actions:W,setActions:z,thirdPartyIds:Q,setThirdPartyIds:le,humanLoop:Se,setHumanLoop:ce,onClear:la,onSave:oa,saving:Rt,onActionTypesLoaded:R=>{const re={};for(const Y of R)typeof Y.actionTypeId=="number"&&(re[Y.actionTypeId]=Y.name);Ce(re)},isAutoExpire:ue,setAutoExpire:xe})]}),o.jsx(d.Divider,{className:"my-6"}),o.jsx(nl,{entries:Tt,userRoles:ye,loading:q||Rt||r,onEdit:R=>{j("rules");const re=Tt.find(V=>V.id===R),Y=e.find(V=>V.RuleId===R)||(re?e.find(V=>V.Name===re.ruleOrSeverityLabel):void 0);O(Y?Y.RuleId:R)}}),o.jsx(d.Divider,{className:"my-6"}),o.jsx(Qr,{userRoles:ye,rules:e,rawRules:n}),o.jsx(d.Divider,{})]})}const{Title:Pn,Text:Ht}=d.Typography;function al({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:a}=Oe(),i=[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],[l,c]=f.useState("By Severity"),[u,h]=f.useState(new Set),[m,g]=f.useState(null),[y,A]=f.useState(null),[x,p]=f.useState({inApp:!1,sms:!1,email:!1}),[B,F]=f.useState([]),[Z,J]=f.useState(!0),[K,G]=f.useState(!1);f.useEffect(()=>{let w=!1;return(async()=>{try{const k=await a.getPreferenceSettings();if(w||!k)return;p({inApp:!!k.inApp,sms:!!k.sms,email:!!k.email});const O=Zn(k.sortBy);c(O==="By Created Date"?"By Created Date":"By Severity"),g(rn(k.doNotDisturbStart)),A(rn(k.doNotDisturbEnd)),Array.isArray(k.anomalyIds)&&h(new Set(k.anomalyIds.map(he=>String(he))))}catch(k){console.error("Error in loading my preferences: ",k)}})(),()=>{w=!0}},[]),f.useEffect(()=>{let w=!1;return(async()=>{try{J(!0);const k=await r.getLookups();if(w||!k)return;const O=Array.isArray(k.anomalies)?k.anomalies:[];F(O)}catch(k){console.error("Failed to load anomalies lookups",k)}finally{w||J(!1)}})(),()=>{w=!0}},[]);const j=w=>{h(k=>{const O=new Set(k);return O.has(w)?O.delete(w):O.add(w),O})},se=async()=>{s?.({sortBy:l,subscribedRuleIds:Array.from(u),dnd:{from:m,to:y},channels:x});try{G(!0);const w=m?m.format?.("HH:mm:ss")??"00:00:00":"00:00:00",k=y?y.format?.("HH:mm:ss")??"00:00:00":"00:00:00",O=Array.from(u).map(oe=>Number(oe)).filter(oe=>Number.isFinite(oe)),he=await a.setPreferenceSettings({anomalyIds:O,doNotDisturbStart:w,doNotDisturbEnd:k,inApp:!!x.inApp,sms:!!x.sms,email:!!x.email,sortBy:l});he?.responseStatus&&Te.toast.success(he?.data||"Preferences updated successfully.")}catch(w){console.error("Error in saving my preferences: ",w)}finally{G(!1)}};return o.jsxs("div",{className:"w-full",children:[o.jsx(d.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:o.jsx(d.Col,{xs:24,md:8,children:o.jsxs(d.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[o.jsx(Ht,{className:"text-gray-600",children:"Sort By:"}),o.jsx(d.Select,{className:"w-[240px]",value:l,options:i,onChange:c})]})})}),o.jsxs("div",{className:"mb-4",children:[o.jsx(Pn,{level:5,className:"!mb-2",children:"Anomalies"}),Z?o.jsx("div",{className:"py-4",children:o.jsx(d.Spin,{})}):o.jsx(d.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray(B)?B:[]).map(w=>{const k=String(w.recordId),O=w.anomalyName;return o.jsx(d.Checkbox,{checked:u.has(k),onChange:()=>j(k),children:O},k)})})]}),o.jsxs("div",{className:"mb-4",children:[o.jsx(Pn,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),o.jsx(d.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:o.jsx(d.Col,{xs:24,md:12,children:o.jsxs(d.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[o.jsx(Ht,{children:"Do Not Disturb mode:"}),o.jsxs(d.Space,{size:12,className:"w-full",children:[o.jsxs(d.Space,{direction:"horizontal",size:8,className:"items-center",children:[o.jsx(Ht,{children:"From"}),o.jsx(d.TimePicker,{value:m,onChange:w=>g(w),format:"HH:mm"})]}),o.jsxs(d.Space,{direction:"horizontal",size:8,className:"items-center",children:[o.jsx(Ht,{children:"To"}),o.jsx(d.TimePicker,{value:y,onChange:w=>A(w),format:"HH:mm"})]})]})]})})}),o.jsxs(d.Row,{gutter:[24,12],children:[o.jsx(d.Col,{children:o.jsx(d.Checkbox,{checked:x.inApp,onChange:w=>p({...x,inApp:w.target.checked}),children:"In-app"})}),o.jsx(d.Col,{children:o.jsx(d.Checkbox,{checked:x.sms,onChange:w=>p({...x,sms:w.target.checked}),children:"SMS"})}),o.jsx(d.Col,{children:o.jsx(d.Checkbox,{checked:x.email,onChange:w=>p({...x,email:w.target.checked}),children:"Email"})})]})]}),o.jsx(d.Divider,{}),o.jsxs(d.Space,{className:"gap-3",children:[o.jsx(d.Button,{onClick:n,disabled:K,children:"Cancel"}),o.jsx(d.Button,{type:"primary",onClick:se,loading:K,children:"Save"})]})]})}function Xr({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r}){return o.jsx("div",{className:"w-full",children:o.jsx(Kr,{severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r})})}const il="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 os(){const{config:t}=Oe();return{timeZoneDetails:f.useMemo(()=>{const s=t.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone;return{timeZoneUniqueId:"",ianaTimeZoneId:s,timeZoneName:s,offset:""}},[t.timeZone]),loading:!1}}function ll(t){const e=(t.status||"").toLowerCase()==="completed"?o.jsx("img",{src:il,alt:"completed",style:{width:20,height:20}}):o.jsx("img",{src:ol,alt:"pending",style:{width:20,height:20}});return{title:o.jsxs("div",{className:"flex flex-col gap-0 min-w-0",children:[o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"block text-sm break-words mb-1 overflow-visible whitespace-normal",children:o.jsx("b",{children:t.title})}),t.description?o.jsx("span",{className:"text-gray-500 text-xs",children:t.description}):null]}),t.timestamp?o.jsx("span",{className:"text-gray-500 text-xs",children:t.timestamp}):null]}),icon:e,description:null}}function cl({data:t}){const{timeZoneDetails:e}=os();return console.log("summary",t),o.jsx("div",{className:"w-full",children:o.jsx(d.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:o.jsxs("div",{className:"w-full",style:{maxHeight:"50vh",overflowY:"auto"},children:[o.jsx(d.Card,{className:"mb-4 rounded-md p-4",bordered:!0,children:o.jsxs("div",{className:"grid grid-cols-4 gap-6 text-xs",children:[o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"text-gray-500",children:"Alert ID"}),o.jsx("span",{className:"text-black",children:t.summary.alertNumber})]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"text-gray-500",children:"Severity"}),o.jsx("span",{className:"text-black",children:t.summary.severity})]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"text-gray-500",children:"Location"}),o.jsx("span",{className:"text-black",children:t.summary.location})]})]})}),o.jsxs(d.Card,{className:"rounded-md p-4",bordered:!0,children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsx("h4",{className:"text-sm text-black font-medium",children:"Response Timeline/ Audit trail/log"})}),o.jsx("div",{className:"mt-2",children:o.jsx(d.Steps,{direction:"vertical",size:"small",current:1,items:(t.timeline||[]).map(ll)})})]})]})},{key:"notification",label:"Notification Sent",children:o.jsxs("div",{className:"grid grid-cols-2 gap-4",style:{maxHeight:"50vh",overflowY:"auto"},children:[(t.notifications||[]).map((s,n)=>o.jsxs(d.Card,{className:"rounded-md p-4",bordered:!0,children:[o.jsxs("div",{className:"flex items-start justify-between",children:[o.jsxs("div",{className:"flex flex-col",children:[o.jsx("h4",{className:"text-sm text-black font-medium",children:s.channelLabel}),o.jsx("span",{className:"text-xs text-gray-500 mt-1",children:es(s.sentAt,e?.ianaTimeZoneId)})]}),o.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"]})]}),o.jsxs("div",{className:"mt-4 text-xs",children:[o.jsxs("div",{className:"text-black",children:[" ",s.messageTitle]}),s.messageBody?o.jsx("div",{className:"text-gray-600",children:s.messageBody}):null]}),o.jsxs("div",{className:"mt-4",children:[o.jsxs("div",{className:"text-xs text-black font-medium",children:["Recipients (",s.total,")"]}),o.jsx("div",{className:"mt-2 flex flex-col gap-3 text-xs",children:(s.recipients||[]).map((r,a)=>{const i=String(r?.notificationReceipientType||"").toLowerCase()==="EscalationNotification".toLowerCase();return o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex flex-col",children:[o.jsxs("span",{className:"text-black",children:[r.name," - ",o.jsx("span",{style:{color:i?"#FF3B30":"#FFB86A"},children:i?"Escalation Notification":"Alert Notification"})]}),o.jsxs("span",{className:"text-gray-500",children:[r.role," . ",r.phone]})]}),o.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:o.jsx("span",{className:"text-gray-500 text-xs",children:"No notifications."})]})}]})})}const ul=({alertId:t,id:e,priority:s,spaceName:n,alertNumber:r,statusHistory:a,notifGroups:i})=>{const l={alertId:t??String(e??""),incidentId:"-",severity:s||"",location:n||"",alertNumber:r??""},{timeZoneDetails:c}=os(),u=a?.length?a.map(m=>{const g=(m?.status||m?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",y=m?.createdDate?es(m.createdDate,c?.ianaTimeZoneId):m?.timestamp?es(m.timestamp,c?.ianaTimeZoneId):"";return{status:g,title:m?.status||m?.eventStatus||"Status Update",description:m?.description||m?.actionNotes||"",timestamp:y}}):[],h={summary:l,timeline:u,notifications:i??[]};return o.jsx(cl,{data:h})};const dl=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ml=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),Wn=t=>{const e=ml(t);return e.charAt(0).toUpperCase()+e.slice(1)},ea=(...t)=>t.filter((e,s,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===s).join(" ").trim(),fl=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var hl={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 yl=f.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:a,iconNode:i,...l},c)=>f.createElement("svg",{ref:c,...hl,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:ea("lucide",r),...!a&&!fl(l)&&{"aria-hidden":"true"},...l},[...i.map(([u,h])=>f.createElement(u,h)),...Array.isArray(a)?a:[a]]));const qs=(t,e)=>{const s=f.forwardRef(({className:n,...r},a)=>f.createElement(yl,{ref:a,iconNode:e,className:ea(`lucide-${dl(Wn(t))}`,`lucide-${t}`,n),...r}));return s.displayName=Wn(t),s};const gl=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],pl=qs("loader-circle",gl);const Sl=[["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"}]],ta=qs("maximize-2",Sl);const xl=[["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"}]],wl=qs("minimize-2",xl),vl=({isOpen:t,onClose:e,src:s,type:n="image"})=>{const[r,a]=f.useState(!1),[i,l]=f.useState(!1);return f.useEffect(()=>{t&&l(!1)},[t,s]),f.useEffect(()=>{t&&(!s||i)&&e()},[t,s,i,e]),t?o.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:o.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"?o.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)}):o.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)}),o.jsx("button",{onClick:e,className:"absolute top-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:"✕"}),o.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?o.jsx(wl,{size:20}):o.jsx(ta,{size:20})})]})}):null};function Tl(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 Vn(t){const e=(t?.mediaType||t?.type||"").toString().toLowerCase();return e==="video"||e==="mp4"?!0:Tl(t?.mediaUrl||t)}function Al(t){const e=t;return e?Array.isArray(e)?e:[e]:[]}const Nl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},bl={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},kl=({isModalOpen:t,handleModalClose:e,selectedRow:s,fetchAlertLogs:n,alertStatusList:r=[],alertStatusLoading:a=!1,initialTab:i="details",sourceTab:l})=>{const[c,u]=f.useState(),[h,m]=f.useState(""),[g,y]=f.useState(!1),A=f.useRef(null),[x,p]=f.useState("details"),[B,F]=f.useState(void 0),Z=Fs(),{alerts:J}=Oe(),{timeZoneDetails:K}=os(),[G,j]=f.useState(!1),[se,w]=f.useState(void 0),[k,O]=f.useState(void 0),[he,oe]=f.useState({}),[C,v]=f.useState({}),S=s?.originalData||{},{eventName:I,alertId:T,timestamp:D,description:N,spaceName:M,assignTeam:$,priority:P,statusType:W,id:z,alertDetails:Q,statusHistory:le,mediaDetails:Se,alertNumber:ce}=S,ue=E=>{const q=String(E||"").toLowerCase();return q==="delivered"||q==="sent"?"Delivered":q==="failed"?"Failed":"Queued"},xe=E=>({name:E?.receipientName||E?.recipientName||"-",role:E?.receipientRoleName||"",phone:E?.receipentPhoneNumber||E?.recipientPhoneNumber||E?.receipientEmail||E?.recipientEmail||"",status:ue(E?.messageStatus),notificationReceipientType:E?.notificationReceipientType||""}),Ae=(E,q)=>{const X=q.map(xe),ge=X.filter(Qe=>Qe.status==="Delivered").length,ke=q.map(Qe=>Qe?.sentAt).filter(Boolean).sort((Qe,ze)=>new Date(ze).getTime()-new Date(Qe).getTime())[0],ne=q[0]||{},Ze=[ne?.severityName,ne?.anomalyName].filter(Boolean).join(" - ")||`${E} Notification`;return{channelLabel:`${E} Notification`,sentAt:ke||"",messageTitle:Ze,messageBody:"",total:X.length,delivered:ge,recipients:X}},Ce=E=>{const q=new Map;return(E||[]).forEach(X=>{const ge=String(X?.notificationType||"Unknown"),ke=q.get(ge)||[];ke.push(X),q.set(ge,ke)}),Array.from(q.entries()).map(([X,ge])=>Ae(X,ge))},_e=async E=>{try{const q=await J.getAlertNotifications(E),X=Ce(q);F(X)}catch{F(void 0)}};f.useEffect(()=>{if(x!=="track"||!z)return;let E=!1;return _e(z).then(()=>{E&&F(void 0)}),()=>{E=!0}},[x,z]),f.useEffect(()=>{t&&p(i)},[t,i]);const ye=l==="archived"||["completed","false positive"].includes(String(W||"").toLowerCase()),ct=E=>{const q=String(E?.value||"").toLowerCase(),X=String(E?.statusName||"").toLowerCase();return q.includes("reopen")||X.includes("reopen")},Tt=(r||[]).filter(E=>{const q=ct(E);return typeof l<"u"?l==="archived"?q:!q:ye?q:!q}).map(E=>({value:E.value,label:E.statusName})),Je=f.useMemo(()=>Al(Se),[Se]);f.useEffect(()=>{let E=!1;const q=new AbortController,X=async ne=>{if(ne){E||oe(Ze=>({...Ze,[ne]:!1}));try{const Ze=await fetch(ne,{method:"HEAD",signal:q.signal});if(Ze.ok){E||oe(ze=>({...ze,[ne]:!0}));return}if(Ze.status===404){E||oe(ze=>({...ze,[ne]:!1}));return}if(!(await fetch(ne,{method:"GET",signal:q.signal})).ok)throw new Error("Media not available");E||oe(ze=>({...ze,[ne]:!0}))}catch{E||oe(Ze=>({...Ze,[ne]:!1}))}}};oe({});const ge=Je.filter(ne=>!Vn(ne)).map(ne=>ne?.mediaUrl||ne).filter(ne=>typeof ne=="string"&&ne.length>0),ke={};return ge.forEach(ne=>{ke[ne]=!0}),v(ke),ge.forEach(ne=>X(ne)),()=>{E=!0,q.abort()}},[Je]);const Rt=async()=>{try{y(!0);const E={alertUniqueId:T,alertId:z,status:c?String(c):void 0,notes:h.trim(),modifiedBy:0},q=await Z.mutateAsync(E);if(q?.responseStatus||q?.Success){const X=q?.Message||q?.data||"Alert updated successfully.";Te.toast.success(X,{autoClose:1500,onClose:()=>{n(),e()}}),u(void 0),m("")}else{const X=q?.errorMessage||q?.Message||"Failed to update alert status";Te.toast.error(X)}}catch(E){console.error("Error updating alert status:",E),Te.toast.error("Failed to update alert status. Please try again.")}finally{y(!1)}};return o.jsx(d.Modal,{open:t,onCancel:e,width:1e3,footer:x==="details"?o.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[o.jsx(d.Button,{onClick:e,className:"bg-[#6C757D] text-white",children:"Cancel"}),o.jsx(d.Button,{type:"primary",onClick:Rt,loading:g,children:g?"Saving...":"Save Changes"})]}):null,children:s&&o.jsx(d.Tabs,{activeKey:x,onChange:E=>p(E),items:[{key:"details",label:"Alert Detail",children:o.jsxs("div",{className:"grid grid-cols-2 gap-2",style:{maxHeight:"50vh",overflowY:"auto"},children:[o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsx("div",{className:"text-sm font-bold",children:I||"Alert Event"}),Q?.firstName?o.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",Q?.firstName," ",Q?.lastName||"","   ",Q?.residentId||""]}):null,o.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp: ",es(D,K?.ianaTimeZoneId)]}),o.jsxs("div",{className:"font-sm text-gray-500",children:[o.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",N||"No description available"]}),M&&o.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",M]}),$&&o.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",$]}),o.jsxs("div",{className:"flex gap-2 justify-start mt-3",children:[o.jsxs(d.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${Nl[String(P)]||"#DFE4EA"}`,backgroundColor:bl[String(P)]},children:["Severity: ",P||"N/A"]}),o.jsxs(d.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(W||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",W||"N/A"]})]}),o.jsx("div",{className:"w-full flex flex-col justify-start items-start mt-2 font-bold",children:o.jsxs("div",{className:"w-full mt-4",children:[o.jsx("div",{className:"flex flex-col gap-2",children:o.jsx(d.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:E=>u(E),value:c,options:Tt,loading:a})}),o.jsxs("div",{className:"flex flex-col gap-2 mt-3",children:[o.jsx("label",{htmlFor:"action-details-input",className:"text-xs text-gray-500 font-medium",children:"Action Taken (Comments)"}),o.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:E=>m(E.target.value)})]})]})})]}),o.jsx("div",{className:"flex flex-col gap-4",children:o.jsxs("div",{className:"w-full mt-1",children:[o.jsxs("div",{className:"w-full flex items-center justify-between",children:[o.jsx("h3",{className:"text-black font-bold text-sm",children:"Camera Footage"}),Je.length>1?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{type:"button",onClick:()=>A.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:o.jsx(it.LeftOutlined,{style:{fontSize:12}})}),o.jsx("button",{type:"button",onClick:()=>A.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:o.jsx(it.RightOutlined,{style:{fontSize:12}})})]}):null]}),Je.length?o.jsx("div",{className:"w-full",children:o.jsx(d.Carousel,{ref:A,dots:!0,className:"w-full",children:Je.map((E,q)=>{const X=E.mediaUrl||E,ge=Vn(E),ke=!ge&&C[String(X)];return o.jsxs("div",{className:"flex justify-center items-center relative",children:[ge?o.jsxs("video",{width:"240",height:"200",controls:!0,className:"max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg",children:[o.jsx("source",{src:X}),"Your browser does not support the video tag."]}):o.jsxs("div",{className:"relative w-full flex justify-center items-center min-h-[200px]",children:[ke&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg z-10",children:o.jsx(pl,{size:32,className:"animate-spin text-gray-400"})}),o.jsx("img",{src:X,alt:E.caption||`media-${q}`,className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg transition-opacity duration-200 ${ke?"opacity-0":"opacity-100"}`,onLoad:()=>v(ne=>({...ne,[String(X)]:!1})),onError:()=>v(ne=>({...ne,[String(X)]:!1}))},String(X))]}),E.caption&&o.jsx("p",{className:"text-xs text-gray-500 mt-1",children:E.caption}),!ge&&he[String(X)]?o.jsx("button",{onClick:()=>{j(!0),w(X),O(E.type||"image")},className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:o.jsx(ta,{size:20})}):null]},String(X)||q)})})}):null]})}),o.jsx(vl,{isOpen:G,onClose:()=>j(!1),src:se||"",type:k||"image"})]})},{key:"track",label:"Track Incident",children:o.jsx(ul,{alertId:T,id:z,priority:P,spaceName:M,alertNumber:ce,statusHistory:le,notifGroups:B})}]})})};function sa(){const{alerts:t}=Oe(),e=ot.useQuery({queryKey:["alerts","statusList"],queryFn:()=>t.getAlertStatusList(),staleTime:5*6e4});return{list:e.data??[],loading:e.isLoading,error:e.error,refetch:e.refetch}}function Gs({alerts:t,loading:e=!1,columns:s,onRefetch:n,onPageChange:r}){const[a,i]=f.useState(!1),[l,c]=f.useState(null),[u,h]=f.useState("details"),{list:m,loading:g}=sa(),{timeZoneDetails:y}=os(),A=y?.timeZoneName??"UTC",x=y?.ianaTimeZoneId??"UTC";function p(K,G){c(K),h(G?.tab??"details"),Z(G?.sourceTab??"active"),i(!0)}function B(){i(!1)}const[F,Z]=f.useState("active"),J=l?{originalData:{...l,alertId:l.alertId??l.id,mediaDetails:l.mediaDetails}}:null;return o.jsxs("div",{className:"p-6 flex flex-col items-start justify-start min-h-screen w-full overflow-auto",children:[o.jsxs("div",{className:"w-full grid grid-cols-3 sm:grid-cols-1 items-center mb-4",children:[o.jsx("h1",{className:"text-xl font-bold text-black",children:"Alert Console"}),o.jsx("div",{className:"flex items-center justify-start sm:justify-center",children:o.jsx(Jr,{label:A,timeZone:x})})]}),o.jsx(d.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:K=>{K==="active"&&n?.()},items:[{key:"active",label:"Active",children:o.jsx(Us,{data:t,loading:e,pageSize:10,columns:s||[],onAlertIdClick:p,onRefetch:n,onPageChange:r})},{key:"archived",label:"Archived",children:o.jsx(_r,{alerts:t,loading:e,columns:s||[],onAlertIdClick:p})},{key:"settings",label:"Settings",children:o.jsx(Il,{})}]}),o.jsx(kl,{isModalOpen:a,handleModalClose:B,selectedRow:J,fetchAlertLogs:()=>{},alertStatusList:m,alertStatusLoading:g,initialTab:u,sourceTab:F})]})}function Il(){const[t,e]=f.useState([]),[s,n]=f.useState([]),[r,a]=f.useState([]),[i,l]=f.useState([]),[c,u]=f.useState(!0),{rules:h}=Oe();return f.useEffect(()=>{let m=!0;return(async()=>{try{const g=await h.getRules();if(!m)return;l(Array.isArray(g)?g:[]);const y=(g||[]).map((A,x)=>({RuleId:A.ruleId||A.ruleName||String(x),Name:A.ruleName||A.Name||"-",Description:A.ruleDesc||A.Description||"",SeverityId:0}));e(y);try{const A=await h.getLookups(),x=Array.isArray(A?.userRoles)?A.userRoles.map(p=>({userRoleId:p.userRoleId??p.id,userRoleName:p.userRoleName??p.name})):[];n(x),a(Array.isArray(A?.severities)?A.severities:[])}catch{}}catch{}finally{m&&u(!1)}})(),()=>{m=!1}},[]),o.jsx(Xr,{severities:r,rules:t,userRoles:s,rawRules:i,loadingRules:c})}function na(t=1){const{alerts:e}=Oe(),s=ot.useQuery({queryKey:["alerts","list",t],queryFn:()=>e.listAlerts({pageNumber:t,pageSize:10}),staleTime:3e4});return{alerts:s.data??[],loading:s.isLoading,error:s.error,refetch:s.refetch}}function Ml(t){const[e,s]=f.useState(1),{alerts:n,loading:r,refetch:a}=na(e);return o.jsx(Gs,{alerts:n,loading:r,columns:t.columns,onRefetch:a,onPageChange:s})}function El({tenant:t,apiDomain:e,rulesDomain:s,headers:n,timeZone:r,userManagementDomain:a,alerts:i,loading:l,columns:c}){const[u]=f.useState(()=>new ot.QueryClient),h=f.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return o.jsx(ot.QueryClientProvider,{client:u,children:o.jsx(qn,{tenant:t,override:h,timeZone:r,userManagementDomain:a,children:Array.isArray(i)?o.jsx(Gs,{alerts:i,loading:!!l,columns:c}):o.jsx(Ml,{columns:c})})})}function Ol(t){const{alerts:e}=Oe(),s=ot.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 Cl=[{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=Qr;exports.AlertConsole=Gs;exports.AlertConsoleWidget=El;exports.AlertsTable=Us;exports.ApiProvider=qn;exports.ArchivedTable=_r;exports.Clock=Jr;exports.DataTable=Gn;exports.MyPreferencesPanel=al;exports.SettingsPanel=Kr;exports.SettingsTabs=Xr;exports.exampleAlertColumns=Cl;exports.useAlertStatusList=sa;exports.useAlerts=na;exports.useAlertsReport=Ol;exports.useApi=Oe;exports.useUpdateAlertStatus=Fs;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),f=require("react"),d=require("antd"),it=require("@ant-design/icons"),we=require("react-toastify"),ot=require("@tanstack/react-query"),ua="#FF3B30",da="#FF9500",ma="#FFCC00",fa="#34C759",Rt={critical:ua,high:da,medium:ma,low:fa},Xs={Critical:Rt.critical,High:Rt.high,Medium:Rt.medium,Low:Rt.low};function ha(t){return Xs[t]||Xs.Low}function en(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),i=Number.parseInt(n,10),l=Number.parseFloat(r||"0"),c=Number.isFinite(a)?a:0,u=Number.isFinite(i)?i:0,h=Number.isFinite(l)?l:0;return c*3600+u*60+h}function tn(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(i=>parseInt(String(i).trim(),10)).filter(i=>Number.isFinite(i)),r=new Set,a=[];return n.forEach(i=>{r.has(i)||(r.add(i),a.push(i))}),a}const Zn="",ya=Zn,ga="",pa="",Sa="",xa="",sn={snl:{alerts:Zn,rules:ya},schools:{alerts:ga,rules:pa},transit:{alerts:Sa,rules:xa}};function Ie(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function wa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Lt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Ee(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 i=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(i)}return a}function va(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=Ie(t.baseUrl,"/api/Alert"),n=await Ee(s,{method:"GET",headers:e});return Array.isArray(n)?n:[]},async getAlertStatusList(){const s=Ie(t.baseUrl,"/api/Alert/AlertStatusList"),n=await Ee(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=Ie(t.baseUrl,"/Alerts/GetAlertsReport"),r=Lt(n,s),a=await Ee(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Ie(t.baseUrl,"/api/Alert/status");return Ee(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=Ie(t.baseUrl,"/api/Alert/GetAdminSettings"),n=await Ee(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=Ie(t.baseUrl,"/api/Alert/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Ee(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Ie(t.baseUrl,"/api/Alert/GetPreferenceSettings"),n=await Ee(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=Ie(t.baseUrl,"/api/Alert/SetPreferenceSettings"),r=await Ee(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,i=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":r?.errorMessage??r?.message??"",statusCode:200,data:i}},async getAlertNotifications(s){const n=Ie(t.baseUrl,"/api/Alert/GetNotifications"),r=Lt(n,{alertId:s}),a=await Ee(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=Ie(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=Lt(n,{alertId:s});return Ee(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const a=Ie(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),i=Lt(a,{alertId:s,isEmail:n,isSMS:r});return Ee(i,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Ie(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Ee(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Ie(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Ee(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 nn(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ta(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Ut(t,e){const s={...e.headers,...Ta()},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 i=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(i)}return a}function Aa(t){const e={"Content-Type":"application/json",...t.headers||{}},s=nn(t.baseUrl,"/api/Rules"),n=nn(t.baseUrl,"/api/Rules/lookups");return{async getRules(){const r=await Ut(s,{method:"GET",headers:e});return Array.isArray(r)?r:[]},async setEscalationSettings(r){return Ut(s,{method:"POST",headers:e,body:JSON.stringify(r??{})})},async getLookups(){return Ut(n,{method:"GET",headers:e})},async updateRule(r,a){const i=`${s}/${r}`;return Ut(i,{method:"PUT",headers:e,body:JSON.stringify(a??{})})}}}function Na(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ht={exports:{}},ba=Ht.exports,rn;function ka(){return rn||(rn=1,(function(t,e){(function(s,n){t.exports=n()})(ba,(function(){var s=1e3,n=6e4,r=36e5,a="millisecond",i="second",l="minute",c="hour",u="day",h="week",m="month",g="quarter",y="year",T="date",S="Invalid Date",b=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,B=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,j={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(C){var w=["th","st","nd","rd"],x=C%100;return"["+C+(w[(x-20)%10]||w[x]||w[0])+"]"}},q=function(C,w,x){var I=String(C);return!I||I.length>=w?C:""+Array(w+1-I.length).join(x)+C},W={s:q,z:function(C){var w=-C.utcOffset(),x=Math.abs(w),I=Math.floor(x/60),v=x%60;return(w<=0?"+":"-")+q(I,2,"0")+":"+q(v,2,"0")},m:function C(w,x){if(w.date()<x.date())return-C(x,w);var I=12*(x.year()-w.year())+(x.month()-w.month()),v=w.clone().add(I,m),D=x-v<0,A=w.clone().add(I+(D?-1:1),m);return+(-(I+(x-v)/(D?v-A:A-v))||0)},a:function(C){return C<0?Math.ceil(C)||0:Math.floor(C)},p:function(C){return{M:m,y,w:h,d:u,D:T,h:c,m:l,s:i,ms:a,Q:g}[C]||String(C||"").toLowerCase().replace(/s$/,"")},u:function(C){return C===void 0}},Q="en",Y={};Y[Q]=j;var F="$isDayjsObject",se=function(C){return C instanceof he||!(!C||!C[F])},p=function C(w,x,I){var v;if(!w)return Q;if(typeof w=="string"){var D=w.toLowerCase();Y[D]&&(v=D),x&&(Y[D]=x,v=D);var A=w.split("-");if(!v&&A.length>1)return C(A[0])}else{var E=w.name;Y[E]=w,v=E}return!I&&v&&(Q=v),v||!I&&Q},k=function(C,w){if(se(C))return C.clone();var x=typeof w=="object"?w:{};return x.date=C,x.args=arguments,new he(x)},M=W;M.l=p,M.i=se,M.w=function(C,w){return k(C,{locale:w.$L,utc:w.$u,x:w.$x,$offset:w.$offset})};var he=(function(){function C(x){this.$L=p(x.locale,null,!0),this.parse(x),this.$x=this.$x||x.x||{},this[F]=!0}var w=C.prototype;return w.parse=function(x){this.$d=(function(I){var v=I.date,D=I.utc;if(v===null)return new Date(NaN);if(M.u(v))return new Date;if(v instanceof Date)return new Date(v);if(typeof v=="string"&&!/Z$/i.test(v)){var A=v.match(b);if(A){var E=A[2]-1||0,$=(A[7]||"0").substring(0,3);return D?new Date(Date.UTC(A[1],E,A[3]||1,A[4]||0,A[5]||0,A[6]||0,$)):new Date(A[1],E,A[3]||1,A[4]||0,A[5]||0,A[6]||0,$)}}return new Date(v)})(x),this.init()},w.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()},w.$utils=function(){return M},w.isValid=function(){return this.$d.toString()!==S},w.isSame=function(x,I){var v=k(x);return this.startOf(I)<=v&&v<=this.endOf(I)},w.isAfter=function(x,I){return k(x)<this.startOf(I)},w.isBefore=function(x,I){return this.endOf(I)<k(x)},w.$g=function(x,I,v){return M.u(x)?this[I]:this.set(v,x)},w.unix=function(){return Math.floor(this.valueOf()/1e3)},w.valueOf=function(){return this.$d.getTime()},w.startOf=function(x,I){var v=this,D=!!M.u(I)||I,A=M.p(x),E=function(ce,ue){var xe=M.w(v.$u?Date.UTC(v.$y,ue,ce):new Date(v.$y,ue,ce),v);return D?xe:xe.endOf(u)},$=function(ce,ue){return M.w(v.toDate()[ce].apply(v.toDate("s"),(D?[0,0,0,0]:[23,59,59,999]).slice(ue)),v)},P=this.$W,Z=this.$M,z=this.$D,K="set"+(this.$u?"UTC":"");switch(A){case y:return D?E(1,0):E(31,11);case m:return D?E(1,Z):E(0,Z+1);case h:var le=this.$locale().weekStart||0,Se=(P<le?P+7:P)-le;return E(D?z-Se:z+(6-Se),Z);case u:case T:return $(K+"Hours",0);case c:return $(K+"Minutes",1);case l:return $(K+"Seconds",2);case i:return $(K+"Milliseconds",3);default:return this.clone()}},w.endOf=function(x){return this.startOf(x,!1)},w.$set=function(x,I){var v,D=M.p(x),A="set"+(this.$u?"UTC":""),E=(v={},v[u]=A+"Date",v[T]=A+"Date",v[m]=A+"Month",v[y]=A+"FullYear",v[c]=A+"Hours",v[l]=A+"Minutes",v[i]=A+"Seconds",v[a]=A+"Milliseconds",v)[D],$=D===u?this.$D+(I-this.$W):I;if(D===m||D===y){var P=this.clone().set(T,1);P.$d[E]($),P.init(),this.$d=P.set(T,Math.min(this.$D,P.daysInMonth())).$d}else E&&this.$d[E]($);return this.init(),this},w.set=function(x,I){return this.clone().$set(x,I)},w.get=function(x){return this[M.p(x)]()},w.add=function(x,I){var v,D=this;x=Number(x);var A=M.p(I),E=function(Z){var z=k(D);return M.w(z.date(z.date()+Math.round(Z*x)),D)};if(A===m)return this.set(m,this.$M+x);if(A===y)return this.set(y,this.$y+x);if(A===u)return E(1);if(A===h)return E(7);var $=(v={},v[l]=n,v[c]=r,v[i]=s,v)[A]||1,P=this.$d.getTime()+x*$;return M.w(P,this)},w.subtract=function(x,I){return this.add(-1*x,I)},w.format=function(x){var I=this,v=this.$locale();if(!this.isValid())return v.invalidDate||S;var D=x||"YYYY-MM-DDTHH:mm:ssZ",A=M.z(this),E=this.$H,$=this.$m,P=this.$M,Z=v.weekdays,z=v.months,K=v.meridiem,le=function(ue,xe,Ae,Ce){return ue&&(ue[xe]||ue(I,D))||Ae[xe].slice(0,Ce)},Se=function(ue){return M.s(E%12||12,ue,"0")},ce=K||function(ue,xe,Ae){var Ce=ue<12?"AM":"PM";return Ae?Ce.toLowerCase():Ce};return D.replace(B,(function(ue,xe){return xe||(function(Ae){switch(Ae){case"YY":return String(I.$y).slice(-2);case"YYYY":return M.s(I.$y,4,"0");case"M":return P+1;case"MM":return M.s(P+1,2,"0");case"MMM":return le(v.monthsShort,P,z,3);case"MMMM":return le(z,P);case"D":return I.$D;case"DD":return M.s(I.$D,2,"0");case"d":return String(I.$W);case"dd":return le(v.weekdaysMin,I.$W,Z,2);case"ddd":return le(v.weekdaysShort,I.$W,Z,3);case"dddd":return Z[I.$W];case"H":return String(E);case"HH":return M.s(E,2,"0");case"h":return Se(1);case"hh":return Se(2);case"a":return ce(E,$,!0);case"A":return ce(E,$,!1);case"m":return String($);case"mm":return M.s($,2,"0");case"s":return String(I.$s);case"ss":return M.s(I.$s,2,"0");case"SSS":return M.s(I.$ms,3,"0");case"Z":return A}return null})(ue)||A.replace(":","")}))},w.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},w.diff=function(x,I,v){var D,A=this,E=M.p(I),$=k(x),P=($.utcOffset()-this.utcOffset())*n,Z=this-$,z=function(){return M.m(A,$)};switch(E){case y:D=z()/12;break;case m:D=z();break;case g:D=z()/3;break;case h:D=(Z-P)/6048e5;break;case u:D=(Z-P)/864e5;break;case c:D=Z/r;break;case l:D=Z/n;break;case i:D=Z/s;break;default:D=Z}return v?D:M.a(D)},w.daysInMonth=function(){return this.endOf(m).$D},w.$locale=function(){return Y[this.$L]},w.locale=function(x,I){if(!x)return this.$L;var v=this.clone(),D=p(x,I,!0);return D&&(v.$L=D),v},w.clone=function(){return M.w(this.$d,this)},w.toDate=function(){return new Date(this.valueOf())},w.toJSON=function(){return this.isValid()?this.toISOString():null},w.toISOString=function(){return this.$d.toISOString()},w.toString=function(){return this.$d.toUTCString()},C})(),oe=he.prototype;return k.prototype=oe,[["$ms",a],["$s",i],["$m",l],["$H",c],["$W",u],["$M",m],["$y",y],["$D",T]].forEach((function(C){oe[C[1]]=function(w){return this.$g(w,C[0],C[1])}})),k.extend=function(C,w){return C.$i||(C(w,he,k),C.$i=!0),k},k.locale=p,k.isDayjs=se,k.unix=function(C){return k(1e3*C)},k.en=Y[Q],k.Ls=Y,k.p={},k}))})(Ht)),Ht.exports}var Ia=ka();const Ea=Na(Ia);function zn(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 Hn(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 an(t){const{hours:e,minutes:s,seconds:n}=Hn(t);return Ea().hour(e).minute(s).second(n).millisecond(0)}function je(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ma(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function on(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 De(t,e){const s={...e.headers,...Ma()},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 i=a?.Message||`HTTP ${n.status}`;throw new Error(i)}return a}const de=(...t)=>t.find(e=>e!=null);function Nt(t,e,s={}){const n={};for(const r of e){const a=s[r]??r.charAt(0).toUpperCase()+r.slice(1);n[r]=t?.[a]??t?.[r]}return n}function Oa(t){return Array.isArray(t)?t.map(e=>Nt(e,["alertLogId","alertId","status","description","actionNotes","createdDate","createdBy","modifiedDate","modifiedBy"])):t}function Ca(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),spaceName:de(t?.SpaceName,t?.spaceName),assignTeam:de(t?.AssignTeam,t?.assignTeam),cameraName:de(t?.CameraName,t?.cameraName),type:de(t?.Type,t?.type),mediaDetails:de(t?.MediaDetails,t?.mediaDetails),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:Oa(de(t?.StatusHistory,t?.statusHistory)),isEmailSent:de(t?.IsEmailSent,t?.isEmailSent),isSMSSent:de(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:de(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function ja(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=je(t.baseUrl,"/api/detectionpolicy/alerts?customerId=99e5c8b5-b9d4-4d35-8885-7f121c532664"),n=await De(s,{method:"GET",headers:e});return Array.isArray(n?.Items)?(n?.Items).map(Ca):[]},async getAlertStatusList(){const s=je(t.baseUrl,"/api/detectionpolicy/alerts/StatusList"),n=await De(s,{method:"GET",headers:e});return(Array.isArray(n)?n:[]).map(a=>Nt(a,["alertStatusId","value","statusName"]))},async getAlertsReport(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),r=on(n,s),a=await De(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=je(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 De(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getAdminSettings(){const s=je(t.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),n=await De(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n.Data??n;if(r&&typeof r=="object")return Nt(r,["userId","isAdminSetting","sortBy"],{sortBy:"SortOption"})}return null},async setAdminSettings(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/SetAdminSettings"),r={Settings:{UserId:0,IsAdminSetting:!0,SortOption:s?.sortBy??"",GroupBy:s?.groupBy??null}};return De(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=je(t.baseUrl,"/api/detectionpolicy/alerts/GetPreferenceSettings"),n=await De(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=je(t.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),r=u=>{const{hours:h,minutes:m,seconds:g}=Hn(u);return(h*3600+m*60+g)*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??""}},i=await De(n,{method:"POST",headers:e,body:JSON.stringify(a)}),l=i?.responseStatus??!0,c=i?.data??i?.message??"Preferences updated successfully.";return{responseStatus:l,errorMessage:l?"":i?.errorMessage??i?.Message??i?.message??"",statusCode:200,data:c}},async getAlertNotifications(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),r=on(n,{alertId:s}),a=await De(r,{method:"GET",headers:e});let i=[];return Array.isArray(a)?i=a:Array.isArray(a?.data)&&(i=a.data),i.map(l=>Nt(l,["alertNotificationSentId","alertId","notificationType","receipientName","receipentPhoneNumber","messageSID","messageStatus","receipientEmail","notificationReceipientType","sentAt"]))},async getTimeZoneMasters(){const s=je(t.baseUrl,"/api/TimeZoneMaster"),n=await De(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n.Data:[]).map(a=>Nt(a,["timeZoneUniqueId","ianaTimeZoneId","timeZoneName","offset"]))},async getMyAppPreferences(){const s=je(t.baseUrl,"/MyProfile"),n=await De(s,{method:"GET",headers:e}),r=n?.data?.userGuid??n?.Data?.userGuid??n?.userGuid;if(!r)return null;const a=je(t.baseUrl,`/api/GetMyAppPreferences/${r}`),i=await De(a,{method:"GET",headers:e});if(i&&typeof i=="object"){const l=i.data??i.Data??i,c=l?.timeZoneUniqueId??l?.TimeZoneUniqueId;if(c)return{timeZoneUniqueId:c}}return null}}}function Da(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function He(t,e){const s={...e.headers,...Da()},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 i=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(i)}return a}function Ra(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/api/detectionpolicy/rules",t.baseUrl).toString();return{async getRules(){const n=await He(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 He(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=[He(n("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:e}),He(n("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:e}),He(n("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:e}),He(n("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:e}),He(n("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:e}),He(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[i,l,c,u,h,m]=await Promise.allSettled(a),g=p=>p.status==="fulfilled"&&Array.isArray(p.value)?p.value:[],y=g(i),T=g(l),S=g(c),b=g(u),B=g(h),j=m.status==="fulfilled"?m.value:null;let q=[];Array.isArray(j)?q=j:Array.isArray(j?.Data)?q=j.Data:Array.isArray(j?.data)&&(q=j.data);const W=y.map(p=>({actionTypeId:Number(p?.ActionTypeId),name:p?.DisplayName??p?.Name??""})),Q=T.map(p=>({recordId:p?.AnomalyId,anomalyName:p?.DisplayName??p?.Name??""})),Y=S.map(p=>({thirdPartyId:Number(p?.ThirdPartyId),thirdPartyName:p?.ThirdPartyName??p?.Name??""})),F=q.map(p=>({userRoleId:p.UserRoleId??p.userRoleId??p.Id??p.id??0,userRoleName:p.UserRoleName??p.userRoleName??p.Name??p.name??""})),se={actionTypes:W,anomalies:Q,thirdParties:Y};return b.length&&(se.severities=b),B.length&&(se.scheduleTypes=B),F.length&&(se.userRoles=F),se},async updateRule(n,r){const a=`${s}/${n}`,{escalationSettings:i,...l}=r??{};return He(a,{method:"PUT",headers:e,body:JSON.stringify({...l,CustomerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",Version:{DeDupWindowSeconds:0,IncludeSubjectInHash:!0},EscalationSettings:i??{}})})}}}function La(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Ke(t,e){const s={...e.headers,...La()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};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 i=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(i)}return a}function Ua(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/list-rule",t.baseUrl).toString();return{async getRules(){const n=await Ke(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 Ke(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=F=>new URL(F,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[Ke(n("/api/ActionTypeMaster/GetAll"),{method:"GET",headers:e}),Ke(n("/api/anomaly/anomaly-list"),{method:"POST",headers:e,body:JSON.stringify({RuleLevel:1})}),Ke(n("/api/Lookup/ThirdParties"),{method:"GET",headers:e}),Ke(n("/api/anomaly/severity-list"),{method:"GET",headers:e}),Ke(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[i,l,c,u,h]=await Promise.allSettled(a),m=F=>{if(F.status!=="fulfilled")return[];const se=F.value;return Array.isArray(se)?se:Array.isArray(se?.data)?se.data:[]},g=m(i),y=m(l),T=m(c),S=m(u),b=h.status==="fulfilled"?h.value:null,B=g.map(F=>({actionTypeId:F?.ActionTypeUniqueId,name:F?.Name??""})),j=y.map(F=>({recordId:F?.AnomalyId,anomalyName:F?.DisplayName??F?.Name??""})),q=T.map(F=>({thirdPartyId:Number(F?.ThirdPartyId),thirdPartyName:F?.ThirdPartyName??F?.Name??""}));let W=[];Array.isArray(b)?W=b:Array.isArray(b?.Data)?W=b.Data:Array.isArray(b?.data)&&(W=b.data);const Q=W.map(F=>({userRoleId:F.userRoleId??0,userRoleName:F.userRoleName??""})),Y={actionTypes:B,anomalies:j,thirdParties:q};return S.length&&(Y.severities=S.map(F=>({SeverityId:F.SeverityId,DisplayName:F.SeverityName??F.DisplayName??""}))),Q.length&&(Y.userRoles=Q),Y},async updateRule(n,r){const a=new URL("/update-rule",t.baseUrl).toString(),{escalationSettings:i,ruleId:l,ruleName:c,ruleDesc:u,...h}=r??{},m=i??{},g=(m.escalationSettingsActionTypeIds??[]).filter(T=>T!=null&&!Number.isNaN(T)),y={Level1UserRoleId:m.level1UserRoleId??0,Level1PostAssistTime:m.level1PostAssistTime??0,Level2UserRoleId:m.level2UserRoleId??0,Level2PostAssistTime:m.level2PostAssistTime??0,Level3UserRoleId:m.level3UserRoleId??0,Level3PostAssistTime:m.level3PostAssistTime??0,EscalationSettingsActionTypeIds:g,ThirdPartyIds:m.thirdPartyId??[],HumanLoop:m.humanLoop??!1};return Ke(a,{method:"POST",headers:e,body:JSON.stringify({...h,RuleId:l??h.RuleId??n,RuleName:c??h.RuleName,RuleDesc:u??h.RuleDesc??null,ActionTypeUniqueIdList:g,EscalationSettings:y})})}}}function Re(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 Ft(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,...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 i=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(i)}return a}function $a(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Re(t.baseUrl,"/api/Alerts"),r=Ft(n,{pageSize:s?.pageSize??10,pageNumber:s?.pageNumber??1}),a=await Le(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async getAlertStatusList(){const s=Re(t.baseUrl,"/api/Alerts/GetAlertStatus"),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=Re(t.baseUrl,"/Alerts/GetAlertsReport"),r=Ft(n,s),a=await Le(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Re(t.baseUrl,"/api/Alerts/UpdateAlertLog"),r={alertId:s.alertId,action:s.status,notes:s.notes};return Le(n,{method:"PUT",headers:e,body:JSON.stringify(r??{})})},async getAdminSettings(){const s=Re(t.baseUrl,"/api/Alerts/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=Re(t.baseUrl,"/api/Alerts/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=Re(t.baseUrl,"/api/Alerts/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=Re(t.baseUrl,"/api/Alerts/SetPreferenceSettings"),r=await Le(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,i=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":r?.errorMessage??r?.message??"",statusCode:200,data:i}},async getAlertNotifications(s){const n=Re(t.baseUrl,"/api/Alerts/GetNotifications"),r=Ft(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 sendSMSorEmailNotifications(s,n,r){const a=Re(t.baseUrl,"/api/Alerts/SendSMSorEmailNotifications"),i=Ft(a,{alertId:s,isEmail:n,isSMS:r});return Le(i,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Re(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=Re(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}}}const qn=f.createContext(null);function Gn({tenant:t="snl",override:e,timeZone:s,userManagementDomain:n,children:r}){const a=f.useMemo(()=>{const l=e?.alertsBaseUrl?.trim()||sn[t]?.alerts||"";let c=e?.rulesBaseUrl?.trim()||sn[t]?.rules||"";t==="snl"&&(c=l);const u=e?.headers;return{tenant:t,alertsBaseUrl:l,rulesBaseUrl:c,headers:u,timeZone:s,userManagementDomain:n}},[t,e?.alertsBaseUrl,e?.rulesBaseUrl,JSON.stringify(e?.headers||{}),s,n]),i=f.useMemo(()=>{const l={baseUrl:a.alertsBaseUrl,headers:a.headers},c={baseUrl:a.rulesBaseUrl,headers:a.headers},u={schools:()=>ja(l),transit:()=>$a(l),snl:()=>va(l)},h={schools:()=>Ra({...c,userManagementBaseUrl:a.userManagementDomain}),transit:()=>Ua({...c,userManagementBaseUrl:a.userManagementDomain}),snl:()=>Aa({baseUrl:a.alertsBaseUrl,headers:a.headers})};return{config:a,alerts:u[a.tenant](),rules:h[a.tenant]()}},[a]);return o.jsx(qn.Provider,{value:i,children:r})}function Oe(){const t=f.useContext(qn);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}const Pa={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Wa={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Ls=6,Us=7;function ln(t,e,s){const n=t===Ls,r=t===Us,a=e.isEmailSent??!1,i=e.isSMSSent??!1,l=n&&a||r&&i,c=n?"Send Email":r?"Send SMS":s,u=n&&a?"Email sent":r&&i?"SMS sent":c,h=n&&a?"Email sent":r&&i?"SMS sent":`Click to ${c}`;return{isDisabled:l,buttonText:u,tooltipTitle:h}}function Va(t){const e=new Set;(t||[]).forEach(n=>{const r=n.anomalyName;typeof r=="string"&&r.trim().length>0&&e.add(r.trim())});const s=Array.from(e).map(n=>({label:n,value:n}));return[{label:"All Types",value:"All"},...s]}function Ba(t){const e=new Set;(t||[]).forEach(n=>{const r=n.spaceName;typeof r=="string"&&r.trim().length>0&&e.add(r.trim())});const s=Array.from(e).map(n=>({label:n,value:n}));return[{label:"All",value:"All"},...s]}function ms(t,e){return`${t}-${e?"email":"sms"}`}function $t(t){return t===Ls||t===Us}function es({value:t,onChange:e,options:s,className:n,dropdownWidth:r}){return o.jsx(d.Select,{className:n,options:s,value:t,onChange:e,dropdownMatchSelectWidth:r??260})}const Za=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function za({value:t,onChange:e,options:s}){return o.jsx(es,{className:"w-[140px]",value:t,onChange:e,options:s||Za})}const Ha=[{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 o.jsx(es,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||Ha})}function Ga({value:t,onChange:e,options:s}){return o.jsx(es,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const Ya=[{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 _a({value:t,onChange:e,options:s}){return o.jsx(es,{className:"w-[130px]",value:t,onChange:e,options:s||Ya})}function Yn({columns:t,data:e,loading:s=!1,pageSize:n=10,rowKey:r="id",toolbar:a,tableProps:i,onPageChange:l}){return o.jsxs("div",{children:[a,o.jsx(d.Table,{rowKey:r,dataSource:e,columns:t,loading:s,pagination:{pageSize:n,showSizeChanger:!0,showTotal:c=>`Total: ${c}`,onChange:l},bordered:!0,...i})]})}function Fs({data:t,loading:e=!1,pageSize:s=10,columns:n,severityOptions:r,spaceOptions:a,renderActions:i,onAlertIdClick:l,onRefetch:c,onPageChange:u,excludeCompleted:h=!0}){const[m,g]=f.useState("All"),[y,T]=f.useState("All"),[S,b]=f.useState("All"),[B,j]=f.useState("All"),[q,W]=f.useState(""),[Q,Y]=f.useState([{label:"All",value:"All"}]),[F,se]=f.useState(new Set),{rules:p,alerts:k}=Oe(),M={6:{title:"Email",kind:"icon",icon:o.jsx(it.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:o.jsx(it.MessageOutlined,{})}},he=f.useMemo(()=>Va(t),[t]),oe=f.useMemo(()=>Ba(t),[t]);f.useEffect(()=>{let A=!0;return(async()=>{try{const E=await p.getLookups(),P=(Array.isArray(E.thirdParties)?E.thirdParties:[]).map(Z=>({label:Z.thirdPartyName,value:String(Z.thirdPartyId)}));A&&Y([{label:"All",value:"All"},...P])}catch(E){console.error("Error loading third party options",E)}})(),()=>{A=!1}},[p]);const C=f.useMemo(()=>(t||[]).some(A=>tn(A).length>0),[t]),w=f.useMemo(()=>(t||[]).filter(A=>{const E=m==="All"||A.priority===m,$=`${A.id} ${A.description} ${A.statusType}`.toLowerCase(),P=!q||$.includes(q.toLowerCase()),Z=y==="All"||(A.anomalyName||"").toLowerCase()===y.toLowerCase(),z=S==="All"||(A.spaceName||"").toLowerCase()===S.toLowerCase(),K=!C||B==="All"||tn(A).includes(Number(B)),le=!h||!["completed","false positive"].includes(String(A.statusType||"").toLowerCase());return E&&P&&Z&&z&&K&&le}),[t,m,q,y,S,B,C,h]),x=he,I=a?.length?a:oe,v=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:A=>o.jsx(d.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Wa[A]}`,backgroundColor:Pa[A]},children:A})},{title:"Tracker",key:"tracker",width:140,render:(A,E)=>o.jsx("a",{onClick:$=>{$.preventDefault(),l?.(E,{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:(A,E)=>{if(i)return o.jsx(o.Fragment,{children:i(E)});const $=async(Ce,_e)=>{const vt=ms(E.id,Ce);se(ye=>new Set(ye).add(vt));try{const ye=await k.sendSMSorEmailNotifications?.(E.id,Ce,_e);ye?.responseStatus||ye?.Success||ye?.success?(we.toast.success(ye?.message||ye.data||(Ce?"Email sent successfully":"SMS sent successfully")),c?.()):we.toast.error(ye?.message||ye?.data||ye?.errorMessage||"Failed to send notification")}catch(ye){we.toast.error(ye?.message||"Failed to send notification")}finally{se(ye=>{const ct=new Set(ye);return ct.delete(vt),ct})}},P=Ls,Z=Us,z=M[P],K=M[Z],le=ln(P,E,z?.title),Se=ln(Z,E,K?.title),ce=ms(E.id,!0),ue=ms(E.id,!1),xe=$t(P)&&F.has(ce),Ae=$t(Z)&&F.has(ue);return o.jsxs(d.Space,{size:"middle",children:[o.jsx(d.Tooltip,{title:le.tooltipTitle,children:o.jsx(d.Button,{size:"small",disabled:le.isDisabled,loading:xe,onClick:$t(P)?()=>$(!0,!1):void 0,icon:!xe&&z?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:le.buttonText})},String(P)),o.jsx(d.Tooltip,{title:Se.tooltipTitle,children:o.jsx(d.Button,{size:"small",disabled:Se.isDisabled,loading:Ae,onClick:$t(Z)?()=>$(!1,!0):void 0,icon:!Ae&&K?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:Se.buttonText})},String(Z))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(A,E)=>{const $=E?.timeElapsed,P=E?.timeRemaining,Z=$?en($):0,z=P?en(P):0,K=Math.round(Z/(Z+z)*100);return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-[70px]",children:"Elapsed:"}),o.jsx("span",{className:"font-medium",children:$??"-"})]}),o.jsx(d.Progress,{percent:K,showInfo:!1,size:"small",strokeColor:ha(E.priority)}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-[70px]",children:"Remaining"}),o.jsx("span",{className:"font-medium",children:P??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(A,E)=>o.jsxs("div",{children:[o.jsx("a",{onClick:$=>{$.preventDefault(),l?.(E,{sourceTab:"active"})},className:"inline-block mb-1 text-blue-600",children:E.alertNumber}),o.jsx("div",{className:"text-black/65",children:A})]})}],D=n&&n.length?n:v;return o.jsx("div",{children:o.jsx(Yn,{rowKey:"id",data:w,columns:D,loading:e,pageSize:s,onPageChange:u,toolbar:o.jsxs(d.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[o.jsx(d.Col,{flex:"none",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{children:"Severity"}),o.jsx(za,{value:m,onChange:g,options:r})]})}),o.jsx(d.Col,{flex:"none",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{children:"Anomaly type"}),o.jsx(qa,{value:y,onChange:T,options:x})]})}),o.jsx(d.Col,{flex:"none",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{children:"Space"}),o.jsx(Ga,{value:S,onChange:b,options:I})]})}),o.jsx(d.Col,{flex:"none",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{children:"Action Taken"}),o.jsx(_a,{value:B,onChange:j,options:Q})]})}),o.jsx(d.Col,{flex:"auto"}),o.jsx(d.Col,{flex:"none",children:o.jsx(d.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:W,onChange:A=>W(A.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}function $s(){const{alerts:t}=Oe(),e=ot.useQueryClient();return ot.useMutation({mutationFn:s=>t.updateAlertStatus(s),onSuccess:()=>{e.invalidateQueries({queryKey:["alerts","list"]}),e.invalidateQueries({queryKey:["alerts","report"]})}})}class lt extends Error{}class Ja extends lt{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class Qa extends lt{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class Ka extends lt{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class ft extends lt{}class _n extends lt{constructor(e){super(`Invalid unit ${e}`)}}class ve extends lt{}class Xe extends lt{constructor(){super("Zone is an abstract class")}}const N="numeric",Be="short",Me="long",_t={year:N,month:N,day:N},Jn={year:N,month:Be,day:N},Xa={year:N,month:Be,day:N,weekday:Be},Qn={year:N,month:Me,day:N},Kn={year:N,month:Me,day:N,weekday:Me},Xn={hour:N,minute:N},er={hour:N,minute:N,second:N},tr={hour:N,minute:N,second:N,timeZoneName:Be},sr={hour:N,minute:N,second:N,timeZoneName:Me},nr={hour:N,minute:N,hourCycle:"h23"},rr={hour:N,minute:N,second:N,hourCycle:"h23"},ar={hour:N,minute:N,second:N,hourCycle:"h23",timeZoneName:Be},ir={hour:N,minute:N,second:N,hourCycle:"h23",timeZoneName:Me},or={year:N,month:N,day:N,hour:N,minute:N},lr={year:N,month:N,day:N,hour:N,minute:N,second:N},cr={year:N,month:Be,day:N,hour:N,minute:N},ur={year:N,month:Be,day:N,hour:N,minute:N,second:N},ei={year:N,month:Be,day:N,weekday:Be,hour:N,minute:N},dr={year:N,month:Me,day:N,hour:N,minute:N,timeZoneName:Be},mr={year:N,month:Me,day:N,hour:N,minute:N,second:N,timeZoneName:Be},fr={year:N,month:Me,day:N,weekday:Me,hour:N,minute:N,timeZoneName:Me},hr={year:N,month:Me,day:N,weekday:Me,hour:N,minute:N,second:N,timeZoneName:Me};class Ot{get type(){throw new Xe}get name(){throw new Xe}get ianaName(){return this.name}get isUniversal(){throw new Xe}offsetName(e,s){throw new Xe}formatOffset(e,s){throw new Xe}offset(e){throw new Xe}equals(e){throw new Xe}get isValid(){throw new Xe}}let fs=null;class ts extends Ot{static get instance(){return fs===null&&(fs=new ts),fs}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return br(e,s,n)}formatOffset(e,s){return Et(this.offset(e),s)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}}const As=new Map;function ti(t){let e=As.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"}),As.set(t,e)),e}const si={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function ni(t,e){const s=t.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(s),[,r,a,i,l,c,u,h]=n;return[i,r,a,l,c,u,h]}function ri(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:a,value:i}=s[r],l=si[a];a==="era"?n[l]=i:U(l)||(n[l]=parseInt(i,10))}return n}const hs=new Map;class Ye extends Ot{static create(e){let s=hs.get(e);return s===void 0&&hs.set(e,s=new Ye(e)),s}static resetCache(){hs.clear(),As.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=Ye.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return br(e,s,n,this.name)}formatOffset(e,s){return Et(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,i,l,c,u,h]=n.formatToParts?ri(n,s):ni(n,s);l==="BC"&&(r=-Math.abs(r)+1);const g=ns({year:r,month:a,day:i,hour:c===24?0:c,minute:u,second:h,millisecond:0});let y=+s;const T=y%1e3;return y-=T>=0?T:1e3+T,(g-y)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let cn={};function ai(t,e={}){const s=JSON.stringify([t,e]);let n=cn[s];return n||(n=new Intl.ListFormat(t,e),cn[s]=n),n}const Ns=new Map;function bs(t,e={}){const s=JSON.stringify([t,e]);let n=Ns.get(s);return n===void 0&&(n=new Intl.DateTimeFormat(t,e),Ns.set(s,n)),n}const ks=new Map;function ii(t,e={}){const s=JSON.stringify([t,e]);let n=ks.get(s);return n===void 0&&(n=new Intl.NumberFormat(t,e),ks.set(s,n)),n}const Is=new Map;function oi(t,e={}){const{base:s,...n}=e,r=JSON.stringify([t,n]);let a=Is.get(r);return a===void 0&&(a=new Intl.RelativeTimeFormat(t,e),Is.set(r,a)),a}let bt=null;function li(){return bt||(bt=new Intl.DateTimeFormat().resolvedOptions().locale,bt)}const Es=new Map;function yr(t){let e=Es.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),Es.set(t,e)),e}const Ms=new Map;function ci(t){let e=Ms.get(t);if(!e){const s=new Intl.Locale(t);e="getWeekInfo"in s?s.getWeekInfo():s.weekInfo,"minimalDays"in e||(e={...gr,...e}),Ms.set(t,e)}return e}function ui(t){const e=t.indexOf("-x-");e!==-1&&(t=t.substring(0,e));const s=t.indexOf("-u-");if(s===-1)return[t];{let n,r;try{n=bs(t).resolvedOptions(),r=t}catch{const c=t.substring(0,s);n=bs(c).resolvedOptions(),r=c}const{numberingSystem:a,calendar:i}=n;return[r,a,i]}}function di(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function mi(t){const e=[];for(let s=1;s<=12;s++){const n=L.utc(2009,s,1);e.push(t(n))}return e}function fi(t){const e=[];for(let s=1;s<=7;s++){const n=L.utc(2016,11,13+s);e.push(t(n))}return e}function Pt(t,e,s,n){const r=t.listingMode();return r==="error"?null:r==="en"?s(e):n(e)}function hi(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||yr(t.locale).numberingSystem==="latn"}class yi{constructor(e,s,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;const{padTo:r,floor:a,...i}=n;if(!s||Object.keys(i).length>0){const l={useGrouping:!1,...n};n.padTo>0&&(l.minimumIntegerDigits=n.padTo),this.inf=ii(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):Zs(e,3);return pe(s,this.padTo)}}}class gi{constructor(e,s,n){this.opts=n,this.originalZone=void 0;let r;if(this.opts.timeZone)this.dt=e;else if(e.zone.type==="fixed"){const i=-1*(e.offset/60),l=i>=0?`Etc/GMT+${i}`:`Etc/GMT${i}`;e.offset!==0&&Ye.create(l).valid?(r=l,this.dt=e):(r="UTC",this.dt=e.offset===0?e:e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type==="system"?this.dt=e:e.zone.type==="iana"?(this.dt=e,r=e.zone.name):(r="UTC",this.dt=e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone);const a={...this.opts};a.timeZone=a.timeZone||r,this.dtf=bs(s,a)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(s=>{if(s.type==="timeZoneName"){const n=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...s,value:n}}else return s}):e}resolvedOptions(){return this.dtf.resolvedOptions()}}class pi{constructor(e,s,n){this.opts={style:"long",...n},!s&&Ar()&&(this.rtf=oi(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):Pi(s,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,s){return this.rtf?this.rtf.formatToParts(e,s):[]}}const gr={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 i=e||fe.defaultLocale,l=i||(a?"en-US":li()),c=s||fe.defaultNumberingSystem,u=n||fe.defaultOutputCalendar,h=Cs(r)||fe.defaultWeekSettings;return new te(l,c,u,h,i)}static resetCache(){bt=null,Ns.clear(),ks.clear(),Is.clear(),Es.clear(),Ms.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[i,l,c]=ui(e);this.locale=i,this.numberingSystem=s||l||null,this.outputCalendar=n||c||null,this.weekSettings=r,this.intl=di(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=a,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=hi(this)),this.fastNumbersCached}listingMode(){const e=this.isEnglish(),s=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return e&&s?"en":"intl"}clone(e){return!e||Object.getOwnPropertyNames(e).length===0?this:te.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,Cs(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 Pt(this,e,Er,()=>{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 i=n?l=>this.dtFormatter(l,r).format():l=>this.extract(l,r,"month");this.monthsCache[a][e]=mi(i)}return this.monthsCache[a][e]})}weekdays(e,s=!1){return Pt(this,e,Cr,()=>{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]=fi(a=>this.extract(a,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return Pt(this,void 0,()=>jr,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[L.utc(2016,11,13,9),L.utc(2016,11,13,19)].map(s=>this.extract(s,e,"dayperiod"))}return this.meridiemCache})}eras(e){return Pt(this,e,Dr,()=>{const s={era:e};return this.eraCache[e]||(this.eraCache[e]=[L.utc(-40,1,1),L.utc(2017,1,1)].map(n=>this.extract(n,s,"era"))),this.eraCache[e]})}extract(e,s,n){const r=this.dtFormatter(e,s),a=r.formatToParts(),i=a.find(l=>l.type.toLowerCase()===n);return i?i.value:null}numberFormatter(e={}){return new yi(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new gi(e,this.intl,s)}relFormatter(e={}){return new pi(this.intl,this.isEnglish(),e)}listFormatter(e={}){return ai(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||yr(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:Nr()?ci(this.locale):gr}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 ys=null;class be extends Ot{static get utcInstance(){return ys===null&&(ys=new be(0)),ys}static instance(e){return e===0?be.utcInstance:new be(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new be(rs(s[1],s[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Et(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Et(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,s){return Et(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 Si extends Ot{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 tt(t,e){if(U(t)||t===null)return e;if(t instanceof Ot)return t;if(Ni(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?ts.instance:s==="utc"||s==="gmt"?be.utcInstance:be.parseSpecifier(s)||Ye.create(t)}else return st(t)?be.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new Si(t)}const Ps={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},un={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]},xi=Ps.hanidec.replace(/[\[|\]]/g,"").split("");function wi(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(Ps.hanidec)!==-1)e+=xi.indexOf(t[s]);else for(const r in un){const[a,i]=un[r];n>=a&&n<=i&&(e+=n-a)}}return parseInt(e,10)}else return e}const Os=new Map;function vi(){Os.clear()}function Pe({numberingSystem:t},e=""){const s=t||"latn";let n=Os.get(s);n===void 0&&(n=new Map,Os.set(s,n));let r=n.get(e);return r===void 0&&(r=new RegExp(`${Ps[s]}${e}`),n.set(e,r)),r}let dn=()=>Date.now(),mn="system",fn=null,hn=null,yn=null,gn=60,pn,Sn=null;class fe{static get now(){return dn}static set now(e){dn=e}static set defaultZone(e){mn=e}static get defaultZone(){return tt(mn,ts.instance)}static get defaultLocale(){return fn}static set defaultLocale(e){fn=e}static get defaultNumberingSystem(){return hn}static set defaultNumberingSystem(e){hn=e}static get defaultOutputCalendar(){return yn}static set defaultOutputCalendar(e){yn=e}static get defaultWeekSettings(){return Sn}static set defaultWeekSettings(e){Sn=Cs(e)}static get twoDigitCutoffYear(){return gn}static set twoDigitCutoffYear(e){gn=e%100}static get throwOnInvalid(){return pn}static set throwOnInvalid(e){pn=e}static resetCaches(){te.resetCache(),Ye.resetCache(),L.resetCache(),vi()}}class Ve{constructor(e,s){this.reason=e,this.explanation=s}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const pr=[0,31,59,90,120,151,181,212,243,273,304,334],Sr=[0,31,60,91,121,152,182,213,244,274,305,335];function Fe(t,e){return new Ve("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function Ws(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 xr(t,e,s){return s+(Ct(t)?Sr:pr)[e-1]}function wr(t,e){const s=Ct(t)?Sr:pr,n=s.findIndex(a=>a<e),r=e-s[n];return{month:n+1,day:r}}function Vs(t,e){return(t-e+7)%7+1}function Jt(t,e=4,s=1){const{year:n,month:r,day:a}=t,i=xr(n,r,a),l=Vs(Ws(n,r,a),s);let c=Math.floor((i-l+14-e)/7),u;return c<1?(u=n-1,c=Mt(u,e,s)):c>Mt(n,e,s)?(u=n+1,c=1):u=n,{weekYear:u,weekNumber:c,weekday:l,...as(t)}}function xn(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:a}=t,i=Vs(Ws(n,1,e),s),l=ht(n);let c=r*7+a-i-7+e,u;c<1?(u=n-1,c+=ht(u)):c>l?(u=n+1,c-=ht(n)):u=n;const{month:h,day:m}=wr(u,c);return{year:u,month:h,day:m,...as(t)}}function gs(t){const{year:e,month:s,day:n}=t,r=xr(e,s,n);return{year:e,ordinal:r,...as(t)}}function wn(t){const{year:e,ordinal:s}=t,{month:n,day:r}=wr(e,s);return{year:e,month:n,day:r,...as(t)}}function vn(t,e){if(!U(t.localWeekday)||!U(t.localWeekNumber)||!U(t.localWeekYear)){if(!U(t.weekday)||!U(t.weekNumber)||!U(t.weekYear))throw new ft("Cannot mix locale-based week fields with ISO-based week fields");return U(t.localWeekday)||(t.weekday=t.localWeekday),U(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),U(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 Ti(t,e=4,s=1){const n=ss(t.weekYear),r=$e(t.weekNumber,1,Mt(t.weekYear,e,s)),a=$e(t.weekday,1,7);return n?r?a?!1:Fe("weekday",t.weekday):Fe("week",t.weekNumber):Fe("weekYear",t.weekYear)}function Ai(t){const e=ss(t.year),s=$e(t.ordinal,1,ht(t.year));return e?s?!1:Fe("ordinal",t.ordinal):Fe("year",t.year)}function vr(t){const e=ss(t.year),s=$e(t.month,1,12),n=$e(t.day,1,Qt(t.year,t.month));return e?s?n?!1:Fe("day",t.day):Fe("month",t.month):Fe("year",t.year)}function Tr(t){const{hour:e,minute:s,second:n,millisecond:r}=t,a=$e(e,0,23)||e===24&&s===0&&n===0&&r===0,i=$e(s,0,59),l=$e(n,0,59),c=$e(r,0,999);return a?i?l?c?!1:Fe("millisecond",r):Fe("second",n):Fe("minute",s):Fe("hour",e)}function U(t){return typeof t>"u"}function st(t){return typeof t=="number"}function ss(t){return typeof t=="number"&&t%1===0}function Ni(t){return typeof t=="string"}function bi(t){return Object.prototype.toString.call(t)==="[object Date]"}function Ar(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function Nr(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function ki(t){return Array.isArray(t)?t:[t]}function Tn(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 Ii(t,e){return e.reduce((s,n)=>(s[n]=t[n],s),{})}function gt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Cs(t){if(t==null)return null;if(typeof t!="object")throw new ve("Week settings must be an object");if(!$e(t.firstDay,1,7)||!$e(t.minimalDays,1,7)||!Array.isArray(t.weekend)||t.weekend.some(e=>!$e(e,1,7)))throw new ve("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function $e(t,e,s){return ss(t)&&t>=e&&t<=s}function Ei(t,e){return t-e*Math.floor(t/e)}function pe(t,e=2){const s=t<0;let n;return s?n="-"+(""+-t).padStart(e,"0"):n=(""+t).padStart(e,"0"),n}function et(t){if(!(U(t)||t===null||t===""))return parseInt(t,10)}function nt(t){if(!(U(t)||t===null||t===""))return parseFloat(t)}function Bs(t){if(!(U(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function Zs(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 Ct(t){return t%4===0&&(t%100!==0||t%400===0)}function ht(t){return Ct(t)?366:365}function Qt(t,e){const s=Ei(e-1,12)+1,n=t+(e-s)/12;return s===2?Ct(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][s-1]}function ns(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 An(t,e,s){return-Vs(Ws(t,1,e),s)+e-1}function Mt(t,e=4,s=1){const n=An(t,e,s),r=An(t+1,e,s);return(ht(t)-n+r)/7}function js(t){return t>99?t:t>fe.twoDigitCutoffYear?1900+t:2e3+t}function br(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 i={timeZoneName:e,...a},l=new Intl.DateTimeFormat(s,i).formatToParts(r).find(c=>c.type.toLowerCase()==="timezonename");return l?l.value:null}function rs(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 kr(t){const e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new ve(`Invalid unit value ${t}`);return e}function Kt(t,e){const s={};for(const n in t)if(gt(t,n)){const r=t[n];if(r==null)continue;s[e(n)]=kr(r)}return s}function Et(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}${pe(s,2)}:${pe(n,2)}`;case"narrow":return`${r}${s}${n>0?`:${n}`:""}`;case"techie":return`${r}${pe(s,2)}${pe(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function as(t){return Ii(t,["hour","minute","second","millisecond"])}const Mi=["January","February","March","April","May","June","July","August","September","October","November","December"],Ir=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Oi=["J","F","M","A","M","J","J","A","S","O","N","D"];function Er(t){switch(t){case"narrow":return[...Oi];case"short":return[...Ir];case"long":return[...Mi];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 Mr=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Or=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Ci=["M","T","W","T","F","S","S"];function Cr(t){switch(t){case"narrow":return[...Ci];case"short":return[...Or];case"long":return[...Mr];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const jr=["AM","PM"],ji=["Before Christ","Anno Domini"],Di=["BC","AD"],Ri=["B","A"];function Dr(t){switch(t){case"narrow":return[...Ri];case"short":return[...Di];case"long":return[...ji];default:return null}}function Li(t){return jr[t.hour<12?0:1]}function Ui(t,e){return Cr(e)[t.weekday-1]}function Fi(t,e){return Er(e)[t.month-1]}function $i(t,e){return Dr(e)[t.year<0?0:1]}function Pi(t,e,s="always",n=!1){const r={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},a=["hours","minutes","seconds"].indexOf(t)===-1;if(s==="auto"&&a){const m=t==="days";switch(e){case 1:return m?"tomorrow":`next ${r[t][0]}`;case-1:return m?"yesterday":`last ${r[t][0]}`;case 0:return m?"today":`this ${r[t][0]}`}}const i=Object.is(e,-0)||e<0,l=Math.abs(e),c=l===1,u=r[t],h=n?c?u[1]:u[2]||u[1]:c?r[t][0]:t;return i?`${l} ${h} ago`:`in ${l} ${h}`}function Nn(t,e){let s="";for(const n of t)n.literal?s+=n.val:s+=e(n.val);return s}const Wi={D:_t,DD:Jn,DDD:Qn,DDDD:Kn,t:Xn,tt:er,ttt:tr,tttt:sr,T:nr,TT:rr,TTT:ar,TTTT:ir,f:or,ff:cr,fff:dr,ffff:fr,F:lr,FF:ur,FFF:mr,FFFF:hr};class Te{static create(e,s={}){return new Te(e,s)}static parseFormat(e){let s=null,n="",r=!1;const a=[];for(let i=0;i<e.length;i++){const l=e.charAt(i);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 Wi[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 pe(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=(y,T)=>this.loc.extract(e,y,T),i=y=>e.isOffsetFixed&&e.offset===0&&y.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,y.format):"",l=()=>n?Li(e):a({hour:"numeric",hourCycle:"h12"},"dayperiod"),c=(y,T)=>n?Fi(e,y):a(T?{month:y}:{month:y,day:"numeric"},"month"),u=(y,T)=>n?Ui(e,y):a(T?{weekday:y}:{weekday:y,month:"long",day:"numeric"},"weekday"),h=y=>{const T=Te.macroTokenToFormatOpts(y);return T?this.formatWithSystemDefault(e,T):y},m=y=>n?$i(e,y):a({era:y},"era"),g=y=>{switch(y){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 i({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return i({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return i({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return l();case"d":return r?a({day:"numeric"},"day"):this.num(e.day);case"dd":return r?a({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return u("short",!0);case"cccc":return u("long",!0);case"ccccc":return u("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return u("short",!1);case"EEEE":return u("long",!1);case"EEEEE":return u("narrow",!1);case"L":return r?a({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?a({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return c("short",!0);case"LLLL":return c("long",!0);case"LLLLL":return c("narrow",!0);case"M":return r?a({month:"numeric"},"month"):this.num(e.month);case"MM":return r?a({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return c("short",!1);case"MMMM":return c("long",!1);case"MMMMM":return c("narrow",!1);case"y":return r?a({year:"numeric"},"year"):this.num(e.year);case"yy":return r?a({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?a({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?a({year:"numeric"},"year"):this.num(e.year,6);case"G":return m("short");case"GG":return m("long");case"GGGGG":return m("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return h(y)}};return Nn(Te.parseFormat(s),g)}formatDurationFromString(e,s){const n=this.opts.signMode==="negativeLargestOnly"?-1:1,r=h=>{switch(h[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=(h,m)=>g=>{const y=r(g);if(y){const T=m.isNegativeDuration&&y!==m.largestUnit?n:1;let S;return this.opts.signMode==="negativeLargestOnly"&&y!==m.largestUnit?S="never":this.opts.signMode==="all"?S="always":S="auto",this.num(h.get(y)*T,g.length,S)}else return g},i=Te.parseFormat(s),l=i.reduce((h,{literal:m,val:g})=>m?h:h.concat(g),[]),c=e.shiftTo(...l.map(r).filter(h=>h)),u={isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]};return Nn(i,a(c,u))}}const Rr=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function pt(...t){const e=t.reduce((s,n)=>s+n.source,"");return RegExp(`^${e}$`)}function St(...t){return e=>t.reduce(([s,n,r],a)=>{const[i,l,c]=a(e,r);return[{...s,...i},l||n,c]},[{},null,1]).slice(0,2)}function xt(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 Lr(...t){return(e,s)=>{const n={};let r;for(r=0;r<t.length;r++)n[t[r]]=et(e[s+r]);return[n,null,s+r]}}const Ur=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,Vi=`(?:${Ur.source}?(?:\\[(${Rr.source})\\])?)?`,zs=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Fr=RegExp(`${zs.source}${Vi}`),Hs=RegExp(`(?:[Tt]${Fr.source})?`),Bi=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,Zi=/(\d{4})-?W(\d\d)(?:-?(\d))?/,zi=/(\d{4})-?(\d{3})/,Hi=Lr("weekYear","weekNumber","weekDay"),qi=Lr("year","ordinal"),Gi=/(\d{4})-(\d\d)-(\d\d)/,$r=RegExp(`${zs.source} ?(?:${Ur.source}|(${Rr.source}))?`),Yi=RegExp(`(?: ${$r.source})?`);function yt(t,e,s){const n=t[e];return U(n)?s:et(n)}function _i(t,e){return[{year:yt(t,e),month:yt(t,e+1,1),day:yt(t,e+2,1)},null,e+3]}function wt(t,e){return[{hours:yt(t,e,0),minutes:yt(t,e+1,0),seconds:yt(t,e+2,0),milliseconds:Bs(t[e+3])},null,e+4]}function jt(t,e){const s=!t[e]&&!t[e+1],n=rs(t[e+1],t[e+2]),r=s?null:be.instance(n);return[{},r,e+3]}function Dt(t,e){const s=t[e]?Ye.create(t[e]):null;return[{},s,e+1]}const Ji=RegExp(`^T?${zs.source}$`),Qi=/^-?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 Ki(t){const[e,s,n,r,a,i,l,c,u]=t,h=e[0]==="-",m=c&&c[0]==="-",g=(y,T=!1)=>y!==void 0&&(T||y&&h)?-y:y;return[{years:g(nt(s)),months:g(nt(n)),weeks:g(nt(r)),days:g(nt(a)),hours:g(nt(i)),minutes:g(nt(l)),seconds:g(nt(c),c==="-0"),milliseconds:g(Bs(u),m)}]}const Xi={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function qs(t,e,s,n,r,a,i){const l={year:e.length===2?js(et(e)):et(e),month:Ir.indexOf(s)+1,day:et(n),hour:et(r),minute:et(a)};return i&&(l.second=et(i)),t&&(l.weekday=t.length>3?Mr.indexOf(t)+1:Or.indexOf(t)+1),l}const eo=/^(?:(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 to(t){const[,e,s,n,r,a,i,l,c,u,h,m]=t,g=qs(e,r,n,s,a,i,l);let y;return c?y=Xi[c]:u?y=0:y=rs(h,m),[g,new be(y)]}function so(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const no=/^(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$/,ro=/^(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$/,ao=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function bn(t){const[,e,s,n,r,a,i,l]=t;return[qs(e,r,n,s,a,i,l),be.utcInstance]}function io(t){const[,e,s,n,r,a,i,l]=t;return[qs(e,l,s,n,r,a,i),be.utcInstance]}const oo=pt(Bi,Hs),lo=pt(Zi,Hs),co=pt(zi,Hs),uo=pt(Fr),Pr=St(_i,wt,jt,Dt),mo=St(Hi,wt,jt,Dt),fo=St(qi,wt,jt,Dt),ho=St(wt,jt,Dt);function yo(t){return xt(t,[oo,Pr],[lo,mo],[co,fo],[uo,ho])}function go(t){return xt(so(t),[eo,to])}function po(t){return xt(t,[no,bn],[ro,bn],[ao,io])}function So(t){return xt(t,[Qi,Ki])}const xo=St(wt);function wo(t){return xt(t,[Ji,xo])}const vo=pt(Gi,Yi),To=pt($r),Ao=St(wt,jt,Dt);function No(t){return xt(t,[vo,Pr],[To,Ao])}const kn="Invalid Duration",Wr={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}},bo={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},...Wr},Ue=146097/400,ut=146097/4800,ko={years:{quarters:4,months:12,weeks:Ue/7,days:Ue,hours:Ue*24,minutes:Ue*24*60,seconds:Ue*24*60*60,milliseconds:Ue*24*60*60*1e3},quarters:{months:3,weeks:Ue/28,days:Ue/4,hours:Ue*24/4,minutes:Ue*24*60/4,seconds:Ue*24*60*60/4,milliseconds:Ue*24*60*60*1e3/4},months:{weeks:ut/7,days:ut,hours:ut*24,minutes:ut*24*60,seconds:ut*24*60*60,milliseconds:ut*24*60*60*1e3},...Wr},at=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Io=at.slice(0).reverse();function qe(t,e,s=!1){const n={values:s?e.values:{...t.values,...e.values||{}},loc:t.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||t.conversionAccuracy,matrix:e.matrix||t.matrix};return new J(n)}function Vr(t,e){let s=e.milliseconds??0;for(const n of Io.slice(1))e[n]&&(s+=e[n]*t[n].milliseconds);return s}function In(t,e){const s=Vr(t,e)<0?-1:1;at.reduceRight((n,r)=>{if(U(e[r]))return n;if(n){const a=e[n]*s,i=t[r][n],l=Math.floor(a/i);e[r]+=l*s,e[n]-=l*i*s}return r},null),at.reduce((n,r)=>{if(U(e[r]))return n;if(n){const a=e[n]%1;e[n]-=a,e[r]+=a*t[n][r]}return r},null)}function En(t){const e={};for(const[s,n]of Object.entries(t))n!==0&&(e[s]=n);return e}class J{constructor(e){const s=e.conversionAccuracy==="longterm"||!1;let n=s?ko:bo;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 J.fromObject({milliseconds:e},s)}static fromObject(e,s={}){if(e==null||typeof e!="object")throw new ve(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new J({values:Kt(e,J.normalizeUnit),loc:te.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(st(e))return J.fromMillis(e);if(J.isDuration(e))return e;if(typeof e=="object")return J.fromObject(e);throw new ve(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,s){const[n]=So(e);return n?J.fromObject(n,s):J.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,s){const[n]=wo(e);return n?J.fromObject(n,s):J.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,s=null){if(!e)throw new ve("need to specify a reason the Duration is invalid");const n=e instanceof Ve?e:new Ve(e,s);if(fe.throwOnInvalid)throw new Ka(n);return new J({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 _n(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?Te.create(this.loc,n).formatDurationFromString(this,e):kn}toHuman(e={}){if(!this.isValid)return kn;const s=e.showZeros!==!1,n=at.map(r=>{const a=this.values[r];return U(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+=Zs(this.seconds+this.milliseconds/1e3,3)+"S"),e==="P"&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;const s=this.toMillis();return s<0||s>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e,includeOffset:!1},L.fromMillis(s,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?Vr(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const s=J.fromDurationLike(e),n={};for(const r of at)(gt(s.values,r)||gt(this.values,r))&&(n[r]=s.get(r)+this.get(r));return qe(this,{values:n},!0)}minus(e){if(!this.isValid)return this;const s=J.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]=kr(e(this.values[n],n));return qe(this,{values:s},!0)}get(e){return this[J.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const s={...this.values,...Kt(e,J.normalizeUnit)};return qe(this,{values:s})}reconfigure({locale:e,numberingSystem:s,conversionAccuracy:n,matrix:r}={}){const i={loc:this.loc.clone({locale:e,numberingSystem:s}),matrix:r,conversionAccuracy:n};return qe(this,i)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return In(this.matrix,e),qe(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=En(this.normalize().shiftToAll().toObject());return qe(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(i=>J.normalizeUnit(i));const s={},n={},r=this.toObject();let a;for(const i of at)if(e.indexOf(i)>=0){a=i;let l=0;for(const u in n)l+=this.matrix[u][i]*n[u],n[u]=0;st(r[i])&&(l+=r[i]);const c=Math.trunc(l);s[i]=c,n[i]=(l*1e3-c*1e3)/1e3}else st(r[i])&&(n[i]=r[i]);for(const i in n)n[i]!==0&&(s[a]+=i===a?n[i]:n[i]/this.matrix[a][i]);return In(this.matrix,s),qe(this,{values:s},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const e={};for(const s of Object.keys(this.values))e[s]=this.values[s]===0?0:-this.values[s];return qe(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=En(this.values);return qe(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function s(n,r){return n===void 0||n===0?r===void 0||r===0:n===r}for(const n of at)if(!s(this.values[n],e.values[n]))return!1;return!0}}const dt="Invalid Interval";function Eo(t,e){return!t||!t.isValid?me.invalid("missing or invalid start"):!e||!e.isValid?me.invalid("missing or invalid end"):e<t?me.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 me{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 ve("need to specify a reason the Interval is invalid");const n=e instanceof Ve?e:new Ve(e,s);if(fe.throwOnInvalid)throw new Qa(n);return new me({invalid:n})}static fromDateTimes(e,s){const n=At(e),r=At(s),a=Eo(n,r);return a??new me({start:n,end:r})}static after(e,s){const n=J.fromDurationLike(s),r=At(e);return me.fromDateTimes(r,r.plus(n))}static before(e,s){const n=J.fromDurationLike(s),r=At(e);return me.fromDateTimes(r.minus(n),r)}static fromISO(e,s){const[n,r]=(e||"").split("/",2);if(n&&r){let a,i;try{a=L.fromISO(n,s),i=a.isValid}catch{i=!1}let l,c;try{l=L.fromISO(r,s),c=l.isValid}catch{c=!1}if(i&&c)return me.fromDateTimes(a,l);if(i){const u=J.fromISO(r,s);if(u.isValid)return me.after(a,u)}else if(c){const u=J.fromISO(n,s);if(u.isValid)return me.before(l,u)}}return me.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?me.fromDateTimes(e||this.s,s||this.e):this}splitAt(...e){if(!this.isValid)return[];const s=e.map(At).filter(i=>this.contains(i)).sort((i,l)=>i.toMillis()-l.toMillis()),n=[];let{s:r}=this,a=0;for(;r<this.e;){const i=s[a]||this.e,l=+i>+this.e?this.e:i;n.push(me.fromDateTimes(r,l)),r=l,a+=1}return n}splitBy(e){const s=J.fromDurationLike(e);if(!this.isValid||!s.isValid||s.as("milliseconds")===0)return[];let{s:n}=this,r=1,a;const i=[];for(;n<this.e;){const l=this.start.plus(s.mapUnits(c=>c*r));a=+l>+this.e?this.e:l,i.push(me.fromDateTimes(n,a)),n=a,r+=1}return i}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:me.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 me.fromDateTimes(s,n)}static merge(e){const[s,n]=e.sort((r,a)=>r.s-a.s).reduce(([r,a],i)=>a?a.overlaps(i)||a.abutsStart(i)?[r,a.union(i)]:[r.concat([a]),i]:[r,i],[[],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"}]),i=Array.prototype.concat(...a),l=i.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(me.fromDateTimes(s,c.time)),s=null);return me.merge(r)}difference(...e){return me.xor([this].concat(e)).map(s=>this.intersection(s)).filter(s=>s&&!s.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:dt}[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=_t,s={}){return this.isValid?Te.create(this.s.loc.clone(s),e).formatInterval(this):dt}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:dt}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:dt}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:dt}toFormat(e,{separator:s=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${s}${this.e.toFormat(e)}`:dt}toDuration(e,s){return this.isValid?this.e.diff(this.s,e,s):J.invalid(this.invalidReason)}mapEndpoints(e){return me.fromDateTimes(e(this.s),e(this.e))}}class Wt{static hasDST(e=fe.defaultZone){const s=L.now().setZone(e).set({month:12});return!e.isUniversal&&s.offset!==s.set({month:6}).offset}static isValidIANAZone(e){return Ye.isValidZone(e)}static normalizeZone(e){return tt(e,fe.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:Ar(),localeWeek:Nr()}}}function Mn(t,e){const s=r=>r.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),n=s(e)-s(t);return Math.floor(J.fromMillis(n).as("days"))}function Mo(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 h=Mn(c,u);return(h-h%7)/7}],["days",Mn]],r={},a=t;let i,l;for(const[c,u]of n)s.indexOf(c)>=0&&(i=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,i]}function Oo(t,e,s,n){let[r,a,i,l]=Mo(t,e,s);const c=e-r,u=s.filter(m=>["hours","minutes","seconds","milliseconds"].indexOf(m)>=0);u.length===0&&(i<e&&(i=r.plus({[l]:1})),i!==r&&(a[l]=(a[l]||0)+c/(i-r)));const h=J.fromObject(a,n);return u.length>0?J.fromMillis(c,n).shiftTo(...u).plus(h):h}const Co="missing Intl.DateTimeFormat.formatToParts support";function ee(t,e=s=>s){return{regex:t,deser:([s])=>e(wi(s))}}const jo=" ",Br=`[ ${jo}]`,Zr=new RegExp(Br,"g");function Do(t){return t.replace(/\./g,"\\.?").replace(Zr,Br)}function On(t){return t.replace(/\./g,"").replace(Zr," ").toLowerCase()}function We(t,e){return t===null?null:{regex:RegExp(t.map(Do).join("|")),deser:([s])=>t.findIndex(n=>On(s)===On(n))+e}}function Cn(t,e){return{regex:t,deser:([,s,n])=>rs(s,n),groups:e}}function Vt(t){return{regex:t,deser:([e])=>e}}function Ro(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Lo(t,e){const s=Pe(e),n=Pe(e,"{2}"),r=Pe(e,"{3}"),a=Pe(e,"{4}"),i=Pe(e,"{6}"),l=Pe(e,"{1,2}"),c=Pe(e,"{1,3}"),u=Pe(e,"{1,6}"),h=Pe(e,"{1,9}"),m=Pe(e,"{2,4}"),g=Pe(e,"{4,6}"),y=b=>({regex:RegExp(Ro(b.val)),deser:([B])=>B,literal:!0}),S=(b=>{if(t.literal)return y(b);switch(b.val){case"G":return We(e.eras("short"),0);case"GG":return We(e.eras("long"),0);case"y":return ee(u);case"yy":return ee(m,js);case"yyyy":return ee(a);case"yyyyy":return ee(g);case"yyyyyy":return ee(i);case"M":return ee(l);case"MM":return ee(n);case"MMM":return We(e.months("short",!0),1);case"MMMM":return We(e.months("long",!0),1);case"L":return ee(l);case"LL":return ee(n);case"LLL":return We(e.months("short",!1),1);case"LLLL":return We(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 Vt(h);case"uu":return Vt(l);case"uuu":return ee(s);case"a":return We(e.meridiems(),0);case"kkkk":return ee(a);case"kk":return ee(m,js);case"W":return ee(l);case"WW":return ee(n);case"E":case"c":return ee(s);case"EEE":return We(e.weekdays("short",!1),1);case"EEEE":return We(e.weekdays("long",!1),1);case"ccc":return We(e.weekdays("short",!0),1);case"cccc":return We(e.weekdays("long",!0),1);case"Z":case"ZZ":return Cn(new RegExp(`([+-]${l.source})(?::(${n.source}))?`),2);case"ZZZ":return Cn(new RegExp(`([+-]${l.source})(${n.source})?`),2);case"z":return Vt(/[a-z_+-/]{1,256}?/i);case" ":return Vt(/[^\S\n\r]/);default:return y(b)}})(t)||{invalidReason:Co};return S.token=t,S}const Uo={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 Fo(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 i=n;n==="hour"&&(e.hour12!=null?i=e.hour12?"hour12":"hour24":e.hourCycle!=null?e.hourCycle==="h11"||e.hourCycle==="h12"?i="hour12":i="hour24":i=s.hour12?"hour12":"hour24");let l=Uo[i];if(typeof l=="object"&&(l=l[a]),l)return{literal:!1,val:l}}function $o(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function Po(t,e,s){const n=t.match(e);if(n){const r={};let a=1;for(const i in s)if(gt(s,i)){const l=s[i],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 Wo(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 U(t.z)||(s=Ye.create(t.z)),U(t.Z)||(s||(s=new be(t.Z)),n=t.Z),U(t.q)||(t.M=(t.q-1)*3+1),U(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),U(t.u)||(t.S=Bs(t.u)),[Object.keys(t).reduce((a,i)=>{const l=e(i);return l&&(a[l]=t[i]),a},{}),s,n]}let ps=null;function Vo(){return ps||(ps=L.fromMillis(1555555555555)),ps}function Bo(t,e){if(t.literal)return t;const s=Te.macroTokenToFormatOpts(t.val),n=Gr(s,e);return n==null||n.includes(void 0)?t:n}function zr(t,e){return Array.prototype.concat(...t.map(s=>Bo(s,e)))}class Hr{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=zr(Te.parseFormat(s),e),this.units=this.tokens.map(n=>Lo(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=$o(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=Po(e,this.regex,this.handlers),[r,a,i]=n?Wo(n):[null,null,void 0];if(gt(n,"a")&&gt(n,"H"))throw new ft("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:i}}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 qr(t,e,s){return new Hr(t,s).explainFromTokens(e)}function Zo(t,e,s){const{result:n,zone:r,specificOffset:a,invalidReason:i}=qr(t,e,s);return[n,r,a,i]}function Gr(t,e){if(!t)return null;const n=Te.create(e,t).dtFormatter(Vo()),r=n.formatToParts(),a=n.resolvedOptions();return r.map(i=>Fo(i,t,a))}const Ss="Invalid DateTime",jn=864e13;function kt(t){return new Ve("unsupported zone",`the zone "${t.name}" is not supported`)}function xs(t){return t.weekData===null&&(t.weekData=Jt(t.c)),t.weekData}function ws(t){return t.localWeekData===null&&(t.localWeekData=Jt(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function rt(t,e){const s={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new L({...s,...e,old:s})}function Yr(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 Bt(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 qt(t,e,s){return Yr(ns(t),e,s)}function Dn(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,Qt(n,r))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},i=J.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=ns(a);let[c,u]=Yr(l,s,t.zone);return i!==0&&(c+=i,u=t.zone.offset(c)),{ts:c,o:u}}function mt(t,e,s,n,r,a){const{setZone:i,zone:l}=s;if(t&&Object.keys(t).length!==0||e){const c=e||l,u=L.fromObject(t,{...s,zone:c,specificOffset:a});return i?u:u.setZone(l)}else return L.invalid(new Ve("unparsable",`the input "${r}" can't be parsed as ${n}`))}function Zt(t,e,s=!0){return t.isValid?Te.create(te.create("en-US"),{allowZ:s,forceSimple:!0}).formatDateTimeFromString(t,e):null}function vs(t,e,s){const n=t.c.year>9999||t.c.year<0;let r="";if(n&&t.c.year>=0&&(r+="+"),r+=pe(t.c.year,n?6:4),s==="year")return r;if(e){if(r+="-",r+=pe(t.c.month),s==="month")return r;r+="-"}else if(r+=pe(t.c.month),s==="month")return r;return r+=pe(t.c.day),r}function Rn(t,e,s,n,r,a,i){let l=!s||t.c.millisecond!==0||t.c.second!==0,c="";switch(i){case"day":case"month":case"year":break;default:if(c+=pe(t.c.hour),i==="hour")break;if(e){if(c+=":",c+=pe(t.c.minute),i==="minute")break;l&&(c+=":",c+=pe(t.c.second))}else{if(c+=pe(t.c.minute),i==="minute")break;l&&(c+=pe(t.c.second))}if(i==="second")break;l&&(!n||t.c.millisecond!==0)&&(c+=".",c+=pe(t.c.millisecond,3))}return r&&(t.isOffsetFixed&&t.offset===0&&!a?c+="Z":t.o<0?(c+="-",c+=pe(Math.trunc(-t.o/60)),c+=":",c+=pe(Math.trunc(-t.o%60))):(c+="+",c+=pe(Math.trunc(t.o/60)),c+=":",c+=pe(Math.trunc(t.o%60)))),a&&(c+="["+t.zone.ianaName+"]"),c}const _r={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},zo={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},Ho={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Gt=["year","month","day","hour","minute","second","millisecond"],qo=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],Go=["year","ordinal","hour","minute","second","millisecond"];function Yt(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 _n(t);return e}function Ln(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return Yt(t)}}function Yo(t){if(It===void 0&&(It=fe.now()),t.type!=="iana")return t.offset(It);const e=t.name;let s=Ds.get(e);return s===void 0&&(s=t.offset(It),Ds.set(e,s)),s}function Un(t,e){const s=tt(e.zone,fe.defaultZone);if(!s.isValid)return L.invalid(kt(s));const n=te.fromObject(e);let r,a;if(U(t.year))r=fe.now();else{for(const c of Gt)U(t[c])&&(t[c]=_r[c]);const i=vr(t)||Tr(t);if(i)return L.invalid(i);const l=Yo(s);[r,a]=qt(t,l,s)}return new L({ts:r,zone:s,loc:n,o:a})}function Fn(t,e,s){const n=U(s.round)?!0:s.round,r=U(s.rounding)?"trunc":s.rounding,a=(l,c)=>(l=Zs(l,n||s.calendary?0:2,s.calendary?"round":r),e.loc.clone(s).relFormatter(s).format(l,c)),i=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(i(s.unit),s.unit);for(const l of s.units){const c=i(l);if(Math.abs(c)>=1)return a(c,l)}return a(t>e?-0:0,s.units[s.units.length-1])}function $n(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 It;const Ds=new Map;class L{constructor(e){const s=e.zone||fe.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Ve("invalid input"):null)||(s.isValid?null:kt(s));this.ts=U(e.ts)?fe.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=st(e.o)&&!e.old?e.o:s.offset(this.ts);r=Bt(this.ts,l),n=Number.isNaN(r.year)?new Ve("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 L({})}static local(){const[e,s]=$n(arguments),[n,r,a,i,l,c,u]=s;return Un({year:n,month:r,day:a,hour:i,minute:l,second:c,millisecond:u},e)}static utc(){const[e,s]=$n(arguments),[n,r,a,i,l,c,u]=s;return e.zone=be.utcInstance,Un({year:n,month:r,day:a,hour:i,minute:l,second:c,millisecond:u},e)}static fromJSDate(e,s={}){const n=bi(e)?e.valueOf():NaN;if(Number.isNaN(n))return L.invalid("invalid input");const r=tt(s.zone,fe.defaultZone);return r.isValid?new L({ts:n,zone:r,loc:te.fromObject(s)}):L.invalid(kt(r))}static fromMillis(e,s={}){if(st(e))return e<-jn||e>jn?L.invalid("Timestamp out of range"):new L({ts:e,zone:tt(s.zone,fe.defaultZone),loc:te.fromObject(s)});throw new ve(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,s={}){if(st(e))return new L({ts:e*1e3,zone:tt(s.zone,fe.defaultZone),loc:te.fromObject(s)});throw new ve("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=tt(s.zone,fe.defaultZone);if(!n.isValid)return L.invalid(kt(n));const r=te.fromObject(s),a=Kt(e,Ln),{minDaysInFirstWeek:i,startOfWeek:l}=vn(a,r),c=fe.now(),u=U(s.specificOffset)?n.offset(c):s.specificOffset,h=!U(a.ordinal),m=!U(a.year),g=!U(a.month)||!U(a.day),y=m||g,T=a.weekYear||a.weekNumber;if((y||h)&&T)throw new ft("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(g&&h)throw new ft("Can't mix ordinal dates with month/day");const S=T||a.weekday&&!y;let b,B,j=Bt(c,u);S?(b=qo,B=zo,j=Jt(j,i,l)):h?(b=Go,B=Ho,j=gs(j)):(b=Gt,B=_r);let q=!1;for(const k of b){const M=a[k];U(M)?q?a[k]=B[k]:a[k]=j[k]:q=!0}const W=S?Ti(a,i,l):h?Ai(a):vr(a),Q=W||Tr(a);if(Q)return L.invalid(Q);const Y=S?xn(a,i,l):h?wn(a):a,[F,se]=qt(Y,u,n),p=new L({ts:F,zone:n,o:se,loc:r});return a.weekday&&y&&e.weekday!==p.weekday?L.invalid("mismatched weekday",`you can't specify both a weekday of ${a.weekday} and a date of ${p.toISO()}`):p.isValid?p:L.invalid(p.invalid)}static fromISO(e,s={}){const[n,r]=yo(e);return mt(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=go(e);return mt(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=po(e);return mt(n,r,s,"HTTP",s)}static fromFormat(e,s,n={}){if(U(e)||U(s))throw new ve("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:a=null}=n,i=te.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0}),[l,c,u,h]=Zo(i,e,s);return h?L.invalid(h):mt(l,c,n,`format ${s}`,e,u)}static fromString(e,s,n={}){return L.fromFormat(e,s,n)}static fromSQL(e,s={}){const[n,r]=No(e);return mt(n,r,s,"SQL",e)}static invalid(e,s=null){if(!e)throw new ve("need to specify a reason the DateTime is invalid");const n=e instanceof Ve?e:new Ve(e,s);if(fe.throwOnInvalid)throw new Ja(n);return new L({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,s={}){const n=Gr(e,te.fromObject(s));return n?n.map(r=>r?r.val:null).join(""):null}static expandFormat(e,s={}){return zr(Te.parseFormat(e),te.fromObject(s)).map(r=>r.val).join("")}static resetCache(){It=void 0,Ds.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?xs(this).weekYear:NaN}get weekNumber(){return this.isValid?xs(this).weekNumber:NaN}get weekday(){return this.isValid?xs(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?ws(this).weekday:NaN}get localWeekNumber(){return this.isValid?ws(this).weekNumber:NaN}get localWeekYear(){return this.isValid?ws(this).weekYear:NaN}get ordinal(){return this.isValid?gs(this.c).ordinal:NaN}get monthShort(){return this.isValid?Wt.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Wt.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Wt.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Wt.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=ns(this.c),r=this.zone.offset(n-e),a=this.zone.offset(n+e),i=this.zone.offset(n-r*s),l=this.zone.offset(n-a*s);if(i===l)return[this];const c=n-i*s,u=n-l*s,h=Bt(c,i),m=Bt(u,l);return h.hour===m.hour&&h.minute===m.minute&&h.second===m.second&&h.millisecond===m.millisecond?[rt(this,{ts:c}),rt(this,{ts:u})]:[this]}get isInLeapYear(){return Ct(this.year)}get daysInMonth(){return Qt(this.year,this.month)}get daysInYear(){return this.isValid?ht(this.year):NaN}get weeksInWeekYear(){return this.isValid?Mt(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Mt(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:s,numberingSystem:n,calendar:r}=Te.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:s,numberingSystem:n,outputCalendar:r}}toUTC(e=0,s={}){return this.setZone(be.instance(e),s)}toLocal(){return this.setZone(fe.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=tt(e,fe.defaultZone),e.equals(this.zone))return this;if(e.isValid){let r=this.ts;if(s||n){const a=e.offset(this.ts),i=this.toObject();[r]=qt(i,a,e)}return rt(this,{ts:r,zone:e})}else return L.invalid(kt(e))}reconfigure({locale:e,numberingSystem:s,outputCalendar:n}={}){const r=this.loc.clone({locale:e,numberingSystem:s,outputCalendar:n});return rt(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const s=Kt(e,Ln),{minDaysInFirstWeek:n,startOfWeek:r}=vn(s,this.loc),a=!U(s.weekYear)||!U(s.weekNumber)||!U(s.weekday),i=!U(s.ordinal),l=!U(s.year),c=!U(s.month)||!U(s.day),u=l||c,h=s.weekYear||s.weekNumber;if((u||i)&&h)throw new ft("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(c&&i)throw new ft("Can't mix ordinal dates with month/day");let m;a?m=xn({...Jt(this.c,n,r),...s},n,r):U(s.ordinal)?(m={...this.toObject(),...s},U(s.day)&&(m.day=Math.min(Qt(m.year,m.month),m.day))):m=wn({...gs(this.c),...s});const[g,y]=qt(m,this.o,this.zone);return rt(this,{ts:g,o:y})}plus(e){if(!this.isValid)return this;const s=J.fromDurationLike(e);return rt(this,Dn(this,s))}minus(e){if(!this.isValid)return this;const s=J.fromDurationLike(e).negate();return rt(this,Dn(this,s))}startOf(e,{useLocaleWeeks:s=!1}={}){if(!this.isValid)return this;const n={},r=J.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:i}=this;i<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?Te.create(this.loc.redefaultToEN(s)).formatDateTimeFromString(this,e):Ss}toLocaleString(e=_t,s={}){return this.isValid?Te.create(this.loc.clone(s),e).formatDateTime(this):Ss}toLocaleParts(e={}){return this.isValid?Te.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:i="milliseconds"}={}){if(!this.isValid)return null;i=Yt(i);const l=e==="extended";let c=vs(this,l,i);return Gt.indexOf(i)>=3&&(c+="T"),c+=Rn(this,l,s,n,r,a,i),c}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?vs(this,e==="extended",Yt(s)):null}toISOWeekDate(){return Zt(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:s=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:a=!1,format:i="extended",precision:l="milliseconds"}={}){return this.isValid?(l=Yt(l),(r&&Gt.indexOf(l)>=3?"T":"")+Rn(this,i==="extended",s,e,n,a,l)):null}toRFC2822(){return Zt(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return Zt(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?vs(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")),Zt(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Ss}[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 J.invalid("created by diffing an invalid DateTime");const r={locale:this.locale,numberingSystem:this.numberingSystem,...n},a=ki(s).map(J.normalizeUnit),i=e.valueOf()>this.valueOf(),l=i?this:e,c=i?e:this,u=Oo(l,c,a,r);return i?u.negate():u}diffNow(e="milliseconds",s={}){return this.diff(L.now(),e,s)}until(e){return this.isValid?me.fromDateTimes(this,e):this}hasSame(e,s,n){if(!this.isValid)return!1;const r=e.valueOf(),a=this.setZone(e.zone,{keepLocalTime:!0});return a.startOf(s,n)<=r&&r<=a.endOf(s,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;const s=e.base||L.fromObject({},{zone:this.zone}),n=e.padding?this<s?-e.padding:e.padding:0;let r=["years","months","days","hours","minutes","seconds"],a=e.unit;return Array.isArray(e.unit)&&(r=e.unit,a=void 0),Fn(s,this.plus(n),{...e,numeric:"always",units:r,unit:a})}toRelativeCalendar(e={}){return this.isValid?Fn(e.base||L.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(L.isDateTime))throw new ve("min requires all arguments be DateTimes");return Tn(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every(L.isDateTime))throw new ve("max requires all arguments be DateTimes");return Tn(e,s=>s.valueOf(),Math.max)}static fromFormatExplain(e,s,n={}){const{locale:r=null,numberingSystem:a=null}=n,i=te.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});return qr(i,e,s)}static fromStringExplain(e,s,n={}){return L.fromFormatExplain(e,s,n)}static buildFormatParser(e,s={}){const{locale:n=null,numberingSystem:r=null}=s,a=te.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new Hr(a,e)}static fromFormatParser(e,s,n={}){if(U(e)||U(s))throw new ve("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:a=null}=n,i=te.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});if(!i.equals(s.locale))throw new ve(`fromFormatParser called with a locale of ${i}, but the format parser was created for ${s.locale}`);const{result:l,zone:c,specificOffset:u,invalidReason:h}=s.explainFromTokens(e);return h?L.invalid(h):mt(l,c,n,`format ${s.format}`,e,u)}static get DATE_SHORT(){return _t}static get DATE_MED(){return Jn}static get DATE_MED_WITH_WEEKDAY(){return Xa}static get DATE_FULL(){return Qn}static get DATE_HUGE(){return Kn}static get TIME_SIMPLE(){return Xn}static get TIME_WITH_SECONDS(){return er}static get TIME_WITH_SHORT_OFFSET(){return tr}static get TIME_WITH_LONG_OFFSET(){return sr}static get TIME_24_SIMPLE(){return nr}static get TIME_24_WITH_SECONDS(){return rr}static get TIME_24_WITH_SHORT_OFFSET(){return ar}static get TIME_24_WITH_LONG_OFFSET(){return ir}static get DATETIME_SHORT(){return or}static get DATETIME_SHORT_WITH_SECONDS(){return lr}static get DATETIME_MED(){return cr}static get DATETIME_MED_WITH_SECONDS(){return ur}static get DATETIME_MED_WITH_WEEKDAY(){return ei}static get DATETIME_FULL(){return dr}static get DATETIME_FULL_WITH_SECONDS(){return mr}static get DATETIME_HUGE(){return fr}static get DATETIME_HUGE_WITH_SECONDS(){return hr}}function At(t){if(L.isDateTime(t))return t;if(t&&t.valueOf&&st(t.valueOf()))return L.fromJSDate(t);if(t&&typeof t=="object")return L.fromObject(t);throw new ve(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function _o(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function Jo(t,e){try{const s=L.fromJSDate(t,{zone:"utc"}).setZone(e),n=s.toJSDate().toLocaleString("en-US",{timeZone:e,timeZoneName:"short"}).split(" ").pop()||void 0,r=s.toFormat("ZZ")||void 0;return{abbr:n,offset:r}}catch{return{}}}function Qo(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(),i=s(e.getHours()),l=s(e.getMinutes()),c=s(e.getSeconds());return`${n}/${r}/${a} ${i}:${l}:${c}`}catch{return"-"}}function Xt(t,e="UTC"){if(!t)return"-";const s=L.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 Ko={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Xo={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function Jr({alerts:t,loading:e=!1,pageSize:s=10,severityOptions:n,anomalyOptions:r,spaceOptions:a,onAlertIdClick:i}){const l=$s(),c=["completed","false positive"],u=async g=>{try{const y=await l.mutateAsync({alertUniqueId:g.alertId??g.id,alertId:g.id,status:"Reopen",notes:"Reopened",modifiedBy:0});if(y?.responseStatus||y?.Success){const T=y?.Message||y?.data||"Alert reopened successfully.";we.toast.success(T)}else{const T=y?.errorMessage||y?.Message||"Failed to reopen alert";we.toast.error(T)}}catch{we.toast.error("Failed to reopen alert. Please try again.")}},h=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:g=>o.jsx(d.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Ko[g]}`,backgroundColor:Xo[String(g)]},children:g})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:g=>Qo(g)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(g,y)=>o.jsxs("div",{children:[o.jsx("a",{onClick:T=>{T.preventDefault(),i?.(y,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:y.alertNumber}),o.jsx("div",{className:"text-black/65",children:g})]})},{title:"",key:"menu",width:60,align:"right",render:(g,y)=>o.jsx(d.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:T})=>{T==="reopen"&&u(y)}},children:o.jsx(d.Button,{type:"text",icon:o.jsx(it.MoreOutlined,{})})})}],m=(t||[]).filter(g=>c.includes((g.statusType||"").toLowerCase()));return o.jsx(Fs,{data:m,loading:e,pageSize:s,columns:h,severityOptions:n,anomalyOptions:r,spaceOptions:a,renderActions:void 0,onAlertIdClick:i,excludeCompleted:!1})}function el({size:t=120,time:e,timeZone:s="America/New_York"}){const{hours:n,minutes:r,seconds:a}=f.useMemo(()=>{const m=new Intl.DateTimeFormat("en-US",{timeZone:s,hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(e);return{hours:parseInt(m.find(g=>g.type==="hour")?.value||"0",10),minutes:parseInt(m.find(g=>g.type==="minute")?.value||"0",10),seconds:parseInt(m.find(g=>g.type==="second")?.value||"0",10)}},[e,s]),i=a*6,l=r*6+a*.1,c=n%12*30+r*.5,u=t/2;return o.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((h,m)=>{const g=m*30,y=6,T=u-4,S=T-y,b=(g-90)*(Math.PI/180),B=u+S*Math.cos(b),j=u+S*Math.sin(b),q=u+T*Math.cos(b),W=u+T*Math.sin(b);return o.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:o.jsx("line",{x1:B,y1:j,x2:q,y2:W,stroke:"#9CA3AF",strokeWidth:m%3===0?2:1,strokeLinecap:"round"})},m)}),o.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${c}deg)`},children:o.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.25,stroke:"#1F2937",strokeWidth:4,strokeLinecap:"round"})}),o.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${l}deg)`},children:o.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.35,stroke:"#374151",strokeWidth:3,strokeLinecap:"round"})}),o.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${i}deg)`},children:o.jsx("line",{x1:u,y1:u+t*.08,x2:u,y2:u-t*.38,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"})}),o.jsx("div",{className:"absolute bg-gray-900 rounded-full",style:{width:8,height:8,left:u-4,top:u-4}})]})}function Qr({label:t="USA",timeZone:e="America/New_York",updateIntervalMs:s=1e3,className:n}){const[r,a]=f.useState(new Date);f.useEffect(()=>{const u=setInterval(()=>a(new Date),s);return()=>clearInterval(u)},[s]);const i=f.useMemo(()=>_o(r,e),[r,e]),{abbr:l,offset:c}=f.useMemo(()=>Jo(r,e),[r,e]);return o.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[o.jsx(el,{time:r,timeZone:e,size:80}),o.jsxs("div",{className:"flex flex-col items-baseline gap-1",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[o.jsx("span",{className:"uppercase",children:t}),l&&o.jsxs("span",{className:"p-2 rounded-md border text-[10px] leading-none text-gray-600 bg-gray-50",children:[l," ",c]})]}),o.jsx("div",{className:"text-2xl font-semibold text-gray-700 tracking-wide",children:i})]})]})}const{Text:tl}=d.Typography;function sl({sortBy:t,onChange:e,showActions:s,onSave:n,onClear:r,saving:a}){return o.jsxs(d.Row,{gutter:[16,16],align:"middle",children:[o.jsx(d.Col,{xs:24,md:8,lg:5,children:o.jsxs(d.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[o.jsx(tl,{className:"text-gray-600 whitespace-nowrap",children:"Sort By:"}),o.jsx(d.Select,{placeholder:"By Severity",value:t,onChange:i=>e({sortBy:i}),options:[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],className:"w-full",style:{minWidth:"200px"}})]})}),o.jsx(d.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?o.jsxs(d.Space,{className:"w-full",direction:"horizontal",size:8,children:[o.jsx(d.Button,{onClick:r,disabled:a,children:"Clear"}),o.jsx(d.Button,{type:"primary",onClick:n,loading:a,children:"Save"})]}):null})]})}const Rs=t=>o.jsxs(d.Tag,{children:[o.jsx(it.PlusOutlined,{})," ",t.length," more"]}),{Text:Ge}=d.Typography;function nl(t){const{selectedRule:e,setSelectedRule:s,ruleOptions:n,minsOptions:r,roleOptions:a,l1mins:i,setL1mins:l,l1role:c,setL1role:u,l2mins:h,setL2mins:m,l2role:g,setL2role:y,l3mins:T,setL3mins:S,l3role:b,setL3role:B,actions:j,setActions:q,thirdPartyIds:W,setThirdPartyIds:Q,humanLoop:Y,setHumanLoop:F,isAutoExpire:se,setAutoExpire:p,onClear:k,onSave:M,saving:he,onActionTypesLoaded:oe}=t,{rules:C}=Oe(),[w,x]=f.useState([]),[I,v]=f.useState([]),[D,A]=f.useState(!1);f.useEffect(()=>{let z=!1;return(async()=>{try{A(!0);const K=await C.getLookups();if(z||!K||!Array.isArray(K.actionTypes))return;const le=K.actionTypes.map(ce=>({label:ce.name,value:String(ce.actionTypeId)}));x(le),oe&&oe(K.actionTypes);const Se=Array.isArray(K.thirdParties)?K.thirdParties.map(ce=>({label:ce.thirdPartyName,value:ce.thirdPartyId})):[];v(Se)}catch(K){console.error("Error loading lookups",K)}finally{z||A(!1)}})(),()=>{z=!0}},[]);const E=typeof i=="number"||typeof c=="number",$=typeof h=="number"||typeof g=="number",P=typeof i=="number"||typeof c=="number"||typeof h=="number"||typeof g=="number"||typeof T=="number"||typeof b=="number"||Array.isArray(j)&&j.length>0||Array.isArray(W)&&W.length>0||!!Y||!!se,Z=!!e&&P&&!he;return o.jsxs(d.Spin,{spinning:!!he||D,children:[o.jsxs(d.Row,{gutter:[16,16],align:"bottom",children:[o.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:o.jsxs("div",{children:[o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),o.jsx(d.Select,{placeholder:"Rules",value:e,onChange:s,options:n,className:"w-full"})]})}),o.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:o.jsxs("div",{children:[o.jsxs(d.Row,{gutter:8,children:[o.jsx(d.Col,{span:10,children:o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),o.jsx(d.Col,{span:14,children:o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),o.jsxs(d.Row,{gutter:8,children:[o.jsx(d.Col,{span:10,children:o.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:i,onChange:l,options:r})}),o.jsx(d.Col,{span:14,children:o.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:c,onChange:u,options:a})})]})]})}),E&&o.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:o.jsxs("div",{children:[o.jsxs(d.Row,{gutter:8,children:[o.jsx(d.Col,{span:10,children:o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),o.jsx(d.Col,{span:14,children:o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),o.jsxs(d.Row,{gutter:8,children:[o.jsx(d.Col,{span:10,children:o.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:h,onChange:m,options:r})}),o.jsx(d.Col,{span:14,children:o.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:g,onChange:y,options:a})})]})]})}),$&&o.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:o.jsxs("div",{children:[o.jsxs(d.Row,{gutter:8,children:[o.jsx(d.Col,{span:10,children:o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),o.jsx(d.Col,{span:14,children:o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),o.jsxs(d.Row,{gutter:8,children:[o.jsx(d.Col,{span:10,children:o.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:T,onChange:S,options:r})}),o.jsx(d.Col,{span:14,children:o.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:b,onChange:B,options:a})})]})]})}),o.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:o.jsxs("div",{children:[o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),o.jsx(d.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:j,onChange:q,options:w,maxTagCount:1,maxTagPlaceholder:Rs})]})}),o.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:o.jsxs("div",{children:[o.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Third Party App"}),o.jsx(d.Select,{mode:"multiple",placeholder:"Third Party app",className:"w-full",value:W,onChange:Q,options:I,maxCount:2,maxTagPlaceholder:Rs})]})})]}),o.jsxs(d.Row,{gutter:[16,16],align:"bottom",className:"mt-4 items-center",children:[o.jsx(d.Col,{xs:24,sm:12,md:8,lg:7,children:o.jsxs("div",{className:"flex items-center h-full gap-8",children:[o.jsx(d.Checkbox,{checked:Y,onChange:z=>F(z.target.checked),className:"w-full",children:"Human-In-The-Loop"}),o.jsx(d.Checkbox,{checked:se,onChange:z=>p(z.target.checked),className:"w-full",children:"Auto-expire in 5 minutes"})]})}),o.jsx(d.Col,{xs:24,sm:12,md:8,children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(d.Button,{onClick:k,children:"Clear"}),o.jsx(d.Button,{type:"primary",onClick:M,loading:!!he,disabled:!Z,children:"Save"})]})})]})]})}function rl({entries:t,userRoles:e,onEdit:s,loading:n}){const r=new Map(e.map(i=>[i.userRoleId,i.userRoleName])),a=i=>i.map(l=>r.get(l)||String(l)).join(", ");return o.jsx(d.Table,{rowKey:"id",dataSource:t,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(i,l)=>`${l[0]}-${l[1]} of ${i} items`},loading:n,columns:[{title:"Rule",dataIndex:"ruleOrSeverityLabel",key:"rule"},{title:"Level 1",key:"l1",render:(i,l)=>o.jsxs("span",{children:[l.l1.minutes?`Action taken in (${l.l1.minutes} Mins)`:"No Action taken in 0 Min",l.l1.roles?.length?`, Escalate to (${a(l.l1.roles)})`:""]})},{title:"Level 2",key:"l2",render:(i,l)=>o.jsxs("span",{children:[l.l2.minutes?`Action taken in (${l.l2.minutes} Mins)`:"No Action taken in 0 Min",l.l2.roles?.length?`, Escalate to (${a(l.l2.roles)})`:""]})},{title:"Level 3",key:"l3",render:(i,l)=>o.jsxs("span",{children:[l.l3.minutes?`Action taken in (${l.l3.minutes} Mins)`:"No Action taken in 0 Min",l.l3.roles?.length?`, Escalate to (${a(l.l3.roles)})`:""]})},{title:"Pick Actions",key:"actionsCol",render:(i,l)=>l.actions?.length?l.actions.join(", "):"-"},{title:"Notify",key:"notify",render:(i,l)=>l.notify?.length?l.notify.join(", "):"-"},{title:"Human-In-The-Loop",key:"humanLoop",render:(i,l)=>l.humanLoop?"Yes":"No"},{title:"Auto Expire",key:"isAutoExpire",render:(i,l)=>l.isAutoExpire?"Yes":"No"},{title:"Actions",key:"ops",render:(i,l)=>o.jsx(d.Button,{type:"text",onClick:()=>s(l.id),children:o.jsx(it.EditOutlined,{})})}]})}const{Title:al}=d.Typography;function Kr({userRoles:t,rules:e,rawRules:s}){const{rules:n}=Oe(),[r,a]=f.useState(!1),[i,l]=f.useState(s),[c,u]=f.useState({}),h=f.useMemo(()=>t.map(S=>({label:S.userRoleName,value:S.userRoleId})),[t]),m=f.useMemo(()=>(e||[]).map((S,b)=>({key:S.RuleId||S.Name||String(b),ruleName:S.Name||"-",ruleDesc:S.Description||""})),[e]);f.useEffect(()=>{let S=!1;return(async()=>{try{a(!0);const b=await n.getRules();S||(l(Array.isArray(b)?b:[]),u({}))}catch{!S&&Array.isArray(s)&&l(s)}finally{S||a(!1)}})(),()=>{S=!0}},[]),f.useEffect(()=>{!i&&Array.isArray(s)&&l(s)},[s]);const g=f.useMemo(()=>{if(!Array.isArray(i)||!i.length)return{};const S={};for(const b of m){const B=i.find(W=>W?.ruleId===b.key||W?.ruleName===b.key||W?.RuleId===b.key||W?.ruleName===b.ruleName||W?.Name===b.ruleName),j=B?.userRoleIds??B?.UserRoleIds,q=Array.isArray(j)?j:[];q.length&&(S[b.key]=q)}return S},[i,m]),y=()=>{u({})},T=async()=>{try{if(!i||!Array.isArray(i)||Object.keys(c).length===0){we.toast.info("No changes to save");return}a(!0);const S=Object.entries(c).map(async([j,q])=>{const W=i.find(p=>p?.ruleId===j||p?.ruleName===j||p?.RuleId===j),Q=typeof W?.recordId=="number"?W.recordId:W?.ruleId||W?.RuleId||void 0;if(!W||!Q)throw new Error(`Unable to find rule identifier for rule ${j}`);const Y=Array.isArray(q)?q:[],F=Y.map(p=>{const k=t.find(M=>M.userRoleId===p);return{id:p,name:k?.userRoleName??String(p)}}),se={...W,ruleId:j,userRoleIds:Y,userRoles:F};return n.updateRule(Q,se)}),B=(await Promise.all(S)).find(j=>!j?.responseStatus&&!j?.Success&&!j?.success);if(B)we.toast.error(B?.errorMessage||B?.Message||"Error saving Alert Assignment");else{we.toast.success("Alert assignment saved");try{const j=await n.getRules();l(Array.isArray(j)?j:[]),u({})}catch(j){console.error("Failed to refresh rules after save",j)}}}catch(S){console.error("Failed to save alert assignment",S),we.toast.error(S instanceof Error?S.message:"Error saving Alert Assignment")}finally{a(!1)}};return o.jsxs("div",{className:"w-full",children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsx(al,{level:4,className:"!mb-4",children:"Alert Assignment"})}),o.jsx(d.Table,{rowKey:"key",dataSource:m,loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(S,b)=>`${b[0]}-${b[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,b)=>o.jsx(d.Select,{mode:"multiple",placeholder:"Dropdown with Multi select",className:"w-full",value:c[b.key]??g[b.key]??[],onChange:B=>u(j=>({...j,[b.key]:B})),options:h,maxTagCount:1,maxTagPlaceholder:Rs})}]}),o.jsxs(d.Space,{className:"mt-4",children:[o.jsx(d.Button,{onClick:y,disabled:r,children:"Clear"}),o.jsx(d.Button,{type:"primary",onClick:T,loading:r,disabled:r||Object.keys(c).length===0,children:"Save"})]})]})}const{Title:Pn}=d.Typography;function Ts(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.ThirdPartyIds,humanLoop:t.humanLoop??t.HumanLoop,isAutoExpire:t.isAutoExpire??t.IsAutoExpire}}function Xr({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r,onSave:a}){const{rules:i,alerts:l}=Oe(),[c,u]=f.useState("By Severity"),[h,m]=f.useState("By severity"),[g,y]=f.useState("By Severity"),[T,S]=f.useState(!1),[b,B]=f.useState(!1),[j,q]=f.useState(!1),[W,Q]=f.useState(null),[Y,F]=f.useState("rules"),[se,p]=f.useState(),[k,M]=f.useState(),[he,oe]=f.useState(),[C,w]=f.useState(),[x,I]=f.useState(),[v,D]=f.useState(),[A,E]=f.useState(),[$,P]=f.useState(),[Z,z]=f.useState([]),[K,le]=f.useState([]),[Se,ce]=f.useState(!1),[ue,xe]=f.useState(!1),[Ae,Ce]=f.useState({}),[_e,vt]=f.useState({}),[ye,ct]=f.useState(s||[]),[Tt,Je]=f.useState([]),[os,O]=f.useState(!1),[G,X]=f.useState(!1),[ge,ke]=f.useState(n||[]);f.useEffect(()=>{n&&n.length&&ke(n)},[n]),f.useEffect(()=>{if(!ge||!ge.length)return;const R=Object.keys(Ae).length>0||Object.keys(_e).length>0;if(Tt.length&&!R)return;const re=ge.map((_,V)=>{const ie=e.find(Ne=>Ne.RuleId===(_.ruleId||_.ruleName))?.Name||_.ruleName||_.Name||"-",H=Ts(_.escalationSettings),ae=typeof H.level1UserRoleId=="number"&&H.level1UserRoleId>0?[H.level1UserRoleId]:[],ls=typeof H.level2UserRoleId=="number"&&H.level2UserRoleId>0?[H.level2UserRoleId]:[],cs=typeof H.level3UserRoleId=="number"&&H.level3UserRoleId>0?[H.level3UserRoleId]:[],Js=(Array.isArray(H.escalationSettingsActionTypeIds)?H.escalationSettingsActionTypeIds:[]).map(Ne=>Ae[Ne]||String(Ne)),Ks=(Array.isArray(H.thirdPartyId)?H.thirdPartyId:[]).map(Ne=>_e[Ne]||String(Ne)),us=typeof H.humanLoop=="boolean"?H.humanLoop:null,ds=typeof H.isAutoExpire=="boolean"?H.isAutoExpire:null;return{id:String(_.ruleId||_.ruleName||V),ruleOrSeverityLabel:ie,l1:{minutes:H.level1PostAssistTime??void 0,roles:ae},l2:{minutes:H.level2PostAssistTime??void 0,roles:ls},l3:{minutes:H.level3PostAssistTime??void 0,roles:cs},actions:Js,notify:Ks,humanLoop:us,isAutoExpire:ds}});Je(re)},[ge,e,Ae,_e]);const ne=f.useMemo(()=>t.map(R=>({label:R.DisplayName,value:R.SeverityId})),[t]),Ze=f.useMemo(()=>e.map(R=>({label:R.Name,value:R.RuleId})),[e]),Qe=f.useMemo(()=>ye.map(R=>({label:R.userRoleName,value:R.userRoleId})),[ye]),ze=f.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(R=>({label:`${R}`,value:R})),[]);f.useEffect(()=>{let R=!1;async function re(){try{q(!0),Q(null);const _=await l.getAdminSettings();if(!R&&_){const V=zn(_.sortBy);u(V),y(V),S(!1)}}catch(_){if(!R){const V=_ instanceof Error?_.message:"Failed to load admin settings";Q(V)}}finally{R||q(!1)}}return re(),()=>{R=!0}},[]),f.useEffect(()=>{if(!k)return;const R=ie=>{const H=Number(ie);return!isNaN(H)&&H>0?H:void 0},re=ie=>{const H=Number(ie);return!isNaN(H)&&H>0?H:void 0},_=(ge||[]).find(ie=>ie?.ruleId===k||ie?.ruleName===k||ie?.RuleId===k),V=Ts(_?.escalationSettings);if(V&&typeof V=="object"){oe(re(V.level1PostAssistTime)),w(R(V.level1UserRoleId)),I(re(V.level2PostAssistTime)),D(R(V.level2UserRoleId)),E(re(V.level3PostAssistTime)),P(R(V.level3UserRoleId));const ie=Array.isArray(V.escalationSettingsActionTypeIds)?V.escalationSettingsActionTypeIds:[];z(ie.map(H=>String(H))),le(Array.isArray(V.thirdPartyId)?V.thirdPartyId:[]),ce(!!V.humanLoop),xe(!!V.isAutoExpire)}},[Y,k,ge]);const aa=async()=>{try{X(!0);const R=await i.getRules(),re=Array.isArray(R)?R:Array.isArray(R?.data)?R.data:[];ke(re);const _=re.map((V,ie)=>{const H=e.find(Ne=>Ne.RuleId===(V.ruleId||V.ruleName))?.Name||V.ruleName||V.Name||"-",ae=Ts(V.escalationSettings??V.EscalationSettings),ls=typeof ae.level1UserRoleId=="number"&&ae.level1UserRoleId>0?[ae.level1UserRoleId]:[],cs=typeof ae.level2UserRoleId=="number"&&ae.level2UserRoleId>0?[ae.level2UserRoleId]:[],_s=typeof ae.level3UserRoleId=="number"&&ae.level3UserRoleId>0?[ae.level3UserRoleId]:[],Qs=(Array.isArray(ae.escalationSettingsActionTypeIds)?ae.escalationSettingsActionTypeIds:[]).map(Ne=>Ae[Ne]||String(Ne)),us=(Array.isArray(ae.thirdPartyId)?ae.thirdPartyId:[]).map(Ne=>_e[Ne]||String(Ne)),ds=typeof ae.humanLoop=="boolean"?ae.humanLoop:null;return{id:String(V.ruleId||V.ruleName||ie),ruleOrSeverityLabel:H,l1:{minutes:ae.level1PostAssistTime??void 0,roles:ls},l2:{minutes:ae.level2PostAssistTime??void 0,roles:cs},l3:{minutes:ae.level3PostAssistTime??void 0,roles:_s},actions:Qs,notify:us,humanLoop:ds}});Je(_)}catch(R){console.error("Failed to refetch entries",R)}finally{X(!1)}};f.useEffect(()=>{let R=!1;return(async()=>{try{const re=await i.getLookups();if(R||!re)return;const _={};if(Array.isArray(re.thirdParties))for(const ie of re.thirdParties)typeof ie.thirdPartyId=="number"&&(_[ie.thirdPartyId]=ie.thirdPartyName);vt(_);const V=Array.isArray(re.userRoles)?re.userRoles.map(ie=>({userRoleId:ie.userRoleId??ie.id,userRoleName:ie.userRoleName??ie.name})):[];R||ct(V.length?V:s||[])}catch(re){console.error("Error loading lookups",re)}})(),()=>{R=!0}},[]);const ia=async()=>{B(!0);try{const R=await l.setAdminSettings({sortBy:c,groupBy:"string"});R?.responseStatus&&R?.data&&we.toast.success(R.data),y(c),S(!1)}catch(R){console.error("Error saving admin settings",R)}finally{B(!1)}},oa=()=>{u(g),S(!1)},la=async()=>{O(!0),a?.({ruleId:k,levels:[{minutes:he,role:C},{minutes:x,role:v},{minutes:A,role:$}],actions:Z,thirdPartyIds:K,humanLoop:Se,isAutoExpire:ue});try{if(k){const re=Array.isArray(Z)?Z.map(ae=>Number.isNaN(Number(ae))?ae:Number(ae)):[],_=(ge||[]).find(ae=>ae?.ruleId===k||ae?.ruleName===k||ae?.RuleId===k),V=typeof _?.recordId=="number"?_.recordId:_?.ruleId||_?.RuleId||void 0;if(!_||!V){we.toast.error("Unable to find rule identifier for update");return}const ie={..._,escalationSettings:{level1UserRoleId:C??0,level1PostAssistTime:he??0,level2UserRoleId:v??0,level2PostAssistTime:x??0,level3UserRoleId:$??0,level3PostAssistTime:A??0,escalationSettingsActionTypeIds:re,thirdPartyId:Array.isArray(K)?K:[],humanLoop:Se,isAutoExpire:ue}},H=await i.updateRule(V,ie);H?.responseStatus||H?.Success||H?.success?(we.toast.success("Escalation settings saved"),await aa(),M(void 0),oe(void 0),w(void 0),I(void 0),D(void 0),E(void 0),P(void 0),z([]),le([]),ce(!1),xe(!1)):we.toast.error(H?.errorMessage||"Error saving Escalation Settings")}}catch(re){console.error("Error saving escalation settings",re)}finally{O(!1)}},ca=()=>{u("By Severity"),m("By severity"),F("rules"),p(void 0),M(void 0),oe(void 0),w(void 0),I(void 0),D(void 0),E(void 0),P(void 0),z([]),le([]),ce(!1),xe(!1)};return o.jsxs("div",{className:"w-full",children:[o.jsxs("div",{className:"mb-6",children:[o.jsx(Pn,{level:4,className:"!mb-2",children:"Admin Settings"}),o.jsxs(d.Spin,{spinning:j,children:[W?o.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",W]}):null,o.jsx(sl,{sortBy:c,groupBy:h,onChange:R=>{R.sortBy&&(u(R.sortBy),S(!0)),R.groupBy&&(m(R.groupBy),S(!0))},showActions:T,onSave:ia,onClear:oa,saving:b})]})]}),o.jsx(d.Divider,{className:"my-6"}),o.jsxs("div",{children:[o.jsx(Pn,{level:4,className:"!mb-4",children:"Escalation Settings"}),o.jsx(nl,{escBasis:Y,setEscBasis:F,selectedSeverity:se,setSelectedSeverity:p,selectedRule:k,setSelectedRule:M,severityOptions:ne,ruleOptions:Ze,minsOptions:ze,roleOptions:Qe,l1mins:he,setL1mins:oe,l1role:C,setL1role:w,l2mins:x,setL2mins:I,l2role:v,setL2role:D,l3mins:A,setL3mins:E,l3role:$,setL3role:P,actions:Z,setActions:z,thirdPartyIds:K,setThirdPartyIds:le,humanLoop:Se,setHumanLoop:ce,onClear:ca,onSave:la,saving:os,onActionTypesLoaded:R=>{const re={};for(const _ of R)typeof _.actionTypeId=="number"&&(re[_.actionTypeId]=_.name);Ce(re)},isAutoExpire:ue,setAutoExpire:xe})]}),o.jsx(d.Divider,{className:"my-6"}),o.jsx(rl,{entries:Tt,userRoles:ye,loading:G||r,onEdit:R=>{F("rules");const re=Tt.find(V=>V.id===R),_=e.find(V=>V.RuleId===R)||(re?e.find(V=>V.Name===re.ruleOrSeverityLabel):void 0);M(_?_.RuleId:R)}}),o.jsx(d.Divider,{className:"my-6"}),o.jsx(Kr,{userRoles:ye,rules:e,rawRules:n}),o.jsx(d.Divider,{})]})}const{Title:Wn,Text:zt}=d.Typography;function il({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:a}=Oe(),i=[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],[l,c]=f.useState("By Severity"),[u,h]=f.useState(new Set),[m,g]=f.useState(null),[y,T]=f.useState(null),[S,b]=f.useState({inApp:!1,sms:!1,email:!1}),[B,j]=f.useState([]),[q,W]=f.useState(!0),[Q,Y]=f.useState(!1);f.useEffect(()=>{let p=!1;return(async()=>{try{const k=await a.getPreferenceSettings();if(p||!k)return;b({inApp:!!k.inApp,sms:!!k.sms,email:!!k.email});const M=zn(k.sortBy);c(M==="By Created Date"?"By Created Date":"By Severity"),g(an(k.doNotDisturbStart)),T(an(k.doNotDisturbEnd)),Array.isArray(k.anomalyIds)&&h(new Set(k.anomalyIds.map(he=>String(he))))}catch(k){console.error("Error in loading my preferences: ",k)}})(),()=>{p=!0}},[]),f.useEffect(()=>{let p=!1;return(async()=>{try{W(!0);const k=await r.getLookups();if(p||!k)return;const M=Array.isArray(k.anomalies)?k.anomalies:[];j(M)}catch(k){console.error("Failed to load anomalies lookups",k)}finally{p||W(!1)}})(),()=>{p=!0}},[]);const F=p=>{h(k=>{const M=new Set(k);return M.has(p)?M.delete(p):M.add(p),M})},se=async()=>{s?.({sortBy:l,subscribedRuleIds:Array.from(u),dnd:{from:m,to:y},channels:S});try{Y(!0);const p=m?m.format?.("HH:mm:ss")??"00:00:00":"00:00:00",k=y?y.format?.("HH:mm:ss")??"00:00:00":"00:00:00",M=Array.from(u).map(oe=>Number(oe)).filter(oe=>Number.isFinite(oe)),he=await a.setPreferenceSettings({anomalyIds:M,doNotDisturbStart:p,doNotDisturbEnd:k,inApp:!!S.inApp,sms:!!S.sms,email:!!S.email,sortBy:l});he?.responseStatus&&we.toast.success(he?.data||"Preferences updated successfully.")}catch(p){console.error("Error in saving my preferences: ",p)}finally{Y(!1)}};return o.jsxs("div",{className:"w-full",children:[o.jsx(d.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:o.jsx(d.Col,{xs:24,md:8,children:o.jsxs(d.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[o.jsx(zt,{className:"text-gray-600",children:"Sort By:"}),o.jsx(d.Select,{className:"w-[240px]",value:l,options:i,onChange:c})]})})}),o.jsxs("div",{className:"mb-4",children:[o.jsx(Wn,{level:5,className:"!mb-2",children:"Anomalies"}),q?o.jsx("div",{className:"py-4",children:o.jsx(d.Spin,{})}):o.jsx(d.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray(B)?B:[]).map(p=>{const k=String(p.recordId),M=p.anomalyName;return o.jsx(d.Checkbox,{checked:u.has(k),onChange:()=>F(k),children:M},k)})})]}),o.jsxs("div",{className:"mb-4",children:[o.jsx(Wn,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),o.jsx(d.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:o.jsx(d.Col,{xs:24,md:12,children:o.jsxs(d.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[o.jsx(zt,{children:"Do Not Disturb mode:"}),o.jsxs(d.Space,{size:12,className:"w-full",children:[o.jsxs(d.Space,{direction:"horizontal",size:8,className:"items-center",children:[o.jsx(zt,{children:"From"}),o.jsx(d.TimePicker,{value:m,onChange:p=>g(p),format:"HH:mm"})]}),o.jsxs(d.Space,{direction:"horizontal",size:8,className:"items-center",children:[o.jsx(zt,{children:"To"}),o.jsx(d.TimePicker,{value:y,onChange:p=>T(p),format:"HH:mm"})]})]})]})})}),o.jsxs(d.Row,{gutter:[24,12],children:[o.jsx(d.Col,{children:o.jsx(d.Checkbox,{checked:S.inApp,onChange:p=>b({...S,inApp:p.target.checked}),children:"In-app"})}),o.jsx(d.Col,{children:o.jsx(d.Checkbox,{checked:S.sms,onChange:p=>b({...S,sms:p.target.checked}),children:"SMS"})}),o.jsx(d.Col,{children:o.jsx(d.Checkbox,{checked:S.email,onChange:p=>b({...S,email:p.target.checked}),children:"Email"})})]})]}),o.jsx(d.Divider,{}),o.jsxs(d.Space,{className:"gap-3",children:[o.jsx(d.Button,{onClick:n,disabled:Q,children:"Cancel"}),o.jsx(d.Button,{type:"primary",onClick:se,loading:Q,children:"Save"})]})]})}function ea({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r}){return o.jsx("div",{className:"w-full",children:o.jsx(Xr,{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=",ll="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 is(){const{config:t}=Oe();return{timeZoneDetails:f.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"?o.jsx("img",{src:ol,alt:"completed",style:{width:20,height:20}}):o.jsx("img",{src:ll,alt:"pending",style:{width:20,height:20}});return{title:o.jsxs("div",{className:"flex flex-col gap-0 min-w-0",children:[o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"block text-sm break-words mb-1 overflow-visible whitespace-normal",children:o.jsx("b",{children:t.title})}),t.description?o.jsx("span",{className:"text-gray-500 text-xs",children:t.description}):null]}),t.timestamp?o.jsx("span",{className:"text-gray-500 text-xs",children:t.timestamp}):null]}),icon:e,description:null}}function ul({data:t}){const{timeZoneDetails:e}=is();return console.log("summary",t),o.jsx("div",{className:"w-full",children:o.jsx(d.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:o.jsxs("div",{className:"w-full",style:{maxHeight:"50vh",overflowY:"auto"},children:[o.jsx(d.Card,{className:"mb-4 rounded-md p-4",bordered:!0,children:o.jsxs("div",{className:"grid grid-cols-4 gap-6 text-xs",children:[o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"text-gray-500",children:"Alert ID"}),o.jsx("span",{className:"text-black",children:t.summary.alertNumber})]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"text-gray-500",children:"Severity"}),o.jsx("span",{className:"text-black",children:t.summary.severity})]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"text-gray-500",children:"Location"}),o.jsx("span",{className:"text-black",children:t.summary.location})]})]})}),o.jsxs(d.Card,{className:"rounded-md p-4",bordered:!0,children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsx("h4",{className:"text-sm text-black font-medium",children:"Response Timeline/ Audit trail/log"})}),o.jsx("div",{className:"mt-2",children:o.jsx(d.Steps,{direction:"vertical",size:"small",current:1,items:(t.timeline||[]).map(cl)})})]})]})},{key:"notification",label:"Notification Sent",children:o.jsxs("div",{className:"grid grid-cols-2 gap-4",style:{maxHeight:"50vh",overflowY:"auto"},children:[(t.notifications||[]).map((s,n)=>o.jsxs(d.Card,{className:"rounded-md p-4",bordered:!0,children:[o.jsxs("div",{className:"flex items-start justify-between",children:[o.jsxs("div",{className:"flex flex-col",children:[o.jsx("h4",{className:"text-sm text-black font-medium",children:s.channelLabel}),o.jsx("span",{className:"text-xs text-gray-500 mt-1",children:Xt(s.sentAt,e?.ianaTimeZoneId)})]}),o.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"]})]}),o.jsxs("div",{className:"mt-4 text-xs",children:[o.jsxs("div",{className:"text-black",children:[" ",s.messageTitle]}),s.messageBody?o.jsx("div",{className:"text-gray-600",children:s.messageBody}):null]}),o.jsxs("div",{className:"mt-4",children:[o.jsxs("div",{className:"text-xs text-black font-medium",children:["Recipients (",s.total,")"]}),o.jsx("div",{className:"mt-2 flex flex-col gap-3 text-xs",children:(s.recipients||[]).map((r,a)=>{const i=String(r?.notificationReceipientType||"").toLowerCase()==="EscalationNotification".toLowerCase();return o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex flex-col",children:[o.jsxs("span",{className:"text-black",children:[r.name," - ",o.jsx("span",{style:{color:i?"#FF3B30":"#FFB86A"},children:i?"Escalation Notification":"Alert Notification"})]}),o.jsxs("span",{className:"text-gray-500",children:[r.role," . ",r.phone]})]}),o.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:o.jsx("span",{className:"text-gray-500 text-xs",children:"No notifications."})]})}]})})}const dl=({alertId:t,id:e,priority:s,spaceName:n,alertNumber:r,statusHistory:a,notifGroups:i})=>{const l={alertId:t??String(e??""),incidentId:"-",severity:s||"",location:n||"",alertNumber:r??""},{timeZoneDetails:c}=is(),u=a?.length?a.map(m=>{const g=(m?.status||m?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",y=m?.createdDate?Xt(m.createdDate,c?.ianaTimeZoneId):m?.timestamp?Xt(m.timestamp,c?.ianaTimeZoneId):"";return{status:g,title:m?.status||m?.eventStatus||"Status Update",description:m?.description||m?.actionNotes||"",timestamp:y}}):[],h={summary:l,timeline:u,notifications:i??[]};return o.jsx(ul,{data:h})};const ml=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),fl=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),Vn=t=>{const e=fl(t);return e.charAt(0).toUpperCase()+e.slice(1)},ta=(...t)=>t.filter((e,s,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===s).join(" ").trim(),hl=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var yl={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 gl=f.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:a,iconNode:i,...l},c)=>f.createElement("svg",{ref:c,...yl,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:ta("lucide",r),...!a&&!hl(l)&&{"aria-hidden":"true"},...l},[...i.map(([u,h])=>f.createElement(u,h)),...Array.isArray(a)?a:[a]]));const Gs=(t,e)=>{const s=f.forwardRef(({className:n,...r},a)=>f.createElement(gl,{ref:a,iconNode:e,className:ta(`lucide-${ml(Vn(t))}`,`lucide-${t}`,n),...r}));return s.displayName=Vn(t),s};const pl=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Sl=Gs("loader-circle",pl);const xl=[["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"}]],sa=Gs("maximize-2",xl);const wl=[["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"}]],vl=Gs("minimize-2",wl),Tl=({isOpen:t,onClose:e,src:s,type:n="image"})=>{const[r,a]=f.useState(!1),[i,l]=f.useState(!1);return f.useEffect(()=>{t&&l(!1)},[t,s]),f.useEffect(()=>{t&&(!s||i)&&e()},[t,s,i,e]),t?o.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:o.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"?o.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)}):o.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)}),o.jsx("button",{onClick:e,className:"absolute top-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:"✕"}),o.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?o.jsx(vl,{size:20}):o.jsx(sa,{size:20})})]})}):null};function Al(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 Bn(t){const e=(t?.mediaType||t?.type||"").toString().toLowerCase();return e==="video"||e==="mp4"?!0:Al(t?.mediaUrl||t)}function Nl(t){const e=t;return e?Array.isArray(e)?e:[e]:[]}const bl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},kl={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Il=({isModalOpen:t,handleModalClose:e,selectedRow:s,fetchAlertLogs:n,alertStatusList:r=[],alertStatusLoading:a=!1,initialTab:i="details",sourceTab:l})=>{const[c,u]=f.useState(),[h,m]=f.useState(""),[g,y]=f.useState(!1),T=f.useRef(null),[S,b]=f.useState("details"),[B,j]=f.useState(void 0),q=$s(),{alerts:W}=Oe(),{timeZoneDetails:Q}=is(),[Y,F]=f.useState(!1),[se,p]=f.useState(void 0),[k,M]=f.useState(void 0),[he,oe]=f.useState({}),[C,w]=f.useState({}),x=s?.originalData||{},{eventName:I,alertId:v,timestamp:D,description:A,spaceName:E,assignTeam:$,priority:P,statusType:Z,id:z,alertDetails:K,statusHistory:le,mediaDetails:Se,alertNumber:ce}=x,ue=O=>{const G=String(O||"").toLowerCase();return G==="delivered"||G==="sent"?"Delivered":G==="failed"?"Failed":"Queued"},xe=O=>({name:O?.receipientName||O?.recipientName||"-",role:O?.receipientRoleName||"",phone:O?.receipentPhoneNumber||O?.recipientPhoneNumber||O?.receipientEmail||O?.recipientEmail||"",status:ue(O?.messageStatus),notificationReceipientType:O?.notificationReceipientType||""}),Ae=(O,G)=>{const X=G.map(xe),ge=X.filter(Qe=>Qe.status==="Delivered").length,ke=G.map(Qe=>Qe?.sentAt).filter(Boolean).sort((Qe,ze)=>new Date(ze).getTime()-new Date(Qe).getTime())[0],ne=G[0]||{},Ze=[ne?.severityName,ne?.anomalyName].filter(Boolean).join(" - ")||`${O} Notification`;return{channelLabel:`${O} Notification`,sentAt:ke||"",messageTitle:Ze,messageBody:"",total:X.length,delivered:ge,recipients:X}},Ce=O=>{const G=new Map;return(O||[]).forEach(X=>{const ge=String(X?.notificationType||"Unknown"),ke=G.get(ge)||[];ke.push(X),G.set(ge,ke)}),Array.from(G.entries()).map(([X,ge])=>Ae(X,ge))},_e=async O=>{try{const G=await W.getAlertNotifications(O),X=Ce(G);j(X)}catch{j(void 0)}};f.useEffect(()=>{if(S!=="track"||!z)return;let O=!1;return _e(z).then(()=>{O&&j(void 0)}),()=>{O=!0}},[S,z]),f.useEffect(()=>{t&&b(i)},[t,i]);const ye=l==="archived"||["completed","false positive"].includes(String(Z||"").toLowerCase()),ct=O=>{const G=String(O?.value||"").toLowerCase(),X=String(O?.statusName||"").toLowerCase();return G.includes("reopen")||X.includes("reopen")},Tt=(r||[]).filter(O=>{const G=ct(O);return typeof l<"u"?l==="archived"?G:!G:ye?G:!G}).map(O=>({value:O.value,label:O.statusName})),Je=f.useMemo(()=>Nl(Se),[Se]);f.useEffect(()=>{let O=!1;const G=new AbortController,X=async ne=>{if(ne){O||oe(Ze=>({...Ze,[ne]:!1}));try{const Ze=await fetch(ne,{method:"HEAD",signal:G.signal});if(Ze.ok){O||oe(ze=>({...ze,[ne]:!0}));return}if(Ze.status===404){O||oe(ze=>({...ze,[ne]:!1}));return}if(!(await fetch(ne,{method:"GET",signal:G.signal})).ok)throw new Error("Media not available");O||oe(ze=>({...ze,[ne]:!0}))}catch{O||oe(Ze=>({...Ze,[ne]:!1}))}}};oe({});const ge=Je.filter(ne=>!Bn(ne)).map(ne=>ne?.mediaUrl||ne).filter(ne=>typeof ne=="string"&&ne.length>0),ke={};return ge.forEach(ne=>{ke[ne]=!0}),w(ke),ge.forEach(ne=>X(ne)),()=>{O=!0,G.abort()}},[Je]);const os=async()=>{try{y(!0);const O={alertUniqueId:v,alertId:z,status:c?String(c):void 0,notes:h.trim(),modifiedBy:0},G=await q.mutateAsync(O);if(G?.responseStatus||G?.Success){const X=G?.Message||G?.data||"Alert updated successfully.";we.toast.success(X,{autoClose:1500,onClose:()=>{n(),e()}}),u(void 0),m("")}else{const X=G?.errorMessage||G?.Message||"Failed to update alert status";we.toast.error(X)}}catch(O){console.error("Error updating alert status:",O),we.toast.error("Failed to update alert status. Please try again.")}finally{y(!1)}};return o.jsx(d.Modal,{open:t,onCancel:e,width:1e3,footer:S==="details"?o.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[o.jsx(d.Button,{onClick:e,className:"bg-[#6C757D] text-white",children:"Cancel"}),o.jsx(d.Button,{type:"primary",onClick:os,loading:g,children:g?"Saving...":"Save Changes"})]}):null,children:s&&o.jsx(d.Tabs,{activeKey:S,onChange:O=>b(O),items:[{key:"details",label:"Alert Detail",children:o.jsxs("div",{className:"grid grid-cols-2 gap-2",style:{maxHeight:"50vh",overflowY:"auto"},children:[o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsx("div",{className:"text-sm font-bold",children:I||"Alert Event"}),K?.firstName?o.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",K?.firstName," ",K?.lastName||"","   ",K?.residentId||""]}):null,o.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp: ",Xt(D,Q?.ianaTimeZoneId)]}),o.jsxs("div",{className:"font-sm text-gray-500",children:[o.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",A||"No description available"]}),E&&o.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",E]}),$&&o.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",$]}),o.jsxs("div",{className:"flex gap-2 justify-start mt-3",children:[o.jsxs(d.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${bl[String(P)]||"#DFE4EA"}`,backgroundColor:kl[String(P)]},children:["Severity: ",P||"N/A"]}),o.jsxs(d.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(Z||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",Z||"N/A"]})]}),o.jsx("div",{className:"w-full flex flex-col justify-start items-start mt-2 font-bold",children:o.jsxs("div",{className:"w-full mt-4",children:[o.jsx("div",{className:"flex flex-col gap-2",children:o.jsx(d.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:O=>u(O),value:c,options:Tt,loading:a})}),o.jsxs("div",{className:"flex flex-col gap-2 mt-3",children:[o.jsx("label",{htmlFor:"action-details-input",className:"text-xs text-gray-500 font-medium",children:"Action Taken (Comments)"}),o.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:O=>m(O.target.value)})]})]})})]}),o.jsx("div",{className:"flex flex-col gap-4",children:o.jsxs("div",{className:"w-full mt-1",children:[o.jsxs("div",{className:"w-full flex items-center justify-between",children:[o.jsx("h3",{className:"text-black font-bold text-sm",children:"Camera Footage"}),Je.length>1?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{type:"button",onClick:()=>T.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:o.jsx(it.LeftOutlined,{style:{fontSize:12}})}),o.jsx("button",{type:"button",onClick:()=>T.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:o.jsx(it.RightOutlined,{style:{fontSize:12}})})]}):null]}),Je.length?o.jsx("div",{className:"w-full",children:o.jsx(d.Carousel,{ref:T,dots:!0,className:"w-full",children:Je.map((O,G)=>{const X=O.mediaUrl||O,ge=Bn(O),ke=!ge&&C[String(X)];return o.jsxs("div",{className:"flex justify-center items-center relative",children:[ge?o.jsxs("video",{width:"240",height:"200",controls:!0,className:"max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg",children:[o.jsx("source",{src:X}),"Your browser does not support the video tag."]}):o.jsxs("div",{className:"relative w-full flex justify-center items-center min-h-[200px]",children:[ke&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg z-10",children:o.jsx(Sl,{size:32,className:"animate-spin text-gray-400"})}),o.jsx("img",{src:X,alt:O.caption||`media-${G}`,className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg transition-opacity duration-200 ${ke?"opacity-0":"opacity-100"}`,onLoad:()=>w(ne=>({...ne,[String(X)]:!1})),onError:()=>w(ne=>({...ne,[String(X)]:!1}))},String(X))]}),O.caption&&o.jsx("p",{className:"text-xs text-gray-500 mt-1",children:O.caption}),!ge&&he[String(X)]?o.jsx("button",{onClick:()=>{F(!0),p(X),M(O.type||"image")},className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:o.jsx(sa,{size:20})}):null]},String(X)||G)})})}):null]})}),o.jsx(Tl,{isOpen:Y,onClose:()=>F(!1),src:se||"",type:k||"image"})]})},{key:"track",label:"Track Incident",children:o.jsx(dl,{alertId:v,id:z,priority:P,spaceName:E,alertNumber:ce,statusHistory:le,notifGroups:B})}]})})};function na(){const{alerts:t}=Oe(),e=ot.useQuery({queryKey:["alerts","statusList"],queryFn:()=>t.getAlertStatusList(),staleTime:5*6e4});return{list:e.data??[],loading:e.isLoading,error:e.error,refetch:e.refetch}}function Ys({alerts:t,loading:e=!1,columns:s,onRefetch:n,onPageChange:r}){const[a,i]=f.useState(!1),[l,c]=f.useState(null),[u,h]=f.useState("details"),{list:m,loading:g}=na(),{timeZoneDetails:y}=is(),T=y?.timeZoneName??"UTC",S=y?.ianaTimeZoneId??"UTC";function b(Q,Y){c(Q),h(Y?.tab??"details"),q(Y?.sourceTab??"active"),i(!0)}function B(){i(!1)}const[j,q]=f.useState("active"),W=l?{originalData:{...l,alertId:l.alertId??l.id,mediaDetails:l.mediaDetails}}:null;return o.jsxs("div",{className:"p-6 flex flex-col items-start justify-start min-h-screen w-full overflow-auto",children:[o.jsxs("div",{className:"w-full grid grid-cols-3 sm:grid-cols-1 items-center mb-4",children:[o.jsx("h1",{className:"text-xl font-bold text-black",children:"Alert Console"}),o.jsx("div",{className:"flex items-center justify-start sm:justify-center",children:o.jsx(Qr,{label:T,timeZone:S})})]}),o.jsx(d.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:Q=>{Q==="active"&&n?.()},items:[{key:"active",label:"Active",children:o.jsx(Fs,{data:t,loading:e,pageSize:10,columns:s||[],onAlertIdClick:b,onRefetch:n,onPageChange:r})},{key:"archived",label:"Archived",children:o.jsx(Jr,{alerts:t,loading:e,columns:s||[],onAlertIdClick:b})},{key:"settings",label:"Settings",children:o.jsx(El,{})}]}),o.jsx(Il,{isModalOpen:a,handleModalClose:B,selectedRow:W,fetchAlertLogs:()=>{},alertStatusList:m,alertStatusLoading:g,initialTab:u,sourceTab:j})]})}function El(){const[t,e]=f.useState([]),[s,n]=f.useState([]),[r,a]=f.useState([]),[i,l]=f.useState([]),[c,u]=f.useState(!0),{rules:h}=Oe();return f.useEffect(()=>{let m=!0;return(async()=>{try{const g=await h.getRules();if(!m)return;l(Array.isArray(g)?g:[]);const y=(g||[]).map((T,S)=>({RuleId:T.ruleId||T.ruleName||String(S),Name:T.ruleName||T.Name||"-",Description:T.ruleDesc||T.Description||"",SeverityId:0}));e(y);try{const T=await h.getLookups(),S=Array.isArray(T?.userRoles)?T.userRoles.map(b=>({userRoleId:b.userRoleId??b.id,userRoleName:b.userRoleName??b.name})):[];n(S),a(Array.isArray(T?.severities)?T.severities:[])}catch{}}catch{}finally{m&&u(!1)}})(),()=>{m=!1}},[]),o.jsx(ea,{severities:r,rules:t,userRoles:s,rawRules:i,loadingRules:c})}function ra(t=1){const{alerts:e}=Oe(),s=ot.useQuery({queryKey:["alerts","list",t],queryFn:()=>e.listAlerts({pageNumber:t,pageSize:10}),staleTime:3e4});return{alerts:s.data??[],loading:s.isLoading,error:s.error,refetch:s.refetch}}function Ml(t){const[e,s]=f.useState(1),{alerts:n,loading:r,refetch:a}=ra(e);return o.jsx(Ys,{alerts:n,loading:r,columns:t.columns,onRefetch:a,onPageChange:s})}function Ol({tenant:t,apiDomain:e,rulesDomain:s,headers:n,timeZone:r,userManagementDomain:a,alerts:i,loading:l,columns:c}){const[u]=f.useState(()=>new ot.QueryClient),h=f.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return o.jsx(ot.QueryClientProvider,{client:u,children:o.jsx(Gn,{tenant:t,override:h,timeZone:r,userManagementDomain:a,children:Array.isArray(i)?o.jsx(Ys,{alerts:i,loading:!!l,columns:c}):o.jsx(Ml,{columns:c})})})}function Cl(t){const{alerts:e}=Oe(),s=ot.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 jl=[{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=Kr;exports.AlertConsole=Ys;exports.AlertConsoleWidget=Ol;exports.AlertsTable=Fs;exports.ApiProvider=Gn;exports.ArchivedTable=Jr;exports.Clock=Qr;exports.DataTable=Yn;exports.MyPreferencesPanel=il;exports.SettingsPanel=Xr;exports.SettingsTabs=ea;exports.exampleAlertColumns=jl;exports.useAlertStatusList=na;exports.useAlerts=ra;exports.useAlertsReport=Cl;exports.useApi=Oe;exports.useUpdateAlertStatus=$s;
2
2
  //# sourceMappingURL=index.cjs.map