1import{j as e,u as mt}from"./vendor-query-CKtLK1dq.js";import{w as R,bL as lt,I as Te,ak as pt,u as ut,r as je,cl as ht,c3 as gt,ck as bt,cV as kt,cW as ft,cX as jt,cY as _t,b4 as vt,cZ as Nt,c_ as wt,d as ee,c$ as Qe,a3 as yt,cz as Re,cA as Pe,l as J,b as me,aB as Ye,d0 as St,M as _e,d1 as Ct,bV as $e,a2 as ve,g as Ne,d2 as At,bZ as Xe,b_ as Je,co as Lt,d3 as Tt}from"./index-CvWaq0wg.js";import{A as Mt}from"./AutoGrowTextarea-IR9FaccU.js";import{r as F,i as It,d as Rt,c as Pt}from"./vendor-react-jvDhuP46.js";import{A as Ze}from"./AiRequestsPanel-By6QNQl5.js";import{g as Ee,A as $t}from"./AiCostBreakdownModal-DHyNoXqr.js";import{T as we}from"./Toggle-cv-SuYBU.js";import{t as De,i as Et,z as zt}from"./timezone-C-o5P0La.js";import"./vendor-axios-DEWho_Gc.js";import"./vendor-i18n-DMkF1ssK.js";const Bt={anchor_alternatives:"Anchor Alternatives",slug:"URL Slug",title:"Title",type:"Content Type",search_locale:"Search Locale",has_previous:"Has Previous Version",previous_version:"Previous Version",previous_word_count:"Previous Word Count",assets_preserved:"Assets Preserved",search_urls:"Search URLs Found",search_queries:"Search Queries",queries_with_providers:"Queries With Providers",search_results:"Search Results",url_contents:"Pages Scraped",collected_data:"Data Sources Collected",failed_urls:"Failed URLs",sources_count:"Total Sources",total_chars:"Characters Collected",total_links:"Total Links Found",relevant_links:"Relevant Links",banned_links_removed:"Banned Links Removed",kb_links_removed:"KB Links Removed",pages_scraped:"Pages Scraped",cache_hits:"Cache Hits",fresh_scrapes:"Fresh Scrapes",entities_resolved:"Entities Resolved",entity_names:"Entities",category:"Category",category_id:"Category",tags:"Tags",tag_ids:"Tags",tag_names:"Tags Attached",category_name:"Category",fields_checked:"Fields Checked",optimization_attempts:"AI Optimization Attempts",field_report:"Field Report",meta_keywords:"Meta Keywords",og_description:"Open Graph Description",twitter_title:"Twitter Title",twitter_description:"Twitter Description",excerpt:"Excerpt",structure_pattern:"Content Pattern",pattern:"Content Pattern",sections_count:"Total Sections",section_types:"Section Types",section_layout:"Section Layout",sections_config:"Section Config",sections:"Sections",structure_reasoning:"AI Reasoning",internal_link_count:"Internal Links",internal_links:"Internal Link URLs",external_links:"External Links",generated_sections:"Sections Generated",strong_keyword_selected_count:"Strong Keywords Selected",strong_keyword_applied_count:"Strong Keywords Applied",strong_keyword_selections:"Strong Keyword Selections",word_count:"Word Count",heading_count:"Headings",quality_score:"Quality Score",validation_passed:"Validation Passed",passed:"Validation Passed",issues:"Issues Found",suggestions:"Suggestions",validation_summary:"Validation Summary",meta_title:"Meta Title",meta_description:"Meta Description",og_title:"Open Graph Title",focus_keyword:"Focus Keyword",waiting_image:"Async Image Generation",image_generated:"Image Generated",featured_image:"Featured Image",image_url:"Image URL",preserved_inline_assets:"Inline Assets Preserved",skipped:"Skipped",skip_reason:"Skip Reason",candidate_count:"Candidate Articles",ai_attempted:"AI Request Made",ai_error:"AI Request Error",selected_article:"Selected Partner Article",version_number:"Version",creation_reason:"Creation Reason",categories_attached:"Categories Attached",tags_attached:"Tags Attached",fields_optimized:"Fields Optimized",truncated_fields:"Truncated Fields",completed:"Completed Successfully",completed_at:"Completed At",final_status:"Final Status",published:"Auto Published",notification_sent:"Notification Sent",image_metadata_cleaned:"Metadata Cleaned",image_metadata_applied:"Custom Metadata Applied",clean_source_image_path:"Clean Source Path",clean_image_path:"Clean Image Path",clean_image_url:"Clean Image",image_watermark_applied:"Watermark Applied",watermark_source_image_path:"Watermark Source Path",watermarked_image_path:"Watermarked Image Path",watermarked_image_url:"Watermarked Image",watermark_position:"Watermark Position",watermark_type:"Watermark Type",logo_used:"Logo Used",base_image_path:"Base Image Path",base_image_url:"Base Image",image_title_overlay_applied:"Title Overlay Applied",title_overlay_source_image_path:"Title Source Path",titled_image_path:"Titled Image Path",titled_image_url:"Titled Image",title_overlay_template:"Title Template",variants_source_image_path:"Variants Source Path",variants_source_image_url:"Variants Source Image",og_image_url:"OG Variant",medium_image_url:"Medium Variant",small_image_url:"Small Variant",thumbnail_image_url:"Thumbn
1ail Variant",image_variants:"Image Variants",image_variants_count:"Variants Generated",facts:"Facts",statistics:"Statistics",regulations:"Regulations",costs:"Costs",requirements:"Requirements",processes:"Processes",trends:"Trends",comparisons:"Comparisons",definitions:"Definitions",recommendations:"Recommendations",quotes:"Quotes",categories_extracted:"Categories Extracted",sections_selected:"Sections Selected",section_ids:"Section IDs"},Wt={Initialize:"Sets up content metadata, generates URL slug, and prepares the generation context.","Analyze Previous":"Checks for existing versions to preserve assets and inform the update strategy.","Collect Data":"Searches the web and gathers research data to inform the content generation.","Collect Knowledge Base":"Retrieves relevant knowledge base articles to provide domain-specific context.","Summarize Knowledge Base":"Summarizes knowledge base content for use in generation context.","Filter Links":"Uses AI to filter and rank search results by relevance, removing banned links.","Scrape Internet Pages":"Scrapes the filtered URLs to extract internet page content for research context.","Process Internet Data":"Processes and cleans scraped internet data for the pipeline.","Resolve Entities":"Identifies and resolves key entities (people, companies, concepts) from the research data.","Generate Statistics":"Builds a validated statistics pool and chart candidates from research data so charts can be planned from trusted numbers.","Generate Taxonomy":"Uses AI to decide which category and tags fit the content, then creates or finds them in your taxonomy.","Select Structure":"Chooses the optimal content structure pattern based on the topic.","Prepare Links":"Gathers internal and external links to weave into the content.","Generate Structure":"Generates the full content body using AI with the chosen structure.","Validate Structure":"Validates content quality, readability, and structure integrity.","Apply Strong Keywords":"Selects high-value strong keywords and applies emphasis metadata to finalized sections.","Render Chart Images":"Renders chart sections as PNG image variants after editorial mutations so discarded or renamed charts stay in sync.","Generate SEO":"Generates SEO metadata: meta title, description, and Open Graph data.","Prepare Image":"Generates or prepares a featured image for the content.","Clean Image":"Strips AI-generated metadata from the image and optionally applies custom brand metadata.","Watermark Image":"Applies brand watermark (logo or text) to the image. Free tier uses ContentPulse branding; pro users can use their own logo. Creates a base image for translation reuse.","Title Image Overlay":"Overlays the content title on the image using a layout template (upper-mid, center, lower-mid, left-aligned, right-aligned). Template selection can be randomized. Re-run per translation with a different title.","Generate Image Variants":"Generates responsive image variants (Open Graph, medium, small, thumbnail) with WebP support for modern browsers.","Optimize Fields":"Checks and optimizes meta fields to meet character limits for search engines.","Create Version":"Creates a new content version record with the optimized content.",Complete:"Finalizes the content, sends notifications, and marks the run as complete."},Ot={Initialize:e.jsxs("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 010 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.954.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 010-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.
1125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),"Analyze Previous":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m5.231 13.481L15 17.25m-4.5-15H5.625c-.621 0-1.125.504-1.125 1.125v16.5c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9zm3.75 11.625a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z"})}),"Collect Data":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 21a9.004 9.004 0 008.716-6.747M12 21a9.004 9.004 0 01-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 017.843 4.582M12 3a8.997 8.997 0 00-7.843 4.582m15.686 0A11.953 11.953 0 0112 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0121 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0112 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 013 12c0-1.605.42-3.113 1.157-4.418"})}),"Collect Knowledge Base":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25"})}),"Summarize Knowledge Base":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.129.166 2.27.293 3.423.379.35.026.67.21.865.501L12 21l2.755-4.133a1.14 1.14 0 01.865-.501 48.172 48.172 0 003.423-.379c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.
1123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z"})}),"Filter Links":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 3c2.755 0 5.455.232 8.083.678.533.09.917.556.917 1.096v1.044a2.25 2.25 0 01-.659 1.591l-5.432 5.432a2.25 2.25 0 00-.659 1.591v2.927a2.25 2.25 0 01-1.244 2.013L9.75 21v-6.568a2.25 2.25 0 00-.659-1.591L3.659 7.409A2.25 2.25 0 013 5.818V4.774c0-.54.384-1.006.917-1.096A48.32 48.32 0 0112 3z"})}),"Scrape Internet Pages":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),"Process Internet Data":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M20.25 6.375c0 2.278-3.694 4.125-8.25 4.125S3.75 8.653 3.75 6.375m16.5 0c0-2.278-3.694-4.125-8.25-4.125S3.75 4.097 3.75 6.375m16.5 0v11.25c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125V6.375m16.5 0c-2.278 0-4.125 1.847-4.125 4.125v11.25c0 2.278 1.847 4.125 4.125 4.125s4.125-1.847 4.125-4.125V6.375c0-2.278-1.847-4.125-4.125-4.125z"})}),"Resolve Entities":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3.75 3v11.25A2.25 2.25 0 006 16.5h2.25M3.75 3h-1.5m1.5 0h16.5m0 0h1.5m-1.5 0v11.25A2.25 2.25 0 0118 16.5h-2.25m-7.5 0h7.5m-7.5 0l-1 3m8.5-3l1 3m0 0l.5 1.5m-.5-1.5h-9.5m0 0l-.5 1.5m.75-9l3-3 2.148 2.148A12.061 12.061 0 0116.5 7.605"})}),"Generate Statistics":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 013 19.875v-6.75zM9.75 8.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v11.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V8.625zM16.5 4.125c0-.621.504-1.125 1.125-1.125h2.25C20.496 3 21 3.504 21 4.125v15.75c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V4.125z"})}),"Generate Taxonomy":e.jsxs("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.568 3H5.25A2.25 2.25 0 003 5.25v4.318c0 .597.237 1.17.659 1.591l9.581 9.581c.699.699 1.78.872 2.607.33a18.095 18.095 0 005.223-5.223c.542-.827.369-1.908-.33-2.607L11.16 3.66A2.25 2.25 0 009.568 3z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M6 6h.008v.008H6V6z"})]}),"Select Structure":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3.75 6A2.25 2.25 0 016 3.75h2.25A2.25 2.25 0 0110.5 6v2.25a2.25 2.25 0 01-2.25 2.25H6a2.25 2.25 0 01-2.25-2.25V6zM3.75 15.75A2.25 2.25 0 016 13.5h2.25a2.25 2.25 0 012.25 2.25V18a2.25 2.25 0 01-2.25 2.25H6A2.25 2.25 0 013.75 18v-2.25zM13.5 6a2.25 2.25 0 012.25-2.25H18A2.25 2.25 0 0120.25 6v2.25A2.25 2.25 0 0118 10.5h-2.25a2.25 2.25 0 01-2.25-2.25V6zM13.5 15.75a2.25 2.25 0 012.25-2.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-2.25A2.25 2.25 0 0113.5 18v-2.25z"})}),"Prepare Links":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M13.19 8.688a4.5 4.5 0 011.242 7.244l-4.5 4.5a4.5 4.5 0 01-6.364-6.364l1.757-1.757m13.35-.622l1.757-1.757a4.5 4.5 0 00-6.364-6.364l-4.5 4.5a4.5 4.5 0 001.242 7.244"})}),"Generate Structure":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09
1L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456zM16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z"})}),"Validate Structure":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 013.598 6 11.99 11.99 0 003 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285z"})}),"Apply Strong Keywords":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8.25 6.75h7.5M8.25 12h7.5m-7.5 5.25h4.5M5.25 3h13.5A2.25 2.25 0 0121 5.25v13.5A2.25 2.25 0 0118.75 21H5.25A2.25 2.25 0 013 18.75V5.25A2.25 2.25 0 015.25 3z"})}),"Render Chart Images":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909M2.25 18.75h19.5M3 20.25h18A1.5 1.5 0 0022.5 18.75V5.25A1.5 1.5 0 0021 3.75H3A1.5 1.5 0 001.5 5.25v13.5A1.5 1.5 0 003 20.25z"})}),"Generate SEO":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"})}),"Prepare Image":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909M2.25 18.75h19.5M3 20.25h18A1.5 1.5 0 0022.5 18.75V5.25A1.5 1.5 0 0021 3.75H3A1.5 1.5 0 001.5 5.25v13.5A1.5 1.5 0 003 20.25z"})}),"Create Version":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m3.75 9v6m3-3H9m1.5-12H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),"Optimize Fields":e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M10.5 6h9.75M10.5 6a1.5 1.5 0 11-3 0m3 0a1.5 1.5 0 10-3 0M3.75 6H7.5m3 12h9.75m-9.75 0a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m-3.75 0H7.5m9-6h3.75m-3.75 0a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m-9.75 0h9.75"})}),Complete:e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 3v1.5M3 21v-6m0 0l2.77-.693a9 9 0 016.208.682l.108.054a9 9 0 006.086.71l3.114-.732a48.524 48.524 0 01-.005-10.499l-3.11.732a9 9 0 01-6.085-.711l-.108-.054a9 9 0 00-6.208-.682L3 4.5M3 15V4.5"})})},qt=Wt,et=Bt;function tt(s){return et[s]?et[s]:s.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Ft(s,t){if(typeof t=="boolean")return t?"Yes":"No";if(t==null)return"-";if(s==="version_number"&&typeof t=="number")return`v${t}`;if(s==="quality_score"&&typeof t=="number")return`${t}/100`;if((s==="word_count"||s==="previous_word_count"||s==="total_chars"||s==="heading_count")&&typeof t=="number")return t.toLocaleString();if(s==="creation_reason"&&typeof t=="string")return t.split("_").map(c=>c.charAt(0).toUpperCase()+c.slice(1)).join(" ");if((s==="structure_pattern"||s==="pattern"||s==="final_status")&&typeof t=="string")return t.split("_").map(c=>c.charAt(0).toUpperCase()+c.slice(1)).join(" ");if(s==="completed_at"&&typeof t=="string")try{return Te(t)}catch{return t}return typeof t=="object"&&t!==null?"":String(t)}function Gt(s,t){return s==="quality_score"&&typeof t=="number"?t>=80?"text-emerald-600 dark:text-emerald-400":t>
1=50?"text-amber-600 dark:text-amber-400":"text-rose-600 dark:text-rose-400":s==="validation_passed"||s==="passed"||s==="completed"||s==="published"||s==="notification_sent"||s==="image_generated"?t?"text-emerald-600 dark:text-emerald-400":"text-slate-500 dark:text-slate-400":s==="skipped"?t?"text-amber-600 dark:text-amber-400":"text-slate-500 dark:text-slate-400":s==="failed_urls"&&typeof t=="string"&&t!=="0"?"text-rose-600 dark:text-rose-400":"text-slate-700 dark:text-slate-200"}function Vt(s){return s==="tags"||s==="section_types"||s==="tag_names"||s==="meta_keywords"||s==="entity_names"||s==="anchor_alternatives"}function Ht(s){return s==="featured_image"||s==="image_url"||s.endsWith("_image_url")}function Ut(s){return s==="field_report"}const Kt=e.jsx("svg",{className:"h-4.5 w-4.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M13 7l5 5-5 5"})}),Qt={within_limits:{label:"OK",color:"text-emerald-600 dark:text-emerald-400 bg-emerald-50 dark:bg-emerald-500/10"},too_short:{label:"Too Short",color:"text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-500/10"},too_long:{label:"Too Long",color:"text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-500/10"},ai_optimized:{label:"AI Optimized",color:"text-violet-600 dark:text-violet-400 bg-violet-50 dark:bg-violet-500/10"},truncated:{label:"Truncated",color:"text-slate-600 dark:text-slate-400 bg-slate-50 dark:bg-slate-500/10"}};function Yt(s,t){return s!=null&&s>0?s<1e3?`${s}ms`:`${(s/1e3).toFixed(1)}s`:t!=null&&t>0?`${t}s`:null}function ze(s){return!!(s.output_summary||s.error_message||s.output_detail||s.ai_requests&&s.ai_requests.length>0)}function Xt({steps:s,currentRunId:t,contentId:c,isGenerationActive:a=!0,expandAll:n=!1,canRegenerate:i=!1,regeneratingStep:l=null,onRegenerateStep:k,onRegenerateCharts:g,selectedForceSteps:y=[],onSelectedForceStepsChange:f,purposeConfigs:j}){var se;const[w,N]=F.useState(new Set),[I,W]=F.useState({}),$=F.useRef(n);F.useEffect(()=>{if(n!==$.current)if($.current=n,n){const x=new Set;s.forEach((P,G)=>{(ze(P)||P.status!=="pending")&&x.add(G)}),N(x)}else N(new Set)},[n,s]);const u=x=>{const P=s[x];!ze(P)&&P.status==="pending"||N(G=>{const z=new Set(G);return z.has(x)?z.delete(x):z.add(x),z})},O=(x,P)=>{W(G=>({...G,[x]:P}))},q=s.find(x=>x.name==="Generate Structure"),K=((se=q==null?void 0:q.output_detail)==null?void 0:se.kind)==="generated_sections"?q.output_detail:null;return e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-[19px] top-6 bottom-6 w-px bg-gradient-to-b from-slate-200 via-slate-200 to-transparent dark:from-white/10 dark:via-white/10 dark:to-transparent"}),e.jsx("div",{className:"space-y-0",children:s.map((x,P)=>{var Ce;const G=a&&x.status==="running",z=x.status==="completed",H=x.status==="failed",X=x.status==="skipped",p=x.status==="completed"&&!!(x.output_summary&&x.output_summary.skipped),T=X||p,pe=typeof((Ce=x.output_summary)==null?void 0:Ce.skip_reason)=="string"?x.output_summary.skip_reason:void 0,S=x.status==="pending",ie=ze(x),Q=w.has(P),ue=!!(ie||!S),le=Yt(x.duration_ms,x.duration_seconds),he=Ot[x.name],oe=qt[x.name],o=x.output_summary?Object.entries(x.output_summary):[],A=x.output_detail,Y=(A==null?void 0:A.kind)==="generated_sections",U=(A==null?void 0:A.kind)==="validation_result",V=(A==null?void 0:A.kind)==="resolved_entities",de=(A==null?void 0:A.kind)==="quality_check_result",ge=(A==null?void 0:A.kind)==="statistics_generation",Se=x.ai_requests&&x.ai_requests.length>0,Me=o.length>0||Y||U||V||de||ge||!!x.error_message,Z=Se&&Me,te=I[P]||"output";return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{onClick:()=>u(P),className:R("group relative flex items-start gap-3 px-2 py-3 rounded-xl transition-all duration-200",ue&&"cursor-pointer",G&&"bg-violet-50/80 dark:bg-violet-500/[0.08]",H&&!Q&&"bg-rose-50/50 dark:bg-rose-500/[0.04]",!G&&!H&&ue&&"hover:bg-slate-50 dark:hover:bg-white/[0.02]"),children:[e.jsx("div",{className:"relative z-10 shrink-0",children:e.jsx("div",{className:R("flex h-10 w-10 items-center justify-center rounded-xl transition-all duration-300",G&&"bg-violet-500 text-white shadow-lg shadow-violet-500/25 ring-4 ring-violet-500/20",z&&!p&&"bg-emerald-500/10 text-emerald-500 dark:bg-emerald-500/15 dark:text-emerald-400 ring-1 ring-emerald-500/20",H&&"bg-rose-500/10 text-rose-500 dark:bg-rose-500/15 dark:text-rose-400 ring-1 ring-rose-500/20",T&&"bg-amber-500/10 text-amber-600 dar
1k:bg-amber-500/15 dark:text-amber-400 ring-1 ring-amber-500/20",S&&"bg-slate-100 text-slate-400 dark:bg-white/[0.04] dark:text-slate-600 ring-1 ring-slate-200 dark:ring-white/[0.06]"),children:G?e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white/30 border-t-white"}):T?Kt:z?e.jsx("svg",{className:"h-4.5 w-4.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):H?e.jsx("svg",{className:"h-4.5 w-4.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}):he||e.jsx("span",{className:"text-xs font-bold",children:P+1})})}),e.jsxs("div",{className:"flex-1 min-w-0 pt-1",children:[e.jsxs("div",{className:"flex flex-col gap-1.5 xs:flex-row xs:items-center xs:justify-between xs:gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("h4",{className:R("text-sm",G?"font-semibold text-violet-700 dark:text-violet-300":z&&!p?"font-semibold text-slate-800 dark:text-slate-200":H?"font-semibold text-rose-700 dark:text-rose-300":T?"font-medium text-amber-700 dark:text-amber-400":"font-semibold text-slate-400 dark:text-slate-500"),children:x.name}),ie&&!S&&e.jsx("svg",{className:R("h-3.5 w-3.5 shrink-0 transition-transform duration-200 text-slate-400 dark:text-slate-500",Q&&"rotate-180"),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 xs:shrink-0",children:[i&&f&&(z||H||T)&&x.name!=="Complete"&&e.jsx("label",{onClick:h=>h.stopPropagation(),className:"flex items-center gap-1.5 cursor-pointer",title:"Select to force-regenerate this step",children:e.jsx("input",{type:"checkbox",checked:y.includes(x.step),onChange:()=>{const h=y.includes(x.step)?y.filter(b=>b!==x.step):[...y,x.step].sort((b,M)=>b-M);f(h)},className:"h-3.5 w-3.5 rounded border-slate-300 dark:border-white/20 text-violet-500 focus:ring-violet-500"})}),i&&x.name==="Generate Statistics"&&g&&e.jsx("button",{onClick:h=>{h.stopPropagation(),g()},disabled:l!==null,className:"flex items-center gap-1.5 text-[11px] font-medium px-2.5 py-1.5 rounded-lg border border-violet-200 dark:border-violet-500/20 bg-violet-50 dark:bg-violet-500/10 text-violet-700 dark:text-violet-300 hover:bg-violet-100 dark:hover:bg-violet-500/15 disabled:opacity-50 disabled:cursor-not-allowed",title:"Regenerate charts only, without rewriting article text",children:"Regenerate charts"}),i&&(z||H||T)&&k&&x.name!=="Complete"&&e.jsxs("button",{onClick:h=>{h.stopPropagation(),k(x.step,{forceRetrySingle:!0})},disabled:l!==null,className:R("flex items-center gap-1.5 text-[11px] font-medium px-2.5 py-1.5 rounded-lg border transition-all duration-200",l===x.step?"bg-violet-100 dark:bg-violet-500/15 text-violet-600 dark:text-violet-400 border-violet-200 dark:border-violet-500/20 cursor-wait":l!==null?"bg-slate-50 dark:bg-white/[0.02] text-slate-400 dark:text-slate-600 border-slate-200 dark:border-white/[0.04] cursor-not-allowed opacity-50":"bg-white dark:bg-white/[0.04] text-slate-600 dark:text-slate-400 border-slate-200 dark:border-white/[0.08] hover:bg-violet-50 dark:hover:bg-violet-500/10 hover:text-violet-600 dark:hover:text-violet-400 hover:border-violet-300 dark:hover:border-violet-500/20"),title:`Force retry only "${x.name}"`,children:[l===x.step?e.jsx("div",{className:"h-3.5 w-3.5 animate-spin rounded-full border-[1.5px] border-violet-400/30 border-t-violet-500"}):e.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182"})}),l===x.step?"Regenerating...":"Force retry"]}),i&&(z||H||T)&&k&&x.name!=="Complete"&&e.jsx("button",{onClick:h=>{h.stopPropagation(),k(x.step)},disabled:l!==null,className:"flex items-center gap-1.5 text-[11px] font-medium px-2.5 py-1.5 rounded-lg border border-slate-200 dark:border-white/[0.08] bg-white dark:bg-white/[0.04] text-slate-600 dar
1k:text-slate-400 hover:bg-slate-50 dark:hover:bg-white/[0.06] disabled:opacity-50 disabled:cursor-not-allowed",title:`Regenerate from "${x.name}" onward`,children:"From here"}),le&&e.jsx("span",{className:R("text-xs font-mono px-1.5 py-0.5 rounded-md",T?"text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-500/10":z?"text-emerald-600 dark:text-emerald-400 bg-emerald-50 dark:bg-emerald-500/10":H?"text-rose-600 dark:text-rose-400 bg-rose-50 dark:bg-rose-500/10":"text-slate-500 bg-slate-100 dark:bg-white/[0.06]"),children:le}),(z||T)&&(x.source_run_id||t)&&e.jsx("span",{className:R("text-[10px] font-medium px-1.5 py-0.5 rounded-md",x.source_run_id?"text-slate-500 dark:text-slate-400 bg-slate-100 dark:bg-white/[0.06]":"text-violet-600 dark:text-violet-400 bg-violet-50 dark:bg-violet-500/10"),title:x.source_run_id?`Reused from Run #${x.source_run_id}`:`Executed in Run #${t}`,children:x.source_run_id?`#${x.source_run_id}`:`#${t}`}),G&&e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded-full bg-violet-100 text-violet-700 dark:bg-violet-500/15 dark:text-violet-300 animate-pulse",children:"Running"})]})]}),(S||G)&&oe&&e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mt-0.5 leading-relaxed",children:oe}),(X||p)&&!Q&&e.jsxs("p",{className:"text-[11px] text-amber-600/90 dark:text-amber-400/90 mt-0.5",children:["Skipped: ",pe||"Using last generated data",x.completed_at?` · ${new Date(x.completed_at).toLocaleTimeString()}`:""]}),z&&!p&&x.completed_at&&!Q&&e.jsxs("p",{className:"text-[11px] text-slate-400 dark:text-slate-500 mt-0.5",children:["Completed: ",new Date(x.completed_at).toLocaleTimeString()]})]})]}),Q&&e.jsx("div",{className:"relative ml-2 sm:ml-[52px] mr-2 mb-2 mt-0 overflow-hidden",children:e.jsxs("div",{className:R("rounded-xl border overflow-hidden",H?"border-rose-200/60 dark:border-rose-500/15 bg-rose-50/40 dark:bg-rose-500/[0.03]":"border-slate-200/60 dark:border-white/[0.06] bg-white/60 dark:bg-white/[0.02]"),children:[Z&&e.jsxs("div",{className:"flex overflow-x-auto border-b border-slate-200/60 dark:border-white/[0.06] bg-slate-50/60 dark:bg-white/[0.015] [scrollbar-width:none] [-webkit-overflow-scrolling:touch] [&::-webkit-scrollbar]:hidden",children:[e.jsxs("button",{onClick:h=>{h.stopPropagation(),O(P,"output")},className:R("flex shrink-0 items-center gap-1 sm:gap-1.5 px-2.5 sm:px-4 py-2 text-[11px] font-semibold transition-all duration-150 border-b-2 -mb-px",te==="output"?"text-violet-700 dark:text-violet-300 border-violet-500":"text-slate-500 dark:text-slate-400 border-transparent hover:text-slate-700 dark:hover:text-slate-300"),children:[e.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),"Output"]}),e.jsxs("button",{onClick:h=>{h.stopPropagation(),O(P,"prompts")},className:R("flex shrink-0 items-center gap-1 sm:gap-1.5 px-2.5 sm:px-4 py-2 text-[11px] font-semibold transition-all duration-150 border-b-2 -mb-px",te==="prompts"?"text-violet-700 dark:text-violet-300 border-violet-500":"text-slate-500 dark:text-slate-400 border-transparent hover:text-slate-700 dark:hover:text-slate-300"),children:[e.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.129.166 2.27.293 3.423.379.35.026.67.21.865.501L12 21l2.755-4.133a1.14 1.14 0 01.865-.501 48.172 48.172 0 003.423-.379c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.
1123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z"})}),"AI Prompts",e.jsx("span",{className:"inline-flex items-center justify-center h-4 min-w-[16px] px-1 rounded-full bg-violet-100 dark:bg-violet-500/15 text-[9px] font-bold text-violet-700 dark:text-violet-300",children:x.ai_requests.length})]}),j&&e.jsxs("button",{onClick:h=>{h.stopPropagation(),O(P,"settings")},className:R("flex shrink-0 items-center gap-1 sm:gap-1.5 px-2.5 sm:px-4 py-2 text-[11px] font-semibold transition-all duration-150 border-b-2 -mb-px",te==="settings"?"text-violet-700 dark:text-violet-300 border-violet-500":"text-slate-500 dark:text-slate-400 border-transparent hover:text-slate-700 dark:hover:text-slate-300"),children:[e.jsxs("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.324.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.24-.438.613-.43.992a7.723 7.723 0 010 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.954.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 010-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),"Settings"]})]}),(te==="output"||!Z)&&e.jsxs(e.Fragment,{children:[x.error_message&&(x.status!=="failed"&&/^Awaiting Vertex batch /i.test(x.error_message)?e.jsx("div",{className:"px-4 py-3 border-b border-violet-200/50 dark:border-violet-500/10 bg-violet-50/80 dark:bg-violet-500/[0.06]",children:e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"shrink-0 mt-0.5 flex h-5 w-5 items-center justify-center rounded-full bg-violet-100 dark:bg-violet-500/15",children:e.jsx("svg",{className:"h-3 w-3 text-violet-600 dark:text-violet-400 animate-spin",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4v4m0 8v4m8-8h-4M8 12H4m12.95-7.05l-2.83 2.83M8.88 15.12l-2.83 2.83m0-13.9l2.83 2.83m7.24 7.24l2.83 2.83"})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-violet-700 dark:text-violet-300 mb-0.5",children:"Waiting on Vertex batch"}),e.jsx("p",{className:"text-xs text-violet-600 dark:text-violet-300/80 break-words leading-relaxed font-mono",children:x.error_message.replace(/^Awaiting Vertex batch\s*/i,"")}),e.jsx("p",{className:"text-[10px] text-violet-500 dark:text-violet-400/70 mt-1",children:"The pipeline is paused until this batch completes. It resumes automatically - no action needed."})]})]})}):e.jsx("div",{className:"px-4 py-3 border-b border-rose-200/50 dark:border-rose-500/10 bg-rose-50/80 dark:bg-rose-500/[0.06]",children:e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"shrink-0 mt-0.5 flex h-5 w-5 items-center justify-center rounded-full bg-rose-100 dark:bg-rose-500/15",children:e.jsx("svg",{className:"h-3 w-3 text-rose-600 dar
1k:text-rose-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-rose-700 dark:text-rose-300 mb-0.5",children:"Error"}),e.jsx("p",{className:"text-xs text-rose-600 dark:text-rose-300/80 break-words leading-relaxed",children:x.error_message})]})]})})),o.length>0&&e.jsx("div",{className:"px-4 py-3",children:e.jsx("div",{className:"space-y-2",children:o.map(([h,b])=>{if((h==="internal_link_count"||h==="external_link_count")&&o.some(([_,m])=>_===h.replace("_count","s")&&Array.isArray(m)))return null;const M=tt(h),ce=Ft(h,b),xe=Gt(h,b),be=Vt(h),Ae=typeof b=="string"&&String(b).length>60;if(Ut(h)&&b&&typeof b=="object"&&!Array.isArray(b)){const _=b;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:M}),e.jsx("div",{className:"rounded-lg border border-slate-200/40 dark:border-white/[0.06] overflow-hidden",children:e.jsxs("table",{className:"w-full text-[11px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50/80 dark:bg-white/[0.02]",children:[e.jsx("th",{className:"px-2.5 py-1.5 text-left font-medium text-slate-500 dark:text-slate-400",children:"Field"}),e.jsx("th",{className:"px-2.5 py-1.5 text-center font-medium text-slate-500 dark:text-slate-400",children:"Status"}),e.jsx("th",{className:"px-2.5 py-1.5 text-right font-medium text-slate-500 dark:text-slate-400",children:"Length"}),e.jsx("th",{className:"px-2.5 py-1.5 text-right font-medium text-slate-500 dark:text-slate-400",children:"Range"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100 dark:divide-white/[0.03]",children:Object.entries(_).map(([m,v])=>{const C=Qt[v.status]||{label:v.status,color:"text-slate-500"};return e.jsxs("tr",{children:[e.jsx("td",{className:"px-2.5 py-1.5 text-slate-700 dark:text-slate-300 font-medium",children:tt(m)}),e.jsx("td",{className:"px-2.5 py-1.5 text-center",children:e.jsx("span",{className:R("inline-flex px-1.5 py-0.5 rounded-md text-[10px] font-semibold",C.color),children:C.label})}),e.jsxs("td",{className:"px-2.5 py-1.5 text-right font-mono text-slate-600 dark:text-slate-400",children:[v.length,v.new_length!=null?` â ${v.new_length}`:""]}),e.jsxs("td",{className:"px-2.5 py-1.5 text-right font-mono text-slate-500 dark:text-slate-500",children:[v.min,"-",v.max]})]},m)})})]})})]},h)}if(h==="search_queries"&&Array.isArray(b)){const _=b.filter(m=>typeof m=="string");return _.length===0?null:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:M}),e.jsx("ul",{className:"list-disc list-inside text-xs text-slate-700 dark:text-slate-300 space-y-1",children:_.map((m,v)=>e.jsx("li",{className:"break-words",children:m},v))})]},h)}if(h==="queries_with_providers"&&Array.isArray(b)){const _=b.filter(m=>m!=null&&typeof m=="object");return _.length===0?null:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:M}),e.jsx("ul",{className:"space-y-1.5",children:_.map((m,v)=>{const C=(m.query??m.query_text??"").toString(),E=(m.provider??"").toString();return e.jsxs("li",{className:"text-xs text-slate-700 dark:text-slate-300 rounded-md bg-slate-50 dark:bg-white/[0.04] px-2 py-1.5 border border-slate-200/40 dark:border-white/[0.06]",children:[e.jsx("span",{className:"break-words",children:C||"(query)"}),E&&e.jsxs("span",{className:"ml-2 text-[11px] text-slate-500 dark:text-slate-400 font-medium",children:["(",E,")"]})]},v)})})]},h)}if(h==="search_results"&&Array.isArray(b)){const _=b.filter(m=>m!=null&&typeof m=="object");return _.length===0?null:e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-[11px] font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:[M," (",_.length,")"]}),e.jsx("ul",{className:"space-y-2 max-h-64 overflow-y-auto",children:_.map((m,v)=>{const C=(m.title??m.name??"").toString().trim()||"Untitled",E=(m.url??m.link??"").toString().trim(),D=(m.description??m.snippet??"").toString().trim();return e.jsxs("li",{className:"text-xs rounded-md bg-slate-50 dark:bg-white/[0.04] p-2 border border-slate-200/40 dark:border-white/[0.06]",children:[E?e.jsx("a",{href:E,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-violet-600 dar
1k:text-violet-400 hover:underline break-all",children:C}):e.jsx("span",{className:"font-medium text-slate-700 dark:text-slate-300",children:C}),D&&e.jsx("p",{className:"mt-0.5 text-slate-600 dark:text-slate-400 line-clamp-2",children:D})]},v)})})]},h)}if(h==="search_urls"&&Array.isArray(b)){const _=b.filter(m=>typeof m=="string");return _.length===0?null:e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-[11px] font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:[M," (",_.length,")"]}),e.jsx("ul",{className:"list-none space-y-1 max-h-48 overflow-y-auto",children:_.map((m,v)=>e.jsx("li",{className:"text-xs",children:e.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-violet-600 dark:text-violet-400 hover:underline break-all",children:m})},v))})]},h)}if((h==="internal_links"||h==="external_links")&&Array.isArray(b)){const _=b.filter(m=>m!=null&&typeof m=="object");return _.length===0?null:e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-[11px] font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:[M," (",_.length,")"]}),e.jsx("ul",{className:"space-y-1.5 max-h-64 overflow-y-auto",children:_.map((m,v)=>{const C=(m.title??m.name??"").toString().trim(),E=(m.url??"").toString().trim(),D=(m.content_type??"").toString().trim();return e.jsxs("li",{className:"text-xs rounded-md bg-slate-50 dark:bg-white/[0.04] px-2 py-1.5 border border-slate-200/40 dark:border-white/[0.06]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[E?e.jsx("a",{href:E,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-violet-600 dark:text-violet-400 hover:underline break-all",children:C||E}):e.jsx("span",{className:"font-medium text-slate-700 dark:text-slate-300",children:C||"(untitled)"}),D&&e.jsx("span",{className:"shrink-0 text-[9px] font-semibold rounded px-1 py-0.5 bg-slate-200/60 dark:bg-white/[0.06] text-slate-500 dark:text-slate-400",children:D})]}),E&&C&&e.jsx("p",{className:"mt-0.5 text-[10px] text-slate-500 dark:text-slate-500 break-all",children:E})]},v)})})]},h)}if(h==="selected_article"&&b&&typeof b=="object"&&!Array.isArray(b)){const _=b,m=String(_.title??"").trim()||"Selected article",v=String(_.external_url??"").trim(),C=String(_.contentpulse_url??"").trim();return e.jsxs("div",{className:"rounded-lg border border-violet-200/70 dark:border-violet-500/20 bg-violet-50/60 dark:bg-violet-500/[0.06] px-3 py-2.5",children:[e.jsx("p",{className:"text-[11px] font-medium text-violet-700 dark:text-violet-300 uppercase tracking-wider mb-1",children:M}),v?e.jsx("a",{href:v,target:"_blank",rel:"noopener noreferrer",className:"block text-xs font-semibold text-violet-700 dark:text-violet-300 hover:underline break-words",children:m}):e.jsx("p",{className:"text-xs font-semibold text-slate-700 dark:text-slate-300",children:m}),v&&e.jsx("p",{className:"mt-1 text-[10px] text-slate-500 dark:text-slate-400 break-all",children:v}),C&&e.jsxs("p",{className:"mt-1 text-[10px] text-slate-500 dark:text-slate-400",children:["Content #",C.split("/").pop()]})]},h)}if(h==="section_layout"&&Array.isArray(b)){const _=b.map(m=>{if(!m||typeof m!="object")return null;const v=m,C=typeof v.section=="string"?v.section.trim():"",E=typeof v.explanation=="string"?v.explanation.trim():"";return!C||!E?null:{sectionLabel:C.replace(/_/g," ").replace(/\b\w/g,ke=>ke.toUpperCase()),explanation:E}}).filter(m=>m!==null);return _.length===0?null:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:M}),e.jsx("div",{className:"space-y-1.5",children:_.map((m,v)=>e.jsxs("div",{className:"grid grid-cols-[minmax(0,140px)_1fr] gap-2 rounded-md border border-slate-200/40 dark:border-white/[0.06] bg-slate-50 dark:bg-white/[0.03] px-2.5 py-2",children:[e.jsx("span",{className:"text-[11px] font-semibold text-slate-700 dark:text-slate-300",children:m.sectionLabel}),e.jsx("span",{className:"text-xs leading-relaxed text-slate-600 dar
1k:text-slate-400 break-words",children:m.explanation})]},`${m.sectionLabel}-${v}`))})]},h)}if(h==="collected_data"&&b&&typeof b=="object"&&!Array.isArray(b)){const _=b,m=_.topic!=null?String(_.topic):"",v=_.search_locale!=null?String(_.search_locale):"",C=[m&&`Topic: ${m}`,v&&`Locale: ${v}`].filter(Boolean);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:M}),C.length>0?e.jsx("p",{className:"text-xs text-slate-600 dark:text-slate-400",children:C.join(" · ")}):e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-500 italic",children:"Summary data"})]},h)}if(Ht(h)&&typeof b=="string"&&b){const _=b;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:M}),e.jsxs("div",{className:"rounded-lg border border-slate-200/40 dark:border-white/[0.06] overflow-hidden bg-slate-50 dark:bg-white/[0.02]",children:[e.jsx("img",{src:_,alt:"Generated featured image",className:"w-full max-h-48 object-cover",onError:m=>{const v=m.target;v.style.display="none";const C=v.nextElementSibling;C&&(C.style.display="block")}}),e.jsx("p",{className:"hidden px-3 py-2 text-xs text-slate-500 dark:text-slate-400 break-all",children:b})]})]},h)}if(be&&typeof b=="string"&&b.includes(",")){const _=b.split(",").map(m=>m.trim()).filter(Boolean);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:M}),e.jsx("div",{className:"flex flex-wrap gap-1",children:_.map((m,v)=>{const C=lt[m]??m.replace(/_/g," ").replace(/\b\w/g,E=>E.toUpperCase());return e.jsx("span",{className:"inline-flex items-center rounded-md bg-violet-50 dark:bg-violet-500/10 px-2 py-0.5 text-[11px] font-medium text-violet-700 dark:text-violet-300 ring-1 ring-inset ring-violet-200 dark:ring-violet-500/20",children:C},`${m}-${v}`)})})]},h)}if(h==="sections"&&typeof b=="string"&&b.trim().length>0){const _=b.split(` 2`).map(m=>m.trim()).filter(m=>m.length>0);return _.length===0?null:e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-[11px] font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:[M," (",_.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:_.map((m,v)=>{const C=m.match(/^#(\d+):\s*(.+?)\s*\((.+?),\s*(p\d+(?:-\d+)?)\)$/);if(!C)return e.jsx("li",{className:"text-xs text-slate-700 dark:text-slate-300 rounded-md bg-slate-50 dark:bg-white/[0.04] px-2.5 py-1.5 border border-slate-200/40 dark:border-white/[0.06] break-words",children:m},v);const[,E,D,ke,Le]=C;return e.jsx("li",{className:"rounded-md bg-slate-50 dark:bg-white/[0.04] border border-slate-200/40 dark:border-white/[0.06] px-2.5 py-1.5",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"inline-flex items-center justify-center rounded bg-violet-100 dark:bg-violet-500/20 text-violet-600 dark:text-violet-400 text-[10px] font-semibold px-1.5 py-0.5 shrink-0 mt-0.5",children:["#",E]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs font-medium text-slate-800 dark:text-slate-200 break-words",children:D}),e.jsxs("p",{className:"text-[11px] text-slate-500 dark:text-slate-400 mt-0.5 break-words",children:[ke," · ",Le]})]})]})},v)})})]},h)}return Ae?e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:M}),e.jsx("p",{className:R("text-xs leading-relaxed break-words",xe),children:ce})]},h):["meta_title","og_title","twitter_title"].includes(h)?e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:M}),e.jsx("p",{className:R("text-xs leading-relaxed break-words",xe),children:ce})]},h):ce===""&&typeof b=="object"&&b!==null?null:e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("span",{className:"text-[11px] font-medium text-slate-500 dark:text-slate-400 shrink-0",children:M}),e.jsx("span",{className:R("text-xs font-medium text-right break-words",xe),children:ce})]},h)})})}),Y&&e.jsx(dt,{detail:A}),U&&e.jsx(gs,{detail:A,generatedDetail:K,aiRequests:x.ai_requests??[]}),V&&e.jsx(bs,{detail:A}),de&&e.jsx(ks,{detail:A}),ge&&e.jsx(ts,{detail:A}),!x.error_message&&o.length===0&&!Y&&!U&&!V&&!de&&!ge&&e.jsx("div",{className:"px-4 py-3",children:Se&&!Z?e.jsx(Ze,{requests:x.ai_requests,purposeConfigs:j,debugContext:{stepName:x.name,contentId:c??void 0,runI
2d:t??void 0}}):e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 italic",children:oe||"No detailed output recorded for this step."})})]}),te==="prompts"&&Z&&e.jsx(Ze,{requests:x.ai_requests,purposeConfigs:j,debugContext:{stepName:x.name,contentId:c??void 0,runId:t??void 0}}),te==="settings"&&Z&&j&&e.jsx("div",{className:"p-4 space-y-4",children:(()=>{const h=x.ai_requests?[...new Set(x.ai_requests.map(b=>b.purpose))]:[];return h.length===0?e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500",children:"No AI purposes for this step."}):h.map(b=>{var xe;const M=j[b];if(!M)return null;const ce=b.replace(/_/g," ").replace(/\b\w/g,be=>be.toUpperCase());return e.jsxs("div",{className:"rounded-lg border border-slate-200/60 dark:border-white/[0.06] bg-slate-50/50 dark:bg-white/[0.02] p-3 space-y-2",children:[e.jsx("p",{className:"text-[11px] font-semibold text-slate-600 dark:text-slate-300 uppercase tracking-wider",children:ce}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5 text-xs",children:[e.jsxs("div",{className:"sm:col-span-2 flex flex-col sm:flex-row sm:items-baseline gap-1 sm:gap-2",children:[e.jsx("span",{className:"text-slate-400 dark:text-slate-500 shrink-0",children:"Models:"}),e.jsx("span",{className:"text-slate-700 dark:text-slate-300 break-all text-[11px] leading-relaxed",children:M.models.join(" â ")})]}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-slate-400 dark:text-slate-500 shrink-0",children:"Max Tokens:"}),e.jsx("span",{className:"text-slate-700 dark:text-slate-300",children:((xe=M.max_tokens)==null?void 0:xe.toLocaleString())??"-"})]}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-slate-400 dark:text-slate-500 shrink-0",children:"Temperature:"}),e.jsx("span",{className:"text-slate-700 dark:text-slate-300",children:M.temperature??"-"})]}),M.thinking_budget!=null&&e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-slate-400 dark:text-slate-500 shrink-0",children:"Thinking Budget:"}),e.jsx("span",{className:"text-slate-700 dark:text-slate-300",children:M.thinking_budget.toLocaleString()})]}),M.reasoning_effort!=null&&e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-slate-400 dark:text-slate-500 shrink-0",children:"Reasoning Effort:"}),e.jsx("span",{className:"text-slate-700 dark:text-slate-300",children:M.reasoning_effort})]})]})]},b)})})()}),(x.started_at||x.completed_at)&&e.jsxs("div",{className:"px-3 sm:px-4 py-2 border-t border-slate-100 dark:border-white/[0.04] bg-slate-50/50 dark:bg-white/[0.01] flex flex-wrap items-center justify-between gap-1 text-[10px] text-slate-400 dark:text-slate-500",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[x.started_at&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})}),new Date(x.started_at).toLocaleTimeString()]}),x.completed_at&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),new Date(x.completed_at).toLocaleTimeString()]})]}),le&&e.jsx("span",{className:"font-mono",children:le})]})]})})]},P)})})]})}const Jt={titles:"bg-slate-100 text-slate-700 dark:bg-slate-500/15 dark:text-slate-300 ring-slate-200 dark:ring-slate-500/20",hero:"bg-violet-100 text-violet-700 dark:bg-violet-500/15 dark:text-violet-300 ring-violet-200 dark:ring-violet-500/20",content:"bg-blue-100 text-blue-700 dark:bg-blue-500/15 dark:text-blue-300 ring-blue-200 dark:ring-blue-500/20",content_seo:"bg-sky-100 text-sky-700 dark:bg-sky-500/15 dark:text-sky-300 ring-sky-200 dark:ring-sky-500/20",content_backlink:"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300 ring-emerald-200 dark:ring-emerald-500/20",conclusion:"bg-slate-100 text-slate-700 dark:bg-slate-500/15 dark:text-slate-300 ring-slate-200 dark:ring-slate-500/20",steps:"bg-indigo-100 text-indigo-700 dark:bg-indigo-500/15 dark:text-indigo-300 ring-indigo-200 dark:ring-indigo-500/20",table:"bg-cyan-100 text-cyan-700 dark:bg-cyan-500/15 dark:text-cyan-300 ring-cyan-200 dark:ring-cyan-500/20",grid:"bg-teal-100 text-teal-700 dark:bg-teal-500/15 dark:text-teal-300 ring-teal-200 dark:ring-teal-500/20",alert:"bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300 ring-amber-200 dark:ring-amber-500/20",checklist:"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300 ring-emerald-200 dark:ring-emerald-500/20",faq:"bg-purple-100 text-purple-700 dark:bg-purple-500/15 dark:text-purple-300 ring-purple-200 dark:ring-purple-500/20",dos_donts:"bg-orange-100 text-orange-700 dark:bg-orange-500/15 dark:text-orange-300 ring-orange-200 dark:ring-orange-500/20",quote:"bg-pink-100 text-pink-700 dark:bg-pink-500/15 dark:text-pink-300 ring-pink-200 dark:ring-pink-500/20",cta:"bg-rose-100 text-rose-700 dark:bg-rose-500/15 dark:text-rose-300 ring-rose-200 dark:ring-rose-500/20",seo_keywords:"bg-lime-100 text-lime-700 dark:bg-lime-500/15 dark:text-lime-300 ring-lime-200 dark:ring-lime-500/20",references:"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300 ring-emerald-200 dark:ring-emerald-500/20",comparison_table:"bg-cyan-100 text-cyan-700 dark:bg-cyan-500/15 dark:text-cyan-300 ring-cyan-200 dark:ring-cyan-500/20",analysis:"bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300 ring-amber-200 dark:ring-amber-500/20",verdict:"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300 ring-emerald-200 dark:ring-emerald-500/20",tips:"bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300 ring-amber-200 dark:ring-amber-500/20",list_items:"bg-teal-100 text-teal-700 dark:bg-teal-500/15 dark:text-teal-300 ring-teal-200 dark:ring-teal-500/20",summary:"bg-slate-100 text-slate-700 dark:bg-slate-500/15 dark:text-slate-300 ring-slate-200 dark:ring-slate-500/20",overview:"bg-blue-100 text-blue-700 dark:bg-blue-500/15 dark:text-blue-300 ring-blue-200 dark:ring-blue-500/20",chapters:"bg-indigo-100 text-indigo-700 dark:bg-indigo-500/15 dark:text-indigo-300 ring-indigo-200 dark:ring-indigo-500/20",resources:"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300 ring-emerald-200 dark:ring-emerald-500/20"};function Zt(s){return s.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Dt(s){if("data"in s&&s.data&&typeof s.data=="object"){const t=s.data;if(typeof t.title=="string")return t.title;if(typeof t.original=="string")return t.original;if(typeof t.quote=="string")return t.quote.substring(0,60)+(t.quote.length>60?"...":"")}return"Untitled Section"}function es(s){return"word_count"in s&&typeof s.word_count=="number"?s.word_count:null}function ot(s){if(!("data"in s)||!s.data||typeof s.data!="object")return"";const t=s.data,c=s.type,a=[];switch(c){case"titles":t.original&&a.push(`Title: ${t.original}`),Array.isArray(t.alternatives)&&(a.push("Alternatives:"),t.alternatives.forEac
2h((n,i)=>a.push(` ${i+1}. ${n}`)));break;case"hero":t.title&&a.push(t.title),t.description&&a.push(t.description);break;case"content":case"content_seo":case"content_backlink":case"conclusion":if(t.title&&a.push(`## ${t.title}`),Array.isArray(t.paragraphs)&&t.paragraphs.forEach(n=>a.push(n)),t.internal_seo&&typeof t.internal_seo=="object"){const n=t.internal_seo;a.push(`[SEO keyword: ${n.anchor_text??n.chosen_keyword}]`)}if(t.backlink_exchange&&typeof t.backlink_exchange=="object"){const n=t.backlink_exchange;a.push(`[Backlink: ${n.anchor_text??n.chosen_keyword}]`)}Array.isArray(t.strong_keywords)&&t.strong_keywords.forEach(n=>{n!=null&&n.keyword&&a.push(`[Strong keyword: ${n.keyword}]`)});break;case"steps":t.title&&a.push(`## ${t.title}`),Array.isArray(t.steps)&&t.steps.forEach((n,i)=>{a.push(`${i+1}. ${n.title}: ${n.description}`)});break;case"table":t.title&&a.push(`## ${t.title}`),Array.isArray(t.headers)&&a.push(t.headers.join(" | ")),Array.isArray(t.rows)&&t.rows.forEach(n=>a.push(n.join(" | ")));break;case"chart":{t.title&&a.push(`## ${t.title}`),typeof t.image_url=="string"&&t.image_url.trim()&&a.push(`[Chart image: ${t.image_url}]`),Array.isArray(t.data)&&t.data.forEach(n=>{a.push(` ${n.label??"â"}: ${n.value??""}${n.unit==="percentage"?"%":""}`)});break}case"grid":{const n=t.title||"",i=Array.isArray(t.items)?t.items.filter(l=>l&&(l.title||l.content)):[];if(i.length===0&&!n)break;return e.jsxs("div",{children:[n&&e.jsx("h3",{className:"text-xs font-semibold text-slate-800 dark:text-slate-200 mb-2",children:n}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:i.map((l,k)=>e.jsxs("div",{className:"rounded-md border border-slate-200 dark:border-slate-700 p-2.5 text-[11px]",children:[l.title&&e.jsx("div",{className:"font-semibold text-slate-700 dark:text-slate-200 mb-0.5",children:l.title}),l.content&&e.jsx("div",{className:"text-slate-500 dark:text-slate-400 leading-relaxed",children:l.content})]},k))})]})}case"alert":t.title&&a.push(`[!] ${t.title}`),t.description?a.push(t.description):t.content&&a.push(t.content);break;case"checklist":t.title&&a.push(`## ${t.title}`),Array.isArray(t.items)&&t.items.forEach(n=>a.push(`[ ] ${n}`));break;case"faq":t.title&&a.push(`## ${t.title}`),t.description&&a.push(t.description),Array.isArray(t.items)&&t.items.forEach(n=>{a.push(`Q: ${n.question}`),a.push(`A: ${n.answer}`)});break;case"dos_donts":t.title&&a.push(`## ${t.title}`),Array.isArray(t.dos)&&(a.push("Do:"),t.dos.forEach(n=>a.push(` + ${n}`))),Array.isArray(t.donts)&&(a.push("Don't:"),t.donts.forEach(n=>a.push(` - ${n}`)));break;case"quote":t.quote&&a.push(`"${t.quote}"`),t.author&&a.push(`- ${t.author}${t.role?`, ${t.role}`:""}`);break;case"cta":t.title&&a.push(t.title),t.description&&a.push(t.description);break;case"seo_keywords":Array.isArray(t.keywords)&&a.push("Target Keywords: "+t.keywords.join(", ")),Array.isArray(t.key_concepts)&&a.push("Key Concepts: "+t.key_concepts.join(", "));break;case"references":Array.isArray(t.sources)&&t.sources.forEach(n=>{a.push(`- ${n.title}: ${n.url}`)});break;default:a.push(JSON.stringify(t,null,2))}return a.join(` 3`)}function ts({detail:s}){const t=(c,a)=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-slate-500 dark:text-slate-400",children:[c," (",a.length,")"]}),a.length>0?e.jsx("ul",{className:"space-y-1.5",children:a.map((n,i)=>e.jsx("li",{className:"rounded-md border border-slate-200/50 bg-slate-50/70 px-2.5 py-2 text-xs leading-relaxed text-slate-700 dark:border-white/[0.06] dark:bg-white/[0.03] dark:text-slate-300",children:n},`${c}-${i}`))}):e.jsx("p",{className:"text-xs italic text-slate-400 dark:text-slate-500",children:"None used."})]});return e.jsxs("div",{className:"space-y-4 border-t border-slate-200/60 px-4 py-3 dark:border-white/[0.06]",children:[t("Statistics used",s.statistics),t("Comparisons used",s.comparisons),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-slate-500 dark:text-slate-400",children:"Decision"}),e.jsx("p",{className:"text-xs font-medium text-slate-700 dark:text-slate-300",children:s.decision_summary}),s.decision.map(c=>e.jsxs("div",{className:"rounded-lg border border-violet-200/60 bg-violet-50/50 p-2.5 dark:border-violet-500/15 dark:bg-violet-500/[0.05]",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-800 dark:text-slate-200",children:c.title}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-slate-500 dark:text-slate-400",children:[c.chart_type," · ",c.unit]}),e.jsx("ul",{className:"mt-2 grid gap-1 sm:grid-cols-2",children:c.data.map((a,n)=>e.jsxs("li",{className:"flex justify-between gap-3 text-[11px] text-slate-700 dark:text-slate-300",children:[e.jsx("span",{children:a.label}),e.jsx("span",{className:"font-mono font-medium",children:a.value})]},`${c.group_id}-${n}`))})]},c.group_id))]})]})}
3function dt({detail:s}){const[t,c]=F.useState(new Set),a=l=>{c(k=>{const g=new Set(k);return g.has(l)?g.delete(l):g.add(l),g})},n=t.size===s.sections.length,i=()=>{c(n?new Set:new Set(s.sections.map((l,k)=>k)))};return e.jsxs("div",{className:"border-t border-slate-200/50 dark:border-white/[0.04]",children:[e.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between bg-slate-50/60 dark:bg-white/[0.01]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"h-3.5 w-3.5 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),e.jsx("span",{className:"text-[11px] font-semibold text-slate-600 dark:text-slate-300 uppercase tracking-wider",children:"Generated Content"}),e.jsxs("span",{className:"text-[10px] text-slate-400 dark:text-slate-500 font-medium",children:[s.sections.length," sections / ",s.total_word_count.toLocaleString()," words"]})]}),e.jsx("button",{onClick:i,className:"text-[10px] text-violet-600 dark:text-violet-400 hover:text-violet-700 dark:hover:text-violet-300 font-medium",children:n?"Collapse":"Show Content"})]}),e.jsx("div",{className:"divide-y divide-slate-100 dark:divide-white/[0.03]",children:s.sections.map((l,k)=>{const g=l,y=t.has(k),f=Jt[l.type]||"bg-slate-100 text-slate-700 dark:bg-slate-500/15 dark:text-slate-300 ring-slate-200 dark:ring-slate-500/20",j=Dt(g),w=es(g),N=ot(g);return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>a(k),className:"w-full px-4 py-2.5 flex items-center justify-between hover:bg-slate-50/80 dark:hover:bg-white/[0.02] transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:R("inline-flex items-center rounded-md px-1.5 py-0.5 text-[10px] font-semibold ring-1 ring-inset shrink-0",f),children:lt[l.type]??Zt(l.type)}),e.jsx("span",{className:"text-xs font-medium text-slate-700 dark:text-slate-300 truncate",children:j})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[w!==null&&e.jsxs("span",{className:"text-[10px] text-slate-400 font-mono",children:[w," words"]}),e.jsx("svg",{className:R("h-3 w-3 text-slate-400 transition-transform",y&&"rotate-180"),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]})]}),y&&e.jsx("div",{className:"px-4 pb-3",children:e.jsx("div",{className:"rounded-lg bg-slate-50/80 dark:bg-white/[0.02] border border-slate-200/40 dark:border-white/[0.04] p-3 max-h-80 overflow-y-auto",children:e.jsx("div",{className:"prose prose-xs dark:prose-invert max-w-none text-[12px] leading-relaxed text-slate-700 dark:text-slate-300 whitespace-pre-wrap break-words",children:N})})})]},k)})})]})}function ss(s){switch(s){case"applied":return{label:"Applied",className:"bg-emerald-50 text-emerald-700 ring-emerald-200 dark:bg-emerald-500/10 dark:text-emerald-400 dark:ring-emerald-500/20"};case"fallback_or_adjusted":return{label:"Adjusted",className:"bg-violet-50 text-violet-700 ring-violet-200 dark:bg-violet-500/10 dark:text-violet-400 dark:ring-violet-500/20"};case"unchanged":return{label:"Rejected",className:"bg-amber-50 text-amber-700 ring-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:ring-amber-500/20"};case"missing_ai_result":return{label:"No AI Result",className:"bg-rose-50 text-rose-700 ring-rose-200 dark:bg-rose-500/10 dark:text-rose-400 dark:ring-rose-500/20"};default:return{label:"Unknown",className:"bg-slate-100 text-slate-700 ring-slate-200 dark:bg-slate-500/10 dark:text-slate-400 dark:ring-slate-500/20"}}}const rs=/^S(\d+)_(P(\d+)|HERO|FAQ_A(\d+)|COMP_TEXT|COMP|PARAS)$/,Ve="__CP_STRONG_OPEN__",He="__CP_STRONG_CLOSE__";function ne(s){return(s??"").replace(/\s+/g," ").trim()}function as(s){return s.replace(/<\s*strong\b[^>]*>/gi,Ve).replace(/<\s*\/\s*strong\s*>/gi,He)}function ns(s){return s.split(Ve).join("<strong>").split(He).join("</strong>")}function is(s){return s.split(Ve).join("").split(He).join("")}function Be(s){if(!s||!s.trim())return null;const t=s.replace(/<[^>]*>/g," ").trim().match(/\S+/g);return(t==null?void 0:t.length)??0}function We(s){return!s||!s.trim()?[]:s.replace(/<[^>]*>
3/g," ").trim().split(new RegExp("(?<=[.?!])\\s+")).filter(Boolean).map(a=>a.trim().split(/\s+/).filter(Boolean).length).filter(a=>a>0)}function Oe(s){if(!s||!s.trim())return[];const t=as(s).replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();return t?t.split(new RegExp("(?<=[.?!])\\s+")).filter(Boolean).map(a=>{const n=a.trim(),i=ns(n),l=is(n);return{text:i,wordCount:l.split(/\s+/).filter(Boolean).length}}):[]}function qe(s){if(!s.includes("<strong>")&&!s.includes("</strong>"))return s;const t=s.split(/(<\/?strong>)/i).filter(Boolean),c=[];let a=!1;for(let n=0;n<t.length;n+=1){const i=t[n],l=i.toLowerCase();if(l==="<strong>"){a=!0;continue}if(l==="</strong>"){a=!1;continue}if(a){c.push(e.jsx("strong",{className:"font-semibold text-inherit",children:i},`strong-${n}`));continue}c.push(e.jsx("span",{children:i},`text-${n}`))}return c.length>0?c:s}function ls(s){const t=Oe(s.before_text),c=Oe(s.ai_text),a=Oe(s.result_text),n=Math.max(t.length,c.length,a.length),i=[];for(let l=0;l<n;l+=1)i.push({index:l+1,before:t[l]??null,ai:c[l]??null,result:a[l]??null});return i}function os(s){if(s.startsWith("Reduce to ")||s.startsWith("Increase to ")||s.startsWith("Current length is ")||s.startsWith("Sentence "))return s;const t=s.match(/Expected\s+(\d+)\s+sentences?,\s+got\s+(\d+)/i);if(t){const i=Number(t[1]),l=Number(t[2]);return l>i?`Reduce to ${i} sentences (currently ${l}). Do not merge sentences to force lower count.`:`Increase to ${i} sentences (currently ${l}).`}const c=s.match(/S(\d+)\s*:\s*(\d+)w\s*\(\s*target\s*(\d+)w/i);if(c){const i=Number(c[1]),l=Number(c[2]),k=Number(c[3]),g=Math.abs(k-l);return g===0?`Sentence ${i} is on target.`:k>l?`Sentence ${i}: increase by ${g} words (current ${l}).`:`Sentence ${i}: reduce by ${g} words (current ${l}).`}const a=s.match(/(\d+)w\s*\(expected\s*(\d+)-(\d+)w/i);if(a){const i=Number(a[1]),l=Number(a[2]),k=Number(a[3]);if(i<l)return`Current length ${i} words. Increase by ${l-i} words.`;if(i>k)return`Current length ${i} words. Reduce by ${i-k} words.`}const n=s.match(/(\d+)w\s*\(expected\s*~(\d+)w,\s*min\s*(\d+)w/i);if(n){const i=Number(n[1]),l=Number(n[3]);if(i<l)return`Current length ${i} words. Increase by ${l-i} words.`}return s}function ds(s){const t=ct(s.unit_type),c=s.asked_actions;if(Array.isArray(c)&&c.length>0){const a=c.map(n=>n.trim()).filter(Boolean).filter(n=>t?!0:!st(n));if(a.length>0)return Array.from(new Set(a))}return Array.from(new Set(s.issues.map(a=>os(a)).map(a=>a.trim()).filter(Boolean))).filter(a=>t?!0:!st(a))}const cs=new Set(["component_text","component_items","component_dual_list"]);function ct(s){return cs.has(s)}function st(s){return/^Current length(?: is)? \d+ words\.\s*(Increase|Reduce) by \d+ words\.?$/i.test(s)}function xs(s){if(Array.isArray(s.issue_groups)&&s.issue_groups.length>0)return s.issue_groups;const t=new Map;for(const c of s.issues??[]){if(typeof c!="string")continue;const a=c.trim();if(!a)continue;const n=`legacy:${a.toLowerCase()}`,i=t.get(n);if(i){i.raw_count+=1;continue}t.set(n,{key:n,label:"Issue",details:[a],raw_count:1})}return Array.from(t.values())}function xt(s){const t=i=>{try{const l=JSON.parse(i);return l&&typeof l=="object"&&!Array.isArray(l)?l:null}catch{return null}},c=t(s);if(c)return c;const a=s.indexOf("{"),n=s.lastIndexOf("}");return a>=0&&n>a?t(s.slice(a,n+1)):null}function ms(s){if(typeof s=="string")return s.trim();if(Array.isArray(s)){const t=s.filter(c=>typeof c=="string");return t.length>0?t.join(` 4 5`).trim():JSON.stringify(s)}return s&&typeof s=="object"?JSON.stringify(s):null}function ps(s,t){var y;const c=s.includes("previous corrections")?"threaded-follow-up":"legacy-request",a=s.match(/REQUEST_JSON:\s*([\s\S]*?)(?:\n\s*RETURN FORMAT:|$)/),n=a?xt(a[1]):null,i=Array.isArray(n==null?void 0:n.units)?n.units:[];if(i.length>0){const f=[];for(const j of i){if(!j||typeof j!="object"||Array.isArray(j))continue;const w=j,N=typeof w.id=="string"?w.id:"";if(!N)continue;const W=(Array.isArray(w.actions)?w.actions:[]).map($=>{if(!$||typeof $!="object"||Array.isArray($))return"";const u=$.instruction;return typeof u=="string"?u.trim():""}
5).filter(Boolean);f.push({unit_id:N,section_title:typeof w.section_title=="string"?w.section_title:"",section_type:"",unit_type:typeof w.unit_type=="string"?w.unit_type:"",issues:W,suggested_target_words:typeof w.suggested_target_words=="number"?w.suggested_target_words:null,before_text:typeof w.current_text=="string"?w.current_text:null,ai_text:null,attempt:t,mode:"request-json"})}if(f.length>0)return f}if(!s.includes("[S"))return[];const k=(s.includes("UNITS TO FIX:")?s.split("UNITS TO FIX:")[1]??"":s).split(` 6--- 7`).map(f=>f.trim()).filter(f=>f.startsWith("[S")),g=[];for(const f of k){const j=f.match(/^\[(S\d+_(?:P\d+|HERO|FAQ_A\d+|COMP(?:_TEXT)?|PARAS))\]/m);if(!j)continue;const w=j[1],N=f.match(/Section:\s*"([^"]*)"/),I=f.match(/\|\s*Type:\s*([^\n]+)/),W=f.match(/ISSUES:\s*([^\n]+)/),$=f.match(/ACTIONS:\s*([\s\S]*?)\nCURRENT TEXT:/),u=f.match(/TARGET WORDS:\s*(\d+)/),O=f.indexOf("CURRENT TEXT:"),q=O>=0?f.slice(O+13).trim():null,K=((y=$==null?void 0:$[1])==null?void 0:y.split(` 8`).map(x=>x.replace(/^\s*-\s*/,"").trim()).filter(Boolean))??[],se=((W==null?void 0:W[1])??"").split(";").map(x=>x.trim()).filter(Boolean)??[];g.push({unit_id:w,section_title:((N==null?void 0:N[1])??"").trim(),section_type:"",unit_type:((I==null?void 0:I[1])??"").trim(),issues:K.length>0?K:se,suggested_target_words:u?Number(u[1]):null,before_text:q&&q.length>0?q:null,ai_text:null,attempt:t,mode:c})}return g}function Ge(s,t){if(!s||!t.trim())return null;const c=t.trim().toLowerCase();for(let a=0;a<s.sections.length;a+=1){const i=s.sections[a].data;if((typeof i.title=="string"?i.title:typeof i.original=="string"?i.original:"").trim().toLowerCase()===c)return a}return null}function rt(s,t,c,a){if(!s)return null;const n=t.match(rs);let i=n?Number(n[1]):null;const l=n?n[2]:"";if((i==null||Number.isNaN(i))&&a&&(i=Ge(s,a)),i==null||i<0||i>=s.sections.length)return null;const k=s.sections[i],g=k.data;if(l.startsWith("P")){const f=Number((n==null?void 0:n[3])??-1),j=Array.isArray(g.paragraphs)?g.paragraphs:[];return typeof j[f]=="string"?j[f]:null}if(l==="HERO")return typeof g.description=="string"?g.description:null;if(l==="FAQ_A"){const f=Number((n==null?void 0:n[4])??-1),w=(Array.isArray(g.items)?g.items:[])[f];if(w&&typeof w=="object"&&!Array.isArray(w)){const N=w.answer;return typeof N=="string"?N:null}return null}if(l==="PARAS"){const f=Array.isArray(g.paragraphs)?g.paragraphs.filter(j=>typeof j=="string"):[];return f.length>0?f.join(` 9 10`):null}if(l==="COMP_TEXT"||c==="component_text"){const f=["description","content","quote","answer","title"];for(const j of f)if(typeof g[j]=="string")return g[j]}if(l==="COMP"){if(Array.isArray(g.items))return g.items.map(j=>typeof j=="string"?j:JSON.stringify(j)).join(` 11`);if(Array.isArray(g.steps))return g.steps.map(j=>JSON.stringify(j)).join(` 12`)}const y=ot(k);return typeof y=="string"?y:null}function us(s,t){var a;const c=new Map;for(const n of s.issues??[]){if(!n)continue;let i=null,l="",k="";const g=n.match(/^Section "([^"]+)" para (\d+):\s*(.+)$/);if(g){l=g[1];const N=Ge(t,l);if(N!=null){const I=Number(g[2])-1;i=`S${N}_P${Math.max(0,I)}`,k="paragraph"}}const y=n.match(/^Hero section:\s*(.+)$/);if(!i&&y&&t){const N=t.sections.findIndex(I=>I.type==="hero");N>=0&&(i=`S${N}_HERO`,k="hero_description")}const f=n.match(/^FAQ answer (\d+):\s*(.+)$/);if(!i&&f&&t){const N=t.sections.findIndex(I=>I.type==="faq");N>=0&&(i=`S${N}_FAQ_A${Math.max(0,Number(f[1])-1)}`,k="faq_answer")}const j=n.match(/^Section "([^"]+)" \(([^)]+)\):\s*(.+)$/);if(!i&&j){l=j[1];const N=Ge(t,l);if(N!=null){const I=t==null?void 0:t.sections[N],W=Array.isArray((a=I==null?void 0:I.data)==null?void 0:a.paragraphs);i=W?`S${N}_PARAS`:`S${N}_COMP`,k=W?"section_paragraphs":"component_items"}}if(!i)continue;const w=c.get(i);if(w){w.issues.push(n);continue}c.set(i,{unit_id:i,section_title:l,section_type:"",unit_type:k,issues:[n],suggested_target_words:null,before_text:null,ai_text:null,attempt:1,mode:"legacy-issues"})}return Array.from(c.values())}function hs(s,t,c){const a=new Map;c.filter(l=>l.purpose==="content_validation").forEach((l,k)=>{const g=k+1,y=l.response_content?xt(l.response_content):null,f=(l.messages??[]).filter(j=>j.role==="user");
12for(const j of f){const w=ps(j.content,g);for(const N of w){const I=a.get(N.unit_id),W=y==null?void 0:y[N.unit_id],$=ms(W),u={...I??N,...N,ai_text:$??(I==null?void 0:I.ai_text)??null};a.set(N.unit_id,u)}}});let n=Array.from(a.values());n.length===0&&(n=us(s,t));const i=s.corrected_sections??t;return n.map(l=>{const k=l.before_text??rt(t,l.unit_id,l.unit_type,l.section_title),g=rt(i,l.unit_id,l.unit_type,l.section_title),y=l.ai_text;let f="unknown";return!y||!y.trim()?f="missing_ai_result":ne(k)===ne(g)?f="unchanged":ne(y)===ne(g)?f="applied":f="fallback_or_adjusted",{attempt:l.attempt,mode:l.mode,unit_id:l.unit_id,section_title:l.section_title,section_type:l.section_type,unit_type:l.unit_type,issues:l.issues,spec:{},suggested_target_words:l.suggested_target_words,before_text:k,before_word_count:Be(k),before_sentence_word_counts:We(k),ai_text:y,ai_word_count:Be(y),ai_sentence_word_counts:We(y),result_text:g,result_word_count:Be(g),result_sentence_word_counts:We(g),status:f}}).filter(l=>l.before_text||l.ai_text||l.result_text||l.issues.length>0)}function gs({detail:s,generatedDetail:t,aiRequests:c}){var W,$;const a=s.structure_corrected,n=s.validation_passed??((W=s.issues)==null?void 0:W.length)===0,i=(($=s.issues)==null?void 0:$.length)??0,l=xs(s),k=l.length,g=s.fix_comparisons??[],y=g.length>
120?g:hs(s,t,c),[f,j]=F.useState(!1),[w,N]=F.useState(!1),I=y.filter(u=>u.status==="applied"||u.status==="fallback_or_adjusted").length;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-slate-200/50 dark:border-white/[0.04]",children:[e.jsx("div",{className:"px-4 pt-3 pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-lg px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider bg-violet-50 text-violet-600 ring-1 ring-inset ring-violet-200 dark:bg-violet-500/10 dark:text-violet-400 dark:ring-violet-500/20",children:[e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182"})}),"Structure Corrected"]}):n?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-lg px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider bg-emerald-50 text-emerald-600 ring-1 ring-inset ring-emerald-200 dark:bg-emerald-500/10 dark:text-emerald-400 dark:ring-emerald-500/20",children:[e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),"Passed"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-lg px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider bg-amber-50 text-amber-600 ring-1 ring-inset ring-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:ring-amber-500/20",children:[e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})}),i>0?`Completed with ${k} issue groups`:"Completed"]}),s.word_count!=null&&e.jsxs("span",{className:"text-[10px] text-slate-500 dark:text-slate-400 font-medium",children:[s.word_count.toLocaleString()," words"]}),e.jsx("button",{type:"button",onClick:()=>j(!0),className:"inline-flex items-center gap-1 rounded-md border border-violet-200 dark:border-violet-500/20 bg-violet-50 dark:bg-violet-500/10 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-violet-700 dark:text-violet-300 hover:bg-violet-100 dark:hover:bg-violet-500/20 transition-colors",children:"Compare Fixes"})]})}),i>0&&e.jsxs("div",{className:"px-4 pt-1 pb-2 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("p",{className:"text-[11px] font-semibold text-slate-600 dark:text-slate-300 uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx("svg",{className:"h-3.5 w-3.5 text-amber-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})}),"Issues Found (",k," groups / ",i," raw checks)"]}),e.jsx("button",{type:"button",onClick:()=>N(u=>!u),className:"text-[10px] font-medium text-violet-600 dark:text-violet-400 hover:text-violet-700 dark:hover:text-violet-300 transition-colors",children:w?"Hide raw list":"Show raw list"})]}),e.jsx("div",{className:"space-y-2",children:l.map(u=>e.jsxs("details",{className:"rounded-md border border-slate-200/60 dark:border-white/[0.06] bg-slate-50/60 dark:bg-white/[0.02]",children:[e.jsxs("summary",{className:"cursor-pointer list-none px-3 py-2 flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-xs font-medium text-slate-700 dark:text-slate-300 break-words",children:u.label}),e.jsxs("span",{className:"text-[10px] text-slate-500 dark:text-slate-400 shrink-0",children:[u.raw_count," checks"]})]}),e.jsx("ul",{className:"px-3 pb-2 space-y-1",children:u.details.map((O,q)=>e.jsxs("li",{className:"flex items-start gap-2 text-xs text-slate-700 dark:text-slate-300 leading-relaxed",children:[e.jsx("span",{className:"text-amber-500 mt-0.5 shrink-0",children:"â¢"}),e.jsx("span",{className:"break-words",children:O})]},`${u.key}-${q}`))})]},u.key))}),w&&e.jsxs("div",{className:"rounded-md border border-slate-200/60 dark:border-white/[0.06] bg-white/70 dark:bg-white/[0.01] p-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 dark:text-slate-400 font-semibold mb-1.5",children:"Raw Issues"}),e.jsx("ul",{className:"space-y-1 max-h-44 overflow-y-auto pr-1",children:s.issues.map((u,O)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px] text-slate-600 dar
12k:text-slate-300 leading-relaxed",children:[e.jsx("span",{className:"text-slate-400 mt-0.5 shrink-0",children:"â¢"}),e.jsx("span",{className:"break-words",children:u})]},`raw-${O}`))})]})]}),a&&s.corrected_sections&&e.jsxs("div",{className:"border-t border-slate-200/50 dark:border-white/[0.04]",children:[e.jsx("div",{className:"px-4 pt-3 pb-1",children:e.jsxs("p",{className:"text-[11px] font-semibold text-slate-600 dark:text-slate-300 uppercase tracking-wider mb-1 flex items-center gap-1.5",children:[e.jsx("svg",{className:"h-3.5 w-3.5 text-violet-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),"Corrected Structure (",s.corrected_sections.sections.length," sections /"," ",s.corrected_sections.total_word_count.toLocaleString()," words)"]})}),e.jsx(dt,{detail:s.corrected_sections})]})]}),e.jsx(pt,{isOpen:f,onClose:()=>j(!1),title:"Validate Structure - Fix Comparison",size:"full",children:y.length===0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-300",children:"No comparable fix rows were found for this run."}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:"We tried both: stored comparison data and a legacy fallback using Generate Structure + Validate Structure outputs and Validate-step AI prompts."}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:"This usually means no unit-level correction happened in Validate Structure for this run."})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"rounded-lg border border-slate-200/60 dark:border-white/[0.06] bg-slate-50/70 dark:bg-white/[0.02] p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 dark:text-slate-400 font-medium",children:"Compared Issues"}),e.jsx("p",{className:"text-lg font-bold text-slate-900 dark:text-white mt-0.5",children:y.length})]}),e.jsxs("div",{className:"rounded-lg border border-emerald-200/60 dark:border-emerald-500/15 bg-emerald-50/60 dark:bg-emerald-500/[0.04] p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-emerald-700/80 dark:text-emerald-300/70 font-medium",children:"Changed/Fixed"}),e.jsx("p",{className:"text-lg font-bold text-emerald-700 dark:text-emerald-300 mt-0.5",children:I})]}),e.jsxs("div",{className:"rounded-lg border border-amber-200/60 dark:border-amber-500/15 bg-amber-50/60 dark:bg-amber-500/[0.04] p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-amber-700/80 dark:text-amber-300/70 font-medium",children:"Unchanged/Missing"}),e.jsx("p",{className:"text-lg font-bold text-amber-700 dark:text-amber-300 mt-0.5",children:y.length-I})]})]}),e.jsx("div",{className:"space-y-3",children:y.map((u,O)=>{const q=ss(u.status),K=ls(u),se=ds(u),x=ne(u.ai_text)!==""&&ne(u.ai_text)===ne(u.result_text),G=!(ne(u.before_text)===ne(u.result_text)),z=typeof u.rejection_reason=="string"&&u.rejection_reason.trim()!==""?u.rejection_reason.trim():null,X=ct(u.unit_type)&&u.suggested_target_words!=null&&u.before_word_count!=null?u.suggested_target_words-u.before_word_count:null,p=`${u.before_word_count!=null?`${u.before_word_count}w`:"--"} / ${u.before_sentence_word_counts.length}s`,T=`${u.ai_word_count!=null?`${u.ai_word_count}w`:"--"} / ${u.ai_sentence_word_counts.length}s`,pe=`${u.result_word_count!=null?`${u.result_word_count}w`:"--"} / ${u.result_sentence_word_counts.length}s`;return e.jsxs("div",{className:"rounded-lg border border-slate-200/60 dark:border-white/[0.06] bg-white/70 dark:bg-white/[0.02] overflow-hidden",children:[e.jsxs("div",{className:"px-3 py-2 bg-slate-50/80 dark:bg-white/[0.02] border-b border-slate-200/60 dark:border-white/[0.06] flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-mono text-[11px] text-slate-700 dark:text-slate-300",children:u.unit_id}),e.jsx("p",{className:"text-[11px] text-slate-500 dark:text-slate-400 break-words",children:u.section_title||u.section_type||u.unit_type}),e.jsxs("p",{className:"text-[10px] text-slate-400 dark:text-slate-500",children:["Attempt ",u.attempt," - ",u.mode]})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:e.jsx("span",{className:R("inline-flex items-center rounded-md px-1.5 py-0.5 text-[10px] font-semibold ring-1 ring-inset",q.className),children:q.label})})]}),e.jsx("div",{className:"px-3 py-2 bg-violet-50/40 dark:bg-violet-500/[0.04] border-b border-slate-200/50 dark:border-white/[0.04]",children:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider font-semibold text-violet-700 dark:text-violet-300",children:"Asked to AI (Request)"}),se.length>0?e.jsx("ul",{className:"space-y-1",children:se.map((S,ie)=>e.jsxs("li",{className:"text-[11px] text-slate-700 dark:text-slate-300 leading-relaxed break-words",children:["- ",S]},ie))}):e.jsx("p",{className:"text-[11px] text-slate-400 dark:text-slate-500",children:"--"}),X!=null&&X!==0&&e.jsx("p",{className:"text-[10px] font-medium text-violet-600 dar
12k:text-violet-400",children:X>0?`Length action: increase by ${X} words`:`Length action: reduce by ${Math.abs(X)} words`})]})}),e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200/50 dark:border-white/[0.04] space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[x&&e.jsx("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium bg-emerald-50 text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-300",children:"Same as AI output"}),G?e.jsx("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium bg-cyan-50 text-cyan-700 dark:bg-cyan-500/10 dark:text-cyan-300",children:"Changed from previous"}):e.jsx("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium bg-amber-50 text-amber-700 dark:bg-amber-500/10 dark:text-amber-300",children:"Rejected"}),!x&&G&&e.jsx("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium bg-violet-50 text-violet-700 dark:bg-violet-500/10 dark:text-violet-300",children:"Adjusted after validation guards"})]}),z&&e.jsxs("p",{className:"text-[10px] text-amber-700 dark:text-amber-300 leading-relaxed",children:["Rejected reason: ",z]})]}),e.jsx("div",{className:"px-3 pt-0 pb-3",children:e.jsxs("div",{className:"rounded-md border border-slate-200/60 dark:border-white/[0.06] overflow-x-auto",children:[e.jsx("div",{className:"px-2 py-1.5 border-b border-slate-200/60 dark:border-white/[0.06] bg-white/80 dark:bg-white/[0.02]",children:e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500 dark:text-slate-400",children:"Sentence-Level Comparison"})}),e.jsxs("table",{className:"w-full min-w-[950px] text-[11px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50/80 dark:bg-white/[0.03] border-b border-slate-200/60 dark:border-white/[0.06]",children:[e.jsx("th",{className:"text-left px-2 py-1.5 font-medium text-slate-500 dark:text-slate-400",children:"#"}),e.jsx("th",{className:"text-left px-2 py-1.5 font-medium text-slate-500 dark:text-slate-400",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:"Before"}),e.jsx("span",{className:"text-[10px] font-mono text-slate-400 dark:text-slate-500",children:p})]})}),e.jsx("th",{className:"text-left px-2 py-1.5 font-medium text-slate-500 dark:text-slate-400",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:"AI Returned"}),e.jsx("span",{className:"text-[10px] font-mono text-slate-400 dark:text-slate-500",children:T})]})}),e.jsx("th",{className:"text-left px-2 py-1.5 font-medium text-slate-500 dark:text-slate-400",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:"Result"}),e.jsx("span",{className:"text-[10px] font-mono text-slate-400 dark:text-slate-500",children:pe})]})})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100 dark:divide-white/[0.04]",children:K.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-2 py-2 text-slate-400 dark:text-slate-500 text-[11px] italic",children:"No sentence-level data available."})}):K.map(S=>e.jsxs("tr",{className:"align-top",children:[e.jsxs("td",{className:"px-2 py-1.5 font-mono text-slate-500 dark:text-slate-400",children:["S",S.index]}),e.jsx("td",{className:"px-2 py-1.5 text-slate-700 dark:text-slate-300",children:S.before?e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 dark:text-slate-400",children:[S.before.wordCount,"w"]}),e.jsx("p",{className:"break-words",children:qe(S.before.text)})]}):e.jsx("span",{className:"text-slate-400 dark:text-slate-500",children:"--"})}),e.jsx("td",{className:"px-2 py-1.5 text-slate-700 dark:text-slate-300",children:S.ai?e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 dark:text-slate-400",children:[S.ai.wordCount,"w"]}),e.jsx("p",{className:"break-words",children:qe(S.ai.text)})]}):e.jsx("span",{className:"text-slate-400 dark:text-slate-500",children:"--"})}),e.jsx("td",{className:"px-2 py-1.5 text-slate-700 dark:text-slate-300",children:S.result?e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 dark:text-slate-400",children:[S.result.wordCount,"w"]}),e.jsx("p",{className:"break-words",children:qe(S.result.text)})]}):e.jsx("span",{className:"text-slate-400 dark:text-slate-500",children:"--"})})]},S.index))})]})]})})]},`${u.unit_id}-${O}`)})})]})})]})}const at={person:"bg-blue-50 text-blue-700 dark:bg-blue-500/10 dark:text-blue-300 ring-blue-200 dark:ring-blue-500/20",organization:"bg-purple-50 text-purple-700 dark:bg-purple-500/10 dark:text-purple-300 ring-purple-200 dark:ring-purple-500/20",concept:"bg-amber-50 text-amber-700 dark:bg-amber-500/10 dark:text-amber-300 ring-amber-200 dark:ring-amber-500/20",product:"bg-teal-50 text-teal-700 dark:bg-teal-500/10 dark:text-teal-300 ring-teal-200 dark:ring-teal-500/20",location:"bg-rose-50 text-rose-700 dark:bg-rose-500/10 dark:text-rose-300 ring-rose-200 dark:ring-rose-500/20"},nt={person:e.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z"})}),organization:e.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 21h16.5M4.5 3h15M5.25 3v18m13.5-18v18M9 6.75h1.5m-1.5 3h1.5m-1.5 3h1.5m3-6H15m-1.5 3H15m-1.5 3H15M9 21v-3.375c0-.621.504-1.125 1.125-1.125h3.75c.621 0 1.125.504 1.125 1.125V21"})}),concept:e.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 18v-5.25m0 0a6.01 6.01 0 001.5-.189m-1.5.189a6.01 6.01 0 01-1.5-.189m3.75 7.478a12.06 12.06 0 01-4.5 0m3.75 2.383a14.406 14.406 0 01-3 0M14.25 18v-.192c0-.983.658-1.823 1.508-2.316a7.5 7.5 0 10-7.517 0c.85.493 1.509 1.333 1.509 2.316V18"})}),product:e.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 7.5l-9-5.25L3 7.5m18 0l-9 5.25m9-5.25v9l-9 5.25M3 7.5l9 5.25M3 7.5v9l9 5.25m0-9v9"})}),location:e.jsxs("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 10.5a3 3 0 11-6 0 3 3 0 016 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 10.5c0 7.142-7.5 11.25-7.5 11.25S4.5 17.642 4.5 10.5a7.5 7.5 0 1115 0z"})]})};function bs({detail:s}){return e.jsxs("div",{className:"border-t border-slate-200/50 dark:border-white/[0.04]",children:[e.jsxs("div",{className:"px-4 py-2.5 flex items-center gap-2 bg-slate-50/60 dark:bg-white/[0.01]",children:[e.jsx("svg",{className:"h-3.5 w-3.5 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 3v11.25A2.25 2.25 0 006 16.5h2.25M3.75 3h-1.5m1.5 0h16.5m0 0h1.5m-1.5 0v11.25A2.25 2.25 0 0118 16.5h-2.25m-7.5 0h7.5m-7.5 0l-1 3m8.5-3l1 3m0 0l.5 1.5m-.5-1.5h-9.5m0 0l-.5 1.5m.75-9l3-3 2.148 2.148A12.061 12.061 0 0116.5 7.605"})}),e.jsx("span",{className:"text-[11px] font-semibold text-slate-600 dar
12k:text-slate-300 uppercase tracking-wider",children:"Resolved Entities"}),e.jsxs("span",{className:"text-[10px] text-slate-400 dark:text-slate-500 font-medium",children:[s.total_count," ",s.total_count===1?"entity":"entities"]})]}),e.jsx("div",{className:"px-4 py-3 space-y-2.5",children:s.entities.map((t,c)=>{const a=at[t.type]||at.concept,n=nt[t.type]||nt.concept;return e.jsx("div",{className:"rounded-lg border border-slate-200/50 dark:border-white/[0.06] bg-white/60 dark:bg-white/[0.02] p-3",children:e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:R("flex h-7 w-7 items-center justify-center rounded-lg shrink-0 ring-1 ring-inset",a),children:n}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs font-semibold text-slate-800 dark:text-slate-200",children:t.name}),e.jsx("span",{className:R("inline-flex items-center rounded-md px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider ring-1 ring-inset",a),children:t.type}),t.role==="primary"&&e.jsx("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider bg-violet-50 text-violet-600 ring-1 ring-inset ring-violet-200 dark:bg-violet-500/10 dark:text-violet-400 dark:ring-violet-500/20",children:"Primary"})]}),t.description&&e.jsx("p",{className:"text-[11px] text-slate-500 dark:text-slate-400 mt-1 leading-relaxed",children:t.description}),t.synonyms.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[e.jsx("span",{className:"text-[10px] text-slate-400 dark:text-slate-500 font-medium mr-0.5",children:"Synonyms:"}),t.synonyms.map((i,l)=>e.jsx("span",{className:"inline-flex items-center rounded bg-slate-100 dark:bg-white/[0.06] px-1.5 py-0.5 text-[10px] text-slate-600 dark:text-slate-400",children:i},l))]})]})]})},c)})})]})}function ks({detail:s}){const{applied:t,rejected:c,skipped_noop:a,applied_count:n,rejected_count:i,skipped_noop_count:l,no_changes_needed:k}=s;return t.length>0||c.length>0||a.length>0?e.jsxs("div",{className:"border-t border-slate-200/50 dark:border-white/[0.04]",children:[e.jsxs("div",{className:"px-4 py-2.5 flex items-center gap-2 bg-slate-50/60 dark:bg-white/[0.01]",children:[e.jsx("svg",{className:"h-3.5 w-3.5 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("span",{className:"text-[11px] font-semibold text-slate-600 dark:text-slate-300 uppercase tracking-wider",children:"Quality Check Changes"}),e.jsxs("span",{className:"text-[10px] text-slate-400 dark:text-slate-500 font-medium",children:[n," applied · ",i," rejected · ",l," no-op"]})]}),t.length>0&&e.jsx(Fe,{title:"Applied",tone:"applied",changes:t,emptyHint:"No applied changes."}),c.length>0&&e.jsx(Fe,{title:"Rejected",tone:"rejected",changes:c,emptyHint:"No rejected changes."}),a.length>0&&e.jsx(Fe,{title:"Skipped (no-op)",tone:"skipped",changes:a,emptyHint:"No no-op changes."})]}):e.jsx("div",{className:"border-t border-slate-200/50 dark:border-white/[0.04]",children:e.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 bg-slate-50/60 dark:bg-white/[0.01]",children:[e.jsx("svg",{className:"h-3.5 w-3.5 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("span",{className:"text-[11px] font-semibold text-slate-600 dark:text-slate-300 uppercase tracking-wider",children:"Quality Check"}),e.jsx("span",{className:"text-[10px] text-slate-400 dark:text-slate-500 font-medium",children:k?"No changes needed":"No patches applied"})]})})}function Fe({title:s,tone:t,changes:c,emptyHint:a}){const n={applied:"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300 ring-emerald-200 dark:ring-emerald-500/20",rejected:"bg-rose-100 text-rose-700 dark:bg-rose-500/15 dark:text-rose-300 ring-rose-200 dark:ring-rose-500/20",skipped:"bg-slate-100 text-slate-600 dar
12k:bg-white/[0.06] dark:text-slate-300 ring-slate-200 dark:ring-white/[0.06]"};return e.jsxs("div",{className:"px-4 py-3 space-y-2.5 border-t border-slate-100 dark:border-white/[0.04]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:R("inline-flex items-center rounded-md px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider ring-1 ring-inset",n[t]),children:s}),e.jsxs("span",{className:"text-[10px] text-slate-400 dark:text-slate-500 font-medium",children:[c.length," ",c.length===1?"change":"changes"]})]}),c.map((i,l)=>e.jsx(fs,{change:i,tone:t},`${s}-${i.unit_id}-${l}`))]})}function fs({change:s,tone:t}){const{unit_id:c,operation:a,issue:n,reason:i,before_text:l,after_text:k}=s;return e.jsxs("div",{className:"rounded-lg border border-slate-200/50 dark:border-white/[0.06] bg-white/60 dark:bg-white/[0.02] p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap text-[11px]",children:[e.jsx("span",{className:"font-mono text-slate-500 dark:text-slate-400",children:c}),a&&e.jsx("span",{className:"inline-flex items-center rounded bg-slate-100 dark:bg-white/[0.06] px-1.5 py-0.5 text-[10px] font-medium text-slate-600 dark:text-slate-400",children:a}),t==="rejected"&&i&&e.jsx("span",{className:"inline-flex items-center rounded bg-rose-50 dark:bg-rose-500/10 px-1.5 py-0.5 text-[10px] font-medium text-rose-600 dar
12k:text-rose-300",children:i})]}),n&&e.jsxs("p",{className:"text-[11px] text-slate-500 dark:text-slate-400 leading-relaxed",children:[e.jsx("span",{className:"font-semibold text-slate-600 dark:text-slate-300",children:"Issue:"})," ",n]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsxs("div",{className:"rounded border border-slate-200/60 dark:border-white/[0.04] bg-slate-50/60 dark:bg-white/[0.02] p-2",children:[e.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-wider text-slate-400 dark:text-slate-500 mb-1",children:"Before"}),e.jsx("div",{className:"text-[11px] text-slate-700 dark:text-slate-300 whitespace-pre-wrap leading-relaxed",children:l===null||l===""?e.jsx("span",{className:"italic text-slate-400 dark:text-slate-500",children:"(none / insert)"}):l})]}),e.jsxs("div",{className:"rounded border border-slate-200/60 dark:border-white/[0.04] bg-slate-50/60 dark:bg-white/[0.02] p-2",children:[e.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-wider text-slate-400 dark:text-slate-500 mb-1",children:"After"}),e.jsx("div",{className:"text-[11px] text-slate-700 dark:text-slate-300 whitespace-pre-wrap leading-relaxed",children:k===null||k===""?e.jsx("span",{className:"italic text-slate-400 dark:text-slate-500",children:"(deleted)"}):k})]})]})]})}function ye({label:s,value:t,subtitle:c,valueColor:a="text-slate-900 dark:text-white",className:n,...i}){return e.jsxs("div",{className:R("rounded-xl border border-slate-200/80 dark:border-white/[0.08] bg-white/80 dark:bg-slate-900/80 p-3 sm:p-4",n),...i,children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-400 dark:text-slate-500 mb-1",children:s}),e.jsx("p",{className:R("text-xl sm:text-2xl font-bold",a),children:t}),c&&e.jsx("p",{className:"text-[11px] text-slate-400 dark:text-slate-500 mt-0.5",children:c})]})}const it=new Set(["publish","wordpress_publish"]);function js(s,t){if(!s)return"";const c=s.trim();if(c==="")return"";const a=c.replace(" ","T");return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(a)?a:Et(a,t)}function _s(s,t){if(!s)return;const c=s.trim();if(c!=="")return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(c)?zt(c,t)??c:c}function Is(){var v,C,E,D,ke,Le,Ue,Ke;const{id:s}=It(),[t,c]=Rt(),a=Pt(),{isAdmin:n}=ut(),i=je(s,"content route param"),l=t.get("run_id"),k=l===null?void 0:je(l,"run_id query param"),{data:g,isLoading:y,isError:f,refetch:j}=ht(i,!0,k),{data:w}=gt(i),N=bt(),I=kt(),W=ft(),$=jt(),u=_t(),O=vt(),q=mt(),[K,se]=F.useState(!1),[x,P]=F.useState(null),[G,z]=F.useState(!1),[H,X]=F.useState(!1),[p,T]=F.useState(null),[pe,S]=F.useState(""),[ie,Q]=F.useState(!1),[ue,le]=F.useState(!1),[he,oe]=F.useState(!1),o=g==null?void 0:g.data;F.useEffect(()=>{n||a(`/content/${i}`,{replace:!0})},[n,a,i]),F.useEffect(()=>{if(!ie)return;const r=setInterval(async()=>{var ae,fe;const B=(fe=(ae=(await j()).data)==null?void 0:ae.data)==null?void 0:fe.status;B&&!["completed","failed","stopped","cancelled"].includes(B)&&Q(!1)},Nt),d=setTimeout(()=>Q(!1),wt);return()=>{clearInterval(r),clearTimeout(d)}},[ie,j]);const A=(o==null?void 0:o.status)==="completed",Y=(o==null?void 0:o.status)==="failed",U=o==null?void 0:o.is_paused,V=o==null?void 0:o.is_stopped,de=!A&&!Y&&!U&&!V,ge=async()=>{await N.mutateAsync(i)},Se=async()=>{await I.mutateAsync(i)},Me=async()=>{await W.mutateAsync(i)},[Z,te]=F.useState([]),Ce=async(r,d)=>{var L;P(r),S("");try{const B=d!=null&&d.forceRetrySingle?{step_number:r,force_retry_single:!0,from_here:!1}:{step_number:r,from_here:!0},re=await $.mutateAsync({contentId:i,payload:B}),ae=(L=re==null?void 0:re.data)==null?void 0:L.run_id;if(ae!=null){const fe=je(ae,"regenerated run id");c({run_id:fe}),q.invalidateQueries({queryKey:ve.content.progress(i,fe)}),Q(!0)}}catch(B){S(Ne(B,"Failed to start regeneration."))}finally{setTimeout(()=>P(null),2e3)}},h=async()=>{var r;P(9),S("");try{const d=await u.mutateAsync(i),L=(r=d==null?void 0:d.data)==null?void 0:r.run_id;if(L!=null){const B=je(L,"chart regeneration run id");c({run_id:B}),q.invalidateQueries({queryKey:ve.content.progress(i,B)}),Q(!0)}}catch(d){S(Ne(d,"Failed to regenerate charts."))}finally{setTimeout(()=>P(null),2e3)}},b=async()=>{var r;if(Z.length!==0){S("");try{const d=await $.mutateAsync({contentId:i,payload:{force_steps:Z}}),L=(r=d==null?void 0:d.data)==null?void 0:r.run_id;if(L!=null){const B=je(L,"regenerated run id");c({run_id:B}
12),te([]),q.invalidateQueries({queryKey:ve.content.progress(i,B)}),Q(!0)}}catch(d){S(Ne(d,"Failed to start regeneration."))}}};if(!n)return null;if(y)return e.jsxs("div",{className:"w-full space-y-5 animate-pulse",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-5 w-5 rounded bg-slate-200 dark:bg-white/[0.06] mt-1 shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 w-20 bg-slate-100 dark:bg-white/[0.04] rounded-full"}),e.jsx("div",{className:"h-7 bg-slate-200 dark:bg-white/[0.06] rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-slate-100 dark:bg-white/[0.04] rounded w-1/3"})]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[...Array(4)].map((r,d)=>e.jsxs("div",{className:"rounded-xl border border-slate-200/80 dark:border-white/[0.08] bg-white/80 dark:bg-slate-900/80 p-3 space-y-2",children:[e.jsx("div",{className:"h-2.5 w-16 bg-slate-100 dark:bg-white/[0.04] rounded"}),e.jsx("div",{className:"h-6 w-12 bg-slate-200 dark:bg-white/[0.06] rounded"}),e.jsx("div",{className:"h-2.5 w-20 bg-slate-100 dark:bg-white/[0.04] rounded"})]},d))}),e.jsx("div",{className:"rounded-xl border border-slate-200/80 dark:border-white/[0.08] bg-white/80 dark:bg-slate-900/80 p-3",children:e.jsx("div",{className:"h-2.5 bg-slate-100 dark:bg-white/[0.06] rounded-full"})}),e.jsx("div",{className:"rounded-2xl border border-slate-200/80 dark:border-white/[0.08] bg-white/85 dark:bg-slate-900/80 p-4 space-y-3",children:[...Array(5)].map((r,d)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-7 w-7 rounded-full bg-slate-200 dark:bg-white/[0.06] shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-3.5 bg-slate-200 dark:bg-white/[0.06] rounded w-1/3"}),e.jsx("div",{className:"h-2.5 bg-slate-100 dark:bg-white/[0.04] rounded w-1/2"})]})]},d))})]});if(f||!o)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 space-y-4",children:[e.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-rose-500/10",children:e.jsx("svg",{className:"h-8 w-8 text-rose-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"})})}),e.jsx("h2",{className:"text-lg font-semibold text-slate-900 dark:text-white",children:"Unable to Load Progress"}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400",children:"The generation progress data could not be found."}),e.jsx(ee,{size:"sm",onClick:()=>a("/content"),children:"Back to Content"})]});if(o.status==="none"||o.total_steps==null)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 space-y-4",children:[e.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-slate-500/10",children:e.jsx("svg",{className:"h-8 w-8 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("h2",{className:"text-lg font-semibold text-slate-900 dark:text-white",children:"No Generation Runs Yet"}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400",children:"This content has no generation progress to show."}),e.jsx(ee,{size:"sm",onClick:()=>a(`/content/${i}`),children:"View Content"})]});const M=!!o.force_generate&&(o.status==="running"||o.status==="resuming"),be=((o.steps&&o.steps.length>0?[...o.steps].sort((r,d)=>r.step-d.step):null)??Tt.map((r,d)=>({step:d+1,name:Qe[d]??r,status:"pending",started_at:null,completed_at:null,duration_seconds:null,duration_ms:null,details:null,error_message:null,output_summary:null,output_detail:null,source_run_id:null}))).map((r,d)=>{const L=r.step??d+1,B=r.name??Qe[d],re=Ee(B),ae=o.is_rewrite&&B==="generate_structure"?"Refresh Structure":re;return{step:L,name:ae,status:(r==null?void 0:r.status)??(L<o.current_step?"completed":L===o.current_step?"running":"pending"),started_at:(r==null?void 0:r.started_at)??null,completed_at:(r==null?void 0:r.completed_at)??null,duration_seconds:(r==null?void 0:r.duration_seconds)??null,duration_ms:(r==null?void 0:r.duration_ms)??null,details:(r==null?void 0:r.details)??null,error_message:(r==null?void 0:r.error_message)??null,output_summary:(r==null?void 0:r.output_summary)??null,output_detail:(r==null?void 0:r.output_detail)??null,ai_requests:r==null?void 0:r.ai_requests,source_run_id:(r==null?void 0:r.source_run_id)??null}}),Ae=M?be.map(r=>r.step>o.current_step?{...r,status:"pending",completed_at:null,duration_ms:null,duration_seconds:null,output_summary:null}:r):be,Ie=o.completed_steps??Ae.filter(r=>r.status==="completed").length,_=((v=w==null?void 0:w.data)==null?void 0:v.reduce((r,d)=>r+(d.total_ai_cost_usd??0),0))??0,m=[];for(const r of o.steps??[])if(r.ai_requests)for(const d of r.ai_requests)m.pu
12sh({...d,step_name:r.name});return e.jsxs("div",{className:"w-full space-y-5",children:[e.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[e.jsx("button",{onClick:()=>a(`/content/${i}`),"aria-label":"Back to content",className:"mt-1 text-slate-400 dark:text-slate-500 hover:text-slate-900 dark:hover:text-white transition-colors shrink-0",children:e.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 19l-7-7 7-7"})})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-0.5",children:[e.jsxs("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider ${A?"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-400":Y?"bg-rose-100 text-rose-700 dark:bg-rose-500/15 dark:text-rose-400":U?"bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-400":V?"bg-slate-100 text-slate-700 dark:bg-slate-500/15 dark:text-slate-400":"bg-violet-100 text-violet-700 dark:bg-violet-500/15 dark:text-violet-400"}`,children:[e.jsx("span",{className:"hidden xs:inline",children:U?"Awaiting Approval":V?"Stopped":o.status}),e.jsx("span",{className:"xs:hidden",children:U?"Approval":V?"Stopped":o.status})]}),o.retry_count>0&&e.jsxs("span",{className:"text-[10px] text-slate-400 dark:text-slate-500 font-medium",children:["Retry ",o.retry_count,"/",o.max_retries]})]}),e.jsx("h1",{className:"text-lg sm:text-xl md:text-2xl font-bold text-slate-900 dark:text-white leading-tight break-words",children:o.content_title}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 mt-1 text-[11px] sm:text-xs text-slate-500 dark:text-slate-400",children:[o.website_name&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex items-center gap-1 truncate max-w-[150px] sm:max-w-none",children:[e.jsx("svg",{className:"h-3 w-3 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 21a9.004 9.004 0 008.716-6.747M12 21a9.004 9.004 0 01-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 017.843 4.582M12 3a8.997 8.997 0 00-7.843 4.582m15.686 0A11.953 11.953 0 0112 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0121 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0112 16.5a17.919 17.919 0 01-8.716-2.247m0 0A9.015 9.015 0 013 12c0-1.605.42-3.113 1.157-4.418"})}),e.jsx("span",{className:"truncate",children:o.website_name})]}),e.jsx("span",{className:"text-slate-300 dark:text-slate-600 hidden xs:inline",children:"/"})]}),e.jsxs("span",{className:"hidden xs:inline",children:["Content #",i]}),e.jsx("span",{className:"text-slate-300 dark:text-slate-600 hidden xs:inline",children:"/"}),e.jsxs("span",{children:["Run #",o.run_id]})]})]})]}),ie&&e.jsxs("div",{className:"rounded-xl border border-violet-200 dark:border-violet-500/30 bg-violet-50/80 dark:bg-violet-500/10 p-3 flex items-center gap-2 text-sm text-violet-800 dark:text-violet-300",children:[e.jsx("span",{className:"inline-block h-4 w-4 animate-spin rounded-full border-2 border-violet-500 border-t-transparent","aria-hidden":!0}),"Starting regenerationâ¦"]}),o.generation_settings&&e.jsxs("div",{className:"rounded-xl border border-slate-200/80 dark:border-white/[0.08] bg-white/80 dark:bg-slate-900/80 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("svg",{className:"h-3.5 w-3.5 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 010 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 010-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.
12125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),e.jsx("span",{className:"text-[10px] font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:"Generation Settings"})]}),H?e.jsx(ee,{size:"sm",variant:"ghost",onClick:()=>{X(!1),T(null),S("")},children:"Cancel"}):e.jsx(ee,{size:"sm",variant:"ghost",onClick:()=>{S("");const r=o.generation_settings;T({...r,keywords:r.keywords??[],approval_required:r.approval_required??!0,approval_stop_step:r.approval_stop_step??"generate_content",completion_action:r.completion_action??(r.auto_publish?"publish":"draft"),scheduled_publish_at:r.scheduled_publish_at??null,action_requirement:r.action_requirement??null,cta_url:r.cta_url??null}),X(!0)},children:"Edit"})]}),H?p&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 mt-1",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:J,children:"Title"}),e.jsx("input",{type:"text",className:me,value:p.title??"",onChange:r=>T(d=>d&&{...d,title:r.target.value})})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:J,children:"Topic"}),e.jsx("input",{type:"text",className:me,value:p.topic??"",onChange:r=>T(d=>d&&{...d,topic:r.target.value})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("label",{className:J,children:"Content type"}),e.jsxs("span",{className:"relative inline-flex group/contenttype",children:[e.jsx("button",{type:"button","aria-label":"Content type descriptions",className:"inline-flex h-4 w-4 items-center justify-center rounded-full border border-slate-300 dark:border-slate-600 text-slate-500 dark:text-slate-400 hover:border-violet-400 hover:text-violet-500 dark:hover:border-violet-500 dark:hover:text-violet-400 transition-colors text-[10px] font-bold",children:"i"}),e.jsxs("span",{className:"absolute left-0 top-full z-20 mt-1 hidden w-64 rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 px-3 py-2.5 text-left text-xs shadow-lg group-hover/contenttype:block",children:[e.jsx("p",{className:"font-semibold text-slate-700 dark:text-slate-200 mb-2",children:"Content types"}),e.jsx("ul",{className:"space-y-1.5",children:Ye.map(r=>e.jsxs("li",{children:[e.jsxs("span",{className:"font-medium text-slate-700 dark:text-slate-200",children:[r.label,":"]})," ",e.jsx("span",{className:"text-slate-600 dark:text-slate-400",children:St[r.value]??r.label})]},r.value))})]})]})]}),e.jsx("select",{className:_e,value:p.content_type??"article",onChange:r=>T(d=>d&&{...d,content_type:r.target.value}),children:Ye.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:J,children:"Locale"}),e.jsx("select",{className:_e,value:p.search_locale??"en-US",onChange:r=>T(d=>d&&{...d,search_locale:r.target.value}),children:Ct.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:J,children:"Target word count"}),e.jsx("select",{className:_e,value:p.target_word_count!=null&&$e.some(r=>r.value===p.target_word_count)?p.target_word_count:$e[0].value,onChange:r=>{const d=parseInt(r.target.value,10);T(L=>L&&{...L,target_word_count:d})},children:$e.map(r=>e.jsxs("option",{value:r.value,children:[r.label," - ",r.description]},r.value))})]}),p.idea_id&&e.jsxs("div",{children:[e.jsx("label",{className:J,children:"Idea"}),e.jsx("div",{className:`${me} cursor-not-allowed bg-slate-50 dark:bg-slate-900/40 text-slate-600 dark:text-slate-400 line-clamp-1`,title:p.idea_id,"aria-readonly":"true",children:((ke=o.generation_settings)==null?void 0:ke.idea_title)??`#${p.idea_id}`})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:J,children:"Keywords (comma-separated)"}),e.jsx("input",{type:"text",className:me,value:(p.keywords??[]).join(", "),onChange:r=>T(d=>d&&{...d,keywords:r.target.value.split(",").map(L=>
12L.trim()).filter(Boolean)})})]}),e.jsxs("div",{className:"sm:col-span-2 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsx(we,{checked:p.use_internet_search,onChange:r=>T(d=>d&&{...d,use_internet_search:r,use_citations:r?d.use_citations??!0:!1}),label:"Web search"}),e.jsx(we,{checked:!!p.use_citations,onChange:r=>T(d=>d&&{...d,use_citations:r}),label:"Linked citations",disabled:!p.use_internet_search}),e.jsx(we,{checked:p.approval_required!==!1,onChange:r=>T(d=>d&&{...d,approval_required:r,approval_stop_step:r?d.approval_stop_step??"generate_content":void 0}),label:"Approval required"})]}),p.approval_required!==!1&&e.jsxs("div",{children:[e.jsx("label",{className:J,children:"Approval stop step"}),e.jsx("select",{className:_e,value:p.approval_stop_step??"generate_content",onChange:r=>T(d=>d&&{...d,approval_stop_step:r.target.value}),children:Re.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1.5",children:((Le=Re.find(r=>r.value===(p.approval_stop_step??"generate_content")))==null?void 0:Le.description)??"Choose when generation should pause for approval."})]}),e.jsxs("div",{children:[e.jsx("label",{className:J,children:"Complete step action"}),e.jsx("select",{className:_e,value:p.completion_action??(p.auto_publish?"publish":"draft"),onChange:r=>T(d=>{if(!d)return d;const L=r.target.value,B=it.has(L??"");return{...d,completion_action:L,auto_publish:B,scheduled_publish_at:L==="schedule_publish"?d.scheduled_publish_at:null}}),children:Pe.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1.5",children:((Ue=Pe.find(r=>r.value===(p.completion_action??(p.auto_publish?"publish":"draft"))))==null?void 0:Ue.description)??"Choose what should happen automatically at the complete step."})]}),p.completion_action==="schedule_publish"&&e.jsxs("div",{children:[e.jsx("label",{className:J,children:"Scheduled publish at (optional)"}),e.jsx("input",{type:"datetime-local",className:me,value:js(p.scheduled_publish_at,o.website_timezone),onChange:r=>T(d=>d&&{...d,scheduled_publish_at:r.target.value.trim()===""?null:r.target.value})}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1.5",children:"Leave empty to use backend default delay."}),e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mt-1",children:o.website_timezone?`Times are in ${De(o.website_timezone)} (site timezone).`:`Times are in ${De()} (your local timezone).`})]}),e.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:["Auto publish is derived from completion action:"," ",it.has(p.completion_action??"")?"enabled (publish immediately)":"disabled"]})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:J,children:"Action requirement (optional)"}),e.jsx(Mt,{minRows:2,className:me,value:p.action_requirement??"",onChange:r=>T(d=>d&&{...d,action_requirement:r.target.value.trim()===""?null:r.target.value}),placeholder:"What should readers do after reading?"})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:J,children:"CTA URL (optional)"}),e.jsx("input",{type:"text",className:me,value:p.cta_url??"",onChange:r=>T(d=>d&&{...d,cta_url:r.target.value.trim()===""?null:r.target.value}),placeholder:"https://example.com/signup"})]}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(we,{checked:ue,onChange:r=>{le(r),r&&oe(!1)},label:"Regenerate everything from scratch (e.g. title/topic changed)"})}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(we,{checked:he,onChange:r=>{oe(r),r&&le(!1)},label:"Surgical rewrite (refresh only outdated parts using new research, keep the rest)"})})]}
12),pe&&e.jsx("p",{className:"mt-2 text-xs text-rose-600 dark:text-rose-400",role:"alert",children:pe}),(A||Y||V)&&e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:e.jsx(ee,{disabled:!At(p,o.generation_settings)&&!ue&&!he||O.isPending,loading:O.isPending,onClick:async()=>{var d,L,B,re;S("");const r={title:p.title??void 0,topic:p.topic??void 0,keywords:(d=p.keywords)!=null&&d.length?p.keywords:void 0,type:p.content_type,search_locale:p.search_locale,target_word_count:p.target_word_count??void 0,use_internet_search:p.use_internet_search,use_citations:p.use_citations,auto_publish:p.auto_publish,approval_required:p.approval_required,approval_stop_step:p.approval_required===!1?void 0:p.approval_stop_step??"generate_content",completion_action:p.completion_action??(p.auto_publish?"publish":"draft"),scheduled_publish_at:p.completion_action==="schedule_publish"?_s(p.scheduled_publish_at,o.website_timezone):void 0,action_requirement:((L=p.action_requirement)==null?void 0:L.trim())===""?void 0:p.action_requirement??void 0,cta_url:((B=p.cta_url)==null?void 0:B.trim())===""?void 0:p.cta_url??void 0,idea_id:(re=p.idea_id)!=null&&re.trim()?p.idea_id:void 0,force_generate:ue||void 0,rewrite_mode:he||void 0};try{await O.mutateAsync({contentId:i,payload:r}),X(!1),T(null),le(!1),oe(!1),c({}),Q(!0),await q.refetchQueries({queryKey:ve.content.progress(i)})}catch(ae){S(Ne(ae,"Regeneration failed."))}},children:"Regenerate with new settings"})})]}):e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5",children:[o.generation_settings.topic&&o.generation_settings.topic!==o.generation_settings.title&&e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-400 dark:text-slate-500",children:"Topic"}),e.jsx("p",{className:"text-xs text-slate-700 dark:text-slate-300 leading-snug line-clamp-2",children:o.generation_settings.topic})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5",children:[o.generation_settings.target_word_count&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-400 dark:text-slate-500",children:"Words"}),e.jsx("p",{className:"text-xs font-medium text-slate-700 dark:text-slate-300",children:yt(o.generation_settings.target_word_count)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-400 dark:text-slate-500",children:"Type"}),e.jsx("p",{className:"text-xs font-medium text-slate-700 dark:text-slate-300 capitalize",children:o.generation_settings.content_type})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-400 dark:text-slate-500",children:"Locale"}),e.jsx("p",{className:"text-xs font-medium text-slate-700 dark:text-slate-300 uppercase",children:o.generation_settings.search_locale})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-400 dark:text-slate-500",children:"Web Search"}),e.jsx("p",{className:"text-xs font-medium text-slate-700 dark:text-slate-300",children:o.generation_settings.use_internet_search?"Enabled":"Disabled"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-400 dark:text-slate-500",children:"Citations"}),e.jsx("p",{className:"text-xs font-medium text-slate-700 dark:text-slate-300",children:o.generation_settings.use_citations?"Enabled":"Disabled"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-400 dark:text-slate-500",children:"Batch Mode"}),e.jsx("p",{className:"text-xs font-medium text-slate-700 dark:text-slate-300",children:o.generation_settings.use_batch?"On (Vertex batch)":"Off (online)"})]}),o.generation_settings.idea_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-400 dark:text-slate-500",children:"Idea"}),e.jsx("p",{className:"text-xs font-medium text-slate-700 dark:text-slate-300 line-clamp-1",children:o.generation_settings.idea_title??`#${o.generation_settings.idea_id}`})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-400 dark:text-slate-500",children:"Auto Publish"}),e.jsx("p",{className:"text-xs font-medium text-slate-700 dark:text-slate-300",children:o.generation_settings.auto_publish?"Yes":"No"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-400 dark:text-slate-500",children:"Approval Required"}),e.jsx("p",{className:"text-xs font-medium text-slate-700 dark:text-slate-300",children:o.generation_settings.approval_required!==!1?"Yes":"No"})]}),o.generation_settings.approval_required!==!1&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-400 dark:text-slate-500",children:"Approval Stop Step"}),e.jsx("p",{className:"text-xs font-medium text-slate-700 dark:text-slate-300",children:((C=Re.find(r=>{var d;return r.value===(((d=o.generation_settings)==null?void 0:d.approval_stop_step)??"generate_content")}))==null?void 0:C.label)??"Generate Content"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-400 dark:text-slate-500",children:"Complete Action"}),e.jsx("p",{className:"text-xs font-medium text-slate-700 dark:text-slate-300",children:((E=Pe.find(r=>{var d,L;return r.value===(((d=o.generation_settings)==null?void 0:d.completion_action)??((L=o.generation_settings)!=null&&L.auto_publish?"publish":"draft"))}))==null?void 0:E.label)??"Auto Draft"})]})]}),o.generation_settings.completion_action==="schedule_publish"&&e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-400 dark:text-slate-500",children:"Scheduled Publish At"}),e.jsx("p",{className:"text-xs font-medium text-slate-700 dark:text-slate-300",children:o.generation_settings.scheduled_publish_at||"Default backend schedule delay"})]}),(o.generation_settings.action_requirement||o.generation_settings.cta_url)&&e.jsxs("div",{className:"sm:col-span-2 grid grid-cols-1 sm:grid-cols-2 gap-2",children:[o.generation_settings.action_requirement&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-400 dark:text-slate-500",children:"Action Requirement"}),e.jsx("p",{className:"text-xs text-slate-700 dark:text-slate-300 leading-snug line-clamp-2",children:o.generation_settings.action_requirement})]}),o.generation_settings.cta_url&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-400 dark:text-slate-500",children:"CTA URL"}),e.jsx("p",{className:"text-xs text-slate-700 dark:text-slate-300 break-all line-clamp-2",children:o.generation_settings.cta_url})]})]}),((D=o.generation_settings.keywords)==null?void 0:D.length)>0&&e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-400 dark:text-slate-500",children:"Keywords"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:o.generation_settings.keywords.map((r,d)=>e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-violet-50 text-violet-700 dark:bg-violet-500/10 dark:text-violet-400",children:r},d))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 ga
12p-2 sm:gap-3",children:[e.jsx(ye,{label:"Progress",value:`${Math.round(o.percentage)}%`,subtitle:`${Ie}/${o.total_steps} steps`}),e.jsx(ye,{label:"Duration",value:Xe(o.duration_seconds),subtitle:o.started_at?`Started ${Te(o.started_at)}`:"Elapsed time"}),e.jsx(ye,{label:"AI Cost",value:Je(o.total_ai_cost_usd),subtitle:o.has_batch_requests?"Incl. batch (~50% off) · Click for breakdown":"Click for breakdown",onClick:()=>z(!0),className:"text-left cursor-pointer hover:border-violet-300 dark:hover:border-violet-500/30 hover:bg-violet-50/40 dark:hover:bg-violet-500/[0.04] transition-colors"}),e.jsx(ye,{label:"Total",value:Je(_),subtitle:`All ${((Ke=w==null?void 0:w.data)==null?void 0:Ke.length)??0} run(s)`}),e.jsx(ye,{label:"Current Step",value:e.jsx("span",{className:"text-xs sm:text-sm truncate block",title:Ee(o.step_name),children:Ee(o.step_name)}),subtitle:`Step ${Math.min(o.current_step+1,o.total_steps)} of ${o.total_steps}`})]}),e.jsxs("div",{className:"rounded-xl border border-slate-200/80 dark:border-white/[0.08] bg-white/80 dark:bg-slate-900/80 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[de&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-violet-500 animate-pulse"}),A&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-emerald-500"}),Y&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-rose-500"}),U&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-amber-500"}),V&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-500"}),e.jsx("span",{className:"text-xs font-medium text-slate-700 dark:text-slate-300",children:A?"All steps completed":U?"Waiting for approval":Y?"Generation failed":V?"Generation stopped":`Processing step ${o.current_step+1}...`})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[de&&o.can_stop&&e.jsxs("button",{onClick:Me,disabled:W.isPending,className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium text-rose-600 dar
12k:text-rose-400 bg-rose-50 dark:bg-rose-500/10 border border-rose-200 dark:border-rose-500/20 hover:bg-rose-100 dark:hover:bg-rose-500/20 transition-colors disabled:opacity-50",children:[e.jsx("svg",{className:"h-3 w-3",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),W.isPending?"Stopping...":"Stop"]}),e.jsxs("span",{className:"text-xs font-bold text-slate-600 dark:text-slate-300",children:[Math.round(o.percentage),"%"]})]})]}),e.jsx("div",{className:"h-2.5 rounded-full bg-slate-100 dark:bg-white/[0.06] overflow-hidden",role:"progressbar","aria-valuenow":Math.round(o.percentage),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Generation progress: ${Math.round(o.percentage)}%`,children:e.jsx("div",{className:`h-full rounded-full transition-all duration-700 ease-out ${A?"bg-emerald-500":Y?"bg-rose-500":U?"bg-amber-500":V?"bg-slate-400":"bg-violet-600"}`,style:{width:`${o.percentage}%`}})})]}),U&&e.jsx("div",{className:"rounded-xl border border-amber-200/80 dark:border-amber-500/15 bg-amber-50/80 dark:bg-amber-500/[0.05] p-3 sm:p-4",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 sm:h-9 sm:w-9 items-center justify-center rounded-lg bg-amber-100 dark:bg-amber-500/15 shrink-0",children:e.jsx("svg",{className:"h-4 w-4 sm:h-5 sm:w-5 text-amber-600 dark:text-amber-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-xs sm:text-sm font-semibold text-amber-800 dark:text-amber-300",children:"Approval Required"}),e.jsxs("p",{className:"text-[11px] sm:text-xs text-amber-700/80 dark:text-amber-300/60 mt-0.5",children:["Generation is paused at ",o.step_name||"the selected step"," and is waiting for your approval."]})]})]}),e.jsxs(ee,{onClick:Se,loading:I.isPending,className:"w-full sm:w-auto sm:self-start",size:"sm",children:[e.jsx("span",{className:"hidden xs:inline",children:"Approve & Continue"}),e.jsx("span",{className:"xs:hidden",children:"Approve"})]})]})}),V&&e.jsx("div",{className:"rounded-xl border border-slate-200/80 dark:border-slate-500/15 bg-slate-50/80 dark:bg-slate-500/[0.05] p-3 sm:p-4",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 sm:h-9 sm:w-9 items-center justify-center rounded-lg bg-slate-100 dark:bg-slate-500/15 shrink-0",children:e.jsx("svg",{className:"h-4 w-4 sm:h-5 sm:w-5 text-slate-600 dark:text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5.25 7.5A2.25 2.25 0 017.5 5.25h9a2.25 2.25 0 012.25 2.25v9a2.25 2.25 0 01-2.25 2.25h-9a2.25 2.25 0 01-2.25-2.25v-9z"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-xs sm:text-sm font-semibold text-slate-800 dark:text-slate-300",children:"Generation Stopped"}),e.jsx("p",{className:"text-[11px] sm:text-xs text-slate-600/80 dark:text-slate-300/60 mt-0.5",children:"Generation was stopped by user. You can resume from the last completed step."})]})]}),e.jsxs(ee,{onClick:ge,loading:N.isPending,className:"w-full sm:w-auto sm:self-start",size:"sm",children:[e.jsx("span",{className:"hidden xs:inline",children:"Resume Generation"}),e.jsx("span",{className:"xs:hidden",children:"Resume"})]})]})}),Y&&e.jsx("div",{className:"rounded-xl border border-rose-200/80 dark:border-rose-500/15 bg-rose-50/80 dark:bg-rose-500/[0.05] p-3 sm:p-4",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 sm:h-9 sm:w-9 items-center justify-center rounded-lg bg-rose-100 dar
12k:bg-rose-500/15 shrink-0",children:e.jsx("svg",{className:"h-4 w-4 sm:h-5 sm:w-5 text-rose-600 dark:text-rose-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-xs sm:text-sm font-semibold text-rose-800 dark:text-rose-300",children:"Generation Failed"}),e.jsx("p",{className:"text-[11px] sm:text-xs text-rose-700/80 dark:text-rose-300/60 mt-0.5 break-words",children:o.error||"An error occurred during content generation."}),o.can_resume&&e.jsx("p",{className:"text-[10px] sm:text-[11px] text-rose-600/60 dark:text-rose-400/40 mt-1",children:"Checkpoint available -- you can resume from the last successful step."})]})]}),o.can_resume&&e.jsxs(ee,{onClick:ge,loading:N.isPending,className:"w-full sm:w-auto sm:self-start",size:"sm",children:[e.jsx("span",{className:"hidden xs:inline",children:"Resume from Checkpoint"}),e.jsx("span",{className:"xs:hidden",children:"Resume"})]})]})}),A&&e.jsx("div",{className:"rounded-xl border border-emerald-200/80 dark:border-emerald-500/15 bg-emerald-50/80 dark:bg-emerald-500/[0.05] p-3 sm:p-4",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 sm:h-9 sm:w-9 items-center justify-center rounded-lg bg-emerald-100 dark:bg-emerald-500/15 shrink-0",children:e.jsx("svg",{className:"h-4 w-4 sm:h-5 sm:w-5 text-emerald-600 dark:text-emerald-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-xs sm:text-sm font-semibold text-emerald-800 dark:text-emerald-300",children:"Generation Complete"}),e.jsxs("p",{className:"text-[11px] sm:text-xs text-emerald-700/80 dark:text-emerald-300/60 mt-0.5",children:["All ",o.total_steps," pipeline steps finished successfully in"," ",Xe(o.duration_seconds),".",o.total_ai_cost_usd>0&&` AI cost: ${Lt(o.total_ai_cost_usd)}.`]})]})]}),e.jsxs("div",{className:"flex flex-col xs:flex-row gap-2",children:[e.jsx(ee,{onClick:()=>a(`/content/${i}`),size:"sm",className:"w-full xs:w-auto",children:"View Content"}),e.jsxs(ee,{variant:"secondary",size:"sm",onClick:async()=>{S("");try{await O.mutateAsync({contentId:i,payload:{force_generate:!0}}),c({}),Q(!0),await q.refetchQueries({queryKey:ve.content.progress(i)})}catch(r){S(Ne(r,"Force retry all failed."))}},disabled:O.isPending,loading:O.isPending,title:"Re-run all 19 steps from scratch (no reuse)",className:"w-full xs:w-auto",children:[e.jsx("span",{className:"hidden xs:inline",children:"Force retry all"}),e.jsx("span",{className:"xs:hidden",children:"Retry all"})]})]})]})}),e.jsxs("div",{className:"rounded-2xl border border-slate-200/80 dark:border-white/[0.08] bg-white/85 dark:bg-slate-900/80 backdrop-blur-xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 sm:px-5 py-3 border-b border-slate-200/60 dark:border-white/[0.04]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"h-4 w-4 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 12h16.5m-16.5 3.75h16.5M3.75 19.5h16.5M5.625 4.5h12.75a1.875 1.875 0 010 3.75H5.625a1.875 1.875 0 010-3.75z"})}),e.jsx("h3",{className:"text-sm font-semibold text-slate-700 dark:text-slate-300",children:"Pipeline Steps"}),e.jsxs("span",{className:"text-[10px] font-medium text-slate-400 dark:text-slate-500 bg-slate-100 dark:bg-white/[0.06] px-1.5 py-0.5 rounded-full",children:[Ie,"/",o.total_steps]})]}),e.jsxs("button",{onClick:()=>se(r=>!r),"aria-expanded":K,"aria-label":K?"Collapse all steps":"Expand all steps",className:"flex items-center gap-1 text-xs text-violet-600 dar
12k:text-violet-400 hover:text-violet-700 dark:hover:text-violet-300 transition-colors font-medium",children:[e.jsx("svg",{className:`h-3 w-3 transition-transform duration-200 ${K?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})}),K?"Collapse All":"Expand All"]})]}),e.jsxs("div",{className:"px-3 sm:px-4 py-2",children:[(A||Y||U||V)&&Z.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 sm:px-4 py-2",children:[e.jsxs(ee,{size:"sm",variant:"secondary",onClick:b,disabled:$.isPending,loading:$.isPending,children:["Regenerate selected steps (",Z.length,")"]}),e.jsx("button",{type:"button",onClick:()=>te([]),className:"text-xs text-slate-500 dark:text-slate-400 hover:underline",children:"Clear selection"})]}),e.jsx(Xt,{steps:Ae,currentRunId:o.run_id,contentId:i,isGenerationActive:de,expandAll:K,canRegenerate:A||Y||U||V,regeneratingStep:x,onRegenerateStep:Ce,onRegenerateCharts:h,selectedForceSteps:Z,onSelectedForceStepsChange:te,purposeConfigs:o.purpose_configs})]})]}),(o.started_at||o.completed_at)&&e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-[11px] text-slate-400 dark:text-slate-500",children:[o.started_at&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Started: ",Te(o.started_at)]}),o.completed_at&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Completed: ",Te(o.completed_at)]})]}),e.jsx($t,{isOpen:G,onClose:()=>z(!1),aiRequests:m,totalCost:o.total_ai_cost_usd})]})}export{Is 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.