import{B as e,Bt as t,Dt as n,F as r,G as i,L as a,Mt as o,N as s,P as c,Q as l,R as u,T as d,Tt as f,Ut as p,bt as m,ot as h,qt as g,w as _,y as v}from"./vue-3bs2-dMU.js";import{K as y,U as b,l as x}from"./stores-DmetsdTd.js";import{C as S,D as C,G as w,K as T,S as E,T as D,dt as O,ht as k,mt as A,w as j,y as M}from"./vuetify-gGrfRH2I.js";i(),f(),p(),v();var N={key:0,class:`text-warning`},P=e({__name:`TagFormDialog`,props:{guid:{},initialTag:{}},emits:[`submit`],setup(e,{emit:i}){let f=e,p=i,{isOpened:v}=b(f.guid),{t:P}=y(),F=x(),I=o(!1),L=o([e=>!!e||P(`dialogs.tag.required`),e=>!f.initialTag||!!f.initialTag&&!e.includes(`,`)||P(`dialogs.tag.comma`)]),R=o(``);async function z(){if(!I.value)return;let e;f.initialTag?(e=[R.value],await F.editTag(f.initialTag,R.value)):(e=R.value.split(`,`),await F.createTags(e)),p(`submit`,e),B()}function B(){v.value=!1}return l(()=>{R.value=f.initialTag||``}),(i,o)=>(h(),s(E,{modelValue:t(v),"onUpdate:modelValue":o[3]||=e=>n(v)?v.value=e:null},{default:m(()=>[u(S,null,{default:m(()=>[u(D,null,{default:m(()=>[a(g(i.$t(`dialogs.tag.title.${e.initialTag?`rename`:`create`}`)),1)]),_:1}),u(j,null,{default:m(()=>[u(t(M),{ref:`form`,modelValue:I.value,"onUpdate:modelValue":o[1]||=e=>I.value=e,onSubmit:o[2]||=d(()=>{},[`prevent`]),onKeydown:_(d(z,[`prevent`]),[`enter`])},{default:m(()=>[e.initialTag?(h(),s(w,{key:0,"model-value":e.initialTag,disabled:``,label:i.$t(`dialogs.tag.oldName`)},null,8,[`model-value`,`label`])):c(``,!0),u(w,{modelValue:R.value,"onUpdate:modelValue":o[0]||=e=>R.value=e,rules:L.value,autofocus:``,hint:i.$t(`dialogs.tag.hint`),label:i.$t(`dialogs.tag.name`)},null,8,[`modelValue`,`rules`,`hint`,`label`]),u(O,null,{default:m(()=>[e.initialTag&&e.initialTag!==R.value?(h(),r(`div`,N,[u(A,null,{default:m(()=>[...o[4]||=[a(`mdi-alert`,-1)]]),_:1}),a(` `+g(i.$t(`dialogs.tag.warnEdit`)),1)])):c(``,!0)]),_:1})]),_:1},8,[`modelValue`,`onKeydown`])]),_:1}),u(C,null,{default:m(()=>[u(k),u(T,{color:`error`,onClick:B},{default:m(()=>[a(g(i.$t(`common.cancel`)),1)]),_:1}),u(T,{color:`accent`,disabled:!I.value,onClick:z},{default:m(()=>[a(g(i.$t(`common.save`)),1)]),_:1},8,[`disabled`])]),_:1})]),_:1})]),_:1},8,[`modelValue`]))}});export{P as default};