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