!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).readXlsxFile=e()}(this,(function(){"use strict";var r={createDocument:function(r){return(new DOMParser).parseFromString(r.trim(),"text/xml")}},e=Uint8Array,t=Uint16Array,n=Uint32Array,o=new e([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),i=new e([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),u=new e([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),a=function(r,e){for(var o=new t(31),i=0;i<31;++i)o[i]=e+=1<>>1|(21845&y)<<1;m=(61680&(m=(52428&m)>>>2|(13107&m)<<2))>>>4|(3855&m)<<4,p[y]=((65280&m)>>>8|(255&m)<<8)>>>1}var b=function(r,e,n){for(var o=r.length,i=0,u=new t(e);i>>f]=c}else for(a=new t(o),i=0;i>>15-r[i]);return a},v=new e(288);for(y=0;y<144;++y)v[y]=8;for(y=144;y<256;++y)v[y]=9;for(y=256;y<280;++y)v[y]=7;for(y=280;y<288;++y)v[y]=8;var d=new e(32);for(y=0;y<32;++y)d[y]=5;var h=b(v,9,1),g=b(d,5,1),w=function(r){for(var e=r[0],t=1;te&&(e=r[t]);return e},O=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(7&e)&t},S=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(7&e)},j=function(r,o,i){(null==o||o<0)&&(o=0),(null==i||i>r.length)&&(i=r.length);var u=new(2==r.BYTES_PER_ELEMENT?t:4==r.BYTES_PER_ELEMENT?n:e)(i-o);return u.set(r.subarray(o,i)),u},P=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],E=function(r,e,t){var n=new Error(e||P[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,E),!t)throw n;return n},A=function(r,t,n){var a=r.length;if(!a||n&&n.f&&!n.l)return t||new e(0);var l=!t||n,c=!n||n.i;n||(n={}),t||(t=new e(3*a));var p=function(r){var n=t.length;if(r>n){var o=new e(Math.max(2*n,r));o.set(t),t=o}},y=n.f||0,m=n.p||0,v=n.b||0,d=n.l,P=n.d,A=n.m,C=n.n,x=8*a;do{if(!d){y=O(r,m,1);var I=O(r,m+1,3);if(m+=3,!I){var N=r[(B=4+((m+7)/8|0))-4]|r[B-3]<<8,k=B+N;if(k>a){c&&E(0);break}l&&p(v+N),t.set(r.subarray(B,k),v),n.b=v+=N,n.p=m=8*k,n.f=y;continue}if(1==I)d=h,P=g,A=9,C=5;else if(2==I){var T=O(r,m,31)+257,D=O(r,m+10,15)+4,F=T+O(r,m+5,31)+1;m+=14;for(var V=new e(F),_=new e(19),M=0;M>>4)<16)V[M++]=B;else{var q=0,X=0;for(16==B?(X=3+O(r,m,3),m+=2,q=V[M-1]):17==B?(X=3+O(r,m,7),m+=3):18==B&&(X=11+O(r,m,127),m+=7);X--;)V[M++]=q}}var z=V.subarray(0,T),G=V.subarray(T);A=w(z),C=w(G),d=b(z,A,1),P=b(G,C,1)}else E(1);if(m>x){c&&E(0);break}}l&&p(v+131072);for(var Y=(1<>>4;if((m+=15&q)>x){c&&E(0);break}if(q||E(2),J<256)t[v++]=J;else{if(256==J){H=m,d=null;break}var K=J-254;if(J>264){var Q=o[M=J-257];K=O(r,m,(1<>>4;Z||E(3),m+=15&Z;G=s[rr];if(rr>3){Q=i[rr];G+=S(r,m)&(1<x){c&&E(0);break}l&&p(v+131072);for(var er=v+K;v>>0},N=function(r,e){return I(r,e)+4294967296*I(r,e+4)};function k(r,e){return A(r,e)}var T="undefined"!=typeof TextDecoder&&new TextDecoder;try{T.decode(C,{stream:!0}),1}catch(r){}var D=function(r){for(var e="",t=0;;){var n=r[t++],o=(n>127)+(n>223)+(n>239);if(t+o>r.length)return[e,j(r,t-1)];o?3==o?(n=((15&n)<<18|(63&r[t++])<<12|(63&r[t++])<<6|63&r[t++])-65536,e+=String.fromCharCode(55296|n>>10,56320|1023&n)):e+=1&o?String.fromCharCode((31&n)<<6|63&r[t++]):String.fromCharCode((15&n)<<12|(63&r[t++])<<6|63&r[t++]):e+=String.fromCharCode(n)}};function F(r,e){if(e){for(var t="",n=0;n65558)&&E(13);var i=x(r,o+8);if(!i)return{};var u=I(r,o+16),a=4294967295==u||65535==i;if(a){var l=I(r,o-12);(a=101075792==I(r,l))&&(i=I(r,l+32),u=I(r,l+48))}for(var f=t&&t.filter,c=0;c"}function z(r){var e,t,n=r.documentElement;return e=function(r){var e=R(r,"t");if(e)return e.textContent;var t="";return B(r,"r",(function(r){t+=R(r,"t").textContent})),t},t=[],B(n,"si",(function(r,n){t.push(e(r,n))})),t}function G(r,e){var t=e.createDocument(r),n={},o=R(t.documentElement,"workbookPr");o&&"1"===o.getAttribute("date1904")&&(n.epoch1904=!0),n.sheets=[];return function(r){return $(R(r.documentElement,"sheets"),"sheet")}(t).forEach((function(r){r.getAttribute("name")&&n.sheets.push({id:r.getAttribute("sheetId"),name:r.getAttribute("name"),relationId:r.getAttribute("r:id")})})),n}function Y(r,e){var t=e.createDocument(r),n={sheets:{},sharedStrings:void 0,styles:void 0};return function(r){return $(r.documentElement,"Relationship")}(t).forEach((function(r){var e=r.getAttribute("Target");switch(r.getAttribute("Type")){case"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles":n.styles=W(e);break;case"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings":n.sharedStrings=W(e);break;case"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet":n.sheets[r.getAttribute("Id")]=W(e)}})),n}function W(r){return"/"===r[0]?r.slice(1):"xl/"+r}function H(r){return H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},H(r)}function J(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.push.apply(t,n)}return t}function K(r){for(var e=1;e=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function or(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t=0||t.dateFormat&&n.numberFormat.template===t.dateFormat||!1!==t.smartDateParser&&n.numberFormat.template&&function(r){for(var e,t=nr((r=(r=(r=r.toLowerCase()).replace(ar,"")).replace(lr,"")).split(/\W+/));!(e=t()).done;){var n=e.value;if(fr.indexOf(n)<0)return!1}return!0}(n.numberFormat.template))return!0}}var ur=[14,15,16,17,18,19,20,21,22,27,30,36,45,46,47,50,57],ar=/^\[\$-414\]/,lr=/;@$/;var fr=["ss","mm","h","hh","am","pm","d","dd","m","mm","mmm","mmmm","yy","yyyy","e"];function cr(r,e,t){var n=t.getInlineStringValue,o=t.getInlineStringXml,i=t.getStyleId,u=t.styles,a=t.values,l=t.properties,f=t.options;switch(e||(e="n"),e){case"str":r=sr(r,f);break;case"inlineStr":if(void 0===(r=n()))throw new Error('Unsupported "inline string" cell value structure: '.concat(o()));r=sr(r,f);break;case"s":var c=Number(r);if(isNaN(c))throw new Error('Invalid "shared" string index: '.concat(r));if(c>=a.length)throw new Error('An out-of-bounds "shared" string index: '.concat(r));r=sr(r=a[c],f);break;case"b":if("1"===r)r=!0;else{if("0"!==r)throw new Error('Unsupported "boolean" cell value: '.concat(r));r=!1}break;case"z":r=void 0;break;case"e":r=function(r){switch(r){case 0:return"#NULL!";case 7:return"#DIV/0!";case 15:return"#VALUE!";case 23:return"#REF!";case 29:return"#NAME?";case 36:return"#NUM!";case 42:return"#N/A";case 43:return"#GETTING_DATA";default:return"#ERROR_".concat(r)}}(r);break;case"d":if(void 0===r)break;var s=new Date(r);if(isNaN(s.valueOf()))throw new Error('Unsupported "date" cell value: '.concat(r));r=s;break;case"n":if(void 0===r)break;r=ir(i(),u,f)?tr(r=pr(r),l):(f.parseNumber||pr)(r);break;default:throw new TypeError("Cell type not supported: ".concat(e))}return void 0===r&&(r=null),r}function sr(r,e){return!1!==e.trim&&(r=r.trim()),""===r&&(r=void 0),r}function pr(r){var e=Number(r);if(isNaN(e))throw new Error('Invalid "numeric" cell value: '.concat(r));return e}var yr=["","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function mr(r){for(var e=0,t=0;tr.length)&&(e=r.length);for(var t=0,n=new Array(e);t=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Sr(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Pr(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);tr.length)&&(e=r.length);for(var t=0,n=new Array(e);t=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(n);!(s=p()).done;){var y=s.value,m=y.row-1,b=y.column-1;b1&&void 0!==arguments[1]?arguments[1]:{},t=e.rowIndexMap,n=e.accessor,o=void 0===n?function(r){return r}:n,i=e.onlyTrimAtTheEnd,u=r.length-1;u>=0;){for(var a,l=!0,f=Or(r[u]);!(a=f()).done;)if(null!==o(a.value)){l=!1;break}if(l)r.splice(u,1),t&&t.splice(u,1);else if(i)break;u--}return r}(function(r){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=e.accessor,n=void 0===t?function(r){return r}:t,o=e.onlyTrimAtTheEnd,i=r[0].length-1;i>=0;){for(var u,a=!0,l=jr(r);!(u=l()).done;)if(null!==n(u.value[i])){a=!1;break}if(a)for(var f=0;f=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function kr(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t2&&void 0!==arguments[2]?arguments[2]:{};t.sheet||(t=Dr({sheet:1},t));var n=function(e){if(!r[e])throw new Error('"'.concat(e,'" file not found inside the *.xlsx file zip archive'));return r[e]},o=Y(n("xl/_rels/workbook.xml.rels"),e),i=o.sharedStrings?function(r,e){return r?z(e.createDocument(r)):[]}(n(o.sharedStrings),e):[],u=o.styles?Z(n(o.styles),e):{},a=G(n("xl/workbook.xml"),e);if(t.getSheets)return a.sheets.map((function(r){return{name:r.name}}));var l=function(r,e){if("number"==typeof r){var t=e[r-1];return t&&t.relationId}for(var n,o=Nr(e);!(n=o()).done;){var i=n.value;if(i.name===r)return i.relationId}}(t.sheet,a.sheets);if(!l||!o.sheets[l])throw function(r,e){var t=e&&e.map((function(r,e){return'"'.concat(r.name,'" (#').concat(e+1,")")})).join(", ");return new Error("Sheet ".concat("number"==typeof r?"#"+r:'"'+r+'"'," not found in the *.xlsx file.").concat(e?" Available sheets: "+t+".":""))}(t.sheet,a.sheets);var f=function(r,e,t,n,o,i){var u=e.createDocument(r),a=dr(u,0,t,n,o,i),l=wr(u)||function(r){var e=function(r,e){return r-e},t=r.map((function(r){return r.row})).sort(e),n=r.map((function(r){return r.column})).sort(e),o=t[0],i=t[t.length-1];return[{row:o,column:n[0]},{row:i,column:n[n.length-1]}]}(a);return{cells:a,dimensions:l}}(n(o.sheets[l]),e,i,u,a,t),c=xr(f,t=Dr({rowMap:[]},t));return t.properties?{data:c,properties:a}:c}function _r(r){return _r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},_r(r)}function Mr(r,e){for(var t=0;tr.length)&&(e=r.length);for(var t=0,n=new Array(e);t=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(l);!(s=p()).done;){var y=s.value;y.row=i[y.row-1]+1}return{rows:a,errors:l}}function ne(r,e,t,n,o,i,u){for(var a={},l=!0,f=function(e){var n=e.column,o=e.value,i=e.error,u=e.reason,a={error:i,row:t+1,column:n,value:o};return u&&(a.reason=u),r[n].type&&(a.type=r[n].type),a},c=[],s=function(){var s,m,b,v,d=y[p],h=r[d],g="object"===Hr(h.type)&&!Array.isArray(h.type),w="".concat(n||"",".").concat(h.prop),O=o.indexOf(d),S=O<0;if(S||(s=e[O]),g)m=ne(h.type,e,t,w,o,i,u);else if(S)m=u.schemaPropertyValueForMissingColumn;else if(void 0===s)m=u.schemaPropertyValueForUndefinedCellValue;else if(null===s)m=u.schemaPropertyValueForNullCellValue;else if(Array.isArray(h.type)){var j=function(r,e){var t=[],n=0;for(;n2&&void 0!==arguments[2]?arguments[2]:{},n=t.includeNullValues,o=t.ignoreEmptyRows,i=t.isColumnOriented,u=t.rowMap,a={schemaPropertyValueForMissingColumn:void 0,schemaPropertyValueForUndefinedCellValue:void 0,schemaPropertyValueForNullCellValue:void 0,schemaPropertyShouldSkipRequiredValidationForMissingColumn:function(r,e){return e.path,!1},getEmptyObjectValue:function(r,e){return e.path?void 0:null},getEmptyArrayValue:function(){return null},arrayValueSeparator:","};n&&(a.schemaPropertyValueForMissingColumn=null,a.schemaPropertyValueForUndefinedCellValue=null,a.schemaPropertyValueForNullCellValue=null,a.getEmptyObjectValue=function(r,e){return e.path,null});var l=te(r,e,se(se({},a),{},{rowIndexMap:u,isColumnOriented:i}));return!1!==o&&(l.rows=l.rows.filter((function(r){return r!==a.getEmptyObjectValue(r,{path:void 0})}))),l}function me(r){return me="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},me(r)}var be=["schemaPropertyValueForEmptyCell"];function ve(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.push.apply(t,n)}return t}function de(r){for(var e=1;e=0||(o[t]=r[t]);return o}(r,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(r,t)&&(o[t]=r[t])}return o}function we(r){return we="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},we(r)}function Oe(r){for(var e={},t=0,n=Object.keys(r);t=0||(o[t]=r[t]);return o}(r,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(r,t)&&(o[t]=r[t])}return o}function xe(r,e,t){var n=t.schema,o=t.map,i=Ce(t,je);!n&&o&&(n=Oe(o));var u=Vr(r,e,Ee(Ee({},i),{},{properties:n||i.properties}));return n?function(r,e,t){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=n.schemaPropertyValueForEmptyCell;return r(e,t,de(de({},ge(n,be)),{},{schemaPropertyValueForNullCellValue:o}))}(ye,u.data,n,Ee(Ee({},i),{},{properties:u.properties})):u}return function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(t=e,t instanceof File||t instanceof Blob?t.arrayBuffer().then(U):U(t)).then((function(e){return xe(e,r,n)}))}}));