@ssgc/alert-console 2.6.4 → 2.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +1843 -1810
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),f=require("react"),d=require("antd"),it=require("@ant-design/icons"),we=require("react-toastify"),ot=require("@tanstack/react-query"),da="#FF3B30",ma="#FF9500",fa="#FFCC00",ha="#34C759",Rt={critical:da,high:ma,medium:fa,low:ha},en={Critical:Rt.critical,High:Rt.high,Medium:Rt.medium,Low:Rt.low};function ya(t){return en[t]||en.Low}function tn(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 sn(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 zn="",ga=zn,pa="",Sa="",xa="",wa="",nn={snl:{alerts:zn,rules:ga},schools:{alerts:pa,rules:Sa},transit:{alerts:xa,rules:wa}};function Ie(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function va(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Lt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Ee(t,e){const s={...e.headers,...va()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Ta(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=Ie(t.baseUrl,"/api/Alert"),n=await Ee(s,{method:"GET",headers:e});return Array.isArray(n)?n:[]},async getAlertStatusList(){const s=Ie(t.baseUrl,"/api/Alert/AlertStatusList"),n=await Ee(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getAlertsReport(s){const n=Ie(t.baseUrl,"/Alerts/GetAlertsReport"),r=Lt(n,s),a=await Ee(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Ie(t.baseUrl,"/api/Alert/status");return Ee(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=Ie(t.baseUrl,"/api/Alert/GetAdminSettings"),n=await Ee(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("userId"in n)return n}return null},async setAdminSettings(s){const n=Ie(t.baseUrl,"/api/Alert/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Ee(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Ie(t.baseUrl,"/api/Alert/GetPreferenceSettings"),n=await Ee(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=Ie(t.baseUrl,"/api/Alert/SetPreferenceSettings"),r=await Ee(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,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=Ie(t.baseUrl,"/api/Alert/GetNotifications"),r=Lt(n,{alertId:s}),a=await Ee(r,{method:"GET",headers:e});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]},async notifyFamilyMembers(s){const n=Ie(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=Lt(n,{alertId:s});return Ee(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const a=Ie(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),o=Lt(a,{alertId:s,isEmail:n,isSMS:r});return Ee(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Ie(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Ee(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Ie(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Ee(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null}}}function rn(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Aa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Ut(t,e){const s={...e.headers,...Aa()},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 Na(t){const e={"Content-Type":"application/json",...t.headers||{}},s=rn(t.baseUrl,"/api/Rules"),n=rn(t.baseUrl,"/api/Rules/lookups");return{async getRules(){const r=await Ut(s,{method:"GET",headers:e});return Array.isArray(r)?r:[]},async setEscalationSettings(r){return Ut(s,{method:"POST",headers:e,body:JSON.stringify(r??{})})},async getLookups(){return Ut(n,{method:"GET",headers:e})},async updateRule(r,a){const o=`${s}/${r}`;return Ut(o,{method:"PUT",headers:e,body:JSON.stringify(a??{})})}}}function ba(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ht={exports:{}},ka=Ht.exports,an;function Ia(){return an||(an=1,(function(t,e){(function(s,n){t.exports=n()})(ka,(function(){var s=1e3,n=6e4,r=36e5,a="millisecond",o="second",l="minute",c="hour",u="day",h="week",m="month",p="quarter",y="year",v="date",E="Invalid Date",C=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,_=/\[([^\]]+)]|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,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(j){var x=["th","st","nd","rd"],S=j%100;return"["+j+(x[(S-20)%10]||x[S]||x[0])+"]"}},K=function(j,x,S){var k=String(j);return!k||k.length>=x?j:""+Array(x+1-k.length).join(S)+j},b={s:K,z:function(j){var x=-j.utcOffset(),S=Math.abs(x),k=Math.floor(S/60),w=S%60;return(x<=0?"+":"-")+K(k,2,"0")+":"+K(w,2,"0")},m:function j(x,S){if(x.date()<S.date())return-j(S,x);var k=12*(S.year()-x.year())+(S.month()-x.month()),w=x.clone().add(k,m),L=S-w<0,T=x.clone().add(k+(L?-1:1),m);return+(-(k+(S-w)/(L?w-T:T-w))||0)},a:function(j){return j<0?Math.ceil(j)||0:Math.floor(j)},p:function(j){return{M:m,y,w:h,d:u,D:v,h:c,m:l,s:o,ms:a,Q:p}[j]||String(j||"").toLowerCase().replace(/s$/,"")},u:function(j){return j===void 0}},D="en",V={};V[D]=G;var R="$isDayjsObject",z=function(j){return j instanceof he||!(!j||!j[R])},g=function j(x,S,k){var w;if(!x)return D;if(typeof x=="string"){var L=x.toLowerCase();V[L]&&(w=L),S&&(V[L]=S,w=L);var T=x.split("-");if(!w&&T.length>1)return j(T[0])}else{var I=x.name;V[I]=x,w=I}return!k&&w&&(D=w),w||!k&&D},N=function(j,x){if(z(j))return j.clone();var S=typeof x=="object"?x:{};return S.date=j,S.args=arguments,new he(S)},M=b;M.l=g,M.i=z,M.w=function(j,x){return N(j,{locale:x.$L,utc:x.$u,x:x.$x,$offset:x.$offset})};var he=(function(){function j(S){this.$L=g(S.locale,null,!0),this.parse(S),this.$x=this.$x||S.x||{},this[R]=!0}var x=j.prototype;return x.parse=function(S){this.$d=(function(k){var w=k.date,L=k.utc;if(w===null)return new Date(NaN);if(M.u(w))return new Date;if(w instanceof Date)return new Date(w);if(typeof w=="string"&&!/Z$/i.test(w)){var T=w.match(C);if(T){var I=T[2]-1||0,P=(T[7]||"0").substring(0,3);return L?new Date(Date.UTC(T[1],I,T[3]||1,T[4]||0,T[5]||0,T[6]||0,P)):new Date(T[1],I,T[3]||1,T[4]||0,T[5]||0,T[6]||0,P)}}return new Date(w)})(S),this.init()},x.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()},x.$utils=function(){return M},x.isValid=function(){return this.$d.toString()!==E},x.isSame=function(S,k){var w=N(S);return this.startOf(k)<=w&&w<=this.endOf(k)},x.isAfter=function(S,k){return N(S)<this.startOf(k)},x.isBefore=function(S,k){return this.endOf(k)<N(S)},x.$g=function(S,k,w){return M.u(S)?this[k]:this.set(w,S)},x.unix=function(){return Math.floor(this.valueOf()/1e3)},x.valueOf=function(){return this.$d.getTime()},x.startOf=function(S,k){var w=this,L=!!M.u(k)||k,T=M.p(S),I=function(ce,ue){var xe=M.w(w.$u?Date.UTC(w.$y,ue,ce):new Date(w.$y,ue,ce),w);return L?xe:xe.endOf(u)},P=function(ce,ue){return M.w(w.toDate()[ce].apply(w.toDate("s"),(L?[0,0,0,0]:[23,59,59,999]).slice(ue)),w)},W=this.$W,Z=this.$M,H=this.$D,X="set"+(this.$u?"UTC":"");switch(T){case y:return L?I(1,0):I(31,11);case m:return L?I(1,Z):I(0,Z+1);case h:var le=this.$locale().weekStart||0,Se=(W<le?W+7:W)-le;return I(L?H-Se:H+(6-Se),Z);case u:case v:return P(X+"Hours",0);case c:return P(X+"Minutes",1);case l:return P(X+"Seconds",2);case o:return P(X+"Milliseconds",3);default:return this.clone()}},x.endOf=function(S){return this.startOf(S,!1)},x.$set=function(S,k){var w,L=M.p(S),T="set"+(this.$u?"UTC":""),I=(w={},w[u]=T+"Date",w[v]=T+"Date",w[m]=T+"Month",w[y]=T+"FullYear",w[c]=T+"Hours",w[l]=T+"Minutes",w[o]=T+"Seconds",w[a]=T+"Milliseconds",w)[L],P=L===u?this.$D+(k-this.$W):k;if(L===m||L===y){var W=this.clone().set(v,1);W.$d[I](P),W.init(),this.$d=W.set(v,Math.min(this.$D,W.daysInMonth())).$d}else I&&this.$d[I](P);return this.init(),this},x.set=function(S,k){return this.clone().$set(S,k)},x.get=function(S){return this[M.p(S)]()},x.add=function(S,k){var w,L=this;S=Number(S);var T=M.p(k),I=function(Z){var H=N(L);return M.w(H.date(H.date()+Math.round(Z*S)),L)};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 P=(w={},w[l]=n,w[c]=r,w[o]=s,w)[T]||1,W=this.$d.getTime()+S*P;return M.w(W,this)},x.subtract=function(S,k){return this.add(-1*S,k)},x.format=function(S){var k=this,w=this.$locale();if(!this.isValid())return w.invalidDate||E;var L=S||"YYYY-MM-DDTHH:mm:ssZ",T=M.z(this),I=this.$H,P=this.$m,W=this.$M,Z=w.weekdays,H=w.months,X=w.meridiem,le=function(ue,xe,Ae,je){return ue&&(ue[xe]||ue(k,L))||Ae[xe].slice(0,je)},Se=function(ue){return M.s(I%12||12,ue,"0")},ce=X||function(ue,xe,Ae){var je=ue<12?"AM":"PM";return Ae?je.toLowerCase():je};return L.replace(_,(function(ue,xe){return xe||(function(Ae){switch(Ae){case"YY":return String(k.$y).slice(-2);case"YYYY":return M.s(k.$y,4,"0");case"M":return W+1;case"MM":return M.s(W+1,2,"0");case"MMM":return le(w.monthsShort,W,H,3);case"MMMM":return le(H,W);case"D":return k.$D;case"DD":return M.s(k.$D,2,"0");case"d":return String(k.$W);case"dd":return le(w.weekdaysMin,k.$W,Z,2);case"ddd":return le(w.weekdaysShort,k.$W,Z,3);case"dddd":return Z[k.$W];case"H":return String(I);case"HH":return M.s(I,2,"0");case"h":return Se(1);case"hh":return Se(2);case"a":return ce(I,P,!0);case"A":return ce(I,P,!1);case"m":return String(P);case"mm":return M.s(P,2,"0");case"s":return String(k.$s);case"ss":return M.s(k.$s,2,"0");case"SSS":return M.s(k.$ms,3,"0");case"Z":return T}return null})(ue)||T.replace(":","")}))},x.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},x.diff=function(S,k,w){var L,T=this,I=M.p(k),P=N(S),W=(P.utcOffset()-this.utcOffset())*n,Z=this-P,H=function(){return M.m(T,P)};switch(I){case y:L=H()/12;break;case m:L=H();break;case p:L=H()/3;break;case h:L=(Z-W)/6048e5;break;case u:L=(Z-W)/864e5;break;case c:L=Z/r;break;case l:L=Z/n;break;case o:L=Z/s;break;default:L=Z}return w?L:M.a(L)},x.daysInMonth=function(){return this.endOf(m).$D},x.$locale=function(){return V[this.$L]},x.locale=function(S,k){if(!S)return this.$L;var w=this.clone(),L=g(S,k,!0);return L&&(w.$L=L),w},x.clone=function(){return M.w(this.$d,this)},x.toDate=function(){return new Date(this.valueOf())},x.toJSON=function(){return this.isValid()?this.toISOString():null},x.toISOString=function(){return this.$d.toISOString()},x.toString=function(){return this.$d.toUTCString()},j})(),oe=he.prototype;return N.prototype=oe,[["$ms",a],["$s",o],["$m",l],["$H",c],["$W",u],["$M",m],["$y",y],["$D",v]].forEach((function(j){oe[j[1]]=function(x){return this.$g(x,j[0],j[1])}})),N.extend=function(j,x){return j.$i||(j(x,he,N),j.$i=!0),N},N.locale=g,N.isDayjs=z,N.unix=function(j){return N(1e3*j)},N.en=V[D],N.Ls=V,N.p={},N}))})(Ht)),Ht.exports}var Ea=Ia();const Ma=ba(Ea);function Hn(t){if(!t)return"By Severity";const e=t.trim().toLowerCase();return e.includes("created")?"By Created Date":e.includes("updated")||e.includes("modified")?"By Updated Date":"By Severity"}function qn(t){if(!t||typeof t!="string")return{hours:0,minutes:0,seconds:0};const e=t.split(":").map(a=>parseInt(a,10)),s=Number.isFinite(e[0])?e[0]:0,n=Number.isFinite(e[1])?e[1]:0,r=Number.isFinite(e[2])?e[2]:0;return{hours:s,minutes:n,seconds:r}}function on(t){const{hours:e,minutes:s,seconds:n}=qn(t);return Ma().hour(e).minute(s).second(n).millisecond(0)}function Ce(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Oa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function ln(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,...Oa()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.Message||`HTTP ${n.status}`;throw new Error(o)}return a}const de=(...t)=>t.find(e=>e!=null);function Nt(t,e,s={}){const n={};for(const r of e){const a=s[r]??r.charAt(0).toUpperCase()+r.slice(1);n[r]=t?.[a]??t?.[r]}return n}function ja(t){return Array.isArray(t)?t.map(e=>Nt(e,["alertLogId","alertId","status","description","actionNotes","createdDate","createdBy","modifiedDate","modifiedBy"])):t}function Ca(t){return{id:String(de(t?.AlertId,t?.alertId)??""),alertNumber:de(t?.AlertNumber,t?.alertNumber),priority:de(t?.Priority,t?.priority,"Low"),timestamp:de(t?.UpdatedUtc,t?.timestamp,""),statusType:de(t?.Status,t?.statusType,""),description:de(t?.Description,t?.description,""),eventName:de(t?.EventName,t?.eventName),ruleName:de(t?.RuleName,t?.ruleName),spaceName:de(t?.SpaceName,t?.spaceName),assignTeam:de(t?.AssignTeam,t?.assignTeam),cameraName:de(t?.CameraName,t?.cameraName),type:de(t?.Type,t?.type),mediaDetails:de(t?.MediaDetails,t?.mediaDetails),additionalMedia:de(t?.AdditionalMedia,t?.additionalMedia),timeElapsed:de(t?.TimeElapsed,t?.timeElapsed),timeRemaining:de(t?.TimeRemaining,t?.timeRemaining),anomalyName:de(t?.AnomalyName,t?.anomalyName),alertDetails:de(t?.AlertDetails,t?.alertDetails),statusHistory:ja(de(t?.StatusHistory,t?.statusHistory)),isEmailSent:de(t?.IsEmailSent,t?.isEmailSent),isSMSSent:de(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:de(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function Da(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=Ce(t.baseUrl,"/api/detectionpolicy/alerts?customerId=99e5c8b5-b9d4-4d35-8885-7f121c532664"),n=await De(s,{method:"GET",headers:e});return Array.isArray(n?.Items)?(n?.Items).map(Ca):[]},async getAlertStatusList(){const s=Ce(t.baseUrl,"/api/detectionpolicy/alerts/StatusList"),n=await De(s,{method:"GET",headers:e});return(Array.isArray(n)?n:[]).map(a=>Nt(a,["alertStatusId","value","statusName"]))},async getAlertsReport(s){const n=Ce(t.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),r=ln(n,s),a=await De(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Ce(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=Ce(t.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),n=await De(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n.Data??n;if(r&&typeof r=="object")return Nt(r,["userId","isAdminSetting","sortBy"],{sortBy:"SortOption"})}return null},async setAdminSettings(s){const n=Ce(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=Ce(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=Ce(t.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),r=u=>{const{hours:h,minutes:m,seconds:p}=qn(u);return(h*3600+m*60+p)*1e7},a={Settings:{UserId:0,AnomalyIds:Array.isArray(s?.anomalyIds)?s.anomalyIds.map(u=>String(u)):[],DoNotDisturbStart:{Ticks:r(s?.doNotDisturbStart)},DoNotDisturbEnd:{Ticks:r(s?.doNotDisturbEnd)},InApp:!!s?.inApp,SMS:!!s?.sms,Email:!!s?.email,SortBy:s?.sortBy??""}},o=await 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=Ce(t.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),r=ln(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=>Nt(l,["alertNotificationSentId","alertId","notificationType","receipientName","receipentPhoneNumber","messageSID","messageStatus","receipientEmail","notificationReceipientType","sentAt"]))},async getTimeZoneMasters(){const s=Ce(t.baseUrl,"/api/TimeZoneMaster"),n=await De(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n.Data:[]).map(a=>Nt(a,["timeZoneUniqueId","ianaTimeZoneId","timeZoneName","offset"]))},async getMyAppPreferences(){const s=Ce(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=Ce(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 Ra(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function He(t,e){const s={...e.headers,...Ra()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function La(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/api/detectionpolicy/rules",t.baseUrl).toString();return{async getRules(){const n=await He(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n?.Data:[]).map(a=>({...a,ruleId:a.ruleId??a.RuleId,ruleName:a.ruleName??a.RuleName??a.Name,escalationSettings:a.escalationSettings??a.EscalationSettings}))},async setEscalationSettings(n){return He(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=g=>new URL(g,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[He(n("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:e}),He(n("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:e}),He(n("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:e}),He(n("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:e}),He(n("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:e}),He(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,l,c,u,h,m]=await Promise.allSettled(a),p=g=>g.status==="fulfilled"&&Array.isArray(g.value)?g.value:[],y=p(o),v=p(l),E=p(c),C=p(u),_=p(h),G=m.status==="fulfilled"?m.value:null;let K=[];Array.isArray(G)?K=G:Array.isArray(G?.Data)?K=G.Data:Array.isArray(G?.data)&&(K=G.data);const b=y.map(g=>({actionTypeId:Number(g?.ActionTypeId),name:g?.DisplayName??g?.Name??""})),D=v.map(g=>({recordId:g?.AnomalyId,anomalyName:g?.DisplayName??g?.Name??""})),V=E.map(g=>({thirdPartyId:Number(g?.ThirdPartyId),thirdPartyName:g?.ThirdPartyName??g?.Name??""})),R=K.map(g=>({userRoleId:g.UserRoleId??g.userRoleId??g.Id??g.id??0,userRoleName:g.UserRoleName??g.userRoleName??g.Name??g.name??""})),z={actionTypes:b,anomalies:D,thirdParties:V};return C.length&&(z.severities=C),_.length&&(z.scheduleTypes=_),R.length&&(z.userRoles=R),z},async updateRule(n,r){const a=`${s}/${n}`,{escalationSettings:o,...l}=r??{};return He(a,{method:"PUT",headers:e,body:JSON.stringify({...l,CustomerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",Version:{DeDupWindowSeconds:0,IncludeSubjectInHash:!0},EscalationSettings:o??{}})})}}}function Ua(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Ke(t,e){const s={...e.headers,...Ua()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Fa(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/list-rule",t.baseUrl).toString();return{async getRules(){const n=await Ke(s,{method:"POST",headers:e,body:JSON.stringify({command:"get-all"})});return(Array.isArray(n?.data)?n.data:[]).map(a=>({...a,ruleId:a.RuleId??a.ruleId,ruleName:a.RuleName??a.ruleName,ruleDesc:a.RuleDesc??a.ruleDesc??null}))},async setEscalationSettings(n){return Ke(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=R=>new URL(R,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[Ke(n("/api/ActionTypeMaster/GetAll"),{method:"GET",headers:e}),Ke(n("/api/anomaly/anomaly-list"),{method:"POST",headers:e,body:JSON.stringify({RuleLevel:1})}),Ke(n("/api/Lookup/ThirdParties"),{method:"GET",headers:e}),Ke(n("/api/anomaly/severity-list"),{method:"GET",headers:e}),Ke(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,l,c,u,h]=await Promise.allSettled(a),m=R=>{if(R.status!=="fulfilled")return[];const z=R.value;return Array.isArray(z)?z:Array.isArray(z?.data)?z.data:[]},p=m(o),y=m(l),v=m(c),E=m(u),C=h.status==="fulfilled"?h.value:null,_=p.map(R=>({actionTypeId:R?.ActionTypeUniqueId,name:R?.Name??""})),G=y.map(R=>({recordId:R?.AnomalyId,anomalyName:R?.DisplayName??R?.Name??""})),K=v.map(R=>({thirdPartyId:Number(R?.ThirdPartyId),thirdPartyName:R?.ThirdPartyName??R?.Name??""}));let b=[];Array.isArray(C)?b=C:Array.isArray(C?.Data)?b=C.Data:Array.isArray(C?.data)&&(b=C.data);const D=b.map(R=>({userRoleId:R.userRoleId??0,userRoleName:R.userRoleName??""})),V={actionTypes:_,anomalies:G,thirdParties:K};return E.length&&(V.severities=E.map(R=>({SeverityId:R.SeverityId,DisplayName:R.SeverityName??R.DisplayName??""}))),D.length&&(V.userRoles=D),V},async updateRule(n,r){const a=new URL("/update-rule",t.baseUrl).toString(),{escalationSettings:o,ruleId:l,ruleName:c,ruleDesc:u,...h}=r??{},m=o??{},p=(m.escalationSettingsActionTypeIds??[]).filter(v=>v!=null&&!Number.isNaN(v)),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:p,ThirdPartyIds:m.thirdPartyId??[],HumanLoop:m.humanLoop??!1};return Ke(a,{method:"POST",headers:e,body:JSON.stringify({...h,RuleId:l??h.RuleId??n,RuleName:c??h.RuleName,RuleDesc:u??h.RuleDesc??null,ActionTypeUniqueIdList:p,EscalationSettings:y})})}}}function Re(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function $a(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Ft(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Le(t,e){const s={...e.headers,...$a()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Pa(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Re(t.baseUrl,"/api/Alerts"),r=Ft(n,{pageSize:s?.pageSize??10,pageNumber:s?.pageNumber??1}),a=await Le(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async getAlertStatusList(){const s=Re(t.baseUrl,"/api/Alerts/GetAlertStatus"),n=await Le(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getAlertsReport(s){const n=Re(t.baseUrl,"/Alerts/GetAlertsReport"),r=Ft(n,s),a=await Le(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Re(t.baseUrl,"/api/Alerts/UpdateAlertLog"),r={alertId:s.alertId,action:s.status,notes:s.notes};return Le(n,{method:"PUT",headers:e,body:JSON.stringify(r??{})})},async getAdminSettings(){const s=Re(t.baseUrl,"/api/Alerts/GetAdminSettings"),n=await Le(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("userId"in n)return n}return null},async setAdminSettings(s){const n=Re(t.baseUrl,"/api/Alerts/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Le(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Re(t.baseUrl,"/api/Alerts/GetPreferenceSettings"),n=await Le(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=Re(t.baseUrl,"/api/Alerts/SetPreferenceSettings"),r=await Le(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,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=Ft(n,{alertId:s}),a=await Le(r,{method:"GET",headers:e});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]},async sendSMSorEmailNotifications(s,n,r){const a=Re(t.baseUrl,"/api/Alerts/SendSMSorEmailNotifications"),o=Ft(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 Gn=f.createContext(null);function Yn({tenant:t="snl",override:e,timeZone:s,userManagementDomain:n,children:r}){const a=f.useMemo(()=>{const l=e?.alertsBaseUrl?.trim()||nn[t]?.alerts||"";let c=e?.rulesBaseUrl?.trim()||nn[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:()=>Da(l),transit:()=>Pa(l),snl:()=>Ta(l)},h={schools:()=>La({...c,userManagementBaseUrl:a.userManagementDomain}),transit:()=>Fa({...c,userManagementBaseUrl:a.userManagementDomain}),snl:()=>Na({baseUrl:a.alertsBaseUrl,headers:a.headers})};return{config:a,alerts:u[a.tenant](),rules:h[a.tenant]()}},[a]);return i.jsx(Gn.Provider,{value:o,children:r})}function Oe(){const t=f.useContext(Gn);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}const Wa={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Va={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Us=6,Fs=7;function cn(t,e,s){const n=t===Us,r=t===Fs,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 Ba(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 Za(t){const e=new Set;(t||[]).forEach(n=>{const r=n.spaceName;typeof r=="string"&&r.trim().length>0&&e.add(r.trim())});const s=Array.from(e).map(n=>({label:n,value:n}));return[{label:"All",value:"All"},...s]}function ms(t,e){return`${t}-${e?"email":"sms"}`}function $t(t){return t===Us||t===Fs}function es({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 za=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function Ha({value:t,onChange:e,options:s}){return i.jsx(es,{className:"w-[140px]",value:t,onChange:e,options:s||za})}const qa=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function Ga({value:t,onChange:e,options:s}){return i.jsx(es,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||qa})}function Ya({value:t,onChange:e,options:s}){return i.jsx(es,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const _a=[{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 Ja({value:t,onChange:e,options:s}){return i.jsx(es,{className:"w-[130px]",value:t,onChange:e,options:s||_a})}function _n({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 $s({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,p]=f.useState("All"),[y,v]=f.useState("All"),[E,C]=f.useState("All"),[_,G]=f.useState("All"),[K,b]=f.useState(""),[D,V]=f.useState([{label:"All",value:"All"}]),[R,z]=f.useState(new Set),{rules:g,alerts:N}=Oe(),M={6:{title:"Email",kind:"icon",icon:i.jsx(it.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:i.jsx(it.MessageOutlined,{})}},he=f.useMemo(()=>Ba(t),[t]),oe=f.useMemo(()=>Za(t),[t]);f.useEffect(()=>{let T=!0;return(async()=>{try{const I=await g.getLookups(),W=(Array.isArray(I.thirdParties)?I.thirdParties:[]).map(Z=>({label:Z.thirdPartyName,value:String(Z.thirdPartyId)}));T&&V([{label:"All",value:"All"},...W])}catch(I){console.error("Error loading third party options",I)}})(),()=>{T=!1}},[g]);const j=f.useMemo(()=>(t||[]).some(T=>sn(T).length>0),[t]),x=f.useMemo(()=>(t||[]).filter(T=>{const I=m==="All"||T.priority===m,P=`${T.id} ${T.description} ${T.statusType}`.toLowerCase(),W=!K||P.includes(K.toLowerCase()),Z=y==="All"||(T.anomalyName||"").toLowerCase()===y.toLowerCase(),H=E==="All"||(T.spaceName||"").toLowerCase()===E.toLowerCase(),X=!j||_==="All"||sn(T).includes(Number(_)),le=!h||!["completed","false positive"].includes(String(T.statusType||"").toLowerCase());return I&&W&&Z&&H&&X&&le}),[t,m,K,y,E,_,j,h]),S=he,k=a?.length?a:oe,w=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:T=>i.jsx(d.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Va[T]}`,backgroundColor:Wa[T]},children:T})},{title:"Tracker",key:"tracker",width:140,render:(T,I)=>i.jsx("a",{onClick:P=>{P.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 P=async(je,_e)=>{const vt=ms(I.id,je);z(ye=>new Set(ye).add(vt));try{const ye=await N.sendSMSorEmailNotifications?.(I.id,je,_e);ye?.responseStatus||ye?.Success||ye?.success?(we.toast.success(ye?.message||ye.data||(je?"Email sent successfully":"SMS sent successfully")),c?.()):we.toast.error(ye?.message||ye?.data||ye?.errorMessage||"Failed to send notification")}catch(ye){we.toast.error(ye?.message||"Failed to send notification")}finally{z(ye=>{const ct=new Set(ye);return ct.delete(vt),ct})}},W=Us,Z=Fs,H=M[W],X=M[Z],le=cn(W,I,H?.title),Se=cn(Z,I,X?.title),ce=ms(I.id,!0),ue=ms(I.id,!1),xe=$t(W)&&R.has(ce),Ae=$t(Z)&&R.has(ue);return i.jsxs(d.Space,{size:"middle",children:[i.jsx(d.Tooltip,{title:le.tooltipTitle,children:i.jsx(d.Button,{size:"small",disabled:le.isDisabled,loading:xe,onClick:$t(W)?()=>P(!0,!1):void 0,icon:!xe&&H?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:le.buttonText})},String(W)),i.jsx(d.Tooltip,{title:Se.tooltipTitle,children:i.jsx(d.Button,{size:"small",disabled:Se.isDisabled,loading:Ae,onClick:$t(Z)?()=>P(!1,!0):void 0,icon:!Ae&&X?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:Se.buttonText})},String(Z))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(T,I)=>{const P=I?.timeElapsed,W=I?.timeRemaining,Z=P?tn(P):0,H=W?tn(W):0,X=Math.round(Z/(Z+H)*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:P??"-"})]}),i.jsx(d.Progress,{percent:X,showInfo:!1,size:"small",strokeColor:ya(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:W??"-"})]})]})}},{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:P=>{P.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})]})}],L=n&&n.length?n:w;return i.jsx("div",{children:i.jsx(_n,{rowKey:"id",data:x,columns:L,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(Ha,{value:m,onChange:p,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(Ga,{value:y,onChange:v,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(Ya,{value:E,onChange:C,options:k})]})}),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(Ja,{value:_,onChange:G,options:D})]})}),i.jsx(d.Col,{flex:"auto"}),i.jsx(d.Col,{flex:"none",children:i.jsx(d.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:b,onChange:T=>b(T.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}function Ps(){const{alerts:t}=Oe(),e=ot.useQueryClient();return ot.useMutation({mutationFn:s=>t.updateAlertStatus(s),onSuccess:()=>{e.invalidateQueries({queryKey:["alerts","list"]}),e.invalidateQueries({queryKey:["alerts","report"]})}})}class lt extends Error{}class Qa extends lt{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class Ka extends lt{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class Xa extends lt{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class ft extends lt{}class Jn extends lt{constructor(e){super(`Invalid unit ${e}`)}}class ve extends lt{}class Xe extends lt{constructor(){super("Zone is an abstract class")}}const A="numeric",Be="short",Me="long",_t={year:A,month:A,day:A},Qn={year:A,month:Be,day:A},ei={year:A,month:Be,day:A,weekday:Be},Kn={year:A,month:Me,day:A},Xn={year:A,month:Me,day:A,weekday:Me},er={hour:A,minute:A},tr={hour:A,minute:A,second:A},sr={hour:A,minute:A,second:A,timeZoneName:Be},nr={hour:A,minute:A,second:A,timeZoneName:Me},rr={hour:A,minute:A,hourCycle:"h23"},ar={hour:A,minute:A,second:A,hourCycle:"h23"},ir={hour:A,minute:A,second:A,hourCycle:"h23",timeZoneName:Be},or={hour:A,minute:A,second:A,hourCycle:"h23",timeZoneName:Me},lr={year:A,month:A,day:A,hour:A,minute:A},cr={year:A,month:A,day:A,hour:A,minute:A,second:A},ur={year:A,month:Be,day:A,hour:A,minute:A},dr={year:A,month:Be,day:A,hour:A,minute:A,second:A},ti={year:A,month:Be,day:A,weekday:Be,hour:A,minute:A},mr={year:A,month:Me,day:A,hour:A,minute:A,timeZoneName:Be},fr={year:A,month:Me,day:A,hour:A,minute:A,second:A,timeZoneName:Be},hr={year:A,month:Me,day:A,weekday:Me,hour:A,minute:A,timeZoneName:Me},yr={year:A,month:Me,day:A,weekday:Me,hour:A,minute:A,second:A,timeZoneName:Me};class Ot{get type(){throw new Xe}get name(){throw new Xe}get ianaName(){return this.name}get isUniversal(){throw new Xe}offsetName(e,s){throw new Xe}formatOffset(e,s){throw new Xe}offset(e){throw new Xe}equals(e){throw new Xe}get isValid(){throw new Xe}}let fs=null;class ts extends Ot{static get instance(){return fs===null&&(fs=new ts),fs}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return kr(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 Ns=new Map;function si(t){let e=Ns.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"}),Ns.set(t,e)),e}const ni={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function ri(t,e){const s=t.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(s),[,r,a,o,l,c,u,h]=n;return[o,r,a,l,c,u,h]}function ai(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:a,value:o}=s[r],l=ni[a];a==="era"?n[l]=o:$(l)||(n[l]=parseInt(o,10))}return n}const hs=new Map;class Ye extends Ot{static create(e){let s=hs.get(e);return s===void 0&&hs.set(e,s=new Ye(e)),s}static resetCache(){hs.clear(),Ns.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 kr(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=si(this.name);let[r,a,o,l,c,u,h]=n.formatToParts?ai(n,s):ri(n,s);l==="BC"&&(r=-Math.abs(r)+1);const p=ns({year:r,month:a,day:o,hour:c===24?0:c,minute:u,second:h,millisecond:0});let y=+s;const v=y%1e3;return y-=v>=0?v:1e3+v,(p-y)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let un={};function ii(t,e={}){const s=JSON.stringify([t,e]);let n=un[s];return n||(n=new Intl.ListFormat(t,e),un[s]=n),n}const bs=new Map;function ks(t,e={}){const s=JSON.stringify([t,e]);let n=bs.get(s);return n===void 0&&(n=new Intl.DateTimeFormat(t,e),bs.set(s,n)),n}const Is=new Map;function oi(t,e={}){const s=JSON.stringify([t,e]);let n=Is.get(s);return n===void 0&&(n=new Intl.NumberFormat(t,e),Is.set(s,n)),n}const Es=new Map;function li(t,e={}){const{base:s,...n}=e,r=JSON.stringify([t,n]);let a=Es.get(r);return a===void 0&&(a=new Intl.RelativeTimeFormat(t,e),Es.set(r,a)),a}let bt=null;function ci(){return bt||(bt=new Intl.DateTimeFormat().resolvedOptions().locale,bt)}const Ms=new Map;function gr(t){let e=Ms.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),Ms.set(t,e)),e}const Os=new Map;function ui(t){let e=Os.get(t);if(!e){const s=new Intl.Locale(t);e="getWeekInfo"in s?s.getWeekInfo():s.weekInfo,"minimalDays"in e||(e={...pr,...e}),Os.set(t,e)}return e}function di(t){const e=t.indexOf("-x-");e!==-1&&(t=t.substring(0,e));const s=t.indexOf("-u-");if(s===-1)return[t];{let n,r;try{n=ks(t).resolvedOptions(),r=t}catch{const c=t.substring(0,s);n=ks(c).resolvedOptions(),r=c}const{numberingSystem:a,calendar:o}=n;return[r,a,o]}}function mi(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function fi(t){const e=[];for(let s=1;s<=12;s++){const n=F.utc(2009,s,1);e.push(t(n))}return e}function hi(t){const e=[];for(let s=1;s<=7;s++){const n=F.utc(2016,11,13+s);e.push(t(n))}return e}function Pt(t,e,s,n){const r=t.listingMode();return r==="error"?null:r==="en"?s(e):n(e)}function yi(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||gr(t.locale).numberingSystem==="latn"}class gi{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=oi(e,l)}}format(e){if(this.inf){const s=this.floor?Math.floor(e):e;return this.inf.format(s)}else{const s=this.floor?Math.floor(e):zs(e,3);return pe(s,this.padTo)}}}class pi{constructor(e,s,n){this.opts=n,this.originalZone=void 0;let r;if(this.opts.timeZone)this.dt=e;else if(e.zone.type==="fixed"){const o=-1*(e.offset/60),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 a={...this.opts};a.timeZone=a.timeZone||r,this.dtf=ks(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 Si{constructor(e,s,n){this.opts={style:"long",...n},!s&&Nr()&&(this.rtf=li(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):Wi(s,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,s){return this.rtf?this.rtf.formatToParts(e,s):[]}}const pr={firstDay:1,minimalDays:4,weekend:[6,7]};class se{static fromOpts(e){return se.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":ci()),c=s||fe.defaultNumberingSystem,u=n||fe.defaultOutputCalendar,h=Cs(r)||fe.defaultWeekSettings;return new se(l,c,u,h,o)}static resetCache(){bt=null,bs.clear(),Is.clear(),Es.clear(),Ms.clear(),Os.clear()}static fromObject({locale:e,numberingSystem:s,outputCalendar:n,weekSettings:r}={}){return se.create(e,s,n,r)}constructor(e,s,n,r,a){const[o,l,c]=di(e);this.locale=o,this.numberingSystem=s||l||null,this.outputCalendar=n||c||null,this.weekSettings=r,this.intl=mi(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=yi(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:se.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,Cs(e.weekSettings)||this.weekSettings,e.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,s=!1){return Pt(this,e,Mr,()=>{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]=fi(o)}return this.monthsCache[a][e]})}weekdays(e,s=!1){return Pt(this,e,Cr,()=>{const n=s?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},r=s?"format":"standalone";return this.weekdaysCache[r][e]||(this.weekdaysCache[r][e]=hi(a=>this.extract(a,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return Pt(this,void 0,()=>Dr,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[F.utc(2016,11,13,9),F.utc(2016,11,13,19)].map(s=>this.extract(s,e,"dayperiod"))}return this.meridiemCache})}eras(e){return Pt(this,e,Rr,()=>{const s={era:e};return this.eraCache[e]||(this.eraCache[e]=[F.utc(-40,1,1),F.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 gi(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new pi(e,this.intl,s)}relFormatter(e={}){return new Si(this.intl,this.isEnglish(),e)}listFormatter(e={}){return ii(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||gr(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:br()?ui(this.locale):pr}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let ys=null;class be extends Ot{static get utcInstance(){return ys===null&&(ys=new be(0)),ys}static instance(e){return e===0?be.utcInstance:new be(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new be(rs(s[1],s[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Et(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Et(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,s){return Et(this.fixed,s)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type==="fixed"&&e.fixed===this.fixed}get isValid(){return!0}}class xi extends Ot{constructor(e){super(),this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function tt(t,e){if($(t)||t===null)return e;if(t instanceof Ot)return t;if(bi(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?ts.instance:s==="utc"||s==="gmt"?be.utcInstance:be.parseSpecifier(s)||Ye.create(t)}else return st(t)?be.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new xi(t)}const Ws={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},dn={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]},wi=Ws.hanidec.replace(/[\[|\]]/g,"").split("");function vi(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(Ws.hanidec)!==-1)e+=wi.indexOf(t[s]);else for(const r in dn){const[a,o]=dn[r];n>=a&&n<=o&&(e+=n-a)}}return parseInt(e,10)}else return e}const js=new Map;function Ti(){js.clear()}function Pe({numberingSystem:t},e=""){const s=t||"latn";let n=js.get(s);n===void 0&&(n=new Map,js.set(s,n));let r=n.get(e);return r===void 0&&(r=new RegExp(`${Ws[s]}${e}`),n.set(e,r)),r}let mn=()=>Date.now(),fn="system",hn=null,yn=null,gn=null,pn=60,Sn,xn=null;class fe{static get now(){return mn}static set now(e){mn=e}static set defaultZone(e){fn=e}static get defaultZone(){return tt(fn,ts.instance)}static get defaultLocale(){return hn}static set defaultLocale(e){hn=e}static get defaultNumberingSystem(){return yn}static set defaultNumberingSystem(e){yn=e}static get defaultOutputCalendar(){return gn}static set defaultOutputCalendar(e){gn=e}static get defaultWeekSettings(){return xn}static set defaultWeekSettings(e){xn=Cs(e)}static get twoDigitCutoffYear(){return pn}static set twoDigitCutoffYear(e){pn=e%100}static get throwOnInvalid(){return Sn}static set throwOnInvalid(e){Sn=e}static resetCaches(){se.resetCache(),Ye.resetCache(),F.resetCache(),Ti()}}class Ve{constructor(e,s){this.reason=e,this.explanation=s}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const Sr=[0,31,59,90,120,151,181,212,243,273,304,334],xr=[0,31,60,91,121,152,182,213,244,274,305,335];function Fe(t,e){return new Ve("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function Vs(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 wr(t,e,s){return s+(jt(t)?xr:Sr)[e-1]}function vr(t,e){const s=jt(t)?xr:Sr,n=s.findIndex(a=>a<e),r=e-s[n];return{month:n+1,day:r}}function Bs(t,e){return(t-e+7)%7+1}function Jt(t,e=4,s=1){const{year:n,month:r,day:a}=t,o=wr(n,r,a),l=Bs(Vs(n,r,a),s);let c=Math.floor((o-l+14-e)/7),u;return c<1?(u=n-1,c=Mt(u,e,s)):c>Mt(n,e,s)?(u=n+1,c=1):u=n,{weekYear:u,weekNumber:c,weekday:l,...as(t)}}function wn(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:a}=t,o=Bs(Vs(n,1,e),s),l=ht(n);let c=r*7+a-o-7+e,u;c<1?(u=n-1,c+=ht(u)):c>l?(u=n+1,c-=ht(n)):u=n;const{month:h,day:m}=vr(u,c);return{year:u,month:h,day:m,...as(t)}}function gs(t){const{year:e,month:s,day:n}=t,r=wr(e,s,n);return{year:e,ordinal:r,...as(t)}}function vn(t){const{year:e,ordinal:s}=t,{month:n,day:r}=vr(e,s);return{year:e,month:n,day:r,...as(t)}}function Tn(t,e){if(!$(t.localWeekday)||!$(t.localWeekNumber)||!$(t.localWeekYear)){if(!$(t.weekday)||!$(t.weekNumber)||!$(t.weekYear))throw new ft("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 Ai(t,e=4,s=1){const n=ss(t.weekYear),r=$e(t.weekNumber,1,Mt(t.weekYear,e,s)),a=$e(t.weekday,1,7);return n?r?a?!1:Fe("weekday",t.weekday):Fe("week",t.weekNumber):Fe("weekYear",t.weekYear)}function Ni(t){const e=ss(t.year),s=$e(t.ordinal,1,ht(t.year));return e?s?!1:Fe("ordinal",t.ordinal):Fe("year",t.year)}function Tr(t){const e=ss(t.year),s=$e(t.month,1,12),n=$e(t.day,1,Qt(t.year,t.month));return e?s?n?!1:Fe("day",t.day):Fe("month",t.month):Fe("year",t.year)}function Ar(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 $(t){return typeof t>"u"}function st(t){return typeof t=="number"}function ss(t){return typeof t=="number"&&t%1===0}function bi(t){return typeof t=="string"}function ki(t){return Object.prototype.toString.call(t)==="[object Date]"}function Nr(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function br(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function Ii(t){return Array.isArray(t)?t:[t]}function An(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 Ei(t,e){return e.reduce((s,n)=>(s[n]=t[n],s),{})}function gt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Cs(t){if(t==null)return null;if(typeof t!="object")throw new ve("Week settings must be an object");if(!$e(t.firstDay,1,7)||!$e(t.minimalDays,1,7)||!Array.isArray(t.weekend)||t.weekend.some(e=>!$e(e,1,7)))throw new ve("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function $e(t,e,s){return ss(t)&&t>=e&&t<=s}function Mi(t,e){return t-e*Math.floor(t/e)}function pe(t,e=2){const s=t<0;let n;return s?n="-"+(""+-t).padStart(e,"0"):n=(""+t).padStart(e,"0"),n}function et(t){if(!($(t)||t===null||t===""))return parseInt(t,10)}function nt(t){if(!($(t)||t===null||t===""))return parseFloat(t)}function Zs(t){if(!($(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function zs(t,e,s="round"){const n=10**e;switch(s){case"expand":return t>0?Math.ceil(t*n)/n:Math.floor(t*n)/n;case"trunc":return Math.trunc(t*n)/n;case"round":return Math.round(t*n)/n;case"floor":return Math.floor(t*n)/n;case"ceil":return Math.ceil(t*n)/n;default:throw new RangeError(`Value rounding ${s} is out of range`)}}function jt(t){return t%4===0&&(t%100!==0||t%400===0)}function ht(t){return jt(t)?366:365}function Qt(t,e){const s=Mi(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 ns(t){let e=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second,t.millisecond);return t.year<100&&t.year>=0&&(e=new Date(e),e.setUTCFullYear(t.year,t.month-1,t.day)),+e}function Nn(t,e,s){return-Bs(Vs(t,1,e),s)+e-1}function Mt(t,e=4,s=1){const n=Nn(t,e,s),r=Nn(t+1,e,s);return(ht(t)-n+r)/7}function Ds(t){return t>99?t:t>fe.twoDigitCutoffYear?1900+t:2e3+t}function kr(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 rs(t,e){let s=parseInt(t,10);Number.isNaN(s)&&(s=0);const n=parseInt(e,10)||0,r=s<0||Object.is(s,-0)?-n:n;return s*60+r}function Ir(t){const e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new ve(`Invalid unit value ${t}`);return e}function Kt(t,e){const s={};for(const n in t)if(gt(t,n)){const r=t[n];if(r==null)continue;s[e(n)]=Ir(r)}return s}function Et(t,e){const s=Math.trunc(Math.abs(t/60)),n=Math.trunc(Math.abs(t%60)),r=t>=0?"+":"-";switch(e){case"short":return`${r}${pe(s,2)}:${pe(n,2)}`;case"narrow":return`${r}${s}${n>0?`:${n}`:""}`;case"techie":return`${r}${pe(s,2)}${pe(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function as(t){return Ei(t,["hour","minute","second","millisecond"])}const Oi=["January","February","March","April","May","June","July","August","September","October","November","December"],Er=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ji=["J","F","M","A","M","J","J","A","S","O","N","D"];function Mr(t){switch(t){case"narrow":return[...ji];case"short":return[...Er];case"long":return[...Oi];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 Or=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],jr=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Ci=["M","T","W","T","F","S","S"];function Cr(t){switch(t){case"narrow":return[...Ci];case"short":return[...jr];case"long":return[...Or];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const Dr=["AM","PM"],Di=["Before Christ","Anno Domini"],Ri=["BC","AD"],Li=["B","A"];function Rr(t){switch(t){case"narrow":return[...Li];case"short":return[...Ri];case"long":return[...Di];default:return null}}function Ui(t){return Dr[t.hour<12?0:1]}function Fi(t,e){return Cr(e)[t.weekday-1]}function $i(t,e){return Mr(e)[t.month-1]}function Pi(t,e){return Rr(e)[t.year<0?0:1]}function Wi(t,e,s="always",n=!1){const r={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},a=["hours","minutes","seconds"].indexOf(t)===-1;if(s==="auto"&&a){const m=t==="days";switch(e){case 1:return m?"tomorrow":`next ${r[t][0]}`;case-1:return m?"yesterday":`last ${r[t][0]}`;case 0:return m?"today":`this ${r[t][0]}`}}const o=Object.is(e,-0)||e<0,l=Math.abs(e),c=l===1,u=r[t],h=n?c?u[1]:u[2]||u[1]:c?r[t][0]:t;return o?`${l} ${h} ago`:`in ${l} ${h}`}function bn(t,e){let s="";for(const n of t)n.literal?s+=n.val:s+=e(n.val);return s}const Vi={D:_t,DD:Qn,DDD:Kn,DDDD:Xn,t:er,tt:tr,ttt:sr,tttt:nr,T:rr,TT:ar,TTT:ir,TTTT:or,f:lr,ff:ur,fff:mr,ffff:hr,F:cr,FF:dr,FFF:fr,FFFF:yr};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 Vi[e]}constructor(e,s){this.opts=s,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,s){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...s}).format()}dtFormatter(e,s={}){return this.loc.dtFormatter(e,{...this.opts,...s})}formatDateTime(e,s){return this.dtFormatter(e,s).format()}formatDateTimeParts(e,s){return this.dtFormatter(e,s).formatToParts()}formatInterval(e,s){return this.dtFormatter(e.start,s).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,s){return this.dtFormatter(e,s).resolvedOptions()}num(e,s=0,n=void 0){if(this.opts.forceSimple)return pe(e,s);const r={...this.opts};return s>0&&(r.padTo=s),n&&(r.signDisplay=n),this.loc.numberFormatter(r).format(e)}formatDateTimeFromString(e,s){const n=this.loc.listingMode()==="en",r=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",a=(y,v)=>this.loc.extract(e,y,v),o=y=>e.isOffsetFixed&&e.offset===0&&y.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,y.format):"",l=()=>n?Ui(e):a({hour:"numeric",hourCycle:"h12"},"dayperiod"),c=(y,v)=>n?$i(e,y):a(v?{month:y}:{month:y,day:"numeric"},"month"),u=(y,v)=>n?Fi(e,y):a(v?{weekday:y}:{weekday:y,month:"long",day:"numeric"},"weekday"),h=y=>{const v=Te.macroTokenToFormatOpts(y);return v?this.formatWithSystemDefault(e,v):y},m=y=>n?Pi(e,y):a({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?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 bn(Te.parseFormat(s),p)}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)=>p=>{const y=r(p);if(y){const v=m.isNegativeDuration&&y!==m.largestUnit?n:1;let E;return this.opts.signMode==="negativeLargestOnly"&&y!==m.largestUnit?E="never":this.opts.signMode==="all"?E="always":E="auto",this.num(h.get(y)*v,p.length,E)}else return p},o=Te.parseFormat(s),l=o.reduce((h,{literal:m,val:p})=>m?h:h.concat(p),[]),c=e.shiftTo(...l.map(r).filter(h=>h)),u={isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]};return bn(o,a(c,u))}}const Lr=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function pt(...t){const e=t.reduce((s,n)=>s+n.source,"");return RegExp(`^${e}$`)}function St(...t){return e=>t.reduce(([s,n,r],a)=>{const[o,l,c]=a(e,r);return[{...s,...o},l||n,c]},[{},null,1]).slice(0,2)}function xt(t,...e){if(t==null)return[null,null];for(const[s,n]of e){const r=s.exec(t);if(r)return n(r)}return[null,null]}function Ur(...t){return(e,s)=>{const n={};let r;for(r=0;r<t.length;r++)n[t[r]]=et(e[s+r]);return[n,null,s+r]}}const Fr=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,Bi=`(?:${Fr.source}?(?:\\[(${Lr.source})\\])?)?`,Hs=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,$r=RegExp(`${Hs.source}${Bi}`),qs=RegExp(`(?:[Tt]${$r.source})?`),Zi=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,zi=/(\d{4})-?W(\d\d)(?:-?(\d))?/,Hi=/(\d{4})-?(\d{3})/,qi=Ur("weekYear","weekNumber","weekDay"),Gi=Ur("year","ordinal"),Yi=/(\d{4})-(\d\d)-(\d\d)/,Pr=RegExp(`${Hs.source} ?(?:${Fr.source}|(${Lr.source}))?`),_i=RegExp(`(?: ${Pr.source})?`);function yt(t,e,s){const n=t[e];return $(n)?s:et(n)}function Ji(t,e){return[{year:yt(t,e),month:yt(t,e+1,1),day:yt(t,e+2,1)},null,e+3]}function wt(t,e){return[{hours:yt(t,e,0),minutes:yt(t,e+1,0),seconds:yt(t,e+2,0),milliseconds:Zs(t[e+3])},null,e+4]}function Ct(t,e){const s=!t[e]&&!t[e+1],n=rs(t[e+1],t[e+2]),r=s?null:be.instance(n);return[{},r,e+3]}function Dt(t,e){const s=t[e]?Ye.create(t[e]):null;return[{},s,e+1]}const Qi=RegExp(`^T?${Hs.source}$`),Ki=/^-?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 Xi(t){const[e,s,n,r,a,o,l,c,u]=t,h=e[0]==="-",m=c&&c[0]==="-",p=(y,v=!1)=>y!==void 0&&(v||y&&h)?-y:y;return[{years:p(nt(s)),months:p(nt(n)),weeks:p(nt(r)),days:p(nt(a)),hours:p(nt(o)),minutes:p(nt(l)),seconds:p(nt(c),c==="-0"),milliseconds:p(Zs(u),m)}]}const eo={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Gs(t,e,s,n,r,a,o){const l={year:e.length===2?Ds(et(e)):et(e),month:Er.indexOf(s)+1,day:et(n),hour:et(r),minute:et(a)};return o&&(l.second=et(o)),t&&(l.weekday=t.length>3?Or.indexOf(t)+1:jr.indexOf(t)+1),l}const to=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function so(t){const[,e,s,n,r,a,o,l,c,u,h,m]=t,p=Gs(e,r,n,s,a,o,l);let y;return c?y=eo[c]:u?y=0:y=rs(h,m),[p,new be(y)]}function no(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const ro=/^(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$/,ao=/^(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$/,io=/^(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 kn(t){const[,e,s,n,r,a,o,l]=t;return[Gs(e,r,n,s,a,o,l),be.utcInstance]}function oo(t){const[,e,s,n,r,a,o,l]=t;return[Gs(e,l,s,n,r,a,o),be.utcInstance]}const lo=pt(Zi,qs),co=pt(zi,qs),uo=pt(Hi,qs),mo=pt($r),Wr=St(Ji,wt,Ct,Dt),fo=St(qi,wt,Ct,Dt),ho=St(Gi,wt,Ct,Dt),yo=St(wt,Ct,Dt);function go(t){return xt(t,[lo,Wr],[co,fo],[uo,ho],[mo,yo])}function po(t){return xt(no(t),[to,so])}function So(t){return xt(t,[ro,kn],[ao,kn],[io,oo])}function xo(t){return xt(t,[Ki,Xi])}const wo=St(wt);function vo(t){return xt(t,[Qi,wo])}const To=pt(Yi,_i),Ao=pt(Pr),No=St(wt,Ct,Dt);function bo(t){return xt(t,[To,Wr],[Ao,No])}const In="Invalid Duration",Vr={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}},ko={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},...Vr},Ue=146097/400,ut=146097/4800,Io={years:{quarters:4,months:12,weeks:Ue/7,days:Ue,hours:Ue*24,minutes:Ue*24*60,seconds:Ue*24*60*60,milliseconds:Ue*24*60*60*1e3},quarters:{months:3,weeks:Ue/28,days:Ue/4,hours:Ue*24/4,minutes:Ue*24*60/4,seconds:Ue*24*60*60/4,milliseconds:Ue*24*60*60*1e3/4},months:{weeks:ut/7,days:ut,hours:ut*24,minutes:ut*24*60,seconds:ut*24*60*60,milliseconds:ut*24*60*60*1e3},...Vr},at=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Eo=at.slice(0).reverse();function qe(t,e,s=!1){const n={values:s?e.values:{...t.values,...e.values||{}},loc:t.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||t.conversionAccuracy,matrix:e.matrix||t.matrix};return new Q(n)}function Br(t,e){let s=e.milliseconds??0;for(const n of Eo.slice(1))e[n]&&(s+=e[n]*t[n].milliseconds);return s}function En(t,e){const s=Br(t,e)<0?-1:1;at.reduceRight((n,r)=>{if($(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),at.reduce((n,r)=>{if($(e[r]))return n;if(n){const a=e[n]%1;e[n]-=a,e[r]+=a*t[n][r]}return r},null)}function Mn(t){const e={};for(const[s,n]of Object.entries(t))n!==0&&(e[s]=n);return e}class Q{constructor(e){const s=e.conversionAccuracy==="longterm"||!1;let n=s?Io:ko;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||se.create(),this.conversionAccuracy=s?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=n,this.isLuxonDuration=!0}static fromMillis(e,s){return Q.fromObject({milliseconds:e},s)}static fromObject(e,s={}){if(e==null||typeof e!="object")throw new ve(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new Q({values:Kt(e,Q.normalizeUnit),loc:se.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(st(e))return Q.fromMillis(e);if(Q.isDuration(e))return e;if(typeof e=="object")return Q.fromObject(e);throw new ve(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,s){const[n]=xo(e);return n?Q.fromObject(n,s):Q.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,s){const[n]=vo(e);return n?Q.fromObject(n,s):Q.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,s=null){if(!e)throw new ve("need to specify a reason the Duration is invalid");const n=e instanceof Ve?e:new Ve(e,s);if(fe.throwOnInvalid)throw new Xa(n);return new Q({invalid:n})}static normalizeUnit(e){const s={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[e&&e.toLowerCase()];if(!s)throw new Jn(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):In}toHuman(e={}){if(!this.isValid)return In;const s=e.showZeros!==!1,n=at.map(r=>{const a=this.values[r];return $(a)||a===0&&!s?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:r.slice(0,-1)}).format(a)}).filter(r=>r);return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(n)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e="P";return this.years!==0&&(e+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+"M"),this.weeks!==0&&(e+=this.weeks+"W"),this.days!==0&&(e+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+="T"),this.hours!==0&&(e+=this.hours+"H"),this.minutes!==0&&(e+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(e+=zs(this.seconds+this.milliseconds/1e3,3)+"S"),e==="P"&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;const s=this.toMillis();return s<0||s>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e,includeOffset:!1},F.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?Br(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const s=Q.fromDurationLike(e),n={};for(const r of at)(gt(s.values,r)||gt(this.values,r))&&(n[r]=s.get(r)+this.get(r));return qe(this,{values:n},!0)}minus(e){if(!this.isValid)return this;const s=Q.fromDurationLike(e);return this.plus(s.negate())}mapUnits(e){if(!this.isValid)return this;const s={};for(const n of Object.keys(this.values))s[n]=Ir(e(this.values[n],n));return qe(this,{values:s},!0)}get(e){return this[Q.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const s={...this.values,...Kt(e,Q.normalizeUnit)};return qe(this,{values:s})}reconfigure({locale:e,numberingSystem:s,conversionAccuracy:n,matrix:r}={}){const o={loc:this.loc.clone({locale:e,numberingSystem:s}),matrix:r,conversionAccuracy:n};return qe(this,o)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return En(this.matrix,e),qe(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=Mn(this.normalize().shiftToAll().toObject());return qe(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(o=>Q.normalizeUnit(o));const s={},n={},r=this.toObject();let a;for(const o of at)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;st(r[o])&&(l+=r[o]);const c=Math.trunc(l);s[o]=c,n[o]=(l*1e3-c*1e3)/1e3}else st(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 En(this.matrix,s),qe(this,{values:s},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const e={};for(const s of Object.keys(this.values))e[s]=this.values[s]===0?0:-this.values[s];return qe(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=Mn(this.values);return qe(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function s(n,r){return n===void 0||n===0?r===void 0||r===0:n===r}for(const n of at)if(!s(this.values[n],e.values[n]))return!1;return!0}}const dt="Invalid Interval";function Mo(t,e){return!t||!t.isValid?me.invalid("missing or invalid start"):!e||!e.isValid?me.invalid("missing or invalid end"):e<t?me.invalid("end before start",`The end of an interval must be after its start, but you had start=${t.toISO()} and end=${e.toISO()}`):null}class me{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,s=null){if(!e)throw new ve("need to specify a reason the Interval is invalid");const n=e instanceof Ve?e:new Ve(e,s);if(fe.throwOnInvalid)throw new Ka(n);return new me({invalid:n})}static fromDateTimes(e,s){const n=At(e),r=At(s),a=Mo(n,r);return a??new me({start:n,end:r})}static after(e,s){const n=Q.fromDurationLike(s),r=At(e);return me.fromDateTimes(r,r.plus(n))}static before(e,s){const n=Q.fromDurationLike(s),r=At(e);return me.fromDateTimes(r.minus(n),r)}static fromISO(e,s){const[n,r]=(e||"").split("/",2);if(n&&r){let a,o;try{a=F.fromISO(n,s),o=a.isValid}catch{o=!1}let l,c;try{l=F.fromISO(r,s),c=l.isValid}catch{c=!1}if(o&&c)return me.fromDateTimes(a,l);if(o){const u=Q.fromISO(r,s);if(u.isValid)return me.after(a,u)}else if(c){const u=Q.fromISO(n,s);if(u.isValid)return me.before(l,u)}}return me.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(e).get(e):NaN}count(e="milliseconds",s){if(!this.isValid)return NaN;const n=this.start.startOf(e,s);let r;return s?.useLocaleWeeks?r=this.end.reconfigure({locale:n.locale}):r=this.end,r=r.startOf(e,s),Math.floor(r.diff(n,e).get(e))+(r.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:e,end:s}={}){return this.isValid?me.fromDateTimes(e||this.s,s||this.e):this}splitAt(...e){if(!this.isValid)return[];const s=e.map(At).filter(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=Q.fromDurationLike(e);if(!this.isValid||!s.isValid||s.as("milliseconds")===0)return[];let{s:n}=this,r=1,a;const o=[];for(;n<this.e;){const l=this.start.plus(s.mapUnits(c=>c*r));a=+l>+this.e?this.e:l,o.push(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()})`:dt}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=_t,s={}){return this.isValid?Te.create(this.s.loc.clone(s),e).formatInterval(this):dt}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:dt}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:dt}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:dt}toFormat(e,{separator:s=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${s}${this.e.toFormat(e)}`:dt}toDuration(e,s){return this.isValid?this.e.diff(this.s,e,s):Q.invalid(this.invalidReason)}mapEndpoints(e){return me.fromDateTimes(e(this.s),e(this.e))}}class Wt{static hasDST(e=fe.defaultZone){const s=F.now().setZone(e).set({month:12});return!e.isUniversal&&s.offset!==s.set({month:6}).offset}static isValidIANAZone(e){return Ye.isValidZone(e)}static normalizeZone(e){return tt(e,fe.defaultZone)}static getStartOfWeek({locale:e=null,locObj:s=null}={}){return(s||se.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:s=null}={}){return(s||se.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:s=null}={}){return(s||se.create(e)).getWeekendDays().slice()}static months(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||se.create(s,n,a)).months(e)}static monthsFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||se.create(s,n,a)).months(e,!0)}static weekdays(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||se.create(s,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||se.create(s,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return se.create(e).meridiems()}static eras(e="short",{locale:s=null}={}){return se.create(s,null,"gregory").eras(e)}static features(){return{relative:Nr(),localeWeek:br()}}}function On(t,e){const s=r=>r.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),n=s(e)-s(t);return Math.floor(Q.fromMillis(n).as("days"))}function Oo(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=On(c,u);return(h-h%7)/7}],["days",On]],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 jo(t,e,s,n){let[r,a,o,l]=Oo(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=Q.fromObject(a,n);return u.length>0?Q.fromMillis(c,n).shiftTo(...u).plus(h):h}const Co="missing Intl.DateTimeFormat.formatToParts support";function te(t,e=s=>s){return{regex:t,deser:([s])=>e(vi(s))}}const Do=" ",Zr=`[ ${Do}]`,zr=new RegExp(Zr,"g");function Ro(t){return t.replace(/\./g,"\\.?").replace(zr,Zr)}function jn(t){return t.replace(/\./g,"").replace(zr," ").toLowerCase()}function We(t,e){return t===null?null:{regex:RegExp(t.map(Ro).join("|")),deser:([s])=>t.findIndex(n=>jn(s)===jn(n))+e}}function Cn(t,e){return{regex:t,deser:([,s,n])=>rs(s,n),groups:e}}function Vt(t){return{regex:t,deser:([e])=>e}}function Lo(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Uo(t,e){const s=Pe(e),n=Pe(e,"{2}"),r=Pe(e,"{3}"),a=Pe(e,"{4}"),o=Pe(e,"{6}"),l=Pe(e,"{1,2}"),c=Pe(e,"{1,3}"),u=Pe(e,"{1,6}"),h=Pe(e,"{1,9}"),m=Pe(e,"{2,4}"),p=Pe(e,"{4,6}"),y=C=>({regex:RegExp(Lo(C.val)),deser:([_])=>_,literal:!0}),E=(C=>{if(t.literal)return y(C);switch(C.val){case"G":return We(e.eras("short"),0);case"GG":return We(e.eras("long"),0);case"y":return te(u);case"yy":return te(m,Ds);case"yyyy":return te(a);case"yyyyy":return te(p);case"yyyyyy":return te(o);case"M":return te(l);case"MM":return te(n);case"MMM":return We(e.months("short",!0),1);case"MMMM":return We(e.months("long",!0),1);case"L":return te(l);case"LL":return te(n);case"LLL":return We(e.months("short",!1),1);case"LLLL":return We(e.months("long",!1),1);case"d":return te(l);case"dd":return te(n);case"o":return te(c);case"ooo":return te(r);case"HH":return te(n);case"H":return te(l);case"hh":return te(n);case"h":return te(l);case"mm":return te(n);case"m":return te(l);case"q":return te(l);case"qq":return te(n);case"s":return te(l);case"ss":return te(n);case"S":return te(c);case"SSS":return te(r);case"u":return Vt(h);case"uu":return Vt(l);case"uuu":return te(s);case"a":return We(e.meridiems(),0);case"kkkk":return te(a);case"kk":return te(m,Ds);case"W":return te(l);case"WW":return te(n);case"E":case"c":return te(s);case"EEE":return We(e.weekdays("short",!1),1);case"EEEE":return We(e.weekdays("long",!1),1);case"ccc":return We(e.weekdays("short",!0),1);case"cccc":return We(e.weekdays("long",!0),1);case"Z":case"ZZ":return Cn(new RegExp(`([+-]${l.source})(?::(${n.source}))?`),2);case"ZZZ":return Cn(new RegExp(`([+-]${l.source})(${n.source})?`),2);case"z":return Vt(/[a-z_+-/]{1,256}?/i);case" ":return Vt(/[^\S\n\r]/);default:return y(C)}})(t)||{invalidReason:Co};return E.token=t,E}const Fo={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 $o(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=Fo[o];if(typeof l=="object"&&(l=l[a]),l)return{literal:!1,val:l}}function Po(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function Wo(t,e,s){const n=t.match(e);if(n){const r={};let a=1;for(const o in s)if(gt(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 Vo(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 $(t.z)||(s=Ye.create(t.z)),$(t.Z)||(s||(s=new be(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=Zs(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 Bo(){return ps||(ps=F.fromMillis(1555555555555)),ps}function Zo(t,e){if(t.literal)return t;const s=Te.macroTokenToFormatOpts(t.val),n=Yr(s,e);return n==null||n.includes(void 0)?t:n}function Hr(t,e){return Array.prototype.concat(...t.map(s=>Zo(s,e)))}class qr{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=Hr(Te.parseFormat(s),e),this.units=this.tokens.map(n=>Uo(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=Po(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=Wo(e,this.regex,this.handlers),[r,a,o]=n?Vo(n):[null,null,void 0];if(gt(n,"a")&>(n,"H"))throw new ft("Can't include meridiem when specifying 24-hour format");return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:s,matches:n,result:r,zone:a,specificOffset: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 Gr(t,e,s){return new qr(t,s).explainFromTokens(e)}function zo(t,e,s){const{result:n,zone:r,specificOffset:a,invalidReason:o}=Gr(t,e,s);return[n,r,a,o]}function Yr(t,e){if(!t)return null;const n=Te.create(e,t).dtFormatter(Bo()),r=n.formatToParts(),a=n.resolvedOptions();return r.map(o=>$o(o,t,a))}const Ss="Invalid DateTime",Dn=864e13;function kt(t){return new Ve("unsupported zone",`the zone "${t.name}" is not supported`)}function xs(t){return t.weekData===null&&(t.weekData=Jt(t.c)),t.weekData}function ws(t){return t.localWeekData===null&&(t.localWeekData=Jt(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function rt(t,e){const s={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new F({...s,...e,old:s})}function _r(t,e,s){let n=t-e*60*1e3;const r=s.offset(n);if(e===r)return[n,e];n-=(r-e)*60*1e3;const a=s.offset(n);return r===a?[n,r]:[t-Math.min(r,a)*60*1e3,Math.max(r,a)]}function Bt(t,e){t+=e*60*1e3;const s=new Date(t);return{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),hour:s.getUTCHours(),minute:s.getUTCMinutes(),second:s.getUTCSeconds(),millisecond:s.getUTCMilliseconds()}}function qt(t,e,s){return _r(ns(t),e,s)}function Rn(t,e){const s=t.o,n=t.c.year+Math.trunc(e.years),r=t.c.month+Math.trunc(e.months)+Math.trunc(e.quarters)*3,a={...t.c,year:n,month:r,day:Math.min(t.c.day,Qt(n,r))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},o=Q.fromObject({years:e.years-Math.trunc(e.years),quarters:e.quarters-Math.trunc(e.quarters),months:e.months-Math.trunc(e.months),weeks:e.weeks-Math.trunc(e.weeks),days:e.days-Math.trunc(e.days),hours:e.hours,minutes:e.minutes,seconds:e.seconds,milliseconds:e.milliseconds}).as("milliseconds"),l=ns(a);let[c,u]=_r(l,s,t.zone);return o!==0&&(c+=o,u=t.zone.offset(c)),{ts:c,o:u}}function mt(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=F.fromObject(t,{...s,zone:c,specificOffset:a});return o?u:u.setZone(l)}else return F.invalid(new Ve("unparsable",`the input "${r}" can't be parsed as ${n}`))}function Zt(t,e,s=!0){return t.isValid?Te.create(se.create("en-US"),{allowZ:s,forceSimple:!0}).formatDateTimeFromString(t,e):null}function vs(t,e,s){const n=t.c.year>9999||t.c.year<0;let r="";if(n&&t.c.year>=0&&(r+="+"),r+=pe(t.c.year,n?6:4),s==="year")return r;if(e){if(r+="-",r+=pe(t.c.month),s==="month")return r;r+="-"}else if(r+=pe(t.c.month),s==="month")return r;return r+=pe(t.c.day),r}function Ln(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+=pe(t.c.hour),o==="hour")break;if(e){if(c+=":",c+=pe(t.c.minute),o==="minute")break;l&&(c+=":",c+=pe(t.c.second))}else{if(c+=pe(t.c.minute),o==="minute")break;l&&(c+=pe(t.c.second))}if(o==="second")break;l&&(!n||t.c.millisecond!==0)&&(c+=".",c+=pe(t.c.millisecond,3))}return r&&(t.isOffsetFixed&&t.offset===0&&!a?c+="Z":t.o<0?(c+="-",c+=pe(Math.trunc(-t.o/60)),c+=":",c+=pe(Math.trunc(-t.o%60))):(c+="+",c+=pe(Math.trunc(t.o/60)),c+=":",c+=pe(Math.trunc(t.o%60)))),a&&(c+="["+t.zone.ianaName+"]"),c}const Jr={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},Ho={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},qo={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Gt=["year","month","day","hour","minute","second","millisecond"],Go=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],Yo=["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 Jn(t);return e}function Un(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 _o(t){if(It===void 0&&(It=fe.now()),t.type!=="iana")return t.offset(It);const e=t.name;let s=Rs.get(e);return s===void 0&&(s=t.offset(It),Rs.set(e,s)),s}function Fn(t,e){const s=tt(e.zone,fe.defaultZone);if(!s.isValid)return F.invalid(kt(s));const n=se.fromObject(e);let r,a;if($(t.year))r=fe.now();else{for(const c of Gt)$(t[c])&&(t[c]=Jr[c]);const o=Tr(t)||Ar(t);if(o)return F.invalid(o);const l=_o(s);[r,a]=qt(t,l,s)}return new F({ts:r,zone:s,loc:n,o:a})}function $n(t,e,s){const n=$(s.round)?!0:s.round,r=$(s.rounding)?"trunc":s.rounding,a=(l,c)=>(l=zs(l,n||s.calendary?0:2,s.calendary?"round":r),e.loc.clone(s).relFormatter(s).format(l,c)),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 Pn(t){let e={},s;return t.length>0&&typeof t[t.length-1]=="object"?(e=t[t.length-1],s=Array.from(t).slice(0,t.length-1)):s=Array.from(t),[e,s]}let It;const Rs=new Map;class F{constructor(e){const s=e.zone||fe.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Ve("invalid input"):null)||(s.isValid?null:kt(s));this.ts=$(e.ts)?fe.now():e.ts;let r=null,a=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(s))[r,a]=[e.old.c,e.old.o];else{const l=st(e.o)&&!e.old?e.o:s.offset(this.ts);r=Bt(this.ts,l),n=Number.isNaN(r.year)?new Ve("invalid input"):null,r=n?null:r,a=n?null:l}this._zone=s,this.loc=e.loc||se.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=a,this.isLuxonDateTime=!0}static now(){return new F({})}static local(){const[e,s]=Pn(arguments),[n,r,a,o,l,c,u]=s;return Fn({year:n,month:r,day:a,hour:o,minute:l,second:c,millisecond:u},e)}static utc(){const[e,s]=Pn(arguments),[n,r,a,o,l,c,u]=s;return e.zone=be.utcInstance,Fn({year:n,month:r,day:a,hour:o,minute:l,second:c,millisecond:u},e)}static fromJSDate(e,s={}){const n=ki(e)?e.valueOf():NaN;if(Number.isNaN(n))return F.invalid("invalid input");const r=tt(s.zone,fe.defaultZone);return r.isValid?new F({ts:n,zone:r,loc:se.fromObject(s)}):F.invalid(kt(r))}static fromMillis(e,s={}){if(st(e))return e<-Dn||e>Dn?F.invalid("Timestamp out of range"):new F({ts:e,zone:tt(s.zone,fe.defaultZone),loc:se.fromObject(s)});throw new ve(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,s={}){if(st(e))return new F({ts:e*1e3,zone:tt(s.zone,fe.defaultZone),loc:se.fromObject(s)});throw new ve("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=tt(s.zone,fe.defaultZone);if(!n.isValid)return F.invalid(kt(n));const r=se.fromObject(s),a=Kt(e,Un),{minDaysInFirstWeek:o,startOfWeek:l}=Tn(a,r),c=fe.now(),u=$(s.specificOffset)?n.offset(c):s.specificOffset,h=!$(a.ordinal),m=!$(a.year),p=!$(a.month)||!$(a.day),y=m||p,v=a.weekYear||a.weekNumber;if((y||h)&&v)throw new ft("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(p&&h)throw new ft("Can't mix ordinal dates with month/day");const E=v||a.weekday&&!y;let C,_,G=Bt(c,u);E?(C=Go,_=Ho,G=Jt(G,o,l)):h?(C=Yo,_=qo,G=gs(G)):(C=Gt,_=Jr);let K=!1;for(const N of C){const M=a[N];$(M)?K?a[N]=_[N]:a[N]=G[N]:K=!0}const b=E?Ai(a,o,l):h?Ni(a):Tr(a),D=b||Ar(a);if(D)return F.invalid(D);const V=E?wn(a,o,l):h?vn(a):a,[R,z]=qt(V,u,n),g=new F({ts:R,zone:n,o:z,loc:r});return a.weekday&&y&&e.weekday!==g.weekday?F.invalid("mismatched weekday",`you can't specify both a weekday of ${a.weekday} and a date of ${g.toISO()}`):g.isValid?g:F.invalid(g.invalid)}static fromISO(e,s={}){const[n,r]=go(e);return mt(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=po(e);return mt(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=So(e);return mt(n,r,s,"HTTP",s)}static fromFormat(e,s,n={}){if($(e)||$(s))throw new ve("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:a=null}=n,o=se.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0}),[l,c,u,h]=zo(o,e,s);return h?F.invalid(h):mt(l,c,n,`format ${s}`,e,u)}static fromString(e,s,n={}){return F.fromFormat(e,s,n)}static fromSQL(e,s={}){const[n,r]=bo(e);return mt(n,r,s,"SQL",e)}static invalid(e,s=null){if(!e)throw new ve("need to specify a reason the DateTime is invalid");const n=e instanceof Ve?e:new Ve(e,s);if(fe.throwOnInvalid)throw new Qa(n);return new F({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,s={}){const n=Yr(e,se.fromObject(s));return n?n.map(r=>r?r.val:null).join(""):null}static expandFormat(e,s={}){return Hr(Te.parseFormat(e),se.fromObject(s)).map(r=>r.val).join("")}static resetCache(){It=void 0,Rs.clear()}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?xs(this).weekYear:NaN}get weekNumber(){return this.isValid?xs(this).weekNumber:NaN}get weekday(){return this.isValid?xs(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?ws(this).weekday:NaN}get localWeekNumber(){return this.isValid?ws(this).weekNumber:NaN}get localWeekYear(){return this.isValid?ws(this).weekYear:NaN}get ordinal(){return this.isValid?gs(this.c).ordinal:NaN}get monthShort(){return this.isValid?Wt.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Wt.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Wt.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Wt.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const e=864e5,s=6e4,n=ns(this.c),r=this.zone.offset(n-e),a=this.zone.offset(n+e),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=Bt(c,o),m=Bt(u,l);return h.hour===m.hour&&h.minute===m.minute&&h.second===m.second&&h.millisecond===m.millisecond?[rt(this,{ts:c}),rt(this,{ts:u})]:[this]}get isInLeapYear(){return jt(this.year)}get daysInMonth(){return Qt(this.year,this.month)}get daysInYear(){return this.isValid?ht(this.year):NaN}get weeksInWeekYear(){return this.isValid?Mt(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Mt(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:s,numberingSystem:n,calendar:r}=Te.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:s,numberingSystem:n,outputCalendar:r}}toUTC(e=0,s={}){return this.setZone(be.instance(e),s)}toLocal(){return this.setZone(fe.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=tt(e,fe.defaultZone),e.equals(this.zone))return this;if(e.isValid){let r=this.ts;if(s||n){const a=e.offset(this.ts),o=this.toObject();[r]=qt(o,a,e)}return rt(this,{ts:r,zone:e})}else return F.invalid(kt(e))}reconfigure({locale:e,numberingSystem:s,outputCalendar:n}={}){const r=this.loc.clone({locale:e,numberingSystem:s,outputCalendar:n});return rt(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const s=Kt(e,Un),{minDaysInFirstWeek:n,startOfWeek:r}=Tn(s,this.loc),a=!$(s.weekYear)||!$(s.weekNumber)||!$(s.weekday),o=!$(s.ordinal),l=!$(s.year),c=!$(s.month)||!$(s.day),u=l||c,h=s.weekYear||s.weekNumber;if((u||o)&&h)throw new ft("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(c&&o)throw new ft("Can't mix ordinal dates with month/day");let m;a?m=wn({...Jt(this.c,n,r),...s},n,r):$(s.ordinal)?(m={...this.toObject(),...s},$(s.day)&&(m.day=Math.min(Qt(m.year,m.month),m.day))):m=vn({...gs(this.c),...s});const[p,y]=qt(m,this.o,this.zone);return rt(this,{ts:p,o:y})}plus(e){if(!this.isValid)return this;const s=Q.fromDurationLike(e);return rt(this,Rn(this,s))}minus(e){if(!this.isValid)return this;const s=Q.fromDurationLike(e).negate();return rt(this,Rn(this,s))}startOf(e,{useLocaleWeeks:s=!1}={}){if(!this.isValid)return this;const n={},r=Q.normalizeUnit(e);switch(r){case"years":n.month=1;case"quarters":case"months":n.day=1;case"weeks":case"days":n.hour=0;case"hours":n.minute=0;case"minutes":n.second=0;case"seconds":n.millisecond=0;break}if(r==="weeks")if(s){const a=this.loc.getStartOfWeek(),{weekday:o}=this;o<a&&(n.weekNumber=this.weekNumber-1),n.weekday=a}else n.weekday=1;if(r==="quarters"){const a=Math.ceil(this.month/3);n.month=(a-1)*3+1}return this.set(n)}endOf(e,s){return this.isValid?this.plus({[e]:1}).startOf(e,s).minus(1):this}toFormat(e,s={}){return this.isValid?Te.create(this.loc.redefaultToEN(s)).formatDateTimeFromString(this,e):Ss}toLocaleString(e=_t,s={}){return this.isValid?Te.create(this.loc.clone(s),e).formatDateTime(this):Ss}toLocaleParts(e={}){return this.isValid?Te.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:s=!1,suppressMilliseconds:n=!1,includeOffset:r=!0,extendedZone:a=!1,precision:o="milliseconds"}={}){if(!this.isValid)return null;o=Yt(o);const l=e==="extended";let c=vs(this,l,o);return Gt.indexOf(o)>=3&&(c+="T"),c+=Ln(this,l,s,n,r,a,o),c}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?vs(this,e==="extended",Yt(s)):null}toISOWeekDate(){return Zt(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:s=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:a=!1,format:o="extended",precision:l="milliseconds"}={}){return this.isValid?(l=Yt(l),(r&&Gt.indexOf(l)>=3?"T":"")+Ln(this,o==="extended",s,e,n,a,l)):null}toRFC2822(){return Zt(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return Zt(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?vs(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:s=!1,includeOffsetSpace:n=!0}={}){let r="HH:mm:ss.SSS";return(s||e)&&(n&&(r+=" "),s?r+="z":e&&(r+="ZZ")),Zt(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Ss}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};const s={...this.c};return e.includeConfig&&(s.outputCalendar=this.outputCalendar,s.numberingSystem=this.loc.numberingSystem,s.locale=this.loc.locale),s}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,s="milliseconds",n={}){if(!this.isValid||!e.isValid)return Q.invalid("created by diffing an invalid DateTime");const r={locale:this.locale,numberingSystem:this.numberingSystem,...n},a=Ii(s).map(Q.normalizeUnit),o=e.valueOf()>this.valueOf(),l=o?this:e,c=o?e:this,u=jo(l,c,a,r);return o?u.negate():u}diffNow(e="milliseconds",s={}){return this.diff(F.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||F.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),$n(s,this.plus(n),{...e,numeric:"always",units:r,unit:a})}toRelativeCalendar(e={}){return this.isValid?$n(e.base||F.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(F.isDateTime))throw new ve("min requires all arguments be DateTimes");return An(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every(F.isDateTime))throw new ve("max requires all arguments be DateTimes");return An(e,s=>s.valueOf(),Math.max)}static fromFormatExplain(e,s,n={}){const{locale:r=null,numberingSystem:a=null}=n,o=se.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});return Gr(o,e,s)}static fromStringExplain(e,s,n={}){return F.fromFormatExplain(e,s,n)}static buildFormatParser(e,s={}){const{locale:n=null,numberingSystem:r=null}=s,a=se.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new qr(a,e)}static fromFormatParser(e,s,n={}){if($(e)||$(s))throw new ve("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:a=null}=n,o=se.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?F.invalid(h):mt(l,c,n,`format ${s.format}`,e,u)}static get DATE_SHORT(){return _t}static get DATE_MED(){return Qn}static get DATE_MED_WITH_WEEKDAY(){return ei}static get DATE_FULL(){return Kn}static get DATE_HUGE(){return Xn}static get TIME_SIMPLE(){return er}static get TIME_WITH_SECONDS(){return tr}static get TIME_WITH_SHORT_OFFSET(){return sr}static get TIME_WITH_LONG_OFFSET(){return nr}static get TIME_24_SIMPLE(){return rr}static get TIME_24_WITH_SECONDS(){return ar}static get TIME_24_WITH_SHORT_OFFSET(){return ir}static get TIME_24_WITH_LONG_OFFSET(){return or}static get DATETIME_SHORT(){return lr}static get DATETIME_SHORT_WITH_SECONDS(){return cr}static get DATETIME_MED(){return ur}static get DATETIME_MED_WITH_SECONDS(){return dr}static get DATETIME_MED_WITH_WEEKDAY(){return ti}static get DATETIME_FULL(){return mr}static get DATETIME_FULL_WITH_SECONDS(){return fr}static get DATETIME_HUGE(){return hr}static get DATETIME_HUGE_WITH_SECONDS(){return yr}}function At(t){if(F.isDateTime(t))return t;if(t&&t.valueOf&&st(t.valueOf()))return F.fromJSDate(t);if(t&&typeof t=="object")return F.fromObject(t);throw new ve(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function Jo(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function Qo(t,e){try{const s=F.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 Ko(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 Xt(t,e="UTC"){if(!t)return"-";const s=F.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 Xo={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},el={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function Qr({alerts:t,loading:e=!1,pageSize:s=10,severityOptions:n,anomalyOptions:r,spaceOptions:a,onAlertIdClick:o}){const l=Ps(),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){const v=y?.Message||y?.data||"Alert reopened successfully.";we.toast.success(v)}else{const v=y?.errorMessage||y?.Message||"Failed to reopen alert";we.toast.error(v)}}catch{we.toast.error("Failed to reopen alert. Please try again.")}},h=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:p=>i.jsx(d.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Xo[p]}`,backgroundColor:el[String(p)]},children:p})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:p=>Ko(p)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(p,y)=>i.jsxs("div",{children:[i.jsx("a",{onClick:v=>{v.preventDefault(),o?.(y,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:y.alertNumber}),i.jsx("div",{className:"text-black/65",children:p})]})},{title:"",key:"menu",width:60,align:"right",render:(p,y)=>i.jsx(d.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:v})=>{v==="reopen"&&u(y)}},children:i.jsx(d.Button,{type:"text",icon:i.jsx(it.MoreOutlined,{})})})}],m=(t||[]).filter(p=>c.includes((p.statusType||"").toLowerCase()));return i.jsx($s,{data:m,loading:e,pageSize:s,columns:h,severityOptions:n,anomalyOptions:r,spaceOptions:a,renderActions:void 0,onAlertIdClick:o,excludeCompleted:!1})}function tl({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(p=>p.type==="hour")?.value||"0",10),minutes:parseInt(m.find(p=>p.type==="minute")?.value||"0",10),seconds:parseInt(m.find(p=>p.type==="second")?.value||"0",10)}},[e,s]),o=a*6,l=r*6+a*.1,c=n%12*30+r*.5,u=t/2;return i.jsxs("div",{className:"relative rounded-full border border-gray-300 bg-white",style:{width:t,height:t},role:"img","aria-label":"Analog Clock",children:[[...Array(12)].map((h,m)=>{const p=m*30,y=6,v=u-4,E=v-y,C=(p-90)*(Math.PI/180),_=u+E*Math.cos(C),G=u+E*Math.sin(C),K=u+v*Math.cos(C),b=u+v*Math.sin(C);return i.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:i.jsx("line",{x1:_,y1:G,x2:K,y2:b,stroke:"#9CA3AF",strokeWidth:m%3===0?2:1,strokeLinecap:"round"})},m)}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${c}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.25,stroke:"#1F2937",strokeWidth:4,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${l}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.35,stroke:"#374151",strokeWidth:3,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${o}deg)`},children:i.jsx("line",{x1:u,y1:u+t*.08,x2:u,y2:u-t*.38,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"})}),i.jsx("div",{className:"absolute bg-gray-900 rounded-full",style:{width:8,height:8,left:u-4,top:u-4}})]})}function Kr({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(()=>Jo(r,e),[r,e]),{abbr:l,offset:c}=f.useMemo(()=>Qo(r,e),[r,e]);return i.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[i.jsx(tl,{time:r,timeZone:e,size:80}),i.jsxs("div",{className:"flex flex-col items-baseline gap-1",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[i.jsx("span",{className:"uppercase",children:t}),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:sl}=d.Typography;function nl({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(sl,{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 Ls=t=>i.jsxs(d.Tag,{children:[i.jsx(it.PlusOutlined,{})," ",t.length," more"]}),{Text:Ge}=d.Typography;function rl(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:p,setL2role:y,l3mins:v,setL3mins:E,l3role:C,setL3role:_,actions:G,setActions:K,thirdPartyIds:b,setThirdPartyIds:D,humanLoop:V,setHumanLoop:R,isAutoExpire:z,setAutoExpire:g,onClear:N,onSave:M,saving:he,onActionTypesLoaded:oe}=t,{rules:j}=Oe(),[x,S]=f.useState([]),[k,w]=f.useState([]),[L,T]=f.useState(!1);f.useEffect(()=>{let H=!1;return(async()=>{try{T(!0);const X=await j.getLookups();if(H||!X||!Array.isArray(X.actionTypes))return;const le=X.actionTypes.map(ce=>({label:ce.name,value:String(ce.actionTypeId)}));S(le),oe&&oe(X.actionTypes);const Se=Array.isArray(X.thirdParties)?X.thirdParties.map(ce=>({label:ce.thirdPartyName,value:ce.thirdPartyId})):[];w(Se)}catch(X){console.error("Error loading lookups",X)}finally{H||T(!1)}})(),()=>{H=!0}},[]);const I=typeof o=="number"||typeof c=="number",P=typeof h=="number"||typeof p=="number",W=typeof o=="number"||typeof c=="number"||typeof h=="number"||typeof p=="number"||typeof v=="number"||typeof C=="number"||Array.isArray(G)&&G.length>0||Array.isArray(b)&&b.length>0||!!V||!!z,Z=!!e&&W&&!he;return i.jsxs(d.Spin,{spinning:!!he||L,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(Ge,{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(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),i.jsx(d.Col,{span:14,children:i.jsx(Ge,{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&&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(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),i.jsx(d.Col,{span:14,children:i.jsx(Ge,{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:p,onChange:y,options:a})})]})]})}),P&&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(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),i.jsx(d.Col,{span:14,children:i.jsx(Ge,{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:v,onChange:E,options:r})}),i.jsx(d.Col,{span:14,children:i.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:C,onChange:_,options:a})})]})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Ge,{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:G,onChange:K,options:x,maxTagCount:1,maxTagPlaceholder:Ls})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Ge,{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:b,onChange:D,options:k,maxCount:2,maxTagPlaceholder:Ls})]})})]}),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:V,onChange:H=>R(H.target.checked),className:"w-full",children:"Human-In-The-Loop"}),i.jsx(d.Checkbox,{checked:z,onChange:H=>g(H.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:N,children:"Clear"}),i.jsx(d.Button,{type:"primary",onClick:M,loading:!!he,disabled:!Z,children:"Save"})]})})]})]})}function al({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(it.EditOutlined,{})})}]})}const{Title:il,Text:Ts}=d.Typography;function Xr({userRoles:t,rules:e,rawRules:s}){const{rules:n}=Oe(),[r,a]=f.useState(!1),[o,l]=f.useState(!1),[c,u]=f.useState(s),[h,m]=f.useState(),[p,y]=f.useState([]),v=f.useMemo(()=>t.map(b=>({label:b.userRoleName,value:b.userRoleId})),[t]),E=f.useMemo(()=>(e||[]).map(b=>({label:b.Name||"-",value:b.RuleId||b.Name||""})),[e]),C=f.useMemo(()=>(e||[]).map((b,D)=>({key:b.RuleId||b.Name||String(D),ruleName:b.Name||"-",ruleDesc:b.Description||""})),[e]);f.useEffect(()=>{let b=!1;return(async()=>{try{a(!0);const D=await n.getRules();b||u(Array.isArray(D)?D:[])}catch{!b&&Array.isArray(s)&&u(s)}finally{b||a(!1)}})(),()=>{b=!0}},[]),f.useEffect(()=>{!c&&Array.isArray(s)&&u(s)},[s]),f.useEffect(()=>{if(!h||!Array.isArray(c)){y([]);return}const b=c.find(V=>V?.ruleId===h||V?.RuleId===h||V?.ruleName===h),D=b?.userRoleIds??b?.UserRoleIds;y(Array.isArray(D)?D:[])},[h,c]);const _=f.useMemo(()=>{if(!Array.isArray(c)||!c.length)return{};const b={};for(const D of C){const V=c.find(g=>g?.ruleId===D.key||g?.ruleName===D.key||g?.RuleId===D.key||g?.ruleName===D.ruleName||g?.Name===D.ruleName),R=V?.userRoleIds??V?.UserRoleIds,z=Array.isArray(R)?R:[];z.length&&(b[D.key]=z)}return b},[c,C]),G=()=>{m(void 0),y([])},K=async()=>{if(!h){we.toast.info("Please select a rule");return}try{l(!0);const b=Array.isArray(c)?c.find(g=>g?.ruleId===h||g?.RuleId===h||g?.ruleName===h):void 0,D=typeof b?.recordId=="number"?b.recordId:b?.ruleId||b?.RuleId||void 0;if(!b||!D)throw new Error(`Unable to find rule identifier for rule ${h}`);const V=p.map(g=>{const N=t.find(M=>M.userRoleId===g);return{id:g,name:N?.userRoleName??String(g)}}),R={...b,ruleId:h,userRoleIds:p,userRoles:V},z=await n.updateRule(D,R);if(!z?.responseStatus&&!z?.Success&&!z?.success)we.toast.error(z?.errorMessage||z?.Message||"Error saving Alert Assignment");else{we.toast.success("Alert assignment saved"),m(void 0),y([]);try{const g=await n.getRules();u(Array.isArray(g)?g:[])}catch(g){console.error("Failed to refresh rules after save",g)}}}catch(b){console.error("Failed to save alert assignment",b),we.toast.error(b instanceof Error?b.message:"Error saving Alert Assignment")}finally{l(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(il,{level:4,className:"!mb-4",children:"Alert Assignment"}),i.jsx(d.Spin,{spinning:o||r,children:i.jsxs(d.Row,{gutter:[16,16],align:"bottom",className:"mb-6",children:[i.jsx(d.Col,{xs:24,sm:12,md:8,lg:6,children:i.jsxs("div",{children:[i.jsx(Ts,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(d.Select,{placeholder:"Rules",value:h,onChange:m,options:E,className:"w-full"})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:8,children:i.jsxs("div",{children:[i.jsx(Ts,{className:"text-gray-700 font-medium block mb-1",children:"Alert Notification To"}),i.jsx(d.Select,{mode:"multiple",placeholder:"Select roles",className:"w-full",value:p,onChange:y,options:v,maxTagCount:1,maxTagPlaceholder:Ls})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.Button,{onClick:G,disabled:o,children:"Cancel"}),i.jsx(d.Button,{type:"primary",onClick:K,loading:o,disabled:o||!h,children:"Save"})]})})]})}),i.jsx(d.Table,{rowKey:"key",dataSource:C,loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(b,D)=>`${D[0]}-${D[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,D)=>{const V=_[D.key]??[];return V.length?i.jsx("div",{className:"flex flex-wrap gap-1",children:V.map(R=>{const z=t.find(g=>g.userRoleId===R);return i.jsx(d.Tag,{children:z?.userRoleName??String(R)},R)})}):i.jsx(Ts,{type:"secondary",children:"—"})}}]})]})}const{Title:Wn}=d.Typography;function As(t){return!t||typeof t!="object"?{}:{level1UserRoleId:t.level1UserRoleId??t.Level1UserRoleId,level1PostAssistTime:t.level1PostAssistTime??t.Level1PostAssistTime,level2UserRoleId:t.level2UserRoleId??t.Level2UserRoleId,level2PostAssistTime:t.level2PostAssistTime??t.Level2PostAssistTime,level3UserRoleId:t.level3UserRoleId??t.Level3UserRoleId,level3PostAssistTime:t.level3PostAssistTime??t.Level3PostAssistTime,escalationSettingsActionTypeIds:t.escalationSettingsActionTypeIds??t.EscalationSettingsActionTypeIds,thirdPartyId:t.thirdPartyId??t.ThirdPartyIds,humanLoop:t.humanLoop??t.HumanLoop,isAutoExpire:t.isAutoExpire??t.IsAutoExpire}}function ea({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r,onSave:a}){const{rules:o,alerts:l}=Oe(),[c,u]=f.useState("By Severity"),[h,m]=f.useState("By severity"),[p,y]=f.useState("By Severity"),[v,E]=f.useState(!1),[C,_]=f.useState(!1),[G,K]=f.useState(!1),[b,D]=f.useState(null),[V,R]=f.useState("rules"),[z,g]=f.useState(),[N,M]=f.useState(),[he,oe]=f.useState(),[j,x]=f.useState(),[S,k]=f.useState(),[w,L]=f.useState(),[T,I]=f.useState(),[P,W]=f.useState(),[Z,H]=f.useState([]),[X,le]=f.useState([]),[Se,ce]=f.useState(!1),[ue,xe]=f.useState(!1),[Ae,je]=f.useState({}),[_e,vt]=f.useState({}),[ye,ct]=f.useState(s||[]),[Tt,Je]=f.useState([]),[os,O]=f.useState(!1),[Y,ee]=f.useState(!1),[ge,ke]=f.useState(n||[]);f.useEffect(()=>{n&&n.length&&ke(n)},[n]),f.useEffect(()=>{if(!ge||!ge.length)return;const U=Object.keys(Ae).length>0||Object.keys(_e).length>0;if(Tt.length&&!U)return;const re=ge.map((J,B)=>{const ie=e.find(Ne=>Ne.RuleId===(J.ruleId||J.ruleName))?.Name||J.ruleName||J.Name||"-",q=As(J.escalationSettings),ae=typeof q.level1UserRoleId=="number"&&q.level1UserRoleId>0?[q.level1UserRoleId]:[],ls=typeof q.level2UserRoleId=="number"&&q.level2UserRoleId>0?[q.level2UserRoleId]:[],cs=typeof q.level3UserRoleId=="number"&&q.level3UserRoleId>0?[q.level3UserRoleId]:[],Qs=(Array.isArray(q.escalationSettingsActionTypeIds)?q.escalationSettingsActionTypeIds:[]).map(Ne=>Ae[Ne]||String(Ne)),Xs=(Array.isArray(q.thirdPartyId)?q.thirdPartyId:[]).map(Ne=>_e[Ne]||String(Ne)),us=typeof q.humanLoop=="boolean"?q.humanLoop:null,ds=typeof q.isAutoExpire=="boolean"?q.isAutoExpire:null;return{id:String(J.ruleId||J.ruleName||B),ruleOrSeverityLabel:ie,l1:{minutes:q.level1PostAssistTime??void 0,roles:ae},l2:{minutes:q.level2PostAssistTime??void 0,roles:ls},l3:{minutes:q.level3PostAssistTime??void 0,roles:cs},actions:Qs,notify:Xs,humanLoop:us,isAutoExpire:ds}});Je(re)},[ge,e,Ae,_e]);const ne=f.useMemo(()=>t.map(U=>({label:U.DisplayName,value:U.SeverityId})),[t]),Ze=f.useMemo(()=>e.map(U=>({label:U.Name,value:U.RuleId})),[e]),Qe=f.useMemo(()=>ye.map(U=>({label:U.userRoleName,value:U.userRoleId})),[ye]),ze=f.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(U=>({label:`${U}`,value:U})),[]);f.useEffect(()=>{let U=!1;async function re(){try{K(!0),D(null);const J=await l.getAdminSettings();if(!U&&J){const B=Hn(J.sortBy);u(B),y(B),E(!1)}}catch(J){if(!U){const B=J instanceof Error?J.message:"Failed to load admin settings";D(B)}}finally{U||K(!1)}}return re(),()=>{U=!0}},[]),f.useEffect(()=>{if(!N)return;const U=ie=>{const q=Number(ie);return!isNaN(q)&&q>0?q:void 0},re=ie=>{const q=Number(ie);return!isNaN(q)&&q>0?q:void 0},J=(ge||[]).find(ie=>ie?.ruleId===N||ie?.ruleName===N||ie?.RuleId===N),B=As(J?.escalationSettings);if(B&&typeof B=="object"){oe(re(B.level1PostAssistTime)),x(U(B.level1UserRoleId)),k(re(B.level2PostAssistTime)),L(U(B.level2UserRoleId)),I(re(B.level3PostAssistTime)),W(U(B.level3UserRoleId));const ie=Array.isArray(B.escalationSettingsActionTypeIds)?B.escalationSettingsActionTypeIds:[];H(ie.map(q=>String(q))),le(Array.isArray(B.thirdPartyId)?B.thirdPartyId:[]),ce(!!B.humanLoop),xe(!!B.isAutoExpire)}},[V,N,ge]);const ia=async()=>{try{ee(!0);const U=await o.getRules(),re=Array.isArray(U)?U:Array.isArray(U?.data)?U.data:[];ke(re);const J=re.map((B,ie)=>{const q=e.find(Ne=>Ne.RuleId===(B.ruleId||B.ruleName))?.Name||B.ruleName||B.Name||"-",ae=As(B.escalationSettings??B.EscalationSettings),ls=typeof ae.level1UserRoleId=="number"&&ae.level1UserRoleId>0?[ae.level1UserRoleId]:[],cs=typeof ae.level2UserRoleId=="number"&&ae.level2UserRoleId>0?[ae.level2UserRoleId]:[],Js=typeof ae.level3UserRoleId=="number"&&ae.level3UserRoleId>0?[ae.level3UserRoleId]:[],Ks=(Array.isArray(ae.escalationSettingsActionTypeIds)?ae.escalationSettingsActionTypeIds:[]).map(Ne=>Ae[Ne]||String(Ne)),us=(Array.isArray(ae.thirdPartyId)?ae.thirdPartyId:[]).map(Ne=>_e[Ne]||String(Ne)),ds=typeof ae.humanLoop=="boolean"?ae.humanLoop:null;return{id:String(B.ruleId||B.ruleName||ie),ruleOrSeverityLabel:q,l1:{minutes:ae.level1PostAssistTime??void 0,roles:ls},l2:{minutes:ae.level2PostAssistTime??void 0,roles:cs},l3:{minutes:ae.level3PostAssistTime??void 0,roles:Js},actions:Ks,notify:us,humanLoop:ds}});Je(J)}catch(U){console.error("Failed to refetch entries",U)}finally{ee(!1)}};f.useEffect(()=>{let U=!1;return(async()=>{try{const re=await o.getLookups();if(U||!re)return;const J={};if(Array.isArray(re.thirdParties))for(const ie of re.thirdParties)typeof ie.thirdPartyId=="number"&&(J[ie.thirdPartyId]=ie.thirdPartyName);vt(J);const B=Array.isArray(re.userRoles)?re.userRoles.map(ie=>({userRoleId:ie.userRoleId??ie.id,userRoleName:ie.userRoleName??ie.name})):[];U||ct(B.length?B:s||[])}catch(re){console.error("Error loading lookups",re)}})(),()=>{U=!0}},[]);const oa=async()=>{_(!0);try{const U=await l.setAdminSettings({sortBy:c,groupBy:"string"});U?.responseStatus&&U?.data&&we.toast.success(U.data),y(c),E(!1)}catch(U){console.error("Error saving admin settings",U)}finally{_(!1)}},la=()=>{u(p),E(!1)},ca=async()=>{O(!0),a?.({ruleId:N,levels:[{minutes:he,role:j},{minutes:S,role:w},{minutes:T,role:P}],actions:Z,thirdPartyIds:X,humanLoop:Se,isAutoExpire:ue});try{if(N){const re=Array.isArray(Z)?Z.map(ae=>Number.isNaN(Number(ae))?ae:Number(ae)):[],J=(ge||[]).find(ae=>ae?.ruleId===N||ae?.ruleName===N||ae?.RuleId===N),B=typeof J?.recordId=="number"?J.recordId:J?.ruleId||J?.RuleId||void 0;if(!J||!B){we.toast.error("Unable to find rule identifier for update");return}const ie={...J,escalationSettings:{level1UserRoleId:j??0,level1PostAssistTime:he??0,level2UserRoleId:w??0,level2PostAssistTime:S??0,level3UserRoleId:P??0,level3PostAssistTime:T??0,escalationSettingsActionTypeIds:re,thirdPartyId:Array.isArray(X)?X:[],humanLoop:Se,isAutoExpire:ue}},q=await o.updateRule(B,ie);q?.responseStatus||q?.Success||q?.success?(we.toast.success("Escalation settings saved"),await ia(),M(void 0),oe(void 0),x(void 0),k(void 0),L(void 0),I(void 0),W(void 0),H([]),le([]),ce(!1),xe(!1)):we.toast.error(q?.errorMessage||q?.Message||"Error saving Escalation Settings")}}catch(re){console.error("Error saving escalation settings",re)}finally{O(!1)}},ua=()=>{u("By Severity"),m("By severity"),R("rules"),g(void 0),M(void 0),oe(void 0),x(void 0),k(void 0),L(void 0),I(void 0),W(void 0),H([]),le([]),ce(!1),xe(!1)};return i.jsxs("div",{className:"w-full",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(Wn,{level:4,className:"!mb-2",children:"Admin Settings"}),i.jsxs(d.Spin,{spinning:G,children:[b?i.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",b]}):null,i.jsx(nl,{sortBy:c,groupBy:h,onChange:U=>{U.sortBy&&(u(U.sortBy),E(!0)),U.groupBy&&(m(U.groupBy),E(!0))},showActions:v,onSave:oa,onClear:la,saving:C})]})]}),i.jsx(d.Divider,{className:"my-6"}),i.jsxs("div",{children:[i.jsx(Wn,{level:4,className:"!mb-4",children:"Escalation Settings"}),i.jsx(rl,{escBasis:V,setEscBasis:R,selectedSeverity:z,setSelectedSeverity:g,selectedRule:N,setSelectedRule:M,severityOptions:ne,ruleOptions:Ze,minsOptions:ze,roleOptions:Qe,l1mins:he,setL1mins:oe,l1role:j,setL1role:x,l2mins:S,setL2mins:k,l2role:w,setL2role:L,l3mins:T,setL3mins:I,l3role:P,setL3role:W,actions:Z,setActions:H,thirdPartyIds:X,setThirdPartyIds:le,humanLoop:Se,setHumanLoop:ce,onClear:ua,onSave:ca,saving:os,onActionTypesLoaded:U=>{const re={};for(const J of U)typeof J.actionTypeId=="number"&&(re[J.actionTypeId]=J.name);je(re)},isAutoExpire:ue,setAutoExpire:xe})]}),i.jsx(d.Divider,{className:"my-6"}),i.jsx(al,{entries:Tt,userRoles:ye,loading:Y||r,onEdit:U=>{R("rules");const re=Tt.find(B=>B.id===U),J=e.find(B=>B.RuleId===U)||(re?e.find(B=>B.Name===re.ruleOrSeverityLabel):void 0);M(J?J.RuleId:U)}}),i.jsx(d.Divider,{className:"my-6"}),i.jsx(Xr,{userRoles:ye,rules:e,rawRules:n}),i.jsx(d.Divider,{})]})}const{Title:Vn,Text:zt}=d.Typography;function ol({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:a}=Oe(),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,p]=f.useState(null),[y,v]=f.useState(null),[E,C]=f.useState({inApp:!1,sms:!1,email:!1}),[_,G]=f.useState([]),[K,b]=f.useState(!0),[D,V]=f.useState(!1);f.useEffect(()=>{let g=!1;return(async()=>{try{const N=await a.getPreferenceSettings();if(g||!N)return;C({inApp:!!N.inApp,sms:!!N.sms,email:!!N.email});const M=Hn(N.sortBy);c(M==="By Created Date"?"By Created Date":"By Severity"),p(on(N.doNotDisturbStart)),v(on(N.doNotDisturbEnd)),Array.isArray(N.anomalyIds)&&h(new Set(N.anomalyIds.map(he=>String(he))))}catch(N){console.error("Error in loading my preferences: ",N)}})(),()=>{g=!0}},[]),f.useEffect(()=>{let g=!1;return(async()=>{try{b(!0);const N=await r.getLookups();if(g||!N)return;const M=Array.isArray(N.anomalies)?N.anomalies:[];G(M)}catch(N){console.error("Failed to load anomalies lookups",N)}finally{g||b(!1)}})(),()=>{g=!0}},[]);const R=g=>{h(N=>{const M=new Set(N);return M.has(g)?M.delete(g):M.add(g),M})},z=async()=>{s?.({sortBy:l,subscribedRuleIds:Array.from(u),dnd:{from:m,to:y},channels:E});try{V(!0);const g=m?m.format?.("HH:mm:ss")??"00:00:00":"00:00:00",N=y?y.format?.("HH:mm:ss")??"00:00:00":"00:00:00",M=Array.from(u).map(oe=>Number(oe)).filter(oe=>Number.isFinite(oe)),he=await a.setPreferenceSettings({anomalyIds:M,doNotDisturbStart:g,doNotDisturbEnd:N,inApp:!!E.inApp,sms:!!E.sms,email:!!E.email,sortBy:l});he?.responseStatus&&we.toast.success(he?.data||"Preferences updated successfully.")}catch(g){console.error("Error in saving my preferences: ",g)}finally{V(!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(zt,{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(Vn,{level:5,className:"!mb-2",children:"Anomalies"}),K?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(_)?_:[]).map(g=>{const N=String(g.recordId),M=g.anomalyName;return i.jsx(d.Checkbox,{checked:u.has(N),onChange:()=>R(N),children:M},N)})})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx(Vn,{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(zt,{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(zt,{children:"From"}),i.jsx(d.TimePicker,{value:m,onChange:g=>p(g),format:"HH:mm"})]}),i.jsxs(d.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(zt,{children:"To"}),i.jsx(d.TimePicker,{value:y,onChange:g=>v(g),format:"HH:mm"})]})]})]})})}),i.jsxs(d.Row,{gutter:[24,12],children:[i.jsx(d.Col,{children:i.jsx(d.Checkbox,{checked:E.inApp,onChange:g=>C({...E,inApp:g.target.checked}),children:"In-app"})}),i.jsx(d.Col,{children:i.jsx(d.Checkbox,{checked:E.sms,onChange:g=>C({...E,sms:g.target.checked}),children:"SMS"})}),i.jsx(d.Col,{children:i.jsx(d.Checkbox,{checked:E.email,onChange:g=>C({...E,email:g.target.checked}),children:"Email"})})]})]}),i.jsx(d.Divider,{}),i.jsxs(d.Space,{className:"gap-3",children:[i.jsx(d.Button,{onClick:n,disabled:D,children:"Cancel"}),i.jsx(d.Button,{type:"primary",onClick:z,loading:D,children:"Save"})]})]})}function ta({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r}){return i.jsx("div",{className:"w-full",children:i.jsx(ea,{severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r})})}const ll="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=",cl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAKeSURBVHgBjVVdbtpAEJ5ZmygPfTBSaVWpUt0bwFuURgJOUG5QeoLACbw+QeAEwA3SGxgJokh9CDeI+xSpTRU/Imw8nbFZx6QQGAl5d2fm229+dkDYI2f6oaUAOwhWExBcPnL4FwFBSLCexpCMf+qPi12++PKgpR/cGOwRa1pwQIjgOoWkf6s/hOVzVd588R+/xWjf5YAY8Y0+ErQrZFfnXg3lK3uGm7A+RISOxfbit5NprqBxxgBoeEIVHehqtI9lSz+5McaaITaA2J17bycFaBayMOS8IaT+zHuv4Ui58P9oAvB4Ga0paUgqbFGswL5idIcIx3P9DCiXrQB7iJawcTiCkMMIUlj7Jo8zr6Yv/EfRXXIqRnzUxnP9u46Id8Q5Sslq3+pqWErHAPKqvxROC/ZMuJwKJ8bkPouUkrYUqgt5IgMDKAxfAYT8nAZnmR2A5J47YSjrFKyOYpZN2SiIJ8YjRqVfASyAFVg9s2F2gXwRsClMXdnYcFpq5PyiQ8KEilaywc79+aEow2i7fdCF46SIpuTvCGi2kWSXjCM4QqS4Zl3yjwQ0UySwrBfGRJNjQKW4ZrmEpL45CxUDTGWdgmoZgxOoDA6zxYgr7ZudhWk3x6Sp4kl0nZmgujQhcH5Cvqy/Hxi5hdL+dgsWxR2rma4FkLeDw+PMM243+t2YB0jDDI9nMBquyWqI3tjmLYguQfqDzxebty/DIcnePr9jfePVfDhSzv2/Hs8LAY3kMmFfTCl+rl3uu1GWF6Jx+X3vkpa+58jeeNyXvY3Pd8N+a0hvgK9ge3hMTmG5CPTnSICWcFpXaDfZUcAck99yOnZM/id3hcmAFV/hgEilU6p0TcH2gpZYS98xc/kXUJ8YImPFzfeLh0cgXbMp8n/yD3ySPZSK0MWKAAAAAElFTkSuQmCC";function is(){const{config:t}=Oe();return{timeZoneDetails:f.useMemo(()=>{const s=t.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone;return{timeZoneUniqueId:"",ianaTimeZoneId:s,timeZoneName:s,offset:""}},[t.timeZone]),loading:!1}}function ul(t){const e=(t.status||"").toLowerCase()==="completed"?i.jsx("img",{src:ll,alt:"completed",style:{width:20,height:20}}):i.jsx("img",{src:cl,alt:"pending",style:{width:20,height:20}});return{title:i.jsxs("div",{className:"flex flex-col gap-0 min-w-0",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{className:"block text-sm break-words mb-1 overflow-visible whitespace-normal",children:i.jsx("b",{children:t.title})}),t.description?i.jsx("span",{className:"text-gray-500 text-xs",children:t.description}):null]}),t.timestamp?i.jsx("span",{className:"text-gray-500 text-xs",children:t.timestamp}):null]}),icon:e,description:null}}function dl({data:t}){const{timeZoneDetails:e}=is();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(ul)})})]})]})},{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:Xt(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 ml=({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}=is(),u=a?.length?a.map(m=>{const p=(m?.status||m?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",y=m?.createdDate?Xt(m.createdDate,c?.ianaTimeZoneId):m?.timestamp?Xt(m.timestamp,c?.ianaTimeZoneId):"";return{status:p,title:m?.status||m?.eventStatus||"Status Update",description:m?.description||m?.actionNotes||"",timestamp:y}}):[],h={summary:l,timeline:u,notifications:o??[]};return i.jsx(dl,{data:h})};const fl=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),hl=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),Bn=t=>{const e=hl(t);return e.charAt(0).toUpperCase()+e.slice(1)},sa=(...t)=>t.filter((e,s,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===s).join(" ").trim(),yl=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var gl={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 pl=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,...gl,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:sa("lucide",r),...!a&&!yl(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,h])=>f.createElement(u,h)),...Array.isArray(a)?a:[a]]));const Ys=(t,e)=>{const s=f.forwardRef(({className:n,...r},a)=>f.createElement(pl,{ref:a,iconNode:e,className:sa(`lucide-${fl(Bn(t))}`,`lucide-${t}`,n),...r}));return s.displayName=Bn(t),s};const Sl=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],xl=Ys("loader-circle",Sl);const wl=[["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"}]],na=Ys("maximize-2",wl);const vl=[["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"}]],Tl=Ys("minimize-2",vl),Al=({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(Tl,{size:20}):i.jsx(na,{size:20})})]})}):null};function Nl(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 Zn(t){const e=(t?.mediaType||t?.type||"").toString().toLowerCase();return e==="video"||e==="mp4"?!0:Nl(t?.mediaUrl||t)}function bl(t){const e=t;return e?Array.isArray(e)?e:[e]:[]}const kl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Il={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},El=({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(""),[p,y]=f.useState(!1),v=f.useRef(null),[E,C]=f.useState("details"),[_,G]=f.useState(void 0),K=Ps(),{alerts:b}=Oe(),{timeZoneDetails:D}=is(),[V,R]=f.useState(!1),[z,g]=f.useState(void 0),[N,M]=f.useState(void 0),[he,oe]=f.useState({}),[j,x]=f.useState({}),S=s?.originalData||{},{eventName:k,alertId:w,timestamp:L,description:T,spaceName:I,assignTeam:P,priority:W,statusType:Z,id:H,alertDetails:X,statusHistory:le,mediaDetails:Se,alertNumber:ce}=S,ue=O=>{const Y=String(O||"").toLowerCase();return Y==="delivered"||Y==="sent"?"Delivered":Y==="failed"?"Failed":"Queued"},xe=O=>({name:O?.receipientName||O?.recipientName||"-",role:O?.receipientRoleName||"",phone:O?.receipentPhoneNumber||O?.recipientPhoneNumber||O?.receipientEmail||O?.recipientEmail||"",status:ue(O?.messageStatus),notificationReceipientType:O?.notificationReceipientType||""}),Ae=(O,Y)=>{const ee=Y.map(xe),ge=ee.filter(Qe=>Qe.status==="Delivered").length,ke=Y.map(Qe=>Qe?.sentAt).filter(Boolean).sort((Qe,ze)=>new Date(ze).getTime()-new Date(Qe).getTime())[0],ne=Y[0]||{},Ze=[ne?.severityName,ne?.anomalyName].filter(Boolean).join(" - ")||`${O} Notification`;return{channelLabel:`${O} Notification`,sentAt:ke||"",messageTitle:Ze,messageBody:"",total:ee.length,delivered:ge,recipients:ee}},je=O=>{const Y=new Map;return(O||[]).forEach(ee=>{const ge=String(ee?.notificationType||"Unknown"),ke=Y.get(ge)||[];ke.push(ee),Y.set(ge,ke)}),Array.from(Y.entries()).map(([ee,ge])=>Ae(ee,ge))},_e=async O=>{try{const Y=await b.getAlertNotifications(O),ee=je(Y);G(ee)}catch{G(void 0)}};f.useEffect(()=>{if(E!=="track"||!H)return;let O=!1;return _e(H).then(()=>{O&&G(void 0)}),()=>{O=!0}},[E,H]),f.useEffect(()=>{t&&C(o)},[t,o]);const ye=l==="archived"||["completed","false positive"].includes(String(Z||"").toLowerCase()),ct=O=>{const Y=String(O?.value||"").toLowerCase(),ee=String(O?.statusName||"").toLowerCase();return Y.includes("reopen")||ee.includes("reopen")},Tt=(r||[]).filter(O=>{const Y=ct(O);return typeof l<"u"?l==="archived"?Y:!Y:ye?Y:!Y}).map(O=>({value:O.value,label:O.statusName})),Je=f.useMemo(()=>bl(Se),[Se]);f.useEffect(()=>{let O=!1;const Y=new AbortController,ee=async ne=>{if(ne){O||oe(Ze=>({...Ze,[ne]:!1}));try{const Ze=await fetch(ne,{method:"HEAD",signal:Y.signal});if(Ze.ok){O||oe(ze=>({...ze,[ne]:!0}));return}if(Ze.status===404){O||oe(ze=>({...ze,[ne]:!1}));return}if(!(await fetch(ne,{method:"GET",signal:Y.signal})).ok)throw new Error("Media not available");O||oe(ze=>({...ze,[ne]:!0}))}catch{O||oe(Ze=>({...Ze,[ne]:!1}))}}};oe({});const ge=Je.filter(ne=>!Zn(ne)).map(ne=>ne?.mediaUrl||ne).filter(ne=>typeof ne=="string"&&ne.length>0),ke={};return ge.forEach(ne=>{ke[ne]=!0}),x(ke),ge.forEach(ne=>ee(ne)),()=>{O=!0,Y.abort()}},[Je]);const os=async()=>{try{y(!0);const O={alertUniqueId:w,alertId:H,status:c?String(c):void 0,notes:h.trim(),modifiedBy:0},Y=await K.mutateAsync(O);if(Y?.responseStatus||Y?.Success){const ee=Y?.Message||Y?.data||"Alert updated successfully.";we.toast.success(ee,{autoClose:1500,onClose:()=>{n(),e()}}),u(void 0),m("")}else{const ee=Y?.errorMessage||Y?.Message||"Failed to update alert status";we.toast.error(ee)}}catch(O){console.error("Error updating alert status:",O),we.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:E==="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:os,loading:p,children:p?"Saving...":"Save Changes"})]}):null,children:s&&i.jsx(d.Tabs,{activeKey:E,onChange:O=>C(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:k||"Alert Event"}),X?.firstName?i.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",X?.firstName," ",X?.lastName||""," ",X?.residentId||""]}):null,i.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp: ",Xt(L,D?.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]}),P&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",P]}),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 ${kl[String(W)]||"#DFE4EA"}`,backgroundColor:Il[String(W)]},children:["Severity: ",W||"N/A"]}),i.jsxs(d.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(Z||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",Z||"N/A"]})]}),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:Tt,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"}),Je.length>1?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>v.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(it.LeftOutlined,{style:{fontSize:12}})}),i.jsx("button",{type:"button",onClick:()=>v.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(it.RightOutlined,{style:{fontSize:12}})})]}):null]}),Je.length?i.jsx("div",{className:"w-full",children:i.jsx(d.Carousel,{ref:v,dots:!0,className:"w-full",children:Je.map((O,Y)=>{const ee=O.mediaUrl||O,ge=Zn(O),ke=!ge&&j[String(ee)];return i.jsxs("div",{className:"flex justify-center items-center relative",children:[ge?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:ee}),"Your browser does not support the video tag."]}):i.jsxs("div",{className:"relative w-full flex justify-center items-center min-h-[200px]",children:[ke&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg z-10",children:i.jsx(xl,{size:32,className:"animate-spin text-gray-400"})}),i.jsx("img",{src:ee,alt:O.caption||`media-${Y}`,className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg transition-opacity duration-200 ${ke?"opacity-0":"opacity-100"}`,onLoad:()=>x(ne=>({...ne,[String(ee)]:!1})),onError:()=>x(ne=>({...ne,[String(ee)]:!1}))},String(ee))]}),O.caption&&i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:O.caption}),!ge&&he[String(ee)]?i.jsx("button",{onClick:()=>{R(!0),g(ee),M(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(na,{size:20})}):null]},String(ee)||Y)})})}):null]})}),i.jsx(Al,{isOpen:V,onClose:()=>R(!1),src:z||"",type:N||"image"})]})},{key:"track",label:"Track Incident",children:i.jsx(ml,{alertId:w,id:H,priority:W,spaceName:I,alertNumber:ce,statusHistory:le,notifGroups:_})}]})})};function ra(){const{alerts:t}=Oe(),e=ot.useQuery({queryKey:["alerts","statusList"],queryFn:()=>t.getAlertStatusList(),staleTime:5*6e4});return{list:e.data??[],loading:e.isLoading,error:e.error,refetch:e.refetch}}function _s({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:p}=ra(),{timeZoneDetails:y}=is(),v=y?.timeZoneName??"UTC",E=y?.ianaTimeZoneId??"UTC";function C(D,V){c(D),h(V?.tab??"details"),K(V?.sourceTab??"active"),o(!0)}function _(){o(!1)}const[G,K]=f.useState("active"),b=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(Kr,{label:v,timeZone:E})})]}),i.jsx(d.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:D=>{D==="active"&&n?.()},items:[{key:"active",label:"Active",children:i.jsx($s,{data:t,loading:e,pageSize:10,columns:s||[],onAlertIdClick:C,onRefetch:n,onPageChange:r})},{key:"archived",label:"Archived",children:i.jsx(Qr,{alerts:t,loading:e,columns:s||[],onAlertIdClick:C})},{key:"settings",label:"Settings",children:i.jsx(Ml,{})}]}),i.jsx(El,{isModalOpen:a,handleModalClose:_,selectedRow:b,fetchAlertLogs:()=>{},alertStatusList:m,alertStatusLoading:p,initialTab:u,sourceTab:G})]})}function Ml(){const[t,e]=f.useState([]),[s,n]=f.useState([]),[r,a]=f.useState([]),[o,l]=f.useState([]),[c,u]=f.useState(!0),{rules:h}=Oe();return f.useEffect(()=>{let m=!0;return(async()=>{try{const p=await h.getRules();if(!m)return;l(Array.isArray(p)?p:[]);const y=(p||[]).map((v,E)=>({RuleId:v.ruleId||v.ruleName||String(E),Name:v.ruleName||v.Name||"-",Description:v.ruleDesc||v.Description||"",SeverityId:0}));e(y);try{const v=await h.getLookups(),E=Array.isArray(v?.userRoles)?v.userRoles.map(C=>({userRoleId:C.userRoleId??C.id,userRoleName:C.userRoleName??C.name})):[];n(E),a(Array.isArray(v?.severities)?v.severities:[])}catch{}}catch{}finally{m&&u(!1)}})(),()=>{m=!1}},[]),i.jsx(ta,{severities:r,rules:t,userRoles:s,rawRules:o,loadingRules:c})}function aa(t=1){const{alerts:e}=Oe(),s=ot.useQuery({queryKey:["alerts","list",t],queryFn:()=>e.listAlerts({pageNumber:t,pageSize:10}),staleTime:3e4});return{alerts:s.data??[],loading:s.isLoading,error:s.error,refetch:s.refetch}}function Ol(t){const[e,s]=f.useState(1),{alerts:n,loading:r,refetch:a}=aa(e);return i.jsx(_s,{alerts:n,loading:r,columns:t.columns,onRefetch:a,onPageChange:s})}function jl({tenant:t,apiDomain:e,rulesDomain:s,headers:n,timeZone:r,userManagementDomain:a,alerts:o,loading:l,columns:c}){const[u]=f.useState(()=>new ot.QueryClient),h=f.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return i.jsx(ot.QueryClientProvider,{client:u,children:i.jsx(Yn,{tenant:t,override:h,timeZone:r,userManagementDomain:a,children:Array.isArray(o)?i.jsx(_s,{alerts:o,loading:!!l,columns:c}):i.jsx(Ol,{columns:c})})})}function Cl(t){const{alerts:e}=Oe(),s=ot.useQuery({queryKey:["alerts","report",t],queryFn:()=>e.getAlertsReport(t),staleTime:6e4});return{data:s.data??[],loading:s.isLoading,error:s.error,refetch:s.refetch}}const Dl=[{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=Xr;exports.AlertConsole=_s;exports.AlertConsoleWidget=jl;exports.AlertsTable=$s;exports.ApiProvider=Yn;exports.ArchivedTable=Qr;exports.Clock=Kr;exports.DataTable=_n;exports.MyPreferencesPanel=ol;exports.SettingsPanel=ea;exports.SettingsTabs=ta;exports.exampleAlertColumns=Dl;exports.useAlertStatusList=ra;exports.useAlerts=aa;exports.useAlertsReport=Cl;exports.useApi=Oe;exports.useUpdateAlertStatus=Ps;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),f=require("react"),d=require("antd"),it=require("@ant-design/icons"),xe=require("react-toastify"),ot=require("@tanstack/react-query"),da="#FF3B30",ma="#FF9500",fa="#FFCC00",ha="#34C759",Lt={critical:da,high:ma,medium:fa,low:ha},tn={Critical:Lt.critical,High:Lt.high,Medium:Lt.medium,Low:Lt.low};function ya(t){return tn[t]||tn.Low}function sn(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 nn(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 Hn="",ga=Hn,pa="",Sa="",xa="",wa="",rn={snl:{alerts:Hn,rules:ga},schools:{alerts:pa,rules:Sa},transit:{alerts:xa,rules:wa}};function Ie(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function va(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}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 Me(t,e){const s={...e.headers,...va()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Aa(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=Ie(t.baseUrl,"/api/Alert"),n=await Me(s,{method:"GET",headers:e});return Array.isArray(n)?n:[]},async getAlertStatusList(){const s=Ie(t.baseUrl,"/api/Alert/AlertStatusList"),n=await Me(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getAlertsReport(s){const n=Ie(t.baseUrl,"/Alerts/GetAlertsReport"),r=Ft(n,s),a=await Me(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Ie(t.baseUrl,"/api/Alert/status");return Me(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=Ie(t.baseUrl,"/api/Alert/GetAdminSettings"),n=await Me(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("userId"in n)return n}return null},async setAdminSettings(s){const n=Ie(t.baseUrl,"/api/Alert/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Me(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Ie(t.baseUrl,"/api/Alert/GetPreferenceSettings"),n=await Me(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=Ie(t.baseUrl,"/api/Alert/SetPreferenceSettings"),r=await Me(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,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=Ie(t.baseUrl,"/api/Alert/GetNotifications"),r=Ft(n,{alertId:s}),a=await Me(r,{method:"GET",headers:e});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]},async notifyFamilyMembers(s){const n=Ie(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=Ft(n,{alertId:s});return Me(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const a=Ie(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),o=Ft(a,{alertId:s,isEmail:n,isSMS:r});return Me(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Ie(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Me(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Ie(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Me(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null}}}function an(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ta(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function $t(t,e){const s={...e.headers,...Ta()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Na(t){const e={"Content-Type":"application/json",...t.headers||{}},s=an(t.baseUrl,"/api/Rules"),n=an(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 ba(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Gt={exports:{}},ka=Gt.exports,on;function Ia(){return on||(on=1,(function(t,e){(function(s,n){t.exports=n()})(ka,(function(){var s=1e3,n=6e4,r=36e5,a="millisecond",o="second",l="minute",c="hour",u="day",h="week",m="month",p="quarter",y="year",w="date",M="Invalid Date",C=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,_=/\[([^\]]+)]|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,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(j){var x=["th","st","nd","rd"],S=j%100;return"["+j+(x[(S-20)%10]||x[S]||x[0])+"]"}},ee=function(j,x,S){var k=String(j);return!k||k.length>=x?j:""+Array(x+1-k.length).join(S)+j},b={s:ee,z:function(j){var x=-j.utcOffset(),S=Math.abs(x),k=Math.floor(S/60),v=S%60;return(x<=0?"+":"-")+ee(k,2,"0")+":"+ee(v,2,"0")},m:function j(x,S){if(x.date()<S.date())return-j(S,x);var k=12*(S.year()-x.year())+(S.month()-x.month()),v=x.clone().add(k,m),U=S-v<0,A=x.clone().add(k+(U?-1:1),m);return+(-(k+(S-v)/(U?v-A:A-v))||0)},a:function(j){return j<0?Math.ceil(j)||0:Math.floor(j)},p:function(j){return{M:m,y,w:h,d:u,D:w,h:c,m:l,s:o,ms:a,Q:p}[j]||String(j||"").toLowerCase().replace(/s$/,"")},u:function(j){return j===void 0}},D="en",W={};W[D]=G;var R="$isDayjsObject",H=function(j){return j instanceof ue||!(!j||!j[R])},g=function j(x,S,k){var v;if(!x)return D;if(typeof x=="string"){var U=x.toLowerCase();W[U]&&(v=U),S&&(W[U]=S,v=U);var A=x.split("-");if(!v&&A.length>1)return j(A[0])}else{var E=x.name;W[E]=x,v=E}return!k&&v&&(D=v),v||!k&&D},N=function(j,x){if(H(j))return j.clone();var S=typeof x=="object"?x:{};return S.date=j,S.args=arguments,new ue(S)},O=b;O.l=g,O.i=H,O.w=function(j,x){return N(j,{locale:x.$L,utc:x.$u,x:x.$x,$offset:x.$offset})};var ue=(function(){function j(S){this.$L=g(S.locale,null,!0),this.parse(S),this.$x=this.$x||S.x||{},this[R]=!0}var x=j.prototype;return x.parse=function(S){this.$d=(function(k){var v=k.date,U=k.utc;if(v===null)return new Date(NaN);if(O.u(v))return new Date;if(v instanceof Date)return new Date(v);if(typeof v=="string"&&!/Z$/i.test(v)){var A=v.match(C);if(A){var E=A[2]-1||0,P=(A[7]||"0").substring(0,3);return U?new Date(Date.UTC(A[1],E,A[3]||1,A[4]||0,A[5]||0,A[6]||0,P)):new Date(A[1],E,A[3]||1,A[4]||0,A[5]||0,A[6]||0,P)}}return new Date(v)})(S),this.init()},x.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()},x.$utils=function(){return O},x.isValid=function(){return this.$d.toString()!==M},x.isSame=function(S,k){var v=N(S);return this.startOf(k)<=v&&v<=this.endOf(k)},x.isAfter=function(S,k){return N(S)<this.startOf(k)},x.isBefore=function(S,k){return this.endOf(k)<N(S)},x.$g=function(S,k,v){return O.u(S)?this[k]:this.set(v,S)},x.unix=function(){return Math.floor(this.valueOf()/1e3)},x.valueOf=function(){return this.$d.getTime()},x.startOf=function(S,k){var v=this,U=!!O.u(k)||k,A=O.p(S),E=function(ce,de){var Se=O.w(v.$u?Date.UTC(v.$y,de,ce):new Date(v.$y,de,ce),v);return U?Se:Se.endOf(u)},P=function(ce,de){return O.w(v.toDate()[ce].apply(v.toDate("s"),(U?[0,0,0,0]:[23,59,59,999]).slice(de)),v)},V=this.$W,B=this.$M,Y=this.$D,K="set"+(this.$u?"UTC":"");switch(A){case y:return U?E(1,0):E(31,11);case m:return U?E(1,B):E(0,B+1);case h:var ae=this.$locale().weekStart||0,we=(V<ae?V+7:V)-ae;return E(U?Y-we:Y+(6-we),B);case u:case w:return P(K+"Hours",0);case c:return P(K+"Minutes",1);case l:return P(K+"Seconds",2);case o:return P(K+"Milliseconds",3);default:return this.clone()}},x.endOf=function(S){return this.startOf(S,!1)},x.$set=function(S,k){var v,U=O.p(S),A="set"+(this.$u?"UTC":""),E=(v={},v[u]=A+"Date",v[w]=A+"Date",v[m]=A+"Month",v[y]=A+"FullYear",v[c]=A+"Hours",v[l]=A+"Minutes",v[o]=A+"Seconds",v[a]=A+"Milliseconds",v)[U],P=U===u?this.$D+(k-this.$W):k;if(U===m||U===y){var V=this.clone().set(w,1);V.$d[E](P),V.init(),this.$d=V.set(w,Math.min(this.$D,V.daysInMonth())).$d}else E&&this.$d[E](P);return this.init(),this},x.set=function(S,k){return this.clone().$set(S,k)},x.get=function(S){return this[O.p(S)]()},x.add=function(S,k){var v,U=this;S=Number(S);var A=O.p(k),E=function(B){var Y=N(U);return O.w(Y.date(Y.date()+Math.round(B*S)),U)};if(A===m)return this.set(m,this.$M+S);if(A===y)return this.set(y,this.$y+S);if(A===u)return E(1);if(A===h)return E(7);var P=(v={},v[l]=n,v[c]=r,v[o]=s,v)[A]||1,V=this.$d.getTime()+S*P;return O.w(V,this)},x.subtract=function(S,k){return this.add(-1*S,k)},x.format=function(S){var k=this,v=this.$locale();if(!this.isValid())return v.invalidDate||M;var U=S||"YYYY-MM-DDTHH:mm:ssZ",A=O.z(this),E=this.$H,P=this.$m,V=this.$M,B=v.weekdays,Y=v.months,K=v.meridiem,ae=function(de,Se,Te,je){return de&&(de[Se]||de(k,U))||Te[Se].slice(0,je)},we=function(de){return O.s(E%12||12,de,"0")},ce=K||function(de,Se,Te){var je=de<12?"AM":"PM";return Te?je.toLowerCase():je};return U.replace(_,(function(de,Se){return Se||(function(Te){switch(Te){case"YY":return String(k.$y).slice(-2);case"YYYY":return O.s(k.$y,4,"0");case"M":return V+1;case"MM":return O.s(V+1,2,"0");case"MMM":return ae(v.monthsShort,V,Y,3);case"MMMM":return ae(Y,V);case"D":return k.$D;case"DD":return O.s(k.$D,2,"0");case"d":return String(k.$W);case"dd":return ae(v.weekdaysMin,k.$W,B,2);case"ddd":return ae(v.weekdaysShort,k.$W,B,3);case"dddd":return B[k.$W];case"H":return String(E);case"HH":return O.s(E,2,"0");case"h":return we(1);case"hh":return we(2);case"a":return ce(E,P,!0);case"A":return ce(E,P,!1);case"m":return String(P);case"mm":return O.s(P,2,"0");case"s":return String(k.$s);case"ss":return O.s(k.$s,2,"0");case"SSS":return O.s(k.$ms,3,"0");case"Z":return A}return null})(de)||A.replace(":","")}))},x.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},x.diff=function(S,k,v){var U,A=this,E=O.p(k),P=N(S),V=(P.utcOffset()-this.utcOffset())*n,B=this-P,Y=function(){return O.m(A,P)};switch(E){case y:U=Y()/12;break;case m:U=Y();break;case p:U=Y()/3;break;case h:U=(B-V)/6048e5;break;case u:U=(B-V)/864e5;break;case c:U=B/r;break;case l:U=B/n;break;case o:U=B/s;break;default:U=B}return v?U:O.a(U)},x.daysInMonth=function(){return this.endOf(m).$D},x.$locale=function(){return W[this.$L]},x.locale=function(S,k){if(!S)return this.$L;var v=this.clone(),U=g(S,k,!0);return U&&(v.$L=U),v},x.clone=function(){return O.w(this.$d,this)},x.toDate=function(){return new Date(this.valueOf())},x.toJSON=function(){return this.isValid()?this.toISOString():null},x.toISOString=function(){return this.$d.toISOString()},x.toString=function(){return this.$d.toUTCString()},j})(),le=ue.prototype;return N.prototype=le,[["$ms",a],["$s",o],["$m",l],["$H",c],["$W",u],["$M",m],["$y",y],["$D",w]].forEach((function(j){le[j[1]]=function(x){return this.$g(x,j[0],j[1])}})),N.extend=function(j,x){return j.$i||(j(x,ue,N),j.$i=!0),N},N.locale=g,N.isDayjs=H,N.unix=function(j){return N(1e3*j)},N.en=W[D],N.Ls=W,N.p={},N}))})(Gt)),Gt.exports}var Ma=Ia();const Ea=ba(Ma);function qn(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 Gn(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 ln(t){const{hours:e,minutes:s,seconds:n}=Gn(t);return Ea().hour(e).minute(s).second(n).millisecond(0)}function Ce(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Oa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function cn(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,...Oa()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.Message||`HTTP ${n.status}`;throw new Error(o)}return a}const me=(...t)=>t.find(e=>e!=null);function Nt(t,e,s={}){const n={};for(const r of e){const a=s[r]??r.charAt(0).toUpperCase()+r.slice(1);n[r]=t?.[a]??t?.[r]}return n}function ja(t){return Array.isArray(t)?t.map(e=>Nt(e,["alertLogId","alertId","status","description","actionNotes","createdDate","createdBy","modifiedDate","modifiedBy"])):t}function Ca(t){return{id:String(me(t?.AlertId,t?.alertId)??""),alertNumber:me(t?.AlertNumber,t?.alertNumber),priority:me(t?.Priority,t?.priority,"Low"),timestamp:me(t?.UpdatedUtc,t?.timestamp,""),statusType:me(t?.Status,t?.statusType,""),description:me(t?.Description,t?.description,""),eventName:me(t?.EventName,t?.eventName),ruleName:me(t?.RuleName,t?.ruleName),spaceName:me(t?.SpaceName,t?.spaceName),assignTeam:me(t?.AssignTeam,t?.assignTeam),cameraName:me(t?.CameraName,t?.cameraName),type:me(t?.Type,t?.type),mediaDetails:me(t?.MediaDetails,t?.mediaDetails,t?.MediaUrls,t?.mediaUrls),additionalMedia:me(t?.AdditionalMedia,t?.additionalMedia),timeElapsed:me(t?.TimeElapsed,t?.timeElapsed),timeRemaining:me(t?.TimeRemaining,t?.timeRemaining),anomalyName:me(t?.AnomalyName,t?.anomalyName),alertDetails:me(t?.AlertDetails,t?.alertDetails),statusHistory:ja(me(t?.StatusHistory,t?.statusHistory)),isEmailSent:me(t?.IsEmailSent,t?.isEmailSent),isSMSSent:me(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:me(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function Da(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=Ce(t.baseUrl,"/api/detectionpolicy/alerts?customerId=99e5c8b5-b9d4-4d35-8885-7f121c532664"),n=await De(s,{method:"GET",headers:e});return Array.isArray(n?.Items)?(n?.Items).map(Ca):[]},async getAlertStatusList(){const s=Ce(t.baseUrl,"/api/detectionpolicy/alerts/StatusList"),n=await De(s,{method:"GET",headers:e});return(Array.isArray(n)?n:[]).map(a=>Nt(a,["alertStatusId","value","statusName"]))},async getAlertsReport(s){const n=Ce(t.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),r=cn(n,s),a=await De(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Ce(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=Ce(t.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),n=await De(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n.Data??n;if(r&&typeof r=="object")return Nt(r,["userId","isAdminSetting","sortBy"],{sortBy:"SortOption"})}return null},async setAdminSettings(s){const n=Ce(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=Ce(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=Ce(t.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),r=u=>{const{hours:h,minutes:m,seconds:p}=Gn(u);return(h*3600+m*60+p)*1e7},a={Settings:{UserId:0,AnomalyIds:Array.isArray(s?.anomalyIds)?s.anomalyIds.map(u=>String(u)):[],DoNotDisturbStart:{Ticks:r(s?.doNotDisturbStart)},DoNotDisturbEnd:{Ticks:r(s?.doNotDisturbEnd)},InApp:!!s?.inApp,SMS:!!s?.sms,Email:!!s?.email,SortBy:s?.sortBy??""}},o=await 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=Ce(t.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),r=cn(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=>Nt(l,["alertNotificationSentId","alertId","notificationType","receipientName","receipentPhoneNumber","messageSID","messageStatus","receipientEmail","notificationReceipientType","sentAt"]))},async getTimeZoneMasters(){const s=Ce(t.baseUrl,"/api/TimeZoneMaster"),n=await De(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n.Data:[]).map(a=>Nt(a,["timeZoneUniqueId","ianaTimeZoneId","timeZoneName","offset"]))},async getMyAppPreferences(){const s=Ce(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=Ce(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 Ra(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function He(t,e){const s={...e.headers,...Ra()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Ua(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/api/detectionpolicy/rules",t.baseUrl).toString();return{async getRules(){const n=await He(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n?.Data:[]).map(a=>({...a,ruleId:a.ruleId??a.RuleId,ruleName:a.ruleName??a.RuleName??a.Name,escalationSettings:a.escalationSettings??a.EscalationSettings}))},async setEscalationSettings(n){return He(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=g=>new URL(g,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[He(n("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:e}),He(n("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:e}),He(n("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:e}),He(n("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:e}),He(n("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:e}),He(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,l,c,u,h,m]=await Promise.allSettled(a),p=g=>g.status==="fulfilled"&&Array.isArray(g.value)?g.value:[],y=p(o),w=p(l),M=p(c),C=p(u),_=p(h),G=m.status==="fulfilled"?m.value:null;let ee=[];Array.isArray(G)?ee=G:Array.isArray(G?.Data)?ee=G.Data:Array.isArray(G?.data)&&(ee=G.data);const b=y.map(g=>({actionTypeId:Number(g?.ActionTypeId),name:g?.DisplayName??g?.Name??""})),D=w.map(g=>({recordId:g?.AnomalyId,anomalyName:g?.DisplayName??g?.Name??""})),W=M.map(g=>({thirdPartyId:Number(g?.ThirdPartyId),thirdPartyName:g?.ThirdPartyName??g?.Name??""})),R=ee.map(g=>({userRoleId:g.UserRoleId??g.userRoleId??g.Id??g.id??0,userRoleName:g.UserRoleName??g.userRoleName??g.Name??g.name??""})),H={actionTypes:b,anomalies:D,thirdParties:W};return C.length&&(H.severities=C),_.length&&(H.scheduleTypes=_),R.length&&(H.userRoles=R),H},async updateRule(n,r){const a=`${s}/${n}`,{escalationSettings:o,...l}=r??{};return He(a,{method:"PUT",headers:e,body:JSON.stringify({...l,CustomerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",Version:{DeDupWindowSeconds:0,IncludeSubjectInHash:!0},EscalationSettings:o??{}})})}}}function La(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Qe(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 Fa(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/list-rule",t.baseUrl).toString();return{async getRules(){const n=await Qe(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 Qe(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=R=>new URL(R,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[Qe(n("/api/ActionTypeMaster/GetAll"),{method:"GET",headers:e}),Qe(n("/api/anomaly/anomaly-list"),{method:"POST",headers:e,body:JSON.stringify({RuleLevel:1})}),Qe(n("/api/Lookup/ThirdParties"),{method:"GET",headers:e}),Qe(n("/api/anomaly/severity-list"),{method:"GET",headers:e}),Qe(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,l,c,u,h]=await Promise.allSettled(a),m=R=>{if(R.status!=="fulfilled")return[];const H=R.value;return Array.isArray(H)?H:Array.isArray(H?.data)?H.data:[]},p=m(o),y=m(l),w=m(c),M=m(u),C=h.status==="fulfilled"?h.value:null,_=p.map(R=>({actionTypeId:R?.ActionTypeUniqueId,name:R?.Name??""})),G=y.map(R=>({recordId:R?.AnomalyId,anomalyName:R?.DisplayName??R?.Name??""})),ee=w.map(R=>({thirdPartyId:Number(R?.ThirdPartyId),thirdPartyName:R?.ThirdPartyName??R?.Name??""}));let b=[];Array.isArray(C)?b=C:Array.isArray(C?.Data)?b=C.Data:Array.isArray(C?.data)&&(b=C.data);const D=b.map(R=>({userRoleId:R.userRoleId??0,userRoleName:R.userRoleName??""})),W={actionTypes:_,anomalies:G,thirdParties:ee};return M.length&&(W.severities=M.map(R=>({SeverityId:R.SeverityId,DisplayName:R.SeverityName??R.DisplayName??""}))),D.length&&(W.userRoles=D),W},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??{},p=(m.escalationSettingsActionTypeIds??[]).filter(w=>w!=null&&!Number.isNaN(w)),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:p,ThirdPartyIds:m.thirdPartyId??[],HumanLoop:m.humanLoop??!1};return Qe(a,{method:"POST",headers:e,body:JSON.stringify({...h,RuleId:l??h.RuleId??n,RuleName:c??h.RuleName,RuleDesc:u??h.RuleDesc??null,ActionTypeUniqueIdList:p,EscalationSettings:y})})}}}function Re(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function $a(){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 Ue(t,e){const s={...e.headers,...$a()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Pa(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Re(t.baseUrl,"/api/Alerts"),r=Pt(n,{pageSize:s?.pageSize??10,pageNumber:s?.pageNumber??1}),a=await Ue(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async getAlertStatusList(){const s=Re(t.baseUrl,"/api/Alerts/GetAlertStatus"),n=await Ue(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 Ue(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 Ue(n,{method:"PUT",headers:e,body:JSON.stringify(r??{})})},async getAdminSettings(){const s=Re(t.baseUrl,"/api/Alerts/GetAdminSettings"),n=await Ue(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 Ue(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Re(t.baseUrl,"/api/Alerts/GetPreferenceSettings"),n=await Ue(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 Ue(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 Ue(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 Ue(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Re(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Ue(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 Ue(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 Yn=f.createContext(null);function _n({tenant:t="snl",override:e,timeZone:s,userManagementDomain:n,children:r}){const a=f.useMemo(()=>{const l=e?.alertsBaseUrl?.trim()||rn[t]?.alerts||"";let c=e?.rulesBaseUrl?.trim()||rn[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:()=>Da(l),transit:()=>Pa(l),snl:()=>Aa(l)},h={schools:()=>Ua({...c,userManagementBaseUrl:a.userManagementDomain}),transit:()=>Fa({...c,userManagementBaseUrl:a.userManagementDomain}),snl:()=>Na({baseUrl:a.alertsBaseUrl,headers:a.headers})};return{config:a,alerts:u[a.tenant](),rules:h[a.tenant]()}},[a]);return i.jsx(Yn.Provider,{value:o,children:r})}function Oe(){const t=f.useContext(Yn);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}const Wa={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Va={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},$s=6,Ps=7;function un(t,e,s){const n=t===$s,r=t===Ps,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 Ba(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 Za(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 hs(t,e){return`${t}-${e?"email":"sms"}`}function Wt(t){return t===$s||t===Ps}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 za=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function Ha({value:t,onChange:e,options:s}){return i.jsx(ss,{className:"w-[140px]",value:t,onChange:e,options:s||za})}const qa=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function Ga({value:t,onChange:e,options:s}){return i.jsx(ss,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||qa})}function Ya({value:t,onChange:e,options:s}){return i.jsx(ss,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const _a=[{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 Ja({value:t,onChange:e,options:s}){return i.jsx(ss,{className:"w-[130px]",value:t,onChange:e,options:s||_a})}function Jn({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 Ws({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,p]=f.useState("All"),[y,w]=f.useState("All"),[M,C]=f.useState("All"),[_,G]=f.useState("All"),[ee,b]=f.useState(""),[D,W]=f.useState([{label:"All",value:"All"}]),[R,H]=f.useState(new Set),{rules:g,alerts:N}=Oe(),O={6:{title:"Email",kind:"icon",icon:i.jsx(it.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:i.jsx(it.MessageOutlined,{})}},ue=f.useMemo(()=>Ba(t),[t]),le=f.useMemo(()=>Za(t),[t]);f.useEffect(()=>{let A=!0;return(async()=>{try{const E=await g.getLookups(),V=(Array.isArray(E.thirdParties)?E.thirdParties:[]).map(B=>({label:B.thirdPartyName,value:String(B.thirdPartyId)}));A&&W([{label:"All",value:"All"},...V])}catch(E){console.error("Error loading third party options",E)}})(),()=>{A=!1}},[g]);const j=f.useMemo(()=>(t||[]).some(A=>nn(A).length>0),[t]),x=f.useMemo(()=>(t||[]).filter(A=>{const E=m==="All"||A.priority===m,P=`${A.id} ${A.description} ${A.statusType}`.toLowerCase(),V=!ee||P.includes(ee.toLowerCase()),B=y==="All"||(A.anomalyName||"").toLowerCase()===y.toLowerCase(),Y=M==="All"||(A.spaceName||"").toLowerCase()===M.toLowerCase(),K=!j||_==="All"||nn(A).includes(Number(_)),ae=!h||!["completed","false positive"].includes(String(A.statusType||"").toLowerCase());return E&&V&&B&&Y&&K&&ae}),[t,m,ee,y,M,_,j,h]),S=ue,k=a?.length?a:le,v=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:A=>i.jsx(d.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Va[A]}`,backgroundColor:Wa[A]},children:A})},{title:"Tracker",key:"tracker",width:140,render:(A,E)=>i.jsx("a",{onClick:P=>{P.preventDefault(),l?.(E,{tab:"track",sourceTab:"active"})},className:"text-blue-600 hover:underline",children:"Tracker"})},{title:"Call to action/Human in the loop",key:"actions",width:320,render:(A,E)=>{if(o)return i.jsx(i.Fragment,{children:o(E)});const P=async(je,_e)=>{const ct=hs(E.id,je);H(ye=>new Set(ye).add(ct));try{const ye=await N.sendSMSorEmailNotifications?.(E.id,je,_e);ye?.responseStatus||ye?.Success||ye?.success?(xe.toast.success(ye?.message||ye.data||(je?"Email sent successfully":"SMS sent successfully")),c?.()):xe.toast.error(ye?.message||ye?.data||ye?.errorMessage||"Failed to send notification")}catch(ye){xe.toast.error(ye?.message||"Failed to send notification")}finally{H(ye=>{const ut=new Set(ye);return ut.delete(ct),ut})}},V=$s,B=Ps,Y=O[V],K=O[B],ae=un(V,E,Y?.title),we=un(B,E,K?.title),ce=hs(E.id,!0),de=hs(E.id,!1),Se=Wt(V)&&R.has(ce),Te=Wt(B)&&R.has(de);return i.jsxs(d.Space,{size:"middle",children:[i.jsx(d.Tooltip,{title:ae.tooltipTitle,children:i.jsx(d.Button,{size:"small",disabled:ae.isDisabled,loading:Se,onClick:Wt(V)?()=>P(!0,!1):void 0,icon:!Se&&Y?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:ae.buttonText})},String(V)),i.jsx(d.Tooltip,{title:we.tooltipTitle,children:i.jsx(d.Button,{size:"small",disabled:we.isDisabled,loading:Te,onClick:Wt(B)?()=>P(!1,!0):void 0,icon:!Te&&K?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:we.buttonText})},String(B))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(A,E)=>{const P=E?.timeElapsed,V=E?.timeRemaining,B=P?sn(P):0,Y=V?sn(V):0,K=Math.round(B/(B+Y)*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:P??"-"})]}),i.jsx(d.Progress,{percent:K,showInfo:!1,size:"small",strokeColor:ya(E.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:V??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(A,E)=>i.jsxs("div",{children:[i.jsx("a",{onClick:P=>{P.preventDefault(),l?.(E,{sourceTab:"active"})},className:"inline-block mb-1 text-blue-600",children:E.alertNumber}),i.jsx("div",{className:"text-black/65",children:A})]})}],U=n&&n.length?n:v;return i.jsx("div",{children:i.jsx(Jn,{rowKey:"id",data:x,columns:U,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(Ha,{value:m,onChange:p,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(Ga,{value:y,onChange:w,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(Ya,{value:M,onChange:C,options:k})]})}),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(Ja,{value:_,onChange:G,options:D})]})}),i.jsx(d.Col,{flex:"auto"}),i.jsx(d.Col,{flex:"none",children:i.jsx(d.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:b,onChange:A=>b(A.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}function Vs(){const{alerts:t}=Oe(),e=ot.useQueryClient();return ot.useMutation({mutationFn:s=>t.updateAlertStatus(s),onSuccess:()=>{e.invalidateQueries({queryKey:["alerts","list"]}),e.invalidateQueries({queryKey:["alerts","report"]})}})}class lt extends Error{}class Qa extends lt{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class Ka extends lt{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class Xa extends lt{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class ht extends lt{}class Qn extends lt{constructor(e){super(`Invalid unit ${e}`)}}class ve extends lt{}class Ke extends lt{constructor(){super("Zone is an abstract class")}}const T="numeric",Be="short",Ee="long",Qt={year:T,month:T,day:T},Kn={year:T,month:Be,day:T},ei={year:T,month:Be,day:T,weekday:Be},Xn={year:T,month:Ee,day:T},er={year:T,month:Ee,day:T,weekday:Ee},tr={hour:T,minute:T},sr={hour:T,minute:T,second:T},nr={hour:T,minute:T,second:T,timeZoneName:Be},rr={hour:T,minute:T,second:T,timeZoneName:Ee},ar={hour:T,minute:T,hourCycle:"h23"},ir={hour:T,minute:T,second:T,hourCycle:"h23"},or={hour:T,minute:T,second:T,hourCycle:"h23",timeZoneName:Be},lr={hour:T,minute:T,second:T,hourCycle:"h23",timeZoneName:Ee},cr={year:T,month:T,day:T,hour:T,minute:T},ur={year:T,month:T,day:T,hour:T,minute:T,second:T},dr={year:T,month:Be,day:T,hour:T,minute:T},mr={year:T,month:Be,day:T,hour:T,minute:T,second:T},ti={year:T,month:Be,day:T,weekday:Be,hour:T,minute:T},fr={year:T,month:Ee,day:T,hour:T,minute:T,timeZoneName:Be},hr={year:T,month:Ee,day:T,hour:T,minute:T,second:T,timeZoneName:Be},yr={year:T,month:Ee,day:T,weekday:Ee,hour:T,minute:T,timeZoneName:Ee},gr={year:T,month:Ee,day:T,weekday:Ee,hour:T,minute:T,second:T,timeZoneName:Ee};class Ot{get type(){throw new Ke}get name(){throw new Ke}get ianaName(){return this.name}get isUniversal(){throw new Ke}offsetName(e,s){throw new Ke}formatOffset(e,s){throw new Ke}offset(e){throw new Ke}equals(e){throw new Ke}get isValid(){throw new Ke}}let ys=null;class ns extends Ot{static get instance(){return ys===null&&(ys=new ns),ys}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Ir(e,s,n)}formatOffset(e,s){return Mt(this.offset(e),s)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}}const ks=new Map;function si(t){let e=ks.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"}),ks.set(t,e)),e}const ni={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function ri(t,e){const s=t.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(s),[,r,a,o,l,c,u,h]=n;return[o,r,a,l,c,u,h]}function ai(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:a,value:o}=s[r],l=ni[a];a==="era"?n[l]=o:$(l)||(n[l]=parseInt(o,10))}return n}const gs=new Map;class Ye extends Ot{static create(e){let s=gs.get(e);return s===void 0&&gs.set(e,s=new Ye(e)),s}static resetCache(){gs.clear(),ks.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 Ir(e,s,n,this.name)}formatOffset(e,s){return Mt(this.offset(e),s)}offset(e){if(!this.valid)return NaN;const s=new Date(e);if(isNaN(s))return NaN;const n=si(this.name);let[r,a,o,l,c,u,h]=n.formatToParts?ai(n,s):ri(n,s);l==="BC"&&(r=-Math.abs(r)+1);const p=as({year:r,month:a,day:o,hour:c===24?0:c,minute:u,second:h,millisecond:0});let y=+s;const w=y%1e3;return y-=w>=0?w:1e3+w,(p-y)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let dn={};function ii(t,e={}){const s=JSON.stringify([t,e]);let n=dn[s];return n||(n=new Intl.ListFormat(t,e),dn[s]=n),n}const Is=new Map;function Ms(t,e={}){const s=JSON.stringify([t,e]);let n=Is.get(s);return n===void 0&&(n=new Intl.DateTimeFormat(t,e),Is.set(s,n)),n}const Es=new Map;function oi(t,e={}){const s=JSON.stringify([t,e]);let n=Es.get(s);return n===void 0&&(n=new Intl.NumberFormat(t,e),Es.set(s,n)),n}const Os=new Map;function li(t,e={}){const{base:s,...n}=e,r=JSON.stringify([t,n]);let a=Os.get(r);return a===void 0&&(a=new Intl.RelativeTimeFormat(t,e),Os.set(r,a)),a}let bt=null;function ci(){return bt||(bt=new Intl.DateTimeFormat().resolvedOptions().locale,bt)}const js=new Map;function pr(t){let e=js.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),js.set(t,e)),e}const Cs=new Map;function ui(t){let e=Cs.get(t);if(!e){const s=new Intl.Locale(t);e="getWeekInfo"in s?s.getWeekInfo():s.weekInfo,"minimalDays"in e||(e={...Sr,...e}),Cs.set(t,e)}return e}function di(t){const e=t.indexOf("-x-");e!==-1&&(t=t.substring(0,e));const s=t.indexOf("-u-");if(s===-1)return[t];{let n,r;try{n=Ms(t).resolvedOptions(),r=t}catch{const c=t.substring(0,s);n=Ms(c).resolvedOptions(),r=c}const{numberingSystem:a,calendar:o}=n;return[r,a,o]}}function mi(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function fi(t){const e=[];for(let s=1;s<=12;s++){const n=F.utc(2009,s,1);e.push(t(n))}return e}function hi(t){const e=[];for(let s=1;s<=7;s++){const n=F.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 yi(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||pr(t.locale).numberingSystem==="latn"}class gi{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=oi(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):qs(e,3);return ge(s,this.padTo)}}}class pi{constructor(e,s,n){this.opts=n,this.originalZone=void 0;let r;if(this.opts.timeZone)this.dt=e;else if(e.zone.type==="fixed"){const o=-1*(e.offset/60),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 a={...this.opts};a.timeZone=a.timeZone||r,this.dtf=Ms(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 Si{constructor(e,s,n){this.opts={style:"long",...n},!s&&br()&&(this.rtf=li(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):Wi(s,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,s){return this.rtf?this.rtf.formatToParts(e,s):[]}}const Sr={firstDay:1,minimalDays:4,weekend:[6,7]};class se{static fromOpts(e){return se.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,s,n,r,a=!1){const o=e||he.defaultLocale,l=o||(a?"en-US":ci()),c=s||he.defaultNumberingSystem,u=n||he.defaultOutputCalendar,h=Rs(r)||he.defaultWeekSettings;return new se(l,c,u,h,o)}static resetCache(){bt=null,Is.clear(),Es.clear(),Os.clear(),js.clear(),Cs.clear()}static fromObject({locale:e,numberingSystem:s,outputCalendar:n,weekSettings:r}={}){return se.create(e,s,n,r)}constructor(e,s,n,r,a){const[o,l,c]=di(e);this.locale=o,this.numberingSystem=s||l||null,this.outputCalendar=n||c||null,this.weekSettings=r,this.intl=mi(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=yi(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:se.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,Rs(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,Or,()=>{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]=fi(o)}return this.monthsCache[a][e]})}weekdays(e,s=!1){return Vt(this,e,Dr,()=>{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]=hi(a=>this.extract(a,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return Vt(this,void 0,()=>Rr,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[F.utc(2016,11,13,9),F.utc(2016,11,13,19)].map(s=>this.extract(s,e,"dayperiod"))}return this.meridiemCache})}eras(e){return Vt(this,e,Ur,()=>{const s={era:e};return this.eraCache[e]||(this.eraCache[e]=[F.utc(-40,1,1),F.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 gi(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new pi(e,this.intl,s)}relFormatter(e={}){return new Si(this.intl,this.isEnglish(),e)}listFormatter(e={}){return ii(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||pr(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:kr()?ui(this.locale):Sr}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 ps=null;class be extends Ot{static get utcInstance(){return ps===null&&(ps=new be(0)),ps}static instance(e){return e===0?be.utcInstance:new be(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new be(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${Mt(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Mt(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,s){return Mt(this.fixed,s)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type==="fixed"&&e.fixed===this.fixed}get isValid(){return!0}}class xi extends Ot{constructor(e){super(),this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function et(t,e){if($(t)||t===null)return e;if(t instanceof Ot)return t;if(bi(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?ns.instance:s==="utc"||s==="gmt"?be.utcInstance:be.parseSpecifier(s)||Ye.create(t)}else return tt(t)?be.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new xi(t)}const Bs={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},mn={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]},wi=Bs.hanidec.replace(/[\[|\]]/g,"").split("");function vi(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(Bs.hanidec)!==-1)e+=wi.indexOf(t[s]);else for(const r in mn){const[a,o]=mn[r];n>=a&&n<=o&&(e+=n-a)}}return parseInt(e,10)}else return e}const Ds=new Map;function Ai(){Ds.clear()}function Pe({numberingSystem:t},e=""){const s=t||"latn";let n=Ds.get(s);n===void 0&&(n=new Map,Ds.set(s,n));let r=n.get(e);return r===void 0&&(r=new RegExp(`${Bs[s]}${e}`),n.set(e,r)),r}let fn=()=>Date.now(),hn="system",yn=null,gn=null,pn=null,Sn=60,xn,wn=null;class he{static get now(){return fn}static set now(e){fn=e}static set defaultZone(e){hn=e}static get defaultZone(){return et(hn,ns.instance)}static get defaultLocale(){return yn}static set defaultLocale(e){yn=e}static get defaultNumberingSystem(){return gn}static set defaultNumberingSystem(e){gn=e}static get defaultOutputCalendar(){return pn}static set defaultOutputCalendar(e){pn=e}static get defaultWeekSettings(){return wn}static set defaultWeekSettings(e){wn=Rs(e)}static get twoDigitCutoffYear(){return Sn}static set twoDigitCutoffYear(e){Sn=e%100}static get throwOnInvalid(){return xn}static set throwOnInvalid(e){xn=e}static resetCaches(){se.resetCache(),Ye.resetCache(),F.resetCache(),Ai()}}class Ve{constructor(e,s){this.reason=e,this.explanation=s}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const xr=[0,31,59,90,120,151,181,212,243,273,304,334],wr=[0,31,60,91,121,152,182,213,244,274,305,335];function Fe(t,e){return new Ve("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function Zs(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 vr(t,e,s){return s+(jt(t)?wr:xr)[e-1]}function Ar(t,e){const s=jt(t)?wr:xr,n=s.findIndex(a=>a<e),r=e-s[n];return{month:n+1,day:r}}function zs(t,e){return(t-e+7)%7+1}function Kt(t,e=4,s=1){const{year:n,month:r,day:a}=t,o=vr(n,r,a),l=zs(Zs(n,r,a),s);let c=Math.floor((o-l+14-e)/7),u;return c<1?(u=n-1,c=Et(u,e,s)):c>Et(n,e,s)?(u=n+1,c=1):u=n,{weekYear:u,weekNumber:c,weekday:l,...os(t)}}function vn(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:a}=t,o=zs(Zs(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}=Ar(u,c);return{year:u,month:h,day:m,...os(t)}}function Ss(t){const{year:e,month:s,day:n}=t,r=vr(e,s,n);return{year:e,ordinal:r,...os(t)}}function An(t){const{year:e,ordinal:s}=t,{month:n,day:r}=Ar(e,s);return{year:e,month:n,day:r,...os(t)}}function Tn(t,e){if(!$(t.localWeekday)||!$(t.localWeekNumber)||!$(t.localWeekYear)){if(!$(t.weekday)||!$(t.weekNumber)||!$(t.weekYear))throw new ht("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 Ti(t,e=4,s=1){const n=rs(t.weekYear),r=$e(t.weekNumber,1,Et(t.weekYear,e,s)),a=$e(t.weekday,1,7);return n?r?a?!1:Fe("weekday",t.weekday):Fe("week",t.weekNumber):Fe("weekYear",t.weekYear)}function Ni(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 Tr(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 Nr(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 $(t){return typeof t>"u"}function tt(t){return typeof t=="number"}function rs(t){return typeof t=="number"&&t%1===0}function bi(t){return typeof t=="string"}function ki(t){return Object.prototype.toString.call(t)==="[object Date]"}function br(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function kr(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function Ii(t){return Array.isArray(t)?t:[t]}function Nn(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 Mi(t,e){return e.reduce((s,n)=>(s[n]=t[n],s),{})}function pt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Rs(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 Ei(t,e){return t-e*Math.floor(t/e)}function ge(t,e=2){const s=t<0;let n;return s?n="-"+(""+-t).padStart(e,"0"):n=(""+t).padStart(e,"0"),n}function Xe(t){if(!($(t)||t===null||t===""))return parseInt(t,10)}function nt(t){if(!($(t)||t===null||t===""))return parseFloat(t)}function Hs(t){if(!($(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function qs(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=Ei(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 bn(t,e,s){return-zs(Zs(t,1,e),s)+e-1}function Et(t,e=4,s=1){const n=bn(t,e,s),r=bn(t+1,e,s);return(yt(t)-n+r)/7}function Us(t){return t>99?t:t>he.twoDigitCutoffYear?1900+t:2e3+t}function Ir(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 Mr(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)]=Mr(r)}return s}function Mt(t,e){const s=Math.trunc(Math.abs(t/60)),n=Math.trunc(Math.abs(t%60)),r=t>=0?"+":"-";switch(e){case"short":return`${r}${ge(s,2)}:${ge(n,2)}`;case"narrow":return`${r}${s}${n>0?`:${n}`:""}`;case"techie":return`${r}${ge(s,2)}${ge(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function os(t){return Mi(t,["hour","minute","second","millisecond"])}const Oi=["January","February","March","April","May","June","July","August","September","October","November","December"],Er=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ji=["J","F","M","A","M","J","J","A","S","O","N","D"];function Or(t){switch(t){case"narrow":return[...ji];case"short":return[...Er];case"long":return[...Oi];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 jr=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Cr=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Ci=["M","T","W","T","F","S","S"];function Dr(t){switch(t){case"narrow":return[...Ci];case"short":return[...Cr];case"long":return[...jr];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const Rr=["AM","PM"],Di=["Before Christ","Anno Domini"],Ri=["BC","AD"],Ui=["B","A"];function Ur(t){switch(t){case"narrow":return[...Ui];case"short":return[...Ri];case"long":return[...Di];default:return null}}function Li(t){return Rr[t.hour<12?0:1]}function Fi(t,e){return Dr(e)[t.weekday-1]}function $i(t,e){return Or(e)[t.month-1]}function Pi(t,e){return Ur(e)[t.year<0?0:1]}function Wi(t,e,s="always",n=!1){const r={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},a=["hours","minutes","seconds"].indexOf(t)===-1;if(s==="auto"&&a){const m=t==="days";switch(e){case 1:return m?"tomorrow":`next ${r[t][0]}`;case-1:return m?"yesterday":`last ${r[t][0]}`;case 0:return m?"today":`this ${r[t][0]}`}}const o=Object.is(e,-0)||e<0,l=Math.abs(e),c=l===1,u=r[t],h=n?c?u[1]:u[2]||u[1]:c?r[t][0]:t;return o?`${l} ${h} ago`:`in ${l} ${h}`}function kn(t,e){let s="";for(const n of t)n.literal?s+=n.val:s+=e(n.val);return s}const Vi={D:Qt,DD:Kn,DDD:Xn,DDDD:er,t:tr,tt:sr,ttt:nr,tttt:rr,T:ar,TT:ir,TTT:or,TTTT:lr,f:cr,ff:dr,fff:fr,ffff:yr,F:ur,FF:mr,FFF:hr,FFFF:gr};class Ae{static create(e,s={}){return new Ae(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 Vi[e]}constructor(e,s){this.opts=s,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,s){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...s}).format()}dtFormatter(e,s={}){return this.loc.dtFormatter(e,{...this.opts,...s})}formatDateTime(e,s){return this.dtFormatter(e,s).format()}formatDateTimeParts(e,s){return this.dtFormatter(e,s).formatToParts()}formatInterval(e,s){return this.dtFormatter(e.start,s).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,s){return this.dtFormatter(e,s).resolvedOptions()}num(e,s=0,n=void 0){if(this.opts.forceSimple)return ge(e,s);const r={...this.opts};return s>0&&(r.padTo=s),n&&(r.signDisplay=n),this.loc.numberFormatter(r).format(e)}formatDateTimeFromString(e,s){const n=this.loc.listingMode()==="en",r=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",a=(y,w)=>this.loc.extract(e,y,w),o=y=>e.isOffsetFixed&&e.offset===0&&y.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,y.format):"",l=()=>n?Li(e):a({hour:"numeric",hourCycle:"h12"},"dayperiod"),c=(y,w)=>n?$i(e,y):a(w?{month:y}:{month:y,day:"numeric"},"month"),u=(y,w)=>n?Fi(e,y):a(w?{weekday:y}:{weekday:y,month:"long",day:"numeric"},"weekday"),h=y=>{const w=Ae.macroTokenToFormatOpts(y);return w?this.formatWithSystemDefault(e,w):y},m=y=>n?Pi(e,y):a({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?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 kn(Ae.parseFormat(s),p)}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)=>p=>{const y=r(p);if(y){const w=m.isNegativeDuration&&y!==m.largestUnit?n:1;let M;return this.opts.signMode==="negativeLargestOnly"&&y!==m.largestUnit?M="never":this.opts.signMode==="all"?M="always":M="auto",this.num(h.get(y)*w,p.length,M)}else return p},o=Ae.parseFormat(s),l=o.reduce((h,{literal:m,val:p})=>m?h:h.concat(p),[]),c=e.shiftTo(...l.map(r).filter(h=>h)),u={isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]};return kn(o,a(c,u))}}const Lr=/[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 Fr(...t){return(e,s)=>{const n={};let r;for(r=0;r<t.length;r++)n[t[r]]=Xe(e[s+r]);return[n,null,s+r]}}const $r=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,Bi=`(?:${$r.source}?(?:\\[(${Lr.source})\\])?)?`,Gs=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Pr=RegExp(`${Gs.source}${Bi}`),Ys=RegExp(`(?:[Tt]${Pr.source})?`),Zi=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,zi=/(\d{4})-?W(\d\d)(?:-?(\d))?/,Hi=/(\d{4})-?(\d{3})/,qi=Fr("weekYear","weekNumber","weekDay"),Gi=Fr("year","ordinal"),Yi=/(\d{4})-(\d\d)-(\d\d)/,Wr=RegExp(`${Gs.source} ?(?:${$r.source}|(${Lr.source}))?`),_i=RegExp(`(?: ${Wr.source})?`);function gt(t,e,s){const n=t[e];return $(n)?s:Xe(n)}function Ji(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:Hs(t[e+3])},null,e+4]}function Ct(t,e){const s=!t[e]&&!t[e+1],n=is(t[e+1],t[e+2]),r=s?null:be.instance(n);return[{},r,e+3]}function Dt(t,e){const s=t[e]?Ye.create(t[e]):null;return[{},s,e+1]}const Qi=RegExp(`^T?${Gs.source}$`),Ki=/^-?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 Xi(t){const[e,s,n,r,a,o,l,c,u]=t,h=e[0]==="-",m=c&&c[0]==="-",p=(y,w=!1)=>y!==void 0&&(w||y&&h)?-y:y;return[{years:p(nt(s)),months:p(nt(n)),weeks:p(nt(r)),days:p(nt(a)),hours:p(nt(o)),minutes:p(nt(l)),seconds:p(nt(c),c==="-0"),milliseconds:p(Hs(u),m)}]}const eo={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function _s(t,e,s,n,r,a,o){const l={year:e.length===2?Us(Xe(e)):Xe(e),month:Er.indexOf(s)+1,day:Xe(n),hour:Xe(r),minute:Xe(a)};return o&&(l.second=Xe(o)),t&&(l.weekday=t.length>3?jr.indexOf(t)+1:Cr.indexOf(t)+1),l}const to=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function so(t){const[,e,s,n,r,a,o,l,c,u,h,m]=t,p=_s(e,r,n,s,a,o,l);let y;return c?y=eo[c]:u?y=0:y=is(h,m),[p,new be(y)]}function no(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const ro=/^(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$/,ao=/^(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$/,io=/^(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 In(t){const[,e,s,n,r,a,o,l]=t;return[_s(e,r,n,s,a,o,l),be.utcInstance]}function oo(t){const[,e,s,n,r,a,o,l]=t;return[_s(e,l,s,n,r,a,o),be.utcInstance]}const lo=St(Zi,Ys),co=St(zi,Ys),uo=St(Hi,Ys),mo=St(Pr),Vr=xt(Ji,vt,Ct,Dt),fo=xt(qi,vt,Ct,Dt),ho=xt(Gi,vt,Ct,Dt),yo=xt(vt,Ct,Dt);function go(t){return wt(t,[lo,Vr],[co,fo],[uo,ho],[mo,yo])}function po(t){return wt(no(t),[to,so])}function So(t){return wt(t,[ro,In],[ao,In],[io,oo])}function xo(t){return wt(t,[Ki,Xi])}const wo=xt(vt);function vo(t){return wt(t,[Qi,wo])}const Ao=St(Yi,_i),To=St(Wr),No=xt(vt,Ct,Dt);function bo(t){return wt(t,[Ao,Vr],[To,No])}const Mn="Invalid Duration",Br={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}},ko={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},...Br},Le=146097/400,dt=146097/4800,Io={years:{quarters:4,months:12,weeks:Le/7,days:Le,hours:Le*24,minutes:Le*24*60,seconds:Le*24*60*60,milliseconds:Le*24*60*60*1e3},quarters:{months:3,weeks:Le/28,days:Le/4,hours:Le*24/4,minutes:Le*24*60/4,seconds:Le*24*60*60/4,milliseconds:Le*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},...Br},at=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Mo=at.slice(0).reverse();function qe(t,e,s=!1){const n={values:s?e.values:{...t.values,...e.values||{}},loc:t.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||t.conversionAccuracy,matrix:e.matrix||t.matrix};return new X(n)}function Zr(t,e){let s=e.milliseconds??0;for(const n of Mo.slice(1))e[n]&&(s+=e[n]*t[n].milliseconds);return s}function En(t,e){const s=Zr(t,e)<0?-1:1;at.reduceRight((n,r)=>{if($(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),at.reduce((n,r)=>{if($(e[r]))return n;if(n){const a=e[n]%1;e[n]-=a,e[r]+=a*t[n][r]}return r},null)}function On(t){const e={};for(const[s,n]of Object.entries(t))n!==0&&(e[s]=n);return e}class X{constructor(e){const s=e.conversionAccuracy==="longterm"||!1;let n=s?Io:ko;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||se.create(),this.conversionAccuracy=s?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=n,this.isLuxonDuration=!0}static fromMillis(e,s){return X.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 X({values:es(e,X.normalizeUnit),loc:se.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(tt(e))return X.fromMillis(e);if(X.isDuration(e))return e;if(typeof e=="object")return X.fromObject(e);throw new ve(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,s){const[n]=xo(e);return n?X.fromObject(n,s):X.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,s){const[n]=vo(e);return n?X.fromObject(n,s):X.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,s=null){if(!e)throw new ve("need to specify a reason the Duration is invalid");const n=e instanceof Ve?e:new Ve(e,s);if(he.throwOnInvalid)throw new Xa(n);return new X({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 Qn(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?Ae.create(this.loc,n).formatDurationFromString(this,e):Mn}toHuman(e={}){if(!this.isValid)return Mn;const s=e.showZeros!==!1,n=at.map(r=>{const a=this.values[r];return $(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+=qs(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},F.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?Zr(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const s=X.fromDurationLike(e),n={};for(const r of at)(pt(s.values,r)||pt(this.values,r))&&(n[r]=s.get(r)+this.get(r));return qe(this,{values:n},!0)}minus(e){if(!this.isValid)return this;const s=X.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]=Mr(e(this.values[n],n));return qe(this,{values:s},!0)}get(e){return this[X.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const s={...this.values,...es(e,X.normalizeUnit)};return qe(this,{values:s})}reconfigure({locale:e,numberingSystem:s,conversionAccuracy:n,matrix:r}={}){const o={loc:this.loc.clone({locale:e,numberingSystem:s}),matrix:r,conversionAccuracy:n};return qe(this,o)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return En(this.matrix,e),qe(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=On(this.normalize().shiftToAll().toObject());return qe(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(o=>X.normalizeUnit(o));const s={},n={},r=this.toObject();let a;for(const o of at)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;tt(r[o])&&(l+=r[o]);const c=Math.trunc(l);s[o]=c,n[o]=(l*1e3-c*1e3)/1e3}else tt(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 En(this.matrix,s),qe(this,{values:s},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const e={};for(const s of Object.keys(this.values))e[s]=this.values[s]===0?0:-this.values[s];return qe(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=On(this.values);return qe(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function s(n,r){return n===void 0||n===0?r===void 0||r===0:n===r}for(const n of at)if(!s(this.values[n],e.values[n]))return!1;return!0}}const mt="Invalid Interval";function Eo(t,e){return!t||!t.isValid?fe.invalid("missing or invalid start"):!e||!e.isValid?fe.invalid("missing or invalid end"):e<t?fe.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 fe{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,s=null){if(!e)throw new ve("need to specify a reason the Interval is invalid");const n=e instanceof Ve?e:new Ve(e,s);if(he.throwOnInvalid)throw new Ka(n);return new fe({invalid:n})}static fromDateTimes(e,s){const n=Tt(e),r=Tt(s),a=Eo(n,r);return a??new fe({start:n,end:r})}static after(e,s){const n=X.fromDurationLike(s),r=Tt(e);return fe.fromDateTimes(r,r.plus(n))}static before(e,s){const n=X.fromDurationLike(s),r=Tt(e);return fe.fromDateTimes(r.minus(n),r)}static fromISO(e,s){const[n,r]=(e||"").split("/",2);if(n&&r){let a,o;try{a=F.fromISO(n,s),o=a.isValid}catch{o=!1}let l,c;try{l=F.fromISO(r,s),c=l.isValid}catch{c=!1}if(o&&c)return fe.fromDateTimes(a,l);if(o){const u=X.fromISO(r,s);if(u.isValid)return fe.after(a,u)}else if(c){const u=X.fromISO(n,s);if(u.isValid)return fe.before(l,u)}}return fe.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?fe.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,a=0;for(;r<this.e;){const o=s[a]||this.e,l=+o>+this.e?this.e:o;n.push(fe.fromDateTimes(r,l)),r=l,a+=1}return n}splitBy(e){const s=X.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(fe.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:fe.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 fe.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(fe.fromDateTimes(s,c.time)),s=null);return fe.merge(r)}difference(...e){return fe.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?Ae.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):X.invalid(this.invalidReason)}mapEndpoints(e){return fe.fromDateTimes(e(this.s),e(this.e))}}class Bt{static hasDST(e=he.defaultZone){const s=F.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 et(e,he.defaultZone)}static getStartOfWeek({locale:e=null,locObj:s=null}={}){return(s||se.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:s=null}={}){return(s||se.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:s=null}={}){return(s||se.create(e)).getWeekendDays().slice()}static months(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||se.create(s,n,a)).months(e)}static monthsFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||se.create(s,n,a)).months(e,!0)}static weekdays(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||se.create(s,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||se.create(s,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return se.create(e).meridiems()}static eras(e="short",{locale:s=null}={}){return se.create(s,null,"gregory").eras(e)}static features(){return{relative:br(),localeWeek:kr()}}}function jn(t,e){const s=r=>r.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),n=s(e)-s(t);return Math.floor(X.fromMillis(n).as("days"))}function Oo(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=jn(c,u);return(h-h%7)/7}],["days",jn]],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 jo(t,e,s,n){let[r,a,o,l]=Oo(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=X.fromObject(a,n);return u.length>0?X.fromMillis(c,n).shiftTo(...u).plus(h):h}const Co="missing Intl.DateTimeFormat.formatToParts support";function te(t,e=s=>s){return{regex:t,deser:([s])=>e(vi(s))}}const Do=" ",zr=`[ ${Do}]`,Hr=new RegExp(zr,"g");function Ro(t){return t.replace(/\./g,"\\.?").replace(Hr,zr)}function Cn(t){return t.replace(/\./g,"").replace(Hr," ").toLowerCase()}function We(t,e){return t===null?null:{regex:RegExp(t.map(Ro).join("|")),deser:([s])=>t.findIndex(n=>Cn(s)===Cn(n))+e}}function Dn(t,e){return{regex:t,deser:([,s,n])=>is(s,n),groups:e}}function Zt(t){return{regex:t,deser:([e])=>e}}function Uo(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Lo(t,e){const s=Pe(e),n=Pe(e,"{2}"),r=Pe(e,"{3}"),a=Pe(e,"{4}"),o=Pe(e,"{6}"),l=Pe(e,"{1,2}"),c=Pe(e,"{1,3}"),u=Pe(e,"{1,6}"),h=Pe(e,"{1,9}"),m=Pe(e,"{2,4}"),p=Pe(e,"{4,6}"),y=C=>({regex:RegExp(Uo(C.val)),deser:([_])=>_,literal:!0}),M=(C=>{if(t.literal)return y(C);switch(C.val){case"G":return We(e.eras("short"),0);case"GG":return We(e.eras("long"),0);case"y":return te(u);case"yy":return te(m,Us);case"yyyy":return te(a);case"yyyyy":return te(p);case"yyyyyy":return te(o);case"M":return te(l);case"MM":return te(n);case"MMM":return We(e.months("short",!0),1);case"MMMM":return We(e.months("long",!0),1);case"L":return te(l);case"LL":return te(n);case"LLL":return We(e.months("short",!1),1);case"LLLL":return We(e.months("long",!1),1);case"d":return te(l);case"dd":return te(n);case"o":return te(c);case"ooo":return te(r);case"HH":return te(n);case"H":return te(l);case"hh":return te(n);case"h":return te(l);case"mm":return te(n);case"m":return te(l);case"q":return te(l);case"qq":return te(n);case"s":return te(l);case"ss":return te(n);case"S":return te(c);case"SSS":return te(r);case"u":return Zt(h);case"uu":return Zt(l);case"uuu":return te(s);case"a":return We(e.meridiems(),0);case"kkkk":return te(a);case"kk":return te(m,Us);case"W":return te(l);case"WW":return te(n);case"E":case"c":return te(s);case"EEE":return We(e.weekdays("short",!1),1);case"EEEE":return We(e.weekdays("long",!1),1);case"ccc":return We(e.weekdays("short",!0),1);case"cccc":return We(e.weekdays("long",!0),1);case"Z":case"ZZ":return Dn(new RegExp(`([+-]${l.source})(?::(${n.source}))?`),2);case"ZZZ":return Dn(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(C)}})(t)||{invalidReason:Co};return M.token=t,M}const Fo={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 $o(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=Fo[o];if(typeof l=="object"&&(l=l[a]),l)return{literal:!1,val:l}}function Po(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function Wo(t,e,s){const n=t.match(e);if(n){const r={};let a=1;for(const o in s)if(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 Vo(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 $(t.z)||(s=Ye.create(t.z)),$(t.Z)||(s||(s=new be(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=Hs(t.u)),[Object.keys(t).reduce((a,o)=>{const l=e(o);return l&&(a[l]=t[o]),a},{}),s,n]}let xs=null;function Bo(){return xs||(xs=F.fromMillis(1555555555555)),xs}function Zo(t,e){if(t.literal)return t;const s=Ae.macroTokenToFormatOpts(t.val),n=_r(s,e);return n==null||n.includes(void 0)?t:n}function qr(t,e){return Array.prototype.concat(...t.map(s=>Zo(s,e)))}class Gr{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=qr(Ae.parseFormat(s),e),this.units=this.tokens.map(n=>Lo(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=Po(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=Wo(e,this.regex,this.handlers),[r,a,o]=n?Vo(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 Yr(t,e,s){return new Gr(t,s).explainFromTokens(e)}function zo(t,e,s){const{result:n,zone:r,specificOffset:a,invalidReason:o}=Yr(t,e,s);return[n,r,a,o]}function _r(t,e){if(!t)return null;const n=Ae.create(e,t).dtFormatter(Bo()),r=n.formatToParts(),a=n.resolvedOptions();return r.map(o=>$o(o,t,a))}const ws="Invalid DateTime",Rn=864e13;function kt(t){return new Ve("unsupported zone",`the zone "${t.name}" is not supported`)}function vs(t){return t.weekData===null&&(t.weekData=Kt(t.c)),t.weekData}function As(t){return t.localWeekData===null&&(t.localWeekData=Kt(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function rt(t,e){const s={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new F({...s,...e,old:s})}function Jr(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 Jr(as(t),e,s)}function Un(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=X.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]=Jr(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=F.fromObject(t,{...s,zone:c,specificOffset:a});return o?u:u.setZone(l)}else return F.invalid(new Ve("unparsable",`the input "${r}" can't be parsed as ${n}`))}function Ht(t,e,s=!0){return t.isValid?Ae.create(se.create("en-US"),{allowZ:s,forceSimple:!0}).formatDateTimeFromString(t,e):null}function Ts(t,e,s){const n=t.c.year>9999||t.c.year<0;let r="";if(n&&t.c.year>=0&&(r+="+"),r+=ge(t.c.year,n?6:4),s==="year")return r;if(e){if(r+="-",r+=ge(t.c.month),s==="month")return r;r+="-"}else if(r+=ge(t.c.month),s==="month")return r;return r+=ge(t.c.day),r}function Ln(t,e,s,n,r,a,o){let l=!s||t.c.millisecond!==0||t.c.second!==0,c="";switch(o){case"day":case"month":case"year":break;default:if(c+=ge(t.c.hour),o==="hour")break;if(e){if(c+=":",c+=ge(t.c.minute),o==="minute")break;l&&(c+=":",c+=ge(t.c.second))}else{if(c+=ge(t.c.minute),o==="minute")break;l&&(c+=ge(t.c.second))}if(o==="second")break;l&&(!n||t.c.millisecond!==0)&&(c+=".",c+=ge(t.c.millisecond,3))}return r&&(t.isOffsetFixed&&t.offset===0&&!a?c+="Z":t.o<0?(c+="-",c+=ge(Math.trunc(-t.o/60)),c+=":",c+=ge(Math.trunc(-t.o%60))):(c+="+",c+=ge(Math.trunc(t.o/60)),c+=":",c+=ge(Math.trunc(t.o%60)))),a&&(c+="["+t.zone.ianaName+"]"),c}const Qr={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},Ho={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},qo={ordinal:1,hour:0,minute:0,second:0,millisecond:0},_t=["year","month","day","hour","minute","second","millisecond"],Go=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],Yo=["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 Qn(t);return e}function Fn(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 _o(t){if(It===void 0&&(It=he.now()),t.type!=="iana")return t.offset(It);const e=t.name;let s=Ls.get(e);return s===void 0&&(s=t.offset(It),Ls.set(e,s)),s}function $n(t,e){const s=et(e.zone,he.defaultZone);if(!s.isValid)return F.invalid(kt(s));const n=se.fromObject(e);let r,a;if($(t.year))r=he.now();else{for(const c of _t)$(t[c])&&(t[c]=Qr[c]);const o=Tr(t)||Nr(t);if(o)return F.invalid(o);const l=_o(s);[r,a]=Yt(t,l,s)}return new F({ts:r,zone:s,loc:n,o:a})}function Pn(t,e,s){const n=$(s.round)?!0:s.round,r=$(s.rounding)?"trunc":s.rounding,a=(l,c)=>(l=qs(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 Wn(t){let e={},s;return t.length>0&&typeof t[t.length-1]=="object"?(e=t[t.length-1],s=Array.from(t).slice(0,t.length-1)):s=Array.from(t),[e,s]}let It;const Ls=new Map;class F{constructor(e){const s=e.zone||he.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Ve("invalid input"):null)||(s.isValid?null:kt(s));this.ts=$(e.ts)?he.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=tt(e.o)&&!e.old?e.o:s.offset(this.ts);r=zt(this.ts,l),n=Number.isNaN(r.year)?new Ve("invalid input"):null,r=n?null:r,a=n?null:l}this._zone=s,this.loc=e.loc||se.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=a,this.isLuxonDateTime=!0}static now(){return new F({})}static local(){const[e,s]=Wn(arguments),[n,r,a,o,l,c,u]=s;return $n({year:n,month:r,day:a,hour:o,minute:l,second:c,millisecond:u},e)}static utc(){const[e,s]=Wn(arguments),[n,r,a,o,l,c,u]=s;return e.zone=be.utcInstance,$n({year:n,month:r,day:a,hour:o,minute:l,second:c,millisecond:u},e)}static fromJSDate(e,s={}){const n=ki(e)?e.valueOf():NaN;if(Number.isNaN(n))return F.invalid("invalid input");const r=et(s.zone,he.defaultZone);return r.isValid?new F({ts:n,zone:r,loc:se.fromObject(s)}):F.invalid(kt(r))}static fromMillis(e,s={}){if(tt(e))return e<-Rn||e>Rn?F.invalid("Timestamp out of range"):new F({ts:e,zone:et(s.zone,he.defaultZone),loc:se.fromObject(s)});throw new ve(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,s={}){if(tt(e))return new F({ts:e*1e3,zone:et(s.zone,he.defaultZone),loc:se.fromObject(s)});throw new ve("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=et(s.zone,he.defaultZone);if(!n.isValid)return F.invalid(kt(n));const r=se.fromObject(s),a=es(e,Fn),{minDaysInFirstWeek:o,startOfWeek:l}=Tn(a,r),c=he.now(),u=$(s.specificOffset)?n.offset(c):s.specificOffset,h=!$(a.ordinal),m=!$(a.year),p=!$(a.month)||!$(a.day),y=m||p,w=a.weekYear||a.weekNumber;if((y||h)&&w)throw new ht("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(p&&h)throw new ht("Can't mix ordinal dates with month/day");const M=w||a.weekday&&!y;let C,_,G=zt(c,u);M?(C=Go,_=Ho,G=Kt(G,o,l)):h?(C=Yo,_=qo,G=Ss(G)):(C=_t,_=Qr);let ee=!1;for(const N of C){const O=a[N];$(O)?ee?a[N]=_[N]:a[N]=G[N]:ee=!0}const b=M?Ti(a,o,l):h?Ni(a):Tr(a),D=b||Nr(a);if(D)return F.invalid(D);const W=M?vn(a,o,l):h?An(a):a,[R,H]=Yt(W,u,n),g=new F({ts:R,zone:n,o:H,loc:r});return a.weekday&&y&&e.weekday!==g.weekday?F.invalid("mismatched weekday",`you can't specify both a weekday of ${a.weekday} and a date of ${g.toISO()}`):g.isValid?g:F.invalid(g.invalid)}static fromISO(e,s={}){const[n,r]=go(e);return ft(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=po(e);return ft(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=So(e);return ft(n,r,s,"HTTP",s)}static fromFormat(e,s,n={}){if($(e)||$(s))throw new ve("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:a=null}=n,o=se.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0}),[l,c,u,h]=zo(o,e,s);return h?F.invalid(h):ft(l,c,n,`format ${s}`,e,u)}static fromString(e,s,n={}){return F.fromFormat(e,s,n)}static fromSQL(e,s={}){const[n,r]=bo(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 Ve?e:new Ve(e,s);if(he.throwOnInvalid)throw new Qa(n);return new F({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,s={}){const n=_r(e,se.fromObject(s));return n?n.map(r=>r?r.val:null).join(""):null}static expandFormat(e,s={}){return qr(Ae.parseFormat(e),se.fromObject(s)).map(r=>r.val).join("")}static resetCache(){It=void 0,Ls.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?vs(this).weekYear:NaN}get weekNumber(){return this.isValid?vs(this).weekNumber:NaN}get weekday(){return this.isValid?vs(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?As(this).weekday:NaN}get localWeekNumber(){return this.isValid?As(this).weekNumber:NaN}get localWeekYear(){return this.isValid?As(this).weekYear:NaN}get ordinal(){return this.isValid?Ss(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?[rt(this,{ts:c}),rt(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?Et(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Et(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:s,numberingSystem:n,calendar:r}=Ae.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:s,numberingSystem:n,outputCalendar:r}}toUTC(e=0,s={}){return this.setZone(be.instance(e),s)}toLocal(){return this.setZone(he.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=et(e,he.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 rt(this,{ts:r,zone:e})}else return F.invalid(kt(e))}reconfigure({locale:e,numberingSystem:s,outputCalendar:n}={}){const r=this.loc.clone({locale:e,numberingSystem:s,outputCalendar:n});return rt(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const s=es(e,Fn),{minDaysInFirstWeek:n,startOfWeek:r}=Tn(s,this.loc),a=!$(s.weekYear)||!$(s.weekNumber)||!$(s.weekday),o=!$(s.ordinal),l=!$(s.year),c=!$(s.month)||!$(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=vn({...Kt(this.c,n,r),...s},n,r):$(s.ordinal)?(m={...this.toObject(),...s},$(s.day)&&(m.day=Math.min(Xt(m.year,m.month),m.day))):m=An({...Ss(this.c),...s});const[p,y]=Yt(m,this.o,this.zone);return rt(this,{ts:p,o:y})}plus(e){if(!this.isValid)return this;const s=X.fromDurationLike(e);return rt(this,Un(this,s))}minus(e){if(!this.isValid)return this;const s=X.fromDurationLike(e).negate();return rt(this,Un(this,s))}startOf(e,{useLocaleWeeks:s=!1}={}){if(!this.isValid)return this;const n={},r=X.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?Ae.create(this.loc.redefaultToEN(s)).formatDateTimeFromString(this,e):ws}toLocaleString(e=Qt,s={}){return this.isValid?Ae.create(this.loc.clone(s),e).formatDateTime(this):ws}toLocaleParts(e={}){return this.isValid?Ae.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=Ts(this,l,o);return _t.indexOf(o)>=3&&(c+="T"),c+=Ln(this,l,s,n,r,a,o),c}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?Ts(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":"")+Ln(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?Ts(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():ws}[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 X.invalid("created by diffing an invalid DateTime");const r={locale:this.locale,numberingSystem:this.numberingSystem,...n},a=Ii(s).map(X.normalizeUnit),o=e.valueOf()>this.valueOf(),l=o?this:e,c=o?e:this,u=jo(l,c,a,r);return o?u.negate():u}diffNow(e="milliseconds",s={}){return this.diff(F.now(),e,s)}until(e){return this.isValid?fe.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||F.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),Pn(s,this.plus(n),{...e,numeric:"always",units:r,unit:a})}toRelativeCalendar(e={}){return this.isValid?Pn(e.base||F.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(F.isDateTime))throw new ve("min requires all arguments be DateTimes");return Nn(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every(F.isDateTime))throw new ve("max requires all arguments be DateTimes");return Nn(e,s=>s.valueOf(),Math.max)}static fromFormatExplain(e,s,n={}){const{locale:r=null,numberingSystem:a=null}=n,o=se.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});return Yr(o,e,s)}static fromStringExplain(e,s,n={}){return F.fromFormatExplain(e,s,n)}static buildFormatParser(e,s={}){const{locale:n=null,numberingSystem:r=null}=s,a=se.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new Gr(a,e)}static fromFormatParser(e,s,n={}){if($(e)||$(s))throw new ve("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:a=null}=n,o=se.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?F.invalid(h):ft(l,c,n,`format ${s.format}`,e,u)}static get DATE_SHORT(){return Qt}static get DATE_MED(){return Kn}static get DATE_MED_WITH_WEEKDAY(){return ei}static get DATE_FULL(){return Xn}static get DATE_HUGE(){return er}static get TIME_SIMPLE(){return tr}static get TIME_WITH_SECONDS(){return sr}static get TIME_WITH_SHORT_OFFSET(){return nr}static get TIME_WITH_LONG_OFFSET(){return rr}static get TIME_24_SIMPLE(){return ar}static get TIME_24_WITH_SECONDS(){return ir}static get TIME_24_WITH_SHORT_OFFSET(){return or}static get TIME_24_WITH_LONG_OFFSET(){return lr}static get DATETIME_SHORT(){return cr}static get DATETIME_SHORT_WITH_SECONDS(){return ur}static get DATETIME_MED(){return dr}static get DATETIME_MED_WITH_SECONDS(){return mr}static get DATETIME_MED_WITH_WEEKDAY(){return ti}static get DATETIME_FULL(){return fr}static get DATETIME_FULL_WITH_SECONDS(){return hr}static get DATETIME_HUGE(){return yr}static get DATETIME_HUGE_WITH_SECONDS(){return gr}}function Tt(t){if(F.isDateTime(t))return t;if(t&&t.valueOf&&tt(t.valueOf()))return F.fromJSDate(t);if(t&&typeof t=="object")return F.fromObject(t);throw new ve(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function Jo(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function Qo(t,e){try{const s=F.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 Ko(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=F.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 Xo={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},el={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function Kr({alerts:t,loading:e=!1,pageSize:s=10,severityOptions:n,anomalyOptions:r,spaceOptions:a,onAlertIdClick:o}){const l=Vs(),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){const w=y?.Message||y?.data||"Alert reopened successfully.";xe.toast.success(w)}else{const w=y?.errorMessage||y?.Message||"Failed to reopen alert";xe.toast.error(w)}}catch{xe.toast.error("Failed to reopen alert. Please try again.")}},h=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:p=>i.jsx(d.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Xo[p]}`,backgroundColor:el[String(p)]},children:p})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:p=>Ko(p)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(p,y)=>i.jsxs("div",{children:[i.jsx("a",{onClick:w=>{w.preventDefault(),o?.(y,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:y.alertNumber}),i.jsx("div",{className:"text-black/65",children:p})]})},{title:"",key:"menu",width:60,align:"right",render:(p,y)=>i.jsx(d.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:w})=>{w==="reopen"&&u(y)}},children:i.jsx(d.Button,{type:"text",icon:i.jsx(it.MoreOutlined,{})})})}],m=(t||[]).filter(p=>c.includes((p.statusType||"").toLowerCase()));return i.jsx(Ws,{data:m,loading:e,pageSize:s,columns:h,severityOptions:n,anomalyOptions:r,spaceOptions:a,renderActions:void 0,onAlertIdClick:o,excludeCompleted:!1})}function tl({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(p=>p.type==="hour")?.value||"0",10),minutes:parseInt(m.find(p=>p.type==="minute")?.value||"0",10),seconds:parseInt(m.find(p=>p.type==="second")?.value||"0",10)}},[e,s]),o=a*6,l=r*6+a*.1,c=n%12*30+r*.5,u=t/2;return i.jsxs("div",{className:"relative rounded-full border border-gray-300 bg-white",style:{width:t,height:t},role:"img","aria-label":"Analog Clock",children:[[...Array(12)].map((h,m)=>{const p=m*30,y=6,w=u-4,M=w-y,C=(p-90)*(Math.PI/180),_=u+M*Math.cos(C),G=u+M*Math.sin(C),ee=u+w*Math.cos(C),b=u+w*Math.sin(C);return i.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:i.jsx("line",{x1:_,y1:G,x2:ee,y2:b,stroke:"#9CA3AF",strokeWidth:m%3===0?2:1,strokeLinecap:"round"})},m)}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${c}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.25,stroke:"#1F2937",strokeWidth:4,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${l}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.35,stroke:"#374151",strokeWidth:3,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${o}deg)`},children:i.jsx("line",{x1:u,y1:u+t*.08,x2:u,y2:u-t*.38,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"})}),i.jsx("div",{className:"absolute bg-gray-900 rounded-full",style:{width:8,height:8,left:u-4,top:u-4}})]})}function Xr({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(()=>Jo(r,e),[r,e]),{abbr:l,offset:c}=f.useMemo(()=>Qo(r,e),[r,e]);return i.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[i.jsx(tl,{time:r,timeZone:e,size:80}),i.jsxs("div",{className:"flex flex-col items-baseline gap-1",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[i.jsx("span",{className:"uppercase",children:t}),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:sl}=d.Typography;function nl({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(sl,{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 Fs=t=>i.jsxs(d.Tag,{children:[i.jsx(it.PlusOutlined,{})," ",t.length," more"]}),{Text:Ge}=d.Typography;function rl(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:p,setL2role:y,l3mins:w,setL3mins:M,l3role:C,setL3role:_,actions:G,setActions:ee,thirdPartyIds:b,setThirdPartyIds:D,humanLoop:W,setHumanLoop:R,isAutoExpire:H,setAutoExpire:g,onClear:N,onSave:O,saving:ue,onActionTypesLoaded:le}=t,{rules:j}=Oe(),[x,S]=f.useState([]),[k,v]=f.useState([]),[U,A]=f.useState(!1);f.useEffect(()=>{let Y=!1;return(async()=>{try{A(!0);const K=await j.getLookups();if(Y||!K||!Array.isArray(K.actionTypes))return;const ae=K.actionTypes.map(ce=>({label:ce.name,value:String(ce.actionTypeId)}));S(ae),le&&le(K.actionTypes);const we=Array.isArray(K.thirdParties)?K.thirdParties.map(ce=>({label:ce.thirdPartyName,value:ce.thirdPartyId})):[];v(we)}catch(K){console.error("Error loading lookups",K)}finally{Y||A(!1)}})(),()=>{Y=!0}},[]);const E=typeof o=="number"||typeof c=="number",P=typeof h=="number"||typeof p=="number",V=typeof o=="number"||typeof c=="number"||typeof h=="number"||typeof p=="number"||typeof w=="number"||typeof C=="number"||Array.isArray(G)&&G.length>0||Array.isArray(b)&&b.length>0||!!W||!!H,B=!!e&&V&&!ue;return i.jsxs(d.Spin,{spinning:!!ue||U,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(Ge,{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(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),i.jsx(d.Col,{span:14,children:i.jsx(Ge,{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})})]})]})}),E&&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(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),i.jsx(d.Col,{span:14,children:i.jsx(Ge,{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:p,onChange:y,options:a})})]})]})}),P&&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(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),i.jsx(d.Col,{span:14,children:i.jsx(Ge,{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:w,onChange:M,options:r})}),i.jsx(d.Col,{span:14,children:i.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:C,onChange:_,options:a})})]})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Ge,{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:G,onChange:ee,options:x,maxTagCount:1,maxTagPlaceholder:Fs})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Notify"}),i.jsx(d.Select,{mode:"multiple",placeholder:"Notify",className:"w-full",value:b,onChange:D,options:k,maxCount:2,maxTagPlaceholder:Fs})]})})]}),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:W,onChange:Y=>R(Y.target.checked),className:"w-full",children:"Human-In-The-Loop"}),i.jsx(d.Checkbox,{checked:H,onChange:Y=>g(Y.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:N,children:"Clear"}),i.jsx(d.Button,{type:"primary",onClick:O,loading:!!ue,disabled:!B,children:"Save"})]})})]})]})}function al({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(it.EditOutlined,{})})}]})}const{Title:il,Text:Ns}=d.Typography;function ea({userRoles:t,rules:e,rawRules:s}){const{rules:n}=Oe(),[r,a]=f.useState(!1),[o,l]=f.useState(!1),[c,u]=f.useState(s),[h,m]=f.useState(),[p,y]=f.useState([]),w=f.useMemo(()=>t.map(b=>({label:b.userRoleName,value:b.userRoleId})),[t]),M=f.useMemo(()=>(e||[]).map(b=>({label:b.Name||"-",value:b.RuleId||b.Name||""})),[e]),C=f.useMemo(()=>(e||[]).map((b,D)=>({key:b.RuleId||b.Name||String(D),ruleName:b.Name||"-",ruleDesc:b.Description||""})),[e]);f.useEffect(()=>{let b=!1;return(async()=>{try{a(!0);const D=await n.getRules();b||u(Array.isArray(D)?D:[])}catch{!b&&Array.isArray(s)&&u(s)}finally{b||a(!1)}})(),()=>{b=!0}},[]),f.useEffect(()=>{!c&&Array.isArray(s)&&u(s)},[s]),f.useEffect(()=>{if(!h||!Array.isArray(c)){y([]);return}const b=c.find(W=>W?.ruleId===h||W?.RuleId===h||W?.ruleName===h),D=b?.userRoleIds??b?.UserRoleIds;y(Array.isArray(D)?D:[])},[h,c]);const _=f.useMemo(()=>{if(!Array.isArray(c)||!c.length)return{};const b={};for(const D of C){const W=c.find(g=>g?.ruleId===D.key||g?.ruleName===D.key||g?.RuleId===D.key||g?.ruleName===D.ruleName||g?.Name===D.ruleName),R=W?.userRoleIds??W?.UserRoleIds,H=Array.isArray(R)?R:[];H.length&&(b[D.key]=H)}return b},[c,C]),G=()=>{m(void 0),y([])},ee=async()=>{if(!h){xe.toast.info("Please select a rule");return}try{l(!0);const b=Array.isArray(c)?c.find(g=>g?.ruleId===h||g?.RuleId===h||g?.ruleName===h):void 0,D=typeof b?.recordId=="number"?b.recordId:b?.ruleId||b?.RuleId||void 0;if(!b||!D)throw new Error(`Unable to find rule identifier for rule ${h}`);const W=p.map(g=>{const N=t.find(O=>O.userRoleId===g);return{id:g,name:N?.userRoleName??String(g)}}),R={...b,ruleId:h,userRoleIds:p,userRoles:W},H=await n.updateRule(D,R);if(!H?.responseStatus&&!H?.Success&&!H?.success)xe.toast.error(H?.errorMessage||H?.Message||"Error saving Alert Assignment");else{xe.toast.success("Alert assignment saved"),m(void 0),y([]);try{const g=await n.getRules();u(Array.isArray(g)?g:[])}catch(g){console.error("Failed to refresh rules after save",g)}}}catch(b){console.error("Failed to save alert assignment",b),xe.toast.error(b instanceof Error?b.message:"Error saving Alert Assignment")}finally{l(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(il,{level:4,className:"!mb-4",children:"Alert Assignment"}),i.jsx(d.Spin,{spinning:o||r,children:i.jsxs(d.Row,{gutter:[16,16],align:"bottom",className:"mb-6",children:[i.jsx(d.Col,{xs:24,sm:12,md:8,lg:6,children:i.jsxs("div",{children:[i.jsx(Ns,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(d.Select,{placeholder:"Rules",value:h,onChange:m,options:M,className:"w-full"})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:8,children:i.jsxs("div",{children:[i.jsx(Ns,{className:"text-gray-700 font-medium block mb-1",children:"Alert Notification To"}),i.jsx(d.Select,{mode:"multiple",placeholder:"Select roles",className:"w-full",value:p,onChange:y,options:w,maxTagCount:1,maxTagPlaceholder:Fs})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.Button,{onClick:G,disabled:o,children:"Cancel"}),i.jsx(d.Button,{type:"primary",onClick:ee,loading:o,disabled:o||!h,children:"Save"})]})})]})}),i.jsx(d.Table,{rowKey:"key",dataSource:C,loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(b,D)=>`${D[0]}-${D[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,D)=>{const W=_[D.key]??[];return W.length?i.jsx("div",{className:"flex flex-wrap gap-1",children:W.map(R=>{const H=t.find(g=>g.userRoleId===R);return i.jsx(d.Tag,{children:H?.userRoleName??String(R)},R)})}):i.jsx(Ns,{type:"secondary",children:"—"})}}]})]})}const{Title:Vn}=d.Typography;function bs(t){return!t||typeof t!="object"?{}:{level1UserRoleId:t.level1UserRoleId??t.Level1UserRoleId,level1PostAssistTime:t.level1PostAssistTime??t.Level1PostAssistTime,level2UserRoleId:t.level2UserRoleId??t.Level2UserRoleId,level2PostAssistTime:t.level2PostAssistTime??t.Level2PostAssistTime,level3UserRoleId:t.level3UserRoleId??t.Level3UserRoleId,level3PostAssistTime:t.level3PostAssistTime??t.Level3PostAssistTime,escalationSettingsActionTypeIds:t.escalationSettingsActionTypeIds??t.EscalationSettingsActionTypeIds,thirdPartyId:t.thirdPartyId??t.ThirdPartyIds,humanLoop:t.humanLoop??t.HumanLoop,isAutoExpire:t.isAutoExpire??t.IsAutoExpire}}function ta({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r,onSave:a}){const{rules:o,alerts:l}=Oe(),[c,u]=f.useState("By Severity"),[h,m]=f.useState("By severity"),[p,y]=f.useState("By Severity"),[w,M]=f.useState(!1),[C,_]=f.useState(!1),[G,ee]=f.useState(!1),[b,D]=f.useState(null),[W,R]=f.useState("rules"),[H,g]=f.useState(),[N,O]=f.useState(),[ue,le]=f.useState(),[j,x]=f.useState(),[S,k]=f.useState(),[v,U]=f.useState(),[A,E]=f.useState(),[P,V]=f.useState(),[B,Y]=f.useState([]),[K,ae]=f.useState([]),[we,ce]=f.useState(!1),[de,Se]=f.useState(!1),[Te,je]=f.useState({}),[_e,ct]=f.useState({}),[ye,ut]=f.useState(s||[]),[At,Rt]=f.useState([]),[st,Ut]=f.useState(!1),[I,z]=f.useState(!1),[J,pe]=f.useState(n||[]);f.useEffect(()=>{n&&n.length&&pe(n)},[n]),f.useEffect(()=>{if(!J||!J.length)return;const L=Object.keys(Te).length>0||Object.keys(_e).length>0;if(At.length&&!L)return;const ne=J.map((Q,Z)=>{const oe=e.find(Ne=>Ne.RuleId===(Q.ruleId||Q.ruleName))?.Name||Q.ruleName||Q.Name||"-",q=bs(Q.escalationSettings),re=typeof q.level1UserRoleId=="number"&&q.level1UserRoleId>0?[q.level1UserRoleId]:[],us=typeof q.level2UserRoleId=="number"&&q.level2UserRoleId>0?[q.level2UserRoleId]:[],ds=typeof q.level3UserRoleId=="number"&&q.level3UserRoleId>0?[q.level3UserRoleId]:[],Ks=(Array.isArray(q.escalationSettingsActionTypeIds)?q.escalationSettingsActionTypeIds:[]).map(Ne=>Te[Ne]||String(Ne)),en=(Array.isArray(q.thirdPartyId)?q.thirdPartyId:[]).map(Ne=>_e[Ne]||String(Ne)),ms=typeof q.humanLoop=="boolean"?q.humanLoop:null,fs=typeof q.isAutoExpire=="boolean"?q.isAutoExpire:null;return{id:String(Q.ruleId||Q.ruleName||Z),ruleOrSeverityLabel:oe,l1:{minutes:q.level1PostAssistTime??void 0,roles:re},l2:{minutes:q.level2PostAssistTime??void 0,roles:us},l3:{minutes:q.level3PostAssistTime??void 0,roles:ds},actions:Ks,notify:en,humanLoop:ms,isAutoExpire:fs}});Rt(ne)},[J,e,Te,_e]);const ke=f.useMemo(()=>t.map(L=>({label:L.DisplayName,value:L.SeverityId})),[t]),ie=f.useMemo(()=>e.map(L=>({label:L.Name,value:L.RuleId})),[e]),Ze=f.useMemo(()=>ye.map(L=>({label:L.userRoleName,value:L.userRoleId})),[ye]),Je=f.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(L=>({label:`${L}`,value:L})),[]);f.useEffect(()=>{let L=!1;async function ne(){try{ee(!0),D(null);const Q=await l.getAdminSettings();if(!L&&Q){const Z=qn(Q.sortBy);u(Z),y(Z),M(!1)}}catch(Q){if(!L){const Z=Q instanceof Error?Q.message:"Failed to load admin settings";D(Z)}}finally{L||ee(!1)}}return ne(),()=>{L=!0}},[]),f.useEffect(()=>{if(!N)return;const L=oe=>{const q=Number(oe);return!isNaN(q)&&q>0?q:void 0},ne=oe=>{const q=Number(oe);return!isNaN(q)&&q>0?q:void 0},Q=(J||[]).find(oe=>oe?.ruleId===N||oe?.ruleName===N||oe?.RuleId===N),Z=bs(Q?.escalationSettings);if(Z&&typeof Z=="object"){le(ne(Z.level1PostAssistTime)),x(L(Z.level1UserRoleId)),k(ne(Z.level2PostAssistTime)),U(L(Z.level2UserRoleId)),E(ne(Z.level3PostAssistTime)),V(L(Z.level3UserRoleId));const oe=Array.isArray(Z.escalationSettingsActionTypeIds)?Z.escalationSettingsActionTypeIds:[];Y(oe.map(q=>String(q))),ae(Array.isArray(Z.thirdPartyId)?Z.thirdPartyId:[]),ce(!!Z.humanLoop),Se(!!Z.isAutoExpire)}},[W,N,J]);const ze=async()=>{try{z(!0);const L=await o.getRules(),ne=Array.isArray(L)?L:Array.isArray(L?.data)?L.data:[];pe(ne);const Q=ne.map((Z,oe)=>{const q=e.find(Ne=>Ne.RuleId===(Z.ruleId||Z.ruleName))?.Name||Z.ruleName||Z.Name||"-",re=bs(Z.escalationSettings??Z.EscalationSettings),us=typeof re.level1UserRoleId=="number"&&re.level1UserRoleId>0?[re.level1UserRoleId]:[],ds=typeof re.level2UserRoleId=="number"&&re.level2UserRoleId>0?[re.level2UserRoleId]:[],Qs=typeof re.level3UserRoleId=="number"&&re.level3UserRoleId>0?[re.level3UserRoleId]:[],Xs=(Array.isArray(re.escalationSettingsActionTypeIds)?re.escalationSettingsActionTypeIds:[]).map(Ne=>Te[Ne]||String(Ne)),ms=(Array.isArray(re.thirdPartyId)?re.thirdPartyId:[]).map(Ne=>_e[Ne]||String(Ne)),fs=typeof re.humanLoop=="boolean"?re.humanLoop:null;return{id:String(Z.ruleId||Z.ruleName||oe),ruleOrSeverityLabel:q,l1:{minutes:re.level1PostAssistTime??void 0,roles:us},l2:{minutes:re.level2PostAssistTime??void 0,roles:ds},l3:{minutes:re.level3PostAssistTime??void 0,roles:Qs},actions:Xs,notify:ms,humanLoop:fs}});Rt(Q)}catch(L){console.error("Failed to refetch entries",L)}finally{z(!1)}};f.useEffect(()=>{let L=!1;return(async()=>{try{const ne=await o.getLookups();if(L||!ne)return;const Q={};if(Array.isArray(ne.thirdParties))for(const oe of ne.thirdParties)typeof oe.thirdPartyId=="number"&&(Q[oe.thirdPartyId]=oe.thirdPartyName);ct(Q);const Z=Array.isArray(ne.userRoles)?ne.userRoles.map(oe=>({userRoleId:oe.userRoleId??oe.id,userRoleName:oe.userRoleName??oe.name})):[];L||ut(Z.length?Z:s||[])}catch(ne){console.error("Error loading lookups",ne)}})(),()=>{L=!0}},[]);const oa=async()=>{_(!0);try{const L=await l.setAdminSettings({sortBy:c,groupBy:"string"});L?.responseStatus&&L?.data&&xe.toast.success(L.data),y(c),M(!1)}catch(L){console.error("Error saving admin settings",L)}finally{_(!1)}},la=()=>{u(p),M(!1)},ca=async()=>{Ut(!0),a?.({ruleId:N,levels:[{minutes:ue,role:j},{minutes:S,role:v},{minutes:A,role:P}],actions:B,thirdPartyIds:K,humanLoop:we,isAutoExpire:de});try{if(N){const ne=Array.isArray(B)?B.map(re=>Number.isNaN(Number(re))?re:Number(re)):[],Q=(J||[]).find(re=>re?.ruleId===N||re?.ruleName===N||re?.RuleId===N),Z=typeof Q?.recordId=="number"?Q.recordId:Q?.ruleId||Q?.RuleId||void 0;if(!Q||!Z){xe.toast.error("Unable to find rule identifier for update");return}const oe={...Q,escalationSettings:{level1UserRoleId:j??0,level1PostAssistTime:ue??0,level2UserRoleId:v??0,level2PostAssistTime:S??0,level3UserRoleId:P??0,level3PostAssistTime:A??0,escalationSettingsActionTypeIds:ne,thirdPartyId:Array.isArray(K)?K:[],humanLoop:we,isAutoExpire:de}},q=await o.updateRule(Z,oe);q?.responseStatus||q?.Success||q?.success?(xe.toast.success("Escalation settings saved"),await ze(),O(void 0),le(void 0),x(void 0),k(void 0),U(void 0),E(void 0),V(void 0),Y([]),ae([]),ce(!1),Se(!1)):xe.toast.error(q?.errorMessage||q?.Message||"Error saving Escalation Settings")}}catch(ne){console.error("Error saving escalation settings",ne)}finally{Ut(!1)}},ua=()=>{u("By Severity"),m("By severity"),R("rules"),g(void 0),O(void 0),le(void 0),x(void 0),k(void 0),U(void 0),E(void 0),V(void 0),Y([]),ae([]),ce(!1),Se(!1)};return i.jsxs("div",{className:"w-full",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(Vn,{level:4,className:"!mb-2",children:"Admin Settings"}),i.jsxs(d.Spin,{spinning:G,children:[b?i.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",b]}):null,i.jsx(nl,{sortBy:c,groupBy:h,onChange:L=>{L.sortBy&&(u(L.sortBy),M(!0)),L.groupBy&&(m(L.groupBy),M(!0))},showActions:w,onSave:oa,onClear:la,saving:C})]})]}),i.jsx(d.Divider,{className:"my-6"}),i.jsxs("div",{children:[i.jsx(Vn,{level:4,className:"!mb-4",children:"Escalation Settings"}),i.jsx(rl,{escBasis:W,setEscBasis:R,selectedSeverity:H,setSelectedSeverity:g,selectedRule:N,setSelectedRule:O,severityOptions:ke,ruleOptions:ie,minsOptions:Je,roleOptions:Ze,l1mins:ue,setL1mins:le,l1role:j,setL1role:x,l2mins:S,setL2mins:k,l2role:v,setL2role:U,l3mins:A,setL3mins:E,l3role:P,setL3role:V,actions:B,setActions:Y,thirdPartyIds:K,setThirdPartyIds:ae,humanLoop:we,setHumanLoop:ce,onClear:ua,onSave:ca,saving:st,onActionTypesLoaded:L=>{const ne={};for(const Q of L)typeof Q.actionTypeId=="number"&&(ne[Q.actionTypeId]=Q.name);je(ne)},isAutoExpire:de,setAutoExpire:Se})]}),i.jsx(d.Divider,{className:"my-6"}),i.jsx(al,{entries:At,userRoles:ye,loading:I||r,onEdit:L=>{R("rules");const ne=At.find(Z=>Z.id===L),Q=e.find(Z=>Z.RuleId===L)||(ne?e.find(Z=>Z.Name===ne.ruleOrSeverityLabel):void 0);O(Q?Q.RuleId:L)}}),i.jsx(d.Divider,{className:"my-6"}),i.jsx(ea,{userRoles:ye,rules:e,rawRules:n}),i.jsx(d.Divider,{})]})}const{Title:Bn,Text:qt}=d.Typography;function ol({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:a}=Oe(),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,p]=f.useState(null),[y,w]=f.useState(null),[M,C]=f.useState({inApp:!1,sms:!1,email:!1}),[_,G]=f.useState([]),[ee,b]=f.useState(!0),[D,W]=f.useState(!1);f.useEffect(()=>{let g=!1;return(async()=>{try{const N=await a.getPreferenceSettings();if(g||!N)return;C({inApp:!!N.inApp,sms:!!N.sms,email:!!N.email});const O=qn(N.sortBy);c(O==="By Created Date"?"By Created Date":"By Severity"),p(ln(N.doNotDisturbStart)),w(ln(N.doNotDisturbEnd)),Array.isArray(N.anomalyIds)&&h(new Set(N.anomalyIds.map(ue=>String(ue))))}catch(N){console.error("Error in loading my preferences: ",N)}})(),()=>{g=!0}},[]),f.useEffect(()=>{let g=!1;return(async()=>{try{b(!0);const N=await r.getLookups();if(g||!N)return;const O=Array.isArray(N.anomalies)?N.anomalies:[];G(O)}catch(N){console.error("Failed to load anomalies lookups",N)}finally{g||b(!1)}})(),()=>{g=!0}},[]);const R=g=>{h(N=>{const O=new Set(N);return O.has(g)?O.delete(g):O.add(g),O})},H=async()=>{s?.({sortBy:l,subscribedRuleIds:Array.from(u),dnd:{from:m,to:y},channels:M});try{W(!0);const g=m?m.format?.("HH:mm:ss")??"00:00:00":"00:00:00",N=y?y.format?.("HH:mm:ss")??"00:00:00":"00:00:00",O=Array.from(u).map(le=>Number(le)).filter(le=>Number.isFinite(le)),ue=await a.setPreferenceSettings({anomalyIds:O,doNotDisturbStart:g,doNotDisturbEnd:N,inApp:!!M.inApp,sms:!!M.sms,email:!!M.email,sortBy:l});ue?.responseStatus&&xe.toast.success(ue?.data||"Preferences updated successfully.")}catch(g){console.error("Error in saving my preferences: ",g)}finally{W(!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(Bn,{level:5,className:"!mb-2",children:"Anomalies"}),ee?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(_)?_:[]).map(g=>{const N=String(g.recordId),O=g.anomalyName;return i.jsx(d.Checkbox,{checked:u.has(N),onChange:()=>R(N),children:O},N)})})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx(Bn,{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:g=>p(g),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:g=>w(g),format:"HH:mm"})]})]})]})})}),i.jsxs(d.Row,{gutter:[24,12],children:[i.jsx(d.Col,{children:i.jsx(d.Checkbox,{checked:M.inApp,onChange:g=>C({...M,inApp:g.target.checked}),children:"In-app"})}),i.jsx(d.Col,{children:i.jsx(d.Checkbox,{checked:M.sms,onChange:g=>C({...M,sms:g.target.checked}),children:"SMS"})}),i.jsx(d.Col,{children:i.jsx(d.Checkbox,{checked:M.email,onChange:g=>C({...M,email:g.target.checked}),children:"Email"})})]})]}),i.jsx(d.Divider,{}),i.jsxs(d.Space,{className:"gap-3",children:[i.jsx(d.Button,{onClick:n,disabled:D,children:"Cancel"}),i.jsx(d.Button,{type:"primary",onClick:H,loading:D,children:"Save"})]})]})}function sa({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r}){return i.jsx("div",{className:"w-full",children:i.jsx(ta,{severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r})})}const ll="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=",cl="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}=Oe();return{timeZoneDetails:f.useMemo(()=>{const s=t.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone;return{timeZoneUniqueId:"",ianaTimeZoneId:s,timeZoneName:s,offset:""}},[t.timeZone]),loading:!1}}function ul(t){const e=(t.status||"").toLowerCase()==="completed"?i.jsx("img",{src:ll,alt:"completed",style:{width:20,height:20}}):i.jsx("img",{src:cl,alt:"pending",style:{width:20,height:20}});return{title:i.jsxs("div",{className:"flex flex-col gap-0 min-w-0",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{className:"block text-sm break-words mb-1 overflow-visible whitespace-normal",children:i.jsx("b",{children:t.title})}),t.description?i.jsx("span",{className:"text-gray-500 text-xs",children:t.description}):null]}),t.timestamp?i.jsx("span",{className:"text-gray-500 text-xs",children:t.timestamp}):null]}),icon:e,description:null}}function dl({data:t}){const{timeZoneDetails:e}=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(ul)})})]})]})},{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 ml=({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 p=(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:p,title:m?.status||m?.eventStatus||"Status Update",description:m?.description||m?.actionNotes||"",timestamp:y}}):[],h={summary:l,timeline:u,notifications:o??[]};return i.jsx(dl,{data:h})};const fl=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),hl=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),Zn=t=>{const e=hl(t);return e.charAt(0).toUpperCase()+e.slice(1)},na=(...t)=>t.filter((e,s,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===s).join(" ").trim(),yl=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var gl={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 pl=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,...gl,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:na("lucide",r),...!a&&!yl(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,h])=>f.createElement(u,h)),...Array.isArray(a)?a:[a]]));const cs=(t,e)=>{const s=f.forwardRef(({className:n,...r},a)=>f.createElement(pl,{ref:a,iconNode:e,className:na(`lucide-${fl(Zn(t))}`,`lucide-${t}`,n),...r}));return s.displayName=Zn(t),s};const Sl=[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]],xl=cs("image-off",Sl);const wl=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],vl=cs("loader-circle",wl);const Al=[["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"}]],ra=cs("maximize-2",Al);const Tl=[["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"}]],Nl=cs("minimize-2",Tl),bl=({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(Nl,{size:20}):i.jsx(ra,{size:20})})]})}):null};function kl(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 zn(t){const e=(t?.mediaType||t?.type||"").toString().toLowerCase();return e==="video"||e==="mp4"?!0:kl(t?.mediaUrl||t)}function Il(t){const e=t?.mediaUrl;let s=null;if(Array.isArray(e))s=e;else if(typeof e=="string")try{const n=JSON.parse(e);Array.isArray(n)&&(s=n)}catch{}return s&&s.length>0?s.map(n=>({...t,mediaUrl:n})):[t]}function Ml(t){const e=t;return e?(Array.isArray(e)?e:[e]).flatMap(Il):[]}const El={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Ol={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},jl=({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(""),[p,y]=f.useState(!1),w=f.useRef(null),[M,C]=f.useState("details"),[_,G]=f.useState(void 0),ee=Vs(),{alerts:b}=Oe(),{timeZoneDetails:D}=ls(),[W,R]=f.useState(!1),[H,g]=f.useState(void 0),[N,O]=f.useState(void 0),[ue,le]=f.useState({}),[j,x]=f.useState({}),S=(I,z,J)=>{const pe=j[I];return ue[I]===!1&&!pe?i.jsxs("div",{className:"w-full flex flex-col items-center justify-center min-h-[200px] bg-gray-100 rounded-lg gap-2 text-gray-400",children:[i.jsx(xl,{size:40}),i.jsx("span",{className:"text-sm",children:"Media not available"})]}):i.jsxs("div",{className:"relative w-full flex justify-center items-center min-h-[200px]",children:[pe&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg z-10",children:i.jsx(vl,{size:32,className:"animate-spin text-gray-400"})}),i.jsx("img",{src:I,alt:z.caption||`media-${J}`,className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg transition-opacity duration-200 ${pe?"opacity-0":"opacity-100"}`,onLoad:()=>x(ke=>({...ke,[I]:!1})),onError:()=>x(ke=>({...ke,[I]:!1}))},I)]})},k=s?.originalData||{},{eventName:v,alertId:U,timestamp:A,description:E,spaceName:P,assignTeam:V,priority:B,statusType:Y,id:K,alertDetails:ae,statusHistory:we,mediaDetails:ce,alertNumber:de}=k,Se=I=>{const z=String(I||"").toLowerCase();return z==="delivered"||z==="sent"?"Delivered":z==="failed"?"Failed":"Queued"},Te=I=>({name:I?.receipientName||I?.recipientName||"-",role:I?.receipientRoleName||"",phone:I?.receipentPhoneNumber||I?.recipientPhoneNumber||I?.receipientEmail||I?.recipientEmail||"",status:Se(I?.messageStatus),notificationReceipientType:I?.notificationReceipientType||""}),je=(I,z)=>{const J=z.map(Te),pe=J.filter(Je=>Je.status==="Delivered").length,ke=z.map(Je=>Je?.sentAt).filter(Boolean).sort((Je,ze)=>new Date(ze).getTime()-new Date(Je).getTime())[0],ie=z[0]||{},Ze=[ie?.severityName,ie?.anomalyName].filter(Boolean).join(" - ")||`${I} Notification`;return{channelLabel:`${I} Notification`,sentAt:ke||"",messageTitle:Ze,messageBody:"",total:J.length,delivered:pe,recipients:J}},_e=I=>{const z=new Map;return(I||[]).forEach(J=>{const pe=String(J?.notificationType||"Unknown"),ke=z.get(pe)||[];ke.push(J),z.set(pe,ke)}),Array.from(z.entries()).map(([J,pe])=>je(J,pe))},ct=async I=>{try{const z=await b.getAlertNotifications(I),J=_e(z);G(J)}catch{G(void 0)}};f.useEffect(()=>{if(M!=="track"||!K)return;let I=!1;return ct(K).then(()=>{I&&G(void 0)}),()=>{I=!0}},[M,K]),f.useEffect(()=>{t&&C(o)},[t,o]);const ut=l==="archived"||["completed","false positive"].includes(String(Y||"").toLowerCase()),At=I=>{const z=String(I?.value||"").toLowerCase(),J=String(I?.statusName||"").toLowerCase();return z.includes("reopen")||J.includes("reopen")},Rt=(r||[]).filter(I=>{const z=At(I);return typeof l<"u"?l==="archived"?z:!z:ut?z:!z}).map(I=>({value:I.value,label:I.statusName})),st=f.useMemo(()=>Ml(ce),[ce]);f.useEffect(()=>{let I=!1;const z=new AbortController,J=async ie=>{if(ie){I||le(Ze=>({...Ze,[ie]:!1}));try{const Ze=await fetch(ie,{method:"HEAD",signal:z.signal});if(Ze.ok){I||le(ze=>({...ze,[ie]:!0}));return}if(Ze.status===404){I||le(ze=>({...ze,[ie]:!1}));return}if(!(await fetch(ie,{method:"GET",signal:z.signal})).ok)throw new Error("Media not available");I||le(ze=>({...ze,[ie]:!0}))}catch{I||le(Ze=>({...Ze,[ie]:!1}))}}};le({});const pe=st.filter(ie=>!zn(ie)).map(ie=>ie?.mediaUrl||ie).filter(ie=>typeof ie=="string"&&ie.length>0),ke={};return pe.forEach(ie=>{ke[ie]=!0}),x(ke),pe.forEach(ie=>J(ie)),()=>{I=!0,z.abort()}},[st]);const Ut=async()=>{try{y(!0);const I={alertUniqueId:U,alertId:K,status:c?String(c):void 0,notes:h.trim(),modifiedBy:0},z=await ee.mutateAsync(I);if(z?.responseStatus||z?.Success){const J=z?.Message||z?.data||"Alert updated successfully.";xe.toast.success(J,{autoClose:1500,onClose:()=>{n(),e()}}),u(void 0),m("")}else{const J=z?.errorMessage||z?.Message||"Failed to update alert status";xe.toast.error(J)}}catch(I){console.error("Error updating alert status:",I),xe.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:M==="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:Ut,loading:p,children:p?"Saving...":"Save Changes"})]}):null,children:s&&i.jsx(d.Tabs,{activeKey:M,onChange:I=>C(I),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:v||"Alert Event"}),ae?.firstName?i.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",ae?.firstName," ",ae?.lastName||""," ",ae?.residentId||""]}):null,i.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp: ",ts(A,D?.ianaTimeZoneId)]}),i.jsxs("div",{className:"font-sm text-gray-500",children:[i.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",E||"No description available"]}),P&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",P]}),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 ${El[String(B)]||"#DFE4EA"}`,backgroundColor:Ol[String(B)]},children:["Severity: ",B||"N/A"]}),i.jsxs(d.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(Y||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",Y||"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:I=>u(I),value:c,options:Rt,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:I=>m(I.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"}),st.length>1?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>w.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(it.LeftOutlined,{style:{fontSize:12}})}),i.jsx("button",{type:"button",onClick:()=>w.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(it.RightOutlined,{style:{fontSize:12}})})]}):null]}),st.length?i.jsx("div",{className:"w-full",children:i.jsx(d.Carousel,{ref:w,dots:!0,className:"w-full",children:st.map((I,z)=>{const J=I.mediaUrl||I,pe=zn(I);return i.jsxs("div",{className:"flex justify-center items-center relative",children:[pe?i.jsxs("video",{width:"240",height:"200",controls:!0,className:"max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg",children:[i.jsx("source",{src:J}),"Your browser does not support the video tag."]}):S(String(J),I,z),I.caption&&i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:I.caption}),!pe&&ue[String(J)]?i.jsx("button",{onClick:()=>{R(!0),g(J),O(I.type||"image")},className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:i.jsx(ra,{size:20})}):null]},String(J)||z)})})}):null]})}),i.jsx(bl,{isOpen:W,onClose:()=>R(!1),src:H||"",type:N||"image"})]})},{key:"track",label:"Track Incident",children:i.jsx(ml,{alertId:U,id:K,priority:B,spaceName:P,alertNumber:de,statusHistory:we,notifGroups:_})}]})})};function aa(){const{alerts:t}=Oe(),e=ot.useQuery({queryKey:["alerts","statusList"],queryFn:()=>t.getAlertStatusList(),staleTime:5*6e4});return{list:e.data??[],loading:e.isLoading,error:e.error,refetch:e.refetch}}function Js({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:p}=aa(),{timeZoneDetails:y}=ls(),w=y?.timeZoneName??"UTC",M=y?.ianaTimeZoneId??"UTC";function C(D,W){c(D),h(W?.tab??"details"),ee(W?.sourceTab??"active"),o(!0)}function _(){o(!1)}const[G,ee]=f.useState("active"),b=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(Xr,{label:w,timeZone:M})})]}),i.jsx(d.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:D=>{D==="active"&&n?.()},items:[{key:"active",label:"Active",children:i.jsx(Ws,{data:t,loading:e,pageSize:10,columns:s||[],onAlertIdClick:C,onRefetch:n,onPageChange:r})},{key:"archived",label:"Archived",children:i.jsx(Kr,{alerts:t,loading:e,columns:s||[],onAlertIdClick:C})},{key:"settings",label:"Settings",children:i.jsx(Cl,{})}]}),i.jsx(jl,{isModalOpen:a,handleModalClose:_,selectedRow:b,fetchAlertLogs:()=>{},alertStatusList:m,alertStatusLoading:p,initialTab:u,sourceTab:G})]})}function Cl(){const[t,e]=f.useState([]),[s,n]=f.useState([]),[r,a]=f.useState([]),[o,l]=f.useState([]),[c,u]=f.useState(!0),{rules:h}=Oe();return f.useEffect(()=>{let m=!0;return(async()=>{try{const p=await h.getRules();if(!m)return;l(Array.isArray(p)?p:[]);const y=(p||[]).map((w,M)=>({RuleId:w.ruleId||w.ruleName||String(M),Name:w.ruleName||w.Name||"-",Description:w.ruleDesc||w.Description||"",SeverityId:0}));e(y);try{const w=await h.getLookups(),M=Array.isArray(w?.userRoles)?w.userRoles.map(C=>({userRoleId:C.userRoleId??C.id,userRoleName:C.userRoleName??C.name})):[];n(M),a(Array.isArray(w?.severities)?w.severities:[])}catch{}}catch{}finally{m&&u(!1)}})(),()=>{m=!1}},[]),i.jsx(sa,{severities:r,rules:t,userRoles:s,rawRules:o,loadingRules:c})}function ia(t=1){const{alerts:e}=Oe(),s=ot.useQuery({queryKey:["alerts","list",t],queryFn:()=>e.listAlerts({pageNumber:t,pageSize:10}),staleTime:3e4});return{alerts:s.data??[],loading:s.isLoading,error:s.error,refetch:s.refetch}}function Dl(t){const[e,s]=f.useState(1),{alerts:n,loading:r,refetch:a}=ia(e);return i.jsx(Js,{alerts:n,loading:r,columns:t.columns,onRefetch:a,onPageChange:s})}function Rl({tenant:t,apiDomain:e,rulesDomain:s,headers:n,timeZone:r,userManagementDomain:a,alerts:o,loading:l,columns:c}){const[u]=f.useState(()=>new ot.QueryClient),h=f.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return i.jsx(ot.QueryClientProvider,{client:u,children:i.jsx(_n,{tenant:t,override:h,timeZone:r,userManagementDomain:a,children:Array.isArray(o)?i.jsx(Js,{alerts:o,loading:!!l,columns:c}):i.jsx(Dl,{columns:c})})})}function Ul(t){const{alerts:e}=Oe(),s=ot.useQuery({queryKey:["alerts","report",t],queryFn:()=>e.getAlertsReport(t),staleTime:6e4});return{data:s.data??[],loading:s.isLoading,error:s.error,refetch:s.refetch}}const Ll=[{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=ea;exports.AlertConsole=Js;exports.AlertConsoleWidget=Rl;exports.AlertsTable=Ws;exports.ApiProvider=_n;exports.ArchivedTable=Kr;exports.Clock=Xr;exports.DataTable=Jn;exports.MyPreferencesPanel=ol;exports.SettingsPanel=ta;exports.SettingsTabs=sa;exports.exampleAlertColumns=Ll;exports.useAlertStatusList=aa;exports.useAlerts=ia;exports.useAlertsReport=Ul;exports.useApi=Oe;exports.useUpdateAlertStatus=Vs;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|