@ssgc/alert-console 2.10.0 → 2.10.2
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 +2166 -2113
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),d=require("react"),h=require("antd"),dt=require("@ant-design/icons"),xe=require("react-toastify"),mt=require("@tanstack/react-query"),Aa="#FF3B30",Ta="#FF9500",Na="#FFCC00",ba="#34C759",Ht={critical:Aa,high:Ta,medium:Na,low:ba},un={Critical:Ht.critical,High:Ht.high,Medium:Ht.medium,Low:Ht.low};function ka(t){return un[t]||un.Low}function dn(t){if(!t||typeof t!="string")return 0;const e=t.trim().split(":");if(e.length!==3)return 0;const[s,n,r]=e,a=Number.parseInt(s,10),o=Number.parseInt(n,10),l=Number.parseFloat(r||"0"),c=Number.isFinite(a)?a:0,u=Number.isFinite(o)?o:0,f=Number.isFinite(l)?l:0;return c*3600+u*60+f}function mn(t){return t.toLowerCase().replaceAll("'","").replaceAll("‘","").replaceAll("’","")}const Xn="",Ia=Xn,Ea="",Ma="",Oa="",ja="",fn={snl:{alerts:Xn,rules:Ia},schools:{alerts:Ea,rules:Ma},transit:{alerts:Oa,rules:ja}};function Me(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ca(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function jt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Oe(t,e){const s={...e.headers,...Ca()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`,l=new Error(o);throw l.status=n.status,l}return a}function Da(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Me(t.baseUrl,"/api/Alert"),r=jt(n,{page:s?.pageNumber??1,pageSize:s?.pageSize??10,...s?.anomalyId!==void 0&&{anomalyId:s.anomalyId},...s?.spaceId!==void 0&&{spaceId:s.spaceId},...s?.severityName!==void 0&&{severity:s.severityName},...s?.thirdPartyIds?.length&&{thirdPartyIds:s.thirdPartyIds.join(",")},...s?.searchText&&{searchText:s.searchText},isArchived:s?.isArchived??!1}),a=await Oe(r,{method:"GET",headers:e}),o=Array.isArray(a)?a:[],l=o.length>0?o[0].totalRecords??o.length:0;return{items:o,total:l}},async getAlertStatusList(){const s=Me(t.baseUrl,"/api/Alert/AlertStatusList"),n=await Oe(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=Me(t.baseUrl,"/Alerts/GetAlertsReport"),r=jt(n,s),a=await Oe(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Me(t.baseUrl,"/api/Alert/status");return Oe(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=Me(t.baseUrl,"/api/Alert/GetAdminSettings"),n=await Oe(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=Me(t.baseUrl,"/api/Alert/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Oe(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Me(t.baseUrl,"/api/Alert/GetPreferenceSettings"),n=await Oe(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=Me(t.baseUrl,"/api/Alert/SetPreferenceSettings"),r=await Oe(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=Me(t.baseUrl,"/api/Alert/GetNotifications"),r=jt(n,{alertId:s}),a=await Oe(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=Me(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=jt(n,{alertId:s});return Oe(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const a=Me(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),o=jt(a,{alertId:s,isEmail:n,isSMS:r});return Oe(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Me(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Oe(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Me(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Oe(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null},async getAllSpaces(){const s=Me(t.baseUrl,"/api/Spaces/GetAllSpaces"),n=await Oe(s,{method:"GET",headers:e});return(Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]).map(a=>({spaceId:a?.spaceId??a?.SpaceId,spaceName:a?.spaceName??a?.SpaceName??""}))}}}function hn(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ra(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function qt(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=hn(t.baseUrl,"/api/Rules"),n=hn(t.baseUrl,"/api/Rules/lookups");return{async getRules(){const r=await qt(s,{method:"GET",headers:e});return Array.isArray(r)?r:[]},async setEscalationSettings(r){return qt(s,{method:"POST",headers:e,body:JSON.stringify(r??{})})},async getLookups(){return qt(n,{method:"GET",headers:e})},async updateRule(r,a){const o=`${s}/${r}`;return qt(o,{method:"PUT",headers:e,body:JSON.stringify(a??{})})}}}function La(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ss={exports:{}},Fa=ss.exports,yn;function $a(){return yn||(yn=1,(function(t,e){(function(s,n){t.exports=n()})(Fa,(function(){var s=1e3,n=6e4,r=36e5,a="millisecond",o="second",l="minute",c="hour",u="day",f="week",m="month",S="quarter",y="year",A="date",T="Invalid Date",x=/^(\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,H={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(j){var k=["th","st","nd","rd"],w=j%100;return"["+j+(k[(w-20)%10]||k[w]||k[0])+"]"}},J=function(j,k,w){var M=String(j);return!M||M.length>=k?j:""+Array(k+1-M.length).join(w)+j},E={s:J,z:function(j){var k=-j.utcOffset(),w=Math.abs(k),M=Math.floor(w/60),b=w%60;return(k<=0?"+":"-")+J(M,2,"0")+":"+J(b,2,"0")},m:function j(k,w){if(k.date()<w.date())return-j(w,k);var M=12*(w.year()-k.year())+(w.month()-k.month()),b=k.clone().add(M,m),R=w-b<0,D=k.clone().add(M+(R?-1:1),m);return+(-(M+(w-b)/(R?b-D:D-b))||0)},a:function(j){return j<0?Math.ceil(j)||0:Math.floor(j)},p:function(j){return{M:m,y,w:f,d:u,D:A,h:c,m:l,s:o,ms:a,Q:S}[j]||String(j||"").toLowerCase().replace(/s$/,"")},u:function(j){return j===void 0}},L="en",z={};z[L]=H;var C="$isDayjsObject",q=function(j){return j instanceof Q||!(!j||!j[C])},p=function j(k,w,M){var b;if(!k)return L;if(typeof k=="string"){var R=k.toLowerCase();z[R]&&(b=R),w&&(z[R]=w,b=R);var D=k.split("-");if(!b&&D.length>1)return j(D[0])}else{var _=k.name;z[_]=k,b=_}return!M&&b&&(L=b),b||!M&&L},v=function(j,k){if(q(j))return j.clone();var w=typeof k=="object"?k:{};return w.date=j,w.args=arguments,new Q(w)},O=E;O.l=p,O.i=q,O.w=function(j,k){return v(j,{locale:k.$L,utc:k.$u,x:k.$x,$offset:k.$offset})};var Q=(function(){function j(w){this.$L=p(w.locale,null,!0),this.parse(w),this.$x=this.$x||w.x||{},this[C]=!0}var k=j.prototype;return k.parse=function(w){this.$d=(function(M){var b=M.date,R=M.utc;if(b===null)return new Date(NaN);if(O.u(b))return new Date;if(b instanceof Date)return new Date(b);if(typeof b=="string"&&!/Z$/i.test(b)){var D=b.match(x);if(D){var _=D[2]-1||0,G=(D[7]||"0").substring(0,3);return R?new Date(Date.UTC(D[1],_,D[3]||1,D[4]||0,D[5]||0,D[6]||0,G)):new Date(D[1],_,D[3]||1,D[4]||0,D[5]||0,D[6]||0,G)}}return new Date(b)})(w),this.init()},k.init=function(){var w=this.$d;this.$y=w.getFullYear(),this.$M=w.getMonth(),this.$D=w.getDate(),this.$W=w.getDay(),this.$H=w.getHours(),this.$m=w.getMinutes(),this.$s=w.getSeconds(),this.$ms=w.getMilliseconds()},k.$utils=function(){return O},k.isValid=function(){return this.$d.toString()!==T},k.isSame=function(w,M){var b=v(w);return this.startOf(M)<=b&&b<=this.endOf(M)},k.isAfter=function(w,M){return v(w)<this.startOf(M)},k.isBefore=function(w,M){return this.endOf(M)<v(w)},k.$g=function(w,M,b){return O.u(w)?this[M]:this.set(b,w)},k.unix=function(){return Math.floor(this.valueOf()/1e3)},k.valueOf=function(){return this.$d.getTime()},k.startOf=function(w,M){var b=this,R=!!O.u(M)||M,D=O.p(w),_=function(ge,ce){var V=O.w(b.$u?Date.UTC(b.$y,ce,ge):new Date(b.$y,ce,ge),b);return R?V:V.endOf(u)},G=function(ge,ce){return O.w(b.toDate()[ge].apply(b.toDate("s"),(R?[0,0,0,0]:[23,59,59,999]).slice(ce)),b)},X=this.$W,te=this.$M,ie=this.$D,ve="set"+(this.$u?"UTC":"");switch(D){case y:return R?_(1,0):_(31,11);case m:return R?_(1,te):_(0,te+1);case f:var le=this.$locale().weekStart||0,de=(X<le?X+7:X)-le;return _(R?ie-de:ie+(6-de),te);case u:case A:return G(ve+"Hours",0);case c:return G(ve+"Minutes",1);case l:return G(ve+"Seconds",2);case o:return G(ve+"Milliseconds",3);default:return this.clone()}},k.endOf=function(w){return this.startOf(w,!1)},k.$set=function(w,M){var b,R=O.p(w),D="set"+(this.$u?"UTC":""),_=(b={},b[u]=D+"Date",b[A]=D+"Date",b[m]=D+"Month",b[y]=D+"FullYear",b[c]=D+"Hours",b[l]=D+"Minutes",b[o]=D+"Seconds",b[a]=D+"Milliseconds",b)[R],G=R===u?this.$D+(M-this.$W):M;if(R===m||R===y){var X=this.clone().set(A,1);X.$d[_](G),X.init(),this.$d=X.set(A,Math.min(this.$D,X.daysInMonth())).$d}else _&&this.$d[_](G);return this.init(),this},k.set=function(w,M){return this.clone().$set(w,M)},k.get=function(w){return this[O.p(w)]()},k.add=function(w,M){var b,R=this;w=Number(w);var D=O.p(M),_=function(te){var ie=v(R);return O.w(ie.date(ie.date()+Math.round(te*w)),R)};if(D===m)return this.set(m,this.$M+w);if(D===y)return this.set(y,this.$y+w);if(D===u)return _(1);if(D===f)return _(7);var G=(b={},b[l]=n,b[c]=r,b[o]=s,b)[D]||1,X=this.$d.getTime()+w*G;return O.w(X,this)},k.subtract=function(w,M){return this.add(-1*w,M)},k.format=function(w){var M=this,b=this.$locale();if(!this.isValid())return b.invalidDate||T;var R=w||"YYYY-MM-DDTHH:mm:ssZ",D=O.z(this),_=this.$H,G=this.$m,X=this.$M,te=b.weekdays,ie=b.months,ve=b.meridiem,le=function(ce,V,P,re){return ce&&(ce[V]||ce(M,R))||P[V].slice(0,re)},de=function(ce){return O.s(_%12||12,ce,"0")},ge=ve||function(ce,V,P){var re=ce<12?"AM":"PM";return P?re.toLowerCase():re};return R.replace($,(function(ce,V){return V||(function(P){switch(P){case"YY":return String(M.$y).slice(-2);case"YYYY":return O.s(M.$y,4,"0");case"M":return X+1;case"MM":return O.s(X+1,2,"0");case"MMM":return le(b.monthsShort,X,ie,3);case"MMMM":return le(ie,X);case"D":return M.$D;case"DD":return O.s(M.$D,2,"0");case"d":return String(M.$W);case"dd":return le(b.weekdaysMin,M.$W,te,2);case"ddd":return le(b.weekdaysShort,M.$W,te,3);case"dddd":return te[M.$W];case"H":return String(_);case"HH":return O.s(_,2,"0");case"h":return de(1);case"hh":return de(2);case"a":return ge(_,G,!0);case"A":return ge(_,G,!1);case"m":return String(G);case"mm":return O.s(G,2,"0");case"s":return String(M.$s);case"ss":return O.s(M.$s,2,"0");case"SSS":return O.s(M.$ms,3,"0");case"Z":return D}return null})(ce)||D.replace(":","")}))},k.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},k.diff=function(w,M,b){var R,D=this,_=O.p(M),G=v(w),X=(G.utcOffset()-this.utcOffset())*n,te=this-G,ie=function(){return O.m(D,G)};switch(_){case y:R=ie()/12;break;case m:R=ie();break;case S:R=ie()/3;break;case f:R=(te-X)/6048e5;break;case u:R=(te-X)/864e5;break;case c:R=te/r;break;case l:R=te/n;break;case o:R=te/s;break;default:R=te}return b?R:O.a(R)},k.daysInMonth=function(){return this.endOf(m).$D},k.$locale=function(){return z[this.$L]},k.locale=function(w,M){if(!w)return this.$L;var b=this.clone(),R=p(w,M,!0);return R&&(b.$L=R),b},k.clone=function(){return O.w(this.$d,this)},k.toDate=function(){return new Date(this.valueOf())},k.toJSON=function(){return this.isValid()?this.toISOString():null},k.toISOString=function(){return this.$d.toISOString()},k.toString=function(){return this.$d.toUTCString()},j})(),he=Q.prototype;return v.prototype=he,[["$ms",a],["$s",o],["$m",l],["$H",c],["$W",u],["$M",m],["$y",y],["$D",A]].forEach((function(j){he[j[1]]=function(k){return this.$g(k,j[0],j[1])}})),v.extend=function(j,k){return j.$i||(j(k,Q,v),j.$i=!0),v},v.locale=p,v.isDayjs=q,v.unix=function(j){return v(1e3*j)},v.en=z[L],v.Ls=z,v.p={},v}))})(ss)),ss.exports}var Pa=$a();const Wa=La(Pa);function er(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 tr(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 pn(t){const{hours:e,minutes:s,seconds:n}=tr(t);return Wa().hour(e).minute(s).second(n).millisecond(0)}function je(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ba(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Gt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Ce(t,e){const s={...e.headers,...Ba()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.Message||`HTTP ${n.status}`;throw new Error(o)}return a}const oe=(...t)=>t.find(e=>e!=null);function Dt(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 Va(t){return Array.isArray(t)?t.map(e=>Dt(e,["alertLogId","alertId","status","description","actionNotes","createdDate","createdBy","modifiedDate","modifiedBy"])):t}function Za(t){return{id:String(oe(t?.AlertId,t?.alertId)??""),alertNumber:oe(t?.AlertNumber,t?.alertNumber),priority:oe(t?.Priority,t?.priority,"Low"),timestamp:oe(t?.UpdatedUtc,t?.timestamp,""),statusType:oe(t?.Status,t?.statusType,""),description:oe(t?.Description,t?.description,""),eventName:oe(t?.EventName,t?.eventName),ruleName:oe(t?.RuleName,t?.ruleName),spaceId:oe(t?.SpaceId,t?.spaceId),spaceName:oe(t?.SpaceName,t?.spaceName),anomalyId:oe(t?.AnomalyId,t?.anomalyId),severityId:oe(t?.SeverityId,t?.severityId),assignTeam:oe(t?.AssignTeam,t?.assignTeam),cameraName:oe(t?.CameraName,t?.cameraName),type:oe(t?.Type,t?.type),mediaDetails:oe(t?.MediaDetails,t?.mediaDetails,t?.MediaUrls,t?.mediaUrls),additionalMedia:oe(t?.AdditionalMedia,t?.additionalMedia),timeElapsed:oe(t?.TimeElapsed,t?.timeElapsed),timeRemaining:oe(t?.TimeRemaining,t?.timeRemaining),anomalyName:oe(t?.AnomalyName,t?.anomalyName),alertDetails:oe(t?.AlertDetails,t?.alertDetails),statusHistory:Va(oe(t?.StatusHistory,t?.statusHistory)),isEmailSent:oe(t?.IsEmailSent,t?.isEmailSent),isSMSSent:oe(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:oe(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function za(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts"),r=Gt(n,{customerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",pageSize:s?.pageSize??10,page:s?.pageNumber??1,...s?.anomalyId!==void 0&&{anomalyId:s.anomalyId},...s?.spaceId!==void 0&&{spaceId:s.spaceId},...s?.severityId!==void 0&&{severityId:s.severityId},...s?.thirdPartyIds?.length&&{ThirdPartyIds:s.thirdPartyIds.join(",")},...s?.searchText&&{searchText:s.searchText},isArchived:s?.isArchived??!1}),a=await Ce(r,{method:"GET",headers:e});return{items:Array.isArray(a?.Items)?a.Items.map(Za):[],total:a?.Total}},async getAlertStatusList(){const s=je(t.baseUrl,"/api/detectionpolicy/alerts/StatusList"),n=await Ce(s,{method:"GET",headers:e});return(Array.isArray(n)?n:[]).map(a=>Dt(a,["alertStatusId","value","statusName"]))},async getAlertsReport(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),r=Gt(n,s),a=await Ce(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/Log"),r={AlertId:s.alertId??s.alertUniqueId??s.AlertId,Status:s.status??s.Status??"",Notes:s.notes??s.Notes??""};return Ce(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getAdminSettings(){const s=je(t.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),n=await Ce(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n.Data??n;if(r&&typeof r=="object")return Dt(r,["userId","isAdminSetting","sortBy"],{sortBy:"SortOption"})}return null},async setAdminSettings(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/SetAdminSettings"),r={Settings:{UserId:0,IsAdminSetting:!0,SortOption:s?.sortBy??"",GroupBy:s?.groupBy??null}};return Ce(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=je(t.baseUrl,"/api/detectionpolicy/alerts/GetPreferenceSettings"),n=await Ce(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),r=u=>{const{hours:f,minutes:m,seconds:S}=tr(u);return(f*3600+m*60+S)*1e7},a={Settings:{UserId:0,AnomalyIds:Array.isArray(s?.anomalyIds)?s.anomalyIds.map(u=>String(u)):[],DoNotDisturbStart:{Ticks:r(s?.doNotDisturbStart)},DoNotDisturbEnd:{Ticks:r(s?.doNotDisturbEnd)},InApp:!!s?.inApp,SMS:!!s?.sms,Email:!!s?.email,SortBy:s?.sortBy??""}},o=await Ce(n,{method:"POST",headers:e,body:JSON.stringify(a)}),l=o?.responseStatus??!0,c=o?.data??o?.message??"Preferences updated successfully.";return{responseStatus:l,errorMessage:l?"":o?.errorMessage??o?.Message??o?.message??"",statusCode:200,data:c}},async sendSMSorEmailNotifications(s,n,r){const a=je(t.baseUrl,"/api/detectionpolicy/alerts/SendSMSorEmailNotifications"),o=Gt(a,{alertId:s,isEmail:n,isSMS:r});return Ce(o,{method:"POST",headers:e})},async getAlertNotifications(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),r=Gt(n,{alertId:s}),a=await Ce(r,{method:"GET",headers:e});let o=[];return Array.isArray(a)?o=a:Array.isArray(a?.data)&&(o=a.data),o.map(l=>Dt(l,["alertNotificationSentId","alertId","notificationType","receipientName","receipentPhoneNumber","messageSID","messageStatus","receipientEmail","notificationReceipientType","sentAt"]))},async getTimeZoneMasters(){const s=je(t.baseUrl,"/api/TimeZoneMaster"),n=await Ce(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n.Data:[]).map(a=>Dt(a,["timeZoneUniqueId","ianaTimeZoneId","timeZoneName","offset"]))},async getAllSpaces(){const s=t.spacesBaseUrl||t.baseUrl,n=je(s,"/api/AllSpaces"),r=await Ce(n,{method:"GET",headers:e});return(Array.isArray(r?.Data)?r.Data:[]).map(o=>({spaceId:o?.SpaceId??o?.spaceId,spaceName:o?.SpaceName??o?.spaceName??""}))},async getMyAppPreferences(){const s=je(t.baseUrl,"/MyProfile"),n=await Ce(s,{method:"GET",headers:e}),r=n?.data?.userGuid??n?.Data?.userGuid??n?.userGuid;if(!r)return null;const a=je(t.baseUrl,`/api/GetMyAppPreferences/${r}`),o=await Ce(a,{method:"GET",headers:e});if(o&&typeof o=="object"){const l=o.data??o.Data??o,c=l?.timeZoneUniqueId??l?.TimeZoneUniqueId;if(c)return{timeZoneUniqueId:c}}return null}}}function Ha(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Je(t,e){const s={...e.headers,...Ha()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function qa(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/api/detectionpolicy/rules",t.baseUrl).toString();return{async getRules(){const n=await Je(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 Je(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=p=>new URL(p,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[Je(n("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:e}),Je(n("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:e}),Je(n("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:e}),Je(n("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:e}),Je(n("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:e}),Je(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,l,c,u,f,m]=await Promise.allSettled(a),S=p=>{if(p.status!=="fulfilled")return[];const v=p.value;return Array.isArray(v)?v:Array.isArray(v?.Data)?v.Data:Array.isArray(v?.data)?v.data:[]},y=S(o),A=S(l),T=S(c),x=S(u),$=S(f),H=m.status==="fulfilled"?m.value:null;let J=[];Array.isArray(H)?J=H:Array.isArray(H?.Data)?J=H.Data:Array.isArray(H?.data)&&(J=H.data);const E=y.map(p=>({actionTypeId:Number(p?.ActionTypeId),name:p?.DisplayName??p?.Name??""})),L=A.map(p=>({recordId:p?.AnomalyId,anomalyName:p?.DisplayName??p?.Name??""})),z=T.map(p=>({thirdPartyId:Number(p?.ThirdPartyId),thirdPartyName:p?.ThirdPartyName??p?.Name??""})),C=J.map(p=>({userRoleId:p.UserRoleId??p.userRoleId??p.Id??p.id??0,userRoleName:p.UserRoleName??p.userRoleName??p.Name??p.name??""})),q={actionTypes:E,anomalies:L,thirdParties:z};return x.length&&(q.severities=x.map(p=>({severityId:p?.SeverityId??p?.severityId,severityName:p?.DisplayName??p?.SeverityName??p?.Name??p?.name??""}))),$.length&&(q.scheduleTypes=$),C.length&&(q.userRoles=C),q},async updateRule(n,r){const a=`${s}/${n}`,{escalationSettings:o,Anomaly:l,Severity:c,...u}=r??{};return Je(a,{method:"PUT",headers:e,body:JSON.stringify({...u,CustomerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",Version:{DeDupWindowSeconds:0,IncludeSubjectInHash:!0},AnomalyId:l?.AnomalyId,SeverityId:c?.SeverityId,EscalationSettings:o?{...o,ThirdPartyIds:o.thirdPartyId??[]}:{}})})}}}function Ga(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function et(t,e){const s={...e.headers,...Ga()},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 Ya(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/list-rule",t.baseUrl).toString();return{async getRules(){const n=await et(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 et(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=C=>new URL(C,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[et(n("/api/ActionTypeMaster/GetAll"),{method:"GET",headers:e}),et(n("/api/anomaly/anomaly-list"),{method:"POST",headers:e,body:JSON.stringify({RuleLevel:1})}),et(n("/api/Lookup/ThirdParties"),{method:"GET",headers:e}),et(n("/api/anomaly/severity-list"),{method:"GET",headers:e}),et(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,l,c,u,f]=await Promise.allSettled(a),m=C=>{if(C.status!=="fulfilled")return[];const q=C.value;return Array.isArray(q)?q:Array.isArray(q?.data)?q.data:[]},S=m(o),y=m(l),A=m(c),T=m(u),x=f.status==="fulfilled"?f.value:null,$=S.map(C=>({actionTypeId:C?.ActionTypeUniqueId,name:C?.Name??""})),H=y.map(C=>({recordId:C?.AnomalyId,anomalyName:C?.DisplayName??C?.Name??""})),J=A.map(C=>({thirdPartyId:Number(C?.ThirdPartyId),thirdPartyName:C?.ThirdPartyName??C?.Name??""}));let E=[];Array.isArray(x)?E=x:Array.isArray(x?.Data)?E=x.Data:Array.isArray(x?.data)&&(E=x.data);const L=E.map(C=>({userRoleId:C.userRoleId??0,userRoleName:C.userRoleName??""})),z={actionTypes:$,anomalies:H,thirdParties:J};return T.length&&(z.severities=T.map(C=>({SeverityId:C.SeverityId,DisplayName:C.SeverityName??C.DisplayName??""}))),L.length&&(z.userRoles=L),z},async updateRule(n,r){const a=new URL("/update-rule",t.baseUrl).toString(),{escalationSettings:o,ruleId:l,ruleName:c,ruleDesc:u,...f}=r??{},m=o??{},S=(m.escalationSettingsActionTypeIds??[]).filter(A=>A!=null&&!Number.isNaN(A)),y={Level1UserRoleId:m.level1UserRoleId??0,Level1PostAssistTime:m.level1PostAssistTime??0,Level2UserRoleId:m.level2UserRoleId??0,Level2PostAssistTime:m.level2PostAssistTime??0,Level3UserRoleId:m.level3UserRoleId??0,Level3PostAssistTime:m.level3PostAssistTime??0,EscalationSettingsActionTypeIds:S,ThirdPartyIds:m.thirdPartyId??[],HumanLoop:m.humanLoop??!1};return et(a,{method:"POST",headers:e,body:JSON.stringify({...f,RuleId:l??f.RuleId??n,RuleName:c??f.RuleName,RuleDesc:u??f.RuleDesc??null,ActionTypeUniqueIdList:S,EscalationSettings:y})})}}}function Fe(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 Yt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function $e(t,e){const s={...e.headers,..._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 Ja(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Fe(t.baseUrl,"/api/Alerts"),r=Yt(n,{pageSize:s?.pageSize??10,pageNumber:s?.pageNumber??1,...s?.spaceNumber!==void 0&&{spaceNumber:s.spaceNumber},...s?.anomalyId!==void 0&&{anomalyId:s.anomalyId},...s?.severityId!==void 0&&{severityId:s.severityId},...s?.thirdPartyIds?.length&&{thirdPartyIds:s.thirdPartyIds.join(",")},...s?.isArchived!==void 0&&{isArchived:s.isArchived}}),a=await $e(r,{method:"GET",headers:e});if(Array.isArray(a))return a;if(a&&typeof a=="object"){if(Array.isArray(a.items))return{items:a.items,total:typeof a.total=="number"?a.total:void 0};if(Array.isArray(a.data))return{items:a.data,total:typeof a.total=="number"?a.total:void 0};if(Array.isArray(a.alerts))return{items:a.alerts,total:typeof a.total=="number"?a.total:void 0}}return[]},async getAlertStatusList(){const s=Fe(t.baseUrl,"/api/Alerts/GetAlertStatus"),n=await $e(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getAlertsReport(s){const n=Fe(t.baseUrl,"/Alerts/GetAlertsReport"),r=Yt(n,s),a=await $e(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Fe(t.baseUrl,"/api/Alerts/UpdateAlertLog"),r={alertId:s.alertId,action:s.status,notes:s.notes};return $e(n,{method:"PUT",headers:e,body:JSON.stringify(r??{})})},async getAdminSettings(){const s=Fe(t.baseUrl,"/api/Alerts/GetAdminSettings"),n=await $e(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("userId"in n)return n}return null},async setAdminSettings(s){const n=Fe(t.baseUrl,"/api/Alerts/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return $e(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Fe(t.baseUrl,"/api/Alerts/GetPreferenceSettings"),n=await $e(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=Fe(t.baseUrl,"/api/Alerts/SetPreferenceSettings"),r=await $e(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,o=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":r?.errorMessage??r?.message??"",statusCode:200,data:o}},async getAlertNotifications(s){const n=Fe(t.baseUrl,"/api/Alerts/GetNotifications"),r=Yt(n,{alertId:s}),a=await $e(r,{method:"GET",headers:e});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]},async sendSMSorEmailNotifications(s,n,r){const a=Fe(t.baseUrl,"/api/Alerts/SendSMSorEmailNotifications"),o=Yt(a,{alertId:s,isEmail:n,isSMS:r});return $e(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Fe(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await $e(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Fe(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await $e(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null}}}const sr=d.createContext(null);function nr({tenant:t="snl",override:e,timeZone:s,userManagementDomain:n,spacesBaseUrl:r,children:a}){const o=d.useMemo(()=>{const c=e?.alertsBaseUrl?.trim()||fn[t]?.alerts||"";let u=e?.rulesBaseUrl?.trim()||fn[t]?.rules||"";t==="snl"&&(u=c);const f=e?.headers;return{tenant:t,alertsBaseUrl:c,rulesBaseUrl:u,headers:f,timeZone:s,userManagementDomain:n,spacesBaseUrl:r}},[t,e?.alertsBaseUrl,e?.rulesBaseUrl,JSON.stringify(e?.headers||{}),s,n,r]),l=d.useMemo(()=>{const c={baseUrl:o.alertsBaseUrl,headers:o.headers},u={baseUrl:o.rulesBaseUrl,headers:o.headers},f={schools:()=>za({...c,spacesBaseUrl:o.spacesBaseUrl}),transit:()=>Ja(c),snl:()=>Da(c)},m={schools:()=>qa({...u,userManagementBaseUrl:o.userManagementDomain}),transit:()=>Ya({...u,userManagementBaseUrl:o.userManagementDomain}),snl:()=>Ua({baseUrl:o.alertsBaseUrl,headers:o.headers})};return{config:o,alerts:f[o.tenant](),rules:m[o.tenant]()}},[o]);return i.jsx(sr.Provider,{value:l,children:a})}function De(){const t=d.useContext(sr);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}const Ka={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Qa={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Js=6,Ks=7;function gn(t,e,s){const n=t===Js,r=t===Ks,a=e.isEmailSent??!1,o=e.isSMSSent??!1,l=n&&a||r&&o,c=n?"Send Email":r?"Send SMS":s,u=n&&a?"Email sent":r&&o?"SMS sent":c,f=n&&a?"Email sent":r&&o?"SMS sent":`Click to ${c}`;return{isDisabled:l,buttonText:u,tooltipTitle:f}}function bs(t,e){return`${t}-${e?"email":"sms"}`}function _t(t){return t===Js||t===Ks}function ds({value:t,onChange:e,options:s,className:n,dropdownWidth:r}){return i.jsx(h.Select,{className:n,options:s,value:t,onChange:e,dropdownMatchSelectWidth:r??260})}const Xa=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function ei({value:t,onChange:e,options:s}){return i.jsx(ds,{className:"w-[140px]",value:t,onChange:e,options:s||Xa})}const ti=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function si({value:t,onChange:e,options:s}){return i.jsx(ds,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||ti})}function ni({value:t,onChange:e,options:s}){return i.jsx(ds,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const ri=[{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 ai({value:t,onChange:e,options:s}){return i.jsx(ds,{className:"w-[130px]",value:t,onChange:e,options:s||ri})}function rr({columns:t,data:e,loading:s=!1,pageSize:n=10,total:r,currentPage:a,rowKey:o="id",toolbar:l,tableProps:c,onPageChange:u}){const m=r===void 0&&a!==void 0?e.length===n?a*n+1:(a-1)*n+e.length:void 0;return i.jsxs("div",{children:[l,i.jsx(h.Table,{rowKey:o,dataSource:e,columns:t,loading:s,pagination:{pageSize:n,current:a,total:r??m,showSizeChanger:!1,showTotal:S=>`Total: ${S}`,onChange:u},bordered:!0,...c})]})}function ii(t){if(!t||typeof t!="string")return!1;const e=t.split("?")[0].toLowerCase();return e.endsWith(".mp4")||e.endsWith(".webm")||e.endsWith(".ogg")||e.endsWith(".m3u8")}function Fs(t){const e=(t?.mediaType||t?.type||"").toString().toLowerCase();return e==="video"||e==="mp4"?!0:ii(t?.mediaUrl||t)}function oi(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 ar(t){const e=t;return e?(Array.isArray(e)?e:[e]).flatMap(oi):[]}const li=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ci=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),Sn=t=>{const e=ci(t);return e.charAt(0).toUpperCase()+e.slice(1)},ir=(...t)=>t.filter((e,s,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===s).join(" ").trim(),ui=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var di={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 mi=d.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:a,iconNode:o,...l},c)=>d.createElement("svg",{ref:c,...di,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:ir("lucide",r),...!a&&!ui(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,f])=>d.createElement(u,f)),...Array.isArray(a)?a:[a]]));const ms=(t,e)=>{const s=d.forwardRef(({className:n,...r},a)=>d.createElement(mi,{ref:a,iconNode:e,className:ir(`lucide-${li(Sn(t))}`,`lucide-${t}`,n),...r}));return s.displayName=Sn(t),s};const fi=[["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"}]],or=ms("image-off",fi);const hi=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],yi=ms("loader-circle",hi);const pi=[["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"}]],lr=ms("maximize-2",pi);const gi=[["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"}]],Si=ms("minimize-2",gi),tt=16,st=2,xn={Low:"#22c55e",Medium:"#fde047",High:"#fb2c36",Critical:"#7a0707"};function cr({boxes:t,priority:e="High"}){const s=xn[e]??xn.High;return i.jsx(i.Fragment,{children:t.map((n,r)=>i.jsxs("div",{className:"absolute pointer-events-none",style:{left:n.x,top:n.y,width:n.width,height:n.height},children:[i.jsx("div",{className:"absolute left-0 whitespace-nowrap rounded-sm px-2 py-1 text-[10px] font-semibold text-white",style:{backgroundColor:s,transform:"translateY(-140%)"},children:n.label}),i.jsx("div",{className:"absolute top-0 left-0",style:{width:tt,height:tt,borderTop:`${st}px solid ${s}`,borderLeft:`${st}px solid ${s}`}}),i.jsx("div",{className:"absolute top-0 right-0",style:{width:tt,height:tt,borderTop:`${st}px solid ${s}`,borderRight:`${st}px solid ${s}`}}),i.jsx("div",{className:"absolute bottom-0 left-0",style:{width:tt,height:tt,borderBottom:`${st}px solid ${s}`,borderLeft:`${st}px solid ${s}`}}),i.jsx("div",{className:"absolute bottom-0 right-0",style:{width:tt,height:tt,borderBottom:`${st}px solid ${s}`,borderRight:`${st}px solid ${s}`}})]},`${n.label}-${r}`))})}const xi=t=>{if(!t)return[0,0,0,0];if(typeof t=="string")return t.replace(/[()[\]\s]/g,"").split(",").map(Number);if(!Array.isArray(t)||t.length===0)return[0,0,0,0];const e=t[0];return typeof e=="string"?e.replace(/[()[\]\s]/g,"").split(",").map(Number):Array.isArray(e)?e.map(Number):t.map(Number)},ur=(t,e,s,n,r)=>{if(!e||!s||!n||!r)return[];const a=n/e,o=r/s;return t.flatMap(l=>{const[c,u,f,m]=xi(l.bbox_xyxy);return c>e||f>e||u>s||m>s?[]:[{personName:l.personName,x:c*a,y:u*o,width:(f-c)*a,height:(m-u)*o}]})},vn={naturalWidth:0,naturalHeight:0,renderedWidth:0,renderedHeight:0};function dr(){const t=d.useRef(null),[e,s]=d.useState(vn),n=d.useCallback(()=>{const a=t.current;a&&s({naturalWidth:a.naturalWidth,naturalHeight:a.naturalHeight,renderedWidth:a.offsetWidth,renderedHeight:a.offsetHeight})},[]),r=d.useCallback(()=>{s(vn)},[]);return{imageRef:t,dimensions:e,onLoad:n,resetDimensions:r}}const mr=({isOpen:t,onClose:e,src:s,type:n="image",detections:r=[],priority:a})=>{const[o,l]=d.useState(!1),[c,u]=d.useState(!1),{imageRef:f,dimensions:m,onLoad:S,resetDimensions:y}=dr(),A=d.useMemo(()=>ur(r,m.naturalWidth,m.naturalHeight,m.renderedWidth,m.renderedHeight),[r,m]),T=d.useMemo(()=>A.map(x=>({...x,label:x.personName||""})),[A]);return d.useEffect(()=>{t&&(u(!1),y())},[t,s,y]),d.useEffect(()=>{t&&(!s||c)&&e()},[t,s,c,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:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),e())},onTouchStart:e,children:i.jsxs("div",{className:`relative ${o?"w-full h-full":"max-w-5xl max-h-[90vh] w-full"} flex items-center justify-center`,onClick:x=>x.stopPropagation(),children:[n==="image"?i.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[i.jsx("img",{ref:f,src:s,alt:"preview",className:`object-contain rounded-lg shadow-lg ${o?"w-full h-full":"max-w-full max-h-[90vh]"}`,onLoad:S,onError:()=>u(!0)}),i.jsx(cr,{boxes:T,priority:a})]}):i.jsx("video",{src:s,controls:!0,className:`object-contain rounded-lg shadow-lg ${o?"w-full h-full":"max-w-full max-h-[90vh]"}`,onError:()=>u(!0)}),i.jsx("button",{onClick:e,className:"absolute top-3 right-8 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:"✕"}),i.jsx("button",{onClick:()=>l(!o),className:"absolute bottom-3 right-8 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:o?i.jsx(Si,{size:20}):i.jsx(lr,{size:20})})]})}):null};function vi(t){const s=ar(t.mediaDetails)[0];if(!s)return null;const n=s.mediaUrl??s;return typeof n!="string"||!n.length?null:{url:n,item:s}}function fr({record:t}){const e=d.useMemo(()=>vi(t),[t]),[s,n]=d.useState(!1),[r,a]=d.useState(!1),{imageRef:o,dimensions:l,onLoad:c,resetDimensions:u}=dr(),f=d.useMemo(()=>t.bbox_xyxy?[{bbox_xyxy:t.bbox_xyxy,personName:t.personName}]:[],[t.bbox_xyxy,t.personName]),m=d.useMemo(()=>ur(f,l.naturalWidth,l.naturalHeight,l.renderedWidth,l.renderedHeight),[f,l]),S=d.useMemo(()=>m.map(H=>({...H,label:H.personName||""})),[m]);if(d.useEffect(()=>{u(),a(!1)},[e?.url,u]),!e)return i.jsx("span",{className:"text-gray-400 text-sm",children:"—"});const{url:y,item:A}=e,T=Fs(A),x=T?"video":"image",$="block w-[72px] h-[54px] object-cover bg-gray-100 border border-gray-200 rounded-sm";return i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",disabled:r,className:"p-0 border-0 bg-transparent rounded-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-1 cursor-pointer disabled:cursor-not-allowed disabled:opacity-60","aria-label":r?"Preview unavailable":"Expand preview",onClick:()=>n(!0),children:r?i.jsx("span",{className:`${$} flex items-center justify-center text-gray-400`,children:i.jsx(or,{size:20,"aria-hidden":!0})}):T?i.jsx("video",{src:y,className:$,muted:!0,playsInline:!0,preload:"metadata",onError:()=>a(!0)}):i.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[i.jsx("img",{ref:o,src:y,alt:"",className:$,onLoad:c,onError:()=>a(!0)}),i.jsx(cr,{boxes:S,priority:t.priority})]})}),i.jsx(mr,{isOpen:s,onClose:()=>n(!1),src:y,type:x,detections:f,priority:t.priority})]})}function wi(t,e){const[s,n]=d.useState(t);return d.useEffect(()=>{const r=window.setTimeout(()=>n(t),e);return()=>window.clearTimeout(r)},[t,e]),s}function Qs({data:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,columns:a,renderActions:o,onAlertIdClick:l,onRefetch:c,onPageChange:u,onFilterChange:f,resetKey:m}){const[S,y]=d.useState("All"),[A,T]=d.useState("All"),[x,$]=d.useState("All"),[H,J]=d.useState("All"),[E,L]=d.useState(""),[z,C]=d.useState(r??1);d.useEffect(()=>{m!==void 0&&(y("All"),T("All"),$("All"),J("All"),L(""),C(1))},[m]),d.useEffect(()=>{r!==void 0&&C(r)},[r]);const[q,p]=d.useState([{label:"All",value:"All"}]),[v,O]=d.useState([]),[Q,he]=d.useState([]),[j,k]=d.useState([]),[w,M]=d.useState(new Set),{rules:b,alerts:R,config:D}=De(),_=D.tenant==="schools",G=D.tenant==="transit",X=wi(E,600),te=_&&X.trim()?100:s,ie={6:{title:"Email",kind:"icon",icon:i.jsx(dt.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:i.jsx(dt.MessageOutlined,{})}};d.useEffect(()=>{if(!R.getAllSpaces)return;let V=!0;return(async()=>{try{const P=await R.getAllSpaces();if(V){const re=P.map(ae=>({label:G?String(ae.spaceNumber??ae.spaceName??""):ae.spaceName,value:String(G?ae.spaceNumber??ae.spaceId:ae.spaceId)}));O([{label:"All",value:"All"},...re])}}catch(P){console.error("Error loading space options",P)}})(),()=>{V=!1}},[R,G]),d.useEffect(()=>{let V=!0;return(async()=>{try{const P=await b.getLookups(),ae=(Array.isArray(P.thirdParties)?P.thirdParties:[]).map(Te=>({label:Te.thirdPartyName,value:String(Te.thirdPartyId)})),Ae=(Array.isArray(P.anomalies)?P.anomalies:[]).map(Te=>({label:Te.anomalyName,value:Te.anomalyId})),Re=(Array.isArray(P.severities)?P.severities:[]).map(Te=>({label:Te.severityName,value:String(Te.severityId)}));V&&(p([{label:"All",value:"All"},...ae]),Ae.length&&he([{label:"All Types",value:"All"},...Ae]),Re.length&&k([{label:"All levels",value:"All"},...Re]))}catch(P){console.error("Error loading filter options",P)}})(),()=>{V=!1}},[b]),d.useEffect(()=>{if(!f)return;const V=j.find(re=>re.value===S),P={anomalyId:Q.length>1&&A!=="All"?A:void 0,spaceId:!G&&v.length>1&&x!=="All"?Number(x):void 0,spaceNumber:G&&v.length>1&&x!=="All"?x:void 0,severityId:j.length>1&&S!=="All"?S:void 0,severityName:j.length>1&&S!=="All"?V?.label:void 0,thirdPartyIds:H==="All"?void 0:[Number(H)],searchText:X.trim()||void 0};f(P),u?.(1)},[A,x,S,H,X,Q.length,v.length,j.length,G,_]);const ve=Q.length>1?Q:void 0,le=v.length>1?v:void 0,de=j.length>1?j:void 0,ge=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:V=>i.jsx(h.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Qa[V]}`,backgroundColor:Ka[V]},children:V})},{title:"Tracker",key:"tracker",width:140,render:(V,P)=>i.jsx("a",{onClick:re=>{re.preventDefault(),l?.(P,{tab:"track",sourceTab:"active"})},className:"text-blue-600 hover:underline",children:"Tracker"})},{title:"Call to action/Human in the loop",key:"actions",width:320,render:(V,P)=>{if(o)return i.jsx(i.Fragment,{children:o(P)});const re=async(Ue,pt)=>{const Ot=bs(P.id,Ue);M(Se=>new Set(Se).add(Ot));try{const Se=await R.sendSMSorEmailNotifications?.(P.id,Ue,pt);Se?.responseStatus||Se?.Success||Se?.success?(xe.toast.success(Se?.message||Se.data||(Ue?"Email sent successfully":"SMS sent successfully")),c?.()):xe.toast.error(Se?.message||Se?.data||Se?.errorMessage||"Failed to send notification")}catch(Se){xe.toast.error(Se?.message||"Failed to send notification")}finally{M(Se=>{const gt=new Set(Se);return gt.delete(Ot),gt})}},ae=Js,we=Ks,Ae=ie[ae],Ye=ie[we],Re=gn(ae,P,Ae?.title),Te=gn(we,P,Ye?.title),Mt=bs(P.id,!0),ht=bs(P.id,!1),yt=_t(ae)&&w.has(Mt),ot=_t(we)&&w.has(ht);return i.jsxs(h.Space,{size:"middle",children:[i.jsx(h.Tooltip,{title:Re.tooltipTitle,children:i.jsx(h.Button,{size:"small",disabled:Re.isDisabled,loading:yt,onClick:_t(ae)?()=>re(!0,!1):void 0,icon:!yt&&Ae?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:Re.buttonText})},String(ae)),i.jsx(h.Tooltip,{title:Te.tooltipTitle,children:i.jsx(h.Button,{size:"small",disabled:Te.isDisabled,loading:ot,onClick:_t(we)?()=>re(!1,!0):void 0,icon:!ot&&Ye?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:Te.buttonText})},String(we))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(V,P)=>{const re=P?.timeElapsed,ae=P?.timeRemaining,we=re?dn(re):0,Ae=ae?dn(ae):0,Ye=Math.round(we/(we+Ae)*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:re??"-"})]}),i.jsx(h.Progress,{percent:Ye,showInfo:!1,size:"small",strokeColor:ka(P.priority)}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-[70px]",children:"Remaining"}),i.jsx("span",{className:"font-medium",children:ae??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(V,P)=>i.jsxs("div",{children:[i.jsx("a",{onClick:re=>{re.preventDefault(),l?.(P,{sourceTab:"active"})},className:"inline-block mb-1 text-blue-600",children:P.alertNumber}),i.jsx("div",{className:"text-black/65",children:V})]})},{title:"Preview",key:"preview",width:100,align:"center",render:(V,P)=>i.jsx(fr,{record:P})}],ce=a&&a.length?a:ge;return i.jsx("div",{children:i.jsx(rr,{rowKey:"id",data:t,columns:ce,loading:e,pageSize:te,total:n,currentPage:z,onPageChange:u,toolbar:i.jsxs(h.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[i.jsx(h.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Severity"}),i.jsx(ei,{value:S,onChange:y,options:de})]})}),i.jsx(h.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Anomaly type"}),i.jsx(si,{value:A,onChange:T,options:ve})]})}),i.jsx(h.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:G?"Bus Number":"Space"}),i.jsx(ni,{value:x,onChange:$,options:le})]})}),i.jsx(h.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Action Taken"}),i.jsx(ai,{value:H,onChange:J,options:q})]})}),i.jsx(h.Col,{flex:"auto"}),i.jsx(h.Col,{flex:"none",children:i.jsx(h.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:L,onChange:V=>L(V.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}const Ai=["completed","false positive","face doesn't match name","safe","supervised exit","elopement confirmed"];function Xs(){const{alerts:t}=De(),e=mt.useQueryClient();return mt.useMutation({mutationFn:s=>t.updateAlertStatus(s),onSuccess:()=>{e.invalidateQueries({queryKey:["alerts","list"]}),e.invalidateQueries({queryKey:["alerts","report"]})}})}class ft extends Error{}class Ti extends ft{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class Ni extends ft{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class bi extends ft{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class wt extends ft{}class hr extends ft{constructor(e){super(`Invalid unit ${e}`)}}class Ne extends ft{}class nt extends ft{constructor(){super("Zone is an abstract class")}}const I="numeric",qe="short",Le="long",is={year:I,month:I,day:I},yr={year:I,month:qe,day:I},ki={year:I,month:qe,day:I,weekday:qe},pr={year:I,month:Le,day:I},gr={year:I,month:Le,day:I,weekday:Le},Sr={hour:I,minute:I},xr={hour:I,minute:I,second:I},vr={hour:I,minute:I,second:I,timeZoneName:qe},wr={hour:I,minute:I,second:I,timeZoneName:Le},Ar={hour:I,minute:I,hourCycle:"h23"},Tr={hour:I,minute:I,second:I,hourCycle:"h23"},Nr={hour:I,minute:I,second:I,hourCycle:"h23",timeZoneName:qe},br={hour:I,minute:I,second:I,hourCycle:"h23",timeZoneName:Le},kr={year:I,month:I,day:I,hour:I,minute:I},Ir={year:I,month:I,day:I,hour:I,minute:I,second:I},Er={year:I,month:qe,day:I,hour:I,minute:I},Mr={year:I,month:qe,day:I,hour:I,minute:I,second:I},Ii={year:I,month:qe,day:I,weekday:qe,hour:I,minute:I},Or={year:I,month:Le,day:I,hour:I,minute:I,timeZoneName:qe},jr={year:I,month:Le,day:I,hour:I,minute:I,second:I,timeZoneName:qe},Cr={year:I,month:Le,day:I,weekday:Le,hour:I,minute:I,timeZoneName:Le},Dr={year:I,month:Le,day:I,weekday:Le,hour:I,minute:I,second:I,timeZoneName:Le};class Pt{get type(){throw new nt}get name(){throw new nt}get ianaName(){return this.name}get isUniversal(){throw new nt}offsetName(e,s){throw new nt}formatOffset(e,s){throw new nt}offset(e){throw new nt}equals(e){throw new nt}get isValid(){throw new nt}}let ks=null;class fs extends Pt{static get instance(){return ks===null&&(ks=new fs),ks}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return zr(e,s,n)}formatOffset(e,s){return Ft(this.offset(e),s)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}}const $s=new Map;function Ei(t){let e=$s.get(t);return e===void 0&&(e=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),$s.set(t,e)),e}const Mi={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function Oi(t,e){const s=t.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(s),[,r,a,o,l,c,u,f]=n;return[o,r,a,l,c,u,f]}function ji(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:a,value:o}=s[r],l=Mi[a];a==="era"?n[l]=o:B(l)||(n[l]=parseInt(o,10))}return n}const Is=new Map;class Xe extends Pt{static create(e){let s=Is.get(e);return s===void 0&&Is.set(e,s=new Xe(e)),s}static resetCache(){Is.clear(),$s.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch{return!1}}constructor(e){super(),this.zoneName=e,this.valid=Xe.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return zr(e,s,n,this.name)}formatOffset(e,s){return Ft(this.offset(e),s)}offset(e){if(!this.valid)return NaN;const s=new Date(e);if(isNaN(s))return NaN;const n=Ei(this.name);let[r,a,o,l,c,u,f]=n.formatToParts?ji(n,s):Oi(n,s);l==="BC"&&(r=-Math.abs(r)+1);const S=ys({year:r,month:a,day:o,hour:c===24?0:c,minute:u,second:f,millisecond:0});let y=+s;const A=y%1e3;return y-=A>=0?A:1e3+A,(S-y)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let wn={};function Ci(t,e={}){const s=JSON.stringify([t,e]);let n=wn[s];return n||(n=new Intl.ListFormat(t,e),wn[s]=n),n}const Ps=new Map;function Ws(t,e={}){const s=JSON.stringify([t,e]);let n=Ps.get(s);return n===void 0&&(n=new Intl.DateTimeFormat(t,e),Ps.set(s,n)),n}const Bs=new Map;function Di(t,e={}){const s=JSON.stringify([t,e]);let n=Bs.get(s);return n===void 0&&(n=new Intl.NumberFormat(t,e),Bs.set(s,n)),n}const Vs=new Map;function Ri(t,e={}){const{base:s,...n}=e,r=JSON.stringify([t,n]);let a=Vs.get(r);return a===void 0&&(a=new Intl.RelativeTimeFormat(t,e),Vs.set(r,a)),a}let Rt=null;function Ui(){return Rt||(Rt=new Intl.DateTimeFormat().resolvedOptions().locale,Rt)}const Zs=new Map;function Rr(t){let e=Zs.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),Zs.set(t,e)),e}const zs=new Map;function Li(t){let e=zs.get(t);if(!e){const s=new Intl.Locale(t);e="getWeekInfo"in s?s.getWeekInfo():s.weekInfo,"minimalDays"in e||(e={...Ur,...e}),zs.set(t,e)}return e}function Fi(t){const e=t.indexOf("-x-");e!==-1&&(t=t.substring(0,e));const s=t.indexOf("-u-");if(s===-1)return[t];{let n,r;try{n=Ws(t).resolvedOptions(),r=t}catch{const c=t.substring(0,s);n=Ws(c).resolvedOptions(),r=c}const{numberingSystem:a,calendar:o}=n;return[r,a,o]}}function $i(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function Pi(t){const e=[];for(let s=1;s<=12;s++){const n=W.utc(2009,s,1);e.push(t(n))}return e}function Wi(t){const e=[];for(let s=1;s<=7;s++){const n=W.utc(2016,11,13+s);e.push(t(n))}return e}function Jt(t,e,s,n){const r=t.listingMode();return r==="error"?null:r==="en"?s(e):n(e)}function Bi(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||Rr(t.locale).numberingSystem==="latn"}class Vi{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=Di(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):rn(e,3);return pe(s,this.padTo)}}}class Zi{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&&Xe.create(l).valid?(r=l,this.dt=e):(r="UTC",this.dt=e.offset===0?e:e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type==="system"?this.dt=e:e.zone.type==="iana"?(this.dt=e,r=e.zone.name):(r="UTC",this.dt=e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone);const a={...this.opts};a.timeZone=a.timeZone||r,this.dtf=Ws(s,a)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(s=>{if(s.type==="timeZoneName"){const n=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...s,value:n}}else return s}):e}resolvedOptions(){return this.dtf.resolvedOptions()}}class zi{constructor(e,s,n){this.opts={style:"long",...n},!s&&Vr()&&(this.rtf=Ri(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):fo(s,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,s){return this.rtf?this.rtf.formatToParts(e,s):[]}}const Ur={firstDay:1,minimalDays:4,weekend:[6,7]};class ne{static fromOpts(e){return ne.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,s,n,r,a=!1){const o=e||fe.defaultLocale,l=o||(a?"en-US":Ui()),c=s||fe.defaultNumberingSystem,u=n||fe.defaultOutputCalendar,f=qs(r)||fe.defaultWeekSettings;return new ne(l,c,u,f,o)}static resetCache(){Rt=null,Ps.clear(),Bs.clear(),Vs.clear(),Zs.clear(),zs.clear()}static fromObject({locale:e,numberingSystem:s,outputCalendar:n,weekSettings:r}={}){return ne.create(e,s,n,r)}constructor(e,s,n,r,a){const[o,l,c]=Fi(e);this.locale=o,this.numberingSystem=s||l||null,this.outputCalendar=n||c||null,this.weekSettings=r,this.intl=$i(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=Bi(this)),this.fastNumbersCached}listingMode(){const e=this.isEnglish(),s=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return e&&s?"en":"intl"}clone(e){return!e||Object.getOwnPropertyNames(e).length===0?this:ne.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,qs(e.weekSettings)||this.weekSettings,e.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,s=!1){return Jt(this,e,Gr,()=>{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]=Pi(o)}return this.monthsCache[a][e]})}weekdays(e,s=!1){return Jt(this,e,Jr,()=>{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]=Wi(a=>this.extract(a,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return Jt(this,void 0,()=>Kr,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[W.utc(2016,11,13,9),W.utc(2016,11,13,19)].map(s=>this.extract(s,e,"dayperiod"))}return this.meridiemCache})}eras(e){return Jt(this,e,Qr,()=>{const s={era:e};return this.eraCache[e]||(this.eraCache[e]=[W.utc(-40,1,1),W.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 Vi(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new Zi(e,this.intl,s)}relFormatter(e={}){return new zi(this.intl,this.isEnglish(),e)}listFormatter(e={}){return Ci(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||Rr(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:Zr()?Li(this.locale):Ur}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let Es=null;class Ee extends Pt{static get utcInstance(){return Es===null&&(Es=new Ee(0)),Es}static instance(e){return e===0?Ee.utcInstance:new Ee(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new Ee(ps(s[1],s[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Ft(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Ft(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,s){return Ft(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 Hi extends Pt{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 at(t,e){if(B(t)||t===null)return e;if(t instanceof Pt)return t;if(Ki(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?fs.instance:s==="utc"||s==="gmt"?Ee.utcInstance:Ee.parseSpecifier(s)||Xe.create(t)}else return it(t)?Ee.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new Hi(t)}const en={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},An={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]},qi=en.hanidec.replace(/[\[|\]]/g,"").split("");function Gi(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(en.hanidec)!==-1)e+=qi.indexOf(t[s]);else for(const r in An){const[a,o]=An[r];n>=a&&n<=o&&(e+=n-a)}}return parseInt(e,10)}else return e}const Hs=new Map;function Yi(){Hs.clear()}function Ze({numberingSystem:t},e=""){const s=t||"latn";let n=Hs.get(s);n===void 0&&(n=new Map,Hs.set(s,n));let r=n.get(e);return r===void 0&&(r=new RegExp(`${en[s]}${e}`),n.set(e,r)),r}let Tn=()=>Date.now(),Nn="system",bn=null,kn=null,In=null,En=60,Mn,On=null;class fe{static get now(){return Tn}static set now(e){Tn=e}static set defaultZone(e){Nn=e}static get defaultZone(){return at(Nn,fs.instance)}static get defaultLocale(){return bn}static set defaultLocale(e){bn=e}static get defaultNumberingSystem(){return kn}static set defaultNumberingSystem(e){kn=e}static get defaultOutputCalendar(){return In}static set defaultOutputCalendar(e){In=e}static get defaultWeekSettings(){return On}static set defaultWeekSettings(e){On=qs(e)}static get twoDigitCutoffYear(){return En}static set twoDigitCutoffYear(e){En=e%100}static get throwOnInvalid(){return Mn}static set throwOnInvalid(e){Mn=e}static resetCaches(){ne.resetCache(),Xe.resetCache(),W.resetCache(),Yi()}}class He{constructor(e,s){this.reason=e,this.explanation=s}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const Lr=[0,31,59,90,120,151,181,212,243,273,304,334],Fr=[0,31,60,91,121,152,182,213,244,274,305,335];function We(t,e){return new He("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function tn(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 $r(t,e,s){return s+(Wt(t)?Fr:Lr)[e-1]}function Pr(t,e){const s=Wt(t)?Fr:Lr,n=s.findIndex(a=>a<e),r=e-s[n];return{month:n+1,day:r}}function sn(t,e){return(t-e+7)%7+1}function os(t,e=4,s=1){const{year:n,month:r,day:a}=t,o=$r(n,r,a),l=sn(tn(n,r,a),s);let c=Math.floor((o-l+14-e)/7),u;return c<1?(u=n-1,c=$t(u,e,s)):c>$t(n,e,s)?(u=n+1,c=1):u=n,{weekYear:u,weekNumber:c,weekday:l,...gs(t)}}function jn(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:a}=t,o=sn(tn(n,1,e),s),l=At(n);let c=r*7+a-o-7+e,u;c<1?(u=n-1,c+=At(u)):c>l?(u=n+1,c-=At(n)):u=n;const{month:f,day:m}=Pr(u,c);return{year:u,month:f,day:m,...gs(t)}}function Ms(t){const{year:e,month:s,day:n}=t,r=$r(e,s,n);return{year:e,ordinal:r,...gs(t)}}function Cn(t){const{year:e,ordinal:s}=t,{month:n,day:r}=Pr(e,s);return{year:e,month:n,day:r,...gs(t)}}function Dn(t,e){if(!B(t.localWeekday)||!B(t.localWeekNumber)||!B(t.localWeekYear)){if(!B(t.weekday)||!B(t.weekNumber)||!B(t.weekYear))throw new wt("Cannot mix locale-based week fields with ISO-based week fields");return B(t.localWeekday)||(t.weekday=t.localWeekday),B(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),B(t.localWeekYear)||(t.weekYear=t.localWeekYear),delete t.localWeekday,delete t.localWeekNumber,delete t.localWeekYear,{minDaysInFirstWeek:e.getMinDaysInFirstWeek(),startOfWeek:e.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function _i(t,e=4,s=1){const n=hs(t.weekYear),r=Be(t.weekNumber,1,$t(t.weekYear,e,s)),a=Be(t.weekday,1,7);return n?r?a?!1:We("weekday",t.weekday):We("week",t.weekNumber):We("weekYear",t.weekYear)}function Ji(t){const e=hs(t.year),s=Be(t.ordinal,1,At(t.year));return e?s?!1:We("ordinal",t.ordinal):We("year",t.year)}function Wr(t){const e=hs(t.year),s=Be(t.month,1,12),n=Be(t.day,1,ls(t.year,t.month));return e?s?n?!1:We("day",t.day):We("month",t.month):We("year",t.year)}function Br(t){const{hour:e,minute:s,second:n,millisecond:r}=t,a=Be(e,0,23)||e===24&&s===0&&n===0&&r===0,o=Be(s,0,59),l=Be(n,0,59),c=Be(r,0,999);return a?o?l?c?!1:We("millisecond",r):We("second",n):We("minute",s):We("hour",e)}function B(t){return typeof t>"u"}function it(t){return typeof t=="number"}function hs(t){return typeof t=="number"&&t%1===0}function Ki(t){return typeof t=="string"}function Qi(t){return Object.prototype.toString.call(t)==="[object Date]"}function Vr(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function Zr(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function Xi(t){return Array.isArray(t)?t:[t]}function Rn(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 eo(t,e){return e.reduce((s,n)=>(s[n]=t[n],s),{})}function Nt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function qs(t){if(t==null)return null;if(typeof t!="object")throw new Ne("Week settings must be an object");if(!Be(t.firstDay,1,7)||!Be(t.minimalDays,1,7)||!Array.isArray(t.weekend)||t.weekend.some(e=>!Be(e,1,7)))throw new Ne("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function Be(t,e,s){return hs(t)&&t>=e&&t<=s}function to(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 rt(t){if(!(B(t)||t===null||t===""))return parseInt(t,10)}function lt(t){if(!(B(t)||t===null||t===""))return parseFloat(t)}function nn(t){if(!(B(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function rn(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 Wt(t){return t%4===0&&(t%100!==0||t%400===0)}function At(t){return Wt(t)?366:365}function ls(t,e){const s=to(e-1,12)+1,n=t+(e-s)/12;return s===2?Wt(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][s-1]}function ys(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 Un(t,e,s){return-sn(tn(t,1,e),s)+e-1}function $t(t,e=4,s=1){const n=Un(t,e,s),r=Un(t+1,e,s);return(At(t)-n+r)/7}function Gs(t){return t>99?t:t>fe.twoDigitCutoffYear?1900+t:2e3+t}function zr(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 ps(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 Hr(t){const e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new Ne(`Invalid unit value ${t}`);return e}function cs(t,e){const s={};for(const n in t)if(Nt(t,n)){const r=t[n];if(r==null)continue;s[e(n)]=Hr(r)}return s}function Ft(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 gs(t){return eo(t,["hour","minute","second","millisecond"])}const so=["January","February","March","April","May","June","July","August","September","October","November","December"],qr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],no=["J","F","M","A","M","J","J","A","S","O","N","D"];function Gr(t){switch(t){case"narrow":return[...no];case"short":return[...qr];case"long":return[...so];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 Yr=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],_r=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],ro=["M","T","W","T","F","S","S"];function Jr(t){switch(t){case"narrow":return[...ro];case"short":return[..._r];case"long":return[...Yr];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const Kr=["AM","PM"],ao=["Before Christ","Anno Domini"],io=["BC","AD"],oo=["B","A"];function Qr(t){switch(t){case"narrow":return[...oo];case"short":return[...io];case"long":return[...ao];default:return null}}function lo(t){return Kr[t.hour<12?0:1]}function co(t,e){return Jr(e)[t.weekday-1]}function uo(t,e){return Gr(e)[t.month-1]}function mo(t,e){return Qr(e)[t.year<0?0:1]}function fo(t,e,s="always",n=!1){const r={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},a=["hours","minutes","seconds"].indexOf(t)===-1;if(s==="auto"&&a){const m=t==="days";switch(e){case 1:return m?"tomorrow":`next ${r[t][0]}`;case-1:return m?"yesterday":`last ${r[t][0]}`;case 0:return m?"today":`this ${r[t][0]}`}}const o=Object.is(e,-0)||e<0,l=Math.abs(e),c=l===1,u=r[t],f=n?c?u[1]:u[2]||u[1]:c?r[t][0]:t;return o?`${l} ${f} ago`:`in ${l} ${f}`}function Ln(t,e){let s="";for(const n of t)n.literal?s+=n.val:s+=e(n.val);return s}const ho={D:is,DD:yr,DDD:pr,DDDD:gr,t:Sr,tt:xr,ttt:vr,tttt:wr,T:Ar,TT:Tr,TTT:Nr,TTTT:br,f:kr,ff:Er,fff:Or,ffff:Cr,F:Ir,FF:Mr,FFF:jr,FFFF:Dr};class be{static create(e,s={}){return new be(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 ho[e]}constructor(e,s){this.opts=s,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,s){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...s}).format()}dtFormatter(e,s={}){return this.loc.dtFormatter(e,{...this.opts,...s})}formatDateTime(e,s){return this.dtFormatter(e,s).format()}formatDateTimeParts(e,s){return this.dtFormatter(e,s).formatToParts()}formatInterval(e,s){return this.dtFormatter(e.start,s).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,s){return this.dtFormatter(e,s).resolvedOptions()}num(e,s=0,n=void 0){if(this.opts.forceSimple)return pe(e,s);const r={...this.opts};return s>0&&(r.padTo=s),n&&(r.signDisplay=n),this.loc.numberFormatter(r).format(e)}formatDateTimeFromString(e,s){const n=this.loc.listingMode()==="en",r=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",a=(y,A)=>this.loc.extract(e,y,A),o=y=>e.isOffsetFixed&&e.offset===0&&y.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,y.format):"",l=()=>n?lo(e):a({hour:"numeric",hourCycle:"h12"},"dayperiod"),c=(y,A)=>n?uo(e,y):a(A?{month:y}:{month:y,day:"numeric"},"month"),u=(y,A)=>n?co(e,y):a(A?{weekday:y}:{weekday:y,month:"long",day:"numeric"},"weekday"),f=y=>{const A=be.macroTokenToFormatOpts(y);return A?this.formatWithSystemDefault(e,A):y},m=y=>n?mo(e,y):a({era:y},"era"),S=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 f(y)}};return Ln(be.parseFormat(s),S)}formatDurationFromString(e,s){const n=this.opts.signMode==="negativeLargestOnly"?-1:1,r=f=>{switch(f[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},a=(f,m)=>S=>{const y=r(S);if(y){const A=m.isNegativeDuration&&y!==m.largestUnit?n:1;let T;return this.opts.signMode==="negativeLargestOnly"&&y!==m.largestUnit?T="never":this.opts.signMode==="all"?T="always":T="auto",this.num(f.get(y)*A,S.length,T)}else return S},o=be.parseFormat(s),l=o.reduce((f,{literal:m,val:S})=>m?f:f.concat(S),[]),c=e.shiftTo(...l.map(r).filter(f=>f)),u={isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]};return Ln(o,a(c,u))}}const Xr=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function bt(...t){const e=t.reduce((s,n)=>s+n.source,"");return RegExp(`^${e}$`)}function kt(...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 It(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 ea(...t){return(e,s)=>{const n={};let r;for(r=0;r<t.length;r++)n[t[r]]=rt(e[s+r]);return[n,null,s+r]}}const ta=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,yo=`(?:${ta.source}?(?:\\[(${Xr.source})\\])?)?`,an=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,sa=RegExp(`${an.source}${yo}`),on=RegExp(`(?:[Tt]${sa.source})?`),po=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,go=/(\d{4})-?W(\d\d)(?:-?(\d))?/,So=/(\d{4})-?(\d{3})/,xo=ea("weekYear","weekNumber","weekDay"),vo=ea("year","ordinal"),wo=/(\d{4})-(\d\d)-(\d\d)/,na=RegExp(`${an.source} ?(?:${ta.source}|(${Xr.source}))?`),Ao=RegExp(`(?: ${na.source})?`);function Tt(t,e,s){const n=t[e];return B(n)?s:rt(n)}function To(t,e){return[{year:Tt(t,e),month:Tt(t,e+1,1),day:Tt(t,e+2,1)},null,e+3]}function Et(t,e){return[{hours:Tt(t,e,0),minutes:Tt(t,e+1,0),seconds:Tt(t,e+2,0),milliseconds:nn(t[e+3])},null,e+4]}function Bt(t,e){const s=!t[e]&&!t[e+1],n=ps(t[e+1],t[e+2]),r=s?null:Ee.instance(n);return[{},r,e+3]}function Vt(t,e){const s=t[e]?Xe.create(t[e]):null;return[{},s,e+1]}const No=RegExp(`^T?${an.source}$`),bo=/^-?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 ko(t){const[e,s,n,r,a,o,l,c,u]=t,f=e[0]==="-",m=c&&c[0]==="-",S=(y,A=!1)=>y!==void 0&&(A||y&&f)?-y:y;return[{years:S(lt(s)),months:S(lt(n)),weeks:S(lt(r)),days:S(lt(a)),hours:S(lt(o)),minutes:S(lt(l)),seconds:S(lt(c),c==="-0"),milliseconds:S(nn(u),m)}]}const Io={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function ln(t,e,s,n,r,a,o){const l={year:e.length===2?Gs(rt(e)):rt(e),month:qr.indexOf(s)+1,day:rt(n),hour:rt(r),minute:rt(a)};return o&&(l.second=rt(o)),t&&(l.weekday=t.length>3?Yr.indexOf(t)+1:_r.indexOf(t)+1),l}const Eo=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function Mo(t){const[,e,s,n,r,a,o,l,c,u,f,m]=t,S=ln(e,r,n,s,a,o,l);let y;return c?y=Io[c]:u?y=0:y=ps(f,m),[S,new Ee(y)]}function Oo(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const jo=/^(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$/,Co=/^(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$/,Do=/^(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 Fn(t){const[,e,s,n,r,a,o,l]=t;return[ln(e,r,n,s,a,o,l),Ee.utcInstance]}function Ro(t){const[,e,s,n,r,a,o,l]=t;return[ln(e,l,s,n,r,a,o),Ee.utcInstance]}const Uo=bt(po,on),Lo=bt(go,on),Fo=bt(So,on),$o=bt(sa),ra=kt(To,Et,Bt,Vt),Po=kt(xo,Et,Bt,Vt),Wo=kt(vo,Et,Bt,Vt),Bo=kt(Et,Bt,Vt);function Vo(t){return It(t,[Uo,ra],[Lo,Po],[Fo,Wo],[$o,Bo])}function Zo(t){return It(Oo(t),[Eo,Mo])}function zo(t){return It(t,[jo,Fn],[Co,Fn],[Do,Ro])}function Ho(t){return It(t,[bo,ko])}const qo=kt(Et);function Go(t){return It(t,[No,qo])}const Yo=bt(wo,Ao),_o=bt(na),Jo=kt(Et,Bt,Vt);function Ko(t){return It(t,[Yo,ra],[_o,Jo])}const $n="Invalid Duration",aa={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}},Qo={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},...aa},Pe=146097/400,St=146097/4800,Xo={years:{quarters:4,months:12,weeks:Pe/7,days:Pe,hours:Pe*24,minutes:Pe*24*60,seconds:Pe*24*60*60,milliseconds:Pe*24*60*60*1e3},quarters:{months:3,weeks:Pe/28,days:Pe/4,hours:Pe*24/4,minutes:Pe*24*60/4,seconds:Pe*24*60*60/4,milliseconds:Pe*24*60*60*1e3/4},months:{weeks:St/7,days:St,hours:St*24,minutes:St*24*60,seconds:St*24*60*60,milliseconds:St*24*60*60*1e3},...aa},ut=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],el=ut.slice(0).reverse();function Ke(t,e,s=!1){const n={values:s?e.values:{...t.values,...e.values||{}},loc:t.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||t.conversionAccuracy,matrix:e.matrix||t.matrix};return new K(n)}function ia(t,e){let s=e.milliseconds??0;for(const n of el.slice(1))e[n]&&(s+=e[n]*t[n].milliseconds);return s}function Pn(t,e){const s=ia(t,e)<0?-1:1;ut.reduceRight((n,r)=>{if(B(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),ut.reduce((n,r)=>{if(B(e[r]))return n;if(n){const a=e[n]%1;e[n]-=a,e[r]+=a*t[n][r]}return r},null)}function Wn(t){const e={};for(const[s,n]of Object.entries(t))n!==0&&(e[s]=n);return e}class K{constructor(e){const s=e.conversionAccuracy==="longterm"||!1;let n=s?Xo:Qo;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||ne.create(),this.conversionAccuracy=s?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=n,this.isLuxonDuration=!0}static fromMillis(e,s){return K.fromObject({milliseconds:e},s)}static fromObject(e,s={}){if(e==null||typeof e!="object")throw new Ne(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new K({values:cs(e,K.normalizeUnit),loc:ne.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(it(e))return K.fromMillis(e);if(K.isDuration(e))return e;if(typeof e=="object")return K.fromObject(e);throw new Ne(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,s){const[n]=Ho(e);return n?K.fromObject(n,s):K.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,s){const[n]=Go(e);return n?K.fromObject(n,s):K.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,s=null){if(!e)throw new Ne("need to specify a reason the Duration is invalid");const n=e instanceof He?e:new He(e,s);if(fe.throwOnInvalid)throw new bi(n);return new K({invalid:n})}static normalizeUnit(e){const s={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[e&&e.toLowerCase()];if(!s)throw new hr(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?be.create(this.loc,n).formatDurationFromString(this,e):$n}toHuman(e={}){if(!this.isValid)return $n;const s=e.showZeros!==!1,n=ut.map(r=>{const a=this.values[r];return B(a)||a===0&&!s?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:r.slice(0,-1)}).format(a)}).filter(r=>r);return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(n)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e="P";return this.years!==0&&(e+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+"M"),this.weeks!==0&&(e+=this.weeks+"W"),this.days!==0&&(e+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+="T"),this.hours!==0&&(e+=this.hours+"H"),this.minutes!==0&&(e+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(e+=rn(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},W.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?ia(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e),n={};for(const r of ut)(Nt(s.values,r)||Nt(this.values,r))&&(n[r]=s.get(r)+this.get(r));return Ke(this,{values:n},!0)}minus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e);return this.plus(s.negate())}mapUnits(e){if(!this.isValid)return this;const s={};for(const n of Object.keys(this.values))s[n]=Hr(e(this.values[n],n));return Ke(this,{values:s},!0)}get(e){return this[K.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const s={...this.values,...cs(e,K.normalizeUnit)};return Ke(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 Ke(this,o)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return Pn(this.matrix,e),Ke(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=Wn(this.normalize().shiftToAll().toObject());return Ke(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(o=>K.normalizeUnit(o));const s={},n={},r=this.toObject();let a;for(const o of ut)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;it(r[o])&&(l+=r[o]);const c=Math.trunc(l);s[o]=c,n[o]=(l*1e3-c*1e3)/1e3}else it(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 Pn(this.matrix,s),Ke(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 Ke(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=Wn(this.values);return Ke(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 ut)if(!s(this.values[n],e.values[n]))return!1;return!0}}const xt="Invalid Interval";function tl(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 Ne("need to specify a reason the Interval is invalid");const n=e instanceof He?e:new He(e,s);if(fe.throwOnInvalid)throw new Ni(n);return new me({invalid:n})}static fromDateTimes(e,s){const n=Ct(e),r=Ct(s),a=tl(n,r);return a??new me({start:n,end:r})}static after(e,s){const n=K.fromDurationLike(s),r=Ct(e);return me.fromDateTimes(r,r.plus(n))}static before(e,s){const n=K.fromDurationLike(s),r=Ct(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=W.fromISO(n,s),o=a.isValid}catch{o=!1}let l,c;try{l=W.fromISO(r,s),c=l.isValid}catch{c=!1}if(o&&c)return me.fromDateTimes(a,l);if(o){const u=K.fromISO(r,s);if(u.isValid)return me.after(a,u)}else if(c){const u=K.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(Ct).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=K.fromDurationLike(e);if(!this.isValid||!s.isValid||s.as("milliseconds")===0)return[];let{s:n}=this,r=1,a;const o=[];for(;n<this.e;){const l=this.start.plus(s.mapUnits(c=>c*r));a=+l>+this.e?this.e:l,o.push(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()})`:xt}[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=is,s={}){return this.isValid?be.create(this.s.loc.clone(s),e).formatInterval(this):xt}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:xt}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:xt}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:xt}toFormat(e,{separator:s=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${s}${this.e.toFormat(e)}`:xt}toDuration(e,s){return this.isValid?this.e.diff(this.s,e,s):K.invalid(this.invalidReason)}mapEndpoints(e){return me.fromDateTimes(e(this.s),e(this.e))}}class Kt{static hasDST(e=fe.defaultZone){const s=W.now().setZone(e).set({month:12});return!e.isUniversal&&s.offset!==s.set({month:6}).offset}static isValidIANAZone(e){return Xe.isValidZone(e)}static normalizeZone(e){return at(e,fe.defaultZone)}static getStartOfWeek({locale:e=null,locObj:s=null}={}){return(s||ne.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:s=null}={}){return(s||ne.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:s=null}={}){return(s||ne.create(e)).getWeekendDays().slice()}static months(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||ne.create(s,n,a)).months(e)}static monthsFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||ne.create(s,n,a)).months(e,!0)}static weekdays(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||ne.create(s,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||ne.create(s,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return ne.create(e).meridiems()}static eras(e="short",{locale:s=null}={}){return ne.create(s,null,"gregory").eras(e)}static features(){return{relative:Vr(),localeWeek:Zr()}}}function Bn(t,e){const s=r=>r.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),n=s(e)-s(t);return Math.floor(K.fromMillis(n).as("days"))}function sl(t,e,s){const n=[["years",(c,u)=>u.year-c.year],["quarters",(c,u)=>u.quarter-c.quarter+(u.year-c.year)*4],["months",(c,u)=>u.month-c.month+(u.year-c.year)*12],["weeks",(c,u)=>{const f=Bn(c,u);return(f-f%7)/7}],["days",Bn]],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 nl(t,e,s,n){let[r,a,o,l]=sl(t,e,s);const c=e-r,u=s.filter(m=>["hours","minutes","seconds","milliseconds"].indexOf(m)>=0);u.length===0&&(o<e&&(o=r.plus({[l]:1})),o!==r&&(a[l]=(a[l]||0)+c/(o-r)));const f=K.fromObject(a,n);return u.length>0?K.fromMillis(c,n).shiftTo(...u).plus(f):f}const rl="missing Intl.DateTimeFormat.formatToParts support";function ee(t,e=s=>s){return{regex:t,deser:([s])=>e(Gi(s))}}const al=" ",oa=`[ ${al}]`,la=new RegExp(oa,"g");function il(t){return t.replace(/\./g,"\\.?").replace(la,oa)}function Vn(t){return t.replace(/\./g,"").replace(la," ").toLowerCase()}function ze(t,e){return t===null?null:{regex:RegExp(t.map(il).join("|")),deser:([s])=>t.findIndex(n=>Vn(s)===Vn(n))+e}}function Zn(t,e){return{regex:t,deser:([,s,n])=>ps(s,n),groups:e}}function Qt(t){return{regex:t,deser:([e])=>e}}function ol(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function ll(t,e){const s=Ze(e),n=Ze(e,"{2}"),r=Ze(e,"{3}"),a=Ze(e,"{4}"),o=Ze(e,"{6}"),l=Ze(e,"{1,2}"),c=Ze(e,"{1,3}"),u=Ze(e,"{1,6}"),f=Ze(e,"{1,9}"),m=Ze(e,"{2,4}"),S=Ze(e,"{4,6}"),y=x=>({regex:RegExp(ol(x.val)),deser:([$])=>$,literal:!0}),T=(x=>{if(t.literal)return y(x);switch(x.val){case"G":return ze(e.eras("short"),0);case"GG":return ze(e.eras("long"),0);case"y":return ee(u);case"yy":return ee(m,Gs);case"yyyy":return ee(a);case"yyyyy":return ee(S);case"yyyyyy":return ee(o);case"M":return ee(l);case"MM":return ee(n);case"MMM":return ze(e.months("short",!0),1);case"MMMM":return ze(e.months("long",!0),1);case"L":return ee(l);case"LL":return ee(n);case"LLL":return ze(e.months("short",!1),1);case"LLLL":return ze(e.months("long",!1),1);case"d":return ee(l);case"dd":return ee(n);case"o":return ee(c);case"ooo":return ee(r);case"HH":return ee(n);case"H":return ee(l);case"hh":return ee(n);case"h":return ee(l);case"mm":return ee(n);case"m":return ee(l);case"q":return ee(l);case"qq":return ee(n);case"s":return ee(l);case"ss":return ee(n);case"S":return ee(c);case"SSS":return ee(r);case"u":return Qt(f);case"uu":return Qt(l);case"uuu":return ee(s);case"a":return ze(e.meridiems(),0);case"kkkk":return ee(a);case"kk":return ee(m,Gs);case"W":return ee(l);case"WW":return ee(n);case"E":case"c":return ee(s);case"EEE":return ze(e.weekdays("short",!1),1);case"EEEE":return ze(e.weekdays("long",!1),1);case"ccc":return ze(e.weekdays("short",!0),1);case"cccc":return ze(e.weekdays("long",!0),1);case"Z":case"ZZ":return Zn(new RegExp(`([+-]${l.source})(?::(${n.source}))?`),2);case"ZZZ":return Zn(new RegExp(`([+-]${l.source})(${n.source})?`),2);case"z":return Qt(/[a-z_+-/]{1,256}?/i);case" ":return Qt(/[^\S\n\r]/);default:return y(x)}})(t)||{invalidReason:rl};return T.token=t,T}const cl={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 ul(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=cl[o];if(typeof l=="object"&&(l=l[a]),l)return{literal:!1,val:l}}function dl(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function ml(t,e,s){const n=t.match(e);if(n){const r={};let a=1;for(const o in s)if(Nt(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 fl(t){const e=a=>{switch(a){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let s=null,n;return B(t.z)||(s=Xe.create(t.z)),B(t.Z)||(s||(s=new Ee(t.Z)),n=t.Z),B(t.q)||(t.M=(t.q-1)*3+1),B(t.h)||(t.h<12&&t.a===1?t.h+=12:t.h===12&&t.a===0&&(t.h=0)),t.G===0&&t.y&&(t.y=-t.y),B(t.u)||(t.S=nn(t.u)),[Object.keys(t).reduce((a,o)=>{const l=e(o);return l&&(a[l]=t[o]),a},{}),s,n]}let Os=null;function hl(){return Os||(Os=W.fromMillis(1555555555555)),Os}function yl(t,e){if(t.literal)return t;const s=be.macroTokenToFormatOpts(t.val),n=ma(s,e);return n==null||n.includes(void 0)?t:n}function ca(t,e){return Array.prototype.concat(...t.map(s=>yl(s,e)))}class ua{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=ca(be.parseFormat(s),e),this.units=this.tokens.map(n=>ll(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=dl(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=ml(e,this.regex,this.handlers),[r,a,o]=n?fl(n):[null,null,void 0];if(Nt(n,"a")&&Nt(n,"H"))throw new wt("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 da(t,e,s){return new ua(t,s).explainFromTokens(e)}function pl(t,e,s){const{result:n,zone:r,specificOffset:a,invalidReason:o}=da(t,e,s);return[n,r,a,o]}function ma(t,e){if(!t)return null;const n=be.create(e,t).dtFormatter(hl()),r=n.formatToParts(),a=n.resolvedOptions();return r.map(o=>ul(o,t,a))}const js="Invalid DateTime",zn=864e13;function Ut(t){return new He("unsupported zone",`the zone "${t.name}" is not supported`)}function Cs(t){return t.weekData===null&&(t.weekData=os(t.c)),t.weekData}function Ds(t){return t.localWeekData===null&&(t.localWeekData=os(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function ct(t,e){const s={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new W({...s,...e,old:s})}function fa(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 Xt(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 ns(t,e,s){return fa(ys(t),e,s)}function Hn(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,ls(n,r))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},o=K.fromObject({years:e.years-Math.trunc(e.years),quarters:e.quarters-Math.trunc(e.quarters),months:e.months-Math.trunc(e.months),weeks:e.weeks-Math.trunc(e.weeks),days:e.days-Math.trunc(e.days),hours:e.hours,minutes:e.minutes,seconds:e.seconds,milliseconds:e.milliseconds}).as("milliseconds"),l=ys(a);let[c,u]=fa(l,s,t.zone);return o!==0&&(c+=o,u=t.zone.offset(c)),{ts:c,o:u}}function vt(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=W.fromObject(t,{...s,zone:c,specificOffset:a});return o?u:u.setZone(l)}else return W.invalid(new He("unparsable",`the input "${r}" can't be parsed as ${n}`))}function es(t,e,s=!0){return t.isValid?be.create(ne.create("en-US"),{allowZ:s,forceSimple:!0}).formatDateTimeFromString(t,e):null}function Rs(t,e,s){const n=t.c.year>9999||t.c.year<0;let r="";if(n&&t.c.year>=0&&(r+="+"),r+=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 qn(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 ha={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},gl={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},Sl={ordinal:1,hour:0,minute:0,second:0,millisecond:0},rs=["year","month","day","hour","minute","second","millisecond"],xl=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],vl=["year","ordinal","hour","minute","second","millisecond"];function as(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 hr(t);return e}function Gn(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return as(t)}}function wl(t){if(Lt===void 0&&(Lt=fe.now()),t.type!=="iana")return t.offset(Lt);const e=t.name;let s=Ys.get(e);return s===void 0&&(s=t.offset(Lt),Ys.set(e,s)),s}function Yn(t,e){const s=at(e.zone,fe.defaultZone);if(!s.isValid)return W.invalid(Ut(s));const n=ne.fromObject(e);let r,a;if(B(t.year))r=fe.now();else{for(const c of rs)B(t[c])&&(t[c]=ha[c]);const o=Wr(t)||Br(t);if(o)return W.invalid(o);const l=wl(s);[r,a]=ns(t,l,s)}return new W({ts:r,zone:s,loc:n,o:a})}function _n(t,e,s){const n=B(s.round)?!0:s.round,r=B(s.rounding)?"trunc":s.rounding,a=(l,c)=>(l=rn(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 Jn(t){let e={},s;return t.length>0&&typeof t[t.length-1]=="object"?(e=t[t.length-1],s=Array.from(t).slice(0,t.length-1)):s=Array.from(t),[e,s]}let Lt;const Ys=new Map;class W{constructor(e){const s=e.zone||fe.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new He("invalid input"):null)||(s.isValid?null:Ut(s));this.ts=B(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=it(e.o)&&!e.old?e.o:s.offset(this.ts);r=Xt(this.ts,l),n=Number.isNaN(r.year)?new He("invalid input"):null,r=n?null:r,a=n?null:l}this._zone=s,this.loc=e.loc||ne.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=a,this.isLuxonDateTime=!0}static now(){return new W({})}static local(){const[e,s]=Jn(arguments),[n,r,a,o,l,c,u]=s;return Yn({year:n,month:r,day:a,hour:o,minute:l,second:c,millisecond:u},e)}static utc(){const[e,s]=Jn(arguments),[n,r,a,o,l,c,u]=s;return e.zone=Ee.utcInstance,Yn({year:n,month:r,day:a,hour:o,minute:l,second:c,millisecond:u},e)}static fromJSDate(e,s={}){const n=Qi(e)?e.valueOf():NaN;if(Number.isNaN(n))return W.invalid("invalid input");const r=at(s.zone,fe.defaultZone);return r.isValid?new W({ts:n,zone:r,loc:ne.fromObject(s)}):W.invalid(Ut(r))}static fromMillis(e,s={}){if(it(e))return e<-zn||e>zn?W.invalid("Timestamp out of range"):new W({ts:e,zone:at(s.zone,fe.defaultZone),loc:ne.fromObject(s)});throw new Ne(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,s={}){if(it(e))return new W({ts:e*1e3,zone:at(s.zone,fe.defaultZone),loc:ne.fromObject(s)});throw new Ne("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=at(s.zone,fe.defaultZone);if(!n.isValid)return W.invalid(Ut(n));const r=ne.fromObject(s),a=cs(e,Gn),{minDaysInFirstWeek:o,startOfWeek:l}=Dn(a,r),c=fe.now(),u=B(s.specificOffset)?n.offset(c):s.specificOffset,f=!B(a.ordinal),m=!B(a.year),S=!B(a.month)||!B(a.day),y=m||S,A=a.weekYear||a.weekNumber;if((y||f)&&A)throw new wt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(S&&f)throw new wt("Can't mix ordinal dates with month/day");const T=A||a.weekday&&!y;let x,$,H=Xt(c,u);T?(x=xl,$=gl,H=os(H,o,l)):f?(x=vl,$=Sl,H=Ms(H)):(x=rs,$=ha);let J=!1;for(const v of x){const O=a[v];B(O)?J?a[v]=$[v]:a[v]=H[v]:J=!0}const E=T?_i(a,o,l):f?Ji(a):Wr(a),L=E||Br(a);if(L)return W.invalid(L);const z=T?jn(a,o,l):f?Cn(a):a,[C,q]=ns(z,u,n),p=new W({ts:C,zone:n,o:q,loc:r});return a.weekday&&y&&e.weekday!==p.weekday?W.invalid("mismatched weekday",`you can't specify both a weekday of ${a.weekday} and a date of ${p.toISO()}`):p.isValid?p:W.invalid(p.invalid)}static fromISO(e,s={}){const[n,r]=Vo(e);return vt(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=Zo(e);return vt(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=zo(e);return vt(n,r,s,"HTTP",s)}static fromFormat(e,s,n={}){if(B(e)||B(s))throw new Ne("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:a=null}=n,o=ne.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0}),[l,c,u,f]=pl(o,e,s);return f?W.invalid(f):vt(l,c,n,`format ${s}`,e,u)}static fromString(e,s,n={}){return W.fromFormat(e,s,n)}static fromSQL(e,s={}){const[n,r]=Ko(e);return vt(n,r,s,"SQL",e)}static invalid(e,s=null){if(!e)throw new Ne("need to specify a reason the DateTime is invalid");const n=e instanceof He?e:new He(e,s);if(fe.throwOnInvalid)throw new Ti(n);return new W({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,s={}){const n=ma(e,ne.fromObject(s));return n?n.map(r=>r?r.val:null).join(""):null}static expandFormat(e,s={}){return ca(be.parseFormat(e),ne.fromObject(s)).map(r=>r.val).join("")}static resetCache(){Lt=void 0,Ys.clear()}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?Cs(this).weekYear:NaN}get weekNumber(){return this.isValid?Cs(this).weekNumber:NaN}get weekday(){return this.isValid?Cs(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Ds(this).weekday:NaN}get localWeekNumber(){return this.isValid?Ds(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Ds(this).weekYear:NaN}get ordinal(){return this.isValid?Ms(this.c).ordinal:NaN}get monthShort(){return this.isValid?Kt.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Kt.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Kt.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Kt.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=ys(this.c),r=this.zone.offset(n-e),a=this.zone.offset(n+e),o=this.zone.offset(n-r*s),l=this.zone.offset(n-a*s);if(o===l)return[this];const c=n-o*s,u=n-l*s,f=Xt(c,o),m=Xt(u,l);return f.hour===m.hour&&f.minute===m.minute&&f.second===m.second&&f.millisecond===m.millisecond?[ct(this,{ts:c}),ct(this,{ts:u})]:[this]}get isInLeapYear(){return Wt(this.year)}get daysInMonth(){return ls(this.year,this.month)}get daysInYear(){return this.isValid?At(this.year):NaN}get weeksInWeekYear(){return this.isValid?$t(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?$t(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:s,numberingSystem:n,calendar:r}=be.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:s,numberingSystem:n,outputCalendar:r}}toUTC(e=0,s={}){return this.setZone(Ee.instance(e),s)}toLocal(){return this.setZone(fe.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=at(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]=ns(o,a,e)}return ct(this,{ts:r,zone:e})}else return W.invalid(Ut(e))}reconfigure({locale:e,numberingSystem:s,outputCalendar:n}={}){const r=this.loc.clone({locale:e,numberingSystem:s,outputCalendar:n});return ct(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const s=cs(e,Gn),{minDaysInFirstWeek:n,startOfWeek:r}=Dn(s,this.loc),a=!B(s.weekYear)||!B(s.weekNumber)||!B(s.weekday),o=!B(s.ordinal),l=!B(s.year),c=!B(s.month)||!B(s.day),u=l||c,f=s.weekYear||s.weekNumber;if((u||o)&&f)throw new wt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(c&&o)throw new wt("Can't mix ordinal dates with month/day");let m;a?m=jn({...os(this.c,n,r),...s},n,r):B(s.ordinal)?(m={...this.toObject(),...s},B(s.day)&&(m.day=Math.min(ls(m.year,m.month),m.day))):m=Cn({...Ms(this.c),...s});const[S,y]=ns(m,this.o,this.zone);return ct(this,{ts:S,o:y})}plus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e);return ct(this,Hn(this,s))}minus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e).negate();return ct(this,Hn(this,s))}startOf(e,{useLocaleWeeks:s=!1}={}){if(!this.isValid)return this;const n={},r=K.normalizeUnit(e);switch(r){case"years":n.month=1;case"quarters":case"months":n.day=1;case"weeks":case"days":n.hour=0;case"hours":n.minute=0;case"minutes":n.second=0;case"seconds":n.millisecond=0;break}if(r==="weeks")if(s){const a=this.loc.getStartOfWeek(),{weekday:o}=this;o<a&&(n.weekNumber=this.weekNumber-1),n.weekday=a}else n.weekday=1;if(r==="quarters"){const a=Math.ceil(this.month/3);n.month=(a-1)*3+1}return this.set(n)}endOf(e,s){return this.isValid?this.plus({[e]:1}).startOf(e,s).minus(1):this}toFormat(e,s={}){return this.isValid?be.create(this.loc.redefaultToEN(s)).formatDateTimeFromString(this,e):js}toLocaleString(e=is,s={}){return this.isValid?be.create(this.loc.clone(s),e).formatDateTime(this):js}toLocaleParts(e={}){return this.isValid?be.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=as(o);const l=e==="extended";let c=Rs(this,l,o);return rs.indexOf(o)>=3&&(c+="T"),c+=qn(this,l,s,n,r,a,o),c}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?Rs(this,e==="extended",as(s)):null}toISOWeekDate(){return es(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=as(l),(r&&rs.indexOf(l)>=3?"T":"")+qn(this,o==="extended",s,e,n,a,l)):null}toRFC2822(){return es(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return es(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?Rs(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:s=!1,includeOffsetSpace:n=!0}={}){let r="HH:mm:ss.SSS";return(s||e)&&(n&&(r+=" "),s?r+="z":e&&(r+="ZZ")),es(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():js}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};const s={...this.c};return e.includeConfig&&(s.outputCalendar=this.outputCalendar,s.numberingSystem=this.loc.numberingSystem,s.locale=this.loc.locale),s}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,s="milliseconds",n={}){if(!this.isValid||!e.isValid)return K.invalid("created by diffing an invalid DateTime");const r={locale:this.locale,numberingSystem:this.numberingSystem,...n},a=Xi(s).map(K.normalizeUnit),o=e.valueOf()>this.valueOf(),l=o?this:e,c=o?e:this,u=nl(l,c,a,r);return o?u.negate():u}diffNow(e="milliseconds",s={}){return this.diff(W.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||W.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||W.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(W.isDateTime))throw new Ne("min requires all arguments be DateTimes");return Rn(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every(W.isDateTime))throw new Ne("max requires all arguments be DateTimes");return Rn(e,s=>s.valueOf(),Math.max)}static fromFormatExplain(e,s,n={}){const{locale:r=null,numberingSystem:a=null}=n,o=ne.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});return da(o,e,s)}static fromStringExplain(e,s,n={}){return W.fromFormatExplain(e,s,n)}static buildFormatParser(e,s={}){const{locale:n=null,numberingSystem:r=null}=s,a=ne.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new ua(a,e)}static fromFormatParser(e,s,n={}){if(B(e)||B(s))throw new Ne("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:a=null}=n,o=ne.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});if(!o.equals(s.locale))throw new Ne(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${s.locale}`);const{result:l,zone:c,specificOffset:u,invalidReason:f}=s.explainFromTokens(e);return f?W.invalid(f):vt(l,c,n,`format ${s.format}`,e,u)}static get DATE_SHORT(){return is}static get DATE_MED(){return yr}static get DATE_MED_WITH_WEEKDAY(){return ki}static get DATE_FULL(){return pr}static get DATE_HUGE(){return gr}static get TIME_SIMPLE(){return Sr}static get TIME_WITH_SECONDS(){return xr}static get TIME_WITH_SHORT_OFFSET(){return vr}static get TIME_WITH_LONG_OFFSET(){return wr}static get TIME_24_SIMPLE(){return Ar}static get TIME_24_WITH_SECONDS(){return Tr}static get TIME_24_WITH_SHORT_OFFSET(){return Nr}static get TIME_24_WITH_LONG_OFFSET(){return br}static get DATETIME_SHORT(){return kr}static get DATETIME_SHORT_WITH_SECONDS(){return Ir}static get DATETIME_MED(){return Er}static get DATETIME_MED_WITH_SECONDS(){return Mr}static get DATETIME_MED_WITH_WEEKDAY(){return Ii}static get DATETIME_FULL(){return Or}static get DATETIME_FULL_WITH_SECONDS(){return jr}static get DATETIME_HUGE(){return Cr}static get DATETIME_HUGE_WITH_SECONDS(){return Dr}}function Ct(t){if(W.isDateTime(t))return t;if(t&&t.valueOf&&it(t.valueOf()))return W.fromJSDate(t);if(t&&typeof t=="object")return W.fromObject(t);throw new Ne(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function Al(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function Tl(t,e){try{const s=W.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 Nl(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 us(t,e="UTC"){if(!t)return"-";const s=W.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 bl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},kl={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function ya({alerts:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,onAlertIdClick:a,onAlertView:o,onFilterChange:l,onPageChange:c,onRefetch:u,resetKey:f}){const m=Xs(),S=async T=>{try{const x=await m.mutateAsync({alertUniqueId:T.alertId??T.id,alertId:T.id,status:"Reopen",notes:"Reopened",modifiedBy:0});if(x?.responseStatus||x?.Success){const $=x?.Message||x?.data||"Alert reopened successfully.";xe.toast.success($)}else{const $=x?.errorMessage||x?.Message||"Failed to reopen alert";xe.toast.error($)}}catch{xe.toast.error("Failed to reopen alert. Please try again.")}},y=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:T=>i.jsx(h.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${bl[T]}`,backgroundColor:kl[String(T)]},children:T})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:T=>Nl(T)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(T,x)=>i.jsxs("div",{children:[i.jsx("a",{onClick:$=>{$.preventDefault(),a?.(x,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:x.alertNumber}),i.jsx("div",{className:"text-black/65",children:T})]})},{title:"Preview",key:"preview",width:100,align:"center",render:(T,x)=>i.jsx(fr,{record:x})},{title:"",key:"menu",width:60,align:"right",render:(T,x)=>i.jsx(h.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:$})=>{$==="reopen"&&S(x)}},children:i.jsx(h.Button,{type:"text",icon:i.jsx(dt.MoreOutlined,{})})})}],A=l?t:(t||[]).filter(T=>{const x=mn(T.statusType||"");return Ai.some($=>x.includes(mn($)))});return i.jsx(Qs,{data:A,loading:e,pageSize:s,total:n,currentPage:r,columns:y,renderActions:void 0,onAlertIdClick:a,onAlertView:o,onFilterChange:l,onPageChange:c,onRefetch:u,resetKey:f,excludeCompleted:!1})}function Il({size:t=120,time:e,timeZone:s="America/New_York"}){const{hours:n,minutes:r,seconds:a}=d.useMemo(()=>{const m=new Intl.DateTimeFormat("en-US",{timeZone:s,hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(e);return{hours:parseInt(m.find(S=>S.type==="hour")?.value||"0",10),minutes:parseInt(m.find(S=>S.type==="minute")?.value||"0",10),seconds:parseInt(m.find(S=>S.type==="second")?.value||"0",10)}},[e,s]),o=a*6,l=r*6+a*.1,c=n%12*30+r*.5,u=t/2;return i.jsxs("div",{className:"relative rounded-full border border-gray-300 bg-white",style:{width:t,height:t},role:"img","aria-label":"Analog Clock",children:[[...Array(12)].map((f,m)=>{const S=m*30,y=6,A=u-4,T=A-y,x=(S-90)*(Math.PI/180),$=u+T*Math.cos(x),H=u+T*Math.sin(x),J=u+A*Math.cos(x),E=u+A*Math.sin(x);return i.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:i.jsx("line",{x1:$,y1:H,x2:J,y2:E,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 pa({label:t="USA",timeZone:e="America/New_York",updateIntervalMs:s=1e3,className:n}){const[r,a]=d.useState(new Date);d.useEffect(()=>{const u=setInterval(()=>a(new Date),s);return()=>clearInterval(u)},[s]);const o=d.useMemo(()=>Al(r,e),[r,e]),{abbr:l,offset:c}=d.useMemo(()=>Tl(r,e),[r,e]);return i.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[i.jsx(Il,{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:El}=h.Typography;function Ml({sortBy:t,onChange:e,showActions:s,onSave:n,onClear:r,saving:a}){return i.jsxs(h.Row,{gutter:[16,16],align:"middle",children:[i.jsx(h.Col,{xs:24,md:8,lg:5,children:i.jsxs(h.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[i.jsx(El,{className:"text-gray-600 whitespace-nowrap",children:"Sort By:"}),i.jsx(h.Select,{placeholder:"By Severity",value:t,onChange:o=>e({sortBy:o}),options:[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],className:"w-full",style:{minWidth:"200px"}})]})}),i.jsx(h.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?i.jsxs(h.Space,{className:"w-full",direction:"horizontal",size:8,children:[i.jsx(h.Button,{onClick:r,disabled:a,children:"Clear"}),i.jsx(h.Button,{type:"primary",onClick:n,loading:a,children:"Save"})]}):null})]})}const _s=t=>i.jsxs(h.Tag,{children:[i.jsx(dt.PlusOutlined,{})," ",t.length," more"]}),{Text:Qe}=h.Typography;function Ol(t){const{selectedRule:e,setSelectedRule:s,ruleOptions:n,minsOptions:r,roleOptions:a,l1mins:o,setL1mins:l,l1role:c,setL1role:u,l2mins:f,setL2mins:m,l2role:S,setL2role:y,l3mins:A,setL3mins:T,l3role:x,setL3role:$,actions:H,setActions:J,thirdPartyIds:E,setThirdPartyIds:L,humanLoop:z,setHumanLoop:C,isAutoExpire:q,setAutoExpire:p,onClear:v,onSave:O,saving:Q,onActionTypesLoaded:he}=t,{rules:j,config:k}=De(),w=k.tenant==="schools",[M,b]=d.useState([]),[R,D]=d.useState([]),[_,G]=d.useState(!1);d.useEffect(()=>{let le=!1;return(async()=>{try{G(!0);const de=await j.getLookups();if(le||!de||!Array.isArray(de.actionTypes))return;const ge=de.actionTypes.map(V=>({label:V.name,value:String(V.actionTypeId)}));b(ge),he&&he(de.actionTypes);const ce=Array.isArray(de.thirdParties)?de.thirdParties.map(V=>({label:V.thirdPartyName,value:V.thirdPartyIds??V.thirdPartyId})):[];D(ce)}catch(de){console.error("Error loading lookups",de)}finally{le||G(!1)}})(),()=>{le=!0}},[]);const X=typeof o=="number"||typeof c=="number",te=typeof f=="number"||typeof S=="number",ie=typeof o=="number"||typeof c=="number"||typeof f=="number"||typeof S=="number"||typeof A=="number"||typeof x=="number"||Array.isArray(H)&&H.length>0||Array.isArray(E)&&E.length>0||!!z||!!q,ve=!!e&&ie&&!Q;return i.jsxs(h.Spin,{spinning:!!Q||_,children:[i.jsxs(h.Row,{gutter:[16,16],align:"bottom",children:[i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(h.Select,{placeholder:"Rules",value:e,onChange:s,options:n,className:"w-full"})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),i.jsx(h.Col,{span:14,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:o,onChange:l,options:r})}),i.jsx(h.Col,{span:14,children:i.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:c,onChange:u,options:a})})]})]})}),X&&i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),i.jsx(h.Col,{span:14,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:f,onChange:m,options:r})}),i.jsx(h.Col,{span:14,children:i.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:S,onChange:y,options:a})})]})]})}),te&&i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),i.jsx(h.Col,{span:14,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:A,onChange:T,options:r})}),i.jsx(h.Col,{span:14,children:i.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:x,onChange:$,options:a})})]})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),i.jsx(h.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:H,onChange:J,options:M,maxTagCount:1,maxTagPlaceholder:_s})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Notify"}),i.jsx(h.Select,{mode:"multiple",placeholder:"Notify",className:"w-full",value:E,onChange:L,options:R,maxCount:2,maxTagPlaceholder:_s})]})})]}),i.jsxs(h.Row,{gutter:[16,16],align:"bottom",className:"mt-4 items-center",children:[i.jsx(h.Col,{xs:24,sm:12,md:8,lg:7,children:i.jsxs("div",{className:"flex items-center h-full gap-8",children:[!w&&i.jsx(h.Checkbox,{checked:z,onChange:le=>C(le.target.checked),className:"w-full",children:"Human-In-The-Loop"}),i.jsx(h.Checkbox,{checked:q,onChange:le=>p(le.target.checked),className:"w-full",children:"Auto-expire in 5 minutes"})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(h.Button,{onClick:v,children:"Clear"}),i.jsx(h.Button,{type:"primary",onClick:O,loading:!!Q,disabled:!ve,children:"Save"})]})})]})]})}function jl({entries:t,userRoles:e,onEdit:s,loading:n}){const{config:r}=De(),a=r.tenant==="schools",o=new Map(e.map(c=>[c.userRoleId,c.userRoleName])),l=c=>c.map(u=>o.get(u)||String(u)).join(", ");return i.jsx(h.Table,{rowKey:"id",dataSource:t,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(c,u)=>`${u[0]}-${u[1]} of ${c} items`},loading:n,columns:[{title:"Rule",dataIndex:"ruleOrSeverityLabel",key:"rule"},{title:"Level 1",key:"l1",render:(c,u)=>i.jsxs("span",{children:[u.l1.minutes?`Action taken in (${u.l1.minutes} Mins)`:"No Action taken in 0 Min",u.l1.roles?.length?`, Escalate to (${l(u.l1.roles)})`:""]})},{title:"Level 2",key:"l2",render:(c,u)=>i.jsxs("span",{children:[u.l2.minutes?`Action taken in (${u.l2.minutes} Mins)`:"No Action taken in 0 Min",u.l2.roles?.length?`, Escalate to (${l(u.l2.roles)})`:""]})},{title:"Level 3",key:"l3",render:(c,u)=>i.jsxs("span",{children:[u.l3.minutes?`Action taken in (${u.l3.minutes} Mins)`:"No Action taken in 0 Min",u.l3.roles?.length?`, Escalate to (${l(u.l3.roles)})`:""]})},{title:"Pick Actions",key:"actionsCol",render:(c,u)=>u.actions?.length?u.actions.join(", "):"-"},{title:"Notify",key:"notify",render:(c,u)=>u.notify?.length?u.notify.join(", "):"-"},...a?[]:[{title:"Human-In-The-Loop",key:"humanLoop",render:(c,u)=>u.humanLoop?"Yes":"No"}],{title:"Auto Expire",key:"isAutoExpire",render:(c,u)=>u.isAutoExpire?"Yes":"No"},{title:"Actions",key:"ops",render:(c,u)=>i.jsx(h.Button,{type:"text",onClick:()=>s(u.id),children:i.jsx(dt.EditOutlined,{})})}]})}const{Title:Cl,Text:Us}=h.Typography;function ga({userRoles:t,rules:e,rawRules:s}){const{rules:n}=De(),[r,a]=d.useState(!1),[o,l]=d.useState(!1),[c,u]=d.useState(s),[f,m]=d.useState(),[S,y]=d.useState([]),A=d.useMemo(()=>t.map(E=>({label:E.userRoleName,value:E.userRoleId})),[t]),T=d.useMemo(()=>(e||[]).map(E=>({label:E.Name||"-",value:E.RuleId||E.Name||""})),[e]),x=d.useMemo(()=>(e||[]).map((E,L)=>({key:E.RuleId||E.Name||String(L),ruleName:E.Name||"-",ruleDesc:E.Description||""})),[e]);d.useEffect(()=>{let E=!1;return(async()=>{try{a(!0);const L=await n.getRules();E||u(Array.isArray(L)?L:[])}catch{!E&&Array.isArray(s)&&u(s)}finally{E||a(!1)}})(),()=>{E=!0}},[]),d.useEffect(()=>{!c&&Array.isArray(s)&&u(s)},[s]),d.useEffect(()=>{if(!f||!Array.isArray(c)){y([]);return}const E=c.find(z=>z?.ruleId===f||z?.RuleId===f||z?.ruleName===f),L=E?.userRoleIds??E?.UserRoleIds;y(Array.isArray(L)?L:[])},[f,c]);const $=d.useMemo(()=>{if(!Array.isArray(c)||!c.length)return{};const E={};for(const L of x){const z=c.find(p=>p?.ruleId===L.key||p?.ruleName===L.key||p?.RuleId===L.key||p?.ruleName===L.ruleName||p?.Name===L.ruleName),C=z?.userRoleIds??z?.UserRoleIds,q=Array.isArray(C)?C:[];q.length&&(E[L.key]=q)}return E},[c,x]),H=()=>{m(void 0),y([])},J=async()=>{if(!f){xe.toast.info("Please select a rule");return}try{l(!0);const E=Array.isArray(c)?c.find(p=>p?.ruleId===f||p?.RuleId===f||p?.ruleName===f):void 0,L=typeof E?.recordId=="number"?E.recordId:E?.ruleId||E?.RuleId||void 0;if(!E||!L)throw new Error(`Unable to find rule identifier for rule ${f}`);const z=S.map(p=>{const v=t.find(O=>O.userRoleId===p);return{id:p,name:v?.userRoleName??String(p)}}),C={...E,ruleId:f,userRoleIds:S,userRoles:z},q=await n.updateRule(L,C);if(!q?.responseStatus&&!q?.Success&&!q?.success)xe.toast.error(q?.errorMessage||q?.Message||"Error saving Alert Assignment");else{xe.toast.success("Alert assignment saved"),m(void 0),y([]);try{const p=await n.getRules();u(Array.isArray(p)?p:[])}catch(p){console.error("Failed to refresh rules after save",p)}}}catch(E){console.error("Failed to save alert assignment",E),xe.toast.error(E instanceof Error?E.message:"Error saving Alert Assignment")}finally{l(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(Cl,{level:4,className:"!mb-4",children:"Alert Assignment"}),i.jsx(h.Spin,{spinning:o||r,children:i.jsxs(h.Row,{gutter:[16,16],align:"bottom",className:"mb-6",children:[i.jsx(h.Col,{xs:24,sm:12,md:8,lg:6,children:i.jsxs("div",{children:[i.jsx(Us,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(h.Select,{placeholder:"Rules",value:f,onChange:m,options:T,className:"w-full"})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:8,children:i.jsxs("div",{children:[i.jsx(Us,{className:"text-gray-700 font-medium block mb-1",children:"Alert Notification To"}),i.jsx(h.Select,{mode:"multiple",placeholder:"Select roles",className:"w-full",value:S,onChange:y,options:A,maxTagCount:1,maxTagPlaceholder:_s})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(h.Button,{onClick:H,disabled:o,children:"Cancel"}),i.jsx(h.Button,{type:"primary",onClick:J,loading:o,disabled:o||!f,children:"Save"})]})})]})}),i.jsx(h.Table,{rowKey:"key",dataSource:x,loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(E,L)=>`${L[0]}-${L[1]} of ${E} items`},columns:[{title:"Rule Name",dataIndex:"ruleName",key:"ruleName"},{title:"Description",dataIndex:"ruleDesc",key:"ruleDesc"},{title:"Alert Notification To",key:"assign",render:(E,L)=>{const z=$[L.key]??[];return z.length?i.jsx("div",{className:"flex flex-wrap gap-1",children:z.map(C=>{const q=t.find(p=>p.userRoleId===C);return i.jsx(h.Tag,{children:q?.userRoleName??String(C)},C)})}):i.jsx(Us,{type:"secondary",children:"—"})}}]})]})}const{Title:Kn}=h.Typography;function Ls(t){return!t||typeof t!="object"?{}:{level1UserRoleId:t.level1UserRoleId??t.Level1UserRoleId,level1PostAssistTime:t.level1PostAssistTime??t.Level1PostAssistTime,level2UserRoleId:t.level2UserRoleId??t.Level2UserRoleId,level2PostAssistTime:t.level2PostAssistTime??t.Level2PostAssistTime,level3UserRoleId:t.level3UserRoleId??t.Level3UserRoleId,level3PostAssistTime:t.level3PostAssistTime??t.Level3PostAssistTime,escalationSettingsActionTypeIds:t.escalationSettingsActionTypeIds??t.EscalationSettingsActionTypeIds,thirdPartyId:t.thirdPartyId??t.ThirdPartyId??t.ThirdPartyIds,humanLoop:t.humanLoop??t.HumanLoop,isAutoExpire:t.isAutoExpire??t.IsAutoExpire}}function Sa({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r,onSave:a}){const{rules:o,alerts:l}=De(),[c,u]=d.useState("By Severity"),[f,m]=d.useState("By severity"),[S,y]=d.useState("By Severity"),[A,T]=d.useState(!1),[x,$]=d.useState(!1),[H,J]=d.useState(!1),[E,L]=d.useState(null),[z,C]=d.useState("rules"),[q,p]=d.useState(),[v,O]=d.useState(),[Q,he]=d.useState(),[j,k]=d.useState(),[w,M]=d.useState(),[b,R]=d.useState(),[D,_]=d.useState(),[G,X]=d.useState(),[te,ie]=d.useState([]),[ve,le]=d.useState([]),[de,ge]=d.useState(!1),[ce,V]=d.useState(!1),[P,re]=d.useState({}),[ae,we]=d.useState({}),[Ae,Ye]=d.useState(s||[]),[Re,Te]=d.useState([]),[Mt,ht]=d.useState(!1),[yt,ot]=d.useState(!1),[Ue,pt]=d.useState(n||[]);d.useEffect(()=>{n&&n.length&&pt(n)},[n]),d.useEffect(()=>{if(!Ue||!Ue.length)return;const F=Object.keys(P).length>0||Object.keys(ae).length>0;if(Re.length&&!F)return;const se=Ue.map((Y,Z)=>{const g=e.find(Ie=>Ie.RuleId===(Y.ruleId||Y.ruleName))?.Name||Y.ruleName||Y.Name||"-",N=Ls(Y.escalationSettings),U=typeof N.level1UserRoleId=="number"&&N.level1UserRoleId>0?[N.level1UserRoleId]:[],ye=typeof N.level2UserRoleId=="number"&&N.level2UserRoleId>0?[N.level2UserRoleId]:[],ke=typeof N.level3UserRoleId=="number"&&N.level3UserRoleId>0?[N.level3UserRoleId]:[],Ve=(Array.isArray(N.escalationSettingsActionTypeIds)?N.escalationSettingsActionTypeIds:[]).map(Ie=>P[Ie]||String(Ie)),Ge=(Array.isArray(N.thirdPartyId)?N.thirdPartyId:[]).map(Ie=>ae[Ie]||String(Ie)),Ts=typeof N.humanLoop=="boolean"?N.humanLoop:null,Ns=typeof N.isAutoExpire=="boolean"?N.isAutoExpire:null;return{id:String(Y.ruleId||Y.ruleName||Z),ruleOrSeverityLabel:g,l1:{minutes:N.level1PostAssistTime??void 0,roles:U},l2:{minutes:N.level2PostAssistTime??void 0,roles:ye},l3:{minutes:N.level3PostAssistTime??void 0,roles:ke},actions:Ve,notify:Ge,humanLoop:Ts,isAutoExpire:Ns}});Te(se)},[Ue,e,P,ae]);const Ot=d.useMemo(()=>t.map(F=>({label:F.DisplayName,value:F.SeverityId})),[t]),Se=d.useMemo(()=>e.map(F=>({label:F.Name,value:F.RuleId})),[e]),gt=d.useMemo(()=>Ae.map(F=>({label:F.userRoleName,value:F.userRoleId})),[Ae]),xs=d.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(F=>({label:`${F}`,value:F})),[]);d.useEffect(()=>{let F=!1;async function se(){try{J(!0),L(null);const Y=await l.getAdminSettings();if(!F&&Y){const Z=er(Y.sortBy);u(Z),y(Z),T(!1)}}catch(Y){if(!F){const Z=Y instanceof Error?Y.message:"Failed to load admin settings";L(Z)}}finally{F||J(!1)}}return se(),()=>{F=!0}},[]),d.useEffect(()=>{if(!v)return;const F=g=>{const N=Number(g);return!isNaN(N)&&N>0?N:void 0},se=g=>{const N=Number(g);return!isNaN(N)&&N>0?N:void 0},Y=(Ue||[]).find(g=>g?.ruleId===v||g?.ruleName===v||g?.RuleId===v),Z=Ls(Y?.escalationSettings);if(Z&&typeof Z=="object"){he(se(Z.level1PostAssistTime)),k(F(Z.level1UserRoleId)),M(se(Z.level2PostAssistTime)),R(F(Z.level2UserRoleId)),_(se(Z.level3PostAssistTime)),X(F(Z.level3UserRoleId));const g=Array.isArray(Z.escalationSettingsActionTypeIds)?Z.escalationSettingsActionTypeIds:[];ie(g.map(N=>String(N))),le(Array.isArray(Z.thirdPartyId)?Z.thirdPartyId:[]),ge(!!Z.humanLoop),V(!!Z.isAutoExpire)}},[z,v,Ue]);const vs=async()=>{try{ot(!0);const F=await o.getRules(),se=Array.isArray(F)?F:Array.isArray(F?.data)?F.data:[];pt(se);const Y=se.map((Z,g)=>{const N=e.find(Ie=>Ie.RuleId===(Z.ruleId||Z.ruleName))?.Name||Z.ruleName||Z.Name||"-",U=Ls(Z.escalationSettings??Z.EscalationSettings),ye=typeof U.level1UserRoleId=="number"&&U.level1UserRoleId>0?[U.level1UserRoleId]:[],ke=typeof U.level2UserRoleId=="number"&&U.level2UserRoleId>0?[U.level2UserRoleId]:[],ue=typeof U.level3UserRoleId=="number"&&U.level3UserRoleId>0?[U.level3UserRoleId]:[],_e=(Array.isArray(U.escalationSettingsActionTypeIds)?U.escalationSettingsActionTypeIds:[]).map(Ie=>P[Ie]||String(Ie)),Ts=(Array.isArray(U.thirdPartyId)?U.thirdPartyId:[]).map(Ie=>ae[Ie]||String(Ie)),Ns=typeof U.humanLoop=="boolean"?U.humanLoop:null;return{id:String(Z.ruleId||Z.ruleName||g),ruleOrSeverityLabel:N,l1:{minutes:U.level1PostAssistTime??void 0,roles:ye},l2:{minutes:U.level2PostAssistTime??void 0,roles:ke},l3:{minutes:U.level3PostAssistTime??void 0,roles:ue},actions:_e,notify:Ts,humanLoop:Ns}});Te(Y)}catch(F){console.error("Failed to refetch entries",F)}finally{ot(!1)}};d.useEffect(()=>{let F=!1;return(async()=>{try{const se=await o.getLookups();if(F||!se)return;const Y={};if(Array.isArray(se.thirdParties))for(const g of se.thirdParties){const N=g.thirdPartyIds??g.thirdPartyId;typeof N=="number"&&(Y[N]=g.thirdPartyName)}we(Y);const Z=Array.isArray(se.userRoles)?se.userRoles.map(g=>({userRoleId:g.userRoleId??g.id,userRoleName:g.userRoleName??g.name})):[];F||Ye(Z.length?Z:s||[])}catch(se){console.error("Error loading lookups",se)}})(),()=>{F=!0}},[]);const ws=async()=>{$(!0);try{const F=await l.setAdminSettings({sortBy:c,groupBy:"string"});F?.responseStatus&&F?.data&&xe.toast.success(F.data),y(c),T(!1)}catch(F){console.error("Error saving admin settings",F)}finally{$(!1)}},As=()=>{u(S),T(!1)},Zt=async()=>{ht(!0),a?.({ruleId:v,levels:[{minutes:Q,role:j},{minutes:w,role:b},{minutes:D,role:G}],actions:te,thirdPartyIds:ve,humanLoop:de,isAutoExpire:ce});try{if(v){const se=Array.isArray(te)?te.map(U=>Number.isNaN(Number(U))?U:Number(U)):[],Y=(Ue||[]).find(U=>U?.ruleId===v||U?.ruleName===v||U?.RuleId===v),Z=typeof Y?.recordId=="number"?Y.recordId:Y?.ruleId||Y?.RuleId||void 0;if(!Y||!Z){xe.toast.error("Unable to find rule identifier for update");return}const g={...Y,escalationSettings:{level1UserRoleId:j??0,level1PostAssistTime:Q??0,level2UserRoleId:b??0,level2PostAssistTime:w??0,level3UserRoleId:G??0,level3PostAssistTime:D??0,escalationSettingsActionTypeIds:se,thirdPartyId:Array.isArray(ve)?ve:[],humanLoop:de,isAutoExpire:ce}},N=await o.updateRule(Z,g);N?.responseStatus||N?.Success||N?.success?(xe.toast.success("Escalation settings saved"),await vs(),O(void 0),he(void 0),k(void 0),M(void 0),R(void 0),_(void 0),X(void 0),ie([]),le([]),ge(!1),V(!1)):xe.toast.error(N?.errorMessage||N?.Message||"Error saving Escalation Settings")}}catch(se){console.error("Error saving escalation settings",se)}finally{ht(!1)}},zt=()=>{u("By Severity"),m("By severity"),C("rules"),p(void 0),O(void 0),he(void 0),k(void 0),M(void 0),R(void 0),_(void 0),X(void 0),ie([]),le([]),ge(!1),V(!1)};return i.jsxs("div",{className:"w-full",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(Kn,{level:4,className:"!mb-2",children:"Admin Settings"}),i.jsxs(h.Spin,{spinning:H,children:[E?i.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",E]}):null,i.jsx(Ml,{sortBy:c,groupBy:f,onChange:F=>{F.sortBy&&(u(F.sortBy),T(!0)),F.groupBy&&(m(F.groupBy),T(!0))},showActions:A,onSave:ws,onClear:As,saving:x})]})]}),i.jsx(h.Divider,{className:"my-6"}),i.jsxs("div",{children:[i.jsx(Kn,{level:4,className:"!mb-4",children:"Escalation Settings"}),i.jsx(Ol,{escBasis:z,setEscBasis:C,selectedSeverity:q,setSelectedSeverity:p,selectedRule:v,setSelectedRule:O,severityOptions:Ot,ruleOptions:Se,minsOptions:xs,roleOptions:gt,l1mins:Q,setL1mins:he,l1role:j,setL1role:k,l2mins:w,setL2mins:M,l2role:b,setL2role:R,l3mins:D,setL3mins:_,l3role:G,setL3role:X,actions:te,setActions:ie,thirdPartyIds:ve,setThirdPartyIds:le,humanLoop:de,setHumanLoop:ge,onClear:zt,onSave:Zt,saving:Mt,onActionTypesLoaded:F=>{const se={};for(const Y of F)typeof Y.actionTypeId=="number"&&(se[Y.actionTypeId]=Y.name);re(se)},isAutoExpire:ce,setAutoExpire:V})]}),i.jsx(h.Divider,{className:"my-6"}),i.jsx(jl,{entries:Re,userRoles:Ae,loading:yt||r,onEdit:F=>{C("rules");const se=Re.find(Z=>Z.id===F),Y=e.find(Z=>Z.RuleId===F)||(se?e.find(Z=>Z.Name===se.ruleOrSeverityLabel):void 0);O(Y?Y.RuleId:F)}}),i.jsx(h.Divider,{className:"my-6"}),i.jsx(ga,{userRoles:Ae,rules:e,rawRules:n}),i.jsx(h.Divider,{})]})}const{Title:Qn,Text:ts}=h.Typography;function Dl({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:a}=De(),o=[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],[l,c]=d.useState("By Severity"),[u,f]=d.useState(new Set),[m,S]=d.useState(null),[y,A]=d.useState(null),[T,x]=d.useState({inApp:!1,sms:!1,email:!1}),[$,H]=d.useState([]),[J,E]=d.useState(!0),[L,z]=d.useState(!1);d.useEffect(()=>{let p=!1;return(async()=>{try{const v=await a.getPreferenceSettings();if(p||!v)return;x({inApp:!!v.inApp,sms:!!v.sms,email:!!v.email});const O=er(v.sortBy);c(O==="By Created Date"?"By Created Date":"By Severity"),S(pn(v.doNotDisturbStart)),A(pn(v.doNotDisturbEnd)),Array.isArray(v.anomalyIds)&&f(new Set(v.anomalyIds.map(Q=>String(Q))))}catch(v){console.error("Error in loading my preferences: ",v)}})(),()=>{p=!0}},[]),d.useEffect(()=>{let p=!1;return(async()=>{try{E(!0);const v=await r.getLookups();if(p||!v)return;const O=Array.isArray(v.anomalies)?v.anomalies:[];H(O)}catch(v){console.error("Failed to load anomalies lookups",v)}finally{p||E(!1)}})(),()=>{p=!0}},[]);const C=p=>{f(v=>{const O=new Set(v);return O.has(p)?O.delete(p):O.add(p),O})},q=async()=>{s?.({sortBy:l,subscribedRuleIds:Array.from(u),dnd:{from:m,to:y},channels:T});try{z(!0);const p=m?m.format?.("HH:mm:ss")??"00:00:00":"00:00:00",v=y?y.format?.("HH:mm:ss")??"00:00:00":"00:00:00",O=Array.from(u).map(he=>Number(he)).filter(he=>Number.isFinite(he)),Q=await a.setPreferenceSettings({anomalyIds:O,doNotDisturbStart:p,doNotDisturbEnd:v,inApp:!!T.inApp,sms:!!T.sms,email:!!T.email,sortBy:l});Q?.responseStatus&&xe.toast.success(Q?.data||"Preferences updated successfully.")}catch(p){console.error("Error in saving my preferences: ",p)}finally{z(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(h.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:i.jsx(h.Col,{xs:24,md:8,children:i.jsxs(h.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(ts,{className:"text-gray-600",children:"Sort By:"}),i.jsx(h.Select,{className:"w-[240px]",value:l,options:o,onChange:c})]})})}),i.jsxs("div",{className:"mb-4",children:[i.jsx(Qn,{level:5,className:"!mb-2",children:"Anomalies"}),J?i.jsx("div",{className:"py-4",children:i.jsx(h.Spin,{})}):i.jsx(h.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray($)?$:[]).map(p=>{const v=String(p.recordId),O=p.anomalyName;return i.jsx(h.Checkbox,{checked:u.has(v),onChange:()=>C(v),children:O},v)})})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx(Qn,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),i.jsx(h.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:i.jsx(h.Col,{xs:24,md:12,children:i.jsxs(h.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(ts,{children:"Do Not Disturb mode:"}),i.jsxs(h.Space,{size:12,className:"w-full",children:[i.jsxs(h.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(ts,{children:"From"}),i.jsx(h.TimePicker,{value:m,onChange:p=>S(p),format:"HH:mm"})]}),i.jsxs(h.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(ts,{children:"To"}),i.jsx(h.TimePicker,{value:y,onChange:p=>A(p),format:"HH:mm"})]})]})]})})}),i.jsxs(h.Row,{gutter:[24,12],children:[i.jsx(h.Col,{children:i.jsx(h.Checkbox,{checked:T.inApp,onChange:p=>x({...T,inApp:p.target.checked}),children:"In-app"})}),i.jsx(h.Col,{children:i.jsx(h.Checkbox,{checked:T.sms,onChange:p=>x({...T,sms:p.target.checked}),children:"SMS"})}),i.jsx(h.Col,{children:i.jsx(h.Checkbox,{checked:T.email,onChange:p=>x({...T,email:p.target.checked}),children:"Email"})})]})]}),i.jsx(h.Divider,{}),i.jsxs(h.Space,{className:"gap-3",children:[i.jsx(h.Button,{onClick:n,disabled:L,children:"Cancel"}),i.jsx(h.Button,{type:"primary",onClick:q,loading:L,children:"Save"})]})]})}function xa({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r}){return i.jsx("div",{className:"w-full",children:i.jsx(Sa,{severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r})})}const Rl="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=",Ul="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 Ss(){const{config:t}=De();return{timeZoneDetails:d.useMemo(()=>{const s=t.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone;return{timeZoneUniqueId:"",ianaTimeZoneId:s,timeZoneName:s,offset:""}},[t.timeZone]),loading:!1}}function Ll(t){const e=(t.status||"").toLowerCase()==="completed"?i.jsx("img",{src:Rl,alt:"completed",style:{width:20,height:20}}):i.jsx("img",{src:Ul,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 Fl({data:t}){const{timeZoneDetails:e}=Ss();return i.jsx("div",{className:"w-full",children:i.jsx(h.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:i.jsxs("div",{className:"w-full",style:{maxHeight:"50vh",overflowY:"auto"},children:[i.jsx(h.Card,{className:"mb-4 rounded-md p-4",bordered:!0,children:i.jsxs("div",{className:"grid grid-cols-4 gap-6 text-xs",children:[i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Alert ID"}),i.jsx("span",{className:"text-black",children:t.summary.alertNumber})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Severity"}),i.jsx("span",{className:"text-black",children:t.summary.severity})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Location"}),i.jsx("span",{className:"text-black",children:t.summary.location})]})]})}),i.jsxs(h.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsx("h4",{className:"text-sm text-black font-medium",children:"Response Timeline/ Audit trail/log"})}),i.jsx("div",{className:"mt-2",children:i.jsx(h.Steps,{direction:"vertical",size:"small",current:1,items:(t.timeline||[]).map(Ll)})})]})]})},{key:"notification",label:"Notification Sent",children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",style:{maxHeight:"50vh",overflowY:"auto"},children:[(t.notifications||[]).map((s,n)=>i.jsxs(h.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.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:us(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 $l=({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}=Ss(),u=a?.length?a.map(m=>{const S=(m?.status||m?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",y=m?.createdDate?us(m.createdDate,c?.ianaTimeZoneId):m?.timestamp?us(m.timestamp,c?.ianaTimeZoneId):"";return{status:S,title:m?.status||m?.eventStatus||"Status Update",description:m?.description||m?.actionNotes||"",timestamp:y}}):[],f={summary:l,timeline:u,notifications:o??[]};return i.jsx(Fl,{data:f})},Pl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Wl={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Bl={"elopement attempt":"elopement","elopement completed":"elopement","watchlist person detected":"watchlist","watch list person detected":"watchlist","brandished guns & knives":"weapon","brandished guns and knives":"weapon"},Vl=({isModalOpen:t,handleModalClose:e,selectedRow:s,fetchAlertLogs:n,alertStatusList:r=[],alertStatusLoading:a=!1,initialTab:o="details",sourceTab:l,onAlertView:c})=>{const[u,f]=d.useState(),[m,S]=d.useState(""),[y,A]=d.useState(!1),T=d.useRef(null),[x,$]=d.useState("details"),[H,J]=d.useState(void 0),E=Xs(),{alerts:L,rules:z,config:C}=De(),{timeZoneDetails:q}=Ss(),[p,v]=d.useState(null),[O,Q]=d.useState(!1),[he,j]=d.useState(!1),[k,w]=d.useState(void 0),[M,b]=d.useState(void 0),[R,D]=d.useState({}),[_,G]=d.useState({}),X=(g,N,U)=>{const ye=_[g];return R[g]===!1&&!ye?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(or,{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:[ye&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg z-10",children:i.jsx(yi,{size:32,className:"animate-spin text-gray-400"})}),i.jsx("img",{src:g,alt:N.caption||`media-${U}`,className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg transition-opacity duration-200 ${ye?"opacity-0":"opacity-100"}`,onLoad:()=>G(ke=>({...ke,[g]:!1})),onError:()=>G(ke=>({...ke,[g]:!1}))},g)]})},te=s?.originalData||{},{eventName:ie,eventDisplayName:ve,anomalyName:le,alertId:de,timestamp:ge,description:ce,spaceName:V,assignTeam:P,priority:re,statusType:ae,id:we,alertDetails:Ae,statusHistory:Ye,mediaDetails:Re,alertNumber:Te}=te,Mt=C.tenant==="snl"?ve||ie||"Alert Event":ie||"Alert Event",ht=g=>{const N=String(g||"").toLowerCase();return N==="delivered"||N==="sent"?"Delivered":N==="failed"?"Failed":"Queued"},yt=g=>({name:g?.receipientName||g?.recipientName||"-",role:g?.receipientRoleName||"",phone:g?.receipentPhoneNumber||g?.recipientPhoneNumber||g?.receipientEmail||g?.recipientEmail||"",status:ht(g?.messageStatus),notificationReceipientType:g?.notificationReceipientType||""}),ot=(g,N)=>{const U=N.map(yt),ye=U.filter(_e=>_e.status==="Delivered").length,ke=N.map(_e=>_e?.sentAt).filter(Boolean).sort((_e,Ge)=>new Date(Ge).getTime()-new Date(_e).getTime())[0],Ve=(N[0]||{})?.severityName||`${g} Notification`;return{channelLabel:`${g} Notification`,sentAt:ke||"",messageTitle:Ve,messageBody:"",total:U.length,delivered:ye,recipients:U}},Ue=g=>{const N=new Map;return(g||[]).forEach(U=>{const ye=String(U?.notificationType||"Unknown"),ke=N.get(ye)||[];ke.push(U),N.set(ye,ke)}),Array.from(N.entries()).map(([U,ye])=>ot(U,ye))},pt=async g=>{try{const N=await L.getAlertNotifications(g),U=Ue(N);J(U)}catch{J(void 0)}};d.useEffect(()=>{if(x!=="track"||!we)return;let g=!1;return pt(we).then(()=>{g&&J(void 0)}),()=>{g=!0}},[x,we]),d.useEffect(()=>{t?$(o):(f(void 0),S(""))},[t,o]),d.useEffect(()=>{!t||!c||c([{personName:te.personName,faceId:te.faceId,mediaDetails:te.mediaDetails}])},[t]),d.useEffect(()=>{if(!t||C.tenant!=="snl")return;let g=!1;return Q(!0),z.getLookups().then(N=>{g||(v(N.alertStatusTypes??[]),Q(!1))}).catch(()=>{g||(v([]),Q(!1))}),()=>{g=!0}},[t,C.tenant]);const Se=l==="archived"||["completed","false positive"].includes(String(ae||"").toLowerCase()),gt=g=>{const N=String(g?.value||"").toLowerCase(),U=String(g?.statusName||"").toLowerCase();return N.includes("reopen")||U.includes("reopen")},xs=String(le||"").trim().toLowerCase(),vs=Bl[xs]??"general",ws=r.filter(g=>{const N=gt(g);return typeof l<"u"?l==="archived"?N:!N:Se?N:!N}).map(g=>({value:g.value,label:g.statusName})),As=p??[],Zt=g=>!!g.isWatchListStatus,zt=g=>!!g.isWeapontStatus,F=As.filter(g=>{switch(vs){case"elopement":return g.isElopementStatus;case"watchlist":return Zt(g);case"weapon":return zt(g);default:return!g.isElopementStatus&&!Zt(g)&&!zt(g)}}).map(g=>({value:g.alertStatusTypeName,label:g.alertStatusTypeName})),se=C.tenant==="snl"&&p!==null?F:ws,Y=d.useMemo(()=>ar(Re),[Re]);d.useEffect(()=>{let g=!1;const N=new AbortController,U=async ue=>{if(ue){g||D(Ve=>({...Ve,[ue]:!1}));try{const Ve=await fetch(ue,{method:"HEAD",signal:N.signal});if(Ve.ok){g||D(Ge=>({...Ge,[ue]:!0}));return}if(Ve.status===404){g||D(Ge=>({...Ge,[ue]:!1}));return}if(!(await fetch(ue,{method:"GET",signal:N.signal})).ok)throw new Error("Media not available");g||D(Ge=>({...Ge,[ue]:!0}))}catch{g||D(Ve=>({...Ve,[ue]:!1}))}}};D({});const ye=Y.filter(ue=>!Fs(ue)).map(ue=>ue?.mediaUrl||ue).filter(ue=>typeof ue=="string"&&ue.length>0),ke={};return ye.forEach(ue=>{ke[ue]=!0}),G(ke),ye.forEach(ue=>U(ue)),()=>{g=!0,N.abort()}},[Y]);const Z=async()=>{try{A(!0);const g={alertUniqueId:de,alertId:we,status:u?String(u):void 0,notes:m.trim(),modifiedBy:0},N=await E.mutateAsync(g);if(N?.responseStatus||N?.Success){const U=N?.Message||N?.data||"Alert updated successfully.";xe.toast.success(U,{autoClose:1500,onClose:()=>{n(),e()}}),f(void 0),S("")}else{const U=N?.errorMessage||N?.Message||"Failed to update alert status";xe.toast.error(U)}}catch(g){console.error("Error updating alert status:",g),xe.toast.error("Failed to update alert status. Please try again.")}finally{A(!1)}};return i.jsx(h.Modal,{open:t,onCancel:e,width:1e3,footer:x==="details"?i.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[i.jsx(h.Button,{onClick:e,className:"!bg-[#6C757D] !text-white !border-[#6C757D] hover:!bg-[#5c636a] hover:!text-white hover:!border-[#5c636a]",children:"Cancel"}),i.jsx(h.Button,{type:"primary",onClick:Z,loading:y,children:y?"Saving...":"Save Changes"})]}):null,children:s&&i.jsx(h.Tabs,{activeKey:x,onChange:g=>$(g),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:Mt}),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: ",us(ge,q?.ianaTimeZoneId)]}),i.jsxs("div",{className:"font-sm text-gray-500",children:[i.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",ce||"No description available"]}),V&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",V]}),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(h.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${Pl[String(re)]||"#DFE4EA"}`,backgroundColor:Wl[String(re)]},children:["Severity: ",re||"N/A"]}),i.jsxs(h.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(ae||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",ae||"N/A"]})]}),i.jsx("div",{className:"w-full flex flex-col justify-start items-start mt-2 font-bold",children:i.jsxs("div",{className:"w-full mt-4",children:[i.jsx("div",{className:"flex flex-col gap-2",children:i.jsx(h.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:g=>f(g),value:u,options:se,loading:C.tenant==="snl"?O:a})}),i.jsxs("div",{className:"flex flex-col gap-2 mt-3",children:[i.jsx("label",{htmlFor:"action-details-input",className:"text-xs text-gray-500 font-medium",children:"Action Taken (Comments)"}),i.jsx("textarea",{id:"action-details-input",placeholder:"Enter details...",className:"w-full text-gray-500 h-20 border border-grey-500 rounded-md p-2",value:m,onChange:g=>S(g.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"}),Y.length>1?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>T.current?.prev?.(),className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 text-gray-600","aria-label":"Previous media",children:i.jsx(dt.LeftOutlined,{style:{fontSize:12}})}),i.jsx("button",{type:"button",onClick:()=>T.current?.next?.(),className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 text-gray-600","aria-label":"Next media",children:i.jsx(dt.RightOutlined,{style:{fontSize:12}})})]}):null]}),Y.length?i.jsx("div",{className:"w-full",children:i.jsx(h.Carousel,{ref:T,dots:!0,className:"w-full",children:Y.map((g,N)=>{const U=g.mediaUrl||g,ye=Fs(g);return i.jsxs("div",{className:"flex justify-center items-center relative",children:[ye?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:U}),"Your browser does not support the video tag."]}):X(String(U),g,N),g.caption&&i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:g.caption}),!ye&&R[String(U)]?i.jsx("button",{onClick:()=>{j(!0),w(U),b(g.type||"image")},className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:i.jsx(lr,{size:20})}):null]},String(U)||N)})})}):null]})}),i.jsx(mr,{isOpen:he,onClose:()=>j(!1),src:k||"",type:M||"image"})]})},{key:"track",label:"Track Incident",children:i.jsx($l,{alertId:de,id:we,priority:re,spaceName:V,alertNumber:Te,statusHistory:Ye,notifGroups:H})}]})})};function va(){const{alerts:t}=De(),e=mt.useQuery({queryKey:["alerts","statusList"],queryFn:()=>t.getAlertStatusList(),staleTime:5*6e4});return{list:e.data??[],loading:e.isLoading,error:e.error,refetch:e.refetch}}function cn({alerts:t,loading:e=!1,columns:s,total:n,currentPage:r,onRefetch:a,onPageChange:o,onFilterChange:l,onAlertView:c}){const[u,f]=d.useState(!1),[m,S]=d.useState(null),[y,A]=d.useState("details"),{list:T,loading:x}=va(),{timeZoneDetails:$}=Ss(),H=$?.timeZoneName??"UTC",J=$?.ianaTimeZoneId??"UTC";function E(O,Q){S(O),A(Q?.tab??"details"),C(Q?.sourceTab??"active"),f(!0)}function L(){f(!1)}const[z,C]=d.useState("active"),[q,p]=d.useState(0),v=m?{originalData:{...m,alertId:m.alertId??m.id,mediaDetails:m.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(pa,{label:H,timeZone:J})})]}),i.jsx(h.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:O=>{const Q=O==="archived";p(he=>he+1),o?.(1),l?.({isArchived:Q})},items:[{key:"active",label:"Active",children:i.jsx(Qs,{data:t,loading:e,pageSize:10,total:n,currentPage:r,columns:s||[],onAlertIdClick:E,onAlertView:c,onRefetch:a,onPageChange:o,onFilterChange:l,resetKey:q})},{key:"archived",label:"Archived",children:i.jsx(ya,{alerts:t,loading:e,columns:s||[],total:n,currentPage:r,onAlertIdClick:E,onAlertView:c,onFilterChange:l,onPageChange:o,onRefetch:a,resetKey:q})},{key:"settings",label:"Settings",children:i.jsx(Zl,{})}]}),i.jsx(Vl,{isModalOpen:u,handleModalClose:L,selectedRow:v,fetchAlertLogs:()=>{},alertStatusList:T,alertStatusLoading:x,initialTab:y,sourceTab:z,onAlertView:c})]})}function Zl(){const[t,e]=d.useState([]),[s,n]=d.useState([]),[r,a]=d.useState([]),[o,l]=d.useState([]),[c,u]=d.useState(!0),{rules:f}=De();return d.useEffect(()=>{let m=!0;return(async()=>{try{const S=await f.getRules();if(!m)return;l(Array.isArray(S)?S:[]);const y=(S||[]).map((A,T)=>({RuleId:A.ruleId||A.ruleName||String(T),Name:A.ruleName||A.Name||"-",Description:A.ruleDesc||A.Description||"",SeverityId:0}));e(y);try{const A=await f.getLookups(),T=Array.isArray(A?.userRoles)?A.userRoles.map(x=>({userRoleId:x.userRoleId??x.id,userRoleName:x.userRoleName??x.name})):[];n(T),a(Array.isArray(A?.severities)?A.severities:[])}catch{}}catch{}finally{m&&u(!1)}})(),()=>{m=!1}},[]),i.jsx(xa,{severities:r,rules:t,userRoles:s,rawRules:o,loadingRules:c})}function zl(t){return Array.isArray(t)?{items:t}:t}function wa(t=1,e){const{alerts:s,config:n}=De(),r=n.tenant==="schools"&&!!String(e?.searchText??"").trim(),a=mt.useQuery({queryKey:["alerts","list",n.tenant,t,e],queryFn:()=>{const o={...e};return n.tenant==="schools"?(o.pageNumber=t,o.pageSize=r?100:10):(o.pageNumber=t,o.pageSize=10),s.listAlerts(o).then(zl)},staleTime:r?0:3e4});return{alerts:a.data?.items??[],total:a.data?.total,loading:a.isLoading,error:a.error,refetch:a.refetch}}function Hl(t){const[e,s]=d.useState(1),[n,r]=d.useState({}),{alerts:a,total:o,loading:l,refetch:c}=wa(e,n);d.useEffect(()=>{!l&&a.length>0&&t.onAlertView?.(a)},[a,l]);const u=f=>{"isArchived"in f?r({isArchived:f.isArchived}):r(m=>({...m,...f}))};return i.jsx(cn,{alerts:a,loading:l,columns:t.columns,total:o,currentPage:e,onRefetch:c,onPageChange:s,onFilterChange:u,onAlertView:t.onAlertView})}function ql({tenant:t,apiDomain:e,rulesDomain:s,headers:n,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,alerts:l,loading:c,columns:u,onAlertView:f}){const[m]=d.useState(()=>new mt.QueryClient({defaultOptions:{queries:{retry:(y,A)=>{const T=A.response?.status??A?.status;return T>=400&&T<=500?!1:y<2},refetchOnWindowFocus:!1}}})),S=d.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return i.jsx(mt.QueryClientProvider,{client:m,children:i.jsx(nr,{tenant:t,override:S,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,children:Array.isArray(l)?i.jsx(cn,{alerts:l,loading:!!c,columns:u,onAlertView:f}):i.jsx(Hl,{columns:u,onAlertView:f})})})}function Gl(t){const{alerts:e}=De(),s=mt.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 Yl=[{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=ga;exports.AlertConsole=cn;exports.AlertConsoleWidget=ql;exports.AlertsTable=Qs;exports.ApiProvider=nr;exports.ArchivedTable=ya;exports.Clock=pa;exports.DataTable=rr;exports.MyPreferencesPanel=Dl;exports.SettingsPanel=Sa;exports.SettingsTabs=xa;exports.exampleAlertColumns=Yl;exports.useAlertStatusList=va;exports.useAlerts=wa;exports.useAlertsReport=Gl;exports.useApi=De;exports.useUpdateAlertStatus=Xs;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),d=require("react"),h=require("antd"),yt=require("@ant-design/icons"),we=require("react-toastify"),pt=require("@tanstack/react-query"),Aa="#FF3B30",Ta="#FF9500",ba="#FFCC00",Na="#34C759",Ht={critical:Aa,high:Ta,medium:ba,low:Na},un={Critical:Ht.critical,High:Ht.high,Medium:Ht.medium,Low:Ht.low};function ka(t){return un[t]||un.Low}function dn(t){if(!t||typeof t!="string")return 0;const e=t.trim().split(":");if(e.length!==3)return 0;const[s,n,r]=e,a=Number.parseInt(s,10),o=Number.parseInt(n,10),l=Number.parseFloat(r||"0"),c=Number.isFinite(a)?a:0,u=Number.isFinite(o)?o:0,f=Number.isFinite(l)?l:0;return c*3600+u*60+f}function mn(t){return t.toLowerCase().replaceAll("'","").replaceAll("‘","").replaceAll("’","")}const Xn="",Ia=Xn,Ea="",Ma="",ja="",Oa="",fn={snl:{alerts:Xn,rules:Ia},schools:{alerts:Ea,rules:Ma},transit:{alerts:ja,rules:Oa}};function Oe(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ca(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Dt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Ce(t,e){const s={...e.headers,...Ca()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`,l=new Error(o);throw l.status=n.status,l}return a}function Da(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Oe(t.baseUrl,"/api/Alert"),r=Dt(n,{page:s?.pageNumber??1,pageSize:s?.pageSize??10,...s?.anomalyId!==void 0&&{anomalyId:s.anomalyId},...s?.spaceId!==void 0&&{spaceId:s.spaceId},...s?.severityName!==void 0&&{severity:s.severityName},...s?.thirdPartyIds?.length&&{thirdPartyIds:s.thirdPartyIds.join(",")},...s?.searchText&&{searchText:s.searchText},isArchived:s?.isArchived??!1}),a=await Ce(r,{method:"GET",headers:e}),o=Array.isArray(a)?a:[],l=o.length>0?o[0].totalRecords??o.length:0;return{items:o,total:l}},async getAlertStatusList(){const s=Oe(t.baseUrl,"/api/Alert/AlertStatusList"),n=await Ce(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getAlertsReport(s){const n=Oe(t.baseUrl,"/Alerts/GetAlertsReport"),r=Dt(n,s),a=await Ce(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Oe(t.baseUrl,"/api/Alert/status");return Ce(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=Oe(t.baseUrl,"/api/Alert/GetAdminSettings"),n=await Ce(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("userId"in n)return n}return null},async setAdminSettings(s){const n=Oe(t.baseUrl,"/api/Alert/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Ce(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Oe(t.baseUrl,"/api/Alert/GetPreferenceSettings"),n=await Ce(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=Oe(t.baseUrl,"/api/Alert/SetPreferenceSettings"),r=await Ce(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=Oe(t.baseUrl,"/api/Alert/GetNotifications"),r=Dt(n,{alertId:s}),a=await Ce(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=Oe(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=Dt(n,{alertId:s});return Ce(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const a=Oe(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),o=Dt(a,{alertId:s,isEmail:n,isSMS:r});return Ce(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Oe(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Ce(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Oe(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Ce(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null},async getAllSpaces(){const s=Oe(t.baseUrl,"/api/Spaces/GetAllSpaces"),n=await Ce(s,{method:"GET",headers:e});return(Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]).map(a=>({spaceId:a?.spaceId??a?.SpaceId,spaceName:a?.spaceName??a?.SpaceName??""}))}}}function hn(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ra(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function qt(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=hn(t.baseUrl,"/api/Rules"),n=hn(t.baseUrl,"/api/Rules/lookups");return{async getRules(){const r=await qt(s,{method:"GET",headers:e});return Array.isArray(r)?r:[]},async setEscalationSettings(r){return qt(s,{method:"POST",headers:e,body:JSON.stringify(r??{})})},async getLookups(){return qt(n,{method:"GET",headers:e})},async updateRule(r,a){const o=`${s}/${r}`;return qt(o,{method:"PUT",headers:e,body:JSON.stringify(a??{})})}}}function La(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ss={exports:{}},Fa=ss.exports,yn;function $a(){return yn||(yn=1,(function(t,e){(function(s,n){t.exports=n()})(Fa,(function(){var s=1e3,n=6e4,r=36e5,a="millisecond",o="second",l="minute",c="hour",u="day",f="week",m="month",S="quarter",g="year",A="date",T="Invalid Date",x=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,P=/\[([^\]]+)]|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,Y={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(j){var N=["th","st","nd","rd"],w=j%100;return"["+j+(N[(w-20)%10]||N[w]||N[0])+"]"}},J=function(j,N,w){var E=String(j);return!E||E.length>=N?j:""+Array(N+1-E.length).join(w)+j},I={s:J,z:function(j){var N=-j.utcOffset(),w=Math.abs(N),E=Math.floor(w/60),b=w%60;return(N<=0?"+":"-")+J(E,2,"0")+":"+J(b,2,"0")},m:function j(N,w){if(N.date()<w.date())return-j(w,N);var E=12*(w.year()-N.year())+(w.month()-N.month()),b=N.clone().add(E,m),D=w-b<0,C=N.clone().add(E+(D?-1:1),m);return+(-(E+(w-b)/(D?b-C:C-b))||0)},a:function(j){return j<0?Math.ceil(j)||0:Math.floor(j)},p:function(j){return{M:m,y:g,w:f,d:u,D:A,h:c,m:l,s:o,ms:a,Q:S}[j]||String(j||"").toLowerCase().replace(/s$/,"")},u:function(j){return j===void 0}},U="en",Z={};Z[U]=Y;var O="$isDayjsObject",H=function(j){return j instanceof X||!(!j||!j[O])},p=function j(N,w,E){var b;if(!N)return U;if(typeof N=="string"){var D=N.toLowerCase();Z[D]&&(b=D),w&&(Z[D]=w,b=D);var C=N.split("-");if(!b&&C.length>1)return j(C[0])}else{var G=N.name;Z[G]=N,b=G}return!E&&b&&(U=b),b||!E&&U},v=function(j,N){if(H(j))return j.clone();var w=typeof N=="object"?N:{};return w.date=j,w.args=arguments,new X(w)},M=I;M.l=p,M.i=H,M.w=function(j,N){return v(j,{locale:N.$L,utc:N.$u,x:N.$x,$offset:N.$offset})};var X=(function(){function j(w){this.$L=p(w.locale,null,!0),this.parse(w),this.$x=this.$x||w.x||{},this[O]=!0}var N=j.prototype;return N.parse=function(w){this.$d=(function(E){var b=E.date,D=E.utc;if(b===null)return new Date(NaN);if(M.u(b))return new Date;if(b instanceof Date)return new Date(b);if(typeof b=="string"&&!/Z$/i.test(b)){var C=b.match(x);if(C){var G=C[2]-1||0,q=(C[7]||"0").substring(0,3);return D?new Date(Date.UTC(C[1],G,C[3]||1,C[4]||0,C[5]||0,C[6]||0,q)):new Date(C[1],G,C[3]||1,C[4]||0,C[5]||0,C[6]||0,q)}}return new Date(b)})(w),this.init()},N.init=function(){var w=this.$d;this.$y=w.getFullYear(),this.$M=w.getMonth(),this.$D=w.getDate(),this.$W=w.getDay(),this.$H=w.getHours(),this.$m=w.getMinutes(),this.$s=w.getSeconds(),this.$ms=w.getMilliseconds()},N.$utils=function(){return M},N.isValid=function(){return this.$d.toString()!==T},N.isSame=function(w,E){var b=v(w);return this.startOf(E)<=b&&b<=this.endOf(E)},N.isAfter=function(w,E){return v(w)<this.startOf(E)},N.isBefore=function(w,E){return this.endOf(E)<v(w)},N.$g=function(w,E,b){return M.u(w)?this[E]:this.set(b,w)},N.unix=function(){return Math.floor(this.valueOf()/1e3)},N.valueOf=function(){return this.$d.getTime()},N.startOf=function(w,E){var b=this,D=!!M.u(E)||E,C=M.p(w),G=function(xe,de){var W=M.w(b.$u?Date.UTC(b.$y,de,xe):new Date(b.$y,de,xe),b);return D?W:W.endOf(u)},q=function(xe,de){return M.w(b.toDate()[xe].apply(b.toDate("s"),(D?[0,0,0,0]:[23,59,59,999]).slice(de)),b)},ee=this.$W,K=this.$M,le=this.$D,Ae="set"+(this.$u?"UTC":"");switch(C){case g:return D?G(1,0):G(31,11);case m:return D?G(1,K):G(0,K+1);case f:var ue=this.$locale().weekStart||0,fe=(ee<ue?ee+7:ee)-ue;return G(D?le-fe:le+(6-fe),K);case u:case A:return q(Ae+"Hours",0);case c:return q(Ae+"Minutes",1);case l:return q(Ae+"Seconds",2);case o:return q(Ae+"Milliseconds",3);default:return this.clone()}},N.endOf=function(w){return this.startOf(w,!1)},N.$set=function(w,E){var b,D=M.p(w),C="set"+(this.$u?"UTC":""),G=(b={},b[u]=C+"Date",b[A]=C+"Date",b[m]=C+"Month",b[g]=C+"FullYear",b[c]=C+"Hours",b[l]=C+"Minutes",b[o]=C+"Seconds",b[a]=C+"Milliseconds",b)[D],q=D===u?this.$D+(E-this.$W):E;if(D===m||D===g){var ee=this.clone().set(A,1);ee.$d[G](q),ee.init(),this.$d=ee.set(A,Math.min(this.$D,ee.daysInMonth())).$d}else G&&this.$d[G](q);return this.init(),this},N.set=function(w,E){return this.clone().$set(w,E)},N.get=function(w){return this[M.p(w)]()},N.add=function(w,E){var b,D=this;w=Number(w);var C=M.p(E),G=function(K){var le=v(D);return M.w(le.date(le.date()+Math.round(K*w)),D)};if(C===m)return this.set(m,this.$M+w);if(C===g)return this.set(g,this.$y+w);if(C===u)return G(1);if(C===f)return G(7);var q=(b={},b[l]=n,b[c]=r,b[o]=s,b)[C]||1,ee=this.$d.getTime()+w*q;return M.w(ee,this)},N.subtract=function(w,E){return this.add(-1*w,E)},N.format=function(w){var E=this,b=this.$locale();if(!this.isValid())return b.invalidDate||T;var D=w||"YYYY-MM-DDTHH:mm:ssZ",C=M.z(this),G=this.$H,q=this.$m,ee=this.$M,K=b.weekdays,le=b.months,Ae=b.meridiem,ue=function(de,W,L,ie){return de&&(de[W]||de(E,D))||L[W].slice(0,ie)},fe=function(de){return M.s(G%12||12,de,"0")},xe=Ae||function(de,W,L){var ie=de<12?"AM":"PM";return L?ie.toLowerCase():ie};return D.replace(P,(function(de,W){return W||(function(L){switch(L){case"YY":return String(E.$y).slice(-2);case"YYYY":return M.s(E.$y,4,"0");case"M":return ee+1;case"MM":return M.s(ee+1,2,"0");case"MMM":return ue(b.monthsShort,ee,le,3);case"MMMM":return ue(le,ee);case"D":return E.$D;case"DD":return M.s(E.$D,2,"0");case"d":return String(E.$W);case"dd":return ue(b.weekdaysMin,E.$W,K,2);case"ddd":return ue(b.weekdaysShort,E.$W,K,3);case"dddd":return K[E.$W];case"H":return String(G);case"HH":return M.s(G,2,"0");case"h":return fe(1);case"hh":return fe(2);case"a":return xe(G,q,!0);case"A":return xe(G,q,!1);case"m":return String(q);case"mm":return M.s(q,2,"0");case"s":return String(E.$s);case"ss":return M.s(E.$s,2,"0");case"SSS":return M.s(E.$ms,3,"0");case"Z":return C}return null})(de)||C.replace(":","")}))},N.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},N.diff=function(w,E,b){var D,C=this,G=M.p(E),q=v(w),ee=(q.utcOffset()-this.utcOffset())*n,K=this-q,le=function(){return M.m(C,q)};switch(G){case g:D=le()/12;break;case m:D=le();break;case S:D=le()/3;break;case f:D=(K-ee)/6048e5;break;case u:D=(K-ee)/864e5;break;case c:D=K/r;break;case l:D=K/n;break;case o:D=K/s;break;default:D=K}return b?D:M.a(D)},N.daysInMonth=function(){return this.endOf(m).$D},N.$locale=function(){return Z[this.$L]},N.locale=function(w,E){if(!w)return this.$L;var b=this.clone(),D=p(w,E,!0);return D&&(b.$L=D),b},N.clone=function(){return M.w(this.$d,this)},N.toDate=function(){return new Date(this.valueOf())},N.toJSON=function(){return this.isValid()?this.toISOString():null},N.toISOString=function(){return this.$d.toISOString()},N.toString=function(){return this.$d.toUTCString()},j})(),pe=X.prototype;return v.prototype=pe,[["$ms",a],["$s",o],["$m",l],["$H",c],["$W",u],["$M",m],["$y",g],["$D",A]].forEach((function(j){pe[j[1]]=function(N){return this.$g(N,j[0],j[1])}})),v.extend=function(j,N){return j.$i||(j(N,X,v),j.$i=!0),v},v.locale=p,v.isDayjs=H,v.unix=function(j){return v(1e3*j)},v.en=Z[U],v.Ls=Z,v.p={},v}))})(ss)),ss.exports}var Pa=$a();const Wa=La(Pa);function er(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 tr(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 pn(t){const{hours:e,minutes:s,seconds:n}=tr(t);return Wa().hour(e).minute(s).second(n).millisecond(0)}function De(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ba(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Gt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Re(t,e){const s={...e.headers,...Ba()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.Message||`HTTP ${n.status}`;throw new Error(o)}return a}const ce=(...t)=>t.find(e=>e!=null);function Ut(t,e,s={}){const n={};for(const r of e){const a=s[r]??r.charAt(0).toUpperCase()+r.slice(1);n[r]=t?.[a]??t?.[r]}return n}function Va(t){return Array.isArray(t)?t.map(e=>Ut(e,["alertLogId","alertId","status","description","actionNotes","createdDate","createdBy","modifiedDate","modifiedBy"])):t}function Za(t){return{id:String(ce(t?.AlertId,t?.alertId)??""),alertNumber:ce(t?.AlertNumber,t?.alertNumber),priority:ce(t?.Priority,t?.priority,"Low"),timestamp:ce(t?.UpdatedUtc,t?.timestamp,""),statusType:ce(t?.Status,t?.statusType,""),description:ce(t?.Description,t?.description,""),eventName:ce(t?.EventName,t?.eventName),ruleName:ce(t?.RuleName,t?.ruleName),spaceId:ce(t?.SpaceId,t?.spaceId),spaceName:ce(t?.SpaceName,t?.spaceName),anomalyId:ce(t?.AnomalyId,t?.anomalyId),severityId:ce(t?.SeverityId,t?.severityId),assignTeam:ce(t?.AssignTeam,t?.assignTeam),cameraName:ce(t?.CameraName,t?.cameraName),type:ce(t?.Type,t?.type),mediaDetails:ce(t?.MediaDetails,t?.mediaDetails,t?.MediaUrls,t?.mediaUrls),additionalMedia:ce(t?.AdditionalMedia,t?.additionalMedia),timeElapsed:ce(t?.TimeElapsed,t?.timeElapsed),timeRemaining:ce(t?.TimeRemaining,t?.timeRemaining),anomalyName:ce(t?.AnomalyName,t?.anomalyName),alertDetails:ce(t?.AlertDetails,t?.alertDetails),statusHistory:Va(ce(t?.StatusHistory,t?.statusHistory)),isEmailSent:ce(t?.IsEmailSent,t?.isEmailSent),isSMSSent:ce(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:ce(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function za(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts"),r=Gt(n,{customerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",pageSize:s?.pageSize??10,page:s?.pageNumber??1,...s?.anomalyId!==void 0&&{anomalyId:s.anomalyId},...s?.spaceId!==void 0&&{spaceId:s.spaceId},...s?.severityId!==void 0&&{severityId:s.severityId},...s?.thirdPartyIds?.length&&{ThirdPartyIds:s.thirdPartyIds.join(",")},...s?.searchText&&{searchText:s.searchText},isArchived:s?.isArchived??!1}),a=await Re(r,{method:"GET",headers:e});return{items:Array.isArray(a?.Items)?a.Items.map(Za):[],total:a?.Total}},async getAlertStatusList(){const s=De(t.baseUrl,"/api/detectionpolicy/alerts/StatusList"),n=await Re(s,{method:"GET",headers:e});return(Array.isArray(n)?n:[]).map(a=>Ut(a,["alertStatusId","value","statusName"]))},async getAlertsReport(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),r=Gt(n,s),a=await Re(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/Log"),r={AlertId:s.alertId??s.alertUniqueId??s.AlertId,Status:s.status??s.Status??"",Notes:s.notes??s.Notes??""};return Re(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getAdminSettings(){const s=De(t.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),n=await Re(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n.Data??n;if(r&&typeof r=="object")return Ut(r,["userId","isAdminSetting","sortBy"],{sortBy:"SortOption"})}return null},async setAdminSettings(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/SetAdminSettings"),r={Settings:{UserId:0,IsAdminSetting:!0,SortOption:s?.sortBy??"",GroupBy:s?.groupBy??null}};return Re(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=De(t.baseUrl,"/api/detectionpolicy/alerts/GetPreferenceSettings"),n=await Re(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),r=u=>{const{hours:f,minutes:m,seconds:S}=tr(u);return(f*3600+m*60+S)*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 Re(n,{method:"POST",headers:e,body:JSON.stringify(a)}),l=o?.responseStatus??!0,c=o?.data??o?.message??"Preferences updated successfully.";return{responseStatus:l,errorMessage:l?"":o?.errorMessage??o?.Message??o?.message??"",statusCode:200,data:c}},async sendSMSorEmailNotifications(s,n,r){const a=De(t.baseUrl,"/api/detectionpolicy/alerts/SendSMSorEmailNotifications"),o=Gt(a,{alertId:s,isEmail:n,isSMS:r});return Re(o,{method:"POST",headers:e})},async getAlertNotifications(s){const n=De(t.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),r=Gt(n,{alertId:s}),a=await Re(r,{method:"GET",headers:e});let o=[];return Array.isArray(a)?o=a:Array.isArray(a?.data)&&(o=a.data),o.map(l=>Ut(l,["alertNotificationSentId","alertId","notificationType","receipientName","receipentPhoneNumber","messageSID","messageStatus","receipientEmail","notificationReceipientType","sentAt"]))},async getTimeZoneMasters(){const s=De(t.baseUrl,"/api/TimeZoneMaster"),n=await Re(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n.Data:[]).map(a=>Ut(a,["timeZoneUniqueId","ianaTimeZoneId","timeZoneName","offset"]))},async getAllSpaces(){const s=t.spacesBaseUrl||t.baseUrl,n=De(s,"/api/AllSpaces"),r=await Re(n,{method:"GET",headers:e});return(Array.isArray(r?.Data)?r.Data:[]).map(o=>({spaceId:o?.SpaceId??o?.spaceId,spaceName:o?.SpaceName??o?.spaceName??""}))},async getMyAppPreferences(){const s=De(t.baseUrl,"/MyProfile"),n=await Re(s,{method:"GET",headers:e}),r=n?.data?.userGuid??n?.Data?.userGuid??n?.userGuid;if(!r)return null;const a=De(t.baseUrl,`/api/GetMyAppPreferences/${r}`),o=await Re(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 Ha(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Qe(t,e){const s={...e.headers,...Ha()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function qa(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/api/detectionpolicy/rules",t.baseUrl).toString();return{async getRules(){const n=await Qe(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n?.Data:[]).map(a=>({...a,ruleId:a.ruleId??a.RuleId,ruleName:a.ruleName??a.RuleName??a.Name,escalationSettings:a.escalationSettings??a.EscalationSettings}))},async setEscalationSettings(n){return Qe(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=p=>new URL(p,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[Qe(n("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:e}),Qe(n("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:e}),Qe(n("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:e}),Qe(n("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:e}),Qe(n("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:e}),Qe(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,l,c,u,f,m]=await Promise.allSettled(a),S=p=>{if(p.status!=="fulfilled")return[];const v=p.value;return Array.isArray(v)?v:Array.isArray(v?.Data)?v.Data:Array.isArray(v?.data)?v.data:[]},g=S(o),A=S(l),T=S(c),x=S(u),P=S(f),Y=m.status==="fulfilled"?m.value:null;let J=[];Array.isArray(Y)?J=Y:Array.isArray(Y?.Data)?J=Y.Data:Array.isArray(Y?.data)&&(J=Y.data);const I=g.map(p=>({actionTypeId:Number(p?.ActionTypeId),name:p?.DisplayName??p?.Name??""})),U=A.map(p=>({recordId:p?.AnomalyId,anomalyName:p?.DisplayName??p?.Name??""})),Z=T.map(p=>({thirdPartyId:Number(p?.ThirdPartyId),thirdPartyName:p?.ThirdPartyName??p?.Name??""})),O=J.map(p=>({userRoleId:p.UserRoleId??p.userRoleId??p.Id??p.id??0,userRoleName:p.UserRoleName??p.userRoleName??p.Name??p.name??""})),H={actionTypes:I,anomalies:U,thirdParties:Z};return x.length&&(H.severities=x.map(p=>({severityId:p?.SeverityId??p?.severityId,severityName:p?.DisplayName??p?.SeverityName??p?.Name??p?.name??""}))),P.length&&(H.scheduleTypes=P),O.length&&(H.userRoles=O),H},async updateRule(n,r){const a=`${s}/${n}`,{escalationSettings:o,Anomaly:l,Severity:c,...u}=r??{};return Qe(a,{method:"PUT",headers:e,body:JSON.stringify({...u,CustomerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",Version:{DeDupWindowSeconds:0,IncludeSubjectInHash:!0},AnomalyId:l?.AnomalyId,SeverityId:c?.SeverityId,EscalationSettings:o?{...o,ThirdPartyIds:o.thirdPartyId??[]}:{}})})}}}function Ga(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function st(t,e){const s={...e.headers,...Ga()},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 Ya(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/list-rule",t.baseUrl).toString();return{async getRules(){const n=await st(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 st(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=O=>new URL(O,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[st(n("/api/ActionTypeMaster/GetAll"),{method:"GET",headers:e}),st(n("/api/anomaly/anomaly-list"),{method:"POST",headers:e,body:JSON.stringify({RuleLevel:1})}),st(n("/api/Lookup/ThirdParties"),{method:"GET",headers:e}),st(n("/api/anomaly/severity-list"),{method:"GET",headers:e}),st(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,l,c,u,f]=await Promise.allSettled(a),m=O=>{if(O.status!=="fulfilled")return[];const H=O.value;return Array.isArray(H)?H:Array.isArray(H?.data)?H.data:[]},S=m(o),g=m(l),A=m(c),T=m(u),x=f.status==="fulfilled"?f.value:null,P=S.map(O=>({actionTypeId:O?.ActionTypeUniqueId,name:O?.Name??""})),Y=g.map(O=>({recordId:O?.AnomalyId,anomalyName:O?.DisplayName??O?.Name??""})),J=A.map(O=>({thirdPartyId:Number(O?.ThirdPartyId),thirdPartyName:O?.ThirdPartyName??O?.Name??""}));let I=[];Array.isArray(x)?I=x:Array.isArray(x?.Data)?I=x.Data:Array.isArray(x?.data)&&(I=x.data);const U=I.map(O=>({userRoleId:O.userRoleId??0,userRoleName:O.userRoleName??""})),Z={actionTypes:P,anomalies:Y,thirdParties:J};return T.length&&(Z.severities=T.map(O=>({SeverityId:O.SeverityId,DisplayName:O.SeverityName??O.DisplayName??""}))),U.length&&(Z.userRoles=U),Z},async updateRule(n,r){const a=new URL("/update-rule",t.baseUrl).toString(),{escalationSettings:o,ruleId:l,ruleName:c,ruleDesc:u,...f}=r??{},m=o??{},S=(m.escalationSettingsActionTypeIds??[]).filter(A=>A!=null&&!Number.isNaN(A)),g={Level1UserRoleId:m.level1UserRoleId??0,Level1PostAssistTime:m.level1PostAssistTime??0,Level2UserRoleId:m.level2UserRoleId??0,Level2PostAssistTime:m.level2PostAssistTime??0,Level3UserRoleId:m.level3UserRoleId??0,Level3PostAssistTime:m.level3PostAssistTime??0,EscalationSettingsActionTypeIds:S,ThirdPartyIds:m.thirdPartyId??[],HumanLoop:m.humanLoop??!1};return st(a,{method:"POST",headers:e,body:JSON.stringify({...f,RuleId:l??f.RuleId??n,RuleName:c??f.RuleName,RuleDesc:u??f.RuleDesc??null,ActionTypeUniqueIdList:S,EscalationSettings:g})})}}}function Pe(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 Yt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function We(t,e){const s={...e.headers,..._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 Ja(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Pe(t.baseUrl,"/api/Alerts"),r=Yt(n,{pageSize:s?.pageSize??10,pageNumber:s?.pageNumber??1,...s?.spaceNumber!==void 0&&{spaceNumber:s.spaceNumber},...s?.anomalyId!==void 0&&{anomalyId:s.anomalyId},...s?.severityId!==void 0&&{severityId:s.severityId},...s?.thirdPartyIds?.length&&{thirdPartyIds:s.thirdPartyIds.join(",")},...s?.isArchived!==void 0&&{isArchived:s.isArchived}}),a=await We(r,{method:"GET",headers:e});if(Array.isArray(a))return a;if(a&&typeof a=="object"){if(Array.isArray(a.items))return{items:a.items,total:typeof a.total=="number"?a.total:void 0};if(Array.isArray(a.data))return{items:a.data,total:typeof a.total=="number"?a.total:void 0};if(Array.isArray(a.alerts))return{items:a.alerts,total:typeof a.total=="number"?a.total:void 0}}return[]},async getAlertStatusList(){const s=Pe(t.baseUrl,"/api/Alerts/GetAlertStatus"),n=await We(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getAlertsReport(s){const n=Pe(t.baseUrl,"/Alerts/GetAlertsReport"),r=Yt(n,s),a=await We(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Pe(t.baseUrl,"/api/Alerts/UpdateAlertLog"),r={alertId:s.alertId,action:s.status,notes:s.notes};return We(n,{method:"PUT",headers:e,body:JSON.stringify(r??{})})},async getAdminSettings(){const s=Pe(t.baseUrl,"/api/Alerts/GetAdminSettings"),n=await We(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("userId"in n)return n}return null},async setAdminSettings(s){const n=Pe(t.baseUrl,"/api/Alerts/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return We(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Pe(t.baseUrl,"/api/Alerts/GetPreferenceSettings"),n=await We(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=Pe(t.baseUrl,"/api/Alerts/SetPreferenceSettings"),r=await We(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,o=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":r?.errorMessage??r?.message??"",statusCode:200,data:o}},async getAlertNotifications(s){const n=Pe(t.baseUrl,"/api/Alerts/GetNotifications"),r=Yt(n,{alertId:s}),a=await We(r,{method:"GET",headers:e});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]},async sendSMSorEmailNotifications(s,n,r){const a=Pe(t.baseUrl,"/api/Alerts/SendSMSorEmailNotifications"),o=Yt(a,{alertId:s,isEmail:n,isSMS:r});return We(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Pe(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await We(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Pe(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await We(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null}}}const sr=d.createContext(null);function nr({tenant:t="snl",override:e,timeZone:s,userManagementDomain:n,spacesBaseUrl:r,children:a}){const o=d.useMemo(()=>{const c=e?.alertsBaseUrl?.trim()||fn[t]?.alerts||"";let u=e?.rulesBaseUrl?.trim()||fn[t]?.rules||"";t==="snl"&&(u=c);const f=e?.headers;return{tenant:t,alertsBaseUrl:c,rulesBaseUrl:u,headers:f,timeZone:s,userManagementDomain:n,spacesBaseUrl:r}},[t,e?.alertsBaseUrl,e?.rulesBaseUrl,JSON.stringify(e?.headers||{}),s,n,r]),l=d.useMemo(()=>{const c={baseUrl:o.alertsBaseUrl,headers:o.headers},u={baseUrl:o.rulesBaseUrl,headers:o.headers},f={schools:()=>za({...c,spacesBaseUrl:o.spacesBaseUrl}),transit:()=>Ja(c),snl:()=>Da(c)},m={schools:()=>qa({...u,userManagementBaseUrl:o.userManagementDomain}),transit:()=>Ya({...u,userManagementBaseUrl:o.userManagementDomain}),snl:()=>Ua({baseUrl:o.alertsBaseUrl,headers:o.headers})};return{config:o,alerts:f[o.tenant](),rules:m[o.tenant]()}},[o]);return i.jsx(sr.Provider,{value:l,children:a})}function Ue(){const t=d.useContext(sr);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}const Ka={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Qa={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Js=6,Ks=7;function gn(t,e,s){const n=t===Js,r=t===Ks,a=e.isEmailSent??!1,o=e.isSMSSent??!1,l=n&&a||r&&o,c=n?"Send Email":r?"Send SMS":s,u=n&&a?"Email sent":r&&o?"SMS sent":c,f=n&&a?"Email sent":r&&o?"SMS sent":`Click to ${c}`;return{isDisabled:l,buttonText:u,tooltipTitle:f}}function Ns(t,e){return`${t}-${e?"email":"sms"}`}function _t(t){return t===Js||t===Ks}function ds({value:t,onChange:e,options:s,className:n,dropdownWidth:r}){return i.jsx(h.Select,{className:n,options:s,value:t,onChange:e,dropdownMatchSelectWidth:r??260})}const Xa=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function ei({value:t,onChange:e,options:s}){return i.jsx(ds,{className:"w-[140px]",value:t,onChange:e,options:s||Xa})}const ti=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function si({value:t,onChange:e,options:s}){return i.jsx(ds,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||ti})}function ni({value:t,onChange:e,options:s}){return i.jsx(ds,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const ri=[{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 ai({value:t,onChange:e,options:s}){return i.jsx(ds,{className:"w-[130px]",value:t,onChange:e,options:s||ri})}function rr({columns:t,data:e,loading:s=!1,pageSize:n=10,total:r,currentPage:a,rowKey:o="id",toolbar:l,tableProps:c,onPageChange:u}){const m=r===void 0&&a!==void 0?e.length===n?a*n+1:(a-1)*n+e.length:void 0;return i.jsxs("div",{children:[l,i.jsx(h.Table,{rowKey:o,dataSource:e,columns:t,loading:s,pagination:{pageSize:n,current:a,total:r??m,showSizeChanger:!1,showTotal:S=>`Total: ${S}`,onChange:u},bordered:!0,...c})]})}function ii(t){if(!t||typeof t!="string")return!1;const e=t.split("?")[0].toLowerCase();return e.endsWith(".mp4")||e.endsWith(".webm")||e.endsWith(".ogg")||e.endsWith(".m3u8")}function Fs(t){const e=(t?.mediaType||t?.type||"").toString().toLowerCase();return e==="video"||e==="mp4"?!0:ii(t?.mediaUrl||t)}function oi(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 ar(t){const e=t;return e?(Array.isArray(e)?e:[e]).flatMap(oi):[]}const li=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ci=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),Sn=t=>{const e=ci(t);return e.charAt(0).toUpperCase()+e.slice(1)},ir=(...t)=>t.filter((e,s,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===s).join(" ").trim(),ui=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var di={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 mi=d.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:a,iconNode:o,...l},c)=>d.createElement("svg",{ref:c,...di,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:ir("lucide",r),...!a&&!ui(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,f])=>d.createElement(u,f)),...Array.isArray(a)?a:[a]]));const ms=(t,e)=>{const s=d.forwardRef(({className:n,...r},a)=>d.createElement(mi,{ref:a,iconNode:e,className:ir(`lucide-${li(Sn(t))}`,`lucide-${t}`,n),...r}));return s.displayName=Sn(t),s};const fi=[["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"}]],or=ms("image-off",fi);const hi=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],yi=ms("loader-circle",hi);const pi=[["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"}]],lr=ms("maximize-2",pi);const gi=[["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"}]],Si=ms("minimize-2",gi),nt=16,rt=2,xn={Low:"#22c55e",Medium:"#fde047",High:"#fb2c36",Critical:"#7a0707"};function cr({boxes:t,priority:e="High"}){const s=xn[e]??xn.High;return i.jsx(i.Fragment,{children:t.map((n,r)=>i.jsxs("div",{className:"absolute pointer-events-none",style:{left:n.x,top:n.y,width:n.width,height:n.height},children:[i.jsx("div",{className:"absolute left-0 whitespace-nowrap rounded-sm px-2 py-1 text-[10px] font-semibold text-white",style:{backgroundColor:s,transform:"translateY(-100%)"},children:n.label}),i.jsx("div",{className:"absolute top-0 left-0",style:{width:nt,height:nt,borderTop:`${rt}px solid ${s}`,borderLeft:`${rt}px solid ${s}`}}),i.jsx("div",{className:"absolute top-0 right-0",style:{width:nt,height:nt,borderTop:`${rt}px solid ${s}`,borderRight:`${rt}px solid ${s}`}}),i.jsx("div",{className:"absolute bottom-0 left-0",style:{width:nt,height:nt,borderBottom:`${rt}px solid ${s}`,borderLeft:`${rt}px solid ${s}`}}),i.jsx("div",{className:"absolute bottom-0 right-0",style:{width:nt,height:nt,borderBottom:`${rt}px solid ${s}`,borderRight:`${rt}px solid ${s}`}})]},`${n.label}-${r}`))})}const xi=t=>{if(!t)return[0,0,0,0];if(typeof t=="string")return t.replace(/[()[\]\s]/g,"").split(",").map(Number);if(!Array.isArray(t)||t.length===0)return[0,0,0,0];const e=t[0];return typeof e=="string"?e.replace(/[()[\]\s]/g,"").split(",").map(Number):Array.isArray(e)?e.map(Number):t.map(Number)},ur=(t,e,s,n,r)=>{if(!e||!s||!n||!r)return[];const a=n/e,o=r/s;return t.flatMap(l=>{const[c,u,f,m]=xi(l.bbox_xyxy);return c>e||f>e||u>s||m>s?[]:[{personName:l.personName,x:c*a,y:u*o,width:(f-c)*a,height:(m-u)*o}]})},vn={naturalWidth:0,naturalHeight:0,renderedWidth:0,renderedHeight:0};function dr(){const t=d.useRef(null),[e,s]=d.useState(vn),n=d.useCallback(()=>{const a=t.current;a&&s({naturalWidth:a.naturalWidth,naturalHeight:a.naturalHeight,renderedWidth:a.offsetWidth,renderedHeight:a.offsetHeight})},[]),r=d.useCallback(()=>{s(vn)},[]);return{imageRef:t,dimensions:e,onLoad:n,resetDimensions:r}}const mr=({isOpen:t,onClose:e,src:s,type:n="image",detections:r=[],priority:a})=>{const[o,l]=d.useState(!1),[c,u]=d.useState(!1),{imageRef:f,dimensions:m,onLoad:S,resetDimensions:g}=dr(),A=d.useMemo(()=>ur(r,m.naturalWidth,m.naturalHeight,m.renderedWidth,m.renderedHeight),[r,m]),T=d.useMemo(()=>A.map(x=>({...x,label:x.personName||""})),[A]);return d.useEffect(()=>{t&&(u(!1),g())},[t,s,g]),d.useEffect(()=>{t&&(!s||c)&&e()},[t,s,c,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:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),e())},onTouchStart:e,children:i.jsxs("div",{className:`relative ${o?"w-full h-full":"max-w-5xl max-h-[90vh] w-full"} flex items-center justify-center`,onClick:x=>x.stopPropagation(),children:[n==="image"?i.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[i.jsx("img",{ref:f,src:s,alt:"preview",className:`object-contain rounded-lg shadow-lg ${o?"w-full h-full":"max-w-full max-h-[90vh]"}`,onLoad:S,onError:()=>u(!0)}),i.jsx(cr,{boxes:T,priority:a})]}):i.jsx("video",{src:s,controls:!0,className:`object-contain rounded-lg shadow-lg ${o?"w-full h-full":"max-w-full max-h-[90vh]"}`,onError:()=>u(!0)}),i.jsx("button",{onClick:e,className:"absolute top-3 right-8 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:"✕"}),i.jsx("button",{onClick:()=>l(!o),className:"absolute bottom-3 right-8 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:o?i.jsx(Si,{size:20}):i.jsx(lr,{size:20})})]})}):null};function vi(t){const s=ar(t.mediaDetails)[0];if(!s)return null;const n=s.mediaUrl??s;return typeof n!="string"||!n.length?null:{url:n,item:s}}function fr({record:t}){const e=d.useMemo(()=>vi(t),[t]),[s,n]=d.useState(!1),[r,a]=d.useState(!1),o=d.useMemo(()=>t.bbox_xyxy?[{bbox_xyxy:t.bbox_xyxy,personName:t.personName}]:[],[t.bbox_xyxy,t.personName]);if(d.useEffect(()=>{a(!1)},[e?.url]),!e)return i.jsx("span",{className:"text-gray-400 text-sm",children:"—"});const{url:l,item:c}=e,u=Fs(c),f=u?"video":"image",m="block w-[72px] h-[54px] object-cover bg-gray-100 border border-gray-200 rounded-sm";return i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",disabled:r,className:"p-0 border-0 bg-transparent rounded-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-1 cursor-pointer disabled:cursor-not-allowed disabled:opacity-60","aria-label":r?"Preview unavailable":"Expand preview",onClick:()=>n(!0),children:r?i.jsx("span",{className:`${m} flex items-center justify-center text-gray-400`,children:i.jsx(or,{size:20,"aria-hidden":!0})}):u?i.jsx("video",{src:l,className:m,muted:!0,playsInline:!0,preload:"metadata",onError:()=>a(!0)}):i.jsx("img",{src:l,alt:"",className:m,onError:()=>a(!0)})}),i.jsx(mr,{isOpen:s,onClose:()=>n(!1),src:l,type:f,detections:o,priority:t.priority})]})}function wi(t,e){const[s,n]=d.useState(t);return d.useEffect(()=>{const r=window.setTimeout(()=>n(t),e);return()=>window.clearTimeout(r)},[t,e]),s}function Qs({data:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,columns:a,renderActions:o,onAlertIdClick:l,onRefetch:c,onPageChange:u,onFilterChange:f,resetKey:m}){const[S,g]=d.useState("All"),[A,T]=d.useState("All"),[x,P]=d.useState("All"),[Y,J]=d.useState("All"),[I,U]=d.useState(""),[Z,O]=d.useState(r??1);d.useEffect(()=>{m!==void 0&&(g("All"),T("All"),P("All"),J("All"),U(""),O(1))},[m]),d.useEffect(()=>{r!==void 0&&O(r)},[r]);const[H,p]=d.useState([{label:"All",value:"All"}]),[v,M]=d.useState([]),[X,pe]=d.useState([]),[j,N]=d.useState([]),[w,E]=d.useState(new Set),{rules:b,alerts:D,config:C}=Ue(),G=C.tenant==="schools",q=C.tenant==="transit",ee=wi(I,600),K=G&&ee.trim()?100:s,le={6:{title:"Email",kind:"icon",icon:i.jsx(yt.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:i.jsx(yt.MessageOutlined,{})}};d.useEffect(()=>{if(!D.getAllSpaces)return;let W=!0;return(async()=>{try{const L=await D.getAllSpaces();if(W){const ie=L.map(oe=>({label:q?String(oe.spaceNumber??oe.spaceName??""):oe.spaceName,value:String(q?oe.spaceNumber??oe.spaceId:oe.spaceId)}));M([{label:"All",value:"All"},...ie])}}catch(L){console.error("Error loading space options",L)}})(),()=>{W=!1}},[D,q]),d.useEffect(()=>{let W=!0;return(async()=>{try{const L=await b.getLookups(),oe=(Array.isArray(L.thirdParties)?L.thirdParties:[]).map(Ne=>({label:Ne.thirdPartyName,value:String(Ne.thirdPartyId)})),be=(Array.isArray(L.anomalies)?L.anomalies:[]).map(Ne=>({label:Ne.anomalyName,value:Ne.anomalyId})),Le=(Array.isArray(L.severities)?L.severities:[]).map(Ne=>({label:Ne.severityName,value:String(Ne.severityId)}));W&&(p([{label:"All",value:"All"},...oe]),be.length&&pe([{label:"All Types",value:"All"},...be]),Le.length&&N([{label:"All levels",value:"All"},...Le]))}catch(L){console.error("Error loading filter options",L)}})(),()=>{W=!1}},[b]),d.useEffect(()=>{if(!f)return;const W=j.find(ie=>ie.value===S),L={anomalyId:X.length>1&&A!=="All"?A:void 0,spaceId:!q&&v.length>1&&x!=="All"?x:void 0,spaceNumber:q&&v.length>1&&x!=="All"?x:void 0,severityId:j.length>1&&S!=="All"?S:void 0,severityName:j.length>1&&S!=="All"?W?.label:void 0,thirdPartyIds:Y==="All"?void 0:[Number(Y)],searchText:ee.trim()||void 0};f(L),u?.(1)},[A,x,S,Y,ee,X.length,v.length,j.length,q,G]);const Ae=X.length>1?X:void 0,ue=v.length>1?v:void 0,fe=j.length>1?j:void 0,xe=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:W=>i.jsx(h.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Qa[W]}`,backgroundColor:Ka[W]},children:W})},{title:"Tracker",key:"tracker",width:140,render:(W,L)=>i.jsx("a",{onClick:ie=>{ie.preventDefault(),l?.(L,{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:(W,L)=>{if(o)return i.jsx(i.Fragment,{children:o(L)});const ie=async(Fe,xt)=>{const vt=Ns(L.id,Fe);E(ve=>new Set(ve).add(vt));try{const ve=await D.sendSMSorEmailNotifications?.(L.id,Fe,xt);ve?.responseStatus||ve?.Success||ve?.success?(we.toast.success(ve?.message||ve.data||(Fe?"Email sent successfully":"SMS sent successfully")),c?.()):we.toast.error(ve?.message||ve?.data||ve?.errorMessage||"Failed to send notification")}catch(ve){we.toast.error(ve?.message||"Failed to send notification")}finally{E(ve=>{const Ct=new Set(ve);return Ct.delete(vt),Ct})}},oe=Js,Te=Ks,be=le[oe],Ke=le[Te],Le=gn(oe,L,be?.title),Ne=gn(Te,L,Ke?.title),ct=Ns(L.id,!0),ut=Ns(L.id,!1),St=_t(oe)&&w.has(ct),dt=_t(Te)&&w.has(ut);return i.jsxs(h.Space,{size:"middle",children:[i.jsx(h.Tooltip,{title:Le.tooltipTitle,children:i.jsx(h.Button,{size:"small",disabled:Le.isDisabled,loading:St,onClick:_t(oe)?()=>ie(!0,!1):void 0,icon:!St&&be?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:Le.buttonText})},String(oe)),i.jsx(h.Tooltip,{title:Ne.tooltipTitle,children:i.jsx(h.Button,{size:"small",disabled:Ne.isDisabled,loading:dt,onClick:_t(Te)?()=>ie(!1,!0):void 0,icon:!dt&&Ke?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:Ne.buttonText})},String(Te))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(W,L)=>{const ie=L?.timeElapsed,oe=L?.timeRemaining,Te=ie?dn(ie):0,be=oe?dn(oe):0,Ke=Math.round(Te/(Te+be)*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:ie??"-"})]}),i.jsx(h.Progress,{percent:Ke,showInfo:!1,size:"small",strokeColor:ka(L.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:oe??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(W,L)=>i.jsxs("div",{children:[i.jsx("a",{onClick:ie=>{ie.preventDefault(),l?.(L,{sourceTab:"active"})},className:"inline-block mb-1 text-blue-600",children:L.alertNumber}),i.jsx("div",{className:"text-black/65",children:W})]})},{title:"Preview",key:"preview",width:100,align:"center",render:(W,L)=>i.jsx(fr,{record:L})}],de=a&&a.length?a:xe;return i.jsx("div",{children:i.jsx(rr,{rowKey:"id",data:t,columns:de,loading:e,pageSize:K,total:n,currentPage:Z,onPageChange:u,toolbar:i.jsxs(h.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[i.jsx(h.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Severity"}),i.jsx(ei,{value:S,onChange:g,options:fe})]})}),i.jsx(h.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Anomaly type"}),i.jsx(si,{value:A,onChange:T,options:Ae})]})}),i.jsx(h.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:q?"Bus Number":"Space"}),i.jsx(ni,{value:x,onChange:P,options:ue})]})}),i.jsx(h.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Action Taken"}),i.jsx(ai,{value:Y,onChange:J,options:H})]})}),i.jsx(h.Col,{flex:"auto"}),i.jsx(h.Col,{flex:"none",children:i.jsx(h.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:U,onChange:W=>U(W.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}const Ai=["completed","false positive","face doesn't match name","safe","supervised exit","elopement confirmed"];function Xs(){const{alerts:t}=Ue(),e=pt.useQueryClient();return pt.useMutation({mutationFn:s=>t.updateAlertStatus(s),onSuccess:()=>{e.invalidateQueries({queryKey:["alerts","list"]}),e.invalidateQueries({queryKey:["alerts","report"]})}})}class gt extends Error{}class Ti extends gt{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class bi extends gt{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class Ni extends gt{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class bt extends gt{}class hr extends gt{constructor(e){super(`Invalid unit ${e}`)}}class ke extends gt{}class at extends gt{constructor(){super("Zone is an abstract class")}}const k="numeric",_e="short",$e="long",is={year:k,month:k,day:k},yr={year:k,month:_e,day:k},ki={year:k,month:_e,day:k,weekday:_e},pr={year:k,month:$e,day:k},gr={year:k,month:$e,day:k,weekday:$e},Sr={hour:k,minute:k},xr={hour:k,minute:k,second:k},vr={hour:k,minute:k,second:k,timeZoneName:_e},wr={hour:k,minute:k,second:k,timeZoneName:$e},Ar={hour:k,minute:k,hourCycle:"h23"},Tr={hour:k,minute:k,second:k,hourCycle:"h23"},br={hour:k,minute:k,second:k,hourCycle:"h23",timeZoneName:_e},Nr={hour:k,minute:k,second:k,hourCycle:"h23",timeZoneName:$e},kr={year:k,month:k,day:k,hour:k,minute:k},Ir={year:k,month:k,day:k,hour:k,minute:k,second:k},Er={year:k,month:_e,day:k,hour:k,minute:k},Mr={year:k,month:_e,day:k,hour:k,minute:k,second:k},Ii={year:k,month:_e,day:k,weekday:_e,hour:k,minute:k},jr={year:k,month:$e,day:k,hour:k,minute:k,timeZoneName:_e},Or={year:k,month:$e,day:k,hour:k,minute:k,second:k,timeZoneName:_e},Cr={year:k,month:$e,day:k,weekday:$e,hour:k,minute:k,timeZoneName:$e},Dr={year:k,month:$e,day:k,weekday:$e,hour:k,minute:k,second:k,timeZoneName:$e};class Bt{get type(){throw new at}get name(){throw new at}get ianaName(){return this.name}get isUniversal(){throw new at}offsetName(e,s){throw new at}formatOffset(e,s){throw new at}offset(e){throw new at}equals(e){throw new at}get isValid(){throw new at}}let ks=null;class fs extends Bt{static get instance(){return ks===null&&(ks=new fs),ks}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return zr(e,s,n)}formatOffset(e,s){return Pt(this.offset(e),s)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}}const $s=new Map;function Ei(t){let e=$s.get(t);return e===void 0&&(e=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),$s.set(t,e)),e}const Mi={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function ji(t,e){const s=t.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(s),[,r,a,o,l,c,u,f]=n;return[o,r,a,l,c,u,f]}function Oi(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:a,value:o}=s[r],l=Mi[a];a==="era"?n[l]=o:$(l)||(n[l]=parseInt(o,10))}return n}const Is=new Map;class tt extends Bt{static create(e){let s=Is.get(e);return s===void 0&&Is.set(e,s=new tt(e)),s}static resetCache(){Is.clear(),$s.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch{return!1}}constructor(e){super(),this.zoneName=e,this.valid=tt.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return zr(e,s,n,this.name)}formatOffset(e,s){return Pt(this.offset(e),s)}offset(e){if(!this.valid)return NaN;const s=new Date(e);if(isNaN(s))return NaN;const n=Ei(this.name);let[r,a,o,l,c,u,f]=n.formatToParts?Oi(n,s):ji(n,s);l==="BC"&&(r=-Math.abs(r)+1);const S=ys({year:r,month:a,day:o,hour:c===24?0:c,minute:u,second:f,millisecond:0});let g=+s;const A=g%1e3;return g-=A>=0?A:1e3+A,(S-g)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let wn={};function Ci(t,e={}){const s=JSON.stringify([t,e]);let n=wn[s];return n||(n=new Intl.ListFormat(t,e),wn[s]=n),n}const Ps=new Map;function Ws(t,e={}){const s=JSON.stringify([t,e]);let n=Ps.get(s);return n===void 0&&(n=new Intl.DateTimeFormat(t,e),Ps.set(s,n)),n}const Bs=new Map;function Di(t,e={}){const s=JSON.stringify([t,e]);let n=Bs.get(s);return n===void 0&&(n=new Intl.NumberFormat(t,e),Bs.set(s,n)),n}const Vs=new Map;function Ri(t,e={}){const{base:s,...n}=e,r=JSON.stringify([t,n]);let a=Vs.get(r);return a===void 0&&(a=new Intl.RelativeTimeFormat(t,e),Vs.set(r,a)),a}let Lt=null;function Ui(){return Lt||(Lt=new Intl.DateTimeFormat().resolvedOptions().locale,Lt)}const Zs=new Map;function Rr(t){let e=Zs.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),Zs.set(t,e)),e}const zs=new Map;function Li(t){let e=zs.get(t);if(!e){const s=new Intl.Locale(t);e="getWeekInfo"in s?s.getWeekInfo():s.weekInfo,"minimalDays"in e||(e={...Ur,...e}),zs.set(t,e)}return e}function Fi(t){const e=t.indexOf("-x-");e!==-1&&(t=t.substring(0,e));const s=t.indexOf("-u-");if(s===-1)return[t];{let n,r;try{n=Ws(t).resolvedOptions(),r=t}catch{const c=t.substring(0,s);n=Ws(c).resolvedOptions(),r=c}const{numberingSystem:a,calendar:o}=n;return[r,a,o]}}function $i(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function Pi(t){const e=[];for(let s=1;s<=12;s++){const n=F.utc(2009,s,1);e.push(t(n))}return e}function Wi(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 Jt(t,e,s,n){const r=t.listingMode();return r==="error"?null:r==="en"?s(e):n(e)}function Bi(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||Rr(t.locale).numberingSystem==="latn"}class Vi{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=Di(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):rn(e,3);return ge(s,this.padTo)}}}class Zi{constructor(e,s,n){this.opts=n,this.originalZone=void 0;let r;if(this.opts.timeZone)this.dt=e;else if(e.zone.type==="fixed"){const o=-1*(e.offset/60),l=o>=0?`Etc/GMT+${o}`:`Etc/GMT${o}`;e.offset!==0&&tt.create(l).valid?(r=l,this.dt=e):(r="UTC",this.dt=e.offset===0?e:e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type==="system"?this.dt=e:e.zone.type==="iana"?(this.dt=e,r=e.zone.name):(r="UTC",this.dt=e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone);const a={...this.opts};a.timeZone=a.timeZone||r,this.dtf=Ws(s,a)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(s=>{if(s.type==="timeZoneName"){const n=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...s,value:n}}else return s}):e}resolvedOptions(){return this.dtf.resolvedOptions()}}class zi{constructor(e,s,n){this.opts={style:"long",...n},!s&&Vr()&&(this.rtf=Ri(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):fo(s,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,s){return this.rtf?this.rtf.formatToParts(e,s):[]}}const Ur={firstDay:1,minimalDays:4,weekend:[6,7]};class ae{static fromOpts(e){return ae.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,s,n,r,a=!1){const o=e||ye.defaultLocale,l=o||(a?"en-US":Ui()),c=s||ye.defaultNumberingSystem,u=n||ye.defaultOutputCalendar,f=qs(r)||ye.defaultWeekSettings;return new ae(l,c,u,f,o)}static resetCache(){Lt=null,Ps.clear(),Bs.clear(),Vs.clear(),Zs.clear(),zs.clear()}static fromObject({locale:e,numberingSystem:s,outputCalendar:n,weekSettings:r}={}){return ae.create(e,s,n,r)}constructor(e,s,n,r,a){const[o,l,c]=Fi(e);this.locale=o,this.numberingSystem=s||l||null,this.outputCalendar=n||c||null,this.weekSettings=r,this.intl=$i(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=Bi(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:ae.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,qs(e.weekSettings)||this.weekSettings,e.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,s=!1){return Jt(this,e,Gr,()=>{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]=Pi(o)}return this.monthsCache[a][e]})}weekdays(e,s=!1){return Jt(this,e,Jr,()=>{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]=Wi(a=>this.extract(a,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return Jt(this,void 0,()=>Kr,()=>{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 Jt(this,e,Qr,()=>{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 Vi(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new Zi(e,this.intl,s)}relFormatter(e={}){return new zi(this.intl,this.isEnglish(),e)}listFormatter(e={}){return Ci(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||Rr(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:Zr()?Li(this.locale):Ur}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let Es=null;class Me extends Bt{static get utcInstance(){return Es===null&&(Es=new Me(0)),Es}static instance(e){return e===0?Me.utcInstance:new Me(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new Me(ps(s[1],s[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Pt(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Pt(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,s){return Pt(this.fixed,s)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type==="fixed"&&e.fixed===this.fixed}get isValid(){return!0}}class Hi extends Bt{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 ot(t,e){if($(t)||t===null)return e;if(t instanceof Bt)return t;if(Ki(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?fs.instance:s==="utc"||s==="gmt"?Me.utcInstance:Me.parseSpecifier(s)||tt.create(t)}else return lt(t)?Me.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new Hi(t)}const en={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},An={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]},qi=en.hanidec.replace(/[\[|\]]/g,"").split("");function Gi(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(en.hanidec)!==-1)e+=qi.indexOf(t[s]);else for(const r in An){const[a,o]=An[r];n>=a&&n<=o&&(e+=n-a)}}return parseInt(e,10)}else return e}const Hs=new Map;function Yi(){Hs.clear()}function qe({numberingSystem:t},e=""){const s=t||"latn";let n=Hs.get(s);n===void 0&&(n=new Map,Hs.set(s,n));let r=n.get(e);return r===void 0&&(r=new RegExp(`${en[s]}${e}`),n.set(e,r)),r}let Tn=()=>Date.now(),bn="system",Nn=null,kn=null,In=null,En=60,Mn,jn=null;class ye{static get now(){return Tn}static set now(e){Tn=e}static set defaultZone(e){bn=e}static get defaultZone(){return ot(bn,fs.instance)}static get defaultLocale(){return Nn}static set defaultLocale(e){Nn=e}static get defaultNumberingSystem(){return kn}static set defaultNumberingSystem(e){kn=e}static get defaultOutputCalendar(){return In}static set defaultOutputCalendar(e){In=e}static get defaultWeekSettings(){return jn}static set defaultWeekSettings(e){jn=qs(e)}static get twoDigitCutoffYear(){return En}static set twoDigitCutoffYear(e){En=e%100}static get throwOnInvalid(){return Mn}static set throwOnInvalid(e){Mn=e}static resetCaches(){ae.resetCache(),tt.resetCache(),F.resetCache(),Yi()}}class Ye{constructor(e,s){this.reason=e,this.explanation=s}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const Lr=[0,31,59,90,120,151,181,212,243,273,304,334],Fr=[0,31,60,91,121,152,182,213,244,274,305,335];function Ve(t,e){return new Ye("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function tn(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 $r(t,e,s){return s+(Vt(t)?Fr:Lr)[e-1]}function Pr(t,e){const s=Vt(t)?Fr:Lr,n=s.findIndex(a=>a<e),r=e-s[n];return{month:n+1,day:r}}function sn(t,e){return(t-e+7)%7+1}function os(t,e=4,s=1){const{year:n,month:r,day:a}=t,o=$r(n,r,a),l=sn(tn(n,r,a),s);let c=Math.floor((o-l+14-e)/7),u;return c<1?(u=n-1,c=Wt(u,e,s)):c>Wt(n,e,s)?(u=n+1,c=1):u=n,{weekYear:u,weekNumber:c,weekday:l,...gs(t)}}function On(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:a}=t,o=sn(tn(n,1,e),s),l=Nt(n);let c=r*7+a-o-7+e,u;c<1?(u=n-1,c+=Nt(u)):c>l?(u=n+1,c-=Nt(n)):u=n;const{month:f,day:m}=Pr(u,c);return{year:u,month:f,day:m,...gs(t)}}function Ms(t){const{year:e,month:s,day:n}=t,r=$r(e,s,n);return{year:e,ordinal:r,...gs(t)}}function Cn(t){const{year:e,ordinal:s}=t,{month:n,day:r}=Pr(e,s);return{year:e,month:n,day:r,...gs(t)}}function Dn(t,e){if(!$(t.localWeekday)||!$(t.localWeekNumber)||!$(t.localWeekYear)){if(!$(t.weekday)||!$(t.weekNumber)||!$(t.weekYear))throw new bt("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 _i(t,e=4,s=1){const n=hs(t.weekYear),r=Ze(t.weekNumber,1,Wt(t.weekYear,e,s)),a=Ze(t.weekday,1,7);return n?r?a?!1:Ve("weekday",t.weekday):Ve("week",t.weekNumber):Ve("weekYear",t.weekYear)}function Ji(t){const e=hs(t.year),s=Ze(t.ordinal,1,Nt(t.year));return e?s?!1:Ve("ordinal",t.ordinal):Ve("year",t.year)}function Wr(t){const e=hs(t.year),s=Ze(t.month,1,12),n=Ze(t.day,1,ls(t.year,t.month));return e?s?n?!1:Ve("day",t.day):Ve("month",t.month):Ve("year",t.year)}function Br(t){const{hour:e,minute:s,second:n,millisecond:r}=t,a=Ze(e,0,23)||e===24&&s===0&&n===0&&r===0,o=Ze(s,0,59),l=Ze(n,0,59),c=Ze(r,0,999);return a?o?l?c?!1:Ve("millisecond",r):Ve("second",n):Ve("minute",s):Ve("hour",e)}function $(t){return typeof t>"u"}function lt(t){return typeof t=="number"}function hs(t){return typeof t=="number"&&t%1===0}function Ki(t){return typeof t=="string"}function Qi(t){return Object.prototype.toString.call(t)==="[object Date]"}function Vr(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function Zr(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function Xi(t){return Array.isArray(t)?t:[t]}function Rn(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 eo(t,e){return e.reduce((s,n)=>(s[n]=t[n],s),{})}function It(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function qs(t){if(t==null)return null;if(typeof t!="object")throw new ke("Week settings must be an object");if(!Ze(t.firstDay,1,7)||!Ze(t.minimalDays,1,7)||!Array.isArray(t.weekend)||t.weekend.some(e=>!Ze(e,1,7)))throw new ke("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function Ze(t,e,s){return hs(t)&&t>=e&&t<=s}function to(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 it(t){if(!($(t)||t===null||t===""))return parseInt(t,10)}function mt(t){if(!($(t)||t===null||t===""))return parseFloat(t)}function nn(t){if(!($(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function rn(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 Vt(t){return t%4===0&&(t%100!==0||t%400===0)}function Nt(t){return Vt(t)?366:365}function ls(t,e){const s=to(e-1,12)+1,n=t+(e-s)/12;return s===2?Vt(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][s-1]}function ys(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 Un(t,e,s){return-sn(tn(t,1,e),s)+e-1}function Wt(t,e=4,s=1){const n=Un(t,e,s),r=Un(t+1,e,s);return(Nt(t)-n+r)/7}function Gs(t){return t>99?t:t>ye.twoDigitCutoffYear?1900+t:2e3+t}function zr(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 ps(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 Hr(t){const e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new ke(`Invalid unit value ${t}`);return e}function cs(t,e){const s={};for(const n in t)if(It(t,n)){const r=t[n];if(r==null)continue;s[e(n)]=Hr(r)}return s}function Pt(t,e){const s=Math.trunc(Math.abs(t/60)),n=Math.trunc(Math.abs(t%60)),r=t>=0?"+":"-";switch(e){case"short":return`${r}${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 gs(t){return eo(t,["hour","minute","second","millisecond"])}const so=["January","February","March","April","May","June","July","August","September","October","November","December"],qr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],no=["J","F","M","A","M","J","J","A","S","O","N","D"];function Gr(t){switch(t){case"narrow":return[...no];case"short":return[...qr];case"long":return[...so];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 Yr=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],_r=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],ro=["M","T","W","T","F","S","S"];function Jr(t){switch(t){case"narrow":return[...ro];case"short":return[..._r];case"long":return[...Yr];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const Kr=["AM","PM"],ao=["Before Christ","Anno Domini"],io=["BC","AD"],oo=["B","A"];function Qr(t){switch(t){case"narrow":return[...oo];case"short":return[...io];case"long":return[...ao];default:return null}}function lo(t){return Kr[t.hour<12?0:1]}function co(t,e){return Jr(e)[t.weekday-1]}function uo(t,e){return Gr(e)[t.month-1]}function mo(t,e){return Qr(e)[t.year<0?0:1]}function fo(t,e,s="always",n=!1){const r={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},a=["hours","minutes","seconds"].indexOf(t)===-1;if(s==="auto"&&a){const m=t==="days";switch(e){case 1:return m?"tomorrow":`next ${r[t][0]}`;case-1:return m?"yesterday":`last ${r[t][0]}`;case 0:return m?"today":`this ${r[t][0]}`}}const o=Object.is(e,-0)||e<0,l=Math.abs(e),c=l===1,u=r[t],f=n?c?u[1]:u[2]||u[1]:c?r[t][0]:t;return o?`${l} ${f} ago`:`in ${l} ${f}`}function Ln(t,e){let s="";for(const n of t)n.literal?s+=n.val:s+=e(n.val);return s}const ho={D:is,DD:yr,DDD:pr,DDDD:gr,t:Sr,tt:xr,ttt:vr,tttt:wr,T:Ar,TT:Tr,TTT:br,TTTT:Nr,f:kr,ff:Er,fff:jr,ffff:Cr,F:Ir,FF:Mr,FFF:Or,FFFF:Dr};class Ie{static create(e,s={}){return new Ie(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 ho[e]}constructor(e,s){this.opts=s,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,s){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...s}).format()}dtFormatter(e,s={}){return this.loc.dtFormatter(e,{...this.opts,...s})}formatDateTime(e,s){return this.dtFormatter(e,s).format()}formatDateTimeParts(e,s){return this.dtFormatter(e,s).formatToParts()}formatInterval(e,s){return this.dtFormatter(e.start,s).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,s){return this.dtFormatter(e,s).resolvedOptions()}num(e,s=0,n=void 0){if(this.opts.forceSimple)return ge(e,s);const r={...this.opts};return s>0&&(r.padTo=s),n&&(r.signDisplay=n),this.loc.numberFormatter(r).format(e)}formatDateTimeFromString(e,s){const n=this.loc.listingMode()==="en",r=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",a=(g,A)=>this.loc.extract(e,g,A),o=g=>e.isOffsetFixed&&e.offset===0&&g.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,g.format):"",l=()=>n?lo(e):a({hour:"numeric",hourCycle:"h12"},"dayperiod"),c=(g,A)=>n?uo(e,g):a(A?{month:g}:{month:g,day:"numeric"},"month"),u=(g,A)=>n?co(e,g):a(A?{weekday:g}:{weekday:g,month:"long",day:"numeric"},"weekday"),f=g=>{const A=Ie.macroTokenToFormatOpts(g);return A?this.formatWithSystemDefault(e,A):g},m=g=>n?mo(e,g):a({era:g},"era"),S=g=>{switch(g){case"S":return this.num(e.millisecond);case"u":case"SSS":return this.num(e.millisecond,3);case"s":return this.num(e.second);case"ss":return this.num(e.second,2);case"uu":return this.num(Math.floor(e.millisecond/10),2);case"uuu":return this.num(Math.floor(e.millisecond/100));case"m":return this.num(e.minute);case"mm":return this.num(e.minute,2);case"h":return this.num(e.hour%12===0?12:e.hour%12);case"hh":return this.num(e.hour%12===0?12:e.hour%12,2);case"H":return this.num(e.hour);case"HH":return this.num(e.hour,2);case"Z":return o({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return o({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return o({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return l();case"d":return r?a({day:"numeric"},"day"):this.num(e.day);case"dd":return r?a({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return u("short",!0);case"cccc":return u("long",!0);case"ccccc":return u("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return u("short",!1);case"EEEE":return u("long",!1);case"EEEEE":return u("narrow",!1);case"L":return r?a({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?a({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return c("short",!0);case"LLLL":return c("long",!0);case"LLLLL":return c("narrow",!0);case"M":return r?a({month:"numeric"},"month"):this.num(e.month);case"MM":return r?a({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return c("short",!1);case"MMMM":return c("long",!1);case"MMMMM":return c("narrow",!1);case"y":return r?a({year:"numeric"},"year"):this.num(e.year);case"yy":return r?a({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?a({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?a({year:"numeric"},"year"):this.num(e.year,6);case"G":return m("short");case"GG":return m("long");case"GGGGG":return m("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return f(g)}};return Ln(Ie.parseFormat(s),S)}formatDurationFromString(e,s){const n=this.opts.signMode==="negativeLargestOnly"?-1:1,r=f=>{switch(f[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},a=(f,m)=>S=>{const g=r(S);if(g){const A=m.isNegativeDuration&&g!==m.largestUnit?n:1;let T;return this.opts.signMode==="negativeLargestOnly"&&g!==m.largestUnit?T="never":this.opts.signMode==="all"?T="always":T="auto",this.num(f.get(g)*A,S.length,T)}else return S},o=Ie.parseFormat(s),l=o.reduce((f,{literal:m,val:S})=>m?f:f.concat(S),[]),c=e.shiftTo(...l.map(r).filter(f=>f)),u={isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]};return Ln(o,a(c,u))}}const Xr=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Et(...t){const e=t.reduce((s,n)=>s+n.source,"");return RegExp(`^${e}$`)}function Mt(...t){return e=>t.reduce(([s,n,r],a)=>{const[o,l,c]=a(e,r);return[{...s,...o},l||n,c]},[{},null,1]).slice(0,2)}function jt(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 ea(...t){return(e,s)=>{const n={};let r;for(r=0;r<t.length;r++)n[t[r]]=it(e[s+r]);return[n,null,s+r]}}const ta=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,yo=`(?:${ta.source}?(?:\\[(${Xr.source})\\])?)?`,an=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,sa=RegExp(`${an.source}${yo}`),on=RegExp(`(?:[Tt]${sa.source})?`),po=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,go=/(\d{4})-?W(\d\d)(?:-?(\d))?/,So=/(\d{4})-?(\d{3})/,xo=ea("weekYear","weekNumber","weekDay"),vo=ea("year","ordinal"),wo=/(\d{4})-(\d\d)-(\d\d)/,na=RegExp(`${an.source} ?(?:${ta.source}|(${Xr.source}))?`),Ao=RegExp(`(?: ${na.source})?`);function kt(t,e,s){const n=t[e];return $(n)?s:it(n)}function To(t,e){return[{year:kt(t,e),month:kt(t,e+1,1),day:kt(t,e+2,1)},null,e+3]}function Ot(t,e){return[{hours:kt(t,e,0),minutes:kt(t,e+1,0),seconds:kt(t,e+2,0),milliseconds:nn(t[e+3])},null,e+4]}function Zt(t,e){const s=!t[e]&&!t[e+1],n=ps(t[e+1],t[e+2]),r=s?null:Me.instance(n);return[{},r,e+3]}function zt(t,e){const s=t[e]?tt.create(t[e]):null;return[{},s,e+1]}const bo=RegExp(`^T?${an.source}$`),No=/^-?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 ko(t){const[e,s,n,r,a,o,l,c,u]=t,f=e[0]==="-",m=c&&c[0]==="-",S=(g,A=!1)=>g!==void 0&&(A||g&&f)?-g:g;return[{years:S(mt(s)),months:S(mt(n)),weeks:S(mt(r)),days:S(mt(a)),hours:S(mt(o)),minutes:S(mt(l)),seconds:S(mt(c),c==="-0"),milliseconds:S(nn(u),m)}]}const Io={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function ln(t,e,s,n,r,a,o){const l={year:e.length===2?Gs(it(e)):it(e),month:qr.indexOf(s)+1,day:it(n),hour:it(r),minute:it(a)};return o&&(l.second=it(o)),t&&(l.weekday=t.length>3?Yr.indexOf(t)+1:_r.indexOf(t)+1),l}const Eo=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function Mo(t){const[,e,s,n,r,a,o,l,c,u,f,m]=t,S=ln(e,r,n,s,a,o,l);let g;return c?g=Io[c]:u?g=0:g=ps(f,m),[S,new Me(g)]}function jo(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const Oo=/^(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$/,Co=/^(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$/,Do=/^(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 Fn(t){const[,e,s,n,r,a,o,l]=t;return[ln(e,r,n,s,a,o,l),Me.utcInstance]}function Ro(t){const[,e,s,n,r,a,o,l]=t;return[ln(e,l,s,n,r,a,o),Me.utcInstance]}const Uo=Et(po,on),Lo=Et(go,on),Fo=Et(So,on),$o=Et(sa),ra=Mt(To,Ot,Zt,zt),Po=Mt(xo,Ot,Zt,zt),Wo=Mt(vo,Ot,Zt,zt),Bo=Mt(Ot,Zt,zt);function Vo(t){return jt(t,[Uo,ra],[Lo,Po],[Fo,Wo],[$o,Bo])}function Zo(t){return jt(jo(t),[Eo,Mo])}function zo(t){return jt(t,[Oo,Fn],[Co,Fn],[Do,Ro])}function Ho(t){return jt(t,[No,ko])}const qo=Mt(Ot);function Go(t){return jt(t,[bo,qo])}const Yo=Et(wo,Ao),_o=Et(na),Jo=Mt(Ot,Zt,zt);function Ko(t){return jt(t,[Yo,ra],[_o,Jo])}const $n="Invalid Duration",aa={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}},Qo={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},...aa},Be=146097/400,wt=146097/4800,Xo={years:{quarters:4,months:12,weeks:Be/7,days:Be,hours:Be*24,minutes:Be*24*60,seconds:Be*24*60*60,milliseconds:Be*24*60*60*1e3},quarters:{months:3,weeks:Be/28,days:Be/4,hours:Be*24/4,minutes:Be*24*60/4,seconds:Be*24*60*60/4,milliseconds:Be*24*60*60*1e3/4},months:{weeks:wt/7,days:wt,hours:wt*24,minutes:wt*24*60,seconds:wt*24*60*60,milliseconds:wt*24*60*60*1e3},...aa},ht=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],el=ht.slice(0).reverse();function Xe(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 ia(t,e){let s=e.milliseconds??0;for(const n of el.slice(1))e[n]&&(s+=e[n]*t[n].milliseconds);return s}function Pn(t,e){const s=ia(t,e)<0?-1:1;ht.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),ht.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 Wn(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?Xo:Qo;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||ae.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 ke(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new Q({values:cs(e,Q.normalizeUnit),loc:ae.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(lt(e))return Q.fromMillis(e);if(Q.isDuration(e))return e;if(typeof e=="object")return Q.fromObject(e);throw new ke(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,s){const[n]=Ho(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]=Go(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 ke("need to specify a reason the Duration is invalid");const n=e instanceof Ye?e:new Ye(e,s);if(ye.throwOnInvalid)throw new Ni(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 hr(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?Ie.create(this.loc,n).formatDurationFromString(this,e):$n}toHuman(e={}){if(!this.isValid)return $n;const s=e.showZeros!==!1,n=ht.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+=rn(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?ia(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 ht)(It(s.values,r)||It(this.values,r))&&(n[r]=s.get(r)+this.get(r));return Xe(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]=Hr(e(this.values[n],n));return Xe(this,{values:s},!0)}get(e){return this[Q.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const s={...this.values,...cs(e,Q.normalizeUnit)};return Xe(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 Xe(this,o)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return Pn(this.matrix,e),Xe(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=Wn(this.normalize().shiftToAll().toObject());return Xe(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 ht)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;lt(r[o])&&(l+=r[o]);const c=Math.trunc(l);s[o]=c,n[o]=(l*1e3-c*1e3)/1e3}else lt(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 Pn(this.matrix,s),Xe(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 Xe(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=Wn(this.values);return Xe(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 ht)if(!s(this.values[n],e.values[n]))return!1;return!0}}const At="Invalid Interval";function tl(t,e){return!t||!t.isValid?he.invalid("missing or invalid start"):!e||!e.isValid?he.invalid("missing or invalid end"):e<t?he.invalid("end before start",`The end of an interval must be after its start, but you had start=${t.toISO()} and end=${e.toISO()}`):null}class he{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,s=null){if(!e)throw new ke("need to specify a reason the Interval is invalid");const n=e instanceof Ye?e:new Ye(e,s);if(ye.throwOnInvalid)throw new bi(n);return new he({invalid:n})}static fromDateTimes(e,s){const n=Rt(e),r=Rt(s),a=tl(n,r);return a??new he({start:n,end:r})}static after(e,s){const n=Q.fromDurationLike(s),r=Rt(e);return he.fromDateTimes(r,r.plus(n))}static before(e,s){const n=Q.fromDurationLike(s),r=Rt(e);return he.fromDateTimes(r.minus(n),r)}static fromISO(e,s){const[n,r]=(e||"").split("/",2);if(n&&r){let a,o;try{a=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 he.fromDateTimes(a,l);if(o){const u=Q.fromISO(r,s);if(u.isValid)return he.after(a,u)}else if(c){const u=Q.fromISO(n,s);if(u.isValid)return he.before(l,u)}}return he.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(e).get(e):NaN}count(e="milliseconds",s){if(!this.isValid)return NaN;const n=this.start.startOf(e,s);let r;return s?.useLocaleWeeks?r=this.end.reconfigure({locale:n.locale}):r=this.end,r=r.startOf(e,s),Math.floor(r.diff(n,e).get(e))+(r.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:e,end:s}={}){return this.isValid?he.fromDateTimes(e||this.s,s||this.e):this}splitAt(...e){if(!this.isValid)return[];const s=e.map(Rt).filter(o=>this.contains(o)).sort((o,l)=>o.toMillis()-l.toMillis()),n=[];let{s:r}=this,a=0;for(;r<this.e;){const o=s[a]||this.e,l=+o>+this.e?this.e:o;n.push(he.fromDateTimes(r,l)),r=l,a+=1}return n}splitBy(e){const s=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(he.fromDateTimes(n,a)),n=a,r+=1}return o}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;const s=this.s>e.s?this.s:e.s,n=this.e<e.e?this.e:e.e;return s>=n?null:he.fromDateTimes(s,n)}union(e){if(!this.isValid)return this;const s=this.s<e.s?this.s:e.s,n=this.e>e.e?this.e:e.e;return he.fromDateTimes(s,n)}static merge(e){const[s,n]=e.sort((r,a)=>r.s-a.s).reduce(([r,a],o)=>a?a.overlaps(o)||a.abutsStart(o)?[r,a.union(o)]:[r.concat([a]),o]:[r,o],[[],null]);return n&&s.push(n),s}static xor(e){let s=null,n=0;const r=[],a=e.map(c=>[{time:c.s,type:"s"},{time:c.e,type:"e"}]),o=Array.prototype.concat(...a),l=o.sort((c,u)=>c.time-u.time);for(const c of l)n+=c.type==="s"?1:-1,n===1?s=c.time:(s&&+s!=+c.time&&r.push(he.fromDateTimes(s,c.time)),s=null);return he.merge(r)}difference(...e){return he.xor([this].concat(e)).map(s=>this.intersection(s)).filter(s=>s&&!s.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:At}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=is,s={}){return this.isValid?Ie.create(this.s.loc.clone(s),e).formatInterval(this):At}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:At}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:At}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:At}toFormat(e,{separator:s=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${s}${this.e.toFormat(e)}`:At}toDuration(e,s){return this.isValid?this.e.diff(this.s,e,s):Q.invalid(this.invalidReason)}mapEndpoints(e){return he.fromDateTimes(e(this.s),e(this.e))}}class Kt{static hasDST(e=ye.defaultZone){const s=F.now().setZone(e).set({month:12});return!e.isUniversal&&s.offset!==s.set({month:6}).offset}static isValidIANAZone(e){return tt.isValidZone(e)}static normalizeZone(e){return ot(e,ye.defaultZone)}static getStartOfWeek({locale:e=null,locObj:s=null}={}){return(s||ae.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:s=null}={}){return(s||ae.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:s=null}={}){return(s||ae.create(e)).getWeekendDays().slice()}static months(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||ae.create(s,n,a)).months(e)}static monthsFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||ae.create(s,n,a)).months(e,!0)}static weekdays(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||ae.create(s,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||ae.create(s,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return ae.create(e).meridiems()}static eras(e="short",{locale:s=null}={}){return ae.create(s,null,"gregory").eras(e)}static features(){return{relative:Vr(),localeWeek:Zr()}}}function Bn(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 sl(t,e,s){const n=[["years",(c,u)=>u.year-c.year],["quarters",(c,u)=>u.quarter-c.quarter+(u.year-c.year)*4],["months",(c,u)=>u.month-c.month+(u.year-c.year)*12],["weeks",(c,u)=>{const f=Bn(c,u);return(f-f%7)/7}],["days",Bn]],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 nl(t,e,s,n){let[r,a,o,l]=sl(t,e,s);const c=e-r,u=s.filter(m=>["hours","minutes","seconds","milliseconds"].indexOf(m)>=0);u.length===0&&(o<e&&(o=r.plus({[l]:1})),o!==r&&(a[l]=(a[l]||0)+c/(o-r)));const f=Q.fromObject(a,n);return u.length>0?Q.fromMillis(c,n).shiftTo(...u).plus(f):f}const rl="missing Intl.DateTimeFormat.formatToParts support";function se(t,e=s=>s){return{regex:t,deser:([s])=>e(Gi(s))}}const al=" ",oa=`[ ${al}]`,la=new RegExp(oa,"g");function il(t){return t.replace(/\./g,"\\.?").replace(la,oa)}function Vn(t){return t.replace(/\./g,"").replace(la," ").toLowerCase()}function Ge(t,e){return t===null?null:{regex:RegExp(t.map(il).join("|")),deser:([s])=>t.findIndex(n=>Vn(s)===Vn(n))+e}}function Zn(t,e){return{regex:t,deser:([,s,n])=>ps(s,n),groups:e}}function Qt(t){return{regex:t,deser:([e])=>e}}function ol(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function ll(t,e){const s=qe(e),n=qe(e,"{2}"),r=qe(e,"{3}"),a=qe(e,"{4}"),o=qe(e,"{6}"),l=qe(e,"{1,2}"),c=qe(e,"{1,3}"),u=qe(e,"{1,6}"),f=qe(e,"{1,9}"),m=qe(e,"{2,4}"),S=qe(e,"{4,6}"),g=x=>({regex:RegExp(ol(x.val)),deser:([P])=>P,literal:!0}),T=(x=>{if(t.literal)return g(x);switch(x.val){case"G":return Ge(e.eras("short"),0);case"GG":return Ge(e.eras("long"),0);case"y":return se(u);case"yy":return se(m,Gs);case"yyyy":return se(a);case"yyyyy":return se(S);case"yyyyyy":return se(o);case"M":return se(l);case"MM":return se(n);case"MMM":return Ge(e.months("short",!0),1);case"MMMM":return Ge(e.months("long",!0),1);case"L":return se(l);case"LL":return se(n);case"LLL":return Ge(e.months("short",!1),1);case"LLLL":return Ge(e.months("long",!1),1);case"d":return se(l);case"dd":return se(n);case"o":return se(c);case"ooo":return se(r);case"HH":return se(n);case"H":return se(l);case"hh":return se(n);case"h":return se(l);case"mm":return se(n);case"m":return se(l);case"q":return se(l);case"qq":return se(n);case"s":return se(l);case"ss":return se(n);case"S":return se(c);case"SSS":return se(r);case"u":return Qt(f);case"uu":return Qt(l);case"uuu":return se(s);case"a":return Ge(e.meridiems(),0);case"kkkk":return se(a);case"kk":return se(m,Gs);case"W":return se(l);case"WW":return se(n);case"E":case"c":return se(s);case"EEE":return Ge(e.weekdays("short",!1),1);case"EEEE":return Ge(e.weekdays("long",!1),1);case"ccc":return Ge(e.weekdays("short",!0),1);case"cccc":return Ge(e.weekdays("long",!0),1);case"Z":case"ZZ":return Zn(new RegExp(`([+-]${l.source})(?::(${n.source}))?`),2);case"ZZZ":return Zn(new RegExp(`([+-]${l.source})(${n.source})?`),2);case"z":return Qt(/[a-z_+-/]{1,256}?/i);case" ":return Qt(/[^\S\n\r]/);default:return g(x)}})(t)||{invalidReason:rl};return T.token=t,T}const cl={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 ul(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=cl[o];if(typeof l=="object"&&(l=l[a]),l)return{literal:!1,val:l}}function dl(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function ml(t,e,s){const n=t.match(e);if(n){const r={};let a=1;for(const o in s)if(It(s,o)){const l=s[o],c=l.groups?l.groups+1:1;!l.literal&&l.token&&(r[l.token.val[0]]=l.deser(n.slice(a,a+c))),a+=c}return[n,r]}else return[n,{}]}function fl(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=tt.create(t.z)),$(t.Z)||(s||(s=new Me(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=nn(t.u)),[Object.keys(t).reduce((a,o)=>{const l=e(o);return l&&(a[l]=t[o]),a},{}),s,n]}let js=null;function hl(){return js||(js=F.fromMillis(1555555555555)),js}function yl(t,e){if(t.literal)return t;const s=Ie.macroTokenToFormatOpts(t.val),n=ma(s,e);return n==null||n.includes(void 0)?t:n}function ca(t,e){return Array.prototype.concat(...t.map(s=>yl(s,e)))}class ua{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=ca(Ie.parseFormat(s),e),this.units=this.tokens.map(n=>ll(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=dl(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=ml(e,this.regex,this.handlers),[r,a,o]=n?fl(n):[null,null,void 0];if(It(n,"a")&&It(n,"H"))throw new bt("Can't include meridiem when specifying 24-hour format");return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:s,matches:n,result:r,zone:a,specificOffset:o}}else return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function da(t,e,s){return new ua(t,s).explainFromTokens(e)}function pl(t,e,s){const{result:n,zone:r,specificOffset:a,invalidReason:o}=da(t,e,s);return[n,r,a,o]}function ma(t,e){if(!t)return null;const n=Ie.create(e,t).dtFormatter(hl()),r=n.formatToParts(),a=n.resolvedOptions();return r.map(o=>ul(o,t,a))}const Os="Invalid DateTime",zn=864e13;function Ft(t){return new Ye("unsupported zone",`the zone "${t.name}" is not supported`)}function Cs(t){return t.weekData===null&&(t.weekData=os(t.c)),t.weekData}function Ds(t){return t.localWeekData===null&&(t.localWeekData=os(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function ft(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 fa(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 Xt(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 ns(t,e,s){return fa(ys(t),e,s)}function Hn(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,ls(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=ys(a);let[c,u]=fa(l,s,t.zone);return o!==0&&(c+=o,u=t.zone.offset(c)),{ts:c,o:u}}function Tt(t,e,s,n,r,a){const{setZone:o,zone:l}=s;if(t&&Object.keys(t).length!==0||e){const c=e||l,u=F.fromObject(t,{...s,zone:c,specificOffset:a});return o?u:u.setZone(l)}else return F.invalid(new Ye("unparsable",`the input "${r}" can't be parsed as ${n}`))}function es(t,e,s=!0){return t.isValid?Ie.create(ae.create("en-US"),{allowZ:s,forceSimple:!0}).formatDateTimeFromString(t,e):null}function Rs(t,e,s){const n=t.c.year>9999||t.c.year<0;let r="";if(n&&t.c.year>=0&&(r+="+"),r+=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 qn(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 ha={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},gl={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},Sl={ordinal:1,hour:0,minute:0,second:0,millisecond:0},rs=["year","month","day","hour","minute","second","millisecond"],xl=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],vl=["year","ordinal","hour","minute","second","millisecond"];function as(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 hr(t);return e}function Gn(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return as(t)}}function wl(t){if($t===void 0&&($t=ye.now()),t.type!=="iana")return t.offset($t);const e=t.name;let s=Ys.get(e);return s===void 0&&(s=t.offset($t),Ys.set(e,s)),s}function Yn(t,e){const s=ot(e.zone,ye.defaultZone);if(!s.isValid)return F.invalid(Ft(s));const n=ae.fromObject(e);let r,a;if($(t.year))r=ye.now();else{for(const c of rs)$(t[c])&&(t[c]=ha[c]);const o=Wr(t)||Br(t);if(o)return F.invalid(o);const l=wl(s);[r,a]=ns(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=rn(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 Jn(t){let e={},s;return t.length>0&&typeof t[t.length-1]=="object"?(e=t[t.length-1],s=Array.from(t).slice(0,t.length-1)):s=Array.from(t),[e,s]}let $t;const Ys=new Map;class F{constructor(e){const s=e.zone||ye.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Ye("invalid input"):null)||(s.isValid?null:Ft(s));this.ts=$(e.ts)?ye.now():e.ts;let r=null,a=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(s))[r,a]=[e.old.c,e.old.o];else{const l=lt(e.o)&&!e.old?e.o:s.offset(this.ts);r=Xt(this.ts,l),n=Number.isNaN(r.year)?new Ye("invalid input"):null,r=n?null:r,a=n?null:l}this._zone=s,this.loc=e.loc||ae.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]=Jn(arguments),[n,r,a,o,l,c,u]=s;return Yn({year:n,month:r,day:a,hour:o,minute:l,second:c,millisecond:u},e)}static utc(){const[e,s]=Jn(arguments),[n,r,a,o,l,c,u]=s;return e.zone=Me.utcInstance,Yn({year:n,month:r,day:a,hour:o,minute:l,second:c,millisecond:u},e)}static fromJSDate(e,s={}){const n=Qi(e)?e.valueOf():NaN;if(Number.isNaN(n))return F.invalid("invalid input");const r=ot(s.zone,ye.defaultZone);return r.isValid?new F({ts:n,zone:r,loc:ae.fromObject(s)}):F.invalid(Ft(r))}static fromMillis(e,s={}){if(lt(e))return e<-zn||e>zn?F.invalid("Timestamp out of range"):new F({ts:e,zone:ot(s.zone,ye.defaultZone),loc:ae.fromObject(s)});throw new ke(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,s={}){if(lt(e))return new F({ts:e*1e3,zone:ot(s.zone,ye.defaultZone),loc:ae.fromObject(s)});throw new ke("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=ot(s.zone,ye.defaultZone);if(!n.isValid)return F.invalid(Ft(n));const r=ae.fromObject(s),a=cs(e,Gn),{minDaysInFirstWeek:o,startOfWeek:l}=Dn(a,r),c=ye.now(),u=$(s.specificOffset)?n.offset(c):s.specificOffset,f=!$(a.ordinal),m=!$(a.year),S=!$(a.month)||!$(a.day),g=m||S,A=a.weekYear||a.weekNumber;if((g||f)&&A)throw new bt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(S&&f)throw new bt("Can't mix ordinal dates with month/day");const T=A||a.weekday&&!g;let x,P,Y=Xt(c,u);T?(x=xl,P=gl,Y=os(Y,o,l)):f?(x=vl,P=Sl,Y=Ms(Y)):(x=rs,P=ha);let J=!1;for(const v of x){const M=a[v];$(M)?J?a[v]=P[v]:a[v]=Y[v]:J=!0}const I=T?_i(a,o,l):f?Ji(a):Wr(a),U=I||Br(a);if(U)return F.invalid(U);const Z=T?On(a,o,l):f?Cn(a):a,[O,H]=ns(Z,u,n),p=new F({ts:O,zone:n,o:H,loc:r});return a.weekday&&g&&e.weekday!==p.weekday?F.invalid("mismatched weekday",`you can't specify both a weekday of ${a.weekday} and a date of ${p.toISO()}`):p.isValid?p:F.invalid(p.invalid)}static fromISO(e,s={}){const[n,r]=Vo(e);return Tt(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=Zo(e);return Tt(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=zo(e);return Tt(n,r,s,"HTTP",s)}static fromFormat(e,s,n={}){if($(e)||$(s))throw new ke("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:a=null}=n,o=ae.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0}),[l,c,u,f]=pl(o,e,s);return f?F.invalid(f):Tt(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]=Ko(e);return Tt(n,r,s,"SQL",e)}static invalid(e,s=null){if(!e)throw new ke("need to specify a reason the DateTime is invalid");const n=e instanceof Ye?e:new Ye(e,s);if(ye.throwOnInvalid)throw new Ti(n);return new F({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,s={}){const n=ma(e,ae.fromObject(s));return n?n.map(r=>r?r.val:null).join(""):null}static expandFormat(e,s={}){return ca(Ie.parseFormat(e),ae.fromObject(s)).map(r=>r.val).join("")}static resetCache(){$t=void 0,Ys.clear()}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?Cs(this).weekYear:NaN}get weekNumber(){return this.isValid?Cs(this).weekNumber:NaN}get weekday(){return this.isValid?Cs(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Ds(this).weekday:NaN}get localWeekNumber(){return this.isValid?Ds(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Ds(this).weekYear:NaN}get ordinal(){return this.isValid?Ms(this.c).ordinal:NaN}get monthShort(){return this.isValid?Kt.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Kt.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Kt.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Kt.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=ys(this.c),r=this.zone.offset(n-e),a=this.zone.offset(n+e),o=this.zone.offset(n-r*s),l=this.zone.offset(n-a*s);if(o===l)return[this];const c=n-o*s,u=n-l*s,f=Xt(c,o),m=Xt(u,l);return f.hour===m.hour&&f.minute===m.minute&&f.second===m.second&&f.millisecond===m.millisecond?[ft(this,{ts:c}),ft(this,{ts:u})]:[this]}get isInLeapYear(){return Vt(this.year)}get daysInMonth(){return ls(this.year,this.month)}get daysInYear(){return this.isValid?Nt(this.year):NaN}get weeksInWeekYear(){return this.isValid?Wt(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Wt(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:s,numberingSystem:n,calendar:r}=Ie.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:s,numberingSystem:n,outputCalendar:r}}toUTC(e=0,s={}){return this.setZone(Me.instance(e),s)}toLocal(){return this.setZone(ye.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=ot(e,ye.defaultZone),e.equals(this.zone))return this;if(e.isValid){let r=this.ts;if(s||n){const a=e.offset(this.ts),o=this.toObject();[r]=ns(o,a,e)}return ft(this,{ts:r,zone:e})}else return F.invalid(Ft(e))}reconfigure({locale:e,numberingSystem:s,outputCalendar:n}={}){const r=this.loc.clone({locale:e,numberingSystem:s,outputCalendar:n});return ft(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const s=cs(e,Gn),{minDaysInFirstWeek:n,startOfWeek:r}=Dn(s,this.loc),a=!$(s.weekYear)||!$(s.weekNumber)||!$(s.weekday),o=!$(s.ordinal),l=!$(s.year),c=!$(s.month)||!$(s.day),u=l||c,f=s.weekYear||s.weekNumber;if((u||o)&&f)throw new bt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(c&&o)throw new bt("Can't mix ordinal dates with month/day");let m;a?m=On({...os(this.c,n,r),...s},n,r):$(s.ordinal)?(m={...this.toObject(),...s},$(s.day)&&(m.day=Math.min(ls(m.year,m.month),m.day))):m=Cn({...Ms(this.c),...s});const[S,g]=ns(m,this.o,this.zone);return ft(this,{ts:S,o:g})}plus(e){if(!this.isValid)return this;const s=Q.fromDurationLike(e);return ft(this,Hn(this,s))}minus(e){if(!this.isValid)return this;const s=Q.fromDurationLike(e).negate();return ft(this,Hn(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?Ie.create(this.loc.redefaultToEN(s)).formatDateTimeFromString(this,e):Os}toLocaleString(e=is,s={}){return this.isValid?Ie.create(this.loc.clone(s),e).formatDateTime(this):Os}toLocaleParts(e={}){return this.isValid?Ie.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=as(o);const l=e==="extended";let c=Rs(this,l,o);return rs.indexOf(o)>=3&&(c+="T"),c+=qn(this,l,s,n,r,a,o),c}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?Rs(this,e==="extended",as(s)):null}toISOWeekDate(){return es(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=as(l),(r&&rs.indexOf(l)>=3?"T":"")+qn(this,o==="extended",s,e,n,a,l)):null}toRFC2822(){return es(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return es(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?Rs(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:s=!1,includeOffsetSpace:n=!0}={}){let r="HH:mm:ss.SSS";return(s||e)&&(n&&(r+=" "),s?r+="z":e&&(r+="ZZ")),es(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Os}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};const s={...this.c};return e.includeConfig&&(s.outputCalendar=this.outputCalendar,s.numberingSystem=this.loc.numberingSystem,s.locale=this.loc.locale),s}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,s="milliseconds",n={}){if(!this.isValid||!e.isValid)return Q.invalid("created by diffing an invalid DateTime");const r={locale:this.locale,numberingSystem:this.numberingSystem,...n},a=Xi(s).map(Q.normalizeUnit),o=e.valueOf()>this.valueOf(),l=o?this:e,c=o?e:this,u=nl(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?he.fromDateTimes(this,e):this}hasSame(e,s,n){if(!this.isValid)return!1;const r=e.valueOf(),a=this.setZone(e.zone,{keepLocalTime:!0});return a.startOf(s,n)<=r&&r<=a.endOf(s,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;const s=e.base||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 ke("min requires all arguments be DateTimes");return Rn(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every(F.isDateTime))throw new ke("max requires all arguments be DateTimes");return Rn(e,s=>s.valueOf(),Math.max)}static fromFormatExplain(e,s,n={}){const{locale:r=null,numberingSystem:a=null}=n,o=ae.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});return da(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=ae.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new ua(a,e)}static fromFormatParser(e,s,n={}){if($(e)||$(s))throw new ke("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:a=null}=n,o=ae.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});if(!o.equals(s.locale))throw new ke(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${s.locale}`);const{result:l,zone:c,specificOffset:u,invalidReason:f}=s.explainFromTokens(e);return f?F.invalid(f):Tt(l,c,n,`format ${s.format}`,e,u)}static get DATE_SHORT(){return is}static get DATE_MED(){return yr}static get DATE_MED_WITH_WEEKDAY(){return ki}static get DATE_FULL(){return pr}static get DATE_HUGE(){return gr}static get TIME_SIMPLE(){return Sr}static get TIME_WITH_SECONDS(){return xr}static get TIME_WITH_SHORT_OFFSET(){return vr}static get TIME_WITH_LONG_OFFSET(){return wr}static get TIME_24_SIMPLE(){return Ar}static get TIME_24_WITH_SECONDS(){return Tr}static get TIME_24_WITH_SHORT_OFFSET(){return br}static get TIME_24_WITH_LONG_OFFSET(){return Nr}static get DATETIME_SHORT(){return kr}static get DATETIME_SHORT_WITH_SECONDS(){return Ir}static get DATETIME_MED(){return Er}static get DATETIME_MED_WITH_SECONDS(){return Mr}static get DATETIME_MED_WITH_WEEKDAY(){return Ii}static get DATETIME_FULL(){return jr}static get DATETIME_FULL_WITH_SECONDS(){return Or}static get DATETIME_HUGE(){return Cr}static get DATETIME_HUGE_WITH_SECONDS(){return Dr}}function Rt(t){if(F.isDateTime(t))return t;if(t&&t.valueOf&<(t.valueOf()))return F.fromJSDate(t);if(t&&typeof t=="object")return F.fromObject(t);throw new ke(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function Al(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function Tl(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 bl(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 us(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 Nl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},kl={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function ya({alerts:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,onAlertIdClick:a,onAlertView:o,onFilterChange:l,onPageChange:c,onRefetch:u,resetKey:f}){const m=Xs(),S=async T=>{try{const x=await m.mutateAsync({alertUniqueId:T.alertId??T.id,alertId:T.id,status:"Reopen",notes:"Reopened",modifiedBy:0});if(x?.responseStatus||x?.Success){const P=x?.Message||x?.data||"Alert reopened successfully.";we.toast.success(P)}else{const P=x?.errorMessage||x?.Message||"Failed to reopen alert";we.toast.error(P)}}catch{we.toast.error("Failed to reopen alert. Please try again.")}},g=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:T=>i.jsx(h.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Nl[T]}`,backgroundColor:kl[String(T)]},children:T})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:T=>bl(T)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(T,x)=>i.jsxs("div",{children:[i.jsx("a",{onClick:P=>{P.preventDefault(),a?.(x,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:x.alertNumber}),i.jsx("div",{className:"text-black/65",children:T})]})},{title:"Preview",key:"preview",width:100,align:"center",render:(T,x)=>i.jsx(fr,{record:x})},{title:"",key:"menu",width:60,align:"right",render:(T,x)=>i.jsx(h.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:P})=>{P==="reopen"&&S(x)}},children:i.jsx(h.Button,{type:"text",icon:i.jsx(yt.MoreOutlined,{})})})}],A=l?t:(t||[]).filter(T=>{const x=mn(T.statusType||"");return Ai.some(P=>x.includes(mn(P)))});return i.jsx(Qs,{data:A,loading:e,pageSize:s,total:n,currentPage:r,columns:g,renderActions:void 0,onAlertIdClick:a,onAlertView:o,onFilterChange:l,onPageChange:c,onRefetch:u,resetKey:f,excludeCompleted:!1})}function Il({size:t=120,time:e,timeZone:s="America/New_York"}){const{hours:n,minutes:r,seconds:a}=d.useMemo(()=>{const m=new Intl.DateTimeFormat("en-US",{timeZone:s,hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(e);return{hours:parseInt(m.find(S=>S.type==="hour")?.value||"0",10),minutes:parseInt(m.find(S=>S.type==="minute")?.value||"0",10),seconds:parseInt(m.find(S=>S.type==="second")?.value||"0",10)}},[e,s]),o=a*6,l=r*6+a*.1,c=n%12*30+r*.5,u=t/2;return i.jsxs("div",{className:"relative rounded-full border border-gray-300 bg-white",style:{width:t,height:t},role:"img","aria-label":"Analog Clock",children:[[...Array(12)].map((f,m)=>{const S=m*30,g=6,A=u-4,T=A-g,x=(S-90)*(Math.PI/180),P=u+T*Math.cos(x),Y=u+T*Math.sin(x),J=u+A*Math.cos(x),I=u+A*Math.sin(x);return i.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:i.jsx("line",{x1:P,y1:Y,x2:J,y2:I,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 pa({label:t="USA",timeZone:e="America/New_York",updateIntervalMs:s=1e3,className:n}){const[r,a]=d.useState(new Date);d.useEffect(()=>{const u=setInterval(()=>a(new Date),s);return()=>clearInterval(u)},[s]);const o=d.useMemo(()=>Al(r,e),[r,e]),{abbr:l,offset:c}=d.useMemo(()=>Tl(r,e),[r,e]);return i.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[i.jsx(Il,{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:El}=h.Typography;function Ml({sortBy:t,onChange:e,showActions:s,onSave:n,onClear:r,saving:a}){return i.jsxs(h.Row,{gutter:[16,16],align:"middle",children:[i.jsx(h.Col,{xs:24,md:8,lg:5,children:i.jsxs(h.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[i.jsx(El,{className:"text-gray-600 whitespace-nowrap",children:"Sort By:"}),i.jsx(h.Select,{placeholder:"By Severity",value:t,onChange:o=>e({sortBy:o}),options:[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],className:"w-full",style:{minWidth:"200px"}})]})}),i.jsx(h.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?i.jsxs(h.Space,{className:"w-full",direction:"horizontal",size:8,children:[i.jsx(h.Button,{onClick:r,disabled:a,children:"Clear"}),i.jsx(h.Button,{type:"primary",onClick:n,loading:a,children:"Save"})]}):null})]})}const _s=t=>i.jsxs(h.Tag,{children:[i.jsx(yt.PlusOutlined,{})," ",t.length," more"]}),{Text:et}=h.Typography;function jl(t){const{selectedRule:e,setSelectedRule:s,ruleOptions:n,minsOptions:r,roleOptions:a,l1mins:o,setL1mins:l,l1role:c,setL1role:u,l2mins:f,setL2mins:m,l2role:S,setL2role:g,l3mins:A,setL3mins:T,l3role:x,setL3role:P,actions:Y,setActions:J,thirdPartyIds:I,setThirdPartyIds:U,humanLoop:Z,setHumanLoop:O,isAutoExpire:H,setAutoExpire:p,onClear:v,onSave:M,saving:X,onActionTypesLoaded:pe}=t,{rules:j,config:N}=Ue(),w=N.tenant==="schools",[E,b]=d.useState([]),[D,C]=d.useState([]),[G,q]=d.useState(!1);d.useEffect(()=>{let ue=!1;return(async()=>{try{q(!0);const fe=await j.getLookups();if(ue||!fe||!Array.isArray(fe.actionTypes))return;const xe=fe.actionTypes.map(W=>({label:W.name,value:String(W.actionTypeId)}));b(xe),pe&&pe(fe.actionTypes);const de=Array.isArray(fe.thirdParties)?fe.thirdParties.map(W=>({label:W.thirdPartyName,value:W.thirdPartyIds??W.thirdPartyId})):[];C(de)}catch(fe){console.error("Error loading lookups",fe)}finally{ue||q(!1)}})(),()=>{ue=!0}},[]);const ee=typeof o=="number"||typeof c=="number",K=typeof f=="number"||typeof S=="number",le=typeof o=="number"||typeof c=="number"||typeof f=="number"||typeof S=="number"||typeof A=="number"||typeof x=="number"||Array.isArray(Y)&&Y.length>0||Array.isArray(I)&&I.length>0||!!Z||!!H,Ae=!!e&&le&&!X;return i.jsxs(h.Spin,{spinning:!!X||G,children:[i.jsxs(h.Row,{gutter:[16,16],align:"bottom",children:[i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(h.Select,{placeholder:"Rules",value:e,onChange:s,options:n,className:"w-full"})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),i.jsx(h.Col,{span:14,children:i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:o,onChange:l,options:r})}),i.jsx(h.Col,{span:14,children:i.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:c,onChange:u,options:a})})]})]})}),ee&&i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),i.jsx(h.Col,{span:14,children:i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:f,onChange:m,options:r})}),i.jsx(h.Col,{span:14,children:i.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:S,onChange:g,options:a})})]})]})}),K&&i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),i.jsx(h.Col,{span:14,children:i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(h.Row,{gutter:8,children:[i.jsx(h.Col,{span:10,children:i.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:A,onChange:T,options:r})}),i.jsx(h.Col,{span:14,children:i.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:x,onChange:P,options:a})})]})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),i.jsx(h.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:Y,onChange:J,options:E,maxTagCount:1,maxTagPlaceholder:_s})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(et,{className:"text-gray-700 font-medium block mb-1",children:"Notify"}),i.jsx(h.Select,{mode:"multiple",placeholder:"Notify",className:"w-full",value:I,onChange:U,options:D,maxCount:2,maxTagPlaceholder:_s})]})})]}),i.jsxs(h.Row,{gutter:[16,16],align:"bottom",className:"mt-4 items-center",children:[i.jsx(h.Col,{xs:24,sm:12,md:8,lg:7,children:i.jsxs("div",{className:"flex items-center h-full gap-8",children:[!w&&i.jsx(h.Checkbox,{checked:Z,onChange:ue=>O(ue.target.checked),className:"w-full",children:"Human-In-The-Loop"}),i.jsx(h.Checkbox,{checked:H,onChange:ue=>p(ue.target.checked),className:"w-full",children:"Auto-expire in 5 minutes"})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(h.Button,{onClick:v,children:"Clear"}),i.jsx(h.Button,{type:"primary",onClick:M,loading:!!X,disabled:!Ae,children:"Save"})]})})]})]})}function Ol({entries:t,userRoles:e,onEdit:s,loading:n}){const{config:r}=Ue(),a=r.tenant==="schools",o=new Map(e.map(c=>[c.userRoleId,c.userRoleName])),l=c=>c.map(u=>o.get(u)||String(u)).join(", ");return i.jsx(h.Table,{rowKey:"id",dataSource:t,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(c,u)=>`${u[0]}-${u[1]} of ${c} items`},loading:n,columns:[{title:"Rule",dataIndex:"ruleOrSeverityLabel",key:"rule"},{title:"Level 1",key:"l1",render:(c,u)=>i.jsxs("span",{children:[u.l1.minutes?`Action taken in (${u.l1.minutes} Mins)`:"No Action taken in 0 Min",u.l1.roles?.length?`, Escalate to (${l(u.l1.roles)})`:""]})},{title:"Level 2",key:"l2",render:(c,u)=>i.jsxs("span",{children:[u.l2.minutes?`Action taken in (${u.l2.minutes} Mins)`:"No Action taken in 0 Min",u.l2.roles?.length?`, Escalate to (${l(u.l2.roles)})`:""]})},{title:"Level 3",key:"l3",render:(c,u)=>i.jsxs("span",{children:[u.l3.minutes?`Action taken in (${u.l3.minutes} Mins)`:"No Action taken in 0 Min",u.l3.roles?.length?`, Escalate to (${l(u.l3.roles)})`:""]})},{title:"Pick Actions",key:"actionsCol",render:(c,u)=>u.actions?.length?u.actions.join(", "):"-"},{title:"Notify",key:"notify",render:(c,u)=>u.notify?.length?u.notify.join(", "):"-"},...a?[]:[{title:"Human-In-The-Loop",key:"humanLoop",render:(c,u)=>u.humanLoop?"Yes":"No"}],{title:"Auto Expire",key:"isAutoExpire",render:(c,u)=>u.isAutoExpire?"Yes":"No"},{title:"Actions",key:"ops",render:(c,u)=>i.jsx(h.Button,{type:"text",onClick:()=>s(u.id),children:i.jsx(yt.EditOutlined,{})})}]})}const{Title:Cl,Text:Us}=h.Typography;function ga({userRoles:t,rules:e,rawRules:s}){const{rules:n}=Ue(),[r,a]=d.useState(!1),[o,l]=d.useState(!1),[c,u]=d.useState(s),[f,m]=d.useState(),[S,g]=d.useState([]),A=d.useMemo(()=>t.map(I=>({label:I.userRoleName,value:I.userRoleId})),[t]),T=d.useMemo(()=>(e||[]).map(I=>({label:I.Name||"-",value:I.RuleId||I.Name||""})),[e]),x=d.useMemo(()=>(e||[]).map((I,U)=>({key:I.RuleId||I.Name||String(U),ruleName:I.Name||"-",ruleDesc:I.Description||""})),[e]);d.useEffect(()=>{let I=!1;return(async()=>{try{a(!0);const U=await n.getRules();I||u(Array.isArray(U)?U:[])}catch{!I&&Array.isArray(s)&&u(s)}finally{I||a(!1)}})(),()=>{I=!0}},[]),d.useEffect(()=>{!c&&Array.isArray(s)&&u(s)},[s]),d.useEffect(()=>{if(!f||!Array.isArray(c)){g([]);return}const I=c.find(Z=>Z?.ruleId===f||Z?.RuleId===f||Z?.ruleName===f),U=I?.userRoleIds??I?.UserRoleIds;g(Array.isArray(U)?U:[])},[f,c]);const P=d.useMemo(()=>{if(!Array.isArray(c)||!c.length)return{};const I={};for(const U of x){const Z=c.find(p=>p?.ruleId===U.key||p?.ruleName===U.key||p?.RuleId===U.key||p?.ruleName===U.ruleName||p?.Name===U.ruleName),O=Z?.userRoleIds??Z?.UserRoleIds,H=Array.isArray(O)?O:[];H.length&&(I[U.key]=H)}return I},[c,x]),Y=()=>{m(void 0),g([])},J=async()=>{if(!f){we.toast.info("Please select a rule");return}try{l(!0);const I=Array.isArray(c)?c.find(p=>p?.ruleId===f||p?.RuleId===f||p?.ruleName===f):void 0,U=typeof I?.recordId=="number"?I.recordId:I?.ruleId||I?.RuleId||void 0;if(!I||!U)throw new Error(`Unable to find rule identifier for rule ${f}`);const Z=S.map(p=>{const v=t.find(M=>M.userRoleId===p);return{id:p,name:v?.userRoleName??String(p)}}),O={...I,ruleId:f,userRoleIds:S,userRoles:Z},H=await n.updateRule(U,O);if(!H?.responseStatus&&!H?.Success&&!H?.success)we.toast.error(H?.errorMessage||H?.Message||"Error saving Alert Assignment");else{we.toast.success("Alert assignment saved"),m(void 0),g([]);try{const p=await n.getRules();u(Array.isArray(p)?p:[])}catch(p){console.error("Failed to refresh rules after save",p)}}}catch(I){console.error("Failed to save alert assignment",I),we.toast.error(I instanceof Error?I.message:"Error saving Alert Assignment")}finally{l(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(Cl,{level:4,className:"!mb-4",children:"Alert Assignment"}),i.jsx(h.Spin,{spinning:o||r,children:i.jsxs(h.Row,{gutter:[16,16],align:"bottom",className:"mb-6",children:[i.jsx(h.Col,{xs:24,sm:12,md:8,lg:6,children:i.jsxs("div",{children:[i.jsx(Us,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(h.Select,{placeholder:"Rules",value:f,onChange:m,options:T,className:"w-full"})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:8,children:i.jsxs("div",{children:[i.jsx(Us,{className:"text-gray-700 font-medium block mb-1",children:"Alert Notification To"}),i.jsx(h.Select,{mode:"multiple",placeholder:"Select roles",className:"w-full",value:S,onChange:g,options:A,maxTagCount:1,maxTagPlaceholder:_s})]})}),i.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(h.Button,{onClick:Y,disabled:o,children:"Cancel"}),i.jsx(h.Button,{type:"primary",onClick:J,loading:o,disabled:o||!f,children:"Save"})]})})]})}),i.jsx(h.Table,{rowKey:"key",dataSource:x,loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(I,U)=>`${U[0]}-${U[1]} of ${I} items`},columns:[{title:"Rule Name",dataIndex:"ruleName",key:"ruleName"},{title:"Description",dataIndex:"ruleDesc",key:"ruleDesc"},{title:"Alert Notification To",key:"assign",render:(I,U)=>{const Z=P[U.key]??[];return Z.length?i.jsx("div",{className:"flex flex-wrap gap-1",children:Z.map(O=>{const H=t.find(p=>p.userRoleId===O);return i.jsx(h.Tag,{children:H?.userRoleName??String(O)},O)})}):i.jsx(Us,{type:"secondary",children:"—"})}}]})]})}const{Title:Kn}=h.Typography;function Ls(t){return!t||typeof t!="object"?{}:{level1UserRoleId:t.level1UserRoleId??t.Level1UserRoleId,level1PostAssistTime:t.level1PostAssistTime??t.Level1PostAssistTime,level2UserRoleId:t.level2UserRoleId??t.Level2UserRoleId,level2PostAssistTime:t.level2PostAssistTime??t.Level2PostAssistTime,level3UserRoleId:t.level3UserRoleId??t.Level3UserRoleId,level3PostAssistTime:t.level3PostAssistTime??t.Level3PostAssistTime,escalationSettingsActionTypeIds:t.escalationSettingsActionTypeIds??t.EscalationSettingsActionTypeIds,thirdPartyId:t.thirdPartyId??t.ThirdPartyId??t.ThirdPartyIds,humanLoop:t.humanLoop??t.HumanLoop,isAutoExpire:t.isAutoExpire??t.IsAutoExpire}}function Sa({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r,onSave:a}){const{rules:o,alerts:l}=Ue(),[c,u]=d.useState("By Severity"),[f,m]=d.useState("By severity"),[S,g]=d.useState("By Severity"),[A,T]=d.useState(!1),[x,P]=d.useState(!1),[Y,J]=d.useState(!1),[I,U]=d.useState(null),[Z,O]=d.useState("rules"),[H,p]=d.useState(),[v,M]=d.useState(),[X,pe]=d.useState(),[j,N]=d.useState(),[w,E]=d.useState(),[b,D]=d.useState(),[C,G]=d.useState(),[q,ee]=d.useState(),[K,le]=d.useState([]),[Ae,ue]=d.useState([]),[fe,xe]=d.useState(!1),[de,W]=d.useState(!1),[L,ie]=d.useState({}),[oe,Te]=d.useState({}),[be,Ke]=d.useState(s||[]),[Le,Ne]=d.useState([]),[ct,ut]=d.useState(!1),[St,dt]=d.useState(!1),[Fe,xt]=d.useState(n||[]);d.useEffect(()=>{n&&n.length&&xt(n)},[n]),d.useEffect(()=>{if(!Fe||!Fe.length)return;const R=Object.keys(L).length>0||Object.keys(oe).length>0;if(Le.length&&!R)return;const te=Fe.map((_,B)=>{const ne=e.find(Ee=>Ee.RuleId===(_.ruleId||_.ruleName))?.Name||_.ruleName||_.Name||"-",V=Ls(_.escalationSettings),y=typeof V.level1UserRoleId=="number"&&V.level1UserRoleId>0?[V.level1UserRoleId]:[],z=typeof V.level2UserRoleId=="number"&&V.level2UserRoleId>0?[V.level2UserRoleId]:[],re=typeof V.level3UserRoleId=="number"&&V.level3UserRoleId>0?[V.level3UserRoleId]:[],je=(Array.isArray(V.escalationSettingsActionTypeIds)?V.escalationSettingsActionTypeIds:[]).map(Ee=>L[Ee]||String(Ee)),ze=(Array.isArray(V.thirdPartyId)?V.thirdPartyId:[]).map(Ee=>oe[Ee]||String(Ee)),Je=typeof V.humanLoop=="boolean"?V.humanLoop:null,He=typeof V.isAutoExpire=="boolean"?V.isAutoExpire:null;return{id:String(_.ruleId||_.ruleName||B),ruleOrSeverityLabel:ne,l1:{minutes:V.level1PostAssistTime??void 0,roles:y},l2:{minutes:V.level2PostAssistTime??void 0,roles:z},l3:{minutes:V.level3PostAssistTime??void 0,roles:re},actions:je,notify:ze,humanLoop:Je,isAutoExpire:He}});Ne(te)},[Fe,e,L,oe]);const vt=d.useMemo(()=>t.map(R=>({label:R.DisplayName,value:R.SeverityId})),[t]),ve=d.useMemo(()=>e.map(R=>({label:R.Name,value:R.RuleId})),[e]),Ct=d.useMemo(()=>be.map(R=>({label:R.userRoleName,value:R.userRoleId})),[be]),xs=d.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(R=>({label:`${R}`,value:R})),[]);d.useEffect(()=>{let R=!1;async function te(){try{J(!0),U(null);const _=await l.getAdminSettings();if(!R&&_){const B=er(_.sortBy);u(B),g(B),T(!1)}}catch(_){if(!R){const B=_ instanceof Error?_.message:"Failed to load admin settings";U(B)}}finally{R||J(!1)}}return te(),()=>{R=!0}},[]),d.useEffect(()=>{if(!v)return;const R=ne=>{const V=Number(ne);return!isNaN(V)&&V>0?V:void 0},te=ne=>{const V=Number(ne);return!isNaN(V)&&V>0?V:void 0},_=(Fe||[]).find(ne=>ne?.ruleId===v||ne?.ruleName===v||ne?.RuleId===v),B=Ls(_?.escalationSettings);if(B&&typeof B=="object"){pe(te(B.level1PostAssistTime)),N(R(B.level1UserRoleId)),E(te(B.level2PostAssistTime)),D(R(B.level2UserRoleId)),G(te(B.level3PostAssistTime)),ee(R(B.level3UserRoleId));const ne=Array.isArray(B.escalationSettingsActionTypeIds)?B.escalationSettingsActionTypeIds:[];le(ne.map(V=>String(V))),ue(Array.isArray(B.thirdPartyId)?B.thirdPartyId:[]),xe(!!B.humanLoop),W(!!B.isAutoExpire)}},[Z,v,Fe]);const vs=async()=>{try{dt(!0);const R=await o.getRules(),te=Array.isArray(R)?R:Array.isArray(R?.data)?R.data:[];xt(te);const _=te.map((B,ne)=>{const V=e.find(Ee=>Ee.RuleId===(B.ruleId||B.ruleName))?.Name||B.ruleName||B.Name||"-",y=Ls(B.escalationSettings??B.EscalationSettings),z=typeof y.level1UserRoleId=="number"&&y.level1UserRoleId>0?[y.level1UserRoleId]:[],re=typeof y.level2UserRoleId=="number"&&y.level2UserRoleId>0?[y.level2UserRoleId]:[],Se=typeof y.level3UserRoleId=="number"&&y.level3UserRoleId>0?[y.level3UserRoleId]:[],me=(Array.isArray(y.escalationSettingsActionTypeIds)?y.escalationSettingsActionTypeIds:[]).map(Ee=>L[Ee]||String(Ee)),Je=(Array.isArray(y.thirdPartyId)?y.thirdPartyId:[]).map(Ee=>oe[Ee]||String(Ee)),He=typeof y.humanLoop=="boolean"?y.humanLoop:null;return{id:String(B.ruleId||B.ruleName||ne),ruleOrSeverityLabel:V,l1:{minutes:y.level1PostAssistTime??void 0,roles:z},l2:{minutes:y.level2PostAssistTime??void 0,roles:re},l3:{minutes:y.level3PostAssistTime??void 0,roles:Se},actions:me,notify:Je,humanLoop:He}});Ne(_)}catch(R){console.error("Failed to refetch entries",R)}finally{dt(!1)}};d.useEffect(()=>{let R=!1;return(async()=>{try{const te=await o.getLookups();if(R||!te)return;const _={};if(Array.isArray(te.thirdParties))for(const ne of te.thirdParties){const V=ne.thirdPartyIds??ne.thirdPartyId;typeof V=="number"&&(_[V]=ne.thirdPartyName)}Te(_);const B=Array.isArray(te.userRoles)?te.userRoles.map(ne=>({userRoleId:ne.userRoleId??ne.id,userRoleName:ne.userRoleName??ne.name})):[];R||Ke(B.length?B:s||[])}catch(te){console.error("Error loading lookups",te)}})(),()=>{R=!0}},[]);const ws=async()=>{P(!0);try{const R=await l.setAdminSettings({sortBy:c,groupBy:"string"});R?.responseStatus&&R?.data&&we.toast.success(R.data),g(c),T(!1)}catch(R){console.error("Error saving admin settings",R)}finally{P(!1)}},As=()=>{u(S),T(!1)},Ts=async()=>{ut(!0),a?.({ruleId:v,levels:[{minutes:X,role:j},{minutes:w,role:b},{minutes:C,role:q}],actions:K,thirdPartyIds:Ae,humanLoop:fe,isAutoExpire:de});try{if(v){const te=Array.isArray(K)?K.map(y=>Number.isNaN(Number(y))?y:Number(y)):[],_=(Fe||[]).find(y=>y?.ruleId===v||y?.ruleName===v||y?.RuleId===v),B=typeof _?.recordId=="number"?_.recordId:_?.ruleId||_?.RuleId||void 0;if(!_||!B){we.toast.error("Unable to find rule identifier for update");return}const ne={..._,escalationSettings:{level1UserRoleId:j??0,level1PostAssistTime:X??0,level2UserRoleId:b??0,level2PostAssistTime:w??0,level3UserRoleId:q??0,level3PostAssistTime:C??0,escalationSettingsActionTypeIds:te,thirdPartyId:Array.isArray(Ae)?Ae:[],humanLoop:fe,isAutoExpire:de}},V=await o.updateRule(B,ne);V?.responseStatus||V?.Success||V?.success?(we.toast.success("Escalation settings saved"),await vs(),M(void 0),pe(void 0),N(void 0),E(void 0),D(void 0),G(void 0),ee(void 0),le([]),ue([]),xe(!1),W(!1)):we.toast.error(V?.errorMessage||V?.Message||"Error saving Escalation Settings")}}catch(te){console.error("Error saving escalation settings",te)}finally{ut(!1)}},bs=()=>{u("By Severity"),m("By severity"),O("rules"),p(void 0),M(void 0),pe(void 0),N(void 0),E(void 0),D(void 0),G(void 0),ee(void 0),le([]),ue([]),xe(!1),W(!1)};return i.jsxs("div",{className:"w-full",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(Kn,{level:4,className:"!mb-2",children:"Admin Settings"}),i.jsxs(h.Spin,{spinning:Y,children:[I?i.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",I]}):null,i.jsx(Ml,{sortBy:c,groupBy:f,onChange:R=>{R.sortBy&&(u(R.sortBy),T(!0)),R.groupBy&&(m(R.groupBy),T(!0))},showActions:A,onSave:ws,onClear:As,saving:x})]})]}),i.jsx(h.Divider,{className:"my-6"}),i.jsxs("div",{children:[i.jsx(Kn,{level:4,className:"!mb-4",children:"Escalation Settings"}),i.jsx(jl,{escBasis:Z,setEscBasis:O,selectedSeverity:H,setSelectedSeverity:p,selectedRule:v,setSelectedRule:M,severityOptions:vt,ruleOptions:ve,minsOptions:xs,roleOptions:Ct,l1mins:X,setL1mins:pe,l1role:j,setL1role:N,l2mins:w,setL2mins:E,l2role:b,setL2role:D,l3mins:C,setL3mins:G,l3role:q,setL3role:ee,actions:K,setActions:le,thirdPartyIds:Ae,setThirdPartyIds:ue,humanLoop:fe,setHumanLoop:xe,onClear:bs,onSave:Ts,saving:ct,onActionTypesLoaded:R=>{const te={};for(const _ of R)typeof _.actionTypeId=="number"&&(te[_.actionTypeId]=_.name);ie(te)},isAutoExpire:de,setAutoExpire:W})]}),i.jsx(h.Divider,{className:"my-6"}),i.jsx(Ol,{entries:Le,userRoles:be,loading:St||r,onEdit:R=>{O("rules");const te=Le.find(B=>B.id===R),_=e.find(B=>B.RuleId===R)||(te?e.find(B=>B.Name===te.ruleOrSeverityLabel):void 0);M(_?_.RuleId:R)}}),i.jsx(h.Divider,{className:"my-6"}),i.jsx(ga,{userRoles:be,rules:e,rawRules:n}),i.jsx(h.Divider,{})]})}const{Title:Qn,Text:ts}=h.Typography;function Dl({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:a}=Ue(),o=[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],[l,c]=d.useState("By Severity"),[u,f]=d.useState(new Set),[m,S]=d.useState(null),[g,A]=d.useState(null),[T,x]=d.useState({inApp:!1,sms:!1,email:!1}),[P,Y]=d.useState([]),[J,I]=d.useState(!0),[U,Z]=d.useState(!1);d.useEffect(()=>{let p=!1;return(async()=>{try{const v=await a.getPreferenceSettings();if(p||!v)return;x({inApp:!!v.inApp,sms:!!v.sms,email:!!v.email});const M=er(v.sortBy);c(M==="By Created Date"?"By Created Date":"By Severity"),S(pn(v.doNotDisturbStart)),A(pn(v.doNotDisturbEnd)),Array.isArray(v.anomalyIds)&&f(new Set(v.anomalyIds.map(X=>String(X))))}catch(v){console.error("Error in loading my preferences: ",v)}})(),()=>{p=!0}},[]),d.useEffect(()=>{let p=!1;return(async()=>{try{I(!0);const v=await r.getLookups();if(p||!v)return;const M=Array.isArray(v.anomalies)?v.anomalies:[];Y(M)}catch(v){console.error("Failed to load anomalies lookups",v)}finally{p||I(!1)}})(),()=>{p=!0}},[]);const O=p=>{f(v=>{const M=new Set(v);return M.has(p)?M.delete(p):M.add(p),M})},H=async()=>{s?.({sortBy:l,subscribedRuleIds:Array.from(u),dnd:{from:m,to:g},channels:T});try{Z(!0);const p=m?m.format?.("HH:mm:ss")??"00:00:00":"00:00:00",v=g?g.format?.("HH:mm:ss")??"00:00:00":"00:00:00",M=Array.from(u).map(pe=>Number(pe)).filter(pe=>Number.isFinite(pe)),X=await a.setPreferenceSettings({anomalyIds:M,doNotDisturbStart:p,doNotDisturbEnd:v,inApp:!!T.inApp,sms:!!T.sms,email:!!T.email,sortBy:l});X?.responseStatus&&we.toast.success(X?.data||"Preferences updated successfully.")}catch(p){console.error("Error in saving my preferences: ",p)}finally{Z(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(h.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:i.jsx(h.Col,{xs:24,md:8,children:i.jsxs(h.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(ts,{className:"text-gray-600",children:"Sort By:"}),i.jsx(h.Select,{className:"w-[240px]",value:l,options:o,onChange:c})]})})}),i.jsxs("div",{className:"mb-4",children:[i.jsx(Qn,{level:5,className:"!mb-2",children:"Anomalies"}),J?i.jsx("div",{className:"py-4",children:i.jsx(h.Spin,{})}):i.jsx(h.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray(P)?P:[]).map(p=>{const v=String(p.recordId),M=p.anomalyName;return i.jsx(h.Checkbox,{checked:u.has(v),onChange:()=>O(v),children:M},v)})})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx(Qn,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),i.jsx(h.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:i.jsx(h.Col,{xs:24,md:12,children:i.jsxs(h.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(ts,{children:"Do Not Disturb mode:"}),i.jsxs(h.Space,{size:12,className:"w-full",children:[i.jsxs(h.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(ts,{children:"From"}),i.jsx(h.TimePicker,{value:m,onChange:p=>S(p),format:"HH:mm"})]}),i.jsxs(h.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(ts,{children:"To"}),i.jsx(h.TimePicker,{value:g,onChange:p=>A(p),format:"HH:mm"})]})]})]})})}),i.jsxs(h.Row,{gutter:[24,12],children:[i.jsx(h.Col,{children:i.jsx(h.Checkbox,{checked:T.inApp,onChange:p=>x({...T,inApp:p.target.checked}),children:"In-app"})}),i.jsx(h.Col,{children:i.jsx(h.Checkbox,{checked:T.sms,onChange:p=>x({...T,sms:p.target.checked}),children:"SMS"})}),i.jsx(h.Col,{children:i.jsx(h.Checkbox,{checked:T.email,onChange:p=>x({...T,email:p.target.checked}),children:"Email"})})]})]}),i.jsx(h.Divider,{}),i.jsxs(h.Space,{className:"gap-3",children:[i.jsx(h.Button,{onClick:n,disabled:U,children:"Cancel"}),i.jsx(h.Button,{type:"primary",onClick:H,loading:U,children:"Save"})]})]})}function xa({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r}){return i.jsx("div",{className:"w-full",children:i.jsx(Sa,{severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r})})}const Rl="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=",Ul="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 Ss(){const{config:t}=Ue();return{timeZoneDetails:d.useMemo(()=>{const s=t.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone;return{timeZoneUniqueId:"",ianaTimeZoneId:s,timeZoneName:s,offset:""}},[t.timeZone]),loading:!1}}function Ll(t){const e=(t.status||"").toLowerCase()==="completed"?i.jsx("img",{src:Rl,alt:"completed",style:{width:20,height:20}}):i.jsx("img",{src:Ul,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 Fl({data:t}){const{timeZoneDetails:e}=Ss();return i.jsx("div",{className:"w-full",children:i.jsx(h.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:i.jsxs("div",{className:"w-full",style:{maxHeight:"50vh",overflowY:"auto"},children:[i.jsx(h.Card,{className:"mb-4 rounded-md p-4",bordered:!0,children:i.jsxs("div",{className:"grid grid-cols-4 gap-6 text-xs",children:[i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Alert ID"}),i.jsx("span",{className:"text-black",children:t.summary.alertNumber})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Severity"}),i.jsx("span",{className:"text-black",children:t.summary.severity})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Location"}),i.jsx("span",{className:"text-black",children:t.summary.location})]})]})}),i.jsxs(h.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsx("h4",{className:"text-sm text-black font-medium",children:"Response Timeline/ Audit trail/log"})}),i.jsx("div",{className:"mt-2",children:i.jsx(h.Steps,{direction:"vertical",size:"small",current:1,items:(t.timeline||[]).map(Ll)})})]})]})},{key:"notification",label:"Notification Sent",children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",style:{maxHeight:"50vh",overflowY:"auto"},children:[(t.notifications||[]).map((s,n)=>i.jsxs(h.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.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:us(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 $l=({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}=Ss(),u=a?.length?a.map(m=>{const S=(m?.status||m?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",g=m?.createdDate?us(m.createdDate,c?.ianaTimeZoneId):m?.timestamp?us(m.timestamp,c?.ianaTimeZoneId):"";return{status:S,title:m?.status||m?.eventStatus||"Status Update",description:m?.description||m?.actionNotes||"",timestamp:g}}):[],f={summary:l,timeline:u,notifications:o??[]};return i.jsx(Fl,{data:f})},Pl=({url:t,alt:e,isLoading:s,priority:n,detections:r,onLoadSuccess:a,onError:o})=>{const{imageRef:l,dimensions:c,onLoad:u}=dr(),f=d.useMemo(()=>ur(r,c.naturalWidth,c.naturalHeight,c.renderedWidth,c.renderedHeight),[r,c]),m=d.useMemo(()=>f.map(S=>({...S,label:S.personName||""})),[f]);return i.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[i.jsx("img",{ref:l,src:t,alt:e,className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg transition-opacity duration-200 ${s?"opacity-0":"opacity-100"}`,onLoad:()=>{u(),a()},onError:o}),i.jsx(cr,{boxes:m,priority:n})]})},Wl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Bl={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Vl={"elopement attempt":"elopement","elopement completed":"elopement","watchlist person detected":"watchlist","watch list person detected":"watchlist","brandished guns & knives":"weapon","brandished guns and knives":"weapon"},Zl=({isModalOpen:t,handleModalClose:e,selectedRow:s,fetchAlertLogs:n,alertStatusList:r=[],alertStatusLoading:a=!1,initialTab:o="details",sourceTab:l,onAlertView:c})=>{const[u,f]=d.useState(),[m,S]=d.useState(""),[g,A]=d.useState(!1),T=d.useRef(null),[x,P]=d.useState("details"),[Y,J]=d.useState(void 0),I=Xs(),{alerts:U,rules:Z,config:O}=Ue(),{timeZoneDetails:H}=Ss(),[p,v]=d.useState(null),[M,X]=d.useState(!1),[pe,j]=d.useState(!1),[N,w]=d.useState(void 0),[E,b]=d.useState(void 0),[D,C]=d.useState({}),[G,q]=d.useState({}),ee=(y,z,re)=>{const Se=G[y];return D[y]===!1&&!Se?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(or,{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:[Se&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg z-10",children:i.jsx(yi,{size:32,className:"animate-spin text-gray-400"})}),i.jsx(Pl,{url:y,alt:z.caption||`media-${re}`,isLoading:Se,priority:ie,detections:ut,onLoadSuccess:()=>q(je=>({...je,[y]:!1})),onError:()=>q(je=>({...je,[y]:!1}))})]})},K=s?.originalData||{},{eventName:le,eventDisplayName:Ae,anomalyName:ue,alertId:fe,timestamp:xe,description:de,spaceName:W,assignTeam:L,priority:ie,statusType:oe,id:Te,alertDetails:be,statusHistory:Ke,mediaDetails:Le,alertNumber:Ne}=K,ct=K.bbox_xyxy,ut=d.useMemo(()=>ct?[{bbox_xyxy:ct,personName:K.personName}]:[],[ct,K.personName]),St=O.tenant==="snl"?Ae||le||"Alert Event":le||"Alert Event",dt=y=>{const z=String(y||"").toLowerCase();return z==="delivered"||z==="sent"?"Delivered":z==="failed"?"Failed":"Queued"},Fe=y=>({name:y?.receipientName||y?.recipientName||"-",role:y?.receipientRoleName||"",phone:y?.receipentPhoneNumber||y?.recipientPhoneNumber||y?.receipientEmail||y?.recipientEmail||"",status:dt(y?.messageStatus),notificationReceipientType:y?.notificationReceipientType||""}),xt=(y,z)=>{const re=z.map(Fe),Se=re.filter(Je=>Je.status==="Delivered").length,je=z.map(Je=>Je?.sentAt).filter(Boolean).sort((Je,He)=>new Date(He).getTime()-new Date(Je).getTime())[0],ze=(z[0]||{})?.severityName||`${y} Notification`;return{channelLabel:`${y} Notification`,sentAt:je||"",messageTitle:ze,messageBody:"",total:re.length,delivered:Se,recipients:re}},vt=y=>{const z=new Map;return(y||[]).forEach(re=>{const Se=String(re?.notificationType||"Unknown"),je=z.get(Se)||[];je.push(re),z.set(Se,je)}),Array.from(z.entries()).map(([re,Se])=>xt(re,Se))},ve=async y=>{try{const z=await U.getAlertNotifications(y),re=vt(z);J(re)}catch{J(void 0)}};d.useEffect(()=>{if(x!=="track"||!Te)return;let y=!1;return ve(Te).then(()=>{y&&J(void 0)}),()=>{y=!0}},[x,Te]),d.useEffect(()=>{t?P(o):(f(void 0),S(""))},[t,o]),d.useEffect(()=>{!t||!c||c([{personName:K.personName,faceId:K.faceId,mediaDetails:K.mediaDetails}])},[t]),d.useEffect(()=>{if(!t||O.tenant!=="snl")return;let y=!1;return X(!0),Z.getLookups().then(z=>{y||(v(z.alertStatusTypes??[]),X(!1))}).catch(()=>{y||(v([]),X(!1))}),()=>{y=!0}},[t,O.tenant]);const xs=l==="archived"||["completed","false positive"].includes(String(oe||"").toLowerCase()),vs=y=>{const z=String(y?.value||"").toLowerCase(),re=String(y?.statusName||"").toLowerCase();return z.includes("reopen")||re.includes("reopen")},ws=String(ue||"").trim().toLowerCase(),As=Vl[ws]??"general",Ts=r.filter(y=>{const z=vs(y);return typeof l<"u"?l==="archived"?z:!z:xs?z:!z}).map(y=>({value:y.value,label:y.statusName})),bs=p??[],R=y=>!!y.isWatchListStatus,te=y=>!!y.isWeapontStatus,_=bs.filter(y=>{switch(As){case"elopement":return y.isElopementStatus;case"watchlist":return R(y);case"weapon":return te(y);default:return!y.isElopementStatus&&!R(y)&&!te(y)}}).map(y=>({value:y.alertStatusTypeName,label:y.alertStatusTypeName})),B=O.tenant==="snl"&&p!==null?_:Ts,ne=d.useMemo(()=>ar(Le),[Le]);d.useEffect(()=>{let y=!1;const z=new AbortController,re=async me=>{if(me){y||C(ze=>({...ze,[me]:!1}));try{const ze=await fetch(me,{method:"HEAD",signal:z.signal});if(ze.ok){y||C(He=>({...He,[me]:!0}));return}if(ze.status===404){y||C(He=>({...He,[me]:!1}));return}if(!(await fetch(me,{method:"GET",signal:z.signal})).ok)throw new Error("Media not available");y||C(He=>({...He,[me]:!0}))}catch{y||C(ze=>({...ze,[me]:!1}))}}};C({});const Se=ne.filter(me=>!Fs(me)).map(me=>me?.mediaUrl||me).filter(me=>typeof me=="string"&&me.length>0),je={};return Se.forEach(me=>{je[me]=!0}),q(je),Se.forEach(me=>re(me)),()=>{y=!0,z.abort()}},[ne]);const V=async()=>{try{A(!0);const y={alertUniqueId:fe,alertId:Te,status:u?String(u):void 0,notes:m.trim(),modifiedBy:0},z=await I.mutateAsync(y);if(z?.responseStatus||z?.Success){const re=z?.Message||z?.data||"Alert updated successfully.";we.toast.success(re,{autoClose:1500,onClose:()=>{n(),e()}}),f(void 0),S("")}else{const re=z?.errorMessage||z?.Message||"Failed to update alert status";we.toast.error(re)}}catch(y){console.error("Error updating alert status:",y),we.toast.error("Failed to update alert status. Please try again.")}finally{A(!1)}};return i.jsx(h.Modal,{open:t,onCancel:e,width:1e3,footer:x==="details"?i.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[i.jsx(h.Button,{onClick:e,className:"!bg-[#6C757D] !text-white !border-[#6C757D] hover:!bg-[#5c636a] hover:!text-white hover:!border-[#5c636a]",children:"Cancel"}),i.jsx(h.Button,{type:"primary",onClick:V,loading:g,children:g?"Saving...":"Save Changes"})]}):null,children:s&&i.jsx(h.Tabs,{activeKey:x,onChange:y=>P(y),items:[{key:"details",label:"Alert Detail",children:i.jsxs("div",{className:"grid grid-cols-2 gap-2",style:{maxHeight:"50vh",overflowY:"auto"},children:[i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("div",{className:"text-sm font-bold",children:St}),be?.firstName?i.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",be?.firstName," ",be?.lastName||""," "," ",be?.residentId||""]}):null,i.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp:"," ",us(xe,H?.ianaTimeZoneId)]}),i.jsxs("div",{className:"font-sm text-gray-500",children:[i.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",de||"No description available"]}),W&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",W]}),L&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",L]}),i.jsxs("div",{className:"flex gap-2 justify-start mt-3",children:[i.jsxs(h.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${Wl[String(ie)]||"#DFE4EA"}`,backgroundColor:Bl[String(ie)]},children:["Severity: ",ie||"N/A"]}),i.jsxs(h.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(oe||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",oe||"N/A"]})]}),i.jsx("div",{className:"w-full flex flex-col justify-start items-start mt-2 font-bold",children:i.jsxs("div",{className:"w-full mt-4",children:[i.jsx("div",{className:"flex flex-col gap-2",children:i.jsx(h.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:y=>f(y),value:u,options:B,loading:O.tenant==="snl"?M:a})}),i.jsxs("div",{className:"flex flex-col gap-2 mt-3",children:[i.jsx("label",{htmlFor:"action-details-input",className:"text-xs text-gray-500 font-medium",children:"Action Taken (Comments)"}),i.jsx("textarea",{id:"action-details-input",placeholder:"Enter details...",className:"w-full text-gray-500 h-20 border border-grey-500 rounded-md p-2",value:m,onChange:y=>S(y.target.value)})]})]})})]}),i.jsx("div",{className:"flex flex-col gap-4",children:i.jsxs("div",{className:"w-full mt-1",children:[i.jsxs("div",{className:"w-full flex items-center justify-between",children:[i.jsx("h3",{className:"text-black font-bold text-sm",children:"Camera Footage"}),ne.length>1?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>T.current?.prev?.(),className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 text-gray-600","aria-label":"Previous media",children:i.jsx(yt.LeftOutlined,{style:{fontSize:12}})}),i.jsx("button",{type:"button",onClick:()=>T.current?.next?.(),className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 text-gray-600","aria-label":"Next media",children:i.jsx(yt.RightOutlined,{style:{fontSize:12}})})]}):null]}),ne.length?i.jsx("div",{className:"w-full",children:i.jsx(h.Carousel,{ref:T,dots:!0,className:"w-full",children:ne.map((y,z)=>{const re=y.mediaUrl||y,Se=Fs(y);return i.jsxs("div",{className:"flex justify-center items-center relative",children:[Se?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:re}),"Your browser does not support the video tag."]}):ee(String(re),y,z),y.caption&&i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:y.caption}),!Se&&D[String(re)]?i.jsx("button",{onClick:()=>{j(!0),w(re),b(y.type||"image")},className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:i.jsx(lr,{size:20})}):null]},String(re)||z)})})}):null]})}),i.jsx(mr,{isOpen:pe,onClose:()=>j(!1),src:N||"",type:E||"image",detections:ut,priority:ie})]})},{key:"track",label:"Track Incident",children:i.jsx($l,{alertId:fe,id:Te,priority:ie,spaceName:W,alertNumber:Ne,statusHistory:Ke,notifGroups:Y})}]})})};function va(){const{alerts:t}=Ue(),e=pt.useQuery({queryKey:["alerts","statusList"],queryFn:()=>t.getAlertStatusList(),staleTime:5*6e4});return{list:e.data??[],loading:e.isLoading,error:e.error,refetch:e.refetch}}function cn({alerts:t,loading:e=!1,columns:s,total:n,currentPage:r,onRefetch:a,onPageChange:o,onFilterChange:l,onAlertView:c}){const[u,f]=d.useState(!1),[m,S]=d.useState(null),[g,A]=d.useState("details"),{list:T,loading:x}=va(),{timeZoneDetails:P}=Ss(),Y=P?.timeZoneName??"UTC",J=P?.ianaTimeZoneId??"UTC";function I(M,X){S(M),A(X?.tab??"details"),O(X?.sourceTab??"active"),f(!0)}function U(){f(!1)}const[Z,O]=d.useState("active"),[H,p]=d.useState(0),v=m?{originalData:{...m,alertId:m.alertId??m.id,mediaDetails:m.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(pa,{label:Y,timeZone:J})})]}),i.jsx(h.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:M=>{const X=M==="archived";p(pe=>pe+1),o?.(1),l?.({isArchived:X})},items:[{key:"active",label:"Active",children:i.jsx(Qs,{data:t,loading:e,pageSize:10,total:n,currentPage:r,columns:s||[],onAlertIdClick:I,onAlertView:c,onRefetch:a,onPageChange:o,onFilterChange:l,resetKey:H})},{key:"archived",label:"Archived",children:i.jsx(ya,{alerts:t,loading:e,columns:s||[],total:n,currentPage:r,onAlertIdClick:I,onAlertView:c,onFilterChange:l,onPageChange:o,onRefetch:a,resetKey:H})},{key:"settings",label:"Settings",children:i.jsx(zl,{})}]}),i.jsx(Zl,{isModalOpen:u,handleModalClose:U,selectedRow:v,fetchAlertLogs:()=>{},alertStatusList:T,alertStatusLoading:x,initialTab:g,sourceTab:Z,onAlertView:c})]})}function zl(){const[t,e]=d.useState([]),[s,n]=d.useState([]),[r,a]=d.useState([]),[o,l]=d.useState([]),[c,u]=d.useState(!0),{rules:f}=Ue();return d.useEffect(()=>{let m=!0;return(async()=>{try{const S=await f.getRules();if(!m)return;l(Array.isArray(S)?S:[]);const g=(S||[]).map((A,T)=>({RuleId:A.ruleId||A.ruleName||String(T),Name:A.ruleName||A.Name||"-",Description:A.ruleDesc||A.Description||"",SeverityId:0}));e(g);try{const A=await f.getLookups(),T=Array.isArray(A?.userRoles)?A.userRoles.map(x=>({userRoleId:x.userRoleId??x.id,userRoleName:x.userRoleName??x.name})):[];n(T),a(Array.isArray(A?.severities)?A.severities:[])}catch{}}catch{}finally{m&&u(!1)}})(),()=>{m=!1}},[]),i.jsx(xa,{severities:r,rules:t,userRoles:s,rawRules:o,loadingRules:c})}function Hl(t){return Array.isArray(t)?{items:t}:t}function wa(t=1,e){const{alerts:s,config:n}=Ue(),r=n.tenant==="schools"&&!!String(e?.searchText??"").trim(),a=pt.useQuery({queryKey:["alerts","list",n.tenant,t,e],queryFn:()=>{const o={...e};return n.tenant==="schools"?(o.pageNumber=t,o.pageSize=r?100:10):(o.pageNumber=t,o.pageSize=10),s.listAlerts(o).then(Hl)},staleTime:r?0:3e4});return{alerts:a.data?.items??[],total:a.data?.total,loading:a.isLoading,error:a.error,refetch:a.refetch}}function ql(t){const[e,s]=d.useState(1),[n,r]=d.useState({}),{alerts:a,total:o,loading:l,refetch:c}=wa(e,n);d.useEffect(()=>{!l&&a.length>0&&t.onAlertView?.(a)},[a,l]);const u=f=>{"isArchived"in f?r({isArchived:f.isArchived}):r(m=>({...m,...f}))};return i.jsx(cn,{alerts:a,loading:l,columns:t.columns,total:o,currentPage:e,onRefetch:c,onPageChange:s,onFilterChange:u,onAlertView:t.onAlertView})}function Gl({tenant:t,apiDomain:e,rulesDomain:s,headers:n,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,alerts:l,loading:c,columns:u,onAlertView:f}){const[m]=d.useState(()=>new pt.QueryClient({defaultOptions:{queries:{retry:(g,A)=>{const T=A.response?.status??A?.status;return T>=400&&T<=500?!1:g<2},refetchOnWindowFocus:!1}}})),S=d.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return i.jsx(pt.QueryClientProvider,{client:m,children:i.jsx(nr,{tenant:t,override:S,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,children:Array.isArray(l)?i.jsx(cn,{alerts:l,loading:!!c,columns:u,onAlertView:f}):i.jsx(ql,{columns:u,onAlertView:f})})})}function Yl(t){const{alerts:e}=Ue(),s=pt.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 _l=[{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=ga;exports.AlertConsole=cn;exports.AlertConsoleWidget=Gl;exports.AlertsTable=Qs;exports.ApiProvider=nr;exports.ArchivedTable=ya;exports.Clock=pa;exports.DataTable=rr;exports.MyPreferencesPanel=Dl;exports.SettingsPanel=Sa;exports.SettingsTabs=xa;exports.exampleAlertColumns=_l;exports.useAlertStatusList=va;exports.useAlerts=wa;exports.useAlertsReport=Yl;exports.useApi=Ue;exports.useUpdateAlertStatus=Xs;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|