Yogesh commited on
Commit
d803eb4
·
1 Parent(s): edadcea

feat: compile and optimize 120-page pdf and TOC slicer

Browse files
assets/{index-4x_ttUEu.js → index-bJnV20--.js} RENAMED
@@ -589,10 +589,7 @@ List exactly 7 targeted backend search keywords separated by commas.
589
  [DESCRIPTION]
590
  Write a high-converting HTML description. Use <h3> for headers and <ul>/<li> for bullet lists. Detail what makes the book unique, what's inside, and print specifications (e.g. 6x9 size, matte cover).
591
 
592
- Start writing now:`;try{let t=await fetch(`${C}/api/generate-text`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prompt:e,maxTokens:900})});if(!t.ok)throw Error(`Failed to generate. Make sure your Hugging Face Space is running and HF_API_KEY is configured.`);let r=(await t.json()).text,i=r.match(/\[TITLE\]\n?([\s\S]*?)(?=\[SUBTITLE\])/i),a=r.match(/\[SUBTITLE\]\n?([\s\S]*?)(?=\[KEYWORDS\])/i),o=r.match(/\[KEYWORDS\]\n?([\s\S]*?)(?=\[DESCRIPTION\])/i),s=r.match(/\[DESCRIPTION\]\n?([\s\S]*)/i),c=i?i[1].trim():`${n} Guide`,u=a?a[1].trim():`The Ultimate Guide to Mastering Your Skills - High-Impact Keywords Included`,d=(o?o[1].trim():`kdp book, self education, guide, journal`).split(`,`).map(e=>e.trim()).filter(e=>e.length>0).slice(0,7),f=s?s[1].trim():`<h3>📚 Discover the ultimate guide to ${n}!</h3>`;l({title:c,subtitle:u,keywords:d.length>0?d:[`kdp guide`,`niche planner`,`workbook`],categories:[`Books > Reference > Custom Niche Guide`,`Books > Self-Help > Productivity`],descriptionHtml:f,price:`$9.99`})}catch(e){console.error(e),alert(`Error connecting to Hugging Face backend. Using pre-loaded mock templates instead.`)}finally{a(!1)}},g=c||p[e];return(0,b.jsxs)(`div`,{className:`animate-fade-in`,style:M.container,children:[(0,b.jsxs)(`div`,{style:M.header,children:[(0,b.jsx)(`h1`,{style:M.heading,children:`Amazon KDP Publishing Copilot`}),(0,b.jsx)(`p`,{style:M.subheading,children:`Publish in under 2 minutes. Copy-paste optimized SEO descriptions safely to prevent account bans.`})]}),(0,b.jsxs)(`div`,{style:M.mainGrid,children:[(0,b.jsxs)(`div`,{className:`glass-card`,style:M.leftCard,children:[(0,b.jsxs)(`h2`,{style:M.sectionTitle,children:[(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`var(--secondary)`,style:{width:`22px`,height:`22px`},children:(0,b.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z`})}),`KDP Upload Copilot`]}),(0,b.jsx)(`p`,{style:M.cardDescription,children:`Open Amazon KDP and follow these 4 simple steps to list your book.`}),(0,b.jsxs)(`div`,{style:M.stepsTimeline,children:[(0,b.jsxs)(`div`,{style:M.stepItem,children:[(0,b.jsx)(`div`,{style:M.stepNum,children:`1`}),(0,b.jsxs)(`div`,{style:M.stepContent,children:[(0,b.jsx)(`strong`,{style:M.stepTitle,children:`Enter Title & Subtitle`}),(0,b.jsx)(`p`,{style:M.stepText,children:`Copy the AI-optimized Title and Subtitle from the right panel and paste them into KDP Paperback Details.`})]})]}),(0,b.jsxs)(`div`,{style:M.stepItem,children:[(0,b.jsx)(`div`,{style:M.stepNum,children:`2`}),(0,b.jsxs)(`div`,{style:M.stepContent,children:[(0,b.jsx)(`strong`,{style:M.stepTitle,children:`Paste HTML Description`}),(0,b.jsx)(`p`,{style:M.stepText,children:`KDP description supports HTML. Copy the description text from the right panel to show rich bullet points on Amazon.`})]})]}),(0,b.jsxs)(`div`,{style:M.stepItem,children:[(0,b.jsx)(`div`,{style:M.stepNum,children:`3`}),(0,b.jsxs)(`div`,{style:M.stepContent,children:[(0,b.jsx)(`strong`,{style:M.stepTitle,children:`Fill the 7 Keyword Boxes`}),(0,b.jsx)(`p`,{style:M.stepText,children:`Paste the 7 custom KDP keywords. This is the secret step that allows buyers to find your book organically!`})]})]}),(0,b.jsxs)(`div`,{style:M.stepItem,children:[(0,b.jsx)(`div`,{style:M.stepNum,children:`4`}),(0,b.jsxs)(`div`,{style:M.stepContent,children:[(0,b.jsx)(`strong`,{style:M.stepTitle,children:`Upload PDF Files & Pricing`}),(0,b.jsx)(`p`,{style:M.stepText,children:`Upload your downloaded Interior PDF and Cover PDF. Select "Worldwide Rights" and input the recommended price.`})]})]})]}),(0,b.jsxs)(`a`,{href:`https://kdp.amazon.com`,target:`_blank`,rel:`noopener noreferrer`,className:`btn btn-secondary`,style:{width:`100%`,marginTop:`20px`},children:[`Open Amazon KDP Shelf`,(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,style:{width:`16px`,height:`16px`},children:(0,b.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M13.5 6H5.25A2.25 2.25 0 0 0 3 8.25v10.5A2.25 2.25 0 0 0 5.25 21h10.5A2.25 2.25 0 0 0 18 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25`})})]})]}),(0,b.jsxs)(`div`,{className:`glass-card`,style:M.rightCard,children:[(0,b.jsxs)(`div`,{style:M.titleRow,children:[(0,b.jsxs)(`h2`,{style:M.sectionTitle,children:[(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`var(--primary)`,style:{width:`22px`,height:`22px`},children:(0,b.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10`})}),`AI SEO Listing Copywriter`]}),c?(0,b.jsxs)(`div`,{style:{display:`flex`,gap:`10px`},children:[(0,b.jsx)(`button`,{onClick:f,disabled:u,className:`btn btn-outline`,style:{padding:`6px 12px`,fontSize:`11px`,color:`var(--success)`,borderColor:`rgba(16,185,129,0.3)`,cursor:`pointer`},children:u?`Saving to DB...`:`Save to KDP Database`}),(0,b.jsx)(`button`,{onClick:()=>l(null),className:`btn btn-outline`,style:{padding:`6px 12px`,fontSize:`11px`,color:`var(--danger)`,borderColor:`rgba(239,68,68,0.2)`,cursor:`pointer`},children:`Reset to Presets`})]}):(0,b.jsxs)(`div`,{style:{display:`flex`,gap:`10px`,alignItems:`center`},children:[(0,b.jsx)(`button`,{onClick:f,disabled:u,className:`btn btn-outline`,style:{padding:`6px 12px`,fontSize:`11px`,color:`var(--success)`,borderColor:`rgba(16,185,129,0.3)`,cursor:`pointer`},children:u?`Saving...`:`Save Preset to DB`}),(0,b.jsxs)(`select`,{value:e,onChange:e=>t(e.target.value),className:`form-select`,style:{width:`180px`,padding:`6px 12px`,fontSize:`12px`},children:[(0,b.jsx)(`option`,{value:`adhd_planner`,children:`ADHD Daily Planner`}),(0,b.jsx)(`option`,{value:`aws_guide`,children:`AWS SAA-C03 Guide`}),(0,b.jsx)(`option`,{value:`puzzle_book`,children:`Large Print Sudoku`})]})]})]}),(0,b.jsx)(`p`,{style:M.cardDescription,children:`Copy-paste these fields directly into Amazon KDP's upload page.`}),(0,b.jsxs)(`div`,{style:M.customGenBox,children:[(0,b.jsx)(`input`,{type:`text`,placeholder:`Enter custom book topic (e.g. 'Dog Training Log Book', 'C++ Interview Q&A')`,value:n,onChange:e=>r(e.target.value),className:`form-input`,style:{flexGrow:1},disabled:i}),(0,b.jsx)(`button`,{onClick:h,disabled:i,className:`btn btn-primary`,style:{flexShrink:0,padding:`12px 20px`},children:i?`Writing...`:`Generate with Llama 3`})]}),(0,b.jsxs)(`div`,{style:M.copilotGrid,children:[(0,b.jsxs)(`div`,{style:M.copyGroup,children:[(0,b.jsxs)(`div`,{style:M.copyLabelRow,children:[(0,b.jsx)(`span`,{style:M.fieldLabel,children:`Book Title (Amazon Page 1 Ranked)`}),(0,b.jsx)(`button`,{onClick:()=>m(g.title,`title`),style:M.copyBtn,children:o===`title`?`COPIED!`:`COPY`})]}),(0,b.jsx)(`div`,{style:M.metaTextBox,children:g.title})]}),(0,b.jsxs)(`div`,{style:M.copyGroup,children:[(0,b.jsxs)(`div`,{style:M.copyLabelRow,children:[(0,b.jsx)(`span`,{style:M.fieldLabel,children:`Book Subtitle (Benefits Focused)`}),(0,b.jsx)(`button`,{onClick:()=>m(g.subtitle,`subtitle`),style:M.copyBtn,children:o===`subtitle`?`COPIED!`:`COPY`})]}),(0,b.jsx)(`div`,{style:M.metaTextBox,children:g.subtitle})]}),(0,b.jsxs)(`div`,{style:M.copyGroup,children:[(0,b.jsxs)(`div`,{style:M.copyLabelRow,children:[(0,b.jsx)(`span`,{style:M.fieldLabel,children:`7 Amazon KDP Search Keywords`}),(0,b.jsx)(`span`,{style:{fontSize:`11px`,color:`var(--text-muted)`},children:`Click individual to copy`})]}),(0,b.jsx)(`div`,{style:M.keywordChipsContainer,children:g.keywords.map((e,t)=>(0,b.jsx)(`button`,{onClick:()=>m(e,`kw-${t}`),style:{...M.kwChip,borderColor:o===`kw-${t}`?`var(--success)`:`var(--border-glow)`,color:o===`kw-${t}`?`var(--success)`:`var(--text-primary)`},children:e},t))})]}),(0,b.jsxs)(`div`,{style:M.copyGroup,children:[(0,b.jsxs)(`div`,{style:M.copyLabelRow,children:[(0,b.jsx)(`span`,{style:M.fieldLabel,children:`HTML Description (Paste to Amazon WYSIWYG)`}),(0,b.jsx)(`button`,{onClick:()=>m(g.descriptionHtml,`description`),style:M.copyBtn,children:o===`description`?`COPIED!`:`COPY`})]}),(0,b.jsx)(`pre`,{style:M.htmlBox,children:g.descriptionHtml})]}),(0,b.jsxs)(`div`,{style:M.metaGridDouble,children:[(0,b.jsxs)(`div`,{style:M.copyGroup,children:[(0,b.jsx)(`span`,{style:M.fieldLabel,children:`Recommended Pricing`}),(0,b.jsxs)(`div`,{style:M.metaTextBox,children:[g.price,` (60% Paperback Royalty)`]})]}),(0,b.jsxs)(`div`,{style:M.copyGroup,children:[(0,b.jsx)(`span`,{style:M.fieldLabel,children:`Target KDP Categories`}),(0,b.jsx)(`div`,{style:{...M.metaTextBox,fontSize:`11px`,lineHeight:`1.4`},children:g.categories.map((e,t)=>(0,b.jsx)(`div`,{children:e},t))})]})]})]})]})]})]})}var M={container:{padding:`30px 40px`},header:{marginBottom:`32px`},heading:{fontSize:`28px`,color:`#fff`},subheading:{color:`var(--text-secondary)`,fontSize:`14px`,marginTop:`4px`},mainGrid:{display:`grid`,gridTemplateColumns:`1fr 1.6fr`,gap:`30px`},leftCard:{height:`fit-content`},rightCard:{display:`flex`,flexDirection:`column`},sectionTitle:{fontSize:`18px`,color:`#fff`,display:`flex`,alignItems:`center`,gap:`8px`},cardDescription:{fontSize:`13px`,color:`var(--text-secondary)`,margin:`6px 0 20px 0`},titleRow:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`6px`},stepsTimeline:{display:`flex`,flexDirection:`column`,gap:`20px`},stepItem:{display:`flex`,gap:`16px`},stepNum:{width:`28px`,height:`28px`,borderRadius:`50%`,background:`rgba(139,92,246,0.1)`,border:`1.5px solid var(--primary)`,color:`var(--primary-hover)`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:`12px`,fontWeight:`800`,flexShrink:0,boxShadow:`0 0 10px rgba(139,92,246,0.2)`},stepContent:{flexGrow:1},stepTitle:{fontSize:`14px`,color:`#fff`,fontWeight:`700`},stepText:{fontSize:`12px`,color:`var(--text-secondary)`,marginTop:`4px`,lineHeight:`1.4`},customGenBox:{display:`flex`,gap:`12px`,background:`rgba(15, 23, 42, 0.3)`,border:`1px solid var(--border-glow)`,borderRadius:`10px`,padding:`12px`,marginBottom:`24px`,alignItems:`center`},copilotGrid:{display:`flex`,flexDirection:`column`,gap:`20px`},copyGroup:{display:`flex`,flexDirection:`column`,gap:`8px`},copyLabelRow:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},fieldLabel:{fontSize:`11px`,fontWeight:`700`,color:`var(--text-secondary)`,letterSpacing:`0.05em`,textTransform:`uppercase`},copyBtn:{background:`rgba(30,41,59,0.6)`,border:`1px solid var(--border-glow)`,borderRadius:`4px`,color:`var(--text-primary)`,fontSize:`10px`,fontWeight:`800`,padding:`4px 10px`,cursor:`pointer`,letterSpacing:`0.05em`,transition:`all 0.2s ease`},metaTextBox:{background:`rgba(6,9,19,0.5)`,border:`1px solid var(--border-glow)`,borderRadius:`8px`,padding:`12px 16px`,fontSize:`13px`,color:`#fff`,fontWeight:`500`},keywordChipsContainer:{display:`flex`,flexWrap:`wrap`,gap:`8px`},kwChip:{background:`rgba(6,9,19,0.5)`,border:`1px solid var(--border-glow)`,borderRadius:`30px`,padding:`6px 14px`,fontSize:`11px`,fontWeight:`600`,cursor:`pointer`,transition:`all 0.2s ease`},htmlBox:{background:`rgba(6,9,19,0.7)`,border:`1px solid var(--border-glow)`,borderRadius:`8px`,padding:`16px`,fontSize:`11px`,color:`#a78bfa`,fontFamily:`monospace`,whiteSpace:`pre-wrap`,maxHeight:`180px`,overflowY:`auto`},metaGridDouble:{display:`grid`,gridTemplateColumns:`1fr 1.5fr`,gap:`16px`}};function se(){let[e,t]=(0,_.useState)(!1),[n,r]=(0,_.useState)(864e5),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(!0),c=(0,_.useRef)(null),l=async()=>{try{let e=await fetch(`${C}/api/autopilot/status`);if(e.ok){let n=await e.json();t(n.active),a(n.thoughts||[])}}catch(e){console.error(`Error fetching autopilot status:`,e)}finally{s(!1)}};return(0,_.useEffect)(()=>{l();let e=setInterval(l,3e3);return()=>clearInterval(e)},[e]),(0,_.useEffect)(()=>{c.current&&c.current.scrollIntoView({behavior:`smooth`})},[i]),(0,b.jsxs)(`div`,{className:`animate-fade-in`,style:N.container,children:[(0,b.jsxs)(`div`,{style:N.header,children:[(0,b.jsx)(`h1`,{style:N.heading,children:`KDP Autonomous Agent & E-Book Packager`}),(0,b.jsx)(`p`,{style:N.subheading,children:`Configure a daily background worker that researches, writes, and packages premium humanized e-books with covers into downloadable ZIPs.`})]}),(0,b.jsxs)(`div`,{style:N.mainGrid,children:[(0,b.jsxs)(`div`,{className:`glass-card`,style:N.controlCard,children:[(0,b.jsxs)(`h2`,{style:N.sectionTitle,children:[(0,b.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`var(--secondary)`,style:{width:`22px`,height:`22px`},children:[(0,b.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 18a3.75 3.75 0 0 0 .495-7.467 5.99 5.99 0 0 0-1.925 3.546 5.974 5.974 0 0 1-2.133-1A3.75 3.75 0 0 0 12 18Z`}),(0,b.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 1 1 7.072 0l-.548.547A3.374 3.374 0 0 0 14 18.469V19a2 2 0 1 1-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547Z`})]}),`Autopilot Parameters`]}),(0,b.jsxs)(`div`,{style:N.toggleRow,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`strong`,{style:{color:`#fff`,fontSize:`15px`,display:`block`},children:`Agent Ignition`}),(0,b.jsx)(`span`,{style:{fontSize:`12px`,color:`var(--text-secondary)`},children:`Toggle to start autonomous loop`})]}),(0,b.jsx)(`button`,{onClick:async()=>{let r=!e;s(!0);try{let e=await fetch(`${C}/api/autopilot/toggle`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({active:r,intervalMs:n})});e.ok&&(t((await e.json()).active),l())}catch(e){console.error(`Error toggling autopilot:`,e),alert(`Error connecting to the backend Space.`)}finally{s(!1)}},disabled:o,style:{...N.toggleBtn,background:e?`var(--success)`:`rgba(255,255,255,0.05)`,color:e?`#000`:`var(--text-secondary)`,boxShadow:e?`0 0 15px rgba(16,185,129,0.4)`:`none`},children:o?`PENDING...`:e?`AUTOPILOT: ON`:`AUTOPILOT: OFF`})]}),(0,b.jsxs)(`div`,{className:`form-group`,style:{marginTop:`24px`},children:[(0,b.jsx)(`label`,{className:`form-label`,children:`Simulated Loop Frequency`}),(0,b.jsxs)(`select`,{value:n,onChange:e=>r(parseInt(e.target.value)),className:`form-select`,disabled:e,children:[(0,b.jsx)(`option`,{value:`60000`,children:`Every 1 Minute (Optimal Testing)`}),(0,b.jsx)(`option`,{value:`3600000`,children:`Every 1 Hour (Standard Scaling)`}),(0,b.jsx)(`option`,{value:`86400000`,children:`Every 24 Hours (Daily Automation)`})]})]}),(0,b.jsxs)(`div`,{style:N.strategyBox,children:[(0,b.jsxs)(`div`,{style:N.strategyHeader,children:[(0,b.jsx)(`span`,{style:N.pulsePoint}),(0,b.jsx)(`strong`,{children:`Autopilot Strategy Blueprint`})]}),(0,b.jsxs)(`ul`,{style:N.strategyList,children:[(0,b.jsxs)(`li`,{children:[`🔍 `,(0,b.jsx)(`strong`,{children:`Scans Hot KDP Trends`}),`: Focuses on high-yield, high-interest niches.`]}),(0,b.jsxs)(`li`,{children:[`✍️ `,(0,b.jsx)(`strong`,{children:`Groq Llama 3 70B Generation`}),`: Generates beautifully styled and humanized book content.`]}),(0,b.jsxs)(`li`,{children:[`🖼️ `,(0,b.jsx)(`strong`,{children:`SDXL High-Res Cover Art`}),`: Automatically designs matched aesthetic book covers.`]}),(0,b.jsxs)(`li`,{children:[`📦 `,(0,b.jsx)(`strong`,{children:`Automated ZIP Packaging`}),": Packages `book.md`, `cover.jpg`, and complete publishing metadata (`listing.txt`) into a single ZIP for manual publishing."]})]})]})]}),(0,b.jsxs)(`div`,{className:`glass-card`,style:N.terminalCard,children:[(0,b.jsxs)(`div`,{className:`card-header`,children:[(0,b.jsx)(`h2`,{style:N.cardTitle,children:`Agent Thought Stream Terminal`}),e&&(0,b.jsx)(`span`,{style:N.runningBadge,children:`ACTIVE RUNNING`})]}),(0,b.jsx)(`p`,{style:N.cardDescription,children:`Live telemetry stream capturing Llama 3 background creation sequences.`}),(0,b.jsxs)(`div`,{style:N.terminalContainer,children:[i.slice().reverse().map((e,t)=>{let n=e.match(/(https?:\/\/\S+)/i),r=e.includes(`❌`)?`var(--danger)`:e.includes(`✅`)?`var(--success)`:e.includes(`🚀`)?`var(--secondary)`:`#a78bfa`;if(n){let i=n[1],a=e.split(i);return(0,b.jsxs)(`div`,{style:{...N.terminalLine,color:r},children:[a[0],(0,b.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,style:{color:`#ff90e8`,fontWeight:`800`,textDecoration:`underline`},children:i}),a[1]]},t)}return(0,b.jsx)(`div`,{style:{...N.terminalLine,color:r},children:e},t)}),(0,b.jsx)(`div`,{ref:c})]})]})]})]})}var N={container:{padding:`30px 40px`},header:{marginBottom:`32px`},heading:{fontSize:`28px`,color:`#fff`},subheading:{color:`var(--text-secondary)`,fontSize:`14px`,marginTop:`4px`},mainGrid:{display:`grid`,gridTemplateColumns:`1fr 1.6fr`,gap:`30px`},controlCard:{height:`fit-content`},sectionTitle:{fontSize:`18px`,color:`#fff`,display:`flex`,alignItems:`center`,gap:`8px`,marginBottom:`20px`},toggleRow:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,background:`rgba(15,23,42,0.4)`,border:`1px solid var(--border-glow)`,borderRadius:`12px`,padding:`18px`},toggleBtn:{border:`none`,borderRadius:`8px`,padding:`12px 20px`,fontWeight:`800`,fontSize:`12px`,cursor:`pointer`,letterSpacing:`0.05em`,transition:`all 0.3s cubic-bezier(0.4, 0, 0.2, 1)`},strategyBox:{background:`rgba(6,9,19,0.5)`,border:`1px solid var(--border-glow)`,borderRadius:`10px`,padding:`16px`,marginTop:`24px`},strategyHeader:{display:`flex`,alignItems:`center`,gap:`8px`,fontSize:`13px`,color:`var(--secondary)`,marginBottom:`12px`},pulsePoint:{width:`6px`,height:`6px`,borderRadius:`50%`,background:`var(--secondary)`,boxShadow:`0 0 6px var(--secondary)`},strategyList:{paddingLeft:`18px`,fontSize:`12px`,color:`var(--text-secondary)`,display:`flex`,flexDirection:`column`,gap:`8px`},terminalCard:{display:`flex`,flexDirection:`column`,maxHeight:`600px`},cardTitle:{fontSize:`18px`,color:`#fff`},cardDescription:{fontSize:`13px`,color:`var(--text-secondary)`,marginBottom:`20px`},runningBadge:{fontSize:`10px`,fontWeight:`800`,background:`rgba(16, 185, 129, 0.1)`,color:`var(--success)`,padding:`3px 8px`,borderRadius:`4px`,boxShadow:`0 0 8px rgba(16,185,129,0.2)`},terminalContainer:{flexGrow:1,background:`#040711`,border:`1px solid var(--border-glow)`,borderRadius:`12px`,padding:`20px`,minHeight:`400px`,overflowY:`auto`,display:`flex`,flexDirection:`column`,gap:`10px`,boxShadow:`inset 0 4px 20px rgba(0,0,0,0.8)`,fontFamily:`monospace`,fontSize:`11px`,lineHeight:`1.5`},terminalLine:{whiteSpace:`pre-wrap`,textShadow:`0 0 2px rgba(167, 139, 250, 0.3)`}},ce=[{id:`gumroad`,name:`Gumroad`,emoji:`🟠`,color:`#ff90e8`,hint:`E-books, templates, courses, digital downloads`},{id:`etsy`,name:`Etsy`,emoji:`🟡`,color:`#f1c40f`,hint:`Printable planners, templates, digital art`},{id:`kdp`,name:`Amazon KDP`,emoji:`🔵`,color:`#4a90e2`,hint:`Kindle e-books and paperbacks`},{id:`kofi`,name:`Ko-fi`,emoji:`☕`,color:`#13c3ff`,hint:`Digital products, memberships, donations`},{id:`payhip`,name:`Payhip`,emoji:`💜`,color:`#9b59b6`,hint:`Simple digital downloads store`},{id:`creative`,name:`Creative Market`,emoji:`🎨`,color:`#e74c3c`,hint:`Fonts, graphics, website templates`},{id:`teachable`,name:`Teachable`,emoji:`🎓`,color:`#2ecc71`,hint:`Online courses and memberships`},{id:`envato`,name:`Envato Market`,emoji:`🟢`,color:`#27ae60`,hint:`Themes, code, graphics, audio`}];function P(){let[e,t]=(0,_.useState)(`gumroad`),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(null),[y,x]=(0,_.useState)(!1),[S,w]=(0,_.useState)(``),[T,ee]=(0,_.useState)(()=>localStorage.getItem(`gumroad_token`)||``),[E,D]=(0,_.useState)(!1),[te,ne]=(0,_.useState)(``),[re,ie]=(0,_.useState)(``),[O,ae]=(0,_.useState)(!1),[k,A]=(0,_.useState)(``),[j,oe]=(0,_.useState)(``),[M,se]=(0,_.useState)(null),[N,P]=(0,_.useState)(``),le=ce.find(t=>t.id===e),ue=e=>{let t=e.target.value;ee(t),localStorage.setItem(`gumroad_token`,t)},de=async()=>{if(!n.trim()){alert(`Please enter a niche or topic!`);return}a(!0),s(`listing`),d(null),p(null),h(``),w(``),ie(``),ne(``);try{let t=await fetch(`${C}/api/generate-product`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({platform:e,niche:n.trim()})});if(!t.ok)throw Error(`Failed to generate product`);let r=await t.json();if(d(r),r.thumbnailPrompt){s(`cover`);try{let e=await fetch(`${C}/api/generate-cover`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prompt:r.thumbnailPrompt,title:r.title})});if(e.ok){let t=await e.json();p(t.imageUrl),h(t.coverUrl)}}catch(e){console.warn(`Auto thumbnail generation failed:`,e.message)}}}catch(e){alert(`Error generating product: `+e.message)}finally{a(!1),s(``)}},fe=async()=>{if(!j.trim()){alert(`Please enter a general topic/niche!`);return}ae(!0),A(`optimizing`),se(null),P(``);try{let e=await fetch(`${C}/api/generate-product`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({platform:`kdp`,niche:j.trim()})});if(!e.ok)throw Error(`Failed to generate best-seller content`);let t=await e.json();se(t),A(`zipping`);let n=await fetch(`${C}/api/generate-package`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:t.title,subtitle:t.subtitle,description:t.description,tags:t.tags,cta:t.cta,price:t.price,platform:`kdp`,productContent:t.productContent,thumbnailPrompt:t.thumbnailPrompt})});if(!n.ok)throw Error(`Failed to package ZIP archive`);let r=await n.json();P(r.packageUrl),window.location.href=r.packageUrl;try{await fetch(`${C}/api/catalog`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:t.title,subtitle:t.subtitle,type:`study_guide`,price:t.price,platform:`kdp`,tags:t.tags,thumbnail_url:t.thumbnailUrl||``,sales_copy:t.description,status:`ready_to_publish`,published_url:r.packageUrl})})}catch(e){console.warn(`Silent save to catalog failed:`,e.message)}}catch(e){alert(`Error packaging best-seller book: `+e.message)}finally{ae(!1),A(``)}},pe=()=>{if(!M?.productContent)return;let e=new Blob([M.productContent],{type:`text/markdown`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${M.title.replace(/[^a-zA-Z0-9]/g,`_`).toLowerCase()}_manuscript.md`,n.click(),URL.revokeObjectURL(t)},me=()=>{if(!M?.productContent)return;let e=window.open(``,`_blank`),t=M.productContent,n=[],r=t.split(`
593
- `),i=-1,a=[];for(r.forEach(e=>{let t=!1;for(let r=0;r<5;r++)if(e.includes(`Chapter ${r+1}`)){a.length>0&&n.push(a.join(`
594
- `)),i=r,a=[e],t=!0;break}!t&&i!==-1&&a.push(e)}),a.length>0&&n.push(a.join(`
595
- `));n.length<5;)n.push(`Chapter ${n.length+1} - Details\n\nContent details for chapter ${n.length+1}...`);let o=``;o+=`
596
  <div class="page left-page cover-page">
597
  <div class="header-brand">BOOKFORGE DIGITAL HUBS</div>
598
  <div class="cover-interior">
@@ -603,7 +600,7 @@ Start writing now:`;try{let t=await fetch(`${C}/api/generate-text`,{method:`POST
603
  </div>
604
  <div class="cover-footer">BOOKFORGE PREMIUM EDITION</div>
605
  </div>
606
- `,o+=`
607
  <div class="page right-page copyright-page">
608
  <div class="header-brand">BOOKFORGE BINDERY & REGISTRATION</div>
609
  <div class="interior-content">
@@ -621,7 +618,7 @@ Start writing now:`;try{let t=await fetch(`${C}/api/generate-text`,{method:`POST
621
  </div>
622
  <div class="page-number">Page 2</div>
623
  </div>
624
- `,o+=`
625
  <div class="page left-page toc-page">
626
  <div class="header-brand">CONTENTS INDEX</div>
627
  <div class="interior-content">
@@ -643,7 +640,7 @@ Start writing now:`;try{let t=await fetch(`${C}/api/generate-text`,{method:`POST
643
  </div>
644
  <div class="page-number">Page 3</div>
645
  </div>
646
- `,o+=`
647
  <div class="page right-page preface-page">
648
  <div class="header-brand">AUTHOR PREFACE</div>
649
  <div class="interior-content">
@@ -656,30 +653,30 @@ Start writing now:`;try{let t=await fetch(`${C}/api/generate-text`,{method:`POST
656
  </div>
657
  <div class="page-number">Page 4</div>
658
  </div>
659
- `;let s=5;for(let e=0;e<5;e++){let t=s%2==0?`right-page`:`left-page`,r=n[e],i=r.split(`
660
- `)[0].replace(/#+/g,``).trim().toUpperCase(),a=r.split(`
661
  `).slice(1).join(`
662
- `).replace(/\n/g,`<br>`).replace(/✓ (.*?)(?=<br>)/g,`<li>✓ $1</li>`);o+=`
663
  <div class="page ${t} chapter-cover">
664
  <div class="header-brand">CHAPTER DIVISION ${e+1}</div>
665
  <div class="chapter-cover-interior">
666
  <span class="chapter-number">CHAPTER 0${e+1}</span>
667
  <div class="cover-divider"></div>
668
- <h2>${i}</h2>
669
- <p style="font-size: 11px; text-transform:uppercase; color:#666; letter-spacing:1px; margin-top:20px;">Detailed Written Guide & Workbook Interior</p>
670
  </div>
671
- <div class="page-number">Page ${s}</div>
672
  </div>
673
- `,s++;let c=s%2==0?`right-page`:`left-page`;o+=`
674
  <div class="page ${c} chapter-content">
675
- <div class="header-brand">${i}</div>
676
  <div class="chapter-text-interior">
677
  <h3>DEVELOPMENTAL MANUAL OUTLINE</h3>
678
- <p>${a}</p>
679
  </div>
680
- <div class="page-number">Page ${s}</div>
681
  </div>
682
- `,s++;let l=e===4?18:22;for(let t=0;t<l;t++){let n=s%2==0?`right-page`:`left-page`,r=``;r=e===0?t%2==0?`
683
  <h2>DAILY FOCUS TRACKER</h2>
684
  <div class="divider"></div>
685
  <div class="box">
@@ -804,15 +801,15 @@ Start writing now:`;try{let t=await fetch(`${C}/api/generate-text`,{method:`POST
804
  <div class="dot-grid">
805
  ${`<div class="dot">.</div>`.repeat(80)}
806
  </div>
807
- `,o+=`
808
  <div class="page ${n}">
809
  <div class="header-brand">BOOKFORGE DIGITAL GOAL PLANNERS</div>
810
  <div class="page-interior">
811
- ${r}
812
  </div>
813
- <div class="page-number">Page ${s}</div>
814
  </div>
815
- `,s++}}e.document.write(`
816
  <html>
817
  <head>
818
  <title>${M.title} - 120 Pages</title>
@@ -822,26 +819,30 @@ Start writing now:`;try{let t=await fetch(`${C}/api/generate-text`,{method:`POST
822
  .page { page-break-after: always; display: flex !important; }
823
  @page { size: 6in 9in; margin: 0; }
824
  }
825
- * { box-sizing: border-box; }
 
 
 
 
826
  body {
827
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
828
- color: #111;
829
  margin: 0;
830
  padding: 0;
831
- background: #f0f0f0;
832
  }
833
  .page {
834
  background: #fff;
835
  width: 6in;
836
  height: 9in;
837
- margin: 20px auto;
838
  position: relative;
839
  display: flex;
840
  flex-direction: column;
841
  justify-content: space-between;
842
- border: 1px solid #ddd;
843
- box-shadow: 0 0 10px rgba(0,0,0,0.05);
844
  }
 
845
  .left-page {
846
  padding: 0.8in 0.75in 0.8in 0.4in;
847
  }
@@ -850,12 +851,13 @@ Start writing now:`;try{let t=await fetch(`${C}/api/generate-text`,{method:`POST
850
  }
851
  .header-brand {
852
  font-size: 8px;
853
- color: #999;
854
  letter-spacing: 2px;
855
  text-align: center;
856
- border-bottom: 1px solid #f0f0f0;
857
  padding-bottom: 6px;
858
  text-transform: uppercase;
 
859
  }
860
  .page-interior {
861
  flex-grow: 1;
@@ -867,217 +869,240 @@ Start writing now:`;try{let t=await fetch(`${C}/api/generate-text`,{method:`POST
867
  .interior-content {
868
  padding: 40px 10px 0 10px;
869
  }
 
870
  .cover-page {
871
  justify-content: space-between;
872
  padding: 1.2in 0.6in;
873
  text-align: center;
 
874
  }
875
  .cover-interior {
876
  display: flex;
877
  flex-direction: column;
878
  align-items: center;
 
879
  }
880
  .cover-title {
881
  font-family: 'Georgia', serif;
882
- font-size: 24px;
883
  font-weight: 900;
884
  text-transform: uppercase;
885
  letter-spacing: 1px;
886
  line-height: 1.3;
887
  margin: 0 0 15px 0;
 
888
  }
889
  .cover-divider {
890
- width: 60px;
891
- height: 3px;
892
- background: #111;
893
- margin: 10px 0;
894
  }
895
  .cover-subtitle {
896
  font-family: 'Georgia', serif;
897
- font-size: 13px;
898
- color: #555;
899
  font-style: italic;
900
  line-height: 1.5;
901
  margin: 15px 0;
 
902
  }
903
  .cover-tag {
904
- font-size: 9px;
905
- font-weight: bold;
906
- border: 1px solid #111;
907
  border-radius: 4px;
908
- padding: 4px 10px;
909
- margin-top: 30px;
910
- letter-spacing: 1px;
 
 
911
  }
912
  .cover-footer {
913
- font-size: 9px;
914
- font-weight: bold;
915
- letter-spacing: 3px;
916
- color: #777;
 
917
  }
 
918
  .copyright-page h3 {
919
- font-size: 11px;
920
- font-weight: bold;
921
  margin-bottom: 8px;
 
922
  }
923
  .copyright-page p {
924
- font-size: 9px;
925
  line-height: 1.5;
926
- color: #444;
927
  text-align: justify;
928
- margin: 0 0 15px 0;
929
  }
 
930
  .toc-list {
931
  display: flex;
932
  flex-direction: column;
933
  gap: 12px;
934
- margin-top: 20px;
935
  }
936
  .toc-item {
937
  display: flex;
938
  justify-content: space-between;
939
- font-size: 9px;
940
  font-weight: bold;
941
- color: #333;
942
  }
943
  .dots {
944
  flex-grow: 1;
945
  text-align: center;
946
- color: #ccc;
947
  overflow: hidden;
948
  white-space: nowrap;
949
  margin: 0 10px;
950
  }
 
951
  .chapter-cover {
952
  justify-content: space-between;
953
  padding: 1.2in 0.6in;
954
  text-align: center;
 
955
  }
956
  .chapter-cover-interior {
957
  display: flex;
958
  flex-direction: column;
959
  align-items: center;
 
960
  }
961
  .chapter-number {
962
- font-size: 11px;
963
- font-weight: bold;
964
- letter-spacing: 3px;
965
- color: #777;
966
  }
967
  .chapter-cover h2 {
968
  font-family: 'Georgia', serif;
969
- font-size: 20px;
970
- font-weight: 800;
971
- margin-top: 15px;
972
  }
 
973
  .chapter-content {
974
  font-family: 'Georgia', serif;
975
- line-height: 1.6;
976
  }
977
  .chapter-text-interior {
978
  padding: 30px 10px;
979
  text-align: justify;
980
  }
981
  .chapter-text-interior h3 {
982
- font-size: 12px;
983
- font-weight: bold;
984
- border-bottom: 2px solid #111;
985
  padding-bottom: 6px;
986
- margin-bottom: 15px;
987
  letter-spacing: 1px;
988
  }
989
  .chapter-text-interior p {
990
  font-size: 11px;
991
  line-height: 1.7;
992
- color: #222;
993
- margin-bottom: 12px;
994
  }
995
  .chapter-text-interior li {
996
  font-size: 11px;
997
- margin-left: 10px;
998
  list-style-type: none;
999
- margin-bottom: 6px;
1000
- color: #333;
 
1001
  }
 
1002
  h2 {
1003
  font-size: 14px;
1004
- font-weight: 800;
1005
  text-align: center;
1006
  margin: 0 0 5px 0;
1007
  letter-spacing: 1px;
 
1008
  }
1009
  .divider {
1010
- height: 2px;
1011
- background: #111;
1012
- width: 30px;
1013
  margin: 0 auto 10px auto;
1014
  }
1015
  .box {
1016
- border: 1px solid #222;
1017
  border-radius: 6px;
1018
- padding: 10px 14px;
1019
  display: flex;
1020
  flex-direction: column;
1021
- gap: 10px;
1022
  background: #fff;
1023
  }
1024
  .label {
1025
- font-size: 8px;
1026
- font-weight: 800;
1027
- letter-spacing: 1px;
1028
- color: #444;
1029
- border-bottom: 1px solid #eee;
1030
  padding-bottom: 4px;
1031
  text-transform: uppercase;
1032
  }
1033
  .line {
1034
- border-bottom: 1px dashed #777;
1035
  height: 20px;
1036
  width: 100%;
1037
  }
1038
  .checkbox-row {
1039
  display: flex;
1040
  align-items: center;
1041
- gap: 10px;
1042
  }
1043
  .checkbox {
1044
- width: 14px;
1045
- height: 14px;
1046
- border: 1px solid #111;
1047
  border-radius: 3px;
1048
  flex-shrink: 0;
 
1049
  }
1050
  .doodle-placeholder {
1051
- border: 1px dashed #999;
1052
  border-radius: 4px;
1053
  flex-grow: 1;
1054
- min-height: 60px;
1055
- background: #fafafa;
1056
  }
1057
  .habit-row {
1058
  display: flex;
1059
  align-items: center;
1060
  justify-content: space-between;
1061
- gap: 10px;
1062
  }
1063
  .circles {
1064
- font-size: 12px;
1065
- letter-spacing: 3px;
1066
- color: #444;
1067
  }
 
1068
  .dot-grid {
1069
  display: grid;
1070
  grid-template-columns: repeat(8, 1fr);
1071
- grid-gap: 20px;
1072
- padding: 20px 30px;
1073
- opacity: 0.15;
1074
  flex-grow: 1;
1075
  }
1076
  .dot {
1077
- font-size: 24px;
1078
  text-align: center;
1079
  line-height: 0;
 
 
1080
  }
 
1081
  .matrix-grid {
1082
  display: grid;
1083
  grid-template-columns: 1fr 1fr;
@@ -1087,41 +1112,45 @@ Start writing now:`;try{let t=await fetch(`${C}/api/generate-text`,{method:`POST
1087
  padding: 10px 0;
1088
  }
1089
  .matrix-box {
1090
- border: 1px solid #222;
1091
  border-radius: 6px;
1092
- padding: 10px;
1093
  display: flex;
1094
  flex-direction: column;
1095
  justify-content: space-between;
1096
  }
 
1097
  .budget-table {
1098
  width: 100%;
1099
  border-collapse: collapse;
1100
  margin-top: 10px;
1101
  }
1102
  .budget-table th {
1103
- font-size: 8px;
1104
- font-weight: 800;
1105
  text-align: left;
1106
- padding: 6px;
1107
- border-bottom: 2px solid #111;
 
1108
  }
1109
  .budget-table td {
1110
- padding: 8px 6px;
1111
- border-bottom: 1px solid #eee;
1112
- font-size: 10px;
 
1113
  }
1114
  .page-number {
1115
  text-align: center;
1116
- font-size: 9px;
1117
- color: #777;
1118
- border-top: 1px solid #f0f0f0;
1119
  padding-top: 6px;
 
1120
  }
1121
  </style>
1122
  </head>
1123
  <body>
1124
- ${o}
1125
  <script>
1126
  window.onload = function() { window.print(); }
1127
  <\/script>
 
589
  [DESCRIPTION]
590
  Write a high-converting HTML description. Use <h3> for headers and <ul>/<li> for bullet lists. Detail what makes the book unique, what's inside, and print specifications (e.g. 6x9 size, matte cover).
591
 
592
+ Start writing now:`;try{let t=await fetch(`${C}/api/generate-text`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prompt:e,maxTokens:900})});if(!t.ok)throw Error(`Failed to generate. Make sure your Hugging Face Space is running and HF_API_KEY is configured.`);let r=(await t.json()).text,i=r.match(/\[TITLE\]\n?([\s\S]*?)(?=\[SUBTITLE\])/i),a=r.match(/\[SUBTITLE\]\n?([\s\S]*?)(?=\[KEYWORDS\])/i),o=r.match(/\[KEYWORDS\]\n?([\s\S]*?)(?=\[DESCRIPTION\])/i),s=r.match(/\[DESCRIPTION\]\n?([\s\S]*)/i),c=i?i[1].trim():`${n} Guide`,u=a?a[1].trim():`The Ultimate Guide to Mastering Your Skills - High-Impact Keywords Included`,d=(o?o[1].trim():`kdp book, self education, guide, journal`).split(`,`).map(e=>e.trim()).filter(e=>e.length>0).slice(0,7),f=s?s[1].trim():`<h3>📚 Discover the ultimate guide to ${n}!</h3>`;l({title:c,subtitle:u,keywords:d.length>0?d:[`kdp guide`,`niche planner`,`workbook`],categories:[`Books > Reference > Custom Niche Guide`,`Books > Self-Help > Productivity`],descriptionHtml:f,price:`$9.99`})}catch(e){console.error(e),alert(`Error connecting to Hugging Face backend. Using pre-loaded mock templates instead.`)}finally{a(!1)}},g=c||p[e];return(0,b.jsxs)(`div`,{className:`animate-fade-in`,style:M.container,children:[(0,b.jsxs)(`div`,{style:M.header,children:[(0,b.jsx)(`h1`,{style:M.heading,children:`Amazon KDP Publishing Copilot`}),(0,b.jsx)(`p`,{style:M.subheading,children:`Publish in under 2 minutes. Copy-paste optimized SEO descriptions safely to prevent account bans.`})]}),(0,b.jsxs)(`div`,{style:M.mainGrid,children:[(0,b.jsxs)(`div`,{className:`glass-card`,style:M.leftCard,children:[(0,b.jsxs)(`h2`,{style:M.sectionTitle,children:[(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`var(--secondary)`,style:{width:`22px`,height:`22px`},children:(0,b.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z`})}),`KDP Upload Copilot`]}),(0,b.jsx)(`p`,{style:M.cardDescription,children:`Open Amazon KDP and follow these 4 simple steps to list your book.`}),(0,b.jsxs)(`div`,{style:M.stepsTimeline,children:[(0,b.jsxs)(`div`,{style:M.stepItem,children:[(0,b.jsx)(`div`,{style:M.stepNum,children:`1`}),(0,b.jsxs)(`div`,{style:M.stepContent,children:[(0,b.jsx)(`strong`,{style:M.stepTitle,children:`Enter Title & Subtitle`}),(0,b.jsx)(`p`,{style:M.stepText,children:`Copy the AI-optimized Title and Subtitle from the right panel and paste them into KDP Paperback Details.`})]})]}),(0,b.jsxs)(`div`,{style:M.stepItem,children:[(0,b.jsx)(`div`,{style:M.stepNum,children:`2`}),(0,b.jsxs)(`div`,{style:M.stepContent,children:[(0,b.jsx)(`strong`,{style:M.stepTitle,children:`Paste HTML Description`}),(0,b.jsx)(`p`,{style:M.stepText,children:`KDP description supports HTML. Copy the description text from the right panel to show rich bullet points on Amazon.`})]})]}),(0,b.jsxs)(`div`,{style:M.stepItem,children:[(0,b.jsx)(`div`,{style:M.stepNum,children:`3`}),(0,b.jsxs)(`div`,{style:M.stepContent,children:[(0,b.jsx)(`strong`,{style:M.stepTitle,children:`Fill the 7 Keyword Boxes`}),(0,b.jsx)(`p`,{style:M.stepText,children:`Paste the 7 custom KDP keywords. This is the secret step that allows buyers to find your book organically!`})]})]}),(0,b.jsxs)(`div`,{style:M.stepItem,children:[(0,b.jsx)(`div`,{style:M.stepNum,children:`4`}),(0,b.jsxs)(`div`,{style:M.stepContent,children:[(0,b.jsx)(`strong`,{style:M.stepTitle,children:`Upload PDF Files & Pricing`}),(0,b.jsx)(`p`,{style:M.stepText,children:`Upload your downloaded Interior PDF and Cover PDF. Select "Worldwide Rights" and input the recommended price.`})]})]})]}),(0,b.jsxs)(`a`,{href:`https://kdp.amazon.com`,target:`_blank`,rel:`noopener noreferrer`,className:`btn btn-secondary`,style:{width:`100%`,marginTop:`20px`},children:[`Open Amazon KDP Shelf`,(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,style:{width:`16px`,height:`16px`},children:(0,b.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M13.5 6H5.25A2.25 2.25 0 0 0 3 8.25v10.5A2.25 2.25 0 0 0 5.25 21h10.5A2.25 2.25 0 0 0 18 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25`})})]})]}),(0,b.jsxs)(`div`,{className:`glass-card`,style:M.rightCard,children:[(0,b.jsxs)(`div`,{style:M.titleRow,children:[(0,b.jsxs)(`h2`,{style:M.sectionTitle,children:[(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`var(--primary)`,style:{width:`22px`,height:`22px`},children:(0,b.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10`})}),`AI SEO Listing Copywriter`]}),c?(0,b.jsxs)(`div`,{style:{display:`flex`,gap:`10px`},children:[(0,b.jsx)(`button`,{onClick:f,disabled:u,className:`btn btn-outline`,style:{padding:`6px 12px`,fontSize:`11px`,color:`var(--success)`,borderColor:`rgba(16,185,129,0.3)`,cursor:`pointer`},children:u?`Saving to DB...`:`Save to KDP Database`}),(0,b.jsx)(`button`,{onClick:()=>l(null),className:`btn btn-outline`,style:{padding:`6px 12px`,fontSize:`11px`,color:`var(--danger)`,borderColor:`rgba(239,68,68,0.2)`,cursor:`pointer`},children:`Reset to Presets`})]}):(0,b.jsxs)(`div`,{style:{display:`flex`,gap:`10px`,alignItems:`center`},children:[(0,b.jsx)(`button`,{onClick:f,disabled:u,className:`btn btn-outline`,style:{padding:`6px 12px`,fontSize:`11px`,color:`var(--success)`,borderColor:`rgba(16,185,129,0.3)`,cursor:`pointer`},children:u?`Saving...`:`Save Preset to DB`}),(0,b.jsxs)(`select`,{value:e,onChange:e=>t(e.target.value),className:`form-select`,style:{width:`180px`,padding:`6px 12px`,fontSize:`12px`},children:[(0,b.jsx)(`option`,{value:`adhd_planner`,children:`ADHD Daily Planner`}),(0,b.jsx)(`option`,{value:`aws_guide`,children:`AWS SAA-C03 Guide`}),(0,b.jsx)(`option`,{value:`puzzle_book`,children:`Large Print Sudoku`})]})]})]}),(0,b.jsx)(`p`,{style:M.cardDescription,children:`Copy-paste these fields directly into Amazon KDP's upload page.`}),(0,b.jsxs)(`div`,{style:M.customGenBox,children:[(0,b.jsx)(`input`,{type:`text`,placeholder:`Enter custom book topic (e.g. 'Dog Training Log Book', 'C++ Interview Q&A')`,value:n,onChange:e=>r(e.target.value),className:`form-input`,style:{flexGrow:1},disabled:i}),(0,b.jsx)(`button`,{onClick:h,disabled:i,className:`btn btn-primary`,style:{flexShrink:0,padding:`12px 20px`},children:i?`Writing...`:`Generate with Llama 3`})]}),(0,b.jsxs)(`div`,{style:M.copilotGrid,children:[(0,b.jsxs)(`div`,{style:M.copyGroup,children:[(0,b.jsxs)(`div`,{style:M.copyLabelRow,children:[(0,b.jsx)(`span`,{style:M.fieldLabel,children:`Book Title (Amazon Page 1 Ranked)`}),(0,b.jsx)(`button`,{onClick:()=>m(g.title,`title`),style:M.copyBtn,children:o===`title`?`COPIED!`:`COPY`})]}),(0,b.jsx)(`div`,{style:M.metaTextBox,children:g.title})]}),(0,b.jsxs)(`div`,{style:M.copyGroup,children:[(0,b.jsxs)(`div`,{style:M.copyLabelRow,children:[(0,b.jsx)(`span`,{style:M.fieldLabel,children:`Book Subtitle (Benefits Focused)`}),(0,b.jsx)(`button`,{onClick:()=>m(g.subtitle,`subtitle`),style:M.copyBtn,children:o===`subtitle`?`COPIED!`:`COPY`})]}),(0,b.jsx)(`div`,{style:M.metaTextBox,children:g.subtitle})]}),(0,b.jsxs)(`div`,{style:M.copyGroup,children:[(0,b.jsxs)(`div`,{style:M.copyLabelRow,children:[(0,b.jsx)(`span`,{style:M.fieldLabel,children:`7 Amazon KDP Search Keywords`}),(0,b.jsx)(`span`,{style:{fontSize:`11px`,color:`var(--text-muted)`},children:`Click individual to copy`})]}),(0,b.jsx)(`div`,{style:M.keywordChipsContainer,children:g.keywords.map((e,t)=>(0,b.jsx)(`button`,{onClick:()=>m(e,`kw-${t}`),style:{...M.kwChip,borderColor:o===`kw-${t}`?`var(--success)`:`var(--border-glow)`,color:o===`kw-${t}`?`var(--success)`:`var(--text-primary)`},children:e},t))})]}),(0,b.jsxs)(`div`,{style:M.copyGroup,children:[(0,b.jsxs)(`div`,{style:M.copyLabelRow,children:[(0,b.jsx)(`span`,{style:M.fieldLabel,children:`HTML Description (Paste to Amazon WYSIWYG)`}),(0,b.jsx)(`button`,{onClick:()=>m(g.descriptionHtml,`description`),style:M.copyBtn,children:o===`description`?`COPIED!`:`COPY`})]}),(0,b.jsx)(`pre`,{style:M.htmlBox,children:g.descriptionHtml})]}),(0,b.jsxs)(`div`,{style:M.metaGridDouble,children:[(0,b.jsxs)(`div`,{style:M.copyGroup,children:[(0,b.jsx)(`span`,{style:M.fieldLabel,children:`Recommended Pricing`}),(0,b.jsxs)(`div`,{style:M.metaTextBox,children:[g.price,` (60% Paperback Royalty)`]})]}),(0,b.jsxs)(`div`,{style:M.copyGroup,children:[(0,b.jsx)(`span`,{style:M.fieldLabel,children:`Target KDP Categories`}),(0,b.jsx)(`div`,{style:{...M.metaTextBox,fontSize:`11px`,lineHeight:`1.4`},children:g.categories.map((e,t)=>(0,b.jsx)(`div`,{children:e},t))})]})]})]})]})]})]})}var M={container:{padding:`30px 40px`},header:{marginBottom:`32px`},heading:{fontSize:`28px`,color:`#fff`},subheading:{color:`var(--text-secondary)`,fontSize:`14px`,marginTop:`4px`},mainGrid:{display:`grid`,gridTemplateColumns:`1fr 1.6fr`,gap:`30px`},leftCard:{height:`fit-content`},rightCard:{display:`flex`,flexDirection:`column`},sectionTitle:{fontSize:`18px`,color:`#fff`,display:`flex`,alignItems:`center`,gap:`8px`},cardDescription:{fontSize:`13px`,color:`var(--text-secondary)`,margin:`6px 0 20px 0`},titleRow:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`6px`},stepsTimeline:{display:`flex`,flexDirection:`column`,gap:`20px`},stepItem:{display:`flex`,gap:`16px`},stepNum:{width:`28px`,height:`28px`,borderRadius:`50%`,background:`rgba(139,92,246,0.1)`,border:`1.5px solid var(--primary)`,color:`var(--primary-hover)`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:`12px`,fontWeight:`800`,flexShrink:0,boxShadow:`0 0 10px rgba(139,92,246,0.2)`},stepContent:{flexGrow:1},stepTitle:{fontSize:`14px`,color:`#fff`,fontWeight:`700`},stepText:{fontSize:`12px`,color:`var(--text-secondary)`,marginTop:`4px`,lineHeight:`1.4`},customGenBox:{display:`flex`,gap:`12px`,background:`rgba(15, 23, 42, 0.3)`,border:`1px solid var(--border-glow)`,borderRadius:`10px`,padding:`12px`,marginBottom:`24px`,alignItems:`center`},copilotGrid:{display:`flex`,flexDirection:`column`,gap:`20px`},copyGroup:{display:`flex`,flexDirection:`column`,gap:`8px`},copyLabelRow:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},fieldLabel:{fontSize:`11px`,fontWeight:`700`,color:`var(--text-secondary)`,letterSpacing:`0.05em`,textTransform:`uppercase`},copyBtn:{background:`rgba(30,41,59,0.6)`,border:`1px solid var(--border-glow)`,borderRadius:`4px`,color:`var(--text-primary)`,fontSize:`10px`,fontWeight:`800`,padding:`4px 10px`,cursor:`pointer`,letterSpacing:`0.05em`,transition:`all 0.2s ease`},metaTextBox:{background:`rgba(6,9,19,0.5)`,border:`1px solid var(--border-glow)`,borderRadius:`8px`,padding:`12px 16px`,fontSize:`13px`,color:`#fff`,fontWeight:`500`},keywordChipsContainer:{display:`flex`,flexWrap:`wrap`,gap:`8px`},kwChip:{background:`rgba(6,9,19,0.5)`,border:`1px solid var(--border-glow)`,borderRadius:`30px`,padding:`6px 14px`,fontSize:`11px`,fontWeight:`600`,cursor:`pointer`,transition:`all 0.2s ease`},htmlBox:{background:`rgba(6,9,19,0.7)`,border:`1px solid var(--border-glow)`,borderRadius:`8px`,padding:`16px`,fontSize:`11px`,color:`#a78bfa`,fontFamily:`monospace`,whiteSpace:`pre-wrap`,maxHeight:`180px`,overflowY:`auto`},metaGridDouble:{display:`grid`,gridTemplateColumns:`1fr 1.5fr`,gap:`16px`}};function se(){let[e,t]=(0,_.useState)(!1),[n,r]=(0,_.useState)(864e5),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(!0),c=(0,_.useRef)(null),l=async()=>{try{let e=await fetch(`${C}/api/autopilot/status`);if(e.ok){let n=await e.json();t(n.active),a(n.thoughts||[])}}catch(e){console.error(`Error fetching autopilot status:`,e)}finally{s(!1)}};return(0,_.useEffect)(()=>{l();let e=setInterval(l,3e3);return()=>clearInterval(e)},[e]),(0,_.useEffect)(()=>{c.current&&c.current.scrollIntoView({behavior:`smooth`})},[i]),(0,b.jsxs)(`div`,{className:`animate-fade-in`,style:N.container,children:[(0,b.jsxs)(`div`,{style:N.header,children:[(0,b.jsx)(`h1`,{style:N.heading,children:`KDP Autonomous Agent & E-Book Packager`}),(0,b.jsx)(`p`,{style:N.subheading,children:`Configure a daily background worker that researches, writes, and packages premium humanized e-books with covers into downloadable ZIPs.`})]}),(0,b.jsxs)(`div`,{style:N.mainGrid,children:[(0,b.jsxs)(`div`,{className:`glass-card`,style:N.controlCard,children:[(0,b.jsxs)(`h2`,{style:N.sectionTitle,children:[(0,b.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`var(--secondary)`,style:{width:`22px`,height:`22px`},children:[(0,b.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 18a3.75 3.75 0 0 0 .495-7.467 5.99 5.99 0 0 0-1.925 3.546 5.974 5.974 0 0 1-2.133-1A3.75 3.75 0 0 0 12 18Z`}),(0,b.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 1 1 7.072 0l-.548.547A3.374 3.374 0 0 0 14 18.469V19a2 2 0 1 1-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547Z`})]}),`Autopilot Parameters`]}),(0,b.jsxs)(`div`,{style:N.toggleRow,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`strong`,{style:{color:`#fff`,fontSize:`15px`,display:`block`},children:`Agent Ignition`}),(0,b.jsx)(`span`,{style:{fontSize:`12px`,color:`var(--text-secondary)`},children:`Toggle to start autonomous loop`})]}),(0,b.jsx)(`button`,{onClick:async()=>{let r=!e;s(!0);try{let e=await fetch(`${C}/api/autopilot/toggle`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({active:r,intervalMs:n})});e.ok&&(t((await e.json()).active),l())}catch(e){console.error(`Error toggling autopilot:`,e),alert(`Error connecting to the backend Space.`)}finally{s(!1)}},disabled:o,style:{...N.toggleBtn,background:e?`var(--success)`:`rgba(255,255,255,0.05)`,color:e?`#000`:`var(--text-secondary)`,boxShadow:e?`0 0 15px rgba(16,185,129,0.4)`:`none`},children:o?`PENDING...`:e?`AUTOPILOT: ON`:`AUTOPILOT: OFF`})]}),(0,b.jsxs)(`div`,{className:`form-group`,style:{marginTop:`24px`},children:[(0,b.jsx)(`label`,{className:`form-label`,children:`Simulated Loop Frequency`}),(0,b.jsxs)(`select`,{value:n,onChange:e=>r(parseInt(e.target.value)),className:`form-select`,disabled:e,children:[(0,b.jsx)(`option`,{value:`60000`,children:`Every 1 Minute (Optimal Testing)`}),(0,b.jsx)(`option`,{value:`3600000`,children:`Every 1 Hour (Standard Scaling)`}),(0,b.jsx)(`option`,{value:`86400000`,children:`Every 24 Hours (Daily Automation)`})]})]}),(0,b.jsxs)(`div`,{style:N.strategyBox,children:[(0,b.jsxs)(`div`,{style:N.strategyHeader,children:[(0,b.jsx)(`span`,{style:N.pulsePoint}),(0,b.jsx)(`strong`,{children:`Autopilot Strategy Blueprint`})]}),(0,b.jsxs)(`ul`,{style:N.strategyList,children:[(0,b.jsxs)(`li`,{children:[`🔍 `,(0,b.jsx)(`strong`,{children:`Scans Hot KDP Trends`}),`: Focuses on high-yield, high-interest niches.`]}),(0,b.jsxs)(`li`,{children:[`✍️ `,(0,b.jsx)(`strong`,{children:`Groq Llama 3 70B Generation`}),`: Generates beautifully styled and humanized book content.`]}),(0,b.jsxs)(`li`,{children:[`🖼️ `,(0,b.jsx)(`strong`,{children:`SDXL High-Res Cover Art`}),`: Automatically designs matched aesthetic book covers.`]}),(0,b.jsxs)(`li`,{children:[`📦 `,(0,b.jsx)(`strong`,{children:`Automated ZIP Packaging`}),": Packages `book.md`, `cover.jpg`, and complete publishing metadata (`listing.txt`) into a single ZIP for manual publishing."]})]})]})]}),(0,b.jsxs)(`div`,{className:`glass-card`,style:N.terminalCard,children:[(0,b.jsxs)(`div`,{className:`card-header`,children:[(0,b.jsx)(`h2`,{style:N.cardTitle,children:`Agent Thought Stream Terminal`}),e&&(0,b.jsx)(`span`,{style:N.runningBadge,children:`ACTIVE RUNNING`})]}),(0,b.jsx)(`p`,{style:N.cardDescription,children:`Live telemetry stream capturing Llama 3 background creation sequences.`}),(0,b.jsxs)(`div`,{style:N.terminalContainer,children:[i.slice().reverse().map((e,t)=>{let n=e.match(/(https?:\/\/\S+)/i),r=e.includes(`❌`)?`var(--danger)`:e.includes(`✅`)?`var(--success)`:e.includes(`🚀`)?`var(--secondary)`:`#a78bfa`;if(n){let i=n[1],a=e.split(i);return(0,b.jsxs)(`div`,{style:{...N.terminalLine,color:r},children:[a[0],(0,b.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,style:{color:`#ff90e8`,fontWeight:`800`,textDecoration:`underline`},children:i}),a[1]]},t)}return(0,b.jsx)(`div`,{style:{...N.terminalLine,color:r},children:e},t)}),(0,b.jsx)(`div`,{ref:c})]})]})]})]})}var N={container:{padding:`30px 40px`},header:{marginBottom:`32px`},heading:{fontSize:`28px`,color:`#fff`},subheading:{color:`var(--text-secondary)`,fontSize:`14px`,marginTop:`4px`},mainGrid:{display:`grid`,gridTemplateColumns:`1fr 1.6fr`,gap:`30px`},controlCard:{height:`fit-content`},sectionTitle:{fontSize:`18px`,color:`#fff`,display:`flex`,alignItems:`center`,gap:`8px`,marginBottom:`20px`},toggleRow:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,background:`rgba(15,23,42,0.4)`,border:`1px solid var(--border-glow)`,borderRadius:`12px`,padding:`18px`},toggleBtn:{border:`none`,borderRadius:`8px`,padding:`12px 20px`,fontWeight:`800`,fontSize:`12px`,cursor:`pointer`,letterSpacing:`0.05em`,transition:`all 0.3s cubic-bezier(0.4, 0, 0.2, 1)`},strategyBox:{background:`rgba(6,9,19,0.5)`,border:`1px solid var(--border-glow)`,borderRadius:`10px`,padding:`16px`,marginTop:`24px`},strategyHeader:{display:`flex`,alignItems:`center`,gap:`8px`,fontSize:`13px`,color:`var(--secondary)`,marginBottom:`12px`},pulsePoint:{width:`6px`,height:`6px`,borderRadius:`50%`,background:`var(--secondary)`,boxShadow:`0 0 6px var(--secondary)`},strategyList:{paddingLeft:`18px`,fontSize:`12px`,color:`var(--text-secondary)`,display:`flex`,flexDirection:`column`,gap:`8px`},terminalCard:{display:`flex`,flexDirection:`column`,maxHeight:`600px`},cardTitle:{fontSize:`18px`,color:`#fff`},cardDescription:{fontSize:`13px`,color:`var(--text-secondary)`,marginBottom:`20px`},runningBadge:{fontSize:`10px`,fontWeight:`800`,background:`rgba(16, 185, 129, 0.1)`,color:`var(--success)`,padding:`3px 8px`,borderRadius:`4px`,boxShadow:`0 0 8px rgba(16,185,129,0.2)`},terminalContainer:{flexGrow:1,background:`#040711`,border:`1px solid var(--border-glow)`,borderRadius:`12px`,padding:`20px`,minHeight:`400px`,overflowY:`auto`,display:`flex`,flexDirection:`column`,gap:`10px`,boxShadow:`inset 0 4px 20px rgba(0,0,0,0.8)`,fontFamily:`monospace`,fontSize:`11px`,lineHeight:`1.5`},terminalLine:{whiteSpace:`pre-wrap`,textShadow:`0 0 2px rgba(167, 139, 250, 0.3)`}},ce=[{id:`gumroad`,name:`Gumroad`,emoji:`🟠`,color:`#ff90e8`,hint:`E-books, templates, courses, digital downloads`},{id:`etsy`,name:`Etsy`,emoji:`🟡`,color:`#f1c40f`,hint:`Printable planners, templates, digital art`},{id:`kdp`,name:`Amazon KDP`,emoji:`🔵`,color:`#4a90e2`,hint:`Kindle e-books and paperbacks`},{id:`kofi`,name:`Ko-fi`,emoji:`☕`,color:`#13c3ff`,hint:`Digital products, memberships, donations`},{id:`payhip`,name:`Payhip`,emoji:`💜`,color:`#9b59b6`,hint:`Simple digital downloads store`},{id:`creative`,name:`Creative Market`,emoji:`🎨`,color:`#e74c3c`,hint:`Fonts, graphics, website templates`},{id:`teachable`,name:`Teachable`,emoji:`🎓`,color:`#2ecc71`,hint:`Online courses and memberships`},{id:`envato`,name:`Envato Market`,emoji:`🟢`,color:`#27ae60`,hint:`Themes, code, graphics, audio`}];function P(){let[e,t]=(0,_.useState)(`gumroad`),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(null),[y,x]=(0,_.useState)(!1),[S,w]=(0,_.useState)(``),[T,ee]=(0,_.useState)(()=>localStorage.getItem(`gumroad_token`)||``),[E,D]=(0,_.useState)(!1),[te,ne]=(0,_.useState)(``),[re,ie]=(0,_.useState)(``),[O,ae]=(0,_.useState)(!1),[k,A]=(0,_.useState)(``),[j,oe]=(0,_.useState)(``),[M,se]=(0,_.useState)(null),[N,P]=(0,_.useState)(``),le=ce.find(t=>t.id===e),ue=e=>{let t=e.target.value;ee(t),localStorage.setItem(`gumroad_token`,t)},de=async()=>{if(!n.trim()){alert(`Please enter a niche or topic!`);return}a(!0),s(`listing`),d(null),p(null),h(``),w(``),ie(``),ne(``);try{let t=await fetch(`${C}/api/generate-product`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({platform:e,niche:n.trim()})});if(!t.ok)throw Error(`Failed to generate product`);let r=await t.json();if(d(r),r.thumbnailPrompt){s(`cover`);try{let e=await fetch(`${C}/api/generate-cover`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prompt:r.thumbnailPrompt,title:r.title})});if(e.ok){let t=await e.json();p(t.imageUrl),h(t.coverUrl)}}catch(e){console.warn(`Auto thumbnail generation failed:`,e.message)}}}catch(e){alert(`Error generating product: `+e.message)}finally{a(!1),s(``)}},fe=async()=>{if(!j.trim()){alert(`Please enter a general topic/niche!`);return}ae(!0),A(`optimizing`),se(null),P(``);try{let e=await fetch(`${C}/api/generate-product`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({platform:`kdp`,niche:j.trim()})});if(!e.ok)throw Error(`Failed to generate best-seller content`);let t=await e.json();se(t),A(`zipping`);let n=await fetch(`${C}/api/generate-package`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:t.title,subtitle:t.subtitle,description:t.description,tags:t.tags,cta:t.cta,price:t.price,platform:`kdp`,productContent:t.productContent,thumbnailPrompt:t.thumbnailPrompt})});if(!n.ok)throw Error(`Failed to package ZIP archive`);let r=await n.json();P(r.packageUrl),window.location.href=r.packageUrl;try{await fetch(`${C}/api/catalog`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:t.title,subtitle:t.subtitle,type:`study_guide`,price:t.price,platform:`kdp`,tags:t.tags,thumbnail_url:t.thumbnailUrl||``,sales_copy:t.description,status:`ready_to_publish`,published_url:r.packageUrl})})}catch(e){console.warn(`Silent save to catalog failed:`,e.message)}}catch(e){alert(`Error packaging best-seller book: `+e.message)}finally{ae(!1),A(``)}},pe=()=>{if(!M?.productContent)return;let e=new Blob([M.productContent],{type:`text/markdown`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${M.title.replace(/[^a-zA-Z0-9]/g,`_`).toLowerCase()}_manuscript.md`,n.click(),URL.revokeObjectURL(t)},me=()=>{if(!M?.productContent)return;let e=window.open(``,`_blank`),t=M.productContent,n=[];for(let e=1;e<=5;e++){let r=`Chapter ${e}`,i=t.indexOf(r),a=-1;if(i!==-1&&(a=t.indexOf(r,i+r.length),a===-1&&(a=i)),a!==-1){let r=t.length;if(e<5){let n=`Chapter ${e+1}`,i=t.indexOf(n),a=-1;i!==-1&&(a=t.indexOf(n,i+n.length),a===-1&&(a=i)),a!==-1&&(r=a)}let i=t.substring(a,r).trim();i.endsWith(`#`)&&(i=i.substring(0,i.lastIndexOf(`#`)).trim()),n.push(i)}else n.push(`Chapter ${e}\n\nContent for chapter ${e} is detailed here.`)}let r=``;r+=`
 
 
 
593
  <div class="page left-page cover-page">
594
  <div class="header-brand">BOOKFORGE DIGITAL HUBS</div>
595
  <div class="cover-interior">
 
600
  </div>
601
  <div class="cover-footer">BOOKFORGE PREMIUM EDITION</div>
602
  </div>
603
+ `,r+=`
604
  <div class="page right-page copyright-page">
605
  <div class="header-brand">BOOKFORGE BINDERY & REGISTRATION</div>
606
  <div class="interior-content">
 
618
  </div>
619
  <div class="page-number">Page 2</div>
620
  </div>
621
+ `,r+=`
622
  <div class="page left-page toc-page">
623
  <div class="header-brand">CONTENTS INDEX</div>
624
  <div class="interior-content">
 
640
  </div>
641
  <div class="page-number">Page 3</div>
642
  </div>
643
+ `,r+=`
644
  <div class="page right-page preface-page">
645
  <div class="header-brand">AUTHOR PREFACE</div>
646
  <div class="interior-content">
 
653
  </div>
654
  <div class="page-number">Page 4</div>
655
  </div>
656
+ `;let i=5;for(let e=0;e<5;e++){let t=i%2==0?`right-page`:`left-page`,a=n[e],o=a.split(`
657
+ `)[0].replace(/#+/g,``).replace(/:/g,``).trim().toUpperCase(),s=a.split(`
658
  `).slice(1).join(`
659
+ `).replace(/\n/g,`<br>`).replace(/✓ (.*?)(?=<br>)/g,`<li>✓ $1</li>`);r+=`
660
  <div class="page ${t} chapter-cover">
661
  <div class="header-brand">CHAPTER DIVISION ${e+1}</div>
662
  <div class="chapter-cover-interior">
663
  <span class="chapter-number">CHAPTER 0${e+1}</span>
664
  <div class="cover-divider"></div>
665
+ <h2>${o}</h2>
666
+ <p style="font-size: 11px; text-transform:uppercase; color:#333; letter-spacing:1px; margin-top:20px;">Detailed Written Guide & Workbook Interior</p>
667
  </div>
668
+ <div class="page-number">Page ${i}</div>
669
  </div>
670
+ `,i++;let c=i%2==0?`right-page`:`left-page`;r+=`
671
  <div class="page ${c} chapter-content">
672
+ <div class="header-brand">${o}</div>
673
  <div class="chapter-text-interior">
674
  <h3>DEVELOPMENTAL MANUAL OUTLINE</h3>
675
+ <p>${s}</p>
676
  </div>
677
+ <div class="page-number">Page ${i}</div>
678
  </div>
679
+ `,i++;let l=e===4?18:22;for(let t=0;t<l;t++){let n=i%2==0?`right-page`:`left-page`,a=``;a=e===0?t%2==0?`
680
  <h2>DAILY FOCUS TRACKER</h2>
681
  <div class="divider"></div>
682
  <div class="box">
 
801
  <div class="dot-grid">
802
  ${`<div class="dot">.</div>`.repeat(80)}
803
  </div>
804
+ `,r+=`
805
  <div class="page ${n}">
806
  <div class="header-brand">BOOKFORGE DIGITAL GOAL PLANNERS</div>
807
  <div class="page-interior">
808
+ ${a}
809
  </div>
810
+ <div class="page-number">Page ${i}</div>
811
  </div>
812
+ `,i++}}e.document.write(`
813
  <html>
814
  <head>
815
  <title>${M.title} - 120 Pages</title>
 
819
  .page { page-break-after: always; display: flex !important; }
820
  @page { size: 6in 9in; margin: 0; }
821
  }
822
+ * {
823
+ box-sizing: border-box;
824
+ -webkit-print-color-adjust: exact !important;
825
+ print-color-adjust: exact !important;
826
+ }
827
  body {
828
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
829
+ color: #000;
830
  margin: 0;
831
  padding: 0;
832
+ background: #fff;
833
  }
834
  .page {
835
  background: #fff;
836
  width: 6in;
837
  height: 9in;
838
+ margin: 0 auto;
839
  position: relative;
840
  display: flex;
841
  flex-direction: column;
842
  justify-content: space-between;
843
+ border: none;
 
844
  }
845
+ /* Gutter Margins Alternating (Perfect Spine Binding) */
846
  .left-page {
847
  padding: 0.8in 0.75in 0.8in 0.4in;
848
  }
 
851
  }
852
  .header-brand {
853
  font-size: 8px;
854
+ color: #444;
855
  letter-spacing: 2px;
856
  text-align: center;
857
+ border-bottom: 2px solid #000;
858
  padding-bottom: 6px;
859
  text-transform: uppercase;
860
+ font-weight: 700;
861
  }
862
  .page-interior {
863
  flex-grow: 1;
 
869
  .interior-content {
870
  padding: 40px 10px 0 10px;
871
  }
872
+ /* Cover page styling */
873
  .cover-page {
874
  justify-content: space-between;
875
  padding: 1.2in 0.6in;
876
  text-align: center;
877
+ border: 3px solid #000;
878
  }
879
  .cover-interior {
880
  display: flex;
881
  flex-direction: column;
882
  align-items: center;
883
+ margin-top: 1.5in;
884
  }
885
  .cover-title {
886
  font-family: 'Georgia', serif;
887
+ font-size: 26px;
888
  font-weight: 900;
889
  text-transform: uppercase;
890
  letter-spacing: 1px;
891
  line-height: 1.3;
892
  margin: 0 0 15px 0;
893
+ color: #000;
894
  }
895
  .cover-divider {
896
+ width: 80px;
897
+ height: 4px;
898
+ background: #000;
899
+ margin: 15px 0;
900
  }
901
  .cover-subtitle {
902
  font-family: 'Georgia', serif;
903
+ font-size: 14px;
904
+ color: #111;
905
  font-style: italic;
906
  line-height: 1.5;
907
  margin: 15px 0;
908
+ max-width: 4.5in;
909
  }
910
  .cover-tag {
911
+ font-size: 10px;
912
+ font-weight: 900;
913
+ border: 2px solid #000;
914
  border-radius: 4px;
915
+ padding: 6px 12px;
916
+ margin-top: 40px;
917
+ letter-spacing: 2px;
918
+ display: inline-block;
919
+ text-transform: uppercase;
920
  }
921
  .cover-footer {
922
+ font-size: 10px;
923
+ font-weight: 900;
924
+ letter-spacing: 4px;
925
+ color: #000;
926
+ margin-bottom: 0.5in;
927
  }
928
+ /* Copyright page styling */
929
  .copyright-page h3 {
930
+ font-size: 12px;
931
+ font-weight: 800;
932
  margin-bottom: 8px;
933
+ text-transform: uppercase;
934
  }
935
  .copyright-page p {
936
+ font-size: 10px;
937
  line-height: 1.5;
938
+ color: #111;
939
  text-align: justify;
940
+ margin: 0 0 18px 0;
941
  }
942
+ /* TOC table */
943
  .toc-list {
944
  display: flex;
945
  flex-direction: column;
946
  gap: 12px;
947
+ margin-top: 30px;
948
  }
949
  .toc-item {
950
  display: flex;
951
  justify-content: space-between;
952
+ font-size: 10px;
953
  font-weight: bold;
954
+ color: #000;
955
  }
956
  .dots {
957
  flex-grow: 1;
958
  text-align: center;
959
+ color: #333;
960
  overflow: hidden;
961
  white-space: nowrap;
962
  margin: 0 10px;
963
  }
964
+ /* Chapter divisions cover */
965
  .chapter-cover {
966
  justify-content: space-between;
967
  padding: 1.2in 0.6in;
968
  text-align: center;
969
+ border: 2px solid #000;
970
  }
971
  .chapter-cover-interior {
972
  display: flex;
973
  flex-direction: column;
974
  align-items: center;
975
+ margin-top: 2in;
976
  }
977
  .chapter-number {
978
+ font-size: 12px;
979
+ font-weight: 900;
980
+ letter-spacing: 4px;
981
+ color: #000;
982
  }
983
  .chapter-cover h2 {
984
  font-family: 'Georgia', serif;
985
+ font-size: 22px;
986
+ font-weight: 900;
987
+ margin-top: 20px;
988
  }
989
+ /* Chapter text summaries */
990
  .chapter-content {
991
  font-family: 'Georgia', serif;
992
+ line-height: 1.7;
993
  }
994
  .chapter-text-interior {
995
  padding: 30px 10px;
996
  text-align: justify;
997
  }
998
  .chapter-text-interior h3 {
999
+ font-size: 13px;
1000
+ font-weight: 900;
1001
+ border-bottom: 2px solid #000;
1002
  padding-bottom: 6px;
1003
+ margin-bottom: 18px;
1004
  letter-spacing: 1px;
1005
  }
1006
  .chapter-text-interior p {
1007
  font-size: 11px;
1008
  line-height: 1.7;
1009
+ color: #000;
1010
+ margin-bottom: 14px;
1011
  }
1012
  .chapter-text-interior li {
1013
  font-size: 11px;
1014
+ margin-left: 15px;
1015
  list-style-type: none;
1016
+ margin-bottom: 8px;
1017
+ color: #000;
1018
+ font-weight: 600;
1019
  }
1020
+ /* High-Contrast Workbook Elements */
1021
  h2 {
1022
  font-size: 14px;
1023
+ font-weight: 900;
1024
  text-align: center;
1025
  margin: 0 0 5px 0;
1026
  letter-spacing: 1px;
1027
+ text-transform: uppercase;
1028
  }
1029
  .divider {
1030
+ height: 3px;
1031
+ background: #000;
1032
+ width: 40px;
1033
  margin: 0 auto 10px auto;
1034
  }
1035
  .box {
1036
+ border: 2px solid #000;
1037
  border-radius: 6px;
1038
+ padding: 12px 16px;
1039
  display: flex;
1040
  flex-direction: column;
1041
+ gap: 12px;
1042
  background: #fff;
1043
  }
1044
  .label {
1045
+ font-size: 9px;
1046
+ font-weight: 900;
1047
+ letter-spacing: 1.5px;
1048
+ color: #000;
1049
+ border-bottom: 2px solid #000;
1050
  padding-bottom: 4px;
1051
  text-transform: uppercase;
1052
  }
1053
  .line {
1054
+ border-bottom: 2px dotted #000;
1055
  height: 20px;
1056
  width: 100%;
1057
  }
1058
  .checkbox-row {
1059
  display: flex;
1060
  align-items: center;
1061
+ gap: 12px;
1062
  }
1063
  .checkbox {
1064
+ width: 16px;
1065
+ height: 16px;
1066
+ border: 2.5px solid #000;
1067
  border-radius: 3px;
1068
  flex-shrink: 0;
1069
+ background: #fff;
1070
  }
1071
  .doodle-placeholder {
1072
+ border: 2px dashed #000;
1073
  border-radius: 4px;
1074
  flex-grow: 1;
1075
+ min-height: 80px;
1076
+ background: #fff;
1077
  }
1078
  .habit-row {
1079
  display: flex;
1080
  align-items: center;
1081
  justify-content: space-between;
1082
+ gap: 12px;
1083
  }
1084
  .circles {
1085
+ font-size: 15px;
1086
+ letter-spacing: 4px;
1087
+ color: #000;
1088
  }
1089
+ /* Dot Grid journaling */
1090
  .dot-grid {
1091
  display: grid;
1092
  grid-template-columns: repeat(8, 1fr);
1093
+ grid-gap: 25px;
1094
+ padding: 30px 40px;
1095
+ opacity: 0.35;
1096
  flex-grow: 1;
1097
  }
1098
  .dot {
1099
+ font-size: 26px;
1100
  text-align: center;
1101
  line-height: 0;
1102
+ color: #000;
1103
+ font-weight: 900;
1104
  }
1105
+ /* Priority Matrix 2x2 grid */
1106
  .matrix-grid {
1107
  display: grid;
1108
  grid-template-columns: 1fr 1fr;
 
1112
  padding: 10px 0;
1113
  }
1114
  .matrix-box {
1115
+ border: 2px solid #000;
1116
  border-radius: 6px;
1117
+ padding: 12px;
1118
  display: flex;
1119
  flex-direction: column;
1120
  justify-content: space-between;
1121
  }
1122
+ /* Double Column budget/case tables */
1123
  .budget-table {
1124
  width: 100%;
1125
  border-collapse: collapse;
1126
  margin-top: 10px;
1127
  }
1128
  .budget-table th {
1129
+ font-size: 9px;
1130
+ font-weight: 900;
1131
  text-align: left;
1132
+ padding: 8px;
1133
+ border-bottom: 3px solid #000;
1134
+ text-transform: uppercase;
1135
  }
1136
  .budget-table td {
1137
+ padding: 12px 8px;
1138
+ border-bottom: 2px solid #000;
1139
+ font-size: 11px;
1140
+ color: #000;
1141
  }
1142
  .page-number {
1143
  text-align: center;
1144
+ font-size: 10px;
1145
+ color: #000;
1146
+ border-top: 2px solid #000;
1147
  padding-top: 6px;
1148
+ font-weight: 700;
1149
  }
1150
  </style>
1151
  </head>
1152
  <body>
1153
+ ${r}
1154
  <script>
1155
  window.onload = function() { window.print(); }
1156
  <\/script>
index.html CHANGED
@@ -5,7 +5,7 @@
5
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
  <title>BookForge Digital - Premium AI Book Publisher & Dashboard</title>
8
- <script type="module" crossorigin src="/assets/index-4x_ttUEu.js"></script>
9
  <link rel="stylesheet" crossorigin href="/assets/index-D3V6GKGj.css">
10
  </head>
11
  <body>
 
5
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
  <title>BookForge Digital - Premium AI Book Publisher & Dashboard</title>
8
+ <script type="module" crossorigin src="/assets/index-bJnV20--.js"></script>
9
  <link rel="stylesheet" crossorigin href="/assets/index-D3V6GKGj.css">
10
  </head>
11
  <body>