1import{k as r,l as n,i as z}from"./app-C23pyaid.js";import{D as K}from"./DashboardLayout-C7ZUhX3E.js";import{P as M}from"./PageHeader-C_haTbyT.js";import{s as D}from"./index-FSFl0VXl.js";import{B as w}from"./button-BJDSJoXt.js";import{a as A}from"./utils-DvGlLt9s.js";import{A as O,h as Y,c as _,f as J,g as G,d as Q,e as U,b as X,a as Z}from"./alert-dialog--xIyN_N0.js";import{C as P}from"./card-BRGtWTV3.js";import{L as $}from"./label-DMHYcBFO.js";import{I}from"./input-4R0coVUt.js";import{a as ee,u as re,F as te}from"./FormChangesBanner-Ckxp49y5.js";import{m as F}from"./proxy-4aWI02cb.js";import{V as k}from"./volume-2-ZJZ-r4Da.js";import{P as S}from"./plus-Dm4Rz2g5.js";import{L as oe}from"./loader-circle-DPj1_t_3.js";import{T as ne}from"./trash-2-mliWMKi-.js";import{C as E}from"./circle-alert-C_gfljDL.js";/* empty css */import"./app-sidebar-IQ8kf7v7.js";import"./PremiumIndicator-CJKijEH_.js";import"./crown-BzO6vmj8.js";import"./createLucideIcon-DtkNhD0y.js";import"./index-yCbMbx6L.js";import"./index-D5RZUrgt.js";import"./index-BFDhkdEZ.js";import"./x-DpaqY1h0.js";import"./intercom-7ryrOXJ7.js";import"./webCall-B8ioDy5-.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"./phone-Cx-YTElW.js";import"./arrow-right-DmEoEHy2.js";import"./mail-CxvMrt8f.js";import"./FacebookCookieManager-B-UAeGDV.js";import"./FacebookPixel-BCntTdvu.js";import"./triangle-alert-2vXudR_f.js";import"./info-auHup_nQ.js";import"./useCompanyNotifications-sZAYcoRP.js";import"./GoogleAnalytics-DI5OpeSs.js";import"./user-h93OoGTe.js";import"./index-BqXUTREf.js";function ie({pronunciations:a}){const c=re(),R=c.resetKey,h=n.useCallback(()=>a.map(e=>({id:e.id,word:e.word,pronunciation:e.pronunciation})),[a]),[i,u]=n.useState(h),[d,f]=n.useState({}),[T,g]=n.useState(null),[j,v]=n.useState(null),m=n.useRef(null),p=n.useRef(null),x=n.useMemo(()=>a.map(e=>({id:e.id,word:e.word,pronunciation:e.pronunciation})),[a]),L=n.useMemo(()=>JSON.stringify(a.map(e=>e.id)),[a]);n.useEffect(()=>{u(h()),f({})},[L,R,h]);const y=n.useMemo(()=>{if(i.filter(t=>t.isNew).some(t=>t.word.trim()||t.pronunciation.trim())||i.length!==x.length)return!0;for(const t of i){if(t.isNew)continue;const o=x.find(s=>s.id===t.id);if(!o||t.word!==o.word||t.pronunciation!==o.pronunciation)return!0}return!1},[i,x]);n.useEffect(()=>{if(p.current&&m.current){m.current.scrollIntoView({behavior:"smooth",block:"center"});const e=m.current.querySelector('input[data-field="word"]');e&&setTimeout(()=>e.focus(),300),p.current=null}},[i]);const b=n.useCallback(()=>{const e=[];for(const t of i)t.isNew?(t.word.trim()||t.pronunciation.trim())&&e.push({word:t.word,pronunciation:t.pronunciation,is_new:!0}):e.push({id:t.id,word:t.word,pronunciation:t.pronunciation});return{pronunciations:e}},[i]);n.useEffect(()=>(c.registerForm("pronunciations",{isDirty:!1,getData:b}),()=>c.unregisterForm("pronunciations")),[c,b]),n.useEffect(()=>{c.updateFormState("pronunciations",y)},[c,y]);const V=n.useCallback(()=>{const e={},t=[];for(const o of i){if(o.isNew&&!o.word.trim()&&!o.pronunciation.trim())continue;o.word.trim()||(e[`pron-${o.id}-word`]="Word is required"),o.pronunciation.trim()||(e[`pron-${o.id}-pronunciation`]="Pronunciation is required");const s=o.word.trim().toLowerCase();s&&(t.includes(s)?e[`pron-${o.id}-word`]="Duplicate word":t.push(s))}return f(e),Object.keys(e).length===0},[i]),N=()=>{const e=`new-${Date.now()}`;p.current=e,u(t=>[...t,{id:e,word:"",pronunciation:"",isNew:!0}])},C=(e,t,o)=>{u(s=>s.map(l=>l.id===e?{...l,[t]:o}:l)),f(s=>{const l=`pron-${e}-${t}`;if(s[l]){const{[l]:se,...q}=s;return q}return s})},B=e=>{e.startsWith("new-")?(u(t=>t.filter(o=>o.id!==e)),g(null)):(v(e),g(null),z.delete(D("pronunciations.delete",e),{preserveScroll:!0,onFinish:()=>v(null)}))},H={hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:.05}}},W={hidden:{y:10,opacity:0},visible:{y:0,opacity:1,transition:{type:"spring",stiffness:100,damping:15}}};return r.jsxs(K,{title:"Pronunciations",breadcrumbs:["Agent Setup","Identity & Voice","Pronunciations"],metaDescription:"Help your agent pronounce company names, emails, and other words correctly.",children:[r.jsxs(F.div,{className:"space-y-6 px-0 md:px-4 pb-20",initial:"hidden",animate:"visible",variants:H,children:[r.jsx(M,{icon:k,title:"Pronunciations",subtitle:"Help your agent pronounce company names, emails, and other words correctly. e.g. [email protected] â hello at hotmail dot com",button:r.jsxs(w,{variant:"default",size:"default",className:"gap-2 w-full md:w-auto",onClick:N,children:[r.jsx(S,{className:"w-4 h-4"}),"Add Pronunciation"]})}),r.jsx(F.div,{variants:W,children:i.length>0?r.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:i.map(e=>r.jsxs(P,{ref:e.id===p.current?m:void 0,className:"p-4 border border-border",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[r.jsx($,{htmlFor:`pron-${e.id}
1-word`,className:"text-sm font-medium text-secondary-foreground/60",children:"Word"}),r.jsxs(O,{open:T===e.id,onOpenChange:t=>g(t?e.id:null),children:[r.jsx(Y,{asChild:!0,children:r.jsx(w,{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:j===e.id,children:j===e.id?r.jsx(oe,{className:"h-4 w-4 animate-spin"}):r.jsx(ne,{className:"h-4 w-4"})})}),r.jsxs(_,{children:[r.jsxs(J,{children:[r.jsx(G,{children:"Remove pronunciation?"}),r.jsx(Q,{children:e.isNew?"This will remove this unsaved pronunciation.":"This will permanently remove this pronunciation. Your agent will no longer use this custom pronunciation."})]}),r.jsxs(U,{children:[r.jsx(X,{children:"Cancel"}),r.jsx(Z,{className:"bg-destructive hover:bg-destructive/90 text-card",onClick:()=>B(e.id),children:"Remove"})]})]})]})]}),r.jsx(I,{id:`pron-${e.id}-word`,"data-field":"word",value:e.word,onChange:t=>C(e.id,"word",t.target.value),placeholder:"e.g. Acme",className:A(d[`pron-${e.id}-word`]&&"border-destructive bg-destructive/10")}),d[`pron-${e.id}-word`]&&r.jsxs("p",{className:"text-xs text-destructive flex items-center gap-1 mt-1",children:[r.jsx(E,{className:"h-3 w-3"}),d[`pron-${e.id}-word`]]}),r.jsxs("div",{className:"mt-4",children:[r.jsx($,{htmlFor:`pron-${e.id}-pronunciation`,className:"text-sm font-medium text-secondary-foreground/60",children:"Say as"}),r.jsx(I,{id:`pron-${e.id}-pronunciation`,"data-field":"pronunciation",value:e.pronunciation,onChange:t=>C(e.id,"pronunciation",t.target.value),placeholder:"e.g. Ack-me",className:A("mt-2",d[`pron-${e.id}-pronunciation`]&&"border-destructive bg-destructive/10")}),d[`pron-${e.id}-pronunciation`]&&r.jsxs("p",{className:"text-xs text-destructive flex items-center gap-1 mt-1",children:[r.jsx(E,{className:"h-3 w-3"}),d[`pron-${e.id}-pronunciation`]]})]})]},e.id))}):r.jsx(P,{className:"border",children:r.jsxs("div",{className:"py-12 text-center",children:[r.jsx("div",{className:"h-12 w-12 rounded-full bg-muted-foreground/5 flex items-center justify-center mx-auto mb-4",children:r.jsx(k,{className:"h-6 w-6 text-secondary-foreground/60"})}),r.jsx("h3",{className:"text-base font-medium text-secondary-foreground mb-1",children:"No Pronunciations Added Yet"}),r.jsx("p",{className:"text-sm text-secondary-foreground/60 max-w-sm mx-auto",children:"Add custom pronunciations to help your agent say company names, emails, and other words correctly."}),r.jsxs(w,{variant:"default",size:"default",className:"gap-2 mt-4",onClick:N,children:[r.jsx(S,{className:"w-4 h-4"}),"Add Your First Pronunciation"]})]})})})]}),r.jsx(te,{endpoint:D("pronunciations.bulk-update"),method:"put",onBeforeSubmit:V})]})}function Xe({pronunciations:a}){return r.jsx(ee,{children:r.jsx(ie,{pronunciations:a})})}export{Xe 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.