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 • 221 kB
JavaScript
/*!
* For license information please see survey.pdf.min.js.LICENSE.txt
*/
(function(k,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):(k=typeof globalThis<"u"?globalThis:k||self,D(k.SurveyPDF={},k.Survey,k.jspdf))})(this,(function(k,D,_t){"use strict";function Jt(...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 St(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 Je(m){return m&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m}var Lt={},te,de;function Ze(){return de||(de=1,te=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 o=Object.keys(t),l=Object.keys(e);if(o.length!==l.length)return!1;for(var a=Object.prototype.hasOwnProperty.bind(e),h=0;h<o.length;h++){var d=o[h];if(!a(d))return!1;var g=t[d],v=e[d];if(n=s?s.call(i,g,v,d):void 0,n===!1||n===void 0&&g!==v)return!1}return!0}),te}var fe;function Ve(){if(fe)return Lt;fe=1,Object.defineProperty(Lt,"__esModule",{value:!0});var m=Ze();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,d=h.getNodeHigh();h.left===void 0&&h.right!==void 0?h.max=Math.max(d,h.right.max):h.left!==void 0&&h.right===void 0?h.max=Math.max(d,h.left.max):h.left===void 0&&h.right===void 0?h.max=d:h.max=Math.max(Math.max(h.left.max,h.right.max),d);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,d=h.getNodeHigh();h.left===void 0&&h.right!==void 0?h.max=Math.max(d,h.right.max):h.left!==void 0&&h.right===void 0?h.max=Math.max(d,h.left.max):h.left===void 0&&h.right===void 0?h.max=d:h.max=Math.max(Math.max(h.left.max,h.right.max),d);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,d){if(a.key<=d&&h<=a.getNodeHigh()){for(var g=[],v=0;v<a.records.length;v++)a.records[v].high>=h&&g.push(a.records[v]);return g}return[]},l.prototype.search=function(a,h){if(this===void 0)return[];var d=[],g=[],v=[];return a>this.max?[]:(this.left!==void 0&&this.left.max>=a&&(d=this.left.search(a,h)),g=this._getOverlappingRecords(this,a,h),h<this.key?d.concat(g):(this.right!==void 0&&(v=this.right.search(a,h)),d.concat(g,v)))},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 d=this.right._minValue();return this.key=d.key,this.records=d.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})();Lt.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 d=0;d<h.records.length;d++)if(m(h.records[d],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 d=void 0,g=0;g<h.records.length;g++)if(m(h.records[g],a)){d=h.records[g],h.records.splice(g,1);break}if(d){if(d=void 0,a.high===h.max){var v=h.getNodeHigh();h.left!==void 0&&h.right!==void 0?h.max=Math.max(Math.max(h.left.max,h.right.max),v):h.left!==void 0&&h.right===void 0?h.max=Math.max(h.left.max,v):h.left===void 0&&h.right!==void 0?h.max=Math.max(h.right.max,v):h.max=v,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 I=new e(this,{low:a.low,high:a.low});I.left=this.root,this.root.parent=I;var S=this.root.remove(h);return this.root=I.left,this.root!==void 0&&(this.root.parent=void 0),S?(S=void 0,this.count--,!0):!1}else{var S=this.root.remove(h);return S?(S=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 o(this.root)},l})();Lt.IntervalTree=s;var i=(function(){function l(){this.tree=new s}return l.prototype.insert=function(a,h,d){return this.tree.insert({low:a,high:h,data:d})},l.prototype.remove=function(a,h,d){return this.tree.remove({low:a,high:h,data:d})},l.prototype.search=function(a,h){return this.tree.search(a,h).map(function(d){return d.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})();Lt.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})();Lt.InOrder=n,typeof Symbol=="function"&&(n.prototype[Symbol.iterator]=function(){return this});var o=(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 Lt.PreOrder=o,typeof Symbol=="function"&&(o.prototype[Symbol.iterator]=function(){return this}),Lt}var pe=Ve(),ts=Je(pe);class W{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=Jt(...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 pe.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},o=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<=o.yTop&&(n.top=t.top),i.yBot>=o.yBot&&(n.bottom=t.bottom),(n.top!==0||n.bottom!==0)&&i.increasePadding(n)}),this.updateRect()}get contentRect(){const t=Jt(...this.bricks.map(e=>e.contentRect));return{...t,width:t.xRight-t.xLeft,height:t.yBot-t.yTop}}}class ee{constructor(t,e,s,i){this.point=t,this.bricks=e,this.controller=s,this.repository=i}}class es extends ee{constructor(t,e,s,i,n){super(t,e,i,n),this.question=s}}class ss extends ee{constructor(t,e,s,i,n){super(t,e,i,n),this.panel=s}}class is extends ee{constructor(t,e,s,i,n){super(t,e,i,n),this.page=s}}const ns={padding:0,borderWidth:0,backgroundColor:null,borderColor:null,borderMode:1,borderRadius:0};class At extends W{get includedBorderWidth(){if(!this.includedBorderWidthValue){const t=St(this.style.borderWidth);Object.keys(t).forEach(e=>{switch(this.style.borderMode){case It.Inside:break;case It.Middle:t[e]=t[e]/2;break;default:return 0}}),this.includedBorderWidthValue=t}return this.includedBorderWidthValue}get padding(){return this._padding||(this._padding=St(this.style.padding)),this._padding}constructor(t,e,s){super(),this.controller=t,this.layout=e,this.style=r.mergeObjects({},ns,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(){this.controller.popMargins(),this.increasePadding({top:this.padding.top+this.includedBorderWidth.top,bottom:this.padding.bot+this.includedBorderWidth.bot});let t=-1;const e=()=>{const s=this.controller.getCurrentPageIndex();if(s!=t){t=s;const i=this.unfold().filter(d=>!d.isEmpty),n=i.filter(d=>d.getPageNumber()==s),o=r.mergeRects(...n),l=["top","right","bot","left"],a=new Array(4).fill(0,0,4).map((d,g)=>{var v;return(v=Array.isArray(this.style.borderWidth)?this.style.borderWidth[g]:this.style.borderWidth)!==null&&v!==void 0?v:0}),h=new Array(4).fill(0,0,4).map((d,g)=>{var v;const I=(v=Array.isArray(this.style.borderRadius)?this.style.borderRadius[g]:this.style.borderRadius)!==null&&v!==void 0?v:0;return Math.min(Math.max(I-a[g]-this.includedBorderWidth[l[g]]),0),Math.max(I-(a[g-1<0?a.length-1:g-1]-this.includedBorderWidth[l[g-1<0?l.length-1:g-1]]),0)});if(i[0]!=n[0]&&(h[0]=0,h[1]=0,a[0]=0),i[i.length-1]!==n[n.length-1]&&(h[2]=0,h[3]=0,a[2]=0),this.style.backgroundColor!==null){this.controller.setFillColor(this.style.backgroundColor);const d=r.createRect({xLeft:this.layout.xLeft+this.includedBorderWidth.left,yTop:o.yTop+this.includedBorderWidth.top},this.layout.width-this.includedBorderWidth.left-this.includedBorderWidth.right,o.yBot-o.yTop-this.includedBorderWidth.top-this.includedBorderWidth.bot),{lines:g,point:v}=r.getDocLinesFromShape(r.createRoundedShape(d,{...this.style,borderRadius:h}));this.controller.doc.lines(g,...v,[1,1],"F",!0),this.controller.restoreFillColor()}this.style.borderColor!==null&&r.renderFlatBorders(this.controller,{xLeft:this.layout.xLeft,xRight:this.layout.xLeft+this.layout.width,yTop:o.yTop,yBot:o.yBot,width:this.layout.width,height:o.yBot-o.yTop},{...this.style,borderRadius:h,borderWidth:a})}};this.bricks.forEach(s=>{s.addBeforeRenderCallback(e)})}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=!1){if(e){const s=(t-this.height)/2;this.translateY((i,n)=>({yTop:i+s,yBot:n+s})),this.increasePadding({top:s,bottom:s})}else this.increasePadding({top:0,bottom:t-this.height})}}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 W;let s=r.clone(t);const i={...this.style.title};if(this.question.no){const o=r.mergeObjects({},i,this.style.number),l=this.question.no;let a;r.hasHtml(this.question.locTitle)?(this.controller.pushMargins(),this.controller.margins.right=this.controller.paperWidth-this.controller.margins.left-this.controller.measureText(l,o).width,a=await r.createHTMLFlat(s,this.controller,r.createHtmlContainerBlock(l,this.controller,o),o),this.controller.popMargins()):a=await r.createTextFlat(s,this.controller,l,o),e.addBrick(a),s.xLeft=a.xRight+this.style.spacing.titleNumberGap}this.controller.pushMargins(),this.controller.margins.left=s.xLeft;const n=await r.createTextFlat(s,this.controller,this.question.locTitle,i);if(e.addBrick(n),this.controller.popMargins(),this.question.isRequired){const o=r.mergeObjects({},i,this.style.requiredMark),l=this.question.requiredMark;if(r.hasHtml(this.question.locTitle))s=r.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,o).width,e.addBrick(await r.createHTMLFlat(s,this.controller,r.createHtmlContainerBlock(l,this.controller,o),o)),this.controller.popMargins();else{const a=n.unfold().pop();if(this.style.spacing.titleRequiredMarkGap+this.controller.measureText(l,o).width<r.getPageAvailableWidth(this.controller)+this.controller.leftTopPoint.xLeft-a.xRight)s=r.createPoint(a,!1,!0),s.xLeft+=this.style.spacing.titleRequiredMarkGap;else{const h=s.xLeft;s=r.createPoint(a,!1,!1),s.xLeft=h}e.addBrick(await r.createTextFlat(s,this.controller,l,o))}}return e}async generateFlatDescription(t){return await r.createTextFlat(t,this.controller,this.question.locDescription,{...this.style.description})}async generateFlatHeader(t){const e=new At(this.controller,{...t,width:r.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 o=r.createPoint(n,!0,!1);o.yTop+=this.style.spacing.titleDescriptionGap,o.xLeft+=this.style.spacing.contentIndentStart,i.push(await this.generateFlatDescription(o))}}),e}async generateFlatsComment(t){const e=this.question.locCommentText,s=await r.createTextFlat(t,this.controller,e,this.style.commentLabel),i=r.createPoint(s);i.yTop+=this.style.spacing.commentLabelGap;const n=r.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),o=r.getPatchedTextStyle(this.controller,r.mergeObjects({},this.style.comment,n?this.style.commentReadOnly:void 0));return new W(s,await r.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:""},o))}async generateFlatsComposite(t){const e=this.question.contentPanel;return e?await r.generatePanelFlats(this.survey,this.controller,e,t):(this.question=r.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=r.clone(t);if(s&&s.length>0&&(i.yTop=r.mergeRects(...s).yBot),this.question.hasComment&&(i.yTop+=this.style.spacing.contentCommentGap,e.push(await this.generateFlatsComment(i))),this.question.hasDescriptionUnderInput){const n=new W;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 W,h=await this.generateFlatHeader(e);a.addBrick(h);let d=r.createPoint(h);const g=this.style.spacing.contentIndentStart;d.xLeft+=g,a.addBrick(r.createRowlineFlat(r.createPoint(h),this.controller)),d.yTop+=this.style.spacing.headerContentGap+r.EPSILON,this.controller.pushMargins(),this.controller.margins.left+=g;const v=await this.generateFlatsContentWithOptionalElements(d);this.controller.popMargins(),v!==null&&v.length!==0&&a.addBrick(v.shift()),s.push(a),s.push(...v);break}case"bottom":{const a=r.clone(e),h=new W;this.controller.pushMargins();const d=this.style.spacing.contentIndentStart;a.xLeft+=d,this.controller.margins.left+=d;const g=await this.generateFlatsContentWithOptionalElements(a);this.controller.popMargins(),g!==null&&g.length!==0&&h.addBrick(g.pop());const v=e;s.length!==0&&(v.yTop=s[s.length-1].yBot),v.yTop+=this.style.spacing.headerContentGap,h.addBrick(await this.generateFlatHeader(v)),s.push(...g),s.push(h);break}case"left":{this.controller.pushMargins(this.controller.margins.left,this.controller.paperWidth-this.controller.margins.left-r.getPageAvailableWidth(this.controller)*this.style.inlineHeaderWidthPercentage);const a=await this.generateFlatHeader(e),h=r.createPoint(a,!1,!0);this.controller.popMargins(),h.xLeft+=this.style.spacing.inlineHeaderContentGap,this.controller.margins.left=h.xLeft;const d=await this.generateFlatsContentWithOptionalElements(h);d!==null&&d.length!==0&&a.addBrick(d.shift()),s.push(a),s.push(...d);break}case"hidden":case n:default:{const a=r.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 o=new es(t,s,this.question,this.controller,N.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,o);const l=[...o.bricks];return this.survey.afterRenderSurveyElement(this.question,l),l}}D.Serializer.addProperty("question",{name:"readonlyRenderAs",default:"auto",choices:["auto","text","acroform"],visible:!1});class ge extends tt{async generateFlatsContent(t){return[await r.createTextFlat(t,this.controller,`${this.question.displayValue}`)]}}class N{constructor(){this.questions={}}static getInstance(){return N.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 o;const l=typeof n>"u"?e.getType():n;let a=this.getRenderer(l);return a||(!((o=e.customWidget)===null||o===void 0)&&o.pdfRender?a=tt:a=ge),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)}}N.instance=new N;class jt 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 jt,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 Wt extends Dt{constructor(t,e,s,i){super(t,e,s,i),this.options=s,this.style=i}async renderInteractive(){this.controller.setTextStyle(r.mergeObjects({},this.style,{fontColor:"#FFFFFF00"}));let t=this.controller.unitHeight*(this.controller.doc.getLineHeightFactor()-Wt.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()}}Wt.SCALE_FACTOR_MAGIC=.955;class ye 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 me 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,o=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,o,Math.min(t,s),Math.min(e,i),this.options.imageId,"MEDIUM")}finally{l()}})}}class Tt 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}=r.getDocLinesFromShape(r.createRoundedShape(this.contentRect,this.style));this.controller.doc.lines(t,...e,[1,1],"F",!0),this.controller.restoreFillColor()}r.renderFlatBorders(this.controller,this.contentRect,this.style)}}class se{constructor(t,e,s){this.controller=t,this.color=s,this.isPageBreak=!1,this.beforeRenderEvent=new jt,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 xe extends pt{constructor(t,e,s,i){var n,o,l,a;super(t,e),this.options=s,this.style=i,s.isMultiline=(n=s.isMultiline)!==null&&n!==void 0?n:!1,s.placeholder=(o=s.placeholder)!==null&&o!==void 0?o:"",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=r.createAcroformRect(r.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}=r.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=r.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),r.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={},o=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),d=h.length==1;h.forEach(g=>{const v=Jt(...n[g]),I={xLeft:this.contentRect.xLeft,xRight:this.contentRect.xRight,width:this.contentRect.width,yTop:d?this.contentRect.yTop:v.yTop,yBot:d?this.contentRect.yBot:v.yBot,height:d?this.contentRect.height:v.yBot-v.yTop};this.controller.setPage(Number(g)),r.renderFlatBorders(this.controller,I,this.style),this.controller.setPage(a)})}}};e.forEach(l=>{l.afterRenderCallback=o.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 ve{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 be=new ve;function ie(){return be}function os(m){be=m}var It;(function(m){m[m.Inside=0]="Inside",m[m.Middle=1]="Middle",m[m.Outside=2]="Outside"})(It||(It={}));var we;(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"})(we||(we={}));class r{static parseWidth(t,e,s=1,i){if(t.indexOf("calc")===0)return e/s;const n=parseFloat(t),o=t.replace(/[^A-Za-z%]/g,"")||i;let l;switch(o){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"),r.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 Jt(...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: ${r.parseColor(t.fontColor).color}; lineHeight: ${t.lineHeight}; margin: 0"`}static createHtmlContainerBlock(t,e,s){const i=r.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 o=Math.floor(i/n)-1;s.push(e);const l=this.createPoint(e);for(let h=0;h<o;h++)s.push(new Tt(t,this.createRect(l,e.width,n))),l.yTop+=n;const a=i-(o+1)*n;return a>0&&s.push(new Tt(t,this.createRect(l,e.width,a))),new W(...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 o=this.clone(t),l=new W;if(n.forEach(a=>{const h=e.measureText(a,i);l.addBrick(new Dt(e,this.createRect(o,h.width,h.height),{text:a},i)),o.yTop+=h.height}),i.textAlign=="right"){const a=t.xLeft+r.getPageAvailableWidth(e);l.translateX((h,d)=>({xLeft:h+(a-d),xRight:a}))}if(i.textAlign=="center"){const a=t.xLeft+r.getPageAvailableWidth(e)/2;l.translateX((h,d)=>{const g=a-(h+d)/2;return{xLeft:h+g,xRight:d+g}})}return l}static async createTextFlat(t,e,s,i){var n;const o={...r.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),o):l=this.splitHtmlRect(e,await this.createHTMLFlat(t,e,this.createHtmlContainerBlock(this.getLocString(s),e,o),o)),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]=r.mergeObjects((n=t[i])!==null&&n!==void 0?n:{},s[i]):t[i]=s[i]})}),t}static getPatchedTextStyle(t,e){const s=r.mergeObjects(r.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 o=this.getPatchedTextStyle(e,n),l=e.paperHeight-e.margins.bot-e.margins.top,a=(e.helperDoc.getNumberOfPages()-1)*(o.fontSize*Math.floor(l/o.fontSize))+i-s.top+r.HTML_TAIL_TEXT_SCALE*o.fontSize,h=e.helperDoc.getNumberOfPages();e.helperDoc.addPage();for(let d=0;d<h;d++)e.helperDoc.deletePage(1);return r.createRect(t,s.width,a)}static async createHTMLFlat(t,e,s,i){const n=this.getHtmlMargins(e,t),o=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=r.createHTMLRect(t,e,n,a.y,o);l(new ye(e,h,{html:s},o))},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 o=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(d=>{const g=xt.customFonts[d];Object.keys(g).forEach(v=>{v==="normal"||v==="bold"?a+=`${this.generateFontFace(d,g[v],v)}`:a+=`${this.generateFontFaceWithItalicStyle(d,g[v],v==="italic"?"normal":"bold")}`}),a="<defs><style>"+a+"</style></defs>"}),{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${o}px" height="${l}px">`+a+`<style>.__surveypdf_html p { margin: unset; line-height: 22px; }</style><foreignObject width="${o}px" height="${l}px">`+this.htmlToXml(t)+"</foreignObject></svg>",divWidth:o,divHeight:l}}static setCanvas(t,e,s,i,n){e.width=s*t.htmlToImageQuality,e.height=i*t.htmlToImageQuality;const o=e.getContext("2d");o.scale(t.htmlToImageQuality,t.htmlToImageQuality),o.fillStyle="#FFFFFF",o.fillRect(0,0,s,i),o.drawImage(n,0,0)}static async htmlToImage(t,e,s){const{svg:i,divWidth:n,divHeight:o}=r.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 d=document.createElement("canvas");r.setCanvas(s,d,n,o,a);const g=d.toDataURL("image/jpeg",s.htmlToImageQuality);d.remove(),h({url:g,aspect:n/o})},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,o;const l=r.getPatchedTextStyle(e,i);s.rows=(n=s.rows)!==null&&n!==void 0?n:1,s.value=(o=s.value)!==null&&o!==void 0?o:"";const a=this.createTextFieldRect(t,e,s.rows,l.lineHeight);let h;s.shouldRenderReadOnly&&(h=await this.createReadOnlyTextFieldTextFlat(t,e,s.value,l));const d=new xe(e,a,s,l);return h&&(d.textBrick=h),d}static get hasDocument(){return typeof document<"u"}static async createImageFlat(t,e,s,i,n){const o=ie();let l=await o.getImageInfo(i.link);(n??s.applyImageFit)&&(l=await o.applyImageFit(l,i.objectFit||"fill",i.width,i.height));const a=r.createRect(t,i.width,i.height);return new me(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 se(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=r.getPatchedTextStyle(e,i),o=await this.createTextFlat(t,e,s.text,n),l=new W;return o.unfold().forEach(a=>{l.addBrick(new Wt(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 o=i*s;return this.createRect(t,n,o)}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},o=St((i=e.borderRadius)!==null&&i!==void 0?i:0);Object.keys(o).forEach(h=>{o[h]=Math.max(0,Math.min(o[h],(t.xRight-t.xLeft)/2,(t.yBot-t.yTop)/2))});function l(h,d,g,v,I){const S=1.3333333333333333*Math.tan(v/4)*g;return[[g,0],[g,S],[g*Math.cos(v)+S*Math.sin(v),g*Math.sin(v)-S*Math.cos(v)],[g*Math.cos(v),g*Math.sin(v)]].reduce((at,dt)=>(at.push(Math.cos(I)*dt[0]-Math.sin(I)*dt[1]+h),at.push(Math.sin(I)*dt[0]+Math.cos(I)*dt[1]+d),at),[])}const a=new Map;if(a.set("top",[[t.xLeft+o.top,t.yTop,t.xRight-o.right,t.yTop]]),a.set("right",[[t.xRight,t.yTop+o.right,t.xRight,t.yBot-o.bot]]),a.set("bot",[[t.xRight-o.bot,t.yBot,t.xLeft+o.left,t.yBot]]),a.set("left",[[t.xLeft,t.yBot-o.left,t.xLeft,t.yTop+o.top]]),o.top){const h=n.top?Math.PI/2:Math.PI/4,d=o.top;a.get("left").push(l(t.xLeft+d,t.yTop+d,d,h,Math.PI)),n.top||a.get("top").unshift(l(t.xLeft+d,t.yTop+d,d,h,Math.PI+h))}if(o.right){const h=n.right?Math.PI/2:Math.PI/4,d=o.right;a.get("top").push(l(t.xRight-d,t.yTop+d,d,h,3/2*Math.PI)),n.right||a.get("right").unshift(l(t.xRight-d,t.yTop+d,d,h,3/2*Math.PI+h))}if(o.bot){const h=n.bot?Math.PI/2:Math.PI/4,d=o.bot;a.get("right").push(l(t.xRight-d,t.yBot-d,d,h,0)),n.bot||a.get("bot").unshift(l(t.xRight-d,t.yBot-d,d,h,h))}if(o.left){const h=n.left?Math.PI/2:Math.PI/4,d=o.left;a.get("bot").push(l(t.xLeft+d,t.yBot-d,d,h,Math.PI/2)),n.left||a.get("left").unshift(l(t.xLeft+d,t.yBot-d,d,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,o;const l=r.mergeObjects({},{borderMode:It.Inside},s),a=St((i=s.borderWidth)!==null&&i!==void 0?i:0),h=St(s.borderColor);if([h,a].some(X=>Object.keys(X).every(T=>!X[T])))return;const d=l.borderMode==It.Middle?0:l.borderMode==It.Inside?.5:-.5,g={xLeft:e.xLeft+d*a.left,yTop:e.yTop+d*a.top,xRight:e.xRight-d*a.right,yBot:e.yBot-d*a.bot},v={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},I=r.createRoundedShape(g,{...l},v),S=[];let Z=0,at=0,dt=0,$=0,K,J;const gt=Array.from(I.keys());if(gt.concat(gt).forEach((X,T)=>{const b=a[X],u=h[X];T!==0&&b==K&&u==J?$++:(K=b,J=u,$>at&&(Z=dt,at=$),dt=T,$=1)}),at==0&&(at=$,Z=dt),at>=2){const X=new Map;for(let b=Z;b<Z+at;b++){const u=gt[b%gt.length];X.set(u,I.get(u))}S.push(X);const T=gt.filter(b=>!X.has(b));if(T.length!==0)if(T.length==2&&T[0]=="top"&&T[1]=="left"&&T.reverse(),T.every(b=>a[T[0]]==a[b]&&h[T[0]]==h[b])){const b=new Map;T.forEach(u=>{b.set(u,I.get(u))}),S.push(b)}else T.forEach(b=>{const u=new Map;u.set(b,I.get(b)),S.push(u)})}else gt.forEach(X=>{const T=new Map;T.set(X,I.get(X)),S.push(T)});if(l.dashStyle){const X=l.dashStyle,T=(Math.abs(g.yTop-g.yBot)+Math.abs(g.xLeft-g.xRight))*2,b=X.dashArray[0]+((n=X.dashArray[1])!==null&&n!==void 0?n:X.dashArray[0]),u=X.dashArray[0]+T%b/Math.floor(T/b);t.doc.setLineDashPattern([u,(o=X.dashArray[1])!==null&&o!==void 0?o:X.dashArray[0]],X.dashPhase)}S.forEach(X=>{const T=X.keys().next().value;if(!h[T]||!a[T])return;t.setDrawColor(h[T]),t.doc.setLineWidth(a[T]);const{lines:b,point:u}=this.getDocLinesFromShape(X);t.doc.lines(b,...u,[1,1],"S",X.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(N.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=St(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 N.getInstance().create(t,s,e,n,i)}static async generateQuestionFlats(t,e,s,i){return[...await r.getFlatQuestion(t,e,s).generateFlats(i)]}static async generatePanelFlats(t,e,s,i){return[...await N.getInstance().createPanel(t,s,e,t.getElementStyle(s)).generateFlats(i)]}static async generatePageFlats(t,e,s,i){return[...await N.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)&&r.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:o,defaultImageHeight:l}=e;s=typeof s=="number"?s.toString():s,n=typeof n=="number"?n.toString():n;let a=s&&r.parseWidth(s,r.getPageAvailableWidth(t),1,"px"),h=n&&r.parseWidth(n,r.getPageAvailableWidth(t),1,"px");o=typeof o=="number"?o.toString():o,l=typeof l=="number"?l.toString():l;let d=o&&r.parseWidth(o,r.getPageAvailableWidth(t),1,"px"),g=l&&r.parseWidth(l,r.getPageAvailableWidth(t),1,"px");if(r.isSizeEmpty(s)||r.isHeightEmpty(n)){const v=await ie().getImageInfo(i);r.isSizeEmpty(s)?r.isHeightEmpty(n)?v&&v.height&&v.width&&(h=Math.min(v.height,r.getPageAvailableWidth(t)),a=Math.min(v.width,r.getPageAvailableWidth(t))):v&&v.height&&(a=v.width*h/v.height):v&&v.width&&(h=v.height*a/v.width)}return{width:a||d||0,height:h||g||0}}static alignVerticallyBricks(t,...e){const s=r.mergeRects(...e);e.forEach(i=>{switch(t){case"center":{i.translateY((n,o)=>{const l=(s.yTop+s.yBot-(n+o))/2;return{yTop:n+l,yBot:o+l}});break}case"bottom":{i.translateY((n,o)=>({yTop:n+s.yBot-o,yBot:s.yBot}));break}default:i.translateY((n,o)=>({yTop:s.yTop,yBot:o-n+s.yTop}))}})}static clear(){ie().clear()}}r.EPSILON=2220446049250313e-30,r.HTML_TAIL_TEXT_SCALE=.24;function rs(m){return m.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")}function as(m){return m=m||"",m.toString(),m="("+rs(m)+")",m}function ls(m){class t extends m.AcroFormTextField{getKeyValueListForStream(){const s=super.getKeyValueListForStream();return s.push({key:"DA",value:as(m.AcroFormAppearance.createDefaultAppearanceStream(this))}),s}}return t}function hs(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 o=this.Kids[n];o.appearanceStreamContent.N[o.optionName]=function(l){const a=i(l),h=a.stream.split(`
`),d=m.__private__.encodeColorString(l.color);return h[0]=h[0]+`
`+d+`
`+d.toUpperCase(),a.stream=h.join(`
`),a}}}}return t}function cs(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 o=n.stream.split(`
`);return o=o.slice(3),n.stream=o.join(`
`),n}}}return t}function us(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 o=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)},d=function(c){return c.toFixed(5)};e.__acroform__={};var g=function(c,p){c.prototype=Object.create(p.prototype),c.prototype.constructor=c},v=function(c){return c*i},I=function(c){return c/i},S=function(c){var p=new O,f=P.internal.getHeight(c)||0,y=P.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},at=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},dt=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},$=e.__acroform__.getBitForPdf=function(c,p){if(isNaN(c)||isNaN(p))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.getBitForPdf");return dt(c,p-1)},K=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)},J=e.__acroform__.clearBitForPdf=function(c,p){if(isNaN(c)||isNaN(p))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf");return at(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],z=c[3],Q={};return Q.lowerLeft_X=p(y)||0,Q.lowerLeft_Y=f(w+z)||0,Q.upperRight_X=p(y+L)||0,Q.upperRight_Y=f(w)||0,[Number(h(Q.lowerLeft_X)),Number(h(Q.lowerLeft_Y)),Number(h(Q.upperRight_X)),Number(h(Q.upperRight_Y))]},X=function(c){if(c.appearanceStreamContent)return c.appearanceStreamContent;if(!(!c.V&&!c.DV)){var p=[],f=c.V||c.DV,y=T(c,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 S(c);return L.stream=p.join(`
`),L}},T=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(Ct){return Ct.split(`
`)}),c.multiline||(w=w.map(function(Ct){return[Ct.join(" ")]}));var L=f,z=2,Q=2,it=P.internal.getHeight(c)||0;it=it<0?-it:it;var ot=P.internal.getWidth(c)||0;ot=ot<0?-ot:ot;var nt=function(Ct,Ts,Cs){if(Ct+1<w.length){var Ps=Ts+" "+w[Ct+1][0],ks=b(Ps,c,Cs).width,Bs=ot-2*Q;return ks<=Bs}else return!1};L++;t:for(;L>0;){p="",L--;var ct=b("3",c,L).height,rt=c.multiline?it-L:(it-ct)/2;rt+=z;var Mt,Gt=rt,wt=0,R=0,Zt,Ot=0;if(L<=0){L=12,p=`(...) Tj
`,p+="% Width of Text: "+b(p,c,L).width+", FieldWidth:"+ot+`
`;break}var Rt="",Vt=0;e:for(var Ft=0;Ft<w.length;Ft++)if(w.hasOwnProperty(Ft)){var $e=!1;if(w[Ft].length!==1&&Ot!==w[Ft].length-1){if((ct+z)*(Vt+2)+z>it)continue t;Rt+=w[Ft][Ot],$e=!0,R=Ft,Ft--}else{Rt+=w[Ft][Ot]+" ",Rt=Rt.substr(Rt.length-1)==" "?Rt.substr(0,Rt.length-1):Rt;var ce=parseInt(Ft),Ye=nt(ce,Rt,L),ue=Ft>=w.length-1;if(Ye&&!ue){Rt+=" ",Ot=0;continue}else if(!Ye&&!ue)if(c.multiline){if((ct+z)*(Vt+2)+z>it)continue t;R=ce}else continue t;else if(ue)R=ce;else if(c.multiline&&(ct+z)*(Vt+2)+z>it)continue t}for(var mt="",Xt=wt;Xt<=R;Xt++){var Kt=w[Xt];if(c.multiline){if(Xt===R){mt+=Kt[Ot]+" ",Ot=(Ot+1)%Kt.length;continue}if(Xt===wt){mt+=Kt[Kt.length-1]+" ";continue}}mt+=Kt[0]+" "}switch(mt=mt.substr(mt.length-1)==" "?mt.substr(0,mt.length-1):mt,Zt=b(mt,c,L).width,c.textAlign){case"right":Mt=ot-Zt-Q;break;case"center":Mt=(ot-Zt)/2;break;default:Mt=Q;break}if(p+=h(Mt)+" "+h(Gt)+` Td
`,c.isUnicode){var Xe={};const Ct=s.internal.getFont(c.fontName,c.fontStyle);Xe[Ct.id]=Ct;var Ke={text:mt,x:null,y:null,options:{lang:null},mutex:{pdfEscape:o,activeFontKey:Ct.id,fonts:Xe,activeFontSize:c.fontSize}};s.internal.events.publish("postProcessText",Ke),p+="<"+Ke.text+`> Tj
`}else p+="("+o(mt)+`) Tj
`;p+=-h(Mt)+` 0 Td
`,Gt=-(L+z),Zt=0,wt=$e?R:R+1,Vt++,Rt="";continue e}break}return y.text=p,y.fontSize=L,y},b=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}},u={fields:[],xForms:[],acroFormDictionaryRoot:null,printedOut:!1,internal:null,isInitialized:!1},F=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||q.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)},C=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.")},B=function(){s.internal.events.unsubscribe(s.internal.acroformPlugin.acroFormDictionaryRoot._eventID),delete s.internal.acroformPlugin.acroFormDictionaryRoot._eventID,s.internal.acroformPlugin.printedOut=!0},A=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=P.createDefaultAppearanceStream(y),typeof y=="object"&&typeof y.getKeyValueListForStream=="function"&&(w=y.getKeyValueListForStream()),y.Rect=L,y.hasAppearanceStream&&!y.appearanceStreamContent){var z=X.call(this,y);w.push({key:"AP",value:"<</N "+z+">>"}),s.internal.acroformPlugin.xForms.push(z)}if(y.appearanceStreamContent){var Q="";for(var it in y.appearanceStreamContent)if(y.appearanceStreamContent.hasOwnProperty(it)){var ot=y.appearanceStreamContent[it];if(Q+="/"+it+" ",Q+="<<",Object.keys(ot).length>=1||Array.isArray(ot)){for(var f in ot)if(ot.hasOwnProperty(f)){var nt=ot[f];typeof nt=="function"&&(nt=nt.call(this,y)),Q+="/"+f+" "+nt+" ",s.internal.acroformPlugin.xForms.indexOf(nt)>=0||s.internal.acroformPlugin.xForms.push(nt)}}else nt=ot,typeof nt=="function"&&(nt=nt.call(this,y)),Q+="/"+f+" "+nt,s.internal.acroformPlugin.xForms.indexOf(nt)>=0||s.internal.acroformPlugin.xForms.push(nt);Q+=">>"}w.push({key:"AP",value:`<<
`+Q+">>"})}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]}},q=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(u)),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",B),s.internal.events.subscribe("buildDocument",F),s.internal.events.subscribe("putCatalog",C),s.internal.events.subscribe("postPutPages",A),s.internal.acroformPlugin.isInitialized=!0}},_=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+="("+o(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 U=function(c){var p=[];return typeof c=="string"&&(p=G(c,/\((.*?)\)/g)),p},M=function(c){return c=c||"",c.toString(),c="("+o(c)+")",c},E=function(){var c;Object.defineProperty(this,"objId",{configurable:!0,get:function(){return c||(c=s.internal.newObjectDeferred()),c},set:function(p){c=p}})};E.prototype.toString=function(){return this.objId+" 0 R"},E.prototype.putStream=function(){var c=this.getKeyValueListForStream();s.internal.putStream({data:this.stream,additionalKeyValues:c}),s.internal.out("endobj")},E.prototype.getKeyValueListForStream=function(){var c=function(p){var f=[],y=Object.getOwnPropertyNames(p).filter(function(it){return it!="content"&&it!="appearanceStreamContent"&&it.substring(0,1)!="_"});for(var w in y){var L=Object.getOwnPropertyDescriptor(p,y[w]);if(L&&L.configurable===!1){var z=y[w],Q=p[z];Q&&(Array.isArray(Q)?f.push({key:z,value:_(Q)}):Q instanceof E?f.push({key:z,value:Q.objId+" 0 R"}):typeof Q!="function"&&f.push({key:z,value:Q}))}}return f};return c(this)};var O=function(){E.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(O,E);var Y=function(){E.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,E);var et=function(){E.call(this);var c=4;this.isUnicode=!1,this.trueValue="",Object.defineProperty(this,"F",{enumerable:!1,configurable:!1,get:function(){return c},set:function(R){if(!isNaN(R))c=R;else throw new Error('Invalid value "'+R+'" for attribute F supplied.')}}),Object.defineProperty(this,"showWhenPrinted",{enumerable:!0,configurable:!0,get:function(){return!!$(c,3)},set:function(R){R?this.F=K(c,3):this.F=J(c,3)}});var p=0;Object.defineProperty(this,"Ff",{enumerable:!1,configurable:!1,get:function(){return p},set:function(R){if(!isNaN(R))p=R;else throw new Error('Invalid value "'+R+'" for attribute Ff supplied.')}});var f=[];Object.defineProperty(this,"Rect",{enumerable:!1,configurable:!1,get:function(){if(f.length!==0)return f},set:function(R){typeof R<"u"?f=R:f=[]}}),Object.defineProperty(this,"x",{enumerable:!0,configurable:!0,get:function(){return!f||isNaN(f[0])?0:I(f[0])},set:function(R){f[0]=v(R)}}),Object.defineProperty(this,"y",{enumerable:!0,configurable:!0,get:function(){return!f||isNaN(f[1])?0:I(f[1])},set:function(R){f[1]=v(R)}}),Object.defineProperty(this,"width",{enumerable:!0,configurable:!0,get:function(){return!f||isNaN(f[2])?0:I(f[2])},set:function(R){f[2]=v(R)}}),Object.defineProperty(this,"height",{enumerable:!0,configurable:!0,get:function(){return!f||isNaN(f[3])?0:I(f[3])},set:function(R){f[3]=v(R)}});var y="";Object.defineProperty(this,"FT",{enumerable:!0,configurable:!1,get:function(){return y},set:function(R){switch(R){case"/Btn":case"/Tx":case"/Ch":case"/Sig":y=R;break;default:throw new Error('Invalid value "'+R+'" 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"("+o(w)+")"},set:function(R){w=R.toString()}}),Object.defineProperty(this,"fieldName",{configurable:!0,enumerable:!0,get:function(){return w},set:function(R){w=R}});var L="helvetica";Object.defineProperty(this,"fontName",{enumerable:!0,configurable:!0,get:function(){return L},set:function(R){L=R}});var z="normal";Object.defineProperty(this,"fontStyle",{enumerable:!0,configurable:!0,get:function(){return z},set:function(R){z=R}});var Q=0;Object.defineProperty(this,"fontSize",{enumerable:!0,configurable:!0,get:function(){return I(Q)},set:function(R){Q=v(R)}});var it=50;Object.defineProperty(this,"maxFontSize",{enumerable:!0,configurable:!0,get:function(){return I(it)},set:function(R){it=v(R)}});var ot="black";Object.defineProperty(this,"color",{enumerable:!0,configurable:!0,get:function(){return ot},set:function(R){ot=R}});var nt="/F1 0 Tf 0 g";Object.defineProperty(this,"DA",{enumerable:!0,configurable:!1,get:function(){if(!(!nt||this instanceof Ht||this instanceof bt))return M(nt)},set:function(R){R=R.toString(),nt=R}});var ct=null;Object.defineProperty(this,"DV",{enumerable:!1,configurable:!1,get:function(){if(ct)return this instanceof V?ct:M(ct)},set:function(R){R=R.toString(),this instanceof V?ct=R:R.substr(0,1)==="("?ct=l(R.substr(1,R.length-2)):ct=l(R)}}),Object.defineProperty(this,"defaultValue",{enumerable:!0,configurable:!0,get:function(){return this instanceof V?l(ct.substr(1,ct.length-1)):ct},set:function(R){R=R.toString(),this instanceof V?ct="/"+R:ct=R}});var rt=null;Object.defineProperty(this,"V",{enumerable:!1,configurable:!1,get:function(){if(this.isUnicode)return rt;if(rt)return this instanceof V?rt:M(rt)},set:function(R){R=R.toString(),this.isUnicode?(rt=n(R),this.trueValue=R):this instanceof V?rt=R:R.substr(0,1)==="("?rt=l(R.substr(1,R.length-2)):rt=l(R)}}),Object.defineProperty(this,"value",{enumerable:!0,configurable:!0,get:function(){return this.isUnicode?rt:this instanceof V?l(rt.substr(1,rt.length-1)):rt},set:function(R){R=R.toString(),this.isUnicode?(rt=n(R),this.trueValue=R):this instanceof V?rt="/"+R:rt=R}}),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 Mt=!1;Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,writeable:!0,get:function(){return Mt},set:function(R){R=!!R,Mt=R}});var Gt;Object.defineProperty(this,"page",{enumerable:!0,configurable:!0,writeable:!0,get:function(){if(Gt)return Gt},set:function(R){Gt=R}}),Object.defineProperty(this,"readOnly",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,1)},set:function(R){R?this.Ff=K(this.Ff,1):this.Ff=J(this.Ff,1)}}),Object.defineProperty(this,"required",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,2)},set:function(R){R?this.Ff=K(this.Ff,2):this.Ff=J(this.Ff,2)}}),Object.defineProperty(this,"noExport",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,3)},set:function(R){R?this.Ff=K(this.Ff,3):this.Ff=J(this.Ff,3)}});var wt=null;Object.defineProperty(this,"Q",{enumerable:!0,configurable:!1,get:function(){if(wt!==null)return wt},set:function(R){if([0,1,2].indexOf(R)!==-1)wt=R;else throw new Error('Invalid value "'+R+'" for attribute Q supplied.')}}),Object.defineProperty(this,"textAlign",{get:function(){var R;switch(wt){case 0:default:R="left";break;case 1:R="center";break;case 2:R="right";break}return R},configurable:!0,enumerable:!0,set:function(R){switch(R){case"right":case 2:wt=2;break;case"center":case 1:wt=1;break;default:wt=0}}})};g(et,E);var st=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):_(f)},set:function(y){f=U(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!!$(this.Ff,18)},set:function(y){y?this.Ff=K(this.Ff,18):this.Ff=J(this.Ff,18)}}),Object.defineProperty(this,"edit",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,19)},set:function(y){this.combo===!0&&(y?this.Ff=K(this.Ff,19):this.Ff=J(this.Ff,19))}}),Object.defineProperty(this,"sort",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,20)},set:function(y){y?(this.Ff=K(this.Ff,20),f.sort()):this.Ff=J(this.Ff,20)}}),Object.defineProperty(this,"multiSelect",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,22)},set:function(y){y?this.Ff=K(this.Ff,22):this.Ff=J(this.Ff,22)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,23)},set:function(y){y?this.Ff=K(this.Ff,23):this.Ff=J(this.Ff,23)}}),Object.defineProperty(this,"commitOnSelChange",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,27)},set:function(y){y?this.Ff=K(this.Ff,27):this.Ff=J(this.Ff,27)}}),this.hasAppearanceStream=!1};g(st,et);var lt=function(){st.call(this),this.fontName="helvetica",this.combo=!1};g(lt,st);var ht=function(){lt.call(this),this.combo=!0};g(ht,lt);var ut=function(){ht.call(this),this.edit=!0};g(ut,ht);var V=function(){et.call(this),this.FT="/Btn",Object.defineProperty(this,"noToggleToOff",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,15)},set:function(f){f?this.Ff=K(this.Ff,15):this.Ff=J(this.Ff,15)}}),Object.defineProperty(this,"radio",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,16)},set:function(f){f?this.Ff=K(this.Ff,16):this.Ff=J(this.Ff,16)}}),Object.defineProperty(this,"pushButton",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,17)},set:function(f){f?this.Ff=K(this.Ff,17):this.Ff=J(this.Ff,17)}}),Object.defineProperty(this,"radioIsUnison",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,26)},set:function(f){f?this.Ff=K(this.Ff,26):this.Ff=J(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 Bt=function(){V.call(this),this.pushButton=!0};g(Bt,V);var vt=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(vt,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=P.RadioButton.Circle,this.appearanceStreamContent=this._AppearanceType.createAppearanceStream(this.optionName)};g(Ht,et),vt.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()}},vt.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 qt=function(){V.call(this),this.fontName="zapfdingbats",this.caption="3",this.appearanceState="On",this.value="On",this.textAlign="center",this.appearanceStreamContent=P.CheckBox.createAppearanceStream()};g(qt,V);var bt=function(){et.call(this),this.FT="/Tx",Object.defineProperty(this,"multiline",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,13)},set:function(p){p?this.Ff=K(this.Ff,13):this.Ff=J(this.Ff,13)}}),Object.defineProperty(this,"fileSelect",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,21)},set:function(p){p?this.Ff=K(this.Ff,21):this.Ff=J(this.Ff,21)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,23)},set:function(p){p?this.Ff=K(this.Ff,23):this.Ff=J(this.Ff,23)}}),Object.defineProperty(this,"doNotScroll",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,24)},set:function(p){p?this.Ff=K(this.Ff,24):this.Ff=J(this.Ff,24)}}),Object.defineProperty(this,"comb",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,25)},set:function(p){p?this.Ff=K(this.Ff,25):this.Ff=J(this.Ff,25)}}),Object.defineProperty(this,"richText",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,26)},set:function(p){p?this.Ff=K(this.Ff,26):this.Ff=J(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(bt,et);var ft=function(){bt.call(this),Object.defineProperty(this,"password",{enumerable:!0,configurable:!0,get:function(){return!!$(this.Ff,14)},set:function(c){c?this.Ff=K(this.Ff,14):this.Ff=J(this.Ff,14)}}),this.password=!0};g(ft,bt);var P={CheckBox:{createAppearanceStream:function(){var c={N:{On:P.CheckBox.YesNormal},D:{On:P.CheckBox.YesPushDown,Off:P.CheckBox.OffPushDown}};return c},YesPushDown:function(c){var p=new S(c),f=[],y=s.internal.getFont(c.fontName,c.fontStyle).id,w=s.__private__.encodeColorString(c.color),L=T(c,c.caption);return f.push("0.749023 g"),f.push("0 0 "+h(P.internal.getWidth(c))+" "+h(P.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 S(c),f=s.internal.getFont(c.fontName,c.fontStyle).id,y=s.__private__.encodeColorString(c.color),w=[],L=P.internal.getHeight(c),z=P.internal.getWidth(c),Q=T(c,c.caption);return w.push("1 g"),w.push("0 0 "+h(z)+" "+h(L)+" re"),w.push("f"),w.push("q"),w.push("0 0 1 rg"),w.push("0 0 "+h(z-1)+" "+h(L-1)+" re"),w.push("W"),w.push("n"),w.push("0 g"),w.push("BT"),w.push("/"+f+" "+h(Q.fontSize)+" Tf "+y),w.push(Q.text),w.push("ET"),w.push("Q"),p.stream=w.join(`
`),p},OffPushDown:function(c){var p=new S(c),f=[];return f.push("0.749023 g"),f.push("0 0 "+h(P.internal.getWidth(c))+" "+h(P.internal.getHeight(c))+" re"),f.push("f"),p.stream=f.join(`
`),p}},RadioButton:{Circle:{createAppearanceStream:function(c){var p={D:{Off:P.RadioButton.Circle.OffPushDown},N:{}};return p.N[c]=P.RadioButton.Circle.YesNormal,p.D[c]=P.RadioButton.Circle.YesPushDown,p},getCA:function(){return"l"},YesNormal:function(c){var p=new S(c),f=[],y=P.internal.getWidth(c)<=P.internal.getHeight(c)?P.internal.getWidth(c)/4:P.internal.getHeight(c)/4;y=Number((y*.9).toFixed(5));var w=P.internal.Bezier_C,L=Number((y*w).toFixed(5));return f.push("q"),f.push("1 0 0 1 "+d(P.internal.getWidth(c)/2)+" "+d(P.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 S(c),f=[],y=P.internal.getWidth(c)<=P.internal.getHeight(c)?P.internal.getWidth(c)/4:P.internal.getHeight(c)/4,y=Number((y*.9).toFixed(5)),w=Number((y*2).toFixed(5)),L=Number((w*P.internal.Bezier_C).toFixed(5)),z=Number((y*P.internal.Bezier_C).toFixed(5));return f.push("0.749023 g"),f.push("q"),f.push("1 0 0 1 "+d(P.internal.getWidth(c)/2)+" "+d(P.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 "+d(P.internal.getWidth(c)/2)+" "+d(P.internal.getHeight(c)/2)+" cm"),f.push(y+" 0 m"),f.push(""+y+" "+z+" "+z+" "+y+" 0 "+y+" c"),f.push("-"+z+" "+y+" -"+y+" "+z+" -"+y+" 0 c"),f.push("-"+y+" -"+z+" -"+z+" -"+y+" 0 -"+y+" c"),f.push(z+" -"+y+" "+y+" -"+z+" "+y+" 0 c"),f.push("f"),f.push("Q"),p.stream=f.join(`
`),p},OffPushDown:function(c){var p=new S(c),f=[],y=P.internal.getWidth(c)<=P.internal.getHeight(c)?P.internal.getWidth(c)/4:P.internal.getHeight(c)/4;y=Number((y*.9).toFixed(5));var w=Number((y*2).toFixed(5)),L=Number((w*P.internal.Bezier_C).toFixed(5));return f.push("0.749023 g"),f.push("q"),f.push("1 0 0 1 "+d(P.internal.getWidth(c)/2)+" "+d(P.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:P.RadioButton.Cross.OffPushDown},N:{}};return p.N[c]=P.RadioButton.Cross.YesNormal,p.D[c]=P.RadioButton.Cross.YesPushDown,p},getCA:function(){return"8"},YesNormal:function(c){var p=new S(c),f=[],y=P.internal.calculateCross(c);return f.push("q"),f.push("1 1 "+h(P.internal.getWidth(c)-2)+" "+h(P.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 S(c),f=P.internal.calculateCross(c),y=[];return y.push("0.749023 g"),y.push("0 0 "+h(P.internal.getWidth(c))+" "+h(P.internal.getHeight(c))+" re"),y.push("f"),y.push("q"),y.push("1 1 "+h(P.internal.getWidth(c)-2)+" "+h(P.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 S(c),f=[];return f.push("0.749023 g"),f.push("0 0 "+h(P.internal.getWidth(c))+" "+h(P.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}};P.internal={Bezier_C:.551915024494,calculateCross:function(c){var p=P.internal.getWidth(c),f=P.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}},P.internal.getWidth=function(c){var p=0;return typeof c=="object"&&(p=v(c.Rect[2])),p},P.internal.getHeight=function(c){var p=0;return typeof c=="object"&&(p=v(c.Rect[3])),p};var yt=e.addField=function(c){if(q.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 bt))throw new Error("Invalid argument passed to jsPDF.addTextField.");return yt.call(this,c)},e.addChoiceField=function(c){if(!(c instanceof st))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=st,t.ListBox=lt,t.ComboBox=ht,t.EditBox=ut,t.Button=V,t.PushButton=Bt,t.RadioButton=vt,t.CheckBox=qt,t.TextField=bt,t.PasswordField=ft,t.AcroForm={Appearance:P}),e.AcroFormChoiceField=st,e.AcroFormListBox=lt,e.AcroFormComboBox=ht,e.AcroFormEditBox=ut,e.AcroFormButton=V,e.AcroFormPushButton=Bt,e.AcroFormRadioButton=vt,e.AcroFormCheckBox=qt,e.AcroFormTextField=bt,e.AcroFormPasswordField=ft,e.AcroFormAppearance=P,e.AcroForm={ChoiceField:st,ListBox:lt,ComboBox:ht,EditBox:ut,Button:V,PushButton:Bt,RadioButton:vt,CheckBox:qt,TextField:bt,PasswordField:ft,Appearance:P},m.AcroForm={ChoiceField:st,ListBox:lt,ComboBox:ht,EditBox:ut,Button:V,PushButton:Bt,RadioButton:vt,CheckBox:qt,TextField:bt,PasswordField:ft,Appearance:P}})(_t.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,o,l,a,h,d,g,v,I,S,Z,at,dt,$,K,J;t=(function(){return function(b){return T.prototype=b,new T};function T(){}})(),d=function(b){var u,F,x,j,C,B,A;for(F=0,x=b.length,u=void 0,j=!1,B=!1;!j&&F!==x;)u=b[F]=b[F].trimLeft(),u&&(j=!0),F++;for(F=x-1;x&&!B&&F!==-1;)u=b[F]=b[F].trimRight(),u&&(B=!0),F--;for(C=/\s+$/g,A=!0,F=0;F!==x;)b[F]!="\u2028"&&(u=b[F].replace(/\s+/g," "),A&&(u=u.trimLeft()),u&&(A=C.test(u)),b[F]=u),F++;return b},g=function(b,u,F,x){return this.pdf=b,this.x=u,this.y=F,this.settings=x,this.watchFunctions=[],this.init(),this},v=function(b){var u,F,x;for(u=void 0,x=b.split(","),F=x.shift();!u&&F;)u=s[F.trim().toLowerCase()],F=x.shift();return u},I=function(b){b=b==="auto"?"0px":b,b.indexOf("em")>-1&&!isNaN(Number(b.replace("em","")))&&(b=Number(b.replace("em",""))*18.719+"px"),b.indexOf("pt")>-1&&!isNaN(Number(b.replace("pt","")))&&(b=Number(b.replace("pt",""))*1.333+"px");var u,F,x;return F=void 0,u=16,x=S[b],x||(x={"xx-small":9,"x-small":11,small:13,medium:16,large:19,"x-large":23,"xx-large":28,auto:0}[b],x!==F||(x=parseFloat(b))?S[b]=x/u:(x=b.match(/([\d\.]+)(px)/),Array.isArray(x)&&x.length===3?S[b]=parseFloat(x[1])/u:S[b]=1))},h=function(b){var u,F,x;return x=(function(j){var C;return C=(function(B){return document.defaultView&&document.defaultView.getComputedStyle?document.defaultView.getComputedStyle(B,null):B.currentStyle?B.currentStyle:B.style})(j),function(B){return B=B.replace(/-\D/g,function(A){return A.charAt(1).toUpperCase()}),C[B]}})(b),u={},F=void 0,u["font-family"]=v(x("font-family"))||"times",u["font-style"]=i[x("font-style")]||"normal",u["text-align"]=n[x("text-align")]||"left",F=o[x("font-weight")]||"normal",F==="bold"&&(u["font-style"]==="normal"?u["font-style"]=F:u["font-style"]=F+u["font-style"]),u["font-size"]=I(x("font-size"))||1,u["line-height"]=I(x("line-height"))||1,u.display=x("display")==="inline"?"inline":"block",F=u.display==="block",u["margin-top"]=F&&I(x("margin-top"))||0,u["margin-bottom"]=F&&I(x("margin-bottom"))||0,u["padding-top"]=F&&I(x("padding-top"))||0,u["padding-bottom"]=F&&I(x("padding-bottom"))||0,u["margin-left"]=F&&I(x("margin-left"))||0,u["margin-right"]=F&&I(x("margin-right"))||0,u["padding-left"]=F&&I(x("padding-left"))||0,u["padding-right"]=F&&I(x("padding-right"))||0,u["page-break-before"]=x("page-break-before")||"auto",u.float=l[x("cssFloat")]||"none",u.clear=a[x("clear")]||"none",u.color=x("color"),u},Z=function(b,u,F){var x,j,C,B,A;if(C=!1,j=void 0,B=void 0,x=F["#"+b.id],x)if(typeof x=="function")C=x(b,u);else for(j=0,B=x.length;!C&&j!==B;)C=x[j](b,u),j++;if(x=F[b.nodeName],!C&&x)if(typeof x=="function")C=x(b,u);else for(j=0,B=x.length;!C&&j!==B;)C=x[j](b,u),j++;for(A=typeof b.className=="string"?b.className.split(" "):[],j=0;j<A.length;j++)if(x=F["."+A[j]],!C&&x)if(typeof x=="function")C=x(b,u);else for(j=0,B=x.length;!C&&j!==B;)C=x[j](b,u),j++;return C},J=function(b,u){var F,x,j,C,B,A,H,q,_;F=[],x=[],j=0,_=0;for(var C=0;C<b.rows[0].cells.length;C++)_+=b.rows[0].cells[C].colSpan;for(H=b.clientWidth;j<_;){q=b.rows[0].cells[j];for(var C=0;C<q.colSpan;C++)x[j+C]={name:q.textContent.toLowerCase().replace(/\s+/g,"")+"_"+C,prompt:q.textContent.replace(/\r?\n/g,""),width:q.clientWidth/H*u.settings.width/q.colSpan};j+=C}for(j=1;j<b.rows.length;){for(A=b.rows[j],B={},C=0;C<A.cells.length;)B[x[C].name]=A.cells[C].textContent.replace(/\r?\n/g,""),C++;F.push(B),j++}return{rows:F,headers:x}};var gt={SCRIPT:1,STYLE:1,NOSCRIPT:1,OBJECT:1,EMBED:1,SELECT:1},X=1;e=function(b,u,F){var x,j,C,B,A,H,q,_;for(j=b.childNodes,x=void 0,C=h(b),A=C.display==="block",A&&(u.setBlockBoundary(),u.setBlockStyle(C)),B=0,H=j.length;B<H;){if(x=j[B],typeof x=="object"){if(u.executeWatchFunctions(x),x.nodeType===1&&x.nodeName==="HEADER"){var G=x,U=u.pdf.margins_doc.top;u.pdf.internal.events.subscribe("addPage",function(ft){u.y=U,e(G,u,F),u.pdf.margins_doc.top=u.y+10,u.y+=10},!1)}if(x.nodeType===8&&x.nodeName==="#comment")~x.textContent.indexOf("ADD_PAGE")&&(u.pdf.addPage(),u.y=u.pdf.margins_doc.top);else if(x.nodeType===1&&!gt[x.nodeName]){var M;if(x.nodeName==="IMG"){var E=x.getAttribute("src");M=at[u.pdf.sHashCode&&u.pdf.sHashCode(E)||E]}if(M){u.pdf.internal.pageSize.getHeight()-u.pdf.margins_doc.bottom<u.y+x.height&&u.y>u.pdf.margins_doc.top&&(u.pdf.addPage(),u.y=u.pdf.margins_doc.top,u.executeWatchFunctions(x));var O=h(x),Y=u.x,et=12/u.pdf.internal.scaleFactor,st=(O["margin-left"]+O["padding-left"])*et,lt=(O["margin-right"]+O["padding-right"])*et,ht=(O["margin-top"]+O["padding-top"])*et,ut=(O["margin-bottom"]+O["padding-bottom"])*et;O.float!==void 0&&O.float==="right"?Y+=u.settings.width-x.width-lt:Y+=st,u.pdf.addImage(M,Y,u.y+ht,x.width,x.height),M=void 0,O.float==="right"||O.float==="left"?(u.watchFunctions.push(function(ft,P,yt,c){return u.y>=P?(u.x+=ft,u.settings.width+=yt,!0):c&&c.nodeType===1&&!gt[c.nodeName]&&u.x+c.width>u.pdf.margins_doc.left+u.pdf.margins_doc.width?(u.x+=ft,u.y=P,u.settings.width+=yt,!0):!1}.bind(this,O.float==="left"?-x.width-st-lt:0,u.y+x.height+ht+ut,x.width)),u.watchFunctions.push(function(ft,P,yt){return u.y<ft&&P===u.pdf.internal.getNumberOfPages()?yt.nodeType===1&&h(yt).clear==="both"?(u.y=ft,!0):!1:!0}.bind(this,u.y+x.height,u.pdf.internal.getNumberOfPages())),u.settings.width-=x.width+st+lt,O.float==="left"&&(u.x+=x.width+st+lt)):u.y+=x.height+ht+ut}else if(x.nodeName==="TABLE")u.pdf.autoTable?(u.y+=10,u.pdf.autoTable({theme:"grid",html:x,startY:u.y,styles:{font:u.pdf.getFont().fontName,fontSize:u.pdf.getFontSize(),textColor:u.pdf.getTextColor()},margin:{top:u.pdf.margins_doc.top,left:u.x,right:u.pdf.internal.pageSize.getWidth()-(u.x+u.settings.width),bottom:u.pdf.margins_doc.bottom}}),u.y=u.pdf.lastAutoTable.finalY):(q=J(x,u),u.y+=10,u.pdf.table(u.x,u.y,q.rows,q.headers,{autoSize:!1,printHeaders:F.printHeaders,margins:u.pdf.margins_doc,css:h(x)}),u.y=u.pdf.internal.__cell__.lastCell.y+u.pdf.internal.__cell__.lastCell.height);else if(x.nodeName==="OL"||x.nodeName==="UL")X=1,Z(x,u,F)||e(x,u,F),u.y+=10;else if(x.nodeName==="LI"){var V=u.x;u.x+=20/u.pdf.internal.scaleFactor,u.y+=3,Z(x,u,F)||e(x,u,F),u.x=V}else x.nodeName==="BR"?(u.y+=C["font-size"]*u.pdf.internal.scaleFactor,u.addText("\u2028",t(C))):Z(x,u,F)||e(x,u,F)}else if(x.nodeType===3){var Bt=x.nodeValue;if(x.nodeValue&&x.parentNode.nodeName==="LI")if(x.parentNode.parentNode.nodeName==="OL")Bt=X+++". "+Bt;else{var vt=C["font-size"],Ht=(3-vt*.75)*u.pdf.internal.scaleFactor,qt=vt*.75*u.pdf.internal.scaleFactor,bt=vt*1.74/u.pdf.internal.scaleFactor;_=function(P,yt){this.pdf.circle(P+Ht,yt+qt,bt,"FD")}}x.ownerDocument.body.compareDocumentPosition(x)&16&&u.addText(Bt,C)}else typeof x=="string"&&u.addText(x,C)}B++}if(F.outY=u.y,A)return u.setBlockBoundary(_)},at={},dt=function(b,u,F,x){var j=b.getElementsByTagName("img"),C=j.length,B,A=0;function H(){u.pdf.internal.events.publish("imagesLoaded"),x(B)}function q(_,G,U){if(_){var M=new Image;B=++A,M.crossOrigin="",M.onerror=M.onload=function(){if(M.complete&&(M.src.indexOf("data:image/")===0&&(M.width=G||M.width||0,M.height=U||M.height||0),M.width+M.height)){var E=u.pdf.sHashCode&&u.pdf.sHashCode(_)||_;at[E]=at[E]||M}--A||H()},M.src=_}}for(;C--;)q(j[C].getAttribute("src"),j[C].width,j[C].height);return A||H()},$=function(b,u,F){var x=b.getElementsByTagName("footer");if(x.length>0){x=x[0];var j=u.pdf.internal.write,C=u.y;u.pdf.internal.write=function(){},e(x,u,F);var B=Math.ceil(u.y-C)+5;u.y=C,u.pdf.internal.write=j,u.pdf.margins_doc.bottom+=B;for(var A=function(G){var U=G!==void 0?G.pageNumber:1,M=u.y;u.y=u.pdf.internal.pageSize.getHeight()-u.pdf.margins_doc.bottom,u.pdf.margins_doc.bottom-=B;for(var E=x.getElementsByTagName("span"),O=0;O<E.length;++O)(" "+E[O].className+" ").replace(/[\n\t]/g," ").indexOf(" pageCounter ")>-1&&(E[O].innerHTML=U),(" "+E[O].className+" ").replace(/[\n\t]/g," ").indexOf(" totalPages ")>-1&&(E[O].innerHTML="###jsPDFVarTotalPages###");e(x,u,F),u.pdf.margins_doc.bottom+=B,u.y=M},H=x.getElementsByTagName("span"),q=0;q<H.length;++q)(" "+H[q].className+" ").replace(/[\n\t]/g," ").indexOf(" totalPages ")>-1&&u.pdf.internal.events.subscribe("htmlRenderingFinished",u.pdf.putTotalPages.bind(u.pdf,"###jsPDFVarTotalPages###"),!0);u.pdf.internal.events.subscribe("addPage",A,!1),A(),gt.FOOTER=1}},K=function(b,u,F,x,j,C){if(!u)return!1;typeof u!="string"&&!u.parentNode&&(u=""+u.innerHTML),typeof u=="string"&&(u=(function(U){var M,E,O,Y;return O="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;",E=document.createElement("div"),E.className="sjs-pdf-hidden-html-div",E.style.cssText=Y,E.innerHTML='<iframe style="height:1px;width:1px" name="'+O+'" />',document.body.appendChild(E),M=window.frames[O],M.document.open(),M.document.writeln(U),M.document.close(),M.document.body})(u.replace(/<\/?script[^>]*?>/gi,"")));for(var B=Object.keys(b.getFontList()),A=0;A<B.length;++A){var H=B[A],q=H.toLowerCase();s[q]||(s[q]=H)}var _=new g(b,F,x,j),G;return dt.call(this,u,_,j.elementHandlers,function(U){$(u,_,j.elementHandlers),e(u,_,j.elementHandlers),_.pdf.internal.events.publish("htmlRenderingFinished"),G=_.dispose(),typeof C=="function"?C(G):U&&console.error("jsPDF Warning: rendering issues? provide a callback to fromHTML!")}),G||{x:_.x,y:_.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(T){var b=!1,u=[];if(this.watchFunctions.length>0){for(var F=0;F<this.watchFunctions.length;++F)this.watchFunctions[F](T)===!0?b=!0:u.push(this.watchFunctions[F]);this.watchFunctions=u}return b},g.prototype.splitFragmentsIntoLines=function(T,b){var u,F,x,j,C,B,A,H,q,_,G,U,M;F=12,q=this.pdf.internal.scaleFactor,x=void 0,H=void 0,j=void 0,M=void 0,A=void 0,B=void 0,C=void 0,_=[],G=[_],u=0,U=this.settings.width;const E=this.pdf.getFont().fontName,O=this.pdf.getFont().fontStyle;for(;T.length;)if(j=T.shift(),M=b.shift(),j)if(x=M["font-family"],H=M["font-style"],this.pdf.setFont(x,H),A={textIndent:u,fontSize:M["font-size"]*F},B=this.pdf.getStringUnitWidth(j,A)*A.fontSize/q,j=="\u2028")_=[],G.push(_);else if(u+B>U){for(C=this.pdf.splitTextToSize(j,U,A),_.push([C.shift(),M]);C.length;)_=[[C.shift(),M]],G.push(_);u=this.pdf.getStringUnitWidth(_[0][0],A)*A.fontSize/q}else _.push([j,M]),u+=B;if(M["text-align"]!==void 0&&(M["text-align"]==="center"||M["text-align"]==="right"||M["text-align"]==="justify"))for(var Y=0;Y<G.length;++Y){var et=this.pdf.getStringUnitWidth(G[Y][0][0],A)*A.fontSize/q;Y>0&&(G[Y][0][1]=t(G[Y][0][1]));var st=U-et;if(M["text-align"]==="right")G[Y][0][1]["margin-left"]=st;else if(M["text-align"]==="center")G[Y][0][1]["margin-left"]=st/2;else if(M["text-align"]==="justify"){var lt=G[Y][0][0].split(" ").length-1;G[Y][0][1]["word-spacing"]=st/lt,Y===G.length-1&&(G[Y][0][1]["word-spacing"]=0)}}return this.pdf.setFont(E,O),G},g.prototype.RenderTextFragment=function(T,b){var u,F,x;if(x=0,u=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(b.color),this.pdf.internal.getCoordinateString(this.x),this.pdf.internal.getVerticalCoordinateString(this.y),"Td"),x=Math.max(x,b["line-height"],b["font-size"]),this.pdf.internal.write(0,(-1*u*x).toFixed(2),"Td")}F=this.pdf.internal.getFont(b["font-family"],b["font-style"]);var j=this.getPdfColor(b.color);j!==this.lastTextColor&&(this.pdf.internal.write(j),this.lastTextColor=j),b["word-spacing"]!==void 0&&b["word-spacing"]>0&&this.pdf.internal.write(b["word-spacing"].toFixed(2),"Tw");var C=function(H,q){for(var _=q.metadata.Unicode.widths,G=["","0","00","000","0000"],U=[""],M=0,E=H.length,O;M<E;++M){if(O=q.metadata.characterToGlyph(H.charCodeAt(M)),q.metadata.glyIdsUsed.push(O),q.metadata.toUnicode[O]=H.charCodeAt(M),_.indexOf(O)==-1&&(_.push(O),_.push([parseInt(q.metadata.widthOfGlyph(O),10)])),O=="0")return U.join("");O=O.toString(16),U.push(G[4-O.length],O)}return U.join("")},B=function(_,q){var _=_||"",G="",U=0,M,E="",O=q.encoding;if(q.encoding!=="Identity-H")return _;for(E=_,U=0;U<E.length;U+=1)q.metadata.hasOwnProperty("cmap")&&(M=q.metadata.cmap.unicode.codeMap[E[U].charCodeAt(0)]),M||E[U].charCodeAt(0)<256&&q.metadata.hasOwnProperty("Unicode")?G+=E[U]:G+="";var Y="";return parseInt(q.id.slice(1))<14||O==="WinAnsiEncoding"?Y=this.pdf.internal.pdfEscape(G,key).split("").map(function(et){return et.charCodeAt(0).toString(16)}).join(""):O==="Identity-H"&&(Y=C(G,q)),Y},A="";F.encoding!=="Identity-H"?A="("+this.pdf.internal.pdfEscape(T)+")":A="<"+B(T,F)+">",this.pdf.internal.write("/"+F.id,(u*b["font-size"]).toFixed(2),"Tf",A+" Tj"),b["word-spacing"]!==void 0&&this.pdf.internal.write(0,"Tw")},g.prototype.getPdfColor=function(T){var b,u,F,x,j=/rgb\s*\(\s*(\d+),\s*(\d+),\s*(\d+\s*)\)/,C=j.exec(T);if(C!=null)u=parseInt(C[1]),F=parseInt(C[2]),x=parseInt(C[3]);else{if(typeof T=="string"&&T.charAt(0)!="#"){var B=new RGBColor(T);B.ok?T=B.toHex():T="#000000"}u=T.substring(1,3),u=parseInt(u,16),F=T.substring(3,5),F=parseInt(F,16),x=T.substring(5,7),x=parseInt(x,16)}if(typeof u=="string"&&/^#[0-9A-Fa-f]{6}$/.test(u)){var A=parseInt(u.substr(1),16);u=A>>16&255,F=A>>8&255,x=A&255}var H=this.f3;return u===0&&F===0&&x===0||typeof F>"u"?b=H(u/255)+" g":b=[H(u/255),H(F/255),H(x/255),"rg"].join(" "),b},g.prototype.f3=function(T){return T.toFixed(3)},g.prototype.renderParagraph=function(T){var b,u,F,x,j,C,B,A,H,q,_,G,U,M;if(x=d(this.paragraph.text),U=this.paragraph.style,b=this.paragraph.blockstyle,this.paragraph.priorblockstyle,this.paragraph={text:[],style:[],blockstyle:{},priorblockstyle:b},!!x.join("").trim()){A=this.splitFragmentsIntoLines(x,U),B=void 0,H=void 0,u=12,F=u/this.pdf.internal.scaleFactor,this.priorMarginBottom=this.priorMarginBottom||0,G=(Math.max((b["margin-top"]||0)-this.priorMarginBottom,0)+(b["padding-top"]||0))*F,_=((b["margin-bottom"]||0)+(b["padding-bottom"]||0))*F,this.priorMarginBottom=b["margin-bottom"]||0,b["page-break-before"]==="always"&&(this.pdf.addPage(),this.y=0,G=((b["margin-top"]||0)+(b["padding-top"]||0))*F),q=this.pdf.internal.write,j=void 0,C=void 0,this.y+=G,q("q","BT 0 g",this.pdf.internal.getCoordinateString(this.x),this.pdf.internal.getVerticalCoordinateString(this.y),"Td");for(var E=0;A.length;){for(B=A.shift(),H=0,j=0,C=B.length;j!==C;)B[j][0].trim()&&(H=Math.max(H,B[j][1]["line-height"],B[j][1]["font-size"]),M=B[j][1]["font-size"]*7),j++;var O=0,Y=0;B[0][1]["margin-left"]!==void 0&&B[0][1]["margin-left"]>0&&(Y=this.pdf.internal.getCoordinateString(B[0][1]["margin-left"]),O=Y-E,E=Y);var et=Math.max(b["margin-left"]||0,0)*F;for(q(O+et,(-1*u*H).toFixed(2),"Td"),j=0,C=B.length;j!==C;)B[j][0]&&this.RenderTextFragment(B[j][0],B[j][1]),j++;if(this.y+=H*F,this.executeWatchFunctions(B[0][1])&&A.length>0){var st=[],lt=[];A.forEach(function(ht){for(var ut=0,V=ht.length;ut!==V;)ht[ut][0]&&(st.push(ht[ut][0]+" "),lt.push(ht[ut][1])),++ut}),A=this.splitFragmentsIntoLines(d(st),lt),q("ET","Q"),q("q","BT 0 g",this.pdf.internal.getCoordinateString(this.x),this.pdf.internal.getVerticalCoordinateString(this.y),"Td")}}return T&&typeof T=="function"&&T.call(this,this.x-9,this.y-M/2),q("ET","Q"),this.y+=_}},g.prototype.setBlockBoundary=function(T){return this.renderParagraph(T)},g.prototype.setBlockStyle=function(T){return this.paragraph.blockstyle=T},g.prototype.addText=function(T,b){return this.paragraph.text.push(T),this.paragraph.style.push(b)},s={helvetica:"helvetica","sans-serif":"helvetica","times new roman":"times",serif:"times",times:"times",monospace:"courier",courier:"courier"},o={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"},S={normal:1},m.fromHTML=function(T,b,u,F,x,j){return this.margins_doc=j||{top:0,bottom:0},F||(F={}),F.elementHandlers||(F.elementHandlers={}),K(this,T,isNaN(b)?4:b,isNaN(u)?4:u,F,x)}})(_t.jsPDF.API);class Pt{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*Pt.MM_TO_PT)),t.fontName?this._fontName=t.fontName:!Pt.SEGOE_BOLD&&!Pt.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=Pt.SEGOE_NORMAL,this._base64Bold=Pt.SEGOE_BOLD),this._margins=r.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}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}}Pt.MM_TO_PT=72/25.4;class xt extends Pt{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 _t.jsPDF(e),typeof this.base64Normal<"u"&&!r.isFontExist(this,this.fontName)&&(xt.addFont(this.fontName,this.base64Normal,"normal"),xt.addFont(this.fontName,this.base64Bold,"bold"),this._doc=new _t.jsPDF(e)),this._useCustomFontInHtml=t.useCustomFontInHtml&&r.isFontExist(this,this.fontName),this._helperDoc=new _t.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 o=xt.customFonts[t];if(o&&o[s]){const l=`${t}-${s}.ttf`;this.addFileToVFS(l,o[s]),this.addFont(l,t,s)}};_t.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:r.getLocString(t),i=t.split("").reduce((n,o)=>n+this._helperDoc.getTextWidth(o),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,o=e(),{color:l,opacity:a}=r.parseColor(t);s(l);let h=!1;return a!==void 0&&(n.saveGraphicsState(),n.setGState(new n.GState({[i]:a})),h=!0),()=>{s(o),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,o;const l=e?this.helperDoc:this.doc,a=l.getFontSize(),h=l.getFont(),d=l.getLineHeightFactor(),g=(s=t?.fontSize)!==null&&s!==void 0?s:a,v=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(((o=t?.lineHeight)!==null&&o!==void 0?o:g)/g),v&&this.setTextColor(t.fontColor),this.textStyleRestoreCallbacks.push({isHelper:e,callback:()=>{l.setFont(h.fontName,h.fontStyle),l.setFontSize(a),l.setLineHeightFactor(d),v&&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=cs(this.doc)),this._AcroFormCheckBox}get AcroFormComboBox(){return this._AcroFormComboBox||(this._AcroFormComboBox=us(this.doc)),this._AcroFormComboBox}get AcroFormTextField(){return this._AcroFormTextField||(this._AcroFormTextField=ls(this.doc)),this._AcroFormTextField}get AcroFormRadioButton(){return this._AcroFormRadioButton||(this._AcroFormRadioButton=hs(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((o,l)=>Math.abs(l.xRight-e)<r.EPSILON||Math.abs(l.xLeft-s)<r.EPSILON||l.pageIndex<o.pageIndex?o:l.pageIndex>o.pageIndex||l.yBot>o.yBot?l:o,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+r.EPSILON?i[i.length-1].push(...h.unfold()):i[i.length-1].push(h)})}),i.forEach(a=>{a.sort((h,d)=>h.yTop<d.yTop?-1:h.yTop>d.yTop||h.xLeft>d.xLeft?1:h.xLeft<d.xLeft?-1:0)});let n=0;const o=[],l=e.paperHeight-e.margins.bot;return i.forEach(a=>{const h=new ts;let d=0;a.forEach(g=>{let{pageIndex:v,yBot:I,absBot:S}=zt.findBotInterval(h,g.xLeft,g.xRight,e);const Z=g.height;g.yTop=I+g.yTop-S,(Math.abs(g.yTop-e.margins.top)>r.EPSILON&&g.yTop+Z>l+r.EPSILON||g.isPageBreak)&&(g.yTop=e.margins.top,v++,d=Math.max(d,v)),h.insert(g.xLeft,g.xRight,{pageIndex:v,xLeft:g.xLeft,xRight:g.xRight,yBot:g.yTop+Z,absBot:g.yBot}),g.yBot=g.yTop+Z,zt.addPack(o,n+v,g)}),n+=d+1}),o}}k.HorizontalAlign=void 0,(function(m){m.NotSet="notset",m.Left="left",m.Center="center",m.Right="right"})(k.HorizontalAlign||(k.HorizontalAlign={})),k.VerticalAlign=void 0,(function(m){m.NotSet="notset",m.Top="top",m.Middle="middle",m.Bottom="bottom"})(k.VerticalAlign||(k.VerticalAlign={}));class ne{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===k.HorizontalAlign.NotSet)&&(t.horizontalAlign=k.HorizontalAlign.Center),(typeof t.verticalAlign>"u"||t.verticalAlign===k.VerticalAlign.NotSet)&&(t.verticalAlign=k.VerticalAlign.Middle));const s=r.clone(this.rect);if(typeof t.horizontalAlign<"u")switch(t.horizontalAlign){case k.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 k.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 k.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 k.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 k.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 k.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=r.clone(t),typeof t.isBold>"u"&&(t.isBold=!1);const e=r.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=r.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 r.createImageFlat(r.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 ds{constructor(t,e,s){this.survey=t,this.controller=e,this.style=s}getTextStyle(){return this.style.text}getLinkStyle(){var t;return r.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 o of t){const a=o.text.split(/(\s+)/);for(const h of a){if(h==="")continue;const d=this.controller.measureText(h,this.getTextStyle()).width;n+d>e&&i.length>0&&(s.push(i),i=[],n=0),i.push({...o,text:h}),n+=d}}return i.length>0&&s.push(i),s.map(o=>{let l;const a=[];for(const h of o)!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 W,n=r.clone(t);for(const o of e){const l=new W;for(const a of o){const h=this.controller.measureText(a.text,this.getTextStyle());let d;a.isLink?d=new Wt(this.controller,r.createRect(n,h.width,h.height),{text:a.text,link:a.url,readOnlyShowLink:!1},this.getLinkStyle()):d=new Dt(this.controller,r.createRect(n,h.width,h.height),{text:a.text},this.getTextStyle()),l.addBrick(d),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,o)=>({xLeft:n+i,xRight:o+i}))}generateFlats(t){if(this.survey.haveCommercialLicense)return[];const e=this.survey.licenseText,s=r.getPageAvailableWidth(this.controller),i=this.getLicenseParts(e),n=this.splitPartsToFit(i,s);return this.generateLicenseFlats(t,n,s)}}let Re;function fs(m){Re=m}function Fe(){return Re()}function Qt(m,t,e){const s=Fe(),i=Fe();s.setup(m.cssVariables),i.setup(t),s.startCollectingVariables(),i.startCollectingVariables();const n=e({getColorVariable:o=>s.getColorVariable(o),getSizeVariable:o=>i.getSizeVariable(o)});return s.stopCollectingVariables(),i.stopCollectingVariables(),n}function ps(m,t){return Qt(m,t,({getSizeVariable:e,getColorVariable:s})=>{const i=e("--sjs2-base-unit-size"),n=e("--sjs2-base-unit-font-size"),o=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:o*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:o,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:o*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 je{static async process_header_events(t,e,s){var i;const n=Qt(t.theme,t.layout,o=>({text:{fontSize:10,lineHeight:12,fontStyle:"normal",fontName:"helvetica",fontColor:o.getColorVariable("--sjs2-color-fg-basic-primary")},link:{fontColor:o.getColorVariable("--sjs2-color-fg-note-primary")}}));if(!t.haveCommercialLicense){const o=new ds(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(...o)})}for(let o=0;o<s.length;o++)await t.onRenderHeader.fire(t,new ne(s[o],e,r.createHeaderRect(e),s.length,o+1)),await t.onRenderFooter.fire(t,new ne(s[o],e,r.createFooterRect(e),s.length,o+1))}}var gs={"--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 kt extends D.SurveyModel{constructor(t,e){if(super(t),this.legacyLayout={},this.onRenderHeader=new jt,this.onRenderFooter=new jt,this.onRenderQuestion=new jt,this.onRenderPanel=new jt,this.onRenderPage=new jt,this.onDocControllerCreated=new D.EventBase,this.onRenderCheckItemAcroform=new jt,this.onRenderRadioGroupWrapAcroform=new jt,this.onRenderRadioItemAcroform=new jt,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=r.clone(e),this.options.fontSize!==void 0){const s=`${this.options.fontSize/14*8}px`;r.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=ps(this.theme,this.layout)),this.styleValue}clearStyles(){this.styleValue=void 0,this.stylesHash={}}applyStyle(t){typeof t=="function"?this.styleValue=r.mergeObjects({},this.style,Qt(this.theme,this.layout,t)):this.styleValue=r.mergeObjects({},this.style,t),this.stylesHash={}}get theme(){return this._theme||D.BaseTheme}applyTheme(t,e){this._theme=r.mergeObjects({},D.BaseTheme,e??{},t),this.clearStyles()}get defaultLayout(){return this.defaultLayoutValue||(this.defaultLayoutValue=r.mergeObjects({},gs,this.legacyLayout)),this.defaultLayoutValue}get layout(){return this._layout||this.defaultLayout}applyLayout(t,e){this._layout=r.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})}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);t.getTemplate()=="composite"&&i.push("composite");const o={};i.forEach(l=>{var a;r.mergeObjects(o,(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:o};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}),o})}return this.stylesHash[e]}correctBricksPosition(t,e){t.isRTL&&e.forEach(s=>{s.forEach(i=>{i.translateX((n,o)=>{const l=t.paperWidth-n-o;return{xLeft:n+l,xRight:o+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(o=>{o.isVisible&&this.navigationMap[o.uniqueId]&&(o.isPanel?this.renderPanelNavigation(t,o,n):i.outline.add(n,o.title||o.name,{pageNumber:this.navigationMap[o.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 N.getInstance().createSurvey(this,t,this.style.survey).generateFlats();this.correctBricksPosition(t,e);const s=zt.pack(e,t);s.forEach((i,n)=>{i.forEach(o=>{o.setPageNumber(n)})}),await je.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),r.clear(),this.stylesHash={}}createDocController(){const t=St(this.style.survey.padding),e=r.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(kt.currentlySaving)kt.saveQueue.push(()=>{this.save(t)});else{const e=this.docController;kt.currentlySaving=!0,r.fixFont(e),await this.renderSurvey(e);const s=e.doc.save(t,{returnPromise:!0});return s.then(()=>{kt.currentlySaving=!1;const i=kt.saveQueue.shift();i&&i()}),s}}async raw(t){const e=this.createDocController();return this.onDocControllerCreated.fire(this,{controller:e}),r.fixFont(e),await this.renderSurvey(e),e.doc.output(t)}}kt.currentlySaving=!1,kt.saveQueue=[];class oe{constructor(t,e,s,i){this.survey=t,this.panel=e,this.controller=s,this.style=i}async generateFlats(t){const e=[],s=r.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 ss(t,e,this.panel,this.controller,N.getInstance());await this.survey.onRenderPanel.fire(this.survey,i);const n=[...i.bricks];return this.survey.afterRenderSurveyElement(this.panel,n),n}async generateContentFlats(t){if(!this.panel.isVisible)return;this.panel.onFirstRendering();const e=[];let s=r.clone(t);const i=new W;if(this.panel.hasDescriptionUnderTitle||this.panel.hasTitle){const o=await this.createHeaderFlats(s);i.addBrick(...o),s.yTop=o[o.length-1].yBot+this.style.spacing.headerContentGap+r.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 W,s={...this.style.title};let i=r.clone(t);if(this.panel.no){const o=await r.createTextFlat(i,this.controller,this.panel.no,s);e.addBrick(o),i.xLeft=o.xRight+this.controller.measureText(" ").width}const n=await r.createTextFlat(i,this.controller,this.panel.locTitle,s);return e.addBrick(n),e}async createHeaderFlats(t){const e=new At(this.controller,{...t,width:r.getPageAvailableWidth(this.controller)},this.style.header);return await e.setup(async(s,i)=>{let n=r.clone(s);if(this.panel.hasTitle){const l=await this.generateTitleFlat(n);i.push(l),n=r.createPoint(l)}if(this.panel.description){this.panel.title&&(n.yTop+=this.style.spacing.titleDescriptionGap);const l=await r.createTextFlat(n,this.controller,this.panel.locDescription,{...this.style.description});i.push(l),n=r.createPoint(l)}const o=r.createPoint(r.mergeRects(...i));i.push(r.createRowlineFlat(o,this.controller))}),[e]}getRows(t){const e=r.getPageAvailableWidth(t),s=[],i=this.style.spacing.inlineElementGap;return this.panel.rows.forEach(n=>{let o=e+i,l=[];if(!n.visible)return;n.elements.filter(h=>h.isVisible).forEach((h,d)=>{const g=this.survey.getElementStyle(h),v=h.minWidth&&h.minWidth!=="auto"?r.parseWidth(h.minWidth,e,void 0,"px"):g.minWidth,I=h.width?r.parseWidth(h.width,e,void 0,"px"):0,S=r.parseWidth(h.maxWidth?h.maxWidth:"100%",e,void 0,"px"),Z=Math.min(Math.max(v,I),S);o<Z+i&&(s.push(l),o=e-i,l=[]),o-=Z+i,l.push({element:h,width:Z})}),l.length!=0&&s.push(l)}),s.forEach(n=>{const o=n.reduce((d,g)=>d+g.width,0);let l=(e-o-(n.length-1)*i)/n.length,a=[].concat(n),h=l*n.length;for(;a.length>0&&h>0;)a=a.filter(d=>{const g=r.parseWidth(d.element.maxWidth?d.element.maxWidth:"100%",e,void 0,"px");return d.element.width&&n.length>1?!1:g>d.width+l?(h-=l,d.width=d.width+l,!0):(h-=g-d.width,d.width=g,!1)}),l=h/a.length;if(h>0){const d=n.filter(v=>!v.element.maxWidth),g=h/d.length;d.forEach(v=>{v.width+=g})}}),s}getGapBetweenRows(){return this.style.spacing.elementGap}async generateRowsFlats(t){const e=r.clone(t),s=[],i=this.getRows(this.controller);for(const n of i){let o=this.controller.margins.left;const l=[];for(let a=0;a<n.length;a++){const{element:h,width:d}=n[a],g=this.style.spacing.inlineElementGap;this.controller.pushMargins(),this.controller.margins.left=o,this.controller.margins.right=this.controller.paperWidth-this.controller.margins.left-d,e.xLeft=this.controller.margins.left;const v=this.survey.getElementStyle(h),I=new At(this.controller,{...e,width:r.getPageAvailableWidth(this.controller)},v.container);await I.setup(async(S,Z)=>{h instanceof D.PanelModel?Z.push(...await r.generatePanelFlats(this.survey,this.controller,h,S)):(await h.waitForQuestionIsReady(),Z.push(...await r.generateQuestionFlats(this.survey,this.controller,h,S)))}),l.push(I),this.controller.popMargins(),o+=d+g}if(e.xLeft=this.controller.margins.left,l.length!==0){const a=r.mergeRects(...l),h=a.yBot;e.yTop=h,l.forEach(d=>{d.fitToHeight(a.yBot-a.yTop)}),l.forEach(d=>s.push(...d.getBricks())),s.push(r.createRowlineFlat(e,this.controller)),e.xLeft=t.xLeft,e.yTop+=this.getGapBetweenRows(),o=e.xLeft}}return s}}N.registerPanel(oe);class Te extends oe{async generateTitleFlat(t){return await r.createTextFlat(t,this.controller,this.panel.locTitle,{...this.style.title})}async generateFlats(t){const e=[];e.push(...await this.generateContentFlats(t));const s=new is(t,e,this.panel,this.controller,N.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()}}N.registerPage(Te);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=r.createAcroformRect(r.createRectInsideBorders(this.contentRect,(t=this.style.borderWidth)!==null&&t!==void 0?t:0)),{color:i}=r.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,r.renderFlatBorders(this.controller,this.contentRect,this.style)}async renderReadOnly(){if(this.style.backgroundColor){this.controller.setFillColor(this.style.backgroundColor);const{lines:t,point:e}=r.getDocLinesFromShape(r.createRoundedShape(this.contentRect,this.style));this.controller.doc.lines(t,...e,[1,1],"F",!0),this.controller.restoreFillColor()}if(r.renderFlatBorders(this.controller,this.contentRect,this.style),this.options.checked){const t=r.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 r.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=r.createAcroformRect(r.createRectInsideBorders(this.contentRect,(t=this.style.borderWidth)!==null&&t!==void 0?t:0)),{color:s}=r.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,r.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}=r.getDocLinesFromShape(r.createRoundedShape(this.contentRect,this.style));this.controller.doc.lines(t,...e,[1,1],"F",!0),this.controller.restoreFillColor()}if(r.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=r.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 r.createTextFlat(e,this.controller,this.style.checkMark,t)).render()}}}class Ce extends tt{getInputStyle(t,e){const s=r.mergeObjects({},this.style.input,this.style.checkboxInput);return t&&(r.mergeObjects(s,this.style.inputReadOnly,this.style.checkboxInputReadOnly),e&&r.mergeObjects(s,this.style.inputReadOnlyChecked,this.style.checkboxInputReadOnlyChecked)),s}async generateFlatsContent(t){const e=new W,s=this.question.isReadOnly,i=s&&r.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,n=r.getPatchedTextStyle(this.controller,this.getInputStyle(s,this.question.booleanValue)),o=new Ut(this.controller,r.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(o),this.question.isLabelRendered){const l=new W,a=r.clone(t);a.xLeft=o.xRight+this.style.spacing.choiceTextGap;const h=this.question.locTitle;if(h!==null&&h.renderedHtml!==null&&l.addBrick(await r.createTextFlat(a,this.controller,h,this.style.choiceText)),this.question.isRequired){const d=this.question.requiredText,g=r.mergeObjects({},this.style.choiceText,this.style.requiredMark);if(r.hasHtml(this.question.locTitle)){const v=r.createPoint(l.unfold()[0],!1,!1);v.xLeft+=this.style.spacing.titleRequiredMarkGap,this.controller.pushMargins(),this.controller.margins.right=this.controller.paperWidth-this.controller.margins.left-this.controller.measureText(d,g).width,l.addBrick(await r.createHTMLFlat(v,this.controller,r.createHtmlContainerBlock(d,this.controller,g))),this.controller.popMargins()}else{const v=r.createPoint(l.unfold().pop(),!1,!0);v.xLeft+=this.style.spacing.titleRequiredMarkGap,l.addBrick(await r.createTextFlat(v,this.controller,d,g))}}r.alignVerticallyBricks("center",o,l.unfold()[0]),l.updateRect(),e.addBrick(l)}return[e]}}class ys extends tt{getInputStyle(t,e){const s=r.mergeObjects({},this.style.input,this.style.radioInput);return t&&(r.mergeObjects(s,this.style.inputReadOnly,this.style.radioInputReadOnly),e&&r.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&&r.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,o=r.getPatchedTextStyle(this.controller,this.getInputStyle(n,i)),l=r.createRect(t,o.width,o.height);return new Nt(this.controller,l,this.radioGroupWrap,{index:s,checked:i,shouldRenderReadOnly:n},o)}async generateFlatComposite(t,e,s){const i=new W,n=this.style.choiceText,o=this.generateFlatItem(t,e,s);i.addBrick(o);const l=r.clone(t);if(l.xLeft=o.xRight+this.style.spacing.choiceTextGap,e.locText.renderedHtml!==null){const a=await r.createTextFlat(l,this.controller,e.locText,n);r.alignVerticallyBricks("center",o,a.unfold()[0]),a.updateRect(),i.addBrick(a)}return i}async generateFlatsContent(t){const e=r.clone(t),s=new W,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(),r.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 o=r.createRowlineFlat(r.createPoint(s),this.controller);return[s,o]}}N.getInstance().register("boolean",ys),N.getInstance().register("boolean-checkbox",Ce);class re extends tt{constructor(){super(...arguments),this.generateVerticallyItems=async(t,e,s)=>{const i=r.clone(t),n=[];for(let o=0;o<e.length;o++){const l=await this.generateFlatComposite(i,e[o],o);i.yTop=l.yBot+(s||this.style.spacing.choiceGap),n.push(l)}return n}}async generateItemComment(t,e){const s=r.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),i=r.getPatchedTextStyle(this.controller,r.mergeObjects({},this.style.comment,s?this.style.commentReadOnly:void 0)),n=this.question.getCommentTextAreaModel(e);return await r.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&&r.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,i={input:r.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 W,n=this.getItemStyle(e),o=this.generateFlatItem(t,e,s,n.input);i.addBrick(o);const l=r.clone(t);if(l.xLeft=o.xRight+this.style.spacing.choiceTextGap,e.locText.renderedHtml!==null){const a=await r.createTextFlat(l,this.controller,e.locText,{...n.choiceText});r.alignVerticallyBricks("center",o,a.unfold()[0]),a.updateRect(),i.addBrick(a)}if(e.isCommentShowing){const a=r.createPoint(i,!0,!1);a.yTop+=this.style.spacing.choiceGap,i.addBrick(await this.generateItemComment(a,e))}return i}getVisibleChoices(){return this.question.visibleChoices}async generateFlatsContent(t){const e=this.question.colCount,s=this.getVisibleChoices();let i=e;if(e==0)i=Math.floor(r.getPageAvailableWidth(this.controller)/this.style.columnMinWidth)||1,s.length<i&&(i=s.length);else if(e>1&&(i=r.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=r.clone(t),o=((s=e[0])!==null&&s!==void 0?s:[]).length,l=[];for(let a of e){const h=new W;for(let g=0;g<a.length;g++){const v=a[g];this.controller.pushMargins(),r.setColumnMargins(this.controller,o,g,this.style.spacing.choiceColumnGap),n.xLeft=this.controller.margins.left;const I=await this.generateFlatComposite(n,v,i.indexOf(v));h.addBrick(I),this.controller.popMargins()}const d=r.createRowlineFlat(r.createPoint(h),this.controller);n.yTop=d.yBot+this.style.spacing.choiceGap,l.push(h,d)}return l}async generateColumns(t){const e=this.question.columns,s=e.reduce((n,o)=>Math.max(n,o.length),0),i=[];for(let n=0;n<s;n++){const o=[];for(let l of e)l[n]&&o.push(l[n]);i.push(o)}return await this.generateRows(t,i)}async generateHorisontallyItems(t,e){const s=[];return this.getVisibleChoices().forEach((n,o)=>{const l=Math.floor(o/e),a=o%e;s[l]||(s[l]=[]),s[l][a]=n}),await this.generateRows(t,s)}}class ae extends re{generateFlatItem(t,e,s,i){const n=r.createRect(t,i.width,i.height),o=this.question.isReadOnly||!e.isEnabled,l=o&&r.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress;return new Ut(this.controller,n,{shouldRenderReadOnly:l,readOnly:o,checked:this.question.isItemSelected(e),fieldName:this.question.id+"index"+s,updateOptions:a=>{this.survey.updateCheckItemAcroformOptions(a,this.question,{item:e})}},r.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 ms extends ae{getVisibleChoices(){return this.controller.tagboxSelectedChoicesOnly?this.question.selectedChoices:super.getVisibleChoices()}}N.getInstance().register("tagbox",ms),N.getInstance().register("checkbox",ae);class Pe extends tt{async generateFlatsContent(t){return N.getInstance().create(this.survey,this.question,this.controller,this.survey.getElementStyle(this.question),this.question.getType()).generateFlatsContent(t)}}N.getInstance().register("custom_model",Pe);class ke extends tt{async generateFlatsContent(t){const e=r.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),s=r.getPatchedTextStyle(this.controller,r.mergeObjects({},this.style.input,e?this.style.inputReadOnly:void 0));return[await r.createCommentFlat(t,this.controller,{shouldRenderReadOnly:e,rows:this.question.rows,isReadOnly:this.question.isReadOnly,isMultiline:!0,fieldName:this.question.id,placeholder:r.getLocString(this.question.locPlaceHolder),shouldRenderBorders:D.settings.readOnlyCommentRenderMode==="textarea",value:this.question.value},r.getPatchedTextStyle(this.controller,s))]}}N.getInstance().register("comment",ke);class Be 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}=r.parseColor(this.style.fontColor),{color:s}=r.parseColor(this.style.backgroundColor),i=new this.controller.AcroFormComboBox;i.backgroundColor=s,i.fieldName=this.options.fieldName,i.Rect=r.createAcroformRect(r.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(o=>{n.push(this.getCorrectedText(o))}),i.setOptions(n),i.fontName=this.style.fontName,i.fontSize=this.style.fontSize,i.readOnly=this.options.isReadOnly,i.isUnicode=r.isCustomFont(this.controller,i.fontName),i.V=this.getCorrectedText(this.options.value),this.controller.doc.addField(i),r.renderFlatBorders(this.controller,this.contentRect,this.style)}}class Le extends tt{async generateItemComment(t){const e=this.question.getCommentTextAreaModel(this.question.selectedItem),s=r.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),i=r.getPatchedTextStyle(this.controller,r.mergeObjects({},this.style.comment,s?this.style.commentReadOnly:void 0));return await r.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},r.getPatchedTextStyle(this.controller,i))}async generateFlatsContent(t){const e=r.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),s=r.getPatchedTextStyle(this.controller,r.mergeObjects({},this.style.input,e?this.style.inputReadOnly:void 0)),i=e?await r.createCommentFlat(t,this.controller,{fieldName:this.question.id,shouldRenderReadOnly:e,shouldRenderBorders:D.settings.readOnlyTextRenderMode==="input",value:this.question.readOnlyText||"",isReadOnly:this.question.isReadOnly,placeholder:r.getLocString(this.question.locPlaceholder)},s):new Be(this.controller,r.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(o=>r.getLocString(o.locText))},s),n=new W(i);if(this.question.isShowingChoiceComment){const o=r.createPoint(n);o.yTop+=this.style.spacing.contentCommentGap,n.addBrick(await this.generateItemComment(o))}return[n]}}N.getInstance().register("dropdown",Le);class Ie extends tt{async generateFlatsContent(t){return[await r.createCommentFlat(t,this.controller,{value:this.question.displayValue,isReadOnly:!0,shouldRenderReadOnly:r.shouldRenderReadOnly(this.question,this.controller,!0),fieldName:this.question.id,shouldRenderBorders:D.settings.readOnlyTextRenderMode==="input"},r.getPatchedTextStyle(this.controller,this.style.input))]}}N.getInstance().register("expression",Ie);class Me extends tt{async generateFlatItem(t,e){const s=new W(await r.createLinkFlat(t,this.controller,{text:e.name===void 0?"image":e.name,link:typeof e.content=="string"?e.content:"",readOnlyShowLink:r.getReadonlyRenderAs(this.question,this.controller)==="text",shouldRenderReadOnly:r.shouldRenderReadOnly(this.question,this.controller)},{...this.style.fileName}));if(this.question.canPreviewImage(e)){const i=r.createPoint(s);i.yTop+=this.style.spacing.imageFileNameGap,s.addBrick(await r.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(r.createRowlineFlat(e,this.controller)),e.yTop+=r.EPSILON,t.push(new W))}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 r.createTextFlat(t,this.controller,this.question.noFileChosenCaption)];const s=[new W],i=r.clone(t);let n=i.yTop;for(let o=0;o<e.length;o++){let l={...e[o]};const a=this.question.canPreviewImage(l);a&&(l.imageSize=await r.getCorrectedImageSize(this.controller,{imageWidth:this.question.imageWidth,imageHeight:this.question.imageHeight,imageLink:e[o].content,defaultImageWidth:200,defaultImageHeight:150}));const h=this.controller.paperWidth-this.controller.margins.right-i.xLeft;if(a){const d=await this.getImagePreviewContentWidth(l);h<d&&(i.xLeft=t.xLeft,i.yTop=n+this.style.spacing.fileItemGap,this.addLine(s,i,o,e)),this.controller.pushMargins(i.xLeft,this.controller.paperWidth-i.xLeft-d);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,o,e));const d=await this.generateFlatItem(i,l);s[s.length-1].addBrick(d),i.xLeft+=d.xRight-d.xLeft,n=Math.max(n,d.yBot)}i.xLeft+=this.style.spacing.fileItemColumnGap}return s}}N.getInstance().register("file",Me);class Se 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(!r.hasDocument)return[new Tt(this.controller,r.createRect(t,0,0))];e==="auto"&&(e=this.controller.htmlRenderAs),e==="auto"&&(e=this.chooseRender(r.getLocString(this.question.locHtml)));const s=r.createHtmlContainerBlock(r.getLocString(this.question.locHtml),this.controller,this.style.text);if(e==="image"){const i=r.getPageAvailableWidth(this.controller),{url:n,aspect:o}=await r.htmlToImage(s,i,this.controller),l=i/o;return[await r.createImageFlat(t,this.question,this.controller,{link:n,width:i,height:l})]}return[r.splitHtmlRect(this.controller,await r.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"]}),N.getInstance().register("html",Se);class Ae extends tt{async getCorrectImageSize(){return await r.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 r.createImageFlat(t,this.question,this.controller,{link:this.question.imageLink,width:e.width,height:e.height})]}}N.getInstance().register("image",Ae);class qe 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=r.mergeObjects({},this.style.input,this.style[`${i}Input`]);return t&&(r.mergeObjects(n,this.style.inputReadOnly,this.style[`${i}InputReadOnly`]),e&&r.mergeObjects(n,this.style.inputReadOnlyChecked,this.style[`${i}InputReadOnlyChecked`])),n}async generateFlatItem(t,e,s){const i=r.getPageAvailableWidth(this.controller),n=this.question.isReadOnly||!e.isEnabled,o=this.question.isItemSelected(e),l=n&&r.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,a=r.mergeObjects({},this.getInputStyle(n,o,this.question.multiSelect)),h=await r.createImageFlat(t,this.question,this.controller,{link:e.imageLink,width:i,height:i/this.style.imageRatio}),d=new W(h);let g=r.createPoint(d);if(this.question.showLabel){let S=await r.createTextFlat(g,this.controller,e.text||e.value,{...this.style.choiceText});d.addBrick(S),g=r.createPoint(S)}g.yTop+=this.style.spacing.imageInputGap;const v=a.height,I=r.createRect(g,i,v);return this.question.multiSelect?d.addBrick(new Ut(this.controller,I,{fieldName:this.question.id+"index"+s,readOnly:n,checked:o,shouldRenderReadOnly:l,updateOptions:S=>this.survey.updateCheckItemAcroformOptions(S,this.question,{item:e})},a)):d.addBrick(new Nt(this.controller,I,this.radioGroupWrap,{index:s,checked:o,shouldRenderReadOnly:l,updateOptions:S=>this.survey.updateRadioItemAcroformOptions(S,this.question,{item:e})},a)),d}getColumnsInfo(){const{imageMinWidth:t,imageMaxWidth:e}=this.style,{choiceColumnGap:s}=this.style.spacing,i=r.getPageAvailableWidth(this.controller);let n=this.question.colCount==0?this.question.visibleChoices.length:this.question.colCount,o;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)),o=l(),{columnsCount:n,columnWidth:o}}async generateFlatsContent(t){const e=[new W],{columnsCount:s,columnWidth:i}=this.getColumnsInfo(),n=Math.ceil(this.question.visibleChoices.length/s),o=r.clone(t);for(let l=0;l<n;l++){let a=o.yTop;this.controller.pushMargins();let h=this.controller.margins.left;for(let d=0;d<s;d++){const g=l*s+d;if(g==this.question.visibleChoices.length)break;this.controller.margins.left=h,this.controller.margins.right=this.controller.paperWidth-h-i,o.xLeft=this.controller.margins.left;const v=await this.generateFlatItem(o,this.question.visibleChoices[g],g);e[e.length-1].addBrick(v),h=this.controller.paperWidth-this.controller.margins.right+this.style.spacing.choiceColumnGap,a=Math.max(a,v.yBot)}this.controller.popMargins(),o.xLeft=t.xLeft,o.yTop=a,l!==n-1&&(e[e.length-1].addBrick(r.createRowlineFlat(o,this.controller)),o.yTop+=this.style.spacing.choiceGap,e.push(new W))}return e}}N.getInstance().register("imagepicker",qe);class Oe extends tt{async generateFlatsContent(t){const e=[],s=r.clone(t);for(const i of this.question.panels){const n=await r.generatePanelFlats(this.survey,this.controller,i,s);n.length!==0&&(s.yTop=r.mergeRects(...n).yBot,s.yTop+=this.style.spacing.panelGap,e.push(...n))}return e}}N.getInstance().register("paneldynamic",Oe);class le extends re{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=r.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&&r.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,updateOptions:o=>this.survey.updateRadioItemAcroformOptions(o,this.question,{item:e})},r.getPatchedTextStyle(this.controller,{...i}))}}N.getInstance().register("radiogroup",le),N.getInstance().register("buttongroup",le);class _e extends pt{constructor(t,e,s,i){super(t,e),this.options=s,this.style=i}async renderInteractive(){var t;const e=r.createRectInsideBorders(this.contentRect,(t=this.style.borderWidth)!==null&&t!==void 0?t:0),s=e.xRight-e.xLeft,i=e.yBot-e.yTop,n=r.createAcroformRect(e);if(this.style.backgroundColor&&(this.controller.setFillColor(this.style.backgroundColor),this.controller.doc.rect(...n,"F"),this.controller.restoreFillColor()),r.renderFlatBorders(this.controller,this.contentRect,this.style),this.options.mark){const o=r.createPoint(e,!0,!0),l={...this.style},a=this.controller.measureText(this.options.mark,l);o.xLeft+=s/2-a.width/2,o.yTop+=i/2-a.height/2,await(await r.createTextFlat(o,this.controller,this.options.mark,l)).render()}else{this.controller.setFillColor(this.style.fontColor);let o=r.createRect(e,this.style.fontSize,this.style.fontSize/7);o=r.moveRect(o,o.xLeft+s/2-(o.xRight-o.xLeft)/2,o.yTop+i/2-(o.yBot-o.yTop)/2),this.controller.doc.rect(...r.createAcroformRect(o),"F"),this.controller.restoreFillColor()}}}class We 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:o}=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:o,"F"),this.controller.restoreFillColor()}}class Ne extends tt{async generateFlatComposite(t,e,s,i=!1){const n=new _e(this.controller,r.createRect(t,this.style.input.width,this.style.input.height),{mark:i?"-":this.question.getNumberByIndex(s)||""},r.getPatchedTextStyle(this.controller,this.style.input)),o=r.clone(t);o.xLeft=n.xRight+this.style.spacing.choiceTextGap;const l=await r.createTextFlat(o,this.controller,e.locText,this.style.choiceText);return r.alignVerticallyBricks("center",n,l.unfold()[0]),new W(n,l)}async generateChoicesColumn(t,e,s=!1){const i=r.clone(t),n=[];for(let o=0;o<e.length;o++){const l=await this.generateFlatComposite(i,e[o],o,s);i.yTop=l.yBot+this.style.spacing.choiceGap,n.push(l)}return n}async generateSelectToRankItemsVertically(t){const e=r.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=r.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 We(this.controller,i,{color:this.style.selectToRankAreaSeparator.color})),s.push(...await this.generateChoicesColumn(e,this.question.unRankingChoices,!0)),s}async generateSelectToRankItemsHorizontally(t){const s=r.clone(t),i=[],n=Math.max(this.question.unRankingChoices.length,this.question.rankingChoices.length);let o=new W;for(let l=0;l<n;l++){let a=0;for(let v of[this.question.unRankingChoices[l],this.question.rankingChoices[l]]){if(v){this.controller.pushMargins(this.controller.margins.left,this.controller.margins.right),r.setColumnMargins(this.controller,2,a,this.style.spacing.choiceColumnGap),s.xLeft=this.controller.margins.left;const I=await this.generateFlatComposite(s,v,l,a==0);o.addBrick(I),this.controller.popMargins()}a++}const h=r.createRowlineFlat(r.createPoint(o),this.controller);i.push(o,h);const d=r.createRect({xLeft:this.controller.margins.left+r.getPageAvailableWidth(this.controller)/2-.5,yTop:s.yTop},0,0),g=this.style.spacing.choiceGap;o.addBrick(new We(this.controller,d,{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,o=new W}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)}}N.getInstance().register("ranking",Ne);class Ee 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),r.getPageAvailableWidth(this.controller))}getItemText(t,e){const s=new D.LocalizableString(e.owner,e.useMarkdown);return s.text=r.getLocString(e),t===0&&this.question.minRateDescription?s.text=this.question.locMinRateDescription.text+" "+r.getLocString(e):t===this.question.visibleRateValues.length-1&&this.question.maxRateDescription&&(s.text=r.getLocString(e)+" "+this.question.locMaxRateDescription.text),s}getInputStyle(t,e){const s={...this.style.input};return t&&(r.mergeObjects(s,this.style.inputReadOnly),e&&r.mergeObjects(s,this.style.inputReadOnlyChecked)),s}generateFlatItem(t,e,s){const i=this.question.isItemSelected(e),n=this.radioGroupWrap.readOnly&&r.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress;return new Nt(this.controller,t,this.radioGroupWrap,{index:s,checked:i,shouldRenderReadOnly:n,updateOptions:o=>this.survey.updateRadioItemAcroformOptions(o,this.question,{item:e})},r.getPatchedTextStyle(this.controller,this.getInputStyle(n,i)))}async generateItemComposite(t,e){const s=r.clone(t),i=new W,n=await r.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(r.createRect(s,e.width,this.style.input.height),e.item,e.index)),i.translateX((o,l)=>{const a=(i.width-(l-o))/2;return{xLeft:o+a,xRight:l+a}}),i}getRows(){const t=[];let e=0,s=0;const i=r.getPageAvailableWidth(this.controller);let n=i;return this.question.visibleRateValues.forEach((o,l)=>{const a=this.getItemText(l,o.locText),h=this.getItemWidth(a),d={index:l,item:o,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(d)}),t}async generateFlatsContent(t){const e=r.clone(t),s=[],i=this.getRows();for(const n of i){const o=new W;for(const l of n)this.controller.pushMargins(),this.controller.margins.left=e.xLeft,this.controller.margins.right=r.getPageAvailableWidth(this.controller)-l.width-e.xLeft,o.addBrick(await this.generateItemComposite(e,l)),this.controller.popMargins(),e.xLeft=o.xRight+this.style.spacing.choiceColumnGap;o.addBrick(r.createRowlineFlat(e,this.controller,o.width)),n!==i[i.length-1]&&(e.yTop=o.yBot+this.style.spacing.choiceGap,e.xLeft=o.xLeft),s.push(o)}return s}}N.getInstance().register("rating",Ee);class He extends tt{async generateFlatsContent(t){let e=r.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 W,i=[];for(let o=0;o<this.question.renderedValue.length;o++){const l=this.question.renderedValue[o],a=this.getOptionsByValue(l.toString()),h=r.clone(t);if(this.controller.pushMargins(),r.setColumnMargins(this.controller,2,o,this.style.spacing.inputRangeGap),h.xLeft=this.controller.margins.left,o>0){const g=r.clone(h);g.xLeft-=this.style.spacing.inputRangeGap-(this.style.spacing.inputRangeGap-this.style.rangeSeparator.width)/2,i.push(new Tt(this.controller,{...g,xRight:g.xLeft+this.style.rangeSeparator.width,yBot:g.yTop+this.style.rangeSeparator.height},this.style.rangeSeparator))}const d=await this.generateInputBrick(h,a);this.controller.popMargins(),i.push(d)}const n=r.mergeRects(...i);return i.forEach(o=>o.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:r.shouldRenderReadOnly(this.question,this.controller,s),shouldRenderBorders:!0}}async generateInputBrick(t,e){const s=r.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),i=r.getPatchedTextStyle(this.controller,r.mergeObjects({},this.style.input,s?this.style.inputReadOnly:void 0));return await r.createCommentFlat(t,this.controller,{...e,shouldRenderReadOnly:s},i)}}N.getInstance().register("slider",He);class Et extends tt{get signatureSize(){if(!this._signatureSize){let t=r.pxToPt(this.question.signatureWidth),e=r.pxToPt(this.question.signatureHeight);const s=r.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 r.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 r.createImageFlat(t,this.question,this.controller,{link:this.getSignImageUrl(),...this.signatureSize},!1):e=new Tt(this.controller,r.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};r.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 W;return this.question.backgroundImage&&e.addBrick(await this.generateBackgroundImage(t)),e.addBrick(await this.generateSign(t)),[e]}}Et.BORDER_STYLE="dashed",N.getInstance().register("signaturepad",Et);class Yt extends tt{async generateFlatsContent(t){const e=r.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),s=r.getPatchedTextStyle(this.controller,r.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:r.getLocString(this.question.locPlaceHolder)||this.question.inputValue};return[await r.createCommentFlat(t,this.controller,{shouldRenderReadOnly:e,rows:Yt.MULTILINE_TEXT_ROWS_COUNT,...i},s)]}}Yt.MULTILINE_TEXT_ROWS_COUNT=1,N.getInstance().register("text",Yt);class Ge{popRowlines(t){for(;t.length>0&&t[t.length-1]instanceof se;)t.pop()}constructor(t,e,s){this.survey=t,this.controller=e,this.style=s}async generateFlatTitle(t){const e=new W;if(this.survey.showTitle){const s=this.style;if(this.survey.title){const i={...s.title},n=await r.createTextFlat(t,this.controller,this.survey.locTitle,i);e.addBrick(n),t=r.createPoint(n)}this.survey.description&&(this.survey.title&&(t.yTop+=s.spacing.titleDescriptionGap),e.addBrick(await r.createTextFlat(t,this.controller,this.survey.locDescription,{...s.description})))}return e}async generateFlatLogoImage(t){const e=r.getLocString(this.survey.locLogo),s=await r.getCorrectedImageSize(this.controller,{imageLink:e,imageHeight:this.survey.logoHeight,imageWidth:this.survey.logoWidth,defaultImageWidth:"300px",defaultImageHeight:"200px"}),i=await r.createImageFlat(t,null,this.controller,{link:e,width:s.width,height:s.height});let n=0;return this.survey.logoPosition==="right"?n=r.getPageAvailableWidth(this.controller)-i.width:this.survey.logoPosition!=="left"&&(n=r.getPageAvailableWidth(this.controller)/2-i.width/2),i.xLeft+=n,i.xRight+=n,i}async generateFlats(){const t=[],e=new At(this.controller,{...this.controller.leftTopPoint,width:r.getPageAvailableWidth(this.controller)},this.style.header);await e.setup(async(i,n)=>{if(this.survey.hasLogo)if(this.survey.isLogoBefore){const o=await this.generateFlatLogoImage(i);n.push(o);const l=r.createPoint(o,this.survey.logoPosition==="top",this.survey.logoPosition!=="top");this.survey.logoPosition!=="top"?(this.controller.pushMargins(),l.xLeft+=this.controller.unitWidth,this.controller.margins.left+=o.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 o=await this.generateFlatLogoImage(i);n.push(o),this.controller.pushMargins(),this.controller.margins.right+=o.width+this.controller.unitWidth;const l=await this.generateFlatTitle(i);l.isEmpty||n.unshift(l),this.controller.popMargins()}else{const o=await this.generateFlatTitle(i);let l=i;o.isEmpty||(n.push(o),l=r.createPoint(o),l.yTop+=this.controller.unitHeight/2);const a=await this.generateFlatLogoImage(l);n.length,n.push(a)}else{const o=await this.generateFlatTitle(i);o.isEmpty||n.push(o)}}),e.isEmpty||t.push(e.getBricks());let s=this.controller.leftTopPoint;t.length!==0&&(s.yTop=r.createPoint(r.mergeRects(...t[0])).yTop,t[0].push(r.createRowlineFlat(s,this.controller)),s.yTop+=this.style.spacing.headerContentGap+r.EPSILON);for(let i=0;i<this.survey.visiblePages.length;i++){this.survey.currentPage=this.survey.visiblePages[i];let n=await r.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}}N.registerSurvey(Ge);class De extends tt{async generateFlatsContent(t){const e=r.getPageAvailableWidth(this.controller),s=this.question.hasRows?this.question.rowTitleWidth?r.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?xs:vs)(this.controller,this.survey,this.question,this.style).generateFlats(t)}}class ze{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 At(this.controller,{...t,width:r.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=r.clone(t),o=this.generateFlatItem(n,e);n.yTop=o.yBot+this.style.spacing.gapBetweenItemText;const l=await r.createTextFlat(n,this.controller,this.question.getCellDisplayLocText(i.name,s));return new W(o,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=r.mergeObjects({},this.style.input,this.style[`${i}Input`]);return t&&(r.mergeObjects(n,this.style.inputReadOnly,this.style[`${i}InputReadOnly`]),e&&r.mergeObjects(n,this.style.inputReadOnlyChecked,this.style[`${i}InputReadOnlyChecked`])),n}generateFlatItem(t,e){const{item:s,row:i,itemIndex:n,rowIndex:o}=e,l=this.question.id+"row"+o,a=i.isChecked(s),h=this.question.isReadOnly,d=h&&r.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,g=r.getPatchedTextStyle(this.controller,this.getInputStyle(d,a,this.question.isMultiSelect)),v=r.createRect(t,g.width,g.height);if(this.question.isMultiSelect)return new Ut(this.controller,v,{fieldName:l+"index"+n,checked:a,shouldRenderReadOnly:d,readOnly:h,updateOptions:I=>{this.survey.updateCheckItemAcroformOptions(I,this.question,{item:s,row:i,rowIndex:o})}},g);{const I=this.getRadioGroupWrap(l,i,o);return new Nt(this.controller,v,I,{checked:a,index:n,shouldRenderReadOnly:d,updateOptions:S=>this.survey.updateRadioItemAcroformOptions(S,this.question,{item:s,row:i,rowIndex:o})},g)}}getGapBetweenRows(){return this.style.spacing.tableRowGap}async generateFlats(t){const e=[];let s=r.clone(t);for(let i=0;i<this.question.visibleRows.length;i++){const n=await this.generateFlatsRow(s,this.question.visibleRows[i],i);s=r.createPoint(r.mergeRects(...n)),s.yTop+=this.getGapBetweenRows(),e.push(...n)}return e}}class xs extends ze{async generateItemComposite(t,e){const s=r.clone(t),i=this.generateFlatItem(t,e);s.xLeft=i.xRight+this.style.spacing.listChoiceTextGap;const n=await r.createTextFlat(s,this.controller,e.item.locText,r.mergeObjects({},this.style.columnTitle,this.style.listChoiceText));return r.alignVerticallyBricks("center",i,n.unfold()[0]),n.updateRect(),new W(i,n)}getGapBetweenRows(){return this.style.spacing.listSectionGap}async generateFlatsRow(t,e,s){const i=r.clone(t),n=await this.generateFlatCell(i,async(o,l)=>{const a=r.clone(o),h=await r.createTextFlat(o,this.controller,e.locText,r.mergeObjects({},this.style.rowTitle,this.style.listSectionTitle));l.push(h),a.yTop=h.yBot+this.style.spacing.listItemTitleContentGap;for(let d=0;d<this.question.visibleColumns.length;d++){const g=await(this.question.hasCellText?this.generateTextComposite:this.generateItemComposite).call(this,a,{item:this.question.visibleColumns[d],itemIndex:d,row:e,rowIndex:s});l.push(g),a.yTop=g.yBot+this.style.spacing.listChoiceGap}});return[n,r.createRowlineFlat(r.createPoint(n),this.controller)]}}class vs extends ze{setup(){const t=r.getPageAvailableWidth(this.controller);this.question.rowTitleWidth?this.rowTitleWidth=r.parseWidth(this.question.rowTitleWidth,t):this.rowTitleWidth=r.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=r.getColumnWidth(this.controller,this.question.visibleColumns.length,this.style.spacing.tableColumnGap),this.controller.popMargins()}async generateFlatsRow(t,e,s){const i=[],n=r.clone(t);this.question.hasRows&&(this.controller.pushMargins(),n.xLeft=this.controller.margins.left,this.controller.margins.right+=r.getPageAvailableWidth(this.controller)-this.rowTitleWidth,i.push(await this.generateFlatCell(n,async(a,h)=>{h.push(await r.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+=r.getPageAvailableWidth(this.controller)-this.columnWidth,i.push(await this.generateFlatCell(n,async(d,g)=>{this.question.hasCellText?g.push(await this.generateTextComposite(d,h)):g.push(this.generateFlatItem(d,h))})),n.xLeft+=this.columnWidth+this.style.spacing.tableColumnGap,this.controller.popMargins()}const o=r.mergeRects(...i);i.forEach(a=>{a.fitToHeight(o.yBot-o.yTop,!0)});const l=new W(...i);return[l,r.createRowlineFlat(r.createPoint(l),this.controller)]}async generateFlatsHeader(t){const e=[],s=r.clone(t);this.question.hasRows&&(this.controller.margins.left=s.xLeft,this.controller.margins.right+=r.getPageAvailableWidth(this.controller)-this.rowTitleWidth,e.push(await this.generateFlatCell(s,async(o,l)=>{l.push(new Tt(this.controller,r.createRect(o,r.getPageAvailableWidth(this.controller),1)))})),s.xLeft+=this.rowTitleWidth+this.style.spacing.tableColumnGap);for(let o=0;o<this.question.visibleColumns.length;o++)this.controller.pushMargins(),this.controller.margins.left=s.xLeft,this.controller.margins.right+=r.getPageAvailableWidth(this.controller)-this.columnWidth,e.push(await this.generateFlatCell(s,async(l,a)=>{a.push(await r.createTextFlat(l,this.controller,this.question.visibleColumns[o].locText,{...this.style.columnTitle}))})),s.xLeft+=this.columnWidth+this.style.spacing.tableColumnGap,this.controller.popMargins();const i=r.mergeRects(...e);e.forEach(o=>{o.fitToHeight(i.yBot-i.yTop,!0)});const n=new W(...e);return[n,r.createRowlineFlat(r.createPoint(n),this.controller)]}async generateFlats(t){this.setup();const e=r.clone(t),s=await this.generateFlatsHeader(t);e.yTop=r.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"]}),N.getInstance().register("matrix",De);class he extends tt{constructor(t,e,s,i,n=!0){super(t,e,s,i),this.survey=t,this.isMultiple=n,this.cellFlatQuestionHash={}}get visibleRows(){return this.visibleRowsValue||(this.visibleRowsValue=this.question.renderedTable.rows.filter(t=>t.visible)),this.visibleRowsValue}getFlatQuestion(t,e,s){const i=s.uniqueId.toString();return this.cellFlatQuestionHash[i]||(this.cellFlatQuestionHash[i]=r.getFlatQuestion(t,e,s)),this.cellFlatQuestionHash[i]}async generateFlatsCell(t,e,s,i=!0){let n=this.style.cell;e.hasTitle&&s!=="header"&&(n=r.mergeObjects({},n),i||(n=r.mergeObjects({},n,this.style.listSectionTitleContainer))),e.hasTitle&&s==="header"&&(n=r.mergeObjects({},n),i||(n=r.mergeObjects({},n)));const o=new At(this.controller,{...t,width:r.getPageAvailableWidth(this.controller)},n);return await o.setup(async(l,a)=>{var h,d;if(e.hasQuestion)if(s=="footer"&&!e.question.isAnswered)a.push(new Tt(this.controller,{...l,yBot:l.yTop,xRight:l.xLeft+r.getPageAvailableWidth(this.controller)}));else{const g=this.getFlatQuestion(this.survey,this.controller,e.question);if(i&&e.isChoice)a.push(g.generateFlatItem(l,e.item,e.choiceIndex,g.getItemStyle(e.item).input));else{e.question.titleLocation="matrix";const v=r.clone(l);!i&&this.question.renderedTable.showHeader&&s!=="header"&&(!((d=(h=e.cell)===null||h===void 0?void 0:h.column)===null||d===void 0)&&d.locTitle)&&(o.addBrick(await r.createTextFlat(v,this.controller,e.cell.column.locTitle,r.mergeObjects({},this.style.columnTitle,this.style.listItemTitle))),v.yTop=o.yBot+this.style.spacing.listItemTitleContentGap),a.push(...await g.generateFlats(v))}}else e.hasTitle?s=="header"?a.push(await r.createTextFlat(l,this.controller,e.locTitle,{...this.style.columnTitle})):a.push(await r.createTextFlat(l,this.controller,e.locTitle,r.mergeObjects({},this.style.rowTitle,i?void 0:this.style.listSectionTitle))):a.push(new Tt(this.controller,{...l,yBot:l.yTop,xRight:l.xLeft+r.getPageAvailableWidth(this.controller)}))}),o}get hasDetailPanel(){return this.visibleRows.some(t=>t.row&&this.question.hasDetailPanel(t.row))}ignoreCell(t,e,s,i=!0){return!i&&s=="footer"&&t.hasQuestion&&!t.question.isAnswered?!0:!(t.hasQuestion||t.hasTitle||this.isMultiple&&(this.hasDetailPanel?e==1:e==0))}getRowLocation(t){return t===this.question.renderedTable.headerRow?"header":this.question.renderedTable.footerRow===t?"footer":void 0}async generateFlatsRowHorisontal(t,e,s){const i=[],n=r.clone(t);let o=this.controller.paperWidth-this.controller.margins.left+this.style.spacing.tableColumnGap;this.controller.pushMargins();let l=0;const a=this.getRowLocation(e);for(let v=0;v<e.cells.length;v++){if(this.ignoreCell(e.cells[v],v,a))continue;this.controller.margins.left=this.controller.paperWidth-o+this.style.spacing.tableColumnGap,this.controller.margins.right=this.controller.paperWidth-this.controller.margins.left-s[l],o=this.controller.margins.right,n.xLeft=this.controller.margins.left;const I=await this.generateFlatsCell(n,e.cells[v],a);I.isEmpty||i.push(I),l++}const{yBot:h,yTop:d}=r.mergeRects(...i),g=h-d;return i.forEach(v=>{v.fitToHeight(g)}),this.controller.popMargins(),new W(...i)}async generateFlatsRowVertical(t,e){const s=new W,i=r.clone(t),n=this.getRowLocation(e);for(let o=0;o<e.cells.length;o++)this.ignoreCell(e.cells[o],o,n,!1)||(s.addBrick(await this.generateFlatsCell(i,e.cells[o],n,!1)),i.yTop=s.yBot+this.style.spacing.tableRowGap);return s}getColumnsAvalableWidth(t){return r.getPageAvailableWidth(this.controller)-(t-1)*this.style.spacing.tableColumnGap}calculateColumnWidth(t,e){const s=this.getColumnsAvalableWidth(e);let i=s,n=e;const o=[],l=[];let a=t[0].cells.filter((d,g)=>!this.ignoreCell(d,g));for(let d=0;d<e;d++){const g=r.parseWidth(a[d].width,s,e)||0;i-=g,g!==0?n--:l.push(a[d]),o.push(g)}if(n===0)return o;const h=this.style.columnMinWidth;return l.sort((d,g)=>{let v=r.parseWidth(d.minWidth,s,e)||0;return(r.parseWidth(g.minWidth,s,e)||0)>v?1:-1}).forEach(d=>{const g=i/n,v=r.parseWidth(d.minWidth,s,e)||0;v>g&&v>h&&(i-=v,n--),o[a.indexOf(d)]=Math.max(h,v,g)}),o}async generateOneRow(t,e,s,i){return s?await this.generateFlatsRowHorisontal(t,e,i):await this.generateFlatsRowVertical(t,e)}async generateFlatsRows(t,e,s,i){const n=r.clone(t),o=[];if(!e||e.length==0)return;const l=this.calculateColumnWidth(e,s);for(let a=0;a<e.length;a++){let h=await this.generateOneRow(n,e[a],i,l);if(!(h.isEmpty&&!(e[a].row&&e[a].row.hasPanel))&&(h.isEmpty||(a!==e.length-1&&(n.yTop=h.yBot,h.addBrick(r.createRowlineFlat(n,this.controller))),o.push(h),n.yTop=h.yBot+this.style.spacing.tableRowGap),e[a].row&&e[a].row.hasPanel)){e[a].row.showDetailPanel();const d=e[a].row.detailPanel;for(let S=0;S<d.questions.length;S++)d.questions[S].id+="_"+a;const g=r.clone(n),v=new W;this.isMultiple&&i&&(this.controller.pushMargins(),g.xLeft+=l[0]+this.style.spacing.tableColumnGap,this.controller.margins.left=g.xLeft);const I=await r.generatePanelFlats(this.survey,this.controller,d,g);if(this.isMultiple&&i){this.controller.popMargins();const S=r.mergeRects(...I),Z=new Tt(this.controller,{...n,xRight:n.xLeft+l[0],yBot:n.yTop+S.yBot-S.yTop},{borderMode:It.Middle,color:this.style.cell.backgroundColor,borderColor:this.style.cell.borderColor,borderRadius:this.style.cell.borderRadius,borderWidth:this.style.cell.borderWidth});v.addBrick(Z)}v.addBrick(...I),n.yTop=v.yBot+this.style.spacing.tableRowGap,o.push(v)}}return o}calculateIsWide(t,e){const s=[];if(t.showHeader&&s.push(t.headerRow),s.push(...this.visibleRows),s.length===0)return!0;const i=this.calculateColumnWidth(s,e).reduce((n,o)=>n+=o,0);return this.question.renderAs!=="list"&&this.controller.matrixRenderAs!=="list"&&Math.floor(i)<=Math.floor(this.getColumnsAvalableWidth(e))}getRowsToRender(t,e,s){const i=[],n=this.visibleRows.filter(o=>!o.isDetailRow);return t.showHeader&&s&&i.push(t.headerRow),i.push(...n),t.hasRemoveRows&&e&&i.pop(),t.showFooter&&i.push(t.footerRow),i}getColCount(t,e){return e[0]?e[0].cells.filter((s,i)=>!this.ignoreCell(s,i)).length:t.showHeader&&t.headerRow?t.headerRow.cells.length:t.showFooter&&t.footerRow?t.footerRow.cells.length:0}async generateFlatsContent(t){let e=this.question.renderedTable,s=this.question.columnLayout==="vertical",i=this.getColCount(e,this.visibleRows);if(i===0&&!this.hasDetailPanel)return[new W(r.createRowlineFlat(t,this.controller))];const n=this.calculateIsWide(e,i),o=this.question.isMobile;n||(this.question.isMobile=!0,s=!1,e=this.question.renderedTable,this.visibleRowsValue=void 0,i=this.getColCount(e,this.visibleRows));const l=this.getRowsToRender(e,s,n),a=await this.generateFlatsRows(t,l,i,n);return this.question.isMobile=o,a}}D.Serializer.removeProperty("matrixdropdown","renderAs"),D.Serializer.addProperty("matrixdropdown",{name:"renderAs",default:"auto",visible:!1,choices:["auto","list"]}),N.getInstance().register("matrixdropdown",he);class Qe extends he{constructor(t,e,s,i){super(t,e,s,i,!1),this.survey=t}}D.Serializer.removeProperty("matrixdynamic","renderAs"),D.Serializer.addProperty("matrixdynamic",{name:"renderAs",default:"auto",visible:!1,choices:["auto","list"]}),N.getInstance().register("matrixdynamic",Qe);class Ue extends tt{getVisibleRows(){return this.question.getRows().filter(t=>t.isVisible)}async generateFlatCell(t,e){const s=new At(this.controller,{...t,width:r.getPageAvailableWidth(this.controller)},this.style.itemCell);return await s.setup(e),s}async generateFlatItemCells(t,e){const s=r.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,o)=>{o.push(await r.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,o)=>{const l=N.getInstance().create(this.survey,e.editor,this.controller,this.survey.getElementStyle(e.editor),"text");o.push(...await l.generateFlatsContent(n))})),this.controller.popMargins(),i}async generateFlatsContent(t){const e=[],s=r.clone(t),i=this.getVisibleRows();for(let n=0;n<i.length;n++){this.controller.pushMargins();const o=[];for(let a=0;a<i[n].cells.length;a++)this.controller.pushMargins(),r.setColumnMargins(this.controller,this.question.colCount,a,this.style.spacing.itemColumnGap),s.xLeft=this.controller.margins.left,o.push(...await this.generateFlatItemCells(s,i[n].cells[a].item)),this.controller.popMargins();this.controller.popMargins(),s.xLeft=t.xLeft;const l=r.mergeRects(...o);o.forEach(a=>{a.fitToHeight(l.yBot-l.yTop)}),s.yTop=l.yBot,e.push(...o,r.createRowlineFlat(s,this.controller)),s.yTop+=this.style.spacing.itemGap}return e}}N.getInstance().register("multipletext",Ue);class bs 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.0.2","survey-pdf");class ws extends ve{async _getImageInfo(t){const s=new Image;return s.crossOrigin="anonymous",await new Promise((n,o)=>{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 d=l.toDataURL();n({data:d,width:s.naturalWidth*.75,height:s.naturalHeight*.75,id:this.getImageId()})},s.onerror=()=>{o()},s.src=t})}getCoverCanvasOptions(t,e,s,i){const n=t/e,o=s/i;let l,a;return o>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 o=this.getCoverCanvasOptions(t.width,t.height,s,i),l=document.createElement("canvas"),a=l.getContext("2d");return l.width=o.canvasWidth,l.height=o.canvasHeight,a?.drawImage(n,o.imageX,o.imageY,o.imageWidth,o.imageHeight),{data:l.toDataURL(),width:s,height:i}}catch{return t}else return super.applyImageFit(t,e,s,i)}}function Rs(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,o=a=>{const h=a.toString(16);return h.length===1?"0"+h:h},l=n?o(Math.round(n*255)):"";return`#${o(e)}${o(s)}${o(i)}${l}`}function Fs(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]),o=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}, ${o})`}else return m}class js{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=Fs(i),Rs(i)})}}os(new ws),fs(()=>new js),k.CheckItemBrick=Ut,k.CompositeBrick=W,k.CustomBrick=bs,k.DocController=xt,k.DocOptions=Pt,k.DrawCanvas=ne,k.DropdownBrick=Be,k.EmptyBrick=Tt,k.EventHandler=je,k.FlatBoolean=Ce,k.FlatCheckbox=ae,k.FlatComment=ke,k.FlatCustomModel=Pe,k.FlatDropdown=Le,k.FlatExpression=Ie,k.FlatFile=Me,k.FlatHTML=Se,k.FlatImage=Ae,k.FlatImagePicker=qe,k.FlatMatrix=De,k.FlatMatrixDynamic=Qe,k.FlatMatrixMultiple=he,k.FlatMultipleText=Ue,k.FlatPage=Te,k.FlatPanel=oe,k.FlatPanelDynamic=Oe,k.FlatQuestion=tt,k.FlatQuestionDefault=ge,k.FlatRadiogroup=le,k.FlatRanking=Ne,k.FlatRating=Ee,k.FlatRepository=N,k.FlatSelectBase=re,k.FlatSignaturePad=Et,k.FlatSlider=He,k.FlatSurvey=Ge,k.FlatTextbox=Yt,k.HTMLBrick=ye,k.ImageBrick=me,k.LinkBrick=Wt,k.PagePacker=zt,k.PdfBrick=pt,k.RadioItemBrick=Nt,k.RankingItemBrick=_e,k.RowlineBrick=se,k.SurveyHelper=r,k.SurveyPDF=kt,k.TextBrick=Dt,k.TextFieldBrick=xe}));