UNPKG

survey-pdf

Version:

Renders JSON-driven SurveyJS forms and their responses as PDF documents in the browser or Node.js: fillable interactive PDF forms (AcroForm) or static printouts.

50 lines • 224 kB
/*!
 * For license information please see survey.pdf.min.js.LICENSE.txt
 */

(function(B,D){typeof exports=="object"&&typeof module<"u"?D(exports,require("survey-core"),require("jspdf")):typeof define=="function"&&define.amd?define(["exports","survey-core","jspdf"],D):(B=typeof globalThis<"u"?globalThis:B||self,D(B.SurveyPDF={},B.Survey,B.jspdf))})(this,(function(B,D,Ot){"use strict";function te(...m){if(m.length==0)return{xLeft:0,xRight:0,yTop:0,yBot:0};const t={xLeft:m[0].xLeft,xRight:m[0].xRight,yTop:m[0].yTop,yBot:m[0].yBot};return m.forEach(e=>{t.xLeft=Math.min(t.xLeft,e.xLeft),t.xRight=Math.max(t.xRight,e.xRight),t.yTop=Math.min(t.yTop,e.yTop),t.yBot=Math.max(t.yBot,e.yBot)}),t}function Mt(m){if(Array.isArray(m)&&m.length>1){if(m.length==2)return{top:m[0],bot:m[0],left:m[1],right:m[1]};if(m.length==3)return{top:m[0],left:m[1],right:m[1],bot:m[2]};if(m.length==4)return{top:m[0],right:m[1],bot:m[2],left:m[3]}}else{const t=Array.isArray(m)?m[0]:m;return{top:t,bot:t,right:t,left:t}}}function es(m){return m&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m}var Bt={},ie,ye;function ss(){return ye||(ye=1,ie=function(t,e,s,i){var n=s?s.call(i,t,e):void 0;if(n!==void 0)return!!n;if(t===e)return!0;if(typeof t!="object"||!t||typeof e!="object"||!e)return!1;var r=Object.keys(t),l=Object.keys(e);if(r.length!==l.length)return!1;for(var a=Object.prototype.hasOwnProperty.bind(e),h=0;h<r.length;h++){var u=r[h];if(!a(u))return!1;var g=t[u],b=e[u];if(n=s?s.call(i,g,b,u):void 0,n===!1||n===void 0&&g!==b)return!1}return!0}),ie}var me;function is(){if(me)return Bt;me=1,Object.defineProperty(Bt,"__esModule",{value:!0});var m=ss();function t(l){return l===void 0?-1:l.height}var e=(function(){function l(a,h){this.intervalTree=a,this.records=[],this.height=0,this.key=h.low,this.max=h.high,this.records.push(h)}return l.prototype.getNodeHigh=function(){for(var a=this.records[0].high,h=1;h<this.records.length;h++)this.records[h].high>a&&(a=this.records[h].high);return a},l.prototype.updateHeight=function(){this.height=Math.max(t(this.left),t(this.right))+1},l.prototype.updateMaxOfParents=function(){if(this!==void 0){var a=this.getNodeHigh();this.left!==void 0&&this.right!==void 0?this.max=Math.max(Math.max(this.left.max,this.right.max),a):this.left!==void 0&&this.right===void 0?this.max=Math.max(this.left.max,a):this.left===void 0&&this.right!==void 0?this.max=Math.max(this.right.max,a):this.max=a,this.parent&&this.parent.updateMaxOfParents()}},l.prototype._updateMaxAfterRightRotate=function(){var a=this.parent,h=a.left,u=h.getNodeHigh();h.left===void 0&&h.right!==void 0?h.max=Math.max(u,h.right.max):h.left!==void 0&&h.right===void 0?h.max=Math.max(u,h.left.max):h.left===void 0&&h.right===void 0?h.max=u:h.max=Math.max(Math.max(h.left.max,h.right.max),u);var g=this.getNodeHigh();this.left===void 0&&this.right!==void 0?this.max=Math.max(g,this.right.max):this.left!==void 0&&this.right===void 0?this.max=Math.max(g,this.left.max):this.left===void 0&&this.right===void 0?this.max=g:this.max=Math.max(Math.max(this.left.max,this.right.max),g),a.max=Math.max(Math.max(a.left.max,a.right.max),a.getNodeHigh())},l.prototype._updateMaxAfterLeftRotate=function(){var a=this.parent,h=a.right,u=h.getNodeHigh();h.left===void 0&&h.right!==void 0?h.max=Math.max(u,h.right.max):h.left!==void 0&&h.right===void 0?h.max=Math.max(u,h.left.max):h.left===void 0&&h.right===void 0?h.max=u:h.max=Math.max(Math.max(h.left.max,h.right.max),u);var g=this.getNodeHigh();this.left===void 0&&this.right!==void 0?this.max=Math.max(g,this.right.max):this.left!==void 0&&this.right===void 0?this.max=Math.max(g,this.left.max):this.left===void 0&&this.right===void 0?this.max=g:this.max=Math.max(Math.max(this.left.max,this.right.max),g),a.max=Math.max(Math.max(a.left.max,h.max),a.getNodeHigh())},l.prototype._leftRotate=function(){var a=this.right;a.parent=this.parent,a.parent===void 0?this.intervalTree.root=a:a.parent.left===this?a.parent.left=a:a.parent.right===this&&(a.parent.right=a),this.right=a.left,this.right!==void 0&&(this.right.parent=this),a.left=this,this.parent=a,this.updateHeight(),a.updateHeight()},l.prototype._rightRotate=function(){var a=this.left;a.parent=this.parent,a.parent===void 0?this.intervalTree.root=a:a.parent.left===this?a.parent.left=a:a.parent.right===this&&(a.parent.right=a),this.left=a.right,this.left!==void 0&&(this.left.parent=this),a.right=this,this.parent=a,this.updateHeight(),a.updateHeight()},l.prototype._rebalance=function(){if(t(this.left)>=2+t(this.right)){var a=this.left;t(a.left)>=t(a.right)?(this._rightRotate(),this._updateMaxAfterRightRotate()):(a._leftRotate(),this._rightRotate(),this._updateMaxAfterRightRotate())}else if(t(this.right)>=2+t(this.left)){var h=this.right;t(h.right)>=t(h.left)?(this._leftRotate(),this._updateMaxAfterLeftRotate()):(h._rightRotate(),this._leftRotate(),this._updateMaxAfterLeftRotate())}},l.prototype.insert=function(a){a.low<this.key?this.left===void 0?(this.left=new l(this.intervalTree,a),this.left.parent=this):this.left.insert(a):this.right===void 0?(this.right=new l(this.intervalTree,a),this.right.parent=this):this.right.insert(a),this.max<a.high&&(this.max=a.high),this.updateHeight(),this._rebalance()},l.prototype._getOverlappingRecords=function(a,h,u){if(a.key<=u&&h<=a.getNodeHigh()){for(var g=[],b=0;b<a.records.length;b++)a.records[b].high>=h&&g.push(a.records[b]);return g}return[]},l.prototype.search=function(a,h){if(this===void 0)return[];var u=[],g=[],b=[];return a>this.max?[]:(this.left!==void 0&&this.left.max>=a&&(u=this.left.search(a,h)),g=this._getOverlappingRecords(this,a,h),h<this.key?u.concat(g):(this.right!==void 0&&(b=this.right.search(a,h)),u.concat(g,b)))},l.prototype.searchExisting=function(a){if(this!==void 0){if(this.key===a)return this;if(a<this.key){if(this.left!==void 0)return this.left.searchExisting(a)}else if(this.right!==void 0)return this.right.searchExisting(a)}},l.prototype._minValue=function(){return this.left===void 0?this:this.left._minValue()},l.prototype.remove=function(a){var h=this.parent;if(a.key<this.key)return this.left!==void 0?this.left.remove(a):void 0;if(a.key>this.key)return this.right!==void 0?this.right.remove(a):void 0;if(this.left!==void 0&&this.right!==void 0){var u=this.right._minValue();return this.key=u.key,this.records=u.records,this.right.remove(this)}else{if(h.left===this)return this.right!==void 0?(h.left=this.right,this.right.parent=h):(h.left=this.left,this.left!==void 0&&(this.left.parent=h)),h.updateMaxOfParents(),h.updateHeight(),h._rebalance(),this;if(h.right===this)return this.right!==void 0?(h.right=this.right,this.right.parent=h):(h.right=this.left,this.left!==void 0&&(this.left.parent=h)),h.updateMaxOfParents(),h.updateHeight(),h._rebalance(),this}},l})();Bt.Node=e;var s=(function(){function l(){this.count=0}return l.prototype.insert=function(a){if(a.low>a.high)throw new Error("`low` value must be lower or equal to `high` value");if(this.root===void 0)return this.root=new e(this,a),this.count++,!0;var h=this.root.searchExisting(a.low);if(h!==void 0){for(var u=0;u<h.records.length;u++)if(m(h.records[u],a))return!1;return h.records.push(a),a.high>h.max&&(h.max=a.high,h.parent&&h.parent.updateMaxOfParents()),this.count++,!0}else return this.root.insert(a),this.count++,!0},l.prototype.search=function(a,h){return this.root===void 0?[]:this.root.search(a,h)},l.prototype.remove=function(a){if(this.root===void 0)return!1;var h=this.root.searchExisting(a.low);if(h===void 0)return!1;if(h.records.length>1){for(var u=void 0,g=0;g<h.records.length;g++)if(m(h.records[g],a)){u=h.records[g],h.records.splice(g,1);break}if(u){if(u=void 0,a.high===h.max){var b=h.getNodeHigh();h.left!==void 0&&h.right!==void 0?h.max=Math.max(Math.max(h.left.max,h.right.max),b):h.left!==void 0&&h.right===void 0?h.max=Math.max(h.left.max,b):h.left===void 0&&h.right!==void 0?h.max=Math.max(h.right.max,b):h.max=b,h.parent&&h.parent.updateMaxOfParents()}return this.count--,!0}else return!1}else if(h.records.length===1)if(m(h.records[0],a))if(this.root.key===h.key){var T=new e(this,{low:a.low,high:a.low});T.left=this.root,this.root.parent=T;var M=this.root.remove(h);return this.root=T.left,this.root!==void 0&&(this.root.parent=void 0),M?(M=void 0,this.count--,!0):!1}else{var M=this.root.remove(h);return M?(M=void 0,this.count--,!0):!1}else return!1;else return!1},l.prototype.inOrder=function(){return new n(this.root)},l.prototype.preOrder=function(){return new r(this.root)},l})();Bt.IntervalTree=s;var i=(function(){function l(){this.tree=new s}return l.prototype.insert=function(a,h,u){return this.tree.insert({low:a,high:h,data:u})},l.prototype.remove=function(a,h,u){return this.tree.remove({low:a,high:h,data:u})},l.prototype.search=function(a,h){return this.tree.search(a,h).map(function(u){return u.data})},l.prototype.inOrder=function(){return this.tree.inOrder()},l.prototype.preOrder=function(){return this.tree.preOrder()},Object.defineProperty(l.prototype,"count",{get:function(){return this.tree.count},enumerable:!0,configurable:!0}),l})();Bt.default=i;var n=(function(){function l(a){this.stack=[],a!==void 0&&this.push(a)}return l.prototype.next=function(){return this.currentNode===void 0?{done:!0,value:void 0}:this.i<this.currentNode.records.length?{done:!1,value:this.currentNode.records[this.i++]}:(this.currentNode.right!==void 0?this.push(this.currentNode.right):this.pop(),this.next())},l.prototype.push=function(a){for(this.currentNode=a,this.i=0;this.currentNode.left!==void 0;)this.stack.push(this.currentNode),this.currentNode=this.currentNode.left},l.prototype.pop=function(){this.currentNode=this.stack.pop(),this.i=0},l})();Bt.InOrder=n,typeof Symbol=="function"&&(n.prototype[Symbol.iterator]=function(){return this});var r=(function(){function l(a){this.stack=[],this.i=0,this.currentNode=a}return l.prototype.next=function(){return this.currentNode===void 0?{done:!0,value:void 0}:this.i<this.currentNode.records.length?{done:!1,value:this.currentNode.records[this.i++]}:(this.currentNode.right!==void 0&&this.push(this.currentNode.right),this.currentNode.left!==void 0&&this.push(this.currentNode.left),this.pop(),this.next())},l.prototype.push=function(a){this.stack.push(a)},l.prototype.pop=function(){this.currentNode=this.stack.pop(),this.i=0},l})();return Bt.PreOrder=r,typeof Symbol=="function"&&(r.prototype[Symbol.iterator]=function(){return this}),Bt}var xe=is(),ns=es(xe);class E{constructor(...t){this.bricks=[],this.isPageBreak=!1,this._xLeft=0,this._xRight=0,this._yTop=0,this._yBot=0,this.addBrick(...t)}addBeforeRenderCallback(t){this.bricks.forEach(e=>e.addBeforeRenderCallback(t))}get xLeft(){return this._xLeft}set xLeft(t){this.shift(t-this.xLeft,0,0,0),this._xLeft=t}get xRight(){return this._xRight}set xRight(t){this.shift(0,t-this.xRight,0,0),this._xRight=t}get yTop(){return this._yTop}set yTop(t){this.shift(0,0,t-this.yTop,0),this._yTop=t}get yBot(){return this._yBot}set yBot(t){this.shift(0,0,0,t-this.yBot),this._yBot=t}shift(t,e,s,i){this.bricks.forEach(n=>{n.xLeft+=t,n.xRight+=e,n.yTop+=s,n.yBot+=i})}get width(){return this.xRight-this.xLeft}get height(){return this.yBot-this.yTop}async render(){for(let t=0;t<this.bricks.length;t++)await this.bricks[t].render()}get isEmpty(){return this.bricks.length===0}_updateRect(){if(this.bricks.length>0){let t=te(...this.bricks);this._xLeft=t.xLeft,this._xRight=t.xRight,this._yTop=t.yTop,this._yBot=t.yBot}}addBrick(...t){t.length!=0&&(this.bricks.push(...t),this._updateRect())}unfold(){const t=[];return this.bricks.forEach(e=>{t.push(...e.unfold())}),t}translateX(t){this.bricks.forEach(s=>s.translateX(t));const e=t(this.xLeft,this.xRight);this._xLeft=e.xLeft,this._xRight=e.xRight}translateY(t){this.bricks.forEach(e=>e.translateY(t)),this._updateRect()}setPageNumber(t){this.bricks.forEach(e=>e.setPageNumber(t))}getPageNumber(){return this.bricks[0].getPageNumber()}updateRect(){this.bricks.forEach(t=>{t.updateRect()}),this._updateRect()}increasePadding(t){if(t.top==0&&t.bottom==0)return;const e=new xe.IntervalTree;this.bricks.filter(i=>!i.isEmpty).forEach(i=>{e.insert({low:i.xLeft,high:i.xRight,yTop:i.yTop,yBot:i.yBot})}),this.bricks.forEach(i=>{const n={top:0,bottom:0},r=e.search(i.xLeft,i.xRight).reduce((l,a)=>(l.yTop=Math.min(l.yTop,a.yTop),l.yBot=Math.max(l.yBot,a.yBot),l),{yTop:Number.MAX_VALUE,yBot:Number.MIN_VALUE});i.yTop<=r.yTop&&(n.top=t.top),i.yBot>=r.yBot&&(n.bottom=t.bottom),(n.top!==0||n.bottom!==0)&&i.increasePadding(n)}),this.updateRect()}get contentRect(){const t=te(...this.bricks.map(e=>e.contentRect));return{...t,width:t.xRight-t.xLeft,height:t.yBot-t.yTop}}}class ne{constructor(t,e,s,i){this.point=t,this.bricks=e,this.controller=s,this.repository=i}}class os extends ne{constructor(t,e,s,i,n){super(t,e,i,n),this.question=s}}class rs extends ne{constructor(t,e,s,i,n){super(t,e,i,n),this.panel=s}}class as extends ne{constructor(t,e,s,i,n){super(t,e,i,n),this.page=s}}const ls={padding:0,borderWidth:0,backgroundColor:null,borderColor:null,borderMode:1,borderRadius:0};class qt extends E{get includedBorderWidth(){if(!this.includedBorderWidthValue){const t=Mt(this.style.borderWidth);Object.keys(t).forEach(e=>{switch(this.style.borderMode){case St.Inside:break;case St.Middle:t[e]=t[e]/2;break;default:return 0}}),this.includedBorderWidthValue=t}return this.includedBorderWidthValue}get padding(){return this._padding||(this._padding=Mt(this.style.padding)),this._padding}constructor(t,e,s){super(),this.controller=t,this.layout=e,this.visualYTopDiff=0,this.visualYBotDiff=0,this.style=o.mergeObjects({},ls,s)}getStartPoint(){return{yTop:this.layout.yTop+this.padding.top+this.includedBorderWidth.top,xLeft:this.layout.xLeft+this.padding.left+this.includedBorderWidth.left}}startSetup(){this.controller.pushMargins(),this.controller.margins.left=this.layout.xLeft+this.padding.left+this.includedBorderWidth.left,this.controller.margins.right=this.controller.paperWidth-(this.layout.xLeft+this.layout.width)+this.padding.right+this.includedBorderWidth.right}finishSetup(){if(this.controller.popMargins(),this.increasePadding({top:this.padding.top+this.includedBorderWidth.top,bottom:this.padding.bot+this.includedBorderWidth.bot}),this.unfold().length!==0){const i=this.unfold().reduce((r,l)=>l.yTop<r.yTop?l:r),n=this.unfold().reduce((r,l)=>l.yBot>r.yBot?l:r);this.visualYTopDiff=i.contentRect.yTop-i.yTop,this.visualYBotDiff=n.yBot-n.contentRect.yBot}let e=-1;const s=()=>{const i=this.controller.getCurrentPageIndex();if(i!=e){e=i;const n=this.unfold().filter(g=>!g.isEmpty),r=n.filter(g=>g.getPageNumber()==i),l=o.mergeRects(...r),a=["top","right","bot","left"],h=new Array(4).fill(0,0,4).map((g,b)=>{var T;return(T=Array.isArray(this.style.borderWidth)?this.style.borderWidth[b]:this.style.borderWidth)!==null&&T!==void 0?T:0}),u=new Array(4).fill(0,0,4).map((g,b)=>{var T;const M=(T=Array.isArray(this.style.borderRadius)?this.style.borderRadius[b]:this.style.borderRadius)!==null&&T!==void 0?T:0;return Math.min(Math.max(M-h[b]-this.includedBorderWidth[a[b]]),0),Math.max(M-(h[b-1<0?h.length-1:b-1]-this.includedBorderWidth[a[b-1<0?a.length-1:b-1]]),0)});if(n[0]!=r[0])u[0]=0,u[1]=0,h[0]=0;else{const g=r.reduce((b,T)=>T.yTop<b.yTop?T:b);l.yTop=g.contentRect.yTop-this.visualYTopDiff}if(n[n.length-1]!==r[r.length-1])u[2]=0,u[3]=0,h[2]=0;else{const g=r.reduce((b,T)=>T.yBot>b.yBot?T:b);l.yBot=g.contentRect.yBot+this.visualYBotDiff}if(this.style.backgroundColor!==null){this.controller.setFillColor(this.style.backgroundColor);const g=o.createRect({xLeft:this.layout.xLeft+this.includedBorderWidth.left,yTop:l.yTop+this.includedBorderWidth.top},this.layout.width-this.includedBorderWidth.left-this.includedBorderWidth.right,l.yBot-l.yTop-this.includedBorderWidth.top-this.includedBorderWidth.bot),{lines:b,point:T}=o.getDocLinesFromShape(o.createRoundedShape(g,{...this.style,borderRadius:u}));this.controller.doc.lines(b,...T,[1,1],"F",!0),this.controller.restoreFillColor()}this.style.borderColor!==null&&o.renderFlatBorders(this.controller,{xLeft:this.layout.xLeft,xRight:this.layout.xLeft+this.layout.width,yTop:l.yTop,yBot:l.yBot,width:this.layout.width,height:l.yBot-l.yTop},{...this.style,borderRadius:u,borderWidth:h})}};this.bricks.forEach(i=>{i.addBeforeRenderCallback(s)})}getBricks(){return this.bricks.slice()}async setup(t){this.startSetup();const e=[];await t(this.getStartPoint(),e),this.addBrick(...e),this.finishSetup()}set xLeft(t){}get xLeft(){return this.layout.xLeft}set xRight(t){}get xRight(){return this.layout.xLeft+this.layout.width}get width(){return this.layout.width}fitToHeight(t,e){if(e){const s=(t-this.height)/2;this.translateY((i,n)=>({yTop:i+s,yBot:n+s})),this.increasePadding({top:s,bottom:s}),this.visualYBotDiff+=s,this.visualYTopDiff+=s}else{const s=t-this.height;this.increasePadding({top:0,bottom:s}),this.visualYBotDiff+=s}}}class tt{constructor(t,e,s,i){this.survey=t,this.question=e,this.controller=s,this.style=i}async generateFlatTitle(t){const e=new E;let s=o.clone(t);const i={...this.style.title};if(this.question.no){const r=o.mergeObjects({},i,this.style.number),l=this.question.no;let a;o.hasHtml(this.question.locTitle)?(this.controller.pushMargins(),this.controller.margins.right=this.controller.paperWidth-this.controller.margins.left-this.controller.measureText(l,r).width,a=await o.createHTMLFlat(s,this.controller,o.createHtmlContainerBlock(l,this.controller,r),r),this.controller.popMargins()):a=await o.createTextFlat(s,this.controller,l,r),e.addBrick(a),s.xLeft=a.xRight+this.style.spacing.titleNumberGap}this.controller.pushMargins(),this.controller.margins.left=s.xLeft;const n=await o.createTextFlat(s,this.controller,this.question.locTitle,i);if(e.addBrick(n),this.controller.popMargins(),this.question.isRequired){const r=o.mergeObjects({},i,this.style.requiredMark),l=this.question.requiredMark;if(o.hasHtml(this.question.locTitle))s=o.createPoint(n.unfold()[0],!1,!1),s.xLeft+=this.style.spacing.titleRequiredMarkGap,this.controller.pushMargins(),this.controller.margins.right=this.controller.paperWidth-this.controller.margins.left-this.controller.measureText(l,r).width,e.addBrick(await o.createHTMLFlat(s,this.controller,o.createHtmlContainerBlock(l,this.controller,r),r)),this.controller.popMargins();else{const a=n.unfold().pop();if(this.style.spacing.titleRequiredMarkGap+this.controller.measureText(l,r).width<o.getPageAvailableWidth(this.controller)+this.controller.leftTopPoint.xLeft-a.xRight)s=o.createPoint(a,!1,!0),s.xLeft+=this.style.spacing.titleRequiredMarkGap;else{const h=s.xLeft;s=o.createPoint(a,!1,!1),s.xLeft=h}e.addBrick(await o.createTextFlat(s,this.controller,l,r))}}return e}async generateFlatDescription(t){return await o.createTextFlat(t,this.controller,this.question.locDescription,{...this.style.description})}async generateFlatHeader(t){const e=new qt(this.controller,{...t,width:o.getPageAvailableWidth(this.controller)},this.style.header);return await e.setup(async(s,i)=>{const n=await this.generateFlatTitle(s);if(i.push(n),this.question.hasDescriptionUnderTitle){const r=o.createPoint(n,!0,!1);r.yTop+=this.style.spacing.titleDescriptionGap,r.xLeft+=this.style.spacing.contentIndentStart,i.push(await this.generateFlatDescription(r))}}),e}async generateFlatsComment(t){const e=this.question.locCommentText,s=await o.createTextFlat(t,this.controller,e,this.style.commentLabel),i=o.createPoint(s);i.yTop+=this.style.spacing.commentLabelGap;const n=o.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),r=o.getPatchedTextStyle(this.controller,o.mergeObjects({},this.style.comment,n?this.style.commentReadOnly:void 0));return new E(s,await o.createCommentFlat(i,this.controller,{fieldName:this.question.id+"_comment",rows:this.controller.otherRowsCount,value:this.question.comment!==void 0&&this.question.comment!==null?this.question.comment:"",shouldRenderBorders:D.settings.readOnlyCommentRenderMode==="textarea",shouldRenderReadOnly:n,isReadOnly:this.question.isReadOnly,isMultiline:!0,placeholder:""},r))}async generateFlatsComposite(t){const e=this.question.contentPanel;return e?await o.generatePanelFlats(this.survey,this.controller,e,t):(this.question=o.getContentQuestion(this.question),await this.generateFlatsContent(t))}async generateFlatsContent(t){return null}async generateFlatsContentWithOptionalElements(t){const e=[],s=await this.generateFlatsComposite(t);Array.isArray(s)&&e.push(...s);const i=o.clone(t);if(s&&s.length>0&&(i.yTop=o.mergeRects(...s).yBot),this.question.hasComment&&(i.yTop+=this.style.spacing.contentCommentGap,e.push(await this.generateFlatsComment(i))),this.question.hasDescriptionUnderInput){const n=new E;e!==null&&e.length!==0&&n.addBrick(e.pop()),i.yTop+=this.style.spacing.contentDescriptionGap,n.addBrick(await this.generateFlatDescription(i)),e.push(n)}return e}async generateFlats(t){this.controller.pushMargins(),this.controller.margins.left+=this.controller.measureText(this.question.indent).width;const e={xLeft:t.xLeft+this.controller.measureText(this.question.indent).width,yTop:t.yTop},s=[];let i=this.question.getTitleLocation();i=this.question.hasTitle?i:"hidden";const n="matrix";switch(i){case"top":case"default":{const a=new E,h=await this.generateFlatHeader(e);a.addBrick(h);let u=o.createPoint(h);const g=this.style.spacing.contentIndentStart;u.xLeft+=g,a.addBrick(o.createRowlineFlat(o.createPoint(h),this.controller)),u.yTop+=this.style.spacing.headerContentGap+o.EPSILON,this.controller.pushMargins(),this.controller.margins.left+=g;const b=await this.generateFlatsContentWithOptionalElements(u);this.controller.popMargins(),b!==null&&b.length!==0&&a.addBrick(b.shift()),s.push(a),s.push(...b);break}case"bottom":{const a=o.clone(e),h=new E;this.controller.pushMargins();const u=this.style.spacing.contentIndentStart;a.xLeft+=u,this.controller.margins.left+=u;const g=await this.generateFlatsContentWithOptionalElements(a);this.controller.popMargins(),g!==null&&g.length!==0&&h.addBrick(g.pop());const b=e;s.length!==0&&(b.yTop=s[s.length-1].yBot),b.yTop+=this.style.spacing.headerContentGap,h.addBrick(await this.generateFlatHeader(b)),s.push(...g),s.push(h);break}case"left":{this.controller.pushMargins(this.controller.margins.left,this.controller.paperWidth-this.controller.margins.left-o.getPageAvailableWidth(this.controller)*this.style.inlineHeaderWidthPercentage);const a=await this.generateFlatHeader(e),h=o.createPoint(a,!1,!0);this.controller.popMargins(),h.xLeft+=this.style.spacing.inlineHeaderContentGap,this.controller.margins.left=h.xLeft;const u=await this.generateFlatsContentWithOptionalElements(h);u!==null&&u.length!==0&&a.addBrick(u.shift()),s.push(a),s.push(...u);break}case"hidden":case n:default:{const a=o.clone(e);if(this.controller.pushMargins(),i!==n){const h=this.style.spacing.contentIndentStart;a.xLeft+=h,this.controller.margins.left+=h}s.push(...await this.generateFlatsContentWithOptionalElements(a)),this.controller.popMargins();break}}this.controller.popMargins();const r=new os(t,s,this.question,this.controller,_.getInstance());this.question.customWidget&&this.question.customWidget.isFit(this.question)&&this.question.customWidget.pdfRender&&this.survey.onRenderQuestion.unshift(this.question.customWidget.pdfRender),await this.survey.onRenderQuestion.fire(this.survey,r);const l=[...r.bricks];return this.survey.afterRenderSurveyElement(this.question,l),l}}D.Serializer.addProperty("question",{name:"readonlyRenderAs",default:"auto",choices:["auto","text","acroform"],visible:!1});class be extends tt{async generateFlatsContent(t){return[await o.createTextFlat(t,this.controller,`${this.question.displayValue}`)]}}class _{constructor(){this.questions={}}static getInstance(){return _.instance}register(t,e){this.questions[t]=e}registerPanel(t){this.panel=t}registerPage(t){this.page=t}registerSurvey(t){this.survey=t}isTypeRegistered(t){return!!this.questions[t]}getRenderer(t){return this.questions[t]}create(t,e,s,i,n){var r;const l=typeof n>"u"?e.getType():n;let a=this.getRenderer(l);return a||(!((r=e.customWidget)===null||r===void 0)&&r.pdfRender?a=tt:a=be),new a(t,e,s,i)}createPanel(t,e,s,i){return new this.panel(t,e,s,i)}createPage(t,e,s,i){return new this.page(t,e,s,i)}createSurvey(t,e,s){return new this.survey(t,e,s)}static registerPanel(t){this.getInstance().registerPanel(t)}static registerPage(t){this.getInstance().registerPage(t)}static registerSurvey(t){this.getInstance().registerSurvey(t)}static register(t,e){this.getInstance().register(t,e)}static getRenderer(t){return this.getInstance().getRenderer(t)}}_.instance=new _;class Tt extends D.EventBase{constructor(){super(...arguments),this.isProcessing=!1}unshift(t){this.hasFunc(t)||(this.callbacks==null&&(this.callbacks=new Array),this.callbacks.unshift(t))}async fire(t,e){if(!(this.callbacks==null||this.isProcessing)){this.isProcessing=!0;for(var s=0;s<this.callbacks.length;s++)await this.callbacks[s](t,e),this.isProcessing=!1}}}class pt{get xLeft(){return this._xLeft}set xLeft(t){this.setXLeft(t)}get xRight(){return this._xRight}set xRight(t){this.setXRight(t)}get yTop(){return this._yTop}set yTop(t){this.setYTop(t)}get yBot(){return this._yBot}set yBot(t){this.setYBottom(t)}constructor(t,e,s={}){this.controller=t,this.options=s,this.isPageBreak=!1,this.beforeRenderEvent=new Tt,this.padding={top:0,bottom:0},this.xLeft=e.xLeft,this.xRight=e.xRight,this.yTop=e.yTop,this.yBot=e.yBot}translateY(t){const e=t(this.yTop,this.yBot);this.yTop=e.yTop,this.yBot=e.yBot}translateX(t){const e=t(this.xLeft,this.xRight);this.xLeft=e.xLeft,this.xRight=e.xRight}get width(){return this.xRight-this.xLeft}get height(){return this.yBot-this.yTop}getShouldRenderReadOnly(){return this.options.shouldRenderReadOnly}async render(){await this.beforeRenderEvent.fire(this,{}),this.getShouldRenderReadOnly()?await this.renderReadOnly():await this.renderInteractive(),this.afterRenderCallback&&this.afterRenderCallback()}async renderInteractive(){}async renderReadOnly(){await this.renderInteractive()}unfold(){return[this]}getCorrectedText(t){return this.controller.isRTL?(t||"").split("").reverse().join(""):t}setXLeft(t){this._xLeft=t,this.resetContentRect()}setXRight(t){this._xRight=t,this.resetContentRect()}setYTop(t){this._yTop=t,this.resetContentRect()}setYBottom(t){this._yBot=t,this.resetContentRect()}getPageNumber(){return this._pageNumber}setPageNumber(t){this._pageNumber=t}addBeforeRenderCallback(t){this.beforeRenderEvent.unshift(t)}increasePadding(t){t.top==0&&t.bottom==0||(Object.keys(this.padding).forEach(e=>{this.padding[e]+=t[e]}),this._yTop-=t.top,this._yBot+=t.bottom,this.resetContentRect())}get contentRect(){return this._contentRect||(this._contentRect=this.getContentRect()),this._contentRect}resetContentRect(){this._contentRect=void 0}getContentRect(){const t=this.yBot-this.padding.bottom,e=this.yTop+this.padding.top;return{yBot:t,yTop:e,xLeft:this.xLeft,xRight:this.xRight,width:this.width,height:Math.max(t-e,0)}}updateRect(){}get isEmpty(){return!1}}class Dt extends pt{constructor(t,e,s,i){super(t,e,s),this.options=s,this.style=i,this.align={isInputRtl:!1,isOutputRtl:t.isRTL,align:t.isRTL?"right":"left",baseline:"middle",lineHeightFactor:1.15}}escapeText(){return this.options.text.replace(/\t/g,Array(5).join("\xA0"))}async renderInteractive(){const t=this.alignPoint(this.contentRect);this.controller.setTextStyle(this.style),this.controller.doc.text(this.escapeText(),t.xLeft,t.yTop,this.align),this.controller.restoreTextStyle()}alignPoint(t){return{xLeft:this.controller.isRTL?t.xRight:t.xLeft,yTop:t.yTop+(t.yBot-t.yTop)/2}}}class _t extends Dt{constructor(t,e,s,i){super(t,e,s,i),this.options=s,this.style=i}async renderInteractive(){this.controller.setTextStyle(o.mergeObjects({},this.style,{fontColor:"#FFFFFF00"}));let t=this.controller.unitHeight*(this.controller.doc.getLineHeightFactor()-_t.SCALE_FACTOR_MAGIC),e=this.contentRect.yTop+(this.contentRect.yBot-this.contentRect.yTop)-t;this.controller.doc.textWithLink(this.options.text,this.contentRect.xLeft,e,{url:this.options.link}),this.controller.restoreTextStyle(),await super.renderInteractive()}async renderReadOnly(){this.options.readOnlyShowLink?super.renderInteractive():this.renderInteractive()}}_t.SCALE_FACTOR_MAGIC=.955;class ve extends pt{constructor(t,e,s,i){super(t,e),this.options=s,this.style=i}async renderInteractive(){this.controller.setTextStyle(this.style),await new Promise(t=>{this.controller.doc.fromHTML(this.options.html,this.contentRect.xLeft,this.contentRect.yTop,{width:this.contentRect.width,pagesplit:!0},function(){[].slice.call(document.querySelectorAll(".sjs-pdf-hidden-html-div")).forEach(function(e){e.parentNode.removeChild(e)}),t()},{top:this.controller.margins.top,bottom:this.controller.margins.bot})}),this.controller.restoreTextStyle()}}class we extends pt{constructor(t,e,s){super(t,e),this.options=s,this.isPageBreak=this.options.height===void 0}async renderInteractive(){const t=this.options.width||this.contentRect.width,e=this.options.height||this.contentRect.height,s=this.contentRect.width,i=this.contentRect.height,n=s>t?this.contentRect.xLeft+(s-t)/2:this.contentRect.xLeft,r=i>e?this.contentRect.yTop+(i-e)/2:this.contentRect.yTop;await new Promise(l=>{try{this.controller.doc.addImage(this.options.link,"PNG",n,r,Math.min(t,s),Math.min(e,i),this.options.imageId,"MEDIUM")}finally{l()}})}}class It extends pt{constructor(t,e,s={}){super(t,e),this.style=s}async renderInteractive(){if(this.style.color){this.controller.setFillColor(this.style.color);const{lines:t,point:e}=o.getDocLinesFromShape(o.createRoundedShape(this.contentRect,this.style));this.controller.doc.lines(t,...e,[1,1],"F",!0),this.controller.restoreFillColor()}o.renderFlatBorders(this.controller,this.contentRect,this.style)}}class oe{constructor(t,e,s){this.controller=t,this.color=s,this.isPageBreak=!1,this.beforeRenderEvent=new Tt,this.padding={top:0,bottom:0},this.xLeft=e.xLeft,this.xRight=e.xRight,this.yTop=e.yTop,this.yBot=e.yBot}get width(){return this.xRight-this.xLeft}get height(){return this.yBot-this.yTop}async render(){await this.beforeRenderEvent.fire(this,{}),this.color!==null&&(this.controller.setDrawColor(this.color),this.controller.doc.line(this.contentRect.xLeft,this.yTop,this.contentRect.xRight,this.contentRect.yTop),this.controller.restoreDrawColor())}getPageNumber(){return this._pageNumber}setPageNumber(t){this._pageNumber=t}addBeforeRenderCallback(t){this.beforeRenderEvent.add(t)}unfold(){return[this]}translateX(t){}translateY(t){const e=t(this.yTop,this.yBot);this.yTop=e.yTop,this.yBot=e.yBot}increasePadding(t){t.top==0&&t.bottom==0||(Object.keys(this.padding).forEach(e=>{this.padding[e]+=t[e]}),this.yTop-=t.top,this.yBot+=t.bottom,this._contentRect=void 0)}get contentRect(){if(!this._contentRect){const t=this.yTop+=this.padding.top,e=this.yBot-=this.padding.bottom;this._contentRect={yBot:e,yTop:t,xLeft:this.xLeft,xRight:this.xRight,width:this.width,height:e-t}}return this._contentRect}updateRect(){}get isEmpty(){return this.color===null}}class Fe extends pt{constructor(t,e,s,i){var n,r,l,a;super(t,e),this.options=s,this.style=i,s.isMultiline=(n=s.isMultiline)!==null&&n!==void 0?n:!1,s.placeholder=(r=s.placeholder)!==null&&r!==void 0?r:"",s.inputType=(l=s.inputType)!==null&&l!==void 0?l:"",s.value=(a=s.value)!==null&&a!==void 0?a:""}renderColorQuestion(){this.controller.setFillColor(this.options.value||"black"),this.controller.doc.rect(this.contentRect.xLeft,this.contentRect.yTop,this.contentRect.width,this.contentRect.height,"F"),this.controller.restoreFillColor()}async renderInteractive(){var t;if(this.options.inputType==="color"){this.renderColorQuestion();return}const e=o.createAcroformRect(o.createRectInsideBorders(this.contentRect,(t=this.style.borderWidth)!==null&&t!==void 0?t:0));this.style.backgroundColor&&(this.controller.setFillColor(this.style.backgroundColor),this.controller.doc.rect(...e,"F"),this.controller.restoreFillColor());const{color:s}=o.parseColor(this.style.fontColor),i=this.options.inputType==="password"?new this.controller.doc.AcroFormPasswordField:new this.controller.AcroFormTextField;i.fieldName=this.options.fieldName,i.fontName=this.style.fontName,i.fontSize=this.style.fontSize,i.maxFontSize=this.style.fontSize,i.isUnicode=o.isCustomFont(this.controller,i.fontName),this.options.inputType!=="password"?(i.value=this.getCorrectedText(this.options.value),i.defaultValue=this.getCorrectedText(this.options.placeholder)):i.value="",i.multiline=this.options.isMultiline,i.readOnly=this.options.isReadOnly,i.color=s,i.Rect=e,this.controller.doc.addField(i),o.renderFlatBorders(this.controller,this.contentRect,this.style)}shouldRenderFlatBorders(){return this.options.shouldRenderBorders}get textBrick(){return this._textBrick}set textBrick(t){this._textBrick=t;const e=t.unfold(),s=e.length;let i=0;const n={},r=l=>{if(this.shouldRenderFlatBorders()){i++;const a=this.controller.getCurrentPageIndex();if(n[a]||(n[a]=[]),n[a].push(l.contentRect),i>=s){const h=Object.keys(n),u=h.length==1;h.forEach(g=>{const b=te(...n[g]),T={xLeft:this.contentRect.xLeft,xRight:this.contentRect.xRight,width:this.contentRect.width,yTop:u?this.contentRect.yTop:b.yTop,yBot:u?this.contentRect.yBot:b.yBot,height:u?this.contentRect.height:b.yBot-b.yTop};this.controller.setPage(Number(g)),o.renderFlatBorders(this.controller,T,this.style),this.controller.setPage(a)})}}};e.forEach(l=>{l.afterRenderCallback=r.bind(this.contentRect,l)}),this.updateRect()}updateRect(){if(this.textBrick){const t=this.width;this.textBrick.updateRect(),this._xLeft=this.textBrick.xLeft,this._xRight=this.textBrick.xLeft+t,this._yTop=this.textBrick.yTop,this._yBot=this.textBrick.yBot}}async renderReadOnly(){this.controller.pushMargins(this.contentRect.xLeft,this.controller.paperWidth-this.contentRect.xRight),this.options.inputType==="color"?this.renderColorQuestion():await this.textBrick.render(),this.controller.popMargins()}unfold(){return this.getShouldRenderReadOnly()&&this.options.inputType!=="color"?this.textBrick.unfold():super.unfold()}translateX(t){const e=t(this.contentRect.xLeft,this.contentRect.xRight);this._xLeft=e.xLeft,this._xRight=e.xRight,this.textBrick&&this.textBrick.translateX(t)}setXLeft(t){const e=t-this._xLeft;super.setXLeft(t),this.textBrick&&(this.textBrick.xLeft=this.textBrick.xLeft+e)}setXRight(t){const e=t-this._xRight;super.setXRight(t),this.textBrick&&(this.textBrick.xRight=this.textBrick.xRight+e)}setYTop(t){const e=t-this._yTop;super.setYTop(t),this.textBrick&&(this.textBrick.yTop=this.textBrick.yTop+e)}setYBottom(t){const e=t-this._yBot;super.setYBottom(t),this.textBrick&&(this.textBrick.yBot=this.textBrick.yBot+e)}setPageNumber(t){this.getShouldRenderReadOnly()&&this.options.inputType!=="color"?this.textBrick.setPageNumber(t):super.setPageNumber(t)}getPageNumber(){return this.getShouldRenderReadOnly()&&this.options.inputType!=="color"?this.textBrick.getPageNumber():super.getPageNumber()}increasePadding(t){t.top==0&&t.bottom==0||(this.getShouldRenderReadOnly()&&this.options.inputType!=="color"?(this.textBrick.increasePadding(t),this.updateRect()):super.increasePadding(t))}addBeforeRenderCallback(t){this.getShouldRenderReadOnly()&&this.options.inputType!=="color"?this.textBrick.addBeforeRenderCallback(t):super.addBeforeRenderCallback(t)}getContentRect(){return this.textBrick?{...this.textBrick.contentRect,xLeft:this.xLeft,xRight:this.xRight,width:this.xRight-this.xLeft}:super.getContentRect()}}class Re{constructor(){this.hash={},this.imageId=1}getImageId(){return`image_${this.imageId++}`}async _getImageInfo(t){return{data:t,width:0,height:0,id:this.getImageId()}}async getImageInfo(t){if(!this.hash[t])try{this.hash[t]=await this._getImageInfo(t)}catch{this.hash[t]=this.emptyImage}return this.hash[t]}async applyImageFit(t,e,s,i){if(e=="fill")return{data:t.data,id:t.id,width:s,height:i};if((e=="contain"||e=="cover")&&t.width&&t.height&&s&&s){const n=Math.min(s/t.width,i/t.height);return{data:t.data,id:t.id,width:t.width*n,height:t.height*n}}else return t}get emptyImage(){return{data:"",width:0,height:0,id:"image_0"}}clear(){this.hash={},this.imageId=1}}let Te=new Re;function re(){return Te}function hs(m){Te=m}var St;(function(m){m[m.Inside=0]="Inside",m[m.Middle=1]="Middle",m[m.Outside=2]="Outside"})(St||(St={}));var je;(function(m){m[m.None=0]="None",m[m.Top=1]="Top",m[m.Bottom=2]="Bottom",m[m.Right=4]="Right",m[m.Left=8]="Left",m[m.All=15]="All"})(je||(je={}));class o{static parseWidth(t,e,s=1,i){if(t.indexOf("calc")===0)return e/s;const n=parseFloat(t),r=t.replace(/[^A-Za-z%]/g,"")||i;let l;switch(r){case"pt":l=1;break;case"mm":l=72/25.4;break;case"cm":l=72/2.54;break;case"in":l=72;break;case"px":l=72/96;break;case"pc":l=12;break;case"em":l=12;break;case"ex":l=6;break;default:case"%":l=e/100;break}return Math.min(n*l,e)}static pxToPt(t){return typeof t=="string"?(isNaN(Number(t))||(t+="px"),o.parseWidth(t,Number.MAX_VALUE)):t*72/96}static parseColor(t){let e,s;if((t??"").match(/^rgba/)){const i=t.match(/[\d.]+/g);i.length==4&&(t=`rgb(${i[0]}, ${i[1]}, ${i[2]})`,e=parseFloat(i[3]))}else(s=(t??"").match(/(#[A-Fa-f0-9]{6})([A-Fa-f0-9]{2})/))&&(t=s[1],e=Math.round(parseInt(s[2],16)/255*100)/100);return{color:t,opacity:e}}static mergeRects(...t){return te(...t)}static createPoint(t,e=!0,s=!1){return{xLeft:e?t.xLeft:t.xRight,yTop:s?t.yTop:t.yBot}}static createRect(t,e,s){return{xLeft:t.xLeft,xRight:t.xLeft+e,yTop:t.yTop,yBot:t.yTop+s}}static createHeaderRect(t){return{xLeft:0,xRight:t.paperWidth,yTop:0,yBot:t.margins.top}}static createFooterRect(t){return{xLeft:0,xRight:t.paperWidth,yTop:t.paperHeight-t.margins.bot,yBot:t.paperHeight}}static chooseHtmlFont(t,e){return t.useCustomFontInHtml?e??t.fontName:"helvetica"}static generateCssTextRule(t){return`"font-size: ${t.fontSize}pt; font-weight: ${t.fontStyle}; font-family: ${t.fontName}; color: ${o.parseColor(t.fontColor).color}; lineHeight: ${t.lineHeight}; margin: 0"`}static createHtmlContainerBlock(t,e,s){const i=o.getPatchedTextStyle(e,s);return this.chooseHtmlFont(e,i.fontName),`<div class="__surveypdf_html" style=${this.generateCssTextRule(i)}><style>.__surveypdf_html p { margin: 0; line-height: ${i.lineHeight}pt } body { margin: 0; }</style>${t}</div>`}static splitHtmlRect(t,e){const s=[],i=e.height,n=t.doc.getFontSize();e.yBot=e.yTop+n;const r=Math.floor(i/n)-1;s.push(e);const l=this.createPoint(e);for(let h=0;h<r;h++)s.push(new It(t,this.createRect(l,e.width,n))),l.yTop+=n;const a=i-(r+1)*n;return a>0&&s.push(new It(t,this.createRect(l,e.width,a))),new E(...s)}static createPlainTextFlat(t,e,s,i){e.setTextStyle(i,!0);const n=e.helperDoc.splitTextToSize(s,e.paperWidth-e.margins.right-t.xLeft);e.restoreTextStyle(!0);const r=this.clone(t),l=new E;if(n.forEach(a=>{const h=e.measureText(a,i);l.addBrick(new Dt(e,this.createRect(r,h.width,h.height),{text:a},i)),r.yTop+=h.height}),i.textAlign=="right"){const a=t.xLeft+o.getPageAvailableWidth(e);l.translateX((h,u)=>({xLeft:h+(a-u),xRight:a}))}if(i.textAlign=="center"){const a=t.xLeft+o.getPageAvailableWidth(e)/2;l.translateX((h,u)=>{const g=a-(h+u)/2;return{xLeft:h+g,xRight:u+g}})}return l}static async createTextFlat(t,e,s,i){var n;const r={...o.getPatchedTextStyle(e,i),textAlign:(n=i?.textAlign)!==null&&n!==void 0?n:"left"};let l;return typeof s=="string"||!this.hasHtml(s)?l=this.createPlainTextFlat(t,e,typeof s=="string"?s:this.getLocString(s),r):l=this.splitHtmlRect(e,await this.createHTMLFlat(t,e,this.createHtmlContainerBlock(this.getLocString(s),e,r),r)),l}static mergeObjects(t,...e){return e.forEach(s=>{s&&Object.keys(s).forEach(i=>{var n;typeof s[i]=="object"&&s[i]!==null&&!Array.isArray(s[i])?t[i]=o.mergeObjects((n=t[i])!==null&&n!==void 0?n:{},s[i]):t[i]=s[i]})}),t}static getPatchedTextStyle(t,e){const s=o.mergeObjects(o.getDefaultTextStyle(t),e??{});return e&&e.lineHeight==null&&(s.lineHeight=s.fontSize),s}static getDefaultTextStyle(t){return{fontSize:t.fontSize,fontName:t.fontName,fontStyle:t.fontStyle,lineHeight:t.fontSize,fontColor:"#404040"}}static hasHtml(t){const e=/<\/?[a-z][\s\S]*>/i;return t.hasHtml&&(e.test(t.renderedText)||e.test(t.renderedHtml))}static getHtmlMargins(t,e){const s=t.paperWidth-e.xLeft-t.margins.right;return{top:t.margins.top,bottom:t.margins.bot,width:s>t.unitWidth?s:t.unitWidth}}static createHTMLRect(t,e,s,i,n){const r=this.getPatchedTextStyle(e,n),l=e.paperHeight-e.margins.bot-e.margins.top,a=(e.helperDoc.getNumberOfPages()-1)*(r.fontSize*Math.floor(l/r.fontSize))+i-s.top+o.HTML_TAIL_TEXT_SCALE*r.fontSize,h=e.helperDoc.getNumberOfPages();e.helperDoc.addPage();for(let u=0;u<h;u++)e.helperDoc.deletePage(1);return o.createRect(t,s.width,a)}static async createHTMLFlat(t,e,s,i){const n=this.getHtmlMargins(e,t),r=this.getPatchedTextStyle(e,i);return await new Promise(l=>{e.helperDoc.fromHTML(s,t.xLeft,n.top,{pagesplit:!0,width:n.width},function(a){const h=o.createHTMLRect(t,e,n,a.y,r);l(new ve(e,h,{html:s},r))},n)})}static generateFontFace(t,e,s){return`@font-face { font-family: ${t}; src: url(data:application/font-woff;charset=utf-8;base64,${e}) format('woff'); font-weight: ${s}; }`}static generateFontFaceWithItalicStyle(t,e,s){return`@font-face { font-family: ${t}; src: url(data:application/font-woff;charset=utf-8;base64,${e}) format('woff'); font-weight: ${s}; font-style: italic}`}static htmlToXml(t){const e=document.implementation.createHTMLDocument("");return e.write(t.replace(/\#/g,"%23")),e.documentElement.setAttribute("xmlns",e.documentElement.namespaceURI),e.body.style.margin="unset",new XMLSerializer().serializeToString(e.body).replace(/%23/g,"#")}static createSvgContent(t,e,s){const i=document.createElement("style");i.innerHTML=".__surveypdf_html p { margin: unset; line-height: 22px; } body { margin: unset; }",document.body.appendChild(i);const n=document.createElement("div");n.className="__surveypdf_html",n.style.display="block",n.style.position="fixed",n.style.top="-10000px",n.style.left="-10000px",n.style.width=e/72*96+"px",n.style.boxSizing="initial",n.style.color="initial",n.style.fontFamily="initial",n.style.font="initial",n.style.lineHeight="initial",n.insertAdjacentHTML("beforeend",t),document.body.appendChild(n);const r=n.offsetWidth,l=n.offsetHeight;n.remove(),i.remove();let a="";return s.useCustomFontInHtml?a=`<defs><style>${this.generateFontFace(s.fontName,s.base64Normal,"normal")} ${this.generateFontFace(s.fontName,s.base64Bold,"bold")}</style></defs>`:Object.keys(xt.customFonts).forEach(u=>{const g=xt.customFonts[u];Object.keys(g).forEach(b=>{b==="normal"||b==="bold"?a+=`${this.generateFontFace(u,g[b],b)}`:a+=`${this.generateFontFaceWithItalicStyle(u,g[b],b==="italic"?"normal":"bold")}`}),a="<defs><style>"+a+"</style></defs>"}),{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${r}px" height="${l}px">`+a+`<style>.__surveypdf_html p { margin: unset; line-height: 22px; }</style><foreignObject width="${r}px" height="${l}px">`+this.htmlToXml(t)+"</foreignObject></svg>",divWidth:r,divHeight:l}}static setCanvas(t,e,s,i,n){e.width=s*t.htmlToImageQuality,e.height=i*t.htmlToImageQuality;const r=e.getContext("2d");r.scale(t.htmlToImageQuality,t.htmlToImageQuality),r.fillStyle="#FFFFFF",r.fillRect(0,0,s,i),r.drawImage(n,0,0)}static async htmlToImage(t,e,s){const{svg:i,divWidth:n,divHeight:r}=o.createSvgContent(t,e,s),l="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(i))),a=new Image;return a.crossOrigin="anonymous",a.src=l,new Promise(h=>{a.onload=function(){const u=document.createElement("canvas");o.setCanvas(s,u,n,r,a);const g=u.toDataURL("image/jpeg",s.htmlToImageQuality);u.remove(),h({url:g,aspect:n/r})},a.onerror=function(){h({url:"data:,",aspect:e/this.EPSILON})}})}static getReadonlyRenderAs(t,e){return t.readonlyRenderAs==="auto"?e.readonlyRenderAs:t.readonlyRenderAs}static async createCommentFlat(t,e,s,i){var n,r;const l=o.getPatchedTextStyle(e,i);s.rows=(n=s.rows)!==null&&n!==void 0?n:1,s.value=(r=s.value)!==null&&r!==void 0?r:"";const a=this.createTextFieldRect(t,e,s.rows,l.lineHeight);let h;s.shouldRenderReadOnly&&(h=await this.createReadOnlyTextFieldTextFlat(t,e,s.value,l));const u=new Fe(e,a,s,l);return h&&(u.textBrick=h),u}static get hasDocument(){return typeof document<"u"}static async createImageFlat(t,e,s,i,n){const r=re();let l=await r.getImageInfo(i.link);(n??s.applyImageFit)&&(l=await r.applyImageFit(l,i.objectFit||"fill",i.width,i.height));const a=o.createRect(t,i.width,i.height);return new we(s,a,{width:l.width,height:l.height,imageId:l.id,link:l.data})}static createRowlineFlat(t,e,s,i){let n=typeof s>"u"?e.paperWidth-e.margins.right:t.xLeft+s;return n=n>t.xLeft?n:t.xLeft+this.EPSILON,new oe(e,{xLeft:t.xLeft,xRight:n,yTop:t.yTop+this.EPSILON,yBot:t.yTop+this.EPSILON},typeof i>"u"?null:i)}static async createLinkFlat(t,e,s,i){const n=o.getPatchedTextStyle(e,i),r=await this.createTextFlat(t,e,s.text,n),l=new E;return r.unfold().forEach(a=>{l.addBrick(new _t(e,a,{link:s.link,text:a.options.text,readOnlyShowLink:s.readOnlyShowLink,shouldRenderReadOnly:s.shouldRenderReadOnly},n));const h=this.createPoint(l);l.addBrick(this.createRowlineFlat(h,e,l.width,n.fontColor))}),l}static createAcroformRect(t){return[t.xLeft,t.yTop,t.xRight-t.xLeft,t.yBot-t.yTop]}static createTextFieldRect(t,e,s=1,i=e.unitHeight){let n=e.paperWidth-t.xLeft-e.margins.right;n=Math.max(n,e.unitWidth);const r=i*s;return this.createRect(t,n,r)}static async createReadOnlyTextFieldTextFlat(t,e,s,i){e.pushMargins(t.xLeft,e.margins.right);const n=await this.createTextFlat(t,e,s.toString(),i);return e.popMargins(),n}static createRoundedShape(t,e,s=!0){var i;const n=typeof s=="object"?s:{top:s,bot:s,left:s,right:s},r=Mt((i=e.borderRadius)!==null&&i!==void 0?i:0);Object.keys(r).forEach(h=>{r[h]=Math.max(0,Math.min(r[h],(t.xRight-t.xLeft)/2,(t.yBot-t.yTop)/2))});function l(h,u,g,b,T){const M=1.3333333333333333*Math.tan(b/4)*g;return[[g,0],[g,M],[g*Math.cos(b)+M*Math.sin(b),g*Math.sin(b)-M*Math.cos(b)],[g*Math.cos(b),g*Math.sin(b)]].reduce((st,lt)=>(st.push(Math.cos(T)*lt[0]-Math.sin(T)*lt[1]+h),st.push(Math.sin(T)*lt[0]+Math.cos(T)*lt[1]+u),st),[])}const a=new Map;if(a.set("top",[[t.xLeft+r.top,t.yTop,t.xRight-r.right,t.yTop]]),a.set("right",[[t.xRight,t.yTop+r.right,t.xRight,t.yBot-r.bot]]),a.set("bot",[[t.xRight-r.bot,t.yBot,t.xLeft+r.left,t.yBot]]),a.set("left",[[t.xLeft,t.yBot-r.left,t.xLeft,t.yTop+r.top]]),r.top){const h=n.top?Math.PI/2:Math.PI/4,u=r.top;a.get("left").push(l(t.xLeft+u,t.yTop+u,u,h,Math.PI)),n.top||a.get("top").unshift(l(t.xLeft+u,t.yTop+u,u,h,Math.PI+h))}if(r.right){const h=n.right?Math.PI/2:Math.PI/4,u=r.right;a.get("top").push(l(t.xRight-u,t.yTop+u,u,h,3/2*Math.PI)),n.right||a.get("right").unshift(l(t.xRight-u,t.yTop+u,u,h,3/2*Math.PI+h))}if(r.bot){const h=n.bot?Math.PI/2:Math.PI/4,u=r.bot;a.get("right").push(l(t.xRight-u,t.yBot-u,u,h,0)),n.bot||a.get("bot").unshift(l(t.xRight-u,t.yBot-u,u,h,h))}if(r.left){const h=n.left?Math.PI/2:Math.PI/4,u=r.left;a.get("bot").push(l(t.xLeft+u,t.yBot-u,u,h,Math.PI/2)),n.left||a.get("left").unshift(l(t.xLeft+u,t.yBot-u,u,h,Math.PI/2+h))}return a}static getDocLinesFromShape(t){const e=t.get(t.keys().next().value)[0].slice(0,2);let s=e;const i=[];return t.forEach(n=>n.forEach(l=>{l=l.slice(2),i.push(l.map((a,h)=>a-s[h%2])),s=l.slice(l.length-2)})),{lines:i,point:e}}static renderFlatBorders(t,e,s){var i,n,r;const l=o.mergeObjects({},{borderMode:St.Inside},s),a=Mt((i=s.borderWidth)!==null&&i!==void 0?i:0),h=Mt(s.borderColor);if([h,a].some(J=>Object.keys(J).every(C=>!J[C])))return;const u=l.borderMode==St.Middle?0:l.borderMode==St.Inside?.5:-.5,g={xLeft:e.xLeft+u*a.left,yTop:e.yTop+u*a.top,xRight:e.xRight-u*a.right,yBot:e.yBot-u*a.bot},b={top:a.left==a.top&&h.left==h.top,right:a.top==a.right&&h.top==h.right,bot:a.right==a.bot&&h.right==h.bot,left:a.bot==a.left&&h.bot==h.left},T=o.createRoundedShape(g,{...l},b),M=[];let Z=0,st=0,lt=0,z=0,X,K;const gt=Array.from(T.keys());if(gt.concat(gt).forEach((J,C)=>{const v=a[J],d=h[J];C!==0&&v==X&&d==K?z++:(X=v,K=d,z>st&&(Z=lt,st=z),lt=C,z=1)}),st==0&&(st=z,Z=lt),st>=2){const J=new Map;for(let v=Z;v<Z+st;v++){const d=gt[v%gt.length];J.set(d,T.get(d))}M.push(J);const C=gt.filter(v=>!J.has(v));if(C.length!==0)if(C.length==2&&C[0]=="top"&&C[1]=="left"&&C.reverse(),C.every(v=>a[C[0]]==a[v]&&h[C[0]]==h[v])){const v=new Map;C.forEach(d=>{v.set(d,T.get(d))}),M.push(v)}else C.forEach(v=>{const d=new Map;d.set(v,T.get(v)),M.push(d)})}else gt.forEach(J=>{const C=new Map;C.set(J,T.get(J)),M.push(C)});if(l.dashStyle){const J=l.dashStyle,C=(Math.abs(g.yTop-g.yBot)+Math.abs(g.xLeft-g.xRight))*2,v=J.dashArray[0]+((n=J.dashArray[1])!==null&&n!==void 0?n:J.dashArray[0]),d=J.dashArray[0]+C%v/Math.floor(C/v);t.doc.setLineDashPattern([d,(r=J.dashArray[1])!==null&&r!==void 0?r:J.dashArray[0]],J.dashPhase)}M.forEach(J=>{const C=J.keys().next().value;if(!h[C]||!a[C])return;t.setDrawColor(h[C]),t.doc.setLineWidth(a[C]);const{lines:v,point:d}=this.getDocLinesFromShape(J);t.doc.lines(v,...d,[1,1],"S",J.size==4),t.restoreDrawColor()}),l.dashStyle&&t.doc.setLineDashPattern([])}static getLocString(t){return this.hasHtml(t)?t.renderedHtml:t.renderedText||t.renderedHtml}static getContentQuestion(t){return t.contentQuestion?t.contentQuestion:t}static isBooleanDisplayMode(t){return t==="radio"||t==="checkbox"||t==="switch"}static isEmptyRenderAs(t){return!t||t==="default"}static getBooleanRenderAsValue(t){if(!this.isEmptyRenderAs(t.renderAs))return t.renderAs;const e=t,s=e.displayMode;return s==="custom"&&e.customRenderAs?e.customRenderAs:this.isBooleanDisplayMode(s)?s:"default"}static getContentQuestionTypeRenderAs(t,e){let s=t.renderAs;if(t.getType()==="boolean"&&(e.options.useLegacyBooleanRendering?s="checkbox":s=this.getBooleanRenderAsValue(t)),s!=="default"){const i=`${t.getType()}-${s}`;if(_.getInstance().isTypeRegistered(i))return i}return t.getType()}static getContentQuestionType(t,e){return t.customWidget?t.customWidget.pdfQuestionType:t.contentQuestion?"custom_model":this.getContentQuestionTypeRenderAs(t,e)}static getPageAvailableWidth(t){return t.paperWidth-t.margins.left-t.margins.right}static getColumnWidth(t,e,s){return(this.getPageAvailableWidth(t)-(e-1)*s)/e}static setColumnMargins(t,e,s,i){const n=this.getColumnWidth(t,e,i);t.margins.left=t.margins.left+s*(n+i),t.margins.right=t.margins.right+(e-s-1)*(n+i)}static moveRect(t,e=t.xLeft,s=t.yTop){return{xLeft:e,yTop:s,xRight:e+t.xRight-t.xLeft,yBot:s+t.yBot-t.yTop}}static createRectInsideBorders(t,e){const s=Mt(e);return{xLeft:t.xLeft+s.left,yTop:t.yTop+s.top,xRight:t.xRight-s.right,yBot:t.yBot-s.bot}}static getFlatQuestion(t,e,s){const i=this.getContentQuestionType(s,t),n=t.getElementStyle(s);return _.getInstance().create(t,s,e,n,i)}static async generateQuestionFlats(t,e,s,i){return[...await o.getFlatQuestion(t,e,s).generateFlats(i)]}static getFlatPanel(t,e,s){return _.getInstance().createPanel(t,s,e,t.getElementStyle(s))}static async generatePanelFlats(t,e,s,i){return[...await this.getFlatPanel(t,e,s).generateFlats(i)]}static async generatePageFlats(t,e,s,i){return[...await _.getInstance().createPage(t,s,e,t.getElementStyle(s)).generateFlats(i)]}static isFontExist(t,e){return t.doc.internal.getFont(e).fontName===e}static isCustomFont(t,e){return t.doc.internal.getFont(e).encoding==="Identity-H"}static fixFont(t){this.isCustomFont(t,t.fontName)&&(t.doc.text("load font",0,0),t.doc.deletePage(1),t.addPage())}static clone(t){const e={};for(const s in t)t.hasOwnProperty(s)&&(e[s]=t[s]);return e}static shouldRenderReadOnly(t,e,s){return(!!t&&t.isReadOnly||s)&&o.getReadonlyRenderAs(t,e)!=="acroform"||e?.compress}static isSizeEmpty(t){return!t||t==="auto"}static isHeightEmpty(t){return this.isSizeEmpty(t)||t=="100%"}static async getCorrectedImageSize(t,e){let{imageWidth:s,imageLink:i,imageHeight:n,defaultImageWidth:r,defaultImageHeight:l}=e;s=typeof s=="number"?s.toString():s,n=typeof n=="number"?n.toString():n;let a=s&&o.parseWidth(s,o.getPageAvailableWidth(t),1,"px"),h=n&&o.parseWidth(n,o.getPageAvailableWidth(t),1,"px");r=typeof r=="number"?r.toString():r,l=typeof l=="number"?l.toString():l;let u=r&&o.parseWidth(r,o.getPageAvailableWidth(t),1,"px"),g=l&&o.parseWidth(l,o.getPageAvailableWidth(t),1,"px");if(o.isSizeEmpty(s)||o.isHeightEmpty(n)){const b=await re().getImageInfo(i);o.isSizeEmpty(s)?o.isHeightEmpty(n)?b&&b.height&&b.width&&(h=Math.min(b.height,o.getPageAvailableWidth(t)),a=Math.min(b.width,o.getPageAvailableWidth(t))):b&&b.height&&(a=b.width*h/b.height):b&&b.width&&(h=b.height*a/b.width)}return{width:a||u||0,height:h||g||0}}static alignVerticallyBricks(t,...e){const s=o.mergeRects(...e);e.forEach(i=>{switch(t){case"center":{i.translateY((n,r)=>{const l=(s.yTop+s.yBot-(n+r))/2;return{yTop:n+l,yBot:r+l}});break}case"bottom":{i.translateY((n,r)=>({yTop:n+s.yBot-r,yBot:s.yBot}));break}default:i.translateY((n,r)=>({yTop:s.yTop,yBot:r-n+s.yTop}))}})}static clear(){re().clear()}}o.EPSILON=2220446049250313e-30,o.HTML_TAIL_TEXT_SCALE=.24;function cs(m){return m.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")}function us(m){return m=m||"",m.toString(),m="("+cs(m)+")",m}function ds(m){class t extends m.AcroFormTextField{getKeyValueListForStream(){const s=super.getKeyValueListForStream();return s.push({key:"DA",value:us(m.AcroFormAppearance.createDefaultAppearanceStream(this))}),s}}return t}function fs(m){class t extends m.AcroFormRadioButton{constructor(){super()}setAppearance(s){super.setAppearance(s);const i=s.YesNormal;for(const n in this.Kids)if(this.Kids.hasOwnProperty(n)){const r=this.Kids[n];r.appearanceStreamContent.N[r.optionName]=function(l){const a=i(l),h=a.stream.split(`
`),u=m.__private__.encodeColorString(l.color);return h[0]=h[0]+`
`+u+`
`+u.toUpperCase(),a.stream=h.join(`
`),a}}}}return t}function ps(m){class t extends m.AcroFormCheckBox{constructor(){super();const s=this.appearanceStreamContent.N.On;this.appearanceStreamContent.N.On=function(i){const n=s(i);let r=n.stream.split(`
`);return r=r.slice(3),n.stream=r.join(`
`),n}}}return t}function gs(m){class t extends m.AcroFormComboBox{constructor(){super()}set backgroundColor(s){if(s){let i=m.__private__.encodeColorString(s).replace(/\s+RG/i,"");i.includes("g")&&(i=i.replace("g","").repeat(3)),this.MK=`<< /BG [ ${i} ]  >>`}}}return t}/**
 * @license
 * Copyright (c) 2016 Alexander Weidt,
 * https://github.com/BiggA94
 * 
 * Licensed under the MIT License. http://opensource.org/licenses/mit-license
 */(function(m,t){var e=m.API,s,i=1;function n(c){for(var p="",f=0;f<c.length;f++){for(var y=c.charCodeAt(f).toString(16).toUpperCase();y.length<4;)y="0"+y;p+=y}return"<FEFF"+p+">"}var r=function(c){return c.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},l=function(c){return c.replace(/\\\\/g,"\\").replace(/\\\(/g,"(").replace(/\\\)/g,")")};function a(c){for(var p="[ ",f=0;f<c.length;f++)p+=n(c[f]);return p+=" ]",p}var h=function(c){return c.toFixed(2)},u=function(c){return c.toFixed(5)};e.__acroform__={};var g=function(c,p){c.prototype=Object.create(p.prototype),c.prototype.constructor=c},b=function(c){return c*i},T=function(c){return c/i},M=function(c){var p=new W,f=k.internal.getHeight(c)||0,y=k.internal.getWidth(c)||0;return p.BBox=[0,0,Number(h(y)),Number(h(f))],p},Z=e.__acroform__.setBit=function(c,p){if(c=c||0,p=p||0,isNaN(c)||isNaN(p))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.setBit");var f=1<<p;return c|=f,c},st=e.__acroform__.clearBit=function(c,p){if(c=c||0,p=p||0,isNaN(c)||isNaN(p))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.clearBit");var f=1<<p;return c&=~f,c},lt=e.__acroform__.getBit=function(c,p){if(isNaN(c)||isNaN(p))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.getBit");return(c&1<<p)===0?0:1},z=e.__acroform__.getBitForPdf=function(c,p){if(isNaN(c)||isNaN(p))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.getBitForPdf");return lt(c,p-1)},X=e.__acroform__.setBitForPdf=function(c,p){if(isNaN(c)||isNaN(p))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.setBitForPdf");return Z(c,p-1)},K=e.__acroform__.clearBitForPdf=function(c,p){if(isNaN(c)||isNaN(p))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf");return st(c,p-1)},gt=e.__acroform__.calculateCoordinates=function(c){var p=this.internal.getHorizontalCoordinate,f=this.internal.getVerticalCoordinate,y=c[0],w=c[1],L=c[2],Q=c[3],U={};return U.lowerLeft_X=p(y)||0,U.lowerLeft_Y=f(w+Q)||0,U.upperRight_X=p(y+L)||0,U.upperRight_Y=f(w)||0,[Number(h(U.lowerLeft_X)),Number(h(U.lowerLeft_Y)),Number(h(U.upperRight_X)),Number(h(U.upperRight_Y))]},J=function(c){if(c.appearanceStreamContent)return c.appearanceStreamContent;if(!(!c.V&&!c.DV)){var p=[],f=c.V||c.DV,y=C(c,l(f)),w=s.internal.getFont(c.fontName,c.fontStyle).id;p.push("/Tx BMC"),p.push("q"),p.push("BT"),p.push(s.__private__.encodeColorString(c.color)),p.push("/"+w+" "+h(y.fontSize)+" Tf"),p.push("1 0 0 1 0 0 Tm"),p.push(y.text),p.push("ET"),p.push("Q"),p.push("EMC");var L=new M(c);return L.stream=p.join(`
`),L}},C=function(c,p){c.isUnicode&&(p=c.trueValue);var f=c.fontSize===0?c.maxFontSize:c.fontSize,y={text:"",fontSize:""};p=p.substr(0,1)=="("?p.substr(1):p,p=p.substr(p.length-1)==")"?p.substr(0,p.length-1):p;var w=p.split(" ");w=w.map(function(jt){return jt.split(`
`)}),c.multiline||(w=w.map(function(jt){return[jt.join(" ")]}));var L=f,Q=2,U=2,nt=k.internal.getHeight(c)||0;nt=nt<0?-nt:nt;var rt=k.internal.getWidth(c)||0;rt=rt<0?-rt:rt;var ot=function(jt,Ms,qs){if(jt+1<w.length){var Ss=Ms+" "+w[jt+1][0],As=v(Ss,c,qs).width,Ws=rt-2*U;return As<=Ws}else return!1};L++;t:for(;L>0;){p="",L--;var ut=v("3",c,L).height,at=c.multiline?nt-L:(nt-ut)/2;at+=Q;var Lt,Gt=at,wt=0,F=0,ee,Wt=0;if(L<=0){L=12,p=`(...) Tj
`,p+="% Width of Text: "+v(p,c,L).width+", FieldWidth:"+rt+`
`;break}var Ft="",se=0;e:for(var Rt=0;Rt<w.length;Rt++)if(w.hasOwnProperty(Rt)){var Je=!1;if(w[Rt].length!==1&&Wt!==w[Rt].length-1){if((ut+Q)*(se+2)+Q>nt)continue t;Ft+=w[Rt][Wt],Je=!0,F=Rt,Rt--}else{Ft+=w[Rt][Wt]+" ",Ft=Ft.substr(Ft.length-1)==" "?Ft.substr(0,Ft.length-1):Ft;var pe=parseInt(Rt),Ze=ot(pe,Ft,L),ge=Rt>=w.length-1;if(Ze&&!ge){Ft+=" ",Wt=0;continue}else if(!Ze&&!ge)if(c.multiline){if((ut+Q)*(se+2)+Q>nt)continue t;F=pe}else continue t;else if(ge)F=pe;else if(c.multiline&&(ut+Q)*(se+2)+Q>nt)continue t}for(var mt="",Zt=wt;Zt<=F;Zt++){var Vt=w[Zt];if(c.multiline){if(Zt===F){mt+=Vt[Wt]+" ",Wt=(Wt+1)%Vt.length;continue}if(Zt===wt){mt+=Vt[Vt.length-1]+" ";continue}}mt+=Vt[0]+" "}switch(mt=mt.substr(mt.length-1)==" "?mt.substr(0,mt.length-1):mt,ee=v(mt,c,L).width,c.textAlign){case"right":Lt=rt-ee-U;break;case"center":Lt=(rt-ee)/2;break;default:Lt=U;break}if(p+=h(Lt)+" "+h(Gt)+` Td
`,c.isUnicode){var Ve={};const jt=s.internal.getFont(c.fontName,c.fontStyle);Ve[jt.id]=jt;var ts={text:mt,x:null,y:null,options:{lang:null},mutex:{pdfEscape:r,activeFontKey:jt.id,fonts:Ve,activeFontSize:c.fontSize}};s.internal.events.publish("postProcessText",ts),p+="<"+ts.text+`> Tj
`}else p+="("+r(mt)+`) Tj
`;p+=-h(Lt)+` 0 Td
`,Gt=-(L+Q),ee=0,wt=Je?F:F+1,se++,Ft="";continue e}break}return y.text=p,y.fontSize=L,y},v=function(c,p,f){var y=s.internal.getFont(p.fontName,p.fontStyle),w=s.getStringUnitWidth(c,{font:y,fontSize:parseFloat(f),charSpace:0})*parseFloat(f),L=s.getStringUnitWidth("3",{font:y,fontSize:parseFloat(f),charSpace:0})*parseFloat(f)*1.5;return{height:L,width:w}},d={fields:[],xForms:[],acroFormDictionaryRoot:null,printedOut:!1,internal:null,isInitialized:!1},R=function(){s.internal.acroformPlugin.acroFormDictionaryRoot.objId=void 0;var c=s.internal.acroformPlugin.acroFormDictionaryRoot.Fields;for(var p in c)if(c.hasOwnProperty(p)){var f=c[p];f.objId=void 0,f.hasAnnotation&&j.call(s,f)}},x=function(c){s.internal.acroformPlugin.printedOut&&(s.internal.acroformPlugin.printedOut=!1,s.internal.acroformPlugin.acroFormDictionaryRoot=null),s.internal.acroformPlugin.acroFormDictionaryRoot||A.call(s),s.internal.acroformPlugin.acroFormDictionaryRoot.Fields.push(c)},j=function(c){var p={type:"reference",object:c},f=function(y){return y.type===p.type&&y.object===p.object};s.internal.getPageInfo(c.page).pageContext.annotations.find(f)===void 0&&s.internal.getPageInfo(c.page).pageContext.annotations.push(p)},P=function(){if(typeof s.internal.acroformPlugin.acroFormDictionaryRoot<"u")s.internal.write("/AcroForm "+s.internal.acroformPlugin.acroFormDictionaryRoot.objId+" 0 R");else throw new Error("putCatalogCallback: Root missing.")},I=function(){s.internal.events.unsubscribe(s.internal.acroformPlugin.acroFormDictionaryRoot._eventID),delete s.internal.acroformPlugin.acroFormDictionaryRoot._eventID,s.internal.acroformPlugin.printedOut=!0},S=function(c){var p=!c;c||(s.internal.newObjectDeferredBegin(s.internal.acroformPlugin.acroFormDictionaryRoot.objId,!0),s.internal.acroformPlugin.acroFormDictionaryRoot.putStream()),c=c||s.internal.acroformPlugin.acroFormDictionaryRoot.Kids;for(var f in c)if(c.hasOwnProperty(f)){var y=c[f],w=[],L=y.Rect;if(y.Rect&&(y.Rect=gt.call(this,y.Rect)),s.internal.newObjectDeferredBegin(y.objId,!0),y.DA=k.createDefaultAppearanceStream(y),typeof y=="object"&&typeof y.getKeyValueListForStream=="function"&&(w=y.getKeyValueListForStream()),y.Rect=L,y.hasAppearanceStream&&!y.appearanceStreamContent){var Q=J.call(this,y);w.push({key:"AP",value:"<</N "+Q+">>"}),s.internal.acroformPlugin.xForms.push(Q)}if(y.appearanceStreamContent){var U="";for(var nt in y.appearanceStreamContent)if(y.appearanceStreamContent.hasOwnProperty(nt)){var rt=y.appearanceStreamContent[nt];if(U+="/"+nt+" ",U+="<<",Object.keys(rt).length>=1||Array.isArray(rt)){for(var f in rt)if(rt.hasOwnProperty(f)){var ot=rt[f];typeof ot=="function"&&(ot=ot.call(this,y)),U+="/"+f+" "+ot+" ",s.internal.acroformPlugin.xForms.indexOf(ot)>=0||s.internal.acroformPlugin.xForms.push(ot)}}else ot=rt,typeof ot=="function"&&(ot=ot.call(this,y)),U+="/"+f+" "+ot,s.internal.acroformPlugin.xForms.indexOf(ot)>=0||s.internal.acroformPlugin.xForms.push(ot);U+=">>"}w.push({key:"AP",value:`<<
`+U+">>"})}s.internal.putStream({additionalKeyValues:w}),s.internal.out("endobj")}p&&H.call(this,s.internal.acroformPlugin.xForms)},H=function(c){for(var p in c)if(c.hasOwnProperty(p)){var f=p,y=c[p];s.internal.newObjectDeferredBegin(y&&y.objId,!0),typeof y=="object"&&typeof y.putStream=="function"&&y.putStream(),delete c[f]}},A=function(){if(this.internal!==void 0&&(this.internal.acroformPlugin===void 0||this.internal.acroformPlugin.isInitialized===!1)){if(s=this,et.FieldNum=0,this.internal.acroformPlugin=JSON.parse(JSON.stringify(d)),this.internal.acroformPlugin.acroFormDictionaryRoot)throw new Error("Exception while creating AcroformDictionary");i=s.internal.scaleFactor,s.internal.acroformPlugin.acroFormDictionaryRoot=new Y,s.internal.acroformPlugin.acroFormDictionaryRoot._eventID=s.internal.events.subscribe("postPutResources",I),s.internal.events.subscribe("buildDocument",R),s.internal.events.subscribe("putCatalog",P),s.internal.events.subscribe("postPutPages",S),s.internal.acroformPlugin.isInitialized=!0}},O=e.__acroform__.arrayToPdfArray=function(c){if(Array.isArray(c)){for(var p="[",f=0;f<c.length;f++)switch(f!==0&&(p+=" "),typeof c[f]){case"boolean":case"number":case"object":p+=c[f].toString();break;case"string":c[f].substr(0,1)!=="/"?p+="("+r(c[f].toString())+")":p+=c[f].toString();break}return p+="]",p}throw new Error("Invalid argument passed to jsPDF.__acroform__.arrayToPdfArray")};function G(c,p,f){f||(f=1);for(var y=[],w;w=p.exec(c);)y.push(w[f]);return y}var $=function(c){var p=[];return typeof c=="string"&&(p=G(c,/\((.*?)\)/g)),p},q=function(c){return c=c||"",c.toString(),c="("+r(c)+")",c},N=function(){var c;Object.defineProperty(this,"objId",{configurable:!0,get:function(){return c||(c=s.internal.newObjectDeferred()),c},set:function(p){c=p}})};N.prototype.toString=function(){return this.objId+" 0 R"},N.prototype.putStream=function(){var c=this.getKeyValueListForStream();s.internal.putStream({data:this.stream,additionalKeyValues:c}),s.internal.out("endobj")},N.prototype.getKeyValueListForStream=function(){var c=function(p){var f=[],y=Object.getOwnPropertyNames(p).filter(function(nt){return nt!="content"&&nt!="appearanceStreamContent"&&nt.substring(0,1)!="_"});for(var w in y){var L=Object.getOwnPropertyDescriptor(p,y[w]);if(L&&L.configurable===!1){var Q=y[w],U=p[Q];U&&(Array.isArray(U)?f.push({key:Q,value:O(U)}):U instanceof N?f.push({key:Q,value:U.objId+" 0 R"}):typeof U!="function"&&f.push({key:Q,value:U}))}}return f};return c(this)};var W=function(){N.call(this),Object.defineProperty(this,"Type",{value:"/XObject",configurable:!1,writeable:!0}),Object.defineProperty(this,"Subtype",{value:"/Form",configurable:!1,writeable:!0}),Object.defineProperty(this,"FormType",{value:1,configurable:!1,writeable:!0});var c=[];Object.defineProperty(this,"BBox",{configurable:!1,writeable:!0,get:function(){return c},set:function(f){c=f}}),Object.defineProperty(this,"Resources",{value:"2 0 R",configurable:!1,writeable:!0});var p;Object.defineProperty(this,"stream",{enumerable:!1,configurable:!0,set:function(f){p=f.trim()},get:function(){return p||null}})};g(W,N);var Y=function(){N.call(this);var c=[];Object.defineProperty(this,"Kids",{enumerable:!1,configurable:!0,get:function(){if(c.length>0)return c}}),Object.defineProperty(this,"Fields",{enumerable:!1,configurable:!1,get:function(){return c}});var p;Object.defineProperty(this,"DA",{enumerable:!1,configurable:!1,get:function(){if(p)return"("+p+")"},set:function(f){p=f}})};g(Y,N);var et=function(){N.call(this);var c=4;this.isUnicode=!1,this.trueValue="",Object.defineProperty(this,"F",{enumerable:!1,configurable:!1,get:function(){return c},set:function(F){if(!isNaN(F))c=F;else throw new Error('Invalid value "'+F+'" for attribute F supplied.')}}),Object.defineProperty(this,"showWhenPrinted",{enumerable:!0,configurable:!0,get:function(){return!!z(c,3)},set:function(F){F?this.F=X(c,3):this.F=K(c,3)}});var p=0;Object.defineProperty(this,"Ff",{enumerable:!1,configurable:!1,get:function(){return p},set:function(F){if(!isNaN(F))p=F;else throw new Error('Invalid value "'+F+'" for attribute Ff supplied.')}});var f=[];Object.defineProperty(this,"Rect",{enumerable:!1,configurable:!1,get:function(){if(f.length!==0)return f},set:function(F){typeof F<"u"?f=F:f=[]}}),Object.defineProperty(this,"x",{enumerable:!0,configurable:!0,get:function(){return!f||isNaN(f[0])?0:T(f[0])},set:function(F){f[0]=b(F)}}),Object.defineProperty(this,"y",{enumerable:!0,configurable:!0,get:function(){return!f||isNaN(f[1])?0:T(f[1])},set:function(F){f[1]=b(F)}}),Object.defineProperty(this,"width",{enumerable:!0,configurable:!0,get:function(){return!f||isNaN(f[2])?0:T(f[2])},set:function(F){f[2]=b(F)}}),Object.defineProperty(this,"height",{enumerable:!0,configurable:!0,get:function(){return!f||isNaN(f[3])?0:T(f[3])},set:function(F){f[3]=b(F)}});var y="";Object.defineProperty(this,"FT",{enumerable:!0,configurable:!1,get:function(){return y},set:function(F){switch(F){case"/Btn":case"/Tx":case"/Ch":case"/Sig":y=F;break;default:throw new Error('Invalid value "'+F+'" for attribute FT supplied.')}}});var w=null;Object.defineProperty(this,"T",{enumerable:!0,configurable:!1,get:function(){if(!w||w.length<1){if(this instanceof Ht)return;w="FieldObject"+et.FieldNum++}return"("+r(w)+")"},set:function(F){w=F.toString()}}),Object.defineProperty(this,"fieldName",{configurable:!0,enumerable:!0,get:function(){return w},set:function(F){w=F}});var L="helvetica";Object.defineProperty(this,"fontName",{enumerable:!0,configurable:!0,get:function(){return L},set:function(F){L=F}});var Q="normal";Object.defineProperty(this,"fontStyle",{enumerable:!0,configurable:!0,get:function(){return Q},set:function(F){Q=F}});var U=0;Object.defineProperty(this,"fontSize",{enumerable:!0,configurable:!0,get:function(){return T(U)},set:function(F){U=b(F)}});var nt=50;Object.defineProperty(this,"maxFontSize",{enumerable:!0,configurable:!0,get:function(){return T(nt)},set:function(F){nt=b(F)}});var rt="black";Object.defineProperty(this,"color",{enumerable:!0,configurable:!0,get:function(){return rt},set:function(F){rt=F}});var ot="/F1 0 Tf 0 g";Object.defineProperty(this,"DA",{enumerable:!0,configurable:!1,get:function(){if(!(!ot||this instanceof Ht||this instanceof vt))return q(ot)},set:function(F){F=F.toString(),ot=F}});var ut=null;Object.defineProperty(this,"DV",{enumerable:!1,configurable:!1,get:function(){if(ut)return this instanceof V?ut:q(ut)},set:function(F){F=F.toString(),this instanceof V?ut=F:F.substr(0,1)==="("?ut=l(F.substr(1,F.length-2)):ut=l(F)}}),Object.defineProperty(this,"defaultValue",{enumerable:!0,configurable:!0,get:function(){return this instanceof V?l(ut.substr(1,ut.length-1)):ut},set:function(F){F=F.toString(),this instanceof V?ut="/"+F:ut=F}});var at=null;Object.defineProperty(this,"V",{enumerable:!1,configurable:!1,get:function(){if(this.isUnicode)return at;if(at)return this instanceof V?at:q(at)},set:function(F){F=F.toString(),this.isUnicode?(at=n(F),this.trueValue=F):this instanceof V?at=F:F.substr(0,1)==="("?at=l(F.substr(1,F.length-2)):at=l(F)}}),Object.defineProperty(this,"value",{enumerable:!0,configurable:!0,get:function(){return this.isUnicode?at:this instanceof V?l(at.substr(1,at.length-1)):at},set:function(F){F=F.toString(),this.isUnicode?(at=n(F),this.trueValue=F):this instanceof V?at="/"+F:at=F}}),Object.defineProperty(this,"hasAnnotation",{enumerable:!0,configurable:!0,get:function(){return this.Rect}}),Object.defineProperty(this,"Type",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?"/Annot":null}}),Object.defineProperty(this,"Subtype",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?"/Widget":null}});var Lt=!1;Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,writeable:!0,get:function(){return Lt},set:function(F){F=!!F,Lt=F}});var Gt;Object.defineProperty(this,"page",{enumerable:!0,configurable:!0,writeable:!0,get:function(){if(Gt)return Gt},set:function(F){Gt=F}}),Object.defineProperty(this,"readOnly",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,1)},set:function(F){F?this.Ff=X(this.Ff,1):this.Ff=K(this.Ff,1)}}),Object.defineProperty(this,"required",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,2)},set:function(F){F?this.Ff=X(this.Ff,2):this.Ff=K(this.Ff,2)}}),Object.defineProperty(this,"noExport",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,3)},set:function(F){F?this.Ff=X(this.Ff,3):this.Ff=K(this.Ff,3)}});var wt=null;Object.defineProperty(this,"Q",{enumerable:!0,configurable:!1,get:function(){if(wt!==null)return wt},set:function(F){if([0,1,2].indexOf(F)!==-1)wt=F;else throw new Error('Invalid value "'+F+'" for attribute Q supplied.')}}),Object.defineProperty(this,"textAlign",{get:function(){var F;switch(wt){case 0:default:F="left";break;case 1:F="center";break;case 2:F="right";break}return F},configurable:!0,enumerable:!0,set:function(F){switch(F){case"right":case 2:wt=2;break;case"center":case 1:wt=1;break;default:wt=0}}})};g(et,N);var it=function(){et.call(this),this.FT="/Ch",this.V="()",this.fontName="zapfdingbats";var c=0;Object.defineProperty(this,"TI",{enumerable:!0,configurable:!1,get:function(){return c},set:function(y){c=y}});var p="<< /BG [ 0.975 0.975 0.975 ]  >>";Object.defineProperty(this,"MK",{enumerable:!0,configurable:!1,get:function(){return p},set:function(y){p=y}}),Object.defineProperty(this,"topIndex",{enumerable:!0,configurable:!0,get:function(){return c},set:function(y){c=y}});var f=[];Object.defineProperty(this,"Opt",{enumerable:!0,configurable:!1,get:function(){return this.isUnicode?a(f):O(f)},set:function(y){f=$(y)}}),this.getOptions=function(){return f},this.setOptions=function(y){f=y,this.sort&&f.sort()},this.addOption=function(y){y=y||"",y=y.toString(),f.push(y),this.sort&&f.sort()},this.removeOption=function(y,w){for(w=w||!1,y=y||"",y=y.toString();f.indexOf(y)!==-1&&(f.splice(f.indexOf(y),1),w!==!1););},Object.defineProperty(this,"combo",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,18)},set:function(y){y?this.Ff=X(this.Ff,18):this.Ff=K(this.Ff,18)}}),Object.defineProperty(this,"edit",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,19)},set:function(y){this.combo===!0&&(y?this.Ff=X(this.Ff,19):this.Ff=K(this.Ff,19))}}),Object.defineProperty(this,"sort",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,20)},set:function(y){y?(this.Ff=X(this.Ff,20),f.sort()):this.Ff=K(this.Ff,20)}}),Object.defineProperty(this,"multiSelect",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,22)},set:function(y){y?this.Ff=X(this.Ff,22):this.Ff=K(this.Ff,22)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,23)},set:function(y){y?this.Ff=X(this.Ff,23):this.Ff=K(this.Ff,23)}}),Object.defineProperty(this,"commitOnSelChange",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,27)},set:function(y){y?this.Ff=X(this.Ff,27):this.Ff=K(this.Ff,27)}}),this.hasAppearanceStream=!1};g(it,et);var ht=function(){it.call(this),this.fontName="helvetica",this.combo=!1};g(ht,it);var ct=function(){ht.call(this),this.combo=!0};g(ct,ht);var dt=function(){ct.call(this),this.edit=!0};g(dt,ct);var V=function(){et.call(this),this.FT="/Btn",Object.defineProperty(this,"noToggleToOff",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,15)},set:function(f){f?this.Ff=X(this.Ff,15):this.Ff=K(this.Ff,15)}}),Object.defineProperty(this,"radio",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,16)},set:function(f){f?this.Ff=X(this.Ff,16):this.Ff=K(this.Ff,16)}}),Object.defineProperty(this,"pushButton",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,17)},set:function(f){f?this.Ff=X(this.Ff,17):this.Ff=K(this.Ff,17)}}),Object.defineProperty(this,"radioIsUnison",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,26)},set:function(f){f?this.Ff=X(this.Ff,26):this.Ff=K(this.Ff,26)}});var c={};Object.defineProperty(this,"MK",{enumerable:!1,configurable:!1,get:function(){if(Object.keys(c).length!==0){var f=[];f.push("<<");var y;for(y in c)f.push("/"+y+" ("+c[y]+")");return f.push(">>"),f.join(`
`)}},set:function(f){typeof f=="object"&&(c=f)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return c.CA||""},set:function(f){typeof f=="string"&&(c.CA=f)}});var p;Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return p},set:function(f){p=f}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return p.substr(1,p.length-1)},set:function(f){p="/"+f}})};g(V,et);var kt=function(){V.call(this),this.pushButton=!0};g(kt,V);var bt=function(){V.call(this),this.radio=!0,this.pushButton=!1;var c=[];Object.defineProperty(this,"Kids",{enumerable:!0,configurable:!1,get:function(){return c},set:function(p){typeof p<"u"?c=p:c=[]}})};g(bt,V);var Ht=function(){et.call(this);var c;Object.defineProperty(this,"Parent",{enumerable:!1,configurable:!1,get:function(){return c},set:function(w){c=w}});var p;Object.defineProperty(this,"optionName",{enumerable:!1,configurable:!0,get:function(){return p},set:function(w){p=w}});var f={};Object.defineProperty(this,"MK",{enumerable:!1,configurable:!1,get:function(){var w=[];w.push("<<");var L;for(L in f)w.push("/"+L+" ("+f[L]+")");return w.push(">>"),w.join(`
`)},set:function(w){typeof w=="object"&&(f=w)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return f.CA||""},set:function(w){typeof w=="string"&&(f.CA=w)}});var y;Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return y},set:function(w){y=w}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return y.substr(1,y.length-1)},set:function(w){y="/"+w}}),this.caption="l",this.appearanceState="Off",this._AppearanceType=k.RadioButton.Circle,this.appearanceStreamContent=this._AppearanceType.createAppearanceStream(this.optionName)};g(Ht,et),bt.prototype.setAppearance=function(c){if(!("createAppearanceStream"in c&&"getCA"in c))throw new Error("Couldn't assign Appearance to RadioButton. Appearance was Invalid!");for(var p in this.Kids)if(this.Kids.hasOwnProperty(p)){var f=this.Kids[p];f.appearanceStreamContent=c.createAppearanceStream(f.optionName),f.caption=c.getCA()}},bt.prototype.createOption=function(c){var p=new Ht;return p.Parent=this,p.optionName=c,this.Kids.push(p),yt.call(this,p),p};var At=function(){V.call(this),this.fontName="zapfdingbats",this.caption="3",this.appearanceState="On",this.value="On",this.textAlign="center",this.appearanceStreamContent=k.CheckBox.createAppearanceStream()};g(At,V);var vt=function(){et.call(this),this.FT="/Tx",Object.defineProperty(this,"multiline",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,13)},set:function(p){p?this.Ff=X(this.Ff,13):this.Ff=K(this.Ff,13)}}),Object.defineProperty(this,"fileSelect",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,21)},set:function(p){p?this.Ff=X(this.Ff,21):this.Ff=K(this.Ff,21)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,23)},set:function(p){p?this.Ff=X(this.Ff,23):this.Ff=K(this.Ff,23)}}),Object.defineProperty(this,"doNotScroll",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,24)},set:function(p){p?this.Ff=X(this.Ff,24):this.Ff=K(this.Ff,24)}}),Object.defineProperty(this,"comb",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,25)},set:function(p){p?this.Ff=X(this.Ff,25):this.Ff=K(this.Ff,25)}}),Object.defineProperty(this,"richText",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,26)},set:function(p){p?this.Ff=X(this.Ff,26):this.Ff=K(this.Ff,26)}});var c=null;Object.defineProperty(this,"MaxLen",{enumerable:!0,configurable:!1,get:function(){return c},set:function(p){c=p}}),Object.defineProperty(this,"maxLength",{enumerable:!0,configurable:!0,get:function(){return c},set:function(p){Number.isInteger(p)&&(c=p)}}),Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,get:function(){return this.V||this.DV}})};g(vt,et);var ft=function(){vt.call(this),Object.defineProperty(this,"password",{enumerable:!0,configurable:!0,get:function(){return!!z(this.Ff,14)},set:function(c){c?this.Ff=X(this.Ff,14):this.Ff=K(this.Ff,14)}}),this.password=!0};g(ft,vt);var k={CheckBox:{createAppearanceStream:function(){var c={N:{On:k.CheckBox.YesNormal},D:{On:k.CheckBox.YesPushDown,Off:k.CheckBox.OffPushDown}};return c},YesPushDown:function(c){var p=new M(c),f=[],y=s.internal.getFont(c.fontName,c.fontStyle).id,w=s.__private__.encodeColorString(c.color),L=C(c,c.caption);return f.push("0.749023 g"),f.push("0 0 "+h(k.internal.getWidth(c))+" "+h(k.internal.getHeight(c))+" re"),f.push("f"),f.push("BMC"),f.push("q"),f.push("0 0 1 rg"),f.push("/"+y+" "+h(L.fontSize)+" Tf "+w),f.push("BT"),f.push(L.text),f.push("ET"),f.push("Q"),f.push("EMC"),p.stream=f.join(`
`),p},YesNormal:function(c){var p=new M(c),f=s.internal.getFont(c.fontName,c.fontStyle).id,y=s.__private__.encodeColorString(c.color),w=[],L=k.internal.getHeight(c),Q=k.internal.getWidth(c),U=C(c,c.caption);return w.push("1 g"),w.push("0 0 "+h(Q)+" "+h(L)+" re"),w.push("f"),w.push("q"),w.push("0 0 1 rg"),w.push("0 0 "+h(Q-1)+" "+h(L-1)+" re"),w.push("W"),w.push("n"),w.push("0 g"),w.push("BT"),w.push("/"+f+" "+h(U.fontSize)+" Tf "+y),w.push(U.text),w.push("ET"),w.push("Q"),p.stream=w.join(`
`),p},OffPushDown:function(c){var p=new M(c),f=[];return f.push("0.749023 g"),f.push("0 0 "+h(k.internal.getWidth(c))+" "+h(k.internal.getHeight(c))+" re"),f.push("f"),p.stream=f.join(`
`),p}},RadioButton:{Circle:{createAppearanceStream:function(c){var p={D:{Off:k.RadioButton.Circle.OffPushDown},N:{}};return p.N[c]=k.RadioButton.Circle.YesNormal,p.D[c]=k.RadioButton.Circle.YesPushDown,p},getCA:function(){return"l"},YesNormal:function(c){var p=new M(c),f=[],y=k.internal.getWidth(c)<=k.internal.getHeight(c)?k.internal.getWidth(c)/4:k.internal.getHeight(c)/4;y=Number((y*.9).toFixed(5));var w=k.internal.Bezier_C,L=Number((y*w).toFixed(5));return f.push("q"),f.push("1 0 0 1 "+u(k.internal.getWidth(c)/2)+" "+u(k.internal.getHeight(c)/2)+" cm"),f.push(y+" 0 m"),f.push(y+" "+L+" "+L+" "+y+" 0 "+y+" c"),f.push("-"+L+" "+y+" -"+y+" "+L+" -"+y+" 0 c"),f.push("-"+y+" -"+L+" -"+L+" -"+y+" 0 -"+y+" c"),f.push(L+" -"+y+" "+y+" -"+L+" "+y+" 0 c"),f.push("f"),f.push("Q"),p.stream=f.join(`
`),p},YesPushDown:function(c){var p=new M(c),f=[],y=k.internal.getWidth(c)<=k.internal.getHeight(c)?k.internal.getWidth(c)/4:k.internal.getHeight(c)/4,y=Number((y*.9).toFixed(5)),w=Number((y*2).toFixed(5)),L=Number((w*k.internal.Bezier_C).toFixed(5)),Q=Number((y*k.internal.Bezier_C).toFixed(5));return f.push("0.749023 g"),f.push("q"),f.push("1 0 0 1 "+u(k.internal.getWidth(c)/2)+" "+u(k.internal.getHeight(c)/2)+" cm"),f.push(w+" 0 m"),f.push(w+" "+L+" "+L+" "+w+" 0 "+w+" c"),f.push("-"+L+" "+w+" -"+w+" "+L+" -"+w+" 0 c"),f.push("-"+w+" -"+L+" -"+L+" -"+w+" 0 -"+w+" c"),f.push(L+" -"+w+" "+w+" -"+L+" "+w+" 0 c"),f.push("f"),f.push("Q"),f.push("0 g"),f.push("q"),f.push("1 0 0 1 "+u(k.internal.getWidth(c)/2)+" "+u(k.internal.getHeight(c)/2)+" cm"),f.push(y+" 0 m"),f.push(""+y+" "+Q+" "+Q+" "+y+" 0 "+y+" c"),f.push("-"+Q+" "+y+" -"+y+" "+Q+" -"+y+" 0 c"),f.push("-"+y+" -"+Q+" -"+Q+" -"+y+" 0 -"+y+" c"),f.push(Q+" -"+y+" "+y+" -"+Q+" "+y+" 0 c"),f.push("f"),f.push("Q"),p.stream=f.join(`
`),p},OffPushDown:function(c){var p=new M(c),f=[],y=k.internal.getWidth(c)<=k.internal.getHeight(c)?k.internal.getWidth(c)/4:k.internal.getHeight(c)/4;y=Number((y*.9).toFixed(5));var w=Number((y*2).toFixed(5)),L=Number((w*k.internal.Bezier_C).toFixed(5));return f.push("0.749023 g"),f.push("q"),f.push("1 0 0 1 "+u(k.internal.getWidth(c)/2)+" "+u(k.internal.getHeight(c)/2)+" cm"),f.push(w+" 0 m"),f.push(w+" "+L+" "+L+" "+w+" 0 "+w+" c"),f.push("-"+L+" "+w+" -"+w+" "+L+" -"+w+" 0 c"),f.push("-"+w+" -"+L+" -"+L+" -"+w+" 0 -"+w+" c"),f.push(L+" -"+w+" "+w+" -"+L+" "+w+" 0 c"),f.push("f"),f.push("Q"),p.stream=f.join(`
`),p}},Cross:{createAppearanceStream:function(c){var p={D:{Off:k.RadioButton.Cross.OffPushDown},N:{}};return p.N[c]=k.RadioButton.Cross.YesNormal,p.D[c]=k.RadioButton.Cross.YesPushDown,p},getCA:function(){return"8"},YesNormal:function(c){var p=new M(c),f=[],y=k.internal.calculateCross(c);return f.push("q"),f.push("1 1 "+h(k.internal.getWidth(c)-2)+" "+h(k.internal.getHeight(c)-2)+" re"),f.push("W"),f.push("n"),f.push(h(y.x1.x)+" "+h(y.x1.y)+" m"),f.push(h(y.x2.x)+" "+h(y.x2.y)+" l"),f.push(h(y.x4.x)+" "+h(y.x4.y)+" m"),f.push(h(y.x3.x)+" "+h(y.x3.y)+" l"),f.push("s"),f.push("Q"),p.stream=f.join(`
`),p},YesPushDown:function(c){var p=new M(c),f=k.internal.calculateCross(c),y=[];return y.push("0.749023 g"),y.push("0 0 "+h(k.internal.getWidth(c))+" "+h(k.internal.getHeight(c))+" re"),y.push("f"),y.push("q"),y.push("1 1 "+h(k.internal.getWidth(c)-2)+" "+h(k.internal.getHeight(c)-2)+" re"),y.push("W"),y.push("n"),y.push(h(f.x1.x)+" "+h(f.x1.y)+" m"),y.push(h(f.x2.x)+" "+h(f.x2.y)+" l"),y.push(h(f.x4.x)+" "+h(f.x4.y)+" m"),y.push(h(f.x3.x)+" "+h(f.x3.y)+" l"),y.push("s"),y.push("Q"),p.stream=y.join(`
`),p},OffPushDown:function(c){var p=new M(c),f=[];return f.push("0.749023 g"),f.push("0 0 "+h(k.internal.getWidth(c))+" "+h(k.internal.getHeight(c))+" re"),f.push("f"),p.stream=f.join(`
`),p}}},createDefaultAppearanceStream:function(c){var p=s.internal.getFont(c.fontName,c.fontStyle).id,f=s.__private__.encodeColorString(c.color),y=c.fontSize,w="/"+p+" "+y+" Tf "+f;return w}};k.internal={Bezier_C:.551915024494,calculateCross:function(c){var p=k.internal.getWidth(c),f=k.internal.getHeight(c),y=Math.min(p,f),w={x1:{x:(p-y)/2,y:(f-y)/2+y},x2:{x:(p-y)/2+y,y:(f-y)/2},x3:{x:(p-y)/2,y:(f-y)/2},x4:{x:(p-y)/2+y,y:(f-y)/2+y}};return w}},k.internal.getWidth=function(c){var p=0;return typeof c=="object"&&(p=b(c.Rect[2])),p},k.internal.getHeight=function(c){var p=0;return typeof c=="object"&&(p=b(c.Rect[3])),p};var yt=e.addField=function(c){if(A.call(this),c instanceof et)x.call(this,c);else throw new Error("Invalid argument passed to jsPDF.addField.");return c.page=s.internal.getCurrentPageInfo().pageNumber,this};e.addButton=function(c){if(!(c instanceof V))throw new Error("Invalid argument passed to jsPDF.addButton.");return yt.call(this,c)},e.addTextField=function(c){if(!(c instanceof vt))throw new Error("Invalid argument passed to jsPDF.addTextField.");return yt.call(this,c)},e.addChoiceField=function(c){if(!(c instanceof it))throw new Error("Invalid argument passed to jsPDF.addChoiceField.");return yt.call(this,c)},typeof t=="object"&&typeof t.ChoiceField>"u"&&typeof t.ListBox>"u"&&typeof t.ComboBox>"u"&&typeof t.EditBox>"u"&&typeof t.Button>"u"&&typeof t.PushButton>"u"&&typeof t.RadioButton>"u"&&typeof t.CheckBox>"u"&&typeof t.TextField>"u"&&typeof t.PasswordField>"u"&&(t.ChoiceField=it,t.ListBox=ht,t.ComboBox=ct,t.EditBox=dt,t.Button=V,t.PushButton=kt,t.RadioButton=bt,t.CheckBox=At,t.TextField=vt,t.PasswordField=ft,t.AcroForm={Appearance:k}),e.AcroFormChoiceField=it,e.AcroFormListBox=ht,e.AcroFormComboBox=ct,e.AcroFormEditBox=dt,e.AcroFormButton=V,e.AcroFormPushButton=kt,e.AcroFormRadioButton=bt,e.AcroFormCheckBox=At,e.AcroFormTextField=vt,e.AcroFormPasswordField=ft,e.AcroFormAppearance=k,e.AcroForm={ChoiceField:it,ListBox:ht,ComboBox:ct,EditBox:dt,Button:V,PushButton:kt,RadioButton:bt,CheckBox:At,TextField:vt,PasswordField:ft,Appearance:k},m.AcroForm={ChoiceField:it,ListBox:ht,ComboBox:ct,EditBox:dt,Button:V,PushButton:kt,RadioButton:bt,CheckBox:At,TextField:vt,PasswordField:ft,Appearance:k}})(Ot.jsPDF,typeof window<"u"&&window||typeof global<"u"&&global);/**
   * jsPDF fromHTML plugin. BETA stage. API subject to change. Needs browser
   * Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
   *               2014 Juan Pablo Gaviria, https://github.com/juanpgaviria
   *               2014 Diego Casorran, https://github.com/diegocr
   *               2014 Daniel Husar, https://github.com/danielhusar
   *               2014 Wolfgang Gassler, https://github.com/woolfg
   *               2014 Steven Spungin, https://github.com/flamenco
   *
   * @license
   * 
   * ====================================================================
   */(function(m){var t,e,s,i,n,r,l,a,h,u,g,b,T,M,Z,st,lt,z,X,K;t=(function(){return function(v){return C.prototype=v,new C};function C(){}})(),u=function(v){var d,R,x,j,P,I,S;for(R=0,x=v.length,d=void 0,j=!1,I=!1;!j&&R!==x;)d=v[R]=v[R].trimLeft(),d&&(j=!0),R++;for(R=x-1;x&&!I&&R!==-1;)d=v[R]=v[R].trimRight(),d&&(I=!0),R--;for(P=/\s+$/g,S=!0,R=0;R!==x;)v[R]!="\u2028"&&(d=v[R].replace(/\s+/g," "),S&&(d=d.trimLeft()),d&&(S=P.test(d)),v[R]=d),R++;return v},g=function(v,d,R,x){return this.pdf=v,this.x=d,this.y=R,this.settings=x,this.watchFunctions=[],this.init(),this},b=function(v){var d,R,x;for(d=void 0,x=v.split(","),R=x.shift();!d&&R;)d=s[R.trim().toLowerCase()],R=x.shift();return d},T=function(v){v=v==="auto"?"0px":v,v.indexOf("em")>-1&&!isNaN(Number(v.replace("em","")))&&(v=Number(v.replace("em",""))*18.719+"px"),v.indexOf("pt")>-1&&!isNaN(Number(v.replace("pt","")))&&(v=Number(v.replace("pt",""))*1.333+"px");var d,R,x;return R=void 0,d=16,x=M[v],x||(x={"xx-small":9,"x-small":11,small:13,medium:16,large:19,"x-large":23,"xx-large":28,auto:0}[v],x!==R||(x=parseFloat(v))?M[v]=x/d:(x=v.match(/([\d\.]+)(px)/),Array.isArray(x)&&x.length===3?M[v]=parseFloat(x[1])/d:M[v]=1))},h=function(v){var d,R,x;return x=(function(j){var P;return P=(function(I){return document.defaultView&&document.defaultView.getComputedStyle?document.defaultView.getComputedStyle(I,null):I.currentStyle?I.currentStyle:I.style})(j),function(I){return I=I.replace(/-\D/g,function(S){return S.charAt(1).toUpperCase()}),P[I]}})(v),d={},R=void 0,d["font-family"]=b(x("font-family"))||"times",d["font-style"]=i[x("font-style")]||"normal",d["text-align"]=n[x("text-align")]||"left",R=r[x("font-weight")]||"normal",R==="bold"&&(d["font-style"]==="normal"?d["font-style"]=R:d["font-style"]=R+d["font-style"]),d["font-size"]=T(x("font-size"))||1,d["line-height"]=T(x("line-height"))||1,d.display=x("display")==="inline"?"inline":"block",R=d.display==="block",d["margin-top"]=R&&T(x("margin-top"))||0,d["margin-bottom"]=R&&T(x("margin-bottom"))||0,d["padding-top"]=R&&T(x("padding-top"))||0,d["padding-bottom"]=R&&T(x("padding-bottom"))||0,d["margin-left"]=R&&T(x("margin-left"))||0,d["margin-right"]=R&&T(x("margin-right"))||0,d["padding-left"]=R&&T(x("padding-left"))||0,d["padding-right"]=R&&T(x("padding-right"))||0,d["page-break-before"]=x("page-break-before")||"auto",d.float=l[x("cssFloat")]||"none",d.clear=a[x("clear")]||"none",d.color=x("color"),d},Z=function(v,d,R){var x,j,P,I,S;if(P=!1,j=void 0,I=void 0,x=R["#"+v.id],x)if(typeof x=="function")P=x(v,d);else for(j=0,I=x.length;!P&&j!==I;)P=x[j](v,d),j++;if(x=R[v.nodeName],!P&&x)if(typeof x=="function")P=x(v,d);else for(j=0,I=x.length;!P&&j!==I;)P=x[j](v,d),j++;for(S=typeof v.className=="string"?v.className.split(" "):[],j=0;j<S.length;j++)if(x=R["."+S[j]],!P&&x)if(typeof x=="function")P=x(v,d);else for(j=0,I=x.length;!P&&j!==I;)P=x[j](v,d),j++;return P},K=function(v,d){var R,x,j,P,I,S,H,A,O;R=[],x=[],j=0,O=0;for(var P=0;P<v.rows[0].cells.length;P++)O+=v.rows[0].cells[P].colSpan;for(H=v.clientWidth;j<O;){A=v.rows[0].cells[j];for(var P=0;P<A.colSpan;P++)x[j+P]={name:A.textContent.toLowerCase().replace(/\s+/g,"")+"_"+P,prompt:A.textContent.replace(/\r?\n/g,""),width:A.clientWidth/H*d.settings.width/A.colSpan};j+=P}for(j=1;j<v.rows.length;){for(S=v.rows[j],I={},P=0;P<S.cells.length;)I[x[P].name]=S.cells[P].textContent.replace(/\r?\n/g,""),P++;R.push(I),j++}return{rows:R,headers:x}};var gt={SCRIPT:1,STYLE:1,NOSCRIPT:1,OBJECT:1,EMBED:1,SELECT:1},J=1;e=function(v,d,R){var x,j,P,I,S,H,A,O;for(j=v.childNodes,x=void 0,P=h(v),S=P.display==="block",S&&(d.setBlockBoundary(),d.setBlockStyle(P)),I=0,H=j.length;I<H;){if(x=j[I],typeof x=="object"){if(d.executeWatchFunctions(x),x.nodeType===1&&x.nodeName==="HEADER"){var G=x,$=d.pdf.margins_doc.top;d.pdf.internal.events.subscribe("addPage",function(ft){d.y=$,e(G,d,R),d.pdf.margins_doc.top=d.y+10,d.y+=10},!1)}if(x.nodeType===8&&x.nodeName==="#comment")~x.textContent.indexOf("ADD_PAGE")&&(d.pdf.addPage(),d.y=d.pdf.margins_doc.top);else if(x.nodeType===1&&!gt[x.nodeName]){var q;if(x.nodeName==="IMG"){var N=x.getAttribute("src");q=st[d.pdf.sHashCode&&d.pdf.sHashCode(N)||N]}if(q){d.pdf.internal.pageSize.getHeight()-d.pdf.margins_doc.bottom<d.y+x.height&&d.y>d.pdf.margins_doc.top&&(d.pdf.addPage(),d.y=d.pdf.margins_doc.top,d.executeWatchFunctions(x));var W=h(x),Y=d.x,et=12/d.pdf.internal.scaleFactor,it=(W["margin-left"]+W["padding-left"])*et,ht=(W["margin-right"]+W["padding-right"])*et,ct=(W["margin-top"]+W["padding-top"])*et,dt=(W["margin-bottom"]+W["padding-bottom"])*et;W.float!==void 0&&W.float==="right"?Y+=d.settings.width-x.width-ht:Y+=it,d.pdf.addImage(q,Y,d.y+ct,x.width,x.height),q=void 0,W.float==="right"||W.float==="left"?(d.watchFunctions.push(function(ft,k,yt,c){return d.y>=k?(d.x+=ft,d.settings.width+=yt,!0):c&&c.nodeType===1&&!gt[c.nodeName]&&d.x+c.width>d.pdf.margins_doc.left+d.pdf.margins_doc.width?(d.x+=ft,d.y=k,d.settings.width+=yt,!0):!1}.bind(this,W.float==="left"?-x.width-it-ht:0,d.y+x.height+ct+dt,x.width)),d.watchFunctions.push(function(ft,k,yt){return d.y<ft&&k===d.pdf.internal.getNumberOfPages()?yt.nodeType===1&&h(yt).clear==="both"?(d.y=ft,!0):!1:!0}.bind(this,d.y+x.height,d.pdf.internal.getNumberOfPages())),d.settings.width-=x.width+it+ht,W.float==="left"&&(d.x+=x.width+it+ht)):d.y+=x.height+ct+dt}else if(x.nodeName==="TABLE")d.pdf.autoTable?(d.y+=10,d.pdf.autoTable({theme:"grid",html:x,startY:d.y,styles:{font:d.pdf.getFont().fontName,fontSize:d.pdf.getFontSize(),textColor:d.pdf.getTextColor()},margin:{top:d.pdf.margins_doc.top,left:d.x,right:d.pdf.internal.pageSize.getWidth()-(d.x+d.settings.width),bottom:d.pdf.margins_doc.bottom}}),d.y=d.pdf.lastAutoTable.finalY):(A=K(x,d),d.y+=10,d.pdf.table(d.x,d.y,A.rows,A.headers,{autoSize:!1,printHeaders:R.printHeaders,margins:d.pdf.margins_doc,css:h(x)}),d.y=d.pdf.internal.__cell__.lastCell.y+d.pdf.internal.__cell__.lastCell.height);else if(x.nodeName==="OL"||x.nodeName==="UL")J=1,Z(x,d,R)||e(x,d,R),d.y+=10;else if(x.nodeName==="LI"){var V=d.x;d.x+=20/d.pdf.internal.scaleFactor,d.y+=3,Z(x,d,R)||e(x,d,R),d.x=V}else x.nodeName==="BR"?(d.y+=P["font-size"]*d.pdf.internal.scaleFactor,d.addText("\u2028",t(P))):Z(x,d,R)||e(x,d,R)}else if(x.nodeType===3){var kt=x.nodeValue;if(x.nodeValue&&x.parentNode.nodeName==="LI")if(x.parentNode.parentNode.nodeName==="OL")kt=J+++". "+kt;else{var bt=P["font-size"],Ht=(3-bt*.75)*d.pdf.internal.scaleFactor,At=bt*.75*d.pdf.internal.scaleFactor,vt=bt*1.74/d.pdf.internal.scaleFactor;O=function(k,yt){this.pdf.circle(k+Ht,yt+At,vt,"FD")}}x.ownerDocument.body.compareDocumentPosition(x)&16&&d.addText(kt,P)}else typeof x=="string"&&d.addText(x,P)}I++}if(R.outY=d.y,S)return d.setBlockBoundary(O)},st={},lt=function(v,d,R,x){var j=v.getElementsByTagName("img"),P=j.length,I,S=0;function H(){d.pdf.internal.events.publish("imagesLoaded"),x(I)}function A(O,G,$){if(O){var q=new Image;I=++S,q.crossOrigin="",q.onerror=q.onload=function(){if(q.complete&&(q.src.indexOf("data:image/")===0&&(q.width=G||q.width||0,q.height=$||q.height||0),q.width+q.height)){var N=d.pdf.sHashCode&&d.pdf.sHashCode(O)||O;st[N]=st[N]||q}--S||H()},q.src=O}}for(;P--;)A(j[P].getAttribute("src"),j[P].width,j[P].height);return S||H()},z=function(v,d,R){var x=v.getElementsByTagName("footer");if(x.length>0){x=x[0];var j=d.pdf.internal.write,P=d.y;d.pdf.internal.write=function(){},e(x,d,R);var I=Math.ceil(d.y-P)+5;d.y=P,d.pdf.internal.write=j,d.pdf.margins_doc.bottom+=I;for(var S=function(G){var $=G!==void 0?G.pageNumber:1,q=d.y;d.y=d.pdf.internal.pageSize.getHeight()-d.pdf.margins_doc.bottom,d.pdf.margins_doc.bottom-=I;for(var N=x.getElementsByTagName("span"),W=0;W<N.length;++W)(" "+N[W].className+" ").replace(/[\n\t]/g," ").indexOf(" pageCounter ")>-1&&(N[W].innerHTML=$),(" "+N[W].className+" ").replace(/[\n\t]/g," ").indexOf(" totalPages ")>-1&&(N[W].innerHTML="###jsPDFVarTotalPages###");e(x,d,R),d.pdf.margins_doc.bottom+=I,d.y=q},H=x.getElementsByTagName("span"),A=0;A<H.length;++A)(" "+H[A].className+" ").replace(/[\n\t]/g," ").indexOf(" totalPages ")>-1&&d.pdf.internal.events.subscribe("htmlRenderingFinished",d.pdf.putTotalPages.bind(d.pdf,"###jsPDFVarTotalPages###"),!0);d.pdf.internal.events.subscribe("addPage",S,!1),S(),gt.FOOTER=1}},X=function(v,d,R,x,j,P){if(!d)return!1;typeof d!="string"&&!d.parentNode&&(d=""+d.innerHTML),typeof d=="string"&&(d=(function($){var q,N,W,Y;return W="jsPDFhtmlText"+Date.now().toString()+(Math.random()*1e3).toFixed(0),Y="position: absolute !important;clip: rect(1px 1px 1px 1px); /* IE6, IE7 */clip: rect(1px, 1px, 1px, 1px);padding:0 !important;border:0 !important;height: 1px !important;width: 1px !important; top:auto;left:-100px;overflow: hidden;",N=document.createElement("div"),N.className="sjs-pdf-hidden-html-div",N.style.cssText=Y,N.innerHTML='<iframe style="height:1px;width:1px" name="'+W+'" />',document.body.appendChild(N),q=window.frames[W],q.document.open(),q.document.writeln($),q.document.close(),q.document.body})(d.replace(/<\/?script[^>]*?>/gi,"")));for(var I=Object.keys(v.getFontList()),S=0;S<I.length;++S){var H=I[S],A=H.toLowerCase();s[A]||(s[A]=H)}var O=new g(v,R,x,j),G;return lt.call(this,d,O,j.elementHandlers,function($){z(d,O,j.elementHandlers),e(d,O,j.elementHandlers),O.pdf.internal.events.publish("htmlRenderingFinished"),G=O.dispose(),typeof P=="function"?P(G):$&&console.error("jsPDF Warning: rendering issues? provide a callback to fromHTML!")}),G||{x:O.x,y:O.y}},g.prototype.init=function(){return this.paragraph={text:[],style:[]},this.pdf.internal.write("q")},g.prototype.dispose=function(){return this.pdf.internal.write("Q"),{x:this.x,y:this.y,ready:!0}},g.prototype.executeWatchFunctions=function(C){var v=!1,d=[];if(this.watchFunctions.length>0){for(var R=0;R<this.watchFunctions.length;++R)this.watchFunctions[R](C)===!0?v=!0:d.push(this.watchFunctions[R]);this.watchFunctions=d}return v},g.prototype.splitFragmentsIntoLines=function(C,v){var d,R,x,j,P,I,S,H,A,O,G,$,q;R=12,A=this.pdf.internal.scaleFactor,x=void 0,H=void 0,j=void 0,q=void 0,S=void 0,I=void 0,P=void 0,O=[],G=[O],d=0,$=this.settings.width;const N=this.pdf.getFont().fontName,W=this.pdf.getFont().fontStyle;for(;C.length;)if(j=C.shift(),q=v.shift(),j)if(x=q["font-family"],H=q["font-style"],this.pdf.setFont(x,H),S={textIndent:d,fontSize:q["font-size"]*R},I=this.pdf.getStringUnitWidth(j,S)*S.fontSize/A,j=="\u2028")O=[],G.push(O);else if(d+I>$){for(P=this.pdf.splitTextToSize(j,$,S),O.push([P.shift(),q]);P.length;)O=[[P.shift(),q]],G.push(O);d=this.pdf.getStringUnitWidth(O[0][0],S)*S.fontSize/A}else O.push([j,q]),d+=I;if(q["text-align"]!==void 0&&(q["text-align"]==="center"||q["text-align"]==="right"||q["text-align"]==="justify"))for(var Y=0;Y<G.length;++Y){var et=this.pdf.getStringUnitWidth(G[Y][0][0],S)*S.fontSize/A;Y>0&&(G[Y][0][1]=t(G[Y][0][1]));var it=$-et;if(q["text-align"]==="right")G[Y][0][1]["margin-left"]=it;else if(q["text-align"]==="center")G[Y][0][1]["margin-left"]=it/2;else if(q["text-align"]==="justify"){var ht=G[Y][0][0].split(" ").length-1;G[Y][0][1]["word-spacing"]=it/ht,Y===G.length-1&&(G[Y][0][1]["word-spacing"]=0)}}return this.pdf.setFont(N,W),G},g.prototype.RenderTextFragment=function(C,v){var d,R,x;if(x=0,d=12,this.pdf.internal.pageSize.getHeight()-this.pdf.margins_doc.bottom<this.y+this.pdf.internal.getFontSize()){this.pdf.internal.write("ET","Q","Q");const H=this.pdf.getCurrentPageInfo().pageNumber;this.pdf.getNumberOfPages()===H?this.pdf.addPage():this.pdf.setPage(H+1),this.y=this.pdf.margins_doc.top,this.pdf.internal.write("q","q","BT",this.getPdfColor(v.color),this.pdf.internal.getCoordinateString(this.x),this.pdf.internal.getVerticalCoordinateString(this.y),"Td"),x=Math.max(x,v["line-height"],v["font-size"]),this.pdf.internal.write(0,(-1*d*x).toFixed(2),"Td")}R=this.pdf.internal.getFont(v["font-family"],v["font-style"]);var j=this.getPdfColor(v.color);j!==this.lastTextColor&&(this.pdf.internal.write(j),this.lastTextColor=j),v["word-spacing"]!==void 0&&v["word-spacing"]>0&&this.pdf.internal.write(v["word-spacing"].toFixed(2),"Tw");var P=function(H,A){for(var O=A.metadata.Unicode.widths,G=["","0","00","000","0000"],$=[""],q=0,N=H.length,W;q<N;++q){if(W=A.metadata.characterToGlyph(H.charCodeAt(q)),A.metadata.glyIdsUsed.push(W),A.metadata.toUnicode[W]=H.charCodeAt(q),O.indexOf(W)==-1&&(O.push(W),O.push([parseInt(A.metadata.widthOfGlyph(W),10)])),W=="0")return $.join("");W=W.toString(16),$.push(G[4-W.length],W)}return $.join("")},I=function(O,A){var O=O||"",G="",$=0,q,N="",W=A.encoding;if(A.encoding!=="Identity-H")return O;for(N=O,$=0;$<N.length;$+=1)A.metadata.hasOwnProperty("cmap")&&(q=A.metadata.cmap.unicode.codeMap[N[$].charCodeAt(0)]),q||N[$].charCodeAt(0)<256&&A.metadata.hasOwnProperty("Unicode")?G+=N[$]:G+="";var Y="";return parseInt(A.id.slice(1))<14||W==="WinAnsiEncoding"?Y=this.pdf.internal.pdfEscape(G,key).split("").map(function(et){return et.charCodeAt(0).toString(16)}).join(""):W==="Identity-H"&&(Y=P(G,A)),Y},S="";R.encoding!=="Identity-H"?S="("+this.pdf.internal.pdfEscape(C)+")":S="<"+I(C,R)+">",this.pdf.internal.write("/"+R.id,(d*v["font-size"]).toFixed(2),"Tf",S+" Tj"),v["word-spacing"]!==void 0&&this.pdf.internal.write(0,"Tw")},g.prototype.getPdfColor=function(C){var v,d,R,x,j=/rgb\s*\(\s*(\d+),\s*(\d+),\s*(\d+\s*)\)/,P=j.exec(C);if(P!=null)d=parseInt(P[1]),R=parseInt(P[2]),x=parseInt(P[3]);else{if(typeof C=="string"&&C.charAt(0)!="#"){var I=new RGBColor(C);I.ok?C=I.toHex():C="#000000"}d=C.substring(1,3),d=parseInt(d,16),R=C.substring(3,5),R=parseInt(R,16),x=C.substring(5,7),x=parseInt(x,16)}if(typeof d=="string"&&/^#[0-9A-Fa-f]{6}$/.test(d)){var S=parseInt(d.substr(1),16);d=S>>16&255,R=S>>8&255,x=S&255}var H=this.f3;return d===0&&R===0&&x===0||typeof R>"u"?v=H(d/255)+" g":v=[H(d/255),H(R/255),H(x/255),"rg"].join(" "),v},g.prototype.f3=function(C){return C.toFixed(3)},g.prototype.renderParagraph=function(C){var v,d,R,x,j,P,I,S,H,A,O,G,$,q;if(x=u(this.paragraph.text),$=this.paragraph.style,v=this.paragraph.blockstyle,this.paragraph.priorblockstyle,this.paragraph={text:[],style:[],blockstyle:{},priorblockstyle:v},!!x.join("").trim()){S=this.splitFragmentsIntoLines(x,$),I=void 0,H=void 0,d=12,R=d/this.pdf.internal.scaleFactor,this.priorMarginBottom=this.priorMarginBottom||0,G=(Math.max((v["margin-top"]||0)-this.priorMarginBottom,0)+(v["padding-top"]||0))*R,O=((v["margin-bottom"]||0)+(v["padding-bottom"]||0))*R,this.priorMarginBottom=v["margin-bottom"]||0,v["page-break-before"]==="always"&&(this.pdf.addPage(),this.y=0,G=((v["margin-top"]||0)+(v["padding-top"]||0))*R),A=this.pdf.internal.write,j=void 0,P=void 0,this.y+=G,A("q","BT 0 g",this.pdf.internal.getCoordinateString(this.x),this.pdf.internal.getVerticalCoordinateString(this.y),"Td");for(var N=0;S.length;){for(I=S.shift(),H=0,j=0,P=I.length;j!==P;)I[j][0].trim()&&(H=Math.max(H,I[j][1]["line-height"],I[j][1]["font-size"]),q=I[j][1]["font-size"]*7),j++;var W=0,Y=0;I[0][1]["margin-left"]!==void 0&&I[0][1]["margin-left"]>0&&(Y=this.pdf.internal.getCoordinateString(I[0][1]["margin-left"]),W=Y-N,N=Y);var et=Math.max(v["margin-left"]||0,0)*R;for(A(W+et,(-1*d*H).toFixed(2),"Td"),j=0,P=I.length;j!==P;)I[j][0]&&this.RenderTextFragment(I[j][0],I[j][1]),j++;if(this.y+=H*R,this.executeWatchFunctions(I[0][1])&&S.length>0){var it=[],ht=[];S.forEach(function(ct){for(var dt=0,V=ct.length;dt!==V;)ct[dt][0]&&(it.push(ct[dt][0]+" "),ht.push(ct[dt][1])),++dt}),S=this.splitFragmentsIntoLines(u(it),ht),A("ET","Q"),A("q","BT 0 g",this.pdf.internal.getCoordinateString(this.x),this.pdf.internal.getVerticalCoordinateString(this.y),"Td")}}return C&&typeof C=="function"&&C.call(this,this.x-9,this.y-q/2),A("ET","Q"),this.y+=O}},g.prototype.setBlockBoundary=function(C){return this.renderParagraph(C)},g.prototype.setBlockStyle=function(C){return this.paragraph.blockstyle=C},g.prototype.addText=function(C,v){return this.paragraph.text.push(C),this.paragraph.style.push(v)},s={helvetica:"helvetica","sans-serif":"helvetica","times new roman":"times",serif:"times",times:"times",monospace:"courier",courier:"courier"},r={100:"normal",200:"normal",300:"normal",400:"normal",500:"bold",600:"bold",700:"bold",800:"bold",900:"bold",normal:"normal",bold:"bold",bolder:"bold",lighter:"normal"},i={normal:"normal",italic:"italic",oblique:"italic"},n={left:"left",right:"right",center:"center",justify:"justify"},l={none:"none",right:"right",left:"left"},a={none:"none",both:"both"},M={normal:1},m.fromHTML=function(C,v,d,R,x,j){return this.margins_doc=j||{top:0,bottom:0},R||(R={}),R.elementHandlers||(R.elementHandlers={}),X(this,C,isNaN(v)?4:v,isNaN(d)?4:d,R,x)}})(Ot.jsPDF.API);class Ct{constructor(t){var e,s;this._fontSize=6,this._base64Normal=void 0,this._base64Bold=void 0,typeof t.orientation>"u"?typeof t.format>"u"||t.format[0]<t.format[1]?this._orientation="p":this._orientation="l":this._orientation=t.orientation,this._format=t.format||"a4",Array.isArray(this._format)&&(this._format=this._format.map(i=>i*Ct.MM_TO_PT)),t.fontName?this._fontName=t.fontName:!Ct.SEGOE_BOLD&&!Ct.SEGOE_NORMAL?this._fontName="helvetica":this._fontName="segoe",typeof t.fontName<"u"&&(typeof t.base64Normal<"u"||typeof t.base64Bold<"u")?(this._base64Normal=t.base64Normal||t.base64Bold,this._base64Bold=t.base64Bold||t.base64Normal):this.fontName==="segoe"&&(this._base64Normal=Ct.SEGOE_NORMAL,this._base64Bold=Ct.SEGOE_BOLD),this._margins=o.clone(t.margins),this._htmlRenderAs=t.htmlRenderAs||"auto",this._matrixRenderAs=t.matrixRenderAs||"auto",this._readonlyRenderAs=t.readonlyRenderAs||"auto",this._compress=t.compress||!1,this._applyImageFit=t.applyImageFit||!1,this._useLegacyBooleanRendering=t.useLegacyBooleanRendering||!1,this._isRTL=t.isRTL||!1,this._tagboxSelectedChoicesOnly=t.tagboxSelectedChoicesOnly||!1,this._htmlToImageQuality=(e=t.htmlToImageQuality)!==null&&e!==void 0?e:1,this._otherRowsCount=(s=t.otherRowsCount)!==null&&s!==void 0?s:2,this._dynamicContent=o.mergeObjects({choiceComments:!1,choiceNestedContent:!1,conditionalChoices:!1,conditionalElements:!1,conditionalMatrixColumns:!1,conditionalMatrixRows:!1},t.dynamicContent||{})}get leftTopPoint(){return{xLeft:this.margins.left,yTop:this.margins.top}}get fontSize(){return this._fontSize}get fontName(){return this._fontName}get base64Normal(){return this._base64Normal}get base64Bold(){return this._base64Bold}get useCustomFontInHtml(){return this._useCustomFontInHtml}get margins(){return this._margins}get format(){return this._format}get orientation(){return this._orientation}get htmlRenderAs(){return this._htmlRenderAs}get matrixRenderAs(){return this._matrixRenderAs}get readonlyRenderAs(){return this._readonlyRenderAs}get compress(){return this._compress}get applyImageFit(){return this._applyImageFit}get useLegacyBooleanRendering(){return this._useLegacyBooleanRendering}get isRTL(){return this._isRTL}get tagboxSelectedChoicesOnly(){return this._tagboxSelectedChoicesOnly}get htmlToImageQuality(){return this._htmlToImageQuality}get otherRowsCount(){return this._otherRowsCount}get dynamicContent(){return this._dynamicContent}}Ct.MM_TO_PT=72/25.4;class xt extends Ct{constructor(t={}){super(t),this.drawColorRestoreCallbacks=[],this.fillColorRestoreCallbacks=[],this.textColorRestoreCallbacks=[],this.textStyleRestoreCallbacks=[];const e={orientation:this.orientation,unit:"pt",format:this.format,compress:this.compress};this._doc=new Ot.jsPDF(e),typeof this.base64Normal<"u"&&!o.isFontExist(this,this.fontName)&&(xt.addFont(this.fontName,this.base64Normal,"normal"),xt.addFont(this.fontName,this.base64Bold,"bold"),this._doc=new Ot.jsPDF(e)),this._useCustomFontInHtml=t.useCustomFontInHtml&&o.isFontExist(this,this.fontName),this._helperDoc=new Ot.jsPDF(e),this._doc.setFont("helvetica"),this._helperDoc.setFont("helvetica"),this._doc.setFontSize(6),this._helperDoc.setFontSize(6),this._fontStyle="normal",this.marginsStack=[]}static addFont(t,e,s){let i=xt.customFonts[t];i||(i={},xt.customFonts[t]=i),i[s]=e;const n=function(){const r=xt.customFonts[t];if(r&&r[s]){const l=`${t}-${s}.ttf`;this.addFileToVFS(l,r[s]),this.addFont(l,t,s)}};Ot.jsPDF.API.events.push(["addFonts",n])}get doc(){return this._doc}get helperDoc(){return this._helperDoc}get fontName(){return this._fontName}set fontName(t){this._fontName=t,this._doc.setFont(t),this._helperDoc.setFont(t)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize=t,this._doc.setFontSize(t),this._helperDoc.setFontSize(t)}get lineHeightFactor(){return this._lineHeightFactor}set lineHeightFactor(t){this._lineHeightFactor=t,this._doc.setLineHeightFactor(t),this._helperDoc.setLineHeightFactor(t)}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle=t,this._doc.setFont(this._fontName,t),this._helperDoc.setFont(this._fontName,t)}measureText(t=1,e){this.setTextStyle(e,!0);const s=this._helperDoc.getLineHeight()/this._helperDoc.internal.scaleFactor;let i=0;return typeof t=="number"?i=s*t:(t=typeof t=="string"?t:o.getLocString(t),i=t.split("").reduce((n,r)=>n+this._helperDoc.getTextWidth(r),0)),this.restoreTextStyle(!0),{width:i,height:s}}get unitWidth(){return this.measureText().width}get unitHeight(){return this.measureText().height}pushMargins(t,e){this.marginsStack.push({left:this.margins.left,right:this.margins.right}),typeof t<"u"&&(this.margins.left=t),typeof e<"u"&&(this.margins.right=e)}popMargins(){const t=this.marginsStack.pop();this.margins.left=t.left,this.margins.right=t.right}get paperWidth(){return this.doc.internal.pageSize.width}get paperHeight(){return this.doc.internal.pageSize.height}getNumberOfPages(){return this.doc.getNumberOfPages()}addPage(){this.doc.addPage()}getCurrentPageIndex(){return this.doc.getCurrentPageInfo().pageNumber-1}setPage(t){this.doc.setPage(t+1)}setColor(t,e,s,i="opacity"){const{doc:n}=this,r=e(),{color:l,opacity:a}=o.parseColor(t);s(l);let h=!1;return a!==void 0&&(n.saveGraphicsState(),n.setGState(new n.GState({[i]:a})),h=!0),()=>{s(r),h&&this.doc.restoreGraphicsState()}}setDrawColor(t){this.drawColorRestoreCallbacks.push(this.setColor(t,()=>this.doc.getDrawColor(),e=>this.doc.setDrawColor(e),"stroke-opacity"))}restoreDrawColor(){this.drawColorRestoreCallbacks.length>0&&this.drawColorRestoreCallbacks.pop()()}setFillColor(t){this.fillColorRestoreCallbacks.push(this.setColor(t,()=>this.doc.getFillColor(),e=>this.doc.setFillColor(e)))}restoreFillColor(){this.fillColorRestoreCallbacks.length>0&&this.fillColorRestoreCallbacks.pop()()}setTextColor(t){this.textColorRestoreCallbacks.push(this.setColor(t,()=>this.doc.getTextColor(),e=>this.doc.setTextColor(e)))}restoreTextColor(){this.textColorRestoreCallbacks.length>0&&this.textColorRestoreCallbacks.pop()()}setTextStyle(t,e=!1){var s,i,n,r;const l=e?this.helperDoc:this.doc,a=l.getFontSize(),h=l.getFont(),u=l.getLineHeightFactor(),g=(s=t?.fontSize)!==null&&s!==void 0?s:a,b=t?.fontColor&&!e;l.setFont((i=t?.fontName)!==null&&i!==void 0?i:h.fontName,(n=t?.fontStyle)!==null&&n!==void 0?n:h.fontStyle),l.setFontSize(g),l.setLineHeightFactor(((r=t?.lineHeight)!==null&&r!==void 0?r:g)/g),b&&this.setTextColor(t.fontColor),this.textStyleRestoreCallbacks.push({isHelper:e,callback:()=>{l.setFont(h.fontName,h.fontStyle),l.setFontSize(a),l.setLineHeightFactor(u),b&&this.restoreTextColor()}})}restoreTextStyle(t=!1){const e=this.textStyleRestoreCallbacks.length-1-this.textStyleRestoreCallbacks.slice().reverse().findIndex(s=>s.isHelper===t);e<this.textStyleRestoreCallbacks.length&&this.textStyleRestoreCallbacks.splice(e,1)[0].callback()}get AcroFormCheckBox(){return this._AcroFormCheckBox||(this._AcroFormCheckBox=ps(this.doc)),this._AcroFormCheckBox}get AcroFormComboBox(){return this._AcroFormComboBox||(this._AcroFormComboBox=gs(this.doc)),this._AcroFormComboBox}get AcroFormTextField(){return this._AcroFormTextField||(this._AcroFormTextField=ds(this.doc)),this._AcroFormTextField}get AcroFormRadioButton(){return this._AcroFormRadioButton||(this._AcroFormRadioButton=fs(this.doc)),this._AcroFormRadioButton}}xt.customFonts={};class zt{static findBotInterval(t,e,s,i){const n=t.search(e,s);return n.push({pageIndex:0,xLeft:i.margins.left,xRight:i.margins.left,yBot:i.margins.top,absBot:i.margins.top}),n.reduce((r,l)=>Math.abs(l.xRight-e)<o.EPSILON||Math.abs(l.xLeft-s)<o.EPSILON||l.pageIndex<r.pageIndex?r:l.pageIndex>r.pageIndex||l.yBot>r.yBot?l:r,n[n.length-1])}static addPack(t,e,s){for(let i=t.length;i<=e;i++)t.push([]);t[e].push(s)}static pack(t,e){const s=e.paperHeight-e.margins.top-e.margins.bot,i=[];t.forEach(a=>{i.push([]),a.forEach(h=>{h.height>s+o.EPSILON?i[i.length-1].push(...h.unfold()):i[i.length-1].push(h)})}),i.forEach(a=>{a.sort((h,u)=>h.yTop<u.yTop?-1:h.yTop>u.yTop||h.xLeft>u.xLeft?1:h.xLeft<u.xLeft?-1:0)});let n=0;const r=[],l=e.paperHeight-e.margins.bot;return i.forEach(a=>{const h=new ns;let u=0;a.forEach(g=>{let{pageIndex:b,yBot:T,absBot:M}=zt.findBotInterval(h,g.xLeft,g.xRight,e);const Z=g.height;g.yTop=T+g.yTop-M,(Math.abs(g.yTop-e.margins.top)>o.EPSILON&&g.yTop+Z>l+o.EPSILON||g.isPageBreak)&&(g.yTop=e.margins.top,b++,u=Math.max(u,b)),h.insert(g.xLeft,g.xRight,{pageIndex:b,xLeft:g.xLeft,xRight:g.xRight,yBot:g.yTop+Z,absBot:g.yBot}),g.yBot=g.yTop+Z,zt.addPack(r,n+b,g)}),n+=u+1}),r}}B.HorizontalAlign=void 0,(function(m){m.NotSet="notset",m.Left="left",m.Center="center",m.Right="right"})(B.HorizontalAlign||(B.HorizontalAlign={})),B.VerticalAlign=void 0,(function(m){m.NotSet="notset",m.Top="top",m.Middle="middle",m.Bottom="bottom"})(B.VerticalAlign||(B.VerticalAlign={}));class ae{constructor(t,e,s,i,n){this.packs=t,this.controller=e,this._rect=s,this._countPages=i,this._pageNumber=n}get pageCount(){return this._countPages}get countPages(){return this._countPages}get pageNumber(){return this._pageNumber}get rect(){return this._rect}alignRect(t,e){typeof t.margins>"u"?t.margins={left:0,right:0,top:0,bot:0}:(typeof t.margins.left>"u"&&(t.margins.left=0),typeof t.margins.right>"u"&&(t.margins.right=0),typeof t.margins.top>"u"&&(t.margins.top=0),typeof t.margins.bot>"u"&&(t.margins.bot=0)),typeof t.rect>"u"&&((typeof t.horizontalAlign>"u"||t.horizontalAlign===B.HorizontalAlign.NotSet)&&(t.horizontalAlign=B.HorizontalAlign.Center),(typeof t.verticalAlign>"u"||t.verticalAlign===B.VerticalAlign.NotSet)&&(t.verticalAlign=B.VerticalAlign.Middle));const s=o.clone(this.rect);if(typeof t.horizontalAlign<"u")switch(t.horizontalAlign){case B.HorizontalAlign.Left:s.xLeft=this.rect.xLeft+t.margins.left,s.xRight=Math.min(this.rect.xRight-t.margins.right,this.rect.xLeft+t.margins.left+e.width);break;case B.HorizontalAlign.Center:s.xLeft=Math.max(this.rect.xLeft+t.margins.left,(this.rect.xLeft+this.rect.xRight-e.width)/2),s.xRight=Math.min(this.rect.xRight-t.margins.right,(this.rect.xLeft+this.rect.xRight+e.width)/2);break;case B.HorizontalAlign.Right:s.xLeft=Math.max(this.rect.xLeft+t.margins.left,this.rect.xRight-t.margins.right-e.width),s.xRight=this.rect.xRight-t.margins.right;break}else s.xLeft=t.rect.xLeft||this.rect.xLeft,s.xRight=t.rect.xRight||this.rect.xRight;if(typeof t.verticalAlign<"u")switch(t.verticalAlign){case B.VerticalAlign.Top:s.yTop=this.rect.yTop+t.margins.top,s.yBot=Math.min(this.rect.yBot-t.margins.bot,this.rect.yTop+t.margins.top+e.height);break;case B.VerticalAlign.Middle:s.yTop=Math.max(this.rect.yTop+t.margins.top,(this.rect.yTop+this.rect.yBot-e.height)/2),s.yBot=Math.min(this.rect.yBot-t.margins.bot,(this.rect.yTop+this.rect.yBot+e.height)/2);break;case B.VerticalAlign.Bottom:s.yTop=Math.max(this.rect.yTop+t.margins.top,this.rect.yBot-t.margins.bot-e.height),s.yBot=this.rect.yBot-t.margins.bot;break}else s.yTop=t.rect.yTop||this.rect.yTop,s.yBot=t.rect.yBot||this.rect.yBot;return s}drawText(t){t=o.clone(t),typeof t.isBold>"u"&&(t.isBold=!1);const e=o.getPatchedTextStyle(this.controller,{fontStyle:t.isBold?"bold":"normal",fontSize:t.fontSize,fontName:this.controller.fontName,fontColor:"#404040"}),s=this.controller.measureText(t.text,e),i=this.alignRect(t,s);this.packs.push(new Dt(this.controller,i,t,e))}async drawImage(t){t=o.clone(t),typeof t.width>"u"&&(t.width=this.rect.xRight-this.rect.xLeft),typeof t.height>"u"&&(t.height=this.rect.yBot-this.rect.yTop);const e={width:t.width,height:t.height},s=this.alignRect(t,e);this.controller.pushMargins(0,0),this.packs.push(await o.createImageFlat(o.createPoint(s,!0,!0),null,this.controller,{link:t.base64,width:s.xRight-s.xLeft,height:s.yBot-s.yTop,objectFit:t.imageFit},!!t.imageFit||this.controller.applyImageFit)),this.controller.popMargins()}}class ys{constructor(t,e,s){this.survey=t,this.controller=e,this.style=s}getTextStyle(){return this.style.text}getLinkStyle(){var t;return o.mergeObjects({},this.getTextStyle(),(t=this.style.link)!==null&&t!==void 0?t:{})}getLicenseParts(t){const e=/\[([^\]]+)\]\(([^)]+)\)|([^\[]+)/g,s=[];let i;for(;(i=e.exec(t))!==null;)i[1]&&i[2]?s.push({text:i[1],isLink:!0,url:i[2]}):i[3]&&s.push({text:i[3]});return s}splitPartsToFit(t,e){const s=[];let i=[],n=0;for(const r of t){const a=r.text.split(/(\s+)/);for(const h of a){if(h==="")continue;const u=this.controller.measureText(h,this.getTextStyle()).width;n+u>e&&i.length>0&&(s.push(i),i=[],n=0),i.push({...r,text:h}),n+=u}}return i.length>0&&s.push(i),s.map(r=>{let l;const a=[];for(const h of r)!l||!(l.isLink===h.isLink&&(!l.isLink||h.isLink&&l.url===h.url))?(l=h,a.push(h)):l.text+=h.text;return a[a.length-1].text=a[a.length-1].text.trimEnd(),a})}generateLicenseFlats(t,e,s){const i=new E,n=o.clone(t);for(const r of e){const l=new E;for(const a of r){const h=this.controller.measureText(a.text,this.getTextStyle());let u;a.isLink?u=new _t(this.controller,o.createRect(n,h.width,h.height),{text:a.text,link:a.url,readOnlyShowLink:!1},this.getLinkStyle()):u=new Dt(this.controller,o.createRect(n,h.width,h.height),{text:a.text},this.getTextStyle()),l.addBrick(u),n.xLeft+=h.width}this.centerLineBrick(l,t.xLeft,s+t.xLeft),i.addBrick(l),n.yTop+=l.height}return[i]}centerLineBrick(t,e,s){const i=(s+e-t.xRight-t.xLeft)/2;t.translateX((n,r)=>({xLeft:n+i,xRight:r+i}))}generateFlats(t){if(this.survey.haveCommercialLicense)return[];const e=this.survey.licenseText,s=o.getPageAvailableWidth(this.controller),i=this.getLicenseParts(e),n=this.splitPartsToFit(i,s);return this.generateLicenseFlats(t,n,s)}}let Ce;function ms(m){Ce=m}function Pe(){return Ce()}function Qt(m,t,e){const s=Pe(),i=Pe();s.setup(m.cssVariables),i.setup(t),s.startCollectingVariables(),i.startCollectingVariables();const n=e({getColorVariable:r=>s.getColorVariable(r),getSizeVariable:r=>i.getSizeVariable(r)});return s.stopCollectingVariables(),i.stopCollectingVariables(),n}function xs(m,t){return Qt(m,t,({getSizeVariable:e,getColorVariable:s})=>{const i=e("--sjs2-base-unit-size"),n=e("--sjs2-base-unit-font-size"),r=e("--sjs2-base-unit-spacing");return{survey:{title:{fontSize:e("--sjs2-typography-font-size-large"),lineHeight:e("--sjs2-typography-line-height-large"),fontStyle:"bold",fontColor:s("--sjs2-color-fg-basic-primary")},description:{fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default"),fontStyle:"normal",fontColor:s("--sjs2-color-fg-basic-secondary")},spacing:{titleDescriptionGap:e("--sjs2-pdf-layout-title-large-gap"),pageGap:r*3,headerContentGap:e("--sjs2-pdf-layout-page-gap-vertical")+e("--sjs2-pdf-layout-title-large-padding-bottom")},backgroundColor:s("--sjs2-color-utility-body"),padding:[e("--sjs2-pdf-layout-page-padding-top"),e("--sjs2-pdf-layout-page-padding-right"),e("--sjs2-pdf-layout-page-padding-bottom"),e("--sjs2-pdf-layout-page-padding-left")]},question:{minWidth:i*25,inlineHeaderWidthPercentage:Math.E/10,container:{padding:[e("--sjs2-pdf-layout-question-padding-vertical"),e("--sjs2-pdf-layout-question-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-question"),borderWidth:e("--sjs2-pdf-border-width-question"),borderColor:s("--sjs2-color-border-basic-secondary"),backgroundColor:s("--sjs2-color-bg-basic-primary")},title:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-small"),lineHeight:e("--sjs2-typography-line-height-small"),fontStyle:"normal"},description:{fontColor:s("--sjs2-color-fg-basic-secondary"),fontSize:e("--sjs2-typography-font-size-small"),fontStyle:"normal",lineHeight:e("--sjs2-typography-line-height-small")},comment:{fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default"),fontColor:s("--sjs2-color-component-input-default-value"),backgroundColor:s("--sjs2-color-component-formbox-default-bg")},commentReadOnly:{backgroundColor:null,fontColor:s("--sjs2-color-fg-basic-primary")},input:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default")},commentLabel:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),fontStyle:"normal",lineHeight:e("--sjs2-typography-line-height-default")},spacing:{headerContentGap:e("--sjs2-pdf-layout-question-gap"),inlineHeaderContentGap:r,contentIndentStart:0,contentCommentGap:e("--sjs2-pdf-layout-question-gap"),contentDescriptionGap:e("--sjs2-pdf-layout-question-gap"),titleDescriptionGap:e("--sjs2-pdf-layout-question-labels-gap-vertical"),titleRequiredMarkGap:n/2,titleNumberGap:n/2,commentLabelGap:e("--sjs2-spacing-x050")}},panel:{minWidth:i*75,header:{padding:[e("--sjs2-pdf-layout-section-padding-vertical"),e("--sjs2-pdf-layout-section-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-section"),backgroundColor:s("--sjs2-color-bg-basic-secondary"),borderWidth:e("--sjs2-pdf-border-width-section"),borderColor:s("--sjs2-color-border-basic-secondary")},title:{fontSize:e("--sjs2-typography-font-size-default"),fontColor:s("--sjs2-color-fg-basic-primary"),fontStyle:"bold",lineHeight:e("--sjs2-typography-line-height-default")},description:{fontColor:s("--sjs2-color-fg-basic-secondary"),fontSize:e("--sjs2-typography-font-size-small"),lineHeight:e("--sjs2-typography-line-height-small")},spacing:{elementGap:e("--sjs2-pdf-layout-page-questions-gap-vertical"),inlineElementGap:e("--sjs2-pdf-layout-page-questions-gap-horizontal"),headerContentGap:e("--sjs2-pdf-layout-page-questions-gap-vertical"),titleDescriptionGap:e("--sjs2-pdf-layout-title-default-gap")}},page:{header:{borderWidth:0,padding:0,backgroundColor:null},title:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-medium"),fontStyle:"bold",lineHeight:e("--sjs2-typography-line-height-medium")},description:{fontColor:s("--sjs2-color-fg-basic-secondary"),fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default")},spacing:{headerContentGap:e("--sjs2-pdf-layout-page-gap-vertical")+e("--sjs2-pdf-layout-title-medium-padding-bottom"),elementGap:e("--sjs2-pdf-layout-page-gap-vertical")}},selectbase:{columnMinWidth:i*20,choiceText:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),fontStyle:"normal",lineHeight:e("--sjs2-typography-line-height-default")},input:{width:e("--sjs2-size-x200"),height:e("--sjs2-size-x200"),fontSize:e("--sjs2-size-x200")*.625,borderColor:s("--sjs2-color-component-checkbox-false-default-border"),borderWidth:e("--sjs2-pdf-border-width-check"),fontName:"zapfdingbats",backgroundColor:s("--sjs2-color-bg-basic-primary"),fontColor:s("--sjs2-color-fg-brand-primary")},inputReadOnly:{fontColor:s("--sjs2-color-component-checkbox-true-default-icon"),backgroundColor:s("--sjs2-color-component-checkbox-false-default-bg")},inputReadOnlyChecked:{borderColor:s("--sjs2-color-component-checkbox-true-default-border"),backgroundColor:s("--sjs2-color-component-checkbox-true-default-bg")},spacing:{choiceColumnGap:e("--sjs2-pdf-layout-question-items-gap-horizontal"),choiceGap:e("--sjs2-pdf-layout-question-items-gap-vertical"),choiceTextGap:e("--sjs2-pdf-layout-check-gap")}},checkbox:{input:{checkMark:"3"},inputReadOnly:{borderRadius:e("--sjs2-pdf-radius-checkbox")}},radiogroup:{input:{checkMark:"l",borderColor:s("--sjs2-color-component-radio-false-default-border")},inputReadOnly:{borderRadius:e("--sjs2-pdf-radius-radio"),fontColor:s("--sjs2-color-component-radio-true-default-icon"),backgroundColor:s("--sjs2-color-component-radio-false-default-bg")},inputReadOnlyChecked:{borderColor:s("--sjs2-color-component-radio-true-default-border"),backgroundColor:s("--sjs2-color-component-radio-true-default-bg")}},matrixbase:{minWidth:i*40,columnMinWidth:i*15,container:{padding:0,borderWidth:0,backgroundColor:null},header:{padding:[e("--sjs2-pdf-layout-section-padding-vertical"),e("--sjs2-pdf-layout-section-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-section"),backgroundColor:s("--sjs2-color-bg-basic-secondary"),borderWidth:e("--sjs2-pdf-border-width-section"),borderColor:s("--sjs2-color-border-basic-secondary")},title:{fontSize:e("--sjs2-typography-font-size-default"),fontColor:s("--sjs2-color-fg-basic-primary"),fontStyle:"bold",lineHeight:e("--sjs2-typography-line-height-default")},description:{fontColor:s("--sjs2-color-fg-basic-secondary"),fontSize:e("--sjs2-typography-font-size-small"),lineHeight:e("--sjs2-typography-line-height-small")},cell:{padding:[e("--sjs2-pdf-layout-question-padding-vertical"),e("--sjs2-pdf-layout-question-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-matrix"),borderWidth:e("--sjs2-pdf-border-width-question"),borderColor:s("--sjs2-color-border-basic-secondary"),backgroundColor:s("--sjs2-color-bg-basic-primary")},rowTitle:{fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default"),fontColor:s("--sjs2-color-fg-basic-secondary"),fontStyle:"normal",textAlign:"right"},columnTitle:{fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default"),fontColor:s("--sjs2-color-fg-basic-secondary"),fontStyle:"normal"},listSectionTitle:{textAlign:"left"},spacing:{titleDescriptionGap:e("--sjs2-pdf-layout-title-default-gap"),headerContentGap:e("--sjs2-pdf-layout-page-questions-gap-vertical"),tableColumnGap:e("--sjs2-pdf-layout-page-matrix-gap-horizontal"),tableRowGap:e("--sjs2-pdf-layout-page-matrix-gap-vertical"),listSectionGap:e("--sjs2-pdf-layout-page-questions-gap-vertical"),listItemTitleContentGap:e("--sjs2-pdf-layout-question-gap")}},matrix:{columnMinWidth:i*12,listChoiceText:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),fontStyle:"normal",lineHeight:e("--sjs2-typography-line-height-default")},listSectionTitle:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-small"),lineHeight:e("--sjs2-typography-line-height-small"),fontStyle:"normal"},input:{width:e("--sjs2-size-x200"),height:e("--sjs2-size-x200"),fontSize:e("--sjs2-size-x200")*.625,borderColor:s("--sjs2-color-component-checkbox-false-default-border"),borderWidth:e("--sjs2-pdf-border-width-check"),backgroundColor:s("--sjs2-color-bg-basic-primary"),fontColor:s("--sjs2-color-fg-brand-primary"),fontName:"zapfdingbats"},inputReadOnly:{fontColor:s("--sjs2-color-component-checkbox-true-default-icon"),backgroundColor:s("--sjs2-color-component-checkbox-false-default-bg")},inputReadOnlyChecked:{borderColor:s("--sjs2-color-component-checkbox-true-default-border"),backgroundColor:s("--sjs2-color-component-checkbox-true-default-bg")},radioInput:{checkMark:"l",borderColor:s("--sjs2-color-component-radio-false-default-border")},radioInputReadOnly:{borderRadius:e("--sjs2-pdf-radius-radio"),fontColor:s("--sjs2-color-component-radio-true-default-icon"),backgroundColor:s("--sjs2-color-component-radio-false-default-bg")},radioInputReadOnlyChecked:{borderColor:s("--sjs2-color-component-radio-true-default-border"),backgroundColor:s("--sjs2-color-component-radio-true-default-bg")},checkboxInput:{checkMark:"3"},checkboxInputReadOnly:{borderRadius:e("--sjs2-pdf-radius-checkbox")},spacing:{gapBetweenItemText:e("--sjs2-pdf-layout-check-gap"),listChoiceGap:e("--sjs2-pdf-layout-question-items-gap-vertical"),listChoiceTextGap:e("--sjs2-pdf-layout-check-gap")}},matrixdropdownbase:{listItemTitle:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-small"),lineHeight:e("--sjs2-typography-line-height-small"),fontStyle:"normal"}},matrixdropdown:{listSectionTitleContainer:{padding:[e("--sjs2-pdf-layout-section-padding-vertical"),e("--sjs2-pdf-layout-section-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-section"),backgroundColor:s("--sjs2-color-bg-basic-secondary"),borderWidth:e("--sjs2-pdf-border-width-section"),borderColor:s("--sjs2-color-border-basic-secondary")},listSectionTitle:{fontSize:e("--sjs2-typography-font-size-default"),fontColor:s("--sjs2-color-fg-basic-primary"),fontStyle:"bold",lineHeight:e("--sjs2-typography-line-height-default")}},multipletext:{itemTitleWidthPercentage:.4,container:{padding:0,borderWidth:0,backgroundColor:null},header:{padding:[e("--sjs2-pdf-layout-section-padding-vertical"),e("--sjs2-pdf-layout-section-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-section"),backgroundColor:s("--sjs2-color-bg-basic-secondary"),borderWidth:e("--sjs2-pdf-border-width-section"),borderColor:s("--sjs2-color-border-basic-secondary")},title:{fontSize:e("--sjs2-typography-font-size-default"),fontColor:s("--sjs2-color-fg-basic-primary"),fontStyle:"bold",lineHeight:e("--sjs2-typography-line-height-default")},description:{fontColor:s("--sjs2-color-fg-basic-secondary"),fontSize:e("--sjs2-typography-font-size-small"),lineHeight:e("--sjs2-typography-line-height-small")},itemTitle:{fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default"),fontColor:s("--sjs2-color-fg-basic-secondary"),fontStyle:"normal"},itemCell:{padding:[e("--sjs2-pdf-layout-question-padding-vertical"),e("--sjs2-pdf-layout-question-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-matrix"),borderWidth:e("--sjs2-pdf-border-width-question"),borderColor:s("--sjs2-color-border-basic-secondary"),backgroundColor:s("--sjs2-color-bg-basic-primary")},spacing:{titleDescriptionGap:e("--sjs2-pdf-layout-title-default-gap"),headerContentGap:e("--sjs2-pdf-layout-page-questions-gap-vertical"),itemColumnGap:e("--sjs2-pdf-layout-page-matrix-gap-horizontal"),itemGap:e("--sjs2-pdf-layout-page-matrix-gap-vertical"),itemTitleGap:e("--sjs2-pdf-layout-page-matrix-gap-horizontal")}},rating:{choiceMinWidth:e("--sjs2-size-x300"),choiceText:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),fontStyle:"normal",lineHeight:e("--sjs2-typography-line-height-default")},input:{width:e("--sjs2-size-x200"),height:e("--sjs2-size-x200"),fontSize:e("--sjs2-size-x200")*.625,borderColor:s("--sjs2-color-component-radio-false-default-border"),borderWidth:e("--sjs2-pdf-border-width-check"),backgroundColor:s("--sjs2-color-bg-basic-primary"),fontColor:s("--sjs2-color-fg-brand-primary"),fontName:"zapfdingbats",checkMark:"l"},inputReadOnly:{fontColor:s("--sjs2-color-component-radio-true-default-icon"),backgroundColor:s("--sjs2-color-component-radio-false-default-bg"),borderRadius:e("--sjs2-pdf-radius-checkbox")},inputReadOnlyChecked:{borderColor:s("--sjs2-color-component-radio-true-default-border"),backgroundColor:s("--sjs2-color-component-radio-true-default-bg")},spacing:{choiceColumnGap:e("--sjs2-pdf-layout-question-items-gap-horizontal"),choiceGap:e("--sjs2-pdf-layout-question-items-gap-vertical"),choiceTextGap:e("--sjs2-pdf-layout-check-gap")}},ranking:{input:{width:e("--sjs2-size-x200"),height:e("--sjs2-size-x200"),fontSize:e("--sjs2-size-x200")*.625,lineHeight:e("--sjs2-size-x200")*.625,borderColor:s("--sjs2-color-component-checkbox-false-default-border"),borderWidth:e("--sjs2-pdf-border-width-check"),fontName:"helvetica",fontStyle:"normal",fontColor:s("--sjs2-color-fg-basic-primary"),backgroundColor:s("--sjs2-color-component-checkbox-false-default-bg")},selectToRankAreaSeparator:{width:i/7,color:s("--sjs2-color-fg-basic-primary")},choiceText:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),fontStyle:"normal",lineHeight:e("--sjs2-typography-line-height-default")},spacing:{choiceColumnGap:e("--sjs2-pdf-layout-question-items-gap-horizontal"),choiceGap:e("--sjs2-pdf-layout-question-items-gap-vertical"),choiceTextGap:e("--sjs2-pdf-layout-check-gap")}},slider:{input:{fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default"),backgroundColor:s("--sjs2-color-component-formbox-default-bg"),fontColor:s("--sjs2-color-component-input-default-value")},inputReadOnly:{backgroundColor:null,fontColor:s("--sjs2-color-fg-basic-primary")},rangeSeparator:{width:i*3,height:i*.125,color:s("--sjs2-color-fg-basic-primary")},spacing:{inputRangeGap:r*8}},dropdown:{input:{borderWidth:0,fontName:void 0,fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default"),fontColor:s("--sjs2-color-component-input-default-value"),backgroundColor:s("--sjs2-color-component-formbox-default-bg")},inputReadOnly:{backgroundColor:null,fontColor:s("--sjs2-color-fg-basic-primary")}},file:{fileItemMinWidth:e("--sjs2-size-x500"),defaultImageFit:"contain",fileName:{fontColor:s("--sjs2-color-fg-note-primary"),fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default")},spacing:{imageFileNameGap:e("--sjs2-pdf-layout-question-items-gap-vertical"),fileItemColumnGap:e("--sjs2-pdf-layout-question-items-gap-horizontal"),fileItemGap:e("--sjs2-pdf-layout-question-items-gap-vertical")}},paneldynamic:{container:{padding:0,borderWidth:0,backgroundColor:null},header:{padding:[e("--sjs2-pdf-layout-section-padding-vertical"),e("--sjs2-pdf-layout-section-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-section"),backgroundColor:s("--sjs2-color-bg-basic-secondary"),borderWidth:e("--sjs2-pdf-border-width-section"),borderColor:s("--sjs2-color-border-basic-secondary")},title:{fontSize:e("--sjs2-typography-font-size-default"),fontColor:s("--sjs2-color-fg-basic-primary"),fontStyle:"bold",lineHeight:e("--sjs2-typography-line-height-default")},description:{fontColor:s("--sjs2-color-fg-basic-secondary"),fontSize:e("--sjs2-typography-font-size-small"),lineHeight:e("--sjs2-typography-line-height-small")},spacing:{headerContentGap:e("--sjs2-pdf-layout-page-questions-gap-vertical"),titleDescriptionGap:e("--sjs2-pdf-layout-title-default-gap"),panelGap:e("--sjs2-pdf-layout-page-questions-gap-vertical")}},boolean:{choiceText:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),fontStyle:"normal",lineHeight:e("--sjs2-typography-line-height-default")},input:{width:e("--sjs2-size-x200"),height:e("--sjs2-size-x200"),fontSize:e("--sjs2-size-x200")*.625,borderColor:s("--sjs2-color-component-checkbox-false-default-border"),borderWidth:e("--sjs2-pdf-border-width-check"),backgroundColor:s("--sjs2-color-bg-basic-primary"),fontColor:s("--sjs2-color-fg-brand-primary"),fontName:"zapfdingbats"},inputReadOnly:{fontColor:s("--sjs2-color-component-checkbox-true-default-icon"),backgroundColor:s("--sjs2-color-component-checkbox-false-default-bg")},inputReadOnlyChecked:{borderColor:s("--sjs2-color-component-checkbox-true-default-border"),backgroundColor:s("--sjs2-color-component-checkbox-true-default-bg")},radioInput:{checkMark:"l",borderColor:s("--sjs2-color-component-radio-false-default-border")},radioInputReadOnly:{borderRadius:e("--sjs2-pdf-radius-radio"),fontColor:s("--sjs2-color-component-radio-true-default-icon"),backgroundColor:s("--sjs2-color-component-radio-false-default-bg")},radioInputReadOnlyChecked:{borderColor:s("--sjs2-color-component-radio-true-default-border"),backgroundColor:s("--sjs2-color-component-radio-true-default-bg")},checkboxInput:{checkMark:"3"},checkboxInputReadOnly:{borderRadius:e("--sjs2-pdf-radius-checkbox")},spacing:{choiceColumnGap:e("--sjs2-pdf-layout-question-items-gap-horizontal"),choiceTextGap:e("--sjs2-pdf-layout-check-gap")}},imagepicker:{imageRatio:4/3,imageMinWidth:i*12.5,imageMaxWidth:i*37.5,inputReadOnly:{borderRadius:e("--sjs2-pdf-radius-checkbox")},radioInput:{checkMark:"l",borderColor:s("--sjs2-color-component-radio-false-default-border")},radioInputReadOnly:{fontColor:s("--sjs2-color-component-radio-true-default-icon"),backgroundColor:s("--sjs2-color-component-radio-false-default-bg")},radioInputReadOnlyChecked:{borderColor:s("--sjs2-color-component-radio-true-default-border"),backgroundColor:s("--sjs2-color-component-radio-true-default-bg")},checkboxInput:{checkMark:"3"},spacing:{imageInputGap:e("--sjs2-pdf-layout-image-picker-items-gap-image-check")}},textbase:{input:{fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default"),backgroundColor:s("--sjs2-color-component-formbox-default-bg"),fontColor:s("--sjs2-color-component-input-default-value")},inputReadOnly:{backgroundColor:null,fontColor:s("--sjs2-color-fg-basic-primary")}},expression:{input:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default")}},html:{text:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default")}},composite:{container:{padding:0,borderWidth:0,backgroundColor:null},header:{padding:[e("--sjs2-pdf-layout-section-padding-vertical"),e("--sjs2-pdf-layout-section-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-section"),backgroundColor:s("--sjs2-color-bg-basic-secondary"),borderWidth:e("--sjs2-pdf-border-width-section"),borderColor:s("--sjs2-color-border-basic-secondary")},title:{fontSize:e("--sjs2-typography-font-size-default"),fontColor:s("--sjs2-color-fg-basic-primary"),fontStyle:"bold",lineHeight:e("--sjs2-typography-line-height-default")},description:{fontColor:s("--sjs2-color-fg-basic-secondary"),fontSize:e("--sjs2-typography-font-size-small"),lineHeight:e("--sjs2-typography-line-height-small")},spacing:{headerContentGap:e("--sjs2-pdf-layout-page-questions-gap-vertical"),titleDescriptionGap:e("--sjs2-pdf-layout-title-default-gap")}}}})}class ke{static async process_header_events(t,e,s){var i;const n=Qt(t.theme,t.layout,r=>({text:{fontSize:10,lineHeight:12,fontStyle:"normal",fontName:"helvetica",fontColor:r.getColorVariable("--sjs2-color-fg-basic-primary")},link:{fontColor:r.getColorVariable("--sjs2-color-fg-note-primary")}}));if(!t.haveCommercialLicense){const r=new ys(t,e,n).generateFlats({xLeft:(i=e.margins.left)!==null&&i!==void 0?i:0,yTop:5});t.onRenderHeader.add((l,a)=>{a.packs.push(...r)})}for(let r=0;r<s.length;r++)await t.onRenderHeader.fire(t,new ae(s[r],e,o.createHeaderRect(e),s.length,r+1)),await t.onRenderFooter.fire(t,new ae(s[r],e,o.createFooterRect(e),s.length,r+1))}}var bs={"--sjs2-base-unit-size":"8px","--sjs2-base-unit-spacing":"8px","--sjs2-base-unit-radius":"8px","--sjs2-base-unit-border-width":"1px","--sjs2-base-unit-font-size":"8px","--sjs2-base-unit-line-height":"8px","--sjs2-base-unit-opacity":"1%","--sjs2-base-unit-scale":"1%","--sjs2-scale-x000":"calc(var(--sjs2-base-unit-scale) * 0)","--sjs2-scale-x025":"calc(var(--sjs2-base-unit-scale) * 25)","--sjs2-scale-x050":"calc(var(--sjs2-base-unit-scale) * 50)","--sjs2-scale-x075":"calc(var(--sjs2-base-unit-scale) * 75)","--sjs2-scale-x095":"calc(var(--sjs2-base-unit-scale) * 95)","--sjs2-scale-x098":"calc(var(--sjs2-base-unit-scale) * 98)","--sjs2-scale-x100":"calc(var(--sjs2-base-unit-scale) * 100)","--sjs2-scale-x200":"calc(var(--sjs2-base-unit-scale) * 200)","--sjs2-size-x000":"calc(var(--sjs2-base-unit-size) * 0)","--sjs2-size-x025":"calc(var(--sjs2-base-unit-size) * 0.25)","--sjs2-size-x050":"calc(var(--sjs2-base-unit-size) * 0.50)","--sjs2-size-x075":"calc(var(--sjs2-base-unit-size) * 0.75)","--sjs2-size-x100":"calc(var(--sjs2-base-unit-size) * 1)","--sjs2-size-x125":"calc(var(--sjs2-base-unit-size) * 1.25)","--sjs2-size-x150":"calc(var(--sjs2-base-unit-size) * 1.50)","--sjs2-size-x200":"calc(var(--sjs2-base-unit-size) * 2)","--sjs2-size-x250":"calc(var(--sjs2-base-unit-size) * 2.50)","--sjs2-size-x300":"calc(var(--sjs2-base-unit-size) * 3)","--sjs2-size-x350":"calc(var(--sjs2-base-unit-size) * 3.50)","--sjs2-size-x400":"calc(var(--sjs2-base-unit-size) * 4)","--sjs2-size-x500":"calc(var(--sjs2-base-unit-size) * 5)","--sjs2-size-x600":"calc(var(--sjs2-base-unit-size) * 6)","--sjs2-size-x700":"calc(var(--sjs2-base-unit-size) * 7)","--sjs2-size-x800":"calc(var(--sjs2-base-unit-size) * 8)","--sjs2-size-x900":"calc(var(--sjs2-base-unit-size) * 9)","--sjs2-size-x1000":"calc(var(--sjs2-base-unit-size) * 10)","--sjs2-size-x1100":"calc(var(--sjs2-base-unit-size) * 11)","--sjs2-size-x1200":"calc(var(--sjs2-base-unit-size) * 12)","--sjs2-size-x1300":"calc(var(--sjs2-base-unit-size) * 13)","--sjs2-size-x1400":"calc(var(--sjs2-base-unit-size) * 14)","--sjs2-size-x1500":"calc(var(--sjs2-base-unit-size) * 15)","--sjs2-radius-x000":"calc(var(--sjs2-base-unit-radius) * 0)","--sjs2-radius-x025":"calc(var(--sjs2-base-unit-radius) * 0.25)","--sjs2-radius-x050":"calc(var(--sjs2-base-unit-radius) * 0.50)","--sjs2-radius-x075":"calc(var(--sjs2-base-unit-radius) * 0.75)","--sjs2-radius-x100":"calc(var(--sjs2-base-unit-radius) * 1)","--sjs2-radius-x125":"calc(var(--sjs2-base-unit-radius) * 1.25)","--sjs2-radius-x150":"calc(var(--sjs2-base-unit-radius) * 1.50)","--sjs2-radius-x200":"calc(var(--sjs2-base-unit-radius) * 2)","--sjs2-radius-x250":"calc(var(--sjs2-base-unit-radius) * 2.50)","--sjs2-radius-x300":"calc(var(--sjs2-base-unit-radius) * 3)","--sjs2-radius-x400":"calc(var(--sjs2-base-unit-radius) * 4)","--sjs2-radius-x500":"calc(var(--sjs2-base-unit-radius) * 5)","--sjs2-radius-x600":"calc(var(--sjs2-base-unit-radius) * 6)","--sjs2-radius-x700":"calc(var(--sjs2-base-unit-radius) * 7)","--sjs2-radius-x800":"calc(var(--sjs2-base-unit-radius) * 8)","--sjs2-radius-round":"9999px","--sjs2-spacing-x000":"calc(var(--sjs2-base-unit-spacing) * 0)","--sjs2-spacing-x025":"calc(var(--sjs2-base-unit-spacing) * 0.25)","--sjs2-spacing-x050":"calc(var(--sjs2-base-unit-spacing) * 0.50)","--sjs2-spacing-x075":"calc(var(--sjs2-base-unit-spacing) * 0.75)","--sjs2-spacing-x100":"calc(var(--sjs2-base-unit-spacing) * 1)","--sjs2-spacing-x125":"calc(var(--sjs2-base-unit-spacing) * 1.25)","--sjs2-spacing-x150":"calc(var(--sjs2-base-unit-spacing) * 1.5)","--sjs2-spacing-x200":"calc(var(--sjs2-base-unit-spacing) * 2)","--sjs2-spacing-x250":"calc(var(--sjs2-base-unit-spacing) * 2.50)","--sjs2-spacing-x300":"calc(var(--sjs2-base-unit-spacing) * 3)","--sjs2-spacing-x400":"calc(var(--sjs2-base-unit-spacing) * 4)","--sjs2-spacing-x500":"calc(var(--sjs2-base-unit-spacing) * 5)","--sjs2-spacing-x550":"calc(var(--sjs2-base-unit-spacing) * 5.5)","--sjs2-spacing-x600":"calc(var(--sjs2-base-unit-spacing) * 6)","--sjs2-spacing-x700":"calc(var(--sjs2-base-unit-spacing) * 7)","--sjs2-spacing-x800":"calc(var(--sjs2-base-unit-spacing) * 8)","--sjs2-spacing-negative-x025":"calc(var(--sjs2-base-unit-spacing) * -0.25)","--sjs2-spacing-negative-x050":"calc(var(--sjs2-base-unit-spacing) * -0.50)","--sjs2-spacing-negative-x075":"calc(var(--sjs2-base-unit-spacing) * -0.75)","--sjs2-spacing-negative-x100":"calc(var(--sjs2-base-unit-spacing) * -1)","--sjs2-spacing-negative-x125":"calc(var(--sjs2-base-unit-spacing) * -1.25)","--sjs2-spacing-negative-x150":"calc(var(--sjs2-base-unit-spacing) * -1.5)","--sjs2-spacing-negative-x200":"calc(var(--sjs2-base-unit-spacing) * -2)","--sjs2-spacing-negative-x250":"calc(var(--sjs2-base-unit-spacing) * -2.50)","--sjs2-spacing-negative-x300":"calc(var(--sjs2-base-unit-spacing) * -3)","--sjs2-spacing-negative-x400":"calc(var(--sjs2-base-unit-spacing) * -4)","--sjs2-spacing-negative-x500":"calc(var(--sjs2-base-unit-spacing) * -5)","--sjs2-spacing-negative-x600":"calc(var(--sjs2-base-unit-spacing) * -6)","--sjs2-spacing-negative-x700":"calc(var(--sjs2-base-unit-spacing) * -7)","--sjs2-spacing-negative-x800":"calc(var(--sjs2-base-unit-spacing) * -8)","--sjs2-opacity-x000":"calc(var(--sjs2-base-unit-opacity) * 0)","--sjs2-opacity-x005":"calc(var(--sjs2-base-unit-opacity) * 5)","--sjs2-opacity-x010":"calc(var(--sjs2-base-unit-opacity) * 10)","--sjs2-opacity-x015":"calc(var(--sjs2-base-unit-opacity) * 15)","--sjs2-opacity-x020":"calc(var(--sjs2-base-unit-opacity) * 20)","--sjs2-opacity-x025":"calc(var(--sjs2-base-unit-opacity) * 25)","--sjs2-opacity-x030":"calc(var(--sjs2-base-unit-opacity) * 30)","--sjs2-opacity-x035":"calc(var(--sjs2-base-unit-opacity) * 35)","--sjs2-opacity-x040":"calc(var(--sjs2-base-unit-opacity) * 40)","--sjs2-opacity-x045":"calc(var(--sjs2-base-unit-opacity) * 45)","--sjs2-opacity-x050":"calc(var(--sjs2-base-unit-opacity) * 50)","--sjs2-opacity-x055":"calc(var(--sjs2-base-unit-opacity) * 55)","--sjs2-opacity-x060":"calc(var(--sjs2-base-unit-opacity) * 60)","--sjs2-opacity-x065":"calc(var(--sjs2-base-unit-opacity) * 65)","--sjs2-opacity-x070":"calc(var(--sjs2-base-unit-opacity) * 70)","--sjs2-opacity-x075":"calc(var(--sjs2-base-unit-opacity) * 75)","--sjs2-opacity-x080":"calc(var(--sjs2-base-unit-opacity) * 80)","--sjs2-opacity-x085":"calc(var(--sjs2-base-unit-opacity) * 85)","--sjs2-opacity-x090":"calc(var(--sjs2-base-unit-opacity) * 90)","--sjs2-opacity-x095":"calc(var(--sjs2-base-unit-opacity) * 95)","--sjs2-opacity-x100":"calc(var(--sjs2-base-unit-opacity) * 100)","--sjs2-border-width-x000":"calc(var(--sjs2-base-unit-border-width) * 0)","--sjs2-border-width-x100":"calc(var(--sjs2-base-unit-border-width) * 1)","--sjs2-border-width-x200":"calc(var(--sjs2-base-unit-border-width) * 2)","--sjs2-border-width-x400":"calc(var(--sjs2-base-unit-border-width) * 4)","--sjs2-font-weight-regular":"400","--sjs2-font-weight-medium":"500","--sjs2-font-weight-semibold":"600","--sjs2-font-weight-bold":"700","--sjs2-font-size-x000":"calc(var(--sjs2-base-unit-font-size) * 0)","--sjs2-font-size-x100":"calc(var(--sjs2-base-unit-font-size) * 1)","--sjs2-font-size-x150":"calc(var(--sjs2-base-unit-font-size) * 1.5)","--sjs2-font-size-x200":"calc(var(--sjs2-base-unit-font-size) * 2)","--sjs2-font-size-x250":"calc(var(--sjs2-base-unit-font-size) * 2.5)","--sjs2-font-size-x300":"calc(var(--sjs2-base-unit-font-size) * 3)","--sjs2-font-size-x350":"calc(var(--sjs2-base-unit-font-size) * 3.5)","--sjs2-font-size-x400":"calc(var(--sjs2-base-unit-font-size) * 4)","--sjs2-font-size-x500":"calc(var(--sjs2-base-unit-font-size) * 5)","--sjs2-font-size-x600":"calc(var(--sjs2-base-unit-font-size) * 6)","--sjs2-line-height-x000":"calc(var(--sjs2-base-unit-line-height) * 0)","--sjs2-line-height-x100":"calc(var(--sjs2-base-unit-line-height) * 1)","--sjs2-line-height-x200":"calc(var(--sjs2-base-unit-line-height) * 2)","--sjs2-line-height-x300":"calc(var(--sjs2-base-unit-line-height) * 3)","--sjs2-line-height-x400":"calc(var(--sjs2-base-unit-line-height) * 4)","--sjs2-line-height-x500":"calc(var(--sjs2-base-unit-line-height) * 5)","--sjs2-line-height-x600":"calc(var(--sjs2-base-unit-line-height) * 6)","--sjs2-text-case-default":"none","--sjs2-text-case-uppercase":"uppercase","--sjs2-typography-font-family-text":"Open Sans","--sjs2-typography-font-family-code":"DM Mono","--sjs2-typography-font-family-component-input-content":"var(--sjs2-typography-font-family-text)","--sjs2-typography-font-family-component-question-title":"var(--sjs2-typography-font-family-text)","--sjs2-typography-font-family-component-question-description":"var(--sjs2-typography-font-family-text)","--sjs2-typography-font-family-component-page-title":"var(--sjs2-typography-font-family-text)","--sjs2-typography-font-family-component-page-description":"var(--sjs2-typography-font-family-text)","--sjs2-typography-font-family-component-header-title":"var(--sjs2-typography-font-family-text)","--sjs2-typography-font-family-component-header-description":"var(--sjs2-typography-font-family-text)","--sjs2-typography-font-size-small":"var(--sjs2-font-size-x150)","--sjs2-typography-font-size-default":"var(--sjs2-font-size-x200)","--sjs2-typography-font-size-medium":"var(--sjs2-font-size-x300)","--sjs2-typography-font-size-large":"var(--sjs2-font-size-x400)","--sjs2-typography-font-size-component-input-content":"var(--sjs2-typography-font-size-default)","--sjs2-typography-font-size-component-question-title":"var(--sjs2-typography-font-size-default)","--sjs2-typography-font-size-component-question-description":"var(--sjs2-typography-font-size-default)","--sjs2-typography-font-size-component-page-title":"var(--sjs2-typography-font-size-medium)","--sjs2-typography-font-size-component-page-description":"var(--sjs2-typography-font-size-default)","--sjs2-typography-font-size-component-header-title":"var(--sjs2-typography-font-size-large)","--sjs2-typography-font-size-component-header-description":"var(--sjs2-typography-font-size-medium)","--sjs2-typography-line-height-small":"var(--sjs2-line-height-x200)","--sjs2-typography-line-height-default":"var(--sjs2-line-height-x300)","--sjs2-typography-line-height-medium":"var(--sjs2-line-height-x400)","--sjs2-typography-line-height-large":"var(--sjs2-line-height-x500)","--sjs2-typography-line-height-component-input-content":"var(--sjs2-typography-line-height-default)","--sjs2-typography-line-height-component-question-title":"var(--sjs2-typography-line-height-default)","--sjs2-typography-line-height-component-question-description":"var(--sjs2-typography-line-height-default)","--sjs2-typography-line-height-component-page-title":"var(--sjs2-typography-line-height-medium)","--sjs2-typography-line-height-component-page-description":"var(--sjs2-typography-line-height-default)","--sjs2-typography-line-height-component-header-title":"var(--sjs2-typography-line-height-large)","--sjs2-typography-line-height-component-header-description":"var(--sjs2-typography-line-height-medium)","--sjs2-typography-font-weight-basic":"var(--sjs2-font-weight-regular)","--sjs2-typography-font-weight-strong":"var(--sjs2-font-weight-semibold)","--sjs2-typography-font-weight-component-input-content":"var(--sjs2-typography-font-weight-basic)","--sjs2-typography-font-weight-component-question-title":"var(--sjs2-typography-font-weight-strong)","--sjs2-typography-font-weight-component-question-description":"var(--sjs2-typography-font-weight-basic)","--sjs2-typography-font-weight-component-page-title":"var(--sjs2-typography-font-weight-strong)","--sjs2-typography-font-weight-component-page-description":"var(--sjs2-typography-font-weight-basic)","--sjs2-typography-font-weight-component-header-title":"var(--sjs2-typography-font-weight-strong)","--sjs2-typography-font-weight-component-header-description":"var(--sjs2-typography-font-weight-basic)","--sjs2-is-panelless":"false","--sjs2-pdf-radius-question":"var(--sjs2-radius-x000)","--sjs2-pdf-radius-matrix":"var(--sjs2-radius-x000)","--sjs2-pdf-radius-checkbox":"var(--sjs2-radius-x000)","--sjs2-pdf-radius-radio":"var(--sjs2-radius-round)","--sjs2-pdf-radius-section":"var(--sjs2-radius-x000)","--sjs2-pdf-border-width-section":"var(--sjs2-border-width-x100)","--sjs2-pdf-border-width-question":"var(--sjs2-border-width-x100)","--sjs2-pdf-border-width-check":"var(--sjs2-border-width-x100)","--sjs2-pdf-layout-page-padding-top":"var(--sjs2-spacing-x550)","--sjs2-pdf-layout-page-padding-bottom":"var(--sjs2-spacing-x550)","--sjs2-pdf-layout-page-padding-left":"var(--sjs2-spacing-x550)","--sjs2-pdf-layout-page-padding-right":"var(--sjs2-spacing-x550)","--sjs2-pdf-layout-page-gap-vertical":"var(--sjs2-spacing-x000)","--sjs2-pdf-layout-page-gap-horizontal":"var(--sjs2-spacing-x000)","--sjs2-pdf-layout-page-questions-gap-horizontal":"var(--sjs2-spacing-x000)","--sjs2-pdf-layout-page-questions-gap-vertical":"var(--sjs2-spacing-x000)","--sjs2-pdf-layout-page-matrix-gap-horizontal":"var(--sjs2-spacing-x000)","--sjs2-pdf-layout-page-matrix-gap-vertical":"var(--sjs2-spacing-x000)","--sjs2-pdf-layout-title-large-gap":"var(--sjs2-spacing-x150)","--sjs2-pdf-layout-title-large-padding-bottom":"var(--sjs2-spacing-x400)","--sjs2-pdf-layout-title-medium-gap":"var(--sjs2-spacing-x100)","--sjs2-pdf-layout-title-medium-padding-bottom":"var(--sjs2-spacing-x300)","--sjs2-pdf-layout-title-default-gap":"var(--sjs2-spacing-x050)","--sjs2-pdf-layout-title-default-padding-bottom":"var(--sjs2-spacing-x150)","--sjs2-pdf-layout-section-padding-vertical":"var(--sjs2-spacing-x100)","--sjs2-pdf-layout-section-padding-horizontal":"var(--sjs2-spacing-x100)","--sjs2-pdf-layout-section-gap":"var(--sjs2-spacing-x050)","--sjs2-pdf-layout-check-padding-vertical":"var(--sjs2-spacing-x000)","--sjs2-pdf-layout-check-padding-horizontal":"var(--sjs2-spacing-x050)","--sjs2-pdf-layout-check-gap":"var(--sjs2-spacing-x100)","--sjs2-pdf-layout-matrix-padding-vertical":"var(--sjs2-spacing-x000)","--sjs2-pdf-layout-matrix-padding-horizontal":"var(--sjs2-spacing-x050)","--sjs2-pdf-layout-matrix-gap":"var(--sjs2-spacing-x100)","--sjs2-pdf-layout-question-padding-vertical":"var(--sjs2-spacing-x100)","--sjs2-pdf-layout-question-padding-horizontal":"var(--sjs2-spacing-x100)","--sjs2-pdf-layout-question-gap":"var(--sjs2-spacing-x100)","--sjs2-pdf-layout-question-labels-gap-vertical":"var(--sjs2-spacing-x050)","--sjs2-pdf-layout-question-items-gap-vertical":"var(--sjs2-spacing-x050)","--sjs2-pdf-layout-question-items-gap-horizontal":"var(--sjs2-spacing-x150)","--sjs2-pdf-layout-image-picker-items-gap-image-check":"var(--sjs2-spacing-x000)"};class Pt extends D.SurveyModel{constructor(t,e){if(super(t),this.legacyLayout={},this.onRenderHeader=new Tt,this.onRenderFooter=new Tt,this.onRenderQuestion=new Tt,this.onRenderPanel=new Tt,this.onRenderPage=new Tt,this.onDocControllerCreated=new D.EventBase,this.onRenderCheckItemAcroform=new Tt,this.onRenderRadioGroupWrapAcroform=new Tt,this.onRenderRadioItemAcroform=new Tt,this.onGetQuestionStyle=new D.EventBase,this.onGetPanelStyle=new D.EventBase,this.onGetPageStyle=new D.EventBase,this.onGetItemStyle=new D.EventBase,this.stylesHash={},this.navigationMap={},typeof e>"u"&&(e={}),(this.questionsOnPageMode=="inputPerPage"||this.questionsOnPageMode=="questionPerPage")&&(this.questionsOnPageMode="standard"),this.options=o.clone(e),this.options.fontSize!==void 0){const s=`${this.options.fontSize/14*8}px`;o.mergeObjects(this.legacyLayout,{"--sjs2-base-unit-size":s,"--sjs2-base-unit-spacing":s,"--sjs2-base-unit-radius":s,"--sjs2-base-unit-border-width":`${this.options.fontSize/14}px`,"--sjs2-base-unit-font-size":s,"--sjs2-base-unit-line-height":s})}if(this.options.margins)for(const s in this.options.margins)this.options.margins[s]!==void 0&&(this.legacyLayout[`--sjs2-pdf-layout-page-padding-${s=="bot"?"bottom":s}`]=`${96/25.4*this.options.margins[s]}px`);this.applyTheme(D.BaseTheme)}get haveCommercialLicense(){const t=D.hasLicense;return!!t&&t(2)}set haveCommercialLicense(t){console.error("As of v1.9.101, the haveCommercialLicense property is not supported. To activate your license, use the setLicenseKey(key) method as shown on the following page: https://surveyjs.io/remove-alert-banner")}get licenseText(){const t=D.glc?D.glc(2):!1;return t&&t.toLocaleDateString?"This banner appears because your maintenance subscription for the PDF Generator library expired on {date}. You may continue using [all versions released up to that date](https://surveyjs.io/stay-updated/release-notes). To remove this banner in the latest version, please [renew your subscription](https://surveyjs.io/manage#license-manager) and [set up a new license key](https://surveyjs.io/remove-alert-banner).".replace("{date}",t.toLocaleDateString()):"To use the PDF Generator library to create PDF forms such as this one, a [developer license](https://surveyjs.io/licensing) is required. If you have an active license, please [set up your license key](https://surveyjs.io/remove-alert-banner) and ensure you're using the [latest version](https://surveyjs.io/stay-updated/release-notes)."}updateCheckItemAcroformOptions(t,e,s){this.onRenderCheckItemAcroform.fire(this,{options:t,question:e,...s??{}})}getUpdatedRadioGroupWrapOptions(t,e,s){this.onRenderRadioGroupWrapAcroform.fire(this,{options:t,question:e,...s??{}})}updateRadioItemAcroformOptions(t,e,s){this.onRenderRadioItemAcroform.fire(this,{options:t,question:e,...s??{}})}get style(){return this.styleValue||(this.styleValue=xs(this.theme,this.layout)),this.styleValue}clearStyles(){this.styleValue=void 0,this.stylesHash={}}applyStyle(t){typeof t=="function"?this.styleValue=o.mergeObjects({},this.style,Qt(this.theme,this.layout,t)):this.styleValue=o.mergeObjects({},this.style,t),this.stylesHash={}}get theme(){return this._theme||D.BaseTheme}applyTheme(t,e){this._theme=o.mergeObjects({},D.BaseTheme,e??{},t),this.clearStyles()}get defaultLayout(){return this.defaultLayoutValue||(this.defaultLayoutValue=o.mergeObjects({},bs,this.legacyLayout)),this.defaultLayoutValue}get layout(){return this._layout||this.defaultLayout}applyLayout(t,e){this._layout=o.mergeObjects({},this.defaultLayout,e??{},t),this.clearStyles()}getItemStyle(t,e,s){return Qt(this.theme,this.layout,i=>{const n={getColorVariable:i.getColorVariable,getSizeVariable:i.getSizeVariable,style:s};return this.onGetItemStyle.fire(this,{question:t,item:e,...n}),s})}addStyleGroups(t){if(t.indexOf("matrixbase")>-1)return;const e=t.findIndex(s=>s==="matrix"||s==="matrixdropdownbase");e>-1&&t.splice(e,0,"matrixbase")}getElementStyle(t){const e=t.uniqueId;if(!this.stylesHash[e]){const s=this.style,i=[t.getType()];let n=D.Serializer.findClass(t.getType());for(;n.parentName;)i.unshift(n.parentName),n=D.Serializer.findClass(n.parentName);this.addStyleGroups(i),t.getTemplate()=="composite"&&i.push("composite");const r={};i.forEach(l=>{var a;o.mergeObjects(r,(a=s[l])!==null&&a!==void 0?a:{})}),this.stylesHash[e]=Qt(this.theme,this.layout,l=>{const a={getColorVariable:l.getColorVariable,getSizeVariable:l.getSizeVariable,style:r};return t.isPanel&&this.onGetPanelStyle.fire(this,{panel:t,...a}),t.isPage&&this.onGetPageStyle.fire(this,{page:t,...a}),t.isQuestion&&this.onGetQuestionStyle.fire(this,{question:t,...a}),r})}return this.stylesHash[e]}correctBricksPosition(t,e){t.isRTL&&e.forEach(s=>{s.forEach(i=>{i.translateX((n,r)=>{const l=t.paperWidth-n-r;return{xLeft:n+l,xRight:r+l}})})})}afterRenderSurveyElement(t,e){e.forEach(s=>s.addBeforeRenderCallback(()=>{var i;s.getPageNumber()!==void 0&&(this.navigationMap[t.uniqueId]=Math.min((i=this.navigationMap[t.uniqueId])!==null&&i!==void 0?i:Number.MAX_VALUE,s.getPageNumber()+1))}))}renderPanelNavigation(t,e,s){const{doc:i}=t;if(!this.navigationMap[e.uniqueId])return;const n=i.outline.add(s,e.title||e.name,{pageNumber:this.navigationMap[e.uniqueId]});e.elements.forEach(r=>{((r.visible||r.visibleIf)&&t.dynamicContent.conditionalElements||r.isVisible||t.doc&&this.navigationMap[r.uniqueId])&&(r.isPanel?this.renderPanelNavigation(t,r,n):i.outline.add(n,r.title||r.name,{pageNumber:this.navigationMap[r.uniqueId]}))})}renderNavigation(t){var e;(!((e=this.options.showNavigation)!==null&&e!==void 0)||e)&&(this.visiblePages.forEach(s=>{this.renderPanelNavigation(t,s,null)}),this.navigationMap={})}async renderSurvey(t){this.visiblePages.forEach(i=>i.onFirstRendering());const e=await _.getInstance().createSurvey(this,t,this.style.survey).generateFlats();this.correctBricksPosition(t,e);const s=zt.pack(e,t);s.forEach((i,n)=>{i.forEach(r=>{r.setPageNumber(n)})}),await ke.process_header_events(this,t,s);for(let i=0;i<s.length;i++){t.getNumberOfPages()===i&&t.addPage(),t.setPage(i),t.setFillColor(this.style.survey.backgroundColor),t.doc.rect(0,0,t.doc.internal.pageSize.getWidth(),t.doc.internal.pageSize.getHeight(),"F"),t.restoreFillColor();for(let n=0;n<s[i].length;n++)await s[i][n].render()}this.renderNavigation(t),o.clear(),this.stylesHash={}}createDocController(){const t=Mt(this.style.survey.padding),e=o.mergeObjects({},this.options,{margins:t}),s=new xt(e);return this.onDocControllerCreated.fire(this,{controller:s}),s}get docController(){return this.docControllerValue||(this.docControllerValue=this.createDocController()),this.docControllerValue}async save(t="survey_result.pdf"){if(Pt.currentlySaving)Pt.saveQueue.push(()=>{this.save(t)});else{const e=this.docController;Pt.currentlySaving=!0,o.fixFont(e),await this.renderSurvey(e);const s=e.doc.save(t,{returnPromise:!0});return s.then(()=>{Pt.currentlySaving=!1;const i=Pt.saveQueue.shift();i&&i()}),s}}async raw(t){const e=this.createDocController();return this.onDocControllerCreated.fire(this,{controller:e}),o.fixFont(e),await this.renderSurvey(e),e.doc.output(t)}}Pt.currentlySaving=!1,Pt.saveQueue=[];class le{constructor(t,e,s,i){this.survey=t,this.panel=e,this.controller=s,this.style=i}async generateFlats(t){const e=[],s=o.clone(t);this.controller.pushMargins(),this.controller.margins.left+=this.controller.measureText(this.panel.innerIndent).width,s.xLeft+=this.controller.measureText(this.panel.innerIndent).width,e.push(...await this.generateContentFlats(s)),this.controller.popMargins();const i=new rs(t,e,this.panel,this.controller,_.getInstance());await this.survey.onRenderPanel.fire(this.survey,i);const n=[...i.bricks];return this.survey.afterRenderSurveyElement(this.panel,n),n}async generateContentFlats(t){this.panel.onFirstRendering();const e=[];let s=o.clone(t);const i=new E;if(this.panel.hasDescriptionUnderTitle||this.panel.hasTitle){const r=await this.createHeaderFlats(s);i.addBrick(...r),s.yTop=r[r.length-1].yBot+this.style.spacing.headerContentGap+o.EPSILON}const n=await this.generateRowsFlats(s);return!i.isEmpty&&n.length>0&&i.addBrick(n.shift()),i.isEmpty||e.push(i),e.push(...n),e}async generateTitleFlat(t){const e=new E,s={...this.style.title};let i=o.clone(t);if(this.panel.no){const r=await o.createTextFlat(i,this.controller,this.panel.no,s);e.addBrick(r),i.xLeft=r.xRight+this.controller.measureText(" ").width}const n=await o.createTextFlat(i,this.controller,this.panel.locTitle,s);return e.addBrick(n),e}async createHeaderFlats(t){const e=new qt(this.controller,{...t,width:o.getPageAvailableWidth(this.controller)},this.style.header);return await e.setup(async(s,i)=>{let n=o.clone(s);if(this.panel.hasTitle){const l=await this.generateTitleFlat(n);i.push(l),n=o.createPoint(l)}if(this.panel.description){this.panel.title&&(n.yTop+=this.style.spacing.titleDescriptionGap);const l=await o.createTextFlat(n,this.controller,this.panel.locDescription,{...this.style.description});i.push(l),n=o.createPoint(l)}const r=o.createPoint(o.mergeRects(...i));i.push(o.createRowlineFlat(r,this.controller))}),[e]}getVisibleElements(){const t=[];return this.panel.rows.forEach(e=>{const s=e.elements.filter(i=>(i.visible||i.visibleIf)&&this.controller.dynamicContent.conditionalElements||i.isVisible);s.length!=0&&t.push(s)}),t}getRows(t){const e=o.getPageAvailableWidth(t),s=[],i=this.style.spacing.inlineElementGap;return this.getVisibleElements().forEach(n=>{let r=e+i,l=[];n.forEach(a=>{const h=this.survey.getElementStyle(a),u=a.minWidth&&a.minWidth!=="auto"?o.parseWidth(a.minWidth,e,void 0,"px"):h.minWidth,g=a.width?o.parseWidth(a.width,e,void 0,"px"):0,b=o.parseWidth(a.maxWidth?a.maxWidth:"100%",e,void 0,"px"),T=Math.min(Math.max(u,g),b);r<T+i&&(s.push(l),r=e-i,l=[]),r-=T+i,l.push({element:a,width:T})}),l.length!=0&&s.push(l)}),s.forEach(n=>{const r=n.reduce((u,g)=>u+g.width,0);let l=(e-r-(n.length-1)*i)/n.length,a=[].concat(n),h=l*n.length;for(;a.length>0&&h>o.EPSILON;)a=a.filter(u=>{const g=o.parseWidth(u.element.maxWidth?u.element.maxWidth:"100%",e,void 0,"px");return u.element.width&&n.length>1?!1:g>u.width+l?(h-=l,u.width=u.width+l,!0):(h-=g-u.width,u.width=g,!1)}),l=h/a.length;if(h>0){const u=n.filter(b=>!b.element.maxWidth),g=h/u.length;u.forEach(b=>{b.width+=g})}}),s}getGapBetweenRows(){return this.style.spacing.elementGap}async generateRowsFlats(t){const e=o.clone(t),s=[],i=this.getRows(this.controller);for(const n of i){let r=this.controller.margins.left;const l=[];for(let a=0;a<n.length;a++){const{element:h,width:u}=n[a],g=this.style.spacing.inlineElementGap;this.controller.pushMargins(),this.controller.margins.left=r,this.controller.margins.right=this.controller.paperWidth-this.controller.margins.left-u,e.xLeft=this.controller.margins.left;const b=this.survey.getElementStyle(h),T=new qt(this.controller,{...e,width:o.getPageAvailableWidth(this.controller)},b.container);await T.setup(async(M,Z)=>{h instanceof D.PanelModel?Z.push(...await o.generatePanelFlats(this.survey,this.controller,h,M)):(await h.waitForQuestionIsReady(),Z.push(...await o.generateQuestionFlats(this.survey,this.controller,h,M)))}),l.push(T),this.controller.popMargins(),r+=u+g}if(e.xLeft=this.controller.margins.left,l.length!==0){const a=o.mergeRects(...l),h=a.yBot;e.yTop=h,l.forEach(u=>{u.fitToHeight(a.yBot-a.yTop)}),l.forEach(u=>s.push(...u.getBricks())),s.push(o.createRowlineFlat(e,this.controller)),e.xLeft=t.xLeft,e.yTop+=this.getGapBetweenRows(),r=e.xLeft}}return s}}_.registerPanel(le);class Be extends le{async generateTitleFlat(t){return await o.createTextFlat(t,this.controller,this.panel.locTitle,{...this.style.title})}async generateFlats(t){const e=[];e.push(...await this.generateContentFlats(t));const s=new as(t,e,this.panel,this.controller,_.getInstance());await this.survey.onRenderPage.fire(this.survey,s);const i=[...s.bricks];return this.survey.afterRenderSurveyElement(this.panel,i),i}getGapBetweenRows(){return this.survey.isSinglePage&&this.panel===this.survey.visiblePages[0]?this.survey.style.survey.spacing.pageGap:super.getGapBetweenRows()}}_.registerPage(Be);class Ut extends pt{constructor(t,e,s,i){super(t,e),this.options=s,this.style=i}async renderInteractive(){var t;const e=new this.controller.AcroFormCheckBox,s=o.createAcroformRect(o.createRectInsideBorders(this.contentRect,(t=this.style.borderWidth)!==null&&t!==void 0?t:0)),{color:i}=o.parseColor(this.style.fontColor);this.style.backgroundColor&&(this.controller.setFillColor(this.style.backgroundColor),this.controller.doc.rect(...s,"F"),this.controller.restoreFillColor());const n={};n.maxFontSize=this.style.fontSize,n.caption=this.style.checkMark,n.textAlign="center",n.fieldName=this.options.fieldName,n.readOnly=this.options.readOnly,n.color=i,n.value=this.options.checked?"On":!1,n.AS=this.options.checked?"/On":"/Off",n.Rect=s,this.controller.doc.addField(e),this.options.updateOptions(n),e.maxFontSize=n.maxFontSize,e.caption=n.caption,e.textAlign=n.textAlign,e.fieldName=n.fieldName,e.readOnly=n.readOnly,e.color=n.color,e.fillColor=[0,0,0],e.value=n.value,e.AS=n.AS,e.Rect=n.Rect,o.renderFlatBorders(this.controller,this.contentRect,this.style)}async renderReadOnly(){if(this.style.backgroundColor){this.controller.setFillColor(this.style.backgroundColor);const{lines:t,point:e}=o.getDocLinesFromShape(o.createRoundedShape(this.contentRect,this.style));this.controller.doc.lines(t,...e,[1,1],"F",!0),this.controller.restoreFillColor()}if(o.renderFlatBorders(this.controller,this.contentRect,this.style),this.options.checked){const t=o.createPoint(this.contentRect,!0,!0),e={fontName:this.style.fontName,fontSize:this.style.fontSize,fontColor:this.style.fontColor},s=this.controller.measureText(this.style.checkMark,e);t.xLeft+=this.contentRect.width/2-s.width/2,t.yTop+=this.contentRect.height/2-s.height/2,await(await o.createTextFlat(t,this.controller,this.style.checkMark,e)).render()}}}class $t{constructor(t,e){this.controller=t,this.options=e}addToPdf(t){this._radioGroup=new this.controller.AcroFormRadioButton;const e={};e.fieldName=this.options.fieldName,e.readOnly=this.options.readOnly,e.color=t,this.options.updateOptions(e),this._radioGroup.fieldName=e.fieldName,this._radioGroup.readOnly=e.readOnly,this._radioGroup.color=e.color,this._radioGroup.value="",this.controller.doc.addField(this._radioGroup)}get radioGroup(){return this._radioGroup}get readOnly(){return this.options.readOnly}get fieldName(){return this.options.fieldName}}class Nt extends pt{constructor(t,e,s,i,n){super(t,e),this.radioGroupWrap=s,this.options=i,this.style=n}async renderInteractive(){var t;const e=o.createAcroformRect(o.createRectInsideBorders(this.contentRect,(t=this.style.borderWidth)!==null&&t!==void 0?t:0)),{color:s}=o.parseColor(this.style.fontColor);this.options.index==0&&this.radioGroupWrap.addToPdf(s),this.style.backgroundColor&&(this.controller.setFillColor(this.style.backgroundColor),this.controller.doc.rect(...e,"F"),this.controller.restoreFillColor());const i={};i.fieldName=this.radioGroupWrap.fieldName+"index"+this.options.index,i.Rect=e,i.color=s,i.multiSelect=!0,i.style=this.controller.doc.AcroForm.Appearance.RadioButton.Circle,i.radioGroup=this.radioGroupWrap.radioGroup,this.options.updateOptions&&this.options.updateOptions(i);let n=this.radioGroupWrap.radioGroup.createOption(i.fieldName);this.options.checked?(i.AS||(n.AS="/"+i.fieldName),this.radioGroupWrap.radioGroup.value||(this.radioGroupWrap.radioGroup.value=i.fieldName)):i.AS||(i.AS="/Off"),n.Rect=i.Rect,n.color=i.color,o.renderFlatBorders(this.controller,this.contentRect,this.style),this.radioGroupWrap.radioGroup.setAppearance(i.style)}async renderReadOnly(){if(this.style.backgroundColor){this.controller.setFillColor(this.style.backgroundColor);const{lines:t,point:e}=o.getDocLinesFromShape(o.createRoundedShape(this.contentRect,this.style));this.controller.doc.lines(t,...e,[1,1],"F",!0),this.controller.restoreFillColor()}if(o.renderFlatBorders(this.controller,this.contentRect,this.style),this.options.checked){const t={fontName:this.style.fontName,fontSize:this.style.fontSize,fontColor:this.style.fontColor,lineHeight:this.style.lineHeight},e=o.createPoint(this.contentRect,!0,!0),s=this.controller.measureText(this.style.checkMark,t);e.xLeft+=this.contentRect.width/2-s.width/2,e.yTop+=this.contentRect.height/2-s.height/2,await(await o.createTextFlat(e,this.controller,this.style.checkMark,t)).render()}}}class Ie extends tt{getInputStyle(t,e){const s=o.mergeObjects({},this.style.input,this.style.checkboxInput);return t&&(o.mergeObjects(s,this.style.inputReadOnly,this.style.checkboxInputReadOnly),e&&o.mergeObjects(s,this.style.inputReadOnlyChecked,this.style.checkboxInputReadOnlyChecked)),s}async generateFlatsContent(t){const e=new E,s=this.question.isReadOnly,i=s&&o.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,n=o.getPatchedTextStyle(this.controller,this.getInputStyle(s,this.question.booleanValue)),r=new Ut(this.controller,o.createRect(t,n.width,n.height),{fieldName:this.question.id,readOnly:s,updateOptions:l=>this.survey.updateCheckItemAcroformOptions(l,this.question),shouldRenderReadOnly:i,checked:this.question.booleanValue},n);if(e.addBrick(r),this.question.isLabelRendered){const l=new E,a=o.clone(t);a.xLeft=r.xRight+this.style.spacing.choiceTextGap;const h=this.question.locTitle;if(h!==null&&h.renderedHtml!==null&&l.addBrick(await o.createTextFlat(a,this.controller,h,this.style.choiceText)),this.question.isRequired){const u=this.question.requiredText,g=o.mergeObjects({},this.style.choiceText,this.style.requiredMark);if(o.hasHtml(this.question.locTitle)){const b=o.createPoint(l.unfold()[0],!1,!1);b.xLeft+=this.style.spacing.titleRequiredMarkGap,this.controller.pushMargins(),this.controller.margins.right=this.controller.paperWidth-this.controller.margins.left-this.controller.measureText(u,g).width,l.addBrick(await o.createHTMLFlat(b,this.controller,o.createHtmlContainerBlock(u,this.controller,g))),this.controller.popMargins()}else{const b=o.createPoint(l.unfold().pop(),!1,!0);b.xLeft+=this.style.spacing.titleRequiredMarkGap,l.addBrick(await o.createTextFlat(b,this.controller,u,g))}}o.alignVerticallyBricks("center",r,l.unfold()[0]),l.updateRect(),e.addBrick(l)}return[e]}}class vs extends tt{getInputStyle(t,e){const s=o.mergeObjects({},this.style.input,this.style.radioInput);return t&&(o.mergeObjects(s,this.style.inputReadOnly,this.style.radioInputReadOnly),e&&o.mergeObjects(s,this.style.inputReadOnlyChecked,this.style.radioInputReadOnlyChecked)),s}get radioGroupWrap(){return this._radioGroupWrap||(this._radioGroupWrap=new $t(this.controller,{readOnly:this.question.isReadOnly,fieldName:this.question.id,updateOptions:t=>{this.survey.getUpdatedRadioGroupWrapOptions(t,this.question)}})),this._radioGroupWrap}generateFlatItem(t,e,s){const i=this.question.value==e.value,n=this.radioGroupWrap.readOnly&&o.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,r=o.getPatchedTextStyle(this.controller,this.getInputStyle(n,i)),l=o.createRect(t,r.width,r.height);return new Nt(this.controller,l,this.radioGroupWrap,{index:s,checked:i,shouldRenderReadOnly:n},r)}async generateFlatComposite(t,e,s){const i=new E,n=this.style.choiceText,r=this.generateFlatItem(t,e,s);i.addBrick(r);const l=o.clone(t);if(l.xLeft=r.xRight+this.style.spacing.choiceTextGap,e.locText.renderedHtml!==null){const a=await o.createTextFlat(l,this.controller,e.locText,n);o.alignVerticallyBricks("center",r,a.unfold()[0]),a.updateRect(),i.addBrick(a)}return i}async generateFlatsContent(t){const e=o.clone(t),s=new E,i=[{locText:this.question.locLabelFalse,value:this.question.valueFalse!==void 0?this.question.valueFalse:!1},{locText:this.question.locLabelTrue,value:this.question.valueTrue!==void 0?this.question.valueTrue:!0}];let n=0;for(let l of i){this.controller.pushMargins(),o.setColumnMargins(this.controller,2,n,this.style.spacing.choiceColumnGap),e.xLeft=this.controller.margins.left;const a=await this.generateFlatComposite(e,l,n);s.addBrick(a),this.controller.popMargins(),n++}const r=o.createRowlineFlat(o.createPoint(s),this.controller);return[s,r]}}_.getInstance().register("boolean",vs),_.getInstance().register("boolean-checkbox",Ie);class he extends tt{constructor(){super(...arguments),this.generateVerticallyItems=async(t,e,s)=>{const i=o.clone(t),n=[];for(let r=0;r<e.length;r++){const l=await this.generateFlatComposite(i,e[r],r);i.yTop=l.yBot+(s||this.style.spacing.choiceGap),n.push(l)}return n}}async generateItemComment(t,e){const s=o.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),i=o.getPatchedTextStyle(this.controller,o.mergeObjects({},this.style.comment,s?this.style.commentReadOnly:void 0)),n=this.question.getCommentTextAreaModel(e);return await o.createCommentFlat(t,this.controller,{shouldRenderReadOnly:s,fieldName:n.id,rows:this.controller.otherRowsCount,value:n.getTextValue(),shouldRenderBorders:D.settings.readOnlyCommentRenderMode==="textarea",isReadOnly:this.question.isReadOnly,isMultiline:!0},i)}getItemStyle(t){const e=this.question.isItemSelected(t),s=this.question.isReadOnly||!t.isEnabled&&o.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,i={input:o.mergeObjects({},this.style.input,s?this.style.inputReadOnly:{},s&&e?this.style.inputReadOnlyChecked:{}),choiceText:{...this.style.choiceText}};return this.survey.getItemStyle(this.question,t,i)}async generateFlatComposite(t,e,s){const i=new E,n=this.getItemStyle(e),r=this.generateFlatItem(t,e,s,n.input);i.addBrick(r);const l=o.clone(t);if(l.xLeft=r.xRight+this.style.spacing.choiceTextGap,e.locText.renderedHtml!==null){const a=await o.createTextFlat(l,this.controller,e.locText,{...n.choiceText});o.alignVerticallyBricks("center",r,a.unfold()[0]),a.updateRect(),i.addBrick(a)}if(e.hasElements&&(this.question.isItemSelected(e)||this.controller.dynamicContent.choiceNestedContent)){const a=o.createPoint(i,!0,!1);a.yTop+=this.style.spacing.choiceGap,i.addBrick(...await o.generatePanelFlats(this.survey,this.controller,e.panel,a))}if(e.showCommentArea&&(this.question.isItemSelected(e)||this.question.isOtherItem(e)||this.controller.dynamicContent.choiceComments)){const a=o.createPoint(i,!0,!1);a.yTop+=this.style.spacing.choiceGap,i.addBrick(await this.generateItemComment(a,e))}return i}getVisibleChoices(){let t=[...this.question.visibleChoices];if(this.controller.dynamicContent.conditionalChoices){const e=this.question.filteredChoicesValue;this.question.filteredChoicesValue=void 0,this.question.updateVisibleChoices(),t=[...this.question.visibleChoices],this.question.filteredChoicesValue=e,this.question.updateVisibleChoices()}return t}async generateFlatsContent(t){const e=this.question.colCount,s=this.getVisibleChoices();let i=e;if(e==0)i=Math.floor(o.getPageAvailableWidth(this.controller)/this.style.columnMinWidth)||1,s.length<i&&(i=s.length);else if(e>1&&(i=o.getColumnWidth(this.controller,e,this.style.spacing.choiceColumnGap)<this.style.columnMinWidth?1:e,i==e))return await this.generateColumns(t);return i==1?await this.generateVerticallyItems(t,s):await this.generateHorisontallyItems(t,i)}async generateRows(t,e){var s;const i=this.getVisibleChoices(),n=o.clone(t),r=((s=e[0])!==null&&s!==void 0?s:[]).length,l=[];for(let a of e){const h=new E;for(let g=0;g<a.length;g++){const b=a[g];this.controller.pushMargins(),o.setColumnMargins(this.controller,r,g,this.style.spacing.choiceColumnGap),n.xLeft=this.controller.margins.left;const T=await this.generateFlatComposite(n,b,i.indexOf(b));h.addBrick(T),this.controller.popMargins()}const u=o.createRowlineFlat(o.createPoint(h),this.controller);n.yTop=u.yBot+this.style.spacing.choiceGap,l.push(h,u)}return l}async generateColumns(t){const e=this.question.columns,s=e.reduce((n,r)=>Math.max(n,r.length),0),i=[];for(let n=0;n<s;n++){const r=[];for(let l of e)l[n]&&r.push(l[n]);i.push(r)}return await this.generateRows(t,i)}async generateHorisontallyItems(t,e){const s=[];return this.getVisibleChoices().forEach((n,r)=>{const l=Math.floor(r/e),a=r%e;s[l]||(s[l]=[]),s[l][a]=n}),await this.generateRows(t,s)}}class ce extends he{generateFlatItem(t,e,s,i){const n=o.createRect(t,i.width,i.height),r=this.question.isReadOnly||!e.isEnabled,l=r&&o.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress;return new Ut(this.controller,n,{shouldRenderReadOnly:l,readOnly:r,checked:this.question.isItemSelected(e),fieldName:this.question.id+"index"+s,updateOptions:a=>{this.survey.updateCheckItemAcroformOptions(a,this.question,{item:e})}},o.getPatchedTextStyle(this.controller,{...i}))}async generateFlats(t){const e=this.question.maxSelectedChoices;this.question.maxSelectedChoices=0;const s=await super.generateFlats(t);return this.question.maxSelectedChoices=e,s}}class ws extends ce{getVisibleChoices(){return this.controller.tagboxSelectedChoicesOnly?this.question.selectedChoices:super.getVisibleChoices()}}_.getInstance().register("tagbox",ws),_.getInstance().register("checkbox",ce);class Le extends tt{async generateFlatsContent(t){return _.getInstance().create(this.survey,this.question,this.controller,this.survey.getElementStyle(this.question),this.question.getType()).generateFlatsContent(t)}}_.getInstance().register("custom_model",Le);class Me extends tt{async generateFlatsContent(t){const e=o.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),s=o.getPatchedTextStyle(this.controller,o.mergeObjects({},this.style.input,e?this.style.inputReadOnly:void 0));return[await o.createCommentFlat(t,this.controller,{shouldRenderReadOnly:e,rows:this.question.rows,isReadOnly:this.question.isReadOnly,isMultiline:!0,fieldName:this.question.id,placeholder:o.getLocString(this.question.locPlaceHolder),shouldRenderBorders:D.settings.readOnlyCommentRenderMode==="textarea",value:this.question.value},o.getPatchedTextStyle(this.controller,s))]}}_.getInstance().register("comment",Me);class qe extends pt{constructor(t,e,s,i){super(t,e),this.controller=t,this.options=s,this.style=i}async renderInteractive(){var t;const{color:e}=o.parseColor(this.style.fontColor),{color:s}=o.parseColor(this.style.backgroundColor),i=new this.controller.AcroFormComboBox;i.backgroundColor=s,i.fieldName=this.options.fieldName,i.Rect=o.createAcroformRect(o.createRectInsideBorders(this.contentRect,(t=this.style.borderWidth)!==null&&t!==void 0?t:0)),i.edit=!1,i.color=e;const n=[];this.options.showOptionsCaption&&n.push(this.getCorrectedText(this.options.optionsCaption)),this.options.items.forEach(r=>{n.push(this.getCorrectedText(r))}),i.setOptions(n),i.fontName=this.style.fontName,i.fontSize=this.style.fontSize,i.readOnly=this.options.isReadOnly,i.isUnicode=o.isCustomFont(this.controller,i.fontName),i.V=this.getCorrectedText(this.options.value),this.controller.doc.addField(i),o.renderFlatBorders(this.controller,this.contentRect,this.style)}}class Se extends tt{async generateItemComment(t){const e=this.question.getCommentTextAreaModel(this.question.selectedItem),s=o.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),i=o.getPatchedTextStyle(this.controller,o.mergeObjects({},this.style.comment,s?this.style.commentReadOnly:void 0));return await o.createCommentFlat(t,this.controller,{shouldRenderReadOnly:s,fieldName:e.id,rows:this.controller.otherRowsCount,value:e.getTextValue(),shouldRenderBorders:D.settings.readOnlyCommentRenderMode==="textarea",isReadOnly:this.question.isReadOnly,isMultiline:!0},o.getPatchedTextStyle(this.controller,i))}async generateFlatsContent(t){const e=o.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),s=o.getPatchedTextStyle(this.controller,o.mergeObjects({},this.style.input,e?this.style.inputReadOnly:void 0)),i=e?await o.createCommentFlat(t,this.controller,{fieldName:this.question.id,shouldRenderReadOnly:e,shouldRenderBorders:D.settings.readOnlyTextRenderMode==="input",value:this.question.readOnlyText||"",isReadOnly:this.question.isReadOnly,placeholder:o.getLocString(this.question.locPlaceholder)},s):new qe(this.controller,o.createTextFieldRect(t,this.controller,1,s.lineHeight),{fieldName:this.question.id,value:this.question.readOnlyText,isReadOnly:this.question.isReadOnly,optionsCaption:this.question.optionsCaption,showOptionsCaption:this.question.showOptionsCaption,items:this.question.visibleChoices.map(r=>o.getLocString(r.locText))},s),n=new E(i);if(this.question.isShowingChoiceComment){const r=o.createPoint(n);r.yTop+=this.style.spacing.contentCommentGap,n.addBrick(await this.generateItemComment(r))}return[n]}}_.getInstance().register("dropdown",Se);class Ae extends tt{async generateFlatsContent(t){return[await o.createCommentFlat(t,this.controller,{value:this.question.displayValue,isReadOnly:!0,shouldRenderReadOnly:o.shouldRenderReadOnly(this.question,this.controller,!0),fieldName:this.question.id,shouldRenderBorders:D.settings.readOnlyTextRenderMode==="input"},o.getPatchedTextStyle(this.controller,this.style.input))]}}_.getInstance().register("expression",Ae);class We extends tt{async generateFlatItem(t,e){const s=new E(await o.createLinkFlat(t,this.controller,{text:e.name===void 0?"image":e.name,link:typeof e.content=="string"?e.content:"",readOnlyShowLink:o.getReadonlyRenderAs(this.question,this.controller)==="text",shouldRenderReadOnly:o.shouldRenderReadOnly(this.question,this.controller)},{...this.style.fileName}));if(this.question.canPreviewImage(e)){const i=o.createPoint(s);i.yTop+=this.style.spacing.imageFileNameGap,s.addBrick(await o.createImageFlat(i,this.question,this.controller,{link:e.content,width:e.imageSize.width,height:e.imageSize.height,objectFit:this.style.defaultImageFit}))}return s}addLine(t,e,s,i){s!==i.length-1&&(t[t.length-1].addBrick(o.createRowlineFlat(e,this.controller)),e.yTop+=o.EPSILON,t.push(new E))}async getImagePreviewContentWidth(t){return Math.max(t.imageSize.width,this.style.fileItemMinWidth)}async generateFlatsContent(t){const e=this.question.showPreview?this.question.previewValue:this.question.value;if(!e||e.length===0)return[await o.createTextFlat(t,this.controller,this.question.noFileChosenCaption)];const s=[new E],i=o.clone(t);let n=i.yTop;for(let r=0;r<e.length;r++){let l={...e[r]};const a=this.question.canPreviewImage(l);a&&(l.imageSize=await o.getCorrectedImageSize(this.controller,{imageWidth:this.question.imageWidth,imageHeight:this.question.imageHeight,imageLink:e[r].content,defaultImageWidth:200,defaultImageHeight:150}));const h=this.controller.paperWidth-this.controller.margins.right-i.xLeft;if(a){const u=await this.getImagePreviewContentWidth(l);h<u&&(i.xLeft=t.xLeft,i.yTop=n+this.style.spacing.fileItemGap,this.addLine(s,i,r,e)),this.controller.pushMargins(i.xLeft,this.controller.paperWidth-i.xLeft-u);const g=await this.generateFlatItem(i,l);s[s.length-1].addBrick(g),i.xLeft+=g.width,n=Math.max(n,g.yBot),this.controller.popMargins()}else{h<this.controller.unitWidth&&(i.xLeft=t.xLeft,i.yTop=n+this.style.spacing.fileItemGap,this.addLine(s,i,r,e));const u=await this.generateFlatItem(i,l);s[s.length-1].addBrick(u),i.xLeft+=u.xRight-u.xLeft,n=Math.max(n,u.yBot)}i.xLeft+=this.style.spacing.fileItemColumnGap}return s}}_.getInstance().register("file",We);class Oe extends tt{chooseRender(t){return/<[^>]*style[^<]*>/.test(t)||/<[^>]*table[^<]*>/.test(t)||/&\w+;/.test(t)?"image":"standard"}get correctHtmlRules(){const t=[{searchRegExp:/(<\/?br\s*?\/?\s*?>\s*){2,}/g,replaceString:"<br>"}];return this.controller.fontName=="helvetica"&&(t.push({searchRegExp:/’/g,replaceString:"'"}),t.push({searchRegExp:/—/g,replaceString:"-"})),t}correctHtml(t){return this.correctHtmlRules.forEach(e=>{t=t.replace(e.searchRegExp,e.replaceString)}),t}async generateFlatsContent(t){let e=this.question.renderAs;if(!o.hasDocument)return[new It(this.controller,o.createRect(t,0,0))];e==="auto"&&(e=this.controller.htmlRenderAs),e==="auto"&&(e=this.chooseRender(o.getLocString(this.question.locHtml)));const s=o.createHtmlContainerBlock(o.getLocString(this.question.locHtml),this.controller,this.style.text);if(e==="image"){const i=o.getPageAvailableWidth(this.controller),{url:n,aspect:r}=await o.htmlToImage(s,i,this.controller),l=i/r;return[await o.createImageFlat(t,this.question,this.controller,{link:n,width:i,height:l})]}return[o.splitHtmlRect(this.controller,await o.createHTMLFlat(t,this.controller,this.correctHtml(s),this.style.text))]}}D.Serializer.removeProperty("html","renderAs"),D.Serializer.addProperty("html",{name:"renderAs",default:"auto",visible:!1,choices:["auto","standard","image"]}),_.getInstance().register("html",Oe);class _e extends tt{async getCorrectImageSize(){return await o.getCorrectedImageSize(this.controller,{imageWidth:this.question.imageWidth,imageHeight:this.question.imageHeight,imageLink:this.question.imageLink})}async generateFlatsContent(t){const e=await this.getCorrectImageSize();return[await o.createImageFlat(t,this.question,this.controller,{link:this.question.imageLink,width:e.width,height:e.height})]}}_.getInstance().register("image",_e);class Ne extends tt{get radioGroupWrap(){return this._radioGroupWrap||(this._radioGroupWrap=new $t(this.controller,{readOnly:this.question.isReadOnly,fieldName:this.question.id,updateOptions:t=>{this.survey.getUpdatedRadioGroupWrapOptions(t,this.question)}})),this._radioGroupWrap}getInputStyle(t,e,s){const i=s?"checkbox":"radio",n=o.mergeObjects({},this.style.input,this.style[`${i}Input`]);return t&&(o.mergeObjects(n,this.style.inputReadOnly,this.style[`${i}InputReadOnly`]),e&&o.mergeObjects(n,this.style.inputReadOnlyChecked,this.style[`${i}InputReadOnlyChecked`])),n}async generateFlatItem(t,e,s){const i=o.getPageAvailableWidth(this.controller),n=this.question.isReadOnly||!e.isEnabled,r=this.question.isItemSelected(e),l=n&&o.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,a=o.mergeObjects({},this.getInputStyle(n,r,this.question.multiSelect)),h=await o.createImageFlat(t,this.question,this.controller,{link:e.imageLink,width:i,height:i/this.style.imageRatio}),u=new E(h);let g=o.createPoint(u);if(this.question.showLabel){let M=await o.createTextFlat(g,this.controller,e.text||e.value,{...this.style.choiceText});u.addBrick(M),g=o.createPoint(M)}g.yTop+=this.style.spacing.imageInputGap;const b=a.height,T=o.createRect(g,i,b);return this.question.multiSelect?u.addBrick(new Ut(this.controller,T,{fieldName:this.question.id+"index"+s,readOnly:n,checked:r,shouldRenderReadOnly:l,updateOptions:M=>this.survey.updateCheckItemAcroformOptions(M,this.question,{item:e})},a)):u.addBrick(new Nt(this.controller,T,this.radioGroupWrap,{index:s,checked:r,shouldRenderReadOnly:l,updateOptions:M=>this.survey.updateRadioItemAcroformOptions(M,this.question,{item:e})},a)),u}getColumnsInfo(){const{imageMinWidth:t,imageMaxWidth:e}=this.style,{choiceColumnGap:s}=this.style.spacing,i=o.getPageAvailableWidth(this.controller);let n=this.question.colCount==0?this.question.visibleChoices.length:this.question.colCount,r;const l=()=>Math.max(Math.min((i-s*(n-1))/n,e),1);return t*n+s*(n-1)<i||(n=Math.max(Math.ceil((i+s)/(t+s)),1)),r=l(),{columnsCount:n,columnWidth:r}}async generateFlatsContent(t){const e=[new E],{columnsCount:s,columnWidth:i}=this.getColumnsInfo(),n=Math.ceil(this.question.visibleChoices.length/s),r=o.clone(t);for(let l=0;l<n;l++){let a=r.yTop;this.controller.pushMargins();let h=this.controller.margins.left;for(let u=0;u<s;u++){const g=l*s+u;if(g==this.question.visibleChoices.length)break;this.controller.margins.left=h,this.controller.margins.right=this.controller.paperWidth-h-i,r.xLeft=this.controller.margins.left;const b=await this.generateFlatItem(r,this.question.visibleChoices[g],g);e[e.length-1].addBrick(b),h=this.controller.paperWidth-this.controller.margins.right+this.style.spacing.choiceColumnGap,a=Math.max(a,b.yBot)}this.controller.popMargins(),r.xLeft=t.xLeft,r.yTop=a,l!==n-1&&(e[e.length-1].addBrick(o.createRowlineFlat(r,this.controller)),r.yTop+=this.style.spacing.choiceGap,e.push(new E))}return e}}_.getInstance().register("imagepicker",Ne);class Ee extends tt{async generateFlatsContent(t){const e=[],s=o.clone(t);for(const i of this.question.panels){const n=await o.generatePanelFlats(this.survey,this.controller,i,s);n.length!==0&&(s.yTop=o.mergeRects(...n).yBot,s.yTop+=this.style.spacing.panelGap,e.push(...n))}return e}}_.getInstance().register("paneldynamic",Ee);class ue extends he{get radioGroupWrap(){return this._radioGroupWrap||(this._radioGroupWrap=new $t(this.controller,{readOnly:this.question.isReadOnly,fieldName:this.question.id,updateOptions:t=>{this.survey.getUpdatedRadioGroupWrapOptions(t,this.question)}})),this._radioGroupWrap}generateFlatItem(t,e,s,i){const n=o.createRect(t,i.width,i.height);return new Nt(this.controller,n,this.radioGroupWrap,{index:s,checked:this.question.isItemSelected(e),shouldRenderReadOnly:this.radioGroupWrap.readOnly&&o.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,updateOptions:r=>this.survey.updateRadioItemAcroformOptions(r,this.question,{item:e})},o.getPatchedTextStyle(this.controller,{...i}))}}_.getInstance().register("radiogroup",ue),_.getInstance().register("buttongroup",ue);class He extends pt{constructor(t,e,s,i){super(t,e),this.options=s,this.style=i}async renderInteractive(){var t;const e=o.createRectInsideBorders(this.contentRect,(t=this.style.borderWidth)!==null&&t!==void 0?t:0),s=e.xRight-e.xLeft,i=e.yBot-e.yTop,n=o.createAcroformRect(e);if(this.style.backgroundColor&&(this.controller.setFillColor(this.style.backgroundColor),this.controller.doc.rect(...n,"F"),this.controller.restoreFillColor()),o.renderFlatBorders(this.controller,this.contentRect,this.style),this.options.mark){const r=o.createPoint(e,!0,!0),l={...this.style},a=this.controller.measureText(this.options.mark,l);r.xLeft+=s/2-a.width/2,r.yTop+=i/2-a.height/2,await(await o.createTextFlat(r,this.controller,this.options.mark,l)).render()}else{this.controller.setFillColor(this.style.fontColor);let r=o.createRect(e,this.style.fontSize,this.style.fontSize/7);r=o.moveRect(r,r.xLeft+s/2-(r.xRight-r.xLeft)/2,r.yTop+i/2-(r.yBot-r.yTop)/2),this.controller.doc.rect(...o.createAcroformRect(r),"F"),this.controller.restoreFillColor()}}}class Ge extends pt{constructor(t,e,s){super(t,e),this.options=s}async renderInteractive(){var t,e;this.controller.setFillColor(this.options.color||"black");const{xLeft:s,yTop:i,width:n,height:r}=this.contentRect;this.controller.doc.rect(s,i,(t=this.options.renderWidth)!==null&&t!==void 0?t:n,(e=this.options.renderHeight)!==null&&e!==void 0?e:r,"F"),this.controller.restoreFillColor()}}class De extends tt{async generateFlatComposite(t,e,s,i=!1){const n=new He(this.controller,o.createRect(t,this.style.input.width,this.style.input.height),{mark:i?"-":this.question.getNumberByIndex(s)||""},o.getPatchedTextStyle(this.controller,this.style.input)),r=o.clone(t);r.xLeft=n.xRight+this.style.spacing.choiceTextGap;const l=await o.createTextFlat(r,this.controller,e.locText,this.style.choiceText);return o.alignVerticallyBricks("center",n,l.unfold()[0]),new E(n,l)}async generateChoicesColumn(t,e,s=!1){const i=o.clone(t),n=[];for(let r=0;r<e.length;r++){const l=await this.generateFlatComposite(i,e[r],r,s);i.yTop=l.yBot+this.style.spacing.choiceGap,n.push(l)}return n}async generateSelectToRankItemsVertically(t){const e=o.clone(t),s=[];this.question.rankingChoices.length!==0&&(s.push(...await this.generateChoicesColumn(e,this.question.rankingChoices)),e.yTop=s[s.length-1].yBot+2*this.style.spacing.choiceGap);const i=o.createRect({xLeft:e.xLeft,yTop:e.yTop-this.style.spacing.choiceGap-.5},this.controller.paperWidth-this.controller.margins.right-e.xLeft,this.style.selectToRankAreaSeparator.width);return s.push(new Ge(this.controller,i,{color:this.style.selectToRankAreaSeparator.color})),s.push(...await this.generateChoicesColumn(e,this.question.unRankingChoices,!0)),s}async generateSelectToRankItemsHorizontally(t){const s=o.clone(t),i=[],n=Math.max(this.question.unRankingChoices.length,this.question.rankingChoices.length);let r=new E;for(let l=0;l<n;l++){let a=0;for(let b of[this.question.unRankingChoices[l],this.question.rankingChoices[l]]){if(b){this.controller.pushMargins(this.controller.margins.left,this.controller.margins.right),o.setColumnMargins(this.controller,2,a,this.style.spacing.choiceColumnGap),s.xLeft=this.controller.margins.left;const T=await this.generateFlatComposite(s,b,l,a==0);r.addBrick(T),this.controller.popMargins()}a++}const h=o.createRowlineFlat(o.createPoint(r),this.controller);i.push(r,h);const u=o.createRect({xLeft:this.controller.margins.left+o.getPageAvailableWidth(this.controller)/2-.5,yTop:s.yTop},0,0),g=this.style.spacing.choiceGap;r.addBrick(new Ge(this.controller,u,{color:this.style.selectToRankAreaSeparator.color,renderWidth:this.style.selectToRankAreaSeparator.width,renderHeight:h.yBot-s.yTop+(l!==n-1?g:0)})),s.yTop=h.yBot+g,r=new E}return i}async generateFlatsContent(t){return this.question.selectToRankEnabled?this.question.selectToRankAreasLayout=="vertical"?this.generateSelectToRankItemsVertically(t):this.generateSelectToRankItemsHorizontally(t):this.generateChoicesColumn(t,this.question.rankingChoices)}}_.getInstance().register("ranking",De);class ze extends tt{get radioGroupWrap(){return this._radioGroupWrap||(this._radioGroupWrap=new $t(this.controller,{readOnly:this.question.isReadOnly,fieldName:this.question.id,updateOptions:t=>{this.survey.getUpdatedRadioGroupWrapOptions(t,this.question)}})),this._radioGroupWrap}getItemWidth(t){return Math.min(Math.max(this.controller.measureText(t,{...this.style.choiceText}).width,this.style.choiceMinWidth),o.getPageAvailableWidth(this.controller))}getItemText(t,e){const s=new D.LocalizableString(e.owner,e.useMarkdown);return s.text=o.getLocString(e),t===0&&this.question.minRateDescription?s.text=this.question.locMinRateDescription.text+" "+o.getLocString(e):t===this.question.visibleRateValues.length-1&&this.question.maxRateDescription&&(s.text=o.getLocString(e)+" "+this.question.locMaxRateDescription.text),s}getInputStyle(t,e){const s={...this.style.input};return t&&(o.mergeObjects(s,this.style.inputReadOnly),e&&o.mergeObjects(s,this.style.inputReadOnlyChecked)),s}generateFlatItem(t,e,s){const i=this.question.isItemSelected(e),n=this.radioGroupWrap.readOnly&&o.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress;return new Nt(this.controller,t,this.radioGroupWrap,{index:s,checked:i,shouldRenderReadOnly:n,updateOptions:r=>this.survey.updateRadioItemAcroformOptions(r,this.question,{item:e})},o.getPatchedTextStyle(this.controller,this.getInputStyle(n,i)))}async generateItemComposite(t,e){const s=o.clone(t),i=new E,n=await o.createTextFlat(t,this.controller,e.locText,{...this.style.choiceText});return i.addBrick(n),s.yTop=n.yBot+this.style.spacing.choiceTextGap,i.addBrick(this.generateFlatItem(o.createRect(s,e.width,this.style.input.height),e.item,e.index)),i.translateX((r,l)=>{const a=(i.width-(l-r))/2;return{xLeft:r+a,xRight:l+a}}),i}getRows(){const t=[];let e=0,s=0;const i=o.getPageAvailableWidth(this.controller);let n=i;return this.question.visibleRateValues.forEach((r,l)=>{const a=this.getItemText(l,r.locText),h=this.getItemWidth(a),u={index:l,item:r,locText:a,width:h},g=h+(s==0?0:this.style.spacing.choiceColumnGap);s!==0&&g>n?(e++,n=i-h):n-=g,s++,t.length<=e&&t.push([]),t[e].push(u)}),t}async generateFlatsContent(t){const e=o.clone(t),s=[],i=this.getRows();for(const n of i){const r=new E;for(const l of n)this.controller.pushMargins(),this.controller.margins.left=e.xLeft,this.controller.margins.right=o.getPageAvailableWidth(this.controller)-l.width-e.xLeft,r.addBrick(await this.generateItemComposite(e,l)),this.controller.popMargins(),e.xLeft=r.xRight+this.style.spacing.choiceColumnGap;r.addBrick(o.createRowlineFlat(e,this.controller,r.width)),n!==i[i.length-1]&&(e.yTop=r.yBot+this.style.spacing.choiceGap,e.xLeft=r.xLeft),s.push(r)}return s}}_.getInstance().register("rating",ze);class Qe extends tt{async generateFlatsContent(t){let e=o.clone(t);if(this.question.sliderType==="single"){const s=this.getOptionsByValue(this.question.value);return[await this.generateInputBrick(e,s)]}if(this.question.sliderType==="range"){const s=new E,i=[];for(let r=0;r<this.question.renderedValue.length;r++){const l=this.question.renderedValue[r],a=this.getOptionsByValue(l.toString()),h=o.clone(t);if(this.controller.pushMargins(),o.setColumnMargins(this.controller,2,r,this.style.spacing.inputRangeGap),h.xLeft=this.controller.margins.left,r>0){const g=o.clone(h);g.xLeft-=this.style.spacing.inputRangeGap-(this.style.spacing.inputRangeGap-this.style.rangeSeparator.width)/2,i.push(new It(this.controller,{...g,xRight:g.xLeft+this.style.rangeSeparator.width,yBot:g.yTop+this.style.rangeSeparator.height},this.style.rangeSeparator))}const u=await this.generateInputBrick(h,a);this.controller.popMargins(),i.push(u)}const n=o.mergeRects(...i);return i.forEach(r=>r.translateY((l,a)=>{const h=(n.yBot-n.yTop-a+l)/2;return{yTop:l+h,yBot:a+h}})),s.addBrick(...i),[s]}}getOptionsByValue(t){const{id:e,isReadOnly:s}=this.question;return{fieldName:e,inputType:"number",value:t,isReadOnly:s,shouldRenderReadOnly:o.shouldRenderReadOnly(this.question,this.controller,s),shouldRenderBorders:!0}}async generateInputBrick(t,e){const s=o.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),i=o.getPatchedTextStyle(this.controller,o.mergeObjects({},this.style.input,s?this.style.inputReadOnly:void 0));return await o.createCommentFlat(t,this.controller,{...e,shouldRenderReadOnly:s},i)}}_.getInstance().register("slider",Qe);class Et extends tt{get signatureSize(){if(!this._signatureSize){let t=o.pxToPt(this.question.signatureWidth),e=o.pxToPt(this.question.signatureHeight);const s=o.getPageAvailableWidth(this.controller);if(t>s){const i=s;e*=i/t,t=i}this._signatureSize={width:t,height:e}}return this._signatureSize}async generateBackgroundImage(t){return await o.createImageFlat(t,this.question,this.controller,{link:this.question.backgroundImage,...this.signatureSize,objectFit:"cover"},!0)}getSignImageUrl(){return this.question.storeDataAsText||!this.question.loadedData?this.question.value:this.question.loadedData}async generateSign(t){let e;return this.question.value?e=await o.createImageFlat(t,this.question,this.controller,{link:this.getSignImageUrl(),...this.signatureSize},!1):e=new It(this.controller,o.createRect(t,this.signatureSize.width,this.signatureSize.height)),Et.BORDER_STYLE!=="none"&&(e.afterRenderCallback=()=>{const s={height:e.width,width:e.width,yTop:e.yTop,yBot:e.yBot,xLeft:e.xLeft,xRight:e.xRight};o.renderFlatBorders(this.controller,s,{...this.style.input,dashStyle:Et.BORDER_STYLE=="dashed"?{dashArray:[5],dashPhase:0}:void 0})}),e}async generateFlatsContent(t){const e=new E;return this.question.backgroundImage&&e.addBrick(await this.generateBackgroundImage(t)),e.addBrick(await this.generateSign(t)),[e]}}Et.BORDER_STYLE="dashed",_.getInstance().register("signaturepad",Et);class Yt extends tt{async generateFlatsContent(t){const e=o.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),s=o.getPatchedTextStyle(this.controller,o.mergeObjects({},this.style.input,e?this.style.inputReadOnly:void 0)),i={fieldName:this.question.id,inputType:this.question.inputType,value:this.question.value?this.question.inputValue:"",isReadOnly:this.question.isReadOnly,shouldRenderReadOnly:e,shouldRenderBorders:D.settings.readOnlyTextRenderMode==="input",placeholder:o.getLocString(this.question.locPlaceHolder)||this.question.inputValue};return[await o.createCommentFlat(t,this.controller,{shouldRenderReadOnly:e,rows:Yt.MULTILINE_TEXT_ROWS_COUNT,...i},s)]}}Yt.MULTILINE_TEXT_ROWS_COUNT=1,_.getInstance().register("text",Yt);class Ue{popRowlines(t){for(;t.length>0&&t[t.length-1]instanceof oe;)t.pop()}constructor(t,e,s){this.survey=t,this.controller=e,this.style=s}async generateFlatTitle(t){const e=new E;if(this.survey.showTitle){const s=this.style;if(this.survey.title){const i={...s.title},n=await o.createTextFlat(t,this.controller,this.survey.locTitle,i);e.addBrick(n),t=o.createPoint(n)}this.survey.description&&(this.survey.title&&(t.yTop+=s.spacing.titleDescriptionGap),e.addBrick(await o.createTextFlat(t,this.controller,this.survey.locDescription,{...s.description})))}return e}async generateFlatLogoImage(t){const e=o.getLocString(this.survey.locLogo),s=await o.getCorrectedImageSize(this.controller,{imageLink:e,imageHeight:this.survey.logoHeight,imageWidth:this.survey.logoWidth,defaultImageWidth:"300px",defaultImageHeight:"200px"}),i=await o.createImageFlat(t,null,this.controller,{link:e,width:s.width,height:s.height});let n=0;return this.survey.logoPosition==="right"?n=o.getPageAvailableWidth(this.controller)-i.width:this.survey.logoPosition!=="left"&&(n=o.getPageAvailableWidth(this.controller)/2-i.width/2),i.xLeft+=n,i.xRight+=n,i}async generateFlats(){const t=[],e=new qt(this.controller,{...this.controller.leftTopPoint,width:o.getPageAvailableWidth(this.controller)},this.style.header);await e.setup(async(i,n)=>{if(this.survey.hasLogo)if(this.survey.isLogoBefore){const r=await this.generateFlatLogoImage(i);n.push(r);const l=o.createPoint(r,this.survey.logoPosition==="top",this.survey.logoPosition!=="top");this.survey.logoPosition!=="top"?(this.controller.pushMargins(),l.xLeft+=this.controller.unitWidth,this.controller.margins.left+=r.width+this.controller.unitWidth):(l.xLeft=i.xLeft,l.yTop+=this.controller.unitHeight/2);const a=await this.generateFlatTitle(l);this.survey.logoPosition!=="top"&&this.controller.popMargins(),a.isEmpty||n.push(a)}else if(this.survey.logoPosition==="right"){const r=await this.generateFlatLogoImage(i);n.push(r),this.controller.pushMargins(),this.controller.margins.right+=r.width+this.controller.unitWidth;const l=await this.generateFlatTitle(i);l.isEmpty||n.unshift(l),this.controller.popMargins()}else{const r=await this.generateFlatTitle(i);let l=i;r.isEmpty||(n.push(r),l=o.createPoint(r),l.yTop+=this.controller.unitHeight/2);const a=await this.generateFlatLogoImage(l);n.length,n.push(a)}else{const r=await this.generateFlatTitle(i);r.isEmpty||n.push(r)}}),e.isEmpty||t.push(e.getBricks());let s=this.controller.leftTopPoint;t.length!==0&&(s.yTop=o.createPoint(o.mergeRects(...t[0])).yTop,t[0].push(o.createRowlineFlat(s,this.controller)),s.yTop+=this.style.spacing.headerContentGap+o.EPSILON);for(let i=0;i<this.survey.visiblePages.length;i++){this.survey.currentPage=this.survey.visiblePages[i];let n=await o.generatePageFlats(this.survey,this.controller,this.survey.currentPage,s);i===0&&t.length!==0?t[0].push(...n):t.push(n),this.popRowlines(t[t.length-1]),s.yTop=this.controller.leftTopPoint.yTop}return t}}_.registerSurvey(Ue);class $e extends tt{async generateFlatsContent(t){const e=o.getPageAvailableWidth(this.controller),s=this.question.hasRows?this.question.rowTitleWidth?o.parseWidth(this.question.rowTitleWidth,e):this.style.columnMinWidth:0,i=e-s,n=this.question.renderAs==="list"||this.controller.matrixRenderAs==="list"||this.style.columnMinWidth*this.question.visibleColumns.length+this.style.spacing.tableColumnGap*(this.question.visibleColumns.length-1)>i;return new(n?Fs:Rs)(this.controller,this.survey,this.question,this.style).generateFlats(t)}}class Ye{constructor(t,e,s,i){this.controller=t,this.survey=e,this.question=s,this.style=i,this.radioGroupWraps={}}async generateFlatCell(t,e){const s=new qt(this.controller,{...t,width:o.getPageAvailableWidth(this.controller)},this.style.cell);return await s.setup(async(i,n)=>{await e(i,n)}),s}async generateTextComposite(t,e){const{item:s,row:i}=e,n=o.clone(t),r=this.generateFlatItem(n,e);n.yTop=r.yBot+this.style.spacing.gapBetweenItemText;const l=await o.createTextFlat(n,this.controller,this.question.getCellDisplayLocText(i.name,s));return new E(r,l)}getRadioGroupWrap(t,e,s){return this.radioGroupWraps[t]||(this.radioGroupWraps[t]=new $t(this.controller,{readOnly:this.question.isReadOnly,fieldName:t,updateOptions:i=>{this.survey.getUpdatedRadioGroupWrapOptions(i,this.question,{row:e,rowIndex:s})}})),this.radioGroupWraps[t]}getInputStyle(t,e,s){const i=s?"checkbox":"radio",n=o.mergeObjects({},this.style.input,this.style[`${i}Input`]);return t&&(o.mergeObjects(n,this.style.inputReadOnly,this.style[`${i}InputReadOnly`]),e&&o.mergeObjects(n,this.style.inputReadOnlyChecked,this.style[`${i}InputReadOnlyChecked`])),n}generateFlatItem(t,e){const{item:s,row:i,itemIndex:n,rowIndex:r}=e,l=this.question.id+"row"+r,a=i.isChecked(s),h=this.question.isReadOnly,u=h&&o.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,g=o.getPatchedTextStyle(this.controller,this.getInputStyle(u,a,this.question.isMultiSelect)),b=o.createRect(t,g.width,g.height);if(this.question.isMultiSelect)return new Ut(this.controller,b,{fieldName:l+"index"+n,checked:a,shouldRenderReadOnly:u,readOnly:h,updateOptions:T=>{this.survey.updateCheckItemAcroformOptions(T,this.question,{item:s,row:i,rowIndex:r})}},g);{const T=this.getRadioGroupWrap(l,i,r);return new Nt(this.controller,b,T,{checked:a,index:n,shouldRenderReadOnly:u,updateOptions:M=>this.survey.updateRadioItemAcroformOptions(M,this.question,{item:s,row:i,rowIndex:r})},g)}}getGapBetweenRows(){return this.style.spacing.tableRowGap}async generateFlats(t){const e=[];let s=o.clone(t);for(let i=0;i<this.question.visibleRows.length;i++){const n=await this.generateFlatsRow(s,this.question.visibleRows[i],i);s=o.createPoint(o.mergeRects(...n)),s.yTop+=this.getGapBetweenRows(),e.push(...n)}return e}}class Fs extends Ye{async generateItemComposite(t,e){const s=o.clone(t),i=this.generateFlatItem(t,e);s.xLeft=i.xRight+this.style.spacing.listChoiceTextGap;const n=await o.createTextFlat(s,this.controller,e.item.locText,o.mergeObjects({},this.style.columnTitle,this.style.listChoiceText));return o.alignVerticallyBricks("center",i,n.unfold()[0]),n.updateRect(),new E(i,n)}getGapBetweenRows(){return this.style.spacing.listSectionGap}async generateFlatsRow(t,e,s){const i=o.clone(t),n=await this.generateFlatCell(i,async(r,l)=>{const a=o.clone(r),h=await o.createTextFlat(r,this.controller,e.locText,o.mergeObjects({},this.style.rowTitle,this.style.listSectionTitle));l.push(h),a.yTop=h.yBot+this.style.spacing.listItemTitleContentGap;for(let u=0;u<this.question.visibleColumns.length;u++){const g=await(this.question.hasCellText?this.generateTextComposite:this.generateItemComposite).call(this,a,{item:this.question.visibleColumns[u],itemIndex:u,row:e,rowIndex:s});l.push(g),a.yTop=g.yBot+this.style.spacing.listChoiceGap}});return[n,o.createRowlineFlat(o.createPoint(n),this.controller)]}}class Rs extends Ye{setup(){const t=o.getPageAvailableWidth(this.controller);this.question.rowTitleWidth?this.rowTitleWidth=o.parseWidth(this.question.rowTitleWidth,t):this.rowTitleWidth=o.getColumnWidth(this.controller,this.question.visibleColumns.length+(this.question.hasRows?1:0),this.style.spacing.tableColumnGap),this.controller.pushMargins(),this.controller.margins.left+=this.rowTitleWidth+this.style.spacing.tableColumnGap,this.columnWidth=o.getColumnWidth(this.controller,this.question.visibleColumns.length,this.style.spacing.tableColumnGap),this.controller.popMargins()}async generateFlatsRow(t,e,s){const i=[],n=o.clone(t);this.question.hasRows&&(this.controller.pushMargins(),n.xLeft=this.controller.margins.left,this.controller.margins.right+=o.getPageAvailableWidth(this.controller)-this.rowTitleWidth,i.push(await this.generateFlatCell(n,async(a,h)=>{h.push(await o.createTextFlat(a,this.controller,e.locText,this.style.rowTitle))})),n.xLeft+=this.rowTitleWidth+this.style.spacing.tableColumnGap,this.controller.popMargins());for(let a=0;a<this.question.visibleColumns.length;a++){this.controller.pushMargins(),this.controller.margins.left=t.xLeft;const h={item:this.question.visibleColumns[a],itemIndex:a,rowIndex:s,row:e};this.controller.margins.right+=o.getPageAvailableWidth(this.controller)-this.columnWidth,i.push(await this.generateFlatCell(n,async(u,g)=>{this.question.hasCellText?g.push(await this.generateTextComposite(u,h)):g.push(this.generateFlatItem(u,h))})),n.xLeft+=this.columnWidth+this.style.spacing.tableColumnGap,this.controller.popMargins()}const r=o.mergeRects(...i);i.forEach(a=>{a.fitToHeight(r.yBot-r.yTop,!0)});const l=new E(...i);return[l,o.createRowlineFlat(o.createPoint(l),this.controller)]}async generateFlatsHeader(t){const e=[],s=o.clone(t);this.question.hasRows&&(this.controller.margins.left=s.xLeft,this.controller.margins.right+=o.getPageAvailableWidth(this.controller)-this.rowTitleWidth,e.push(await this.generateFlatCell(s,async(r,l)=>{l.push(new It(this.controller,o.createRect(r,o.getPageAvailableWidth(this.controller),1)))})),s.xLeft+=this.rowTitleWidth+this.style.spacing.tableColumnGap);for(let r=0;r<this.question.visibleColumns.length;r++)this.controller.pushMargins(),this.controller.margins.left=s.xLeft,this.controller.margins.right+=o.getPageAvailableWidth(this.controller)-this.columnWidth,e.push(await this.generateFlatCell(s,async(l,a)=>{a.push(await o.createTextFlat(l,this.controller,this.question.visibleColumns[r].locText,{...this.style.columnTitle}))})),s.xLeft+=this.columnWidth+this.style.spacing.tableColumnGap,this.controller.popMargins();const i=o.mergeRects(...e);e.forEach(r=>{r.fitToHeight(i.yBot-i.yTop,!0)});const n=new E(...e);return[n,o.createRowlineFlat(o.createPoint(n),this.controller)]}async generateFlats(t){this.setup();const e=o.clone(t),s=await this.generateFlatsHeader(t);e.yTop=o.mergeRects(...s).yBot+this.style.spacing.tableRowGap;const i=await super.generateFlats(e);return[...s,...i]}}D.Serializer.removeProperty("matrix","renderAs"),D.Serializer.addProperty("matrix",{name:"renderAs",default:"auto",visible:!1,choices:["auto","list"]}),_.getInstance().register("matrix",$e);class Xt{constructor(t,e){this.controller=t,this.options=e}getColSpan(){var t;return(t=this.options.colSpan)!==null&&t!==void 0?t:1}async generateFlats(t,e){const s=new qt(this.controller,{...t,width:e},this.options.style.container);return await s.setup(async(i,n)=>{n.push(...await this.generateContentFlats(i))}),s}}class Kt extends Xt{getColSpan(){return 1}async generateContentFlats(t){const{question:e,flatQuestionFabric:s}=this.options;return e.titleLocation="matrix",await s(e).generateFlats(t)}}class Ts extends Xt{async generateContentFlats(t){const{question:e,flatQuestionFabric:s}=this.options,i=s(e);return[i.generateFlatItem(t,this.options.item,this.options.index,i.getItemStyle(this.options.item).input)]}}class Jt extends Xt{async generateContentFlats(t){return[await o.createTextFlat(t,this.controller,this.options.locText,this.options.style.text)]}}class de extends Xt{async generateContentFlats(t){return[new It(this.controller,o.createRect(t,o.getPageAvailableWidth(this.controller),0))]}}class js extends Xt{async generateContentFlats(t){return await this.options.flatPanelFabric(this.options.panel).generateFlats(t)}}class Cs extends Kt{async generateContentFlats(t){const e=[],s=await o.createTextFlat(t,this.controller,this.options.locTitle,this.options.style.title);e.push(s);const i=o.createPoint(s,!0,!1);return i.yTop+=this.options.style.contentGap,e.push(...await super.generateContentFlats(i)),e}}class fe extends tt{getMatrixRows(){return this.controller.dynamicContent.conditionalMatrixRows?this.question.allRows:this.question.visibleRows}isMatrixColumnVisible(t){return t.visible&&(this.controller.dynamicContent.conditionalMatrixColumns||t.isColumnVisible)}getMatrixColumnDescriptors(){const t=[];for(const e of this.question.columns.filter(s=>this.isMatrixColumnVisible(s)))if(e.showInMultipleColumns)for(const s of this.getMultipleColumnChoices(e))t.push({minWidth:e.minWidth,width:e.width,locTitle:s.locTitle});else t.push({minWidth:e.minWidth,width:e.width,locTitle:e.locTitle});return t}getColumnsAvalableWidth(t){return o.getPageAvailableWidth(this.controller)-(t-1)*this.style.spacing.tableColumnGap}getPredefinedTransposedColumnWidths(){const t=[];this.question.showHeader&&t.push({minWidth:this.question.rowTitleWidth,width:this.question.rowTitleWidth});let e=this.getMatrixRows().length;this.question.hasTotal&&e++;for(let s=0;s<e;s++)t.push({width:"",minWidth:""});return t}getPredefinedColumnWidts(){const t=[];this.question.hasRowText&&t.push({minWidth:this.question.rowTitleWidth,width:this.question.rowTitleWidth});for(const e of this.getMatrixColumnDescriptors())t.push({width:e.width,minWidth:e.minWidth});return t}calculateColumnWidth(t){const e=o.getPageAvailableWidth(this.controller),s=[],i=t.length;let n=i,r=this.getColumnsAvalableWidth(i);const l=[],a=this.style.columnMinWidth;for(let h=0;h<i;h++){let u=Math.max(o.parseWidth(t[h].width,e,i)||0);u!==0?(u=Math.max(u,a,o.parseWidth(t[h].minWidth,e,i)||0),r-=u,n--):l.push(t[h]),s.push(u)}return n===0||l.sort((h,u)=>{let g=o.parseWidth(h.minWidth,e,i)||0;return(o.parseWidth(u.minWidth,e,i)||0)>g?1:-1}).forEach(h=>{const u=r/n,g=o.parseWidth(h.minWidth,e,i)||0;g>u&&g>a&&(r-=g,n--),s[t.indexOf(h)]=Math.max(a,g,u)}),s}getMultipleColumnChoices(t){var e=t.templateQuestion.choices;return e&&Array.isArray(e)&&e.length==0?[].concat(this.question.choices,t.getVisibleMultipleChoices()):(e=t.getVisibleMultipleChoices(),!e||!Array.isArray(e)?null:e)}buildTableCore(t,e,s=!0,i=!1){const n=[],r=u=>o.getFlatQuestion(this.survey,this.controller,u),l=u=>o.getFlatPanel(this.survey,this.controller,u),a=this.getMatrixRows();if(this.question.showHeader){const u=[];this.question.hasRowText&&u.push(new de(this.controller,{style:{container:this.style.cell}}));const g=this.getMatrixColumnDescriptors().map(b=>new Jt(this.controller,{style:{container:this.style.cell,text:t},locText:b.locTitle}));u.push(...g),n.push(u)}const h=[];for(const u of a){const g=[];this.question.hasRowText&&g.push(new Jt(this.controller,{style:{container:this.style.cell,text:e},locText:u.locText}));const b=[];for(const T of u.cells.filter(M=>this.isMatrixColumnVisible(M.column)))if(T.column.showInMultipleColumns){let M;for(const[Z,st]of T.question.visibleChoices.entries())b.push(new Ts(this.controller,{style:{container:this.style.cell},item:st,index:Z,question:T.question,flatQuestionFabric:lt=>(M||(M=r(lt)),M)}))}else b.push(new Kt(this.controller,{style:{container:this.style.cell},question:T.question,flatQuestionFabric:r}));if(g.push(...b),h.push(g),u.hasPanel&&s){const T=[];u.showDetailPanel(),this.question.hasRowText&&T.push(new de(this.controller,{style:{container:this.style.cell}})),T.push(new js(this.controller,{style:{container:{}},panel:u.detailPanel,flatPanelFabric:l,colSpan:this.getMatrixColumnDescriptors().length})),h.push(T)}}if(n.push(...h),this.question.hasTotal){const u=[];this.question.hasRowText&&u.push(new Jt(this.controller,{style:{container:this.style.cell,text:e},locText:this.question.getFooterText()}));const g=[];for(const b of this.question.visibleTotalRow.cells.filter(T=>this.isMatrixColumnVisible(T.column)))if(b.question.isAnswered)if(b.column.showInMultipleColumns)for(const T of this.getMultipleColumnChoices(b.column))g.push(new Kt(this.controller,{style:{container:this.style.cell},question:b.question,flatQuestionFabric:r}));else g.push(new Kt(this.controller,{style:{container:this.style.cell},question:b.question,flatQuestionFabric:r}));else g.push(new de(this.controller,{style:{container:this.style.cell}}));u.push(...g),n.push(u)}return n}buildTable(){return this.buildTableCore(this.style.columnTitle,this.style.rowTitle)}buildTransposedTable(){const t=this.buildTableCore(this.style.rowTitle,this.style.columnTitle,!1,!1);return t.length>0?t[0].map((e,s)=>t.map(i=>i[s])):t}buildListTable(){const t=[],e=s=>{const i=n=>o.getFlatQuestion(this.survey,this.controller,n);return this.question.showHeader?new Cs(this.controller,{style:{container:this.style.cell,contentGap:this.style.spacing.listItemTitleContentGap,title:o.mergeObjects({},this.style.columnTitle,this.style.listItemTitle)},question:s.question,locTitle:s.column.locTitle,flatQuestionFabric:i}):new Kt(this.controller,{style:{container:this.style.cell},question:s.question,flatQuestionFabric:i})};for(const s of this.getMatrixRows()){const i=[];this.question.hasRowText&&i.push(new Jt(this.controller,{style:{container:o.mergeObjects({},this.style.cell,this.style.listSectionTitleContainer),text:o.mergeObjects({},this.style.rowTitle,this.style.listSectionTitle)},locText:s.locText}));for(const n of s.cells.filter(r=>this.isMatrixColumnVisible(r.column)))i.push(e(n));t.push(i)}if(this.question.hasTotal){const s=[];this.question.hasRowText&&!this.question.getFooterText().isEmpty&&s.push(new Jt(this.controller,{style:{container:o.mergeObjects({},this.style.cell,this.style.listSectionTitleContainer),text:o.mergeObjects({},this.style.rowTitle,this.style.listSectionTitle)},locText:this.question.getFooterText()}));for(const i of this.question.visibleTotalRow.cells.filter(n=>this.isMatrixColumnVisible(n.column)))i.question.isAnswered&&s.push(e(i));t.push(s)}return t}calculateIsList(t,e){return this.question.renderAs==="list"||this.controller.matrixRenderAs==="list"||Math.floor(t.reduce((s,i)=>s+=i,0))>Math.floor(this.getColumnsAvalableWidth(e))}async generateFlatsContent(t){const e=this.question.transposeData?this.getPredefinedTransposedColumnWidths():this.getPredefinedColumnWidts();let s=this.calculateColumnWidth(e);const i=this.calculateIsList(s,e.length),n=i?this.buildListTable():this.question.transposeData?this.buildTransposedTable():this.buildTable();let r=o.clone(t);const l=[];for(const[a,h]of n.entries()){const u=[];for(const[Z,st]of h.entries()){let lt=i?o.getPageAvailableWidth(this.controller):s.slice(Z,Z+st.getColSpan()).reduce((X,K)=>X+=K,0);const z=await h[Z].generateFlats(r,lt);u.push(z),r=o.createPoint(z,i,!i),i?r.yTop+=this.style.spacing.tableRowGap:r.xLeft+=this.style.spacing.tableColumnGap}const{yBot:g,yTop:b}=o.mergeRects(...u),T=g-b;if(!i)for(const Z of u)Z.fitToHeight(T);const M=new E(...u);M.isEmpty||(r=o.createPoint(M,!0,!1),a!==n.length-1&&M.addBrick(o.createRowlineFlat(r,this.controller)),r.yTop=M.yBot+this.style.spacing.tableRowGap,l.push(M))}return l}}D.Serializer.removeProperty("matrixdropdown","renderAs"),D.Serializer.addProperty("matrixdropdown",{name:"renderAs",default:"auto",visible:!1,choices:["auto","list"]}),_.getInstance().register("matrixdropdown",fe);class Xe extends fe{}D.Serializer.removeProperty("matrixdynamic","renderAs"),D.Serializer.addProperty("matrixdynamic",{name:"renderAs",default:"auto",visible:!1,choices:["auto","list"]}),_.getInstance().register("matrixdynamic",Xe);class Ke extends tt{getVisibleRows(){return this.question.getRows().filter(t=>t.isVisible)}async generateFlatCell(t,e){const s=new qt(this.controller,{...t,width:o.getPageAvailableWidth(this.controller)},this.style.itemCell);return await s.setup(e),s}async generateFlatItemCells(t,e){const s=o.getPageAvailableWidth(this.controller),i=[];return this.controller.pushMargins(),this.controller.margins.right=this.controller.paperWidth-this.controller.margins.left-s*this.style.itemTitleWidthPercentage,i.push(await this.generateFlatCell(t,async(n,r)=>{r.push(await o.createTextFlat(n,this.controller,e.locTitle,{...this.style.itemTitle}))})),this.controller.popMargins(),this.controller.pushMargins(),this.controller.margins.left=t.xLeft+s*this.style.itemTitleWidthPercentage+this.style.spacing.itemTitleGap,i.push(await this.generateFlatCell({xLeft:this.controller.margins.left,yTop:t.yTop},async(n,r)=>{const l=_.getInstance().create(this.survey,e.editor,this.controller,this.survey.getElementStyle(e.editor),"text");r.push(...await l.generateFlatsContent(n))})),this.controller.popMargins(),i}async generateFlatsContent(t){const e=[],s=o.clone(t),i=this.getVisibleRows();for(let n=0;n<i.length;n++){this.controller.pushMargins();const r=[];for(let a=0;a<i[n].cells.length;a++)this.controller.pushMargins(),o.setColumnMargins(this.controller,this.question.colCount,a,this.style.spacing.itemColumnGap),s.xLeft=this.controller.margins.left,r.push(...await this.generateFlatItemCells(s,i[n].cells[a].item)),this.controller.popMargins();this.controller.popMargins(),s.xLeft=t.xLeft;const l=o.mergeRects(...r);r.forEach(a=>{a.fitToHeight(l.yBot-l.yTop)}),s.yTop=l.yBot,e.push(...r,o.createRowlineFlat(s,this.controller)),s.yTop+=this.style.spacing.itemGap}return e}}_.getInstance().register("multipletext",Ke);class Ps extends pt{constructor(t,e,s){super(e,s(e.helperDoc,t,0,0)),this.question=t,this.renderFunc=s}async renderInteractive(){await new Promise(t=>{this.renderFunc(this.controller.doc,this.question,this.contentRect.xLeft,this.contentRect.yTop),t()})}}D.checkLibraryVersion("3.2.2","survey-pdf");class ks extends Re{async _getImageInfo(t){const s=new Image;return s.crossOrigin="anonymous",await new Promise((n,r)=>{s.onload=()=>{const l=document.createElement("canvas"),a=l.getContext("2d"),h=window.devicePixelRatio||1;l.height=s.naturalHeight*h,l.width=s.naturalWidth*h,a?.drawImage(s,0,0,s.naturalWidth*h,s.naturalHeight*h);const u=l.toDataURL();n({data:u,width:s.naturalWidth*.75,height:s.naturalHeight*.75,id:this.getImageId()})},s.onerror=()=>{r()},s.src=t})}getCoverCanvasOptions(t,e,s,i){const n=t/e,r=s/i;let l,a;return r>n?(l=s,a=s/n):(a=i,l=i*n),{canvasWidth:s,canvasHeight:i,imageX:(s-l)/2,imageY:(i-a)/2,imageWidth:l,imageHeight:a}}async applyImageFit(t,e,s,i){if(e=="cover")try{const n=new Image;if(!t.width||!t.height||!t.data||!s||!i)return t;n.src=t.data instanceof Uint8Array?URL.createObjectURL(new Blob([t.data])):t.data,await n.decode();const r=this.getCoverCanvasOptions(t.width,t.height,s,i),l=document.createElement("canvas"),a=l.getContext("2d");return l.width=r.canvasWidth,l.height=r.canvasHeight,a?.drawImage(n,r.imageX,r.imageY,r.imageWidth,r.imageHeight),{data:l.toDataURL(),width:s,height:i}}catch{return t}else return super.applyImageFit(t,e,s,i)}}function Bs(m){const t=m.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+),?\s*([0-9.]+)?\)$/);if(!t)return null;const e=parseInt(t[1]),s=parseInt(t[2]),i=parseInt(t[3]),n=t[4]?parseFloat(t[4]):null,r=a=>{const h=a.toString(16);return h.length===1?"0"+h:h},l=n?r(Math.round(n*255)):"";return`#${r(e)}${r(s)}${r(i)}${l}`}function Is(m){const t=/color\s*\(\s*srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\s*(?:\/\s*([\d.]+))?\s*\)/i,e=m.match(t);if(e){const s=parseFloat(e[1]),i=parseFloat(e[2]),n=parseFloat(e[3]),r=e[4]?parseFloat(e[4]):1,l=Math.round(s*255),a=Math.round(i*255),h=Math.round(n*255);return`rgba(${l}, ${a}, ${h}, ${r})`}else return m}class Ls{setup(t){this.variables=t,this.hash={},this.container=document.createElement("div"),this.container.style.display="none",Object.keys(t).forEach(e=>{var s;(s=this.container)===null||s===void 0||s.style.setProperty(e,t[e])}),this.computedStyle=getComputedStyle(this.container)}startCollectingVariables(){var t;this.container&&!(!((t=this.container)===null||t===void 0)&&t.isConnected)&&document.body.appendChild(this.container)}stopCollectingVariables(){var t;(t=this.container)===null||t===void 0||t.remove()}getVariable(t,e){if(!this.container||!this.variables||!this.hash||!this.computedStyle)throw new Error("VariablesManager not initialized");return this.hash[t]||(this.hash[t]=e(this.computedStyle.getPropertyValue(t),this.container)),this.hash[t]}getSizeVariable(t){return this.getVariable(t,(e,s)=>{s.style.width=e;const i=getComputedStyle(s).width;return i.match(/px$/)?Number.parseFloat(i)*72/96:Number.parseFloat(i)})}getColorVariable(t){return this.getVariable(t,(e,s)=>{s.style.color=e;let i=getComputedStyle(s).color;return i=Is(i),Bs(i)})}}hs(new ks),ms(()=>new Ls),B.CheckItemBrick=Ut,B.CompositeBrick=E,B.CustomBrick=Ps,B.DocController=xt,B.DocOptions=Ct,B.DrawCanvas=ae,B.DropdownBrick=qe,B.EmptyBrick=It,B.EventHandler=ke,B.FlatBoolean=Ie,B.FlatCheckbox=ce,B.FlatComment=Me,B.FlatCustomModel=Le,B.FlatDropdown=Se,B.FlatExpression=Ae,B.FlatFile=We,B.FlatHTML=Oe,B.FlatImage=_e,B.FlatImagePicker=Ne,B.FlatMatrix=$e,B.FlatMatrixDynamic=Xe,B.FlatMatrixMultiple=fe,B.FlatMultipleText=Ke,B.FlatPage=Be,B.FlatPanel=le,B.FlatPanelDynamic=Ee,B.FlatQuestion=tt,B.FlatQuestionDefault=be,B.FlatRadiogroup=ue,B.FlatRanking=De,B.FlatRating=ze,B.FlatRepository=_,B.FlatSelectBase=he,B.FlatSignaturePad=Et,B.FlatSlider=Qe,B.FlatSurvey=Ue,B.FlatTextbox=Yt,B.HTMLBrick=ve,B.ImageBrick=we,B.LinkBrick=_t,B.PagePacker=zt,B.PdfBrick=pt,B.RadioItemBrick=Nt,B.RankingItemBrick=He,B.RowlineBrick=oe,B.SurveyHelper=o,B.SurveyPDF=Pt,B.TextBrick=Dt,B.TextFieldBrick=Fe}));