excel-builder-vanilla
Version:
An easy way of building Excel files with javascript
4 lines • 54.7 kB
JavaScript
var ExcelBuilder=(function(e,t){var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;l<u;l++)d=c[l],!s.call(e,d)&&d!==n&&r(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e};t=((e,t,i)=>(i=e==null?{}:n(o(e)),c(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e)))(t);function l(e){let t=typeof e;return e!=null&&(t===`object`||t===`function`)}function u(e){if(typeof e!=`object`||!e||Object.prototype.toString.call(e)!==`[object Object]`)return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let n=Object.prototype.hasOwnProperty.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&Function.prototype.call(n)===Function.prototype.call(e)}function d(e){return e!=null&&typeof e.valueOf()==`string`}var f={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`};let p=e=>(typeof e!=`string`&&(e=`${e}`),e.replace(/[&<>"']/g,e=>f[e]));var m=class{documentElement;constructor(e,t){this.documentElement=this.createElement(t),this.documentElement.setAttribute(`xmlns`,e)}createElement(e){return new g({nodeName:e})}createTextNode(e){return new h(e)}toString(){return this.documentElement.toString()}static Node={Create:e=>{switch(e.type){case`XML`:return new g(e);case`TEXT`:return new h(e.nodeValue);default:return null}}}},h=class{nodeValue;constructor(e){this.nodeValue=e}toJSON(){return{nodeValue:this.nodeValue,type:`TEXT`}}toString(){return p(this.nodeValue)}},g=class e{nodeName;children;nodeValue;attributes;firstChild;constructor(e){if(this.nodeName=e.nodeName,this.children=[],this.nodeValue=e.nodeValue||``,this.attributes={},e.children)for(let t=0,n=e.children.length;t<n;t++)this.appendChild(m.Node.Create(e.children[t]));if(e.attributes)for(let[t,n]of Object.entries(e.attributes))this.setAttribute(t,n)}toString(){let e=`<${this.nodeName}`;for(let t in this.attributes)this.attributes.hasOwnProperty(t)&&(e=`${e} ${t}="${p(this.attributes[t])}"`);let t=``;for(let e=0,n=this.children.length;e<n;e++)t+=this.children[e].toString();return t?e+=`>${t}</${this.nodeName}>`:e+=`/>`,e}toJSON(){let e=[];for(let t=0,n=this.children.length;t<n;t++)e.push(this.children[t].toJSON());return{nodeName:this.nodeName,children:e,nodeValue:this.nodeValue,attributes:this.attributes,type:`XML`}}setAttribute(e,t){if(t===null){delete this.attributes[e],delete this[e];return}this.attributes[e]=t,this[e]=t}appendChild(e){this.children.push(e),this.firstChild=this.children[0]}cloneNode(t){return new e(this.toJSON())}},_=class e{static _idSpaces={};static uniqueId(t){return e._idSpaces[t]||(e._idSpaces[t]=1),e._idSpaces[t]++}static createXmlDoc(e,t){return new m(e||null,t)}static createElement(e,t,n){let r=e.createElement(t);n||=[];let i=n.length;for(;i--;)r.setAttribute(n[i][0],n[i][1]);return r}static setAttributesOnDoc(e,t){for(let[n,r]of Object.entries(t)){if(u(r))if(r.v!==null&&r.v!==void 0)switch(r.type){case Boolean:r=r.v?`1`:`0`;break}else r=null;r!=null&&e.setAttribute(n,r)}}static LETTER_REFS={};static positionToLetterRef(t,n){let r=1,i,a=t,o=``;if(e.LETTER_REFS[t])return e.LETTER_REFS[t].concat(n);for(;a>0;)a-=26**(r-1),i=a%26**r,a-=i,i/=26**(r-1),o=`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.charAt(i)+o,r+=1;return e.LETTER_REFS[t]=o,o.concat(String(n))}static schemas={worksheet:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet`,sharedStrings:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings`,stylesheet:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles`,relationships:`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,relationshipPackage:`http://schemas.openxmlformats.org/package/2006/relationships`,contentTypes:`http://schemas.openxmlformats.org/package/2006/content-types`,spreadsheetml:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,markupCompat:`http://schemas.openxmlformats.org/markup-compatibility/2006`,x14ac:`http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac`,officeDocument:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument`,package:`http://schemas.openxmlformats.org/package/2006/relationships`,table:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/table`,spreadsheetDrawing:`http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing`,drawing:`http://schemas.openxmlformats.org/drawingml/2006/main`,drawingRelationship:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,image:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/image`,chart:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart`,hyperlink:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink`}},v=class{x=null;y=null;width=null;height=null;constructor(e){e&&(this.setPos(e.x,e.y),this.setDimensions(e.width||0,e.height||0))}setPos(e,t){this.x=e,this.y=t}setDimensions(e,t){this.width=e,this.height=t}toXML(e,t){let n=_.createElement(e,`xdr:absoluteAnchor`),r=_.createElement(e,`xdr:pos`);r.setAttribute(`x`,this.x),r.setAttribute(`y`,this.y),n.appendChild(r);let i=_.createElement(e,`xdr:ext`);return i.setAttribute(`cx`,this.width),i.setAttribute(`cy`,this.height),n.appendChild(i),n.appendChild(t),n.appendChild(_.createElement(e,`xdr:clientData`)),n}},y={};function b(e=`$lodash$`){y[e]||(y[e]=0);let t=++y[e];return e===`$lodash$`?`${t}`:`${e}${t}`}var x=class{x=null;y=null;xOff=null;yOff=null;width=null;height=null;constructor(e){e&&(this.setPos(e.x,e.y,e.xOff,e.yOff),this.setDimensions(e.width||0,e.height||0))}setPos(e,t,n,r){this.x=e,this.y=t,n!==void 0&&(this.xOff=n),r!==void 0&&(this.yOff=r)}setDimensions(e,t){this.width=e,this.height=t}toXML(e,t){let n=_.createElement(e,`xdr:oneCellAnchor`),r=_.createElement(e,`xdr:from`),i=_.createElement(e,`xdr:col`);i.appendChild(e.createTextNode(String(this.x)));let a=_.createElement(e,`xdr:colOff`);a.appendChild(e.createTextNode(String(this.xOff||0)));let o=_.createElement(e,`xdr:row`);o.appendChild(e.createTextNode(String(this.y)));let s=_.createElement(e,`xdr:rowOff`);s.appendChild(e.createTextNode(String(this.yOff||0))),r.appendChild(i),r.appendChild(a),r.appendChild(o),r.appendChild(s),n.appendChild(r);let c=_.createElement(e,`xdr:ext`);return c.setAttribute(`cx`,String(this.width)),c.setAttribute(`cy`,String(this.height)),n.appendChild(c),n.appendChild(t),n.appendChild(_.createElement(e,`xdr:clientData`)),n}},S=class{from={xOff:0,yOff:0};to={xOff:0,yOff:0};constructor(e){e&&(this.setFrom(e.from.x,e.from.y,e.from.xOff,e.from.yOff),this.setTo(e.to.x,e.to.y,e.to.xOff,e.to.yOff))}setFrom(e,t,n,r){this.from.x=e,this.from.y=t,n!==void 0&&(this.from.xOff=n),r!==void 0&&(this.from.yOff=r)}setTo(e,t,n,r){this.to.x=e,this.to.y=t,n!==void 0&&(this.to.xOff=n),r!==void 0&&(this.to.yOff=r)}toXML(e,t){let n=_.createElement(e,`xdr:twoCellAnchor`),r=_.createElement(e,`xdr:from`),i=_.createElement(e,`xdr:col`);i.appendChild(e.createTextNode(this.from.x));let a=_.createElement(e,`xdr:colOff`);a.appendChild(e.createTextNode(this.from.xOff));let o=_.createElement(e,`xdr:row`);o.appendChild(e.createTextNode(this.from.y));let s=_.createElement(e,`xdr:rowOff`);s.appendChild(e.createTextNode(this.from.yOff)),r.appendChild(i),r.appendChild(a),r.appendChild(o),r.appendChild(s);let c=_.createElement(e,`xdr:to`),l=_.createElement(e,`xdr:col`);l.appendChild(e.createTextNode(this.to.x));let u=_.createElement(e,`xdr:colOff`);u.appendChild(e.createTextNode(this.from.xOff));let d=_.createElement(e,`xdr:row`);d.appendChild(e.createTextNode(this.to.y));let f=_.createElement(e,`xdr:rowOff`);return f.appendChild(e.createTextNode(this.from.yOff)),c.appendChild(l),c.appendChild(u),c.appendChild(d),c.appendChild(f),n.appendChild(r),n.appendChild(c),n.appendChild(t),n.appendChild(_.createElement(e,`xdr:clientData`)),n}},C=class{anchor;id=b(`Drawing`);createAnchor(e,t){switch(t??={},t.drawing=this,e){case`absoluteAnchor`:this.anchor=new v(t);break;case`oneCellAnchor`:this.anchor=new x(t);break;case`twoCellAnchor`:this.anchor=new S(t);break}return this.anchor}},w=class extends C{relId=null;index=null;target=null;options;constructor(e){super(),this.options=e}getMediaType(){return`chart`}setRelationshipId(e){this.relId=e}toXML(e){return this.anchor.toXML(e,this._createGraphicFrame(e))}toChartSpaceXML(){let e=_.createXmlDoc(`http://schemas.openxmlformats.org/drawingml/2006/chart`,`c:chartSpace`),t=e.documentElement;t.setAttribute(`xmlns:c`,`http://schemas.openxmlformats.org/drawingml/2006/chart`),t.setAttribute(`xmlns:a`,_.schemas.drawing),t.setAttribute(`xmlns:r`,_.schemas.relationships);let n=_.createElement(e,`c:chart`);this.options.title?(n.appendChild(this._createTitleNode(e,this.options.title)),n.appendChild(_.createElement(e,`c:autoTitleDeleted`,[[`val`,`0`]]))):n.appendChild(_.createElement(e,`c:autoTitleDeleted`,[[`val`,`1`]]));let r=_.createElement(e,`c:plotArea`),i=this._nextAxisIdBase(),a=i+1,o=i+2,s=this.options.type||`column`,c=this.options.categoriesRange||``,l=this._createPrimaryChartNode(e,s,this.options.stacking),u=this.options.series||[];u.forEach((t,n)=>{l.appendChild(this._createSeriesNode(e,t,n,s,c))});let d=this.options.dataLabels;if(d){let t=_.createElement(e,`c:dLbls`),n=(n,r)=>t.appendChild(_.createElement(e,n,[[`val`,r===!0?`1`:`0`]]));n(`c:showVal`,d.showValue),n(`c:showCatName`,d.showCategory),n(`c:showPercent`,d.showPercent),n(`c:showSerName`,d.showSeriesName),l.appendChild(t)}if(s!==`pie`&&s!==`doughnut`&&(l.appendChild(_.createElement(e,`c:axId`,[[`val`,String(a)]])),l.appendChild(_.createElement(e,`c:axId`,[[`val`,String(o)]]))),r.appendChild(l),s!==`pie`&&s!==`doughnut`){let t=this.options.axis?.x,n=this.options.axis?.y,i=t?.title,c=n?.title;s===`scatter`?(r.appendChild(this._createValueAxis(e,a,o,`b`,i,t)),r.appendChild(this._createValueAxis(e,o,a,`l`,c,n))):(r.appendChild(this._createCategoryAxis(e,a,o,i,t)),r.appendChild(this._createValueAxis(e,o,a,`l`,c,n)))}let f=this.options.legend,p=u.length>1;return(typeof f?.show==`boolean`?f.show:p)&&n.appendChild(this._createLegendNode(e,f)),n.appendChild(r),n.appendChild(_.createElement(e,`c:plotVisOnly`,[[`val`,`1`]])),t.appendChild(n),t.appendChild(_.createElement(e,`c:printSettings`)),e}_createGraphicFrame(e){let t=_.createElement(e,`xdr:graphicFrame`),n=_.createElement(e,`xdr:nvGraphicFramePr`);n.appendChild(_.createElement(e,`xdr:cNvPr`,[[`id`,String(this.index||1)],[`name`,this.options.title||`Chart`]])),n.appendChild(_.createElement(e,`xdr:cNvGraphicFramePr`)),t.appendChild(n);let r=_.createElement(e,`xdr:xfrm`);r.appendChild(_.createElement(e,`a:off`,[[`x`,`0`],[`y`,`0`]])),r.appendChild(_.createElement(e,`a:ext`,[[`cx`,String(this.options.width||4e6)],[`cy`,String(this.options.height||3e6)]])),t.appendChild(r);let i=_.createElement(e,`a:graphic`),a=_.createElement(e,`a:graphicData`,[[`uri`,`http://schemas.openxmlformats.org/drawingml/2006/chart`]]);return a.appendChild(_.createElement(e,`c:chart`,[[`xmlns:c`,`http://schemas.openxmlformats.org/drawingml/2006/chart`],[`xmlns:r`,_.schemas.relationships],[`r:id`,this.relId||``]])),i.appendChild(a),t.appendChild(i),t}_createPrimaryChartNode(e,t,n){let r,i=this._resolveGrouping(t,n);switch(t){case`line`:r=_.createElement(e,`c:lineChart`),r.appendChild(_.createElement(e,`c:grouping`,[[`val`,i]])),r.appendChild(_.createElement(e,`c:varyColors`,[[`val`,`0`]]));break;case`pie`:r=_.createElement(e,`c:pieChart`),r.appendChild(_.createElement(e,`c:grouping`,[[`val`,`clustered`]])),r.appendChild(_.createElement(e,`c:varyColors`,[[`val`,`1`]]));break;case`doughnut`:r=_.createElement(e,`c:doughnutChart`),r.appendChild(_.createElement(e,`c:grouping`,[[`val`,`clustered`]])),r.appendChild(_.createElement(e,`c:varyColors`,[[`val`,`1`]])),r.appendChild(_.createElement(e,`c:holeSize`,[[`val`,`50`]]));break;case`scatter`:r=_.createElement(e,`c:scatterChart`),r.appendChild(_.createElement(e,`c:scatterStyle`,[[`val`,`marker`]])),r.appendChild(_.createElement(e,`c:varyColors`,[[`val`,`0`]]));break;case`bar`:r=_.createElement(e,`c:barChart`),r.appendChild(_.createElement(e,`c:barDir`,[[`val`,`bar`]])),r.appendChild(_.createElement(e,`c:grouping`,[[`val`,i]])),n&&r.appendChild(_.createElement(e,`c:overlap`,[[`val`,`100`]])),r.appendChild(_.createElement(e,`c:varyColors`,[[`val`,`0`]]));break;case`column`:default:r=_.createElement(e,`c:barChart`),r.appendChild(_.createElement(e,`c:barDir`,[[`val`,`col`]])),r.appendChild(_.createElement(e,`c:grouping`,[[`val`,i]])),n&&r.appendChild(_.createElement(e,`c:overlap`,[[`val`,`100`]])),r.appendChild(_.createElement(e,`c:varyColors`,[[`val`,`0`]]));break}return r}_createSeriesNode(e,t,n,r,i){let a=_.createElement(e,`c:ser`),o=String(n);a.appendChild(_.createElement(e,`c:idx`,[[`val`,o]])),a.appendChild(_.createElement(e,`c:order`,[[`val`,o]]));let s=_.createElement(e,`c:tx`),c=_.createElement(e,`c:v`);if(c.appendChild(e.createTextNode(t.name)),s.appendChild(c),a.appendChild(s),r===`scatter`){let n=_.createElement(e,`c:xVal`);if(t.scatterXRange){let r=_.createElement(e,`c:numRef`),i=_.createElement(e,`c:f`);i.appendChild(e.createTextNode(t.scatterXRange)),r.appendChild(i),n.appendChild(r)}else{let t=_.createElement(e,`c:numLit`);t.appendChild(_.createElement(e,`c:ptCount`,[[`val`,`0`]])),n.appendChild(t)}a.appendChild(n);let r=_.createElement(e,`c:yVal`),i=_.createElement(e,`c:numRef`),o=_.createElement(e,`c:f`);o.appendChild(e.createTextNode(t.valuesRange)),i.appendChild(o),r.appendChild(i),a.appendChild(r)}else{if(i){let t=_.createElement(e,`c:cat`),n=_.createElement(e,`c:strRef`),r=_.createElement(e,`c:f`);r.appendChild(e.createTextNode(i)),n.appendChild(r),t.appendChild(n),a.appendChild(t)}if(t.valuesRange){let n=_.createElement(e,`c:val`),r=_.createElement(e,`c:numRef`),i=_.createElement(e,`c:f`);i.appendChild(e.createTextNode(t.valuesRange)),r.appendChild(i),n.appendChild(r),a.appendChild(n)}}return this._applySeriesColor(e,a,r,t.color),a}_applySeriesColor(e,t,n,r){if(!r||typeof r!=`string`)return;let i=r.trim().replace(/^#/,``).toUpperCase();if(/^[0-9A-F]{8}$/.test(i))i=i.slice(2);else if(!/^[0-9A-F]{6}$/.test(i))return;let a=_.createElement(e,`c:spPr`);if(n===`line`||n===`scatter`){let t=_.createElement(e,`a:ln`),n=_.createElement(e,`a:solidFill`);n.appendChild(_.createElement(e,`a:srgbClr`,[[`val`,i]])),t.appendChild(n),a.appendChild(t)}else if(n!==`pie`&&n!==`doughnut`){let t=_.createElement(e,`a:solidFill`);t.appendChild(_.createElement(e,`a:srgbClr`,[[`val`,i]])),a.appendChild(t)}else return;t.appendChild(a)}_createLegendNode(e,t){let n=_.createElement(e,`c:legend`),r={right:`r`,left:`l`,top:`t`,bottom:`b`,topRight:`tr`}[t?.position||`right`]||`r`;return n.appendChild(_.createElement(e,`c:legendPos`,[[`val`,r]])),n.appendChild(_.createElement(e,`c:layout`)),n.appendChild(_.createElement(e,`c:overlay`,[[`val`,t?.overlay?`1`:`0`]])),n}_createTitleNode(e,t){let n=_.createElement(e,`c:title`),r=_.createElement(e,`c:tx`),i=_.createElement(e,`c:rich`);i.appendChild(_.createElement(e,`a:bodyPr`)),i.appendChild(_.createElement(e,`a:lstStyle`));let a=_.createElement(e,`a:p`),o=_.createElement(e,`a:r`),s=_.createElement(e,`a:rPr`,[[`lang`,`en-US`]]);o.appendChild(s);let c=_.createElement(e,`a:t`);return c.appendChild(e.createTextNode(t)),o.appendChild(c),a.appendChild(o),a.appendChild(_.createElement(e,`a:endParaRPr`,[[`lang`,`en-US`]])),i.appendChild(a),r.appendChild(i),n.appendChild(r),n.appendChild(_.createElement(e,`c:layout`)),n.appendChild(_.createElement(e,`c:overlay`,[[`val`,`0`]])),n}_createCategoryAxis(e,t,n,r,i){let a=_.createElement(e,`c:catAx`);a.appendChild(_.createElement(e,`c:axId`,[[`val`,String(t)]]));let o=_.createElement(e,`c:scaling`);return o.appendChild(_.createElement(e,`c:orientation`,[[`val`,`minMax`]])),a.appendChild(o),a.appendChild(_.createElement(e,`c:delete`,[[`val`,`0`]])),a.appendChild(_.createElement(e,`c:axPos`,[[`val`,`b`]])),a.appendChild(_.createElement(e,`c:tickLblPos`,[[`val`,`nextTo`]])),a.appendChild(_.createElement(e,`c:crossAx`,[[`val`,String(n)]])),a.appendChild(_.createElement(e,`c:crosses`,[[`val`,`autoZero`]])),i?.showGridLines&&a.appendChild(_.createElement(e,`c:majorGridlines`)),r&&a.appendChild(this._createTitleNode(e,r)),a}_createValueAxis(e,t,n,r,i,a){let o=_.createElement(e,`c:valAx`);o.appendChild(_.createElement(e,`c:axId`,[[`val`,String(t)]]));let s=_.createElement(e,`c:scaling`);return s.appendChild(_.createElement(e,`c:orientation`,[[`val`,`minMax`]])),typeof a?.minimum==`number`&&s.appendChild(_.createElement(e,`c:min`,[[`val`,String(a.minimum)]])),typeof a?.maximum==`number`&&s.appendChild(_.createElement(e,`c:max`,[[`val`,String(a.maximum)]])),o.appendChild(s),o.appendChild(_.createElement(e,`c:delete`,[[`val`,`0`]])),o.appendChild(_.createElement(e,`c:axPos`,[[`val`,r]])),o.appendChild(_.createElement(e,`c:crossAx`,[[`val`,String(n)]])),o.appendChild(_.createElement(e,`c:crosses`,[[`val`,`autoZero`]])),o.appendChild(_.createElement(e,`c:crossBetween`,[[`val`,`between`]])),a?.showGridLines&&o.appendChild(_.createElement(e,`c:majorGridlines`)),i&&o.appendChild(this._createTitleNode(e,i)),o}_nextAxisIdBase(){return(this.index||1)*1e3}_resolveGrouping(e,t){return e===`pie`||e===`doughnut`?`clustered`:e===`line`?t===`stacked`?`stacked`:t===`percent`?`percentStacked`:`standard`:e===`bar`||e===`column`?t===`stacked`?`stacked`:t===`percent`?`percentStacked`:`clustered`:`standard`}},T=class extends C{id=b(`Picture`);pictureId=_.uniqueId(`Picture`);fill={};mediaData=null;description=``;constructor(){super(),this.id=b(`Picture`),this.pictureId=_.uniqueId(`Picture`)}setMedia(e){this.mediaData=e}setDescription(e){this.description=e}setFillType(e){this.fill.type=e}setFillConfig(e){Object.assign(this.fill,e)}getMediaType(){return`image`}getMediaData(){return this.mediaData}setRelationshipId(e){this.mediaData.rId=e}toXML(e){let t=_.createElement(e,`xdr:pic`),n=_.createElement(e,`xdr:nvPicPr`),r=_.createElement(e,`xdr:cNvPr`,[[`id`,this.pictureId],[`name`,this.mediaData.fileName],[`descr`,this.description||``]]);n.appendChild(r);let i=_.createElement(e,`xdr:cNvPicPr`);i.appendChild(_.createElement(e,`a:picLocks`,[[`noChangeAspect`,`1`],[`noChangeArrowheads`,`1`]])),n.appendChild(i),t.appendChild(n);let a=_.createElement(e,`xdr:blipFill`);a.appendChild(_.createElement(e,`a:blip`,[[`xmlns:r`,_.schemas.relationships],[`r:embed`,this.mediaData.rId]])),a.appendChild(_.createElement(e,`a:srcRect`));let o=_.createElement(e,`a:stretch`);o.appendChild(_.createElement(e,`a:fillRect`)),a.appendChild(o),t.appendChild(a);let s=_.createElement(e,`xdr:spPr`,[[`bwMode`,`auto`]]),c=_.createElement(e,`a:xfrm`);s.appendChild(c);let l=_.createElement(e,`a:prstGeom`,[[`prst`,`rect`]]);return s.appendChild(l),t.appendChild(s),this.anchor.toXML(e,t)}};let E={};var D=class{relations={};lastId=1;constructor(){b(`rId`)}importData(e){this.relations=e.relations,this.lastId=e.lastId}exportData(){return{relations:this.relations,lastId:this.lastId}}addRelation(e,t){return this.relations[e.id]={id:b(`rId`),schema:_.schemas[t],object:e},this.relations[e.id].id}getRelationshipId(e){return this.relations[e.id]?this.relations[e.id].id:null}toXML(){let e=_.createXmlDoc(_.schemas.relationshipPackage,`Relationships`),t=e.documentElement;for(let[n,r]of Object.entries(this.relations)){let i=_.createElement(e,`Relationship`,[[`Id`,r.id],[`Type`,r.schema],[`Target`,r.object.target||E[n]]]);r.object.targetMode&&i.setAttribute(`TargetMode`,r.object.targetMode),t.appendChild(i)}return e}},O=class{drawings=[];relations=new D;id=b(`Drawings`);addDrawing(e){this.drawings.push(e)}getCount(){return this.drawings.length}toXML(){let e=_.createXmlDoc(_.schemas.spreadsheetDrawing,`xdr:wsDr`),t=e.documentElement;t.setAttribute(`xmlns:a`,_.schemas.drawing),t.setAttribute(`xmlns:r`,_.schemas.relationships),t.setAttribute(`xmlns:xdr`,_.schemas.spreadsheetDrawing);for(let n=0,r=this.drawings.length;n<r;n++){let r=this.drawings[n];if(r instanceof T){let n=this.relations.getRelationshipId(r.getMediaData());n||=this.relations.addRelation(r.getMediaData(),r.getMediaType()),r.setRelationshipId(n),t.appendChild(r.toXML(e))}else if(r instanceof w){let n=this.relations.getRelationshipId(r);n||=this.relations.addRelation(r,r.getMediaType()),r.setRelationshipId(n),t.appendChild(r.toXML(e))}}return e}},k=class{state=null;xSplit=null;ySplit=null;activePane=`bottomRight`;topLeftCell=null;_freezePane;freezePane(e,t,n){this._freezePane={xSplit:e,ySplit:t,cell:n}}exportXML(e){let t=e.createElement(`pane`);return this.state!==null&&(t.setAttribute(`xSplit`,this._freezePane.xSplit),t.setAttribute(`ySplit`,this._freezePane.ySplit),t.setAttribute(`topLeftCell`,this._freezePane.cell),t.setAttribute(`activePane`,`bottomRight`),t.setAttribute(`state`,`frozen`)),t}},A=class{static pixelsToEMUs(e){return Math.round(e*914400/96)}},j=class{strings={};stringArray=[];id=b(`SharedStrings`);addString(e){return this.strings[e]=this.stringArray.length,this.stringArray[this.stringArray.length]=e,this.strings[e]}exportData(){return this.strings}toXML(){let e=_.createXmlDoc(_.schemas.spreadsheetml,`sst`),t=e.documentElement;this.stringArray.reverse();let n=this.stringArray.length;t.setAttribute(`count`,n),t.setAttribute(`uniqueCount`,n);let r=e.createElement(`si`),i=e.createElement(`t`);i.appendChild(e.createTextNode(`--placeholder--`)),r.appendChild(i);let a=this.stringArray;for(;n--;){let e=r.cloneNode(!0);typeof a[n]==`string`&&a[n].match(/\s+/)&&e.firstChild.setAttribute(`xml:space`,`preserve`),e.firstChild.firstChild.nodeValue=a[n],t.appendChild(e)}return e}},M=class{pane;showZeros=null;defaultGridColor=null;colorId=null;rightToLeft=null;showFormulas=null;showGridLines=null;showOutlineSymbols=null;showRowColHeaders=null;showRuler=null;showWhiteSpace=null;tabSelected=null;topLeftCell=null;viewType=null;windowProtection=null;zoomScale=null;zoomScaleNormal=null;zoomScalePageLayoutView=null;zoomScaleSheetLayoutView=null;constructor(e){this.pane=(e||{}).pane||new k}freezePane(e,t,n){this.pane.state=`frozen`,this.pane.xSplit=e,this.pane.ySplit=t,this.pane.topLeftCell=n}exportXML(e){let t=e.createElement(`sheetViews`),n=e.createElement(`sheetView`);return _.setAttributesOnDoc(n,{workbookViewId:0,showZeros:{v:this.showZeros,type:Boolean},defaultGridColor:{v:this.defaultGridColor,type:Boolean},colorId:this.colorId,rightToLeft:{v:this.rightToLeft,type:Boolean},showFormulas:{v:this.showFormulas,type:Boolean},showGridLines:{v:this.showGridLines,type:Boolean},showOutlineSymbols:{v:this.showOutlineSymbols,type:Boolean},showRowColHeaders:{v:this.showRowColHeaders,type:Boolean},showRuler:{v:this.showRuler,type:Boolean},showWhiteSpace:{v:this.showWhiteSpace,type:Boolean},tabSelected:{v:this.tabSelected,type:Boolean},viewType:this.viewType,windowProtection:{v:this.windowProtection,type:Boolean},zoomScale:{v:this.zoomScale,type:Boolean},zoomScaleNormal:this.zoomScaleNormal,zoomScalePageLayoutView:this.zoomScalePageLayoutView,zoomScaleSheetLayoutView:this.zoomScaleSheetLayoutView}),n.appendChild(this.pane.exportXML(e)),t.appendChild(n),t}};function N(e,t){return t.reduce((t,n)=>(e?.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var P=class{id=b(`StyleSheet`);cellStyles=[{name:`Normal`,xfId:`0`,builtinId:`0`}];defaultTableStyle=!1;differentialStyles=[{}];masterCellFormats=[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfid:0}];masterCellStyles=[{numFmtId:0,fontId:0,fillId:0,borderId:0}];fonts=[{}];numberFormatters=[];fills=[{},{type:`pattern`,patternType:`gray125`,fgColor:`FF333333`,bgColor:`FF333333`}];borders=[{top:{},left:{},right:{},bottom:{},diagonal:{}}];tableStyles=[];createSimpleFormatter(e){let t={id:this.masterCellFormats.length};switch(e){case`date`:t.numFmtId=14;break}return this.masterCellFormats.push(t),t}createFill(e){let t=this.fills.length,n=e;return n.id=t,this.fills.push(n),n}createNumberFormatter(e){let t={id:this.numberFormatters.length+100,formatCode:e};return this.numberFormatters.push(t),t}createFormat(e){let t={id:this.masterCellFormats.length};if(e.protection&&(t.protection=e.protection),e.font&&l(e.font))t.fontId=this.createFontStyle(e.font).id;else if(e.font){if(Number.isNaN(Number.parseInt(e.font,10)))throw Error(`Passing a non-numeric font id is not supported`);t.fontId=e.font}if(e.format&&d(e.format))t.numFmtId=this.createNumberFormatter(e.format).id;else if(e.format){if(Number.isNaN(Number.parseInt(e.format,10)))throw Error(`Invalid number formatter id`);t.numFmtId=e.format}if(e.border&&l(e.border))t.borderId=this.createBorderFormatter(e.border).id;else if(e.border){if(Number.isNaN(Number.parseInt(e.border,10)))throw Error(`Passing a non-numeric border id is not supported`);t.borderId=e.border}if(e.fill&&l(e.fill))t.fillId=this.createFill(e.fill).id;else if(e.fill){if(Number.isNaN(Number.parseInt(e.fill,10)))throw Error(`Passing a non-numeric fill id is not supported`);t.fillId=e.fill}return e.alignment&&l(e.alignment)&&(t.alignment=N(e.alignment,[`horizontal`,`justifyLastLine`,`readingOrder`,`relativeIndent`,`shrinkToFit`,`textRotation`,`vertical`,`wrapText`])),this.masterCellFormats.push(t),t}createDifferentialStyle(e){let t=this.differentialStyles.length,n={id:t};return e.font&&l(e.font)&&(n.font=e.font),e.border&&l(e.border)&&(n.border=Object.assign({top:{},left:{},right:{},bottom:{},diagonal:{}},e.border)),e.fill&&l(e.fill)&&(n.fill=e.fill),e.alignment&&l(e.alignment)&&(n.alignment=e.alignment),e.format&&d(e.format)&&(n.numFmt=e.format),this.differentialStyles[t]=n,n}createTableStyle(e){this.tableStyles.push(e)}createBorderFormatter(e){return e={top:{},left:{},right:{},bottom:{},diagonal:{},id:this.borders.length,...e},this.borders.push(e),e}createFontStyle(e){let t={id:this.fonts.length};return e.bold&&(t.bold=!0),e.italic&&(t.italic=!0),e.superscript&&(t.vertAlign=`superscript`),e.subscript&&(t.vertAlign=`subscript`),e.underline&&(typeof e.underline==`string`&&[`double`,`singleAccounting`,`doubleAccounting`].includes(e.underline)?t.underline=e.underline:t.underline=!0),e.strike&&(t.strike=!0),e.outline&&(t.outline=!0),e.shadow&&(t.shadow=!0),e.size&&(t.size=e.size),e.color&&(t.color=e.color),e.fontName&&(t.fontName=e.fontName),this.fonts.push(t),t}exportBorders(e){let t=e.createElement(`borders`);t.setAttribute(`count`,this.borders.length);for(let n=0,r=this.borders.length;n<r;n++)t.appendChild(this.exportBorder(e,this.borders[n]));return t}exportBorder(e,t){let n=e.createElement(`border`),r=n=>{let r=e.createElement(n);return t[n].style&&r.setAttribute(`style`,t[n].style),t[n].color&&r.appendChild(this.exportColor(e,t[n].color)),r};return n.appendChild(r(`left`)),n.appendChild(r(`right`)),n.appendChild(r(`top`)),n.appendChild(r(`bottom`)),n.appendChild(r(`diagonal`)),n}exportColor(e,t){let n=e.createElement(`color`);return d(t)?(n.setAttribute(`rgb`,t),n):(t.tint!==void 0&&n.setAttribute(`tint`,t.tint),t.auto!==void 0&&n.setAttribute(`auto`,String(!!t.auto)),t.theme!==void 0&&n.setAttribute(`theme`,t.theme),n)}exportMasterCellFormats(e){let t=_.createElement(e,`cellXfs`,[[`count`,this.masterCellFormats.length]]);for(let n=0,r=this.masterCellFormats.length;n<r;n++){let r=this.masterCellFormats[n];t.appendChild(this.exportCellFormatElement(e,r))}return t}exportMasterCellStyles(e){let t=_.createElement(e,`cellStyleXfs`,[[`count`,this.masterCellStyles.length]]);for(let n=0,r=this.masterCellStyles.length;n<r;n++){let r=this.masterCellStyles[n];t.appendChild(this.exportCellFormatElement(e,r))}return t}exportCellFormatElement(e,t){let n=e.createElement(`xf`),r=[`applyAlignment`,`applyBorder`,`applyFill`,`applyFont`,`applyNumberFormat`,`applyProtection`,`borderId`,`fillId`,`fontId`,`numFmtId`,`pivotButton`,`quotePrefix`,`xfId`],i=Object.keys(t).filter(e=>r.indexOf(e)!==-1);if(t.alignment){let r=t.alignment;n.appendChild(this.exportAlignment(e,r))}t.protection&&(n.appendChild(this.exportProtection(e,t.protection)),n.setAttribute(`applyProtection`,`1`));let a=i.length;for(;a--;)n.setAttribute(i[a],t[i[a]]);return t.fillId&&n.setAttribute(`applyFill`,`1`),t.fontId&&n.setAttribute(`applyFont`,`1`),t.borderId&&n.setAttribute(`applyBorder`,`1`),t.alignment&&n.setAttribute(`applyAlignment`,`1`),t.numFmtId&&n.setAttribute(`applyNumberFormat`,`1`),t.numFmtId!==void 0&&t.xfId===void 0&&n.setAttribute(`xfId`,`0`),n}exportAlignment(e,t){let n=e.createElement(`alignment`),r=Object.keys(t);for(let e=0,i=r.length;e<i;e++)n.setAttribute(r[e],t[r[e]]);return n}exportFonts(e){let t=e.createElement(`fonts`);t.setAttribute(`count`,String(this.fonts.length));for(let n=0,r=this.fonts.length;n<r;n++){let r=this.fonts[n];t.appendChild(this.exportFont(e,r))}return t}exportFont(e,t){let n=e.createElement(`font`);if(t.size){let r=e.createElement(`sz`);r.setAttribute(`val`,t.size),n.appendChild(r)}if(t.fontName){let r=e.createElement(`name`);r.setAttribute(`val`,t.fontName),n.appendChild(r)}if(t.bold&&n.appendChild(e.createElement(`b`)),t.italic&&n.appendChild(e.createElement(`i`)),t.vertAlign){let r=e.createElement(`vertAlign`);r.setAttribute(`val`,t.vertAlign),n.appendChild(r)}if(t.underline){let r=e.createElement(`u`);t.underline!==!0&&r.setAttribute(`val`,t.underline),n.appendChild(r)}return t.strike&&n.appendChild(e.createElement(`strike`)),t.shadow&&n.appendChild(e.createElement(`shadow`)),t.outline&&n.appendChild(e.createElement(`outline`)),t.color&&n.appendChild(this.exportColor(e,t.color)),n}exportFills(e){let t=e.createElement(`fills`);t.setAttribute(`count`,String(this.fills.length));for(let n=0,r=this.fills.length;n<r;n++){let r=this.fills[n];t.appendChild(this.exportFill(e,r))}return t}exportFill(e,t){let n,r=e.createElement(`fill`);return t.type===`pattern`?(n=this.exportPatternFill(e,t),r.appendChild(n)):t.type===`gradient`&&(n=this.exportGradientFill(e,t),r.appendChild(n)),r}exportGradientFill(e,t){let n=e.createElement(`gradientFill`);t.degree?n.setAttribute(`degree`,t.degree):t.left&&(n.setAttribute(`left`,t.left),n.setAttribute(`right`,t.right),n.setAttribute(`top`,t.top),n.setAttribute(`bottom`,t.bottom));let r=e.createElement(`stop`);r.setAttribute(`position`,t.start.pureAt||0);let i=e.createElement(`color`);typeof t.start==`string`||t.start.color?i.setAttribute(`rgb`,t.start.color||t.start):t.start.theme&&i.setAttribute(`theme`,t.start.theme);let a=e.createElement(`stop`),o=e.createElement(`color`);return a.setAttribute(`position`,t.end.pureAt||1),typeof t.start==`string`||t.end.color?o.setAttribute(`rgb`,t.end.color||t.end):t.end.theme&&o.setAttribute(`theme`,t.end.theme),r.appendChild(i),a.appendChild(o),n.appendChild(r),n.appendChild(a),n}exportPatternFill(e,t){let n=_.createElement(e,`patternFill`,[[`patternType`,t.patternType]]);t.bgColor||=`FFFFFFFF`,t.fgColor||=`FFFFFFFF`;let r=e.createElement(`bgColor`);d(t.bgColor)?r.setAttribute(`rgb`,t.bgColor):t.bgColor.theme?r.setAttribute(`theme`,t.bgColor.theme):r.setAttribute(`rgb`,t.bgColor.rbg);let i=e.createElement(`fgColor`);return d(t.fgColor)?i.setAttribute(`rgb`,t.fgColor):t.fgColor.theme?i.setAttribute(`theme`,t.fgColor.theme):i.setAttribute(`rgb`,t.fgColor.rbg),n.appendChild(i),n.appendChild(r),n}exportNumberFormatters(e){let t=e.createElement(`numFmts`);t.setAttribute(`count`,String(this.numberFormatters.length));for(let n=0,r=this.numberFormatters.length;n<r;n++){let r=this.numberFormatters[n];t.appendChild(this.exportNumberFormatter(e,r))}return t}exportNumberFormatter(e,t){let n=e.createElement(`numFmt`);return n.setAttribute(`numFmtId`,t.id),n.setAttribute(`formatCode`,t.formatCode),n}exportCellStyles(e){let t=e.createElement(`cellStyles`);t.setAttribute(`count`,String(this.cellStyles.length));for(let n=0,r=this.cellStyles.length;n<r;n++){let r=this.cellStyles[n];delete r.id;let i=_.createElement(e,`cellStyle`);t.appendChild(i);let a=Object.keys(r),o=a.length;for(;o--;)i.setAttribute(a[o],r[a[o]])}return t}exportDifferentialStyles(e){let t=e.createElement(`dxfs`);t.setAttribute(`count`,String(this.differentialStyles.length));for(let n=0,r=this.differentialStyles.length;n<r;n++){let r=this.differentialStyles[n];t.appendChild(this.exportDFX(e,r))}return t}exportDFX(e,t){let n=e.createElement(`dxf`);return t.font&&n.appendChild(this.exportFont(e,t.font)),t.fill&&n.appendChild(this.exportFill(e,t.fill)),t.border&&n.appendChild(this.exportBorder(e,t.border)),t.numFmt&&n.appendChild(this.exportNumberFormatter(e,t.numFmt)),t.alignment&&n.appendChild(this.exportAlignment(e,t.alignment)),n}exportTableStyles(e){let t=e.createElement(`tableStyles`);t.setAttribute(`count`,String(this.tableStyles.length)),this.defaultTableStyle&&t.setAttribute(`defaultTableStyle`,String(this.defaultTableStyle));for(let n=0,r=this.tableStyles.length;n<r;n++)t.appendChild(this.exportTableStyle(e,this.tableStyles[n]));return t}exportTableStyle(e,t){let n=e.createElement(`tableStyle`);n.setAttribute(`name`,t.name),n.setAttribute(`pivot`,`0`);let r=0;return Object.entries(t).forEach(([t,i])=>{if(t===`name`)return;r++;let a=e.createElement(`tableStyleElement`);a.setAttribute(`type`,t),a.setAttribute(`dxfId`,i),n.appendChild(a)}),n.setAttribute(`count`,String(r)),n}exportProtection(e,t){let n=e.createElement(`protection`);for(let e in t)e in t&&n.setAttribute(e,t[e]);return n}toXML(){let e=_.createXmlDoc(_.schemas.spreadsheetml,`styleSheet`),t=e.documentElement;return t.appendChild(this.exportNumberFormatters(e)),t.appendChild(this.exportFonts(e)),t.appendChild(this.exportFills(e)),t.appendChild(this.exportBorders(e)),t.appendChild(this.exportMasterCellStyles(e)),t.appendChild(this.exportMasterCellFormats(e)),t.appendChild(this.exportCellStyles(e)),t.appendChild(this.exportDifferentialStyles(e)),this.tableStyles.length&&t.appendChild(this.exportTableStyles(e)),e}},F=class{name=``;id=``;tableId=``;displayName=``;dataCellStyle=null;dataDfxId=null;headerRowBorderDxfId=null;headerRowCellStyle=null;headerRowCount=1;headerRowDxfId=null;insertRow=!1;insertRowShift=!1;ref=null;tableBorderDxfId=null;totalsRowBorderDxfId=null;totalsRowCellStyle=null;totalsRowCount=0;totalsRowDxfId=null;tableColumns=[];autoFilter=null;sortState=null;styleInfo={};constructor(e){this.initialize(e)}initialize(e){this.displayName=b(`Table`),this.name=this.displayName,this.id=this.name,this.tableId=this.id.replace(`Table`,``),e&&Object.assign(this,e)}setReferenceRange(e,t){this.ref=[e,t]}setTableColumns(e){e.forEach(e=>{this.addTableColumn(e)})}addTableColumn(e){let t=d(e)?{name:e}:e;if(!t.name)throw Error(`Invalid argument for addTableColumn - minimum requirement is a name property`);this.tableColumns.push(t)}setSortState(e){this.sortState=e}toXML(){if(!this.ref)throw Error(`Needs at least a reference range`);let e=_.createXmlDoc(_.schemas.spreadsheetml,`table`),t=e.documentElement;t.setAttribute(`id`,this.tableId),t.setAttribute(`name`,this.name),t.setAttribute(`displayName`,this.displayName);let n=this.ref[0],r=this.ref[1];return t.setAttribute(`ref`,`${_.positionToLetterRef(n[0],n[1])}:${_.positionToLetterRef(r[0],r[1])}`),t.setAttribute(`totalsRowCount`,String(this.totalsRowCount)),t.setAttribute(`headerRowCount`,String(this.headerRowCount)),this.headerRowDxfId&&t.setAttribute(`headerRowDxfId`,String(this.headerRowDxfId)),this.headerRowBorderDxfId&&t.setAttribute(`headerRowBorderDxfId`,String(this.headerRowBorderDxfId)),this.autoFilter||this.addAutoFilter(this.ref[0],this.ref[1]),t.appendChild(this.exportAutoFilter(e)),t.appendChild(this.exportTableColumns(e)),t.appendChild(this.exportTableStyleInfo(e)),e}exportTableColumns(e){let t=e.createElement(`tableColumns`);t.setAttribute(`count`,String(this.tableColumns.length));for(let n=0,r=this.tableColumns.length;n<r;n++){let r=this.tableColumns[n],i=e.createElement(`tableColumn`);i.setAttribute(`id`,String(n+1)),i.setAttribute(`name`,r.name),r.totalsRowFunction&&i.setAttribute(`totalsRowFunction`,r.totalsRowFunction),r.totalsRowLabel&&i.setAttribute(`totalsRowLabel`,r.totalsRowLabel),t.appendChild(i)}return t}exportAutoFilter(e){let t=e.createElement(`autoFilter`);if(this.autoFilter){let e=this.autoFilter[0],n=this.autoFilter[1];t.setAttribute(`ref`,`${_.positionToLetterRef(e[0],e[1])}:${_.positionToLetterRef(n[0],n[1]-this.totalsRowCount)}`)}return t}exportTableStyleInfo(e){let t=this.styleInfo,n=e.createElement(`tableStyleInfo`);return n.setAttribute(`name`,t.themeStyle??``),n.setAttribute(`showFirstColumn`,t.showFirstColumn?`1`:`0`),n.setAttribute(`showLastColumn`,t.showLastColumn?`1`:`0`),n.setAttribute(`showColumnStripes`,t.showColumnStripes?`1`:`0`),n.setAttribute(`showRowStripes`,t.showRowStripes?`1`:`0`),n}addAutoFilter(e,t){this.autoFilter=[e,t]}},I=class{name=``;id=b(`Worksheet`);_timezoneOffset;relations=null;columnFormats=[];data=[];mergedCells=[];columns=[];sheetProtection=!1;_headers=[];_footers=[];_tables=[];_drawings=[];_orientation;_margin;_rowInstructions={};_freezePane={};sharedStrings=null;hyperlinks=[];sheetView;showZeros=null;constructor(e){this._timezoneOffset=new Date().getTimezoneOffset()*60*1e3,this.sheetView=e.sheetView||new M,this.initialize(e)}initialize(e){e||={},this.name=e.name,this.id=b(`Worksheet`),this._timezoneOffset=new Date().getTimezoneOffset()*60*1e3,e.columns&&this.setColumns(e.columns),this.relations=new D}exportData(){return{relations:this.relations?.exportData(),columnFormats:this.columnFormats,data:this.data,columns:this.columns,mergedCells:this.mergedCells,_headers:this._headers,_footers:this._footers,_tables:this._tables,_rowInstructions:this._rowInstructions,_freezePane:this._freezePane,name:this.name,id:this.id}}importData(e){this.relations?.importData(e.relations),delete e.relations,Object.assign(this,e)}setSharedStringCollection(e){this.sharedStrings=e}addTable(e){this._tables.push(e),this.relations?.addRelation(e,`table`)}addDrawings(e){this._drawings.push(e),this.relations?.addRelation(e,`drawingRelationship`)}setRowInstructions(e,t){this._rowInstructions[e]=t}setHeader(e){if(!Array.isArray(e))throw Error(`Invalid argument type - setHeader expects an array of three instructions`);this._headers=e}setFooter(e){if(!Array.isArray(e))throw Error(`Invalid argument type - setFooter expects an array of three instructions`);this._footers=e}compilePageDetailPackage(e){return e||=``,[`&L`,this.compilePageDetailPiece(e[0]||``),`&C`,this.compilePageDetailPiece(e[1]||``),`&R`,this.compilePageDetailPiece(e[2]||``)].join(``)}compilePageDetailPiece(e){if(d(e))return`&"-,Regular"${e}`;if(l(e)&&!Array.isArray(e)){let t=``;if(e.font||e.bold){let n=e.bold?`Bold`:`Regular`;t+=`&"${e.font||`-`}`,t+=`,${n}"`}else t+=`&"-,Regular"`;return e.underline&&(t+=`&U`),e.fontSize&&(t+=`&${e.fontSize}`),t+=e.text,t}if(Array.isArray(e))return e.reduce((e,t)=>e.concat(this.compilePageDetailPiece(t)),``)}exportHeader(e){let t=e.createElement(`oddHeader`);return t.appendChild(e.createTextNode(this.compilePageDetailPackage(this._headers))),t}exportFooter(e){let t=e.createElement(`oddFooter`);return t.appendChild(e.createTextNode(this.compilePageDetailPackage(this._footers))),t}_buildCache(e){let t=e.createElement(`c`),n=e.createElement(`v`);n.appendChild(e.createTextNode(`--temp--`)),t.appendChild(n);let r=e.createElement(`c`),i=e.createElement(`f`);i.appendChild(e.createTextNode(`--temp--`)),r.appendChild(i);let a=e.createElement(`c`);a.setAttribute(`t`,`s`);let o=e.createElement(`v`);return o.appendChild(e.createTextNode(`--temp--`)),a.appendChild(o),{number:t,date:t,string:a,formula:r}}collectSharedStrings(){let e=this.data,t=0,n={};for(let r=0,i=e.length;r<i;r++){let i=e[r],a=i.length;t=a>t?a:t;for(let e=0;e<a;e++){let t=i[e],r=t?.metadata||{};t&&typeof t==`object`&&(t=t.value),r.type||typeof t==`number`&&(r.type=`number`),(r.type===`text`||!r.type)&&n[t]===void 0&&(n[t]=!0)}}return Object.keys(n)}toXML(){let e=this.data,t=this.columns||[],n=_.createXmlDoc(_.schemas.spreadsheetml,`worksheet`),r=n.documentElement,i,a,o;r.setAttribute(`xmlns:r`,_.schemas.relationships),r.setAttribute(`xmlns:mc`,_.schemas.markupCompat);let s=0,c=_.createElement(n,`sheetData`),l=this._buildCache(n);for(o=0,a=e.length;o<a;o++){let r=e[o],i=r.length;s=i>s?i:s;let a=n.createElement(`row`);for(let e=0;e<i;e++){t[e]=t[e]||{};let n=r[e],i,s=n?.metadata||{};switch(n&&typeof n==`object`&&(n=n.value),s.type||typeof n==`number`&&(s.type=`number`),s.type){case`number`:i=l.number.cloneNode(!0),i.firstChild.firstChild.nodeValue=n;break;case`date`:i=l.date.cloneNode(!0),n instanceof Date&&(n=n.getTime()),i.firstChild.firstChild.nodeValue=25569+(n-this._timezoneOffset)/(3600*24*1e3);break;case`formula`:i=l.formula.cloneNode(!0),i.firstChild.firstChild.nodeValue=n;break;case`text`:default:{let e;e=this.sharedStrings?.strings[n]===void 0?this.sharedStrings?.addString(n):this.sharedStrings.strings[n],i=l.string.cloneNode(!0),i.firstChild.firstChild.nodeValue=e;break}}s.style?i.setAttribute(`s`,s.style):this._rowInstructions[o]?.style!==void 0&&i.setAttribute(`s`,this._rowInstructions[o].style),i.setAttribute(`r`,_.positionToLetterRef(e+1,String(o+1))),a.appendChild(i)}if(a.setAttribute(`r`,o+1),this._rowInstructions[o]){let e=this._rowInstructions[o];e.height!==void 0&&(a.setAttribute(`customHeight`,`1`),a.setAttribute(`ht`,e.height)),e.style!==void 0&&(a.setAttribute(`customFormat`,`1`),a.setAttribute(`s`,e.style))}c.appendChild(a)}if(s===0?r.appendChild(_.createElement(n,`dimension`,[[`ref`,_.positionToLetterRef(1,1)]])):r.appendChild(_.createElement(n,`dimension`,[[`ref`,`${_.positionToLetterRef(1,1)}:${_.positionToLetterRef(s,String(e.length))}`]])),r.appendChild(this.sheetView.exportXML(n)),this.columns.length&&r.appendChild(this.exportColumns(n)),r.appendChild(c),this.sheetProtection&&r.appendChild(this.sheetProtection.exportXML(n)),this.hyperlinks.length>0){let e=n.createElement(`hyperlinks`),t=this.hyperlinks;for(i=0,a=t.length;i<a;i++){let r=n.createElement(`hyperlink`),a=t[i];r.setAttribute(`ref`,String(a.cell)),a.id=_.uniqueId(`hyperlink`),this.relations&&(this.relations.addRelation({id:a.id,target:a.location,targetMode:a.targetMode||`External`},`hyperlink`),r.setAttribute(`r:id`,this.relations.getRelationshipId(a))),e.appendChild(r)}r.appendChild(e)}if(this.mergedCells.length>0){let e=n.createElement(`mergeCells`);for(i=0,a=this.mergedCells.length;i<a;i++){let t=n.createElement(`mergeCell`);t.setAttribute(`ref`,`${this.mergedCells[i][0]}:${this.mergedCells[i][1]}`),e.appendChild(t)}r.appendChild(e)}if(this.exportPageSettings(n,r),this._headers.length>0||this._footers.length>0){let e=n.createElement(`headerFooter`);this._headers.length>0&&e.appendChild(this.exportHeader(n)),this._footers.length>0&&e.appendChild(this.exportFooter(n)),r.appendChild(e)}for(i=0,a=this._drawings.length;i<a;i++){let e=n.createElement(`drawing`);this.relations&&e.setAttribute(`r:id`,this.relations.getRelationshipId(this._drawings[i])),r.appendChild(e)}if(this._tables.length>0){let e=n.createElement(`tableParts`);for(e.setAttribute(`count`,this._tables.length),i=0,a=this._tables.length;i<a;i++){let t=n.createElement(`tablePart`);this.relations&&t.setAttribute(`r:id`,this.relations.getRelationshipId(this._tables[i])),e.appendChild(t)}r.appendChild(e)}return n}exportColumns(e){let t=_.createElement(e,`cols`);for(let n=0,r=this.columns.length;n<r;n++){let r=this.columns[n],i=_.createElement(e,`col`,[[`min`,r.min||n+1],[`max`,r.max||n+1]]);r.hidden&&i.setAttribute(`hidden`,`1`),r.bestFit&&i.setAttribute(`bestFit`,`1`),(r.customWidth||r.width)&&i.setAttribute(`customWidth`,`1`),r.width?i.setAttribute(`width`,r.width):i.setAttribute(`width`,`9.140625`),t.appendChild(i)}return t}exportPageSettings(e,t){if(this._margin){let n=.7,r=this._margin.left?this._margin.left:n,i=this._margin.right?this._margin.right:n,a=this._margin.top?this._margin.top:n,o=this._margin.bottom?this._margin.bottom:n;n=.3;let s=this._margin.header?this._margin.header:n,c=this._margin.footer?this._margin.footer:n;t.appendChild(_.createElement(e,`pageMargins`,[[`top`,a],[`bottom`,o],[`left`,r],[`right`,i],[`header`,s],[`footer`,c]]))}this._orientation&&t.appendChild(_.createElement(e,`pageSetup`,[[`orientation`,this._orientation]]))}setPageOrientation(e){this._orientation=e}setPageMargin(e){this._margin=e}setColumns(e){this.columns=e}setData(e){this.data=e}mergeCells(e,t){this.mergedCells.push([e,t])}freezePane(e,t,n){this.sheetView.freezePane(e,t,n)}setColumnFormats(e){this.columnFormats=e}getWorksheetXmlHeader(){return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="${_.schemas.spreadsheetml}"
xmlns:r="${_.schemas.relationships}"
xmlns:mc="${_.schemas.markupCompat}">`}getWorksheetXmlFooter(){if(this._headers.length>0||this._footers.length>0){let e=`<headerFooter>`;return this._headers.length>0&&(e+=`<oddHeader>${this.compilePageDetailPackage(this._headers)}</oddHeader>`),this._footers.length>0&&(e+=`<oddFooter>${this.compilePageDetailPackage(this._footers)}</oddFooter>`),e+=`</headerFooter>`,e}return``}serializeRows(e,t=0){let n=``;for(let r=0,i=e.length;r<i;r++){let i=e[r],a=i.length,o=`<row r="${t+r+1}">`;for(let e=0;e<a;e++){let n=i[e],a=typeof n||`text`,s=``,c=` r="${String.fromCharCode(65+e)}${t+r+1}"`;switch(a){case`number`:s=`<c${c}><v>${n}</v></c>`;break;case`text`:default:{let e;e=this.sharedStrings?.strings[n]===void 0?this.sharedStrings?.addString(n):this.sharedStrings.strings[n],s=`<c${c} t="s"><v>${e}</v></c>`;break}}o+=s}o+=`</row>`,n+=o}return n}},L=class{id=b(`Workbook`);styleSheet=new P;sharedStrings=new j;relations=new D;worksheets=[];charts=[];tables=[];drawings=[];media={};printTitles;constructor(){this.initialize()}initialize(){this.id=b(`Workbook`),this.styleSheet=new P,this.sharedStrings=new j,this.relations=new D,this.relations.addRelation(this.styleSheet,`stylesheet`),this.relations.addRelation(this.sharedStrings,`sharedStrings`)}createWorksheet(e){return e=Object.assign({},{name:`Sheet ${this.worksheets.length+1}`},e),new I(e)}getStyleSheet(){return this.styleSheet}addTable(e){this.tables.push(e)}addDrawings(e){this.drawings.push(e)}addChart(e){e.index=this.charts.length+1,e.target=`../charts/chart${e.index}.xml`,this.charts.push(e)}setPrintTitleTop(e,t){this.printTitles??={},this.printTitles[e]??(this.printTitles[e]={}),this.printTitles[e].top=t}setPrintTitleLeft(e,t){this.printTitles??={},this.printTitles[e]??(this.printTitles[e]={}),this.printTitles[e].left=String.fromCharCode(64+t)}addMedia(e,t,n,r){let i=t.split(`.`),a=i[i.length-1];return r||={jpeg:`image/jpeg`,jpg:`image/jpeg`,png:`image/png`,gif:`image/gif`}[a.toLowerCase()]??null,this.media[t]||(this.media[t]={id:t,data:n,fileName:t,contentType:r,extension:a}),this.media[t]}addWorksheet(e){this.relations.addRelation(e,`worksheet`),e.setSharedStringCollection(this.sharedStrings),this.worksheets.push(e)}createContentTypes(){let e=_.createXmlDoc(_.schemas.contentTypes,`Types`),t=e.documentElement,n,r;t.appendChild(_.createElement(e,`Default`,[[`Extension`,`rels`],[`ContentType`,`application/vnd.openxmlformats-package.relationships+xml`]])),t.appendChild(_.createElement(e,`Default`,[[`Extension`,`xml`],[`ContentType`,`application/xml`]]));let i={};for(let e in this.media)i[this.media[e].extension]=this.media[e].contentType;for(let n in i)t.appendChild(_.createElement(e,`Default`,[[`Extension`,n],[`ContentType`,i[n]]]));for(t.appendChild(_.createElement(e,`Override`,[[`PartName`,`/xl/workbook.xml`],[`ContentType`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml`]])),t.appendChild(_.createElement(e,`Override`,[[`PartName`,`/xl/sharedStrings.xml`],[`ContentType`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml`]])),t.appendChild(_.createElement(e,`Override`,[[`PartName`,`/xl/styles.xml`],[`ContentType`,`application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml`]])),n=0,r=this.worksheets.length;n<r;n++)t.appendChild(_.createElement(e,`Override`,[[`PartName`,`/xl/worksheets/sheet${n+1}.xml`],[`ContentType`,`application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml`]]));for(n=0,r=this.tables.length;n<r;n++)t.appendChild(_.createElement(e,`Override`,[[`PartName`,`/xl/tables/table${n+1}.xml`],[`ContentType`,`application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml`]]));for(n=0,r=this.drawings.length;n<r;n++)t.appendChild(_.createElement(e,`Override`,[[`PartName`,`/xl/drawings/drawing${n+1}.xml`],[`ContentType`,`application/vnd.openxmlformats-officedocument.drawing+xml`]]));for(n=0,r=this.charts.length;n<r;n++)t.appendChild(_.createElement(e,`Override`,[[`PartName`,`/xl/charts/chart${n+1}.xml`],[`ContentType`,`application/vnd.openxmlformats-officedocument.drawingml.chart+xml`]]));return e}toXML(){let e=_.createXmlDoc(_.schemas.spreadsheetml,`workbook`),t=e.documentElement;t.setAttribute(`xmlns:r`,_.schemas.relationships);let n=_.createElement(e,`sheets`);for(let t=0,r=this.worksheets.length;t<r;t++){let r=e.createElement(`sheet`);typeof console<`u`&&this.worksheets[t].name.length>31&&console.log(`Microsoft Excel requires work sheet names to be less than 32 characters long, work sheet name "${this.worksheets[t].name}" is ${this.worksheets[t].name.length} characters long`),r.setAttribute(`name`,this.worksheets[t].name),r.setAttribute(`sheetId`,t+1),r.setAttribute(`r:id`,this.relations.getRelationshipId(this.worksheets[t])),n.appendChild(r)}t.appendChild(n);let r=_.createElement(e,`definedNames`),i=0;for(let t in this.printTitles)if(t in this.printTitles){let n=this.printTitles[t],a=e.createElement(`definedName`);a.setAttribute(`name`,`_xlnm.Print_Titles`),a.setAttribute(`localSheetId`,i++);let o=``;n.top&&(o+=`${t}!$1:$${n.top}`,n.left&&(o+=`,`)),n.left&&(o+=`${t}!$A:$${n.left}`),a.appendChild(e.createTextNode(o)),r.appendChild(a)}return t.appendChild(r),e}createWorkbookRelationship(){let e=_.createXmlDoc(_.schemas.relationshipPackage,`Relationships`);return e.documentElement.appendChild(_.createElement(e,`Relationship`,[[`Id`,`rId1`],[`Type`,_.schemas.officeDocument],[`Ta