1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4487],{44487:function(e,t,s){Promise.resolve().then(s.t.bind(s,72972,23)),Promise.resolve().then(s.bind(s,58341))},58341:function(e,t,s){"use strict";s.d(t,{default:function(){return y}});var a=s(57437),l=s(27648),i=s(2265),n=s(51817),r=s(82023),o=s(92934),d=s(83229),c=s(34928),x=s(96215),p=s(78867),m=s(96362),u=s(95805),h=s(48253);function j(e,t){return e?new Date(e).toLocaleString("en-US",null!=t?t:{month:"short",day:"numeric",year:"numeric"}):"â"}function f(e){return new Intl.NumberFormat("en-US").format(e)}function b(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return t.filter(Boolean).join(" ")}let N=["hook:","context:","contradiction:","proof point:","reset:","playbook prompt:","extra direction:"];function v(e,t){var s,a;if(!e)return"";let l=RegExp("(?:^|\\n)".concat(t,":\\s*(.+)"),"i"),i=e.match(l);return null!==(a=null==i?void 0:null===(s=i[1])||void 0===s?void 0:s.trim())&&void 0!==a?a:""}function g(e,t){var s,a;if(!e)return"";let l=e.match(t);return null!==(a=null==l?void 0:null===(s=l[1])||void 0===s?void 0:s.trim())&&void 0!==a?a:""}function y(e){var t,s,b,y;let{scope:E,itemId:R}=e,T="admin"===E,O=T?"/admin/marketing/content":"/marketing/content",[z,Z]=(0,i.useState)(!0),[D,I]=(0,i.useState)(!1),[B,L]=(0,i.useState)(!1),[U,M]=(0,i.useState)(null),[V,_]=(0,i.useState)(null),F=(0,i.useCallback)(e=>T?"".concat(e,"?scope=admin"):e,[T]),H=(0,i.useCallback)(async()=>{Z(!0),M(null);try{let e=await fetch(F("/api/marketing/command-center/items/".concat(R)));if(!e.ok)throw Error("Failed to load content item");let t=await e.json();_(t.item)}catch(e){M(e instanceof Error?e.message:"Failed to load content item")}finally{Z(!1)}},[R,F]);async function J(e){I(!0),M(null);try{if(!(await fetch("/api/marketing/command-center/items/".concat(R),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:T?"admin":"consultant",status:e})})).ok)throw Error("Could not update status");await H()}catch(e){M(e instanceof Error?e.message:"Could not update status")}finally{I(!1)}}async function $(){I(!0),M(null);try{let e=await fetch("/api/marketing/command-center/items/".concat(R,"/duplicate"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:T?"admin":"consultant"})});if(!e.ok)throw Error("Could not duplicate item");let t=await e.json();window.location.href="".concat(O,"/item/").concat(t.item.id)}catch(e){M(e instanceof Error?e.message:"Could not duplicate item")}finally{I(!1)}}async function K(){if(V){L(!0),M(null);try{var e;let t=v(V.notes,"Source material")||v(V.notes,"Generator context")||V.scriptBody||V.hook||V.topic||V.title,s=await fetch("/api/marketing/command-center/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:T?"admin":"consultant",mode:"PLAYBOOK",platform:V.platform,formatKey:"".concat(h.fi[V.platform],"::").concat(V.formatName),topic:V.topic||V.title,targetAudience:g(V.caption,/Built for (.+?) who/i)||g(V.visualNotes,/Audience:\s*(.+?)(?:\.|$)/i)||"",sourceMaterial:t,contradiction:V.contradiction||"",desiredOutcome:g(V.caption,/Aim the post toward (.+?)(?:\.|$)/i)||g(V.caption,/If the goal is (.+?),(?: start| focus| build)/i)||g(V.visualNotes,/Outcome:\s*(.+?)(?:\.|$)/i)||"",ctaIntent:V.cta||"",assetDirection:g(V.visualNotes,/Direction:\s*(.+?)(?:\.|$)/i),freePrompt:"",sourceAsset:null})});if(!s.ok)throw Error("Could not regenerate AI draft");let a=await s.json();if(!a.generated)throw Error("AI regeneration returned no draft");let l=[a.generated.notes,a.generated.hookPattern?"Primary hook pattern: ".concat(a.generated.hookPattern,"."):"",(null===(e=a.generated.hookOptions)||void 0===e?void 0:e.length)?"Alternate hooks:\n- ".concat(a.generated.hookOptions.join("\n- ")):""].filter(Boolean).join("\n");if(!(await fetch("/api/marketing/command-center/items/".concat(R),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:T?"admin":"consultant",title:a.generated.title,hook:a.generated.hook,scriptBody:a.generated.scriptBody,caption:a.generated.caption,cta:a.generated.cta,hashtags:a.generated.hashtags,talkingPoints:a.generated.talkingPoints,visualNotes:a.generated.visualNotes,thumbnailPrompt:a.generated.thumbnailPrompt,brollNotes:a.generated.brollNotes||null,notes:l,scriptReady:!0,captionReady:!0,ctaReady:!0,saveVersion:!0,versionNotes:"Regenerated
1with improved AI draft quality"})})).ok)throw Error("Could not save regenerated draft");await H()}catch(e){M(e instanceof Error?e.message:"Could not regenerate draft")}finally{L(!1)}}}if((0,i.useEffect)(()=>{H()},[H]),z)return(0,a.jsx)("div",{className:"flex min-h-[320px] items-center justify-center text-slate-500",children:(0,a.jsx)(n.Z,{size:20,className:"animate-spin"})});if(!V)return(0,a.jsx)("div",{className:"rounded-2xl border border-slate-200 bg-white p-8 text-center",children:(0,a.jsx)("p",{className:"text-[14px] font-semibold text-slate-900",children:"Content item not found"})});let q=function(e){var t,s,a,l;let i=null!==(a=null===(t=e.scriptBody)||void 0===t?void 0:t.toLowerCase())&&void 0!==a?a:"",n=null!==(l=null===(s=e.visualNotes)||void 0===s?void 0:s.toLowerCase())&&void 0!==l?l:"";return N.some(e=>i.includes(e))||n.includes("topic:")||n.includes("audience:")||n.includes("direction:")}(V);return(0,a.jsxs)("div",{className:"space-y-4",children:[U?(0,a.jsx)("div",{className:"rounded-xl border border-rose-200 bg-rose-50 px-4 py-3 text-[13px] text-rose-700",children:U}):null,q?(0,a.jsxs)("div",{className:"rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-[13px] text-amber-800",children:["This item looks like it was generated
1with the older template-style draft flow. Use"," ",(0,a.jsx)("span",{className:"font-semibold",children:"Regenerate with AI"})," ","to replace the saved script, caption, CTA, and visual notes in place."]}):null,(0,a.jsxs)("div",{className:"grid gap-4 xl:grid-cols-[280px_1fr_320px]",children:[(0,a.jsxs)("div",{className:"space-y-4 rounded-2xl border border-slate-200 p-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-slate-500",children:"Metadata"}),(0,a.jsx)("h2",{className:"mt-2 text-[18px] font-semibold text-slate-950",children:V.title}),(0,a.jsx)("p",{className:"mt-1 text-[12px] text-slate-600",children:V.postId})]}),(0,a.jsx)(C,{label:"Track",value:null!==(t=h.e5[V.track])&&void 0!==t?t:V.track}),(0,a.jsx)(C,{label:"Platform",value:null!==(s=h.fi[V.platform])&&void 0!==s?s:V.platform}),(0,a.jsx)(C,{label:"Format",value:V.formatName}),(0,a.jsx)(C,{label:"Status",value:null!==(b=h.NK[V.status])&&void 0!==b?b:V.status}),(0,a.jsx)(C,{label:"Priority",value:V.priority}),(0,a.jsx)(C,{label:"Owner",value:V.ownerLabel||"â"}),(0,a.jsx)(C,{label:"Due date",value:j(V.dueDate)}),(0,a.jsx)(C,{label:"Publish date",value:j(V.publishAt)}),(0,a.jsx)(C,{label:"Published URL",value:V.publishedUrl||"â"})]}),(0,a.jsxs)("div",{className:"space-y-4 rounded-2xl border border-slate-200 p-4",children:[(0,a.jsx)(k,{title:"Hook",children:(0,a.jsx)(w,{children:V.hook||"No hook yet."})}),(0,a.jsx)(k,{title:"Script",children:(0,a.jsx)(w,{children:V.scriptBody||"No script body yet."})}),(0,a.jsx)(k,{title:"Caption",children:(0,a.jsx)(w,{children:V.caption||"No caption yet."})}),(0,a.jsx)(k,{title:"CTA",children:(0,a.jsx)(w,{children:V.cta||"No CTA yet."})}),(0,a.jsx)(k,{title:"Hashtags",children:(0,a.jsx)(w,{children:V.hashtags.join(", ")||"No hashtags yet."})}),(0,a.jsx)(k,{title:"Visual Notes",children:(0,a.jsx)(w,{children:V.visualNotes||"No visual notes yet."})}),(0,a.jsx)(k,{title:"Talking Points",children:(0,a.jsx)(w,{children:V.talkingPoints.join("\n")||"No talking points yet."})}),(0,a.jsx)(k,{title:"Internal Notes",children:(0,a.jsx)(w,{children:V.notes||"No notes yet."})})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"rounded-2xl border border-slate-200 p-4",children:[(0,a.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-slate-500",children:"Actions"}),(0,a.jsxs)("div",{className:"mt-3 flex flex-col gap-2",children:[(0,a.jsxs)("button",{onClick:()=>void K(),disabled:D||B,className:S,children:[B?(0,a.jsx)(n.Z,{size:14,className:"animate-spin"}):(0,a.jsx)(r.Z,{size:14}),"Regenerate with AI"]}),(0,a.jsxs)("button",{onClick:()=>void J("APPROVED"),disabled:D,className:P,children:[(0,a.jsx)(o.Z,{size:14}),"Mark Approved"]}),(0,a.jsxs)("button",{onClick:()=>void J("SCHEDULED"),disabled:D,className:S,children:[(0,a.jsx)(d.Z,{size:14}),"Mark Scheduled"]}),(0,a.jsxs)("button",{onClick:()=>void J("PUBLISHED"),disabled:D,className:S,children:[(0,a.jsx)(c.Z,{size:14}),"Mark Published"]}),(0,a.jsxs)("button",{onClick:()=>void J("MEASURED"),disabled:D,className:S,children:[(0,a.jsx)(x.Z,{size:14}),"Mark Measured"]}),(0,a.jsxs)("button",{onClick:()=>void $(),disabled:D,className:S,children:[(0,a.jsx)(p.Z,{size:14}),"Duplicate Item"]}),(0,a.jsx)(l.default,{href:"".concat(O,"/queue"),className:S,children:"Back to Queue"})]})]}),(0,a.jsxs)("div",{className:"rounded-2xl border border-slate-200 p-4",children:[(0,a.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-slate-500",children:"Readiness"}),(0,a.jsxs)("div",{className:"mt-3 space-y-2",children:[(0,a.jsx)(A,{label:"Script",ready:V.scriptReady}),(0,a.jsx)(A,{label:"Visual",ready:V.visualReady}),(0,a.jsx)(A,{label:"Caption",ready:V.captionReady}),(0,a.jsx)(A,{label:"CTA",ready:V.ctaReady}),(0,a.jsx)(A,{label:"Thumbnail",ready:V.thumbnailReady})]}),(0,a.jsxs)("p",{className:"mt-3 text-[12px] text-slate-600",children:["Missing: ",V.missingItems.join(", ")||"Nothing flagged"]})]}),(0,a.jsxs)("div",{className:"rounded-2xl border border-slate-200 p-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(x.Z,{size:15,className:"text-sky-600"}),(0,a.jsx)("p",{className:"text-[14px] font-semibold text-slate-900",children:"Performance"})]}),V.performance?(0,a.jsxs)("div",{className:"mt-3 grid gap-2 text-[12px] text-slate-600",children:[(0,a.jsx)(C,{label:"Views",value:f(V.performance.views)}),(0,a.jsx)(C,{label:"Engagement",value:(y=V.performance.engagementRate,"".concat(y.toFixed(1),"%")),compact:!0}),(0,a.jsx)(C,{label:"Leads",value:f(V.performance.leads),compact:!0}),(0,a.jsx)(C,{label:"Apps Started",value:f(V.performance.applicationsStarted),compact:!0})]}):(0,a.jsx)("p",{className:"mt-3 text-[12px] text-slate-500",children:"No performance data yet."}),(0,a.jsxs)(l.default,{href:"".concat(O,"/performance"),className:"mt-3 inline-flex items-center gap-1 text-[12px] font-medium text-sky-700",children:["Open performance tracker",(0,a.jsx)(m.Z,{size:12})]})]}),(0,a.jsxs)("div",{className:"rounded-2xl border border-slate-200 p-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(u.Z,{size:15,className:"text-sky-600"}),(0,a.jsx)("p",{className:"text-[14px] font-semibold text-slate-900",children:"Leads"})]}),V.leads.length>0?(0,a.jsx)("div",{className:"mt-3 space-y-2",children:V.leads.slice(0,4).map(e=>(0,a.jsxs)("div",{className:"rounded-xl bg-slate-50 px-3 py-2",children:[(0,a.jsx)("p",{className:"text-[12px] font-semibold text-slate-900",children:e.name}),(0,a.jsxs)("p",{className:"mt-1 text-[11px] text-slate-600",children:[e.stage," \xb7 Follow-up ",j(e.followUpDate)]})]},e.id))}):(0,a.jsx)("p",{className:"mt-3 text-[12px] text-slate-500",children:"No leads attached yet."}),(0,a.jsxs)(l.default,{href:"".concat(O,"/leads"),className:"mt-3 inline-flex items-center gap-1 text-[12px] font-medium text-sky-700",children:["Open lead tracker",(0,a.jsx)(m.Z,{size:12})]})]})]})]}),(0,a.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,a.jsxs)("div",{className:"rounded-2xl border border-slate-200 p-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(r.Z,{size:15,className:"text-sky-600"}),(0,a.jsx)("p",{className:"text-[14px] font-semibold text-slate-900",children:"Assets"})]}),V.assets.length>0?(0,a.jsx)("div",{className:"mt-3 space-y-3",children:V.assets.map(e=>(0,a.jsxs)("div",{className:"rounded-xl bg-slate-50 px-3 py-3",children:[(0,a.jsx)("p",{className:"text-[12px] font-semibold text-slate-900",children:e.asset.assetName}),(0,a.jsx)("p",{className:"mt-1 text-[11px] text-slate-600",children:e.relationshipType}),(0,a.jsxs)("a",{href:e.asset.fileUrl,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1 text-[12px] font-medium text-sky-700",children:["Open asset",(0,a.jsx)(m.Z,{size:12})]})]},e.id))}):(0,a.jsx)("p",{className:"mt-3 text-[12px] text-slate-500",children:"No assets attached yet."})]}),(0,a.jsxs)("div",{className:"rounded-2xl border border-slate-200 p-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(r.Z,{size:15,className:"text-sky-600"}),(0,a.jsx)("p",{className:"text-[14px] font-semibold text-slate-900",children:"Repurposing + Versions"})]}),(0,a.jsxs)("div",{className:"mt-3 space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-[12px] font-semibold text-slate-900",children:"Script versions"}),(0,a.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:V.scriptVersions.length>0?V.scriptVersions.map(e=>(0,a.jsxs)("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] text-slate-700",children:["v",e.versionNumber," \xb7 ",j(e.createdAt)]},e.id)):(0,a.jsx)("span",{className:"text-[12px] text-slate-500",children:"No versions yet."})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-[12px] font-semibold text-slate-900",children:"Derived items"}),(0,a.jsx)("div",{className:"mt-2 space-y-2",children:V.repurposeChildren.length>0?V.repurposeChildren.map(e=>{var t;return(0,a.jsxs)("div",{className:"rounded-xl bg-slate-50 px-3 py-2",children:[(0,a.jsx)("p",{className:"text-[12px] font-semibold text-slate-900",children:e.repurposeType}),(0,a.jsx)("p",{className:"mt-1 text-[11px] text-slate-600",children:null!==(t=e.newTitle)&&void 0!==t?t:"Derivative draft in progress"})]},e.id)}):(0,a.jsx)("p",{className:"text-[12px] text-slate-500",children:"No repurpose children yet."})})]})]})]})]})]})}function k(e){let{title:t,children:s}=e;return(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-slate-500",children:t}),(0,a.jsx)("div",{className:"mt-2",children:s})]})}function w(e){let{children:t}=e;return(0,a.jsx)("div",{className:"whitespace-pre-wrap rounded-2xl bg-slate-50 px-4 py-3 text-[13px] leading-6 text-slate-700",children:t})}function C(e){let{label:t,value:s,compact:l}=e;return(0,a.jsxs)("div",{className:b("rounded-xl bg-slate-50 px-3 py-2",l&&"bg-white px-0 py-0"),children:[(0,a.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-slate-500",children:t}),(0,a.jsx)("p",{className:"mt-1 text-[12px] text-slate-900",children:s})]})}function A(e){let{label:t,ready:s}=e;return(0,a.jsxs)("div",{className:b("flex items-center justify-between rounded-xl px-3 py-2 text-[12px] font-medium",s?"bg-emerald-50 text-emerald-700":"bg-amber-50 text-amber-700"),children:[(0,a.jsx)("span",{children:t}),(0,a.jsx)("span",{children:s?"Ready":"Needs Work"})]})}let P="inline-flex items-center justify-center gap-2 rounded-xl bg-slate-950 px-3 py-2 text-[12px] font-semibold text-white transition hover:bg-slate-800 disabled:cursor-not-allowed disabled:opacity-60",S="inline-flex items-center justify-center gap-2 rounded-xl border border-slate-200 bg-white px-3 py-2 text-[12px] font-semibold text-slate-700 transition hover:border-slate-300 hover:text-slate-950"}}]);
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.