import{f as B,b as f,r as X,Q as D,K as b,L as v,O as t,n as l,R as s,P as r,u as T,S as F,T as $,U as w,V as K,W as N}from"./vue-CbNcDebW.js";import{n as R,o as j,p as q,V as E,q as O,r as A,s as C,v as I,x as M,y as z,z as L,A as k,B as Q,C as G}from"./index-Ct76C36l.js";import{V as W}from"./VForm-npRvcQ9U.js";const H={key:0,class:"text-warning"},h=B({__name:"CategoryFormDialog",props:{guid:{},initialCategory:{}},emits:["submit"],setup(i,{emit:S}){const n=i,p=S,{t:g}=R(),V=j(),{isOpened:m}=q(n.guid),U=f(),d=f(!1),P=[e=>!!e||g("dialogs.category.nameRequired")],o=X({name:"",savePath:""});async function y(){d.value&&(n.initialCategory?await V.editCategory(o,n.initialCategory.name===o.name?void 0:n.initialCategory.name):await V.createCategory(o),p("submit",o),c())}function c(){m.value=!1}return D(()=>{o.name=n.initialCategory?.name||"",o.savePath=n.initialCategory?.savePath||""}),(e,a)=>(v(),b(Q,{modelValue:T(m),"onUpdate:modelValue":a[4]||(a[4]=u=>N(m)?m.value=u:null)},{default:t(()=>[l(E,null,{default:t(()=>[l(O,null,{default:t(()=>[s(r(e.$t(`dialogs.category.title.${i.initialCategory?"edit":"create"}`)),1)]),_:1}),l(A,null,{default:t(()=>[l(T(W),{ref_key:"form",ref:U,modelValue:d.value,"onUpdate:modelValue":a[2]||(a[2]=u=>d.value=u),onSubmit:a[3]||(a[3]=$(()=>{},["prevent"])),onKeydown:F($(y,["prevent"]),["enter"])},{default:t(()=>[i.initialCategory?(v(),b(C,{key:0,"model-value":i.initialCategory.name,disabled:"",label:e.$t("dialogs.category.oldName")},null,8,["model-value","label"])):w("",!0),l(C,{modelValue:o.name,"onUpdate:modelValue":a[0]||(a[0]=u=>o.name=u),rules:P,autofocus:!i.initialCategory,label:e.$t("dialogs.category.name")},null,8,["modelValue","autofocus","label"]),l(C,{modelValue:o.savePath,"onUpdate:modelValue":a[1]||(a[1]=u=>o.savePath=u),autofocus:!!i.initialCategory,label:e.$t("dialogs.category.savePath")},null,8,["modelValue","autofocus","label"]),l(I,null,{default:t(()=>[i.initialCategory&&i.initialCategory.name!==o.name?(v(),K("div",H,[l(M,null,{default:t(()=>[...a[5]||(a[5]=[s("mdi-alert",-1)])]),_:1}),s(" "+r(e.$t("dialogs.category.warnEdit")),1)])):w("",!0)]),_:1})]),_:1},8,["modelValue","onKeydown"])]),_:1}),l(z,null,{default:t(()=>[l(L),l(k,{color:"error",onClick:c},{default:t(()=>[s(r(e.$t("common.cancel")),1)]),_:1}),l(k,{color:"accent",disabled:!d.value,onClick:y},{default:t(()=>[s(r(e.$t("common.save")),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]))}}),J={key:0,class:"text-warning"},_=B({__name:"TagFormDialog",props:{guid:{},initialTag:{}},emits:["submit"],setup(i,{emit:S}){const n=i,p=S,{isOpened:g}=q(n.guid),{t:V}=R(),m=G(),U=f(),d=f(!1),P=f([e=>!!e||V("dialogs.tag.required"),e=>!n.initialTag||!!n.initialTag&&!e.includes(",")||V("dialogs.tag.comma")]),o=f("");async function y(){if(!d.value)return;let e;n.initialTag?(e=[o.value],await m.editTag(n.initialTag,o.value)):(e=o.value.split(","),await m.createTags(e)),p("submit",e),c()}function c(){g.value=!1}return D(()=>{o.value=n.initialTag||""}),(e,a)=>(v(),b(Q,{modelValue:T(g),"onUpdate:modelValue":a[3]||(a[3]=u=>N(g)?g.value=u:null)},{default:t(()=>[l(E,null,{default:t(()=>[l(O,null,{default:t(()=>[s(r(e.$t(`dialogs.tag.title.${i.initialTag?"rename":"create"}`)),1)]),_:1}),l(A,null,{default:t(()=>[l(T(W),{ref_key:"form",ref:U,modelValue:d.value,"onUpdate:modelValue":a[1]||(a[1]=u=>d.value=u),onSubmit:a[2]||(a[2]=$(()=>{},["prevent"])),onKeydown:F($(y,["prevent"]),["enter"])},{default:t(()=>[i.initialTag?(v(),b(C,{key:0,"model-value":i.initialTag,disabled:"",label:e.$t("dialogs.tag.oldName")},null,8,["model-value","label"])):w("",!0),l(C,{modelValue:o.value,"onUpdate:modelValue":a[0]||(a[0]=u=>o.value=u),rules:P.value,autofocus:"",hint:e.$t("dialogs.tag.hint"),label:e.$t("dialogs.tag.name")},null,8,["modelValue","rules","hint","label"]),l(I,null,{default:t(()=>[i.initialTag&&i.initialTag!==o.value?(v(),K("div",J,[l(M,null,{default:t(()=>[...a[4]||(a[4]=[s("mdi-alert",-1)])]),_:1}),s(" "+r(e.$t("dialogs.tag.warnEdit")),1)])):w("",!0)]),_:1})]),_:1},8,["modelValue","onKeydown"])]),_:1}),l(z,null,{default:t(()=>[l(L),l(k,{color:"error",onClick:c},{default:t(()=>[s(r(e.$t("common.cancel")),1)]),_:1}),l(k,{color:"accent",disabled:!d.value,onClick:y},{default:t(()=>[s(r(e.$t("common.save")),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]))}});export{_,h as a};
