import{__awaiter as r,__generator as t}from'./../../../ext-esm/tslib/tslib.es6.js';import{jsx as e}from"react/jsx-runtime";import{useState as o,useEffect as s}from"react";import{getFileExtension as n}from"../../../utils/fileExtension.js";import{TextViewer as i}from"../components/TextViewer.js";import{CsvViewer as f}from"../components/CsvViewer.js";import{PdfViewer as m}from"../components/PdfViewer.js";import{FILE_EXTENSIONS as c}from"../constants.js";import{getCsvData as l,getTextData as a,getXlsxData as u}from"../utils.js";var p,j,x=((p={})[c.csv]=f,p[c.json]=i,p[c.txt]=i,p[c.pdf]=m,p[c.xlsx]=f,p),v=((j={})[c.csv]=l,j[c.json]=a,j[c.txt]=a,j[c.xlsx]=u,j),d=function(i){var f=i.fileUrl,m=i.fileName,c=n(m),l=o(""),a=l[0],u=l[1],p=o(!1),j=p[0],d=p[1],b=x[c];return s((function(){f&&c&&function(e,o){r(void 0,void 0,void 0,(function(){var r,s,n;return t(this,(function(t){switch(t.label){case 0:if(!(r=v[o]))return[2];t.label=1;case 1:return t.trys.push([1,3,4,5]),d(!0),[4,r(e)];case 2:return s=t.sent(),u(s),[3,5];case 3:return n=t.sent(),console.error(n),[3,5];case 4:return d(!1),[7];case 5:return[2]}}))}))}(f,c)}),[f,c]),s((function(){f||u("")}),[f]),{fileContent:e(b,{fileData:a,fileUrl:f,fileName:m}),isLoading:j}};export{d as useFileContent};
