1import{r as a,j as e,m as K,M as W,B as C,a1 as y,a6 as X,a7 as Y,a8 as ee,C as se,a9 as te,c as Z,Q as k,R as ae,h as ie,aa as le,_ as ne,L as re,l as ce,A as oe}from"./index-eb9fe256.js";import{A as de}from"./index-cd96df45.js";import{S as P}from"./index-38950aa7.js";function xe({dismiss:i,title:o,description:l,image:c,author:n}){const[d,p]=a.useState(!0),f=a.useMemo(()=>c?URL.createObjectURL(c):"",[c]);return e.jsx(K,{id:"modal",children:e.jsx(W,{dismiss:()=>{},children:e.jsxs("section",{className:"w-full h-full flex bg-white max-w-[1328px] mx-auto rounded-[10px] flex-col",children:[e.jsxs("header",{className:"flex justify-between md:px-5 px-5 w-full h-[70px] border-b-[1px] items-center shrink-0",children:[e.jsx("span",{className:"font-[700] text-lg",children:"Preview"}),e.jsx("div",{className:"scale scale-150",onClick:i,children:e.jsx(P,{name:"times"})})]}),e.jsxs("section",{className:"md:p-8 p-3 flex-1 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center space-x-3 sticky top-0",children:[e.jsx(C,{className:y("max-w-[200px]",d?"bg-[red]":"bg-[#E0E4EE] text-black"),onClick:()=>p(!0),children:e.jsx("span",{children:"Mobile result"})}),e.jsx(C,{className:y("max-w-[200px]",d?"bg-[#E0E4EE] text-black":"bg-[red]"),onClick:()=>p(!1),children:e.jsx("span",{children:"Desktop result"})})]}),e.jsx("section",{className:"flex-1 lg:p-12 md:p-3 md:pt-0 pt-3",children:e.jsxs("div",{className:y("border-[1px] w-full mx-auto py-4 space-y-5 lg:px-24 md:px-12 px-[20px] rounded-[12px]",d&&"max-w-[375px] px-3"),children:[e.jsx("h1",{className:"font-[700] text-2xl",children:o}),f&&e.jsx("img",{src:f,alt:""}),e.jsx("p",{children:X(l)})]})})]})]})})})}const ue=a.lazy(()=>ne(()=>import("./index-3009f4db.js").then(i=>i.i),["assets/index-3009f4db.js","assets/index-eb9fe256.js","assets/index-79ddea36.css"])),fe=({onFileChange:i,url:o})=>{const[l,c]=a.useState(),[n,d]=a.useState(""),p=j=>{const[r]=j.target.files||[];if(!r)return;c(r);const m=URL.createObjectURL(r);d(m)},f=()=>{c(void 0),d("")};a.useEffect(()=>{i(l)},[l]);async function g(j){try{const r=await fetch(`${ce}/${j}`);if(!r.ok)throw new Error(`Failed to fetch file: ${r.statusText}`);const m=await r.blob(),N=new File([m],j,{type:"image/png"});c(N);const b=URL.createObjectURL(N);d(b)}catch(r){console.error("Error creating file from URL:",r)}}return a.useEffect(()=>{o&&g(o)},[o]),e.jsxs("div",{className:"border border-[color:var(--border-grey)] block",children:[e.jsxs("div",{className:"h-[39px] font-[600] text-[16px] flex items-center px-3 justify-between",children:[e.jsx("span",{children:"Feature Image"}),l&&e.jsx("span",{className:"w-[24px] h-[24px] flex items-center justify-center rounded-full bg-[red] text-white",onClick:f,children:"Ã"})]}),e.jsx("hr",{}),e.jsxs("div",{className:"flex items-center justify-center flex-col h-[200px] relative",children:[e.jsx(P,{name:"img"}),e.jsx(re,{to:"#",className:"text-[blue] underline mt-4 block",children:"Upload image"}),n&&e.jsx("img",{src:n,alt:"",className:"absolute top-0 left-0 w-full h-full object-cover"}),e.jsx("label",{htmlFor:"file",className:"absolute top-0 left-0 w-full h-full"})]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",id:"file",onChange:p})]})};function me(){var A;const[i,o]=a.useState(""),[l,c]=a.useState(""),[n,d]=a.useState(),[p,f]=a.useState(!1),[g,j]=a.useState(""),[r,m]=a.useState(!1),[N,b]=a.useState(!1),[L,{data:v,error:x,isSuccess:R}]=Y(),[U,{data:he,error:pe,isSuccess:I}
1]=ee(),[G]=se(),[h,H]=a.useState(G.get("postId")),[F,Q]=a.useState(""),[E,_]=a.useState("save"),{data:s,isLoading:V}=te(h,{skip:!h}),z=Z();a.useEffect(()=>{var u,w,S,B,M,T,D,O,$;const t=((B=(u=s==null?void 0:s.data)==null?void 0:u.revisions)==null?void 0:B[((S=(w=s==null?void 0:s.data)==null?void 0:w.revisions)==null?void 0:S.length)-1])||(s==null?void 0:s.data);s&&(o((t==null?void 0:t.title)||""),c((t==null?void 0:t.content)||""),Q((($=(O=(M=s==null?void 0:s.data)==null?void 0:M.revisions)==null?void 0:O[((D=(T=s==null?void 0:s.data)==null?void 0:T.revisions)==null?void 0:D.length)-1])==null?void 0:$.id)||""))},[s]);const q=async()=>{if(_("publish"),m(!0),!F){await L({title:i,content:l,file:n,id:h,status:"PUBLISHED"}),m(!1);return}await U({title:i,content:l,file:n,id:F,blogPostId:h,status:"PUBLISHED",isPublished:!0}),m(!1)},J=async()=>{var t;if(_("save"),b(!0),!h||((t=s==null?void 0:s.data)==null?void 0:t.status)==="DRAFT"){await L({title:i,content:l,file:n,id:h,status:"DRAFT"}),b(!1);return}await U({title:i,content:l,file:n,id:F,blogPostId:h,isPublished:!1}),b(!1)};return a.useEffect(()=>{var t;v&&H((t=v==null?void 0:v.data)==null?void 0:t.id)},[v]),a.useEffect(()=>{!R&&!I||(k.success(`Post ${E}${E==="publish"?"e":""}d`),E==="publish"&&setTimeout(()=>z(ae.BLOG_LIST),2e3))},[E,R,I]),a.useEffect(()=>{var t,u,w;x&&Array.isArray((t=x==null?void 0:x.data)==null?void 0:t.message)&&((w=(u=x==null?void 0:x.data)==null?void 0:u.message)==null||w.map(S=>{k.error(S)}))},[x]),e.jsxs(e.Fragment,{children:[V&&e.jsxs("div",{className:"mb-3 mt-8 flex items-center space-x-2",children:[e.jsx(ie,{strokeColor:"black",width:"25"}),e.jsx("span",{children:"Loading revision"})]}),e.jsxs("div",{className:"flex space-x-5 mt-3",children:[e.jsxs("section",{className:"flex-1 flex flex-col space-y-3",children:[e.jsx("input",{type:"text",className:"h-[70px] bg-white font-[600] text-[26px] px-3 border-[0px] outline-none w-full",placeholder:"Add title",value:i,onChange:t=>{const u=le(t.target.value,"Title");if(!u.isValid){k.error(u.message),o("");return}o(t.target.value)}}),e.jsx("div",{className:"h-[400px]",children:e.jsx(ue,{onModelChange:t=>c(t),model:l})})]}),e.jsxs("section",{className:"max-w-[306px] w-full bg-white p-3 space-y-5 h-fit",children:[e.jsx(C,{className:"w-full rounded-[5px] h-[60px] bg-[#FF0000]",onClick:q,disabled:!i&&!l&&!n&&!g,loading:r,children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"mr-5",children:"Publish"}),e.jsx(P,{name:"publish"})]})}),e.jsx(C,{className:"w-full rounded-[5px] h-[60px] bg-transparent border-[1px] border-[#FF0000] text-[#FF0000]",onClick:J,disabled:!i&&!l&&!n&&!g,loading:N,loaderColor:"#FF0000",children:e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"mr-5",children:"Save Changes"})})}),e.jsx(C,{className:"w-full rounded-[5px] h-[60px] bg-[#F1BB31] hover:bg-[#F1BB31] text-black",onClick:()=>f(!0),disabled:!i&&!l&&!n&&!g,children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"mr-5",children:"Preview"}),e.jsx("svg",{width:"22",height:"16",viewBox:"0 0 22 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M11 2.5C14.79 2.5 18.17 4.63 19.82 8C18.17 11.37 14.8 13.5 11 13.5C7.2 13.5 3.83 11.37 2.18 8C3.83 4.63 7.21 2.5 11 2.5ZM11 0.5C6 0.5 1.73 3.61 0 8C1.73 12.39 6 15.5 11 15.5C16 15.5 20.27 12.39 22 8C20.27 3.61 16 0.5 11 0.5ZM11 5.5C12.38 5.5 13.5 6.62 13.5 8C13.5 9.38 12.38 10.5 11 10.5C9.62 10.5 8.5 9.38 8.5 8C8.5 6.62 9.62 5.5 11 5.5ZM11 3.5C8.52 3.5 6.5 5.52 6.5 8C6.5 10.48 8.52 12.5 11 12.5C13.48 12.5 15.5 10.48 15.5 8C15.5 5.52 13.48 3.5 11 3.5Z",fill:"#1E1E1E"})})]})}),e.jsx(fe,{onFileChange:t=>d(t),url:(A=s==null?void 0:s.data)==null?void 0:A.featuredImage})]}),p&&e.jsx(xe,{dismiss:()=>f(!1),author:g,title:i,description:l,image:n})]})]})}function ve(){return Z(),e.jsx(oe,{children:e.jsx(de,{children:e.jsx(me,{})})})}export{ve as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.