1import{l as r,k as e,i as K}from"./app-C23pyaid.js";import{D as O}from"./DashboardLayout-C7ZUhX3E.js";import{P as z}from"./PageHeader-C_haTbyT.js";import{s as E}from"./index-FSFl0VXl.js";import{B as y}from"./button-BJDSJoXt.js";import{B as V,a2 as q,a0 as H,a3 as Y,a1 as J}from"./app-sidebar-IQ8kf7v7.js";import{a as I}from"./utils-DvGlLt9s.js";import{A as U,h as W,c as X,f as G,g as Q,d as Z,e as ee,b as te,a as se}from"./alert-dialog--xIyN_N0.js";import{C as A,a as re}from"./card-BRGtWTV3.js";import{L as ie}from"./label-DMHYcBFO.js";import{I as ae}from"./input-4R0coVUt.js";import{b as oe,a as ne,u as le,F as ce}from"./FormChangesBanner-Ckxp49y5.js";import{B as de}from"./badge-CXIN1lAq.js";import{S as me}from"./switch-B4a_P8cM.js";import{C as ue}from"./useCompanyNotifications-sZAYcoRP.js";import{C as fe}from"./circle-x-DtxsOQ7N.js";import{m as D}from"./proxy-4aWI02cb.js";import{P as $}from"./plus-Dm4Rz2g5.js";import{M as _}from"./mail-CxvMrt8f.js";import{L as he}from"./loader-circle-DPj1_t_3.js";import{T as pe}from"./trash-2-mliWMKi-.js";import{C as ge}from"./circle-alert-C_gfljDL.js";/* empty css */import"./createLucideIcon-DtkNhD0y.js";import"./FacebookCookieManager-B-UAeGDV.js";import"./FacebookPixel-BCntTdvu.js";import"./x-DpaqY1h0.js";import"./triangle-alert-2vXudR_f.js";import"./info-auHup_nQ.js";import"./GoogleAnalytics-DI5OpeSs.js";import"./index-D5RZUrgt.js";import"./phone-Cx-YTElW.js";import"./user-h93OoGTe.js";import"./webCall-B8ioDy5-.js";import"./PremiumIndicator-CJKijEH_.js";import"./crown-BzO6vmj8.js";import"./index-yCbMbx6L.js";import"./index-BFDhkdEZ.js";import"./intercom-7ryrOXJ7.js";import"./chevron-right-D7qsCfhd.js";import"./arrow-left-C4b2GcAr.js";import"./Logo--fg2BGnt.js";import"./useAppTheme-DhGyT_BZ.js";import"./hook-Ctp552oP.js";import"./check-Bcca0OH5.js";import"./arrow-right-DmEoEHy2.js";import"./index-BqXUTREf.js";import"./index-D8b57Ql5.js";function xe({id:c,title:u,fieldKey:g,initialEnabled:m,enabledText:i,disabledText:h,icon:w}){const[a,b]=r.useState(m),n=oe(),d=`status_toggle_${c}`,x=r.useRef(a);r.useEffect(()=>{x.current=a},[a]);const f=r.useCallback(()=>({[g]:x.current,section_key:d}),[d,g]);r.useEffect(()=>{if(n)return n.registerForm(d,{isDirty:!1,getData:f}),()=>{n.unregisterForm(d)}},[n,d,f]),r.useEffect(()=>{if(!n)return;const v=a!==m;n.updateFormState(d,v)},[n,d,a,m]);const p=(n==null?void 0:n.resetKey)??0;r.useEffect(()=>{b(m)},[p,m]);const j=v=>{b(v)};return e.jsx(A,{className:"border",children:e.jsx(re,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:`hidden md:flex w-12 h-12 rounded-full items-center justify-center ${a?"bg-success/10":"bg-background"}`,children:a?e.jsx(ue,{className:"text-success h-6 w-6"}):e.jsx(fe,{className:"text-secondary-foreground/60 h-6 w-6"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"text-lg font-semibold",children:u}),e.jsx(de,{variant:a?"default":"secondary",children:a?"Active":"Inactive"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a?i:h})]})]}),e.jsx(me,{id:g,checked:a,onCheckedChange:j,className:"scale-125"})]})})})}function je({notifications:c}){const u=le(),g=u.resetKey,m=r.useCallback(()=>c.contacts.map(t=>({id:t.id,email:t.email})),[c.contacts]),[i,h]=r.useState(m),[w,a]=r.useState({}),[b,n]=r.useState(null),[d,x]=r.useState(null),f=r.useRef(null),p=r.useRef(null),j=r.useMemo(()=>c.contacts.map(t=>({id:t.id,email:t.email})),[c.contacts]),v=r.useMemo(()=>JSON.stringify(c.contacts.map(t=>t.id)),[c.contacts]);r.useEffect(()=>{h(m()),a({})},[v,g,m]);const k=r.useMemo(()=>{if(i.filter(s=>s.isNew).some(s=>s.email.trim())||i.length!==j.length)return!0;for(const s of i){if(s.isNew)continue;const l=j.find(o=>o.id===s.id);if(!l||s.email!==l.email)return!0}return!1},[i,j]);r.useEffect(()=>{if(p.current&&f.current){f.current.scrollIntoView({behavior:"smooth",block:"center"});const t=f.current.querySelector('input[type="email"]');t&&setTimeout(()=>t.focus(),300),p.current=null}},[i]);const T=r.useCallback(()=>{const t=[];
1for(const s of i)s.isNew?s.email.trim()&&t.push({email:s.email,is_new:!0}):t.push({id:s.id,email:s.email});return{contacts:t}},[i]);r.useEffect(()=>(u.registerForm("contacts",{isDirty:!1,getData:T}),()=>u.unregisterForm("contacts")),[u,T]),r.useEffect(()=>{u.updateFormState("contacts",k)},[u,k]);const R=r.useCallback(()=>{const t={},s=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,l=[];for(const o of i){if(o.isNew&&!o.email.trim())continue;const C=o.email.trim().toLowerCase();C?s.test(C)?l.includes(C)?t[`contact-${o.id}-email`]="Duplicate email address":l.push(C):t[`contact-${o.id}-email`]="Please enter a valid email address":t[`contact-${o.id}-email`]="Email address is required"}return a(t),Object.keys(t).length===0},[i]),S=()=>{if(i.length>=5)return;const t=`new-${Date.now()}`;p.current=t,h(s=>[...s,{id:t,email:"",isNew:!0}])},B=(t,s)=>{h(l=>l.map(o=>o.id===t?{...o,email:s}:o)),a(l=>{const o=`contact-${t}-email`;if(l[o]){const{[o]:C,...L}=l;return L}return l})},M=t=>{t.startsWith("new-")?(h(s=>s.filter(l=>l.id!==t)),n(null)):(x(t),n(null),K.delete(E("notifications.contacts.delete",t),{preserveScroll:!0,onFinish:()=>x(null)}))},N=i.length<5,P={hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:.05}}},F={hidden:{y:10,opacity:0},visible:{y:0,opacity:1,transition:{type:"spring",stiffness:100,damping:15}}};return e.jsxs(O,{title:"Notifications",breadcrumbs:["Account","Notifications"],metaDescription:"Manage your notification preferences and contacts",children:[e.jsxs(D.div,{className:"space-y-6 px-0 md:px-4 pb-20",initial:"hidden",animate:"visible",variants:P,children:[e.jsx(z,{icon:V,title:"Notification Settings",subtitle:"Manage who receives notifications when new calls are received.",button:e.jsx(q,{children:e.jsxs(H,{children:[e.jsx(Y,{asChild:!0,children:e.jsxs(y,{variant:"default",size:"default",className:I("gap-2 w-full md:w-auto",!N&&"opacity-50 cursor-not-allowed"),onClick:S,disabled:!N,children:[e.jsx($,{className:"w-4 h-4"}),"Add Contact"]})}),!N&&e.jsx(J,{children:e.jsx("p",{children:"Maximum of 5 contacts allowed"})})]})})}),e.jsx(D.div,{variants:F,children:i.length>0?e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:i.map(t=>e.jsxs(A,{ref:t.id===p.current?f:void 0,className:"p-4 border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ie,{htmlFor:`contact-${t.id}-email`,className:"text-sm font-medium text-secondary-foreground",children:"Email Address"})]}),e.jsxs(U,{open:b===t.id,onOpenChange:s=>n(s?t.id:null),children:[e.jsx(W,{asChild:!0,children:e.jsx(y,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 rounded-full text-secondary-foreground/60 hover:text-destructive hover:bg-destructive/10",disabled:d===t.id,children:d===t.id?e.jsx(he,{className:"h-4 w-4 animate-spin"}):e.jsx(pe,{className:"h-4 w-4"})})}),e.jsxs(X,{children:[e.jsxs(G,{children:[e.jsx(Q,{children:"Remove contact?"}),e.jsx(Z,{children:t.isNew?"This will remove this unsaved contact.":"This will permanently remove this contact from your list. They will no longer receive email notifications when calls are received."})]}),e.jsxs(ee,{children:[e.jsx(te,{children:"Cancel"}),e.jsx(se,{className:"bg-destructive hover:bg-destructive/90 text-card",onClick:()=>M(t.id),children:"Remove"})]})]})]})]}),e.jsx(ae,{id:`contact-${t.id}-email`,type:"email",value:t.email,onChange:s=>B(t.id,s.target.value),placeholder:"[email protected]",className:I(w[`contact-${t.id}-email`]&&"border-destructive bg-destructive/10")}),w[`contact-${t.id}-email`]&&e.jsxs("p",{className:"text-xs text-destructive flex items-center gap-1 mt-1",children:[e.jsx(ge,{className:"h-3 w-3"}),w[`contact-${t.id}-email`]]})]},t.id))}):e.jsx(A,{className:"border",children:e.jsxs("div",{className:"py-12 text-center",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-muted-foreground/5 flex items-center justify-center mx-auto mb-4",children:e.jsx(_,{className:"h-6 w-6 text-secondary-foreground/60"})}),e.jsx("h3",{className:"text-base font-medium text-secondary-foreground mb-1",children:"No Contacts Added Yet"}
1),e.jsx("p",{className:"text-sm text-secondary-foreground/60 max-w-sm mx-auto",children:"Add contacts to receive email notifications when new calls are received."}),e.jsxs(y,{variant:"default",size:"default",className:"gap-2 mt-4",onClick:S,children:[e.jsx($,{className:"w-4 h-4"}),"Add Your First Contact"]})]})})}),e.jsx(D.div,{variants:F,children:e.jsx(xe,{id:"skip-no-conversation",title:"Skip Unanswered Call Notifications",fieldKey:"skip_no_conversation_notifications",initialEnabled:c.skip_no_conversation_notifications,enabledText:"Calls where the caller didn't respond or lasted less than 15 seconds won't trigger a notification",disabledText:"Calls where the caller didn't respond or lasted less than 15 seconds won't trigger a notification"})})]}),e.jsx(ce,{endpoint:E("notifications.contacts.bulk-update"),method:"put",onBeforeSubmit:R})]})}function ft({notifications:c}){return e.jsx(ne,{children:e.jsx(je,{notifications:c})})}export{ft 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.