1import{r as p,j as e,L as y}from"./vendor-react-DK_MHVKo.js";import{u as P,_ as I,b as k,z as C}from"./index-Djo5SZyv.js";import{V as R}from"./VoicePicker-sG7CxSBL.js";import{ac as j,t as h,ao as S,P as D,as as q,ak as T,n as O,e as V,p as F,a6 as H}from"./vendor-icons-Dr_X1Hjo.js";import"./vendor-query-Ceg45NlR.js";const M=["07:00","07:30","08:00","08:30","09:00","09:30","10:00"],z=["17:00","17:30","18:00","18:30","19:00","19:30","20:00","20:30","21:00"],E=(t,i)=>i&&!t.includes(i)?[...t,i].sort():t,B=t=>[{id:"",label:t("inbound.settings.ambientNone")},{id:"call-center",label:t("inbound.settings.ambientOffice")},{id:"coffee-shop",label:t("inbound.settings.ambientCafe")},{id:"convention-hall",label:t("inbound.settings.ambientConference")},{id:"summer-outdoor",label:t("inbound.settings.ambientOutdoor")},{id:"static-noise",label:t("inbound.settings.ambientWhiteNoise")}];function g({label:t,value:i,min:c,max:s,step:a,hints:_,onChange:v}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("label",{className:"text-xs text-slate-400",children:t}),e.jsx("span",{className:"text-xs text-emerald-400 font-mono w-8 text-right",children:i.toFixed(1)})]}),e.jsx("input",{type:"range",min:c,max:s,step:a,value:i,onChange:r=>v(parseFloat(r.target.value)),className:`w-full h-1.5 max-lg:h-2.5 rounded-full appearance-none cursor-pointer bg-slate-700 accent-emerald-500 2 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3.5 [&::-webkit-slider-thumb]:h-3.5 3 max-lg:[&::-webkit-slider-thumb]:w-6 max-lg:[&::-webkit-slider-thumb]:h-6 4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-emerald-500 [&::-webkit-slider-thumb]:shadow-lg`}),e.jsx("div",{className:"flex justify-between text-[10px] text-slate-600 mt-0.5",children:_.map((r,b)=>
4e.jsx("span",{children:r},b))})]})}function K(){const{t}=P(),{user:i}=I(),c=B(t),[s,a]=p.useState(null),[_,v]=p.useState(!0),[r,b]=p.useState(!1);p.useEffect(()=>{k.get("/inbound/config").then(n=>{var l;return a(((l=n.data)==null?void 0:l.data)||n.data)}).catch(()=>a(null)).finally(()=>v(!1))},[]);const N=async()=>{var n,l,o;if(s){b(!0);try{const m=await k.patch("/inbound/config",{active_hours_start:s.active_hours_start,active_hours_end:s.active_hours_end,active_days:s.active_days||[1,2,3,4,5],voice_id:s.voice_id||"custom_voice_dd4e5af09ac1689bcdd16b3783",agent_display_name:s.agent_display_name||null,ambient_sound:s.ambient_sound||null,voice_speed:s.voice_speed??null,voice_temperature:s.voice_temperature??null,interruption_sensitivity:s.interruption_sensitivity??null,backchannel_frequency:s.backchannel_frequency??null,enable_scheduling:s.enable_scheduling,enable_transfer:s.enable_transfer,transfer_phone:(s.transfer_phone||"").replace(/\s/g,"")||null,enable_sms_after_booking:s.enable_sms_after_booking,appointment_sms_template:s.appointment_sms_template,appointment_sms_custom:(s.appointment_sms_custom||"").trim()||null,multi_professional:s.multi_professional,is_active:s.is_active,send_transcript_email:s.send_transcript_email,transcript_email:s.transcript_email||null}),w=((n=m.data)==null?void 0:n.data)||m.data;w&&a(w),C.success(t("inbound.settings.saveSuccess"))}catch(m){C.error(((o=(l=m.response)==null?void 0:l.data)==null?void 0:o.detail)||t("inbound.settings.saveError"))}finally{b(!1)}}};if(_)return e.jsx("div",{className:"flex items-center justify-center h-40",children:e.jsx(j,{className:"w-6 h-6 text-emerald-400 animate-spin"})});const f=(s==null?void 0:s.active_hours_start)==="00:00"&&((s==null?void 0:s.active_hours_end)||"")>="23:59",u=(s==null?void 0:s.active_days)||[1,2,3,4,5],L=n=>{const l=u.includes(n)?u.filter(o=>o!==n):[...u,n].sort();l.length&&a({...s,active_days:l})};return s?(s.phone_number,e.jsxs("div",{className:"space-y-6 max-w-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:t("inbound.settings.title")}),e.jsxs("button",{onClick:N,disabled:r,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-emerald-600 hover:bg-emerald-500 text-white text-sm font-medium disabled:opacity-50 transition-colors",children:[r?e.jsx(j,{className:"w-4 h-4 animate-spin"}):e.jsx(S,{className:"w-4 h-4"}),t("inbound.settings.save")]})]}),e.jsx(d,{title:t("inbound.settings.status"),icon:h,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-white font-medium",children:t("inbound.settings.receptionistActive")}),e.jsx("p",{className:"text-sm text-slate-400",children:s.is_active?t("inbound.settings.aiTakingCalls"):t("inbound.settings.callsNotHandled")})]}),e.jsx(A,{value:s.is_active,onChange:n=>a({...s,is_active:n})})]})}),e.jsxs(d,{title:t("inbound.settings.phoneNumber"),icon:D,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"w-4 h-4 text-emerald-400"}),e.jsx("span",{className:"text-white font-mono",children:s.phone_number||t("inbound.settings.phoneAssigning")}),s.phone_number&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-emerald-500/20 text-emerald-300",children:t("inbound.settings.phoneDedicated")})]}),e.jsx("p",{className:"text-xs text-slate-500 mt-2",children:t("inbound.settings.phoneRoutedToAI")})]}),e.jsx(d,{title:t("inbound.settings.voiceIdentity"),icon:q,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-slate-400 mb-1",children:t("inbound.settings.agentName")}),e.jsx("input",{type:"text",value:s.agent_display_name||"",placeholder:t("inbound.settings.agentNamePlaceholder"),onChange:n=>a({...s,agent_display_name:n.target.value}),className:"w-full bg-slate-800 border border-slate-700 rounded-lg px-3 py-2 text-white text-base lg:text-sm focus:border-emerald-500 outline-none placeholder-slate-500"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t("inbound.settings.agentNameDesc")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-slate-400 mb-1",children:t("inbound.settings.voice")}
4),e.jsx(R,{value:s.voice_id||"custom_voice_dd4e5af09ac1689bcdd16b3783",onChange:n=>a({...s,voice_id:n})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-slate-400 mb-1",children:t("inbound.settings.ambientSound")}),e.jsx("select",{value:s.ambient_sound||"",onChange:n=>a({...s,ambient_sound:n.target.value||null}),className:"w-full bg-slate-800 border border-slate-700 rounded-lg px-3 py-2 text-white text-base lg:text-sm focus:border-emerald-500 outline-none",children:c.map(n=>e.jsx("option",{value:n.id,children:n.label},n.id))}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t("inbound.settings.ambientSoundDesc")})]}),e.jsxs("div",{className:"pt-3 border-t border-slate-700/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("p",{className:"text-xs text-slate-400 font-medium",children:t("inbound.settings.advancedSettings")}),e.jsxs("button",{type:"button",onClick:()=>a({...s,voice_speed:null,voice_temperature:null,interruption_sensitivity:null,backchannel_frequency:null}),className:"flex items-center gap-1 text-[10px] text-slate-500 hover:text-emerald-400 transition-colors",children:[e.jsx(T,{className:"w-3 h-3"}),t("inbound.settings.resetDefault")]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{label:t("inbound.settings.speed"),value:s.voice_speed??1,min:.5,max:2,step:.1,hints:[t("inbound.settings.speedSlow"),t("inbound.settings.speedNormal"),t("inbound.settings.speedFast")],onChange:n=>a({...s,voice_speed:n})}),e.jsx(g,{label:t("inbound.settings.expressiveness"),value:s.voice_temperature??1,min:0,max:2,step:.1,hints:[t("inbound.settings.expressMonotone"),t("inbound.settings.speedNormal"),t("inbound.settings.expressExpressive")
4],onChange:n=>a({...s,voice_temperature:n})}),e.jsx(g,{label:t("inbound.settings.interruptSensitivity"),value:s.interruption_sensitivity??.7,min:0,max:1,step:.05,hints:[t("inbound.settings.interruptIgnore"),"",t("inbound.settings.interruptVerySensitive")],onChange:n=>a({...s,interruption_sensitivity:n})}),e.jsx(g,{label:t("inbound.settings.backchannelLabel"),value:s.backchannel_frequency??.7,min:0,max:1,step:.05,hints:[t("inbound.settings.backchannelNever"),"",t("inbound.settings.backchannelFrequent")],onChange:n=>a({...s,backchannel_frequency:n})})]})]})]})}),e.jsxs(d,{title:t("inbound.settings.receptionHours"),icon:O,children:[e.jsx(x,{label:t("inbound.settings.allDay"),desc:t("inbound.settings.allDayDesc"),value:f,onChange:n=>a({...s,active_hours_start:n?"00:00":"09:00",active_hours_end:n?"23:59":"19:00"})}),!f&&e.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-slate-400 mb-1",children:t("inbound.settings.hoursOpen")}),e.jsx("select",{value:s.active_hours_start,onChange:n=>a({...s,active_hours_start:n.target.value}),className:"w-full bg-slate-800 border border-slate-700 rounded-lg px-3 py-2 text-white text-base lg:text-sm focus:border-emerald-500 outline-none",children:E(M,s.active_hours_start).map(n=>e.jsx("option",{value:n,children:n},n))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-slate-400 mb-1",children:t("inbound.settings.hoursClose")}),e.jsx("select",{value:s.active_hours_end,onChange:n=>a({...s,active_hours_end:n.target.value}),className:"w-full bg-slate-800 border border-slate-700 rounded-lg px-3 py-2 text-white text-base lg:text-sm focus:border-emerald-500 outline-none",children:E(z,s.active_hours_end).map(n=>e.jsx("option",{value:n,children:n},n))})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-xs text-slate-400 mb-1",children:t("inbound.settings.openDays")}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t("inbound.settings.daysShort").split(",").map((n,l)=>{const o=l+1,m=u.includes(o);return e.jsx("button",{type:"button","aria-pressed":m,onClick:()=>L(o),className:`w-9 h-9 rounded-lg text-sm font-medium border transition-colors ${m?"bg-emerald-500/20 border-emerald-500/40 text-emerald-300":"bg-slate-800 border-slate-700 text-slate-500 hover:text-slate-300"}`,children:n},o)})})]}),!(f&&u.length===7)&&e.jsx("p",{className:"text-xs text-slate-500 mt-2",children:t("inbound.settings.afterHoursDesc")})]}),e.jsx(d,{title:t("inbound.settings.features"),icon:h,children:e.jsx("div",{className:"space-y-1",children:e.jsx(x,{label:t("inbound.settings.scheduling"),desc:t("inbound.settings.schedulingDesc"),value:s.enable_scheduling,onChange:n=>a({...s,enable_scheduling:n})})})}),e.jsxs(d,{title:"Transfert VIP",icon:V,children:[e.jsx(x,{label:"Activer le transfert pour les numéros VIP",desc:"Les numéros whitelistés seront transférés directement vers votre mobile au lieu d'être gérés par l'IA.",value:!!s.enable_transfer,onChange:n=>a({...s,enable_transfer:n})}),s.enable_transfer&&e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-slate-400 mb-1",children:"Numéro de transfert (votre mobile)"}),e.jsx("input",{type:"tel",value:s.transfer_phone||"",placeholder:"+33612345678",onChange:n=>a({...s,transfer_phone:n.target.value}),className:"w-full bg-slate-800 border border-slate-700 rounded-lg px-3 py-2 text-white text-base lg:text-sm focus:border-emerald-500 outline-none placeholder-slate-500 font-mono"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Format international obligatoire (ex : +33612345678)."})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{onClick:N,disabled:r,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-emerald-600 hover:bg-emerald-500 text-white text-sm font-medium disabled:opacity-50 transition-colors",children:[r?e.jsx(j,{className:"w-4 h-4 animate-spin"}):e.jsx(S,{className:"w-4 h-4"}),"Enregistrer"]}),e.jsxs(y,{to:"/receptionist/whitelist",className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-slate-800 border border-slate-700 hover:border-emerald-500 text-sm text-white transition-colors",children:[e.jsx(F,{className:"w-4 h-4 text-amber-400"}),"Gérer la liste des numéros VIP"]})]})]})]}),e.jsxs(d,{title:t("inbound.settings.smsConfirmation"),icon:h,children:[e.jsx(x,{label:t("inbound.settings.smsAutoAfterBooking"),desc:t("inbound.settings.smsAutoAfterBookingDesc"),value:s.enable_sms_after_booking??!0,onChange:n=>a({...s,enable_sms_after_booking:n})}),(s.enable_sms_after_booking??!0)&&e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-xs text-slate-400 mb-1",children:t("inbound.settings.smsMessageType")}),e.jsxs("select",{value:s.appointment_sms_template||"appointment_c
4onfirmed_ack",onChange:n=>a({...s,appointment_sms_template:n.target.value}),disabled:!!(s.appointment_sms_custom||"").trim(),className:"w-full bg-slate-800 border border-slate-700 rounded-lg px-3 py-2 text-white text-base lg:text-sm focus:border-emerald-500 outline-none disabled:opacity-50",children:[e.jsx("option",{value:"appointment_confirmed_ack",children:t("inbound.settings.smsSimpleConfirm")}),e.jsx("option",{value:"appointment_confirm_request",children:t("inbound.settings.smsConfirmWithReply")}),e.jsx("option",{value:"appointment_reminder",children:t("inbound.settings.smsReminder")})]}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:s.appointment_sms_template==="appointment_confirm_request"?t("inbound.settings.smsConfirmRequestDesc"):s.appointment_sms_template==="appointment_reminder"?t("inbound.settings.smsReminderDesc"):t("inbound.settings.smsSimpleConfirmDesc")}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-slate-700/50",children:[e.jsxs("label",{className:"block text-xs text-slate-400 mb-1",children:[t("inbound.settings.smsCustomLabel")," ",e.jsx("span",{className:"text-slate-500",children:t("inbound.settings.smsCustomHint")})]}),e.jsx("textarea",{value:s.appointment_sms_custom||"",onChange:n=>a({...s,appointment_sms_custom:n.target.value}),maxLength:320,rows:3,placeholder:t("inbound.settings.smsCustomPlaceholder"),className:"w-full bg-slate-800 border border-slate-700 rounded-lg px-3 py-2 text-white text-base lg:text-sm focus:border-emerald-500 outline-none resize-none placeholder-slate-500"}),e.jsxs("div",{className:"flex items-center justify-between mt-1",children:[e.jsxs("p",{className:"text-[11px] text-slate-500",children:[t("inbound.settings.smsCustomVars")," ","{contact_name}",", ","{appointment_date}",", ","{appointment_time}",", ","{professional_name}"]}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:[(s.appointment_sms_custom||"").length,"/320"]})]})]})]})]}),e.jsxs(d,{title:t("inbound.settings.emailNotifications"),icon:H,children:[e.jsx(x,{label:t("inbound.settings.sendTranscriptEmail"),desc:t("inbound.settings.sendTranscriptEmailDesc"),value:s.send_transcript_email??!1,onChange:n=>a({...s,send_transcript_email:n})}),s.send_transcript_email&&e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-xs text-slate-400 mb-1",children:t("inbound.settings.transcriptEmailLabel")}),e.jsx("input",{type:"email",value:s.transcript_email||"",placeholder:(i==null?void 0:i.email)||t("inbound.settings.transcriptEmailPlaceholder"),onChange:n=>a({...s,transcript_email:n.target.value}),className:"w-full bg-slate-800 border border-slate-700 rounded-lg px-3 py-2 text-white text-base lg:text-sm focus:border-emerald-500 outline-none placeholder-slate-500"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:s.transcript_email?t("inbound.settings.transcriptEmailHelp"):t("inbound.settings.transcriptEmailFallback",{email:(i==null?void 0:i.email)||""})})]})]}),e.jsxs("div",{className:"text-xs text-slate-500 text-center py-2",children:[t("inbound.settings.sector")," : ",s.profession_type," â ",t("inbound.settings.changesAppliedImmediately")]})]})):e.jsxs("div",{className:"bg-slate-800/50 border border-slate-700 rounded-xl p-12 text-center",children:[e.jsx(h,{className:"w-12 h-12 mx-auto mb-3 text-slate-600"}),e.jsx("p",{className:"text-slate-400",children:t("inbound.settings.noConfig")}),e.jsx("p",{className:"text-sm text-slate-500 mt-1",children:t("inbound.settings.noConfigDesc")}),e.jsx(y,{to:"/receptionist/setup",className:"mt-4 inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-emerald-600 hover:bg-emerald-500 text-white text-sm font-medium transition-all",children:t("inbound.noConfigCta")})]})}function d({title:t,icon:i,children:c}){return e.jsxs("div",{className:"bg-slate-800/50 border border-slate-700 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(i,{className:"w-4 h-4 text-emerald-400"}),e.jsx("h2",{className:"text-sm font-semibold text-white",children:t})]}),c]})}function A({value:t,onChange:i}){return e.jsx("button",{onClick:()=>i(!t),role:"switch","aria-checked":t,className:`w-12 h-6 rounded-full transition-colors relative ${t?"bg-emerald-500":"bg-slate-600"}`,children:e.jsx("div",{className:`w-5 h-5 bg-white rounded-full absolute top-0.5 transition-transform ${t?"translate-x-6":"translate-x-0.5"}`})})}function x({label:t,desc:i,value:c,onChange:s}){return e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-white",children:t}),i&&e.jsx("p",{className:"text-xs text-slate-400",children:i})]}),e.jsx(A,{value:c,onChange:s})]})}export{K 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.