PageSourceSearch

https://ai.automateed.com/assets/index-1716c6f5.js

js automateed.com collected 2026-10-01 13:07:38 UTC 28,594 bytes, 1 lines download raw bytes

1import{j as e,i as s,r as t,D as a,c as r,d as l,f as i,B as o,C as n,T as d,_ as c,m as u,n as m,o as x}from"./mui-7de4f23d.js";import{d as p}from"./ArrowBack-99f700d8.js";import{d as b}from"./RocketLaunch-3630dcbe.js";import{r as g,i as h}from"./createSvgIcon-e6c3e379.js";import{d as f}from"./MenuBook-6cf41c2b.js";import{a as j,c as v}from"./react-vendor-60cd4be3.js";import{u as N}from"./useApi-0ea0f466.js";import{c as y,a as w,b as k,d as C,u as _,o as S}from"./yup-57efa774.js";import{C as P}from"./CreateTitleImage-43480db4.js";import{C as B}from"./compressor.esm-884e5c3a.js";import{u as E,q as I}from"./index-bcc72886.js";import{d as z}from"./FileUpload-bdc6b435.js";import{I as $}from"./ImageCropper-de41e77e.js";import{a as A}from"./axios-c6845f15.js";import{B as T}from"./BackdropLoading-3b845af5.js";import{d as q}from"./AutoAwesome-08baa68b.js";import{P as U}from"./PaperbackPublishOption-25888d3d.js";import{d as L}from"./SentimentVeryDissatisfied-0a5e7145.js";import{d as F}from"./Warning-72c6b88d.js";import"./axiosInstance-7d68db82.js";import"./Image-43beabec.js";import"./CoverTemplateSelector-ab2ebfae.js";import"./Close-66ab3496.js";import"./CheckCircle-cf78a038.js";import"./LocalPrintshop-2ed39129.js";var M={},W=h;Object.defineProperty(M,"__esModule",{value:!0});var D=M.default=void 0,O=W(g()),V=e,R=(0,O.default)((0,V.jsx)("path",{d:"M12 12.75c1.63 0 3.07.39 4.24.9 1.08.48 1.76 1.56 1.76 2.73V18H6v-1.61c0-1.18.68-2.26 1.76-2.73 1.17-.52 2.61-.91 4.24-.91zM4 13c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm1.13 1.1c-.37-.06-.74-.1-1.13-.1-.99 0-1.93.21-2.78.58C.48 14.9 0 15.62 0 16.43V18h4.5v-1.61c0-.83.23-1.61.63-2.29zM20 13c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm4 3.43c0-.81-.48-1.53-1.22-1.85-.85-.37-1.79-.58-2.78-.58-.39 0-.76.04-1.13.1.4.68.63 1.46.63 2.29V18H24v-1.57zM12 6c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3z"}),"Groups");function G(){const t=j(),{type:a,id:r}=v();return e.jsxs("div",{className:"bg-[#070B2E] w-screen relative overflow-hidden -ml-[calc(50vw-50%)] lg:-ml-[240px]",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 left-1/4 w-[300px] h-[300px] lg:w-[500px] lg:h-[500px] bg-blue-500/20 rounded-full mix-blend-multiply filter blur-3xl animate-blob"}),e.jsx("div",{className:"absolute top-0 right-1/4 w-[300px] h-[300px] lg:w-[500px] lg:h-[500px] bg-purple-500/20 rounded-full mix-blend-multiply filter blur-3xl animate-blob animation-delay-2000"}),e.jsx("div",{className:"absolute -bottom-8 left-1/2 w-[300px] h-[300px] lg:w-[500px] lg:h-[500px] bg-pink-500/20 rounded-full mix-blend-multiply filter blur-3xl animate-blob animation-delay-4000"}),e.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 1px 1px, rgba(255,255,255,0.05) 1px, transparent 0)",backgroundSize:"24px 24px"}})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"px-0 sm:px-6 lg:pl-[240px] lg:px-8 pt-4",children:e.jsx("div",{className:"px-4 sm:px-0",children:e.jsx(s,{className:"!bg-white/10 hover:!bg-white/20",onClick:()=>t(`/detail/${a}/${r}`),children:e.jsx(p,{className:"text-white/80"})})})}),e.jsx("div",{className:"px-0 sm:px-6 lg:pl-[240px] lg:px-8 py-8 lg:py-20",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-0",children:e.jsxs("div",{className:"grid lg:grid-cols-2 gap-8 lg:gap-20",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute -top-4 -left-2 lg:-top-8 lg:-left-4 pointer-events-none select-none",children:e.jsx("div",{className:"text-white/5 text-[80px] lg:text-[120px] font-bold leading-none",children:"PUBLISH"})}),e.jsxs("h1",{className:"relative text-3xl sm:text-4xl lg:text-6xl font-bold",children:[e.jsx("span",{className:"text-white",children:"Publish Your"}),e.jsx("span",{className:"block mt-2 bg-gradient-to-r from-purple-400 to-pink-400 text-transparent bg-clip-text",children:"Book Today"})]})]}),e.jsx("p",{className:"mt-4 lg:mt-6 text-base lg:text-lg text-blue-100/80 max-w-xl",children:"Share your story with the world. Our platform makes it easy to publish and sell your book to readers worldwide."}),e.jsxs("div",{className:"mt-8 lg:mt-12 grid grid-cols-3 gap-3 lg:gap-8",children:[e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-blue-500/10 to-purple-500/10 rounded-lg lg:rou
1nded-xl blur-md lg:blur-lg group-hover:blur-xl transition-all duration-300"}),e.jsxs("div",{className:"relative bg-white/5 backdrop-blur-sm rounded-lg lg:rounded-xl px-3 lg:px-4 py-4 lg:py-6 border border-white/10",children:[e.jsx("div",{className:"text-xl lg:text-3xl font-bold text-white",children:"50K+"}),e.jsx("div",{className:"text-xs lg:text-sm text-blue-100/60",children:"Authors"})]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-purple-500/10 to-pink-500/10 rounded-lg lg:rounded-xl blur-md lg:blur-lg group-hover:blur-xl transition-all duration-300"}),e.jsxs("div",{className:"relative bg-white/5 backdrop-blur-sm rounded-lg lg:rounded-xl px-3 lg:px-4 py-4 lg:py-6 border border-white/10",children:[e.jsx("div",{className:"text-xl lg:text-3xl font-bold text-white",children:"1M+"}),e.jsx("div",{className:"text-xs lg:text-sm text-blue-100/60",children:"Readers"})]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-pink-500/10 to-red-500/10 rounded-lg lg:rounded-xl blur-md lg:blur-lg group-hover:blur-xl transition-all duration-300"}),e.jsxs("div",{className:"relative bg-white/5 backdrop-blur-sm rounded-lg lg:rounded-xl px-3 lg:px-4 py-4 lg:py-6 border border-white/10",children:[e.jsx("div",{className:"text-xl lg:text-3xl font-bold text-white",children:"4.9"}),e.jsx("div",{className:"text-xs lg:text-sm text-blue-100/60",children:"Rating"})]})]})]})]}),e.jsxs("div",{className:"space-y-3 lg:space-y-4 mt-6 lg:mt-0",children:[e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-blue-500/10 to-indigo-500/10 rounded-lg lg:rounded-xl blur-md lg:blur-lg group-hover:blur-xl transition-all duration-300"}),e.jsx("div",{className:"relative bg-white/5 backdrop-blur-sm rounded-lg lg:rounded-xl p-4 lg:p-6 border border-white/10 hover:bg-white/10 transition-colors",children:e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("div",{className:"w-10 h-10 lg:w-12 lg:h-12 rounded-lg lg:rounded-xl bg-gradient-to-br from-blue-400 to-indigo-400 flex items-center justify-center",children:e.jsx(b,{className:"text-white h-5 w-5 lg:h-6 lg:w-6"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base lg:text-lg font-semibold text-white",children:"Professional Publishing"}),e.jsx("p",{className:"mt-1 text-sm lg:text-base text-blue-100/60",children:"Industry-standard formatting and design"})]})]})})]}),e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-purple-500/10 to-pink-500/10 rounded-lg lg:rounded-xl blur-md lg:blur-lg group-hover:blur-xl transition-all duration-300"}),e.jsx("div",{className:"relative bg-white/5 backdrop-blur-sm rounded-lg lg:rounded-xl p-4 lg:p-6 border border-white/10 hover:bg-white/10 transition-colors",children:e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("div",{className:"w-10 h-10 lg:w-12 lg:h-12 rounded-lg lg:rounded-xl bg-gradient-to-br from-purple-400 to-pink-400 flex items-center justify-center",children:e.jsx(D,{className:"text-white h-5 w-5 lg:h-6 lg:w-6"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base lg:text-lg font-semibold text-white",children:"Global Distribution"}),e.jsx("p",{className:"mt-1 text-sm lg:text-base text-blue-100/60",children:"Reach readers worldwide"})]})]})})]}),e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-pink-500/10 to-red-500/10 rounded-lg lg:rounded-xl blur-md lg:blur-lg group-hover:blur-xl transition-all duration-300"}),e.jsx("div",{className:"relative bg-white/5 backdrop-blur-sm rounded-lg lg:rounded-xl p-4 lg:p-6 border border-white/10 hover:bg-white/10 transition-colors",children:e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("div",{className:"w-10 h-10 lg:w-12 lg:h-12 rounded-lg lg:rounded-xl bg-gradient-to-br from-pink-400 to-red-400 flex items-center justify-center",children:e.jsx(f,{className:"text-white h-5 w-5 lg:h-6 lg:w-6"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base lg:text-lg font-semibold text-white",children:"Easy Publishing"}),e.jsx("p",{className:"mt-1 text-sm lg:text-base text-blue-100/60",children:"Simple step-by-step process"})]})]})})]})]})]})})})]})]})}function H({ebook_id:s,recall:n=()=>{},btnText:d="Upload Cover Image",className:c}){const u=t.useRef(null),{enqueueSnackbar:m}=E(),{apiCall:x,loading:p,response:b,error:g}=N("post"),[h,f]=t.useState(null),[j,v]=t.useState(!1),[y,w]=t.useState(null),k=()=>{w(null),f(null),u.current&&(u.current.value=null)};return t.useEffect(()=>{b?.data&&(m(b?.data?.msg||"Image uploaded successfully",{variant:"success"}),n(),k())},[b]),t.useEffect(()=>{g&&(m(g?.response?.data?.msg||"Image upload failed",{variant:"error"}),k())},[g]),e.jsxs("div",{children:[y&&e.jsxs(a,{open:Boolean(y),onClose:k,fullWidth:!0,maxWidth:"md","aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsx(r,{id:"alert-dialog-title",children:"Are you sure to update this cover?"}),e.jsx(l,{children:e.jsx("div",{className:"flex justify-center",children:e.jsx($,{image:y,onChange:e=>f(e)})})}),e.jsxs(i,{children:[e.jsx(o,{onClick:k,children:"Cancel"}),e.jsx(o,{onClick:()=>{h&&new B(y,{quality:.1,success(e){const t=new FormData;t.append("image",h),v(!0),A({url:`https://server.automateed.com/api/ebook/upload-cover-image/${s}`,method:"POST",data:t,headers:{"Content-Type":"multipart/form-data"}}).then(e=>{v(!1),m(e?.data?.msg||"Image uploaded successfully",{variant:"success"}),n(),k()}).catch(e=>{m(e?.response?.data?.msg||"Image upload failed",{variant:"error"}),k()}).finally(()=>{v(!1),k()})},error(e){m("Failed to compress image. Try again.",{variant:"error"})}})},autoFocus:!0,variant:"contained",disabled:p||!h,children:p?"Uploading. Please wait...":"Upload"})]})]}),e.jsx("input",{ref:u,type:"file",id:"upload-cover-input",className:"hidden",accept:"image/*",onChange:e=>{const s=e.target.files[0];s&&new B(s,{quality:.1,success(e){w(e)},error(e){}})}}),e.jsxs("label",{htmlFor:"upload-cover-input",className:`px-4 py-1 bg-white text-blue-600 text-sm flex items-center space-x-2 rounded-lg mt-2 cursor-pointer w-48 ${c}`,children:[e.jsx(z,{fontSize:"30"}),d]})]})}D=M.default=R;const Y="https://automateed.s3.eu-west-2.amazonaws.com",J=(e,s)=>{if(!e)return null;const t=String(e).replace(/^\/+/,"");return t.startsWith("http")||t.startsWith("data:")?t:t.includes("/")?`${Y}/${t}`:`${Y}/${s}/${t}`};function K({ebook:s,getEbook:t,error:a=""}){let r=null;return s?.custom_image?r=J(s.custom_image,"ai-images"):s?.image?r=J(s.image,"ebook"):(s?.cover_image||s?.coverImage||s?.cover_url||s?.coverUrl||s?.cover_image_url)&&(r=J(s.cover_image||s.coverImage||s.cover_url||s.coverUrl||s.cover_image_url,"ai-images")),e.jsxs("div",{children:[e.jsx("div",{className:"aspect-[1/1.6] w-full max-w-[300px] bg-gray-100 rounded-2xl flex items-center justify-center overflow-hidden relative group hover:shadow-lg transition-shadow duration-300",children:r?e.jsxs("div",{className:"relative w-full h-full",children:[e.jsx("img",{className:"w-full h-full object-cover",src:r,alt:s?.name||"Book Cover",crossOrigin:"anonymous",onError:e=>{}}),e.jsx("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-center justify-center",children:e.jsx(H,{ebook_id:s?.id,btnText:"Change Cover",className:"text-sm bg-white/20 hover:bg-white/30 text-white border border-white/50 px-4 py-2 rounded-lg backdrop-blur-sm transition-all",recall:t})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 p-6 text-center",children:[e.jsx("div",{className:"text-gray-400 mb-2",children:e.jsx("svg",{className:"w-16 h-16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Create an eye-catching cover for your book"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{ebook_id:s?.id,btnText:"Generate with AI",recall:t,className:"w-full bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg transition-colors text-sm"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-gray-300"})}),e.jsx("div",{className:"relative flex justify-center text-sm",children:e.jsx("span",{className:"px-2 bg-gray-100 text-gray-500",children:"or"})})]}),e.jsx(H,{ebook_id:s?.id,btnText:"Upload Image",className:"w-full bg-white border border-gray-300 text-gray-700 hover:bg-gray-50 px-4 py-2 rounded-lg transition-colors text-sm",recall:t})]})]})}),a&&e.jsx("p",{className:"mt-2 text-sm text-red-500",children:a})]})}function Q({ebook:s,getEbook:a,getPublisher:r,publisher:l}){const i=j(),{type:o,id:d}=v(),[c,u]=t.useState([]),[m,x]=t.useState(null);t.useState(!1);const p=Boolean(s?.audio_book),[b,g]=t.useState(!1),[h,f]=t.useState(""),[P,B]=t.useState(!1),E=!0===s?.audiobook_included||1===Number(s?.audiobook_included),z=Number(s?.audiobook_price),$=Number.isFinite(z)?`$${z.toFixed(2)}`:"its configured price",A=""===h?null:Number(h),L=Boolean(s?.isPublished&&(b!==E||b&&E&&A!==z)),{apiCall:F,loading:M,response:W,error:D}=N("post"),{apiCall:O,loading:V,response:R,error:G}=N("get"),{apiCall:H,loading:Y}=N("put"),{apiCall:J,loading:Q,response:X,error:ee}=N("get");t.useEffect(()=>{J("/api/books-categories")},[]),t.useEffect(()=>{200===X?.status&&u(X?.data?.data),ee?.response&&I(ee?.response?.data?.msg||"Internal server error",{variant:"error"})},[X,ee]),t.useEffect(()=>{200===R?.status&&(le("about",R?.data?.data?.aboutText),I("About of book created",{variant:"success"}),a())},[R]),t.useEffect(()=>{G?.response&&I(G?.response?.data?.msg||"Generating about of book is failed",{variant:"error"})},[G]);const se=y().shape({name:w().required("Please enter your name"),about:w().required("Please enter your about"),price:k().required("Please enter price").test("is-number","Price must be a number",e=>null!=e&&""!==e&&!isNaN(e)).test("is-zero-or-positive","Price cannot be negative",e=>null!=e&&""!==e&&Number(e)>=0),checkout_url:w().optional().nullable(),hasCover:C().oneOf([!0],"Please create or upload image before publishing Book").required("Please create or upload image before publishing Book")}),{handleSubmit:te,formState:ae,register:re,setValue:le,setError:ie,watch:oe,clearErrors:ne}=_({mode:"onChange",defaultValues:{name:"",about:"",price:"",checkout_url:"",hasCover:!1},resolver:S(se)}),{errors:de,dirtyFields:ce,isValid:ue}=ae,me=oe();return t.useEffect(()=>{200===W?.status&&(I(W?.data?.msg||"Success",{variant:"success"}),P&&H(`/api/publisher-sites/products/ebook/${d}/print`,{enabled:!1,request_print_setup:!0,title:me.name||s?.name||"Untitled book",currency:"USD"}).then(e=>{I(e?.data?.msg||"Paperback setup started. We'll enable it automatically after validation.",{variant:"success"})}).catch(e=>{I(e?.response?.data?.msg||"Book published, but we couldn't save the paperback request.",{variant:"warning"})}),r())},[W]),t.useEffect(()=>{if(D?.response){const s=D?.response?.data?.msg;s.includes("Stripe")?I(s,{variant:"error",action:s=>e.jsx("button",{onClick:()=>i("/publisher/settings"),className:"text-white hover:underline",children:"Go to Settings"})}):I(s||"Internal server error",{variant:"error"})}},[D]),t.useEffect(()=>{if(s){const e=Boolean(s.image||s.custom_image||s.cover_image||s.coverImage||s.cover_url||s.coverUrl||s.cover_image_url);le("name",s.name),le("about",s.about),le("hasCover",e,{shouldValidate:!0}),e&&ne("hasCover"),le("price",s.price),le("checkout_url","");const t=!0===s.audiobook_included||1===Number(s.audiobook_included);g(t),f(t&&null!==s.audiobook_price&&void 0!==s.audiobook_price?String(s.audiobook_price):""),Object.keys(s).forEac
1h(e=>{s[e]&&ne(e)})}},[s]),e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsx(T,{loading:M,message:"Publishing ebook."}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-gray-100",children:[e.jsx("div",{className:"border-b border-gray-100 p-6",children:e.jsxs("div",{className:"flex items-center justify-between max-w-3xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-green-500 text-white flex items-center justify-center text-sm font-medium",children:"1"}),e.jsx("span",{className:"text-sm mt-2 text-gray-600",children:"Book Cover"})]}),e.jsx("div",{className:"flex-1 h-[2px] bg-gray-200 mx-4"}),e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-green-500 text-white flex items-center justify-center text-sm font-medium",children:"2"}),e.jsx("span",{className:"text-sm mt-2 text-gray-600",children:"Details"})]}),e.jsx("div",{className:"flex-1 h-[2px] bg-gray-200 mx-4"}),e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-500 text-white flex items-center justify-center text-sm font-medium",children:"3"}),e.jsx("span",{className:"text-sm mt-2 text-gray-600",children:"Publish"})]})]})}),e.jsx("form",{id:"publish-ebook-form",className:"p-6",onSubmit:te(e=>{const s={name:e.name,about:e.about,category_id:m?.id};if(s.price=e.price,p&&(s.include_audiobook=b,b)){const e=Number(h);if(isNaN(e)||e<0)return void I("Please enter a valid audiobook price (0 or more)",{variant:"error"});s.audiobook_price=e}F(`/api/publish-ebook/${d}`,s)}),children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx("input",{type:"hidden",...re("hasCover")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"bg-gray-50 rounded-xl p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Book Cover"}),e.jsx(K,{ebook:s,getEbook:a,error:de?.hasCover?.message})]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Book Title"}),e.jsx("input",{...re("name"),type:"text",placeholder:"Enter your book title",className:"w-full px-4 py-3 rounded-lg border border-gray-200 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all outline-none"}),de?.name&&e.jsx("p",{className:"mt-2 text-sm text-red-500",children:de.name.message})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Book Description"}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{...re("about"),placeholder:"Write a compelling description of your book...",rows:6,className:"w-full px-4 py-3 rounded-lg border border-gray-200 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all outline-none resize-none"}),!s?.about&&e.jsxs("button",{type:"button",disabled:V,onClick:e=>{e.preventDefault(),O(`/api/generate-about-book/${s.id}`)},className:"absolute bottom-3 right-3 inline-flex items-center px-4 py-2 rounded-lg bg-blue-50 text-blue-600 text-sm font-medium hover:bg-blue-100 transition-colors disabled:opacity-50",children:[V?e.jsx(n,{size:16,className:"mr-2"}):e.jsx(q,{fontSize:"small",className:"mr-2"}),"Generate with AI"]})]}),de?.about&&e.jsx("p",{className:"mt-2 text-sm text-red-500",children:de.about.message})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Price"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500",children:"$"}),e.jsx("input",{...re("price"),type:"number",step:"0.01",min:"0",placeholder:"Enter price (0 for free, e.g. 9.99)",className:"w-full pl-6 pr-4 py-3 rounded-lg border border-gray-200 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all outline-none"})]}),de?.price&&e.jsx("p",{className:"mt-2 text-sm text-red-500",children:de.price.message})]}),e.jsx("div",{className:"bg-purple-50 border border-purple-200 rounded-xl p-4",children:p?e.jsxs(e.Fragment,{children:[s?.isPublished&&e.jsxs("div",{className:"mb-3 rounded-lg border px-3 py-2 text-sm "+(E?"border-emerald-200 bg-emerald-50 text-emerald-800":"border-amber-200 bg-amber-50 text-amber-800"),children:[e.jsx("span",{className:"font-semibold",children:E?`Currently live for sale as a ${$} add-on`:"Currently not offered for sale"}),e.jsx("span",{className:"block mt-0.5 text-xs opacity-80",children:E?"Buyers can add it from this book's public page and checkout.":"The audiobook exists, but buyers cannot add it until you enable it below."}),L&&e.jsx("span",{className:"block mt-2 border-t border-current/20 pt-2 text-xs font-semibold",children:"Unsaved change. Click Save Publishing Changes to update what buyers see."})]}),e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:b,onChange:e=>g(e.target.checked),className:"mt-1 h-5 w-5 accent-purple-600"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-semibold text-gray-900",children:"🎧 Sell the audiobook as an add-on"}),e.jsx("span",{className:"block text-xs text-gray-600",children:"Buyers can add the audio version of your book at checkout. A free public sample (~90 seconds) will be shown on your book page."})]})]}),b&&e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Audiobook Price"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500",children:"$"}),e.jsx("input",{type:"number",step:"0.01",min:"0",value:h,onChange:e=>f(e.target.value),placeholder:"Enter add-on price (0 for free, e.g. 4.99)",className:"w-full pl-6 pr-4 py-3 rounded-lg border border-gray-200 focus:ring-2 focus:ring-purple-500 focus:border-transparent transition-all outline-none"})]})]})]}):e.jsxs("p",{className:"text-sm text-gray-600",children:["🎧 ",e.jsx("span",{className:"font-semibold",children:"Want to sell an audiobook too?"})," ","Create the audiobook for this book first (Book page → Audiobook), then come back here to publish it as a paid add-on."]})}),e.jsx(U,{checked:P,onChange:B,disabled:M||Y}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Categories"}),e.jsx(Z,{options:c,selectedCategory:m,onSelectCategory:e=>x(e)})]})]})]}),e.jsx("div",{className:"mt-8 flex justify-end",children:e.jsx("button",{type:"submit",form:"publish-ebook-form",disabled:Object.keys(de).length||M,className:"inline-flex items-center px-6 py-3 rounded-lg bg-blue-600 text-white font-medium hover:bg-blue-700 transition-colors disabled:opacity-50 disabled:hover:bg-blue-600",children:M?e.jsxs(e.Fragment,{children:[e.jsx(n,{size:16,className:"mr-2"}),"Publishing..."]}):s?.isPublished?"Save Publishing Changes":"Publish Book"})})]})})]})]})}function Z({options:s,onSelectCategory:a,selectedCategory:r}){const[l,i]=t.useState(""),o=s.filter(e=>e.name.toLowerCase().includes(l.toLowerCase()));return e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{value:l,onCh
1ange:e=>i(e.target.value),placeholder:"Search categories...",variant:"outlined",fullWidth:!0,margin:"normal"}),r&&e.jsx(c,{label:r.name,onDelete:()=>a(null),color:"primary",variant:"outlined",className:"mb-2"}),e.jsx(u,{style:{maxHeight:"200px",overflowY:"auto"},children:o.map(s=>e.jsx(m,{button:!0,onClick:()=>(e=>{a(e)})(s),selected:r?.id===s.id,children:e.jsx(x,{primary:s.name})},s.id))})]})}function X(){const s=j(),{type:a,id:r}=v(),[l,i]=t.useState(null),[o,n]=t.useState(null),{apiCall:d,loading:c,response:u,error:m}=N("get"),{apiCall:x,loading:p,response:b,error:g}=N("get"),h=()=>{d(`/api/get/ebook/${r}`)},f=()=>{x("/api/publisher/profile")};t.useEffect(()=>{f()},[]),t.useEffect(()=>{200===b?.status&&(n(b?.data?.publisher),h())},[b,r]),t.useEffect(()=>{i(200===u?.status?u?.data?.ebook:null)},[u]);const y=()=>!!o&&!!o.stripe_account_id&&"active"===o.stripe_account_status&&1===o.stripe_charges_enabled&&1===o.stripe_payouts_enabled&&1===o.stripe_details_submitted;return m?e.jsx("div",{style:{height:"80vh"},className:"flex items-center justify-center bg-red-50",children:e.jsxs("div",{className:"max-w-md p-6 bg-white shadow-lg rounded-lg border border-red-200",children:[e.jsx("h1",{className:"text-2xl font-bold text-red-600 mb-2",children:m?.response?.data?.msg||"Backend request failed"}),e.jsx("p",{className:"text-red-500",children:"Please refresh the page or contact the admin for assistance."}),e.jsx("button",{onClick:()=>s("/list/ebook"),className:"mt-4 px-4 py-2 bg-blue-500 text-white font-bold rounded hover:bg-blue-700 transition duration-300",children:"Back to Books"})]})}):e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx(G,{}),e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pb-12",children:o?o&&("platform_royalty"===o.payout_mode||!o.stripe_account_id)||y()||y()?e.jsx(Q,{ebook:l,publisher:o,getEbook:h,getPublisher:f}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 bg-white shadow-md rounded-lg",children:[e.jsx("div",{className:"bg-gradient-to-r from-amber-500 to-amber-600 text-white p-6 rounded-full mb-4",children:e.jsx(F,{style:{fontSize:"48px"}})}),e.jsx("p",{className:"text-lg font-semibold text-gray-800 mb-4",children:"Your Stripe account needs to be fully activated."}),e.jsx("p",{className:"text-gray-600 mb-6 text-center max-w-md",children:"To publish books and receive payments, you need to complete your Stripe account setup. Please ensure all required information is submitted and your account is fully activated."}),e.jsxs("div",{className:"space-y-3 mb-6 text-left",children:["active"!==o.stripe_account_status&&e.jsxs("div",{className:"flex items-center text-red-500",children:[e.jsx(F,{className:"mr-2"}),e.jsx("span",{children:"Stripe account is not active"})]}),1!==o.stripe_charges_enabled&&e.jsxs("div",{className:"flex items-center text-red-500",children:[e.jsx(F,{className:"mr-2"}),e.jsx("span",{children:"Charges are not enabled"})]}),1!==o.stripe_payouts_enabled&&e.jsxs("div",{className:"flex items-center text-red-500",children:[e.jsx(F,{className:"mr-2"}),e.jsx("span",{children:"Payouts are not enabled"})]}),1!==o.stripe_details_submitted&&e.jsxs("div",{className:"flex items-center text-red-500",children:[e.jsx(F,{className:"mr-2"}),e.jsx("span",{children:"Required details are not submitted"})]})]}),e.jsx("button",{onClick:()=>s("/publisher/profile"),className:"px-6 py-3 bg-amber-600 hover:bg-amber-700 text-white font-medium rounded-lg shadow-lg transition duration-300",children:"Complete Stripe Setup"}),e.jsx("div",{className:"mt-8 w-full max-w-lg rounded-lg border border-blue-200 bg-blue-50 p-4 text-sm text-blue-900",children:"Prefer Automateed payouts instead? Open your publisher profile and choose “Let Automateed pay me” to publish without Stripe Connect."})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 bg-white shadow-md rounded-lg",children:[e.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-indigo-500 text-white p-6 rounded-full mb-4",children:e.jsx(L,{style:{fontSize:"48px"}})}
1),e.jsx("p",{className:"text-lg font-semibold text-gray-800 mb-4",children:"Your publisher profile is not created."}),e.jsx("p",{className:"text-gray-600 mb-6 text-center",children:"Please create your publisher profile to publish the book and start sharing your stories with the world."}),e.jsx("button",{onClick:()=>s("/publisher/profile"),className:"px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg shadow-lg transition duration-300",children:"Create Publisher Profile"})]})})]})}export{X 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.