UNPKG

pdf-lib

Version:

Library for creating and modifying PDF files in JavaScript

1 lines 864 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.PDFLib={})}("undefined"!=typeof self?self:this,function(e){var t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(e,t){return e(t={exports:{}},t.exports),t.exports}var n="object"==typeof t&&t&&t.Object===Object&&t,i="object"==typeof self&&self&&self.Object===Object&&self,o=n||i||Function("return this")(),a=o.Symbol,s=Object.prototype,u=s.hasOwnProperty,c=s.toString,f=a?a.toStringTag:void 0;var l=function(e){var t=u.call(e,f),r=e[f];try{e[f]=void 0}catch(e){}var n=c.call(e);return t?e[f]=r:delete e[f],n},h=Object.prototype.toString;var p=function(e){return h.call(e)},d="[object Null]",g="[object Undefined]",y=a?a.toStringTag:void 0;var b=function(e){return null==e?void 0===e?g:d:y&&y in Object(e)?l(e):p(e)};var v=function(e){return null!=e&&"object"==typeof e},m="[object Number]";var w=function(e){return"number"==typeof e||v(e)&&b(e)==m};var S=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i};var x=function(e,t){return S(t,function(t){return e[t]})};var P=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n},k="[object Arguments]";var A=function(e){return v(e)&&b(e)==k},O=Object.prototype,C=O.hasOwnProperty,I=O.propertyIsEnumerable,_=A(function(){return arguments}())?A:function(e){return v(e)&&C.call(e,"callee")&&!I.call(e,"callee")},D=Array.isArray;var B=function(){return!1},E=r(function(e,t){var r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,i=n&&n.exports===r?o.Buffer:void 0,a=(i?i.isBuffer:void 0)||B;e.exports=a}),j=9007199254740991,T=/^(?:0|[1-9]\d*)$/;var F=function(e,t){return!!(t=null==t?j:t)&&("number"==typeof e||T.test(e))&&e>-1&&e%1==0&&e<t},z=9007199254740991;var R=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=z},L={};L["[object Float32Array]"]=L["[object Float64Array]"]=L["[object Int8Array]"]=L["[object Int16Array]"]=L["[object Int32Array]"]=L["[object Uint8Array]"]=L["[object Uint8ClampedArray]"]=L["[object Uint16Array]"]=L["[object Uint32Array]"]=!0,L["[object Arguments]"]=L["[object Array]"]=L["[object ArrayBuffer]"]=L["[object Boolean]"]=L["[object DataView]"]=L["[object Date]"]=L["[object Error]"]=L["[object Function]"]=L["[object Map]"]=L["[object Number]"]=L["[object Object]"]=L["[object RegExp]"]=L["[object Set]"]=L["[object String]"]=L["[object WeakMap]"]=!1;var N=function(e){return v(e)&&R(e.length)&&!!L[b(e)]};var M=function(e){return function(t){return e(t)}},U=r(function(e,t){var r=t&&!t.nodeType&&t,i=r&&e&&!e.nodeType&&e,o=i&&i.exports===r&&n.process,a=function(){try{return o&&o.binding&&o.binding("util")}catch(e){}}();e.exports=a}),G=U&&U.isTypedArray,V=G?M(G):N,q=Object.prototype.hasOwnProperty;var W=function(e,t){var r=D(e),n=!r&&_(e),i=!r&&!n&&E(e),o=!r&&!n&&!i&&V(e),a=r||n||i||o,s=a?P(e.length,String):[],u=s.length;for(var c in e)!t&&!q.call(e,c)||a&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||F(c,u))||s.push(c);return s},H=Object.prototype;var Y=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||H)};var X=function(e,t){return function(r){return e(t(r))}},Z=X(Object.keys,Object),K=Object.prototype.hasOwnProperty;var J=function(e){if(!Y(e))return Z(e);var t=[];for(var r in Object(e))K.call(e,r)&&"constructor"!=r&&t.push(r);return t};var Q=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},$="[object AsyncFunction]",ee="[object Function]",te="[object GeneratorFunction]",re="[object Proxy]";var ne=function(e){if(!Q(e))return!1;var t=b(e);return t==ee||t==te||t==$||t==re};var ie=function(e){return null!=e&&R(e.length)&&!ne(e)};var oe=function(e){return ie(e)?W(e):J(e)};var ae=function(e){return null==e?[]:x(e,oe(e))},se="[object Symbol]";var ue=function(e){return"symbol"==typeof e||v(e)&&b(e)==se},ce=NaN;var fe=function(e){return"number"==typeof e?e:ue(e)?ce:+e},le=1/0,he=a?a.prototype:void 0,pe=he?he.toString:void 0;var de=function e(t){if("string"==typeof t)return t;if(D(t))return S(t,e)+"";if(ue(t))return pe?pe.call(t):"";var r=t+"";return"0"==r&&1/t==-le?"-0":r};var ge=function(e,t){return function(r,n){var i;if(void 0===r&&void 0===n)return t;if(void 0!==r&&(i=r),void 0!==n){if(void 0===i)return n;"string"==typeof r||"string"==typeof n?(r=de(r),n=de(n)):(r=fe(r),n=fe(n)),i=e(r,n)}return i}}(function(e,t){return e+t},0);var ye=function(e,t){for(var r,n=-1,i=e.length;++n<i;){var o=t(e[n]);void 0!==o&&(r=void 0===r?o:r+o)}return r};var be=function(e){return e};var ve=function(e){return e&&e.length?ye(e,be):0},me=function(e){throw new Error(e)},we=function(e){return Math.ceil(e.toString(2).length/8)},Se=function(e){for(var t=new Uint8Array(we(e)),r=1;r<=t.length;r++)t[r-1]=e>>8*(t.length-r);return t},xe=function(e){for(var t=0;t<Math.floor(e.length/2);t++){var r=t,n=e.length-t-1,i=e[t];e[r]=e[n],e[n]=i}return e},Pe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.every(function(e){return e.apply(void 0,t)})}},ke=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.some(function(e){return e.apply(void 0,t)})}},Ae=function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return!e.apply(void 0,t)}},Oe=function(e){if(1!==e.length)throw new Error('"char" must be exactly one character long');return e.charCodeAt(0)},Ce=function(e){return String.fromCharCode(e)},Ie=function(e,t){for(var r=0;r<e.length;r+=1)t[r]=e.charCodeAt(r);return t.subarray(e.length)},_e=function(e,t,r){void 0===t&&(t=0);for(var n=void 0===r||r>=e.length?e.length:r,i="",o=t;o<n;o+=1)i+=Ce(e[o]);return i},De=function(e,t){return String.fromCharCode(e[t])},Be=function(e){for(var t=0;String.fromCharCode(e[t]).match(/^[\0\t\n\f\r ]/)&&t<e.length;)t+=1;return e.subarray(t)},Ee=Oe("%"),je=Oe("\n"),Te=Oe("\r"),Fe=function(e){return e===je||e===Te},ze=function(e){for(var t=!0,r=e;t;)if((r=Be(r))[0]===Ee){for(var n=0;!Fe(r[n])&&n<r.length;)n+=1;var i=Fe(r[n]);i&&(r=r.subarray(n)),t=i}else t=!1;return r},Re=function(e,t,r,n,i,o){var a=r-t;if(a!==o-i)return!1;for(var s=0;s<a;s+=1)if(e[t+s]!==n[i+s])return!1;return!0},Le=function(e,t,r){void 0===r&&(r=0);for(var n=t.split("").map(function(e){return e.charCodeAt(0)}),i=r;!Re(e,i,i+t.length,n,0,n.length);)if((i+=1)>=e.length)return;return i},Ne=function(e,t,r){return e.substring(0,t)+r+e.substring(t+1)},Me=Math.max,Ue=Math.min;var Ge=function(e,t,r){return e>=Ue(t,r)&&e<Me(t,r)},Ve=NaN,qe=/^\s+|\s+$/g,We=/^[-+]0x[0-9a-f]+$/i,He=/^0b[01]+$/i,Ye=/^0o[0-7]+$/i,Xe=parseInt;var Ze=function(e){if("number"==typeof e)return e;if(ue(e))return Ve;if(Q(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Q(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(qe,"");var r=He.test(e);return r||Ye.test(e)?Xe(e.slice(2),r?2:8):We.test(e)?Ve:+e},Ke=1/0,Je=1.7976931348623157e308;var Qe=function(e){return e?(e=Ze(e))===Ke||e===-Ke?(e<0?-1:1)*Je:e==e?e:0:0===e?e:0};var $e=function(e,t,r){return t=Qe(t),void 0===r?(r=t,t=0):r=Qe(r),e=Ze(e),Ge(e,t,r)};var et=function(e){return w(e)&&e!=+e};var tt,rt=function(e){return null==e},nt=function(e,t,r){if(!t(e))throw new Error(r)},it=function(e,t,r){nt(e,D,"validateArr.value must be an array."),e.forEach(function(e){return nt(e,t,r)})},ot=function(e){return function(t){return t instanceof e}},at=function(e){return function(t){if(!D(t))return!1;for(var r=0;r<t.length;r++)if(!(t[r]instanceof e))return!1;return!0}},st=function(e){return function(t){return t===e}},ut=function(e){return function(t){return t!==e}},ct=function(e){return function(t){return!!t.match(e)}},ft=function(e){return Pe(w,Ae(et))(e)},lt=function(e,t){return function(r){return $e(r,e,t)||r===t}},ht=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return e.some(function(e){return e===t})}},pt=function(){function e(){var e=this;this.index=new Map,this.highestObjectNumber=-1,this.assign=function(t,r){return nt(t,ot(qt),'"key" must be a PDFIndirectReference'),nt(r,ot(dt),'"val" must be a PDFObject'),t.objectNumber>e.highestObjectNumber&&(e.highestObjectNumber=t.objectNumber),e.index.set(t,r),e},this.nextObjectNumber=function(){return e.highestObjectNumber+=1,qt.forNumbers(e.highestObjectNumber,0)},this.assignNextObjectNumberTo=function(t){var r=e.nextObjectNumber();return e.assign(r,t),r},this.lookupMaybe=function(t){return t instanceof qt?e.index.get(t):t},this.lookup=function(t){return e.lookupMaybe(t)||me("Failed to lookup ref: "+t)}}return e.create=function(){return new e},e}(),dt=function(){return function(){var e=this;this.clone=function(){throw new Error("clone() is not implemented on "+e.constructor.name)},this.toString=function(){throw new Error("toString() is not implemented on "+e.constructor.name)},this.bytesSize=function(){throw new Error("bytesSize() is not implemented on "+e.constructor.name)},this.copyBytesInto=function(t){throw new Error("copyBytesInto() is not implemented on "+e.constructor.name)}}}(),gt=(tt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}tt(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),yt=function(e){function t(r,n){var i=e.call(this)||this;return i.push=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return it(t,ot(dt),"PDFArray.push() requires arguments to be PDFObjects"),(e=i.array).push.apply(e,t),i},i.set=function(e,t){return nt(e,w,"PDFArray.set() requires indexes to be numbers"),nt(t,ot(dt),"PDFArray.set() requires values to be PDFObjects"),i.array[e]=t,i},i.get=function(e){return nt(e,w,"PDFArray.get() requires indexes to be numbers"),i.array[e]},i.forEach=function(e){return i.array.forEach(e)},i.map=function(e){return i.array.map(e)},i.splice=function(e,t){return i.array.splice(e,t)},i.clone=function(){return t.fromArray(i.array.slice(),i.index)},i.toString=function(){var e=i.bytesSize(),t=new Uint8Array(e);return i.copyBytesInto(t),_e(t)},i.bytesSize=function(){return 2+i.array.map(function(e){return e instanceof Ht?e.toReference().length+1:e instanceof dt?e.bytesSize()+1:me("Not a PDFObject: "+e)}).reduce(ge,0)+1},i.copyBytesInto=function(e){var t=Ie("[ ",e);return i.array.forEach(function(e,r){e instanceof Ht?t=Ie(e.toReference(),t):e instanceof dt?t=e.copyBytesInto(t):me("Not a PDFObject: "+e),t=Ie(" ",t)}),t=Ie("]",t)},it(r,ot(dt),"Cannot construct PDFArray from array whose elements are not PDFObjects"),nt(n,ot(pt),'"index" must be a an instance of PDFObjectIndex'),i.array=r,i.index=n,i}return gt(t,e),t.fromArray=function(e,r){return new t(e,r)},t}(dt),bt="[object Boolean]";var vt=function(e){return!0===e||!1===e||v(e)&&b(e)==bt},mt=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),wt=function(e){function t(r){var n=e.call(this)||this;return n.clone=function(){return t.fromBool(n.boolean)},n.toString=function(){return n.boolean.toString()},n.bytesSize=function(){return n.toString().length},n.copyBytesInto=function(e){return Ie(n.toString(),e)},nt(r,vt,"Can only construct PDFBooleans from Booleans"),n.boolean=r,n}return mt(t,e),t.fromBool=function(e){return new t(e)},t.fromString=function(e){return new t(function(e){if("true"===e)return!0;if("false"===e)return!1;throw new Error('"'+e+'" cannot be converted to a boolean')}(e))},t}(dt);var St=function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e};var xt=function(e){return function(t,r,n){for(var i=-1,o=Object(t),a=n(t),s=a.length;s--;){var u=a[e?s:++i];if(!1===r(o[u],u,o))break}return t}}();var Pt=function(e,t){return function(r,n){if(null==r)return r;if(!ie(r))return e(r,n);for(var i=r.length,o=t?i:-1,a=Object(r);(t?o--:++o<i)&&!1!==n(a[o],o,a););return r}}(function(e,t){return e&&xt(e,t,oe)});var kt=function(e){return"function"==typeof e?e:be};var At=function(e,t){return(D(e)?St:Pt)(e,kt(t))},Ot=X(Object.getPrototypeOf,Object),Ct="[object Object]",It=Function.prototype,_t=Object.prototype,Dt=It.toString,Bt=_t.hasOwnProperty,Et=Dt.call(Object);var jt=function(e){if(!v(e)||b(e)!=Ct)return!1;var t=Ot(e);if(null===t)return!0;var r=Bt.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&Dt.call(r)==Et},Tt="[object String]";var Ft=function(e){return"string"==typeof e||!D(e)&&v(e)&&b(e)==Tt},zt=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Rt=function(e){function t(r,n,i){var o=e.call(this)||this;return o.filter=function(e){return Array.from(o.map.entries()).filter(function(t){var r=t[0],n=t[1];return e(n,r)})},o.getMaybe=function(e){nt(e,ke(Ft,ot(Kt)),"PDFDictionary.set() requires keys to be strings or PDFNames");var t=e instanceof Kt?e:Kt.from(e);return o.map.get(t)},o.get=function(e){return o.getMaybe(e)||me('Missing PDFDictionary entry "'+e+'".')},o.set=function(e,t,r){void 0===r&&(r=!0),nt(e,ke(Ft,ot(Kt)),"PDFDictionary.set() requires keys to be strings or PDFNames"),nt(t,ot(dt),"PDFDictionary.set() requires values to be PDFObjects");var n=e instanceof Kt?e:Kt.from(e);return r&&o.validKeys&&!o.validKeys.includes(n.key)&&me('Invalid key: "'+n.key+'"'),o.map.set(n,t),o},o.delete=function(e){nt(e,ke(Ft,ot(Kt)),"PDFDictionary.set() requires keys to be strings or PDFNames");var t=e instanceof Kt?e:Kt.from(e);return o.map.delete(t),o},o.clone=function(){return t.from(new Map(o.map),o.index)},o.toString=function(){var e=new Uint8Array(o.bytesSize());return o.copyBytesInto(e),_e(e)},o.bytesSize=function(){return 3+Array.from(o.map.entries()).map(function(e){var t=e[0],r=e[1],n=(t.toString()+" ").length;if(r instanceof Ht)return n+r.toReference().length+1;if(r instanceof dt)return n+r.bytesSize()+1;throw new Error("Not a PDFObject: "+r.constructor.name)}).reduce(ge,0)+2},o.copyBytesInto=function(e){var t=Ie("<<\n",e);return o.map.forEach(function(e,r){if(t=Ie(r.toString()+" ",t),e instanceof Ht)t=Ie(e.toReference(),t);else{if(!(e instanceof dt))throw new Error("Not a PDFObject: "+e.constructor.name);t=e.copyBytesInto(t)}t=Ie("\n",t)}),t=Ie(">>",t)},nt(r,Pe(Ae(rt),ke(jt,ot(Map))),"PDFDictionary can only be constructed from an Object or a Map"),nt(n,ot(pt),'"index" must be an instance of PDFObjectIndex'),o.index=n,o.validKeys=i,r instanceof Map?o.map=r:(o.map=new Map,At(r,function(e,t){return o.set(t,e,!1)})),o}return zt(t,e),t.from=function(e,r){return new t(e,r)},t}(dt),Lt=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Nt=/^[\dABCDEFabcdef\0\t\n\f\r ]*$/,Mt=function(e){function t(r){var n=e.call(this)||this;return n.clone=function(){return t.fromString(n.string)},n.toString=function(){return"<"+n.string+">"},n.bytesSize=function(){return n.toString().length},n.copyBytesInto=function(e){return Ie(n.toString(),e)},nt(r,Ft,"PDFHexString.string must be a String"),nt(r,ct(Nt),'Invalid characters in hex string: "'+r+'"'),n.string=r,n}return Lt(t,e),t.fromString=function(e){return new t(e)},t}(dt),Ut=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Gt="@@__PDF_INDIRECT_REF_ENFORCER",Vt=new Map,qt=function(e){function t(t,r,n){var i=e.call(this)||this;return i.clone=function(){return i},i.toString=function(){return i.objectNumber+" "+i.generationNumber+" R"},i.bytesSize=function(){return i.toString().length},i.copyBytesInto=function(e){return Ie(i.toString(),e)},nt(t,st(Gt),"Cannot create PDFIndirectReference via constructor. Use PDFIndirectReference.forNumbers instead."),nt(r,w,"objectNumber must be a Number"),nt(n,w,"generationNumber must be a Number"),i.objectNumber=r,i.generationNumber=n,i}return Ut(t,e),t.forNumbers=function(e,r){var n=e+" "+r,i=Vt.get(n);return i||(i=new t(Gt,e,r),Vt.set(n,i)),i},t}(dt),Wt=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Ht=function(e){function t(r){var n=e.call(this)||this;return n.getReference=function(){return n.reference},n.setReferenceNumbers=function(e,t){return nt(e,w,"objectNumber must be a Number"),nt(t,w,"generationNumber must be a Number"),n.reference=qt.forNumbers(e,t),n},n.setReference=function(e){return nt(e,ot(qt),'"reference" must be a PDFIndirectReference object'),n.reference=e,n},n.toReference=function(){return n.reference.toString()},n.clone=function(){return t.of(n.pdfObject).setReference(n.reference)},n.toString=function(){var e=new Uint8Array(n.bytesSize());return n.copyBytesInto(e),_e(e)},n.bytesSize=function(){return(n.reference.objectNumber+" "+n.reference.generationNumber+" obj\n").length+n.pdfObject.bytesSize()+9},n.copyBytesInto=function(e){var t=Ie(n.reference.objectNumber+" "+n.reference.generationNumber+" obj\n",e);return t=n.pdfObject.copyBytesInto(t),t=Ie("\nendobj\n\n",t)},nt(r,ot(dt),"PDFIndirectObject.pdfObject must be of type PDFObject"),n.pdfObject=r,n}return Wt(t,e),t.of=function(e){return new t(e)},t}(dt),Yt=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Xt="@@__PDF_NAME_ENFORCER",Zt=new Map,Kt=function(e){function t(r,n){var i=e.call(this)||this;return i.clone=function(){return i},i.toString=function(){return("/"+i.key).replace("#","#23").split("").map(function(e){return t.isRegularChar(e)?e:"#"+Oe(e).toString(16)}).join("")},i.bytesSize=function(){return i.toString().length},i.copyBytesInto=function(e){return Ie(i.toString(),e)},nt(r,st(Xt),"Cannot create PDFName via constructor. Use PDFName.from instead."),nt(n.charAt(0),Pe(ut(" "),ut("/")),"PDFName objects may not begin with a space or slash character."),i.key=n,i}return Yt(t,e),t.isRegularChar=function(e){return Oe(e)>=Oe("!")&&Oe(e)<=Oe("~")},t.from=function(e){nt(e,Ft,"PDFName.from() requires string as argument");var r=Zt.get(e);return r||(r=new t(Xt,e),Zt.set(e,r)),r},t.fromEncoded=function(e){nt(e,Ft,"PDFName.fromEncoded() requires string as argument");var r=e.replace(/(#\d{2})/g,function(e){return String.fromCharCode(parseInt(e.slice(1),16))});return t.from(r)},t}(dt),Jt=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Qt="@@__PDF_NULL_ENFORCER",$t=function(e){function t(t){var r=e.call(this)||this;return r.clone=function(){return r},r.toString=function(){return"null"},r.bytesSize=function(){return 4},r.copyBytesInto=function(e){return Ie("null",e)},nt(t,st(Qt),"Cannot create new PDFNull objects - use PDFNull.instance"),r}return Jt(t,e),t.instance=new t(Qt),t}(dt),er=o.isFinite;var tr=function(e){return"number"==typeof e&&er(e)},rr=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),nr=function(e){function t(r){var n=e.call(this)||this;return n.clone=function(){return t.fromNumber(n.number)},n.toString=function(){return n.number.toString()},n.bytesSize=function(){return n.toString().length},n.copyBytesInto=function(e){return Ie(n.toString(),e)},nt(r,tr,"Can only construct PDFNumbers from Numbers"),n.number=r,n}return rr(t,e),t.fromNumber=function(e){return new t(e)},t.fromString=function(e){return nt(e,Ft,"PDFNumber.fromString requires a string as a parameter."),new t(Number(e))},t}(dt),ir=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),or=function(e){function t(t){var r=e.call(this)||this;return r.validateDictionary=function(){r.dictionary.getMaybe("Length")||me('"Length" is a required field for PDFStream dictionaries')},r.clone=function(){return me('"clone" is not implemented on PDFStream.')},nt(t,ot(Rt),"PDFStream.dictionary must be of type PDFDictionary"),r.dictionary=t,r}return ir(t,e),t}(dt),ar=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),sr=function(e){function t(r,n){var i=e.call(this,r)||this;return i.clone=function(){return t.from(i.dictionary.clone(),i.content.slice())},i.bytesSize=function(){return i.dictionary.bytesSize()+1+7+i.content.length+10},i.copyBytesInto=function(e){i.validateDictionary();var t=i.dictionary.copyBytesInto(e);return(t=Ie("\nstream\n",t)).set(i.content,0),t=t.subarray(i.content.length),t=Ie("\nendstream",t)},nt(n,ot(Uint8Array),"PDFRawStream.content must be a Uint8Array"),i.content=n,i}return ar(t,e),t.from=function(e,r){return new t(e,r)},t}(or),ur=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),cr=function(e){function t(r){var n=e.call(this)||this;return n.clone=function(){return t.fromString(n.string)},n.toString=function(){return"("+n.string.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")+")"},n.bytesSize=function(){return n.toString().length},n.copyBytesInto=function(e){return Ie(n.toString(),e)},nt(r,Ft,"Can only construct PDFStrings from Strings"),n.string=r,n}return ur(t,e),t.fromString=function(e){return new t(e)},t}(dt),fr=9007199254740991,lr=Math.floor;var hr=function(e,t){var r="";if(!e||t<1||t>fr)return r;do{t%2&&(r+=e),(t=lr(t/2))&&(e+=e)}while(t);return r};var pr=function(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n<i;)o[n]=e[n+t];return o};var dr=function(e,t,r){var n=e.length;return r=void 0===r?n:r,!t&&r>=n?e:pr(e,t,r)},gr=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var yr=function(e){return gr.test(e)};var br=function(e){return function(t){return null==t?void 0:t[e]}},vr=br("length"),mr="[\\ud800-\\udfff]",wr="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Sr="\\ud83c[\\udffb-\\udfff]",xr="[^\\ud800-\\udfff]",Pr="(?:\\ud83c[\\udde6-\\uddff]){2}",kr="[\\ud800-\\udbff][\\udc00-\\udfff]",Ar="(?:"+wr+"|"+Sr+")"+"?",Or="[\\ufe0e\\ufe0f]?"+Ar+("(?:\\u200d(?:"+[xr,Pr,kr].join("|")+")[\\ufe0e\\ufe0f]?"+Ar+")*"),Cr="(?:"+[xr+wr+"?",wr,Pr,kr,mr].join("|")+")",Ir=RegExp(Sr+"(?="+Sr+")|"+Cr+Or,"g");var _r=function(e){for(var t=Ir.lastIndex=0;Ir.test(e);)++t;return t};var Dr=function(e){return yr(e)?_r(e):vr(e)};var Br=function(e){return e.split("")},Er="[\\ud800-\\udfff]",jr="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Tr="\\ud83c[\\udffb-\\udfff]",Fr="[^\\ud800-\\udfff]",zr="(?:\\ud83c[\\udde6-\\uddff]){2}",Rr="[\\ud800-\\udbff][\\udc00-\\udfff]",Lr="(?:"+jr+"|"+Tr+")"+"?",Nr="[\\ufe0e\\ufe0f]?"+Lr+("(?:\\u200d(?:"+[Fr,zr,Rr].join("|")+")[\\ufe0e\\ufe0f]?"+Lr+")*"),Mr="(?:"+[Fr+jr+"?",jr,zr,Rr,Er].join("|")+")",Ur=RegExp(Tr+"(?="+Tr+")|"+Mr+Nr,"g");var Gr=function(e){return e.match(Ur)||[]};var Vr=function(e){return yr(e)?Gr(e):Br(e)},qr=Math.ceil;var Wr=function(e,t){var r=(t=void 0===t?" ":de(t)).length;if(r<2)return r?hr(t,e):t;var n=hr(t,qr(e/Dr(t)));return yr(t)?dr(Vr(n),0,e).join(""):n.slice(0,e)};var Hr=function(e){var t=Qe(e),r=t%1;return t==t?r?t-r:t:0};var Yr=function(e){return null==e?"":de(e)};var Xr=function(e,t,r){e=Yr(e);var n=(t=Hr(t))?Dr(e):0;return t&&n<t?Wr(t-n,r)+e:e},Zr=function(){function e(){var e=this;this.isInUse=!1,this.setOffset=function(t){return nt(t,w,"offset must be a number"),e.offset=t,e},this.setGenerationNum=function(t){return nt(t,w,"generationNum must be a number"),e.generationNum=t,e},this.setIsInUse=function(t){return nt(t,vt,"isInUse must be a boolean"),e.isInUse=t,e},this.toString=function(){return Xr(String(e.offset),10,"0")+" "+Xr(String(e.generationNum),5,"0")+" "+(e.isInUse?"n":"f")+" \n"},this.bytesSize=function(){return e.toString().length}}return e.create=function(){return new e},e}(),Kr=function(){function e(e){void 0===e&&(e=[]);var t=this;this.entries=[],this.addEntry=function(e){return nt(e,ot(Zr),'"entry" must be instance of PDFXRef.Entry'),t.entries.push(e),t},this.setFirstObjNum=function(e){return nt(e,w,"firstObjNum must be a number"),t.firstObjNum=e,t},this.toString=function(){return t.firstObjNum+" "+t.entries.length+"\n"+t.entries.map(String).join("")},this.bytesSize=function(){return(t.firstObjNum+" "+t.entries.length+"\n").length+t.entries.map(function(e){return e.bytesSize()}).reduce(ge,0)},it(e,ot(Zr),"PDFXRef.Subsection.entries must be an array of PDFXRef.Entry"),this.entries=e}return e.from=function(t){return void 0===t&&(t=[]),new e(t)},e}(),Jr=function(){function e(e){void 0===e&&(e=[]);var t=this;this.subsections=[],this.addSubsection=function(e){return nt(e,ot(Kr),'"subsection" must be instance of PDFXRef.Subsection'),t.subsections.push(e),t},this.toString=function(){return"xref\n"+t.subsections.map(String).join("\n")+"\n"},this.bytesSize=function(){return 5+t.subsections.map(function(e){return e.bytesSize()+1}).reduce(ge,0)},this.copyBytesInto=function(e){var r=Ie("xref\n",e);return t.subsections.map(String).forEach(function(e){r=Ie(e+"\n",r)}),r},it(e,ot(Kr),"subsections must be an array of PDFXRef.Subsection"),this.subsections=e}return e.from=function(t){return void 0===t&&(t=[]),new e(t)},e}(),Qr=Object.freeze({Entry:Zr,Subsection:Kr,Table:Jr}),$r=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),en=Object.freeze(["Type","Version","Extensions","Pages","PageLabels","Names","Dests","ViewerPreferences","PageLayout","PageMode","Outlines","Threads","OpenAction","AA","URI","AcroForm","Metadata","StructTreeRoot","MarkInfo","Lang","SpiderInfo","OutputIntents","PieceInfo","OCProperties","Perms","Legal","Requirements","Collection","NeedsRendering"]),tn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return $r(t,e),Object.defineProperty(t.prototype,"Pages",{get:function(){var e=this.get("Pages");return this.index.lookup(e)},enumerable:!0,configurable:!0}),t.create=function(e,r){return nt(e,ot(qt),'"pageTree" must be an indirect reference'),new t({Type:Kt.from("Catalog"),Pages:e},r)},t.fromObject=function(e,r){return new t(e,r,en)},t.fromDict=function(e){return nt(e,ot(Rt),'"dict" must be a PDFDictionary'),new t(e.map,e.index,en)},t}(Rt);var rn=function(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e},nn=a?a.isConcatSpreadable:void 0;var on=function(e){return D(e)||_(e)||!!(nn&&e&&e[nn])};var an=function e(t,r,n,i,o){var a=-1,s=t.length;for(n||(n=on),o||(o=[]);++a<s;){var u=t[a];r>0&&n(u)?r>1?e(u,r-1,n,i,o):rn(o,u):i||(o[o.length]=u)}return o};var sn=function(e){return null!=e&&e.length?an(e,1):[]},un=r(function(e,t){var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)n(r,i)&&(e[i]=r[i])}}return e},t.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var i={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){var t,r,n,i,o,a;for(n=0,t=0,r=e.length;t<r;t++)n+=e[t].length;for(a=new Uint8Array(n),i=0,t=0,r=e.length;t<r;t++)o=e[t],a.set(o,i),i+=o.length;return a}},o={arraySet:function(e,t,r,n,i){for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){return[].concat.apply([],e)}};t.setTyped=function(e){e?(t.Buf8=Uint8Array,t.Buf16=Uint16Array,t.Buf32=Int32Array,t.assign(t,i)):(t.Buf8=Array,t.Buf16=Array,t.Buf32=Array,t.assign(t,o))},t.setTyped(r)}),cn=(un.assign,un.shrinkBuf,un.setTyped,un.Buf8,un.Buf16,un.Buf32,4),fn=0,ln=1,hn=2;function pn(e){for(var t=e.length;--t>=0;)e[t]=0}var dn=0,gn=1,yn=2,bn=29,vn=256,mn=vn+1+bn,wn=30,Sn=19,xn=2*mn+1,Pn=15,kn=16,An=7,On=256,Cn=16,In=17,_n=18,Dn=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Bn=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],En=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],jn=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Tn=new Array(2*(mn+2));pn(Tn);var Fn=new Array(2*wn);pn(Fn);var zn=new Array(512);pn(zn);var Rn=new Array(256);pn(Rn);var Ln=new Array(bn);pn(Ln);var Nn,Mn,Un,Gn=new Array(wn);function Vn(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function qn(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Wn(e){return e<256?zn[e]:zn[256+(e>>>7)]}function Hn(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function Yn(e,t,r){e.bi_valid>kn-r?(e.bi_buf|=t<<e.bi_valid&65535,Hn(e,e.bi_buf),e.bi_buf=t>>kn-e.bi_valid,e.bi_valid+=r-kn):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function Xn(e,t,r){Yn(e,r[2*t],r[2*t+1])}function Zn(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function Kn(e,t,r){var n,i,o=new Array(Pn+1),a=0;for(n=1;n<=Pn;n++)o[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];0!==s&&(e[2*i]=Zn(o[s]++,s))}}function Jn(e){var t;for(t=0;t<mn;t++)e.dyn_ltree[2*t]=0;for(t=0;t<wn;t++)e.dyn_dtree[2*t]=0;for(t=0;t<Sn;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*On]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function Qn(e){e.bi_valid>8?Hn(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function $n(e,t,r,n){var i=2*t,o=2*r;return e[i]<e[o]||e[i]===e[o]&&n[t]<=n[r]}function ei(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&$n(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!$n(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function ti(e,t,r){var n,i,o,a,s=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],i=e.pending_buf[e.l_buf+s],s++,0===n?Xn(e,i,t):(Xn(e,(o=Rn[i])+vn+1,t),0!==(a=Dn[o])&&Yn(e,i-=Ln[o],a),Xn(e,o=Wn(--n),r),0!==(a=Bn[o])&&Yn(e,n-=Gn[o],a))}while(s<e.last_lit);Xn(e,On,t)}function ri(e,t){var r,n,i,o=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,u=t.stat_desc.elems,c=-1;for(e.heap_len=0,e.heap_max=xn,r=0;r<u;r++)0!==o[2*r]?(e.heap[++e.heap_len]=c=r,e.depth[r]=0):o[2*r+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=c<2?++c:0)]=1,e.depth[i]=0,e.opt_len--,s&&(e.static_len-=a[2*i+1]);for(t.max_code=c,r=e.heap_len>>1;r>=1;r--)ei(e,o,r);i=u;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ei(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,o[2*i]=o[2*r]+o[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,o[2*r+1]=o[2*n+1]=i,e.heap[1]=i++,ei(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,o,a,s,u=t.dyn_tree,c=t.max_code,f=t.stat_desc.static_tree,l=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,d=t.stat_desc.max_length,g=0;for(o=0;o<=Pn;o++)e.bl_count[o]=0;for(u[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<xn;r++)(o=u[2*u[2*(n=e.heap[r])+1]+1]+1)>d&&(o=d,g++),u[2*n+1]=o,n>c||(e.bl_count[o]++,a=0,n>=p&&(a=h[n-p]),s=u[2*n],e.opt_len+=s*(o+a),l&&(e.static_len+=s*(f[2*n+1]+a)));if(0!==g){do{for(o=d-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[d]--,g-=2}while(g>0);for(o=d;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>c||(u[2*i+1]!==o&&(e.opt_len+=(o-u[2*i+1])*u[2*i],u[2*i+1]=o),n--)}}(e,t),Kn(o,c,e.bl_count)}function ni(e,t,r){var n,i,o=-1,a=t[1],s=0,u=7,c=4;for(0===a&&(u=138,c=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=t[2*(n+1)+1],++s<u&&i===a||(s<c?e.bl_tree[2*i]+=s:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[2*Cn]++):s<=10?e.bl_tree[2*In]++:e.bl_tree[2*_n]++,s=0,o=i,0===a?(u=138,c=3):i===a?(u=6,c=3):(u=7,c=4))}function ii(e,t,r){var n,i,o=-1,a=t[1],s=0,u=7,c=4;for(0===a&&(u=138,c=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++s<u&&i===a)){if(s<c)do{Xn(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(Xn(e,i,e.bl_tree),s--),Xn(e,Cn,e.bl_tree),Yn(e,s-3,2)):s<=10?(Xn(e,In,e.bl_tree),Yn(e,s-3,3)):(Xn(e,_n,e.bl_tree),Yn(e,s-11,7));s=0,o=i,0===a?(u=138,c=3):i===a?(u=6,c=3):(u=7,c=4)}}pn(Gn);var oi=!1;function ai(e,t,r,n){Yn(e,(dn<<1)+(n?1:0),3),function(e,t,r,n){Qn(e),n&&(Hn(e,r),Hn(e,~r)),un.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}var si={_tr_init:function(e){oi||(function(){var e,t,r,n,i,o=new Array(Pn+1);for(r=0,n=0;n<bn-1;n++)for(Ln[n]=r,e=0;e<1<<Dn[n];e++)Rn[r++]=n;for(Rn[r-1]=n,i=0,n=0;n<16;n++)for(Gn[n]=i,e=0;e<1<<Bn[n];e++)zn[i++]=n;for(i>>=7;n<wn;n++)for(Gn[n]=i<<7,e=0;e<1<<Bn[n]-7;e++)zn[256+i++]=n;for(t=0;t<=Pn;t++)o[t]=0;for(e=0;e<=143;)Tn[2*e+1]=8,e++,o[8]++;for(;e<=255;)Tn[2*e+1]=9,e++,o[9]++;for(;e<=279;)Tn[2*e+1]=7,e++,o[7]++;for(;e<=287;)Tn[2*e+1]=8,e++,o[8]++;for(Kn(Tn,mn+1,o),e=0;e<wn;e++)Fn[2*e+1]=5,Fn[2*e]=Zn(e,5);Nn=new Vn(Tn,Dn,vn+1,mn,Pn),Mn=new Vn(Fn,Bn,0,wn,Pn),Un=new Vn(new Array(0),En,0,Sn,An)}(),oi=!0),e.l_desc=new qn(e.dyn_ltree,Nn),e.d_desc=new qn(e.dyn_dtree,Mn),e.bl_desc=new qn(e.bl_tree,Un),e.bi_buf=0,e.bi_valid=0,Jn(e)},_tr_stored_block:ai,_tr_flush_block:function(e,t,r,n){var i,o,a=0;e.level>0?(e.strm.data_type===hn&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return fn;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return ln;for(t=32;t<vn;t++)if(0!==e.dyn_ltree[2*t])return ln;return fn}(e)),ri(e,e.l_desc),ri(e,e.d_desc),a=function(e){var t;for(ni(e,e.dyn_ltree,e.l_desc.max_code),ni(e,e.dyn_dtree,e.d_desc.max_code),ri(e,e.bl_desc),t=Sn-1;t>=3&&0===e.bl_tree[2*jn[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==t?ai(e,t,r,n):e.strategy===cn||o===i?(Yn(e,(gn<<1)+(n?1:0),3),ti(e,Tn,Fn)):(Yn(e,(yn<<1)+(n?1:0),3),function(e,t,r,n){var i;for(Yn(e,t-257,5),Yn(e,r-1,5),Yn(e,n-4,4),i=0;i<n;i++)Yn(e,e.bl_tree[2*jn[i]+1],3);ii(e,e.dyn_ltree,t-1),ii(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),ti(e,e.dyn_ltree,e.dyn_dtree)),Jn(e),n&&Qn(e)},_tr_tally:function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(Rn[r]+vn+1)]++,e.dyn_dtree[2*Wn(t)]++),e.last_lit===e.lit_bufsize-1},_tr_align:function(e){Yn(e,gn<<1,3),Xn(e,On,Tn),function(e){16===e.bi_valid?(Hn(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}};var ui=function(e,t,r,n){for(var i=65535&e|0,o=e>>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+t[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16|0};var ci=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();var fi,li=function(e,t,r,n){var i=ci,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e},hi={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},pi=0,di=1,gi=3,yi=4,bi=5,vi=0,mi=1,wi=-2,Si=-3,xi=-5,Pi=-1,ki=1,Ai=2,Oi=3,Ci=4,Ii=0,_i=2,Di=8,Bi=9,Ei=15,ji=8,Ti=286,Fi=30,zi=19,Ri=2*Ti+1,Li=15,Ni=3,Mi=258,Ui=Mi+Ni+1,Gi=32,Vi=42,qi=69,Wi=73,Hi=91,Yi=103,Xi=113,Zi=666,Ki=1,Ji=2,Qi=3,$i=4,eo=3;function to(e,t){return e.msg=hi[t],t}function ro(e){return(e<<1)-(e>4?9:0)}function no(e){for(var t=e.length;--t>=0;)e[t]=0}function io(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(un.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function oo(e,t){si._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,io(e.strm)}function ao(e,t){e.pending_buf[e.pending++]=t}function so(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function uo(e,t){var r,n,i=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,u=e.strstart>e.w_size-Ui?e.strstart-(e.w_size-Ui):0,c=e.window,f=e.w_mask,l=e.prev,h=e.strstart+Mi,p=c[o+a-1],d=c[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(c[(r=t)+a]===d&&c[r+a-1]===p&&c[r]===c[o]&&c[++r]===c[o+1]){o+=2,r++;do{}while(c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&o<h);if(n=Mi-(h-o),o=h-Mi,n>a){if(e.match_start=t,a=n,n>=s)break;p=c[o+a-1],d=c[o+a]}}}while((t=l[t&f])>u&&0!=--i);return a<=e.lookahead?a:e.lookahead}function co(e){var t,r,n,i,o,a,s,u,c,f,l=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=l+(l-Ui)){un.arraySet(e.window,e.window,l,l,0),e.match_start-=l,e.strstart-=l,e.block_start-=l,t=r=e.hash_size;do{n=e.head[--t],e.head[t]=n>=l?n-l:0}while(--r);t=r=l;do{n=e.prev[--t],e.prev[t]=n>=l?n-l:0}while(--r);i+=l}if(0===e.strm.avail_in)break;if(a=e.strm,s=e.window,u=e.strstart+e.lookahead,c=i,f=void 0,(f=a.avail_in)>c&&(f=c),r=0===f?0:(a.avail_in-=f,un.arraySet(s,a.input,a.next_in,f,u),1===a.state.wrap?a.adler=ui(a.adler,s,f,u):2===a.state.wrap&&(a.adler=li(a.adler,s,f,u)),a.next_in+=f,a.total_in+=f,f),e.lookahead+=r,e.lookahead+e.insert>=Ni)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+Ni-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<Ni)););}while(e.lookahead<Ui&&0!==e.strm.avail_in)}function fo(e,t){for(var r,n;;){if(e.lookahead<Ui){if(co(e),e.lookahead<Ui&&t===pi)return Ki;if(0===e.lookahead)break}if(r=0,e.lookahead>=Ni&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ni-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-Ui&&(e.match_length=uo(e,r)),e.match_length>=Ni)if(n=si._tr_tally(e,e.strstart-e.match_start,e.match_length-Ni),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Ni){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ni-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=si._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(oo(e,!1),0===e.strm.avail_out))return Ki}return e.insert=e.strstart<Ni-1?e.strstart:Ni-1,t===yi?(oo(e,!0),0===e.strm.avail_out?Qi:$i):e.last_lit&&(oo(e,!1),0===e.strm.avail_out)?Ki:Ji}function lo(e,t){for(var r,n,i;;){if(e.lookahead<Ui){if(co(e),e.lookahead<Ui&&t===pi)return Ki;if(0===e.lookahead)break}if(r=0,e.lookahead>=Ni&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ni-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=Ni-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-Ui&&(e.match_length=uo(e,r),e.match_length<=5&&(e.strategy===ki||e.match_length===Ni&&e.strstart-e.match_start>4096)&&(e.match_length=Ni-1)),e.prev_length>=Ni&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-Ni,n=si._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-Ni),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ni-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=Ni-1,e.strstart++,n&&(oo(e,!1),0===e.strm.avail_out))return Ki}else if(e.match_available){if((n=si._tr_tally(e,0,e.window[e.strstart-1]))&&oo(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return Ki}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=si._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<Ni-1?e.strstart:Ni-1,t===yi?(oo(e,!0),0===e.strm.avail_out?Qi:$i):e.last_lit&&(oo(e,!1),0===e.strm.avail_out)?Ki:Ji}function ho(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function po(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Di,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new un.Buf16(2*Ri),this.dyn_dtree=new un.Buf16(2*(2*Fi+1)),this.bl_tree=new un.Buf16(2*(2*zi+1)),no(this.dyn_ltree),no(this.dyn_dtree),no(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new un.Buf16(Li+1),this.heap=new un.Buf16(2*Ti+1),no(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new un.Buf16(2*Ti+1),no(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function go(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=_i,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?Vi:Xi,e.adler=2===t.wrap?0:1,t.last_flush=pi,si._tr_init(t),vi):to(e,wi)}function yo(e){var t,r=go(e);return r===vi&&((t=e.state).window_size=2*t.w_size,no(t.head),t.max_lazy_match=fi[t.level].max_lazy,t.good_match=fi[t.level].good_length,t.nice_match=fi[t.level].nice_length,t.max_chain_length=fi[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=Ni-1,t.match_available=0,t.ins_h=0),r}function bo(e,t,r,n,i,o){if(!e)return wi;var a=1;if(t===Pi&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>Bi||r!==Di||n<8||n>15||t<0||t>9||o<0||o>Ci)return to(e,wi);8===n&&(n=9);var s=new po;return e.state=s,s.strm=e,s.wrap=a,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+Ni-1)/Ni),s.window=new un.Buf8(2*s.w_size),s.head=new un.Buf16(s.hash_size),s.prev=new un.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new un.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=o,s.method=r,yo(e)}fi=[new ho(0,0,0,0,function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(co(e),0===e.lookahead&&t===pi)return Ki;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,oo(e,!1),0===e.strm.avail_out))return Ki;if(e.strstart-e.block_start>=e.w_size-Ui&&(oo(e,!1),0===e.strm.avail_out))return Ki}return e.insert=0,t===yi?(oo(e,!0),0===e.strm.avail_out?Qi:$i):(e.strstart>e.block_start&&(oo(e,!1),e.strm.avail_out),Ki)}),new ho(4,4,8,4,fo),new ho(4,5,16,8,fo),new ho(4,6,32,32,fo),new ho(4,4,16,16,lo),new ho(8,16,32,32,lo),new ho(8,16,128,128,lo),new ho(8,32,128,256,lo),new ho(32,128,258,1024,lo),new ho(32,258,258,4096,lo)];var vo={deflateInit:function(e,t){return bo(e,t,Di,Ei,ji,Ii)},deflateInit2:bo,deflateReset:yo,deflateResetKeep:go,deflateSetHeader:function(e,t){return e&&e.state?2!==e.state.wrap?wi:(e.state.gzhead=t,vi):wi},deflate:function(e,t){var r,n,i,o;if(!e||!e.state||t>bi||t<0)return e?to(e,wi):wi;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===Zi&&t!==yi)return to(e,0===e.avail_out?xi:wi);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===Vi)if(2===n.wrap)e.adler=0,ao(n,31),ao(n,139),ao(n,8),n.gzhead?(ao(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),ao(n,255&n.gzhead.time),ao(n,n.gzhead.time>>8&255),ao(n,n.gzhead.time>>16&255),ao(n,n.gzhead.time>>24&255),ao(n,9===n.level?2:n.strategy>=Ai||n.level<2?4:0),ao(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(ao(n,255&n.gzhead.extra.length),ao(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=li(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=qi):(ao(n,0),ao(n,0),ao(n,0),ao(n,0),ao(n,0),ao(n,9===n.level?2:n.strategy>=Ai||n.level<2?4:0),ao(n,eo),n.status=Xi);else{var a=Di+(n.w_bits-8<<4)<<8;a|=(n.strategy>=Ai||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=Gi),a+=31-a%31,n.status=Xi,so(n,a),0!==n.strstart&&(so(n,e.adler>>>16),so(n,65535&e.adler)),e.adler=1}if(n.status===qi)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=li(e.adler,n.pending_buf,n.pending-i,i)),io(e),i=n.pending,n.pending!==n.pending_buf_size));)ao(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=li(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=Wi)}else n.status=Wi;if(n.status===Wi)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=li(e.adler,n.pending_buf,n.pending-i,i)),io(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,ao(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=li(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.gzindex=0,n.status=Hi)}else n.status=Hi;if(n.status===Hi)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=li(e.adler,n.pending_buf,n.pending-i,i)),io(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,ao(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=li(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=Yi)}else n.status=Yi;if(n.status===Yi&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&io(e),n.pending+2<=n.pending_buf_size&&(ao(n,255&e.adler),ao(n,e.adler>>8&255),e.adler=0,n.status=Xi)):n.status=Xi),0!==n.pending){if(io(e),0===e.avail_out)return n.last_flush=-1,vi}else if(0===e.avail_in&&ro(t)<=ro(r)&&t!==yi)return to(e,xi);if(n.status===Zi&&0!==e.avail_in)return to(e,xi);if(0!==e.avail_in||0!==n.lookahead||t!==pi&&n.status!==Zi){var s=n.strategy===Ai?function(e,t){for(var r;;){if(0===e.lookahead&&(co(e),0===e.lookahead)){if(t===pi)return Ki;break}if(e.match_length=0,r=si._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(oo(e,!1),0===e.strm.avail_out))return Ki}return e.insert=0,t===yi?(oo(e,!0),0===e.strm.avail_out?Qi:$i):e.last_lit&&(oo(e,!1),0===e.strm.avail_out)?Ki:Ji}(n,t):n.strategy===Oi?function(e,t){for(var r,n,i,o,a=e.window;;){if(e.lookahead<=Mi){if(co(e),e.lookahead<=Mi&&t===pi)return Ki;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=Ni&&e.strstart>0&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){o=e.strstart+Mi;do{}while(n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&i<o);e.match_length=Mi-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Ni?(r=si._tr_tally(e,1,e.match_length-Ni),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=si._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(oo