heyhank 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +83 -10
- package/bin/cli.ts +7 -7
- package/bin/ctl.ts +42 -42
- package/dist/assets/{AgentsPage-BPhirnCe.js → AgentsPage-B-AAmsMK.js} +3 -3
- package/dist/assets/AssistantPage-BV1Mfwdt.js +2 -0
- package/dist/assets/BusinessPage-tLpNEz19.js +1 -0
- package/dist/assets/{CronManager-DDbz-yiT.js → CronManager-B-K_n3Jg.js} +1 -1
- package/dist/assets/HelpPage-Bhf_j6Xr.js +1 -0
- package/dist/assets/{IntegrationsPage-CrOitCmJ.js → IntegrationsPage-DAMjs9tM.js} +1 -1
- package/dist/assets/JarvisHUD-C_TGXCCn.js +120 -0
- package/dist/assets/MediaPage-C48HTTrt.js +1 -0
- package/dist/assets/MemoryPage-JkC-qtgp.js +1 -0
- package/dist/assets/{PlatformDashboard-Do6F0O2p.js → PlatformDashboard-AUo7tNnE.js} +1 -1
- package/dist/assets/{Playground-Fc5cdc5p.js → Playground-AzNMsRBL.js} +1 -1
- package/dist/assets/{ProcessPanel-CslEiZkI.js → ProcessPanel-DpE_2sX3.js} +1 -1
- package/dist/assets/{PromptsPage-D2EhsdNO.js → PromptsPage-C2RQOs6p.js} +2 -2
- package/dist/assets/RunsPage-B9UOyO79.js +1 -0
- package/dist/assets/{SandboxManager-a1AVI5q2.js → SandboxManager-jHvYjwfh.js} +1 -1
- package/dist/assets/SettingsPage-BBJax6gt.js +51 -0
- package/dist/assets/SkillsMarketplace-IjmjfdjD.js +1 -0
- package/dist/assets/SocialMediaPage-DoPZHhr2.js +10 -0
- package/dist/assets/{TailscalePage-CHiFhZXF.js → TailscalePage-DDEY7ckO.js} +1 -1
- package/dist/assets/TelephonyPage-OPNBZYKt.js +9 -0
- package/dist/assets/{TerminalPage-Drwyrnfd.js → TerminalPage-BjMbHHW3.js} +1 -1
- package/dist/assets/{gemini-live-client-C7rqAW7G.js → gemini-live-client-C70FEtX2.js} +11 -8
- package/dist/assets/{index-CEqZnThB.js → index-BgYM4wXw.js} +94 -93
- package/dist/assets/index-BkjSoVgn.css +32 -0
- package/dist/assets/sw-register-C7NOHtIu.js +1 -0
- package/dist/assets/text-chat-client-BSbLJerZ.js +2 -0
- package/dist/index.html +2 -2
- package/dist/sw.js +1 -1
- package/package.json +6 -1
- package/server/agent-executor.ts +37 -2
- package/server/agent-store.ts +3 -3
- package/server/agent-types.ts +11 -0
- package/server/assistant-store.ts +232 -6
- package/server/auth-manager.ts +9 -0
- package/server/cache-headers.ts +1 -1
- package/server/calendar-service.ts +10 -0
- package/server/ceo/document-store.ts +129 -0
- package/server/ceo/finance-store.ts +343 -0
- package/server/ceo/kpi-store.ts +208 -0
- package/server/ceo/memory-import.ts +277 -0
- package/server/ceo/news-store.ts +208 -0
- package/server/ceo/template-store.ts +134 -0
- package/server/ceo/time-tracking-store.ts +227 -0
- package/server/claude-auth-monitor.ts +128 -0
- package/server/claude-code-worker.ts +86 -0
- package/server/claude-session-discovery.ts +74 -1
- package/server/cli-launcher.ts +32 -10
- package/server/codex-adapter.ts +2 -2
- package/server/codex-ws-proxy.cjs +1 -1
- package/server/container-manager.ts +4 -4
- package/server/content-intelligence/content-engine.ts +1112 -0
- package/server/content-intelligence/platform-knowledge.ts +870 -0
- package/server/cron-store.ts +3 -3
- package/server/embedding-service.ts +49 -0
- package/server/event-bus-types.ts +13 -0
- package/server/federation/node-store.ts +5 -4
- package/server/fs-utils.ts +28 -1
- package/server/hank-notifications-store.ts +91 -0
- package/server/hank-tool-executor.ts +1835 -0
- package/server/hank-tools.ts +2107 -0
- package/server/image-pull-manager.ts +2 -2
- package/server/index.ts +25 -2
- package/server/llm-providers-streaming.ts +541 -0
- package/server/llm-providers.ts +12 -0
- package/server/marketplace.ts +249 -0
- package/server/mcp-registry.ts +158 -0
- package/server/memory-service.ts +296 -0
- package/server/obsidian-sync.ts +184 -0
- package/server/provider-manager.ts +5 -2
- package/server/provider-registry.ts +12 -0
- package/server/reminder-scheduler.ts +37 -1
- package/server/routes/agent-routes.ts +2 -1
- package/server/routes/assistant-routes.ts +198 -5
- package/server/routes/ceo-finance-kpi-routes.ts +167 -0
- package/server/routes/ceo-news-time-routes.ts +137 -0
- package/server/routes/ceo-routes.ts +99 -0
- package/server/routes/content-routes.ts +116 -0
- package/server/routes/email-routes.ts +147 -0
- package/server/routes/env-routes.ts +3 -3
- package/server/routes/fs-routes.ts +12 -9
- package/server/routes/hank-chat-routes.ts +592 -0
- package/server/routes/llm-routes.ts +12 -0
- package/server/routes/marketplace-routes.ts +63 -0
- package/server/routes/media-routes.ts +1 -1
- package/server/routes/memory-routes.ts +127 -0
- package/server/routes/platform-routes.ts +14 -675
- package/server/routes/sandbox-routes.ts +1 -1
- package/server/routes/settings-routes.ts +51 -1
- package/server/routes/socialmedia-routes.ts +152 -2
- package/server/routes/system-routes.ts +2 -2
- package/server/routes/team-routes.ts +71 -0
- package/server/routes/telephony-routes.ts +98 -18
- package/server/routes.ts +36 -9
- package/server/session-creation-service.ts +2 -2
- package/server/session-orchestrator.ts +54 -2
- package/server/session-types.ts +2 -0
- package/server/settings-manager.ts +50 -2
- package/server/skill-discovery.ts +68 -0
- package/server/socialmedia/adapters/browser-adapter.ts +179 -0
- package/server/socialmedia/adapters/postiz-adapter.ts +291 -14
- package/server/socialmedia/manager.ts +234 -15
- package/server/socialmedia/store.ts +51 -1
- package/server/socialmedia/types.ts +35 -2
- package/server/socialview/browser-manager.ts +150 -0
- package/server/socialview/extractors.ts +1298 -0
- package/server/socialview/image-describe.ts +188 -0
- package/server/socialview/library.ts +119 -0
- package/server/socialview/poster.ts +276 -0
- package/server/socialview/routes.ts +371 -0
- package/server/socialview/style-analyzer.ts +187 -0
- package/server/socialview/style-profiles.ts +67 -0
- package/server/socialview/types.ts +166 -0
- package/server/socialview/vision.ts +127 -0
- package/server/socialview/vnc-manager.ts +110 -0
- package/server/style-injector.ts +135 -0
- package/server/team-service.ts +239 -0
- package/server/team-store.ts +75 -0
- package/server/team-types.ts +52 -0
- package/server/telephony/audio-bridge.ts +281 -35
- package/server/telephony/audio-recorder.ts +132 -0
- package/server/telephony/call-manager.ts +803 -104
- package/server/telephony/call-types.ts +67 -1
- package/server/telephony/esl-client.ts +319 -0
- package/server/telephony/freeswitch-sync.ts +155 -0
- package/server/telephony/phone-utils.ts +63 -0
- package/server/telephony/telephony-store.ts +9 -8
- package/server/url-validator.ts +82 -0
- package/server/vault-markdown.ts +317 -0
- package/server/vault-migration.ts +121 -0
- package/server/vault-store.ts +466 -0
- package/server/vault-watcher.ts +59 -0
- package/server/vector-store.ts +210 -0
- package/server/voice-pipeline/gemini-live-adapter.ts +97 -0
- package/server/voice-pipeline/greeting-cache.ts +200 -0
- package/server/voice-pipeline/manager.ts +249 -0
- package/server/voice-pipeline/pipeline.ts +335 -0
- package/server/voice-pipeline/providers/index.ts +47 -0
- package/server/voice-pipeline/providers/llm-internal.ts +527 -0
- package/server/voice-pipeline/providers/stt-google.ts +157 -0
- package/server/voice-pipeline/providers/tts-google.ts +126 -0
- package/server/voice-pipeline/types.ts +247 -0
- package/server/ws-bridge-types.ts +6 -1
- package/dist/assets/AssistantPage-DJ-cMQfb.js +0 -1
- package/dist/assets/HelpPage-DMfkzERp.js +0 -1
- package/dist/assets/MediaPage-CE5rdvkC.js +0 -1
- package/dist/assets/RunsPage-C5BZF5Rx.js +0 -1
- package/dist/assets/SettingsPage-DirhjQrJ.js +0 -51
- package/dist/assets/SocialMediaPage-DBuM28vD.js +0 -1
- package/dist/assets/TelephonyPage-x0VV0fOo.js +0 -1
- package/dist/assets/index-C8M_PUmX.css +0 -32
- package/dist/assets/sw-register-LSSpj6RU.js +0 -1
- package/server/socialmedia/adapters/ayrshare-adapter.ts +0 -169
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import{r as s,b as o,j as e,u as b,n as bs,a as vs}from"./index-CEqZnThB.js";import{unsubscribeFromPush as ys,subscribeToPush as js}from"./sw-register-LSSpj6RU.js";function Ns(){const[a,p]=s.useState(null),[w,v]=s.useState(""),[u,d]=s.useState([]),[m,S]=s.useState([]),[h,N]=s.useState(!0),[A,i]=s.useState(!1),[x,T]=s.useState(""),[O,D]=s.useState(""),[R,n]=s.useState(""),[I,F]=s.useState(""),[H,ae]=s.useState(""),G=s.useCallback(async()=>{try{const[r,P,$]=await Promise.all([o.getFederationIdentity(),o.getFederationNodes(),o.getFederationRemoteSessions()]);p(r),v(r.name),d(P.nodes),S($.sessions)}catch{}N(!1)},[]);s.useEffect(()=>{G()},[G]),s.useEffect(()=>{const r=setInterval(G,1e4);return()=>clearInterval(r)},[G]);const L=(r,P=!1)=>{P?(T(r),D("")):(D(r),T("")),setTimeout(()=>{T(""),D("")},4e3)},Q=async()=>{if(w.trim()){i(!0);try{await o.updateFederationIdentity(w.trim()),L("Node name saved")}catch(r){L(r instanceof Error?r.message:"Failed to save",!0)}i(!1)}},C=async()=>{if(!R.trim()||!I.trim()){L("URL and shared secret are required",!0);return}i(!0);try{await o.addFederationNode({url:R.trim(),secret:I.trim(),name:H.trim()}),n(""),F(""),ae(""),L("Node added, connecting..."),setTimeout(G,2e3)}catch(r){L(r instanceof Error?r.message:"Failed to add node",!0)}i(!1)},J=async r=>{try{await o.removeFederationNode(r),L("Node removed"),G()}catch(P){L(P instanceof Error?P.message:"Failed to remove",!0)}},me=async r=>{try{const P=await o.testFederationNode(r);L(P.connected?"Connection OK":"Not connected")}catch(P){L(P instanceof Error?P.message:"Test failed",!0)}};return h?e.jsx("div",{className:"text-sm text-cc-muted",children:"Loading federation..."}):e.jsxs("div",{className:"space-y-5",children:[x&&e.jsx("div",{className:"text-sm text-cc-error bg-cc-error/5 border border-cc-error/20 rounded-lg px-3 py-2",children:x}),O&&e.jsx("div",{className:"text-sm text-cc-success bg-cc-success/5 border border-cc-success/20 rounded-lg px-3 py-2",children:O}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold text-cc-muted uppercase tracking-wider mb-2",children:"This Node"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:w,onChange:r=>v(r.target.value),onKeyDown:r=>r.key==="Enter"&&Q(),placeholder:"Node name",className:"flex-1 px-3 py-2 text-sm rounded-lg bg-cc-hover border border-cc-border text-cc-fg outline-none focus:border-cc-primary/50"}),e.jsx("button",{onClick:Q,disabled:A,className:"px-3 py-2 text-sm rounded-lg bg-cc-hover border border-cc-border text-cc-fg hover:bg-cc-active transition-colors cursor-pointer disabled:opacity-50",children:"Save"})]}),a&&e.jsxs("p",{className:"text-[10px] text-cc-muted/60 font-mono mt-1 break-all",children:["ID: ",a.nodeId]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold text-cc-muted uppercase tracking-wider mb-2",children:"Add Node"}),e.jsx("p",{className:"text-xs text-cc-muted mb-2",children:"Enter the URL and shared secret of a remote HeyHank instance."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{type:"url",value:R,onChange:r=>n(r.target.value),placeholder:"https://other-hank.example.com",className:"w-full px-3 py-2 text-sm rounded-lg bg-cc-hover border border-cc-border text-cc-fg outline-none focus:border-cc-primary/50"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"password",value:I,onChange:r=>F(r.target.value),placeholder:"Shared secret",className:"flex-1 px-3 py-2 text-sm rounded-lg bg-cc-hover border border-cc-border text-cc-fg outline-none focus:border-cc-primary/50"}),e.jsx("input",{type:"text",value:H,onChange:r=>ae(r.target.value),placeholder:"Name (optional)",className:"flex-1 px-3 py-2 text-sm rounded-lg bg-cc-hover border border-cc-border text-cc-fg outline-none focus:border-cc-primary/50"})]}),e.jsx("button",{onClick:C,disabled:A,className:"w-full px-3 py-2.5 text-sm font-medium rounded-lg bg-cc-primary/10 border border-cc-primary/30 text-cc-primary hover:bg-cc-primary/15 transition-colors cursor-pointer disabled:opacity-50",children:"Connect Node"})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold text-cc-muted uppercase tracking-wider mb-2",children:["Connected Nodes (",u.length,")"]}),u.length===0?e.jsx("p",{className:"text-xs text-cc-muted/50",children:"No nodes configured."}):e.jsx("div",{className:"space-y-2",children:u.map(r=>e.jsxs("div",{className:"border border-cc-border/60 rounded-lg p-3 bg-cc-card/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("span",{className:"text-sm font-medium text-cc-fg flex items-center gap-1.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${r.connected?"bg-cc-success shadow-[0_0_6px_rgba(74,222,128,0.4)]":"bg-cc-error/60"}`}),r.remoteName||r.name||"Unknown"]}),e.jsxs("span",{className:"text-[10px] text-cc-muted",children:[r.connected?"Connected":"Offline"," · ",r.sessionCount," sessions"]})]}),e.jsx("p",{className:"text-[10px] text-cc-muted/60 break-all mb-2",children:r.url}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("button",{onClick:()=>me(r.id),className:"px-2 py-1 text-[11px] rounded bg-cc-hover border border-cc-border text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:"Test"}),e.jsx("button",{onClick:()=>J(r.id),className:"px-2 py-1 text-[11px] rounded bg-cc-hover border border-cc-error/20 text-cc-error hover:bg-cc-error/5 transition-colors cursor-pointer",children:"Remove"})]})]},r.id))})]}),m.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold text-cc-muted uppercase tracking-wider mb-2",children:["Remote Sessions (",m.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:m.map(r=>e.jsxs("div",{className:"border border-cc-border/40 rounded-lg px-3 py-2 bg-cc-card/30",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs font-medium text-cc-fg truncate",children:r.name||r.sessionId.slice(0,8)}),e.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded bg-cc-primary/15 text-cc-primary leading-none shrink-0",children:r.nodeName})]}),e.jsxs("p",{className:"text-[10px] text-cc-muted/60 truncate mt-0.5",children:[r.model||""," · ",r.cwd||r.sessionId]})]},`${r.nodeId}:${r.sessionId}`))})]})]})}const ks={cloud:"Cloud Providers",gateway:"Gateways & Proxies",local:"Local / Self-Hosted",custom:"Custom"},ws=["cloud","gateway","local","custom"];function Ss(){const[a,p]=s.useState([]),[w,v]=s.useState(!0),[u,d]=s.useState(null),[m,S]=s.useState(""),h=s.useCallback(()=>{o.getProviders().then(p).catch(()=>{}).finally(()=>v(!1))},[]);if(s.useEffect(()=>{h()},[h]),w)return e.jsx("p",{className:"text-xs text-cc-muted",children:"Loading providers..."});const N=m?a.filter(i=>i.name.toLowerCase().includes(m.toLowerCase())||i.description.toLowerCase().includes(m.toLowerCase())):a,A=ws.map(i=>({category:i,label:ks[i]||i,items:N.filter(x=>x.category===i)})).filter(i=>i.items.length>0);return e.jsxs("div",{className:"space-y-4",children:[a.length>10&&e.jsx("input",{type:"text",value:m,onChange:i=>S(i.target.value),placeholder:"Search providers...",className:"w-full px-3 py-2 text-sm bg-cc-input-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"}),A.map(i=>e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-cc-muted uppercase tracking-wide mb-2",children:i.label}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:i.items.map(x=>e.jsx(Cs,{provider:x,expanded:u===x.id,onToggle:()=>d(u===x.id?null:x.id),onUpdate:h},x.id))})]},i.category))]})}function Cs({provider:a,expanded:p,onToggle:w,onUpdate:v}){const[u,d]=s.useState({}),[m,S]=s.useState(!1),[h,N]=s.useState(!1),[A,i]=s.useState(""),[x,T]=s.useState(!1);s.useEffect(()=>{p&&!x&&o.getProvider(a.id).then(n=>{var F;const I={};for(const H of a.envFields)!H.secret&&((F=n.envValues)!=null&&F[H.key])&&(I[H.key]=n.envValues[H.key]);d(I),T(!0)}).catch(()=>{})},[p,x,a.id,a.envFields]);const O=async()=>{S(!0),i(""),N(!1);try{const n={};for(const[I,F]of Object.entries(u))F.trim()&&(n[I]=F.trim());await o.updateProvider(a.id,{enabled:!0,envValues:n}),N(!0),setTimeout(()=>N(!1),2e3),d({}),T(!1),v()}catch(n){i(n instanceof Error?n.message:String(n))}finally{S(!1)}},D=async()=>{try{await o.deleteProvider(a.id),d({}),T(!1),v()}catch{}},R=async()=>{try{await o.updateProvider(a.id,{enabled:!a.enabled}),v()}catch{}};return e.jsxs("div",{className:`rounded-lg border transition-colors ${a.configured&&a.enabled?"border-cc-success/30 bg-cc-success/5":a.configured?"border-cc-warning/30 bg-cc-warning/5":"border-cc-border bg-cc-bg"}`,children:[e.jsxs("button",{type:"button",onClick:w,className:"w-full flex items-center justify-between px-3 py-2.5 cursor-pointer text-left",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-cc-fg truncate",children:a.name}),a.configured&&a.enabled&&e.jsx("span",{className:"shrink-0 w-1.5 h-1.5 rounded-full bg-cc-success"}),a.configured&&!a.enabled&&e.jsx("span",{className:"shrink-0 w-1.5 h-1.5 rounded-full bg-cc-warning"})]}),e.jsx("p",{className:"text-[11px] text-cc-muted truncate",children:a.description})]}),e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`shrink-0 w-3.5 h-3.5 text-cc-muted transition-transform ${p?"rotate-180":""}`,children:e.jsx("path",{fillRule:"evenodd",d:"M4.22 6.22a.75.75 0 0 1 1.06 0L8 8.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L4.22 7.28a.75.75 0 0 1 0-1.06Z"})})]}),p&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-cc-border/50 pt-3",children:[a.envFields.map(n=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"block text-xs text-cc-muted",htmlFor:`prov-${a.id}-${n.key}`,children:[n.label,n.required&&e.jsx("span",{className:"text-cc-error ml-0.5",children:"*"}),a.envConfigured[n.key]&&n.secret&&e.jsx("span",{className:"ml-1 text-cc-success",children:"(configured)"})]}),e.jsx("input",{id:`prov-${a.id}-${n.key}`,type:n.secret?"password":"text",value:u[n.key]??"",onChange:I=>d({...u,[n.key]:I.target.value}),placeholder:a.envConfigured[n.key]&&n.secret?"Enter new value to replace":n.placeholder||"",className:"w-full px-2.5 py-1.5 text-sm bg-cc-input-bg rounded-md text-cc-fg placeholder:text-cc-muted/50 focus:outline-none focus:ring-1 focus:ring-cc-primary/40"})]},n.key)),a.docsUrl&&e.jsxs("a",{href:a.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-cc-primary hover:underline",children:["Documentation",e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:e.jsx("path",{d:"M3.75 2a.75.75 0 0 0 0 1.5h5.69L2.22 10.72a.75.75 0 1 0 1.06 1.06L10.5 4.56v5.69a.75.75 0 0 0 1.5 0V2.75a.75.75 0 0 0-.75-.75H3.75Z"})})]}),A&&e.jsx("p",{className:"text-xs text-cc-error",children:A}),h&&e.jsx("p",{className:"text-xs text-cc-success",children:"Saved!"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:O,disabled:m||Object.values(u).every(n=>!n.trim()),className:`px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${m||Object.values(u).every(n=>!n.trim())?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary-btn hover:bg-cc-primary-btn-hover text-white cursor-pointer"}`,children:m?"Saving...":"Save"}),a.configured&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:R,className:"px-3 py-1.5 rounded-md text-xs font-medium bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:a.enabled?"Disable":"Enable"}),e.jsx("button",{type:"button",onClick:D,className:"px-3 py-1.5 rounded-md text-xs font-medium text-cc-error hover:bg-cc-error/10 transition-colors cursor-pointer",children:"Remove"})]})]})]})]})}const Ye=[{id:"general",label:"General"},{id:"connectivity",label:"Connectivity"},{id:"authentication",label:"Authentication"},{id:"notifications",label:"Notifications"},{id:"providers",label:"Providers"},{id:"gemini",label:"Gemini"},{id:"email",label:"Email"},{id:"calendar",label:"Calendar"},{id:"ai-features",label:"HeyHank AI"},{id:"updates",label:"Updates"},{id:"appearance",label:"Appearance"},{id:"environments",label:"Environments"},{id:"federation",label:"Federation"},{id:"backup",label:"Backup"}];function As(){const[a,p]=s.useState(!1),[w,v]=s.useState(!0);s.useEffect(()=>{(async()=>{var d;try{const m=await((d=navigator.serviceWorker)==null?void 0:d.ready);if(m){const S=await m.pushManager.getSubscription();p(!!S)}}catch{}v(!1)})()},[]);const u=async()=>{v(!0);try{if(a)await ys(),p(!1);else{if(Notification.permission!=="granted"&&await Notification.requestPermission()!=="granted"){v(!1);return}const d=await js();p(!!d)}}catch(d){console.error("[push] Toggle failed:",d)}v(!1)};return typeof Notification>"u"||!("serviceWorker"in navigator)?null:e.jsxs("button",{type:"button",onClick:u,disabled:w,className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer disabled:opacity-50",children:[e.jsx("span",{children:"Push Notifications (Agent Alerts)"}),e.jsx("span",{className:"text-xs text-cc-muted",children:w?"...":a?"On":"Off"})]})}function Ds({embedded:a=!1}){const[p,w]=s.useState(""),[v,u]=s.useState("claude-sonnet-4-6"),[d,m]=s.useState(!1),[S,h]=s.useState(!1),[N,A]=s.useState(!0),[i,x]=s.useState(!1),[T,O]=s.useState(""),[D,R]=s.useState(!1),n=b(t=>t.darkMode),I=b(t=>t.toggleDarkMode),F=b(t=>t.diffBase),H=b(t=>t.setDiffBase),ae=b(t=>t.notificationSound),G=b(t=>t.toggleNotificationSound),L=b(t=>t.notificationDesktop),Q=b(t=>t.setNotificationDesktop),C=b(t=>t.updateInfo),J=b(t=>t.setUpdateInfo),me=b(t=>t.setUpdateOverlayActive),r=b(t=>t.setEditorTabEnabled),P=typeof Notification<"u",[$,Z]=s.useState("stable"),[re,xe]=s.useState(!1),[pe,qe]=s.useState(!1),[he,Qe]=s.useState(!1),[Je,X]=s.useState(""),[Ze,ne]=s.useState(""),[oe,ge]=s.useState(!1),[fe,be]=s.useState(!0),[ve,ye]=s.useState(!1),[ee,je]=s.useState(""),[Xe,et]=s.useState("general"),[Us,Ts]=s.useState(!1),[Is,Ls]=s.useState(!1),[Fs,Os]=s.useState(null),[z,tt]=s.useState(""),[ie,st]=s.useState(!1),[Y,ct]=s.useState(""),[le,at]=s.useState(!1),[Ne,rt]=s.useState(!1),[Wt,ke]=s.useState(!1),[nt,ot]=s.useState(""),[zt,it]=s.useState(!1),[Yt,lt]=s.useState(!1),[g,dt]=s.useState(null),[j,ut]=s.useState(null),[te,mt]=s.useState(""),[we,xt]=s.useState(!1),[Se,Ce]=s.useState("Kore"),[qt,pt]=s.useState("Kore"),[Ae,Ee]=s.useState(""),[Qt,ht]=s.useState(""),[Pe,Ue]=s.useState(""),[Jt,gt]=s.useState(""),[Zt,ft]=s.useState(!1),[Te,bt]=s.useState(!1),[Xt,Ie]=s.useState(!1),[vt,yt]=s.useState(""),[jt,es]=s.useState([]),[ts,Nt]=s.useState(!1),[kt,Le]=s.useState(""),[wt,St]=s.useState(""),[V,Ct]=s.useState(null),[ss,Fe]=s.useState(!1),[f,U]=s.useState({name:"",email:"",imapHost:"",imapPort:"993",imapSecure:!0,smtpHost:"",smtpPort:"465",smtpSecure:!0,authUser:"",authPass:""}),[At,Et]=s.useState(null),[se,Oe]=s.useState(null),[Pt,cs]=s.useState([]),[as,Ut]=s.useState(!1),[Tt,de]=s.useState(""),[It,Lt]=s.useState(""),[_,Ft]=s.useState(null),[Ot,Re]=s.useState(!1),[k,B]=s.useState({name:"",provider:"google",serverUrl:"",authUser:"",authPass:""}),[Rt,Vt]=s.useState(null),[W,Ve]=s.useState(null),[ce,Dt]=s.useState(null),[De,Ht]=s.useState(!1),[M,$t]=s.useState(null),[ue,rs]=s.useState(0),[He,Mt]=s.useState(!1),[$e,Gt]=s.useState(!1),[ns,Kt]=s.useState(!1),_t=s.useRef(null),Me=s.useRef({});s.useEffect(()=>{const t=_t.current;if(!t)return;const c=new IntersectionObserver(l=>{var q;let y=null;for(const ze of l)ze.isIntersecting&&(!y||ze.boundingClientRect.top<y.boundingClientRect.top)&&(y=ze);(q=y==null?void 0:y.target)!=null&&q.id&&et(y.target.id)},{root:t,rootMargin:"-10% 0px -70% 0px",threshold:0});for(const l of Ye){const y=Me.current[l.id];y&&c.observe(y)}return()=>c.disconnect()},[N]);const Bt=s.useCallback(t=>{et(t);const c=Me.current[t];c&&c.scrollIntoView({behavior:"smooth",block:"start"})},[]);s.useEffect(()=>{o.getSettings().then(t=>{h(t.anthropicApiKeyConfigured),o.getProviders().then(c=>{c.some(l=>l.configured&&l.enabled)&&h(!0)}).catch(()=>{}),st(t.claudeCodeOAuthTokenConfigured),at(t.openaiApiKeyConfigured),t.claudeCliAuth&&dt(t.claudeCliAuth),t.codexCliAuth&&ut(t.codexCliAuth),xt(t.geminiApiKeyConfigured),t.geminiVoice&&(Ce(t.geminiVoice),pt(t.geminiVoice)),typeof t.assistantName=="string"&&(Ee(t.assistantName),ht(t.assistantName)),typeof t.userName=="string"&&(Ue(t.userName),gt(t.userName)),u(t.anthropicModel||"claude-sonnet-4-6"),m(t.editorTabEnabled),r(t.editorTabEnabled),typeof t.aiValidationEnabled=="boolean"&&ge(t.aiValidationEnabled),typeof t.aiValidationAutoApprove=="boolean"&&be(t.aiValidationAutoApprove),typeof t.aiValidationAutoDeny=="boolean"&&ye(t.aiValidationAutoDeny),(t.updateChannel==="stable"||t.updateChannel==="prerelease")&&Z(t.updateChannel),typeof t.dockerAutoUpdate=="boolean"&&xe(t.dockerAutoUpdate),typeof t.publicUrl=="string"&&(je(t.publicUrl),b.getState().setPublicUrl(t.publicUrl))}).catch(t=>O(t instanceof Error?t.message:String(t))).finally(()=>A(!1)),o.getAuthToken().then(t=>Dt(t.token)).catch(()=>{}),Ge(),_e()},[]);function Ge(){Nt(!0),fetch("/api/email-accounts",{headers:{...K()}}).then(t=>t.json()).then(t=>es(t)).catch(()=>{}).finally(()=>Nt(!1))}function K(){const t=localStorage.getItem("auth_token")||sessionStorage.getItem("auth_token");return t?{Authorization:`Bearer ${t}`}:{}}function Ke(){U({name:"",email:"",imapHost:"",imapPort:"993",imapSecure:!0,smtpHost:"",smtpPort:"465",smtpSecure:!0,authUser:"",authPass:""}),Ct(null),Fe(!1)}async function os(){Le("");const t={name:f.name.trim(),email:f.email.trim(),imap:{host:f.imapHost.trim(),port:parseInt(f.imapPort)||993,secure:f.imapSecure},smtp:{host:f.smtpHost.trim(),port:parseInt(f.smtpPort)||465,secure:f.smtpSecure},auth:{user:f.authUser.trim(),pass:f.authPass}};if(!t.name||!t.email||!t.imap.host||!t.smtp.host||!t.auth.user||!t.auth.pass){Le("All fields are required.");return}try{const c=V?`/api/email-accounts/${V.id}`:"/api/email-accounts",y=await fetch(c,{method:V?"PUT":"POST",headers:{"Content-Type":"application/json",...K()},body:JSON.stringify(t)});if(!y.ok){const q=await y.json().catch(()=>({}));throw new Error(q.error||"Failed")}St(V?"Account updated.":"Account added."),setTimeout(()=>St(""),2e3),Ke(),Ge()}catch(c){Le(c instanceof Error?c.message:String(c))}}async function is(t){if(confirm("Delete this email account?"))try{await fetch(`/api/email-accounts/${t}`,{method:"DELETE",headers:K()}),Ge()}catch{}}async function ls(t){Et(t),Oe(null);try{const l=await(await fetch(`/api/email-accounts/${t}/test`,{method:"POST",headers:K()})).json();Oe({id:t,ok:l.ok,message:l.ok?l.message:l.error})}catch(c){Oe({id:t,ok:!1,message:c instanceof Error?c.message:"Connection failed"})}finally{Et(null)}}function ds(t){Ct(t),U({name:t.name,email:t.email,imapHost:t.imap.host,imapPort:String(t.imap.port),imapSecure:t.imap.secure,smtpHost:t.smtp.host,smtpPort:String(t.smtp.port),smtpSecure:t.smtp.secure,authUser:t.auth.user,authPass:""}),Fe(!0)}function _e(){Ut(!0),fetch("/api/calendar-accounts",{headers:{...K()}}).then(t=>t.json()).then(t=>cs(t)).catch(()=>{}).finally(()=>Ut(!1))}function Be(){B({name:"",provider:"google",serverUrl:"",authUser:"",authPass:""}),Ft(null),Re(!1)}function us(t){const c={google:{serverUrl:"https://apidata.googleusercontent.com/caldav/v2/"},icloud:{serverUrl:"https://caldav.icloud.com/"},outlook:{serverUrl:"https://outlook.office365.com/caldav/"},caldav:{serverUrl:""}};B(l=>{var y;return{...l,provider:t==="outlook"?"caldav":t,serverUrl:((y=c[t])==null?void 0:y.serverUrl)||""}})}async function ms(){de("");const t={name:k.name.trim(),provider:k.provider,serverUrl:k.serverUrl.trim(),auth:{user:k.authUser.trim(),pass:k.authPass}};if(!t.name||!t.auth.user||!t.auth.pass){de("Name, user and password are required.");return}if(t.provider==="caldav"&&!t.serverUrl){de("Server URL is required for custom CalDAV.");return}try{const c=_?`/api/calendar-accounts/${_.id}`:"/api/calendar-accounts",y=await fetch(c,{method:_?"PUT":"POST",headers:{"Content-Type":"application/json",...K()},body:JSON.stringify(t)});if(!y.ok){const q=await y.json().catch(()=>({}));throw new Error(q.error||"Failed")}Lt(_?"Account updated.":"Account added."),setTimeout(()=>Lt(""),2e3),Be(),_e()}catch(c){de(c instanceof Error?c.message:String(c))}}async function xs(t){if(confirm("Delete this calendar account?"))try{await fetch(`/api/calendar-accounts/${t}`,{method:"DELETE",headers:K()}),_e()}catch{}}async function ps(t){Vt(t),Ve(null);try{const l=await(await fetch(`/api/calendar-accounts/${t}/test`,{method:"POST",headers:K()})).json();Ve({id:t,ok:l.ok,message:l.ok?l.message:l.error,calendars:l.calendars})}catch(c){Ve({id:t,ok:!1,message:c instanceof Error?c.message:"Connection failed"})}finally{Vt(null)}}function hs(t){Ft(t),B({name:t.name,provider:t.provider,serverUrl:t.serverUrl,authUser:t.auth.user,authPass:""}),Re(!0)}async function We(t){const c=t==="aiValidationEnabled"?oe:t==="aiValidationAutoApprove"?fe:ve,l=!c;t==="aiValidationEnabled"?ge(l):t==="aiValidationAutoApprove"?be(l):ye(l);try{await o.updateSettings({[t]:l})}catch{t==="aiValidationEnabled"?ge(c):t==="aiValidationAutoApprove"?be(c):ye(c)}}async function gs(){qe(!0),X(""),ne("");try{const t=await o.forceCheckForUpdate();J(t),t.updateAvailable&&t.latestVersion?X(`Update v${t.latestVersion} is available.`):X("You are up to date.")}catch(t){ne(t instanceof Error?t.message:String(t))}finally{qe(!1)}}async function fs(){Qe(!0),X(""),ne("");try{localStorage.setItem("heyhank_docker_prompt_pending","1");const t=await o.triggerUpdate();X(t.message),me(!0)}catch(t){localStorage.removeItem("heyhank_docker_prompt_pending"),ne(t instanceof Error?t.message:String(t)),Qe(!1)}}const E=s.useCallback(t=>c=>{Me.current[t]=c},[]);return e.jsxs("div",{className:`${a?"h-full":"h-[100dvh]"} bg-cc-bg text-cc-fg font-sans-ui antialiased flex flex-col`,children:[e.jsx("div",{className:"shrink-0 max-w-5xl w-full mx-auto px-4 sm:px-8 pt-6 sm:pt-10",children:e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-cc-fg",children:"Settings"}),e.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Configure API access, notifications, appearance, and workspace defaults."})]}),!a&&e.jsx("button",{onClick:()=>{const t=b.getState().currentSessionId;t?bs(t):vs()},className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Back"})]})}),e.jsx("div",{className:"sm:hidden shrink-0 border-b border-cc-border",children:e.jsx("nav",{className:"flex gap-1 px-4 py-2 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","aria-label":"Settings categories",children:Ye.map(t=>e.jsx("button",{type:"button",onClick:()=>Bt(t.id),className:`shrink-0 px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer ${Xe===t.id?"text-cc-primary bg-cc-primary/8":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:t.label},t.id))})}),e.jsxs("div",{className:"flex-1 min-h-0 flex max-w-5xl w-full mx-auto",children:[e.jsx("nav",{className:"hidden sm:flex flex-col gap-0.5 w-44 shrink-0 pt-2 pr-6 pl-8 sticky top-0 self-start","aria-label":"Settings categories",children:Ye.map(t=>e.jsx("button",{type:"button",onClick:()=>Bt(t.id),className:`text-left px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer ${Xe===t.id?"text-cc-primary bg-cc-primary/8":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:t.label},t.id))}),e.jsx("div",{ref:_t,className:"flex-1 min-w-0 overflow-y-auto px-4 sm:px-8 sm:pl-0 pb-safe",children:e.jsxs("div",{className:"space-y-10 py-4 sm:py-2",children:[e.jsxs("section",{id:"general",ref:E("general"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"General"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",onClick:I,className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Theme"}),e.jsx("span",{className:"text-xs text-cc-muted",children:n?"Dark":"Light"})]}),e.jsxs("button",{type:"button",onClick:()=>m(t=>!t),className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Enable Editor tab (CodeMirror)"}),e.jsx("span",{className:"text-xs text-cc-muted",children:d?"On":"Off"})]}),e.jsx("p",{className:"text-xs text-cc-muted px-1",children:"Shows a simple in-app file editor in the session tabs."}),e.jsxs("button",{type:"button",onClick:()=>H(F==="last-commit"?"default-branch":"last-commit"),className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Diff compare against"}),e.jsx("span",{className:"text-xs text-cc-muted",children:F==="last-commit"?"Last commit (HEAD)":"Default branch"})]}),e.jsx("p",{className:"text-xs text-cc-muted px-1",children:"Last commit shows only uncommitted changes. Default branch shows all changes since diverging from main."})]})]}),e.jsxs("section",{id:"connectivity",ref:E("connectivity"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Connectivity"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-cc-muted",children:"HeyHank needs an externally-reachable HTTPS URL for mobile access (PWA), webhooks (GitHub), and OAuth callbacks."}),e.jsxs("div",{className:"bg-cc-hover/50 rounded-lg p-3 space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold text-cc-muted uppercase tracking-wider",children:"Public URL"}),e.jsx("p",{className:"text-[11px] text-cc-muted",children:"If you have your own domain with a reverse proxy (nginx, Caddy), enter the URL here."}),e.jsx("input",{id:"public-url",type:"url","aria-label":"Public URL",value:ee,onChange:t=>je(t.target.value),placeholder:"https://your-domain.example.com",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg border border-cc-border text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary font-mono-code"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:async()=>{x(!0),O("");try{const t=await o.updateSettings({publicUrl:ee.trim()});je(t.publicUrl),b.getState().setPublicUrl(t.publicUrl),R(!0),setTimeout(()=>R(!1),1800)}catch(t){O(t instanceof Error?t.message:String(t))}finally{x(!1)}},disabled:i,className:"px-3 py-1.5 rounded-lg text-xs font-medium bg-cc-primary text-white hover:opacity-90 transition-opacity disabled:opacity-50 cursor-pointer",children:i?"Saving...":D?"Saved!":"Save"}),ee&&e.jsxs("span",{className:"text-[11px] text-green-500 font-medium",children:["Active: ",ee]}),!ee&&e.jsxs("span",{className:"text-[11px] text-cc-muted",children:["Not set — using ",typeof window<"u"?window.location.origin:"http://localhost:3456"]})]})]}),e.jsxs("div",{className:"bg-cc-hover/50 rounded-lg p-3 space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold text-cc-muted uppercase tracking-wider",children:"Tailscale (no domain needed)"}),e.jsx("p",{className:"text-[11px] text-cc-muted",children:"No domain? Tailscale Funnel gives you a free HTTPS URL automatically. Install Tailscale on your server, then enable Funnel here."}),e.jsx(Es,{})]}),e.jsxs("div",{className:"bg-cc-hover/50 rounded-lg p-3 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-cc-muted uppercase tracking-wider",children:"What the Public URL enables"}),e.jsxs("ul",{className:"text-[11px] text-cc-muted space-y-1 list-disc pl-4",children:[e.jsx("li",{children:"Mobile access — install HeyHank as PWA on your phone"}),e.jsx("li",{children:"Webhooks — receive events from GitHub and other services"}),e.jsx("li",{children:"OAuth callbacks — authenticate with external services"}),e.jsx("li",{children:"Federation — connect multiple HeyHank instances"})]})]})]})]}),e.jsxs("section",{id:"authentication",ref:E("authentication"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Authentication"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-cc-muted",children:"Use the auth token or QR code to connect additional devices (e.g. mobile over Tailscale)."}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",children:"Auth Token"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg font-mono-code select-all break-all flex items-center",children:ce?De?ce:"••••••••••••••••":e.jsx("span",{className:"text-cc-muted",children:"Loading..."})}),e.jsx("button",{type:"button",onClick:()=>Ht(t=>!t),className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer",title:De?"Hide token":"Show token",children:De?"Hide":"Show"}),e.jsx("button",{type:"button",onClick:()=>{ce&&navigator.clipboard.writeText(ce).then(()=>{Kt(!0),setTimeout(()=>Kt(!1),1500)})},disabled:!ce,className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",title:"Copy token to clipboard",children:ns?"Copied":"Copy"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",children:"Mobile Login QR"}),M&&M.length>0?e.jsxs("div",{className:"space-y-3",children:[M.length>1&&e.jsx("div",{className:"flex gap-1",children:M.map((t,c)=>e.jsx("button",{type:"button",onClick:()=>rs(c),className:`px-3 py-1.5 rounded-md text-xs font-medium transition-colors cursor-pointer ${c===ue?"bg-cc-primary text-white":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:t.label},t.label))}),e.jsx("div",{className:"inline-block rounded-lg bg-white p-2",children:e.jsx("img",{src:M[ue].qrDataUrl,alt:`QR code for ${M[ue].label} login`,className:"w-48 h-48"})}),e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-bg text-sm font-mono-code text-cc-fg break-all select-all",children:M[ue].url}),e.jsx("p",{className:"text-xs text-cc-muted",children:"Scan with your phone's camera app — it will open the URL and auto-authenticate."})]}):M&&M.length===0?e.jsx("p",{className:"text-xs text-cc-muted",children:"No remote addresses detected (LAN or Tailscale). Connect to a network to generate a QR code."}):e.jsx("button",{type:"button",onClick:async()=>{Mt(!0);try{const t=await o.getAuthQr();$t(t.qrCodes)}catch{}finally{Mt(!1)}},disabled:He,className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${He?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-hover hover:bg-cc-active text-cc-fg cursor-pointer"}`,children:He?"Generating...":"Show QR Code"})]}),e.jsxs("div",{className:"pt-2",children:[e.jsx("button",{type:"button",onClick:async()=>{if(confirm("Regenerate auth token? All existing sessions on other devices will be signed out.")){Gt(!0);try{const t=await o.regenerateAuthToken();Dt(t.token),Ht(!0),$t(null)}catch{}finally{Gt(!1)}}},disabled:$e,className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${$e?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-error/10 hover:bg-cc-error/20 text-cc-error cursor-pointer"}`,children:$e?"Regenerating...":"Regenerate Token"}),e.jsx("p",{className:"mt-1.5 text-xs text-cc-muted",children:"Creates a new token. All other signed-in devices will need to re-authenticate."})]})]})]}),e.jsxs("section",{id:"notifications",ref:E("notifications"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Notifications"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",onClick:G,className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Sound"}),e.jsx("span",{className:"text-xs text-cc-muted",children:ae?"On":"Off"})]}),P&&e.jsxs("button",{type:"button",onClick:async()=>{if(L)Q(!1);else{if(Notification.permission!=="granted"&&await Notification.requestPermission()!=="granted")return;Q(!0)}},className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Desktop Alerts"}),e.jsx("span",{className:"text-xs text-cc-muted",children:L?"On":"Off"})]}),e.jsx(As,{})]})]}),e.jsxs("section",{id:"providers",ref:E("providers"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Providers"}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("p",{className:"text-xs text-cc-muted",children:["Connect AI backends to power your agent sessions. Configure CLI backends (Claude Code, Codex) and additional model providers for Claude Code's ",e.jsx("code",{className:"font-mono-code bg-cc-code-bg px-1 py-0.5 rounded text-cc-code-fg",children:"--provider"})," flag."]}),e.jsxs("div",{className:"space-y-3 p-4 bg-cc-bg rounded-lg border border-cc-border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-cc-fg",children:"Claude Code"}),(g==null?void 0:g.cliVersion)&&e.jsx("p",{className:"text-xs text-cc-muted mt-0.5",children:g.cliVersion})]}),g!=null&&g.authenticated||ie?e.jsx("span",{className:"px-2 py-0.5 text-xs rounded-full bg-cc-success/15 text-cc-success border border-cc-success/20",children:"Authenticated"}):e.jsx("span",{className:"px-2 py-0.5 text-xs rounded-full bg-cc-error/15 text-cc-error border border-cc-error/20",children:"Not configured"})]}),(g==null?void 0:g.authenticated)&&e.jsxs("div",{className:"px-3 py-2 rounded-lg bg-cc-success/5 border border-cc-success/10 text-xs text-cc-muted",children:[g.method==="cli_login"&&e.jsxs(e.Fragment,{children:["Authenticated via ",e.jsx("strong",{className:"text-cc-fg",children:"CLI login"}),". Sessions authenticate automatically."]}),g.method==="env_api_key"&&e.jsxs(e.Fragment,{children:["Authenticated via ",e.jsx("strong",{className:"text-cc-fg",children:"ANTHROPIC_API_KEY"})," env var."]}),g.method==="env_oauth"&&e.jsxs(e.Fragment,{children:["Authenticated via ",e.jsx("strong",{className:"text-cc-fg",children:"CLAUDE_CODE_OAUTH_TOKEN"})," env var."]}),g.method==="env_auth_token"&&e.jsxs(e.Fragment,{children:["Authenticated via ",e.jsx("strong",{className:"text-cc-fg",children:"ANTHROPIC_AUTH_TOKEN"})," env var."]})]}),!(g!=null&&g.authenticated)&&!ie&&e.jsxs("div",{className:"px-3 py-2.5 rounded-lg bg-cc-primary/5 border border-cc-primary/15 text-xs text-cc-muted space-y-1.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"CLI Login:"})," Run ",e.jsx("code",{className:"font-mono-code bg-cc-code-bg px-1 py-0.5 rounded text-cc-code-fg",children:"claude login"})," on the server."]}),e.jsxs("p",{children:[e.jsx("strong",{children:"OAuth Token:"})," Paste a token from ",e.jsx("code",{className:"font-mono-code bg-cc-code-bg px-1 py-0.5 rounded text-cc-code-fg",children:"claude setup-token"})," below."]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{className:"block text-xs text-cc-muted",htmlFor:"claude-code-token",children:["OAuth Token ",g!=null&&g.authenticated?"(optional)":""]}),e.jsx("input",{id:"claude-code-token",type:"password",value:ie&&!zt&&!z?"••••••••••••••••":z,onChange:t=>tt(t.target.value),onFocus:()=>it(!0),onBlur:()=>it(!1),placeholder:ie?"Enter a new token to replace":"Paste token from claude setup-token",className:"w-full px-3 py-2 text-sm bg-cc-input-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"})]})]}),e.jsxs("div",{className:"space-y-3 p-4 bg-cc-bg rounded-lg border border-cc-border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-cc-fg",children:"OpenAI Codex"}),(j==null?void 0:j.cliVersion)&&e.jsx("p",{className:"text-xs text-cc-muted mt-0.5",children:j.cliVersion})]}),j!=null&&j.authenticated||le?e.jsx("span",{className:"px-2 py-0.5 text-xs rounded-full bg-cc-success/15 text-cc-success border border-cc-success/20",children:"Authenticated"}):e.jsx("span",{className:"px-2 py-0.5 text-xs rounded-full bg-cc-error/15 text-cc-error border border-cc-error/20",children:"Not configured"})]}),(j==null?void 0:j.authenticated)&&e.jsxs("div",{className:"px-3 py-2 rounded-lg bg-cc-success/5 border border-cc-success/10 text-xs text-cc-muted",children:[j.method==="cli_login"&&e.jsxs(e.Fragment,{children:["Authenticated via ",e.jsx("strong",{className:"text-cc-fg",children:"device login"}),"."]}),j.method==="env_api_key"&&e.jsxs(e.Fragment,{children:["Authenticated via ",e.jsx("strong",{className:"text-cc-fg",children:"OPENAI_API_KEY"})," env var."]})]}),!(j!=null&&j.authenticated)&&!le&&e.jsxs("div",{className:"px-3 py-2.5 rounded-lg bg-cc-primary/5 border border-cc-primary/15 text-xs text-cc-muted space-y-1.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Device Login:"})," Run ",e.jsx("code",{className:"font-mono-code bg-cc-code-bg px-1 py-0.5 rounded text-cc-code-fg",children:"codex --login"})," on the server."]}),e.jsxs("p",{children:[e.jsx("strong",{children:"API Key:"})," Enter your key below from ",e.jsx("a",{href:"https://platform.openai.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:"text-cc-primary hover:underline",children:"platform.openai.com"}),"."]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{className:"block text-xs text-cc-muted",htmlFor:"openai-api-key",children:["API Key ",j!=null&&j.authenticated?"(optional)":""]}),e.jsx("input",{id:"openai-api-key",type:"password",value:le&&!Yt&&!Y?"••••••••••••••••":Y,onChange:t=>ct(t.target.value),onFocus:()=>lt(!0),onBlur:()=>lt(!1),placeholder:le?"Enter a new key to replace":"sk-...",className:"w-full px-3 py-2 text-sm bg-cc-input-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"})]})]}),nt&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:nt}),Wt&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-success/10 border border-cc-success/20 text-xs text-cc-success",children:"Provider settings saved."}),e.jsx("button",{type:"button",disabled:Ne||!z.trim()&&!Y.trim(),onClick:async()=>{rt(!0),ot(""),ke(!1);try{const t={};z.trim()&&(t.claudeCodeOAuthToken=z.trim()),Y.trim()&&(t.openaiApiKey=Y.trim());const c=await o.updateSettings(t);st(c.claudeCodeOAuthTokenConfigured),at(c.openaiApiKeyConfigured),c.claudeCliAuth&&dt(c.claudeCliAuth),c.codexCliAuth&&ut(c.codexCliAuth),tt(""),ct(""),ke(!0),setTimeout(()=>ke(!1),1800)}catch(t){ot(t instanceof Error?t.message:String(t))}finally{rt(!1)}},className:`px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${Ne||!z.trim()&&!Y.trim()?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary-btn hover:bg-cc-primary-btn-hover text-white cursor-pointer"}`,children:Ne?"Saving...":"Save CLI Backend Settings"}),e.jsxs("details",{className:"border-t border-cc-border pt-4 group",children:[e.jsxs("summary",{className:"flex items-center justify-between cursor-pointer list-none",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-cc-fg",children:"Additional Providers"}),e.jsxs("p",{className:"text-xs text-cc-muted mt-0.5",children:["Configure model providers for Claude Code's ",e.jsx("code",{className:"font-mono-code bg-cc-code-bg px-1 py-0.5 rounded text-cc-code-fg text-[10px]",children:"--provider"})," flag."]})]}),e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4 text-cc-muted transition-transform group-open:rotate-180",children:e.jsx("path",{fillRule:"evenodd",d:"M4.22 6.22a.75.75 0 0 1 1.06 0L8 8.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L4.22 7.28a.75.75 0 0 1 0-1.06Z"})})]}),e.jsx("div",{className:"mt-4",children:e.jsx(Ss,{})})]})]})]}),e.jsxs("section",{id:"gemini",ref:E("gemini"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Gemini"}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("p",{className:"text-xs text-cc-muted",children:["Configure Gemini Live for voice chat. Get an API key from"," ",e.jsx("a",{href:"https://aistudio.google.com/apikey",target:"_blank",rel:"noopener noreferrer",className:"text-cc-primary hover:underline",children:"Google AI Studio"}),"."]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"gemini-api-key",children:"Gemini API Key"}),e.jsx("input",{id:"gemini-api-key",type:"password",value:we&&!Zt&&!te?"••••••••••••••••":te,onChange:t=>mt(t.target.value),onFocus:()=>ft(!0),onBlur:()=>ft(!1),placeholder:we?"Enter a new key to replace":"AIza...",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"}),e.jsx("p",{className:"text-xs text-cc-muted",children:we?"Gemini API key configured":"Gemini API key not configured"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"assistant-name",children:"Assistant Name"}),e.jsx("input",{id:"assistant-name",type:"text",value:Ae,onChange:t=>Ee(t.target.value),placeholder:"e.g. Jarvis, Friday, Max",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"}),e.jsx("p",{className:"text-xs text-cc-muted",children:"Give your voice assistant a custom name. Leave empty for default."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"user-name",children:"Your Name"}),e.jsx("input",{id:"user-name",type:"text",value:Pe,onChange:t=>Ue(t.target.value),placeholder:"e.g. Markus",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"}),e.jsx("p",{className:"text-xs text-cc-muted",children:"Your name so Gemini knows who it's talking to."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"gemini-voice",children:"Voice"}),e.jsxs("select",{id:"gemini-voice",value:Se,onChange:t=>Ce(t.target.value),className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow",children:[e.jsx("option",{value:"Kore",children:"Kore (female, firm)"}),e.jsx("option",{value:"Puck",children:"Puck (male, playful)"}),e.jsx("option",{value:"Charon",children:"Charon (male, deep)"}),e.jsx("option",{value:"Fenrir",children:"Fenrir (male, bold)"}),e.jsx("option",{value:"Aoede",children:"Aoede (female, bright)"}),e.jsx("option",{value:"Leda",children:"Leda (female, gentle)"}),e.jsx("option",{value:"Orus",children:"Orus (male, clear)"}),e.jsx("option",{value:"Zephyr",children:"Zephyr (neutral, calm)"})]})]}),vt&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:vt}),Xt&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-success/10 border border-cc-success/20 text-xs text-cc-success",children:"Gemini settings saved."}),e.jsx("button",{type:"button",disabled:Te||!te.trim()&&Se===qt&&Ae===Qt&&Pe===Jt,onClick:async()=>{bt(!0),yt(""),Ie(!1);try{const t={};te.trim()&&(t.geminiApiKey=te.trim()),t.assistantName=Ae,t.userName=Pe,t.geminiVoice=Se;const c=await o.updateSettings(t);xt(c.geminiApiKeyConfigured),c.geminiVoice&&(Ce(c.geminiVoice),pt(c.geminiVoice)),typeof c.assistantName=="string"&&(Ee(c.assistantName),ht(c.assistantName)),typeof c.userName=="string"&&(Ue(c.userName),gt(c.userName)),mt(""),Ie(!0),setTimeout(()=>Ie(!1),1800)}catch(t){yt(t instanceof Error?t.message:String(t))}finally{bt(!1)}},className:`px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${Te?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary-btn hover:bg-cc-primary-btn-hover text-white cursor-pointer"}`,children:Te?"Saving...":"Save Gemini Settings"})]})]}),e.jsxs("section",{id:"email",ref:E("email"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Email Accounts"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-cc-muted",children:"Configure IMAP/SMTP email accounts for the voice assistant. Gemini can read, search, and send emails on your behalf."}),ts?e.jsx("p",{className:"text-xs text-cc-muted",children:"Loading accounts..."}):jt.length===0?e.jsx("p",{className:"text-xs text-cc-muted",children:"No email accounts configured."}):e.jsx("div",{className:"space-y-2",children:jt.map(t=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5 bg-cc-bg rounded-lg",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-cc-fg truncate",children:t.name}),e.jsx("div",{className:"text-xs text-cc-muted truncate",children:t.email}),e.jsxs("div",{className:"text-xs text-cc-muted",children:["IMAP: ",t.imap.host,":",t.imap.port," | SMTP: ",t.smtp.host,":",t.smtp.port]}),(se==null?void 0:se.id)===t.id&&e.jsx("div",{className:`text-xs mt-1 ${se.ok?"text-cc-success":"text-cc-error"}`,children:se.message})]}),e.jsxs("div",{className:"flex gap-1.5 ml-2 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>ls(t.id),disabled:At===t.id,className:"px-2 py-1 text-xs rounded bg-cc-hover text-cc-fg hover:bg-cc-border transition-colors",children:At===t.id?"...":"Test"}),e.jsx("button",{type:"button",onClick:()=>ds(t),className:"px-2 py-1 text-xs rounded bg-cc-hover text-cc-fg hover:bg-cc-border transition-colors",children:"Edit"}),e.jsx("button",{type:"button",onClick:()=>is(t.id),className:"px-2 py-1 text-xs rounded bg-cc-error/10 text-cc-error hover:bg-cc-error/20 transition-colors",children:"Delete"})]})]},t.id))}),ss?e.jsxs("div",{className:"space-y-3 p-4 bg-cc-bg rounded-lg border border-cc-border",children:[e.jsx("h3",{className:"text-sm font-medium text-cc-fg",children:V?`Edit: ${V.name}`:"Add Email Account"}),!V&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-cc-muted font-medium",children:"Quick presets:"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:[{label:"Gmail",imap:"imap.gmail.com",smtp:"smtp.gmail.com",imapPort:"993",smtpPort:"465",info:`1. Go to myaccount.google.com
|
|
2
|
-
2. Security → 2-Step Verification (must be ON)
|
|
3
|
-
3. Search for "App passwords" or go to myaccount.google.com/apppasswords
|
|
4
|
-
4. Create a new App Password (name: e.g. "Email Agent")
|
|
5
|
-
5. Copy the 16-character password
|
|
6
|
-
6. Use your Gmail address as both Email and Username
|
|
7
|
-
|
|
8
|
-
Note: If "App passwords" is not available, 2-Step Verification is not enabled yet.`},{label:"Outlook",imap:"outlook.office365.com",smtp:"smtp.office365.com",imapPort:"993",smtpPort:"587",smtpSecure:!1,info:`1. Go to account.microsoft.com
|
|
9
|
-
2. Security → Advanced security options
|
|
10
|
-
3. Enable 2-Step Verification if not active
|
|
11
|
-
4. App passwords → Create a new app password
|
|
12
|
-
5. Copy the generated password
|
|
13
|
-
6. Use your Outlook/Hotmail email as both Email and Username
|
|
14
|
-
|
|
15
|
-
Note: SMTP uses port 587 with STARTTLS (not SSL). For work/school accounts, ask your admin about IMAP access.`},{label:"Hostinger",imap:"imap.hostinger.com",smtp:"smtp.hostinger.com",imapPort:"993",smtpPort:"465",info:`1. Use the email address you created in Hostinger
|
|
16
|
-
2. Use the same password you set for the email account
|
|
17
|
-
3. IMAP: imap.hostinger.com (Port 993, SSL)
|
|
18
|
-
4. SMTP: smtp.hostinger.com (Port 465, SSL)
|
|
19
|
-
|
|
20
|
-
No App Password needed — use your regular email password.`},{label:"World4You",imap:"imap.world4you.com",smtp:"smtp.world4you.com",imapPort:"993",smtpPort:"465",info:`1. Use your World4You email address
|
|
21
|
-
2. Use the password from your World4You control panel
|
|
22
|
-
3. IMAP: imap.world4you.com (Port 993, SSL)
|
|
23
|
-
4. SMTP: smtp.world4you.com (Port 465, SSL)
|
|
24
|
-
|
|
25
|
-
No App Password needed — use your regular email password.`}].map(t=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>U(c=>({...c,imapHost:t.imap,smtpHost:t.smtp,imapPort:t.imapPort,smtpPort:t.smtpPort,imapSecure:!0,smtpSecure:t.smtpSecure!==!1})),className:"px-2 py-1 text-xs rounded bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer border border-cc-border",children:t.label}),e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"w-4 h-4 flex items-center justify-center rounded-full bg-cc-hover text-cc-muted text-[10px] font-bold cursor-help border border-cc-border group-hover:bg-cc-primary group-hover:text-white group-hover:border-cc-primary transition-colors",children:"i"}),e.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 w-72 p-3 rounded-lg bg-cc-card border border-cc-border shadow-lg text-xs text-cc-fg whitespace-pre-line opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity z-50",children:[e.jsxs("div",{className:"font-semibold mb-1.5 text-cc-primary",children:[t.label," Setup"]}),t.info,e.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 -mt-px w-2 h-2 bg-cc-card border-r border-b border-cc-border rotate-45"})]})]})]},t.label))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-cc-muted mb-1",children:"Display Name"}),e.jsx("input",{type:"text",value:f.name,onChange:t=>U(c=>({...c,name:t.target.value})),placeholder:"e.g. Gmail, Work, Personal",className:"w-full px-3 py-2 text-sm bg-cc-input-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-cc-muted mb-1",children:"Email Address"}),e.jsx("input",{type:"email",value:f.email,onChange:t=>U(c=>({...c,email:t.target.value})),placeholder:"user@example.com",className:"w-full px-3 py-2 text-sm bg-cc-input-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-cc-muted mb-1 font-medium",children:"IMAP (Incoming)"}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx("input",{type:"text",value:f.imapHost,onChange:t=>U(c=>({...c,imapHost:t.target.value})),placeholder:"imap.example.com",className:"col-span-2 px-3 py-2 text-sm bg-cc-input-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40"}),e.jsx("div",{className:"flex gap-2",children:e.jsx("input",{type:"text",value:f.imapPort,onChange:t=>U(c=>({...c,imapPort:t.target.value})),placeholder:"993",className:"w-full px-3 py-2 text-sm bg-cc-input-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40"})})]}),e.jsxs("label",{className:"flex items-center gap-2 mt-1.5 text-xs text-cc-muted cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:f.imapSecure,onChange:t=>U(c=>({...c,imapSecure:t.target.checked})),className:"rounded"}),"SSL/TLS"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-cc-muted mb-1 font-medium",children:"SMTP (Outgoing)"}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx("input",{type:"text",value:f.smtpHost,onChange:t=>U(c=>({...c,smtpHost:t.target.value})),placeholder:"smtp.example.com",className:"col-span-2 px-3 py-2 text-sm bg-cc-input-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40"}),e.jsx("input",{type:"text",value:f.smtpPort,onChange:t=>U(c=>({...c,smtpPort:t.target.value})),placeholder:"465",className:"w-full px-3 py-2 text-sm bg-cc-input-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40"})]}),e.jsxs("label",{className:"flex items-center gap-2 mt-1.5 text-xs text-cc-muted cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:f.smtpSecure,onChange:t=>U(c=>({...c,smtpSecure:t.target.checked})),className:"rounded"}),"SSL/TLS"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-cc-muted mb-1 font-medium",children:"Authentication"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("input",{type:"text",value:f.authUser,onChange:t=>U(c=>({...c,authUser:t.target.value})),placeholder:"Username / Email",className:"px-3 py-2 text-sm bg-cc-input-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40"}),e.jsx("input",{type:"password",value:f.authPass,onChange:t=>U(c=>({...c,authPass:t.target.value})),placeholder:V?"New password (leave empty to keep)":"Password / App Password",className:"px-3 py-2 text-sm bg-cc-input-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40"})]})]}),kt&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:kt}),wt&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-success/10 border border-cc-success/20 text-xs text-cc-success",children:wt}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:os,className:"px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-primary-btn hover:bg-cc-primary-btn-hover text-white transition-colors cursor-pointer",children:V?"Update Account":"Add Account"}),e.jsx("button",{type:"button",onClick:Ke,className:"px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-hover text-cc-fg hover:bg-cc-border transition-colors cursor-pointer",children:"Cancel"})]})]}):e.jsx("button",{type:"button",onClick:()=>{Ke(),Fe(!0)},className:"px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-primary-btn hover:bg-cc-primary-btn-hover text-white transition-colors cursor-pointer",children:"Add Email Account"})]})]}),e.jsxs("section",{id:"calendar",ref:E("calendar"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Calendar Accounts"}),e.jsx("p",{className:"text-xs text-cc-muted mb-4",children:"Connect CalDAV calendars (Google Calendar, iCloud, Outlook, Nextcloud, etc.) so your assistant can manage events."}),Tt&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error mb-2",children:Tt}),It&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-success/10 border border-cc-success/20 text-xs text-cc-success mb-2",children:It}),as?e.jsx("div",{className:"text-xs text-cc-muted",children:"Loading..."}):Pt.length>0?e.jsx("div",{className:"space-y-2 mb-4",children:Pt.map(t=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5 bg-cc-bg rounded-lg",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-cc-fg truncate",children:t.name}),e.jsxs("div",{className:"text-xs text-cc-muted truncate",children:[t.auth.user," (",t.provider,")"]}),(W==null?void 0:W.id)===t.id&&e.jsxs("div",{className:`text-xs mt-1 ${W.ok?"text-cc-success":"text-cc-error"}`,children:[W.message,W.calendars&&e.jsxs("span",{className:"text-cc-muted",children:[" — Calendars: ",W.calendars.join(", ")]})]})]}),e.jsxs("div",{className:"flex gap-1.5 ml-2 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>ps(t.id),disabled:Rt===t.id,className:"px-2 py-1 text-xs rounded bg-cc-hover text-cc-fg hover:bg-cc-border transition-colors",children:Rt===t.id?"...":"Test"}),e.jsx("button",{type:"button",onClick:()=>hs(t),className:"px-2 py-1 text-xs rounded bg-cc-hover text-cc-fg hover:bg-cc-border transition-colors",children:"Edit"}),e.jsx("button",{type:"button",onClick:()=>xs(t.id),className:"px-2 py-1 text-xs rounded bg-cc-error/10 text-cc-error hover:bg-cc-error/20 transition-colors",children:"Delete"})]})]},t.id))}):e.jsx("div",{className:"text-xs text-cc-muted mb-4",children:"No calendar accounts configured."}),!Ot&&e.jsx("button",{type:"button",onClick:()=>{Be(),Re(!0)},className:"px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-primary-btn hover:bg-cc-primary-btn-hover text-white transition-colors cursor-pointer",children:"Add Calendar Account"}),Ot&&e.jsxs("div",{className:"space-y-3 p-4 bg-cc-bg rounded-lg border border-cc-border",children:[e.jsx("h3",{className:"text-sm font-medium text-cc-fg",children:_?"Edit Calendar Account":"Add Calendar Account"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-cc-muted mb-1 font-medium",children:"Provider"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:[{id:"google",label:"Google",info:`1. Go to myaccount.google.com
|
|
26
|
-
2. Security → 2-Step Verification (must be ON)
|
|
27
|
-
3. Search for "App passwords" or go to myaccount.google.com/apppasswords
|
|
28
|
-
4. Create a new App Password (name: e.g. "Calendar")
|
|
29
|
-
5. Copy the 16-character password (format: xxxx xxxx xxxx xxxx)
|
|
30
|
-
6. Use your Gmail address as username and the App Password here`},{id:"icloud",label:"iCloud",info:`1. Go to appleid.apple.com and sign in
|
|
31
|
-
2. Sign-In and Security → App-Specific Passwords
|
|
32
|
-
3. Click "+" to generate a new password
|
|
33
|
-
4. Name it (e.g. "Calendar Agent")
|
|
34
|
-
5. Copy the generated password (format: xxxx-xxxx-xxxx-xxxx)
|
|
35
|
-
6. Use your Apple ID email as username and the App-Specific Password here
|
|
36
|
-
|
|
37
|
-
Note: 2-Factor Authentication must be enabled (default for iCloud)`},{id:"outlook",label:"Outlook",info:`1. Go to account.microsoft.com and sign in
|
|
38
|
-
2. Security → Advanced security options
|
|
39
|
-
3. App passwords → Create a new app password
|
|
40
|
-
4. Copy the generated password
|
|
41
|
-
5. Use your Outlook/Hotmail email as username
|
|
42
|
-
|
|
43
|
-
CalDAV URL: https://outlook.office365.com/caldav/
|
|
44
|
-
|
|
45
|
-
Note: App Passwords require 2-Step Verification to be enabled. For work/school accounts, your admin may need to enable CalDAV access.`},{id:"caldav",label:"CalDAV",info:`For Nextcloud:
|
|
46
|
-
URL: https://your-server.com/remote.php/dav/
|
|
47
|
-
|
|
48
|
-
For Synology:
|
|
49
|
-
URL: https://your-nas:5001/caldav/
|
|
50
|
-
|
|
51
|
-
For other servers, check your provider's CalDAV documentation for the correct URL.`}].map(t=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>us(t.id),className:`px-2 py-1 text-xs rounded border transition-colors cursor-pointer ${k.provider===t.id?"bg-cc-primary-btn text-white border-cc-primary-btn":"bg-cc-hover text-cc-fg border-cc-border hover:bg-cc-active"}`,children:t.label}),e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"w-4 h-4 flex items-center justify-center rounded-full bg-cc-hover text-cc-muted text-[10px] font-bold cursor-help border border-cc-border group-hover:bg-cc-primary group-hover:text-white group-hover:border-cc-primary transition-colors",children:"i"}),e.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 w-72 p-3 rounded-lg bg-cc-card border border-cc-border shadow-lg text-xs text-cc-fg whitespace-pre-line opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity z-50",children:[e.jsxs("div",{className:"font-semibold mb-1.5 text-cc-primary",children:[t.label," Setup"]}),t.info,e.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 -mt-px w-2 h-2 bg-cc-card border-r border-b border-cc-border rotate-45"})]})]})]},t.id))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-cc-muted mb-1",children:"Display Name"}),e.jsx("input",{type:"text",value:k.name,onChange:t=>B(c=>({...c,name:t.target.value})),placeholder:"e.g. Google, iCloud, Work",className:"w-full px-3 py-2 text-sm bg-cc-input-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40"})]}),(k.provider==="caldav"||k.provider==="outlook")&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-cc-muted mb-1",children:"Server URL"}),e.jsx("input",{type:"text",value:k.serverUrl,onChange:t=>B(c=>({...c,serverUrl:t.target.value})),placeholder:k.provider==="outlook"?"https://outlook.office365.com/caldav/":"https://cloud.example.com/remote.php/dav/",className:"w-full px-3 py-2 text-sm bg-cc-input-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-cc-muted mb-1",children:"Username / Email"}),e.jsx("input",{type:"text",value:k.authUser,onChange:t=>B(c=>({...c,authUser:t.target.value})),placeholder:k.provider==="google"?"you@gmail.com":k.provider==="icloud"?"you@icloud.com":k.provider==="outlook"?"you@outlook.com":"username",className:"w-full px-3 py-2 text-sm bg-cc-input-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-cc-muted mb-1",children:"Password / App Password"}),e.jsx("input",{type:"password",value:k.authPass,onChange:t=>B(c=>({...c,authPass:t.target.value})),placeholder:_?"New password (leave empty to keep)":"App Password",className:"w-full px-3 py-2 text-sm bg-cc-input-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:ms,className:"px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-primary-btn hover:bg-cc-primary-btn-hover text-white transition-colors cursor-pointer",children:_?"Update Account":"Add Account"}),e.jsx("button",{type:"button",onClick:Be,className:"px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-hover text-cc-fg hover:bg-cc-border transition-colors cursor-pointer",children:"Cancel"})]})]})]}),e.jsxs("section",{id:"ai-features",ref:E("ai-features"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"HeyHank AI Features"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-cc-muted leading-relaxed",children:"These features use any enabled provider configured under Providers → Additional Providers above."}),e.jsxs("div",{className:"px-3 py-2.5 rounded-lg bg-cc-hover/50 border border-cc-border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-cc-fg",children:"Auto-Rename Sessions"}),e.jsx("span",{className:`text-xs font-medium ${S?"text-cc-success":"text-cc-muted"}`,children:S?"Active":"No provider"})]}),e.jsx("p",{className:"text-[11px] text-cc-muted mt-1",children:"Automatically generates a short title for new sessions based on the first message."})]}),e.jsxs("div",{className:"space-y-3 p-3 bg-cc-bg rounded-lg border border-cc-border",children:[e.jsx("h3",{className:"text-xs font-medium text-cc-fg",children:"AI Validation"}),e.jsx("p",{className:"text-[11px] text-cc-muted leading-relaxed",children:"An AI model evaluates tool calls before execution. Safe ops are auto-approved, dangerous ones blocked. Uses any configured provider. Per-session overrides via the shield icon."}),e.jsxs("button",{type:"button",onClick:()=>We("aiValidationEnabled"),className:"w-full flex items-center justify-between px-3 py-2.5 rounded-lg bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer",children:[e.jsx("span",{className:"text-sm",children:"AI Validation"}),e.jsx("span",{className:`text-xs font-medium ${oe?"text-cc-success":"text-cc-muted"}`,children:oe?"On":"Off"})]}),oe&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>We("aiValidationAutoApprove"),className:"w-full flex items-center justify-between px-3 py-2.5 rounded-lg bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm",children:"Auto-approve safe tools"}),e.jsx("p",{className:"text-[11px] text-cc-muted mt-0.5",children:"Allow read-only tools automatically"})]}),e.jsx("span",{className:`text-xs font-medium ${fe?"text-cc-success":"text-cc-muted"}`,children:fe?"On":"Off"})]}),e.jsxs("button",{type:"button",onClick:()=>We("aiValidationAutoDeny"),className:"w-full flex items-center justify-between px-3 py-2.5 rounded-lg bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm",children:"Auto-deny dangerous tools"}),e.jsx("p",{className:"text-[11px] text-cc-muted mt-0.5",children:"Block destructive commands like rm -rf"})]}),e.jsx("span",{className:`text-xs font-medium ${ve?"text-cc-success":"text-cc-muted"}`,children:ve?"On":"Off"})]})]})]})]})]}),e.jsxs("section",{id:"updates",ref:E("updates"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Updates"}),e.jsxs("div",{className:"space-y-3",children:[C?e.jsxs("p",{className:"text-xs text-cc-muted",children:["Current version: v",C.currentVersion,C.latestVersion?` • Latest: v${C.latestVersion}`:"",C.channel==="prerelease"?" (prerelease)":""]}):e.jsx("p",{className:"text-xs text-cc-muted",children:"Version information not loaded yet."}),e.jsxs("div",{children:[e.jsx("span",{id:"update-channel-label",className:"block text-sm font-medium mb-1.5",children:"Update Channel"}),e.jsxs("div",{className:"flex gap-1",role:"radiogroup","aria-labelledby":"update-channel-label",children:[e.jsx("button",{type:"button",role:"radio","aria-checked":$==="stable",onClick:async()=>{if($!=="stable"){Z("stable");try{await o.updateSettings({updateChannel:"stable"})}catch{Z("prerelease");return}try{const t=await o.forceCheckForUpdate();J(t)}catch{}}},className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer ${$==="stable"?"bg-cc-primary text-white":"bg-cc-hover text-cc-muted hover:text-cc-fg hover:bg-cc-active"}`,children:"Stable"}),e.jsx("button",{type:"button",role:"radio","aria-checked":$==="prerelease",onClick:async()=>{if($!=="prerelease"){Z("prerelease");try{await o.updateSettings({updateChannel:"prerelease"})}catch{Z("stable");return}try{const t=await o.forceCheckForUpdate();J(t)}catch{}}},className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer ${$==="prerelease"?"bg-cc-primary text-white":"bg-cc-hover text-cc-muted hover:text-cc-fg hover:bg-cc-active"}`,children:"Prerelease"})]}),e.jsx("p",{className:"mt-1.5 text-xs text-cc-muted",children:$==="prerelease"?"Tracking prerelease channel. You will receive preview builds from the latest main branch.":"Tracking stable channel. You will only receive versioned releases."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"block text-sm font-medium",children:"Auto-update Docker image"}),e.jsx("p",{className:"mt-0.5 text-xs text-cc-muted",children:"Automatically re-pull the sandbox Docker image when updating HeyHank"})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":re,onClick:async()=>{const t=!re;xe(t);try{await o.updateSettings({dockerAutoUpdate:t})}catch{xe(!t)}},className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ${re?"bg-cc-primary":"bg-cc-hover"}`,children:e.jsx("span",{className:`pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform transition-transform ${re?"translate-x-5":"translate-x-0"}`})})]}),Ze&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:Ze}),Je&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-success/10 border border-cc-success/20 text-xs text-cc-success",children:Je}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:gs,disabled:pe,className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${pe?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-hover hover:bg-cc-active text-cc-fg cursor-pointer"}`,children:pe?"Checking...":"Check for updates"}),C!=null&&C.isServiceMode?e.jsx("button",{type:"button",onClick:fs,disabled:he||C.updateInProgress||!C.updateAvailable,className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${he||C.updateInProgress||!C.updateAvailable?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary-btn hover:bg-cc-primary-btn-hover text-white cursor-pointer"}`,children:he||C.updateInProgress?"Updating...":"Update & Restart"}):e.jsxs("p",{className:"text-xs text-cc-muted self-center",children:["Install service mode with ",e.jsx("code",{className:"font-mono-code bg-cc-code-bg px-1 py-0.5 rounded text-cc-code-fg",children:"heyhank install"})," to enable one-click updates."]})]})]})]}),e.jsxs("section",{id:"appearance",ref:E("appearance"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Appearance"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-cc-fg font-medium block mb-2",children:"Theme"}),e.jsx("div",{className:"flex items-center gap-2",children:["light","dark","system"].map(t=>{const c=t==="system"?localStorage.getItem("cc-dark-mode")===null:t==="dark"?n&&localStorage.getItem("cc-dark-mode")!==null:!n&&localStorage.getItem("cc-dark-mode")!==null;return e.jsxs("button",{type:"button",onClick:()=>{if(t==="system"){localStorage.removeItem("cc-dark-mode");const l=window.matchMedia("(prefers-color-scheme: dark)").matches;b.getState().setDarkMode(l),localStorage.removeItem("cc-dark-mode")}else b.getState().setDarkMode(t==="dark")},className:`flex items-center gap-2 px-3 py-2 min-h-[44px] rounded-lg text-xs font-medium transition-colors cursor-pointer ${c?"bg-cc-primary/15 text-cc-primary border border-cc-primary/30":"bg-cc-hover text-cc-muted border border-transparent hover:text-cc-fg"}`,children:[t==="light"&&e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"5"}),e.jsx("path",{d:"M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"})]}),t==="dark"&&e.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"})}),t==="system"&&e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]}),t.charAt(0).toUpperCase()+t.slice(1)]},t)})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-cc-fg font-medium block mb-2",children:"Font Size"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{id:"font-size-slider",type:"range",min:"12",max:"20",step:"1",value:parseInt(localStorage.getItem("cc-font-size")||"14",10),onChange:t=>{const c=t.target.value;localStorage.setItem("cc-font-size",c),document.documentElement.style.fontSize=`${c}px`},className:"flex-1 accent-cc-primary cursor-pointer"}),e.jsxs("span",{className:"text-xs text-cc-muted tabular-nums w-8 text-right",children:[localStorage.getItem("cc-font-size")||"14","px"]})]}),e.jsx("button",{type:"button",onClick:()=>{localStorage.removeItem("cc-font-size"),document.documentElement.style.fontSize="",window.dispatchEvent(new Event("storage"))},className:"text-xs text-cc-muted hover:text-cc-fg transition-colors cursor-pointer mt-1",children:"Reset to default"})]})]})]}),e.jsxs("section",{id:"environments",ref:E("environments"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Environments"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-cc-muted",children:"Manage reusable environment profiles used when creating sessions."}),e.jsx("button",{type:"button",onClick:()=>{window.location.hash="#/environments"},className:"px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-primary-btn hover:bg-cc-primary-btn-hover text-white transition-colors cursor-pointer",children:"Open Environments Page"})]})]}),e.jsxs("section",{id:"federation",ref:E("federation"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Federation"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-cc-muted",children:"Connect multiple HeyHank instances into a peer-to-peer mesh."}),e.jsx(Ns,{})]})]}),e.jsxs("section",{id:"backup",ref:E("backup"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Export & Backup"}),e.jsx(Ps,{})]})]})})]})]})}function Es(){const[a,p]=s.useState(null),[w,v]=s.useState(!0),[u,d]=s.useState(!1);s.useEffect(()=>{o.getTailscaleStatus().then(h=>p(h)).catch(()=>p(null)).finally(()=>v(!1))},[]);async function m(){d(!0);try{const h=await o.startTailscaleFunnel();p(h),h.funnelUrl&&!h.error&&b.getState().setPublicUrl(h.funnelUrl)}catch{}d(!1)}async function S(){d(!0);try{const h=await o.stopTailscaleFunnel();p(h);const N=b.getState().publicUrl;(!N||N===(a==null?void 0:a.funnelUrl))&&b.getState().setPublicUrl("")}catch{}d(!1)}return w?e.jsx("p",{className:"text-[11px] text-cc-muted",children:"Checking Tailscale..."}):!a||!a.installed?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-cc-muted"}),e.jsx("span",{className:"text-xs text-cc-muted",children:"Not installed"})]}),e.jsx("a",{href:"https://tailscale.com/download",target:"_blank",rel:"noopener noreferrer",className:"text-[11px] text-cc-primary hover:underline",children:"Install Tailscale"})]}):a.connected?a.funnelActive?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500"}),e.jsx("span",{className:"text-xs text-green-500 font-medium",children:"Funnel active"})]}),e.jsx("button",{onClick:S,disabled:u,className:"text-[11px] text-red-400 hover:text-red-300 transition-colors cursor-pointer disabled:opacity-50",children:u?"Stopping...":"Disable"})]}),e.jsx("p",{className:"text-[11px] text-cc-fg font-mono",children:a.funnelUrl}),e.jsx("p",{className:"text-[10px] text-cc-muted",children:"This URL was automatically set as your Public URL."})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500"}),e.jsxs("span",{className:"text-xs text-cc-muted",children:["Connected as ",a.dnsName]})]}),a.needsOperatorMode&&e.jsxs("div",{className:"rounded-lg bg-amber-500/10 border border-amber-500/20 px-3 py-2 space-y-1",children:[e.jsx("p",{className:"text-[11px] text-amber-500 font-medium",children:"Setup needed: operator mode"}),e.jsx("div",{className:"font-mono text-[11px] text-cc-fg",children:"sudo tailscale set --operator=$USER"})]}),e.jsx("button",{onClick:m,disabled:u,className:"px-3 py-1.5 rounded-lg text-xs font-medium bg-cc-primary text-white hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50",children:u?"Starting...":"Enable HTTPS via Funnel"}),a.error&&!a.needsOperatorMode&&e.jsx("p",{className:"text-[11px] text-red-400",children:a.error})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500"}),e.jsx("span",{className:"text-xs text-cc-muted",children:"Installed but not connected"})]}),e.jsx("div",{className:"rounded-lg bg-cc-bg border border-cc-border px-3 py-1.5 font-mono text-[11px] text-cc-fg",children:"sudo tailscale up"})]})}function Ps(){const[a,p]=s.useState(!1),[w,v]=s.useState(!1),[u,d]=s.useState(null),m=s.useRef(null);async function S(){p(!0);try{const N=await o.exportAll(),A=new Blob([JSON.stringify(N,null,2)],{type:"application/json"}),i=URL.createObjectURL(A),x=document.createElement("a");x.href=i,x.download=`heyhank-backup-${new Date().toISOString().slice(0,10)}.json`,x.click(),URL.revokeObjectURL(i)}catch{}p(!1)}async function h(N){var i;const A=(i=N.target.files)==null?void 0:i[0];if(A){v(!0),d(null);try{const x=await A.text(),T=JSON.parse(x),O=await o.importData({agents:T.agents,notes:T.notes,todos:T.todos}),D=Object.entries(O.imported).map(([R,n])=>`${n} ${R}`);d(`Imported: ${D.join(", ")||"nothing new"}`)}catch{d("Import failed — invalid file format")}v(!1),m.current&&(m.current.value="")}}return e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-cc-muted",children:"Export all agents, settings, notes, todos, and Gemini conversations as a JSON file. Import to restore on a new instance."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:S,disabled:a,className:"px-3 py-2 text-xs font-medium rounded-lg bg-cc-primary text-white hover:bg-cc-primary-hover transition-colors cursor-pointer disabled:opacity-50",children:a?"Exporting...":"Export Backup"}),e.jsxs("label",{className:"px-3 py-2 text-xs font-medium rounded-lg bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[w?"Importing...":"Import Backup",e.jsx("input",{ref:m,type:"file",accept:".json",onChange:h,className:"hidden"})]})]}),u&&e.jsx("p",{className:`text-xs ${u.startsWith("Import failed")?"text-cc-error":"text-cc-success"}`,children:u})]})}export{Ds as SettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as s,j as e,b as S}from"./index-CEqZnThB.js";const Q=["twitter","instagram","linkedin","facebook","tiktok","threads"],re=["January","February","March","April","May","June","July","August","September","October","November","December"],le=["Mo","Tu","We","Th","Fr","Sa","Su"],H={twitter:"𝕏",instagram:"📷",linkedin:"in",facebook:"f",tiktok:"♪",threads:"@"};function E(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":String(t)}function _(t){const a=Date.now()-new Date(t).getTime(),d=Math.floor(a/6e4);if(d<1)return"just now";if(d<60)return`${d}m ago`;const o=Math.floor(d/60);if(o<24)return`${o}h ago`;const b=Math.floor(o/24);return b<7?`${b}d ago`:new Date(t).toLocaleDateString()}function fe({embedded:t}){const[a,d]=s.useState("posts"),[o,b]=s.useState(""),[g,j]=s.useState(!1),[f,p]=s.useState(!1),[w,N]=s.useState(null),[u,c]=s.useState(0);function l(m,T=!1){b(m),j(T),setTimeout(()=>b(""),T?5e3:3e3)}function h(){c(m=>m+1)}function r(m){N(m||null),p(!0)}function x(){p(!1),N(null)}const y=[{id:"posts",label:"Queue"},{id:"drafts",label:"Drafts"},{id:"calendar",label:"Calendar"},{id:"analytics",label:"Analytics"},{id:"settings",label:"Settings"}];return e.jsx("div",{className:`h-full overflow-auto ${t?"":"p-4"}`,children:e.jsxs("div",{className:"max-w-4xl mx-auto p-4 md:p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Social Media"}),e.jsx("button",{onClick:()=>r(),className:"px-3 py-1.5 text-xs font-medium rounded-md bg-cc-accent text-white hover:bg-cc-accent/90 transition-colors",children:"+ New Post"})]}),e.jsx("div",{className:"flex gap-1 border-b border-cc-border pb-2",children:y.map(m=>e.jsx("button",{onClick:()=>d(m.id),className:`px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors ${a===m.id?"bg-cc-accent/10 text-cc-accent border-b-2 border-cc-accent":"text-cc-muted hover:text-cc-fg"}`,children:m.label},m.id))}),o&&e.jsx("div",{className:`text-xs px-3 py-2 rounded-md ${g?"bg-red-500/10 text-red-400 border border-red-500/20":"bg-green-500/10 text-green-400 border border-green-500/20"}`,children:o}),f&&e.jsx(ne,{post:w,onClose:x,onSuccess:m=>{x(),l(m),h()},showMessage:l}),a==="posts"&&e.jsx(ie,{refreshKey:u,showMessage:l,onEdit:r,onRefresh:h}),a==="drafts"&&e.jsx(de,{refreshKey:u,showMessage:l,onEdit:r,onRefresh:h}),a==="calendar"&&e.jsx(xe,{refreshKey:u,showMessage:l,onEdit:r,onRefresh:h}),a==="analytics"&&e.jsx(me,{showMessage:l}),a==="settings"&&e.jsx(ue,{showMessage:l})]})})}function ne({post:t,onClose:a,onSuccess:d,showMessage:o}){var q;const[b,g]=s.useState((t==null?void 0:t.text)||""),[j,f]=s.useState((t==null?void 0:t.platforms)||[]),[p,w]=s.useState((t==null?void 0:t.title)||""),[N,u]=s.useState((t==null?void 0:t.firstComment)||""),[c,l]=s.useState(((q=t==null?void 0:t.mediaUrls)==null?void 0:q.join(", "))||""),[h,r]=s.useState((t==null?void 0:t.videoUrl)||""),[x,y]=s.useState((t==null?void 0:t.thumbnailUrl)||""),[m,T]=s.useState((t==null?void 0:t.status)==="draft"?"draft":t!=null&&t.scheduledAt?"schedule":"now"),[F,M]=s.useState(t!=null&&t.scheduledAt?new Date(t.scheduledAt).toISOString().slice(0,16):""),[v,k]=s.useState(!1),[A,n]=s.useState(!!(t!=null&&t.firstComment||t!=null&&t.videoUrl||t!=null&&t.thumbnailUrl)),C=s.useRef(null),[$,L]=s.useState(!1),D=!!t,B=b.length,I=280;function R(i){f(P=>P.includes(i)?P.filter(U=>U!==i):[...P,i])}async function ee(i){const P=i.target.files;if(P!=null&&P.length){L(!0);try{const U=[];for(const z of Array.from(P)){const Y=new FileReader,ce=await new Promise(ae=>{Y.onload=()=>ae(Y.result.split(",")[1]),Y.readAsDataURL(z)}),se=await S.uploadMedia(ce,z.type,z.name);U.push(se.url)}const G=c.split(",").map(z=>z.trim()).filter(Boolean);l([...G,...U].join(", "))}catch(U){o(U instanceof Error?U.message:"Upload failed",!0)}finally{L(!1),i.target.value=""}}}async function te(){if(!b.trim()){o("Post text is required.",!0);return}if(!j.length){o("Select at least one platform.",!0);return}if(m==="schedule"&&!F){o("Select a date and time.",!0);return}k(!0);try{const i={text:b.trim(),platforms:j,scheduledAt:m==="schedule"?new Date(F).toISOString():null,mediaUrls:c.split(",").map(P=>P.trim()).filter(Boolean),title:p.trim()||void 0,firstComment:N.trim()||void 0,videoUrl:h.trim()||void 0,thumbnailUrl:x.trim()||void 0,isDraft:m==="draft",createdBy:"user"};D?(await S.updateSocialPost(t.id,i),d("Post updated!")):(await S.createSocialPost(i),d(m==="draft"?"Draft saved!":m==="schedule"?"Post scheduled!":"Post created!"))}catch(i){o(i instanceof Error?i.message:"Failed",!0)}finally{k(!1)}}const K=c.split(",").map(i=>i.trim()).filter(Boolean);return e.jsxs("div",{className:"border border-cc-accent/30 rounded-xl bg-cc-card shadow-lg shadow-cc-accent/5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-cc-border/50 bg-cc-bg/50",children:[e.jsx("span",{className:"text-xs font-medium text-cc-fg",children:D?"Edit Post":"New Post"}),e.jsx("button",{onClick:a,className:"text-cc-muted hover:text-cc-fg transition-colors text-sm leading-none",children:"×"})]}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-cc-muted uppercase tracking-wider block mb-1.5",children:"Channels"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Q.map(i=>e.jsxs("button",{onClick:()=>R(i),className:`flex items-center gap-1 px-2.5 py-1 rounded-full text-[11px] font-medium transition-all border ${j.includes(i)?"bg-cc-accent/15 text-cc-accent border-cc-accent/40":"bg-cc-bg text-cc-muted border-cc-border hover:border-cc-accent/30 hover:text-cc-fg"}`,children:[e.jsx("span",{className:"text-[10px]",children:H[i]}),i.charAt(0).toUpperCase()+i.slice(1)]},i))})]}),e.jsx("input",{value:p,onChange:i=>w(i.target.value),placeholder:"Title (optional)",className:"w-full bg-transparent text-sm font-medium text-cc-fg placeholder:text-cc-muted/50 focus:outline-none"}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{value:b,onChange:i=>g(i.target.value),rows:4,placeholder:"What would you like to share?",className:"w-full bg-cc-bg border border-cc-border rounded-lg p-3 text-sm text-cc-fg resize-y focus:outline-none focus:border-cc-accent/50 min-h-[100px]"}),j.includes("twitter")&&e.jsxs("div",{className:`absolute bottom-2 right-2 text-[10px] ${B>I?"text-red-400":"text-cc-muted"}`,children:[B,"/",I]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{var i;return(i=C.current)==null?void 0:i.click()},disabled:$,className:"flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-cc-muted hover:text-cc-fg border border-cc-border rounded-md hover:border-cc-accent/30 transition-colors disabled:opacity-50",children:$?"Uploading...":"📎 Add Media"}),e.jsx("input",{ref:C,type:"file",accept:"image/*,video/*",multiple:!0,onChange:ee,className:"hidden"}),K.length>0&&e.jsxs("span",{className:"text-[10px] text-cc-muted",children:[K.length," file(s)"]})]}),K.length>0&&e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1",children:K.map((i,P)=>e.jsxs("div",{className:"relative group shrink-0",children:[e.jsx("img",{src:i,alt:`Media ${P+1}`,className:"h-20 w-20 rounded-lg border border-cc-border/50 object-cover"}),e.jsx("button",{onClick:()=>{const U=K.filter((G,z)=>z!==P);l(U.join(", "))},className:"absolute -top-1 -right-1 w-4 h-4 bg-red-500 text-white rounded-full text-[9px] leading-none flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]},P))})]}),e.jsx("button",{onClick:()=>n(!A),className:"text-[10px] text-cc-muted hover:text-cc-fg transition-colors",children:A?"▾ Less options":"▸ More options (first comment, video, thumbnail)"}),A&&e.jsxs("div",{className:"space-y-2 pl-2 border-l-2 border-cc-border/30",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-cc-muted block mb-1",children:"First Comment (Instagram, LinkedIn)"}),e.jsx("textarea",{value:N,onChange:i=>u(i.target.value),rows:2,placeholder:"Hashtags, links, additional context...",className:"w-full bg-cc-bg border border-cc-border rounded-md p-2 text-xs text-cc-fg resize-y focus:outline-none focus:border-cc-accent/50"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-cc-muted block mb-1",children:"Video URL"}),e.jsx("input",{value:h,onChange:i=>r(i.target.value),placeholder:"https://...",className:"w-full bg-cc-bg border border-cc-border rounded-md p-2 text-xs text-cc-fg focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-cc-muted block mb-1",children:"Thumbnail URL"}),e.jsx("input",{value:x,onChange:i=>y(i.target.value),placeholder:"https://...",className:"w-full bg-cc-bg border border-cc-border rounded-md p-2 text-xs text-cc-fg focus:outline-none"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-cc-muted uppercase tracking-wider block mb-1.5",children:"When to post"}),e.jsx("div",{className:"flex gap-1.5",children:[{id:"now",label:"Post Now"},{id:"schedule",label:"Schedule"},{id:"draft",label:"Save as Draft"}].map(i=>e.jsx("button",{onClick:()=>T(i.id),className:`px-3 py-1.5 text-[11px] font-medium rounded-md transition-all border ${m===i.id?"bg-cc-accent/15 text-cc-accent border-cc-accent/40":"bg-cc-bg text-cc-muted border-cc-border hover:border-cc-accent/30"}`,children:i.label},i.id))})]}),m==="schedule"&&e.jsx("input",{type:"datetime-local",value:F,onChange:i=>M(i.target.value),className:"w-full bg-cc-bg border border-cc-border rounded-md p-2 text-xs text-cc-fg focus:outline-none focus:border-cc-accent/50"}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("button",{onClick:te,disabled:v,className:"px-4 py-2 text-xs font-medium rounded-md bg-cc-accent text-white hover:bg-cc-accent/90 disabled:opacity-50 transition-colors",children:v?"Saving...":m==="now"?D?"Update & Post":"Post Now":m==="schedule"?D?"Update & Schedule":"Schedule":D?"Update Draft":"Save Draft"}),e.jsx("button",{onClick:a,className:"px-3 py-2 text-xs text-cc-muted hover:text-cc-fg transition-colors",children:"Cancel"})]})]})]})}function ie({refreshKey:t,showMessage:a,onEdit:d,onRefresh:o}){const[b,g]=s.useState([]),[j,f]=s.useState("all"),[p,w]=s.useState(""),N=s.useCallback(async()=>{try{const l=await S.listSocialPosts({limit:50});g((l.posts||[]).filter(h=>h.status!=="draft"))}catch{}},[]);s.useEffect(()=>{N()},[N,t]);async function u(l){try{await S.deleteSocialPost(l),a("Post deleted."),N(),o()}catch(h){a(h instanceof Error?h.message:"Failed",!0)}}const c=b.filter(l=>!(j!=="all"&&l.status!==j||p&&!l.platforms.includes(p)));return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.jsx("div",{className:"flex gap-1",children:["all","published","scheduled","failed"].map(l=>e.jsx("button",{onClick:()=>f(l),className:`px-2 py-1 text-[10px] font-medium rounded-md transition-colors ${j===l?"bg-cc-accent/15 text-cc-accent":"text-cc-muted hover:text-cc-fg"}`,children:l==="all"?"All":l.charAt(0).toUpperCase()+l.slice(1)},l))}),e.jsxs("select",{value:p,onChange:l=>w(l.target.value),className:"bg-cc-bg border border-cc-border rounded-md px-2 py-1 text-[10px] text-cc-fg focus:outline-none",children:[e.jsx("option",{value:"",children:"All platforms"}),Q.map(l=>e.jsx("option",{value:l,children:l.charAt(0).toUpperCase()+l.slice(1)},l))]}),e.jsxs("span",{className:"text-[10px] text-cc-muted ml-auto",children:[c.length," post(s)"]})]}),c.length===0?e.jsx(X,{text:j==="all"?"No posts yet. Create your first post!":`No ${j} posts.`}):e.jsx("div",{className:"space-y-2",children:c.map(l=>e.jsx(W,{post:l,onEdit:d,onDelete:u,showMessage:a,onRefresh:()=>{N(),o()}},l.id))})]})}function de({refreshKey:t,showMessage:a,onEdit:d,onRefresh:o}){const[b,g]=s.useState([]),[j,f]=s.useState(null),p=s.useCallback(async()=>{try{const u=await S.listSocialPosts({limit:50,status:"draft"});g(u.posts||[])}catch{}},[]);s.useEffect(()=>{p()},[p,t]);async function w(u){f(u);try{await S.publishSocialPost(u),a("Post published!"),p(),o()}catch(c){a(c instanceof Error?c.message:"Failed to publish",!0)}finally{f(null)}}async function N(u){try{await S.deleteSocialPost(u),a("Draft deleted."),p(),o()}catch(c){a(c instanceof Error?c.message:"Failed",!0)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("span",{className:"text-[10px] text-cc-muted",children:[b.length," draft(s)"]})}),b.length===0?e.jsx(X,{text:"No drafts. Drafts created by you, Gemini, or agents will appear here."}):e.jsx("div",{className:"space-y-2",children:b.map(u=>e.jsx(W,{post:u,onEdit:d,onDelete:N,showMessage:a,onRefresh:()=>{p(),o()},onPublish:w,isPublishing:j===u.id},u.id))})]})}function W({post:t,onEdit:a,onDelete:d,showMessage:o,onRefresh:b,onPublish:g,isPublishing:j}){const[f,p]=s.useState(!1),[w,N]=s.useState([]),u=t.status==="draft",c=t.mediaUrls||[];async function l(){if(f){p(!1);return}try{const r=await S.getSocialPostComments(t.id);N(r.comments||[]),p(!0)}catch{p(!0)}}async function h(r,x){try{const y=await S.replySocialComment(t.id,r,x);if(y.ok){o("Reply sent.");const m=await S.getSocialPostComments(t.id);N(m.comments||[])}else o(y.error||"Failed",!0)}catch(y){o(y instanceof Error?y.message:"Failed",!0)}}return e.jsxs("div",{className:`border rounded-xl overflow-hidden bg-cc-card transition-colors ${u?"border-yellow-500/25":"border-cc-border/50"}`,children:[e.jsxs("div",{className:"p-3.5 space-y-2.5",children:[t.title&&e.jsx("h3",{className:"text-xs font-semibold text-cc-fg",children:t.title}),e.jsx("p",{className:"text-sm text-cc-fg whitespace-pre-wrap break-words leading-relaxed",children:t.text}),(t.thumbnailUrl||c.length>0)&&e.jsxs("div",{className:"flex gap-2 overflow-x-auto",children:[t.thumbnailUrl&&e.jsx("img",{src:t.thumbnailUrl,alt:"Thumbnail",className:"h-24 rounded-lg border border-cc-border/30 object-cover"}),c.map((r,x)=>e.jsx("img",{src:r,alt:`Media ${x+1}`,className:"h-24 rounded-lg border border-cc-border/30 object-cover"},x))]}),t.videoUrl&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-cc-muted bg-cc-bg rounded-md px-2 py-1",children:[e.jsx("span",{children:"🎬"}),e.jsx("span",{className:"truncate",children:t.videoUrl})]}),t.firstComment&&e.jsx("div",{className:"text-[11px] text-cc-muted/80 border-l-2 border-cc-accent/20 pl-2.5 italic",children:t.firstComment}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(Z,{status:t.status}),t.createdBy&&t.createdBy!=="user"&&e.jsx(he,{by:t.createdBy}),t.platforms.map(r=>e.jsx(V,{platform:r},r)),e.jsx("span",{className:"text-[10px] text-cc-muted ml-auto",children:t.scheduledAt?`Scheduled: ${new Date(t.scheduledAt).toLocaleString()}`:t.createdAt?_(t.createdAt):""})]})]}),e.jsxs("div",{className:"flex items-center gap-1 px-3.5 py-2 border-t border-cc-border/30 bg-cc-bg/30",children:[u&&g&&e.jsx("button",{onClick:()=>g(t.id),disabled:j,className:"flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-green-400 hover:bg-green-400/10 rounded-md transition-colors disabled:opacity-50",children:j?"Publishing...":"▶ Publish"}),e.jsx("button",{onClick:()=>a(t),className:"flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-cc-muted hover:text-cc-fg hover:bg-cc-hover rounded-md transition-colors",children:"Edit"}),e.jsx("button",{onClick:l,className:"flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-cc-muted hover:text-cc-fg hover:bg-cc-hover rounded-md transition-colors",children:"Comments"}),e.jsx("button",{onClick:()=>d(t.id),className:"flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-red-400/70 hover:text-red-400 hover:bg-red-400/10 rounded-md transition-colors ml-auto",children:"Delete"})]}),f&&e.jsx("div",{className:"px-3.5 pb-3 border-t border-cc-border/30",children:e.jsx(oe,{comments:w,onReply:h})})]})}function oe({comments:t,onReply:a}){return e.jsxs("div",{className:"pt-2.5 space-y-2",children:[t.length===0&&e.jsx("p",{className:"text-[10px] text-cc-muted",children:"No comments."}),t.map(d=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-cc-accent",children:d.author}),e.jsx("span",{className:"text-[9px] text-cc-muted",children:d.createdAt?_(d.createdAt):""}),d.likes?e.jsxs("span",{className:"text-[9px] text-cc-muted",children:["· ",d.likes," likes"]}):null]}),e.jsx("p",{className:"text-[11px] text-cc-fg",children:d.text}),e.jsx(J,{onSubmit:o=>a(d.id,o),placeholder:"Reply..."})]},d.id)),e.jsx(J,{onSubmit:d=>a(null,d),placeholder:"New comment..."})]})}function J({onSubmit:t,placeholder:a}){const[d,o]=s.useState("");return e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("input",{value:d,onChange:b=>o(b.target.value),placeholder:a,className:"flex-1 bg-cc-bg border border-cc-border/50 rounded-md px-2 py-1 text-[10px] text-cc-fg focus:outline-none focus:border-cc-accent/50",onKeyDown:b=>{b.key==="Enter"&&d.trim()&&(t(d.trim()),o(""))}}),e.jsx("button",{onClick:()=>{d.trim()&&(t(d.trim()),o(""))},className:"text-[10px] text-cc-accent hover:text-cc-accent/80 transition-colors px-2",children:"Send"})]})}function xe({refreshKey:t,showMessage:a,onEdit:d,onRefresh:o}){const b=new Date,[g,j]=s.useState(b.getFullYear()),[f,p]=s.useState(b.getMonth()),[w,N]=s.useState({}),[u,c]=s.useState(null),l=`${g}-${String(f+1).padStart(2,"0")}`,h=s.useCallback(async()=>{try{const v=await S.getSocialCalendar(l);N(v.days||{})}catch{}},[l]);s.useEffect(()=>{h()},[h,t]);function r(){f===0?(p(11),j(g-1)):p(f-1),c(null)}function x(){f===11?(p(0),j(g+1)):p(f+1),c(null)}const y=new Date(g,f+1,0).getDate();let m=new Date(g,f,1).getDay();m=m===0?6:m-1;const T=new Date().toISOString().slice(0,10);async function F(v){const k=prompt("New date/time (YYYY-MM-DDTHH:MM):");if(k)try{await S.updateSocialPost(v,{scheduledAt:new Date(k).toISOString()}),a("Post rescheduled."),h(),o()}catch(A){a(A instanceof Error?A.message:"Failed",!0)}}const M=u?w[u]||[]:[];return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("button",{onClick:r,className:"px-2 py-1 text-cc-muted hover:text-cc-fg transition-colors rounded-md hover:bg-cc-hover",children:"←"}),e.jsxs("span",{className:"text-sm font-medium text-cc-fg",children:[re[f]," ",g]}),e.jsx("button",{onClick:x,className:"px-2 py-1 text-cc-muted hover:text-cc-fg transition-colors rounded-md hover:bg-cc-hover",children:"→"})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-0.5",children:[le.map(v=>e.jsx("div",{className:"text-center text-[9px] font-medium text-cc-muted py-1.5 uppercase tracking-wider",children:v},v)),Array.from({length:m}).map((v,k)=>e.jsx("div",{className:"aspect-square"},`e-${k}`)),Array.from({length:y}).map((v,k)=>{const A=k+1,n=`${l}-${String(A).padStart(2,"0")}`,C=w[n]||[],$=n===T,L=n===u,D=C.some(R=>R.status==="draft"),B=C.some(R=>R.status==="scheduled"),I=C.some(R=>R.status==="published");return e.jsxs("button",{onClick:()=>c(L?null:n),className:`aspect-square flex flex-col items-center justify-center rounded-lg text-xs transition-all border relative ${L?"border-cc-accent bg-cc-accent/15 text-cc-accent font-semibold":C.length>0?"border-cc-border/30 bg-cc-card text-cc-fg hover:border-cc-accent/30":"border-transparent text-cc-fg hover:bg-cc-hover"} ${$?"ring-1 ring-cc-accent/30":""}`,children:[e.jsx("span",{className:$?"font-bold":"",children:A}),C.length>0&&e.jsxs("div",{className:"flex items-center gap-0.5 mt-0.5",children:[I&&e.jsx("div",{className:"w-1 h-1 rounded-full bg-green-400"}),B&&e.jsx("div",{className:"w-1 h-1 rounded-full bg-cc-accent"}),D&&e.jsx("div",{className:"w-1 h-1 rounded-full bg-yellow-400"}),e.jsx("span",{className:"text-[8px] text-cc-muted font-medium ml-0.5",children:C.length})]})]},A)})]}),e.jsxs("div",{className:"flex gap-3 justify-center text-[9px] text-cc-muted",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 inline-block"})," Published"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cc-accent inline-block"})," Scheduled"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-yellow-400 inline-block"})," Draft"]})]}),u&&e.jsxs("div",{className:"border border-cc-border rounded-xl p-3.5 bg-cc-card space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-medium text-cc-fg",children:new Date(u+"T00:00:00").toLocaleDateString(void 0,{weekday:"long",day:"numeric",month:"long",year:"numeric"})}),e.jsx("button",{onClick:()=>d({id:"",text:"",status:"draft",platforms:[],createdAt:"",scheduledAt:u+"T12:00:00"}),className:"text-[10px] px-2 py-1 rounded-md bg-cc-accent/10 text-cc-accent border border-cc-accent/30 hover:bg-cc-accent/20 transition-colors cursor-pointer",children:"+ New Post"})]}),M.length===0?e.jsx("p",{className:"text-[10px] text-cc-muted",children:"No posts on this day."}):M.map(v=>e.jsxs("div",{className:"border border-cc-border/30 rounded-lg p-2.5 space-y-1.5 bg-cc-bg/50",children:[v.title&&e.jsx("div",{className:"text-[11px] font-semibold text-cc-fg",children:v.title}),e.jsx("p",{className:"text-[11px] text-cc-fg break-words leading-relaxed",children:v.text}),e.jsxs("div",{className:"flex flex-wrap gap-1 items-center",children:[e.jsx(Z,{status:v.status}),v.platforms.map(k=>e.jsx(V,{platform:k},k)),v.scheduledAt&&e.jsx("span",{className:"text-[9px] text-cc-muted",children:new Date(v.scheduledAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>d(v),className:"text-[10px] text-cc-muted hover:text-cc-fg transition-colors",children:"Edit"}),e.jsx("button",{onClick:()=>F(v.id),className:"text-[10px] text-cc-accent hover:text-cc-accent/80 transition-colors",children:"Reschedule"})]})]},v.id))]})]})}function me({showMessage:t}){const[a,d]=s.useState([]),[o,b]=s.useState(""),[g,j]=s.useState(null),[f,p]=s.useState([]),[w,N]=s.useState(!1);s.useEffect(()=>{S.getSocialProfiles().then(c=>d(c.profiles||[])).catch(()=>{})},[]);async function u(){if(!o){t("Select a profile.",!0);return}N(!0);try{const c=await S.getSocialAccountAnalytics(o);j(c);const l=await S.listSocialPosts({limit:10}),h=await Promise.all((l.posts||[]).filter(r=>r.status==="published").map(async r=>{try{const x=await S.getSocialPostAnalytics(r.id);return{post:r,analytics:x}}catch{return{post:r,analytics:{impressions:0,likes:0,shares:0,comments:0}}}}));p(h)}catch(c){t(c instanceof Error?c.message:"Failed",!0)}finally{N(!1)}}return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-[10px] text-cc-muted uppercase tracking-wider block mb-1",children:"Profile"}),e.jsxs("select",{value:o,onChange:c=>b(c.target.value),className:"w-full bg-cc-bg border border-cc-border rounded-md p-2 text-xs text-cc-fg focus:outline-none",children:[e.jsx("option",{value:"",children:"Select profile..."}),a.map(c=>e.jsxs("option",{value:c.id,children:[H[c.platform]||""," ",c.platform," — ",c.name]},c.id))]})]}),e.jsx("button",{onClick:u,disabled:w,className:"px-3 py-2 text-xs font-medium rounded-md bg-cc-accent/10 text-cc-accent border border-cc-accent/30 hover:bg-cc-accent/20 disabled:opacity-50 transition-colors",children:w?"Loading...":"Load"})]}),g&&e.jsx("div",{className:"grid grid-cols-3 gap-3",children:[{label:"Followers",value:g.followers},{label:"Following",value:g.following},{label:"Posts",value:g.posts}].map(c=>e.jsxs("div",{className:"border border-cc-border rounded-xl p-3.5 bg-cc-card text-center",children:[e.jsx("div",{className:"text-xl font-bold text-cc-accent",children:E(c.value)}),e.jsx("div",{className:"text-[9px] text-cc-muted uppercase tracking-wider mt-1",children:c.label})]},c.label))}),f.length>0&&(()=>{const c=f.reduce((r,{analytics:x})=>({impressions:r.impressions+x.impressions,likes:r.likes+x.likes,shares:r.shares+x.shares,comments:r.comments+x.comments}),{impressions:0,likes:0,shares:0,comments:0}),l=c.impressions>0?((c.likes+c.shares+c.comments)/c.impressions*100).toFixed(2):"0.00",h=f.reduce((r,x)=>{const y=x.analytics.likes+x.analytics.shares+x.analytics.comments,m=r.analytics.likes+r.analytics.shares+r.analytics.comments;return y>m?x:r},f[0]);return e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"grid grid-cols-5 gap-2",children:[{label:"Total Views",value:E(c.impressions)},{label:"Total Likes",value:E(c.likes)},{label:"Total Shares",value:E(c.shares)},{label:"Total Comments",value:E(c.comments)},{label:"Engagement",value:`${l}%`}].map(r=>e.jsxs("div",{className:"border border-cc-border rounded-xl p-2.5 bg-cc-card text-center",children:[e.jsx("div",{className:"text-sm font-bold text-cc-accent",children:r.value}),e.jsx("div",{className:"text-[8px] text-cc-muted uppercase tracking-wider mt-0.5",children:r.label})]},r.label))}),h&&h.analytics.likes+h.analytics.shares+h.analytics.comments>0&&e.jsxs("div",{className:"border border-cc-accent/30 rounded-xl p-3.5 bg-cc-accent/5 space-y-2",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-cc-accent/20 text-cc-accent font-medium",children:"Top Post"})}),e.jsxs("p",{className:"text-[11px] text-cc-fg break-words",children:[h.post.text.slice(0,150),h.post.text.length>150?"...":""]}),e.jsxs("div",{className:"flex gap-3 text-[10px] text-cc-muted",children:[e.jsxs("span",{children:[E(h.analytics.impressions)," views"]}),e.jsxs("span",{children:[E(h.analytics.likes)," likes"]}),e.jsxs("span",{children:[E(h.analytics.shares)," shares"]})]})]}),e.jsx("h3",{className:"text-[10px] text-cc-muted uppercase tracking-wider font-medium",children:"Post Performance"}),f.map(({post:r,analytics:x})=>e.jsxs("div",{className:"border border-cc-border rounded-xl p-3.5 bg-cc-card space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-cc-fg break-words",children:[r.text.slice(0,120),r.text.length>120?"...":""]}),e.jsxs("div",{className:"flex gap-1 text-[10px]",children:[r.platforms.map(y=>e.jsx(V,{platform:y},y)),e.jsx("span",{className:"text-cc-muted",children:r.createdAt?_(r.createdAt):""}),x.impressions>0&&e.jsxs("span",{className:"text-cc-muted ml-auto",children:[((x.likes+x.shares+x.comments)/x.impressions*100).toFixed(1),"% eng."]})]}),e.jsx("div",{className:"grid grid-cols-4 gap-2",children:[{label:"Views",value:x.impressions},{label:"Likes",value:x.likes},{label:"Shares",value:x.shares},{label:"Comments",value:x.comments}].map(y=>e.jsxs("div",{className:"border border-cc-border/30 rounded-lg p-2 bg-cc-bg text-center",children:[e.jsx("div",{className:"text-sm font-bold text-cc-fg",children:E(y.value)}),e.jsx("div",{className:"text-[8px] text-cc-muted uppercase tracking-wider",children:y.label})]},y.label))})]},r.id))]})})()]})}function ue({showMessage:t}){const[a,d]=s.useState(""),[o,b]=s.useState("hosted"),[g,j]=s.useState(""),[f,p]=s.useState(""),[w,N]=s.useState(""),[u,c]=s.useState(""),[l,h]=s.useState(""),[r,x]=s.useState([]),[y,m]=s.useState(!1),[T,F]=s.useState(!1);s.useEffect(()=>{S.getSocialSettings().then(n=>{var C,$,L;if(d(n.backend||""),h(n.backend||""),(C=n.backends)!=null&&C.postiz){const D=n.backends.postiz.url||"";j(D),p(n.backends.postiz.apiKey||""),b(D&&D!=="https://api.postiz.com"?"selfhosted":"hosted")}($=n.backends)!=null&&$.ayrshare&&N(n.backends.ayrshare.apiKey||""),(L=n.backends)!=null&&L.buffer&&c(n.backends.buffer.apiKey||"")}).catch(()=>{})},[]);async function M(){const n={};a==="postiz"&&(n.postiz={url:o==="selfhosted"?g:"",apiKey:f}),a==="ayrshare"&&(n.ayrshare={apiKey:w}),a==="buffer"&&(n.buffer={apiKey:u}),await S.updateSocialSettings({backend:a||null,backends:n,defaultPlatforms:[]}),h(a)}async function v(){m(!0);try{await M(),t("Settings saved.")}catch(n){t(n instanceof Error?n.message:"Failed",!0)}finally{m(!1)}}async function k(){F(!0);try{await M();const n=await S.testSocialConnection();if(n.ok){t("Connection successful!");const C=await S.getSocialProfiles();x(C.profiles||[])}else t("Connection failed: "+(n.error||"unknown"),!0)}catch(n){t(n instanceof Error?n.message:"Failed",!0)}finally{F(!1)}}const A=[{id:"buffer",label:"Buffer",desc:"SaaS — GraphQL API"},{id:"ayrshare",label:"Ayrshare",desc:"SaaS — REST API"},{id:"postiz",label:"Postiz",desc:"Hosted or Self-hosted"}];return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-cc-muted uppercase tracking-wider block mb-1",children:"Backend"}),e.jsx("p",{className:"text-[9px] text-cc-muted mb-2",children:"One active backend at a time. Switching will replace the current configuration."}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:A.map(n=>e.jsxs("button",{onClick:()=>d(n.id),className:`p-3 rounded-xl border text-left transition-all ${a===n.id?"border-cc-accent bg-cc-accent/10":"border-cc-border bg-cc-card hover:border-cc-accent/30"}`,children:[e.jsxs("div",{className:"text-xs font-medium text-cc-fg flex items-center gap-1.5",children:[n.label,l===n.id&&e.jsx("span",{className:"text-[8px] px-1.5 py-0.5 rounded-full bg-green-500/20 text-green-400 font-medium",children:"Active"})]}),e.jsx("div",{className:"text-[9px] text-cc-muted mt-0.5",children:n.desc})]},n.id))})]}),a==="postiz"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-cc-muted uppercase tracking-wider block mb-1.5",children:"Hosting"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("button",{onClick:()=>b("hosted"),className:`p-2.5 rounded-lg border text-left transition-all ${o==="hosted"?"border-cc-accent bg-cc-accent/10":"border-cc-border bg-cc-card hover:border-cc-accent/30"}`,children:[e.jsx("div",{className:"text-xs font-medium text-cc-fg",children:"Standard"}),e.jsx("div",{className:"text-[9px] text-cc-muted mt-0.5",children:"api.postiz.com"})]}),e.jsxs("button",{onClick:()=>b("selfhosted"),className:`p-2.5 rounded-lg border text-left transition-all ${o==="selfhosted"?"border-cc-accent bg-cc-accent/10":"border-cc-border bg-cc-card hover:border-cc-accent/30"}`,children:[e.jsx("div",{className:"text-xs font-medium text-cc-fg",children:"Self-hosted"}),e.jsx("div",{className:"text-[9px] text-cc-muted mt-0.5",children:"Custom URL"})]})]})]}),o==="selfhosted"&&e.jsx(O,{label:"Postiz URL",value:g,onChange:j,placeholder:"https://postiz.example.com"}),e.jsx(O,{label:"API Key",value:f,onChange:p,placeholder:"Settings → Developers → Public API",password:!0})]}),a==="ayrshare"&&e.jsx(O,{label:"Ayrshare API Key",value:w,onChange:N,placeholder:"API Key",password:!0}),a==="buffer"&&e.jsx(O,{label:"Buffer API Key",value:u,onChange:c,placeholder:"Access Token from publish.buffer.com/settings/api",password:!0}),a&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:v,disabled:y,className:"px-4 py-2 text-xs font-medium rounded-md bg-cc-accent text-white hover:bg-cc-accent/90 disabled:opacity-50 transition-colors",children:y?"Saving...":"Save"}),e.jsx("button",{onClick:k,disabled:T,className:"px-4 py-2 text-xs font-medium rounded-md text-cc-muted hover:text-cc-fg border border-cc-border hover:border-cc-accent/30 disabled:opacity-50 transition-colors",children:T?"Testing...":"Test Connection"})]}),r.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-[10px] text-cc-muted uppercase tracking-wider font-medium mb-2",children:"Connected Channels"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:r.map(n=>e.jsxs("div",{className:"flex items-center gap-2.5 p-2.5 rounded-lg border border-cc-border/50 bg-cc-card",children:[n.picture?e.jsx("img",{src:n.picture,alt:"",className:"w-7 h-7 rounded-full"}):e.jsx("div",{className:"w-7 h-7 rounded-full bg-cc-accent/10 flex items-center justify-center text-[10px] text-cc-accent font-medium",children:H[n.platform]||"?"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-medium text-cc-fg",children:n.name}),e.jsx("div",{className:"text-[9px] text-cc-muted",children:n.platform})]})]},n.id))})]})]})}function O({label:t,value:a,onChange:d,placeholder:o,password:b}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-cc-muted block mb-1",children:t}),e.jsx("input",{type:b?"password":"text",value:a,onChange:g=>d(g.target.value),placeholder:o,className:"w-full bg-cc-bg border border-cc-border rounded-md p-2 text-xs text-cc-fg focus:outline-none focus:border-cc-accent/50"})]})}function X({text:t}){return e.jsxs("div",{className:"text-center py-12",children:[e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-8 h-8 text-cc-muted/20 mx-auto mb-3",children:e.jsx("path",{d:"M8 0a8 8 0 100 16A8 8 0 008 0zm3.5 5.3l-1 4.5a.75.75 0 01-.37.47.73.73 0 01-.58.05L7.7 9.58l-1.22 1.18a.25.25 0 01-.43-.17V9.13L10.5 5l-4.4 3.56-1.7-.56a.5.5 0 01-.02-.94l8.5-3.5a.5.5 0 01.62.74z"})}),e.jsx("p",{className:"text-xs text-cc-muted",children:t})]})}function Z({status:t}){const a={published:"text-green-400 border-green-400/30 bg-green-400/5",scheduled:"text-cc-accent border-cc-accent/30 bg-cc-accent/5",failed:"text-red-400 border-red-400/30 bg-red-400/5",draft:"text-yellow-400 border-yellow-400/30 bg-yellow-400/5"};return e.jsx("span",{className:`inline-block text-[9px] font-medium uppercase tracking-wider border rounded-full px-1.5 py-0.5 ${a[t]||a.draft}`,children:t})}function he({by:t}){const a={gemini:"text-blue-400 border-blue-400/30 bg-blue-400/5",agent:"text-purple-400 border-purple-400/30 bg-purple-400/5"};return e.jsx("span",{className:`inline-block text-[9px] font-medium border rounded-full px-1.5 py-0.5 ${a[t]||"text-cc-muted border-cc-border"}`,children:t==="gemini"?"✦ Gemini":t==="agent"?"⚡ Agent":t})}function V({platform:t}){return e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[9px] font-medium text-cc-accent/80 border border-cc-accent/20 bg-cc-accent/5 rounded-full px-1.5 py-0.5",children:[e.jsx("span",{className:"text-[8px]",children:H[t]||""}),t]})}export{fe as SocialMediaPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r,b as n,j as e}from"./index-CEqZnThB.js";function ie({embedded:d}){const[x,h]=r.useState(""),[f,R]=r.useState(""),[P,F]=r.useState(!1),[H,E]=r.useState(""),[c,p]=r.useState(null),[J,M]=r.useState(!1),[v,B]=r.useState(null),[j,W]=r.useState(!1),[a,u]=r.useState({name:"peoplefone",provider:"peoplefone",username:"",password:"",server:"sip.peoplefone.at",callerId:"",enabled:!0}),[V,_]=r.useState([]),[z,q]=r.useState([]),[i,$]=r.useState(null),[N,y]=r.useState([]),w=r.useRef(null),g=r.useRef(null),[K,C]=r.useState([]),[S,O]=r.useState(!1),[l,k]=r.useState({name:"",phone:"",notes:""}),[T,D]=r.useState(null),[m,I]=r.useState({name:"",phone:"",notes:""});r.useEffect(()=>{A();const t=setInterval(A,5e3);return()=>clearInterval(t)},[]),r.useEffect(()=>{n.getContacts().then(t=>C(t.contacts)).catch(()=>{}),n.getTelephonySettings().then(t=>p(t)).catch(()=>{})},[]),r.useEffect(()=>{w.current&&(w.current.scrollTop=w.current.scrollHeight)},[N]);async function A(){try{const[t,s]=await Promise.all([n.getActiveCalls(),n.getCallHistory(20)]);_(t.calls),q(s.calls)}catch{}}async function Q(){if(!(!x.trim()||!f.trim()||P)){F(!0),E("");try{const t=await n.startCall({phone:x.trim(),prompt:f.trim()});t.error?E(t.error):(h(""),R(""),U(t.id),A())}catch(t){E(t instanceof Error?t.message:"Failed to start call")}finally{F(!1)}}}function U(t){g.current&&g.current.close(),y([]);const s=window.location.protocol==="https:"?"wss:":"ws:",o=new WebSocket(`${s}//${window.location.host}/ws/telephony/transcript/${t}`);o.onmessage=ce=>{try{const L=JSON.parse(ce.data);L.type==="transcript"&&L.entry&&y(ae=>[...ae,L.entry])}catch{}},o.onclose=()=>{g.current=null},g.current=o}async function X(t){try{await n.endCall(t),A()}catch{}}async function Y(){if(!(!l.name.trim()||!l.phone.trim()))try{const t=await n.addContact(l);C(s=>[...s,t]),k({name:"",phone:"",notes:""}),O(!1)}catch{}}async function Z(t){try{await n.deleteContact(t),C(s=>s.filter(o=>o.id!==t))}catch{}}async function ee(){if(T)try{const t=await n.updateContact(T,m);C(s=>s.map(o=>o.id===T?t:o)),D(null)}catch{}}async function b(t){M(!0);try{await n.updateTelephonySettings(t);const s=await n.getTelephonySettings();p(s)}catch{}M(!1)}async function te(){B(null);const t=await n.testFreeSwitchConnection();B(t)}async function se(){if(!(!a.username||!a.password||!a.server))try{await fetch("/api/telephony/trunks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});const t=await n.getTelephonySettings();p(t),W(!1),u({name:"peoplefone",provider:"peoplefone",username:"",password:"",server:"sip.peoplefone.at",callerId:"",enabled:!0})}catch{}}async function re(t){try{await fetch(`/api/telephony/trunks/${encodeURIComponent(t)}`,{method:"DELETE"});const s=await n.getTelephonySettings();p(s)}catch{}}function G(t){$(t),t.status==="active"||t.status==="dialing"||t.status==="ringing"?U(t.id):n.getCall(t.id).then(s=>{$(s),y(s.transcript||[])}).catch(()=>{})}return e.jsx("div",{className:"h-full overflow-auto ",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-8 sm:px-6",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Telephony"}),e.jsx("p",{className:"text-xs text-cc-muted mt-1",children:"Make AI-powered phone calls via FreeSWITCH + Gemini Live."})]}),e.jsxs("div",{className:"bg-cc-card border border-cc-border rounded-xl p-4 mb-6",children:[e.jsx("h2",{className:"text-xs font-semibold text-cc-muted uppercase tracking-wider mb-3",children:"New Call"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{children:e.jsx("input",{type:"tel",value:x,onChange:t=>h(t.target.value),placeholder:"+43 664 1234567",className:"w-full px-3 py-2 text-sm bg-cc-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted/60 focus:outline-none focus:border-cc-primary"})}),e.jsx("div",{children:e.jsx("textarea",{value:f,onChange:t=>R(t.target.value),placeholder:"Task for the AI (e.g. 'Reserve a table for 4 at 7pm on Friday')",rows:2,className:"w-full px-3 py-2 text-sm bg-cc-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted/60 focus:outline-none focus:border-cc-primary resize-none"})}),e.jsx("button",{onClick:Q,disabled:!x.trim()||!f.trim()||P,className:"px-4 py-2 rounded-lg text-xs font-medium bg-green-600 text-white hover:bg-green-500 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:P?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-3 h-3 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Dialing..."]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ne,{className:"w-3.5 h-3.5"}),"Call"]})})]})]}),H&&e.jsx("div",{className:"mb-4 px-3 py-2 rounded-lg bg-cc-error/5 border border-cc-error/20",children:e.jsx("p",{className:"text-xs text-cc-error",children:H})}),e.jsxs("div",{className:"bg-cc-card border border-cc-border rounded-xl p-4 mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-xs font-semibold text-cc-muted uppercase tracking-wider",children:"Contacts"}),e.jsx("button",{onClick:()=>O(!S),className:"text-xs text-cc-primary hover:text-cc-primary/80 transition-colors cursor-pointer",children:S?"Cancel":"+ Add"})]}),S&&e.jsxs("div",{className:"bg-cc-bg rounded-lg p-3 border border-cc-border space-y-2 mb-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-cc-muted",children:"Name"}),e.jsx("input",{type:"text",value:l.name,onChange:t=>k({...l,name:t.target.value}),placeholder:"e.g. Mama",className:"w-full px-2 py-1.5 text-xs bg-cc-hover border border-cc-border rounded text-cc-fg"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-cc-muted",children:"Phone"}),e.jsx("input",{type:"tel",value:l.phone,onChange:t=>k({...l,phone:t.target.value}),placeholder:"+43...",className:"w-full px-2 py-1.5 text-xs bg-cc-hover border border-cc-border rounded text-cc-fg"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-cc-muted",children:"Notes (optional)"}),e.jsx("input",{type:"text",value:l.notes,onChange:t=>k({...l,notes:t.target.value}),placeholder:"e.g. Mo-Sa 10-18 Uhr",className:"w-full px-2 py-1.5 text-xs bg-cc-hover border border-cc-border rounded text-cc-fg"})]}),e.jsx("button",{onClick:Y,disabled:!l.name.trim()||!l.phone.trim(),className:"px-3 py-1.5 text-xs rounded bg-green-600 text-white hover:bg-green-500 transition-colors cursor-pointer disabled:opacity-50",children:"Add Contact"})]}),K.length===0&&!S?e.jsx("p",{className:"text-xs text-cc-muted",children:"No contacts yet. Add contacts so Gemini can call them by name."}):e.jsx("div",{className:"space-y-1.5",children:K.map(t=>e.jsx("div",{className:"bg-cc-bg rounded-lg px-3 py-2 border border-cc-border",children:T===t.id?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("input",{type:"text",value:m.name,onChange:s=>I({...m,name:s.target.value}),className:"px-2 py-1.5 text-xs bg-cc-hover border border-cc-border rounded text-cc-fg"}),e.jsx("input",{type:"tel",value:m.phone,onChange:s=>I({...m,phone:s.target.value}),className:"px-2 py-1.5 text-xs bg-cc-hover border border-cc-border rounded text-cc-fg"})]}),e.jsx("input",{type:"text",value:m.notes,onChange:s=>I({...m,notes:s.target.value}),placeholder:"Notes",className:"w-full px-2 py-1.5 text-xs bg-cc-hover border border-cc-border rounded text-cc-fg"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:ee,className:"px-2 py-1 text-[11px] rounded bg-green-600 text-white hover:bg-green-500 cursor-pointer",children:"Save"}),e.jsx("button",{onClick:()=>D(null),className:"px-2 py-1 text-[11px] rounded bg-cc-hover text-cc-muted hover:text-cc-fg cursor-pointer",children:"Cancel"})]})]}):e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("button",{onClick:()=>{h(t.phone)},className:"min-w-0 flex-1 text-left cursor-pointer hover:opacity-80",title:"Click to use this number",children:[e.jsx("p",{className:"text-xs font-medium text-cc-fg",children:t.name}),e.jsxs("p",{className:"text-[11px] text-cc-muted",children:[t.phone,t.notes?` — ${t.notes}`:""]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-2 shrink-0",children:[e.jsx("button",{onClick:()=>{D(t.id),I({name:t.name,phone:t.phone,notes:t.notes||""})},className:"text-[11px] text-cc-muted hover:text-cc-fg transition-colors cursor-pointer",children:"Edit"}),e.jsx("button",{onClick:()=>Z(t.id),className:"text-[11px] text-red-400 hover:text-red-300 transition-colors cursor-pointer",children:"Remove"})]})]})},t.id))})]}),V.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xs font-semibold text-cc-muted uppercase tracking-wider mb-3",children:"Active Calls"}),e.jsx("div",{className:"space-y-2",children:V.map(t=>e.jsxs("div",{className:"bg-cc-card border border-cc-border rounded-lg px-4 py-3 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-cc-fg",children:t.phone}),e.jsx("p",{className:"text-[11px] text-cc-muted truncate max-w-[200px]",children:t.prompt})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] text-cc-muted",children:t.status}),e.jsx("button",{onClick:()=>G(t),className:"text-xs text-cc-primary hover:text-cc-primary/80 transition-colors cursor-pointer",children:"View"}),e.jsx("button",{onClick:()=>X(t.id),className:"text-xs text-red-500 hover:text-red-400 transition-colors cursor-pointer",children:"Hang up"})]})]},t.id))})]}),(N.length>0||i)&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-xs font-semibold text-cc-muted uppercase tracking-wider",children:i?`Transcript — ${i.phone}`:"Live Transcript"}),i&&e.jsx("button",{onClick:()=>{var t;$(null),y([]),(t=g.current)==null||t.close()},className:"text-[11px] text-cc-muted hover:text-cc-fg transition-colors cursor-pointer",children:"Close"})]}),e.jsxs("div",{ref:w,className:"bg-cc-card border border-cc-border rounded-xl p-3 max-h-[300px] overflow-y-auto space-y-2",children:[N.length===0&&e.jsx("p",{className:"text-xs text-cc-muted text-center py-4",children:"Waiting for conversation..."}),N.map((t,s)=>e.jsx("div",{className:`flex ${t.speaker==="ai"?"justify-end":"justify-start"}`,children:e.jsxs("div",{className:`max-w-[80%] rounded-lg px-3 py-1.5 text-xs ${t.speaker==="ai"?"bg-cc-primary/20 text-cc-fg":t.speaker==="system"?"bg-cc-hover text-cc-muted italic":"bg-cc-card text-cc-fg border border-cc-border"}`,children:[e.jsx("span",{className:"text-[10px] text-cc-muted font-medium",children:t.speaker==="callee"?"Callee":t.speaker==="ai"?"AI":"System"}),e.jsx("p",{className:"mt-0.5",children:t.text})]})},s))]}),(i==null?void 0:i.summary)&&e.jsxs("div",{className:"mt-2 px-3 py-2 bg-cc-hover rounded-lg",children:[e.jsx("p",{className:"text-[11px] text-cc-muted font-medium mb-1",children:"Summary"}),e.jsx("p",{className:"text-xs text-cc-fg",children:i.summary})]})]}),c&&e.jsxs("details",{className:"bg-cc-card border border-cc-border rounded-xl mb-6 group",children:[e.jsxs("summary",{className:"px-4 py-3 cursor-pointer text-xs font-semibold text-cc-muted uppercase tracking-wider flex items-center justify-between select-none",children:[e.jsx("span",{children:"Settings"}),e.jsx("svg",{className:"w-3.5 h-3.5 text-cc-muted transition-transform group-open:rotate-180",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]}),e.jsxs("div",{className:"px-4 pb-4 space-y-4",children:[e.jsxs("button",{type:"button",onClick:()=>b({enabled:!c.enabled}),disabled:J,className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Enable Telephony"}),e.jsx("span",{className:`inline-flex w-9 h-5 rounded-full transition-colors relative shrink-0 ${c.enabled?"bg-green-500":"bg-cc-muted/30"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${c.enabled?"translate-x-4":"translate-x-0"}`})})]}),c.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-cc-bg rounded-lg p-3 space-y-2 border border-cc-border",children:[e.jsx("h3",{className:"text-xs font-semibold text-cc-muted uppercase tracking-wider",children:"FreeSWITCH ESL"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-cc-muted",children:"Host"}),e.jsx("input",{type:"text",value:c.freeswitch.eslHost,onChange:t=>p({...c,freeswitch:{...c.freeswitch,eslHost:t.target.value}}),onBlur:()=>b({freeswitch:c.freeswitch}),className:"w-full px-2 py-1.5 text-xs bg-cc-hover border border-cc-border rounded text-cc-fg"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-cc-muted",children:"Port"}),e.jsx("input",{type:"number",value:c.freeswitch.eslPort,onChange:t=>p({...c,freeswitch:{...c.freeswitch,eslPort:parseInt(t.target.value)||8021}}),onBlur:()=>b({freeswitch:c.freeswitch}),className:"w-full px-2 py-1.5 text-xs bg-cc-hover border border-cc-border rounded text-cc-fg"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-cc-muted",children:"ESL Password"}),e.jsx("input",{type:"password",value:c.freeswitch.eslPassword||"",onChange:t=>p({...c,freeswitch:{...c.freeswitch,eslPassword:t.target.value}}),onBlur:()=>b({freeswitch:c.freeswitch}),placeholder:"heyhank_esl_secret",className:"w-full px-2 py-1.5 text-xs bg-cc-hover border border-cc-border rounded text-cc-fg"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:te,className:"px-3 py-1.5 text-xs rounded bg-cc-primary text-white hover:opacity-90 transition-opacity cursor-pointer",children:"Test Connection"}),v&&e.jsx("span",{className:`text-xs ${v.connected?"text-green-500":"text-red-400"}`,children:v.connected?"Connected":v.error||"Failed"})]})]}),e.jsxs("div",{className:"bg-cc-bg rounded-lg p-3 space-y-2 border border-cc-border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-semibold text-cc-muted uppercase tracking-wider",children:"SIP Trunks"}),e.jsx("button",{onClick:()=>W(!j),className:"text-xs text-cc-primary hover:text-cc-primary/80 transition-colors cursor-pointer",children:j?"Cancel":"+ Add Trunk"})]}),c.trunks.length===0&&!j&&e.jsx("p",{className:"text-xs text-cc-muted",children:"No SIP trunks configured."}),c.trunks.map(t=>e.jsxs("div",{className:"flex items-center justify-between bg-cc-hover rounded-lg px-3 py-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs font-medium text-cc-fg",children:[t.name," ",e.jsxs("span",{className:"text-cc-muted",children:["(",t.provider,")"]})]}),e.jsx("p",{className:"text-[11px] text-cc-muted",children:t.callerId||"No caller ID"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${t.enabled?"bg-green-500":"bg-cc-muted"}`}),e.jsx("button",{onClick:()=>re(t.id),className:"text-[11px] text-red-400 hover:text-red-300 transition-colors cursor-pointer",children:"Remove"})]})]},t.id)),j&&e.jsxs("div",{className:"bg-cc-hover rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-cc-muted",children:"Name"}),e.jsx("input",{type:"text",value:a.name,onChange:t=>u({...a,name:t.target.value}),className:"w-full px-2 py-1.5 text-xs bg-cc-bg border border-cc-border rounded text-cc-fg"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-cc-muted",children:"Provider"}),e.jsxs("select",{value:a.provider,onChange:t=>{const s=t.target.value;u({...a,provider:s,name:s,server:{peoplefone:"sip.peoplefone.at",easybell:"sip.easybell.de",sipgate:"sipconnect.sipgate.de"}[s]||""})},className:"w-full px-2 py-1.5 text-xs bg-cc-bg border border-cc-border rounded text-cc-fg",children:[e.jsx("option",{value:"peoplefone",children:"peoplefone (AT)"}),e.jsx("option",{value:"easybell",children:"easybell (DE)"}),e.jsx("option",{value:"sipgate",children:"sipgate (DE)"}),e.jsx("option",{value:"custom",children:"Custom"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-cc-muted",children:"SIP Server"}),e.jsx("input",{type:"text",value:a.server,onChange:t=>u({...a,server:t.target.value}),className:"w-full px-2 py-1.5 text-xs bg-cc-bg border border-cc-border rounded text-cc-fg"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-cc-muted",children:"SIP Username"}),e.jsx("input",{type:"text",value:a.username,onChange:t=>u({...a,username:t.target.value}),className:"w-full px-2 py-1.5 text-xs bg-cc-bg border border-cc-border rounded text-cc-fg"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-cc-muted",children:"SIP Password"}),e.jsx("input",{type:"password",value:a.password,onChange:t=>u({...a,password:t.target.value}),className:"w-full px-2 py-1.5 text-xs bg-cc-bg border border-cc-border rounded text-cc-fg"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-cc-muted",children:"Caller ID (E.164)"}),e.jsx("input",{type:"text",value:a.callerId,onChange:t=>u({...a,callerId:t.target.value}),placeholder:"+43...",className:"w-full px-2 py-1.5 text-xs bg-cc-bg border border-cc-border rounded text-cc-fg"})]}),e.jsx("button",{onClick:se,disabled:!a.username||!a.password||!a.server,className:"px-3 py-1.5 text-xs rounded bg-green-600 text-white hover:bg-green-500 transition-colors cursor-pointer disabled:opacity-50",children:"Add Trunk"})]})]}),e.jsxs("div",{className:"bg-cc-bg rounded-lg p-3 space-y-2 border border-cc-border",children:[e.jsx("h3",{className:"text-xs font-semibold text-cc-muted uppercase tracking-wider",children:"Defaults"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-cc-muted",children:"Default Voice"}),e.jsxs("select",{value:c.defaultVoice||"Kore",onChange:t=>b({defaultVoice:t.target.value}),className:"w-full px-2 py-1.5 text-xs bg-cc-hover border border-cc-border rounded text-cc-fg",children:[e.jsx("option",{value:"Kore",children:"Kore (male)"}),e.jsx("option",{value:"Puck",children:"Puck (male)"}),e.jsx("option",{value:"Charon",children:"Charon (male)"}),e.jsx("option",{value:"Aoede",children:"Aoede (female)"}),e.jsx("option",{value:"Fenrir",children:"Fenrir (male)"}),e.jsx("option",{value:"Leda",children:"Leda (female)"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-cc-muted",children:"Max Call Duration (sec)"}),e.jsx("input",{type:"number",value:c.maxCallDurationSeconds||600,onChange:t=>b({maxCallDurationSeconds:parseInt(t.target.value)||600}),className:"w-full px-2 py-1.5 text-xs bg-cc-hover border border-cc-border rounded text-cc-fg"})]})]})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xs font-semibold text-cc-muted uppercase tracking-wider mb-3",children:"History"}),z.length===0?e.jsx("p",{className:"text-xs text-cc-muted",children:"No calls yet."}):e.jsx("div",{className:"space-y-1.5",children:z.map(t=>e.jsxs("button",{onClick:()=>G(t),className:"w-full text-left bg-cc-card border border-cc-border rounded-lg px-4 py-2.5 hover:border-cc-primary/40 transition-colors cursor-pointer",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${t.status==="ended"?"bg-cc-muted":t.status==="failed"?"bg-red-500":"bg-green-500"}`}),e.jsx("span",{className:"text-sm text-cc-fg",children:t.phone})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[t.durationSeconds>0&&e.jsx("span",{className:"text-[11px] text-cc-muted",children:le(t.durationSeconds)}),e.jsx("span",{className:"text-[11px] text-cc-muted",children:oe(t.startedAt)})]})]}),e.jsx("p",{className:"text-[11px] text-cc-muted truncate mt-0.5",children:t.prompt}),t.summary&&e.jsx("p",{className:"text-[11px] text-cc-fg/70 truncate mt-0.5",children:t.summary})]},t.id))})]})]})})}function ne({className:d}){return e.jsx("svg",{className:d,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})})}function le(d){const x=Math.floor(d/60),h=d%60;return x>0?`${x}m ${h}s`:`${h}s`}function oe(d){return new Date(d).toLocaleString("de-AT",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"})}export{ie as TelephonyPage};
|