@ssgc/alert-console 2.9.5 → 2.9.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),d=require("react"),f=require("antd"),yt=require("@ant-design/icons"),we=require("react-toastify"),pt=require("@tanstack/react-query"),ga="#FF3B30",Sa="#FF9500",xa="#FFCC00",va="#34C759",Ht={critical:ga,high:Sa,medium:xa,low:va},cn={Critical:Ht.critical,High:Ht.high,Medium:Ht.medium,Low:Ht.low};function wa(t){return cn[t]||cn.Low}function un(t){if(!t||typeof t!="string")return 0;const e=t.trim().split(":");if(e.length!==3)return 0;const[s,n,r]=e,a=Number.parseInt(s,10),o=Number.parseInt(n,10),c=Number.parseFloat(r||"0"),l=Number.isFinite(a)?a:0,u=Number.isFinite(o)?o:0,m=Number.isFinite(c)?c:0;return l*3600+u*60+m}function dn(t){const e=t.thirdPartyIds??t.ThirdPartyIds??t.thirdPartyId??t.ThirdPartyId??"",s=Array.isArray(e)?e.join(","):String(e??"");if(!s||!s.trim())return[];const n=s.split(",").map(o=>parseInt(String(o).trim(),10)).filter(o=>Number.isFinite(o)),r=new Set,a=[];return n.forEach(o=>{r.has(o)||(r.add(o),a.push(o))}),a}function os(t){return t.toLowerCase().replaceAll("'","").replaceAll("‘","").replaceAll("’","")}const Jn="",Aa=Jn,Ta="",Na="",ba="",ka="",mn={snl:{alerts:Jn,rules:Aa},schools:{alerts:Ta,rules:Na},transit:{alerts:ba,rules:ka}};function Ce(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ia(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function qt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function De(t,e){const s={...e.headers,...Ia()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Ea(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=Ce(t.baseUrl,"/api/Alert"),n=await De(s,{method:"GET",headers:e});return Array.isArray(n)?n:[]},async getAlertStatusList(){const s=Ce(t.baseUrl,"/api/Alert/AlertStatusList"),n=await De(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getAlertsReport(s){const n=Ce(t.baseUrl,"/Alerts/GetAlertsReport"),r=qt(n,s),a=await De(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Ce(t.baseUrl,"/api/Alert/status");return De(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=Ce(t.baseUrl,"/api/Alert/GetAdminSettings"),n=await De(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("userId"in n)return n}return null},async setAdminSettings(s){const n=Ce(t.baseUrl,"/api/Alert/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return De(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Ce(t.baseUrl,"/api/Alert/GetPreferenceSettings"),n=await De(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=Ce(t.baseUrl,"/api/Alert/SetPreferenceSettings"),r=await De(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,o=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":r?.errorMessage??r?.message??"",statusCode:200,data:o}},async getAlertNotifications(s){const n=Ce(t.baseUrl,"/api/Alert/GetNotifications"),r=qt(n,{alertId:s}),a=await De(r,{method:"GET",headers:e});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]},async notifyFamilyMembers(s){const n=Ce(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=qt(n,{alertId:s});return De(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const a=Ce(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),o=qt(a,{alertId:s,isEmail:n,isSMS:r});return De(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Ce(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await De(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Ce(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await De(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null}}}function fn(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ma(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Gt(t,e){const s={...e.headers,...Ma()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Oa(t){const e={"Content-Type":"application/json",...t.headers||{}},s=fn(t.baseUrl,"/api/Rules"),n=fn(t.baseUrl,"/api/Rules/lookups");return{async getRules(){const r=await Gt(s,{method:"GET",headers:e});return Array.isArray(r)?r:[]},async setEscalationSettings(r){return Gt(s,{method:"POST",headers:e,body:JSON.stringify(r??{})})},async getLookups(){return Gt(n,{method:"GET",headers:e})},async updateRule(r,a){const o=`${s}/${r}`;return Gt(o,{method:"PUT",headers:e,body:JSON.stringify(a??{})})}}}function ja(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ns={exports:{}},Ca=ns.exports,hn;function Da(){return hn||(hn=1,(function(t,e){(function(s,n){t.exports=n()})(Ca,(function(){var s=1e3,n=6e4,r=36e5,a="millisecond",o="second",c="minute",l="hour",u="day",m="week",h="month",S="quarter",g="year",b="date",C="Invalid Date",D=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,q=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,F={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(L){var w=["th","st","nd","rd"],v=L%100;return"["+L+(w[(v-20)%10]||w[v]||w[0])+"]"}},$=function(L,w,v){var E=String(L);return!E||E.length>=w?L:""+Array(w+1-E.length).join(v)+L},T={s:$,z:function(L){var w=-L.utcOffset(),v=Math.abs(w),E=Math.floor(v/60),A=v%60;return(w<=0?"+":"-")+$(E,2,"0")+":"+$(A,2,"0")},m:function L(w,v){if(w.date()<v.date())return-L(v,w);var E=12*(v.year()-w.year())+(v.month()-w.month()),A=w.clone().add(E,h),U=v-A<0,P=w.clone().add(E+(U?-1:1),h);return+(-(E+(v-A)/(U?A-P:P-A))||0)},a:function(L){return L<0?Math.ceil(L)||0:Math.floor(L)},p:function(L){return{M:h,y:g,w:m,d:u,D:b,h:l,m:c,s:o,ms:a,Q:S}[L]||String(L||"").toLowerCase().replace(/s$/,"")},u:function(L){return L===void 0}},O="en",W={};W[O]=F;var R="$isDayjsObject",H=function(L){return L instanceof oe||!(!L||!L[R])},p=function L(w,v,E){var A;if(!w)return O;if(typeof w=="string"){var U=w.toLowerCase();W[U]&&(A=U),v&&(W[U]=v,A=U);var P=w.split("-");if(!A&&P.length>1)return L(P[0])}else{var G=w.name;W[G]=w,A=G}return!E&&A&&(O=A),A||!E&&O},x=function(L,w){if(H(L))return L.clone();var v=typeof w=="object"?w:{};return v.date=L,v.args=arguments,new oe(v)},j=T;j.l=p,j.i=H,j.w=function(L,w){return x(L,{locale:w.$L,utc:w.$u,x:w.$x,$offset:w.$offset})};var oe=(function(){function L(v){this.$L=p(v.locale,null,!0),this.parse(v),this.$x=this.$x||v.x||{},this[R]=!0}var w=L.prototype;return w.parse=function(v){this.$d=(function(E){var A=E.date,U=E.utc;if(A===null)return new Date(NaN);if(j.u(A))return new Date;if(A instanceof Date)return new Date(A);if(typeof A=="string"&&!/Z$/i.test(A)){var P=A.match(D);if(P){var G=P[2]-1||0,J=(P[7]||"0").substring(0,3);return U?new Date(Date.UTC(P[1],G,P[3]||1,P[4]||0,P[5]||0,P[6]||0,J)):new Date(P[1],G,P[3]||1,P[4]||0,P[5]||0,P[6]||0,J)}}return new Date(A)})(v),this.init()},w.init=function(){var v=this.$d;this.$y=v.getFullYear(),this.$M=v.getMonth(),this.$D=v.getDate(),this.$W=v.getDay(),this.$H=v.getHours(),this.$m=v.getMinutes(),this.$s=v.getSeconds(),this.$ms=v.getMilliseconds()},w.$utils=function(){return j},w.isValid=function(){return this.$d.toString()!==C},w.isSame=function(v,E){var A=x(v);return this.startOf(E)<=A&&A<=this.endOf(E)},w.isAfter=function(v,E){return x(v)<this.startOf(E)},w.isBefore=function(v,E){return this.endOf(E)<x(v)},w.$g=function(v,E,A){return j.u(v)?this[E]:this.set(A,v)},w.unix=function(){return Math.floor(this.valueOf()/1e3)},w.valueOf=function(){return this.$d.getTime()},w.startOf=function(v,E){var A=this,U=!!j.u(E)||E,P=j.p(v),G=function(xe,ae){var le=j.w(A.$u?Date.UTC(A.$y,ae,xe):new Date(A.$y,ae,xe),A);return U?le:le.endOf(u)},J=function(xe,ae){return j.w(A.toDate()[xe].apply(A.toDate("s"),(U?[0,0,0,0]:[23,59,59,999]).slice(ae)),A)},te=this.$W,ne=this.$M,Q=this.$D,Se="set"+(this.$u?"UTC":"");switch(P){case g:return U?G(1,0):G(31,11);case h:return U?G(1,ne):G(0,ne+1);case m:var ie=this.$locale().weekStart||0,me=(te<ie?te+7:te)-ie;return G(U?Q-me:Q+(6-me),ne);case u:case b:return J(Se+"Hours",0);case l:return J(Se+"Minutes",1);case c:return J(Se+"Seconds",2);case o:return J(Se+"Milliseconds",3);default:return this.clone()}},w.endOf=function(v){return this.startOf(v,!1)},w.$set=function(v,E){var A,U=j.p(v),P="set"+(this.$u?"UTC":""),G=(A={},A[u]=P+"Date",A[b]=P+"Date",A[h]=P+"Month",A[g]=P+"FullYear",A[l]=P+"Hours",A[c]=P+"Minutes",A[o]=P+"Seconds",A[a]=P+"Milliseconds",A)[U],J=U===u?this.$D+(E-this.$W):E;if(U===h||U===g){var te=this.clone().set(b,1);te.$d[G](J),te.init(),this.$d=te.set(b,Math.min(this.$D,te.daysInMonth())).$d}else G&&this.$d[G](J);return this.init(),this},w.set=function(v,E){return this.clone().$set(v,E)},w.get=function(v){return this[j.p(v)]()},w.add=function(v,E){var A,U=this;v=Number(v);var P=j.p(E),G=function(ne){var Q=x(U);return j.w(Q.date(Q.date()+Math.round(ne*v)),U)};if(P===h)return this.set(h,this.$M+v);if(P===g)return this.set(g,this.$y+v);if(P===u)return G(1);if(P===m)return G(7);var J=(A={},A[c]=n,A[l]=r,A[o]=s,A)[P]||1,te=this.$d.getTime()+v*J;return j.w(te,this)},w.subtract=function(v,E){return this.add(-1*v,E)},w.format=function(v){var E=this,A=this.$locale();if(!this.isValid())return A.invalidDate||C;var U=v||"YYYY-MM-DDTHH:mm:ssZ",P=j.z(this),G=this.$H,J=this.$m,te=this.$M,ne=A.weekdays,Q=A.months,Se=A.meridiem,ie=function(ae,le,Ae,Ue){return ae&&(ae[le]||ae(E,U))||Ae[le].slice(0,Ue)},me=function(ae){return j.s(G%12||12,ae,"0")},xe=Se||function(ae,le,Ae){var Ue=ae<12?"AM":"PM";return Ae?Ue.toLowerCase():Ue};return U.replace(q,(function(ae,le){return le||(function(Ae){switch(Ae){case"YY":return String(E.$y).slice(-2);case"YYYY":return j.s(E.$y,4,"0");case"M":return te+1;case"MM":return j.s(te+1,2,"0");case"MMM":return ie(A.monthsShort,te,Q,3);case"MMMM":return ie(Q,te);case"D":return E.$D;case"DD":return j.s(E.$D,2,"0");case"d":return String(E.$W);case"dd":return ie(A.weekdaysMin,E.$W,ne,2);case"ddd":return ie(A.weekdaysShort,E.$W,ne,3);case"dddd":return ne[E.$W];case"H":return String(G);case"HH":return j.s(G,2,"0");case"h":return me(1);case"hh":return me(2);case"a":return xe(G,J,!0);case"A":return xe(G,J,!1);case"m":return String(J);case"mm":return j.s(J,2,"0");case"s":return String(E.$s);case"ss":return j.s(E.$s,2,"0");case"SSS":return j.s(E.$ms,3,"0");case"Z":return P}return null})(ae)||P.replace(":","")}))},w.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},w.diff=function(v,E,A){var U,P=this,G=j.p(E),J=x(v),te=(J.utcOffset()-this.utcOffset())*n,ne=this-J,Q=function(){return j.m(P,J)};switch(G){case g:U=Q()/12;break;case h:U=Q();break;case S:U=Q()/3;break;case m:U=(ne-te)/6048e5;break;case u:U=(ne-te)/864e5;break;case l:U=ne/r;break;case c:U=ne/n;break;case o:U=ne/s;break;default:U=ne}return A?U:j.a(U)},w.daysInMonth=function(){return this.endOf(h).$D},w.$locale=function(){return W[this.$L]},w.locale=function(v,E){if(!v)return this.$L;var A=this.clone(),U=p(v,E,!0);return U&&(A.$L=U),A},w.clone=function(){return j.w(this.$d,this)},w.toDate=function(){return new Date(this.valueOf())},w.toJSON=function(){return this.isValid()?this.toISOString():null},w.toISOString=function(){return this.$d.toISOString()},w.toString=function(){return this.$d.toUTCString()},L})(),re=oe.prototype;return x.prototype=re,[["$ms",a],["$s",o],["$m",c],["$H",l],["$W",u],["$M",h],["$y",g],["$D",b]].forEach((function(L){re[L[1]]=function(w){return this.$g(w,L[0],L[1])}})),x.extend=function(L,w){return L.$i||(L(w,oe,x),L.$i=!0),x},x.locale=p,x.isDayjs=H,x.unix=function(L){return x(1e3*L)},x.en=W[O],x.Ls=W,x.p={},x}))})(ns)),ns.exports}var Ra=Da();const Ua=ja(Ra);function Kn(t){if(!t)return"By Severity";const e=t.trim().toLowerCase();return e.includes("created")?"By Created Date":e.includes("updated")||e.includes("modified")?"By Updated Date":"By Severity"}function Qn(t){if(!t||typeof t!="string")return{hours:0,minutes:0,seconds:0};const e=t.split(":").map(a=>parseInt(a,10)),s=Number.isFinite(e[0])?e[0]:0,n=Number.isFinite(e[1])?e[1]:0,r=Number.isFinite(e[2])?e[2]:0;return{hours:s,minutes:n,seconds:r}}function yn(t){const{hours:e,minutes:s,seconds:n}=Qn(t);return Ua().hour(e).minute(s).second(n).millisecond(0)}function Oe(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function La(){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 je(t,e){const s={...e.headers,...La()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.Message||`HTTP ${n.status}`;throw new Error(o)}return a}const ue=(...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 Fa(t){return Array.isArray(t)?t.map(e=>Ut(e,["alertLogId","alertId","status","description","actionNotes","createdDate","createdBy","modifiedDate","modifiedBy"])):t}function $a(t){return{id:String(ue(t?.AlertId,t?.alertId)??""),alertNumber:ue(t?.AlertNumber,t?.alertNumber),priority:ue(t?.Priority,t?.priority,"Low"),timestamp:ue(t?.UpdatedUtc,t?.timestamp,""),statusType:ue(t?.Status,t?.statusType,""),description:ue(t?.Description,t?.description,""),eventName:ue(t?.EventName,t?.eventName),ruleName:ue(t?.RuleName,t?.ruleName),spaceId:ue(t?.SpaceId,t?.spaceId),spaceName:ue(t?.SpaceName,t?.spaceName),anomalyId:ue(t?.AnomalyId,t?.anomalyId),severityId:ue(t?.SeverityId,t?.severityId),assignTeam:ue(t?.AssignTeam,t?.assignTeam),cameraName:ue(t?.CameraName,t?.cameraName),type:ue(t?.Type,t?.type),mediaDetails:ue(t?.MediaDetails,t?.mediaDetails,t?.MediaUrls,t?.mediaUrls),additionalMedia:ue(t?.AdditionalMedia,t?.additionalMedia),timeElapsed:ue(t?.TimeElapsed,t?.timeElapsed),timeRemaining:ue(t?.TimeRemaining,t?.timeRemaining),anomalyName:ue(t?.AnomalyName,t?.anomalyName),alertDetails:ue(t?.AlertDetails,t?.alertDetails),statusHistory:Fa(ue(t?.StatusHistory,t?.statusHistory)),isEmailSent:ue(t?.IsEmailSent,t?.isEmailSent),isSMSSent:ue(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:ue(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function Pa(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Oe(t.baseUrl,"/api/detectionpolicy/alerts"),r=Yt(n,{customerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",pageSize:s?.pageSize??10,page:s?.pageNumber??1,...s?.anomalyId!==void 0&&{anomalyId:s.anomalyId},...s?.spaceId!==void 0&&{spaceId:s.spaceId},...s?.severityId!==void 0&&{severityId:s.severityId},...s?.thirdPartyIds?.length&&{ThirdPartyIds:s.thirdPartyIds.join(",")},...s?.searchText&&{searchText:s.searchText},isArchived:s?.isArchived??!1}),a=await je(r,{method:"GET",headers:e});return{items:Array.isArray(a?.Items)?a.Items.map($a):[],total:a?.Total}},async getAlertStatusList(){const s=Oe(t.baseUrl,"/api/detectionpolicy/alerts/StatusList"),n=await je(s,{method:"GET",headers:e});return(Array.isArray(n)?n:[]).map(a=>Ut(a,["alertStatusId","value","statusName"]))},async getAlertsReport(s){const n=Oe(t.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),r=Yt(n,s),a=await je(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Oe(t.baseUrl,"/api/detectionpolicy/alerts/Log"),r={AlertId:s.alertId??s.alertUniqueId??s.AlertId,Status:s.status??s.Status??"",Notes:s.notes??s.Notes??""};return je(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getAdminSettings(){const s=Oe(t.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),n=await je(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n.Data??n;if(r&&typeof r=="object")return Ut(r,["userId","isAdminSetting","sortBy"],{sortBy:"SortOption"})}return null},async setAdminSettings(s){const n=Oe(t.baseUrl,"/api/detectionpolicy/alerts/SetAdminSettings"),r={Settings:{UserId:0,IsAdminSetting:!0,SortOption:s?.sortBy??"",GroupBy:s?.groupBy??null}};return je(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Oe(t.baseUrl,"/api/detectionpolicy/alerts/GetPreferenceSettings"),n=await je(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=Oe(t.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),r=u=>{const{hours:m,minutes:h,seconds:S}=Qn(u);return(m*3600+h*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 je(n,{method:"POST",headers:e,body:JSON.stringify(a)}),c=o?.responseStatus??!0,l=o?.data??o?.message??"Preferences updated successfully.";return{responseStatus:c,errorMessage:c?"":o?.errorMessage??o?.Message??o?.message??"",statusCode:200,data:l}},async sendSMSorEmailNotifications(s,n,r){const a=Oe(t.baseUrl,"/api/detectionpolicy/alerts/SendSMSorEmailNotifications"),o=Yt(a,{alertId:s,isEmail:n,isSMS:r});return je(o,{method:"POST",headers:e})},async getAlertNotifications(s){const n=Oe(t.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),r=Yt(n,{alertId:s}),a=await je(r,{method:"GET",headers:e});let o=[];return Array.isArray(a)?o=a:Array.isArray(a?.data)&&(o=a.data),o.map(c=>Ut(c,["alertNotificationSentId","alertId","notificationType","receipientName","receipentPhoneNumber","messageSID","messageStatus","receipientEmail","notificationReceipientType","sentAt"]))},async getTimeZoneMasters(){const s=Oe(t.baseUrl,"/api/TimeZoneMaster"),n=await je(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n.Data:[]).map(a=>Ut(a,["timeZoneUniqueId","ianaTimeZoneId","timeZoneName","offset"]))},async getAllSpaces(){const s=t.spacesBaseUrl||t.baseUrl,n=Oe(s,"/api/AllSpaces"),r=await je(n,{method:"GET",headers:e});return(Array.isArray(r?.Data)?r.Data:[]).map(o=>({spaceId:o?.SpaceId??o?.spaceId,spaceName:o?.SpaceName??o?.spaceName??""}))},async getMyAppPreferences(){const s=Oe(t.baseUrl,"/MyProfile"),n=await je(s,{method:"GET",headers:e}),r=n?.data?.userGuid??n?.Data?.userGuid??n?.userGuid;if(!r)return null;const a=Oe(t.baseUrl,`/api/GetMyAppPreferences/${r}`),o=await je(a,{method:"GET",headers:e});if(o&&typeof o=="object"){const c=o.data??o.Data??o,l=c?.timeZoneUniqueId??c?.TimeZoneUniqueId;if(l)return{timeZoneUniqueId:l}}return null}}}function Wa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Ke(t,e){const s={...e.headers,...Wa()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Va(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/api/detectionpolicy/rules",t.baseUrl).toString();return{async getRules(){const n=await Ke(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 Ke(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=[Ke(n("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:e}),Ke(n("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:e}),Ke(n("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:e}),Ke(n("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:e}),Ke(n("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:e}),Ke(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,c,l,u,m,h]=await Promise.allSettled(a),S=p=>{if(p.status!=="fulfilled")return[];const x=p.value;return Array.isArray(x)?x:Array.isArray(x?.Data)?x.Data:Array.isArray(x?.data)?x.data:[]},g=S(o),b=S(c),C=S(l),D=S(u),q=S(m),F=h.status==="fulfilled"?h.value:null;let $=[];Array.isArray(F)?$=F:Array.isArray(F?.Data)?$=F.Data:Array.isArray(F?.data)&&($=F.data);const T=g.map(p=>({actionTypeId:Number(p?.ActionTypeId),name:p?.DisplayName??p?.Name??""})),O=b.map(p=>({recordId:p?.AnomalyId,anomalyName:p?.DisplayName??p?.Name??""})),W=C.map(p=>({thirdPartyId:Number(p?.ThirdPartyId),thirdPartyName:p?.ThirdPartyName??p?.Name??""})),R=$.map(p=>({userRoleId:p.UserRoleId??p.userRoleId??p.Id??p.id??0,userRoleName:p.UserRoleName??p.userRoleName??p.Name??p.name??""})),H={actionTypes:T,anomalies:O,thirdParties:W};return D.length&&(H.severities=D.map(p=>({severityId:p?.SeverityId??p?.severityId,severityName:p?.DisplayName??p?.SeverityName??p?.Name??p?.name??""}))),q.length&&(H.scheduleTypes=q),R.length&&(H.userRoles=R),H},async updateRule(n,r){const a=`${s}/${n}`,{escalationSettings:o,Anomaly:c,Severity:l,...u}=r??{};return Ke(a,{method:"PUT",headers:e,body:JSON.stringify({...u,CustomerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",Version:{DeDupWindowSeconds:0,IncludeSubjectInHash:!0},AnomalyId:c?.AnomalyId,SeverityId:l?.SeverityId,EscalationSettings:o?{...o,ThirdPartyIds:o.thirdPartyId??[]}:{}})})}}}function Ba(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function rt(t,e){const s={...e.headers,...Ba()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Za(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/list-rule",t.baseUrl).toString();return{async getRules(){const n=await rt(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 rt(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=R=>new URL(R,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[rt(n("/api/ActionTypeMaster/GetAll"),{method:"GET",headers:e}),rt(n("/api/anomaly/anomaly-list"),{method:"POST",headers:e,body:JSON.stringify({RuleLevel:1})}),rt(n("/api/Lookup/ThirdParties"),{method:"GET",headers:e}),rt(n("/api/anomaly/severity-list"),{method:"GET",headers:e}),rt(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,c,l,u,m]=await Promise.allSettled(a),h=R=>{if(R.status!=="fulfilled")return[];const H=R.value;return Array.isArray(H)?H:Array.isArray(H?.data)?H.data:[]},S=h(o),g=h(c),b=h(l),C=h(u),D=m.status==="fulfilled"?m.value:null,q=S.map(R=>({actionTypeId:R?.ActionTypeUniqueId,name:R?.Name??""})),F=g.map(R=>({recordId:R?.AnomalyId,anomalyName:R?.DisplayName??R?.Name??""})),$=b.map(R=>({thirdPartyId:Number(R?.ThirdPartyId),thirdPartyName:R?.ThirdPartyName??R?.Name??""}));let T=[];Array.isArray(D)?T=D:Array.isArray(D?.Data)?T=D.Data:Array.isArray(D?.data)&&(T=D.data);const O=T.map(R=>({userRoleId:R.userRoleId??0,userRoleName:R.userRoleName??""})),W={actionTypes:q,anomalies:F,thirdParties:$};return C.length&&(W.severities=C.map(R=>({SeverityId:R.SeverityId,DisplayName:R.SeverityName??R.DisplayName??""}))),O.length&&(W.userRoles=O),W},async updateRule(n,r){const a=new URL("/update-rule",t.baseUrl).toString(),{escalationSettings:o,ruleId:c,ruleName:l,ruleDesc:u,...m}=r??{},h=o??{},S=(h.escalationSettingsActionTypeIds??[]).filter(b=>b!=null&&!Number.isNaN(b)),g={Level1UserRoleId:h.level1UserRoleId??0,Level1PostAssistTime:h.level1PostAssistTime??0,Level2UserRoleId:h.level2UserRoleId??0,Level2PostAssistTime:h.level2PostAssistTime??0,Level3UserRoleId:h.level3UserRoleId??0,Level3PostAssistTime:h.level3PostAssistTime??0,EscalationSettingsActionTypeIds:S,ThirdPartyIds:h.thirdPartyId??[],HumanLoop:h.humanLoop??!1};return rt(a,{method:"POST",headers:e,body:JSON.stringify({...m,RuleId:c??m.RuleId??n,RuleName:l??m.RuleName,RuleDesc:u??m.RuleDesc??null,ActionTypeUniqueIdList:S,EscalationSettings:g})})}}}function $e(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function za(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function _t(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Pe(t,e){const s={...e.headers,...za()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Ha(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=$e(t.baseUrl,"/api/Alerts"),r=_t(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 Pe(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=$e(t.baseUrl,"/api/Alerts/GetAlertStatus"),n=await Pe(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=$e(t.baseUrl,"/Alerts/GetAlertsReport"),r=_t(n,s),a=await Pe(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=$e(t.baseUrl,"/api/Alerts/UpdateAlertLog"),r={alertId:s.alertId,action:s.status,notes:s.notes};return Pe(n,{method:"PUT",headers:e,body:JSON.stringify(r??{})})},async getAdminSettings(){const s=$e(t.baseUrl,"/api/Alerts/GetAdminSettings"),n=await Pe(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=$e(t.baseUrl,"/api/Alerts/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Pe(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=$e(t.baseUrl,"/api/Alerts/GetPreferenceSettings"),n=await Pe(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=$e(t.baseUrl,"/api/Alerts/SetPreferenceSettings"),r=await Pe(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=$e(t.baseUrl,"/api/Alerts/GetNotifications"),r=_t(n,{alertId:s}),a=await Pe(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=$e(t.baseUrl,"/api/Alerts/SendSMSorEmailNotifications"),o=_t(a,{alertId:s,isEmail:n,isSMS:r});return Pe(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=$e(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Pe(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=$e(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Pe(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null}}}const Xn=d.createContext(null);function er({tenant:t="snl",override:e,timeZone:s,userManagementDomain:n,spacesBaseUrl:r,children:a}){const o=d.useMemo(()=>{const l=e?.alertsBaseUrl?.trim()||mn[t]?.alerts||"";let u=e?.rulesBaseUrl?.trim()||mn[t]?.rules||"";t==="snl"&&(u=l);const m=e?.headers;return{tenant:t,alertsBaseUrl:l,rulesBaseUrl:u,headers:m,timeZone:s,userManagementDomain:n,spacesBaseUrl:r}},[t,e?.alertsBaseUrl,e?.rulesBaseUrl,JSON.stringify(e?.headers||{}),s,n,r]),c=d.useMemo(()=>{const l={baseUrl:o.alertsBaseUrl,headers:o.headers},u={baseUrl:o.rulesBaseUrl,headers:o.headers},m={schools:()=>Pa({...l,spacesBaseUrl:o.spacesBaseUrl}),transit:()=>Ha(l),snl:()=>Ea(l)},h={schools:()=>Va({...u,userManagementBaseUrl:o.userManagementDomain}),transit:()=>Za({...u,userManagementBaseUrl:o.userManagementDomain}),snl:()=>Oa({baseUrl:o.alertsBaseUrl,headers:o.headers})};return{config:o,alerts:m[o.tenant](),rules:h[o.tenant]()}},[o]);return i.jsx(Xn.Provider,{value:c,children:a})}function Me(){const t=d.useContext(Xn);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}const qa={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Ga={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Ys=6,_s=7;function pn(t,e,s){const n=t===Ys,r=t===_s,a=e.isEmailSent??!1,o=e.isSMSSent??!1,c=n&&a||r&&o,l=n?"Send Email":r?"Send SMS":s,u=n&&a?"Email sent":r&&o?"SMS sent":l,m=n&&a?"Email sent":r&&o?"SMS sent":`Click to ${l}`;return{isDisabled:c,buttonText:u,tooltipTitle:m}}function Ya(t){const e=new Set;(t||[]).forEach(n=>{const r=n.anomalyName;typeof r=="string"&&r.trim().length>0&&e.add(r.trim())});const s=Array.from(e).map(n=>({label:n,value:n}));return[{label:"All Types",value:"All"},...s]}function _a(t,e=!1){const s=new Set;(t||[]).forEach(r=>{const a=e?r.spaceNumber??r.spaceName:r.spaceName;typeof a=="string"&&a.trim().length>0&&s.add(a.trim())});const n=Array.from(s).map(r=>({label:r,value:r}));return[{label:"All",value:"All"},...n]}function Ts(t,e){return`${t}-${e?"email":"sms"}`}function Jt(t){return t===Ys||t===_s}function fs({value:t,onChange:e,options:s,className:n,dropdownWidth:r}){return i.jsx(f.Select,{className:n,options:s,value:t,onChange:e,dropdownMatchSelectWidth:r??260})}const Ja=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function Ka({value:t,onChange:e,options:s}){return i.jsx(fs,{className:"w-[140px]",value:t,onChange:e,options:s||Ja})}const Qa=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function Xa({value:t,onChange:e,options:s}){return i.jsx(fs,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||Qa})}function ei({value:t,onChange:e,options:s}){return i.jsx(fs,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const ti=[{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 si({value:t,onChange:e,options:s}){return i.jsx(fs,{className:"w-[130px]",value:t,onChange:e,options:s||ti})}function tr({columns:t,data:e,loading:s=!1,pageSize:n=10,total:r,currentPage:a,rowKey:o="id",toolbar:c,tableProps:l,onPageChange:u}){const h=r===void 0&&a!==void 0?e.length===n?a*n+1:(a-1)*n+e.length:void 0;return i.jsxs("div",{children:[c,i.jsx(f.Table,{rowKey:o,dataSource:e,columns:t,loading:s,pagination:{pageSize:n,current:a,total:r??h,showSizeChanger:!1,showTotal:S=>`Total: ${S}`,onChange:u},bordered:!0,...l})]})}function ni(t){if(!t||typeof t!="string")return!1;const e=t.split("?")[0].toLowerCase();return e.endsWith(".mp4")||e.endsWith(".webm")||e.endsWith(".ogg")||e.endsWith(".m3u8")}function Us(t){const e=(t?.mediaType||t?.type||"").toString().toLowerCase();return e==="video"||e==="mp4"?!0:ni(t?.mediaUrl||t)}function ri(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 sr(t){const e=t;return e?(Array.isArray(e)?e:[e]).flatMap(ri):[]}const ai=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ii=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),gn=t=>{const e=ii(t);return e.charAt(0).toUpperCase()+e.slice(1)},nr=(...t)=>t.filter((e,s,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===s).join(" ").trim(),oi=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var li={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 ci=d.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:a,iconNode:o,...c},l)=>d.createElement("svg",{ref:l,...li,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:nr("lucide",r),...!a&&!oi(c)&&{"aria-hidden":"true"},...c},[...o.map(([u,m])=>d.createElement(u,m)),...Array.isArray(a)?a:[a]]));const hs=(t,e)=>{const s=d.forwardRef(({className:n,...r},a)=>d.createElement(ci,{ref:a,iconNode:e,className:nr(`lucide-${ai(gn(t))}`,`lucide-${t}`,n),...r}));return s.displayName=gn(t),s};const ui=[["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"}]],rr=hs("image-off",ui);const di=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],mi=hs("loader-circle",di);const fi=[["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"}]],ar=hs("maximize-2",fi);const hi=[["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"}]],yi=hs("minimize-2",hi),ir=({isOpen:t,onClose:e,src:s,type:n="image"})=>{const[r,a]=d.useState(!1),[o,c]=d.useState(!1);return d.useEffect(()=>{t&&c(!1)},[t,s]),d.useEffect(()=>{t&&(!s||o)&&e()},[t,s,o,e]),t?i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-70",role:"button",tabIndex:0,"aria-label":"Close media preview",onClick:e,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),e())},onTouchStart:e,children:i.jsxs("div",{className:`relative ${r?"w-full h-full":"max-w-5xl max-h-[90vh] w-full"} flex items-center justify-center`,onClick:l=>l.stopPropagation(),children:[n==="image"?i.jsx("img",{src:s,alt:"preview",className:`object-contain rounded-lg shadow-lg ${r?"w-full h-full":"max-w-full max-h-[90vh]"}`,onError:()=>c(!0)}):i.jsx("video",{src:s,controls:!0,className:`object-contain rounded-lg shadow-lg ${r?"w-full h-full":"max-w-full max-h-[90vh]"}`,onError:()=>c(!0)}),i.jsx("button",{onClick:e,className:"absolute top-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:"✕"}),i.jsx("button",{onClick:()=>a(!r),className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:r?i.jsx(yi,{size:20}):i.jsx(ar,{size:20})})]})}):null};function pi(t){const s=sr(t.mediaDetails)[0];if(!s)return null;const n=s.mediaUrl??s;return typeof n!="string"||!n.length?null:{url:n,item:s}}function or({record:t}){const e=d.useMemo(()=>pi(t),[t]),[s,n]=d.useState(!1),[r,a]=d.useState(!1);if(d.useEffect(()=>{a(!1)},[e?.url]),!e)return i.jsx("span",{className:"text-gray-400 text-sm",children:"—"});const{url:o,item:c}=e,l=Us(c),u=l?"video":"image",m="block w-[72px] h-[54px] object-cover bg-gray-100 border border-gray-200 rounded-sm";return i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",disabled:r,className:"p-0 border-0 bg-transparent rounded-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-1 cursor-pointer disabled:cursor-not-allowed disabled:opacity-60","aria-label":r?"Preview unavailable":"Expand preview",onClick:()=>n(!0),children:r?i.jsx("span",{className:`${m} flex items-center justify-center text-gray-400`,children:i.jsx(rr,{size:20,"aria-hidden":!0})}):l?i.jsx("video",{src:o,className:m,muted:!0,playsInline:!0,preload:"metadata",onError:()=>a(!0)}):i.jsx("img",{src:o,alt:"",className:m,onError:()=>a(!0)})}),i.jsx(ir,{isOpen:s,onClose:()=>n(!1),src:o,type:u})]})}const lr=["completed","false positive","face doesn't match name","safe","supervised exit","elopement confirmed"];function gi(t,e){const[s,n]=d.useState(t);return d.useEffect(()=>{const r=window.setTimeout(()=>n(t),e);return()=>window.clearTimeout(r)},[t,e]),s}function Js({data:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,columns:a,severityOptions:o,anomalyOptions:c,spaceOptions:l,renderActions:u,onAlertIdClick:m,onRefetch:h,onPageChange:S,onFilterChange:g,excludeCompleted:b=!0,resetKey:C,serverSideFilters:D=!1}){const[q,F]=d.useState("All"),[$,T]=d.useState("All"),[O,W]=d.useState("All"),[R,H]=d.useState("All"),[p,x]=d.useState("");d.useEffect(()=>{C!==void 0&&(F("All"),T("All"),W("All"),H("All"),x(""))},[C]);const[j,oe]=d.useState([{label:"All",value:"All"}]),[re,L]=d.useState([]),[w,v]=d.useState([]),[E,A]=d.useState([]),[U,P]=d.useState(new Set),{rules:G,alerts:J,config:te}=Me(),ne=te.tenant==="schools",Q=te.tenant==="transit",Se=gi(p,600),ie={6:{title:"Email",kind:"icon",icon:i.jsx(yt.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:i.jsx(yt.MessageOutlined,{})}},me=d.useMemo(()=>Ya(t),[t]),xe=d.useMemo(()=>_a(t,Q),[t,Q]);d.useEffect(()=>{if(!J.getAllSpaces)return;let X=!0;return(async()=>{try{const Z=await J.getAllSpaces();if(X){const ye=Z.map(de=>({label:Q?String(de.spaceNumber??de.spaceName??""):de.spaceName,value:String(Q?de.spaceNumber??de.spaceId:de.spaceId)}));L([{label:"All",value:"All"},...ye])}}catch(Z){console.error("Error loading space options",Z)}})(),()=>{X=!1}},[J,Q]),d.useEffect(()=>{let X=!0;return(async()=>{try{const Z=await G.getLookups(),de=(Array.isArray(Z.thirdParties)?Z.thirdParties:[]).map(ve=>({label:ve.thirdPartyName,value:String(ve.thirdPartyId)})),ge=(Array.isArray(Z.anomalies)?Z.anomalies:[]).map(ve=>({label:ve.anomalyName,value:String(ve.recordId)})),Fe=(Array.isArray(Z.severities)?Z.severities:[]).map(ve=>({label:ve.severityName,value:String(ve.severityId)}));X&&(oe([{label:"All",value:"All"},...de]),ge.length&&v([{label:"All Types",value:"All"},...ge]),Fe.length&&A([{label:"All levels",value:"All"},...Fe]))}catch(Z){console.error("Error loading filter options",Z)}})(),()=>{X=!1}},[G]);const ae=d.useMemo(()=>(t||[]).some(X=>dn(X).length>0),[t]);d.useEffect(()=>{if(!g)return;const X={anomalyId:w.length>1&&$!=="All"?$:void 0,spaceId:!Q&&re.length>1&&O!=="All"?Number(O):void 0,spaceNumber:Q&&re.length>1&&O!=="All"?O:void 0,severityId:E.length>1&&q!=="All"?Number(q):void 0,thirdPartyIds:R==="All"?void 0:[Number(R)],searchText:ne&&Se.trim()||void 0};g(X),S?.(1)},[$,O,q,R,Se,w.length,re.length,E.length,Q,ne]);const le=d.useMemo(()=>{const X=D;return(t||[]).filter(Z=>{const ye=X||q==="All"||Z.priority===q,de=`${Z.id} ${Z.alertNumber} ${Z.description} ${Z.statusType}`.toLowerCase(),Te=!p||de.includes(p.toLowerCase()),ge=X||$==="All"||(Z.anomalyName||"").toLowerCase()===$.toLowerCase(),Ze=X||O==="All"||(Z.spaceName||"").toLowerCase()===O.toLowerCase(),Fe=X||!ae||R==="All"||dn(Z).includes(Number(R)),ve=os(String(Z.statusType||"")),ut=!b||!lr.some(dt=>ve.includes(os(dt)));return ye&&Te&&ge&&Ze&&Fe&&ut})},[t,q,p,$,O,R,ae,b,D]),Ae=c?.length?c:me,Ue=D&&w.length>1?w:Ae,Le=l?.length?l:xe,tt=D&&re.length>1?re:Le,st=D&&E.length>1?E:o,St=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:X=>i.jsx(f.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Ga[X]}`,backgroundColor:qa[X]},children:X})},{title:"Tracker",key:"tracker",width:140,render:(X,Z)=>i.jsx("a",{onClick:ye=>{ye.preventDefault(),m?.(Z,{tab:"track",sourceTab:"active"})},className:"text-blue-600 hover:underline",children:"Tracker"})},{title:"Call to action/Human in the loop",key:"actions",width:320,render:(X,Z)=>{if(u)return i.jsx(i.Fragment,{children:u(Z)});const ye=async(nt,wt)=>{const At=Ts(Z.id,nt);P(k=>new Set(k).add(At));try{const k=await J.sendSMSorEmailNotifications?.(Z.id,nt,wt);k?.responseStatus||k?.Success||k?.success?(we.toast.success(k?.message||k.data||(nt?"Email sent successfully":"SMS sent successfully")),h?.()):we.toast.error(k?.message||k?.data||k?.errorMessage||"Failed to send notification")}catch(k){we.toast.error(k?.message||"Failed to send notification")}finally{P(k=>{const Y=new Set(k);return Y.delete(At),Y})}},de=Ys,Te=_s,ge=ie[de],Ze=ie[Te],Fe=pn(de,Z,ge?.title),ve=pn(Te,Z,Ze?.title),ut=Ts(Z.id,!0),dt=Ts(Z.id,!1),xt=Jt(de)&&U.has(ut),vt=Jt(Te)&&U.has(dt);return i.jsxs(f.Space,{size:"middle",children:[i.jsx(f.Tooltip,{title:Fe.tooltipTitle,children:i.jsx(f.Button,{size:"small",disabled:Fe.isDisabled,loading:xt,onClick:Jt(de)?()=>ye(!0,!1):void 0,icon:!xt&&ge?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:Fe.buttonText})},String(de)),i.jsx(f.Tooltip,{title:ve.tooltipTitle,children:i.jsx(f.Button,{size:"small",disabled:ve.isDisabled,loading:vt,onClick:Jt(Te)?()=>ye(!1,!0):void 0,icon:!vt&&Ze?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:ve.buttonText})},String(Te))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(X,Z)=>{const ye=Z?.timeElapsed,de=Z?.timeRemaining,Te=ye?un(ye):0,ge=de?un(de):0,Ze=Math.round(Te/(Te+ge)*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:ye??"-"})]}),i.jsx(f.Progress,{percent:Ze,showInfo:!1,size:"small",strokeColor:wa(Z.priority)}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-[70px]",children:"Remaining"}),i.jsx("span",{className:"font-medium",children:de??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(X,Z)=>i.jsxs("div",{children:[i.jsx("a",{onClick:ye=>{ye.preventDefault(),m?.(Z,{sourceTab:"active"})},className:"inline-block mb-1 text-blue-600",children:Z.alertNumber}),i.jsx("div",{className:"text-black/65",children:X})]})},{title:"Preview",key:"preview",width:100,align:"center",render:(X,Z)=>i.jsx(or,{record:Z})}],ct=a&&a.length?a:St;return i.jsx("div",{children:i.jsx(tr,{rowKey:"id",data:le,columns:ct,loading:e,pageSize:s,total:n,currentPage:r,onPageChange:S,toolbar:i.jsxs(f.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[i.jsx(f.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Severity"}),i.jsx(Ka,{value:q,onChange:F,options:st})]})}),i.jsx(f.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Anomaly type"}),i.jsx(Xa,{value:$,onChange:T,options:Ue})]})}),i.jsx(f.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:Q?"Bus Number":"Space"}),i.jsx(ei,{value:O,onChange:W,options:tt})]})}),i.jsx(f.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Action Taken"}),i.jsx(si,{value:R,onChange:H,options:j})]})}),i.jsx(f.Col,{flex:"auto"}),i.jsx(f.Col,{flex:"none",children:i.jsx(f.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:x,onChange:X=>x(X.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}function Ks(){const{alerts:t}=Me(),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 Si extends gt{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class xi extends gt{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class vi extends gt{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class kt extends gt{}class cr extends gt{constructor(e){super(`Invalid unit ${e}`)}}class Ne extends gt{}class at extends gt{constructor(){super("Zone is an abstract class")}}const N="numeric",Ye="short",Re="long",ls={year:N,month:N,day:N},ur={year:N,month:Ye,day:N},wi={year:N,month:Ye,day:N,weekday:Ye},dr={year:N,month:Re,day:N},mr={year:N,month:Re,day:N,weekday:Re},fr={hour:N,minute:N},hr={hour:N,minute:N,second:N},yr={hour:N,minute:N,second:N,timeZoneName:Ye},pr={hour:N,minute:N,second:N,timeZoneName:Re},gr={hour:N,minute:N,hourCycle:"h23"},Sr={hour:N,minute:N,second:N,hourCycle:"h23"},xr={hour:N,minute:N,second:N,hourCycle:"h23",timeZoneName:Ye},vr={hour:N,minute:N,second:N,hourCycle:"h23",timeZoneName:Re},wr={year:N,month:N,day:N,hour:N,minute:N},Ar={year:N,month:N,day:N,hour:N,minute:N,second:N},Tr={year:N,month:Ye,day:N,hour:N,minute:N},Nr={year:N,month:Ye,day:N,hour:N,minute:N,second:N},Ai={year:N,month:Ye,day:N,weekday:Ye,hour:N,minute:N},br={year:N,month:Re,day:N,hour:N,minute:N,timeZoneName:Ye},kr={year:N,month:Re,day:N,hour:N,minute:N,second:N,timeZoneName:Ye},Ir={year:N,month:Re,day:N,weekday:Re,hour:N,minute:N,timeZoneName:Re},Er={year:N,month:Re,day:N,weekday:Re,hour:N,minute:N,second:N,timeZoneName:Re};class Vt{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 Ns=null;class ys extends Vt{static get instance(){return Ns===null&&(Ns=new ys),Ns}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Pr(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 Ls=new Map;function Ti(t){let e=Ls.get(t);return e===void 0&&(e=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),Ls.set(t,e)),e}const Ni={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function bi(t,e){const s=t.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(s),[,r,a,o,c,l,u,m]=n;return[o,r,a,c,l,u,m]}function ki(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:a,value:o}=s[r],c=Ni[a];a==="era"?n[c]=o:B(c)||(n[c]=parseInt(o,10))}return n}const bs=new Map;class et extends Vt{static create(e){let s=bs.get(e);return s===void 0&&bs.set(e,s=new et(e)),s}static resetCache(){bs.clear(),Ls.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch{return!1}}constructor(e){super(),this.zoneName=e,this.valid=et.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Pr(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=Ti(this.name);let[r,a,o,c,l,u,m]=n.formatToParts?ki(n,s):bi(n,s);c==="BC"&&(r=-Math.abs(r)+1);const S=gs({year:r,month:a,day:o,hour:l===24?0:l,minute:u,second:m,millisecond:0});let g=+s;const b=g%1e3;return g-=b>=0?b:1e3+b,(S-g)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let Sn={};function Ii(t,e={}){const s=JSON.stringify([t,e]);let n=Sn[s];return n||(n=new Intl.ListFormat(t,e),Sn[s]=n),n}const Fs=new Map;function $s(t,e={}){const s=JSON.stringify([t,e]);let n=Fs.get(s);return n===void 0&&(n=new Intl.DateTimeFormat(t,e),Fs.set(s,n)),n}const Ps=new Map;function Ei(t,e={}){const s=JSON.stringify([t,e]);let n=Ps.get(s);return n===void 0&&(n=new Intl.NumberFormat(t,e),Ps.set(s,n)),n}const Ws=new Map;function Mi(t,e={}){const{base:s,...n}=e,r=JSON.stringify([t,n]);let a=Ws.get(r);return a===void 0&&(a=new Intl.RelativeTimeFormat(t,e),Ws.set(r,a)),a}let Lt=null;function Oi(){return Lt||(Lt=new Intl.DateTimeFormat().resolvedOptions().locale,Lt)}const Vs=new Map;function Mr(t){let e=Vs.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),Vs.set(t,e)),e}const Bs=new Map;function ji(t){let e=Bs.get(t);if(!e){const s=new Intl.Locale(t);e="getWeekInfo"in s?s.getWeekInfo():s.weekInfo,"minimalDays"in e||(e={...Or,...e}),Bs.set(t,e)}return e}function Ci(t){const e=t.indexOf("-x-");e!==-1&&(t=t.substring(0,e));const s=t.indexOf("-u-");if(s===-1)return[t];{let n,r;try{n=$s(t).resolvedOptions(),r=t}catch{const l=t.substring(0,s);n=$s(l).resolvedOptions(),r=l}const{numberingSystem:a,calendar:o}=n;return[r,a,o]}}function Di(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function Ri(t){const e=[];for(let s=1;s<=12;s++){const n=V.utc(2009,s,1);e.push(t(n))}return e}function Ui(t){const e=[];for(let s=1;s<=7;s++){const n=V.utc(2016,11,13+s);e.push(t(n))}return e}function Kt(t,e,s,n){const r=t.listingMode();return r==="error"?null:r==="en"?s(e):n(e)}function Li(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||Mr(t.locale).numberingSystem==="latn"}class Fi{constructor(e,s,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;const{padTo:r,floor:a,...o}=n;if(!s||Object.keys(o).length>0){const c={useGrouping:!1,...n};n.padTo>0&&(c.minimumIntegerDigits=n.padTo),this.inf=Ei(e,c)}}format(e){if(this.inf){const s=this.floor?Math.floor(e):e;return this.inf.format(s)}else{const s=this.floor?Math.floor(e):sn(e,3);return pe(s,this.padTo)}}}class $i{constructor(e,s,n){this.opts=n,this.originalZone=void 0;let r;if(this.opts.timeZone)this.dt=e;else if(e.zone.type==="fixed"){const o=-1*(e.offset/60),c=o>=0?`Etc/GMT+${o}`:`Etc/GMT${o}`;e.offset!==0&&et.create(c).valid?(r=c,this.dt=e):(r="UTC",this.dt=e.offset===0?e:e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type==="system"?this.dt=e:e.zone.type==="iana"?(this.dt=e,r=e.zone.name):(r="UTC",this.dt=e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone);const a={...this.opts};a.timeZone=a.timeZone||r,this.dtf=$s(s,a)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(s=>{if(s.type==="timeZoneName"){const n=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...s,value:n}}else return s}):e}resolvedOptions(){return this.dtf.resolvedOptions()}}class Pi{constructor(e,s,n){this.opts={style:"long",...n},!s&&Fr()&&(this.rtf=Mi(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):oo(s,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,s){return this.rtf?this.rtf.formatToParts(e,s):[]}}const Or={firstDay:1,minimalDays:4,weekend:[6,7]};class se{static fromOpts(e){return se.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,s,n,r,a=!1){const o=e||he.defaultLocale,c=o||(a?"en-US":Oi()),l=s||he.defaultNumberingSystem,u=n||he.defaultOutputCalendar,m=zs(r)||he.defaultWeekSettings;return new se(c,l,u,m,o)}static resetCache(){Lt=null,Fs.clear(),Ps.clear(),Ws.clear(),Vs.clear(),Bs.clear()}static fromObject({locale:e,numberingSystem:s,outputCalendar:n,weekSettings:r}={}){return se.create(e,s,n,r)}constructor(e,s,n,r,a){const[o,c,l]=Ci(e);this.locale=o,this.numberingSystem=s||c||null,this.outputCalendar=n||l||null,this.weekSettings=r,this.intl=Di(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=a,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=Li(this)),this.fastNumbersCached}listingMode(){const e=this.isEnglish(),s=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return e&&s?"en":"intl"}clone(e){return!e||Object.getOwnPropertyNames(e).length===0?this:se.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,zs(e.weekSettings)||this.weekSettings,e.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,s=!1){return Kt(this,e,Br,()=>{const n=this.intl==="ja"||this.intl.startsWith("ja-");s&=!n;const r=s?{month:e,day:"numeric"}:{month:e},a=s?"format":"standalone";if(!this.monthsCache[a][e]){const o=n?c=>this.dtFormatter(c,r).format():c=>this.extract(c,r,"month");this.monthsCache[a][e]=Ri(o)}return this.monthsCache[a][e]})}weekdays(e,s=!1){return Kt(this,e,Hr,()=>{const n=s?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},r=s?"format":"standalone";return this.weekdaysCache[r][e]||(this.weekdaysCache[r][e]=Ui(a=>this.extract(a,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return Kt(this,void 0,()=>qr,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[V.utc(2016,11,13,9),V.utc(2016,11,13,19)].map(s=>this.extract(s,e,"dayperiod"))}return this.meridiemCache})}eras(e){return Kt(this,e,Gr,()=>{const s={era:e};return this.eraCache[e]||(this.eraCache[e]=[V.utc(-40,1,1),V.utc(2017,1,1)].map(n=>this.extract(n,s,"era"))),this.eraCache[e]})}extract(e,s,n){const r=this.dtFormatter(e,s),a=r.formatToParts(),o=a.find(c=>c.type.toLowerCase()===n);return o?o.value:null}numberFormatter(e={}){return new Fi(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new $i(e,this.intl,s)}relFormatter(e={}){return new Pi(this.intl,this.isEnglish(),e)}listFormatter(e={}){return Ii(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||Mr(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:$r()?ji(this.locale):Or}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let ks=null;class Ee extends Vt{static get utcInstance(){return ks===null&&(ks=new Ee(0)),ks}static instance(e){return e===0?Ee.utcInstance:new Ee(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new Ee(Ss(s[1],s[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${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 Wi extends Vt{constructor(e){super(),this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function ot(t,e){if(B(t)||t===null)return e;if(t instanceof Vt)return t;if(qi(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?ys.instance:s==="utc"||s==="gmt"?Ee.utcInstance:Ee.parseSpecifier(s)||et.create(t)}else return lt(t)?Ee.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new Wi(t)}const Qs={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},xn={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},Vi=Qs.hanidec.replace(/[\[|\]]/g,"").split("");function Bi(t){let e=parseInt(t,10);if(isNaN(e)){e="";for(let s=0;s<t.length;s++){const n=t.charCodeAt(s);if(t[s].search(Qs.hanidec)!==-1)e+=Vi.indexOf(t[s]);else for(const r in xn){const[a,o]=xn[r];n>=a&&n<=o&&(e+=n-a)}}return parseInt(e,10)}else return e}const Zs=new Map;function Zi(){Zs.clear()}function He({numberingSystem:t},e=""){const s=t||"latn";let n=Zs.get(s);n===void 0&&(n=new Map,Zs.set(s,n));let r=n.get(e);return r===void 0&&(r=new RegExp(`${Qs[s]}${e}`),n.set(e,r)),r}let vn=()=>Date.now(),wn="system",An=null,Tn=null,Nn=null,bn=60,kn,In=null;class he{static get now(){return vn}static set now(e){vn=e}static set defaultZone(e){wn=e}static get defaultZone(){return ot(wn,ys.instance)}static get defaultLocale(){return An}static set defaultLocale(e){An=e}static get defaultNumberingSystem(){return Tn}static set defaultNumberingSystem(e){Tn=e}static get defaultOutputCalendar(){return Nn}static set defaultOutputCalendar(e){Nn=e}static get defaultWeekSettings(){return In}static set defaultWeekSettings(e){In=zs(e)}static get twoDigitCutoffYear(){return bn}static set twoDigitCutoffYear(e){bn=e%100}static get throwOnInvalid(){return kn}static set throwOnInvalid(e){kn=e}static resetCaches(){se.resetCache(),et.resetCache(),V.resetCache(),Zi()}}class Ge{constructor(e,s){this.reason=e,this.explanation=s}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const jr=[0,31,59,90,120,151,181,212,243,273,304,334],Cr=[0,31,60,91,121,152,182,213,244,274,305,335];function Ve(t,e){return new Ge("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function Xs(t,e,s){const n=new Date(Date.UTC(t,e-1,s));t<100&&t>=0&&n.setUTCFullYear(n.getUTCFullYear()-1900);const r=n.getUTCDay();return r===0?7:r}function Dr(t,e,s){return s+(Bt(t)?Cr:jr)[e-1]}function Rr(t,e){const s=Bt(t)?Cr:jr,n=s.findIndex(a=>a<e),r=e-s[n];return{month:n+1,day:r}}function en(t,e){return(t-e+7)%7+1}function cs(t,e=4,s=1){const{year:n,month:r,day:a}=t,o=Dr(n,r,a),c=en(Xs(n,r,a),s);let l=Math.floor((o-c+14-e)/7),u;return l<1?(u=n-1,l=Wt(u,e,s)):l>Wt(n,e,s)?(u=n+1,l=1):u=n,{weekYear:u,weekNumber:l,weekday:c,...xs(t)}}function En(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:a}=t,o=en(Xs(n,1,e),s),c=It(n);let l=r*7+a-o-7+e,u;l<1?(u=n-1,l+=It(u)):l>c?(u=n+1,l-=It(n)):u=n;const{month:m,day:h}=Rr(u,l);return{year:u,month:m,day:h,...xs(t)}}function Is(t){const{year:e,month:s,day:n}=t,r=Dr(e,s,n);return{year:e,ordinal:r,...xs(t)}}function Mn(t){const{year:e,ordinal:s}=t,{month:n,day:r}=Rr(e,s);return{year:e,month:n,day:r,...xs(t)}}function On(t,e){if(!B(t.localWeekday)||!B(t.localWeekNumber)||!B(t.localWeekYear)){if(!B(t.weekday)||!B(t.weekNumber)||!B(t.weekYear))throw new kt("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 zi(t,e=4,s=1){const n=ps(t.weekYear),r=Be(t.weekNumber,1,Wt(t.weekYear,e,s)),a=Be(t.weekday,1,7);return n?r?a?!1:Ve("weekday",t.weekday):Ve("week",t.weekNumber):Ve("weekYear",t.weekYear)}function Hi(t){const e=ps(t.year),s=Be(t.ordinal,1,It(t.year));return e?s?!1:Ve("ordinal",t.ordinal):Ve("year",t.year)}function Ur(t){const e=ps(t.year),s=Be(t.month,1,12),n=Be(t.day,1,us(t.year,t.month));return e?s?n?!1:Ve("day",t.day):Ve("month",t.month):Ve("year",t.year)}function Lr(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),c=Be(n,0,59),l=Be(r,0,999);return a?o?c?l?!1:Ve("millisecond",r):Ve("second",n):Ve("minute",s):Ve("hour",e)}function B(t){return typeof t>"u"}function lt(t){return typeof t=="number"}function ps(t){return typeof t=="number"&&t%1===0}function qi(t){return typeof t=="string"}function Gi(t){return Object.prototype.toString.call(t)==="[object Date]"}function Fr(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function $r(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function Yi(t){return Array.isArray(t)?t:[t]}function jn(t,e,s){if(t.length!==0)return t.reduce((n,r)=>{const a=[e(r),r];return n&&s(n[0],a[0])===n[0]?n:a},null)[1]}function _i(t,e){return e.reduce((s,n)=>(s[n]=t[n],s),{})}function Mt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function zs(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 ps(t)&&t>=e&&t<=s}function Ji(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 it(t){if(!(B(t)||t===null||t===""))return parseInt(t,10)}function mt(t){if(!(B(t)||t===null||t===""))return parseFloat(t)}function tn(t){if(!(B(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function sn(t,e,s="round"){const n=10**e;switch(s){case"expand":return t>0?Math.ceil(t*n)/n:Math.floor(t*n)/n;case"trunc":return Math.trunc(t*n)/n;case"round":return Math.round(t*n)/n;case"floor":return Math.floor(t*n)/n;case"ceil":return Math.ceil(t*n)/n;default:throw new RangeError(`Value rounding ${s} is out of range`)}}function Bt(t){return t%4===0&&(t%100!==0||t%400===0)}function It(t){return Bt(t)?366:365}function us(t,e){const s=Ji(e-1,12)+1,n=t+(e-s)/12;return s===2?Bt(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][s-1]}function gs(t){let e=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second,t.millisecond);return t.year<100&&t.year>=0&&(e=new Date(e),e.setUTCFullYear(t.year,t.month-1,t.day)),+e}function Cn(t,e,s){return-en(Xs(t,1,e),s)+e-1}function Wt(t,e=4,s=1){const n=Cn(t,e,s),r=Cn(t+1,e,s);return(It(t)-n+r)/7}function Hs(t){return t>99?t:t>he.twoDigitCutoffYear?1900+t:2e3+t}function Pr(t,e,s,n=null){const r=new Date(t),a={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};n&&(a.timeZone=n);const o={timeZoneName:e,...a},c=new Intl.DateTimeFormat(s,o).formatToParts(r).find(l=>l.type.toLowerCase()==="timezonename");return c?c.value:null}function Ss(t,e){let s=parseInt(t,10);Number.isNaN(s)&&(s=0);const n=parseInt(e,10)||0,r=s<0||Object.is(s,-0)?-n:n;return s*60+r}function Wr(t){const e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new Ne(`Invalid unit value ${t}`);return e}function ds(t,e){const s={};for(const n in t)if(Mt(t,n)){const r=t[n];if(r==null)continue;s[e(n)]=Wr(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}${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 xs(t){return _i(t,["hour","minute","second","millisecond"])}const Ki=["January","February","March","April","May","June","July","August","September","October","November","December"],Vr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Qi=["J","F","M","A","M","J","J","A","S","O","N","D"];function Br(t){switch(t){case"narrow":return[...Qi];case"short":return[...Vr];case"long":return[...Ki];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const Zr=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],zr=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Xi=["M","T","W","T","F","S","S"];function Hr(t){switch(t){case"narrow":return[...Xi];case"short":return[...zr];case"long":return[...Zr];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const qr=["AM","PM"],eo=["Before Christ","Anno Domini"],to=["BC","AD"],so=["B","A"];function Gr(t){switch(t){case"narrow":return[...so];case"short":return[...to];case"long":return[...eo];default:return null}}function no(t){return qr[t.hour<12?0:1]}function ro(t,e){return Hr(e)[t.weekday-1]}function ao(t,e){return Br(e)[t.month-1]}function io(t,e){return Gr(e)[t.year<0?0:1]}function oo(t,e,s="always",n=!1){const r={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},a=["hours","minutes","seconds"].indexOf(t)===-1;if(s==="auto"&&a){const h=t==="days";switch(e){case 1:return h?"tomorrow":`next ${r[t][0]}`;case-1:return h?"yesterday":`last ${r[t][0]}`;case 0:return h?"today":`this ${r[t][0]}`}}const o=Object.is(e,-0)||e<0,c=Math.abs(e),l=c===1,u=r[t],m=n?l?u[1]:u[2]||u[1]:l?r[t][0]:t;return o?`${c} ${m} ago`:`in ${c} ${m}`}function Dn(t,e){let s="";for(const n of t)n.literal?s+=n.val:s+=e(n.val);return s}const lo={D:ls,DD:ur,DDD:dr,DDDD:mr,t:fr,tt:hr,ttt:yr,tttt:pr,T:gr,TT:Sr,TTT:xr,TTTT:vr,f:wr,ff:Tr,fff:br,ffff:Ir,F:Ar,FF:Nr,FFF:kr,FFFF:Er};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 c=e.charAt(o);c==="'"?((n.length>0||r)&&a.push({literal:r||/^\s+$/.test(n),val:n===""?"'":n}),s=null,n="",r=!r):r||c===s?n+=c:(n.length>0&&a.push({literal:/^\s+$/.test(n),val:n}),n=c,s=c)}return n.length>0&&a.push({literal:r||/^\s+$/.test(n),val:n}),a}static macroTokenToFormatOpts(e){return lo[e]}constructor(e,s){this.opts=s,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,s){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...s}).format()}dtFormatter(e,s={}){return this.loc.dtFormatter(e,{...this.opts,...s})}formatDateTime(e,s){return this.dtFormatter(e,s).format()}formatDateTimeParts(e,s){return this.dtFormatter(e,s).formatToParts()}formatInterval(e,s){return this.dtFormatter(e.start,s).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,s){return this.dtFormatter(e,s).resolvedOptions()}num(e,s=0,n=void 0){if(this.opts.forceSimple)return 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=(g,b)=>this.loc.extract(e,g,b),o=g=>e.isOffsetFixed&&e.offset===0&&g.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,g.format):"",c=()=>n?no(e):a({hour:"numeric",hourCycle:"h12"},"dayperiod"),l=(g,b)=>n?ao(e,g):a(b?{month:g}:{month:g,day:"numeric"},"month"),u=(g,b)=>n?ro(e,g):a(b?{weekday:g}:{weekday:g,month:"long",day:"numeric"},"weekday"),m=g=>{const b=be.macroTokenToFormatOpts(g);return b?this.formatWithSystemDefault(e,b):g},h=g=>n?io(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 c();case"d":return r?a({day:"numeric"},"day"):this.num(e.day);case"dd":return r?a({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return u("short",!0);case"cccc":return u("long",!0);case"ccccc":return u("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return u("short",!1);case"EEEE":return u("long",!1);case"EEEEE":return u("narrow",!1);case"L":return r?a({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?a({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return l("short",!0);case"LLLL":return l("long",!0);case"LLLLL":return l("narrow",!0);case"M":return r?a({month:"numeric"},"month"):this.num(e.month);case"MM":return r?a({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return l("short",!1);case"MMMM":return l("long",!1);case"MMMMM":return l("narrow",!1);case"y":return r?a({year:"numeric"},"year"):this.num(e.year);case"yy":return r?a({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?a({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?a({year:"numeric"},"year"):this.num(e.year,6);case"G":return h("short");case"GG":return h("long");case"GGGGG":return h("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return m(g)}};return Dn(be.parseFormat(s),S)}formatDurationFromString(e,s){const n=this.opts.signMode==="negativeLargestOnly"?-1:1,r=m=>{switch(m[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},a=(m,h)=>S=>{const g=r(S);if(g){const b=h.isNegativeDuration&&g!==h.largestUnit?n:1;let C;return this.opts.signMode==="negativeLargestOnly"&&g!==h.largestUnit?C="never":this.opts.signMode==="all"?C="always":C="auto",this.num(m.get(g)*b,S.length,C)}else return S},o=be.parseFormat(s),c=o.reduce((m,{literal:h,val:S})=>h?m:m.concat(S),[]),l=e.shiftTo(...c.map(r).filter(m=>m)),u={isNegativeDuration:l<0,largestUnit:Object.keys(l.values)[0]};return Dn(o,a(l,u))}}const Yr=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Ot(...t){const e=t.reduce((s,n)=>s+n.source,"");return RegExp(`^${e}$`)}function jt(...t){return e=>t.reduce(([s,n,r],a)=>{const[o,c,l]=a(e,r);return[{...s,...o},c||n,l]},[{},null,1]).slice(0,2)}function Ct(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 _r(...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 Jr=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,co=`(?:${Jr.source}?(?:\\[(${Yr.source})\\])?)?`,nn=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Kr=RegExp(`${nn.source}${co}`),rn=RegExp(`(?:[Tt]${Kr.source})?`),uo=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,mo=/(\d{4})-?W(\d\d)(?:-?(\d))?/,fo=/(\d{4})-?(\d{3})/,ho=_r("weekYear","weekNumber","weekDay"),yo=_r("year","ordinal"),po=/(\d{4})-(\d\d)-(\d\d)/,Qr=RegExp(`${nn.source} ?(?:${Jr.source}|(${Yr.source}))?`),go=RegExp(`(?: ${Qr.source})?`);function Et(t,e,s){const n=t[e];return B(n)?s:it(n)}function So(t,e){return[{year:Et(t,e),month:Et(t,e+1,1),day:Et(t,e+2,1)},null,e+3]}function Dt(t,e){return[{hours:Et(t,e,0),minutes:Et(t,e+1,0),seconds:Et(t,e+2,0),milliseconds:tn(t[e+3])},null,e+4]}function Zt(t,e){const s=!t[e]&&!t[e+1],n=Ss(t[e+1],t[e+2]),r=s?null:Ee.instance(n);return[{},r,e+3]}function zt(t,e){const s=t[e]?et.create(t[e]):null;return[{},s,e+1]}const xo=RegExp(`^T?${nn.source}$`),vo=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function wo(t){const[e,s,n,r,a,o,c,l,u]=t,m=e[0]==="-",h=l&&l[0]==="-",S=(g,b=!1)=>g!==void 0&&(b||g&&m)?-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(c)),seconds:S(mt(l),l==="-0"),milliseconds:S(tn(u),h)}]}const Ao={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function an(t,e,s,n,r,a,o){const c={year:e.length===2?Hs(it(e)):it(e),month:Vr.indexOf(s)+1,day:it(n),hour:it(r),minute:it(a)};return o&&(c.second=it(o)),t&&(c.weekday=t.length>3?Zr.indexOf(t)+1:zr.indexOf(t)+1),c}const To=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function No(t){const[,e,s,n,r,a,o,c,l,u,m,h]=t,S=an(e,r,n,s,a,o,c);let g;return l?g=Ao[l]:u?g=0:g=Ss(m,h),[S,new Ee(g)]}function bo(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const ko=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,Io=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,Eo=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function Rn(t){const[,e,s,n,r,a,o,c]=t;return[an(e,r,n,s,a,o,c),Ee.utcInstance]}function Mo(t){const[,e,s,n,r,a,o,c]=t;return[an(e,c,s,n,r,a,o),Ee.utcInstance]}const Oo=Ot(uo,rn),jo=Ot(mo,rn),Co=Ot(fo,rn),Do=Ot(Kr),Xr=jt(So,Dt,Zt,zt),Ro=jt(ho,Dt,Zt,zt),Uo=jt(yo,Dt,Zt,zt),Lo=jt(Dt,Zt,zt);function Fo(t){return Ct(t,[Oo,Xr],[jo,Ro],[Co,Uo],[Do,Lo])}function $o(t){return Ct(bo(t),[To,No])}function Po(t){return Ct(t,[ko,Rn],[Io,Rn],[Eo,Mo])}function Wo(t){return Ct(t,[vo,wo])}const Vo=jt(Dt);function Bo(t){return Ct(t,[xo,Vo])}const Zo=Ot(po,go),zo=Ot(Qr),Ho=jt(Dt,Zt,zt);function qo(t){return Ct(t,[Zo,Xr],[zo,Ho])}const Un="Invalid Duration",ea={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},Go={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...ea},We=146097/400,Tt=146097/4800,Yo={years:{quarters:4,months:12,weeks:We/7,days:We,hours:We*24,minutes:We*24*60,seconds:We*24*60*60,milliseconds:We*24*60*60*1e3},quarters:{months:3,weeks:We/28,days:We/4,hours:We*24/4,minutes:We*24*60/4,seconds:We*24*60*60/4,milliseconds:We*24*60*60*1e3/4},months:{weeks:Tt/7,days:Tt,hours:Tt*24,minutes:Tt*24*60,seconds:Tt*24*60*60,milliseconds:Tt*24*60*60*1e3},...ea},ht=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],_o=ht.slice(0).reverse();function Qe(t,e,s=!1){const n={values:s?e.values:{...t.values,...e.values||{}},loc:t.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||t.conversionAccuracy,matrix:e.matrix||t.matrix};return new K(n)}function ta(t,e){let s=e.milliseconds??0;for(const n of _o.slice(1))e[n]&&(s+=e[n]*t[n].milliseconds);return s}function Ln(t,e){const s=ta(t,e)<0?-1:1;ht.reduceRight((n,r)=>{if(B(e[r]))return n;if(n){const a=e[n]*s,o=t[r][n],c=Math.floor(a/o);e[r]+=c*s,e[n]-=c*o*s}return r},null),ht.reduce((n,r)=>{if(B(e[r]))return n;if(n){const a=e[n]%1;e[n]-=a,e[r]+=a*t[n][r]}return r},null)}function Fn(t){const e={};for(const[s,n]of Object.entries(t))n!==0&&(e[s]=n);return e}class K{constructor(e){const s=e.conversionAccuracy==="longterm"||!1;let n=s?Yo:Go;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||se.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:ds(e,K.normalizeUnit),loc:se.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(lt(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]=Wo(e);return n?K.fromObject(n,s):K.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,s){const[n]=Bo(e);return n?K.fromObject(n,s):K.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,s=null){if(!e)throw new Ne("need to specify a reason the Duration is invalid");const n=e instanceof Ge?e:new Ge(e,s);if(he.throwOnInvalid)throw new vi(n);return new K({invalid:n})}static normalizeUnit(e){const s={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[e&&e.toLowerCase()];if(!s)throw new cr(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):Un}toHuman(e={}){if(!this.isValid)return Un;const s=e.showZeros!==!1,n=ht.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+=sn(this.seconds+this.milliseconds/1e3,3)+"S"),e==="P"&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;const s=this.toMillis();return s<0||s>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e,includeOffset:!1},V.fromMillis(s,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?ta(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 ht)(Mt(s.values,r)||Mt(this.values,r))&&(n[r]=s.get(r)+this.get(r));return Qe(this,{values:n},!0)}minus(e){if(!this.isValid)return this;const s=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]=Wr(e(this.values[n],n));return Qe(this,{values:s},!0)}get(e){return this[K.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const s={...this.values,...ds(e,K.normalizeUnit)};return Qe(this,{values:s})}reconfigure({locale:e,numberingSystem:s,conversionAccuracy:n,matrix:r}={}){const o={loc:this.loc.clone({locale:e,numberingSystem:s}),matrix:r,conversionAccuracy:n};return Qe(this,o)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return Ln(this.matrix,e),Qe(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=Fn(this.normalize().shiftToAll().toObject());return Qe(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(o=>K.normalizeUnit(o));const s={},n={},r=this.toObject();let a;for(const o of ht)if(e.indexOf(o)>=0){a=o;let c=0;for(const u in n)c+=this.matrix[u][o]*n[u],n[u]=0;lt(r[o])&&(c+=r[o]);const l=Math.trunc(c);s[o]=l,n[o]=(c*1e3-l*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 Ln(this.matrix,s),Qe(this,{values:s},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const e={};for(const s of Object.keys(this.values))e[s]=this.values[s]===0?0:-this.values[s];return Qe(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=Fn(this.values);return Qe(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function s(n,r){return n===void 0||n===0?r===void 0||r===0:n===r}for(const n of ht)if(!s(this.values[n],e.values[n]))return!1;return!0}}const Nt="Invalid Interval";function Jo(t,e){return!t||!t.isValid?fe.invalid("missing or invalid start"):!e||!e.isValid?fe.invalid("missing or invalid end"):e<t?fe.invalid("end before start",`The end of an interval must be after its start, but you had start=${t.toISO()} and end=${e.toISO()}`):null}class fe{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,s=null){if(!e)throw new Ne("need to specify a reason the Interval is invalid");const n=e instanceof Ge?e:new Ge(e,s);if(he.throwOnInvalid)throw new xi(n);return new fe({invalid:n})}static fromDateTimes(e,s){const n=Rt(e),r=Rt(s),a=Jo(n,r);return a??new fe({start:n,end:r})}static after(e,s){const n=K.fromDurationLike(s),r=Rt(e);return fe.fromDateTimes(r,r.plus(n))}static before(e,s){const n=K.fromDurationLike(s),r=Rt(e);return fe.fromDateTimes(r.minus(n),r)}static fromISO(e,s){const[n,r]=(e||"").split("/",2);if(n&&r){let a,o;try{a=V.fromISO(n,s),o=a.isValid}catch{o=!1}let c,l;try{c=V.fromISO(r,s),l=c.isValid}catch{l=!1}if(o&&l)return fe.fromDateTimes(a,c);if(o){const u=K.fromISO(r,s);if(u.isValid)return fe.after(a,u)}else if(l){const u=K.fromISO(n,s);if(u.isValid)return fe.before(c,u)}}return fe.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(e).get(e):NaN}count(e="milliseconds",s){if(!this.isValid)return NaN;const n=this.start.startOf(e,s);let r;return s?.useLocaleWeeks?r=this.end.reconfigure({locale:n.locale}):r=this.end,r=r.startOf(e,s),Math.floor(r.diff(n,e).get(e))+(r.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:e,end:s}={}){return this.isValid?fe.fromDateTimes(e||this.s,s||this.e):this}splitAt(...e){if(!this.isValid)return[];const s=e.map(Rt).filter(o=>this.contains(o)).sort((o,c)=>o.toMillis()-c.toMillis()),n=[];let{s:r}=this,a=0;for(;r<this.e;){const o=s[a]||this.e,c=+o>+this.e?this.e:o;n.push(fe.fromDateTimes(r,c)),r=c,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 c=this.start.plus(s.mapUnits(l=>l*r));a=+c>+this.e?this.e:c,o.push(fe.fromDateTimes(n,a)),n=a,r+=1}return o}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;const s=this.s>e.s?this.s:e.s,n=this.e<e.e?this.e:e.e;return s>=n?null:fe.fromDateTimes(s,n)}union(e){if(!this.isValid)return this;const s=this.s<e.s?this.s:e.s,n=this.e>e.e?this.e:e.e;return fe.fromDateTimes(s,n)}static merge(e){const[s,n]=e.sort((r,a)=>r.s-a.s).reduce(([r,a],o)=>a?a.overlaps(o)||a.abutsStart(o)?[r,a.union(o)]:[r.concat([a]),o]:[r,o],[[],null]);return n&&s.push(n),s}static xor(e){let s=null,n=0;const r=[],a=e.map(l=>[{time:l.s,type:"s"},{time:l.e,type:"e"}]),o=Array.prototype.concat(...a),c=o.sort((l,u)=>l.time-u.time);for(const l of c)n+=l.type==="s"?1:-1,n===1?s=l.time:(s&&+s!=+l.time&&r.push(fe.fromDateTimes(s,l.time)),s=null);return fe.merge(r)}difference(...e){return fe.xor([this].concat(e)).map(s=>this.intersection(s)).filter(s=>s&&!s.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:Nt}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=ls,s={}){return this.isValid?be.create(this.s.loc.clone(s),e).formatInterval(this):Nt}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:Nt}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Nt}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:Nt}toFormat(e,{separator:s=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${s}${this.e.toFormat(e)}`:Nt}toDuration(e,s){return this.isValid?this.e.diff(this.s,e,s):K.invalid(this.invalidReason)}mapEndpoints(e){return fe.fromDateTimes(e(this.s),e(this.e))}}class Qt{static hasDST(e=he.defaultZone){const s=V.now().setZone(e).set({month:12});return!e.isUniversal&&s.offset!==s.set({month:6}).offset}static isValidIANAZone(e){return et.isValidZone(e)}static normalizeZone(e){return ot(e,he.defaultZone)}static getStartOfWeek({locale:e=null,locObj:s=null}={}){return(s||se.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:s=null}={}){return(s||se.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:s=null}={}){return(s||se.create(e)).getWeekendDays().slice()}static months(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||se.create(s,n,a)).months(e)}static monthsFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||se.create(s,n,a)).months(e,!0)}static weekdays(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||se.create(s,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||se.create(s,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return se.create(e).meridiems()}static eras(e="short",{locale:s=null}={}){return se.create(s,null,"gregory").eras(e)}static features(){return{relative:Fr(),localeWeek:$r()}}}function $n(t,e){const s=r=>r.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),n=s(e)-s(t);return Math.floor(K.fromMillis(n).as("days"))}function Ko(t,e,s){const n=[["years",(l,u)=>u.year-l.year],["quarters",(l,u)=>u.quarter-l.quarter+(u.year-l.year)*4],["months",(l,u)=>u.month-l.month+(u.year-l.year)*12],["weeks",(l,u)=>{const m=$n(l,u);return(m-m%7)/7}],["days",$n]],r={},a=t;let o,c;for(const[l,u]of n)s.indexOf(l)>=0&&(o=l,r[l]=u(t,e),c=a.plus(r),c>e?(r[l]--,t=a.plus(r),t>e&&(c=t,r[l]--,t=a.plus(r))):t=c);return[t,r,c,o]}function Qo(t,e,s,n){let[r,a,o,c]=Ko(t,e,s);const l=e-r,u=s.filter(h=>["hours","minutes","seconds","milliseconds"].indexOf(h)>=0);u.length===0&&(o<e&&(o=r.plus({[c]:1})),o!==r&&(a[c]=(a[c]||0)+l/(o-r)));const m=K.fromObject(a,n);return u.length>0?K.fromMillis(l,n).shiftTo(...u).plus(m):m}const Xo="missing Intl.DateTimeFormat.formatToParts support";function ee(t,e=s=>s){return{regex:t,deser:([s])=>e(Bi(s))}}const el=" ",sa=`[ ${el}]`,na=new RegExp(sa,"g");function tl(t){return t.replace(/\./g,"\\.?").replace(na,sa)}function Pn(t){return t.replace(/\./g,"").replace(na," ").toLowerCase()}function qe(t,e){return t===null?null:{regex:RegExp(t.map(tl).join("|")),deser:([s])=>t.findIndex(n=>Pn(s)===Pn(n))+e}}function Wn(t,e){return{regex:t,deser:([,s,n])=>Ss(s,n),groups:e}}function Xt(t){return{regex:t,deser:([e])=>e}}function sl(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function nl(t,e){const s=He(e),n=He(e,"{2}"),r=He(e,"{3}"),a=He(e,"{4}"),o=He(e,"{6}"),c=He(e,"{1,2}"),l=He(e,"{1,3}"),u=He(e,"{1,6}"),m=He(e,"{1,9}"),h=He(e,"{2,4}"),S=He(e,"{4,6}"),g=D=>({regex:RegExp(sl(D.val)),deser:([q])=>q,literal:!0}),C=(D=>{if(t.literal)return g(D);switch(D.val){case"G":return qe(e.eras("short"),0);case"GG":return qe(e.eras("long"),0);case"y":return ee(u);case"yy":return ee(h,Hs);case"yyyy":return ee(a);case"yyyyy":return ee(S);case"yyyyyy":return ee(o);case"M":return ee(c);case"MM":return ee(n);case"MMM":return qe(e.months("short",!0),1);case"MMMM":return qe(e.months("long",!0),1);case"L":return ee(c);case"LL":return ee(n);case"LLL":return qe(e.months("short",!1),1);case"LLLL":return qe(e.months("long",!1),1);case"d":return ee(c);case"dd":return ee(n);case"o":return ee(l);case"ooo":return ee(r);case"HH":return ee(n);case"H":return ee(c);case"hh":return ee(n);case"h":return ee(c);case"mm":return ee(n);case"m":return ee(c);case"q":return ee(c);case"qq":return ee(n);case"s":return ee(c);case"ss":return ee(n);case"S":return ee(l);case"SSS":return ee(r);case"u":return Xt(m);case"uu":return Xt(c);case"uuu":return ee(s);case"a":return qe(e.meridiems(),0);case"kkkk":return ee(a);case"kk":return ee(h,Hs);case"W":return ee(c);case"WW":return ee(n);case"E":case"c":return ee(s);case"EEE":return qe(e.weekdays("short",!1),1);case"EEEE":return qe(e.weekdays("long",!1),1);case"ccc":return qe(e.weekdays("short",!0),1);case"cccc":return qe(e.weekdays("long",!0),1);case"Z":case"ZZ":return Wn(new RegExp(`([+-]${c.source})(?::(${n.source}))?`),2);case"ZZZ":return Wn(new RegExp(`([+-]${c.source})(${n.source})?`),2);case"z":return Xt(/[a-z_+-/]{1,256}?/i);case" ":return Xt(/[^\S\n\r]/);default:return g(D)}})(t)||{invalidReason:Xo};return C.token=t,C}const rl={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function al(t,e,s){const{type:n,value:r}=t;if(n==="literal"){const l=/^\s+$/.test(r);return{literal:!l,val:l?" ":r}}const a=e[n];let o=n;n==="hour"&&(e.hour12!=null?o=e.hour12?"hour12":"hour24":e.hourCycle!=null?e.hourCycle==="h11"||e.hourCycle==="h12"?o="hour12":o="hour24":o=s.hour12?"hour12":"hour24");let c=rl[o];if(typeof c=="object"&&(c=c[a]),c)return{literal:!1,val:c}}function il(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function ol(t,e,s){const n=t.match(e);if(n){const r={};let a=1;for(const o in s)if(Mt(s,o)){const c=s[o],l=c.groups?c.groups+1:1;!c.literal&&c.token&&(r[c.token.val[0]]=c.deser(n.slice(a,a+l))),a+=l}return[n,r]}else return[n,{}]}function ll(t){const e=a=>{switch(a){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let s=null,n;return B(t.z)||(s=et.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=tn(t.u)),[Object.keys(t).reduce((a,o)=>{const c=e(o);return c&&(a[c]=t[o]),a},{}),s,n]}let Es=null;function cl(){return Es||(Es=V.fromMillis(1555555555555)),Es}function ul(t,e){if(t.literal)return t;const s=be.macroTokenToFormatOpts(t.val),n=oa(s,e);return n==null||n.includes(void 0)?t:n}function ra(t,e){return Array.prototype.concat(...t.map(s=>ul(s,e)))}class aa{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=ra(be.parseFormat(s),e),this.units=this.tokens.map(n=>nl(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=il(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=ol(e,this.regex,this.handlers),[r,a,o]=n?ll(n):[null,null,void 0];if(Mt(n,"a")&&Mt(n,"H"))throw new kt("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 ia(t,e,s){return new aa(t,s).explainFromTokens(e)}function dl(t,e,s){const{result:n,zone:r,specificOffset:a,invalidReason:o}=ia(t,e,s);return[n,r,a,o]}function oa(t,e){if(!t)return null;const n=be.create(e,t).dtFormatter(cl()),r=n.formatToParts(),a=n.resolvedOptions();return r.map(o=>al(o,t,a))}const Ms="Invalid DateTime",Vn=864e13;function Ft(t){return new Ge("unsupported zone",`the zone "${t.name}" is not supported`)}function Os(t){return t.weekData===null&&(t.weekData=cs(t.c)),t.weekData}function js(t){return t.localWeekData===null&&(t.localWeekData=cs(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function 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 V({...s,...e,old:s})}function la(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 es(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 rs(t,e,s){return la(gs(t),e,s)}function Bn(t,e){const s=t.o,n=t.c.year+Math.trunc(e.years),r=t.c.month+Math.trunc(e.months)+Math.trunc(e.quarters)*3,a={...t.c,year:n,month:r,day:Math.min(t.c.day,us(n,r))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},o=K.fromObject({years:e.years-Math.trunc(e.years),quarters:e.quarters-Math.trunc(e.quarters),months:e.months-Math.trunc(e.months),weeks:e.weeks-Math.trunc(e.weeks),days:e.days-Math.trunc(e.days),hours:e.hours,minutes:e.minutes,seconds:e.seconds,milliseconds:e.milliseconds}).as("milliseconds"),c=gs(a);let[l,u]=la(c,s,t.zone);return o!==0&&(l+=o,u=t.zone.offset(l)),{ts:l,o:u}}function bt(t,e,s,n,r,a){const{setZone:o,zone:c}=s;if(t&&Object.keys(t).length!==0||e){const l=e||c,u=V.fromObject(t,{...s,zone:l,specificOffset:a});return o?u:u.setZone(c)}else return V.invalid(new Ge("unparsable",`the input "${r}" can't be parsed as ${n}`))}function ts(t,e,s=!0){return t.isValid?be.create(se.create("en-US"),{allowZ:s,forceSimple:!0}).formatDateTimeFromString(t,e):null}function Cs(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 Zn(t,e,s,n,r,a,o){let c=!s||t.c.millisecond!==0||t.c.second!==0,l="";switch(o){case"day":case"month":case"year":break;default:if(l+=pe(t.c.hour),o==="hour")break;if(e){if(l+=":",l+=pe(t.c.minute),o==="minute")break;c&&(l+=":",l+=pe(t.c.second))}else{if(l+=pe(t.c.minute),o==="minute")break;c&&(l+=pe(t.c.second))}if(o==="second")break;c&&(!n||t.c.millisecond!==0)&&(l+=".",l+=pe(t.c.millisecond,3))}return r&&(t.isOffsetFixed&&t.offset===0&&!a?l+="Z":t.o<0?(l+="-",l+=pe(Math.trunc(-t.o/60)),l+=":",l+=pe(Math.trunc(-t.o%60))):(l+="+",l+=pe(Math.trunc(t.o/60)),l+=":",l+=pe(Math.trunc(t.o%60)))),a&&(l+="["+t.zone.ianaName+"]"),l}const ca={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},ml={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},fl={ordinal:1,hour:0,minute:0,second:0,millisecond:0},as=["year","month","day","hour","minute","second","millisecond"],hl=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],yl=["year","ordinal","hour","minute","second","millisecond"];function is(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 cr(t);return e}function zn(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return is(t)}}function pl(t){if($t===void 0&&($t=he.now()),t.type!=="iana")return t.offset($t);const e=t.name;let s=qs.get(e);return s===void 0&&(s=t.offset($t),qs.set(e,s)),s}function Hn(t,e){const s=ot(e.zone,he.defaultZone);if(!s.isValid)return V.invalid(Ft(s));const n=se.fromObject(e);let r,a;if(B(t.year))r=he.now();else{for(const l of as)B(t[l])&&(t[l]=ca[l]);const o=Ur(t)||Lr(t);if(o)return V.invalid(o);const c=pl(s);[r,a]=rs(t,c,s)}return new V({ts:r,zone:s,loc:n,o:a})}function qn(t,e,s){const n=B(s.round)?!0:s.round,r=B(s.rounding)?"trunc":s.rounding,a=(c,l)=>(c=sn(c,n||s.calendary?0:2,s.calendary?"round":r),e.loc.clone(s).relFormatter(s).format(c,l)),o=c=>s.calendary?e.hasSame(t,c)?0:e.startOf(c).diff(t.startOf(c),c).get(c):e.diff(t,c).get(c);if(s.unit)return a(o(s.unit),s.unit);for(const c of s.units){const l=o(c);if(Math.abs(l)>=1)return a(l,c)}return a(t>e?-0:0,s.units[s.units.length-1])}function Gn(t){let e={},s;return t.length>0&&typeof t[t.length-1]=="object"?(e=t[t.length-1],s=Array.from(t).slice(0,t.length-1)):s=Array.from(t),[e,s]}let $t;const qs=new Map;class V{constructor(e){const s=e.zone||he.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Ge("invalid input"):null)||(s.isValid?null:Ft(s));this.ts=B(e.ts)?he.now():e.ts;let r=null,a=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(s))[r,a]=[e.old.c,e.old.o];else{const c=lt(e.o)&&!e.old?e.o:s.offset(this.ts);r=es(this.ts,c),n=Number.isNaN(r.year)?new Ge("invalid input"):null,r=n?null:r,a=n?null:c}this._zone=s,this.loc=e.loc||se.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=a,this.isLuxonDateTime=!0}static now(){return new V({})}static local(){const[e,s]=Gn(arguments),[n,r,a,o,c,l,u]=s;return Hn({year:n,month:r,day:a,hour:o,minute:c,second:l,millisecond:u},e)}static utc(){const[e,s]=Gn(arguments),[n,r,a,o,c,l,u]=s;return e.zone=Ee.utcInstance,Hn({year:n,month:r,day:a,hour:o,minute:c,second:l,millisecond:u},e)}static fromJSDate(e,s={}){const n=Gi(e)?e.valueOf():NaN;if(Number.isNaN(n))return V.invalid("invalid input");const r=ot(s.zone,he.defaultZone);return r.isValid?new V({ts:n,zone:r,loc:se.fromObject(s)}):V.invalid(Ft(r))}static fromMillis(e,s={}){if(lt(e))return e<-Vn||e>Vn?V.invalid("Timestamp out of range"):new V({ts:e,zone:ot(s.zone,he.defaultZone),loc:se.fromObject(s)});throw new Ne(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,s={}){if(lt(e))return new V({ts:e*1e3,zone:ot(s.zone,he.defaultZone),loc:se.fromObject(s)});throw new Ne("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=ot(s.zone,he.defaultZone);if(!n.isValid)return V.invalid(Ft(n));const r=se.fromObject(s),a=ds(e,zn),{minDaysInFirstWeek:o,startOfWeek:c}=On(a,r),l=he.now(),u=B(s.specificOffset)?n.offset(l):s.specificOffset,m=!B(a.ordinal),h=!B(a.year),S=!B(a.month)||!B(a.day),g=h||S,b=a.weekYear||a.weekNumber;if((g||m)&&b)throw new kt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(S&&m)throw new kt("Can't mix ordinal dates with month/day");const C=b||a.weekday&&!g;let D,q,F=es(l,u);C?(D=hl,q=ml,F=cs(F,o,c)):m?(D=yl,q=fl,F=Is(F)):(D=as,q=ca);let $=!1;for(const x of D){const j=a[x];B(j)?$?a[x]=q[x]:a[x]=F[x]:$=!0}const T=C?zi(a,o,c):m?Hi(a):Ur(a),O=T||Lr(a);if(O)return V.invalid(O);const W=C?En(a,o,c):m?Mn(a):a,[R,H]=rs(W,u,n),p=new V({ts:R,zone:n,o:H,loc:r});return a.weekday&&g&&e.weekday!==p.weekday?V.invalid("mismatched weekday",`you can't specify both a weekday of ${a.weekday} and a date of ${p.toISO()}`):p.isValid?p:V.invalid(p.invalid)}static fromISO(e,s={}){const[n,r]=Fo(e);return bt(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=$o(e);return bt(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=Po(e);return bt(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=se.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0}),[c,l,u,m]=dl(o,e,s);return m?V.invalid(m):bt(c,l,n,`format ${s}`,e,u)}static fromString(e,s,n={}){return V.fromFormat(e,s,n)}static fromSQL(e,s={}){const[n,r]=qo(e);return bt(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 Ge?e:new Ge(e,s);if(he.throwOnInvalid)throw new Si(n);return new V({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,s={}){const n=oa(e,se.fromObject(s));return n?n.map(r=>r?r.val:null).join(""):null}static expandFormat(e,s={}){return ra(be.parseFormat(e),se.fromObject(s)).map(r=>r.val).join("")}static resetCache(){$t=void 0,qs.clear()}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?Os(this).weekYear:NaN}get weekNumber(){return this.isValid?Os(this).weekNumber:NaN}get weekday(){return this.isValid?Os(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?js(this).weekday:NaN}get localWeekNumber(){return this.isValid?js(this).weekNumber:NaN}get localWeekYear(){return this.isValid?js(this).weekYear:NaN}get ordinal(){return this.isValid?Is(this.c).ordinal:NaN}get monthShort(){return this.isValid?Qt.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Qt.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Qt.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Qt.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const e=864e5,s=6e4,n=gs(this.c),r=this.zone.offset(n-e),a=this.zone.offset(n+e),o=this.zone.offset(n-r*s),c=this.zone.offset(n-a*s);if(o===c)return[this];const l=n-o*s,u=n-c*s,m=es(l,o),h=es(u,c);return m.hour===h.hour&&m.minute===h.minute&&m.second===h.second&&m.millisecond===h.millisecond?[ft(this,{ts:l}),ft(this,{ts:u})]:[this]}get isInLeapYear(){return Bt(this.year)}get daysInMonth(){return us(this.year,this.month)}get daysInYear(){return this.isValid?It(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}=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(he.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=ot(e,he.defaultZone),e.equals(this.zone))return this;if(e.isValid){let r=this.ts;if(s||n){const a=e.offset(this.ts),o=this.toObject();[r]=rs(o,a,e)}return ft(this,{ts:r,zone:e})}else return V.invalid(Ft(e))}reconfigure({locale:e,numberingSystem:s,outputCalendar:n}={}){const r=this.loc.clone({locale:e,numberingSystem:s,outputCalendar:n});return ft(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const s=ds(e,zn),{minDaysInFirstWeek:n,startOfWeek:r}=On(s,this.loc),a=!B(s.weekYear)||!B(s.weekNumber)||!B(s.weekday),o=!B(s.ordinal),c=!B(s.year),l=!B(s.month)||!B(s.day),u=c||l,m=s.weekYear||s.weekNumber;if((u||o)&&m)throw new kt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(l&&o)throw new kt("Can't mix ordinal dates with month/day");let h;a?h=En({...cs(this.c,n,r),...s},n,r):B(s.ordinal)?(h={...this.toObject(),...s},B(s.day)&&(h.day=Math.min(us(h.year,h.month),h.day))):h=Mn({...Is(this.c),...s});const[S,g]=rs(h,this.o,this.zone);return ft(this,{ts:S,o:g})}plus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e);return ft(this,Bn(this,s))}minus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e).negate();return ft(this,Bn(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):Ms}toLocaleString(e=ls,s={}){return this.isValid?be.create(this.loc.clone(s),e).formatDateTime(this):Ms}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=is(o);const c=e==="extended";let l=Cs(this,c,o);return as.indexOf(o)>=3&&(l+="T"),l+=Zn(this,c,s,n,r,a,o),l}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?Cs(this,e==="extended",is(s)):null}toISOWeekDate(){return ts(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:s=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:a=!1,format:o="extended",precision:c="milliseconds"}={}){return this.isValid?(c=is(c),(r&&as.indexOf(c)>=3?"T":"")+Zn(this,o==="extended",s,e,n,a,c)):null}toRFC2822(){return ts(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return ts(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?Cs(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")),ts(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Ms}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};const s={...this.c};return e.includeConfig&&(s.outputCalendar=this.outputCalendar,s.numberingSystem=this.loc.numberingSystem,s.locale=this.loc.locale),s}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,s="milliseconds",n={}){if(!this.isValid||!e.isValid)return K.invalid("created by diffing an invalid DateTime");const r={locale:this.locale,numberingSystem:this.numberingSystem,...n},a=Yi(s).map(K.normalizeUnit),o=e.valueOf()>this.valueOf(),c=o?this:e,l=o?e:this,u=Qo(c,l,a,r);return o?u.negate():u}diffNow(e="milliseconds",s={}){return this.diff(V.now(),e,s)}until(e){return this.isValid?fe.fromDateTimes(this,e):this}hasSame(e,s,n){if(!this.isValid)return!1;const r=e.valueOf(),a=this.setZone(e.zone,{keepLocalTime:!0});return a.startOf(s,n)<=r&&r<=a.endOf(s,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;const s=e.base||V.fromObject({},{zone:this.zone}),n=e.padding?this<s?-e.padding:e.padding:0;let r=["years","months","days","hours","minutes","seconds"],a=e.unit;return Array.isArray(e.unit)&&(r=e.unit,a=void 0),qn(s,this.plus(n),{...e,numeric:"always",units:r,unit:a})}toRelativeCalendar(e={}){return this.isValid?qn(e.base||V.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(V.isDateTime))throw new Ne("min requires all arguments be DateTimes");return jn(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every(V.isDateTime))throw new Ne("max requires all arguments be DateTimes");return jn(e,s=>s.valueOf(),Math.max)}static fromFormatExplain(e,s,n={}){const{locale:r=null,numberingSystem:a=null}=n,o=se.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});return ia(o,e,s)}static fromStringExplain(e,s,n={}){return V.fromFormatExplain(e,s,n)}static buildFormatParser(e,s={}){const{locale:n=null,numberingSystem:r=null}=s,a=se.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new aa(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=se.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:c,zone:l,specificOffset:u,invalidReason:m}=s.explainFromTokens(e);return m?V.invalid(m):bt(c,l,n,`format ${s.format}`,e,u)}static get DATE_SHORT(){return ls}static get DATE_MED(){return ur}static get DATE_MED_WITH_WEEKDAY(){return wi}static get DATE_FULL(){return dr}static get DATE_HUGE(){return mr}static get TIME_SIMPLE(){return fr}static get TIME_WITH_SECONDS(){return hr}static get TIME_WITH_SHORT_OFFSET(){return yr}static get TIME_WITH_LONG_OFFSET(){return pr}static get TIME_24_SIMPLE(){return gr}static get TIME_24_WITH_SECONDS(){return Sr}static get TIME_24_WITH_SHORT_OFFSET(){return xr}static get TIME_24_WITH_LONG_OFFSET(){return vr}static get DATETIME_SHORT(){return wr}static get DATETIME_SHORT_WITH_SECONDS(){return Ar}static get DATETIME_MED(){return Tr}static get DATETIME_MED_WITH_SECONDS(){return Nr}static get DATETIME_MED_WITH_WEEKDAY(){return Ai}static get DATETIME_FULL(){return br}static get DATETIME_FULL_WITH_SECONDS(){return kr}static get DATETIME_HUGE(){return Ir}static get DATETIME_HUGE_WITH_SECONDS(){return Er}}function Rt(t){if(V.isDateTime(t))return t;if(t&&t.valueOf&&lt(t.valueOf()))return V.fromJSDate(t);if(t&&typeof t=="object")return V.fromObject(t);throw new Ne(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function gl(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function Sl(t,e){try{const s=V.fromJSDate(t,{zone:"utc"}).setZone(e),n=s.toJSDate().toLocaleString("en-US",{timeZone:e,timeZoneName:"short"}).split(" ").pop()||void 0,r=s.toFormat("ZZ")||void 0;return{abbr:n,offset:r}}catch{return{}}}function xl(t){if(!t)return"-";try{const e=new Date(t),s=u=>String(u).padStart(2,"0"),n=s(e.getMonth()+1),r=s(e.getDate()),a=e.getFullYear(),o=s(e.getHours()),c=s(e.getMinutes()),l=s(e.getSeconds());return`${n}/${r}/${a} ${o}:${c}:${l}`}catch{return"-"}}function ms(t,e="UTC"){if(!t)return"-";const s=V.fromISO(t,{zone:"utc"}).setZone(e);if(!s.isValid)return"-";const n=s.offsetNameShort,r=s.toFormat("ZZZZ"),a=n.startsWith("GMT")||n===r?r:`${n}/${r}`;return`${s.toFormat("MM/dd/yyyy, hh:mm:ss a")} (${a})`}const vl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},wl={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function ua({alerts:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,severityOptions:a,anomalyOptions:o,spaceOptions:c,onAlertIdClick:l,onFilterChange:u,onPageChange:m,onRefetch:h,resetKey:S,serverSideFilters:g}){const b=Ks(),C=async F=>{try{const $=await b.mutateAsync({alertUniqueId:F.alertId??F.id,alertId:F.id,status:"Reopen",notes:"Reopened",modifiedBy:0});if($?.responseStatus||$?.Success){const T=$?.Message||$?.data||"Alert reopened successfully.";we.toast.success(T)}else{const T=$?.errorMessage||$?.Message||"Failed to reopen alert";we.toast.error(T)}}catch{we.toast.error("Failed to reopen alert. Please try again.")}},D=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:F=>i.jsx(f.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${vl[F]}`,backgroundColor:wl[String(F)]},children:F})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:F=>xl(F)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(F,$)=>i.jsxs("div",{children:[i.jsx("a",{onClick:T=>{T.preventDefault(),l?.($,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:$.alertNumber}),i.jsx("div",{className:"text-black/65",children:F})]})},{title:"Preview",key:"preview",width:100,align:"center",render:(F,$)=>i.jsx(or,{record:$})},{title:"",key:"menu",width:60,align:"right",render:(F,$)=>i.jsx(f.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:T})=>{T==="reopen"&&C($)}},children:i.jsx(f.Button,{type:"text",icon:i.jsx(yt.MoreOutlined,{})})})}],q=u&&g?t:(t||[]).filter(F=>{const $=os(F.statusType||"");return lr.some(T=>$.includes(os(T)))});return i.jsx(Js,{data:q,loading:e,pageSize:s,total:n,currentPage:r,columns:D,severityOptions:a,anomalyOptions:o,spaceOptions:c,renderActions:void 0,onAlertIdClick:l,onFilterChange:u,onPageChange:m,onRefetch:h,resetKey:S,serverSideFilters:g,excludeCompleted:!1})}function Al({size:t=120,time:e,timeZone:s="America/New_York"}){const{hours:n,minutes:r,seconds:a}=d.useMemo(()=>{const h=new Intl.DateTimeFormat("en-US",{timeZone:s,hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(e);return{hours:parseInt(h.find(S=>S.type==="hour")?.value||"0",10),minutes:parseInt(h.find(S=>S.type==="minute")?.value||"0",10),seconds:parseInt(h.find(S=>S.type==="second")?.value||"0",10)}},[e,s]),o=a*6,c=r*6+a*.1,l=n%12*30+r*.5,u=t/2;return i.jsxs("div",{className:"relative rounded-full border border-gray-300 bg-white",style:{width:t,height:t},role:"img","aria-label":"Analog Clock",children:[[...Array(12)].map((m,h)=>{const S=h*30,g=6,b=u-4,C=b-g,D=(S-90)*(Math.PI/180),q=u+C*Math.cos(D),F=u+C*Math.sin(D),$=u+b*Math.cos(D),T=u+b*Math.sin(D);return i.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:i.jsx("line",{x1:q,y1:F,x2:$,y2:T,stroke:"#9CA3AF",strokeWidth:h%3===0?2:1,strokeLinecap:"round"})},h)}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${l}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.25,stroke:"#1F2937",strokeWidth:4,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${c}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.35,stroke:"#374151",strokeWidth:3,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${o}deg)`},children:i.jsx("line",{x1:u,y1:u+t*.08,x2:u,y2:u-t*.38,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"})}),i.jsx("div",{className:"absolute bg-gray-900 rounded-full",style:{width:8,height:8,left:u-4,top:u-4}})]})}function da({label:t="USA",timeZone:e="America/New_York",updateIntervalMs:s=1e3,className:n}){const[r,a]=d.useState(new Date);d.useEffect(()=>{const u=setInterval(()=>a(new Date),s);return()=>clearInterval(u)},[s]);const o=d.useMemo(()=>gl(r,e),[r,e]),{abbr:c,offset:l}=d.useMemo(()=>Sl(r,e),[r,e]);return i.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[i.jsx(Al,{time:r,timeZone:e,size:80}),i.jsxs("div",{className:"flex flex-col items-baseline gap-1",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[i.jsx("span",{className:"uppercase",children:t}),c&&i.jsxs("span",{className:"p-2 rounded-md border text-[10px] leading-none text-gray-600 bg-gray-50",children:[c," ",l]})]}),i.jsx("div",{className:"text-2xl font-semibold text-gray-700 tracking-wide",children:o})]})]})}const{Text:Tl}=f.Typography;function Nl({sortBy:t,onChange:e,showActions:s,onSave:n,onClear:r,saving:a}){return i.jsxs(f.Row,{gutter:[16,16],align:"middle",children:[i.jsx(f.Col,{xs:24,md:8,lg:5,children:i.jsxs(f.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[i.jsx(Tl,{className:"text-gray-600 whitespace-nowrap",children:"Sort By:"}),i.jsx(f.Select,{placeholder:"By Severity",value:t,onChange:o=>e({sortBy:o}),options:[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],className:"w-full",style:{minWidth:"200px"}})]})}),i.jsx(f.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?i.jsxs(f.Space,{className:"w-full",direction:"horizontal",size:8,children:[i.jsx(f.Button,{onClick:r,disabled:a,children:"Clear"}),i.jsx(f.Button,{type:"primary",onClick:n,loading:a,children:"Save"})]}):null})]})}const Gs=t=>i.jsxs(f.Tag,{children:[i.jsx(yt.PlusOutlined,{})," ",t.length," more"]}),{Text:Xe}=f.Typography;function bl(t){const{selectedRule:e,setSelectedRule:s,ruleOptions:n,minsOptions:r,roleOptions:a,l1mins:o,setL1mins:c,l1role:l,setL1role:u,l2mins:m,setL2mins:h,l2role:S,setL2role:g,l3mins:b,setL3mins:C,l3role:D,setL3role:q,actions:F,setActions:$,thirdPartyIds:T,setThirdPartyIds:O,humanLoop:W,setHumanLoop:R,isAutoExpire:H,setAutoExpire:p,onClear:x,onSave:j,saving:oe,onActionTypesLoaded:re}=t,{rules:L,config:w}=Me(),v=w.tenant==="schools",[E,A]=d.useState([]),[U,P]=d.useState([]),[G,J]=d.useState(!1);d.useEffect(()=>{let ie=!1;return(async()=>{try{J(!0);const me=await L.getLookups();if(ie||!me||!Array.isArray(me.actionTypes))return;const xe=me.actionTypes.map(le=>({label:le.name,value:String(le.actionTypeId)}));A(xe),re&&re(me.actionTypes);const ae=Array.isArray(me.thirdParties)?me.thirdParties.map(le=>({label:le.thirdPartyName,value:le.thirdPartyIds??le.thirdPartyId})):[];P(ae)}catch(me){console.error("Error loading lookups",me)}finally{ie||J(!1)}})(),()=>{ie=!0}},[]);const te=typeof o=="number"||typeof l=="number",ne=typeof m=="number"||typeof S=="number",Q=typeof o=="number"||typeof l=="number"||typeof m=="number"||typeof S=="number"||typeof b=="number"||typeof D=="number"||Array.isArray(F)&&F.length>0||Array.isArray(T)&&T.length>0||!!W||!!H,Se=!!e&&Q&&!oe;return i.jsxs(f.Spin,{spinning:!!oe||G,children:[i.jsxs(f.Row,{gutter:[16,16],align:"bottom",children:[i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(f.Select,{placeholder:"Rules",value:e,onChange:s,options:n,className:"w-full"})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),i.jsx(f.Col,{span:14,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(f.Select,{className:"w-full",placeholder:"Mins",value:o,onChange:c,options:r})}),i.jsx(f.Col,{span:14,children:i.jsx(f.Select,{placeholder:"Escalate to",className:"w-full",value:l,onChange:u,options:a})})]})]})}),te&&i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),i.jsx(f.Col,{span:14,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(f.Select,{className:"w-full",placeholder:"Mins",value:m,onChange:h,options:r})}),i.jsx(f.Col,{span:14,children:i.jsx(f.Select,{placeholder:"Escalate to",className:"w-full",value:S,onChange:g,options:a})})]})]})}),ne&&i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),i.jsx(f.Col,{span:14,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(f.Select,{className:"w-full",placeholder:"Mins",value:b,onChange:C,options:r})}),i.jsx(f.Col,{span:14,children:i.jsx(f.Select,{placeholder:"Escalate to",className:"w-full",value:D,onChange:q,options:a})})]})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),i.jsx(f.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:F,onChange:$,options:E,maxTagCount:1,maxTagPlaceholder:Gs})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Notify"}),i.jsx(f.Select,{mode:"multiple",placeholder:"Notify",className:"w-full",value:T,onChange:O,options:U,maxCount:2,maxTagPlaceholder:Gs})]})})]}),i.jsxs(f.Row,{gutter:[16,16],align:"bottom",className:"mt-4 items-center",children:[i.jsx(f.Col,{xs:24,sm:12,md:8,lg:7,children:i.jsxs("div",{className:"flex items-center h-full gap-8",children:[!v&&i.jsx(f.Checkbox,{checked:W,onChange:ie=>R(ie.target.checked),className:"w-full",children:"Human-In-The-Loop"}),i.jsx(f.Checkbox,{checked:H,onChange:ie=>p(ie.target.checked),className:"w-full",children:"Auto-expire in 5 minutes"})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(f.Button,{onClick:x,children:"Clear"}),i.jsx(f.Button,{type:"primary",onClick:j,loading:!!oe,disabled:!Se,children:"Save"})]})})]})]})}function kl({entries:t,userRoles:e,onEdit:s,loading:n}){const{config:r}=Me(),a=r.tenant==="schools",o=new Map(e.map(l=>[l.userRoleId,l.userRoleName])),c=l=>l.map(u=>o.get(u)||String(u)).join(", ");return i.jsx(f.Table,{rowKey:"id",dataSource:t,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(l,u)=>`${u[0]}-${u[1]} of ${l} items`},loading:n,columns:[{title:"Rule",dataIndex:"ruleOrSeverityLabel",key:"rule"},{title:"Level 1",key:"l1",render:(l,u)=>i.jsxs("span",{children:[u.l1.minutes?`Action taken in (${u.l1.minutes} Mins)`:"No Action taken in 0 Min",u.l1.roles?.length?`, Escalate to (${c(u.l1.roles)})`:""]})},{title:"Level 2",key:"l2",render:(l,u)=>i.jsxs("span",{children:[u.l2.minutes?`Action taken in (${u.l2.minutes} Mins)`:"No Action taken in 0 Min",u.l2.roles?.length?`, Escalate to (${c(u.l2.roles)})`:""]})},{title:"Level 3",key:"l3",render:(l,u)=>i.jsxs("span",{children:[u.l3.minutes?`Action taken in (${u.l3.minutes} Mins)`:"No Action taken in 0 Min",u.l3.roles?.length?`, Escalate to (${c(u.l3.roles)})`:""]})},{title:"Pick Actions",key:"actionsCol",render:(l,u)=>u.actions?.length?u.actions.join(", "):"-"},{title:"Notify",key:"notify",render:(l,u)=>u.notify?.length?u.notify.join(", "):"-"},...a?[]:[{title:"Human-In-The-Loop",key:"humanLoop",render:(l,u)=>u.humanLoop?"Yes":"No"}],{title:"Auto Expire",key:"isAutoExpire",render:(l,u)=>u.isAutoExpire?"Yes":"No"},{title:"Actions",key:"ops",render:(l,u)=>i.jsx(f.Button,{type:"text",onClick:()=>s(u.id),children:i.jsx(yt.EditOutlined,{})})}]})}const{Title:Il,Text:Ds}=f.Typography;function ma({userRoles:t,rules:e,rawRules:s}){const{rules:n}=Me(),[r,a]=d.useState(!1),[o,c]=d.useState(!1),[l,u]=d.useState(s),[m,h]=d.useState(),[S,g]=d.useState([]),b=d.useMemo(()=>t.map(T=>({label:T.userRoleName,value:T.userRoleId})),[t]),C=d.useMemo(()=>(e||[]).map(T=>({label:T.Name||"-",value:T.RuleId||T.Name||""})),[e]),D=d.useMemo(()=>(e||[]).map((T,O)=>({key:T.RuleId||T.Name||String(O),ruleName:T.Name||"-",ruleDesc:T.Description||""})),[e]);d.useEffect(()=>{let T=!1;return(async()=>{try{a(!0);const O=await n.getRules();T||u(Array.isArray(O)?O:[])}catch{!T&&Array.isArray(s)&&u(s)}finally{T||a(!1)}})(),()=>{T=!0}},[]),d.useEffect(()=>{!l&&Array.isArray(s)&&u(s)},[s]),d.useEffect(()=>{if(!m||!Array.isArray(l)){g([]);return}const T=l.find(W=>W?.ruleId===m||W?.RuleId===m||W?.ruleName===m),O=T?.userRoleIds??T?.UserRoleIds;g(Array.isArray(O)?O:[])},[m,l]);const q=d.useMemo(()=>{if(!Array.isArray(l)||!l.length)return{};const T={};for(const O of D){const W=l.find(p=>p?.ruleId===O.key||p?.ruleName===O.key||p?.RuleId===O.key||p?.ruleName===O.ruleName||p?.Name===O.ruleName),R=W?.userRoleIds??W?.UserRoleIds,H=Array.isArray(R)?R:[];H.length&&(T[O.key]=H)}return T},[l,D]),F=()=>{h(void 0),g([])},$=async()=>{if(!m){we.toast.info("Please select a rule");return}try{c(!0);const T=Array.isArray(l)?l.find(p=>p?.ruleId===m||p?.RuleId===m||p?.ruleName===m):void 0,O=typeof T?.recordId=="number"?T.recordId:T?.ruleId||T?.RuleId||void 0;if(!T||!O)throw new Error(`Unable to find rule identifier for rule ${m}`);const W=S.map(p=>{const x=t.find(j=>j.userRoleId===p);return{id:p,name:x?.userRoleName??String(p)}}),R={...T,ruleId:m,userRoleIds:S,userRoles:W},H=await n.updateRule(O,R);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"),h(void 0),g([]);try{const p=await n.getRules();u(Array.isArray(p)?p:[])}catch(p){console.error("Failed to refresh rules after save",p)}}}catch(T){console.error("Failed to save alert assignment",T),we.toast.error(T instanceof Error?T.message:"Error saving Alert Assignment")}finally{c(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(Il,{level:4,className:"!mb-4",children:"Alert Assignment"}),i.jsx(f.Spin,{spinning:o||r,children:i.jsxs(f.Row,{gutter:[16,16],align:"bottom",className:"mb-6",children:[i.jsx(f.Col,{xs:24,sm:12,md:8,lg:6,children:i.jsxs("div",{children:[i.jsx(Ds,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(f.Select,{placeholder:"Rules",value:m,onChange:h,options:C,className:"w-full"})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:8,children:i.jsxs("div",{children:[i.jsx(Ds,{className:"text-gray-700 font-medium block mb-1",children:"Alert Notification To"}),i.jsx(f.Select,{mode:"multiple",placeholder:"Select roles",className:"w-full",value:S,onChange:g,options:b,maxTagCount:1,maxTagPlaceholder:Gs})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(f.Button,{onClick:F,disabled:o,children:"Cancel"}),i.jsx(f.Button,{type:"primary",onClick:$,loading:o,disabled:o||!m,children:"Save"})]})})]})}),i.jsx(f.Table,{rowKey:"key",dataSource:D,loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(T,O)=>`${O[0]}-${O[1]} of ${T} items`},columns:[{title:"Rule Name",dataIndex:"ruleName",key:"ruleName"},{title:"Description",dataIndex:"ruleDesc",key:"ruleDesc"},{title:"Alert Notification To",key:"assign",render:(T,O)=>{const W=q[O.key]??[];return W.length?i.jsx("div",{className:"flex flex-wrap gap-1",children:W.map(R=>{const H=t.find(p=>p.userRoleId===R);return i.jsx(f.Tag,{children:H?.userRoleName??String(R)},R)})}):i.jsx(Ds,{type:"secondary",children:"—"})}}]})]})}const{Title:Yn}=f.Typography;function Rs(t){return!t||typeof t!="object"?{}:{level1UserRoleId:t.level1UserRoleId??t.Level1UserRoleId,level1PostAssistTime:t.level1PostAssistTime??t.Level1PostAssistTime,level2UserRoleId:t.level2UserRoleId??t.Level2UserRoleId,level2PostAssistTime:t.level2PostAssistTime??t.Level2PostAssistTime,level3UserRoleId:t.level3UserRoleId??t.Level3UserRoleId,level3PostAssistTime:t.level3PostAssistTime??t.Level3PostAssistTime,escalationSettingsActionTypeIds:t.escalationSettingsActionTypeIds??t.EscalationSettingsActionTypeIds,thirdPartyId:t.thirdPartyId??t.ThirdPartyId??t.ThirdPartyIds,humanLoop:t.humanLoop??t.HumanLoop,isAutoExpire:t.isAutoExpire??t.IsAutoExpire}}function fa({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r,onSave:a}){const{rules:o,alerts:c}=Me(),[l,u]=d.useState("By Severity"),[m,h]=d.useState("By severity"),[S,g]=d.useState("By Severity"),[b,C]=d.useState(!1),[D,q]=d.useState(!1),[F,$]=d.useState(!1),[T,O]=d.useState(null),[W,R]=d.useState("rules"),[H,p]=d.useState(),[x,j]=d.useState(),[oe,re]=d.useState(),[L,w]=d.useState(),[v,E]=d.useState(),[A,U]=d.useState(),[P,G]=d.useState(),[J,te]=d.useState(),[ne,Q]=d.useState([]),[Se,ie]=d.useState([]),[me,xe]=d.useState(!1),[ae,le]=d.useState(!1),[Ae,Ue]=d.useState({}),[Le,tt]=d.useState({}),[st,St]=d.useState(s||[]),[ct,X]=d.useState([]),[Z,ye]=d.useState(!1),[de,Te]=d.useState(!1),[ge,Ze]=d.useState(n||[]);d.useEffect(()=>{n&&n.length&&Ze(n)},[n]),d.useEffect(()=>{if(!ge||!ge.length)return;const k=Object.keys(Ae).length>0||Object.keys(Le).length>0;if(ct.length&&!k)return;const Y=ge.map((_,y)=>{const M=e.find(Ie=>Ie.RuleId===(_.ruleId||_.ruleName))?.Name||_.ruleName||_.Name||"-",I=Rs(_.escalationSettings),z=typeof I.level1UserRoleId=="number"&&I.level1UserRoleId>0?[I.level1UserRoleId]:[],ke=typeof I.level2UserRoleId=="number"&&I.level2UserRoleId>0?[I.level2UserRoleId]:[],ce=typeof I.level3UserRoleId=="number"&&I.level3UserRoleId>0?[I.level3UserRoleId]:[],Je=(Array.isArray(I.escalationSettingsActionTypeIds)?I.escalationSettingsActionTypeIds:[]).map(Ie=>Ae[Ie]||String(Ie)),ln=(Array.isArray(I.thirdPartyId)?I.thirdPartyId:[]).map(Ie=>Le[Ie]||String(Ie)),ws=typeof I.humanLoop=="boolean"?I.humanLoop:null,As=typeof I.isAutoExpire=="boolean"?I.isAutoExpire:null;return{id:String(_.ruleId||_.ruleName||y),ruleOrSeverityLabel:M,l1:{minutes:I.level1PostAssistTime??void 0,roles:z},l2:{minutes:I.level2PostAssistTime??void 0,roles:ke},l3:{minutes:I.level3PostAssistTime??void 0,roles:ce},actions:Je,notify:ln,humanLoop:ws,isAutoExpire:As}});X(Y)},[ge,e,Ae,Le]);const Fe=d.useMemo(()=>t.map(k=>({label:k.DisplayName,value:k.SeverityId})),[t]),ve=d.useMemo(()=>e.map(k=>({label:k.Name,value:k.RuleId})),[e]),ut=d.useMemo(()=>st.map(k=>({label:k.userRoleName,value:k.userRoleId})),[st]),dt=d.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(k=>({label:`${k}`,value:k})),[]);d.useEffect(()=>{let k=!1;async function Y(){try{$(!0),O(null);const _=await c.getAdminSettings();if(!k&&_){const y=Kn(_.sortBy);u(y),g(y),C(!1)}}catch(_){if(!k){const y=_ instanceof Error?_.message:"Failed to load admin settings";O(y)}}finally{k||$(!1)}}return Y(),()=>{k=!0}},[]),d.useEffect(()=>{if(!x)return;const k=M=>{const I=Number(M);return!isNaN(I)&&I>0?I:void 0},Y=M=>{const I=Number(M);return!isNaN(I)&&I>0?I:void 0},_=(ge||[]).find(M=>M?.ruleId===x||M?.ruleName===x||M?.RuleId===x),y=Rs(_?.escalationSettings);if(y&&typeof y=="object"){re(Y(y.level1PostAssistTime)),w(k(y.level1UserRoleId)),E(Y(y.level2PostAssistTime)),U(k(y.level2UserRoleId)),G(Y(y.level3PostAssistTime)),te(k(y.level3UserRoleId));const M=Array.isArray(y.escalationSettingsActionTypeIds)?y.escalationSettingsActionTypeIds:[];Q(M.map(I=>String(I))),ie(Array.isArray(y.thirdPartyId)?y.thirdPartyId:[]),xe(!!y.humanLoop),le(!!y.isAutoExpire)}},[W,x,ge]);const xt=async()=>{try{Te(!0);const k=await o.getRules(),Y=Array.isArray(k)?k:Array.isArray(k?.data)?k.data:[];Ze(Y);const _=Y.map((y,M)=>{const I=e.find(Ie=>Ie.RuleId===(y.ruleId||y.ruleName))?.Name||y.ruleName||y.Name||"-",z=Rs(y.escalationSettings??y.EscalationSettings),ke=typeof z.level1UserRoleId=="number"&&z.level1UserRoleId>0?[z.level1UserRoleId]:[],ce=typeof z.level2UserRoleId=="number"&&z.level2UserRoleId>0?[z.level2UserRoleId]:[],ze=typeof z.level3UserRoleId=="number"&&z.level3UserRoleId>0?[z.level3UserRoleId]:[],_e=(Array.isArray(z.escalationSettingsActionTypeIds)?z.escalationSettingsActionTypeIds:[]).map(Ie=>Ae[Ie]||String(Ie)),ws=(Array.isArray(z.thirdPartyId)?z.thirdPartyId:[]).map(Ie=>Le[Ie]||String(Ie)),As=typeof z.humanLoop=="boolean"?z.humanLoop:null;return{id:String(y.ruleId||y.ruleName||M),ruleOrSeverityLabel:I,l1:{minutes:z.level1PostAssistTime??void 0,roles:ke},l2:{minutes:z.level2PostAssistTime??void 0,roles:ce},l3:{minutes:z.level3PostAssistTime??void 0,roles:ze},actions:_e,notify:ws,humanLoop:As}});X(_)}catch(k){console.error("Failed to refetch entries",k)}finally{Te(!1)}};d.useEffect(()=>{let k=!1;return(async()=>{try{const Y=await o.getLookups();if(k||!Y)return;const _={};if(Array.isArray(Y.thirdParties))for(const M of Y.thirdParties){const I=M.thirdPartyIds??M.thirdPartyId;typeof I=="number"&&(_[I]=M.thirdPartyName)}tt(_);const y=Array.isArray(Y.userRoles)?Y.userRoles.map(M=>({userRoleId:M.userRoleId??M.id,userRoleName:M.userRoleName??M.name})):[];k||St(y.length?y:s||[])}catch(Y){console.error("Error loading lookups",Y)}})(),()=>{k=!0}},[]);const vt=async()=>{q(!0);try{const k=await c.setAdminSettings({sortBy:l,groupBy:"string"});k?.responseStatus&&k?.data&&we.toast.success(k.data),g(l),C(!1)}catch(k){console.error("Error saving admin settings",k)}finally{q(!1)}},nt=()=>{u(S),C(!1)},wt=async()=>{ye(!0),a?.({ruleId:x,levels:[{minutes:oe,role:L},{minutes:v,role:A},{minutes:P,role:J}],actions:ne,thirdPartyIds:Se,humanLoop:me,isAutoExpire:ae});try{if(x){const Y=Array.isArray(ne)?ne.map(z=>Number.isNaN(Number(z))?z:Number(z)):[],_=(ge||[]).find(z=>z?.ruleId===x||z?.ruleName===x||z?.RuleId===x),y=typeof _?.recordId=="number"?_.recordId:_?.ruleId||_?.RuleId||void 0;if(!_||!y){we.toast.error("Unable to find rule identifier for update");return}const M={..._,escalationSettings:{level1UserRoleId:L??0,level1PostAssistTime:oe??0,level2UserRoleId:A??0,level2PostAssistTime:v??0,level3UserRoleId:J??0,level3PostAssistTime:P??0,escalationSettingsActionTypeIds:Y,thirdPartyId:Array.isArray(Se)?Se:[],humanLoop:me,isAutoExpire:ae}},I=await o.updateRule(y,M);I?.responseStatus||I?.Success||I?.success?(we.toast.success("Escalation settings saved"),await xt(),j(void 0),re(void 0),w(void 0),E(void 0),U(void 0),G(void 0),te(void 0),Q([]),ie([]),xe(!1),le(!1)):we.toast.error(I?.errorMessage||I?.Message||"Error saving Escalation Settings")}}catch(Y){console.error("Error saving escalation settings",Y)}finally{ye(!1)}},At=()=>{u("By Severity"),h("By severity"),R("rules"),p(void 0),j(void 0),re(void 0),w(void 0),E(void 0),U(void 0),G(void 0),te(void 0),Q([]),ie([]),xe(!1),le(!1)};return i.jsxs("div",{className:"w-full",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(Yn,{level:4,className:"!mb-2",children:"Admin Settings"}),i.jsxs(f.Spin,{spinning:F,children:[T?i.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",T]}):null,i.jsx(Nl,{sortBy:l,groupBy:m,onChange:k=>{k.sortBy&&(u(k.sortBy),C(!0)),k.groupBy&&(h(k.groupBy),C(!0))},showActions:b,onSave:vt,onClear:nt,saving:D})]})]}),i.jsx(f.Divider,{className:"my-6"}),i.jsxs("div",{children:[i.jsx(Yn,{level:4,className:"!mb-4",children:"Escalation Settings"}),i.jsx(bl,{escBasis:W,setEscBasis:R,selectedSeverity:H,setSelectedSeverity:p,selectedRule:x,setSelectedRule:j,severityOptions:Fe,ruleOptions:ve,minsOptions:dt,roleOptions:ut,l1mins:oe,setL1mins:re,l1role:L,setL1role:w,l2mins:v,setL2mins:E,l2role:A,setL2role:U,l3mins:P,setL3mins:G,l3role:J,setL3role:te,actions:ne,setActions:Q,thirdPartyIds:Se,setThirdPartyIds:ie,humanLoop:me,setHumanLoop:xe,onClear:At,onSave:wt,saving:Z,onActionTypesLoaded:k=>{const Y={};for(const _ of k)typeof _.actionTypeId=="number"&&(Y[_.actionTypeId]=_.name);Ue(Y)},isAutoExpire:ae,setAutoExpire:le})]}),i.jsx(f.Divider,{className:"my-6"}),i.jsx(kl,{entries:ct,userRoles:st,loading:de||r,onEdit:k=>{R("rules");const Y=ct.find(y=>y.id===k),_=e.find(y=>y.RuleId===k)||(Y?e.find(y=>y.Name===Y.ruleOrSeverityLabel):void 0);j(_?_.RuleId:k)}}),i.jsx(f.Divider,{className:"my-6"}),i.jsx(ma,{userRoles:st,rules:e,rawRules:n}),i.jsx(f.Divider,{})]})}const{Title:_n,Text:ss}=f.Typography;function El({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:a}=Me(),o=[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],[c,l]=d.useState("By Severity"),[u,m]=d.useState(new Set),[h,S]=d.useState(null),[g,b]=d.useState(null),[C,D]=d.useState({inApp:!1,sms:!1,email:!1}),[q,F]=d.useState([]),[$,T]=d.useState(!0),[O,W]=d.useState(!1);d.useEffect(()=>{let p=!1;return(async()=>{try{const x=await a.getPreferenceSettings();if(p||!x)return;D({inApp:!!x.inApp,sms:!!x.sms,email:!!x.email});const j=Kn(x.sortBy);l(j==="By Created Date"?"By Created Date":"By Severity"),S(yn(x.doNotDisturbStart)),b(yn(x.doNotDisturbEnd)),Array.isArray(x.anomalyIds)&&m(new Set(x.anomalyIds.map(oe=>String(oe))))}catch(x){console.error("Error in loading my preferences: ",x)}})(),()=>{p=!0}},[]),d.useEffect(()=>{let p=!1;return(async()=>{try{T(!0);const x=await r.getLookups();if(p||!x)return;const j=Array.isArray(x.anomalies)?x.anomalies:[];F(j)}catch(x){console.error("Failed to load anomalies lookups",x)}finally{p||T(!1)}})(),()=>{p=!0}},[]);const R=p=>{m(x=>{const j=new Set(x);return j.has(p)?j.delete(p):j.add(p),j})},H=async()=>{s?.({sortBy:c,subscribedRuleIds:Array.from(u),dnd:{from:h,to:g},channels:C});try{W(!0);const p=h?h.format?.("HH:mm:ss")??"00:00:00":"00:00:00",x=g?g.format?.("HH:mm:ss")??"00:00:00":"00:00:00",j=Array.from(u).map(re=>Number(re)).filter(re=>Number.isFinite(re)),oe=await a.setPreferenceSettings({anomalyIds:j,doNotDisturbStart:p,doNotDisturbEnd:x,inApp:!!C.inApp,sms:!!C.sms,email:!!C.email,sortBy:c});oe?.responseStatus&&we.toast.success(oe?.data||"Preferences updated successfully.")}catch(p){console.error("Error in saving my preferences: ",p)}finally{W(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(f.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:i.jsx(f.Col,{xs:24,md:8,children:i.jsxs(f.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(ss,{className:"text-gray-600",children:"Sort By:"}),i.jsx(f.Select,{className:"w-[240px]",value:c,options:o,onChange:l})]})})}),i.jsxs("div",{className:"mb-4",children:[i.jsx(_n,{level:5,className:"!mb-2",children:"Anomalies"}),$?i.jsx("div",{className:"py-4",children:i.jsx(f.Spin,{})}):i.jsx(f.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray(q)?q:[]).map(p=>{const x=String(p.recordId),j=p.anomalyName;return i.jsx(f.Checkbox,{checked:u.has(x),onChange:()=>R(x),children:j},x)})})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx(_n,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),i.jsx(f.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:i.jsx(f.Col,{xs:24,md:12,children:i.jsxs(f.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(ss,{children:"Do Not Disturb mode:"}),i.jsxs(f.Space,{size:12,className:"w-full",children:[i.jsxs(f.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(ss,{children:"From"}),i.jsx(f.TimePicker,{value:h,onChange:p=>S(p),format:"HH:mm"})]}),i.jsxs(f.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(ss,{children:"To"}),i.jsx(f.TimePicker,{value:g,onChange:p=>b(p),format:"HH:mm"})]})]})]})})}),i.jsxs(f.Row,{gutter:[24,12],children:[i.jsx(f.Col,{children:i.jsx(f.Checkbox,{checked:C.inApp,onChange:p=>D({...C,inApp:p.target.checked}),children:"In-app"})}),i.jsx(f.Col,{children:i.jsx(f.Checkbox,{checked:C.sms,onChange:p=>D({...C,sms:p.target.checked}),children:"SMS"})}),i.jsx(f.Col,{children:i.jsx(f.Checkbox,{checked:C.email,onChange:p=>D({...C,email:p.target.checked}),children:"Email"})})]})]}),i.jsx(f.Divider,{}),i.jsxs(f.Space,{className:"gap-3",children:[i.jsx(f.Button,{onClick:n,disabled:O,children:"Cancel"}),i.jsx(f.Button,{type:"primary",onClick:H,loading:O,children:"Save"})]})]})}function ha({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r}){return i.jsx("div",{className:"w-full",children:i.jsx(fa,{severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r})})}const Ml="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAIZSURBVHgBnZW/b9NAFMe/z3H6i1ZNJUBFQsL/QQkLCFBtRhhKF1ibhBmpXbtgFlYqsTG0gRGWwgAjMb8EYmjYGN0pCCrVVaX+SBxf37PiqHWcOu5Xsux79+6j77vz3RH66IbdsDTQPCFngmBwqMCPBwVXoe204Fd/2ZfrSWMpHrDshtGCvsY9FlKkFNYD+Es/7EtuX+itp1sLnLrScTWoPMYsfnty/lUPtAOs4syiUgQOoWHJpG9kdBiX11Z+UaZCk1YT+vOzACuzYxgf7hZbyBGvhTi9af+7SkQbyKi7M8N4ZJ5D+eU2dg9UN07KvyNOS8io6UkNFXMMj1/vnACKAuTmNXZpIqME+LF+iIbX7ukjkClODWTQw+ujuGYMYfXzXnICbxSBDrxAUvYDhkrZp6ggUC8+sDI7mpj9YmESb3/uJ5Z9TJ5A3eORvzsBpgs6lufGT2TKPNY3fbxh6Knis0FTSjnx+LP3u5DJicDi/t7MCFadPaRJQTl02/5vKcKnpITluYkwrWjksebs48Pvg3SoUkXtq32hxt+1pITI8Zc/zcGACN59ty/WdWnklV5ukZ+49wU8MUJIF3mBGlqUr3Dv1+wpl20v9UuP75pElyrgc3XK7UJFbLvK4DJiv9ggDmWcjO9G4imWvW00yV/hjvtpOFnpQOVLkcO+0EhyevGrROG1ol1hREFc8ZGxyddIje+v9c4i9+gI5z7MozLxclgAAAAASUVORK5CYII=",Ol="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAKeSURBVHgBjVVdbtpAEJ5ZmygPfTBSaVWpUt0bwFuURgJOUG5QeoLACbw+QeAEwA3SGxgJokh9CDeI+xSpTRU/Imw8nbFZx6QQGAl5d2fm229+dkDYI2f6oaUAOwhWExBcPnL4FwFBSLCexpCMf+qPi12++PKgpR/cGOwRa1pwQIjgOoWkf6s/hOVzVd588R+/xWjf5YAY8Y0+ErQrZFfnXg3lK3uGm7A+RISOxfbit5NprqBxxgBoeEIVHehqtI9lSz+5McaaITaA2J17bycFaBayMOS8IaT+zHuv4Ui58P9oAvB4Ga0paUgqbFGswL5idIcIx3P9DCiXrQB7iJawcTiCkMMIUlj7Jo8zr6Yv/EfRXXIqRnzUxnP9u46Id8Q5Sslq3+pqWErHAPKqvxROC/ZMuJwKJ8bkPouUkrYUqgt5IgMDKAxfAYT8nAZnmR2A5J47YSjrFKyOYpZN2SiIJ8YjRqVfASyAFVg9s2F2gXwRsClMXdnYcFpq5PyiQ8KEilaywc79+aEow2i7fdCF46SIpuTvCGi2kWSXjCM4QqS4Zl3yjwQ0UySwrBfGRJNjQKW4ZrmEpL45CxUDTGWdgmoZgxOoDA6zxYgr7ZudhWk3x6Sp4kl0nZmgujQhcH5Cvqy/Hxi5hdL+dgsWxR2rma4FkLeDw+PMM243+t2YB0jDDI9nMBquyWqI3tjmLYguQfqDzxebty/DIcnePr9jfePVfDhSzv2/Hs8LAY3kMmFfTCl+rl3uu1GWF6Jx+X3vkpa+58jeeNyXvY3Pd8N+a0hvgK9ge3hMTmG5CPTnSICWcFpXaDfZUcAck99yOnZM/id3hcmAFV/hgEilU6p0TcH2gpZYS98xc/kXUJ8YImPFzfeLh0cgXbMp8n/yD3ySPZSK0MWKAAAAAElFTkSuQmCC";function vs(){const{config:t}=Me();return{timeZoneDetails:d.useMemo(()=>{const s=t.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone;return{timeZoneUniqueId:"",ianaTimeZoneId:s,timeZoneName:s,offset:""}},[t.timeZone]),loading:!1}}function jl(t){const e=(t.status||"").toLowerCase()==="completed"?i.jsx("img",{src:Ml,alt:"completed",style:{width:20,height:20}}):i.jsx("img",{src:Ol,alt:"pending",style:{width:20,height:20}});return{title:i.jsxs("div",{className:"flex flex-col gap-0 min-w-0",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{className:"block text-sm break-words mb-1 overflow-visible whitespace-normal",children:i.jsx("b",{children:t.title})}),t.description?i.jsx("span",{className:"text-gray-500 text-xs",children:t.description}):null]}),t.timestamp?i.jsx("span",{className:"text-gray-500 text-xs",children:t.timestamp}):null]}),icon:e,description:null}}function Cl({data:t}){const{timeZoneDetails:e}=vs();return console.log("summary",t),i.jsx("div",{className:"w-full",children:i.jsx(f.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:i.jsxs("div",{className:"w-full",style:{maxHeight:"50vh",overflowY:"auto"},children:[i.jsx(f.Card,{className:"mb-4 rounded-md p-4",bordered:!0,children:i.jsxs("div",{className:"grid grid-cols-4 gap-6 text-xs",children:[i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Alert ID"}),i.jsx("span",{className:"text-black",children:t.summary.alertNumber})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Severity"}),i.jsx("span",{className:"text-black",children:t.summary.severity})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Location"}),i.jsx("span",{className:"text-black",children:t.summary.location})]})]})}),i.jsxs(f.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsx("h4",{className:"text-sm text-black font-medium",children:"Response Timeline/ Audit trail/log"})}),i.jsx("div",{className:"mt-2",children:i.jsx(f.Steps,{direction:"vertical",size:"small",current:1,items:(t.timeline||[]).map(jl)})})]})]})},{key:"notification",label:"Notification Sent",children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",style:{maxHeight:"50vh",overflowY:"auto"},children:[(t.notifications||[]).map((s,n)=>i.jsxs(f.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("h4",{className:"text-sm text-black font-medium",children:s.channelLabel}),i.jsx("span",{className:"text-xs text-gray-500 mt-1",children:ms(s.sentAt,e?.ianaTimeZoneId)})]}),i.jsxs("span",{className:"text-[11px] px-2 py-1 rounded-full bg-green-50 text-green-700 border border-green-200",children:[s.delivered,"/",s.total," Delivered"]})]}),i.jsxs("div",{className:"mt-4 text-xs",children:[i.jsxs("div",{className:"text-black",children:[" ",s.messageTitle]}),s.messageBody?i.jsx("div",{className:"text-gray-600",children:s.messageBody}):null]}),i.jsxs("div",{className:"mt-4",children:[i.jsxs("div",{className:"text-xs text-black font-medium",children:["Recipients (",s.total,")"]}),i.jsx("div",{className:"mt-2 flex flex-col gap-3 text-xs",children:(s.recipients||[]).map((r,a)=>{const o=String(r?.notificationReceipientType||"").toLowerCase()==="EscalationNotification".toLowerCase();return i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsxs("span",{className:"text-black",children:[r.name," - ",i.jsx("span",{style:{color:o?"#FF3B30":"#FFB86A"},children:o?"Escalation Notification":"Alert Notification"})]}),i.jsxs("span",{className:"text-gray-500",children:[r.role," . ",r.phone]})]}),i.jsx("span",{className:`text-[11px] px-3 py-[2px] rounded ${r.status==="Delivered"?"bg-green-50 text-green-700 border border-green-200":"bg-red-50 text-red-700 border border-red-200"}`,children:r.status})]},a)})})]})]},n)),t?.notifications?.length?null:i.jsx("span",{className:"text-gray-500 text-xs",children:"No notifications."})]})}]})})}const Dl=({alertId:t,id:e,priority:s,spaceName:n,alertNumber:r,statusHistory:a,notifGroups:o})=>{const c={alertId:t??String(e??""),incidentId:"-",severity:s||"",location:n||"",alertNumber:r??""},{timeZoneDetails:l}=vs(),u=a?.length?a.map(h=>{const S=(h?.status||h?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",g=h?.createdDate?ms(h.createdDate,l?.ianaTimeZoneId):h?.timestamp?ms(h.timestamp,l?.ianaTimeZoneId):"";return{status:S,title:h?.status||h?.eventStatus||"Status Update",description:h?.description||h?.actionNotes||"",timestamp:g}}):[],m={summary:c,timeline:u,notifications:o??[]};return i.jsx(Cl,{data:m})},Rl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Ul={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Ll={"elopement attempt":"elopement","elopement completed":"elopement","watchlist person detected":"watchlist","watch list person detected":"watchlist","brandished guns & knives":"weapon","brandished guns and knives":"weapon"},Fl=({isModalOpen:t,handleModalClose:e,selectedRow:s,fetchAlertLogs:n,alertStatusList:r=[],alertStatusLoading:a=!1,initialTab:o="details",sourceTab:c})=>{const[l,u]=d.useState(),[m,h]=d.useState(""),[S,g]=d.useState(!1),b=d.useRef(null),[C,D]=d.useState("details"),[q,F]=d.useState(void 0),$=Ks(),{alerts:T,rules:O,config:W}=Me(),{timeZoneDetails:R}=vs(),[H,p]=d.useState(null),[x,j]=d.useState(!1),[oe,re]=d.useState(!1),[L,w]=d.useState(void 0),[v,E]=d.useState(void 0),[A,U]=d.useState({}),[P,G]=d.useState({}),J=(y,M,I)=>{const z=P[y];return A[y]===!1&&!z?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(rr,{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:[z&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg z-10",children:i.jsx(mi,{size:32,className:"animate-spin text-gray-400"})}),i.jsx("img",{src:y,alt:M.caption||`media-${I}`,className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg transition-opacity duration-200 ${z?"opacity-0":"opacity-100"}`,onLoad:()=>G(ke=>({...ke,[y]:!1})),onError:()=>G(ke=>({...ke,[y]:!1}))},y)]})},te=s?.originalData||{},{eventName:ne,eventDisplayName:Q,anomalyName:Se,alertId:ie,timestamp:me,description:xe,spaceName:ae,assignTeam:le,priority:Ae,statusType:Ue,id:Le,alertDetails:tt,statusHistory:st,mediaDetails:St,alertNumber:ct}=te,X=W.tenant==="snl"?Q||ne||"Alert Event":ne||"Alert Event",Z=y=>{const M=String(y||"").toLowerCase();return M==="delivered"||M==="sent"?"Delivered":M==="failed"?"Failed":"Queued"},ye=y=>({name:y?.receipientName||y?.recipientName||"-",role:y?.receipientRoleName||"",phone:y?.receipentPhoneNumber||y?.recipientPhoneNumber||y?.receipientEmail||y?.recipientEmail||"",status:Z(y?.messageStatus),notificationReceipientType:y?.notificationReceipientType||""}),de=(y,M)=>{const I=M.map(ye),z=I.filter(Je=>Je.status==="Delivered").length,ke=M.map(Je=>Je?.sentAt).filter(Boolean).sort((Je,_e)=>new Date(_e).getTime()-new Date(Je).getTime())[0],ze=(M[0]||{})?.severityName||`${y} Notification`;return{channelLabel:`${y} Notification`,sentAt:ke||"",messageTitle:ze,messageBody:"",total:I.length,delivered:z,recipients:I}},Te=y=>{const M=new Map;return(y||[]).forEach(I=>{const z=String(I?.notificationType||"Unknown"),ke=M.get(z)||[];ke.push(I),M.set(z,ke)}),Array.from(M.entries()).map(([I,z])=>de(I,z))},ge=async y=>{try{const M=await T.getAlertNotifications(y),I=Te(M);F(I)}catch{F(void 0)}};d.useEffect(()=>{if(C!=="track"||!Le)return;let y=!1;return ge(Le).then(()=>{y&&F(void 0)}),()=>{y=!0}},[C,Le]),d.useEffect(()=>{t?D(o):(u(void 0),h(""))},[t,o]),d.useEffect(()=>{if(!t||W.tenant!=="snl")return;let y=!1;return j(!0),O.getLookups().then(M=>{y||(p(M.alertStatusTypes??[]),j(!1))}).catch(()=>{y||(p([]),j(!1))}),()=>{y=!0}},[t,W.tenant]);const Fe=c==="archived"||["completed","false positive"].includes(String(Ue||"").toLowerCase()),ve=y=>{const M=String(y?.value||"").toLowerCase(),I=String(y?.statusName||"").toLowerCase();return M.includes("reopen")||I.includes("reopen")},ut=String(Se||"").trim().toLowerCase(),dt=Ll[ut]??"general",xt=r.filter(y=>{const M=ve(y);return typeof c<"u"?c==="archived"?M:!M:Fe?M:!M}).map(y=>({value:y.value,label:y.statusName})),vt=H??[],nt=y=>!!y.isWatchListStatus,wt=y=>!!y.isWeapontStatus,At=vt.filter(y=>{switch(dt){case"elopement":return y.isElopementStatus;case"watchlist":return nt(y);case"weapon":return wt(y);default:return!y.isElopementStatus&&!nt(y)&&!wt(y)}}).map(y=>({value:y.alertStatusTypeName,label:y.alertStatusTypeName})),k=W.tenant==="snl"&&H!==null?At:xt,Y=d.useMemo(()=>sr(St),[St]);d.useEffect(()=>{let y=!1;const M=new AbortController,I=async ce=>{if(ce){y||U(ze=>({...ze,[ce]:!1}));try{const ze=await fetch(ce,{method:"HEAD",signal:M.signal});if(ze.ok){y||U(_e=>({..._e,[ce]:!0}));return}if(ze.status===404){y||U(_e=>({..._e,[ce]:!1}));return}if(!(await fetch(ce,{method:"GET",signal:M.signal})).ok)throw new Error("Media not available");y||U(_e=>({..._e,[ce]:!0}))}catch{y||U(ze=>({...ze,[ce]:!1}))}}};U({});const z=Y.filter(ce=>!Us(ce)).map(ce=>ce?.mediaUrl||ce).filter(ce=>typeof ce=="string"&&ce.length>0),ke={};return z.forEach(ce=>{ke[ce]=!0}),G(ke),z.forEach(ce=>I(ce)),()=>{y=!0,M.abort()}},[Y]);const _=async()=>{try{g(!0);const y={alertUniqueId:ie,alertId:Le,status:l?String(l):void 0,notes:m.trim(),modifiedBy:0},M=await $.mutateAsync(y);if(M?.responseStatus||M?.Success){const I=M?.Message||M?.data||"Alert updated successfully.";we.toast.success(I,{autoClose:1500,onClose:()=>{n(),e()}}),u(void 0),h("")}else{const I=M?.errorMessage||M?.Message||"Failed to update alert status";we.toast.error(I)}}catch(y){console.error("Error updating alert status:",y),we.toast.error("Failed to update alert status. Please try again.")}finally{g(!1)}};return i.jsx(f.Modal,{open:t,onCancel:e,width:1e3,footer:C==="details"?i.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[i.jsx(f.Button,{onClick:e,className:"bg-[#6C757D] text-white",children:"Cancel"}),i.jsx(f.Button,{type:"primary",onClick:_,loading:S,children:S?"Saving...":"Save Changes"})]}):null,children:s&&i.jsx(f.Tabs,{activeKey:C,onChange:y=>D(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:X}),tt?.firstName?i.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",tt?.firstName," ",tt?.lastName||"","   ",tt?.residentId||""]}):null,i.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp: ",ms(me,R?.ianaTimeZoneId)]}),i.jsxs("div",{className:"font-sm text-gray-500",children:[i.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",xe||"No description available"]}),ae&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",ae]}),le&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",le]}),i.jsxs("div",{className:"flex gap-2 justify-start mt-3",children:[i.jsxs(f.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${Rl[String(Ae)]||"#DFE4EA"}`,backgroundColor:Ul[String(Ae)]},children:["Severity: ",Ae||"N/A"]}),i.jsxs(f.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(Ue||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",Ue||"N/A"]})]}),i.jsx("div",{className:"w-full flex flex-col justify-start items-start mt-2 font-bold",children:i.jsxs("div",{className:"w-full mt-4",children:[i.jsx("div",{className:"flex flex-col gap-2",children:i.jsx(f.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:y=>u(y),value:l,options:k,loading:W.tenant==="snl"?x: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=>h(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"}),Y.length>1?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>b.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:()=>b.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]}),Y.length?i.jsx("div",{className:"w-full",children:i.jsx(f.Carousel,{ref:b,dots:!0,className:"w-full",children:Y.map((y,M)=>{const I=y.mediaUrl||y,z=Us(y);return i.jsxs("div",{className:"flex justify-center items-center relative",children:[z?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:I}),"Your browser does not support the video tag."]}):J(String(I),y,M),y.caption&&i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:y.caption}),!z&&A[String(I)]?i.jsx("button",{onClick:()=>{re(!0),w(I),E(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(ar,{size:20})}):null]},String(I)||M)})})}):null]})}),i.jsx(ir,{isOpen:oe,onClose:()=>re(!1),src:L||"",type:v||"image"})]})},{key:"track",label:"Track Incident",children:i.jsx(Dl,{alertId:ie,id:Le,priority:Ae,spaceName:ae,alertNumber:ct,statusHistory:st,notifGroups:q})}]})})};function ya(){const{alerts:t}=Me(),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 on({alerts:t,loading:e=!1,columns:s,total:n,currentPage:r,onRefetch:a,onPageChange:o,onFilterChange:c}){const[l,u]=d.useState(!1),[m,h]=d.useState(null),[S,g]=d.useState("details"),{list:b,loading:C}=ya(),{config:D}=Me(),q=D.tenant==="schools",{timeZoneDetails:F}=vs(),$=F?.timeZoneName??"UTC",T=F?.ianaTimeZoneId??"UTC";function O(oe,re){h(oe),g(re?.tab??"details"),H(re?.sourceTab??"active"),u(!0)}function W(){u(!1)}const[R,H]=d.useState("active"),[p,x]=d.useState(0),j=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(da,{label:$,timeZone:T})})]}),i.jsx(f.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:oe=>{const re=oe==="archived";x(L=>L+1),o?.(1),c?.({isArchived:re})},items:[{key:"active",label:"Active",children:i.jsx(Js,{data:t,loading:e,pageSize:10,total:n,currentPage:r,columns:s||[],onAlertIdClick:O,onRefetch:a,onPageChange:o,onFilterChange:c,resetKey:p,serverSideFilters:q})},{key:"archived",label:"Archived",children:i.jsx(ua,{alerts:t,loading:e,columns:s||[],total:n,currentPage:r,onAlertIdClick:O,onFilterChange:c,onPageChange:o,onRefetch:a,resetKey:p,serverSideFilters:q})},{key:"settings",label:"Settings",children:i.jsx($l,{})}]}),i.jsx(Fl,{isModalOpen:l,handleModalClose:W,selectedRow:j,fetchAlertLogs:()=>{},alertStatusList:b,alertStatusLoading:C,initialTab:S,sourceTab:R})]})}function $l(){const[t,e]=d.useState([]),[s,n]=d.useState([]),[r,a]=d.useState([]),[o,c]=d.useState([]),[l,u]=d.useState(!0),{rules:m}=Me();return d.useEffect(()=>{let h=!0;return(async()=>{try{const S=await m.getRules();if(!h)return;c(Array.isArray(S)?S:[]);const g=(S||[]).map((b,C)=>({RuleId:b.ruleId||b.ruleName||String(C),Name:b.ruleName||b.Name||"-",Description:b.ruleDesc||b.Description||"",SeverityId:0}));e(g);try{const b=await m.getLookups(),C=Array.isArray(b?.userRoles)?b.userRoles.map(D=>({userRoleId:D.userRoleId??D.id,userRoleName:D.userRoleName??D.name})):[];n(C),a(Array.isArray(b?.severities)?b.severities:[])}catch{}}catch{}finally{h&&u(!1)}})(),()=>{h=!1}},[]),i.jsx(ha,{severities:r,rules:t,userRoles:s,rawRules:o,loadingRules:l})}function Pl(t){return Array.isArray(t)?{items:t}:t}function pa(t=1,e){const{alerts:s,config:n}=Me(),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==="transit"||n.tenant==="schools")&&(o.pageNumber=t,o.pageSize=10),s.listAlerts(o).then(Pl)},staleTime:r?0:3e4});return{alerts:a.data?.items??[],total:a.data?.total,loading:a.isLoading,error:a.error,refetch:a.refetch}}function Wl(t){const[e,s]=d.useState(1),[n,r]=d.useState({}),{alerts:a,total:o,loading:c,refetch:l}=pa(e,n),u=m=>{"isArchived"in m?r({isArchived:m.isArchived}):r(h=>({...h,...m}))};return i.jsx(on,{alerts:a,loading:c,columns:t.columns,total:o,currentPage:e,onRefetch:l,onPageChange:s,onFilterChange:u})}function Vl({tenant:t,apiDomain:e,rulesDomain:s,headers:n,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,alerts:c,loading:l,columns:u}){const[m]=d.useState(()=>new pt.QueryClient),h=d.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return i.jsx(pt.QueryClientProvider,{client:m,children:i.jsx(er,{tenant:t,override:h,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,children:Array.isArray(c)?i.jsx(on,{alerts:c,loading:!!l,columns:u}):i.jsx(Wl,{columns:u})})})}function Bl(t){const{alerts:e}=Me(),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 Zl=[{title:"ID",dataIndex:"id",key:"id",width:120},{title:"Priority",dataIndex:"priority",key:"priority",width:120},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:220},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description"}];exports.AlertAssignment=ma;exports.AlertConsole=on;exports.AlertConsoleWidget=Vl;exports.AlertsTable=Js;exports.ApiProvider=er;exports.ArchivedTable=ua;exports.Clock=da;exports.DataTable=tr;exports.MyPreferencesPanel=El;exports.SettingsPanel=fa;exports.SettingsTabs=ha;exports.exampleAlertColumns=Zl;exports.useAlertStatusList=ya;exports.useAlerts=pa;exports.useAlertsReport=Bl;exports.useApi=Me;exports.useUpdateAlertStatus=Ks;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),d=require("react"),f=require("antd"),gt=require("@ant-design/icons"),we=require("react-toastify"),St=require("@tanstack/react-query"),Sa="#FF3B30",xa="#FF9500",va="#FFCC00",wa="#34C759",Ht={critical:Sa,high:xa,medium:va,low:wa},cn={Critical:Ht.critical,High:Ht.high,Medium:Ht.medium,Low:Ht.low};function Aa(t){return cn[t]||cn.Low}function un(t){if(!t||typeof t!="string")return 0;const e=t.trim().split(":");if(e.length!==3)return 0;const[s,n,r]=e,a=Number.parseInt(s,10),o=Number.parseInt(n,10),c=Number.parseFloat(r||"0"),l=Number.isFinite(a)?a:0,u=Number.isFinite(o)?o:0,m=Number.isFinite(c)?c:0;return l*3600+u*60+m}function dn(t){const e=t.thirdPartyIds??t.ThirdPartyIds??t.thirdPartyId??t.ThirdPartyId??"",s=Array.isArray(e)?e.join(","):String(e??"");if(!s||!s.trim())return[];const n=s.split(",").map(o=>parseInt(String(o).trim(),10)).filter(o=>Number.isFinite(o)),r=new Set,a=[];return n.forEach(o=>{r.has(o)||(r.add(o),a.push(o))}),a}function os(t){return t.toLowerCase().replaceAll("'","").replaceAll("‘","").replaceAll("’","")}const Jn="",Ta=Jn,Na="",ba="",ka="",Ia="",mn={snl:{alerts:Jn,rules:Ta},schools:{alerts:Na,rules:ba},transit:{alerts:ka,rules:Ia}};function Ce(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ea(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function qt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function De(t,e){const s={...e.headers,...Ea()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Ma(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=Ce(t.baseUrl,"/api/Alert"),n=await De(s,{method:"GET",headers:e});return Array.isArray(n)?n:[]},async getAlertStatusList(){const s=Ce(t.baseUrl,"/api/Alert/AlertStatusList"),n=await De(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getAlertsReport(s){const n=Ce(t.baseUrl,"/Alerts/GetAlertsReport"),r=qt(n,s),a=await De(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Ce(t.baseUrl,"/api/Alert/status");return De(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=Ce(t.baseUrl,"/api/Alert/GetAdminSettings"),n=await De(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("userId"in n)return n}return null},async setAdminSettings(s){const n=Ce(t.baseUrl,"/api/Alert/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return De(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Ce(t.baseUrl,"/api/Alert/GetPreferenceSettings"),n=await De(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=Ce(t.baseUrl,"/api/Alert/SetPreferenceSettings"),r=await De(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,o=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":r?.errorMessage??r?.message??"",statusCode:200,data:o}},async getAlertNotifications(s){const n=Ce(t.baseUrl,"/api/Alert/GetNotifications"),r=qt(n,{alertId:s}),a=await De(r,{method:"GET",headers:e});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]},async notifyFamilyMembers(s){const n=Ce(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=qt(n,{alertId:s});return De(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const a=Ce(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),o=qt(a,{alertId:s,isEmail:n,isSMS:r});return De(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Ce(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await De(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Ce(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await De(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null}}}function fn(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Oa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Gt(t,e){const s={...e.headers,...Oa()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function ja(t){const e={"Content-Type":"application/json",...t.headers||{}},s=fn(t.baseUrl,"/api/Rules"),n=fn(t.baseUrl,"/api/Rules/lookups");return{async getRules(){const r=await Gt(s,{method:"GET",headers:e});return Array.isArray(r)?r:[]},async setEscalationSettings(r){return Gt(s,{method:"POST",headers:e,body:JSON.stringify(r??{})})},async getLookups(){return Gt(n,{method:"GET",headers:e})},async updateRule(r,a){const o=`${s}/${r}`;return Gt(o,{method:"PUT",headers:e,body:JSON.stringify(a??{})})}}}function Ca(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ns={exports:{}},Da=ns.exports,hn;function Ra(){return hn||(hn=1,(function(t,e){(function(s,n){t.exports=n()})(Da,(function(){var s=1e3,n=6e4,r=36e5,a="millisecond",o="second",c="minute",l="hour",u="day",m="week",h="month",S="quarter",g="year",b="date",j="Invalid Date",C=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,G=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,F={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(U){var w=["th","st","nd","rd"],v=U%100;return"["+U+(w[(v-20)%10]||w[v]||w[0])+"]"}},$=function(U,w,v){var I=String(U);return!I||I.length>=w?U:""+Array(w+1-I.length).join(v)+U},T={s:$,z:function(U){var w=-U.utcOffset(),v=Math.abs(w),I=Math.floor(v/60),A=v%60;return(w<=0?"+":"-")+$(I,2,"0")+":"+$(A,2,"0")},m:function U(w,v){if(w.date()<v.date())return-U(v,w);var I=12*(v.year()-w.year())+(v.month()-w.month()),A=w.clone().add(I,h),R=v-A<0,P=w.clone().add(I+(R?-1:1),h);return+(-(I+(v-A)/(R?A-P:P-A))||0)},a:function(U){return U<0?Math.ceil(U)||0:Math.floor(U)},p:function(U){return{M:h,y:g,w:m,d:u,D:b,h:l,m:c,s:o,ms:a,Q:S}[U]||String(U||"").toLowerCase().replace(/s$/,"")},u:function(U){return U===void 0}},M="en",V={};V[M]=F;var D="$isDayjsObject",q=function(U){return U instanceof le||!(!U||!U[D])},p=function U(w,v,I){var A;if(!w)return M;if(typeof w=="string"){var R=w.toLowerCase();V[R]&&(A=R),v&&(V[R]=v,A=R);var P=w.split("-");if(!A&&P.length>1)return U(P[0])}else{var Y=w.name;V[Y]=w,A=Y}return!I&&A&&(M=A),A||!I&&M},x=function(U,w){if(q(U))return U.clone();var v=typeof w=="object"?w:{};return v.date=U,v.args=arguments,new le(v)},O=T;O.l=p,O.i=q,O.w=function(U,w){return x(U,{locale:w.$L,utc:w.$u,x:w.$x,$offset:w.$offset})};var le=(function(){function U(v){this.$L=p(v.locale,null,!0),this.parse(v),this.$x=this.$x||v.x||{},this[D]=!0}var w=U.prototype;return w.parse=function(v){this.$d=(function(I){var A=I.date,R=I.utc;if(A===null)return new Date(NaN);if(O.u(A))return new Date;if(A instanceof Date)return new Date(A);if(typeof A=="string"&&!/Z$/i.test(A)){var P=A.match(C);if(P){var Y=P[2]-1||0,J=(P[7]||"0").substring(0,3);return R?new Date(Date.UTC(P[1],Y,P[3]||1,P[4]||0,P[5]||0,P[6]||0,J)):new Date(P[1],Y,P[3]||1,P[4]||0,P[5]||0,P[6]||0,J)}}return new Date(A)})(v),this.init()},w.init=function(){var v=this.$d;this.$y=v.getFullYear(),this.$M=v.getMonth(),this.$D=v.getDate(),this.$W=v.getDay(),this.$H=v.getHours(),this.$m=v.getMinutes(),this.$s=v.getSeconds(),this.$ms=v.getMilliseconds()},w.$utils=function(){return O},w.isValid=function(){return this.$d.toString()!==j},w.isSame=function(v,I){var A=x(v);return this.startOf(I)<=A&&A<=this.endOf(I)},w.isAfter=function(v,I){return x(v)<this.startOf(I)},w.isBefore=function(v,I){return this.endOf(I)<x(v)},w.$g=function(v,I,A){return O.u(v)?this[I]:this.set(A,v)},w.unix=function(){return Math.floor(this.valueOf()/1e3)},w.valueOf=function(){return this.$d.getTime()},w.startOf=function(v,I){var A=this,R=!!O.u(I)||I,P=O.p(v),Y=function(Se,oe){var ce=O.w(A.$u?Date.UTC(A.$y,oe,Se):new Date(A.$y,oe,Se),A);return R?ce:ce.endOf(u)},J=function(Se,oe){return O.w(A.toDate()[Se].apply(A.toDate("s"),(R?[0,0,0,0]:[23,59,59,999]).slice(oe)),A)},Q=this.$W,se=this.$M,X=this.$D,ye="set"+(this.$u?"UTC":"");switch(P){case g:return R?Y(1,0):Y(31,11);case h:return R?Y(1,se):Y(0,se+1);case m:var ie=this.$locale().weekStart||0,me=(Q<ie?Q+7:Q)-ie;return Y(R?X-me:X+(6-me),se);case u:case b:return J(ye+"Hours",0);case l:return J(ye+"Minutes",1);case c:return J(ye+"Seconds",2);case o:return J(ye+"Milliseconds",3);default:return this.clone()}},w.endOf=function(v){return this.startOf(v,!1)},w.$set=function(v,I){var A,R=O.p(v),P="set"+(this.$u?"UTC":""),Y=(A={},A[u]=P+"Date",A[b]=P+"Date",A[h]=P+"Month",A[g]=P+"FullYear",A[l]=P+"Hours",A[c]=P+"Minutes",A[o]=P+"Seconds",A[a]=P+"Milliseconds",A)[R],J=R===u?this.$D+(I-this.$W):I;if(R===h||R===g){var Q=this.clone().set(b,1);Q.$d[Y](J),Q.init(),this.$d=Q.set(b,Math.min(this.$D,Q.daysInMonth())).$d}else Y&&this.$d[Y](J);return this.init(),this},w.set=function(v,I){return this.clone().$set(v,I)},w.get=function(v){return this[O.p(v)]()},w.add=function(v,I){var A,R=this;v=Number(v);var P=O.p(I),Y=function(se){var X=x(R);return O.w(X.date(X.date()+Math.round(se*v)),R)};if(P===h)return this.set(h,this.$M+v);if(P===g)return this.set(g,this.$y+v);if(P===u)return Y(1);if(P===m)return Y(7);var J=(A={},A[c]=n,A[l]=r,A[o]=s,A)[P]||1,Q=this.$d.getTime()+v*J;return O.w(Q,this)},w.subtract=function(v,I){return this.add(-1*v,I)},w.format=function(v){var I=this,A=this.$locale();if(!this.isValid())return A.invalidDate||j;var R=v||"YYYY-MM-DDTHH:mm:ssZ",P=O.z(this),Y=this.$H,J=this.$m,Q=this.$M,se=A.weekdays,X=A.months,ye=A.meridiem,ie=function(oe,ce,xe,Ue){return oe&&(oe[ce]||oe(I,R))||xe[ce].slice(0,Ue)},me=function(oe){return O.s(Y%12||12,oe,"0")},Se=ye||function(oe,ce,xe){var Ue=oe<12?"AM":"PM";return xe?Ue.toLowerCase():Ue};return R.replace(G,(function(oe,ce){return ce||(function(xe){switch(xe){case"YY":return String(I.$y).slice(-2);case"YYYY":return O.s(I.$y,4,"0");case"M":return Q+1;case"MM":return O.s(Q+1,2,"0");case"MMM":return ie(A.monthsShort,Q,X,3);case"MMMM":return ie(X,Q);case"D":return I.$D;case"DD":return O.s(I.$D,2,"0");case"d":return String(I.$W);case"dd":return ie(A.weekdaysMin,I.$W,se,2);case"ddd":return ie(A.weekdaysShort,I.$W,se,3);case"dddd":return se[I.$W];case"H":return String(Y);case"HH":return O.s(Y,2,"0");case"h":return me(1);case"hh":return me(2);case"a":return Se(Y,J,!0);case"A":return Se(Y,J,!1);case"m":return String(J);case"mm":return O.s(J,2,"0");case"s":return String(I.$s);case"ss":return O.s(I.$s,2,"0");case"SSS":return O.s(I.$ms,3,"0");case"Z":return P}return null})(oe)||P.replace(":","")}))},w.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},w.diff=function(v,I,A){var R,P=this,Y=O.p(I),J=x(v),Q=(J.utcOffset()-this.utcOffset())*n,se=this-J,X=function(){return O.m(P,J)};switch(Y){case g:R=X()/12;break;case h:R=X();break;case S:R=X()/3;break;case m:R=(se-Q)/6048e5;break;case u:R=(se-Q)/864e5;break;case l:R=se/r;break;case c:R=se/n;break;case o:R=se/s;break;default:R=se}return A?R:O.a(R)},w.daysInMonth=function(){return this.endOf(h).$D},w.$locale=function(){return V[this.$L]},w.locale=function(v,I){if(!v)return this.$L;var A=this.clone(),R=p(v,I,!0);return R&&(A.$L=R),A},w.clone=function(){return O.w(this.$d,this)},w.toDate=function(){return new Date(this.valueOf())},w.toJSON=function(){return this.isValid()?this.toISOString():null},w.toISOString=function(){return this.$d.toISOString()},w.toString=function(){return this.$d.toUTCString()},U})(),ae=le.prototype;return x.prototype=ae,[["$ms",a],["$s",o],["$m",c],["$H",l],["$W",u],["$M",h],["$y",g],["$D",b]].forEach((function(U){ae[U[1]]=function(w){return this.$g(w,U[0],U[1])}})),x.extend=function(U,w){return U.$i||(U(w,le,x),U.$i=!0),x},x.locale=p,x.isDayjs=q,x.unix=function(U){return x(1e3*U)},x.en=V[M],x.Ls=V,x.p={},x}))})(ns)),ns.exports}var Ua=Ra();const La=Ca(Ua);function Kn(t){if(!t)return"By Severity";const e=t.trim().toLowerCase();return e.includes("created")?"By Created Date":e.includes("updated")||e.includes("modified")?"By Updated Date":"By Severity"}function Qn(t){if(!t||typeof t!="string")return{hours:0,minutes:0,seconds:0};const e=t.split(":").map(a=>parseInt(a,10)),s=Number.isFinite(e[0])?e[0]:0,n=Number.isFinite(e[1])?e[1]:0,r=Number.isFinite(e[2])?e[2]:0;return{hours:s,minutes:n,seconds:r}}function yn(t){const{hours:e,minutes:s,seconds:n}=Qn(t);return La().hour(e).minute(s).second(n).millisecond(0)}function Me(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Fa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function 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 Oe(t,e){const s={...e.headers,...Fa()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.Message||`HTTP ${n.status}`;throw new Error(o)}return a}const de=(...t)=>t.find(e=>e!=null);function Ut(t,e,s={}){const n={};for(const r of e){const a=s[r]??r.charAt(0).toUpperCase()+r.slice(1);n[r]=t?.[a]??t?.[r]}return n}function $a(t){return Array.isArray(t)?t.map(e=>Ut(e,["alertLogId","alertId","status","description","actionNotes","createdDate","createdBy","modifiedDate","modifiedBy"])):t}function Pa(t){return{id:String(de(t?.AlertId,t?.alertId)??""),alertNumber:de(t?.AlertNumber,t?.alertNumber),priority:de(t?.Priority,t?.priority,"Low"),timestamp:de(t?.UpdatedUtc,t?.timestamp,""),statusType:de(t?.Status,t?.statusType,""),description:de(t?.Description,t?.description,""),eventName:de(t?.EventName,t?.eventName),ruleName:de(t?.RuleName,t?.ruleName),spaceId:de(t?.SpaceId,t?.spaceId),spaceName:de(t?.SpaceName,t?.spaceName),anomalyId:de(t?.AnomalyId,t?.anomalyId),severityId:de(t?.SeverityId,t?.severityId),assignTeam:de(t?.AssignTeam,t?.assignTeam),cameraName:de(t?.CameraName,t?.cameraName),type:de(t?.Type,t?.type),mediaDetails:de(t?.MediaDetails,t?.mediaDetails,t?.MediaUrls,t?.mediaUrls),additionalMedia:de(t?.AdditionalMedia,t?.additionalMedia),timeElapsed:de(t?.TimeElapsed,t?.timeElapsed),timeRemaining:de(t?.TimeRemaining,t?.timeRemaining),anomalyName:de(t?.AnomalyName,t?.anomalyName),alertDetails:de(t?.AlertDetails,t?.alertDetails),statusHistory:$a(de(t?.StatusHistory,t?.statusHistory)),isEmailSent:de(t?.IsEmailSent,t?.isEmailSent),isSMSSent:de(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:de(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function Wa(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=Me(t.baseUrl,"/api/detectionpolicy/alerts"),r=Yt(n,{customerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",pageSize:s?.pageSize??10,page:s?.pageNumber??1,...s?.anomalyId!==void 0&&{anomalyId:s.anomalyId},...s?.spaceId!==void 0&&{spaceId:s.spaceId},...s?.severityId!==void 0&&{severityId:s.severityId},...s?.thirdPartyIds?.length&&{ThirdPartyIds:s.thirdPartyIds.join(",")},...s?.searchText&&{searchText:s.searchText},isArchived:s?.isArchived??!1}),a=await Oe(r,{method:"GET",headers:e});return{items:Array.isArray(a?.Items)?a.Items.map(Pa):[],total:a?.Total}},async getAlertStatusList(){const s=Me(t.baseUrl,"/api/detectionpolicy/alerts/StatusList"),n=await Oe(s,{method:"GET",headers:e});return(Array.isArray(n)?n:[]).map(a=>Ut(a,["alertStatusId","value","statusName"]))},async getAlertsReport(s){const n=Me(t.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),r=Yt(n,s),a=await Oe(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Me(t.baseUrl,"/api/detectionpolicy/alerts/Log"),r={AlertId:s.alertId??s.alertUniqueId??s.AlertId,Status:s.status??s.Status??"",Notes:s.notes??s.Notes??""};return Oe(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getAdminSettings(){const s=Me(t.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),n=await Oe(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n.Data??n;if(r&&typeof r=="object")return Ut(r,["userId","isAdminSetting","sortBy"],{sortBy:"SortOption"})}return null},async setAdminSettings(s){const n=Me(t.baseUrl,"/api/detectionpolicy/alerts/SetAdminSettings"),r={Settings:{UserId:0,IsAdminSetting:!0,SortOption:s?.sortBy??"",GroupBy:s?.groupBy??null}};return Oe(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Me(t.baseUrl,"/api/detectionpolicy/alerts/GetPreferenceSettings"),n=await Oe(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=Me(t.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),r=u=>{const{hours:m,minutes:h,seconds:S}=Qn(u);return(m*3600+h*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 Oe(n,{method:"POST",headers:e,body:JSON.stringify(a)}),c=o?.responseStatus??!0,l=o?.data??o?.message??"Preferences updated successfully.";return{responseStatus:c,errorMessage:c?"":o?.errorMessage??o?.Message??o?.message??"",statusCode:200,data:l}},async sendSMSorEmailNotifications(s,n,r){const a=Me(t.baseUrl,"/api/detectionpolicy/alerts/SendSMSorEmailNotifications"),o=Yt(a,{alertId:s,isEmail:n,isSMS:r});return Oe(o,{method:"POST",headers:e})},async getAlertNotifications(s){const n=Me(t.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),r=Yt(n,{alertId:s}),a=await Oe(r,{method:"GET",headers:e});let o=[];return Array.isArray(a)?o=a:Array.isArray(a?.data)&&(o=a.data),o.map(c=>Ut(c,["alertNotificationSentId","alertId","notificationType","receipientName","receipentPhoneNumber","messageSID","messageStatus","receipientEmail","notificationReceipientType","sentAt"]))},async getTimeZoneMasters(){const s=Me(t.baseUrl,"/api/TimeZoneMaster"),n=await Oe(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n.Data:[]).map(a=>Ut(a,["timeZoneUniqueId","ianaTimeZoneId","timeZoneName","offset"]))},async getAllSpaces(){const s=t.spacesBaseUrl||t.baseUrl,n=Me(s,"/api/AllSpaces"),r=await Oe(n,{method:"GET",headers:e});return(Array.isArray(r?.Data)?r.Data:[]).map(o=>({spaceId:o?.SpaceId??o?.spaceId,spaceName:o?.SpaceName??o?.spaceName??""}))},async getMyAppPreferences(){const s=Me(t.baseUrl,"/MyProfile"),n=await Oe(s,{method:"GET",headers:e}),r=n?.data?.userGuid??n?.Data?.userGuid??n?.userGuid;if(!r)return null;const a=Me(t.baseUrl,`/api/GetMyAppPreferences/${r}`),o=await Oe(a,{method:"GET",headers:e});if(o&&typeof o=="object"){const c=o.data??o.Data??o,l=c?.timeZoneUniqueId??c?.TimeZoneUniqueId;if(l)return{timeZoneUniqueId:l}}return null}}}function Va(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Ke(t,e){const s={...e.headers,...Va()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Ba(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/api/detectionpolicy/rules",t.baseUrl).toString();return{async getRules(){const n=await Ke(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 Ke(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=[Ke(n("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:e}),Ke(n("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:e}),Ke(n("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:e}),Ke(n("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:e}),Ke(n("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:e}),Ke(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,c,l,u,m,h]=await Promise.allSettled(a),S=p=>{if(p.status!=="fulfilled")return[];const x=p.value;return Array.isArray(x)?x:Array.isArray(x?.Data)?x.Data:Array.isArray(x?.data)?x.data:[]},g=S(o),b=S(c),j=S(l),C=S(u),G=S(m),F=h.status==="fulfilled"?h.value:null;let $=[];Array.isArray(F)?$=F:Array.isArray(F?.Data)?$=F.Data:Array.isArray(F?.data)&&($=F.data);const T=g.map(p=>({actionTypeId:Number(p?.ActionTypeId),name:p?.DisplayName??p?.Name??""})),M=b.map(p=>({recordId:p?.AnomalyId,anomalyName:p?.DisplayName??p?.Name??""})),V=j.map(p=>({thirdPartyId:Number(p?.ThirdPartyId),thirdPartyName:p?.ThirdPartyName??p?.Name??""})),D=$.map(p=>({userRoleId:p.UserRoleId??p.userRoleId??p.Id??p.id??0,userRoleName:p.UserRoleName??p.userRoleName??p.Name??p.name??""})),q={actionTypes:T,anomalies:M,thirdParties:V};return C.length&&(q.severities=C.map(p=>({severityId:p?.SeverityId??p?.severityId,severityName:p?.DisplayName??p?.SeverityName??p?.Name??p?.name??""}))),G.length&&(q.scheduleTypes=G),D.length&&(q.userRoles=D),q},async updateRule(n,r){const a=`${s}/${n}`,{escalationSettings:o,Anomaly:c,Severity:l,...u}=r??{};return Ke(a,{method:"PUT",headers:e,body:JSON.stringify({...u,CustomerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",Version:{DeDupWindowSeconds:0,IncludeSubjectInHash:!0},AnomalyId:c?.AnomalyId,SeverityId:l?.SeverityId,EscalationSettings:o?{...o,ThirdPartyIds:o.thirdPartyId??[]}:{}})})}}}function Za(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function nt(t,e){const s={...e.headers,...Za()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function za(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/list-rule",t.baseUrl).toString();return{async getRules(){const n=await nt(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 nt(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=D=>new URL(D,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[nt(n("/api/ActionTypeMaster/GetAll"),{method:"GET",headers:e}),nt(n("/api/anomaly/anomaly-list"),{method:"POST",headers:e,body:JSON.stringify({RuleLevel:1})}),nt(n("/api/Lookup/ThirdParties"),{method:"GET",headers:e}),nt(n("/api/anomaly/severity-list"),{method:"GET",headers:e}),nt(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,c,l,u,m]=await Promise.allSettled(a),h=D=>{if(D.status!=="fulfilled")return[];const q=D.value;return Array.isArray(q)?q:Array.isArray(q?.data)?q.data:[]},S=h(o),g=h(c),b=h(l),j=h(u),C=m.status==="fulfilled"?m.value:null,G=S.map(D=>({actionTypeId:D?.ActionTypeUniqueId,name:D?.Name??""})),F=g.map(D=>({recordId:D?.AnomalyId,anomalyName:D?.DisplayName??D?.Name??""})),$=b.map(D=>({thirdPartyId:Number(D?.ThirdPartyId),thirdPartyName:D?.ThirdPartyName??D?.Name??""}));let T=[];Array.isArray(C)?T=C:Array.isArray(C?.Data)?T=C.Data:Array.isArray(C?.data)&&(T=C.data);const M=T.map(D=>({userRoleId:D.userRoleId??0,userRoleName:D.userRoleName??""})),V={actionTypes:G,anomalies:F,thirdParties:$};return j.length&&(V.severities=j.map(D=>({SeverityId:D.SeverityId,DisplayName:D.SeverityName??D.DisplayName??""}))),M.length&&(V.userRoles=M),V},async updateRule(n,r){const a=new URL("/update-rule",t.baseUrl).toString(),{escalationSettings:o,ruleId:c,ruleName:l,ruleDesc:u,...m}=r??{},h=o??{},S=(h.escalationSettingsActionTypeIds??[]).filter(b=>b!=null&&!Number.isNaN(b)),g={Level1UserRoleId:h.level1UserRoleId??0,Level1PostAssistTime:h.level1PostAssistTime??0,Level2UserRoleId:h.level2UserRoleId??0,Level2PostAssistTime:h.level2PostAssistTime??0,Level3UserRoleId:h.level3UserRoleId??0,Level3PostAssistTime:h.level3PostAssistTime??0,EscalationSettingsActionTypeIds:S,ThirdPartyIds:h.thirdPartyId??[],HumanLoop:h.humanLoop??!1};return nt(a,{method:"POST",headers:e,body:JSON.stringify({...m,RuleId:c??m.RuleId??n,RuleName:l??m.RuleName,RuleDesc:u??m.RuleDesc??null,ActionTypeUniqueIdList:S,EscalationSettings:g})})}}}function $e(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ha(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function _t(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Pe(t,e){const s={...e.headers,...Ha()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function qa(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=$e(t.baseUrl,"/api/Alerts"),r=_t(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 Pe(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=$e(t.baseUrl,"/api/Alerts/GetAlertStatus"),n=await Pe(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=$e(t.baseUrl,"/Alerts/GetAlertsReport"),r=_t(n,s),a=await Pe(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=$e(t.baseUrl,"/api/Alerts/UpdateAlertLog"),r={alertId:s.alertId,action:s.status,notes:s.notes};return Pe(n,{method:"PUT",headers:e,body:JSON.stringify(r??{})})},async getAdminSettings(){const s=$e(t.baseUrl,"/api/Alerts/GetAdminSettings"),n=await Pe(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=$e(t.baseUrl,"/api/Alerts/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Pe(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=$e(t.baseUrl,"/api/Alerts/GetPreferenceSettings"),n=await Pe(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=$e(t.baseUrl,"/api/Alerts/SetPreferenceSettings"),r=await Pe(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=$e(t.baseUrl,"/api/Alerts/GetNotifications"),r=_t(n,{alertId:s}),a=await Pe(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=$e(t.baseUrl,"/api/Alerts/SendSMSorEmailNotifications"),o=_t(a,{alertId:s,isEmail:n,isSMS:r});return Pe(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=$e(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Pe(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=$e(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Pe(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null}}}const Xn=d.createContext(null);function er({tenant:t="snl",override:e,timeZone:s,userManagementDomain:n,spacesBaseUrl:r,children:a}){const o=d.useMemo(()=>{const l=e?.alertsBaseUrl?.trim()||mn[t]?.alerts||"";let u=e?.rulesBaseUrl?.trim()||mn[t]?.rules||"";t==="snl"&&(u=l);const m=e?.headers;return{tenant:t,alertsBaseUrl:l,rulesBaseUrl:u,headers:m,timeZone:s,userManagementDomain:n,spacesBaseUrl:r}},[t,e?.alertsBaseUrl,e?.rulesBaseUrl,JSON.stringify(e?.headers||{}),s,n,r]),c=d.useMemo(()=>{const l={baseUrl:o.alertsBaseUrl,headers:o.headers},u={baseUrl:o.rulesBaseUrl,headers:o.headers},m={schools:()=>Wa({...l,spacesBaseUrl:o.spacesBaseUrl}),transit:()=>qa(l),snl:()=>Ma(l)},h={schools:()=>Ba({...u,userManagementBaseUrl:o.userManagementDomain}),transit:()=>za({...u,userManagementBaseUrl:o.userManagementDomain}),snl:()=>ja({baseUrl:o.alertsBaseUrl,headers:o.headers})};return{config:o,alerts:m[o.tenant](),rules:h[o.tenant]()}},[o]);return i.jsx(Xn.Provider,{value:c,children:a})}function Ee(){const t=d.useContext(Xn);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}const Ga={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Ya={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Ys=6,_s=7;function pn(t,e,s){const n=t===Ys,r=t===_s,a=e.isEmailSent??!1,o=e.isSMSSent??!1,c=n&&a||r&&o,l=n?"Send Email":r?"Send SMS":s,u=n&&a?"Email sent":r&&o?"SMS sent":l,m=n&&a?"Email sent":r&&o?"SMS sent":`Click to ${l}`;return{isDisabled:c,buttonText:u,tooltipTitle:m}}function tr(t,e){const s=e==="anomalyDisplayName"?t.anomalyDisplayName:t.anomalyName;return typeof s=="string"&&s.trim().length>0?s.trim():""}function _a(t,e="anomalyName"){const s=new Set;(t||[]).forEach(r=>{const a=tr(r,e);a&&s.add(a)});const n=Array.from(s).map(r=>({label:r,value:r}));return[{label:"All Types",value:"All"},...n]}function Ja(t,e=!1){const s=new Set;(t||[]).forEach(r=>{const a=e?r.spaceNumber??r.spaceName:r.spaceName;typeof a=="string"&&a.trim().length>0&&s.add(a.trim())});const n=Array.from(s).map(r=>({label:r,value:r}));return[{label:"All",value:"All"},...n]}function Ts(t,e){return`${t}-${e?"email":"sms"}`}function Jt(t){return t===Ys||t===_s}function fs({value:t,onChange:e,options:s,className:n,dropdownWidth:r}){return i.jsx(f.Select,{className:n,options:s,value:t,onChange:e,dropdownMatchSelectWidth:r??260})}const Ka=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function Qa({value:t,onChange:e,options:s}){return i.jsx(fs,{className:"w-[140px]",value:t,onChange:e,options:s||Ka})}const Xa=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function ei({value:t,onChange:e,options:s}){return i.jsx(fs,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||Xa})}function ti({value:t,onChange:e,options:s}){return i.jsx(fs,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const si=[{label:"All",value:"All"},{label:"SOS",value:"SOS"},{label:"911",value:"911"},{label:"Aegix",value:"Aegix"},{label:"Eli",value:"Eli"},{label:"Skydio",value:"Skydio"}];function ni({value:t,onChange:e,options:s}){return i.jsx(fs,{className:"w-[130px]",value:t,onChange:e,options:s||si})}function sr({columns:t,data:e,loading:s=!1,pageSize:n=10,total:r,currentPage:a,rowKey:o="id",toolbar:c,tableProps:l,onPageChange:u}){const h=r===void 0&&a!==void 0?e.length===n?a*n+1:(a-1)*n+e.length:void 0;return i.jsxs("div",{children:[c,i.jsx(f.Table,{rowKey:o,dataSource:e,columns:t,loading:s,pagination:{pageSize:n,current:a,total:r??h,showSizeChanger:!1,showTotal:S=>`Total: ${S}`,onChange:u},bordered:!0,...l})]})}function ri(t){if(!t||typeof t!="string")return!1;const e=t.split("?")[0].toLowerCase();return e.endsWith(".mp4")||e.endsWith(".webm")||e.endsWith(".ogg")||e.endsWith(".m3u8")}function Us(t){const e=(t?.mediaType||t?.type||"").toString().toLowerCase();return e==="video"||e==="mp4"?!0:ri(t?.mediaUrl||t)}function ai(t){const e=t?.mediaUrl;let s=null;if(Array.isArray(e))s=e;else if(typeof e=="string")try{const n=JSON.parse(e);Array.isArray(n)&&(s=n)}catch{}return s&&s.length>0?s.map(n=>({...t,mediaUrl:n})):[t]}function nr(t){const e=t;return e?(Array.isArray(e)?e:[e]).flatMap(ai):[]}const ii=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),oi=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),gn=t=>{const e=oi(t);return e.charAt(0).toUpperCase()+e.slice(1)},rr=(...t)=>t.filter((e,s,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===s).join(" ").trim(),li=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var ci={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const ui=d.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:a,iconNode:o,...c},l)=>d.createElement("svg",{ref:l,...ci,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:rr("lucide",r),...!a&&!li(c)&&{"aria-hidden":"true"},...c},[...o.map(([u,m])=>d.createElement(u,m)),...Array.isArray(a)?a:[a]]));const hs=(t,e)=>{const s=d.forwardRef(({className:n,...r},a)=>d.createElement(ui,{ref:a,iconNode:e,className:rr(`lucide-${ii(gn(t))}`,`lucide-${t}`,n),...r}));return s.displayName=gn(t),s};const di=[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]],ar=hs("image-off",di);const mi=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],fi=hs("loader-circle",mi);const hi=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ir=hs("maximize-2",hi);const yi=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],pi=hs("minimize-2",yi),or=({isOpen:t,onClose:e,src:s,type:n="image"})=>{const[r,a]=d.useState(!1),[o,c]=d.useState(!1);return d.useEffect(()=>{t&&c(!1)},[t,s]),d.useEffect(()=>{t&&(!s||o)&&e()},[t,s,o,e]),t?i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-70",role:"button",tabIndex:0,"aria-label":"Close media preview",onClick:e,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),e())},onTouchStart:e,children:i.jsxs("div",{className:`relative ${r?"w-full h-full":"max-w-5xl max-h-[90vh] w-full"} flex items-center justify-center`,onClick:l=>l.stopPropagation(),children:[n==="image"?i.jsx("img",{src:s,alt:"preview",className:`object-contain rounded-lg shadow-lg ${r?"w-full h-full":"max-w-full max-h-[90vh]"}`,onError:()=>c(!0)}):i.jsx("video",{src:s,controls:!0,className:`object-contain rounded-lg shadow-lg ${r?"w-full h-full":"max-w-full max-h-[90vh]"}`,onError:()=>c(!0)}),i.jsx("button",{onClick:e,className:"absolute top-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:"✕"}),i.jsx("button",{onClick:()=>a(!r),className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:r?i.jsx(pi,{size:20}):i.jsx(ir,{size:20})})]})}):null};function gi(t){const s=nr(t.mediaDetails)[0];if(!s)return null;const n=s.mediaUrl??s;return typeof n!="string"||!n.length?null:{url:n,item:s}}function lr({record:t}){const e=d.useMemo(()=>gi(t),[t]),[s,n]=d.useState(!1),[r,a]=d.useState(!1);if(d.useEffect(()=>{a(!1)},[e?.url]),!e)return i.jsx("span",{className:"text-gray-400 text-sm",children:"—"});const{url:o,item:c}=e,l=Us(c),u=l?"video":"image",m="block w-[72px] h-[54px] object-cover bg-gray-100 border border-gray-200 rounded-sm";return i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",disabled:r,className:"p-0 border-0 bg-transparent rounded-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-1 cursor-pointer disabled:cursor-not-allowed disabled:opacity-60","aria-label":r?"Preview unavailable":"Expand preview",onClick:()=>n(!0),children:r?i.jsx("span",{className:`${m} flex items-center justify-center text-gray-400`,children:i.jsx(ar,{size:20,"aria-hidden":!0})}):l?i.jsx("video",{src:o,className:m,muted:!0,playsInline:!0,preload:"metadata",onError:()=>a(!0)}):i.jsx("img",{src:o,alt:"",className:m,onError:()=>a(!0)})}),i.jsx(or,{isOpen:s,onClose:()=>n(!1),src:o,type:u})]})}const cr=["completed","false positive","face doesn't match name","safe","supervised exit","elopement confirmed"];function Si(t,e){const[s,n]=d.useState(t);return d.useEffect(()=>{const r=window.setTimeout(()=>n(t),e);return()=>window.clearTimeout(r)},[t,e]),s}function Js({data:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,columns:a,severityOptions:o,anomalyOptions:c,spaceOptions:l,renderActions:u,onAlertIdClick:m,onRefetch:h,onPageChange:S,onFilterChange:g,excludeCompleted:b=!0,resetKey:j,serverSideFilters:C=!1}){const[G,F]=d.useState("All"),[$,T]=d.useState("All"),[M,V]=d.useState("All"),[D,q]=d.useState("All"),[p,x]=d.useState("");d.useEffect(()=>{j!==void 0&&(F("All"),T("All"),V("All"),q("All"),x(""))},[j]);const[O,le]=d.useState([{label:"All",value:"All"}]),[ae,U]=d.useState([]),[w,v]=d.useState([]),[I,A]=d.useState([]),[R,P]=d.useState(new Set),{rules:Y,alerts:J,config:Q}=Ee(),se=Q.tenant==="schools",X=Q.tenant==="transit",ye=Q.tenant==="snl"?"anomalyDisplayName":"anomalyName",ie=Si(p,600),me=se&&ie.trim()?100:s,Se={6:{title:"Email",kind:"icon",icon:i.jsx(gt.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:i.jsx(gt.MessageOutlined,{})}},oe=d.useMemo(()=>_a(t,ye),[t,ye]),ce=d.useMemo(()=>Ja(t,X),[t,X]);d.useEffect(()=>{if(!J.getAllSpaces)return;let ee=!0;return(async()=>{try{const z=await J.getAllSpaces();if(ee){const pe=z.map(ne=>({label:X?String(ne.spaceNumber??ne.spaceName??""):ne.spaceName,value:String(X?ne.spaceNumber??ne.spaceId:ne.spaceId)}));U([{label:"All",value:"All"},...pe])}}catch(z){console.error("Error loading space options",z)}})(),()=>{ee=!1}},[J,X]),d.useEffect(()=>{let ee=!0;return(async()=>{try{const z=await Y.getLookups(),ne=(Array.isArray(z.thirdParties)?z.thirdParties:[]).map(ve=>({label:ve.thirdPartyName,value:String(ve.thirdPartyId)})),je=(Array.isArray(z.anomalies)?z.anomalies:[]).map(ve=>({label:ve.anomalyName,value:String(ve.recordId)})),Fe=(Array.isArray(z.severities)?z.severities:[]).map(ve=>({label:ve.severityName,value:String(ve.severityId)}));ee&&(le([{label:"All",value:"All"},...ne]),je.length&&v([{label:"All Types",value:"All"},...je]),Fe.length&&A([{label:"All levels",value:"All"},...Fe]))}catch(z){console.error("Error loading filter options",z)}})(),()=>{ee=!1}},[Y]);const xe=d.useMemo(()=>(t||[]).some(ee=>dn(ee).length>0),[t]);d.useEffect(()=>{if(!g)return;const ee={anomalyId:w.length>1&&$!=="All"?$:void 0,spaceId:!X&&ae.length>1&&M!=="All"?Number(M):void 0,spaceNumber:X&&ae.length>1&&M!=="All"?M:void 0,severityId:I.length>1&&G!=="All"?Number(G):void 0,thirdPartyIds:D==="All"?void 0:[Number(D)],searchText:se&&ie.trim()||void 0};g(ee),S?.(1)},[$,M,G,D,ie,w.length,ae.length,I.length,X,se]);const Ue=d.useMemo(()=>{const ee=C;return(t||[]).filter(z=>{const pe=ee||G==="All"||z.priority===G,ne=`${z.id} ${z.alertNumber} ${z.description} ${z.statusType}`.toLowerCase(),Ne=!p||ne.includes(p.toLowerCase()),je=ee||$==="All"||tr(z,ye).toLowerCase()===$.toLowerCase(),Ze=ee||M==="All"||(z.spaceName||"").toLowerCase()===M.toLowerCase(),Fe=ee||!xe||D==="All"||dn(z).includes(Number(D)),ve=os(String(z.statusType||"")),ct=!b||!cr.some(ut=>ve.includes(os(ut)));return pe&&Ne&&je&&Ze&&Fe&&ct})},[t,G,p,$,M,D,xe,b,C,ye]),Le=c?.length?c:oe,tt=C&&w.length>1?w:Le,st=l?.length?l:ce,vt=C&&ae.length>1?ae:st,lt=C&&I.length>1?I:o,wt=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:ee=>i.jsx(f.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Ya[ee]}`,backgroundColor:Ga[ee]},children:ee})},{title:"Tracker",key:"tracker",width:140,render:(ee,z)=>i.jsx("a",{onClick:pe=>{pe.preventDefault(),m?.(z,{tab:"track",sourceTab:"active"})},className:"text-blue-600 hover:underline",children:"Tracker"})},{title:"Call to action/Human in the loop",key:"actions",width:320,render:(ee,z)=>{if(u)return i.jsx(i.Fragment,{children:u(z)});const pe=async(ft,L)=>{const _=Ts(z.id,ft);P(W=>new Set(W).add(_));try{const W=await J.sendSMSorEmailNotifications?.(z.id,ft,L);W?.responseStatus||W?.Success||W?.success?(we.toast.success(W?.message||W.data||(ft?"Email sent successfully":"SMS sent successfully")),h?.()):we.toast.error(W?.message||W?.data||W?.errorMessage||"Failed to send notification")}catch(W){we.toast.error(W?.message||"Failed to send notification")}finally{P(W=>{const y=new Set(W);return y.delete(_),y})}},ne=Ys,Ne=_s,je=Se[ne],Ze=Se[Ne],Fe=pn(ne,z,je?.title),ve=pn(Ne,z,Ze?.title),ct=Ts(z.id,!0),ut=Ts(z.id,!1),dt=Jt(ne)&&R.has(ct),mt=Jt(Ne)&&R.has(ut);return i.jsxs(f.Space,{size:"middle",children:[i.jsx(f.Tooltip,{title:Fe.tooltipTitle,children:i.jsx(f.Button,{size:"small",disabled:Fe.isDisabled,loading:dt,onClick:Jt(ne)?()=>pe(!0,!1):void 0,icon:!dt&&je?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:Fe.buttonText})},String(ne)),i.jsx(f.Tooltip,{title:ve.tooltipTitle,children:i.jsx(f.Button,{size:"small",disabled:ve.isDisabled,loading:mt,onClick:Jt(Ne)?()=>pe(!1,!0):void 0,icon:!mt&&Ze?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:ve.buttonText})},String(Ne))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(ee,z)=>{const pe=z?.timeElapsed,ne=z?.timeRemaining,Ne=pe?un(pe):0,je=ne?un(ne):0,Ze=Math.round(Ne/(Ne+je)*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:pe??"-"})]}),i.jsx(f.Progress,{percent:Ze,showInfo:!1,size:"small",strokeColor:Aa(z.priority)}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-[70px]",children:"Remaining"}),i.jsx("span",{className:"font-medium",children:ne??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(ee,z)=>i.jsxs("div",{children:[i.jsx("a",{onClick:pe=>{pe.preventDefault(),m?.(z,{sourceTab:"active"})},className:"inline-block mb-1 text-blue-600",children:z.alertNumber}),i.jsx("div",{className:"text-black/65",children:ee})]})},{title:"Preview",key:"preview",width:100,align:"center",render:(ee,z)=>i.jsx(lr,{record:z})}],Dt=a&&a.length?a:wt;return i.jsx("div",{children:i.jsx(sr,{rowKey:"id",data:Ue,columns:Dt,loading:e,pageSize:me,total:n,currentPage:r,onPageChange:S,toolbar:i.jsxs(f.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[i.jsx(f.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Severity"}),i.jsx(Qa,{value:G,onChange:F,options:lt})]})}),i.jsx(f.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Anomaly type"}),i.jsx(ei,{value:$,onChange:T,options:tt})]})}),i.jsx(f.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:X?"Bus Number":"Space"}),i.jsx(ti,{value:M,onChange:V,options:vt})]})}),i.jsx(f.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Action Taken"}),i.jsx(ni,{value:D,onChange:q,options:O})]})}),i.jsx(f.Col,{flex:"auto"}),i.jsx(f.Col,{flex:"none",children:i.jsx(f.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:x,onChange:ee=>x(ee.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}function Ks(){const{alerts:t}=Ee(),e=St.useQueryClient();return St.useMutation({mutationFn:s=>t.updateAlertStatus(s),onSuccess:()=>{e.invalidateQueries({queryKey:["alerts","list"]}),e.invalidateQueries({queryKey:["alerts","report"]})}})}class xt extends Error{}class xi extends xt{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class vi extends xt{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class wi extends xt{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class bt extends xt{}class ur extends xt{constructor(e){super(`Invalid unit ${e}`)}}class Ae extends xt{}class rt extends xt{constructor(){super("Zone is an abstract class")}}const N="numeric",Ye="short",Re="long",ls={year:N,month:N,day:N},dr={year:N,month:Ye,day:N},Ai={year:N,month:Ye,day:N,weekday:Ye},mr={year:N,month:Re,day:N},fr={year:N,month:Re,day:N,weekday:Re},hr={hour:N,minute:N},yr={hour:N,minute:N,second:N},pr={hour:N,minute:N,second:N,timeZoneName:Ye},gr={hour:N,minute:N,second:N,timeZoneName:Re},Sr={hour:N,minute:N,hourCycle:"h23"},xr={hour:N,minute:N,second:N,hourCycle:"h23"},vr={hour:N,minute:N,second:N,hourCycle:"h23",timeZoneName:Ye},wr={hour:N,minute:N,second:N,hourCycle:"h23",timeZoneName:Re},Ar={year:N,month:N,day:N,hour:N,minute:N},Tr={year:N,month:N,day:N,hour:N,minute:N,second:N},Nr={year:N,month:Ye,day:N,hour:N,minute:N},br={year:N,month:Ye,day:N,hour:N,minute:N,second:N},Ti={year:N,month:Ye,day:N,weekday:Ye,hour:N,minute:N},kr={year:N,month:Re,day:N,hour:N,minute:N,timeZoneName:Ye},Ir={year:N,month:Re,day:N,hour:N,minute:N,second:N,timeZoneName:Ye},Er={year:N,month:Re,day:N,weekday:Re,hour:N,minute:N,timeZoneName:Re},Mr={year:N,month:Re,day:N,weekday:Re,hour:N,minute:N,second:N,timeZoneName:Re};class Vt{get type(){throw new rt}get name(){throw new rt}get ianaName(){return this.name}get isUniversal(){throw new rt}offsetName(e,s){throw new rt}formatOffset(e,s){throw new rt}offset(e){throw new rt}equals(e){throw new rt}get isValid(){throw new rt}}let Ns=null;class ys extends Vt{static get instance(){return Ns===null&&(Ns=new ys),Ns}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Wr(e,s,n)}formatOffset(e,s){return Pt(this.offset(e),s)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}}const Ls=new Map;function Ni(t){let e=Ls.get(t);return e===void 0&&(e=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),Ls.set(t,e)),e}const bi={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function ki(t,e){const s=t.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(s),[,r,a,o,c,l,u,m]=n;return[o,r,a,c,l,u,m]}function Ii(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:a,value:o}=s[r],c=bi[a];a==="era"?n[c]=o:Z(c)||(n[c]=parseInt(o,10))}return n}const bs=new Map;class et extends Vt{static create(e){let s=bs.get(e);return s===void 0&&bs.set(e,s=new et(e)),s}static resetCache(){bs.clear(),Ls.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch{return!1}}constructor(e){super(),this.zoneName=e,this.valid=et.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Wr(e,s,n,this.name)}formatOffset(e,s){return Pt(this.offset(e),s)}offset(e){if(!this.valid)return NaN;const s=new Date(e);if(isNaN(s))return NaN;const n=Ni(this.name);let[r,a,o,c,l,u,m]=n.formatToParts?Ii(n,s):ki(n,s);c==="BC"&&(r=-Math.abs(r)+1);const S=gs({year:r,month:a,day:o,hour:l===24?0:l,minute:u,second:m,millisecond:0});let g=+s;const b=g%1e3;return g-=b>=0?b:1e3+b,(S-g)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let Sn={};function Ei(t,e={}){const s=JSON.stringify([t,e]);let n=Sn[s];return n||(n=new Intl.ListFormat(t,e),Sn[s]=n),n}const Fs=new Map;function $s(t,e={}){const s=JSON.stringify([t,e]);let n=Fs.get(s);return n===void 0&&(n=new Intl.DateTimeFormat(t,e),Fs.set(s,n)),n}const Ps=new Map;function Mi(t,e={}){const s=JSON.stringify([t,e]);let n=Ps.get(s);return n===void 0&&(n=new Intl.NumberFormat(t,e),Ps.set(s,n)),n}const Ws=new Map;function Oi(t,e={}){const{base:s,...n}=e,r=JSON.stringify([t,n]);let a=Ws.get(r);return a===void 0&&(a=new Intl.RelativeTimeFormat(t,e),Ws.set(r,a)),a}let Lt=null;function ji(){return Lt||(Lt=new Intl.DateTimeFormat().resolvedOptions().locale,Lt)}const Vs=new Map;function Or(t){let e=Vs.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),Vs.set(t,e)),e}const Bs=new Map;function Ci(t){let e=Bs.get(t);if(!e){const s=new Intl.Locale(t);e="getWeekInfo"in s?s.getWeekInfo():s.weekInfo,"minimalDays"in e||(e={...jr,...e}),Bs.set(t,e)}return e}function Di(t){const e=t.indexOf("-x-");e!==-1&&(t=t.substring(0,e));const s=t.indexOf("-u-");if(s===-1)return[t];{let n,r;try{n=$s(t).resolvedOptions(),r=t}catch{const l=t.substring(0,s);n=$s(l).resolvedOptions(),r=l}const{numberingSystem:a,calendar:o}=n;return[r,a,o]}}function Ri(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function Ui(t){const e=[];for(let s=1;s<=12;s++){const n=B.utc(2009,s,1);e.push(t(n))}return e}function Li(t){const e=[];for(let s=1;s<=7;s++){const n=B.utc(2016,11,13+s);e.push(t(n))}return e}function Kt(t,e,s,n){const r=t.listingMode();return r==="error"?null:r==="en"?s(e):n(e)}function Fi(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||Or(t.locale).numberingSystem==="latn"}class $i{constructor(e,s,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;const{padTo:r,floor:a,...o}=n;if(!s||Object.keys(o).length>0){const c={useGrouping:!1,...n};n.padTo>0&&(c.minimumIntegerDigits=n.padTo),this.inf=Mi(e,c)}}format(e){if(this.inf){const s=this.floor?Math.floor(e):e;return this.inf.format(s)}else{const s=this.floor?Math.floor(e):sn(e,3);return ge(s,this.padTo)}}}class Pi{constructor(e,s,n){this.opts=n,this.originalZone=void 0;let r;if(this.opts.timeZone)this.dt=e;else if(e.zone.type==="fixed"){const o=-1*(e.offset/60),c=o>=0?`Etc/GMT+${o}`:`Etc/GMT${o}`;e.offset!==0&&et.create(c).valid?(r=c,this.dt=e):(r="UTC",this.dt=e.offset===0?e:e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type==="system"?this.dt=e:e.zone.type==="iana"?(this.dt=e,r=e.zone.name):(r="UTC",this.dt=e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone);const a={...this.opts};a.timeZone=a.timeZone||r,this.dtf=$s(s,a)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(s=>{if(s.type==="timeZoneName"){const n=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...s,value:n}}else return s}):e}resolvedOptions(){return this.dtf.resolvedOptions()}}class Wi{constructor(e,s,n){this.opts={style:"long",...n},!s&&$r()&&(this.rtf=Oi(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):lo(s,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,s){return this.rtf?this.rtf.formatToParts(e,s):[]}}const jr={firstDay:1,minimalDays:4,weekend:[6,7]};class re{static fromOpts(e){return re.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,s,n,r,a=!1){const o=e||he.defaultLocale,c=o||(a?"en-US":ji()),l=s||he.defaultNumberingSystem,u=n||he.defaultOutputCalendar,m=zs(r)||he.defaultWeekSettings;return new re(c,l,u,m,o)}static resetCache(){Lt=null,Fs.clear(),Ps.clear(),Ws.clear(),Vs.clear(),Bs.clear()}static fromObject({locale:e,numberingSystem:s,outputCalendar:n,weekSettings:r}={}){return re.create(e,s,n,r)}constructor(e,s,n,r,a){const[o,c,l]=Di(e);this.locale=o,this.numberingSystem=s||c||null,this.outputCalendar=n||l||null,this.weekSettings=r,this.intl=Ri(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=a,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=Fi(this)),this.fastNumbersCached}listingMode(){const e=this.isEnglish(),s=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return e&&s?"en":"intl"}clone(e){return!e||Object.getOwnPropertyNames(e).length===0?this:re.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,zs(e.weekSettings)||this.weekSettings,e.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,s=!1){return Kt(this,e,Zr,()=>{const n=this.intl==="ja"||this.intl.startsWith("ja-");s&=!n;const r=s?{month:e,day:"numeric"}:{month:e},a=s?"format":"standalone";if(!this.monthsCache[a][e]){const o=n?c=>this.dtFormatter(c,r).format():c=>this.extract(c,r,"month");this.monthsCache[a][e]=Ui(o)}return this.monthsCache[a][e]})}weekdays(e,s=!1){return Kt(this,e,qr,()=>{const n=s?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},r=s?"format":"standalone";return this.weekdaysCache[r][e]||(this.weekdaysCache[r][e]=Li(a=>this.extract(a,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return Kt(this,void 0,()=>Gr,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[B.utc(2016,11,13,9),B.utc(2016,11,13,19)].map(s=>this.extract(s,e,"dayperiod"))}return this.meridiemCache})}eras(e){return Kt(this,e,Yr,()=>{const s={era:e};return this.eraCache[e]||(this.eraCache[e]=[B.utc(-40,1,1),B.utc(2017,1,1)].map(n=>this.extract(n,s,"era"))),this.eraCache[e]})}extract(e,s,n){const r=this.dtFormatter(e,s),a=r.formatToParts(),o=a.find(c=>c.type.toLowerCase()===n);return o?o.value:null}numberFormatter(e={}){return new $i(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new Pi(e,this.intl,s)}relFormatter(e={}){return new Wi(this.intl,this.isEnglish(),e)}listFormatter(e={}){return Ei(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||Or(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:Pr()?Ci(this.locale):jr}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let ks=null;class Ie extends Vt{static get utcInstance(){return ks===null&&(ks=new Ie(0)),ks}static instance(e){return e===0?Ie.utcInstance:new Ie(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new Ie(Ss(s[1],s[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Pt(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Pt(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,s){return Pt(this.fixed,s)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type==="fixed"&&e.fixed===this.fixed}get isValid(){return!0}}class Vi extends Vt{constructor(e){super(),this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function it(t,e){if(Z(t)||t===null)return e;if(t instanceof Vt)return t;if(Gi(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?ys.instance:s==="utc"||s==="gmt"?Ie.utcInstance:Ie.parseSpecifier(s)||et.create(t)}else return ot(t)?Ie.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new Vi(t)}const Qs={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},xn={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},Bi=Qs.hanidec.replace(/[\[|\]]/g,"").split("");function Zi(t){let e=parseInt(t,10);if(isNaN(e)){e="";for(let s=0;s<t.length;s++){const n=t.charCodeAt(s);if(t[s].search(Qs.hanidec)!==-1)e+=Bi.indexOf(t[s]);else for(const r in xn){const[a,o]=xn[r];n>=a&&n<=o&&(e+=n-a)}}return parseInt(e,10)}else return e}const Zs=new Map;function zi(){Zs.clear()}function He({numberingSystem:t},e=""){const s=t||"latn";let n=Zs.get(s);n===void 0&&(n=new Map,Zs.set(s,n));let r=n.get(e);return r===void 0&&(r=new RegExp(`${Qs[s]}${e}`),n.set(e,r)),r}let vn=()=>Date.now(),wn="system",An=null,Tn=null,Nn=null,bn=60,kn,In=null;class he{static get now(){return vn}static set now(e){vn=e}static set defaultZone(e){wn=e}static get defaultZone(){return it(wn,ys.instance)}static get defaultLocale(){return An}static set defaultLocale(e){An=e}static get defaultNumberingSystem(){return Tn}static set defaultNumberingSystem(e){Tn=e}static get defaultOutputCalendar(){return Nn}static set defaultOutputCalendar(e){Nn=e}static get defaultWeekSettings(){return In}static set defaultWeekSettings(e){In=zs(e)}static get twoDigitCutoffYear(){return bn}static set twoDigitCutoffYear(e){bn=e%100}static get throwOnInvalid(){return kn}static set throwOnInvalid(e){kn=e}static resetCaches(){re.resetCache(),et.resetCache(),B.resetCache(),zi()}}class Ge{constructor(e,s){this.reason=e,this.explanation=s}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const Cr=[0,31,59,90,120,151,181,212,243,273,304,334],Dr=[0,31,60,91,121,152,182,213,244,274,305,335];function Ve(t,e){return new Ge("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function Xs(t,e,s){const n=new Date(Date.UTC(t,e-1,s));t<100&&t>=0&&n.setUTCFullYear(n.getUTCFullYear()-1900);const r=n.getUTCDay();return r===0?7:r}function Rr(t,e,s){return s+(Bt(t)?Dr:Cr)[e-1]}function Ur(t,e){const s=Bt(t)?Dr:Cr,n=s.findIndex(a=>a<e),r=e-s[n];return{month:n+1,day:r}}function en(t,e){return(t-e+7)%7+1}function cs(t,e=4,s=1){const{year:n,month:r,day:a}=t,o=Rr(n,r,a),c=en(Xs(n,r,a),s);let l=Math.floor((o-c+14-e)/7),u;return l<1?(u=n-1,l=Wt(u,e,s)):l>Wt(n,e,s)?(u=n+1,l=1):u=n,{weekYear:u,weekNumber:l,weekday:c,...xs(t)}}function En(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:a}=t,o=en(Xs(n,1,e),s),c=kt(n);let l=r*7+a-o-7+e,u;l<1?(u=n-1,l+=kt(u)):l>c?(u=n+1,l-=kt(n)):u=n;const{month:m,day:h}=Ur(u,l);return{year:u,month:m,day:h,...xs(t)}}function Is(t){const{year:e,month:s,day:n}=t,r=Rr(e,s,n);return{year:e,ordinal:r,...xs(t)}}function Mn(t){const{year:e,ordinal:s}=t,{month:n,day:r}=Ur(e,s);return{year:e,month:n,day:r,...xs(t)}}function On(t,e){if(!Z(t.localWeekday)||!Z(t.localWeekNumber)||!Z(t.localWeekYear)){if(!Z(t.weekday)||!Z(t.weekNumber)||!Z(t.weekYear))throw new bt("Cannot mix locale-based week fields with ISO-based week fields");return Z(t.localWeekday)||(t.weekday=t.localWeekday),Z(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),Z(t.localWeekYear)||(t.weekYear=t.localWeekYear),delete t.localWeekday,delete t.localWeekNumber,delete t.localWeekYear,{minDaysInFirstWeek:e.getMinDaysInFirstWeek(),startOfWeek:e.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function Hi(t,e=4,s=1){const n=ps(t.weekYear),r=Be(t.weekNumber,1,Wt(t.weekYear,e,s)),a=Be(t.weekday,1,7);return n?r?a?!1:Ve("weekday",t.weekday):Ve("week",t.weekNumber):Ve("weekYear",t.weekYear)}function qi(t){const e=ps(t.year),s=Be(t.ordinal,1,kt(t.year));return e?s?!1:Ve("ordinal",t.ordinal):Ve("year",t.year)}function Lr(t){const e=ps(t.year),s=Be(t.month,1,12),n=Be(t.day,1,us(t.year,t.month));return e?s?n?!1:Ve("day",t.day):Ve("month",t.month):Ve("year",t.year)}function Fr(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),c=Be(n,0,59),l=Be(r,0,999);return a?o?c?l?!1:Ve("millisecond",r):Ve("second",n):Ve("minute",s):Ve("hour",e)}function Z(t){return typeof t>"u"}function ot(t){return typeof t=="number"}function ps(t){return typeof t=="number"&&t%1===0}function Gi(t){return typeof t=="string"}function Yi(t){return Object.prototype.toString.call(t)==="[object Date]"}function $r(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function Pr(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function _i(t){return Array.isArray(t)?t:[t]}function jn(t,e,s){if(t.length!==0)return t.reduce((n,r)=>{const a=[e(r),r];return n&&s(n[0],a[0])===n[0]?n:a},null)[1]}function Ji(t,e){return e.reduce((s,n)=>(s[n]=t[n],s),{})}function Et(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function zs(t){if(t==null)return null;if(typeof t!="object")throw new Ae("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 Ae("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function Be(t,e,s){return ps(t)&&t>=e&&t<=s}function Ki(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 at(t){if(!(Z(t)||t===null||t===""))return parseInt(t,10)}function ht(t){if(!(Z(t)||t===null||t===""))return parseFloat(t)}function tn(t){if(!(Z(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function sn(t,e,s="round"){const n=10**e;switch(s){case"expand":return t>0?Math.ceil(t*n)/n:Math.floor(t*n)/n;case"trunc":return Math.trunc(t*n)/n;case"round":return Math.round(t*n)/n;case"floor":return Math.floor(t*n)/n;case"ceil":return Math.ceil(t*n)/n;default:throw new RangeError(`Value rounding ${s} is out of range`)}}function Bt(t){return t%4===0&&(t%100!==0||t%400===0)}function kt(t){return Bt(t)?366:365}function us(t,e){const s=Ki(e-1,12)+1,n=t+(e-s)/12;return s===2?Bt(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][s-1]}function gs(t){let e=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second,t.millisecond);return t.year<100&&t.year>=0&&(e=new Date(e),e.setUTCFullYear(t.year,t.month-1,t.day)),+e}function Cn(t,e,s){return-en(Xs(t,1,e),s)+e-1}function Wt(t,e=4,s=1){const n=Cn(t,e,s),r=Cn(t+1,e,s);return(kt(t)-n+r)/7}function Hs(t){return t>99?t:t>he.twoDigitCutoffYear?1900+t:2e3+t}function Wr(t,e,s,n=null){const r=new Date(t),a={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};n&&(a.timeZone=n);const o={timeZoneName:e,...a},c=new Intl.DateTimeFormat(s,o).formatToParts(r).find(l=>l.type.toLowerCase()==="timezonename");return c?c.value:null}function Ss(t,e){let s=parseInt(t,10);Number.isNaN(s)&&(s=0);const n=parseInt(e,10)||0,r=s<0||Object.is(s,-0)?-n:n;return s*60+r}function Vr(t){const e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new Ae(`Invalid unit value ${t}`);return e}function ds(t,e){const s={};for(const n in t)if(Et(t,n)){const r=t[n];if(r==null)continue;s[e(n)]=Vr(r)}return s}function Pt(t,e){const s=Math.trunc(Math.abs(t/60)),n=Math.trunc(Math.abs(t%60)),r=t>=0?"+":"-";switch(e){case"short":return`${r}${ge(s,2)}:${ge(n,2)}`;case"narrow":return`${r}${s}${n>0?`:${n}`:""}`;case"techie":return`${r}${ge(s,2)}${ge(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function xs(t){return Ji(t,["hour","minute","second","millisecond"])}const Qi=["January","February","March","April","May","June","July","August","September","October","November","December"],Br=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Xi=["J","F","M","A","M","J","J","A","S","O","N","D"];function Zr(t){switch(t){case"narrow":return[...Xi];case"short":return[...Br];case"long":return[...Qi];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const zr=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Hr=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],eo=["M","T","W","T","F","S","S"];function qr(t){switch(t){case"narrow":return[...eo];case"short":return[...Hr];case"long":return[...zr];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const Gr=["AM","PM"],to=["Before Christ","Anno Domini"],so=["BC","AD"],no=["B","A"];function Yr(t){switch(t){case"narrow":return[...no];case"short":return[...so];case"long":return[...to];default:return null}}function ro(t){return Gr[t.hour<12?0:1]}function ao(t,e){return qr(e)[t.weekday-1]}function io(t,e){return Zr(e)[t.month-1]}function oo(t,e){return Yr(e)[t.year<0?0:1]}function lo(t,e,s="always",n=!1){const r={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},a=["hours","minutes","seconds"].indexOf(t)===-1;if(s==="auto"&&a){const h=t==="days";switch(e){case 1:return h?"tomorrow":`next ${r[t][0]}`;case-1:return h?"yesterday":`last ${r[t][0]}`;case 0:return h?"today":`this ${r[t][0]}`}}const o=Object.is(e,-0)||e<0,c=Math.abs(e),l=c===1,u=r[t],m=n?l?u[1]:u[2]||u[1]:l?r[t][0]:t;return o?`${c} ${m} ago`:`in ${c} ${m}`}function Dn(t,e){let s="";for(const n of t)n.literal?s+=n.val:s+=e(n.val);return s}const co={D:ls,DD:dr,DDD:mr,DDDD:fr,t:hr,tt:yr,ttt:pr,tttt:gr,T:Sr,TT:xr,TTT:vr,TTTT:wr,f:Ar,ff:Nr,fff:kr,ffff:Er,F:Tr,FF:br,FFF:Ir,FFFF:Mr};class Te{static create(e,s={}){return new Te(e,s)}static parseFormat(e){let s=null,n="",r=!1;const a=[];for(let o=0;o<e.length;o++){const c=e.charAt(o);c==="'"?((n.length>0||r)&&a.push({literal:r||/^\s+$/.test(n),val:n===""?"'":n}),s=null,n="",r=!r):r||c===s?n+=c:(n.length>0&&a.push({literal:/^\s+$/.test(n),val:n}),n=c,s=c)}return n.length>0&&a.push({literal:r||/^\s+$/.test(n),val:n}),a}static macroTokenToFormatOpts(e){return co[e]}constructor(e,s){this.opts=s,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,s){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...s}).format()}dtFormatter(e,s={}){return this.loc.dtFormatter(e,{...this.opts,...s})}formatDateTime(e,s){return this.dtFormatter(e,s).format()}formatDateTimeParts(e,s){return this.dtFormatter(e,s).formatToParts()}formatInterval(e,s){return this.dtFormatter(e.start,s).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,s){return this.dtFormatter(e,s).resolvedOptions()}num(e,s=0,n=void 0){if(this.opts.forceSimple)return 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,b)=>this.loc.extract(e,g,b),o=g=>e.isOffsetFixed&&e.offset===0&&g.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,g.format):"",c=()=>n?ro(e):a({hour:"numeric",hourCycle:"h12"},"dayperiod"),l=(g,b)=>n?io(e,g):a(b?{month:g}:{month:g,day:"numeric"},"month"),u=(g,b)=>n?ao(e,g):a(b?{weekday:g}:{weekday:g,month:"long",day:"numeric"},"weekday"),m=g=>{const b=Te.macroTokenToFormatOpts(g);return b?this.formatWithSystemDefault(e,b):g},h=g=>n?oo(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 c();case"d":return r?a({day:"numeric"},"day"):this.num(e.day);case"dd":return r?a({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return u("short",!0);case"cccc":return u("long",!0);case"ccccc":return u("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return u("short",!1);case"EEEE":return u("long",!1);case"EEEEE":return u("narrow",!1);case"L":return r?a({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?a({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return l("short",!0);case"LLLL":return l("long",!0);case"LLLLL":return l("narrow",!0);case"M":return r?a({month:"numeric"},"month"):this.num(e.month);case"MM":return r?a({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return l("short",!1);case"MMMM":return l("long",!1);case"MMMMM":return l("narrow",!1);case"y":return r?a({year:"numeric"},"year"):this.num(e.year);case"yy":return r?a({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?a({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?a({year:"numeric"},"year"):this.num(e.year,6);case"G":return h("short");case"GG":return h("long");case"GGGGG":return h("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return m(g)}};return Dn(Te.parseFormat(s),S)}formatDurationFromString(e,s){const n=this.opts.signMode==="negativeLargestOnly"?-1:1,r=m=>{switch(m[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},a=(m,h)=>S=>{const g=r(S);if(g){const b=h.isNegativeDuration&&g!==h.largestUnit?n:1;let j;return this.opts.signMode==="negativeLargestOnly"&&g!==h.largestUnit?j="never":this.opts.signMode==="all"?j="always":j="auto",this.num(m.get(g)*b,S.length,j)}else return S},o=Te.parseFormat(s),c=o.reduce((m,{literal:h,val:S})=>h?m:m.concat(S),[]),l=e.shiftTo(...c.map(r).filter(m=>m)),u={isNegativeDuration:l<0,largestUnit:Object.keys(l.values)[0]};return Dn(o,a(l,u))}}const _r=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Mt(...t){const e=t.reduce((s,n)=>s+n.source,"");return RegExp(`^${e}$`)}function Ot(...t){return e=>t.reduce(([s,n,r],a)=>{const[o,c,l]=a(e,r);return[{...s,...o},c||n,l]},[{},null,1]).slice(0,2)}function 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 Jr(...t){return(e,s)=>{const n={};let r;for(r=0;r<t.length;r++)n[t[r]]=at(e[s+r]);return[n,null,s+r]}}const Kr=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,uo=`(?:${Kr.source}?(?:\\[(${_r.source})\\])?)?`,nn=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Qr=RegExp(`${nn.source}${uo}`),rn=RegExp(`(?:[Tt]${Qr.source})?`),mo=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,fo=/(\d{4})-?W(\d\d)(?:-?(\d))?/,ho=/(\d{4})-?(\d{3})/,yo=Jr("weekYear","weekNumber","weekDay"),po=Jr("year","ordinal"),go=/(\d{4})-(\d\d)-(\d\d)/,Xr=RegExp(`${nn.source} ?(?:${Kr.source}|(${_r.source}))?`),So=RegExp(`(?: ${Xr.source})?`);function It(t,e,s){const n=t[e];return Z(n)?s:at(n)}function xo(t,e){return[{year:It(t,e),month:It(t,e+1,1),day:It(t,e+2,1)},null,e+3]}function Ct(t,e){return[{hours:It(t,e,0),minutes:It(t,e+1,0),seconds:It(t,e+2,0),milliseconds:tn(t[e+3])},null,e+4]}function Zt(t,e){const s=!t[e]&&!t[e+1],n=Ss(t[e+1],t[e+2]),r=s?null:Ie.instance(n);return[{},r,e+3]}function zt(t,e){const s=t[e]?et.create(t[e]):null;return[{},s,e+1]}const vo=RegExp(`^T?${nn.source}$`),wo=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function Ao(t){const[e,s,n,r,a,o,c,l,u]=t,m=e[0]==="-",h=l&&l[0]==="-",S=(g,b=!1)=>g!==void 0&&(b||g&&m)?-g:g;return[{years:S(ht(s)),months:S(ht(n)),weeks:S(ht(r)),days:S(ht(a)),hours:S(ht(o)),minutes:S(ht(c)),seconds:S(ht(l),l==="-0"),milliseconds:S(tn(u),h)}]}const To={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function an(t,e,s,n,r,a,o){const c={year:e.length===2?Hs(at(e)):at(e),month:Br.indexOf(s)+1,day:at(n),hour:at(r),minute:at(a)};return o&&(c.second=at(o)),t&&(c.weekday=t.length>3?zr.indexOf(t)+1:Hr.indexOf(t)+1),c}const No=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function bo(t){const[,e,s,n,r,a,o,c,l,u,m,h]=t,S=an(e,r,n,s,a,o,c);let g;return l?g=To[l]:u?g=0:g=Ss(m,h),[S,new Ie(g)]}function ko(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const Io=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,Eo=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,Mo=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function Rn(t){const[,e,s,n,r,a,o,c]=t;return[an(e,r,n,s,a,o,c),Ie.utcInstance]}function Oo(t){const[,e,s,n,r,a,o,c]=t;return[an(e,c,s,n,r,a,o),Ie.utcInstance]}const jo=Mt(mo,rn),Co=Mt(fo,rn),Do=Mt(ho,rn),Ro=Mt(Qr),ea=Ot(xo,Ct,Zt,zt),Uo=Ot(yo,Ct,Zt,zt),Lo=Ot(po,Ct,Zt,zt),Fo=Ot(Ct,Zt,zt);function $o(t){return jt(t,[jo,ea],[Co,Uo],[Do,Lo],[Ro,Fo])}function Po(t){return jt(ko(t),[No,bo])}function Wo(t){return jt(t,[Io,Rn],[Eo,Rn],[Mo,Oo])}function Vo(t){return jt(t,[wo,Ao])}const Bo=Ot(Ct);function Zo(t){return jt(t,[vo,Bo])}const zo=Mt(go,So),Ho=Mt(Xr),qo=Ot(Ct,Zt,zt);function Go(t){return jt(t,[zo,ea],[Ho,qo])}const Un="Invalid Duration",ta={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},Yo={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...ta},We=146097/400,At=146097/4800,_o={years:{quarters:4,months:12,weeks:We/7,days:We,hours:We*24,minutes:We*24*60,seconds:We*24*60*60,milliseconds:We*24*60*60*1e3},quarters:{months:3,weeks:We/28,days:We/4,hours:We*24/4,minutes:We*24*60/4,seconds:We*24*60*60/4,milliseconds:We*24*60*60*1e3/4},months:{weeks:At/7,days:At,hours:At*24,minutes:At*24*60,seconds:At*24*60*60,milliseconds:At*24*60*60*1e3},...ta},pt=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Jo=pt.slice(0).reverse();function Qe(t,e,s=!1){const n={values:s?e.values:{...t.values,...e.values||{}},loc:t.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||t.conversionAccuracy,matrix:e.matrix||t.matrix};return new K(n)}function sa(t,e){let s=e.milliseconds??0;for(const n of Jo.slice(1))e[n]&&(s+=e[n]*t[n].milliseconds);return s}function Ln(t,e){const s=sa(t,e)<0?-1:1;pt.reduceRight((n,r)=>{if(Z(e[r]))return n;if(n){const a=e[n]*s,o=t[r][n],c=Math.floor(a/o);e[r]+=c*s,e[n]-=c*o*s}return r},null),pt.reduce((n,r)=>{if(Z(e[r]))return n;if(n){const a=e[n]%1;e[n]-=a,e[r]+=a*t[n][r]}return r},null)}function Fn(t){const e={};for(const[s,n]of Object.entries(t))n!==0&&(e[s]=n);return e}class K{constructor(e){const s=e.conversionAccuracy==="longterm"||!1;let n=s?_o:Yo;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||re.create(),this.conversionAccuracy=s?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=n,this.isLuxonDuration=!0}static fromMillis(e,s){return K.fromObject({milliseconds:e},s)}static fromObject(e,s={}){if(e==null||typeof e!="object")throw new Ae(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new K({values:ds(e,K.normalizeUnit),loc:re.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(ot(e))return K.fromMillis(e);if(K.isDuration(e))return e;if(typeof e=="object")return K.fromObject(e);throw new Ae(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,s){const[n]=Vo(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]=Zo(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 Ae("need to specify a reason the Duration is invalid");const n=e instanceof Ge?e:new Ge(e,s);if(he.throwOnInvalid)throw new wi(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 ur(e);return s}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,s={}){const n={...s,floor:s.round!==!1&&s.floor!==!1};return this.isValid?Te.create(this.loc,n).formatDurationFromString(this,e):Un}toHuman(e={}){if(!this.isValid)return Un;const s=e.showZeros!==!1,n=pt.map(r=>{const a=this.values[r];return Z(a)||a===0&&!s?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:r.slice(0,-1)}).format(a)}).filter(r=>r);return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(n)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e="P";return this.years!==0&&(e+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+"M"),this.weeks!==0&&(e+=this.weeks+"W"),this.days!==0&&(e+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+="T"),this.hours!==0&&(e+=this.hours+"H"),this.minutes!==0&&(e+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(e+=sn(this.seconds+this.milliseconds/1e3,3)+"S"),e==="P"&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;const s=this.toMillis();return s<0||s>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e,includeOffset:!1},B.fromMillis(s,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?sa(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e),n={};for(const r of pt)(Et(s.values,r)||Et(this.values,r))&&(n[r]=s.get(r)+this.get(r));return Qe(this,{values:n},!0)}minus(e){if(!this.isValid)return this;const s=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]=Vr(e(this.values[n],n));return Qe(this,{values:s},!0)}get(e){return this[K.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const s={...this.values,...ds(e,K.normalizeUnit)};return Qe(this,{values:s})}reconfigure({locale:e,numberingSystem:s,conversionAccuracy:n,matrix:r}={}){const o={loc:this.loc.clone({locale:e,numberingSystem:s}),matrix:r,conversionAccuracy:n};return Qe(this,o)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return Ln(this.matrix,e),Qe(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=Fn(this.normalize().shiftToAll().toObject());return Qe(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(o=>K.normalizeUnit(o));const s={},n={},r=this.toObject();let a;for(const o of pt)if(e.indexOf(o)>=0){a=o;let c=0;for(const u in n)c+=this.matrix[u][o]*n[u],n[u]=0;ot(r[o])&&(c+=r[o]);const l=Math.trunc(c);s[o]=l,n[o]=(c*1e3-l*1e3)/1e3}else ot(r[o])&&(n[o]=r[o]);for(const o in n)n[o]!==0&&(s[a]+=o===a?n[o]:n[o]/this.matrix[a][o]);return Ln(this.matrix,s),Qe(this,{values:s},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const e={};for(const s of Object.keys(this.values))e[s]=this.values[s]===0?0:-this.values[s];return Qe(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=Fn(this.values);return Qe(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function s(n,r){return n===void 0||n===0?r===void 0||r===0:n===r}for(const n of pt)if(!s(this.values[n],e.values[n]))return!1;return!0}}const Tt="Invalid Interval";function Ko(t,e){return!t||!t.isValid?fe.invalid("missing or invalid start"):!e||!e.isValid?fe.invalid("missing or invalid end"):e<t?fe.invalid("end before start",`The end of an interval must be after its start, but you had start=${t.toISO()} and end=${e.toISO()}`):null}class fe{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,s=null){if(!e)throw new Ae("need to specify a reason the Interval is invalid");const n=e instanceof Ge?e:new Ge(e,s);if(he.throwOnInvalid)throw new vi(n);return new fe({invalid:n})}static fromDateTimes(e,s){const n=Rt(e),r=Rt(s),a=Ko(n,r);return a??new fe({start:n,end:r})}static after(e,s){const n=K.fromDurationLike(s),r=Rt(e);return fe.fromDateTimes(r,r.plus(n))}static before(e,s){const n=K.fromDurationLike(s),r=Rt(e);return fe.fromDateTimes(r.minus(n),r)}static fromISO(e,s){const[n,r]=(e||"").split("/",2);if(n&&r){let a,o;try{a=B.fromISO(n,s),o=a.isValid}catch{o=!1}let c,l;try{c=B.fromISO(r,s),l=c.isValid}catch{l=!1}if(o&&l)return fe.fromDateTimes(a,c);if(o){const u=K.fromISO(r,s);if(u.isValid)return fe.after(a,u)}else if(l){const u=K.fromISO(n,s);if(u.isValid)return fe.before(c,u)}}return fe.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(e).get(e):NaN}count(e="milliseconds",s){if(!this.isValid)return NaN;const n=this.start.startOf(e,s);let r;return s?.useLocaleWeeks?r=this.end.reconfigure({locale:n.locale}):r=this.end,r=r.startOf(e,s),Math.floor(r.diff(n,e).get(e))+(r.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:e,end:s}={}){return this.isValid?fe.fromDateTimes(e||this.s,s||this.e):this}splitAt(...e){if(!this.isValid)return[];const s=e.map(Rt).filter(o=>this.contains(o)).sort((o,c)=>o.toMillis()-c.toMillis()),n=[];let{s:r}=this,a=0;for(;r<this.e;){const o=s[a]||this.e,c=+o>+this.e?this.e:o;n.push(fe.fromDateTimes(r,c)),r=c,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 c=this.start.plus(s.mapUnits(l=>l*r));a=+c>+this.e?this.e:c,o.push(fe.fromDateTimes(n,a)),n=a,r+=1}return o}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;const s=this.s>e.s?this.s:e.s,n=this.e<e.e?this.e:e.e;return s>=n?null:fe.fromDateTimes(s,n)}union(e){if(!this.isValid)return this;const s=this.s<e.s?this.s:e.s,n=this.e>e.e?this.e:e.e;return fe.fromDateTimes(s,n)}static merge(e){const[s,n]=e.sort((r,a)=>r.s-a.s).reduce(([r,a],o)=>a?a.overlaps(o)||a.abutsStart(o)?[r,a.union(o)]:[r.concat([a]),o]:[r,o],[[],null]);return n&&s.push(n),s}static xor(e){let s=null,n=0;const r=[],a=e.map(l=>[{time:l.s,type:"s"},{time:l.e,type:"e"}]),o=Array.prototype.concat(...a),c=o.sort((l,u)=>l.time-u.time);for(const l of c)n+=l.type==="s"?1:-1,n===1?s=l.time:(s&&+s!=+l.time&&r.push(fe.fromDateTimes(s,l.time)),s=null);return fe.merge(r)}difference(...e){return fe.xor([this].concat(e)).map(s=>this.intersection(s)).filter(s=>s&&!s.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:Tt}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=ls,s={}){return this.isValid?Te.create(this.s.loc.clone(s),e).formatInterval(this):Tt}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:Tt}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Tt}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:Tt}toFormat(e,{separator:s=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${s}${this.e.toFormat(e)}`:Tt}toDuration(e,s){return this.isValid?this.e.diff(this.s,e,s):K.invalid(this.invalidReason)}mapEndpoints(e){return fe.fromDateTimes(e(this.s),e(this.e))}}class Qt{static hasDST(e=he.defaultZone){const s=B.now().setZone(e).set({month:12});return!e.isUniversal&&s.offset!==s.set({month:6}).offset}static isValidIANAZone(e){return et.isValidZone(e)}static normalizeZone(e){return it(e,he.defaultZone)}static getStartOfWeek({locale:e=null,locObj:s=null}={}){return(s||re.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:s=null}={}){return(s||re.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:s=null}={}){return(s||re.create(e)).getWeekendDays().slice()}static months(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||re.create(s,n,a)).months(e)}static monthsFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||re.create(s,n,a)).months(e,!0)}static weekdays(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||re.create(s,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||re.create(s,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return re.create(e).meridiems()}static eras(e="short",{locale:s=null}={}){return re.create(s,null,"gregory").eras(e)}static features(){return{relative:$r(),localeWeek:Pr()}}}function $n(t,e){const s=r=>r.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),n=s(e)-s(t);return Math.floor(K.fromMillis(n).as("days"))}function Qo(t,e,s){const n=[["years",(l,u)=>u.year-l.year],["quarters",(l,u)=>u.quarter-l.quarter+(u.year-l.year)*4],["months",(l,u)=>u.month-l.month+(u.year-l.year)*12],["weeks",(l,u)=>{const m=$n(l,u);return(m-m%7)/7}],["days",$n]],r={},a=t;let o,c;for(const[l,u]of n)s.indexOf(l)>=0&&(o=l,r[l]=u(t,e),c=a.plus(r),c>e?(r[l]--,t=a.plus(r),t>e&&(c=t,r[l]--,t=a.plus(r))):t=c);return[t,r,c,o]}function Xo(t,e,s,n){let[r,a,o,c]=Qo(t,e,s);const l=e-r,u=s.filter(h=>["hours","minutes","seconds","milliseconds"].indexOf(h)>=0);u.length===0&&(o<e&&(o=r.plus({[c]:1})),o!==r&&(a[c]=(a[c]||0)+l/(o-r)));const m=K.fromObject(a,n);return u.length>0?K.fromMillis(l,n).shiftTo(...u).plus(m):m}const el="missing Intl.DateTimeFormat.formatToParts support";function te(t,e=s=>s){return{regex:t,deser:([s])=>e(Zi(s))}}const tl=" ",na=`[ ${tl}]`,ra=new RegExp(na,"g");function sl(t){return t.replace(/\./g,"\\.?").replace(ra,na)}function Pn(t){return t.replace(/\./g,"").replace(ra," ").toLowerCase()}function qe(t,e){return t===null?null:{regex:RegExp(t.map(sl).join("|")),deser:([s])=>t.findIndex(n=>Pn(s)===Pn(n))+e}}function Wn(t,e){return{regex:t,deser:([,s,n])=>Ss(s,n),groups:e}}function Xt(t){return{regex:t,deser:([e])=>e}}function nl(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function rl(t,e){const s=He(e),n=He(e,"{2}"),r=He(e,"{3}"),a=He(e,"{4}"),o=He(e,"{6}"),c=He(e,"{1,2}"),l=He(e,"{1,3}"),u=He(e,"{1,6}"),m=He(e,"{1,9}"),h=He(e,"{2,4}"),S=He(e,"{4,6}"),g=C=>({regex:RegExp(nl(C.val)),deser:([G])=>G,literal:!0}),j=(C=>{if(t.literal)return g(C);switch(C.val){case"G":return qe(e.eras("short"),0);case"GG":return qe(e.eras("long"),0);case"y":return te(u);case"yy":return te(h,Hs);case"yyyy":return te(a);case"yyyyy":return te(S);case"yyyyyy":return te(o);case"M":return te(c);case"MM":return te(n);case"MMM":return qe(e.months("short",!0),1);case"MMMM":return qe(e.months("long",!0),1);case"L":return te(c);case"LL":return te(n);case"LLL":return qe(e.months("short",!1),1);case"LLLL":return qe(e.months("long",!1),1);case"d":return te(c);case"dd":return te(n);case"o":return te(l);case"ooo":return te(r);case"HH":return te(n);case"H":return te(c);case"hh":return te(n);case"h":return te(c);case"mm":return te(n);case"m":return te(c);case"q":return te(c);case"qq":return te(n);case"s":return te(c);case"ss":return te(n);case"S":return te(l);case"SSS":return te(r);case"u":return Xt(m);case"uu":return Xt(c);case"uuu":return te(s);case"a":return qe(e.meridiems(),0);case"kkkk":return te(a);case"kk":return te(h,Hs);case"W":return te(c);case"WW":return te(n);case"E":case"c":return te(s);case"EEE":return qe(e.weekdays("short",!1),1);case"EEEE":return qe(e.weekdays("long",!1),1);case"ccc":return qe(e.weekdays("short",!0),1);case"cccc":return qe(e.weekdays("long",!0),1);case"Z":case"ZZ":return Wn(new RegExp(`([+-]${c.source})(?::(${n.source}))?`),2);case"ZZZ":return Wn(new RegExp(`([+-]${c.source})(${n.source})?`),2);case"z":return Xt(/[a-z_+-/]{1,256}?/i);case" ":return Xt(/[^\S\n\r]/);default:return g(C)}})(t)||{invalidReason:el};return j.token=t,j}const al={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function il(t,e,s){const{type:n,value:r}=t;if(n==="literal"){const l=/^\s+$/.test(r);return{literal:!l,val:l?" ":r}}const a=e[n];let o=n;n==="hour"&&(e.hour12!=null?o=e.hour12?"hour12":"hour24":e.hourCycle!=null?e.hourCycle==="h11"||e.hourCycle==="h12"?o="hour12":o="hour24":o=s.hour12?"hour12":"hour24");let c=al[o];if(typeof c=="object"&&(c=c[a]),c)return{literal:!1,val:c}}function ol(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function ll(t,e,s){const n=t.match(e);if(n){const r={};let a=1;for(const o in s)if(Et(s,o)){const c=s[o],l=c.groups?c.groups+1:1;!c.literal&&c.token&&(r[c.token.val[0]]=c.deser(n.slice(a,a+l))),a+=l}return[n,r]}else return[n,{}]}function cl(t){const e=a=>{switch(a){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let s=null,n;return Z(t.z)||(s=et.create(t.z)),Z(t.Z)||(s||(s=new Ie(t.Z)),n=t.Z),Z(t.q)||(t.M=(t.q-1)*3+1),Z(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),Z(t.u)||(t.S=tn(t.u)),[Object.keys(t).reduce((a,o)=>{const c=e(o);return c&&(a[c]=t[o]),a},{}),s,n]}let Es=null;function ul(){return Es||(Es=B.fromMillis(1555555555555)),Es}function dl(t,e){if(t.literal)return t;const s=Te.macroTokenToFormatOpts(t.val),n=la(s,e);return n==null||n.includes(void 0)?t:n}function aa(t,e){return Array.prototype.concat(...t.map(s=>dl(s,e)))}class ia{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=aa(Te.parseFormat(s),e),this.units=this.tokens.map(n=>rl(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=ol(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=ll(e,this.regex,this.handlers),[r,a,o]=n?cl(n):[null,null,void 0];if(Et(n,"a")&&Et(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 oa(t,e,s){return new ia(t,s).explainFromTokens(e)}function ml(t,e,s){const{result:n,zone:r,specificOffset:a,invalidReason:o}=oa(t,e,s);return[n,r,a,o]}function la(t,e){if(!t)return null;const n=Te.create(e,t).dtFormatter(ul()),r=n.formatToParts(),a=n.resolvedOptions();return r.map(o=>il(o,t,a))}const Ms="Invalid DateTime",Vn=864e13;function Ft(t){return new Ge("unsupported zone",`the zone "${t.name}" is not supported`)}function Os(t){return t.weekData===null&&(t.weekData=cs(t.c)),t.weekData}function js(t){return t.localWeekData===null&&(t.localWeekData=cs(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function yt(t,e){const s={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new B({...s,...e,old:s})}function ca(t,e,s){let n=t-e*60*1e3;const r=s.offset(n);if(e===r)return[n,e];n-=(r-e)*60*1e3;const a=s.offset(n);return r===a?[n,r]:[t-Math.min(r,a)*60*1e3,Math.max(r,a)]}function es(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 rs(t,e,s){return ca(gs(t),e,s)}function Bn(t,e){const s=t.o,n=t.c.year+Math.trunc(e.years),r=t.c.month+Math.trunc(e.months)+Math.trunc(e.quarters)*3,a={...t.c,year:n,month:r,day:Math.min(t.c.day,us(n,r))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},o=K.fromObject({years:e.years-Math.trunc(e.years),quarters:e.quarters-Math.trunc(e.quarters),months:e.months-Math.trunc(e.months),weeks:e.weeks-Math.trunc(e.weeks),days:e.days-Math.trunc(e.days),hours:e.hours,minutes:e.minutes,seconds:e.seconds,milliseconds:e.milliseconds}).as("milliseconds"),c=gs(a);let[l,u]=ca(c,s,t.zone);return o!==0&&(l+=o,u=t.zone.offset(l)),{ts:l,o:u}}function Nt(t,e,s,n,r,a){const{setZone:o,zone:c}=s;if(t&&Object.keys(t).length!==0||e){const l=e||c,u=B.fromObject(t,{...s,zone:l,specificOffset:a});return o?u:u.setZone(c)}else return B.invalid(new Ge("unparsable",`the input "${r}" can't be parsed as ${n}`))}function ts(t,e,s=!0){return t.isValid?Te.create(re.create("en-US"),{allowZ:s,forceSimple:!0}).formatDateTimeFromString(t,e):null}function Cs(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 Zn(t,e,s,n,r,a,o){let c=!s||t.c.millisecond!==0||t.c.second!==0,l="";switch(o){case"day":case"month":case"year":break;default:if(l+=ge(t.c.hour),o==="hour")break;if(e){if(l+=":",l+=ge(t.c.minute),o==="minute")break;c&&(l+=":",l+=ge(t.c.second))}else{if(l+=ge(t.c.minute),o==="minute")break;c&&(l+=ge(t.c.second))}if(o==="second")break;c&&(!n||t.c.millisecond!==0)&&(l+=".",l+=ge(t.c.millisecond,3))}return r&&(t.isOffsetFixed&&t.offset===0&&!a?l+="Z":t.o<0?(l+="-",l+=ge(Math.trunc(-t.o/60)),l+=":",l+=ge(Math.trunc(-t.o%60))):(l+="+",l+=ge(Math.trunc(t.o/60)),l+=":",l+=ge(Math.trunc(t.o%60)))),a&&(l+="["+t.zone.ianaName+"]"),l}const ua={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},fl={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},hl={ordinal:1,hour:0,minute:0,second:0,millisecond:0},as=["year","month","day","hour","minute","second","millisecond"],yl=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],pl=["year","ordinal","hour","minute","second","millisecond"];function is(t){const e={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[t.toLowerCase()];if(!e)throw new ur(t);return e}function zn(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return is(t)}}function gl(t){if($t===void 0&&($t=he.now()),t.type!=="iana")return t.offset($t);const e=t.name;let s=qs.get(e);return s===void 0&&(s=t.offset($t),qs.set(e,s)),s}function Hn(t,e){const s=it(e.zone,he.defaultZone);if(!s.isValid)return B.invalid(Ft(s));const n=re.fromObject(e);let r,a;if(Z(t.year))r=he.now();else{for(const l of as)Z(t[l])&&(t[l]=ua[l]);const o=Lr(t)||Fr(t);if(o)return B.invalid(o);const c=gl(s);[r,a]=rs(t,c,s)}return new B({ts:r,zone:s,loc:n,o:a})}function qn(t,e,s){const n=Z(s.round)?!0:s.round,r=Z(s.rounding)?"trunc":s.rounding,a=(c,l)=>(c=sn(c,n||s.calendary?0:2,s.calendary?"round":r),e.loc.clone(s).relFormatter(s).format(c,l)),o=c=>s.calendary?e.hasSame(t,c)?0:e.startOf(c).diff(t.startOf(c),c).get(c):e.diff(t,c).get(c);if(s.unit)return a(o(s.unit),s.unit);for(const c of s.units){const l=o(c);if(Math.abs(l)>=1)return a(l,c)}return a(t>e?-0:0,s.units[s.units.length-1])}function Gn(t){let e={},s;return t.length>0&&typeof t[t.length-1]=="object"?(e=t[t.length-1],s=Array.from(t).slice(0,t.length-1)):s=Array.from(t),[e,s]}let $t;const qs=new Map;class B{constructor(e){const s=e.zone||he.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Ge("invalid input"):null)||(s.isValid?null:Ft(s));this.ts=Z(e.ts)?he.now():e.ts;let r=null,a=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(s))[r,a]=[e.old.c,e.old.o];else{const c=ot(e.o)&&!e.old?e.o:s.offset(this.ts);r=es(this.ts,c),n=Number.isNaN(r.year)?new Ge("invalid input"):null,r=n?null:r,a=n?null:c}this._zone=s,this.loc=e.loc||re.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=a,this.isLuxonDateTime=!0}static now(){return new B({})}static local(){const[e,s]=Gn(arguments),[n,r,a,o,c,l,u]=s;return Hn({year:n,month:r,day:a,hour:o,minute:c,second:l,millisecond:u},e)}static utc(){const[e,s]=Gn(arguments),[n,r,a,o,c,l,u]=s;return e.zone=Ie.utcInstance,Hn({year:n,month:r,day:a,hour:o,minute:c,second:l,millisecond:u},e)}static fromJSDate(e,s={}){const n=Yi(e)?e.valueOf():NaN;if(Number.isNaN(n))return B.invalid("invalid input");const r=it(s.zone,he.defaultZone);return r.isValid?new B({ts:n,zone:r,loc:re.fromObject(s)}):B.invalid(Ft(r))}static fromMillis(e,s={}){if(ot(e))return e<-Vn||e>Vn?B.invalid("Timestamp out of range"):new B({ts:e,zone:it(s.zone,he.defaultZone),loc:re.fromObject(s)});throw new Ae(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,s={}){if(ot(e))return new B({ts:e*1e3,zone:it(s.zone,he.defaultZone),loc:re.fromObject(s)});throw new Ae("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=it(s.zone,he.defaultZone);if(!n.isValid)return B.invalid(Ft(n));const r=re.fromObject(s),a=ds(e,zn),{minDaysInFirstWeek:o,startOfWeek:c}=On(a,r),l=he.now(),u=Z(s.specificOffset)?n.offset(l):s.specificOffset,m=!Z(a.ordinal),h=!Z(a.year),S=!Z(a.month)||!Z(a.day),g=h||S,b=a.weekYear||a.weekNumber;if((g||m)&&b)throw new bt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(S&&m)throw new bt("Can't mix ordinal dates with month/day");const j=b||a.weekday&&!g;let C,G,F=es(l,u);j?(C=yl,G=fl,F=cs(F,o,c)):m?(C=pl,G=hl,F=Is(F)):(C=as,G=ua);let $=!1;for(const x of C){const O=a[x];Z(O)?$?a[x]=G[x]:a[x]=F[x]:$=!0}const T=j?Hi(a,o,c):m?qi(a):Lr(a),M=T||Fr(a);if(M)return B.invalid(M);const V=j?En(a,o,c):m?Mn(a):a,[D,q]=rs(V,u,n),p=new B({ts:D,zone:n,o:q,loc:r});return a.weekday&&g&&e.weekday!==p.weekday?B.invalid("mismatched weekday",`you can't specify both a weekday of ${a.weekday} and a date of ${p.toISO()}`):p.isValid?p:B.invalid(p.invalid)}static fromISO(e,s={}){const[n,r]=$o(e);return Nt(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=Po(e);return Nt(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=Wo(e);return Nt(n,r,s,"HTTP",s)}static fromFormat(e,s,n={}){if(Z(e)||Z(s))throw new Ae("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:a=null}=n,o=re.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0}),[c,l,u,m]=ml(o,e,s);return m?B.invalid(m):Nt(c,l,n,`format ${s}`,e,u)}static fromString(e,s,n={}){return B.fromFormat(e,s,n)}static fromSQL(e,s={}){const[n,r]=Go(e);return Nt(n,r,s,"SQL",e)}static invalid(e,s=null){if(!e)throw new Ae("need to specify a reason the DateTime is invalid");const n=e instanceof Ge?e:new Ge(e,s);if(he.throwOnInvalid)throw new xi(n);return new B({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,s={}){const n=la(e,re.fromObject(s));return n?n.map(r=>r?r.val:null).join(""):null}static expandFormat(e,s={}){return aa(Te.parseFormat(e),re.fromObject(s)).map(r=>r.val).join("")}static resetCache(){$t=void 0,qs.clear()}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?Os(this).weekYear:NaN}get weekNumber(){return this.isValid?Os(this).weekNumber:NaN}get weekday(){return this.isValid?Os(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?js(this).weekday:NaN}get localWeekNumber(){return this.isValid?js(this).weekNumber:NaN}get localWeekYear(){return this.isValid?js(this).weekYear:NaN}get ordinal(){return this.isValid?Is(this.c).ordinal:NaN}get monthShort(){return this.isValid?Qt.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Qt.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Qt.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Qt.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const e=864e5,s=6e4,n=gs(this.c),r=this.zone.offset(n-e),a=this.zone.offset(n+e),o=this.zone.offset(n-r*s),c=this.zone.offset(n-a*s);if(o===c)return[this];const l=n-o*s,u=n-c*s,m=es(l,o),h=es(u,c);return m.hour===h.hour&&m.minute===h.minute&&m.second===h.second&&m.millisecond===h.millisecond?[yt(this,{ts:l}),yt(this,{ts:u})]:[this]}get isInLeapYear(){return Bt(this.year)}get daysInMonth(){return us(this.year,this.month)}get daysInYear(){return this.isValid?kt(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}=Te.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:s,numberingSystem:n,outputCalendar:r}}toUTC(e=0,s={}){return this.setZone(Ie.instance(e),s)}toLocal(){return this.setZone(he.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=it(e,he.defaultZone),e.equals(this.zone))return this;if(e.isValid){let r=this.ts;if(s||n){const a=e.offset(this.ts),o=this.toObject();[r]=rs(o,a,e)}return yt(this,{ts:r,zone:e})}else return B.invalid(Ft(e))}reconfigure({locale:e,numberingSystem:s,outputCalendar:n}={}){const r=this.loc.clone({locale:e,numberingSystem:s,outputCalendar:n});return yt(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const s=ds(e,zn),{minDaysInFirstWeek:n,startOfWeek:r}=On(s,this.loc),a=!Z(s.weekYear)||!Z(s.weekNumber)||!Z(s.weekday),o=!Z(s.ordinal),c=!Z(s.year),l=!Z(s.month)||!Z(s.day),u=c||l,m=s.weekYear||s.weekNumber;if((u||o)&&m)throw new bt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(l&&o)throw new bt("Can't mix ordinal dates with month/day");let h;a?h=En({...cs(this.c,n,r),...s},n,r):Z(s.ordinal)?(h={...this.toObject(),...s},Z(s.day)&&(h.day=Math.min(us(h.year,h.month),h.day))):h=Mn({...Is(this.c),...s});const[S,g]=rs(h,this.o,this.zone);return yt(this,{ts:S,o:g})}plus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e);return yt(this,Bn(this,s))}minus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e).negate();return yt(this,Bn(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?Te.create(this.loc.redefaultToEN(s)).formatDateTimeFromString(this,e):Ms}toLocaleString(e=ls,s={}){return this.isValid?Te.create(this.loc.clone(s),e).formatDateTime(this):Ms}toLocaleParts(e={}){return this.isValid?Te.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:s=!1,suppressMilliseconds:n=!1,includeOffset:r=!0,extendedZone:a=!1,precision:o="milliseconds"}={}){if(!this.isValid)return null;o=is(o);const c=e==="extended";let l=Cs(this,c,o);return as.indexOf(o)>=3&&(l+="T"),l+=Zn(this,c,s,n,r,a,o),l}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?Cs(this,e==="extended",is(s)):null}toISOWeekDate(){return ts(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:s=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:a=!1,format:o="extended",precision:c="milliseconds"}={}){return this.isValid?(c=is(c),(r&&as.indexOf(c)>=3?"T":"")+Zn(this,o==="extended",s,e,n,a,c)):null}toRFC2822(){return ts(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return ts(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?Cs(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")),ts(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Ms}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};const s={...this.c};return e.includeConfig&&(s.outputCalendar=this.outputCalendar,s.numberingSystem=this.loc.numberingSystem,s.locale=this.loc.locale),s}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,s="milliseconds",n={}){if(!this.isValid||!e.isValid)return K.invalid("created by diffing an invalid DateTime");const r={locale:this.locale,numberingSystem:this.numberingSystem,...n},a=_i(s).map(K.normalizeUnit),o=e.valueOf()>this.valueOf(),c=o?this:e,l=o?e:this,u=Xo(c,l,a,r);return o?u.negate():u}diffNow(e="milliseconds",s={}){return this.diff(B.now(),e,s)}until(e){return this.isValid?fe.fromDateTimes(this,e):this}hasSame(e,s,n){if(!this.isValid)return!1;const r=e.valueOf(),a=this.setZone(e.zone,{keepLocalTime:!0});return a.startOf(s,n)<=r&&r<=a.endOf(s,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;const s=e.base||B.fromObject({},{zone:this.zone}),n=e.padding?this<s?-e.padding:e.padding:0;let r=["years","months","days","hours","minutes","seconds"],a=e.unit;return Array.isArray(e.unit)&&(r=e.unit,a=void 0),qn(s,this.plus(n),{...e,numeric:"always",units:r,unit:a})}toRelativeCalendar(e={}){return this.isValid?qn(e.base||B.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(B.isDateTime))throw new Ae("min requires all arguments be DateTimes");return jn(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every(B.isDateTime))throw new Ae("max requires all arguments be DateTimes");return jn(e,s=>s.valueOf(),Math.max)}static fromFormatExplain(e,s,n={}){const{locale:r=null,numberingSystem:a=null}=n,o=re.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});return oa(o,e,s)}static fromStringExplain(e,s,n={}){return B.fromFormatExplain(e,s,n)}static buildFormatParser(e,s={}){const{locale:n=null,numberingSystem:r=null}=s,a=re.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new ia(a,e)}static fromFormatParser(e,s,n={}){if(Z(e)||Z(s))throw new Ae("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:a=null}=n,o=re.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});if(!o.equals(s.locale))throw new Ae(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${s.locale}`);const{result:c,zone:l,specificOffset:u,invalidReason:m}=s.explainFromTokens(e);return m?B.invalid(m):Nt(c,l,n,`format ${s.format}`,e,u)}static get DATE_SHORT(){return ls}static get DATE_MED(){return dr}static get DATE_MED_WITH_WEEKDAY(){return Ai}static get DATE_FULL(){return mr}static get DATE_HUGE(){return fr}static get TIME_SIMPLE(){return hr}static get TIME_WITH_SECONDS(){return yr}static get TIME_WITH_SHORT_OFFSET(){return pr}static get TIME_WITH_LONG_OFFSET(){return gr}static get TIME_24_SIMPLE(){return Sr}static get TIME_24_WITH_SECONDS(){return xr}static get TIME_24_WITH_SHORT_OFFSET(){return vr}static get TIME_24_WITH_LONG_OFFSET(){return wr}static get DATETIME_SHORT(){return Ar}static get DATETIME_SHORT_WITH_SECONDS(){return Tr}static get DATETIME_MED(){return Nr}static get DATETIME_MED_WITH_SECONDS(){return br}static get DATETIME_MED_WITH_WEEKDAY(){return Ti}static get DATETIME_FULL(){return kr}static get DATETIME_FULL_WITH_SECONDS(){return Ir}static get DATETIME_HUGE(){return Er}static get DATETIME_HUGE_WITH_SECONDS(){return Mr}}function Rt(t){if(B.isDateTime(t))return t;if(t&&t.valueOf&&ot(t.valueOf()))return B.fromJSDate(t);if(t&&typeof t=="object")return B.fromObject(t);throw new Ae(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function Sl(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function xl(t,e){try{const s=B.fromJSDate(t,{zone:"utc"}).setZone(e),n=s.toJSDate().toLocaleString("en-US",{timeZone:e,timeZoneName:"short"}).split(" ").pop()||void 0,r=s.toFormat("ZZ")||void 0;return{abbr:n,offset:r}}catch{return{}}}function vl(t){if(!t)return"-";try{const e=new Date(t),s=u=>String(u).padStart(2,"0"),n=s(e.getMonth()+1),r=s(e.getDate()),a=e.getFullYear(),o=s(e.getHours()),c=s(e.getMinutes()),l=s(e.getSeconds());return`${n}/${r}/${a} ${o}:${c}:${l}`}catch{return"-"}}function ms(t,e="UTC"){if(!t)return"-";const s=B.fromISO(t,{zone:"utc"}).setZone(e);if(!s.isValid)return"-";const n=s.offsetNameShort,r=s.toFormat("ZZZZ"),a=n.startsWith("GMT")||n===r?r:`${n}/${r}`;return`${s.toFormat("MM/dd/yyyy, hh:mm:ss a")} (${a})`}const wl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Al={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function da({alerts:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,severityOptions:a,anomalyOptions:o,spaceOptions:c,onAlertIdClick:l,onFilterChange:u,onPageChange:m,onRefetch:h,resetKey:S,serverSideFilters:g}){const b=Ks(),j=async F=>{try{const $=await b.mutateAsync({alertUniqueId:F.alertId??F.id,alertId:F.id,status:"Reopen",notes:"Reopened",modifiedBy:0});if($?.responseStatus||$?.Success){const T=$?.Message||$?.data||"Alert reopened successfully.";we.toast.success(T)}else{const T=$?.errorMessage||$?.Message||"Failed to reopen alert";we.toast.error(T)}}catch{we.toast.error("Failed to reopen alert. Please try again.")}},C=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:F=>i.jsx(f.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${wl[F]}`,backgroundColor:Al[String(F)]},children:F})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:F=>vl(F)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(F,$)=>i.jsxs("div",{children:[i.jsx("a",{onClick:T=>{T.preventDefault(),l?.($,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:$.alertNumber}),i.jsx("div",{className:"text-black/65",children:F})]})},{title:"Preview",key:"preview",width:100,align:"center",render:(F,$)=>i.jsx(lr,{record:$})},{title:"",key:"menu",width:60,align:"right",render:(F,$)=>i.jsx(f.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:T})=>{T==="reopen"&&j($)}},children:i.jsx(f.Button,{type:"text",icon:i.jsx(gt.MoreOutlined,{})})})}],G=u&&g?t:(t||[]).filter(F=>{const $=os(F.statusType||"");return cr.some(T=>$.includes(os(T)))});return i.jsx(Js,{data:G,loading:e,pageSize:s,total:n,currentPage:r,columns:C,severityOptions:a,anomalyOptions:o,spaceOptions:c,renderActions:void 0,onAlertIdClick:l,onFilterChange:u,onPageChange:m,onRefetch:h,resetKey:S,serverSideFilters:g,excludeCompleted:!1})}function Tl({size:t=120,time:e,timeZone:s="America/New_York"}){const{hours:n,minutes:r,seconds:a}=d.useMemo(()=>{const h=new Intl.DateTimeFormat("en-US",{timeZone:s,hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(e);return{hours:parseInt(h.find(S=>S.type==="hour")?.value||"0",10),minutes:parseInt(h.find(S=>S.type==="minute")?.value||"0",10),seconds:parseInt(h.find(S=>S.type==="second")?.value||"0",10)}},[e,s]),o=a*6,c=r*6+a*.1,l=n%12*30+r*.5,u=t/2;return i.jsxs("div",{className:"relative rounded-full border border-gray-300 bg-white",style:{width:t,height:t},role:"img","aria-label":"Analog Clock",children:[[...Array(12)].map((m,h)=>{const S=h*30,g=6,b=u-4,j=b-g,C=(S-90)*(Math.PI/180),G=u+j*Math.cos(C),F=u+j*Math.sin(C),$=u+b*Math.cos(C),T=u+b*Math.sin(C);return i.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:i.jsx("line",{x1:G,y1:F,x2:$,y2:T,stroke:"#9CA3AF",strokeWidth:h%3===0?2:1,strokeLinecap:"round"})},h)}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${l}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.25,stroke:"#1F2937",strokeWidth:4,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${c}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.35,stroke:"#374151",strokeWidth:3,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${o}deg)`},children:i.jsx("line",{x1:u,y1:u+t*.08,x2:u,y2:u-t*.38,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"})}),i.jsx("div",{className:"absolute bg-gray-900 rounded-full",style:{width:8,height:8,left:u-4,top:u-4}})]})}function ma({label:t="USA",timeZone:e="America/New_York",updateIntervalMs:s=1e3,className:n}){const[r,a]=d.useState(new Date);d.useEffect(()=>{const u=setInterval(()=>a(new Date),s);return()=>clearInterval(u)},[s]);const o=d.useMemo(()=>Sl(r,e),[r,e]),{abbr:c,offset:l}=d.useMemo(()=>xl(r,e),[r,e]);return i.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[i.jsx(Tl,{time:r,timeZone:e,size:80}),i.jsxs("div",{className:"flex flex-col items-baseline gap-1",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[i.jsx("span",{className:"uppercase",children:t}),c&&i.jsxs("span",{className:"p-2 rounded-md border text-[10px] leading-none text-gray-600 bg-gray-50",children:[c," ",l]})]}),i.jsx("div",{className:"text-2xl font-semibold text-gray-700 tracking-wide",children:o})]})]})}const{Text:Nl}=f.Typography;function bl({sortBy:t,onChange:e,showActions:s,onSave:n,onClear:r,saving:a}){return i.jsxs(f.Row,{gutter:[16,16],align:"middle",children:[i.jsx(f.Col,{xs:24,md:8,lg:5,children:i.jsxs(f.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[i.jsx(Nl,{className:"text-gray-600 whitespace-nowrap",children:"Sort By:"}),i.jsx(f.Select,{placeholder:"By Severity",value:t,onChange:o=>e({sortBy:o}),options:[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],className:"w-full",style:{minWidth:"200px"}})]})}),i.jsx(f.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?i.jsxs(f.Space,{className:"w-full",direction:"horizontal",size:8,children:[i.jsx(f.Button,{onClick:r,disabled:a,children:"Clear"}),i.jsx(f.Button,{type:"primary",onClick:n,loading:a,children:"Save"})]}):null})]})}const Gs=t=>i.jsxs(f.Tag,{children:[i.jsx(gt.PlusOutlined,{})," ",t.length," more"]}),{Text:Xe}=f.Typography;function kl(t){const{selectedRule:e,setSelectedRule:s,ruleOptions:n,minsOptions:r,roleOptions:a,l1mins:o,setL1mins:c,l1role:l,setL1role:u,l2mins:m,setL2mins:h,l2role:S,setL2role:g,l3mins:b,setL3mins:j,l3role:C,setL3role:G,actions:F,setActions:$,thirdPartyIds:T,setThirdPartyIds:M,humanLoop:V,setHumanLoop:D,isAutoExpire:q,setAutoExpire:p,onClear:x,onSave:O,saving:le,onActionTypesLoaded:ae}=t,{rules:U,config:w}=Ee(),v=w.tenant==="schools",[I,A]=d.useState([]),[R,P]=d.useState([]),[Y,J]=d.useState(!1);d.useEffect(()=>{let ie=!1;return(async()=>{try{J(!0);const me=await U.getLookups();if(ie||!me||!Array.isArray(me.actionTypes))return;const Se=me.actionTypes.map(ce=>({label:ce.name,value:String(ce.actionTypeId)}));A(Se),ae&&ae(me.actionTypes);const oe=Array.isArray(me.thirdParties)?me.thirdParties.map(ce=>({label:ce.thirdPartyName,value:ce.thirdPartyIds??ce.thirdPartyId})):[];P(oe)}catch(me){console.error("Error loading lookups",me)}finally{ie||J(!1)}})(),()=>{ie=!0}},[]);const Q=typeof o=="number"||typeof l=="number",se=typeof m=="number"||typeof S=="number",X=typeof o=="number"||typeof l=="number"||typeof m=="number"||typeof S=="number"||typeof b=="number"||typeof C=="number"||Array.isArray(F)&&F.length>0||Array.isArray(T)&&T.length>0||!!V||!!q,ye=!!e&&X&&!le;return i.jsxs(f.Spin,{spinning:!!le||Y,children:[i.jsxs(f.Row,{gutter:[16,16],align:"bottom",children:[i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(f.Select,{placeholder:"Rules",value:e,onChange:s,options:n,className:"w-full"})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),i.jsx(f.Col,{span:14,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(f.Select,{className:"w-full",placeholder:"Mins",value:o,onChange:c,options:r})}),i.jsx(f.Col,{span:14,children:i.jsx(f.Select,{placeholder:"Escalate to",className:"w-full",value:l,onChange:u,options:a})})]})]})}),Q&&i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),i.jsx(f.Col,{span:14,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(f.Select,{className:"w-full",placeholder:"Mins",value:m,onChange:h,options:r})}),i.jsx(f.Col,{span:14,children:i.jsx(f.Select,{placeholder:"Escalate to",className:"w-full",value:S,onChange:g,options:a})})]})]})}),se&&i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),i.jsx(f.Col,{span:14,children:i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(f.Row,{gutter:8,children:[i.jsx(f.Col,{span:10,children:i.jsx(f.Select,{className:"w-full",placeholder:"Mins",value:b,onChange:j,options:r})}),i.jsx(f.Col,{span:14,children:i.jsx(f.Select,{placeholder:"Escalate to",className:"w-full",value:C,onChange:G,options:a})})]})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),i.jsx(f.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:F,onChange:$,options:I,maxTagCount:1,maxTagPlaceholder:Gs})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Xe,{className:"text-gray-700 font-medium block mb-1",children:"Notify"}),i.jsx(f.Select,{mode:"multiple",placeholder:"Notify",className:"w-full",value:T,onChange:M,options:R,maxCount:2,maxTagPlaceholder:Gs})]})})]}),i.jsxs(f.Row,{gutter:[16,16],align:"bottom",className:"mt-4 items-center",children:[i.jsx(f.Col,{xs:24,sm:12,md:8,lg:7,children:i.jsxs("div",{className:"flex items-center h-full gap-8",children:[!v&&i.jsx(f.Checkbox,{checked:V,onChange:ie=>D(ie.target.checked),className:"w-full",children:"Human-In-The-Loop"}),i.jsx(f.Checkbox,{checked:q,onChange:ie=>p(ie.target.checked),className:"w-full",children:"Auto-expire in 5 minutes"})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(f.Button,{onClick:x,children:"Clear"}),i.jsx(f.Button,{type:"primary",onClick:O,loading:!!le,disabled:!ye,children:"Save"})]})})]})]})}function Il({entries:t,userRoles:e,onEdit:s,loading:n}){const{config:r}=Ee(),a=r.tenant==="schools",o=new Map(e.map(l=>[l.userRoleId,l.userRoleName])),c=l=>l.map(u=>o.get(u)||String(u)).join(", ");return i.jsx(f.Table,{rowKey:"id",dataSource:t,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(l,u)=>`${u[0]}-${u[1]} of ${l} items`},loading:n,columns:[{title:"Rule",dataIndex:"ruleOrSeverityLabel",key:"rule"},{title:"Level 1",key:"l1",render:(l,u)=>i.jsxs("span",{children:[u.l1.minutes?`Action taken in (${u.l1.minutes} Mins)`:"No Action taken in 0 Min",u.l1.roles?.length?`, Escalate to (${c(u.l1.roles)})`:""]})},{title:"Level 2",key:"l2",render:(l,u)=>i.jsxs("span",{children:[u.l2.minutes?`Action taken in (${u.l2.minutes} Mins)`:"No Action taken in 0 Min",u.l2.roles?.length?`, Escalate to (${c(u.l2.roles)})`:""]})},{title:"Level 3",key:"l3",render:(l,u)=>i.jsxs("span",{children:[u.l3.minutes?`Action taken in (${u.l3.minutes} Mins)`:"No Action taken in 0 Min",u.l3.roles?.length?`, Escalate to (${c(u.l3.roles)})`:""]})},{title:"Pick Actions",key:"actionsCol",render:(l,u)=>u.actions?.length?u.actions.join(", "):"-"},{title:"Notify",key:"notify",render:(l,u)=>u.notify?.length?u.notify.join(", "):"-"},...a?[]:[{title:"Human-In-The-Loop",key:"humanLoop",render:(l,u)=>u.humanLoop?"Yes":"No"}],{title:"Auto Expire",key:"isAutoExpire",render:(l,u)=>u.isAutoExpire?"Yes":"No"},{title:"Actions",key:"ops",render:(l,u)=>i.jsx(f.Button,{type:"text",onClick:()=>s(u.id),children:i.jsx(gt.EditOutlined,{})})}]})}const{Title:El,Text:Ds}=f.Typography;function fa({userRoles:t,rules:e,rawRules:s}){const{rules:n}=Ee(),[r,a]=d.useState(!1),[o,c]=d.useState(!1),[l,u]=d.useState(s),[m,h]=d.useState(),[S,g]=d.useState([]),b=d.useMemo(()=>t.map(T=>({label:T.userRoleName,value:T.userRoleId})),[t]),j=d.useMemo(()=>(e||[]).map(T=>({label:T.Name||"-",value:T.RuleId||T.Name||""})),[e]),C=d.useMemo(()=>(e||[]).map((T,M)=>({key:T.RuleId||T.Name||String(M),ruleName:T.Name||"-",ruleDesc:T.Description||""})),[e]);d.useEffect(()=>{let T=!1;return(async()=>{try{a(!0);const M=await n.getRules();T||u(Array.isArray(M)?M:[])}catch{!T&&Array.isArray(s)&&u(s)}finally{T||a(!1)}})(),()=>{T=!0}},[]),d.useEffect(()=>{!l&&Array.isArray(s)&&u(s)},[s]),d.useEffect(()=>{if(!m||!Array.isArray(l)){g([]);return}const T=l.find(V=>V?.ruleId===m||V?.RuleId===m||V?.ruleName===m),M=T?.userRoleIds??T?.UserRoleIds;g(Array.isArray(M)?M:[])},[m,l]);const G=d.useMemo(()=>{if(!Array.isArray(l)||!l.length)return{};const T={};for(const M of C){const V=l.find(p=>p?.ruleId===M.key||p?.ruleName===M.key||p?.RuleId===M.key||p?.ruleName===M.ruleName||p?.Name===M.ruleName),D=V?.userRoleIds??V?.UserRoleIds,q=Array.isArray(D)?D:[];q.length&&(T[M.key]=q)}return T},[l,C]),F=()=>{h(void 0),g([])},$=async()=>{if(!m){we.toast.info("Please select a rule");return}try{c(!0);const T=Array.isArray(l)?l.find(p=>p?.ruleId===m||p?.RuleId===m||p?.ruleName===m):void 0,M=typeof T?.recordId=="number"?T.recordId:T?.ruleId||T?.RuleId||void 0;if(!T||!M)throw new Error(`Unable to find rule identifier for rule ${m}`);const V=S.map(p=>{const x=t.find(O=>O.userRoleId===p);return{id:p,name:x?.userRoleName??String(p)}}),D={...T,ruleId:m,userRoleIds:S,userRoles:V},q=await n.updateRule(M,D);if(!q?.responseStatus&&!q?.Success&&!q?.success)we.toast.error(q?.errorMessage||q?.Message||"Error saving Alert Assignment");else{we.toast.success("Alert assignment saved"),h(void 0),g([]);try{const p=await n.getRules();u(Array.isArray(p)?p:[])}catch(p){console.error("Failed to refresh rules after save",p)}}}catch(T){console.error("Failed to save alert assignment",T),we.toast.error(T instanceof Error?T.message:"Error saving Alert Assignment")}finally{c(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(El,{level:4,className:"!mb-4",children:"Alert Assignment"}),i.jsx(f.Spin,{spinning:o||r,children:i.jsxs(f.Row,{gutter:[16,16],align:"bottom",className:"mb-6",children:[i.jsx(f.Col,{xs:24,sm:12,md:8,lg:6,children:i.jsxs("div",{children:[i.jsx(Ds,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(f.Select,{placeholder:"Rules",value:m,onChange:h,options:j,className:"w-full"})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:8,children:i.jsxs("div",{children:[i.jsx(Ds,{className:"text-gray-700 font-medium block mb-1",children:"Alert Notification To"}),i.jsx(f.Select,{mode:"multiple",placeholder:"Select roles",className:"w-full",value:S,onChange:g,options:b,maxTagCount:1,maxTagPlaceholder:Gs})]})}),i.jsx(f.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(f.Button,{onClick:F,disabled:o,children:"Cancel"}),i.jsx(f.Button,{type:"primary",onClick:$,loading:o,disabled:o||!m,children:"Save"})]})})]})}),i.jsx(f.Table,{rowKey:"key",dataSource:C,loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(T,M)=>`${M[0]}-${M[1]} of ${T} items`},columns:[{title:"Rule Name",dataIndex:"ruleName",key:"ruleName"},{title:"Description",dataIndex:"ruleDesc",key:"ruleDesc"},{title:"Alert Notification To",key:"assign",render:(T,M)=>{const V=G[M.key]??[];return V.length?i.jsx("div",{className:"flex flex-wrap gap-1",children:V.map(D=>{const q=t.find(p=>p.userRoleId===D);return i.jsx(f.Tag,{children:q?.userRoleName??String(D)},D)})}):i.jsx(Ds,{type:"secondary",children:"—"})}}]})]})}const{Title:Yn}=f.Typography;function Rs(t){return!t||typeof t!="object"?{}:{level1UserRoleId:t.level1UserRoleId??t.Level1UserRoleId,level1PostAssistTime:t.level1PostAssistTime??t.Level1PostAssistTime,level2UserRoleId:t.level2UserRoleId??t.Level2UserRoleId,level2PostAssistTime:t.level2PostAssistTime??t.Level2PostAssistTime,level3UserRoleId:t.level3UserRoleId??t.Level3UserRoleId,level3PostAssistTime:t.level3PostAssistTime??t.Level3PostAssistTime,escalationSettingsActionTypeIds:t.escalationSettingsActionTypeIds??t.EscalationSettingsActionTypeIds,thirdPartyId:t.thirdPartyId??t.ThirdPartyId??t.ThirdPartyIds,humanLoop:t.humanLoop??t.HumanLoop,isAutoExpire:t.isAutoExpire??t.IsAutoExpire}}function ha({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r,onSave:a}){const{rules:o,alerts:c}=Ee(),[l,u]=d.useState("By Severity"),[m,h]=d.useState("By severity"),[S,g]=d.useState("By Severity"),[b,j]=d.useState(!1),[C,G]=d.useState(!1),[F,$]=d.useState(!1),[T,M]=d.useState(null),[V,D]=d.useState("rules"),[q,p]=d.useState(),[x,O]=d.useState(),[le,ae]=d.useState(),[U,w]=d.useState(),[v,I]=d.useState(),[A,R]=d.useState(),[P,Y]=d.useState(),[J,Q]=d.useState(),[se,X]=d.useState([]),[ye,ie]=d.useState([]),[me,Se]=d.useState(!1),[oe,ce]=d.useState(!1),[xe,Ue]=d.useState({}),[Le,tt]=d.useState({}),[st,vt]=d.useState(s||[]),[lt,wt]=d.useState([]),[Dt,ee]=d.useState(!1),[z,pe]=d.useState(!1),[ne,Ne]=d.useState(n||[]);d.useEffect(()=>{n&&n.length&&Ne(n)},[n]),d.useEffect(()=>{if(!ne||!ne.length)return;const L=Object.keys(xe).length>0||Object.keys(Le).length>0;if(lt.length&&!L)return;const _=ne.map((W,y)=>{const E=e.find(ke=>ke.RuleId===(W.ruleId||W.ruleName))?.Name||W.ruleName||W.Name||"-",k=Rs(W.escalationSettings),H=typeof k.level1UserRoleId=="number"&&k.level1UserRoleId>0?[k.level1UserRoleId]:[],be=typeof k.level2UserRoleId=="number"&&k.level2UserRoleId>0?[k.level2UserRoleId]:[],ue=typeof k.level3UserRoleId=="number"&&k.level3UserRoleId>0?[k.level3UserRoleId]:[],Je=(Array.isArray(k.escalationSettingsActionTypeIds)?k.escalationSettingsActionTypeIds:[]).map(ke=>xe[ke]||String(ke)),ln=(Array.isArray(k.thirdPartyId)?k.thirdPartyId:[]).map(ke=>Le[ke]||String(ke)),ws=typeof k.humanLoop=="boolean"?k.humanLoop:null,As=typeof k.isAutoExpire=="boolean"?k.isAutoExpire:null;return{id:String(W.ruleId||W.ruleName||y),ruleOrSeverityLabel:E,l1:{minutes:k.level1PostAssistTime??void 0,roles:H},l2:{minutes:k.level2PostAssistTime??void 0,roles:be},l3:{minutes:k.level3PostAssistTime??void 0,roles:ue},actions:Je,notify:ln,humanLoop:ws,isAutoExpire:As}});wt(_)},[ne,e,xe,Le]);const je=d.useMemo(()=>t.map(L=>({label:L.DisplayName,value:L.SeverityId})),[t]),Ze=d.useMemo(()=>e.map(L=>({label:L.Name,value:L.RuleId})),[e]),Fe=d.useMemo(()=>st.map(L=>({label:L.userRoleName,value:L.userRoleId})),[st]),ve=d.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(L=>({label:`${L}`,value:L})),[]);d.useEffect(()=>{let L=!1;async function _(){try{$(!0),M(null);const W=await c.getAdminSettings();if(!L&&W){const y=Kn(W.sortBy);u(y),g(y),j(!1)}}catch(W){if(!L){const y=W instanceof Error?W.message:"Failed to load admin settings";M(y)}}finally{L||$(!1)}}return _(),()=>{L=!0}},[]),d.useEffect(()=>{if(!x)return;const L=E=>{const k=Number(E);return!isNaN(k)&&k>0?k:void 0},_=E=>{const k=Number(E);return!isNaN(k)&&k>0?k:void 0},W=(ne||[]).find(E=>E?.ruleId===x||E?.ruleName===x||E?.RuleId===x),y=Rs(W?.escalationSettings);if(y&&typeof y=="object"){ae(_(y.level1PostAssistTime)),w(L(y.level1UserRoleId)),I(_(y.level2PostAssistTime)),R(L(y.level2UserRoleId)),Y(_(y.level3PostAssistTime)),Q(L(y.level3UserRoleId));const E=Array.isArray(y.escalationSettingsActionTypeIds)?y.escalationSettingsActionTypeIds:[];X(E.map(k=>String(k))),ie(Array.isArray(y.thirdPartyId)?y.thirdPartyId:[]),Se(!!y.humanLoop),ce(!!y.isAutoExpire)}},[V,x,ne]);const ct=async()=>{try{pe(!0);const L=await o.getRules(),_=Array.isArray(L)?L:Array.isArray(L?.data)?L.data:[];Ne(_);const W=_.map((y,E)=>{const k=e.find(ke=>ke.RuleId===(y.ruleId||y.ruleName))?.Name||y.ruleName||y.Name||"-",H=Rs(y.escalationSettings??y.EscalationSettings),be=typeof H.level1UserRoleId=="number"&&H.level1UserRoleId>0?[H.level1UserRoleId]:[],ue=typeof H.level2UserRoleId=="number"&&H.level2UserRoleId>0?[H.level2UserRoleId]:[],ze=typeof H.level3UserRoleId=="number"&&H.level3UserRoleId>0?[H.level3UserRoleId]:[],_e=(Array.isArray(H.escalationSettingsActionTypeIds)?H.escalationSettingsActionTypeIds:[]).map(ke=>xe[ke]||String(ke)),ws=(Array.isArray(H.thirdPartyId)?H.thirdPartyId:[]).map(ke=>Le[ke]||String(ke)),As=typeof H.humanLoop=="boolean"?H.humanLoop:null;return{id:String(y.ruleId||y.ruleName||E),ruleOrSeverityLabel:k,l1:{minutes:H.level1PostAssistTime??void 0,roles:be},l2:{minutes:H.level2PostAssistTime??void 0,roles:ue},l3:{minutes:H.level3PostAssistTime??void 0,roles:ze},actions:_e,notify:ws,humanLoop:As}});wt(W)}catch(L){console.error("Failed to refetch entries",L)}finally{pe(!1)}};d.useEffect(()=>{let L=!1;return(async()=>{try{const _=await o.getLookups();if(L||!_)return;const W={};if(Array.isArray(_.thirdParties))for(const E of _.thirdParties){const k=E.thirdPartyIds??E.thirdPartyId;typeof k=="number"&&(W[k]=E.thirdPartyName)}tt(W);const y=Array.isArray(_.userRoles)?_.userRoles.map(E=>({userRoleId:E.userRoleId??E.id,userRoleName:E.userRoleName??E.name})):[];L||vt(y.length?y:s||[])}catch(_){console.error("Error loading lookups",_)}})(),()=>{L=!0}},[]);const ut=async()=>{G(!0);try{const L=await c.setAdminSettings({sortBy:l,groupBy:"string"});L?.responseStatus&&L?.data&&we.toast.success(L.data),g(l),j(!1)}catch(L){console.error("Error saving admin settings",L)}finally{G(!1)}},dt=()=>{u(S),j(!1)},mt=async()=>{ee(!0),a?.({ruleId:x,levels:[{minutes:le,role:U},{minutes:v,role:A},{minutes:P,role:J}],actions:se,thirdPartyIds:ye,humanLoop:me,isAutoExpire:oe});try{if(x){const _=Array.isArray(se)?se.map(H=>Number.isNaN(Number(H))?H:Number(H)):[],W=(ne||[]).find(H=>H?.ruleId===x||H?.ruleName===x||H?.RuleId===x),y=typeof W?.recordId=="number"?W.recordId:W?.ruleId||W?.RuleId||void 0;if(!W||!y){we.toast.error("Unable to find rule identifier for update");return}const E={...W,escalationSettings:{level1UserRoleId:U??0,level1PostAssistTime:le??0,level2UserRoleId:A??0,level2PostAssistTime:v??0,level3UserRoleId:J??0,level3PostAssistTime:P??0,escalationSettingsActionTypeIds:_,thirdPartyId:Array.isArray(ye)?ye:[],humanLoop:me,isAutoExpire:oe}},k=await o.updateRule(y,E);k?.responseStatus||k?.Success||k?.success?(we.toast.success("Escalation settings saved"),await ct(),O(void 0),ae(void 0),w(void 0),I(void 0),R(void 0),Y(void 0),Q(void 0),X([]),ie([]),Se(!1),ce(!1)):we.toast.error(k?.errorMessage||k?.Message||"Error saving Escalation Settings")}}catch(_){console.error("Error saving escalation settings",_)}finally{ee(!1)}},ft=()=>{u("By Severity"),h("By severity"),D("rules"),p(void 0),O(void 0),ae(void 0),w(void 0),I(void 0),R(void 0),Y(void 0),Q(void 0),X([]),ie([]),Se(!1),ce(!1)};return i.jsxs("div",{className:"w-full",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(Yn,{level:4,className:"!mb-2",children:"Admin Settings"}),i.jsxs(f.Spin,{spinning:F,children:[T?i.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",T]}):null,i.jsx(bl,{sortBy:l,groupBy:m,onChange:L=>{L.sortBy&&(u(L.sortBy),j(!0)),L.groupBy&&(h(L.groupBy),j(!0))},showActions:b,onSave:ut,onClear:dt,saving:C})]})]}),i.jsx(f.Divider,{className:"my-6"}),i.jsxs("div",{children:[i.jsx(Yn,{level:4,className:"!mb-4",children:"Escalation Settings"}),i.jsx(kl,{escBasis:V,setEscBasis:D,selectedSeverity:q,setSelectedSeverity:p,selectedRule:x,setSelectedRule:O,severityOptions:je,ruleOptions:Ze,minsOptions:ve,roleOptions:Fe,l1mins:le,setL1mins:ae,l1role:U,setL1role:w,l2mins:v,setL2mins:I,l2role:A,setL2role:R,l3mins:P,setL3mins:Y,l3role:J,setL3role:Q,actions:se,setActions:X,thirdPartyIds:ye,setThirdPartyIds:ie,humanLoop:me,setHumanLoop:Se,onClear:ft,onSave:mt,saving:Dt,onActionTypesLoaded:L=>{const _={};for(const W of L)typeof W.actionTypeId=="number"&&(_[W.actionTypeId]=W.name);Ue(_)},isAutoExpire:oe,setAutoExpire:ce})]}),i.jsx(f.Divider,{className:"my-6"}),i.jsx(Il,{entries:lt,userRoles:st,loading:z||r,onEdit:L=>{D("rules");const _=lt.find(y=>y.id===L),W=e.find(y=>y.RuleId===L)||(_?e.find(y=>y.Name===_.ruleOrSeverityLabel):void 0);O(W?W.RuleId:L)}}),i.jsx(f.Divider,{className:"my-6"}),i.jsx(fa,{userRoles:st,rules:e,rawRules:n}),i.jsx(f.Divider,{})]})}const{Title:_n,Text:ss}=f.Typography;function Ml({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:a}=Ee(),o=[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],[c,l]=d.useState("By Severity"),[u,m]=d.useState(new Set),[h,S]=d.useState(null),[g,b]=d.useState(null),[j,C]=d.useState({inApp:!1,sms:!1,email:!1}),[G,F]=d.useState([]),[$,T]=d.useState(!0),[M,V]=d.useState(!1);d.useEffect(()=>{let p=!1;return(async()=>{try{const x=await a.getPreferenceSettings();if(p||!x)return;C({inApp:!!x.inApp,sms:!!x.sms,email:!!x.email});const O=Kn(x.sortBy);l(O==="By Created Date"?"By Created Date":"By Severity"),S(yn(x.doNotDisturbStart)),b(yn(x.doNotDisturbEnd)),Array.isArray(x.anomalyIds)&&m(new Set(x.anomalyIds.map(le=>String(le))))}catch(x){console.error("Error in loading my preferences: ",x)}})(),()=>{p=!0}},[]),d.useEffect(()=>{let p=!1;return(async()=>{try{T(!0);const x=await r.getLookups();if(p||!x)return;const O=Array.isArray(x.anomalies)?x.anomalies:[];F(O)}catch(x){console.error("Failed to load anomalies lookups",x)}finally{p||T(!1)}})(),()=>{p=!0}},[]);const D=p=>{m(x=>{const O=new Set(x);return O.has(p)?O.delete(p):O.add(p),O})},q=async()=>{s?.({sortBy:c,subscribedRuleIds:Array.from(u),dnd:{from:h,to:g},channels:j});try{V(!0);const p=h?h.format?.("HH:mm:ss")??"00:00:00":"00:00:00",x=g?g.format?.("HH:mm:ss")??"00:00:00":"00:00:00",O=Array.from(u).map(ae=>Number(ae)).filter(ae=>Number.isFinite(ae)),le=await a.setPreferenceSettings({anomalyIds:O,doNotDisturbStart:p,doNotDisturbEnd:x,inApp:!!j.inApp,sms:!!j.sms,email:!!j.email,sortBy:c});le?.responseStatus&&we.toast.success(le?.data||"Preferences updated successfully.")}catch(p){console.error("Error in saving my preferences: ",p)}finally{V(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(f.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:i.jsx(f.Col,{xs:24,md:8,children:i.jsxs(f.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(ss,{className:"text-gray-600",children:"Sort By:"}),i.jsx(f.Select,{className:"w-[240px]",value:c,options:o,onChange:l})]})})}),i.jsxs("div",{className:"mb-4",children:[i.jsx(_n,{level:5,className:"!mb-2",children:"Anomalies"}),$?i.jsx("div",{className:"py-4",children:i.jsx(f.Spin,{})}):i.jsx(f.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray(G)?G:[]).map(p=>{const x=String(p.recordId),O=p.anomalyName;return i.jsx(f.Checkbox,{checked:u.has(x),onChange:()=>D(x),children:O},x)})})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx(_n,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),i.jsx(f.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:i.jsx(f.Col,{xs:24,md:12,children:i.jsxs(f.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(ss,{children:"Do Not Disturb mode:"}),i.jsxs(f.Space,{size:12,className:"w-full",children:[i.jsxs(f.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(ss,{children:"From"}),i.jsx(f.TimePicker,{value:h,onChange:p=>S(p),format:"HH:mm"})]}),i.jsxs(f.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(ss,{children:"To"}),i.jsx(f.TimePicker,{value:g,onChange:p=>b(p),format:"HH:mm"})]})]})]})})}),i.jsxs(f.Row,{gutter:[24,12],children:[i.jsx(f.Col,{children:i.jsx(f.Checkbox,{checked:j.inApp,onChange:p=>C({...j,inApp:p.target.checked}),children:"In-app"})}),i.jsx(f.Col,{children:i.jsx(f.Checkbox,{checked:j.sms,onChange:p=>C({...j,sms:p.target.checked}),children:"SMS"})}),i.jsx(f.Col,{children:i.jsx(f.Checkbox,{checked:j.email,onChange:p=>C({...j,email:p.target.checked}),children:"Email"})})]})]}),i.jsx(f.Divider,{}),i.jsxs(f.Space,{className:"gap-3",children:[i.jsx(f.Button,{onClick:n,disabled:M,children:"Cancel"}),i.jsx(f.Button,{type:"primary",onClick:q,loading:M,children:"Save"})]})]})}function ya({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r}){return i.jsx("div",{className:"w-full",children:i.jsx(ha,{severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r})})}const Ol="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAIZSURBVHgBnZW/b9NAFMe/z3H6i1ZNJUBFQsL/QQkLCFBtRhhKF1ibhBmpXbtgFlYqsTG0gRGWwgAjMb8EYmjYGN0pCCrVVaX+SBxf37PiqHWcOu5Xsux79+6j77vz3RH66IbdsDTQPCFngmBwqMCPBwVXoe204Fd/2ZfrSWMpHrDshtGCvsY9FlKkFNYD+Es/7EtuX+itp1sLnLrScTWoPMYsfnty/lUPtAOs4syiUgQOoWHJpG9kdBiX11Z+UaZCk1YT+vOzACuzYxgf7hZbyBGvhTi9af+7SkQbyKi7M8N4ZJ5D+eU2dg9UN07KvyNOS8io6UkNFXMMj1/vnACKAuTmNXZpIqME+LF+iIbX7ukjkClODWTQw+ujuGYMYfXzXnICbxSBDrxAUvYDhkrZp6ggUC8+sDI7mpj9YmESb3/uJ5Z9TJ5A3eORvzsBpgs6lufGT2TKPNY3fbxh6Knis0FTSjnx+LP3u5DJicDi/t7MCFadPaRJQTl02/5vKcKnpITluYkwrWjksebs48Pvg3SoUkXtq32hxt+1pITI8Zc/zcGACN59ty/WdWnklV5ukZ+49wU8MUJIF3mBGlqUr3Dv1+wpl20v9UuP75pElyrgc3XK7UJFbLvK4DJiv9ggDmWcjO9G4imWvW00yV/hjvtpOFnpQOVLkcO+0EhyevGrROG1ol1hREFc8ZGxyddIje+v9c4i9+gI5z7MozLxclgAAAAASUVORK5CYII=",jl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAKeSURBVHgBjVVdbtpAEJ5ZmygPfTBSaVWpUt0bwFuURgJOUG5QeoLACbw+QeAEwA3SGxgJokh9CDeI+xSpTRU/Imw8nbFZx6QQGAl5d2fm229+dkDYI2f6oaUAOwhWExBcPnL4FwFBSLCexpCMf+qPi12++PKgpR/cGOwRa1pwQIjgOoWkf6s/hOVzVd588R+/xWjf5YAY8Y0+ErQrZFfnXg3lK3uGm7A+RISOxfbit5NprqBxxgBoeEIVHehqtI9lSz+5McaaITaA2J17bycFaBayMOS8IaT+zHuv4Ui58P9oAvB4Ga0paUgqbFGswL5idIcIx3P9DCiXrQB7iJawcTiCkMMIUlj7Jo8zr6Yv/EfRXXIqRnzUxnP9u46Id8Q5Sslq3+pqWErHAPKqvxROC/ZMuJwKJ8bkPouUkrYUqgt5IgMDKAxfAYT8nAZnmR2A5J47YSjrFKyOYpZN2SiIJ8YjRqVfASyAFVg9s2F2gXwRsClMXdnYcFpq5PyiQ8KEilaywc79+aEow2i7fdCF46SIpuTvCGi2kWSXjCM4QqS4Zl3yjwQ0UySwrBfGRJNjQKW4ZrmEpL45CxUDTGWdgmoZgxOoDA6zxYgr7ZudhWk3x6Sp4kl0nZmgujQhcH5Cvqy/Hxi5hdL+dgsWxR2rma4FkLeDw+PMM243+t2YB0jDDI9nMBquyWqI3tjmLYguQfqDzxebty/DIcnePr9jfePVfDhSzv2/Hs8LAY3kMmFfTCl+rl3uu1GWF6Jx+X3vkpa+58jeeNyXvY3Pd8N+a0hvgK9ge3hMTmG5CPTnSICWcFpXaDfZUcAck99yOnZM/id3hcmAFV/hgEilU6p0TcH2gpZYS98xc/kXUJ8YImPFzfeLh0cgXbMp8n/yD3ySPZSK0MWKAAAAAElFTkSuQmCC";function vs(){const{config:t}=Ee();return{timeZoneDetails:d.useMemo(()=>{const s=t.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone;return{timeZoneUniqueId:"",ianaTimeZoneId:s,timeZoneName:s,offset:""}},[t.timeZone]),loading:!1}}function Cl(t){const e=(t.status||"").toLowerCase()==="completed"?i.jsx("img",{src:Ol,alt:"completed",style:{width:20,height:20}}):i.jsx("img",{src:jl,alt:"pending",style:{width:20,height:20}});return{title:i.jsxs("div",{className:"flex flex-col gap-0 min-w-0",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{className:"block text-sm break-words mb-1 overflow-visible whitespace-normal",children:i.jsx("b",{children:t.title})}),t.description?i.jsx("span",{className:"text-gray-500 text-xs",children:t.description}):null]}),t.timestamp?i.jsx("span",{className:"text-gray-500 text-xs",children:t.timestamp}):null]}),icon:e,description:null}}function Dl({data:t}){const{timeZoneDetails:e}=vs();return console.log("summary",t),i.jsx("div",{className:"w-full",children:i.jsx(f.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:i.jsxs("div",{className:"w-full",style:{maxHeight:"50vh",overflowY:"auto"},children:[i.jsx(f.Card,{className:"mb-4 rounded-md p-4",bordered:!0,children:i.jsxs("div",{className:"grid grid-cols-4 gap-6 text-xs",children:[i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Alert ID"}),i.jsx("span",{className:"text-black",children:t.summary.alertNumber})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Severity"}),i.jsx("span",{className:"text-black",children:t.summary.severity})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Location"}),i.jsx("span",{className:"text-black",children:t.summary.location})]})]})}),i.jsxs(f.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsx("h4",{className:"text-sm text-black font-medium",children:"Response Timeline/ Audit trail/log"})}),i.jsx("div",{className:"mt-2",children:i.jsx(f.Steps,{direction:"vertical",size:"small",current:1,items:(t.timeline||[]).map(Cl)})})]})]})},{key:"notification",label:"Notification Sent",children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",style:{maxHeight:"50vh",overflowY:"auto"},children:[(t.notifications||[]).map((s,n)=>i.jsxs(f.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("h4",{className:"text-sm text-black font-medium",children:s.channelLabel}),i.jsx("span",{className:"text-xs text-gray-500 mt-1",children:ms(s.sentAt,e?.ianaTimeZoneId)})]}),i.jsxs("span",{className:"text-[11px] px-2 py-1 rounded-full bg-green-50 text-green-700 border border-green-200",children:[s.delivered,"/",s.total," Delivered"]})]}),i.jsxs("div",{className:"mt-4 text-xs",children:[i.jsxs("div",{className:"text-black",children:[" ",s.messageTitle]}),s.messageBody?i.jsx("div",{className:"text-gray-600",children:s.messageBody}):null]}),i.jsxs("div",{className:"mt-4",children:[i.jsxs("div",{className:"text-xs text-black font-medium",children:["Recipients (",s.total,")"]}),i.jsx("div",{className:"mt-2 flex flex-col gap-3 text-xs",children:(s.recipients||[]).map((r,a)=>{const o=String(r?.notificationReceipientType||"").toLowerCase()==="EscalationNotification".toLowerCase();return i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsxs("span",{className:"text-black",children:[r.name," - ",i.jsx("span",{style:{color:o?"#FF3B30":"#FFB86A"},children:o?"Escalation Notification":"Alert Notification"})]}),i.jsxs("span",{className:"text-gray-500",children:[r.role," . ",r.phone]})]}),i.jsx("span",{className:`text-[11px] px-3 py-[2px] rounded ${r.status==="Delivered"?"bg-green-50 text-green-700 border border-green-200":"bg-red-50 text-red-700 border border-red-200"}`,children:r.status})]},a)})})]})]},n)),t?.notifications?.length?null:i.jsx("span",{className:"text-gray-500 text-xs",children:"No notifications."})]})}]})})}const Rl=({alertId:t,id:e,priority:s,spaceName:n,alertNumber:r,statusHistory:a,notifGroups:o})=>{const c={alertId:t??String(e??""),incidentId:"-",severity:s||"",location:n||"",alertNumber:r??""},{timeZoneDetails:l}=vs(),u=a?.length?a.map(h=>{const S=(h?.status||h?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",g=h?.createdDate?ms(h.createdDate,l?.ianaTimeZoneId):h?.timestamp?ms(h.timestamp,l?.ianaTimeZoneId):"";return{status:S,title:h?.status||h?.eventStatus||"Status Update",description:h?.description||h?.actionNotes||"",timestamp:g}}):[],m={summary:c,timeline:u,notifications:o??[]};return i.jsx(Dl,{data:m})},Ul={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Ll={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Fl={"elopement attempt":"elopement","elopement completed":"elopement","watchlist person detected":"watchlist","watch list person detected":"watchlist","brandished guns & knives":"weapon","brandished guns and knives":"weapon"},$l=({isModalOpen:t,handleModalClose:e,selectedRow:s,fetchAlertLogs:n,alertStatusList:r=[],alertStatusLoading:a=!1,initialTab:o="details",sourceTab:c})=>{const[l,u]=d.useState(),[m,h]=d.useState(""),[S,g]=d.useState(!1),b=d.useRef(null),[j,C]=d.useState("details"),[G,F]=d.useState(void 0),$=Ks(),{alerts:T,rules:M,config:V}=Ee(),{timeZoneDetails:D}=vs(),[q,p]=d.useState(null),[x,O]=d.useState(!1),[le,ae]=d.useState(!1),[U,w]=d.useState(void 0),[v,I]=d.useState(void 0),[A,R]=d.useState({}),[P,Y]=d.useState({}),J=(y,E,k)=>{const H=P[y];return A[y]===!1&&!H?i.jsxs("div",{className:"w-full flex flex-col items-center justify-center min-h-[200px] bg-gray-100 rounded-lg gap-2 text-gray-400",children:[i.jsx(ar,{size:40}),i.jsx("span",{className:"text-sm",children:"Media not available"})]}):i.jsxs("div",{className:"relative w-full flex justify-center items-center min-h-[200px]",children:[H&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg z-10",children:i.jsx(fi,{size:32,className:"animate-spin text-gray-400"})}),i.jsx("img",{src:y,alt:E.caption||`media-${k}`,className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg transition-opacity duration-200 ${H?"opacity-0":"opacity-100"}`,onLoad:()=>Y(be=>({...be,[y]:!1})),onError:()=>Y(be=>({...be,[y]:!1}))},y)]})},Q=s?.originalData||{},{eventName:se,eventDisplayName:X,anomalyName:ye,alertId:ie,timestamp:me,description:Se,spaceName:oe,assignTeam:ce,priority:xe,statusType:Ue,id:Le,alertDetails:tt,statusHistory:st,mediaDetails:vt,alertNumber:lt}=Q,wt=V.tenant==="snl"?X||se||"Alert Event":se||"Alert Event",Dt=y=>{const E=String(y||"").toLowerCase();return E==="delivered"||E==="sent"?"Delivered":E==="failed"?"Failed":"Queued"},ee=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||""}),z=(y,E)=>{const k=E.map(ee),H=k.filter(Je=>Je.status==="Delivered").length,be=E.map(Je=>Je?.sentAt).filter(Boolean).sort((Je,_e)=>new Date(_e).getTime()-new Date(Je).getTime())[0],ze=(E[0]||{})?.severityName||`${y} Notification`;return{channelLabel:`${y} Notification`,sentAt:be||"",messageTitle:ze,messageBody:"",total:k.length,delivered:H,recipients:k}},pe=y=>{const E=new Map;return(y||[]).forEach(k=>{const H=String(k?.notificationType||"Unknown"),be=E.get(H)||[];be.push(k),E.set(H,be)}),Array.from(E.entries()).map(([k,H])=>z(k,H))},ne=async y=>{try{const E=await T.getAlertNotifications(y),k=pe(E);F(k)}catch{F(void 0)}};d.useEffect(()=>{if(j!=="track"||!Le)return;let y=!1;return ne(Le).then(()=>{y&&F(void 0)}),()=>{y=!0}},[j,Le]),d.useEffect(()=>{t?C(o):(u(void 0),h(""))},[t,o]),d.useEffect(()=>{if(!t||V.tenant!=="snl")return;let y=!1;return O(!0),M.getLookups().then(E=>{y||(p(E.alertStatusTypes??[]),O(!1))}).catch(()=>{y||(p([]),O(!1))}),()=>{y=!0}},[t,V.tenant]);const je=c==="archived"||["completed","false positive"].includes(String(Ue||"").toLowerCase()),Ze=y=>{const E=String(y?.value||"").toLowerCase(),k=String(y?.statusName||"").toLowerCase();return E.includes("reopen")||k.includes("reopen")},Fe=String(ye||"").trim().toLowerCase(),ve=Fl[Fe]??"general",ct=r.filter(y=>{const E=Ze(y);return typeof c<"u"?c==="archived"?E:!E:je?E:!E}).map(y=>({value:y.value,label:y.statusName})),ut=q??[],dt=y=>!!y.isWatchListStatus,mt=y=>!!y.isWeapontStatus,ft=ut.filter(y=>{switch(ve){case"elopement":return y.isElopementStatus;case"watchlist":return dt(y);case"weapon":return mt(y);default:return!y.isElopementStatus&&!dt(y)&&!mt(y)}}).map(y=>({value:y.alertStatusTypeName,label:y.alertStatusTypeName})),L=V.tenant==="snl"&&q!==null?ft:ct,_=d.useMemo(()=>nr(vt),[vt]);d.useEffect(()=>{let y=!1;const E=new AbortController,k=async ue=>{if(ue){y||R(ze=>({...ze,[ue]:!1}));try{const ze=await fetch(ue,{method:"HEAD",signal:E.signal});if(ze.ok){y||R(_e=>({..._e,[ue]:!0}));return}if(ze.status===404){y||R(_e=>({..._e,[ue]:!1}));return}if(!(await fetch(ue,{method:"GET",signal:E.signal})).ok)throw new Error("Media not available");y||R(_e=>({..._e,[ue]:!0}))}catch{y||R(ze=>({...ze,[ue]:!1}))}}};R({});const H=_.filter(ue=>!Us(ue)).map(ue=>ue?.mediaUrl||ue).filter(ue=>typeof ue=="string"&&ue.length>0),be={};return H.forEach(ue=>{be[ue]=!0}),Y(be),H.forEach(ue=>k(ue)),()=>{y=!0,E.abort()}},[_]);const W=async()=>{try{g(!0);const y={alertUniqueId:ie,alertId:Le,status:l?String(l):void 0,notes:m.trim(),modifiedBy:0},E=await $.mutateAsync(y);if(E?.responseStatus||E?.Success){const k=E?.Message||E?.data||"Alert updated successfully.";we.toast.success(k,{autoClose:1500,onClose:()=>{n(),e()}}),u(void 0),h("")}else{const k=E?.errorMessage||E?.Message||"Failed to update alert status";we.toast.error(k)}}catch(y){console.error("Error updating alert status:",y),we.toast.error("Failed to update alert status. Please try again.")}finally{g(!1)}};return i.jsx(f.Modal,{open:t,onCancel:e,width:1e3,footer:j==="details"?i.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[i.jsx(f.Button,{onClick:e,className:"!bg-[#6C757D] !text-white !border-[#6C757D] hover:!bg-[#5c636a] hover:!text-white hover:!border-[#5c636a]",children:"Cancel"}),i.jsx(f.Button,{type:"primary",onClick:W,loading:S,children:S?"Saving...":"Save Changes"})]}):null,children:s&&i.jsx(f.Tabs,{activeKey:j,onChange:y=>C(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:wt}),tt?.firstName?i.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",tt?.firstName," ",tt?.lastName||"","   ",tt?.residentId||""]}):null,i.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp: ",ms(me,D?.ianaTimeZoneId)]}),i.jsxs("div",{className:"font-sm text-gray-500",children:[i.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",Se||"No description available"]}),oe&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",oe]}),ce&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",ce]}),i.jsxs("div",{className:"flex gap-2 justify-start mt-3",children:[i.jsxs(f.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${Ul[String(xe)]||"#DFE4EA"}`,backgroundColor:Ll[String(xe)]},children:["Severity: ",xe||"N/A"]}),i.jsxs(f.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(Ue||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",Ue||"N/A"]})]}),i.jsx("div",{className:"w-full flex flex-col justify-start items-start mt-2 font-bold",children:i.jsxs("div",{className:"w-full mt-4",children:[i.jsx("div",{className:"flex flex-col gap-2",children:i.jsx(f.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:y=>u(y),value:l,options:L,loading:V.tenant==="snl"?x: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=>h(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"}),_.length>1?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>b.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(gt.LeftOutlined,{style:{fontSize:12}})}),i.jsx("button",{type:"button",onClick:()=>b.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(gt.RightOutlined,{style:{fontSize:12}})})]}):null]}),_.length?i.jsx("div",{className:"w-full",children:i.jsx(f.Carousel,{ref:b,dots:!0,className:"w-full",children:_.map((y,E)=>{const k=y.mediaUrl||y,H=Us(y);return i.jsxs("div",{className:"flex justify-center items-center relative",children:[H?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:k}),"Your browser does not support the video tag."]}):J(String(k),y,E),y.caption&&i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:y.caption}),!H&&A[String(k)]?i.jsx("button",{onClick:()=>{ae(!0),w(k),I(y.type||"image")},className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:i.jsx(ir,{size:20})}):null]},String(k)||E)})})}):null]})}),i.jsx(or,{isOpen:le,onClose:()=>ae(!1),src:U||"",type:v||"image"})]})},{key:"track",label:"Track Incident",children:i.jsx(Rl,{alertId:ie,id:Le,priority:xe,spaceName:oe,alertNumber:lt,statusHistory:st,notifGroups:G})}]})})};function pa(){const{alerts:t}=Ee(),e=St.useQuery({queryKey:["alerts","statusList"],queryFn:()=>t.getAlertStatusList(),staleTime:5*6e4});return{list:e.data??[],loading:e.isLoading,error:e.error,refetch:e.refetch}}function on({alerts:t,loading:e=!1,columns:s,total:n,currentPage:r,onRefetch:a,onPageChange:o,onFilterChange:c}){const[l,u]=d.useState(!1),[m,h]=d.useState(null),[S,g]=d.useState("details"),{list:b,loading:j}=pa(),{config:C}=Ee(),G=C.tenant==="schools",{timeZoneDetails:F}=vs(),$=F?.timeZoneName??"UTC",T=F?.ianaTimeZoneId??"UTC";function M(le,ae){h(le),g(ae?.tab??"details"),q(ae?.sourceTab??"active"),u(!0)}function V(){u(!1)}const[D,q]=d.useState("active"),[p,x]=d.useState(0),O=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(ma,{label:$,timeZone:T})})]}),i.jsx(f.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:le=>{const ae=le==="archived";x(U=>U+1),o?.(1),c?.({isArchived:ae})},items:[{key:"active",label:"Active",children:i.jsx(Js,{data:t,loading:e,pageSize:10,total:n,currentPage:r,columns:s||[],onAlertIdClick:M,onRefetch:a,onPageChange:o,onFilterChange:c,resetKey:p,serverSideFilters:G})},{key:"archived",label:"Archived",children:i.jsx(da,{alerts:t,loading:e,columns:s||[],total:n,currentPage:r,onAlertIdClick:M,onFilterChange:c,onPageChange:o,onRefetch:a,resetKey:p,serverSideFilters:G})},{key:"settings",label:"Settings",children:i.jsx(Pl,{})}]}),i.jsx($l,{isModalOpen:l,handleModalClose:V,selectedRow:O,fetchAlertLogs:()=>{},alertStatusList:b,alertStatusLoading:j,initialTab:S,sourceTab:D})]})}function Pl(){const[t,e]=d.useState([]),[s,n]=d.useState([]),[r,a]=d.useState([]),[o,c]=d.useState([]),[l,u]=d.useState(!0),{rules:m}=Ee();return d.useEffect(()=>{let h=!0;return(async()=>{try{const S=await m.getRules();if(!h)return;c(Array.isArray(S)?S:[]);const g=(S||[]).map((b,j)=>({RuleId:b.ruleId||b.ruleName||String(j),Name:b.ruleName||b.Name||"-",Description:b.ruleDesc||b.Description||"",SeverityId:0}));e(g);try{const b=await m.getLookups(),j=Array.isArray(b?.userRoles)?b.userRoles.map(C=>({userRoleId:C.userRoleId??C.id,userRoleName:C.userRoleName??C.name})):[];n(j),a(Array.isArray(b?.severities)?b.severities:[])}catch{}}catch{}finally{h&&u(!1)}})(),()=>{h=!1}},[]),i.jsx(ya,{severities:r,rules:t,userRoles:s,rawRules:o,loadingRules:l})}function Wl(t){return Array.isArray(t)?{items:t}:t}function ga(t=1,e){const{alerts:s,config:n}=Ee(),r=n.tenant==="schools"&&!!String(e?.searchText??"").trim(),a=St.useQuery({queryKey:["alerts","list",n.tenant,t,e],queryFn:()=>{const o={...e};return n.tenant==="transit"?(o.pageNumber=t,o.pageSize=10):n.tenant==="schools"&&(o.pageNumber=t,o.pageSize=r?100:10),s.listAlerts(o).then(Wl)},staleTime:r?0:3e4});return{alerts:a.data?.items??[],total:a.data?.total,loading:a.isLoading,error:a.error,refetch:a.refetch}}function Vl(t){const[e,s]=d.useState(1),[n,r]=d.useState({}),{alerts:a,total:o,loading:c,refetch:l}=ga(e,n),u=m=>{"isArchived"in m?r({isArchived:m.isArchived}):r(h=>({...h,...m}))};return i.jsx(on,{alerts:a,loading:c,columns:t.columns,total:o,currentPage:e,onRefetch:l,onPageChange:s,onFilterChange:u})}function Bl({tenant:t,apiDomain:e,rulesDomain:s,headers:n,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,alerts:c,loading:l,columns:u}){const[m]=d.useState(()=>new St.QueryClient),h=d.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return i.jsx(St.QueryClientProvider,{client:m,children:i.jsx(er,{tenant:t,override:h,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,children:Array.isArray(c)?i.jsx(on,{alerts:c,loading:!!l,columns:u}):i.jsx(Vl,{columns:u})})})}function Zl(t){const{alerts:e}=Ee(),s=St.useQuery({queryKey:["alerts","report",t],queryFn:()=>e.getAlertsReport(t),staleTime:6e4});return{data:s.data??[],loading:s.isLoading,error:s.error,refetch:s.refetch}}const zl=[{title:"ID",dataIndex:"id",key:"id",width:120},{title:"Priority",dataIndex:"priority",key:"priority",width:120},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:220},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description"}];exports.AlertAssignment=fa;exports.AlertConsole=on;exports.AlertConsoleWidget=Bl;exports.AlertsTable=Js;exports.ApiProvider=er;exports.ArchivedTable=da;exports.Clock=ma;exports.DataTable=sr;exports.MyPreferencesPanel=Ml;exports.SettingsPanel=ha;exports.SettingsTabs=ya;exports.exampleAlertColumns=zl;exports.useAlertStatusList=pa;exports.useAlerts=ga;exports.useAlertsReport=Zl;exports.useApi=Ee;exports.useUpdateAlertStatus=Ks;
2
2
  //# sourceMappingURL=index.cjs.map