@mertdeveci55/univer-import-export
Version:
Excel/CSV import and export library for Univer spreadsheets with full format preservation
1 lines • 158 kB
JavaScript
"use strict";var nanoid=require("nanoid"),Papa=require("papaparse"),dayjs=require("dayjs"),JSZip=require("@progress/jszip-esm"),XLSX=require("xlsx"),exceljs=require("@zwight/exceljs");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var l=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,l.get?l:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var Papa__default=_interopDefaultLegacy(Papa),dayjs__default=_interopDefaultLegacy(dayjs),JSZip__default=_interopDefaultLegacy(JSZip),XLSX__namespace=_interopNamespace(XLSX),exceljs__default=_interopDefaultLegacy(exceljs);const debug_log=(...e)=>{console.log&&console.log(...e)},debug_warn=(...e)=>{console.warn&&console.warn(...e)},debug_error=(...e)=>{console.error&&console.error(...e)},columeHeader_word=["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"],columeHeader_word_index={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25},coreFile="docProps/core.xml",stylesFile="xl/styles.xml";let numFmtDefault={0:"General",1:"0",2:"0.00",3:"#,##0",4:"#,##0.00",9:"0%",10:"0.00%",11:"0.00E+00",12:"# ?/?",13:"# ??/??",14:"yyyy/m/d",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"yyyy/m/d h:mm",37:"#,##0 ;(#,##0)",38:"#,##0 ;[Red](#,##0)",39:"#,##0.00;(#,##0.00)",40:"#,##0.00;[Red](#,##0.00)",45:"mm:ss",46:"[h]:mm:ss",47:"mmss.0",48:"##0.0E+0",49:"@"};const indexedColors={0:"00000000",1:"00FFFFFF",2:"00FF0000",3:"0000FF00",4:"000000FF",5:"00FFFF00",6:"00FF00FF",7:"0000FFFF",8:"00000000",9:"00FFFFFF",10:"00FF0000",11:"0000FF00",12:"000000FF",13:"00FFFF00",14:"00FF00FF",15:"0000FFFF",16:"00800000",17:"00008000",18:"00000080",19:"00808000",20:"00800080",21:"00008080",22:"00C0C0C0",23:"00808080",24:"009999FF",25:"00993366",26:"00FFFFCC",27:"00CCFFFF",28:"00660066",29:"00FF8080",30:"000066CC",31:"00CCCCFF",32:"00000080",33:"00FF00FF",34:"00FFFF00",35:"0000FFFF",36:"00800080",37:"00800000",38:"00008080",39:"000000FF",40:"0000CCFF",41:"00CCFFFF",42:"00CCFFCC",43:"00FFFF99",44:"0099CCFF",45:"00FF99CC",46:"00CC99FF",47:"00FFCC99",48:"003366FF",49:"0033CCCC",50:"0099CC00",51:"00FFCC00",52:"00FF9900",53:"00FF6600",54:"00666699",55:"00969696",56:"00003366",57:"00339966",58:"00003300",59:"00333300",60:"00993300",61:"00993366",62:"00333399",63:"00333333",64:null,65:null},borderTypes={none:0,thin:1,hair:2,dotted:3,dashed:4,dashDot:5,dashDotDot:6,double:7,medium:8,mediumDashed:9,mediumDashDot:10,mediumDashDotDot:11,slantDashDot:12,thick:13};let numFmtDefaultMap={"yyyy/m/d;@":"yyyy/MM/dd","yyyy"\u5e74"m"\u6708"d"\u65e5";@":"yyyy"\u5e74"MM"\u6708"dd"\u65e5"","[$-409]yyyy/m/d\\ h:mm\\ AM/PM;@":"yyyy/MM/dd hh:mm AM/PM"};const fontFamilys={0:"defualt",1:"Roman",2:"Swiss",3:"Modern",4:"Script",5:"Decorative"},DATA_VERIFICATION_MAP={list:"dropdown",whole:"number_integer",decimal:"number_decimal",custom:"text_content",textLength:"text_length",date:"date",unknown1:"number",unknown2:"checkbox",unknown3:"validity"},COMMON_TYPE2=["number","number_integer","number_decimal","text_length"],DATA_VERIFICATION_TYPE2_MAP={common:{between:"bw",notBetween:"nb",equal:"eq",notEqualTo:"ne",moreThanThe:"gt",lessThan:"lt",greaterOrEqualTo:"gte",lessThanOrEqualTo:"lte"},text_content:{include:"include",exclude:"exclude",equal:"equal"},date:{between:"bw",notBetween:"nb",equal:"eq",notEqualTo:"ne",earlierThan:"bf",noEarlierThan:"nbf",laterThan:"af",noLaterThan:"naf"},validity:{card:"card",phone:"phone"}};var ChartAttributeBits,ChartTypeBits,LabelContentType;function getcellrange(e){let t=e.split("!"),r="";if(t.length>1?(t[0],r=t[1]):r=t[0],-1==r.indexOf(":")){let e=parseInt(r.replace(/[^0-9]/g,""))-1,t=ABCatNum(r.replace(/[^A-Za-z]/g,""));return isNaN(e)||isNaN(t)?null:{row:[e,e],column:[t,t]}}{let e=r.split(":"),t=[],l=[];return t[0]=parseInt(e[0].replace(/[^0-9]/g,""))-1,t[1]=parseInt(e[1].replace(/[^0-9]/g,""))-1,t[0]>t[1]?null:(l[0]=ABCatNum(e[0].replace(/[^A-Za-z]/g,"")),l[1]=ABCatNum(e[1].replace(/[^A-Za-z]/g,"")),l[0]>l[1]?null:{row:t,column:l})}}function ABCatNum(e){let t=(e=e.toUpperCase()).length;if(0==t)return NaN;let r=e.split(""),l=columeHeader_word.length,n=0;for(let e=t-1;e>=0;e--)n+=e==t-1?columeHeader_word_index[r[e]]:Math.pow(l,t-e-1)*(columeHeader_word_index[r[e]]+1);return n}function chatatABC(e){let t=columeHeader_word.length;if(e<t)return columeHeader_word[e];{let r=0,l="",n=1,a=0;for(;e>=t/(t-1)*(Math.pow(t,n++)-1);)a=n;r=e-t/(t-1)*(Math.pow(t,a-1)-1)+1;for(let e=a;e>0;e--){let n=r;if(1==e)return n%=t,0==n&&(n=26),l+columeHeader_word[n-1];n=Math.ceil(n/Math.pow(t,e-1)),l+=columeHeader_word[n-1],e>1&&(r-=(n-1)*t)}}}function getPxByEMUs(e){return null==e?0:e/914400*72/.75}function getXmlAttibute(e,t,r){let l=e[t];return l=null==l?r:l,l}function getColumnWidthPixel(e){return Math.round(8*(e-.83)+5)}function getRowHeightPixel(e){return Math.round(e/.75)}function hexToRgbArray(e){var t=e.toLowerCase();if(t&&/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(t)){if(4===t.length){for(var r="#",l=1;l<4;l+=1)r+=t.slice(l,l+1).concat(t.slice(l,l+1));t=r}var n=[];for(l=1;l<7;l+=2)n.push(parseInt("0x"+t.slice(l,l+2)));return n}return null}function generateRandomIndex(e){null==e&&(e="Sheet");let t=navigator.userAgent.replace(/[^a-zA-Z0-9]/g,"").split(""),r="";for(let e=0;e<5;e++)r+=t[Math.round(Math.random()*(t.length-1))];return e+"_"+r+"_"+(new Date).getTime()}function escapeCharacter(e){return null==e||0==e.length?e:e.replace(/&/g,"&").replace(/"/g,'"').replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ").replace(/'/g,"'").replace(/¡/g,"\xa1").replace(/¢/g,"\xa2").replace(/£/g,"\xa3").replace(/¤/g,"\xa4").replace(/¥/g,"\xa5").replace(/¦/g,"\xa6").replace(/§/g,"\xa7").replace(/¨/g,"\xa8").replace(/©/g,"\xa9").replace(/ª/g,"\xaa").replace(/«/g,"\xab").replace(/¬/g,"\xac").replace(/­/g,"\xad").replace(/®/g,"\xae").replace(/¯/g,"\xaf").replace(/°/g,"\xb0").replace(/±/g,"\xb1").replace(/²/g,"\xb2").replace(/³/g,"\xb3").replace(/´/g,"\xb4").replace(/µ/g,"\xb5").replace(/¶/g,"\xb6").replace(/·/g,"\xb7").replace(/¸/g,"\xb8").replace(/¹/g,"\xb9").replace(/º/g,"\xba").replace(/»/g,"\xbb").replace(/¼/g,"\xbc").replace(/½/g,"\xbd").replace(/¾/g,"\xbe").replace(/¿/g,"\xbf").replace(/×/g,"\xd7").replace(/÷/g,"\xf7").replace(/À/g,"\xc0").replace(/Á/g,"\xc1").replace(/Â/g,"\xc2").replace(/Ã/g,"\xc3").replace(/Ä/g,"\xc4").replace(/Å/g,"\xc5").replace(/Æ/g,"\xc6").replace(/Ç/g,"\xc7").replace(/È/g,"\xc8").replace(/É/g,"\xc9").replace(/Ê/g,"\xca").replace(/Ë/g,"\xcb").replace(/Ì/g,"\xcc").replace(/Í/g,"\xcd").replace(/Î/g,"\xce").replace(/Ï/g,"\xcf").replace(/Ð/g,"\xd0").replace(/Ñ/g,"\xd1").replace(/Ò/g,"\xd2").replace(/Ó/g,"\xd3").replace(/Ô/g,"\xd4").replace(/Õ/g,"\xd5").replace(/Ö/g,"\xd6").replace(/Ø/g,"\xd8").replace(/Ù/g,"\xd9").replace(/Ú/g,"\xda").replace(/Û/g,"\xdb").replace(/Ü/g,"\xdc").replace(/Ý/g,"\xdd").replace(/Þ/g,"\xde").replace(/ß/g,"\xdf").replace(/à/g,"\xe0").replace(/á/g,"\xe1").replace(/â/g,"\xe2").replace(/ã/g,"\xe3").replace(/ä/g,"\xe4").replace(/å/g,"\xe5").replace(/æ/g,"\xe6").replace(/ç/g,"\xe7").replace(/è/g,"\xe8").replace(/é/g,"\xe9").replace(/ê/g,"\xea").replace(/ë/g,"\xeb").replace(/ì/g,"\xec").replace(/í/g,"\xed").replace(/î/g,"\xee").replace(/ï/g,"\xef").replace(/ð/g,"\xf0").replace(/ñ/g,"\xf1").replace(/ò/g,"\xf2").replace(/ó/g,"\xf3").replace(/ô/g,"\xf4").replace(/õ/g,"\xf5").replace(/ö/g,"\xf6").replace(/ø/g,"\xf8").replace(/ù/g,"\xf9").replace(/ú/g,"\xfa").replace(/û/g,"\xfb").replace(/ü/g,"\xfc").replace(/ý/g,"\xfd").replace(/þ/g,"\xfe").replace(/ÿ/g,"\xff")}!function(e){e[e.Stack=1073741824]="Stack",e[e.PercentStack=1610612736]="PercentStack",e[e.Horizontal=268435456]="Horizontal"}(ChartAttributeBits||(ChartAttributeBits={})),function(e){e[e.None=0]="None",e[e.Line=2]="Line",e[e.Column=4]="Column",e[e.ColumnStacked=1073741828]="ColumnStacked",e[e.ColumnPercentStacked=1610612740]="ColumnPercentStacked",e[e.Bar=268435460]="Bar",e[e.BarStacked=1342177284]="BarStacked",e[e.BarPercentStacked=1879048196]="BarPercentStacked",e[e.Pie=8]="Pie",e[e.Doughnut=264]="Doughnut",e[e.Area=16]="Area",e[e.AreaStacked=1073741840]="AreaStacked",e[e.AreaPercentStacked=1610612752]="AreaPercentStacked",e[e.Radar=32]="Radar",e[e.Scatter=64]="Scatter",e[e.Combination=128]="Combination"}(ChartTypeBits||(ChartTypeBits={})),function(e){e[e.Empty=0]="Empty",e[e.CategoryName=2]="CategoryName",e[e.SeriesName=4]="SeriesName",e[e.Value=8]="Value",e[e.Percentage=16]="Percentage"}(LabelContentType||(LabelContentType={}));class fromulaRef{static trim(e){return null==e&&(e=""),e.replace(/(^\s*)|(\s*$)/g,"")}static functionCopy(e,t,r){let l=this;if(null==l.operatorjson){let e=l.operator.split("|"),t={};for(let r=0;r<e.length;r++)t[e[r].toString()]=1;l.operatorjson=t}null==t&&(t="down"),null==r&&(r=1),"="==e.substr(0,1)&&(e=e.substr(1));let n=e.split(""),a=0,o="",i="",s={bracket:0,comma:0,squote:0,dquote:0};for(;a<n.length;){let e=n[a];if("("==e&&0==s.dquote)s.bracket+=1,o.length>0?i+=o+"(":i+="(",o="";else if(")"==e&&0==s.dquote)s.bracket-=1,i+=l.functionCopy(o,t,r)+")",o="";else if('"'==e&&0==s.squote)s.dquote>0?(i+=o+'"',s.dquote-=1,o=""):(s.dquote+=1,o+='"');else if(","==e&&0==s.dquote)i+=l.functionCopy(o,t,r)+",",o="";else if("&"==e&&0==s.dquote)o.length>0?(i+=l.functionCopy(o,t,r)+"&",o=""):i+="&";else if(e in l.operatorjson&&0==s.dquote){let s="";a+1<n.length&&(s=n[a+1]);let u=a-1,c=null;if(u>=0)do{c=n[u--]}while(u>=0&&" "==c);e+s in l.operatorjson?(o.length>0?(i+=l.functionCopy(o,t,r)+e+s,o=""):i+=e+s,a++):/[^0-9]/.test(s)||"-"!=e||"("!=c&&null!=c&&","!=c&&" "!=c&&!(c in l.operatorjson)?o.length>0?(i+=l.functionCopy(o,t,r)+e,o=""):i+=e:o+=e}else o+=e;a==n.length-1&&(l.iscelldata(l.trim(o))?"down"==t?i+=l.downparam(l.trim(o),r):"up"==t?i+=l.upparam(l.trim(o),r):"left"==t?i+=l.leftparam(l.trim(o),r):"right"==t&&(i+=l.rightparam(l.trim(o),r)):i+=l.trim(o)),a++}return i}static downparam(e,t){return this.updateparam("d",e,t)}static upparam(e,t){return this.updateparam("u",e,t)}static leftparam(e,t){return this.updateparam("l",e,t)}static rightparam(e,t){return this.updateparam("r",e,t)}static updateparam(e,t,r){let l,n=this,a=t.split("!"),o="";if(a.length>1?(l=a[1],o=a[0]+"!"):l=a[0],-1==l.indexOf(":")){let a=parseInt(l.replace(/[^0-9]/g,"")),i=ABCatNum(l.replace(/[^A-Za-z]/g,"")),s=isfreezonFuc(l),u=s[0]?"$":"",c=s[1]?"$":"";return"u"==e?s[0]||(a-=r):"d"==e?s[0]||(a+=r):"r"==e?s[1]||(i+=r):"l"==e&&(s[1]||(i-=r)),a<0||i<0?n.error.r:isNaN(a)||isNaN(i)?isNaN(a)?isNaN(i)?t:o+c+chatatABC(i):o+u+a:o+c+chatatABC(i)+u+a}{l=l.split(":");let a=[],i=[];if(a[0]=parseInt(l[0].replace(/[^0-9]/g,"")),a[1]=parseInt(l[1].replace(/[^0-9]/g,"")),a[0]>a[1])return t;if(i[0]=ABCatNum(l[0].replace(/[^A-Za-z]/g,"")),i[1]=ABCatNum(l[1].replace(/[^A-Za-z]/g,"")),i[0]>i[1])return t;let s=isfreezonFuc(l[0]),u=isfreezonFuc(l[1]),c=s[0]?"$":"",h=s[1]?"$":"",g=u[0]?"$":"",d=u[1]?"$":"";return"u"==e?(s[0]||(a[0]-=r),u[0]||(a[1]-=r)):"r"==e?(s[1]||(i[0]+=r),u[1]||(i[1]+=r)):"l"==e?(s[1]||(i[0]-=r),u[1]||(i[1]-=r)):(s[0]||(a[0]+=r),u[0]||(a[1]+=r)),a[0]<0||i[0]<0?n.error.r:isNaN(i[0])&&isNaN(i[1])?o+c+a[0]+":"+g+a[1]:isNaN(a[0])&&isNaN(a[1])?o+h+chatatABC(i[0])+":"+d+chatatABC(i[1]):o+h+chatatABC(i[0])+c+a[0]+":"+d+chatatABC(i[1])+g+a[1]}}static iscelldata(e){let t,r=e.split("!");t=r.length>1?r[1]:r[0];let l=/^(([a-zA-Z]+)|([$][a-zA-Z]+))(([0-9]+)|([$][0-9]+))$/g,n=/^(((([a-zA-Z]+)|([$][a-zA-Z]+))(([0-9]+)|([$][0-9]+)))|((([a-zA-Z]+)|([$][a-zA-Z]+))))$/g;if(-1==t.indexOf(":")){let e=parseInt(t.replace(/[^0-9]/g,""))-1,r=ABCatNum(t.replace(/[^A-Za-z]/g,""));return!(isNaN(e)||isNaN(r)||!t.toString().match(l))||!!isNaN(e)&&(isNaN(r),!1)}{n=/^(((([a-zA-Z]+)|([$][a-zA-Z]+))(([0-9]+)|([$][0-9]+)))|((([a-zA-Z]+)|([$][a-zA-Z]+)))|((([0-9]+)|([$][0-9]+s))))$/g,t=t.split(":");let e=[],r=[];return e[0]=parseInt(t[0].replace(/[^0-9]/g,""))-1,e[1]=parseInt(t[1].replace(/[^0-9]/g,""))-1,!(e[0]>e[1]||(r[0]=ABCatNum(t[0].replace(/[^A-Za-z]/g,"")),r[1]=ABCatNum(t[1].replace(/[^A-Za-z]/g,"")),r[0]>r[1]||!t[0].toString().match(n)||!t[1].toString().match(n)))}}}function isChinese(e){return!!/[\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3008|\u3009|\u3010|\u3011|\u300e|\u300f|\u300c|\u300d|\ufe43|\ufe44|\u3014|\u3015|\u2026|\u2014|\uff5e|\ufe4f|\uffe5]/.test(e)||!/[^\u4e00-\u9fa5]/.test(e)}function isJapanese(e){return!/[^\u0800-\u4e00]/.test(e)}function isKoera(e){return e>12592&&e<12687||e>=44032&&e<=55203}function getMultiSequenceToNum(e){if(!e||e?.length<=0)return[];let t=(l=(e=e.toUpperCase()).split(" ").filter(e=>e&&e.trim()),l?.map(e=>{if(e.includes(":")){let t=e.split(":");2===t?.length&&(l=l.concat(function(e){let t=[];const r=new RegExp(/[A-Z]+|[0-9]+/g),l=e[0]?.match(r),n=e[1]?.match(r),a=Math.max(ABCatNum(l[0]),ABCatNum(n[0])),o=Math.min(ABCatNum(l[0]),ABCatNum(n[0])),i=Math.max(parseInt(l[1]),parseInt(n[1])),s=Math.min(parseInt(l[1]),parseInt(n[1]));for(let e=o;e<=a;e++)for(let r=s;r<=i;r++)t.push(`${chatatABC(e)}${r}`);return t}(t))).splice(l.indexOf(e),1)}}),l.filter((e,t,r)=>r.indexOf(e)===t)),r=[];var l;for(let e=0;e<t.length;e++){let l=getSingleSequenceToNum(t[e]);l&&r.push(l)}return r}function getSingleSequenceToNum(e){let t=e.match(/[A-Z]+|[0-9]+/g),r=t.length,l=new RegExp("^[A-Z]+$"),n="";for(let e=r-1;e>=0;e--){let r=t[e];l.test(r)?n+=ABCatNum(r)+"_":n+=parseInt(r)-1+"_"}return n.substring(0,n.length-1)}function getTransR1C1ToSequence(e){if(!e&&e?.length<=0)return"";const t=e.length,r=e.lastIndexOf("!"),l=[e.slice(0,r),e.slice(r+1,t)],n=l[1]||"",a=n.indexOf("R"),o=n.indexOf("C"),i=Number(n.slice(a+1,o)),s=chatatABC(Number(n.slice(o+1,n?.length))-1);return`${l[0]}!${s}${i}`}function getPeelOffX14(e){if(!e||e?.length<=0)return{};const t=new RegExp("</x14:formula[^]>","g"),r=e.match(t)?.length,l=`</x14:formula${r}>`,n=e.indexOf(l);let a=e.substring(0,n+l.length);a=a.replace(/<xm:f>/g,"").replace(/<\/xm:f>/g,"").replace(/x14:/g,"").replace(/\/x14:/g,"");const o=a,i=e.indexOf("<xm:sqref>"),s=e.indexOf("</xm:sqref>");return{formula:o,sqref:e.substring(i+10,s)}}function getMultiFormulaValue(e){if(!e||e?.length<=0)return[];const t=new RegExp("formula","g"),r=(e.match(t)?.length||0)/2;if(0===r)return[];let l=[];for(let t=1;t<=r;t++){const r=`<formula${t}>`?.length,n=e.indexOf(`<formula${t}>`),a=e.indexOf(`</formula${t}>`),o=e.substring(n+r,a);l.push(escapeCharacter(o.replace(/"|^\"|\"$/g,"")))}return l}function isfreezonFuc(e){e.indexOf("!")>-1&&(e=e.split("!")[1]);const t=e.match(/^(\$?)([A-Za-z]+)(\$?)(\d+)$/);if(!t)return[!1,!1];const r="$"===t[1];return["$"===t[3],r]}function ABCToNumber(e){if(null==e||0===e.length)return Number.NaN;const t=e.toLowerCase().split(""),r=t.length,l=e=>e.charCodeAt(0)-96;let n=0,a=0;for(let e=0;e<r;e++)a=l(t[e]),n+=a*26**(r-e-1);return 0===n?Number.NaN:n-1}fromulaRef.operator="==|!=|<>|<=|>=|=|+|-|>|<|/|*|%|&|^",fromulaRef.error={v:"#VALUE!",n:"#NAME?",na:"#N/A",r:"#REF!",d:"#DIV/0!",nm:"#NUM!",nl:"#NULL!",sp:"#SPILL!"},fromulaRef.operatorjson=null;const orderA="A".charCodeAt(0),orderZ="Z".charCodeAt(0);function numberToABC(e){const t=orderZ-orderA+1;let r="";for(;e>=0;)r=String.fromCharCode(e%t+orderA)+r,e=Math.floor(e/t)-1;return r}function str2num(e){if(null==e)return e;try{return Number.isNaN(Number(e))?e:Number(e)}catch(t){return e}}function generateRandomId(e=21,t){return t?nanoid.customAlphabet(t,e)():nanoid.nanoid(e)}function jsonParse(e){if(!e)return{};try{return JSON.parse(e)}catch(e){return null}}function isObject(e){return"[object Object]"===Object.prototype.toString.call(e)}class xmloperation{escapeXmlAttributes(e){return e}unescapeXmlAttributes(e){return e}getElementsByOneTag(e,t){const r=this.escapeXmlAttributes(t);let l;if(r.length>2e5){console.log(`[XML] Large file detected (${r.length} chars) for tag "${e}", processing in chunks`);const t=[],l=e.indexOf("|")>-1?e.split("|"):[e];for(const e of l){let l=0;const n=`<${e}`,a=`</${e}>`;for(;l<r.length;){const e=r.indexOf(n,l);if(-1===e)break;const o=r.indexOf(">",e);if(-1===o)break;{const n=r.substring(e,o+1);if(n.endsWith("/>")){t.push(n),l=o+1;continue}const i=r.indexOf(a,o);if(-1!==i){const n=r.substring(e,i+a.length);t.push(n),l=i+a.length}else l=o+1}}}let n=t.length>0?t:null;return null==n?[]:n.map(e=>this.unescapeXmlAttributes(e))}if(e.indexOf("|")>-1){let t=e.split("|"),r="";for(let e=0;e<t.length;e++){let l=t[e];r+="|<"+l+" [^>]+?[^/]>[\\s\\S]*?</"+l+">|<"+l+" [^>]+?/>|<"+l+">[\\s\\S]*?</"+l+">|<"+l+"/>"}r=r.substr(1,r.length),l=new RegExp(r,"g")}else l=new RegExp("<"+e+" [^>]+?[^/]>[\\s\\S]*?</"+e+">|<"+e+" [^>]+?/>|<"+e+">[\\s\\S]*?</"+e+">|<"+e+"/>","g");let n=r.match(l);return null==n?[]:n.map(e=>this.unescapeXmlAttributes(e))}getElementByTagLink(e,t){const r=(new DOMParser).parseFromString(t,"text/xml");let l=Array.from(r.children);if(e.indexOf("/")>-1){let t=e.split("/");for(let e=0;e<t.length;e++){const r=t[e],n=l.findIndex(e=>Array.from(e.children).findIndex(e=>e.tagName===r)>-1);if(-1===n&&e<=t.length-1)return[];l=Array.from(l[n].children).filter(e=>e.tagName===r)}}else l=Array.from(l[0].children).filter(t=>t.tagName===e);const n=new XMLSerializer;return l.map(e=>n.serializeToString(e))}}class ReadXml extends xmloperation{constructor(e){super(),this.originFile=e}getElementsByTagName(e,t,r=!0){let l=this.getFileByName(t);r||(l=t);let n,a=e.split("/");for(let e in a){let t=a[e];if(null==n)n=this.getElementsByOneTag(t,l);else if(n instanceof Array){let e=[];for(let r in n){let l=n[r];e=e.concat(this.getElementsByOneTag(t,l))}n=e}else n=this.getElementsByOneTag(t,n)}let o=[];for(let e=0;e<n.length;e++){let t=new Element(n[e]);o.push(t)}return o}getElementsByTagNameLink(e,t,r=!0){let l=this.getFileByName(t);r||(l=t);const n=this.getElementByTagLink(e,l);let a=[];for(let e=0;e<n.length;e++){let t=new Element(n[e]);a.push(t)}return a}getFileByName(e){for(let t in this.originFile)if(t.indexOf(e)>-1)return this.originFile[t];return""}}class Element extends xmloperation{constructor(e){let t;if(super(),this.elementString=e,this.setValue(),this.container.length>5e4){t=[];let e=0;for(;e<this.container.length;){const r=this.container.indexOf('="',e);if(-1===r)break;let l=r-1;for(;l>=0&&/[a-zA-Z0-9_:]/.test(this.container[l]);)l--;l++;const n=this.container.indexOf('"',r+2);if(-1===n)break;const a=this.container.substring(l,n+1);t.push(a),e=n+1}0===t.length&&(t=null)}else{const e=new RegExp('[a-zA-Z0-9_:]*?=".*?"',"g");t=this.container.match(e)}if(this.attributeList={},null!=t)for(let e in t){let r=t[e];if(0==r.length)continue;let l=r.substr(0,r.indexOf("=")),n=r.substr(r.indexOf("=")+1);if(null==l||null==n||0==l.length||0==n.length)continue;let a=n.substr(1,n.length-2);this.attributeList[l]=a}}get(e){return this.attributeList[e]}getInnerElements(e){let t=this.getElementsByOneTag(e,this.elementString),r=[];for(let e=0;e<t.length;e++){let l=new Element(t[e]);r.push(l)}return 0==r.length?null:r}getInnerElementsTagLink(e){const t=this.getElementByTagLink(e,this.elementString);let r=[];for(let e=0;e<t.length;e++){let l=new Element(t[e]);r.push(l)}return 0==r.length?null:r}setValue(){let e=this.elementString;if("/>"==e.substr(e.length-2,2))this.value="",this.container=e;else{let t=this.getFirstTag();if(e.length>5e4){console.log(`[XML setValue] Large string detected (${e.length} chars), using safe parsing`);const r="</"+t+">",l=e.indexOf(r);if(-1!==l){const n=e.substring(0,l+r.length);let a=new RegExp("(<"+t+" [^>]+?[^/]>)([\\s\\S]*?)</"+t+">|(<"+t+">)([\\s\\S]*?)</"+t+">","g").exec(n);null!=a&&(null!=a[1]?(this.container=a[1],this.value=a[2]):(this.container=a[3],this.value=a[4]))}else this.container=e,this.value=""}else{let r=new RegExp("(<"+t+" [^>]+?[^/]>)([\\s\\S]*?)</"+t+">|(<"+t+">)([\\s\\S]*?)</"+t+">","g").exec(e);null!=r&&(null!=r[1]?(this.container=r[1],this.value=r[2]):(this.container=r[3],this.value=r[4]))}}}getFirstTag(){let e=this.elementString,t=e.substr(0,e.indexOf(" "));return(""==t||t.indexOf(">")>-1)&&(t=e.substr(0,e.indexOf(">"))),t=t.substr(1,t.length),t}}function getColor(e,t,r="g"){let l=e.attributeList,n=t.clrScheme,a=t.indexedColors;t.mruColors;let o,i=function(e,t){let r={};if(null==e||0==e.length)return t;for(let l in t){let n=t[l],a=e[parseInt(l)];if(null==a)r[l]=n;else{let e=a.attributeList.rgb;r[l]=e}}return r}(a,indexedColors),s=l.indexed,u=l.rgb,c=l.theme,h=l.tint;if(null!=s)o=i[parseInt(s)],null!=o&&(o=o.substring(o.length-6,o.length),o="#"+o);else if(null!=u)u=u.substring(u.length-6,u.length),o="#"+u;else if(null!=c){let e=parseInt(c);0==e?e=1:1==e?e=0:2==e?e=3:3==e&&(e=2);let t=n[e];if(null!=t){let e=t.getInnerElements("a:sysClr|a:srgbClr");if(null!=e){let t=e[0],r=t.attributeList;t.container.indexOf("sysClr")>-1?null!=r.lastClr?o="#"+r.lastClr:null!=r.val&&(o="#"+r.val):t.container.indexOf("srgbClr")>-1&&(o="#"+r.val)}}}if(null!=h){let e=parseFloat(h);null!=o&&(o=function(e,t){let r=e.substring(e.length-6,e.length),l=hexToRgbArray("#"+r),n=function(e,t,r){e/=255,t/=255,r/=255;var l,n,a=Math.max(e,t,r),o=Math.min(e,t,r),i=(a+o)/2;if(a==o)l=n=0;else{var s=a-o;switch(n=i>.5?s/(2-a-o):s/(a+o),a){case e:l=(t-r)/s+(t<r?6:0);break;case t:l=(r-e)/s+2;break;case r:l=(e-t)/s+4}l/=6}return[l,n,i]}(l[0],l[1],l[2]);if(t>0)n[2]=n[2]*(1-t)+t;else{if(!(t<0))return"#"+r;n[2]=n[2]*(1+t)}return function(e){if(/^(rgb|RGB)/.test(e)){for(var t=e.replace(/(?:\(|\)|rgb|RGB)*/g,"").split(","),r="#",l=0;l<t.length;l++){var n=Number(t[l]).toString(16);n.length<2&&(n="0"+n),r+=n}return 7!==r.length&&(r=e),r}if(/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(e)){var a=e.replace(/#/,"").split("");if(6===a.length)return e;if(3===a.length){var o="#";for(l=0;l<a.length;l+=1)o+=a[l]+a[l];return o}}return e}("RGB("+function(e,t,r){var l,n,a;if(0==t)l=n=a=r;else{var o=function(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+(t-e)*(2/3-r)*6:e},i=r<.5?r*(1+t):r+t-r*t,s=2*r-i;l=o(s,i,e+1/3),n=o(s,i,e),a=o(s,i,e-1/3)}return[Math.round(255*l),Math.round(255*n),Math.round(255*a)]}(n[0],n[1],n[2]).join(",")+")")}(o,e))}return o}function getlineStringAttr(e,t){let r,l=e.getInnerElements(t);if(null!=l&&l.length>0)if("b"==t||"i"==t||"strike"==t)r="1";else if("u"==t){let e=l[0].attributeList.val;r="double"==e?"2":"singleAccounting"==e?"3":"doubleAccounting"==e?"4":"1"}else if("vertAlign"==t){let e=l[0].attributeList.val;"subscript"==e?r="1":"superscript"==e&&(r="2")}else r=l[0].attributeList.val;return r}class LuckyFileBase{}class WorkBookInfo{}class LuckySheetBase{}class LuckyFileInfo{}class LuckySheetCelldataBase{}class LuckySheetCelldataValue{}class LuckySheetCellFormat{}class LuckyInlineString{}class LuckyConfig{}class LuckySheetborderInfoCellForImp{}class LuckySheetborderInfoCellValue{}class LuckySheetborderInfoCellValueStyle{}class LuckySheetConfigMerge{}class LuckysheetCalcChain{}class LuckyImageBase{}class LuckyChartImageBase{}class LuckyChart{}var AbsoluteRefType;function getBorderInfo(e,t){if(null==e)return null;let r=e[0],l=r.attributeList.style;if(null==l||"none"==l)return null;let n=r.getInnerElements("color"),a="#000000";null!=n&&(a=getColor(n[0],t,"b"),null==a&&(a="#000000"));let o=new LuckySheetborderInfoCellValueStyle;return o.style=borderTypes[l],o.color=a,o}function handleBorder(e,t){const r=new LuckySheetborderInfoCellValue;let l=!1;if(!e)return{borderCellValue:r,isAdd:l};let n=e.getInnerElements("left"),a=e.getInnerElements("right"),o=e.getInnerElements("top"),i=e.getInnerElements("bottom"),s=e.getInnerElements("diagonal"),u=e.getInnerElements("start"),c=e.getInnerElements("end"),h=getBorderInfo(n,t),g=getBorderInfo(a,t),d=getBorderInfo(o,t),m=getBorderInfo(i,t),f=getBorderInfo(s,t),p=getBorderInfo(u,t),E=getBorderInfo(c,t);if(null!=p&&null!=p.color&&(r.l=p,l=!0),null!=E&&null!=E.color&&(r.r=E,l=!0),null!=h&&null!=h.color&&(r.l=h,l=!0),null!=g&&null!=g.color&&(r.r=g,l=!0),null!=d&&null!=d.color&&(r.t=d,l=!0),null!=m&&null!=m.color&&(r.b=m,l=!0),null!=f&&null!=f.color){const t=e.attributeList.diagonalUp,n=e.attributeList.diagonalDown;"1"===t&&(r.bl_tr=f),"1"===n&&(r.tl_br=f),l=!0}return{borderCellValue:r,isAdd:l}}function getBackgroundByFill(e,t){let r=e.getInnerElements("patternFill");if(null!=r){let e,l,n=r[0],a=n.getInnerElements("fgColor"),o=n.getInnerElements("bgColor");if(null!=a&&(e=getColor(a[0],t)),null!=o&&(l=getColor(o[0],t)),null!=e)return e;if(null!=l)return l}else if(null!=e.getInnerElements("gradientFill"))return null}function getFontStyle(e,t){let r=null;const l=new LuckySheetCelldataValue;let n=e.getInnerElements("sz"),a=e.getInnerElements("color"),o=e.getInnerElements("name"),i=e.getInnerElements("family");e.getInnerElements("charset");let s=e.getInnerElements("b"),u=e.getInnerElements("i"),c=e.getInnerElements("strike"),h=e.getInnerElements("u");if(null!=n&&n.length>0){let e=n[0].attributeList.val;null!=e&&(l.fs=parseInt(e))}if(null!=a&&a.length>0){let e=getColor(a[0],t,"t");null!=e&&(l.fc=e)}if(null!=i&&i.length>0){let e=i[0].attributeList.val;null!=e&&(r=fontFamilys[e])}if(null!=o&&o.length>0){let e=o[0].attributeList.val;null!=e&&(l.ff=e)}if(null!=s&&s.length>0){let e=s[0].attributeList.val;l.bl="0"==e?0:1}if(null!=u&&u.length>0){let e=u[0].attributeList.val;l.it="0"==e?0:1}if(null!=c&&c.length>0){let e=c[0].attributeList.val;l.cl="0"==e?0:1}if(null!=h&&h.length>0){let e=h[0].attributeList.val;l.un="single"==e?1:"double"==e?2:"singleAccounting"==e?3:"doubleAccounting"==e?4:0}return{cellValue:l,familyFont:r}}!function(e){e[e.NONE=0]="NONE",e[e.ROW=1]="ROW",e[e.COLUMN=2]="COLUMN",e[e.ALL=3]="ALL"}(AbsoluteRefType||(AbsoluteRefType={}));const handleRanges=e=>e.split(" ").map(e=>{const t=e.split(":"),r=parseInt(t[0].replace(/[^0-9]/g,""))-1,l=ABCToNumber(t[0].replace(/[^A-Za-z]/g,"")),n=isfreezonFuc(t[0]),a=1===t.length?r:parseInt(t[1].replace(/[^0-9]/g,""))-1,o=1===t.length?l:ABCToNumber(t[1].replace(/[^A-Za-z]/g,"")),i=1===t.length?n:isfreezonFuc(t[1]),s=e=>!0===e[0]&&!0===e[1]?AbsoluteRefType.ALL:!0===e[0]?AbsoluteRefType.ROW:!0===e[1]?AbsoluteRefType.COLUMN:AbsoluteRefType.NONE;return{startRow:r,startColumn:l,endRow:a,endColumn:o,startAbsoluteRefType:s(n),endAbsoluteRefType:s(i),rangeType:0}});var CHARSET_TYPE;!function(e){e.UTF8="UTF-8",e.GBK="GBK",e.CP936="CP936",e.ISO8859="ISO-8859"}(CHARSET_TYPE||(CHARSET_TYPE={}));const replaceSpecialWrap=e=>e.replace(/_x000D_/g,"").replace(/ /g,"\r\n").replace(/ /g,"\r").replace(/ /g,"\n");class LuckySheetCelldata extends LuckySheetCelldataBase{constructor(e,t,r,l,n,a,o,i,s){super(),this.cell=e,this.sheetFile=a,this.styles=r,this.sharedStrings=l,this.readXml=s,this.mergeCells=n,this.cellImages=o,this.imageList=i,this.cellSize=t;let u=e.attributeList,c=u.r,h=u.s,g=u.t,d=getcellrange(c);this.r=d.row[0],this.c=d.column[0],this.v=this.generateValue(h,g)}generateValue(e,t){let r=this.cell.getInnerElements("v"),l=this.cell.getInnerElements("f");null==r&&(r=this.cell.getInnerElements("t"));let n=this.styles.cellXfs,a=this.styles.cellStyleXfs;this.styles.cellStyles;let o=this.styles.fonts,i=this.styles.fills,s=this.styles.borders,u=this.styles.numfmts;this.styles.clrScheme;let c=this.sharedStrings,h=new LuckySheetCelldataValue;if(null!=l){let e=l[0].attributeList,t=e.t,r=e.ref,n=e.si,a=l[0].value;"shared"==t?(this._fomulaRef=r,this._formulaType=t,this._formulaSi=n):"array"==t&&(this._fomulaRef=r,this._formulaType=t),(null!=r||null!=a&&a.length>0)&&(a=escapeCharacter(a),h.f="="===a[0]?a:"="+a,h.f.startsWith("=+")&&(h.f="="+h.f.substring(2)),"array"!=t&&"shared"!=t||(h.ft=t,r&&(h.ref=r)))}let g,d=null;if(null!=e){let r,l,c,m,f,p,E,C,y,T=n[parseInt(e)],b=T.attributeList.xfId;if(null!=b){let e=a[parseInt(b)],t=e.attributeList,n=t.applyNumberFormat,o=t.applyFont,i=t.applyFill,s=t.applyBorder,u=t.applyAlignment;if(t.applyProtection,g=t.quotePrefix,"0"!=n&&null!=t.numFmtId&&(r=t.numFmtId),"0"!=o&&null!=t.fontId&&(l=t.fontId),"0"!=i&&null!=t.fillId&&(c=t.fillId),"0"!=s&&null!=t.borderId&&(m=t.borderId),null!=u&&"0"!=u){let t=e.getInnerElements("alignment");if(null!=t){let e=t[0].attributeList;null!=e.horizontal&&(f=e.horizontal),null!=e.vertical&&(p=e.vertical),null!=e.wrapText&&(E=e.wrapText),null!=e.textRotation&&(C=e.textRotation),null!=e.shrinkToFit&&e.shrinkToFit,null!=e.indent&&(y=e.indent)}}}let R=T.attributeList.applyNumberFormat,A=T.attributeList.applyFont,S=T.attributeList.applyFill,w=T.attributeList.applyBorder,F=T.attributeList.applyAlignment;if(null!=T.attributeList.applyProtection&&T.attributeList.applyProtection,null!=T.attributeList.quotePrefix&&(g=T.attributeList.quotePrefix),"0"!=R&&null!=T.attributeList.numFmtId&&(r=T.attributeList.numFmtId),"0"!=A&&(l=T.attributeList.fontId),"0"!=S&&(c=T.attributeList.fillId),"0"!=w&&(m=T.attributeList.borderId),"0"!=F){let e=T.getInnerElements("alignment");if(null!=e&&e.length>0){let t=e[0].attributeList;null!=t.horizontal&&(f=t.horizontal),null!=t.vertical&&(p=t.vertical),null!=t.wrapText&&(E=t.wrapText),null!=t.textRotation&&(C=t.textRotation),null!=t.shrinkToFit&&t.shrinkToFit,null!=t.indent&&(y=t.indent)}}if(null!=r){let e=u[parseInt(r)],l=new LuckySheetCellFormat;l.fa=escapeCharacter(e),l.t=t||"d",h.ct=l}if(null!=c){let e=getBackgroundByFill(i[parseInt(c)],this.styles);null!=e&&(h.bg=e)}if(null!=l){let e=o[parseInt(l)];if(null!=e){const{cellValue:t,familyFont:r}=getFontStyle(e,this.styles);h={...h,...t},d=r}}if(null!=f&&(h.ht="center"==f||"centerContinuous"==f?0:"left"==f?1:"right"==f?2:"distributed"==f?0:"fill"==f||"general"==f?1:"justify"==f?0:1),h.vt=null!=p?"bottom"==p?2:"center"==p||"distributed"==p||"justify"==p?0:1:2,h.tb=null!=E&&"1"==E?2:1,null!=C&&("255"==C?h.tr=3:(h.tr=0,h.rt=parseInt(C))),null!=y){const e=parseInt(y);isNaN(e)||(h.ti=e)}if(null!=m){let e=s[parseInt(m)],t=new LuckySheetborderInfoCellForImp;t.rangeType="cell";const{isAdd:r,borderCellValue:l}=handleBorder(e,this.styles);l.row_index=this.r,l.col_index=this.c,r&&(t.value=l,this._borderObject=t)}}else h.tb=1;if(null!=r){let e=r[0].value;/&#\d+;/.test(e)&&(e=this.htmlDecode(e));const l=e=>{let t=e.getInnerElements("r");if(null==t){let t=e.getInnerElements("t");if(null!=t){let e="";if(t.forEach(t=>{e+=t.value}),e=escapeCharacter(e),/&#\d+;/.test(e)&&(e=this.htmlDecode(e)),"Roman"==d&&e.length>0){let t=e.split(""),r=null,l="",n=null,a="Times New Roman";null!=h.ff&&(a=h.ff);let o=h.ct;null==o&&(o=new LuckySheetCellFormat),null==o.s&&(o.s=[]);for(let e=0;e<t.length;e++){let i=t[e],s=null,u=a;if(isChinese(i)?(s="c",u="\u5b8b\u4f53"):isJapanese(i)?(s="j",u="Yu Gothic"):isKoera(i)?(s="k",u="Malgun Gothic"):s="e",s!=r&&null!=r||e==t.length-1){let a=new LuckyInlineString;if(a.ff=n,null!=h.fc&&(a.fc=h.fc),null!=h.fs&&(a.fs=h.fs),null!=h.cl&&(a.cl=h.cl),null!=h.un&&(a.un=h.un),null!=h.bl&&(a.bl=h.bl),null!=h.it&&(a.it=h.it),e==t.length-1){if(s!=r){a.ff=n,a.v=l,o.s.push(a);let e=new LuckyInlineString;e.ff=u,e.v=i,null!=h.fc&&(e.fc=h.fc),null!=h.fs&&(e.fs=h.fs),null!=h.cl&&(e.cl=h.cl),null!=h.un&&(e.un=h.un),null!=h.bl&&(e.bl=h.bl),null!=h.it&&(e.it=h.it),o.s.push(e);break}a.ff=u,a.v=l+i}else a.v=l;o.s.push(a),l=i}else l+=i;r=s,n=u}o.t="inlineStr",h.ct=o}else if(e=replaceSpecialWrap(e),e.indexOf("\r\n")>-1||e.indexOf("\n")>-1){let t=new LuckyInlineString;t.v=e;let r=h.ct;null==r&&(r=new LuckySheetCellFormat),null!=h.ff&&(t.ff=h.ff),null!=h.fc&&(t.fc=h.fc),null!=h.fs&&(t.fs=h.fs),null!=h.cl&&(t.cl=h.cl),null!=h.un&&(t.un=h.un),null!=h.bl&&(t.bl=h.bl),null!=h.it&&(t.it=h.it),r.t="inlineStr",r.s=[t],h.ct=r}else h.v=e,g="1"}}else{let e=[];t.forEach(t=>{let r=t.getInnerElements("t"),l=t.getInnerElements("rPr"),n=new LuckyInlineString;if(null!=r&&r.length>0){let e=r[0].value;e=replaceSpecialWrap(e),e=escapeCharacter(e),n.v=e}if(null!=l&&l.length>0){let e=l[0],t=getlineStringAttr(e,"sz"),r=getlineStringAttr(e,"rFont");getlineStringAttr(e,"family"),getlineStringAttr(e,"charset"),getlineStringAttr(e,"scheme");let a,o,i=getlineStringAttr(e,"b"),s=getlineStringAttr(e,"i"),u=getlineStringAttr(e,"u"),c=getlineStringAttr(e,"strike"),g=getlineStringAttr(e,"vertAlign"),d=e.getInnerElements("color");null!=d&&d.length>0&&(a=getColor(d[0],this.styles,"t")),null!=r&&(o=r),null!=o?n.ff=o:null!=h.ff&&(n.ff=h.ff),null!=a&&(n.fc=a),null!=t?n.fs=parseInt(t):null!=h.fs&&(n.fs=h.fs),null!=c?n.cl=parseInt(c):null!=h.cl&&(n.cl=h.cl),null!=u?n.un=parseInt(u):null!=h.un&&(n.un=h.un),null!=i?n.bl=parseInt(i):null!=h.bl&&(n.bl=h.bl),null!=s?n.it=parseInt(s):null!=h.it&&(n.it=h.it),null!=g&&(n.va=parseInt(g))}else null==n.ff&&null!=h.ff&&(n.ff=h.ff),null==n.fc&&null!=h.fc&&(n.fc=h.fc),null==n.fs&&null!=h.fs&&(n.fs=h.fs),null==n.cl&&null!=h.cl&&(n.cl=h.cl),null==n.un&&null!=h.un&&(n.un=h.un),null==n.bl&&null!=h.bl&&(n.bl=h.bl),null==n.it&&null!=h.it&&(n.it=h.it);e.push(n)});let r=h.ct;null==r&&(r=new LuckySheetCellFormat),r.t="inlineStr",r.s=e,h.ct=r}};if("s"==t)l(c[parseInt(r[0].value)]);else if("inlineStr"==t&&null!=r){h.v=this.htmlDecode(e);let t=h.ct;null==t&&(t=new LuckySheetCellFormat),t.t="s",h.ct=t;let r=this.cell.getInnerElements("is");r.length&&l(r[0])}else if("str"==t&&e.includes("=DISPIMG")){let t=h.ct;null==t&&(t=new LuckySheetCellFormat),t.t="str",t.ci=this.getCellImage(h,e),h.ct=t}else e=escapeCharacter(e),h.v=e}if(null!=g&&(h.qp=parseInt(g)),null!==t&&!h.ct?.t){let e=new LuckySheetCellFormat;e.t=t||"d",h.ct=e}return h}htmlDecode(e){return e.replace(/&#(x)?([^&]{1,5});/g,function(e,t,r){return String.fromCharCode(parseInt(r,t?16:10))})}getCellImage(e,t){const r=this.extractImageId(t);let l={};return this.cellImages.forEach(e=>{const t=e.getInnerElements("xdr:pic")[0],n=t.getInnerElements("xdr:nvPicPr")[0].getInnerElements("xdr:cNvPr")[0],a=t.getInnerElements("xdr:blipFill")[0].getInnerElements("a:blip")[0],o=n.get("name"),i=a.get("r:embed");if(r==o){const e=this.getBase64ByRid(i,"xl/_rels/cellimages.xml.rels");l=e;let r=0,a=0,o=0,s=0;const u=t.getInnerElements("xdr:spPr")[0].getInnerElements("a:xfrm")[0],c=u.getInnerElements("a:off")[0],h=u.getInnerElements("a:ext")[0];o=getPxByEMUs(parseInt(h.get("cx"))),s=getPxByEMUs(parseInt(h.get("cy"))),r=getPxByEMUs(parseInt(c.get("x"))),a=getPxByEMUs(parseInt(c.get("y")));const g=o/this.cellSize.width,d=s/this.cellSize.height;g>1&&g>d&&(s/=g,o=this.cellSize.width),d>1&&d>g&&(o/=d,s=this.cellSize.height);let m={height:s,left:r,top:a,width:o};l.default=m,l.descr=n.get("descr")}}),l}extractImageId(e){const t=e.match(/ID_[A-Za-z0-9]{32}/);return t?t[0]:null}getBase64ByRid(e,t){let r=this.readXml.getElementsByTagName("Relationships/Relationship",t);if(null!=r&&r.length>0)for(let t=0;t<r.length;t++){let l=r[t].attributeList,n=getXmlAttibute(l,"Id",null),a=getXmlAttibute(l,"Target",null);if(n==e)return a=a.replace(/\.\.\//g,""),a="xl/"+a,this.imageList.getImageByName(a)}return{}}}var CFTextOperator,CFTimePeriodOperator,CFNumberOperator,CFRuleType,CFSubRuleType;!function(e){e.beginsWith="beginsWith",e.endsWith="endsWith",e.containsText="containsText",e.notContainsText="notContainsText",e.equal="equal",e.notEqual="notEqual",e.containsBlanks="containsBlanks",e.notContainsBlanks="notContainsBlanks",e.containsErrors="containsErrors",e.notContainsErrors="notContainsErrors"}(CFTextOperator||(CFTextOperator={})),function(e){e.today="today",e.yesterday="yesterday",e.tomorrow="tomorrow",e.last7Days="last7Days",e.thisMonth="thisMonth",e.lastMonth="lastMonth",e.nextMonth="nextMonth",e.thisWeek="thisWeek",e.lastWeek="lastWeek",e.nextWeek="nextWeek"}(CFTimePeriodOperator||(CFTimePeriodOperator={})),function(e){e.greaterThan="greaterThan",e.greaterThanOrEqual="greaterThanOrEqual",e.lessThan="lessThan",e.lessThanOrEqual="lessThanOrEqual",e.notBetween="notBetween",e.between="between",e.equal="equal",e.notEqual="notEqual"}(CFNumberOperator||(CFNumberOperator={})),function(e){e.highlightCell="highlightCell",e.dataBar="dataBar",e.colorScale="colorScale",e.iconSet="iconSet"}(CFRuleType||(CFRuleType={})),function(e){e.uniqueValues="uniqueValues",e.duplicateValues="duplicateValues",e.rank="rank",e.text="text",e.timePeriod="timePeriod",e.number="number",e.average="average",e.formula="formula"}(CFSubRuleType||(CFSubRuleType={}));class LuckyCondition{constructor(e,t,r){this.stopIfTrue=!1,this.handleRules=(e,t,r)=>{const{attributeList:l,value:n,extLst:a,isExtLst:o}=e,i=getXmlAttibute(l,"type","expression"),s={type:CFRuleType.highlightCell},u=getXmlAttibute(l,"operator",""),c=getXmlAttibute(l,"rank",""),h=t.getElementsByTagName("formula",n,!1);switch(getXmlAttibute(l,"aboveAverage",""),u&&(s.operator=u),(h[0]?.value||"0"==h[0]?.value)&&(s.value=str2num(h[0]?.value)),i){case"expression":s.subType=CFSubRuleType.formula;break;case"cellIs":s.subType=CFSubRuleType.number;break;case"top10":s.subType=CFSubRuleType.rank;const e=getXmlAttibute(l,"percent","0"),i=getXmlAttibute(l,"bottom","0");c&&(s.value=str2num(c)),s.isBottom="1"===i,s.isPercent="1"===e;break;case"aboveAverage":s.subType=CFSubRuleType.average,s.operator=s.operator||CFNumberOperator.lessThan;break;case"timePeriod":s.subType=CFSubRuleType.timePeriod,s.operator=getXmlAttibute(l,"timePeriod",void 0);break;case"duplicateValues":s.subType=CFSubRuleType.duplicateValues;break;case"containsText":s.subType=CFSubRuleType.text,s.operator="containsText",s.value=getXmlAttibute(l,"text","");break;case"colorScale":const u=t.getElementsByTagName("colorScale/cfvo",n,!1),h=t.getElementsByTagName("colorScale/color",n,!1);s.type=CFRuleType.colorScale,s.config=u.map((e,t)=>{const l=getXmlAttibute(e.attributeList,"type",""),n=getXmlAttibute(e.attributeList,"val",void 0);return{index:0,color:h[t]?getColor(h[t],r):void 0,value:{type:l,value:str2num(n)}}});break;case"dataBar":s.type=CFRuleType.dataBar;const g=t.getElementsByTagName("dataBar",n,!1)?.[0],d=t.getElementsByTagName("cfvo",g.value,!1),m=t.getElementsByTagName("color",g.value,!1),f=getXmlAttibute(g.attributeList,"showValue","1");s.isShowValue="1"===f;let p=m[0]?getColor(m[0],r):void 0,E=!0,C="";if(a){const e=getXmlAttibute(t.getElementsByTagName("x14:dataBar",a.value,!1)[0].attributeList,"gradient",null),l=t.getElementsByTagName("x14:dataBar/x14:negativeFillColor",a.value,!1)?.[0];C=l?getColor(l,r):void 0,E="0"!==e}s.config={min:{type:getXmlAttibute(d[0]?.attributeList,"type","min"),value:str2num(getXmlAttibute(d[0]?.attributeList,"val",void 0))},max:{type:getXmlAttibute(d[1]?.attributeList,"type","max"),value:str2num(getXmlAttibute(d[1]?.attributeList,"val",void 0))},isGradient:E,positiveColor:p,nativeColor:C};break;case"iconSet":if(s.type=CFRuleType.iconSet,o){const e=t.getElementsByTagName("x14:iconSet",n,!1)[0],r=t.getElementsByTagName("x14:iconSet/x14:cfvo",n,!1),l=t.getElementsByTagName("x14:iconSet/x14:cfIcon",n,!1),a="1"===getXmlAttibute(e?.attributeList,"custom","0");s.isShowValue="0"!==e?.attributeList?.showValue,s.config=r.map((r,n)=>{const o=t.getElementsByTagName("xm:f",r.value,!1)[0];let i=l[n]?.attributeList;const s=a?i?.iconSet:e?.attributeList.iconSet,u=str2num(s.charAt(0))-str2num(i?.iconId)-1;return{operator:CFNumberOperator.greaterThanOrEqual,value:{type:r.attributeList.type,value:str2num(o?.value)},iconType:s,iconId:u}}).reverse()}else{const e=t.getElementsByTagName("iconSet",n,!1),r=t.getElementsByTagName("iconSet/cfvo",n,!1);s.isShowValue="0"!==e[0]?.attributeList?.showValue,s.config=r.map((t,r)=>({operator:s.operator||CFNumberOperator.greaterThanOrEqual,value:{type:t.attributeList.type,value:str2num(t.attributeList.val)},iconType:e[0].attributeList.iconSet,iconId:r}))}}const g=getXmlAttibute(l,"dxfId",null);if(g){let e=r.dxfs;const t=null!==g?e[Number(g)]:void 0,l=t.getInnerElements("font")?.[0],n=t.getInnerElements("numFmt")?.[0],a=t.getInnerElements("fill")?.[0],o=t.getInnerElements("border")?.[0];let i=r.numfmts,u={};if(o){const{borderCellValue:e}=handleBorder(o,r);u.border=e}if(a){const e=getBackgroundByFill(a,r);u.bg=e}if(n){let e=i[parseInt(n?.attributeList?.numFmtId)],t=new LuckySheetCellFormat;t.fa=e?escapeCharacter(e):n.attributeList.formatCode,u.ct=t}if(l){const{cellValue:e}=getFontStyle(l,u);u={...u,...e}}s.style=u}this.rule=s};const{attributeList:l,parentAttribute:n}=e;n?.sqref&&(this.ranges=handleRanges(n.sqref)),this.order=Number(getXmlAttibute(l,"priority","1")),this.cfId=generateRandomIndex("condition"),this.stopIfTrue="1"===getXmlAttibute(l,"stopIfTrue","0"),this.handleRules(e,t,r)}}class LuckyVerification{constructor(e,t){let r=e.attributeList,l=e.value,n=getXmlAttibute(r,"type",void 0);if(!n)return;this.uid=generateRandomIndex("verification");let a=[],o="";const i=getXmlAttibute(r,"operator",void 0),s="1"===getXmlAttibute(r,"allowBlank",void 0),u="1"===getXmlAttibute(r,"showInputMessage",void 0),c="1"===getXmlAttibute(r,"showErrorMessage",void 0),h=getXmlAttibute(r,"prompt",void 0),g=getXmlAttibute(r,"promptTitle",void 0),d=getXmlAttibute(r,"error",void 0),m=getXmlAttibute(r,"errorTitle",void 0),f=getXmlAttibute(r,"errorStyle","stop");if(new RegExp(/<x14:formula1>|<xm:sqref>/g).test(l)&&t?.length>=0){const e=getPeelOffX14(l);o=e?.sqref,a=getMultiFormulaValue(e?.formula)}else a=getMultiFormulaValue(l),o=getXmlAttibute(r,"sqref",null);let p=a?.length>=1?a[0]:void 0,E=2===a?.length?a[1]:void 0;switch(o&&(this.ranges=handleRanges(o)),this.type=n,this.allowBlank=s,this.operator=i,this.formula1=p,this.formula2=E,this.showErrorMessage=c,this.showInputMessage=u,this.prompt=h,this.promptTitle=g,this.error=d,this.errorTitle=m,f){case"information":this.errorStyle=0;break;case"warning":this.errorStyle=2;break;case"stop":this.errorStyle=1}this.ranges=handleRanges(o)}}class LuckFilter{constructor(e,t){const r=e.getElementsByTagName("autoFilter",t)[0];if(!r)return;this.ref=handleRanges(r.attributeList.ref)?.[0];const l=r.getInnerElements("filterColumn");this.filterColumns=l?.map(e=>{const t=e.getInnerElements("customFilters")?.[0],r=e.getInnerElements("filters")?.[0];let l,n,a=str2num(e.attributeList.colId);if(a=this.ref?a+this.ref.startRow:a,t){const e=t.getInnerElements("customFilter");l={and:"1"===t.attributeList?.and?1:void 0,customFilters:e.map(e=>({val:replaceSpecialWrap(e.attributeList.val),operator:e.attributeList?.operator}))}}if(r){const e=r.getInnerElements("filter");n={blank:"1"===r.attributeList?.blank,filters:e.map(e=>replaceSpecialWrap(e.attributeList.val))}}return{colId:a,filters:n,customFilters:l}})}}class LuckyFreezen{constructor(e){const t=getXmlAttibute(e.attributeList,"xSplit","0"),r=getXmlAttibute(e.attributeList,"ySplit","0");this.horizen=Number(r),this.vertical=Number(t)}}const getChartType=(e,t)=>{const r=e.getElementsByTagName("c:barChart",t)[0],l=e.getElementsByTagName("c:lineChart",t)[0],n=e.getElementsByTagName("c:pieChart",t)[0],a=e.getElementsByTagName("c:doughnutChart",t)[0],o=e.getElementsByTagName("c:areaChart",t)[0],i=e.getElementsByTagName("c:radarChart",t)[0],s=e.getElementsByTagName("c:scatterChart",t)[0];let u=[],c=r,h=ChartTypeBits.Column;if(r){const e=r.getInnerElements("c:barDir")?.[0]?.get("val"),t=r.getInnerElements("c:grouping")?.[0]?.get("val");"col"===e?(h=ChartTypeBits.Column,"stacked"===t?h=ChartTypeBits.ColumnStacked:"percentStacked"===t&&(h=ChartTypeBits.ColumnPercentStacked)):"bar"===e&&(h=ChartTypeBits.Bar,"stacked"===t?h=ChartTypeBits.BarStacked:"percentStacked"===t&&(h=ChartTypeBits.BarPercentStacked)),c=r,u.push({chartEle:c,chartType:h})}if(l&&(c=l,h=ChartTypeBits.Line,u.push({chartEle:c,chartType:h})),n&&(c=n,h=ChartTypeBits.Pie,u.push({chartEle:c,chartType:h})),a&&(c=a,h=ChartTypeBits.Doughnut,u.push({chartEle:c,chartType:h})),o){c=o,h=ChartTypeBits.Area;const e=o.getInnerElements("c:grouping")?.[0]?.get("val");"stacked"===e?h=ChartTypeBits.AreaStacked:"percentStacked"===e&&(h=ChartTypeBits.AreaPercentStacked),u.push({chartEle:c,chartType:h})}return i&&(c=i,h=ChartTypeBits.Radar,u.push({chartEle:c,chartType:h})),s&&(c=s,h=ChartTypeBits.Scatter,u.push({chartEle:c,chartType:h})),u.length>1&&(h=ChartTypeBits.Combination,c=u),{chartEle:c,chartType:h}};class LuckyChartImage extends LuckyChartImageBase{constructor(e,t,r,l){super(),this.id=e,this.type="chart",this.data={chartType:l,range:r,border:"#979DAC",background:"rgba(0,0,0,0)",isRowDirection:!0};let n=0,a=0,o=0,i=0;const s=t.getInnerElements("a:off")[0],u=t.getInnerElements("a:ext")[0];o=getPxByEMUs(parseInt(u.get("cx"))),i=getPxByEMUs(parseInt(u.get("cy"))),n=getPxByEMUs(parseInt(s.get("x"))),a=getPxByEMUs(parseInt(s.get("y"))),this.transform={width:o,height:i,top:a,left:n}}}class ChartImageGroup{constructor({graphicFrame:e,readXml:t,drawingRelsFile:r,styles:l}){this.getChartRange=e=>{try{let t=0,r=0,l=0,n=0;if(Array.isArray(e))e.map(e=>this.getChartRef(e.chartEle.value)).forEach((e,a)=>{0===a?(t=e.maxColumn,r=e.maxRow,l=e.minColumn,n=e.minRow):(t=Math.max(t,e.maxColumn),r=Math.max(r,e.maxRow),l=Math.min(l,e.minColumn),n=Math.min(n,e.minRow))});else{const a=this.getChartRef(e.value);t=a.maxColumn,r=a.maxRow,l=a.minColumn,n=a.minRow}const a=numberToABC(t)+(r+1);return numberToABC(l)+(n+1)+":"+a}catch(e){return debug_error("Error getting chart range:",e),"A1:B2"}},this.getChartRef=e=>{try{const t=this.readXml.getElementsByTagName("c:ser/c:cat/c:numRef/c:f",e,!1)?.[0],r=this.readXml.getElementsByTagName("c:ser/c:cat/c:strRef/c:f",e,!1)?.[0],l=this.readXml.getElementsByTagName("c:ser/c:xVal/c:strRef/c:f",e,!1)?.[0],n=this.readXml.getElementsByTagName("c:ser/c:xVal/c:numRef/c:f",e,!1)?.[0],a=t||r||l||n,o=this.readXml.getElementsByTagName("c:ser/c:tx/c:strRef/c:f",e,!1),i=this.readXml.getElementsByTagName("c:ser/c:val/c:numRef/c:f",e,!1),s=o?.[o.length-1]||i?.[i.length-1],u=a;if(!(u&&s&&u.value&&s.value))return debug_warn("Chart missing data references, using default range"),{maxColumn:1,maxRow:1,minColumn:0,minRow:0};const c=getcellrange(u.value),h=getcellrange(s.value),g=[...c.column,...h.column],d=[...c.row,...h.row],m=Math.max(...g);return{maxColumn:m,maxRow:Math.max(...d),minColumn:Math.min(...g),minRow:Math.min(...d)}}catch(e){return debug_error("Error parsing chart references:",e),{maxColumn:1,maxRow:1,minColumn:0,minRow:0}}},this.readXml=t;const n=e.getInnerElements("xdr:xfrm")[0],a=function(e){const{rid:t,fileName:r,callback:l,readXml:n}=e;let a=n.getElementsByTagName("Relationships/Relationship",r);if(null!=a&&a.length>0)for(let e=0;e<a.length;e++){let r=a[e].attributeList,n=getXmlAttibute(r,"Id",null),o=getXmlAttibute(r,"Target",null);if(n==t)return o=o.replace(/\.\.\//g,""),l?l(o):o}return null}({rid:t.getElementsByTagName("a:graphic/a:graphicData/c:chart",e.value,!1)[0].get("r:id"),fileName:r,readXml:t}),{chartEle:o,chartType:i}=getChartType(t,a),s=this.getChartRange(o),u=generateRandomId();this.image=new LuckyChartImage(u,n,s,i);const c=new Chart({id:u,range:s,chartType:i,chartFile:a,readXml:t,image:this.image,styles:l});this.chart=c.model}}class Chart extends LuckyChart{constructor(e){super(),this.getStyle=e=>{const t=this.readXml.getElementsByTagNameLink("c:spPr",this.chartFile)[0],r=t.getInnerElements("a:solidFill")[0],l=t.getInnerElements("a:ln")[0],n=r?this.getColor(r.getInnerElements("a:schemeClr")[0]):void 0,a=l?this.getColor(l.getInnerElements("a:schemeClr")[0]):void 0,o=this.getAllTitle(),i=this.readXml.getElementsByTagNameLink("c:chart/c:autoTitleDeleted",this.chartFile)[0],s=this.readXml.getElementsByTagNameLink("c:chart/c:plotArea",this.chartFile)[0],u=this.getAxis(s?.getInnerElements("c:catAx")?.[0]),c=this.getAxis(s?.getInnerElements("c:valAx")?.[0]),h=this.readXml.getElementsByTagNameLink("c:chart/c:legend",this.chartFile)[0],g=this.getLegend(h);return{titles:{...o,titlePosition:"1"===i?.get("val")?"hide":"top"},runtime:{},width:e.transform.width,height:e.transform.height,backgroundColor:n,borderColor:a,xAxis:u,yAxis:c,legend:g,...this.getChartSeries()}},this.getChartSeries=()=>{const{chartEle:e,chartType:t}=getChartType(this.readXml,this.chartFile);if(!e)return{};if(Array.isArray(e))return{seriesStyleMap:e.map(e=>this.getChartSeriesBase(e.chartEle,e.chartType,!0)).reduce((e,t)=>Object.assign(e,t),{})};const r=e.getInnerElementsTagLink("c:dLbls")[0].getInnerElements("c:showVal")[0];return{allSeriesStyle:{label:{visible:!!r&&"1"===r.get("val")}},seriesStyleMap:this.getChartSeriesBase(e,t)}},this.getChartSeriesBase=(e,t,r)=>{const l=e.getInnerElements("c:ser"),n={};return l.forEach(e=>{const l=e.getInnerElements("c:idx")[0],a=parseInt(l.get("val"))+1,o=e.getInnerElements("c:spPr")[0],i=o?.getInnerElementsTagLink("a:solidFill")?.[0],s=o?.getInnerElements("a:ln")?.[0],u=this.getColor(i?.getInnerElements("a:schemeClr")?.[0]),c=i?.getInnerElements("a:alpha")?.[0]?.get("val"),h=s?this.getLine(s):void 0,g=e.getInnerElements("c:dLbls")[0],d=g.getInnerElements("c:showVal")?.[0]?.get("val"),m=g.getInnerElements("c:showCatName")?.[0]?.get("val"),f=g.getInnerElements("c:showSerName")?.[0]?.get("val"),p=g.getInnerElements("c:showPercent")?.[0]?.get("val"),E=this.getBaseStyle(g.getInnerElements("a:defRPr")?.[0]),C=0|("1"===d?LabelContentType.Value:0)|("1"===m?LabelContentType.CategoryName:0)|("1"===f?LabelContentType.SeriesName:0)|("1"===p?LabelContentType.Percentage:0),y={border:h,label:{visible:!!C,contentType:C,...E},color:u,fillOpacity:c?parseInt(c)/1e5:1,chartType:r?t:void 0};let T=this.getExtraSerise(y,e,t);n[a]=T}),n},this.getExtraSerise=(e,t,r)=>{if(r===ChartTypeBits.Line){e.border?.color&&(e.color=e.border.colo