import{a as e,n as t,t as n}from"./jsx-runtime-CutOxEx1.js";import{l as r}from"./chunk-6CSD65Y2-BjfinoX-.js";import{r as i}from"./authSession-Dulxhbeq.js";import{t as a}from"./createLucideIcon-D6B-X28I.js";import{t as o}from"./download-BtyQsy17.js";import{t as s}from"./printer-xRe3kO9b.js";import{t as c}from"./refresh-cw-DzeRqf3I.js";import{t as l}from"./rotate-ccw-CWKCobgh.js";import{t as u}from"./send-D2dk6kZF.js";import{t as d}from"./PlatformTokenUsage-BOBT9r1m.js";import{t as f}from"./HrShell-ToXdRH2L.js";import{n as p,r as m,t as h}from"./hrPptHandoff-CpxrwDXl.js";import"./ToolSidebarNav-Py6lZOex.js";import{t as g}from"./ToolLiveStreamPanel-DOjuHZof.js";import{t as _}from"./usePlatformTokenUsage-D1OWw-XN.js";var v=a(`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`}]]),y=e(t(),1),b=`
<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>`,x=e=>{let t=e.replace(/<style id=["']hireedge-ppt-print-fix["'][\s\S]*?<\/style>/gi,``);return/<\/head>/i.test(t)?t.replace(/<\/head>/i,`${b}\n</head>`):t.replace(/<body/i,`${b}\n<body`)},S=(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`,C=()=>`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,w=()=>{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)}},T=`hireedge_ppt_turns`,E=`https://api2.bysjob.com`,D=()=>{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`${E}/api/llm/op`},O=(e=T)=>{try{if(performance.getEntriesByType(`navigation`)[0]?.type===`reload`)return sessionStorage.removeItem(e),[];let t=sessionStorage.getItem(e);return t?JSON.parse(t):[]}catch{return[]}},k=(e,t=T)=>{try{sessionStorage.setItem(t,JSON.stringify(e))}catch{}},A=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}},j=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}},M=e=>e?(e.match(/<section\b/gi)||[]).length:0,N=e=>{let t=String(e||``);return t.length<=6e4?t:[t.slice(0,3e4),`
<!-- 中间内容已省略；请保留已有结构、视觉风格和页码顺序，并按尾部继续补全 -->
`,t.slice(-25e3)].join(``)},P=e=>e.slice(-24).map(e=>{let t=e.role===`user`?`用户`:`AI`,n=e.html?`\n[HTML页数] ${M(e.html)} 页${e.incompleteGeneration?`，上次生成未完成`:``}`:``;return`${t}：${e.content.slice(0,3e3)}${n}`}).join(`

`),F=(e,t,n)=>e!==`full`||!t||M(t)>1?!1:!/(?:1\s*页|一页|单页|只做封面|封面预览)/.test(n),I=[`候选人/面试对象`,`HR/招聘团队`,`用人经理/业务负责人`,`公司管理层`,`投资人/VC`,`客户/合作方`,`普通观众`,`其他`],L=[`2-3页（快速体验）`,`5-7页`,`8-10页`,`10-15页`,`其他（自定义）`],R=e=>`${e.id||``} ${e.label||``}`.toLowerCase(),z=e=>/audience|受众|演示给谁看|听众|观众/.test(R(e)),B=e=>/page|length|slide|count|页数|几页|页面数量|篇幅|长度/.test(R(e)),V=e=>e.some(e=>e.role===`user`&&/演示给谁看[？?]?\s*[：:]|受众\s*[：:]|audience\s*[：:]/i.test(e.content)),H=e=>e?e.questions.some(e=>/color_confirm|style_confirm|preview_confirm|风格确认|配色确认|预览|封面/.test(`${e.id||``}${e.label||``}`)):!1,U=(e,t)=>{let n=V(t),r=e.questions.map(e=>B(e)?{...e,id:e.id||`page_count`,label:e.label||`大概需要多少页？`,type:`single`,options:L}:e),i=r.find(z);if(!n)return{intro:`先确认一个关键问题：这份演示主要给谁看？我会根据受众再继续问制作要求。`,questions:[{...i||{id:`audience`,label:`演示给谁看？`,type:`single`},id:i?.id||`audience`,label:`演示给谁看？`,type:`single`,options:i?.options?.length?i.options:I}]};let a=r.filter(e=>!z(e)),o=a.flatMap(e=>B(e)?a.some(e=>/page_count_custom|自定义页数|其他页数/.test(R(e)))?[e]:[e,{id:`page_count_custom`,label:`如果选择“其他”，请填写页数`,type:`text`,placeholder:`例如：3页、12页、只做封面+2页内容`}]:[e]);return{...e,questions:o}};function W(e={}){let t=e.storageKey||T,[n,r]=(0,y.useState)(()=>({turns:O(t),streaming:!1,streamText:``,streamThinking:``,streamToolSteps:[],error:``,currentRequestId:``})),a=(0,y.useRef)(null),{begin:o,captureRequestId:s,finish:c,reset:l}=_({rangeDays:1,pageSize:200,attempts:8,retryDelayMs:800});(0,y.useEffect)(()=>{k(n.turns,t)},[n.turns,t]);let u=(0,y.useCallback)(async e=>{if(!e.trim()||n.streaming)return;let t={id:C(),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,y.useCallback)(async(e,t)=>{r(e=>({...e,streaming:!0,streamText:``,streamThinking:``,streamToolSteps:[],error:``})),l();let u=new AbortController;a.current=u;try{let a=await i();if(!a?.token){r(e=>({...e,streaming:!1,error:`请先登录`}));return}let l=D(),d=w();r(e=>({...e,currentRequestId:d}));let f=P(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":a.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}=A(_),{form:o,cleanText:s}=j(_),l=[...n.turns,{id:`current`,role:`user`,content:e,timestamp:Date.now()}],u=o?U(o,l):null,d=s;i&&(d=d.replace(i,``).replace(/```html[\s\S]*?```/g,``).trim()||`已为你生成 HTML 演示文稿`);let f=F(t,i,e),p=b>=0||a>0&&a<1||f,m=b>=0?b:f?.35:a,h=t===`preview`||!!i&&t!==`full`&&M(i)<=1&&H(u),g=t===`full`,v={id:C(),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,y.useCallback)(e=>{if(!e.trim()||n.streaming)return;let t={id:C(),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,y.useCallback)(()=>{a.current?.abort(),r(e=>({...e,streaming:!1}))},[]),reset:(0,y.useCallback)(()=>{a.current?.abort(),l(),sessionStorage.removeItem(t),r({turns:[],streaming:!1,streamText:``,streamThinking:``,streamToolSteps:[],error:``,currentRequestId:``})},[l,t]),regenerate:(0,y.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,y.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:C(),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,y.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,y.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?N(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:C(),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 G=n();function K(e){let t=e.split(`
`),n=[],r=[],i=()=>{r.length!==0&&(n.push((0,G.jsx)(`ul`,{style:{margin:`6px 0 6px 20px`,padding:0},children:r.map((e,t)=>(0,G.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,G.jsx)(`div`,{style:{height:6}},`br-${t}`));return}if(/^[-*_]{3,}\s*$/.test(a.trim())){n.push((0,G.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,G.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,G.jsxs)(`div`,{style:{display:`flex`,gap:6,marginBottom:2},children:[(0,G.jsxs)(`span`,{style:{fontWeight:600,minWidth:16},children:[c[1],`.`]}),(0,G.jsx)(`span`,{children:q(c[2])})]},`n-${t}`));return}n.push((0,G.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,G.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 J=`<style id="hireedge-ppt-preview-guard">.export-toolbar{display:none!important}</style>`,Y=e=>/<\/head>/i.test(e)?e.replace(/<\/head>/i,`${J}\n</head>`):e.replace(/<body/i,`${J}\n<body`),X=e=>e?(e.match(/<section/g)||[]).length:0,Z=[`商务专业（沉稳大气）`,`创意活力（年轻冲击）`,`极简清新（简洁留白）`,`暗色科技（深色背景+光效）`,`优雅文艺（衬线字体+暖色）`,`霓虹赛博（深蓝+荧光）`];function Q({onSelect:e,onClose:t}){return(0,G.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,G.jsx)(`div`,{style:{fontSize:12,fontWeight:600,color:`var(--ds-text-secondary)`,marginBottom:8},children:`选择新风格（会重新生成预览，消耗积分）`}),(0,G.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6},children:Z.map(t=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>e(t),className:`ds-btn ds-btn-secondary`,style:{padding:`5px 10px`,fontSize:11},children:t},t))}),(0,G.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 $({turn:e,onDownload:t,onExportPdf:n,onSubmitForm:r,onRegenerate:i,onRegeneratePreview:a,onConfirmGenerate:l,onContinue:u,isLast:f,streaming:p}){let m=(0,y.useRef)(null),[h,g]=(0,y.useState)(!1),[_,b]=(0,y.useState)(!1),x=e.role===`user`,S=f&&!p&&!x&&e.html,C=!!e.html&&!e.previewMode;return(0,G.jsx)(`div`,{style:{padding:`8px 20px`,display:`flex`,justifyContent:x?`flex-end`:`flex-start`},children:(0,G.jsxs)(`div`,{style:{maxWidth:x?`70%`:e.html?`100%`:`90%`,borderRadius:`var(--ds-radius-md)`,padding:x?`10px 16px`:`14px 18px`,background:x?`var(--ds-brand)`:`var(--ds-bg-subtle)`,color:x?`var(--ds-text-on-brand)`:`var(--ds-text-primary)`,fontSize:14,lineHeight:1.6},children:[x?(0,G.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:e.content}):K(e.content),x?null:(0,G.jsx)(d,{billing:e.billing,label:e.html?`本次 PPT 生成`:`本轮`}),e.questionForm&&(0,G.jsx)(ee,{form:e.questionForm,onSubmit:t=>r(e.questionForm,t)}),!x&&e.incompleteGeneration&&(0,G.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,G.jsxs)(`span`,{children:[`生成未完全完成（约 `,Math.round((e.completionRatio||0)*100),`%），部分内容可能缺失。已按比例扣分。`]}),u?(0,G.jsx)(`button`,{type:`button`,onClick:u,disabled:p,style:{marginLeft:`auto`,textDecoration:`underline`,cursor:`pointer`,background:`none`,border:`none`,color:`inherit`,fontSize:13},children:`继续生成`}):null,(0,G.jsx)(`button`,{type:`button`,onClick:i,style:{textDecoration:`underline`,cursor:`pointer`,background:`none`,border:`none`,color:`inherit`,fontSize:13},children:`重新生成`})]}),e.html&&(0,G.jsxs)(`div`,{style:{marginTop:12},children:[e.previewMode&&(0,G.jsx)(`div`,{style:{fontSize:13,fontWeight:600,marginBottom:8,color:`var(--ds-text-primary)`},children:`封面预览（1 页）`}),C&&(0,G.jsxs)(`div`,{style:{fontSize:13,fontWeight:600,marginBottom:8,color:`var(--ds-text-primary)`},children:[`完整版（`,X(e.html),` 页）`]}),(0,G.jsx)(`div`,{ref:m,style:{borderRadius:`var(--ds-radius-md)`,overflow:`hidden`,border:`1px solid var(--ds-border-default)`,width:`100%`,aspectRatio:`16/9`,marginBottom:10},children:(0,G.jsx)(`iframe`,{srcDoc:e.previewMode?Y(e.html):e.html,title:`PPT`,style:{width:`100%`,height:`100%`,border:`none`,display:`block`},sandbox:`allow-scripts allow-downloads allow-modals`})}),C&&(0,G.jsx)(`div`,{style:{fontSize:11,color:`var(--ds-text-muted)`,marginBottom:8},children:`点击全屏查看全部页面，可用方向键翻页；导出 PDF 时请在打印窗口选择“另存为 PDF”。`}),(0,G.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`},children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>m.current?.requestFullscreen?.(),className:`ds-btn ds-btn-secondary`,style:{padding:`5px 10px`,fontSize:12,display:`flex`,alignItems:`center`,gap:4},children:[(0,G.jsx)(v,{size:12}),` 全屏`]}),e.previewMode&&!e.confirmed&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>g(!h),className:`ds-btn ds-btn-secondary`,style:{padding:`5px 10px`,fontSize:12,display:`flex`,alignItems:`center`,gap:4},children:[(0,G.jsx)(c,{size:12}),` 换风格`]}),(0,G.jsx)(`button`,{type:`button`,onClick:l,disabled:p,className:`ds-btn ds-btn-primary`,style:{padding:`5px 14px`,fontSize:12},children:`确认，生成完整版`})]}),C&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{style:{position:`relative`},children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>b(e=>!e),className:`ds-btn ds-btn-primary`,style:{padding:`5px 10px`,fontSize:12,display:`flex`,alignItems:`center`,gap:4},children:[(0,G.jsx)(o,{size:12}),` 下载/导出`]}),_&&(0,G.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,G.jsx)(`button`,{type:`button`,onClick:()=>{b(!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,G.jsx)(`button`,{type:`button`,onClick:()=>{b(!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,G.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,G.jsx)(s,{size:12}),` 打印/PDF`]})]}),S&&(0,G.jsxs)(`button`,{type:`button`,onClick:i,className:`ds-btn ds-btn-secondary`,style:{padding:`5px 10px`,fontSize:12,display:`flex`,alignItems:`center`,gap:4},children:[(0,G.jsx)(c,{size:12}),` 重新生成`]})]}),h&&(0,G.jsx)(Q,{onSelect:e=>{g(!1),a(e)},onClose:()=>g(!1)})]}),S&&!e.html&&(0,G.jsx)(`div`,{style:{marginTop:10},children:(0,G.jsxs)(`button`,{type:`button`,onClick:i,className:`ds-btn ds-btn-secondary`,style:{padding:`5px 10px`,fontSize:12,display:`flex`,alignItems:`center`,gap:4},children:[(0,G.jsx)(c,{size:12}),` 重新生成`]})})]})})}function ee({form:e,onSubmit:t}){let[n,r]=(0,y.useState)({}),[i,a]=(0,y.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,G.jsxs)(`div`,{style:{marginTop:14},children:[e.intro&&(0,G.jsx)(`div`,{style:{fontSize:13,color:`var(--ds-text-secondary)`,marginBottom:12,lineHeight:1.6},children:e.intro}),(0,G.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:e.questions.map((e,t)=>(0,G.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,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,G.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,G.jsxs)(`div`,{style:{fontSize:13,fontWeight:600,color:`var(--ds-text-primary)`},children:[e.label,e.type===`multi`&&(0,G.jsx)(`span`,{style:{fontWeight:400,fontSize:11,color:`var(--ds-text-muted)`,marginLeft:6},children:`（可多选）`}),e.type===`text`&&(0,G.jsx)(`span`,{style:{fontWeight:400,fontSize:11,color:`var(--ds-text-muted)`,marginLeft:6},children:`（选填）`})]})]}),(e.type===`single`||e.type===`multi`)&&e.options&&(0,G.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,G.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,G.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,G.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 te=e=>{if(e.questions.length!==1)return!1;let t=e.questions[0];return/audience|受众|演示给谁看|听众|观众/.test(`${t.id||``}${t.label||``}`)};function ne(){let e=r(),[t,n]=(0,y.useState)(!0),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(``),{state:d,send:_,cancel:v,reset:b,regenerate:C,regeneratePreview:w,confirmGenerate:T,continueGeneration:E}=W({storageKey:`hireedge_hr_ppt_turns`}),D=(0,y.useRef)(null);(0,y.useEffect)(()=>{let t=!0;return(async()=>{let r=await i();if(t){if(!r?.token){e(`/auth?returnTo=%2Fhr%2Fppt-builder`);return}n(!1)}})(),()=>{t=!1,v()}},[v,e]),(0,y.useEffect)(()=>{D.current?.scrollTo({top:D.current.scrollHeight,behavior:`smooth`})},[d.turns,d.streamText]),(0,y.useEffect)(()=>{let e=m();e&&(p(),b(),o(h(e)),c(`已带入 ${e.fileName||`HR 数据分析`} 的分析素材，可直接发送开始制作 PPT。`))},[b]);let O=()=>{!a.trim()||d.streaming||(_(a.trim()),o(``))},k=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),O())},A=(e,t)=>{let n=x(e),r=new Blob([n],{type:`text/html;charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`${S(n,t)}.html`,document.body.appendChild(a),a.click(),document.body.removeChild(a),window.setTimeout(()=>URL.revokeObjectURL(i),1e3)},j=e=>{let t=x(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)},M=(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(`
`);_(te(e)?`${r}\n请根据这个受众继续生成后续制作要求表单，暂时不要生成大纲。`:r)};if(t)return(0,G.jsx)(f,{children:(0,G.jsx)(`p`,{className:`hr-page-sub`,children:`正在加载...`})});let N=d.turns.length===0&&!d.streaming;return(0,G.jsxs)(f,{children:[(0,G.jsxs)(`div`,{className:`hr-page-header`,children:[(0,G.jsx)(`h1`,{className:`hr-page-title`,children:`HR PPT生成`}),(0,G.jsx)(`p`,{className:`hr-page-sub`,children:`使用完整 PPT 生成流程：先确认受众和要求，再生成预览，确认后生成完整 HTML 演示文稿。`}),s?(0,G.jsx)(`p`,{className:`hr-inline-note`,children:s}):null]}),(0,G.jsxs)(`section`,{className:`hr-ppt-chat-panel`,children:[(0,G.jsxs)(`div`,{ref:D,className:`hr-ppt-chat-scroll`,children:[N?(0,G.jsxs)(`div`,{className:`hr-ppt-empty`,children:[(0,G.jsx)(`h2`,{children:`告诉我你要做什么 HR PPT`}),(0,G.jsx)(`p`,{children:`例如：招聘周报、面试复盘、薪资调研汇报、培训宣讲、岗位分析汇报。`})]}):null,d.turns.map((e,t)=>(0,G.jsx)($,{turn:e,onDownload:A,onExportPdf:j,onSubmitForm:M,onRegenerate:C,onRegeneratePreview:w,onConfirmGenerate:()=>T(e.id),onContinue:()=>E(e.id),isLast:t===d.turns.length-1,streaming:d.streaming},e.id)),d.streaming?(0,G.jsx)(`div`,{className:`hr-ppt-stream`,children:(0,G.jsx)(g,{assistantLabel:`PPT 设计师`,busy:d.streaming,streamText:d.streamText,streamThinking:d.streamThinking,agentMode:!0,agentText:d.streamText,agentSteps:d.streamToolSteps,stepLabels:{orchestrator:`AI 思考`,frontend_slides:`PPT 规范加载`,pptx_generator:`大纲生成`,frontend_dev:`HTML 生成`},emptyText:`正在生成演示文稿...`,fullWidth:!0})}):null]}),d.error?(0,G.jsx)(`p`,{className:`hr-error hr-ppt-error`,children:d.error}):null,(0,G.jsxs)(`div`,{className:`hr-ppt-composer`,children:[(0,G.jsx)(`textarea`,{value:a,onChange:e=>o(e.target.value),onKeyDown:k,placeholder:`描述你想做的 HR 演示文稿...`,rows:1}),d.streaming?(0,G.jsx)(`button`,{type:`button`,onClick:v,className:`hr-btn-ghost`,children:`停止`}):(0,G.jsx)(`button`,{type:`button`,onClick:O,disabled:!a.trim(),className:`hr-btn-primary`,"aria-label":`发送`,children:(0,G.jsx)(u,{size:16})}),d.turns.length>0&&!d.streaming?(0,G.jsx)(`button`,{type:`button`,onClick:b,className:`hr-btn-ghost`,title:`重新开始`,"aria-label":`重新开始`,children:(0,G.jsx)(l,{size:16})}):null]})]})]})}export{ne as default};