const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/exportJobsXlsx-BBWHgh7o.js","assets/db-Cn_z-BCk.js","assets/chunk-B3pr0VN8.js","assets/csv-BkYNeWrG.js","assets/exportCloudFavoritesXlsx-B2279QHj.js","assets/norm-CeclA1Tu.js","assets/appConfig-CuVl6yRs.js","assets/cloudFavorites-BzoE_TYU.js","assets/preload-helper-Dd-HcVz_.js","assets/authSession-CrP9lMPq.js"])))=>i.map(i=>d[i]);
import{i as e}from"./chunk-B3pr0VN8.js";import{n as t,t as n}from"./jsx-runtime-wTfS3W87.js";import{t as r}from"./preload-helper-Dd-HcVz_.js";import{r as i}from"./chunk-6CSD65Y2-Dj7xjS5D.js";import{a,l as o,n as s}from"./toolRuntime-wpPmOqkC.js";import{a as c,n as l,o as u,t as d}from"./ToolSidebarNav-ydI_X_Ab.js";import{n as f}from"./useToolRunState-lqkZz3ea.js";import{t as p}from"./ToolRunStatus-sSVJghbX.js";import{n as m,t as h}from"./useRestoredFieldsHighlight-C1fpbsAB.js";var g=e(t(),1),_=n(),v=()=>r(()=>import(`./exportJobsXlsx-BBWHgh7o.js`),__vite__mapDeps([0,1,2,3])),y=()=>r(()=>import(`./exportCloudFavoritesXlsx-B2279QHj.js`),__vite__mapDeps([4,3,5,6,2,7,8,9]));function b(){let[e,t]=(0,g.useState)(!1),[n,r]=(0,g.useState)(``),{runState:b,progress:x,setProgress:S,start:C,done:w,setRunState:T}=f(),[E,D]=(0,g.useState)(``),{restoredFields:O,setRestoredFields:k}=h(),[A,j]=(0,g.useState)(``),M=(0,g.useRef)(null),N=(0,g.useRef)(null),P=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=c(`export`);if(e&&typeof e==`object`){String(e.msg||``).trim()&&r(String(e.msg));let n=String(e.focus||``).trim();(n===`local`||n===`cloud`)&&j(n);let i=String(e.runState||``).trim();Number.isFinite(Number(e.progress))&&S(Number(e.progress)),i===`running`&&(t(!0),T(`running`)),i===`done`&&w(),i===`failed`&&T(`failed`),i===`cancelled`&&T(`cancelled`)}let n={msg:``,progress:-1};P.current=window.setInterval(()=>{let e=c(`export`);if(!e||typeof e!=`object`)return;let i=String(e.runState||``).trim(),a=String(e.msg||``).trim(),o=Number(e.progress);if(a!==n.msg&&(n.msg=a,r(a)),Number.isFinite(o)&&o!==n.progress&&(n.progress=o,S(o)),i===`done`&&(w(),t(!1)),i===`failed`&&(T(`failed`),t(!1)),i===`cancelled`&&(T(`cancelled`),t(!1)),i!==`running`){try{P.current&&window.clearInterval(P.current)}catch{}P.current=null}},600);let i=new URLSearchParams(window.location.search),o=String(i.get(`focus`)||``).trim(),s=String(i.get(`rid`)||``).trim();if(s){let e=a(s,`导出`);e&&typeof e==`object`&&String(e?.msg||``).trim()&&(r(String(e.msg)),D(`已恢复历史记录 ${s.slice(-6)}`),k([`导出提示`]))}(o===`local`||o===`cloud`)&&j(o);let l=o===`cloud`?N.current:o===`local`?M.current:null;if(l)return window.setTimeout(()=>{try{l.scrollIntoView({behavior:`smooth`,block:`start`})}catch{}},80),()=>{try{P.current&&window.clearInterval(P.current)}catch{}P.current=null}},[]);let F=async(n,i,a)=>{if(!e){t(!0),C(),r(``),u(`export`,{runState:`running`,progress:0,msg:``,focus:a});try{await n();let e=`已开始导出（如浏览器下载被拦截，请检查下载设置/弹窗拦截）。`;r(e),w(),u(`export`,{runState:`done`,progress:100,msg:e,focus:a});let t=`export_${Date.now()}_${Math.random().toString(16).slice(2,8)}`;await o({id:t,toolType:`导出`,title:i,score:`已触发下载`,createdAt:Date.now(),deepLink:s(`/tools/export`,a,{rid:t})},{msg:e,focus:a})}catch(e){T(`failed`);let t=String(e?.message||`导出失败`);r(t),u(`export`,{runState:`failed`,msg:t,focus:a})}finally{t(!1)}}};return(0,_.jsx)(l,{title:`导出`,subTitle:`把岗位库与云端收藏导出为文件，便于备份与迁移。`,sidebar:(0,_.jsx)(d,{current:`/tools/export`}),children:(0,_.jsxs)(`div`,{className:`he-tools-main`,children:[(0,_.jsxs)(`div`,{className:`he-grid`,children:[(0,_.jsx)(`div`,{className:`he-grid-1`,children:(0,_.jsxs)(`div`,{className:[`he-split-card`,A===`local`?`he-restored-focus`:``].join(` `),ref:M,children:[(0,_.jsx)(`div`,{className:`he-split-head`,children:(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`he-tool-title`,children:`导出岗位库（本机）`}),(0,_.jsx)(`div`,{className:`he-muted`,children:`导出当前浏览器本机保存的岗位数据为 CSV。`}),(0,_.jsx)(m,{restoredHint:A===`local`?E:``,restoredFields:A===`local`?O:[]})]})}),(0,_.jsx)(`div`,{className:`he-split-body`,children:(0,_.jsx)(`div`,{className:`he-actions`,children:(0,_.jsx)(`button`,{type:`button`,className:`btn-primary`,disabled:e,onClick:()=>F(async()=>{let{exportAllJobsXlsx:e}=await v();await e()},`导出岗位库（本机）`,`local`),children:e?`导出中…`:`导出岗位 CSV`})})})]})}),(0,_.jsx)(`div`,{className:`he-grid-1`,children:(0,_.jsxs)(`div`,{className:[`he-split-card`,A===`cloud`?`he-restored-focus`:``].join(` `),ref:N,children:[(0,_.jsx)(`div`,{className:`he-split-head`,children:(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`he-tool-title`,children:`导出云端收藏`}),(0,_.jsx)(`div`,{className:`he-muted`,children:`导出已同步到云端的收藏（需要登录）。`}),(0,_.jsx)(m,{restoredHint:A===`cloud`?E:``,restoredFields:A===`cloud`?O:[]})]})}),(0,_.jsx)(`div`,{className:`he-split-body`,children:(0,_.jsxs)(`div`,{className:`he-actions`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn-primary`,disabled:e,onClick:()=>F(async()=>{let{exportCloudFavoritesXlsx:e}=await y();await e()},`导出云端收藏`,`cloud`),children:e?`导出中…`:`导出收藏 CSV`}),(0,_.jsx)(i,{className:`btn-secondary`,to:`/me`,children:`去个人中心`})]})})]})})]}),(0,_.jsx)(p,{state:b,progress:x}),(0,_.jsx)(m,{runState:b,nextTo:`/me`}),n?(0,_.jsx)(`div`,{className:[n.includes(`失败`)?`he-err`:`he-ok`,O.includes(`导出提示`)?`he-restored-field`:``].join(` `),style:{marginTop:14},children:n}):null]})})}export{b as default};