jspdf-md-renderer 1.8.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -3
- package/dist/index.d.ts +6 -9
- package/dist/index.js +3 -2
- package/dist/index.mjs +1717 -480
- package/package.json +66 -66
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
A jsPDF utility to render Markdown directly into formatted PDFs with custom designs.
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/jspdf-md-renderer)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://www.npmjs.com/package/jspdf-md-renderer)
|
|
8
|
+
|
|
5
9
|
## Table of Contents
|
|
6
10
|
|
|
7
11
|
- [Installation](#installation)
|
|
@@ -148,7 +152,6 @@ Parses markdown into tokens and converts to a custom parsed structure.
|
|
|
148
152
|
|
|
149
153
|
The following Markdown elements are currently supported by `jspdf-md-renderer`:
|
|
150
154
|
|
|
151
|
-
### Already Implemented:
|
|
152
155
|
- **Headings**: `#`, `##`, `###`, etc.
|
|
153
156
|
- **Paragraphs**
|
|
154
157
|
- **Lists**:
|
|
@@ -169,8 +172,6 @@ The following Markdown elements are currently supported by `jspdf-md-renderer`:
|
|
|
169
172
|
```markdown
|
|
170
173
|
[GitHub](https://github.com)
|
|
171
174
|
```
|
|
172
|
-
|
|
173
|
-
### Proposed for Future Implementation:
|
|
174
175
|
- **Blockquotes**:
|
|
175
176
|
```markdown
|
|
176
177
|
> This is a blockquote.
|
|
@@ -200,6 +201,10 @@ You can find more examples in the [examples](examples/test-pdf-gen) directory.
|
|
|
200
201
|
|
|
201
202
|
Contributions are welcome! Please read the [contributing guidelines](CONTRIBUTING.md) first.
|
|
202
203
|
|
|
204
|
+
## Support
|
|
205
|
+
|
|
206
|
+
If you find this library useful, please consider giving it a ⭐ on GitHub! It helps others find the project and motivates continued development.
|
|
207
|
+
|
|
203
208
|
## License
|
|
204
209
|
|
|
205
210
|
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { default as default_2 } from 'jspdf';
|
|
2
2
|
import { jsPDFOptions } from 'jspdf';
|
|
3
|
+
import { UserOptions } from 'jspdf-autotable';
|
|
3
4
|
|
|
4
5
|
declare type FontItem = {
|
|
5
6
|
name: string;
|
|
@@ -36,14 +37,9 @@ declare type ParsedElement = {
|
|
|
36
37
|
alt?: string;
|
|
37
38
|
href?: string;
|
|
38
39
|
text?: string;
|
|
39
|
-
header?:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
rows?: {
|
|
44
|
-
type?: string;
|
|
45
|
-
content?: any;
|
|
46
|
-
};
|
|
40
|
+
header?: ParsedElement[];
|
|
41
|
+
rows?: ParsedElement[][];
|
|
42
|
+
data?: string;
|
|
47
43
|
};
|
|
48
44
|
|
|
49
45
|
export declare type RenderOption = {
|
|
@@ -77,7 +73,8 @@ export declare type RenderOption = {
|
|
|
77
73
|
link?: {
|
|
78
74
|
linkColor: [number, number, number];
|
|
79
75
|
};
|
|
80
|
-
|
|
76
|
+
table?: UserOptions;
|
|
77
|
+
pageBreakHandler?: (doc: default_2) => void;
|
|
81
78
|
endCursorYHandler: (y: number) => void;
|
|
82
79
|
};
|
|
83
80
|
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("marked");var o=(t=>(t.Heading="heading",t.Paragraph="paragraph",t.List="list",t.ListItem="list_item",t.Blockquote="blockquote",t.Code="code",t.CodeSpan="codespan",t.Table="table",t.Html="html",t.Hr="hr",t.Image="image",t.Link="link",t.Strong="strong",t.Em="em",t.TableHeader="table_header",t.TableCell="table_cell",t.Raw="raw",t.Text="text",t))(o||{});const z=async t=>{const i=await I.marked.lexer(t,{async:!0});return W(i)},W=t=>{const i=[];return t.forEach(s=>{try{const x=k[s.type];x?i.push(x(s)):i.push({type:o.Raw,content:s.raw})}catch(x){console.error("Failed to handle token ==>",s,x)}}),i},k={[o.Heading]:t=>({type:o.Heading,depth:t.depth,content:t.text,items:t.tokens?W(t.tokens):[]}),[o.Paragraph]:t=>({type:o.Paragraph,content:t.text,items:t.tokens?W(t.tokens):[]}),[o.List]:t=>({type:o.List,ordered:t.ordered,start:t.start,items:t.items?W(t.items):[]}),[o.ListItem]:t=>({type:o.ListItem,content:t.text,items:t.tokens?W(t.tokens):[]}),[o.Code]:t=>({type:o.Code,lang:t.lang,code:t.text}),[o.Table]:t=>({type:o.Table,header:t.header.map(i=>({type:o.TableHeader,content:i})),rows:t.rows.map(i=>i.map(s=>({type:o.TableCell,content:s})))}),[o.Image]:t=>({type:o.Image,src:t.href,alt:t.text}),[o.Link]:t=>({type:o.Link,href:t.href,text:t.text,items:t.tokens?W(t.tokens):[]}),[o.Strong]:t=>({type:o.Strong,content:t.text,items:t.tokens?W(t.tokens):[]}),[o.Em]:t=>({type:o.Em,content:t.text,items:t.tokens?W(t.tokens):[]}),[o.Text]:t=>({type:o.Text,content:t.text,items:t.tokens?W(t.tokens):[]}),[o.Hr]:t=>({type:o.Hr,content:t.raw,items:t.tokens?W(t.tokens):[]}),[o.CodeSpan]:t=>({type:o.CodeSpan,content:t.text,items:t.tokens?W(t.tokens):[]})},y=class y{static initialize(i){this.options_=i,this.cursor={x:i.cursor.x,y:i.cursor.y}}static getCursor(){return this.cursor}static setCursor(i){this.cursor=i}static get options(){return this.options_}static get isInlineLockActive(){return this.inlineLock}static activateInlineLock(){this.inlineLock=!0}static deactivateInlineLock(){this.inlineLock=!1}static updateX(i,s="set"){s==="set"?this.cursor.x=i:s==="add"&&(this.cursor.x+=i)}static updateY(i,s="set"){s==="set"?this.cursor.y=i:s==="add"&&(this.cursor.y+=i)}static get X(){return this.cursor.x}static get Y(){return this.cursor.y}};y.cursor={x:0,y:0},y.inlineLock=!1;let e=y;const C=t=>{var i,s;typeof e.options.pageBreakHandler=="function"?e.options.pageBreakHandler():t.addPage((i=e.options.page)==null?void 0:i.format,(s=e.options.page)==null?void 0:s.orientation),e.updateY(e.options.page.topmargin),e.updateX(e.options.page.xpading)},d=t=>t.getTextDimensions("H").h*e.options.page.defaultLineHeightFactor,L=t=>t.getTextDimensions("H").w*e.options.page.defaultLineHeightFactor,E=(t,i,s,x)=>{const h=6-((i==null?void 0:i.depth)??0)>0?6-((i==null?void 0:i.depth)??0):1;if(t.setFontSize(e.options.page.defaultFontSize+h),e.updateY(h*.2*d(t),"add"),i!=null&&i.items&&(i==null?void 0:i.items.length)>0)for(const p of(i==null?void 0:i.items)??[])x(p,s,!1);else t.text((i==null?void 0:i.content)??"",e.X+s,e.Y,{align:"left",maxWidth:e.options.page.maxContentWidth-s});t.setFontSize(e.options.page.defaultFontSize),e.updateX(e.options.page.xpading)},D=(t,i,s,x,h,p,c,g,a)=>{const l=(g-s)/(i.length-1);let n=h;const r=p+x*c;for(const u of i)t.text(u.text,n,r,{align:"justify",lineHeightFactor:a,maxWidth:g}),n+=u.wordLength+l},P=(t,i,s,x,h,p,c,g)=>{const a=t.map(l=>l.text).join(" ");i.text(a,s,x+h*p,{align:"justify",lineHeightFactor:g,maxWidth:c})},F=(t,i,s,x,h,p)=>{const c={x:s,y:x},g=t.getTextDimensions("A").h*p,a=i.split(" ");let l=0,n=[],r=0;for(const u of a){const b=t.getTextWidth(u+"a");b+r>=h&&(D(t,n,r,l++,s,x,g,h,p),n=[],r=0),n.push({text:u,wordLength:b}),r+=b}return n.length>0&&P(n,t,s,x,l,g,h,p),c.y=x+l*g,c.x=t.getTextWidth(i)+s,c},S=(t,i,s)=>{const x=t.getFont().fontName,h=t.getFont().fontStyle,p=t.getFontSize(),c=a=>{switch(a){case"normal":return 0;case"bold":return 1;case"italic":return 1.5;case"bolditalic":return 1.5;default:return 0}},g=(a,l)=>{var u;l==="bold"?t.setFont(e.options.font.bold.name&&e.options.font.bold.name!==""?e.options.font.bold.name:x,e.options.font.bold.style||"bold"):l==="italic"?t.setFont(e.options.font.regular.name,"italic"):l==="bolditalic"?t.setFont(e.options.font.bold.name&&e.options.font.bold.name!==""?e.options.font.bold.name:x,"bolditalic"):t.setFont(e.options.font.regular.name,h);const n=e.options.page.maxContentWidth-s-e.X,r=t.splitTextToSize(a,n);if(e.isInlineLockActive)for(let b=0;b<r.length;b++)t.text(r[b],e.X+s,e.Y,{baseline:"top",maxWidth:n}),e.updateX(t.getTextDimensions(r[b]).w+1,"add"),b<r.length-1&&(e.updateY(d(t),"add"),e.updateX(e.options.page.xpading+s,"set"));else if(r.length>1){const b=r[0],f=(u=r==null?void 0:r.slice(1))==null?void 0:u.join(" ");t.text(b,e.X+(s>=2?s+2*c(l):0),e.Y,{baseline:"top",maxWidth:n}),e.updateX(e.options.page.xpading+s),e.updateY(d(t),"add");const Y=e.options.page.maxContentWidth-s-e.options.page.xpading;t.splitTextToSize(f,Y).forEach(m=>{t.text(m,e.X+L(t),e.Y,{baseline:"top",maxWidth:Y})})}else t.text(a,e.X+s,e.Y,{baseline:"top",maxWidth:n}),e.updateX(t.getTextDimensions(a).w+(s>=2?a.split(" ").length+2:2)*c(l)*.5,"add")};if(i.type==="text"&&i.items&&i.items.length>0)for(const a of i.items)if(a.type==="em"||a.type==="strong"){const l=a.type==="em"?"italic":"bold";if(a.items&&a.items.length>0)for(const n of a.items)n.type==="strong"&&l==="italic"||n.type==="em"&&l==="bold"?g(n.content||"","bolditalic"):g(n.content||"",l);else g(a.content||"",l)}else g(a.content||"","normal");else i.type==="em"?g(i.content||"","italic"):i.type==="strong"?g(i.content||"","bold"):g(i.content||"","normal");t.setFont(x,h),t.setFontSize(p)},j=(t,i,s,x)=>{e.activateInlineLock(),t.setFontSize(e.options.page.defaultFontSize);let h=i.content;const p=t.getTextDimensions("A").h*e.options.page.defaultLineHeightFactor;if(i!=null&&i.items&&(i==null?void 0:i.items.length)>0){let c=0;for(const g of(i==null?void 0:i.items)??[])["strong","em","text"].includes(g.type)?(g.type!=="text"&&c!=0&&e.updateX(L(t)*1.5,"add"),S(t,g,s),g.type!=="text"&&c!=0&&e.updateX(L(t),"add")):x(g,s,!1),c++}else{if(e.Y+t.splitTextToSize(h??"",e.options.page.maxContentWidth-s).length*p-3*p>=e.options.page.maxContentHeight){const g=t.splitTextToSize(h??"",e.options.page.maxContentWidth-s),a=[],l=e.Y;for(let n=0;n<g.length;n++)if(e.Y-2*p<e.options.page.maxContentHeight)a.push(g[n]),e.updateY(e.options.page.lineSpace,"add");else{n<=g.length-1&&(h=g.slice(n).join(""));break}if(a.length>0){const n=F(t,a.join(" "),e.X+s,l,e.options.page.maxContentWidth-s,e.options.page.defaultLineHeightFactor);e.setCursor(n)}C(t)}const c=F(t,h??"",e.X+s,e.Y,e.options.page.maxContentWidth-s,e.options.page.defaultLineHeightFactor).y+d(t);e.updateY(c)}e.updateY(p,"add"),e.updateX(e.options.page.xpading),e.deactivateInlineLock()},v=(t,i,s,x)=>{var h;t.setFontSize(e.options.page.defaultFontSize);for(const[p,c]of((h=i==null?void 0:i.items)==null?void 0:h.entries())??[]){const g=i.ordered?(i.start??0)+p:i.start;x(c,s+1,!0,g,i.ordered)}},A=(t,i,s,x,h,p)=>{const c=s*e.options.page.indent,g=p?`${h}. `:"• ";e.Y+d(t)>=e.options.page.maxContentHeight&&C(t),t.setFont(e.options.font.regular.name,e.options.font.regular.style),t.text(g,e.X+c,e.Y,{baseline:"top"});const a=t.getTextWidth(g);if(e.updateX(a,"add"),i.items&&i.items.length>0)for(const l of i.items){if(e.Y+d(t)>=e.options.page.maxContentHeight&&C(t),l.type===o.List)x(l,s+1,!0,h,l.ordered??!1);else if(l.type===o.ListItem){const n=i.type===o.List?s:s+1;x(l,n,!0,h,p)}else e.activateInlineLock(),S(t,l,c),e.deactivateInlineLock();e.updateX(e.options.page.xpading),e.updateY(d(t),"add")}else if(i.content){const l=e.X+c,n=t.getTextWidth(g),r=e.options.page.maxContentWidth-c-n,u=t.splitTextToSize(i.content,r);if(u.length>0){t.text(u[0],l+n,e.Y,{baseline:"top",maxWidth:r});for(let f=1;f<u.length;f++)e.updateY(d(t),"add"),t.text(u[f],l+n,e.Y,{baseline:"top",maxWidth:r});e.updateX(e.options.page.xmargin+c),e.updateY(d(t),"add");const b=t.getTextWidth(i.content);e.updateX(b,"add")}}},R=(t,i,s,x,h,p,c,g=!0)=>{if(i!=null&&i.items&&(i==null?void 0:i.items.length)>0)for(const a of(i==null?void 0:i.items)??[])h(a,s,x,p,c,g);else{const a=s*e.options.page.indent,l=x?c?`${p}. `:"• ":"";if(x&&l){const n=t.getTextWidth(l),r=e.options.page.maxContentWidth-a-n,u=t.splitTextToSize(i.content||"",r);if(u.length>0){t.text(l,e.X+a,e.Y,{baseline:"top"}),t.text(u[0],e.X+a+n,e.Y,{baseline:"top",maxWidth:r});for(let f=1;f<u.length;f++)e.updateX(e.options.page.xpading),e.updateY(d(t),"add"),t.text(u[f],e.X+a+n,e.Y,{baseline:"top",maxWidth:r-a-n});e.updateY(d(t),"add"),e.updateX(e.options.page.xpading+a);const b=t.getTextWidth(i.content||"");e.updateX(b,"add")}}else{const n=t.splitTextToSize(i.content||"",e.options.page.maxContentWidth-a);if(e.Y+n.length*d(t)>=e.options.page.maxContentHeight&&C(t),g){const r=F(t,i.content||"",e.X+a,e.Y,e.options.page.maxContentWidth-a,e.options.page.defaultLineHeightFactor).y+d(t)*.5;e.updateY(r),e.updateX(e.options.page.xpading)}else t.text(n||"",e.X+a,e.Y,{baseline:"top"}),e.updateX(t.getTextWidth(i.content||""),"add"),e.X>=e.options.page.xpading+e.options.page.maxContentWidth&&C(t)}}},B=t=>{const i=t.internal.pageSize.getWidth();t.setLineDashPattern([1,1],0),t.setLineWidth(.1),t.line(e.options.page.xpading,e.Y,i-e.options.page.xpading,e.Y),t.setLineWidth(.1),t.setLineDashPattern([],0),e.updateY(d(t),"add")},_=(t,i,s,x)=>{const h=s*e.options.page.indent;e.Y+t.splitTextToSize(i.code??"",e.options.page.maxContentWidth-h).length*d(t)-2*d(t)>=e.options.page.maxContentHeight&&C(t);const p=t.splitTextToSize(i.code??"",e.options.page.maxContentWidth-h).length*d(t);e.updateY(e.options.page.lineSpace,"add"),t.setFillColor("#EEEEEE"),t.setDrawColor("#eee"),t.roundedRect(e.X,e.Y-e.options.page.lineSpace,e.options.page.maxContentWidth,p,2,2,"FD"),t.setFontSize(10),t.text(i.lang??"",e.X+e.options.page.maxContentWidth-t.getTextWidth(i.lang??"")-e.options.page.lineSpace/2,e.Y),t.setFontSize(e.options.page.defaultFontSize),t.text(i.code??"",e.X+4,e.Y),e.updateY(p,"add")},q=(t,i,s)=>{var u,b;const x=t.getFont().fontName,h=t.getFont().fontStyle,p=t.getFontSize(),c=t.getTextColor(),g=((u=e.options.link)==null?void 0:u.linkColor)||[0,0,255];t.setTextColor(...g);const a=e.options.page.maxContentWidth-s-e.X,l=i.text||i.content||"",n=i.href||"",r=t.splitTextToSize(l,a);if(e.isInlineLockActive)for(let f=0;f<r.length;f++){const Y=t.getTextDimensions(r[f]).w,X=d(t)/2;t.link(e.X+s,e.Y,Y,X,{url:n}),t.text(r[f],e.X+s,e.Y,{baseline:"top",maxWidth:a}),e.updateX(Y+1,"add"),e.X+Y>e.options.page.maxContentWidth-s&&(e.updateY(X,"add"),e.updateX(e.options.page.xpading+s,"set")),f<r.length-1&&(e.updateY(X,"add"),e.updateX(e.options.page.xpading+s,"set"))}else if(r.length>1){const f=r[0],Y=(b=r==null?void 0:r.slice(1))==null?void 0:b.join(" "),X=t.getTextDimensions(f).w,m=d(t)/2;t.link(e.X+s,e.Y,X,m,{url:n}),t.text(f,e.X+s,e.Y,{baseline:"top",maxWidth:a}),e.updateX(e.options.page.xpading+s),e.updateY(m,"add");const H=e.options.page.maxContentWidth-s-e.options.page.xpading;t.splitTextToSize(Y,H).forEach(T=>{const w=t.getTextDimensions(T).w;t.link(e.X+L(t),e.Y,w,m,{url:n}),t.text(T,e.X+L(t),e.Y,{baseline:"top",maxWidth:H})})}else{const f=t.getTextDimensions(l).w,Y=d(t)/2;t.link(e.X+s,e.Y,f,Y,{url:n}),t.text(l,e.X+s,e.Y,{baseline:"top",maxWidth:a}),e.updateX(f+2,"add")}t.setFont(x,h),t.setFontSize(p),t.setTextColor(c)},J=async(t,i,s)=>{e.initialize(s);const x=await z(i),h=(p,c=0,g=!1,a=0,l=!1,n=!0)=>{const r=c*s.page.indent;switch(e.Y+t.splitTextToSize(p.content??"",s.page.maxContentWidth-r).length*d(t)>=s.page.maxContentHeight&&C(t),p.type){case o.Heading:E(t,p,r,h);break;case o.Paragraph:j(t,p,r,h);break;case o.List:v(t,p,c,h);break;case o.ListItem:A(t,p,c,h,a,l);break;case o.Hr:B(t);break;case o.Code:_(t,p,c);break;case o.Strong:case o.Em:S(t,p,r);break;case o.Link:q(t,p,r);break;case o.Raw:case o.Text:R(t,p,c,g,h,a,l,n);break;default:console.warn(`Warning: Unsupported element type encountered: ${p.type}.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const vt=require("marked");var c=(t=>(t.Heading="heading",t.Paragraph="paragraph",t.List="list",t.ListItem="list_item",t.Blockquote="blockquote",t.Code="code",t.CodeSpan="codespan",t.Table="table",t.Html="html",t.Hr="hr",t.Image="image",t.Link="link",t.Strong="strong",t.Em="em",t.TableHeader="table_header",t.TableCell="table_cell",t.Raw="raw",t.Text="text",t))(c||{});const Z=async t=>{const e=await vt.marked.lexer(t,{async:!0,gfm:!0});return b(e)},b=t=>{const e=[];return t.forEach(i=>{try{const n=ct[i.type];n?e.push(n(i)):e.push({type:c.Raw,content:i.raw})}catch(n){console.error("Failed to handle token ==>",i,n)}}),e},ct={[c.Heading]:t=>({type:c.Heading,depth:t.depth,content:t.text,items:t.tokens?b(t.tokens):[]}),[c.Paragraph]:t=>({type:c.Paragraph,content:t.text,items:t.tokens?b(t.tokens):[]}),[c.List]:t=>({type:c.List,ordered:t.ordered,start:t.start,items:t.items?b(t.items):[]}),[c.ListItem]:t=>({type:c.ListItem,content:t.text,items:t.tokens?b(t.tokens):[]}),[c.Code]:t=>({type:c.Code,lang:t.lang,code:t.text}),[c.Table]:t=>({type:c.Table,header:t.header.map(e=>({type:c.TableHeader,content:e.text})),rows:t.rows.map(e=>e.map(i=>({type:c.TableCell,content:i.text})))}),[c.Image]:t=>({type:c.Image,src:t.href,alt:t.text}),[c.Link]:t=>({type:c.Link,href:t.href,text:t.text,items:t.tokens?b(t.tokens):[]}),[c.Strong]:t=>({type:c.Strong,content:t.text,items:t.tokens?b(t.tokens):[]}),[c.Em]:t=>({type:c.Em,content:t.text,items:t.tokens?b(t.tokens):[]}),[c.Text]:t=>({type:c.Text,content:t.text,items:t.tokens?b(t.tokens):[]}),[c.Hr]:t=>({type:c.Hr,content:t.raw,items:t.tokens?b(t.tokens):[]}),[c.CodeSpan]:t=>({type:c.CodeSpan,content:t.text,items:t.tokens?b(t.tokens):[]}),[c.Blockquote]:t=>({type:c.Blockquote,content:t.text,items:t.tokens?b(t.tokens):[]})},L=class L{static initialize(e){this.options_=e,this.cursor={x:e.cursor.x,y:e.cursor.y}}static getCursor(){return this.cursor}static setCursor(e){this.cursor=e}static get options(){return this.options_}static get isInlineLockActive(){return this.inlineLock}static activateInlineLock(){this.inlineLock=!0}static deactivateInlineLock(){this.inlineLock=!1}static updateX(e,i="set"){i==="set"?this.cursor.x=e:i==="add"&&(this.cursor.x+=e)}static updateY(e,i="set"){i==="set"?this.cursor.y=e:i==="add"&&(this.cursor.y+=e)}static get X(){return this.cursor.x}static get Y(){return this.cursor.y}};L.cursor={x:0,y:0},L.inlineLock=!1;let f=L;const D=t=>{typeof f.options.pageBreakHandler=="function"?f.options.pageBreakHandler(t):t.addPage(f.options.page?.format,f.options.page?.orientation),f.updateY(f.options.page.topmargin),f.updateX(f.options.page.xpading)},w=t=>t.getTextDimensions("H").h*f.options.page.defaultLineHeightFactor,F=t=>t.getTextDimensions("H").w*f.options.page.defaultLineHeightFactor,yt=(t,e,i,n)=>{const r=6-(e?.depth??0)>0?6-(e?.depth??0):1;if(t.setFontSize(f.options.page.defaultFontSize+r),f.updateY(r*.2*w(t),"add"),e?.items&&e?.items.length>0)for(const a of e?.items??[])n(a,i,!1);else t.text(e?.content??"",f.X+i,f.Y,{align:"left",maxWidth:f.options.page.maxContentWidth-i});t.setFontSize(f.options.page.defaultFontSize),f.updateX(f.options.page.xpading)},O=(t,e,i)=>{const n=t.getFont().fontName,r=t.getFont().fontStyle,a=t.getFontSize(),s=l=>{switch(l){case"normal":return 0;case"bold":return 1;case"italic":return 1.5;case"bolditalic":return 1.5;case"codespan":return .5;default:return 0}},h=(l,o)=>{o==="bold"?t.setFont(f.options.font.bold.name&&f.options.font.bold.name!==""?f.options.font.bold.name:n,f.options.font.bold.style||"bold"):o==="italic"?t.setFont(f.options.font.regular.name,"italic"):o==="bolditalic"?t.setFont(f.options.font.bold.name&&f.options.font.bold.name!==""?f.options.font.bold.name:n,"bolditalic"):o==="codespan"?(t.setFont("courier","normal"),t.setFontSize(a*.9)):t.setFont(f.options.font.regular.name,r);const g=f.options.page.maxContentWidth-i-f.X,p=t.splitTextToSize(l,g),u=o==="codespan",d=1,v="#EEEEEE";if(f.isInlineLockActive)for(let y=0;y<p.length;y++){if(u){const m=t.getTextWidth(p[y])+F(t),x=w(t);t.setFillColor(v),t.roundedRect(f.X+i-d,f.Y-d,m+d*2,x+d*2,2,2,"F"),t.setFillColor("#000000")}t.text(p[y],f.X+i,f.Y,{baseline:"top",maxWidth:g}),f.updateX(t.getTextDimensions(p[y]).w+(u?d*2:1),"add"),y<p.length-1&&(f.updateY(w(t),"add"),f.updateX(f.options.page.xpading,"set"))}else if(p.length>1){const y=p[0],m=p?.slice(1)?.join(" ");if(u){const S=t.getTextWidth(y)+F(t),W=w(t);t.setFillColor(v),t.roundedRect(f.X+(i>=2?i+2:0)-d,f.Y-d,S+d*2,W+d*2,2,2,"F"),t.setFillColor("#000000")}t.text(y,f.X+(i>=2?i+2*s(o):0),f.Y,{baseline:"top",maxWidth:g}),f.updateX(f.options.page.xpading+i),f.updateY(w(t),"add");const x=f.options.page.maxContentWidth-i-f.options.page.xpading;t.splitTextToSize(m,x).forEach(S=>{if(u){const W=t.getTextWidth(S)+F(t),X=w(t);t.setFillColor(v),t.roundedRect(f.X+F(t)-d,f.Y-d,W+d*2,X+d*2,2,2,"F"),t.setFillColor("#000000")}t.text(S,f.X+F(t),f.Y,{baseline:"top",maxWidth:x})})}else{if(u){const y=t.getTextWidth(l)+F(t),m=w(t);t.setFillColor(v),t.roundedRect(f.X+i-d,f.Y-d,y+d*2,m+d*2,2,2,"F"),t.setFillColor("#000000")}t.text(l,f.X+i,f.Y,{baseline:"top",maxWidth:g}),f.updateX(t.getTextDimensions(l).w+(i>=2?l.split(" ").length+2:2)*s(o)*.5+(u?d*2:0),"add")}};if(e.type==="text"&&e.items&&e.items.length>0)for(const l of e.items)if(l.type==="codespan")h(l.content||"","codespan");else if(l.type==="em"||l.type==="strong"){const o=l.type==="em"?"italic":"bold";if(l.items&&l.items.length>0)for(const g of l.items)g.type==="strong"&&o==="italic"||g.type==="em"&&o==="bold"?h(g.content||"","bolditalic"):h(g.content||"",o);else h(l.content||"",o)}else h(l.content||"","normal");else e.type==="em"?h(e.content||"","italic"):e.type==="strong"?h(e.content||"","bold"):e.type==="codespan"?h(e.content||"","codespan"):h(e.content||"","normal");t.setFont(n,r),t.setFontSize(a)};class mt{static renderText(e,i,n=f.X,r=f.Y,a,s=!1){const h=e.splitTextToSize(i,a),l=w(e);let o=r;for(let g=0;g<h.length;g++){const p=h[g];o+l>f.options.page.maxContentHeight&&(D(e),o=f.Y),s?g===h.length-1?e.text(p,n,o):e.text(p,n,o,{maxWidth:a,align:"justify"}):e.text(p,n,o),o+=l,f.updateY(l,"add")}return o}}const xt=(t,e,i,n)=>{f.activateInlineLock(),t.setFontSize(f.options.page.defaultFontSize);const r=e.content,a=t.getTextDimensions("A").h*f.options.page.defaultLineHeightFactor;if(e?.items&&e?.items.length>0){let s=0;for(const h of e?.items??[])["strong","em","text","codespan"].includes(h.type)?(h.type!=="text"&&s!=0&&f.updateX(F(t)*1.5,"add"),O(t,h,i),h.type!=="text"&&s!=0&&f.updateX(F(t),"add")):n(h,i,!1),s++}else{const s=f.options.page.maxContentWidth-i;mt.renderText(t,r??"",f.X+i,f.Y,s,!0)}f.updateY(a,"add"),f.updateX(f.options.page.xpading),f.deactivateInlineLock()},wt=(t,e,i,n)=>{t.setFontSize(f.options.page.defaultFontSize);for(const[r,a]of e?.items?.entries()??[]){const s=e.ordered?(e.start??0)+r:e.start;n(a,i+1,!0,s,e.ordered)}},St=(t,e,i,n,r,a)=>{const s=i*f.options.page.indent,h=a?`${r}. `:"• ";f.Y+w(t)>=f.options.page.maxContentHeight&&D(t),t.setFont(f.options.font.regular.name,f.options.font.regular.style),t.text(h,f.X+s,f.Y,{baseline:"top"});const l=t.getTextWidth(h);if(f.updateX(l,"add"),e.items&&e.items.length>0)for(const o of e.items){if(f.Y+w(t)>=f.options.page.maxContentHeight&&D(t),o.type===c.List)n(o,i+1,!0,r,o.ordered??!1);else if(o.type===c.ListItem){const g=e.type===c.List?i:i+1;n(o,g,!0,r,a)}else f.activateInlineLock(),O(t,o,s),f.deactivateInlineLock();f.updateX(f.options.page.xpading),f.updateY(w(t),"add")}else if(e.content){const o=f.X+s,g=t.getTextWidth(h),p=f.options.page.maxContentWidth-s-g,u=t.splitTextToSize(e.content,p);if(u.length>0){t.text(u[0],o+g,f.Y,{baseline:"top",maxWidth:p});for(let v=1;v<u.length;v++)f.updateY(w(t),"add"),t.text(u[v],o+g,f.Y,{baseline:"top",maxWidth:p});f.updateX(f.options.page.xmargin+s),f.updateY(w(t),"add");const d=t.getTextWidth(e.content);f.updateX(d,"add")}}},Ct=(t,e,i,n,r,a,s,h,l)=>{const o=(h-i)/(e.length-1);let g=r;const p=a+n*s;for(const u of e)t.text(u.text,g,p,{align:"justify",lineHeightFactor:l,maxWidth:h}),g+=u.wordLength+o},bt=(t,e,i,n,r,a,s,h)=>{const l=t.map(o=>o.text).join(" ");e.text(l,i,n+r*a,{align:"justify",lineHeightFactor:h,maxWidth:s})},Wt=(t,e,i,n,r,a)=>{const s={x:i,y:n},h=t.getTextDimensions("A").h*a,l=e.split(" ");let o=0,g=[],p=0;for(const u of l){const d=t.getTextWidth(u+"a");d+p>=r&&(Ct(t,g,p,o++,i,n,h,r,a),g=[],p=0),g.push({text:u,wordLength:d}),p+=d}return g.length>0&&bt(g,t,i,n,o,h,r,a),s.y=n+o*h,s.x=t.getTextWidth(e)+i,s},Ft=(t,e,i,n,r,a,s,h=!0)=>{if(e?.items&&e?.items.length>0)for(const l of e?.items??[])r(l,i,n,a,s,h);else{const l=i*f.options.page.indent,o=n?s?`${a}. `:"• ":"";if(n&&o){const g=t.getTextWidth(o),p=f.options.page.maxContentWidth-l-g,u=t.splitTextToSize(e.content||"",p);if(u.length>0){t.text(o,f.X+l,f.Y,{baseline:"top"}),t.text(u[0],f.X+l+g,f.Y,{baseline:"top",maxWidth:p});for(let v=1;v<u.length;v++)f.updateX(f.options.page.xpading),f.updateY(w(t),"add"),t.text(u[v],f.X+l+g,f.Y,{baseline:"top",maxWidth:p-l-g});f.updateY(w(t),"add"),f.updateX(f.options.page.xpading+l);const d=t.getTextWidth(e.content||"");f.updateX(d,"add")}}else{const g=t.splitTextToSize(e.content||"",f.options.page.maxContentWidth-l);if(f.Y+g.length*w(t)>=f.options.page.maxContentHeight&&D(t),h){const p=Wt(t,e.content||"",f.X+l,f.Y,f.options.page.maxContentWidth-l,f.options.page.defaultLineHeightFactor).y+w(t)*.5;f.updateY(p),f.updateX(f.options.page.xpading)}else t.text(g||"",f.X+l,f.Y,{baseline:"top"}),f.updateX(t.getTextWidth(e.content||""),"add"),f.X>=f.options.page.xpading+f.options.page.maxContentWidth&&D(t)}}},Ht=t=>{const e=t.internal.pageSize.getWidth();t.setLineDashPattern([1,1],0),t.setLineWidth(.1),t.line(f.options.page.xpading,f.Y,e-f.options.page.xpading,f.Y),t.setLineWidth(.1),t.setLineDashPattern([],0),f.updateY(w(t),"add")},Pt=(t,e,i,n)=>{const r=i*f.options.page.indent,a=f.options.page.maxContentWidth-r,s=w(t),h=e.code??"",l=t.splitTextToSize(h,a),o=f.options.page.lineSpace??4,g="#EEEEEE",p="#eee";let u=0;for(;u<l.length;){const d=f.options.page.maxContentHeight-f.Y,v=l.length-u;let y=Math.floor(d/s);if(y<=0){D(t);continue}y>v&&(y=v);const m=l.slice(u,u+y),x=y===v,C=y*s;u===0&&f.updateY(o,"add"),t.setFillColor(g),t.setDrawColor(p),t.roundedRect(f.X,f.Y-o,f.options.page.maxContentWidth,C+o+(x?o:0),2,2,"FD"),u===0&&e.lang&&(t.setFontSize(10),t.text(e.lang,f.X+f.options.page.maxContentWidth-t.getTextWidth(e.lang)-f.options.page.lineSpace/2,f.Y)),t.setFontSize(f.options.page.defaultFontSize),t.text(m,f.X+4,f.Y);const S=y*s;f.updateY(S,"add"),u+=y,u<l.length&&(D(t),f.updateY(o,"add"))}f.updateY(o,"add")},Dt=(t,e,i)=>{const n=t.getFont().fontName,r=t.getFont().fontStyle,a=t.getFontSize(),s=t.getTextColor(),h=f.options.link?.linkColor||[0,0,255];t.setTextColor(...h);const l=f.options.page.maxContentWidth-i-f.X,o=e.text||e.content||"",g=e.href||"",p=t.splitTextToSize(o,l);if(f.isInlineLockActive)for(let u=0;u<p.length;u++){const d=t.getTextDimensions(p[u]).w,v=w(t)/2;t.link(f.X+i,f.Y,d,v,{url:g}),t.text(p[u],f.X+i,f.Y,{baseline:"top",maxWidth:l}),f.updateX(d+1,"add"),f.X+d>f.options.page.maxContentWidth-i&&(f.updateY(v,"add"),f.updateX(f.options.page.xpading+i,"set")),u<p.length-1&&(f.updateY(v,"add"),f.updateX(f.options.page.xpading+i,"set"))}else if(p.length>1){const u=p[0],d=p?.slice(1)?.join(" "),v=t.getTextDimensions(u).w,y=w(t)/2;t.link(f.X+i,f.Y,v,y,{url:g}),t.text(u,f.X+i,f.Y,{baseline:"top",maxWidth:l}),f.updateX(f.options.page.xpading+i),f.updateY(y,"add");const m=f.options.page.maxContentWidth-i-f.options.page.xpading;t.splitTextToSize(d,m).forEach(C=>{const S=t.getTextDimensions(C).w;t.link(f.X+F(t),f.Y,S,y,{url:g}),t.text(C,f.X+F(t),f.Y,{baseline:"top",maxWidth:m})})}else{const u=t.getTextDimensions(o).w,d=w(t)/2;t.link(f.X+i,f.Y,u,d,{url:g}),t.text(o,f.X+i,f.Y,{baseline:"top",maxWidth:l}),f.updateX(u+2,"add")}t.setFont(n,r),t.setFontSize(a),t.setTextColor(s)},Tt=(t,e,i,n)=>{const r=f.options,a=i+1,s=f.X+i*r.page.indent,h=f.Y,l=s+r.page.indent/2,o=h,g=t.internal.getCurrentPageInfo().pageNumber;e.items&&e.items.length>0&&e.items.forEach(d=>{n(d,a)});const p=f.Y,u=t.internal.getCurrentPageInfo().pageNumber;t.setDrawColor(100),t.setLineWidth(1);for(let d=g;d<=u;d++){t.setPage(d);const v=d===g,y=d===u,m=v?o:r.page.topmargin,x=y?p:r.page.maxContentHeight;t.line(l,m,l,x)}t.setPage(u),f.updateY(r.page.lineSpace,"add")},kt=(t,e,i)=>{if(!e.data)return;const n=f.options,r=f.X+i*n.page.indent;let a=f.Y;const s=n.page.maxContentWidth-i*n.page.indent;try{const h=t.getImageProperties(e.data),l=h.width,o=h.height;let g=l,p=o;const u=l/o;g>0&&(g=s,p=g/u),a+p>n.page.maxContentHeight&&(t.addPage(),a=n.page.topmargin,f.updateY(a));let d=e.src?.split(".").pop()?.toUpperCase()||"JPEG";e.data.startsWith("data:image/png")?d="PNG":e.data.startsWith("data:image/jpeg")||e.data.startsWith("data:image/jpg")?d="JPEG":e.data.startsWith("data:image/webp")&&(d="WEBP"),t.addImage(e.data,d,r,a,g,p),f.updateY(p+n.page.lineSpace,"add")}catch(h){console.warn("Failed to render image",h)}};function V(t,e,i,n,r){n=n||{};var a=1.15,s=r.internal.scaleFactor,h=r.internal.getFontSize()/s,l=r.getLineHeightFactor?r.getLineHeightFactor():a,o=h*l,g=/\r\n|\r|\n/g,p="",u=1;if((n.valign==="middle"||n.valign==="bottom"||n.halign==="center"||n.halign==="right")&&(p=typeof t=="string"?t.split(g):t,u=p.length||1),i+=h*(2-a),n.valign==="middle"?i-=u/2*o:n.valign==="bottom"&&(i-=u*o),n.halign==="center"||n.halign==="right"){var d=h;if(n.halign==="center"&&(d*=.5),p&&u>=1){for(var v=0;v<p.length;v++)r.text(p[v],e-r.getStringUnitWidth(p[v])*d,i),i+=o;return r}e-=r.getStringUnitWidth(t)*d}return n.halign==="justify"?r.text(t,e,i,{maxWidth:n.maxWidth||100,align:"justify"}):r.text(t,e,i),r}var q={},T=(function(){function t(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 t.setDefaults=function(e,i){i===void 0&&(i=null),i?i.__autoTableDocumentDefaults=e:q=e},t.unifyColor=function(e){return Array.isArray(e)?e:typeof e=="number"?[e,e,e]:typeof e=="string"?[e]:null},t.prototype.applyStyles=function(e,i){var n,r,a;i===void 0&&(i=!1),e.fontStyle&&this.jsPDFDocument.setFontStyle&&this.jsPDFDocument.setFontStyle(e.fontStyle);var s=this.jsPDFDocument.internal.getFont(),h=s.fontStyle,l=s.fontName;if(e.font&&(l=e.font),e.fontStyle){h=e.fontStyle;var o=this.getFontList()[l];o&&o.indexOf(h)===-1&&this.jsPDFDocument.setFontStyle&&(this.jsPDFDocument.setFontStyle(o[0]),h=o[0])}if(this.jsPDFDocument.setFont(l,h),e.fontSize&&this.jsPDFDocument.setFontSize(e.fontSize),!i){var g=t.unifyColor(e.fillColor);g&&(n=this.jsPDFDocument).setFillColor.apply(n,g),g=t.unifyColor(e.textColor),g&&(r=this.jsPDFDocument).setTextColor.apply(r,g),g=t.unifyColor(e.lineColor),g&&(a=this.jsPDFDocument).setDrawColor.apply(a,g),typeof e.lineWidth=="number"&&this.jsPDFDocument.setLineWidth(e.lineWidth)}},t.prototype.splitTextToSize=function(e,i,n){return this.jsPDFDocument.splitTextToSize(e,i,n)},t.prototype.rect=function(e,i,n,r,a){return this.jsPDFDocument.rect(e,i,n,r,a)},t.prototype.getLastAutoTable=function(){return this.jsPDFDocument.lastAutoTable||null},t.prototype.getTextWidth=function(e){return this.jsPDFDocument.getTextWidth(e)},t.prototype.getDocument=function(){return this.jsPDFDocument},t.prototype.setPage=function(e){this.jsPDFDocument.setPage(e)},t.prototype.addPage=function(){return this.jsPDFDocument.addPage()},t.prototype.getFontList=function(){return this.jsPDFDocument.getFontList()},t.prototype.getGlobalOptions=function(){return q||{}},t.prototype.getDocumentOptions=function(){return this.jsPDFDocument.__autoTableDocumentDefaults||{}},t.prototype.pageSize=function(){var e=this.jsPDFDocument.internal.pageSize;return e.width==null&&(e={width:e.getWidth(),height:e.getHeight()}),e},t.prototype.scaleFactor=function(){return this.jsPDFDocument.internal.scaleFactor},t.prototype.getLineHeightFactor=function(){var e=this.jsPDFDocument;return e.getLineHeightFactor?e.getLineHeightFactor():1.15},t.prototype.getLineHeight=function(e){return e/this.scaleFactor()*this.getLineHeightFactor()},t.prototype.pageNumber=function(){var e=this.jsPDFDocument.internal.getCurrentPageInfo();return e?e.pageNumber:this.jsPDFDocument.internal.getNumberOfPages()},t})(),I=function(t,e){return I=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])},I(t,e)};function tt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");I(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}var et=(function(t){tt(e,t);function e(i){var n=t.call(this)||this;return n._element=i,n}return e})(Array);function Yt(t){return{font:"helvetica",fontStyle:"normal",overflow:"linebreak",fillColor:!1,textColor:20,halign:"left",valign:"top",fontSize:10,cellPadding:5/t,lineColor:200,lineWidth:0,cellWidth:"auto",minCellHeight:0,minCellWidth:0}}function zt(t){var e={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"}}};return e[t]}function Y(t,e,i){i.applyStyles(e,!0);var n=Array.isArray(t)?t:[t],r=n.map(function(a){return i.getTextWidth(a)}).reduce(function(a,s){return Math.max(a,s)},0);return r}function it(t,e,i,n){var r=e.settings.tableLineWidth,a=e.settings.tableLineColor;t.applyStyles({lineWidth:r,lineColor:a});var s=nt(r,!1);s&&t.rect(i.x,i.y,e.getWidth(t.pageSize().width),n.y-i.y,s)}function nt(t,e){var i=t>0,n=e||e===0;return i&&n?"DF":i?"S":n?"F":null}function R(t,e){var i,n,r,a;if(t=t||e,Array.isArray(t)){if(t.length>=4)return{top:t[0],right:t[1],bottom:t[2],left:t[3]};if(t.length===3)return{top:t[0],right:t[1],bottom:t[2],left:t[1]};if(t.length===2)return{top:t[0],right:t[1],bottom:t[0],left:t[1]};t.length===1?t=t[0]:t=e}return typeof t=="object"?(typeof t.vertical=="number"&&(t.top=t.vertical,t.bottom=t.vertical),typeof t.horizontal=="number"&&(t.right=t.horizontal,t.left=t.horizontal),{left:(i=t.left)!==null&&i!==void 0?i:e,top:(n=t.top)!==null&&n!==void 0?n:e,right:(r=t.right)!==null&&r!==void 0?r:e,bottom:(a=t.bottom)!==null&&a!==void 0?a:e}):(typeof t!="number"&&(t=e),{top:t,right:t,bottom:t,left:t})}function rt(t,e){var i=R(e.settings.margin,0);return t.pageSize().width-(i.left+i.right)}function Lt(t,e,i,n,r){var a={},s=1.3333333333333333,h=E(e,function(S){return r.getComputedStyle(S).backgroundColor});h!=null&&(a.fillColor=h);var l=E(e,function(S){return r.getComputedStyle(S).color});l!=null&&(a.textColor=l);var o=Xt(n,i);o&&(a.cellPadding=o);var g="borderTopColor",p=s*i,u=n.borderTopWidth;if(n.borderBottomWidth===u&&n.borderRightWidth===u&&n.borderLeftWidth===u){var d=(parseFloat(u)||0)/p;d&&(a.lineWidth=d)}else a.lineWidth={top:(parseFloat(n.borderTopWidth)||0)/p,right:(parseFloat(n.borderRightWidth)||0)/p,bottom:(parseFloat(n.borderBottomWidth)||0)/p,left:(parseFloat(n.borderLeftWidth)||0)/p},a.lineWidth.top||(a.lineWidth.right?g="borderRightColor":a.lineWidth.bottom?g="borderBottomColor":a.lineWidth.left&&(g="borderLeftColor"));var v=E(e,function(S){return r.getComputedStyle(S)[g]});v!=null&&(a.lineColor=v);var y=["left","right","center","justify"];y.indexOf(n.textAlign)!==-1&&(a.halign=n.textAlign),y=["middle","bottom","top"],y.indexOf(n.verticalAlign)!==-1&&(a.valign=n.verticalAlign);var m=parseInt(n.fontSize||"");isNaN(m)||(a.fontSize=m/s);var x=Rt(n);x&&(a.fontStyle=x);var C=(n.fontFamily||"").toLowerCase();return t.indexOf(C)!==-1&&(a.font=C),a}function Rt(t){var e="";return(t.fontWeight==="bold"||t.fontWeight==="bolder"||parseInt(t.fontWeight)>=700)&&(e="bold"),(t.fontStyle==="italic"||t.fontStyle==="oblique")&&(e+="italic"),e}function E(t,e){var i=at(t,e);if(!i)return null;var n=i.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d*))?\)$/);if(!n||!Array.isArray(n))return null;var r=[parseInt(n[1]),parseInt(n[2]),parseInt(n[3])],a=parseInt(n[4]);return a===0||isNaN(r[0])||isNaN(r[1])||isNaN(r[2])?null:r}function at(t,e){var i=e(t);return i==="rgba(0, 0, 0, 0)"||i==="transparent"||i==="initial"||i==="inherit"?t.parentElement==null?null:at(t.parentElement,e):i}function Xt(t,e){var i=[t.paddingTop,t.paddingRight,t.paddingBottom,t.paddingLeft],n=96/(72/e),r=(parseInt(t.lineHeight)-parseInt(t.fontSize))/e/2,a=i.map(function(h){return parseInt(h||"0")/n}),s=R(a,0);return r>s.top&&(s.top=r),r>s.bottom&&(s.bottom=r),s}function ot(t,e,i,n,r){var a,s;n===void 0&&(n=!1),r===void 0&&(r=!1);var h;typeof e=="string"?h=i.document.querySelector(e):h=e;var l=Object.keys(t.getFontList()),o=t.scaleFactor(),g=[],p=[],u=[];if(!h)return console.error("Html table could not be found with input: ",e),{head:g,body:p,foot:u};for(var d=0;d<h.rows.length;d++){var v=h.rows[d],y=(s=(a=v?.parentElement)===null||a===void 0?void 0:a.tagName)===null||s===void 0?void 0:s.toLowerCase(),m=Et(l,o,i,v,n,r);m&&(y==="thead"?g.push(m):y==="tfoot"?u.push(m):p.push(m))}return{head:g,body:p,foot:u}}function Et(t,e,i,n,r,a){for(var s=new et(n),h=0;h<n.cells.length;h++){var l=n.cells[h],o=i.getComputedStyle(l);if(r||o.display!=="none"){var g=void 0;a&&(g=Lt(t,l,e,o,i)),s.push({rowSpan:l.rowSpan,colSpan:l.colSpan,styles:g,_element:l,content:jt(l)})}}var p=i.getComputedStyle(n);if(s.length>0&&(r||p.display!=="none"))return s}function jt(t){var e=t.cloneNode(!0);return e.innerHTML=e.innerHTML.replace(/\n/g,"").replace(/ +/g," "),e.innerHTML=e.innerHTML.split(/<br.*?>/).map(function(i){return i.trim()}).join(`
|
|
2
|
+
`),e.innerText||e.textContent||""}function At(t,e,i){for(var n=0,r=[t,e,i];n<r.length;n++){var a=r[n];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 H(t,e,i,n,r){if(t==null)throw new TypeError("Cannot convert undefined or null to object");for(var a=Object(t),s=1;s<arguments.length;s++){var h=arguments[s];if(h!=null)for(var l in h)Object.prototype.hasOwnProperty.call(h,l)&&(a[l]=h[l])}return a}function st(t,e){var i=new T(t),n=i.getDocumentOptions(),r=i.getGlobalOptions();At(r,n,e);var a=H({},r,n,e),s;typeof window<"u"&&(s=window);var h=Bt(r,n,e),l=It(r,n,e),o=Nt(i,a),g=Ot(i,a,s);return{id:e.tableId,content:g,hooks:l,styles:h,settings:o}}function Bt(t,e,i){for(var n={styles:{},headStyles:{},bodyStyles:{},footStyles:{},alternateRowStyles:{},columnStyles:{}},r=function(l){if(l==="columnStyles"){var o=t[l],g=e[l],p=i[l];n.columnStyles=H({},o,g,p)}else{var u=[t,e,i],d=u.map(function(v){return v[l]||{}});n[l]=H({},d[0],d[1],d[2])}},a=0,s=Object.keys(n);a<s.length;a++){var h=s[a];r(h)}return n}function It(t,e,i){for(var n=[t,e,i],r={didParseCell:[],willDrawCell:[],didDrawCell:[],willDrawPage:[],didDrawPage:[]},a=0,s=n;a<s.length;a++){var h=s[a];h.didParseCell&&r.didParseCell.push(h.didParseCell),h.willDrawCell&&r.willDrawCell.push(h.willDrawCell),h.didDrawCell&&r.didDrawCell.push(h.didDrawCell),h.willDrawPage&&r.willDrawPage.push(h.willDrawPage),h.didDrawPage&&r.didDrawPage.push(h.didDrawPage)}return r}function Nt(t,e){var i,n,r,a,s,h,l,o,g,p,u,d,v=R(e.margin,40/t.scaleFactor()),y=(i=Mt(t,e.startY))!==null&&i!==void 0?i:v.top,m;e.showFoot===!0?m="everyPage":e.showFoot===!1?m="never":m=(n=e.showFoot)!==null&&n!==void 0?n:"everyPage";var x;e.showHead===!0?x="everyPage":e.showHead===!1?x="never":x=(r=e.showHead)!==null&&r!==void 0?r:"everyPage";var C=(a=e.useCss)!==null&&a!==void 0?a:!1,S=e.theme||(C?"plain":"striped"),W=!!e.horizontalPageBreak,X=(s=e.horizontalPageBreakRepeat)!==null&&s!==void 0?s:null;return{includeHiddenHtml:(h=e.includeHiddenHtml)!==null&&h!==void 0?h:!1,useCss:C,theme:S,startY:y,margin:v,pageBreak:(l=e.pageBreak)!==null&&l!==void 0?l:"auto",rowPageBreak:(o=e.rowPageBreak)!==null&&o!==void 0?o:"auto",tableWidth:(g=e.tableWidth)!==null&&g!==void 0?g:"auto",showHead:x,showFoot:m,tableLineWidth:(p=e.tableLineWidth)!==null&&p!==void 0?p:0,tableLineColor:(u=e.tableLineColor)!==null&&u!==void 0?u:200,horizontalPageBreak:W,horizontalPageBreakRepeat:X,horizontalPageBreakBehaviour:(d=e.horizontalPageBreakBehaviour)!==null&&d!==void 0?d:"afterAllRows"}}function Mt(t,e){var i=t.getLastAutoTable(),n=t.scaleFactor(),r=t.pageNumber(),a=!1;if(i&&i.startPageNumber){var s=i.startPageNumber+i.pageNumber-1;a=s===r}return typeof e=="number"?e:(e==null||e===!1)&&a&&i?.finalY!=null?i.finalY+20/n:null}function Ot(t,e,i){var n=e.head||[],r=e.body||[],a=e.foot||[];if(e.html){var s=e.includeHiddenHtml;if(i){var h=ot(t,e.html,i,s,e.useCss)||{};n=h.head||n,r=h.body||n,a=h.foot||n}else console.error("Cannot parse html in non browser environment")}var l=e.columns||qt(n,r,a);return{columns:l,head:n,body:r,foot:a}}function qt(t,e,i){var n=t[0]||e[0]||i[0]||[],r=[];return Object.keys(n).filter(function(a){return a!=="_element"}).forEach(function(a){var s=1,h;Array.isArray(n)?h=n[parseInt(a)]:h=n[a],typeof h=="object"&&!Array.isArray(h)&&(s=h?.colSpan||1);for(var l=0;l<s;l++){var o=void 0;Array.isArray(n)?o=r.length:o=a+(l>0?"_".concat(l):"");var g={dataKey:o};r.push(g)}}),r}var N=(function(){function t(e,i,n){this.table=i,this.pageNumber=i.pageNumber,this.settings=i.settings,this.cursor=n,this.doc=e.getDocument()}return t})(),Jt=(function(t){tt(e,t);function e(i,n,r,a,s,h){var l=t.call(this,i,n,h)||this;return l.cell=r,l.row=a,l.column=s,l.section=a.section,l}return e})(N),Kt=(function(){function t(e,i){this.pageNumber=1,this.id=e.id,this.settings=e.settings,this.styles=e.styles,this.hooks=e.hooks,this.columns=i.columns,this.head=i.head,this.body=i.body,this.foot=i.foot}return t.prototype.getHeadHeight=function(e){return this.head.reduce(function(i,n){return i+n.getMaxCellHeight(e)},0)},t.prototype.getFootHeight=function(e){return this.foot.reduce(function(i,n){return i+n.getMaxCellHeight(e)},0)},t.prototype.allRows=function(){return this.head.concat(this.body).concat(this.foot)},t.prototype.callCellHooks=function(e,i,n,r,a,s){for(var h=0,l=i;h<l.length;h++){var o=l[h],g=new Jt(e,this,n,r,a,s),p=o(g)===!1;if(n.text=Array.isArray(n.text)?n.text:[n.text],p)return!1}return!0},t.prototype.callEndPageHooks=function(e,i){e.applyStyles(e.userStyles);for(var n=0,r=this.hooks.didDrawPage;n<r.length;n++){var a=r[n];a(new N(e,this,i))}},t.prototype.callWillDrawPageHooks=function(e,i){for(var n=0,r=this.hooks.willDrawPage;n<r.length;n++){var a=r[n];a(new N(e,this,i))}},t.prototype.getWidth=function(e){if(typeof this.settings.tableWidth=="number")return this.settings.tableWidth;if(this.settings.tableWidth==="wrap"){var i=this.columns.reduce(function(r,a){return r+a.wrappedWidth},0);return i}else{var n=this.settings.margin;return e-n.left-n.right}},t})(),lt=(function(){function t(e,i,n,r,a){a===void 0&&(a=!1),this.height=0,this.raw=e,e instanceof et&&(this.raw=e._element,this.element=e._element),this.index=i,this.section=n,this.cells=r,this.spansMultiplePages=a}return t.prototype.getMaxCellHeight=function(e){var i=this;return e.reduce(function(n,r){var a;return Math.max(n,((a=i.cells[r.index])===null||a===void 0?void 0:a.height)||0)},0)},t.prototype.hasRowSpan=function(e){var i=this;return e.filter(function(n){var r=i.cells[n.index];return r?r.rowSpan>1:!1}).length>0},t.prototype.canEntireRowFit=function(e,i){return this.getMaxCellHeight(i)<=e},t.prototype.getMinimumRowHeight=function(e,i){var n=this;return e.reduce(function(r,a){var s=n.cells[a.index];if(!s)return 0;var h=i.getLineHeight(s.styles.fontSize),l=s.padding("vertical"),o=l+h;return o>r?o:r},0)},t})(),ht=(function(){function t(e,i,n){var r;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=i,this.section=n,this.raw=e;var a=e;e!=null&&typeof e=="object"&&!Array.isArray(e)?(this.rowSpan=e.rowSpan||1,this.colSpan=e.colSpan||1,a=(r=e.content)!==null&&r!==void 0?r:e,e._element&&(this.raw=e._element)):(this.rowSpan=1,this.colSpan=1);var s=a!=null?""+a:"",h=/\r\n|\r|\n/g;this.text=s.split(h)}return t.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 i=this.height-this.padding("vertical");e=this.y+i/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}},t.prototype.getContentHeight=function(e,i){i===void 0&&(i=1.15);var n=Array.isArray(this.text)?this.text.length:1,r=this.styles.fontSize/e*i,a=n*r+this.padding("vertical");return Math.max(a,this.styles.minCellHeight)},t.prototype.padding=function(e){var i=R(this.styles.cellPadding,0);return e==="vertical"?i.top+i.bottom:e==="horizontal"?i.left+i.right:i[e]},t})(),$t=(function(){function t(e,i,n){this.wrappedWidth=0,this.minReadableWidth=0,this.minWidth=0,this.width=0,this.dataKey=e,this.raw=i,this.index=n}return t.prototype.getMaxCustomCellWidth=function(e){for(var i=0,n=0,r=e.allRows();n<r.length;n++){var a=r[n],s=a.cells[this.index];s&&typeof s.styles.cellWidth=="number"&&(i=Math.max(i,s.styles.cellWidth))}return i},t})();function Ut(t,e){_t(t,e);var i=[],n=0;e.columns.forEach(function(a){var s=a.getMaxCustomCellWidth(e);s?a.width=s:(a.width=a.wrappedWidth,i.push(a)),n+=a.width});var r=e.getWidth(t.pageSize().width)-n;r&&(r=M(i,r,function(a){return Math.max(a.minReadableWidth,a.minWidth)})),r&&(r=M(i,r,function(a){return a.minWidth})),r=Math.abs(r),!e.settings.horizontalPageBreak&&r>.1/t.scaleFactor()&&(r=r<1?r:Math.round(r),console.warn("Of the table content, ".concat(r," units width could not fit page"))),Qt(e),Zt(e,t),Gt(e)}function _t(t,e){var i=t.scaleFactor(),n=e.settings.horizontalPageBreak,r=rt(t,e);e.allRows().forEach(function(a){for(var s=0,h=e.columns;s<h.length;s++){var l=h[s],o=a.cells[l.index];if(o){var g=e.hooks.didParseCell;e.callCellHooks(t,g,o,a,l,null);var p=o.padding("horizontal");o.contentWidth=Y(o.text,o.styles,t)+p;var u=Y(o.text.join(" ").split(/[^\S\u00A0]+/),o.styles,t);if(o.minReadableWidth=u+o.padding("horizontal"),typeof o.styles.cellWidth=="number")o.minWidth=o.styles.cellWidth,o.wrappedWidth=o.styles.cellWidth;else if(o.styles.cellWidth==="wrap"||n===!0)o.contentWidth>r?(o.minWidth=r,o.wrappedWidth=r):(o.minWidth=o.contentWidth,o.wrappedWidth=o.contentWidth);else{var d=10/i;o.minWidth=o.styles.minCellWidth||d,o.wrappedWidth=o.contentWidth,o.minWidth>o.wrappedWidth&&(o.wrappedWidth=o.minWidth)}}}}),e.allRows().forEach(function(a){for(var s=0,h=e.columns;s<h.length;s++){var l=h[s],o=a.cells[l.index];if(o&&o.colSpan===1)l.wrappedWidth=Math.max(l.wrappedWidth,o.wrappedWidth),l.minWidth=Math.max(l.minWidth,o.minWidth),l.minReadableWidth=Math.max(l.minReadableWidth,o.minReadableWidth);else{var g=e.styles.columnStyles[l.dataKey]||e.styles.columnStyles[l.index]||{},p=g.cellWidth||g.minCellWidth;p&&typeof p=="number"&&(l.minWidth=p,l.wrappedWidth=p)}o&&(o.colSpan>1&&!l.minWidth&&(l.minWidth=o.minWidth),o.colSpan>1&&!l.wrappedWidth&&(l.wrappedWidth=o.minWidth))}})}function M(t,e,i){for(var n=e,r=t.reduce(function(d,v){return d+v.wrappedWidth},0),a=0;a<t.length;a++){var s=t[a],h=s.wrappedWidth/r,l=n*h,o=s.width+l,g=i(s),p=o<g?g:o;e-=p-s.width,s.width=p}if(e=Math.round(e*1e10)/1e10,e){var u=t.filter(function(d){return e<0?d.width>i(d):!0});u.length&&(e=M(u,e,i))}return e}function Gt(t){for(var e={},i=1,n=t.allRows(),r=0;r<n.length;r++)for(var a=n[r],s=0,h=t.columns;s<h.length;s++){var l=h[s],o=e[l.index];if(i>1)i--,delete a.cells[l.index];else if(o)o.cell.height+=a.height,i=o.cell.colSpan,delete a.cells[l.index],o.left--,o.left<=1&&delete e[l.index];else{var g=a.cells[l.index];if(!g)continue;if(g.height=a.height,g.rowSpan>1){var p=n.length-r,u=g.rowSpan>p?p:g.rowSpan;e[l.index]={cell:g,left:u,row:a}}}}}function Qt(t){for(var e=t.allRows(),i=0;i<e.length;i++)for(var n=e[i],r=null,a=0,s=0,h=0;h<t.columns.length;h++){var l=t.columns[h];if(s-=1,s>1&&t.columns[h+1])a+=l.width,delete n.cells[l.index];else if(r){var o=r;delete n.cells[l.index],r=null,o.width=l.width+a}else{var o=n.cells[l.index];if(!o)continue;if(s=o.colSpan,a=0,o.colSpan>1){r=o,a+=l.width;continue}o.width=l.width+a}}}function Zt(t,e){for(var i={count:0,height:0},n=0,r=t.allRows();n<r.length;n++){for(var a=r[n],s=0,h=t.columns;s<h.length;s++){var l=h[s],o=a.cells[l.index];if(o){e.applyStyles(o.styles,!0);var g=o.width-o.padding("horizontal");if(o.styles.overflow==="linebreak")o.text=e.splitTextToSize(o.text,g+1/e.scaleFactor(),{fontSize:o.styles.fontSize});else if(o.styles.overflow==="ellipsize")o.text=J(o.text,g,o.styles,e,"...");else if(o.styles.overflow==="hidden")o.text=J(o.text,g,o.styles,e,"");else if(typeof o.styles.overflow=="function"){var p=o.styles.overflow(o.text,g);typeof p=="string"?o.text=[p]:o.text=p}o.contentHeight=o.getContentHeight(e.scaleFactor(),e.getLineHeightFactor());var u=o.contentHeight/o.rowSpan;o.rowSpan>1&&i.count*i.height<u*o.rowSpan?i={height:u,count:o.rowSpan}:i&&i.count>0&&i.height>u&&(u=i.height),u>a.height&&(a.height=u)}}i.count--}}function J(t,e,i,n,r){return t.map(function(a){return Vt(a,e,i,n,r)})}function Vt(t,e,i,n,r){var a=1e4*n.scaleFactor();if(e=Math.ceil(e*a)/a,e>=Y(t,i,n))return t;for(;e<Y(t+r,i,n)&&!(t.length<=1);)t=t.substring(0,t.length-1);return t.trim()+r}function ft(t,e){var i=new T(t),n=te(e,i.scaleFactor()),r=new Kt(e,n);return Ut(i,r),i.applyStyles(i.userStyles),r}function te(t,e){var i=t.content,n=ie(i.columns);if(i.head.length===0){var r=K(n,"head");r&&i.head.push(r)}if(i.foot.length===0){var r=K(n,"foot");r&&i.foot.push(r)}var a=t.settings.theme,s=t.styles;return{columns:n,head:j("head",i.head,n,s,a,e),body:j("body",i.body,n,s,a,e),foot:j("foot",i.foot,n,s,a,e)}}function j(t,e,i,n,r,a){var s={},h=e.map(function(l,o){for(var g=0,p={},u=0,d=0,v=0,y=i;v<y.length;v++){var m=y[v];if(s[m.index]==null||s[m.index].left===0)if(d===0){var x=void 0;Array.isArray(l)?x=l[m.index-u-g]:x=l[m.dataKey];var C={};typeof x=="object"&&!Array.isArray(x)&&(C=x?.styles||{});var S=ne(t,m,o,r,n,a,C),W=new ht(x,S,t);p[m.dataKey]=W,p[m.index]=W,d=W.colSpan-1,s[m.index]={left:W.rowSpan-1,times:d}}else d--,u++;else s[m.index].left--,d=s[m.index].times,g++}return new lt(l,o,t,p)});return h}function K(t,e){var i={};return t.forEach(function(n){if(n.raw!=null){var r=ee(e,n.raw);r!=null&&(i[n.dataKey]=r)}}),Object.keys(i).length>0?i:null}function ee(t,e){if(t==="head"){if(typeof e=="object")return e.header||null;if(typeof e=="string"||typeof e=="number")return e}else if(t==="foot"&&typeof e=="object")return e.footer;return null}function ie(t){return t.map(function(e,i){var n,r;return typeof e=="object"?r=(n=e.dataKey)!==null&&n!==void 0?n:i:r=i,new $t(r,e,i)})}function ne(t,e,i,n,r,a,s){var h=zt(n),l;t==="head"?l=r.headStyles:t==="body"?l=r.bodyStyles:t==="foot"&&(l=r.footStyles);var o=H({},h.table,h[t],r.styles,l),g=r.columnStyles[e.dataKey]||r.columnStyles[e.index]||{},p=t==="body"?g:{},u=t==="body"&&i%2===0?H({},h.alternateRow,r.alternateRowStyles):{},d=Yt(a),v=H({},d,o,u,p);return H(v,s)}function re(t,e,i){var n;i===void 0&&(i={});var r=rt(t,e),a=new Map,s=[],h=[],l=[];Array.isArray(e.settings.horizontalPageBreakRepeat)?l=e.settings.horizontalPageBreakRepeat:(typeof e.settings.horizontalPageBreakRepeat=="string"||typeof e.settings.horizontalPageBreakRepeat=="number")&&(l=[e.settings.horizontalPageBreakRepeat]),l.forEach(function(u){var d=e.columns.find(function(v){return v.dataKey===u||v.index===u});d&&!a.has(d.index)&&(a.set(d.index,!0),s.push(d.index),h.push(e.columns[d.index]),r-=d.wrappedWidth)});for(var o=!0,g=(n=i?.start)!==null&&n!==void 0?n:0;g<e.columns.length;){if(a.has(g)){g++;continue}var p=e.columns[g].wrappedWidth;if(o||r>=p)o=!1,s.push(g),h.push(e.columns[g]),r-=p;else break;g++}return{colIndexes:s,columns:h,lastIndex:g-1}}function ae(t,e){for(var i=[],n=0;n<e.columns.length;n++){var r=re(t,e,{start:n});r.columns.length&&(i.push(r),n=r.lastIndex)}return i}function gt(t,e){var i=e.settings,n=i.startY,r=i.margin,a={x:r.left,y:n},s=e.getHeadHeight(e.columns)+e.getFootHeight(e.columns),h=n+r.bottom+s;if(i.pageBreak==="avoid"){var l=e.body,o=l.reduce(function(u,d){return u+d.height},0);h+=o}var g=new T(t);(i.pageBreak==="always"||i.startY!=null&&h>g.pageSize().height)&&(ut(g),a.y=r.top),e.callWillDrawPageHooks(g,a);var p=H({},a);e.startPageNumber=g.pageNumber(),i.horizontalPageBreak?oe(g,e,p,a):(g.applyStyles(g.userStyles),(i.showHead==="firstPage"||i.showHead==="everyPage")&&e.head.forEach(function(u){return P(g,e,u,a,e.columns)}),g.applyStyles(g.userStyles),e.body.forEach(function(u,d){var v=d===e.body.length-1;z(g,e,u,v,p,a,e.columns)}),g.applyStyles(g.userStyles),(i.showFoot==="lastPage"||i.showFoot==="everyPage")&&e.foot.forEach(function(u){return P(g,e,u,a,e.columns)})),it(g,e,p,a),e.callEndPageHooks(g,a),e.finalY=a.y,t.lastAutoTable=e,g.applyStyles(g.userStyles)}function oe(t,e,i,n){var r=ae(t,e),a=e.settings;if(a.horizontalPageBreakBehaviour==="afterAllRows")r.forEach(function(o,g){t.applyStyles(t.userStyles),g>0?k(t,e,i,n,o.columns,!0):$(t,e,n,o.columns),se(t,e,i,n,o.columns),A(t,e,n,o.columns)});else for(var s=-1,h=r[0],l=function(){var o=s;if(h){t.applyStyles(t.userStyles);var g=h.columns;s>=0?k(t,e,i,n,g,!0):$(t,e,n,g),o=U(t,e,s+1,n,g),A(t,e,n,g)}var p=o-s;r.slice(1).forEach(function(u){t.applyStyles(t.userStyles),k(t,e,i,n,u.columns,!0),U(t,e,s+1,n,u.columns,p),A(t,e,n,u.columns)}),s=o};s<e.body.length-1;)l()}function $(t,e,i,n){var r=e.settings;t.applyStyles(t.userStyles),(r.showHead==="firstPage"||r.showHead==="everyPage")&&e.head.forEach(function(a){return P(t,e,a,i,n)})}function se(t,e,i,n,r){t.applyStyles(t.userStyles),e.body.forEach(function(a,s){var h=s===e.body.length-1;z(t,e,a,h,i,n,r)})}function U(t,e,i,n,r,a){t.applyStyles(t.userStyles),a=a??e.body.length;var s=Math.min(i+a,e.body.length),h=-1;return e.body.slice(i,s).forEach(function(l,o){var g=i+o===e.body.length-1,p=pt(t,e,g,n);l.canEntireRowFit(p,r)&&(P(t,e,l,n,r),h=i+o)}),h}function A(t,e,i,n){var r=e.settings;t.applyStyles(t.userStyles),(r.showFoot==="lastPage"||r.showFoot==="everyPage")&&e.foot.forEach(function(a){return P(t,e,a,i,n)})}function le(t,e,i){var n=i.getLineHeight(t.styles.fontSize),r=t.padding("vertical"),a=Math.floor((e-r)/n);return Math.max(0,a)}function he(t,e,i,n){var r={};t.spansMultiplePages=!0,t.height=0;for(var a=0,s=0,h=i.columns;s<h.length;s++){var l=h[s],o=t.cells[l.index];if(o){Array.isArray(o.text)||(o.text=[o.text]);var g=new ht(o.raw,o.styles,o.section);g=H(g,o),g.text=[];var p=le(o,e,n);o.text.length>p&&(g.text=o.text.splice(p,o.text.length));var u=n.scaleFactor(),d=n.getLineHeightFactor();o.contentHeight=o.getContentHeight(u,d),o.contentHeight>=e&&(o.contentHeight=e,g.styles.minCellHeight-=e),o.contentHeight>t.height&&(t.height=o.contentHeight),g.contentHeight=g.getContentHeight(u,d),g.contentHeight>a&&(a=g.contentHeight),r[l.index]=g}}var v=new lt(t.raw,-1,t.section,r,!0);v.height=a;for(var y=0,m=i.columns;y<m.length;y++){var l=m[y],g=v.cells[l.index];g&&(g.height=v.height);var o=t.cells[l.index];o&&(o.height=t.height)}return v}function fe(t,e,i,n){var r=t.pageSize().height,a=n.settings.margin,s=a.top+a.bottom,h=r-s;e.section==="body"&&(h-=n.getHeadHeight(n.columns)+n.getFootHeight(n.columns));var l=e.getMinimumRowHeight(n.columns,t),o=l<i;if(l>h)return console.error("Will not be able to print row ".concat(e.index," correctly since it's minimum height is larger than page height")),!0;if(!o)return!1;var g=e.hasRowSpan(n.columns),p=e.getMaxCellHeight(n.columns)>h;return p?(g&&console.error("The content of row ".concat(e.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):!(g||n.settings.rowPageBreak==="avoid")}function z(t,e,i,n,r,a,s){var h=pt(t,e,n,a);if(i.canEntireRowFit(h,s))P(t,e,i,a,s);else if(fe(t,i,h,e)){var l=he(i,h,e,t);P(t,e,i,a,s),k(t,e,r,a,s),z(t,e,l,n,r,a,s)}else k(t,e,r,a,s),z(t,e,i,n,r,a,s)}function P(t,e,i,n,r){n.x=e.settings.margin.left;for(var a=0,s=r;a<s.length;a++){var h=s[a],l=i.cells[h.index];if(!l){n.x+=h.width;continue}t.applyStyles(l.styles),l.x=n.x,l.y=n.y;var o=e.callCellHooks(t,e.hooks.willDrawCell,l,i,h,n);if(o===!1){n.x+=h.width;continue}ge(t,l,n);var g=l.getTextPos();V(l.text,g.x,g.y,{halign:l.styles.halign,valign:l.styles.valign,maxWidth:Math.ceil(l.width-l.padding("left")-l.padding("right"))},t.getDocument()),e.callCellHooks(t,e.hooks.didDrawCell,l,i,h,n),n.x+=h.width}n.y+=i.height}function ge(t,e,i){var n=e.styles;if(t.getDocument().setFillColor(t.getDocument().getFillColor()),typeof n.lineWidth=="number"){var r=nt(n.lineWidth,n.fillColor);r&&t.rect(e.x,i.y,e.width,e.height,r)}else typeof n.lineWidth=="object"&&(n.fillColor&&t.rect(e.x,i.y,e.width,e.height,"F"),pe(t,e,i,n.lineWidth))}function pe(t,e,i,n){var r,a,s,h;n.top&&(r=i.x,a=i.y,s=i.x+e.width,h=i.y,n.right&&(s+=.5*n.right),n.left&&(r-=.5*n.left),l(n.top,r,a,s,h)),n.bottom&&(r=i.x,a=i.y+e.height,s=i.x+e.width,h=i.y+e.height,n.right&&(s+=.5*n.right),n.left&&(r-=.5*n.left),l(n.bottom,r,a,s,h)),n.left&&(r=i.x,a=i.y,s=i.x,h=i.y+e.height,n.top&&(a-=.5*n.top),n.bottom&&(h+=.5*n.bottom),l(n.left,r,a,s,h)),n.right&&(r=i.x+e.width,a=i.y,s=i.x+e.width,h=i.y+e.height,n.top&&(a-=.5*n.top),n.bottom&&(h+=.5*n.bottom),l(n.right,r,a,s,h));function l(o,g,p,u,d){t.getDocument().setLineWidth(o),t.getDocument().line(g,p,u,d,"S")}}function pt(t,e,i,n){var r=e.settings.margin.bottom,a=e.settings.showFoot;return(a==="everyPage"||a==="lastPage"&&i)&&(r+=e.getFootHeight(e.columns)),t.pageSize().height-n.y-r}function k(t,e,i,n,r,a){r===void 0&&(r=[]),a===void 0&&(a=!1),t.applyStyles(t.userStyles),e.settings.showFoot==="everyPage"&&!a&&e.foot.forEach(function(h){return P(t,e,h,n,r)}),e.callEndPageHooks(t,n);var s=e.settings.margin;it(t,e,i,n),ut(t),e.pageNumber++,n.x=s.left,n.y=s.top,i.y=s.top,e.callWillDrawPageHooks(t,n),e.settings.showHead==="everyPage"&&(e.head.forEach(function(h){return P(t,e,h,n,r)}),t.applyStyles(t.userStyles))}function ut(t){var e=t.pageNumber();t.setPage(e+1);var i=t.pageNumber();return i===e?(t.addPage(),!0):!1}function ue(t){t.API.autoTable=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=e[0],r=st(this,n),a=ft(this,r);return gt(this,a),this},t.API.lastAutoTable=!1,t.API.autoTableText=function(e,i,n,r){V(e,i,n,r,this)},t.API.autoTableSetDefaults=function(e){return T.setDefaults(e,this),this},t.autoTableSetDefaults=function(e,i){T.setDefaults(e,i)},t.API.autoTableHtmlToJson=function(e,i){var n;if(i===void 0&&(i=!1),typeof window>"u")return console.error("Cannot run autoTableHtmlToJson in non browser environment"),null;var r=new T(this),a=ot(r,e,window,i,!1),s=a.head,h=a.body,l=((n=s[0])===null||n===void 0?void 0:n.map(function(o){return o.content}))||[];return{columns:l,rows:h,data:h}}}var B;function de(t,e){var i=st(t,e),n=ft(t,i);gt(t,n)}try{if(typeof window<"u"&&window){var _=window,G=_.jsPDF||((B=_.jspdf)===null||B===void 0?void 0:B.jsPDF);G&&ue(G)}}catch(t){console.error("Could not apply autoTable plugin",t)}const ve=(t,e,i)=>{if(!e.header||!e.rows)return;const n=f.options,r=n.page.xmargin+i*n.page.indent,a=[e.header.map(l=>l.content||"")],s=e.rows.map(l=>l.map(o=>o.content||"")),h=n.table||{};de(t,{head:a,body:s,startY:f.Y,margin:{left:r,right:n.page.xmargin},...h,didDrawPage:l=>{h.didDrawPage&&h.didDrawPage(l)},didDrawCell:l=>{h.didDrawCell&&h.didDrawCell(l),f.setCursor({x:f.X,y:l.cell.y+2*n.page.lineSpace})}})},dt=async t=>{for(const e of t){if(e.type===c.Image&&e.src)try{if(e.src.startsWith("data:"))e.data=e.src;else{const i=await fetch(e.src);if(!i.ok)throw new Error(`Failed to fetch image: ${i.statusText}`);const n=await i.blob(),r=await new Promise((a,s)=>{const h=new FileReader;h.onloadend=()=>{typeof h.result=="string"?a(h.result):s(new Error("Failed to convert image to base64 string"))},h.onerror=s,h.readAsDataURL(n)});e.data=r}}catch(i){console.warn(`[jspdf-md-renderer] Warning: Failed to load image at ${e.src}. It will be skipped.`,i)}e.items&&e.items.length>0&&await dt(e.items)}},Q={page:{indent:10,maxContentWidth:190,maxContentHeight:277,lineSpace:1.5,defaultLineHeightFactor:1.2,defaultFontSize:12,defaultTitleFontSize:14,topmargin:10,xpading:10,xmargin:10,format:"a4",orientation:"p"},font:{bold:{name:"helvetica",style:"bold"},regular:{name:"helvetica",style:"normal"},light:{name:"helvetica",style:"light"}}},ce=t=>{if(!t)throw new Error("RenderOption is required");const e={...Q.page,...t.page},i={...Q.font,...t.font};return e.maxContentWidth||(e.maxContentWidth=190),e.maxContentHeight||(e.maxContentHeight=277),{...t,page:e,font:i}},ye=async(t,e,i)=>{const n=ce(i);f.initialize(n);const r=await Z(e);await dt(r),console.log(r);const a=(s,h=0,l=!1,o=0,g=!1,p=!0)=>{const u=h*n.page.indent;switch(f.Y+t.splitTextToSize(s.content??"",n.page.maxContentWidth-u).length*w(t)>=n.page.maxContentHeight&&D(t),s.type){case c.Heading:yt(t,s,u,a);break;case c.Paragraph:xt(t,s,u,a);break;case c.List:wt(t,s,h,a);break;case c.ListItem:St(t,s,h,a,o,g);break;case c.Hr:Ht(t);break;case c.Code:Pt(t,s,h);break;case c.Strong:case c.Em:case c.CodeSpan:O(t,s,u);break;case c.Link:Dt(t,s,u);break;case c.Blockquote:Tt(t,s,h,a);break;case c.Image:kt(t,s,h);break;case c.Table:ve(t,s,h);break;case c.Raw:case c.Text:Ft(t,s,h,l,a,o,g,n.page.defaultFontSize>0);break;default:console.warn(`Warning: Unsupported element type encountered: ${s.type}.
|
|
2
3
|
If you believe this element type should be supported, please create an issue at:
|
|
3
4
|
https://github.com/JeelGajera/jspdf-md-renderer/issues
|
|
4
|
-
with details of the element and expected behavior. Thanks for helping to improve this library!`);break}};for(const
|
|
5
|
+
with details of the element and expected behavior. Thanks for helping to improve this library!`);break}};for(const s of r)a(s);n.endCursorYHandler(f.Y)};exports.MdTextParser=Z;exports.MdTextRender=ye;
|