import{r as e}from"./norm-CeclA1Tu.js";import{t}from"./csv-BkYNeWrG.js";import{cloudFavoritesPull as n}from"./cloudFavorites-BzoE_TYU.js";var r=e=>String(e).padStart(2,`0`),i=()=>{let e=new Date;return`${e.getFullYear()}${r(e.getMonth()+1)}${r(e.getDate())}`},a=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)},o=async r=>{let o=(()=>{let e=r?.items;return Array.isArray(e)&&e.length?e:[]})(),s=o.length?o:await(async()=>{let t=new Set((r?.jobIds||[]).map(t=>e(t)).filter(Boolean)),i=``,a=[];for(let t=0;t<30;t++){let t=await n(i,500),r=Array.isArray(t.items)?t.items:[];if(!r.length||(a.push(...r),i=e(t.cursor)||i,r.length<500))break}let o=new Map;for(let t of a){let n=e(t?.jobId||t?.id);n&&o.set(n,t)}return Array.from(o.values()).filter(n=>!n?.deleted&&(!t.size||t.has(e(n?.jobId)))).map(t=>({jobId:e(t?.jobId),title:e(t?.title),company:e(t?.company),url:e(t?.url),updatedAt:e(t?.updatedAt),platform:e(t?.platform)||`import`,location:e(t?.location),salaryText:e(t?.salary_text||t?.salaryText),experience:e(t?.experience),education:e(t?.education),description:e(t?.description)}))})();if(!s.length)throw Error(`云端暂无可导出收藏`);let c=t(s.map(t=>({title:e(t.title),company:e(t.company),platform:e(t.platform)||`import`,url:e(t.url),location:e(t.location),salary_text:e(t.salaryText),experience:e(t.experience),education:e(t.education),description:e(t.description)})),[`title`,`company`,`platform`,`url`,`location`,`salary_text`,`experience`,`education`,`description`],{title:`岗位名称`,company:`公司`,platform:`平台`,url:`职位链接`,location:`地点`,salary_text:`薪资`,experience:`经验`,education:`学历`,description:`职位描述`}),l=r?.fileName,u=l&&e(l)?e(l).replace(/\.xlsx$/i,`.csv`):`岗位数据_${i()}.csv`;a(new Blob([c],{type:`text/csv;charset=utf-8`}),u)};export{o as exportCloudFavoritesXlsx};