@ssgc/alert-console 2.5.0 → 2.6.0

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 a=require("react/jsx-runtime"),m=require("react"),d=require("antd"),rt=require("@ant-design/icons"),Ae=require("react-toastify"),Xe=require("@tanstack/react-query"),ri="#FF3B30",ii="#FF9500",ai="#FFCC00",oi="#34C759",Rt={critical:ri,high:ii,medium:ai,low:oi},Gs={Critical:Rt.critical,High:Rt.high,Medium:Rt.medium,Low:Rt.low};function li(t){return Gs[t]||Gs.Low}function _s(t){if(!t||typeof t!="string")return 0;const e=t.trim().split(":");if(e.length!==3)return 0;const[s,n,r]=e,i=Number.parseInt(s,10),o=Number.parseInt(n,10),l=Number.parseFloat(r||"0"),c=Number.isFinite(i)?i:0,u=Number.isFinite(o)?o:0,f=Number.isFinite(l)?l:0;return c*3600+u*60+f}function Js(t){const e=t.thirdPartyIds??t.ThirdPartyIds??t.thirdPartyId??t.ThirdPartyId??"",s=Array.isArray(e)?e.join(","):String(e??"");if(!s||!s.trim())return[];const n=s.split(",").map(o=>parseInt(String(o).trim(),10)).filter(o=>Number.isFinite(o)),r=new Set,i=[];return n.forEach(o=>{r.has(o)||(r.add(o),i.push(o))}),i}const Un="",ci=Un,ui="",di="",Qs={snl:{alerts:Un,rules:ci},schools:{alerts:ui,rules:di}};function Ie(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function mi(){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 Ce(t,e){const s={...e.headers,...mi()},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 i={};if(r)try{i=JSON.parse(r)}catch{i={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=i?.errorMessage||i?.message||`HTTP ${n.status}`;throw new Error(o)}return i}function fi(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=Ie(t.baseUrl,"/api/Alert"),n=await Ce(s,{method:"GET",headers:e});return Array.isArray(n)?n:[]},async getAlertStatusList(){const s=Ie(t.baseUrl,"/api/Alert/AlertStatusList"),n=await Ce(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=Ft(n,s),i=await Ce(r,{method:"GET",headers:e});return Array.isArray(i)?i:[]},async updateAlertStatus(s){const n=Ie(t.baseUrl,"/api/Alert/status");return Ce(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=Ie(t.baseUrl,"/api/Alert/GetAdminSettings"),n=await Ce(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 Ce(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Ie(t.baseUrl,"/api/Alert/GetPreferenceSettings"),n=await Ce(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=Ie(t.baseUrl,"/api/Alert/SetPreferenceSettings"),r=await Ce(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),i=r?.responseStatus??!0,o=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:i,errorMessage:i?"":r?.errorMessage??r?.message??"",statusCode:200,data:o}},async getAlertNotifications(s){const n=Ie(t.baseUrl,"/api/Alert/GetNotifications"),r=Ft(n,{alertId:s}),i=await Ce(r,{method:"GET",headers:e});return Array.isArray(i)?i:i&&typeof i=="object"&&Array.isArray(i.data)?i.data:[]},async notifyFamilyMembers(s){const n=Ie(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=Ft(n,{alertId:s});return Ce(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const i=Ie(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),o=Ft(i,{alertId:s,isEmail:n,isSMS:r});return Ce(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Ie(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Ce(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 Ce(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 Ks(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function hi(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Lt(t,e){const s={...e.headers,...hi()},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 i={};if(r)try{i=JSON.parse(r)}catch{i={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=i?.errorMessage||i?.message||`HTTP ${n.status}`;throw new Error(o)}return i}function yi(t){const e={"Content-Type":"application/json",...t.headers||{}},s=Ks(t.baseUrl,"/api/Rules"),n=Ks(t.baseUrl,"/api/Rules/lookups");return{async getRules(){const r=await Lt(s,{method:"GET",headers:e});return Array.isArray(r)?r:[]},async setEscalationSettings(r){return Lt(s,{method:"POST",headers:e,body:JSON.stringify(r??{})})},async getLookups(){return Lt(n,{method:"GET",headers:e})},async updateRule(r,i){const o=`${s}/${r}`;return Lt(o,{method:"PUT",headers:e,body:JSON.stringify(i??{})})}}}function pi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var zt={exports:{}},gi=zt.exports,Xs;function Si(){return Xs||(Xs=1,(function(t,e){(function(s,n){t.exports=n()})(gi,(function(){var s=1e3,n=6e4,r=36e5,i="millisecond",o="second",l="minute",c="hour",u="day",f="week",h="month",p="quarter",y="year",k="date",b="Invalid Date",A=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,z=/\[([^\]]+)]|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(O){var w=["th","st","nd","rd"],S=O%100;return"["+O+(w[(S-20)%10]||w[S]||w[0])+"]"}},Z=function(O,w,S){var I=String(O);return!I||I.length>=w?O:""+Array(w+1-I.length).join(S)+O},se={s:Z,z:function(O){var w=-O.utcOffset(),S=Math.abs(w),I=Math.floor(S/60),x=S%60;return(w<=0?"+":"-")+Z(I,2,"0")+":"+Z(x,2,"0")},m:function O(w,S){if(w.date()<S.date())return-O(S,w);var I=12*(S.year()-w.year())+(S.month()-w.month()),x=w.clone().add(I,h),v=S-x<0,T=w.clone().add(I+(v?-1:1),h);return+(-(I+(S-x)/(v?x-T:T-x))||0)},a:function(O){return O<0?Math.ceil(O)||0:Math.floor(O)},p:function(O){return{M:h,y,w:f,d:u,D:k,h:c,m:l,s:o,ms:i,Q:p}[O]||String(O||"").toLowerCase().replace(/s$/,"")},u:function(O){return O===void 0}},X="en",_={};_[X]=F;var ee="$isDayjsObject",re=function(O){return O instanceof ce||!(!O||!O[ee])},g=function O(w,S,I){var x;if(!w)return X;if(typeof w=="string"){var v=w.toLowerCase();_[v]&&(x=v),S&&(_[v]=S,x=v);var T=w.split("-");if(!x&&T.length>1)return O(T[0])}else{var D=w.name;_[D]=w,x=D}return!I&&x&&(X=x),x||!I&&X},C=function(O,w){if(re(O))return O.clone();var S=typeof w=="object"?w:{};return S.date=O,S.args=arguments,new ce(S)},E=se;E.l=g,E.i=re,E.w=function(O,w){return C(O,{locale:w.$L,utc:w.$u,x:w.$x,$offset:w.$offset})};var ce=(function(){function O(S){this.$L=g(S.locale,null,!0),this.parse(S),this.$x=this.$x||S.x||{},this[ee]=!0}var w=O.prototype;return w.parse=function(S){this.$d=(function(I){var x=I.date,v=I.utc;if(x===null)return new Date(NaN);if(E.u(x))return new Date;if(x instanceof Date)return new Date(x);if(typeof x=="string"&&!/Z$/i.test(x)){var T=x.match(A);if(T){var D=T[2]-1||0,P=(T[7]||"0").substring(0,3);return v?new Date(Date.UTC(T[1],D,T[3]||1,T[4]||0,T[5]||0,T[6]||0,P)):new Date(T[1],D,T[3]||1,T[4]||0,T[5]||0,T[6]||0,P)}}return new Date(x)})(S),this.init()},w.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()},w.$utils=function(){return E},w.isValid=function(){return this.$d.toString()!==b},w.isSame=function(S,I){var x=C(S);return this.startOf(I)<=x&&x<=this.endOf(I)},w.isAfter=function(S,I){return C(S)<this.startOf(I)},w.isBefore=function(S,I){return this.endOf(I)<C(S)},w.$g=function(S,I,x){return E.u(S)?this[I]:this.set(x,S)},w.unix=function(){return Math.floor(this.valueOf()/1e3)},w.valueOf=function(){return this.$d.getTime()},w.startOf=function(S,I){var x=this,v=!!E.u(I)||I,T=E.p(S),D=function(ge,oe){var pe=E.w(x.$u?Date.UTC(x.$y,oe,ge):new Date(x.$y,oe,ge),x);return v?pe:pe.endOf(u)},P=function(ge,oe){return E.w(x.toDate()[ge].apply(x.toDate("s"),(v?[0,0,0,0]:[23,59,59,999]).slice(oe)),x)},U=this.$W,W=this.$M,V=this.$D,ae="set"+(this.$u?"UTC":"");switch(T){case y:return v?D(1,0):D(31,11);case h:return v?D(1,W):D(0,W+1);case f:var he=this.$locale().weekStart||0,fe=(U<he?U+7:U)-he;return D(v?V-fe:V+(6-fe),W);case u:case k:return P(ae+"Hours",0);case c:return P(ae+"Minutes",1);case l:return P(ae+"Seconds",2);case o:return P(ae+"Milliseconds",3);default:return this.clone()}},w.endOf=function(S){return this.startOf(S,!1)},w.$set=function(S,I){var x,v=E.p(S),T="set"+(this.$u?"UTC":""),D=(x={},x[u]=T+"Date",x[k]=T+"Date",x[h]=T+"Month",x[y]=T+"FullYear",x[c]=T+"Hours",x[l]=T+"Minutes",x[o]=T+"Seconds",x[i]=T+"Milliseconds",x)[v],P=v===u?this.$D+(I-this.$W):I;if(v===h||v===y){var U=this.clone().set(k,1);U.$d[D](P),U.init(),this.$d=U.set(k,Math.min(this.$D,U.daysInMonth())).$d}else D&&this.$d[D](P);return this.init(),this},w.set=function(S,I){return this.clone().$set(S,I)},w.get=function(S){return this[E.p(S)]()},w.add=function(S,I){var x,v=this;S=Number(S);var T=E.p(I),D=function(W){var V=C(v);return E.w(V.date(V.date()+Math.round(W*S)),v)};if(T===h)return this.set(h,this.$M+S);if(T===y)return this.set(y,this.$y+S);if(T===u)return D(1);if(T===f)return D(7);var P=(x={},x[l]=n,x[c]=r,x[o]=s,x)[T]||1,U=this.$d.getTime()+S*P;return E.w(U,this)},w.subtract=function(S,I){return this.add(-1*S,I)},w.format=function(S){var I=this,x=this.$locale();if(!this.isValid())return x.invalidDate||b;var v=S||"YYYY-MM-DDTHH:mm:ssZ",T=E.z(this),D=this.$H,P=this.$m,U=this.$M,W=x.weekdays,V=x.months,ae=x.meridiem,he=function(oe,pe,be,ke){return oe&&(oe[pe]||oe(I,v))||be[pe].slice(0,ke)},fe=function(oe){return E.s(D%12||12,oe,"0")},ge=ae||function(oe,pe,be){var ke=oe<12?"AM":"PM";return be?ke.toLowerCase():ke};return v.replace(z,(function(oe,pe){return pe||(function(be){switch(be){case"YY":return String(I.$y).slice(-2);case"YYYY":return E.s(I.$y,4,"0");case"M":return U+1;case"MM":return E.s(U+1,2,"0");case"MMM":return he(x.monthsShort,U,V,3);case"MMMM":return he(V,U);case"D":return I.$D;case"DD":return E.s(I.$D,2,"0");case"d":return String(I.$W);case"dd":return he(x.weekdaysMin,I.$W,W,2);case"ddd":return he(x.weekdaysShort,I.$W,W,3);case"dddd":return W[I.$W];case"H":return String(D);case"HH":return E.s(D,2,"0");case"h":return fe(1);case"hh":return fe(2);case"a":return ge(D,P,!0);case"A":return ge(D,P,!1);case"m":return String(P);case"mm":return E.s(P,2,"0");case"s":return String(I.$s);case"ss":return E.s(I.$s,2,"0");case"SSS":return E.s(I.$ms,3,"0");case"Z":return T}return null})(oe)||T.replace(":","")}))},w.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},w.diff=function(S,I,x){var v,T=this,D=E.p(I),P=C(S),U=(P.utcOffset()-this.utcOffset())*n,W=this-P,V=function(){return E.m(T,P)};switch(D){case y:v=V()/12;break;case h:v=V();break;case p:v=V()/3;break;case f:v=(W-U)/6048e5;break;case u:v=(W-U)/864e5;break;case c:v=W/r;break;case l:v=W/n;break;case o:v=W/s;break;default:v=W}return x?v:E.a(v)},w.daysInMonth=function(){return this.endOf(h).$D},w.$locale=function(){return _[this.$L]},w.locale=function(S,I){if(!S)return this.$L;var x=this.clone(),v=g(S,I,!0);return v&&(x.$L=v),x},w.clone=function(){return E.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()},O})(),ie=ce.prototype;return C.prototype=ie,[["$ms",i],["$s",o],["$m",l],["$H",c],["$W",u],["$M",h],["$y",y],["$D",k]].forEach((function(O){ie[O[1]]=function(w){return this.$g(w,O[0],O[1])}})),C.extend=function(O,w){return O.$i||(O(w,ce,C),O.$i=!0),C},C.locale=g,C.isDayjs=re,C.unix=function(O){return C(1e3*O)},C.en=_[X],C.Ls=_,C.p={},C}))})(zt)),zt.exports}var xi=Si();const wi=pi(xi);function Pn(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 Wn(t){if(!t||typeof t!="string")return{hours:0,minutes:0,seconds:0};const e=t.split(":").map(i=>parseInt(i,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 en(t){const{hours:e,minutes:s,seconds:n}=Wn(t);return wi().hour(e).minute(s).second(n).millisecond(0)}function De(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function vi(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function tn(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function je(t,e){const s={...e.headers,...vi()},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 i={};if(r)try{i=JSON.parse(r)}catch{i={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=i?.Message||`HTTP ${n.status}`;throw new Error(o)}return i}const ue=(...t)=>t.find(e=>e!=null);function Nt(t,e,s={}){const n={};for(const r of e){const i=s[r]??r.charAt(0).toUpperCase()+r.slice(1);n[r]=t?.[i]??t?.[r]}return n}function Ti(t){return Array.isArray(t)?t.map(e=>Nt(e,["alertLogId","alertId","status","description","actionNotes","createdDate","createdBy","modifiedDate","modifiedBy"])):t}function Ni(t){return{id:String(ue(t?.AlertId,t?.alertId)??""),alertNumber:ue(t?.AlertNumber,t?.alertNumber),priority:ue(t?.Priority,t?.priority,"Low"),timestamp:ue(t?.UpdatedUtc,t?.timestamp,""),statusType:ue(t?.Status,t?.statusType,""),description:ue(t?.Description,t?.description,""),eventName:ue(t?.EventName,t?.eventName),ruleName:ue(t?.RuleName,t?.ruleName),spaceName:ue(t?.SpaceName,t?.spaceName),assignTeam:ue(t?.AssignTeam,t?.assignTeam),cameraName:ue(t?.CameraName,t?.cameraName),type:ue(t?.Type,t?.type),mediaDetails:ue(t?.MediaDetails,t?.mediaDetails),additionalMedia:ue(t?.AdditionalMedia,t?.additionalMedia),timeElapsed:ue(t?.TimeElapsed,t?.timeElapsed),timeRemaining:ue(t?.TimeRemaining,t?.timeRemaining),anomalyName:ue(t?.AnomalyName,t?.anomalyName),alertDetails:ue(t?.AlertDetails,t?.alertDetails),statusHistory:Ti(ue(t?.StatusHistory,t?.statusHistory)),isEmailSent:ue(t?.IsEmailSent,t?.isEmailSent),isSMSSent:ue(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:ue(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function Ai(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=De(t.baseUrl,"/api/detectionpolicy/alerts?customerId=99e5c8b5-b9d4-4d35-8885-7f121c532664"),n=await je(s,{method:"GET",headers:e});return Array.isArray(n?.Items)?(n?.Items).map(Ni):[]},async getAlertStatusList(){const s=De(t.baseUrl,"/api/detectionpolicy/alerts/StatusList"),n=await je(s,{method:"GET",headers:e});return(Array.isArray(n)?n:[]).map(i=>Nt(i,["alertStatusId","value","statusName"]))},async getAlertsReport(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),r=tn(n,s),i=await je(r,{method:"GET",headers:e});return Array.isArray(i)?i:[]},async updateAlertStatus(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/Log"),r={AlertId:s.alertId??s.alertUniqueId??s.AlertId,Status:s.status??s.Status??"",Notes:s.notes??s.Notes??""};return je(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getAdminSettings(){const s=De(t.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),n=await je(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n.Data??n;if(r&&typeof r=="object")return Nt(r,["userId","isAdminSetting","sortBy"],{sortBy:"SortOption"})}return null},async setAdminSettings(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/SetAdminSettings"),r={Settings:{UserId:0,IsAdminSetting:!0,SortOption:s?.sortBy??"",GroupBy:s?.groupBy??null}};return je(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=De(t.baseUrl,"/api/detectionpolicy/alerts/GetPreferenceSettings"),n=await je(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),r=u=>{const{hours:f,minutes:h,seconds:p}=Wn(u);return(f*3600+h*60+p)*1e7},i={Settings:{UserId:0,AnomalyIds:Array.isArray(s?.anomalyIds)?s.anomalyIds.map(u=>String(u)):[],DoNotDisturbStart:{Ticks:r(s?.doNotDisturbStart)},DoNotDisturbEnd:{Ticks:r(s?.doNotDisturbEnd)},InApp:!!s?.inApp,SMS:!!s?.sms,Email:!!s?.email,SortBy:s?.sortBy??""}},o=await je(n,{method:"POST",headers:e,body:JSON.stringify(i)}),l=o?.responseStatus??!0,c=o?.data??o?.message??"Preferences updated successfully.";return{responseStatus:l,errorMessage:l?"":o?.errorMessage??o?.Message??o?.message??"",statusCode:200,data:c}},async getAlertNotifications(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),r=tn(n,{alertId:s}),i=await je(r,{method:"GET",headers:e});let o=[];return Array.isArray(i)?o=i:Array.isArray(i?.data)&&(o=i.data),o.map(l=>Nt(l,["alertNotificationSentId","alertId","notificationType","receipientName","receipentPhoneNumber","messageSID","messageStatus","receipientEmail","notificationReceipientType","sentAt"]))},async getTimeZoneMasters(){const s=De(t.baseUrl,"/api/TimeZoneMaster"),n=await je(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n.Data:[]).map(i=>Nt(i,["timeZoneUniqueId","ianaTimeZoneId","timeZoneName","offset"]))},async getMyAppPreferences(){const s=De(t.baseUrl,"/MyProfile"),n=await je(s,{method:"GET",headers:e}),r=n?.data?.userGuid??n?.Data?.userGuid??n?.userGuid;if(!r)return null;const i=De(t.baseUrl,`/api/GetMyAppPreferences/${r}`),o=await je(i,{method:"GET",headers:e});if(o&&typeof o=="object"){const l=o.data??o.Data??o,c=l?.timeZoneUniqueId??l?.TimeZoneUniqueId;if(c)return{timeZoneUniqueId:c}}return null}}}function ki(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function ze(t,e){const s={...e.headers,...ki()},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 i={};if(r)try{i=JSON.parse(r)}catch{i={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=i?.errorMessage||i?.message||`HTTP ${n.status}`;throw new Error(o)}return i}function bi(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/api/detectionpolicy/rules",t.baseUrl).toString();return{async getRules(){const n=await ze(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n?.Data:[]).map(i=>({...i,ruleId:i.ruleId??i.RuleId,ruleName:i.ruleName??i.RuleName??i.Name}))},async setEscalationSettings(n){return ze(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=g=>new URL(g,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,i=[ze(n("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:e}),ze(n("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:e}),ze(n("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:e}),ze(n("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:e}),ze(n("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:e}),ze(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,l,c,u,f,h]=await Promise.allSettled(i),p=g=>g.status==="fulfilled"&&Array.isArray(g.value)?g.value:[],y=p(o),k=p(l),b=p(c),A=p(u),z=p(f),F=h.status==="fulfilled"?h.value:null;let Z=[];Array.isArray(F)?Z=F:Array.isArray(F?.Data)?Z=F.Data:Array.isArray(F?.data)&&(Z=F.data);const se=y.map(g=>({actionTypeId:Number(g?.ActionTypeId),name:g?.DisplayName??g?.Name??""})),X=k.map(g=>({recordId:g?.AnomalyId,anomalyName:g?.DisplayName??g?.Name??""})),_=b.map(g=>({thirdPartyId:Number(g?.ThirdPartyId),thirdPartyName:g?.ThirdPartyName??g?.Name??""})),ee=Z.map(g=>({userRoleId:g.UserRoleId??g.userRoleId??g.Id??g.id??0,userRoleName:g.UserRoleName??g.userRoleName??g.Name??g.name??""})),re={actionTypes:se,anomalies:X,thirdParties:_};return A.length&&(re.severities=A),z.length&&(re.scheduleTypes=z),ee.length&&(re.userRoles=ee),re},async updateRule(n,r){const i=`${s}/${n}`;return ze(i,{method:"PUT",headers:e,body:JSON.stringify(r??{})})}}}const Vn=m.createContext(null);function Zn({tenant:t="snl",override:e,timeZone:s,userManagementDomain:n,children:r}){const i=m.useMemo(()=>{const l=e?.alertsBaseUrl?.trim()||Qs[t]?.alerts||"";let c=e?.rulesBaseUrl?.trim()||Qs[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]),o=m.useMemo(()=>{const l=i.tenant==="schools"?Ai({baseUrl:i.alertsBaseUrl,headers:i.headers}):fi({baseUrl:i.alertsBaseUrl,headers:i.headers}),c=i.tenant==="schools"?bi({baseUrl:i.rulesBaseUrl,headers:i.headers,userManagementBaseUrl:i.userManagementDomain}):yi({baseUrl:i.alertsBaseUrl,headers:i.headers});return{config:i,alerts:l,rules:c}},[i]);return a.jsx(Vn.Provider,{value:o,children:r})}function Oe(){const t=m.useContext(Vn);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}const Ii={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Ci={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Os=6,Es=7;function sn(t,e,s){const n=t===Os,r=t===Es,i=e.isEmailSent??!1,o=e.isSMSSent??!1,l=n&&i||r&&o,c=n?"Send Email":r?"Send SMS":s,u=n&&i?"Email sent":r&&o?"SMS sent":c,f=n&&i?"Email sent":r&&o?"SMS sent":`Click to ${c}`;return{isDisabled:l,buttonText:u,tooltipTitle:f}}function Mi(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 Oi(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 cs(t,e){return`${t}-${e?"email":"sms"}`}function $t(t){return t===Os||t===Es}function Xt({value:t,onChange:e,options:s,className:n,dropdownWidth:r}){return a.jsx(d.Select,{className:n,options:s,value:t,onChange:e,dropdownMatchSelectWidth:r??260})}const Ei=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function Di({value:t,onChange:e,options:s}){return a.jsx(Xt,{className:"w-[140px]",value:t,onChange:e,options:s||Ei})}const ji=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function Ri({value:t,onChange:e,options:s}){return a.jsx(Xt,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||ji})}function Fi({value:t,onChange:e,options:s}){return a.jsx(Xt,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const Li=[{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 $i({value:t,onChange:e,options:s}){return a.jsx(Xt,{className:"w-[130px]",value:t,onChange:e,options:s||Li})}function Bn({columns:t,data:e,loading:s=!1,pageSize:n=10,rowKey:r="id",toolbar:i,tableProps:o}){return a.jsxs("div",{children:[i,a.jsx(d.Table,{rowKey:r,dataSource:e,columns:t,loading:s,pagination:{pageSize:n,showSizeChanger:!0,showTotal:l=>`Total: ${l}`},bordered:!0,...o})]})}function Ds({data:t,loading:e=!1,pageSize:s=10,columns:n,severityOptions:r,spaceOptions:i,renderActions:o,onAlertIdClick:l,onRefetch:c,excludeCompleted:u=!0}){const[f,h]=m.useState("All"),[p,y]=m.useState("All"),[k,b]=m.useState("All"),[A,z]=m.useState("All"),[F,Z]=m.useState(""),[se,X]=m.useState([{label:"All",value:"All"}]),[_,ee]=m.useState(new Set),{rules:re,alerts:g}=Oe(),C={6:{title:"Email",kind:"icon",icon:a.jsx(rt.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:a.jsx(rt.MessageOutlined,{})}},E=m.useMemo(()=>Mi(t),[t]),ce=m.useMemo(()=>Oi(t),[t]);m.useEffect(()=>{let v=!0;return(async()=>{try{const T=await re.getLookups(),P=(Array.isArray(T.thirdParties)?T.thirdParties:[]).map(U=>({label:U.thirdPartyName,value:String(U.thirdPartyId)}));v&&X([{label:"All",value:"All"},...P])}catch(T){console.error("Error loading third party options",T)}})(),()=>{v=!1}},[re]);const ie=m.useMemo(()=>(t||[]).some(v=>Js(v).length>0),[t]),O=m.useMemo(()=>(t||[]).filter(v=>{const T=f==="All"||v.priority===f,D=`${v.id} ${v.description} ${v.statusType}`.toLowerCase(),P=!F||D.includes(F.toLowerCase()),U=p==="All"||(v.anomalyName||"").toLowerCase()===p.toLowerCase(),W=k==="All"||(v.spaceName||"").toLowerCase()===k.toLowerCase(),V=!ie||A==="All"||Js(v).includes(Number(A)),ae=!u||!["completed","false positive"].includes(String(v.statusType||"").toLowerCase());return T&&P&&U&&W&&V&&ae}),[t,f,F,p,k,A,ie,u]),w=E,S=i&&i.length?i:ce,I=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:v=>a.jsx(d.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Ci[v]}`,backgroundColor:Ii[v]},children:v})},{title:"Tracker",key:"tracker",width:140,render:(v,T)=>a.jsx("a",{onClick:D=>{D.preventDefault(),l?.(T,{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:(v,T)=>{if(o)return a.jsx(a.Fragment,{children:o(T)});const D=async(be,ke)=>{const at=cs(T.id,be);ee(Se=>new Set(Se).add(at));try{const Se=await g.sendSMSorEmailNotifications?.(T.id,be,ke);Se?.responseStatus?(Ae.toast.success(Se.data||(be?"Email sent successfully":"SMS sent successfully")),c?.()):Ae.toast.error(Se?.data||Se?.errorMessage||"Failed to send notification")}catch(Se){Ae.toast.error(Se?.message||"Failed to send notification")}finally{ee(Se=>{const ot=new Set(Se);return ot.delete(at),ot})}},P=Os,U=Es,W=C[P],V=C[U],ae=sn(P,T,W?.title),he=sn(U,T,V?.title),fe=cs(T.id,!0),ge=cs(T.id,!1),oe=$t(P)&&_.has(fe),pe=$t(U)&&_.has(ge);return a.jsxs(d.Space,{size:"middle",children:[a.jsx(d.Tooltip,{title:ae.tooltipTitle,children:a.jsx(d.Button,{size:"small",disabled:ae.isDisabled,loading:oe,onClick:$t(P)?()=>D(!0,!1):void 0,icon:!oe&&W?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:ae.buttonText})},String(P)),a.jsx(d.Tooltip,{title:he.tooltipTitle,children:a.jsx(d.Button,{size:"small",disabled:he.isDisabled,loading:pe,onClick:$t(U)?()=>D(!1,!0):void 0,icon:!pe&&V?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:he.buttonText})},String(U))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(v,T)=>{const D=T?.timeElapsed,P=T?.timeRemaining,U=D?_s(D):0,W=P?_s(P):0,V=Math.round(U/(U+W)*100);return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-[70px]",children:"Elapsed:"}),a.jsx("span",{className:"font-medium",children:D??"-"})]}),a.jsx(d.Progress,{percent:V,showInfo:!1,size:"small",strokeColor:li(T.priority)}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-[70px]",children:"Remaining"}),a.jsx("span",{className:"font-medium",children:P??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(v,T)=>a.jsxs("div",{children:[a.jsx("a",{onClick:D=>{D.preventDefault(),l?.(T,{sourceTab:"active"})},className:"inline-block mb-1 text-blue-600",children:T.alertNumber}),a.jsx("div",{className:"text-black/65",children:v})]})}],x=n&&n.length?n:I;return a.jsx("div",{children:a.jsx(Bn,{rowKey:"id",data:O,columns:x,loading:e,pageSize:s,toolbar:a.jsxs(d.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[a.jsx(d.Col,{flex:"none",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{children:"Severity"}),a.jsx(Di,{value:f,onChange:h,options:r})]})}),a.jsx(d.Col,{flex:"none",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{children:"Anomaly type"}),a.jsx(Ri,{value:p,onChange:y,options:w})]})}),a.jsx(d.Col,{flex:"none",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{children:"Space"}),a.jsx(Fi,{value:k,onChange:b,options:S})]})}),a.jsx(d.Col,{flex:"none",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{children:"Action Taken"}),a.jsx($i,{value:A,onChange:z,options:se})]})}),a.jsx(d.Col,{flex:"auto"}),a.jsx(d.Col,{flex:"none",children:a.jsx(d.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:Z,onChange:v=>Z(v.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}function js(){const{alerts:t}=Oe(),e=Xe.useQueryClient();return Xe.useMutation({mutationFn:s=>t.updateAlertStatus(s),onSuccess:()=>{e.invalidateQueries({queryKey:["alerts","list"]}),e.invalidateQueries({queryKey:["alerts","report"]})}})}class it extends Error{}class Ui extends it{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class Pi extends it{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class Wi extends it{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class mt extends it{}class zn extends it{constructor(e){super(`Invalid unit ${e}`)}}class we extends it{}class _e extends it{constructor(){super("Zone is an abstract class")}}const N="numeric",We="short",Me="long",Gt={year:N,month:N,day:N},Hn={year:N,month:We,day:N},Vi={year:N,month:We,day:N,weekday:We},qn={year:N,month:Me,day:N},Yn={year:N,month:Me,day:N,weekday:Me},Gn={hour:N,minute:N},_n={hour:N,minute:N,second:N},Jn={hour:N,minute:N,second:N,timeZoneName:We},Qn={hour:N,minute:N,second:N,timeZoneName:Me},Kn={hour:N,minute:N,hourCycle:"h23"},Xn={hour:N,minute:N,second:N,hourCycle:"h23"},er={hour:N,minute:N,second:N,hourCycle:"h23",timeZoneName:We},tr={hour:N,minute:N,second:N,hourCycle:"h23",timeZoneName:Me},sr={year:N,month:N,day:N,hour:N,minute:N},nr={year:N,month:N,day:N,hour:N,minute:N,second:N},rr={year:N,month:We,day:N,hour:N,minute:N},ir={year:N,month:We,day:N,hour:N,minute:N,second:N},Zi={year:N,month:We,day:N,weekday:We,hour:N,minute:N},ar={year:N,month:Me,day:N,hour:N,minute:N,timeZoneName:We},or={year:N,month:Me,day:N,hour:N,minute:N,second:N,timeZoneName:We},lr={year:N,month:Me,day:N,weekday:Me,hour:N,minute:N,timeZoneName:Me},cr={year:N,month:Me,day:N,weekday:Me,hour:N,minute:N,second:N,timeZoneName:Me};class Mt{get type(){throw new _e}get name(){throw new _e}get ianaName(){return this.name}get isUniversal(){throw new _e}offsetName(e,s){throw new _e}formatOffset(e,s){throw new _e}offset(e){throw new _e}equals(e){throw new _e}get isValid(){throw new _e}}let us=null;class es extends Mt{static get instance(){return us===null&&(us=new es),us}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return wr(e,s,n)}formatOffset(e,s){return It(this.offset(e),s)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}}const xs=new Map;function Bi(t){let e=xs.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"}),xs.set(t,e)),e}const zi={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function Hi(t,e){const s=t.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(s),[,r,i,o,l,c,u,f]=n;return[o,r,i,l,c,u,f]}function qi(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:i,value:o}=s[r],l=zi[i];i==="era"?n[l]=o:$(l)||(n[l]=parseInt(o,10))}return n}const ds=new Map;class Ye extends Mt{static create(e){let s=ds.get(e);return s===void 0&&ds.set(e,s=new Ye(e)),s}static resetCache(){ds.clear(),xs.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 wr(e,s,n,this.name)}formatOffset(e,s){return It(this.offset(e),s)}offset(e){if(!this.valid)return NaN;const s=new Date(e);if(isNaN(s))return NaN;const n=Bi(this.name);let[r,i,o,l,c,u,f]=n.formatToParts?qi(n,s):Hi(n,s);l==="BC"&&(r=-Math.abs(r)+1);const p=ss({year:r,month:i,day:o,hour:c===24?0:c,minute:u,second:f,millisecond:0});let y=+s;const k=y%1e3;return y-=k>=0?k:1e3+k,(p-y)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let nn={};function Yi(t,e={}){const s=JSON.stringify([t,e]);let n=nn[s];return n||(n=new Intl.ListFormat(t,e),nn[s]=n),n}const ws=new Map;function vs(t,e={}){const s=JSON.stringify([t,e]);let n=ws.get(s);return n===void 0&&(n=new Intl.DateTimeFormat(t,e),ws.set(s,n)),n}const Ts=new Map;function Gi(t,e={}){const s=JSON.stringify([t,e]);let n=Ts.get(s);return n===void 0&&(n=new Intl.NumberFormat(t,e),Ts.set(s,n)),n}const Ns=new Map;function _i(t,e={}){const{base:s,...n}=e,r=JSON.stringify([t,n]);let i=Ns.get(r);return i===void 0&&(i=new Intl.RelativeTimeFormat(t,e),Ns.set(r,i)),i}let At=null;function Ji(){return At||(At=new Intl.DateTimeFormat().resolvedOptions().locale,At)}const As=new Map;function ur(t){let e=As.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),As.set(t,e)),e}const ks=new Map;function Qi(t){let e=ks.get(t);if(!e){const s=new Intl.Locale(t);e="getWeekInfo"in s?s.getWeekInfo():s.weekInfo,"minimalDays"in e||(e={...dr,...e}),ks.set(t,e)}return e}function Ki(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=vs(t).resolvedOptions(),r=t}catch{const c=t.substring(0,s);n=vs(c).resolvedOptions(),r=c}const{numberingSystem:i,calendar:o}=n;return[r,i,o]}}function Xi(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function ea(t){const e=[];for(let s=1;s<=12;s++){const n=L.utc(2009,s,1);e.push(t(n))}return e}function ta(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 Ut(t,e,s,n){const r=t.listingMode();return r==="error"?null:r==="en"?s(e):n(e)}function sa(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||ur(t.locale).numberingSystem==="latn"}class na{constructor(e,s,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;const{padTo:r,floor:i,...o}=n;if(!s||Object.keys(o).length>0){const l={useGrouping:!1,...n};n.padTo>0&&(l.minimumIntegerDigits=n.padTo),this.inf=Gi(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):Us(e,3);return ye(s,this.padTo)}}}class ra{constructor(e,s,n){this.opts=n,this.originalZone=void 0;let r;if(this.opts.timeZone)this.dt=e;else if(e.zone.type==="fixed"){const o=-1*(e.offset/60),l=o>=0?`Etc/GMT+${o}`:`Etc/GMT${o}`;e.offset!==0&&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 i={...this.opts};i.timeZone=i.timeZone||r,this.dtf=vs(s,i)}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 ia{constructor(e,s,n){this.opts={style:"long",...n},!s&&Sr()&&(this.rtf=_i(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):Ia(s,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,s){return this.rtf?this.rtf.formatToParts(e,s):[]}}const dr={firstDay:1,minimalDays:4,weekend:[6,7]};class Q{static fromOpts(e){return Q.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,s,n,r,i=!1){const o=e||me.defaultLocale,l=o||(i?"en-US":Ji()),c=s||me.defaultNumberingSystem,u=n||me.defaultOutputCalendar,f=Is(r)||me.defaultWeekSettings;return new Q(l,c,u,f,o)}static resetCache(){At=null,ws.clear(),Ts.clear(),Ns.clear(),As.clear(),ks.clear()}static fromObject({locale:e,numberingSystem:s,outputCalendar:n,weekSettings:r}={}){return Q.create(e,s,n,r)}constructor(e,s,n,r,i){const[o,l,c]=Ki(e);this.locale=o,this.numberingSystem=s||l||null,this.outputCalendar=n||c||null,this.weekSettings=r,this.intl=Xi(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=i,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=sa(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:Q.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,Is(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 Ut(this,e,Nr,()=>{const n=this.intl==="ja"||this.intl.startsWith("ja-");s&=!n;const r=s?{month:e,day:"numeric"}:{month:e},i=s?"format":"standalone";if(!this.monthsCache[i][e]){const o=n?l=>this.dtFormatter(l,r).format():l=>this.extract(l,r,"month");this.monthsCache[i][e]=ea(o)}return this.monthsCache[i][e]})}weekdays(e,s=!1){return Ut(this,e,br,()=>{const n=s?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},r=s?"format":"standalone";return this.weekdaysCache[r][e]||(this.weekdaysCache[r][e]=ta(i=>this.extract(i,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return Ut(this,void 0,()=>Ir,()=>{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 Ut(this,e,Cr,()=>{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),i=r.formatToParts(),o=i.find(l=>l.type.toLowerCase()===n);return o?o.value:null}numberFormatter(e={}){return new na(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new ra(e,this.intl,s)}relFormatter(e={}){return new ia(this.intl,this.isEnglish(),e)}listFormatter(e={}){return Yi(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||ur(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:xr()?Qi(this.locale):dr}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 ms=null;class Ne extends Mt{static get utcInstance(){return ms===null&&(ms=new Ne(0)),ms}static instance(e){return e===0?Ne.utcInstance:new Ne(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new Ne(ns(s[1],s[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${It(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${It(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,s){return It(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 aa extends Mt{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 Qe(t,e){if($(t)||t===null)return e;if(t instanceof Mt)return t;if(ma(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?es.instance:s==="utc"||s==="gmt"?Ne.utcInstance:Ne.parseSpecifier(s)||Ye.create(t)}else return Ke(t)?Ne.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new aa(t)}const Rs={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},rn={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]},oa=Rs.hanidec.replace(/[\[|\]]/g,"").split("");function la(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(Rs.hanidec)!==-1)e+=oa.indexOf(t[s]);else for(const r in rn){const[i,o]=rn[r];n>=i&&n<=o&&(e+=n-i)}}return parseInt(e,10)}else return e}const bs=new Map;function ca(){bs.clear()}function $e({numberingSystem:t},e=""){const s=t||"latn";let n=bs.get(s);n===void 0&&(n=new Map,bs.set(s,n));let r=n.get(e);return r===void 0&&(r=new RegExp(`${Rs[s]}${e}`),n.set(e,r)),r}let an=()=>Date.now(),on="system",ln=null,cn=null,un=null,dn=60,mn,fn=null;class me{static get now(){return an}static set now(e){an=e}static set defaultZone(e){on=e}static get defaultZone(){return Qe(on,es.instance)}static get defaultLocale(){return ln}static set defaultLocale(e){ln=e}static get defaultNumberingSystem(){return cn}static set defaultNumberingSystem(e){cn=e}static get defaultOutputCalendar(){return un}static set defaultOutputCalendar(e){un=e}static get defaultWeekSettings(){return fn}static set defaultWeekSettings(e){fn=Is(e)}static get twoDigitCutoffYear(){return dn}static set twoDigitCutoffYear(e){dn=e%100}static get throwOnInvalid(){return mn}static set throwOnInvalid(e){mn=e}static resetCaches(){Q.resetCache(),Ye.resetCache(),L.resetCache(),ca()}}class Pe{constructor(e,s){this.reason=e,this.explanation=s}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const mr=[0,31,59,90,120,151,181,212,243,273,304,334],fr=[0,31,60,91,121,152,182,213,244,274,305,335];function Fe(t,e){return new Pe("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function Fs(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 hr(t,e,s){return s+(Ot(t)?fr:mr)[e-1]}function yr(t,e){const s=Ot(t)?fr:mr,n=s.findIndex(i=>i<e),r=e-s[n];return{month:n+1,day:r}}function Ls(t,e){return(t-e+7)%7+1}function _t(t,e=4,s=1){const{year:n,month:r,day:i}=t,o=hr(n,r,i),l=Ls(Fs(n,r,i),s);let c=Math.floor((o-l+14-e)/7),u;return c<1?(u=n-1,c=Ct(u,e,s)):c>Ct(n,e,s)?(u=n+1,c=1):u=n,{weekYear:u,weekNumber:c,weekday:l,...rs(t)}}function hn(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:i}=t,o=Ls(Fs(n,1,e),s),l=ft(n);let c=r*7+i-o-7+e,u;c<1?(u=n-1,c+=ft(u)):c>l?(u=n+1,c-=ft(n)):u=n;const{month:f,day:h}=yr(u,c);return{year:u,month:f,day:h,...rs(t)}}function fs(t){const{year:e,month:s,day:n}=t,r=hr(e,s,n);return{year:e,ordinal:r,...rs(t)}}function yn(t){const{year:e,ordinal:s}=t,{month:n,day:r}=yr(e,s);return{year:e,month:n,day:r,...rs(t)}}function pn(t,e){if(!$(t.localWeekday)||!$(t.localWeekNumber)||!$(t.localWeekYear)){if(!$(t.weekday)||!$(t.weekNumber)||!$(t.weekYear))throw new mt("Cannot mix locale-based week fields with ISO-based week fields");return $(t.localWeekday)||(t.weekday=t.localWeekday),$(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),$(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 ua(t,e=4,s=1){const n=ts(t.weekYear),r=Le(t.weekNumber,1,Ct(t.weekYear,e,s)),i=Le(t.weekday,1,7);return n?r?i?!1:Fe("weekday",t.weekday):Fe("week",t.weekNumber):Fe("weekYear",t.weekYear)}function da(t){const e=ts(t.year),s=Le(t.ordinal,1,ft(t.year));return e?s?!1:Fe("ordinal",t.ordinal):Fe("year",t.year)}function pr(t){const e=ts(t.year),s=Le(t.month,1,12),n=Le(t.day,1,Jt(t.year,t.month));return e?s?n?!1:Fe("day",t.day):Fe("month",t.month):Fe("year",t.year)}function gr(t){const{hour:e,minute:s,second:n,millisecond:r}=t,i=Le(e,0,23)||e===24&&s===0&&n===0&&r===0,o=Le(s,0,59),l=Le(n,0,59),c=Le(r,0,999);return i?o?l?c?!1:Fe("millisecond",r):Fe("second",n):Fe("minute",s):Fe("hour",e)}function $(t){return typeof t>"u"}function Ke(t){return typeof t=="number"}function ts(t){return typeof t=="number"&&t%1===0}function ma(t){return typeof t=="string"}function fa(t){return Object.prototype.toString.call(t)==="[object Date]"}function Sr(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function xr(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function ha(t){return Array.isArray(t)?t:[t]}function gn(t,e,s){if(t.length!==0)return t.reduce((n,r)=>{const i=[e(r),r];return n&&s(n[0],i[0])===n[0]?n:i},null)[1]}function ya(t,e){return e.reduce((s,n)=>(s[n]=t[n],s),{})}function yt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Is(t){if(t==null)return null;if(typeof t!="object")throw new we("Week settings must be an object");if(!Le(t.firstDay,1,7)||!Le(t.minimalDays,1,7)||!Array.isArray(t.weekend)||t.weekend.some(e=>!Le(e,1,7)))throw new we("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function Le(t,e,s){return ts(t)&&t>=e&&t<=s}function pa(t,e){return t-e*Math.floor(t/e)}function ye(t,e=2){const s=t<0;let n;return s?n="-"+(""+-t).padStart(e,"0"):n=(""+t).padStart(e,"0"),n}function Je(t){if(!($(t)||t===null||t===""))return parseInt(t,10)}function tt(t){if(!($(t)||t===null||t===""))return parseFloat(t)}function $s(t){if(!($(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function Us(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 Ot(t){return t%4===0&&(t%100!==0||t%400===0)}function ft(t){return Ot(t)?366:365}function Jt(t,e){const s=pa(e-1,12)+1,n=t+(e-s)/12;return s===2?Ot(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][s-1]}function ss(t){let e=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second,t.millisecond);return t.year<100&&t.year>=0&&(e=new Date(e),e.setUTCFullYear(t.year,t.month-1,t.day)),+e}function Sn(t,e,s){return-Ls(Fs(t,1,e),s)+e-1}function Ct(t,e=4,s=1){const n=Sn(t,e,s),r=Sn(t+1,e,s);return(ft(t)-n+r)/7}function Cs(t){return t>99?t:t>me.twoDigitCutoffYear?1900+t:2e3+t}function wr(t,e,s,n=null){const r=new Date(t),i={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};n&&(i.timeZone=n);const o={timeZoneName:e,...i},l=new Intl.DateTimeFormat(s,o).formatToParts(r).find(c=>c.type.toLowerCase()==="timezonename");return l?l.value:null}function ns(t,e){let s=parseInt(t,10);Number.isNaN(s)&&(s=0);const n=parseInt(e,10)||0,r=s<0||Object.is(s,-0)?-n:n;return s*60+r}function vr(t){const e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new we(`Invalid unit value ${t}`);return e}function Qt(t,e){const s={};for(const n in t)if(yt(t,n)){const r=t[n];if(r==null)continue;s[e(n)]=vr(r)}return s}function It(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}${ye(s,2)}:${ye(n,2)}`;case"narrow":return`${r}${s}${n>0?`:${n}`:""}`;case"techie":return`${r}${ye(s,2)}${ye(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function rs(t){return ya(t,["hour","minute","second","millisecond"])}const ga=["January","February","March","April","May","June","July","August","September","October","November","December"],Tr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Sa=["J","F","M","A","M","J","J","A","S","O","N","D"];function Nr(t){switch(t){case"narrow":return[...Sa];case"short":return[...Tr];case"long":return[...ga];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 Ar=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],kr=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],xa=["M","T","W","T","F","S","S"];function br(t){switch(t){case"narrow":return[...xa];case"short":return[...kr];case"long":return[...Ar];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const Ir=["AM","PM"],wa=["Before Christ","Anno Domini"],va=["BC","AD"],Ta=["B","A"];function Cr(t){switch(t){case"narrow":return[...Ta];case"short":return[...va];case"long":return[...wa];default:return null}}function Na(t){return Ir[t.hour<12?0:1]}function Aa(t,e){return br(e)[t.weekday-1]}function ka(t,e){return Nr(e)[t.month-1]}function ba(t,e){return Cr(e)[t.year<0?0:1]}function Ia(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."]},i=["hours","minutes","seconds"].indexOf(t)===-1;if(s==="auto"&&i){const h=t==="days";switch(e){case 1:return h?"tomorrow":`next ${r[t][0]}`;case-1:return h?"yesterday":`last ${r[t][0]}`;case 0:return h?"today":`this ${r[t][0]}`}}const o=Object.is(e,-0)||e<0,l=Math.abs(e),c=l===1,u=r[t],f=n?c?u[1]:u[2]||u[1]:c?r[t][0]:t;return o?`${l} ${f} ago`:`in ${l} ${f}`}function xn(t,e){let s="";for(const n of t)n.literal?s+=n.val:s+=e(n.val);return s}const Ca={D:Gt,DD:Hn,DDD:qn,DDDD:Yn,t:Gn,tt:_n,ttt:Jn,tttt:Qn,T:Kn,TT:Xn,TTT:er,TTTT:tr,f:sr,ff:rr,fff:ar,ffff:lr,F:nr,FF:ir,FFF:or,FFFF:cr};class ve{static create(e,s={}){return new ve(e,s)}static parseFormat(e){let s=null,n="",r=!1;const i=[];for(let o=0;o<e.length;o++){const l=e.charAt(o);l==="'"?((n.length>0||r)&&i.push({literal:r||/^\s+$/.test(n),val:n===""?"'":n}),s=null,n="",r=!r):r||l===s?n+=l:(n.length>0&&i.push({literal:/^\s+$/.test(n),val:n}),n=l,s=l)}return n.length>0&&i.push({literal:r||/^\s+$/.test(n),val:n}),i}static macroTokenToFormatOpts(e){return Ca[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 ye(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",i=(y,k)=>this.loc.extract(e,y,k),o=y=>e.isOffsetFixed&&e.offset===0&&y.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,y.format):"",l=()=>n?Na(e):i({hour:"numeric",hourCycle:"h12"},"dayperiod"),c=(y,k)=>n?ka(e,y):i(k?{month:y}:{month:y,day:"numeric"},"month"),u=(y,k)=>n?Aa(e,y):i(k?{weekday:y}:{weekday:y,month:"long",day:"numeric"},"weekday"),f=y=>{const k=ve.macroTokenToFormatOpts(y);return k?this.formatWithSystemDefault(e,k):y},h=y=>n?ba(e,y):i({era:y},"era"),p=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 o({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return o({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return o({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return l();case"d":return r?i({day:"numeric"},"day"):this.num(e.day);case"dd":return r?i({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?i({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?i({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?i({month:"numeric"},"month"):this.num(e.month);case"MM":return r?i({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?i({year:"numeric"},"year"):this.num(e.year);case"yy":return r?i({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?i({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?i({year:"numeric"},"year"):this.num(e.year,6);case"G":return h("short");case"GG":return h("long");case"GGGGG":return h("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return f(y)}};return xn(ve.parseFormat(s),p)}formatDurationFromString(e,s){const n=this.opts.signMode==="negativeLargestOnly"?-1:1,r=f=>{switch(f[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},i=(f,h)=>p=>{const y=r(p);if(y){const k=h.isNegativeDuration&&y!==h.largestUnit?n:1;let b;return this.opts.signMode==="negativeLargestOnly"&&y!==h.largestUnit?b="never":this.opts.signMode==="all"?b="always":b="auto",this.num(f.get(y)*k,p.length,b)}else return p},o=ve.parseFormat(s),l=o.reduce((f,{literal:h,val:p})=>h?f:f.concat(p),[]),c=e.shiftTo(...l.map(r).filter(f=>f)),u={isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]};return xn(o,i(c,u))}}const Mr=/[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 gt(...t){return e=>t.reduce(([s,n,r],i)=>{const[o,l,c]=i(e,r);return[{...s,...o},l||n,c]},[{},null,1]).slice(0,2)}function St(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 Or(...t){return(e,s)=>{const n={};let r;for(r=0;r<t.length;r++)n[t[r]]=Je(e[s+r]);return[n,null,s+r]}}const Er=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,Ma=`(?:${Er.source}?(?:\\[(${Mr.source})\\])?)?`,Ps=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Dr=RegExp(`${Ps.source}${Ma}`),Ws=RegExp(`(?:[Tt]${Dr.source})?`),Oa=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,Ea=/(\d{4})-?W(\d\d)(?:-?(\d))?/,Da=/(\d{4})-?(\d{3})/,ja=Or("weekYear","weekNumber","weekDay"),Ra=Or("year","ordinal"),Fa=/(\d{4})-(\d\d)-(\d\d)/,jr=RegExp(`${Ps.source} ?(?:${Er.source}|(${Mr.source}))?`),La=RegExp(`(?: ${jr.source})?`);function ht(t,e,s){const n=t[e];return $(n)?s:Je(n)}function $a(t,e){return[{year:ht(t,e),month:ht(t,e+1,1),day:ht(t,e+2,1)},null,e+3]}function xt(t,e){return[{hours:ht(t,e,0),minutes:ht(t,e+1,0),seconds:ht(t,e+2,0),milliseconds:$s(t[e+3])},null,e+4]}function Et(t,e){const s=!t[e]&&!t[e+1],n=ns(t[e+1],t[e+2]),r=s?null:Ne.instance(n);return[{},r,e+3]}function Dt(t,e){const s=t[e]?Ye.create(t[e]):null;return[{},s,e+1]}const Ua=RegExp(`^T?${Ps.source}$`),Pa=/^-?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 Wa(t){const[e,s,n,r,i,o,l,c,u]=t,f=e[0]==="-",h=c&&c[0]==="-",p=(y,k=!1)=>y!==void 0&&(k||y&&f)?-y:y;return[{years:p(tt(s)),months:p(tt(n)),weeks:p(tt(r)),days:p(tt(i)),hours:p(tt(o)),minutes:p(tt(l)),seconds:p(tt(c),c==="-0"),milliseconds:p($s(u),h)}]}const Va={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Vs(t,e,s,n,r,i,o){const l={year:e.length===2?Cs(Je(e)):Je(e),month:Tr.indexOf(s)+1,day:Je(n),hour:Je(r),minute:Je(i)};return o&&(l.second=Je(o)),t&&(l.weekday=t.length>3?Ar.indexOf(t)+1:kr.indexOf(t)+1),l}const Za=/^(?:(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 Ba(t){const[,e,s,n,r,i,o,l,c,u,f,h]=t,p=Vs(e,r,n,s,i,o,l);let y;return c?y=Va[c]:u?y=0:y=ns(f,h),[p,new Ne(y)]}function za(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const Ha=/^(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$/,qa=/^(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$/,Ya=/^(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 wn(t){const[,e,s,n,r,i,o,l]=t;return[Vs(e,r,n,s,i,o,l),Ne.utcInstance]}function Ga(t){const[,e,s,n,r,i,o,l]=t;return[Vs(e,l,s,n,r,i,o),Ne.utcInstance]}const _a=pt(Oa,Ws),Ja=pt(Ea,Ws),Qa=pt(Da,Ws),Ka=pt(Dr),Rr=gt($a,xt,Et,Dt),Xa=gt(ja,xt,Et,Dt),eo=gt(Ra,xt,Et,Dt),to=gt(xt,Et,Dt);function so(t){return St(t,[_a,Rr],[Ja,Xa],[Qa,eo],[Ka,to])}function no(t){return St(za(t),[Za,Ba])}function ro(t){return St(t,[Ha,wn],[qa,wn],[Ya,Ga])}function io(t){return St(t,[Pa,Wa])}const ao=gt(xt);function oo(t){return St(t,[Ua,ao])}const lo=pt(Fa,La),co=pt(jr),uo=gt(xt,Et,Dt);function mo(t){return St(t,[lo,Rr],[co,uo])}const vn="Invalid Duration",Fr={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}},fo={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},...Fr},Re=146097/400,lt=146097/4800,ho={years:{quarters:4,months:12,weeks:Re/7,days:Re,hours:Re*24,minutes:Re*24*60,seconds:Re*24*60*60,milliseconds:Re*24*60*60*1e3},quarters:{months:3,weeks:Re/28,days:Re/4,hours:Re*24/4,minutes:Re*24*60/4,seconds:Re*24*60*60/4,milliseconds:Re*24*60*60*1e3/4},months:{weeks:lt/7,days:lt,hours:lt*24,minutes:lt*24*60,seconds:lt*24*60*60,milliseconds:lt*24*60*60*1e3},...Fr},nt=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],yo=nt.slice(0).reverse();function He(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 G(n)}function Lr(t,e){let s=e.milliseconds??0;for(const n of yo.slice(1))e[n]&&(s+=e[n]*t[n].milliseconds);return s}function Tn(t,e){const s=Lr(t,e)<0?-1:1;nt.reduceRight((n,r)=>{if($(e[r]))return n;if(n){const i=e[n]*s,o=t[r][n],l=Math.floor(i/o);e[r]+=l*s,e[n]-=l*o*s}return r},null),nt.reduce((n,r)=>{if($(e[r]))return n;if(n){const i=e[n]%1;e[n]-=i,e[r]+=i*t[n][r]}return r},null)}function Nn(t){const e={};for(const[s,n]of Object.entries(t))n!==0&&(e[s]=n);return e}class G{constructor(e){const s=e.conversionAccuracy==="longterm"||!1;let n=s?ho:fo;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||Q.create(),this.conversionAccuracy=s?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=n,this.isLuxonDuration=!0}static fromMillis(e,s){return G.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 G({values:Qt(e,G.normalizeUnit),loc:Q.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(Ke(e))return G.fromMillis(e);if(G.isDuration(e))return e;if(typeof e=="object")return G.fromObject(e);throw new we(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,s){const[n]=io(e);return n?G.fromObject(n,s):G.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,s){const[n]=oo(e);return n?G.fromObject(n,s):G.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 Pe?e:new Pe(e,s);if(me.throwOnInvalid)throw new Wi(n);return new G({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 zn(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):vn}toHuman(e={}){if(!this.isValid)return vn;const s=e.showZeros!==!1,n=nt.map(r=>{const i=this.values[r];return $(i)||i===0&&!s?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:r.slice(0,-1)}).format(i)}).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+=Us(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?Lr(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const s=G.fromDurationLike(e),n={};for(const r of nt)(yt(s.values,r)||yt(this.values,r))&&(n[r]=s.get(r)+this.get(r));return He(this,{values:n},!0)}minus(e){if(!this.isValid)return this;const s=G.fromDurationLike(e);return this.plus(s.negate())}mapUnits(e){if(!this.isValid)return this;const s={};for(const n of Object.keys(this.values))s[n]=vr(e(this.values[n],n));return He(this,{values:s},!0)}get(e){return this[G.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const s={...this.values,...Qt(e,G.normalizeUnit)};return He(this,{values:s})}reconfigure({locale:e,numberingSystem:s,conversionAccuracy:n,matrix:r}={}){const o={loc:this.loc.clone({locale:e,numberingSystem:s}),matrix:r,conversionAccuracy:n};return He(this,o)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return Tn(this.matrix,e),He(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=Nn(this.normalize().shiftToAll().toObject());return He(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(o=>G.normalizeUnit(o));const s={},n={},r=this.toObject();let i;for(const o of nt)if(e.indexOf(o)>=0){i=o;let l=0;for(const u in n)l+=this.matrix[u][o]*n[u],n[u]=0;Ke(r[o])&&(l+=r[o]);const c=Math.trunc(l);s[o]=c,n[o]=(l*1e3-c*1e3)/1e3}else Ke(r[o])&&(n[o]=r[o]);for(const o in n)n[o]!==0&&(s[i]+=o===i?n[o]:n[o]/this.matrix[i][o]);return Tn(this.matrix,s),He(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 He(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=Nn(this.values);return He(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 nt)if(!s(this.values[n],e.values[n]))return!1;return!0}}const ct="Invalid Interval";function po(t,e){return!t||!t.isValid?de.invalid("missing or invalid start"):!e||!e.isValid?de.invalid("missing or invalid end"):e<t?de.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 de{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 Pe?e:new Pe(e,s);if(me.throwOnInvalid)throw new Pi(n);return new de({invalid:n})}static fromDateTimes(e,s){const n=Tt(e),r=Tt(s),i=po(n,r);return i??new de({start:n,end:r})}static after(e,s){const n=G.fromDurationLike(s),r=Tt(e);return de.fromDateTimes(r,r.plus(n))}static before(e,s){const n=G.fromDurationLike(s),r=Tt(e);return de.fromDateTimes(r.minus(n),r)}static fromISO(e,s){const[n,r]=(e||"").split("/",2);if(n&&r){let i,o;try{i=L.fromISO(n,s),o=i.isValid}catch{o=!1}let l,c;try{l=L.fromISO(r,s),c=l.isValid}catch{c=!1}if(o&&c)return de.fromDateTimes(i,l);if(o){const u=G.fromISO(r,s);if(u.isValid)return de.after(i,u)}else if(c){const u=G.fromISO(n,s);if(u.isValid)return de.before(l,u)}}return de.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?de.fromDateTimes(e||this.s,s||this.e):this}splitAt(...e){if(!this.isValid)return[];const s=e.map(Tt).filter(o=>this.contains(o)).sort((o,l)=>o.toMillis()-l.toMillis()),n=[];let{s:r}=this,i=0;for(;r<this.e;){const o=s[i]||this.e,l=+o>+this.e?this.e:o;n.push(de.fromDateTimes(r,l)),r=l,i+=1}return n}splitBy(e){const s=G.fromDurationLike(e);if(!this.isValid||!s.isValid||s.as("milliseconds")===0)return[];let{s:n}=this,r=1,i;const o=[];for(;n<this.e;){const l=this.start.plus(s.mapUnits(c=>c*r));i=+l>+this.e?this.e:l,o.push(de.fromDateTimes(n,i)),n=i,r+=1}return o}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;const s=this.s>e.s?this.s:e.s,n=this.e<e.e?this.e:e.e;return s>=n?null:de.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 de.fromDateTimes(s,n)}static merge(e){const[s,n]=e.sort((r,i)=>r.s-i.s).reduce(([r,i],o)=>i?i.overlaps(o)||i.abutsStart(o)?[r,i.union(o)]:[r.concat([i]),o]:[r,o],[[],null]);return n&&s.push(n),s}static xor(e){let s=null,n=0;const r=[],i=e.map(c=>[{time:c.s,type:"s"},{time:c.e,type:"e"}]),o=Array.prototype.concat(...i),l=o.sort((c,u)=>c.time-u.time);for(const c of l)n+=c.type==="s"?1:-1,n===1?s=c.time:(s&&+s!=+c.time&&r.push(de.fromDateTimes(s,c.time)),s=null);return de.merge(r)}difference(...e){return de.xor([this].concat(e)).map(s=>this.intersection(s)).filter(s=>s&&!s.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:ct}[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=Gt,s={}){return this.isValid?ve.create(this.s.loc.clone(s),e).formatInterval(this):ct}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:ct}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:ct}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:ct}toFormat(e,{separator:s=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${s}${this.e.toFormat(e)}`:ct}toDuration(e,s){return this.isValid?this.e.diff(this.s,e,s):G.invalid(this.invalidReason)}mapEndpoints(e){return de.fromDateTimes(e(this.s),e(this.e))}}class Pt{static hasDST(e=me.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 Qe(e,me.defaultZone)}static getStartOfWeek({locale:e=null,locObj:s=null}={}){return(s||Q.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:s=null}={}){return(s||Q.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:s=null}={}){return(s||Q.create(e)).getWeekendDays().slice()}static months(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i="gregory"}={}){return(r||Q.create(s,n,i)).months(e)}static monthsFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i="gregory"}={}){return(r||Q.create(s,n,i)).months(e,!0)}static weekdays(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||Q.create(s,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||Q.create(s,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return Q.create(e).meridiems()}static eras(e="short",{locale:s=null}={}){return Q.create(s,null,"gregory").eras(e)}static features(){return{relative:Sr(),localeWeek:xr()}}}function An(t,e){const s=r=>r.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),n=s(e)-s(t);return Math.floor(G.fromMillis(n).as("days"))}function go(t,e,s){const n=[["years",(c,u)=>u.year-c.year],["quarters",(c,u)=>u.quarter-c.quarter+(u.year-c.year)*4],["months",(c,u)=>u.month-c.month+(u.year-c.year)*12],["weeks",(c,u)=>{const f=An(c,u);return(f-f%7)/7}],["days",An]],r={},i=t;let o,l;for(const[c,u]of n)s.indexOf(c)>=0&&(o=c,r[c]=u(t,e),l=i.plus(r),l>e?(r[c]--,t=i.plus(r),t>e&&(l=t,r[c]--,t=i.plus(r))):t=l);return[t,r,l,o]}function So(t,e,s,n){let[r,i,o,l]=go(t,e,s);const c=e-r,u=s.filter(h=>["hours","minutes","seconds","milliseconds"].indexOf(h)>=0);u.length===0&&(o<e&&(o=r.plus({[l]:1})),o!==r&&(i[l]=(i[l]||0)+c/(o-r)));const f=G.fromObject(i,n);return u.length>0?G.fromMillis(c,n).shiftTo(...u).plus(f):f}const xo="missing Intl.DateTimeFormat.formatToParts support";function J(t,e=s=>s){return{regex:t,deser:([s])=>e(la(s))}}const wo=" ",$r=`[ ${wo}]`,Ur=new RegExp($r,"g");function vo(t){return t.replace(/\./g,"\\.?").replace(Ur,$r)}function kn(t){return t.replace(/\./g,"").replace(Ur," ").toLowerCase()}function Ue(t,e){return t===null?null:{regex:RegExp(t.map(vo).join("|")),deser:([s])=>t.findIndex(n=>kn(s)===kn(n))+e}}function bn(t,e){return{regex:t,deser:([,s,n])=>ns(s,n),groups:e}}function Wt(t){return{regex:t,deser:([e])=>e}}function To(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function No(t,e){const s=$e(e),n=$e(e,"{2}"),r=$e(e,"{3}"),i=$e(e,"{4}"),o=$e(e,"{6}"),l=$e(e,"{1,2}"),c=$e(e,"{1,3}"),u=$e(e,"{1,6}"),f=$e(e,"{1,9}"),h=$e(e,"{2,4}"),p=$e(e,"{4,6}"),y=A=>({regex:RegExp(To(A.val)),deser:([z])=>z,literal:!0}),b=(A=>{if(t.literal)return y(A);switch(A.val){case"G":return Ue(e.eras("short"),0);case"GG":return Ue(e.eras("long"),0);case"y":return J(u);case"yy":return J(h,Cs);case"yyyy":return J(i);case"yyyyy":return J(p);case"yyyyyy":return J(o);case"M":return J(l);case"MM":return J(n);case"MMM":return Ue(e.months("short",!0),1);case"MMMM":return Ue(e.months("long",!0),1);case"L":return J(l);case"LL":return J(n);case"LLL":return Ue(e.months("short",!1),1);case"LLLL":return Ue(e.months("long",!1),1);case"d":return J(l);case"dd":return J(n);case"o":return J(c);case"ooo":return J(r);case"HH":return J(n);case"H":return J(l);case"hh":return J(n);case"h":return J(l);case"mm":return J(n);case"m":return J(l);case"q":return J(l);case"qq":return J(n);case"s":return J(l);case"ss":return J(n);case"S":return J(c);case"SSS":return J(r);case"u":return Wt(f);case"uu":return Wt(l);case"uuu":return J(s);case"a":return Ue(e.meridiems(),0);case"kkkk":return J(i);case"kk":return J(h,Cs);case"W":return J(l);case"WW":return J(n);case"E":case"c":return J(s);case"EEE":return Ue(e.weekdays("short",!1),1);case"EEEE":return Ue(e.weekdays("long",!1),1);case"ccc":return Ue(e.weekdays("short",!0),1);case"cccc":return Ue(e.weekdays("long",!0),1);case"Z":case"ZZ":return bn(new RegExp(`([+-]${l.source})(?::(${n.source}))?`),2);case"ZZZ":return bn(new RegExp(`([+-]${l.source})(${n.source})?`),2);case"z":return Wt(/[a-z_+-/]{1,256}?/i);case" ":return Wt(/[^\S\n\r]/);default:return y(A)}})(t)||{invalidReason:xo};return b.token=t,b}const Ao={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 ko(t,e,s){const{type:n,value:r}=t;if(n==="literal"){const c=/^\s+$/.test(r);return{literal:!c,val:c?" ":r}}const i=e[n];let o=n;n==="hour"&&(e.hour12!=null?o=e.hour12?"hour12":"hour24":e.hourCycle!=null?e.hourCycle==="h11"||e.hourCycle==="h12"?o="hour12":o="hour24":o=s.hour12?"hour12":"hour24");let l=Ao[o];if(typeof l=="object"&&(l=l[i]),l)return{literal:!1,val:l}}function bo(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function Io(t,e,s){const n=t.match(e);if(n){const r={};let i=1;for(const o in s)if(yt(s,o)){const l=s[o],c=l.groups?l.groups+1:1;!l.literal&&l.token&&(r[l.token.val[0]]=l.deser(n.slice(i,i+c))),i+=c}return[n,r]}else return[n,{}]}function Co(t){const e=i=>{switch(i){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 $(t.z)||(s=Ye.create(t.z)),$(t.Z)||(s||(s=new Ne(t.Z)),n=t.Z),$(t.q)||(t.M=(t.q-1)*3+1),$(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),$(t.u)||(t.S=$s(t.u)),[Object.keys(t).reduce((i,o)=>{const l=e(o);return l&&(i[l]=t[o]),i},{}),s,n]}let hs=null;function Mo(){return hs||(hs=L.fromMillis(1555555555555)),hs}function Oo(t,e){if(t.literal)return t;const s=ve.macroTokenToFormatOpts(t.val),n=Zr(s,e);return n==null||n.includes(void 0)?t:n}function Pr(t,e){return Array.prototype.concat(...t.map(s=>Oo(s,e)))}class Wr{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=Pr(ve.parseFormat(s),e),this.units=this.tokens.map(n=>No(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=bo(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=Io(e,this.regex,this.handlers),[r,i,o]=n?Co(n):[null,null,void 0];if(yt(n,"a")&&yt(n,"H"))throw new mt("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:i,specificOffset:o}}else return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function Vr(t,e,s){return new Wr(t,s).explainFromTokens(e)}function Eo(t,e,s){const{result:n,zone:r,specificOffset:i,invalidReason:o}=Vr(t,e,s);return[n,r,i,o]}function Zr(t,e){if(!t)return null;const n=ve.create(e,t).dtFormatter(Mo()),r=n.formatToParts(),i=n.resolvedOptions();return r.map(o=>ko(o,t,i))}const ys="Invalid DateTime",In=864e13;function kt(t){return new Pe("unsupported zone",`the zone "${t.name}" is not supported`)}function ps(t){return t.weekData===null&&(t.weekData=_t(t.c)),t.weekData}function gs(t){return t.localWeekData===null&&(t.localWeekData=_t(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function st(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 Br(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 i=s.offset(n);return r===i?[n,r]:[t-Math.min(r,i)*60*1e3,Math.max(r,i)]}function Vt(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 Ht(t,e,s){return Br(ss(t),e,s)}function Cn(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,i={...t.c,year:n,month:r,day:Math.min(t.c.day,Jt(n,r))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},o=G.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=ss(i);let[c,u]=Br(l,s,t.zone);return o!==0&&(c+=o,u=t.zone.offset(c)),{ts:c,o:u}}function ut(t,e,s,n,r,i){const{setZone:o,zone:l}=s;if(t&&Object.keys(t).length!==0||e){const c=e||l,u=L.fromObject(t,{...s,zone:c,specificOffset:i});return o?u:u.setZone(l)}else return L.invalid(new Pe("unparsable",`the input "${r}" can't be parsed as ${n}`))}function Zt(t,e,s=!0){return t.isValid?ve.create(Q.create("en-US"),{allowZ:s,forceSimple:!0}).formatDateTimeFromString(t,e):null}function Ss(t,e,s){const n=t.c.year>9999||t.c.year<0;let r="";if(n&&t.c.year>=0&&(r+="+"),r+=ye(t.c.year,n?6:4),s==="year")return r;if(e){if(r+="-",r+=ye(t.c.month),s==="month")return r;r+="-"}else if(r+=ye(t.c.month),s==="month")return r;return r+=ye(t.c.day),r}function Mn(t,e,s,n,r,i,o){let l=!s||t.c.millisecond!==0||t.c.second!==0,c="";switch(o){case"day":case"month":case"year":break;default:if(c+=ye(t.c.hour),o==="hour")break;if(e){if(c+=":",c+=ye(t.c.minute),o==="minute")break;l&&(c+=":",c+=ye(t.c.second))}else{if(c+=ye(t.c.minute),o==="minute")break;l&&(c+=ye(t.c.second))}if(o==="second")break;l&&(!n||t.c.millisecond!==0)&&(c+=".",c+=ye(t.c.millisecond,3))}return r&&(t.isOffsetFixed&&t.offset===0&&!i?c+="Z":t.o<0?(c+="-",c+=ye(Math.trunc(-t.o/60)),c+=":",c+=ye(Math.trunc(-t.o%60))):(c+="+",c+=ye(Math.trunc(t.o/60)),c+=":",c+=ye(Math.trunc(t.o%60)))),i&&(c+="["+t.zone.ianaName+"]"),c}const zr={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},Do={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},jo={ordinal:1,hour:0,minute:0,second:0,millisecond:0},qt=["year","month","day","hour","minute","second","millisecond"],Ro=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],Fo=["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 zn(t);return e}function On(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 Lo(t){if(bt===void 0&&(bt=me.now()),t.type!=="iana")return t.offset(bt);const e=t.name;let s=Ms.get(e);return s===void 0&&(s=t.offset(bt),Ms.set(e,s)),s}function En(t,e){const s=Qe(e.zone,me.defaultZone);if(!s.isValid)return L.invalid(kt(s));const n=Q.fromObject(e);let r,i;if($(t.year))r=me.now();else{for(const c of qt)$(t[c])&&(t[c]=zr[c]);const o=pr(t)||gr(t);if(o)return L.invalid(o);const l=Lo(s);[r,i]=Ht(t,l,s)}return new L({ts:r,zone:s,loc:n,o:i})}function Dn(t,e,s){const n=$(s.round)?!0:s.round,r=$(s.rounding)?"trunc":s.rounding,i=(l,c)=>(l=Us(l,n||s.calendary?0:2,s.calendary?"round":r),e.loc.clone(s).relFormatter(s).format(l,c)),o=l=>s.calendary?e.hasSame(t,l)?0:e.startOf(l).diff(t.startOf(l),l).get(l):e.diff(t,l).get(l);if(s.unit)return i(o(s.unit),s.unit);for(const l of s.units){const c=o(l);if(Math.abs(c)>=1)return i(c,l)}return i(t>e?-0:0,s.units[s.units.length-1])}function jn(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 bt;const Ms=new Map;class L{constructor(e){const s=e.zone||me.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Pe("invalid input"):null)||(s.isValid?null:kt(s));this.ts=$(e.ts)?me.now():e.ts;let r=null,i=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(s))[r,i]=[e.old.c,e.old.o];else{const l=Ke(e.o)&&!e.old?e.o:s.offset(this.ts);r=Vt(this.ts,l),n=Number.isNaN(r.year)?new Pe("invalid input"):null,r=n?null:r,i=n?null:l}this._zone=s,this.loc=e.loc||Q.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=i,this.isLuxonDateTime=!0}static now(){return new L({})}static local(){const[e,s]=jn(arguments),[n,r,i,o,l,c,u]=s;return En({year:n,month:r,day:i,hour:o,minute:l,second:c,millisecond:u},e)}static utc(){const[e,s]=jn(arguments),[n,r,i,o,l,c,u]=s;return e.zone=Ne.utcInstance,En({year:n,month:r,day:i,hour:o,minute:l,second:c,millisecond:u},e)}static fromJSDate(e,s={}){const n=fa(e)?e.valueOf():NaN;if(Number.isNaN(n))return L.invalid("invalid input");const r=Qe(s.zone,me.defaultZone);return r.isValid?new L({ts:n,zone:r,loc:Q.fromObject(s)}):L.invalid(kt(r))}static fromMillis(e,s={}){if(Ke(e))return e<-In||e>In?L.invalid("Timestamp out of range"):new L({ts:e,zone:Qe(s.zone,me.defaultZone),loc:Q.fromObject(s)});throw new we(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,s={}){if(Ke(e))return new L({ts:e*1e3,zone:Qe(s.zone,me.defaultZone),loc:Q.fromObject(s)});throw new we("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=Qe(s.zone,me.defaultZone);if(!n.isValid)return L.invalid(kt(n));const r=Q.fromObject(s),i=Qt(e,On),{minDaysInFirstWeek:o,startOfWeek:l}=pn(i,r),c=me.now(),u=$(s.specificOffset)?n.offset(c):s.specificOffset,f=!$(i.ordinal),h=!$(i.year),p=!$(i.month)||!$(i.day),y=h||p,k=i.weekYear||i.weekNumber;if((y||f)&&k)throw new mt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(p&&f)throw new mt("Can't mix ordinal dates with month/day");const b=k||i.weekday&&!y;let A,z,F=Vt(c,u);b?(A=Ro,z=Do,F=_t(F,o,l)):f?(A=Fo,z=jo,F=fs(F)):(A=qt,z=zr);let Z=!1;for(const C of A){const E=i[C];$(E)?Z?i[C]=z[C]:i[C]=F[C]:Z=!0}const se=b?ua(i,o,l):f?da(i):pr(i),X=se||gr(i);if(X)return L.invalid(X);const _=b?hn(i,o,l):f?yn(i):i,[ee,re]=Ht(_,u,n),g=new L({ts:ee,zone:n,o:re,loc:r});return i.weekday&&y&&e.weekday!==g.weekday?L.invalid("mismatched weekday",`you can't specify both a weekday of ${i.weekday} and a date of ${g.toISO()}`):g.isValid?g:L.invalid(g.invalid)}static fromISO(e,s={}){const[n,r]=so(e);return ut(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=no(e);return ut(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=ro(e);return ut(n,r,s,"HTTP",s)}static fromFormat(e,s,n={}){if($(e)||$(s))throw new we("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:i=null}=n,o=Q.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0}),[l,c,u,f]=Eo(o,e,s);return f?L.invalid(f):ut(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]=mo(e);return ut(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 Pe?e:new Pe(e,s);if(me.throwOnInvalid)throw new Ui(n);return new L({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,s={}){const n=Zr(e,Q.fromObject(s));return n?n.map(r=>r?r.val:null).join(""):null}static expandFormat(e,s={}){return Pr(ve.parseFormat(e),Q.fromObject(s)).map(r=>r.val).join("")}static resetCache(){bt=void 0,Ms.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?ps(this).weekYear:NaN}get weekNumber(){return this.isValid?ps(this).weekNumber:NaN}get weekday(){return this.isValid?ps(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?gs(this).weekday:NaN}get localWeekNumber(){return this.isValid?gs(this).weekNumber:NaN}get localWeekYear(){return this.isValid?gs(this).weekYear:NaN}get ordinal(){return this.isValid?fs(this.c).ordinal:NaN}get monthShort(){return this.isValid?Pt.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Pt.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Pt.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Pt.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const e=864e5,s=6e4,n=ss(this.c),r=this.zone.offset(n-e),i=this.zone.offset(n+e),o=this.zone.offset(n-r*s),l=this.zone.offset(n-i*s);if(o===l)return[this];const c=n-o*s,u=n-l*s,f=Vt(c,o),h=Vt(u,l);return f.hour===h.hour&&f.minute===h.minute&&f.second===h.second&&f.millisecond===h.millisecond?[st(this,{ts:c}),st(this,{ts:u})]:[this]}get isInLeapYear(){return Ot(this.year)}get daysInMonth(){return Jt(this.year,this.month)}get daysInYear(){return this.isValid?ft(this.year):NaN}get weeksInWeekYear(){return this.isValid?Ct(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Ct(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(Ne.instance(e),s)}toLocal(){return this.setZone(me.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=Qe(e,me.defaultZone),e.equals(this.zone))return this;if(e.isValid){let r=this.ts;if(s||n){const i=e.offset(this.ts),o=this.toObject();[r]=Ht(o,i,e)}return st(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 st(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const s=Qt(e,On),{minDaysInFirstWeek:n,startOfWeek:r}=pn(s,this.loc),i=!$(s.weekYear)||!$(s.weekNumber)||!$(s.weekday),o=!$(s.ordinal),l=!$(s.year),c=!$(s.month)||!$(s.day),u=l||c,f=s.weekYear||s.weekNumber;if((u||o)&&f)throw new mt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(c&&o)throw new mt("Can't mix ordinal dates with month/day");let h;i?h=hn({..._t(this.c,n,r),...s},n,r):$(s.ordinal)?(h={...this.toObject(),...s},$(s.day)&&(h.day=Math.min(Jt(h.year,h.month),h.day))):h=yn({...fs(this.c),...s});const[p,y]=Ht(h,this.o,this.zone);return st(this,{ts:p,o:y})}plus(e){if(!this.isValid)return this;const s=G.fromDurationLike(e);return st(this,Cn(this,s))}minus(e){if(!this.isValid)return this;const s=G.fromDurationLike(e).negate();return st(this,Cn(this,s))}startOf(e,{useLocaleWeeks:s=!1}={}){if(!this.isValid)return this;const n={},r=G.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 i=this.loc.getStartOfWeek(),{weekday:o}=this;o<i&&(n.weekNumber=this.weekNumber-1),n.weekday=i}else n.weekday=1;if(r==="quarters"){const i=Math.ceil(this.month/3);n.month=(i-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):ys}toLocaleString(e=Gt,s={}){return this.isValid?ve.create(this.loc.clone(s),e).formatDateTime(this):ys}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:i=!1,precision:o="milliseconds"}={}){if(!this.isValid)return null;o=Yt(o);const l=e==="extended";let c=Ss(this,l,o);return qt.indexOf(o)>=3&&(c+="T"),c+=Mn(this,l,s,n,r,i,o),c}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?Ss(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:i=!1,format:o="extended",precision:l="milliseconds"}={}){return this.isValid?(l=Yt(l),(r&&qt.indexOf(l)>=3?"T":"")+Mn(this,o==="extended",s,e,n,i,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?Ss(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():ys}[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 G.invalid("created by diffing an invalid DateTime");const r={locale:this.locale,numberingSystem:this.numberingSystem,...n},i=ha(s).map(G.normalizeUnit),o=e.valueOf()>this.valueOf(),l=o?this:e,c=o?e:this,u=So(l,c,i,r);return o?u.negate():u}diffNow(e="milliseconds",s={}){return this.diff(L.now(),e,s)}until(e){return this.isValid?de.fromDateTimes(this,e):this}hasSame(e,s,n){if(!this.isValid)return!1;const r=e.valueOf(),i=this.setZone(e.zone,{keepLocalTime:!0});return i.startOf(s,n)<=r&&r<=i.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"],i=e.unit;return Array.isArray(e.unit)&&(r=e.unit,i=void 0),Dn(s,this.plus(n),{...e,numeric:"always",units:r,unit:i})}toRelativeCalendar(e={}){return this.isValid?Dn(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 gn(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every(L.isDateTime))throw new we("max requires all arguments be DateTimes");return gn(e,s=>s.valueOf(),Math.max)}static fromFormatExplain(e,s,n={}){const{locale:r=null,numberingSystem:i=null}=n,o=Q.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0});return Vr(o,e,s)}static fromStringExplain(e,s,n={}){return L.fromFormatExplain(e,s,n)}static buildFormatParser(e,s={}){const{locale:n=null,numberingSystem:r=null}=s,i=Q.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new Wr(i,e)}static fromFormatParser(e,s,n={}){if($(e)||$(s))throw new we("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:i=null}=n,o=Q.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0});if(!o.equals(s.locale))throw new we(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${s.locale}`);const{result:l,zone:c,specificOffset:u,invalidReason:f}=s.explainFromTokens(e);return f?L.invalid(f):ut(l,c,n,`format ${s.format}`,e,u)}static get DATE_SHORT(){return Gt}static get DATE_MED(){return Hn}static get DATE_MED_WITH_WEEKDAY(){return Vi}static get DATE_FULL(){return qn}static get DATE_HUGE(){return Yn}static get TIME_SIMPLE(){return Gn}static get TIME_WITH_SECONDS(){return _n}static get TIME_WITH_SHORT_OFFSET(){return Jn}static get TIME_WITH_LONG_OFFSET(){return Qn}static get TIME_24_SIMPLE(){return Kn}static get TIME_24_WITH_SECONDS(){return Xn}static get TIME_24_WITH_SHORT_OFFSET(){return er}static get TIME_24_WITH_LONG_OFFSET(){return tr}static get DATETIME_SHORT(){return sr}static get DATETIME_SHORT_WITH_SECONDS(){return nr}static get DATETIME_MED(){return rr}static get DATETIME_MED_WITH_SECONDS(){return ir}static get DATETIME_MED_WITH_WEEKDAY(){return Zi}static get DATETIME_FULL(){return ar}static get DATETIME_FULL_WITH_SECONDS(){return or}static get DATETIME_HUGE(){return lr}static get DATETIME_HUGE_WITH_SECONDS(){return cr}}function Tt(t){if(L.isDateTime(t))return t;if(t&&t.valueOf&&Ke(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 $o(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function Uo(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 Po(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()),i=e.getFullYear(),o=s(e.getHours()),l=s(e.getMinutes()),c=s(e.getSeconds());return`${n}/${r}/${i} ${o}:${l}:${c}`}catch{return"-"}}function Kt(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"),i=n.startsWith("GMT")||n===r?r:`${n}/${r}`;return`${s.toFormat("MM/dd/yyyy, hh:mm:ss a")} (${i})`}const Wo={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Vo={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function Hr({alerts:t,loading:e=!1,pageSize:s=10,severityOptions:n,anomalyOptions:r,spaceOptions:i,onAlertIdClick:o}){const l=js(),c=["completed","false positive"],u=async p=>{try{const y=await l.mutateAsync({alertUniqueId:p.alertId??p.id,alertId:p.id,status:"Reopen",notes:"Reopened",modifiedBy:0});if(y?.responseStatus||y?.Success===!0){const k=y?.Message||y?.data||"Alert reopened successfully.";Ae.toast.success(k)}else{const k=y?.errorMessage||"Failed to reopen alert";Ae.toast.error(k)}}catch{Ae.toast.error("Failed to reopen alert. Please try again.")}},f=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:p=>a.jsx(d.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Wo[p]}`,backgroundColor:Vo[String(p)]},children:p})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:p=>Po(p)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(p,y)=>a.jsxs("div",{children:[a.jsx("a",{onClick:k=>{k.preventDefault(),o?.(y,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:y.alertNumber}),a.jsx("div",{className:"text-black/65",children:p})]})},{title:"",key:"menu",width:60,align:"right",render:(p,y)=>a.jsx(d.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:k})=>{k==="reopen"&&u(y)}},children:a.jsx(d.Button,{type:"text",icon:a.jsx(rt.MoreOutlined,{})})})}],h=(t||[]).filter(p=>c.includes((p.statusType||"").toLowerCase()));return a.jsx(Ds,{data:h,loading:e,pageSize:s,columns:f,severityOptions:n,anomalyOptions:r,spaceOptions:i,renderActions:void 0,onAlertIdClick:o,excludeCompleted:!1})}function Zo({size:t=120,time:e,timeZone:s="America/New_York"}){const{hours:n,minutes:r,seconds:i}=m.useMemo(()=>{const h=new Intl.DateTimeFormat("en-US",{timeZone:s,hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(e);return{hours:parseInt(h.find(p=>p.type==="hour")?.value||"0",10),minutes:parseInt(h.find(p=>p.type==="minute")?.value||"0",10),seconds:parseInt(h.find(p=>p.type==="second")?.value||"0",10)}},[e,s]),o=i*6,l=r*6+i*.1,c=n%12*30+r*.5,u=t/2;return a.jsxs("div",{className:"relative rounded-full border border-gray-300 bg-white",style:{width:t,height:t},role:"img","aria-label":"Analog Clock",children:[[...Array(12)].map((f,h)=>{const p=h*30,y=6,k=u-4,b=k-y,A=(p-90)*(Math.PI/180),z=u+b*Math.cos(A),F=u+b*Math.sin(A),Z=u+k*Math.cos(A),se=u+k*Math.sin(A);return a.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:a.jsx("line",{x1:z,y1:F,x2:Z,y2:se,stroke:"#9CA3AF",strokeWidth:h%3===0?2:1,strokeLinecap:"round"})},h)}),a.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${c}deg)`},children:a.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.25,stroke:"#1F2937",strokeWidth:4,strokeLinecap:"round"})}),a.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${l}deg)`},children:a.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.35,stroke:"#374151",strokeWidth:3,strokeLinecap:"round"})}),a.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${o}deg)`},children:a.jsx("line",{x1:u,y1:u+t*.08,x2:u,y2:u-t*.38,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"})}),a.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,i]=m.useState(new Date);m.useEffect(()=>{const u=setInterval(()=>i(new Date),s);return()=>clearInterval(u)},[s]);const o=m.useMemo(()=>$o(r,e),[r,e]),{abbr:l,offset:c}=m.useMemo(()=>Uo(r,e),[r,e]);return a.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[a.jsx(Zo,{time:r,timeZone:e,size:80}),a.jsxs("div",{className:"flex flex-col items-baseline gap-1",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[a.jsx("span",{className:"uppercase",children:t}),l&&a.jsxs("span",{className:"p-2 rounded-md border text-[10px] leading-none text-gray-600 bg-gray-50",children:[l," ",c]})]}),a.jsx("div",{className:"text-2xl font-semibold text-gray-700 tracking-wide",children:o})]})]})}const Bo=[{SeverityId:1,Code:"LOW",DisplayName:"Low",SortOrder:10,IsActive:!0},{SeverityId:2,Code:"MEDIUM",DisplayName:"Medium",SortOrder:20,IsActive:!0},{SeverityId:3,Code:"HIGH",DisplayName:"High",SortOrder:30,IsActive:!0},{SeverityId:4,Code:"CRITICAL",DisplayName:"Critical",SortOrder:40,IsActive:!0}],zo=[{RuleId:"0938aa00-dfa7-4258-805a-67396366c776",RuleVersionId:"36d2d581-57c3-45c3-8705-8235935fdf96",Name:"License Plate Recognition",Description:"License Plate Recognition",VersionCount:1,ActionCount:0,ApplicabilityPeriodCount:0,SuppressionCount:0,AssignmentCount:0,ExclusionCount:0,IsDeleted:!1,SeverityId:3,AnomalyId:"915976ef-4eb6-4f7b-bbe6-e53862517fc9",Level:"global"},{RuleId:"2437286a-db6a-4d35-814e-9ac49f158dde",RuleVersionId:"00000000-0000-0000-0000-000000000000",Name:"Monitor And Track Onsite Vehicle timelog",Description:"Monitor And Track Onsite Vehicle timelog",VersionCount:0,ActionCount:0,ApplicabilityPeriodCount:0,SuppressionCount:0,AssignmentCount:0,ExclusionCount:0,IsDeleted:!1,SeverityId:3,AnomalyId:"9fd651ab-4312-4826-84b6-94d735894477",Level:"global"},{RuleId:"b99120ba-7a83-4ade-b5d9-a420550fe351",RuleVersionId:"d7b14dae-a7b1-474e-a357-199182c02ac3",Name:"Watchlist person detected",Description:"Watchlist person detected",VersionCount:1,ActionCount:0,ApplicabilityPeriodCount:0,SuppressionCount:0,AssignmentCount:0,ExclusionCount:0,IsDeleted:!1,SeverityId:4,AnomalyId:"bb3a3d3a-73a3-4f5a-8804-1baadbd0d412",Level:"global"},{RuleId:"ffc2c24f-adb7-4aba-ace7-f19c54e21530",RuleVersionId:"6ab3178f-bf77-4a1e-898d-1d5dbef749c5",Name:"Weapon Detection",Description:"Weapon Detection",VersionCount:1,ActionCount:0,ApplicabilityPeriodCount:0,SuppressionCount:0,AssignmentCount:0,ExclusionCount:0,IsDeleted:!1,SeverityId:4,AnomalyId:"ac82c3a2-72e6-4f9c-88fb-851a3ca3c4de",Level:"global"}],Ho=[{userRoleId:1,userRoleName:"Super Admin"},{userRoleId:2,userRoleName:"Security Officer"},{userRoleId:3,userRoleName:"Security Admin"},{userRoleId:4,userRoleName:"Regulatory Officer/First Responder"},{userRoleId:5,userRoleName:"User"}],dt={severities:Bo,rules:zo,userRoles:Ho},{Text:qo}=d.Typography;function Yo({sortBy:t,onChange:e,showActions:s,onSave:n,onClear:r,saving:i}){return a.jsxs(d.Row,{gutter:[16,16],align:"middle",children:[a.jsx(d.Col,{xs:24,md:8,lg:5,children:a.jsxs(d.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[a.jsx(qo,{className:"text-gray-600 whitespace-nowrap",children:"Sort By:"}),a.jsx(d.Select,{placeholder:"By Severity",value:t,onChange:o=>e({sortBy:o}),options:[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],className:"w-full",style:{minWidth:"200px"}})]})}),a.jsx(d.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?a.jsxs(d.Space,{className:"w-full",direction:"horizontal",size:8,children:[a.jsx(d.Button,{onClick:r,disabled:i,children:"Clear"}),a.jsx(d.Button,{type:"primary",onClick:n,loading:i,children:"Save"})]}):null})]})}const{Text:qe}=d.Typography;function Go(t){const{selectedRule:e,setSelectedRule:s,ruleOptions:n,minsOptions:r,roleOptions:i,l1mins:o,setL1mins:l,l1role:c,setL1role:u,l2mins:f,setL2mins:h,l2role:p,setL2role:y,l3mins:k,setL3mins:b,l3role:A,setL3role:z,actions:F,setActions:Z,thirdPartyIds:se,setThirdPartyIds:X,humanLoop:_,setHumanLoop:ee,isAutoExpire:re,setAutoExpire:g,onClear:C,onSave:E,saving:ce,onActionTypesLoaded:ie}=t,{rules:O}=Oe(),[w,S]=m.useState([]),[I,x]=m.useState([]),[v,T]=m.useState(!1);m.useEffect(()=>{let W=!1;return(async()=>{try{T(!0);const V=await O.getLookups();if(W||!V||!Array.isArray(V.actionTypes))return;const ae=V.actionTypes.map(fe=>({label:fe.name,value:String(fe.actionTypeId)}));S(ae),ie&&ie(V.actionTypes);const he=Array.isArray(V.thirdParties)?V.thirdParties.map(fe=>({label:fe.thirdPartyName,value:fe.thirdPartyId})):[];x(he)}catch(V){console.error("Error loading lookups",V)}finally{W||T(!1)}})(),()=>{W=!0}},[]);const D=W=>a.jsxs(d.Tag,{children:[a.jsx(rt.PlusOutlined,{})," ",W.length," more"]}),P=typeof o=="number"||typeof c=="number"||typeof f=="number"||typeof p=="number"||typeof k=="number"||typeof A=="number"||Array.isArray(F)&&F.length>0||Array.isArray(se)&&se.length>0||!!_||!!re,U=!!e&&P&&!ce;return a.jsxs(d.Spin,{spinning:!!ce||v,children:[a.jsxs(d.Row,{gutter:[16,16],align:"bottom",children:[a.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:a.jsxs("div",{children:[a.jsx(qe,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),a.jsx(d.Select,{placeholder:"Rules",value:e,onChange:s,options:n,className:"w-full"})]})}),a.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:a.jsxs("div",{children:[a.jsxs(d.Row,{gutter:8,children:[a.jsx(d.Col,{span:10,children:a.jsx(qe,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),a.jsx(d.Col,{span:14,children:a.jsx(qe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),a.jsxs(d.Row,{gutter:8,children:[a.jsx(d.Col,{span:10,children:a.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:o,onChange:l,options:r})}),a.jsx(d.Col,{span:14,children:a.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:c,onChange:u,options:i})})]})]})}),a.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:a.jsxs("div",{children:[a.jsxs(d.Row,{gutter:8,children:[a.jsx(d.Col,{span:10,children:a.jsx(qe,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),a.jsx(d.Col,{span:14,children:a.jsx(qe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),a.jsxs(d.Row,{gutter:8,children:[a.jsx(d.Col,{span:10,children:a.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:f,onChange:h,options:r})}),a.jsx(d.Col,{span:14,children:a.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:p,onChange:y,options:i})})]})]})}),a.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:a.jsxs("div",{children:[a.jsxs(d.Row,{gutter:8,children:[a.jsx(d.Col,{span:10,children:a.jsx(qe,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),a.jsx(d.Col,{span:14,children:a.jsx(qe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),a.jsxs(d.Row,{gutter:8,children:[a.jsx(d.Col,{span:10,children:a.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:k,onChange:b,options:r})}),a.jsx(d.Col,{span:14,children:a.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:A,onChange:z,options:i})})]})]})}),a.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:a.jsxs("div",{children:[a.jsx(qe,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),a.jsx(d.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:F,onChange:Z,options:w,maxTagCount:1,maxTagPlaceholder:D})]})}),a.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:a.jsxs("div",{children:[a.jsx(qe,{className:"text-gray-700 font-medium block mb-1",children:"Third Party App"}),a.jsx(d.Select,{mode:"multiple",placeholder:"Third Party app",className:"w-full",value:se,onChange:X,options:I})]})})]}),a.jsxs(d.Row,{gutter:[16,16],align:"bottom",className:"mt-4 items-center",children:[a.jsx(d.Col,{xs:24,sm:12,md:8,lg:7,children:a.jsxs("div",{className:"flex items-center h-full gap-8",children:[a.jsx(d.Checkbox,{checked:_,onChange:W=>ee(W.target.checked),className:"w-full",children:"Human-In-The-Loop"}),a.jsx(d.Checkbox,{checked:re,onChange:W=>g(W.target.checked),className:"w-full",children:"Auto-expire in 5 minutes"})]})}),a.jsx(d.Col,{xs:24,sm:12,md:8,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(d.Button,{onClick:C,children:"Clear"}),a.jsx(d.Button,{type:"primary",onClick:E,loading:!!ce,disabled:!U,children:"Save"})]})})]})]})}function _o({entries:t,userRoles:e,onEdit:s,loading:n}){const r=new Map(e.map(o=>[o.userRoleId,o.userRoleName])),i=o=>o.map(l=>r.get(l)||String(l)).join(", ");return a.jsx(d.Table,{rowKey:"id",dataSource:t,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(o,l)=>`${l[0]}-${l[1]} of ${o} items`},loading:n,columns:[{title:"Rule",dataIndex:"ruleOrSeverityLabel",key:"rule"},{title:"Level 1",key:"l1",render:(o,l)=>a.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 (${i(l.l1.roles)})`:""]})},{title:"Level 2",key:"l2",render:(o,l)=>a.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 (${i(l.l2.roles)})`:""]})},{title:"Level 3",key:"l3",render:(o,l)=>a.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 (${i(l.l3.roles)})`:""]})},{title:"Pick Actions",key:"actionsCol",render:(o,l)=>l.actions?.length?l.actions.join(", "):"-"},{title:"Notify",key:"notify",render:(o,l)=>l.notify?.length?l.notify.join(", "):"-"},{title:"Human-In-The-Loop",key:"humanLoop",render:(o,l)=>l.humanLoop?"Yes":"No"},{title:"Auto Expire",key:"isAutoExpire",render:(o,l)=>l.isAutoExpire?"Yes":"No"},{title:"Actions",key:"ops",render:(o,l)=>a.jsx(d.Button,{type:"text",onClick:()=>s(l.id),children:a.jsx(rt.EditOutlined,{})})}]})}const{Title:Jo}=d.Typography;function Yr({userRoles:t,rules:e,rawRules:s}){const{rules:n}=Oe(),[r,i]=m.useState(!1),[o,l]=m.useState(s),[c,u]=m.useState({}),f=m.useMemo(()=>t.map(b=>({label:b.userRoleName,value:b.userRoleId})),[t]),h=m.useMemo(()=>(e||[]).map((b,A)=>({key:b.RuleId||b.Name||String(A),ruleName:b.Name||"-",ruleDesc:b.Description||""})),[e]);m.useEffect(()=>{let b=!1;return(async()=>{try{i(!0);const A=await n.getRules();b||(l(Array.isArray(A)?A:[]),u({}))}catch{!b&&Array.isArray(s)&&l(s)}finally{b||i(!1)}})(),()=>{b=!0}},[]),m.useEffect(()=>{!o&&Array.isArray(s)&&l(s)},[s]);const p=m.useMemo(()=>{if(!Array.isArray(o)||!o.length)return{};const b={};for(const A of h){const z=o.find(Z=>Z?.ruleId===A.key||Z?.ruleName===A.key||Z?.RuleId===A.key||Z?.ruleName===A.ruleName||Z?.Name===A.ruleName),F=Array.isArray(z?.userRoleIds)?z.userRoleIds:[];F.length&&(b[A.key]=F)}return b},[o,h]),y=()=>{u({})},k=async()=>{try{if(!o||!Array.isArray(o)||Object.keys(c).length===0){Ae.toast.info("No changes to save");return}i(!0);const b=Object.entries(c).map(async([A,z])=>{const F=o.find(ee=>ee?.ruleId===A||ee?.ruleName===A||ee?.RuleId===A),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 ${A}`);const se=Array.isArray(z)?z:[],X=se.map(ee=>{const re=t.find(g=>g.userRoleId===ee);return{id:ee,name:re?.userRoleName??String(ee)}}),_={...F,ruleId:A,userRoleIds:se,userRoles:X};return n.updateRule(Z,_)});await Promise.all(b),Ae.toast.success("Alert assignment saved");try{const A=await n.getRules();l(Array.isArray(A)?A:[]),u({})}catch(A){console.error("Failed to refresh rules after save",A)}}catch(b){console.error("Failed to save alert assignment",b)}finally{i(!1)}};return a.jsxs("div",{className:"w-full",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsx(Jo,{level:4,className:"!mb-4",children:"Alert Assignment"})}),a.jsx(d.Table,{rowKey:"key",dataSource:h,loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(b,A)=>`${A[0]}-${A[1]} of ${b} items`},columns:[{title:"Rule Name",dataIndex:"ruleName",key:"ruleName"},{title:"Description",dataIndex:"ruleDesc",key:"ruleDesc"},{title:"Alert Notification To",key:"assign",render:(b,A)=>a.jsx(d.Select,{mode:"multiple",placeholder:"Dropdown with Multi select",className:"w-full",value:c[A.key]??p[A.key]??[],onChange:z=>u(F=>({...F,[A.key]:z})),options:f})}]}),a.jsxs(d.Space,{className:"mt-4",children:[a.jsx(d.Button,{onClick:y,disabled:r,children:"Clear"}),a.jsx(d.Button,{type:"primary",onClick:k,loading:r,disabled:r||Object.keys(c).length===0,children:"Save"})]})]})}const{Title:Rn}=d.Typography;function Gr({severities:t,rules:e,userRoles:s,rawRules:n,onSave:r}){const{rules:i,alerts:o}=Oe(),[l,c]=m.useState("By Severity"),[u,f]=m.useState("By severity"),[h,p]=m.useState("By Severity"),[y,k]=m.useState(!1),[b,A]=m.useState(!1),[z,F]=m.useState(!1),[Z,se]=m.useState(null),[X,_]=m.useState("rules"),[ee,re]=m.useState(),[g,C]=m.useState(),[E,ce]=m.useState(),[ie,O]=m.useState(),[w,S]=m.useState(),[I,x]=m.useState(),[v,T]=m.useState(),[D,P]=m.useState(),[U,W]=m.useState([]),[V,ae]=m.useState([]),[he,fe]=m.useState(!1),[ge,oe]=m.useState(!1),[pe,be]=m.useState({}),[ke,at]=m.useState({}),[Se,ot]=m.useState(s||[]),[wt,vt]=m.useState([]),[et,jt]=m.useState(!1),[M,H]=m.useState(!1),[B,xe]=m.useState(n||[]);m.useEffect(()=>{n&&n.length&&xe(n)},[n]),m.useEffect(()=>{if(!B||!B.length)return;const j=Object.keys(pe).length>0||Object.keys(ke).length>0;if(wt.length&&!j)return;const ne=B.map((q,R)=>{const te=e.find(Te=>Te.RuleId===(q.ruleId||q.ruleName))?.Name||q.ruleName||q.Name||"-",Y=q.escalationSettings||{},le=typeof Y.level1UserRoleId=="number"&&Y.level1UserRoleId>0?[Y.level1UserRoleId]:[],Be=typeof Y.level2UserRoleId=="number"&&Y.level2UserRoleId>0?[Y.level2UserRoleId]:[],as=typeof Y.level3UserRoleId=="number"&&Y.level3UserRoleId>0?[Y.level3UserRoleId]:[],Hs=(Array.isArray(Y.escalationSettingsActionTypeIds)?Y.escalationSettingsActionTypeIds:[]).map(Te=>pe[Te]||String(Te)),Ys=(Array.isArray(Y.thirdPartyId)?Y.thirdPartyId:[]).map(Te=>ke[Te]||String(Te)),os=typeof Y.humanLoop=="boolean"?Y.humanLoop:null,ls=typeof Y.isAutoExpire=="boolean"?Y.isAutoExpire:null;return{id:String(q.ruleId||q.ruleName||R),ruleOrSeverityLabel:te,l1:{minutes:Y.level1PostAssistTime??void 0,roles:le},l2:{minutes:Y.level2PostAssistTime??void 0,roles:Be},l3:{minutes:Y.level3PostAssistTime??void 0,roles:as},actions:Hs,notify:Ys,humanLoop:os,isAutoExpire:ls}});vt(ne)},[B,e,pe,ke]);const Ee=m.useMemo(()=>t.map(j=>({label:j.DisplayName,value:j.SeverityId})),[t]),K=m.useMemo(()=>e.map(j=>({label:j.Name,value:j.RuleId})),[e]),Ve=m.useMemo(()=>Se.map(j=>({label:j.userRoleName,value:j.userRoleId})),[Se]),Ge=m.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(j=>({label:`${j}`,value:j})),[]);m.useEffect(()=>{let j=!1;async function ne(){try{F(!0),se(null);const q=await o.getAdminSettings();if(!j&&q){const R=Pn(q.sortBy);c(R),p(R),k(!1)}}catch(q){if(!j){const R=q instanceof Error?q.message:"Failed to load admin settings";se(R)}}finally{j||F(!1)}}return ne(),()=>{j=!0}},[]),m.useEffect(()=>{if(!g)return;const j=te=>{const Y=Number(te);return!isNaN(Y)&&Y>0?Y:void 0},ne=te=>{const Y=Number(te);return!isNaN(Y)&&Y>0?Y:void 0},R=(B||[]).find(te=>te?.ruleId===g||te?.ruleName===g||te?.RuleId===g)?.escalationSettings;if(R&&typeof R=="object"){ce(ne(R.level1PostAssistTime)),O(j(R.level1UserRoleId)),S(ne(R.level2PostAssistTime)),x(j(R.level2UserRoleId)),T(ne(R.level3PostAssistTime)),P(j(R.level3UserRoleId));const te=Array.isArray(R.escalationSettingsActionTypeIds)?R.escalationSettingsActionTypeIds:[];W(te.map(Y=>String(Y))),ae(Array.isArray(R.thirdPartyId)?R.thirdPartyId:[]),fe(!!R.humanLoop),oe(!!R.isAutoExpire)}},[X,g,B]);const Ze=async()=>{try{H(!0);const j=await i.getRules(),ne=Array.isArray(j)?j:Array.isArray(j?.data)?j.data:[];xe(ne);const q=ne.map((R,te)=>{const Y=e.find(Te=>Te.RuleId===(R.ruleId||R.ruleName))?.Name||R.ruleName||R.Name||"-",le=R.escalationSettings||{},Be=typeof le.level1UserRoleId=="number"&&le.level1UserRoleId>0?[le.level1UserRoleId]:[],as=typeof le.level2UserRoleId=="number"&&le.level2UserRoleId>0?[le.level2UserRoleId]:[],zs=typeof le.level3UserRoleId=="number"&&le.level3UserRoleId>0?[le.level3UserRoleId]:[],qs=(Array.isArray(le.escalationSettingsActionTypeIds)?le.escalationSettingsActionTypeIds:[]).map(Te=>pe[Te]||String(Te)),os=(Array.isArray(le.thirdPartyId)?le.thirdPartyId:[]).map(Te=>ke[Te]||String(Te)),ls=typeof le.humanLoop=="boolean"?le.humanLoop:null;return{id:String(R.ruleId||R.ruleName||te),ruleOrSeverityLabel:Y,l1:{minutes:le.level1PostAssistTime??void 0,roles:Be},l2:{minutes:le.level2PostAssistTime??void 0,roles:as},l3:{minutes:le.level3PostAssistTime??void 0,roles:zs},actions:qs,notify:os,humanLoop:ls}});vt(q)}catch(j){console.error("Failed to refetch entries",j)}finally{H(!1)}};m.useEffect(()=>{let j=!1;return(async()=>{try{const ne=await i.getLookups();if(j||!ne)return;const q={};if(Array.isArray(ne.thirdParties))for(const te of ne.thirdParties)typeof te.thirdPartyId=="number"&&(q[te.thirdPartyId]=te.thirdPartyName);at(q);const R=Array.isArray(ne.userRoles)?ne.userRoles.map(te=>({userRoleId:te.userRoleId??te.id,userRoleName:te.userRoleName??te.name})):[];j||ot(R.length?R:s||[])}catch(ne){console.error("Error loading lookups",ne)}})(),()=>{j=!0}},[]);const ei=async()=>{A(!0);try{const j=await o.setAdminSettings({sortBy:l,groupBy:"string"});j?.responseStatus&&j?.data&&Ae.toast.success(j.data),p(l),k(!1)}catch(j){console.error("Error saving admin settings",j)}finally{A(!1)}},ti=()=>{c(h),k(!1)},si=async()=>{jt(!0),r?.({ruleId:g,levels:[{minutes:E,role:ie},{minutes:w,role:I},{minutes:v,role:D}],actions:U,thirdPartyIds:V,humanLoop:he,isAutoExpire:ge});try{if(g){const q=Array.isArray(U)?U.map(Be=>Number(Be)):[],R=(B||[]).find(Be=>Be?.ruleId===g||Be?.ruleName===g||Be?.RuleId===g),te=typeof R?.recordId=="number"?R.recordId:R?.ruleId||R?.RuleId||void 0;if(!R||!te){Ae.toast.error("Unable to find rule identifier for update");return}const Y={...R,escalationSettings:{level1UserRoleId:ie??0,level1PostAssistTime:E??0,level2UserRoleId:I??0,level2PostAssistTime:w??0,level3UserRoleId:D??0,level3PostAssistTime:v??0,escalationSettingsActionTypeIds:q,thirdPartyId:Array.isArray(V)?V:[],humanLoop:he,isAutoExpire:ge}},le=await i.updateRule(te,Y);if(le?.responseStatus||le?.ok||le){Ae.toast.success("Escalation settings saved"),await Ze(),C(void 0),ce(void 0),O(void 0),S(void 0),x(void 0),T(void 0),P(void 0),W([]),ae([]),fe(!1),oe(!1);return}}}catch(q){console.error("Error saving escalation settings",q)}finally{jt(!1)}const ne=e.find(q=>q.RuleId===g)?.Name||"-";vt(q=>[...q,{id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,ruleOrSeverityLabel:ne,l1:{minutes:E,roles:ie?[ie]:[]},l2:{minutes:w,roles:I?[I]:[]},l3:{minutes:v,roles:D?[D]:[]},actions:(Array.isArray(U)?U:[]).map(R=>{const te=Number(R);return pe[te]||String(R)}),notify:(Array.isArray(V)?V:[]).map(R=>ke[R]||String(R)),humanLoop:!!he,isAutoExpire:!!ge}])},ni=()=>{c("By Severity"),f("By severity"),_("rules"),re(void 0),C(void 0),ce(void 0),O(void 0),S(void 0),x(void 0),T(void 0),P(void 0),W([]),ae([]),fe(!1),oe(!1)};return a.jsxs("div",{className:"w-full",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx(Rn,{level:4,className:"!mb-2",children:"Admin Settings"}),a.jsxs(d.Spin,{spinning:z,children:[Z?a.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",Z]}):null,a.jsx(Yo,{sortBy:l,groupBy:u,onChange:j=>{j.sortBy&&(c(j.sortBy),k(!0)),j.groupBy&&(f(j.groupBy),k(!0))},showActions:y,onSave:ei,onClear:ti,saving:b})]})]}),a.jsx(d.Divider,{className:"my-6"}),a.jsxs("div",{children:[a.jsx(Rn,{level:4,className:"!mb-4",children:"Escalation Settings"}),a.jsx(Go,{escBasis:X,setEscBasis:_,selectedSeverity:ee,setSelectedSeverity:re,selectedRule:g,setSelectedRule:C,severityOptions:Ee,ruleOptions:K,minsOptions:Ge,roleOptions:Ve,l1mins:E,setL1mins:ce,l1role:ie,setL1role:O,l2mins:w,setL2mins:S,l2role:I,setL2role:x,l3mins:v,setL3mins:T,l3role:D,setL3role:P,actions:U,setActions:W,thirdPartyIds:V,setThirdPartyIds:ae,humanLoop:he,setHumanLoop:fe,onClear:ni,onSave:si,saving:et,onActionTypesLoaded:j=>{const ne={};for(const q of j)typeof q.actionTypeId=="number"&&(ne[q.actionTypeId]=q.name);be(ne)},isAutoExpire:ge,setAutoExpire:oe})]}),a.jsx(d.Divider,{className:"my-6"}),a.jsx(_o,{entries:wt,userRoles:Se,loading:M,onEdit:j=>{_("rules");const ne=wt.find(R=>R.id===j),q=e.find(R=>R.RuleId===j)||(ne?e.find(R=>R.Name===ne.ruleOrSeverityLabel):void 0);C(q?q.RuleId:j)}}),a.jsx(d.Divider,{className:"my-6"}),a.jsx(Yr,{userRoles:Se,rules:e,rawRules:n}),a.jsx(d.Divider,{})]})}const{Title:Fn,Text:Bt}=d.Typography;function Qo({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:i}=Oe(),o=[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],[l,c]=m.useState("By Severity"),[u,f]=m.useState(new Set),[h,p]=m.useState(null),[y,k]=m.useState(null),[b,A]=m.useState({inApp:!1,sms:!1,email:!1}),[z,F]=m.useState([]),[Z,se]=m.useState(!0),[X,_]=m.useState(!1);m.useEffect(()=>{let g=!1;return(async()=>{try{const C=await i.getPreferenceSettings();if(g||!C)return;A({inApp:!!C.inApp,sms:!!C.sms,email:!!C.email});const E=Pn(C.sortBy);c(E==="By Created Date"?"By Created Date":"By Severity"),p(en(C.doNotDisturbStart)),k(en(C.doNotDisturbEnd)),Array.isArray(C.anomalyIds)&&f(new Set(C.anomalyIds.map(ce=>String(ce))))}catch(C){console.error("Error in loading my preferences: ",C)}})(),()=>{g=!0}},[]),m.useEffect(()=>{let g=!1;return(async()=>{try{se(!0);const C=await r.getLookups();if(g||!C)return;const E=Array.isArray(C.anomalies)?C.anomalies:[];F(E)}catch(C){console.error("Failed to load anomalies lookups",C)}finally{g||se(!1)}})(),()=>{g=!0}},[]);const ee=g=>{f(C=>{const E=new Set(C);return E.has(g)?E.delete(g):E.add(g),E})},re=async()=>{s?.({sortBy:l,subscribedRuleIds:Array.from(u),dnd:{from:h,to:y},channels:b});try{_(!0);const g=h?h.format?.("HH:mm:ss")??"00:00:00":"00:00:00",C=y?y.format?.("HH:mm:ss")??"00:00:00":"00:00:00",E=Array.from(u).map(ie=>Number(ie)).filter(ie=>Number.isFinite(ie)),ce=await i.setPreferenceSettings({anomalyIds:E,doNotDisturbStart:g,doNotDisturbEnd:C,inApp:!!b.inApp,sms:!!b.sms,email:!!b.email,sortBy:l});ce?.responseStatus&&Ae.toast.success(ce?.data||"Preferences updated successfully.")}catch(g){console.error("Error in saving my preferences: ",g)}finally{_(!1)}};return a.jsxs("div",{className:"w-full",children:[a.jsx(d.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:a.jsx(d.Col,{xs:24,md:8,children:a.jsxs(d.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[a.jsx(Bt,{className:"text-gray-600",children:"Sort By:"}),a.jsx(d.Select,{className:"w-[240px]",value:l,options:o,onChange:c})]})})}),a.jsxs("div",{className:"mb-4",children:[a.jsx(Fn,{level:5,className:"!mb-2",children:"Anomalies"}),Z?a.jsx("div",{className:"py-4",children:a.jsx(d.Spin,{})}):a.jsx(d.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray(z)?z:[]).map(g=>{const C=String(g.recordId),E=g.anomalyName;return a.jsx(d.Checkbox,{checked:u.has(C),onChange:()=>ee(C),children:E},C)})})]}),a.jsxs("div",{className:"mb-4",children:[a.jsx(Fn,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),a.jsx(d.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:a.jsx(d.Col,{xs:24,md:12,children:a.jsxs(d.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[a.jsx(Bt,{children:"Do Not Disturb mode:"}),a.jsxs(d.Space,{size:12,className:"w-full",children:[a.jsxs(d.Space,{direction:"horizontal",size:8,className:"items-center",children:[a.jsx(Bt,{children:"From"}),a.jsx(d.TimePicker,{value:h,onChange:g=>p(g),format:"HH:mm"})]}),a.jsxs(d.Space,{direction:"horizontal",size:8,className:"items-center",children:[a.jsx(Bt,{children:"To"}),a.jsx(d.TimePicker,{value:y,onChange:g=>k(g),format:"HH:mm"})]})]})]})})}),a.jsxs(d.Row,{gutter:[24,12],children:[a.jsx(d.Col,{children:a.jsx(d.Checkbox,{checked:b.inApp,onChange:g=>A({...b,inApp:g.target.checked}),children:"In-app"})}),a.jsx(d.Col,{children:a.jsx(d.Checkbox,{checked:b.sms,onChange:g=>A({...b,sms:g.target.checked}),children:"SMS"})}),a.jsx(d.Col,{children:a.jsx(d.Checkbox,{checked:b.email,onChange:g=>A({...b,email:g.target.checked}),children:"Email"})})]})]}),a.jsx(d.Divider,{}),a.jsxs(d.Space,{className:"gap-3",children:[a.jsx(d.Button,{onClick:n,disabled:X,children:"Cancel"}),a.jsx(d.Button,{type:"primary",onClick:re,loading:X,children:"Save"})]})]})}function _r({severities:t,rules:e,userRoles:s,rawRules:n}){return a.jsx("div",{className:"w-full",children:a.jsx(Gr,{severities:t,rules:e,userRoles:s,rawRules:n})})}const Ko="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=",Xo="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{alerts:t,config:e}=Oe(),{data:s,isLoading:n}=Xe.useQuery({queryKey:["userTimeZone",e.timeZone],queryFn:async()=>{if(e.timeZone)return{timeZoneUniqueId:"",ianaTimeZoneId:e.timeZone,timeZoneName:e.timeZone,offset:""};const[r,i]=await Promise.all([t.getMyAppPreferences?.()??Promise.resolve(null),t.getTimeZoneMasters?.()??Promise.resolve([])]),o=Intl.DateTimeFormat().resolvedOptions().timeZone,l={timeZoneUniqueId:"",ianaTimeZoneId:o,timeZoneName:o,offset:""};if(!r?.timeZoneUniqueId||!i.length)return l;const c=i.find(u=>u.timeZoneUniqueId===r.timeZoneUniqueId);return c?.ianaTimeZoneId?{timeZoneUniqueId:c.timeZoneUniqueId,ianaTimeZoneId:c.ianaTimeZoneId,timeZoneName:c.timeZoneName,offset:c.offset}:l},staleTime:5*6e4});return{timeZoneDetails:s,loading:n}}function el(t){const e=(t.status||"").toLowerCase()==="completed"?a.jsx("img",{src:Ko,alt:"completed",style:{width:20,height:20}}):a.jsx("img",{src:Xo,alt:"pending",style:{width:20,height:20}});return{title:a.jsxs("div",{className:"flex flex-col gap-0 min-w-0",children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"block text-sm break-words mb-1 overflow-visible whitespace-normal",children:a.jsx("b",{children:t.title})}),t.description?a.jsx("span",{className:"text-gray-500 text-xs",children:t.description}):null]}),t.timestamp?a.jsx("span",{className:"text-gray-500 text-xs",children:t.timestamp}):null]}),icon:e,description:null}}function tl({data:t}){const{timeZoneDetails:e}=is();return console.log("summary",t),a.jsx("div",{className:"w-full",children:a.jsx(d.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:a.jsxs("div",{className:"w-full",style:{maxHeight:"50vh",overflowY:"auto"},children:[a.jsx(d.Card,{className:"mb-4 rounded-md p-4",bordered:!0,children:a.jsxs("div",{className:"grid grid-cols-4 gap-6 text-xs",children:[a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx("span",{className:"text-gray-500",children:"Alert ID"}),a.jsx("span",{className:"text-black",children:t.summary.alertNumber})]}),a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx("span",{className:"text-gray-500",children:"Severity"}),a.jsx("span",{className:"text-black",children:t.summary.severity})]}),a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx("span",{className:"text-gray-500",children:"Location"}),a.jsx("span",{className:"text-black",children:t.summary.location})]})]})}),a.jsxs(d.Card,{className:"rounded-md p-4",bordered:!0,children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsx("h4",{className:"text-sm text-black font-medium",children:"Response Timeline/ Audit trail/log"})}),a.jsx("div",{className:"mt-2",children:a.jsx(d.Steps,{direction:"vertical",size:"small",current:1,items:(t.timeline||[]).map(el)})})]})]})},{key:"notification",label:"Notification Sent",children:a.jsxs("div",{className:"grid grid-cols-2 gap-4",style:{maxHeight:"50vh",overflowY:"auto"},children:[(t.notifications||[]).map((s,n)=>a.jsxs(d.Card,{className:"rounded-md p-4",bordered:!0,children:[a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx("h4",{className:"text-sm text-black font-medium",children:s.channelLabel}),a.jsx("span",{className:"text-xs text-gray-500 mt-1",children:Kt(s.sentAt,e?.ianaTimeZoneId)})]}),a.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"]})]}),a.jsxs("div",{className:"mt-4 text-xs",children:[a.jsxs("div",{className:"text-black",children:[" ",s.messageTitle]}),s.messageBody?a.jsx("div",{className:"text-gray-600",children:s.messageBody}):null]}),a.jsxs("div",{className:"mt-4",children:[a.jsxs("div",{className:"text-xs text-black font-medium",children:["Recipients (",s.total,")"]}),a.jsx("div",{className:"mt-2 flex flex-col gap-3 text-xs",children:(s.recipients||[]).map((r,i)=>{const o=String(r?.notificationReceipientType||"").toLowerCase()==="EscalationNotification".toLowerCase();return a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsxs("span",{className:"text-black",children:[r.name," - ",a.jsx("span",{style:{color:o?"#FF3B30":"#FFB86A"},children:o?"Escalation Notification":"Alert Notification"})]}),a.jsxs("span",{className:"text-gray-500",children:[r.role," . ",r.phone]})]}),a.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})]},i)})})]})]},n)),t?.notifications?.length?null:a.jsx("span",{className:"text-gray-500 text-xs",children:"No notifications."})]})}]})})}const sl=({alertId:t,id:e,priority:s,spaceName:n,alertNumber:r,statusHistory:i,notifGroups:o})=>{const l={alertId:t??String(e??""),incidentId:"-",severity:s||"",location:n||"",alertNumber:r??""},{timeZoneDetails:c}=is(),u=i?.length?i.map(h=>{const p=(h?.status||h?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",y=h?.createdDate?Kt(h.createdDate,c?.ianaTimeZoneId):h?.timestamp?Kt(h.timestamp,c?.ianaTimeZoneId):"";return{status:p,title:h?.status||h?.eventStatus||"Status Update",description:h?.description||h?.actionNotes||"",timestamp:y}}):[],f={summary:l,timeline:u,notifications:o??[]};return a.jsx(tl,{data:f})};const nl=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),rl=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),Ln=t=>{const e=rl(t);return e.charAt(0).toUpperCase()+e.slice(1)},Jr=(...t)=>t.filter((e,s,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===s).join(" ").trim(),il=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var al={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 ol=m.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:i,iconNode:o,...l},c)=>m.createElement("svg",{ref:c,...al,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:Jr("lucide",r),...!i&&!il(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,f])=>m.createElement(u,f)),...Array.isArray(i)?i:[i]]));const Zs=(t,e)=>{const s=m.forwardRef(({className:n,...r},i)=>m.createElement(ol,{ref:i,iconNode:e,className:Jr(`lucide-${nl(Ln(t))}`,`lucide-${t}`,n),...r}));return s.displayName=Ln(t),s};const ll=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],cl=Zs("loader-circle",ll);const ul=[["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"}]],Qr=Zs("maximize-2",ul);const dl=[["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"}]],ml=Zs("minimize-2",dl),fl=({isOpen:t,onClose:e,src:s,type:n="image"})=>{const[r,i]=m.useState(!1),[o,l]=m.useState(!1);return m.useEffect(()=>{t&&l(!1)},[t,s]),m.useEffect(()=>{t&&(!s||o)&&e()},[t,s,o,e]),t?a.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:a.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"?a.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)}):a.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)}),a.jsx("button",{onClick:e,className:"absolute top-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:"✕"}),a.jsx("button",{onClick:()=>i(!r),className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:r?a.jsx(ml,{size:20}):a.jsx(Qr,{size:20})})]})}):null};function hl(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 $n(t){const e=(t?.mediaType||t?.type||"").toString().toLowerCase();return e==="video"||e==="mp4"?!0:hl(t?.mediaUrl||t)}function yl(t){const e=t;return e?Array.isArray(e)?e:[e]:[]}const pl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},gl={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Sl=({isModalOpen:t,handleModalClose:e,selectedRow:s,fetchAlertLogs:n,alertStatusList:r=[],alertStatusLoading:i=!1,initialTab:o="details",sourceTab:l})=>{const[c,u]=m.useState(),[f,h]=m.useState(""),[p,y]=m.useState(!1),k=m.useRef(null),[b,A]=m.useState("details"),[z,F]=m.useState(void 0),Z=js(),{alerts:se}=Oe(),{timeZoneDetails:X}=is(),[_,ee]=m.useState(!1),[re,g]=m.useState(void 0),[C,E]=m.useState(void 0),[ce,ie]=m.useState({}),[O,w]=m.useState({}),S=s?.originalData||{},{eventName:I,alertId:x,timestamp:v,description:T,spaceName:D,assignTeam:P,priority:U,statusType:W,id:V,alertDetails:ae,statusHistory:he,mediaDetails:fe,alertNumber:ge}=S,oe=M=>{const H=String(M||"").toLowerCase();return H==="delivered"||H==="sent"?"Delivered":H==="failed"?"Failed":"Queued"},pe=M=>({name:M?.receipientName||M?.recipientName||"-",role:M?.receipientRoleName||"",phone:M?.receipentPhoneNumber||M?.recipientPhoneNumber||M?.receipientEmail||M?.recipientEmail||"",status:oe(M?.messageStatus),notificationReceipientType:M?.notificationReceipientType||""}),be=(M,H)=>{const B=H.map(pe),xe=B.filter(Ge=>Ge.status==="Delivered").length,Ee=H.map(Ge=>Ge?.sentAt).filter(Boolean).sort((Ge,Ze)=>new Date(Ze).getTime()-new Date(Ge).getTime())[0],K=H[0]||{},Ve=[K?.severityName,K?.anomalyName].filter(Boolean).join(" - ")||`${M} Notification`;return{channelLabel:`${M} Notification`,sentAt:Ee||"",messageTitle:Ve,messageBody:"",total:B.length,delivered:xe,recipients:B}},ke=M=>{const H=new Map;return(M||[]).forEach(B=>{const xe=String(B?.notificationType||"Unknown"),Ee=H.get(xe)||[];Ee.push(B),H.set(xe,Ee)}),Array.from(H.entries()).map(([B,xe])=>be(B,xe))},at=async M=>{try{const H=await se.getAlertNotifications(M),B=ke(H);F(B)}catch{F(void 0)}};m.useEffect(()=>{if(b!=="track"||!V)return;let M=!1;return at(V).then(()=>{M&&F(void 0)}),()=>{M=!0}},[b,V]),m.useEffect(()=>{t&&A(o)},[t,o]);const ot=l==="archived"||["completed","false positive"].includes(String(W||"").toLowerCase()),wt=M=>{const H=String(M?.value||"").toLowerCase(),B=String(M?.statusName||"").toLowerCase();return H.includes("reopen")||B.includes("reopen")},vt=(r||[]).filter(M=>{const H=wt(M);return typeof l<"u"?l==="archived"?H:!H:ot?H:!H}).map(M=>({value:M.value,label:M.statusName})),et=m.useMemo(()=>yl(fe),[fe]);m.useEffect(()=>{let M=!1;const H=new AbortController,B=async K=>{if(K){M||ie(Ve=>({...Ve,[K]:!1}));try{const Ve=await fetch(K,{method:"HEAD",signal:H.signal});if(Ve.ok){M||ie(Ze=>({...Ze,[K]:!0}));return}if(Ve.status===404){M||ie(Ze=>({...Ze,[K]:!1}));return}if(!(await fetch(K,{method:"GET",signal:H.signal})).ok)throw new Error("Media not available");M||ie(Ze=>({...Ze,[K]:!0}))}catch{M||ie(Ve=>({...Ve,[K]:!1}))}}};ie({});const xe=et.filter(K=>!$n(K)).map(K=>K?.mediaUrl||K).filter(K=>typeof K=="string"&&K.length>0),Ee={};return xe.forEach(K=>{Ee[K]=!0}),w(Ee),xe.forEach(K=>B(K)),()=>{M=!0,H.abort()}},[et]);const jt=async()=>{try{y(!0);const M={alertUniqueId:x,alertId:V,status:c?String(c):void 0,notes:f.trim(),modifiedBy:0},H=await Z.mutateAsync(M);if(H?.responseStatus){const B=H?.data||"Alert updated successfully.";Ae.toast.success(B,{autoClose:1500,onClose:()=>{n(),e()}}),u(void 0),h("")}else{const B=H?.errorMessage||"Failed to update alert status";Ae.toast.error(B)}}catch(M){console.error("Error updating alert status:",M),Ae.toast.error("Failed to update alert status. Please try again.")}finally{y(!1)}};return a.jsx(d.Modal,{open:t,onCancel:e,width:1e3,footer:b==="details"?a.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[a.jsx(d.Button,{onClick:e,className:"bg-[#6C757D] text-white",children:"Cancel"}),a.jsx(d.Button,{type:"primary",onClick:jt,loading:p,children:p?"Saving...":"Save Changes"})]}):null,children:s&&a.jsx(d.Tabs,{activeKey:b,onChange:M=>A(M),items:[{key:"details",label:"Alert Detail",children:a.jsxs("div",{className:"grid grid-cols-2 gap-2",style:{maxHeight:"50vh",overflowY:"auto"},children:[a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx("div",{className:"text-sm font-bold",children:I||"Alert Event"}),ae?.firstName?a.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",ae?.firstName," ",ae?.lastName||"","   ",ae?.residentId||""]}):null,a.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp: ",Kt(v,X?.ianaTimeZoneId)]}),a.jsxs("div",{className:"font-sm text-gray-500",children:[a.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",T||"No description available"]}),D&&a.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",D]}),P&&a.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",P]}),a.jsxs("div",{className:"flex gap-2 justify-start mt-3",children:[a.jsxs(d.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${pl[String(U)]||"#DFE4EA"}`,backgroundColor:gl[String(U)]},children:["Severity: ",U||"N/A"]}),a.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"]})]}),a.jsx("div",{className:"w-full flex flex-col justify-start items-start mt-2 font-bold",children:a.jsxs("div",{className:"w-full mt-4",children:[a.jsx("div",{className:"flex flex-col gap-2",children:a.jsx(d.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:M=>u(M),value:c,options:vt,loading:i})}),a.jsxs("div",{className:"flex flex-col gap-2 mt-3",children:[a.jsx("label",{htmlFor:"action-details-input",className:"text-xs text-gray-500 font-medium",children:"Action Taken (Comments)"}),a.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:f,onChange:M=>h(M.target.value)})]})]})})]}),a.jsx("div",{className:"flex flex-col gap-4",children:a.jsxs("div",{className:"w-full mt-1",children:[a.jsxs("div",{className:"w-full flex items-center justify-between",children:[a.jsx("h3",{className:"text-black font-bold text-sm",children:"Camera Footage"}),et.length>1?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{type:"button",onClick:()=>k.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:a.jsx(rt.LeftOutlined,{style:{fontSize:12}})}),a.jsx("button",{type:"button",onClick:()=>k.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:a.jsx(rt.RightOutlined,{style:{fontSize:12}})})]}):null]}),et.length?a.jsx("div",{className:"w-full",children:a.jsx(d.Carousel,{ref:k,dots:!0,className:"w-full",children:et.map((M,H)=>{const B=M.mediaUrl||M,xe=$n(M),Ee=!xe&&O[String(B)];return a.jsxs("div",{className:"flex justify-center items-center relative",children:[xe?a.jsxs("video",{width:"240",height:"200",controls:!0,className:"max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg",children:[a.jsx("source",{src:B}),"Your browser does not support the video tag."]}):a.jsxs("div",{className:"relative w-full flex justify-center items-center min-h-[200px]",children:[Ee&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg z-10",children:a.jsx(cl,{size:32,className:"animate-spin text-gray-400"})}),a.jsx("img",{src:B,alt:M.caption||`media-${H}`,className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg transition-opacity duration-200 ${Ee?"opacity-0":"opacity-100"}`,onLoad:()=>w(K=>({...K,[String(B)]:!1})),onError:()=>w(K=>({...K,[String(B)]:!1}))},String(B))]}),M.caption&&a.jsx("p",{className:"text-xs text-gray-500 mt-1",children:M.caption}),!xe&&ce[String(B)]?a.jsx("button",{onClick:()=>{ee(!0),g(B),E(M.type||"image")},className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:a.jsx(Qr,{size:20})}):null]},String(B)||H)})})}):null]})}),a.jsx(fl,{isOpen:_,onClose:()=>ee(!1),src:re||"",type:C||"image"})]})},{key:"track",label:"Track Incident",children:a.jsx(sl,{alertId:x,id:V,priority:U,spaceName:D,alertNumber:ge,statusHistory:he,notifGroups:z})}]})})};function Kr(){const{alerts:t}=Oe(),e=Xe.useQuery({queryKey:["alerts","statusList"],queryFn:()=>t.getAlertStatusList(),staleTime:5*6e4});return{list:e.data??[],loading:e.isLoading,error:e.error,refetch:e.refetch}}function Bs({alerts:t,loading:e=!1,columns:s,onRefetch:n}){const[r,i]=m.useState(!1),[o,l]=m.useState(null),[c,u]=m.useState("details"),{list:f,loading:h}=Kr(),{timeZoneDetails:p,loading:y}=is(),k=p?.timeZoneName??"UTC",b=p?.ianaTimeZoneId??"UTC";function A(X,_){l(X),u(_?.tab??"details"),Z(_?.sourceTab??"active"),i(!0)}function z(){i(!1)}const[F,Z]=m.useState("active"),se=o?{originalData:{...o,alertId:o.alertId??o.id,mediaDetails:o.mediaDetails}}:null;return a.jsxs("div",{className:"p-6 flex flex-col items-start justify-start min-h-screen w-full overflow-auto",children:[a.jsxs("div",{className:"w-full grid grid-cols-3 sm:grid-cols-1 items-center mb-4",children:[a.jsx("h1",{className:"text-xl font-bold text-black",children:"Alert Console"}),a.jsx("div",{className:"flex items-center justify-start sm:justify-center",children:y?a.jsx(d.Spin,{size:"small"}):a.jsx(qr,{label:k,timeZone:b})})]}),a.jsx(d.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:X=>{X==="active"&&n?.()},items:[{key:"active",label:"Active",children:a.jsx(Ds,{data:t,loading:e,pageSize:10,columns:s||[],onAlertIdClick:A,onRefetch:n})},{key:"archived",label:"Archived",children:a.jsx(Hr,{alerts:t,loading:e,columns:s||[],onAlertIdClick:A})},{key:"settings",label:"Settings",children:a.jsx(xl,{})}]}),a.jsx(Sl,{isModalOpen:r,handleModalClose:z,selectedRow:se,fetchAlertLogs:()=>{},alertStatusList:f,alertStatusLoading:h,initialTab:c,sourceTab:F})]})}function xl(){const[t,e]=m.useState([]),[s,n]=m.useState([]),[r,i]=m.useState([]),{rules:o}=Oe();return m.useEffect(()=>{let l=!0;return(async()=>{try{const c=await o.getRules();if(!l)return;i(Array.isArray(c)?c:[]);const u=(c||[]).map((f,h)=>({RuleId:f.ruleId||f.ruleName||String(h),Name:f.ruleName||f.Name||"-",Description:f.ruleDesc||f.Description||"",SeverityId:0}));e(u.length?u:dt.rules);try{const f=await o.getLookups(),h=Array.isArray(f?.userRoles)?f.userRoles.map(p=>({userRoleId:p.userRoleId??p.id,userRoleName:p.userRoleName??p.name})):[];n(h.length?h:dt.userRoles)}catch{n(dt.userRoles)}}catch{e(dt.rules),n(dt.userRoles)}})(),()=>{l=!1}},[]),a.jsx(_r,{severities:dt.severities,rules:t,userRoles:s,rawRules:r})}function Xr(){const{alerts:t}=Oe(),e=Xe.useQuery({queryKey:["alerts","list"],queryFn:()=>t.listAlerts(),staleTime:3e4});return{alerts:e.data??[],loading:e.isLoading,error:e.error,refetch:e.refetch}}function wl(t){const{alerts:e,loading:s,refetch:n}=Xr();return a.jsx(Bs,{alerts:e,loading:s,columns:t.columns,onRefetch:n})}function vl({tenant:t,apiDomain:e,rulesDomain:s,headers:n,timeZone:r,userManagementDomain:i,alerts:o,loading:l,columns:c}){const[u]=m.useState(()=>new Xe.QueryClient),f=m.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return a.jsx(Xe.QueryClientProvider,{client:u,children:a.jsx(Zn,{tenant:t,override:f,timeZone:r,userManagementDomain:i,children:Array.isArray(o)?a.jsx(Bs,{alerts:o,loading:!!l,columns:c}):a.jsx(wl,{columns:c})})})}function Tl(t){const{alerts:e}=Oe(),s=Xe.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 Nl=[{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=Yr;exports.AlertConsole=Bs;exports.AlertConsoleWidget=vl;exports.AlertsTable=Ds;exports.ApiProvider=Zn;exports.ArchivedTable=Hr;exports.Clock=qr;exports.DataTable=Bn;exports.MyPreferencesPanel=Qo;exports.SettingsPanel=Gr;exports.SettingsTabs=_r;exports.exampleAlertColumns=Nl;exports.useAlertStatusList=Kr;exports.useAlerts=Xr;exports.useAlertsReport=Tl;exports.useApi=Oe;exports.useUpdateAlertStatus=js;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),f=require("react"),d=require("antd"),lt=require("@ant-design/icons"),Ae=require("react-toastify"),ct=require("@tanstack/react-query"),la="#FF3B30",ca="#FF9500",ua="#FFCC00",da="#34C759",Ut={critical:la,high:ca,medium:ua,low:da},Ks={Critical:Ut.critical,High:Ut.high,Medium:Ut.medium,Low:Ut.low};function ma(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),o=Number.parseInt(n,10),l=Number.parseFloat(r||"0"),c=Number.isFinite(a)?a:0,u=Number.isFinite(o)?o: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(o=>parseInt(String(o).trim(),10)).filter(o=>Number.isFinite(o)),r=new Set,a=[];return n.forEach(o=>{r.has(o)||(r.add(o),a.push(o))}),a}const Bn="",fa=Bn,ha="",ya="",ga="",pa="",tn={snl:{alerts:Bn,rules:fa},schools:{alerts:ha,rules:ya},transit:{alerts:ga,rules:pa}};function be(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Sa(){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 Ie(t,e){const s={...e.headers,...Sa()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function xa(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=be(t.baseUrl,"/api/Alert"),n=await Ie(s,{method:"GET",headers:e});return Array.isArray(n)?n:[]},async getAlertStatusList(){const s=be(t.baseUrl,"/api/Alert/AlertStatusList"),n=await Ie(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=be(t.baseUrl,"/Alerts/GetAlertsReport"),r=Ft(n,s),a=await Ie(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=be(t.baseUrl,"/api/Alert/status");return Ie(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=be(t.baseUrl,"/api/Alert/GetAdminSettings"),n=await Ie(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=be(t.baseUrl,"/api/Alert/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Ie(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=be(t.baseUrl,"/api/Alert/GetPreferenceSettings"),n=await Ie(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=be(t.baseUrl,"/api/Alert/SetPreferenceSettings"),r=await Ie(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,o=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":r?.errorMessage??r?.message??"",statusCode:200,data:o}},async getAlertNotifications(s){const n=be(t.baseUrl,"/api/Alert/GetNotifications"),r=Ft(n,{alertId:s}),a=await Ie(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=be(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=Ft(n,{alertId:s});return Ie(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const a=be(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),o=Ft(a,{alertId:s,isEmail:n,isSMS:r});return Ie(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=be(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Ie(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=be(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Ie(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 wa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function $t(t,e){const s={...e.headers,...wa()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function va(t){const e={"Content-Type":"application/json",...t.headers||{}},s=sn(t.baseUrl,"/api/Rules"),n=sn(t.baseUrl,"/api/Rules/lookups");return{async getRules(){const r=await $t(s,{method:"GET",headers:e});return Array.isArray(r)?r:[]},async setEscalationSettings(r){return $t(s,{method:"POST",headers:e,body:JSON.stringify(r??{})})},async getLookups(){return $t(n,{method:"GET",headers:e})},async updateRule(r,a){const o=`${s}/${r}`;return $t(o,{method:"PUT",headers:e,body:JSON.stringify(a??{})})}}}function Ta(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Gt={exports:{}},Aa=Gt.exports,nn;function Na(){return nn||(nn=1,(function(t,e){(function(s,n){t.exports=n()})(Aa,(function(){var s=1e3,n=6e4,r=36e5,a="millisecond",o="second",l="minute",c="hour",u="day",h="week",m="month",g="quarter",y="year",N="date",k="Invalid Date",w=/^(\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,$={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(E){var v=["th","st","nd","rd"],S=E%100;return"["+E+(v[(S-20)%10]||v[S]||v[0])+"]"}},Z=function(E,v,S){var b=String(E);return!b||b.length>=v?E:""+Array(v+1-b.length).join(S)+E},Q={s:Z,z:function(E){var v=-E.utcOffset(),S=Math.abs(v),b=Math.floor(S/60),x=S%60;return(v<=0?"+":"-")+Z(b,2,"0")+":"+Z(x,2,"0")},m:function E(v,S){if(v.date()<S.date())return-E(S,v);var b=12*(S.year()-v.year())+(S.month()-v.month()),x=v.clone().add(b,m),j=S-x<0,T=v.clone().add(b+(j?-1:1),m);return+(-(b+(S-x)/(j?x-T:T-x))||0)},a:function(E){return E<0?Math.ceil(E)||0:Math.floor(E)},p:function(E){return{M:m,y,w:h,d:u,D:N,h:c,m:l,s:o,ms:a,Q:g}[E]||String(E||"").toLowerCase().replace(/s$/,"")},u:function(E){return E===void 0}},K="en",q={};q[K]=$;var U="$isDayjsObject",ee=function(E){return E instanceof ue||!(!E||!E[U])},p=function E(v,S,b){var x;if(!v)return K;if(typeof v=="string"){var j=v.toLowerCase();q[j]&&(x=j),S&&(q[j]=S,x=j);var T=v.split("-");if(!x&&T.length>1)return E(T[0])}else{var I=v.name;q[I]=v,x=I}return!b&&x&&(K=x),x||!b&&K},M=function(E,v){if(ee(E))return E.clone();var S=typeof v=="object"?v:{};return S.date=E,S.args=arguments,new ue(S)},C=Q;C.l=p,C.i=ee,C.w=function(E,v){return M(E,{locale:v.$L,utc:v.$u,x:v.$x,$offset:v.$offset})};var ue=(function(){function E(S){this.$L=p(S.locale,null,!0),this.parse(S),this.$x=this.$x||S.x||{},this[U]=!0}var v=E.prototype;return v.parse=function(S){this.$d=(function(b){var x=b.date,j=b.utc;if(x===null)return new Date(NaN);if(C.u(x))return new Date;if(x instanceof Date)return new Date(x);if(typeof x=="string"&&!/Z$/i.test(x)){var T=x.match(w);if(T){var I=T[2]-1||0,V=(T[7]||"0").substring(0,3);return j?new Date(Date.UTC(T[1],I,T[3]||1,T[4]||0,T[5]||0,T[6]||0,V)):new Date(T[1],I,T[3]||1,T[4]||0,T[5]||0,T[6]||0,V)}}return new Date(x)})(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 C},v.isValid=function(){return this.$d.toString()!==k},v.isSame=function(S,b){var x=M(S);return this.startOf(b)<=x&&x<=this.endOf(b)},v.isAfter=function(S,b){return M(S)<this.startOf(b)},v.isBefore=function(S,b){return this.endOf(b)<M(S)},v.$g=function(S,b,x){return C.u(S)?this[b]:this.set(x,S)},v.unix=function(){return Math.floor(this.valueOf()/1e3)},v.valueOf=function(){return this.$d.getTime()},v.startOf=function(S,b){var x=this,j=!!C.u(b)||b,T=C.p(S),I=function(Se,ce){var ye=C.w(x.$u?Date.UTC(x.$y,ce,Se):new Date(x.$y,ce,Se),x);return j?ye:ye.endOf(u)},V=function(Se,ce){return C.w(x.toDate()[Se].apply(x.toDate("s"),(j?[0,0,0,0]:[23,59,59,999]).slice(ce)),x)},D=this.$W,F=this.$M,G=this.$D,ie="set"+(this.$u?"UTC":"");switch(T){case y:return j?I(1,0):I(31,11);case m:return j?I(1,F):I(0,F+1);case h:var re=this.$locale().weekStart||0,pe=(D<re?D+7:D)-re;return I(j?G-pe:G+(6-pe),F);case u:case N:return V(ie+"Hours",0);case c:return V(ie+"Minutes",1);case l:return V(ie+"Seconds",2);case o:return V(ie+"Milliseconds",3);default:return this.clone()}},v.endOf=function(S){return this.startOf(S,!1)},v.$set=function(S,b){var x,j=C.p(S),T="set"+(this.$u?"UTC":""),I=(x={},x[u]=T+"Date",x[N]=T+"Date",x[m]=T+"Month",x[y]=T+"FullYear",x[c]=T+"Hours",x[l]=T+"Minutes",x[o]=T+"Seconds",x[a]=T+"Milliseconds",x)[j],V=j===u?this.$D+(b-this.$W):b;if(j===m||j===y){var D=this.clone().set(N,1);D.$d[I](V),D.init(),this.$d=D.set(N,Math.min(this.$D,D.daysInMonth())).$d}else I&&this.$d[I](V);return this.init(),this},v.set=function(S,b){return this.clone().$set(S,b)},v.get=function(S){return this[C.p(S)]()},v.add=function(S,b){var x,j=this;S=Number(S);var T=C.p(b),I=function(F){var G=M(j);return C.w(G.date(G.date()+Math.round(F*S)),j)};if(T===m)return this.set(m,this.$M+S);if(T===y)return this.set(y,this.$y+S);if(T===u)return I(1);if(T===h)return I(7);var V=(x={},x[l]=n,x[c]=r,x[o]=s,x)[T]||1,D=this.$d.getTime()+S*V;return C.w(D,this)},v.subtract=function(S,b){return this.add(-1*S,b)},v.format=function(S){var b=this,x=this.$locale();if(!this.isValid())return x.invalidDate||k;var j=S||"YYYY-MM-DDTHH:mm:ssZ",T=C.z(this),I=this.$H,V=this.$m,D=this.$M,F=x.weekdays,G=x.months,ie=x.meridiem,re=function(ce,ye,Oe,xe){return ce&&(ce[ye]||ce(b,j))||Oe[ye].slice(0,xe)},pe=function(ce){return C.s(I%12||12,ce,"0")},Se=ie||function(ce,ye,Oe){var xe=ce<12?"AM":"PM";return Oe?xe.toLowerCase():xe};return j.replace(B,(function(ce,ye){return ye||(function(Oe){switch(Oe){case"YY":return String(b.$y).slice(-2);case"YYYY":return C.s(b.$y,4,"0");case"M":return D+1;case"MM":return C.s(D+1,2,"0");case"MMM":return re(x.monthsShort,D,G,3);case"MMMM":return re(G,D);case"D":return b.$D;case"DD":return C.s(b.$D,2,"0");case"d":return String(b.$W);case"dd":return re(x.weekdaysMin,b.$W,F,2);case"ddd":return re(x.weekdaysShort,b.$W,F,3);case"dddd":return F[b.$W];case"H":return String(I);case"HH":return C.s(I,2,"0");case"h":return pe(1);case"hh":return pe(2);case"a":return Se(I,V,!0);case"A":return Se(I,V,!1);case"m":return String(V);case"mm":return C.s(V,2,"0");case"s":return String(b.$s);case"ss":return C.s(b.$s,2,"0");case"SSS":return C.s(b.$ms,3,"0");case"Z":return T}return null})(ce)||T.replace(":","")}))},v.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},v.diff=function(S,b,x){var j,T=this,I=C.p(b),V=M(S),D=(V.utcOffset()-this.utcOffset())*n,F=this-V,G=function(){return C.m(T,V)};switch(I){case y:j=G()/12;break;case m:j=G();break;case g:j=G()/3;break;case h:j=(F-D)/6048e5;break;case u:j=(F-D)/864e5;break;case c:j=F/r;break;case l:j=F/n;break;case o:j=F/s;break;default:j=F}return x?j:C.a(j)},v.daysInMonth=function(){return this.endOf(m).$D},v.$locale=function(){return q[this.$L]},v.locale=function(S,b){if(!S)return this.$L;var x=this.clone(),j=p(S,b,!0);return j&&(x.$L=j),x},v.clone=function(){return C.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()},E})(),le=ue.prototype;return M.prototype=le,[["$ms",a],["$s",o],["$m",l],["$H",c],["$W",u],["$M",m],["$y",y],["$D",N]].forEach((function(E){le[E[1]]=function(v){return this.$g(v,E[0],E[1])}})),M.extend=function(E,v){return E.$i||(E(v,ue,M),E.$i=!0),M},M.locale=p,M.isDayjs=ee,M.unix=function(E){return M(1e3*E)},M.en=q[K],M.Ls=q,M.p={},M}))})(Gt)),Gt.exports}var ka=Na();const ba=Ta(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 ba().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 Ia(){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,...Ia()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.Message||`HTTP ${n.status}`;throw new Error(o)}return a}const de=(...t)=>t.find(e=>e!=null);function kt(t,e,s={}){const n={};for(const r of e){const a=s[r]??r.charAt(0).toUpperCase()+r.slice(1);n[r]=t?.[a]??t?.[r]}return n}function Ma(t){return Array.isArray(t)?t.map(e=>kt(e,["alertLogId","alertId","status","description","actionNotes","createdDate","createdBy","modifiedDate","modifiedBy"])):t}function Ea(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:Ma(de(t?.StatusHistory,t?.statusHistory)),isEmailSent:de(t?.IsEmailSent,t?.isEmailSent),isSMSSent:de(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:de(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function Oa(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(Ea):[]},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=>kt(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 kt(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??""}},o=await De(n,{method:"POST",headers:e,body:JSON.stringify(a)}),l=o?.responseStatus??!0,c=o?.data??o?.message??"Preferences updated successfully.";return{responseStatus:l,errorMessage:l?"":o?.errorMessage??o?.Message??o?.message??"",statusCode:200,data:c}},async 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 o=[];return Array.isArray(a)?o=a:Array.isArray(a?.data)&&(o=a.data),o.map(l=>kt(l,["alertNotificationSentId","alertId","notificationType","receipientName","receipentPhoneNumber","messageSID","messageStatus","receipientEmail","notificationReceipientType","sentAt"]))},async getTimeZoneMasters(){const s=je(t.baseUrl,"/api/TimeZoneMaster"),n=await De(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n.Data:[]).map(a=>kt(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}`),o=await De(a,{method:"GET",headers:e});if(o&&typeof o=="object"){const l=o.data??o.Data??o,c=l?.timeZoneUniqueId??l?.TimeZoneUniqueId;if(c)return{timeZoneUniqueId:c}}return null}}}function Ca(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function qe(t,e){const s={...e.headers,...Ca()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function ja(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/api/detectionpolicy/rules",t.baseUrl).toString();return{async getRules(){const n=await qe(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 qe(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=[qe(n("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:e}),qe(n("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:e}),qe(n("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:e}),qe(n("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:e}),qe(n("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:e}),qe(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,l,c,u,h,m]=await Promise.allSettled(a),g=p=>p.status==="fulfilled"&&Array.isArray(p.value)?p.value:[],y=g(o),N=g(l),k=g(c),w=g(u),B=g(h),$=m.status==="fulfilled"?m.value:null;let Z=[];Array.isArray($)?Z=$:Array.isArray($?.Data)?Z=$.Data:Array.isArray($?.data)&&(Z=$.data);const Q=y.map(p=>({actionTypeId:Number(p?.ActionTypeId),name:p?.DisplayName??p?.Name??""})),K=N.map(p=>({recordId:p?.AnomalyId,anomalyName:p?.DisplayName??p?.Name??""})),q=k.map(p=>({thirdPartyId:Number(p?.ThirdPartyId),thirdPartyName:p?.ThirdPartyName??p?.Name??""})),U=Z.map(p=>({userRoleId:p.UserRoleId??p.userRoleId??p.Id??p.id??0,userRoleName:p.UserRoleName??p.userRoleName??p.Name??p.name??""})),ee={actionTypes:Q,anomalies:K,thirdParties:q};return w.length&&(ee.severities=w),B.length&&(ee.scheduleTypes=B),U.length&&(ee.userRoles=U),ee},async updateRule(n,r){const a=`${s}/${n}`,{escalationSettings:o,...l}=r??{};return qe(a,{method:"PUT",headers:e,body:JSON.stringify({...l,EscalationSettings:o??{}})})}}}function Da(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Xe(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 o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Ra(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/list-rule",t.baseUrl).toString();return{async getRules(){const n=await Xe(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 Xe(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=U=>new URL(U,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[Xe(n("/api/ActionTypeMaster/GetAll"),{method:"GET",headers:e}),Xe(n("/api/anomaly/anomaly-list"),{method:"POST",headers:e,body:JSON.stringify({RuleLevel:1})}),Xe(n("/api/Lookup/ThirdParties"),{method:"GET",headers:e}),Xe(n("/api/anomaly/severity-list"),{method:"GET",headers:e}),Xe(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,l,c,u,h]=await Promise.allSettled(a),m=U=>{if(U.status!=="fulfilled")return[];const ee=U.value;return Array.isArray(ee)?ee:Array.isArray(ee?.data)?ee.data:[]},g=m(o),y=m(l),N=m(c),k=m(u),w=h.status==="fulfilled"?h.value:null,B=g.map(U=>({actionTypeId:U?.ActionTypeUniqueId,name:U?.Name??""})),$=y.map(U=>({recordId:U?.AnomalyId,anomalyName:U?.DisplayName??U?.Name??""})),Z=N.map(U=>({thirdPartyId:Number(U?.ThirdPartyId),thirdPartyName:U?.ThirdPartyName??U?.Name??""}));let Q=[];Array.isArray(w)?Q=w:Array.isArray(w?.Data)?Q=w.Data:Array.isArray(w?.data)&&(Q=w.data);const K=Q.map(U=>({userRoleId:U.userRoleId??0,userRoleName:U.userRoleName??""})),q={actionTypes:B,anomalies:$,thirdParties:Z};return k.length&&(q.severities=k.map(U=>({SeverityId:U.SeverityId,DisplayName:U.SeverityName??U.DisplayName??""}))),K.length&&(q.userRoles=K),q},async updateRule(n,r){const a=new URL("/update-rule",t.baseUrl).toString(),{escalationSettings:o,ruleId:l,ruleName:c,ruleDesc:u,...h}=r??{},m=o??{},g=(m.escalationSettingsActionTypeIds??[]).filter(N=>N!=null&&!Number.isNaN(N)),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 Xe(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 La(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Pt(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,...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 o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Ua(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Re(t.baseUrl,"/api/Alerts"),r=Pt(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=Pt(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,o=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":r?.errorMessage??r?.message??"",statusCode:200,data:o}},async getAlertNotifications(s){const n=Re(t.baseUrl,"/api/Alerts/GetNotifications"),r=Pt(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"),o=Pt(a,{alertId:s,isEmail:n,isSMS:r});return Le(o,{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]),o=f.useMemo(()=>{const l={baseUrl:a.alertsBaseUrl,headers:a.headers},c={baseUrl:a.rulesBaseUrl,headers:a.headers},u={schools:()=>Oa(l),transit:()=>Ua(l),snl:()=>xa(l)},h={schools:()=>ja({...c,userManagementBaseUrl:a.userManagementDomain}),transit:()=>Ra({...c,userManagementBaseUrl:a.userManagementDomain}),snl:()=>va({baseUrl:a.alertsBaseUrl,headers:a.headers})};return{config:a,alerts:u[a.tenant](),rules:h[a.tenant]()}},[a]);return i.jsx(Hn.Provider,{value:o,children:r})}function Ee(){const t=f.useContext(Hn);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}const Fa={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},$a={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,o=e.isSMSSent??!1,l=n&&a||r&&o,c=n?"Send Email":r?"Send SMS":s,u=n&&a?"Email sent":r&&o?"SMS sent":c,h=n&&a?"Email sent":r&&o?"SMS sent":`Click to ${c}`;return{isDisabled:l,buttonText:u,tooltipTitle:h}}function Pa(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 Wa(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 Wt(t){return t===Rs||t===Ls}function ss({value:t,onChange:e,options:s,className:n,dropdownWidth:r}){return i.jsx(d.Select,{className:n,options:s,value:t,onChange:e,dropdownMatchSelectWidth:r??260})}const Va=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function Ba({value:t,onChange:e,options:s}){return i.jsx(ss,{className:"w-[140px]",value:t,onChange:e,options:s||Va})}const Za=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function za({value:t,onChange:e,options:s}){return i.jsx(ss,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||Za})}function Ha({value:t,onChange:e,options:s}){return i.jsx(ss,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const qa=[{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 Ga({value:t,onChange:e,options:s}){return i.jsx(ss,{className:"w-[130px]",value:t,onChange:e,options:s||qa})}function Gn({columns:t,data:e,loading:s=!1,pageSize:n=10,rowKey:r="id",toolbar:a,tableProps:o,onPageChange:l}){return i.jsxs("div",{children:[a,i.jsx(d.Table,{rowKey:r,dataSource:e,columns:t,loading:s,pagination:{pageSize:n,showSizeChanger:!0,showTotal:c=>`Total: ${c}`,onChange:l},bordered:!0,...o})]})}function Us({data:t,loading:e=!1,pageSize:s=10,columns:n,severityOptions:r,spaceOptions:a,renderActions:o,onAlertIdClick:l,onRefetch:c,onPageChange:u,excludeCompleted:h=!0}){const[m,g]=f.useState("All"),[y,N]=f.useState("All"),[k,w]=f.useState("All"),[B,$]=f.useState("All"),[Z,Q]=f.useState(""),[K,q]=f.useState([{label:"All",value:"All"}]),[U,ee]=f.useState(new Set),{rules:p,alerts:M}=Ee(),C={6:{title:"Email",kind:"icon",icon:i.jsx(lt.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:i.jsx(lt.MessageOutlined,{})}},ue=f.useMemo(()=>Pa(t),[t]),le=f.useMemo(()=>Wa(t),[t]);f.useEffect(()=>{let T=!0;return(async()=>{try{const I=await p.getLookups(),D=(Array.isArray(I.thirdParties)?I.thirdParties:[]).map(F=>({label:F.thirdPartyName,value:String(F.thirdPartyId)}));T&&q([{label:"All",value:"All"},...D])}catch(I){console.error("Error loading third party options",I)}})(),()=>{T=!1}},[p]);const E=f.useMemo(()=>(t||[]).some(T=>en(T).length>0),[t]),v=f.useMemo(()=>(t||[]).filter(T=>{const I=m==="All"||T.priority===m,V=`${T.id} ${T.description} ${T.statusType}`.toLowerCase(),D=!Z||V.includes(Z.toLowerCase()),F=y==="All"||(T.anomalyName||"").toLowerCase()===y.toLowerCase(),G=k==="All"||(T.spaceName||"").toLowerCase()===k.toLowerCase(),ie=!E||B==="All"||en(T).includes(Number(B)),re=!h||!["completed","false positive"].includes(String(T.statusType||"").toLowerCase());return I&&D&&F&&G&&ie&&re}),[t,m,Z,y,k,B,E,h]),S=ue,b=a?.length?a:le,x=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:T=>i.jsx(d.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${$a[T]}`,backgroundColor:Fa[T]},children:T})},{title:"Tracker",key:"tracker",width:140,render:(T,I)=>i.jsx("a",{onClick:V=>{V.preventDefault(),l?.(I,{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:(T,I)=>{if(o)return i.jsx(i.Fragment,{children:o(I)});const V=async(xe,Tt)=>{const Je=ms(I.id,xe);ee(ge=>new Set(ge).add(Je));try{const ge=await M.sendSMSorEmailNotifications?.(I.id,xe,Tt);ge?.responseStatus||ge?.Success||ge?.success?(Ae.toast.success(ge?.message||ge.data||(xe?"Email sent successfully":"SMS sent successfully")),c?.()):Ae.toast.error(ge?.message||ge?.data||ge?.errorMessage||"Failed to send notification")}catch(ge){Ae.toast.error(ge?.message||"Failed to send notification")}finally{ee(ge=>{const Qe=new Set(ge);return Qe.delete(Je),Qe})}},D=Rs,F=Ls,G=C[D],ie=C[F],re=on(D,I,G?.title),pe=on(F,I,ie?.title),Se=ms(I.id,!0),ce=ms(I.id,!1),ye=Wt(D)&&U.has(Se),Oe=Wt(F)&&U.has(ce);return i.jsxs(d.Space,{size:"middle",children:[i.jsx(d.Tooltip,{title:re.tooltipTitle,children:i.jsx(d.Button,{size:"small",disabled:re.isDisabled,loading:ye,onClick:Wt(D)?()=>V(!0,!1):void 0,icon:!ye&&G?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:re.buttonText})},String(D)),i.jsx(d.Tooltip,{title:pe.tooltipTitle,children:i.jsx(d.Button,{size:"small",disabled:pe.isDisabled,loading:Oe,onClick:Wt(F)?()=>V(!1,!0):void 0,icon:!Oe&&ie?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:pe.buttonText})},String(F))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(T,I)=>{const V=I?.timeElapsed,D=I?.timeRemaining,F=V?Xs(V):0,G=D?Xs(D):0,ie=Math.round(F/(F+G)*100);return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-[70px]",children:"Elapsed:"}),i.jsx("span",{className:"font-medium",children:V??"-"})]}),i.jsx(d.Progress,{percent:ie,showInfo:!1,size:"small",strokeColor:ma(I.priority)}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-[70px]",children:"Remaining"}),i.jsx("span",{className:"font-medium",children:D??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(T,I)=>i.jsxs("div",{children:[i.jsx("a",{onClick:V=>{V.preventDefault(),l?.(I,{sourceTab:"active"})},className:"inline-block mb-1 text-blue-600",children:I.alertNumber}),i.jsx("div",{className:"text-black/65",children:T})]})}],j=n&&n.length?n:x;return i.jsx("div",{children:i.jsx(Gn,{rowKey:"id",data:v,columns:j,loading:e,pageSize:s,onPageChange:u,toolbar:i.jsxs(d.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[i.jsx(d.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Severity"}),i.jsx(Ba,{value:m,onChange:g,options:r})]})}),i.jsx(d.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Anomaly type"}),i.jsx(za,{value:y,onChange:N,options:S})]})}),i.jsx(d.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Space"}),i.jsx(Ha,{value:k,onChange:w,options:b})]})}),i.jsx(d.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Action Taken"}),i.jsx(Ga,{value:B,onChange:$,options:K})]})}),i.jsx(d.Col,{flex:"auto"}),i.jsx(d.Col,{flex:"none",children:i.jsx(d.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:Q,onChange:T=>Q(T.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}function Fs(){const{alerts:t}=Ee(),e=ct.useQueryClient();return ct.useMutation({mutationFn:s=>t.updateAlertStatus(s),onSuccess:()=>{e.invalidateQueries({queryKey:["alerts","list"]}),e.invalidateQueries({queryKey:["alerts","report"]})}})}class ut extends Error{}class Ya extends ut{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class _a extends ut{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class Ja extends ut{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class ht extends ut{}class Yn extends ut{constructor(e){super(`Invalid unit ${e}`)}}class ve extends ut{}class et extends ut{constructor(){super("Zone is an abstract class")}}const A="numeric",Ze="short",Me="long",Qt={year:A,month:A,day:A},_n={year:A,month:Ze,day:A},Qa={year:A,month:Ze,day:A,weekday:Ze},Jn={year:A,month:Me,day:A},Qn={year:A,month:Me,day:A,weekday:Me},Kn={hour:A,minute:A},Xn={hour:A,minute:A,second:A},er={hour:A,minute:A,second:A,timeZoneName:Ze},tr={hour:A,minute:A,second:A,timeZoneName:Me},sr={hour:A,minute:A,hourCycle:"h23"},nr={hour:A,minute:A,second:A,hourCycle:"h23"},rr={hour:A,minute:A,second:A,hourCycle:"h23",timeZoneName:Ze},ar={hour:A,minute:A,second:A,hourCycle:"h23",timeZoneName:Me},ir={year:A,month:A,day:A,hour:A,minute:A},or={year:A,month:A,day:A,hour:A,minute:A,second:A},lr={year:A,month:Ze,day:A,hour:A,minute:A},cr={year:A,month:Ze,day:A,hour:A,minute:A,second:A},Ka={year:A,month:Ze,day:A,weekday:Ze,hour:A,minute:A},ur={year:A,month:Me,day:A,hour:A,minute:A,timeZoneName:Ze},dr={year:A,month:Me,day:A,hour:A,minute:A,second:A,timeZoneName:Ze},mr={year:A,month:Me,day:A,weekday:Me,hour:A,minute:A,timeZoneName:Me},fr={year:A,month:Me,day:A,weekday:Me,hour:A,minute:A,second:A,timeZoneName:Me};class Ct{get type(){throw new et}get name(){throw new et}get ianaName(){return this.name}get isUniversal(){throw new et}offsetName(e,s){throw new et}formatOffset(e,s){throw new et}offset(e){throw new et}equals(e){throw new et}get isValid(){throw new et}}let fs=null;class ns extends Ct{static get instance(){return fs===null&&(fs=new ns),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 Et(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 Xa(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 ei={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function ti(t,e){const s=t.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(s),[,r,a,o,l,c,u,h]=n;return[o,r,a,l,c,u,h]}function si(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:a,value:o}=s[r],l=ei[a];a==="era"?n[l]=o:W(l)||(n[l]=parseInt(o,10))}return n}const hs=new Map;class _e extends Ct{static create(e){let s=hs.get(e);return s===void 0&&hs.set(e,s=new _e(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=_e.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 Et(this.offset(e),s)}offset(e){if(!this.valid)return NaN;const s=new Date(e);if(isNaN(s))return NaN;const n=Xa(this.name);let[r,a,o,l,c,u,h]=n.formatToParts?si(n,s):ti(n,s);l==="BC"&&(r=-Math.abs(r)+1);const g=as({year:r,month:a,day:o,hour:c===24?0:c,minute:u,second:h,millisecond:0});let y=+s;const N=y%1e3;return y-=N>=0?N:1e3+N,(g-y)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let ln={};function ni(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 ks=new Map;function ri(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 bs=new Map;function ai(t,e={}){const{base:s,...n}=e,r=JSON.stringify([t,n]);let a=bs.get(r);return a===void 0&&(a=new Intl.RelativeTimeFormat(t,e),bs.set(r,a)),a}let bt=null;function ii(){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 oi(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 li(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:o}=n;return[r,a,o]}}function ci(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function ui(t){const e=[];for(let s=1;s<=12;s++){const n=P.utc(2009,s,1);e.push(t(n))}return e}function di(t){const e=[];for(let s=1;s<=7;s++){const n=P.utc(2016,11,13+s);e.push(t(n))}return e}function Vt(t,e,s,n){const r=t.listingMode();return r==="error"?null:r==="en"?s(e):n(e)}function mi(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||hr(t.locale).numberingSystem==="latn"}class fi{constructor(e,s,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;const{padTo:r,floor:a,...o}=n;if(!s||Object.keys(o).length>0){const l={useGrouping:!1,...n};n.padTo>0&&(l.minimumIntegerDigits=n.padTo),this.inf=ri(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 he(s,this.padTo)}}}class hi{constructor(e,s,n){this.opts=n,this.originalZone=void 0;let r;if(this.opts.timeZone)this.dt=e;else if(e.zone.type==="fixed"){const o=-1*(e.offset/60),l=o>=0?`Etc/GMT+${o}`:`Etc/GMT${o}`;e.offset!==0&&_e.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 yi{constructor(e,s,n){this.opts={style:"long",...n},!s&&Tr()&&(this.rtf=ai(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):Fi(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 o=e||fe.defaultLocale,l=o||(a?"en-US":ii()),c=s||fe.defaultNumberingSystem,u=n||fe.defaultOutputCalendar,h=Os(r)||fe.defaultWeekSettings;return new te(l,c,u,h,o)}static resetCache(){bt=null,As.clear(),ks.clear(),bs.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[o,l,c]=li(e);this.locale=o,this.numberingSystem=s||l||null,this.outputCalendar=n||c||null,this.weekSettings=r,this.intl=ci(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=a,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=mi(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 Vt(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 o=n?l=>this.dtFormatter(l,r).format():l=>this.extract(l,r,"month");this.monthsCache[a][e]=ui(o)}return this.monthsCache[a][e]})}weekdays(e,s=!1){return Vt(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]=di(a=>this.extract(a,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return Vt(this,void 0,()=>Cr,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[P.utc(2016,11,13,9),P.utc(2016,11,13,19)].map(s=>this.extract(s,e,"dayperiod"))}return this.meridiemCache})}eras(e){return Vt(this,e,jr,()=>{const s={era:e};return this.eraCache[e]||(this.eraCache[e]=[P.utc(-40,1,1),P.utc(2017,1,1)].map(n=>this.extract(n,s,"era"))),this.eraCache[e]})}extract(e,s,n){const r=this.dtFormatter(e,s),a=r.formatToParts(),o=a.find(l=>l.type.toLowerCase()===n);return o?o.value:null}numberFormatter(e={}){return new fi(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new hi(e,this.intl,s)}relFormatter(e={}){return new yi(this.intl,this.isEnglish(),e)}listFormatter(e={}){return ni(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()?oi(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 ke extends Ct{static get utcInstance(){return ys===null&&(ys=new ke(0)),ys}static instance(e){return e===0?ke.utcInstance:new ke(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new ke(is(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 gi extends Ct{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 st(t,e){if(W(t)||t===null)return e;if(t instanceof Ct)return t;if(Ti(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?ns.instance:s==="utc"||s==="gmt"?ke.utcInstance:ke.parseSpecifier(s)||_e.create(t)}else return nt(t)?ke.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new gi(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]},pi=$s.hanidec.replace(/[\[|\]]/g,"").split("");function Si(t){let e=parseInt(t,10);if(isNaN(e)){e="";for(let s=0;s<t.length;s++){const n=t.charCodeAt(s);if(t[s].search($s.hanidec)!==-1)e+=pi.indexOf(t[s]);else for(const r in cn){const[a,o]=cn[r];n>=a&&n<=o&&(e+=n-a)}}return parseInt(e,10)}else return e}const Es=new Map;function xi(){Es.clear()}function We({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 st(dn,ns.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(),_e.resetCache(),P.resetCache(),xi()}}class Be{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 Be("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+(jt(t)?pr:gr)[e-1]}function xr(t,e){const s=jt(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 Kt(t,e=4,s=1){const{year:n,month:r,day:a}=t,o=Sr(n,r,a),l=Ws(Ps(n,r,a),s);let c=Math.floor((o-l+14-e)/7),u;return c<1?(u=n-1,c=Ot(u,e,s)):c>Ot(n,e,s)?(u=n+1,c=1):u=n,{weekYear:u,weekNumber:c,weekday:l,...os(t)}}function Sn(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:a}=t,o=Ws(Ps(n,1,e),s),l=yt(n);let c=r*7+a-o-7+e,u;c<1?(u=n-1,c+=yt(u)):c>l?(u=n+1,c-=yt(n)):u=n;const{month:h,day:m}=xr(u,c);return{year:u,month:h,day:m,...os(t)}}function gs(t){const{year:e,month:s,day:n}=t,r=Sr(e,s,n);return{year:e,ordinal:r,...os(t)}}function xn(t){const{year:e,ordinal:s}=t,{month:n,day:r}=xr(e,s);return{year:e,month:n,day:r,...os(t)}}function wn(t,e){if(!W(t.localWeekday)||!W(t.localWeekNumber)||!W(t.localWeekYear)){if(!W(t.weekday)||!W(t.weekNumber)||!W(t.weekYear))throw new ht("Cannot mix locale-based week fields with ISO-based week fields");return W(t.localWeekday)||(t.weekday=t.localWeekday),W(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),W(t.localWeekYear)||(t.weekYear=t.localWeekYear),delete t.localWeekday,delete t.localWeekNumber,delete t.localWeekYear,{minDaysInFirstWeek:e.getMinDaysInFirstWeek(),startOfWeek:e.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function wi(t,e=4,s=1){const n=rs(t.weekYear),r=$e(t.weekNumber,1,Ot(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 vi(t){const e=rs(t.year),s=$e(t.ordinal,1,yt(t.year));return e?s?!1:Fe("ordinal",t.ordinal):Fe("year",t.year)}function wr(t){const e=rs(t.year),s=$e(t.month,1,12),n=$e(t.day,1,Xt(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,o=$e(s,0,59),l=$e(n,0,59),c=$e(r,0,999);return a?o?l?c?!1:Fe("millisecond",r):Fe("second",n):Fe("minute",s):Fe("hour",e)}function W(t){return typeof t>"u"}function nt(t){return typeof t=="number"}function rs(t){return typeof t=="number"&&t%1===0}function Ti(t){return typeof t=="string"}function Ai(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 Ni(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 pt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Os(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 rs(t)&&t>=e&&t<=s}function bi(t,e){return t-e*Math.floor(t/e)}function he(t,e=2){const s=t<0;let n;return s?n="-"+(""+-t).padStart(e,"0"):n=(""+t).padStart(e,"0"),n}function tt(t){if(!(W(t)||t===null||t===""))return parseInt(t,10)}function at(t){if(!(W(t)||t===null||t===""))return parseFloat(t)}function Vs(t){if(!(W(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 jt(t){return t%4===0&&(t%100!==0||t%400===0)}function yt(t){return jt(t)?366:365}function Xt(t,e){const s=bi(e-1,12)+1,n=t+(e-s)/12;return s===2?jt(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][s-1]}function as(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 Ot(t,e=4,s=1){const n=Tn(t,e,s),r=Tn(t+1,e,s);return(yt(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 o={timeZoneName:e,...a},l=new Intl.DateTimeFormat(s,o).formatToParts(r).find(c=>c.type.toLowerCase()==="timezonename");return l?l.value:null}function is(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 es(t,e){const s={};for(const n in t)if(pt(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}${he(s,2)}:${he(n,2)}`;case"narrow":return`${r}${s}${n>0?`:${n}`:""}`;case"techie":return`${r}${he(s,2)}${he(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function os(t){return ki(t,["hour","minute","second","millisecond"])}const Ii=["January","February","March","April","May","June","July","August","September","October","November","December"],br=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Mi=["J","F","M","A","M","J","J","A","S","O","N","D"];function Ir(t){switch(t){case"narrow":return[...Mi];case"short":return[...br];case"long":return[...Ii];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"],Ei=["M","T","W","T","F","S","S"];function Or(t){switch(t){case"narrow":return[...Ei];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"],Oi=["Before Christ","Anno Domini"],Ci=["BC","AD"],ji=["B","A"];function jr(t){switch(t){case"narrow":return[...ji];case"short":return[...Ci];case"long":return[...Oi];default:return null}}function Di(t){return Cr[t.hour<12?0:1]}function Ri(t,e){return Or(e)[t.weekday-1]}function Li(t,e){return Ir(e)[t.month-1]}function Ui(t,e){return jr(e)[t.year<0?0:1]}function Fi(t,e,s="always",n=!1){const r={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},a=["hours","minutes","seconds"].indexOf(t)===-1;if(s==="auto"&&a){const m=t==="days";switch(e){case 1:return m?"tomorrow":`next ${r[t][0]}`;case-1:return m?"yesterday":`last ${r[t][0]}`;case 0:return m?"today":`this ${r[t][0]}`}}const o=Object.is(e,-0)||e<0,l=Math.abs(e),c=l===1,u=r[t],h=n?c?u[1]:u[2]||u[1]:c?r[t][0]:t;return o?`${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 $i={D:Qt,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 Te{static create(e,s={}){return new Te(e,s)}static parseFormat(e){let s=null,n="",r=!1;const a=[];for(let o=0;o<e.length;o++){const l=e.charAt(o);l==="'"?((n.length>0||r)&&a.push({literal:r||/^\s+$/.test(n),val:n===""?"'":n}),s=null,n="",r=!r):r||l===s?n+=l:(n.length>0&&a.push({literal:/^\s+$/.test(n),val:n}),n=l,s=l)}return n.length>0&&a.push({literal:r||/^\s+$/.test(n),val:n}),a}static macroTokenToFormatOpts(e){return $i[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 he(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,N)=>this.loc.extract(e,y,N),o=y=>e.isOffsetFixed&&e.offset===0&&y.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,y.format):"",l=()=>n?Di(e):a({hour:"numeric",hourCycle:"h12"},"dayperiod"),c=(y,N)=>n?Li(e,y):a(N?{month:y}:{month:y,day:"numeric"},"month"),u=(y,N)=>n?Ri(e,y):a(N?{weekday:y}:{weekday:y,month:"long",day:"numeric"},"weekday"),h=y=>{const N=Te.macroTokenToFormatOpts(y);return N?this.formatWithSystemDefault(e,N):y},m=y=>n?Ui(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 o({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return o({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return o({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return l();case"d":return r?a({day:"numeric"},"day"):this.num(e.day);case"dd":return r?a({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return u("short",!0);case"cccc":return u("long",!0);case"ccccc":return u("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return u("short",!1);case"EEEE":return u("long",!1);case"EEEEE":return u("narrow",!1);case"L":return r?a({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?a({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return c("short",!0);case"LLLL":return c("long",!0);case"LLLLL":return c("narrow",!0);case"M":return r?a({month:"numeric"},"month"):this.num(e.month);case"MM":return r?a({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return c("short",!1);case"MMMM":return c("long",!1);case"MMMMM":return c("narrow",!1);case"y":return r?a({year:"numeric"},"year"):this.num(e.year);case"yy":return r?a({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?a({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?a({year:"numeric"},"year"):this.num(e.year,6);case"G":return m("short");case"GG":return m("long");case"GGGGG":return m("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return h(y)}};return An(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 N=m.isNegativeDuration&&y!==m.largestUnit?n:1;let k;return this.opts.signMode==="negativeLargestOnly"&&y!==m.largestUnit?k="never":this.opts.signMode==="all"?k="always":k="auto",this.num(h.get(y)*N,g.length,k)}else return g},o=Te.parseFormat(s),l=o.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(o,a(c,u))}}const Dr=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function St(...t){const e=t.reduce((s,n)=>s+n.source,"");return RegExp(`^${e}$`)}function xt(...t){return e=>t.reduce(([s,n,r],a)=>{const[o,l,c]=a(e,r);return[{...s,...o},l||n,c]},[{},null,1]).slice(0,2)}function wt(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]]=tt(e[s+r]);return[n,null,s+r]}}const Lr=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,Pi=`(?:${Lr.source}?(?:\\[(${Dr.source})\\])?)?`,Zs=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Ur=RegExp(`${Zs.source}${Pi}`),zs=RegExp(`(?:[Tt]${Ur.source})?`),Wi=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,Vi=/(\d{4})-?W(\d\d)(?:-?(\d))?/,Bi=/(\d{4})-?(\d{3})/,Zi=Rr("weekYear","weekNumber","weekDay"),zi=Rr("year","ordinal"),Hi=/(\d{4})-(\d\d)-(\d\d)/,Fr=RegExp(`${Zs.source} ?(?:${Lr.source}|(${Dr.source}))?`),qi=RegExp(`(?: ${Fr.source})?`);function gt(t,e,s){const n=t[e];return W(n)?s:tt(n)}function Gi(t,e){return[{year:gt(t,e),month:gt(t,e+1,1),day:gt(t,e+2,1)},null,e+3]}function vt(t,e){return[{hours:gt(t,e,0),minutes:gt(t,e+1,0),seconds:gt(t,e+2,0),milliseconds:Vs(t[e+3])},null,e+4]}function Dt(t,e){const s=!t[e]&&!t[e+1],n=is(t[e+1],t[e+2]),r=s?null:ke.instance(n);return[{},r,e+3]}function Rt(t,e){const s=t[e]?_e.create(t[e]):null;return[{},s,e+1]}const Yi=RegExp(`^T?${Zs.source}$`),_i=/^-?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 Ji(t){const[e,s,n,r,a,o,l,c,u]=t,h=e[0]==="-",m=c&&c[0]==="-",g=(y,N=!1)=>y!==void 0&&(N||y&&h)?-y:y;return[{years:g(at(s)),months:g(at(n)),weeks:g(at(r)),days:g(at(a)),hours:g(at(o)),minutes:g(at(l)),seconds:g(at(c),c==="-0"),milliseconds:g(Vs(u),m)}]}const Qi={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,o){const l={year:e.length===2?Cs(tt(e)):tt(e),month:br.indexOf(s)+1,day:tt(n),hour:tt(r),minute:tt(a)};return o&&(l.second=tt(o)),t&&(l.weekday=t.length>3?Mr.indexOf(t)+1:Er.indexOf(t)+1),l}const Ki=/^(?:(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 Xi(t){const[,e,s,n,r,a,o,l,c,u,h,m]=t,g=Hs(e,r,n,s,a,o,l);let y;return c?y=Qi[c]:u?y=0:y=is(h,m),[g,new ke(y)]}function eo(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const to=/^(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$/,so=/^(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$/,no=/^(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,o,l]=t;return[Hs(e,r,n,s,a,o,l),ke.utcInstance]}function ro(t){const[,e,s,n,r,a,o,l]=t;return[Hs(e,l,s,n,r,a,o),ke.utcInstance]}const ao=St(Wi,zs),io=St(Vi,zs),oo=St(Bi,zs),lo=St(Ur),$r=xt(Gi,vt,Dt,Rt),co=xt(Zi,vt,Dt,Rt),uo=xt(zi,vt,Dt,Rt),mo=xt(vt,Dt,Rt);function fo(t){return wt(t,[ao,$r],[io,co],[oo,uo],[lo,mo])}function ho(t){return wt(eo(t),[Ki,Xi])}function yo(t){return wt(t,[to,Nn],[so,Nn],[no,ro])}function go(t){return wt(t,[_i,Ji])}const po=xt(vt);function So(t){return wt(t,[Yi,po])}const xo=St(Hi,qi),wo=St(Fr),vo=xt(vt,Dt,Rt);function To(t){return wt(t,[xo,$r],[wo,vo])}const kn="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}},Ao={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,dt=146097/4800,No={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:dt/7,days:dt,hours:dt*24,minutes:dt*24*60,seconds:dt*24*60*60,milliseconds:dt*24*60*60*1e3},...Pr},ot=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],ko=ot.slice(0).reverse();function Ge(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 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 bn(t,e){const s=Wr(t,e)<0?-1:1;ot.reduceRight((n,r)=>{if(W(e[r]))return n;if(n){const a=e[n]*s,o=t[r][n],l=Math.floor(a/o);e[r]+=l*s,e[n]-=l*o*s}return r},null),ot.reduce((n,r)=>{if(W(e[r]))return n;if(n){const a=e[n]%1;e[n]-=a,e[r]+=a*t[n][r]}return r},null)}function In(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?No:Ao;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:es(e,J.normalizeUnit),loc:te.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(nt(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]=go(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]=So(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 Be?e:new Be(e,s);if(fe.throwOnInvalid)throw new Ja(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 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?Te.create(this.loc,n).formatDurationFromString(this,e):kn}toHuman(e={}){if(!this.isValid)return kn;const s=e.showZeros!==!1,n=ot.map(r=>{const a=this.values[r];return W(a)||a===0&&!s?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:r.slice(0,-1)}).format(a)}).filter(r=>r);return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(n)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e="P";return this.years!==0&&(e+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+"M"),this.weeks!==0&&(e+=this.weeks+"W"),this.days!==0&&(e+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+="T"),this.hours!==0&&(e+=this.hours+"H"),this.minutes!==0&&(e+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(e+=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},P.fromMillis(s,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?Wr(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 ot)(pt(s.values,r)||pt(this.values,r))&&(n[r]=s.get(r)+this.get(r));return Ge(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 Ge(this,{values:s},!0)}get(e){return this[J.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const s={...this.values,...es(e,J.normalizeUnit)};return Ge(this,{values:s})}reconfigure({locale:e,numberingSystem:s,conversionAccuracy:n,matrix:r}={}){const o={loc:this.loc.clone({locale:e,numberingSystem:s}),matrix:r,conversionAccuracy:n};return Ge(this,o)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return bn(this.matrix,e),Ge(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=In(this.normalize().shiftToAll().toObject());return Ge(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(o=>J.normalizeUnit(o));const s={},n={},r=this.toObject();let a;for(const o of ot)if(e.indexOf(o)>=0){a=o;let l=0;for(const u in n)l+=this.matrix[u][o]*n[u],n[u]=0;nt(r[o])&&(l+=r[o]);const c=Math.trunc(l);s[o]=c,n[o]=(l*1e3-c*1e3)/1e3}else nt(r[o])&&(n[o]=r[o]);for(const o in n)n[o]!==0&&(s[a]+=o===a?n[o]:n[o]/this.matrix[a][o]);return bn(this.matrix,s),Ge(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 Ge(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=In(this.values);return Ge(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 ot)if(!s(this.values[n],e.values[n]))return!1;return!0}}const mt="Invalid Interval";function bo(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 Be?e:new Be(e,s);if(fe.throwOnInvalid)throw new _a(n);return new me({invalid:n})}static fromDateTimes(e,s){const n=Nt(e),r=Nt(s),a=bo(n,r);return a??new me({start:n,end:r})}static after(e,s){const n=J.fromDurationLike(s),r=Nt(e);return me.fromDateTimes(r,r.plus(n))}static before(e,s){const n=J.fromDurationLike(s),r=Nt(e);return me.fromDateTimes(r.minus(n),r)}static fromISO(e,s){const[n,r]=(e||"").split("/",2);if(n&&r){let a,o;try{a=P.fromISO(n,s),o=a.isValid}catch{o=!1}let l,c;try{l=P.fromISO(r,s),c=l.isValid}catch{c=!1}if(o&&c)return me.fromDateTimes(a,l);if(o){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(Nt).filter(o=>this.contains(o)).sort((o,l)=>o.toMillis()-l.toMillis()),n=[];let{s:r}=this,a=0;for(;r<this.e;){const o=s[a]||this.e,l=+o>+this.e?this.e:o;n.push(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 o=[];for(;n<this.e;){const l=this.start.plus(s.mapUnits(c=>c*r));a=+l>+this.e?this.e:l,o.push(me.fromDateTimes(n,a)),n=a,r+=1}return o}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;const s=this.s>e.s?this.s:e.s,n=this.e<e.e?this.e:e.e;return s>=n?null: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],o)=>a?a.overlaps(o)||a.abutsStart(o)?[r,a.union(o)]:[r.concat([a]),o]:[r,o],[[],null]);return n&&s.push(n),s}static xor(e){let s=null,n=0;const r=[],a=e.map(c=>[{time:c.s,type:"s"},{time:c.e,type:"e"}]),o=Array.prototype.concat(...a),l=o.sort((c,u)=>c.time-u.time);for(const c of l)n+=c.type==="s"?1:-1,n===1?s=c.time:(s&&+s!=+c.time&&r.push(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()})`:mt}[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=Qt,s={}){return this.isValid?Te.create(this.s.loc.clone(s),e).formatInterval(this):mt}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:mt}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:mt}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:mt}toFormat(e,{separator:s=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${s}${this.e.toFormat(e)}`:mt}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 Bt{static hasDST(e=fe.defaultZone){const s=P.now().setZone(e).set({month:12});return!e.isUniversal&&s.offset!==s.set({month:6}).offset}static isValidIANAZone(e){return _e.isValidZone(e)}static normalizeZone(e){return st(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(J.fromMillis(n).as("days"))}function Io(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 o,l;for(const[c,u]of n)s.indexOf(c)>=0&&(o=c,r[c]=u(t,e),l=a.plus(r),l>e?(r[c]--,t=a.plus(r),t>e&&(l=t,r[c]--,t=a.plus(r))):t=l);return[t,r,l,o]}function Mo(t,e,s,n){let[r,a,o,l]=Io(t,e,s);const c=e-r,u=s.filter(m=>["hours","minutes","seconds","milliseconds"].indexOf(m)>=0);u.length===0&&(o<e&&(o=r.plus({[l]:1})),o!==r&&(a[l]=(a[l]||0)+c/(o-r)));const h=J.fromObject(a,n);return u.length>0?J.fromMillis(c,n).shiftTo(...u).plus(h):h}const Eo="missing Intl.DateTimeFormat.formatToParts support";function X(t,e=s=>s){return{regex:t,deser:([s])=>e(Si(s))}}const Oo=" ",Vr=`[ ${Oo}]`,Br=new RegExp(Vr,"g");function Co(t){return t.replace(/\./g,"\\.?").replace(Br,Vr)}function En(t){return t.replace(/\./g,"").replace(Br," ").toLowerCase()}function Ve(t,e){return t===null?null:{regex:RegExp(t.map(Co).join("|")),deser:([s])=>t.findIndex(n=>En(s)===En(n))+e}}function On(t,e){return{regex:t,deser:([,s,n])=>is(s,n),groups:e}}function Zt(t){return{regex:t,deser:([e])=>e}}function jo(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Do(t,e){const s=We(e),n=We(e,"{2}"),r=We(e,"{3}"),a=We(e,"{4}"),o=We(e,"{6}"),l=We(e,"{1,2}"),c=We(e,"{1,3}"),u=We(e,"{1,6}"),h=We(e,"{1,9}"),m=We(e,"{2,4}"),g=We(e,"{4,6}"),y=w=>({regex:RegExp(jo(w.val)),deser:([B])=>B,literal:!0}),k=(w=>{if(t.literal)return y(w);switch(w.val){case"G":return Ve(e.eras("short"),0);case"GG":return Ve(e.eras("long"),0);case"y":return X(u);case"yy":return X(m,Cs);case"yyyy":return X(a);case"yyyyy":return X(g);case"yyyyyy":return X(o);case"M":return X(l);case"MM":return X(n);case"MMM":return Ve(e.months("short",!0),1);case"MMMM":return Ve(e.months("long",!0),1);case"L":return X(l);case"LL":return X(n);case"LLL":return Ve(e.months("short",!1),1);case"LLLL":return Ve(e.months("long",!1),1);case"d":return X(l);case"dd":return X(n);case"o":return X(c);case"ooo":return X(r);case"HH":return X(n);case"H":return X(l);case"hh":return X(n);case"h":return X(l);case"mm":return X(n);case"m":return X(l);case"q":return X(l);case"qq":return X(n);case"s":return X(l);case"ss":return X(n);case"S":return X(c);case"SSS":return X(r);case"u":return Zt(h);case"uu":return Zt(l);case"uuu":return X(s);case"a":return Ve(e.meridiems(),0);case"kkkk":return X(a);case"kk":return X(m,Cs);case"W":return X(l);case"WW":return X(n);case"E":case"c":return X(s);case"EEE":return Ve(e.weekdays("short",!1),1);case"EEEE":return Ve(e.weekdays("long",!1),1);case"ccc":return Ve(e.weekdays("short",!0),1);case"cccc":return Ve(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 Zt(/[a-z_+-/]{1,256}?/i);case" ":return Zt(/[^\S\n\r]/);default:return y(w)}})(t)||{invalidReason:Eo};return k.token=t,k}const Ro={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 Lo(t,e,s){const{type:n,value:r}=t;if(n==="literal"){const c=/^\s+$/.test(r);return{literal:!c,val:c?" ":r}}const a=e[n];let o=n;n==="hour"&&(e.hour12!=null?o=e.hour12?"hour12":"hour24":e.hourCycle!=null?e.hourCycle==="h11"||e.hourCycle==="h12"?o="hour12":o="hour24":o=s.hour12?"hour12":"hour24");let l=Ro[o];if(typeof l=="object"&&(l=l[a]),l)return{literal:!1,val:l}}function Uo(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function Fo(t,e,s){const n=t.match(e);if(n){const r={};let a=1;for(const o in s)if(pt(s,o)){const l=s[o],c=l.groups?l.groups+1:1;!l.literal&&l.token&&(r[l.token.val[0]]=l.deser(n.slice(a,a+c))),a+=c}return[n,r]}else return[n,{}]}function $o(t){const e=a=>{switch(a){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let s=null,n;return W(t.z)||(s=_e.create(t.z)),W(t.Z)||(s||(s=new ke(t.Z)),n=t.Z),W(t.q)||(t.M=(t.q-1)*3+1),W(t.h)||(t.h<12&&t.a===1?t.h+=12:t.h===12&&t.a===0&&(t.h=0)),t.G===0&&t.y&&(t.y=-t.y),W(t.u)||(t.S=Vs(t.u)),[Object.keys(t).reduce((a,o)=>{const l=e(o);return l&&(a[l]=t[o]),a},{}),s,n]}let ps=null;function Po(){return ps||(ps=P.fromMillis(1555555555555)),ps}function Wo(t,e){if(t.literal)return t;const s=Te.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=>Wo(s,e)))}class zr{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=Zr(Te.parseFormat(s),e),this.units=this.tokens.map(n=>Do(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=Uo(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=Fo(e,this.regex,this.handlers),[r,a,o]=n?$o(n):[null,null,void 0];if(pt(n,"a")&&pt(n,"H"))throw new ht("Can't include meridiem when specifying 24-hour format");return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:s,matches:n,result:r,zone:a,specificOffset:o}}else return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function Hr(t,e,s){return new zr(t,s).explainFromTokens(e)}function Vo(t,e,s){const{result:n,zone:r,specificOffset:a,invalidReason:o}=Hr(t,e,s);return[n,r,a,o]}function qr(t,e){if(!t)return null;const n=Te.create(e,t).dtFormatter(Po()),r=n.formatToParts(),a=n.resolvedOptions();return r.map(o=>Lo(o,t,a))}const Ss="Invalid DateTime",Cn=864e13;function It(t){return new Be("unsupported zone",`the zone "${t.name}" is not supported`)}function xs(t){return t.weekData===null&&(t.weekData=Kt(t.c)),t.weekData}function ws(t){return t.localWeekData===null&&(t.localWeekData=Kt(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function it(t,e){const s={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new P({...s,...e,old:s})}function 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 Yt(t,e,s){return Gr(as(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,Xt(n,r))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},o=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=as(a);let[c,u]=Gr(l,s,t.zone);return o!==0&&(c+=o,u=t.zone.offset(c)),{ts:c,o:u}}function ft(t,e,s,n,r,a){const{setZone:o,zone:l}=s;if(t&&Object.keys(t).length!==0||e){const c=e||l,u=P.fromObject(t,{...s,zone:c,specificOffset:a});return o?u:u.setZone(l)}else return P.invalid(new Be("unparsable",`the input "${r}" can't be parsed as ${n}`))}function Ht(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+=he(t.c.year,n?6:4),s==="year")return r;if(e){if(r+="-",r+=he(t.c.month),s==="month")return r;r+="-"}else if(r+=he(t.c.month),s==="month")return r;return r+=he(t.c.day),r}function Dn(t,e,s,n,r,a,o){let l=!s||t.c.millisecond!==0||t.c.second!==0,c="";switch(o){case"day":case"month":case"year":break;default:if(c+=he(t.c.hour),o==="hour")break;if(e){if(c+=":",c+=he(t.c.minute),o==="minute")break;l&&(c+=":",c+=he(t.c.second))}else{if(c+=he(t.c.minute),o==="minute")break;l&&(c+=he(t.c.second))}if(o==="second")break;l&&(!n||t.c.millisecond!==0)&&(c+=".",c+=he(t.c.millisecond,3))}return r&&(t.isOffsetFixed&&t.offset===0&&!a?c+="Z":t.o<0?(c+="-",c+=he(Math.trunc(-t.o/60)),c+=":",c+=he(Math.trunc(-t.o%60))):(c+="+",c+=he(Math.trunc(t.o/60)),c+=":",c+=he(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},Bo={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},Zo={ordinal:1,hour:0,minute:0,second:0,millisecond:0},_t=["year","month","day","hour","minute","second","millisecond"],zo=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],Ho=["year","ordinal","hour","minute","second","millisecond"];function Jt(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 Jt(t)}}function qo(t){if(Mt===void 0&&(Mt=fe.now()),t.type!=="iana")return t.offset(Mt);const e=t.name;let s=js.get(e);return s===void 0&&(s=t.offset(Mt),js.set(e,s)),s}function Ln(t,e){const s=st(e.zone,fe.defaultZone);if(!s.isValid)return P.invalid(It(s));const n=te.fromObject(e);let r,a;if(W(t.year))r=fe.now();else{for(const c of _t)W(t[c])&&(t[c]=Yr[c]);const o=wr(t)||vr(t);if(o)return P.invalid(o);const l=qo(s);[r,a]=Yt(t,l,s)}return new P({ts:r,zone:s,loc:n,o:a})}function Un(t,e,s){const n=W(s.round)?!0:s.round,r=W(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)),o=l=>s.calendary?e.hasSame(t,l)?0:e.startOf(l).diff(t.startOf(l),l).get(l):e.diff(t,l).get(l);if(s.unit)return a(o(s.unit),s.unit);for(const l of s.units){const c=o(l);if(Math.abs(c)>=1)return a(c,l)}return a(t>e?-0:0,s.units[s.units.length-1])}function 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 Mt;const js=new Map;class P{constructor(e){const s=e.zone||fe.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Be("invalid input"):null)||(s.isValid?null:It(s));this.ts=W(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=nt(e.o)&&!e.old?e.o:s.offset(this.ts);r=zt(this.ts,l),n=Number.isNaN(r.year)?new Be("invalid input"):null,r=n?null:r,a=n?null:l}this._zone=s,this.loc=e.loc||te.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=a,this.isLuxonDateTime=!0}static now(){return new P({})}static local(){const[e,s]=Fn(arguments),[n,r,a,o,l,c,u]=s;return Ln({year:n,month:r,day:a,hour:o,minute:l,second:c,millisecond:u},e)}static utc(){const[e,s]=Fn(arguments),[n,r,a,o,l,c,u]=s;return e.zone=ke.utcInstance,Ln({year:n,month:r,day:a,hour:o,minute:l,second:c,millisecond:u},e)}static fromJSDate(e,s={}){const n=Ai(e)?e.valueOf():NaN;if(Number.isNaN(n))return P.invalid("invalid input");const r=st(s.zone,fe.defaultZone);return r.isValid?new P({ts:n,zone:r,loc:te.fromObject(s)}):P.invalid(It(r))}static fromMillis(e,s={}){if(nt(e))return e<-Cn||e>Cn?P.invalid("Timestamp out of range"):new P({ts:e,zone:st(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(nt(e))return new P({ts:e*1e3,zone:st(s.zone,fe.defaultZone),loc:te.fromObject(s)});throw new ve("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=st(s.zone,fe.defaultZone);if(!n.isValid)return P.invalid(It(n));const r=te.fromObject(s),a=es(e,Rn),{minDaysInFirstWeek:o,startOfWeek:l}=wn(a,r),c=fe.now(),u=W(s.specificOffset)?n.offset(c):s.specificOffset,h=!W(a.ordinal),m=!W(a.year),g=!W(a.month)||!W(a.day),y=m||g,N=a.weekYear||a.weekNumber;if((y||h)&&N)throw new ht("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(g&&h)throw new ht("Can't mix ordinal dates with month/day");const k=N||a.weekday&&!y;let w,B,$=zt(c,u);k?(w=zo,B=Bo,$=Kt($,o,l)):h?(w=Ho,B=Zo,$=gs($)):(w=_t,B=Yr);let Z=!1;for(const M of w){const C=a[M];W(C)?Z?a[M]=B[M]:a[M]=$[M]:Z=!0}const Q=k?wi(a,o,l):h?vi(a):wr(a),K=Q||vr(a);if(K)return P.invalid(K);const q=k?Sn(a,o,l):h?xn(a):a,[U,ee]=Yt(q,u,n),p=new P({ts:U,zone:n,o:ee,loc:r});return a.weekday&&y&&e.weekday!==p.weekday?P.invalid("mismatched weekday",`you can't specify both a weekday of ${a.weekday} and a date of ${p.toISO()}`):p.isValid?p:P.invalid(p.invalid)}static fromISO(e,s={}){const[n,r]=fo(e);return ft(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=ho(e);return ft(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=yo(e);return ft(n,r,s,"HTTP",s)}static fromFormat(e,s,n={}){if(W(e)||W(s))throw new ve("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:a=null}=n,o=te.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0}),[l,c,u,h]=Vo(o,e,s);return h?P.invalid(h):ft(l,c,n,`format ${s}`,e,u)}static fromString(e,s,n={}){return P.fromFormat(e,s,n)}static fromSQL(e,s={}){const[n,r]=To(e);return ft(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 Be?e:new Be(e,s);if(fe.throwOnInvalid)throw new Ya(n);return new P({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(Te.parseFormat(e),te.fromObject(s)).map(r=>r.val).join("")}static resetCache(){Mt=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?Bt.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Bt.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Bt.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Bt.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=as(this.c),r=this.zone.offset(n-e),a=this.zone.offset(n+e),o=this.zone.offset(n-r*s),l=this.zone.offset(n-a*s);if(o===l)return[this];const c=n-o*s,u=n-l*s,h=zt(c,o),m=zt(u,l);return h.hour===m.hour&&h.minute===m.minute&&h.second===m.second&&h.millisecond===m.millisecond?[it(this,{ts:c}),it(this,{ts:u})]:[this]}get isInLeapYear(){return jt(this.year)}get daysInMonth(){return Xt(this.year,this.month)}get daysInYear(){return this.isValid?yt(this.year):NaN}get weeksInWeekYear(){return this.isValid?Ot(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Ot(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(ke.instance(e),s)}toLocal(){return this.setZone(fe.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=st(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),o=this.toObject();[r]=Yt(o,a,e)}return it(this,{ts:r,zone:e})}else return P.invalid(It(e))}reconfigure({locale:e,numberingSystem:s,outputCalendar:n}={}){const r=this.loc.clone({locale:e,numberingSystem:s,outputCalendar:n});return it(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const s=es(e,Rn),{minDaysInFirstWeek:n,startOfWeek:r}=wn(s,this.loc),a=!W(s.weekYear)||!W(s.weekNumber)||!W(s.weekday),o=!W(s.ordinal),l=!W(s.year),c=!W(s.month)||!W(s.day),u=l||c,h=s.weekYear||s.weekNumber;if((u||o)&&h)throw new ht("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(c&&o)throw new ht("Can't mix ordinal dates with month/day");let m;a?m=Sn({...Kt(this.c,n,r),...s},n,r):W(s.ordinal)?(m={...this.toObject(),...s},W(s.day)&&(m.day=Math.min(Xt(m.year,m.month),m.day))):m=xn({...gs(this.c),...s});const[g,y]=Yt(m,this.o,this.zone);return it(this,{ts:g,o:y})}plus(e){if(!this.isValid)return this;const s=J.fromDurationLike(e);return it(this,jn(this,s))}minus(e){if(!this.isValid)return this;const s=J.fromDurationLike(e).negate();return it(this,jn(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:o}=this;o<a&&(n.weekNumber=this.weekNumber-1),n.weekday=a}else n.weekday=1;if(r==="quarters"){const a=Math.ceil(this.month/3);n.month=(a-1)*3+1}return this.set(n)}endOf(e,s){return this.isValid?this.plus({[e]:1}).startOf(e,s).minus(1):this}toFormat(e,s={}){return this.isValid?Te.create(this.loc.redefaultToEN(s)).formatDateTimeFromString(this,e):Ss}toLocaleString(e=Qt,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:o="milliseconds"}={}){if(!this.isValid)return null;o=Jt(o);const l=e==="extended";let c=vs(this,l,o);return _t.indexOf(o)>=3&&(c+="T"),c+=Dn(this,l,s,n,r,a,o),c}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?vs(this,e==="extended",Jt(s)):null}toISOWeekDate(){return Ht(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:s=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:a=!1,format:o="extended",precision:l="milliseconds"}={}){return this.isValid?(l=Jt(l),(r&&_t.indexOf(l)>=3?"T":"")+Dn(this,o==="extended",s,e,n,a,l)):null}toRFC2822(){return Ht(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return Ht(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")),Ht(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=Ni(s).map(J.normalizeUnit),o=e.valueOf()>this.valueOf(),l=o?this:e,c=o?e:this,u=Mo(l,c,a,r);return o?u.negate():u}diffNow(e="milliseconds",s={}){return this.diff(P.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||P.fromObject({},{zone:this.zone}),n=e.padding?this<s?-e.padding:e.padding:0;let r=["years","months","days","hours","minutes","seconds"],a=e.unit;return Array.isArray(e.unit)&&(r=e.unit,a=void 0),Un(s,this.plus(n),{...e,numeric:"always",units:r,unit:a})}toRelativeCalendar(e={}){return this.isValid?Un(e.base||P.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(P.isDateTime))throw new ve("min requires all arguments be DateTimes");return vn(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every(P.isDateTime))throw new ve("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,o=te.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});return Hr(o,e,s)}static fromStringExplain(e,s,n={}){return P.fromFormatExplain(e,s,n)}static buildFormatParser(e,s={}){const{locale:n=null,numberingSystem:r=null}=s,a=te.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new zr(a,e)}static fromFormatParser(e,s,n={}){if(W(e)||W(s))throw new ve("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:a=null}=n,o=te.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});if(!o.equals(s.locale))throw new ve(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${s.locale}`);const{result:l,zone:c,specificOffset:u,invalidReason:h}=s.explainFromTokens(e);return h?P.invalid(h):ft(l,c,n,`format ${s.format}`,e,u)}static get DATE_SHORT(){return Qt}static get DATE_MED(){return _n}static get DATE_MED_WITH_WEEKDAY(){return Qa}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 Ka}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 Nt(t){if(P.isDateTime(t))return t;if(t&&t.valueOf&&nt(t.valueOf()))return P.fromJSDate(t);if(t&&typeof t=="object")return P.fromObject(t);throw new ve(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function Go(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function Yo(t,e){try{const s=P.fromJSDate(t,{zone:"utc"}).setZone(e),n=s.toJSDate().toLocaleString("en-US",{timeZone:e,timeZoneName:"short"}).split(" ").pop()||void 0,r=s.toFormat("ZZ")||void 0;return{abbr:n,offset:r}}catch{return{}}}function _o(t){if(!t)return"-";try{const e=new Date(t),s=u=>String(u).padStart(2,"0"),n=s(e.getMonth()+1),r=s(e.getDate()),a=e.getFullYear(),o=s(e.getHours()),l=s(e.getMinutes()),c=s(e.getSeconds());return`${n}/${r}/${a} ${o}:${l}:${c}`}catch{return"-"}}function ts(t,e="UTC"){if(!t)return"-";const s=P.fromISO(t,{zone:"utc"}).setZone(e);if(!s.isValid)return"-";const n=s.offsetNameShort,r=s.toFormat("ZZZZ"),a=n.startsWith("GMT")||n===r?r:`${n}/${r}`;return`${s.toFormat("MM/dd/yyyy, hh:mm:ss a")} (${a})`}const Jo={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Qo={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:o}){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 N=y?.Message||y?.data||"Alert reopened successfully.";Ae.toast.success(N)}else{const N=y?.errorMessage||y?.Message||"Failed to reopen alert";Ae.toast.error(N)}}catch{Ae.toast.error("Failed to reopen alert. Please try again.")}},h=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:g=>i.jsx(d.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Jo[g]}`,backgroundColor:Qo[String(g)]},children:g})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:g=>_o(g)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(g,y)=>i.jsxs("div",{children:[i.jsx("a",{onClick:N=>{N.preventDefault(),o?.(y,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:y.alertNumber}),i.jsx("div",{className:"text-black/65",children:g})]})},{title:"",key:"menu",width:60,align:"right",render:(g,y)=>i.jsx(d.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:N})=>{N==="reopen"&&u(y)}},children:i.jsx(d.Button,{type:"text",icon:i.jsx(lt.MoreOutlined,{})})})}],m=(t||[]).filter(g=>c.includes((g.statusType||"").toLowerCase()));return i.jsx(Us,{data:m,loading:e,pageSize:s,columns:h,severityOptions:n,anomalyOptions:r,spaceOptions:a,renderActions:void 0,onAlertIdClick:o,excludeCompleted:!1})}function Ko({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]),o=a*6,l=r*6+a*.1,c=n%12*30+r*.5,u=t/2;return i.jsxs("div",{className:"relative rounded-full border border-gray-300 bg-white",style:{width:t,height:t},role:"img","aria-label":"Analog Clock",children:[[...Array(12)].map((h,m)=>{const g=m*30,y=6,N=u-4,k=N-y,w=(g-90)*(Math.PI/180),B=u+k*Math.cos(w),$=u+k*Math.sin(w),Z=u+N*Math.cos(w),Q=u+N*Math.sin(w);return i.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:i.jsx("line",{x1:B,y1:$,x2:Z,y2:Q,stroke:"#9CA3AF",strokeWidth:m%3===0?2:1,strokeLinecap:"round"})},m)}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${c}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.25,stroke:"#1F2937",strokeWidth:4,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${l}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.35,stroke:"#374151",strokeWidth:3,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${o}deg)`},children:i.jsx("line",{x1:u,y1:u+t*.08,x2:u,y2:u-t*.38,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"})}),i.jsx("div",{className:"absolute bg-gray-900 rounded-full",style:{width:8,height:8,left:u-4,top:u-4}})]})}function 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 o=f.useMemo(()=>Go(r,e),[r,e]),{abbr:l,offset:c}=f.useMemo(()=>Yo(r,e),[r,e]);return i.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[i.jsx(Ko,{time:r,timeZone:e,size:80}),i.jsxs("div",{className:"flex flex-col items-baseline gap-1",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[i.jsx("span",{className:"uppercase",children:t}),l&&i.jsxs("span",{className:"p-2 rounded-md border text-[10px] leading-none text-gray-600 bg-gray-50",children:[l," ",c]})]}),i.jsx("div",{className:"text-2xl font-semibold text-gray-700 tracking-wide",children:o})]})]})}const{Text:Xo}=d.Typography;function el({sortBy:t,onChange:e,showActions:s,onSave:n,onClear:r,saving:a}){return i.jsxs(d.Row,{gutter:[16,16],align:"middle",children:[i.jsx(d.Col,{xs:24,md:8,lg:5,children:i.jsxs(d.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[i.jsx(Xo,{className:"text-gray-600 whitespace-nowrap",children:"Sort By:"}),i.jsx(d.Select,{placeholder:"By Severity",value:t,onChange:o=>e({sortBy:o}),options:[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],className:"w-full",style:{minWidth:"200px"}})]})}),i.jsx(d.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?i.jsxs(d.Space,{className:"w-full",direction:"horizontal",size:8,children:[i.jsx(d.Button,{onClick:r,disabled:a,children:"Clear"}),i.jsx(d.Button,{type:"primary",onClick:n,loading:a,children:"Save"})]}):null})]})}const Ds=t=>i.jsxs(d.Tag,{children:[i.jsx(lt.PlusOutlined,{})," ",t.length," more"]}),{Text:Ye}=d.Typography;function tl(t){const{selectedRule:e,setSelectedRule:s,ruleOptions:n,minsOptions:r,roleOptions:a,l1mins:o,setL1mins:l,l1role:c,setL1role:u,l2mins:h,setL2mins:m,l2role:g,setL2role:y,l3mins:N,setL3mins:k,l3role:w,setL3role:B,actions:$,setActions:Z,thirdPartyIds:Q,setThirdPartyIds:K,humanLoop:q,setHumanLoop:U,isAutoExpire:ee,setAutoExpire:p,onClear:M,onSave:C,saving:ue,onActionTypesLoaded:le}=t,{rules:E}=Ee(),[v,S]=f.useState([]),[b,x]=f.useState([]),[j,T]=f.useState(!1);f.useEffect(()=>{let D=!1;return(async()=>{try{T(!0);const F=await E.getLookups();if(D||!F||!Array.isArray(F.actionTypes))return;const G=F.actionTypes.map(re=>({label:re.name,value:String(re.actionTypeId)}));S(G),le&&le(F.actionTypes);const ie=Array.isArray(F.thirdParties)?F.thirdParties.map(re=>({label:re.thirdPartyName,value:re.thirdPartyId})):[];x(ie)}catch(F){console.error("Error loading lookups",F)}finally{D||T(!1)}})(),()=>{D=!0}},[]);const I=typeof o=="number"||typeof c=="number"||typeof h=="number"||typeof g=="number"||typeof N=="number"||typeof w=="number"||Array.isArray($)&&$.length>0||Array.isArray(Q)&&Q.length>0||!!q||!!ee,V=!!e&&I&&!ue;return i.jsxs(d.Spin,{spinning:!!ue||j,children:[i.jsxs(d.Row,{gutter:[16,16],align:"bottom",children:[i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Ye,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(d.Select,{placeholder:"Rules",value:e,onChange:s,options:n,className:"w-full"})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(Ye,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),i.jsx(d.Col,{span:14,children:i.jsx(Ye,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:o,onChange:l,options:r})}),i.jsx(d.Col,{span:14,children:i.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:c,onChange:u,options:a})})]})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(Ye,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),i.jsx(d.Col,{span:14,children:i.jsx(Ye,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:h,onChange:m,options:r})}),i.jsx(d.Col,{span:14,children:i.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:g,onChange:y,options:a})})]})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(Ye,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),i.jsx(d.Col,{span:14,children:i.jsx(Ye,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:N,onChange:k,options:r})}),i.jsx(d.Col,{span:14,children:i.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:w,onChange:B,options:a})})]})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Ye,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),i.jsx(d.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:$,onChange:Z,options:v,maxTagCount:1,maxTagPlaceholder:Ds})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Ye,{className:"text-gray-700 font-medium block mb-1",children:"Third Party App"}),i.jsx(d.Select,{mode:"multiple",placeholder:"Third Party app",className:"w-full",value:Q,onChange:K,options:b,maxCount:2,maxTagPlaceholder:Ds})]})})]}),i.jsxs(d.Row,{gutter:[16,16],align:"bottom",className:"mt-4 items-center",children:[i.jsx(d.Col,{xs:24,sm:12,md:8,lg:7,children:i.jsxs("div",{className:"flex items-center h-full gap-8",children:[i.jsx(d.Checkbox,{checked:q,onChange:D=>U(D.target.checked),className:"w-full",children:"Human-In-The-Loop"}),i.jsx(d.Checkbox,{checked:ee,onChange:D=>p(D.target.checked),className:"w-full",children:"Auto-expire in 5 minutes"})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.Button,{onClick:M,children:"Clear"}),i.jsx(d.Button,{type:"primary",onClick:C,loading:!!ue,disabled:!V,children:"Save"})]})})]})]})}function sl({entries:t,userRoles:e,onEdit:s,loading:n}){const r=new Map(e.map(o=>[o.userRoleId,o.userRoleName])),a=o=>o.map(l=>r.get(l)||String(l)).join(", ");return i.jsx(d.Table,{rowKey:"id",dataSource:t,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(o,l)=>`${l[0]}-${l[1]} of ${o} items`},loading:n,columns:[{title:"Rule",dataIndex:"ruleOrSeverityLabel",key:"rule"},{title:"Level 1",key:"l1",render:(o,l)=>i.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:(o,l)=>i.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:(o,l)=>i.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:(o,l)=>l.actions?.length?l.actions.join(", "):"-"},{title:"Notify",key:"notify",render:(o,l)=>l.notify?.length?l.notify.join(", "):"-"},{title:"Human-In-The-Loop",key:"humanLoop",render:(o,l)=>l.humanLoop?"Yes":"No"},{title:"Auto Expire",key:"isAutoExpire",render:(o,l)=>l.isAutoExpire?"Yes":"No"},{title:"Actions",key:"ops",render:(o,l)=>i.jsx(d.Button,{type:"text",onClick:()=>s(l.id),children:i.jsx(lt.EditOutlined,{})})}]})}const{Title:nl}=d.Typography;function Qr({userRoles:t,rules:e,rawRules:s}){const{rules:n}=Ee(),[r,a]=f.useState(!1),[o,l]=f.useState(s),[c,u]=f.useState({}),h=f.useMemo(()=>t.map(k=>({label:k.userRoleName,value:k.userRoleId})),[t]),m=f.useMemo(()=>(e||[]).map((k,w)=>({key:k.RuleId||k.Name||String(w),ruleName:k.Name||"-",ruleDesc:k.Description||""})),[e]);f.useEffect(()=>{let k=!1;return(async()=>{try{a(!0);const w=await n.getRules();k||(l(Array.isArray(w)?w:[]),u({}))}catch{!k&&Array.isArray(s)&&l(s)}finally{k||a(!1)}})(),()=>{k=!0}},[]),f.useEffect(()=>{!o&&Array.isArray(s)&&l(s)},[s]);const g=f.useMemo(()=>{if(!Array.isArray(o)||!o.length)return{};const k={};for(const w of m){const B=o.find(Z=>Z?.ruleId===w.key||Z?.ruleName===w.key||Z?.RuleId===w.key||Z?.ruleName===w.ruleName||Z?.Name===w.ruleName),$=Array.isArray(B?.userRoleIds)?B.userRoleIds:[];$.length&&(k[w.key]=$)}return k},[o,m]),y=()=>{u({})},N=async()=>{try{if(!o||!Array.isArray(o)||Object.keys(c).length===0){Ae.toast.info("No changes to save");return}a(!0);const k=Object.entries(c).map(async([w,B])=>{const $=o.find(U=>U?.ruleId===w||U?.ruleName===w||U?.RuleId===w),Z=typeof $?.recordId=="number"?$.recordId:$?.ruleId||$?.RuleId||void 0;if(!$||!Z)throw new Error(`Unable to find rule identifier for rule ${w}`);const Q=Array.isArray(B)?B:[],K=Q.map(U=>{const ee=t.find(p=>p.userRoleId===U);return{id:U,name:ee?.userRoleName??String(U)}}),q={...$,ruleId:w,userRoleIds:Q,userRoles:K};return n.updateRule(Z,q)});await Promise.all(k),Ae.toast.success("Alert assignment saved");try{const w=await n.getRules();l(Array.isArray(w)?w:[]),u({})}catch(w){console.error("Failed to refresh rules after save",w)}}catch(k){console.error("Failed to save alert assignment",k)}finally{a(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsx(nl,{level:4,className:"!mb-4",children:"Alert Assignment"})}),i.jsx(d.Table,{rowKey:"key",dataSource:m,loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(k,w)=>`${w[0]}-${w[1]} of ${k} items`},columns:[{title:"Rule Name",dataIndex:"ruleName",key:"ruleName"},{title:"Description",dataIndex:"ruleDesc",key:"ruleDesc"},{title:"Alert Notification To",key:"assign",render:(k,w)=>i.jsx(d.Select,{mode:"multiple",placeholder:"Dropdown with Multi select",className:"w-full",value:c[w.key]??g[w.key]??[],onChange:B=>u($=>({...$,[w.key]:B})),options:h,maxTagCount:1,maxTagPlaceholder:Ds})}]}),i.jsxs(d.Space,{className:"mt-4",children:[i.jsx(d.Button,{onClick:y,disabled:r,children:"Clear"}),i.jsx(d.Button,{type:"primary",onClick:N,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,onSave:r}){const{rules:a,alerts:o}=Ee(),[l,c]=f.useState("By Severity"),[u,h]=f.useState("By severity"),[m,g]=f.useState("By Severity"),[y,N]=f.useState(!1),[k,w]=f.useState(!1),[B,$]=f.useState(!1),[Z,Q]=f.useState(null),[K,q]=f.useState("rules"),[U,ee]=f.useState(),[p,M]=f.useState(),[C,ue]=f.useState(),[le,E]=f.useState(),[v,S]=f.useState(),[b,x]=f.useState(),[j,T]=f.useState(),[I,V]=f.useState(),[D,F]=f.useState([]),[G,ie]=f.useState([]),[re,pe]=f.useState(!1),[Se,ce]=f.useState(!1),[ye,Oe]=f.useState({}),[xe,Tt]=f.useState({}),[Je,ge]=f.useState(s||[]),[Qe,At]=f.useState([]),[rt,Lt]=f.useState(!1),[O,z]=f.useState(!1),[H,we]=f.useState(n||[]);f.useEffect(()=>{n&&n.length&&we(n)},[n]),f.useEffect(()=>{if(!H||!H.length)return;const R=Object.keys(ye).length>0||Object.keys(xe).length>0;if(Qe.length&&!R)return;const ae=H.map((Y,L)=>{const ne=e.find(Ne=>Ne.RuleId===(Y.ruleId||Y.ruleName))?.Name||Y.ruleName||Y.Name||"-",_=Y.escalationSettings||{},oe=typeof _.level1UserRoleId=="number"&&_.level1UserRoleId>0?[_.level1UserRoleId]:[],Pe=typeof _.level2UserRoleId=="number"&&_.level2UserRoleId>0?[_.level2UserRoleId]:[],cs=typeof _.level3UserRoleId=="number"&&_.level3UserRoleId>0?[_.level3UserRoleId]:[],_s=(Array.isArray(_.escalationSettingsActionTypeIds)?_.escalationSettingsActionTypeIds:[]).map(Ne=>ye[Ne]||String(Ne)),Qs=(Array.isArray(_.thirdPartyId)?_.thirdPartyId:[]).map(Ne=>xe[Ne]||String(Ne)),us=typeof _.humanLoop=="boolean"?_.humanLoop:null,ds=typeof _.isAutoExpire=="boolean"?_.isAutoExpire:null;return{id:String(Y.ruleId||Y.ruleName||L),ruleOrSeverityLabel:ne,l1:{minutes:_.level1PostAssistTime??void 0,roles:oe},l2:{minutes:_.level2PostAssistTime??void 0,roles:Pe},l3:{minutes:_.level3PostAssistTime??void 0,roles:cs},actions:_s,notify:Qs,humanLoop:us,isAutoExpire:ds}});At(ae)},[H,e,ye,xe]);const Ce=f.useMemo(()=>t.map(R=>({label:R.DisplayName,value:R.SeverityId})),[t]),se=f.useMemo(()=>e.map(R=>({label:R.Name,value:R.RuleId})),[e]),ze=f.useMemo(()=>Je.map(R=>({label:R.userRoleName,value:R.userRoleId})),[Je]),Ke=f.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(R=>({label:`${R}`,value:R})),[]);f.useEffect(()=>{let R=!1;async function ae(){try{$(!0),Q(null);const Y=await o.getAdminSettings();if(!R&&Y){const L=Zn(Y.sortBy);c(L),g(L),N(!1)}}catch(Y){if(!R){const L=Y instanceof Error?Y.message:"Failed to load admin settings";Q(L)}}finally{R||$(!1)}}return ae(),()=>{R=!0}},[]),f.useEffect(()=>{if(!p)return;const R=ne=>{const _=Number(ne);return!isNaN(_)&&_>0?_:void 0},ae=ne=>{const _=Number(ne);return!isNaN(_)&&_>0?_:void 0},L=(H||[]).find(ne=>ne?.ruleId===p||ne?.ruleName===p||ne?.RuleId===p)?.escalationSettings;if(L&&typeof L=="object"){ue(ae(L.level1PostAssistTime)),E(R(L.level1UserRoleId)),S(ae(L.level2PostAssistTime)),x(R(L.level2UserRoleId)),T(ae(L.level3PostAssistTime)),V(R(L.level3UserRoleId));const ne=Array.isArray(L.escalationSettingsActionTypeIds)?L.escalationSettingsActionTypeIds:[];F(ne.map(_=>String(_))),ie(Array.isArray(L.thirdPartyId)?L.thirdPartyId:[]),pe(!!L.humanLoop),ce(!!L.isAutoExpire)}},[K,p,H]);const He=async()=>{try{z(!0);const R=await a.getRules(),ae=Array.isArray(R)?R:Array.isArray(R?.data)?R.data:[];we(ae);const Y=ae.map((L,ne)=>{const _=e.find(Ne=>Ne.RuleId===(L.ruleId||L.ruleName))?.Name||L.ruleName||L.Name||"-",oe=L.escalationSettings||{},Pe=typeof oe.level1UserRoleId=="number"&&oe.level1UserRoleId>0?[oe.level1UserRoleId]:[],cs=typeof oe.level2UserRoleId=="number"&&oe.level2UserRoleId>0?[oe.level2UserRoleId]:[],Ys=typeof oe.level3UserRoleId=="number"&&oe.level3UserRoleId>0?[oe.level3UserRoleId]:[],Js=(Array.isArray(oe.escalationSettingsActionTypeIds)?oe.escalationSettingsActionTypeIds:[]).map(Ne=>ye[Ne]||String(Ne)),us=(Array.isArray(oe.thirdPartyId)?oe.thirdPartyId:[]).map(Ne=>xe[Ne]||String(Ne)),ds=typeof oe.humanLoop=="boolean"?oe.humanLoop:null;return{id:String(L.ruleId||L.ruleName||ne),ruleOrSeverityLabel:_,l1:{minutes:oe.level1PostAssistTime??void 0,roles:Pe},l2:{minutes:oe.level2PostAssistTime??void 0,roles:cs},l3:{minutes:oe.level3PostAssistTime??void 0,roles:Ys},actions:Js,notify:us,humanLoop:ds}});At(Y)}catch(R){console.error("Failed to refetch entries",R)}finally{z(!1)}};f.useEffect(()=>{let R=!1;return(async()=>{try{const ae=await a.getLookups();if(R||!ae)return;const Y={};if(Array.isArray(ae.thirdParties))for(const ne of ae.thirdParties)typeof ne.thirdPartyId=="number"&&(Y[ne.thirdPartyId]=ne.thirdPartyName);Tt(Y);const L=Array.isArray(ae.userRoles)?ae.userRoles.map(ne=>({userRoleId:ne.userRoleId??ne.id,userRoleName:ne.userRoleName??ne.name})):[];R||ge(L.length?L:s||[])}catch(ae){console.error("Error loading lookups",ae)}})(),()=>{R=!0}},[]);const ra=async()=>{w(!0);try{const R=await o.setAdminSettings({sortBy:l,groupBy:"string"});R?.responseStatus&&R?.data&&Ae.toast.success(R.data),g(l),N(!1)}catch(R){console.error("Error saving admin settings",R)}finally{w(!1)}},aa=()=>{c(m),N(!1)},ia=async()=>{Lt(!0),r?.({ruleId:p,levels:[{minutes:C,role:le},{minutes:v,role:b},{minutes:j,role:I}],actions:D,thirdPartyIds:G,humanLoop:re,isAutoExpire:Se});try{if(p){const Y=Array.isArray(D)?D.map(Pe=>Number.isNaN(Number(Pe))?Pe:Number(Pe)):[],L=(H||[]).find(Pe=>Pe?.ruleId===p||Pe?.ruleName===p||Pe?.RuleId===p),ne=typeof L?.recordId=="number"?L.recordId:L?.ruleId||L?.RuleId||void 0;if(!L||!ne){Ae.toast.error("Unable to find rule identifier for update");return}const _={...L,escalationSettings:{level1UserRoleId:le??0,level1PostAssistTime:C??0,level2UserRoleId:b??0,level2PostAssistTime:v??0,level3UserRoleId:I??0,level3PostAssistTime:j??0,escalationSettingsActionTypeIds:Y,thirdPartyId:Array.isArray(G)?G:[],humanLoop:re,isAutoExpire:Se}},oe=await a.updateRule(ne,_);if(oe?.responseStatus||oe?.Success||oe?.success){Ae.toast.success("Escalation settings saved"),await He(),M(void 0),ue(void 0),E(void 0),S(void 0),x(void 0),T(void 0),V(void 0),F([]),ie([]),pe(!1),ce(!1);return}else Ae.toast.error(oe?.errorMessage||"Error saving Escalation Settings")}}catch(Y){console.error("Error saving escalation settings",Y)}finally{Lt(!1)}const ae=e.find(Y=>Y.RuleId===p)?.Name||"-";At(Y=>[...Y,{id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,ruleOrSeverityLabel:ae,l1:{minutes:C,roles:le?[le]:[]},l2:{minutes:v,roles:b?[b]:[]},l3:{minutes:j,roles:I?[I]:[]},actions:(Array.isArray(D)?D:[]).map(L=>{const ne=Number(L);return ye[ne]||String(L)}),notify:(Array.isArray(G)?G:[]).map(L=>xe[L]||String(L)),humanLoop:!!re,isAutoExpire:!!Se}])},oa=()=>{c("By Severity"),h("By severity"),q("rules"),ee(void 0),M(void 0),ue(void 0),E(void 0),S(void 0),x(void 0),T(void 0),V(void 0),F([]),ie([]),pe(!1),ce(!1)};return i.jsxs("div",{className:"w-full",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx($n,{level:4,className:"!mb-2",children:"Admin Settings"}),i.jsxs(d.Spin,{spinning:B,children:[Z?i.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",Z]}):null,i.jsx(el,{sortBy:l,groupBy:u,onChange:R=>{R.sortBy&&(c(R.sortBy),N(!0)),R.groupBy&&(h(R.groupBy),N(!0))},showActions:y,onSave:ra,onClear:aa,saving:k})]})]}),i.jsx(d.Divider,{className:"my-6"}),i.jsxs("div",{children:[i.jsx($n,{level:4,className:"!mb-4",children:"Escalation Settings"}),i.jsx(tl,{escBasis:K,setEscBasis:q,selectedSeverity:U,setSelectedSeverity:ee,selectedRule:p,setSelectedRule:M,severityOptions:Ce,ruleOptions:se,minsOptions:Ke,roleOptions:ze,l1mins:C,setL1mins:ue,l1role:le,setL1role:E,l2mins:v,setL2mins:S,l2role:b,setL2role:x,l3mins:j,setL3mins:T,l3role:I,setL3role:V,actions:D,setActions:F,thirdPartyIds:G,setThirdPartyIds:ie,humanLoop:re,setHumanLoop:pe,onClear:oa,onSave:ia,saving:rt,onActionTypesLoaded:R=>{const ae={};for(const Y of R)typeof Y.actionTypeId=="number"&&(ae[Y.actionTypeId]=Y.name);Oe(ae)},isAutoExpire:Se,setAutoExpire:ce})]}),i.jsx(d.Divider,{className:"my-6"}),i.jsx(sl,{entries:Qe,userRoles:Je,loading:O,onEdit:R=>{q("rules");const ae=Qe.find(L=>L.id===R),Y=e.find(L=>L.RuleId===R)||(ae?e.find(L=>L.Name===ae.ruleOrSeverityLabel):void 0);M(Y?Y.RuleId:R)}}),i.jsx(d.Divider,{className:"my-6"}),i.jsx(Qr,{userRoles:Je,rules:e,rawRules:n}),i.jsx(d.Divider,{})]})}const{Title:Pn,Text:qt}=d.Typography;function rl({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:a}=Ee(),o=[{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,N]=f.useState(null),[k,w]=f.useState({inApp:!1,sms:!1,email:!1}),[B,$]=f.useState([]),[Z,Q]=f.useState(!0),[K,q]=f.useState(!1);f.useEffect(()=>{let p=!1;return(async()=>{try{const M=await a.getPreferenceSettings();if(p||!M)return;w({inApp:!!M.inApp,sms:!!M.sms,email:!!M.email});const C=Zn(M.sortBy);c(C==="By Created Date"?"By Created Date":"By Severity"),g(rn(M.doNotDisturbStart)),N(rn(M.doNotDisturbEnd)),Array.isArray(M.anomalyIds)&&h(new Set(M.anomalyIds.map(ue=>String(ue))))}catch(M){console.error("Error in loading my preferences: ",M)}})(),()=>{p=!0}},[]),f.useEffect(()=>{let p=!1;return(async()=>{try{Q(!0);const M=await r.getLookups();if(p||!M)return;const C=Array.isArray(M.anomalies)?M.anomalies:[];$(C)}catch(M){console.error("Failed to load anomalies lookups",M)}finally{p||Q(!1)}})(),()=>{p=!0}},[]);const U=p=>{h(M=>{const C=new Set(M);return C.has(p)?C.delete(p):C.add(p),C})},ee=async()=>{s?.({sortBy:l,subscribedRuleIds:Array.from(u),dnd:{from:m,to:y},channels:k});try{q(!0);const p=m?m.format?.("HH:mm:ss")??"00:00:00":"00:00:00",M=y?y.format?.("HH:mm:ss")??"00:00:00":"00:00:00",C=Array.from(u).map(le=>Number(le)).filter(le=>Number.isFinite(le)),ue=await a.setPreferenceSettings({anomalyIds:C,doNotDisturbStart:p,doNotDisturbEnd:M,inApp:!!k.inApp,sms:!!k.sms,email:!!k.email,sortBy:l});ue?.responseStatus&&Ae.toast.success(ue?.data||"Preferences updated successfully.")}catch(p){console.error("Error in saving my preferences: ",p)}finally{q(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(d.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:i.jsx(d.Col,{xs:24,md:8,children:i.jsxs(d.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(qt,{className:"text-gray-600",children:"Sort By:"}),i.jsx(d.Select,{className:"w-[240px]",value:l,options:o,onChange:c})]})})}),i.jsxs("div",{className:"mb-4",children:[i.jsx(Pn,{level:5,className:"!mb-2",children:"Anomalies"}),Z?i.jsx("div",{className:"py-4",children:i.jsx(d.Spin,{})}):i.jsx(d.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray(B)?B:[]).map(p=>{const M=String(p.recordId),C=p.anomalyName;return i.jsx(d.Checkbox,{checked:u.has(M),onChange:()=>U(M),children:C},M)})})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx(Pn,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),i.jsx(d.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:i.jsx(d.Col,{xs:24,md:12,children:i.jsxs(d.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(qt,{children:"Do Not Disturb mode:"}),i.jsxs(d.Space,{size:12,className:"w-full",children:[i.jsxs(d.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(qt,{children:"From"}),i.jsx(d.TimePicker,{value:m,onChange:p=>g(p),format:"HH:mm"})]}),i.jsxs(d.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(qt,{children:"To"}),i.jsx(d.TimePicker,{value:y,onChange:p=>N(p),format:"HH:mm"})]})]})]})})}),i.jsxs(d.Row,{gutter:[24,12],children:[i.jsx(d.Col,{children:i.jsx(d.Checkbox,{checked:k.inApp,onChange:p=>w({...k,inApp:p.target.checked}),children:"In-app"})}),i.jsx(d.Col,{children:i.jsx(d.Checkbox,{checked:k.sms,onChange:p=>w({...k,sms:p.target.checked}),children:"SMS"})}),i.jsx(d.Col,{children:i.jsx(d.Checkbox,{checked:k.email,onChange:p=>w({...k,email:p.target.checked}),children:"Email"})})]})]}),i.jsx(d.Divider,{}),i.jsxs(d.Space,{className:"gap-3",children:[i.jsx(d.Button,{onClick:n,disabled:K,children:"Cancel"}),i.jsx(d.Button,{type:"primary",onClick:ee,loading:K,children:"Save"})]})]})}function Xr({severities:t,rules:e,userRoles:s,rawRules:n}){return i.jsx("div",{className:"w-full",children:i.jsx(Kr,{severities:t,rules:e,userRoles:s,rawRules:n})})}const al="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=",il="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 ls(){const{config:t}=Ee();return{timeZoneDetails:f.useMemo(()=>{const s=t.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone;return{timeZoneUniqueId:"",ianaTimeZoneId:s,timeZoneName:s,offset:""}},[t.timeZone]),loading:!1}}function ol(t){const e=(t.status||"").toLowerCase()==="completed"?i.jsx("img",{src:al,alt:"completed",style:{width:20,height:20}}):i.jsx("img",{src:il,alt:"pending",style:{width:20,height:20}});return{title:i.jsxs("div",{className:"flex flex-col gap-0 min-w-0",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{className:"block text-sm break-words mb-1 overflow-visible whitespace-normal",children:i.jsx("b",{children:t.title})}),t.description?i.jsx("span",{className:"text-gray-500 text-xs",children:t.description}):null]}),t.timestamp?i.jsx("span",{className:"text-gray-500 text-xs",children:t.timestamp}):null]}),icon:e,description:null}}function ll({data:t}){const{timeZoneDetails:e}=ls();return console.log("summary",t),i.jsx("div",{className:"w-full",children:i.jsx(d.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:i.jsxs("div",{className:"w-full",style:{maxHeight:"50vh",overflowY:"auto"},children:[i.jsx(d.Card,{className:"mb-4 rounded-md p-4",bordered:!0,children:i.jsxs("div",{className:"grid grid-cols-4 gap-6 text-xs",children:[i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Alert ID"}),i.jsx("span",{className:"text-black",children:t.summary.alertNumber})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Severity"}),i.jsx("span",{className:"text-black",children:t.summary.severity})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Location"}),i.jsx("span",{className:"text-black",children:t.summary.location})]})]})}),i.jsxs(d.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsx("h4",{className:"text-sm text-black font-medium",children:"Response Timeline/ Audit trail/log"})}),i.jsx("div",{className:"mt-2",children:i.jsx(d.Steps,{direction:"vertical",size:"small",current:1,items:(t.timeline||[]).map(ol)})})]})]})},{key:"notification",label:"Notification Sent",children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",style:{maxHeight:"50vh",overflowY:"auto"},children:[(t.notifications||[]).map((s,n)=>i.jsxs(d.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("h4",{className:"text-sm text-black font-medium",children:s.channelLabel}),i.jsx("span",{className:"text-xs text-gray-500 mt-1",children:ts(s.sentAt,e?.ianaTimeZoneId)})]}),i.jsxs("span",{className:"text-[11px] px-2 py-1 rounded-full bg-green-50 text-green-700 border border-green-200",children:[s.delivered,"/",s.total," Delivered"]})]}),i.jsxs("div",{className:"mt-4 text-xs",children:[i.jsxs("div",{className:"text-black",children:[" ",s.messageTitle]}),s.messageBody?i.jsx("div",{className:"text-gray-600",children:s.messageBody}):null]}),i.jsxs("div",{className:"mt-4",children:[i.jsxs("div",{className:"text-xs text-black font-medium",children:["Recipients (",s.total,")"]}),i.jsx("div",{className:"mt-2 flex flex-col gap-3 text-xs",children:(s.recipients||[]).map((r,a)=>{const o=String(r?.notificationReceipientType||"").toLowerCase()==="EscalationNotification".toLowerCase();return i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsxs("span",{className:"text-black",children:[r.name," - ",i.jsx("span",{style:{color:o?"#FF3B30":"#FFB86A"},children:o?"Escalation Notification":"Alert Notification"})]}),i.jsxs("span",{className:"text-gray-500",children:[r.role," . ",r.phone]})]}),i.jsx("span",{className:`text-[11px] px-3 py-[2px] rounded ${r.status==="Delivered"?"bg-green-50 text-green-700 border border-green-200":"bg-red-50 text-red-700 border border-red-200"}`,children:r.status})]},a)})})]})]},n)),t?.notifications?.length?null:i.jsx("span",{className:"text-gray-500 text-xs",children:"No notifications."})]})}]})})}const cl=({alertId:t,id:e,priority:s,spaceName:n,alertNumber:r,statusHistory:a,notifGroups:o})=>{const l={alertId:t??String(e??""),incidentId:"-",severity:s||"",location:n||"",alertNumber:r??""},{timeZoneDetails:c}=ls(),u=a?.length?a.map(m=>{const g=(m?.status||m?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",y=m?.createdDate?ts(m.createdDate,c?.ianaTimeZoneId):m?.timestamp?ts(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:o??[]};return i.jsx(ll,{data:h})};const ul=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),dl=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),Wn=t=>{const e=dl(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(),ml=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var fl={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 hl=f.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:a,iconNode:o,...l},c)=>f.createElement("svg",{ref:c,...fl,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:ea("lucide",r),...!a&&!ml(l)&&{"aria-hidden":"true"},...l},[...o.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(hl,{ref:a,iconNode:e,className:ea(`lucide-${ul(Wn(t))}`,`lucide-${t}`,n),...r}));return s.displayName=Wn(t),s};const yl=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],gl=qs("loader-circle",yl);const pl=[["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",pl);const Sl=[["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"}]],xl=qs("minimize-2",Sl),wl=({isOpen:t,onClose:e,src:s,type:n="image"})=>{const[r,a]=f.useState(!1),[o,l]=f.useState(!1);return f.useEffect(()=>{t&&l(!1)},[t,s]),f.useEffect(()=>{t&&(!s||o)&&e()},[t,s,o,e]),t?i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-70",role:"button",tabIndex:0,"aria-label":"Close media preview",onClick:e,onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),e())},onTouchStart:e,children:i.jsxs("div",{className:`relative ${r?"w-full h-full":"max-w-5xl max-h-[90vh] w-full"} flex items-center justify-center`,onClick:c=>c.stopPropagation(),children:[n==="image"?i.jsx("img",{src:s,alt:"preview",className:`object-contain rounded-lg shadow-lg ${r?"w-full h-full":"max-w-full max-h-[90vh]"}`,onError:()=>l(!0)}):i.jsx("video",{src:s,controls:!0,className:`object-contain rounded-lg shadow-lg ${r?"w-full h-full":"max-w-full max-h-[90vh]"}`,onError:()=>l(!0)}),i.jsx("button",{onClick:e,className:"absolute top-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:"✕"}),i.jsx("button",{onClick:()=>a(!r),className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:r?i.jsx(xl,{size:20}):i.jsx(ta,{size:20})})]})}):null};function vl(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:vl(t?.mediaUrl||t)}function Tl(t){const e=t;return e?Array.isArray(e)?e:[e]:[]}const Al={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Nl={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},kl=({isModalOpen:t,handleModalClose:e,selectedRow:s,fetchAlertLogs:n,alertStatusList:r=[],alertStatusLoading:a=!1,initialTab:o="details",sourceTab:l})=>{const[c,u]=f.useState(),[h,m]=f.useState(""),[g,y]=f.useState(!1),N=f.useRef(null),[k,w]=f.useState("details"),[B,$]=f.useState(void 0),Z=Fs(),{alerts:Q}=Ee(),{timeZoneDetails:K}=ls(),[q,U]=f.useState(!1),[ee,p]=f.useState(void 0),[M,C]=f.useState(void 0),[ue,le]=f.useState({}),[E,v]=f.useState({}),S=s?.originalData||{},{eventName:b,alertId:x,timestamp:j,description:T,spaceName:I,assignTeam:V,priority:D,statusType:F,id:G,alertDetails:ie,statusHistory:re,mediaDetails:pe,alertNumber:Se}=S,ce=O=>{const z=String(O||"").toLowerCase();return z==="delivered"||z==="sent"?"Delivered":z==="failed"?"Failed":"Queued"},ye=O=>({name:O?.receipientName||O?.recipientName||"-",role:O?.receipientRoleName||"",phone:O?.receipentPhoneNumber||O?.recipientPhoneNumber||O?.receipientEmail||O?.recipientEmail||"",status:ce(O?.messageStatus),notificationReceipientType:O?.notificationReceipientType||""}),Oe=(O,z)=>{const H=z.map(ye),we=H.filter(Ke=>Ke.status==="Delivered").length,Ce=z.map(Ke=>Ke?.sentAt).filter(Boolean).sort((Ke,He)=>new Date(He).getTime()-new Date(Ke).getTime())[0],se=z[0]||{},ze=[se?.severityName,se?.anomalyName].filter(Boolean).join(" - ")||`${O} Notification`;return{channelLabel:`${O} Notification`,sentAt:Ce||"",messageTitle:ze,messageBody:"",total:H.length,delivered:we,recipients:H}},xe=O=>{const z=new Map;return(O||[]).forEach(H=>{const we=String(H?.notificationType||"Unknown"),Ce=z.get(we)||[];Ce.push(H),z.set(we,Ce)}),Array.from(z.entries()).map(([H,we])=>Oe(H,we))},Tt=async O=>{try{const z=await Q.getAlertNotifications(O),H=xe(z);$(H)}catch{$(void 0)}};f.useEffect(()=>{if(k!=="track"||!G)return;let O=!1;return Tt(G).then(()=>{O&&$(void 0)}),()=>{O=!0}},[k,G]),f.useEffect(()=>{t&&w(o)},[t,o]);const ge=l==="archived"||["completed","false positive"].includes(String(F||"").toLowerCase()),Qe=O=>{const z=String(O?.value||"").toLowerCase(),H=String(O?.statusName||"").toLowerCase();return z.includes("reopen")||H.includes("reopen")},At=(r||[]).filter(O=>{const z=Qe(O);return typeof l<"u"?l==="archived"?z:!z:ge?z:!z}).map(O=>({value:O.value,label:O.statusName})),rt=f.useMemo(()=>Tl(pe),[pe]);f.useEffect(()=>{let O=!1;const z=new AbortController,H=async se=>{if(se){O||le(ze=>({...ze,[se]:!1}));try{const ze=await fetch(se,{method:"HEAD",signal:z.signal});if(ze.ok){O||le(He=>({...He,[se]:!0}));return}if(ze.status===404){O||le(He=>({...He,[se]:!1}));return}if(!(await fetch(se,{method:"GET",signal:z.signal})).ok)throw new Error("Media not available");O||le(He=>({...He,[se]:!0}))}catch{O||le(ze=>({...ze,[se]:!1}))}}};le({});const we=rt.filter(se=>!Vn(se)).map(se=>se?.mediaUrl||se).filter(se=>typeof se=="string"&&se.length>0),Ce={};return we.forEach(se=>{Ce[se]=!0}),v(Ce),we.forEach(se=>H(se)),()=>{O=!0,z.abort()}},[rt]);const Lt=async()=>{try{y(!0);const O={alertUniqueId:x,alertId:G,status:c?String(c):void 0,notes:h.trim(),modifiedBy:0},z=await Z.mutateAsync(O);if(z?.responseStatus||z?.Success){const H=z?.Message||z?.data||"Alert updated successfully.";Ae.toast.success(H,{autoClose:1500,onClose:()=>{n(),e()}}),u(void 0),m("")}else{const H=z?.errorMessage||z?.Message||"Failed to update alert status";Ae.toast.error(H)}}catch(O){console.error("Error updating alert status:",O),Ae.toast.error("Failed to update alert status. Please try again.")}finally{y(!1)}};return i.jsx(d.Modal,{open:t,onCancel:e,width:1e3,footer:k==="details"?i.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[i.jsx(d.Button,{onClick:e,className:"bg-[#6C757D] text-white",children:"Cancel"}),i.jsx(d.Button,{type:"primary",onClick:Lt,loading:g,children:g?"Saving...":"Save Changes"})]}):null,children:s&&i.jsx(d.Tabs,{activeKey:k,onChange:O=>w(O),items:[{key:"details",label:"Alert Detail",children:i.jsxs("div",{className:"grid grid-cols-2 gap-2",style:{maxHeight:"50vh",overflowY:"auto"},children:[i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("div",{className:"text-sm font-bold",children:b||"Alert Event"}),ie?.firstName?i.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",ie?.firstName," ",ie?.lastName||"","   ",ie?.residentId||""]}):null,i.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp: ",ts(j,K?.ianaTimeZoneId)]}),i.jsxs("div",{className:"font-sm text-gray-500",children:[i.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",T||"No description available"]}),I&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",I]}),V&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",V]}),i.jsxs("div",{className:"flex gap-2 justify-start mt-3",children:[i.jsxs(d.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${Al[String(D)]||"#DFE4EA"}`,backgroundColor:Nl[String(D)]},children:["Severity: ",D||"N/A"]}),i.jsxs(d.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(F||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",F||"N/A"]})]}),i.jsx("div",{className:"w-full flex flex-col justify-start items-start mt-2 font-bold",children:i.jsxs("div",{className:"w-full mt-4",children:[i.jsx("div",{className:"flex flex-col gap-2",children:i.jsx(d.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:O=>u(O),value:c,options:At,loading:a})}),i.jsxs("div",{className:"flex flex-col gap-2 mt-3",children:[i.jsx("label",{htmlFor:"action-details-input",className:"text-xs text-gray-500 font-medium",children:"Action Taken (Comments)"}),i.jsx("textarea",{id:"action-details-input",placeholder:"Enter details...",className:"w-full text-gray-500 h-20 border border-grey-500 rounded-md p-2",value:h,onChange:O=>m(O.target.value)})]})]})})]}),i.jsx("div",{className:"flex flex-col gap-4",children:i.jsxs("div",{className:"w-full mt-1",children:[i.jsxs("div",{className:"w-full flex items-center justify-between",children:[i.jsx("h3",{className:"text-black font-bold text-sm",children:"Camera Footage"}),rt.length>1?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>N.current?.prev?.(),className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 text-gray-600","aria-label":"Previous media",children:i.jsx(lt.LeftOutlined,{style:{fontSize:12}})}),i.jsx("button",{type:"button",onClick:()=>N.current?.next?.(),className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 text-gray-600","aria-label":"Next media",children:i.jsx(lt.RightOutlined,{style:{fontSize:12}})})]}):null]}),rt.length?i.jsx("div",{className:"w-full",children:i.jsx(d.Carousel,{ref:N,dots:!0,className:"w-full",children:rt.map((O,z)=>{const H=O.mediaUrl||O,we=Vn(O),Ce=!we&&E[String(H)];return i.jsxs("div",{className:"flex justify-center items-center relative",children:[we?i.jsxs("video",{width:"240",height:"200",controls:!0,className:"max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg",children:[i.jsx("source",{src:H}),"Your browser does not support the video tag."]}):i.jsxs("div",{className:"relative w-full flex justify-center items-center min-h-[200px]",children:[Ce&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg z-10",children:i.jsx(gl,{size:32,className:"animate-spin text-gray-400"})}),i.jsx("img",{src:H,alt:O.caption||`media-${z}`,className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg transition-opacity duration-200 ${Ce?"opacity-0":"opacity-100"}`,onLoad:()=>v(se=>({...se,[String(H)]:!1})),onError:()=>v(se=>({...se,[String(H)]:!1}))},String(H))]}),O.caption&&i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:O.caption}),!we&&ue[String(H)]?i.jsx("button",{onClick:()=>{U(!0),p(H),C(O.type||"image")},className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:i.jsx(ta,{size:20})}):null]},String(H)||z)})})}):null]})}),i.jsx(wl,{isOpen:q,onClose:()=>U(!1),src:ee||"",type:M||"image"})]})},{key:"track",label:"Track Incident",children:i.jsx(cl,{alertId:x,id:G,priority:D,spaceName:I,alertNumber:Se,statusHistory:re,notifGroups:B})}]})})};function sa(){const{alerts:t}=Ee(),e=ct.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,o]=f.useState(!1),[l,c]=f.useState(null),[u,h]=f.useState("details"),{list:m,loading:g}=sa(),{timeZoneDetails:y}=ls(),N=y?.timeZoneName??"UTC",k=y?.ianaTimeZoneId??"UTC";function w(K,q){c(K),h(q?.tab??"details"),Z(q?.sourceTab??"active"),o(!0)}function B(){o(!1)}const[$,Z]=f.useState("active"),Q=l?{originalData:{...l,alertId:l.alertId??l.id,mediaDetails:l.mediaDetails}}:null;return i.jsxs("div",{className:"p-6 flex flex-col items-start justify-start min-h-screen w-full overflow-auto",children:[i.jsxs("div",{className:"w-full grid grid-cols-3 sm:grid-cols-1 items-center mb-4",children:[i.jsx("h1",{className:"text-xl font-bold text-black",children:"Alert Console"}),i.jsx("div",{className:"flex items-center justify-start sm:justify-center",children:i.jsx(Jr,{label:N,timeZone:k})})]}),i.jsx(d.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:K=>{K==="active"&&n?.()},items:[{key:"active",label:"Active",children:i.jsx(Us,{data:t,loading:e,pageSize:10,columns:s||[],onAlertIdClick:w,onRefetch:n,onPageChange:r})},{key:"archived",label:"Archived",children:i.jsx(_r,{alerts:t,loading:e,columns:s||[],onAlertIdClick:w})},{key:"settings",label:"Settings",children:i.jsx(bl,{})}]}),i.jsx(kl,{isModalOpen:a,handleModalClose:B,selectedRow:Q,fetchAlertLogs:()=>{},alertStatusList:m,alertStatusLoading:g,initialTab:u,sourceTab:$})]})}function bl(){const[t,e]=f.useState([]),[s,n]=f.useState([]),[r,a]=f.useState([]),[o,l]=f.useState([]),{rules:c}=Ee();return f.useEffect(()=>{let u=!0;return(async()=>{try{const h=await c.getRules();if(!u)return;l(Array.isArray(h)?h:[]);const m=(h||[]).map((g,y)=>({RuleId:g.ruleId||g.ruleName||String(y),Name:g.ruleName||g.Name||"-",Description:g.ruleDesc||g.Description||"",SeverityId:0}));e(m);try{const g=await c.getLookups(),y=Array.isArray(g?.userRoles)?g.userRoles.map(N=>({userRoleId:N.userRoleId??N.id,userRoleName:N.userRoleName??N.name})):[];n(y),a(Array.isArray(g?.severities)?g.severities:[])}catch{}}catch{}})(),()=>{u=!1}},[]),i.jsx(Xr,{severities:r,rules:t,userRoles:s,rawRules:o})}function na(t=1){const{alerts:e}=Ee(),s=ct.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 Il(t){const[e,s]=f.useState(1),{alerts:n,loading:r,refetch:a}=na(e);return i.jsx(Gs,{alerts:n,loading:r,columns:t.columns,onRefetch:a,onPageChange:s})}function Ml({tenant:t,apiDomain:e,rulesDomain:s,headers:n,timeZone:r,userManagementDomain:a,alerts:o,loading:l,columns:c}){const[u]=f.useState(()=>new ct.QueryClient),h=f.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return i.jsx(ct.QueryClientProvider,{client:u,children:i.jsx(qn,{tenant:t,override:h,timeZone:r,userManagementDomain:a,children:Array.isArray(o)?i.jsx(Gs,{alerts:o,loading:!!l,columns:c}):i.jsx(Il,{columns:c})})})}function El(t){const{alerts:e}=Ee(),s=ct.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 Ol=[{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=Ml;exports.AlertsTable=Us;exports.ApiProvider=qn;exports.ArchivedTable=_r;exports.Clock=Jr;exports.DataTable=Gn;exports.MyPreferencesPanel=rl;exports.SettingsPanel=Kr;exports.SettingsTabs=Xr;exports.exampleAlertColumns=Ol;exports.useAlertStatusList=sa;exports.useAlerts=na;exports.useAlertsReport=El;exports.useApi=Ee;exports.useUpdateAlertStatus=Fs;
2
2
  //# sourceMappingURL=index.cjs.map