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