@e-llm-studio/federated-dashboard-components 2.2.5 → 2.2.6-test

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.
Files changed (29) hide show
  1. package/dist/ExecutiveDashboard/api/alertsapi.js +1 -1
  2. package/dist/ExecutiveDashboard/components/Alerts/AlertsViewTrigger.js +1 -1
  3. package/dist/ExecutiveDashboard/components/Alerts/CreateAlertModal.js +1 -1
  4. package/dist/ExecutiveDashboard/components/DropDowns/CustomSingleSelect.js +1 -1
  5. package/dist/ExecutiveDashboard/components/Table/FTable.js +1 -1
  6. package/dist/ExecutiveDashboard/components/common/ChipSelector/ChipSelector.js +2 -0
  7. package/dist/ExecutiveDashboard/components/common/ChipSelector/ChipSelector.js.map +1 -0
  8. package/dist/cjs/ExecutiveDashboard/api/alertsapi.js +1 -1
  9. package/dist/cjs/ExecutiveDashboard/components/Alerts/AlertsViewTrigger.js +1 -1
  10. package/dist/cjs/ExecutiveDashboard/components/Alerts/CreateAlertModal.js +1 -1
  11. package/dist/cjs/ExecutiveDashboard/components/DropDowns/CustomSingleSelect.js +1 -1
  12. package/dist/cjs/ExecutiveDashboard/components/Table/FTable.js +1 -1
  13. package/dist/cjs/ExecutiveDashboard/components/common/ChipSelector/ChipSelector.js +2 -0
  14. package/dist/cjs/ExecutiveDashboard/components/common/ChipSelector/ChipSelector.js.map +1 -0
  15. package/dist/cjs/styles.css +1 -1
  16. package/dist/styles.css +1 -1
  17. package/dist/types/ExecutiveDashboard/api/alertsapi.d.ts +1 -0
  18. package/dist/types/ExecutiveDashboard/api/alertsapi.d.ts.map +1 -1
  19. package/dist/types/ExecutiveDashboard/components/Alerts/AlertsViewTrigger.d.ts.map +1 -1
  20. package/dist/types/ExecutiveDashboard/components/Alerts/CreateAlertModal.d.ts +3 -0
  21. package/dist/types/ExecutiveDashboard/components/Alerts/CreateAlertModal.d.ts.map +1 -1
  22. package/dist/types/ExecutiveDashboard/components/Alerts/alerts.types.d.ts +19 -0
  23. package/dist/types/ExecutiveDashboard/components/Alerts/alerts.types.d.ts.map +1 -0
  24. package/dist/types/ExecutiveDashboard/components/DropDowns/CustomSingleSelect.d.ts +4 -1
  25. package/dist/types/ExecutiveDashboard/components/DropDowns/CustomSingleSelect.d.ts.map +1 -1
  26. package/dist/types/ExecutiveDashboard/components/Table/FTable.d.ts.map +1 -1
  27. package/dist/types/ExecutiveDashboard/components/common/ChipSelector/ChipSelector.d.ts +32 -0
  28. package/dist/types/ExecutiveDashboard/components/common/ChipSelector/ChipSelector.d.ts.map +1 -0
  29. package/package.json +2 -2
@@ -1,2 +1,2 @@
1
- import{__awaiter as t,__generator as e,__assign as n}from"../../_virtual/_tslib.js";import{DashboardApiError as r}from"./dashboardApi.js";var s=function(t){try{return t.replace(/\/+$/,"")}catch(e){return t}};function i(n,s,i,o){var a,c;return t(this,void 0,void 0,function(){var t,u;return e(this,function(e){switch(e.label){case 0:if(!i)throw new r("Access token is required.");return[4,fetch(n,{method:"POST",headers:{accept:"application/json","Content-Type":"application/json",Authorization:"Bearer ".concat(i)},body:JSON.stringify(s),signal:o})];case 1:if(!(t=e.sent()).ok)throw new r("Request failed with status ".concat(t.status),t.status);return[4,t.json()];case 2:if(!1===(u=e.sent()).success)throw new r((null===(a=u.error)||void 0===a?void 0:a.errorMessage)||"Request failed");return[2,null!==(c=u.data)&&void 0!==c?c:u]}})})}function o(n,s,i,o){var a,c;return t(this,void 0,void 0,function(){var t,u;return e(this,function(e){switch(e.label){case 0:if(!s)throw new r("Access token is required.");return[4,fetch(n,{method:"GET",headers:{accept:"application/json",Authorization:"Bearer ".concat(s)},credentials:o?"include":void 0,signal:i})];case 1:if(!(t=e.sent()).ok)throw new r("Request failed with status ".concat(t.status),t.status);return[4,t.json()];case 2:if(!1===(u=e.sent()).success)throw new r((null===(a=u.error)||void 0===a?void 0:a.errorMessage)||"Request failed");return[2,null!==(c=u.data)&&void 0!==c?c:u]}})})}function a(n,s,i,o){var a,c;return t(this,void 0,void 0,function(){var t,u;return e(this,function(e){switch(e.label){case 0:if(!i)throw new r("Access token is required.");return[4,fetch(n,{method:"PUT",headers:{accept:"application/json","Content-Type":"application/json",Authorization:"Bearer ".concat(i)},body:JSON.stringify(s),signal:o})];case 1:if(!(t=e.sent()).ok)throw new r("Request failed with status ".concat(t.status),t.status);return[4,t.json()];case 2:if(!1===(u=e.sent()).success)throw new r((null===(a=u.error)||void 0===a?void 0:a.errorMessage)||"Request failed");return[2,null!==(c=u.data)&&void 0!==c?c:u]}})})}function c(n,s,i){var o,a;return t(this,void 0,void 0,function(){var t,c;return e(this,function(e){switch(e.label){case 0:if(!s)throw new r("Access token is required.");return[4,fetch(n,{method:"DELETE",headers:{accept:"application/json",Authorization:"Bearer ".concat(s)},signal:i})];case 1:if(!(t=e.sent()).ok)throw new r("Request failed with status ".concat(t.status),t.status);return[4,t.json()];case 2:if(!1===(c=e.sent()).success)throw new r((null===(o=c.error)||void 0===o?void 0:o.errorMessage)||"Request failed");return[2,null!==(a=c.data)&&void 0!==a?a:c]}})})}function u(n,r){var i=n.baseUrl,a=void 0===i?"":i,c=n.configId,u=n.accessToken;return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,o("".concat(s(a),"/federated/alerts/").concat(c,"/rules"),u,r)];case 1:return[2,t.sent()]}})})}function d(r,o,a){var c=r.baseUrl,u=void 0===c?"":c,d=r.configId,l=r.accessToken;return t(this,void 0,void 0,function(){var t;return e(this,function(e){switch(e.label){case 0:return t=n(n({},o),{config_id:d}),[4,i("".concat(s(u),"/federated/alerts/").concat(d,"/rules"),t,l,a)];case 1:return[2,e.sent()]}})})}function l(n,r,i,o){var c=n.baseUrl,u=void 0===c?"":c,d=n.configId,l=n.accessToken;return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,a("".concat(s(u),"/federated/alerts/").concat(d,"/rules/").concat(r),{payload:i},l,o)];case 1:return[2,t.sent()]}})})}function f(n,r,i){var o=n.baseUrl,a=void 0===o?"":o,u=n.configId,d=n.accessToken;return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,c("".concat(s(a),"/federated/alerts/").concat(u,"/rules/").concat(r),d,i)];case 1:return[2,t.sent()]}})})}function h(n,r){var i=n.baseUrl,a=void 0===i?"":i,c=n.configId,u=n.accessToken;return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,o("".concat(s(a),"/federated/alerts/").concat(c,"/history/sources"),u,r)];case 1:return[2,t.sent()]}})})}function v(n,r){var i=n.baseUrl,a=void 0===i?"":i,c=n.configId,u=n.accessToken;return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,o("".concat(s(a),"/federated/alerts/").concat(c,"/history"),u,r)];case 1:return[2,t.sent()]}})})}function w(n,i,a){var c=n.authBaseUrl,u=void 0===c?"":c,d=n.accessToken,l=void 0===d?"":d;return t(this,void 0,void 0,function(){var t,n;return e(this,function(e){switch(e.label){case 0:if(!u)throw new r("authBaseUrl is required.");return t=new URLSearchParams,i&&Object.entries(i).forEach(function(e){var n=e[0],r=e[1];null!=r&&""!==r&&t.append(n,String(r))}),n=t.toString(),[4,o("".concat(s(u),"/api/user/get-by-query-v2").concat(n?"?"+n:""),l,a,!0)];case 1:return[2,e.sent()]}})})}export{d as createAlert,f as deleteAlert,v as fetchAlertHistory,u as fetchAlerts,h as fetchDistinctSources,w as getAllUsers,l as updateAlert};
1
+ import{__awaiter as t,__generator as e,__assign as n}from"../../_virtual/_tslib.js";import{DashboardApiError as r}from"./dashboardApi.js";var s=function(t){try{return t.replace(/\/+$/,"")}catch(e){return t}};function i(n,s,i,o){var a,c;return t(this,void 0,void 0,function(){var t,u;return e(this,function(e){switch(e.label){case 0:if(!i)throw new r("Access token is required.");return[4,fetch(n,{method:"POST",headers:{accept:"application/json","Content-Type":"application/json",Authorization:"Bearer ".concat(i)},body:JSON.stringify(s),signal:o})];case 1:if(!(t=e.sent()).ok)throw new r("Request failed with status ".concat(t.status),t.status);return[4,t.json()];case 2:if(!1===(u=e.sent()).success)throw new r((null===(a=u.error)||void 0===a?void 0:a.errorMessage)||"Request failed");return[2,null!==(c=u.data)&&void 0!==c?c:u]}})})}function o(n,s,i,o){var a,c;return t(this,void 0,void 0,function(){var t,u;return e(this,function(e){switch(e.label){case 0:if(!s)throw new r("Access token is required.");return[4,fetch(n,{method:"GET",headers:{accept:"application/json",Authorization:"Bearer ".concat(s)},credentials:o?"include":void 0,signal:i})];case 1:if(!(t=e.sent()).ok)throw new r("Request failed with status ".concat(t.status),t.status);return[4,t.json()];case 2:if(!1===(u=e.sent()).success)throw new r((null===(a=u.error)||void 0===a?void 0:a.errorMessage)||"Request failed");return[2,null!==(c=u.data)&&void 0!==c?c:u]}})})}function a(n,s,i,o){var a,c;return t(this,void 0,void 0,function(){var t,u;return e(this,function(e){switch(e.label){case 0:if(!i)throw new r("Access token is required.");return[4,fetch(n,{method:"PUT",headers:{accept:"application/json","Content-Type":"application/json",Authorization:"Bearer ".concat(i)},body:JSON.stringify(s),signal:o})];case 1:if(!(t=e.sent()).ok)throw new r("Request failed with status ".concat(t.status),t.status);return[4,t.json()];case 2:if(!1===(u=e.sent()).success)throw new r((null===(a=u.error)||void 0===a?void 0:a.errorMessage)||"Request failed");return[2,null!==(c=u.data)&&void 0!==c?c:u]}})})}function c(n,s,i){var o,a;return t(this,void 0,void 0,function(){var t,c;return e(this,function(e){switch(e.label){case 0:if(!s)throw new r("Access token is required.");return[4,fetch(n,{method:"DELETE",headers:{accept:"application/json",Authorization:"Bearer ".concat(s)},signal:i})];case 1:if(!(t=e.sent()).ok)throw new r("Request failed with status ".concat(t.status),t.status);return[4,t.json()];case 2:if(!1===(c=e.sent()).success)throw new r((null===(o=c.error)||void 0===o?void 0:o.errorMessage)||"Request failed");return[2,null!==(a=c.data)&&void 0!==a?a:c]}})})}function u(n,r){var i=n.baseUrl,a=void 0===i?"":i,c=n.configId,u=n.accessToken;return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,o("".concat(s(a),"/federated/alerts/").concat(c,"/plots"),u,r)];case 1:return[2,t.sent()]}})})}function d(n,r){var i=n.baseUrl,a=void 0===i?"":i,c=n.configId,u=n.accessToken;return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,o("".concat(s(a),"/federated/alerts/").concat(c,"/rules"),u,r)];case 1:return[2,t.sent()]}})})}function l(r,o,a){var c=r.baseUrl,u=void 0===c?"":c,d=r.configId,l=r.accessToken;return t(this,void 0,void 0,function(){var t;return e(this,function(e){switch(e.label){case 0:return t=n(n({},o),{config_id:d}),[4,i("".concat(s(u),"/federated/alerts/").concat(d,"/rules"),t,l,a)];case 1:return[2,e.sent()]}})})}function f(n,r,i,o){var c=n.baseUrl,u=void 0===c?"":c,d=n.configId,l=n.accessToken;return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,a("".concat(s(u),"/federated/alerts/").concat(d,"/rules/").concat(r),{payload:i},l,o)];case 1:return[2,t.sent()]}})})}function h(n,r,i){var o=n.baseUrl,a=void 0===o?"":o,u=n.configId,d=n.accessToken;return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,c("".concat(s(a),"/federated/alerts/").concat(u,"/rules/").concat(r),d,i)];case 1:return[2,t.sent()]}})})}function v(n,r){var i=n.baseUrl,a=void 0===i?"":i,c=n.configId,u=n.accessToken;return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,o("".concat(s(a),"/federated/alerts/").concat(c,"/history/sources"),u,r)];case 1:return[2,t.sent()]}})})}function w(n,r){var i=n.baseUrl,a=void 0===i?"":i,c=n.configId,u=n.accessToken;return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,o("".concat(s(a),"/federated/alerts/").concat(c,"/history"),u,r)];case 1:return[2,t.sent()]}})})}function p(n,i,a){var c=n.authBaseUrl,u=void 0===c?"":c,d=n.accessToken,l=void 0===d?"":d;return t(this,void 0,void 0,function(){var t,n;return e(this,function(e){switch(e.label){case 0:if(!u)throw new r("authBaseUrl is required.");return t=new URLSearchParams,i&&Object.entries(i).forEach(function(e){var n=e[0],r=e[1];null!=r&&""!==r&&t.append(n,String(r))}),n=t.toString(),[4,o("".concat(s(u),"/api/user/get-by-query-v2").concat(n?"?"+n:""),l,a,!0)];case 1:return[2,e.sent()]}})})}export{l as createAlert,h as deleteAlert,w as fetchAlertHistory,d as fetchAlerts,v as fetchDistinctSources,u as fetchPlotAndKPIs,p as getAllUsers,f as updateAlert};
2
2
  //# sourceMappingURL=alertsapi.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__spreadArray as r,__awaiter as t,__generator as n}from"../../../_virtual/_tslib.js";import{jsx as i,jsxs as o,Fragment as l}from"react/jsx-runtime";import{Toast as a}from"primereact/toast";import s from"../common/ConfirmationModal.js";import{ChevronRight as c,Pencil as u,MoreVertical as d,Loader2 as p,Play as f,Pause as y,Trash2 as h}from"lucide-react";import v from"../TablePage/TablePage.js";import g from"../FiltersSidebar/FiltersSidebar.js";import{useState as m,useRef as b,useEffect as x,useMemo as S,useCallback as w}from"react";import{createPortal as C}from"react-dom";import A from"./CreateAlertModal.js";import{fetchAlertHistory as k,deleteAlert as F,updateAlert as E,fetchAlerts as T,fetchDistinctSources as z,getAllUsers as P,createAlert as D}from"../../api/alertsapi.js";var I=function(I){var L=I.baseUrl,N=I.authBaseUrl,U=I.configId,R=I.onClose,_=I.uiConfig,j=I.accessToken,B=m(""),O=B[0],W=B[1],V=m([]),q=V[0],K=V[1],H=m(!1),M=H[0],G=H[1],X=m([]),Y=X[0],J=X[1],Q=m(!1),Z=Q[0],$=Q[1],ee=m({}),re=ee[0],te=ee[1],ne=m({}),ie=ne[0],oe=ne[1],le=m(null),ae=le[0],se=le[1],ce=m(!1),ue=ce[0],de=ce[1],pe=m(null),fe=pe[0],ye=pe[1],he=m(null),ve=he[0],ge=he[1],me=b({}),be=m({}),xe=be[0],Se=be[1],we=m(null),Ce=we[0],Ae=we[1],ke=m(!1),Fe=ke[0],Ee=ke[1],Te=m(""),ze=Te[0],Pe=Te[1],De=m([]),Ie=De[0],Le=De[1],Ne=m(!1),Ue=Ne[0],Re=Ne[1],_e=m(!1),je=_e[0],Be=_e[1],Oe=m({}),We=Oe[0],Ve=Oe[1],qe=m({}),Ke=qe[0],He=qe[1],Me=m("history"),Ge=Me[0],Xe=Me[1],Ye=b(null),Je=b(null),Qe=b(null),Ze=b(null);function $e(e){var r=new Date(e);return isNaN(r.getTime())?e:r.toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})}x(function(){Z&&oe(re)},[Z,re]),x(function(){je&&He(We)},[je,We]);var er=function(){return t(void 0,void 0,void 0,function(){var e,r,t,i;return n(this,function(n){switch(n.label){case 0:G(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,T({baseUrl:L,configId:U||"",accessToken:j})];case 2:return e=n.sent(),r=e,K(Array.isArray(r)?r:[]),[3,5];case 3:return t=n.sent(),console.error("Failed to fetch alerts:",t),null===(i=Ye.current)||void 0===i||i.show({severity:"error",summary:"Error",detail:"Failed to load alerts. Please refresh.",life:3e3}),K([]),[3,5];case 4:return G(!1),[7];case 5:return[2]}})})};x(function(){er()},[]),x(function(){t(void 0,void 0,void 0,function(){var e,r,t,i;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,z({baseUrl:L,configId:U||"",accessToken:j})];case 1:return e=n.sent(),r=e,J(Array.isArray(r)?r:[]),[3,3];case 2:return t=n.sent(),console.error("Failed to fetch distinct sources:",t),null===(i=Ye.current)||void 0===i||i.show({severity:"error",summary:"Error",detail:"Failed to load data sources.",life:3e3}),[3,3];case 3:return[2]}})})},[]),x(function(){var e=!0;return"history"===Ge?(Re(!0),k({baseUrl:L,configId:U||"",accessToken:j}).then(function(r){e&&Le(r||[])}).catch(function(r){var t;console.error("Error fetching history:",r),null===(t=Ye.current)||void 0===t||t.show({severity:"error",summary:"Error",detail:"Failed to load alert history.",life:3e3}),e&&Le([])}).finally(function(){e&&Re(!1)})):Le([]),function(){e=!1}},[Ge]);var rr=(Array.isArray(q)?q:[]).map(function(e){var r,t,n,i=e.kpiType?e.kpiType.charAt(0).toUpperCase()+e.kpiType.slice(1):"—",o=e.status?e.status.charAt(0).toUpperCase()+e.status.slice(1):"—",l=(null===(t=null===(r=e.recipients)||void 0===r?void 0:r.userEmails)||void 0===t?void 0:t.map(function(r,t){var n;return{name:r,email:r,value:r,label:r,userId:(null===(n=e.recipients.userIds)||void 0===n?void 0:n[t])||void 0}}))||[],a={">":"Greater than","<":"Less than",">=":"Greater than or equal to","<=":"Less than or equal to"}[e.conditionType]||e.conditionType||"",s=a?"".concat(a," ").concat(e.thresholdValue):"".concat(e.thresholdValue);return{id:e.id,alertName:e.name,type:i,status:o,subscribers:l,raw:e,kpi:(n=e.kpiKey,n?n.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join(" "):"—"),threshold:s,severity:e.severity,createdOn:e.createdAt?$e(e.createdAt):"—",rawScope:e.entityType,triggerConfig:{"Evaluation Type":e.evaluationType,"Evaluation period":e.evaluationPeriod,"Trigger After":e.triggerAfter?"".concat(e.triggerAfter," data points"):void 0}}}),tr=S(function(){return rr.filter(function(e){var r,t,n=!re.severity||(null===(r=e.severity)||void 0===r?void 0:r.toLowerCase())===re.severity.toLowerCase(),i=!re.status||(null===(t=e.status)||void 0===t?void 0:t.toLowerCase())===re.status.toLowerCase();return n&&i})},[re,rr]),nr=S(function(){var e=0,r=!1;return Object.entries(We).forEach(function(t){var n=t[0],i=t[1];null===i||""===i||Array.isArray(i)&&0===i.length||("dateFrom"===n||"dateTo"===n?r=!0:e+=Array.isArray(i)?i.length:1)}),r&&(e+=1),e},[We]),ir=Object.values(re).reduce(function(e,r){return e+(Array.isArray(r)?r.length:r&&""!==r?1:0)},0),or=[{key:"alertName",header:i("span",e({style:{fontSize:"13px"}},{children:"Alert Name"})),body:function(r){return o("div",e({style:{fontWeight:500,display:"flex",alignItems:"center",gap:"8px",color:"#475569",fontSize:"13px"}},{children:[i("span",e({className:"q-alert-chevron",style:{cursor:"pointer",display:"flex",padding:"4px"}},{children:i(c,{size:16})})),r.alertName||"—"]}))}},{key:"kpi",header:i("span",e({style:{fontSize:"13px"}},{children:"KPI"})),body:function(r){return i("span",e({style:{color:"#475569",fontSize:"13px"}},{children:r.kpi||"—"}))}},{key:"threshold",header:i("span",e({style:{fontSize:"13px"}},{children:"Threshold"})),body:function(r){return i("span",e({style:{color:"#475569",fontSize:"13px",whiteSpace:"nowrap"}},{children:r.threshold||"—"}))}},{key:"severity",header:i("span",e({style:{fontSize:"13px"}},{children:"Severity"})),body:function(r){var t=r.severity||"",n=t.charAt(0).toUpperCase()+t.slice(1),o="#F1F5F9",l="#475569";return"critical"===t.toLowerCase()?(o="#FEE2E2",l="#DC2626"):"warning"===t.toLowerCase()&&(o="#FEF3C7",l="#D97706"),i("span",e({style:{background:o,color:l,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:600,display:"inline-block"}},{children:n||"—"}))}},{key:"createdOn",header:i("span",e({style:{fontSize:"13px"}},{children:"Created on"})),body:function(r){return i("span",e({style:{color:"#475569",fontSize:"13px"}},{children:r.createdOn}))}},{key:"status",header:i("span",e({style:{fontSize:"13px"}},{children:"Status"})),body:function(r){var t="#F1F5F9",n="#475569",o=r.status||"Active";return"active"===o.toLowerCase()?(t="#DCFCE7",n="#16A34A"):"failed"===o.toLowerCase()?(t="#FEE2E2",n="#DC2626"):"paused"===o.toLowerCase()&&(t="#F1F5F9",n="#64748B"),i("span",e({style:{background:t,color:n,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",display:"inline-block"}},{children:o.charAt(0).toUpperCase()+o.slice(1)}))}},{key:"customActions",header:i("span",e({style:{fontSize:"13px"}},{children:"Actions"})),body:function(r){var t="Failed"===r.status||"Paused"===r.status;return o("div",e({style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"nowrap",position:"relative"}},{children:[o("button",e({onClick:function(e){e.stopPropagation(),se(r),de(!0)},style:{background:"white",color:t?"#94A3B8":"#475569",border:"1px solid #cbd5e1",padding:"6px 12px",borderRadius:"6px",fontSize:"13px",display:"flex",alignItems:"center",gap:"6px",cursor:t?"not-allowed":"pointer",fontWeight:500,opacity:t?.6:1,whiteSpace:"nowrap",flexShrink:0},disabled:t},{children:[i(u,{size:12})," Edit Alert"]})),i("button",e({ref:function(e){me.current[r.id]=e},className:"q-alert-kebab-trigger",onClick:function(e){return dr(e,r)}},{children:i(d,{size:16})}))]}))}}],lr=[{id:"severity",label:"Severity",type:"singleSelect",options:[{label:"All",value:""},{label:"Critical",value:"critical"},{label:"Warning",value:"warning"},{label:"Info",value:"info"}],value:ie.severity||"",onChange:function(r){return oe(function(t){return e(e({},t),{severity:r})})}},{id:"status",label:"Status",type:"singleSelect",options:[{label:"All",value:""},{label:"Active",value:"active"},{label:"Paused",value:"paused"}],value:ie.status||"",onChange:function(r){return oe(function(t){return e(e({},t),{status:r})})}}],ar=[{key:"no",header:i("span",e({style:{fontSize:"13px"}},{children:"No"})),body:function(r){return i("span",e({style:{color:"#475569",fontSize:"13px"}},{children:r.no}))}},{key:"alert_name",header:i("span",e({style:{fontSize:"13px"}},{children:"Alert Name"})),body:function(r){return i("span",e({style:{color:"#475569",fontSize:"13px"}},{children:r.alert_name}))}},{key:"source",header:i("span",e({style:{fontSize:"13px"}},{children:"Source"})),body:function(r){return i("div",e({style:{color:"#475569",fontSize:"13px",display:"flex",flexDirection:"column"}},{children:r.source.length>0?o(l,{children:[o("span",{children:[r.source[0]," ",r.source.length>1?"|":""]}),r.source.slice(1).map(function(r,t){return i("span",e({style:{fontWeight:600,color:"#0F172A"}},{children:r}),t)})]}):"—"}))}},{key:"severity",header:i("span",e({style:{fontSize:"13px"}},{children:"Severity"})),body:function(r){var t=r.severity||"",n=t.charAt(0).toUpperCase()+t.slice(1),o="#F1F5F9",l="#475569";return"critical"===t.toLowerCase()?(o="#FEE2E2",l="#DC2626"):"warning"===t.toLowerCase()&&(o="#FEF3C7",l="#D97706"),i("span",e({style:{background:o,color:l,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:600,display:"inline-block"}},{children:n||"—"}))}},{key:"triggered_at",header:i("span",e({style:{fontSize:"13px"}},{children:"Triggered at"})),body:function(r){return i("span",e({style:{color:"#475569",fontSize:"13px"}},{children:r.triggered_at}))}},{key:"current_value",header:i("span",e({style:{fontSize:"13px"}},{children:"Current value"})),body:function(r){return i("span",e({style:{color:"#475569",fontSize:"13px"}},{children:r.current_value}))}},{key:"threshold",header:i("span",e({style:{fontSize:"13px"}},{children:"Threshold"})),body:function(r){return i("span",e({style:{color:"#475569",fontSize:"13px"}},{children:r.threshold}))}}],sr=S(function(){return Ie.map(function(e,r){return{id:e.historyId||"hist_".concat(r),no:r+1,alert_name:e.title||"—",rawSource:e.source,source:e.source?String(e.source).split("|").map(function(e){return e.trim()}):[],severity:e.severity||"—",triggered_at:e.triggeredAt?$e(e.triggeredAt):"—",current_value:void 0!==e.currentValue?String(e.currentValue):"—",threshold:void 0!==e.thresholdValue?String(e.thresholdValue):"—"}})},[Ie]),cr=S(function(){return sr.filter(function(e,r){var t,n=!We.severity||(null===(t=e.severity)||void 0===t?void 0:t.toLowerCase())===We.severity.toLowerCase(),i=We.source,o=!i||e.rawSource.includes(i),l=new Date(e.triggered_at),a=!We.dateFrom||l>=We.dateFrom,s=!We.dateTo||l<=We.dateTo;return n&&o&&a&&s})},[We,sr,Ie]),ur=[{id:"source",label:"Source",type:"singleSelect",options:r([{label:"All",value:""}],(null==Y?void 0:Y.map(function(e){return{label:e,value:e}}))||[],!0),value:Ke.source||"",onChange:function(r){return He(function(t){return e(e({},t),{source:r})})}},{id:"severity",label:"Severity",type:"singleSelect",options:[{label:"All",value:""},{label:"Critical",value:"critical"},{label:"Warning",value:"warning"},{label:"Info",value:"info"}],value:Ke.severity||"",onChange:function(r){return He(function(t){return e(e({},t),{severity:r})})}},{id:"dateRange",label:"Date range",type:"dateRange",value:{start:Ke.dateFrom||null,end:Ke.dateTo||null},onChange:function(r){return He(function(t){var n,i;return e(e({},t),{dateFrom:null!==(n=null==r?void 0:r.start)&&void 0!==n?n:null,dateTo:null!==(i=null==r?void 0:r.end)&&void 0!==i?i:null})})}}],dr=w(function(e,r){e.stopPropagation(),ye(function(e){if((null==e?void 0:e.id)===r.id)return ge(null),null;var t=me.current[r.id];if(t){var n=t.getBoundingClientRect();ge({top:n.bottom+4,left:n.right})}return r})},[]);x(function(){if(fe){var e=function(){ye(null),ge(null)};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),function(){window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}}},[fe]);return"history"===Ge?i(l,{children:o("div",e({style:{display:"flex",flexDirection:"column",height:"100%",width:"100%"}},{children:[i("div",{children:i(v,{title:"Alerts",onClose:R,headerCtaLabel:"Manage alerts",onClickHeaderCta:function(){return Xe("manage")},styles:{tableWrapper:{border:"1px solid #E2E8F0",borderRadius:"12px",boxShadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",padding:"16px"}},subtitle:"View and track recent alerts generated across your services",search:{value:ze,placeholder:"Search..",searchKey:"alert_name",onChange:Pe},filter:{count:nr,onClick:function(){return Be(!0)}},table:{rows:cr,loading:Ue,extraColumns:ar,emptyState:{title:"No alerts found",description:"No alerts have been generated yet."},tableProps:{className:"q-alert-hist-log-table"}}})}),i(g,{visible:je,onHide:function(){return Be(!1)},title:"Filter History",onReset:function(){Ve({}),He({}),Be(!1)},onApply:function(){Ve(Ke),Be(!1)},fields:ur})]}))}):o(l,{children:[i(a,{ref:Ye,position:"top-right"}),o("div",e({style:{width:"100%"}},{children:[i(v,{title:"Manage Alerts",onClose:function(){return Xe("history")},styles:{tableWrapper:{border:"1px solid #E2E8F0",borderRadius:"12px",boxShadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",padding:"16px"}},subtitle:"Set up and manage custom alert triggers to stay updated about your services.",search:{value:O,placeholder:"Search...",searchKey:"alertName",onChange:W},filter:{count:ir,onClick:function(){return $(!0)}},addAction:{label:"Create Alert",onClick:function(){se(null),de(!0)}},table:{rows:tr,loading:M,extraColumns:or,hiddenColumns:["logId","modifiedBy","changeSummary","changeDateTime","actions"],emptyState:{title:"No Alerts found",description:"Try creating one."},tableProps:{className:"q-alert-log-table"},onRowClick:function(e,r){r.toggle()},rowDetail:{expandOnRowClick:!1,style:{padding:0,backgroundColor:"transparent"},render:function(r){return o("div",e({style:{padding:"16px 40px",display:"flex",gap:"48px",borderBottom:"1px solid #E2E8F0",background:"#F8FAFC",fontSize:"13px"}},{children:[o("div",e({style:{flex:1,display:"flex",flexDirection:"column",gap:"8px"}},{children:[i("strong",e({style:{fontSize:"11px",color:"#64748B",textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Scope"})),i("div",e({style:{display:"flex",flexDirection:"column",gap:"4px"}},{children:r.rawScope&&Object.entries(r.rawScope).filter(function(e){return e[0],null!=e[1]}).length>0?Object.entries(r.rawScope).filter(function(e){return e[0],null!=e[1]}).map(function(r){var t=r[0],n=r[1];return o("div",e({style:{display:"flex",gap:"16px",marginBottom:"4px"}},{children:[i("span",e({style:{color:"#64748B",width:"120px",whiteSpace:"nowrap"}},{children:t})),i("span",e({style:{color:"#0F172A",fontWeight:500}},{children:String(n)}))]}),t)}):i("div",e({style:{color:"#94a3b8"}},{children:"No scope defined"}))}))]})),i("div",{style:{width:"1px",backgroundColor:"#E2E8F0"}}),o("div",e({style:{flex:1,display:"flex",flexDirection:"column",gap:"8px"}},{children:[i("strong",e({style:{fontSize:"11px",color:"#64748B",textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Trigger Configuration"})),i("div",e({style:{display:"flex",flexDirection:"column",gap:"4px"}},{children:r.triggerConfig&&Object.entries(r.triggerConfig).filter(function(e){return e[0],null!=e[1]}).length>0?Object.entries(r.triggerConfig).filter(function(e){return e[0],null!=e[1]}).map(function(r){var t=r[0],n=r[1];return o("div",e({style:{display:"flex",gap:"16px",marginBottom:"4px"}},{children:[i("span",e({style:{color:"#64748B",width:"120px"}},{children:t})),i("span",e({style:{color:"#0F172A",fontWeight:500}},{children:String(n)}))]}),t)}):i("div",e({style:{color:"#94a3b8"}},{children:"No trigger configuration"}))}))]})),i("div",{style:{width:"1px",backgroundColor:"#E2E8F0"}}),o("div",e({style:{flex:1,display:"flex",flexDirection:"column",gap:"8px"}},{children:[i("strong",e({style:{fontSize:"11px",color:"#64748B",textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Alert Recipients"})),i("div",e({style:{display:"flex",flexDirection:"column",gap:"4px"}},{children:r.subscribers&&r.subscribers.length>0?i("span",e({style:{color:"#0F172A",fontWeight:500}},{children:(Array.isArray(r.subscribers)?r.subscribers:[r.subscribers]).map(function(e){return"string"==typeof e?e:e.name||e.email||e.label||""}).join(", ")})):i("div",e({style:{color:"#94a3b8"}},{children:"No recipients"}))}))]}))]}))}}}}),i(g,{visible:Z,onHide:function(){return $(!1)},onReset:function(){oe({}),te({}),$(!1)},onApply:function(){te(ie),$(!1)},fields:lr}),i(s,{isOpen:!!Ce,isLoading:Fe,onClose:function(){Fe||Ae(null)},onConfirm:function(){return t(void 0,void 0,void 0,function(){var e,r,t;return n(this,function(n){switch(n.label){case 0:if(!Ce)return[2];Ee(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,F({baseUrl:L,configId:U||"",accessToken:j},Ce.id)];case 2:return n.sent(),null===(r=Ye.current)||void 0===r||r.show({severity:"success",summary:"Success",detail:"Alert deleted successfully!",life:3e3}),er(),Ae(null),[3,5];case 3:return e=n.sent(),console.error(e),null===(t=Ye.current)||void 0===t||t.show({severity:"error",summary:"Error",detail:"Failed to delete alert. Please try again.",life:3e3}),[3,5];case 4:return Ee(!1),[7];case 5:return[2]}})})},title:"Delete Alert?",message:Ce?"You'll stop receiving reports for \"".concat(Ce.alertName,'."'):"",warningText:"This action cannot be undone.",confirmText:"Delete",cancelText:"Cancel",confirmButtonColor:"#EF4444"}),i(A,{isOpen:ue,onClose:function(){de(!1),se(null)},uiConfig:_,onSearchSubscribers:function(e){return new Promise(function(r){Je.current&&(clearTimeout(Je.current),Qe.current&&Qe.current([])),Ze.current&&Ze.current.abort(),Qe.current=r,Je.current=setTimeout(function(){return t(void 0,void 0,void 0,function(){var t,i,o;return n(this,function(n){switch(n.label){case 0:t=new AbortController,Ze.current=t,n.label=1;case 1:return n.trys.push([1,3,4,5]),i=[],[4,P({authBaseUrl:N,accessToken:j},{page:1,limit:50,pagination:!0,search:e.trim()||void 0,isPopulateRoles:!1,isPopulatePermissions:!1,isPopulateApps:!1,isPopulateEnvironments:!1,isPopulateOperations:!1,isPopulateGroups:!1,isPopulateOrganization:!1},t.signal)];case 2:return(o=n.sent())&&o.forEach(function(e){i.push({label:e.email,value:e.email,userId:e._id})}),r(i),[3,5];case 3:return"AbortError"===n.sent().name||console.error("User search failed: An error occurred while querying the user directory."),r([]),[3,5];case 4:return Ze.current===t&&(Ze.current=null),Je.current=null,Qe.current=null,[7];case 5:return[2]}})})},400)})},onSave:function(e,r){return t(void 0,void 0,void 0,function(){var t,i,o,l,a;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,5,,6]),r?(t=null==ae?void 0:ae.id,[4,E({baseUrl:L,configId:U||"",accessToken:j},t,e)]):[3,2];case 1:return n.sent(),null===(o=Ye.current)||void 0===o||o.show({severity:"success",summary:"Success",detail:"Updates saved successfully!",life:3e3}),[3,4];case 2:return[4,D({baseUrl:L,configId:U||"",accessToken:j},e)];case 3:n.sent(),null===(l=Ye.current)||void 0===l||l.show({severity:"success",summary:"Success",detail:"Alert created successfully!",life:3e3}),n.label=4;case 4:return er(),[2,!0];case 5:return i=n.sent(),console.error("Error in handleCreateAlert:",i),null===(a=Ye.current)||void 0===a||a.show({severity:"error",summary:"Error",detail:r?"Failed to update alert. Please try again.":"Failed to create alert. Please try again.",life:3e3}),[2,!1];case 6:return[2]}})})},editData:ae})]})),fe&&ve&&C(o(l,{children:[i("div",{style:{position:"fixed",inset:0,zIndex:9998},onClick:function(){ye(null),ge(null)}}),o("div",e({className:"q-alert-kebab-menu",style:{position:"fixed",top:ve.top,left:ve.left,transform:"translateX(-100%)"}},{children:[o("button",e({className:"q-alert-kebab-item",disabled:"FAILED"===fe.status||xe[fe.id],style:{color:"FAILED"===fe.status||xe[fe.id]?"#94a3b8":void 0,cursor:"FAILED"===fe.status||xe[fe.id]?"not-allowed":"pointer"},onClick:function(r){return t(void 0,void 0,void 0,function(){var t,i,o,l,a,s,c,u,d,p,f,y,h;return n(this,function(n){switch(n.label){case 0:if(r.stopPropagation(),"FAILED"===fe.status||xe[fe.id])return[2];t=fe,Se(function(r){var n;return e(e({},r),((n={})[t.id]=!0,n))}),n.label=1;case 1:return n.trys.push([1,4,5,6]),i=(null===(u=t.status)||void 0===u?void 0:u.toUpperCase())||"",l=(o="PAUSED"===i)?"ACTIVE":"PAUSED",a=t.raw||{},s={name:(null==a?void 0:a.name)||"",kpiKey:(null==a?void 0:a.kpiKey)||"",kpiType:(null==a?void 0:a.kpiType)||"",entityType:(null==a?void 0:a.entityType)||{},conditionType:(null==a?void 0:a.conditionType)||"",thresholdValue:null!==(d=null==a?void 0:a.thresholdValue)&&void 0!==d?d:null,severity:(null==a?void 0:a.severity)||"",evaluationType:(null==a?void 0:a.evaluationType)||"",evaluationPeriod:(null==a?void 0:a.evaluationPeriod)||null,triggerAfter:null!==(p=null==a?void 0:a.triggerAfter)&&void 0!==p?p:0,recipients:(null==a?void 0:a.recipients)||{userIds:[],userEmails:[]},status:l},[4,E({baseUrl:L,configId:U||"",accessToken:j},t.id,s)];case 2:return n.sent(),o?null===(f=Ye.current)||void 0===f||f.show({severity:"success",summary:"Success",detail:"Alert resumed successfully!",life:3e3}):null===(y=Ye.current)||void 0===y||y.show({severity:"success",summary:"Success",detail:"Alert paused successfully!",life:3e3}),[4,er()];case 3:return n.sent(),ye(null),ge(null),[3,6];case 4:return c=n.sent(),console.error(c),null===(h=Ye.current)||void 0===h||h.show({severity:"error",summary:"Error",detail:"Failed to update Alert status. Please try again.",life:3e3}),[3,6];case 5:return Se(function(r){var n;return e(e({},r),((n={})[t.id]=!1,n))}),[7];case 6:return[2]}})})}},{children:[xe[fe.id]?i(p,{size:14,className:"animate-spin"}):"PAUSED"===fe.status?i(f,{size:14}):i(y,{size:14}),"PAUSED"===fe.status?"Resume Alert":"ACTIVE"===fe.status?"Pause Alert":""]})),o("button",e({className:"q-alert-kebab-item danger",onClick:function(e){e.stopPropagation(),Ae(fe),ye(null),ge(null)}},{children:[i(h,{size:14})," Delete"]}))]}))]}),document.body)]})};export{I as AlertsViewTrigger};
