import{ax as q,d as H,aA as R,b as s,a7 as E,aB as G,M as g,a8 as j,bq as z,P as _,r as J,_ as L}from"./app-QjDgb7aF.js";import{F as W}from"./suspense-jJyLIr98.js";import{b as $,w as K,f as I,E as x,A as O,j as c,g as h,i as o,k as m,u as a,I as B,J as f,D as r,q as k,p as C,F as Q,G as X,t as Y,l as Z,H as ee,a as v}from"./vue-Cm77DuTi.js";import"./charts-3gEHPHRq.js";import"./media-DuCIZ-3n.js";const te={class:"_formBlock"},le={class:"name"},ae=["onClick","aria-label"],se=$({__name:"edit",props:{postId:{}},setup(b){const y=q(),i=b;let S=v(null),n=v([]),d=v(null),p=v(null),u=v(!1);function w(t){z(t.currentTarget??t.target,null).then(e=>{n.value=n.value.concat(e)})}function M(t){n.value=n.value.filter(e=>e.id!==t.id)}async function V(){if(i.postId)await _("gallery/posts/update",{postId:i.postId,title:p.value,description:d.value,fileIds:n.value.map(t=>t.id),isSensitive:u.value}),y.push(`/gallery/${i.postId}`);else{const t=await _("gallery/posts/create",{title:p.value,description:d.value,fileIds:n.value.map(e=>e.id),isSensitive:u.value});y.push(`/gallery/${t.id}`)}}async function F(){const{canceled:t}=await J({type:"warning",text:s.ts.deleteConfirm});t||(await _("gallery/posts/delete",{postId:i.postId}),y.push("/gallery"))}K(()=>i.postId,()=>{S.value=()=>i.postId?H("gallery/posts/show",{postId:i.postId}).then(t=>{n.value=t.files,p.value=t.title,d.value=t.description,u.value=t.isSensitive}):Promise.resolve(null)},{immediate:!0});const D=I(()=>[]),P=I(()=>[]);return R(I(()=>i.postId?{title:s.ts.edit,icon:"ph-pencil ph-bold ph-lg"}:{title:s.ts.postToGallery,icon:"ph-pencil ph-bold ph-lg"})),(t,e)=>{const T=x("MkPageHeader"),A=x("MkSpacer"),N=x("MkStickyContainer"),U=O("tooltip");return c(),h(N,null,{header:o(()=>[m(T,{actions:D.value,tabs:P.value},null,8,["actions","tabs"])]),default:o(()=>[m(A,{"content-max":800,"margin-min":16,"margin-max":32},{default:o(()=>[m(W,{p:a(S),class:"_formRoot"},{default:o(()=>[m(E,{modelValue:a(p),"onUpdate:modelValue":e[0]||(e[0]=l=>B(p)?p.value=l:p=l),class:"_formBlock"},{label:o(()=>[f(r(a(s).ts.title),1)]),_:1},8,["modelValue"]),m(G,{modelValue:a(d),"onUpdate:modelValue":e[1]||(e[1]=l=>B(d)?d.value=l:d=l),max:500,class:"_formBlock"},{label:o(()=>[f(r(a(s).ts.description),1)]),_:1},8,["modelValue"]),k("div",te,[(c(!0),C(Q,null,X(a(n),l=>(c(),C("div",{key:l.id,class:"wqugxsfx _formBlock",style:Y({backgroundImage:l?`url(${l.thumbnailUrl})`:null})},[k("div",le,r(l.name),1),Z((c(),C("button",{class:"remove _button",onClick:oe=>M(l),"aria-label":a(s).t("remove")},[...e[3]||(e[3]=[k("i",{class:"ph-x ph-bold ph-lg"},null,-1)])],8,ae)),[[U,a(s).ts.remove]])],4))),128)),m(g,{primary:"",onClick:w},{default:o(()=>[e[4]||(e[4]=k("i",{class:"ph-plus ph-bold ph-lg"},null,-1)),f(" "+r(a(s).ts.attachFile),1)]),_:1})]),m(j,{modelValue:a(u),"onUpdate:modelValue":e[2]||(e[2]=l=>B(u)?u.value=l:u=l),class:"_formBlock"},{default:o(()=>[f(r(a(s).ts.markAsSensitive),1)]),_:1},8,["modelValue"]),b.postId?(c(),h(g,{key:0,primary:"",onClick:V,class:"_formBlock"},{default:o(()=>[e[5]||(e[5]=k("i",{class:"ph-floppy-disk-back ph-bold ph-lg"},null,-1)),f(" "+r(a(s).ts.save),1)]),_:1})):(c(),h(g,{key:1,primary:"",onClick:V,class:"_formBlock"},{default:o(()=>[e[6]||(e[6]=k("i",{class:"ph-floppy-disk-back ph-bold ph-lg"},null,-1)),f(" "+r(a(s).ts.publish),1)]),_:1})),b.postId?(c(),h(g,{key:2,danger:"",onClick:F,class:"_formBlock"},{default:o(()=>[e[7]||(e[7]=k("i",{class:"ph-trash ph-bold ph-lg"},null,-1)),f(" "+r(a(s).ts.delete),1)]),_:1})):ee("",!0)]),_:1},8,["p"])]),_:1})]),_:1})}}}),ue=L(se,[["__scopeId","data-v-c724bfdb"]]);export{ue as default};
//# sourceMappingURL=edit-DboivJ_a.js.map
