@digital-blueprint/esign-app
Version:
[GitHub Repository](https://github.com/digital-blueprint/esign-app) | [npmjs package](https://www.npmjs.com/package/@digital-blueprint/esign-app) | [Unpkg CDN](https://unpkg.com/browse/@digital-blueprint/esign-app/) | [Esign Bundle](https://gitlab.tugraz.
20 lines • 30.4 kB
JavaScript
/*!
* License: LGPL-2.1-or-later
* Dependencies:
*
* @webcomponents/scoped-custom-element-registry: BSD-3-Clause
* @dbp-toolkit/app-shell: LGPL-2.1-or-later
* @dbp-toolkit/language-select: LGPL-2.1-or-later
* @dbp-toolkit/auth: LGPL-2.1-or-later
* @dbp-toolkit/notification: LGPL-2.1-or-later
* @dbp-toolkit/theme-switcher: LGPL-2.1-or-later
* universal-router: MIT
* @dbp-toolkit/matomo: LGPL-2.1-or-later
* @tugraz/web-components: LGPL-2.1-or-later
* exceljs: MIT
* fabric: MIT
* jspdf-autotable: MIT
*/
function e(e,t,n,r,i){r||={};var a=1.15,o=i.internal.scaleFactor,s=i.internal.getFontSize()/o,c=s*(i.getLineHeightFactor?i.getLineHeightFactor():a),l=/\r\n|\r|\n/g,u=``,d=1;if((r.valign===`middle`||r.valign===`bottom`||r.halign===`center`||r.halign===`right`)&&(u=typeof e==`string`?e.split(l):e,d=u.length||1),n+=s*(2-a),r.valign===`middle`?n-=d/2*c:r.valign===`bottom`&&(n-=d*c),r.halign===`center`||r.halign===`right`){var f=s;if(r.halign===`center`&&(f*=.5),u&&d>=1){for(var p=0;p<u.length;p++)i.text(u[p],t-i.getStringUnitWidth(u[p])*f,n),n+=c;return i}t-=i.getStringUnitWidth(e)*f}return r.halign===`justify`?i.text(e,t,n,{maxWidth:r.maxWidth||100,align:`justify`}):i.text(e,t,n),i}var t={},n=function(){function e(e){this.jsPDFDocument=e,this.userStyles={textColor:e.getTextColor?this.jsPDFDocument.getTextColor():0,fontSize:e.internal.getFontSize(),fontStyle:e.internal.getFont().fontStyle,font:e.internal.getFont().fontName,lineWidth:e.getLineWidth?this.jsPDFDocument.getLineWidth():0,lineColor:e.getDrawColor?this.jsPDFDocument.getDrawColor():0}}return e.setDefaults=function(e,n){n===void 0&&(n=null),n?n.__autoTableDocumentDefaults=e:t=e},e.unifyColor=function(e){return Array.isArray(e)?e:typeof e==`number`?[e,e,e]:typeof e==`string`?[e]:null},e.prototype.applyStyles=function(t,n){var r,i,a;n===void 0&&(n=!1),t.fontStyle&&this.jsPDFDocument.setFontStyle&&this.jsPDFDocument.setFontStyle(t.fontStyle);var o=this.jsPDFDocument.internal.getFont(),s=o.fontStyle,c=o.fontName;if(t.font&&(c=t.font),t.fontStyle){s=t.fontStyle;var l=this.getFontList()[c];l&&l.indexOf(s)===-1&&this.jsPDFDocument.setFontStyle&&(this.jsPDFDocument.setFontStyle(l[0]),s=l[0])}if(this.jsPDFDocument.setFont(c,s),t.fontSize&&this.jsPDFDocument.setFontSize(t.fontSize),!n){var u=e.unifyColor(t.fillColor);u&&(r=this.jsPDFDocument).setFillColor.apply(r,u),u=e.unifyColor(t.textColor),u&&(i=this.jsPDFDocument).setTextColor.apply(i,u),u=e.unifyColor(t.lineColor),u&&(a=this.jsPDFDocument).setDrawColor.apply(a,u),typeof t.lineWidth==`number`&&this.jsPDFDocument.setLineWidth(t.lineWidth)}},e.prototype.splitTextToSize=function(e,t,n){return this.jsPDFDocument.splitTextToSize(e,t,n)},e.prototype.rect=function(e,t,n,r,i){return this.jsPDFDocument.rect(e,t,n,r,i)},e.prototype.getLastAutoTable=function(){return this.jsPDFDocument.lastAutoTable||null},e.prototype.getTextWidth=function(e){return this.jsPDFDocument.getTextWidth(e)},e.prototype.getDocument=function(){return this.jsPDFDocument},e.prototype.setPage=function(e){this.jsPDFDocument.setPage(e)},e.prototype.addPage=function(){return this.jsPDFDocument.addPage()},e.prototype.getFontList=function(){return this.jsPDFDocument.getFontList()},e.prototype.getGlobalOptions=function(){return t||{}},e.prototype.getDocumentOptions=function(){return this.jsPDFDocument.__autoTableDocumentDefaults||{}},e.prototype.pageSize=function(){var e=this.jsPDFDocument.internal.pageSize;return e.width??(e={width:e.getWidth(),height:e.getHeight()}),e},e.prototype.scaleFactor=function(){return this.jsPDFDocument.internal.scaleFactor},e.prototype.getLineHeightFactor=function(){var e=this.jsPDFDocument;return e.getLineHeightFactor?e.getLineHeightFactor():1.15},e.prototype.getLineHeight=function(e){return e/this.scaleFactor()*this.getLineHeightFactor()},e.prototype.pageNumber=function(){var e=this.jsPDFDocument.internal.getCurrentPageInfo();return e?e.pageNumber:this.jsPDFDocument.internal.getNumberOfPages()},e}(),r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)};function i(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var a=function(e){i(t,e);function t(t){var n=e.call(this)||this;return n._element=t,n}return t}(Array);function o(e){return{font:`helvetica`,fontStyle:`normal`,overflow:`linebreak`,fillColor:!1,textColor:20,halign:`left`,valign:`top`,fontSize:10,cellPadding:5/e,lineColor:200,lineWidth:0,cellWidth:`auto`,minCellHeight:0,minCellWidth:0}}function s(e){return{striped:{table:{fillColor:255,textColor:80,fontStyle:`normal`},head:{textColor:255,fillColor:[41,128,185],fontStyle:`bold`},body:{},foot:{textColor:255,fillColor:[41,128,185],fontStyle:`bold`},alternateRow:{fillColor:245}},grid:{table:{fillColor:255,textColor:80,fontStyle:`normal`,lineWidth:.1},head:{textColor:255,fillColor:[26,188,156],fontStyle:`bold`,lineWidth:0},body:{},foot:{textColor:255,fillColor:[26,188,156],fontStyle:`bold`,lineWidth:0},alternateRow:{}},plain:{head:{fontStyle:`bold`},foot:{fontStyle:`bold`}}}[e]}function c(e,t,n){return n.applyStyles(t,!0),(Array.isArray(e)?e:[e]).map(function(e){return n.getTextWidth(e)}).reduce(function(e,t){return Math.max(e,t)},0)}function l(e,t,n,r){var i=t.settings.tableLineWidth,a=t.settings.tableLineColor;e.applyStyles({lineWidth:i,lineColor:a});var o=u(i,!1);o&&e.rect(n.x,n.y,t.getWidth(e.pageSize().width),r.y-n.y,o)}function u(e,t){var n=e>0,r=t||t===0;return n&&r?`DF`:n?`S`:r?`F`:null}function d(e,t){if(e||=t,Array.isArray(e)){if(e.length>=4)return{top:e[0],right:e[1],bottom:e[2],left:e[3]};if(e.length===3)return{top:e[0],right:e[1],bottom:e[2],left:e[1]};if(e.length===2)return{top:e[0],right:e[1],bottom:e[0],left:e[1]};e=e.length===1?e[0]:t}return typeof e==`object`?(typeof e.vertical==`number`&&(e.top=e.vertical,e.bottom=e.vertical),typeof e.horizontal==`number`&&(e.right=e.horizontal,e.left=e.horizontal),{left:e.left??t,top:e.top??t,right:e.right??t,bottom:e.bottom??t}):(typeof e!=`number`&&(e=t),{top:e,right:e,bottom:e,left:e})}function f(e,t){var n=d(t.settings.margin,0);return e.pageSize().width-(n.left+n.right)}function p(e,t,n,r,i){var a={},o=96/72,s=h(t,function(e){return i.getComputedStyle(e).backgroundColor});s!=null&&(a.fillColor=s);var c=h(t,function(e){return i.getComputedStyle(e).color});c!=null&&(a.textColor=c);var l=_(r,n);l&&(a.cellPadding=l);var u=`borderTopColor`,d=o*n,f=r.borderTopWidth;if(r.borderBottomWidth===f&&r.borderRightWidth===f&&r.borderLeftWidth===f){var p=(parseFloat(f)||0)/d;p&&(a.lineWidth=p)}else a.lineWidth={top:(parseFloat(r.borderTopWidth)||0)/d,right:(parseFloat(r.borderRightWidth)||0)/d,bottom:(parseFloat(r.borderBottomWidth)||0)/d,left:(parseFloat(r.borderLeftWidth)||0)/d},a.lineWidth.top||(a.lineWidth.right?u=`borderRightColor`:a.lineWidth.bottom?u=`borderBottomColor`:a.lineWidth.left&&(u=`borderLeftColor`));var g=h(t,function(e){return i.getComputedStyle(e)[u]});g!=null&&(a.lineColor=g);var v=[`left`,`right`,`center`,`justify`];v.indexOf(r.textAlign)!==-1&&(a.halign=r.textAlign),v=[`middle`,`bottom`,`top`],v.indexOf(r.verticalAlign)!==-1&&(a.valign=r.verticalAlign);var y=parseInt(r.fontSize||``);isNaN(y)||(a.fontSize=y/o);var b=m(r);b&&(a.fontStyle=b);var x=(r.fontFamily||``).toLowerCase();return e.indexOf(x)!==-1&&(a.font=x),a}function m(e){var t=``;return(e.fontWeight===`bold`||e.fontWeight===`bolder`||parseInt(e.fontWeight)>=700)&&(t=`bold`),(e.fontStyle===`italic`||e.fontStyle===`oblique`)&&(t+=`italic`),t}function h(e,t){var n=g(e,t);if(!n)return null;var r=n.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d*))?\)$/);if(!r||!Array.isArray(r))return null;var i=[parseInt(r[1]),parseInt(r[2]),parseInt(r[3])];return parseInt(r[4])===0||isNaN(i[0])||isNaN(i[1])||isNaN(i[2])?null:i}function g(e,t){var n=t(e);return n===`rgba(0, 0, 0, 0)`||n===`transparent`||n===`initial`||n===`inherit`?e.parentElement==null?null:g(e.parentElement,t):n}function _(e,t){var n=[e.paddingTop,e.paddingRight,e.paddingBottom,e.paddingLeft],r=96/(72/t),i=(parseInt(e.lineHeight)-parseInt(e.fontSize))/t/2,a=d(n.map(function(e){return parseInt(e||`0`)/r}),0);return i>a.top&&(a.top=i),i>a.bottom&&(a.bottom=i),a}function v(e,t,n,r,i){r===void 0&&(r=!1),i===void 0&&(i=!1);var a=typeof t==`string`?n.document.querySelector(t):t,o=Object.keys(e.getFontList()),s=e.scaleFactor(),c=[],l=[],u=[];if(!a)return console.error(`Html table could not be found with input: `,t),{head:c,body:l,foot:u};for(var d=0;d<a.rows.length;d++){var f=a.rows[d],p=(f?.parentElement?.tagName)?.toLowerCase(),m=y(o,s,n,f,r,i);m&&(p===`thead`?c.push(m):p===`tfoot`?u.push(m):l.push(m))}return{head:c,body:l,foot:u}}function y(e,t,n,r,i,o){for(var s=new a(r),c=0;c<r.cells.length;c++){var l=r.cells[c],u=n.getComputedStyle(l);if(i||u.display!==`none`){var d=void 0;o&&(d=p(e,l,t,u,n)),s.push({rowSpan:l.rowSpan,colSpan:l.colSpan,styles:d,_element:l,content:b(l)})}}var f=n.getComputedStyle(r);if(s.length>0&&(i||f.display!==`none`))return s}function b(e){var t=e.cloneNode(!0);return t.innerHTML=t.innerHTML.replace(/\n/g,``).replace(/ +/g,` `),t.innerHTML=t.innerHTML.split(/<br.*?>/).map(function(e){return e.trim()}).join(`
`),t.innerText||t.textContent||``}function x(e,t,n){for(var r=0,i=[e,t,n];r<i.length;r++){var a=i[r];a&&typeof a!=`object`&&console.error(`The options parameter should be of type object, is: `+typeof a),a.startY&&typeof a.startY!=`number`&&(console.error(`Invalid value for startY option`,a.startY),delete a.startY)}}function S(e,t,n,r,i){if(e==null)throw TypeError(`Cannot convert undefined or null to object`);for(var a=Object(e),o=1;o<arguments.length;o++){var s=arguments[o];if(s!=null)for(var c in s)Object.prototype.hasOwnProperty.call(s,c)&&(a[c]=s[c])}return a}function C(e,t){var r=new n(e),i=r.getDocumentOptions(),a=r.getGlobalOptions();x(a,i,t);var o=S({},a,i,t),s;typeof window<`u`&&(s=window);var c=ee(a,i,t),l=w(a,i,t),u=T(r,o),d=E(r,o,s);return{id:t.tableId,content:d,hooks:l,styles:c,settings:u}}function ee(e,t,n){for(var r={styles:{},headStyles:{},bodyStyles:{},footStyles:{},alternateRowStyles:{},columnStyles:{}},i=function(i){if(i===`columnStyles`){var a=e[i],o=t[i],s=n[i];r.columnStyles=S({},a,o,s)}else{var c=[e,t,n].map(function(e){return e[i]||{}});r[i]=S({},c[0],c[1],c[2])}},a=0,o=Object.keys(r);a<o.length;a++){var s=o[a];i(s)}return r}function w(e,t,n){for(var r=[e,t,n],i={didParseCell:[],willDrawCell:[],didDrawCell:[],willDrawPage:[],didDrawPage:[]},a=0,o=r;a<o.length;a++){var s=o[a];s.didParseCell&&i.didParseCell.push(s.didParseCell),s.willDrawCell&&i.willDrawCell.push(s.willDrawCell),s.didDrawCell&&i.didDrawCell.push(s.didDrawCell),s.willDrawPage&&i.willDrawPage.push(s.willDrawPage),s.didDrawPage&&i.didDrawPage.push(s.didDrawPage)}return i}function T(e,t){var n=d(t.margin,40/e.scaleFactor()),r=te(e,t.startY)??n.top,i=t.showFoot===!0?`everyPage`:t.showFoot===!1?`never`:t.showFoot??`everyPage`,a=t.showHead===!0?`everyPage`:t.showHead===!1?`never`:t.showHead??`everyPage`,o=t.useCss??!1,s=t.theme||(o?`plain`:`striped`),c=!!t.horizontalPageBreak,l=t.horizontalPageBreakRepeat??null;return{includeHiddenHtml:t.includeHiddenHtml??!1,useCss:o,theme:s,startY:r,margin:n,pageBreak:t.pageBreak??`auto`,rowPageBreak:t.rowPageBreak??`auto`,tableWidth:t.tableWidth??`auto`,showHead:a,showFoot:i,tableLineWidth:t.tableLineWidth??0,tableLineColor:t.tableLineColor??200,horizontalPageBreak:c,horizontalPageBreakRepeat:l,horizontalPageBreakBehaviour:t.horizontalPageBreakBehaviour??`afterAllRows`}}function te(e,t){var n=e.getLastAutoTable(),r=e.scaleFactor(),i=e.pageNumber(),a=!1;return n&&n.startPageNumber&&(a=n.startPageNumber+n.pageNumber-1===i),typeof t==`number`?t:(t==null||t===!1)&&a&&n?.finalY!=null?n.finalY+20/r:null}function E(e,t,n){var r=t.head||[],i=t.body||[],a=t.foot||[];if(t.html){var o=t.includeHiddenHtml;if(n){var s=v(e,t.html,n,o,t.useCss)||{};r=s.head||r,i=s.body||r,a=s.foot||r}else console.error(`Cannot parse html in non browser environment`)}return{columns:t.columns||ne(r,i,a),head:r,body:i,foot:a}}function ne(e,t,n){var r=e[0]||t[0]||n[0]||[],i=[];return Object.keys(r).filter(function(e){return e!==`_element`}).forEach(function(e){var t=1,n=Array.isArray(r)?r[parseInt(e)]:r[e];typeof n==`object`&&!Array.isArray(n)&&(t=n?.colSpan||1);for(var a=0;a<t;a++){var o=void 0;o=Array.isArray(r)?i.length:e+(a>0?`_${a}`:``);var s={dataKey:o};i.push(s)}}),i}var D=function(){function e(e,t,n){this.table=t,this.pageNumber=t.pageNumber,this.settings=t.settings,this.cursor=n,this.doc=e.getDocument()}return e}(),O=function(e){i(t,e);function t(t,n,r,i,a,o){var s=e.call(this,t,n,o)||this;return s.cell=r,s.row=i,s.column=a,s.section=i.section,s}return t}(D),k=function(){function e(e,t){this.pageNumber=1,this.id=e.id,this.settings=e.settings,this.styles=e.styles,this.hooks=e.hooks,this.columns=t.columns,this.head=t.head,this.body=t.body,this.foot=t.foot}return e.prototype.getHeadHeight=function(e){return this.head.reduce(function(t,n){return t+n.getMaxCellHeight(e)},0)},e.prototype.getFootHeight=function(e){return this.foot.reduce(function(t,n){return t+n.getMaxCellHeight(e)},0)},e.prototype.allRows=function(){return this.head.concat(this.body).concat(this.foot)},e.prototype.callCellHooks=function(e,t,n,r,i,a){for(var o=0,s=t;o<s.length;o++){var c=s[o],l=c(new O(e,this,n,r,i,a))===!1;if(n.text=Array.isArray(n.text)?n.text:[n.text],l)return!1}return!0},e.prototype.callEndPageHooks=function(e,t){e.applyStyles(e.userStyles);for(var n=0,r=this.hooks.didDrawPage;n<r.length;n++){var i=r[n];i(new D(e,this,t))}},e.prototype.callWillDrawPageHooks=function(e,t){for(var n=0,r=this.hooks.willDrawPage;n<r.length;n++){var i=r[n];i(new D(e,this,t))}},e.prototype.getWidth=function(e){if(typeof this.settings.tableWidth==`number`)return this.settings.tableWidth;if(this.settings.tableWidth===`wrap`)return this.columns.reduce(function(e,t){return e+t.wrappedWidth},0);var t=this.settings.margin;return e-t.left-t.right},e}(),A=function(){function e(e,t,n,r,i){i===void 0&&(i=!1),this.height=0,this.raw=e,e instanceof a&&(this.raw=e._element,this.element=e._element),this.index=t,this.section=n,this.cells=r,this.spansMultiplePages=i}return e.prototype.getMaxCellHeight=function(e){var t=this;return e.reduce(function(e,n){return Math.max(e,t.cells[n.index]?.height||0)},0)},e.prototype.hasRowSpan=function(e){var t=this;return e.filter(function(e){var n=t.cells[e.index];return n?n.rowSpan>1:!1}).length>0},e.prototype.canEntireRowFit=function(e,t){return this.getMaxCellHeight(t)<=e},e.prototype.getMinimumRowHeight=function(e,t){var n=this;return e.reduce(function(e,r){var i=n.cells[r.index];if(!i)return 0;var a=t.getLineHeight(i.styles.fontSize),o=i.padding(`vertical`)+a;return o>e?o:e},0)},e}(),j=function(){function e(e,t,n){this.contentHeight=0,this.contentWidth=0,this.wrappedWidth=0,this.minReadableWidth=0,this.minWidth=0,this.width=0,this.height=0,this.x=0,this.y=0,this.styles=t,this.section=n,this.raw=e;var r=e;typeof e==`object`&&e&&!Array.isArray(e)?(this.rowSpan=e.rowSpan||1,this.colSpan=e.colSpan||1,r=e.content??e,e._element&&(this.raw=e._element)):(this.rowSpan=1,this.colSpan=1),this.text=(r==null?``:``+r).split(/\r\n|\r|\n/g)}return e.prototype.getTextPos=function(){var e;if(this.styles.valign===`top`)e=this.y+this.padding(`top`);else if(this.styles.valign===`bottom`)e=this.y+this.height-this.padding(`bottom`);else{var t=this.height-this.padding(`vertical`);e=this.y+t/2+this.padding(`top`)}var n;if(this.styles.halign===`right`)n=this.x+this.width-this.padding(`right`);else if(this.styles.halign===`center`){var r=this.width-this.padding(`horizontal`);n=this.x+r/2+this.padding(`left`)}else n=this.x+this.padding(`left`);return{x:n,y:e}},e.prototype.getContentHeight=function(e,t){t===void 0&&(t=1.15);var n=(Array.isArray(this.text)?this.text.length:1)*(this.styles.fontSize/e*t)+this.padding(`vertical`);return Math.max(n,this.styles.minCellHeight)},e.prototype.padding=function(e){var t=d(this.styles.cellPadding,0);return e===`vertical`?t.top+t.bottom:e===`horizontal`?t.left+t.right:t[e]},e}(),M=function(){function e(e,t,n){this.wrappedWidth=0,this.minReadableWidth=0,this.minWidth=0,this.width=0,this.dataKey=e,this.raw=t,this.index=n}return e.prototype.getMaxCustomCellWidth=function(e){for(var t=0,n=0,r=e.allRows();n<r.length;n++){var i=r[n].cells[this.index];i&&typeof i.styles.cellWidth==`number`&&(t=Math.max(t,i.styles.cellWidth))}return t},e}();function re(e,t){ie(e,t);var n=[],r=0;t.columns.forEach(function(e){var i=e.getMaxCustomCellWidth(t);i?e.width=i:(e.width=e.wrappedWidth,n.push(e)),r+=e.width});var i=t.getWidth(e.pageSize().width)-r;i&&=N(n,i,function(e){return Math.max(e.minReadableWidth,e.minWidth)}),i&&=N(n,i,function(e){return e.minWidth}),i=Math.abs(i),!t.settings.horizontalPageBreak&&i>.1/e.scaleFactor()&&(i=i<1?i:Math.round(i),console.warn(`Of the table content, ${i} units width could not fit page`)),oe(t),se(t,e),ae(t)}function ie(e,t){var n=e.scaleFactor(),r=t.settings.horizontalPageBreak,i=f(e,t);t.allRows().forEach(function(a){for(var o=0,s=t.columns;o<s.length;o++){var l=s[o],u=a.cells[l.index];if(u){var d=t.hooks.didParseCell;t.callCellHooks(e,d,u,a,l,null);var f=u.padding(`horizontal`);if(u.contentWidth=c(u.text,u.styles,e)+f,u.minReadableWidth=c(u.text.join(` `).split(/[^\S\u00A0]+/),u.styles,e)+u.padding(`horizontal`),typeof u.styles.cellWidth==`number`)u.minWidth=u.styles.cellWidth,u.wrappedWidth=u.styles.cellWidth;else if(u.styles.cellWidth===`wrap`||r===!0)u.contentWidth>i?(u.minWidth=i,u.wrappedWidth=i):(u.minWidth=u.contentWidth,u.wrappedWidth=u.contentWidth);else{var p=10/n;u.minWidth=u.styles.minCellWidth||p,u.wrappedWidth=u.contentWidth,u.minWidth>u.wrappedWidth&&(u.wrappedWidth=u.minWidth)}}}}),t.allRows().forEach(function(e){for(var n=0,r=t.columns;n<r.length;n++){var i=r[n],a=e.cells[i.index];if(a&&a.colSpan===1)i.wrappedWidth=Math.max(i.wrappedWidth,a.wrappedWidth),i.minWidth=Math.max(i.minWidth,a.minWidth),i.minReadableWidth=Math.max(i.minReadableWidth,a.minReadableWidth);else{var o=t.styles.columnStyles[i.dataKey]||t.styles.columnStyles[i.index]||{},s=o.cellWidth||o.minCellWidth;s&&typeof s==`number`&&(i.minWidth=s,i.wrappedWidth=s)}a&&(a.colSpan>1&&!i.minWidth&&(i.minWidth=a.minWidth),a.colSpan>1&&!i.wrappedWidth&&(i.wrappedWidth=a.minWidth))}})}function N(e,t,n){for(var r=t,i=e.reduce(function(e,t){return e+t.wrappedWidth},0),a=0;a<e.length;a++){var o=e[a],s=r*(o.wrappedWidth/i),c=o.width+s,l=n(o),u=c<l?l:c;t-=u-o.width,o.width=u}if(t=Math.round(t*1e10)/1e10,t){var d=e.filter(function(e){return t<0?e.width>n(e):!0});d.length&&(t=N(d,t,n))}return t}function ae(e){for(var t={},n=1,r=e.allRows(),i=0;i<r.length;i++)for(var a=r[i],o=0,s=e.columns;o<s.length;o++){var c=s[o],l=t[c.index];if(n>1)n--,delete a.cells[c.index];else if(l)l.cell.height+=a.height,n=l.cell.colSpan,delete a.cells[c.index],l.left--,l.left<=1&&delete t[c.index];else{var u=a.cells[c.index];if(!u)continue;if(u.height=a.height,u.rowSpan>1){var d=r.length-i,f=u.rowSpan>d?d:u.rowSpan;t[c.index]={cell:u,left:f,row:a}}}}}function oe(e){for(var t=e.allRows(),n=0;n<t.length;n++)for(var r=t[n],i=null,a=0,o=0,s=0;s<e.columns.length;s++){var c=e.columns[s];if(--o,o>1&&e.columns[s+1])a+=c.width,delete r.cells[c.index];else if(i){var l=i;delete r.cells[c.index],i=null,l.width=c.width+a}else{var l=r.cells[c.index];if(!l)continue;if(o=l.colSpan,a=0,l.colSpan>1){i=l,a+=c.width;continue}l.width=c.width+a}}}function se(e,t){for(var n={count:0,height:0},r=0,i=e.allRows();r<i.length;r++){for(var a=i[r],o=0,s=e.columns;o<s.length;o++){var c=s[o],l=a.cells[c.index];if(l){t.applyStyles(l.styles,!0);var u=l.width-l.padding(`horizontal`);if(l.styles.overflow===`linebreak`)l.text=t.splitTextToSize(l.text,u+1/t.scaleFactor(),{fontSize:l.styles.fontSize});else if(l.styles.overflow===`ellipsize`)l.text=P(l.text,u,l.styles,t,`...`);else if(l.styles.overflow===`hidden`)l.text=P(l.text,u,l.styles,t,``);else if(typeof l.styles.overflow==`function`){var d=l.styles.overflow(l.text,u);typeof d==`string`?l.text=[d]:l.text=d}l.contentHeight=l.getContentHeight(t.scaleFactor(),t.getLineHeightFactor());var f=l.contentHeight/l.rowSpan;l.rowSpan>1&&n.count*n.height<f*l.rowSpan?n={height:f,count:l.rowSpan}:n&&n.count>0&&n.height>f&&(f=n.height),f>a.height&&(a.height=f)}}n.count--}}function P(e,t,n,r,i){return e.map(function(e){return ce(e,t,n,r,i)})}function ce(e,t,n,r,i){var a=1e4*r.scaleFactor();if(t=Math.ceil(t*a)/a,t>=c(e,n,r))return e;for(;t<c(e+i,n,r)&&!(e.length<=1);)e=e.substring(0,e.length-1);return e.trim()+i}function F(e,t){var r=new n(e),i=new k(t,le(t,r.scaleFactor()));return re(r,i),r.applyStyles(r.userStyles),i}function le(e,t){var n=e.content,r=de(n.columns);if(n.head.length===0){var i=L(r,`head`);i&&n.head.push(i)}if(n.foot.length===0){var i=L(r,`foot`);i&&n.foot.push(i)}var a=e.settings.theme,o=e.styles;return{columns:r,head:I(`head`,n.head,r,o,a,t),body:I(`body`,n.body,r,o,a,t),foot:I(`foot`,n.foot,r,o,a,t)}}function I(e,t,n,r,i,a){var o={};return t.map(function(t,s){for(var c=0,l={},u=0,d=0,f=0,p=n;f<p.length;f++){var m=p[f];if(o[m.index]==null||o[m.index].left===0)if(d===0){var h=void 0;h=Array.isArray(t)?t[m.index-u-c]:t[m.dataKey];var g={};typeof h==`object`&&!Array.isArray(h)&&(g=h?.styles||{});var _=R(e,m,s,i,r,a,g),v=new j(h,_,e);l[m.dataKey]=v,l[m.index]=v,d=v.colSpan-1,o[m.index]={left:v.rowSpan-1,times:d}}else d--,u++;else o[m.index].left--,d=o[m.index].times,c++}return new A(t,s,e,l)})}function L(e,t){var n={};return e.forEach(function(e){if(e.raw!=null){var r=ue(t,e.raw);r!=null&&(n[e.dataKey]=r)}}),Object.keys(n).length>0?n:null}function ue(e,t){if(e===`head`){if(typeof t==`object`)return t.header||null;if(typeof t==`string`||typeof t==`number`)return t}else if(e===`foot`&&typeof t==`object`)return t.footer;return null}function de(e){return e.map(function(e,t){return new M(typeof e==`object`?e.dataKey??t:t,e,t)})}function R(e,t,n,r,i,a,c){var l=s(r),u;e===`head`?u=i.headStyles:e===`body`?u=i.bodyStyles:e===`foot`&&(u=i.footStyles);var d=S({},l.table,l[e],i.styles,u),f=i.columnStyles[t.dataKey]||i.columnStyles[t.index]||{},p=e===`body`?f:{},m=e===`body`&&n%2==0?S({},l.alternateRow,i.alternateRowStyles):{};return S(S({},o(a),d,m,p),c)}function z(e,t,n){n===void 0&&(n={});var r=f(e,t),i=new Map,a=[],o=[],s=[];Array.isArray(t.settings.horizontalPageBreakRepeat)?s=t.settings.horizontalPageBreakRepeat:(typeof t.settings.horizontalPageBreakRepeat==`string`||typeof t.settings.horizontalPageBreakRepeat==`number`)&&(s=[t.settings.horizontalPageBreakRepeat]),s.forEach(function(e){var n=t.columns.find(function(t){return t.dataKey===e||t.index===e});n&&!i.has(n.index)&&(i.set(n.index,!0),a.push(n.index),o.push(t.columns[n.index]),r-=n.wrappedWidth)});for(var c=!0,l=n?.start??0;l<t.columns.length;){if(i.has(l)){l++;continue}var u=t.columns[l].wrappedWidth;if(c||r>=u)c=!1,a.push(l),o.push(t.columns[l]),r-=u;else break;l++}return{colIndexes:a,columns:o,lastIndex:l-1}}function B(e,t){for(var n=[],r=0;r<t.columns.length;r++){var i=z(e,t,{start:r});i.columns.length&&(n.push(i),r=i.lastIndex)}return n}function V(e,t){var r=t.settings,i=r.startY,a=r.margin,o={x:a.left,y:i},s=t.getHeadHeight(t.columns)+t.getFootHeight(t.columns),c=i+a.bottom+s;if(r.pageBreak===`avoid`){var u=t.body.reduce(function(e,t){return e+t.height},0);c+=u}var d=new n(e);(r.pageBreak===`always`||r.startY!=null&&c>d.pageSize().height)&&(Y(d),o.y=a.top),t.callWillDrawPageHooks(d,o);var f=S({},o);t.startPageNumber=d.pageNumber(),r.horizontalPageBreak?fe(d,t,f,o):(d.applyStyles(d.userStyles),(r.showHead===`firstPage`||r.showHead===`everyPage`)&&t.head.forEach(function(e){return K(d,t,e,o,t.columns)}),d.applyStyles(d.userStyles),t.body.forEach(function(e,n){G(d,t,e,n===t.body.length-1,f,o,t.columns)}),d.applyStyles(d.userStyles),(r.showFoot===`lastPage`||r.showFoot===`everyPage`)&&t.foot.forEach(function(e){return K(d,t,e,o,t.columns)})),l(d,t,f,o),t.callEndPageHooks(d,o),t.finalY=o.y,e.lastAutoTable=t,d.applyStyles(d.userStyles)}function fe(e,t,n,r){var i=B(e,t);if(t.settings.horizontalPageBreakBehaviour===`afterAllRows`)i.forEach(function(i,a){e.applyStyles(e.userStyles),a>0?J(e,t,n,r,i.columns,!0):H(e,t,r,i.columns),pe(e,t,n,r,i.columns),W(e,t,r,i.columns)});else for(var a=-1,o=i[0],s=function(){var s=a;if(o){e.applyStyles(e.userStyles);var c=o.columns;a>=0?J(e,t,n,r,c,!0):H(e,t,r,c),s=U(e,t,a+1,r,c),W(e,t,r,c)}var l=s-a;i.slice(1).forEach(function(i){e.applyStyles(e.userStyles),J(e,t,n,r,i.columns,!0),U(e,t,a+1,r,i.columns,l),W(e,t,r,i.columns)}),a=s};a<t.body.length-1;)s()}function H(e,t,n,r){var i=t.settings;e.applyStyles(e.userStyles),(i.showHead===`firstPage`||i.showHead===`everyPage`)&&t.head.forEach(function(i){return K(e,t,i,n,r)})}function pe(e,t,n,r,i){e.applyStyles(e.userStyles),t.body.forEach(function(a,o){G(e,t,a,o===t.body.length-1,n,r,i)})}function U(e,t,n,r,i,a){e.applyStyles(e.userStyles),a??=t.body.length;var o=Math.min(n+a,t.body.length),s=-1;return t.body.slice(n,o).forEach(function(a,o){var c=q(e,t,n+o===t.body.length-1,r);a.canEntireRowFit(c,i)&&(K(e,t,a,r,i),s=n+o)}),s}function W(e,t,n,r){var i=t.settings;e.applyStyles(e.userStyles),(i.showFoot===`lastPage`||i.showFoot===`everyPage`)&&t.foot.forEach(function(i){return K(e,t,i,n,r)})}function me(e,t,n){var r=n.getLineHeight(e.styles.fontSize),i=e.padding(`vertical`),a=Math.floor((t-i)/r);return Math.max(0,a)}function he(e,t,n,r){var i={};e.spansMultiplePages=!0,e.height=0;for(var a=0,o=0,s=n.columns;o<s.length;o++){var c=s[o],l=e.cells[c.index];if(l){Array.isArray(l.text)||(l.text=[l.text]);var u=new j(l.raw,l.styles,l.section);u=S(u,l),u.text=[];var d=me(l,t,r);l.text.length>d&&(u.text=l.text.splice(d,l.text.length));var f=r.scaleFactor(),p=r.getLineHeightFactor();l.contentHeight=l.getContentHeight(f,p),l.contentHeight>=t&&(l.contentHeight=t,u.styles.minCellHeight-=t),l.contentHeight>e.height&&(e.height=l.contentHeight),u.contentHeight=u.getContentHeight(f,p),u.contentHeight>a&&(a=u.contentHeight),i[c.index]=u}}var m=new A(e.raw,-1,e.section,i,!0);m.height=a;for(var h=0,g=n.columns;h<g.length;h++){var c=g[h],u=m.cells[c.index];u&&(u.height=m.height);var l=e.cells[c.index];l&&(l.height=e.height)}return m}function ge(e,t,n,r){var i=e.pageSize().height,a=r.settings.margin,o=i-(a.top+a.bottom);t.section===`body`&&(o-=r.getHeadHeight(r.columns)+r.getFootHeight(r.columns));var s=t.getMinimumRowHeight(r.columns,e),c=s<n;if(s>o)return console.error(`Will not be able to print row ${t.index} correctly since it's minimum height is larger than page height`),!0;if(!c)return!1;var l=t.hasRowSpan(r.columns);return t.getMaxCellHeight(r.columns)>o?(l&&console.error(`The content of row ${t.index} will not be drawn correctly since drawing rows with a height larger than the page height and has cells with rowspans is not supported.`),!0):!(l||r.settings.rowPageBreak===`avoid`)}function G(e,t,n,r,i,a,o){var s=q(e,t,r,a);if(n.canEntireRowFit(s,o))K(e,t,n,a,o);else if(ge(e,n,s,t)){var c=he(n,s,t,e);K(e,t,n,a,o),J(e,t,i,a,o),G(e,t,c,r,i,a,o)}else J(e,t,i,a,o),G(e,t,n,r,i,a,o)}function K(t,n,r,i,a){i.x=n.settings.margin.left;for(var o=0,s=a;o<s.length;o++){var c=s[o],l=r.cells[c.index];if(!l){i.x+=c.width;continue}if(t.applyStyles(l.styles),l.x=i.x,l.y=i.y,n.callCellHooks(t,n.hooks.willDrawCell,l,r,c,i)===!1){i.x+=c.width;continue}_e(t,l,i);var u=l.getTextPos();e(l.text,u.x,u.y,{halign:l.styles.halign,valign:l.styles.valign,maxWidth:Math.ceil(l.width-l.padding(`left`)-l.padding(`right`))},t.getDocument()),n.callCellHooks(t,n.hooks.didDrawCell,l,r,c,i),i.x+=c.width}i.y+=r.height}function _e(e,t,n){var r=t.styles;if(e.getDocument().setFillColor(e.getDocument().getFillColor()),typeof r.lineWidth==`number`){var i=u(r.lineWidth,r.fillColor);i&&e.rect(t.x,n.y,t.width,t.height,i)}else typeof r.lineWidth==`object`&&(r.fillColor&&e.rect(t.x,n.y,t.width,t.height,`F`),ve(e,t,n,r.lineWidth))}function ve(e,t,n,r){var i,a,o,s;r.top&&(i=n.x,a=n.y,o=n.x+t.width,s=n.y,r.right&&(o+=.5*r.right),r.left&&(i-=.5*r.left),c(r.top,i,a,o,s)),r.bottom&&(i=n.x,a=n.y+t.height,o=n.x+t.width,s=n.y+t.height,r.right&&(o+=.5*r.right),r.left&&(i-=.5*r.left),c(r.bottom,i,a,o,s)),r.left&&(i=n.x,a=n.y,o=n.x,s=n.y+t.height,r.top&&(a-=.5*r.top),r.bottom&&(s+=.5*r.bottom),c(r.left,i,a,o,s)),r.right&&(i=n.x+t.width,a=n.y,o=n.x+t.width,s=n.y+t.height,r.top&&(a-=.5*r.top),r.bottom&&(s+=.5*r.bottom),c(r.right,i,a,o,s));function c(t,n,r,i,a){e.getDocument().setLineWidth(t),e.getDocument().line(n,r,i,a,`S`)}}function q(e,t,n,r){var i=t.settings.margin.bottom,a=t.settings.showFoot;return(a===`everyPage`||a===`lastPage`&&n)&&(i+=t.getFootHeight(t.columns)),e.pageSize().height-r.y-i}function J(e,t,n,r,i,a){i===void 0&&(i=[]),a===void 0&&(a=!1),e.applyStyles(e.userStyles),t.settings.showFoot===`everyPage`&&!a&&t.foot.forEach(function(n){return K(e,t,n,r,i)}),t.callEndPageHooks(e,r);var o=t.settings.margin;l(e,t,n,r),Y(e),t.pageNumber++,r.x=o.left,r.y=o.top,n.y=o.top,t.callWillDrawPageHooks(e,r),t.settings.showHead===`everyPage`&&(t.head.forEach(function(n){return K(e,t,n,r,i)}),e.applyStyles(e.userStyles))}function Y(e){var t=e.pageNumber();return e.setPage(t+1),e.pageNumber()===t?(e.addPage(),!0):!1}function X(t){t.API.autoTable=function(){var e=[...arguments][0],t=C(this,e),n=F(this,t);return V(this,n),this},t.API.lastAutoTable=!1,t.API.autoTableText=function(t,n,r,i){e(t,n,r,i,this)},t.API.autoTableSetDefaults=function(e){return n.setDefaults(e,this),this},t.autoTableSetDefaults=function(e,t){n.setDefaults(e,t)},t.API.autoTableHtmlToJson=function(e,t){if(t===void 0&&(t=!1),typeof window>`u`)return console.error(`Cannot run autoTableHtmlToJson in non browser environment`),null;var r=v(new n(this),e,window,t,!1),i=r.head,a=r.body;return{columns:i[0]?.map(function(e){return e.content})||[],rows:a,data:a}}}function Z(e,t){V(e,F(e,C(e,t)))}try{if(typeof window<`u`&&window){var Q=window,$=Q.jsPDF||Q.jspdf?.jsPDF;$&&X($)}}catch(e){console.error(`Could not apply autoTable plugin`,e)}export{j as Cell,O as CellHookData,M as Column,D as HookData,A as Row,k as Table,X as applyPlugin,Z as autoTable,Z as default};
//# sourceMappingURL=jspdf.plugin.autotable.VuRPiabj.js.map