Files
pyMC_Repeater/repeater/web/html/assets/Companions-MRhz2x9w.js
T
2026-06-23 16:35:02 +01:00

1 line
27 KiB
JavaScript

import{C as e,D as t,P as n,T as r,U as i,X as ee,_t as a,c as o,f as s,h as c,ht as l,i as u,j as d,l as f,m as p,o as m,p as h,r as g,s as _,u as v,y}from"./runtime-core.esm-bundler-CINEgm0a.js";import{i as b,l as x,o as S,r as C}from"./runtime-dom.esm-bundler-B3VeUO8l.js";import{t as w}from"./api-DSaJA91r.js";import{t as T}from"./Spinner-CMJUE3iy.js";import{r as E}from"./index-Cijj_ZXo.js";import{t as D}from"./ConfirmDialog-Dv9g-D0s.js";import{t as O}from"./MessageDialog-bNNcjSEH.js";var k={role:`dialog`,"aria-describedby":`import-modal-description`,class:`bg-white dark:bg-surface-elevated backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6 max-w-lg w-full max-h-[90vh] overflow-y-auto`},A={id:`import-modal-description`,class:`text-content-secondary dark:text-content-muted text-sm mb-4`},j={class:`mb-4`},M={class:`flex items-center gap-2 mb-2`},N={key:0,class:`text-content-muted dark:text-content-muted text-xs mb-2`},P={key:1,class:`flex flex-wrap gap-3 ml-6`},F=[`value`],I={class:`text-content-primary dark:text-content-primary text-sm capitalize`},L={class:`border-t border-stroke-subtle dark:border-white/10 pt-4 mt-4 mb-4`},R={class:`flex flex-wrap gap-3 mb-2`},z=[`value`],B={class:`text-content-primary dark:text-content-primary text-sm`},V={class:`flex flex-wrap items-center gap-2 mt-2`},H={class:`flex items-center gap-2`},te={key:1,class:`text-content-muted dark:text-content-muted text-sm`},ne={class:`border-t border-stroke-subtle dark:border-white/10 pt-4 mt-4 mb-4`},re={class:`flex flex-wrap items-center gap-2`},ie={key:0,role:`alert`,class:`mb-4 p-3 rounded-lg bg-accent-red/10 dark:bg-accent-red/20 border border-accent-red/30 text-accent-red text-sm`},U={key:1,class:`text-content-muted dark:text-content-muted text-sm mb-4`},ae={class:`flex justify-end gap-3`},W=[`disabled`],G=[`disabled`],K=c({name:`ImportRepeaterContactsModal`,__name:`ImportRepeaterContactsModal`,props:{isOpen:{type:Boolean},companionName:{}},emits:[`close`,`imported`],setup(e,{emit:s}){let c=[`companion`,`repeater`,`room_server`,`sensor`],l=[{label:`All time`,value:null},{label:`Last 24 hours`,value:24},{label:`Last 7 days`,value:168},{label:`Last 30 days`,value:720},{label:`Custom`,value:`custom`}].slice(0,4),p=e,T=s,E=i(!1),D=i(null),O=i(!0),K=i([]),q=i(null),J=i(``),Y=i(``),X=i(null),oe=i(null);function Z(){let e=q.value;if(e===null||e===`custom`){if(e===`custom`){let e=J.value;if(e===``||e===null)return;let t=Number(e);return Number.isInteger(t)&&t>=1?t:void 0}return}return e}function Q(){let e=Y.value;if(e===``||e===null)return;let t=Number(e);return Number.isInteger(t)&&t>=1?t:void 0}function se(){O.value=!0,K.value=[],q.value=null,J.value=``,Y.value=``,D.value=null}d(()=>p.isOpen,e=>{e&&(se(),y(()=>{oe.value?.focus()}))}),d(q,e=>{e===`custom`&&y(()=>{X.value?.focus()})});let ce=m(()=>{let e=O.value?`All types`:K.value.map(e=>e.replace(`_`,` `)).join(`, `),t,n=q.value;if(n===null)t=`all time`;else if(n===`custom`){let e=Z();t=e===void 0?`custom`:`last ${e} hours`}else t=n===24?`last 24 hours`:n===168?`last 7 days`:n===720?`last 30 days`:`all time`;let r=Q(),i=r===void 0?`no limit`:`max ${r} contacts`;return`Import: ${e}, ${t}, ${i}.`});function le(){if(q.value===`custom`){let e=Z();if(e===void 0||e<1)return`Custom recency must be at least 1 hour.`}let e=Q();if(Y.value!==``&&(e===void 0||e<1))return`Limit must be at least 1.`;if(!O.value&&K.value.length===0)return`Select at least one contact type or use All types.`;if(!O.value){let e=K.value.filter(e=>!c.includes(e));if(e.length>0)return`Invalid contact type: ${e.join(`, `)}`}return null}async function ue(){D.value=null;let e=le();if(e){D.value=e;return}let t={companion_name:p.companionName};!O.value&&K.value.length>0&&(t.contact_types=[...K.value]);let n=Z();n!==void 0&&(t.hours=n);let r=Q();r!==void 0&&(t.limit=r),E.value=!0;try{let e=await w.importRepeaterContacts(t);e.success&&e.data?(T(`imported`,e.data.imported),T(`close`)):D.value=e.error||`Import failed.`}catch(e){D.value=e instanceof Error?e.message:`Import failed.`}finally{E.value=!1}}function de(e){e.key===`Escape`&&T(`close`)}return(i,s)=>(r(),o(u,{to:`body`},[e.isOpen?(r(),v(`div`,{key:0,class:`fixed inset-0 bg-black/50 backdrop-blur-lg flex items-center justify-center z-[350] p-4`,onClick:s[7]||=x(e=>T(`close`),[`self`]),onKeydown:de},[_(`div`,k,[s[18]||=_(`h2`,{class:`text-xl font-bold text-content-primary dark:text-content-primary mb-4`},` Import repeater contacts `,-1),_(`p`,A,[s[8]||=h(` Seed `,-1),_(`strong`,null,a(e.companionName),1),s[9]||=h(` with contacts from the repeater's adverts. Results are ordered by most recent first. `,-1)]),_(`div`,j,[s[11]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},` Contact types `,-1),_(`label`,M,[n(_(`input`,{ref_key:`firstFocusRef`,ref:oe,"onUpdate:modelValue":s[0]||=e=>O.value=e,type:`checkbox`,class:`rounded border-stroke-subtle dark:border-stroke/20 text-primary focus:ring-primary/50`},null,512),[[C,O.value]]),s[10]||=_(`span`,{class:`text-content-primary dark:text-content-primary text-sm`},`All types`,-1)]),O.value?(r(),v(`p`,N,` Uncheck to filter by type (repeater, companion, room server, sensor). `)):f(``,!0),O.value?f(``,!0):(r(),v(`div`,P,[(r(),v(g,null,t(c,e=>_(`label`,{key:e,class:`flex items-center gap-2`},[n(_(`input`,{"onUpdate:modelValue":s[1]||=e=>K.value=e,type:`checkbox`,value:e,class:`rounded border-stroke-subtle dark:border-stroke/20 text-primary focus:ring-primary/50`},null,8,F),[[C,K.value]]),_(`span`,I,a(e.replace(`_`,` `)),1)])),64))]))]),_(`div`,L,[s[13]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},` Recency `,-1),_(`div`,R,[(r(!0),v(g,null,t(ee(l),e=>(r(),v(`label`,{key:e.label,class:`flex items-center gap-2`},[n(_(`input`,{"onUpdate:modelValue":s[2]||=e=>q.value=e,type:`radio`,value:e.value,class:`border-stroke-subtle dark:border-stroke/20 text-primary focus:ring-primary/50`},null,8,z),[[b,q.value]]),_(`span`,B,a(e.label),1)]))),128))]),_(`div`,V,[_(`label`,H,[n(_(`input`,{"onUpdate:modelValue":s[3]||=e=>q.value=e,type:`radio`,value:`custom`,class:`border-stroke-subtle dark:border-stroke/20 text-primary focus:ring-primary/50`},null,512),[[b,q.value]]),s[12]||=_(`span`,{class:`text-content-primary dark:text-content-primary text-sm`},`Custom:`,-1)]),q.value===`custom`?n((r(),v(`input`,{key:0,ref_key:`customHoursInputRef`,ref:X,"onUpdate:modelValue":s[4]||=e=>J.value=e,type:`number`,min:`1`,placeholder:`e.g. 48`,class:`w-24 bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-3 py-1.5 text-content-primary dark:text-content-primary text-sm placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50`},null,512)),[[S,J.value,void 0,{number:!0}]]):f(``,!0),q.value===`custom`?(r(),v(`span`,te,`hours`)):f(``,!0)])]),_(`div`,ne,[s[16]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},` Max contacts (optional) `,-1),_(`div`,re,[s[14]||=_(`span`,{class:`text-content-muted dark:text-content-muted text-sm`},`Import at most`,-1),n(_(`input`,{"onUpdate:modelValue":s[5]||=e=>Y.value=e,type:`number`,inputmode:`numeric`,min:`1`,placeholder:`No limit`,class:`w-32 bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-3 py-2 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50`},null,512),[[S,Y.value,void 0,{number:!0}]]),s[15]||=_(`span`,{class:`text-content-muted dark:text-content-muted text-sm`},`contacts`,-1)]),s[17]||=_(`p`,{class:`text-content-muted dark:text-content-muted text-xs mt-1`},` Leave empty for no cap. Server caps at companion max. `,-1)]),D.value?(r(),v(`div`,ie,a(D.value),1)):f(``,!0),D.value?f(``,!0):(r(),v(`p`,U,a(ce.value),1)),_(`div`,ae,[_(`button`,{type:`button`,disabled:E.value,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors disabled:opacity-50`,onClick:s[6]||=e=>T(`close`)},` Cancel `,8,W),_(`button`,{type:`button`,disabled:E.value,class:`btn-primary`,onClick:ue},a(E.value?`Importing…`:`Import`),9,G)])])],32)):f(``,!0)]))}}),q={class:`p-6 space-y-6`},J={key:0,class:`grid grid-cols-1 md:grid-cols-3 gap-4`},Y={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-5`},X={class:`flex items-center justify-between`},oe={class:`text-3xl font-bold text-content-primary dark:text-content-primary mb-1`},Z={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-5`},Q={class:`flex items-center justify-between`},se={class:`text-3xl font-bold text-primary mb-1`},ce={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-5`},le={class:`flex items-center justify-between`},ue={key:0,class:`w-6 h-6 text-accent-green`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},de={key:1,class:`w-6 h-6 text-accent-yellow`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},fe={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6`},pe={key:0,class:`flex items-center justify-center py-12`},me={class:`text-center`},he={key:1,class:`flex items-center justify-center py-12`},ge={class:`text-center`},_e={class:`text-content-secondary dark:text-content-muted text-sm mb-4`},ve={key:2,class:`space-y-4`},ye={class:`flex items-start justify-between`},be={class:`flex-1`},xe={class:`flex items-center gap-3 mb-4`},Se={class:`relative`},Ce={key:0,class:`absolute inset-0 bg-accent-green/50 rounded-full animate-ping`},we={class:`text-xl font-bold text-content-primary dark:text-content-primary`},Te={key:0,class:`text-content-muted dark:text-content-muted text-sm`},Ee={class:`grid grid-cols-1 md:grid-cols-2 gap-3 text-sm mb-3`},De={class:`text-content-primary dark:text-content-primary/90 ml-2`},Oe={class:`text-content-primary dark:text-content-primary/90 ml-2`},ke={class:`text-content-primary dark:text-content-primary/90 ml-2`},Ae={class:`flex items-center gap-2`},je={key:0,class:`text-content-primary dark:text-content-primary/90 font-mono ml-2 text-xs`},Me={key:1,class:`text-content-muted dark:text-content-muted ml-2 text-xs`},Ne=[`onClick`],Pe={class:`text-xs text-content-muted dark:text-content-muted`},Fe={key:0,class:`ml-2 font-mono text-content-primary dark:text-content-primary/90 break-all`},Ie={key:1,class:`ml-2 text-content-muted dark:text-content-muted`},Le={class:`ml-4 flex flex-wrap gap-2`},Re=[`onClick`],ze=[`onClick`],Be=[`onClick`],Ve={key:3,class:`text-center py-12 text-content-secondary dark:text-content-muted`},He={class:`bg-white dark:bg-surface-elevated backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6 max-w-2xl w-full max-h-[90vh] overflow-y-auto`},Ue={class:`space-y-4`},We={class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},Ge={key:0},Ke={key:1,class:`text-content-secondary dark:text-content-muted text-sm`},qe={class:`grid grid-cols-2 gap-4`},Je={class:`bg-white dark:bg-surface-elevated backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6 max-w-2xl w-full max-h-[90vh] overflow-y-auto`},Ye={class:`space-y-4`},Xe={class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},Ze={key:0},Qe={class:`grid grid-cols-2 gap-4`},$e=5050,et=1,tt=65535,nt=c({name:`CompanionsView`,__name:`Companions`,setup(ee){let c=i(!1),d=i(null),y=i(null),b=i(!1),C=i(!1),k=i(!1),A=i(null),j=i(``),M=i(!1),N=i(!1),P=i(new Set),F=i(!1),I=i(``),L=i(!1),R=i(``),z=i(!1),B=i({message:``,variant:`success`}),V=i({name:``,identity_key:``,type:`companion`,settings:{node_name:``,tcp_port:5e3,bind_address:`0.0.0.0`}});e(async()=>{await H()});async function H(){c.value=!0,d.value=null;try{let e=await w.getIdentities();e.success?y.value=e.data:d.value=e.error||`Failed to load identities`}catch(e){d.value=e instanceof Error?e.message:`Failed to load identities`}finally{c.value=!1}}async function te(){try{let e=await w.createIdentity({...V.value,settings:{node_name:V.value.settings.node_name||V.value.name,tcp_port:V.value.settings.tcp_port??5e3,bind_address:V.value.settings.bind_address||`0.0.0.0`}});e.success?(b.value=!1,W(),await H(),U(e.message||`Companion created successfully!`,`success`)):U(`Failed to create companion: ${e.error}`,`error`)}catch(e){U(`Error creating companion: ${e}`,`error`)}}async function ne(){let e={name:j.value,identity_key:A.value.identity_key,type:`companion`,settings:{node_name:A.value.settings?.node_name,tcp_port:A.value.settings?.tcp_port,bind_address:A.value.settings?.bind_address}};A.value.name!==j.value&&(e.new_name=A.value.name);try{let t=await w.updateIdentity(e);t.success?(C.value=!1,A.value=null,await H(),k.value=!0):U(`Failed to update companion: ${t.error}`,`error`)}catch(e){U(`Error updating companion: ${e}`,`error`)}}function re(e){I.value=e,F.value=!0}async function ie(){let e=I.value;F.value=!1;try{let t=await w.deleteIdentity(e,`companion`);t.success?(await H(),U(t.message||`Companion deleted successfully!`,`success`)):U(`Failed to delete companion: ${t.error}`,`error`)}catch(e){U(`Error deleting companion: ${e}`,`error`)}finally{I.value=``}}function U(e,t){B.value={message:e,variant:t},z.value=!0}function ae(e){A.value=JSON.parse(JSON.stringify(e)),j.value=A.value.name,delete A.value.new_name,A.value.settings||(A.value.settings={node_name:``,tcp_port:5e3,bind_address:`0.0.0.0`}),N.value=!1,C.value=!0}function W(){V.value={name:``,identity_key:``,type:`companion`,settings:{node_name:``,tcp_port:5e3,bind_address:`0.0.0.0`}},M.value=!1}function G(){b.value=!1,C.value=!1,A.value=null,M.value=!1,N.value=!1,W()}function nt(e){P.value.has(e)?P.value.delete(e):P.value.add(e)}let rt=()=>y.value?.configured_companions??[],it=m(()=>y.value?.configured_companions?.length??0),at=m(()=>y.value?.configured_companions?.filter(e=>e.registered).length??0),$=m(()=>at.value===it.value);function ot(){let e=rt();if(e.length===0)return $e;let t=e.map(e=>e.settings?.tcp_port??5e3),n=Math.max(...t)+1;return Math.min(tt,Math.max(et,n))}function st(){W(),V.value.settings.tcp_port=ot(),b.value=!0}function ct(e){R.value=e,L.value=!0}function lt(){L.value=!1,R.value=``}function ut(e){U(`Imported ${e} contact${e===1?``:`s`}.`,`success`),lt()}return(e,i)=>(r(),v(g,null,[_(`div`,q,[_(`div`,{class:`relative overflow-hidden rounded-[20px] p-6 mb-6 glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10`},[i[18]||=_(`div`,{class:`absolute inset-0 bg-gradient-to-br from-primary/20 via-secondary/10 to-accent-purple/20 opacity-50`},null,-1),i[19]||=_(`div`,{class:`absolute inset-0 bg-gradient-to-tl from-accent-green/10 via-transparent to-primary/10 animate-pulse`},null,-1),_(`div`,{class:`relative flex items-center justify-between`},[i[17]||=s(`<div class="flex items-center gap-4"><div class="relative"><div class="absolute inset-0 bg-primary/30 blur-xl rounded-full"></div><div class="relative bg-primary/20 p-4 rounded-[15px] border border-primary/30"><svg class="w-8 h-8 text-primary" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z"></path></svg></div></div><div><h1 class="text-3xl font-bold text-content-primary dark:text-content-primary mb-1"> Companions </h1><p class="text-content-secondary dark:text-content-muted text-sm"> Manage companion identities (TCP frame server) </p></div></div>`,1),_(`button`,{onClick:st,class:`group relative px-6 py-3 bg-gradient-to-r from-primary/30 to-secondary/30 hover:from-primary/40 hover:to-secondary/40 text-content-primary dark:text-content-primary rounded-[12px] border border-primary/50 transition-all hover:scale-105 hover:shadow-lg hover:shadow-primary/20`},[...i[16]||=[_(`span`,{class:`flex items-center gap-2`},[_(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[_(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})]),h(` Add Companion `)],-1)]])])]),y.value&&it.value>0?(r(),v(`div`,J,[_(`div`,Y,[_(`div`,X,[_(`div`,null,[i[20]||=_(`div`,{class:`text-content-secondary dark:text-content-muted text-xs font-medium mb-2 uppercase tracking-wide`},` Total Configured `,-1),_(`div`,oe,a(it.value),1)]),i[21]||=_(`div`,{class:`bg-background-mute dark:bg-white/10 p-3 rounded-[12px]`},[_(`svg`,{class:`w-6 h-6 text-content-secondary dark:text-content-primary/70`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[_(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z`})])],-1)])]),_(`div`,Z,[_(`div`,Q,[_(`div`,null,[i[22]||=_(`div`,{class:`text-content-secondary dark:text-content-muted text-xs font-medium mb-2 uppercase tracking-wide`},` Currently Registered `,-1),_(`div`,se,a(at.value),1)]),i[23]||=_(`div`,{class:`bg-primary/20 p-3 rounded-[12px]`},[_(`svg`,{class:`w-6 h-6 text-primary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[_(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 13l4 4L19 7`})])],-1)])]),_(`div`,ce,[_(`div`,le,[_(`div`,null,[i[24]||=_(`div`,{class:`text-content-secondary dark:text-content-muted text-xs font-medium mb-2 uppercase tracking-wide`},` Status `,-1),_(`div`,{class:l([`text-3xl font-bold`,$.value?`text-accent-green`:`text-accent-yellow`])},a($.value?`Synced`:`Out of Sync`),3)]),_(`div`,{class:l([`p-3 rounded-[12px]`,$.value?`bg-accent-green/20`:`bg-accent-yellow/20`])},[$.value?(r(),v(`svg`,ue,[...i[25]||=[_(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]])):(r(),v(`svg`,de,[...i[26]||=[_(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]]))],2)])])])):f(``,!0),_(`div`,fe,[c.value?(r(),v(`div`,pe,[_(`div`,me,[p(T,{class:`mx-auto mb-4`}),i[27]||=_(`div`,{class:`text-content-secondary dark:text-content-primary/70`},` Loading companions... `,-1)])])):d.value?(r(),v(`div`,he,[_(`div`,ge,[i[28]||=_(`div`,{class:`text-red-600 dark:text-red-400 mb-2`},`Failed to load companions`,-1),_(`div`,_e,a(d.value),1),_(`button`,{onClick:H,class:`btn-primary`},` Retry `)])])):y.value&&rt().length>0?(r(),v(`div`,ve,[(r(!0),v(g,null,t(rt(),e=>(r(),v(`div`,{key:e.name,class:`glass-card backdrop-blur-xl rounded-[15px] p-5 border border-stroke-subtle dark:border-white/10`},[_(`div`,ye,[_(`div`,be,[_(`div`,xe,[_(`div`,Se,[e.registered?(r(),v(`div`,Ce)):f(``,!0),_(`div`,{class:l([`relative w-3 h-3 rounded-full`,e.registered?`bg-accent-green`:`bg-accent-red`])},null,2)]),_(`h3`,we,a(e.name),1),_(`span`,{class:l([`px-3 py-1 text-xs font-semibold rounded-full`,e.registered?`bg-accent-green/20 text-accent-green border border-accent-green/30`:`bg-accent-red/20 text-accent-red border border-accent-red/30`])},a(e.registered?`● Active`:`○ Inactive`),3),e.hash?(r(),v(`span`,Te,a(e.hash),1)):f(``,!0)]),_(`div`,Ee,[_(`div`,null,[i[29]||=_(`span`,{class:`text-content-muted dark:text-content-muted`},`Node Name:`,-1),_(`span`,De,a(e.settings?.node_name||e.name),1)]),_(`div`,null,[i[30]||=_(`span`,{class:`text-content-muted dark:text-content-muted`},`TCP Port:`,-1),_(`span`,Oe,a(e.settings?.tcp_port??5e3),1)]),_(`div`,null,[i[31]||=_(`span`,{class:`text-content-muted dark:text-content-muted`},`Bind Address:`,-1),_(`span`,ke,a(e.settings?.bind_address||`0.0.0.0`),1)]),_(`div`,Ae,[i[32]||=_(`span`,{class:`text-content-muted dark:text-content-muted`},`Identity Key:`,-1),P.value.has(e.name)?(r(),v(`span`,je,a(e.identity_key),1)):(r(),v(`span`,Me,`••••••••••••••••`)),_(`button`,{onClick:t=>nt(e.name),class:`text-primary/70 hover:text-primary text-xs underline`},a(P.value.has(e.name)?`Hide`:`Show`),9,Ne)])]),_(`div`,Pe,[i[33]||=_(`span`,{class:`text-content-muted dark:text-content-muted`},`Public Key:`,-1),e.public_key?(r(),v(`span`,Fe,a(e.public_key),1)):(r(),v(`span`,Ie,``))])]),_(`div`,Le,[_(`button`,{onClick:t=>ct(e.name),class:`btn-primary-xs`},` Import contacts `,8,Re),_(`button`,{onClick:t=>ae(e),class:`btn-primary-xs`},` Edit `,8,ze),_(`button`,{onClick:t=>re(e.name),class:`btn-danger-xs`},` Delete `,8,Be)])])]))),128))])):(r(),v(`div`,Ve,[i[34]||=_(`svg`,{class:`w-16 h-16 mx-auto mb-4 text-content-muted dark:text-content-muted/60`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[_(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z`})],-1),i[35]||=_(`p`,{class:`text-lg mb-2`},`No companions configured`,-1),i[36]||=_(`p`,{class:`text-sm mb-4`},` Add a companion to run a TCP frame server for firmware or other clients `,-1),_(`button`,{onClick:st,class:`btn-primary`},` + Add Companion `)]))]),(r(),o(u,{to:`body`},[b.value?(r(),v(`div`,{key:0,class:`fixed inset-0 bg-black/50 backdrop-blur-lg flex items-center justify-center z-[300] p-4`,onClick:i[6]||=x(e=>b.value=!1,[`self`])},[_(`div`,He,[i[43]||=_(`h2`,{class:`text-xl font-bold text-content-primary dark:text-content-primary mb-4`},` Add Companion `,-1),_(`div`,Ue,[_(`div`,null,[i[37]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Name *`,-1),n(_(`input`,{"onUpdate:modelValue":i[0]||=e=>V.value.name=e,type:`text`,placeholder:`e.g., TestCompanion`,class:`modal-input`},null,512),[[S,V.value.name]])]),_(`div`,null,[_(`label`,We,[i[38]||=h(` Identity Key (Optional) `,-1),_(`button`,{onClick:i[1]||=e=>M.value=!M.value,type:`button`,class:`ml-2 text-primary/70 hover:text-primary text-xs underline`},a(M.value?`Hide`:`Show/Edit`),1)]),M.value?(r(),v(`div`,Ge,[n(_(`input`,{"onUpdate:modelValue":i[2]||=e=>V.value.identity_key=e,type:`text`,placeholder:`Leave empty to auto-generate (32 bytes hex)`,class:`modal-input font-mono text-sm`},null,512),[[S,V.value.identity_key]]),i[39]||=_(`p`,{class:`text-content-secondary dark:text-content-muted text-xs mt-1`},` 32 or 64 bytes hex. Leave empty to auto-generate. `,-1)])):(r(),v(`div`,Ke,` Will be auto-generated if not provided `))]),_(`div`,null,[i[40]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Node Name`,-1),n(_(`input`,{"onUpdate:modelValue":i[3]||=e=>V.value.settings.node_name=e,type:`text`,placeholder:`Display name (defaults to Name)`,class:`modal-input`},null,512),[[S,V.value.settings.node_name]])]),_(`div`,qe,[_(`div`,null,[i[41]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`TCP Port`,-1),n(_(`input`,{"onUpdate:modelValue":i[4]||=e=>V.value.settings.tcp_port=e,type:`number`,min:`1`,max:`65535`,class:`modal-input`},null,512),[[S,V.value.settings.tcp_port,void 0,{number:!0}]])]),_(`div`,null,[i[42]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Bind Address`,-1),n(_(`input`,{"onUpdate:modelValue":i[5]||=e=>V.value.settings.bind_address=e,type:`text`,placeholder:`0.0.0.0`,class:`modal-input`},null,512),[[S,V.value.settings.bind_address]])])])]),_(`div`,{class:`flex justify-end gap-3 mt-6`},[_(`button`,{onClick:G,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors`},` Cancel `),_(`button`,{onClick:te,class:`btn-primary`},` Create `)])])])):f(``,!0)])),(r(),o(u,{to:`body`},[C.value&&A.value?(r(),v(`div`,{key:0,class:`fixed inset-0 bg-black/50 backdrop-blur-lg flex items-center justify-center z-[300] p-4`,onClick:x(G,[`self`])},[_(`div`,Je,[i[49]||=_(`h2`,{class:`text-xl font-bold text-content-primary dark:text-content-primary mb-4`},` Edit Companion `,-1),_(`div`,Ye,[_(`div`,null,[i[44]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Name *`,-1),n(_(`input`,{"onUpdate:modelValue":i[7]||=e=>A.value.name=e,type:`text`,class:`modal-input`},null,512),[[S,A.value.name]])]),_(`div`,null,[_(`label`,Xe,[i[45]||=h(` Identity Key (Optional) `,-1),_(`button`,{onClick:i[8]||=e=>N.value=!N.value,type:`button`,class:`ml-2 text-primary/70 hover:text-primary text-xs underline`},a(N.value?`Hide`:`Show/Edit`),1)]),N.value?(r(),v(`div`,Ze,[n(_(`input`,{"onUpdate:modelValue":i[9]||=e=>A.value.identity_key=e,type:`text`,placeholder:`Leave empty to keep current key`,class:`modal-input font-mono text-sm`},null,512),[[S,A.value.identity_key]])])):f(``,!0)]),_(`div`,null,[i[46]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Node Name`,-1),n(_(`input`,{"onUpdate:modelValue":i[10]||=e=>A.value.settings.node_name=e,type:`text`,class:`modal-input`},null,512),[[S,A.value.settings.node_name]])]),_(`div`,Qe,[_(`div`,null,[i[47]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`TCP Port`,-1),n(_(`input`,{"onUpdate:modelValue":i[11]||=e=>A.value.settings.tcp_port=e,type:`number`,min:`1`,max:`65535`,class:`modal-input`},null,512),[[S,A.value.settings.tcp_port,void 0,{number:!0}]])]),_(`div`,null,[i[48]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Bind Address`,-1),n(_(`input`,{"onUpdate:modelValue":i[12]||=e=>A.value.settings.bind_address=e,type:`text`,class:`modal-input`},null,512),[[S,A.value.settings.bind_address]])])])]),_(`div`,{class:`flex justify-end gap-3 mt-6`},[_(`button`,{onClick:G,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors`},` Cancel `),_(`button`,{onClick:ne,class:`btn-primary`},` Update `)])])])):f(``,!0)]))]),p(K,{"is-open":L.value,"companion-name":R.value,onClose:lt,onImported:ut},null,8,[`is-open`,`companion-name`]),p(D,{show:F.value,title:`Delete Companion`,message:`Are you sure you want to delete '${I.value}'? Restart required to fully remove.`,"confirm-text":`Delete`,"cancel-text":`Cancel`,variant:`danger`,onClose:i[13]||=e=>F.value=!1,onConfirm:ie},null,8,[`show`,`message`]),p(O,{show:z.value,message:B.value.message,variant:B.value.variant,onClose:i[14]||=e=>z.value=!1},null,8,[`show`,`message`,`variant`]),p(E,{modelValue:k.value,"onUpdate:modelValue":i[15]||=e=>k.value=e,message:`Companion settings have been saved. A service restart is required for the changes to take effect.`},null,8,[`modelValue`])],64))}});export{nt as default};