1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[599],{13794:e=>{e.exports={"va-panel":"VideoAgentPanel_va-panel__HPwL4","va-header":"VideoAgentPanel_va-header__vL_fV","va-header-left":"VideoAgentPanel_va-header-left__4tjb_","va-icon":"VideoAgentPanel_va-icon__8104_","va-title":"VideoAgentPanel_va-title__YukKY","va-badge":"VideoAgentPanel_va-badge__QC4NL","va-badge-ok":"VideoAgentPanel_va-badge-ok__ouuMr","va-badge-warn":"VideoAgentPanel_va-badge-warn__geyV2","va-chevron":"VideoAgentPanel_va-chevron__Prp_t","va-chevron-open":"VideoAgentPanel_va-chevron-open__5R_s7","va-body":"VideoAgentPanel_va-body___AT1Z","va-notice":"VideoAgentPanel_va-notice__XLefv","va-notice-warn":"VideoAgentPanel_va-notice-warn__yWMNE","va-notice-error":"VideoAgentPanel_va-notice-error__gPAcN","va-notice-icon":"VideoAgentPanel_va-notice-icon__AUsbt","va-notice-title":"VideoAgentPanel_va-notice-title__jdx6W","va-notice-text":"VideoAgentPanel_va-notice-text__78Bah","va-dismiss":"VideoAgentPanel_va-dismiss__ololO","va-loading":"VideoAgentPanel_va-loading__AHbw4","va-spinner":"
1VideoAgentPanel_va-spinner__KEdQh","va-spin":"VideoAgentPanel_va-spin__EJJc_","va-spinner-sm":"VideoAgentPanel_va-spinner-sm__uMUki","va-section-label":"VideoAgentPanel_va-section-label__PruYv","va-import-actions":"VideoAgentPanel_va-import-actions__tpGnz","va-progress":"VideoAgentPanel_va-progress__sdsum","va-hint":"VideoAgentPanel_va-hint__XIJ4i","va-btn":"VideoAgentPanel_va-btn__1b4Xs","va-btn-primary":"VideoAgentPanel_va-btn-primary__UByPc","va-btn-secondary":"VideoAgentPanel_va-btn-secondary__vXKFs","va-btn-sm":"VideoAgentPanel_va-btn-sm__c0HyR","va-btn-icon":"VideoAgentPanel_va-btn-icon__jNqTC","va-agents":"VideoAgentPanel_va-agents__UptUI","va-agent-grid":"VideoAgentPanel_va-agent-grid__Kxk4j","va-card":"VideoAgentPanel_va-card__WvAdB","va-card-head":"VideoAgentPanel_va-card-head__cx1ex","va-card-icon":"VideoAgentPanel_va-card-icon__ay3zo","va-card-title":"VideoAgentPanel_va-card-title__J5wMb","va-inline-form":"VideoAgentPanel_va-inline-form__fkCv3","va-clip-form":"VideoAgentPanel_va-clip-form__HQmI8","va-input":"VideoAgentPanel_va-input__Dcq4P","va-input-sm":"VideoAgentPanel_va-input-sm__WukhR","va-select":"VideoAgentPanel_va-select__HNN_V","va-field":"VideoAgentPanel_va-field___RkXB","va-field-grow":"VideoAgentPanel_va-field-grow__gOh2K","va-field-label":"VideoAgentPanel_va-field-label__GzzU8","va-range":"VideoAgentPanel_va-range__UY5yN","va-range-value":"VideoAgentPanel_va-range-value__uOjMv","va-result":"VideoAgentPanel_va-result__MC9D0","va-result-text":"VideoAgentPanel_va-result-text__JFA5k","va-result-link":"VideoAgentPanel_va-result-link__i943U","va-collapse-toggle":"VideoAgentPanel_va-collapse-toggle__zJHbp","va-video-player":"VideoAgentPanel_va-video-player__WlIqt","va-frame-thumb":"VideoAgentPanel_va-frame-thumb__umFFc","va-search-results":"VideoAgentPanel_va-search-results__Jciqh","va-search-hit":"VideoAgentPanel_va-search-hit__jsxM7","va-timestamp":"VideoAgentPanel_va-timestamp__WfIGw","va-search-text":"VideoAgentPanel_va-search-text__O529_"}},28219:(e,t,l)=>{"use strict";function a(e){if(!function(e){if("string"!=typeof e)return!1;try{let t=e.split(".");if(3!==t.length||!t[2])return!1;let l=JSON.parse(atob(t[1].replace(/-/g,"+").replace(/_/g,"/")));return!!l.sub&&Number(l.exp)>Date.now()/1e3}catch(e){return!1}}(e))throw Object.assign(Error("Please sign in to build your website."),{response:{status:401}});return{Authorization:"Bearer ".concat(e)}}l.d(t,{V:()=>a})},68145:(e,t,l)=>{"use strict";l.d(t,{Ks:()=>d,Uf:()=>u,lt:()=>o,sU:()=>s,vi:()=>c});let a=/\.(png|jpe?g|webp|gif)(\?|$)/i;function i(e){var t;return(null==(t=String(e||"").split(/[/\\]/).pop())?void 0:t.split("?")[0])||"image.png"}function n(e){return/^https?:\/\//i.test(String(e||""))}function r(e){var t,l;let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=String(e||"").trim();if(!r)return null;let s=i(r),o=s.toLowerCase(),d=r.replace(/\\/g,"/").toLowerCase().split("?")[0];return{...n(r)?{url:r}:{path:r},name:s,rel:d.includes("/")?d:o,is_cover:null!=(t=a.is_cover)?t:"cover.png"===o||d.endsWith("/cover.png"),is_page:null!=(l=a.is_page)?l:d.includes("/pages/")||/^page_\d+/i.test(o),is_composed_panel:o.includes("_composed."),is_raw_panel:o.startsWith("panel_")&&!o.includes("_composed.")&&d.includes("/panels/"),is_portrait:d.includes("character_portraits")||o.includes("portrait")}}function s(e){return(e||[]).some(e=>n(null==e?void 0:e.url))}function o(e){if(!e||"object"!=typeof e)return[];let t=new Map,l=e=>{if(!e)return;let l=i(e.url||e.path||e.name).toLowerCase();if(!l)return;let a=t.get(l);if(!a)return void t.set(l,e);let r=n(a.url);if(n(e.url)&&!r)return void t.set(l,{...a,...e,is_cover:a.is_cover||e.is_cover,is_page:a.is_page||e.is_page});a.is_cover=a.is_cover||e.is_cover,a.is_page=a.is_page||e.is_page};if("string"==typeof e.cover_url&&a.test(e.cover_url)&&l(r(e.cover_url,{is_cover:!0})),Array.isArray(e.page_urls))for(let t of e.page_urls)"string"==typeof t&&a.test(t)&&l(r(t,{is_page:!0}));if(Array.isArray(e.pages))for(let t of e.pages)(null==t?void 0:t.url)&&a.test(t.url)&&l(r(t.url,{is_page:!0}));if(Array.isArray(e.image_urls))for(let t of e.image_urls)"string"==typeof t&&a.test(t)&&l(r(t));
1for(let t of[e.public_url,e.s3_url])"string"==typeof t&&a.test(t)&&l(r(t));if(e.cover_path&&l(r(e.cover_path,{is_cover:!0})),Array.isArray(e.pages))for(let t of e.pages)(null==t?void 0:t.path)&&l(r(t.path,{is_page:!0}));let s=[...t.values()],o=e=>(null==e?void 0:e.is_cover)?0:(null==e?void 0:e.is_page)?1:2;return s.sort((e,t)=>{let l=o(e)-o(t);return 0!==l?l:String((null==e?void 0:e.name)||"").localeCompare(String((null==t?void 0:t.name)||""))}),s}function d(e){let t=(e||[]).filter(Boolean);if(!t.length)return[];let l=t.find(e=>e.is_cover)||t[0],a=t.filter(e=>e!==l&&e.is_page).sort((e,t)=>String((null==e?void 0:e.name)||"").localeCompare(String((null==t?void 0:t.name)||""))),i=t.filter(e=>e!==l&&!e.is_page&&!e.is_cover);return a.length?[l,...a]:[l,...i]}function c(e){return String(e||"comic").replace(/[^\w\s-]+/g,"").trim().replace(/\s+/g,"_").slice(0,60)||"comic"}function u(e,t,l){if(!e||"object"!=typeof e)return null;let a=String(e.pipeline||t||"").toLowerCase();if("comic"!==String(a||"").toLowerCase())return null;let i=e.result&&"object"==typeof e.result?e.result:{},n=o(i);if(!n.length)return null;let r=i.title||e.title||e.message||l||"";return{overview:{run_meta:{pipeline:a,status:e.status||"completed",title:r,task_id:l||e.id},checkpoint:{current_phase:"complete"}},pipeline_type:a,pipeline_output:{...i,pipeline:a},scripts:{},media:{videos:[],images:n,audio:[]},ideation:null,council_audits:[],monetization:null,run_path:e.output_path||i.working_dir||"",result:i}}},83292:(e,t,l)=>{"use strict";l.d(t,{A:()=>h});var a=l(88392),i=l(47940),n=l(68145);function r(e){return new TextEncoder().encode(e)}function s(e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),l=0;for(let a of e)t.set(a,l),l+=a.length;return t}function o(e){return new Uint8Array([255&e,e>>>8&255])}function d(e){return new Uint8Array([255&e,e>>>8&255,e>>>16&255,e>>>24&255])}let c=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let l=t;for(let e=0;e<8;e+=1)l=1&l?0xedb88320^l>>>1:l>>>1;e[t]=l>>>0}return e})();function u(e){return"".concat((0,n.vi)(e),"_pages.zip")}async function p(e){let t=function(e){let t=String(e||"").trim();return t?t.startsWith("/")&&!t.startsWith("//")?t:/^https?:\/\//i.test(t)?"/media-proxy/comic-image?url=".concat(encodeURIComponent(t)):"":""}(e);if(!t)throw Error("Missing comic image link");let l=await fetch(t);if(!l.ok)throw Error("Could not load a comic page (".concat(l.status,")"));let a=new Uint8Array(await l.arrayBuffer());if(a.length<32)throw Error("A comic page came back empty");return a}function m(e){let t=String((null==e?void 0:e.url)||"").trim();return/^https?:\/\//i.test(t)||t.startsWith("/")&&!t.startsWith("//")?t:""}async function v(){let{images:e,title:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},l=(0,n.Ks)(e).filter(e=>m(e));if(!l.length)throw Error("No cover or pages to download yet");let a=[];for(let e=0;e<l.length;e+=1){let t=l[e];a.push({name:function(e,t){let l=String((null==e?void 0:e.name)||"").split("?")[0].split(/[/\\]/).pop()||"",a=l.match(/\.(png|jpe?g|webp)$/i),i=a?a[0].toLowerCase():".png",n=String(t).padStart(2,"0");
1return(null==e?void 0:e.is_cover)?"".concat(n,"_cover").concat(i):a?"".concat(n,"_").concat(l):"".concat(n,"_page").concat(i)}(t,e),bytes:await p(m(t))})}let i=new Blob([function(e){let t=(e||[]).filter(e=>e&&e.name&&e.bytes&&e.bytes.length);if(!t.length)throw Error("No PNG files to zip");let l=[],a=[],i=0;for(let e of t){let t=r(String(e.name).replace(/\\/g,"/")),n=e.bytes instanceof Uint8Array?e.bytes:new Uint8Array(e.bytes),u=function(e){let t=0xffffffff,l=e instanceof Uint8Array?e:new Uint8Array(e);for(let e=0;e<l.length;e+=1)t=c[(t^l[e])&255]^t>>>8;return(0xffffffff^t)>>>0}(n),p=s([r("PK\x03\x04"),o(20),o(0),o(0),o(0),o(0),d(u),d(n.length),d(n.length),o(t.length),o(0),t,n]);l.push(p),a.push(s([r("PK\x01\x02"),o(20),o(20),o(0),o(0),o(0),o(0),d(u),d(n.length),d(n.length),o(t.length),o(0),o(0),o(0),o(0),d(0),d(i),t])),i+=p.length}let n=s(a),u=s([r("PK\x05\x06"),o(0),o(0),o(t.length),o(t.length),d(n.length),d(i),o(0)]);return s([...l,n,u])}(a)],{type:"application/zip"}),v=URL.createObjectURL(i),h=document.createElement("a");return h.href=v,h.download=u(t),h.rel="noopener",document.body.appendChild(h),h.click(),h.remove(),URL.revokeObjectURL(v),{files:a.length,filename:u(t)}}function h(e){let{images:t,title:l,className:n}=e,[r,s]=(0,i.useState)(!1),[o,d]=(0,i.useState)("");return(t||[]).some(e=>String((null==e?void 0:e.url)||"").trim())?(0,a.jsxs)("span",{className:"inline-flex flex-col items-start gap-1",children:[(0,a.jsx)("button",{type:"button",className:n,disabled:r,onClick:()=>{d(""),s(!0),v({images:t,title:l}).catch(e=>{d(e instanceof Error?e.message:"Could not download the PNGs.")}).finally(()=>s(!1))},children:r?"Saving PNGsâ¦":"Download PNGs"}),o?(0,a.jsx)("span",{className:"text-xs text-red-600 max-w-[16rem] text-left",role:"alert",children:o}):null]}):null}},90093:(e,t,l)=>{"use strict";l.r(t),l.d(t,{default:()=>ee});var a=l(88392),i=l(80244),n=l.n(i),r=l(66436);let{Axios:s,AxiosError:o,CanceledError:d,isCancel:c,CancelToken:u,VERSION:p,all:m,Cancel:v,isAxiosError:h,spread:g,toFormData:x,AxiosHeaders:f,HttpStatusCode:b,formToJSON:_,getAdapter:y,mergeConfig:w}=r.A;var j=l(68145),N=l(47940),k=l(5081),S=l(58907),C=l(75422),A=l(83292);function P(e){return null==e||!Number.isFinite(e)||e<0?"Size checked when reviewed":e<1024?"".concat(e," B"):e<1048576?"".concat((e/1024).toFixed(1)," KB"):"".concat((e/1048576).toFixed(1)," MB")}function L(e){let t=(e.identifier||e.providerIdentifier||e.provider||"").trim().toLowerCase();return({twitter:"x","instagram-standalone":"instagram","linkedin-page":"linkedin","facebook-page":"facebook"})[t]||t}function I(e){var t,l;let a=null==e||null==(l=e.response)||null==(t=l.data)?void 0:t.detail;if("string"==typeof a)return a;if(a&&"object"==typeof a&&"message"in a&&"string"==typeof a.message){let e="accepted_posts"in a||"reconciliation_required"in a;return a.message+(e?" Check the connected accounts and existing submission IDs before retrying.":"")}return"Publishing could not complete. Review the task and account connection before trying again."}let V=new Set(["youtube","tiktok","x","instagram","linkedin","facebook","pinterest"]);function M(e){var t;let{taskId:l}=e,i=(0,N.useRef)(0),[n,r]=(0,N.useState)([]),[s,o]=(0,N.useState)([]),[d,c]=(0,N.useState)(""),[u,p]=(0,N.useState)([]),[m,v]=(0,N.useState)([]),[h,g]=(0,N.useState)(""),[x,f]=(0,N.useState)(""),[b,_]=(0,N.useState)("public"),[y,w]=(0,N.useState)(""),[j,k]=(0,N.useState)(""),[C,A]=(0,N.useState)(null),[M,D]=(0,N.useState)(!1),[T,R]=(0,N.useState)(""),[E,z]=(0,N.useState)(""),[F,B]=(0,N.useState)(""),[O,W]=(0,N.useState)("");async function U(){if(!l||M)return;let e=++i.current;D(!0),R("refresh"),B(""),A(null),W("");try{var t,a;let[n,s]=await Promise.allSettled([S.Ay.post("/automation/publish-handoff",{task_id:l,selected_references:[],target_accounts:[]}),S.ij.postizIntegrations()]);if(e!==i.current)return;let d=[];if("fulfilled"===n.status){let e=n.value.data;r(e.artifacts||[]),c((null==(t=e.delivery)?void 0:t.instruction)||""),p(t=>t.filter(t=>{var l;return null==(l=e.artifacts)?void 0:l.some(e=>e.reference===t)}))}else d.push("Run files: "+I(n.reason));if("fulfilled"===s.status){let e=((null==(a=s.value.data)?void 0:a.integrations)||[]).filter(e=>V.has(L(e)));o(e),v(t=>t.filter(t=>e.some(e=>e.id===t)))}else d.push("Connected accounts: "+I(s.reason));B(d.join(" "))}catch(t){e===i.current&&B(I(t))}finally{e===i.current&&D(!1)}}async function G(){let e=++i.current;D(!0),R("preview"),B(""),A(null);try{let t={task_id:l,selected_references:u,target_accounts:s.filter(e=>m.includes(e.id)).map(e=>({platform:L(e),integration_id:e.id,enabled:!0})),title:x,visibility:b,caption:h,canonical_url:y.trim(),schedule_at:j?new Date(j).toISOString():null},a=await S.Ay.post("/automation/publish-handoff",t);e===i.current&&A({body:t,result:a.data})}catch(t){e===i.current&&B(I(t))}finally{e===i.current&&D(!1)}}async function H(e){var t,a;if(!C||C.body.task_id!==l||M||(e?!(null==(t=C.result.release_review)?void 0:t.can_approve):!(null==(a=C.result.release_review)?void 0:a.can_prepare)))return;let n=++i.current;D(!0),R(e?"review":"prepare"),B("");try{let t={...C.body,review_fingerprint:C.result.review_fingerprint,...e?{action:e,reason:E.trim()}:{}},l=await S.Ay.post("/automation/publish-handoff/".concat(e?"review":"prepare-review"),t);n===i.current&&A({body:C.body,result:l.data})}catch(e){n===i.current&&B(I(e))}finally{n===i.current&&D(!1)}}async function q(){if(!(null==C?void 0:C.result.ready)||C.body.task_id!==l||M)return;let e=++i.current;D(!0),R("publish"),B("");try{var t;let l=await S.Ay.post("/automation/publish-handoff/execute",{...C.body,review_fingerprint:C.result.review_fingerprint});if(e!==i.current)return;let a=(t=l.data).reconciliation_required?{error:"A publishing request may already have been accepted. Check the connected account and existing submission IDs before retrying."}:t.ok?{receipt:"scheduled"===t.state?"Posts scheduled. Their final publishing status will be confirmed by the connected accounts.":"Posts submitted to Postiz. This does not yet confirm they are live."}:{error:"Some posts were not accepted. Review their publishing status before retrying."};if(a.error)return void B(a.error);W(a.receipt||""),A(null)}catch(t){e===i.current&&B(I(t))}finally{e===i.current&&D(!1)}}return(0,N.useEffect)(()=>{let e=!1;return(i.current+=1,D(!0),R("load"),z(""),o([]),g(""),f(""),_("public"),w(""),k(""),A(null),r([]),v([]),p([]),W(""),B(""),l)?(Promise.allSettled([S.Ay.post("/automation/publish-handoff",{task_id:l,selected_references:[],target_accounts:[]}),S.ij.postizIntegrations()]).then(t=>{var l,a;let[i,n]=t;if(e)return;let s=[];if("fulfilled"===i.status){let e=i.value.data;r(e.artifacts||[]),c((null==(l=e.delivery)?void 0:l.instruction)||""),f(e.title||"")}else s.push("Run files: "+I(i.reason));"fulfilled"===n.status?o(((null==(a=n.value.data)?void 0:a.integrations)||[]).filter(e=>V.has(L(e)))):s.push("Connected accounts: "+I(n.reason)),B(s.join(" "))}).catch(t=>{e||B(I(t))}).finally(()=>{e||D(!1)}),()=>{e=!0}):void D(!1)},[l]),(0,N.useEffect)(()=>{i.current+=1,A(null),W(""),z("")},[u,m,h,x,b,y,j]),(0,a.jsxs)("section",{className:"space-y-4 border-t border-gray-200 pt-5","aria-label":"Social publishing handoff",children:[(0,a.jsx)("h3",{className:"font-semibold",children:"Share this content on social"}),(0,a.jsx)("p",{className:"text-sm text-gray-600",children:d||"Choose a finished preview or link, then review the exact posts before publishing."}),(0,a.jsx)("button",{type:"button",disabled:!l||M,onClick:U,className:"rounded-lg border border-gray-300 px-3 py-2 text-sm disabled:opacity-50",children:M&&"refresh"===T?"Refreshingâ¦":"Refresh files and accounts"}),M&&"load"===T&&(0,a.jsx)("p",{role:"status",className:"text-sm text-gray-600",children:"Loading run files and connected accountsâ¦"}),(0,a.jsxs)("fieldset",{disabled:M,className:"space-y-3",children:[(0,a.jsx)("legend",{className:"text-sm font-medium",children:"Delivery files (one video or up to four images)"}),(0,a.jsx)("p",{className:"text-xs text-gray-600",children:"Select the intended final version. Final labels reflect the run or your edit choices; release checks still apply."}),!n.length&&(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"No supported preview files found. You can use a public landing-page link for a text post."}),n.map(e=>(0,a.jsxs)("label",{className:"flex items-start gap-3 rounded-lg border p-3 text-sm ".concat(u.includes(e.reference)?"border-indigo-400 bg-indigo-50":"border-gray-200"),children:[(0,a.jsx)("input",{type:"checkbox",checked:u.includes(e.reference),disabled:"native"===e.kind||!u.includes(e.reference)&&(u.length>=4||"video"===e.kind&&u.length>0||u.some(e=>{var t;return(null==(t=n.find(t=>t.reference===e))?void 0:t.kind)==="video"})),onChange:t=>p(l=>t.target.checked?[...l,e.reference]:l.filter(t=>t!==e.reference))}),(0,a.jsxs)("span",{className:"min-w-0",children:[(0,a.jsx)("span",{className:"block break-all font-medium",children:e.relative_path||e.name}),(0,a.jsxs)("span",{className:"block text-xs text-gray-600",children:[e.kind.toUpperCase()," \xb7 ",P(e.size_bytes)]}),(0,a.jsx)("span",{className:"block text-xs ".concat(e.recommended?"text-indigo-700":"text-gray-600"),children:"human_final"===e.role?"Human edit".concat(e.revision?" \xb7 revision ".concat(e.revision):""," \xb7 marked publish-ready"):"final_override"===e.role?"Active final override".concat(e.replaces?" for ".concat(e.replaces):""):"human_revision"===e.role?"Human edit".concat(e.revision?" \xb7 revision ".concat(e.revision):""," \xb7 not marked publish-ready"):"pipeline_final"===e.role?"Pipeline final output":"native"===e.kind?"Native export":"Run output \xb7 final version unconfirmed"}),"native"===e.kind&&(0,a.jsx)("span",{className:"block text-xs text-gray-600",children:"Download from the artifact library; use a social preview or link here."})]})]},e.reference)),u.length>1&&(0,a.jsxs)("div",{className:"space-y-2 rounded-lg bg-gray-50 p-3",children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Post order \xb7 first image is the cover"}),u.map((e,t)=>{var l,i;return(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,a.jsxs)("span",{className:"min-w-0 flex-1 break-all",children:[t+1,". ",(null==(l=n.find(t=>t.reference===e))?void 0:l.relative_path)||(null==(i=n.find(t=>t.reference===e))?void 0:i.name)||e]}),(0,a.jsx)("button",{type:"button",disabled:0===t,"aria-label":"Move image ".concat(t+1," earlier"),className:"rounded border px-2 py-1 disabled:opacity-40",onClick:()=>p(e=>{let l=[...e];return[l[t-1],l[t]]=[l[t],l[t-1]],l}),children:"Earlier"}),(0,a.jsx)("button",{type:"button",disabled:t===u.length-1,"aria-label":"Move image ".concat(t+1," later"),className:"rounded border px-2 py-1 disabled:opacity-40",onClick:()=>p(e=>{let l=[...e];return[l[t],l[t+1]]=[l[t+1],l[t]],l}),children:"Later"})]},e)})]}),(0,a.jsxs)("label",{className:"block text-sm",children:["Post title",(0,a.jsx)("input",{type:"text",value:x,onChange:e=>f(e.target.value),className:"mt-1 w-full border rounded-lg p-2"}),(0,a.jsxs)("span",{className:"text-xs text-gray-600",children:[x.length," characters \xb7 YouTube accepts 2â100. Titles are checked before submission."]})]}),(0,a.jsxs)("label",{className:"block text-sm",children:["Public landing-page link",(0,a.jsx)("input",{type:"url",value:y,onChange:e=>w(e.target.value),placeholder:"https://â¦",className:"mt-1 w-full border rounded-lg p-2"})]}),(0,a.jsxs)("label",{className:"block text-sm",children:["Caption",(0,a.jsx)("textarea",{rows:3,value:h,onChange:e=>g(e.target.value),className:"mt-1 w-full border rounded-lg p-2"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Connected accounts"}),!s.length&&(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Connect a supported account in the release calendar first."}),s.map(e=>(0,a.jsxs)("label",{className:"flex gap-2 text-sm",children:[(0,a.jsx)("input",{type:"checkbox",checked:m.includes(e.id),disabled:e.disabled||e.refreshNeeded,onChange:t=>v(l=>t.target.checked?[...l,e.id]:l.filter(t=>t!==e.id))}),e.name||L(e)," \xb7 ",L(e),e.disabled||e.refreshNeeded?" \xb7 Reconnect required":""]},e.id))]}),(0,a.jsxs)("label",{className:"block text-sm",children:["YouTube visibility",(0,a.jsxs)("select",{value:b,onChange:e=>_(e.target.value),className:"mt-1 block rounded-lg border p-2",children:[(0,a.jsx)("option",{value:"public",children:"Public"}),(0,a.jsx)("option",{value:"unlisted",children:"Unlisted \xb7 anyone with the link"}),(0,a.jsx)("option",{value:"private",children:"Private \xb7 only invited viewers"})]}),(0,a.jsx)("span",{className:"text-xs text-gray-600",children:"Choose only YouTube accounts for private or unlisted delivery. Other
1connected platforms require Public."})]}),(0,a.jsxs)("label",{className:"block text-sm",children:["Schedule (your local time; optional)",(0,a.jsx)("input",{type:"datetime-local",value:j,onChange:e=>k(e.target.value),className:"mt-1 block border rounded-lg p-2"})]}),(0,a.jsx)("button",{type:"button",disabled:!l||!m.length,onClick:G,className:"rounded-lg bg-indigo-600 text-white px-4 py-2 disabled:opacity-50",children:"Review posts"})]}),F&&(0,a.jsx)("p",{role:"alert",className:"text-sm text-red-700",children:F}),C&&C.body.task_id===l&&(0,a.jsxs)("div",{className:"space-y-3 rounded-xl bg-gray-50 p-4",children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:C.result.title||"Social post"}),(0,a.jsxs)("p",{className:"text-sm capitalize",children:["Visibility: ",C.body.visibility," \xb7 ",C.body.schedule_at?"Scheduled for ".concat(new Date(C.body.schedule_at).toLocaleString()):"Publish now"]}),(0,a.jsxs)("div",{className:"text-sm",children:[(0,a.jsx)("p",{className:"font-medium",children:"Files in post order"}),C.body.selected_references.length?(0,a.jsx)("ol",{className:"list-inside list-decimal",children:C.body.selected_references.map(e=>{var t;let l=(null==(t=C.result.artifacts)?void 0:t.find(t=>t.reference===e))||n.find(t=>t.reference===e);return(0,a.jsxs)("li",{className:"break-all",children:[(null==l?void 0:l.relative_path)||(null==l?void 0:l.name)||e," \xb7 ",P(null==l?void 0:l.size_bytes)]},e)})}):(0,a.jsx)("p",{children:"Text/link only"})]}),C.body.canonical_url&&(0,a.jsxs)("p",{className:"text-sm break-all",children:["Link: ",C.body.canonical_url]}),C.result.posts.map(e=>{var t,l,i;return(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"font-medium text-sm",children:[(null==(l=C.result.account_snapshot)||null==(t=l.find(t=>t.integration_id===e.integration_id))?void 0:t.name)||(null==(i=s.find(t=>t.id===e.integration_id))?void 0:i.name)||e.platform," \xb7 ",e.platform]}),e.title&&(0,a.jsxs)("p",{className:"text-sm",children:["Title: ",e.title]}),(0,a.jsx)("p",{className:"whitespace-pre-wrap text-sm",children:e.content}),null!=e.character_limit&&(0,a.jsxs)("p",{className:"text-xs text-gray-500",children:[e.character_count,"/",e.character_limit," caption characters"]})]},e.integration_id)}),null==(t=C.result.warnings)?void 0:t.map((e,t)=>(0,a.jsx)("p",{className:"text-sm text-amber-800",children:e},t)),C.result.blockers.map((e,t)=>(0,a.jsx)("p",{className:"text-sm text-amber-800",children:e},t)),C.result.release_review&&(0,a.jsxs)("div",{className:"space-y-2 border-t border-gray-200 pt-3","aria-live":"polite",children:[(0,a.jsxs)("p",{className:"text-sm font-medium",children:["Release review: ",C.result.release_review.state.replaceAll("_"," ").toLowerCase()]}),C.result.release_review.reason&&(0,a.jsx)("p",{className:"text-sm text-gray-600",children:C.result.release_review.reason}),C.result.release_review.last_decision&&(0,a.jsxs)("div",{className:"rounded-lg border border-gray-200 p-2 text-sm",children:[(0,a.jsxs)("p",{children:["Last human decision: ","reject"===C.result.release_review.last_decision.decision?"Changes requested":"Approved"]}),C.result.release_review.last_decision.reason&&(0,a.jsx)("p",{className:"whitespace-pre-wrap",children:C.result.release_review.last_decision.reason}),"reject"===C.result.release_review.last_decision.decision&&(0,a.jsx)("p",{className:"text-gray-600",children:"Update the file selection or post wording, then review the revised posts."})]}),C.result.release_review.can_prepare&&(0,a.jsx)("button",{type:"button",disabled:M,onClick:()=>H(),className:"rounded-lg border border-indigo-300 text-indigo-700 px-4 py-2 disabled:opacity-50",children:M&&"prepare"===T?"Running release checksâ¦":"Run release checks"}),C.result.release_review.can_approve&&(0,a.jsxs)("fieldset",{disabled:M,className:"space-y-2",children:[(0,a.jsxs)("label",{className:"block text-sm",children:["Review notes (optional)",(0,a.jsx)("textarea",{rows:2,value:E,onChange:e=>z(e.target.value),className:"mt-1 w-full border rounded-lg p-2"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)("button",{type:"button",onClick:()=>H("approve"),className:"rounded-lg border border-emerald-400 text-emerald-800 px-3 py-2",children:"Approve reviewed posts"}),(0,a.jsx)("button",{type:"button",onClick:()=>H("reject"),className:"rounded-lg border border-red-300 text-red-700 px-3 py-2",children:"Reject"})]})]}),"AWAITING_HUMAN"===C.result.release_review.state&&!C.result.release_review.can_approve&&(0,a.jsx)("p",{className:"text-sm text-amber-800",children:"An authorized release reviewer needs to approve these posts."})]}),(0,a.jsx)("button",{type:"button",disabled:!C.result.ready||M,onClick:q,className:"rounded-lg bg-emerald-700 text-white px-4 py-2 disabled:opacity-50",children:M?"publish"===T?"Submittingâ¦":"Workingâ¦":C.body.schedule_at?"Schedule reviewed posts":"Publish reviewed posts"})]}),O&&(0,a.jsx)("p",{role:"status",className:"text-sm text-emerald-800",children:O})]})}var D=l(58704),T=l(53589),R=l(26499);let E=r.A.create({baseURL:"https://studio.content-x.ai/api",headers:{"Content-Type":"application/json"},timeout:3e5});E.interceptors.request.use(e=>{var t,l;let a=null!=(l=null==(t=window.localStorage)?void 0:t.getItem("auth_token"))?l:null;return a&&(e.headers.Authorization="Bearer ".concat(a)),e});let z={listCollections:()=>E.get("/video-agents/collections"),upload:e=>E.post("/video-agents/upload",e),importRun:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";return E.post("/video-agents/import-run",{run_path:e,collection_id:t})},transcribe:e=>E.post("/video-agents/transcribe",e),search:e=>E.post("/video-agents/search",e),subtitle:e=>E.post("/video-agents/subtitle",e),translate:e=>E.post("/video-agents/translate",e),dub:e=>E.post("/video-agents/dub",e),clip:e=>E.post("/video-agents/clip",e),extractFrame:e=>E.post("/video-agents/extract-frame",e),summarize:e=>E.post("/video-agents/summarize",e)};var F=l(13794),B=l.n(F);let O=[{value:"spanish",label:"Spanish"},{value:"french",label:"French"},{value:"german",label:"German"},{value:"japanese",label:"Japanese"},{value:"hindi",label:"Hindi"},{value:"portuguese",label:"Portuguese"},{value:"italian",label:"Italian"},{value:"korean",label:"Korean"},{value:"chinese",label:"Chinese"},{value:"arabic",label:"Arabic"}];function W(e){if(!e)return null;let t=e.stream_url||e.url||e.stream_link;return"string"==typeof t?t:null}function U(e){if(!e)return"";let t=e.text||e.transcript||e.translated_transcript||e.summary||e.translation||"";return"string"==typeof t?t:""}function G(e){let{videoUrl:t="",videoPath:l="",runPath:i="",collectionId:n="default"}=e,[r,s]=(0,N.useState)(!0),[o,d]=(0,N.useState)(null),[c,u]=(0,N.useState)(!1),[p,m]=(0,N.useState)(""),[v,h]=(0,N.useState)(null),[g,x]=(0,N.useState)(null),[f,b]=(0,N.useState)(""),[_,y]=(0,N.useState)({}),[w,j]=(0,N.useState)(""),[k,C]=(0,N.useState)(0),[A,P]=(0,N.useState)(10),[L,I]=(0,N.useState)("spanish"),[V,M]=(0,N.useState)("spanish"),[D,T]=(0,N.useState)(0),[R,E]=(0,N.useState)(!1),F=!!(t||l),G=!!v,H=(0,N.useCallback)(async()=>{try{await z.listCollections(),d(!0)}catch(l){var e;let t=503!==(null==l||null==(e=l.response)?void 0:e.status);d(t),t||b("VideoDB is not configured. Set VIDEODB_API_KEY to enable video intelligence.")}},[]);async function q(){if(F){u(!0),m("Uploading video to VideoDB..."),b("");try{let e={collection_id:n};t?e.url=t:l&&(e.file_path=l);let{data:a}=await z.upload(e);h(a.id),m("")}catch(e){b((0,S.PE)(e)),m("")}finally{u(!1)}}}async function K(){if(i){u(!0),m("Importing full run directory..."),b("");try{var e;let{data:t}=await z.importRun(i,n);(null==(e=t.files)?void 0:e.length)&&h(t.files[0].id),m("Imported ".concat(t.imported||0," video(s)")),setTimeout(()=>m(""),3e3)}catch(e){b((0,S.PE)(e)),m("")}finally{u(!1)}}}function J(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{video_id:v,collection_id:n,...e}}async function $(e,t){x(e),b("");try{let{data:l}=await t();y(t=>({...t,[e]:l}))}catch(t){b("".concat(e,": ").concat((0,S.PE)(t)))}finally{x(null)}}(0,N.useEffect)(()=>{r||null!==o||H()}
1,[r,o,H]);let Y=(0,N.useMemo)(()=>{var e;let t=null==(e=_.search)?void 0:e.results;return Array.isArray(t)?t:[]},[_.search]);return(0,a.jsxs)("div",{className:B()["va-panel"],children:[(0,a.jsxs)("button",{type:"button",className:B()["va-header"],onClick:()=>s(e=>!e),children:[(0,a.jsxs)("div",{className:B()["va-header-left"],children:[(0,a.jsx)("svg",{className:B()["va-icon"],viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}),(0,a.jsx)("span",{className:B()["va-title"],children:"Video Intelligence"}),!1===o&&(0,a.jsx)("span",{className:"".concat(B()["va-badge"]," ").concat(B()["va-badge-warn"]),children:"Offline"}),!1!==o&&G&&(0,a.jsx)("span",{className:"".concat(B()["va-badge"]," ").concat(B()["va-badge-ok"]),children:"Connected"})]}),(0,a.jsx)("svg",{className:"".concat(B()["va-chevron"]).concat(r?"":" ".concat(B()["va-chevron-open"])),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),!r&&(0,a.jsxs)("div",{className:B()["va-body"],children:[!1===o&&(0,a.jsxs)("div",{className:"".concat(B()["va-notice"]," ").concat(B()["va-notice-warn"]),children:[(0,a.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:B()["va-notice-icon"],children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01M12 3l9.66 16.59A1 1 0 0120.82 21H3.18a1 1 0 01-.84-1.41L12 3z"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:B()["va-notice-title"],children:"VideoDB Not Configured"}),(0,a.jsxs)("p",{className:B()["va-notice-text"],children:["Set ",(0,a.jsx)("code",{children:"VIDEODB_API_KEY"})," in your environment to enable video intelligence features."]})]})]}),null===o&&(0,a.jsxs)("div",{className:B()["va-loading"],children:[(0,a.jsx)("div",{className:B()["va-spinner"]}),(0,a.jsx)("span",{children:"Checking VideoDB connection..."})]}),!0===o&&(0,a.jsxs)(a.Fragment,{children:[f&&(0,a.jsxs)("div",{className:"".concat(B()["va-notice"]," ").concat(B()["va-notice-error"]),children:[(0,a.jsx)("span",{children:f}),(0,a.jsx)("button",{type:"button",className:B()["va-dismiss"],onClick:()=>b(""),children:"\xd7"})]}),!G&&(0,a.jsxs)("div",{className:B()["va-section"],children:[(0,a.jsx)("p",{className:B()["va-section-label"],children:"Import Video"}),(0,a.jsxs)("div",{className:B()["va-import-actions"],children:[F&&(0,a.jsxs)("button",{type:"button",className:"".concat(B()["va-btn"]," ").concat(B()["va-btn-primary"]),disabled:c,onClick:()=>void q(),children:[(0,a.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:B()["va-btn-icon"],children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v2a2 2 0 002 2h12a2 2 0 002-2v-2M7 10l5 5 5-5M12 15V3"})}),"Import to VideoDB"]}),i&&(0,a.jsxs)("button",{type:"button",className:"".concat(B()["va-btn"]," ").concat(B()["va-btn-secondary"]),disabled:c,onClick:()=>void K(),children:[(0,a.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:B()["va-btn-icon"],children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),"Import Full Run"]})]}),c&&(0,a.jsxs)("div",{className:B()["va-progress"],children:[(0,a.jsx)("div",{className:B()["va-spinner"]}),(0,a.jsx)("span",{children:p})]}),!F&&!i&&(0,a.jsx)("p",{className:B()["va-hint"],children:"No video URL or path provided."})]}),G&&(0,a.jsxs)("div",{className:B()["va-agents"],children:[(0,a.jsx)("p",{className:B()["va-section-label"],children:"Agent Actions"}),(0,a.jsxs)("div",{className:B()["va-agent-grid"],children:[(0,a.jsxs)("div",{className:B()["va-card"],children:[(0,a.jsxs)("div",{className:B()["va-card-head"],children:[(0,a.jsx)("span",{className:B()["va-card-icon"],children:"\uD83D\uDCDD"}),(0,a.jsx)("span",{className:B()["va-card-title"],children:"Transcribe"})]}),(0,a.jsx)("button",{type:"button",className:"".concat(B()["va-btn"]," ").concat(B()["va-btn-sm"]),disabled:"transcribe"===g,onClick:()=>void $("transcribe",()=>z.transcribe(J())),children:"transcribe"===g?(0,a.jsx)("div",{className:B()["va-spinner-sm"]}):"Get Transcript"}),_.transcribe&&(0,a.jsxs)("div",{className:B()["va-result"],children:[(0,a.jsxs)("button",{type:"button",className:B()["va-collapse-toggle"],onClick:()=>E(e=>!e),children:[R?"Collapse":"Expand"," transcript"]}),R&&(0,a.jsx)("pre",{className:B()["va-result-text"],children:U(_.transcribe)})]})]}),(0,a.jsxs)("div",{className:B()["va-card"],children:[(0,a.jsxs)("div",{className:B()["va-card-head"],children:[(0,a.jsx)("span",{className:B()["va-card-icon"],children:"\uD83D\uDD0D"}),(0,a.jsx)("span",{className:B()["va-card-title"],children:"Search"})]}),(0,a.jsxs)("div",{className:B()["va-inline-form"],children:[(0,a.jsx)("input",{type:"text",placeholder:"Search in video...",className:B()["va-input"],value:w,onChange:e=>j(e.target.value)}),(0,a.jsx)("button",{type:"button",className:"".concat(B()["va-btn"]," ").concat(B()["va-btn-sm"]),disabled:"search"===g||!w.trim(),onClick:()=>void $("search",()=>
1z.search(J({query:w}))),children:"search"===g?(0,a.jsx)("div",{className:B()["va-spinner-sm"]}):"Go"})]}),_.search&&(0,a.jsx)("div",{className:B()["va-result"],children:Y.length>0?(0,a.jsx)("div",{className:B()["va-search-results"],children:Y.map((e,t)=>{var l,i,n,r,s,o;return(0,a.jsxs)("div",{className:B()["va-search-hit"],children:[(0,a.jsxs)("span",{className:B()["va-timestamp"],children:[null!=(s=null==(i=e.start)||null==(l=i.toFixed)?void 0:l.call(i,1))?s:e.start,"s - ",null!=(o=null==(r=e.end)||null==(n=r.toFixed)?void 0:n.call(r,1))?o:e.end,"s"]}),(0,a.jsx)("span",{className:B()["va-search-text"],children:e.text})]},t)})}):W(_.search)?(0,a.jsx)("p",{className:B()["va-result-link"],children:(0,a.jsx)("a",{href:W(_.search),target:"_blank",rel:"noopener",children:"View search results stream"})}):(0,a.jsx)("p",{className:B()["va-hint"],children:"No results found."})})]}),(0,a.jsxs)("div",{className:B()["va-card"],children:[(0,a.jsxs)("div",{className:B()["va-card-head"],children:[(0,a.jsx)("span",{className:B()["va-card-icon"],children:"\uD83C\uDFAC"}),(0,a.jsx)("span",{className:B()["va-card-title"],children:"Add Subtitles"})]}),(0,a.jsx)("button",{type:"button",className:"".concat(B()["va-btn"]," ").concat(B()["va-btn-sm"]),disabled:"subtitle"===g,onClick:()=>void $("subtitle",()=>z.subtitle(J())),children:"subtitle"===g?(0,a.jsx)("div",{className:B()["va-spinner-sm"]}):"Generate"}),_.subtitle&&W(_.subtitle)&&(0,a.jsx)("div",{className:B()["va-result"],children:(0,a.jsx)("video",{src:W(_.subtitle),controls:!0,className:B()["va-video-player"]})})]}),(0,a.jsxs)("div",{className:B()["va-card"],children:[(0,a.jsxs)("div",{className:B()["va-card-head"],children:[(0,a.jsx)("span",{className:B()["va-card-icon"],children:"â"}),(0,a.jsx)("span",{className:B()["va-card-title"],children:"Create Clip"})]}),(0,a.jsxs)("div",{className:"".concat(B()["va-inline-form"]," ").concat(B()["va-clip-form"]),children:[(0,a.jsxs)("label",{className:B()["va-field"],children:[(0,a.jsx)("span",{className:B()["va-field-label"],children:"Start (s)"}),(0,a.jsx)("input",{type:"number",min:0,step:.1,className:"".concat(B()["va-input"]," ").concat(B()["va-input-sm"]),value:k,onChange:e=>C(Number(e.target.value))})]}),(0,a.jsxs)("label",{className:B()["va-field"],children:[(0,a.jsx)("span",{className:B()["va-field-label"],children:"End (s)"}),(0,a.jsx)("input",{type:"number",min:0,step:.1,className:"".concat(B()["va-input"]," ").concat(B()["va-input-sm"]),value:A,onChange:e=>P(Number(e.target.value))})]}),(0,a.jsx)("button",{type:"button",className:"".concat(B()["va-btn"]," ").concat(B()["va-btn-sm"]),disabled:"clip"===g,onClick:()=>void $("clip",()=>z.clip(J({timeline:[[Number(k),Number(A)]]}))),children:"clip"===g?(0,a.jsx)("div",{className:B()["va-spinner-sm"]}):"Clip"})]}),_.clip&&W(_.clip)&&(0,a.jsx)("div",{className:B()["va-result"],children:(0,a.jsx)("video",{src:W(_.clip),controls:!0,className:B()["va-video-player"]})})]}),(0,a.jsxs)("div",{className:B()["va-card"],children:[(0,a.jsxs)("div",{className:B()["va-card-head"],children:[(0,a.jsx)("span",{className:B()["va-card-icon"],children:"\uD83C\uDFA4"}),(0,a.jsx)("span",{className:B()["va-card-title"],children:"Dub Video"})]}),(0,a.jsxs)("div",{className:B()["va-inline-form"],children:[(0,a.jsx)("select",{className:B()["va-select"],value:L,onChange:e=>I(e.target.value),children:O.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,a.jsx)("button",{type:"button",className:"".concat(B()["va-btn"]," ").concat(B()["va-btn-sm"]),disabled:"dub"===g,onClick:()=>void $("dub",()=>z.dub(J({language_code:L}))),children:"dub"===g?(0,a.jsx)("div",{className:B()["va-spinner-sm"]}):"Dub"})]}),_.dub&&W(_.dub)&&(0,a.jsx)("div",{className:B()["va-result"],children:(0,a.jsx)("video",{src:W(_.dub),controls:!0,className:B()["va-video-player"]})})]}),(0,a.jsxs)("div",{className:B()["va-card"],children:[(0,a.jsxs)("div",{className:B()["va-card-head"],children:[(0,a.jsx)("span",{className:B()["va-card-icon"],children:"\uD83C\uDF10"}),(0,a.jsx)("span",{className:B()["va-card-title"],children:"Translate"})]}),(0,a.jsxs)("div",{className:B()["va-inline-form"],children:[(0,a.jsx)("select",{className:B()["va-select"],value:V,onChange:e=>M(e.target.value),children:O.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,a.jsx)("button",{type:"button",className:"".concat(B()["va-btn"]," ").concat(B()["va-btn-sm"]),disabled:"translate"===g,onClick:()=>void $("translate",()=>z.translate(J({language:V}))),children:"translate"===g?(0,a.jsx)("div",{className:B()["va-spinner-sm"]}):"Translate"})]}),_.translate&&(0,a.jsx)("div",{className:B()["va-result"],children:(0,a.jsx)("pre",{className:B()["va-result-text"],children:U(_.translate)})})]}),(0,a.jsxs)("div",{className:B()["va-card"],children:[(0,a.jsxs)("div",{className:B()["va-card-head"],children:[(0,a.jsx)("span",{className:B()["va-card-icon"],children:"\uD83D\uDCF7"}),(0,a.jsx)("span",{className:B()["va-card-title"],children:"Extract Frame"})]}),(0,a.jsxs)("div",{className:B()["va-inline-form"],children:[(0,a.jsxs)("label",{className:"".concat(B()["va-field"]," ").concat(B()["va-field-grow"]),children:[(0,a.jsx)("span",{className:B()["va-field-label"],children:"Timestamp (s)"}),(0,a.jsx)("input",{type:"range",min:0,max:300,step:.5,className:B()["va-range"],value:D,onChange:e=>T(Number(e.target.value))}),(0,a.jsxs)("span",{className:B()["va-range-value"],children:[D,"s"]})]}),(0,a.jsx)("button",{type:"button",className:"".concat(B()["va-btn"]," ").concat(B()["va-btn-sm"]),disabled:"extractFrame"===g,onClick:()=>void $("extractFrame",()=>z.extractFrame(J({timestamp:Number(D)}
1))),children:"extractFrame"===g?(0,a.jsx)("div",{className:B()["va-spinner-sm"]}):"Extract"})]}),_.extractFrame&&(0,a.jsx)("div",{className:B()["va-result"],children:(_.extractFrame.image_url||_.extractFrame.url)&&(0,a.jsx)("img",{src:String(_.extractFrame.image_url||_.extractFrame.url),className:B()["va-frame-thumb"],alt:"Extracted frame"})})]}),(0,a.jsxs)("div",{className:B()["va-card"],children:[(0,a.jsxs)("div",{className:B()["va-card-head"],children:[(0,a.jsx)("span",{className:B()["va-card-icon"],children:"\uD83D\uDCC4"}),(0,a.jsx)("span",{className:B()["va-card-title"],children:"Summarize"})]}),(0,a.jsx)("button",{type:"button",className:"".concat(B()["va-btn"]," ").concat(B()["va-btn-sm"]),disabled:"summarize"===g,onClick:()=>void $("summarize",()=>z.summarize(J())),children:"summarize"===g?(0,a.jsx)("div",{className:B()["va-spinner-sm"]}):"Summarize"}),_.summarize&&(0,a.jsx)("div",{className:B()["va-result"],children:(0,a.jsx)("pre",{className:B()["va-result-text"],children:U(_.summarize)})})]})]})]})]})]})]})}var H=l(5099),q=l(68978);function K(e){var t;if(!e||"object"!=typeof e)return null;if(e.story)return e.story;if(e.script)return Array.isArray(e.script)?e.script.join("\n\n---\n\n"):"string"==typeof e.script?e.script:JSON.stringify(e.script,null,2);let l=e.scripts||{};if("string"==typeof l.article_markdown&&l.article_markdown.trim())return l.article_markdown;if("string"==typeof l.main&&l.main.trim())return l.main;if("string"==typeof l.story_text&&l.story_text.trim())return l.story_text;let a=null==(t=e.pipeline_output)?void 0:t.content;if(a&&"object"==typeof a){if("string"==typeof a.markdown&&a.markdown.trim())return a.markdown;if("string"==typeof a.html&&a.html.trim())return a.html}return"string"==typeof a&&a.trim()?a:null}function J(e){var t,l;let a=(null==e?void 0:e.scripts)||{};if("string"==typeof a.article_html&&a.article_html.trim())return a.article_html;let i=null==e||null==(l=e.pipeline_output)||null==(t=l.content)?void 0:t.html;return"string"==typeof i&&i.trim()?i:null}function $(e){if(!e||"object"!=typeof e)return{};let t=e.content,l=t&&"object"==typeof t&&"string"==typeof t.html&&t.html||"string"==typeof e.article_html&&e.article_html||"string"==typeof e.html&&e.html||"",a=t&&"object"==typeof t&&"string"==typeof t.markdown&&t.markdown||"string"==typeof e.article_markdown&&e.article_markdown||"string"==typeof e.markdown&&e.markdown||"";return"string"==typeof t&&t.trim()&&!l&&!a?{main:t}:l||a?{main:l||a,article_html:l||void 0,article_markdown:a||void 0}:{}}function Y(e){let t=String(e||"").toLowerCase();return"blog"===t||"translate_blog"===t}function Q(e,t){return!!Y(t||(null==e?void 0:e.pipeline_type))&&!!(J(e)||K(e))}var X=l(44809);let Z=new Set(["ad_banners","adbanners","banners","script2image","social_carousel","social_post","comic"]);function ee(){var e,t,l,i,r,s,o,d,c,u,p,m,v,g,x,f,b,_;arguments.length>0&&void 0!==arguments[0]&&arguments[0];let[y,w]=(0,N.useState)(!1);(0,k.usePathname)();let P=(0,k.useParams)(),L=(0,k.useSearchParams)();Object.fromEntries((null==L||null==(e=L.entries)?void 0:e.call(L))||[]);let I=(0,k.useRouter)(),V=(null==P?void 0:P.runId)||"",E=(null==P?void 0:P.type)||"video",[z,F]=(0,N.useState)(!0),[B,O]=(0,N.useState)(null),[W,U]=(0,N.useState)(null),[ee,et]=(0,N.useState)(null),[el,ea]=(0,N.useState)(!1),[ei,en]=(0,N.useState)(null),[er,es]=(0,N.useState)(""),[eo,ed]=(0,N.useState)("overview"),[ec,eu]=(0,N.useState)(""),[ep,em]=(0,N.useState)(null),[ev,eh]=(0,N.useState)(null),[eg,ex]=(0,N.useState)(null),[ef,eb]=(0,N.useState)(!1),[e_,ey]=(0,N.useState)(null),[ew,ej]=(0,N.useState)(null),[eN,ek]=(0,N.useState)(null),[eS,eC]=(0,N.useState)(!1),[eA,eP]=(0,N.useState)(!1),[eL,eI]=(0,N.useState)(null),[eV,eM]=(0,N.useState)([]),[eD,eT]=(0,N.useState)(!1),[eR,eE]=(0,N.useState)([]),[ez,eF]=(0,N.useState)(""),[eB,eO]=(0,N.useState)(""),[eW,eU]=(0,N.useState)(["youtube"]),[eG,eH]=(0,N.useState)(""),[eq,eK]=(0,N.useState)(!1),[eJ,e$]=(0,N.useState)(!1),[eY,eQ]=(0,N.useState)("later"),[eX,eZ]=(0,N.useState)(""),[e0,e1]=(0,N.useState)(""),[e2,e5]=(0,N.useState)(""),[e3,e4]=(0,N.useState)(12),[e8,e6]=(0,N.useState)(24),[e7,e9]=(0,N.useState)(20),[te,tt]=(0,N.useState)(20),[tl,ta]=(0,N.useState)(30),[ti,tn]=(0,N.useState)(50),[tr,ts]=(0,N.useState)(24),[to,td]=(0,N.useState)({}),[tc,tu]=(0,N.useState)([]),[tp,tm]=(0,N.useState)(!1),tv=(0,N.useRef)(null),th=(0,N.useRef)(W);th.current=W,(0,N.useCallback)(async()=>{var e,t;let l=null==(t=th.current)||null==(e=t.run)?void 0:e.orchestrator_job_ids,a=Array.isArray(l)?l:l?[l]:[];if(!a.length)return void tu([]);tu((await Promise.allSettled(a.map(async e=>{let{data:t}=await C.zZ.getJobStatus(e);return{id:e,...t||{}}}))).map((e,t)=>"fulfilled"===e.status?e.value:{id:a[t],status:"error",error:String(e.reason)}))},[]);let[tg,tx]=(0,N.useState)([]),[tf,tb]=(0,N.useState)(!1),[t_,ty]=(0,N.useState)(null),[tw,tj]=(0,N.useState)(null),[tN,tk]=(0,N.useState)(!1),[tS,tC]=(0,N.useState)(null),tA=(0,N.useRef)(null),tP=(0,N.useRef)(null),[tL,tI]=(0,N.useState)(!1),[tV,tM]=(0,N.useState)(null),[tD,tT]=(0,N.useState)(!1),[tR,tE]=(0,N.useState)(!1),[tz,tF]=(0,N.useState)(!1),[tB,tO]=(0,N.useState)(null),[tW,tU]=(0,N.useState)(!1),[tG,tH]=(0,N.useState)(!1),[tq,tK]=(0,N.useState)(null),[tJ,t$]=(0,N.useState)(!1),tY=(0,N.useRef)(null),[tQ,tX]=(0,N.useState)(!1);function tZ(){var e,t;return(null==W?void 0:W.run_path)||(null==W||null==(e=W.run)?void 0:e.output_dir)||(null==W||null==(t=W.run)?void 0:t.working_dir)||""}async function t0(){tI(!0),tT(!0),tM(null);try{let e=tZ();if(!e)throw Error("Run path not available");let{data:t}=await S.I8.getRunFileMap(e);tM(t)}catch(l){var e,t;tM({error:(null==l||null==(t=l.response)||null==(e=t.data)?void 0:e.detail)||l.message||"Failed to load file map"})}finally{tT(!1)}}async function t1(){if(tB){tH(!0),tK(null);try{let e=tZ();if(!e)throw Error("Run path not available");await S.I8.uploadHumanOverride(e,tB,tW),t$(!0);try{await S.I8.startSync({run_path:e})}catch(e){console.warn("S3 sync after override upload failed (non-fatal):",e)}let{data:t}=await S.I8.getRunArtifacts(e,S.Ay,{noCache:!0});U(t)}catch(l){var e,t;tK((null==l||null==(t=l.response)||null==(e=t.data)?void 0:e.detail)||l.message||"Upload failed")}finally{tH(!1)}}}async function t2(){var e,t,l,a;if(V){tb(!0),ty(null);try{let l=(null==W||null==(e=W.run)?void 0:e.output_dir)||(null==W||null==(t=W.run)?void 0:t.working_dir)||"";if(!l)return void tx([]);let{data:a}=await S.EN.listVersions(l,"auto");tx(Array.isArray(a)?a:(null==a?void 0:a.versions)||[])}catch(e){ty((null==e||null==(a=e.response)||null==(l=a.data)?void 0:l.detail)||e.message),tx([])}finally{tb(!1)}}}async function t5(e){var t,l,a,i;if(V&&!tw){tj(e.version||e.name);try{let a=(null==(t=W.run)?void 0:t.output_dir)||(null==(l=W.run)?void 0:l.working_dir)||"";
1await S.EN.restoreVersion(a,e.version||e.name,"auto"),await lz(),await t2()}catch(e){ty("Restore failed: ".concat((null==(i=e.response)||null==(a=i.data)?void 0:a.detail)||e.message))}finally{tj(null)}}}let t3={viral_shorts:"social",video_shorts:"social",movie:"video",short_movie:"video",shortmovie:"video",shortmovie_video:"video",short_movie_video:"video",short_video:"video",longs:"video",kidsmovie:"video",kids_movie:"video",documentary:"video",video:"video",script2video:"video",musicvideo:"audio",music_video:"audio",song:"audio",lyrics:"audio",song2musicvideo:"audio",podcast2video:"audio",podcast:"audio",podcast_series:"series",tv_series:"series",tvseries:"series",learning_series:"series",learningseries:"series",weekly_series:"series",short_movie_series:"series",series:"series",ad:"ads",adbanners:"ads",ad_banners:"ads",social_carousel:"ads",social_post:"ads",blog:"written",ebook:"written",book:"written",novel:"written",audiobook:"written",comic:"written",ad_jingle:"audio",character_2d:"assets",character_3d:"assets",
1interactive_avatar:"video",merch:"assets",interactive_story:"video",nl_editor:"video",long_form_video:"video"},t4=(0,N.useMemo)(()=>{let e=null==ee?void 0:ee.pipeline,t=null==W?void 0:W.pipeline_type;return t3[e||E||(t&&"unknown"!==t?t:null)||"video"]||"video"},[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]);(0,N.useMemo)(()=>(null==W?void 0:W.pipeline_output)||null,[P,W,ee]);let t8=(0,N.useMemo)(()=>{var e;let t=null==ee?void 0:ee.pipeline,l=null==W?void 0:W.pipeline_type;return e=t||E||(l&&"unknown"!==l?l:null)||"content",(0,q.cb)(e)},[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]),t6=(0,N.useMemo)(()=>{var e,t,l,a,i,n,r,s,o,d;let c=W||{},u=c.ideation||{},p=(null==ee?void 0:ee.input)||{},m=u.title||(null==(e=u.concept)?void 0:e.title)||(null==(t=c.pipeline_output)?void 0:t.title)||(null==(l=c.result)?void 0:l.title)||(null==ee||null==(a=ee.result)?void 0:a.title)||p.idea||p.premise||p.scenario||p.topic||p.story_idea||(null==(i=p.script_text)?void 0:i.substring(0,80))||(null==(n=p.script)?void 0:n.substring(0,80))||(p.brand&&p.product?"".concat(p.brand," â ").concat(p.product):null)||p.brand_or_game||p.song_title||p.brand_id||(null==(r=c.overview)?void 0:r.title)||(null==(o=c.overview)||null==(s=o.idea)?void 0:s.substring(0,80))||(null==ee||null==(d=ee.message)?void 0:d.replace(/^Starting\s+/,"").replace(/\s+generation\.{0,3}$/,""))||t8+" Run";return"interactive_avatar"===String((null==ee?void 0:ee.pipeline)||c.pipeline_type||E||"").toLowerCase()?(0,S.Ee)(String(m||"AvatarLive")):m},[W,ee,E,t8,e3,e8,e7,te,tl,ti,tr,V,P]),t7=null,t9=null,le=(0,N.useMemo)(()=>{var e;let t=String((null==ee?void 0:ee.status)||"").toLowerCase(),l=String((null==ee||null==(e=ee.result)?void 0:e.status)||"").toLowerCase();return["awaiting_approval","awaiting_human_review"].includes(t||l)},[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]),lt=(0,N.useMemo)(()=>{let e=(null==ee?void 0:ee.result)||{};return e.run_id||e.graph_run_id||(null==ee?void 0:ee.run_id)||(null==ee?void 0:ee.graph_run_id)||null},[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]),ll=(0,N.useMemo)(()=>{let e=null==ee?void 0:ee.status;return"pending"===e||"processing"===e},[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]),la=(0,N.useMemo)(()=>{var e,t,l,a;let i=null==W||null==(t=W.overview)||null==(e=t.checkpoint)?void 0:e.current_phase,n=null==W||null==(a=W.overview)||null==(l=a.graph_state)?void 0:l.current_phase,r=null==ee?void 0:ee.status;return"complete"===i||"completed"===i||"complete"===n||"completed"===n||"completed"===r},[W,ee]),li=(0,N.useMemo)(()=>{var e;return null!=(e=null==ee?void 0:ee.progress)?e:0},[P,W,ee]),ln=(0,N.useMemo)(()=>(null==ee?void 0:ee.message)||"",[P,W,ee]);(0,N.useMemo)(()=>(null==ee?void 0:ee.worker_id)||null,[P,W,ee]),(0,N.useMemo)(()=>(null==ee?void 0:ee.execution_mode)||null,[P,W,ee]);let lr=(0,N.useMemo)(()=>(null==ee?void 0:ee.queued_at)||null,[P,W,ee]),ls=(0,N.useMemo)(()=>{var e,t;return(null==W||null==(t=W.media)||null==(e=t.videos)?void 0:e.slice(0,e3))||[]},[W,e3]),lo=(0,N.useMemo)(()=>lM(W,ee,(null==ee?void 0:ee.pipeline)||(null==W?void 0:W.pipeline_type)||E).slice(0,e8),[P,W,ee,E,e8]),ld=(0,N.useMemo)(()=>{var e,t;return(null==W||null==(t=W.media)||null==(e=t.audio)?void 0:e.slice(0,e7))||[]},[W,e7]),[lc,lu]=(0,N.useState)(0),lp=null;async function lm(){try{let{data:e}=await S.aW.getTask(V,void 0,{skipCache:!0});return et(e),e}catch(e){try{let{data:e}=await S.I8.getTask(V);return et(e),e}catch(e){return null}}}function lv(){lh(),lp&&clearInterval(lp),lp=setInterval(()=>{lr&&lu(Math.floor(Date.now()/1e3-lr))},1e3),t9=setInterval(async()=>{let e=await lm();if(!e)return;let t=String(e.status||"").toLowerCase();if((0,S._w)(e,E)&&("processing"===t||"pending"===t)){let t=(0,S.gn)(e);U(e=>{var l;return(null==e?void 0:e.overview)&&(null==(l=e.overview.checkpoint)?void 0:l.current_phase)!==t?{...e,overview:{...e.overview,checkpoint:{...e.overview.checkpoint||{},current_phase:t}}}:e})}if("awaiting_approval"===t)return void lh();("completed"===t||"failed"===t||"needs_review"===t)&&(lh(),("completed"===t||"needs_review"===t)&&lz())},3e3)}function lh(){t9&&(clearInterval(t9),t9=null),lp&&(clearInterval(lp),lp=null)}function lg(){t7&&(clearInterval(t7),t7=null)}(0,N.useMemo)(()=>{var e,t;let l=[];
1if(!W)return l;let a=W.productionState,i=W.productionGraph;if(W.characters){let e=Array.isArray(W.characters)?W.characters:Object.values(W.characters||{});l.push({name:"Characters Defined",status:e.length>0?"pass":"warning",value:"".concat(e.length," characters"),details:e.map(e=>(null==e?void 0:e.name)||(null==e?void 0:e.character_name)||"").filter(Boolean).join(", ")})}if((null==i||null==(e=i.nodes)?void 0:e.filter(e=>"voice"===e.type).length)>0){let e=i.nodes.filter(e=>"voice"===e.type);l.push({name:"Voice Assignments",status:"pass",value:"".concat(e.length," voices"),details:e.map(e=>e.label).join(", ")})}if((null==a||null==(t=a.completed_scenes)?void 0:t.length)>0&&l.push({name:"Scenes Completed",status:"pass",value:"".concat(a.completed_scenes.length," scenes")}),(null==a?void 0:a.completed_shots)&&Object.keys(a.completed_shots).length>0){let e=Object.values(a.completed_shots).flat().length;l.push({name:"Shots Rendered",status:"pass",value:"".concat(e," shots")})}let n=W.media||{},r=Array.isArray(n.videos)?n.videos:[],s=Array.isArray(n.images)?n.images:[],o=Array.isArray(n.audio)?n.audio:[];r.length>0&&l.push({name:"Videos Generated",status:"pass",value:"".concat(r.length," videos")}),s.length>0&&l.push({name:"Images Generated",status:"pass",value:"".concat(s.length," images")}),o.length>0&&l.push({name:"Audio Generated",status:"pass",value:"".concat(o.length," audio files")}),r.some(e=>{var t,l;return(null==e||null==(t=e.name)?void 0:t.includes("final"))||(null==e||null==(l=e.name)?void 0:l.includes("output"))||(null==e?void 0:e.is_final)})?l.push({name:"Final Output",status:"pass",value:"Available"}):r.length>0&&l.push({name:"Final Output",status:"warning",value:"Not assembled yet"});let d=l.filter(e=>"pass"===e.status).length;return l.unshift({name:"Overall Status",status:la?"pass":"in_progress",value:la?"Complete":"In Progress (".concat(d,"/").concat(l.length," checks passed)")}),l},[W,la]);let lx=(0,N.useMemo)(()=>K(W),[W]),lf=(0,N.useMemo)(()=>J(W),[W]),lb=(0,N.useMemo)(()=>{let e=String((null==ee?void 0:ee.pipeline)||E||(null==W?void 0:W.pipeline_type)||"").toLowerCase();return"blog"===e||"translate_blog"===e},[ee,E,W]);function l_(e){if(!e)return"";let t=String(e).trim().replace(/\\/g,"/");if(!t)return"";let l=t.toLowerCase().indexOf(".working_dir/");return l>=0&&(t=t.slice(l)),t.startsWith("/app/")&&(t=t.slice(5)),t.replace(/\/{2,}/g,"/")}function ly(e){if(!e)return"";let t=String(e).trim();if(!t)return"";if(t.startsWith("http://")||t.startsWith("https://"))return t;let l="";try{l=String((0,S.Gi)()||"").replace(/\/$/,"")}catch(e){}{let e=window.location.hostname;("localhost"===e||"127.0.0.1"===e||!l||/localhost:8000|127\.0\.0\.1:8000/i.test(l))&&(l="".concat(window.location.protocol,"//").concat(window.location.host,"/api"))}l||(l="http://127.0.0.1:8001/api");let a=t.replace(/\\/g,"/").replace(/^\/api(?=\/)/,"");if(/^\/?local\/file(?:\?|$)/i.test(a)){try{let e=a.indexOf("?");if(e>=0){let t=new URLSearchParams(a.slice(e+1)),i=l_(t.get("path")||"");if(i)return"".concat(l,"/local/file?path=").concat(encodeURIComponent(i))}}catch(e){}let e=a.startsWith("/")?a:"/".concat(a);return"".concat(l).concat(e)}let i=l_(t),n=/^(output\/|\.working_dir\/|working_dir\/|[a-zA-Z]:\/)/i.test(i);if(i&&!n&&!i.startsWith(".")&&!i.startsWith("/")&&!i.toLowerCase().startsWith("working_dir/")){var r;let e=l_((null==W?void 0:W.run_path)||(null==W||null==(r=W.run)?void 0:r.working_dir)||"");i=e?"".concat(e.replace(/\/$/,""),"/").concat(i.replace(/^\//,"")):i}return i?"".concat(l,"/local/file?path=").concat(encodeURIComponent(i)):""}function lw(e){if(!e)return"";if(e.path_with_text){let t=e.path_with_text,l=e.url_with_text;return l&&(String(l).startsWith("http://")||String(l).startsWith("https://"))?l:ly(t)}let t="string"==typeof e.url?e.url:"";return t.startsWith("http://")||t.startsWith("https://")?t:e.presigned_url?e.presigned_url:e.s3_url?e.s3_url:e.path?ly(e.path):e.rel?ly(e.rel):e.url?ly(e.url):""}function lj(e){return(0,S.dR)(e,V)}(0,N.useEffect)(()=>{var e;let t=String((null==ee?void 0:ee.pipeline)||E||"").toLowerCase(),l=String((null==ee||null==(e=ee.result)?void 0:e.best_index_html)||"").trim();if("playable_ad"!==t||!l)return void eu("");let a=!1;return fetch(ly(l)).then(e=>e.ok?e.text():"").then(e=>{a||eu(e||"")}).catch(()=>{a||eu("")}),()=>{a=!0}},[ee,E,W]);let lN={viral_shorts:"social/viral_shorts",video_shorts:"video_shorts",shortmovie:"shortmovie",shortmovie_video:"shortmovie_video",kidsmovie:"kidsmovie",movie:"movie",musicvideo:"musicvideo",documentary:"documentary",learning_series:"learningseries",podcast_series:"podcastseries",podcast:"podcast",podcastseries:"podcastseries",adbanners:"ad_banners",ad_banners:"ad_banners",script2image:"script2image",social_carousel:"social/social_carousel",social_post:"social/social_carousel",ad:"ad",lyrics:"lyrics",song:"song",series:"movie",video:"video",character_2d:"character_2d",character_3d:"character_3d",interactive_avatar:"interactive_avatar",script2video:"script2video",content:"content",merch:"merch",tv_series:"movie",tvseries:"movie",weekly_series:"movie",short_movie_series:"movie",kids_movie:"kidsmovie",short_movie:"shortmovie",short_movie_video:"shortmovie_video",short_video:"shortmovie_video",music_video:"musicvideo",song2musicvideo:"musicvideo",podcast2video:"podcast",blog:"blog",comic:"comic",book:"content",ebook:"content",n
1ovel:"content",audiobook:"content",longs:"video",long_form_video:"video",interactive_story:"interactive_story"};async function lk(){var e,t,l;let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,i=a||ee;if(!i)try{let{data:e}=await S.aW.getTask(V,void 0,{skipCache:!0});i=e,et(e)}catch(e){try{let{data:e}=await S.I8.getTask(V);i=e,et(e)}catch(e){}}if(null==i?void 0:i.output_path){let e=lj(i.output_path);if(e){try{let{data:l}=await S.I8.listLocal({path:e});null==l||null==(t=l.files)||t.length}catch(e){}return e}}let n=lN[E]||E,r=".working_dir/".concat(n,"/").concat(V),s=".working_dir/".concat(V),o=null==(e=V.split(/\d{8}_/)[0])?void 0:e.replace(/_$/,""),d=o?lN[o]||o:null,c=d&&d!==n?".working_dir/".concat(d,"/").concat(V):null;if(!lN[E]&&V.startsWith(E+"_"))return s;let u=[...new Set([c,r,".working_dir/movie/".concat(V),s].filter(Boolean))];for(let e of(await Promise.allSettled(u.map(e=>S.I8.listLocal({path:e}).then(t=>({candidate:e,data:null==t?void 0:t.data})))))){if("fulfilled"!==e.status)continue;let t=null==(l=e.value)?void 0:l.data,a=null==t?void 0:t.files;if(Array.isArray(a)?a.length>0:!!t)return e.value.candidate}return c||r}let[lS,lC]=(0,N.useState)(""),[lA,lP]=(0,N.useState)(0);function lL(e){if(!Array.isArray(e)||!e.length)return e||[];let t=new Set(e.map(e=>{var t;return(null==(t=String((null==e?void 0:e.name)||(null==e?void 0:e.path)||"").split(/[/\\]/).pop())?void 0:t.toLowerCase())||""})),l=e.filter(e=>{var l;let a=(null==(l=String((null==e?void 0:e.name)||(null==e?void 0:e.path)||"").split(/[/\\]/).pop())?void 0:l.toLowerCase())||"";if(((e,t)=>{let l=e.toLowerCase(),a=String(t||"").replace(/\\/g,"/").toLowerCase();return!!(/^(bg_|composite_|raw_)/.test(l)||a.includes("/debug/")||a.includes("/brand_assets/"))||"brand_logo.png"===l||"brand_logo.jpg"===l||"brand_logo.webp"===l})(a,String((null==e?void 0:e.rel)||(null==e?void 0:e.path)||"")))return!1;if(!/\.(png|jpe?g|webp)$/i.test(a)||a.includes("_text."))return!0;let i=a.replace(/(\.(png|jpe?g|webp))$/i,"_text$1");return!t.has(i)}),a=l.filter(e=>{var t;return((null==(t=String((null==e?void 0:e.name)||(null==e?void 0:e.path)||"").split(/[/\\]/).pop())?void 0:t.toLowerCase())||"").includes("_text.")});return a.length?a:l}function lI(e){let t=[],l=new Set;for(let a of e){let e=String(a||"").replace(/\\/g,"/");!e||l.has(e)||(l.add(e),t.push(a))}return t}function lV(e){if(!e||"object"!=typeof e)return[];let t=e=>{if(!Array.isArray(e))return[];let t=[];for(let l of e){let e=function e(t){if(!t)return"";if("string"==typeof t){let e=t.trim();return e?e.startsWith("http://")||e.startsWith("https://")||/^\/?local\/file(?:\?|$)/i.test(e.replace(/\\/g,"/"))?e:e.includes(".working_dir")||e.includes("working_dir/")?e.replace(/\\/g,"/"):"":""}if("object"!=typeof t)return"";for(let l of["url","presigned_url","s3_url","path","rel"]){let a=e(t[l]);if(a)return a}return""}(l);e&&t.push(e)}return t},l=e=>/\/social_posts\//i.test(e.replace(/\\/g,"/")),a=t(e.image_urls),i=t(e.social_derivative_urls),n=t(e.master_image_urls),r=[...t(e.artifact_urls),...t(e.s3&&"object"==typeof e.s3?e.s3.artifact_urls:void 0)];if(a.length){let e=a.filter(l);return e.length?lI(e):lI(a)}if(i.length)return lI(i);if(n.length)return lI(n);let s=r.filter(l);if(s.length)return lI(s);let o=r.filter(e=>{let t=e.replace(/\\/g,"/").toLowerCase();return t.includes("/shots/")&&(t.includes("first_frame")||t.includes("last_frame"))});return o.length?lI(o):lI(r)}function lM(e,t,l){let a=e&&"object"==typeof e?e:{},i=t&&"object"==typeof t?t:{},n=a.media&&"object"==typeof a.media?a.media:{},r=Array.isArray(n.images)?n.images:[],s=String(l||a.pipeline_type||i.pipeline||"").toLowerCase(),o=function(e,t){let l=String(t||"").toLowerCase();if("ad_banners"===l||"adbanners"===l||"banners"===l)return lL(e);let a=lL(e);if("social_carousel"===l||"social_post"===l)return Array.isArray(a)&&a.length?a.map(e=>{var t;return(null==(t=String((null==e?void 0:e.name)||(null==e?void 0:e.path)||"").split(/[/\\]/).pop())?void 0:t.toLowerCase())||""}).some(e=>e.startsWith("postable_"))?a.filter(e=>{var t;let l=(null==(t=String((null==e?void 0:e.name)||(null==e?void 0:e.path)||"").split(/[/\\]/).pop())?void 0:t.toLowerCase())||"";return!/\.(png|jpe?g|webp)$/i.test(l)||l.startsWith("postable_")}):a:a||[];
1if("comic"===l){if(!Array.isArray(a)||!a.length)return a||[];let e=a.some(e=>{var t;let l=(null==(t=String((null==e?void 0:e.name)||(null==e?void 0:e.path)||"").split(/[/\\]/).pop())?void 0:t.toLowerCase())||"";return(null==e?void 0:e.is_composed_panel)||l.includes("_composed.")}),t=a.filter(t=>{var l;let a=String((null==t?void 0:t.rel)||(null==t?void 0:t.path)||"").replace(/\\/g,"/").toLowerCase(),i=(null==(l=String((null==t?void 0:t.name)||(null==t?void 0:t.path)||"").split(/[/\\]/).pop())?void 0:l.toLowerCase())||"";return!((null==t?void 0:t.is_raw_panel)||e&&i.startsWith("panel_")&&!i.includes("_composed.")&&a.includes("/panels/"))}),l=e=>{var t;let l=String((null==e?void 0:e.rel)||(null==e?void 0:e.path)||"").replace(/\\/g,"/").toLowerCase(),a=(null==(t=String((null==e?void 0:e.name)||(null==e?void 0:e.path)||"").split(/[/\\]/).pop())?void 0:t.toLowerCase())||"";return(null==e?void 0:e.is_cover)||"cover.png"===a?0:(null==e?void 0:e.is_page)||l.includes("/pages/")||/^page_\d+/i.test(a)?1:(null==e?void 0:e.is_composed_panel)||a.includes("_composed.")?2:(null==e?void 0:e.is_portrait)||l.includes("character_portraits")?4:3};return[...t].sort((e,t)=>{let a=l(e)-l(t);return 0!==a?a:String((null==e?void 0:e.rel)||(null==e?void 0:e.name)||"").localeCompare(String((null==t?void 0:t.rel)||(null==t?void 0:t.name)||""))})}if("script2image"===l||"scriptframe"===l||"script_to_image"===l){if(!Array.isArray(a)||!a.length)return a||[];let e=a.filter(e=>{let t=String((null==e?void 0:e.rel)||"").replace(/\\/g,"/").toLowerCase(),l=String((null==e?void 0:e.path)||"").replace(/\\/g,"/").toLowerCase(),a=String((null==e?void 0:e.name)||"").replace(/\\/g,"/").toLowerCase();return/(^|\/)social_posts\//.test(t)||/(^|\/)social_posts\//.test(l)||/(^|\/)social_posts\//.test(a)});return e.length?e:a}return a}(r,s);if("script2image"!==s&&"scriptframe"!==s&&"script_to_image"!==s)return o;let d=[],c=new Set,u=e=>{let t=String(e.path||e.url||e.rel||e.name||"").replace(/\\/g,"/");!t||c.has(t)||(c.add(t),d.push(e))};for(let e of o)u(e);let p=o.some(e=>{let t="".concat(e.rel||""," ").concat(e.path||""," ").concat(e.url||""," ").concat(e.name||"").replace(/\\/g,"/");return/social_posts/i.test(t)}),m=lI([...lV(i.result),...lV(a.pipeline_output),...lV(a.result)]);for(let e of p?m.filter(e=>/\/social_posts\//i.test(e.replace(/\\/g,"/"))):m){var v;u({url:e,path:e,name:(null==(v=e.split("/").pop())?void 0:v.split("?")[0])||"image.png"})}let h=d.filter(e=>{let t="".concat(e.rel||""," ").concat(e.path||""," ").concat(e.url||""," ").concat(e.name||"").replace(/\\/g,"/");return/social_posts/i.test(t)});return h.length?h:d}function lD(e){let t=String((null==e?void 0:e.name)||(null==e?void 0:e.path)||"").split(/[/\\]/).pop()||"";if((null==e?void 0:e.is_cover)||"cover.png"===t.toLowerCase())return"Cover";if((null==e?void 0:e.is_page)||/^page_/i.test(t)){let e=t.match(/page[_\-]?(\d+)/i);return e?"Page ".concat(Number(e[1])):"Page"}if((null==e?void 0:e.is_composed_panel)||t.toLowerCase().includes("_composed")){let e=t.match(/panel[_\-]?(\d+)/i);return e?"Panel ".concat(Number(e[1])):"Panel"}return(null==e?void 0:e.is_portrait)?"Character":t}function lT(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=e||ee;if(null==t?void 0:t.output_path)return lj(t.output_path);let l=lN[E]||E;return".working_dir/".concat(l,"/").concat(V)}async function lR(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3,l=async e=>{var l;if(!e)return null;let a=S.I8.listLocal({path:e}).then(e=>e.data),i=new Promise((e,l)=>setTimeout(()=>l(Error("timeout")),t)),n=await Promise.race([a,i]);if(!(null==n||null==(l=n.files)?void 0:l.length))return null;let r=n.path||e,s=[],o=[],d=[];for(let t of n.files){let l=String(t.path||t.key||"").replace(/\\/g,"/"),a=String(r||e||"").replace(/\\/g,"/").replace(/\/$/,""),i=l;if(a&&l.startsWith(a+"/"))i=l.slice(a.length+1);else{let e=".working_dir/",n=l.toLowerCase().indexOf(e);if(n>=0){let r=l.slice(n),s=a.toLowerCase().includes(e)?a.slice(a.toLowerCase().indexOf(e)):a;i=r.startsWith(s+"/")?r.slice(s.length+1):r.replace(/^\/?\.working_dir\/[^/]+\/[^/]+\//,"")||t.name}else i=t.name||l}let n={path:l.toLowerCase().includes(".working_dir/")?l.slice(l.toLowerCase().indexOf(".working_dir/")):a?"".concat(a,"/").concat(i):i,name:t.name||i,size:t.size,rel:i};if("video"===t.type)s.push(n);else if("image"===t.type){let e=String(i||"").replace(/\\/g,"/").toLowerCase(),l=String(t.name||i||"").toLowerCase();o.push({...n,is_cover:"cover.png"===l||e.endsWith("/cover.png"),is_page:e.includes("/pages/")||l.startsWith("page_"),is_composed_panel:l.includes("_composed."),is_raw_panel:l.startsWith("panel_")&&!l.includes("_composed.")&&e.includes("/panels/"),is_portrait:e.includes("character_portraits")||l.includes("portrait")})}else"audio"===t.type&&d.push(n)}return{overview:{run_meta:{pipeline:E,status:"completed",title:V,task_id:V},checkpoint:{current_phase:"complete"}},pipeline_type:E,scripts:{},media:{videos:s,images:o,audio:d},ideation:null,council_audits:[],monetization:null,run_path:r,_fallback:!0}};try{let t=await l(e);return t||e===".working_dir/".concat(V)||(t=await l(".working_dir/".concat(V))),t}catch(e){return null}}function lE(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;(async()=>{try{let a=await lk(e),{data:i}=await S.I8.getRunArtifacts(a);if(i){var t,l;U(i),eC(!!(null==i||null==(l=i.overview)||null==(t=l.run_meta)?void 0:t.published)),Q(i,(null==e?void 0:e.pipeline)||(null==ee?void 0:ee.pipeline)||E)&&ed("scripts");try{let{data:e}=await S.Ay.get("/local/file",{params:{path:"".concat(a,"/economics/summary.json")}});if(e){let t="string"==typeof e?JSON.parse(e):e;U(e=>e?{...e,economics:t}:e)}}catch(e){}}}catch(e){}})()}async function lz(){var e,t,l,a,i,n,r,s,o,d,c,u,p,m,v,g,x,f,b,_,y,w,N,k,C;F(!0),O(null),lC("Resolving run location...");let A=ee;if(!A)try{let{data:e}=await S.aW.getTask(V,void 0,{skipCache:!0});A=e,et(e)}catch(e){try{let{data:e}=await S.I8.getTask(V);A=e,et(e)}catch(e){}}let P=String((null==A?void 0:A.status)||"").toLowerCase(),L=String((null==A||null==(e=A.result)?void 0:e.status)||"").toLowerCase();if(A&&["awaiting_approval","awaiting_human_review"].includes(P||L)){U({overview:{run_meta:{pipeline:A.pipeline||E,status:"awaiting_approval",title:(null==(s=A.input)?void 0:s.idea)||A.message||"Plan ready â approve to cook",task_id:V},checkpoint:{current_phase:"awaiting_approval"}},pipeline_type:A.pipeline||E,scripts:{},media:{videos:[],images:[],audio:[]},ideation:(null==(o=A.result)?void 0:o.plan)||(null==(d=A.result)?void 0:d.interrupt)||null,council_audits:[],monetization:null,run_path:A.output_path||"",result:A.result||null}),F(!1),lh();return}if(A&&["processing","pending"].includes(String(A.status||"").toLowerCase())){U({overview:{run_meta:{pipeline:A.pipeline||E,status:A.status,title:(null==(c=A.input)?void 0:c.idea)||A.title||A.message||"Processing...",task_id:V},checkpoint:{current_phase:(0,S._w)(A,E)?(0,S.gn)(A):A.status}},pipeline_type:A.pipeline||E,scripts:{},media:{videos:[],images:[],audio:[]},ideation:null,council_audits:[],monetization:null,run_path:A.output_path?lj(A.output_path):""}),F(!1),lv();return}if(A&&"failed"===A.status&&!A.output_path){U({overview:{run_meta:{pipeline:A.pipeline||E,status:"failed",title:(null==(u=A.input)?void 0:u.idea)||A.title||"Failed",task_id:V},checkpoint:{current_phase:"failed"}},pipeline_type:A.pipeline||E,scripts:{},media:{videos:[],images:[],audio:[]},ideation:null,council_audits:[],monetization:null,run_path:"",error_message:A.error||A.message||"Pipeline failed"}),F(!1);return}let I=(0,S.aD)(A,E,V);if(I&&["completed","done","success"].includes(String((null==A?void 0:A.status)||"").toLowerCase())){U(I),O(null),F(!1),ed("overview");let e=I.run_path;e&&lR(e,1500).then(e=>{(null==e?void 0:e.media)&&U(t=>{var l,a,i,n,r,s;return t?{...t,media:{videos:(null==(a=t.media)||null==(l=a.videos)?void 0:l.length)?t.media.videos:e.media.videos||[],images:(null==(i=e.media.images)?void 0:i.length)?e.media.images:(null==(n=t.media)?void 0:n.images)||[],audio:(null==(r=e.media.audio)?void 0:r.length)?e.media.audio:(null==(s=t.media)?void 0:s.audio)||[]},run_path:e.run_path||t.run_path}:t})}).catch(()=>{});return}let M=(0,j.Uf)(A,E,V);if(M&&["completed","done","success"].includes(String((null==A?void 0:A.status)||"").toLowerCase())){U(M),O(null),F(!1),ed("media");return}let D=(0,S.PH)(A,E,V);if(D&&"awaiting_approval"!==String((null==A?void 0:A.status)||"").toLowerCase()){U(D),O(null),F(!1),ed("media");return}let T=function(e,t,l){if(!e||"object"!=typeof e)return null;let a=String(e.pipeline||t||"").toLowerCase();if(!Y(a))return null;let i=e.result&&"object"==typeof e.result?e.result:{},n=$(i),r=["completed","done","success"].includes(String(e.status||"").toLowerCase());if(!n.article_html&&!n.article_markdown&&!n.main&&!r)return null;let{images:s,audio:o}=function(e){let t=[],l=[],a=(null==e?void 0:e.files)&&"object"==typeof e.files?e.files:{};return a.featured_image&&t.push({path:a.featured_image,name:"Featured Image"}),a.section_images&&"object"==typeof a.section_images&&Object.values(a.section_images).forEac
1h(e=>{e&&t.push({path:e,name:String(e).split(/[/\\]/).pop()||"Section image"})}),Array.isArray(null==e?void 0:e.image_urls)&&e.image_urls.forEach((e,l)=>{e&&t.push({path:e,name:String(e).split(/[/\\]/).pop()||"image_".concat(l)})}),a.audio_narration&&l.push({path:a.audio_narration,name:"Audio Narration"}),{images:t,audio:l}}(i),d=i.title||i.topic||e.title||e.message||"";return{overview:{run_meta:{pipeline:a,status:e.status||"completed",title:d,task_id:l||e.id},checkpoint:{current_phase:"completed"}},pipeline_type:a,pipeline_output:{...i,pipeline:a},scripts:n,media:{videos:[],images:s,audio:o},ideation:i.topic||i.title?{topic:i.topic,title:i.title,slug:i.slug,meta_description:i.meta_description}:null,council_audits:null!=i.council_score?[{score:i.council_score}]:[],monetization:i.monetization||null,run_path:e.output_path||i.working_dir||"",result:i}}(A,E,V);if(T&&["completed","done","success"].includes(String((null==A?void 0:A.status)||"").toLowerCase())){U(T),O(null),F(!1),Q(T,(null==A?void 0:A.pipeline)||E)&&ed("scripts"),lE(A);return}lC("Loading assets...");let R=lR(lT(A),1500),z=new Promise((e,t)=>setTimeout(()=>t(Error("fast_timeout")),3e3)),B=null;try{B=await Promise.race([R,z])}catch(e){B=null}if(B&&((null==(l=B.media)||null==(t=l.videos)?void 0:t.length)||(null==(i=B.media)||null==(a=i.images)?void 0:a.length)||(null==(r=B.media)||null==(n=r.audio)?void 0:n.length))){U(B),O(null),F(!1),ed("media"),lE(A);return}let W=!1,G=(async()=>{var e,t,l,a,i;let n,r=await lk(A);lC("Scanning artifacts...");try{({data:n}=await S.I8.getRunArtifacts(r))}catch(i){let e=h(i)?null==(l=i.response)?void 0:l.status:void 0,t=(0,S.aD)(A,E,V);if(404===e&&t){U(t),O(null),F(!1),ed("overview");return}let a=(0,S.PH)(A,E,V);if(404===e&&a){U(a),O(null),F(!1),ed("media");return}throw i}if(W){U(n),O(null),F(!1),eC(!!(null==n||null==(i=n.overview)||null==(a=i.run_meta)?void 0:a.published)),Q(n,(null==A?void 0:A.pipeline)||E)&&ed("scripts");return}U(n),lP(0),eC(!!(null==n||null==(t=n.overview)||null==(e=t.run_meta)?void 0:e.published)),O(null),F(!1),Q(n,(null==A?void 0:A.pipeline)||E)&&ed("scripts");try{let{data:e}=await S.Ay.get("/local/file",{params:{path:"".concat(r,"/economics/summary.json")}});if(e){let t="string"==typeof e?JSON.parse(e):e;U(e=>e?{...e,economics:t}:e)}}catch(e){}})(),H=new Promise((e,t)=>setTimeout(()=>t(Error("LOAD_TIMEOUT")),3e4));try{await Promise.race([G,H])}catch(e){if((null==e?void 0:e.message)==="LOAD_TIMEOUT"){W=!0,lC("Loading large run â please wait...");let e=lT(A),t=await lR(e);t?(U(t),O(null),((null==(m=t.media)||null==(p=m.videos)?void 0:p.length)||(null==(g=t.media)||null==(v=g.images)?void 0:v.length)||(null==(f=t.media)||null==(x=f.audio)?void 0:x.length))&&ed("media")):lC("Still loading â scanning large run..."),lP(0)}else if(lA<2){let e=lA+1;lP(e),lC("Retrying (".concat(e,"/").concat(2,")...")),setTimeout(()=>lz(),2e3);return}else if((null==A?void 0:A.result)&&"object"==typeof A.result){let e=(0,S.aD)(A,E,V);if(e){U(e),O(null),F(!1),lP(0),ed("overview");return}let t=(0,S.PH)(A,E,V);if(t){U(t),O(null),F(!1),lP(0),ed("media");return}let l=A.result,a=A.pipeline||E,i=[],n=[];(null==(b=l.files)?void 0:b.featured_image)&&i.push({path:l.files.featured_image,name:"Featured Image"}),(null==(_=l.files)?void 0:_.section_images)&&Object.values(l.files.section_images).forEach(e=>i.push({path:e})),Array.isArray(l.image_urls)&&l.image_urls.forEach((e,t)=>{e&&i.push({path:e,name:String(e).split(/[/\\]/).pop()||"slide_".concat(t)})}),Array.isArray(l.carousel_manifest)&&l.carousel_manifest.forEach(e=>{let t=null==e?void 0:e.image_path;t&&i.push({path:t,name:String(t).split(/[/\\]/).pop()||e.role})}),(null==(y=l.files)?void 0:y.audio_narration)&&n.push({path:l.files.audio_narration,name:"Audio Narration"});let r={overview:{run_meta:{pipeline:a,status:A.status,title:l.title||l.topic||A.message||"",task_id:V},checkpoint:{current_phase:"completed"===A.status?"completed":A.status}},pipeline_type:a,pipeline_output:{...l,pipeline:a},scripts:$(l),media:{videos:[],images:i,audio:n},ideation:l.topic?{topic:l.topic,title:l.title,slug:l.slug,meta_description:l.meta_description}:null,council_audits:l.council_score?[{score:l.council_score}]:[],monetization:l.monetization||null,run_path:A.output_path||""};U(r),O(null),F(!1),lP(0),Q(r,a)&&ed("scripts")}else{let t=(null==e||null==(N=e.response)||null==(w=N.data)?void 0:w.detail)||e.message||"Failed to load run data";O(t.includes("not found")?"Run directory not found. The pipeline may still be processing or the output was not saved. Try refreshing the page or navigating from the Tasks list.":t)}}finally{if(W){let e=new Promise((e,t)=>
1setTimeout(()=>t(Error("LATE_TIMEOUT")),8e3));try{await Promise.race([G,e])}catch(e){if((null==e?void 0:e.message)!=="LATE_TIMEOUT"){let t=(null==e||null==(C=e.response)||null==(k=C.data)?void 0:k.detail)||(null==e?void 0:e.message)||"Failed to load run data";O(t.includes("not found")?"Run directory not found. The pipeline may still be processing or the output was not saved.":t)}}}F(!1)}}async function lF(e){ey(e),eb(!0),ex(null);try{let{data:t}=await S.I8.getFileContent(e.rel?"".concat(W.run_path,"/").concat(e.rel):e.path);ex(t)}catch(e){ex({error:e.message})}finally{eb(!1)}}async function lB(e){var t,l,a,i,n;let r=null==(l=e.target)||null==(t=l.files)?void 0:t[0],s=tP.current;if(!r||!s)return;e.target.value="";let o=(null==W?void 0:W.run_path)||(null==W||null==(a=W.run)?void 0:a.output_dir)||(null==W||null==(i=W.run)?void 0:i.working_dir)||"",d=(null==s||null==(n=s.ai_backup)?void 0:n.rel)||(null==s?void 0:s.rel)||(null==s?void 0:s.name)||"";if(o&&d&&/\.(mp4|mov|webm)$/i.test(r.name)){tk(!0);try{await S.I8.setRunFinalOverride(o,d,r);try{await S.I8.startSync({run_path:o})}catch(e){}let{data:e}=await S.I8.getRunArtifacts(o,S.Ay,{noCache:!0});U(e)}catch(e){console.error("Override failed:",e)}finally{tk(!1),tP.current=null}}}let lO=(0,N.useMemo)(()=>{var e,t,l,a,i,n,r,s,o,d,c,u;let p=W||{},m=[{id:"overview",label:"Overview",icon:"chart"}];if((p.ideation||(null==(e=p.reasoning)?void 0:e.length))&&m.push({id:"journey",label:"Creative Journey",icon:"sparkle"}),p.ideation){let e=(null==ee?void 0:ee.pipeline)||E||"",t="ads"===t4?"Ad Concept":e.includes("podcast")?"Podcast Concept":e.includes("song")||"music_video"===e||"musicvideo"===e||"lyrics"===e?"Song Concept":"audio"===t4?"Concept":"written"===t4?"Outline":"Idea";m.push({id:"ideation",label:t,icon:"bulb"})}if(Object.keys(p.scripts||{}).length||(null==(t=p.pipeline_output)?void 0:t.content)){let e=String((null==ee?void 0:ee.pipeline)||E||"").toLowerCase();m.push({id:"scripts",label:"blog"===e||"translate_blog"===e?"Article":"audio"===t4?"Lyrics & Script":"ads"===t4?"Ad Copy":"Script",icon:"doc"})}(null==(l=p.council_audits)?void 0:l.length)&&m.push({id:"council",label:"Quality Reviews",icon:"shield"}),((null==(a=p.storyboard)?void 0:a.length)||(null==(i=p.shots)?void 0:i.length))&&m.push({id:"storyboard",label:"Storyboard",icon:"film"}),((null==(r=p.media)||null==(n=r.videos)?void 0:n.length)||(null==(o=p.media)||null==(s=o.images)?void 0:s.length)||(null==(c=p.media)||null==(d=c.audio)?void 0:d.length))&&m.push({id:"media",label:"audio"===t4?"Audio & Media":"assets"===t4?"Assets":"Media Gallery",icon:"play"}),(p.monetization||Object.keys(p.quality||{}).length||p.cost||p.delivery)&&m.push({id:"business",label:"Business Intel",icon:"money"}),(Object.keys(p.voices||{}).length||Object.keys(p.continuity||{}).length)&&m.push({id:"production",label:"Production",icon:"gear"}),la&&m.push({id:"publish",label:"Edit & Publish",icon:"rocket"});let v=String((null==ee?void 0:ee.pipeline)||p.pipeline_type||E||"").toLowerCase();return(null==(u=p.raw_files)?void 0:u.length)&&!Z.has(v)&&m.push({id:"explorer",label:"Files",icon:"folder"}),m},[la,W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]),lW=(0,N.useMemo)(()=>{var e,t,l,a,i,n,r,s,o,d;if(!W)return[];let c=W.summary||{},u=W.pipeline_output,p=[],m=String((null==ee?void 0:ee.pipeline)||W.pipeline_type||E||"").toLowerCase(),v=Z.has(m),h=null==(e=W.overview)?void 0:e.checkpoint;(null==h?void 0:h.current_phase)&&p.push({label:"Current Phase",value:h.current_phase.replace(/_/g," "),color:"purple"}),(null==h||null==(t=h.completed_phases)?void 0:t.length)&&p.push({label:"Completed Phases",value:h.completed_phases.length,color:"green"});let g=lM(W,ee,m).length||c.total_images||(null==u?void 0:u.image_count)||(null==(a=W.media)||null==(l=a.images)?void 0:l.length)||0,x=c.total_audio||+(null!=u&&!!u.has_audio_narration)||(null==(n=W.media)||null==(i=n.audio)?void 0:i.length)||0,f=c.total_videos||(null==(s=W.media)||null==(r=s.videos)?void 0:r.length)||0,b=c.total_raw_files||(null==(o=W.raw_files)?void 0:o.length)||0;return v||p.push({label:"Videos",value:f,color:"blue",targetTab:"media"}),p.push({label:"Images",value:g,color:"indigo",targetTab:"media"}),v||p.push({label:"Audio Files",value:x,color:"pink",targetTab:"media"}),v||p.push({label:"Shots Planned",value:c.total_shots||0,color:"amber",targetTab:"storyboard"}),p.push({label:"Quality Reviews",value:c.total_audits||(null==(d=W.council_audits)?void 0:d.length)||0,color:"emerald",targetTab:"council"}),v||p.push({label:"Total Files",value:b,color:"slate",targetTab:"explorer"}),p},[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]);(0,N.useMemo)(()=>{var e,t;if(!W)return[];let l=null==(e=W.overview)?void 0:e.checkpoint;if(!(null==l||null==(t=l.completed_phases)?void 0:t.length))return[];let a=l.current_phase;return l.completed_phases.map(e=>({name:e.replace(/_/g," "),status:"done"})).concat(a&&"complete"!==a&&"completed"!==a?[{name:a.replace(/_/g," "),status:"active"}]:[])},[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]);let lU=(0,S._w)(ee,E)?[{id:"avatar_script",label:"Script",aliases:["avatar_script","script_generation"]},{id:"avatar_voice",label:"Voice",aliases:["avatar_voice","audio_generation"]},{id:"avatar_render",label:"Talking head",aliases:["avatar_render","avatar_processing"]},{id:"avatar_bundle",label:"Bundle",aliases:["avatar_bundle","mobile_export"]},{id:"complete",label:"Done",aliases:["complete","completed"]}]:[{id:"ideation",label:"Ideation",aliases:["ideation","concept","trends","characters"]},{id:"reference_images",label:"Reference Images",aliases:["reference_images","ref_images","reference"]},{id:"script",label:"Script",aliases:["script","screenplay","dialogue"]},{id:"production",label:"Production",aliases:["production","video","audio"]},{id:"post_production",label:"Post-Production",aliases:["post_production","postprod","editing","effects"]},{id:"quality_review",label:"Quality Review",aliases:["quality_review","council","audit"]},{id:"complete",label:"Complete",aliases:["complete","completed"]}];function lG(e){if(!e)return -1;let t=String(e).toLowerCase().replace(/\s/g,"_");for(let e=0;e<lU.length;e++)if(lU[e].aliases.some(e=>t.includes(e)||e.includes(t)))return e;return -1}let lH=(0,N.useMemo)(()=>{var e,t,l,a,i,n;let r=(null==W||null==(t=W.overview)||null==(e=t.checkpoint)?void 0:e.current_phase)||(null==W||null==(a=W.overview)||null==(l=a.graph_state)?void 0:l.current_phase),s=(null==W||null==(n=W.overview)||null==(i=n.checkpoint)?void 0:i.completed_phases)||[],o=lG(r),d=new Set(s.flatMap(e=>{let t=lG(e);return t>=0?[t]:[]}));return lU.map((e,t)=>{let l="pending";return d.has(t)||("complete"===r||"completed"===r)&&t<lU.length-1?l="complete":t===o&&(l="active"),{...e,status:l}})},[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]),lq=(0,N.useMemo)(()=>{var e,t,l,a;let i=(null==W||null==(t=W.overview)||null==(e=t.checkpoint)?void 0:e.current_phase)||(null==W||null==(a=W.overview)||null==(l=a.graph_state)?void 0:l.current_phase);if(!i)return"Loadingâ¦";let n=lG(i);return n>=0&&n<lU.length?lU[n].label:String(i).replace(/_/g," ")},[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]),lK=(0,N.useMemo)(()=>{let e=Number(null==ee?void 0:ee.progress);if(Number.isFinite(e)&&e>0)return Math.min(100,Math.max(0,e));if(!(null==lH?void 0:lH.length))return 0;let t=lH.findIndex(e=>"active"===e.status);return t>=0?(t+.5)/lH.length*100:lH.filter(e=>"complete"===e.status).length/lH.length*100},[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]);(0,N.useMemo)(()=>{let e=null==W?void 0:W.ideation;return e&&(e.audit_score||e.virality_score||e.score)||null},[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]);let lJ={hook_strength:{label:"Hook Strength",icon:"\uD83C\uDFA3",description:"How well the first 0.5 seconds grabs attention and stops the scroll.",weight:.25},loop_completion_likelihood:{label:"Watch-Through Rate",icon:"\uD83D\uDD01",description:"Predicted percentage of viewers who will watch the entire video.",weight:.15},comment_bait_score:{label:"Comment Driver",icon:"\uD83D\uDCAC",description:"How likely viewers are to leave a comment â questions, debates, or reactions.",weight:.1},trend_alignment:{label:"Trend Alignment",icon:"\uD83D\uDCC8",description:"How closely the content matches current platform trends, sounds, or formats.",weight:.1},emotional_resonance:{label:"Emotional Impact",icon:"â¤",description:"Strength of emotional response â surprise, joy, curiosity, or empathy.",weight:.1},save_potential:{label:"Save / Bookmark Value",icon:"\uD83D\uDD16",description:"Educational or reference value that makes viewers s
1ave it for later.",weight:.05},duet_potential:{label:"Duet Potential",icon:"\uD83E\uDD1D",description:"How well this works as a TikTok duet â reaction-worthy or side-by-side format.",weight:.05},stitch_potential:{label:"Stitch Potential",icon:"â",description:"Whether the first few seconds work as a stitch hook for other creators.",weight:.05}};(0,N.useMemo)(()=>{var e;let t=null==W||null==(e=W.quality)?void 0:e.viral_metrics;return t?Object.keys(lJ).filter(e=>void 0!==t[e]&&!Array.isArray(t[e])).map(e=>({key:e,value:t[e],...lJ[e]})):[]},[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]),(0,N.useMemo)(()=>{var e;let t=null==W||null==(e=W.quality)?void 0:e.viral_metrics;return Array.isArray(null==t?void 0:t.shareable_moments)?t.shareable_moments:[]},[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]);let l$=(0,N.useMemo)(()=>{var e;let t=null==W||null==(e=W.quality)?void 0:e.viral_metrics;if(!t)return 0;let l=0,a=0;for(let[e,i]of Object.entries(lJ)){let n=t[e];"number"==typeof n&&(l+=n*i.weight,a+=i.weight)}return l+=.15*Math.min(20*(Array.isArray(t.shareable_moments)?t.shareable_moments:[]).length,100),(a+=.15)>0?l/a:0},[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]);async function lY(){if(!eA){eP(!0);try{var e;let t=(null==W?void 0:W.run_path)||(null==W||null==(e=W.run)?void 0:e.output_dir)||"",l=!eS;await S.Ay.post("/local/run-publish-status?path=".concat(encodeURIComponent(t),"&published=").concat(l)),eC(l)}catch(e){console.error("Failed to toggle publish status:",e)}finally{eP(!1)}}}async function lQ(e){if(!lt)return void en("Missing graph run id â refresh and try again.");ea(!0),en(null);try{await S.$P.resume(lt,{action:e,notes:er||"",task_id:V});let t=await lm(),l=String((null==t?void 0:t.status)||"").toLowerCase();"pending"===l||"processing"===l?lv():"completed"===l||"needs_review"===l?await lz():"awaiting_approval"===l?lh():"failed"===l&&lh()}catch(a){var t,l;let e=h(a)?null==(l=a.response)||null==(t=l.data)?void 0:t.detail
1:void 0;en("string"==typeof e?e:a instanceof Error?a.message:"Could not resume plan. Try again.")}finally{ea(!1)}}function lX(e){var t,l,a,i;let n=String((null==ee||null==(t=ee.input)?void 0:t.brand_id)||(null==ee||null==(l=ee.result)?void 0:l.brand_id)||(null==W||null==(i=W.overview)||null==(a=i.checkpoint)?void 0:a.brand_id)||(0,R.fx)()||"").trim();if(e1(""),!n){ed("publish"),e1("Pick a brand on Home if you want the calendar. This tab still shares through Postiz.");return}eZ(n),eQ(e),e$(!0)}async function lZ(){eT(!0);try{let{data:e}=await S.Ay.get("/automation/channels");eM(Array.isArray(e)?e:(null==e?void 0:e.channels)||[])}catch(e){eM([])}finally{eT(!1)}try{let{data:e}=await S.ij.postizIntegrations(),t=Array.isArray(e)?e:(null==e?void 0:e.integrations)||(null==e?void 0:e.accounts)||[];eE(Array.isArray(t)?t:[])}catch(e){eE([])}}async function l0(){var e,t,l,a,i,n,r,s;ej("publishing"),ek(null);try{if(lb){let e=ez||eL;if(!e)throw Error("Select a WordPress integration first");let t=eB||(null==W||null==(i=W.pipeline_output)?void 0:i.title)||(null==W||null==(n=W.ideation)?void 0:n.title)||"Untitled article";await S.ij.publishBlog({task_id:V,postiz_integration_id:String(e),title:t}),ej("published"),eK(!1);return}let r=null==W||null==(t=W.media)||null==(e=t.videos)?void 0:e.find(e=>e.is_final),s={task_id:V,channel_id:eL||void 0,title:eB||(null==W||null==(l=W.ideation)?void 0:l.title)||"Untitled",description:(null==W||null==(a=W.ideation)?void 0:a.idea)||"",video_url:r?lw(r):void 0,schedule_at:eG||void 0};await S.Ay.post("/automation/publish",s),ej("published"),eK(!1)}catch(e){ej("error"),ek((null==e||null==(s=e.response)||null==(r=s.data)?void 0:r.detail)||e.message)}}(0,N.useMemo)(()=>l$>=75?"#22c55e":l$>=50?"#eab308":l$>=25?"#f97316":"#ef4444",[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]),(0,N.useMemo)(()=>l$>=75?"text-green-600":l$>=50?"text-yellow-600":l$>=25?"text-orange-500":"text-red-500",[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]),(0,N.useMemo)(()=>l$>=80?"Excellent Viral Potential":l$>=65?"Strong Viral Potential":l$>=50?"Moderate Viral Potential":l$>=35?"Below Average":"Needs Improvement",[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]),(0,N.useMemo)(()=>l$>=80?"This content has strong signals across hook, engagement, and trend alignment. High likelihood of organic reach and shares.":l$>=65?"Good engagement signals with room for optimization. Consider strengthening weaker areas to maximize reach.":l$>=50?"Average performance expected. Focus on improving the hook and adding more comment-driving elements.":l$>=35?"Several engagement signals are weak. Consider reworking the hook, pacing, or adding trending elements.":"Significant improvements needed. Review the hook, pacing, trend alignment, and emotional triggers.",[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]),(0,N.useMemo)(()=>{let e=null==W?void 0:W.economics;if(e)return e;let t=null==W?void 0:W.overview;if(null==t?void 0:t.economics)return t.economics;let l=((null==W?void 0:W.files)||[]).find(e=>{var t;return"summary.json"===e.name&&(null==(t=e.path)?void 0:t.includes("economics"))});return(null==l?void 0:l.content)?l.content:null},[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]);let l1=(0,N.useMemo)(()=>{var e,t,l,a,i,n,r,s,o,d,c,u,p,m,v,h,g,x,f,b,_,y,w;if(!W)return[];let j=[],N=(null==(e=W.overview)?void 0:e.checkpoint)||(null==(t=W.overview)?void 0:t.graph_state)||{};if(N.brand_id||N.game_id||N.character_ids||(null==(l=W.ideation)?void 0:l.brand_context)||(null==(a=W.ideation)?void 0:a.game_context)){let e=[];(N.brand_id||(null==(v=W.ideation)?void 0:v.brand_context))&&e.push({label:"Brand",value:N.brand_id||(null==(g=W.ideation)||null==(h=g.brand_context)?void 0:h.brand_name)||"Loaded from S3"}),(N.game_id||(null==(x=W.ideation)?void 0:x.game_context))&&e.push({label:"App / Game",value:N.game_id||(null==(b=W.ideation)||null==(f=b.game_context)?void 0:f.game_name)||"Loaded from S3"}),N.character_ids&&e.push({label:"Characters",value:Array.isArray(N.character_ids)?N.character_ids.join(", "):N.character_ids}),j.push({id:"context",icon:"\uD83C\uDFF7ï¸",title:"Entity Context Loaded",subtitle:"Brand, app, or character context was loaded from S3 to guide content creation",details:e,status:"done"})}if((null==(i=W.ideation)?void 0:i.trends)||(null==(n=W.ideation)?void 0:n.trend_data)||(null==(r=W.ideation)?void 0:r.trending_topics)){let e=W.ideation.trends||W.ideation.trend_data||W.ideation.trending_topics;j.push({id:"trends",icon:"\uD83D\uDCC8",title:"Trend Analysis",subtitle:"AI analyzed current trends to find a timely angle",details:Array.isArray(e)?e.slice(0,5).map(e=>({label:"string"==typeof e?e:e.topic||e.title||"Trend",value:e.score?"Score: ".concat(e.score):""})):[{label:"Source",value:"string"==typeof e?e:"Perplexity Sonar
1+ Google Trends"}],status:"done"})}if(W.ideation){let e=W.ideation;j.push({id:"ideation",icon:"\uD83D\uDCA1",title:"ads"===t4?"Ad Concept Generated":"audio"===t4?"Song Concept Created":"Creative Idea Generated",subtitle:e.title||"The AI brainstormed and selected the best creative concept",details:[e.hook?{label:"Hook",value:e.hook}:null,e.target_audience?{label:"Target Audience",value:e.target_audience}:null,e.tone?{label:"Tone",value:e.tone}:null,e.genre?{label:"Genre",value:e.genre}:null,e.platform?{label:"Platform",value:e.platform}:null,(()=>{var t,l,a,i,n;let r=null!=(l=null!=(t=e.audit_score)?t:e.virality_score)?l:e.score;if(null==r)return null;let s="object"==typeof r?null!=(n=null!=(i=null!=(a=r.overall)?a:r.score)?i:r.total)?n:Object.values(r)[0]:r;return null!=s?{label:"Ideation Score",value:"".concat(s,"/10")}:null})()].filter(Boolean),status:"done"})}let k=null==(s=W.council_audits)?void 0:s.find(e=>{var t;return"ideation"===e.phase||(null==(t=e.name)?void 0:t.includes("ideation"))});k&&j.push({id:"ideation_audit",icon:"\uD83D\uDEE1ï¸",title:"Ideation Quality Review",subtitle:"AI Council reviewed the creative concept â ".concat(k.verdict||"reviewed"),details:[k.score?{label:"Score",value:"".concat(k.score,"/10")}:null,k.verdict?{label:"Verdict",value:k.verdict}:null].filter(Boolean),status:"done"}),(null==(o=W.reference_images)?void 0:o.length)&&j.push({id:"ref_images",icon:"\uD83C\uDFA8",title:"Reference Images Generated",subtitle:"".concat(W.reference_images.length," concept image(s) created as visual anchors for production"),images:W.reference_images.slice(0,4),status:"done"});let S=Object.keys(W.scripts||{});if(S.length){let e=W.scripts.viral_script||W.scripts.script||W.scripts.director_brief||W.scripts[S[0]],t=(null==e||null==(_=e.scenes)?void 0:_.length)||(null==e||null==(y=e.segments)?void 0:y.length)||0;j.push({id:"script",icon:"\uD83D\uDCDD",title:"audio"===t4?"Lyrics Written":"Script Written",subtitle:t?"".concat(t," scene(s) scripted with dialogue and direction"):"Full script generated from the creative concept",details:[t?{label:"Scenes",value:t}:null,(null==e?void 0:e.total_duration_seconds)?{label:"Duration",value:function(e){if(e<60)return"".concat(e,"s");let t=Math.floor(e/60);return t>=60?"".concat(Math.floor(t/60),"h ").concat(t%60,"m"):"".concat(t,"m ").concat(e%60,"s")}(e.total_duration_seconds)}:null,(null==e?void 0:e.title)?{label:"Title",value:e.title}:null].filter(Boolean),status:"done"})}let C=null==(d=W.council_audits)?void 0:d.find(e=>{var t;return"script"===e.phase||(null==(t=e.name)?void 0:t.includes("script"))});C&&j.push({id:"script_audit",icon:"\uD83D\uDEE1ï¸",title:"Script Quality Review",subtitle:"AI Council reviewed the script â ".concat(C.verdict||"reviewed"),details:[C.score?{label:"Score",value:"".concat(C.score,"/10")}:null,C.verdict?{label:"Verdict",value:C.verdict}:null].filter(Boolean),status:"done"}),(null==(c=W.storyboard)?void 0:c.length)&&j.push({id:"storyboard",icon:"\uD83C\uDFAC",title:"Storyboard Visualized",subtitle:"".concat(W.storyboard.length," frames storyboarded for shot-by-shot production"),status:"done"});let A=(null==(u=W.media)?void 0:u.videos)||[],P=(null==(p=W.media)?void 0:p.images)||[];if(A.length||P.length){let e=A.find(e=>e.is_final);j.push({id:"production",icon:"\uD83C\uDFA5",title:"Production Complete",subtitle:"".concat(A.length," video(s) and ").concat(P.length," image(s) generated"),details:[e?{label:"Final Output",value:e.name||"final_video.mp4"}:null,{label:"Total Videos",value:A.length},{label:"Total Images",value:P.length}].filter(Boolean),status:"done"})}if(W.delivery||(null==(m=W.quality)?void 0:m.delivery_gate)){let e=W.delivery||(null==(w=W.quality)?void 0:w.delivery_gate)||{};j.push({id:"delivery",icon:"â
",title:"Quality Gate Passed",subtitle:e.verdict?"Delivery verdict: ".concat(e.verdict):"Final quality check completed",details:[e.verdict?{label:"Verdict",value:e.verdict}:null,e.overall_score?{label:"Score",value:"".concat(e.overall_score,"/10")}:null].filter(Boolean),status:"done"})}return W.monetization&&j.push({id:"monetization",icon:"\uD83D\uDCB0",title:"Monetization Strategy",subtitle:"Revenue potential and distribution strategy analyzed",details:[W.monetization.estimated_revenue?{label:"Revenue Estimate",value:W.monetization.estimated_revenue}:null,W.monetization.primary_platform?{label:"Best Platform",value:W.monetization.primary_platform}
1:null].filter(Boolean),status:"done"}),j},[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]),l2=(0,N.useMemo)(()=>"comic"===String((null==ee?void 0:ee.pipeline)||E||(null==W?void 0:W.pipeline_type)||"").toLowerCase(),[ee,E,W]),l5=(0,N.useMemo)(()=>{var e,t,l,a,i,n,r,s,o,d;if(!W)return null;let c=String((null==ee?void 0:ee.pipeline)||E||W.pipeline_type||"").toLowerCase(),u=null==(t=W.media)||null==(e=t.videos)?void 0:e.find(e=>e.is_final);u||"interactive_avatar"!==c||(u=((null==(r=W.media)?void 0:r.videos)||[]).find(e=>/talking_head|final/i.test(String((null==e?void 0:e.name)||(null==e?void 0:e.path)||"")))||(null==(o=W.media)||null==(s=o.videos)?void 0:s[0])||((null==ee||null==(d=ee.result)?void 0:d.video_path)?{path:ee.result.video_path,name:"talking_head.mp4",is_final:!0}:null));let p=null==(a=W.media)||null==(l=a.audio)?void 0:l.find(e=>{var t;return e.is_final||(null==(t=e.name)?void 0:t.includes("final"))}),m=lM(W,ee,(null==ee?void 0:ee.pipeline)||W.pipeline_type||E),v=m.find(e=>e.is_cover||"cover.png"===String(e.name||"").toLowerCase()),h=m.filter(e=>e.is_page||/page_\d+/i.test(String(e.name||"")));return{video:u,audio:p,thumbnail:m.find(e=>{var t,l,a;return(null==(t=e.name)?void 0:t.includes("thumbnail"))||(null==(l=e.name)?void 0:l.includes("thumb"))||(null==(a=e.name)?void 0:a.includes("cover"))}),comicCover:v,comicPages:h,allVideos:(null==(i=W.media)?void 0:i.videos)||[],allAudio:(null==(n=W.media)?void 0:n.audio)||[],allImages:m}},[W,ee,E,e3,e8,e7,te,tl,ti,tr,V,P]);(0,N.useEffect)(()=>{lZ()},[]),(0,N.useEffect)(()=>{"versions"!==eo||0!==tg.length||tf||t2(),"media"===eo&&(e4(12),e6(24),e9(20)),"storyboard"===eo&&(tt(20),ta(30),ts(24)),"explorer"===eo&&tn(50)},[eo]),(0,N.useEffect)(()=>()=>{lg(),lh(),tv.current&&(clearInterval(tv.current),tv.current=null)},[]),(0,N.useEffect)(()=>{if(lg(),lh(),!V)return;let e=!1;return(async()=>{let t=await lm();e||(t&&("pending"===t.status||"processing"===t.status)&&lv(),lz())})(),()=>{e=!0,lg(),lh()}},[V]);let l3=(null==W||null==(t=W.media)?void 0:t.videos)||[],l4=lM(W,ee,(null==ee?void 0:ee.pipeline)||(null==W?void 0:W.pipeline_type)||E),l8=(null==W||null==(l=W.media)?void 0:l.audio)||[],l6=String((null==ee?void 0:ee.pipeline)||E||(null==W?void 0:W.pipeline_type)||"").toLowerCase(),l7=!Z.has(l6)&&!!((null==l5?void 0:l5.video)||l3.length>0||(null==ee||null==(i=ee.result)?void 0:i.video_url)),l9=(null==W?void 0:W.pipeline_output)||(null==W?void 0:W.result)||(null==ee?void 0:ee.result)||null,ae=(null==W?void 0:W.raw_files)||[];return(0,a.jsxs)("div",{className:"w-full",children:[(0,a.jsx)("div",{className:"bg-white border-b border-gray-200 sticky top-0 z-30 shadow-sm",children:(0,a.jsxs)("div",{className:"max-w-[1400px] mx-auto px-4 sm:px-6 lg:px-8 py-3",children:[(0,a.jsxs)("nav",{className:"flex items-center gap-1.5 text-xs text-gray-400 mb-2",children:[(0,a.jsx)(n(),{href:"/contentx/working-dir",className:"hover:text-purple-600 transition-colors",children:"Library"}),(0,a.jsx)("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 5l7 7-7 7"})}),(0,a.jsx)(n(),{href:"/contentx/working-dir/".concat(E),className:"hover:text-purple-600 transition-colors capitalize",children:t8}),(0,a.jsx)("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 5l7 7-7 7"})}),(0,a.jsx)("span",{className:"text-gray-500 font-medium",children:"Run"})]}),(0,a.jsxs)("div",{className:"flex items-start gap-3 sm:gap-4",children:[(0,a.jsx)("button",{type:"button",onClick:()=>I.back(),className:"p-2 sm:p-1.5 hover:bg-gray-100 rounded-lg transition-colors mt-1 shrink-0 min-h-[44px] min-w-[44px] flex items-center justify-center",children:(0,a.jsx)("svg",{className:"w-5 h-5 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 19l-7-7 7-7"})})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("h1",{className:"text-xl sm:text-2xl lg:text-3xl font-bold text-gray-900 leading-tight",children:t6}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mt-1.5",children:[(0,a.jsx)("span",{className:"px-2.5 py-0.5 bg-purple-50 text-purple-700 rounded-md text-xs font-semibold uppercase tracking-wider border border-purple-100",children:t8}),la?(0,a.jsx)("span",{className:"px-2.5 py-0.5 bg-green-50 text-green-700 rounded-md text-xs font-medium border border-green-100",children:"Complete"}):(null==ee?void 0:ee.status)==="needs_review"?(0,a.jsx)("span",{className:"px-2.5 py-0.5 bg-amber-50 text-amber-800 rounded-md text-xs font-medium border border-amber-200",children:"Needs review"}):(null==ee?void 0:ee.status)==="failed"?(0,a.jsx)("span",{className:"px-2.5 py-0.5 bg-red-50 text-red-700 rounded-md text-xs font-medium border border-red-100",children:"Failed"}):le?(0,a.jsx)("span",{className:"px-2.5 py-0.5 bg-orange-50 text-orange-800 rounded-md text-xs font-medium border border-orange-200",children:"Needs approval"}):(0,a.jsxs)("span",{className:"px-2.5 py-0.5 bg-amber-50 text-amber-700 rounded-md text-xs font-medium border border-amber-100 flex items-center gap-1",children:[(0,a.jsx)("span",{className:"w-1.5 h-1.5 bg-amber-500 rounded-full animate-pulse"}),"In Progress"]}),(0,a.jsx)("button",{type:"button",onClick:lY,disabled:eA,className:["px-2.5 py-1 sm:py-0.5 rounded-md text-xs font-medium border flex items-center gap-1 transition-all",eS?"bg-emerald-50 text-emerald-700 border-emerald-200":"bg-gray-50 text-gray-500 border-gray-200"].filter(
1Boolean).join(" "),children:eS?"Published":"Unpublished"}),(0,a.jsx)("span",{className:"text-xs text-gray-400 font-mono hidden sm:inline",children:V}),W?(0,a.jsx)("button",{type:"button",onClick:t0,className:"px-2.5 py-1 sm:py-0.5 rounded-md text-xs font-medium border bg-gray-50 text-gray-500 border-gray-200 hover:bg-purple-50 hover:text-purple-700",title:"Download all run files",children:"Download All"}):null,W&&la?(0,a.jsx)("button",{type:"button",onClick:function(){tF(!0),tX(!1),tO(null),tU(!1),tH(!1),tK(null),t$(!1)},className:"px-2.5 py-1 sm:py-0.5 rounded-md text-xs font-medium border bg-gray-50 text-gray-500 border-gray-200 hover:bg-amber-50 hover:text-amber-700",title:"Upload override",children:"Upload"}):null,(0,a.jsx)(H.A,{helpKey:"runId",position:"bottom-left"})]})]})]}),!z&&!B&&(null==lH?void 0:lH.length)?(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsx)("div",{className:"hidden md:flex items-start justify-between gap-1 overflow-x-auto pb-2",children:lH.map((e,t)=>(0,a.jsxs)("div",{className:["flex items-center shrink-0",t<lH.length-1?"flex-1 min-w-0":""].filter(Boolean).join(" "),children:[(0,a.jsxs)("div",{className:"flex flex-col items-center",children:[(0,a.jsx)("div",{className:["w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 border-2","complete"===e.status&&"bg-green-500 border-green-500 text-white","active"===e.status&&"bg-blue-500 border-blue-500 text-white animate-pulse","pending"===e.status&&"bg-gray-100 border-gray-200 text-gray-400"].filter(Boolean).join(" "),children:"complete"===e.status?"â":(0,a.jsx)("span",{className:"text-xs font-bold",children:t+1})}),(0,a.jsx)("span",{className:["text-[10px] sm:text-xs mt-1.5 text-center max-w-[4rem] leading-tight","active"===e.status?"text-blue-600 font-semibold":"complete"===e.status?"text-gray-700":"text-gray-400"].filter(Boolean).join(" "),children:e.label})]}),t<lH.length-1?(0,a.jsx)("div",{className:["flex-1 h-0.5 mx-1 mt-4 min-w-3","complete"===e.status?"bg-green-300":"bg-gray-200"].filter(Boolean).join(" ")}):null]},e.id))}),(0,a.jsxs)("div",{className:"md:hidden flex items-center gap-3 px-3 py-2.5 bg-gray-50 rounded-lg border border-gray-100",children:[(0,a.jsx)("div",{className:"flex-1 h-2 bg-gray-200 rounded-full overflow-hidden",children:(0,a.jsx)("div",{className:"h-full rounded-full bg-blue-500 transition-all duration-300",style:{width:"".concat(lK,"%")}})}),(0,a.jsx)("span",{className:"text-sm font-medium text-gray-700 shrink-0",children:lq})]})]}):null]})}),(0,a.jsxs)("div",{className:"max-w-[1400px] mx-auto px-4 sm:px-6 lg:px-8 py-6",children:[le?(0,a.jsxs)("div",{className:"mb-6 rounded-2xl border border-orange-200 bg-orange-50/80 p-5",children:[(0,a.jsx)("div",{className:"text-sm font-semibold text-orange-950 mb-1",children:"Plan ready â approve to cook the video"}),(0,a.jsx)("p",{className:"text-sm text-orange-900/80 mb-3",children:ln||("interactive_avatar"===String((null==ee?void 0:ee.pipeline)||E||"").toLowerCase()?"AvatarLive Create is scripted. There is no Viral Shorts / LTX approve step.":"Viral Shorts parked for your OK. Approve to start LTX video generation.")}),lt?(0,a.jsxs)("p",{className:"text-xs text-orange-800/70 font-mono mb-3",children:["graph: ",lt]}):(0,a.jsx)("p",{className:"text-xs text-red-700 mb-3",children:"No graph run id on this task â refresh, or resume from Tasks if it stays stuck."}),(0,a.jsx)("label",{className:"block text-xs font-medium text-orange-900 mb-1",htmlFor:"hitl-notes",children:"Notes (optional)"}),(0,a.jsx)("textarea",{id:"hitl-notes",rows:2,className:"w-full mb-3 rounded-lg border border-orange-200 bg-white px-3 py-2 text-sm text-gray-800",value:er,onChange:e=>es(e.target.value),placeholder:"Optional feedback if you reject",disabled:el}),ei?(0,a.jsx)("p",{className:"text-sm text-red-700 mb-3",children:ei}):null,(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)("button",{type:"button",disabled:el||!lt,onClick:()=>void lQ("approve"),className:"px-4 py-2 rounded-lg bg-emerald-600 text-white text-sm font-semibold disabled:opacity-50",children:el?"Workingâ¦":"Approve & cook video"}),(0,a.jsx)("button",{type:"button",disabled:el||!lt,onClick:()=>void lQ("reject"),className:"px-4 py-2 rounded-lg border border-orange-300 bg-white text-orange-900 text-sm font-medium disabled:opacity-50",children:"Reject plan"})]})]}):null,ll?(0,a.jsxs)("div",{className:"mb-6 rounded-2xl border border-indigo-100 bg-indigo-50/60 p-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 mb-2",children:[(0,a.jsx)("div",{className:"text-sm font-semibold text-indigo-800",children:ln||"Processingâ¦"}),(0,a.jsxs)("div",{className:"text-xs text-indigo-600 font-mono",children:[li,"%"]})]}),(0,a.jsx)("div",{className:"h-2 bg-indigo-100 rounded-full overflow-hidden",children:(0,a.jsx)("div",{className:"h-full bg-gradient-to-r from-indigo-500 to-blue-500 transition-all",style:{width:"".concat(li,"%")}
1})})]}):null,z?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 gap-4",children:[(0,a.jsx)("div",{className:"w-12 h-12 border-4 border-purple-100 border-t-purple-500 rounded-full animate-spin"}),(0,a.jsx)(X.L,{messages:X.LOAD_HINTS.run,className:"text-gray-600"}),lS?(0,a.jsx)("p",{className:"text-gray-400 text-sm",children:lS}):null]}):null,!z&&B?(0,a.jsx)("div",{className:"max-w-lg mx-auto py-16",children:(0,a.jsxs)("div",{className:"bg-white border border-red-100 rounded-2xl p-8 text-center shadow-sm",children:[(0,a.jsx)("h2",{className:"text-lg font-bold text-gray-900 mb-2",children:"Couldn't load this run"}),(0,a.jsx)("p",{className:"text-gray-500 text-sm mb-6",children:B}),(0,a.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[(0,a.jsx)("button",{type:"button",onClick:()=>{lP(0),lz()},className:"px-5 py-2.5 bg-purple-600 text-white rounded-xl text-sm font-medium",children:"Try Again"}),(0,a.jsx)("button",{type:"button",onClick:()=>I.back(),className:"px-5 py-2.5 bg-gray-100 text-gray-700 rounded-xl text-sm font-medium",children:"Go Back"})]})]})}):null,!z&&!B&&(W||la)?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex gap-2 overflow-x-auto pb-3 mb-6 border-b border-gray-100",children:lO.map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>ed(e.id),className:["px-3 py-2 rounded-lg text-xs sm:text-sm font-semibold whitespace-nowrap",eo===e.id?"bg-purple-600 text-white":"bg-gray-50 text-gray-600"].filter(Boolean).join(" "),children:e.label},e.id))}),"playable_ad"===String((null==ee?void 0:ee.pipeline)||E||"").toLowerCase()&&(null==ee||null==(r=ee.result)?void 0:r.best_index_html)?(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-100 p-4 sm:p-6 mb-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3 gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-base font-semibold text-gray-900",children:"Playable"}),(0,a.jsxs)("p",{className:"text-xs text-gray-500 mt-0.5",children:[ee.result.app_name||"TapAd",ee.result.mechanic?" \xb7 ".concat(ee.result.mechanic):"",ee.result.best_variant_id?" \xb7 variant ".concat(ee.result.best_variant_id):""]})]}),(0,a.jsx)("a",{href:ly(ee.result.best_index_html),target:"_blank",rel:"noreferrer",className:"px-3 py-1.5 text-xs font-medium rounded-lg bg-purple-600 text-white shrink-0",children:"Open"})]}),(0,a.jsx)("div",{className:"mx-auto w-full max-w-[390px]",children:ec?(0,a.jsx)("iframe",{title:"TapAd preview",srcDoc:ec,sandbox:"allow-scripts allow-popups allow-popups-to-escape-sandbox",className:"w-full h-[640px] rounded-xl border border-gray-200 bg-[#F5F5F7]"}):(0,a.jsx)("div",{className:"w-full h-[640px] rounded-xl border border-gray-200 bg-gray-50 flex items-center justify-center text-sm text-gray-500",children:"Loading playableâ¦"})})]}):null,(0,a.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-8 gap-2 sm:gap-3 mb-8",children:lW.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>{e.targetTab&&lO.some(t=>t.id===e.targetTab)&&ed(e.targetTab)},className:"bg-white rounded-xl border border-gray-100 p-4 text-center hover:shadow-md",children:[(0,a.jsx)("div",{className:"text-2xl font-bold text-purple-600",children:e.value}),(0,a.jsx)("div",{className:"text-xs text-gray-500 mt-1",children:e.label})]},e.label))}),"overview"===eo?(0,a.jsxs)("div",{className:"space-y-6",children:[(null==l5?void 0:l5.video)||"interactive_avatar"===String((null==ee?void 0:ee.pipeline)||E||"").toLowerCase()&&(null==ee||null==(s=ee.result)?void 0:s.mobile_bundle_path)?(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-100 p-4 sm:p-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsx)("h2",{className:"text-base font-semibold text-gray-900",children:"Final Output"}),(null==l5?void 0:l5.video)?(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{type:"button",onClick:function(){var e,t,l;let a=null==W||null==(t=W.media)||null==(e=t.videos)?void 0:e.find(e=>e.is_final);if(!a)return;let i=lw(a);if(!i)return;let n=document.createElement("a");
1n.href=i,n.download=((null==W||null==(l=W.ideation)?void 0:l.title)||"video").replace(/[^a-zA-Z0-9-_]/g,"_")+".mp4",n.rel="noopener",n.target="_blank",n.click()},className:"px-3 py-1.5 text-xs font-medium rounded-lg bg-gray-100",children:"Download"}),(0,a.jsx)("button",{type:"button",onClick:function(){I.push("/contentx/editor?runId=".concat(encodeURIComponent(String(V||""))))},className:"px-3 py-1.5 text-xs font-medium rounded-lg bg-purple-600 text-white",children:"Edit"}),"interactive_avatar"===String((null==ee?void 0:ee.pipeline)||E||"").toLowerCase()?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",onClick:()=>lX("now"),className:"px-3 py-1.5 text-xs font-medium rounded-lg bg-emerald-600 text-white",children:"Publish"}),(0,a.jsx)("button",{type:"button",onClick:()=>lX("later"),className:"px-3 py-1.5 text-xs font-medium rounded-lg bg-indigo-600 text-white",children:"Schedule"})]}):null]}):null]}),(null==l5?void 0:l5.video)?(0,a.jsx)("video",{src:lw(l5.video),controls:!0,className:"w-full max-h-[480px] rounded-xl bg-black"}):null,e0&&"interactive_avatar"===String((null==ee?void 0:ee.pipeline)||E||"").toLowerCase()?(0,a.jsx)("p",{className:"mt-2 text-xs text-gray-500",children:e0}):null,"interactive_avatar"===String((null==ee?void 0:ee.pipeline)||E||"").toLowerCase()&&(null==ee||null==(o=ee.result)?void 0:o.mobile_bundle_path)?(0,a.jsx)("a",{href:ly(ee.result.mobile_bundle_path),className:"inline-block mt-3 text-sm font-medium text-purple-700",children:"Download mobile bundle"}):null]}):null,l2&&((null==l5?void 0:l5.comicCover)||(null!=(g=null==l5||null==(d=l5.comicPages)?void 0:d.length)?g:0)>0||(null!=(x=null==l5||null==(c=l5.allImages)?void 0:c.length)?x:0)>0)?(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-100 p-4 sm:p-6 space-y-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsx)("h2",{className:"text-base font-semibold text-gray-900",children:"Comic Output"}),(0,a.jsx)(A.A,{images:((null==l5?void 0:l5.allImages)||[]).map(e=>({...e,url:lw(e)})),title:t6,className:"px-3 py-1.5 text-xs font-medium rounded-lg bg-gray-100"}),(0,a.jsx)("button",{type:"button",onClick:()=>ed("media"),className:"px-3 py-1.5 text-xs font-medium rounded-lg bg-purple-600 text-white",children:"Open gallery"})]}),(null==l5?void 0:l5.comicCover)?(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wide text-gray-500 mb-2",children:"Cover"}),(0,a.jsx)("a",{href:lw(l5.comicCover),target:"_blank",rel:"noreferrer",className:"inline-block max-w-sm",children:(0,a.jsx)("img",{src:lw(l5.comicCover),alt:"Comic cover",className:"w-full rounded-xl border border-gray-100 bg-gray-50 object-contain max-h-[520px]"})})]}):null,(null!=(f=null==l5||null==(u=l5.comicPages)?void 0:u.length)?f:0)>0?(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"text-xs font-semibold uppercase tracking-wide text-gray-500 mb-2",children:["Pages (",l5.comicPages.length,")"]}),(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:l5.comicPages.map((e,t)=>(0,a.jsxs)("a",{href:lw(e),target:"_blank",rel:"noreferrer",className:"block rounded-xl overflow-hidden border border-gray-100 bg-white",children:[(0,a.jsx)("img",{src:lw(e),alt:lD(e),className:"w-full aspect-[2/3] object-contain bg-gray-50"}),(0,a.jsx)("div",{className:"p-2 text-xs font-medium text-gray-700",children:lD(e)})]},e.path||e.url||t))})]}):(null!=(b=null==l5||null==(p=l5.allImages)?void 0:p.length)?b:0)>0?(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"text-xs font-semibold uppercase tracking-wide text-gray-500 mb-2",children:["Images (",l5.allImages.length,")"]}),(0,a.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:l5.allImages.slice(0,12).map((e,t)=>(0,a.jsxs)("a",{href:lw(e),target:"_blank",rel:"noreferrer",className:"block rounded-xl overflow-hidden border border-gray-100 bg-white",children:[(0,a.jsx)("img",{src:lw(e),alt:lD(e),className:"w-full aspect-[2/3] object-contain bg-gray-50"}),(0,a.jsx)("div",{className:"p-2 text-xs font-medium text-gray-700 truncate",children:lD(e)})]},e.path||e.url||t))})]}):null]}
1):null,Z.has(l6)&&(null!=(_=null==l5||null==(m=l5.allImages)?void 0:m.length)?_:0)>0?(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-100 p-4 sm:p-6",children:[(0,a.jsx)("h2",{className:"text-base font-semibold text-gray-900 mb-3",children:"Image"}),(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:l5.allImages.slice(0,4).map((e,t)=>(0,a.jsx)("a",{href:lw(e),target:"_blank",rel:"noreferrer",className:"block",children:(0,a.jsx)("img",{src:lw(e),alt:e.name||"ScriptFrame still",className:"w-full rounded-xl border border-gray-100 bg-gray-50 object-contain max-h-[640px]"})},e.url||e.path||t))})]}):null,l7?(0,a.jsx)(G,{videoUrl:(null==l5?void 0:l5.video)?lw(l5.video):"",runPath:(null==W?void 0:W.run_path)||""}):null]}):null,"media"===eo?(0,a.jsxs)("div",{className:"space-y-8",children:[(0,a.jsxs)("section",{children:[(0,a.jsxs)("h2",{className:"text-base font-semibold mb-3",children:["Videos (",l3.length,")"]}),(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:ls.map((e,t)=>(0,a.jsxs)("div",{className:"bg-white rounded-xl border border-gray-100 overflow-hidden",children:[(0,a.jsx)("video",{src:lw(e),controls:!0,className:"w-full aspect-video bg-black"}),(0,a.jsxs)("div",{className:"p-3 flex justify-between gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-gray-600 truncate",children:e.name||e.path||"video"}),(0,a.jsx)("button",{type:"button",onClick:()=>(function(e){let t=(null==e?void 0:e.path)||(null==e?void 0:e.url)||"";if(t)if(t.startsWith("s3://")||(null==e?void 0:e.source)==="s3"){let l=(null==e?void 0:e.s3_key)||t.replace(/^s3:\/\/[^/]+\//,"");I.push("/contentx/editor?s3Key=".concat(encodeURIComponent(String(l))))}else I.push("/contentx/editor?filePath=".concat(encodeURIComponent(String(t))))})(e),className:"text-xs text-purple-600 font-medium",children:"Edit"})]})]},e.path||e.url||t))}),l3.length>e3?(0,a.jsx)("button",{type:"button",onClick:function(){e4(e=>e+12)},className:"mt-3 text-sm text-purple-600 font-medium",children:"Show more"}):null]}),(0,a.jsxs)("section",{children:[(0,a.jsxs)("h2",{className:"text-base font-semibold mb-3",children:["Images (",l4.length,")"]}),"social_carousel"===E||"social_post"===E?(0,a.jsx)("p",{className:"text-xs text-gray-500 mb-3",children:"Words live under each photo â they are not baked into the picture."}):null,l2?(0,a.jsx)("p",{className:"text-xs text-gray-500 mb-3",children:"Cover and pages first, then panels with speech bubbles."}):null,(0,a.jsx)("div",{className:l2?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4":"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:lo.map((e,t)=>{let l=function(e,t){let l=Array.isArray(null==t?void 0:t.carousel_manifest)?t.carousel_manifest:Array.isArray(null==t?void 0:t.slides)?t.slides:[],a=String((null==e?void 0:e.name)||(null==e?void 0:e.path)||"").split(/[/\\]/).pop()||"",i=l.find(e=>{let t=String((null==e?void 0:e.image_path)||(null==e?void 0:e.path)||"");return t.endsWith(a)||t.includes(a)});return i?{role:String(i.role||""),title:String(i.title||""),body:String(i.body||""),caption:String(i.caption||"")}:null}(e,l9),i=l2?lD(e):null;return(0,a.jsxs)("a",{href:lw(e),target:"_blank",rel:"noreferrer",className:"block rounded-xl overflow-hidden border border-gray-100 bg-white",children:[(0,a.jsx)("img",{src:lw(e),alt:(null==l?void 0:l.title)||i||e.name||"",className:l2?"w-full aspect-[2/3] object-contain bg-gray-50":"w-full aspect-square object-cover"}),l&&(l.title||l.caption)?(0,a.jsxs)("div",{className:"p-2 text-left",children:[l.role?(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-purple-600 font-semibold",children:l.role}):null,l.title?(0,a.jsx)("div",{className:"text-xs font-semibold text-gray-900 leading-snug",children:l.title}):null,l.caption?(0,a.jsx)("div",{className:"text-[11px] text-gray-500 mt-0.5 leading-snug",children:l.caption}):null]}):i?(0,a.jsx)("div",{className:"p-2 text-xs font-medium text-gray-700",children:i}):null]},e.path||e.url||t)})}),l4.length>
1e8?(0,a.jsx)("button",{type:"button",onClick:function(){e6(e=>e+24)},className:"mt-3 text-sm text-purple-600 font-medium",children:"Show more"}):null]}),(0,a.jsxs)("section",{children:[(0,a.jsxs)("h2",{className:"text-base font-semibold mb-3",children:["Audio (",l8.length,")"]}),(0,a.jsx)("div",{className:"space-y-2",children:ld.map((e,t)=>(0,a.jsxs)("div",{className:"bg-white rounded-xl border border-gray-100 p-3",children:[(0,a.jsx)("div",{className:"text-xs text-gray-600 mb-2",children:e.name||e.path}),(0,a.jsx)("audio",{src:lw(e),controls:!0,className:"w-full"})]},e.path||e.url||t))}),l8.length>e7?(0,a.jsx)("button",{type:"button",onClick:function(){e9(e=>e+20)},className:"mt-3 text-sm text-purple-600 font-medium",children:"Show more"}):null]})]}):null,"explorer"===eo?(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-100 overflow-hidden",children:[(0,a.jsxs)("div",{className:"px-4 py-3 border-b font-semibold text-sm",children:["Files (",ae.length,")"]}),(0,a.jsx)("div",{className:"divide-y max-h-[560px] overflow-y-auto",children:ae.slice(0,ti).map((e,t)=>{var l;return(0,a.jsxs)("button",{type:"button",onClick:()=>lF(e),className:"w-full text-left px-4 py-2.5 hover:bg-purple-50/50 flex justify-between gap-3",children:[(0,a.jsx)("span",{className:"text-sm truncate",children:e.rel||e.path||e.name}),(0,a.jsx)("span",{className:"text-xs text-gray-400",children:(l=e.size)?l>1048576?"".concat((l/1048576).toFixed(1)," MB"):l>1024?"".concat((l/1024).toFixed(0)," KB"):"".concat(l," B"):"â"})]},e.rel||e.path||t)})}),ae.length>ti?(0,a.jsx)("button",{type:"button",onClick:()=>tn(ti+50),className:"w-full py-3 text-sm text-purple-600 border-t",children:"Show more files"}):null,e_?(0,a.jsxs)("div",{className:"border-t p-4 bg-gray-50",children:[(0,a.jsx)("div",{className:"text-xs font-semibold text-gray-500 mb-2",children:e_.rel||e_.path}),ef?(0,a.jsx)("div",{className:"text-sm text-gray-500",children:"Loadingâ¦"}):(0,a.jsx)("pre",{className:"text-xs overflow-auto max-h-80 whitespace-pre-wrap",children:"string"==typeof eg?eg:JSON.stringify(eg,null,2)})]}):null]}):null,"publish"===eo?(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-100 p-4 sm:p-6 space-y-4",children:[(0,a.jsx)("h2",{className:"text-base font-semibold",children:lb?"Publish Blog":"Edit & Publish"}),lb?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"text-sm text-gray-600",children:"Publish this harvested article to WordPress. This is not the public Articles list (Sanity / n8n)."}),(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700",children:["WordPress integration",(0,a.jsxs)("select",{className:"mt-1 w-full border border-gray-200 rounded-xl p-2.5 text-sm",value:ez,onChange:e=>eF(e.target.value),children:[(0,a.jsx)("option",{value:"",children:"Select integrationâ¦"}),eR.map(e=>(0,a.jsx)("option",{value:e.id||e.integration_id,children:e.name||e.provider||e.platform||e.id||e.integration_id},e.id||e.integration_id))]})]}),(0,a.jsx)("textarea",{value:eB,onChange:e=>eO(e.target.value),placeholder:"Article title (optional override)",className:"w-full border border-gray-200 rounded-xl p-3 text-sm",rows:2}),(0,a.jsx)("button",{type:"button",onClick:l0,className:"px-4 py-2 rounded-lg bg-indigo-600 text-white text-sm",children:"Publish to WordPress"})]}):(0,a.jsx)(M,{taskId:V}),ew?(0,a.jsxs)("div",{className:"text-sm text-gray-600",children:["Status: ",ew,eN?" â ".concat(eN):""]}):null]}):null,"versions"===eo?(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-100 p-4 sm:p-6",children:[(0,a.jsx)("h2",{className:"text-base font-semibold mb-4",children:"Version History"}),tf?(0,a.jsx)("div",{className:"text-sm text-gray-500",children:"Loadingâ¦"}):null,t_?(0,a.jsx)("div",{className:"text-sm text-red-600 mb-3",children:String(t_)}):null,(0,a.jsx)("div",{className:"space-y-2",children:tg.map((e,t)=>(0,a.jsxs)("div",{className:"p-3 rounded-xl border flex items-center justify-between gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"text-sm font-semibold",children:["v",e.version||tg.length-t]}),(0,a.jsx)("div",{className:"text-xs text-gray-500",children:e.filename||e.name||"Version"})]}),t>0?(0,a.jsx)("button",{type:"button",disabled:null!==tw,onClick:()=>t5(e),className:"text-xs px-3 py-1.5 rounded-lg bg-purple-50 text-purple-700",children:tw===(e.version||e.name)?"Re
1storingâ¦":"Restore"}):(0,a.jsx)("span",{className:"text-[10px] uppercase text-purple-600 font-bold",children:"Current"})]},e.version||e.name||t))})]}):null,["overview","media","explorer","publish","versions"].includes(eo)?null:(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-100 p-6 space-y-3",children:[(0,a.jsx)("h2",{className:"text-base font-semibold",children:(null==(v=lO.find(e=>e.id===eo))?void 0:v.label)||eo}),"journey"===eo?l1.map(e=>(0,a.jsxs)("div",{className:"border rounded-xl p-4",children:[(0,a.jsxs)("div",{className:"font-medium text-sm",children:[e.icon," ",e.title]}),(0,a.jsx)("div",{className:"text-xs text-gray-500 mt-1",children:e.subtitle})]},e.id)):null,"scripts"===eo&&(lx||lf)?(0,a.jsxs)("div",{className:"space-y-3",children:[lf?(0,a.jsx)("div",{className:"prose prose-sm max-w-none bg-gray-50 rounded-xl p-4 max-h-[480px] overflow-auto text-slate-800",dangerouslySetInnerHTML:{__html:lf}}):null,lx&&(!lf||lx!==lf)?(0,a.jsx)("pre",{className:"text-xs whitespace-pre-wrap bg-gray-50 rounded-xl p-4 max-h-[480px] overflow-auto",children:lx}):null]}):null,"council"===eo?((null==W?void 0:W.council_audits)||[]).map((e,t)=>{var l;return(0,a.jsxs)("div",{className:"border rounded-xl p-3 text-sm flex justify-between",children:[(0,a.jsx)("span",{children:e.name||e.ph
1ase||"Audit"}),(0,a.jsxs)("span",{className:"font-semibold",children:[null!=(l=e.score)?l:"â"," \xb7 ",e.verdict||""]})]},t)}):null]})]}):null]}),tL?(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/40",onClick:()=>tI(!1),children:(0,a.jsxs)("div",{className:"bg-white rounded-2xl shadow-xl max-w-lg w-full p-6",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("h3",{className:"text-lg font-bold mb-3",children:"Download run files"}),tD?(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Loading file mapâ¦"}):null,(null==tV?void 0:tV.error)?(0,a.jsx)("p",{className:"text-sm text-red-600",children:tV.error}):null,tV&&!tV.error?(0,a.jsxs)("p",{className:"text-sm text-gray-600 mb-4",children:[tV.total_files||tV.file_count||"Ready"," files \xb7 ",function(e){if(!e||0===e)return"0 B";let t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(1))+" "+["B","KB","MB","GB"][t]}(tV.total_bytes||tV.total_size||0)]}):null,(0,a.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,a.jsx)("button",{type:"button",onClick:()=>tI(!1),className:"px-4 py-2 rounded-lg bg-gray-100 text-sm",children:"Cancel"}),(0,a.jsx)("button",{type:"button",onClick:function(){let e=tZ();if(!e)return;tE(!0);let t=S.I8.downloadRunZipUrl(e),l=document.createElement("a");l.href=t,l.download="".concat(V||"run",".zip"),l.click(),setTimeout(()=>{tE(!1)},3e3)},disabled:tR||!!(null==tV?void 0:tV.error),className:"px-4 py-2 rounded-lg bg-purple-600 text-white text-sm disabled:opacity-50",children:tR?"Startingâ¦":"Download ZIP"})]})]})}):null,tz?(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/40",onClick:()=>tF(!1),children:(0,a.jsxs)("div",{className:"bg-white rounded-2xl shadow-xl max-w-lg w-full p-6",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("h3",{className:"text-lg font-bold mb-3",children:"Upload override"}),(0,a.jsx)("input",{ref:tY,type:"file",accept:"video/*,.mp4,.mov,.webm",className:"mb-3 text-sm",onChange:function(e){var t,l;let a=null==(l=e.target)||null==(t=l.files)?void 0:t[0];a&&(tO(a),tX(!0))}}),tB?(0,a.jsx)("p",{className:"text-sm text-gray-600 mb-2",children:tB.name}):null,(0,a.jsxs)("label",{className:"flex items-center gap-2 text-sm mb-4",children:[(0,a.jsx)("input",{type:"checkbox",checked:!!tW,onChange:e=>tU(e.target.checked)}),"Mark publish-ready"]}),tq?(0,a.jsx)("p",{className:"text-sm text-red-600 mb-2",children:tq}):null,tJ?(0,a.jsx)("p",{className:"text-sm text-emerald-600 mb-2",children:"Uploaded successfully"}):null,(0,a.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,a.jsx)("button",{type:"button",onClick:()=>tF(!1),className:"px-4 py-2 rounded-lg bg-gray-100 text-sm",children:"Close"}),(0,a.jsx)("button",{type:"button",onClick:t1,disabled:!tB||tG,className:"px-4 py-2 rounded-lg bg-amber-600 text-white text-sm disabled:opacity-50",children:tG?"Uploadingâ¦":"Confirm upload"})]})]})}):null,(0,a.jsx)("input",{ref:tA,type:"file",accept:".mp4,.mov,.webm",className:"hidden",onChange:lB}),eJ&&eX&&(null==l5?void 0:l5.video)?(0,a.jsx)(D.A,{fallbackTitle:"Schedule failed to open",onReset:()=>e$(!1),children:(0,a.jsx)(T.A,{brandId:eX,initialMode:eY,previewSrc:lw(l5.video),initialCaption:String(t6||""),item:{id:String(V||""),name:String(t6||"AvatarLive"),kind:"video",ext:"mp4",specs:"9:16",status:"Approved",source:"ai",date:new Date().toISOString().slice(0,10),url:lw(l5.video),thumb:lw(l5.video),taskId:String(V||""),pipeline:"interactive_avatar",title:String(t6||"AvatarLive")},onClose:()=>e$(!1),onScheduled:e=>{e$(!1),e1(e||("now"===eY?"Sent to publish.":"Post scheduled."))}})}):null]})}}}]);
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.