1import{r as d,j as e,d as Me}from"./react-vendor-CSsSSEML.js";import{z as ve,x as oe,f as ne,P as re,h as st,i as nt,E as rt,B as Z,D as xe,F as V,K as G,r as _e,j as $e,G as ot,I as fe,S as at}from"./index-BVsjb7mB.js";import{T as lt}from"./Tabs-i18bnVDL.js";import{E as Be}from"./ErrorState-CE1mnLGb.js";import{C as ct}from"./ConfirmDialog-BvaLv-yh.js";import{u as Re,a as it,b as dt,c as ut,d as mt}from"./useChannels-4fu1MmMN.js";import{d as je,c as De,b as ze}from"./tanstack-vendor-D2LStv3_.js";import{c as ht}from"./TypeToConfirmInput-BRI3yPKX.js";import{i as pt}from"./formDirty-KbNXPJ_S.js";import{u as xt}from"./useGroups-BAd--nxI.js";import{u as ft}from"./useTeams-DCi7LYev.js";import"./sentry-vendor-DQkRq1-W.js";import"./useCopyToClipboard-D1iEeEhF.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"33b2f1a2eb67da61a8a79f4c3c0fca45c630c2e5"};var a=new t.Error().stack;a&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[a]="6a849c40-9b8c-4fcb-992f-fcf480ba29ca",t._sentryDebugIdIdentifier="sentry-dbid-6a849c40-9b8c-4fcb-992f-fcf480ba29ca")}catch{}})();function gt(t){if(!t)return"";try{return`${new URL(t).origin}/${"â¢".repeat(8)}`}catch{return"â¢".repeat(20)}}const ke={all:()=>["notification-subscriptions"],list:()=>[...ke.all(),"list"]};function bt(){return je({queryKey:ke.list(),queryFn:()=>oe.get("/notifications/subscriptions"),select:t=>Array.isArray(t)?t:[]})}function yt(){return je({queryKey:["notification-event-types"],queryFn:()=>oe.get("/notifications/event-types"),select:t=>Array.isArray(t)?t:[],staleTime:1/0})}function vt(){const t=De();return ze({mutationFn:a=>oe.post("/notifications/subscriptions/bulk",a),onSuccess:()=>{t.invalidateQueries({queryKey:ke.all()})},onError:()=>ve.error("Failed to update subscriptions")})}const we=[{value:"slack",label:"Slack"},{value:"teams",label:"Microsoft Teams"},{value:"gchat",label:"Google Chat"},{value:"webhook",label:"Custom Webhook"}],ge=Object.fromEntries(we.map(t=>[t.value,t])),ue={slack:e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-5 w-5",fill:"none",children:[e.jsx("path",{d:"M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zm1.271 0a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313z",fill:"#E01E5A"}),e.jsx("path",{d:"M8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zm0 1.271a2.527 2.527 0 0 1 2.521 2.521 2.527 2.527 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312z",fill:"#36C5F0"}),e.jsx("path",{d:"M18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zm-1.27 0a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.163 0a2.528 2.528 0 0 1 2.523 2.522v6.312z",fill:"#2EB67D"}),e.jsx("path",{d:"M15.163 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.163 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zm0-1.27a2.527 2.527 0 0 1-2.52-2.523 2.527 2.527 0 0 1 2.52-2.52h6.315A2.528 2.528 0 0 1 24 15.163a2.528 2.528 0 0 1-2.522 2.523h-6.315z",fill:"#ECB22E"})]}),teams:e.jsxs("svg",{viewBox:"0 0 22 22",className:"h-5 w-5",fill:"none",fillRule:"evenodd",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"tg3",x1:"19%",x2:"81%",y1:"-7%",y2:"107%",children:[e.jsx("stop",{offset:"0%",stopColor:"#5A62C3"}),e.jsx("stop",{offset:"50%",stopColor:"#4D55BD"}),e.jsx("stop",{offset:"100%",stopColor:"#3940AB"})]})}),e.jsx("path",{fill:"#5059C9",d:"M15.345 8.875h5.683c.537 0 .972.447.972.997v5.312c0 2.025-1.6 3.666-3.573 3.666h-.017c-1.973 0-3.572-1.64-3.573-3.666V9.396c0-.288.228-.521.508-.521"}),e.jsx("ellipse",{cx:"19.186",cy:"5.462",fill:"#5059C9",rx:"2.302",ry:"2.363"}),e.jsx("ellipse",{cx:"12.023",cy:"4.413",fill:"#7B83EB",rx:"3.326",ry:"3.413"}),e.jsx("path",{fill:"#7B83EB",d:"M16.458 8.875h-9.38a.976.976 0 0 0-.938 1.01v6.058C6.065 19.209 8.584 21.92 11.767 22c3.184-.08 5.702-2.79 5.628-6.057V9.885a.976.976 0 0 0-.937-1.01"}),e.jsx("path",{fill:"url(#tg3)",d:"M.938 5.725h9.38a.95.95 0 0 1 .938.962v9.626a.95.95 0 0 1-.938.962H.938A.95.95 0 0 1 0 16.313V6.687a.95.95 0 0 1 .938-.962"}),e.jsx("path",{fill:"#FFF",d:"M8.096 9.388H6.221v5.24H5.026v-5.24H3.16V8.372h4.936z"})]}),gchat:e.jsxs("svg",{viewBox:"0 0 22 22",className:"h-5 w-5",fill:"none",fillRule:"evenodd",children:[e.jsx("path",{fill:"#0066DA",d:"M6.157.035v5.257L1 5.291V1.428q.057-.41.238-.688Q1.684.05 2.536.046q1.8-.01 3.62-.01"}),e.jsx("path",{fill:"#FBBC04",d:"m6.157.035 10.63.001q.034 0 .062.02l.025.019-.019.009a.02.02 0 0 0-.011.02l-.001 5.19H6.16l-.003-.002z"}),e.jsx("path",{fill:"#EA4335",d:"m16.874.075 5.094 5.203-5.125.
1016V.104a.02.02 0 0 1 .012-.02z"}),e.jsx("path",{fill:"#2684FC",d:"m1 5.291 5.157.001.003.002v7.266L1 12.559z"}),e.jsx("path",{fill:"#00AC47",d:"M21.968 5.278 22 5.3v11.13q-.18 1-1.017 1.291-.298.105-.88.104-3.774-.008-7.625-.012-.558 0-1.134.008a.08.08 0 0 0-.054.023q-1.896 1.921-3.781 3.852c-.194.198-.414.31-.692.267a.74.74 0 0 1-.573-.408q-.077-.15-.08-.542-.003-1.595-.002-3.199l-.001-2.632 2.55-2.597a.12.12 0 0 1 .086-.036l7.988.003c.03 0 .056-.026.056-.057l-.002-7.202h.004z"}),e.jsx("path",{fill:"#00832D",d:"M6.16 12.56v2.623l.002 2.632q-1.62.01-3.21.006-.663 0-.955-.106-.82-.291-.997-1.292v-3.864z"})]}),webhook:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-5 w-5 text-text-secondary",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"})})},Oe={slack:"https://hooks.slack.com/services/...",teams:"https://outlook.office.com/webhook/...",gchat:"https://chat.googleapis.com/v1/spaces/...",webhook:"https://your-endpoint.com/webhook"},pe={name:"",platform:"slack",webhookUrl:"",slackBotToken:"",slackChannelId:"",slackSigningSecret:""},jt={slack:{title:"How to get your Slack credentials",steps:[{text:"Go to ",link:{label:"api.slack.com/apps",url:"https://api.slack.com/apps"},after:' â click Create New App â select "From scratch" â give it a name and pick your workspace.'},{text:"In your app settings, go to OAuth & Permissions â scroll to Scopes â add Bot Token Scopes: ",code:"chat:write",after:" and ",code2:"chat:write.public",after2:"."},{text:"Scroll up to OAuth Tokens â click Install to Workspace â Authorize â copy the Bot User OAuth Token (starts with ",code:"xoxb-",after:")."},{text:"In Slack, right-click the target channel â View channel details â copy the Channel ID from the bottom of the panel."},{text:"Back in your app on api.slack.com, go to Basic Information â scroll to App Credentials â copy the Signing Secret."}]},teams:{title:"How to get your Microsoft Teams webhook URL",steps:[{text:"Open Microsoft Teams and go to the channel where you want to receive notifications."},{text:"Click the â¢â¢â¢ (more options) next to the channel name â select Workflows."},{text:'Choose the "Send webhook alerts to channel" template and follow the setup wizard.'},{text:"Once created, copy the Webhook URL provided by the workflow."}]},gchat:{title:"How to get your Google Chat webhook URL",steps:[{text:"Open Google Chat and go to the Space where you want notifications."},{text:"Click the Space name at the top â select Apps & integrations."},{text:'Click + Add webhooks â name it (e.g., "ZopNight Alerts").'},{text:"Copy the Webhook URL from the dialog."}]},webhook:{title:"Custom Webhook requirements",steps:[{text:"Set up an HTTP endpoint that accepts POST requests with a JSON body."},{text:"The payload will include: ",code:'{ "body": "...", "priority": "0|1|2" }'},{text:"Paste your endpoint URL in the field below."}]}};function kt({platform:t}){const a=jt[t];return a?e.jsxs("details",{className:"group rounded-lg border border-border bg-surface-secondary/50 text-sm",children:[e.jsxs("summary",{className:"flex items-center gap-2 cursor-pointer px-3 py-2.5 text-xs font-medium text-primary-500 hover:text-primary-400 transition-colors select-none",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"w-3.5 h-3.5 shrink-0 transition-transform group-open:rotate-90",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m8.25 4.5 7.5 7.5-7.5 7.5"})}),a.title]}),e.jsx("ol",{className:"px-3 pb-3 pt-1 space-y-2 text-xs text-text-secondary list-decimal list-inside marker:text-text-muted marker:font-semibold",children:a.steps.map((r,f)=>e.jsxs("li",{className:"leading-relaxed pl-1",children:[r.text,r.link&&e.jsx("a",{href:r.link.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary-500 hover:underline",children:r.link.label}),r.code&&e.jsx("code",{className:"px-1 py-0.5 rounded bg-surface-tertiary text-text-primary text-[11px] font-mono",children:r.code}),r.after,r.code2&&e.jsx("code",{className:"px-1 py-0.5 rounded bg-surface-tertiary text-text-primary text-[11px] font-mono",children:r.code2}),r.after2]},f))})]}):null}function wt(t){const a={};for(const r of t)a[r.category]||(a[r.category]=[]),a[r.category].push(r);return a}function Nt({open:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:`w-4 h-4 text-text-muted transition-transform duration-200 ${t?"rotate-180":""}`,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5"})})}function me({checked:t,onChange:a,disabled:r}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,onClick:r?void 0:a,disabled:r,className:`relative inline-flex h-6 w-11 shrink-0 rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 ${r?"cursor-not-allowed opacity-50":"cursor-pointer"} ${t?"bg-success-500":"bg-text-muted/30"}`,children:e.jsx("span",{className:`pointer-events-none inline-flex h-5 w-5 transform items-center justify-center rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ${t?"translate-x-5":"translate-x-0"}`})})}function Ct({platform:t,channels:a,alertCounts:r,expanded:f,onToggleExpand:b,onConfigureChannel:p,onDeleteChannel:y,onTestChannel:v,isTestPending:m,canUpdate:o=!0,canDelete:i=!0}){const j=ge[t],g=a.length,S=a.reduce((w,c)=>w+(r[c.id]??0),0);return e.jsxs("div",{className:"border border-border rounded-xl bg-surface overflow-hidden",children:[e.jsxs("button",{onClick:b,className:"w-full flex items-center gap-3.5 px-5 py-4 hover:bg-surface-tertiary/30 transition-colors text-left",children:[e.jsx("div",{className:"flex items-center justify-center h-9 w-9 rounded-lg bg-surface-tertiary border border-border shrink-0",children:ue[t]}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:j.label}),e.jsxs(_e,{variant:"neutral",children:[g," channel",g!==1?"s":""]})]})}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[S>0&&e.jsxs("span",{className:"text-xs text-text-muted",children:[S," alert",S!==1?"s":""," active"]}),e.jsx(Nt,{open:f})]})]}),f&&e.jsx("div",{className:"border-t border-border",children:a.map(w=>
1{const c=r[w.id]??0;return e.jsxs("div",{onClick:o?()=>p(w):void 0,className:`flex items-center gap-3.5 px-5 py-3 border-b border-border last:border-b-0 transition-colors group ${o?"hover:bg-surface-tertiary/40 cursor-pointer":"cursor-default"}`,children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-success-500 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-text-primary truncate",children:w.name}),e.jsx("p",{className:"text-xs text-text-muted font-mono truncate mt-0.5",children:(w.platform??"webhook")==="slack"?w.credentials?.SLACK_CHANNEL_ID??"":gt(w.webhookUrl)})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[c>0?e.jsxs(_e,{variant:"success",children:[c," alert",c!==1?"s":""]}):e.jsx("span",{className:"text-xs text-warning-600",children:"No alerts"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx($e,{content:"Edit",wrapDisabled:!0,children:e.jsx("button",{type:"button",disabled:!o,onClick:N=>{N.stopPropagation(),o&&p(w)},"aria-label":"Edit channel",className:`p-1.5 rounded-md transition-colors ${o?"text-text-muted hover:text-primary-600 hover:bg-surface-tertiary":"text-text-muted/40 cursor-not-allowed"}`,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",className:"w-4 h-4",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10"})})})}),e.jsx($e,{content:"Delete",wrapDisabled:!0,children:e.jsx("button",{type:"button",disabled:!i,onClick:N=>{N.stopPropagation(),i&&y(w)},"aria-label":"Delete channel",className:`p-1.5 rounded-md transition-colors ${i?"text-text-muted hover:text-danger-500 hover:bg-surface-tertiary":"text-text-muted/40 cursor-not-allowed"}`,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",className:"w-4 h-4",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})})})})]})]})]},w.id)})})]})}function Tt({value:t,onChange:a}){return e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:we.map(r=>{const f=t===r.value;return e.jsxs("button",{type:"button",onClick:()=>a(r.value),className:`flex items-center gap-2.5 px-3.5 py-3 rounded-xl border transition-all text-left ${f?"border-primary-600 bg-primary-600/5 ring-1 ring-primary-600/20":"border-border bg-surface-secondary/50 hover:border-border-strong hover:bg-surface-secondary"}`,children:[e.jsx("span",{className:"shrink-0",children:ue[r.value]}),e.jsx("span",{className:`text-sm font-medium ${f?"text-primary-600":"text-text-primary"}`,children:r.label})]},r.value)})})}function be({text:t}){const[a,r]=d.useState(!1),[f,b]=d.useState(null),p=d.useRef(null),y=d.useRef(null);d.useEffect(()=>{if(!a)return;function m(o){p.current?.contains(o.target)||y.current?.contains(o.target)||r(!1)}return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[a]);const v=()=>{if(p.current){const m=p.current.getBoundingClientRect();b({top:m.bottom+6,left:Math.max(12,m.left-110)})}r(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:p,type:"button",onClick:()=>a?r(!1):v(),onMouseEnter:v,onMouseLeave:()=>r(!1),className:"inline-flex items-center justify-center text-text-muted hover:text-text-primary transition-colors cursor-pointer","aria-label":"More info",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-4 w-4",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"})})}),a&&f&&Me.createPortal(e.jsx("div",{ref:y,className:"fixed w-64 px-3 py-2.5 text-xs text-text-primary bg-surface-elevated border border-border-strong rounded-lg shadow-xl leading-relaxed whitespace-pre-line",style:{to
1p:f.top,left:f.left,zIndex:99999},onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:t}),document.body)]})}const se=["warning","critical","emergency"],St={warning:"Warning",critical:"Critical",emergency:"Emergency"},It={warning:"Warning: Triggers when cost exceeds the 7-day rolling average by 30% or more.",critical:"Critical: Triggers when cost exceeds the 7-day rolling average by 100% or more (cost doubled).",emergency:"Emergency: Triggers when cost exceeds the 7-day rolling average by 500% or more (extreme spike)."};function At({level:t,active:a,disabled:r,align:f,leftPct:b,isEdge:p,onChange:y,position:v}){const m=d.useRef(null),[o,i]=d.useState(!1),[j,g]=d.useState({top:0,left:0,right:0}),S=()=>{if(!m.current)return;const c=m.current.getBoundingClientRect();g({top:c.top-6,left:c.left,right:c.right,cx:c.left+c.width/2}),i(!0)},w=v==="first"?{top:j.top,left:j.left,transform:"translateY(-100%)"}:v==="last"?{top:j.top,right:window.innerWidth-j.right,transform:"translateY(-100%)"}:{top:j.top,left:j.cx,transform:"translate(-50%, -100%)"};return e.jsxs("span",{ref:m,className:`absolute text-[10px] transition-colors ${f}`,style:p?void 0:{left:`${b}%`},onMouseEnter:S,onMouseLeave:()=>i(!1),children:[e.jsx("button",{type:"button",disabled:r,onClick:()=>y(t),className:`${a?"text-primary-600 font-medium":"text-text-muted"} ${r?"":"hover:text-text-primary cursor-pointer"}`,children:St[t]}),o&&Me.createPortal(e.jsx("div",{className:"fixed z-[9999] px-3 py-2 text-[11px] leading-relaxed text-text-primary bg-surface-elevated border border-border rounded-lg shadow-lg w-64 pointer-events-none",style:w,children:It[t]}),document.body)]})}function Fe({value:t,onChange:a,disabled:r}){const f=t==="off"?"warning":t,b=se.indexOf(f),p=se.length-1,y=p===0?0:b/p*100,v=m=>{if(r)return;const o=m.currentTarget.getBoundingClientRect(),j=(m.clientX-o.left)/o.width,g=Math.round(j*p);a(se[Math.max(0,Math.min(p,g))])};return e.jsxs("div",{className:`flex-1 min-w-0 ${r?"opacity-50 pointer-events-none":""}`,children:[e.jsxs("div",{className:"relative h-5 flex items-center mx-2 cursor-pointer",onClick:v,children:[e.jsx("div",{className:"absolute inset-x-0 h-1 rounded-full bg-border-strong"}),e.jsx("div",{className:"absolute left-0 h-1 rounded-full bg-primary-600 transition-all duration-200",style:{width:`${y}%`}}),se.map((m,o)=>e.jsx("div",{className:`absolute h-2 w-2 rounded-full transition-colors ${o<=b?"bg-primary-600":"bg-border-strong"}`,style:{left:`calc(${o/p*100}% - 4px)`}},o)),e.jsx("div",{className:"absolute h-3.5 w-3.5 rounded-full bg-white border-2 border-primary-600 shadow transition-all duration-200",style:{left:`calc(${y}% - 7px)`}})]}),e.jsx("div",{className:"relative h-5 mt-1 mx-2 overflow-visible",children:se.map((m,o)=>{const i=o<=b,j=o/p*100,g=o===0?"left-0":o===p?"right-0":"left-1/2 -translate-x-1/2";return e.jsx(At,{level:m,active:i,disabled:r,align:g,leftPct:j,isEdge:o===0||o===p,onChange:a,position:o===0?"first":o===p?"last":"middle"},m)})})]})}const We=[{key:"org",label:"Organization",prefix:"cost.anomaly",hasEntityPicker:!1},{key:"cloud_account",label:"Cloud Account",prefix:"cost.anomaly.cloud_account",hasEntityPicker:!0,hasProviderTabs:!0},{key:"team",label:"Team",prefix:"cost.anomaly.team",hasEntityPicker:!0},{key:"resource_group",label:"Resource Group",prefix:"cost.anomaly.resource_group",hasEntityPicker:!0},{key:"resource",label:"Resource",prefix:"cost.anomaly.resource",hasEntityPicker:!1}],Ue=[{key:"aws",label:"AWS"},{key:"gcp",label:"GCP"},{key:"azure",label:"Azure"}],F=["warning","critical","emergency"];function ye(t,a){for(let r=F.length-1;r>=0;r--)if(a.has(`${t}.${F[r]}`))return F[r];return"off"}function Et(t,a,r,f,b){const p={},y=m=>{for(const o of m??[]){if(o.channelId!==r||o.scopeType!==f||!o.scopeId||!o.eventType?.startsWith(b+"."))continue;const i=o.eventType.slice(b.length+1);F.includes(i)&&(p[o.scopeId]||(p[o.scopeId]=new Set),o.enabled?p[o.scopeId].add(i):p[o.scopeId].delete(i))}};y(t),y(Object.values(a??{}));const v={};for(const[m,o]of Object.entries(p))for(let i=F.length-1;i>=0;i--)if(o.has(F[i])){v[m]=F[i];break}return v}function de(t){if(t==="off")return[];const a=F.indexOf(t);return a>=0?F.slice(0,a+1):[]}function Lt({options:t,selected:a,onChange:r,placeholder:f,disabled:b,onErrorChange:p}
1){const[y,v]=d.useState(!1),[m,o]=d.useState(""),[i,j]=d.useState(!1),g=d.useRef(null),S=d.useRef(null);d.useEffect(()=>{function h(L){g.current&&!g.current.contains(L.target)&&(v(!1),o(""))}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);const w=m?t.filter(h=>h.label.toLowerCase().includes(m.toLowerCase())):t,[c,N]=d.useState(!1),k=a.length>0?!1:c,E=a.length===0&&!k,B=d.useMemo(()=>new Set(a),[a]),C=h=>{if(E){const L=t.filter(W=>W.value!==h).map(W=>W.value);N(!1),r(L)}else{const L=new Set(B);L.has(h)?L.delete(h):L.add(h),L.size===0&&N(!0),r([...L])}},K=()=>{E?(N(!0),r([])):(N(!1),r([]))},z=k&&a.length===0;d.useEffect(()=>{p?.(z)},[z,p]);const l=()=>{if(g.current){const h=g.current.getBoundingClientRect(),L=window.innerHeight-h.bottom;j(L<260)}v(h=>!h),o(""),setTimeout(()=>S.current?.focus(),0)},n=z?"Select at least one":E?f:a.length===1?t.find(h=>h.value===a[0])?.label??a[0]:`${a.length} selected`,T=h=>`w-4 h-4 rounded border shrink-0 flex items-center justify-center ${h?"bg-primary-600 border-primary-600":"border-border-strong"}`,R=e.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})});return e.jsxs("div",{ref:g,className:"relative",children:[e.jsxs("button",{type:"button",disabled:b,onClick:l,className:`w-full flex items-center justify-between gap-2 px-3 py-2 text-sm bg-surface-tertiary border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-600/30 transition-all ${z?"border-red-500":"border-border-strong"} ${b?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[e.jsx("span",{className:`flex-1 truncate text-left ${z?"text-red-400":"text-text-primary"}`,children:n}),e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:`h-4 w-4 text-text-muted shrink-0 transition-transform ${y?"rotate-180":""}`,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5"})})]}),y&&e.jsxs("div",{className:`absolute left-0 z-[100] w-full bg-surface-elevated border border-border-strong rounded-lg shadow-xl overflow-hidden ${i?"bottom-full mb-1":"top-full mt-1"}`,children:[e.jsx("div",{className:"p-2 border-b border-border",children:e.jsx("input",{ref:S,autoFocus:!0,t
1ype:"text",className:"w-full px-3 py-2 bg-surface-tertiary border border-border-strong rounded-md text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-primary-600/30 transition-all",placeholder:"Search...",value:m,onChange:h=>o(h.target.value),onKeyDown:h=>{h.key==="Escape"&&(v(!1),o(""))}})}),e.jsxs("ul",{className:"max-h-52 overflow-y-auto py-1",children:[!m&&e.jsxs("li",{onClick:K,className:`px-3 py-2 text-sm cursor-pointer transition-colors flex items-center gap-2.5 ${E?"bg-primary-600/10 text-primary-600 font-medium":"text-text-primary hover:bg-surface-secondary"}`,children:[e.jsx("span",{className:T(E),children:E&&R}),e.jsx("span",{children:"All"})]}),w.length===0?e.jsx("li",{className:"px-3 py-2.5 text-sm text-text-muted",children:"No results"}):w.map(h=>{const L=E||B.has(h.value);return e.jsxs("li",{onClick:()=>C(h.value),className:`px-3 py-2 text-sm cursor-pointer transition-colors flex items-center gap-2.5 ${L?"bg-primary-600/10 text-primary-600 font-medium":"text-text-primary hover:bg-surface-secondary"}`,children:[e.jsx("span",{className:T(L),children:L&&R}),e.jsx("span",{className:"truncate",children:h.label})]},h.value)})]})]}),z&&e.jsx("p",{className:"text-xs text-red-400 mt-1",children:"Please select at least one option"})]})}const Pe={aws:[{value:"cloud_account",label:"Account Level",prefix:"cost.anomaly.cloud_account"}],gcp:[{value:"cloud_account",label:"Project Level",prefix:"cost.anomaly.cloud_account"}],azure:[{value:"cloud_account",label:"Subscription Level",prefix:"cost.anomaly.cloud_account"},{value:"azure_resource_group",label:"Resource Group Level",prefix:"cost.anomaly.azure_resource_group"},{value:"azure_tenant",label:"Tenant Level",prefix:"cost.anomaly.azure_tenant",requiresParent:!0}]};function _t({open:t,onClose:a,provider:r,accounts:f,selected:b,onLevelChange:p,onScopedLevelChange:y,scopedLevels:v,dimKey:m,prefix:o,enabledSet:i,disabled:j}){const g=Ue.find(l=>l.key===r)?.label??(r??"").toUpperCase(),S=Pe[r]??Pe.aws,w=f.some(l=>l.parentAccountId),c=d.useMemo(()=>new Set(b??[]),[b]),[N,k]=d.useState({}),E=l=>v?.[l]??"off",B=l=>{const n=E(l)==="off";k(T=>({...T,[l]:n})),y?.(m,o,l,n?"warning":"off")},C=(l,n)=>{if(l.prefix===o){const T=E(n);y?.(m,o,n,T==="off"?"warning":"off")}else{const T=i?ye(l.prefix,i):"off";p?.(l.prefix,T==="off"?"warning":"off")}},K=(l,n,T)=>{l.prefix===o?y?.(m,o,n,T):p?.(l.prefix,T)},z=c.size;return r?e.jsx(xe,{open:t,onClose:a,title:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:a,className:"p-1.5 -ml-1.5 rounded-lg hover:bg-surface-tertiary transition-colors cursor-pointer","aria-label":"Back",children:e.jsx("svg",{className:"w-4 h-4 text-text-secondary",fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}),e.jsx("span",{className:"w-6 h-6",children:e.jsx(fe,{provider:r})}),e.jsxs("div",{children:[e.jsxs("span",{className:"text-base font-semibold",children:[g," Accounts"]}),z>0&&e.jsxs("span",{className:"ml-2 text-[11px] text-primary-400 font-medium",children:[z," active"]})]})]}),children:e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] text-text-muted mb-5 leading-relaxed",children:"Enable cost anomaly monitoring per account. Configure the severity threshold and detection level for each."}),f.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"w-10 h-10 mb-3 opacity-30",children:e.jsx(fe,{provider:r})}),e.jsxs("p",{className:"text-sm text-text-muted",children:["No ",g," accounts connected"]}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Connect a cloud account to enable monitoring"})]}),e.jsx("div",{className:"space-y-3",children:f.map(l=>{const n=l.cloudAccountId??l.id,T=l.name||l.cloudAccountId||l.id,R=E(n)!=="off";return e.jsxs("div",{className:`rounded-xl border transition-all duration-200 ${R?"border-border-strong bg-surface-secondary/40":"border-border bg-surface-secondary/20 hover:bg-surface-secondary/40"}`,children:[e.jsxs("div",{className:"flex items-center px-4 py-3.5 gap-3",children:[e.jsx("button",{type:"button",onClick:()=>k(h=>({...h,[n]:!h[n]})),className:"shrink-0 p-0.5 cursor-pointer","aria-label":N[n]?"Collapse":"Expand",children:e.jsx("svg",{className:`w-4 h-4 text-text-muted transition-transform duration-200 ${N[n]?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-text-primary truncate",children:T}),l.cloudAccountId&&l.name&&e.jsx("p",{className:"text-[11px] text-text-muted truncate mt-0.5 font-mono",children:l.cloudAccountId})]}),e.jsx(me,{checked:R,onChange:()=>B(n),disabled:j})]}),N[n]&&R&&e.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-border/50",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-text-muted pt-3 mb-3",children:"Detection Levels"}),e.jsx("div",{className:"space-y-1 divide-y divide-border/40",children:S.map(h=>{const L=h.requiresParent&&!w,W=h.prefix===o?E(n):i?ye(h.prefix,i):"off",ee=W!=="off";return e.jsxs("div",{className:`pt-2.5 pb-2.5 first:pt-0 ${L?"opacity-50":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-sm font-medium text-text-primary",children:h.label}),L&&e.jsx(be,{text:"Connect a tenant to enable tenant-level detection"})]}),e.jsx(me,{checked:ee,onChange:()=>C(h,n),disabled:j||L})]}),ee&&!L&&e.jsx("div",{className:"mt-2 px-0.5",children:e.jsx(Fe,{value:W,onChange:ae=>K(h,n,ae),disabled:j})})]},h.value)})})]})]},n)})})]})}):null}function $t({accounts:t,selected:a,onLevelChange:r,onScopedLevelChange:f,scopedLevels:b,dimKey:p,prefix:y,enabledSet:v,disabled:m,onErrorChange:o}
1){const[i,j]=d.useState(null),g=d.useMemo(()=>{const c={aws:[],gcp:[],azure:[]};for(const N of t){const k=(N.provider??"").toLowerCase();c[k]&&c[k].push(N)}return c},[t]),S=d.useMemo(()=>Ue.filter(c=>g[c.key]?.length>0),[g]),w=d.useMemo(()=>{const c={aws:0,gcp:0,azure:0};if(!a?.length)return c;const N=new Set(a);for(const k of t){const E=(k.provider??"").toLowerCase(),B=k.cloudAccountId??k.id;c[E]!==void 0&&N.has(B)&&c[E]++}return c},[t,a]);return d.useEffect(()=>{S.length===0&&o?.(!1)},[S.length,o]),S.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:S.map(c=>{const N=g[c.key]?.length??0,k=w[c.key]??0,E=k>0;return e.jsxs("button",{onClick:()=>j(c.key),disabled:m,className:`group flex items-center gap-2.5 px-3 py-3 rounded-lg border transition-all duration-200 cursor-pointer hover:bg-surface-secondary ${E?"border-border bg-surface-secondary/60":"border-border bg-surface hover:border-border-strong"} ${m?"opacity-50 cursor-not-allowed":""}`,children:[e.jsx("span",{className:"w-6 h-6 shrink-0",children:e.jsx(fe,{provider:c.key})}),e.jsxs("div",{className:"text-left min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs font-semibold text-text-primary leading-tight",children:c.label}),e.jsx("p",{className:"text-[10px] text-text-muted leading-tight mt-0.5",children:E?`${k} of ${N} active`:`${N} account${N!==1?"s":""}`})]}),e.jsx("svg",{className:"w-3.5 h-3.5 text-text-muted/60 shrink-0 group-hover:text-text-muted transition-colors",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})]},c.key)})}),e.jsx(_t,{open:!!i,onClose:()=>j(null),provider:i,accounts:g[i]??[],selected:a,onLevelChange:r,onScopedLevelChange:f,scopedLevels:b,dimKey:p,prefix:y,enabledSet:v,disabled:m})]})}function Ot({dim:t,enabledSet:a,onSliderChange:r,onLevelChange:f,onScopedLevelChange:b,scopedLevels:p,entityOptions:y,selectedEntities:v,onEntitiesChange:m,disabled:o,onErrorChange:i,rawAccounts:j}){const g=ye(t.prefix,a),S=g!=="off",w=()=>{r(t.prefix,S?"off":"warning")},c=B=>{r(t.prefix,B)},N=d.useCallback(B=>{m(B,g)},[m,g]),k=t.hasEntityPicker&&S&&y.length>0;d.useEffect(()=>{k||i?.(!1)},[k,i]);const E=S&&!t.hasProviderTabs;return e.jsxs("div",{className:"px-4 py-3 space-y-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-text-primary",children:t.label}),e.jsx(me,{checked:S,onChange:w,disabled:o})]}),E&&e.jsx("div",{className:"mt-1 px-1",children:e.jsx(Fe,{value:g,onChange:c,disabled:o})}),k&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs text-text-muted mb-1.5",children:["Select which ",t.label.toLowerCase(),"s to monitor:"]}),t.hasProviderTabs&&j?e.jsx($t,{accounts:j,selected:v,onLevelChange:f,onScopedLevelChange:b,scopedLevels:p,dimKey:t.key,prefix:t.prefix,enabledSet:a,disabled:o,onErrorChange:i}):e.jsx(Lt,{options:y,selected:v,onChange:N,placeholder:`All ${t.label.toLowerCase()}s`,disabled:o,onErrorChange:i})]})]})}function Pt({channelId:t,enabledSet:a,onSliderChange:r,onLevelChange:f,onScopedToggle:b,onScopedLevelChange:p,subscriptions:y,pendingSubs:v={},canUpdate:m,onEntityError:o}){const{data:i=[]}=ot(),{data:j=[]}=xt(),{data:g=[]}=ft(),S=d.useMemo(()=>(Array.isArray(i)?i:i?.items??[]).map(l=>({value:l.cloudAccountId??l.id,label:l.name||l.cloudAccountId||l.id})),[i]),w=d.useMemo(()=>(Array.isArray(j)?j:j?.items??[]).map(l=>({value:l.id,label:l.name||l.id})),[j]),c=d.useMemo(()=>(Array.isArray(g)?g:g?.items??[]).map(l=>({value:l.id,label:l.name||l.id})),[g]),N=d.useMemo(()=>{const l={cloud_account:{},resource_group:{},team:{}};for(const n of y){if(n.channelId!==t||!n.scopeId)continue;const T=n.scopeType;if(!l[T])continue;const R=`cost.anomaly.${T}.`;n.eventType?.startsWith(R)&&n.enabled&&(l[T][n.scopeId]=!0)}for(const n of Object.values(v)){if(!n.scopeId||!n.scopeType||n.scopeType==="org")continue;const T=n.scopeType;l[T]&&n.enabled&&(l[T][n.scopeId]=!0)}for(const n of Object.keys(l))for(const T of Object.keys(l[n])){const R=Object.values(v).filter(h=>h.scopeId===T&&h.scopeType===n);R.length>0&&R.every(h=>!h.enabled)&&(l[n][T]=!1)}return{cloud_account:Object.entries(l.cloud_account).filter(([,n])=>n).map(([n])=>n),resource_group:Object.entries(l.resource_group).filter(([,n])=>n).map(([n])=>n),team:Object.entries(l.team).filter(([,n])=>n).map(([n])=>n)}},[y,t,v]),k=d.useMemo(()=>Et(y,v,t,"cloud_account","cost.anomaly.cloud_account"),[y,v,t]),E={cloud_account:S,resource_group:w,team:c},B=d.useCallback((l,n,T,R)=>{const h=de(R);b(l,n,h,T)},[b]),C=d.useRef({}),K=d.useCallback((l,n)=>{(C.current[l]??!1)!==n&&(C.current={...C.current,[l]:n},o?.(Object.values(C.current).some(Boolean)))},[o]),z=d.useMemo(()=>Array.isArray(i)?i:i?.items??[],[i]);return e.jsxs("div",{className:"border border-border-strong rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2.5 bg-surface-secondary/60 border-b border-border-strong flex items-center gap-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-text-secondary",children:"Cost Anomaly"}),e.jsx(be,{text:"Get alerted when your cloud costs spike unexpectedly. The system compares each day's spend against the past 7-day average and flags unusual increases so you can investigate before costs spiral."})]}),e.jsx("div",{className:"flex items-center gap-4 px-4 py-2 border-b border-border-strong bg-surface-tertiary/30",children:e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wider text-text-muted",children:["Level",e.jsx(be,{text:`Choose what to monitor: 2⢠Organization â your total cloud bill 3⢠Cloud Account â per-account spend (e.g. production vs staging) 4⢠Team â per-team cost allocation 5⢠Resource Group â grouped resources 6⢠Resource â individual VMs, databases, etc.`})]})}),e.jsx("div",{className:"divide-y divide-border-strong",children:We.map(l=>e.jsx(Ot,{dim:l,enabledSet:a,onSliderChange:r,onLevelChange:f,onScopedLevelChange:p,scopedLevels:l.hasProviderTabs?k:void 0,entityOptions:E[l.key]??[],selectedEntities:N[l.key]??[],onEntitiesChange:(n,T)=>
6B(l.key,l.prefix,n,T),disabled:!m,onErrorChange:n=>K(l.key,n),rawAccounts:l.hasProviderTabs?z:void 0},l.key))})]})}function Mt({channelId:t,eventTypes:a,subscriptions:r,onToggle:f,onSliderChange:b,onLevelChange:p,onScopedToggle:y,onScopedLevelChange:v,saving:m,canUpdate:o=!0,pendingSubs:i={},onEntityError:j}){const g=wt(a),S=new Map;for(const c of r){if(c.channelId!==t)continue;const N=`${c.eventType}|${c.scopeType}|${c.scopeId??""}`;S.set(N,c)}const w=new Set([...S.values()].filter(c=>c.enabled).map(c=>c.eventType));for(const c of Object.values(i))c.enabled?w.add(c.eventType):c.scopeType==="org"&&!c.scopeId&&(Object.values(i).some(k=>k.eventType===c.eventType&&k.scopeId&&k.enabled)||w.delete(c.eventType));return e.jsxs("div",{className:"space-y-4",children:[Object.entries(g).map(([c,N])=>c==="Cost Anomaly"?e.jsx(Pt,{channelId:t,enabledSet:w,onSliderChange:b,onLevelChange:p,onScopedToggle:y,onScopedLevelChange:v,subscriptions:r,pendingSubs:i,canUpdate:o,onEntityError:j},c):e.jsxs("div",{className:"border border-border-strong rounded-xl overflow-hidden",children:[e.jsx("div",{className:"px-4 py-2.5 bg-surface-secondary/60 border-b border-border-strong",children:e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-text-secondary",children:c})}),e.jsx("div",{className:"divide-y divide-border",children:N.map(k=>e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("span",{className:"text-sm text-text-primary",children:k.label}),e.jsx(me,{checked:w.has(k.key),onChange:()=>f(k.key,!w.has(k.key)),disabled:!o})]},k.key))})]},c)),m&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-primary-500",children:[e.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-2 border-primary-600 border-t-transparent"}),"Saving..."]})]})}const Bt=d.forwardRef(function(a,r){const{data:f=[],isLoading:b,isError:p,error:y,refetch:v}=Re(),{data:m=[]}=yt(),{data:o=[]}=bt(),i=it(),j=dt(),g=ut(),S=mt(),w=vt(),c=ne(re.NOTIFICATION_CREATE),N=ne(re.NOTIFICATION_UPDATE),k=ne(re.NOTIFICATION_DELETE),[E,B]=d.useState(null),[C,K]=d.useState(null),[z,l]=d.useState(null),[n,T]=d.useState(pe),[R,h]=d.useState(null),[L,W]=d.useState({}),[ee,ae]=d.useState({}),[J,le]=d.useState(!1),Ce=d.useRef(!1);d.useEffect(()=>{Ce.current||b||(Ce.current=!0,st(nt.CHANNELS_VIEWED,{channel_count:f.length}))},[b,f.length]);const qe=[...We.map(s=>s.prefix),"cost.anomaly.azure_resource_group","cost.anomaly.azure_tenant"],Q={};for(const s of o){if(!s.enabled)continue;const u=s.channelId;Q[u]||(Q[u]={total:0,seenDimensions:new Set});const I=qe.filter(P=>s.eventType?.startsWith(P+".")).sort((P,_)=>_.length-P.length)[0];I?Q[u].seenDimensions.has(I)||(Q[u].seenDimensions.add(I),Q[u].total+=1):Q[u].total+=1}const Te={};for(const[s,u]of Object.entries(Q))Te[s]=u.total;const te={};for(const s of f){const u=s.platform??"webhook";te[u]||(te[u]=[]),te[u].push(s)}const he=we.filter(s=>te[s.value]?.length>0);d.useEffect(()=>{const s={};for(const u of he)s[u.value]=ee[u.value]??!0;ae(s)},[f.length]);const He=s=>ae(u=>({...u,[s]:!u[s]})),Se=()=>{K(null),T(pe),h(null),le(!1),B("add")};d.useImperativeHandle(r,()=>({openAdd:Se}));const Ve=s=>{K(s);const u=(s.platform??"webhook")==="slack",I={name:s.name??"",platform:s.platform??"webhook",webhookUrl:u?"":s.webhookUrl??"",slackBotToken:u?s.credentials?.SLACK_BOT_TOKEN??"":"",slackChannelId:u?s.credentials?.SLACK_CHANNEL_ID??"":"",slackSigningSecret:u?s.credentials?.SLACK_SIGNING_SECRET??"":""};T(I),h(I),le(!1),B("configure")},X=()=>{B(null),K(null),W({}),Ie(!1)},U=(s,u)=>T(I=>({...I,[s]:u})),ce=n.platform==="slack",[Ge,Ie]=d.useState(!1),Ae=n.name.trim()&&!Ge&&(ce?n.slackBotToken.trim()&&n.slackChannelId.trim()&&n.slackSigningSecret.trim():n.webhookUrl.trim()),Ke=Object.keys(L).length>0,Ee=!!C&&R!=null&&pt(R,n),Le=()=>ce?{name:n.name,platform:"slack",slackBotToken:n.slackBotToken,slackChannelId:n.slackChannelId,slackSigningSecret:n.slackSigningSecret}:{name:n.name,platform:n.platform,webhookUrl:n.webhookUrl},Ye=()=>i.mutate(Le(),{onSuccess:()=>{X(),T(pe)}}),Ze=()=>{if(!C)return;const s=new Set(o.map(x=>`${x.eventType}|${x.scopeType}|${x.scopeId??""}`)),u=Object.entries(L).filter(([x,H])=>H.enabled||s.has(x)).map(([,x])=>x),I=!Ee,P=u.length>0;let _=!I,M=!P;const q=()=>{_&&M&&X()};I&&j.mutate({id:C.id,...Le()},{onSuccess:()=>{_=!0,q()}}),P?w.mutate({subscriptions:u},{onSuccess:()=>{M=!0,ve.success("Alert settings saved"),q()}}):q()},Y=d.useCallback(s=>{const u=`${s.eventType}|${s.scopeType}|${s.scopeId??""}`;W(I=>({...I,[u]:s}))},[]),Qe=d.useCallback((s,u)=>{C&&Y({eventType:s,channelId:C.id,scopeType:"org",enabled:u})},[C,Y]),Xe=d.useCallback((s,u)=>{if(!C)return;const I=C.id,P=de(u);for(const _ of F)Y({eventType:`${s}.${_}`,channelId:I,scopeType:"org",enabled:P.includes(_)});W(_=>{const M={};for(const x of o)x.channelId===I&&x.enabled&&x.scopeId&&x.eventType?.startsWith(s+".")&&(M[x.scopeType]||(M[x.scopeType]=new Set),M[x.scopeType].add(x.scopeId));for(const x of Object.values(_))x.channelId===I&&x.scopeId&&x.eventType?.startsWith(s+".")&&x.enabled&&(M[x.scopeType]||(M[x.scopeType]=new Set),M[x.scopeType].add(x.scopeId));for(const x of Object.values(_))x.channelId===I&&x.scopeId&&!x.enabled&&x.eventType?.startsWith(s+".")&&M[x.scopeType]?.has(x.scopeId)&&(Object.values(_).some(D=>D.channelId===I&&D.scopeId===x.scopeId&&D.scopeType===x.scopeType&&D.enabled&&D.eventType?.startsWith(s+"."))||M[x.scopeType].delete(x.scopeId));if(Object.keys(M).length===0)return _;const q={..._};for(const x of F){const H=`${s}.${x}`,D=P.includes(x);q[`${H}|org|`]={eventType:H,channelId:I,scopeType:"org",enabled:!1};for(const[A,O]of Object.entries(M))for(const $ of O)q[`${H}|${A}|${$}`]={eventType:H,channelId:I,scopeType:A,scopeId:$,enabled:D}}return q})},[C,o,Y]),Je=d.useCallback((s,u)=>{if(!C)return;const I=de(u);for(const P of F)Y({eventType:`${s}.${P}`,channelId:C.id,scopeType:"org",enabled:I.includes(P)})},[C,Y]),et=d.useCallback((s,u,I,P)=>{if(!C||!I)return;const _=de(P);for(const M of F)Y({eventType:`${u}.${M}`,channelId:C.id,scopeType:s,scopeId:I,enabled:_.includes(M)})},[C,Y]),tt=d.useCallback((s,u,I,P)=>{if(!C)return;const _=C.id,M=new Set(P);W(q=>{const x={};for(const A of o)A.channelId===_&&A.scopeId&&A.scopeType===s&&A.eventType?.startsWith(u+".")&&A.enabled&&(x[A.scopeId]=!0);for(const A of Object.values(q))A.channelId===_&&A.scopeId&&A.scopeType===s&&A.eventType?.startsWith(u+".")&&A.enabled&&(x[A.scopeId]=!0);for(const A of Object.keys(x)){const O=Object.values(q).filter($=>$.scopeId===A&&$.scopeType===s&&$.eventType?.startsWith(u+"."));O.length>0&&O.every($=>!$.enabled)&&(x[A]=!1)}const H=new Set(Object.entries(x).filter(([,A])=>A).map(([A])=>A)),D={...q};for(const A of I){const O=`${u}.${A}`;if(P.length===0){D[`${O}|org|`]={eventType:O,channelId:_,scopeType:"org",enabled:!0};for(const $ of H)D[`${O}|${s}|${$}`]={eventType:O,channelId:_,scopeType:s,scopeId:$,enabled:!1}}else{D[`${O}|org|`]={eventType:O,channelId:_,scopeType:"org",enabled:!1};for(const $ of P)D[`${O}|${s}|${$}`]={eventType:O,channelId:_,scopeType:s,scopeId:$,enabled:!0};for(const $ of H)M.has($)||(D[`${O}|${s}|${$}`]={eventType:O,channelId:_,scopeType:s,scopeId:$,enabled:!1})}}for(const A of F)if(!I.includes(A)){const O=`${u}.${A}`;D[`${O}|org|`]={eventType:O,channelId:_,scopeType:"org",enabled:!1};for(const $ of H)D[`${O}|${s}|${$}`]={eventType:O,channelId:_,scopeType:s,scopeId:$,enabled:!1}}return D})},[C,o]),ie=i.isPending||j.isPending;return b?e.jsx("div",{className:"animate-pulse space-y-4",children:[1,2,3].map(s=>e.jsxs("div",{className:"border border-border rounded-xl p-5 flex items-center gap-3.5",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-surface-tertiary shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-32 bg-surface-tertiary rounded"}),e.jsx("div",{className:"h-3 w-48 bg-surface-tertiary rounded"})]}),e.jsx("div",{className:"h-5 w-16 bg-surface-tertiary rounded-full"})]},s))}):p?e.jsx(Be,{title:"Failed to load channels",error:y,onRetry:v,resource:"notification channels"}):e.jsxs("div",{children:[e.jsx("p",{className:"mb-5 text-sm text-text-secondary",children:"Manage notification channels and configure alert routing."}),he.length===0?e.jsx("div",{className:"border border-border rounded-xl bg-surface p-12",children:e.jsx(rt,{icon:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1,stroke:"currentColor",className:"h-10 w-10 text-text-muted",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.857 17.082a23.848 23.848 0 0 0 5.454-1.31A8.967 8.967 0 0 1 18 9.75V9A6 6 0 0 0 6 9v.75a8.967 8.967 0 0 1-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 0 1-5.714 0m5.714 0a3 3 0 1 1-5.714 0"})}),title:"No channels configured",description:"Add a Slack, Teams, Google Chat, or webhook channel to start receiving notifications.",action:c&&e.jsx(Z,{onClick:Se,children:"+ Add Channel"})})}):e.jsx("div",{className:"space-y-3",children:he.map(s=>e.jsx(Ct,{platform:s.value,channels:te[s.value],alertCounts:Te,expanded:!!ee[s.value],onToggleExpand:()=>He(s.value),onConfigureChannel:Ve,onDeleteChannel:u=>l(u),onTestChannel:u=>S.mutate(u.id),isTestPending:S.isPending,canUpdate:N,canDelete:k},s.value))}),e.jsx(xe,{open:E==="add",onClose:X,title:"Add Channel",footer:e.jsxs(e.Fragment,{children:[e.jsx(Z,{onClick:Ye,disabled:ie||!Ae,children:ie?"Adding...":"Add Channel"}),e.jsx(Z,{variant:"secondary",onClick:X,children:"Cancel"})]}),children:e.jsxs("div",{className:"space-y-5",children:[e.jsx(V,{label:"Platform",required:!0,children:e.jsx(Tt,{value:n.platform,onChange:s=>U("platform",s)})}),e.jsx(kt,{platform:n.platform}),e.jsx(V,{label:"Channel Name",required:!0,children:e.jsx(G,{type:"text",placeholder:"e.g. DevOps Alerts",value:n.name,onChange:s=>U("name",s.target.value)})}),ce?e.jsxs(e.Fragment,{children:[e.jsx(V,{label:"Bot Token",required:!0,children:e.jsx(G,{type:"text",placeholder:"xoxb-...",value:n.slackBotToken,onChange:s=>U("slackBotToken",s.target.value)})}),e.jsx(V,{label:"Channel ID",required:!0,children:e.jsx(G,{type:"text",placeholder:"C01ABC...",value:n.slackChannelId,onChange:s=>U("slackChannelId",s.target.value)})}),e.jsx(V,{label:"Signing Secret",required:!0,children:e.jsxs("div",{className:"relative",children:[e.jsx(G,{type:J?"text":"password",placeholder:"e7ecbb90...",value:n.slackSigningSecret,onChange:s=>U("slackSigningSecret",s.target.value),className:"pr-10"}),e.jsx("button",{type:"button",onClick:()=>le(s=>!s),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 text-text-muted hover:text-text-primary transition-colors","aria-label":J?"Hide secret":"Show secret",children:J?e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.98 8.223A10.477 10.477 0 0 0 1.934 12c1.292 4.338 5.31 7.5 10.066 7.5.993 0 1.953-.138 2.863-.395M6.228 6.228A10.451 10.451 0 0 1 12 4.5c4.756 0 8.773 3.162 10.065 7.498a10.522 10.522 0 0 1-4.293 5.774M6.228 6.228 3 3m3.228 3.228 3.65 3.65m7.894 7.894L21 21m-3.228-3.228-3.65-3.65m0 0a3 3 0 1 0-4.243-4.243m4.242 4.242L9.88 9.88"})}):e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})]})})]})})]}):e.jsxs(V,{label:"Webhook URL",required:!0,children:[e.jsx(G,{type:"url",placeholder:Oe[n.platform],value:n.webhookUrl,onChange:s=>U("webhookUrl",s.target.value)}),e.jsxs("p",{className:"text-xs text-text-muted mt-1.5",children:["Paste the incoming webhook URL from your ",ge[n.platform]?.label," ","workspace."]})]})]})}),e.jsx(xe,{open:E==="configure",onClose:X,title:"Channel Settings",footer
6:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[k&&C&&e.jsx(Z,{variant:"delete",size:"sm",onClick:()=>{X(),l(C)},children:"Delete"}),C&&e.jsx(Z,{variant:"secondary",size:"sm",onClick:()=>S.mutate(C.id),disabled:S.isPending,children:S.isPending?"Testing...":"Test Notification"})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[Object.keys(L).length>0&&e.jsx("span",{className:"text-xs text-amber-500 font-medium",children:"Unsaved changes"}),e.jsx(Z,{variant:"secondary",onClick:X,children:"Cancel"}),e.jsx(Z,{onClick:Ze,disabled:ie||!Ae||Ee&&!Ke,children:ie?"Saving...":"Save"})]})]}),children:C&&e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex items-center gap-3.5 p-4 rounded-xl bg-surface-secondary border border-border",children:[e.jsx("div",{className:"flex items-center justify-center h-10 w-10 rounded-lg bg-surface border border-border shadow-sm shrink-0",children:ue[n.platform]??ue.webhook}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-text-primary truncate",children:n.name||"Unnamed"}),e.jsx("p",{className:"text-xs text-text-muted",children:ge[n.platform]?.label})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-success-500"}),e.jsx("span",{className:"text-xs text-success-600 font-medium",children:"Connected"})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-text-muted mb-3",children:"Connection"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(V,{label:"Name",children:e.jsx(G,{type:"text",value:n.name,onChange:s=>U("name",s.target.value)})}),ce?e.jsxs(e.Fragment,{children:[e.jsx(V,{label:"Bot Token",children:e.jsx(G,{type:"text",placeholder:"xoxb-...",value:n.slackBotToken,onChange:s=>U("slackBotToken",s.target.value)})}),e.jsx(V,{label:"Channel ID",children:e.jsx(G,{type:"text",placeholder:"C01ABC...",value:n.slackChannelId,onChange:s=>U("slackChannelId",s.target.value)})}),e.jsx(V,{label:"Signing Secret",children:e.jsxs("div",{className:"relative",children:[e.jsx(G,{type:J?"text":"password",placeholder:"e7ecbb90...",value:n.slackSigningSecret,onChange:s=>U("slackSigningSecret",s.target.value),className:"pr-10"}),e.jsx("button",{type:"button",onClick:()=>le(s=>!s),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 text-text-muted hover:text-text-primary transition-colors","aria-label":J?"Hide secret":"Show secret",children:J?e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.98 8.223A10.477 10.477 0 0 0 1.934 12c1.292 4.338 5.31 7.5 10.066 7.5.993 0 1.953-.138 2.863-.395M6.228 6.228A10.451 10.451 0 0 1 12 4.5c4.756 0 8.773 3.162 10.065 7.498a10.522 10.522 0 0 1-4.293 5.774M6.228 6.228 3 3m3.228 3.228 3.65 3.65m7.894 7.894L21 21m-3.228-3.228-3.65-3.65m0 0a3 3 0 1 0-4.243-4.243m4.242 4.242L9.88 9.88"})}):e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})]})})]})})]}):e.jsx(V,{label:"Webhook URL",children:e.jsx(G,{type:"url",value:n.webhookUrl,onChange:s=>U("webhookUrl",s.target.value),placeholder:Oe[n.platform]})})]})]}),m.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-text-muted mb-1",children:"Alert Routing"}),e.jsx("p",{className:"text-xs text-text-muted mb-4",children:"Choose which events send notifications to this channel."}),e.jsx(Mt,{channelId:C.id,eventTypes:m,subscriptions:o,onToggle:Qe,onSliderChange:Xe,onLevelChange:Je,onScopedToggle:tt,onScopedLevelChange:et,saving:w.isPending,canUpdate:N,pendingSubs:L,onEntityError:Ie})]})]})}),e.jsx(ct,{open:!!z,onClose:()=>l(null),title:"Delete Channel",confirmLabel:"Delete",loadingLabel:"Deleting...",variant:"delete",typeToConfirm:ht(z),requireTypeToConfirm:!0,isLoading:g.isPending,onConfirm:()=>g.mutate(z.id,{onSuccess:()=>l(null)}),children:e.jsx("div",{className:"p-3.5 rounded-xl bg-danger-500/10 border border-danger-500/20",children:e.jsx("p",{className:"text-sm text-danger-500",children:"This will permanently remove the channel and all its alert subscriptions. This cannot be undone."})})})]})}),Ne={all:()=>["email-preferences"],list:()=>[...Ne.all(),"list"]};function Rt(){return je({queryKey:Ne.list(),queryFn:()=>oe.get("/notifications/email-preferences"),select:t=>t??[]})}function Dt(){const t=De();
6return ze({mutationFn:({eventKey:a,enabled:r})=>oe.put(`/notifications/email-preferences/${a}`,{enabled:r}),onSuccess:()=>{t.invalidateQueries({queryKey:Ne.all()})},onError:()=>ve.error("Failed to update email preference")})}const zt=[{category:"User Management",events:[{key:"user_added_to_org",name:"User added to organization",description:"Notifies the invited user when they are added to the organization."},{key:"user_removed_from_org",name:"User removed from organization",description:"Notifies the user when they are removed from the organization."}]},{category:"Roles & Permissions",events:[{key:"role_assigned",name:"Role assigned",description:"Notifies the user when a new role is assigned to them."},{key:"role_changed",name:"Role changed",description:"Notifies the user when their existing role is modified."},{key:"role_removed",name:"Role removed",description:"Notifies the user when a role is revoked from them."}]},{category:"Team Membership",events:[{key:"member_added_to_team",name:"Member added to team",description:"Notifies the user when they are added to a team."},{key:"member_removed_from_team",name:"Member removed from team",description:"Notifies the user when they are removed from a team."}]},{category:"Cloud Alerts",events:[{key:"resource_alert",name:"Cloud alert raised",description:"Notifies organization admins by email when a cloud alert is raised for this organization."}]},{category:"Getting Started",events:[{key:"onboarding_complete",name:"Setup complete",description:"Sent once when the first cloud account finishes discovery, summarising what was found."},{key:"recommendations_ready",name:"Recommendations ready",description:"Sent once when the first savings recommendations are available for this organization."}]},{category:"Budgets & Billing",events:[{key:"budget_alert",name:"Budget threshold reached",description:"Emails organization admins when a budget crosses its warning or exceeded threshold and no notification channel is configured."}]}];function Ft({checked:t,onChange:a,disabled:r}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,onClick:r?void 0:a,disabled:r,className:`relative inline-flex h-6 w-11 shrink-0 rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 ${r?"cursor-not-allowed opacity-50":"cursor-pointer"} ${t?"bg-success-500":"bg-text-muted/30"}`,children:e.jsx("span",{className:`pointer-events-none inline-flex h-5 w-5 transform items-center justify-center rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ${t?"translate-x-5":"translate-x-0"}`})})}function Wt(){const{data:t=[],isLoading:a,isError:r,error:f,refetch:b}=Rt(),p=Dt(),y=ne(re.NOTIFICATION_UPDATE),v={};for(const o of t)v[o.eventKey]=o.enabled;const m=o=>v[o]??!0;return a?e.jsx(at,{}):r?e.jsx(Be,{title:"Failed to load email preferences",error:f,onRetry:b,resource:"email preferences"}):e.jsxs("div",{children:[e.jsx("div",{className:"p-4 rounded-xl bg-surface-secondary border border-border mb-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"shrink-0 mt-0.5",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-5 w-5 text-primary-500",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 0 1-2.25 2.25h-15a2.25 2.25 0 0 1-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0 0 19.5 4.5h-15a2.25 2.25 0 0 0-2.25 2.25m19.5 0v.243a2.25 2.25 0 0 1-1.07 1.916l-7.5 4.615a2.25 2.25 0 0 1-2.36 0L3.32 8.91a2.25 2.25 0 0 1-1.07-1.916V6.75"})})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-text-primary",children:"Transactional Emails"}),e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:"These emails are sent automatically when key account events occur. Toggle individual events on or off to control which notifications are delivered."})]})]})}),e.jsx("div",{className:"space-y-4",children:zt.map(o=>e.jsxs("div",{className:"border border-border rounded-xl overflow-hidden",children:[e.jsx("div",{className:"px-5 py-3 bg-surface-secondary/50 border-b border-border",children:e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-text-secondary",children:o.category})}),e.jsx("div",{className:"divide-y divide-border",children:o.events.map(i=>e.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",children:[e.jsxs("div",{className:"min-w-0 flex-1 pr-4",children:[e.jsx("p",{className:"text-sm font-medium text-text-primary",children:i.name}),e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:i.description})]}),e.jsx(Ft,{checked:m(i.key),onChange:()=>
6p.mutate({eventKey:i.key,enabled:!m(i.key)}),disabled:!y})]},i.key))})]},o.category))})]})}const Ut=[{value:"channels",label:"Channels & Alerts"},{value:"emails",label:"Emails"}];function ns(){const[t,a]=d.useState("channels"),r=d.useRef(null),f=ne(re.NOTIFICATION_CREATE),{data:b=[]}=Re(),p=t==="channels"&&f&&b.length>0?e.jsx(Z,{onClick:()=>r.current?.openAdd(),className:"whitespace-nowrap shrink-0",children:"+ Add Channel"}):null;return e.jsxs("div",{className:"space-y-6",children:[e.jsx("h1",{className:"sr-only",children:"Notifications & Alerts"}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx(lt,{tabs:Ut,active:t,onChange:a}),p]}),t==="channels"&&e.jsx(Bt,{ref:r}),t==="emails"&&e.jsx(Wt,{})]})}export{ns as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.