import{f as _,i as l,a5 as J,a7 as F,a6 as y,a2 as B,M as G,P as L,w as P,aA as W,s as Y,e as q,bH as O,n as Q}from"./app-JmgyQoR0.js";import{b as Z,a as d,w as ee,h as m,t as k,u as v,l as p,j as s,K as o,E as t,z as n,i as w,F as M,G as N,H as R,I as ae,J as te}from"./vue-y3KLWBaS.js";const E=V=>(ae("data-v-dcadbf8d"),V=V(),te(),V),le={class:"shaynizk"},ne={class:"form"},se={value:"all"},oe={value:"users"},ue={value:"instances"},ie=["value"],de=["value"],re={class:"actions"},me=E(()=>v("i",{class:"ph-floppy-disk-back ph-bold ph-lg"},null,-1)),pe=E(()=>v("i",{class:"ph-trash ph-bold ph-lg"},null,-1)),ve=Z({__name:"editor",props:{antenna:{}},emits:["created","updated","deleted"],setup(V,{emit:$}){const i=V,I=$;let b=d(i.antenna.name),r=d(i.antenna.src),S=d(i.antenna.userListId),U=d(i.antenna.userGroupId),c=d(i.antenna.users.join(`
`)),f=d(i.antenna.instances.join(`
`)),x=d(i.antenna.keywords.map(u=>u.join(" ")).join(`
`)),g=d(i.antenna.excludeKeywords.map(u=>u.join(" ")).join(`
`)),h=d(i.antenna.caseSensitive),j=d(i.antenna.withReplies),K=d(i.antenna.withFile),A=d(i.antenna.notify),C=d(null),D=d(null);ee(()=>r.value,async()=>{if(r.value==="list"&&C.value===null&&(C.value=await _("users/lists/list")),r.value==="group"&&D.value===null){const u=await _("users/groups/owned"),e=await _("users/groups/joined");D.value=[...u,...e]}});async function z(){const u={name:b.value,src:r.value,userListId:S.value,userGroupId:U.value,withReplies:j.value,withFile:K.value,notify:A.value,caseSensitive:h.value,users:c.value.trim().split(`
`).map(e=>e.trim()),instances:f.value.trim().split(`
`).map(e=>e.trim()),keywords:x.value.trim().split(`
`).map(e=>e.trim().split(" ")),excludeKeywords:g.value.trim().split(`
`).map(e=>e.trim().split(" "))};i.antenna.id==null?(await L("antennas/create",u),I("created")):(u.antennaId=i.antenna.id,await L("antennas/update",u),I("updated"))}async function H(){const{canceled:u}=await P({type:"warning",text:l.t("removeAreYouSure",{x:i.antenna.name})});u||(await _("antennas/delete",{antennaId:i.antenna.id}),W(),I("deleted"))}function T(){Y().then(u=>{c.value=c.value.trim(),c.value+=`
@${q.toString(u)}`,c.value=c.value.trim()})}function X(){O().then(u=>{f.value=f.value.trim(),f.value+=`
`+u.host,f.value=f.value.trim()})}return(u,e)=>(m(),k("div",le,[v("div",ne,[p(J,{modelValue:b.value,"onUpdate:modelValue":e[0]||(e[0]=a=>b.value=a),class:"_formBlock"},{label:s(()=>[o(t(n(l).ts.name),1)]),_:1},8,["modelValue"]),p(F,{modelValue:r.value,"onUpdate:modelValue":e[1]||(e[1]=a=>r.value=a),class:"_formBlock"},{label:s(()=>[o(t(n(l).ts.antennaSource),1)]),default:s(()=>[v("option",se,t(n(l).ts._antennaSources.all),1),v("option",oe,t(n(l).ts._antennaSources.users),1),v("option",ue,t(n(l).ts._antennaSources.instances),1)]),_:1},8,["modelValue"]),r.value==="list"?(m(),w(F,{key:0,modelValue:S.value,"onUpdate:modelValue":e[2]||(e[2]=a=>S.value=a),class:"_formBlock"},{label:s(()=>[o(t(n(l).ts.userList),1)]),default:s(()=>[(m(!0),k(M,null,N(C.value,a=>(m(),k("option",{key:a.id,value:a.id},t(a.name),9,ie))),128))]),_:1},8,["modelValue"])):r.value==="group"?(m(),w(F,{key:1,modelValue:U.value,"onUpdate:modelValue":e[3]||(e[3]=a=>U.value=a),class:"_formBlock"},{label:s(()=>[o(t(n(l).ts.userGroup),1)]),default:s(()=>[(m(!0),k(M,null,N(D.value,a=>(m(),k("option",{key:a.id,value:a.id},t(a.name),9,de))),128))]),_:1},8,["modelValue"])):r.value==="users"?(m(),w(y,{key:2,modelValue:c.value,"onUpdate:modelValue":e[4]||(e[4]=a=>c.value=a),class:"_formBlock"},{label:s(()=>[o(t(n(l).ts.users),1)]),caption:s(()=>[o(t(n(l).ts.antennaUsersDescription)+" ",1),v("button",{class:"_textButton",onClick:T},t(n(l).ts.addUser),1)]),_:1},8,["modelValue"])):r.value==="instances"?(m(),w(y,{key:3,modelValue:f.value,"onUpdate:modelValue":e[5]||(e[5]=a=>f.value=a),class:"_formBlock"},{label:s(()=>[o(t(n(l).ts.instances),1)]),caption:s(()=>[o(t(n(l).ts.antennaInstancesDescription)+" ",1),v("button",{class:"_textButton",onClick:X},t(n(l).ts.addInstance),1)]),_:1},8,["modelValue"])):R("",!0),p(B,{modelValue:j.value,"onUpdate:modelValue":e[6]||(e[6]=a=>j.value=a),class:"_formBlock"},{default:s(()=>[o(t(n(l).ts.withReplies),1)]),_:1},8,["modelValue"]),p(y,{modelValue:x.value,"onUpdate:modelValue":e[7]||(e[7]=a=>x.value=a),class:"_formBlock"},{label:s(()=>[o(t(n(l).ts.antennaKeywords),1)]),caption:s(()=>[o(t(n(l).ts.antennaKeywordsDescription),1)]),_:1},8,["modelValue"]),p(y,{modelValue:g.value,"onUpdate:modelValue":e[8]||(e[8]=a=>g.value=a),class:"_formBlock"},{label:s(()=>[o(t(n(l).ts.antennaExcludeKeywords),1)]),caption:s(()=>[o(t(n(l).ts.antennaKeywordsDescription),1)]),_:1},8,["modelValue"]),p(B,{modelValue:h.value,"onUpdate:modelValue":e[9]||(e[9]=a=>h.value=a),class:"_formBlock"},{default:s(()=>[o(t(n(l).ts.caseSensitive),1)]),_:1},8,["modelValue"]),p(B,{modelValue:K.value,"onUpdate:modelValue":e[10]||(e[10]=a=>K.value=a),class:"_formBlock"},{default:s(()=>[o(t(n(l).ts.withFileAntenna),1)]),_:1},8,["modelValue"]),p(B,{modelValue:A.value,"onUpdate:modelValue":e[11]||(e[11]=a=>A.value=a),class:"_formBlock"},{default:s(()=>[o(t(n(l).ts.notifyAntenna),1)]),_:1},8,["modelValue"])]),v("div",re,[p(G,{inline:"",primary:"",onClick:e[12]||(e[12]=a=>z())},{default:s(()=>[me,o(" "+t(n(l).ts.save),1)]),_:1}),u.antenna.id!=null?(m(),w(G,{key:0,inline:"",danger:"",onClick:e[13]||(e[13]=a=>H())},{default:s(()=>[pe,o(" "+t(n(l).ts.delete),1)]),_:1})):R("",!0)])]))}}),Ve=Q(ve,[["__scopeId","data-v-dcadbf8d"]]);export{Ve as X};
