const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pptxgen.es-B5WfMOjD.js","assets/chunk-B3pr0VN8.js","assets/jszip.min-BuovhjG-.js"])))=>i.map(i=>d[i]);
import{i as e}from"./chunk-B3pr0VN8.js";import{n as t,t as n}from"./jsx-runtime-wTfS3W87.js";import{t as r}from"./preload-helper-Dd-HcVz_.js";import{d as i}from"./chunk-6CSD65Y2-Dj7xjS5D.js";import{r as a}from"./authSession-CrP9lMPq.js";import{t as o}from"./createLucideIcon-D8EZdzY3.js";import{t as s}from"./download-8udYNbpo.js";import{t as c}from"./file-text-CHBGhHo7.js";import{t as l}from"./printer-OxZToARA.js";import{t as u}from"./refresh-cw-BgzRAeGH.js";import{t as d}from"./rotate-ccw-DeMkoVBS.js";import{t as f}from"./send-CWrHn2eV.js";import{t as p}from"./PlatformTokenUsage-DOyFOKQg.js";/* empty css                    */import{t as m}from"./HrShell-C3cCIv29.js";import{n as h,r as g,t as _}from"./hrPptHandoff-Cne5FuIv.js";import"./ToolSidebarNav-ChQWauy7.js";import{t as v}from"./ToolLiveStreamPanel-NdoSsKvg.js";import{t as y}from"./usePlatformTokenUsage-pEv5JJw3.js";var b=o(`Maximize2`,[[`polyline`,{points:`15 3 21 3 21 9`,key:`mznyad`}],[`polyline`,{points:`9 21 3 21 3 15`,key:`1avn1i`}],[`line`,{x1:`21`,x2:`14`,y1:`3`,y2:`10`,key:`ota7mn`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),x=e(t(),1),S=`
<style id="hireedge-ppt-print-fix">
@page { size: 13.333in 7.5in; margin: 0; }
@media print {
  html, body {
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: white !important;
    scroll-snap-type: none !important;
  }
  body { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  main, .deck, .slides, .presentation, .slide-deck, .deck-root {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    display: block !important;
    scroll-snap-type: none !important;
  }
  .slide {
    width: 100vw !important;
    height: 100vh !important;
    min-height: 100vh !important;
    max-height: 100vh !important;
    overflow: hidden !important;
    break-after: page !important;
    page-break-after: always !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    scroll-snap-align: none !important;
    box-sizing: border-box !important;
  }
  .slide:last-of-type {
    break-after: auto !important;
    page-break-after: auto !important;
  }
  .export-toolbar, .nav-dots, .progress-bar, .keyboard-hint {
    display: none !important;
  }
  [contenteditable] { outline: none !important; }
}
</style>`,C=e=>{let t=e.replace(/<style id=["']hireedge-ppt-print-fix["'][\s\S]*?<\/style>/gi,``);return/<\/head>/i.test(t)?t.replace(/<\/head>/i,`${S}\n</head>`):t.replace(/<body/i,`${S}\n<body`)},w=(e,t)=>(e.match(/<title[^>]*>([\s\S]*?)<\/title>/i)?.[1]||e.match(/<h1[^>]*>([\s\S]*?)<\/h1>/i)?.[1]||t||`presentation`).replace(/<[^>]+>/g,``).replace(/[\\/:*?"<>|]+/g,`_`).replace(/\s+/g,`_`).slice(0,60)||`presentation`,T=`Microsoft YaHei`,E={brand:`1F7A5C`,text:`1F2937`,muted:`64748B`,surface:`FFFFFF`,brandSubtle:`E8F3EF`,border:`D8E2DC`},D=`演示文稿内容`,O=e=>String(e||``).replace(/\u00a0/g,` `).replace(/\s+/g,` `).trim(),k=(e,t)=>{let n=new Set,r=[];for(let i of e){let e=O(i);if(!(!e||n.has(e))&&(n.add(e),r.push(e),r.length>=t))break}return r},A=(e,t)=>{let n=O(e);return n.length>t?n.slice(0,t-1)+`…`:n},j=(e,t,n)=>k(Array.from(e.querySelectorAll(t)).map(e=>e.textContent||``),n),M=e=>{if(typeof DOMParser>`u`)return[{title:w(e),bullets:[O(e.replace(/<[^>]+>/g,` `)).slice(0,300)||D],notes:[]}];let t=new DOMParser().parseFromString(e,`text/html`);t.querySelectorAll(`script, style, nav, button, iframe, .export-toolbar, .nav-dots, .progress-bar, .keyboard-hint`).forEach(e=>e.remove());let n=Array.from(t.querySelectorAll(`section`)),r=(n.length>0?n:[t.body]).map((t,n)=>{let r=A(j(t,`h1, h2, h3, [data-title], .title, .slide-title`,1)[0]||t.getAttribute(`aria-label`)||(n===0?w(e):``),80)||`第 `+(n+1)+` 页`,i=j(t,`li, [data-bullet], .bullet, .point`,8),a=j(t,`p, div, span`,12).filter(e=>e!==r&&e.length<=180),o=k(i.length>0?i:a,6),s=a.filter(e=>!o.includes(e)).slice(0,3);return{title:r,bullets:o.length>0?o.map(e=>A(e,150)):[D],notes:s.map(e=>A(e,180))}}).filter(e=>e.title||e.bullets.length>0);return r.length>0?r:[{title:w(e),bullets:[D],notes:[]}]},N=(e,t,n)=>{let r=e.ShapeType||e.shapes||{};t.addShape(r.line||r.LINE||`line`,{x:.65,y:5.1,w:8.2,h:0,line:{color:E.border,transparency:20}}),t.addText(String(n).padStart(2,`0`),{x:9.25,y:4.95,w:.45,h:.3,fontFace:T,fontSize:9,bold:!0,align:`center`,color:E.brand,margin:0})},P=(e,t,n)=>{let r=e.addSlide(),i=e.ShapeType||e.shapes||{};r.background={color:E.surface},r.addShape(i.rect||i.RECTANGLE||`rect`,{x:0,y:0,w:.32,h:5.625,fill:{color:E.brand},line:{color:E.brand}}),r.addShape(i.rect||i.RECTANGLE||`rect`,{x:.65,y:.75,w:1.2,h:.08,fill:{color:E.brand},line:{color:E.brand}}),r.addText(t||n.title,{x:.65,y:1.25,w:8.4,h:1.2,fontFace:T,fontSize:34,bold:!0,color:E.text,margin:0,fit:`shrink`,breakLine:!1});let a=k([...n.bullets,...n.notes],3).join(` / `);a&&r.addText(a,{x:.68,y:2.75,w:7.6,h:.75,fontFace:T,fontSize:15,color:E.muted,margin:0,fit:`shrink`}),r.addText(`HireEdge`,{x:.68,y:4.75,w:1.6,h:.25,fontFace:T,fontSize:10,bold:!0,color:E.brand,margin:0})},F=(e,t,n)=>{let r=e.addSlide(),i=e.ShapeType||e.shapes||{};r.background={color:E.surface},r.addShape(i.rect||i.RECTANGLE||`rect`,{x:0,y:0,w:10,h:.18,fill:{color:E.brand},line:{color:E.brand}}),r.addText(t.title,{x:.65,y:.52,w:8.4,h:.55,fontFace:T,fontSize:22,bold:!0,color:E.text,margin:0,fit:`shrink`}),r.addShape(i.rect||i.RECTANGLE||`rect`,{x:.65,y:1.18,w:.72,h:.05,fill:{color:E.brand},line:{color:E.brand}});let a=t.bullets.slice(0,6).flatMap((e,n)=>[{text:e,options:{bullet:{indent:14},hanging:4,breakLine:n<t.bullets.length-1}}]);r.addText(a.length>0?a:[{text:D,options:{bullet:{indent:14}}}],{x:.85,y:1.55,w:8.35,h:2.75,fontFace:T,fontSize:15,color:E.text,fit:`shrink`,breakLine:!1,paraSpaceAfterPt:9,margin:.03}),t.notes.length>0&&(r.addShape(i.roundRect||i.ROUNDED_RECTANGLE||`roundRect`,{x:.65,y:4.42,w:8.4,h:.48,rectRadius:.08,fill:{color:E.brandSubtle},line:{color:E.border,transparency:25}}),r.addText(t.notes.join(`  `),{x:.85,y:4.52,w:8,h:.24,fontFace:T,fontSize:9.5,color:E.muted,margin:0,fit:`shrink`})),N(e,r,n)},ee=async(e,t)=>{let n=await r(()=>import(`./pptxgen.es-B5WfMOjD.js`),__vite__mapDeps([0,1,2])),i=new(n.default||n);i.layout=`LAYOUT_16x9`,i.author=`HireEdge`,i.company=`HireEdge`,i.subject=`Editable presentation exported from HireEdge`;let a=C(e),o=w(a,t),s=M(a);i.title=o,P(i,o.replace(/_/g,` `),s[0]),s.slice(1).forEach((e,t)=>F(i,e,t+2)),s.length===1&&F(i,s[0],2),await i.writeFile({fileName:o+`.pptx`})},I=()=>`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,te=()=>{try{let e=new Uint8Array(12);return crypto.getRandomValues(e),Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}catch{return`${Date.now().toString(16)}${Math.random().toString(16).slice(2)}`.replace(/[^a-f0-9]/gi,``).slice(0,24)}},L=`hireedge_ppt_turns`,R=`https://api2.bysjob.com`,z=()=>{try{return`${`https://api2.bysjob.com`.replace(/\/+$/g,``)}/api/llm/op`}catch{}try{let e=String(window.location.origin||``).replace(/\/+$/g,``),t=String(window.location.hostname||``).toLowerCase();if(e&&(t===`localhost`||t===`127.0.0.1`||t===`::1`))return`${e}/api/llm/op`}catch{}return`${R}/api/llm/op`},B=(e=L)=>{try{if(performance.getEntriesByType(`navigation`)[0]?.type===`reload`)return sessionStorage.removeItem(e),[];let t=sessionStorage.getItem(e);return t?JSON.parse(t):[]}catch{return[]}},V=(e,t=L)=>{try{sessionStorage.setItem(t,JSON.stringify(e))}catch{}},H=e=>{let t=e.match(/```(?:html)?\s*\n?(<!DOCTYPE html[\s\S]*?<\/html>)\s*\n?```/i);if(t)return{html:t[1],completionRatio:1};let n=e.match(/<!DOCTYPE html[\s\S]*<\/html>/i);if(n)return{html:n[0],completionRatio:1};let r=e.match(/```(?:html)?\s*\n?(<!DOCTYPE html[\s\S]*)/i)||e.match(/(<!DOCTYPE html[\s\S]*)/i);if(r&&r[1].length>500){let e=(r[1].match(/<section/g)||[]).length,t=(r[1].match(/<\/section>/g)||[]).length,n=e>0?Math.min(1,t/e):.5,i=r[1];for(let n=0;n<e-t;n++)i+=`</section>`;return i.includes(`</body>`)||(i+=`</body>`),i.includes(`</html>`)||(i+=`</html>`),{html:i,completionRatio:n}}return{html:void 0,completionRatio:0}},U=e=>{let t=e.match(/```(?:ppt_questions|question_form)\s*\n([\s\S]*?)\n```/);if(!t)return{form:null,cleanText:e};try{let n=JSON.parse(t[1]);if(n&&Array.isArray(n.questions))return{form:n,cleanText:e.replace(t[0],``).trim()}}catch{}return{form:null,cleanText:e}},W=e=>e?(e.match(/<section\b/gi)||[]).length:0,G=e=>{let t=String(e||``);return t.length<=6e4?t:[t.slice(0,3e4),`
<!-- 中间内容已省略；请保留已有结构、视觉风格和页码顺序，并按尾部继续补全 -->
`,t.slice(-25e3)].join(``)},K=e=>e.slice(-24).map(e=>{let t=e.role===`user`?`用户`:`AI`,n=e.html?`\n[HTML页数] ${W(e.html)} 页${e.incompleteGeneration?`，上次生成未完成`:``}`:``;return`${t}：${e.content.slice(0,3e3)}${n}`}).join(`

`),q=(e,t,n)=>e!==`full`||!t||W(t)>1?!1:!/(?:1\s*页|一页|单页|只做封面|封面预览)/.test(n),ne=[`候选人/面试对象`,`HR/招聘团队`,`用人经理/业务负责人`,`公司管理层`,`投资人/VC`,`客户/合作方`,`普通观众`,`其他`],re=[`2-3页（快速体验）`,`5-7页`,`8-10页`,`10-15页`,`其他（自定义）`],J=e=>`${e.id||``} ${e.label||``}`.toLowerCase(),Y=e=>/audience|受众|演示给谁看|听众|观众/.test(J(e)),X=e=>/page|length|slide|count|页数|几页|页面数量|篇幅|长度/.test(J(e)),ie=e=>e.some(e=>e.role===`user`&&/演示给谁看[？?]?\s*[：:]|受众\s*[：:]|audience\s*[：:]/i.test(e.content)),ae=e=>e?e.questions.some(e=>/color_confirm|style_confirm|preview_confirm|风格确认|配色确认|预览|封面/.test(`${e.id||``}${e.label||``}`)):!1,oe=(e,t)=>{let n=ie(t),r=e.questions.map(e=>X(e)?{...e,id:e.id||`page_count`,label:e.label||`大概需要多少页？`,type:`single`,options:re}:e),i=r.find(Y);if(!n)return{intro:`先确认一个关键问题：这份演示主要给谁看？我会根据受众再继续问制作要求。`,questions:[{...i||{id:`audience`,label:`演示给谁看？`,type:`single`},id:i?.id||`audience`,label:`演示给谁看？`,type:`single`,options:i?.options?.length?i.options:ne}]};let a=r.filter(e=>!Y(e)),o=a.flatMap(e=>X(e)?a.some(e=>/page_count_custom|自定义页数|其他页数/.test(J(e)))?[e]:[e,{id:`page_count_custom`,label:`如果选择“其他”，请填写页数`,type:`text`,placeholder:`例如：3页、12页、只做封面+2页内容`}]:[e]);return{...e,questions:o}};function se(e={}){let t=e.storageKey||L,[n,r]=(0,x.useState)(()=>({turns:B(t),streaming:!1,streamText:``,streamThinking:``,streamToolSteps:[],error:``,currentRequestId:``})),i=(0,x.useRef)(null),{begin:o,captureRequestId:s,finish:c,reset:l}=y({rangeDays:1,pageSize:200,attempts:8,retryDelayMs:800});(0,x.useEffect)(()=>{V(n.turns,t)},[n.turns,t]);let u=(0,x.useCallback)(async e=>{if(!e.trim()||n.streaming)return;let t={id:I(),role:`user`,content:e.trim(),timestamp:Date.now()};r(e=>({...e,turns:[...e.turns,t],streaming:!0,streamText:``,streamThinking:``,streamToolSteps:[],error:``})),d(e.trim())},[n.streaming]),d=(0,x.useCallback)(async(e,t)=>{r(e=>({...e,streaming:!0,streamText:``,streamThinking:``,streamToolSteps:[],error:``})),l();let u=new AbortController;i.current=u;try{let i=await a();if(!i?.token){r(e=>({...e,streaming:!1,error:`请先登录`}));return}let l=z(),d=te();r(e=>({...e,currentRequestId:d}));let f=K(n.turns);await o(),s({requestId:d});let p=await fetch(l,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`text/event-stream`,"x-auth-token":i.token,"x-ol-request-id":d},body:JSON.stringify({op:`ppt_generation_agent`,requestId:d,data:{userInput:e,context:f,planCount:`single`,phase:t||`chat`}}),signal:u.signal});if(!p.ok){let e=await p.text(),t=`请求失败`;try{t=JSON.parse(e)?.message||t}catch{}r(e=>({...e,streaming:!1,error:t}));return}let m=p.body?.getReader();if(!m){r(e=>({...e,streaming:!1,error:`无法读取响应`}));return}let h=new TextDecoder,g=``,_=``,v=``,y=[],b=-1;for(;!u.signal.aborted;){let{done:e,value:t}=await m.read();if(e)break;g+=h.decode(t,{stream:!0});let n;for(;(n=g.indexOf(`

`))>=0;){let e=g.slice(0,n);g=g.slice(n+2);for(let t of e.split(`
`)){if(!t.startsWith(`data: `))continue;let e=t.slice(6);if(e===`[DONE]`)break;let n;try{n=JSON.parse(e)}catch{continue}if(n.type===`start`&&n.requestId)s({requestId:String(n.requestId)});else if(n.type===`tool_start`)y=[...y.filter(e=>e.tool!==n.tool),{tool:n.tool,status:`running`}],r(e=>({...e,streamToolSteps:y}));else if(n.type===`tool_done`)y=y.map(e=>e.tool===n.tool?{...e,status:`done`}:e),r(e=>({...e,streamToolSteps:y}));else if(n.type===`delta`){let e=n.delta||``,t=n.thinking||``;e&&(_+=e,r(e=>({...e,streamText:_}))),t&&(v+=t,r(e=>({...e,streamThinking:v})))}else n.type===`generation_incomplete`?b=n.completionRatio??.5:n.type===`done`?n.requestId&&s({requestId:String(n.requestId)}):(n.type===`error`||n.error)&&r(e=>({...e,error:n.message||`生成失败`}))}}}if(!u.signal.aborted&&_){let{html:i,completionRatio:a}=H(_),{form:o,cleanText:s}=U(_),l=[...n.turns,{id:`current`,role:`user`,content:e,timestamp:Date.now()}],u=o?oe(o,l):null,d=s;i&&(d=d.replace(i,``).replace(/```html[\s\S]*?```/g,``).trim()||`已为你生成 HTML 演示文稿`);let f=q(t,i,e),p=b>=0||a>0&&a<1||f,m=b>=0?b:f?.35:a,h=t===`preview`||!!i&&t!==`full`&&W(i)<=1&&ae(u),g=t===`full`,v={id:I(),role:`assistant`,content:h?`已为你生成封面预览：`:g?`已为你生成完整演示文稿：`:d,html:i,previewMode:h||void 0,confirmed:g||void 0,questionForm:u||void 0,incompleteGeneration:p||void 0,completionRatio:p?m:void 0,toolSteps:y.length>0?y:void 0,billing:null,timestamp:Date.now()};r(e=>({...e,turns:[...e.turns,v],streaming:!1,streamText:``,streamThinking:``,streamToolSteps:[]})),c({aggregateAllNew:!0}).then(e=>{e&&r(t=>({...t,turns:t.turns.map(t=>t.id===v.id?{...t,billing:e}:t)}))}).catch(()=>{})}else r(e=>({...e,streaming:!1,streamText:``,streamThinking:``,streamToolSteps:[]}))}catch(e){if(await c({aggregateAllNew:!0}),e?.name===`AbortError`){r(e=>({...e,streaming:!1}));return}r(t=>({...t,streaming:!1,error:String(e?.message||`网络错误`)}))}},[o,s,c,l,n.turns]);return{state:n,send:u,sendFull:(0,x.useCallback)(e=>{if(!e.trim()||n.streaming)return;let t={id:I(),role:`user`,content:e.trim(),timestamp:Date.now()};r(e=>({...e,turns:[...e.turns,t],streaming:!0,streamText:``,streamThinking:``,streamToolSteps:[],error:``})),d(e.trim(),`full`)},[d,n.streaming]),cancel:(0,x.useCallback)(()=>{i.current?.abort(),r(e=>({...e,streaming:!1}))},[]),reset:(0,x.useCallback)(()=>{i.current?.abort(),l(),sessionStorage.removeItem(t),r({turns:[],streaming:!1,streamText:``,streamThinking:``,streamToolSteps:[],error:``,currentRequestId:``})},[l,t]),regenerate:(0,x.useCallback)(()=>{let e=n.turns.map(e=>e.role).lastIndexOf(`user`);if(e<0)return;let t=n.turns[e].content;r(t=>({...t,turns:t.turns.slice(0,e)})),setTimeout(()=>{u(t)},50)},[n.turns,u]),regeneratePreview:(0,x.useCallback)(e=>{if(n.streaming)return;let t=n.turns.filter(e=>e.role===`user`).map(e=>e.content).join(`
`),i=`用户要求更换风格为：${e}。请重新生成封面预览 HTML，使用新风格"${e}"。`,a={id:I(),role:`user`,content:`换风格 -> ${e}`,timestamp:Date.now()};r(e=>({...e,turns:[...e.turns,a]})),setTimeout(()=>{d(t+`
`+i,`preview`)},50)},[n.turns,n.streaming]),confirmGenerate:(0,x.useCallback)(e=>{if(n.streaming)return;r(t=>({...t,turns:t.turns.map(t=>t.id===e?{...t,confirmed:!0}:t)}));let t=n.turns.filter(e=>e.role===`user`).map(e=>e.content).join(`
`)+`
用户已确认预览风格，请直接生成完整的多页 HTML 演示文稿（跳过追问和大纲步骤，直接输出完整 HTML 代码）。`;setTimeout(()=>{d(t,`full`)},50)},[n.turns,n.streaming]),continueGeneration:(0,x.useCallback)(e=>{if(n.streaming)return;let t=n.turns.find(t=>t.id===e);if(!t?.html&&!t?.content)return;let i=n.turns.filter(e=>e.role===`user`).map(e=>e.content).join(`
`),a=t.html?G(t.html):t.content.slice(0,4e4),o=[i,``,`上一次完整 PPT 生成被截断，完成度约 ${t.completionRatio?`${Math.round(t.completionRatio*100)}%`:`未完成`}。请基于下面已有输出生成一份补全后的完整 HTML 演示文稿。`,`要求：保留已有页面内容、数据结论和视觉风格，补齐缺失页面；输出完整 <!DOCTYPE html> 到 </html>，不要只输出说明文字，不要要求用户重新提供素材。`,``,t.html?`[已有 HTML]`:`[已有中断输出]`,a].join(`
`),s={id:I(),role:`user`,content:`继续补完整 PPT`,timestamp:Date.now()};r(e=>({...e,turns:[...e.turns,s],streaming:!0,streamText:``,streamThinking:``,streamToolSteps:[],error:``})),setTimeout(()=>{d(o,`full`)},50)},[d,n.streaming,n.turns])}}var Z=n();function ce(e){let t=e.split(`
`),n=[],r=[],i=()=>{r.length!==0&&(n.push((0,Z.jsx)(`ul`,{style:{margin:`6px 0 6px 20px`,padding:0},children:r.map((e,t)=>(0,Z.jsx)(`li`,{style:{marginBottom:3},children:Q(e)},t))},`ul-${n.length}`)),r=[])};return t.forEach((e,t)=>{let a=e.trimEnd(),o=a.match(/^\s*[-*]\s+(.+)$/);if(o){r.push(o[1]);return}if(i(),!a.trim()){n.push((0,Z.jsx)(`div`,{style:{height:6}},`br-${t}`));return}if(/^[-*_]{3,}\s*$/.test(a.trim())){n.push((0,Z.jsx)(`div`,{style:{height:1,background:`var(--border-soft, rgba(148,163,184,0.3))`,margin:`8px 0`}},`hr-${t}`));return}let s=a.match(/^(#{1,4})\s+(.+)$/);if(s){let e=s[1].length;n.push((0,Z.jsx)(`div`,{style:{fontWeight:700,fontSize:[16,15,14,13][e-1]||14,margin:`6px 0 4px`,color:`var(--ds-text-primary)`},children:Q(s[2])},`h-${t}`));return}let c=a.match(/^\s*(\d+)[.)]\s+(.+)$/);if(c){n.push((0,Z.jsxs)(`div`,{style:{display:`flex`,gap:6,marginBottom:2},children:[(0,Z.jsxs)(`span`,{style:{fontWeight:600,minWidth:16},children:[c[1],`.`]}),(0,Z.jsx)(`span`,{children:Q(c[2])})]},`n-${t}`));return}n.push((0,Z.jsx)(`div`,{style:{marginBottom:2},children:Q(a)},`p-${t}`))}),i(),n}function Q(e){let t=[],n=/\*\*([^*]+)\*\*/g,r=0,i,a=0;for(;(i=n.exec(e))!==null;)i.index>r&&t.push(e.slice(r,i.index)),t.push((0,Z.jsx)(`strong`,{style:{fontWeight:700},children:i[1]},a++)),r=i.index+i[0].length;return r<e.length&&t.push(e.slice(r)),t.length>0?t:e}var $=`<style id="hireedge-ppt-preview-guard">.export-toolbar{display:none!important}</style>`,le=e=>/<\/head>/i.test(e)?e.replace(/<\/head>/i,`${$}\n</head>`):e.replace(/<body/i,`${$}\n<body`),ue=e=>e?(e.match(/<section/g)||[]).length:0,de=[`商务专业（沉稳大气）`,`创意活力（年轻冲击）`,`极简清新（简洁留白）`,`暗色科技（深色背景+光效）`,`优雅文艺（衬线字体+暖色）`,`霓虹赛博（深蓝+荧光）`];function fe({onSelect:e,onClose:t}){return(0,Z.jsxs)(`div`,{style:{marginTop:8,padding:`10px 12px`,borderRadius:`var(--ds-radius-sm)`,border:`1px solid var(--ds-border-default)`,background:`var(--ds-bg-surface)`},children:[(0,Z.jsx)(`div`,{style:{fontSize:12,fontWeight:600,color:`var(--ds-text-secondary)`,marginBottom:8},children:`选择新风格（会重新生成预览，消耗积分）`}),(0,Z.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6},children:de.map(t=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>e(t),className:`ds-btn ds-btn-secondary`,style:{padding:`5px 10px`,fontSize:11},children:t},t))}),(0,Z.jsx)(`button`,{type:`button`,onClick:t,style:{marginTop:8,padding:`4px 10px`,fontSize:11,color:`var(--ds-text-muted)`,background:`none`,border:`none`,cursor:`pointer`},children:`取消`})]})}function pe({turn:e,onDownload:t,onExportPdf:n,onExportPptx:r,onSubmitForm:i,onRegenerate:a,onRegeneratePreview:o,onConfirmGenerate:d,onContinue:f,isLast:m,streaming:h}){let g=(0,x.useRef)(null),[_,v]=(0,x.useState)(!1),[y,S]=(0,x.useState)(!1),C=e.role===`user`,w=m&&!h&&!C&&e.html,T=!!e.html&&!e.previewMode;return(0,Z.jsx)(`div`,{style:{padding:`8px 20px`,display:`flex`,justifyContent:C?`flex-end`:`flex-start`},children:(0,Z.jsxs)(`div`,{style:{maxWidth:C?`70%`:e.html?`100%`:`90%`,borderRadius:`var(--ds-radius-md)`,padding:C?`10px 16px`:`14px 18px`,background:C?`var(--ds-brand)`:`var(--ds-bg-subtle)`,color:C?`var(--ds-text-on-brand)`:`var(--ds-text-primary)`,fontSize:14,lineHeight:1.6},children:[C?(0,Z.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:e.content}):ce(e.content),C?null:(0,Z.jsx)(p,{billing:e.billing,label:e.html?`本次 PPT 生成`:`本轮`}),e.questionForm&&(0,Z.jsx)(me,{form:e.questionForm,onSubmit:t=>i(e.questionForm,t)}),!C&&e.incompleteGeneration&&(0,Z.jsxs)(`div`,{style:{padding:`10px 14px`,borderRadius:`var(--ds-radius-sm)`,background:`rgba(245,158,11,0.1)`,border:`1px solid rgba(245,158,11,0.3)`,color:`#b45309`,fontSize:13,marginTop:10,marginBottom:10,display:`flex`,alignItems:`center`,gap:8},children:[(0,Z.jsxs)(`span`,{children:[`生成未完全完成（约 `,Math.round((e.completionRatio||0)*100),`%），部分内容可能缺失。已按比例扣分。`]}),f?(0,Z.jsx)(`button`,{type:`button`,onClick:f,disabled:h,style:{marginLeft:`auto`,textDecoration:`underline`,cursor:`pointer`,background:`none`,border:`none`,color:`inherit`,fontSize:13},children:`继续生成`}):null,(0,Z.jsx)(`button`,{type:`button`,onClick:a,style:{textDecoration:`underline`,cursor:`pointer`,background:`none`,border:`none`,color:`inherit`,fontSize:13},children:`重新生成`})]}),e.html&&(0,Z.jsxs)(`div`,{style:{marginTop:12},children:[e.previewMode&&(0,Z.jsx)(`div`,{style:{fontSize:13,fontWeight:600,marginBottom:8,color:`var(--ds-text-primary)`},children:`封面预览（1 页）`}),T&&(0,Z.jsxs)(`div`,{style:{fontSize:13,fontWeight:600,marginBottom:8,color:`var(--ds-text-primary)`},children:[`完整版（`,ue(e.html),` 页）`]}),(0,Z.jsx)(`div`,{ref:g,style:{borderRadius:`var(--ds-radius-md)`,overflow:`hidden`,border:`1px solid var(--ds-border-default)`,width:`100%`,aspectRatio:`16/9`,marginBottom:10},children:(0,Z.jsx)(`iframe`,{srcDoc:e.previewMode?le(e.html):e.html,title:`PPT`,style:{width:`100%`,height:`100%`,border:`none`,display:`block`},sandbox:`allow-scripts allow-downloads allow-modals`})}),T&&(0,Z.jsx)(`div`,{style:{fontSize:11,color:`var(--ds-text-muted)`,marginBottom:8},children:`点击全屏查看全部页面，可用方向键翻页；导出 PDF 时请在打印窗口选择“另存为 PDF”。`}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`},children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>g.current?.requestFullscreen?.(),className:`ds-btn ds-btn-secondary`,style:{padding:`5px 10px`,fontSize:12,display:`flex`,alignItems:`center`,gap:4},children:[(0,Z.jsx)(b,{size:12}),` 全屏`]}),e.previewMode&&!e.confirmed&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>v(!_),className:`ds-btn ds-btn-secondary`,style:{padding:`5px 10px`,fontSize:12,display:`flex`,alignItems:`center`,gap:4},children:[(0,Z.jsx)(u,{size:12}),` 换风格`]}),(0,Z.jsx)(`button`,{type:`button`,onClick:d,disabled:h,className:`ds-btn ds-btn-primary`,style:{padding:`5px 14px`,fontSize:12},children:`确认，生成完整版`})]}),T&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{style:{position:`relative`},children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>S(e=>!e),className:`ds-btn ds-btn-primary`,style:{padding:`5px 10px`,fontSize:12,display:`flex`,alignItems:`center`,gap:4},children:[(0,Z.jsx)(s,{size:12}),` 下载/导出`]}),y&&(0,Z.jsxs)(`div`,{style:{position:`absolute`,top:`calc(100% + 6px)`,left:0,zIndex:20,minWidth:128,padding:6,borderRadius:`var(--ds-radius-sm)`,border:`1px solid var(--ds-border-default)`,background:`var(--ds-bg-surface)`,boxShadow:`var(--ds-shadow-md)`},children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{S(!1),r(e.html,e.content.slice(0,30))},style:{display:`block`,width:`100%`,padding:`7px 10px`,border:0,borderRadius:`var(--ds-radius-xs)`,background:`transparent`,color:`var(--ds-text-primary)`,fontSize:12,textAlign:`left`,cursor:`pointer`},children:`PPTX（可编辑）`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{S(!1),t(e.html,e.content.slice(0,30))},style:{display:`block`,width:`100%`,padding:`7px 10px`,border:0,borderRadius:`var(--ds-radius-xs)`,background:`transparent`,color:`var(--ds-text-primary)`,fontSize:12,textAlign:`left`,cursor:`pointer`},children:`HTML 文件`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{S(!1),n(e.html)},style:{display:`block`,width:`100%`,padding:`7px 10px`,border:0,borderRadius:`var(--ds-radius-xs)`,background:`transparent`,color:`var(--ds-text-primary)`,fontSize:12,textAlign:`left`,cursor:`pointer`},children:`PDF（打印另存）`})]})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>r(e.html,e.content.slice(0,30)),className:`ds-btn ds-btn-secondary`,style:{padding:`5px 10px`,fontSize:12,display:`flex`,alignItems:`center`,gap:4},children:[(0,Z.jsx)(c,{size:12}),` PPTX`]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>n(e.html),className:`ds-btn ds-btn-secondary`,style:{padding:`5px 10px`,fontSize:12,display:`flex`,alignItems:`center`,gap:4},children:[(0,Z.jsx)(l,{size:12}),` 打印/PDF`]})]}),w&&(0,Z.jsxs)(`button`,{type:`button`,onClick:a,className:`ds-btn ds-btn-secondary`,style:{padding:`5px 10px`,fontSize:12,display:`flex`,alignItems:`center`,gap:4},children:[(0,Z.jsx)(u,{size:12}),` 重新生成`]})]}),_&&(0,Z.jsx)(fe,{onSelect:e=>{v(!1),o(e)},onClose:()=>v(!1)})]}),w&&!e.html&&(0,Z.jsx)(`div`,{style:{marginTop:10},children:(0,Z.jsxs)(`button`,{type:`button`,onClick:a,className:`ds-btn ds-btn-secondary`,style:{padding:`5px 10px`,fontSize:12,display:`flex`,alignItems:`center`,gap:4},children:[(0,Z.jsx)(u,{size:12}),` 重新生成`]})})]})})}function me({form:e,onSubmit:t}){let[n,r]=(0,x.useState)({}),[i,a]=(0,x.useState)(!1),o=(e,t)=>r(n=>({...n,[e]:t})),s=(e,t)=>r(n=>{let r=n[e]||[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}}),c=(e,t)=>r(n=>({...n,[e]:t})),l=e.questions.every(t=>{if(t.type===`text`){if(/page_count_custom|自定义页数|其他页数/.test(`${t.id||``}${t.label||``}`)){let r=e.questions.find(e=>/page|length|slide|count|页数|几页|页面数量|篇幅|长度/.test(`${e.id||``}${e.label||``}`.toLowerCase())),i=r?n[r.id]:void 0;return!(Array.isArray(i)?i.some(e=>/其他|自定义/i.test(e)):/其他|自定义/i.test(String(i||``)))||!!String(n[t.id]||``).trim()}return!0}let r=n[t.id];return t.type===`multi`?Array.isArray(r)&&r.length>0:!!r}),u=()=>{i||(a(!0),t(n))},d=e.questions.length===1&&/audience|受众|演示给谁看/.test(`${e.questions[0]?.id||``}${e.questions[0]?.label||``}`)?`继续填写制作要求`:`开始生成 PPT`;return(0,Z.jsxs)(`div`,{style:{marginTop:14},children:[e.intro&&(0,Z.jsx)(`div`,{style:{fontSize:13,color:`var(--ds-text-secondary)`,marginBottom:12,lineHeight:1.6},children:e.intro}),(0,Z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:e.questions.map((e,t)=>(0,Z.jsxs)(`div`,{style:{padding:`14px 16px`,borderRadius:`var(--ds-radius-md)`,background:`var(--ds-bg-surface)`,border:`1px solid var(--ds-border-default)`,boxShadow:`var(--ds-shadow-xs)`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,Z.jsx)(`span`,{style:{width:22,height:22,borderRadius:`50%`,background:`var(--ds-bg-brand-subtle)`,color:`var(--ds-brand)`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,fontSize:11,fontWeight:700,flexShrink:0},children:t+1}),(0,Z.jsxs)(`div`,{style:{fontSize:13,fontWeight:600,color:`var(--ds-text-primary)`},children:[e.label,e.type===`multi`&&(0,Z.jsx)(`span`,{style:{fontWeight:400,fontSize:11,color:`var(--ds-text-muted)`,marginLeft:6},children:`（可多选）`}),e.type===`text`&&(0,Z.jsx)(`span`,{style:{fontWeight:400,fontSize:11,color:`var(--ds-text-muted)`,marginLeft:6},children:`（选填）`})]})]}),(e.type===`single`||e.type===`multi`)&&e.options&&(0,Z.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6,paddingLeft:30},children:e.options.map(t=>{let r=e.type===`multi`,a=r?Array.isArray(n[e.id])&&n[e.id].includes(t):n[e.id]===t;return(0,Z.jsx)(`button`,{type:`button`,disabled:i,onClick:()=>r?s(e.id,t):o(e.id,t),style:{padding:`7px 14px`,borderRadius:`var(--ds-radius-pill)`,border:a?`1.5px solid var(--ds-brand)`:`1px solid var(--ds-border-default)`,background:a?`var(--ds-bg-brand-subtle)`:`var(--ds-bg-surface)`,color:a?`var(--ds-brand)`:`var(--ds-text-secondary)`,fontSize:12,fontWeight:a?600:400,cursor:i?`not-allowed`:`pointer`,opacity:i?.6:1,transition:`all var(--ds-duration-fast) var(--ds-ease-out)`},children:t},t)})}),e.type===`text`&&(0,Z.jsx)(`input`,{type:`text`,value:n[e.id]||``,onChange:t=>c(e.id,t.target.value),placeholder:e.placeholder||`可选`,disabled:i,style:{width:`calc(100% - 30px)`,marginLeft:30,padding:`8px 12px`,borderRadius:`var(--ds-radius-sm)`,border:`1px solid var(--ds-border-default)`,background:`var(--ds-bg-surface)`,color:`var(--ds-text-primary)`,fontSize:13,opacity:i?.6:1}})]},e.id))}),(0,Z.jsx)(`button`,{type:`button`,onClick:u,disabled:!l||i,className:`ds-btn ds-btn-primary`,style:{marginTop:14,padding:`9px 20px`,fontSize:13,opacity:!l||i?.5:1,cursor:!l||i?`not-allowed`:`pointer`},children:i?`已提交`:d})]})}var he=e=>{if(e.questions.length!==1)return!1;let t=e.questions[0];return/audience|受众|演示给谁看|听众|观众/.test(`${t.id||``}${t.label||``}`)};function ge(){let e=i(),[t,n]=(0,x.useState)(!0),[r,o]=(0,x.useState)(``),[s,c]=(0,x.useState)(``),{state:l,send:u,cancel:p,reset:y,regenerate:b,regeneratePreview:S,confirmGenerate:T,continueGeneration:E}=se({storageKey:`hireedge_hr_ppt_turns`}),D=(0,x.useRef)(null);(0,x.useEffect)(()=>{let t=!0;return(async()=>{let r=await a();if(t){if(!r?.token){e(`/auth?returnTo=%2Fhr%2Fppt-builder`);return}n(!1)}})(),()=>{t=!1,p()}},[p,e]),(0,x.useEffect)(()=>{D.current?.scrollTo({top:D.current.scrollHeight,behavior:`smooth`})},[l.turns,l.streamText]),(0,x.useEffect)(()=>{let e=g();e&&(h(),y(),o(_(e)),c(`已带入 ${e.fileName||`HR 数据分析`} 的分析素材，可直接发送开始制作 PPT。`))},[y]);let O=()=>{!r.trim()||l.streaming||(u(r.trim()),o(``))},k=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),O())},A=(e,t)=>{let n=C(e),r=new Blob([n],{type:`text/html;charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`${w(n,t)}.html`,document.body.appendChild(a),a.click(),document.body.removeChild(a),window.setTimeout(()=>URL.revokeObjectURL(i),1e3)},j=(e,t)=>{ee(e,t).catch(()=>{window.alert(`PPTX 导出失败，请先下载 HTML 或 PDF。`)})},M=e=>{let t=C(e),n=window.open(``,`_blank`);if(!n){let e=document.createElement(`iframe`);e.style.position=`fixed`,e.style.right=`0`,e.style.bottom=`0`,e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.onload=()=>{window.setTimeout(()=>{try{e.contentWindow?.focus()}catch{}try{e.contentWindow?.print()}catch{}window.setTimeout(()=>e.remove(),1e3)},500)},document.body.appendChild(e),e.contentDocument?.open(),e.contentDocument?.write(t),e.contentDocument?.close();return}n.document.open(),n.document.write(t),n.document.close(),window.setTimeout(()=>{try{n.focus()}catch{}try{n.print()}catch{}},500)},N=(e,t)=>{let n=e.questions.map(e=>{let n=t[e.id];if(!n||Array.isArray(n)&&n.length===0)return null;let r=Array.isArray(n)?n.join(`、`):n;return`${e.label}：${r}`}).filter(Boolean);if(n.length===0)return;let r=n.join(`
`);u(he(e)?`${r}\n请根据这个受众继续生成后续制作要求表单，暂时不要生成大纲。`:r)};if(t)return(0,Z.jsx)(m,{children:(0,Z.jsx)(`p`,{className:`hr-page-sub`,children:`正在加载...`})});let P=l.turns.length===0&&!l.streaming;return(0,Z.jsxs)(m,{children:[(0,Z.jsxs)(`div`,{className:`hr-page-header`,children:[(0,Z.jsx)(`h1`,{className:`hr-page-title`,children:`HR PPT生成`}),(0,Z.jsx)(`p`,{className:`hr-page-sub`,children:`使用完整 PPT 生成流程：先确认受众和要求，再生成预览，确认后生成完整 HTML 演示文稿。`}),s?(0,Z.jsx)(`p`,{className:`hr-inline-note`,children:s}):null]}),(0,Z.jsxs)(`section`,{className:`hr-ppt-chat-panel`,children:[(0,Z.jsxs)(`div`,{ref:D,className:`hr-ppt-chat-scroll`,children:[P?(0,Z.jsxs)(`div`,{className:`hr-ppt-empty`,children:[(0,Z.jsx)(`h2`,{children:`告诉我你要做什么 HR PPT`}),(0,Z.jsx)(`p`,{children:`例如：招聘周报、面试复盘、薪资调研汇报、培训宣讲、岗位分析汇报。`})]}):null,l.turns.map((e,t)=>(0,Z.jsx)(pe,{turn:e,onDownload:A,onExportPdf:M,onExportPptx:j,onSubmitForm:N,onRegenerate:b,onRegeneratePreview:S,onConfirmGenerate:()=>T(e.id),onContinue:()=>E(e.id),isLast:t===l.turns.length-1,streaming:l.streaming},e.id)),l.streaming?(0,Z.jsx)(`div`,{className:`hr-ppt-stream`,children:(0,Z.jsx)(v,{assistantLabel:`PPT 设计师`,busy:l.streaming,streamText:l.streamText,streamThinking:l.streamThinking,agentMode:!0,agentText:l.streamText,agentSteps:l.streamToolSteps,stepLabels:{orchestrator:`AI 思考`,frontend_slides:`PPT 规范加载`,pptx_generator:`大纲生成`,frontend_dev:`HTML 生成`},emptyText:`正在生成演示文稿...`,fullWidth:!0})}):null]}),l.error?(0,Z.jsx)(`p`,{className:`hr-error hr-ppt-error`,children:l.error}):null,(0,Z.jsxs)(`div`,{className:`hr-ppt-composer`,children:[(0,Z.jsx)(`textarea`,{value:r,onChange:e=>o(e.target.value),onKeyDown:k,placeholder:`描述你想做的 HR 演示文稿...`,rows:1}),l.streaming?(0,Z.jsx)(`button`,{type:`button`,onClick:p,className:`hr-btn-ghost`,children:`停止`}):(0,Z.jsx)(`button`,{type:`button`,onClick:O,disabled:!r.trim(),className:`hr-btn-primary`,"aria-label":`发送`,children:(0,Z.jsx)(f,{size:16})}),l.turns.length>0&&!l.streaming?(0,Z.jsx)(`button`,{type:`button`,onClick:y,className:`hr-btn-ghost`,title:`重新开始`,"aria-label":`重新开始`,children:(0,Z.jsx)(d,{size:16})}):null]})]})]})}export{ge as default};