let A=null;function T(n){let l="",r=n;for(;r>0;){const i=(r-1)%26;l=String.fromCharCode(65+i)+l,r=Math.floor((r-1)/26)}return l}function I(n){const l=[",",";","	","|"],r=n.split(`
`).slice(0,20).filter(c=>c.trim()!=="");if(r.length===0)return",";if(r.length===1){const c=r[0];for(const t of l)if(c.includes(t))return t;return","}const i=[];for(const c of l){const t=[];let d=!0;for(const h of r)try{const u=M(h,c);t.push(u.length)}catch{d=!1;break}if(!d||t.length===0)continue;const m=t.reduce((h,u)=>h+u,0)/t.length;if(m<2)continue;const a=t.reduce((h,u)=>h+Math.pow(u-m,2),0)/t.length,v=a===0?1e3:m/Math.sqrt(a),F=Math.min(m/2,10),g=v*F;i.push({delimiter:c,columnCounts:t,avgColumns:m,variance:a,parseSuccess:d,score:g})}return i.length===0?",":(i.sort((c,t)=>{if(Math.abs(c.score-t.score)<.1){const d=[",",";","	","|"];return d.indexOf(c.delimiter)-d.indexOf(t.delimiter)}return t.score-c.score}),i[0].delimiter)}function M(n,l=","){const r=[];let i="",c=!1;for(let t=0;t<n.length;t++){const d=n[t],m=n[t+1];d==='"'?c&&m==='"'?(i+='"',t++):c=!c:d===l&&!c?(r.push(i),i=""):i+=d}return r.push(i),r}function k(n){const l=n.trim(),r=/^(\d{2})\/(\d{2})\/(\d{4})$/,i=l.match(r);if(i){const[,t,d,m]=i,a=new Date(parseInt(m),parseInt(d)-1,parseInt(t));if(a.getFullYear()===parseInt(m)&&a.getMonth()===parseInt(d)-1&&a.getDate()===parseInt(t))return{value:a,type:"d"}}const c=Number(l);if(l!==""&&!isNaN(c)&&isFinite(c)){const t=parseFloat(l);if(t>=100&&t<=1e5){const d=new Date(Date.UTC(1899,11,31)),m=1440*60*1e3,a=t>60?t-1:t;return{value:new Date(d.getTime()+a*m),type:"d"}}return{value:t,type:"n"}}return{value:l,type:"s"}}function z(n){return typeof n!="number"?!1:n>=100&&n<=1e5}function j(n){const l=new Date(Date.UTC(1899,11,31)),r=1440*60*1e3,i=n>60?n-1:n;return new Date(l.getTime()+i*r)}function E(n,l=!1){const r={0:"FF000000",1:"FFFFFFFF",2:"FF44546A",3:"FFE7E6E6",4:"FF4472C4",5:"FFED7D31",6:"FFA5A5A5",7:"FFFFC000",8:"FF5B9BD5",9:"FF70AD47"};return n===1&&!l?"FF000000":r[n]}self.addEventListener("message",async n=>{const l=n.data;if(l.type==="parse")try{A||(A=await import("./exceljs.min-Yejzm3hp.js").then(function(a){return a.e}));const{arrayBuffer:r,filename:i}=l,c=i.toLowerCase().endsWith(".csv"),t=new A.Workbook;if(c){const v=new TextDecoder("utf-8").decode(r),F=I(v),g=v.split(`
`).filter(u=>u.trim()!==""),h=t.addWorksheet("Sheet1");g.forEach((u,x)=>{M(u,F).forEach((e,p)=>{const D=h.getCell(x+1,p+1),w=k(e);D.value=w.value})})}else{const a=r.byteLength/1048576;await t.xlsx.load(r),t.model&&t.model.themes}const d=[];t.eachSheet((a,v)=>{const F=a.name;d.push(F);const g={},h={s:{r:0,c:0},e:{r:0,c:0}};if(a.eachRow((u,x)=>{const b=x-1;b>h.e.r&&(h.e.r=b),u.eachCell({includeEmpty:!1},(e,p)=>{const D=p-1;D>h.e.c&&(h.e.c=D);const w=T(p)+x;let o=e.value,C;o&&typeof o=="object"&&(o.result!==void 0?o=o.result:o.richText&&Array.isArray(o.richText)?o=o.richText.map(s=>s.text||"").join(""):o.text!==void 0?o=o.text:o.hyperlink!==void 0?o=o.text||o.hyperlink:o.error!==void 0?o=o.error:o.sharedFormula!==void 0||o.formula!==void 0?o=e.result!==void 0?e.result:"":(console.warn(`[Worker] Unknown cell value type in ${w}:`,o),o="")),e.formula?C=e.formula:e.value&&typeof e.value=="object"&&e.value.formula?C=e.value.formula:e.value&&typeof e.value=="object"&&e.value.sharedFormula&&(C=e.value.sharedFormula);const y={v:o,t:"s"};if(C&&(y.f=C),e.numFmt&&(y.z=e.numFmt),o==null||o===""?y.t="z":o instanceof Date?y.t="d":typeof o=="number"?z(o)?(y.v=j(o),y.t="d"):y.t="n":typeof o=="boolean"&&(y.t="b"),e.style){const s={};if(e.style.font&&(s.font={name:e.style.font.name,sz:e.style.font.size,bold:e.style.font.bold,italic:e.style.font.italic,underline:e.style.font.underline,strike:e.style.font.strike},e.style.font.color)){if(e.style.font.color.argb)s.font.color={rgb:e.style.font.color.argb};else if(e.style.font.color.theme!==void 0){const f=E(e.style.font.color.theme,!1);f?s.font.color={rgb:f}:s.font.color={theme:e.style.font.color.theme}}}if(e.style.fill&&(s.fill={},e.style.fill.type==="pattern"&&(s.fill.patternType=e.style.fill.pattern,e.style.fill.pattern!=="none"))){if(e.style.fill.fgColor){if(e.style.fill.fgColor.argb)s.fill.fgColor={rgb:e.style.fill.fgColor.argb};else if(e.style.fill.fgColor.theme!==void 0){const f=E(e.style.fill.fgColor.theme,!0);f?s.fill.fgColor={rgb:f}:s.fill.fgColor={theme:e.style.fill.fgColor.theme}}}if(e.style.fill.bgColor){if(e.style.fill.bgColor.argb)s.fill.bgColor={rgb:e.style.fill.bgColor.argb};else if(e.style.fill.bgColor.theme!==void 0){const f=E(e.style.fill.bgColor.theme,!0);f?s.fill.bgColor={rgb:f}:s.fill.bgColor={theme:e.style.fill.bgColor.theme}}}}e.style.border&&(s.border={},["top","left","bottom","right"].forEach(f=>{if(e.style.border[f]&&(s.border[f]={style:e.style.border[f].style},e.style.border[f].color)){if(e.style.border[f].color.argb)s.border[f].color={rgb:e.style.border[f].color.argb};else if(e.style.border[f].color.theme!==void 0){const S=E(e.style.border[f].color.theme,!1);S?s.border[f].color={rgb:S}:s.border[f].color={theme:e.style.border[f].color.theme}}}})),e.style.alignment&&(s.alignment={horizontal:e.style.alignment.horizontal,vertical:e.style.alignment.vertical,wrapText:e.style.alignment.wrapText,textRotation:e.style.alignment.textRotation,indent:e.style.alignment.indent}),y.s=s}g[w]=y})}),g["!ref"]=`A1:${T(h.e.c+1)}${h.e.r+1}`,a.model&&a.model.merges&&Array.isArray(a.model.merges)){const u=[];a.model.merges.forEach(x=>{const b=x.split(":");if(b.length===2){const e=b[0].match(/^([A-Z]+)(\d+)$/),p=b[1].match(/^([A-Z]+)(\d+)$/);if(e&&p){const D=e[1].split("").reduce((y,s)=>y*26+s.charCodeAt(0)-65,0),w=p[1].split("").reduce((y,s)=>y*26+s.charCodeAt(0)-65,0),o=parseInt(e[2])-1,C=parseInt(p[2])-1;u.push({s:{r:o,c:D},e:{r:C,c:w}})}}}),u.length>0&&(g["!merges"]=u)}self.postMessage({type:"sheet-data",sheetName:F,sheetData:g})});const m={type:"success",sheetNames:d};self.postMessage(m)}catch(r){console.error("[Worker] Error parsing spreadsheet:",r);const i={type:"error",error:r instanceof Error?r.message:"Unknown error parsing spreadsheet"};self.postMessage(i)}});
//# sourceMappingURL=spreadsheet.worker-DjNfu0H2.js.map
