import{n as e}from"./chunk-B3pr0VN8.js";import{r as t}from"./authSession-CrP9lMPq.js";import{n,t as r}from"./norm-CeclA1Tu.js";import{f as i,o as a}from"./cloudModel-CGo_el7I.js";import{n as o,t as s}from"./llmSettings-A1Pww_S_.js";import{a as c}from"./proxyOps-D3Awrk7b.js";import{a as l,n as u,t as d,v as f}from"./llm-C3ZnNouF.js";import{t as p}from"./privacyMask-CsOBYv0S.js";import{t as m}from"./roleTaxonomy-CL03wfHw.js";import{t as h}from"./universityDictionary-EuUlQPS3.js";var g=e({generateResumeMatchSplitWithAiGateway:()=>P,generateResumeMatchWithAiGateway:()=>N}),_=async e=>{let t=await a(),n=i(t),r=String(e?.provider||``).trim(),o=String(e?.model||``).trim();return{modelChoice:t,effectiveProvider:r||n?.provider||``,effectiveModel:o||(r?``:String(n?.model||``).trim())}},v=async e=>{try{let e=await t(),n=String(e?.user?.id||``).trim();if(n)return`u:${n}`.slice(0,120)}catch{}return String(e||`public`).slice(0,120)||`public`},y=(e,t)=>{let n=String(e||``).trim().toLowerCase();if(!/^[a-f0-9]{12,64}$/.test(n))return;let r=`${n}:${String(t||``).trim().toLowerCase()}`,i=2166136261,a=2654435769,o=2246822507;for(let e=0;e<r.length;e++){let t=r.charCodeAt(e);i^=t,i=Math.imul(i,16777619),a^=t+e,a=Math.imul(a,2246822507),o^=t+e*17,o=Math.imul(o,3266489909)}return[(i>>>0).toString(16).padStart(8,`0`),(a>>>0).toString(16).padStart(8,`0`),(o>>>0).toString(16).padStart(8,`0`)].join(``).slice(0,24)},b=async e=>{let t=await r();return t?e.map(e=>({...e,jd:p(String(e?.jd||``),t)})):e},x=e=>Array.isArray(e)?e.map(e=>String(e??``)).filter(Boolean).slice(0,30):[],S=e=>{try{return JSON.parse(l(e))}catch{return null}},C=(e,t)=>{let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r=e.match(RegExp(`["']${n}["']\\s*:\\s*"([^"]*)"`,`i`));if(r)return String(r[1]||``).trim();let i=e.match(RegExp(`${n}\\s*[:：]\\s*([^\\n,}]+)`,`i`));return i?String(i[1]||``).replace(/^["']|["']$/g,``).trim():``},w=(e,t)=>{let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r=e.match(RegExp(`["']${n}["']\\s*:\\s*(-?\\d+(?:\\.\\d+)?)|${n}\\s*[:：]\\s*(-?\\d+(?:\\.\\d+)?)`,`i`)),i=String(r?.[1]||r?.[2]||``).trim(),a=Number(i);return Number.isFinite(a)?a:void 0},T=(e,t)=>{let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r=e.match(RegExp(`["']${n}["']\\s*:\\s*\\[([\\s\\S]*?)\\]`,`i`));return r&&String(r[1]||``).match(/"([^"]+)"/g)?.map(e=>String(e||``).replace(/^"|"$/g,``).trim()).filter(Boolean).slice(0,12)||[]},E=e=>{let t=String(e||``),n=w(t,`score`),r=C(t,`fit`);return!Number.isFinite(n)&&!r?null:{jobId:C(t,`jobId`),jobTitle:C(t,`jobTitle`),company:C(t,`company`),score:Number.isFinite(n)?Math.max(0,Math.min(100,Math.round(Number(n)))):0,fit:r,strengths:T(t,`strengths`),gaps:T(t,`gaps`),actions:T(t,`actions`)}},D=e=>{let t=String(e||``),n=C(t,`summary`),r=C(t,`title`),i=w(t,`overallScore`),a=w(t,`objectiveScore`),o=w(t,`subjectiveScore`),s=T(t,`highlights`),c=T(t,`gapsSummary`),l=T(t,`riskSignals`);return!n&&!r&&!Number.isFinite(i)&&!s.length&&!c.length&&!l.length?null:{title:r,summary:n,overallScore:i,objectiveScore:a,subjectiveScore:o,highlights:s,gapsSummary:c,riskSignals:l}},O=(e,t)=>{let n=String(e||``).trim();if(!n)return null;let r=n.replace(/\r/g,`
`).split(`
`).map(e=>e.replace(/^[-*#>\s]+/,``).trim()).filter(Boolean);if(!r.length)return null;let i=t.toLowerCase().startsWith(`zh`),a=n.match(/(?:总分|匹配度|得分|score)\s*[:：]?\s*(\d{1,3})(?:\s*[%分])?/i)||n.match(/(\d{1,3})\s*%/),o=Number(a?.[1]||0),s=Number.isFinite(o)?Math.max(0,Math.min(100,Math.round(o))):0,c=e=>r.filter(t=>e.some(e=>e.test(t))).slice(0,4),l=c([/(优势|亮点|匹配|符合|擅长|经验|能力|成功|成果)/i,/(strength|advantage|match|fit|qualified|evidence)/i]),u=c([/(不足|缺口|短板|风险|欠缺|薄弱|需补充|待提升)/i,/(gap|risk|missing|lack|weak)/i]),d=c([/(建议|优化|补充|提升|准备|下一步|行动)/i,/(suggest|action|next step|improve|prepare)/i]),f=(r.find(e=>/(建议投递|谨慎投递|不建议|可投递|匹配|结论|推荐)/i.test(e))||r.find(e=>e.length>=8)||``).slice(0,80)||(i?`已生成匹配结论`:`Match conclusion generated`);return!f&&!s&&!l.length&&!u.length&&!d.length?null:{score:s,fit:f,strengths:l,gaps:u,actions:d}},k=(e,t)=>{let n=t.toLowerCase().startsWith(`zh`),r=e.reduce((e,t)=>Number(t?.score||0)>Number(e?.score||-1)?t:e,e[0]||null),i=Number(r?.score||0),a=(r?.strengths||[]).map(e=>String(e||``).trim()).filter(Boolean).slice(0,6),o=(r?.gaps||[]).map(e=>String(e||``).trim()).filter(Boolean).slice(0,6),s=String(r?.fit||``).trim()||(n?`已生成岗位匹配结论，建议结合维度详情继续判断。`:`Match conclusion generated. Review detail dimensions before decision.`);return{title:n?`简历匹配`:`Resume Match`,summary:s,overallScore:i>0?i:void 0,objectiveScore:i>0?i:void 0,subjectiveScore:i>0?i:void 0,highlights:a,gapsSummary:o}},A=(e,t)=>{let n=String(e||``).trim();return n?n.length>t?`${n.slice(0,t)}…`:n:``},j=(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:A(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}})},M=(e,t)=>{let n=e&&typeof e==`object`?e:{},r=String(n.title||``).trim()||(t.toLowerCase().startsWith(`zh`)?`简历匹配`:`Resume Match`),i=String(n.summary||``).trim(),a=(e,t)=>{let n=Number(e);return Number.isFinite(n)?Math.max(0,Math.min(t,n)):null},o=e=>{let t=a(e,100);return t==null?void 0:Math.round(t)},s=n.focus&&typeof n.focus==`object`?n.focus:null,c=s?{jobId:String(s?.jobId||``).trim(),jobTitle:String(s?.jobTitle||``).trim(),company:String(s?.company||``).trim()}:void 0,l=n.radar&&typeof n.radar==`object`?n.radar:null,u=Array.isArray(l?.labels)?l.labels.map(e=>String(e||``).trim()).filter(Boolean):[],d=(Array.isArray(l?.values)?l.values:[]).map(e=>a(e,10)).filter(e=>e!=null).map(e=>Math.round(e*10)/10),f=u.length&&d.length?{labels:u.slice(0,8),values:d.slice(0,8)}:void 0,p=(Array.isArray(n.keywords)?n.keywords:[]).slice(0,12).map(e=>({keyword:String(e?.keyword||``).trim(),jd:Number(a(e?.jd,10)??0),resume:Number(a(e?.resume,10)??0),match:String(e?.match||``).trim(),note:String(e?.note||``).trim()})).filter(e=>e.keyword),m=(Array.isArray(n.items)?n.items:[]).slice(0,8).map(e=>{let t=Number(e?.score??0);return{jobId:String(e?.jobId||``),jobTitle:String(e?.jobTitle||``),company:String(e?.company||``),score:Number.isFinite(t)?Math.max(0,Math.min(100,Math.round(t))):0,fit:String(e?.fit||``).trim(),strengths:x(e?.strengths),gaps:x(e?.gaps),actions:x(e?.actions)}}).filter(e=>e.jobId||e.jobTitle||e.company);return{lang:String(n.lang||t||`zh-CN`),title:r,summary:i,overallScore:o(n.overallScore),objectiveScore:o(n.objectiveScore),subjectiveScore:o(n.subjectiveScore),focus:c&&(c.jobId||c.jobTitle||c.company)?c:void 0,radar:f,keywords:p.length?p:void 0,highlights:x(n.highlights),gapsSummary:x(n.gapsSummary),riskSignals:x(n.riskSignals),interviewQuestions:x(n.interviewQuestions),items:m,caveats:x(n.caveats)}},N=async(e,t,i)=>{let a=await o(),c=await v(a.clientId||`public`),u=await s(),{modelChoice:g,effectiveProvider:y,effectiveModel:x}=await _({provider:i?.provider,model:i?.model});if(!(typeof g==`string`&&g.startsWith(`custom:`))&&(!a.enabled||!a.proxyUrl))throw Error(`AI 网关未启用或配置不完整`);let S=y===`glm`,C=f({modelChoice:g,provider:y,model:x,thinkingEnabled:!1}),w=n();if(!String(t||``).trim())throw Error(w.toLowerCase().startsWith(`zh`)?`请先粘贴简历内容`:`Please paste your resume first`);let T=(e||[]).slice(0,5);if(T.length<1)throw Error(w.toLowerCase().startsWith(`zh`)?`请先选择岗位`:`Select jobs first`);let E=await r(),D=E?p(A(t,C.resumeCap),E):A(t,C.resumeCap),O=m.buildRoleContextFromText(`${t}\n${T.map(e=>`${e.title}\n${e.description||``}`).join(`

`)}`),k=await h.buildUniversityContextFromText(t).catch(()=>``),N=[D,O,k].filter(Boolean).join(`

`),P=await b(j(T,S&&u.jdMode===`full`?`excerpt`:u.jdMode,{maxJobs:5,excerptLen:C.overviewExcerptLen})),F=await d({proxyUrl:a.proxyUrl||`custom://local`,gatewayApiKey:a.gatewayApiKey||``,clientId:c,tier:a.tier,preset:`resume_match`,provider:y||void 0,model:x||void 0,data:{lang:w,resume:N,jobs:P,roleContext:O,universityContext:k},signal:i?.signal}),I=null;try{I=JSON.parse(l(F))}catch{let e=String(F||``).slice(0,220).replace(/\s+/g,` `).trim();throw Error(e?`代理未返回可解析的 JSON：${e}`:`代理未返回可解析的 JSON`)}let L=M(I,w);try{let e=w.toLowerCase().startsWith(`zh`),t=new Map;for(let e of L.items||[]){let n=String(e?.jobId||``).trim();n&&!t.has(n)&&t.set(n,e)}let n=[];for(let r of T){let i=String(r?.id||``).trim();i&&(t.has(i)||n.push({jobId:i,jobTitle:String(r?.title||``).trim(),company:String(r?.company||``).trim(),score:0,fit:e?`未返回结果`:`No result returned`,strengths:[],gaps:[],actions:[]}))}n.length&&(L.items=[...L.items||[],...n].slice(0,8))}catch(e){console.warn(`[resumeMatch] placeholder fill failed`,e)}return L.caveats=Array.isArray(L.caveats)?L.caveats.slice(0,10):[],L},P=async(e,i,a)=>{let g=await o();if(!g.enabled||!g.proxyUrl)throw Error(`AI 网关未启用或配置不完整`);let C=await v(g.clientId||`public`),w=await s(),{modelChoice:T,effectiveProvider:P,effectiveModel:I}=await _({provider:a?.provider,model:a?.model}),L=P===`glm`,R=f({modelChoice:T,provider:P,model:I,thinkingEnabled:!!a?.thinking}),ee=await t().catch(()=>null),te=!!String(ee?.token||``).trim(),z=(()=>{try{let e=String(globalThis?.location?.protocol||``);return!(!e||e===`chrome-extension:`||e===`moz-extension:`||e===`safari-extension:`)}catch{return!1}})(),B=n();if(!String(i||``).trim())throw Error(B.toLowerCase().startsWith(`zh`)?`请先粘贴简历内容`:`Please paste your resume first`);let V=(e||[]).slice(0,5);if(V.length<1)throw Error(B.toLowerCase().startsWith(`zh`)?`请先选择岗位`:`Select jobs first`);let H=new AbortController,ne=window.setTimeout(()=>{try{H.abort()}catch{try{H.abort()}catch{}}},6e5),U=a?.signal?(()=>{if(a.signal.aborted)return a.signal;let e=new AbortController,t=()=>{try{e.abort(a.signal.reason)}catch{try{e.abort()}catch{}}},n=()=>{try{e.abort(H.signal.reason)}catch{try{e.abort()}catch{}}};try{a.signal.addEventListener(`abort`,t,{once:!0})}catch{}try{H.signal.addEventListener(`abort`,n,{once:!0})}catch{}return e.signal})():H.signal,W=await r(),re=W?p(A(i,R.resumeCap),W):A(i,R.resumeCap),G=m.buildRoleContextFromText(`${i}\n${V.map(e=>`${e.title}\n${e.description||``}`).join(`

`)}`),K=await h.buildUniversityContextFromText(i).catch(()=>``),q=[re,G,K].filter(Boolean).join(`

`),J=L&&w.jdMode===`full`?`excerpt`:w.jdMode,Y=e=>{let t=Math.max(1,Math.min(100,Math.round(e)));try{a?.onProgress?.(t)}catch{}try{a?.onPartial?.({_progress:t})}catch{}},X=e=>{try{a?.onPartial?.(e)}catch{}},ie=(e,t)=>{let n=String(e?.fromProvider||e?.from_provider||``).trim(),r=String(e?.fromModel||e?.from_model||``).trim(),i=String(e?.provider||``).trim(),a=String(e?.model||``).trim(),o=String(t?.reason||e?.reason||``).trim(),s=String(t?.stage||e?.stage||``).trim();return!i&&!a&&!n&&!r&&!o?null:{fromProvider:n,fromModel:r,provider:i,model:a,reason:o,stage:s}},Z=null,Q=(e,t)=>{let n=ie(e,t);n&&(Z=Z?{...Z,...Object.fromEntries(Object.entries(n).filter(([,e])=>!!String(e||``).trim()))}:n)},ae=e=>{let t=S(e)||E(e);if(!t||typeof t!=`object`)throw Error(`invalid_resume_match_item`);let n=t&&typeof t==`object`?t:{},r=Number(n?.score??0);return{jobId:String(n?.jobId||``).trim(),jobTitle:String(n?.jobTitle||``).trim(),company:String(n?.company||``).trim(),score:Number.isFinite(r)?Math.max(0,Math.min(100,Math.round(r))):0,fit:String(n?.fit||``).trim(),strengths:x(n?.strengths).slice(0,12),gaps:x(n?.gaps).slice(0,12),actions:x(n?.actions).slice(0,12)}},$=async e=>{let t=B.toLowerCase().startsWith(`zh`),n=V.map((e,t)=>{let n=`[${t+1}] jobId=${String(e?.id||``).trim()} | ${String(e?.title||``).trim()} | ${String(e?.company||``).trim()} | ${String(e?.location||``).trim()}`,r=String(e?.description||``).trim(),i=r?`JD:\n${A(r,6e3)}`:``;return i?`${n}\n${i}`:n}).join(`

`),r=[t?`你是简历与岗位匹配助手。请对多个岗位分别给出匹配评估。必须严格输出 JSON（仅一个 JSON 对象），不要输出多余文本。`:`You are a resume-job matching assistant. Evaluate multiple jobs. Output strict JSON only (single JSON object), no extra text.`,`{"lang":"zh-CN","title":"...","summary":"...","overallScore":88,"confidence":0.82,"items":[{"jobId":"...","jobTitle":"...","company":"...","score":88,"fit":"...","strengths":["..."],"gaps":["..."],"actions":["..."]}],"highlights":["..."],"gapsSummary":["..."],"actions":["..."]}`,t?`要求：score 为 0-100；confidence 为 0-1；strengths/gaps/actions 每项 3-6 条；不要编造简历中不存在的信息。`:`Constraints: score 0-100; confidence 0-1; strengths/gaps/actions 3-6 items; do not fabricate.`,``,`岗位列表：`,n].join(`
`);Y(92);let a=await c({jobDescription:`多岗位简历匹配`,resumeText:i,text:r,timeoutMs:6e5}),o=String(a?.content||``).trim(),s=JSON.parse(l(o)),u=M({...s,lang:s?.lang||B,items:s?.items},B);return Q({provider:`glm_agent`,model:`glm-agent`,reason:e,stage:`glm_agent`}),u._fallback=Z||{provider:`glm_agent`,model:`glm-agent`,reason:e,stage:`glm_agent`},Y(100),u},oe=async e=>{let t=String(e||``).trim().toLowerCase();return t?t.includes(`请先登录`)||t.includes(`登录已过期`)||t.includes(`auth_required`)||t.includes(`invalid_session`)||t.includes(`login_required`)||t.includes(`model_not_allowed`)||t.includes(`missing authorization`)||t.includes(`invalid jwt`)||t.includes(`forbidden`)||t.includes(`403`)?!0:!te:!1},se=e=>{let t=String(e||``).trim().toLowerCase();return t?t.includes(`invalid_preset`)||t.includes(`unknown_preset`)||t.includes(`missing_payload`)||t.includes(`compile_preset_payload_failed`)||t.includes(`preset_compile_failed`)||t.includes(`400`)||t.includes(`bad request`):!1};try{let e=B.toLowerCase().startsWith(`zh`),t=[];Y(10);for(let n=0;n<V.length;n++){if(U?.aborted)throw Error(`timeout`);let r=V[n],i=await b(j([r],J,{maxJobs:1,excerptLen:R.overviewExcerptLen})),o=Array.isArray(i)?i[0]??{}:i,s=`item_${n+1}_of_${V.length}`,c=y(a?.requestId,s),l=12+Math.round(n/V.length*58),f=12+Math.round((n+1)/V.length*58)-2,p=Math.max(4,f-l),m=!1,h=l,_=e=>{let t=Math.min(f,Math.max(l,h+e));if(t>h){h=t;try{Y(t)}catch{}}},v=z?await u({proxyUrl:g.proxyUrl,gatewayApiKey:g.gatewayApiKey,clientId:C,tier:g.tier,preset:`resume_match_item`,provider:P||void 0,model:I||void 0,thinking:a?.thinking,data:{lang:B,resume:q,job:o,roleContext:G,universityContext:K},signal:U,requestId:c,suppressGlobalSync:a?.suppressGlobalSync,onMeta:e=>{if(e.type!==`start`)return;e?.fallback&&Q(e.fallback,{stage:`resume_match_item`});let t=String(e.provider||``).trim(),r=String(e.model||``).trim(),i=t||r?`Model: ${[t,r].filter(Boolean).join(`/`)}`:``;X({_streamSegment:s,_streamStage:`岗位 ${n+1}/${V.length}`,_streamActor:[i,`Skill: resume_match_item`].filter(Boolean).join(` · `)})},onText:e=>{m=!0,_(Math.max(1,Math.round(p/20)));let t=String(e||``).slice(-24e3);X({_streamSegment:s,_streamStage:`岗位 ${n+1}/${V.length} · 正文生成中`,_streamActor:`Skill: resume_match_item`,_streamText:t})},onThinking:e=>{_(Math.max(1,Math.round(p/40)));let t=String(e||``).slice(-24e3);X({_streamSegment:s,_streamStage:m?`岗位 ${n+1}/${V.length} · 正文生成中`:`岗位 ${n+1}/${V.length} · 深度思考中…`,_streamActor:`Skill: resume_match_item`,_streamThinking:t})}}):await d({proxyUrl:g.proxyUrl,gatewayApiKey:g.gatewayApiKey,clientId:C,tier:g.tier,preset:`resume_match_item`,provider:P||void 0,model:I||void 0,thinking:a?.thinking,data:{lang:B,resume:q,job:o,roleContext:G,universityContext:K},signal:U,requestId:c,onResponseMeta:e=>{e?.fallback&&Q(e.fallback,{stage:`resume_match_item`})}}),x=null;try{x=ae(v)}catch{x=null}if(!x){let e=O(v,B);e&&(x={jobId:``,jobTitle:``,company:``,score:Number(e.score||0),fit:String(e.fit||``),strengths:Array.isArray(e.strengths)?e.strengths:[],gaps:Array.isArray(e.gaps)?e.gaps:[],actions:Array.isArray(e.actions)?e.actions:[]})}let S=String(r?.id||``).trim();if(x&&(x.jobId||x.jobTitle||x.company))!x.jobId&&S&&(x.jobId=S),x.jobTitle||=String(r?.title||``).trim(),x.company||=String(r?.company||``).trim(),String(x.fit||``).trim()||(x.fit=e?`已生成`:`Done`),t.push(x);else if(a?.disableFallback){let t=String(v||``).slice(0,200).replace(/\s+/g,` `).trim();throw Error(e?`模型未返回可解析的结构化结果${t?`：${t}`:``}`:`Model did not return parseable structured result${t?`: ${t}`:``}`)}else t.push({jobId:S,jobTitle:String(r?.title||``).trim(),company:String(r?.company||``).trim(),score:0,fit:e?`未返回结果`:`No result returned`,strengths:[],gaps:[],actions:[]});X({items:V.map(n=>{let r=String(n?.id||``).trim();return t.find(e=>String(e?.jobId||``).trim()===r)||{jobId:r,jobTitle:String(n?.title||``).trim(),company:String(n?.company||``).trim(),score:0,fit:e?`生成中…`:`Generating…`,strengths:[],gaps:[],actions:[]}}).slice(0,8)}),Y(12+Math.round((n+1)/V.length*58))}let n=(()=>{let e=0,n=-1;for(let r=0;r<t.length;r++){let i=Number(t[r]?.score??0);Number.isFinite(i)&&i>n&&(n=i,e=r)}return t[e]||t[0]})();if(V.length===1){let e=k(t,B),r=M({lang:e?.lang||B,title:e?.title||(B.toLowerCase().startsWith(`zh`)?`简历匹配`:`Resume Match`),summary:e?.summary||String(n?.fit||``).trim(),overallScore:e?.overallScore??Number(n?.score||0),objectiveScore:e?.objectiveScore??Number(n?.score||0),subjectiveScore:e?.subjectiveScore??Number(n?.score||0),focus:e?.focus||{jobId:String(n?.jobId||``),jobTitle:String(n?.jobTitle||``),company:String(n?.company||``)},radar:e?.radar,keywords:e?.keywords,highlights:e?.highlights,gapsSummary:e?.gapsSummary,riskSignals:e?.riskSignals,interviewQuestions:e?.interviewQuestions,items:t,caveats:e?.caveats},B);return r.riskSignals=F(i,r,B),r.caveats=Array.isArray(r.caveats)?r.caveats.slice(0,10):[],Z&&(r._fallback=Z),X({overallScore:r.overallScore,objectiveScore:r.objectiveScore,subjectiveScore:r.subjectiveScore,focus:r.focus,radar:r.radar,keywords:r.keywords,highlights:r.highlights,gapsSummary:r.gapsSummary,riskSignals:r.riskSignals,interviewQuestions:r.interviewQuestions,caveats:r.caveats,summary:String(r.summary||``).trim(),title:String(r.title||``).trim()}),Y(100),r}let r=String(n?.jobId||``).trim(),o=await b(j([V.find(e=>String(e?.id||``).trim()===r)||V[0]],J,{maxJobs:1,excerptLen:R.focusExcerptLen})),s=Array.isArray(o)?o[0]??{}:o;Y(76);let c=null;try{let e=`meta_summary`,n=y(a?.requestId,e),r=!1,i=76,o=e=>{let t=Math.min(90,Math.max(76,i+e));if(t>i){i=t;try{Y(t)}catch{}}},l=z?await u({proxyUrl:g.proxyUrl,gatewayApiKey:g.gatewayApiKey,clientId:C,tier:g.tier,preset:`resume_match_meta`,provider:P||void 0,model:I||void 0,thinking:a?.thinking,data:{lang:B,resume:q,focusJob:s,roleContext:G,universityContext:K,items:t.map(e=>({jobId:e.jobId,jobTitle:e.jobTitle,company:e.company,score:e.score,fit:e.fit,gaps:e.gaps?.slice?.(0,2)||[]}))},signal:U,requestId:n,suppressGlobalSync:a?.suppressGlobalSync,onMeta:t=>{if(t.type!==`start`)return;t?.fallback&&Q(t.fallback,{stage:`resume_match_meta`});let n=String(t.provider||``).trim(),r=String(t.model||``).trim();X({_streamSegment:e,_streamStage:`汇总`,_streamActor:[n||r?`Model: ${[n,r].filter(Boolean).join(`/`)}`:``,`Skill: resume_match_meta`].filter(Boolean).join(` · `)})},onText:t=>{r=!0,o(1),X({_streamSegment:e,_streamStage:`汇总 · 正文生成中`,_streamActor:`Skill: resume_match_meta`,_streamText:String(t||``).slice(-24e3)})},onThinking:t=>{o(1);let n=String(t||``).slice(-24e3);X({_streamSegment:e,_streamStage:r?`汇总 · 正文生成中`:`汇总 · 深度思考中…`,_streamActor:`Skill: resume_match_meta`,_streamThinking:n})}}):await d({proxyUrl:g.proxyUrl,gatewayApiKey:g.gatewayApiKey,clientId:C,tier:g.tier,preset:`resume_match_meta`,provider:P||void 0,model:I||void 0,thinking:a?.thinking,data:{lang:B,resume:q,focusJob:s,roleContext:G,universityContext:K,items:t.map(e=>({jobId:e.jobId,jobTitle:e.jobTitle,company:e.company,score:e.score,fit:e.fit,gaps:e.gaps?.slice?.(0,2)||[]}))},signal:U,requestId:n,onResponseMeta:e=>{e?.fallback&&Q(e.fallback,{stage:`resume_match_meta`})}});c=S(l)||D(l)}catch(e){console.warn(`[resumeMatch] meta parse failed`,e),c=null}c&&typeof c==`object`&&X({overallScore:c.overallScore,objectiveScore:c.objectiveScore,subjectiveScore:c.subjectiveScore,focus:c.focus,radar:c.radar,keywords:c.keywords,highlights:c.highlights,gapsSummary:c.gapsSummary,riskSignals:c.riskSignals,interviewQuestions:c.interviewQuestions,caveats:c.caveats,summary:String(c.summary||``).trim(),title:String(c.title||``).trim()}),Y(92);let l=c&&typeof c==`object`?c:k(t,B),f=M({lang:l?.lang||B,title:l?.title||(B.toLowerCase().startsWith(`zh`)?`简历匹配`:`Resume Match`),summary:l?.summary||``,overallScore:l?.overallScore,objectiveScore:l?.objectiveScore,subjectiveScore:l?.subjectiveScore,focus:l?.focus,radar:l?.radar,keywords:l?.keywords,highlights:l?.highlights,gapsSummary:l?.gapsSummary,riskSignals:l?.riskSignals,interviewQuestions:l?.interviewQuestions,items:t,caveats:l?.caveats},B),p=t.reduce((e,t)=>{let n=Number(e?.score??-1);return Number(t?.score??-1)>n?t:e},t[0]||null);f.overallScore==null&&Number(p?.score)>0&&(f.overallScore=Math.round(Number(p?.score))),f.objectiveScore==null&&Number(p?.score)>0&&(f.objectiveScore=Math.round(Number(p?.score))),f.subjectiveScore==null&&Number(p?.score)>0&&(f.subjectiveScore=Math.round(Number(p?.score))),!String(f.summary||``).trim()&&String(p?.fit||``).trim()&&(f.summary=B.toLowerCase().startsWith(`zh`)?`当前已生成单岗位匹配结论：${String(p?.fit||``).trim()}。结构化总览报告暂未完整返回，可先基于现有结论继续判断与改写。`:`A single-job match conclusion is available: ${String(p?.fit||``).trim()}. The structured overview report is not fully returned yet.`),f.riskSignals=Array.isArray(l?.riskSignals)&&l.riskSignals.length?l.riskSignals.map(e=>String(e||``).trim()).filter(Boolean).slice(0,8):F(i,f,B),f.caveats=Array.isArray(f.caveats)?f.caveats.slice(0,10):[],Z&&(f._fallback=Z);let m=(()=>{let e=Number(c?.confidence??c?._confidence);return Number.isFinite(e)?Math.max(0,Math.min(1,e)):1})();return Y(100),m<.7&&!a?.disableFallback?await $(`low_confidence`):f}catch(e){if(a?.signal?.aborted)throw e;let t=String(e?.message||``);if(a?.disableFallback||await oe(t))throw e;if(se(t))return Y(65),await N(V,i,{provider:P||void 0,model:I||void 0});if(t.toLowerCase().includes(`internal_error`)){Y(65);try{return await N(V,i,{provider:P||void 0,model:I||void 0})}catch{}}let n=t.includes(`timeout`)||H.signal.aborted;try{return await $(n?`timeout`:`error`)}catch{throw e}}finally{try{window.clearTimeout(ne)}catch{}}},F=(e,t,n)=>{let r=n.toLowerCase().startsWith(`zh`),i=String(e||``).replace(/\s+/g,` `),a=[];/(\d+%|\d+\s*(万|w|W|k|K)|同比|增长|提升|降低|GMV|ROI|转化率|成本|营收|用户)/.test(i)||a.push(r?`简历中的量化成果偏少，建议补充结果指标。`:`Quantified outcomes are limited; add measurable impact.`),(i.match(/待补充|TODO|TBD/gi)||[]).length>=2&&a.push(r?`简历中存在多处待补充信息，关键证据还不完整。`:`Several placeholders remain; key evidence is incomplete.`);let o=Array.from(i.matchAll(/(20\d{2})[.\-/年 ]{0,2}(\d{1,2})?\s*(?:至|到|-|~|—)\s*(20\d{2}|至今|现在|present)/gi)),s=0;for(let e of o){let t=Number(e[1]||0),n=Number(e[2]||1),r=String(e[3]||``).toLowerCase(),i=/至今|现在|present/.test(r)?new Date:new Date(Number(r||0),0,1);if(!t||Number.isNaN(i.getFullYear()))continue;let a=(i.getFullYear()-t)*12+(i.getMonth()+1-n);a>0&&a<12&&(s+=1)}return s>=2&&a.push(r?`简历里出现多段较短任职经历，建议提前准备稳定性说明。`:`Multiple short tenures detected; prepare a stability explanation.`),(Array.isArray(t.gapsSummary)?t.gapsSummary.length:0)>=6&&a.push(r?`与目标岗位的关键缺口较多，建议先补齐核心证据再投递。`:`Many critical gaps exist; fill core evidence before applying.`),Array.from(new Set(a)).slice(0,6)};export{P as n,g as t};