Files
pyMC_Repeater/repeater/web/html/assets/Companions-BSRfTnkl.js
T
2026-03-13 09:06:57 +00:00

2 lines
28 KiB
JavaScript

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