import{a as e,n as t,t as n}from"./jsx-runtime-CutOxEx1.js";import{c as r,l as i}from"./chunk-6CSD65Y2-BjfinoX-.js";import{i as a,r as o}from"./authSession-Dulxhbeq.js";import{n as s,r as c,t as l}from"./norm-f7iXVy-b.js";import{n as u}from"./runtimeFeatures-DPvDAM4s.js";import{o as d}from"./cloudModel-CkCu0fP6.js";import{n as f,t as p}from"./llmSettings-8VBl-FQI.js";import{t as m}from"./resumeAiConsent-3fYgyUHE.js";import{t as h}from"./exportDomPng-7Vd6Q3rW.js";import{t as g}from"./download-BtyQsy17.js";import{t as _}from"./PlatformTokenUsage-BOBT9r1m.js";import{n as v,t as y}from"./ToolConversationUI-WfmJSuU3.js";import{t as b}from"./FallbackNoticeCard-huoe2-vu.js";import{a as x,n as ee,r as S,t as C}from"./llm-DjSVhhgj.js";import{t as w}from"./privacyMask-RjOeeXKn.js";import{d as T}from"./proxyOps-DSvg656Q.js";import{t as E}from"./roleTaxonomy-BS4qXB9y.js";import{c as D,l as O,n as k,o as A,s as te,t as j,u as ne}from"./toolRuntime-CFu8ZbRX.js";import{n as M,t as N}from"./ToolSidebarNav-Py6lZOex.js";import{t as re}from"./ThinkingPanel-DbDGAOQ7.js";import{t as P}from"./MarkdownText-Du4i1sv4.js";import{t as F}from"./ToolLiveStreamPanel-DOjuHZof.js";import{i as ie,r as ae,t as I}from"./ToolConversationBilling-DMVcVppo.js";import{t as L}from"./universityDictionary-BaVUJ_Wo.js";import"./aiInterviewCoach-dCdPqnwf.js";import{n as oe}from"./aiResumeOptimize-QdaSyeQb.js";import{n as se}from"./aiResumeMatch-Cv_oifLl.js";import{t as R}from"./supportFileText-DOFcXb8H.js";import{n as ce}from"./taskPointGuard-DQLlEFVj.js";import{n as z}from"./toolSkillSummary-BaaCQSOG.js";import{t as le}from"./resumeTranslate-BM5seWc3.js";import{n as B}from"./cloudWorkspaceClient-CCTm89GG.js";import{n as V,o as H,t as U}from"./ToolConversationExecution-Do6biEtR.js";import{n as W,t as G}from"./ComingSoonPanel-fFedT8aH.js";import{n as ue}from"./useToolRunState-BASJ0aoE.js";import{n as de,r as fe,t as pe}from"./ToolConversationHelpers-Cl6_xe6W.js";import{i as me,r as he,t as ge}from"./careerCoachSessionStore-d573rS4S.js";import{t as _e}from"./JdBuzzwordDetector-nBzVD84Q.js";var K=e(t(),1),q=(e,t=8)=>Array.from(new Set((Array.isArray(e)?e:[]).map(e=>c(e)).filter(Boolean))).slice(0,t),ve=`he_career_coach_professional_notice_v1`,ye=(e,t)=>({id:`career_job_${Date.now()}`,title:c(t.targetRole)||`目标岗位`,company:`目标公司`,salary:{min:0,max:0,currency:`CNY`},description:c(e),url:``,platform:`import`,tags:[],location:c(t.location),experience:c(t.yearsExperience),industry:c(t.targetIndustry)}),J=(e,t=1200)=>{let n=c(e);return n?n.length<=t?n:`${n.slice(0,t).trimEnd()}…`:``},be=()=>{try{let e=globalThis?.crypto;if(e?.randomUUID)return String(e.randomUUID())}catch{}return`career_${Date.now()}_${Math.random().toString(16).slice(2,10)}`},Y=e=>Array.isArray(e)?e.slice(0,16).map(e=>({text:c(e?.text).slice(0,1600),thought:!!e?.thought,thoughtSignature:c(e?.thoughtSignature||e?.thought_signature).slice(0,240),functionCall:e?.functionCall&&typeof e.functionCall==`object`?{name:c(e.functionCall?.name).slice(0,120),args:typeof e.functionCall?.args==`string`?c(e.functionCall.args).slice(0,2400):e.functionCall?.args&&typeof e.functionCall.args==`object`?e.functionCall.args:null}:null,functionResponse:e?.functionResponse&&typeof e.functionResponse==`object`?{name:c(e.functionResponse?.name).slice(0,120),response:typeof e.functionResponse?.response==`string`?c(e.functionResponse.response).slice(0,2400):e.functionResponse?.response&&typeof e.functionResponse.response==`object`?e.functionResponse.response:null}:null})):[],X=e=>Array.isArray(e)?e.slice(0,8).map(e=>({id:c(e?.id).slice(0,160),type:c(e?.type).slice(0,40)||`function`,function:e?.function&&typeof e.function==`object`?{name:c(e.function?.name).slice(0,120),arguments:c(e.function?.arguments).slice(0,4e3)}:void 0,extra_content:e?.extra_content&&typeof e.extra_content==`object`?e.extra_content:void 0})):[],xe=e=>(Array.isArray(e)?e:[]).slice(-12).map(e=>({id:c(e.id).slice(0,120),role:e.role,content:c(e.content).slice(0,4e3),createdAt:Number(e.createdAt||0)||Date.now(),reasoningContent:c(e.reasoningContent).slice(0,2400),thoughtSignature:c(e.thoughtSignature).slice(0,240),rawParts:Y(e.rawParts),toolCalls:X(e.toolCalls)})),Se=(e,t)=>q([c(e.targetRole),c(e.targetIndustry),c(e.currentRole),...Array.isArray(e.goals)?e.goals:[],...Array.isArray(e.constraints)?e.constraints:[],...String(t||``).split(/[\s\n、，,；。]/g)].flatMap(e=>{let t=c(e);return!t||t.length<=1?[]:t.length>24?[t.slice(0,24)]:[t]}),8),Ce=e=>q([c(e.currentRole),c(e.targetRole),c(e.yearsExperience),c(e.riskTolerance)],6),we=e=>{let t=c(String(e||``).split(`
`).map(e=>c(e)).filter(Boolean).slice(0,3).join(`；`)||String(e||``).slice(0,140));return t.length<=140?t:`${t.slice(0,140)}…`},Te=e=>{let t=String(e||``).replace(/\r/g,``);return t?Array.from(t.matchAll(/<thought>([\s\S]*?)<\/thought>/gi)).map(e=>c(e?.[1]||``)).filter(Boolean).join(`

`).trim():``},Ee=e=>{let t=String(e||``).replace(/\r/g,``);return t?t.replace(/<thought>[\s\S]*?<\/thought>/gi,``).trim():``},De=e=>{let t=Ee(String(e||``).replace(/\r/g,``));if(!t)return``;let n=t,r=t.match(/---JSON_STATE---/);if(r&&typeof r.index==`number`)n=t.slice(0,r.index);else{let e=t.match(/```json\n([\s\S]*)/);e&&typeof e.index==`number`&&(n=t.slice(0,e.index))}n=n.replace(/^<对话回复>[\s\n]*/i,``).replace(/<\/?对话回复>[\s\n]*/gi,``).trim();let i=n.split(`
`).map(e=>e.trimEnd()).filter(e=>!!String(e||``).trim()).join(`
`);return i.length<=16e3?i:`…\n${i.slice(-16e3)}`},Oe=e=>{let t=Te(e),n=[String(e||``).replace(/\r/g,``),t].filter(Boolean).join(`
`).replace(/```[\s\S]*?```/g,``).split(`
`).map(e=>e.trimEnd()),r=[],i=``;for(let e of n){let t=String(e||``).trim();t&&(/^\s*[\{\}\[\],]+\s*$/.test(t)||/output_schema|compact_json|response_format|max_tokens|prompt_tokens/i.test(t)||t!==i&&(i=t,r.push(t)))}let a=r.join(`
`);return a.length<=12e3?a:`…\n${a.slice(-12e3)}`},Z=e=>{let t=c((Array.isArray(e)?e:[]).find(e=>c(e?.function?.name)===`submit_career_coach_result`)?.function?.arguments);if(!t)return null;try{let e=JSON.parse(t);return e&&typeof e==`object`?e:null}catch{return null}},ke=e=>{let t=e&&typeof e==`object`?e:{};return{title:c(t.title)||`职业教练建议`,summary:c(t.summary),stage:c(t.stage),directionVerdict:c(t.directionVerdict||t.verdict),confidenceScore:Number.isFinite(Number(t.confidenceScore))?Math.max(0,Math.min(100,Math.round(Number(t.confidenceScore||0)))):void 0,primaryAction:c(t.primaryAction),nextQuestion:c(t.nextQuestion),profileSnapshot:t.profileSnapshot&&typeof t.profileSnapshot==`object`?t.profileSnapshot:void 0,recommendedTracks:(Array.isArray(t.recommendedTracks)?t.recommendedTracks:[]).slice(0,4).map(e=>({label:c(e?.label),fit:c(e?.fit),why:c(e?.why),risks:q(e?.risks,4),firstStep:c(e?.firstStep)})).filter(e=>e.label||e.why),strengths:q(t.strengths,8),blockers:q(t.blockers,8),opportunities:q(t.opportunities,8),marketSignals:q(t.marketSignals,8),actionPlan:(Array.isArray(t.actionPlan)?t.actionPlan:[]).slice(0,6).map(e=>({phase:c(e?.phase),title:c(e?.title),why:c(e?.why),steps:q(e?.steps,6),recommendedTool:c(e?.recommendedTool),toolPrompt:c(e?.toolPrompt)})).filter(e=>e.title||e.why||Array.isArray(e.steps)&&e.steps.length),resumeFocus:c(t.resumeFocus),interviewFocus:c(t.interviewFocus),compensationStrategy:c(t.compensationStrategy),diagnosis:t.diagnosis&&typeof t.diagnosis==`object`?{stage:c(t.diagnosis?.stage),painPoint:c(t.diagnosis?.painPoint),currentState:c(t.diagnosis?.currentState),urgency:c(t.diagnosis?.urgency)}:void 0,coachingInsights:q(t.coachingInsights,8),gapAnalysis:t.gapAnalysis&&typeof t.gapAnalysis==`object`?{skills:q(t.gapAnalysis?.skills,6),network:q(t.gapAnalysis?.network,6),positioning:q(t.gapAnalysis?.positioning,6),mindset:q(t.gapAnalysis?.mindset,6)}:void 0,roadmap:(Array.isArray(t.roadmap)?t.roadmap:[]).slice(0,4).map(e=>({timeframe:c(e?.timeframe),focus:c(e?.focus),actions:q(e?.actions,6)})).filter(e=>e.timeframe||e.focus||Array.isArray(e.actions)&&e.actions.length),toolRecommendations:(Array.isArray(t.toolRecommendations)?t.toolRecommendations:[]).slice(0,4).map(e=>({tool:c(e?.tool),route:c(e?.route),reason:c(e?.reason),urgency:c(e?.urgency),prefillHint:c(e?.prefillHint)})).filter(e=>e.tool||e.reason),toolExecutionPlan:(Array.isArray(t.toolExecutionPlan)?t.toolExecutionPlan:[]).slice(0,6).map(e=>({tool:c(e?.tool),title:c(e?.title),reason:c(e?.reason),prefillHint:c(e?.prefillHint),fallbackToModel:!!e?.fallbackToModel})).filter(e=>e.tool||e.reason||e.title),toolSchemaVersion:c(t.toolSchemaVersion),toolSchemaSummary:q(t.toolSchemaSummary,8),followUpQuestions:q(t.followUpQuestions,6),knowledgeRefs:(Array.isArray(t.knowledgeRefs)?t.knowledgeRefs:[]).slice(0,6).map(e=>({title:c(e?.title),sourceType:c(e?.sourceType),useFor:c(e?.useFor)})).filter(e=>e.title||e.useFor),caveats:q(t.caveats,8),evidence:q(t.evidence,8),executionLedger:(Array.isArray(t.executionLedger)?t.executionLedger:[]).slice(-12).map(e=>({id:c(e?.id),tool:c(e?.tool),title:c(e?.title),reason:c(e?.reason),status:c(e?.status),source:c(e?.source),startedAt:Number(e?.startedAt||0)||void 0,finishedAt:Number(e?.finishedAt||0)||void 0,requestCount:Number(e?.requestCount||0)||void 0,totalTokens:Number(e?.totalTokens||0)||void 0,estimatedPoints:Number(e?.estimatedPoints||0)||void 0,actualPoints:Number(e?.actualPoints||0)||void 0,pointsStatus:c(e?.pointsStatus)===`actual`||c(e?.pointsStatus)===`mixed`||c(e?.pointsStatus)===`estimated`?c(e?.pointsStatus):void 0,model:c(e?.model),note:c(e?.note)})).filter(e=>e.tool||e.status||e.title),workflowContext:t.workflowContext&&typeof t.workflowContext==`object`?{resumeText:c(t.workflowContext?.resumeText),jdText:c(t.workflowContext?.jdText)}:void 0}},Ae=e=>{let t=String(e||``).trim().toLowerCase();return t===`deep`?{id:`deep`,replyTimeoutMs:6e4,structuredTimeoutMs:3e4,useAgentWhenReady:!0}:t===`lite`?{id:`lite`,replyTimeoutMs:25e3,structuredTimeoutMs:18e3,useAgentWhenReady:!1}:{id:`standard`,replyTimeoutMs:4e4,structuredTimeoutMs:24e3,useAgentWhenReady:!0}},je=async e=>{try{e.onStatus?.(`正在整理外部上下文…`);let t=[],n=String(e.prompt||``),r=String(e.profile?.summary||``),i=E.buildRoleContextFromText([n,r,String(e.profile?.targetRole||``),String(e.profile?.targetIndustry||``),...Array.isArray(e.profile?.goals)?e.profile.goals:[]].join(`
`));i&&t.push(i);let a=/([^，。！？,!?\s]{2,10}(大学|学院|分校|Institute|University|College))/gi,o=new Set,s;for(;(s=a.exec(n))!==null;)o.add(s[1].trim());for(;(s=a.exec(r))!==null;)o.add(s[1].trim());if(o.size>0){e.onStatus?.(`正在查验高校背景字典…`);for(let e of Array.from(o).slice(0,3)){let n=await L.getSchoolSummaryContext(e);n&&t.push(n)}}return t}catch(e){console.warn(`CareerCoach: Failed to collect external context`,e)}return[]},Me=(e,t=[])=>{let n=Z(t);if(n&&typeof n==`object`)return n;let r=c(e);if(!r)return null;let i=r.match(/```json\n([\s\S]*?)```/)?.[1]?.trim()||x(r);try{let e=JSON.parse(i);return e&&typeof e==`object`?e:null}catch{return null}},Ne={title:`string`,summary:`string`,stage:`string`,directionVerdict:`string`,confidenceScore:`number(0-100)`,primaryAction:`string`,nextQuestion:`string`,strengths:[`string`],blockers:[`string`],opportunities:[`string`],actionPlan:[{phase:`string`,title:`string`,why:`string`,steps:[`string`],recommendedTool:`string`,toolPrompt:`string`}],resumeFocus:`string`,interviewFocus:`string`,compensationStrategy:`string`,followUpQuestions:[`string`],caveats:[`string`],evidence:[`string`]},Pe=`deepseek_pro`,Fe=`deepseek`,Ie=`deepseek-v4-pro`,Le=e=>e.reduce((e,t)=>e+c(t?.content).length+c(t?.preview).length+c(t?.name).length,0),Re=e=>e.reduce((e,t)=>e+c(t?.content).length,0),ze=e=>{try{return JSON.stringify(e||{}).length}catch{return c(e?.summary).length+c(e?.currentRole).length+c(e?.targetRole).length}},Be=e=>{let t=e.currentResult&&typeof e.currentResult==`object`?e.currentResult:null,n={profile:e.profile||{},userInput:e.userInput,assistantReply:c(e.assistantReply).slice(0,2200),currentResult:t?{title:c(t.title),summary:c(t.summary),directionVerdict:c(t.directionVerdict),primaryAction:c(t.primaryAction),nextQuestion:c(t.nextQuestion),strengths:Array.isArray(t.strengths)?t.strengths.slice(0,4):[],blockers:Array.isArray(t.blockers)?t.blockers.slice(0,4):[],opportunities:Array.isArray(t.opportunities)?t.opportunities.slice(0,4):[],actionPlan:Array.isArray(t.actionPlan)?t.actionPlan.slice(0,3).map(e=>({phase:c(e?.phase),title:c(e?.title),why:c(e?.why),steps:Array.isArray(e?.steps)?e.steps.slice(0,3):[]})):[]}:null,recentTurns:c(e.recentTurns).slice(0,1400),recentToolContext:c(e.recentToolContext).slice(0,600),knowledgeContext:Array.isArray(e.knowledgeContext)?e.knowledgeContext.slice(0,4).map(e=>({title:c(e?.title),sourceType:c(e?.sourceType),summary:c(e?.summary).slice(0,180)})):[],uploadedDocs:Array.isArray(e.uploadedDocs)?e.uploadedDocs.slice(0,4).map(e=>({name:c(e?.name),preview:c(e?.preview)})):[],resumeText:c(e.resumeText).slice(0,1200),jdText:c(e.jdText).slice(0,1200),pinnedContext:c(e.pinnedContext),progressSummary:c(e.progressSummary)},r=JSON.stringify(Ne,null,2),i=JSON.stringify(n,null,2);return{messages:[{role:`system`,content:e.retry?`你是资深中文职业教练。上一次输出未能被解析。本次必须只输出一个合法 JSON 对象，不要输出任何解释、Markdown、代码块或额外文字。`:`你是资深中文职业教练。请基于给定上下文生成结构化详细规划。必须只输出一个合法 JSON 对象，不要输出任何解释、Markdown、代码块或额外文字。`},{role:`user`,content:[`请基于以下上下文，输出职业教练详细规划。`,`要求：`,`1. 结论要具体、可执行，避免空泛表述。`,`2. actionPlan 输出 3-5 条，steps 每条 2-5 步。`,`3. strengths / blockers / opportunities / followUpQuestions / caveats / evidence 都尽量填写。`,`4. 如果信息不足，也要给出当前最稳妥的建议，并在 caveats 中说明缺口。`,`5. recommendedTool 只允许填写：resume_match、resume_optimize、jd_analysis、resume_translate、resume_html、market_signal_scan、job_search_strategy、interview_coach、salary_negotiation、none。`,``,`输出 JSON Schema：`,r,``,`上下文：`,i].join(`
`)}],temperature:e.retry?.1:.2,max_tokens:3600}};function Ve(e){let t=(0,K.useRef)(e);t.current=e;let n=(0,K.useCallback)(async()=>{let{sessionId:e,detailBusy:n,coachConsentAccepted:r,profile:i,result:a,setResult:s,setErr:l,dialogInput:u,setDialogInput:d,chatTurns:p,uploadedDocs:m,setStreamText:h,writeToolConversationRun:g,start:_,setProgress:v,appendChatTurn:y,updateChatTurn:b,abortRef:x,clearDetailCardTimers:C,setDetailBusy:w,setDetailStatus:T,setDetailCardTurnId:D,setDetailCardStage:O,setBusy:k,makeId:A,setSessionId:te,navigate:ne,runSeqRef:M,pendingAttachments:N,setPendingAttachments:re,resetBufferedConversationState:P,setStreamThinking:F,setStreamStage:I,setStreamActor:L,streamTextRawRef:oe,streamThinkingRawRef:se,streamTextFlushTimerRef:R,streamThinkingFlushTimerRef:z,setModelChoiceState:le,syncProfileToCloud:B,syncSessionToCloud:H,listLocalToolResultSummaries:U,listCareerCoachKnowledgeItems:G,analysisDepth:ue,withTimeout:de,done:fe,failByMessage:pe,executionLedger:me,derivedResumeText:he,derivedJdText:ge,pinnedContext:_e,autoProgressSummary:K,beginDetailCardReveal:q,normalizeToolError:ve,sanitizeTurnRawParts:ye,buildPlainStreamPreview:J}=t.current,be=await o();if(!be?.token){window.location.href=j();return}if(!r){l(`请先确认职业教练的专业模型与扣费提示，再开始使用。`);return}let Y=c(u);if(!Y&&!m.length&&!c(i.summary)&&!c(i.currentRole)&&!c(i.targetRole)){l(`请先输入你的问题、职业背景，或上传简历后再开始。`);return}try{let e=await ce({tool:`career_coach`,modelChoice:Pe,inputChars:Y.length+ze(i)+c(_e).length+c(K).length,docsChars:Le(m),chatChars:Re(p),resumeChars:c(he).length,jdChars:c(ge).length,outputChars:9e3});if(!e.ok){l(`${e.message} 请先充值后再开始。`);return}}catch(e){l(String(e?.message||`暂时无法校验积分余额，请稍后重试。`));return}if(n&&x.current)try{x.current.abort()}catch{}l(``),C(),w(!1),T(``),D(``),O(0),s(null),_(),v(10),k(!0);let X=c(e)||A();if(!c(e)){te(X);try{ne(`/tools/career-coach?sid=${encodeURIComponent(X)}`,{replace:!0})}catch{}}let Ee=++M.current,De=new AbortController;x.current=De;let Z=De.signal,Ne=await ie({pageSize:100,rangeDays:1}),Fe=N.slice(),Ie=Y||Fe.length?{id:`turn_u_${Date.now()}_${Math.random().toString(16).slice(2,8)}`,role:`user`,content:Y,attachments:Fe,createdAt:Date.now()}:null;(Y||Fe.length)&&y(Ie);let Be=Ie?[...p,Ie].slice(-80):p.slice(-80);re([]),d(``),P({setStreamText:h,setStreamThinking:F,setStreamStage:I,setStreamActor:L,streamTextRawRef:oe,streamThinkingRawRef:se,streamTextFlushTimerRef:R,streamThinkingFlushTimerRef:z}),le(`deepseek_pro`),await B(i);let Ve=!1,Q=Be,He=``;try{await H({status:`running`,sid:X,chatTurnsOverride:Be,uploadedDocsOverride:m,runtimeState:{modelChoice:`deepseek_pro`,thinkingEnabled:!0}})}catch(e){console.warn(`Failed to sync session to cloud initially:`,e)}try{let e=(Ie?Be.slice(0,-1):Be).filter(e=>e.role===`user`||e.role===`assistant`),t=xe(e),n=e.slice(-12).map(e=>`${e.role===`assistant`?`AI`:`用户`}：${c(e.content).slice(0,700)}`).filter(Boolean).join(`
`),r=U({userId:c(be?.user?.id)}).slice(0,6).map(e=>{let t=c(e?.insightSummary?.headline),n=c(e?.insightSummary?.primaryAction);return`${c(e.toolType)}｜${c(e.title)}${t?`｜${t}`:``}${n?`｜下一步：${n}`:``}`}).filter(Boolean).join(`
`),a=``;try{let e=await W(Y,Z,e=>{I(e),T(e)});e.triggered&&e.contextText&&(a=e.contextText)}catch{}let o=[a,r].filter(Boolean).join(`

`),l=Ae(ue),u=await G({query:[Y,c(i.targetRole),c(i.targetIndustry),...Array.isArray(i.goals)?i.goals:[]].filter(Boolean).join(`；`),tags:Se(i,Y),audienceTags:Ce(i),limit:6}).catch(()=>[]),d=(Array.isArray(u)?u:[]).slice(0,6).map(e=>({title:c(e.title),sourceType:c(e.sourceType),tags:Array.isArray(e.tags)?e.tags:[],audienceTags:Array.isArray(e.audienceTags)?e.audienceTags:[],summary:c(e.summary).slice(0,260),content:c(e.content).slice(0,900)})),p=await je({mode:l.id,prompt:Y,profile:i,signal:Z,onStatus:T}).catch(()=>[]),_=[...p,...d].slice(0,6),C=m.slice(-6).map(e=>({name:e.name,preview:c(e.preview||we(e.content)),content:c(e.content).slice(0,6e3)})),D={},O=await f(),A=l.replyTimeoutMs,te=c(_e),j=c(K),ne=E.buildRoleContextFromText([Y,c(i.targetRole),c(i.targetIndustry),...Array.isArray(i.goals)?i.goals:[],ge,he].join(`
`)),N=V({tool:`career_coach`,runSeq:Ee,runSeqRef:M,stage:`career_coach`,agentLabel:`Agent: career-coach`,skillLabel:`Skill: career_coach`,setStreamStage:I,setStreamActor:L,setStreamText:h,setStreamThinking:F,buildPlainStreamPreview:J,sanitizeThinking:Oe,streamTextRawRef:oe,streamThinkingRawRef:se,streamTextFlushTimerRef:R,streamThinkingFlushTimerRef:z,hideModelMeta:!0}),re=c(he).length>100,ie=c(ge).length>50;if(re&&ie&&l.useAgentWhenReady){T(`正在分析...`);let e=await de(S({proxyUrl:O.proxyUrl,gatewayApiKey:O.gatewayApiKey,clientId:O.clientId,tier:O.tier,data:{userInput:Y,resume:he,jd:ge,profile:i,pinnedContext:te,progressSummary:j,roleContext:ne,historyTurns:t,runtimeMode:l.id,externalContext:p},signal:Z,onToolStart:(e,t,n)=>{T(t),N.onText(`\n\n*${t}*`)},onToolDone:(e,t)=>{T(`整理结果中...`)},onText:e=>{N.onText(e)}}),A,`职业教练 Agent`);T(``);let n=`turn_a_${Date.now()}_${Math.random().toString(16).slice(2,8)}`;He=n;let r={id:n,role:`assistant`,content:e,createdAt:Date.now()};y(r),Ve=!0,Q=[...Be,r];let a=Me(e),o=a?{...ke(a),...me.length?{executionLedger:me.slice(-24)}:{},workflowContext:{resumeText:he,jdText:ge}}:null;o&&(s(o),q(n,o));let c=await ae({beforeIds:Ne,aggregateAllNew:!0,pageSize:100,rangeDays:1}),u=c&&{...c,model:``};u&&(b(n,{billing:u}),Q=Q.map(e=>e.id===n?{...e,billing:u}:e)),g(`career_coach`,{runState:`done`,progress:100,sessionId:X,profile:i,analysisDepth:ue,result:o,chatTurns:Q,uploadedDocs:m.slice(-12)}),await H({status:`done`,sid:X,nextResult:o,chatTurnsOverride:Q,uploadedDocsOverride:m,runtimeState:{modelChoice:`deepseek_pro`,thinkingEnabled:!0}}),P({setStreamText:h,setStreamThinking:F,setStreamStage:I,setStreamActor:L,streamTextRawRef:oe,streamThinkingRawRef:se,streamTextFlushTimerRef:R,streamThinkingFlushTimerRef:z}),x.current=null,k(!1),fe();return}let ce=e=>{let t=Te(e);t&&N.onThinking(t),N.onText(e)},le=await de(ee({proxyUrl:O.proxyUrl,gatewayApiKey:O.gatewayApiKey,clientId:O.clientId,tier:O.tier,preset:`career_coach`,provider:`deepseek`,model:`deepseek-v4-pro`,data:{lang:`zh-CN`,mode:l.id,outputMode:`reply_only`,profile:{...i,goals:Array.isArray(i.goals)?i.goals:[],constraints:Array.isArray(i.constraints)?i.constraints:[]},recentTurns:n,historyTurns:t,pinnedContext:te,progressSummary:j,roleContext:ne,userInput:Y,uploadedDocs:C,recentToolContext:o,knowledgeContext:_,externalContext:p},thinking:!0,signal:Z,onThinking:N.onThinking,onText:ce,onToolCalls:e=>{D.toolCalls=Array.isArray(e)?e:[]},onResponseMeta:e=>{N.onMeta({type:`start`,requestId:``,provider:e.provider,model:e.model}),D.provider=c(e.provider||D.provider),D.model=c(e.model||D.model),D.fallbackMeta=e.fallback&&typeof e.fallback==`object`?{fromProvider:c(e.fallback?.fromProvider),fromModel:c(e.fallback?.fromModel),provider:c(e.fallback?.provider),model:c(e.fallback?.model)}:D.fallbackMeta||null,D.reasoningContent=Oe(String(e.reasoningContent||D.reasoningContent||``)),D.thoughtSignature=c(e.thoughtSignature||D.thoughtSignature),D.thoughtsTokens=Math.max(0,Number(e.thoughtsTokens||D.thoughtsTokens||0)),D.rawParts=ye(e.rawParts),Array.isArray(e.toolCalls)&&(D.toolCalls=e.toolCalls)}}),A,`职业教练生成`);if(Ee!==M.current)return;N.flushPending(),c(D.reasoningContent)||(D.reasoningContent=Oe(Te(le)));let B=Me(le,D.toolCalls||[]),pe=B?{...ke(B),...me.length?{executionLedger:me.slice(-24)}:{},workflowContext:{resumeText:he,jdText:ge}}:null,ve=J(le),De={id:`turn_a_${Date.now()}_${Math.random().toString(16).slice(2,8)}`,role:`assistant`,content:ve,createdAt:Date.now(),providerMeta:null,fallbackMeta:null};He=De.id,y(De),pe&&(s(pe),q(De.id,pe)),Q=[...Be,De].slice(-80),Ve=!0,P({setStreamText:h,setStreamThinking:F,setStreamStage:I,setStreamActor:L,streamTextRawRef:oe,streamThinkingRawRef:se,streamTextFlushTimerRef:R,streamThinkingFlushTimerRef:z}),v(58),k(!1),w(!1),T(``),g(`career_coach`,{runState:`partial`,progress:58,sessionId:X,profile:i,analysisDepth:ue,result:pe,chatTurns:Q,uploadedDocs:m.slice(-12),streamThinking:``,streamStage:``,streamActor:``});let Pe=await ae({beforeIds:Ne,aggregateAllNew:!0,pageSize:100,rangeDays:1}),Fe=Pe&&{...Pe,model:``,...Number(D.thoughtsTokens||0)>0?{thoughtsTokens:Math.max(0,Number(D.thoughtsTokens||0))}:{}},Le={...De,content:ve||De.content,billing:Fe,providerMeta:null,fallbackMeta:null,reasoningContent:Oe(String(D.reasoningContent||``)),thoughtSignature:c(D.thoughtSignature),rawParts:ye(D.rawParts),toolCalls:Array.isArray(D.toolCalls)?D.toolCalls:void 0};b(He,Le);let Re=Q.map(e=>e.id===He?Le:e).slice(-80);fe(),v(100),w(!1),T(``),g(`career_coach`,{runState:`done`,progress:100,sessionId:X,profile:i,analysisDepth:ue,result:pe,chatTurns:Re,uploadedDocs:m.slice(-12)}),await H({status:`done`,sid:X,nextResult:pe,chatTurnsOverride:Re,uploadedDocsOverride:m,runtimeState:{modelChoice:`deepseek_pro`,thinkingEnabled:!0}})}catch(e){if(Ee!==M.current)return;let t=ve(e,`生成失败`);if(P({setStreamText:h,setStreamThinking:F,setStreamStage:I,setStreamActor:L,streamTextRawRef:oe,streamThinkingRawRef:se,streamTextFlushTimerRef:R,streamThinkingFlushTimerRef:z}),w(!1),T(``),Ve){x.current=null,k(!1),fe(),v(100),l(t===`已取消`?`已取消`:``),g(`career_coach`,{runState:`done`,progress:100,sessionId:X,profile:i,analysisDepth:ue,result:a,chatTurns:Q,uploadedDocs:m.slice(-12)}),await H({status:`done`,sid:X,nextResult:a,chatTurnsOverride:Q,uploadedDocsOverride:m,runtimeState:{modelChoice:`deepseek_pro`,thinkingEnabled:!0}});return}pe(t,l),k(!1),g(`career_coach`,{runState:t===`已取消`?`cancelled`:`failed`,err:t}),await H({status:`failed`,sid:X,error:t,chatTurnsOverride:Be,uploadedDocsOverride:m,runtimeState:{modelChoice:`deepseek_pro`,thinkingEnabled:!0}})}},[]),r=(0,K.useCallback)(async e=>{let{sessionId:n,busy:r,detailBusy:i,coachConsentAccepted:a,profile:s,setResult:l,setErr:u,chatTurns:d,uploadedDocs:p,writeToolConversationRun:m,abortRef:h,clearDetailCardTimers:g,setDetailBusy:_,setDetailStatus:v,setDetailCardTurnId:y,setDetailCardStage:b,setStreamText:x,setStreamThinking:S,setStreamStage:w,setStreamActor:T,streamTextRawRef:E,streamThinkingRawRef:D,streamTextFlushTimerRef:O,streamThinkingFlushTimerRef:k,runSeqRef:A,buildPlainStreamPreview:te,resetBufferedConversationState:ne,syncSessionToCloud:M,listLocalToolResultSummaries:N,listCareerCoachKnowledgeItems:re,analysisDepth:P,withTimeout:F,executionLedger:ie,derivedResumeText:ae,derivedJdText:I,pinnedContext:L,autoProgressSummary:oe,beginDetailCardReveal:se,normalizeToolError:R,sanitizeTurnRawParts:z,sanitizeTurnToolCalls:le}=t.current;if(r||i)return;if(!a){u(`请先确认职业教练的专业模型与扣费提示，再开始使用。`);return}let B=await o();if(!B?.token){window.location.href=j();return}let H=c(e.id);if(!H)return;let U=d.findIndex(e=>c(e.id)===H),W=(U>=0?d.slice(0,U+1):d.slice()).filter(e=>e.role===`user`||e.role===`assistant`),G=c([...W].reverse().find(e=>e.role===`user`)?.content);if(!G){u(`请先完成一轮对话，再生成详细规划。`);return}try{let t=await ce({tool:`career_coach`,modelChoice:Pe,inputChars:G.length+c(e.content).length+ze(s)+c(L).length+c(oe).length,docsChars:Le(p),chatChars:Re(W),resumeChars:c(ae).length,jdChars:c(I).length,outputChars:7e3});if(!t.ok){u(`${t.message} 请先充值后再开始。`);return}}catch(e){u(String(e?.message||`暂时无法校验积分余额，请稍后重试。`));return}u(``),g(),_(!0),v(`正在生成详细规划…`),y(H),b(0),l(null),ne?.({setStreamText:x,setStreamThinking:S,setStreamStage:w,setStreamActor:T,streamTextRawRef:E,streamThinkingRawRef:D,streamTextFlushTimerRef:O,streamThinkingFlushTimerRef:k});let ue=A.current,de=new AbortController;h.current=de;let fe=de.signal,pe=W.slice(-12).map(e=>`${e.role===`assistant`?`AI`:`用户`}：${c(e.content).slice(0,700)}`).filter(Boolean).join(`
`),me=N({userId:c(B?.user?.id)}).slice(0,6).map(e=>{let t=c(e?.insightSummary?.headline),n=c(e?.insightSummary?.primaryAction);return`${c(e.toolType)}｜${c(e.title)}${t?`｜${t}`:``}${n?`｜下一步：${n}`:``}`}).filter(Boolean).join(`
`),he=Ae(P),ge=await re({query:[G,c(s.targetRole),c(s.targetIndustry),...Array.isArray(s.goals)?s.goals:[]].filter(Boolean).join(`；`),tags:Se(s,G),audienceTags:Ce(s),limit:6}).catch(()=>[]),_e=(Array.isArray(ge)?ge:[]).slice(0,6).map(e=>({title:c(e.title),sourceType:c(e.sourceType),tags:Array.isArray(e.tags)?e.tags:[],audienceTags:Array.isArray(e.audienceTags)?e.audienceTags:[],summary:c(e.summary).slice(0,260),content:c(e.content).slice(0,900)})),K=[...await je({mode:he.id,prompt:G,profile:s,signal:fe,onStatus:v}).catch(()=>[]),..._e].slice(0,6),q=p.slice(-6).map(e=>({name:e.name,preview:c(e.preview||we(e.content)),content:c(e.content).slice(0,6e3)})),ve=c(L),ye=c(oe),J={};try{let r=await f(),i=he.structuredTimeoutMs,a=Be({userInput:G,assistantReply:c(e.content),profile:s,currentResult:t.current.result,recentTurns:pe,recentToolContext:me,knowledgeContext:K,uploadedDocs:q,resumeText:ae,jdText:I,pinnedContext:ve,progressSummary:ye}),o=V({tool:`career_coach`,runSeq:ue,runSeqRef:A,stage:`详细规划生成中`,agentLabel:`Agent: career-coach`,skillLabel:`Skill: detailed_plan`,setStreamStage:w,setStreamActor:T,setStreamText:x,setStreamThinking:S,buildPlainStreamPreview:te,sanitizeThinking:Oe,streamTextRawRef:E,streamThinkingRawRef:D,streamTextFlushTimerRef:O,streamThinkingFlushTimerRef:k,hideModelMeta:!0}),u=await F(ee({proxyUrl:r.proxyUrl,gatewayApiKey:r.gatewayApiKey,clientId:r.clientId,tier:r.tier,payload:a,provider:`deepseek`,model:`deepseek-v4-pro`,thinking:!0,signal:fe,onMeta:o.onMeta,onText:o.onText,onThinking:o.onThinking,onResponseMeta:e=>{J.provider=c(e.provider||J.provider),J.model=c(e.model||J.model),J.rawParts=z(e.rawParts),Array.isArray(e.toolCalls)&&(J.toolCalls=le(e.toolCalls))},_forceDirectProxy:!0}),i,`职业教练详细规划生成`);o.flushPending();let h=Me(u,J.toolCalls||[]),g=!!(h&&typeof h==`object`&&!Array.isArray(h)&&!Object.keys(h).length);if(!h||typeof h!=`object`||g){let n=Be({userInput:G,assistantReply:c(e.content),profile:s,currentResult:t.current.result,recentTurns:pe,recentToolContext:me,knowledgeContext:K,uploadedDocs:q,resumeText:ae,jdText:I,pinnedContext:ve,progressSummary:ye,retry:!0});h=Me(await F(C({proxyUrl:r.proxyUrl,gatewayApiKey:r.gatewayApiKey,clientId:r.clientId,tier:r.tier,payload:n,provider:Fe,model:Ie,thinking:!0,onResponseMeta:e=>{J.provider=c(e.provider||J.provider),J.model=c(e.model||J.model),J.rawParts=z(e.rawParts),Array.isArray(e.toolCalls)&&(J.toolCalls=le(e.toolCalls))},signal:fe,_forceDirectProxy:!0}),Math.min(i,9e4),`职业教练详细规划重试`),J.toolCalls||[])}if(!h||typeof h!=`object`||!Object.keys(h).length)throw Error(`详细规划生成失败，请稍后再试`);let y={...ke(h),...ie.length?{executionLedger:ie.slice(-24)}:{},workflowContext:{resumeText:ae,jdText:I}};l(y),se(H,y),v(``),_(!1),ne?.({setStreamText:x,setStreamThinking:S,setStreamStage:w,setStreamActor:T,streamTextRawRef:E,streamThinkingRawRef:D,streamTextFlushTimerRef:O,streamThinkingFlushTimerRef:k}),m(`career_coach`,{runState:`done`,progress:100,sessionId:c(n),profile:s,analysisDepth:P,result:y,chatTurns:d,uploadedDocs:p.slice(-12)}),await M({status:`done`,nextResult:y,chatTurnsOverride:d,uploadedDocsOverride:p,runtimeState:{modelChoice:`deepseek_pro`,thinkingEnabled:!0}})}catch(e){_(!1),v(``),ne?.({setStreamText:x,setStreamThinking:S,setStreamStage:w,setStreamActor:T,streamTextRawRef:E,streamThinkingRawRef:D,streamTextFlushTimerRef:O,streamThinkingFlushTimerRef:k}),u(R(e,`详细规划生成失败`))}},[]);return(0,K.useMemo)(()=>({submit:n,generateDetailedPlan:r}),[n,r])}var Q=async e=>{let t=await o();if(!t?.token)throw Error(`请先登录后再使用职业教练工作流。`);let n=await f(),r=c(n.proxyUrl),i=c(n.gatewayApiKey);if(!r||!i)throw Error(`代理配置缺失`);let a=await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,apikey:i,Authorization:`Bearer ${i}`,"x-auth-token":t.token,"x-client-id":`career_workflow:${Date.now()}`},body:JSON.stringify(e||{})}),s=null;try{s=await a.json()}catch{}if(!a.ok)throw Error(c(s?.message)||c(s?.error)||`职业教练工作流执行失败`);return s},He=e=>({ok:!!e?.ok,sessionId:c(e?.sessionId)||void 0,completedCount:Number(e?.completedCount||0)||0,stoppedAt:c(e?.stoppedAt)||void 0,steps:Array.isArray(e?.steps)?e.steps.map(e=>({id:c(e?.id),tool:c(e?.tool),title:c(e?.title),reason:c(e?.reason),status:c(e?.status)===`failed`?`failed`:c(e?.status)===`skipped`?`skipped`:`completed`,requestId:c(e?.requestId)||void 0,requestCount:Number(e?.requestCount||0)||void 0,totalTokens:Number(e?.totalTokens||0)||void 0,estimatedPoints:Number(e?.estimatedPoints||0)||void 0,model:c(e?.model)||void 0,note:c(e?.note)||void 0,outputText:c(e?.outputText)||void 0,source:c(e?.source)||void 0})).filter(e=>e.id&&e.tool):[]}),Ue=async e=>He(await Q({op:`career_tool_execute`,sessionId:c(e.sessionId),profile:e.profile,resumeText:c(e.resumeText),jdText:c(e.jdText),steps:Array.isArray(e.steps)?e.steps:[]})),We=async e=>{try{let e=await o(),t=String(e?.user?.id||``).trim();if(t)return`u:${t}`.slice(0,120)}catch{}return String(e||`public`).slice(0,120)||`public`},Ge=async e=>{let t=await l();return t?e.map(e=>({...e,jd:w(String(e?.jd||``),t)})):e},Ke=e=>Array.isArray(e)?e.map(e=>String(e??``)).filter(Boolean).slice(0,30):[],qe=(e,t)=>{let n=String(e||``).trim();return n?n.length>t?`${n.slice(0,t)}…`:n:``},Je=(e,t,n)=>{let r=Math.min(Math.max(1,Number(n?.maxJobs||12)||12),e.length),i=Math.max(120,Math.min(8e3,Number(n?.excerptLen||4e3)||4e3));return e.slice(0,r).map(e=>{let n=String(e.description||``),r=t===`none`?``:t===`full`?n:qe(n,i);return{id:String(e.id||``),title:String(e.title||``),company:String(e.company||``),location:String(e.location||e.city_name||e.province_name||``),experience:String(e.experience||``),education:String(e.education||``),salary_text:String(e.salary?.text||``),salary_min:Number(e.salary?.min||0)||0,salary_max:Number(e.salary?.max||0)||0,platform:String(e.platform||``),jd:r}})},Ye=(e,t)=>{let n=e&&typeof e==`object`?e:{},r=e=>String(e??``).trim(),i=r(n.title)||(t.toLowerCase().startsWith(`zh`)?`JD 优化`:`JD Optimization`);return{lang:r(n.lang)||t,title:i,optimizedJd:r(n.optimizedJd),formatPatterns:Ke(n.formatPatterns||n.format||n.patterns).slice(0,20),keywords:Ke(n.keywords).slice(0,30),sellingPoints:Ke(n.sellingPoints||n.selling_points||n.highlights).slice(0,20),talentPersona:r(n.talentPersona||n.persona||n.talent_profile),changes:Ke(n.changes).slice(0,20),competencies:Ke(n.competencies).slice(0,20),risks:Ke(n.risks).slice(0,20),caveats:Ke(n.caveats).slice(0,10)}},Xe=async(e,t)=>{let n=await f();if(!n.enabled||!n.proxyUrl)throw Error(`AI 网关未启用或配置不完整`);let r=await We(n.clientId||`public`),i=s(),a=await p(),o=await d()===`glm5`,c=o&&a.jdMode===`full`?`excerpt`:a.jdMode,l=Array.isArray(e?.referenceJobs)?e.referenceJobs:[],u=e?.targetJob||null,m=String(e?.roleTitle||``).trim(),h=String(e?.requirementsIdea||``).trim(),g=Array.isArray(e?.clarifyQa)?e.clarifyQa:[],_=String(e?.extraContext||``).trim(),v=String(e?.style||`professional`).trim(),y=E.buildRoleContextFromText([m,h,_,...g.map(e=>`${String(e?.q||``)}\n${String(e?.a||``)}`)].join(`
`)),b=await L.buildUniversityContextFromText([m,h,_,...g.map(e=>`${String(e?.q||``)}\n${String(e?.a||``)}`)].join(`
`)).catch(()=>``),ee=[_,y,b].filter(Boolean).join(`
`).slice(0,1200);if(!l.length&&!u&&!m&&!h)throw Error(i.toLowerCase().startsWith(`zh`)?`请至少选择岗位参考或输入岗位名称/岗位要求`:`Provide reference jobs or role info`);let S=await Ge(Je(l,c,{maxJobs:5,excerptLen:o?3e3:4e3})),w=u?(await Ge(Je([u],c,{maxJobs:1,excerptLen:o?3e3:4e3})))?.[0]||{}:null,T=await C({proxyUrl:n.proxyUrl,gatewayApiKey:n.gatewayApiKey,clientId:r,tier:n.tier,preset:`optimize_jd`,data:{lang:i,referenceJobs:S,targetJob:w,roleTitle:qe(m,120),requirementsIdea:qe(h,2200),clarifyQa:g.map(e=>({q:String(e?.q||``).trim(),a:String(e?.a||``).trim()})).filter(e=>e.q&&e.a).slice(0,8),extraContext:ee,style:v.slice(0,40),roleContext:y,universityContext:b},signal:t?.signal}),D=null;try{D=JSON.parse(x(T))}catch{let e=String(T||``).slice(0,220).replace(/\s+/g,` `).trim();throw Error(e?`代理未返回可解析的 JSON：${e}`:`代理未返回可解析的 JSON`)}let O=Ye(D,i),k=O.caveats||[],A=i.toLowerCase().startsWith(`zh`)?`该JD优化由云端大模型生成，输出可能不准确`:`JD optimization generated by a cloud LLM; output may be inaccurate.`;return k.includes(A)||k.unshift(A),O.caveats=k.slice(0,10),O},Ze={resume_match:`简历匹配`,resume_optimize:`简历优化`,jd_analysis:`JD 分析`,resume_translate:`简历翻译`,resume_html:`HTML 简历`},Qe={...Ze,market_signal_scan:`市场信号扫描`,job_search_strategy:`求职推进策略`},$e=e=>{let t=c(e).toLowerCase();return t===`resume_match`?`resume_match`:t===`resume_optimize`?`resume_optimize`:t===`resume_translate`?`resume_translate`:t===`resume_html_generation`||t===`resume_html`?`resume_html`:t===`optimize_jd`||t===`jd_analysis`||t===`jd_clarify`?`jd_analysis`:``},et=e=>{let t=$e(e);if(t)return t;let n=c(e).toLowerCase();return n===`market_signal_scan`?`market_signal_scan`:n===`job_search_strategy`?`job_search_strategy`:``},tt=e=>Qe[e]||c(e)||`协同步骤`,nt=e=>({requiresResume:e===`resume_match`||e===`resume_optimize`||e===`resume_translate`||e===`resume_html`,requiresJd:e===`resume_match`||e===`resume_optimize`||e===`jd_analysis`}),rt=(e,t,n,r)=>({id:`${e}_${Math.random().toString(16).slice(2,8)}`,kind:e,title:c(r?.title)||Qe[e],reason:c(t)||`执行${Qe[e]}`,prefillHint:c(n)||void 0,source:r?.source||`heuristic`,fallbackToModel:!!r?.fallbackToModel,...nt(e)}),it=(e,t)=>t.map(t=>e.indexOf(t)).filter(e=>e>=0).sort((e,t)=>e-t)[0]??-1,at=e=>{let t=c(e.userInput).toLowerCase(),n=!!c(e.resumeText),r=!!c(e.jdText),i=[],a=(e,t,n,r)=>{i.some(t=>t.kind===e)||i.push(rt(e,t,n,r))};(Array.isArray(e.result?.toolExecutionPlan)&&e.result?.toolExecutionPlan||[]).forEach(e=>{let t=et(c(e?.tool));t&&a(t,c(e?.reason)||`根据职业教练编排执行${Qe[t]}`,c(e?.prefillHint),{title:c(e?.title),source:`tool_execution_plan`,fallbackToModel:!!e?.fallbackToModel})}),(Array.isArray(e.result?.toolRecommendations)&&e.result?.toolRecommendations||[]).forEach(e=>{let t=et(c(e?.tool));t&&a(t,c(e?.reason)||`根据职业教练建议执行${Qe[t]}`,c(e?.prefillHint),{source:`tool_recommendation`})}),(Array.isArray(e.result?.actionPlan)&&e.result?.actionPlan||[]).forEach(e=>{let t=et(c(e?.recommendedTool));t&&a(t,c(e?.toolPrompt)||c(e?.title)||`根据行动计划执行${Qe[t]}`,``,{source:`action_plan`})});let o=[],s=(e,n,r,i=!0)=>{if(!i)return;let a=it(t,n);a<0||o.push({kind:e,index:a,reason:r})};return s(`jd_analysis`,[`jd`,`岗位`,`职位`,`要求`,`职责`,`分析`],`按你当前提问，先拆解岗位关键词、风险点与目标画像`,r),s(`resume_match`,[`匹配`,`对比`,`适配`,`符合`],`按你当前提问，先判断简历与目标岗位的匹配度`,n&&r),s(`resume_optimize`,[`优化`,`改写`,`重写`,`润色`],`按你当前提问，直接进入简历优化与强化`,n&&r),s(`resume_translate`,[`英文`,`翻译`,`english`,`海外`],`按你当前提问，直接生成英文版简历`,n),s(`resume_html`,[`html`,`pdf`,`导出`,`排版`,`打印`],`按你当前提问，生成可导出版本`,n),o.sort((e,t)=>e.index-t.index).forEach(e=>a(e.kind,e.reason,``,{source:`heuristic`})),!i.length&&n&&r&&a(`resume_match`,`当前已具备简历与 JD，先做匹配判断更容易找到下一步重点`,``,{source:`heuristic`}),i.filter(e=>(!e.requiresResume||n)&&(!e.requiresJd||r)).slice(0,5)},ot=`deepseek_pro`,st=`deepseek`,ct=`deepseek-v4-pro`,lt=`deepseek`,ut=`deepseek-v4-flash`,dt=e=>e===`resume_match`?`resume_match`:e===`resume_optimize`?`resume_optimize`:e===`resume_translate`?`resume_translate`:`career_coach`,ft=e=>e===`resume_match`?lt:ot;function pt({sessionId:e,isAuthed:t,busy:n,detailBusy:r,coachConsentAccepted:i,profile:a,result:s,setResult:l,setErr:u,dialogInput:d,chatTurns:f,uploadedDocs:p,buildActionHref:m,jumpToRecommendedTool:h,appendChatTurn:g}){let[_,v]=(0,K.useState)(`resume_match`),[y,b]=(0,K.useState)(``),[x,ee]=(0,K.useState)(``),[S,C]=(0,K.useState)(!1),[w,E]=(0,K.useState)(0),[D,k]=(0,K.useState)(``),[A,ne]=(0,K.useState)(!1),[M,N]=(0,K.useState)(``),[re,P]=(0,K.useState)([]),[F,I]=(0,K.useState)([]),[L,R]=(0,K.useState)(null),B=(e,t)=>{g({id:`turn_tool_${Date.now()}_${Math.random().toString(16).slice(2,8)}`,role:`assistant`,content:`**${e}**\n\n${t}`,createdAt:Date.now()})},V=e=>{I(t=>{let n=[...t,e].slice(-24);return l(e=>e&&{...e,executionLedger:n}),n})},H=(0,K.useMemo)(()=>c(y)?c(y):p.map(e=>c(e.content)).filter(Boolean).join(`

`).trim()||c(s?.workflowContext?.resumeText),[y,s,p]),U=(0,K.useMemo)(()=>{if(c(x))return c(x);let e=[...f].reverse().find(e=>e.role===`user`);return c(d)||c(e?.content)||c(s?.workflowContext?.jdText)},[f,d,x,s]),W=(0,K.useMemo)(()=>at({result:s,userInput:c(d)||c([...f].reverse().find(e=>e.role===`user`)?.content),resumeText:H,jdText:U}),[f,U,H,d,s]),G=(0,K.useMemo)(()=>{if(!W.length)return[];let e=new Map;F.forEach(t=>{let n=c(t.tool);n&&e.set(n,c(t.status))});let t=W.findIndex(t=>e.get(t.kind)!==`completed`);return t<0?[]:W.slice(t)},[F,W]);(0,K.useEffect)(()=>{if(A)return;let e=new Map;F.forEach(t=>{let n=c(t.tool);n&&e.set(n,c(t.status))}),P(W.map(t=>({id:t.id,kind:t.kind,title:t.title,reason:t.reason,status:e.get(t.kind)===`completed`?`completed`:e.get(t.kind)===`failed`?`failed`:`pending`}))),N(W.length?`职业教练已整理好多步执行建议。`:``)},[F,A,W]),(0,K.useEffect)(()=>{s&&I(Array.isArray(s?.executionLedger)&&s?.executionLedger||[])},[s]);let ue=async(e,t)=>{try{let n=await ce({tool:dt(e),modelChoice:ft(e),resumeChars:c(t?.resumeText??H).length,jdChars:c(t?.jdText??U).length,inputChars:Math.max(0,Math.floor(Number(t?.extraChars||0))),chatChars:f.reduce((e,t)=>e+c(t?.content).length,0),docsChars:p.reduce((e,t)=>e+c(t?.content).length+c(t?.preview).length,0),outputChars:e===`resume_html`?9e3:e===`resume_optimize`?8e3:5e3});return n.ok?!0:(u(`${n.message} 请先充值后再开始。`),!1)}catch(e){return u(String(e?.message||`暂时无法校验积分余额，请稍后重试。`)),!1}},de=async e=>{try{let t=e.map(e=>`${c(e.kind)} ${c(e.title)} ${c(e.reason)} ${c(e.prefillHint)}`).join(`
`),n=await ce({tool:`career_coach`,modelChoices:[ot],resumeChars:c(H).length,jdChars:c(U).length,inputChars:t.length+c(d).length+JSON.stringify(a||{}).length,chatChars:f.reduce((e,t)=>e+c(t?.content).length,0),docsChars:p.reduce((e,t)=>e+c(t?.content).length+c(t?.preview).length,0),outputChars:Math.max(5e3,e.length*4500)});return n.ok?!0:(u(`${n.message} 请先充值后再开始。`),!1)}catch(e){return u(String(e?.message||`暂时无法校验积分余额，请稍后重试。`)),!1}};return{embeddedToolKind:_,setEmbeddedToolKind:v,embeddedResumeDraft:y,setEmbeddedResumeDraft:b,embeddedJdDraft:x,setEmbeddedJdDraft:ee,embeddedToolBusy:S,setEmbeddedToolBusy:C,embeddedToolProgress:w,setEmbeddedToolProgress:E,embeddedToolStatus:D,setEmbeddedToolStatus:k,workflowBusy:A,setWorkflowBusy:ne,workflowStatus:M,setWorkflowStatus:N,workflowStepsState:re,setWorkflowStepsState:P,executionLedger:F,setExecutionLedger:I,embeddedToolResult:L,setEmbeddedToolResult:R,derivedResumeText:H,derivedJdText:U,workflowPlan:W,resumableWorkflowPlan:G,pushEmbeddedToolTurn:B,appendExecutionLedgerEntry:V,runEmbeddedCoachTool:async(e,t)=>{if(n||r||S||A&&!t?.viaWorkflow)return!1;if(!i)return u(`请先确认职业教练的专业模型与扣费提示，再开始使用。`),!1;let s=await o();if(!s?.token)return window.location.href=j(),!1;let l=c(t?.prefillHint)||U,d=H,f=l;if((e===`resume_match`||e===`resume_optimize`||e===`resume_translate`||e===`resume_html`)&&!d)return u(`请先上传或粘贴你的简历内容，再让职业教练调用相关工具。`),!1;if((e===`resume_match`||e===`resume_optimize`||e===`jd_analysis`)&&!f)return u(`请先在对话里粘贴目标 JD，或在下方工作台补充 JD 内容。`),!1;if(!await ue(e,{resumeText:d,jdText:f,extraChars:c(t?.prefillHint).length}))return!1;c(t?.prefillHint)&&ee(c(t?.prefillHint)),v(e),C(!0),E(6),k(`正在执行${Ze[e]}…`),R(null);let p=`ledger_${e}_${Date.now()}_${Math.random().toString(16).slice(2,8)}`,h=Date.now(),g=await ie({pageSize:100,rangeDays:1}),_=``,y=``,b=new AbortController;try{if(e===`resume_match`){let n=await se([ye(f,a)],d,{provider:st,model:ut,thinking:!0,signal:b.signal,onProgress:E}),r=Array.isArray(n.items)?n.items[0]:null,i=[c(n.summary),...Array.isArray(r?.actions)?r.actions.slice(0,3):[]].filter(Boolean).join(`
`);R({kind:e,title:`简历匹配结果`,summary:`匹配度 ${Math.round(Number(n.overallScore||r?.score||0))} 分`,content:J(i||`已生成简历匹配结果。`,1600)}),await O({id:`career_inline_${e}_${Date.now()}`,toolType:`resume_match`,title:`职业教练内嵌简历匹配`,score:Number.isFinite(Number(n.overallScore))?`${Math.round(Number(n.overallScore||0))}`:void 0,createdAt:Date.now(),deepLink:m(`resume_match`)||`/tools/career-coach`,userId:c(s.user?.id)||void 0,insightSummary:z(`resume_match`,n)},n),y=c(n?.meta?.model||n?.model),_=`匹配度 ${Math.round(Number(n.overallScore||r?.score||0))} 分`,B(t?.viaWorkflow?`工作流已完成简历匹配`:`已完成简历匹配`,i||`我已经在当前对话里完成了简历与目标 JD 的匹配分析。`)}else if(e===`resume_optimize`){let n=await oe([ye(f,a)],d,{provider:st,model:ct,thinking:!0,signal:b.signal,onProgress:E}),r=Array.isArray(n.items)?n.items[0]:null,i=c(r?.optimizedResume),o=[c(r?.fitSummary),...Array.isArray(r?.changes)?r.changes.slice(0,4):[]].filter(Boolean).join(`
`);R({kind:e,title:`简历优化结果`,summary:c(r?.fitSummary)||`已生成针对目标岗位的改写版简历`,content:J(i||o||`已完成简历优化。`,2400)}),await O({id:`career_inline_${e}_${Date.now()}`,toolType:`resume_optimize`,title:`职业教练内嵌简历优化`,score:Number.isFinite(Number(r?.fitScore))?`${Math.round(Number(r?.fitScore||0))}`:void 0,createdAt:Date.now(),deepLink:m(`resume_optimize`)||`/tools/career-coach`,userId:c(s.user?.id)||void 0,insightSummary:z(`resume_optimize`,n)},n),y=c(n?.meta?.model||n?.model),_=c(r?.fitSummary)||`已生成改写版简历`,B(t?.viaWorkflow?`工作流已完成简历优化`:`已完成简历优化`,o||`我已经在当前对话里完成了简历优化，你可以直接继续追问。`)}else if(e===`jd_analysis`){let n=await Xe({requirementsIdea:f,roleTitle:c(a.targetRole)||void 0},{signal:b.signal}),r=[c(n.talentPersona)?`目标画像：${c(n.talentPersona)}`:``,Array.isArray(n.keywords)?`关键词：${n.keywords.slice(0,6).join(`、`)}`:``,Array.isArray(n.risks)?`风险点：${n.risks.slice(0,3).join(`；`)}`:``].filter(Boolean).join(`
`);R({kind:e,title:`JD 分析结果`,summary:`已提炼岗位关键词、目标画像与风险点`,content:J(r||c(n.optimizedJd)||`已完成 JD 分析。`,1800)}),await O({id:`career_inline_${e}_${Date.now()}`,toolType:`jd_analysis`,title:`职业教练内嵌 JD 分析`,createdAt:Date.now(),deepLink:`/tools/career-coach`,userId:c(s.user?.id)||void 0,insightSummary:{title:`JD 分析`,headline:J(r,72)||`已提炼岗位关键信号`,primaryAction:`根据 JD 结果继续优化简历`}},n),y=c(n?.meta?.model||n?.model),_=`已提炼岗位关键词与目标画像`,B(t?.viaWorkflow?`工作流已完成 JD 分析`:`已完成 JD 分析`,r||`我已经在当前对话里完成了 JD 分析。`)}else if(e===`resume_translate`){let n=await le(d,{signal:b.signal,to:`en`,onProgress:E,onPartial:t=>R({kind:e,title:`英文简历译文`,summary:`正在生成英文版简历`,content:J(c(t.en),2400)})});R({kind:e,title:`英文简历译文`,summary:n.piiFound?`已完成翻译，并自动做了隐私保护处理`:`已完成英文简历翻译`,content:J(c(n.en),2400)}),await O({id:`career_inline_${e}_${Date.now()}`,toolType:`resume_translate`,title:`职业教练内嵌简历翻译`,createdAt:Date.now(),deepLink:`/tools/career-coach`,userId:c(s.user?.id)||void 0,insightSummary:{title:`简历翻译`,headline:n.piiFound?`已翻译并做隐私处理`:`已生成英文版简历`,primaryAction:`检查术语后再用于投递`}},n),y=c(n?.provider||n?.model),_=n.piiFound?`已生成带隐私处理的译文`:`已生成英文版简历`,B(t?.viaWorkflow?`工作流已完成简历翻译`:`已完成简历翻译`,`我已经在当前对话里生成了英文版简历，你可以继续让我润色或导出。`)}else if(e===`resume_html`){let n=await T({resumeText:d,signal:b.signal}),r=c(n?.html||``),i=new Blob([r],{type:`text/html;charset=utf-8`}),a=URL.createObjectURL(i);R({kind:e,title:`HTML 简历已生成`,summary:`可直接下载 HTML，再用浏览器打印另存为 PDF`,content:J(r.replace(/<[^>]+>/g,` `),1600),downloadName:`career-coach-resume.html`,downloadUrl:a}),await O({id:`career_inline_${e}_${Date.now()}`,toolType:`resume_html`,title:`职业教练内嵌 HTML 简历`,createdAt:Date.now(),deepLink:`/tools/career-coach`,userId:c(s.user?.id)||void 0,insightSummary:{title:`HTML 简历`,headline:`已生成可下载 HTML 简历`,primaryAction:`下载后用浏览器打印为 PDF`}},n),y=c(n?.model||n?.provider),_=`已生成可下载的 HTML 简历`,B(t?.viaWorkflow?`工作流已完成 HTML 简历生成`:`已完成 HTML 简历生成`,`我已经在当前对话里生成了 HTML 简历，你可以直接下载并另存为 PDF。`)}E(100),k(`${Ze[e]}已完成`);let n=await ae({beforeIds:g,aggregateAllNew:!0,pageSize:100,rangeDays:1});return V({id:p,tool:e,title:Ze[e],reason:t?.viaWorkflow?`由职业教练编排方案自动触发`:`由职业教练当前对话直接触发`,status:`completed`,source:t?.viaWorkflow?`workflow`:`manual`,startedAt:h,finishedAt:Date.now(),requestCount:Number(n?.requests||0)||void 0,totalTokens:Number(n?.totalTokens||0)||void 0,estimatedPoints:Number(n?.estimatedPoints||0)||void 0,actualPoints:Number(n?.actualPoints||0)||void 0,pointsStatus:n?.pointsStatus===`actual`||n?.pointsStatus===`mixed`||n?.pointsStatus===`estimated`?n.pointsStatus:void 0,model:y||void 0,note:_||void 0}),!0}catch(n){let r=await ae({beforeIds:g,aggregateAllNew:!0,pageSize:100,rangeDays:1}).catch(()=>null);return V({id:p,tool:e,title:Ze[e],reason:t?.viaWorkflow?`由职业教练编排方案自动触发`:`由职业教练当前对话直接触发`,status:`failed`,source:t?.viaWorkflow?`workflow`:`manual`,startedAt:h,finishedAt:Date.now(),requestCount:Number(r?.requests||0)||void 0,totalTokens:Number(r?.totalTokens||0)||void 0,estimatedPoints:Number(r?.estimatedPoints||0)||void 0,actualPoints:Number(r?.actualPoints||0)||void 0,pointsStatus:r?.pointsStatus===`actual`||r?.pointsStatus===`mixed`||r?.pointsStatus===`estimated`?r.pointsStatus:void 0,model:y||void 0,note:te(n,`${Ze[e]}执行失败`)}),u(te(n,`${Ze[e]}执行失败`)),k(``),!1}finally{C(!1)}},runCareerCoachWorkflow:async t=>{let i=Array.isArray(t)&&t.length?t:W;if(!(!i.length||A||S||n||r)&&await de(i)){u(``),ne(!0),N(`职业教练正在通过后端执行器编排并执行多步方案…`),l(e=>e&&{...e,workflowContext:{resumeText:H,jdText:U}}),P(i.map(e=>({id:e.id,kind:e.kind,title:e.title,reason:e.reason,status:`pending`})));try{let t=await Ue({sessionId:c(e),profile:a,steps:i,resumeText:H,jdText:U}),n=new Map(t.steps.map(e=>[e.id,e.status===`failed`?`failed`:`completed`]));P(e=>e.map(e=>({...e,status:n.get(e.id)||e.status}))),t.steps.forEach(e=>{V({id:e.id,tool:e.tool,title:e.title||tt(e.tool),reason:e.reason,status:e.status,source:e.source||`backend_executor`,startedAt:Date.now(),finishedAt:Date.now(),requestCount:e.requestCount,totalTokens:e.totalTokens,estimatedPoints:e.estimatedPoints,model:e.model,note:e.note}),c(e.outputText)&&B(e.status===`failed`?`工作流在 ${e.title} 停止`:`后端执行器已完成${e.title}`,c(e.outputText)||c(e.note))}),t.stoppedAt?N(`已在 ${t.stoppedAt} 停止，可在补充材料后续跑未完成步骤。`):(N(`多步方案已完成，共执行 ${t.completedCount} 个动作。`),B(`多步编排执行完成`,`职业教练已通过后端执行器完成 ${t.completedCount} 个协同步骤。你可以继续追问，我会基于这些结果继续推进。`))}finally{ne(!1)}}}}}var mt=(e,t=8,n=80)=>Array.from(new Set((Array.isArray(e)?e:[]).map(e=>c(e)).filter(Boolean))).slice(0,t).map(e=>e.length<=n?e:`${e.slice(0,Math.max(1,n-1)).trimEnd()}…`),ht=async e=>{let t=await B(e);if(!t.ok)throw Error(t.error||`${e.op}_failed`);return t.data},gt=async e=>{let t=await ht({op:`list_career_knowledge_items`,query:c(e?.query).slice(0,200),tags:mt(e?.tags,8,48),audienceTags:mt(e?.audienceTags,8,48),limit:Math.max(1,Math.min(12,Math.floor(Number(e?.limit||6)||6)))});return Array.isArray(t?.items)?t.items:[]},_t=`deepseek_pro`,vt=`DeepSeek V4 Pro`,yt=!0,bt=(e,t=4e3)=>{let n=String(e??``);return n.length<=t?n:n.slice(0,Math.max(0,t))},xt=(e,t=0)=>{if(e==null)return e;if(typeof e==`string`)return bt(e,t<=1?6e3:2e3);if(typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e))return e.slice(0,t<=1?24:12).map(e=>xt(e,t+1));if(typeof e==`object`){if(t>=5)return;let n={};return Object.entries(e).slice(0,t===0?40:24).forEach(([e,r])=>{let i=xt(r,t+1);i!==void 0&&(n[e]=i)}),n}},St=e=>({...e,providerMeta:void 0,fallbackMeta:void 0,billing:e?.billing?{...e.billing,model:``}:e?.billing}),Ct=e=>(Array.isArray(e)?e:[]).map(e=>St(e)),wt=e=>(Array.isArray(e)?e:[]).slice(-40).map(e=>({...St(e),content:bt(e?.content,5e3),reasoningContent:bt(e?.reasoningContent,1200),rawParts:void 0,toolCalls:Array.isArray(e?.toolCalls)?e.toolCalls.slice(0,4).map(e=>xt(e,1)):void 0})),Tt=e=>(Array.isArray(e)?e:[]).slice(-8).map(e=>({...e,content:bt(e?.content,4e3),preview:bt(e?.preview||e?.content,1200)})),Et=e=>e&&typeof e==`object`?xt(e,0):null,Dt={currentRole:``,yearsExperience:``,targetRole:``,targetIndustry:``,location:``,workMode:``,compensationGoal:``,urgency:``,riskTolerance:``,summary:``,goals:[],constraints:[]},Ot={resume_match:`/tools/resume-match`,resume_optimize:`/tools/resume-optimize`,interview_coach:`/tools/interview-coach`,salary_negotiation:`/tools/salary-negotiation`};function kt(){let e=i(),t=r(),[n,s]=(0,K.useState)(!1),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(``),[p,h]=(0,K.useState)(``),[g,_]=(0,K.useState)(0),[v,y]=(0,K.useState)(``),{start:b,setProgress:x,done:ee,failByMessage:S}=ue(),[C,w]=(0,K.useState)(``),[T,E]=(0,K.useState)(null),[O,j]=(0,K.useState)([]),[M,N]=(0,K.useState)([]),[re,P]=(0,K.useState)([]),[F,ie]=(0,K.useState)(``),[ae,I]=(0,K.useState)(``),[L,oe]=(0,K.useState)(``),[se,ce]=(0,K.useState)(``),z=(0,K.useRef)(``),le=(0,K.useRef)(null),B=(0,K.useRef)(``),V=(0,K.useRef)(null),U=(0,K.useRef)(null),W=(0,K.useRef)(null),G=(0,K.useRef)(0),fe=(0,K.useRef)([]),pe=(0,K.useRef)(null),[_e,q]=(0,K.useState)(``),[ye,J]=(0,K.useState)(()=>!!a()?.token),[xe,Se]=(0,K.useState)(()=>!!a()?.token),[Ce,Te]=(0,K.useState)(``),[Ee,Oe]=(0,K.useState)(`deep`),[Z,ke]=(0,K.useState)(Dt),[Ae,je]=(0,K.useState)(``),[Me,Ne]=(0,K.useState)(_t),[Pe,Fe]=(0,K.useState)(yt),[Ie,Le]=(0,K.useState)(!0),Re=(0,K.useRef)(c(a()?.user?.id)),ze=(0,K.useMemo)(()=>new URLSearchParams(t.search).get(`sid`)||``,[t.search]),Be=(0,K.useCallback)(async()=>({modelChoice:_t,modelLabel:vt,thinkingEnabled:yt}),[]),Q=e=>{j(t=>[...t,e].slice(-80))},He=(e,t)=>{c(e)&&j(n=>n.map(n=>n.id===e?{...n,...t}:n).slice(-80))},Ue=He,We=be,Ge=()=>{fe.current.forEach(e=>window.clearTimeout(e)),fe.current=[]},Ke=(e,t)=>{Ge(),h(c(e)),_(1);let n=Array.isArray(t.actionPlan)&&t.actionPlan.length>0,r=Array.isArray(t.roadmap)&&t.roadmap.length>0,i=Array.isArray(t.followUpQuestions)&&t.followUpQuestions.length>0,a=Ee===`quick`?260:Ee===`deep`?620:420,o=Ee===`quick`?560:Ee===`deep`?1180:860;(n||r||i)&&fe.current.push(window.setTimeout(()=>_(2),a)),(r||i)&&fe.current.push(window.setTimeout(()=>_(3),o))},qe=(0,K.useRef)({setExecutionLedger:null,setWorkflowStatus:null,setWorkflowStepsState:null}),Je=(0,K.useCallback)(()=>{Ge();try{W.current?.abort()}catch{}y(``),E(null),h(``),_(0),j([]),s(!1),u(!1),f(``),N([]),P([]),qe.current.setExecutionLedger?.([]),qe.current.setWorkflowStatus?.(``),qe.current.setWorkflowStepsState?.([]),w(``),Te(``),q(``),ke(Dt),H({setStreamText:ie,setStreamThinking:I,setStreamStage:oe,setStreamActor:ce,streamTextRawRef:z,streamThinkingRawRef:B,streamTextFlushTimerRef:le,streamThinkingFlushTimerRef:V}),ge()},[]);(0,K.useEffect)(()=>{if(ze)return;let e=he();if(!e||typeof e!=`object`)return;Array.isArray(e.chatTurns)&&j(Ct(e.chatTurns).slice(-80)),e.result&&typeof e.result==`object`&&E(e.result),Array.isArray(e.uploadedDocs)&&N(e.uploadedDocs.slice(-12)),e.profile&&typeof e.profile==`object`&&ke(t=>({...t,...e.profile})),c(e.pinnedContext)&&je(c(e.pinnedContext)),c(e.sessionId)&&Te(c(e.sessionId)),Oe(`deep`);let t=c(e.runState);t===`failed`?S(String(e.err||`生成失败`),y):t===`cancelled`&&S(`已取消`,y)},[]),(0,K.useEffect)(()=>(U.current&&window.clearTimeout(U.current),U.current=window.setTimeout(()=>{me(`career_coach`,{sessionId:Ce,profile:xt(Z,0),chatTurns:wt(O),uploadedDocs:Tt(M),analysisDepth:Ee,result:Et(T),pinnedContext:Ae}),U.current=null},240),()=>{U.current&&=(window.clearTimeout(U.current),null)}),[Ee,O,Ae,Z,T,Ce,M]),(0,K.useEffect)(()=>{let e=pe.current;if(e)try{e.scrollTop=e.scrollHeight}catch{}},[n,O.length,_e,F,ae]),(0,K.useEffect)(()=>()=>Ge(),[]),(0,K.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await o();if(!e)return;let n=c(t?.user?.id);Re.current&&n&&Re.current!==n?(Re.current=n,Je()):!Re.current&&n?Re.current=n:Re.current&&!n&&(Re.current=``),J(!!t?.token),Se(!0)}catch{if(!e)return;Se(!0)}};t();let n=()=>{t()};return window.addEventListener(`AUTH_SESSION_UPDATED_WEB`,n),()=>{e=!1,window.removeEventListener(`AUTH_SESSION_UPDATED_WEB`,n)}},[Je]),(0,K.useEffect)(()=>{let e=c(ze);if(!e)return;let t=he();!t||c(t.sessionId)!==e||(Te(e),t.result&&typeof t.result==`object`&&E(t.result),t.profile&&typeof t.profile==`object`&&ke(e=>({...e,...t.profile})),Array.isArray(t.chatTurns)&&j(Ct(t.chatTurns).slice(-80)),Array.isArray(t.uploadedDocs)&&N(t.uploadedDocs.map(e=>({name:c(e?.name),content:c(e?.content||e?.preview),preview:c(e?.preview||e?.content)}))),Oe(`deep`),y(``))},[ze]);let Ye=(0,K.useMemo)(()=>c([...O].reverse().find(e=>e.role===`assistant`)?.id),[O]);(0,K.useEffect)(()=>{if(!l){if(!T||!Ye){h(``),_(0);return}p!==Ye&&(Ge(),h(Ye),_(3))}},[l,p,Ye,T]);let Xe=(0,K.useMemo)(()=>{let e=O.filter(e=>e.role===`user`||e.role===`assistant`).slice(0,-12);if(!e.length)return``;let t=e.filter(e=>e.role===`user`).slice(-4).map(e=>`用户：${c(e.content).replace(/\s+/g,` `).slice(0,90)}`).filter(Boolean),n=e.filter(e=>e.role===`assistant`).slice(-3).map(e=>`教练：${c(e.content).replace(/\s+/g,` `).slice(0,90)}`).filter(Boolean),r=[...t,...n].slice(-6);return r.length?r.join(`
`):``},[O]),Ze=e=>{let t=Ot[e];return t?k(t,`tool`,{source:`career_coach`,sid:c(Ce)}):``},Qe=(e,t)=>{let n=Ze(e),r=c(Ce);r&&D({sid:r,source:`career_coach`,tool:e,createdAt:Date.now(),resumeText:bt(Nt,12e3),jdText:bt(Pt,12e3),currentRole:c(Z.currentRole),targetRole:c(Z.targetRole),targetIndustry:c(Z.targetIndustry),summary:c(Z.summary)||Xe,primaryAction:c(T?.primaryAction),nextQuestion:c(T?.nextQuestion),prefillHint:c(t)}),n&&(window.location.href=n)},{embeddedToolKind:$e,setEmbeddedToolKind:et,embeddedResumeDraft:tt,setEmbeddedResumeDraft:nt,embeddedJdDraft:rt,setEmbeddedJdDraft:it,embeddedToolBusy:at,setEmbeddedToolBusy:ot,embeddedToolProgress:st,setEmbeddedToolProgress:ct,embeddedToolStatus:lt,setEmbeddedToolStatus:ut,workflowBusy:dt,setWorkflowBusy:ft,workflowStatus:mt,setWorkflowStatus:ht,workflowStepsState:St,setWorkflowStepsState:kt,executionLedger:$,setExecutionLedger:At,embeddedToolResult:jt,setEmbeddedToolResult:Mt,derivedResumeText:Nt,derivedJdText:Pt,workflowPlan:Ft,resumableWorkflowPlan:It,pushEmbeddedToolTurn:Lt,appendExecutionLedgerEntry:Rt,runEmbeddedCoachTool:zt,runCareerCoachWorkflow:Bt}=pt({sessionId:Ce,isAuthed:ye,busy:n,detailBusy:l,coachConsentAccepted:Ie,profile:Z,result:T,setResult:E,setErr:y,dialogInput:C,chatTurns:O,uploadedDocs:M,buildActionHref:Ze,jumpToRecommendedTool:Qe,appendChatTurn:Q});qe.current={setExecutionLedger:At,setWorkflowStatus:ht,setWorkflowStepsState:kt};let Vt=async()=>{try{localStorage.setItem(ve,`1`)}catch{}Le(!0),Fe(!0)},Ht=async e=>{},Ut=async e=>{let t=c(e.sid||Ce);if(!t)return;let n=e.nextResult===void 0?T:e.nextResult,r=Ct(Array.isArray(e.chatTurnsOverride)?e.chatTurnsOverride:O),i=Array.isArray(e.uploadedDocsOverride)?e.uploadedDocsOverride:M;me(`career_coach`,{sessionId:t,runState:e.status===`running`?`running`:e.status===`failed`?`failed`:`done`,err:c(e.error)||void 0,profile:xt(Z,0),result:Et(n||null),chatTurns:wt(r),uploadedDocs:Tt(i),analysisDepth:Ee})},Wt=(0,K.useRef)(Ut);Wt.current=Ut,(0,K.useEffect)(()=>{if(!Ce||!T||!$.length||n||l||at||dt)return;let e=window.setTimeout(()=>{Wt.current({status:`done`,nextResult:{...T,executionLedger:$},runtimeState:{modelChoice:Me,thinkingEnabled:Pe}})},420);return()=>window.clearTimeout(e)},[n,l,at,$,Me,T,Ce,Pe,dt]);let Gt=async e=>{let t=Array.isArray(e)?e.slice(0,4):[];if(!t.length)return;if(!(await o())?.token)throw Error(`请先登录后上传文件`);if(!await m())throw Error(`未同意隐私条款，已取消文件解析`);let n=[],r=[];try{for(let e of t){let t=c(e?.name)||`附件`,i=t.toLowerCase(),a=``;if(q(`解析 ${t}…`),a=c(await R(e,{minLength:120,onStage:e=>q(`${t} · ${c(e)||`解析中`}`)}).catch(()=>i.endsWith(`.txt`)||i.endsWith(`.md`)||i.endsWith(`.markdown`)||i.endsWith(`.json`)||i.endsWith(`.csv`)?e.text().catch(()=>``):``)),!a)throw Error(`${t} 解析失败，请重试`);let o=we(a);n.push({name:t,content:a,preview:o}),r.push({name:t,preview:o})}}finally{q(``)}N(e=>[...e,...n].slice(-12)),P(e=>[...e,...r].slice(-12))},Kt=e=>{P(t=>t.filter((t,n)=>n!==e)),N(t=>t.filter((t,n)=>n!==e))},qt=e=>de(c(e),`center`),Jt=async()=>{Je();try{e(`/tools/career-coach`,{replace:!0})}catch{}},{submit:Yt,generateDetailedPlan:Xt}=Ve({sessionId:Ce,busy:n,detailBusy:l,coachConsentAccepted:Ie,profile:Z,result:T,setResult:E,setErr:y,dialogInput:C,setDialogInput:w,chatTurns:O,uploadedDocs:M,setStreamText:ie,writeToolConversationRun:me,start:b,setProgress:x,appendChatTurn:Q,updateChatTurn:Ue,abortRef:W,clearDetailCardTimers:Ge,setDetailBusy:u,setDetailStatus:f,setDetailCardTurnId:h,setDetailCardStage:_,setBusy:s,makeId:We,setSessionId:Te,navigate:e,runSeqRef:G,pendingAttachments:re,setPendingAttachments:P,resetBufferedConversationState:H,setStreamThinking:I,setStreamStage:oe,setStreamActor:ce,streamTextRawRef:z,streamThinkingRawRef:B,streamTextFlushTimerRef:le,streamThinkingFlushTimerRef:V,setModelChoiceState:Ne,syncProfileToCloud:Ht,syncSessionToCloud:Ut,listLocalToolResultSummaries:A,listCareerCoachKnowledgeItems:gt,analysisDepth:Ee,withTimeout:ne,done:ee,failByMessage:S,executionLedger:$,derivedResumeText:Nt,derivedJdText:Pt,pinnedContext:Ae,autoProgressSummary:Xe,beginDetailCardReveal:Ke,normalizeToolError:te,sanitizeTurnRawParts:Y,sanitizeTurnToolCalls:X,buildPlainStreamPreview:De});return{navigate:e,location:t,busy:n,setBusy:s,detailBusy:l,setDetailBusy:u,detailStatus:d,setDetailStatus:f,detailCardTurnId:p,setDetailCardTurnId:h,detailCardStage:g,setDetailCardStage:_,err:v,setErr:y,dialogInput:C,setDialogInput:w,result:T,setResult:E,chatTurns:O,setChatTurns:j,uploadedDocs:M,setUploadedDocs:N,pendingAttachments:re,setPendingAttachments:P,streamText:F,setStreamText:ie,streamThinking:ae,setStreamThinking:I,_streamStage:L,setStreamStage:oe,_streamActor:se,setStreamActor:ce,streamTextRawRef:z,streamTextFlushTimerRef:le,streamThinkingRawRef:B,streamThinkingFlushTimerRef:V,abortRef:W,runSeqRef:G,detailCardTimersRef:fe,chatScrollRef:pe,parseStage:_e,setParseStage:q,isAuthed:ye,setIsAuthed:J,sessionId:Ce,setSessionId:Te,analysisDepth:Ee,setAnalysisDepth:Oe,profile:Z,setProfile:ke,pinnedContext:Ae,setPinnedContext:je,autoProgressSummary:Xe,modelChoice:Me,thinkingEnabledState:Pe,setThinkingEnabledState:Fe,coachConsentAccepted:Ie,authResolved:xe,setCoachConsentAccepted:Le,embeddedToolKind:$e,setEmbeddedToolKind:et,embeddedResumeDraft:tt,setEmbeddedResumeDraft:nt,embeddedJdDraft:rt,setEmbeddedJdDraft:it,embeddedToolBusy:at,setEmbeddedToolBusy:ot,embeddedToolProgress:st,setEmbeddedToolProgress:ct,embeddedToolStatus:lt,setEmbeddedToolStatus:ut,workflowBusy:dt,setWorkflowBusy:ft,workflowStatus:mt,setWorkflowStatus:ht,workflowStepsState:St,setWorkflowStepsState:kt,executionLedger:$,setExecutionLedger:At,embeddedToolResult:jt,setEmbeddedToolResult:Mt,authUserIdRef:Re,latestSessionQuery:ze,readLatestCloudRuntimeState:Be,appendChatTurn:Q,patchChatTurn:He,clearDetailCardTimers:Ge,beginDetailCardReveal:Ke,resetConversationStateForUserIsolation:Je,latestAssistantTurnId:Ye,showReplyPreview:!1,buildActionHref:Ze,derivedResumeText:Nt,derivedJdText:Pt,workflowPlan:Ft,resumableWorkflowPlan:It,persistCoachConsent:Vt,pushEmbeddedToolTurn:Lt,appendExecutionLedgerEntry:Rt,runEmbeddedCoachTool:zt,runCareerCoachWorkflow:Bt,jumpToRecommendedTool:Qe,syncProfileToCloud:Ht,syncSessionToCloud:Ut,ingestFilesToChat:Gt,removePendingAttachment:Kt,jumpToTurn:qt,resetAll:Jt,submit:Yt,generateDetailedPlan:Xt}}var $=n(),At=`
@keyframes careerCoachStageFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes careerCoachStagePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.18);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(245, 158, 11, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}
.career-coach-stage-card {
  animation: careerCoachStageFadeIn 320ms ease both;
}
.career-coach-stage-card.active {
  animation: careerCoachStageFadeIn 320ms ease both, careerCoachStagePulse 1.4s ease-out 1;
}
`;function jt({assistantTurnId:e,detailCardTurnId:t,detailCardStage:n,result:r,onAnswerQuestion:i,onOpenReport:a,onRunTool:o}){let s=(0,K.useRef)(null),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(`overview`),p=Array.isArray(r.actionPlan)?r.actionPlan.slice(0,3):[],m=Array.isArray(r.followUpQuestions)?r.followUpQuestions.slice(0,4):[],_=Array.isArray(r.roadmap)?r.roadmap.slice(0,3):[],v=Array.isArray(r.toolRecommendations)?r.toolRecommendations.slice(0,2):[],y=r.diagnosis,b=p.length>0,x=m.length>0,ee=!!(y&&c(y.currentState)),S=_.length>0,C=t===e,w=C?n:3,T=ee&&w>=1,E=b&&w>=2,D=S&&w>=(b?3:2),O=x&&w>=3,k=[{key:`diag`,label:`诊断摘要`,visible:ee,reached:w>=1},{key:`plan`,label:`行动计划`,visible:b,reached:w>=2},{key:`roadmap`,label:`路线图`,visible:S||x,reached:w>=(b?3:2)}].filter(e=>e.visible),A=w<2&&b?`plan`:w<(b?3:2)&&(S||x)?`roadmap`:``,te=w<2&&b?`正在补充行动计划…`:w<(b?3:2)&&S?`正在补充阶段路线图…`:w<3&&x?`正在补充关键追问…`:``;if(!b&&!x&&!ee&&!S&&!c(r.summary))return null;let j=async()=>{if(!(!s.current||l)){u(!0);try{await h({element:s.current,fileName:`career-coach-summary.png`,backgroundColor:`#F7F5F2`,pixelRatio:2})}finally{u(!1)}}};return(0,$.jsxs)(`div`,{style:{marginTop:22,display:`flex`,flexDirection:`column`,gap:14},children:[(0,$.jsx)(`style`,{children:At}),(0,$.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8},"data-export-ignore":`1`,children:[a?(0,$.jsx)(`button`,{type:`button`,className:`btn-secondary`,style:{padding:`0 12px`,height:30,fontSize:12},onClick:a,children:`查看完整报告`}):null,(0,$.jsx)(`button`,{type:`button`,className:`btn-secondary`,style:{padding:`0 12px`,height:30,fontSize:12},onClick:()=>void j(),disabled:l,children:(0,$.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:6},children:[(0,$.jsx)(g,{size:14}),l?`导出中`:`导出摘要`]})})]}),(0,$.jsxs)(`div`,{ref:s,style:{display:`grid`,gap:14,padding:16,borderRadius:18,border:`1px solid color-mix(in srgb, var(--accent) 18%, var(--border))`,background:`linear-gradient(180deg, color-mix(in srgb, var(--surface) 98%, transparent) 0%, color-mix(in srgb, var(--accent) 6%, var(--surface)) 100%)`},children:[(0,$.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,gap:12,flexWrap:`wrap`},children:[(0,$.jsxs)(`div`,{style:{maxWidth:620},children:[(0,$.jsx)(`div`,{style:{fontSize:11,fontWeight:700,letterSpacing:`0.18em`,textTransform:`uppercase`,color:`var(--accent)`},children:`职业教练摘要`}),(0,$.jsx)(`div`,{style:{marginTop:8,fontSize:24,fontWeight:800,lineHeight:1.32,color:`var(--text-1)`},children:c(r.directionVerdict)||c(r.title)||`你的下一步方向已经整理好了`}),(0,$.jsx)(`div`,{style:{marginTop:8,fontSize:13,lineHeight:1.75,color:`var(--text-2)`},children:c(r.summary)||c(r.primaryAction)||`你可以直接按下面的行动计划推进，也可以先回答关键追问让我继续细化。`})]}),(0,$.jsxs)(`div`,{style:{minWidth:176,borderRadius:18,border:`1px solid color-mix(in srgb, var(--accent) 16%, var(--border))`,background:`var(--surface)`,padding:`14px 16px`},children:[(0,$.jsx)(`div`,{style:{fontSize:12,color:`var(--text-3)`},children:`信心分`}),(0,$.jsx)(`div`,{style:{marginTop:8,fontSize:34,fontWeight:800,color:`var(--accent)`},children:Number.isFinite(Number(r.confidenceScore))?Number(r.confidenceScore):`--`}),(0,$.jsx)(`div`,{style:{fontSize:12,color:`var(--text-3)`},children:c(r.stage)||`职业判断`}),(0,$.jsx)(`div`,{style:{marginTop:6,fontSize:11,color:`var(--text-3)`,lineHeight:1.6},children:`基于你提供的信息完整度、目标明确度与上下文一致性估计。补充简历 / JD / Offer 可提升准确度。`})]})]}),(0,$.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`},children:[c(r.primaryAction)?(0,$.jsxs)(`span`,{style:{padding:`5px 12px`,borderRadius:999,border:`1px solid color-mix(in srgb, var(--accent) 18%, var(--border))`,background:`var(--surface)`,fontSize:11,fontWeight:600,color:`var(--accent)`},children:[`当前主动作：`,c(r.primaryAction)]}):null,c(r.nextQuestion)?(0,$.jsxs)(`span`,{style:{padding:`5px 12px`,borderRadius:999,border:`1px solid var(--border)`,background:`var(--surface)`,fontSize:11,fontWeight:600,color:`var(--text-2)`},children:[`下一问：`,c(r.nextQuestion)]}):null,v.map((e,t)=>(0,$.jsx)(`span`,{style:{padding:`5px 12px`,borderRadius:999,border:`1px solid var(--border)`,background:`var(--surface)`,fontSize:11,fontWeight:600,color:`var(--text-2)`},children:c(e.reason)||c(e.tool)},`${t}_${e.tool}`))]}),v.length||m.length?(0,$.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:16,padding:14,background:`var(--surface)`},"data-export-ignore":`1`,children:[(0,$.jsx)(`div`,{style:{fontSize:12,fontWeight:700,letterSpacing:`0.14em`,textTransform:`uppercase`,color:`var(--text-3)`},children:`下一步承接`}),(0,$.jsxs)(`div`,{style:{marginTop:10,display:`flex`,gap:10,flexWrap:`wrap`},children:[v.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,className:`ui-btn-primary`,onClick:()=>o?.(c(e.tool),c(e.prefillHint)),children:c(e.reason)||`继续执行 ${c(e.tool)}`},`${t}_${e.tool}`)),m[0]?(0,$.jsx)(`button`,{type:`button`,className:`ui-btn-outline`,onClick:()=>i(m[0]),children:`回答关键追问 →`}):null]})]}):null,(0,$.jsx)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`},"data-export-ignore":`1`,children:[{key:`overview`,label:`概览`},{key:`diagnosis`,label:`诊断`},{key:`plan`,label:`行动计划`},{key:`roadmap`,label:`路线图`},{key:`tools`,label:`推荐工具`}].map(e=>(0,$.jsx)(`button`,{type:`button`,className:`btn-secondary`,style:{minHeight:30,padding:`0 12px`,borderColor:d===e.key?`var(--accent)`:void 0,color:d===e.key?`var(--accent)`:void 0},onClick:()=>f(e.key),children:e.label},e.key))}),k.length?(0,$.jsxs)(`div`,{className:A?`career-coach-stage-card active`:`career-coach-stage-card`,style:{display:`grid`,gap:10,padding:`12px 14px`,borderRadius:14,border:`1px solid var(--border)`,background:`color-mix(in srgb, var(--surface) 94%, transparent)`},children:[(0,$.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,flexWrap:`wrap`},children:k.map((e,t)=>{let n=e.reached&&A!==e.key,r=A===e.key;return(0,$.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[(0,$.jsxs)(`div`,{style:{display:`inline-flex`,alignItems:`center`,gap:8},children:[(0,$.jsx)(`span`,{style:{width:22,height:22,borderRadius:999,display:`grid`,placeItems:`center`,fontSize:11,fontWeight:700,color:n||r?`#fff`:`var(--text-2)`,background:n?`var(--accent)`:r?`color-mix(in srgb, var(--accent) 86%, #fff)`:`var(--surface)`,border:n||r?`none`:`1px solid var(--border)`,transition:`all 220ms ease`,transform:r?`scale(1.06)`:`scale(1)`,boxShadow:r?`0 0 0 6px rgba(245,158,11,0.10)`:`none`},children:n?`完`:t+1}),(0,$.jsx)(`span`,{style:{fontSize:13,fontWeight:n||r?700:500,color:n||r?`var(--text-1)`:`var(--text-2)`,transition:`all 220ms ease`,transform:r?`translateY(-1px)`:`none`},children:e.label})]}),t<k.length-1?(0,$.jsx)(`span`,{style:{width:26,height:1,background:n?`color-mix(in srgb, var(--accent) 65%, var(--border))`:r?`color-mix(in srgb, var(--accent) 40%, var(--border))`:`var(--border)`,transition:`background 220ms ease`}}):null]},e.key)})}),(0,$.jsx)(`div`,{style:{fontSize:12,color:`var(--text-3)`},children:te||`详细内容已全部就绪`})]}):null,te?(0,$.jsx)(`div`,{className:`career-coach-stage-card active`,style:{padding:`10px 14px`,borderRadius:12,border:`1px solid var(--border)`,background:`color-mix(in srgb, var(--surface) 92%, transparent)`,color:`var(--text-2)`,fontSize:13},children:te}):null,T&&(d===`overview`||d===`diagnosis`)?(0,$.jsxs)(`div`,{className:`career-coach-stage-card${C&&w===1?` active`:``}`,style:{padding:16,background:`var(--bg2)`,borderRadius:12,border:`1px solid var(--border)`,boxShadow:C&&w===1?`0 14px 30px rgba(245,158,11,0.10)`:`0 8px 20px rgba(15,23,42,0.04)`,transition:`box-shadow 240ms ease, border-color 240ms ease`,borderColor:C&&w===1?`color-mix(in srgb, var(--accent) 42%, var(--border))`:`var(--border)`},children:[(0,$.jsx)(`div`,{style:{fontSize:14,fontWeight:700,color:`var(--text-1)`,marginBottom:12},children:`当前诊断与定位`}),(0,$.jsxs)(`div`,{style:{display:`grid`,gap:8,fontSize:13},children:[(0,$.jsxs)(`div`,{style:{display:`flex`,gap:12},children:[(0,$.jsx)(`span`,{style:{color:`var(--text-3)`,width:64,flexShrink:0},children:`当前阶段`}),(0,$.jsx)(`span`,{style:{color:`var(--text-1)`},children:c(y?.stage)})]}),(0,$.jsxs)(`div`,{style:{display:`flex`,gap:12},children:[(0,$.jsx)(`span`,{style:{color:`var(--text-3)`,width:64,flexShrink:0},children:`核心痛点`}),(0,$.jsx)(`span`,{style:{color:`var(--text-1)`},children:c(y?.painPoint)})]}),(0,$.jsxs)(`div`,{style:{display:`flex`,gap:12},children:[(0,$.jsx)(`span`,{style:{color:`var(--text-3)`,width:64,flexShrink:0},children:`现状评估`}),(0,$.jsx)(`span`,{style:{color:`var(--text-1)`,lineHeight:1.6},children:c(y?.currentState)})]})]})]}):null,E&&(d===`overview`||d===`plan`)?(0,$.jsxs)(`div`,{className:`career-coach-stage-card${C&&A===`plan`?` active`:``}`,style:{padding:16,background:`var(--bg2)`,borderRadius:12,border:`1px solid var(--border)`,boxShadow:C&&A===`plan`?`0 14px 30px rgba(245,158,11,0.10)`:`0 8px 20px rgba(15,23,42,0.04)`,transition:`box-shadow 240ms ease, border-color 240ms ease`,borderColor:C&&A===`plan`?`color-mix(in srgb, var(--accent) 42%, var(--border))`:`var(--border)`},children:[(0,$.jsx)(`div`,{style:{fontSize:14,fontWeight:700,color:`var(--text-1)`,marginBottom:16},children:`你的专属行动计划`}),(0,$.jsx)(`div`,{style:{display:`grid`,gap:16},children:p.map((e,t)=>(0,$.jsxs)(`div`,{style:{display:`flex`,gap:12,alignItems:`flex-start`},children:[(0,$.jsx)(`div`,{style:{width:24,height:24,borderRadius:`50%`,background:`var(--surface)`,border:`1px solid var(--border)`,display:`grid`,placeItems:`center`,fontSize:12,fontWeight:600,color:`var(--text-2)`,flexShrink:0,marginTop:2},children:t+1}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{style:{fontSize:14,fontWeight:600,color:`var(--text-1)`},children:c(e.title)||c(e.phase)}),(0,$.jsx)(`div`,{style:{fontSize:13,color:`var(--text-2)`,marginTop:4,lineHeight:1.6},children:c(e.why)})]})]},`${t}_${e.title||e.phase}`))})]}):null,D&&(d===`overview`||d===`roadmap`)?(0,$.jsxs)(`div`,{className:`career-coach-stage-card${C&&A===`roadmap`?` active`:``}`,style:{padding:16,background:`var(--bg2)`,borderRadius:12,border:`1px solid var(--border)`,boxShadow:C&&A===`roadmap`?`0 14px 30px rgba(245,158,11,0.10)`:`0 8px 20px rgba(15,23,42,0.04)`,transition:`box-shadow 240ms ease, border-color 240ms ease`,borderColor:C&&A===`roadmap`?`color-mix(in srgb, var(--accent) 42%, var(--border))`:`var(--border)`},children:[(0,$.jsx)(`div`,{style:{fontSize:14,fontWeight:700,color:`var(--text-1)`,marginBottom:16},children:`阶段路线图`}),(0,$.jsx)(`div`,{style:{display:`grid`,gap:16},children:_.map((e,t)=>(0,$.jsxs)(`div`,{style:{display:`flex`,gap:12,alignItems:`flex-start`},children:[(0,$.jsx)(`div`,{style:{width:6,height:6,borderRadius:`50%`,background:`var(--accent)`,marginTop:8,flexShrink:0}}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{style:{fontSize:13,fontWeight:600,color:`var(--text-1)`},children:[c(e.timeframe),` · `,c(e.focus)]}),(0,$.jsx)(`div`,{style:{fontSize:13,color:`var(--text-2)`,marginTop:6,display:`grid`,gap:6},children:(Array.isArray(e.actions)?e.actions:[]).slice(0,3).map((e,t)=>(0,$.jsxs)(`div`,{style:{lineHeight:1.5},children:[`- `,c(e)]},`${t}_${e}`))})]})]},`${t}_${e.timeframe||e.focus}`))})]}):null,(O||v.length)&&d===`tools`?(0,$.jsxs)(`div`,{className:`career-coach-stage-card`,style:{padding:16,background:`var(--bg2)`,borderRadius:12,border:`1px solid var(--border)`,boxShadow:`0 8px 20px rgba(15,23,42,0.04)`},"data-export-ignore":`1`,children:[v.length?(0,$.jsxs)(`div`,{style:{display:`grid`,gap:10,marginBottom:m.length?14:0},children:[(0,$.jsx)(`div`,{style:{fontSize:13,fontWeight:600,color:`var(--text-2)`},children:`推荐你继续使用这些工具：`}),v.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,className:`btn-secondary`,style:{textAlign:`left`,whiteSpace:`normal`,lineHeight:1.6,padding:`12px 16px`,justifyContent:`flex-start`},onClick:()=>o?.(c(e.tool),c(e.prefillHint)),children:c(e.reason)||`去使用 ${c(e.tool)}`},`${t}_${e.tool}`))]}):null,O?(0,$.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[(0,$.jsx)(`div`,{style:{fontSize:13,fontWeight:600,color:`var(--text-2)`},children:`如果你愿意，可以直接回答这些关键问题：`}),m.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,className:`btn-secondary`,style:{textAlign:`left`,whiteSpace:`normal`,lineHeight:1.6,padding:`12px 16px`,justifyContent:`flex-start`,border:`1px solid var(--border)`,background:`var(--surface)`},onClick:()=>i(e),children:`回答：${e}`},`${t}_${e}`))]}):null]}):null,O&&d===`overview`?(0,$.jsxs)(`div`,{className:`career-coach-stage-card`,style:{padding:16,background:`var(--bg2)`,borderRadius:12,border:`1px solid var(--border)`,boxShadow:`0 8px 20px rgba(15,23,42,0.04)`},"data-export-ignore":`1`,children:[(0,$.jsx)(`div`,{style:{fontSize:13,fontWeight:600,color:`var(--text-2)`,marginBottom:12},children:`如果你愿意，可以直接回答这些关键问题：`}),(0,$.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:m.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,className:`btn-secondary`,style:{textAlign:`left`,whiteSpace:`normal`,lineHeight:1.6,padding:`12px 16px`,justifyContent:`flex-start`,border:`1px solid var(--border)`,background:`var(--surface)`},onClick:()=>i(e),children:`回答：${e}`},`${t}_${e}`))})]}):null]})]})}function Mt({sticky:e=!0,busy:t,detailBusy:n,detailStatus:r,parseStage:i,needsUserInput:a,pendingAttachments:o,removePendingAttachment:s,dialogInput:l,setDialogInput:u,submit:d,ingestFilesToChat:f,isAuthed:p,chatTurns:m,result:h,sessionId:g,latestAssistantTurnId:_,jumpToTurn:v,runSeqRef:b,abortRef:x,setBusy:ee,setDetailBusy:S,setDetailStatus:C,err:w,setErr:T}){return(0,$.jsx)(`div`,{style:{position:e?`sticky`:`relative`,bottom:e?0:void 0,padding:e?`20px 0 30px 0`:`12px 0 8px 0`,background:e?`linear-gradient(180deg, rgba(10,13,18,0) 0%, color-mix(in srgb, var(--bg) 88%, transparent) 18%, var(--bg) 48%)`:`transparent`,backdropFilter:e?`blur(10px)`:void 0,zIndex:10},children:(0,$.jsx)(`div`,{style:{maxWidth:860,margin:`0 auto`},children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{busy:t,inputDisabled:!!i,fileDisabled:!!i||t||n,actionDisabled:t,pendingAttachments:o,onRemoveAttachment:s,value:l,onChange:u,onSubmit:()=>{d()},onFilesPicked:async e=>{try{await f(e)}catch(e){T(c(e?.message||`文件解析失败`))}},placeholder:m.length?``:`直接告诉我：你要面什么岗位，你目前的背景，JD重点，你担心的问题；也可以直接粘贴简历或岗位描述。`,helperText:``,parseStage:i,submitDisabled:!p,submitLabel:`发送`,simpleStyle:!0,minTextareaHeight:120,maxTextareaHeight:260,rightActions:(0,$.jsx)($.Fragment,{children:h&&c(g)?(0,$.jsx)(`a`,{href:`/report/career-coach?sid=${encodeURIComponent(c(g))}`,className:`btn-secondary`,style:{padding:`0 10px`,height:28,fontSize:12,lineHeight:`26px`,borderRadius:14,marginRight:8,background:`transparent`,border:`none`,color:`var(--text-2)`,textDecoration:`none`},children:`查看报告`}):null})}),a?(0,$.jsx)(`div`,{style:{marginTop:10,padding:`10px 12px`,borderRadius:14,border:`1px solid rgba(239,68,68,0.24)`,background:`rgba(239,68,68,0.07)`,fontSize:12,color:`var(--text-2)`},children:`我还差一点信息。你在这里补一句背景、目标或岗位细节，我就能接着往下推进。`}):null,n?(0,$.jsx)(`div`,{style:{marginTop:12,padding:`12px 14px`,borderRadius:16,border:`1px solid color-mix(in srgb, var(--border) 88%, transparent)`,background:`color-mix(in srgb, var(--surface) 85%, transparent)`,fontSize:13,color:`var(--text-2)`},children:r||`正在生成详细规划。你现在可以继续聊天，或等待完整规划生成完成。`}):null,(0,$.jsxs)(`div`,{className:`he-actions`,style:{marginTop:14,alignItems:`center`},children:[_?(0,$.jsx)(`button`,{type:`button`,className:`btn-secondary`,style:{padding:`0 12px`,height:28,fontSize:12},onClick:()=>v(_),children:`定位到最新回答`}):null,(0,$.jsx)(`div`,{style:{flex:1}}),t||n?(0,$.jsx)(`button`,{type:`button`,className:`btn-primary`,style:{padding:`0 14px`,height:34,fontSize:13},onClick:()=>U({tool:`career_coach`,runSeqRef:b,abortRef:x,setBusy:ee,onCancelled:()=>{S(!1),C(``),T(n?`已停止继续整理详细建议，你可以继续输入下一条消息。`:`已取消`)}}),children:n?`停止补全`:`停止生成`}):null]}),w?(0,$.jsx)(`div`,{className:`he-card`,style:{marginTop:12,color:`var(--danger)`,padding:`10px 16px`,fontSize:13},children:w}):null]})})})}var Nt=[`我想从运营转产品，不知道差距在哪，请先帮我判断优势和短板。`,`我拿到两个 Offer，不确定怎么选，请先问清楚岗位和薪资再帮我判断。`,`我在当前公司停滞了 2 年，想重新规划，请帮我判断问题出在哪里。`,`我准备跳槽但不知道简历问题在哪，请先问我目标岗位和当前经历。`],Pt=e=>{let t=c(e).replace(/[？?]+$/g,``);return t?`关于“${t}”，我的回答是：`:``},Ft=e=>{let t=String(e||``).split(`
`).map(e=>c(e).replace(/^[-*#>\s]+/,``).replace(/\*\*/g,``)).filter(Boolean),n=t.find(e=>!/^(?:google\/|provider:|model:|thought|思考过程)/i.test(e))||t[0]||``;return n?n.length<=64?n:`${n.slice(0,64)}…`:`已完成思考，点击查看完整过程`},It=(e,t)=>{let n=String(e||``).trim();return n?t===`user`?(0,$.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:n}):(0,$.jsx)(P,{text:n}):null};function Lt(){return u(`/tools/career-coach`)?(0,$.jsx)(M,{title:`职业教练`,hideModelSelector:!0,hideThinkingToggle:!0,compactHero:!0,hideFootnote:!0,children:(0,$.jsx)(G,{title:`职业教练即将上线`,description:`职业教练即将上线，建议先使用简历匹配与简历优化。`})}):(0,$.jsx)(Rt,{})}function Rt(){let{copiedKey:e,copyText:t}=fe(),{busy:n,setBusy:r,detailBusy:i,setDetailBusy:a,detailStatus:o,setDetailStatus:s,detailCardTurnId:l,detailCardStage:u,err:d,setErr:f,dialogInput:p,setDialogInput:m,result:h,chatTurns:g,pendingAttachments:y,streamThinking:x,streamText:ee,_streamStage:S,_streamActor:C,abortRef:w,runSeqRef:T,chatScrollRef:E,parseStage:D,isAuthed:O,authResolved:k,sessionId:A,coachConsentAccepted:te,setEmbeddedJdDraft:ne,workflowStepsState:P,latestAssistantTurnId:ie,buildActionHref:ae,jumpToRecommendedTool:L,runEmbeddedCoachTool:oe,ingestFilesToChat:se,removePendingAttachment:R,jumpToTurn:ce,resetAll:z,submit:le,generateDetailedPlan:B,profile:V}=kt(),H=(0,K.useMemo)(()=>({...Qe,orchestrator:`总编排`,interview_questions:`面试题库`,salary_research:`薪酬调研`,career_assessment:`职业评估`,session_note:`阶段总结`,cover_letter:`Cover Letter`,networking_message:`人脉破冰`,finalize:`收尾整合`}),[]),U=(0,K.useMemo)(()=>(Array.isArray(P)?P:[]).map(e=>({tool:String(e?.kind||e?.tool||``),status:String(e?.status||``).trim()===`completed`?`done`:`running`})).filter(e=>e.tool),[P]),W=!!(n||ee||x||U.length||i),G=(0,K.useMemo)(()=>I(g),[g]);return(0,$.jsx)(M,{title:`职业教练`,hideModelSelector:!0,hideThinkingToggle:!0,compactHero:!0,hideFootnote:!0,hideEyebrow:!0,children:(0,$.jsxs)(`div`,{className:`he-tools-layout`,children:[(0,$.jsx)(`aside`,{className:`he-tools-sidebar`,children:(0,$.jsx)(N,{current:`/tools/career-coach`})}),(0,$.jsxs)(`section`,{className:`he-tools-main`,style:{display:`flex`,flexDirection:`column`},children:[k&&!O?(0,$.jsxs)(`div`,{className:`he-card`,children:[(0,$.jsx)(`div`,{className:`he-label`,children:`需要登录`}),(0,$.jsx)(`div`,{className:`he-muted`,style:{marginTop:8},children:`职业教练需要登录后才能开始聊天。对话保存在你当前的浏览器里，下次打开能接着继续；换设备或清除浏览器数据后会丢失。`}),(0,$.jsx)(`div`,{className:`he-actions`,style:{marginTop:12},children:(0,$.jsx)(`a`,{href:j(),className:`btn-primary`,children:`去登录`})})]}):null,(0,$.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`},children:[(0,$.jsxs)(`div`,{style:{width:`100%`,display:`flex`,flexDirection:`column`},children:[G?(0,$.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,padding:`0 2px 8px`},children:(0,$.jsx)(_,{billing:G,label:`本次会话累计`,style:{marginTop:0,fontSize:11,lineHeight:1.5}})}):null,(0,$.jsx)(v,{style:{overflowY:`visible`},turns:g,assistantLabel:`职业教练助手`,hideBillingModel:!0,emptyText:`直接开始你的第一句提问。`,emptyState:(0,$.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,padding:`26px 24px 18px`},children:[(0,$.jsxs)(`div`,{style:{borderBottom:`1px solid var(--border-soft)`,paddingBottom:16},children:[(0,$.jsx)(`div`,{className:`he-label`,children:`职业教练对话`}),(0,$.jsx)(`div`,{style:{marginTop:8,fontSize:22,fontWeight:800,color:`var(--text-1)`,letterSpacing:`-0.02em`},children:`职业教练不是另一个聊天框，而是你的职业判断中枢`}),(0,$.jsx)(`div`,{className:`he-muted`,style:{marginTop:8,fontSize:13,lineHeight:1.8,maxWidth:720},children:`从转岗、跳槽、Offer 选择到长期规划，我会先帮你一步步完成。`}),(0,$.jsxs)(`div`,{style:{marginTop:12,display:`flex`,alignItems:`flex-start`,gap:8,padding:`10px 12px`,borderRadius:12,border:`1px solid var(--border-soft)`,background:`var(--surface2)`,maxWidth:720},children:[(0,$.jsx)(`span`,{style:{fontSize:12,fontWeight:700,color:`var(--text-2)`,flexShrink:0,marginTop:1},children:`说明`}),(0,$.jsx)(`span`,{className:`he-muted`,style:{fontSize:12,lineHeight:1.7},children:`本工具的对话会保存在你当前的浏览器里，下次打开能接着上次继续。换设备、更换浏览器或清除浏览器数据后会丢失；点「重新开始」会清空当前对话。`})]})]}),(0,$.jsxs)(`div`,{style:{marginTop:16,padding:`16px 16px 12px`,borderRadius:18,border:`1px solid var(--border)`,background:`var(--surface)`},children:[(0,$.jsx)(`div`,{className:`he-label`,children:`建议这样开始`}),(0,$.jsx)(`div`,{style:{marginTop:12,display:`flex`,flexWrap:`wrap`,gap:10},children:Nt.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(e),style:{padding:`10px 14px`,borderRadius:999,border:`1px solid var(--border)`,background:`var(--surface2)`,cursor:`pointer`,textAlign:`left`,transition:`transform 0.15s, border-color 0.15s`},onMouseEnter:e=>{e.currentTarget.style.transform=`translateY(-1px)`,e.currentTarget.style.borderColor=`var(--accent)`},onMouseLeave:e=>{e.currentTarget.style.transform=``,e.currentTarget.style.borderColor=`var(--border)`},children:(0,$.jsx)(`span`,{style:{fontSize:12,fontWeight:600,color:`var(--text-1)`,lineHeight:1.5},children:e})},`scenario_${t}`))}),(0,$.jsx)(`div`,{className:`he-muted`,style:{marginTop:12,fontSize:12,lineHeight:1.7},children:`你也可以直接粘贴简历、JD、offer 邮件、追问记录，或上传附件开始对话。`})]}),c(V?.currentRole)||c(V?.targetRole)||c(V?.yearsExperience)?(0,$.jsxs)(`div`,{style:{marginTop:16,padding:`14px 16px`,borderRadius:14,border:`1px solid var(--border-soft)`,background:`var(--surface2)`,display:`flex`,flexWrap:`wrap`,gap:10,alignItems:`center`},children:[(0,$.jsx)(`span`,{className:`he-label`,style:{fontSize:11,marginRight:4},children:`我的档案`}),c(V?.currentRole)?(0,$.jsxs)(`span`,{className:`he-chip`,children:[`现在：`,V.currentRole]}):null,c(V?.targetRole)?(0,$.jsxs)(`span`,{className:`he-chip`,style:{borderColor:`var(--accent)`,color:`var(--accent)`,background:`color-mix(in srgb, var(--accent) 8%, transparent)`},children:[`目标：`,V.targetRole]}):null,c(V?.yearsExperience)?(0,$.jsxs)(`span`,{className:`he-chip`,children:[V.yearsExperience,` 年经验`]}):null]}):null]}),chatScrollRef:E,renderContent:e=>(0,$.jsxs)($.Fragment,{children:[e.role===`assistant`&&c(e.reasoningContent)?(0,$.jsx)(`div`,{style:{marginBottom:12},children:(0,$.jsx)(re,{thinking:e.reasoningContent||``,title:`思考`,defaultCollapsed:!0,maxHeight:160,fontSize:11,lineHeight:1.45,embedded:!0,collapsedPreview:Ft(e.reasoningContent)})}):null,e.role===`assistant`&&e.fallbackMeta?(0,$.jsx)(b,{raw:e.fallbackMeta,variant:`notice`,style:{marginBottom:12,padding:`10px 14px`,borderRadius:14,background:`rgba(244, 136, 53, 0.08)`,border:`1px solid rgba(244, 136, 53, 0.18)`},textStyle:{color:`var(--text-1)`,fontSize:13,fontWeight:600}}):null,e.role===`assistant`&&e.fallbackMeta?(0,$.jsx)(b,{raw:e.fallbackMeta,variant:`hint`,style:{marginBottom:12,padding:`10px 14px`,borderRadius:14,background:`rgba(244, 136, 53, 0.07)`,border:`1px solid rgba(244, 136, 53, 0.16)`},textStyle:{color:`var(--text-2)`,fontSize:13,lineHeight:1.65}}):null,It(e.content,e.role)]}),streamPreview:W?(0,$.jsx)(F,{assistantLabel:`职业教练助手`,busy:n||i,streamText:ee,streamThinking:x,streamStage:S,streamActor:C,agentMode:U.length>0,agentSteps:U,stepLabels:H,stageText:c(o)||`职业教练正在思考与规划下一步`,emptyText:`正在结合画像、上下文和工具执行台账生成下一步建议…`}):null,onCopyAssistantMessage:e=>t(`msg_${e.id}`,e.content),copiedAssistantTurnId:e.startsWith(`msg_`)?e.slice(4):``,getAssistantActions:e=>{let t=ie===e.id,n=t&&h&&c(A),r=t&&h&&Array.isArray(h.toolRecommendations)&&h.toolRecommendations.length>0,a=[];return t&&a.push({key:h?`refresh_detail_plan`:`generate_detail_plan`,label:i&&l===e.id?`正在生成详细规划`:h?`重新生成详细规划`:`生成详细规划`,onClick:()=>{i&&l===e.id||B(e)},primary:!1}),r&&h.toolRecommendations.slice(0,2).map((e,t)=>{let n=$e(c(e.tool)),r=ae(c(e.tool));n?a.push({key:`tool_inline_${t}`,label:`${c(e.reason)||`在对话里执行 ${Ze[n]}`}`,onClick:()=>{c(e.prefillHint)&&ne(c(e.prefillHint)),oe(n)},primary:!1}):r&&a.push({key:`tool_${t}`,label:`${c(e.reason)||`去使用 ${c(e.tool)}`}`,onClick:()=>{L(c(e.tool),c(e.prefillHint))},primary:!1})}),pe({nextQuestion:t?c(h?.nextQuestion):``,onUseNextQuestion:t&&c(h?.nextQuestion)?()=>m(Pt(c(h?.nextQuestion))):void 0,nextQuestionLabel:`回答教练追问`,onShowDetail:n?()=>{window.location.href=`/report/career-coach?sid=${encodeURIComponent(c(A))}`}:void 0,customActions:a})},getAssistantCards:e=>ie!==e.id||!h?null:(0,$.jsx)(jt,{assistantTurnId:e.id,detailCardTurnId:l,detailCardStage:u,result:h,onAnswerQuestion:e=>m(Pt(e)),onOpenReport:c(A)?()=>{window.location.href=`/report/career-coach?sid=${encodeURIComponent(c(A))}`}:void 0,onRunTool:(e,t)=>{let n=$e(c(e));if(n){c(t)&&ne(c(t)),oe(n);return}L(c(e),t)}})})]}),(0,$.jsx)(Mt,{sticky:!0,busy:n,detailBusy:i,detailStatus:o,parseStage:D,coachConsentAccepted:te,needsUserInput:P.some(e=>String(e?.status||``).trim()===`failed`),pendingAttachments:y,removePendingAttachment:R,dialogInput:p,setDialogInput:m,submit:le,ingestFilesToChat:se,isAuthed:O,resetAll:z,chatTurns:g,result:h,sessionId:A,latestAssistantTurnId:ie,jumpToTurn:ce,runSeqRef:T,abortRef:w,setBusy:r,setDetailBusy:a,setDetailStatus:s,err:d,setErr:f})]}),(0,$.jsxs)(`details`,{style:{marginTop:12},children:[(0,$.jsx)(`summary`,{style:{cursor:`pointer`,fontSize:13,fontWeight:600,color:`var(--text-2)`},children:`检测岗位 JD 黑话（粘贴 JD，解读招聘套路与风险）`}),(0,$.jsx)(_e,{standalone:!0,sourceTool:`career_coach`,disabled:n})]})]})]})})}export{Lt as default};