PageSourceSearch

https://slickbot.ai/assets/IntelligenceSettingsPage-Ck-4EK48.js

js slickbot.ai collected 2026-10-05 14:28:10 UTC 48,770 bytes, 1 lines download raw bytes

1import{j as e,d as me,u as A,b as j}from"./vendor-query-DPZO-Gta.js";import{b as xe,r as n}from"./vendor-react-BomFe3BT.js";import{m as d,z as r}from"./index-BLzMsaFd.js";import{u as ie}from"./ingestionStore-D6XvWybo.js";import{_ as ee}from"./vendor-ui-BLhm8pMN.js";import"./vendor-charts-DodUWJ0z.js";function je(a){return a<1024?`${a} B`:a<1024*1024?`${(a/1024).toFixed(1)} KB`:`${(a/(1024*1024)).toFixed(1)} MB`}const oe=[{key:"conversations",name:"Conversations",from:"Unibox",color:"bg-blue-500"},{key:"contacts",name:"Contacts & Leads",from:"Customer Management",color:"bg-emerald-500"},{key:"invoices",name:"Invoices & Estimates",from:"Invoicing",color:"bg-amber-500"},{key:"calendar",name:"Calendar Events",from:"Calendar",color:"bg-purple-500"},{key:"bots",name:"Bot Interactions",from:"Bots",color:"bg-pink-500"},{key:"feed",name:"Feed Activity",from:"Feed",color:"bg-cyan-500"}],ce=[{key:"google_ads",name:"Google Ads",description:"Import campaign performance, spend, and conversion data",color:"bg-blue-500"},{key:"meta",name:"Meta (Facebook & Instagram)",description:"Import ad performance across Facebook and Instagram",color:"bg-indigo-500"}
1,{key:"tiktok",name:"TikTok Ads",description:"Import TikTok advertising campaign data",color:"bg-rose-500"},{key:"linkedin",name:"LinkedIn Ads",description:"Import LinkedIn advertising campaign metrics",color:"bg-sky-500"},{key:"google_analytics",name:"Google Analytics",description:"Import website traffic and conversion analytics",color:"bg-amber-500"}],ve={google_ads:e.jsx("svg",{className:"w-3.5 h-3.5 text-white",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.34 15.84c-.688-.06-1.386-.09-2.09-.09H7.5a4.5 4.5 0 110-9h.75c.704 0 1.402-.03 2.09-.09m0 9.18c.253.962.584 1.892.985 2.783.247.55.06 1.21-.463 1.511l-.657.38c-.551.318-1.26.117-1.527-.461a20.845 20.845 0 01-1.44-4.282m3.102.069a18.03 18.03 0 01-.59-4.59c0-1.586.205-3.124.59-4.59m0 9.18a23.848 23.848 0 018.835 2.535M10.34 6.66a23.847 23.847 0 008.835-2.535m0 0A23.74 23.74 0 0018.795 3m.38 1.125a23.91 23.91 0 011.014 5.395m-1.014 8.855c-.118.38-.245.754-.38 1.125m.38-1.125a23.91 23.91 0 001.014-5.395m0-3.46c.495.413.811 1.035.811 1.73 0 .695-.316 1.317-.811 1.73m0-3.46a24.347 24.347 0 010 3.46"})}),meta:e.jsx("svg",{className:"w-3.5 h-3.5 text-white",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M18 18.72a9.094 9.094 0 003.741-.479 3 3 0 00-4.682-2.72m.94 3.198l.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0112 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 016 18.719m12 0a5.971 5.971 0 00-.941-3.197m0 0A5.995 5.995 0 0012 12.75a5.995 5.995 0 00-5.058 2.772m0 0a3 3 0 00-4.681 2.72 8.986 8.986 0 003.74.477m.94-3.197a5.971 5.971 0 00-.94 3.197M15 6.75a3 3 0 11-6 0 3 3 0 016 0zm6 3a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0zm-13.5 0a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0z"})}),tiktok:e.jsx("svg",{className:"w-3.5 h-3.5 text-white",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 9l10.5-3m0 6.553v3.75a2.25 2.25 0 01-1.632 2.163l-1.32.377a1.803 1.803 0 11-.99-3.467l2.31-.66a2.25 2.25 0 001.632-2.163zm0 0V4.5A2.25 2.25 0 0117.25 2.25h1.5"})}),linkedin:e.jsx("svg",{className:"w-3.5 h-3.5 text-white",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.25 14.15v4.25c0 1.094-.787 2.036-1.872 2.18-2.087.277-4.216.42-6.378.42s-4.291-.143-6.378-.42c-1.085-.144-1.872-1.086-1.872-2.18v-4.25m16.5 0a2.18 2.18 0 00.75-1.661V8.706c0-1.081-.768-2.015-1.837-2.175a48.114 48.114 0 00-3.413-.387m4.5 8.006c-.194.165-.42.295-.673.38A23.978 23.978 0 0112 15.75c-2.648 0-5.195-.429-7.577-1.22a2.016 2.016 0 01-.673-.38m0 0A2.18 2.18 0 013 12.489V8.706c0-1.081.768-2.015 1.837-2.175a48.111 48.111 0 013.413-.387m7.5 0V5.25A2.25 2.25 0 0013.5 3h-3a2.25 2.25 0 00-2.25 2.25v.894m7.5 0a48.667 48.667 0 00-7.5 0"})}),google_analytics:e.jsx("svg",{className:"w-3.5 h-3.5 text-white",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 013 19.875v-6.75zM9.75 8.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v11.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V8.625zM16.5 4.125c0-.621.504-1.125 1.125-1.125h2.25C20.496 3 21 3.504 21 4.125v15.75c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V4.125z"})})},ue={google_ads:[{key:"account_id",label:"Account ID",placeholder:"123-456-7890"},{key:"api_key",label:"API Key",placeholder:"AIza..."},{key:"developer_token",label:"Developer Token",placeholder:"Enter developer token"}],meta:[{key:"app_id",label:"App ID",placeholder:"Enter App ID"},{key:"app_secret",label:"App Secret",placeholder:"Enter App Secret",type:"password"},{key:"access_token",label:"Access Token",placeholder:"Enter Access Token",type:"password"}],tiktok:[{key:"advertiser_id",label:"Advertiser ID",placeholder:"Enter Advertiser ID"},{key:"access_token",label:"Access Token",placeholder:"Enter Access Token",type:"password"}],linkedin:[{key:"account_id",label:"Account ID",placeholder:"Enter Account ID"},{key:"access_token",label:"Access Token",placeholder:"Enter Access Token",type:"password"}],google_analytics:[{key:"property_id",label:"Property ID",placeholder:"UA-XXXXX-Y or G-XXXXXXX"},{key:"api_key",label:"API Key",placeholder:"Enter API Key",type:"password"}],"PostgreSQL Database":[{key:"host",label:"Host",placeholder:"localhost"},{key:"port",label:"Port",placeholder:"5432"},{key:"database",label:"Database",placeholder:"my_database"},{key:"username",label:"Username",placeholder:"postgres"},{key:"password",label:"Password",placeholder:"Enter password",type:"password"}],"MySQL Database":[{key:"host",label:"Host",placeholder:"localhost"},{key:"port",label:"Port",placeholder:"3306"},{key:"database",label:"Database",placeholder:"my_database"},{key:"username",label:"Username",placeholder:"root"},{key:"password",label:"Password",placeholder:"Enter password",type:"password"}],"REST API":[{key:"endpoint_url",label:"Endpoint URL",placeholder:"https://api.example.com/data"},{key:"api_key",label:"API Key",placeholder:"Enter API Key",type:"password"},{key:"auth_header",label:"Auth Header",placeholder:"Authorization"}],"Google Sheets":[{key:"spreadsheet_url",label:"Spreadsheet URL",placeholder:"https://docs.google.com/spreadsheets/d/..."},{key:"api_key",label:"API Key",placeholder:"Enter API Key",type:"password"}],website:[{key:"url",label:"Website URL",placeholder:"https://example.com"}]};function he({open:a,onClose:i,connectorName:u,fields:y,onConnect:h}){const[v,o]=n.useState(()=>Object.fromEntries(y.map(c=>[c.key,""])));n.useEffect(()=>{a&&o(Object.fromEntries(y.map(c=>[c.key,""])))},[a,y]);const C=c=>{c.preventDefault(),h(v),i()};return e.jsxs(ee,{open:a,onClose:i,className:"relative z-50",children:[e.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-sm","aria-hidden":"true"}),e.jsx("div",{className:"fixed inset-0 flex items-center justify-center p-4",children:e.jsxs(ee.Panel,{className:"card w-full max-w-md p-6",children:[e.jsxs(ee.Title,{className:"text-lg font-bold text-gray-900 mb-6",children:["Connect ",u]}),e.jsxs("form",{onSubmit:C,children:[e.jsx("div",{className:"space-y-4",children:y.map(c=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:c.label}),e.jsx("input",{type:c.type||"text",value:v[c.key]||"",onChange:m=>o(N=>({...N,[c.key]:m.target.value})),placeholder:c.placeholder,className:"input-field w-full text-sm",required:!0})]},c.key))}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx("button",{type:"button",onClick:i,className:"btn btn-ghost text-sm",children:"Cancel"}),e.jsx("button",{type:"submit",className:"btn btn-primary text-sm",children:"Connect"})]})]})]})})]})}function Ne(){const[a,i]=n.useState(new Set),[u,y]=n.useState(null),h=ce.find(o=>o.key===u),v=u?ue[u]||[]:[];return e.jsxs("div",{className:"card p-6",children:[e.jsx("div",{className:"space-y-3",children:ce.map(o=>{const C=a.has(o.key);return e.jsxs("div",{className:"flex items-center justify-between py-3 px-3 rounded-xl bg-surface-50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-7 h-7 rounded-lg ${o.color} flex items-center justify-center`,children:ve[o.key]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-gray-700",children:o.name}),e.jsx("p",{className:"text-xs text-muted-400",children:o.description})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:C?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-emerald-50 text-emerald-700",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500"}),"Connected"]}),e.jsx("button",{onClick:()=>{i(c=>{const m=new Set(c);return m.delete(o.key),m}),r.success(`${o.name} disconnected`)},className:"btn btn-ghost text-xs px-3 py-1.5",children:"Disconnect"})]}):e.jsx("button",{onClick:()=>y(o.key),className:"btn btn-ghost text-xs px-3 py-1.5",children:"Connect"})})]},o.key)})}),e.jsx(he,{open:u!==null,onClose:()=>y(null),connectorName:(h==null?void 0:h.name)||"",fields:v,onConnect:()=>{u&&(i(o=>new Set(o).add(u)),r.success(`${h==null?void 0:h.name} connected successfully`))}})]})}const ke=[{name:"PostgreSQL Database",icon:"database"},{name:"MySQL Database",icon:"database"},{name:"REST API",icon:"api"},{name:"Google Sheets",icon:"sheets"}];function we(){const{id:a}=xe(),i=me(),u=n.useRef(null),[y,h]=n.useState(!1),[v,o]=n.useState(()=>Object.fromEntries(oe.map(t=>[t.key,!0]))),[C,c]=n.useState(new Set),[m,N]=n.useState(null),[W,q]=n.useState(!1),R=m?ue[m]||[]:[],{data:M,isLoading:$}=A({queryKey:["operator-data-sources",a],queryFn:async()=>(await d.getDataSources(a)).data,enabled:!!a}),I=(M==null?void 0:M.items)||[],{addJob:z,updateJob:k}=ie(),Q=n.useCallback((t,l)=>{const x=Date.now(),p=setInterval(async()=>{var _;try{(((_=(await d.getMessages(a,0,50)).data)==null?void 0:_.items)||[]).find(T=>{var F;
1return T.source==="data_analysis"&&((F=T.tool_calls)==null?void 0:F.data_source_id)===l})?(clearInterval(p),k(t,{status:"ready",progress:100}),i.invalidateQueries({queryKey:["operator-data-sources",a]}),i.invalidateQueries({queryKey:["operator-messages",a]})):k(t,{status:"analyzing"})}catch{}Date.now()-x>5*60*1e3&&(clearInterval(p),k(t,{status:"ready",progress:100}))},4e3);return p},[a,k,i]),w=j({mutationFn:t=>{const l=`ingestion-${Date.now()}`;return z({id:l,fileName:t.name,businessId:a,status:"uploading"}),d.uploadDataSource(a,t).then(x=>({data:x.data,fileName:t.name,jobId:l}))},onSuccess:t=>{var x,p;const l=((x=t.data)==null?void 0:x.id)||((p=t.data)==null?void 0:p.source_id);k(t.jobId,{status:"processing"}),Q(t.jobId,l),i.invalidateQueries({queryKey:["operator-data-sources",a]})},onError:t=>{var x,p,_,D;const l=ie.getState().jobs.find(E=>E.status==="uploading");l&&k(l.id,{status:"error",errorMessage:((p=(x=t.response)==null?void 0:x.data)==null?void 0:p.detail)||"Upload failed"}),r.error(((D=(_=t.response)==null?void 0:_.data)==null?void 0:D.detail)||"Failed to upload data source")}}),K=j({mutationFn:t=>d.deleteDataSource(a,t),onSuccess:()=>{i.invalidateQueries({queryKey:["operator-data-sources",a]}),r.success("Data source deleted")},onError:()=>r.error("Failed to delete data source")}),L=n.useCallback(t=>{t.preventDefault(),t.stopPropagation(),t.type==="dragenter"||t.type==="dragover"?h(!0):t.type==="dragleave"&&h(!1)},[]),H=n.useCallback(t=>{var l;t.preventDefault(),t.stopPropagation(),h(!1),(l=t.dataTransfer.files)!=null&&l[0]&&w.mutate(t.dataTransfer.files[0])},[w]),U=t=>{var l;(l=t.target.files)!=null&&l[0]&&(w.mutate(t.target.files[0]),t.target.value="")};return $?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"w-8 h-8 border-2 border-primary-500 border-t-transparent rounded-full animate-spin"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"card p-6 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-primary-50 flex items-center justify-center",children:e.jsx("svg",{className:"w-4.5 h-4.5 text-primary-600",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.25 6.375c0 2.278-3.694 4.125-8.25 4.125S3.75 8.653 3.75 6.375m16.5 0c0-2.278-3.694-4.125-8.25-4.125S3.75 4.097 3.75 6.375m16.5 0v11.25c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125V6.375m16.5 0v3.75c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125v-3.75m16.5 3.75v3.75c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125v-3.75"})})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Internal Sources"}),e.jsx("p",{className:"text-sm text-muted-400",children:"Data from your platform features — automatically available to your AI Operator."})]})]}),e.jsx("div",{className:"mt-4 divide-y divide-surface-100",children:oe.map(t=>{const l=v[t.key];return e.jsxs("div",{className:"flex items-center justify-between py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${t.color}`}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:t.name}),e.jsxs("span",{className:"text-sm text-muted-400 ml-1.5",children:["from ",t.from]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${l?"bg-emerald-50 text-emerald-700":"bg-gray-100 text-gray-500"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${l?"bg-emerald-500":"bg-gray-400"}`}),l?"Connected":"Disconnected"]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:l,onChange:()=>o(x=>({...x,[t.key]:!x[t.key]})),className:"sr-only peer"}),e.jsx("div",{className:"w-9 h-5 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-primary-500"})]})]})]},t.key)})})]}),e.jsxs("div",{className:"card p-6 mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-blue-50 flex items-center justify-center",children:e.jsx("svg",{className:"w-4.5 h-4.5 text-blue-600",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 16.5V9.75m0 0l3 3m-3-3l-3 3M6.75 19.5a4.5 4.5 0 01-1.41-8.775 5.25 5.25 0 0110.233-2.33 3 3 0 013.758 3.848A3.752 3.752 0 0118 19.5H6.75z"})})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Exter
1nal Sources"}),e.jsx("p",{className:"text-sm text-muted-400",children:"Import data from spreadsheets, databases, and APIs."})]})]}),e.jsxs("button",{onClick:()=>{var t;return(t=u.current)==null?void 0:t.click()},disabled:w.isPending,className:"btn btn-primary text-sm",children:[e.jsx("svg",{className:"w-4 h-4 mr-1.5",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),"Upload File"]}),e.jsx("input",{ref:u,type:"file",accept:".csv,.xlsx",onChange:U,className:"hidden"})]}),e.jsxs("div",{className:`border-2 border-dashed rounded-2xl p-8 text-center transition-colors mt-4 ${y?"border-primary-500 bg-primary-50":"border-surface-200 hover:border-surface-300"}`,onDragEnter:L,onDragOver:L,onDragLeave:L,onDrop:H,children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 rounded-2xl bg-surface-100 flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-muted-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})})}),e.jsx("p",{className:"text-sm font-medium text-gray-700 mb-1",children:w.isPending?"Uploading...":"Drag & drop files here"}),e.jsx("p",{className:"text-xs text-muted-400",children:"CSV or XLSX files, max 1 MB each. Up to 20 per business."})]}),I.length>0&&e.jsx("div",{className:"space-y-3 mt-4",children:I.map(t=>e.jsxs("div",{className:"bg-surface-50 rounded-xl p-4 flex items-center gap-4",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 ${t.file_type==="csv"?"bg-green-100":"bg-blue-100"}`,children:e.jsx("span",{className:`text-xs font-bold uppercase ${t.file_type==="csv"?"text-green-700":"text-blue-700"}`,children:t.file_type})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-900 truncate",children:t.name}),e.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium ${t.status==="ready"?"bg-green-100 text-green-700":t.status==="error"?"bg-red-100 text-red-700":"bg-yellow-100 text-yellow-700"}`,children:t.status})]}),t.status==="ready"?e.jsxs("p",{className:"text-xs text-muted-400 mt-0.5",children:[t.row_count.toLocaleString()," rows × ",t.column_count," columns · ",je(t.file_size)]}):t.status==="error"?e.jsx("p",{className:"text-xs text-red-500 mt-0.5",children:t.error_message}):null,t.status==="ready"&&t.columns.length>0&&e.jsxs("p",{className:"text-xs text-muted-300 mt-0.5 truncate",children:[t.columns.slice(0,6).join(", "),t.columns.length>6&&`, +${t.columns.length-6} more`]})]}),e.jsx("button",{onClick:()=>{window.confirm(`Delete "${t.name}"?`)&&K.mutate(t.id)},disabled:K.isPending,className:"p-2 text-muted-400 hover:text-red-500 transition-colors rounded-lg hover:bg-red-50",title:"Delete",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.74 9l-.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 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})})})]},t.id))}),e.jsxs("div",{className:"mt-6 pt-4 border-t border-surface-100",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-300 uppercase tracking-wider mb-3",children:"Additional Connectors"}),e.jsx("div",{className:"space-y-2",children:ke.map(t=>{const l=C.has(t.name);return e.jsxs("div",{className:"flex items-center justify-between py-2.5 px-3 rounded-xl bg-surface-50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("svg",{className:"w-4.5 h-4.5 text-muted-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.25 6.375c0 2.278-3.694 4.125-8.25 4.125S3.75 8.653 3.75 6.375m16.5 0c0-2.278-3.694-4.125-8.25-4.125S3.75 4.097 3.75 6.375m16.5 0v11.25c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125V6.375m16.5 0v3.75c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125v-3.75m16.5 3.75v3.75c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125v-3.75"})}),e.jsx("span",{className:"text-sm font-medium text-gray-700",children:t.name})]}),l?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-emerald-50 text-emerald-700",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500"}),"Connected"]}),e.jsx("button",{onClick:()=>{c(x=>{const p=new Set(x);return p.delete(t.name),p}),r.success(`${t.name} disconnected`)},className:"btn btn-ghost text-xs px-3 py-1.5",children:"Disconnect"})]}):e.jsx("button",{onClick:()=>N(t.name),className:"btn btn-ghost text-xs px-3 py-1.5",children:"Connect"})]},t.name)}
1)})]})]}),e.jsxs("div",{className:"card p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-violet-50 flex items-center justify-center",children:e.jsx("svg",{className:"w-4.5 h-4.5 text-violet-600",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 21a9.004 9.004 0 008.716-6.747M12 21a9.004 9.004 0 01-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 017.843 4.582M12 3a8.997 8.997 0 00-7.843 4.582m15.686 0A11.953 11.953 0 0112 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0121 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0112 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 013 12c0-1.605.42-3.113 1.157-4.418"})})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Public Sources"}),e.jsx("p",{className:"text-sm text-muted-400",children:"Connect to public data on the internet."})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between py-3 px-3 rounded-xl bg-surface-50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("svg",{className:"w-4.5 h-4.5 text-muted-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 21a9.004 9.004 0 008.716-6.747M12 21a9.004 9.004 0 01-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 017.843 4.582M12 3a8.997 8.997 0 00-7.843 4.582m15.686 0A11.953 11.953 0 0112 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0121 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0112 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 013 12c0-1.605.42-3.113 1.157-4.418"})}),e.jsx("div",{children:e.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Website Monitoring"})})]}),e.jsx("div",{className:"flex items-center gap-2",children:W?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-emerald-50 text-emerald-700",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500"}),"Connected"]}),e.jsx("button",{onClick:()=>{q(!1),r.success("Website monitoring disconnected")},className:"btn btn-ghost text-xs px-3 py-1.5",children:"Disconnect"})]}):e.jsx("button",{onClick:()=>N("website"),className:"btn btn-ghost text-xs px-3 py-1.5",children:"Add Website URL"})})]})})})]}),e.jsx(he,{open:m!==null,onClose:()=>N(null),connectorName:m==="website"?"Website Monitoring":m||"",fields:R,onConnect:()=>{m==="website"?(q(!0),r.success("Website monitoring connected successfully")):m&&(c(t=>new Set(t).add(m)),r.success(`${m} connected successfully`))}})]})}const Ce=[{value:"openrouter",label:"OpenRouter"},{value:"anthropic",label:"Anthropic"},{value:"openai",label:"OpenAI"},{value:"deepseek",label:"DeepSeek"}],de={openrouter:[{value:"anthropic/claude-sonnet-4",label:"Claude Sonnet 4"},{value:"anthropic/claude-3.5-sonnet",label:"Claude 3.5 Sonnet"},{value:"openai/gpt-4o",label:"GPT-4o"},{value:"deepseek/deepseek-chat",label:"DeepSeek Chat"},{value:"google/gemini-2.0-flash-001",label:"Gemini 2.0 Flash"}],anthropic:[{value:"claude-sonnet-4-20250514",label:"Claude Sonnet 4"},{value:"claude-3-5-sonnet-20241022",label:"Claude 3.5 Sonnet"},{value:"claude-3-haiku-20240307",label:"Claude 3 Haiku"}],openai:[{value:"gpt-4o",label:"GPT-4o"},{value:"gpt-4o-mini",label:"GPT-4o Mini"},{value:"gpt-4-turbo",label:"GPT-4 Turbo"}],deepseek:[{value:"deepseek-chat",label:"DeepSeek Chat"},{value:"deepseek-reasoner",label:"DeepSeek Reasoner"}]};function _e(){var re,le;const{id:a}=xe(),i=me(),[u,y]=n.useState("openrouter"),[h,v]=n.useState("anthropic/claude-sonnet-4"),[o,C]=n.useState("0.7"),[c,m]=n.useState(""),[N,W]=n.useState(!0),[q,R]=n.useState(30),[M,$]=n.useState(!1),[I,z]=n.useState(""),[k,Q
1]=n.useState(""),[w,K]=n.useState(!0),[L,H]=n.useState(!0),[U,t]=n.useState(7),[l,x]=n.useState(3),[p,_]=n.useState(!0),[D,E]=n.useState(!1),[B,T]=n.useState(""),[F,te]=n.useState(""),{data:b,isLoading:pe}=A({queryKey:["operator-config",a],queryFn:async()=>(await d.getConfig(a)).data,enabled:!!a,retry:!1}),{data:O}=A({queryKey:["operator-usage",a],queryFn:async()=>(await d.getUsage(a)).data,enabled:!!a}),{data:f}=A({queryKey:["operator-telegram-status",a],queryFn:async()=>(await d.getTelegramStatus(a)).data,enabled:!!a}),{data:S}=A({queryKey:["operator-analytics",a],queryFn:async()=>(await d.getAnalytics(a,30)).data,enabled:!!a}),{data:P}=A({queryKey:["operator-memory",a],queryFn:async()=>(await d.getMemory(a)).data,enabled:!!a}),{data:V}=A({queryKey:["operator-channels",a],queryFn:async()=>(await d.getChannels(a)).data,enabled:!!a});n.useEffect(()=>{b&&(y(b.llm_provider||"openrouter"),v(b.llm_model||"anthropic/claude-sonnet-4"),C(b.temperature||"0.7"),m(b.custom_instructions||""),W(b.heartbeat_enabled??!0),R(b.heartbeat_interval_minutes??30),$(b.web_search_enabled??!1))},[b]),n.useEffect(()=>{f!=null&&f.telegram_allow_from&&Q(f.telegram_allow_from.join(", "))},[f]),n.useEffect(()=>{if(b){K(b.alerts_enabled??!0);const s=b.alert_config||{};H(s.new_high_value_lead??!0),t(s.invoice_overdue_days??7),x(s.booking_spike_threshold??3),_(s.human_intervention_required??!0)}},[b]),n.useEffect(()=>{P&&T(P.content||"")},[P]);const G=j({mutationFn:s=>d.updateSettings(a,s),onSuccess:()=>{i.invalidateQueries({queryKey:["operator-config",a]}),r.success("Settings saved")},onError:()=>r.error("Failed to save settings")}),se=j({mutationFn:()=>d.deactivate(a),onSuccess:()=>{i.invalidateQueries({queryKey:["operator-config",a]}),r.success("Operator deactivated")},onError:()=>r.error("Failed to deactivate")}),ae=j({mutationFn:()=>d.clearMessages(a),onSuccess:()=>{i.invalidateQueries({queryKey:["operator-messages",a]}),r.success("Chat history cleared")},onError:()=>r.error("Failed to clear messages")}),X=j({mutationFn:()=>{const s=k.split(",").map(g=>g.trim()).filter(Boolean);return d.connectTelegram(a,{telegram_enabled:!0,telegram_bot_token:I,telegram_allow_from:s})},onSuccess:s=>{const g=s.data;g.success?(r.success(`Connected to @${g.bot_username}`),i.invalidateQueries({queryKey:["operator-telegram-status",a]}),i.invalidateQueries({queryKey:["operator-config",a]})):r.error(g.error||"Failed to connect")},onError:()=>r.error("Failed to connect Telegram")}),J=j({mutationFn:()=>d.disconnectTelegram(a),onSuccess:()=>{i.invalidateQueries({queryKey:["operator-telegram-status",a]}),i.invalidateQueries({queryKey:["operator-config",a]}),z(""),r.success("Telegram disconnected")},onError:()=>r.error("Failed to disconnect")}),Y=j({mutationFn:()=>d.updateAlertConfig(a,{alerts_enabled:w,new_high_value_lead:L,invoice_overdue_days:U,booking_spike_threshold:l,human_intervention_required:p}),onSuccess:()=>{i.invalidateQueries({queryKey:["operator-config",a]}),r.success("Alert settings saved")},onError:()=>r.error("Failed to save alert settings")}),Z=j({mutationFn:()=>d.updateMemory(a,B),onSuccess:()=>{i.invalidateQueries({queryKey:["operator-memory",a]}),E(!1),r.success("Memory updated")},onError:()=>r.error("Failed to update memory")}),ne=j({mutationFn:s=>d.addChannel(a,{channel_type:s,config:{}}),onSuccess:()=>{i.invalidateQueries({queryKey:["operator-channels",a]}),te(""),r.success("Channel added")},onError:()=>r.error("Failed to add channel")}),ge=j({mutationFn:s=>d.removeChannel(a,s),onSuccess:()=>{i.invalidateQueries({queryKey:["operator-channels",a]}),r.success("Channel removed")},onError:()=>r.error("Failed to remove channel")}),be=()=>{G.mutate({llm_provider:u,llm_model:h,temperature:o,custom_instructions:c,heartbeat_enabled:N,heartbeat_interval_minutes:q,web_search_enabled:M})};return pe?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"w-8 h-8 border-2 border-primary-500 border-t-transparent rounded-full animate-spin"})}):e.jsxs(e.Fragment,{children:[O&&e.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-8",children:[e.jsxs("div",{className:"bg-surface-50 rounded-2xl p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-gray-900",children:O.total_messages}),e.jsx("div",{className:"text-xs text-muted-400 mt-1",children:"Messages"})]}),e.jsxs("div",{className:"bg-surface-50 rounded-2xl p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-gray-900",children:O.total_tool_calls}),e.jsx("div",{className:"text-xs text-muted-400 mt-1",children:"Tool Calls"})]}),e.jsxs("div",{className:"bg-surface-50 rounded-2xl p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-gray-900",children:O.last_active_at?new Date(O.last_active_at).toLocaleDateString():"Never"}),e.jsx("div",{className:"text-xs text-muted-400 mt-1",children:"Last Active"})]})]}),S&&S.messages_by_day.length>0&&e.jsxs("div",{className:"card p-6 mb-6",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 mb-4",children:"Usage Analytics (Last 30 Days)"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-4",children:Object.entries(S.messages_by_source).map(([s,g])=>e.jsxs("div",{className:"bg-surface-50 rounded-xl p-3 text-center",children:[e.jsx("div",{className:"text-lg font-bold text-gray-900",children:g}),e.jsx("div",{className:"text-xs text-muted-400 capitalize",children:s.replace("_"," ")})]},s))}),e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-xs text-muted-400 mb-2",children:"Messages per day"}),e.jsx("div",{className:"flex items-end gap-1 h-24",children:S.messages_by_day.slice(-30).map(s=>{const g=Math.max(...S.messages_by_day.map(ye=>ye.count),1),fe=Math.max(s.count/g*100,4);return e.jsx("div",{className:"flex-1 bg-primary-400 rounded-t hover:bg-primary-500 transition-colors",style:{height:`${fe}%`},title:`${s.date}: ${s.count} messages`},s.date)})}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-300 mt-1",children:[e.jsx("span",{children:(re=S.messages_by_day[0])==null?void 0:re.date}),e.jsx("span",{children:(le=S.messages_by_day[S.messages_by_day.length-1])==null?void 0:le.date})]})]})]}),e.jsxs("div",{className:"card p-6 mb-6",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 mb-4",children:"AI Model"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Provider"}),e.jsx("select",{value:u,onChange:s=>{y(s.target.value);const g=de[s.target.value];g!=null&&g.length&&v(g[0].value)},className:"input-field w-full",children:Ce.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Model"}),e.jsx("select",{value:h,onChange:s=>v(s.target.value),className:"input-field w-full",children:(de[u]||[]).map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["Temperature: ",o]}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:o,onChange:s=>C(s.target.value),className:"w-full"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-400",children:[e.jsx("span",{children:"Precise"}),e.jsx("span",{children:"Creative"})]})]})]})]}),e.jsxs("div",{className:"card p-6 mb-6",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 mb-4",children:"Custom Instructions"}),e.jsx("p",{className:"text-sm text-muted-400 mb-3",children:"Add specific instructions for your operator. These are injected into the agent's personality and behavior guidelines."}),e.jsx("textarea",{value:c,onChange:s=>m(s.target.value),placeholder:"e.g., Always respond in Spanish. Focus on lead conversion metrics. Our fiscal year starts in April.",rows:4,className:"input-field w-full resize-y"})]}),e.jsxs("div",{className:"card p-6 mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Periodic Reports"}),e.jsx("p",{className:"text-sm text-muted-400 mt-1",children:"Automatically check your business data and generate reports on a 
1schedule."})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:N,onChange:s=>W(s.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-primary-500"})]})]}),N&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Check every (minutes)"}),e.jsxs("select",{value:q,onChange:s=>R(parseInt(s.target.value)),className:"input-field w-48",children:[e.jsx("option",{value:15,children:"15 minutes"}),e.jsx("option",{value:30,children:"30 minutes"}),e.jsx("option",{value:60,children:"1 hour"}),e.jsx("option",{value:120,children:"2 hours"}),e.jsx("option",{value:360,children:"6 hours"}),e.jsx("option",{value:720,children:"12 hours"}),e.jsx("option",{value:1440,children:"24 hours"})]})]})]}),e.jsx("div",{className:"card p-6 mb-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Web Search"}),e.jsx("p",{className:"text-sm text-muted-400 mt-1",children:"Allow the operator to search the web for current information."})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:M,onChange:s=>$(s.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-primary-500"})]})]})}),e.jsxs("div",{className:"card p-6 mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Telegram Integration"}),e.jsx("p",{className:"text-sm text-muted-400 mt-1",children:"Chat with your operator on the go via Telegram."})]}),(f==null?void 0:f.telegram_connected)&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium bg-emerald-50 text-emerald-700",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500"}),"Connected"]})]}),f!=null&&f.telegram_connected?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-500",children:"Your Telegram bot is active and receiving messages."}),f.telegram_allow_from.length>0&&e.jsxs("div",{className:"text-sm text-muted-400",children:[e.jsx("span",{className:"font-medium text-gray-700",children:"Allowed users: "}),f.telegram_allow_from.join(", ")]}),e.jsx("button",{onClick:()=>{window.confirm("Disconnect Telegram bot?")&&J.mutate()},disabled:J.isPending,className:"btn btn-ghost text-red-600 hover:bg-red-50 text-sm",children:J.isPending?"Disconnecting...":"Disconnect Telegram"})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-surface-50 rounded-xl p-4 text-sm text-muted-500 space-y-2",children:[e.jsx("p",{className:"font-medium text-gray-700",children:"How to set up:"}),e.jsxs("ol",{className:"list-decimal ml-4 space-y-1",children:[e.jsxs("li",{children:["Open Telegram and search for ",e.jsx("span",{className:"font-mono text-xs bg-white px-1 py-0.5 rounded",children:"@BotFather"})]}),e.jsxs("li",{children:["Send ",e.jsx("span",{className:"font-mono text-xs bg-white px-1 py-0.5 rounded",children:"/newbot"})," and follow the prompts"]}),e.jsx("li",{children:"Copy the bot token and paste it below"}),e.jsxs("li",{children:["To find your Telegram user ID, send ",e.jsx("span",{className:"font-mono text-xs bg-white px-1 py-0.5 rounded",children:"/start"})," to ",e.jsx("span",{className:"font-mono text-xs bg-white px-1 py-0.5 rounded",children:"@userinfobot"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Bot Token"}),e.jsx("input",{type:"password",value:I,onChange:s=>
1z(s.target.value),placeholder:"123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11",className:"input-field w-full font-mono text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Allowed User IDs"}),e.jsx("input",{type:"text",value:k,onChange:s=>Q(s.target.value),placeholder:"123456789, 987654321",className:"input-field w-full text-sm"}),e.jsx("p",{className:"text-xs text-muted-400 mt-1",children:"Comma-separated Telegram user IDs or usernames. Only these users can interact with the bot."})]}),e.jsx("button",{onClick:()=>X.mutate(),disabled:X.isPending||!I.trim(),className:"btn btn-primary text-sm",children:X.isPending?"Connecting...":"Connect Telegram Bot"})]})]}),e.jsx("div",{className:"flex items-center justify-between mb-8",children:e.jsx("button",{onClick:be,disabled:G.isPending,className:"btn btn-primary px-6",children:G.isPending?"Saving...":"Save Settings"})}),e.jsxs("div",{className:"card p-6 mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Proactive Alerts"}),e.jsx("p",{className:"text-sm text-muted-400 mt-1",children:"Get notified about important business events automatically."})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:w,onChange:s=>K(s.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-primary-500"})]})]}),w&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:L,onChange:s=>H(s.target.checked),className:"rounded border-gray-300 text-primary-500 focus:ring-primary-500"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-gray-700",children:"New high-value leads"}),e.jsx("p",{className:"text-xs text-muted-400",children:"Alert when a lead with score 80+ is captured"})]})]}),e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:p,onChange:s=>_(s.target.checked),className:"rounded border-gray-300 text-primary-500 focus:ring-primary-500"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Human intervention needed"}),e.jsx("p",{className:"text-xs text-muted-400",children:"Alert when conversations are flagged for human review"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 w-48",children:"Invoice overdue threshold"}),e.jsxs("select",{value:U,onChange:s=>t(parseInt(s.target.value)),className:"input-field w-32 text-sm",children:[e.jsx("option",{value:3,children:"3 days"}),e.jsx("option",{value:7,children:"7 days"}),e.jsx("option",{value:14,children:"14 days"}),e.jsx("option",{value:30,children:"30 days"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 w-48",children:"Booking spike multiplier"}),e.jsxs("select",{value:l,onChange:s=>x(parseInt(s.target.value)),className:"input-field w-32 text-sm",children:[e.jsx("option",{value:2,children:"2x average"}),e.jsx("option",{value:3,children:"3x average"}),e.jsx("option",{value:5,children:"5x average"})]})]}),e.jsx("button",{onClick:()=>Y.mutate(),disabled:Y.isPending,className:"btn btn-primary text-sm mt-2",children:Y.isPending?"Saving...":"Save Alert Settings"})]})]}),e.jsxs("div",{className:"card p-6 mb-6",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 mb-4",children:"Communication Channels"}),e.jsx("p",{className:"text-sm text-muted-400 mb-4",children:"Configure additional channels to interact with your operator."}),V&&V.length>0&&e.jsx("div",{className:"space-y-2 mb-4",children:V.map(s=>e.jsxs("div",{className:"flex items-center justify-between bg-surface-50 rounded-xl p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 capitalize",children:s.channel_type}),e.jsx("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs ${s.connected?"bg-emerald-50 text-emerald-700":"bg-gray-100 text-gray-500"}`,children:s.connected?"Connected":"Not connected"})]}),e.jsx("button",{onClick:()=>{window.confirm(`Remove ${s.channel_type} channel?`)&&ge.mutate(s.id)},className:"text-xs text-red-500 hover:text-red-700",children:"Remove"})]},s.id))}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{value:F,onChange:s=>te(s.target.value),className:"input-field text-sm",children:[e.jsx("option",{value:"",children:"Add channel..."}),e.jsx("option",{value:"discord",children:"Discord"}),e.jsx("option",{value:"slack",children:"Slack"}),e.jsx("option",{value:"whatsapp",children:"WhatsApp"})]}),F&&e.jsx("button",{onClick:()=>ne.mutate(F),disabled:ne.isPending,className:"btn btn-primary text-sm",children:"Add"})]}),e.jsx("p",{className:"text-xs text-muted-400 mt-2",children:"Channel integrations are being rolled out. Adding a channel reserves it for your business."})]}),e.jsxs("div",{className:"card p-6 mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"What I've Learned"}),e.jsx("p",{className:"text-sm text-muted-400 mt-1",children:"Facts and preferences your operator has learned about your business."})]}),!D&&e.jsx("button",{onClick:()=>E(!0),className:"btn btn-ghost text-sm",children:"Edit"})]}),D?e.jsxs("div",{children:[e.jsx("textarea",{value:B,onChange:s=>T(s.target.value),rows:12,className:"input-field w-full resize-y font-mono text-sm",placeholder:"# Memory\\n\\nYour operator will save learned facts here..."}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsx("button",{onClick:()=>Z.mutate(),disabled:Z.isPending,className:"btn btn-primary text-sm",children:Z.isPending?"Saving...":"Save Memory"}),e.jsx("button",{onClick:()=>{E(!1),T((P==null?void 0:P.content)||"")},className:"btn btn-ghost text-sm",children:"Cancel"})]})]}):e.jsx("div",{className:"bg-surface-50 rounded-xl p-4 min-h-[80px]",children:B?e.jsx("pre",{className:"text-sm text-gray-700 whitespace-pre-wrap font-mono",children:B}):e.jsx("p",{className:"text-sm text-muted-400 italic",children:"No memories yet. As you chat with your operator, it will save important facts here."})})]}),e.jsxs("div",{className:"card p-6 border-red-200",children:[e.jsx("h3",{className:"text-base font-semibold text-red-600 mb-4",children:"Danger Zone"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:"Clear Chat History"}),e.jsx("p",{className:"text-xs text-muted-400",children:"Remove all operator messages. This cannot be undone."})]}),e.jsx("button",{onClick:()=>{window.confirm("Are you sure you want to clear all operator messages?")&&ae.mutate()},disabled:ae.isPending,className:"btn btn-ghost text-red-600 hover:bg-red-50 text-sm",children:"Clear History"})]}),e.jsx("div",{className:"border-t border-surface-100"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:"Deactivate Operator"}),e.jsx("p",{className:"text-xs text-muted-400",children:"Stops the agent but preserves all data and settings."})]}),e.jsx("button",{onClick:()=>{window.confirm("Deactivate the AI operator?")&&se.mutate()},disabled:se.isPending,className:"btn btn-ghost text-red-600 hover:bg-red-50 text-sm",children:"Deactivate"})]})]})]})]})}function Ee(){return e.jsxs("div",{className:"max-w-4xl",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900",children:"Intelligence Settings"}),e.jsx("p",{className:"text-sm text-muted-400 mt-0.5",children:"Configure data sources and AI operator behavior."})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-primary-50 flex items-center justify-center",children:e.jsx("svg",{className:"w-4.5 h-4.5 text-primary-600",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.25 6.375c0 2.278-3.694 4.125-8.25 4.125S3.75 8.653 3.75 6.375m16.5 0c0-2.278-3.694-4.125-8.25-4.125S3.75 4.097 3.75 6.375m16.5 0v11.25c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125V6.375"})})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Data Sources"})]}),e.jsx(we,{})]}),e.jsx("hr",{className:"my-8 border-surface-200"}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-rose-50 flex items-center justify-center",children:e.jsx("svg",{className:"w-4.5 h-4.5 text-rose-600",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 3v11.25A2.25 2.25 0 006 16.5h2.25M3.75 3h-1.5m1.5 0h16.5m0 0h1.5m-1.5 0v11.25A2.25 2.25 0 0118 16.5h-2.25m-7.5 0h7.5m-7.5 0l-1 3m8.5-3l1 3m0 0l.5 1.5m-.5-1.5h-9.5m0 0l-.5 1.5m.75-9l3-3 2.148 2.148A12.061 12.061 0 0116.5 7.605"})})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Marketing Integrations"})]}),e.jsx(Ne,{})]}),e.jsx("hr",{className:"my-8 border-surface-200"}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-purple-50 flex items-center justify-center",children:e.jsx("svg",{className:"w-4.5 h-4.5 text-purple-600",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09
1L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09z"})})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"AI Operator Settings"})]}),e.jsx(_e,{})]})]})}export{Ee 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.