1
+ import{__assign as e,__spreadArray as r,__awaiter as t,__generator as n}from"../../../_virtual/_tslib.js";import{jsx as i,jsxs as l,Fragment as o}from"react/jsx-runtime";import{Toast as a}from"primereact/toast";import s from"../common/ConfirmationModal.js";import{ChevronRight as c,Pencil as u,MoreVertical as d,Loader2 as p,Play as f,Pause as y,Trash2 as h}from"lucide-react";import v from"../TablePage/TablePage.js";import g from"../FiltersSidebar/FiltersSidebar.js";import{useState as m,useRef as b,useEffect as x,useMemo as S,useCallback as A}from"react";import{createPortal as w}from"react-dom";import C from"./CreateAlertModal.js";import{fetchAlertHistory as k,deleteAlert as F,updateAlert as E,fetchDistinctSources as T,getAllUsers as z,createAlert as P,fetchAlerts as D,fetchPlotAndKPIs as I}from"../../api/alertsapi.js";var L=function(L){var N=L.baseUrl,U=L.authBaseUrl,R=L.configId,B=L.onClose,_=L.uiConfig,j=L.accessToken,O=m(""),W=O[0],V=O[1],q=m([]),K=q[0],H=q[1],M=m(!1),G=M[0],X=M[1],Y=m([]),J=Y[0],Q=Y[1],Z=m(!1),$=Z[0],ee=Z[1],re=m({}),te=re[0],ne=re[1],ie=m({}),le=ie[0],oe=ie[1],ae=m(null),se=ae[0],ce=ae[1],ue=m(!1),de=ue[0],pe=ue[1],fe=m(null),ye=fe[0],he=fe[1],ve=m(null),ge=ve[0],me=ve[1],be=b({}),xe=m({}),Se=xe[0],Ae=xe[1],we=m(null),Ce=we[0],ke=we[1],Fe=m(!1),Ee=Fe[0],Te=Fe[1],ze=m(""),Pe=ze[0],De=ze[1],Ie=m([]),Le=Ie[0],Ne=Ie[1],Ue=m(!1),Re=Ue[0],Be=Ue[1],_e=m(!1),je=_e[0],Oe=_e[1],We=m({}),Ve=We[0],qe=We[1],Ke=m({}),He=Ke[0],Me=Ke[1],Ge=m("history"),Xe=Ge[0],Ye=Ge[1],Je=m([]),Qe=Je[0],Ze=Je[1],$e=m([]),er=$e[0],rr=$e[1],tr=b(null),nr=b(null),ir=b(null),lr=b(null);function or(e){var r=new Date(e);return isNaN(r.getTime())?e:r.toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})}x(function(){$&&oe(te)},[$,te]),x(function(){je&&Me(Ve)},[je,Ve]);var ar=function(){return t(void 0,void 0,void 0,function(){var e,r,t,i;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,T({baseUrl:N,configId:R||"",accessToken:j})];case 1:return e=n.sent(),r=e,Q(Array.isArray(r)?r:[]),[3,3];case 2:return t=n.sent(),console.error("Failed to fetch distinct sources:",t),null===(i=tr.current)||void 0===i||i.show({severity:"error",summary:"Error",detail:"Failed to load data sources.",life:3e3}),[3,3];case 3:return[2]}})})};function sr(){t(void 0,void 0,void 0,function(){var e,r,t,i;return n(this,function(n){switch(n.label){case 0:X(!0),he(null),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,D({baseUrl:N,configId:R||"",accessToken:j})];case 2:return e=n.sent(),r=e,H(Array.isArray(r)?r:[]),[3,5];case 3:return t=n.sent(),console.error("Failed to fetch alerts:",t),null===(i=tr.current)||void 0===i||i.show({severity:"error",summary:"Error",detail:"Failed to load alerts. Please refresh.",life:3e3}),H([]),[3,5];case 4:return X(!1),[7];case 5:return[2]}})}),t(void 0,void 0,void 0,function(){var e,r,t,i;return n(this,function(n){switch(n.label){case 0:X(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,I({baseUrl:N,configId:R||"",accessToken:j})];case 2:return e=n.sent(),r=e,Ze(Array.isArray(r)?r:[]),[3,5];case 3:return t=n.sent(),console.error("Failed to fetch plots & KPI's:",t),null===(i=tr.current)||void 0===i||i.show({severity:"error",summary:"Error",detail:"Failed to load plots & KPIs. Please refresh.",life:3e3}),Ze([]),[3,5];case 4:return X(!1),[7];case 5:return[2]}})}),ar()}x(function(){sr()},[]),x(function(){var e=!0;return"history"===Xe?(Be(!0),k({baseUrl:N,configId:R||"",accessToken:j}).then(function(r){e&&Ne(r||[])}).catch(function(r){var t;console.error("Error fetching history:",r),null===(t=tr.current)||void 0===t||t.show({severity:"error",summary:"Error",detail:"Failed to load alert history.",life:3e3}),e&&Ne([])}).finally(function(){e&&Be(!1)}),ar()):Ne([]),function(){e=!1}},[Xe]);var cr=(Array.isArray(K)?K:[]).map(function(e){var r,t,n=e.kpiType?e.kpiType.charAt(0).toUpperCase()+e.kpiType.slice(1):"—",i=e.status?e.status.charAt(0).toUpperCase()+e.status.slice(1):"—",l=(null===(t=null===(r=e.recipients)||void 0===r?void 0:r.userEmails)||void 0===t?void 0:t.map(function(r,t){var n;return{name:r,email:r,value:r,label:r,userId:(null===(n=e.recipients.userIds)||void 0===n?void 0:n[t])||void 0}}))||[],o={">":"Greater than","<":"Less than",">=":"Greater than or equal to","<=":"Less than or equal to"}[e.conditionType]||e.conditionType||"",a=o?"".concat(o," ").concat(e.thresholdValue):"".concat(e.thresholdValue);return{id:e.id,alertName:e.name,type:n,status:i,subscribers:l,raw:e,kpi:e.kpiLabel,threshold:a,severity:e.severity,createdOn:e.createdAt?or(e.createdAt):"—",alertScope:e.alertScope,triggerConfig:{"Evaluation Type":e.evaluationType,"Evaluation period":e.evaluationPeriod,"Trigger After":e.triggerAfter?"".concat(e.triggerAfter," data points"):void 0}}}),ur=S(function(){return cr.filter(function(e){var r,t,n=!te.severity||(null===(r=e.severity)||void 0===r?void 0:r.toLowerCase())===te.severity.toLowerCase(),i=!te.status||(null===(t=e.status)||void 0===t?void 0:t.toLowerCase())===te.status.toLowerCase();return n&&i})},[te,cr]),dr=S(function(){var e=0,r=!1;return Object.entries(Ve).forEach(function(t){var n=t[0],i=t[1];null===i||""===i||Array.isArray(i)&&0===i.length||("dateFrom"===n||"dateTo"===n?r=!0:e+=Array.isArray(i)?i.length:1)}),r&&(e+=1),e},[Ve]),pr=Object.values(te).reduce(function(e,r){return e+(Array.isArray(r)?r.length:r&&""!==r?1:0)},0),fr=[{key:"alertName",header:i("span",e({style:{fontSize:"13px"}},{children:"Alert Name"})),body:function(r){return l("div",e({style:{fontWeight:500,display:"flex",alignItems:"center",gap:"8px",color:"#475569",fontSize:"13px"}},{children:[i("span",e({className:"q-alert-chevron",style:{cursor:"pointer",display:"flex",padding:"4px"}},{children:i(c,{size:16})})),r.alertName||"—"]}))}},{key:"kpi",header:i("span",e({style:{fontSize:"13px"}},{children:"KPI"})),body:function(r){return i("span",e({style:{color:"#475569",fontSize:"13px"}},{children:r.kpi||"—"}))}},{key:"threshold",header:i("span",e({style:{fontSize:"13px"}},{children:"Threshold"})),body:function(r){return i("span",e({style:{color:"#475569",fontSize:"13px",whiteSpace:"nowrap"}},{children:r.threshold||"—"}))}},{key:"severity",header:i("span",e({style:{fontSize:"13px"}},{children:"Severity"})),body:function(r){var t=r.severity||"",n=t.charAt(0).toUpperCase()+t.slice(1),l="#F1F5F9",o="#475569";return"critical"===t.toLowerCase()?(l="#FEE2E2",o="#DC2626"):"warning"===t.toLowerCase()&&(l="#FEF3C7",o="#D97706"),i("span",e({style:{background:l,color:o,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:600,display:"inline-block"}},{children:n||"—"}))}},{key:"createdOn",header:i("span",e({style:{fontSize:"13px"}},{children:"Created on"})),body:function(r){return i("span",e({style:{color:"#475569",fontSize:"13px"}},{children:r.createdOn}))}},{key:"status",header:i("span",e({style:{fontSize:"13px"}},{children:"Status"})),body:function(r){var t="#F1F5F9",n="#475569",l=r.status||"Active";return"active"===l.toLowerCase()?(t="#DCFCE7",n="#16A34A"):"failed"===l.toLowerCase()?(t="#FEE2E2",n="#DC2626"):"paused"===l.toLowerCase()&&(t="#F1F5F9",n="#64748B"),i("span",e({style:{background:t,color:n,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",display:"inline-block"}},{children:l.charAt(0).toUpperCase()+l.slice(1)}))}},{key:"customActions",header:i("span",e({style:{fontSize:"13px"}},{children:"Actions"})),body:function(r){var t="Failed"===r.status||"Paused"===r.status;return l("div",e({style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"nowrap",position:"relative"}},{children:[l("button",e({onClick:function(e){e.stopPropagation(),ce(r),pe(!0)},style:{background:"white",color:t?"#94A3B8":"#475569",border:"1px solid #cbd5e1",padding:"6px 12px",borderRadius:"6px",fontSize:"13px",display:"flex",alignItems:"center",gap:"6px",cursor:t?"not-allowed":"pointer",fontWeight:500,opacity:t?.6:1,whiteSpace:"nowrap",flexShrink:0},disabled:t},{children:[i(u,{size:12})," Edit Alert"]})),i("button",e({ref:function(e){be.current[r.id]=e},className:"q-alert-kebab-trigger",onClick:function(e){return br(e,r)}},{children:i(d,{size:16})}))]}))}}],yr=[{id:"severity",label:"Severity",type:"singleSelect",options:[{label:"All",value:""},{label:"Critical",value:"critical"},{label:"Warning",value:"warning"},{label:"Info",value:"info"}],value:le.severity||"",onChange:function(r){return oe(function(t){return e(e({},t),{severity:r})})}},{id:"status",label:"Status",type:"singleSelect",options:[{label:"All",value:""},{label:"Active",value:"active"},{label:"Paused",value:"paused"}],value:le.status||"",onChange:function(r){return oe(function(t){return e(e({},t),{status:r})})}}],hr=[{key:"no",header:i("span",e({style:{fontSize:"13px"}},{children:"No"})),body:function(r){return i("span",e({style:{color:"#475569",fontSize:"13px"}},{children:r.no}))}},{key:"alert_name",header:i("span",e({style:{fontSize:"13px"}},{children:"Alert Name"})),body:function(r){return i("span",e({style:{color:"#475569",fontSize:"13px"}},{children:r.alert_name}))}},{key:"source",header:i("span",e({style:{fontSize:"13px"}},{children:"Source"})),body:function(r){return i("div",e({style:{color:"#475569",fontSize:"13px",display:"flex",flexDirection:"column"}},{children:r.source.length>0?l(o,{children:[l("span",{children:[r.source[0]," ",r.source.length>1?"|":""]}),r.source.slice(1).map(function(r,t){return i("span",e({style:{fontWeight:600,color:"#0F172A"}},{children:r}),t)})]}):"—"}))}},{key:"severity",header:i("span",e({style:{fontSize:"13px"}},{children:"Severity"})),body:function(r){var t=r.severity||"",n=t.charAt(0).toUpperCase()+t.slice(1),l="#F1F5F9",o="#475569";return"critical"===t.toLowerCase()?(l="#FEE2E2",o="#DC2626"):"warning"===t.toLowerCase()&&(l="#FEF3C7",o="#D97706"),i("span",e({style:{background:l,color:o,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:600,display:"inline-block"}},{children:n||"—"}))}},{key:"triggered_at",header:i("span",e({style:{fontSize:"13px"}},{children:"Triggered at"})),body:function(r){return i("span",e({style:{color:"#475569",fontSize:"13px"}},{children:r.triggered_at}))}},{key:"current_value",header:i("span",e({style:{fontSize:"13px"}},{children:"Triggered value"})),body:function(r){return i("span",e({style:{color:"#475569",fontSize:"13px"}},{children:r.current_value}))}},{key:"threshold",header:i("span",e({style:{fontSize:"13px"}},{children:"Threshold"})),body:function(r){return i("span",e({style:{color:"#475569",fontSize:"13px"}},{children:r.threshold}))}}],vr=S(function(){return Le.map(function(e,r){return{id:e.historyId||"hist_".concat(r),no:r+1,alert_name:e.title||"—",rawSource:e.source,source:e.source?String(e.source).split("|").map(function(e){return e.trim()}):[],severity:e.severity||"—",triggered_at:e.triggeredAt?or(e.triggeredAt):"—",current_value:void 0!==e.currentValue?String(e.currentValue):"—",threshold:void 0!==e.thresholdValue?String(e.thresholdValue):"—"}})},[Le]),gr=S(function(){return vr.filter(function(e,r){var t,n=!Ve.severity||(null===(t=e.severity)||void 0===t?void 0:t.toLowerCase())===Ve.severity.toLowerCase(),i=Ve.source,l=!i||e.rawSource.includes(i),o=new Date(e.triggered_at),a=!Ve.dateFrom||o>=Ve.dateFrom,s=!Ve.dateTo||o<=Ve.dateTo;return n&&l&&a&&s})},[Ve,vr,Le]),mr=[{id:"source",label:"Source",type:"singleSelect",options:r([{label:"All",value:""}],(null==J?void 0:J.map(function(e){return{label:e,value:e}}))||[],!0),value:He.source||"",onChange:function(r){return Me(function(t){return e(e({},t),{source:r})})}},{id:"severity",label:"Severity",type:"singleSelect",options:[{label:"All",value:""},{label:"Critical",value:"critical"},{label:"Warning",value:"warning"},{label:"Info",value:"info"}],value:He.severity||"",onChange:function(r){return Me(function(t){return e(e({},t),{severity:r})})}},{id:"dateRange",label:"Date range",type:"dateRange",value:{start:He.dateFrom||null,end:He.dateTo||null},onChange:function(r){return Me(function(t){var n,i;return e(e({},t),{dateFrom:null!==(n=null==r?void 0:r.start)&&void 0!==n?n:null,dateTo:null!==(i=null==r?void 0:r.end)&&void 0!==i?i:null})})}}],br=A(function(e,r){e.stopPropagation(),he(function(e){if((null==e?void 0:e.id)===r.id)return me(null),null;var t=be.current[r.id];if(t){var n=t.getBoundingClientRect();me({top:n.bottom+4,left:n.right})}return r})},[]);x(function(){if(ye){var e=function(){he(null),me(null)};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),function(){window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}}},[ye]);return"history"===Xe?i(o,{children:l("div",e({style:{display:"flex",flexDirection:"column",height:"100%",width:"100%"}},{children:[i("div",{children:i(v,{title:"Alerts",onClose:B,headerCtaLabel:"Manage alerts",onClickHeaderCta:function(){return Ye("manage")},styles:{tableWrapper:{border:"1px solid #E2E8F0",borderRadius:"12px",boxShadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",padding:"16px"}},subtitle:"View and track recent alerts generated across your services",search:{value:Pe,placeholder:"Search..",searchKey:"alert_name",onChange:De},filter:{count:dr,onClick:function(){return Oe(!0)}},table:{rows:gr,loading:Re,extraColumns:hr,emptyState:{title:"No alerts found",description:"No alerts have been generated yet."},tableProps:{className:"q-alert-hist-log-table"}}})}),i(g,{visible:je,onHide:function(){return Oe(!1)},title:"Filter History",onReset:function(){qe({}),Me({}),Oe(!1)},onApply:function(){qe(He),Oe(!1)},fields:mr})]}))}):l(o,{children:[i(a,{ref:tr,position:"top-right"}),l("div",e({style:{width:"100%"}},{children:[i(v,{title:"Manage Alerts",onClose:function(){return Ye("history")},styles:{tableWrapper:{border:"1px solid #E2E8F0",borderRadius:"12px",boxShadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",padding:"16px"}},subtitle:"Set up and manage custom alert triggers to stay updated about your services.",search:{value:W,placeholder:"Search...",searchKey:"alertName",onChange:V},filter:{count:pr,onClick:function(){return ee(!0)}},addAction:{label:"Create Alert",onClick:function(){ce(null),pe(!0)}},table:{rows:ur,loading:G,extraColumns:fr,hiddenColumns:["logId","modifiedBy","changeSummary","changeDateTime","actions"],emptyState:{title:"No Alerts found",description:"Try creating one."},tableProps:{className:"q-alert-log-table"},onRowClick:function(e,r){r.toggle()},rowDetail:{expandOnRowClick:!1,style:{padding:0,backgroundColor:"transparent"},render:function(r){return l("div",e({style:{padding:"16px 40px",display:"flex",gap:"48px",borderBottom:"1px solid #E2E8F0",background:"#F8FAFC",fontSize:"13px"}},{children:[l("div",e({style:{flex:1,display:"flex",flexDirection:"column",gap:"8px"}},{children:[i("strong",e({style:{fontSize:"11px",color:"#64748B",textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Scope"})),i("div",e({style:{display:"flex",flexDirection:"column",gap:"4px"}},{children:r.alertScope&&Object.entries(r.alertScope).filter(function(e){return e[0],null!=e[1]}).length>0?Object.entries(r.alertScope).filter(function(e){return e[0],null!=e[1].data}).map(function(r){var t=r[0],n=r[1];return l("div",e({style:{display:"flex",gap:"16px",marginBottom:"4px"}},{children:[i("span",e({style:{color:"#64748B",width:"120px",whiteSpace:"nowrap"}},{children:n.label})),i("span",e({style:{color:"#0F172A",fontWeight:500}},{children:n.data.map(function(e,r){var t;return"".concat(e).concat(r!==(null===(t=n.data)||void 0===t?void 0:t.length)-1?", ":"")})}))]}),t)}):i("div",e({style:{color:"#94a3b8"}},{children:"No scope defined"}))}))]})),i("div",{style:{width:"1px",backgroundColor:"#E2E8F0"}}),l("div",e({style:{flex:1,display:"flex",flexDirection:"column",gap:"8px"}},{children:[i("strong",e({style:{fontSize:"11px",color:"#64748B",textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Trigger Configuration"})),i("div",e({style:{display:"flex",flexDirection:"column",gap:"4px"}},{children:r.triggerConfig&&Object.entries(r.triggerConfig).filter(function(e){return e[0],null!=e[1]}).length>0?Object.entries(r.triggerConfig).filter(function(e){return e[0],null!=e[1]}).map(function(r){var t=r[0],n=r[1];return l("div",e({style:{display:"flex",gap:"16px",marginBottom:"4px"}},{children:[i("span",e({style:{color:"#64748B",width:"120px"}},{children:t})),i("span",e({style:{color:"#0F172A",fontWeight:500}},{children:String(n)}))]}),t)}):i("div",e({style:{color:"#94a3b8"}},{children:"No trigger configuration"}))}))]})),i("div",{style:{width:"1px",backgroundColor:"#E2E8F0"}}),l("div",e({style:{flex:1,display:"flex",flexDirection:"column",gap:"8px"}},{children:[i("strong",e({style:{fontSize:"11px",color:"#64748B",textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Alert Recipients"})),i("div",e({style:{display:"flex",flexDirection:"column",gap:"4px"}},{children:r.subscribers&&r.subscribers.length>0?i("span",e({style:{color:"#0F172A",fontWeight:500}},{children:(Array.isArray(r.subscribers)?r.subscribers:[r.subscribers]).map(function(e){return"string"==typeof e?e:e.name||e.email||e.label||""}).join(", ")})):i("div",e({style:{color:"#94a3b8"}},{children:"No recipients"}))}))]}))]}))}}}}),i(g,{visible:$,onHide:function(){return ee(!1)},onReset:function(){oe({}),ne({}),ee(!1)},onApply:function(){ne(le),ee(!1)},fields:yr}),i(s,{isOpen:!!Ce,isLoading:Ee,onClose:function(){Ee||ke(null)},onConfirm:function(){return t(void 0,void 0,void 0,function(){var e,r,t;return n(this,function(n){switch(n.label){case 0:if(!Ce)return[2];Te(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,F({baseUrl:N,configId:R||"",accessToken:j},Ce.id)];case 2:return n.sent(),null===(r=tr.current)||void 0===r||r.show({severity:"success",summary:"Success",detail:"Alert deleted successfully!",life:3e3}),sr(),ke(null),[3,5];case 3:return e=n.sent(),console.error(e),null===(t=tr.current)||void 0===t||t.show({severity:"error",summary:"Error",detail:"Failed to delete alert. Please try again.",life:3e3}),[3,5];case 4:return Te(!1),[7];case 5:return[2]}})})},title:"Delete Alert?",message:Ce?'Are you sure you want to delete the alert "'.concat(Ce.alertName,'."? You’ll no longer receive alerts from it.'):"",warningText:"This action cannot be undone.",confirmText:"Delete",cancelText:"Cancel",confirmButtonColor:"#EF4444"}),i(C,{isOpen:de,onClose:function(){pe(!1),ce(null)},uiConfig:_,onSearchSubscribers:function(e){return new Promise(function(r){nr.current&&(clearTimeout(nr.current),ir.current&&ir.current([])),lr.current&&lr.current.abort(),ir.current=r,nr.current=setTimeout(function(){return t(void 0,void 0,void 0,function(){var t,i,l;return n(this,function(n){switch(n.label){case 0:t=new AbortController,lr.current=t,n.label=1;case 1:return n.trys.push([1,3,4,5]),i=[],[4,z({authBaseUrl:U,accessToken:j},{page:1,limit:50,pagination:!0,search:e.trim()||void 0,isPopulateRoles:!1,isPopulatePermissions:!1,isPopulateApps:!1,isPopulateEnvironments:!1,isPopulateOperations:!1,isPopulateGroups:!1,isPopulateOrganization:!1},t.signal)];case 2:return(l=n.sent())&&l.forEach(function(e){i.push({label:e.email,value:e.email,userId:e._id})}),r(i),[3,5];case 3:return"AbortError"===n.sent().name||console.error("User search failed: An error occurred while querying the user directory."),r([]),[3,5];case 4:return lr.current===t&&(lr.current=null),nr.current=null,ir.current=null,[7];case 5:return[2]}})})},400)})},onSave:function(e,r){return t(void 0,void 0,void 0,function(){var t,i,l,o,a;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,5,,6]),r?(t=null==se?void 0:se.id,[4,E({baseUrl:N,configId:R||"",accessToken:j},t,e)]):[3,2];case 1:return n.sent(),null===(l=tr.current)||void 0===l||l.show({severity:"success",summary:"Success",detail:"Updates saved successfully!",life:3e3}),[3,4];case 2:return[4,P({baseUrl:N,configId:R||"",accessToken:j},e)];case 3:n.sent(),null===(o=tr.current)||void 0===o||o.show({severity:"success",summary:"Success",detail:"Alert created successfully!",life:3e3}),n.label=4;case 4:return sr(),[2,!0];case 5:return i=n.sent(),console.error("Error in handleCreateAlert:",i),null===(a=tr.current)||void 0===a||a.show({severity:"error",summary:"Error",detail:r?"Failed to update alert. Please try again.":"Failed to create alert. Please try again.",life:3e3}),[2,!1];case 6:return[2]}})})},editData:se,plotAndKPIs:Qe,selectedPlot:er,handlePlotSelectionChange:function(e){rr(e)}})]})),ye&&ge&&w(l(o,{children:[i("div",{style:{position:"fixed",inset:0,zIndex:9998},onClick:function(){he(null),me(null)}}),l("div",e({className:"q-alert-kebab-menu",style:{position:"fixed",top:ge.top,left:ge.left,transform:"translateX(-100%)"}},{children:[l("button",e({className:"q-alert-kebab-item",disabled:"FAILED"===ye.status||Se[ye.id],style:{color:"FAILED"===ye.status||Se[ye.id]?"#94a3b8":void 0,cursor:"FAILED"===ye.status||Se[ye.id]?"not-allowed":"pointer"},onClick:function(r){return t(void 0,void 0,void 0,function(){var t,i,l,o,a,s,c,u,d,p,f,y,h;return n(this,function(n){switch(n.label){case 0:if(r.stopPropagation(),"FAILED"===ye.status||Se[ye.id])return[2];t=ye,Ae(function(r){var n;return e(e({},r),((n={})[t.id]=!0,n))}),n.label=1;case 1:return n.trys.push([1,4,5,6]),i=(null===(u=t.status)||void 0===u?void 0:u.toUpperCase())||"",o=(l="PAUSED"===i)?"ACTIVE":"PAUSED",a=t.raw||{},s={name:(null==a?void 0:a.name)||"",kpiKey:(null==a?void 0:a.kpiKey)||"",kpiType:(null==a?void 0:a.kpiType)||"",entityType:(null==a?void 0:a.entityType)||{},conditionType:(null==a?void 0:a.conditionType)||"",thresholdValue:null!==(d=null==a?void 0:a.thresholdValue)&&void 0!==d?d:null,severity:(null==a?void 0:a.severity)||"",evaluationType:(null==a?void 0:a.evaluationType)||"",evaluationPeriod:(null==a?void 0:a.evaluationPeriod)||null,triggerAfter:null!==(p=null==a?void 0:a.triggerAfter)&&void 0!==p?p:0,recipients:(null==a?void 0:a.recipients)||{userIds:[],userEmails:[]},status:o},[4,E({baseUrl:N,configId:R||"",accessToken:j},t.id,s)];case 2:return n.sent(),l?null===(f=tr.current)||void 0===f||f.show({severity:"success",summary:"Success",detail:"Alert resumed successfully!",life:3e3}):null===(y=tr.current)||void 0===y||y.show({severity:"success",summary:"Success",detail:"Alert paused successfully!",life:3e3}),[4,sr()];case 3:return n.sent(),he(null),me(null),[3,6];case 4:return c=n.sent(),console.error(c),null===(h=tr.current)||void 0===h||h.show({severity:"error",summary:"Error",detail:"Failed to update Alert status. Please try again.",life:3e3}),[3,6];case 5:return Ae(function(r){var n;return e(e({},r),((n={})[t.id]=!1,n))}),[7];case 6:return[2]}})})}},{children:[Se[ye.id]?i(p,{size:14,className:"animate-spin"}):"PAUSED"===ye.status?i(f,{size:14}):i(y,{size:14}),"PAUSED"===ye.status?"Resume Alert":"ACTIVE"===ye.status?"Pause Alert":""]})),l("button",e({className:"q-alert-kebab-item danger",onClick:function(e){e.stopPropagation(),ke(ye),he(null),me(null)}},{children:[i(h,{size:14})," Delete"]}))]}))]}),document.body)]})};export{L as AlertsViewTrigger};
2
2
  //# sourceMappingURL=AlertsViewTrigger.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__awaiter as a,__generator as l,__spreadArray as r}from"../../../_virtual/_tslib.js";import{jsx as i,jsxs as t}from"react/jsx-runtime";import{useState as n,useMemo as o,useEffect as s}from"react";import{X as c,Check as d,Info as u,Loader2 as v}from"lucide-react";import p from"../DropDowns/CustomSingleSelect.js";import m from"../DropDowns/CustomMultiSelect.js";var h=function(h){var f=h.isOpen,y=h.onClose,b=h.uiConfig,g=h.onSearchSubscribers,N=h.onSave,q=h.editData,C=h.status,w=n(1),k=w[0],x=w[1],A=(null==b?void 0:b.data)||b,S=o(function(){return((null==A?void 0:A.sidebarFilters)||[]).map(function(e){var a,l;return{id:e.schemaFilterName||e.label,label:e.label,options:(null===(a=e.options)||void 0===a?void 0:a.map(function(e){var a="string"==typeof e?e:void 0!==e.value?e.value:e;return{label:"string"==typeof e?e:e.label||a,value:a}}))||[],scopeType:(null===(l=e.type)||void 0===l?void 0:l.toLowerCase().includes("multi"))?"multiSelect":"singleSelect"}})},[A]),L=o(function(){var e,a=[];return((null===(e=null==A?void 0:A.graphBuilder)||void 0===e?void 0:e.tiers)||[]).forEach(function(e){e.series&&Array.isArray(e.series)&&e.series.forEach(function(e){e.name&&e.key&&a.push({label:e.name,value:e.key})})}),a},[A]),T=n(""),B=T[0],E=T[1],I=n({}),O=I[0],j=I[1],z=n(""),D=z[0],_=z[1],V=n(""),M=V[0],P=V[1],K=n(""),U=K[0],W=K[1],F=n(void 0),R=F[0],G=F[1],Y=n(""),H=Y[0],J=Y[1],Q=n("snapshot"),X=Q[0],Z=Q[1],$=n(""),ee=$[0],ae=$[1],le=n(void 0),re=le[0],ie=le[1],te=n([]),ne=te[0],oe=te[1],se=n(""),ce=se[0],de=se[1],ue=n(!1),ve=ue[0],pe=ue[1],me=n([]),he=me[0],fe=me[1],ye=n(!1),be=ye[0],ge=ye[1],Ne=[{label:"Greater Than",value:"greater_than"},{label:"Less Than",value:"less_than"}];s(function(){var e,a,l,r,i,t,n,o,s,c,d,u,v,p,m;if(f&&pe(!1),f&&q){E(q.alertName||(null===(e=q.raw)||void 0===e?void 0:e.name)||"");var h={},y=q.rawScope||(null===(a=q.raw)||void 0===a?void 0:a.entityType)||{};Object.keys(y).forEach(function(e){var a=S.find(function(a){var l;return(null===(l=a.id)||void 0===l?void 0:l.toLowerCase())===e.toLowerCase()}),l=a?a.id:e,r=y[e];if(a&&a.options)if(Array.isArray(r))r=r.map(function(e){var l=a.options.find(function(a){return String(a.value).toLowerCase()===String(e).toLowerCase()});return l?l.value:e});else{var i=a.options.find(function(e){return String(e.value).toLowerCase()===String(r).toLowerCase()});r=i?i.value:r}h[l]=r}),j(h);var b=(null===(l=q.raw)||void 0===l?void 0:l.kpiKey)||"",g=b,N=L.find(function(e){return String(e.value).toLowerCase()===b.toLowerCase()||e.label.toLowerCase()===b.toLowerCase()});N&&(g=N.value),_(g),P(q.type||(null===(r=q.raw)||void 0===r?void 0:r.kpiType)||"");var C=null===(i=q.raw)||void 0===i?void 0:i.conditionType,w=Ne.find(function(e){return e.value===C||e.value===(">"===C?"greater_than":"<"===C?"less_than":C)});W(w?w.value:C||""),G(void 0!==(null===(t=q.raw)||void 0===t?void 0:t.thresholdValue)&&null!==(null===(n=q.raw)||void 0===n?void 0:n.thresholdValue)?Number(q.raw.thresholdValue):void 0);var k=q.severity||(null===(o=q.raw)||void 0===o?void 0:o.severity)||"";J(k.toLowerCase());var A=(null===(c=null===(s=q.raw)||void 0===s?void 0:s.evaluationType)||void 0===c?void 0:c.toLowerCase())||"";Z("accumulate"===A||"snapshot"===A?A:void 0),ae((null===(d=q.raw)||void 0===d?void 0:d.evaluationPeriod)||""),ie(null!==(v=null===(u=q.raw)||void 0===u?void 0:u.triggerAfter)&&void 0!==v?v:void 0);var T=Array.isArray(q.subscribers)&&q.subscribers.length>0?q.subscribers.map(function(e){return{label:e.label||e.email,value:e.value||e.email,userId:e.userId}}):Array.isArray(null===(m=null===(p=q.raw)||void 0===p?void 0:p.recipients)||void 0===m?void 0:m.userEmails)?q.raw.recipients.userEmails.map(function(e,a){var l;return{label:e,value:e,userId:null===(l=q.raw.recipients.userIds)||void 0===l?void 0:l[a]}}):[];oe(T),x(1)}else f&&!q&&(x(1),E(""),j({}),_(""),P(""),W(""),G(void 0),J(""),Z("snapshot"),ae(""),ie(void 0),oe([]),de(""),fe([]))},[f,q,S]);if(s(function(){!function(e){var a,l;if(e){if(q){var r=q.type||(null===(a=q.raw)||void 0===a?void 0:a.kpiType);if(r)return void P(String(r).toLowerCase())}for(var i="",t=0,n=(null===(l=null==A?void 0:A.graphBuilder)||void 0===l?void 0:l.tiers)||[];t<n.length;t++){var o=n[t];if(o.series&&Array.isArray(o.series)&&o.series.find(function(a){return a.key===e})&&o.plotOptions&&Array.isArray(o.plotOptions)&&o.plotOptions.length>0){i=o.plotOptions[0].value;break}}if(i)P(i);else{var s=e.toLowerCase(),c=L.find(function(e){return e.value.toLowerCase()===s});c&&P(c.value)}}}(D)},[D,L,q]),!f)return null;var qe=function(e,a){if(!e)return a?[]:"";var l=Object.keys(O).find(function(a){return a.toLowerCase()===(null==e?void 0:e.toLowerCase())});if(l&&void 0!==O[l]){var r=O[l];return a?Array.isArray(r)?r:r?[r]:[]:Array.isArray(r)?r.length>0?r[0]:"":r}return a?[]:""},Ce=""!==B.trim(),we=!(""===D||""===U||void 0===R||""===H||void 0===X||"accumulate"===X&&""===ee||"snapshot"===X&&void 0===re);return i("div",e({className:"q-alert-modal-overlay",onClick:ve?void 0:y},{children:t("div",e({className:"q-alert-modal",onClick:function(e){return e.stopPropagation()}},{children:[t("div",e({className:"q-alert-modal-header"},{children:[i("div",e({className:"q-alert-modal-title"},{children:q?"Edit alert":"Create alert"})),i("button",e({className:"q-alert-modal-close",onClick:y,disabled:ve},{children:i(c,{size:14})}))]})),t("div",e({className:"q-alert-stepper"},{children:[t("div",e({className:"q-alert-step ".concat(k>=1?k>1?"completed":"active":"")},{children:[i("div",e({className:"q-alert-step-num"},{children:k>1?i(d,{size:14}):"1"})),"Define Alert"]})),i("div",{className:"q-alert-step-line ".concat(k>1?"completed":"")}),t("div",e({className:"q-alert-step ".concat(k>=2?k>2?"completed":"active":"")},{children:[i("div",e({className:"q-alert-step-num"},{children:k>2?i(d,{size:14}):"2"})),"Configure Alert"]})),i("div",{className:"q-alert-step-line ".concat(k>2?"completed":"")}),t("div",e({className:"q-alert-step ".concat(k>=3?"active":"")},{children:[i("div",e({className:"q-alert-step-num"},{children:"3"})),"Set Recipients"]}))]})),t("div",e({className:"q-alert-modal-body"},{children:[1===k&&t("div",{children:[t("div",e({className:"q-alert-form-group"},{children:[t("label",e({className:"q-alert-form-label"},{children:["Alert name ",i("span",e({className:"req"},{children:"*"}))]})),i("input",{type:"text",className:"q-alert-input",placeholder:"Enter a name so it can be easily identified",value:B,onChange:function(e){return E(e.target.value)}})]})),i("div",{style:{height:"1px",background:"#E2E8F0",margin:"0 0 24px 0"}}),i("label",e({className:"q-alert-form-label"},{children:"Alert Scope"})),i("div",e({className:"q-alert-grid-2"},{children:S.map(function(a){var l,r;return t("div",{children:[i("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:a.label})),"multiSelect"===a.scopeType?i(m,{options:a.options,value:qe(a.id,!0)||[],onChange:function(l){var r,i=Object.keys(O).find(function(e){return e.toLowerCase()===(a.id||"").toLowerCase()});j(e(e({},O),((r={})[i||a.id]=l,r)))},placeholder:"Select ".concat((null===(l=a.label)||void 0===l?void 0:l.toLowerCase())||"")}):i(p,{options:a.options,value:qe(a.id,!1)||"",onChange:function(l){var r,i=Object.keys(O).find(function(e){return e.toLowerCase()===(a.id||"").toLowerCase()});j(e(e({},O),((r={})[i||a.id]=l,r)))},placeholder:"Select ".concat((null===(r=a.label)||void 0===r?void 0:r.toLowerCase())||"")})]},a.id)})}))]}),2===k&&t("div",{children:[t("div",e({className:"q-alert-form-group"},{children:[t("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:["KPI ",i("span",e({className:"req"},{children:"*"}))]})),i(p,{options:L,value:D,onChange:function(e){return _(e)},placeholder:"Select a KPI"})]})),t("div",e({className:"q-alert-form-group"},{children:[i("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:"Threshold Configuration"})),i("div",e({className:"q-alert-form-desc"},{children:"Define the threshold condition that will trigger the alert."})),t("div",e({className:"q-alert-grid-2"},{children:[t("div",{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Condition ",i("span",e({className:"req"},{children:"*"}))]})),i(p,{options:Ne,value:U,onChange:function(e){return W(e)},placeholder:"Select condition"})]}),t("div",{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Value ",i("span",e({className:"req"},{children:"*"}))]})),i("input",{type:"number",className:"q-alert-input",placeholder:"Enter value",value:void 0===R?"":R,onChange:function(e){return G(""===e.target.value?void 0:Number(e.target.value))}})]})]})),t("div",e({style:{marginTop:"16px",width:"calc(50% - 8px)"}},{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Severity ",i("span",e({className:"req"},{children:"*"}))]})),i(p,{options:[{label:"Critical",value:"critical"},{label:"Warning",value:"warning"},{label:"Info",value:"info"}],value:H,onChange:function(e){return J(e)},placeholder:"Select severity"})]}))]})),t("div",e({className:"q-alert-form-group"},{children:[i("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:"Trigger Configuration"})),i("div",e({className:"q-alert-form-desc"},{children:"Who should receive this report?"})),t("div",e({style:{width:"calc(50% - 8px)"}},{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Evaluation Type ",i("span",e({className:"req"},{children:"*"}))," ",i(u,{size:12,style:{display:"inline",color:"#94a3b8"}})]})),i(p,{options:[{label:"Snapshot",value:"snapshot"},{label:"Accumulate",value:"accumulate"}],value:X,onChange:function(e){return Z(e)},placeholder:"Select evaluation type"})]})),"accumulate"===X&&t("div",e({style:{width:"calc(50% - 8px)",marginTop:"16px"}},{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Evaluation period ",i("span",e({className:"req"},{children:"*"}))," ",i(u,{size:12,style:{display:"inline",color:"#94a3b8"}})]})),i(p,{options:[{label:"Daily",value:"daily"},{label:"Weekly",value:"weekly"},{label:"Monthly",value:"monthly"}],value:ee,onChange:function(e){return ae(e)},placeholder:"Select evaluation period"})]})),"snapshot"===X&&t("div",e({style:{width:"calc(50% - 8px)",marginTop:"16px"}},{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Trigger After ",i("span",e({className:"req"},{children:"*"}))," ",i(u,{size:12,style:{display:"inline",color:"#94a3b8"}})]})),i("input",{type:"number",className:"q-alert-input",placeholder:"Enter no. of data points",value:void 0===re?"":re,min:"0",onChange:function(e){return ie(""===e.target.value?void 0:Math.max(0,Number(e.target.value)))}})]}))]}))]}),3===k&&i("div",{children:t("div",e({className:"q-alert-form-group"},{children:[t("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:["Alert Recipients ",i("span",e({className:"req"},{children:"*"}))]})),i("div",e({className:"q-alert-form-desc"},{children:"Add users who should receive an email when this alert is triggered."})),t("div",e({className:"q-alert-search-box",style:{position:"relative"}},{children:[i("input",{type:"text",className:"q-alert-input",placeholder:"Type name or email...",value:ce,onChange:function(e){return a(void 0,void 0,void 0,function(){var a,r;return l(this,function(l){switch(l.label){case 0:if(a=e.target.value,de(a),!a)return fe([]),[2];if(!g)return[3,5];ge(!0),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,g(a)];case 2:return r=l.sent(),fe(r||[]),[3,5];case 3:return l.sent(),fe([]),[3,5];case 4:return ge(!1),[7];case 5:return[2]}})})}}),be&&i("div",e({style:{position:"absolute",right:"12px",top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center"}},{children:i(v,{size:16,className:"animate-spin",color:"#94a3b8"})})),he.length>0&&ce&&i("div",e({className:"q-alert-search-results"},{children:he.map(function(a){return i("div",e({className:"q-alert-search-item",onClick:function(){return function(e){ne.find(function(a){return a.value===e.value})||oe(r(r([],ne,!0),[e],!1)),de(""),fe([])}(a)}},{children:a.label}),a.value)})}))]})),ne.length>0&&i("div",e({className:"q-alert-chips"},{children:ne.map(function(a){return t("div",e({className:"q-alert-chip"},{children:[a.label,i("div",e({className:"q-alert-chip-remove",onClick:function(){return e=a.value,void oe(ne.filter(function(a){return a.value!==e}));var e}},{children:i(c,{size:12,strokeWidth:3})}))]}),a.value)})}))]}))})]})),t("div",e({className:"q-alert-modal-footer"},{children:[i("button",1===k?e({className:"q-alert-btn-cancel",onClick:y,disabled:ve},{children:"Cancel"}):e({className:"q-alert-btn-cancel",onClick:function(){return x(function(e){return Math.max(e-1,1)})},disabled:ve},{children:"Back"})),k<3?t("button",e({className:"q-alert-btn-primary",onClick:function(){return x(function(e){return Math.min(e+1,3)})},disabled:1===k?!Ce:2===k&&!we},{children:["Next ",i("span",e({style:{marginLeft:"4px"}},{children:"→"}))]})):i("button",e({className:"q-alert-btn-primary",onClick:function(){return a(void 0,void 0,void 0,function(){var e,a;return l(this,function(l){switch(l.label){case 0:pe(!0),e={name:B,kpiKey:D,kpiType:M,entityType:O,conditionType:"greater_than"===U?">":"less_than"===U?"<":U,thresholdValue:void 0!==R?Number(R):null,severity:H.toUpperCase(),evaluationType:(null==X?void 0:X.toUpperCase())||"",evaluationPeriod:ee||null,triggerAfter:void 0!==re?Number(re):0,recipients:{userIds:ne.map(function(e){return e.userId}).filter(Boolean),userEmails:ne.map(function(e){return e.value})},status:q?"ACTIVE":C},l.label=1;case 1:return l.trys.push([1,,4,5]),N?[4,N(e,!!(null==q?void 0:q.id)||(null===(a=null==q?void 0:q.raw)||void 0===a?void 0:a.id))]:[3,3];case 2:!1!==l.sent()&&(y(),x(1),E(""),j({}),_(""),P(""),W(""),G(void 0),J(""),ae(""),ie(void 0),oe([]),de("")),l.label=3;case 3:return[3,5];case 4:return pe(!1),[7];case 5:return[2]}})})},disabled:ve||0===ne.length},{children:ve?q?"Updating...":"Creating...":q?"Update alert":"Create alert"}))]}))]}))}))};export{h as default};
1
+ import{__assign as e,__awaiter as l,__generator as a,__spreadArray as r}from"../../../_virtual/_tslib.js";import{jsx as i,jsxs as t,Fragment as n}from"react/jsx-runtime";import{useState as o,useMemo as s,useEffect as c}from"react";import{X as d,Check as u,Info as v,Loader2 as m}from"lucide-react";import p from"../DropDowns/CustomSingleSelect.js";import h from"../DropDowns/CustomMultiSelect.js";import{ChipSelector as f}from"../common/ChipSelector/ChipSelector.js";var b=function(b){var y,g,N,q=b.isOpen,C=b.onClose,w=b.uiConfig,x=b.onSearchSubscribers,k=b.onSave,S=b.editData,A=b.status,T=b.plotAndKPIs,L=b.selectedPlot,B=b.handlePlotSelectionChange,I=o(1),E=I[0],P=I[1],K=(null==w?void 0:w.data)||w,z=s(function(){return((null==K?void 0:K.sidebarFilters)||[]).map(function(e){var l,a;return{id:e.schemaFilterName||e.label,label:e.label,options:(null===(l=e.options)||void 0===l?void 0:l.map(function(e){var l="string"==typeof e?e:void 0!==e.value?e.value:e;return{label:"string"==typeof e?e:e.label||l,value:l}}))||[],scopeType:(null===(a=e.type)||void 0===a?void 0:a.toLowerCase().includes("multi"))?"multiSelect":"singleSelect"}})},[K]),j=o(""),D=j[0],O=j[1],_=o({}),M=_[0],V=_[1],U=o(""),W=U[0],F=U[1],R=o(""),G=R[0],Y=R[1],H=o(""),J=H[0],Q=H[1],X=o(void 0),Z=X[0],$=X[1],ee=o(""),le=ee[0],ae=ee[1],re=o("snapshot"),ie=re[0],te=re[1],ne=o(""),oe=ne[0],se=ne[1],ce=o(void 0),de=ce[0],ue=ce[1],ve=o([]),me=ve[0],pe=ve[1],he=o(""),fe=he[0],be=he[1],ye=o(!1),ge=ye[0],Ne=ye[1],qe=o([]),Ce=qe[0],we=qe[1],xe=o(!1),ke=xe[0],Se=xe[1],Ae=[{label:"Greater Than",value:"greater_than"},{label:"Less Than",value:"less_than"}];c(function(){var e,l,a,r,i,t,n,o,s,c,d,u,v,m,p,h;if(q&&Ne(!1),q&&S){O(S.alertName||(null===(e=S.raw)||void 0===e?void 0:e.name)||"");var f={},b=S.alertScope||(null===(l=S.raw)||void 0===l?void 0:l.alertScope)||{};Object.keys(b).forEach(function(e){var l=z.find(function(l){var a;return(null===(a=l.id)||void 0===a?void 0:a.toLowerCase())===e.toLowerCase()}),a=l?l.id:e,r=b[e];if(l&&l.options)if(Array.isArray(r))r=r.map(function(e){var a=l.options.find(function(l){return String(l.value).toLowerCase()===String(e).toLowerCase()});return a?a.value:e});else{var i=l.options.find(function(e){return String(e.value).toLowerCase()===String(r).toLowerCase()});r=i?i.value:r}f[a]={label:(null==l?void 0:l.label)||e,id:a,data:null==r?void 0:r.data}}),V(f);var y=(null===(a=S.raw)||void 0===a?void 0:a.kpiKey)||"";F(y),Y(S.type||(null===(r=S.raw)||void 0===r?void 0:r.kpiType)||"");var g=null===(i=S.raw)||void 0===i?void 0:i.conditionType,N=Ae.find(function(e){return e.value===g||e.value===(">"===g?"greater_than":"<"===g?"less_than":g)});Q(N?N.value:g||""),$(void 0!==(null===(t=S.raw)||void 0===t?void 0:t.thresholdValue)&&null!==(null===(n=S.raw)||void 0===n?void 0:n.thresholdValue)?Number(S.raw.thresholdValue):void 0);var C=S.severity||(null===(o=S.raw)||void 0===o?void 0:o.severity)||"";ae(C.toLowerCase());var w=(null===(c=null===(s=S.raw)||void 0===s?void 0:s.evaluationType)||void 0===c?void 0:c.toLowerCase())||"";te("accumulate"===w||"snapshot"===w?w:void 0),se((null===(d=S.raw)||void 0===d?void 0:d.evaluationPeriod)||""),ue(null!==(v=null===(u=S.raw)||void 0===u?void 0:u.triggerAfter)&&void 0!==v?v:void 0);var x=Array.isArray(S.subscribers)&&S.subscribers.length>0?S.subscribers.map(function(e){return{label:e.label||e.email,value:e.value||e.email,userId:e.userId}}):Array.isArray(null===(p=null===(m=S.raw)||void 0===m?void 0:m.recipients)||void 0===p?void 0:p.userEmails)?S.raw.recipients.userEmails.map(function(e,l){var a;return{label:e,value:e,userId:null===(a=S.raw.recipients.userIds)||void 0===a?void 0:a[l]}}):[];pe(x),B((null===(h=S.raw)||void 0===h?void 0:h.plotOptionKey)?[S.raw.plotOptionKey]:[]),P(1)}else q&&!S&&(P(1),O(""),V({}),F(""),Y(""),Q(""),$(void 0),ae(""),te("snapshot"),se(""),ue(void 0),pe([]),be(""),we([]))},[q,S,z]);if(c(function(){!function(e){var l;e&&Y(S?null===(l=S.raw)||void 0===l?void 0:l.plotOptionKey:null==L?void 0:L[0])}(W)},[W,S,L]),!q)return null;var Te=function(e,l){if(!e)return l?[]:"";var a=Object.keys(M).find(function(l){return l.toLowerCase()===(null==e?void 0:e.toLowerCase())});if(a&&void 0!==M[a]){var r=M[a].data;return l?Array.isArray(r)?r:r?[r]:[]:Array.isArray(r)?r.length>0?r[0]:"":r}return l?[]:""},Le=""!==D.trim(),Be=!(""===W||""===J||void 0===Z||""===le||void 0===ie||"accumulate"===ie&&""===oe||"snapshot"===ie&&void 0===de),Ie=!!S,Ee=T.map(function(e){return{id:e.key,label:e.label,disabled:Ie}}),Pe=T.reduce(function(e,l){return e[l.key]=l.kpis.filter(function(e){var l;return!(((null===(l=e.threshold)||void 0===l?void 0:l.configured)||!1)&&!Ie)}).map(function(e){return{value:e.key,label:e.label}}),e},{}),Ke=function(l,a){var r,i=Object.keys(M).find(function(e){return e.toLowerCase()===(l.id||"").toLowerCase()});V(e(e({},M),((r={})[i||l.id]={label:(null==l?void 0:l.label)||"",id:l.id,data:a},r)))};return i("div",e({className:"q-alert-modal-overlay",onClick:ge?void 0:C},{children:t("div",e({className:"q-alert-modal",onClick:function(e){return e.stopPropagation()}},{children:[t("div",e({className:"q-alert-modal-header"},{children:[i("div",e({className:"q-alert-modal-title"},{children:S?"Edit alert":"Create alert"})),i("button",e({className:"q-alert-modal-close",onClick:C,disabled:ge},{children:i(d,{size:14})}))]})),t("div",e({className:"q-alert-stepper"},{children:[t("div",e({className:"q-alert-step ".concat(E>=1?E>1?"completed":"active":"")},{children:[i("div",e({className:"q-alert-step-num"},{children:E>1?i(u,{size:14}):"1"})),"Define Alert"]})),i("div",{className:"q-alert-step-line ".concat(E>1?"completed":"")}),t("div",e({className:"q-alert-step ".concat(E>=2?E>2?"completed":"active":"")},{children:[i("div",e({className:"q-alert-step-num"},{children:E>2?i(u,{size:14}):"2"})),"Configure Alert"]})),i("div",{className:"q-alert-step-line ".concat(E>2?"completed":"")}),t("div",e({className:"q-alert-step ".concat(E>=3?"active":"")},{children:[i("div",e({className:"q-alert-step-num"},{children:"3"})),"Set Recipients"]}))]})),t("div",e({className:"q-alert-modal-body"},{children:[1===E&&t("div",{children:[t("div",e({className:"q-alert-form-group"},{children:[t("label",e({className:"q-alert-form-label"},{children:["Alert name ",i("span",e({className:"req"},{children:"*"}))]})),i("input",{type:"text",className:"q-alert-input",placeholder:"Enter a name so it can be easily identified",value:D,onChange:function(e){return O(e.target.value)}})]})),i("div",{style:{height:"1px",background:"#E2E8F0",margin:"0 0 24px 0"}}),i("label",e({className:"q-alert-form-label"},{children:"Alert Scope"})),i("div",e({className:"q-alert-grid-2"},{children:z.map(function(l){var a,r;return t("div",{children:[i("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:l.label})),"multiSelect"===l.scopeType?i(h,{options:l.options,value:Te(l.id,!0)||[],onChange:function(e){return Ke(l,e)},placeholder:"Select ".concat((null===(a=l.label)||void 0===a?void 0:a.toLowerCase())||"")}):i(p,{options:l.options,value:Te(l.id,!1)||"",onChange:function(e){return Ke(l,[e])},placeholder:"Select ".concat((null===(r=l.label)||void 0===r?void 0:r.toLowerCase())||"")})]},l.id)})}))]}),2===E&&t("div",{children:[i("div",e({className:"q-alert-form-group"},{children:Ie?t("div",e({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[i("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:"Plot Metric: "})),i("span",e({className:"q-alert-form-value"},{children:(null===(y=Ee.find(function(e){return e.id===(null==L?void 0:L[0])}))||void 0===y?void 0:y.label)||"N/A"}))]})):t(n,{children:[t("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:["Select the Plot Metric ",i("span",e({className:"req"},{children:"*"}))]})),i(f,{options:Ee,selectedIds:L,onSelectionChange:B,size:"medium",variant:"outlined"})]})})),i("div",e({className:"q-alert-form-group"},{children:Ie?t("div",e({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[i("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:"KPI: "})),i("span",e({className:"q-alert-form-value"},{children:(null===(N=null===(g=Pe[null==L?void 0:L[0]])||void 0===g?void 0:g.find(function(e){return e.value===W}))||void 0===N?void 0:N.label)||"N/A"}))]})):t(n,{children:[t("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:["KPI ",i("span",e({className:"req"},{children:"*"}))]})),i(p,{options:Pe[null==L?void 0:L[0]]||[],value:W,onChange:function(e){return F(e)},placeholder:"Select a KPI",disabledReasonStyle:{fontStyle:"italic"}})]})})),t("div",e({className:"q-alert-form-group"},{children:[i("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:"Threshold Configuration"})),i("div",e({className:"q-alert-form-desc"},{children:"Define the threshold condition that will trigger the alert."})),t("div",e({className:"q-alert-grid-2"},{children:[t("div",{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Condition ",i("span",e({className:"req"},{children:"*"}))]})),i(p,{options:Ae,value:J,onChange:function(e){return Q(e)},placeholder:"Select condition"})]}),t("div",{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Value ",i("span",e({className:"req"},{children:"*"}))]})),i("input",{type:"number",className:"q-alert-input",placeholder:"Enter value",value:void 0===Z?"":Z,onChange:function(e){return $(""===e.target.value?void 0:Number(e.target.value))}})]})]})),t("div",e({style:{marginTop:"16px",width:"calc(50% - 8px)"}},{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Severity ",i("span",e({className:"req"},{children:"*"}))]})),i(p,{options:[{label:"Critical",value:"critical"},{label:"Warning",value:"warning"},{label:"Info",value:"info"}],value:le,onChange:function(e){return ae(e)},placeholder:"Select severity"})]}))]})),t("div",e({className:"q-alert-form-group"},{children:[i("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:"Trigger Configuration"})),i("div",e({className:"q-alert-form-desc"},{children:"Who should receive this report?"})),t("div",e({style:{width:"calc(50% - 8px)"}},{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Evaluation Type ",i("span",e({className:"req"},{children:"*"}))," ",i(v,{size:12,style:{display:"inline",color:"#94a3b8"}})]})),i(p,{options:[{label:"Snapshot",value:"snapshot"},{label:"Accumulate",value:"accumulate"}],value:ie,onChange:function(e){return te(e)},placeholder:"Select evaluation type"})]})),"accumulate"===ie&&t("div",e({style:{width:"calc(50% - 8px)",marginTop:"16px"}},{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Evaluation period ",i("span",e({className:"req"},{children:"*"}))," ",i(v,{size:12,style:{display:"inline",color:"#94a3b8"}})]})),i(p,{options:[{label:"Daily",value:"daily"},{label:"Weekly",value:"weekly"},{label:"Monthly",value:"monthly"}],value:oe,onChange:function(e){return se(e)},placeholder:"Select evaluation period"})]})),"snapshot"===ie&&t("div",e({style:{width:"calc(50% - 8px)",marginTop:"16px"}},{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Trigger After ",i("span",e({className:"req"},{children:"*"}))," ",i(v,{size:12,style:{display:"inline",color:"#94a3b8"}})]})),i("input",{type:"number",className:"q-alert-input",placeholder:"Enter no. of data points",value:void 0===de?"":de,min:"0",onChange:function(e){return ue(""===e.target.value?void 0:Math.max(0,Number(e.target.value)))}})]}))]}))]}),3===E&&i("div",{children:t("div",e({className:"q-alert-form-group"},{children:[t("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:["Alert Recipients ",i("span",e({className:"req"},{children:"*"}))]})),i("div",e({className:"q-alert-form-desc"},{children:"Add users who should receive an email when this alert is triggered."})),t("div",e({className:"q-alert-search-box",style:{position:"relative"}},{children:[i("input",{type:"text",className:"q-alert-input",placeholder:"Type name or email...",value:fe,onChange:function(e){return l(void 0,void 0,void 0,function(){var l,r;return a(this,function(a){switch(a.label){case 0:if(l=e.target.value,be(l),!l)return we([]),[2];if(!x)return[3,5];Se(!0),a.label=1;case 1:return a.trys.push([1,3,4,5]),[4,x(l)];case 2:return r=a.sent(),we(r||[]),[3,5];case 3:return a.sent(),we([]),[3,5];case 4:return Se(!1),[7];case 5:return[2]}})})}}),ke&&i("div",e({style:{position:"absolute",right:"12px",top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center"}},{children:i(m,{size:16,className:"animate-spin",color:"#94a3b8"})})),Ce.length>0&&fe&&i("div",e({className:"q-alert-search-results"},{children:Ce.map(function(l){return i("div",e({className:"q-alert-search-item",onClick:function(){return function(e){me.find(function(l){return l.value===e.value})||pe(r(r([],me,!0),[e],!1)),be(""),we([])}(l)}},{children:l.label}),l.value)})}))]})),me.length>0&&i("div",e({className:"q-alert-chips"},{children:me.map(function(l){return t("div",e({className:"q-alert-chip"},{children:[l.label,i("div",e({className:"q-alert-chip-remove",onClick:function(){return e=l.value,void pe(me.filter(function(l){return l.value!==e}));var e}},{children:i(d,{size:12,strokeWidth:3})}))]}),l.value)})}))]}))})]})),t("div",e({className:"q-alert-modal-footer"},{children:[i("button",1===E?e({className:"q-alert-btn-cancel",onClick:C,disabled:ge},{children:"Cancel"}):e({className:"q-alert-btn-cancel",onClick:function(){return P(function(e){return Math.max(e-1,1)})},disabled:ge},{children:"Back"})),E<3?t("button",e({className:"q-alert-btn-primary",onClick:function(){return P(function(e){return Math.min(e+1,3)})},disabled:1===E?!Le:2===E&&!Be},{children:["Next ",i("span",e({style:{marginLeft:"4px"}},{children:"→"}))]})):i("button",e({className:"q-alert-btn-primary",onClick:function(){return l(void 0,void 0,void 0,function(){var e,l,r,i;return a(this,function(a){switch(a.label){case 0:Ne(!0),e={name:D,kpiKey:W,kpiType:G,alertScope:M,conditionType:"greater_than"===J?">":"less_than"===J?"<":J,thresholdValue:void 0!==Z?Number(Z):null,severity:le.toUpperCase(),evaluationType:(null==ie?void 0:ie.toUpperCase())||"",evaluationPeriod:oe||null,triggerAfter:void 0!==de?Number(de):0,recipients:{userIds:me.map(function(e){return e.userId}).filter(Boolean),userEmails:me.map(function(e){return e.value})},status:S?"ACTIVE":A,plotOptionKey:(null==L?void 0:L[0])||"",kpiLabel:(null===(r=null===(l=T.find(function(e){return e.key===(null==L?void 0:L[0])}))||void 0===l?void 0:l.kpis.find(function(e){return e.key===W}))||void 0===r?void 0:r.label)||""},a.label=1;case 1:return a.trys.push([1,,4,5]),k?[4,k(e,!!(null==S?void 0:S.id)||(null===(i=null==S?void 0:S.raw)||void 0===i?void 0:i.id))]:[3,3];case 2:!1!==a.sent()&&(C(),P(1),O(""),V({}),F(""),Y(""),Q(""),$(void 0),ae(""),se(""),ue(void 0),pe([]),be("")),a.label=3;case 3:return[3,5];case 4:return Ne(!1),[7];case 5:return[2]}})})},disabled:ge||0===me.length},{children:ge?S?"Updating...":"Creating...":S?"Update alert":"Create alert"}))]}))]}))}))};export{b as default};
2
2
  //# sourceMappingURL=CreateAlertModal.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"../../../_virtual/_tslib.js";import{jsxs as n,jsx as r}from"react/jsx-runtime";import{useState as t,useRef as s,useEffect as c,useMemo as a}from"react";import{Search as i}from"lucide-react";function o(o){var l=o.options,u=o.value,d=o.onChange,v=o.placeholder,m=void 0===v?"Select":v,f=o.searchPlaceholder,h=void 0===f?"Search...":f,p=o.disabled,N=void 0!==p&&p,g=t(!1),b=g[0],C=g[1],w=t(""),x=w[0],L=w[1],j=s(null);c(function(){var e=function(e){var n;(null===(n=j.current)||void 0===n?void 0:n.contains(e.target))||C(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}},[]);var k=a(function(){var e=x.trim().toLowerCase();return e?l.filter(function(n){return n.label.toLowerCase().includes(e)}):l},[x,l]),y=a(function(){var e,n;return u&&null!==(n=null===(e=l.find(function(e){return e.value===u}))||void 0===e?void 0:e.label)&&void 0!==n?n:m},[u,l,m]);return n("div",e({className:"css-root",ref:j},{children:[n("button",e({type:"button",disabled:N,className:"css-trigger",onClick:function(){return C(function(e){return!e})}},{children:[r("span",e({className:"css-triggerText ".concat(u?"css-hasValue":"")},{children:y})),r("span",e({className:"css-chevron"},{children:"▾"}))]})),b&&n("div",e({className:"css-panel"},{children:[n("div",e({className:"css-searchRow"},{children:[r(i,{size:18}),r("input",{className:"css-searchInput",placeholder:h,value:x,autoFocus:!0,onChange:function(e){return L(e.target.value)}})]})),r("div",e({className:"css-list"},{children:0===k.length?r("div",e({className:"css-empty"},{children:"No options found"})):k.map(function(n){return r("div",e({className:"css-item ".concat(u===(null==n?void 0:n.value)?"css-selected":""),onClick:function(){return function(e){d(e),C(!1)}(n.value)}},{children:r("span",e({className:"css-itemText"},{children:n.label}))}),n.value)})}))]}))]}))}export{o as default};
1
+ import{__assign as e}from"../../../_virtual/_tslib.js";import{jsxs as n,jsx as s}from"react/jsx-runtime";import{useState as a,useRef as t,useEffect as c,useMemo as i}from"react";import{Search as l}from"lucide-react";function r(r){var o=r.options,d=r.value,u=r.onChange,m=r.placeholder,v=void 0===m?"Select":m,f=r.searchPlaceholder,h=void 0===f?"Search...":f,p=r.disabled,b=void 0!==p&&p,N=r.disabledReasonStyle,g=a(!1),C=g[0],w=g[1],R=a(""),x=R[0],y=R[1],L=t(null);c(function(){var e=function(e){var n;(null===(n=L.current)||void 0===n?void 0:n.contains(e.target))||w(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}},[]);var S=i(function(){var e=x.trim().toLowerCase();return e?o.filter(function(n){return n.label.toLowerCase().includes(e)}):o},[x,o]),j=i(function(){var e,n;return d&&null!==(n=null===(e=o.find(function(e){return e.value===d}))||void 0===e?void 0:e.label)&&void 0!==n?n:v},[d,o,v]);return n("div",e({className:"css-root",ref:L},{children:[n("button",e({type:"button",disabled:b,className:"css-trigger",onClick:function(){return w(function(e){return!e})}},{children:[s("span",e({className:"css-triggerText ".concat(d?"css-hasValue":"")},{children:j})),s("span",e({className:"css-chevron"},{children:"▾"}))]})),C&&n("div",e({className:"css-panel"},{children:[n("div",e({className:"css-searchRow"},{children:[s(l,{size:18}),s("input",{className:"css-searchInput",placeholder:h,value:x,autoFocus:!0,onChange:function(e){return y(e.target.value)}})]})),s("div",e({className:"css-list"},{children:0===S.length?s("div",e({className:"css-empty"},{children:"No options found"})):S.map(function(a){return n("div",e({className:"css-item ".concat(d===(null==a?void 0:a.value)?"css-selected":""," ").concat(a.disabled?"css-item-disabled":""),onClick:function(){a.disabled||function(e){u(e),w(!1)}(a.value)}},{children:[s("span",e({className:"css-itemText"},{children:a.label})),a.disabled&&a.disabledReason&&s("span",e({className:"css-itemDisabledReason",style:N},{children:a.disabledReason}))]}),a.value)})}))]}))]}))}export{r as default};
2
2
  //# sourceMappingURL=CustomSingleSelect.js.map
@@ -1,2 +1,2 @@
1
- import{__rest as l,__spreadArray as i,__assign as e}from"../../../_virtual/_tslib.js";import{jsx as o,jsxs as n}from"react/jsx-runtime";import{useRef as t,useState as r,useEffect as a}from"react";import{DataTable as d}from"primereact/datatable";import{Column as u}from"primereact/column";import{ColumnGroup as c}from"primereact/columngroup";import{Row as s}from"primereact/row";import{Skeleton as m}from"primereact/skeleton";import"primereact/resources/primereact.min.css";import"primeicons/primeicons.css";function v(v){var p,f,h,g,y=v.rows,w=void 0===y?[]:y,N=v.loading,b=v.loadingMore,x=v.onLoadMore,C=v.hasMore,_=v.emptyState,k=v.columns,S=v.tableProps,R=v.onRowClick,E=v.rowDetail,j=v.scrollHeight,T=void 0===j?"flex":j,D=t(null);t(null);var H="function"==typeof(null==E?void 0:E.render),M=r({}),L=M[0],q=M[1],A=function(l){return!(!(null==l?void 0:l.id)||!L[l.id])},B=function(l){(null==l?void 0:l.id)&&q(function(i){var o,n;return(null==E?void 0:E.multiple)?e(e({},i),((o={})[l.id]=!0,o)):((n={})[l.id]=!0,n)})},z=function(l){(null==l?void 0:l.id)&&q(function(i){var o=e({},i);return delete o[l.id],o})},F=function(l){return A(l)?z(l):B(l)},G=null!=S?S:{},K=G.onRowClick,O=G.rowClassName,P=l(G,["onRowClick","rowClassName"]),W=i(i([],w,!0),b?[{id:"__loading-more",__loading:!0}]:[],!0),I=!b&&x&&!1===C&&(null!==(p=null==k?void 0:k.length)&&void 0!==p?p:0)>0?o(c,{children:o(s,{children:o(u,{colSpan:k.length,footer:n("span",e({className:"audit-paginationEndContent"},{children:[o("i",{className:"pi pi-check-circle","aria-hidden":"true"}),"No more records to load"]})),footerClassName:"audit-paginationEnd"})})}):void 0;return a(function(){var l,i=null===(l=D.current)||void 0===l?void 0:l.querySelector(".p-datatable-wrapper");if(i){var e=!1,o=function(){e||(e=!0,requestAnimationFrame(function(){var l=i.scrollTop;i.scrollHeight-l-i.clientHeight<100&&C&&!b&&(null==x||x()),e=!1}))};return i.addEventListener("scroll",o),function(){i.removeEventListener("scroll",o)}}},[w,C,b,x]),N?o("div",{children:i([],Array(5),!0).map(function(l,i){return n("div",e({className:"audit-skeletonRow"},{children:[o(m,{height:0===i?"55px":"25px",width:"25%"}),o(m,{height:0===i?"55px":"25px",width:"50%"}),o(m,{height:0===i?"55px":"25px",width:"25%"})]}),i)})}):w&&0!==w.length?o("div",e({className:"audit-tableWrap",ref:D},{children:o(d,e({value:W,className:"audit-table ".concat(null!==(g=null==S?void 0:S.className)&&void 0!==g?g:""),dataKey:"id",scrollable:!0,scrollHeight:T},P,{rowClassName:function(l,i){var o="function"==typeof O?O(l,i):O,n=!H&&!R||(null==l?void 0:l.__loading)?"":"audit-row--clickable";return o&&"object"==typeof o?e(e({},o),{"audit-row--clickable":!!n}):[o,n].filter(Boolean).join(" ")},expandedRows:L,onRowToggle:function(l){return q(l.data)},rowExpansionTemplate:H?function(l){var i;return!H||(null==l?void 0:l.__loading)?null:o("div",e({className:"audit-rowDetail ".concat(null!==(i=null==E?void 0:E.className)&&void 0!==i?i:""),style:null==E?void 0:E.style},{children:E.render(l,{close:function(){return z(l)}})}))}:void 0,onRowClick:function(l){var i,e,o=null==l?void 0:l.data;if(o&&!o.__loading){var n=null===(i=null==l?void 0:l.originalEvent)||void 0===i?void 0:i.target;(null===(e=null==n?void 0:n.closest)||void 0===e?void 0:e.call(n,"button, a, input, .audit-seeMore"))||(null==R||R(o,{isExpanded:A(o),expand:function(){return B(o)},collapse:function(){return z(o)},toggle:function(){return F(o)}}),H&&!1!==(null==E?void 0:E.expandOnRowClick)&&F(o)),null==K||K(l)}},footerColumnGroup:I},{children:null==k?void 0:k.map(function(l){return o(u,{header:null==l?void 0:l.header,body:function(i){return(null==i?void 0:i.__loading)?o(m,{height:"25px"}):null==l?void 0:l.body(i)},style:null==l?void 0:l.style,headerStyle:null==l?void 0:l.headerStyle,bodyStyle:null==l?void 0:l.bodyStyle,headerClassName:null==l?void 0:l.headerClassName,bodyClassName:null==l?void 0:l.bodyClassName},null==l?void 0:l.key)})}))})):n("div",e({className:"audit-emptyState"},{children:[(null==_?void 0:_.icon)?_.icon:o("i",{className:"pi pi-file",style:{fontSize:"63px",marginBottom:"8px"}}),o("div",e({className:"audit-emptyTitle"},{children:null!==(f=null==_?void 0:_.title)&&void 0!==f?f:"No Data found"})),o("div",e({className:"audit-emptyDesc"},{children:null!==(h=null==_?void 0:_.description)&&void 0!==h?h:"Try adjusting your filters or search criteria."}))]}))}export{v as default};
1
+ import{__rest as l,__spreadArray as e,__assign as i}from"../../../_virtual/_tslib.js";import{jsx as o,jsxs as n}from"react/jsx-runtime";import{useRef as t,useState as r,useEffect as a}from"react";import{DataTable as d}from"primereact/datatable";import{Column as u}from"primereact/column";import{ColumnGroup as c}from"primereact/columngroup";import{Row as s}from"primereact/row";import{Skeleton as p}from"primereact/skeleton";import"primereact/resources/primereact.min.css";import"primeicons/primeicons.css";function m(m){var v,f,h,g,y=m.rows,w=void 0===y?[]:y,N=m.loading,x=m.loadingMore,b=m.onLoadMore,C=m.hasMore,_=m.emptyState,k=m.columns,S=m.tableProps,R=m.onRowClick,E=m.rowDetail,j=m.scrollHeight,T=void 0===j?"flex":j,D=t(null);t(null);var H="function"==typeof(null==E?void 0:E.render),M=r({}),L=M[0],q=M[1],A=function(l){return!(!(null==l?void 0:l.id)||!L[l.id])},B=function(l){(null==l?void 0:l.id)&&q(function(e){var o,n;return(null==E?void 0:E.multiple)?i(i({},e),((o={})[l.id]=!0,o)):((n={})[l.id]=!0,n)})},z=function(l){(null==l?void 0:l.id)&&q(function(e){var o=i({},e);return delete o[l.id],o})},F=function(l){return A(l)?z(l):B(l)},G=null!=S?S:{},K=G.onRowClick,O=G.rowClassName,P=l(G,["onRowClick","rowClassName"]),W=e(e([],w,!0),x?[{id:"__loading-more",__loading:!0}]:[],!0),I=!x&&b&&!1===C&&(null!==(v=null==k?void 0:k.length)&&void 0!==v?v:0)>0?o(c,{children:o(s,{children:o(u,{colSpan:k.length,footer:n("span",i({className:"audit-paginationEndContent"},{children:[o("i",{className:"pi pi-check-circle","aria-hidden":"true"}),"No more records to load"]})),footerClassName:"audit-paginationEnd"})})}):void 0;return a(function(){var l,e=null===(l=D.current)||void 0===l?void 0:l.querySelector(".p-datatable-wrapper");if(e){var i=!1,o=function(){i||(i=!0,requestAnimationFrame(function(){var l=e.scrollTop;e.scrollHeight-l-e.clientHeight<100&&C&&!x&&(null==b||b()),i=!1}))};return e.addEventListener("scroll",o),function(){e.removeEventListener("scroll",o)}}},[w,C,x,b]),N?o("div",{children:e([],Array(5),!0).map(function(l,e){return n("div",i({className:"audit-skeletonRow"},{children:[o(p,{height:0===e?"55px":"25px",width:"25%"}),o(p,{height:0===e?"55px":"25px",width:"50%"}),o(p,{height:0===e?"55px":"25px",width:"25%"})]}),e)})}):w&&0!==w.length?o("div",i({className:"audit-tableWrap",ref:D},{children:o(d,i({value:W,className:"audit-table ".concat(null!==(g=null==S?void 0:S.className)&&void 0!==g?g:""),dataKey:"id",scrollable:!0,scrollHeight:T},P,{rowClassName:function(l,e){var o="function"==typeof O?O(l,e):O,n=!H&&!R||(null==l?void 0:l.__loading)?"":"audit-row--clickable";return o&&"object"==typeof o?i(i({},o),{"audit-row--clickable":!!n}):[o,n].filter(Boolean).join(" ")},expandedRows:L,onRowToggle:function(l){return q(l.data)},rowExpansionTemplate:H?function(l){var e;return!H||(null==l?void 0:l.__loading)?null:o("div",i({className:"audit-rowDetail ".concat(null!==(e=null==E?void 0:E.className)&&void 0!==e?e:""),style:null==E?void 0:E.style},{children:E.render(l,{close:function(){return z(l)}})}))}:void 0,onRowClick:function(l){var e,i,o=null==l?void 0:l.data;if(o&&!o.__loading){var n=null===(e=null==l?void 0:l.originalEvent)||void 0===e?void 0:e.target;(null===(i=null==n?void 0:n.closest)||void 0===i?void 0:i.call(n,"button, a, input, .audit-seeMore"))||(null==R||R(o,{isExpanded:A(o),expand:function(){return B(o)},collapse:function(){return z(o)},toggle:function(){return F(o)}}),H&&!1!==(null==E?void 0:E.expandOnRowClick)&&F(o)),null==K||K(l)}},footerColumnGroup:I},{children:null==k?void 0:k.map(function(l){return o(u,{header:null==l?void 0:l.header,body:function(e){return(null==e?void 0:e.__loading)?o(p,{height:"25px"}):null==l?void 0:l.body(e)},style:null==l?void 0:l.style,headerStyle:null==l?void 0:l.headerStyle,bodyStyle:null==l?void 0:l.bodyStyle,headerClassName:null==l?void 0:l.headerClassName,bodyClassName:null==l?void 0:l.bodyClassName,pt:{bodyCell:{style:{padding:"16px"}},headerCell:{style:{padding:"16px"}}}},null==l?void 0:l.key)})}))})):n("div",i({className:"audit-emptyState"},{children:[(null==_?void 0:_.icon)?_.icon:o("i",{className:"pi pi-file",style:{fontSize:"63px",marginBottom:"8px"}}),o("div",i({className:"audit-emptyTitle"},{children:null!==(f=null==_?void 0:_.title)&&void 0!==f?f:"No Data found"})),o("div",i({className:"audit-emptyDesc"},{children:null!==(h=null==_?void 0:_.description)&&void 0!==h?h:"Try adjusting your filters or search criteria."}))]}))}export{m as default};
2
2
  //# sourceMappingURL=FTable.js.map
@@ -0,0 +1,2 @@
1
+ import{__assign as i,__spreadArray as e}from"../../../../_virtual/_tslib.js";import{jsx as l,jsxs as n}from"react/jsx-runtime";var a=function(a){var c=a.options,t=a.selectedIds,d=void 0===t?[]:t,r=a.onSelectionChange,o=a.multiSelect,s=void 0!==o&&o,u=a.size,p=void 0===u?"medium":u,f=a.variant,m=void 0===f?"default":f,h=a.disabled,v=void 0!==h&&h,b=a.className,N=void 0===b?"":b,g=function(i){if(!v){var l,n=c.find(function(e){return e.id===i});if(!(null==n?void 0:n.disabled))l=s?d.includes(i)?d.filter(function(e){return e!==i}):e(e([],d,!0),[i],!1):d.includes(i)?[]:[i],null==r||r(l)}},z={default:"chip-variant-default",outlined:"chip-variant-outlined",filled:"chip-variant-filled"};return l("div",i({className:"chip-selector ".concat({small:"chip-size-small",medium:"chip-size-medium",large:"chip-size-large"}[p]," ").concat(N),role:"group","aria-label":"Chip selector"},{children:c.map(function(e){var a=d.includes(e.id),c=v||e.disabled;return n("button",i({onClick:function(){return g(e.id)},onKeyDown:function(i){return function(i,e){"Enter"!==i.key&&" "!==i.key||(i.preventDefault(),g(e))}(i,e.id)},disabled:c,className:"chip-button ".concat(z[m]," ").concat(a?"chip-selected":"chip-unselected"," ").concat(c?"chip-disabled":""),"aria-pressed":a,"aria-disabled":c,title:e.label},{children:[e.icon&&l("span",i({className:"chip-icon"},{children:e.icon})),l("span",i({className:"chip-label"},{children:e.label}))]}),e.id)})}))};export{a as ChipSelector,a as default};
2
+ //# sourceMappingURL=ChipSelector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChipSelector.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),r=require("./dashboardApi.js"),t=function(e){try{return e.replace(/\/+$/,"")}catch(r){return e}};function a(t,a,n,s){var o,i;return e.__awaiter(this,void 0,void 0,function(){var c,u;return e.__generator(this,function(e){switch(e.label){case 0:if(!n)throw new r.DashboardApiError("Access token is required.");return[4,fetch(t,{method:"POST",headers:{accept:"application/json","Content-Type":"application/json",Authorization:"Bearer ".concat(n)},body:JSON.stringify(a),signal:s})];case 1:if(!(c=e.sent()).ok)throw new r.DashboardApiError("Request failed with status ".concat(c.status),c.status);return[4,c.json()];case 2:if(!1===(u=e.sent()).success)throw new r.DashboardApiError((null===(o=u.error)||void 0===o?void 0:o.errorMessage)||"Request failed");return[2,null!==(i=u.data)&&void 0!==i?i:u]}})})}function n(t,a,n,s){var o,i;return e.__awaiter(this,void 0,void 0,function(){var c,u;return e.__generator(this,function(e){switch(e.label){case 0:if(!a)throw new r.DashboardApiError("Access token is required.");return[4,fetch(t,{method:"GET",headers:{accept:"application/json",Authorization:"Bearer ".concat(a)},credentials:s?"include":void 0,signal:n})];case 1:if(!(c=e.sent()).ok)throw new r.DashboardApiError("Request failed with status ".concat(c.status),c.status);return[4,c.json()];case 2:if(!1===(u=e.sent()).success)throw new r.DashboardApiError((null===(o=u.error)||void 0===o?void 0:o.errorMessage)||"Request failed");return[2,null!==(i=u.data)&&void 0!==i?i:u]}})})}function s(t,a,n,s){var o,i;return e.__awaiter(this,void 0,void 0,function(){var c,u;return e.__generator(this,function(e){switch(e.label){case 0:if(!n)throw new r.DashboardApiError("Access token is required.");return[4,fetch(t,{method:"PUT",headers:{accept:"application/json","Content-Type":"application/json",Authorization:"Bearer ".concat(n)},body:JSON.stringify(a),signal:s})];case 1:if(!(c=e.sent()).ok)throw new r.DashboardApiError("Request failed with status ".concat(c.status),c.status);return[4,c.json()];case 2:if(!1===(u=e.sent()).success)throw new r.DashboardApiError((null===(o=u.error)||void 0===o?void 0:o.errorMessage)||"Request failed");return[2,null!==(i=u.data)&&void 0!==i?i:u]}})})}function o(t,a,n){var s,o;return e.__awaiter(this,void 0,void 0,function(){var i,c;return e.__generator(this,function(e){switch(e.label){case 0:if(!a)throw new r.DashboardApiError("Access token is required.");return[4,fetch(t,{method:"DELETE",headers:{accept:"application/json",Authorization:"Bearer ".concat(a)},signal:n})];case 1:if(!(i=e.sent()).ok)throw new r.DashboardApiError("Request failed with status ".concat(i.status),i.status);return[4,i.json()];case 2:if(!1===(c=e.sent()).success)throw new r.DashboardApiError((null===(s=c.error)||void 0===s?void 0:s.errorMessage)||"Request failed");return[2,null!==(o=c.data)&&void 0!==o?o:c]}})})}exports.createAlert=function(r,n,s){var o=r.baseUrl,i=void 0===o?"":o,c=r.configId,u=r.accessToken;return e.__awaiter(this,void 0,void 0,function(){var r;return e.__generator(this,function(o){switch(o.label){case 0:return r=e.__assign(e.__assign({},n),{config_id:c}),[4,a("".concat(t(i),"/federated/alerts/").concat(c,"/rules"),r,u,s)];case 1:return[2,o.sent()]}})})},exports.deleteAlert=function(r,a,n){var s=r.baseUrl,i=void 0===s?"":s,c=r.configId,u=r.accessToken;return e.__awaiter(this,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,o("".concat(t(i),"/federated/alerts/").concat(c,"/rules/").concat(a),u,n)];case 1:return[2,e.sent()]}})})},exports.fetchAlertHistory=function(r,a){var s=r.baseUrl,o=void 0===s?"":s,i=r.configId,c=r.accessToken;return e.__awaiter(this,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,n("".concat(t(o),"/federated/alerts/").concat(i,"/history"),c,a)];case 1:return[2,e.sent()]}})})},exports.fetchAlerts=function(r,a){var s=r.baseUrl,o=void 0===s?"":s,i=r.configId,c=r.accessToken;return e.__awaiter(this,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,n("".concat(t(o),"/federated/alerts/").concat(i,"/rules"),c,a)];case 1:return[2,e.sent()]}})})},exports.fetchDistinctSources=function(r,a){var s=r.baseUrl,o=void 0===s?"":s,i=r.configId,c=r.accessToken;return e.__awaiter(this,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,n("".concat(t(o),"/federated/alerts/").concat(i,"/history/sources"),c,a)];case 1:return[2,e.sent()]}})})},exports.getAllUsers=function(a,s,o){var i=a.authBaseUrl,c=void 0===i?"":i,u=a.accessToken,d=void 0===u?"":u;return e.__awaiter(this,void 0,void 0,function(){var a,i;return e.__generator(this,function(e){switch(e.label){case 0:if(!c)throw new r.DashboardApiError("authBaseUrl is required.");return a=new URLSearchParams,s&&Object.entries(s).forEach(function(e){var r=e[0],t=e[1];null!=t&&""!==t&&a.append(r,String(t))}),i=a.toString(),[4,n("".concat(t(c),"/api/user/get-by-query-v2").concat(i?"?"+i:""),d,o,!0)];case 1:return[2,e.sent()]}})})},exports.updateAlert=function(r,a,n,o){var i=r.baseUrl,c=void 0===i?"":i,u=r.configId,d=r.accessToken;return e.__awaiter(this,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,s("".concat(t(c),"/federated/alerts/").concat(u,"/rules/").concat(a),{payload:n},d,o)];case 1:return[2,e.sent()]}})})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),r=require("./dashboardApi.js"),t=function(e){try{return e.replace(/\/+$/,"")}catch(r){return e}};function n(t,n,a,s){var o,i;return e.__awaiter(this,void 0,void 0,function(){var c,u;return e.__generator(this,function(e){switch(e.label){case 0:if(!a)throw new r.DashboardApiError("Access token is required.");return[4,fetch(t,{method:"POST",headers:{accept:"application/json","Content-Type":"application/json",Authorization:"Bearer ".concat(a)},body:JSON.stringify(n),signal:s})];case 1:if(!(c=e.sent()).ok)throw new r.DashboardApiError("Request failed with status ".concat(c.status),c.status);return[4,c.json()];case 2:if(!1===(u=e.sent()).success)throw new r.DashboardApiError((null===(o=u.error)||void 0===o?void 0:o.errorMessage)||"Request failed");return[2,null!==(i=u.data)&&void 0!==i?i:u]}})})}function a(t,n,a,s){var o,i;return e.__awaiter(this,void 0,void 0,function(){var c,u;return e.__generator(this,function(e){switch(e.label){case 0:if(!n)throw new r.DashboardApiError("Access token is required.");return[4,fetch(t,{method:"GET",headers:{accept:"application/json",Authorization:"Bearer ".concat(n)},credentials:s?"include":void 0,signal:a})];case 1:if(!(c=e.sent()).ok)throw new r.DashboardApiError("Request failed with status ".concat(c.status),c.status);return[4,c.json()];case 2:if(!1===(u=e.sent()).success)throw new r.DashboardApiError((null===(o=u.error)||void 0===o?void 0:o.errorMessage)||"Request failed");return[2,null!==(i=u.data)&&void 0!==i?i:u]}})})}function s(t,n,a,s){var o,i;return e.__awaiter(this,void 0,void 0,function(){var c,u;return e.__generator(this,function(e){switch(e.label){case 0:if(!a)throw new r.DashboardApiError("Access token is required.");return[4,fetch(t,{method:"PUT",headers:{accept:"application/json","Content-Type":"application/json",Authorization:"Bearer ".concat(a)},body:JSON.stringify(n),signal:s})];case 1:if(!(c=e.sent()).ok)throw new r.DashboardApiError("Request failed with status ".concat(c.status),c.status);return[4,c.json()];case 2:if(!1===(u=e.sent()).success)throw new r.DashboardApiError((null===(o=u.error)||void 0===o?void 0:o.errorMessage)||"Request failed");return[2,null!==(i=u.data)&&void 0!==i?i:u]}})})}function o(t,n,a){var s,o;return e.__awaiter(this,void 0,void 0,function(){var i,c;return e.__generator(this,function(e){switch(e.label){case 0:if(!n)throw new r.DashboardApiError("Access token is required.");return[4,fetch(t,{method:"DELETE",headers:{accept:"application/json",Authorization:"Bearer ".concat(n)},signal:a})];case 1:if(!(i=e.sent()).ok)throw new r.DashboardApiError("Request failed with status ".concat(i.status),i.status);return[4,i.json()];case 2:if(!1===(c=e.sent()).success)throw new r.DashboardApiError((null===(s=c.error)||void 0===s?void 0:s.errorMessage)||"Request failed");return[2,null!==(o=c.data)&&void 0!==o?o:c]}})})}exports.createAlert=function(r,a,s){var o=r.baseUrl,i=void 0===o?"":o,c=r.configId,u=r.accessToken;return e.__awaiter(this,void 0,void 0,function(){var r;return e.__generator(this,function(o){switch(o.label){case 0:return r=e.__assign(e.__assign({},a),{config_id:c}),[4,n("".concat(t(i),"/federated/alerts/").concat(c,"/rules"),r,u,s)];case 1:return[2,o.sent()]}})})},exports.deleteAlert=function(r,n,a){var s=r.baseUrl,i=void 0===s?"":s,c=r.configId,u=r.accessToken;return e.__awaiter(this,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,o("".concat(t(i),"/federated/alerts/").concat(c,"/rules/").concat(n),u,a)];case 1:return[2,e.sent()]}})})},exports.fetchAlertHistory=function(r,n){var s=r.baseUrl,o=void 0===s?"":s,i=r.configId,c=r.accessToken;return e.__awaiter(this,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,a("".concat(t(o),"/federated/alerts/").concat(i,"/history"),c,n)];case 1:return[2,e.sent()]}})})},exports.fetchAlerts=function(r,n){var s=r.baseUrl,o=void 0===s?"":s,i=r.configId,c=r.accessToken;return e.__awaiter(this,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,a("".concat(t(o),"/federated/alerts/").concat(i,"/rules"),c,n)];case 1:return[2,e.sent()]}})})},exports.fetchDistinctSources=function(r,n){var s=r.baseUrl,o=void 0===s?"":s,i=r.configId,c=r.accessToken;return e.__awaiter(this,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,a("".concat(t(o),"/federated/alerts/").concat(i,"/history/sources"),c,n)];case 1:return[2,e.sent()]}})})},exports.fetchPlotAndKPIs=function(r,n){var s=r.baseUrl,o=void 0===s?"":s,i=r.configId,c=r.accessToken;return e.__awaiter(this,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,a("".concat(t(o),"/federated/alerts/").concat(i,"/plots"),c,n)];case 1:return[2,e.sent()]}})})},exports.getAllUsers=function(n,s,o){var i=n.authBaseUrl,c=void 0===i?"":i,u=n.accessToken,d=void 0===u?"":u;return e.__awaiter(this,void 0,void 0,function(){var n,i;return e.__generator(this,function(e){switch(e.label){case 0:if(!c)throw new r.DashboardApiError("authBaseUrl is required.");return n=new URLSearchParams,s&&Object.entries(s).forEach(function(e){var r=e[0],t=e[1];null!=t&&""!==t&&n.append(r,String(t))}),i=n.toString(),[4,a("".concat(t(c),"/api/user/get-by-query-v2").concat(i?"?"+i:""),d,o,!0)];case 1:return[2,e.sent()]}})})},exports.updateAlert=function(r,n,a,o){var i=r.baseUrl,c=void 0===i?"":i,u=r.configId,d=r.accessToken;return e.__awaiter(this,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,s("".concat(t(c),"/federated/alerts/").concat(u,"/rules/").concat(n),{payload:a},d,o)];case 1:return[2,e.sent()]}})})};
2
2
  //# sourceMappingURL=alertsapi.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),t=require("primereact/toast"),n=require("../common/ConfirmationModal.js"),s=require("lucide-react"),i=require("../TablePage/TablePage.js"),a=require("../FiltersSidebar/FiltersSidebar.js"),l=require("react"),o=require("react-dom"),u=require("./CreateAlertModal.js"),c=require("../../api/alertsapi.js");exports.AlertsViewTrigger=function(d){var p=d.baseUrl,f=d.authBaseUrl,g=d.configId,y=d.onClose,h=d.uiConfig,v=d.accessToken,x=l.useState(""),_=x[0],b=x[1],m=l.useState([]),S=m[0],j=m[1],w=l.useState(!1),A=w[0],C=w[1],k=l.useState([]),E=k[0],F=k[1],T=l.useState(!1),z=T[0],P=T[1],D=l.useState({}),I=D[0],L=D[1],N=l.useState({}),U=N[0],R=N[1],q=l.useState(null),B=q[0],O=q[1],W=l.useState(!1),V=W[0],M=W[1],K=l.useState(null),H=K[0],G=K[1],X=l.useState(null),Y=X[0],J=X[1],Q=l.useRef({}),Z=l.useState({}),$=Z[0],ee=Z[1],re=l.useState(null),te=re[0],ne=re[1],se=l.useState(!1),ie=se[0],ae=se[1],le=l.useState(""),oe=le[0],ue=le[1],ce=l.useState([]),de=ce[0],pe=ce[1],fe=l.useState(!1),ge=fe[0],ye=fe[1],he=l.useState(!1),ve=he[0],xe=he[1],_e=l.useState({}),be=_e[0],me=_e[1],Se=l.useState({}),je=Se[0],we=Se[1],Ae=l.useState("history"),Ce=Ae[0],ke=Ae[1],Ee=l.useRef(null),Fe=l.useRef(null),Te=l.useRef(null),ze=l.useRef(null);function Pe(e){var r=new Date(e);return isNaN(r.getTime())?e:r.toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})}l.useEffect(function(){z&&R(I)},[z,I]),l.useEffect(function(){ve&&we(be)},[ve,be]);var De=function(){return e.__awaiter(void 0,void 0,void 0,function(){var r,t,n,s;return e.__generator(this,function(e){switch(e.label){case 0:C(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,c.fetchAlerts({baseUrl:p,configId:g||"",accessToken:v})];case 2:return r=e.sent(),t=r,j(Array.isArray(t)?t:[]),[3,5];case 3:return n=e.sent(),console.error("Failed to fetch alerts:",n),null===(s=Ee.current)||void 0===s||s.show({severity:"error",summary:"Error",detail:"Failed to load alerts. Please refresh.",life:3e3}),j([]),[3,5];case 4:return C(!1),[7];case 5:return[2]}})})};l.useEffect(function(){De()},[]),l.useEffect(function(){e.__awaiter(void 0,void 0,void 0,function(){var r,t,n,s;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,c.fetchDistinctSources({baseUrl:p,configId:g||"",accessToken:v})];case 1:return r=e.sent(),t=r,F(Array.isArray(t)?t:[]),[3,3];case 2:return n=e.sent(),console.error("Failed to fetch distinct sources:",n),null===(s=Ee.current)||void 0===s||s.show({severity:"error",summary:"Error",detail:"Failed to load data sources.",life:3e3}),[3,3];case 3:return[2]}})})},[]),l.useEffect(function(){var e=!0;return"history"===Ce?(ye(!0),c.fetchAlertHistory({baseUrl:p,configId:g||"",accessToken:v}).then(function(r){e&&pe(r||[])}).catch(function(r){var t;console.error("Error fetching history:",r),null===(t=Ee.current)||void 0===t||t.show({severity:"error",summary:"Error",detail:"Failed to load alert history.",life:3e3}),e&&pe([])}).finally(function(){e&&ye(!1)})):pe([]),function(){e=!1}},[Ce]);var Ie=(Array.isArray(S)?S:[]).map(function(e){var r,t,n,s=e.kpiType?e.kpiType.charAt(0).toUpperCase()+e.kpiType.slice(1):"—",i=e.status?e.status.charAt(0).toUpperCase()+e.status.slice(1):"—",a=(null===(t=null===(r=e.recipients)||void 0===r?void 0:r.userEmails)||void 0===t?void 0:t.map(function(r,t){var n;return{name:r,email:r,value:r,label:r,userId:(null===(n=e.recipients.userIds)||void 0===n?void 0:n[t])||void 0}}))||[],l={">":"Greater than","<":"Less than",">=":"Greater than or equal to","<=":"Less than or equal to"}[e.conditionType]||e.conditionType||"",o=l?"".concat(l," ").concat(e.thresholdValue):"".concat(e.thresholdValue);return{id:e.id,alertName:e.name,type:s,status:i,subscribers:a,raw:e,kpi:(n=e.kpiKey,n?n.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join(" "):"—"),threshold:o,severity:e.severity,createdOn:e.createdAt?Pe(e.createdAt):"—",rawScope:e.entityType,triggerConfig:{"Evaluation Type":e.evaluationType,"Evaluation period":e.evaluationPeriod,"Trigger After":e.triggerAfter?"".concat(e.triggerAfter," data points"):void 0}}}),Le=l.useMemo(function(){return Ie.filter(function(e){var r,t,n=!I.severity||(null===(r=e.severity)||void 0===r?void 0:r.toLowerCase())===I.severity.toLowerCase(),s=!I.status||(null===(t=e.status)||void 0===t?void 0:t.toLowerCase())===I.status.toLowerCase();return n&&s})},[I,Ie]),Ne=l.useMemo(function(){var e=0,r=!1;return Object.entries(be).forEach(function(t){var n=t[0],s=t[1];null===s||""===s||Array.isArray(s)&&0===s.length||("dateFrom"===n||"dateTo"===n?r=!0:e+=Array.isArray(s)?s.length:1)}),r&&(e+=1),e},[be]),Ue=Object.values(I).reduce(function(e,r){return e+(Array.isArray(r)?r.length:r&&""!==r?1:0)},0),Re=[{key:"alertName",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Alert Name"})),body:function(t){return r.jsxs("div",e.__assign({style:{fontWeight:500,display:"flex",alignItems:"center",gap:"8px",color:"#475569",fontSize:"13px"}},{children:[r.jsx("span",e.__assign({className:"q-alert-chevron",style:{cursor:"pointer",display:"flex",padding:"4px"}},{children:r.jsx(s.ChevronRight,{size:16})})),t.alertName||"—"]}))}},{key:"kpi",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"KPI"})),body:function(t){return r.jsx("span",e.__assign({style:{color:"#475569",fontSize:"13px"}},{children:t.kpi||"—"}))}},{key:"threshold",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Threshold"})),body:function(t){return r.jsx("span",e.__assign({style:{color:"#475569",fontSize:"13px",whiteSpace:"nowrap"}},{children:t.threshold||"—"}))}},{key:"severity",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Severity"})),body:function(t){var n=t.severity||"",s=n.charAt(0).toUpperCase()+n.slice(1),i="#F1F5F9",a="#475569";return"critical"===n.toLowerCase()?(i="#FEE2E2",a="#DC2626"):"warning"===n.toLowerCase()&&(i="#FEF3C7",a="#D97706"),r.jsx("span",e.__assign({style:{background:i,color:a,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:600,display:"inline-block"}},{children:s||"—"}))}},{key:"createdOn",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Created on"})),body:function(t){return r.jsx("span",e.__assign({style:{color:"#475569",fontSize:"13px"}},{children:t.createdOn}))}},{key:"status",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Status"})),body:function(t){var n="#F1F5F9",s="#475569",i=t.status||"Active";return"active"===i.toLowerCase()?(n="#DCFCE7",s="#16A34A"):"failed"===i.toLowerCase()?(n="#FEE2E2",s="#DC2626"):"paused"===i.toLowerCase()&&(n="#F1F5F9",s="#64748B"),r.jsx("span",e.__assign({style:{background:n,color:s,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",display:"inline-block"}},{children:i.charAt(0).toUpperCase()+i.slice(1)}))}},{key:"customActions",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Actions"})),body:function(t){var n="Failed"===t.status||"Paused"===t.status;return r.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"nowrap",position:"relative"}},{children:[r.jsxs("button",e.__assign({onClick:function(e){e.stopPropagation(),O(t),M(!0)},style:{background:"white",color:n?"#94A3B8":"#475569",border:"1px solid #cbd5e1",padding:"6px 12px",borderRadius:"6px",fontSize:"13px",display:"flex",alignItems:"center",gap:"6px",cursor:n?"not-allowed":"pointer",fontWeight:500,opacity:n?.6:1,whiteSpace:"nowrap",flexShrink:0},disabled:n},{children:[r.jsx(s.Pencil,{size:12})," Edit Alert"]})),r.jsx("button",e.__assign({ref:function(e){Q.current[t.id]=e},className:"q-alert-kebab-trigger",onClick:function(e){return Me(e,t)}},{children:r.jsx(s.MoreVertical,{size:16})}))]}))}}],qe=[{id:"severity",label:"Severity",type:"singleSelect",options:[{label:"All",value:""},{label:"Critical",value:"critical"},{label:"Warning",value:"warning"},{label:"Info",value:"info"}],value:U.severity||"",onChange:function(r){return R(function(t){return e.__assign(e.__assign({},t),{severity:r})})}},{id:"status",label:"Status",type:"singleSelect",options:[{label:"All",value:""},{label:"Active",value:"active"},{label:"Paused",value:"paused"}],value:U.status||"",onChange:function(r){return R(function(t){return e.__assign(e.__assign({},t),{status:r})})}}],Be=[{key:"no",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"No"})),body:function(t){return r.jsx("span",e.__assign({style:{color:"#475569",fontSize:"13px"}},{children:t.no}))}},{key:"alert_name",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Alert Name"})),body:function(t){return r.jsx("span",e.__assign({style:{color:"#475569",fontSize:"13px"}},{children:t.alert_name}))}},{key:"source",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Source"})),body:function(t){return r.jsx("div",e.__assign({style:{color:"#475569",fontSize:"13px",display:"flex",flexDirection:"column"}},{children:t.source.length>0?r.jsxs(r.Fragment,{children:[r.jsxs("span",{children:[t.source[0]," ",t.source.length>1?"|":""]}),t.source.slice(1).map(function(t,n){return r.jsx("span",e.__assign({style:{fontWeight:600,color:"#0F172A"}},{children:t}),n)})]}):"—"}))}},{key:"severity",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Severity"})),body:function(t){var n=t.severity||"",s=n.charAt(0).toUpperCase()+n.slice(1),i="#F1F5F9",a="#475569";return"critical"===n.toLowerCase()?(i="#FEE2E2",a="#DC2626"):"warning"===n.toLowerCase()&&(i="#FEF3C7",a="#D97706"),r.jsx("span",e.__assign({style:{background:i,color:a,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:600,display:"inline-block"}},{children:s||"—"}))}},{key:"triggered_at",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Triggered at"})),body:function(t){return r.jsx("span",e.__assign({style:{color:"#475569",fontSize:"13px"}},{children:t.triggered_at}))}},{key:"current_value",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Current value"})),body:function(t){return r.jsx("span",e.__assign({style:{color:"#475569",fontSize:"13px"}},{children:t.current_value}))}},{key:"threshold",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Threshold"})),body:function(t){return r.jsx("span",e.__assign({style:{color:"#475569",fontSize:"13px"}},{children:t.threshold}))}}],Oe=l.useMemo(function(){return de.map(function(e,r){return{id:e.historyId||"hist_".concat(r),no:r+1,alert_name:e.title||"—",rawSource:e.source,source:e.source?String(e.source).split("|").map(function(e){return e.trim()}):[],severity:e.severity||"—",triggered_at:e.triggeredAt?Pe(e.triggeredAt):"—",current_value:void 0!==e.currentValue?String(e.currentValue):"—",threshold:void 0!==e.thresholdValue?String(e.thresholdValue):"—"}})},[de]),We=l.useMemo(function(){return Oe.filter(function(e,r){var t,n=!be.severity||(null===(t=e.severity)||void 0===t?void 0:t.toLowerCase())===be.severity.toLowerCase(),s=be.source,i=!s||e.rawSource.includes(s),a=new Date(e.triggered_at),l=!be.dateFrom||a>=be.dateFrom,o=!be.dateTo||a<=be.dateTo;return n&&i&&l&&o})},[be,Oe,de]),Ve=[{id:"source",label:"Source",type:"singleSelect",options:e.__spreadArray([{label:"All",value:""}],(null==E?void 0:E.map(function(e){return{label:e,value:e}}))||[],!0),value:je.source||"",onChange:function(r){return we(function(t){return e.__assign(e.__assign({},t),{source:r})})}},{id:"severity",label:"Severity",type:"singleSelect",options:[{label:"All",value:""},{label:"Critical",value:"critical"},{label:"Warning",value:"warning"},{label:"Info",value:"info"}],value:je.severity||"",onChange:function(r){return we(function(t){return e.__assign(e.__assign({},t),{severity:r})})}},{id:"dateRange",label:"Date range",type:"dateRange",value:{start:je.dateFrom||null,end:je.dateTo||null},onChange:function(r){return we(function(t){var n,s;return e.__assign(e.__assign({},t),{dateFrom:null!==(n=null==r?void 0:r.start)&&void 0!==n?n:null,dateTo:null!==(s=null==r?void 0:r.end)&&void 0!==s?s:null})})}}],Me=l.useCallback(function(e,r){e.stopPropagation(),G(function(e){if((null==e?void 0:e.id)===r.id)return J(null),null;var t=Q.current[r.id];if(t){var n=t.getBoundingClientRect();J({top:n.bottom+4,left:n.right})}return r})},[]);l.useEffect(function(){if(H){var e=function(){G(null),J(null)};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),function(){window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}}},[H]);return"history"===Ce?r.jsx(r.Fragment,{children:r.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",height:"100%",width:"100%"}},{children:[r.jsx("div",{children:r.jsx(i.default,{title:"Alerts",onClose:y,headerCtaLabel:"Manage alerts",onClickHeaderCta:function(){return ke("manage")},styles:{tableWrapper:{border:"1px solid #E2E8F0",borderRadius:"12px",boxShadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",padding:"16px"}},subtitle:"View and track recent alerts generated across your services",search:{value:oe,placeholder:"Search..",searchKey:"alert_name",onChange:ue},filter:{count:Ne,onClick:function(){return xe(!0)}},table:{rows:We,loading:ge,extraColumns:Be,emptyState:{title:"No alerts found",description:"No alerts have been generated yet."},tableProps:{className:"q-alert-hist-log-table"}}})}),r.jsx(a.default,{visible:ve,onHide:function(){return xe(!1)},title:"Filter History",onReset:function(){me({}),we({}),xe(!1)},onApply:function(){me(je),xe(!1)},fields:Ve})]}))}):r.jsxs(r.Fragment,{children:[r.jsx(t.Toast,{ref:Ee,position:"top-right"}),r.jsxs("div",e.__assign({style:{width:"100%"}},{children:[r.jsx(i.default,{title:"Manage Alerts",onClose:function(){return ke("history")},styles:{tableWrapper:{border:"1px solid #E2E8F0",borderRadius:"12px",boxShadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",padding:"16px"}},subtitle:"Set up and manage custom alert triggers to stay updated about your services.",search:{value:_,placeholder:"Search...",searchKey:"alertName",onChange:b},filter:{count:Ue,onClick:function(){return P(!0)}},addAction:{label:"Create Alert",onClick:function(){O(null),M(!0)}},table:{rows:Le,loading:A,extraColumns:Re,hiddenColumns:["logId","modifiedBy","changeSummary","changeDateTime","actions"],emptyState:{title:"No Alerts found",description:"Try creating one."},tableProps:{className:"q-alert-log-table"},onRowClick:function(e,r){r.toggle()},rowDetail:{expandOnRowClick:!1,style:{padding:0,backgroundColor:"transparent"},render:function(t){return r.jsxs("div",e.__assign({style:{padding:"16px 40px",display:"flex",gap:"48px",borderBottom:"1px solid #E2E8F0",background:"#F8FAFC",fontSize:"13px"}},{children:[r.jsxs("div",e.__assign({style:{flex:1,display:"flex",flexDirection:"column",gap:"8px"}},{children:[r.jsx("strong",e.__assign({style:{fontSize:"11px",color:"#64748B",textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Scope"})),r.jsx("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:"4px"}},{children:t.rawScope&&Object.entries(t.rawScope).filter(function(e){return e[0],null!=e[1]}).length>0?Object.entries(t.rawScope).filter(function(e){return e[0],null!=e[1]}).map(function(t){var n=t[0],s=t[1];return r.jsxs("div",e.__assign({style:{display:"flex",gap:"16px",marginBottom:"4px"}},{children:[r.jsx("span",e.__assign({style:{color:"#64748B",width:"120px",whiteSpace:"nowrap"}},{children:n})),r.jsx("span",e.__assign({style:{color:"#0F172A",fontWeight:500}},{children:String(s)}))]}),n)}):r.jsx("div",e.__assign({style:{color:"#94a3b8"}},{children:"No scope defined"}))}))]})),r.jsx("div",{style:{width:"1px",backgroundColor:"#E2E8F0"}}),r.jsxs("div",e.__assign({style:{flex:1,display:"flex",flexDirection:"column",gap:"8px"}},{children:[r.jsx("strong",e.__assign({style:{fontSize:"11px",color:"#64748B",textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Trigger Configuration"})),r.jsx("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:"4px"}},{children:t.triggerConfig&&Object.entries(t.triggerConfig).filter(function(e){return e[0],null!=e[1]}).length>0?Object.entries(t.triggerConfig).filter(function(e){return e[0],null!=e[1]}).map(function(t){var n=t[0],s=t[1];return r.jsxs("div",e.__assign({style:{display:"flex",gap:"16px",marginBottom:"4px"}},{children:[r.jsx("span",e.__assign({style:{color:"#64748B",width:"120px"}},{children:n})),r.jsx("span",e.__assign({style:{color:"#0F172A",fontWeight:500}},{children:String(s)}))]}),n)}):r.jsx("div",e.__assign({style:{color:"#94a3b8"}},{children:"No trigger configuration"}))}))]})),r.jsx("div",{style:{width:"1px",backgroundColor:"#E2E8F0"}}),r.jsxs("div",e.__assign({style:{flex:1,display:"flex",flexDirection:"column",gap:"8px"}},{children:[r.jsx("strong",e.__assign({style:{fontSize:"11px",color:"#64748B",textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Alert Recipients"})),r.jsx("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:"4px"}},{children:t.subscribers&&t.subscribers.length>0?r.jsx("span",e.__assign({style:{color:"#0F172A",fontWeight:500}},{children:(Array.isArray(t.subscribers)?t.subscribers:[t.subscribers]).map(function(e){return"string"==typeof e?e:e.name||e.email||e.label||""}).join(", ")})):r.jsx("div",e.__assign({style:{color:"#94a3b8"}},{children:"No recipients"}))}))]}))]}))}}}}),r.jsx(a.default,{visible:z,onHide:function(){return P(!1)},onReset:function(){R({}),L({}),P(!1)},onApply:function(){L(U),P(!1)},fields:qe}),r.jsx(n.default,{isOpen:!!te,isLoading:ie,onClose:function(){ie||ne(null)},onConfirm:function(){return e.__awaiter(void 0,void 0,void 0,function(){var r,t,n;return e.__generator(this,function(e){switch(e.label){case 0:if(!te)return[2];ae(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,c.deleteAlert({baseUrl:p,configId:g||"",accessToken:v},te.id)];case 2:return e.sent(),null===(t=Ee.current)||void 0===t||t.show({severity:"success",summary:"Success",detail:"Alert deleted successfully!",life:3e3}),De(),ne(null),[3,5];case 3:return r=e.sent(),console.error(r),null===(n=Ee.current)||void 0===n||n.show({severity:"error",summary:"Error",detail:"Failed to delete alert. Please try again.",life:3e3}),[3,5];case 4:return ae(!1),[7];case 5:return[2]}})})},title:"Delete Alert?",message:te?"You'll stop receiving reports for \"".concat(te.alertName,'."'):"",warningText:"This action cannot be undone.",confirmText:"Delete",cancelText:"Cancel",confirmButtonColor:"#EF4444"}),r.jsx(u.default,{isOpen:V,onClose:function(){M(!1),O(null)},uiConfig:h,onSearchSubscribers:function(r){return new Promise(function(t){Fe.current&&(clearTimeout(Fe.current),Te.current&&Te.current([])),ze.current&&ze.current.abort(),Te.current=t,Fe.current=setTimeout(function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,s,i;return e.__generator(this,function(e){switch(e.label){case 0:n=new AbortController,ze.current=n,e.label=1;case 1:return e.trys.push([1,3,4,5]),s=[],[4,c.getAllUsers({authBaseUrl:f,accessToken:v},{page:1,limit:50,pagination:!0,search:r.trim()||void 0,isPopulateRoles:!1,isPopulatePermissions:!1,isPopulateApps:!1,isPopulateEnvironments:!1,isPopulateOperations:!1,isPopulateGroups:!1,isPopulateOrganization:!1},n.signal)];case 2:return(i=e.sent())&&i.forEach(function(e){s.push({label:e.email,value:e.email,userId:e._id})}),t(s),[3,5];case 3:return"AbortError"===e.sent().name||console.error("User search failed: An error occurred while querying the user directory."),t([]),[3,5];case 4:return ze.current===n&&(ze.current=null),Fe.current=null,Te.current=null,[7];case 5:return[2]}})})},400)})},onSave:function(r,t){return e.__awaiter(void 0,void 0,void 0,function(){var n,s,i,a,l;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),t?(n=null==B?void 0:B.id,[4,c.updateAlert({baseUrl:p,configId:g||"",accessToken:v},n,r)]):[3,2];case 1:return e.sent(),null===(i=Ee.current)||void 0===i||i.show({severity:"success",summary:"Success",detail:"Updates saved successfully!",life:3e3}),[3,4];case 2:return[4,c.createAlert({baseUrl:p,configId:g||"",accessToken:v},r)];case 3:e.sent(),null===(a=Ee.current)||void 0===a||a.show({severity:"success",summary:"Success",detail:"Alert created successfully!",life:3e3}),e.label=4;case 4:return De(),[2,!0];case 5:return s=e.sent(),console.error("Error in handleCreateAlert:",s),null===(l=Ee.current)||void 0===l||l.show({severity:"error",summary:"Error",detail:t?"Failed to update alert. Please try again.":"Failed to create alert. Please try again.",life:3e3}),[2,!1];case 6:return[2]}})})},editData:B})]})),H&&Y&&o.createPortal(r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{position:"fixed",inset:0,zIndex:9998},onClick:function(){G(null),J(null)}}),r.jsxs("div",e.__assign({className:"q-alert-kebab-menu",style:{position:"fixed",top:Y.top,left:Y.left,transform:"translateX(-100%)"}},{children:[r.jsxs("button",e.__assign({className:"q-alert-kebab-item",disabled:"FAILED"===H.status||$[H.id],style:{color:"FAILED"===H.status||$[H.id]?"#94a3b8":void 0,cursor:"FAILED"===H.status||$[H.id]?"not-allowed":"pointer"},onClick:function(r){return e.__awaiter(void 0,void 0,void 0,function(){var t,n,s,i,a,l,o,u,d,f,y,h,x;return e.__generator(this,function(_){switch(_.label){case 0:if(r.stopPropagation(),"FAILED"===H.status||$[H.id])return[2];t=H,ee(function(r){var n;return e.__assign(e.__assign({},r),((n={})[t.id]=!0,n))}),_.label=1;case 1:return _.trys.push([1,4,5,6]),n=(null===(u=t.status)||void 0===u?void 0:u.toUpperCase())||"",i=(s="PAUSED"===n)?"ACTIVE":"PAUSED",a=t.raw||{},l={name:(null==a?void 0:a.name)||"",kpiKey:(null==a?void 0:a.kpiKey)||"",kpiType:(null==a?void 0:a.kpiType)||"",entityType:(null==a?void 0:a.entityType)||{},conditionType:(null==a?void 0:a.conditionType)||"",thresholdValue:null!==(d=null==a?void 0:a.thresholdValue)&&void 0!==d?d:null,severity:(null==a?void 0:a.severity)||"",evaluationType:(null==a?void 0:a.evaluationType)||"",evaluationPeriod:(null==a?void 0:a.evaluationPeriod)||null,triggerAfter:null!==(f=null==a?void 0:a.triggerAfter)&&void 0!==f?f:0,recipients:(null==a?void 0:a.recipients)||{userIds:[],userEmails:[]},status:i},[4,c.updateAlert({baseUrl:p,configId:g||"",accessToken:v},t.id,l)];case 2:return _.sent(),s?null===(y=Ee.current)||void 0===y||y.show({severity:"success",summary:"Success",detail:"Alert resumed successfully!",life:3e3}):null===(h=Ee.current)||void 0===h||h.show({severity:"success",summary:"Success",detail:"Alert paused successfully!",life:3e3}),[4,De()];case 3:return _.sent(),G(null),J(null),[3,6];case 4:return o=_.sent(),console.error(o),null===(x=Ee.current)||void 0===x||x.show({severity:"error",summary:"Error",detail:"Failed to update Alert status. Please try again.",life:3e3}),[3,6];case 5:return ee(function(r){var n;return e.__assign(e.__assign({},r),((n={})[t.id]=!1,n))}),[7];case 6:return[2]}})})}},{children:[$[H.id]?r.jsx(s.Loader2,{size:14,className:"animate-spin"}):"PAUSED"===H.status?r.jsx(s.Play,{size:14}):r.jsx(s.Pause,{size:14}),"PAUSED"===H.status?"Resume Alert":"ACTIVE"===H.status?"Pause Alert":""]})),r.jsxs("button",e.__assign({className:"q-alert-kebab-item danger",onClick:function(e){e.stopPropagation(),ne(H),G(null),J(null)}},{children:[r.jsx(s.Trash2,{size:14})," Delete"]}))]}))]}),document.body)]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),t=require("primereact/toast"),n=require("../common/ConfirmationModal.js"),s=require("lucide-react"),i=require("../TablePage/TablePage.js"),a=require("../FiltersSidebar/FiltersSidebar.js"),l=require("react"),o=require("react-dom"),u=require("./CreateAlertModal.js"),c=require("../../api/alertsapi.js");exports.AlertsViewTrigger=function(d){var p=d.baseUrl,f=d.authBaseUrl,g=d.configId,y=d.onClose,h=d.uiConfig,v=d.accessToken,x=l.useState(""),_=x[0],b=x[1],m=l.useState([]),S=m[0],j=m[1],A=l.useState(!1),w=A[0],C=A[1],k=l.useState([]),F=k[0],E=k[1],T=l.useState(!1),P=T[0],z=T[1],D=l.useState({}),I=D[0],L=D[1],N=l.useState({}),U=N[0],R=N[1],q=l.useState(null),B=q[0],O=q[1],W=l.useState(!1),V=W[0],M=W[1],K=l.useState(null),H=K[0],G=K[1],X=l.useState(null),Y=X[0],J=X[1],Q=l.useRef({}),Z=l.useState({}),$=Z[0],ee=Z[1],re=l.useState(null),te=re[0],ne=re[1],se=l.useState(!1),ie=se[0],ae=se[1],le=l.useState(""),oe=le[0],ue=le[1],ce=l.useState([]),de=ce[0],pe=ce[1],fe=l.useState(!1),ge=fe[0],ye=fe[1],he=l.useState(!1),ve=he[0],xe=he[1],_e=l.useState({}),be=_e[0],me=_e[1],Se=l.useState({}),je=Se[0],Ae=Se[1],we=l.useState("history"),Ce=we[0],ke=we[1],Fe=l.useState([]),Ee=Fe[0],Te=Fe[1],Pe=l.useState([]),ze=Pe[0],De=Pe[1],Ie=l.useRef(null),Le=l.useRef(null),Ne=l.useRef(null),Ue=l.useRef(null);function Re(e){var r=new Date(e);return isNaN(r.getTime())?e:r.toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})}l.useEffect(function(){P&&R(I)},[P,I]),l.useEffect(function(){ve&&Ae(be)},[ve,be]);var qe=function(){return e.__awaiter(void 0,void 0,void 0,function(){var r,t,n,s;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,c.fetchDistinctSources({baseUrl:p,configId:g||"",accessToken:v})];case 1:return r=e.sent(),t=r,E(Array.isArray(t)?t:[]),[3,3];case 2:return n=e.sent(),console.error("Failed to fetch distinct sources:",n),null===(s=Ie.current)||void 0===s||s.show({severity:"error",summary:"Error",detail:"Failed to load data sources.",life:3e3}),[3,3];case 3:return[2]}})})};function Be(){e.__awaiter(void 0,void 0,void 0,function(){var r,t,n,s;return e.__generator(this,function(e){switch(e.label){case 0:C(!0),G(null),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,c.fetchAlerts({baseUrl:p,configId:g||"",accessToken:v})];case 2:return r=e.sent(),t=r,j(Array.isArray(t)?t:[]),[3,5];case 3:return n=e.sent(),console.error("Failed to fetch alerts:",n),null===(s=Ie.current)||void 0===s||s.show({severity:"error",summary:"Error",detail:"Failed to load alerts. Please refresh.",life:3e3}),j([]),[3,5];case 4:return C(!1),[7];case 5:return[2]}})}),e.__awaiter(void 0,void 0,void 0,function(){var r,t,n,s;return e.__generator(this,function(e){switch(e.label){case 0:C(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,c.fetchPlotAndKPIs({baseUrl:p,configId:g||"",accessToken:v})];case 2:return r=e.sent(),t=r,Te(Array.isArray(t)?t:[]),[3,5];case 3:return n=e.sent(),console.error("Failed to fetch plots & KPI's:",n),null===(s=Ie.current)||void 0===s||s.show({severity:"error",summary:"Error",detail:"Failed to load plots & KPIs. Please refresh.",life:3e3}),Te([]),[3,5];case 4:return C(!1),[7];case 5:return[2]}})}),qe()}l.useEffect(function(){Be()},[]),l.useEffect(function(){var e=!0;return"history"===Ce?(ye(!0),c.fetchAlertHistory({baseUrl:p,configId:g||"",accessToken:v}).then(function(r){e&&pe(r||[])}).catch(function(r){var t;console.error("Error fetching history:",r),null===(t=Ie.current)||void 0===t||t.show({severity:"error",summary:"Error",detail:"Failed to load alert history.",life:3e3}),e&&pe([])}).finally(function(){e&&ye(!1)}),qe()):pe([]),function(){e=!1}},[Ce]);var Oe=(Array.isArray(S)?S:[]).map(function(e){var r,t,n=e.kpiType?e.kpiType.charAt(0).toUpperCase()+e.kpiType.slice(1):"—",s=e.status?e.status.charAt(0).toUpperCase()+e.status.slice(1):"—",i=(null===(t=null===(r=e.recipients)||void 0===r?void 0:r.userEmails)||void 0===t?void 0:t.map(function(r,t){var n;return{name:r,email:r,value:r,label:r,userId:(null===(n=e.recipients.userIds)||void 0===n?void 0:n[t])||void 0}}))||[],a={">":"Greater than","<":"Less than",">=":"Greater than or equal to","<=":"Less than or equal to"}[e.conditionType]||e.conditionType||"",l=a?"".concat(a," ").concat(e.thresholdValue):"".concat(e.thresholdValue);return{id:e.id,alertName:e.name,type:n,status:s,subscribers:i,raw:e,kpi:e.kpiLabel,threshold:l,severity:e.severity,createdOn:e.createdAt?Re(e.createdAt):"—",alertScope:e.alertScope,triggerConfig:{"Evaluation Type":e.evaluationType,"Evaluation period":e.evaluationPeriod,"Trigger After":e.triggerAfter?"".concat(e.triggerAfter," data points"):void 0}}}),We=l.useMemo(function(){return Oe.filter(function(e){var r,t,n=!I.severity||(null===(r=e.severity)||void 0===r?void 0:r.toLowerCase())===I.severity.toLowerCase(),s=!I.status||(null===(t=e.status)||void 0===t?void 0:t.toLowerCase())===I.status.toLowerCase();return n&&s})},[I,Oe]),Ve=l.useMemo(function(){var e=0,r=!1;return Object.entries(be).forEach(function(t){var n=t[0],s=t[1];null===s||""===s||Array.isArray(s)&&0===s.length||("dateFrom"===n||"dateTo"===n?r=!0:e+=Array.isArray(s)?s.length:1)}),r&&(e+=1),e},[be]),Me=Object.values(I).reduce(function(e,r){return e+(Array.isArray(r)?r.length:r&&""!==r?1:0)},0),Ke=[{key:"alertName",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Alert Name"})),body:function(t){return r.jsxs("div",e.__assign({style:{fontWeight:500,display:"flex",alignItems:"center",gap:"8px",color:"#475569",fontSize:"13px"}},{children:[r.jsx("span",e.__assign({className:"q-alert-chevron",style:{cursor:"pointer",display:"flex",padding:"4px"}},{children:r.jsx(s.ChevronRight,{size:16})})),t.alertName||"—"]}))}},{key:"kpi",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"KPI"})),body:function(t){return r.jsx("span",e.__assign({style:{color:"#475569",fontSize:"13px"}},{children:t.kpi||"—"}))}},{key:"threshold",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Threshold"})),body:function(t){return r.jsx("span",e.__assign({style:{color:"#475569",fontSize:"13px",whiteSpace:"nowrap"}},{children:t.threshold||"—"}))}},{key:"severity",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Severity"})),body:function(t){var n=t.severity||"",s=n.charAt(0).toUpperCase()+n.slice(1),i="#F1F5F9",a="#475569";return"critical"===n.toLowerCase()?(i="#FEE2E2",a="#DC2626"):"warning"===n.toLowerCase()&&(i="#FEF3C7",a="#D97706"),r.jsx("span",e.__assign({style:{background:i,color:a,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:600,display:"inline-block"}},{children:s||"—"}))}},{key:"createdOn",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Created on"})),body:function(t){return r.jsx("span",e.__assign({style:{color:"#475569",fontSize:"13px"}},{children:t.createdOn}))}},{key:"status",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Status"})),body:function(t){var n="#F1F5F9",s="#475569",i=t.status||"Active";return"active"===i.toLowerCase()?(n="#DCFCE7",s="#16A34A"):"failed"===i.toLowerCase()?(n="#FEE2E2",s="#DC2626"):"paused"===i.toLowerCase()&&(n="#F1F5F9",s="#64748B"),r.jsx("span",e.__assign({style:{background:n,color:s,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",display:"inline-block"}},{children:i.charAt(0).toUpperCase()+i.slice(1)}))}},{key:"customActions",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Actions"})),body:function(t){var n="Failed"===t.status||"Paused"===t.status;return r.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"nowrap",position:"relative"}},{children:[r.jsxs("button",e.__assign({onClick:function(e){e.stopPropagation(),O(t),M(!0)},style:{background:"white",color:n?"#94A3B8":"#475569",border:"1px solid #cbd5e1",padding:"6px 12px",borderRadius:"6px",fontSize:"13px",display:"flex",alignItems:"center",gap:"6px",cursor:n?"not-allowed":"pointer",fontWeight:500,opacity:n?.6:1,whiteSpace:"nowrap",flexShrink:0},disabled:n},{children:[r.jsx(s.Pencil,{size:12})," Edit Alert"]})),r.jsx("button",e.__assign({ref:function(e){Q.current[t.id]=e},className:"q-alert-kebab-trigger",onClick:function(e){return Qe(e,t)}},{children:r.jsx(s.MoreVertical,{size:16})}))]}))}}],He=[{id:"severity",label:"Severity",type:"singleSelect",options:[{label:"All",value:""},{label:"Critical",value:"critical"},{label:"Warning",value:"warning"},{label:"Info",value:"info"}],value:U.severity||"",onChange:function(r){return R(function(t){return e.__assign(e.__assign({},t),{severity:r})})}},{id:"status",label:"Status",type:"singleSelect",options:[{label:"All",value:""},{label:"Active",value:"active"},{label:"Paused",value:"paused"}],value:U.status||"",onChange:function(r){return R(function(t){return e.__assign(e.__assign({},t),{status:r})})}}],Ge=[{key:"no",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"No"})),body:function(t){return r.jsx("span",e.__assign({style:{color:"#475569",fontSize:"13px"}},{children:t.no}))}},{key:"alert_name",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Alert Name"})),body:function(t){return r.jsx("span",e.__assign({style:{color:"#475569",fontSize:"13px"}},{children:t.alert_name}))}},{key:"source",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Source"})),body:function(t){return r.jsx("div",e.__assign({style:{color:"#475569",fontSize:"13px",display:"flex",flexDirection:"column"}},{children:t.source.length>0?r.jsxs(r.Fragment,{children:[r.jsxs("span",{children:[t.source[0]," ",t.source.length>1?"|":""]}),t.source.slice(1).map(function(t,n){return r.jsx("span",e.__assign({style:{fontWeight:600,color:"#0F172A"}},{children:t}),n)})]}):"—"}))}},{key:"severity",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Severity"})),body:function(t){var n=t.severity||"",s=n.charAt(0).toUpperCase()+n.slice(1),i="#F1F5F9",a="#475569";return"critical"===n.toLowerCase()?(i="#FEE2E2",a="#DC2626"):"warning"===n.toLowerCase()&&(i="#FEF3C7",a="#D97706"),r.jsx("span",e.__assign({style:{background:i,color:a,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:600,display:"inline-block"}},{children:s||"—"}))}},{key:"triggered_at",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Triggered at"})),body:function(t){return r.jsx("span",e.__assign({style:{color:"#475569",fontSize:"13px"}},{children:t.triggered_at}))}},{key:"current_value",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Triggered value"})),body:function(t){return r.jsx("span",e.__assign({style:{color:"#475569",fontSize:"13px"}},{children:t.current_value}))}},{key:"threshold",header:r.jsx("span",e.__assign({style:{fontSize:"13px"}},{children:"Threshold"})),body:function(t){return r.jsx("span",e.__assign({style:{color:"#475569",fontSize:"13px"}},{children:t.threshold}))}}],Xe=l.useMemo(function(){return de.map(function(e,r){return{id:e.historyId||"hist_".concat(r),no:r+1,alert_name:e.title||"—",rawSource:e.source,source:e.source?String(e.source).split("|").map(function(e){return e.trim()}):[],severity:e.severity||"—",triggered_at:e.triggeredAt?Re(e.triggeredAt):"—",current_value:void 0!==e.currentValue?String(e.currentValue):"—",threshold:void 0!==e.thresholdValue?String(e.thresholdValue):"—"}})},[de]),Ye=l.useMemo(function(){return Xe.filter(function(e,r){var t,n=!be.severity||(null===(t=e.severity)||void 0===t?void 0:t.toLowerCase())===be.severity.toLowerCase(),s=be.source,i=!s||e.rawSource.includes(s),a=new Date(e.triggered_at),l=!be.dateFrom||a>=be.dateFrom,o=!be.dateTo||a<=be.dateTo;return n&&i&&l&&o})},[be,Xe,de]),Je=[{id:"source",label:"Source",type:"singleSelect",options:e.__spreadArray([{label:"All",value:""}],(null==F?void 0:F.map(function(e){return{label:e,value:e}}))||[],!0),value:je.source||"",onChange:function(r){return Ae(function(t){return e.__assign(e.__assign({},t),{source:r})})}},{id:"severity",label:"Severity",type:"singleSelect",options:[{label:"All",value:""},{label:"Critical",value:"critical"},{label:"Warning",value:"warning"},{label:"Info",value:"info"}],value:je.severity||"",onChange:function(r){return Ae(function(t){return e.__assign(e.__assign({},t),{severity:r})})}},{id:"dateRange",label:"Date range",type:"dateRange",value:{start:je.dateFrom||null,end:je.dateTo||null},onChange:function(r){return Ae(function(t){var n,s;return e.__assign(e.__assign({},t),{dateFrom:null!==(n=null==r?void 0:r.start)&&void 0!==n?n:null,dateTo:null!==(s=null==r?void 0:r.end)&&void 0!==s?s:null})})}}],Qe=l.useCallback(function(e,r){e.stopPropagation(),G(function(e){if((null==e?void 0:e.id)===r.id)return J(null),null;var t=Q.current[r.id];if(t){var n=t.getBoundingClientRect();J({top:n.bottom+4,left:n.right})}return r})},[]);l.useEffect(function(){if(H){var e=function(){G(null),J(null)};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),function(){window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}}},[H]);return"history"===Ce?r.jsx(r.Fragment,{children:r.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",height:"100%",width:"100%"}},{children:[r.jsx("div",{children:r.jsx(i.default,{title:"Alerts",onClose:y,headerCtaLabel:"Manage alerts",onClickHeaderCta:function(){return ke("manage")},styles:{tableWrapper:{border:"1px solid #E2E8F0",borderRadius:"12px",boxShadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",padding:"16px"}},subtitle:"View and track recent alerts generated across your services",search:{value:oe,placeholder:"Search..",searchKey:"alert_name",onChange:ue},filter:{count:Ve,onClick:function(){return xe(!0)}},table:{rows:Ye,loading:ge,extraColumns:Ge,emptyState:{title:"No alerts found",description:"No alerts have been generated yet."},tableProps:{className:"q-alert-hist-log-table"}}})}),r.jsx(a.default,{visible:ve,onHide:function(){return xe(!1)},title:"Filter History",onReset:function(){me({}),Ae({}),xe(!1)},onApply:function(){me(je),xe(!1)},fields:Je})]}))}):r.jsxs(r.Fragment,{children:[r.jsx(t.Toast,{ref:Ie,position:"top-right"}),r.jsxs("div",e.__assign({style:{width:"100%"}},{children:[r.jsx(i.default,{title:"Manage Alerts",onClose:function(){return ke("history")},styles:{tableWrapper:{border:"1px solid #E2E8F0",borderRadius:"12px",boxShadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",padding:"16px"}},subtitle:"Set up and manage custom alert triggers to stay updated about your services.",search:{value:_,placeholder:"Search...",searchKey:"alertName",onChange:b},filter:{count:Me,onClick:function(){return z(!0)}},addAction:{label:"Create Alert",onClick:function(){O(null),M(!0)}},table:{rows:We,loading:w,extraColumns:Ke,hiddenColumns:["logId","modifiedBy","changeSummary","changeDateTime","actions"],emptyState:{title:"No Alerts found",description:"Try creating one."},tableProps:{className:"q-alert-log-table"},onRowClick:function(e,r){r.toggle()},rowDetail:{expandOnRowClick:!1,style:{padding:0,backgroundColor:"transparent"},render:function(t){return r.jsxs("div",e.__assign({style:{padding:"16px 40px",display:"flex",gap:"48px",borderBottom:"1px solid #E2E8F0",background:"#F8FAFC",fontSize:"13px"}},{children:[r.jsxs("div",e.__assign({style:{flex:1,display:"flex",flexDirection:"column",gap:"8px"}},{children:[r.jsx("strong",e.__assign({style:{fontSize:"11px",color:"#64748B",textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Scope"})),r.jsx("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:"4px"}},{children:t.alertScope&&Object.entries(t.alertScope).filter(function(e){return e[0],null!=e[1]}).length>0?Object.entries(t.alertScope).filter(function(e){return e[0],null!=e[1].data}).map(function(t){var n=t[0],s=t[1];return r.jsxs("div",e.__assign({style:{display:"flex",gap:"16px",marginBottom:"4px"}},{children:[r.jsx("span",e.__assign({style:{color:"#64748B",width:"120px",whiteSpace:"nowrap"}},{children:s.label})),r.jsx("span",e.__assign({style:{color:"#0F172A",fontWeight:500}},{children:s.data.map(function(e,r){var t;return"".concat(e).concat(r!==(null===(t=s.data)||void 0===t?void 0:t.length)-1?", ":"")})}))]}),n)}):r.jsx("div",e.__assign({style:{color:"#94a3b8"}},{children:"No scope defined"}))}))]})),r.jsx("div",{style:{width:"1px",backgroundColor:"#E2E8F0"}}),r.jsxs("div",e.__assign({style:{flex:1,display:"flex",flexDirection:"column",gap:"8px"}},{children:[r.jsx("strong",e.__assign({style:{fontSize:"11px",color:"#64748B",textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Trigger Configuration"})),r.jsx("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:"4px"}},{children:t.triggerConfig&&Object.entries(t.triggerConfig).filter(function(e){return e[0],null!=e[1]}).length>0?Object.entries(t.triggerConfig).filter(function(e){return e[0],null!=e[1]}).map(function(t){var n=t[0],s=t[1];return r.jsxs("div",e.__assign({style:{display:"flex",gap:"16px",marginBottom:"4px"}},{children:[r.jsx("span",e.__assign({style:{color:"#64748B",width:"120px"}},{children:n})),r.jsx("span",e.__assign({style:{color:"#0F172A",fontWeight:500}},{children:String(s)}))]}),n)}):r.jsx("div",e.__assign({style:{color:"#94a3b8"}},{children:"No trigger configuration"}))}))]})),r.jsx("div",{style:{width:"1px",backgroundColor:"#E2E8F0"}}),r.jsxs("div",e.__assign({style:{flex:1,display:"flex",flexDirection:"column",gap:"8px"}},{children:[r.jsx("strong",e.__assign({style:{fontSize:"11px",color:"#64748B",textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Alert Recipients"})),r.jsx("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:"4px"}},{children:t.subscribers&&t.subscribers.length>0?r.jsx("span",e.__assign({style:{color:"#0F172A",fontWeight:500}},{children:(Array.isArray(t.subscribers)?t.subscribers:[t.subscribers]).map(function(e){return"string"==typeof e?e:e.name||e.email||e.label||""}).join(", ")})):r.jsx("div",e.__assign({style:{color:"#94a3b8"}},{children:"No recipients"}))}))]}))]}))}}}}),r.jsx(a.default,{visible:P,onHide:function(){return z(!1)},onReset:function(){R({}),L({}),z(!1)},onApply:function(){L(U),z(!1)},fields:He}),r.jsx(n.default,{isOpen:!!te,isLoading:ie,onClose:function(){ie||ne(null)},onConfirm:function(){return e.__awaiter(void 0,void 0,void 0,function(){var r,t,n;return e.__generator(this,function(e){switch(e.label){case 0:if(!te)return[2];ae(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,c.deleteAlert({baseUrl:p,configId:g||"",accessToken:v},te.id)];case 2:return e.sent(),null===(t=Ie.current)||void 0===t||t.show({severity:"success",summary:"Success",detail:"Alert deleted successfully!",life:3e3}),Be(),ne(null),[3,5];case 3:return r=e.sent(),console.error(r),null===(n=Ie.current)||void 0===n||n.show({severity:"error",summary:"Error",detail:"Failed to delete alert. Please try again.",life:3e3}),[3,5];case 4:return ae(!1),[7];case 5:return[2]}})})},title:"Delete Alert?",message:te?'Are you sure you want to delete the alert "'.concat(te.alertName,'."? You’ll no longer receive alerts from it.'):"",warningText:"This action cannot be undone.",confirmText:"Delete",cancelText:"Cancel",confirmButtonColor:"#EF4444"}),r.jsx(u.default,{isOpen:V,onClose:function(){M(!1),O(null)},uiConfig:h,onSearchSubscribers:function(r){return new Promise(function(t){Le.current&&(clearTimeout(Le.current),Ne.current&&Ne.current([])),Ue.current&&Ue.current.abort(),Ne.current=t,Le.current=setTimeout(function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,s,i;return e.__generator(this,function(e){switch(e.label){case 0:n=new AbortController,Ue.current=n,e.label=1;case 1:return e.trys.push([1,3,4,5]),s=[],[4,c.getAllUsers({authBaseUrl:f,accessToken:v},{page:1,limit:50,pagination:!0,search:r.trim()||void 0,isPopulateRoles:!1,isPopulatePermissions:!1,isPopulateApps:!1,isPopulateEnvironments:!1,isPopulateOperations:!1,isPopulateGroups:!1,isPopulateOrganization:!1},n.signal)];case 2:return(i=e.sent())&&i.forEach(function(e){s.push({label:e.email,value:e.email,userId:e._id})}),t(s),[3,5];case 3:return"AbortError"===e.sent().name||console.error("User search failed: An error occurred while querying the user directory."),t([]),[3,5];case 4:return Ue.current===n&&(Ue.current=null),Le.current=null,Ne.current=null,[7];case 5:return[2]}})})},400)})},onSave:function(r,t){return e.__awaiter(void 0,void 0,void 0,function(){var n,s,i,a,l;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),t?(n=null==B?void 0:B.id,[4,c.updateAlert({baseUrl:p,configId:g||"",accessToken:v},n,r)]):[3,2];case 1:return e.sent(),null===(i=Ie.current)||void 0===i||i.show({severity:"success",summary:"Success",detail:"Updates saved successfully!",life:3e3}),[3,4];case 2:return[4,c.createAlert({baseUrl:p,configId:g||"",accessToken:v},r)];case 3:e.sent(),null===(a=Ie.current)||void 0===a||a.show({severity:"success",summary:"Success",detail:"Alert created successfully!",life:3e3}),e.label=4;case 4:return Be(),[2,!0];case 5:return s=e.sent(),console.error("Error in handleCreateAlert:",s),null===(l=Ie.current)||void 0===l||l.show({severity:"error",summary:"Error",detail:t?"Failed to update alert. Please try again.":"Failed to create alert. Please try again.",life:3e3}),[2,!1];case 6:return[2]}})})},editData:B,plotAndKPIs:Ee,selectedPlot:ze,handlePlotSelectionChange:function(e){De(e)}})]})),H&&Y&&o.createPortal(r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{position:"fixed",inset:0,zIndex:9998},onClick:function(){G(null),J(null)}}),r.jsxs("div",e.__assign({className:"q-alert-kebab-menu",style:{position:"fixed",top:Y.top,left:Y.left,transform:"translateX(-100%)"}},{children:[r.jsxs("button",e.__assign({className:"q-alert-kebab-item",disabled:"FAILED"===H.status||$[H.id],style:{color:"FAILED"===H.status||$[H.id]?"#94a3b8":void 0,cursor:"FAILED"===H.status||$[H.id]?"not-allowed":"pointer"},onClick:function(r){return e.__awaiter(void 0,void 0,void 0,function(){var t,n,s,i,a,l,o,u,d,f,y,h,x;return e.__generator(this,function(_){switch(_.label){case 0:if(r.stopPropagation(),"FAILED"===H.status||$[H.id])return[2];t=H,ee(function(r){var n;return e.__assign(e.__assign({},r),((n={})[t.id]=!0,n))}),_.label=1;case 1:return _.trys.push([1,4,5,6]),n=(null===(u=t.status)||void 0===u?void 0:u.toUpperCase())||"",i=(s="PAUSED"===n)?"ACTIVE":"PAUSED",a=t.raw||{},l={name:(null==a?void 0:a.name)||"",kpiKey:(null==a?void 0:a.kpiKey)||"",kpiType:(null==a?void 0:a.kpiType)||"",entityType:(null==a?void 0:a.entityType)||{},conditionType:(null==a?void 0:a.conditionType)||"",thresholdValue:null!==(d=null==a?void 0:a.thresholdValue)&&void 0!==d?d:null,severity:(null==a?void 0:a.severity)||"",evaluationType:(null==a?void 0:a.evaluationType)||"",evaluationPeriod:(null==a?void 0:a.evaluationPeriod)||null,triggerAfter:null!==(f=null==a?void 0:a.triggerAfter)&&void 0!==f?f:0,recipients:(null==a?void 0:a.recipients)||{userIds:[],userEmails:[]},status:i},[4,c.updateAlert({baseUrl:p,configId:g||"",accessToken:v},t.id,l)];case 2:return _.sent(),s?null===(y=Ie.current)||void 0===y||y.show({severity:"success",summary:"Success",detail:"Alert resumed successfully!",life:3e3}):null===(h=Ie.current)||void 0===h||h.show({severity:"success",summary:"Success",detail:"Alert paused successfully!",life:3e3}),[4,Be()];case 3:return _.sent(),G(null),J(null),[3,6];case 4:return o=_.sent(),console.error(o),null===(x=Ie.current)||void 0===x||x.show({severity:"error",summary:"Error",detail:"Failed to update Alert status. Please try again.",life:3e3}),[3,6];case 5:return ee(function(r){var n;return e.__assign(e.__assign({},r),((n={})[t.id]=!1,n))}),[7];case 6:return[2]}})})}},{children:[$[H.id]?r.jsx(s.Loader2,{size:14,className:"animate-spin"}):"PAUSED"===H.status?r.jsx(s.Play,{size:14}):r.jsx(s.Pause,{size:14}),"PAUSED"===H.status?"Resume Alert":"ACTIVE"===H.status?"Pause Alert":""]})),r.jsxs("button",e.__assign({className:"q-alert-kebab-item danger",onClick:function(e){e.stopPropagation(),ne(H),G(null),J(null)}},{children:[r.jsx(s.Trash2,{size:14})," Delete"]}))]}))]}),document.body)]})};
2
2
  //# sourceMappingURL=AlertsViewTrigger.js.map