PageSourceSearch

https://landedin.ca/assets/Chat-bjnIKDSP.js

js landedin.ca collected 2026-10-02 01:19:42 UTC 116,276 bytes, 10 lines download raw bytes

1import{j as n,r as d,L as _i,a2 as Pe,y as ki,z as Ni}from"./index-KBHVYv2t.js";import{P as qi}from"./PremiumNav-CeDgtuYU.js";import{C as hr}from"./check-CXiZjqea.js";import{L as Pi}from"./loader-circle-BXdtd0oF.js";import{T as Oi,C as Li,P as Bi}from"./triangle-alert-y75ZJhN4.js";import{V as Fi}from"./volume-2-K1DrsiYc.js";import{M as Ui}from"./mic-Ju-cIl1g.js";import{S as Di}from"./send-B4CpIlit.js";import{U as Mi}from"./upload-Wd3AHjkP.js";import{P as $i}from"./plus-oaCGQQv_.js";import{A as Wi}from"./arrow-right-DwT-QhQH.js";import{F as Ki}from"./file-text-CF2dP76g.js";import{D as qt}from"./download-GondLSeE.js";import{U as Yi}from"./UsageMeter-C4-wq2PB.js";import{u as Gi}from"./toolUsage-BrZCGP7o.js";import"./StoreBadges-CAGO-o--.js";import"./sparkles-DVBPnlUj.js";import"./target-D2BggEER.js";import"./message-square-sjXeGOo2.js";import"./dialog-C-PsXlnq.js";import"./index-BlKAU-rT.js";import"./BrandMark-CRZcb4P2.js";import"./star-c-1KNXF-.js";import"./lock-CyZr8Xb5.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"landedin@eb25ddd8c58864a3dcb7d19cc89bf95b67df5652"};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="25c0796a-3b55-448c-b40b-d3164190ea26",e._sentryDebugIdIdentifier="sentry-dbid-25c0796a-3b55-448c-b40b-d3164190ea26")}catch{}})();const Oe={maxProvenanceEvidence:120,maxWarnings:80,maxWarningText:500,maxApplicantAnswerExcerpt:500,maxApplicantAnswer:2e3},st={maxResumeChars:3e4,maxJobChars:3e4},Vi=["rewrite","quality","fidelity","companion"],zi=["passed","failed","timed_out"],Qi=6e4,ot=3,Mt=20,vt="landedin_application_workspace_v2",gt="landedin_application_workspace_v1",vr=["role","company","industry","province"],gr=e=>typeof e=="string"&&vr.includes(e);function Hi(e,t,r){const i=gr(t)?[...new Set([...e.editedTargetFields??[],t])]:e.editedTargetFields,o={...e,[t]:r,...i?{editedTargetFields:i}:{}};return t!=="province"?o:r.trim()?{...o,provinceSource:"applicant"}:{...o,provinceSource:void 0}}function Ji(e,t){if(!t)return e;const r=new Set(e.editedTargetFields??[]),i={...e};for(const o of vr){if(r.has(o))continue;const s=v(t[o],o==="role"||o==="company"?160:100);s&&(i[o]=s,o==="province"&&(i.provinceSource="derived"))}return i}function Xi(e,t){return[e.status,String(e.text.length),e.text,t.status,String(t.text.length),t.text].join("\0")}const Zi=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|(?:\+?1[\s.-]?)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}|linkedin\.com\/in\/|https?:\/\/)/i,v=(e,t)=>typeof e=="string"?e.trim().slice(0,t):"",W=(e,t)=>typeof e=="string"&&e.trim().length>0&&e.length<=t,es=e=>typeof e=="string"?e.slice(0,st.maxResumeChars):"",yr=(e,t)=>typeof e=="string"&&e.length<=st.maxResumeChars;function _e(e,t){const r=t==="resume"?st.maxResumeChars:st.maxJobChars,i=typeof e=="string"?e:"";if(i.length>r){const o=t==="resume"?"Your résumé":"The job description";throw new Error(`${o} is ${i.length.toLocaleString("en-CA")} characters. Please shorten it to ${r.toLocaleString("en-CA")} characters or fewer so nothing is lost.`)}return i}function Vn(e,t,r){const i=typeof e=="string"?e:"";try{_e(i,t)}catch(o){return{status:"error",name:r,text:"",error:o instanceof Error?o.message:"That document is too long."}}return i.trim().length<40?{status:"error",name:r,text:"",error:"Paste at least a few complete lines."}:{status:"ready",name:r,text:i}}const ts=/\b(?:not|never|no|none|nothing|isn|isnt|aren|arent|wasn|wasnt|weren|werent|aint|cant|cannot|can|couldn|couldnt|could|shouldn|shouldnt|should|wouldn|wouldnt|would|doesn|doesnt|don|dont|didn|didnt|hasn|hasnt|haven|havent|won|wont|will|shall|may|might|maybe|perhaps|must|almost|nearly|mostly|partly|partially|somewhat|unsure|if|unless|when|whenever|once|until|whether|what|why|how|where|who)\b/u,br="(?:resume|cv|curriculum vitae)",ns=new RegExp(`^(?:(?:just|please|ok|okay|yes|yeah|sure|alright|simply|only|then)\\s+)*(?:use|build\\s+(?:from|with)|go\\s+with|keep|take|stick\\s+with)\\s+(?:my|the)\\s+${br}\\s+as\\s+(?:is|it\\s+is)(?:\\s+(?:please|thanks|thank\\s+you|now|then|ok|okay))*$`,"u"),rs=new RegExp(`^(?:my|the)\\s+${br}\\s+(?:is|has|have|are)(?:\\s+(?:all\\s+the\\s+information|all\\s+of\\s+the\\s+information|everything|all))?\\s+up\\s?to\\s+date$`,"u"),is=new RegExp("^(?:and\\s+|also\\s+|so\\s+)?(?:no\\s+(?:more\\s+|further\\s+|other\\s+)?(?:questions?|changes?)(?:\\s+(?:needed|required|please))?|(?:i\\s+)?(?:do\\s+not|don\\s+t|dont)\\s+(?:want|need)\\s+(?:any\\s+)?(?:more|further|other)?\\s*(?:questions?|changes?)|(?:please\\s+)?(?:do\\s+not|don\\s+t|dont)\\s+ask\\s+(?:me\\s+)?(?:any\\s+)?(?:more|further|other)?\\s*(?:questions?)?|(?:please\\s+)?(?:do\\s+not|don\\s+t|dont)\\s+change\\s+anything|nothing\\s+(?:else|more)(?:\\s+to\\s+add)?|(?:i\\s+)?(?:do\\s+not|don\\s+t|dont)\\s+(?:need|want)\\s+to\\s+add\\s+anything(?:\\s+else)?|(?:i\\s+have\\s+)?nothing\\s+to\\s+add|(?:that|thats|that\\s+s)\\s+(?:is\\s+)?all|please|thanks|thank\\s+you|ok|okay|done)$","u"),ss=e=>e.normalize("NFKC").normalize("NFD").replace(new RegExp("\\p{M}+","gu"),"").toLocaleLowerCase("en-CA").replace(/[^\p{L}\p{N}]+/gu," ").replace(/\s+/gu," ").trim();function os(e){const t=typeof e=="string"?e:"";if(!t.trim()||/[??]/u.test(t))return!1;const r=t.split(/[,;.!\n]+|\s+(?:and|but|so|then|however|although|though|while|whereas)\s+/iu).map(ss).filter(
1Boolean);if(!r.length)return!1;let i=!1;for(const o of r){if(!ts.test(o)&&(ns.test(o)||rs.test(o))){i=!0;continue}if(!is.test(o))return!1}return i}const rn={AB:"Alberta",BC:"British Columbia",MB:"Manitoba",NB:"New Brunswick",NL:"Newfoundland and Labrador",NS:"Nova Scotia",NT:"Northwest Territories",NU:"Nunavut",ON:"Ontario",PE:"Prince Edward Island",QC:"Quebec",SK:"Saskatchewan",YT:"Yukon"};function as(e){const t=e.split(",").map(r=>r.trim()).filter(Boolean);for(const r of[...t].reverse()){const i=r.toUpperCase();if(rn[i])return rn[i];const o=Object.values(rn).find(s=>s.toLowerCase()===r.toLowerCase());if(o)return o}return""}function wr(e,t){const r=c=>{const m=t.contact[c];return m.decision==="include"?m.value.trim():""},i=(c,m)=>c.trim()?c:m,o=e.province.trim()!==""&&e.provinceSource!=="derived",s=v(as(r("location")),100);return{...e,applicantName:i(e.applicantName,v(r("fullName"),120)),contactInfo:i(e.contactInfo,mn(t)),...o?{}:s?{province:s,provinceSource:"derived"}:{province:"",provinceSource:void 0}}}const $t=["unreviewed","include","omit"],Wt=["summary","experience","education","skills","credentials","languages","other"],pn=["resume_extracted","user_confirmed","user_corrected","question_answer","user_added"],hn=["unreviewed","confirmed","unknown","absent","contradicted","removed"],cs=["applicant","derived"],vn=["mandatory","preferred","responsibility"],ls=["requirement","value","adaptive"],us=["English","French","Hindi","Punjabi","Urdu","Gujarati","Tagalog","Mandarin","Cantonese","Spanish","Arabic","Tamil","Bengali","Farsi"],N=(e,t)=>typeof e=="string"&&t.includes(e),S=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:null,xr=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu,ds=["kept","refunded","unconfirmed"];function Kt(e){const t=e.creditOutcome,r=N(t,ds)?t:t==null||t===""?null:"unconfirmed";return{message:W(e.message,300)?e.message:"",requestId:typeof e.requestId=="string"&&xr.test(e.requestId)?e.requestId:null,creditOutcome:r}}function ms(e){return bn.has(e.status)}function sn(e){if(!e.responseArrived)return"unresolved";const t=e.settlement?.creditOutcome??null;return t==="refunded"?"refunded":t==="kept"?"kept":t==="unconfirmed"?"unresolved":typeof e.status=="number"&&ms({status:e.status})?"unsent":e.delivered?"delivered":"unresolved"}function on(e){const t=e.resolution??null;return t===null||t==="unsent"||t==="refunded"?"open":t==="kept"?e.delivered?"spent":"blocked":t==="delivered"?"spent":"blocked"}function Pt(e){const t=e?.creditOutcome??"not_reserved";return t==="refunded"||t==="not_reserved"?"open":t==="spent"||e?.status==="ready"&&e.text.trim()?"spent":"blocked"}const Cr=Qi+15e3;class zn extends Error{code="APPLICATION_CLIENT_TIMEOUT";constructor(){super("The browser stopped waiting for this build"),this.name="ApplicationClientTimeoutError"}}async function Ut(e){const t=e.setTimer??((m,h)=>setTimeout(m,h)),r=e.clearTimer??(m=>clearTimeout(m));let i=()=>{};const o=new Promise((m,h)=>{i=()=>h(new zn)}),s=t(()=>{i(),e.abort?.()},e.deadlineMs??Cr);let c;try{c=await Promise.race([e.send(),o]);const m=await Promise.race([e.read(c),o]);return{response:c,result:m}}catch(m){throw c!==void 0&&m instanceof zn&&(m.response=c),m}finally{r(s)}}function Qn(){return{settlement:null,error:"Your work could not be saved in this browser, so no résumé build was started and no Career Credit was used. Free up space or try another browser, then build again.",clearsReservation:!0}}function jr(e){return e.usageLoading?"loading":e.usageUnreadable?"wallet_unreadable":e.busy?"busy":e.exhausted?"exhausted":e.resumeUnresolved?"unresolved_resume":e.coverUnprovable?"cover_unprovable":e.coverUnresolved?"unresolved_cover":null}function wt(e){switch(e){case"loading":return"We are reading your Career Credits. This will be ready in a moment.";case"wallet_unreadable":return"We could not read your Career Credits just now, so we have not started anything. Try again in a moment.";case"busy":return"Another paid step is running right now. This comes back when it finishes.";case"exhausted":return"This needs a Career Credit, and this account has none left.";case"unresolved_resume":return"We could not confirm what happened to the Career Credit for your last résumé attempt. Your documents are saved and nothing further will be charged. This is not something we can confirm from here, so please email [email protected] if you would like it raised.";case"unresolved_cover":return"We could not confirm what happened to the Career Credit for your last cover letter attempt. Your documents are saved and nothing further will be charged. This is not something we can confirm from here, so please email [email protected] if you would like it raised.";case"cover_unprovable":return"We could not confirm what happened to the Career Credit for an earlier cover letter, and n
1o record of it was kept. Your résumé is safe. This is not something we can confirm from here: clear it from your résumé review to carry on, and please email [email protected] if you would like it raised.";case"resume_delivered":return"Your résumé is finished and saved. We could not confirm whether it used a Career Credit. Starting another tailored résumé is a new request.";case"resume_credit_spent":return"The Career Credit for this résumé has already been used, so another tailored résumé cannot be started here.";case"cover_in_progress":return"Your cover letter is still being written.";case"cover_ready":return"Your cover letter is ready.";default:return""}}function Rr(e){return!e||e.status==="absent"||e.status==="loading"||e.creditOutcome!=="unconfirmed"||e.status==="ready"||e.text.trim()||e.creditReference?!1:typeof e.creditsUsedBeforeCover!="number"}function an(e){return Rr(e)?{...Ve(),status:"warning",error:"We could not confirm what happened to the Career Credit for an earlier cover letter, and there was nothing left to check it against. You chose to carry on. Email [email protected] if a Career Credit is missing.",errorCode:"COVER_LETTER_CREDIT_ACKNOWLEDGED"}:e}function Ar(e){const t=jr(e);if(t)return t;if(e.resumeResolution==="delivered"&&e.resumeDelivered!==!1)return"resume_delivered";const r=e.latestSettlement?.creditOutcome??null;return r==="kept"?"resume_credit_spent":r==="unconfirmed"?"unresolved_resume":null}function Ir(e){const t=jr(e);if(t)return t;const r=e.coverState?.status??"absent";return r==="absent"?null:r==="ready"?"cover_ready":r==="loading"?"cover_in_progress":null}function fs(e){return Ar(e)===null}function ps(e){return Ir(e)===null}function hs(e){const t=e.resultKind==="evidence_only"||e.resultKind==="source_recovery";return t?t?e.settlement?.creditOutcome!=="refunded":!yt(e.settlement):!1}function vs(e){const t=!!e.buildFailure&&!yt(e.settlement);return{phase:"parsed_review",settlement:e.settlement,creditNotice:t?bt(e.settlement):null}}function gs(){let e=null;return{acquire:()=>{if(e)return null;const t=Symbol("paid-action");return e=t,{release:()=>{e===t&&(e=null)}}},held:()=>e!==null}}function yt(e){const t=e?.creditOutcome??null;return t===null||t==="refunded"}const ys=new Set(["unresolved_resume","unresolved_cover","cover_unprovable","wallet_unreadable"]);function Hn(e){return e&&ys.has(e)?wt(e):null}function bt(e){const t=e?.creditOutcome??null;return t==="refunded"?"We could not finish the résumé. Your Career Credit was refunded. Your work is saved.":t===null?"We could not finish the résumé. Your work is saved.":e?.requestId?`We could not finish the résumé or confirm the refund. Your work is saved. Reference: ${e.requestId}.`:"We could not finish the résumé or confirm the refund. Your work is saved."}function Sr(e,t){const r=t==="evidence_only"?"We built a source-grounded résumé":t==="source_recovery"?"We preserved your source résumé":null;if(!r)return null;const i="Review it, edit it, or download it now.",o=e?.creditOutcome??null;if(o==="refunded")return`${r} and refunded the Career Credit. ${i}`;if(o===null)return`${r}. ${i}`;const s=e?.requestId?` Reference: ${e.requestId}.`:"";return`${r} but could not confirm the Career Credit refund. ${i}${s}`}function bs(e){const t="We used the safest source-grounded version we could prepare",r=e?.creditOutcome??null;return r==="refunded"?`${t}, and your Career Credit was refunded.`:r===null?`${t}.`:`${t}. We could not confirm the Career Credit refund.`}function Ot(e){if(e.buildFailure)return bt(e.settlement);if(hs({resultKind:e.resultKind,settlement:e.settlement})){const r=Sr(e.settlement,e.resultKind??"");return r?e.settlement?.creditOutcome?r:`${r} We are still checking your Career Credits for that attempt, so nothing new can be started yet.`:bt(e.settlement)}return null}function pt(){return"Your résumé is ready, but this browser could not save a copy. Download it now: if you reload or close this tab it may be lost."}function ws(e){const t=e?.creditOutcome??null;return t==="kept"?"spent":t==="refunded"?"refunded":t==="unconfirmed"?"unconfirmed":"unknown"}const Er=(e,t)=>
1!!e&&t.includes(e),xs={fullName:"candidate-contact-full-name-001",email:"candidate-contact-email-001",phone:"candidate-contact-phone-001",location:"candidate-contact-location-001"};function gn(){return{fullName:{value:"",decision:"unreviewed"},email:{value:"",decision:"unreviewed"},phone:{value:"",decision:"unreviewed"},location:{value:"",decision:"unreviewed"}}}function Lt(e,t){const r=S(e),i=v(r?.evidenceId,80);return{value:v(r?r.value:e,t),decision:N(r?.decision,$t)?r.decision:"unreviewed",...i?{evidenceId:i}:{}}}function Cs(e){const t=S(e),r=S(t?.contact);return!!t&&N(t?.parseMode,["structured","source_preserving"])&&typeof t?.sourceResume=="string"&&!!r&&["fullName","email","phone","location"].every(i=>{const o=S(r?.[i]);return!!o&&typeof o?.value=="string"&&N(o?.decision,$t)})&&Array.isArray(t?.evidence)&&t.evidence.every(i=>{const o=S(i);return!!o&&N(o?.section,Wt)&&typeof o?.label=="string"&&typeof o?.value=="string"&&typeof o?.sourceExcerpt=="string"&&N(o?.sourceType,pn)&&N(o?.state,hn)})&&Array.isArray(t?.requirements)&&t.requirements.every(i=>{const o=S(i);return!!o&&N(o?.kind,vn)&&typeof o?.text=="string"&&typeof o?.sourceExcerpt=="string"})&&Array.isArray(t?.warnings)}function yn(e,t,r,{parsed:i=!1}={}){return Object.keys(e).reduce((o,s)=>{const c=e[s],m=Er(c.value,r)?xs[s]:void 0;return o[s]=i&&!m?{value:"",decision:c.decision==="omit"?"omit":"unreviewed"}:{value:c.value,decision:c.decision,...m?{evidenceId:m}:{}},o},gn())}function Tr(e,t,r){const i=S(e),o=es(i?.sourceResume??t),s=S(i?.contact),c=s?{fullName:Lt(s.fullName,120),email:Lt(s.email,160),phone:Lt(s.phone,80),location:Lt(s.location,160)}:{...gn(),fullName:{value:v(r,120),decision:"unreviewed"}},m=new Map,h=(Array.isArray(i?.evidence)?i.evidence:[]).slice(0,Oe.maxProvenanceEvidence).flatMap(C=>{const y=S(C);if(!y||!N(y.section,Wt))return[];const b=v(y.label,160),E=v(y.value,500),X=v(y.sourceExcerpt,500);if(!b||!E||!X)return[];const u=(m.get(y.section)??0)+1;return m.set(y.section,u),[{id:`candidate-${y.section.replace(/s$/,"")}-${String(u).padStart(3,"0")}`,section:y.section,label:b,value:E,sourceExcerpt:X,sourceType:N(y.sourceType,pn)?y.sourceType:"resume_extracted",state:N(y.state,hn)?y.state:"unreviewed"}]}),P=new Map,g=(Array.isArray(i?.requirements)?i.requirements:[]).slice(0,80).flatMap(C=>{const y=S(C);if(!y||!N(y.kind,vn))return[];const b=v(y.text,500),E=v(y.sourceExcerpt,500);if(!b||!E)return[];const X=(P.get(y.kind)??0)+1;return P.set(y.kind,X),[{id:`job-${y.kind}-${String(X).padStart(3,"0")}`,kind:y.kind,text:b,sourceExcerpt:E}]});return{parseMode:i?.parseMode==="structured"?"structured":"source_preserving",sourceResume:o,contact:yn(c,h,o),evidence:h,requirements:g,...S(i?.jobTarget)?{jobTarget:{role:v(S(i?.jobTarget)?.role,160),company:v(S(i?.jobTarget)?.company,160),industry:v(S(i?.jobTarget)?.industry,100),province:v(S(i?.jobTarget)?.province,100),source:S(i?.jobTarget)?.source==="deterministic"?"deterministic":"job_posting"}}:{},warnings:(Array.isArray(i?.warnings)?i.warnings:[]).map(C=>v(C,300)).filter(Boolean).slice(0,20)}}function Jn(e){if(!e||typeof e!="object")return null;const t=e;if(!["empty","reading","ready","error"].includes(t.status))return null;if(typeof t.text=="string"&&!yr(t.text))return{status:"error",name:v(t.name,180),text:"",error:`That document is ${t.text.length.toLocaleString("en-CA")} characters. Please add a version of 30,000 characters or fewer so nothing is lost.`};if(t.status==="reading"){const r=v(t.name,180);return{status:"error",name:r,text:"",error:`We did not finish reading ${r||"that file"}. Attach it again, or paste the text instead.`}}return{status:t.status,name:v(t.name,180),text:v(t.text,st.maxResumeChars),...t.error?{error:v(t.error,300)}:{}}}function js(e){if(!e||typeof e!="object")return null;const t=e,r=v(t.province,100);return{applicantName:v(t.applicantName,120),contactInfo:v(t.contactInfo,320),role:v(t.role,160),company:v(t.company,160),industry:v(t.industry,100),province:r,...r&&N(t.provinceSource,cs)?{provinceSource:t.provinceSource}:{},...Array.isArray(t.editedTargetFields)?{editedTargetFields:[...new Set(t.editedTargetFields.filter(gr))]}:{}}}function Rs(e,t,r){const i=S(e);if(i?.status!=="ready"||!Array.isArray(i.messages)||!Array.isArray(i.questionEvidenceIds)||!Array.isArray(i.suggestions))return{status:"refetch"};const o=r==="guided"?Mt*2+1:ot*2+1;if(i.messages.length>o)return{status:"refetch"};const s=i.messages.flatMap(u=>{const U=S(u);return!N(U?.role,["user","assistant"])||!W(U?.content,2e3)?[]:[{role:U.role,content:U.content.trim()}]});if(s.length!==i.messages.length)return{status:"refetch"};const c=v(i.question,1e3),m=i.ready===!0,h=N(i.questionKind,ls)?i.questionKind:void 0,P=new Set(t.requirements.map(u=>u.id)),g=new Set(t.evidence.map(u=>u.id)),C=v(i.questionRequirementId,80),y=i.questionEvidenceIds.filter(u=>typeof u=="string"&&g.has(u)),b=i.suggestions.flatMap(u=>W(u,160)?[u.trim()]:[]).slice(0,3),E=N(i.language,us)?i.language:"English",X=[...s].reverse().find(u=>u.role==="assistant");return!m&&(!c||!h||X?.content!==c)?{status:"refetch"}:h==="requirement"&&(!C||!P.has(C))?{status:"refetch"}:h!=="requirement"&&C?{status:"refetch"}:y.length!==i.questionEvidenceIds.length||new Set(y).size!==y.length?{status:"refetch"}:{status:"ready",messages:s,question:c||"Your evidence is saved. You can safely retry your tailored résumé.",...h?{questionKind:h}:{},...C?{questionRequirementId:C}:{},questionEvidenceIds:y,suggestions:b,ready:m,language:E}}function As(e){const t=S(e);if(!t||!N(t.status,["absent","loading","ready","warning","error"]))return Ve();const r=N(t.creditOutcome,["spent","refunded","not_reserved","unconfirmed"])?t.creditOutcome:"unconfirmed",i=typeof t.creditReference=="string"&&xr.test(t.creditReference)?t.creditReference:null,o=typeof t.creditsUsedBeforeCover=="number"&&Number.isFinite(t.creditsUsedBeforeCover)&&t.creditsUsedBeforeCover>=0?t.creditsUsedBeforeCover:null;if(t.status==="loading")return{status:"warning",text:"",error:r!=="not_reserved"?"The cover letter was still running when this tab reloaded, so we could not confirm what happened to the Career Credit. Your résumé is unchanged.":"The cover letter was still running when this tab reloaded. No Career Credit was used. Your résumé is unchanged.",errorCode:"COVER_LETTER_STATUS_UNKNOWN",creditOutcome:r!=="not_reserved"?"unconfirmed":"not_reserved",creditReference:null,creditsUsedBeforeCover:o};const s=v(t.text,st.maxResumeChars);return t.status==="ready"&&!s?Ve():{status:t.status,text:t.status==="ready"?s:"",error:typeof t.error=="string"&&v(t.error,500)||null,errorCode:typeof t.errorCode=="string"&&v(t.errorCode,100)||null,creditOutcome:r,creditReference:i,creditsUsedBeforeCover:o}}function Is(e){const t=e.replace(/\r\n/g,`
2`).split(`
3`).map(o=>o.trim()),r=t.findIndex((o,s)=>s>0&&/^#{1,6}\s+/.test(o));return t.slice(0,r>0?r:12).filter(o=>Zi.test(o)).slice(0,2).join(" | ").slice(0,320)}function _r(e){return"kind"in e?{kind:"application_workspace",artifact:{sections:e.artifact.sections.map(t=>({heading:t.heading,claims:t.claims.map(r=>({text:r.text,...r.generatedText!==void 0?{generatedText:r.generatedText}:{},evidenceIds:[...r.evidenceIds],verification:r.verification,evidenceAppliesTo:r.evidenceAppliesTo}))})),evidence:e.artifact.evidence.map(t=>({...t}))},contact:{fullName:{...e.contact.fullName},email:{...e.contact.email},phone:{...e.contact.phone},location:{...e.contact.location}},target:{...e.target},jobDescription:e.jobDescription}:{name:e.name,email:e.email,targetRole:e.targetRole,company:e.company,jobDescription:e.jobDescription,experience:e.experience,contactInfo:e.contactInfo,sendEmail:e.sendEmail}}function Ve(){return{status:"absent",text:"",error:null,errorCode:null,creditOutcome:"not_reserved"}}function Ss(e={}){const t=e.creditsUsedBeforeCover;return{status:"loading",text:"",error:null,errorCode:null,creditOutcome:"unconfirmed",creditReference:null,creditsUsedBeforeCover:typeof t=="number"&&Number.isFinite(t)&&t>=0?t:null}}const bn=new Set([400,402,429]);function Es(e,t){const r=e?.creditOutcome??null;return r==="refunded"?{outcome:"refunded",reference:null,sentence:"Your Career Credit was refunded."}:r==="kept"||r==="unconfirmed"?{outcome:"unconfirmed",reference:e?.requestId??null,sentence:e?.requestId?`We could not confirm the refund. Reference: ${e.requestId}.`:"We could not confirm the refund."}:bn.has(t)?{outcome:"not_reserved",reference:null,sentence:"No Career Credit was used."}:{outcome:"unconfirmed",reference:null,sentence:"We could not confirm what happened to the Career Credit."}}function Xn(){return{status:"error",text:"",error:"Your résumé is ready. The cover letter could not be finished and we could not confirm what happened to the Career Credit.",errorCode:null,creditOutcome:"unconfirmed",creditReference:null}}function Ts(e){const t=e?.creditOutcome??"not_reserved";return t==="refunded"||t==="not_reserved"}function cn(e,t,r){if(e>=200&&e<300&&typeof t.text=="string"&&t.text.trim()){const s=r?.creditOutcome??null;return{status:"ready",text:t.text.trim(),error:null,errorCode:null,creditOutcome:s==="kept"?"spent":s==="refunded"?"refunded":"unconfirmed",creditReference:s===null||s==="unconfirmed"?r?.requestId??null:null}}const i=Es(r,e),o=s=>[s,i.sentence,i.outcome==="refunded"?"Try again when you are ready.":""].filter(
3Boolean).join(" ");return e===402?{status:"error",text:"",error:"Your résumé is ready. One more Career Credit is needed for the cover letter.",errorCode:"COVER_LETTER_CREDITS_REQUIRED",creditOutcome:"not_reserved"}:t.code==="COVER_LETTER_FACT_CHECK_REJECTED"?{status:"error",text:"",error:o("Your résumé is ready. The cover letter did not pass our fact check."),errorCode:t.code,creditOutcome:i.outcome,creditReference:i.reference}:e===409?{status:"warning",text:"",error:o("Your résumé is ready. The cover letter needs another review."),errorCode:"COVER_LETTER_WARNING",creditOutcome:i.outcome,creditReference:i.reference}:{status:"error",text:"",error:o("Your résumé is ready. The cover letter could not be finished."),errorCode:null,creditOutcome:i.outcome,creditReference:i.reference}}function _s(e){return{status:e.status,settlement:Kt({creditOutcome:e.headers?.get?.("X-Career-Credit-Outcome")??null,requestId:e.headers?.get?.("X-Career-Credit-Reference")??null})}}async function ks(e){try{return await e.json()}catch{return{}}}function Ns(e){return{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_r(e))}}function qs(e){return{content:e.content,format:e.format,docType:e.docType,applicantName:e.applicantName,contactInfo:e.contactInfo,targetRole:e.targetRole,templateId:e.templateId}}function wn(e){return(e.mode==="quick"||e.mode==="guided")&&e.resume.status==="ready"&&e.resume.text.trim().length>=40&&e.posting.status==="ready"&&e.posting.text.trim().length>=40}function Ps(e){const t=e.evidence.filter(r=>r.state==="unreviewed").length;return t?[t===1?"Review the 1 highlighted résumé detail: confirm, correct or remove it.":`Review the ${t} highlighted résumé details: confirm, correct or remove each one.`]:[]}function kr(e){return[...Nr(e),...Ps(e)]}function Yt(e){return kr(e).length===0}function Nr(e){const t=[];(!e.contact.fullName.value.trim()||e.contact.fullName.decision!=="include")&&t.push("Enter and include your full name.");for(const r of["email","phone","location"]){const i=e.contact[r],o=r[0].toUpperCase()+r.slice(1);i.decision==="unreviewed"?t.push(`Choose Include or Omit for ${o.toLowerCase()}.`):i.decision==="include"&&!i.value.trim()&&t.push(`Enter ${r==="email"?"an":"a"} ${r} or choose Omit.`)}return t}function mn(e){return["email","phone","location"].flatMap(t=>{const r=e.contact[t];return r.decision==="include"&&r.value.trim()?[r.value.trim()]:[]}).join(" | ").slice(0,320)}function qr(e,t,r){const i=v(r.value,t==="phone"?80:t==="fullName"?120:160),o=t==="fullName"?"include":N(r.decision,$t)?r.decision:"unreviewed",s=e.contact[t],c=i===s.value?v(r.evidenceId,80):"",m=yn({...e.contact,[t]:{value:i,decision:o,...c?{evidenceId:c}:{}}},e.evidence,e.sourceResume);return{...e,contact:m}}function xn(e,t,r){return{...e,evidence:e.evidence.map(i=>i.id===t?r(i):i)}}function Os(e,t){return xn(e,t,r=>({...r,sourceType:"user_confirmed",state:"confirmed"}))}function Ls(e,t,r){const i=v(r,500);return i?xn(e,t,o=>({...o,value:i,sourceType:"user_corrected",state:"confirmed"})):e}function Bs(e,t){return xn(e,t,r=>({...r,state:"removed"}))}function Fs(e,t){if(!N(t.section,Wt)||e.evidence.length>=Oe.maxProvenanceEvidence)return e;const r=v(t.label,160),i=v(t.value,500);if(!r||!i)return e;const o=e.evidence.filter(c=>c.section===t.section).length+1,s={id:`candidate-${t.section.replace(/s$/,"")}-${String(o).padStart(3,"0")}`,section:t.section,label:r,value:i,sourceType:"user_added",sourceExcerpt:i,state:"confirmed"};return{...e,evidence:[...e.evidence,s]}}function Cn(e,t){const r=S(e),i=v(r?.question,500),o=v(r?.answer,Oe.maxApplicantAnswer);if(!i||!o)return null;const s=N(r?.kind,["requirement","value","adaptive"])?r.kind:void 0,c=t?new Set(t.evidence.map(b=>b.id)):null,m=t?new Set(t.requirements.map(b=>b.id)):null,h=s==="requirement"?v(r?.requirementId,80):"",P=h&&(!m||m.has(h))?h:"",g=Array.isArray(r?.candidateEvidenceIds)?r.candidateEvidenceIds.map(b=>v(b,80)).filter(b=>b&&(!c||c.has(b))).slice(0,3):[],C=[...new Set(g)],y=s==="requirement"?P?`requirement:${P}`:"":s==="value"?C[0]?`value:${C[0]}`:"":s==="adaptive"?"adaptive:transferable-value":"";return{question:i,answer:o,...s?{kind:s}:{},...P?{requirementId:P}:{},...C.length?{candidateEvidenceIds:C}:{},...y?{intentKey:y}:{}}}function Us(e){return{...e.finishWithCurrentEvidence===!0?{finishWithCurrentEvidence:!0}:{},messages:e.messages.slice(-20).map(t=>({...t,content:v(t.content,2e3)})),language:e.language,mode:e.mode,sourceResume:_e(e.sourceResume,"resume"),jobDescription:_e(e.jobDescription,"job"),targetRole:v(e.target.role,160),company:v(e.target.company,160),answerCount:e.answers.length,profile:e.profile,questionHistory:e.answers,quickHistory:e.answers}}function Ds(e){const t={...e.profile,sourceResume:_e(e.profile.sourceResume,"resume"),evidence:e.profile.evidence};return{mode:e.mode,sourceResume:_e(e.sourceResume,"resume"),jobDescription:_e(e.jobDescription,"job"),profile:t,target:(r=>({applicantName:v(r.applicantName,120),contactInfo:v(r.contactInfo,320),role:v(r.role,160),company:v(r.company,160),industry:v(r.industry,100),province:v(r.province,100)}))(wr(e.target,t)),clarifications:e.clarifications.slice(0,e.mode==="guided"?Mt:ot).flatMap(r=>{const i=Cn(r,t);return i?[i]:[]})}}function Ms(e){return e.ready===!0}function Pr(e,t){if(e.status!==200&&e.status!==422)return null;const r=S(t),i=S(r?.artifact),o=S(i?.contact),s=o&&Object.keys(gn()).map(x=>S(o[x])),c=[120,160,80,160],m=typeof i?.resumeText=="string"?i.resumeText.trim():"";if(!i||!m||typeof i.resumeText!="string"||i.resumeText.length>5e4||!s||!s.every((x,p)=>x&&typeof x.value=="string"&&x.value.length<=c[p]&&(x.evidenceId===void 0||W(x.evidenceId,80))&&N(x.decision,$t))||s[0]?.decision!=="include"||!v(s[0]?.value,120)||!Array.isArray(i.sections)||i.sections.length===0||i.sections.length>100||!Array.isArray(i.evidence)||i.evidence.length>Oe.maxProvenanceEvidence||!Array.isArray(i.requirements)||i.requirements.length>80||!Array.isArray(i.transformations)||i.transformations.length>100||!Array.isArray(i.warnings)||i.warnings.length>
3Oe.maxWarnings||!W(i.transformationSummary,500))return null;const h=i.resultKind==="tailored"&&i.creditOutcome==="spent",P=(i.resultKind==="evidence_only"||i.resultKind==="source_recovery")&&i.creditOutcome==="refunded";if(e.status===200&&!h||e.status===422&&!P)return null;const g=i.evidence.map(S),C=i.requirements.map(S);if(g.some(x=>!x||!W(x.id,80)||!N(x.section,Wt)||!W(x.label,160)||!W(x.value,500)||!N(x.sourceType,pn)||!W(x.sourceExcerpt,500)||!N(x.state,hn))||C.some(x=>!x||!W(x.id,80)||!N(x.kind,vn)||!W(x.text,500)||!W(x.sourceExcerpt,500)))return null;const y=new Set(g.map(x=>x.id)),b=new Set(C.map(x=>x.id)),E=new Map(g.map(x=>[x.id,x]));if(y.size!==g.length||b.size!==C.length)return null;const X=new Set,u=new Map,U=new Map;let Z=0;for(const x of i.sections){const p=S(x);if(!p||!W(p.id,80)||!W(p.heading,160)||!Array.isArray(p.claims)||p.claims.length===0)return null;for(const ye of p.claims){const _=S(ye),me=v(_?.id,80),w=v(_?.text,500),T=typeof _?.generatedText=="string"?_.generatedText.trim():"",D=_?.verification==="verified"&&_.evidenceAppliesTo==="generated_wording",L=_?.verification==="edited_by_user"&&_.evidenceAppliesTo==="prior_generated_wording"&&T.length>0&&T.length<=500,O=Array.isArray(_?.evidenceIds)?_.evidenceIds:null,ke=Array.isArray(_?.targetingRequirementIds)?_.targetingRequirementIds:null;if(!_||!me||X.has(me)||!w||!W(_.id,80)||!W(_.text,500)||!W(_.sectionId,80)||!W(_.sectionHeading,160)||_.generatedText!==void 0&&!W(_.generatedText,500)||_.sectionId!==p.id||_.sectionHeading!==p.heading||!N(_.presentation,["paragraph","bullet"])||!D&&!L||!O||O.length===0||new Set(O).size!==O.length||O.some(xe=>typeof xe!="string"||!y.has(xe))||!ke||new Set(ke).size!==ke.length||ke.some(xe=>typeof xe!="string"||!b.has(xe))||(X.add(me),u.set(me,L?T:w),U.set(me,new Set(O)),Z+=1,Z>100))return null}}if(Z===0)return null;const oe=new Map;for(const x of i.warnings){const p=S(x);if(!p||p.severity!=="warning"||p.claimPolicy!=="omit"||!W(p.requirement,Oe.maxWarningText)||!W(p.jobExcerpt,Oe.maxWarningText)||p.requirementId!==void 0&&!W(p.requirementId,80)||p.status!==void 0&&!N(p.status,["absent","unknown","expired","pending"])||p.applicantAnswerExcerpt!==void 0&&!W(p.applicantAnswerExcerpt,Oe.maxApplicantAnswerExcerpt))return null;typeof p.requirementId=="string"&&oe.set(p.requirementId,p)}const ne=new Set;for(const x of i.transformations){const p=S(x);if(!p||!W(p.reason,500))return null;if(p.kind==="removed_wording"){const w=Array.isArray(p.evidenceIds)?p.evidenceIds:null;if(!w||w.length===0||new Set(w).size!==w.length||w.some(D=>typeof D!="string"||!y.has(D))||!W(p.before,500)||!w.some(D=>{const L=E.get(String(D));return L&&[L.value,L.sourceExcerpt].some(O=>String(O).trim()===String(p.before).trim())})||p.claimId!==void 0||p.after!==void 0||p.requirementId!==void 0)return null;const T=`${p.kind}:${String(p.before).trim()}`;if(ne.has(T))return null;ne.add(T);continue}if(p.kind==="qualification_omission"){const w=v(p.requirementId,80),T=v(p.warningRequirementId,80),D=oe.get(T);if(!w||w!==T||!b.has(w)||!D||D.status!==p.status||!N(p.status,["absent","unknown","expired","pending"])||p.claimId!==void 0||p.evidenceIds!==void 0||p.before!==void 0||p.after!==void 0)return null;const L=`${p.kind}:${w}`;if(ne.has(L))return null;ne.add(L);continue}const ye=v(p?.claimId,80),_=Array.isArray(p?.evidenceIds)?p.evidenceIds:null;if(p.kind!=="surviving_change"||!u.has(ye)||!_||_.length===0||new Set(_).size!==_.length||_.some(w=>typeof w!="string"||!U.get(ye)?.has(w))||!N(p.category,["rephrased","reordered","condensed","localized","keyword_aligned"])||!v(p.before,500)||!v(p.after,500)||!v(p.reason,500)||typeof p.before!="string"||typeof p.after!="string"||typeof p.reason!="string"||p.before.trim().length>500||p.after.trim().length>500||p.reason.trim().length>500||p.before.trim()===p.after.trim()||p.after.trim()!==u.get(ye))return null;const me=`${p.kind}:${ye}:${p.before.trim()}:${p.after.trim()}`;if(ne.has(me))return null;ne.add(me)}return i}function $s(e){const r=S(e)?.resultKind==="tailored"?200:422,i=Pr({status:r},{artifact:e});if(!i)return null;const o=s=>({value:s.value,decision:s.decision,...s.evidenceId?{evidenceId:s.evidenceId}:{}});return{resumeText:i.resumeText,resultKind:i.resultKind,creditOutcome:i.creditOutcome,contact:{fullName:o(i.contact.fullName),email:o(i.contact.email),phone:o(i.contact.phone),location:o(i.contact.location)},sections:i.sections.map(s=>({id:s.id,heading:s.heading,claims:s.claims.map(c=>({id:c.id,sectionId:c.sectionId,sectionHeading:c.sectionHeading,text:c.text,presentation:c.presentation,evidenceIds:[...c.evidenceIds],targetingRequirementIds:[...c.targetingRequirementIds],verification:c.verification,evidenceAppliesTo:c.evidenceAppliesTo,...c.generatedText!==void 0?{generatedText:c.generatedText}:{}}))}
3)),evidence:i.evidence.map(s=>({id:s.id,section:s.section,label:s.label,value:s.value,sourceType:s.sourceType,sourceExcerpt:s.sourceExcerpt,state:s.state})),requirements:i.requirements.map(s=>({id:s.id,kind:s.kind,text:s.text,sourceExcerpt:s.sourceExcerpt})),transformations:i.transformations.map(s=>s.kind==="surviving_change"?{kind:s.kind,claimId:s.claimId,evidenceIds:[...s.evidenceIds],category:s.category,before:s.before,after:s.after,reason:s.reason}:s.kind==="removed_wording"?{kind:s.kind,evidenceIds:[...s.evidenceIds],before:s.before,reason:s.reason}:{kind:s.kind,requirementId:s.requirementId,warningRequirementId:s.warningRequirementId,status:s.status,reason:s.reason}),transformationSummary:i.transformationSummary,warnings:i.warnings.map(s=>({severity:s.severity,...s.requirementId?{requirementId:s.requirementId}:{},requirement:s.requirement,...s.status?{status:s.status}:{},jobExcerpt:s.jobExcerpt,...s.applicantAnswerExcerpt?{applicantAnswerExcerpt:s.applicantAnswerExcerpt}:{},claimPolicy:s.claimPolicy}))}}async function Ws(e,t=fetch,r={}){if(!wn(e))throw new Error("Add both documents and complete the job details before continuing.");const i={sourceResume:_e(e.resume.text,"resume"),jobDescription:_e(e.posting.text,"job"),target:{role:v(e.target.role,160),company:v(e.target.company,160),industry:v(e.target.industry,100),province:v(e.target.province,100)}},o=typeof AbortController=="function"?new AbortController:null,{response:s,result:c}=await Ut({send:()=>t("/api/application-workspace/parse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),...o?{signal:o.signal}:{}}),read:async b=>{try{return await b.json()}catch{return null}},abort:()=>o?.abort(),...r.deadlineMs===void 0?{}:{deadlineMs:r.deadlineMs},...r.setTimer?{setTimer:r.setTimer}:{},...r.clearTimer?{clearTimer:r.clearTimer}:{}}),m=S(c),h=m?.profile;if(!s.ok||!S(h))throw new Error(v(m?.error,300)||"We could not prepare your résumé review. Try again.");_e(S(h)?.sourceResume??i.sourceResume,"resume");const P=Tr(h,i.sourceResume,""),g={...P,contact:yn(P.contact,P.evidence,i.sourceResume,{parsed:!0})},C=g.contact.fullName.value.trim()?qr(g,"fullName",{...g.contact.fullName,decision:"include"}):g,y=Yt(C)?"evidence_questions":"parsed_review";return{...e,phase:y,profile:C}}function Or(e){return e.length<ot}function Ks(e,t){if(!Or(e))return e;const r=v(t.question,500),i=v(t.answer,2e3);if(!r||!i)return e;const o=Cn({...t,question:r,answer:i});return o?[...e,o]:e}function Bt(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0?e:null}function Ys(e){return e.parseMode!=="source_preserving"?!1:e.evidence.some(t=>t.sourceType==="resume_extracted"&&t.state==="unreviewed"&&t.value===t.sourceExcerpt&&Er(t.value,e.sourceResume))}function Lr(e){const t=S(e);if(!t)return null;const r=Jn(t.resume),i=Jn(t.posting),o=js(t.target);if(!r||!i||!o||!Array.isArray(t.answers))return null;const s=S(t.profile)?.sourceResume;if(typeof s=="string"&&!yr(s))return{phase:"intake",mode:t.mode==="guided"?"guided":"quick",resume:{status:"error",name:r.name,text:"",error:`That résumé is ${s.length.toLocaleString("en-CA")} characters. Please add a version of 30,000 characters or fewer so nothing is lost.`},posting:i,target:o,answers:[]};if(r.status==="error"||i.status==="error")return{phase:"intake",mode:t.mode==="guided"?"guided":"quick",resume:r,posting:i,target:o,answers:[]};const c=t.profile!==void 0,m=Cs(t.profile),h=N(t.phase,["intake","parsed_review","evidence_questions","resume_generation","resume_review","cover_letter"])?t.phase:null,P=h!==null,g=Tr(t.profile,r.text,o.applicantName),C=$s(t.resumeArtifact),y=t.mode==="guided"?"guided":"quick",b=h??"intake",E=c&&(!m||Nr(g).length>0),X=m&&Ys(g),U=!c||!P||b==="intake"||X&&!C?"intake":!!C&&(b==="resume_review"||b==="resume_generation")?"resume_review":E||b!=="parsed_review"&&!X&&!Yt(g)?"parsed_review":(b==="resume_review"||b==="cover_letter")&&!C?"evidence_questions":b==="resume_generation"?C?"resume_review":"evidence_questions":b==="cover_letter"?"resume_review":b,Z=Rs(t.questionSession,g,y),oe=U==="evidence_questions"?b==="resume_generation"?{status:"ready",messages:[],question:"Your evidence is saved.",questionEvidenceIds:[],suggestions:[],ready:!0,language:Z.status==="ready"?Z.language:"English"}:Z:void 0;return{phase:U,mode:y,resume:r,posting:i,target:o,profile:g,...C?{resumeArtifact:C}:{},...oe?{questionSession:oe}:{},...b==="resume_generation"?{buildFailure:"completion"}
3:t.buildFailure!==void 0?{buildFailure:N(t.buildFailure,["fact_check","completion","timeout"])?t.buildFailure:null}:{},...t.buildSettlement!==void 0&&t.buildSettlement!==null?{buildSettlement:Kt(S(t.buildSettlement)??{})}:{},...t.buildStages!==void 0?{buildStages:Dt(t.buildStages)}:{},...b==="resume_generation"||t.interruptedBuild===!0?{interruptedBuild:!0}:{},...Bt(t.attemptId)!==null?{attemptId:Bt(t.attemptId)}:{},...Bt(t.artifactAttemptId)!==null?{artifactAttemptId:Bt(t.artifactAttemptId)}:{},...W(t.attemptNotice,400)?{attemptNotice:t.attemptNotice}:{},...(()=>{if(N(t.resumeCreditResolution,["unsent","refunded","kept","delivered","unresolved"]))return{resumeCreditResolution:t.resumeCreditResolution};if(b==="resume_generation"||t.interruptedBuild===!0)return{resumeCreditResolution:"unresolved"};const ne=S(t.buildSettlement);if(!ne)return{};const x=ne.creditOutcome;return x==="refunded"?{resumeCreditResolution:"refunded"}:x==="kept"?{resumeCreditResolution:"kept"}:{resumeCreditResolution:"unresolved"}})(),...Zn(t.buildElapsedMs)!==null?{buildElapsedMs:Zn(t.buildElapsedMs)}:{},...t.coverLetterState!==void 0?{coverLetterState:As(t.coverLetterState)}:{},contactWasEdited:t.contactWasEdited===!0,answers:t.answers.slice(0,t.mode==="guided"?Mt:ot).flatMap(ne=>{const x=Cn(ne,g);return x?[x]:[]})}}function Dt(e){if(!Array.isArray(e))return[];const t=[];for(const r of e){if(!r||typeof r!="object"||Array.isArray(r))return[];const i=r,o=Vi.find(m=>m===i.stage),s=zi.find(m=>m===i.outcome),c=i.durationMs;if(!o||!s)return[];if(typeof c!="number"||!Number.isFinite(c)||c<0)return[];t.push({stage:o,durationMs:c,outcome:s})}return t}function Zn(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:null}function Ge(e,t){try{const r=t??(typeof window>"u"?void 0:window.sessionStorage);if(!r)return!1;const i=Lr(e);return i?(r.setItem(vt,JSON.stringify(i)),r.removeItem(gt),!0):!1}catch{return!1}}function Gs(e){try{const t=e??(typeof window>"u"?void 0:window.sessionStorage);if(!t)return null;const r=t.getItem(vt),i=r?null:t.getItem(gt),o=r??i;if(!o)return null;const s=Lr(JSON.parse(o));return s?(i&&(t.setItem(vt,JSON.stringify(s)),t.removeItem(gt)),s):(t.removeItem(vt),i&&t.removeItem(gt),null)}catch{try{e?.removeItem(vt),e?.removeItem(gt)}catch{}return null}}const Vs={tailoring:"Tailoring",fact_check:"Fact check",human_voice:"Résumé quality",format:"Evidence map"},zs={rewrite:"Rewrite",quality:"Résumé quality",fidelity:"Fact check",companion:"Evidence map"},Qs={passed:"passed",failed:"failed",timed_out:"timed out"};function fn(e){const t=Math.max(0,Math.floor((Number.isFinite(e)?e:0)/1e3));return`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function Hs({status:e}){return e==="complete"?n.jsx(hr,{"aria-hidden":"true"}):e==="active"?n.jsx(Pi,{className:"application-spin","aria-hidden":"true"}):e==="error"?n.jsx(Oi,{"aria-hidden":"true"}):n.jsx(Li,{"aria-hidden":"true"})}function it({stages:e,expanded:t=!1,recoveryKind:r,settlement:i,elapsedMs:o,stageTimings:s=[],heading:c,expectation:m}){const h=n.jsx("ul",{className:"application-stage-list",children:e.map(b=>n.jsxs("li",{"data-status":b.status,children:[n.jsx(Hs,{status:b.status}
3),n.jsx("span",{children:Vs[b.name]})]},b.name))}),P=r==="evidence_only"?"Your source-grounded résumé is ready":r==="source_recovery"?"Your preserved source résumé is ready":null,g=s.length>0&&n.jsx("ul",{className:"application-stage-report",children:s.map((b,E)=>n.jsxs("li",{"data-outcome":b.outcome,children:[n.jsx("span",{className:"application-stage-report-name",children:zs[b.stage]}),n.jsxs("span",{className:"application-stage-report-duration",children:[": ",fn(b.durationMs)]}),n.jsxs("span",{className:"application-stage-report-outcome",children:[" — ",Qs[b.outcome]]})]},`${b.stage}-${E}`))}),C=typeof o=="number"&&n.jsxs("p",{className:"application-work-elapsed",children:[fn(o)," elapsed"]}),y=m!==void 0?m:r?bs(i??null):"Keep this tab open while LandedIN tailors the résumé and checks every claim.";return t?n.jsxs("section",{className:"application-work-card","aria-live":"polite",children:[n.jsx("p",{children:c??P??"Building and checking your tailored résumé"}),y!==null&&n.jsx("p",{className:"application-work-expectation",children:y}),C,h,g]}):n.jsxs("details",{className:"application-team",children:[n.jsx("summary",{children:"Résumé checks"}),C,h,g]})}function er(e){return e==="APPLICATION_FACT_CHECK_REJECTED"?"fact_check":e==="APPLICATION_BUILD_TIMEOUT"||e==="APPLICATION_CLIENT_TIMEOUT"?"timeout":"completion"}function Js(e){const t=e.buildFailure?bt(e.settlement??null):null,r=t&&e.buildFailure==="timeout"?`The build ran out of time before it finished. ${t}`:t,i=e.blockedReason??null;return{message:e.ready?"I have enough to build your tailored résumé.":null,actionLabel:e.ready&&!e.creditBlocked&&!i&&yt(e.settlement)?t?"Try building again":"Build tailored resume · 1 Career Credit":null,blockedMessage:i?wt(i):null,blockedRetry:i==="wallet_unreadable",alert:r}}const Xs={requirement:"About a requirement",value:"Find transferable value",adaptive:"One last useful detail"};function tr(e){return e.replace(/\s*\u2014\s*/gu,", ").replace(/\s+\u2013\s+/gu," - ").replace(/\u2013/gu,"-")}function Zs(e){const t=d.useRef(null);d.useEffect(()=>{t.current?.focus()},[e.question]);const r=Js({ready:e.ready,buildFailure:e.buildFailure,creditBlocked:e.creditBlocked,settlement:e.settlement,blockedReason:e.blockedReason}),i=e.questionAuthoritative!==!1;function o(){const c=e.input.trim();c&&!e.loading&&i&&e.onSubmit(c)}function s(c){c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),o())}return n.jsxs("main",{className:"application-conversation rise","aria-labelledby":"application-question",children:[n.jsxs("div",{className:"application-conversation-top",children:[n.jsx("span",{children:e.mode==="quick"&&!e.ready?`Question ${Math.min(e.answers.length+1,ot)} of up to ${ot}`:e.mode==="quick"?"Quick · Ready":"Guided"}),n.jsxs("label",{children:["Language",n.jsx("select",{value:e.language,onChange:c=>e.onLanguageChange(c.target.value),children:e.languages.map(c=>n.jsx("option",{children:c},c))})]})]}),n.jsxs("section",{className:"application-question-card",children:[n.jsx("p",{className:"application-eyebrow",children:"LandedIN Career Guide"}),!e.ready&&e.questionKind&&n.jsx("p",{className:"application-question-purpose",children:Xs[e.questionKind]}),n.jsxs("div",{className:"application-question-heading",children:[n.jsx("h1",{id:"application-question",className:"application-current-message",ref:t,tabIndex:-1,children:r.message??tr(e.question)}),n.jsx("button",{type:"button",onClick:e.onReadQuestion,"aria-label":"Read question aloud",children:n.jsx(Fi,{"aria-hidden":"true"})})]}),!e.ready&&!i&&n.jsxs("div",{role:"status",children:[n.jsx("p",{children:"Restoring your saved interview…"}),!e.loading&&n.jsx("button",{type:"button",onClick:e.onRestoreQuestion,children:"Retry restoring interview"})]}),!e.ready&&i&&n.jsx("div",{className:"application-suggestions",children:e.suggestions.slice(0,3).map(c=>n.jsxs("button",{type:"button",onClick:()=>e.onSubmit(c),children:[n.jsx("span",{className:"sr-only",children:"Use suggested answer: "}),c]},c))}),e.creditNotice&&n.jsx("p",{className:"application-credit-note",role:"status",children:e.creditNotice}),e.ready&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"application-credit-note",children:"One successful tailored résumé uses 1 Career Credit."}),r.actionLabel&&n.jsx("button",{type:"button",className:"application-start",onClick:e.onBuild,"aria-label":e.buildF
3ailure?"Try building tailored resume again":"Build tailored resume for one Career Credit",children:r.actionLabel})]}),!r.actionLabel&&r.blockedMessage&&n.jsx("p",{className:"application-credit-note",role:"status",children:r.blockedMessage}),!r.actionLabel&&r.blockedRetry&&e.onRetryUsage&&n.jsx("button",{type:"button",className:"application-block-action",onClick:e.onRetryUsage,children:"Check my Career Credits again"}),!r.actionLabel&&e.blockedReason==="cover_unprovable"&&e.onRecoverUnprovableCover&&n.jsx("button",{type:"button",className:"application-block-action",onClick:e.onRecoverUnprovableCover,children:"Clear this and carry on"})]}),n.jsxs("div",{className:"application-conversation-details",children:[n.jsxs("details",{children:[n.jsx("summary",{children:"What I found"}),n.jsx("p",{children:e.resumeSummary}),n.jsx("p",{children:e.postingSummary})]}),n.jsxs("details",{children:[n.jsx("summary",{children:"Your answers"}),n.jsx("ol",{children:e.answers.map((c,m)=>n.jsxs("li",{children:[n.jsx("strong",{children:tr(c.question)}),n.jsx("span",{children:c.answer})]},`${c.question}-${m}`))})]}),!e.buildFailure&&n.jsx(it,{stages:e.stages,elapsedMs:e.buildElapsedMs,stageTimings:e.buildStages})]}),e.buildFailure&&n.jsx(it,{stages:e.stages,expanded:!0,heading:"What happened to this build",expectation:null,elapsedMs:e.buildElapsedMs,stageTimings:e.buildStages}),(r.alert??e.error)&&n.jsx("p",{className:"application-alert",role:"alert",children:r.alert??e.error}),(!e.ready||e.buildFailure)&&n.jsxs("div",{className:"application-finish-current-evidence",children:[n.jsx("button",{type:"button",onClick:e.onFinishWithCurrentEvidence,disabled:e.loading,children:"Use my résumé as-is"}),n.jsx("span",{children:"I will build from what your résumé already says and leave unsupported job requirements out."})]}),!e.ready&&n.jsxs("div",{className:"application-chat-composer",children:[n.jsx("textarea",{value:e.input,onChange:c=>e.onInputChange(c.target.value),onKeyDown:s,"aria-label":"Your answer",placeholder:"Type your answer",rows:2,disabled:e.loading||!i}),e.speechSupported&&n.jsx("button",{type:"button",onClick:e.onToggleListening,"aria-label":e.listening?"Stop voice input":"Start voice input","data-active":e.listening,children:n.jsx(Ui,{"aria-hidden":"true"})}),n.jsx("button",{type:"button",onClick:o,disabled:!e.input.trim()||e.loading||!i,"aria-label":"Send answer",children:n.jsx(Di,{"aria-hidden":"true"})})]}),n.jsx("p",{className:"application-private-note",children:"Nothing is invented. Only what you share is used."})]})}const eo="https://images.unsplash.com/photo-1758523419155-9436f8715a94?auto=format&fit=crop&w=1600&q=82",to="https://unsplash.com/photos/woman-reading-document-at-kitchen-table-with-coffee-RNUNbvIXUbg",no=["Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland and Labrador","Northwest Territories","Nova Scotia","Nunavut","Ontario","Prince Edward Island","Quebec","Saskatchewan","Yukon"];function nr(e,t){const r=e.target.files?.[0];r&&t(r),e.target.value=""}function rr({document:e,label:t}){return e.status!=="ready"?null:n.jsxs("span",{className:"application-document-chip",title:e.name,children:[n.jsx(hr,{"aria-hidden":"true"}),n.jsxs("span",{children:[t," ready"]})]})}function ln({label:e,onPaste:t}){return n.jsxs("details",{className:"application-paste-fallback",children:[n.jsxs("summary",{children:["Paste ",e.toLowerCase()," text"]}),n.jsxs("label",{children:[n.jsxs("span",{className:"sr-only",children:[e," text"]}),n.jsx("textarea",{rows:5,placeholder:`Paste the ${e.toLowerCase()} here`,onChange:r=>t(r.currentTarget.value)})]})]})}function ro(e){const t=wn({mode:e.mode,resume:e.resume,posting:e.posting,target:e.target});return n.jsxs("main",{className:"application-intake rise","aria-labelledby":"application-intake-title",children:[n.jsxs("section",{className:"application-intake-copy",children:[n.jsx("p",{className:"application-eyebrow",children:"LandedIN Career Guide"}),n.jsx("h1",{id:"application-intake-title",children:"Your next application, handled."}),n.jsx("p",{className:"application-intro",children:"Bring your résumé and the job. We will build the rest."}),n.jsxs("div",{className:"application-composer","aria-label":"Application documents",children:[n.jsxs("div",{className:"application-mode","aria-label":"Application mode",children:[n.jsx("button",{type:"button",className:e.mode==="quick"?"is-active":"","aria-pressed":e.mode==="quick",onClick:()=>
3e.onModeChange("quick"),children:"Quick"}),n.jsx("button",{type:"button",className:e.mode==="guided"?"is-active":"","aria-pressed":e.mode==="guided",onClick:()=>e.onModeChange("guided"),children:"Guided"})]}),n.jsxs("div",{className:"application-attach-row",children:[n.jsxs("label",{className:"application-attach-button",children:[n.jsx(Mi,{"aria-hidden":"true"}),n.jsx("span",{children:e.resume.status==="reading"?"Reading résumé":"Attach résumé"}),n.jsx("input",{type:"file",accept:".pdf,.docx,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document",disabled:e.busy||e.resume.status==="reading",onChange:r=>nr(r,e.onAttachResume)})]}),n.jsxs("label",{className:"application-attach-button",children:[n.jsx($i,{"aria-hidden":"true"}),n.jsx("span",{children:e.posting.status==="reading"?"Reading posting":"Add job posting"}),n.jsx("input",{type:"file",accept:".pdf,.docx,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document",disabled:e.busy||e.posting.status==="reading",onChange:r=>nr(r,e.onAttachPosting)})]})]}),n.jsxs("div",{className:"application-chip-row","aria-live":"polite",children:[n.jsx(rr,{document:e.resume,label:"Résumé"}),n.jsx(rr,{document:e.posting,label:"Job posting"})]}),e.posting.status==="empty"&&n.jsx(ln,{label:"Job posting",onPaste:e.onPastePosting}),e.resume.status!=="ready"&&n.jsx(ln,{label:"Résumé",onPaste:e.onPasteResume}),(e.resume.status==="error"||e.posting.status==="error")&&n.jsxs("div",{className:"application-file-errors",role:"alert",children:[e.resume.status==="error"&&n.jsx("p",{children:e.resume.error}),e.posting.status==="error"&&n.jsx("p",{children:e.posting.error}),e.posting.status==="error"&&n.jsx(ln,{label:"Job posting",onPaste:e.onPastePosting})]}),(e.resume.status==="ready"||e.posting.status==="ready")&&n.jsxs("div",{className:"application-target-grid rise-kids",children:[n.jsxs("label",{children:["Target role",n.jsx("input",{value:e.target.role,onChange:r=>e.onTargetChange("role",r.target.value)})]}),n.jsxs("label",{children:["Company",n.jsx("input",{value:e.target.company,onChange:r=>e.onTargetChange("company",r.target.value)})]}),n.jsxs("label",{children:["Industry",n.jsx("input",{value:e.target.industry,onChange:r=>e.onTargetChange("industry",r.target.value)})]}),n.jsxs("label",{children:["Province",n.jsxs("select",{value:e.target.province,onChange:r=>e.onTargetChange("province",r.target.value),children:[n.jsx("option",{value:"",children:"Choose province"}),no.map(r=>n.jsx("option",{children:r},r))]})]})]}),n.jsx("div",{className:"application-intake-status",role:e.statusIsError?"alert":void 0,"aria-live":e.statusIsError?"assertive":"polite",children:e.statusMessage&&n.jsx("p",{children:e.statusMessage})}),n.jsxs("div",{className:"application-start-row",children:[n.jsxs("button",{type:"button",className:"application-start",disabled:!t||e.busy,onClick:e.onStart,children:[n.jsx("span",{children:e.busy?"Preparing review":"Start"}),n.jsx(Wi,{"aria-hidden":"true"})]}),e.busy&&e.onCancel&&n.jsx("button",{type:"button",className:"application-cancel",onClick:e.onCancel,children:"Cancel"})]})]}),n.jsxs("div",{className:"application-trust-row",children:[n.jsx("span",{children:"Free. No credit card."}),n.jsxs("details",{children:[n.jsx("summary",{children:"How we use your files"}),n.jsx("p",{children:"Your files are used only to build this application. Résumé text is never sent to analytics."})]})]}),n.jsxs(_i,{href:"/build",className:"application-builder-link",children:[n.jsx(Ki,{"aria-hidden":"true"}),"Start without a résumé"]})]}),n.jsxs("aside",{className:"application-photo","aria-label":"A job seeker reading good news",children:[n.jsx("img",{src:eo,alt:"A woman smiling while reading a letter at her kitchen table"}),n.jsxs("details",{className:"application-photo-credit",children:[n.jsx("summary",{children:"Photo"}),n.jsx("a",{href:to,target:"_blank",rel:"noreferrer",children:"Vitaly Gariev on Unsplash"})]})]})]})}const io=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Le=e=>e.normalize("NFKC").replace(/\s+/gu," ").trim(),Br=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|(?:\+?1[\s.-]?)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}|linkedin\.com\/in\/|https?:\/\/)/iu,so=/(?:^|[|·•])\s*(?:email|phone|location|address)\s*:/iu;function oo(e){const t=Le(e);if(!t)return null;const r=t.split(" ").map(io).join("\\s+");return new RegExp(`(^|[^\\p{L}\\p{N}])(?:${r})(?=$|[^\\p{L}\\p{N}])`,"giu")}function Fr(e,t){const r=oo(t);return r?e.replace(r,"$1"):e}function Ur(e,t){const r=Le(e).toLowerCase(),i=new Set(t.map(s=>s.toLowerCase())),o=e.split(/[|·•]/u).some(s=>i.has(Le(s).toLowerCase()));return Br.test(e)||so.test(e)||i.has(r)||o}function ir(e,t){let r=e;for(const i of t)r=Fr(r,i);return/^[\s|·•,;:\-–—#]*$/u.test(r)?null:r.replace(/^\s*[|·•]+\s*|\s*[|·•]+\s*$/gu,"").trimEnd()}function Dr(e){return Br.test(e)}function ao(e,t){const r=new Set;for(const i of t.filter(o=>
3/\s/u.test(o))){const o=i.split(/\s+/u).filter(Boolean);for(let s=0;s<e.length;s+=1)for(let c=s;c<Math.min(e.length,s+o.length+2);c+=1)if(Le(e.slice(s,c+1).join(" "))===i)for(let m=s;m<=c;m+=1)r.add(m)}return e.filter((i,o)=>!r.has(o))}function Y(e,t){if(/\r?\n/u.test(e))return Mr(e.replace(/\r\n/gu,`
4`),t);const r=[t.fullName,t.email,t.phone,t.location].map(c=>Le(c.value)).filter(Boolean).sort((c,m)=>m.length-c.length),i=[t.email,t.phone].filter(c=>c.decision==="omit").map(c=>Le(c.value)).filter(Dr),o=Ur(e,r)?r:i;let s=e;for(const c of o)s=Fr(s,c);return s.replace(/\s{2,}/gu," ").replace(/\s+([.,;:])/gu,"$1").replace(/^[\s|·•]+|[\s|·•]+$/gu,"").trim()}function Mr(e,t){const r=[t.fullName,t.email,t.phone,t.location].map(g=>Le(g.value)).filter(Boolean).sort((g,C)=>C.length-g.length),i=[t.email,t.phone].filter(g=>g.decision==="omit").map(g=>Le(g.value)).filter(Dr),o=e.split(`
5`),s=o.findIndex(g=>/^#{2,6}\s+/u.test(g.trim())),c=s>=0?s:Math.min(o.length,12),h=ao(o.slice(0,c),r).flatMap(g=>{if(!g.trim())return[""];if(!Ur(g,r))return[g];const C=ir(g,r);return C===null?[]:[C]}),P=o.slice(c).flatMap(g=>{if(!g.trim())return[""];const C=ir(g,i);return C===null?[]:[C]});return[...h,...P].join(`
6`).replace(/\n{3,}/gu,`
7
8`).trim()}function jn(e){const t=e.resultKind==="source_recovery"?e.sections.flatMap(r=>r.claims).map(r=>r.text).join(""):e.sections.flatMap(r=>[`## ${r.heading}`,...r.claims.map(i=>i.presentation==="bullet"?`- ${i.text}`:i.text)]).join(`
9
10`).trim();return Mr(t,e.contact)}function co(e,t,r){const i=r.trim();if(!i)throw new Error("Claim edit cannot be empty.");if(i.length>500)throw new Error("Claim edit cannot exceed 500 characters.");let o=!1;const s=e.sections.map(m=>({...m,claims:m.claims.map(h=>{if(h.id!==t)return h;o=!0;const P=h.generatedText??h.text,g=i===P;return{...h,text:i,generatedText:P,verification:g?"verified":"edited_by_user",evidenceAppliesTo:g?"generated_wording":"prior_generated_wording"}})}));if(!o)throw new Error(`Unknown claim ID: ${t}`);const c={...e,sections:s};return{...c,resumeText:jn(c)}}function $r(e){return[e.email,e.phone,e.location].filter(t=>t.decision==="include"&&t.value.trim()).map(t=>t.value.trim().replace(/\s+/gu," ")).join(" | ")}function lo(e,t,r,i){return{content:jn(e),format:t,docType:"resume",applicantName:e.contact.fullName.value.trim().replace(/\s+/gu," "),contact:{fullName:{...e.contact.fullName},email:{...e.contact.email},phone:{...e.contact.phone},location:{...e.contact.location}},targetRole:r.trim(),templateId:i}}function uo(e){const t=$r(e.artifact.contact);return n.jsxs("div",{className:"application-document-preview",children:[n.jsxs("header",{className:"application-resume-header",children:[n.jsx("h2",{children:e.artifact.contact.fullName.value.trim().replace(/\s+/gu," ")}),t&&n.jsx("p",{children:t})]}),e.artifact.sections.map(r=>n.jsxs("section",{"aria-labelledby":`resume-section-${r.id}`,children:[n.jsx("h3",{id:`resume-section-${r.id}`,children:r.heading}),r.claims.map(i=>e.editing?n.jsxs("label",{className:"application-claim-editor",children:[n.jsxs("span",{className:"sr-only",children:["Edit ",r.heading," claim"]}),n.jsx("textarea",{"aria-label":`Edit ${r.heading} claim`,value:Y(i.text,e.artifact.contact),onChange:o=>e.onClaimChange(i.id,o.target.value)})]},i.id):n.jsx("button",{type:"button",className:`application-resume-claim ${i.presentation==="bullet"?"is-bullet":""}`,"aria-pressed":e.selectedClaimId===i.id,onClick:()=>e.onSelectClaim(i.id),children:Y(i.text,e.artifact.contact)},i.id))]},r.id))]})}function mo(e){const t=new Map(e.sections.flatMap(s=>s.claims).map(s=>[s.id,s])),r=new Map(e.evidence.map(s=>[s.id,s])),i=new Set(e.requirements.map(s=>s.id)),o=new Map(e.warnings.flatMap(s=>s.requirementId?[[s.requirementId,s]]:[]));return e.transformations.filter(s=>{if(s.kind==="removed_wording")return s.before.trim().length>0&&s.reason.trim().length>0&&s.before.length<=500&&s.reason.length<=500&&s.evidenceIds.length>0&&s.evidenceIds.some(m=>{const h=r.get(m);return h&&(h.value.trim()===s.before.trim()||h.sourceExcerpt.trim()===s.before.trim())});if(s.kind==="qualification_omission"){const m=o.get(s.warningRequirementId);return i.has(s.requirementId)&&s.warningRequirementId===s.requirementId&&m?.status===s.status&&s.reason.trim().length>0&&s.reason.length<=500}const c=t.get(s.claimId);return!!(c&&s.before.trim()&&s.after.trim()&&s.reason.trim()&&s.before.trim()!==s.after.trim()&&s.before.length<=500&&s.after.length<=500&&s.reason.length<=500&&(c.generatedText??c.text)===s.after&&s.evidenceIds.length>0&&s.evidenceIds.every(m=>r.has(m)&&c.evidenceIds.includes(m)))})}function fo(e){return{resume_extracted:"Résumé extraction",user_confirmed:"Confirmed by you",user_corrected:"Corrected by you",question_answer:"Your answer",user_added:"Added by you"}[e]}function po(e){return{unreviewed:"Not reviewed",confirmed:"Confirmed",unknown:"Unknown",absent:"Absent",contradicted:"Contradicted",removed:"Removed"}[e]}function ho({artifact:e,selectedClaimId:t,activeView:r="resume",isCompactReview:i=!1,showWarnings:o=!0}){const s=e.sections.flatMap(u=>u.claims),c=new Map(s.map(u=>[u.id,u])),m=t?s.filter(u=>u.id===t):s,h=t?c.get(t):void 0,P=h?.verification==="edited_by_user"&&h.evidenceAppliesTo==="prior_generated_wording",g=new Set(m.map(u=>u.id)),C=new Set(m.flatMap(u=>u.evidenceIds)),y=new Set(m.flatMap(u=>u.targetingRequirementIds)),b=mo(e).filter(u=>!t||u.kind==="surviving_change"&&g.has(u.claimId)),E=e.evidence.filter(u=>C.has(u.id)),X=e.requirements.filter(u=>y.has(u.id));return n.jsxs("aside",{className:"application-resume-insights","aria-label":"Résumé insights","data-mobile-active":i?r!=="resume":void 0,children:[n.jsxs("section",{className:"application-insight-panel",id:"application-changes-panel",role:i?"tabpanel":void 0,"aria-labelledby":i?"application-changes-tab resume-changes-title":"resume-changes-title","data-mobile-active":i?r==="changes":void 0,tabIndex:i?0:void 0,children:[n.jsx("h2",{id:"resume-changes-title",children:"What changed"}),b.length?b.map(u=>{if(u.kind==="removed_wording")return n.jsxs("article",{children:[n.jsxs("p",{children:[n.jsx("strong",{children:"Removed wording:"})," ",Y(u.before,e.contact)]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Why it was removed:"})," ",Y(u.reason,e.contact)]})]},`${u.kind}-${u.before}`);if(u.kind==="qualification_omission"){const oe=e.requirements.find(x=>x.id===u.requirementId),ne=e.warnings.find(x=>x.requirementId===u.warningRequirementId);return n.jsxs("article",{children:[n.jsxs("p",{children:[n.jsx("strong",{children:"Qualification left out:"})," ",Y(oe.text,e.contact)]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Status:"})," ",u.status[0].toUpperCase()+u.status.slice(1)]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Posting:"})," “",Y(ne.jobExcerpt,e.contact),"”"]}
10),ne.applicantAnswerExcerpt&&n.jsxs("p",{children:[n.jsx("strong",{children:"Your answer:"})," “",Y(ne.applicantAnswerExcerpt,e.contact),"”"]}),n.jsx("p",{children:Y(u.reason,e.contact)})]},`${u.kind}-${u.requirementId}`)}const U=c.get(u.claimId),Z=U?.verification==="edited_by_user"&&U.evidenceAppliesTo==="prior_generated_wording";return n.jsxs("article",{children:[n.jsxs("p",{children:[n.jsx("strong",{children:"Before:"})," ",Y(u.before,e.contact)]}),n.jsxs("p",{children:[n.jsxs("strong",{children:[Z?"Prior generated wording":"After",":"]})," ",Y(u.after,e.contact)]}),Z&&n.jsxs("p",{children:[n.jsx("strong",{children:"Current edited wording:"})," ",Y(U.text,e.contact)]}),n.jsxs("p",{children:[n.jsxs("strong",{children:[Z?"Why the generated wording changed":"Why",":"]})," ",Y(u.reason,e.contact)]})]},`${u.claimId}-${u.before}`)}):n.jsx("p",{children:"No validated wording changes for this claim."})]}),n.jsxs("section",{className:"application-insight-panel",id:"application-evidence-panel",role:i?"tabpanel":void 0,"aria-labelledby":i?"application-evidence-tab resume-evidence-title":"resume-evidence-title","data-mobile-active":i?r==="evidence":void 0,tabIndex:i?0:void 0,children:[n.jsx("h2",{id:"resume-evidence-title",children:"Evidence"}),P&&n.jsxs("div",{className:"application-evidence-boundary",role:"status",children:[n.jsx("strong",{children:"Edited by you"}),n.jsx("p",{children:"Evidence applies to the prior generated wording. Your current wording has not been reverified."})]}),n.jsx("h3",{children:"Candidate source"}),E.length?n.jsx("ul",{className:"application-evidence-records",children:E.map(u=>{const U=u.value.trim()!==u.sourceExcerpt.trim(),Z=u.sourceType==="user_corrected"?u.state==="confirmed"?"Corrected and confirmed evidence":"Corrected evidence":"Reviewed evidence";return n.jsxs("li",{children:[n.jsxs("p",{children:[n.jsx("strong",{children:"Source type:"})," ",fo(u.sourceType)]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Status:"})," ",po(u.state)]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Original source excerpt:"})," ",Y(u.sourceExcerpt,e.contact)]}),U&&n.jsxs("p",{children:[n.jsxs("strong",{children:[Z,":"]})," ",Y(u.value,e.contact)]})]},u.id)})}):n.jsx("p",{children:"No candidate source is linked to this claim."}),n.jsx("h3",{children:"Job targeting"}),X.length?n.jsx("ul",{children:X.map(u=>n.jsx("li",{children:Y(u.sourceExcerpt,e.contact)},u.id))}):n.jsx("p",{children:"No job-targeting excerpt is linked to this claim."})]}),o&&e.warnings.length>0&&n.jsxs("section",{className:"application-insight-warnings","aria-labelledby":"resume-warnings-title",children:[n.jsx("h2",{id:"resume-warnings-title",children:"Warnings"}),n.jsx("ul",{children:e.warnings.map((u,U)=>n.jsxs("li",{children:[n.jsx("strong",{children:Y(u.requirement,e.contact)}),u.status&&n.jsxs(n.Fragment,{children:[" · ",n.jsx("strong",{children:"Status:"})," ",u.status[0].toUpperCase()+u.status.slice(1)]}),n.jsxs("span",{children:[" · ",n.jsx("strong",{children:"Posting:"})," “",Y(u.jobExcerpt,e.contact),"”"]}),u.applicantAnswerExcerpt&&n.jsxs("span",{children:[" · ",n.jsx("strong",{children:"Your answer:"})," “",Y(u.applicantAnswerExcerpt,e.contact),"”"]}),n.jsx("span",{children:" · This unsupported qualification was left out of the résumé."})]},`${u.requirement}-${U}`))})]})]})}function Rn(e=!0){const t=d.useRef(null);return d.useEffect(()=>{e&&t.current?.focus()},[e]),t}const sr=["resume","changes","evidence"];function vo(){const[e,t]=d.useState(!1);return d.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const r=window.matchMedia("(max-width: 850px)"),i=()=>t(r.matches);return i(),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[]),e}function go(e,t){const r=["resume","changes","evidence"];if(t==="Home")return r[0];if(t==="End")return r[r.length-1];const i=t==="ArrowRight"?1:t==="ArrowLeft"?-1:0;return i?r[(e+i+r.length)%r.length]:null}function yo(e){if(e==="exhausted")return"A cover letter needs another Career Credit. This résumé used your last one.";const t=wt(e);return t?`A cover letter needs its own Career Credit. ${t}`:"A cover letter needs its own Career Credit. We cannot start one until the credit from this résumé is settled."}function bo(e){return e&&e!=="cover_ready"&&e!=="cover_in_progress"?wt(e):null}function wo(e){const[t,r]=d.useState(!1),[i,o]=d.useState(null),[s,c]=d.use
10State("resume"),[m,h]=d.useState(""),[P,g]=d.useState(""),C=vo(),y=Rn(),b=jn(e.artifact).trim().length>0,E=e.coverState??{status:"absent",text:"",error:null,errorCode:null,creditOutcome:"not_reserved"};function X(w,T){try{const D=co(e.artifact,w,T);e.onArtifactChange(D);const L=D.sections.flatMap(O=>O.claims).find(O=>O.id===w);L&&Pe("application_claim_edited",{verification_state:L.verification}),h("")}catch(D){h(D instanceof Error?D.message:"That edit could not be saved.")}}async function u(w){if(b){h("");try{const T=await fetch("/api/export-document",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(lo(e.artifact,w,e.targetRole,e.templateId))});if(!T.ok)throw new Error(`${w.toUpperCase()} download failed. Try again.`);const D=await T.blob(),L=URL.createObjectURL(D),O=document.createElement("a");O.href=L,O.download=`Application_resume.${w}`,O.click(),Pe("application_resume_download",{format:w,result_kind:e.artifact.resultKind}),URL.revokeObjectURL(L)}catch(T){h(T instanceof Error?T.message:"Download failed. Try again.")}}}async function U(w){if(!(E.status!=="ready"||!E.text.trim())){g("");try{const T=await fetch("/api/export-document",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(qs({content:E.text,format:w,docType:"cover-letter",applicantName:e.artifact.contact.fullName.value.trim(),contactInfo:$r(e.artifact.contact),targetRole:e.targetRole,templateId:e.templateId}))});if(!T.ok)throw new Error(`Cover ${w.toUpperCase()} download failed. Try again.`);const D=await T.blob(),L=URL.createObjectURL(D),O=document.createElement("a");O.href=L,O.download=`Application_cover_letter.${w}`,O.click(),URL.revokeObjectURL(L)}catch(T){g(T instanceof Error?T.message:"Cover letter download failed. Try again.")}}}const Z=e.latestAttemptFailed?null:Sr(e.settlement??null,e.artifact.resultKind),oe=e.paidCoverAllowed!==void 0?e.paidCoverAllowed:!e.unresolvedCredit&&(yt(e.settlement)||e.artifact.resultKind==="tailored"),ne=e.paidCoverAllowed!==void 0?e.paidCoverAllowed:oe&&Ts(E),x=e.artifact.resultKind==="tailored"?"tailored résumé":e.artifact.resultKind==="evidence_only"?"source-grounded résumé":"preserved source résumé",p=e.latestAttemptFailed?`Your previous ${x}`:`Your ${x}`,_=e.onRetryResume&&e.paidResumeAllowed!==!1&&!e.unresolvedCredit?null:bo(e.resumeBlockedReason);function me(w,T){const D=go(T,w.key);if(!D)return;w.preventDefault(),c(D);const L=sr.indexOf(D);w.currentTarget.parentElement?.querySelectorAll('[role="tab"]')?.[L]?.focus()}return n.jsxs("main",{className:"application-review rise","aria-labelledby":"application-review-title",children:[n.jsxs("header",{children:[n.jsx("p",{className:"application-eyebrow",children:"Ready to review"}),n.jsx("h1",{id:"application-review-title",ref:y,tabIndex:-1,children:p})]}),e.latestAttemptNotice&&!e.latestAttemptFailed&&n.jsx("p",{className:"application-credit-note",role:"status",children:e.latestAttemptNotice}),e.latestAttemptFailed&&n.jsxs("section",{className:"application-recovery-warning",role:"alert",children:[n.jsxs("p",{children:[n.jsx("strong",{children:"Latest retry failed."}),e.latestFailureReason?` ${e.latestFailureReason}`:""," Your previous ",x," is preserved below for editing, PDF and DOCX."]}),n.jsx("p",{children:bt(e.settlement??null)}),!e.settlement?.creditOutcome&&!_&&n.jsx("p",{children:"We are still checking your Career Credits for that attempt, so nothing new can be started yet."}),_&&n.jsx("p",{children:_}),n.jsxs("div",{className:"application-recovery-actions",children:[e.onRetryResume&&e.paidResumeAllowed!==!1&&!e.unresolvedCredit&&n.jsx("button",{type:"button",onClick:e.onRetryResume,children:"Try tailored resume again · 1 Career Credit"}),e.onBackToEvidence&&n.jsx("button",{type:"button",onClick:e.onBackToEvidence,children:"Back to evidence"})]})]}),Z&&n.jsxs("section",{className:"application-recovery-warning",role:"status",children:[n.jsx("p",{children:Z}),n.jsxs("div",{className:"application-recovery-actions",children:[e.onRetryResume&&!e.unresolvedCredit&&yt(e.settlement)&&n.jsx("button",{type:"button",onClick:e.onRetryResume,children:"Try tailored resume again · 1 Career Credit"}),e.onBackToEvidence&&n.jsx("button",{type:"button",onClick:e.onBackToEvidence,children:"Back to evidence"})]})]}),e.artifact.warnings.length>0&&n.jsxs("section",{className:"application-review-warnings",role:"status","aria-label":"Résumé warnings",children:[n.jsx("p",{children:"The posting includes qualifications that are not supported by your evidence. They were left out without blocking this résumé."}),n.jsx("ul",{children:e.artifact.warnings.map((w,T)=>n.jsxs("li",{children:[n.jsx("strong",{children:Y(w.requirement,e.artifact.contact)}),w.status&&n.jsxs(n.Fragment,{children:[" · ",n.jsx("strong",{children:"Status:"})," ",w.status[0].toUpperCase()+w.status.slice(1)]}),n.jsxs("span",{children:[" · ",n.jsx("strong",{children:"Posting:"})," “",Y(w.jobExcerpt,e.artifact.contact),"”"]}
10),w.applicantAnswerExcerpt&&n.jsxs("span",{children:[" · ",n.jsx("strong",{children:"Your answer:"})," “",Y(w.applicantAnswerExcerpt,e.artifact.contact),"”"]}),n.jsx("span",{children:" · This unsupported qualification was left out without blocking your résumé."})]},`${w.requirement}-${T}`))})]}),C&&n.jsx("div",{className:"application-mobile-tabs",role:"tablist","aria-label":"Résumé review views",children:sr.map((w,T)=>n.jsx("button",{type:"button",role:"tab","aria-selected":s===w,"aria-controls":`application-${w}-panel`,id:`application-${w}-tab`,tabIndex:s===w?0:-1,onClick:()=>c(w),onKeyDown:D=>me(D,T),children:w[0].toUpperCase()+w.slice(1)},w))}),n.jsxs("div",{className:"application-review-grid",children:[n.jsx("article",{className:"application-paper application-review-panel",id:"application-resume-panel",role:C?"tabpanel":void 0,"aria-labelledby":C?"application-resume-tab":void 0,"data-mobile-active":C?s==="resume":void 0,children:n.jsx(uo,{artifact:e.artifact,editing:t,selectedClaimId:i,onClaimChange:X,onSelectClaim:o})}),n.jsx(ho,{artifact:e.artifact,selectedClaimId:i,activeView:s,isCompactReview:C,showWarnings:!1})]}),m&&n.jsx("p",{className:"application-export-error",role:"alert",children:m}),n.jsxs("nav",{className:"application-review-dock sticky","aria-label":"Résumé actions",children:[n.jsxs("button",{type:"button",onClick:()=>r(w=>!w),disabled:!b,children:[n.jsx(Bi,{"aria-hidden":"true"}),"Edit"]}),n.jsxs("button",{type:"button",onClick:()=>{u("docx")},disabled:!b,children:[n.jsx(qt,{"aria-hidden":"true"}),"DOCX"]}),n.jsxs("button",{type:"button",onClick:()=>{u("pdf")},disabled:!b,children:[n.jsx(qt,{"aria-hidden":"true"}),"PDF"]})]}),n.jsxs("section",{className:"application-retry application-cover-card","aria-labelledby":"application-cover-title",children:[n.jsx("p",{className:"application-eyebrow",children:"Optional next step"}),n.jsx("h2",{id:"application-cover-title",children:"Cover letter"}),E.status==="absent"&&(oe?n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Your résumé is ready to use. Create a separate cover letter only if you want one for this application."}),n.jsx("button",{type:"button",onClick:e.onCreateCoverLetter,children:"Create cover letter · 1 Career Credit"})]}):n.jsx("p",{children:yo(e.paidBlockedReason)})),E.status==="loading"&&n.jsx("p",{role:"status",children:"Creating and fact-checking your cover letter. Your résumé actions remain available."}),(E.status==="error"||E.status==="warning")&&n.jsxs(n.Fragment,{children:[n.jsx("p",{role:"alert",children:E.error}),ne&&n.jsx("button",{type:"button",onClick:e.onRetryCoverLetter,children:"Try cover letter again · 1 Career Credit"})]}),E.status==="ready"&&n.jsxs(n.Fragment,{children:[n.jsx("h3",{children:"Cover letter ready"}),n.jsx("div",{className:"application-cover-preview",children:E.text.split(/\n{2,}/u).map((w,T)=>n.jsx("p",{children:w},T))}),n.jsxs("div",{className:"application-cover-actions","aria-label":"Cover letter actions",children:[n.jsxs("button",{type:"button",onClick:()=>{U("docx")},children:[n.jsx(qt,{"aria-hidden":"true"}),"Cover DOCX"]}),n.jsxs("button",{type:"button",onClick:()=>{U("pdf")},children:[n.jsx(qt,{"aria-hidden":"true"}),"Cover PDF"]})]})]}),P&&n.jsx("p",{role:"alert",children:P}),(e.onRecoverUnprovableCover||e.paidBlockedReason==="wallet_unreadable"&&e.onRetryUsage)&&n.jsxs("div",{className:"application-recovery-actions",children:[e.paidBlockedReason==="wallet_unreadable"&&e.onRetryUsage&&n.jsx("button",{type:"button",onClick:e.onRetryUsage,children:"Check my Career Credits again"}),e.onRecoverUnprovableCover&&n.jsx("button",{type:"button",onClick:e.onRecoverUnprovableCover,children:"Clear this and carry on"})]})]})]})}const xo=["email","phone","location"],Wr=[{value:"summary",label:"Summary"},{value:"experience",label:"Experience"},{value:"education",label:"Education"},{value:"skills",label:"Skills"},{value:"credentials",label:"Credentials"},{value:"languages",label:"Languages"},{value:"other",label:"Other evidence"}],he={minHeight:44};function or(e){const t=`parsed-contact-${e.field}`,r=e.field==="email"?"email":e.field==="phone"?"tel":"text";return n.jsxs("div",{className:"parsed-review-contact-field",children:[n.jsx("label",{htmlFor:t,children:e.label}),n.jsx("input",{id:t,type:r,"aria-label":e.field==="fullName"?"Full name":e.field==="email"?"Email":e.field==="phone"?"Phone":"Location",value:e.contact.value,autoComplete:e.field==="fullName"?"name":e.field,style:he,onCh
10ange:i=>{const o=i.currentTarget.value,s=e.field==="fullName"||o.trim()&&e.contact.decision==="unreviewed"?"include":e.contact.decision;e.onChange(e.field,{...e.contact,value:o,decision:s})}}),e.optional&&n.jsxs("div",{className:"parsed-review-decision",role:"group","aria-label":`${e.label} decision`,children:[e.contact.decision==="unreviewed"&&n.jsx("span",{className:"parsed-review-decision-hint",children:"Choose Include or Omit"}),n.jsx("button",{type:"button","aria-label":`Include ${e.field}`,"aria-pressed":e.contact.decision==="include",style:he,onClick:()=>e.onChange(e.field,{...e.contact,decision:"include"}),children:"Include"}),n.jsx("button",{type:"button","aria-label":`Omit ${e.field}`,"aria-pressed":e.contact.decision==="omit",style:he,onClick:()=>e.onChange(e.field,{...e.contact,decision:"omit"}),children:"Omit"})]})]})}function Co(e){const[t,r]=d.useState(e.item.value),i=`evidence-correction-${e.item.id}`;return n.jsxs("article",{className:"parsed-review-evidence-item",children:[n.jsx("h3",{children:e.item.label}),n.jsx("p",{children:e.item.value}),n.jsxs("p",{className:"parsed-review-evidence-state",children:["Review: ",e.item.state.replace(/_/g," ")]}),n.jsxs("div",{className:"parsed-review-evidence-actions",children:[n.jsx("button",{type:"button",style:he,onClick:()=>e.onConfirm(e.item.id),children:"Confirm"}),n.jsx("button",{type:"button",style:he,onClick:()=>e.onRemove(e.item.id),children:"Remove"})]}),n.jsxs("details",{children:[n.jsx("summary",{children:"Correct this item"}),n.jsx("label",{htmlFor:i,children:"Corrected value"}),n.jsx("input",{id:i,"aria-label":"Corrected evidence value",value:t,style:he,onChange:o=>r(o.currentTarget.value)}),n.jsx("button",{type:"button",style:he,onClick:()=>e.onCorrect(e.item.id,t),children:"Save correction"})]}),n.jsxs("details",{children:[n.jsx("summary",{children:"Source excerpt"}),n.jsx("blockquote",{children:e.item.sourceExcerpt})]})]})}function jo(e){const[t,r]=d.useState("experience"),[i,o]=d.useState(""),[s,c]=d.useState(""),m=i.trim().length>0&&s.trim().length>0;return n.jsxs("details",{className:"parsed-review-add",children:[n.jsx("summary",{children:"Add missing evidence"}),n.jsx("label",{htmlFor:"new-evidence-section",children:"Section"}),n.jsx("select",{id:"new-evidence-section",value:t,style:he,onChange:h=>r(h.currentTarget.value),children:Wr.map(h=>n.jsx("option",{value:h.value,children:h.label},h.value))}),n.jsx("label",{htmlFor:"new-evidence-label",children:"Label"}),n.jsx("input",{id:"new-evidence-label",value:i,style:he,onChange:h=>o(h.currentTarget.value)}),n.jsx("label",{htmlFor:"new-evidence-value",children:"Evidence"}),n.jsx("textarea",{id:"new-evidence-value",value:s,onChange:h=>c(h.currentTarget.value)}),n.jsx("button",{type:"button",disabled:!m,style:he,onClick:()=>{m&&(e.onAdd({section:t,label:i,value:s}),o(""),c(""))},children:"Add evidence"})]})}function Ro(e){const t=Yt(e.profile)&&!e.busy,r=Rn();return n.jsxs("main",{className:"application-parsed-review parsed-review rise","aria-labelledby":"parsed-review-title",children:[n.jsxs("header",{children:[n.jsx("p",{className:"application-eyebrow",children:"Confirm what we found"}),n.jsx("h1",{id:"parsed-review-title",ref:r,tabIndex:-1,children:"Review your résumé details"}),n.jsx("p",{children:"Confirm or correct the facts that can support this application."})]}),n.jsxs("div",{className:"parsed-review-recovery","aria-live":"polite",children:[e.latestAttemptNotice&&n.jsx("p",{className:"application-credit-note",role:"status",children:e.latestAttemptNotice}),e.blockedReason&&n.jsx("p",{className:"application-credit-note",role:"status",children:wt(e.blockedReason)}),e.blockedReason==="wallet_unreadable"&&e.onRetryUsage&&n.jsx("button",{type:"button",style:he,onClick:e.onRetryUsage,children:"Check my Career Credits again"}),e.blockedReason==="cover_unprovable"&&e.onRecoverUnprovableCover&&n.jsx("button",{type:"button",style:he,onClick:e.onRecoverUnprovableCover,children:"Clear this and carry on"}),e.onBackToResume&&n.jsx("button",{type:"button",style:he,onClick:e.onBackToResume,children:"Back to your résumé"}),e.profile.parseMode==="source_preserving"&&n.jsx("p",{children:"We preserved your readable résumé source because some details could not be structured automatically."}),e.profile.warnings.map(i=>n.jsx("p",{children:i},i))]}),n.jsxs("section",{"aria-labelledby":"parsed-review-contact-title",children:[n.jsx("h2",{id:"parsed-review-contact-title",children:"Contact details"}),e.contactErrors?.length?n.jsxs("div",{role:"alert",children:[n.jsx("p",{children:"Please fix the following before continuing:"}),n.jsx("ul",{children:e.contactErrors.map(i=>n.jsx("li",{children:i},i))})]}):null,n.jsx(or,{field:"fullName",label:"Full name",contact:e.profile.contact.fullName,onChange:e.onContactChange}),xo.map(i=>n.jsx(or,{field:i,label:i[0].toUpperCase()+i.slice(1),contact:e.profile.contact[i],optional:!0,onChange:e.onContactChange},i))]}),n.jsxs("section",{"aria-labelledby":"parsed-review-evidence-title",children:[n.jsx("h2",{id:"parsed-review-evidence-title",children:"Résumé evidence"}),Wr.map(i=>{const o=e.profile.evidence.filter(s=>s.section===i.value);return o.length?n.jsxs("section",{"aria-labelledby":`parsed-review-section-${i.value}`,children:[n.jsx("h2",{id:`parsed-review-section-${i.value}`,children:i.label}),o.map(s=>n.jsx(Co,{item:s,onConfirm:e.onEvidenceConfirm,onCorrect:e.onEvidenceCorrect,onRemove:e.onEvidenceRemove},s.id))]},i.value):null}),n.jsx(jo,{onAdd:e.onEvidenceAdd})]}),e.profile.requirements.length>0&&n.jsxs("section",{"aria-labelledby":"parsed-review-requirements-title",children:[n.jsx("h2",{id:"parsed-review-requirements-title",children:"Job requirements"}),e.profile.requirements.map(i=>n.jsxs("article",{children:[n.jsx("h3",{children:i.kind[0].toUpperCase()+i.kind.slice(1)}),n.jsx("p",{children:i.text}),n.jsxs("details",{children:[n.jsx("summary",{children:"Source excerpt"}),n.jsx("blockquote",{children:i.sourceExcerpt})]})]},i.id))]}),n.jsx("button",{type:"button",disabled:!t,style:he,onClick:e.onContinue,children:"Continue to questions"})]})}const Ao="X-Career-Credit-Outcome",Io="X-Career-Credit-Reference";function un(e,t){return Kt({message:t,creditOutcome:e.headers.get(Ao),requestId:e.headers.get(Io)})}function So(e){const t=typeof e.status=="number"&&bn.has(e.status);return Kt({message:e.message,creditOutcome:t?null:"unconfirmed"})}function ar(e){let t=null,r=null;const i=()=>{t!==null&&e.onElapsed(Math.max(0,e.now()-t))},o=()=>{r!==null&&(e.clearInterval(r),r=null)};return{start(){o(),t=e.now(),e.onElapsed(0),r=e.setInterval(i,e.everyMs??1e3)},anchor(s){t!==null&&(t=e.now()-Math.max(0,s),i())},stop(){o(),i(),t=null}}}function cr(e,t){const r={rewrite:"tailoring",quality:"human_voice",fidelity:"fact_check",companion:"format"},i=new Set((t??[]).map(s=>r[s])),o=s=>{if(i.has(s))return"active";
10const c=e.findLast(m=>r[m.stage]===s);return c?c.outcome==="passed"?"complete":"error":"waiting"};return[{name:"tailoring",status:o("tailoring")},{name:"human_voice",status:o("human_voice")},{name:"fact_check",status:o("fact_check")},{name:"format",status:o("format")}]}function Ft(e){try{e()}catch{}}class Eo extends Error{code="APPLICATION_DRAFT_NOT_SAVED";constructor(){super("The application draft could not be saved, so no request was started"),this.name="ApplicationDraftNotSavedError"}}async function lr(e){let t=!1;try{t=e.persistSnapshot()===!0}catch{t=!1}if(!t)throw new Eo;try{e.onStarted?.()}catch{}return await e.send()}async function To(e){if(e.stopClock(),!!e.responseArrived)try{await e.refetchUsage()}catch{}}function _o(e,t){return e??t}function ko(e){return{...e,phase:e.resumeArtifact?"resume_review":"evidence_questions",ready:!e.resumeArtifact,creditBlocked:!0,error:"Building this tailored résumé needs 1 Career Credit. Sign in or choose a plan to continue."}}function ur(e,t,r){return t==="APPLICATION_REVIEW_REQUIRED"?{...e,phase:"parsed_review",ready:!1,error:r?.trim()||"Review the highlighted résumé details before continuing.",buildFailure:null}:e.resumeArtifact?{...e,phase:"resume_review",ready:!1,error:null,buildFailure:er(t)}:{...e,phase:"evidence_questions",ready:!0,error:null,buildFailure:er(t)}}const No=["resume","posting","target","profile","answers","artifact"],dr=[2e3,3e3,5e3,8e3,12e3],qo=24,mr=[1e3,3e3,8e3],Po=1e4;function Oo(e){return e===408||e===425||e===429?!0:e>=500}function Lo(e,t){return e===200&&t?.kept===!0}function Bo(){const e=globalThis.crypto;if(typeof e?.getRandomValues!="function")return"";const t=e.getRandomValues(new Uint8Array(16));return Array.from(t,r=>r.toString(16).padStart(2,"0")).join("")}function Fo(e){return typeof e!="number"||!Number.isFinite(e)||e<0||e>Cr?null:e}const Uo="Your details changed while that résumé was being built, so it was stopped before it finished. Nothing came back from that attempt, so check your Career Credits below, then build again when you are ready.";function fr(){return"That build was stopped before it finished. We could not confirm what happened to the Career Credit, so check your Career Credits before building again."}function Do(){return"Your résumé is ready to use here. We could not confirm the copy kept in your account, so download it before you leave this page."}function Mo(e){return e==="rewrite"||e==="quality"||e==="fidelity"||e==="companion"?e:null}function $o(e){if(!Array.isArray(e))return[];const t=[];for(const r of e.slice(0,4)){const i=Mo(r);i&&!t.includes(i)&&t.push(i)}return t}function Wo(e,t,r){const i={fullName:{...e.contact.fullName},email:e.contact.email.decision==="include"?{...e.contact.email}:{value:"",decision:"omit"},phone:e.contact.phone.decision==="include"?{...e.contact.phone}:{value:"",decision:"omit"},location:e.contact.location.decision==="include"?{...e.contact.location}:{value:"",decision:"omit"}};return _r({kind:"application_workspace",artifact:{sections:e.sections.map(o=>({heading:o.heading,claims:o.claims.map(s=>({text:Y(s.text,e.contact),...s.generatedText!==void 0?{generatedText:Y(s.generatedText,e.contact)}:{},evidenceIds:[...s.evidenceIds],verification:s.verification,evidenceAppliesTo:s.evidenceAppliesTo}))})),evidence:e.evidence.map(o=>({id:o.id,value:Y(o.value,e.contact),state:o.state,sourceType:o.sourceType}))},contact:i,target:{role:t.role,company:t.company},jobDescription:r})}const Ko=5*1024*1024;async function ht(e){try{return await e.json()}catch{return{}}}const pr={status:"empty",name:"",text:""},Yo={applicantName:"",contactInfo:"",role:"",company:"",industry:"",province:""},Go=["English","French","Hindi","Punjabi","Urdu","Gujarati","Tagalog","Mandarin","Cantonese","Spanish","Arabic","Tamil","Bengali","Farsi"],dn={English:"en-CA",French:"fr-CA",Hindi:"hi-IN",Punjabi:"pa-IN",Urdu:"ur-PK",Gujarati:"gu-IN",Tagalog:"tl-PH",Mandarin:"zh-CN",Cantonese:"zh-HK",Spanish:"es-419",Arabic:"ar-SA",Tamil:"ta-IN",Bengali:"bn-BD",Farsi:"fa-IR"};function Vo(){return Gs()??{mode:"quick",resume:pr,posting:pr,target:Yo,answers:[]}}function zo(e){const t=e.name.toLowerCase();return t.endsWith(".pdf")||t.endsWith(".docx")}function ja(e,t,r){if(r||e.contactInfo)return e;const i=Is(t);return i?{...e,contactInfo:i}:e}function Ra(){const e=d.useRef(Vo()).current,[t,r]=d.useState(e.phase??"intake"),i=Rn(t==="resume_generation"),[o,s]=d.use
10State(e.mode),[c,m]=d.useState(e.resume),[h,P]=d.useState(e.posting),[g,C]=d.useState(e.target),[y,b]=d.useState(e.profile),[E,X]=d.useState(e.answers),u=e.questionSession?.status==="ready"?e.questionSession:null,[U,Z]=d.useState(u?.messages??[]),[oe,ne]=d.useState(u?.question??""),[x,p]=d.useState(u?.questionKind),[ye,_]=d.useState(u?.questionRequirementId),[me,w]=d.useState(u?.questionEvidenceIds??[]),[T,D]=d.useState(u?.suggestions??[]),[L,O]=d.useState(u?.ready??!1),[ke,xe]=d.useState(!!u),[Kr,Yr]=d.useState(0),[Gr,xt]=d.useState(""),[Re,Vr]=d.useState(u?.language??"English"),[be,Ae]=d.useState(!1),[Be,ve]=d.useState(null),[Ce,zr]=d.useState(e.buildFailure??null),[je,ze]=d.useState(e.buildSettlement??null),[An,Qe]=d.useState(!1),[Qo,In]=d.useState(e.resumeArtifact?.resumeText??""),[Q,Sn]=d.useState(e.resumeArtifact??null),[ue,Ie]=d.useState(()=>e.coverLetterState??Ve()),[Ho,Qr]=d.useState([]),[Fe,Gt]=d.useState(e.buildStages??[]),[Hr,Jr]=d.useState(e.resumeCreditResolution),Vt=d.useRef(e.resumeCreditResolution),Se=Hr,at=a=>{Vt.current=a,Jr(a)},[He,Xr]=d.useState(e.attemptId??0),[we,Zr]=d.useState(e.artifactAttemptId??(e.resumeArtifact&&!e.buildFailure?e.attemptId??0:null)),[Je,ei]=d.useState(e.attemptNotice??Ot({buildFailure:e.buildFailure??null,resultKind:e.resumeArtifact&&!e.buildFailure?e.resumeArtifact.resultKind:null,settlement:e.buildSettlement??null})),[Ue,ti]=d.useState(e.buildElapsedMs??null),[ni,zt]=d.useState([]),Ct=d.useRef(null);Ct.current||(Ct.current=gs());const Xe=d.useRef(null);Xe.current||(Xe.current=ar({now:()=>Date.now(),setInterval:(a,l)=>window.setInterval(a,l),clearInterval:a=>window.clearInterval(a),onElapsed:a=>ti(a)}));const[ri,En]=d.useState(null),[ii,Qt]=d.useState(null),ct=d.useRef(null);ct.current||(ct.current=ar({now:()=>Date.now(),setInterval:(a,l)=>typeof window>"u"?0:window.setInterval(a,l),clearInterval:a=>{typeof window<"u"&&window.clearInterval(a)},onElapsed:a=>En(a)}));const Ht={setTimer:(a,l)=>typeof window>"u"?0:window.setTimeout(a,l),clearTimer:a=>{typeof window<"u"&&window.clearTimeout(a)}},Tn=()=>{ct.current?.stop(),En(null)},[si,oi]=d.useState(!1),[_n,lt]=d.useState(!1),jt=d.useRef(null),kn=d.useRef(!1),ae=Gi("build_ai");y?.contact.fullName.value||g.applicantName,y?mn(y):g.contactInfo;const ai={...g},ci=Q?.resultKind==="evidence_only"||Q?.resultKind==="source_recovery";d.useEffect(()=>{ae.exhausted||Qe(!1)},[ae.exhausted]),d.useEffect(()=>{const a=t==="evidence_questions"?ke?{status:"ready",messages:U,question:oe,...x?{questionKind:x}:{},...ye?{questionRequirementId:ye}:{},questionEvidenceIds:me,suggestions:T,ready:L,language:Re}:{status:"refetch"}:void 0;Ge({phase:t,mode:o,resume:c,posting:h,target:g,profile:y,answers:E,resumeArtifact:Q,questionSession:a,buildFailure:Ce,buildSettlement:je,buildStages:Fe,...Ue===null?{}:{buildElapsedMs:Ue},...Se?{resumeCreditResolution:Se}:{},coverLetterState:ue,attemptId:He,artifactAttemptId:we,attemptNotice:Je})},[t,o,c,h,g,y,E,Q,U,oe,x,ye,me,T,L,Re,ke,Ce,je,Fe,Ue,Se,ue,He,we,Je]),d.useEffect(()=>{const a=window.SpeechRecognition??window.webkitSpeechRecognition;if(!a)return;const l=new a;return l.lang=dn[Re]??"en-CA",l.continuous=!1,l.interimResults=!1,l.maxAlternatives=1,l.onresult=f=>{const j=f.results[0]?.[0]?.transcript?.trim();j&&xt(A=>A?`${A} ${j}`:j)},l.onerror=()=>lt(!1),l.onend=()=>lt(!1),jt.current=l,oi(!0),()=>l.abort()},[]),d.useEffect(()=>{jt.current&&(jt.current.lang=dn[Re]??"en-CA")},[Re]),d.useEffect(()=>{e.questionSession?.status!=="refetch"||t!=="evidence_questions"||kn.current||(kn.current=!0,Ke(U,E))},[]),d.useEffect(()=>()=>Xe.current?.stop(),[]),d.useEffect(()=>()=>ct.current?.stop(),[]);const Rt=cr(Fe,ni),Nn=ae.loading===!0||ae.usageUnreadable===!0?null:ae.used??null,At=!!Q&&we===He,qn=!!Q&&!At,li=qn?Be??void 0:void 0,Pn=on({resolution:Se,delivered:At}),It=Pt(ue)==="blocked",St=Rr(ue),Jt=Pn==="blocked",Et={usageLoading:ae.loading===!0,usageUnreadable:ae.usageUnreadable===!0,exhausted:ae.exhausted,busy:be,resumeUnresolved:Jt,coverUnresolved:It,coverUnprovable:St},ut=Ar({...Et,latestSettlement:Pn==="spent"?je:null,resumeResolution:Se,resumeDelivered:At}),Xt=Ir({...Et,coverState:ue}),On=ut===null,ui=Xt===null,Ne=d.useRef({resolution:Se,attemptId:He,artifactAttemptId:we,hasArtifact:!!Q,coverState:ue,settlement:je,gate:Et,walletUsed:Nn,artifact:Q});
10Ne.current={resolution:Vt.current??Se,attemptId:He,artifactAttemptId:we,hasArtifact:!!Q,coverState:ue,settlement:je,gate:Et,walletUsed:Nn,artifact:Q};const ge=a=>{Ne.current={...Ne.current,...a}},$=d.useRef({generation:0,mode:o,resume:c,posting:h,target:g,profile:y,answers:E,messages:U,language:Re,artifact:Q,artifactAttemptId:we,questionSessionId:0,question:oe,questionKind:x,questionRequirementId:ye,questionEvidenceIds:me});$.current={...$.current,mode:o,resume:c,posting:h,target:g,profile:y,answers:E,messages:U,language:Re,artifact:Q,artifactAttemptId:we};const Ee=a=>{const l=$.current,f={...l,...a,generation:l.generation+1};$.current=f,No.some(j=>f[j]!==l[j])&&(mi(),Zt())},De=d.useRef(null),Me=d.useRef(null),Zt=()=>{const a=Me.current;Me.current=null,a?.cancel()},$e=d.useRef({buildFailure:Ce,attemptNotice:Je});$e.current={buildFailure:Ce,attemptNotice:Je};const fe=a=>{$e.current={...$e.current,attemptNotice:a},ei(a)},qe=a=>{$e.current={...$e.current,buildFailure:a},zr(a)},Tt=d.useRef(null),di=()=>{const a=Tt.current;Tt.current=null,We.current=null,kt.current+=1,a?.abort()},mi=()=>{const a=De.current;a&&(De.current=null,a.abort())},Ze=a=>De.current?.token===a,Ln=a=>({...a.target,applicantName:a.profile?.contact.fullName.value||a.target.applicantName,contactInfo:a.profile?mn(a.profile):a.target.contactInfo}),ie=d.useRef(new Set),ce=d.useRef(!0),ee=d.useRef(0),_t=d.useRef(0),kt=d.useRef(0),et=d.useRef(null),Bn=d.useRef(null),dt=d.useRef(!1),tt=d.useRef({resume:null,posting:null}),Fn=a=>{const l=tt.current[a];l&&(tt.current[a]=null,l.abort())},We=d.useRef(null),nt=d.useRef({generation:0,stop:null});d.useEffect(()=>(ce.current=!0,ee.current+=1,()=>{ce.current=!1;for(const a of ie.current)a.abort();ie.current.clear(),nt.current.stop?.(),nt.current.stop=null,Zt()}),[]);const en=[Je,It?ue.error:null,Hn(ut)??Hn(Xt)].filter((a,l,f)=>!!a&&f.indexOf(a)===l).join(" ")||null;function rt(a,l){Ee(a==="resume"?{resume:l}:{posting:l}),a==="resume"?m(l):P(l)}function fi(a,l){const f=Hi($.current.target,a,l);Ee({target:f}),C(f)}async function Un(a,l){if(Fn(a),l.size>Ko){rt(a,{status:"error",name:l.name,text:"",error:"This file is over 5 MB. Choose a smaller PDF or DOCX."});return}if(!zo(l)){rt(a,{status:"error",name:l.name,text:"",error:"Choose a PDF or DOCX file."});return}rt(a,{status:"reading",name:l.name,text:""}),ve(null);const f=new FormData;f.append("file",l);const j=typeof AbortController=="function"?new AbortController:null;j&&ie.current.add(j);const A={},F=ee.current;tt.current[a]={token:A,abort:()=>j?.abort()};const R=()=>ce.current&&F===ee.current&&tt.current[a]?.token===A;try{const{response:q,result:I}=await Ut({send:()=>fetch("/api/resume/extract-text",{method:"POST",body:f,...j?{signal:j.signal}:{}}),read:z=>ht(z),abort:()=>j?.abort(),setTimer:Ht.setTimer,clearTimer:Ht.clearTimer});if(!R())return;if(!q.ok||!I.text||I.text.trim().length<40)throw new Error(I.error??"We could not read enough text from this file.");rt(a,Vn(I.text,a==="resume"?"resume":"job",l.name))}catch(q){if(!R())return;const I=q?.code==="APPLICATION_CLIENT_TIMEOUT";rt(a,{status:"error",name:l.name,text:"",error:I?`Reading ${l.name} took too long, so we stopped waiting. Paste the text instead, or attach the file again.`:q instanceof Error?q.message:"We could not read this file. Paste the text instead."})}finally{j&&ie.current.delete(j),tt.current[a]?.token===A&&(tt.current[a]=null)}}function Dn(a,l){Fn(a),rt(a,Vn(l,a==="resume"?"resume":"job","Pasted text"))}function pi(a){if(a===$.current.language)return;const l=We.current!==null;if(Ee({language:a}),di(),Vr(a),l){const f=$.current;Ke(f.messages,f.answers)}}async function Ke(a,l,f=!1){if(We.current)return;const j={};We.current=j;const A=ee.current;kt.current+=1;const F=kt.current,R=typeof AbortController=="function"?new AbortController:null;R&&ie.current.add(R),Tt.current=R?{abort:()=>R.abort()}:null;const q=()=>ce.current&&A===ee.current&&F===kt.current;Ae(!0),ve(null),xe(!1);try{const I=$.current,z=Us({...f?{finishWithCurrentEvidence:!0}:{},mode:I.mode,messages:a,language:I.language,sourceResume:I.resume.text,jobDescription:I.posting.text,target:I.target,profile:I.profile,answers:l}),G=await fetch("/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(z),...R?{signal:R.signal}:{}});if(G.status===402){if(!q())return;throw await ae.refetch(),new Error("Your Career Credits are used. Sign in or choose a plan to continue.")}const k=await ht(G);if(!G.ok||!k.message){const le=new Error(k.error??"The Career Guide could not reply.");throw le.code=k.code,le}if(!q())return;const te=[...a,{role:"assistant",content:k.message}],B=k.question??k.message,H=k.candidateEvidenceIds??[];Ee({messages:te,answers:l,questionSessionId:$.current.questionSessionId+1,question:B,questionKind:k.kind,questionRequirementId:k.requirementId,questionEvidenceIds:H}),Z(te),ne(B),D(k.suggestions??[]),p(k.kind),_(k.requirementId),w(H),Yr($.current.questionSessionId),O(Ms(k)||o==="quick"&&!Or(l)),xe(!0)}
10catch(I){if(!q())return;const z=I instanceof Error?I:null;if(z?.code==="APPLICATION_REVIEW_REQUIRED"){const G=ur({phase:t,ready:L,error:Be,buildFailure:Ce,resume:c,posting:h,target:g,profile:y,answers:E},z.code,z.message);O(G.ready),qe(G.buildFailure),ve(G.error),fe(G.error),r(G.phase)}else ve(z?.message??"Please try again.")}finally{R&&ie.current.delete(R),We.current===j&&(We.current=null,Tt.current=null),q()&&Ae(!1)}}async function Mn(){if(dt.current)return;dt.current=!0;const a=ee.current;_t.current+=1;const l=_t.current,f=typeof AbortController=="function"?new AbortController:null;et.current?.abort(),et.current=f,f&&ie.current.add(f);const j=()=>ce.current&&a===ee.current&&l===_t.current;ki("chat_started"),Ae(!0),ve(null),Qt(null),ct.current?.start();try{const A=$.current,F=await Ws({phase:t,mode:A.mode,resume:A.resume,posting:A.posting,target:A.target,profile:A.profile,answers:A.answers},(q,I)=>fetch(q,{...I??{},...f?{signal:f.signal}:{}}),Ht);if(!j())return;const R=Ji(wr($.current.target,F.profile),F.profile.jobTarget);if(Ee({profile:F.profile,target:R}),b(F.profile),C(R),!R.role.trim()){r("intake"),Qt("Add the job title you are applying for. We could not read one from this posting.");return}r(F.phase),Pe("application_parse_ready",{mode:A.mode,parse_mode:F.profile.parseMode}),qe(null),Qe(!1),F.phase==="evidence_questions"&&(Z([]),O(!1),xe(!1),await Ke([],$.current.answers))}catch(A){if(!j())return;ve(A instanceof Error?A.message:"We could not prepare your résumé review. Try again.")}finally{f&&ie.current.delete(f),et.current===f&&(et.current=null),j()&&(dt.current=!1,Tn(),Ae(!1))}}const tn=d.useMemo(()=>Xi(c,h),[c,h]);d.useEffect(()=>{t!=="intake"||be||wn({mode:o,resume:c,posting:h,target:$.current.target})&&Bn.current!==tn&&(Bn.current=tn,Mn())},[tn,t,be,o,c,h]);function hi(){if(!dt.current)return;_t.current+=1,dt.current=!1;const a=et.current;et.current=null,a&&(ie.current.delete(a),a.abort()),Tn(),Ae(!1),ve(null),Qt("Review preparation stopped. Your documents are still here. Start again when you are ready.")}function mt(a){const l=$.current.profile;if(!l)return;const f=a(l);Ee({profile:f}),b(f)}function vi(a,l){mt(f=>qr(f,a,l))}function gi(a){mt(l=>Os(l,a))}function yi(a,l){mt(f=>Ls(f,a,l))}function bi(a){mt(l=>Bs(l,a))}function wi(a){mt(l=>Fs(l,a))}async function xi(){!y||be||!Yt(y)||(r("evidence_questions"),Z([]),O(!1),xe(!1),qe(null),Qe(!1),await Ke([],E))}async function $n(){if(be||L&&!Ce)return;xt("");const a=$.current;await Ke(a.messages,a.answers,!0)}async function Ci(a,l){if(We.current||l!==void 0&&l!==$.current.questionSessionId||be||L)return;if(os(a)){await $n();return}xt("");const f=$.current,j=[...f.messages,{role:"user",content:a.trim().slice(0,2e3)}],A={question:f.question,answer:a,...f.questionKind?{kind:f.questionKind}:{},...f.questionRequirementId?{requirementId:f.questionRequirementId}:{},...f.questionEvidenceIds.length?{candidateEvidenceIds:f.questionEvidenceIds}:{}},F=f.mode==="quick"?Ks(f.answers,A):[...f.answers,A].slice(-Mt);Ee({answers:F,messages:j}),X(F),Pe("application_question_answered",{mode:f.mode,question_kind:f.questionKind??"adaptive"}),await Ke(j,F)}function ji(a,l){nt.current.generation+=1;const f=nt.current.generation;let j=null,A=!1,F=null;const R=()=>!A&&ce.current&&l===ee.current&&f===nt.current.generation;let q=0;const I=async()=>{if(j=null,!R()||q>=qo)return;const G=q;q+=1;const k=typeof AbortController=="function"?new AbortController:null;k&&ie.current.add(k),F=k;try{const B=await fetch(`/api/application-workspace/build-progress/${a}`,k?{signal:k.signal}:{});if(!R())return;if(B.ok){const H=await ht(B);if(!R())return;zt($o(H.activeStages)),Gt(Dt(H.stages));const le=Fo(H.elapsedMs);le!==null&&Xe.current?.anchor(le)}}catch{}finally{k&&ie.current.delete(k),F===k&&(F=null)}if(!R())return;const te=dr[Math.min(G,dr.length-1)];j=window.setTimeout(()=>{I()},te)};I();const z=()=>{A||(A=!0,j!==null&&window.clearTimeout(j),j=null,F?.abort(),F=null,ce.current&&l===ee.current&&zt([]))};return nt.current.stop=z,z}function Ri(a){let l=0,f=!1,j=null,A=null;const F={},R=()=>{f=!0,j?.abort(),j=null,A!==null&&window.clearTimeout(A),A=null};Me.current?.cancel(),Me.current={token:F,cancel:R};const q=()=>!f&&ce.current&&a.mountGeneration===ee.current&&Me.current?.token===F&&$.current.artifact===a.artifact&&$.current.artifactAttemptId===a.artifactAttemptId,I=()=>{Me.current?.token===F&&(Me.current=null)},z=()=>{q()&&(fe(Do()),I())},G=async()=>
10{if(A=null,!q())return;l+=1;let k=!1,te=!1;const B=typeof AbortController=="function"?new AbortController:null;B&&ie.current.add(B),j=B;let H=null;try{const M=new Promise((J,se)=>{H=window.setTimeout(()=>{B?.abort(),se(new Error("APPLICATION_ACCEPT_TIMEOUT"))},Po)}),de=(async()=>{const J=await fetch(`/api/application-workspace/build-accepted/${a.buildId}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({receipt:a.receipt,resumeText:a.artifact.resumeText,targetRole:a.targetRole}),...B?{signal:B.signal}:{}});return{status:J.status,body:await ht(J)}})(),V=await Promise.race([de,M]);k=Lo(V.status,V.body),te=!k&&Oo(V.status)}catch{te=!0}finally{H!==null&&window.clearTimeout(H),B&&ie.current.delete(B),j===B&&(j=null)}if(!q())return;if(k){I();return}if(!te||l>mr.length){z();return}const le=mr[l-1];A=window.setTimeout(()=>{G()},le)};G()}async function Wn(){const a=Ct.current?.acquire();if(a)try{const l=$.current;if(!l.profile)return;const f=Ne.current,j=f.hasArtifact&&f.artifactAttemptId===f.attemptId,A=on({resolution:f.resolution,delivered:j});if(A==="blocked"||!fs({...f.gate,resumeUnresolved:!1,latestSettlement:A==="spent"?f.settlement:null,resumeResolution:f.resolution,resumeDelivered:j})||Pt(f.coverState)==="blocked"||f.walletUsed===null)return;const F=f.walletUsed,R=f.attemptId+1;Xr(R),fe(null),at("unresolved"),ge({resolution:"unresolved",attemptId:R}),r("resume_generation"),Ae(!0),ve(null),qe(null),ze(null),Qe(!1),Gt([]),zt([]),Xe.current?.start();let q,I=null,z=!1,G=null,k=null;const te=ee.current,B=typeof AbortController=="function"?new AbortController:null;B&&ie.current.add(B);const H=Bo(),le=H?ji(H,te):null,M={};De.current={token:M,abort:()=>B?.abort()};let de=!1;try{const V=Ds({mode:l.mode,sourceResume:l.resume.text,jobDescription:l.posting.text,profile:l.profile,target:Ln(l),clarifications:l.answers}),{response:J,result:se}=await lr({persistSnapshot:()=>Ge({phase:"resume_generation",mode:l.mode,resume:l.resume,posting:l.posting,target:l.target,profile:l.profile,answers:l.answers,resumeArtifact:Q,buildStages:[],resumeCreditResolution:"unresolved",coverLetterState:ue,attemptId:R,artifactAttemptId:we,attemptNotice:null}),onStarted:()=>{Zt(),Pe("application_resume_generation_started",{mode:o})},send:()=>Ut({send:()=>fetch("/api/application-workspace/finalize",{method:"POST",headers:{"Content-Type":"application/json",...H?{"X-Application-Build-Id":H}:{}},body:JSON.stringify(V),...B?{signal:B.signal}:{}}),read:K=>(z=!0,G=K.status,k=un(K,"Résumé generation failed."),ht(K)),abort:()=>B?.abort(),setTimer:(K,Ye)=>window.setTimeout(K,Ye),clearTimer:K=>window.clearTimeout(K)})});if(le?.(),!ce.current||te!==ee.current)return;if(!Ze(M)){de=!0;const K=$.current,Ye=un(J,se.error??"Résumé generation failed."),nn=sn({responseArrived:!0,status:J.status,settlement:Ye,delivered:!1});at(nn),ge({resolution:nn,settlement:Ye}),ze(Ye),qe(null);const Yn=Ot({buildFailure:null,resultKind:null,settlement:Ye});fe(Yn),ve("Your details changed while that résumé was being built, so it was stopped before it could be finished. Check your Career Credits below, then build again when you are ready."),O(!0);const Gn=K.artifact?"resume_review":"evidence_questions";r(Gn),Ge({phase:Gn,mode:K.mode,resume:K.resume,posting:K.posting,target:K.target,profile:K.profile,answers:K.answers,resumeArtifact:K.artifact,buildSettlement:Ye,resumeCreditResolution:nn,coverLetterState:Ne.current.coverState,attemptId:R,artifactAttemptId:K.artifactAttemptId,attemptNotice:Yn})||fe(pt());return}q=se.code,Gt(Dt(se.stages)),I=un(J,se.error??"Résumé generation failed.");const Nt=Pr(J,se),Te=sn({responseArrived:!0,status:J.status,settlement:I,delivered:!!Nt});if(at(Te),ge({resolution:Te,settlement:I}),J.status===402){const K=ko({phase:t,ready:L,error:Be,creditBlocked:An,resumeArtifact:Q,coverLetterState:ue});Qe(K.creditBlocked),ve(K.error),O(K.ready),r(K.phase);return}const pe=Nt;if(!pe){const K=new Error(se.error??"Résumé generation failed.");throw K.code=se.code,K}Sn(pe),Zr(R),ge({hasArtifact:!0,artifactAttemptId:R,settlement:I,artifact:pe}),Ee({artifact:pe,artifactAttemptId:R});const re=se.saveReceipt,ft=typeof re=="string"&&re?re:null;H&&ft&&Ri({buildId:H,receipt:ft,artifact:pe,targetRole:V.target.role,artifactAttemptId:R,mountGeneration:te}),In(pe.resumeText),ze(I),fe(Ot({buildFailure:null,resultKind:pe.resultKind,settlement:I}
10)),Ie(Ve()),Ft(()=>Pe("application_resume_generation_result",{result_kind:pe.resultKind,credit_outcome:ws(I)})),Qr([]),pe.resultKind==="tailored"&&Ft(()=>Ni("chat")),r("resume_review"),Ge({phase:"resume_review",mode:l.mode,resume:l.resume,posting:l.posting,target:l.target,profile:l.profile,answers:l.answers,resumeArtifact:pe,buildStages:Dt(se.stages),buildSettlement:I,resumeCreditResolution:Te,coverLetterState:Ve(),attemptId:R,artifactAttemptId:R})||fe(pt())}catch(V){if(!ce.current||te!==ee.current)return;if(!Ze(M)){de=!0;const re=$.current,ft=re.artifact?"resume_review":"evidence_questions";qe(null),ze(null),fe(fr()),ve(Uo),O(!0),r(ft),Ge({phase:ft,mode:re.mode,resume:re.resume,posting:re.posting,target:re.target,profile:re.profile,answers:re.answers,resumeArtifact:re.artifact,resumeCreditResolution:"unresolved",coverLetterState:Ne.current.coverState,attemptId:R,artifactAttemptId:re.artifactAttemptId,attemptNotice:fr()})||fe(pt());return}const J=V instanceof Error?V:null;if(J?.code==="APPLICATION_DRAFT_NOT_SAVED"){const re=Qn();at("unsent"),ge({resolution:"unsent"}),ze(re.settlement),qe(null),fe(null),ve(re.error),O(!0),r(Q?"resume_review":"evidence_questions");return}if(G!==null){const re=sn({responseArrived:!0,status:G,settlement:k,delivered:!1});at(re),ge({resolution:re,settlement:k})}const se=J?.kind==="credits",Nt=_o(J?.code,q),Te=ur({phase:t,ready:L,error:Be,buildFailure:Ce,resume:l.resume,posting:l.posting,target:l.target,profile:l.profile,answers:l.answers,resumeArtifact:Q,coverLetterState:ue},Nt);Qe(se),qe(se?null:Te.buildFailure);const pe=se?null:I??k??So({message:J?.message??"Résumé generation failed."});ze(pe),ge({settlement:pe}),fe(se?null:Ot({buildFailure:Te.buildFailure,resultKind:null,settlement:pe})),ve(se?J?.message??"Your Career Credits are used. Sign in or choose a plan to continue.":Te.error),O(Te.ready),r(Te.phase)}finally{B&&ie.current.delete(B),le?.(),Ze(M)&&(De.current=null),await To({responseArrived:z&&!de&&ce.current&&te===ee.current,stopClock:()=>{ce.current&&te===ee.current&&Xe.current?.stop()},refetchUsage:async()=>{await ae.refetch()}}),ce.current&&te===ee.current&&Ae(!1)}}finally{a.release()}}async function Kn(a){const l=Ct.current?.acquire();if(l)try{if(!Q)return;const f=Ne.current;if(a!==void 0&&a!==f.artifactAttemptId)return;const j=$.current,A=j.artifact;if(!A)return;const F=f.hasArtifact&&f.artifactAttemptId===f.attemptId;if(on({resolution:f.resolution,delivered:F})==="blocked"||Pt(f.coverState)==="blocked"||!ps({...f.gate,coverUnresolved:Pt(f.coverState)==="blocked",coverState:f.coverState})||f.walletUsed===null)return;const R={creditsUsedBeforeCover:f.walletUsed};Ae(!0);const q=typeof AbortController=="function"?new AbortController:null;q&&ie.current.add(q);const I=ee.current;let z=null,G=null;const k=le=>{const M=$.current,de=Ne.current,V=Vt.current??de.resolution;return Ge({phase:"resume_review",mode:M.mode,resume:M.resume,posting:M.posting,target:M.target,profile:M.profile,answers:M.answers,resumeArtifact:M.artifact,buildFailure:$e.current.buildFailure,buildSettlement:de.settlement,coverLetterState:le,attemptId:de.attemptId,artifactAttemptId:M.artifactAttemptId,attemptNotice:$e.current.attemptNotice,...V?{resumeCreditResolution:V}:{}})},te=Ss(R);Ie(te),ge({coverState:te});const B={};De.current={token:B,abort:()=>q?.abort()};let H=!1;try{const{result:le}=await lr({persistSnapshot:()=>Ge({phase:"resume_review",mode:j.mode,resume:j.resume,posting:j.posting,target:j.target,profile:j.profile,answers:j.answers,resumeArtifact:A,buildFailure:Ce,buildSettlement:je,coverLetterState:te,attemptId:He,artifactAttemptId:we,attemptNotice:Je,...Se?{resumeCreditResolution:Se}:{}}),send:()=>Ut({send:()=>fetch("/api/generate-cover-letter",{...Ns(Wo(A,Ln(j),j.posting.text)),...q?{signal:q.signal}:{}}),read:V=>{const J=_s(V);return z=J.status,G=J.settlement,ks(V)},abort:()=>q?.abort(),setTimer:(V,J)=>window.setTimeout(V,J),clearTimer:V=>window.clearTimeout(V)})});if(!ce.current||I!==ee.current)return;if(!Ze(B)){H=!0;const V={...cn(z??500,{},G),creditsUsedBeforeCover:R.creditsUsedBeforeCover,status:"error",error:"You edited your résumé while that cover letter was being written, so it was stopped. Check your Career Credits, then ask for a new letter when you are ready."};Ie(V),ge({coverState:V}),k(V)||fe(pt());return}
10const M={...cn(z??500,le,G),creditsUsedBeforeCover:R.creditsUsedBeforeCover};Ie(M),ge({coverState:M});const de=M.status==="ready"?"success":M.errorCode==="COVER_LETTER_CREDITS_REQUIRED"?"credits_required":M.errorCode==="COVER_LETTER_FACT_CHECK_REJECTED"?"fact_check_rejected":M.status==="warning"?"warning":"failed";Ft(()=>Pe("application_cover_result",{status:de,credit_outcome:M.creditOutcome}))}catch(le){if(!ce.current||I!==ee.current)return;if(!Ze(B)){H=!0;const de={...Xn(),error:"You edited your résumé while that cover letter was being written, so it was stopped before it could finish. We could not confirm what happened to the Career Credit, so check your balance before asking for a new letter.",creditsUsedBeforeCover:R.creditsUsedBeforeCover};Ie(de),ge({coverState:de}),k(de)||fe(pt());return}const M=le?.code==="APPLICATION_DRAFT_NOT_SAVED"?{...Ve(),status:"error",error:Qn().error}:z!==null?{...cn(z,{},G),creditsUsedBeforeCover:R.creditsUsedBeforeCover}:{...Xn(),creditsUsedBeforeCover:R.creditsUsedBeforeCover};Ie(M),ge({coverState:M}),Ft(()=>Pe("application_cover_result",{status:"failed",credit_outcome:M.creditOutcome}))}finally{if(q&&ie.current.delete(q),Ze(B)&&(De.current=null),ce.current&&I===ee.current){if(!H)try{await ae.refetch()}catch{}Ae(!1)}}}finally{l.release()}}function Ai(){const a=jt.current;if(a){if(_n){a.stop(),lt(!1);return}try{a.start(),lt(!0)}catch{lt(!1)}}}function Ii(){if(!("speechSynthesis"in window))return;window.speechSynthesis.cancel();const a=new SpeechSynthesisUtterance(oe);a.lang=dn[Re]??"en-CA",window.speechSynthesis.speak(a)}const Si=be?`Preparing your résumé review. ${fn(ri??0)} elapsed`:Be??ii,Ei=!be&&!!Be;return n.jsxs("div",{className:"application-shell",children:[n.jsx(qi,{}),t==="intake"&&n.jsx(ro,{resume:c,posting:h,target:g,mode:o,busy:be,statusMessage:Si,statusIsError:Ei,onCancel:hi,onAttachResume:a=>{Un("resume",a)},onAttachPosting:a=>{Un("posting",a)},onPasteResume:a=>Dn("resume",a),onPastePosting:a=>Dn("posting",a),onTargetChange:fi,onModeChange:s,onStart:()=>{Mn()}}),t==="parsed_review"&&y&&n.jsx(Ro,{profile:y,busy:be,latestAttemptNotice:en??void 0,blockedReason:ut,onRetryUsage:()=>{ae.refetch()},...St?{onRecoverUnprovableCover:()=>Ie(an(ue))}:{},...Q?{onBackToResume:()=>r("resume_review")}:{},contactErrors:kr(y),onContactChange:vi,onEvidenceConfirm:gi,onEvidenceCorrect:yi,onEvidenceRemove:bi,onEvidenceAdd:wi,onContinue:()=>{xi()}}),t==="evidence_questions"&&n.jsxs(n.Fragment,{children:[ae.exhausted&&n.jsx("div",{className:"application-upgrade",children:n.jsx(Yi,{})}),n.jsx(Zs,{mode:o,question:oe,questionKind:x,suggestions:T,answers:E,ready:L,questionAuthoritative:ke,blockedReason:ut,onRetryUsage:()=>{ae.refetch()},...St?{onRecoverUnprovableCover:()=>Ie(an(ue))}:{},creditNotice:en??void 0,loading:be,error:Be,buildFailure:Ce,settlement:je,creditBlocked:ae.exhausted||An||Jt||It,input:Gr,resumeSummary:`${c.name}: ${c.text.slice(0,180)}...`,postingSummary:`${h.name}: ${h.text.slice(0,180)}...`,stages:Rt,buildStages:Fe,buildElapsedMs:Ue??void 0,language:Re,languages:Go,speechSupported:si,listening:_n,onInputChange:xt,onSubmit:a=>{Ci(a,Kr)},onBuild:()=>{Wn()},onRestoreQuestion:()=>{const a=$.current;Ke(a.messages,a.answers)},onFinishWithCurrentEvidence:()=>{$n()},onLanguageChange:pi,onToggleListening:Ai,onReadQuestion:Ii})]}),t==="resume_generation"&&n.jsxs("main",{className:"application-working rise","aria-labelledby":"application-generation-title",children:[n.jsx("h1",{id:"application-generation-title",ref:i,tabIndex:-1,children:"Building your tailored résumé"}),n.jsx(it,{stages:Rt,expanded:!0,elapsedMs:Ue??void 0,stageTimings:Fe})]}),t==="resume_review"&&Q&&n.jsxs(n.Fragment,{children:[At?ci?n.jsx(it,{stages:Rt,expanded:!0,recoveryKind:Q.resultKind,settlement:je,elapsedMs:Ue??void 0,stageTimings:Fe}):n.jsx(it,{stages:Rt,expanded:!0,heading:"What these checks did",expectation:null,elapsedMs:Ue??void 0,stageTimings:Fe}):n.jsx(it,{stages:cr([]),expanded:!0,heading:"Your preserved résumé",expectation:null}),n.jsx(wo,{artifact:Q,targetRole:ai.role,templateId:"newcomer-professional",coverState:ue,settlement:je,unresolvedCredit:Jt||It,latestAttemptFailed:qn,latestAttemptNotice:en??void 0,latestFailureReason:li,paidResumeAllowed:On,paidCoverAllowed:ui,paidBlockedReason:Xt??void 0,resumeBlockedReason:ut??void 0,onRetryUsage:()=>{ae.refetch()},...St?{onRecoverUnprovableCover:()=>Ie(an(ue))}:{},onCreateCoverLetter:()=>{Kn(we)},onRetryCoverLetter:()=>{Kn(we)},...On?{onRetryResume:()=>{Wn()}}:{},onBackToEvidence:()=>
10{const a=vs({buildFailure:Ce,settlement:je});a.creditNotice&&fe(a.creditNotice),r(a.phase)},onArtifactChange:a=>{Ee({artifact:a}),ge({artifact:a}),Sn(a),In(a.resumeText)}})]})]})}export{mr as APPLICATION_ACCEPT_RETRY_MS,Po as APPLICATION_ACCEPT_TIMEOUT_MS,qo as APPLICATION_PROGRESS_MAX_READS,dr as APPLICATION_PROGRESS_POLL_SCHEDULE_MS,Uo as APPLICATION_STOPPED_BUILD_MESSAGE,Eo as ApplicationDraftNotSavedError,No as PAID_APPLICATION_CONTEXT_FIELDS,Lo as applicationAcceptConfirmed,Oo as applicationAcceptRetryable,ko as applicationBuildCreditRecovery,_o as applicationBuildRecoveryCode,fr as applicationStoppedBuildNotice,ja as applicationTargetWithExtractedContact,cr as applicationTeamStages,Do as applicationUnconfirmedCopyNotice,Bo as createApplicationBuildId,ar as createApplicationElapsedTicker,Wo as createOptionalCoverLetterRequest,Ra as default,To as finishApplicationBuildTiming,$o as readApplicationActiveStages,Mo as readApplicationBuildStage,Fo as readApplicationProgressElapsed,un as readCareerCreditSettlement,ur as recoverApplicationBuild,Ft as reportPaidResult,lr as startApplicationBuildRequest,So as transportFailureSettlement};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.