1import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{S as t}from"./react-C9KpI4k0.js";import{n}from"./i18n-BDsE02CT.js";import{n as r}from"./ToastContext-DpaFneyt.js";import{t as i}from"./useBridge-BTPLwljJ.js";import"./bridge-CuDW457F.js";var a=e(t(),1),o=`whisperly:export-started`,s={ropa_controller:`ROPA controllers`,ropa_processor:`ROPA processors`,tom:`TOMs`,risk:`Risks`,asset:`Assets`,data_breach:`Data breaches`,external_recipient:`External recipients`,va_report_pdf:`Service provider report`,va_report_docx:`Service provider report`,va_questionnaire:`Service provider questionnaire`,ia_report_pdf:`Internal audit report`,ia_report_docx:`Internal audit report`,rfp:`RFP`,email_traffic:`Email traffic`,nda_signatures:`NDA signatures`,vendors:`AI vendors`,outsourced_activity_pdf:`Service assessment`,outsourced_activity_xlsx:`Service assessment`,outsourced_activity_docx:`Service assessment`};function c(e){return e?s[e]??e.replace(/_/g,` `):`Export`}function l(e,t,n){let r=n?.replace(/\.[^./\\]+$/,``).trim();return t?.trim()||r||c(e)}var u=3e3,d=2e4,f=360*60*1e3;function p(e,t,n){if(e===`pending`||e===`started`||!t)return!1;let r=Date.parse(t);return Number.isFinite(r)&&n-r>f}function m(e){return e&&`${e.firstName} ${e.lastName}`.trim()||null}function h(e){let t=document.createElement(`a`);t.href=e,t.rel=`noopener`,document.body.appendChild(t),t.click(),t.remove()}function g(){let e=i(),{t}=n(`common`),{showToast:s}=r(),[c,f]=(0,a.useState)([]),g=(0,a.useRef)(new Set),_=(0,a.useCallback)(async n=>{try{let{downloadUrl:t}=await e.send(`getExportDownloadUrl`,{taskId:n});h(t)}catch{s(t(`toast.exportFailed`),`error`)}},[e,s,t]),v=(0,a.useCallback)(async()=>{let t;try{t=await e.send(`listExportTasks`,void 0)}catch{return}let n=[],r=Date.now();for(let e of t){if(g.current.has(e.taskId)||p(e.status,e.createdAt,r))continue;let t=e.payload??{},i={taskId:e.taskId,resource:l(t.exportKey,t.recordName,e.result?.filename),count:t.ids?.length??null,format:(t.format??`csv`).toUpperCase(),userName:m(e.user),createdAt:e.createdAt??null,errorMessage:null,warnings:[]};e.status===`pending`||e.status===`started`?n.push({...i,status:`processing`}):e.status===`success`?n.push({...i,status:`ready`,warnings:[...new Set(e.result?.warnings??[])]}):n.push({...i,status:`failed`,errorMessage:e.result?.error??null})}f(n)},[e]),y=(0,a.useRef)(c);y.current=c;let b=(0,a.useRef)(v);b.current=v,(0,a.useEffect)(()=>{let e=!1,t,n=0,r=async i=>{if(e||i!==n||(await b.current(),e||i!==n))return;let a=y.current.some(e=>e.status===`processing`);t=setTimeout(()=>r(i),a?u:d)},i=()=>{clearTimeout(t),n+=1,r(n)};return r(n),window.addEventListener(o,i),()=>{e=!0,clearTimeout(t),window.removeEventListener(o,i)}},[]);let x=(0,a.useCallback)(e=>{g.current.add(e),f(t=>t.filter(t=>t.taskId!==e))},[]),S=(0,a.useCallback)(async t=>{x(t);try{await e.send(`dismissExtractionTask`,{taskId:t})}catch{}},[e,x]);return{items:c,downloadItem:_,dismissItem:S,dismissAll:(0,a.useCallback)(()=>{y.current.filter(e=>e.status!==`processing`).forEach(e=>{S(e.taskId)})},[S]),deleteItem:(0,a.useCallback)(async n=>{x(n);try{await e.send(`deleteExportTask`,{taskId:n})}catch{s(t(`toast.exportFailed`),`error`)}},[e,x,s,t])}}export{g as n,o as t};
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.