import{r as s,j as o}from"./app-BwDemWQz.js";import{A as q}from"./AppLayout-3zbhnyYw.js";import{u as z}from"./LanguageContext-zkEAKPTE.js";import{C as B}from"./Composer-CExGpSXC.js";/* empty css            */import"./index-DxJALBsh.js";import"./Button-B-KWyoQR.js";import"./createLucideIcon-BASx8f0E.js";import"./Label-1lm7x8-L.js";import"./Input-BJaxI6jp.js";import"./index-CkDmAPFS.js";import"./zap-BsHQ4DWF.js";import"./rocket-Dt03WmgU.js";import"./users-g1HvrzO9.js";import"./globe-C_ZhZ5i9.js";import"./emoji-picker-react.esm-C2auypZg.js";import"./search-sQ0SJSXK.js";import"./Select-CfDsuz_M.js";import"./index-B0gxmCHE.js";import"./sparkles-BNcnDUCn.js";import"./arrow-right-Ctvx1a-x.js";import"./save-efCvtXyR.js";import"./download-Bp5_-seZ.js";import"./info-CEE4pHon.js";import"./upload-B-3i7Erd.js";import"./link-BuvjkyeI.js";import"./clock-BJENbNTm.js";import"./chevron-left-BxYqeqJW.js";function Ce({post:t,platforms:y,accounts:F,media:b,post_templates:T,ai_templates:j,ai_modules:k}){const i=z(),E=s.useRef(null),[v,r]=s.useState(""),[c,l]=s.useState({}),[d,m]=s.useState([]),[p,u]=s.useState({}),[h,f]=s.useState([]),[x,g]=s.useState(!1),[C,P]=s.useState(null),[M,L]=s.useState([]),[N,A]=s.useState("facebook");s.useEffect(()=>{if(t&&(r(t.content||""),l(t.postTypes||{}),m(t.files||[]),f(t.links||[]),g(t.is_scheduled==="1"),P(t.scheduled_time),L(t.accounts||[]),A(t.activePlatform||"facebook"),t.files)){const e={};t.files.forEach(a=>{a.caption&&(e[a.id]=a.caption)}),u(e)}},[t]);const _=[{label:"Home",href:"user.home"},{label:"Posts",href:"user.post.index"},{label:"Edit Post"}],w=e=>{r(e)},D=(e,a)=>{l(n=>({...n,[e]:a}))},R=e=>{m(e)},H=(e,a)=>{u(n=>({...n,[e]:a}))},I=e=>{f(e)},O=(e,a)=>{g(e),P(a)},S=()=>{const e=d.map((n,U)=>({...n,caption:p[n.id]||"",order:U+1}));return{id:t.id??null,postTypes:c,content:v,files:e,links:h,is_scheduled:x?"1":"0",scheduled_time:C,is_draft:"0"}};return E.current=S,o.jsx(q,{breadcrumbs:_,children:o.jsxs("div",{className:"flex-1 p-6 overflow-auto bg-gray-50 dark:bg-black",children:[o.jsx("div",{className:"flex items-center justify-between flex-wrap gap-4 mb-6",children:o.jsxs("div",{className:"space-y-1",children:[o.jsx("h1",{className:"text-xl sm:text-xl sm:text-2xl dark:text-gray-200 font-bold",children:i("Edit Template")}),o.jsx("p",{className:"text-gray-500 dark:text-gray-200",children:i("Update your post content and settings")})]})}),o.jsx("div",{className:"max-w-full mx-auto",children:o.jsx(B,{isTemplate:!0,isEdit:!0,t:i,platform:N,selectedAccounts:M,media:b,onPostContentChange:w,onPostTypeChange:D,platformPostTypes:c,selectedMedia:d,onSelectedMediaChange:R,mediaCaptions:p,onMediaCaptionChange:H,links:h,onLinksChange:I,onPost:S,onSchedulingChange:O,isScheduled:x,scheduledTime:C,platforms:y,postTemplateList:T,aiTemplateList:j,exisitngDataOnEdit:t,ai_modules:k})})]})})}export{Ce as default};
