@knoopx/react-pdf
Version:
<p align="center"> <img src="https://user-images.githubusercontent.com/5600341/27505816-c8bc37aa-587f-11e7-9a86-08a2d081a8b9.png" height="280px"> <p align="center">React renderer for creating PDF files on the browser and server<p> <p align="center">
1 lines • 80.8 kB
JavaScript
"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var _inheritsLoose=_interopDefault(require("@babel/runtime/helpers/inheritsLoose")),_objectWithoutPropertiesLoose=_interopDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose")),_extends=_interopDefault(require("@babel/runtime/helpers/extends")),React=require("react"),React__default=_interopDefault(React),_regeneratorRuntime=_interopDefault(require("@babel/runtime/regenerator")),_asyncToGenerator=_interopDefault(require("@babel/runtime/helpers/asyncToGenerator")),BlobStream=_interopDefault(require("blob-stream")),ReactFiberReconciler=_interopDefault(require("react-reconciler")),_createClass=_interopDefault(require("@babel/runtime/helpers/createClass")),PDFDocument=require("@react-pdf/pdfkit"),PDFDocument__default=_interopDefault(PDFDocument),Yoga=_interopDefault(require("yoga-layout-prebuilt")),ramda=require("ramda"),matchMedia=_interopDefault(require("media-engine")),_assertThisInitialized=_interopDefault(require("@babel/runtime/helpers/assertThisInitialized")),PDFRenderer$1=_interopDefault(require("@react-pdf/textkit/renderers/pdf")),AttributedString=_interopDefault(require("@react-pdf/textkit/attributedString"));require("is-url");var fontkit=_interopDefault(require("@react-pdf/fontkit")),fetch=_interopDefault(require("cross-fetch")),layoutEngine=_interopDefault(require("@react-pdf/textkit/layout")),linebreaker=_interopDefault(require("@react-pdf/textkit/engines/linebreaker")),justification=_interopDefault(require("@react-pdf/textkit/engines/justification")),textDecoration=_interopDefault(require("@react-pdf/textkit/engines/textDecoration")),scriptItemizer=_interopDefault(require("@react-pdf/textkit/engines/scriptItemizer")),wordHyphenation=_interopDefault(require("@react-pdf/textkit/engines/wordHyphenation")),emojiRegex=_interopDefault(require("emoji-regex")),PNG=_interopDefault(require("@react-pdf/png-js")),_wrapPages=_interopDefault(require("page-wrapping"));function printWarning(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];var i=0,o="Warning: "+t.replace(/%s/g,function(){return r[i++]});"undefined"!=typeof console&&console.error(o);try{throw new Error(o)}catch(t){}}var __DEV__="production"!==process.env.NODE_ENV,warning=__DEV__?function(t,e){if(void 0===e)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(!t){for(var r=arguments.length,n=new Array(r>2?r-2:0),i=2;i<r;i++)n[i-2]=arguments[i];printWarning.apply(void 0,[e].concat(n))}}:function(){},Root=function(){function t(){this.isDirty=!1,this.document=null,this.instance=null}var e=t.prototype;return e.appendChild=function(t){this.document=t},e.removeChild=function(){this.document.cleanup(),this.document=null},e.markDirty=function(){this.isDirty=!0},e.cleanup=function(){this.document.cleanup()},e.finish=function(){this.document.finish()},e.render=function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function t(){return _regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return this.instance=new PDFDocument__default({autoFirstPage:!1}),t.next=3,this.document.render();case 3:this.cleanup(),this.isDirty=!1;case 5:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}(),_createClass(t,[{key:"name",get:function(){return"Root"}}]),t}(),upperFirst=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},isPercent=function(t){return/((-)?\d+\.?\d*)%/g.exec(t)},matchPercent=function(t){var e=isPercent(t);if(e){var r=parseFloat(e[1],10),n=r/100;return{value:r,percent:n,absValue:Math.abs(r),absPercent:Math.abs(n)}}return null},Node=function(){function t(){this.parent=null,this.children=[],this.computed=!1,this.layout=Yoga.Node.createDefault()}var e=t.prototype;return e.appendChild=function(t){t&&(t.parent=this,this.children.push(t),this.layout.insertChild(t.layout,this.layout.getChildCount()))},e.appendChildBefore=function(t,e){var r=this.children.indexOf(e);-1!==r&&t&&(t.parent=this,this.children.splice(r,0,t),this.layout.insertChild(t.layout,r))},e.removeChild=function(t){var e=this.children.indexOf(t);-1!==e&&(t.parent=null,this.children.splice(e,1),this.layout.removeChild(t.layout)),t.cleanup()},e.removeAllChilds=function(){for(var t=[].concat(this.children),e=0;e<t.length;e++)t[e].remove()},e.remove=function(){this.parent.removeChild(this)},e.setDimension=function(t,e){var r="set"+upperFirst(t),n=r+"Percent",i=matchPercent(e);i?this.layout[n](i.value):this.layout[r](e)},e.setPosition=function(t,e){var r=matchPercent(e);r?this.layout.setPositionPercent(t,r.value):this.layout.setPosition(t,e)},e.setPadding=function(t,e){var r=matchPercent(e);r?this.layout.setPaddingPercent(t,r.value):this.layout.setPadding(t,e)},e.setMargin=function(t,e){var r=matchPercent(e);r?this.layout.setMarginPercent(t,r.value):this.layout.setMargin(t,e)},e.setBorder=function(t,e){if(matchPercent(e))throw new Error("Node: You cannot set percentage border widths");this.layout.setBorder(t,e)},e.getAbsoluteLayout=function(){var t=this.parent,e=t&&t.getAbsoluteLayout?t.getAbsoluteLayout():{left:0,top:0};return{left:this.left+e.left,top:this.top+e.top,height:this.height,width:this.width}},e.copyStyle=function(t){this.layout.copyStyle(t.layout)},e.calculateLayout=function(){this.layout.calculateLayout(),this.computed=!0},e.isEmpty=function(){return 0===this.children.length},e.markDirty=function(){return this.layout.markDirty()},e.onAppendDynamically=function(){},e.cleanup=function(){this.children.forEach(function(t){return t.cleanup()}),this.layout.unsetMeasureFunc(),Yoga.Node.destroy(this.layout)},_createClass(t,[{key:"position",get:function(){return this.layout.getPositionType()===Yoga.POSITION_TYPE_ABSOLUTE?"absolute":"relative"},set:function(t){this.layout.setPositionType("absolute"===t?Yoga.POSITION_TYPE_ABSOLUTE:Yoga.POSITION_TYPE_RELATIVE)}},{key:"top",get:function(){return this.layout.getComputedTop()||0},set:function(t){this.setPosition(Yoga.EDGE_TOP,t)}},{key:"left",get:function(){return this.layout.getComputedLeft()||0},set:function(t){this.setPosition(Yoga.EDGE_LEFT,t)}},{key:"right",get:function(){return this.layout.getComputedRight()||0},set:function(t){this.setPosition(Yoga.EDGE_RIGHT,t)}},{key:"bottom",get:function(){return this.layout.getComputedBottom()||0},set:function(t){this.setPosition(Yoga.EDGE_BOTTOM,t)}},{key:"width",get:function(){return this.layout.getComputedWidth()},set:function(t){this.setDimension("width",t)}},{key:"minWidth",get:function(){return this.layout.getMinWidth().value},set:function(t){this.setDimension("minWidth",t)}},{key:"maxWidth",get:function(){return this.layout.getMaxWidth().value},set:function(t){this.setDimension("maxWidth",t)}},{key:"height",get:function(){return this.layout.getComputedHeight()},set:function(t){this.setDimension("height",t)}},{key:"minHeight",get:function(){return this.layout.getMinHeight().value},set:function(t){this.setDimension("minHeight",t)}},{key:"maxHeight",get:function(){return this.layout.getMaxHeight().value},set:function(t){this.setDimension("maxHeight",t)}},{key:"paddingTop",get:function(){return this.layout.getComputedPadding(Yoga.EDGE_TOP)||0},set:function(t){this.setPadding(Yoga.EDGE_TOP,t)}},{key:"paddingRight",get:function(){return this.layout.getComputedPadding(Yoga.EDGE_RIGHT)||0},set:function(t){this.setPadding(Yoga.EDGE_RIGHT,t)}},{key:"paddingBottom",get:function(){return this.layout.getComputedPadding(Yoga.EDGE_BOTTOM)||0},set:function(t){this.setPadding(Yoga.EDGE_BOTTOM,t)}},{key:"paddingLeft",get:function(){return this.layout.getComputedPadding(Yoga.EDGE_LEFT)||0},set:function(t){this.setPadding(Yoga.EDGE_LEFT,t)}},{key:"marginTop",get:function(){return this.layout.getComputedMargin(Yoga.EDGE_TOP)||0},set:function(t){this.setMargin(Yoga.EDGE_TOP,t)}},{key:"marginRight",get:function(){return this.layout.getComputedMargin(Yoga.EDGE_RIGHT)||0},set:function(t){this.setMargin(Yoga.EDGE_RIGHT,t)}},{key:"marginBottom",get:function(){return this.layout.getComputedMargin(Yoga.EDGE_BOTTOM)||0},set:function(t){this.setMargin(Yoga.EDGE_BOTTOM,t)}},{key:"marginLeft",get:function(){return this.layout.getComputedMargin(Yoga.EDGE_LEFT)||0},set:function(t){this.setMargin(Yoga.EDGE_LEFT,t)}},{key:"borderTopWidth",get:function(){return this.layout.getComputedBorder(Yoga.EDGE_TOP)||0},set:function(t){this.setBorder(Yoga.EDGE_TOP,t)}},{key:"borderRightWidth",get:function(){return this.layout.getComputedBorder(Yoga.EDGE_RIGHT)||0},set:function(t){this.setBorder(Yoga.EDGE_RIGHT,t)}},{key:"borderBottomWidth",get:function(){return this.layout.getComputedBorder(Yoga.EDGE_BOTTOM)||0},set:function(t){this.setBorder(Yoga.EDGE_BOTTOM,t)}},{key:"borderLeftWidth",get:function(){return this.layout.getComputedBorder(Yoga.EDGE_LEFT)||0},set:function(t){this.setBorder(Yoga.EDGE_LEFT,t)}},{key:"padding",get:function(){return{top:this.paddingTop,right:this.paddingRight,bottom:this.paddingBottom,left:this.paddingLeft}},set:function(t){this.paddingTop=t,this.paddingRight=t,this.paddingBottom=t,this.paddingLeft=t}},{key:"margin",get:function(){return{top:this.marginTop,right:this.marginRight,bottom:this.marginBottom,left:this.marginLeft}},set:function(t){this.marginTop=t,this.marginRight=t,this.marginBottom=t,this.marginLeft=t}}]),t}(),yogaValue=function(t,e){var r=function(t){return"alignItems"===t||"alignContent"===t||"alignSelf"===t};switch(e){case"auto":if("alignSelf"===t)return Yoga.ALIGN_AUTO;break;case"flex":return Yoga.DISPLAY_FLEX;case"none":return Yoga.DISPLAY_NONE;case"row":return Yoga.FLEX_DIRECTION_ROW;case"row-reverse":return Yoga.FLEX_DIRECTION_ROW_REVERSE;case"column":return Yoga.FLEX_DIRECTION_COLUMN;case"column-reverse":return Yoga.FLEX_DIRECTION_COLUMN_REVERSE;case"stretch":return Yoga.ALIGN_STRETCH;case"baseline":return Yoga.ALIGN_BASELINE;case"space-around":if("justifyContent"===t)return Yoga.JUSTIFY_SPACE_AROUND;if(r(t))return Yoga.ALIGN_SPACE_AROUND;break;case"space-between":if("justifyContent"===t)return Yoga.JUSTIFY_SPACE_BETWEEN;if(r(t))return Yoga.ALIGN_SPACE_BETWEEN;break;case"around":return Yoga.JUSTIFY_SPACE_AROUND;case"between":return Yoga.JUSTIFY_SPACE_BETWEEN;case"wrap":return Yoga.WRAP_WRAP;case"wrap-reverse":return Yoga.WRAP_WRAP_REVERSE;case"nowrap":return Yoga.WRAP_NO_WRAP;case"flex-start":if("justifyContent"===t)return Yoga.JUSTIFY_FLEX_START;if(r(t))return Yoga.ALIGN_FLEX_START;break;case"flex-end":if("justifyContent"===t)return Yoga.JUSTIFY_FLEX_END;if(r(t))return Yoga.ALIGN_FLEX_END;break;case"center":if("justifyContent"===t)return Yoga.JUSTIFY_CENTER;if(r(t))return Yoga.ALIGN_CENTER;break;default:return e}},DPI=72,parseValue=function(t){var e=/^(-?\d*\.?\d+)(in|mm|cm|pt|vh|vw)?$/g.exec(t);return e?{value:parseFloat(e[1],10),unit:e[2]||"pt"}:{value:t,unit:void 0}},parseScalar=function(t,e){var r=parseValue(t);switch(r.unit){case"in":return r.value*DPI;case"mm":return r.value*(1/25.4)*DPI;case"cm":return r.value*(1/2.54)*DPI;case"vh":if(e.isAutoHeight)throw new Error("vh unit not supported in auto-height pages. Please specify page height if you want to use vh.");return r.value*(e.height/100);case"vw":return r.value*(e.width/100);default:return r.value}},isBorderStyle=function(t,e){return t.match(/^border/)&&"string"==typeof e},matchBorderShorthand=function(t){return t.match(/(\d+(px|in|mm|cm|pt|vw|vh)?)\s(\S+)\s(\S+)/)},processBorders=function(t,e){var r=matchBorderShorthand(e);if(r){if(t.match(/.Color/))return r[4];if(t.match(/.Style/))return r[3];if(t.match(/.Width/))return r[1];throw new Error("StyleSheet: Invalid '"+e+"' for '"+t+"'")}return e},isBoxModelStyle=function(t,e){return t.match(/^(margin)|(padding)/)&&"string"==typeof e},matchBoxModel=function(t){return t.match(/\d+(px|in|mm|cm|pt|%|vw|vh)?/g)},processBoxModel=function(t,e){var r=matchBoxModel(e);if(r){if(t.match(/.Top/))return r[0];if(t.match(/.Right/))return r[1]||r[0];if(t.match(/.Bottom/))return r[2]||r[0];if(t.match(/.Left/))return r[3]||r[1]||r[0];throw new Error("StyleSheet: Invalid '"+e+"' for '"+t+"'")}return e},FONT_WEIGHTS={thin:100,hairline:100,ultralight:200,extralight:200,light:300,normal:400,medium:500,semibold:600,demibold:600,bold:700,ultrabold:800,extrabold:800,heavy:900,black:900},isFontWeightStyle=function(t){return t.match(/^fontWeight/)},processFontWeight=function(t){return t?"number"==typeof t?t:FONT_WEIGHTS[t.toLowerCase()]:FONT_WEIGHTS.normal},isObjectPositionStyle=function(t,e){return t.match(/^objectPosition/)&&"string"==typeof e},matchObjectPosition=function(t){return t.match(/\d+(px|in|mm|cm|pt|%|vw|vh)?/g)},processObjectPosition=function(t,e){var r=matchObjectPosition(e);if(r){if(t.match(/.X/))return r[0];if(t.match(/.Y/))return r[1];throw new Error("StyleSheet: Invalid '"+e+"' for '"+t+"'")}return e},isTransformOriginStyle=function(t,e){return t.match(/^transformOrigin/)&&"string"==typeof e},matchTransformOrigin=function(t){return t.match(/(-?\d+(px|in|mm|cm|pt|%|vw|vh)?)|top|right|bottom|left|center/g)},transformOffsetKeywords=function(t){switch(t){case"top":case"left":return"0%";case"right":case"bottom":return"100%";case"center":return"50%";default:return t}},processTransformOrigin=function(t,e){var r=matchTransformOrigin(e);if(r){var n;if(t.match(/.X/))n=r[0];else{if(!t.match(/.Y/))throw new Error("StyleSheet: Invalid '"+e+"' for '"+t+"'");n=r[1]||r[0]}return transformOffsetKeywords(n)}return e},hasOwnProperty=Object.prototype.hasOwnProperty,styleShorthands={margin:{marginTop:!0,marginRight:!0,marginBottom:!0,marginLeft:!0},marginHorizontal:{marginLeft:!0,marginRight:!0},marginVertical:{marginTop:!0,marginBottom:!0},padding:{paddingTop:!0,paddingRight:!0,paddingBottom:!0,paddingLeft:!0},paddingHorizontal:{paddingLeft:!0,paddingRight:!0},paddingVertical:{paddingTop:!0,paddingBottom:!0},border:{borderTopColor:!0,borderTopStyle:!0,borderTopWidth:!0,borderRightColor:!0,borderRightStyle:!0,borderRightWidth:!0,borderBottomColor:!0,borderBottomStyle:!0,borderBottomWidth:!0,borderLeftColor:!0,borderLeftStyle:!0,borderLeftWidth:!0},borderTop:{borderTopColor:!0,borderTopStyle:!0,borderTopWidth:!0},borderRight:{borderRightColor:!0,borderRightStyle:!0,borderRightWidth:!0},borderBottom:{borderBottomColor:!0,borderBottomStyle:!0,borderBottomWidth:!0},borderLeft:{borderLeftColor:!0,borderLeftStyle:!0,borderLeftWidth:!0},borderColor:{borderTopColor:!0,borderRightColor:!0,borderBottomColor:!0,borderLeftColor:!0},borderRadius:{borderTopLeftRadius:!0,borderTopRightRadius:!0,borderBottomRightRadius:!0,borderBottomLeftRadius:!0},borderStyle:{borderTopStyle:!0,borderRightStyle:!0,borderBottomStyle:!0,borderLeftStyle:!0},borderWidth:{borderTopWidth:!0,borderRightWidth:!0,borderBottomWidth:!0,borderLeftWidth:!0},objectPosition:{objectPositionX:!0,objectPositionY:!0},transformOrigin:{transformOriginX:!0,transformOriginY:!0}},expandStyles=function(t){if(!t)return t;for(var e=Object.keys(t),r={},n=0;n<e.length;n++){var i=e[n],o=t[i];switch(i){case"display":case"flex":case"flexDirection":case"flexWrap":case"flexFlow":case"flexGrow":case"flexShrink":case"flexBasis":case"justifyContent":case"alignSelf":case"alignItems":case"alignContent":case"order":r[i]=yogaValue(i,o);break;case"textAlignVertical":r.verticalAlign="center"===o?"middle":o;break;case"margin":case"marginHorizontal":case"marginVertical":case"padding":case"paddingHorizontal":case"paddingVertical":case"border":case"borderTop":case"borderRight":case"borderBottom":case"borderLeft":case"borderColor":case"borderRadius":case"borderStyle":case"borderWidth":case"objectPosition":case"transformOrigin":var a=styleShorthands[i];for(var s in a)hasOwnProperty.call(a,s)&&(r[s]=o);break;default:r[i]=o}}return r},transformStyles=function(t,e){for(var r=expandStyles(t),n=Object.keys(r),i={},o=0;o<n.length;o++){var a=n[o],s=r[a],u=void 0;u=isBorderStyle(a,s)?processBorders(a,s):isBoxModelStyle(a,s)?processBoxModel(a,s):isObjectPositionStyle(a,s)?processObjectPosition(a,s):isTransformOriginStyle(a,s)?processTransformOrigin(a,s):isFontWeightStyle(a)?processFontWeight(s):s,i[a]=parseScalar(u,e)}return i},create=function(t){return t},flatten=function t(e){return Array.isArray(e)||(e=[e]),e.reduce(function(e,r){if(r){var n=Array.isArray(r)?t(r):r;Object.keys(n).forEach(function(t){null!==n[t]&&void 0!==n[t]&&(e[t]=n[t])})}return e},{})},resolveMediaQueries=function(t,e){return Object.keys(t).reduce(function(r,n){var i,o;return/@media/.test(n)?_extends({},r,{},matchMedia(((o={})[n]=t[n],o),e)):_extends({},r,((i={})[n]=t[n],i))},{})},resolve=function(t,e){return t?(t=flatten(t),t=resolveMediaQueries(t,e),t=transformStyles(t,e)):null},absoluteFillObject={position:"absolute",top:0,left:0,bottom:0,right:0},StyleSheet={hairlineWidth:1,create:create,resolve:resolve,flatten:flatten,absoluteFillObject:absoluteFillObject},Debug={debug:function(){var t=this.getAbsoluteLayout(),e=this.padding,r=this.margin;this.root.instance.save(),this.debugContent(t,r,e),this.debugPadding(t,r,e),this.debugMargin(t,r),this.debugText(t,r),this.debugOrigin(),this.root.instance.restore()},debugOrigin:function(){if(this.style.transform){var t=this.origin;this.root.instance.circle(t[0],t[1],3).fill("red").circle(t[0],t[1],5).stroke("red")}},debugText:function(t,e){var r=Math.round(this.width+e.left+e.right),n=Math.round(this.height+e.top+e.bottom);this.root.instance.fontSize(4).opacity(1).fillColor("black").text(r+" x "+n,t.left-e.left,Math.max(t.top-e.top-4,1))},debugContent:function(t,e,r){this.root.instance.fillColor("#a1c6e7").opacity(.5).rect(t.left+r.left,t.top+r.top,t.width-r.left-r.right,t.height-r.top-r.bottom).fill()},debugPadding:function(t,e,r){this.root.instance.fillColor("#c4deb9").opacity(.5),this.root.instance.rect(t.left+r.left,t.top,t.width-r.right-r.left,r.top).fill(),this.root.instance.rect(t.left,t.top,r.left,t.height).fill(),this.root.instance.rect(t.left+t.width-r.right,t.top,r.right,t.height).fill(),this.root.instance.rect(t.left+r.left,t.top+t.height-r.bottom,t.width-r.right-r.left,r.bottom).fill()},debugMargin:function(t,e){this.root.instance.fillColor("#f8cca1").opacity(.5),this.root.instance.rect(t.left,t.top-e.top,t.width,e.top).fill(),this.root.instance.rect(t.left-e.left,t.top-e.top,e.left,t.height+e.top+e.bottom).fill(),this.root.instance.rect(t.left+t.width,t.top-e.top,e.right,t.height+e.top+e.bottom).fill(),this.root.instance.rect(t.left,t.top+t.height,t.width,e.bottom).fill()}},KAPPA=(Math.sqrt(2)-1)/3*4;function drawBorders(){var t=this.root.instance,e=this.getAbsoluteLayout(),r=this.borderTopWidth,n=this.borderLeftWidth,i=this.borderRightWidth,o=this.borderBottomWidth,a=this.style,s=a.opacity,u=a.borderTopLeftRadius,c=void 0===u?0:u,h=a.borderTopRightRadius,l=void 0===h?0:h,d=a.borderBottomLeftRadius,f=void 0===d?0:d,p=a.borderBottomRightRadius,g=void 0===p?0:p,m=a.borderTopColor,y=void 0===m?"black":m,v=a.borderTopStyle,b=void 0===v?"solid":v,T=a.borderLeftColor,R=void 0===T?"black":T,_=a.borderLeftStyle,P=void 0===_?"solid":_,E=a.borderRightColor,C=void 0===E?"black":E,w=a.borderRightStyle,x=void 0===w?"solid":w,S=a.borderBottomColor,k=void 0===S?"black":S,A=a.borderBottomStyle,D={borderTopColor:y,borderTopWidth:r,borderTopStyle:b,borderLeftColor:R,borderLeftWidth:n,borderLeftStyle:P,borderRightColor:C,borderRightWidth:i,borderRightStyle:x,borderBottomColor:k,borderBottomWidth:o,borderBottomStyle:void 0===A?"solid":A,borderTopLeftRadius:c,borderTopRightRadius:l,borderBottomLeftRadius:f,borderBottomRightRadius:g},L=e.width,O=e.height,I=Math.min(l,.5*L,.5*O),B=Math.min(c,.5*L,.5*O),F=Math.min(g,.5*L,.5*O),M=Math.min(f,.5*L,.5*O);t.save(),t.strokeOpacity(s),r&&(t.save(),clipBorderTop(t,e,D,I,B),fillBorderTop(t,e,D,I,B),t.restore()),i&&(t.save(),clipBorderRight(t,e,D,I,F),fillBorderRight(t,e,D,I,F),t.restore()),o&&(t.save(),clipBorderBottom(t,e,D,M,F),fillBorderBottom(t,e,D,M,F),t.restore()),n&&(t.save(),clipBorderLeft(t,e,D,M,B),fillBorderLeft(t,e,D,M,B),t.restore()),t.restore()}var clipBorderTop=function(t,e,r,n,i){var o=e.top,a=e.left,s=e.width,u=e.height,c=r.borderTopWidth,h=r.borderRightWidth,l=r.borderLeftWidth;t.moveTo(a+i,o),t.lineTo(a+s-n,o);var d=n*(1-KAPPA);t.bezierCurveTo(a+s-d,o,a+s,o+d,a+s,o+n);var f=o+Math.max(c,n);t.lineTo(a+s,f),t.lineTo(a+s-h,f);var p=Math.max(n-h,0),g=Math.max(n-c,0),m=p*(1-KAPPA),y=g*(1-KAPPA);t.bezierCurveTo(a+s-h,o+c+y,a+s-h-m,o+c,a+s-h-p,o+c),t.lineTo(a+Math.max(i,l),o+c);var v=Math.max(i-l,0),b=Math.max(i-c,0),T=v*(1-KAPPA),R=b*(1-KAPPA),_=o+Math.max(c,i);t.bezierCurveTo(a+l+T,o+c,a+l,o+c+R,a+l,_),t.lineTo(a,_),t.lineTo(a,o+i);var P=i*(1-KAPPA);if(t.bezierCurveTo(a,o+P,a+P,o,a+i,o),t.closePath(),t.clip(),h){var E=-c/h;t.moveTo(a+s/2,E*(-s/2)+o),t.lineTo(a+s,o),t.lineTo(a,o),t.lineTo(a,o+u),t.closePath(),t.clip()}if(l){var C=-c/l;t.moveTo(a+s/2,C*(-s/2)+o),t.lineTo(a,o),t.lineTo(a+s,o),t.lineTo(a+s,o+u),t.closePath(),t.clip()}},fillBorderTop=function(t,e,r,n,i){var o=e.top,a=e.left,s=e.width,u=r.borderTopColor,c=r.borderTopWidth,h=r.borderTopStyle,l=r.borderRightWidth,d=r.borderLeftWidth,f=i*(1-KAPPA),p=n*(1-KAPPA);t.moveTo(a,o+Math.max(i,c)),t.bezierCurveTo(a,o+f,a+f,o,a+i,o),t.lineTo(a+s-n,o),t.bezierCurveTo(a+s-p,o,a+s,o+p,a+s,o+n),t.strokeColor(u),t.lineWidth(2*Math.max(l,c,d)),"dashed"===h?t.dash(2*c,{space:1.2*c}):"dotted"===h&&t.dash(c,{space:1.2*c}),t.stroke(),t.undash()},clipBorderRight=function(t,e,r,n,i){var o=e.top,a=e.left,s=e.width,u=e.height,c=r.borderTopWidth,h=r.borderRightWidth,l=r.borderBottomWidth;t.moveTo(a+s,o+n),t.lineTo(a+s,o+u-i);var d=i*(1-KAPPA);t.bezierCurveTo(a+s,o+u-d,a+s-d,o+u,a+s-i,o+u);var f=a+s-Math.max(h,i);t.lineTo(f,o+u),t.lineTo(f,o+u-l);var p=Math.max(i-h,0),g=Math.max(i-l,0),m=p*(1-KAPPA),y=g*(1-KAPPA);t.bezierCurveTo(a+s-h-m,o+u-l,a+s-h,o+u-l-y,a+s-h,o+u-Math.max(i,l)),t.lineTo(a+s-h,o+Math.max(n,c));var v=Math.max(n-h,0),b=Math.max(n-c,0),T=v*(1-KAPPA),R=b*(1-KAPPA),_=a+s-Math.max(n,h);t.bezierCurveTo(a+s-h,o+c+R,a+s-h-T,o+c,_,o+c),t.lineTo(_,o),t.lineTo(a+s-n,o);var P=n*(1-KAPPA);if(t.bezierCurveTo(a+s-P,o,a+s,o+P,a+s,o+n),t.closePath(),t.clip(),c){var E=-c/h;t.moveTo(a+s/2,E*(-s/2)+o),t.lineTo(a+s,o),t.lineTo(a+s,o+u),t.lineTo(a,o+u),t.closePath(),t.clip()}if(l){var C=l/h;t.moveTo(a+s/2,C*(-s/2)+o+u),t.lineTo(a+s,o+u),t.lineTo(a+s,o),t.lineTo(a,o),t.closePath(),t.clip()}},fillBorderRight=function(t,e,r,n,i){var o=e.top,a=e.left,s=e.width,u=e.height,c=r.borderRightColor,h=r.borderRightStyle,l=r.borderRightWidth,d=r.borderTopWidth,f=r.borderBottomWidth,p=i*(1-KAPPA),g=n*(1-KAPPA);t.moveTo(a+s-n,o),t.bezierCurveTo(a+s-g,o,a+s,o+g,a+s,o+n),t.lineTo(a+s,o+u-i),t.bezierCurveTo(a+s,o+u-p,a+s-p,o+u,a+s-i,o+u),t.strokeColor(c),t.lineWidth(2*Math.max(l,d,f)),"dashed"===h?t.dash(2*l,{space:1.2*l}):"dotted"===h&&t.dash(l,{space:1.2*l}),t.stroke(),t.undash()},clipBorderBottom=function(t,e,r,n,i){var o=e.top,a=e.left,s=e.width,u=e.height,c=r.borderBottomWidth,h=r.borderRightWidth,l=r.borderLeftWidth;t.moveTo(a+s-i,o+u),t.lineTo(a+n,o+u);var d=n*(1-KAPPA);t.bezierCurveTo(a+d,o+u,a,o+u-d,a,o+u-n);var f=o+u-Math.max(c,n);t.lineTo(a,f),t.lineTo(a+l,f);var p=Math.max(n-l,0),g=Math.max(n-c,0),m=p*(1-KAPPA),y=g*(1-KAPPA);t.bezierCurveTo(a+l,o+u-c-y,a+l+m,o+u-c,a+l+p,o+u-c),t.lineTo(a+s-Math.max(i,h),o+u-c);var v=Math.max(i-h,0),b=Math.max(i-c,0),T=v*(1-KAPPA),R=b*(1-KAPPA),_=o+u-Math.max(c,i);t.bezierCurveTo(a+s-h-T,o+u-c,a+s-h,o+u-c-R,a+s-h,_),t.lineTo(a+s,_),t.lineTo(a+s,o+u-i);var P=i*(1-KAPPA);if(t.bezierCurveTo(a+s,o+u-P,a+s-P,o+u,a+s-i,o+u),t.closePath(),t.clip(),h){var E=c/h;t.moveTo(a+s/2,E*(-s/2)+o+u),t.lineTo(a+s,o+u),t.lineTo(a,o+u),t.lineTo(a,o),t.closePath(),t.clip()}if(l){var C=-c/l;t.moveTo(a+s/2,C*(s/2)+o+u),t.lineTo(a,o+u),t.lineTo(a+s,o+u),t.lineTo(a+s,o),t.closePath(),t.clip()}},fillBorderBottom=function(t,e,r,n,i){var o=e.top,a=e.left,s=e.width,u=e.height,c=r.borderBottomColor,h=r.borderBottomStyle,l=r.borderBottomWidth,d=r.borderRightWidth,f=r.borderLeftWidth,p=n*(1-KAPPA),g=i*(1-KAPPA);t.moveTo(a+s,o+u-i),t.bezierCurveTo(a+s,o+u-g,a+s-g,o+u,a+s-i,o+u),t.lineTo(a+n,o+u),t.bezierCurveTo(a+p,o+u,a,o+u-p,a,o+u-n),t.strokeColor(c),t.lineWidth(2*Math.max(l,d,f)),"dashed"===h?t.dash(2*l,{space:1.2*l}):"dotted"===h&&t.dash(l,{space:1.2*l}),t.stroke(),t.undash()},clipBorderLeft=function(t,e,r,n,i){var o=e.top,a=e.left,s=e.width,u=e.height,c=r.borderTopWidth,h=r.borderLeftWidth,l=r.borderBottomWidth;t.moveTo(a,o+u-n),t.lineTo(a,o+i);var d=i*(1-KAPPA);t.bezierCurveTo(a,o+d,a+d,o,a+i,o);var f=a+Math.max(h,i);t.lineTo(f,o),t.lineTo(f,o+c);var p=Math.max(i-h,0),g=Math.max(i-c,0),m=p*(1-KAPPA),y=g*(1-KAPPA);t.bezierCurveTo(a+h+m,o+c,a+h,o+c+y,a+h,o+Math.max(i,c)),t.lineTo(a+h,o+u-Math.max(n,l));var v=Math.max(n-h,0),b=Math.max(n-l,0),T=v*(1-KAPPA),R=b*(1-KAPPA),_=a+Math.max(n,h);t.bezierCurveTo(a+h,o+u-l-R,a+h+T,o+u-l,_,o+u-l),t.lineTo(_,o+u),t.lineTo(a+n,o+u);var P=n*(1-KAPPA);if(t.bezierCurveTo(a+P,o+u,a,o+u-P,a,o+u-n),t.closePath(),t.clip(),l){var E=-l/h;t.moveTo(a+s/2,E*(s/2)+o+u),t.lineTo(a,o+u),t.lineTo(a,o),t.lineTo(a+s,o),t.closePath(),t.clip()}if(l){var C=-c/h;t.moveTo(a+s/2,C*(-s/2)+o),t.lineTo(a,o),t.lineTo(a,o+u),t.lineTo(a+s,o+u),t.closePath(),t.clip()}},fillBorderLeft=function(t,e,r,n,i){var o=e.top,a=e.left,s=e.height,u=r.borderLeftColor,c=r.borderLeftStyle,h=r.borderLeftWidth,l=r.borderTopWidth,d=r.borderBottomWidth,f=n*(1-KAPPA),p=i*(1-KAPPA);t.moveTo(a+n,o+s),t.bezierCurveTo(a+f,o+s,a,o+s-f,a,o+s-n),t.lineTo(a,o+i),t.bezierCurveTo(a,o+p,a+p,o,a+i,o),t.strokeColor(u),t.lineWidth(2*Math.max(h,l,d)),"dashed"===c?t.dash(2*h,{space:1.2*h}):"dotted"===c&&t.dash(h,{space:1.2*h}),t.stroke(),t.undash()},Borders={drawBorders:drawBorders},KAPPA$1=(Math.sqrt(2)-1)/3*4,Clipping={clip:function(){var t=this.getAbsoluteLayout(),e=t.top,r=t.left,n=t.width,i=t.height,o=this.style,a=o.borderTopLeftRadius,s=void 0===a?0:a,u=o.borderTopRightRadius,c=void 0===u?0:u,h=o.borderBottomRightRadius,l=void 0===h?0:h,d=o.borderBottomLeftRadius,f=void 0===d?0:d,p=Math.min(c,.5*n,.5*i),g=p*(1-KAPPA$1);this.root.instance.moveTo(r+p,e),this.root.instance.lineTo(r+n-p,e),this.root.instance.bezierCurveTo(r+n-g,e,r+n,e+g,r+n,e+p);var m=Math.min(l,.5*n,.5*i),y=m*(1-KAPPA$1);this.root.instance.lineTo(r+n,e+i-m),this.root.instance.bezierCurveTo(r+n,e+i-y,r+n-y,e+i,r+n-m,e+i);var v=Math.min(f,.5*n,.5*i),b=v*(1-KAPPA$1);this.root.instance.lineTo(r+v,e+i),this.root.instance.bezierCurveTo(r+b,e+i,r,e+i-b,r,e+i-v);var T=Math.min(s,.5*n,.5*i),R=T*(1-KAPPA$1);this.root.instance.lineTo(r,e+T),this.root.instance.bezierCurveTo(r,e+R,r+R,e,r+T,e),this.root.instance.closePath(),this.root.instance.clip()}},getRotation=function(t){var e=/rotate\((-?\d+.?\d+)(.+)\)/g.exec(t);if(e&&e[1]&&e[2]){var r=e[1];return"rad"===e[2]?180*r/Math.PI:r}return 0},getTranslateX=function(t){var e=/translateX\((-?\d+\.?d*)\)/g.exec(t),r=/translate\((-?\d+\.?d*).*,\s*(-?\d+\.?d*).*\)/g.exec(t);return e&&e[1]?e[1]:r&&r[1]?r[1]:0},getTranslateY=function(t){var e=/translateY\((-?\d+\.?\d*)\)/g.exec(t),r=/translate\((-?\d+\.?\d*).*,\s*(-?\d+\.?\d*).*\)/g.exec(t);return e&&e[1]?e[1]:r&&r[2]?r[2]:0},getScaleX=function(t){var e=/scaleX\((-?\d+\.?\d*)\)/g.exec(t),r=/scale\((-?\d+\.?\d*).*,\s*(-?\d+\.?\d*).*\)/g.exec(t);return e&&e[1]?e[1]:r&&r[1]?r[1]:1},getScaleY=function(t){var e=/scaleY\((-?\d+\.?\d*)\)/g.exec(t),r=/scale\((-?\d+\.?\d*).*,\s*(-?\d+\.?\d*).*\)/g.exec(t);return e&&e[1]?e[1]:r&&r[2]?r[2]:1},getMatrix=function(t){var e=/matrix\(([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)\)/g.exec(t);return e?e.slice(1,7):null},applySingleTransformation=function(t,e,r){if(/rotate/g.test(e))t.root.instance.rotate(getRotation(e),{origin:r});else if(/scaleX/g.test(e))t.root.instance.scale(getScaleX(e),1,{origin:r});else if(/scaleY/g.test(e))t.root.instance.scale(1,getScaleY(e),{origin:r});else if(/scale/g.test(e))t.root.instance.scale(getScaleX(e),getScaleY(e),{origin:r});else if(/translateX/g.test(e))t.root.instance.translate(getTranslateX(e),1,{origin:r});else if(/translateY/g.test(e))t.root.instance.translate(1,getTranslateY(e),{origin:r});else if(/translate/g.test(e))t.root.instance.translate(getTranslateX(e),getTranslateY(e),{origin:r});else if(/matrix/g.test(e)){var n;(n=t.root.instance).transform.apply(n,getMatrix(e))}},Transformations={applyTransformations:function(){for(var t,e=/[a-zA-Z]+\([^)]+\)/g,r=this.origin,n=this.style&&this.style.transform||"";null!=(t=e.exec(n));)applySingleTransformation(this,t[0],r)}},merge=function(t,e){return ramda.isNil(e)?t:e},deepMerge=function(t){return t.reduce(function(t,e){return ramda.mergeDeepWith(merge,t,e)},{})},isFunction=ramda.compose(ramda.equals("Function"),ramda.type),inheritedProperties=["color","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","opacity","textDecoration","lineHeight","textAlign","visibility","wordSpacing"],Base=function(t){function e(r,n){var i;return(i=t.call(this)||this).root=r,i.style={},i.props=deepMerge([i.constructor.defaultProps,e.defaultProps,n]),warning(!i.props.styles,'"styles" prop passed instead of "style" prop'),i}_inheritsLoose(e,t);var r=e.prototype;return r.appendChild=function(e){t.prototype.appendChild.call(this,e),this.root.markDirty()},r.appendChildBefore=function(e,r){t.prototype.appendChildBefore.call(this,e,r),this.root.markDirty()},r.removeChild=function(e){t.prototype.removeChild.call(this,e),this.root.markDirty()},r.update=function(t){this.props=deepMerge([this.constructor.defaultProps,e.defaultProps,t]),this.root.markDirty()},r.applyProps=function(){var t=this;this.style=this.resolveStyles(),ramda.toPairsIn(this.style).map(function(e){var r=e[0],n=e[1];t.applyStyle(r,n)}),this.children.forEach(function(t){t.applyProps&&t.applyProps()})},r.resolveStyles=function(){var t=this.page,e=t.size,r={orientation:t.orientation,isAutoHeight:t.isAutoHeight,width:e.width,height:e.height},n=StyleSheet.resolve(this.props.style,r),i=this.parent?ramda.pick(inheritedProperties,this.parent.style):{};return _extends({},i,{},n)},r.applyStyle=function(t,e){if(void 0!==e){var r="set"+upperFirst(t);switch(t){case"marginTop":case"marginRight":case"marginBottom":case"marginLeft":case"paddingTop":case"paddingRight":case"paddingBottom":case"paddingLeft":case"borderTopWidth":case"borderRightWidth":case"borderBottomWidth":case"borderLeftWidth":case"position":case"top":case"right":case"bottom":case"left":case"width":case"height":case"minHeight":case"maxHeight":case"minWidth":case"maxWidth":this[t]=e;break;default:isFunction(this.layout[r])&&this.layout[r](e)}}},r.getLayoutData=function(){var t=this.getAbsoluteLayout();return{type:this.name,top:t.top,left:t.left,width:t.width,style:this.style,height:t.height,children:this.children.map(function(t){return t.getLayoutData()})}},r.drawBackgroundColor=function(){var t=this.style,e=t.backgroundColor,r=t.opacity,n=void 0===r?1:r,i=this.getAbsoluteLayout(),o=i.left,a=i.top,s=i.width,u=i.height;e&&(this.root.instance.save(),this.clip(),this.root.instance.fillOpacity(n).fillColor(e).rect(o,a,s,u).fill().restore())},r.clone=function(){var t=new this.constructor(this.root,this.props);return t.copyStyle(this),t.style=this.style,t},r.onNodeSplit=function(t,e){this.calculateLayout(),e.marginTop=0,e.paddingTop=0,e.style.height&&(e.height=this.height-t),this.height=t,this.marginBottom=0,this.paddingBottom=0},r.renderChildren=function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function t(){var e;return _regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=0;case 1:if(!(e<this.children.length)){t.next=7;break}return t.next=4,this.children[e].render();case 4:e++,t.next=1;break;case 7:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}(),_createClass(e,[{key:"page",get:function(){return this.parent.page}},{key:"wrap",get:function(){return this.props.wrap}},{key:"break",get:function(){return this.props.break},set:function(t){this.props.break=t}},{key:"fixed",get:function(){return this.props.fixed}},{key:"minPresenceAhead",get:function(){return this.props.minPresenceAhead}},{key:"absolute",get:function(){return"absolute"===this.props.style.position}},{key:"origin",get:function(){var t=this.style,e=t.transformOriginX,r=t.transformOriginY,n=this.getAbsoluteLayout(),i=n.left,o=n.top,a=n.width,s=n.height,u=matchPercent(e),c=matchPercent(r);return[i+(u?a*u.percent:e),o+(c?s*c.percent:r)]}}]),e}(Node);Base.defaultProps={style:{borderTopLeftRadius:0,borderTopRightRadius:0,borderBottomRightRadius:0,borderBottomLeftRadius:0,transformOriginX:"50%",transformOriginY:"50%"},minPresenceAhead:0},Object.assign(Base.prototype,Debug),Object.assign(Base.prototype,Borders),Object.assign(Base.prototype,Clipping),Object.assign(Base.prototype,Transformations);var RULER_WIDTH=13,RULER_COLOR="white",RULER_FONT_SIZE=5,DEFAULT_RULER_STEPS=50,LINE_WIDTH=.5,LINE_COLOR="gray",GRID_COLOR="#ababab",range=function(t,e){return Array.from({length:Math.ceil(t/e)},function(t,r){return r*e})},matchPercentage=function(t){var e=matchPercent(t);return e?100/e.value:null},Ruler={getRulerWidth:function(){return RULER_WIDTH},hasHorizontalRuler:function(){return this.props.ruler||this.props.horizontalRuler},hasVerticalRuler:function(){return this.props.ruler||this.props.verticalRuler},getHorizontalSteps:function(){var t=this.props.horizontalRulerSteps||this.props.rulerSteps||DEFAULT_RULER_STEPS;if("string"==typeof t){var e=matchPercentage(t);if(e)return(this.width-(this.hasVerticalRuler()?RULER_WIDTH:0))/e;throw new Error("Page: Invalid horizontal steps value")}return t},getVerticalSteps:function(){var t=this.props.verticalRulerSteps||this.props.rulerSteps||DEFAULT_RULER_STEPS;if("string"==typeof t){var e=matchPercentage(t);if(e)return(this.height-(this.hasHorizontalRuler()?RULER_WIDTH:0))/e;throw new Error("Page: Invalid horizontal steps value")}return t},renderRuler:function(){var t=this.hasHorizontalRuler(),e=this.hasVerticalRuler();(t||e)&&(this.root.instance.save().lineWidth(LINE_WIDTH).fontSize(RULER_FONT_SIZE).opacity(1),t&&this.drawHorizontalRuler(),e&&this.drawVerticalRuler(),t&&e&&this.root.instance.rect(0,0,RULER_WIDTH-LINE_WIDTH,RULER_WIDTH-LINE_WIDTH).fill(RULER_COLOR),this.root.instance.restore())},drawHorizontalRuler:function(){var t=this,e=this.hasVerticalRuler()?RULER_WIDTH:0;this.root.instance.rect(e,0,this.width,RULER_WIDTH).fill(RULER_COLOR).moveTo(this.hasVerticalRuler()?RULER_WIDTH:0,RULER_WIDTH).lineTo(this.width,RULER_WIDTH).stroke(LINE_COLOR);var r=range(this.width,this.getHorizontalSteps());r.map(function(r){t.root.instance.moveTo(e+r,0).lineTo(e+r,RULER_WIDTH).stroke(LINE_COLOR).fillColor("black").text(""+Math.round(r),e+r+1,1)}),r.map(function(r){0!==r&&t.root.instance.moveTo(e+r,RULER_WIDTH).lineTo(e+r,t.height).stroke(GRID_COLOR)})},drawVerticalRuler:function(){var t=this,e=this.hasHorizontalRuler()?RULER_WIDTH:0;this.root.instance.rect(0,e,RULER_WIDTH,this.height).fill(RULER_COLOR).moveTo(RULER_WIDTH,this.hasHorizontalRuler()?RULER_WIDTH:0).lineTo(RULER_WIDTH,this.height).stroke(LINE_COLOR);var r=range(this.height,this.getVerticalSteps());r.map(function(r){t.root.instance.moveTo(0,e+r).lineTo(RULER_WIDTH,e+r).stroke(LINE_COLOR).fillColor("black").text(""+Math.round(r),1,e+r+1)}),r.map(function(r){0!==r&&t.root.instance.moveTo(RULER_WIDTH,e+r).lineTo(t.width,e+r).stroke(GRID_COLOR)})}},TextInstance=function(){function t(t,e){this.root=t,this.value=e,this.parent=null,this.props={}}var e=t.prototype;return e.getLayoutData=function(){return this.value},e.remove=function(){this.parent.removeChild(this)},e.clone=function(){return new this.constructor(this.root,this.value)},e.cleanup=function(){},e.update=function(t){this.value=t,this.parent.computed=!1,this.parent.container=null,this.root.markDirty()},_createClass(t,[{key:"name",get:function(){return"TextInstance"}}]),t}(),PAGE_SIZES={"4A0":[4767.87,6740.79],"2A0":[3370.39,4767.87],A0:[2383.94,3370.39],A1:[1683.78,2383.94],A2:[1190.55,1683.78],A3:[841.89,1190.55],A4:[595.28,841.89],A5:[419.53,595.28],A6:[297.64,419.53],A7:[209.76,297.64],A8:[147.4,209.76],A9:[104.88,147.4],A10:[73.7,104.88],B0:[2834.65,4008.19],B1:[2004.09,2834.65],B2:[1417.32,2004.09],B3:[1000.63,1417.32],B4:[708.66,1000.63],B5:[498.9,708.66],B6:[354.33,498.9],B7:[249.45,354.33],B8:[175.75,249.45],B9:[124.72,175.75],B10:[87.87,124.72],C0:[2599.37,3676.54],C1:[1836.85,2599.37],C2:[1298.27,1836.85],C3:[918.43,1298.27],C4:[649.13,918.43],C5:[459.21,649.13],C6:[323.15,459.21],C7:[229.61,323.15],C8:[161.57,229.61],C9:[113.39,161.57],C10:[79.37,113.39],RA0:[2437.8,3458.27],RA1:[1729.13,2437.8],RA2:[1218.9,1729.13],RA3:[864.57,1218.9],RA4:[609.45,864.57],SRA0:[2551.18,3628.35],SRA1:[1814.17,2551.18],SRA2:[1275.59,1814.17],SRA3:[907.09,1275.59],SRA4:[637.8,907.09],EXECUTIVE:[521.86,756],FOLIO:[612,936],LEGAL:[612,1008],LETTER:[612,792],TABLOID:[792,1224]},getPageSize=function(t,e){var r;if(void 0===e&&(e="portrait"),"string"==typeof t)r=PAGE_SIZES[t.toUpperCase()];else if(Array.isArray(t))r=t;else if("number"==typeof t)r=[t];else{if("object"!=typeof t||!t.width)throw new Error("Invalid Page size: "+t);r=[t.width,t.height]}return"portrait"===e?{width:r[0],height:r[1]}:{width:r[1],height:r[0]}},Page=function(t){function e(e,r){var n;return(n=t.call(this,e,r)||this)._size=null,n}_inheritsLoose(e,t);var r=e.prototype;return r.resetMargins=function(){(this.marginTop||this.marginBottom||this.marginLeft||this.marginRight)&&(warning(!1,"Margin values are not allowed on Page element. Use padding instead."),this.marginTop=0,this.marginBottom=0,this.marginLeft=0,this.marginRight=0)},r.applyProps=function(){t.prototype.applyProps.call(this),this.top=0,this.left=0,this.width=this.size.width,this.resetMargins();var e=this.getRulerWidth();this.hasHorizontalRuler()&&(this.paddingTop=this.paddingTop+e),this.hasVerticalRuler()&&(this.paddingLeft=this.paddingLeft+e)},r.setPadding=function(t,e){var r=t===Yoga.EDGE_TOP||t===Yoga.EDGE_BOTTOM?this.size.height:this.size.width,n=matchPercent(e);n?this.layout.setPadding(t,r*n.percent):this.layout.setPadding(t,e)},r.addDynamicChild=function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function t(e,r){var n,i,o,a,s,u,c;return _regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r){t.next=2;break}return t.abrupt("return");case 2:n=Array.isArray(r)?r:[r],i=0;case 4:if(!(i<n.length)){t.next=27;break}if(o=n[i],a=o.type,s=o.props,"string"!=typeof o){t.next=12;break}u=new TextInstance(this.root,o),e.appendChild(u),t.next=24;break;case 12:if(a===React.Fragment){t.next=22;break}return c=createInstance(o,this.root),t.next=16,c.onAppendDynamically();case 16:return e.appendChild(c),c.applyProps(),t.next=20,this.addDynamicChild(c,s.children);case 20:t.next=24;break;case 22:return t.next=24,this.addDynamicChild(e,s.children);case 24:i++,t.next=4;break;case 27:case"end":return t.stop()}},t,this)}));return function(e,r){return t.apply(this,arguments)}}(),r.renderDynamicNodes=function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function t(e,r){var n,i,o;return _regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n=this.children.slice(0);case 1:if(!(n.length>0)){t.next=14;break}if(i=n.shift(),!(!r||r(i))||!i.props.render){t.next=11;break}return i.removeAllChilds(),o=i.props.render(e),t.next=9,this.addDynamicChild(i,o);case 9:return i.fixed||(i.props.render=null),t.abrupt("continue",1);case 11:i.children&&n.push.apply(n,i.children),t.next=1;break;case 14:case"end":return t.stop()}},t,this)}));return function(e,r){return t.apply(this,arguments)}}(),r.nodeWillWrap=function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function t(e){return _regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.renderDynamicNodes(e);case 2:this.calculateLayout();case 3:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}(),r.onNodeSplit=function(t,e){e.marginTop=0,this.marginBottom=0,this.calculateLayout()},r.clone=function(){var e=t.prototype.clone.call(this);return e._size=this.size,e},r.update=function(e){t.prototype.update.call(this,e),this._size=null},r.render=function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function t(){var e,r;return _regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.root.instance,this.isAutoHeight||(this.height=this.size.height),this.calculateLayout(),r=this.isAutoHeight?this.height:this.size.height,e.addPage({size:[this.size.width,r],margin:0}),this.style.backgroundColor&&e.fillColor(this.style.backgroundColor).rect(0,0,this.size.width,r).fill(),t.next=8,this.renderChildren();case 8:this.props.debug&&this.debug(),this.renderRuler();case 10:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}(),_createClass(e,[{key:"name",get:function(){return"Page"}},{key:"document",get:function(){return this.parent}},{key:"page",get:function(){return this}},{key:"orientation",get:function(){return this.props.orientation}},{key:"size",get:function(){return this._size?this._size:(this._size=getPageSize(this.props.size,this.orientation),this.hasHorizontalRuler()&&(this._size.width+=this.getRulerWidth()),this.hasVerticalRuler()&&(this._size.height+=this.getRulerWidth()),this._size)}},{key:"isAutoHeight",get:function(){return void 0===this.size.height}}]),e}(Base);Page.defaultProps={size:"A4",wrap:!0,orientation:"portrait"},Object.assign(Page.prototype,Ruler);var View=function(t){function e(){return t.apply(this,arguments)||this}return _inheritsLoose(e,t),e.prototype.render=function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function t(){return _regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return this.root.instance.save(),this.applyTransformations(),this.drawBackgroundColor(),this.drawBorders(),this.props.onRender&&this.props.onRender(this),t.next=7,this.renderChildren();case 7:this.props.debug&&this.debug(),this.root.instance.restore();case 9:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}(),_createClass(e,[{key:"name",get:function(){return"View"}}]),e}(Base);View.defaultProps={wrap:!0};var emojiSource,hyphenationCallback,fetchFont=function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function t(e,r){var n,i;return _regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch(e,r);case 2:return n=t.sent,t.next=5,n.buffer?n.buffer():n.arrayBuffer();case 5:return i=t.sent,t.abrupt("return","Buffer"===i.constructor.name?i:Buffer.from(i));case 7:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}(),FontSource=function(){function t(t,e,r,n,i){this.src=t,this.fontFamily=e,this.fontStyle=r||"normal",this.fontWeight=processFontWeight(n)||400,this.data=null,this.loading=!1,this.options=i}return t.prototype.load=function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function t(){var e,r,n,i,o,a,s=this;return _regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return this.loading=!0,e=this.options,r=e.headers,n=e.body,i=e.method,o=void 0===i?"GET":i,t.next=5,fetchFont(this.src,{method:o,body:n,headers:r});case 5:a=t.sent,this.data=fontkit.create(a),t.next=12;break;case 9:return t.next=11,new Promise(function(t,e){return fontkit.open(s.src,function(r,n){return r?e(r):t(n)})});case 11:this.data=t.sent;case 12:this.loading=!1;case 13:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}(),t}(),Font=function(){function t(t){this.family=t,this.sources=[]}t.create=function(e){return new t(e)};var e=t.prototype;return e.register=function(t){var e=t.src,r=t.fontWeight,n=t.fontStyle,i=_objectWithoutPropertiesLoose(t,["src","fontWeight","fontStyle"]);this.sources.push(new FontSource(e,this.fontFamily,n,r,i))},e.resolve=function(t){var e,r=t.fontWeight,n=void 0===r?400:r,i=t.fontStyle,o=void 0===i?"normal":i,a=this.sources.filter(function(t){return t.fontStyle===o}),s=a.find(function(t){return t.fontWeight===n});if(s)return s;if(n>=400&&n<=500){var u=a.filter(function(t){return t.fontWeight<=n}),c=a.filter(function(t){return t.fontWeight>500});e=a.filter(function(t){return t.fontWeight>=n&&t.fontWeight<500})[0]||u[u.length-1]||c[0]}var h=a.filter(function(t){return t.fontWeight<n}),l=a.filter(function(t){return t.fontWeight>n});if(n<400&&(e=h[h.length-1]||l[0]),n>500&&(e=l[0]||h[h.length-1]),!e)throw new Error("Could not resolve font for "+this.fontFamily+", fontWeight "+n);return e},t}(),registerEmojiSource=function(t){var e=t.url,r=t.format;emojiSource={url:e,format:void 0===r?"png":r}},getEmojiSource=function(){return emojiSource},emoji={registerEmojiSource:registerEmojiSource,getEmojiSource:getEmojiSource},standardFonts=["Courier","Courier-Bold","Courier-Oblique","Helvetica","Helvetica-Bold","Helvetica-Oblique","Times-Roman","Times-Bold","Times-Italic"],registerHyphenationCallback=function(t){hyphenationCallback=t},getHyphenationCallback=function(){return hyphenationCallback},hyphenation={registerHyphenationCallback:registerHyphenationCallback,getHyphenationCallback:getHyphenationCallback},fonts={},register=function(t,e){"object"==typeof t?e=t:(warning(!1,"Font.register will not longer accept the font source as first argument. Please move it into the data object. For more info refer to https://react-pdf.org/fonts"),e.src=t);var r=e.family;if(fonts[r]||(fonts[r]=Font.create(r)),e.fonts)for(var n=0;n<e.fonts.length;n++)fonts[r].register(_extends({family:r},e.fonts[n]));else fonts[r].register(e)},getRegisteredFonts=function(){return fonts},getRegisteredFontFamilies=function(){return Object.keys(fonts)},getFont=function(t){var e=t.fontFamily;if(standardFonts.includes(e))return null;if(!fonts[e])throw new Error("Font family not registered: "+e+". Please register it calling Font.register() method.");return fonts[e].resolve(t)},load=function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function t(e,r){var n,i;return _regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.fontFamily,!standardFonts.includes(n)){t.next=4;break}return t.abrupt("return");case 4:if((i=getFont(e)).data||i.loading){t.next=8;break}return t.next=8,i.load();case 8:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}(),reset=function(){for(var t in fonts)fonts.hasOwnProperty(t)&&(fonts[t].data=null)},clear=function(){fonts={}},Font$1=_extends({register:register,getRegisteredFonts:getRegisteredFonts,getRegisteredFontFamilies:getRegisteredFontFamilies,getFont:getFont,load:load,clear:clear,reset:reset},emoji,{},hyphenation),StandardFont=function(){function t(t){this.name=t,this.src=PDFDocument.PDFFont.open(null,t)}var e=t.prototype;return e.layout=function(t){var e=this,r=this.src.encode(t),n=r[0],i=r[1];return{positions:i,stringIndices:i.map(function(t,e){return e}),glyphs:n.map(function(t,r){var n=e.getGlyph(parseInt(t,16));return n.advanceWidth=i[r].advanceWidth,n})}},e.glyphForCodePoint=function(t){var e=this.getGlyph(t);return e.advanceWidth=400,e},e.getGlyph=function(t){return{id:t,_font:this.src,codePoints:[t],isLigature:!1,name:this.src.font.characterToGlyph(t)}},e.hasGlyphForCodePoint=function(t){return".notdef"!==this.src.font.characterToGlyph(t)},_createClass(t,[{key:"ascent",get:function(){return 900}},{key:"descent",get:function(){switch(this.name){case"Times-Roman":case"Times-Bold":case"Times-Italic":return-220;case"Courier":case"Courier-Bold":case"Courier-Oblique":return-230;default:return-200}}},{key:"lineGap",get:function(){return 0}},{key:"unitsPerEm",get:function(){return 1e3}}]),t}(),fontCache={},IGNORED_CODE_POINTS=[173],getFontSize=ramda.pathOr(12,["attributes","fontSize"]),getFallbackFont=function(){return getOrCreateFont("Helvetica")},getOrCreateFont=function(t){if(fontCache[t])return fontCache[t];var e=new StandardFont(t);return fontCache[t]=e,e},shouldFallbackToFont=function(t,e){return!IGNORED_CODE_POINTS.includes(t)&&!e.hasGlyphForCodePoint(t)&&getFallbackFont().hasGlyphForCodePoint(t)},fontSubstitution=function(){return function(t){var e=t.string,r=t.runs,n=null,i=0,o=0,a=[],s=r,u=Array.isArray(s),c=0;for(s=u?s:s[Symbol.iterator]();;){var h;if(u){if(c>=s.length)break;h=s[c++]}else{if((c=s.next()).done)break;h=c.value}var l=h,d=getFontSize(l),f="string"==typeof l.attributes.font?getOrCreateFont(l.attributes.font):l.attributes.font;if(0===e.length){a.push({start:0,end:0,attributes:{font:f}});break}var p=e.slice(l.start,l.end),g=Array.isArray(p),m=0;for(p=g?p:p[Symbol.iterator]();;){var y;if(g){if(m>=p.length)break;y=p[m++]}else{if((m=p.next()).done)break;y=m.value}var v=y,b=v.codePointAt(),T=shouldFallbackToFont(b,f)?getFallbackFont():f;T!==n&&(n&&a.push({start:i,end:o,attributes:{font:n,scale:n?d/n.unitsPerEm:0}}),n=T,i=o),o+=v.length}}if(i<e.length){var R=getFontSize(ramda.last(r));a.push({start:i,end:e.length,attributes:{font:n,scale:n?R/n.unitsPerEm:0}})}return{string:e,runs:a}}},engines={linebreaker:linebreaker,justification:justification,textDecoration:textDecoration,scriptItemizer:scriptItemizer,wordHyphenation:wordHyphenation,fontSubstitution:fontSubstitution},engine=layoutEngine(engines),PROTOCOL_REGEXP=/^([a-z]+\:(\/\/)?)/i,getURL=function(t){return t?"string"!=typeof t||t.match(PROTOCOL_REGEXP)?t:"http://"+t:""},fs={};PNG.isValid=function(t){try{return!!new PNG(t)}catch(t){return!1}};var MARKERS=[65472,65473,65474,65475,65477,65478,65479,65480,65481,65482,65483,65484,65485,65486,65487],JPEG=function(t){if(this.data=null,this.width=null,this.height=null,this.data=t,65496!==t.readUInt16BE(0))throw new Error("SOI not found in JPEG");for(var e,r=2;r<t.length&&(e=t.readUInt16BE(r),r+=2,!MARKERS.includes(e));)r+=t.readUInt16BE(r);if(!MARKERS.includes(e))throw new Error("Invalid JPEG.");r+=3,this.height=t.readUInt16BE(r),r+=2,this.width=t.readUInt16BE(r)};JPEG.isValid=function(t){if(!t||!Buffer.isBuffer(t)||65496!==t.readUInt16BE(0))return!1;for(var e,r=2;r<t.length&&(e=t.readUInt16BE(r),r+=2,!MARKERS.includes(e));)r+=t.readUInt16BE(r);return!!MARKERS.includes(e)};var createCach