",l=r.open();return null!==l&&l.document.write(c),l}throw new Error("The option pdfobjectnewwindow just works in a browser-environment.");case"pdfjsnewwindow":if("[object Window]"===Object.prototype.toString.call(r)){var h=' ',g=r.open();if(null!==g&&(g.document.write(p),g.document.title=e.filename),g||"undefined"==typeof safari)return g;break;case"datauri":case"dataurl":return r.document.location.href=this.output("datauristring",e);default:return null}})),Ge=function(t){return!0===Array.isArray(Ut)&&Ut.indexOf(t)>-1};switch(o){case"pt":_t=1;break;case"mm":_t=72/25.4;break;case"cm":_t=72/2.54;break;case"in":_t=72;break;case"px":_t=1==Ge("px_scaling")?.75:96/72;break;case"pc":case"em":_t=12;break;case"ex":_t=6;break;default:if("number"!=typeof o)throw new Error("Invalid unit: "+o);_t=o}var Ye=null;K(),Y();var Je=function(t){return null!==m?Ye.encryptor(t,0):function(t){return t}},Xe=y.__private__.getPageInfo=y.getPageInfo=function(t){if(isNaN(t)||t%1!=0)throw new Error("Invalid argument passed to jsPDF.getPageInfo");return{objId:Rt[t].objId,pageNumber:t,pageContext:Rt[t]}},Ke=y.__private__.getPageInfoByObjId=function(t){if(isNaN(t)||t%1!=0)throw new Error("Invalid argument passed to jsPDF.getPageInfoByObjId");for(var e in Rt)if(Rt[e].objId===t)break;return Xe(e)},Ze=y.__private__.getCurrentPageInfo=y.getCurrentPageInfo=function(){return{objId:Rt[$].objId,pageNumber:$,pageContext:Rt[$]}};y.addPage=function(){return Oe.apply(this,arguments),this},y.setPage=function(){return Me.apply(this,arguments),lt.call(this,ot[$]),this},y.insertPage=function(t){return this.addPage(),this.movePage($,t),this},y.movePage=function(t,e){var r,n;if(t>e){r=ot[t],n=Rt[t];for(var i=t;i>e;i--)ot[i]=ot[i-1],Rt[i]=Rt[i-1];ot[e]=r,Rt[e]=n,this.setPage(e)}else if(t0&&("string"==typeof t?t=g.splitTextToSize(t,h):"[object Array]"===Object.prototype.toString.call(t)&&(t=t.reduce((function(t,e){return t.concat(g.splitTextToSize(e,h))}),[]))),o={text:t,x:r,y:n,options:i,mutex:{pdfEscape:Ce,activeFontKey:St,fonts:It,activeFontSize:gt}},Tt.publish("preProcessText",o),t=o.text,c=(i=o.options).angle,p instanceof Vt==!1&&c&&"number"==typeof c){c*=Math.PI/180,0===i.rotationDirection&&(c=-c),S===x.ADVANCED&&(c=-c);var B=Math.cos(c),M=Math.sin(c);p=new Vt(B,M,-M,B,0,0)}else c&&c instanceof Vt&&(p=c);S!==x.ADVANCED||p||(p=Yt),void 0!==(l=i.charSpace||_r)&&(v+=E(U(l))+" Tc\n",this.setCharSpace(this.getCharSpace()||0)),void 0!==(d=i.horizontalScale)&&(v+=E(100*d)+" Tz\n");i.lang;var D=-1,R=void 0!==i.renderingMode?i.renderingMode:i.stroke,T=g.internal.getCurrentPageInfo().pageContext;switch(R){case 0:case!1:case"fill":D=0;break;case 1:case!0:case"stroke":D=1;break;case 2:case"fillThenStroke":D=2;break;case 3:case"invisible":D=3;break;case 4:case"fillAndAddForClipping":D=4;break;case 5:case"strokeAndAddPathForClipping":D=5;break;case 6:case"fillThenStrokeAndAddToPathForClipping":D=6;break;case 7:case"addToPathForClipping":D=7}var z=void 0!==T.usedRenderingMode?T.usedRenderingMode:-1;-1!==D?v+=D+" Tr\n":-1!==z&&(v+="0 Tr\n"),-1!==D&&(T.usedRenderingMode=D),u=i.align||"left";var H,W=gt*w,V=g.internal.pageSize.getWidth(),G=It[St];l=i.charSpace||_r,h=i.maxWidth||0,f=Object.assign({autoencode:!0,noBOM:!0},i.flags);var Y=[];if("[object Array]"===Object.prototype.toString.call(t)){var J;s=A(t),"left"!==u&&(H=s.map((function(t){return g.getStringUnitWidth(t,{font:G,charSpace:l,fontSize:gt,doKerning:!1})*gt/N})));var X,K=0;if("right"===u){r-=H[0],t=[],C=s.length;for(var Z=0;Z":")"),nt=parseFloat(s[ft][1]),it=parseFloat(s[ft][2]);break;case ot:at=(y?"<":"(")+s[ft]+(y?">":")"),nt=br(r),it=yr(n)}void 0!==Y&&void 0!==Y[ft]&&(ut=Y[ft]+" Tw\n"),0===ft?t.push(ut+lt(nt,it,p)+at):ct===ot?t.push(ut+at):ct===st&&t.push(ut+lt(nt,it,p)+at)}t=ct===ot?t.join(" Tj\nT* "):t.join(" Tj\n"),t+=" Tj\n";var dt="BT\n/";return dt+=St+" "+gt+" Tf\n",dt+=E(gt*w)+" TL\n",dt+=xr+"\n",dt+=v,dt+=t,ht(dt+="ET"),b[St]=!0,g};var $e=y.__private__.clip=y.clip=function(t){return ht("evenodd"===t?"W*":"W"),this};y.clipEvenOdd=function(){return $e("evenodd")},y.__private__.discardPath=y.discardPath=function(){return ht("n"),this};var Qe=y.__private__.isValidStyle=function(t){var e=!1;return-1!==[void 0,null,"S","D","F","DF","FD","f","f*","B","B*","n"].indexOf(t)&&(e=!0),e};y.__private__.setDefaultPathOperation=y.setDefaultPathOperation=function(t){return Qe(t)&&(g=t),this};var tr=y.__private__.getStyle=y.getStyle=function(t){var e=g;switch(t){case"D":case"S":e="S";break;case"F":e="f";break;case"FD":case"DF":e="B";break;case"f":case"f*":case"B":case"B*":e=t}return e},er=y.close=function(){return ht("h"),this};y.stroke=function(){return ht("S"),this},y.fill=function(t){return rr("f",t),this},y.fillEvenOdd=function(t){return rr("f*",t),this},y.fillStroke=function(t){return rr("B",t),this},y.fillStrokeEvenOdd=function(t){return rr("B*",t),this};var rr=function(t,r){"object"===e(r)?ar(r,t):ht(t)},nr=function(t){null===t||S===x.ADVANCED&&void 0===t||(t=tr(t),ht(t))};function ir(t,e,r,n,i){var a=new B(e||this.boundingBox,r||this.xStep,n||this.yStep,this.gState,i||this.matrix);a.stream=this.stream;var o=t+"$$"+this.cloneIndex+++"$$";return Jt(o,a),a}var ar=function(t,e){var r=Bt[t.key],n=Ot[r];if(n instanceof O)ht("q"),ht(or(e)),n.gState&&y.setGState(n.gState),ht(t.matrix.toString()+" cm"),ht("/"+r+" sh"),ht("Q");else if(n instanceof B){var i=new Vt(1,0,0,-1,0,Rr());t.matrix&&(i=i.multiply(t.matrix||Yt),r=ir.call(n,t.key,t.boundingBox,t.xStep,t.yStep,i).id),ht("q"),ht("/Pattern cs"),ht("/"+r+" scn"),n.gState&&y.setGState(n.gState),ht(e),ht("Q")}},or=function(t){switch(t){case"f":case"F":return"W n";case"f*":return"W* n";case"B":return"W S";case"B*":return"W* S";case"S":return"W S";case"n":return"W n"}},sr=y.moveTo=function(t,e){return ht(E(U(t))+" "+E(H(e))+" m"),this},cr=y.lineTo=function(t,e){return ht(E(U(t))+" "+E(H(e))+" l"),this},ur=y.curveTo=function(t,e,r,n,i,a){return ht([E(U(t)),E(H(e)),E(U(r)),E(H(n)),E(U(i)),E(H(a)),"c"].join(" ")),this};y.__private__.line=y.line=function(t,e,r,n,i){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(n)||!Qe(i))throw new Error("Invalid arguments passed to jsPDF.line");return S===x.COMPAT?this.lines([[r-t,n-e]],t,e,[1,1],i||"S"):this.lines([[r-t,n-e]],t,e,[1,1]).stroke()},y.__private__.lines=y.lines=function(t,e,r,n,i,a){var o,s,c,u,l,h,f,d,p,g,m,v;if("number"==typeof t&&(v=r,r=e,e=t,t=v),n=n||[1,1],a=a||!1,isNaN(e)||isNaN(r)||!Array.isArray(t)||!Array.isArray(n)||!Qe(i)||"boolean"!=typeof a)throw new Error("Invalid arguments passed to jsPDF.lines");for(sr(e,r),o=n[0],s=n[1],u=t.length,g=e,m=r,c=0;c>0&255,t>>8&255,t>>16&255,t>>24&255)},k.prototype.toHexString=function(t){return t.split("").map((function(t){return("0"+(255&t.charCodeAt(0)).toString(16)).slice(-2)})).join("")},k.prototype.hexToBytes=function(t){for(var e=[],r=0;r>8&255,t>>16&255,255&e,e>>8&255)).substr(0,10);return function(t){return _(r,t)}},C.prototype.equals=function(t){var r,n="id,objectNumber,equals";if(!t||e(t)!==e(this))return!1;var i=0;for(r in this)if(!(n.indexOf(r)>=0)){if(this.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;if(this[r]!==t[r])return!1;i++}for(r in t)t.hasOwnProperty(r)&&n.indexOf(r)<0&&i--;return 0===i},M.API={events:[]},M.version="2.5.1";var E=M.API,q=1,D=function(t){return t.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},R=function(t){return t.replace(/\\\\/g,"\\").replace(/\\\(/g,"(").replace(/\\\)/g,")")},T=function(t){return t.toFixed(2)},U=function(t){return t.toFixed(5)};E.__acroform__={};var z=function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t},H=function(t){return t*q},W=function(t){var e=new ct,r=Lt.internal.getHeight(t)||0,n=Lt.internal.getWidth(t)||0;return e.BBox=[0,0,Number(T(n)),Number(T(r))],e},V=E.__acroform__.setBit=function(t,e){if(t=t||0,e=e||0,isNaN(t)||isNaN(e))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.setBit");return t|=1<0;){e="",a--;var u,l,h=tt("3",t,a).height,f=t.multiline?o-a:(o-h)/2,d=f+=2,p=0,g=0,m=0;if(a<=0){e="(...) Tj\n",e+="% Width of Text: "+tt(e,t,a=12).width+", FieldWidth:"+s+"\n";break}for(var v="",b=0,y=0;yo)continue t;v+=i[y][m],w=!0,g=y,y--}else{v=" "==(v+=i[y][m]+" ").substr(v.length-1)?v.substr(0,v.length-1):v;var N=parseInt(y),L=c(N,v,a),A=y>=i.length-1;if(L&&!A){v+=" ",m=0;continue}if(L||A){if(A)g=N;else if(t.multiline&&(h+2)*(b+2)+2>o)continue t}else{if(!t.multiline)continue t;if((h+2)*(b+2)+2>o)continue t;g=N}}for(var x="",S=p;S<=g;S++){var _=i[S];if(t.multiline){if(S===g){x+=_[m]+" ",m=(m+1)%_.length;continue}if(S===p){x+=_[_.length-1]+" ";continue}}x+=_[0]+" "}switch(x=" "==x.substr(x.length-1)?x.substr(0,x.length-1):x,l=tt(x,t,a).width,t.textAlign){case"right":u=s-l-2;break;case"center":u=(s-l)/2;break;case"left":default:u=2}e+=T(u)+" "+T(d)+" Td\n",e+="("+D(x)+") Tj\n",e+=-T(u)+" 0 Td\n",d=-(a+2),l=0,p=w?g:g+1,b++,v=""}else;break}return n.text=e,n.fontSize=a,n},tt=function(t,e,r){var n=e.scope.internal.getFont(e.fontName,e.fontStyle),i=e.scope.getStringUnitWidth(t,{font:n,fontSize:parseFloat(r),charSpace:0})*parseFloat(r);return{height:e.scope.getStringUnitWidth("3",{font:n,fontSize:parseFloat(r),charSpace:0})*parseFloat(r)*1.5,width:i}},et={fields:[],xForms:[],acroFormDictionaryRoot:null,printedOut:!1,internal:null,isInitialized:!1},rt=function(t,e){var r={type:"reference",object:t};void 0===e.internal.getPageInfo(t.page).pageContext.annotations.find((function(t){return t.type===r.type&&t.object===r.object}))&&e.internal.getPageInfo(t.page).pageContext.annotations.push(r)},nt=function(t,r){for(var n in t)if(t.hasOwnProperty(n)){var i=n,a=t[n];r.internal.newObjectDeferredBegin(a.objId,!0),"object"===e(a)&&"function"==typeof a.putStream&&a.putStream(),delete t[i]}},it=function(t,r){if(r.scope=t,void 0!==t.internal&&(void 0===t.internal.acroformPlugin||!1===t.internal.acroformPlugin.isInitialized)){if(lt.FieldNum=0,t.internal.acroformPlugin=JSON.parse(JSON.stringify(et)),t.internal.acroformPlugin.acroFormDictionaryRoot)throw new Error("Exception while creating AcroformDictionary");q=t.internal.scaleFactor,t.internal.acroformPlugin.acroFormDictionaryRoot=new ut,t.internal.acroformPlugin.acroFormDictionaryRoot.scope=t,t.internal.acroformPlugin.acroFormDictionaryRoot._eventID=t.internal.events.subscribe("postPutResources",(function(){!function(t){t.internal.events.unsubscribe(t.internal.acroformPlugin.acroFormDictionaryRoot._eventID),delete t.internal.acroformPlugin.acroFormDictionaryRoot._eventID,t.internal.acroformPlugin.printedOut=!0}(t)})),t.internal.events.subscribe("buildDocument",(function(){!function(t){t.internal.acroformPlugin.acroFormDictionaryRoot.objId=void 0;var e=t.internal.acroformPlugin.acroFormDictionaryRoot.Fields;for(var r in e)if(e.hasOwnProperty(r)){var n=e[r];n.objId=void 0,n.hasAnnotation&&rt(n,t)}}(t)})),t.internal.events.subscribe("putCatalog",(function(){!function(t){if(void 0===t.internal.acroformPlugin.acroFormDictionaryRoot)throw new Error("putCatalogCallback: Root missing.");t.internal.write("/AcroForm "+t.internal.acroformPlugin.acroFormDictionaryRoot.objId+" 0 R")}(t)})),t.internal.events.subscribe("postPutPages",(function(r){!function(t,r){var n=!t;for(var i in t||(r.internal.newObjectDeferredBegin(r.internal.acroformPlugin.acroFormDictionaryRoot.objId,!0),r.internal.acroformPlugin.acroFormDictionaryRoot.putStream()),t=t||r.internal.acroformPlugin.acroFormDictionaryRoot.Kids)if(t.hasOwnProperty(i)){var a=t[i],o=[],s=a.Rect;if(a.Rect&&(a.Rect=Z(a.Rect,r)),r.internal.newObjectDeferredBegin(a.objId,!0),a.DA=Lt.createDefaultAppearanceStream(a),"object"===e(a)&&"function"==typeof a.getKeyValueListForStream&&(o=a.getKeyValueListForStream()),a.Rect=s,a.hasAppearanceStream&&!a.appearanceStreamContent){var c=$(a);o.push({key:"AP",value:"<>"}),r.internal.acroformPlugin.xForms.push(c)}if(a.appearanceStreamContent){var u="";for(var l in a.appearanceStreamContent)if(a.appearanceStreamContent.hasOwnProperty(l)){var h=a.appearanceStreamContent[l];if(u+="/"+l+" ",u+="<<",Object.keys(h).length>=1||Array.isArray(h)){for(var i in h)if(h.hasOwnProperty(i)){var f=h[i];"function"==typeof f&&(f=f.call(r,a)),u+="/"+i+" "+f+" ",r.internal.acroformPlugin.xForms.indexOf(f)>=0||r.internal.acroformPlugin.xForms.push(f)}}else"function"==typeof(f=h)&&(f=f.call(r,a)),u+="/"+i+" "+f,r.internal.acroformPlugin.xForms.indexOf(f)>=0||r.internal.acroformPlugin.xForms.push(f);u+=">>"}o.push({key:"AP",value:"<<\n"+u+">>"})}r.internal.putStream({additionalKeyValues:o,objectId:a.objId}),r.internal.out("endobj")}n&&nt(r.internal.acroformPlugin.xForms,r)}(r,t)})),t.internal.acroformPlugin.isInitialized=!0}},at=E.__acroform__.arrayToPdfArray=function(t,r,n){var i=function(t){return t};if(Array.isArray(t)){for(var a="[",o=0;o0?e:void 0}}),Object.defineProperty(this,"Fields",{enumerable:!1,configurable:!1,get:function(){return e}}),Object.defineProperty(this,"DA",{enumerable:!1,configurable:!1,get:function(){if(t){var e=function(t){return t};return this.scope&&(e=this.scope.internal.getEncryptor(this.objId)),"("+D(e(t))+")"}},set:function(e){t=e}})};z(ut,st);var lt=function t(){st.call(this);var e=4;Object.defineProperty(this,"F",{enumerable:!1,configurable:!1,get:function(){return e},set:function(t){if(isNaN(t))throw new Error('Invalid value "'+t+'" for attribute F supplied.');e=t}}),Object.defineProperty(this,"showWhenPrinted",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(e,3))},set:function(t){!0===Boolean(t)?this.F=X(e,3):this.F=K(e,3)}});var r=0;Object.defineProperty(this,"Ff",{enumerable:!1,configurable:!1,get:function(){return r},set:function(t){if(isNaN(t))throw new Error('Invalid value "'+t+'" for attribute Ff supplied.');r=t}});var n=[];Object.defineProperty(this,"Rect",{enumerable:!1,configurable:!1,get:function(){if(0!==n.length)return n},set:function(t){n=void 0!==t?t:[]}}),Object.defineProperty(this,"x",{enumerable:!0,configurable:!0,get:function(){return!n||isNaN(n[0])?0:n[0]},set:function(t){n[0]=t}}),Object.defineProperty(this,"y",{enumerable:!0,configurable:!0,get:function(){return!n||isNaN(n[1])?0:n[1]},set:function(t){n[1]=t}}),Object.defineProperty(this,"width",{enumerable:!0,configurable:!0,get:function(){return!n||isNaN(n[2])?0:n[2]},set:function(t){n[2]=t}}),Object.defineProperty(this,"height",{enumerable:!0,configurable:!0,get:function(){return!n||isNaN(n[3])?0:n[3]},set:function(t){n[3]=t}});var i="";Object.defineProperty(this,"FT",{enumerable:!0,configurable:!1,get:function(){return i},set:function(t){switch(t){case"/Btn":case"/Tx":case"/Ch":case"/Sig":i=t;break;default:throw new Error('Invalid value "'+t+'" for attribute FT supplied.')}}});var a=null;Object.defineProperty(this,"T",{enumerable:!0,configurable:!1,get:function(){if(!a||a.length<1){if(this instanceof bt)return;a="FieldObject"+t.FieldNum++}var e=function(t){return t};return this.scope&&(e=this.scope.internal.getEncryptor(this.objId)),"("+D(e(a))+")"},set:function(t){a=t.toString()}}),Object.defineProperty(this,"fieldName",{configurable:!0,enumerable:!0,get:function(){return a},set:function(t){a=t}});var o="helvetica";Object.defineProperty(this,"fontName",{enumerable:!0,configurable:!0,get:function(){return o},set:function(t){o=t}});var s="normal";Object.defineProperty(this,"fontStyle",{enumerable:!0,configurable:!0,get:function(){return s},set:function(t){s=t}});var c=0;Object.defineProperty(this,"fontSize",{enumerable:!0,configurable:!0,get:function(){return c},set:function(t){c=t}});var u=void 0;Object.defineProperty(this,"maxFontSize",{enumerable:!0,configurable:!0,get:function(){return void 0===u?50/q:u},set:function(t){u=t}});var l="black";Object.defineProperty(this,"color",{enumerable:!0,configurable:!0,get:function(){return l},set:function(t){l=t}});var h="/F1 0 Tf 0 g";Object.defineProperty(this,"DA",{enumerable:!0,configurable:!1,get:function(){if(!(!h||this instanceof bt||this instanceof wt))return ot(h,this.objId,this.scope)},set:function(t){t=t.toString(),h=t}});var f=null;Object.defineProperty(this,"DV",{enumerable:!1,configurable:!1,get:function(){if(f)return this instanceof gt==!1?ot(f,this.objId,this.scope):f},set:function(t){t=t.toString(),f=this instanceof gt==!1?"("===t.substr(0,1)?R(t.substr(1,t.length-2)):R(t):t}}),Object.defineProperty(this,"defaultValue",{enumerable:!0,configurable:!0,get:function(){return this instanceof gt==!0?R(f.substr(1,f.length-1)):f},set:function(t){t=t.toString(),f=this instanceof gt==!0?"/"+t:t}});var d=null;Object.defineProperty(this,"_V",{enumerable:!1,configurable:!1,get:function(){if(d)return d},set:function(t){this.V=t}}),Object.defineProperty(this,"V",{enumerable:!1,configurable:!1,get:function(){if(d)return this instanceof gt==!1?ot(d,this.objId,this.scope):d},set:function(t){t=t.toString(),d=this instanceof gt==!1?"("===t.substr(0,1)?R(t.substr(1,t.length-2)):R(t):t}}),Object.defineProperty(this,"value",{enumerable:!0,configurable:!0,get:function(){return this instanceof gt==!0?R(d.substr(1,d.length-1)):d},set:function(t){t=t.toString(),d=this instanceof gt==!0?"/"+t:t}}),Object.defineProperty(this,"hasAnnotation",{enumerable:!0,configurable:!0,get:function(){return this.Rect}}),Object.defineProperty(this,"Type",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?"/Annot":null}}),Object.defineProperty(this,"Subtype",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?"/Widget":null}});var p,g=!1;Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,get:function(){return g},set:function(t){t=Boolean(t),g=t}}),Object.defineProperty(this,"page",{enumerable:!0,configurable:!0,get:function(){if(p)return p},set:function(t){p=t}}),Object.defineProperty(this,"readOnly",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,1))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,1):this.Ff=K(this.Ff,1)}}),Object.defineProperty(this,"required",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,2))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,2):this.Ff=K(this.Ff,2)}}),Object.defineProperty(this,"noExport",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,3))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,3):this.Ff=K(this.Ff,3)}});var m=null;Object.defineProperty(this,"Q",{enumerable:!0,configurable:!1,get:function(){if(null!==m)return m},set:function(t){if(-1===[0,1,2].indexOf(t))throw new Error('Invalid value "'+t+'" for attribute Q supplied.');m=t}}),Object.defineProperty(this,"textAlign",{get:function(){var t;switch(m){case 0:default:t="left";break;case 1:t="center";break;case 2:t="right"}return t},configurable:!0,enumerable:!0,set:function(t){switch(t){case"right":case 2:m=2;break;case"center":case 1:m=1;break;case"left":case 0:default:m=0}}})};z(lt,st);var ht=function(){lt.call(this),this.FT="/Ch",this.V="()",this.fontName="zapfdingbats";var t=0;Object.defineProperty(this,"TI",{enumerable:!0,configurable:!1,get:function(){return t},set:function(e){t=e}}),Object.defineProperty(this,"topIndex",{enumerable:!0,configurable:!0,get:function(){return t},set:function(e){t=e}});var e=[];Object.defineProperty(this,"Opt",{enumerable:!0,configurable:!1,get:function(){return at(e,this.objId,this.scope)},set:function(t){var r,n;n=[],"string"==typeof(r=t)&&(n=function(t,e,r){r||(r=1);for(var n,i=[];n=e.exec(t);)i.push(n[r]);return i}(r,/\((.*?)\)/g)),e=n}}),this.getOptions=function(){return e},this.setOptions=function(t){e=t,this.sort&&e.sort()},this.addOption=function(t){t=(t=t||"").toString(),e.push(t),this.sort&&e.sort()},this.removeOption=function(t,r){for(r=r||!1,t=(t=t||"").toString();-1!==e.indexOf(t)&&(e.splice(e.indexOf(t),1),!1!==r););},Object.defineProperty(this,"combo",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,18))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,18):this.Ff=K(this.Ff,18)}}),Object.defineProperty(this,"edit",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,19))},set:function(t){!0===this.combo&&(!0===Boolean(t)?this.Ff=X(this.Ff,19):this.Ff=K(this.Ff,19))}}),Object.defineProperty(this,"sort",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,20))},set:function(t){!0===Boolean(t)?(this.Ff=X(this.Ff,20),e.sort()):this.Ff=K(this.Ff,20)}}),Object.defineProperty(this,"multiSelect",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,22))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,22):this.Ff=K(this.Ff,22)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,23))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,23):this.Ff=K(this.Ff,23)}}),Object.defineProperty(this,"commitOnSelChange",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,27))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,27):this.Ff=K(this.Ff,27)}}),this.hasAppearanceStream=!1};z(ht,lt);var ft=function(){ht.call(this),this.fontName="helvetica",this.combo=!1};z(ft,ht);var dt=function(){ft.call(this),this.combo=!0};z(dt,ft);var pt=function(){dt.call(this),this.edit=!0};z(pt,dt);var gt=function(){lt.call(this),this.FT="/Btn",Object.defineProperty(this,"noToggleToOff",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,15))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,15):this.Ff=K(this.Ff,15)}}),Object.defineProperty(this,"radio",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,16))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,16):this.Ff=K(this.Ff,16)}}),Object.defineProperty(this,"pushButton",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,17))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,17):this.Ff=K(this.Ff,17)}}),Object.defineProperty(this,"radioIsUnison",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,26))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,26):this.Ff=K(this.Ff,26)}});var t,r={};Object.defineProperty(this,"MK",{enumerable:!1,configurable:!1,get:function(){var t=function(t){return t};if(this.scope&&(t=this.scope.internal.getEncryptor(this.objId)),0!==Object.keys(r).length){var e,n=[];for(e in n.push("<<"),r)n.push("/"+e+" ("+D(t(r[e]))+")");return n.push(">>"),n.join("\n")}},set:function(t){"object"===e(t)&&(r=t)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return r.CA||""},set:function(t){"string"==typeof t&&(r.CA=t)}}),Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return t},set:function(e){t=e}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return t.substr(1,t.length-1)},set:function(e){t="/"+e}})};z(gt,lt);var mt=function(){gt.call(this),this.pushButton=!0};z(mt,gt);var vt=function(){gt.call(this),this.radio=!0,this.pushButton=!1;var t=[];Object.defineProperty(this,"Kids",{enumerable:!0,configurable:!1,get:function(){return t},set:function(e){t=void 0!==e?e:[]}})};z(vt,gt);var bt=function(){var t,r;lt.call(this),Object.defineProperty(this,"Parent",{enumerable:!1,configurable:!1,get:function(){return t},set:function(e){t=e}}),Object.defineProperty(this,"optionName",{enumerable:!1,configurable:!0,get:function(){return r},set:function(t){r=t}});var n,i={};Object.defineProperty(this,"MK",{enumerable:!1,configurable:!1,get:function(){var t=function(t){return t};this.scope&&(t=this.scope.internal.getEncryptor(this.objId));var e,r=[];for(e in r.push("<<"),i)r.push("/"+e+" ("+D(t(i[e]))+")");return r.push(">>"),r.join("\n")},set:function(t){"object"===e(t)&&(i=t)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return i.CA||""},set:function(t){"string"==typeof t&&(i.CA=t)}}),Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return n},set:function(t){n=t}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return n.substr(1,n.length-1)},set:function(t){n="/"+t}}),this.caption="l",this.appearanceState="Off",this._AppearanceType=Lt.RadioButton.Circle,this.appearanceStreamContent=this._AppearanceType.createAppearanceStream(this.optionName)};z(bt,lt),vt.prototype.setAppearance=function(t){if(!("createAppearanceStream"in t)||!("getCA"in t))throw new Error("Couldn't assign Appearance to RadioButton. Appearance was Invalid!");for(var e in this.Kids)if(this.Kids.hasOwnProperty(e)){var r=this.Kids[e];r.appearanceStreamContent=t.createAppearanceStream(r.optionName),r.caption=t.getCA()}},vt.prototype.createOption=function(t){var e=new bt;return e.Parent=this,e.optionName=t,this.Kids.push(e),At.call(this.scope,e),e};var yt=function(){gt.call(this),this.fontName="zapfdingbats",this.caption="3",this.appearanceState="On",this.value="On",this.textAlign="center",this.appearanceStreamContent=Lt.CheckBox.createAppearanceStream()};z(yt,gt);var wt=function(){lt.call(this),this.FT="/Tx",Object.defineProperty(this,"multiline",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,13))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,13):this.Ff=K(this.Ff,13)}}),Object.defineProperty(this,"fileSelect",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,21))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,21):this.Ff=K(this.Ff,21)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,23))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,23):this.Ff=K(this.Ff,23)}}),Object.defineProperty(this,"doNotScroll",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,24))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,24):this.Ff=K(this.Ff,24)}}),Object.defineProperty(this,"comb",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,25))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,25):this.Ff=K(this.Ff,25)}}),Object.defineProperty(this,"richText",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,26))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,26):this.Ff=K(this.Ff,26)}});var t=null;Object.defineProperty(this,"MaxLen",{enumerable:!0,configurable:!1,get:function(){return t},set:function(e){t=e}}),Object.defineProperty(this,"maxLength",{enumerable:!0,configurable:!0,get:function(){return t},set:function(e){Number.isInteger(e)&&(t=e)}}),Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,get:function(){return this.V||this.DV}})};z(wt,lt);var Nt=function(){wt.call(this),Object.defineProperty(this,"password",{enumerable:!0,configurable:!0,get:function(){return Boolean(J(this.Ff,14))},set:function(t){!0===Boolean(t)?this.Ff=X(this.Ff,14):this.Ff=K(this.Ff,14)}}),this.password=!0};z(Nt,wt);var Lt={CheckBox:{createAppearanceStream:function(){return{N:{On:Lt.CheckBox.YesNormal},D:{On:Lt.CheckBox.YesPushDown,Off:Lt.CheckBox.OffPushDown}}},YesPushDown:function(t){var e=W(t);e.scope=t.scope;var r=[],n=t.scope.internal.getFont(t.fontName,t.fontStyle).id,i=t.scope.__private__.encodeColorString(t.color),a=Q(t,t.caption);return r.push("0.749023 g"),r.push("0 0 "+T(Lt.internal.getWidth(t))+" "+T(Lt.internal.getHeight(t))+" re"),r.push("f"),r.push("BMC"),r.push("q"),r.push("0 0 1 rg"),r.push("/"+n+" "+T(a.fontSize)+" Tf "+i),r.push("BT"),r.push(a.text),r.push("ET"),r.push("Q"),r.push("EMC"),e.stream=r.join("\n"),e},YesNormal:function(t){var e=W(t);e.scope=t.scope;var r=t.scope.internal.getFont(t.fontName,t.fontStyle).id,n=t.scope.__private__.encodeColorString(t.color),i=[],a=Lt.internal.getHeight(t),o=Lt.internal.getWidth(t),s=Q(t,t.caption);return i.push("1 g"),i.push("0 0 "+T(o)+" "+T(a)+" re"),i.push("f"),i.push("q"),i.push("0 0 1 rg"),i.push("0 0 "+T(o-1)+" "+T(a-1)+" re"),i.push("W"),i.push("n"),i.push("0 g"),i.push("BT"),i.push("/"+r+" "+T(s.fontSize)+" Tf "+n),i.push(s.text),i.push("ET"),i.push("Q"),e.stream=i.join("\n"),e},OffPushDown:function(t){var e=W(t);e.scope=t.scope;var r=[];return r.push("0.749023 g"),r.push("0 0 "+T(Lt.internal.getWidth(t))+" "+T(Lt.internal.getHeight(t))+" re"),r.push("f"),e.stream=r.join("\n"),e}},RadioButton:{Circle:{createAppearanceStream:function(t){var e={D:{Off:Lt.RadioButton.Circle.OffPushDown},N:{}};return e.N[t]=Lt.RadioButton.Circle.YesNormal,e.D[t]=Lt.RadioButton.Circle.YesPushDown,e},getCA:function(){return"l"},YesNormal:function(t){var e=W(t);e.scope=t.scope;var r=[],n=Lt.internal.getWidth(t)<=Lt.internal.getHeight(t)?Lt.internal.getWidth(t)/4:Lt.internal.getHeight(t)/4;n=Number((.9*n).toFixed(5));var i=Lt.internal.Bezier_C,a=Number((n*i).toFixed(5));return r.push("q"),r.push("1 0 0 1 "+U(Lt.internal.getWidth(t)/2)+" "+U(Lt.internal.getHeight(t)/2)+" cm"),r.push(n+" 0 m"),r.push(n+" "+a+" "+a+" "+n+" 0 "+n+" c"),r.push("-"+a+" "+n+" -"+n+" "+a+" -"+n+" 0 c"),r.push("-"+n+" -"+a+" -"+a+" -"+n+" 0 -"+n+" c"),r.push(a+" -"+n+" "+n+" -"+a+" "+n+" 0 c"),r.push("f"),r.push("Q"),e.stream=r.join("\n"),e},YesPushDown:function(t){var e=W(t);e.scope=t.scope;var r=[],n=Lt.internal.getWidth(t)<=Lt.internal.getHeight(t)?Lt.internal.getWidth(t)/4:Lt.internal.getHeight(t)/4;n=Number((.9*n).toFixed(5));var i=Number((2*n).toFixed(5)),a=Number((i*Lt.internal.Bezier_C).toFixed(5)),o=Number((n*Lt.internal.Bezier_C).toFixed(5));return r.push("0.749023 g"),r.push("q"),r.push("1 0 0 1 "+U(Lt.internal.getWidth(t)/2)+" "+U(Lt.internal.getHeight(t)/2)+" cm"),r.push(i+" 0 m"),r.push(i+" "+a+" "+a+" "+i+" 0 "+i+" c"),r.push("-"+a+" "+i+" -"+i+" "+a+" -"+i+" 0 c"),r.push("-"+i+" -"+a+" -"+a+" -"+i+" 0 -"+i+" c"),r.push(a+" -"+i+" "+i+" -"+a+" "+i+" 0 c"),r.push("f"),r.push("Q"),r.push("0 g"),r.push("q"),r.push("1 0 0 1 "+U(Lt.internal.getWidth(t)/2)+" "+U(Lt.internal.getHeight(t)/2)+" cm"),r.push(n+" 0 m"),r.push(n+" "+o+" "+o+" "+n+" 0 "+n+" c"),r.push("-"+o+" "+n+" -"+n+" "+o+" -"+n+" 0 c"),r.push("-"+n+" -"+o+" -"+o+" -"+n+" 0 -"+n+" c"),r.push(o+" -"+n+" "+n+" -"+o+" "+n+" 0 c"),r.push("f"),r.push("Q"),e.stream=r.join("\n"),e},OffPushDown:function(t){var e=W(t);e.scope=t.scope;var r=[],n=Lt.internal.getWidth(t)<=Lt.internal.getHeight(t)?Lt.internal.getWidth(t)/4:Lt.internal.getHeight(t)/4;n=Number((.9*n).toFixed(5));var i=Number((2*n).toFixed(5)),a=Number((i*Lt.internal.Bezier_C).toFixed(5));return r.push("0.749023 g"),r.push("q"),r.push("1 0 0 1 "+U(Lt.internal.getWidth(t)/2)+" "+U(Lt.internal.getHeight(t)/2)+" cm"),r.push(i+" 0 m"),r.push(i+" "+a+" "+a+" "+i+" 0 "+i+" c"),r.push("-"+a+" "+i+" -"+i+" "+a+" -"+i+" 0 c"),r.push("-"+i+" -"+a+" -"+a+" -"+i+" 0 -"+i+" c"),r.push(a+" -"+i+" "+i+" -"+a+" "+i+" 0 c"),r.push("f"),r.push("Q"),e.stream=r.join("\n"),e}},Cross:{createAppearanceStream:function(t){var e={D:{Off:Lt.RadioButton.Cross.OffPushDown},N:{}};return e.N[t]=Lt.RadioButton.Cross.YesNormal,e.D[t]=Lt.RadioButton.Cross.YesPushDown,e},getCA:function(){return"8"},YesNormal:function(t){var e=W(t);e.scope=t.scope;var r=[],n=Lt.internal.calculateCross(t);return r.push("q"),r.push("1 1 "+T(Lt.internal.getWidth(t)-2)+" "+T(Lt.internal.getHeight(t)-2)+" re"),r.push("W"),r.push("n"),r.push(T(n.x1.x)+" "+T(n.x1.y)+" m"),r.push(T(n.x2.x)+" "+T(n.x2.y)+" l"),r.push(T(n.x4.x)+" "+T(n.x4.y)+" m"),r.push(T(n.x3.x)+" "+T(n.x3.y)+" l"),r.push("s"),r.push("Q"),e.stream=r.join("\n"),e},YesPushDown:function(t){var e=W(t);e.scope=t.scope;var r=Lt.internal.calculateCross(t),n=[];return n.push("0.749023 g"),n.push("0 0 "+T(Lt.internal.getWidth(t))+" "+T(Lt.internal.getHeight(t))+" re"),n.push("f"),n.push("q"),n.push("1 1 "+T(Lt.internal.getWidth(t)-2)+" "+T(Lt.internal.getHeight(t)-2)+" re"),n.push("W"),n.push("n"),n.push(T(r.x1.x)+" "+T(r.x1.y)+" m"),n.push(T(r.x2.x)+" "+T(r.x2.y)+" l"),n.push(T(r.x4.x)+" "+T(r.x4.y)+" m"),n.push(T(r.x3.x)+" "+T(r.x3.y)+" l"),n.push("s"),n.push("Q"),e.stream=n.join("\n"),e},OffPushDown:function(t){var e=W(t);e.scope=t.scope;var r=[];return r.push("0.749023 g"),r.push("0 0 "+T(Lt.internal.getWidth(t))+" "+T(Lt.internal.getHeight(t))+" re"),r.push("f"),e.stream=r.join("\n"),e}}},createDefaultAppearanceStream:function(t){var e=t.scope.internal.getFont(t.fontName,t.fontStyle).id,r=t.scope.__private__.encodeColorString(t.color);return"/"+e+" "+t.fontSize+" Tf "+r}};Lt.internal={Bezier_C:.551915024494,calculateCross:function(t){var e=Lt.internal.getWidth(t),r=Lt.internal.getHeight(t),n=Math.min(e,r);return{x1:{x:(e-n)/2,y:(r-n)/2+n},x2:{x:(e-n)/2+n,y:(r-n)/2},x3:{x:(e-n)/2,y:(r-n)/2},x4:{x:(e-n)/2+n,y:(r-n)/2+n}}}},Lt.internal.getWidth=function(t){var r=0;return"object"===e(t)&&(r=H(t.Rect[2])),r},Lt.internal.getHeight=function(t){var r=0;return"object"===e(t)&&(r=H(t.Rect[3])),r};var At=E.addField=function(t){if(it(this,t),!(t instanceof lt))throw new Error("Invalid argument passed to jsPDF.addField.");var e;return(e=t).scope.internal.acroformPlugin.printedOut&&(e.scope.internal.acroformPlugin.printedOut=!1,e.scope.internal.acroformPlugin.acroFormDictionaryRoot=null),e.scope.internal.acroformPlugin.acroFormDictionaryRoot.Fields.push(e),t.page=t.scope.internal.getCurrentPageInfo().pageNumber,this};E.AcroFormChoiceField=ht,E.AcroFormListBox=ft,E.AcroFormComboBox=dt,E.AcroFormEditBox=pt,E.AcroFormButton=gt,E.AcroFormPushButton=mt,E.AcroFormRadioButton=vt,E.AcroFormCheckBox=yt,E.AcroFormTextField=wt,E.AcroFormPasswordField=Nt,E.AcroFormAppearance=Lt,E.AcroForm={ChoiceField:ht,ListBox:ft,ComboBox:dt,EditBox:pt,Button:gt,PushButton:mt,RadioButton:vt,CheckBox:yt,TextField:wt,PasswordField:Nt,Appearance:Lt},M.AcroForm={ChoiceField:ht,ListBox:ft,ComboBox:dt,EditBox:pt,Button:gt,PushButton:mt,RadioButton:vt,CheckBox:yt,TextField:wt,PasswordField:Nt,Appearance:Lt};var xt=M.AcroForm;function St(t){return t.reduce((function(t,e,r){return t[e]=r,t}),{})}!function(t){t.__addimage__={};var r="UNKNOWN",n={PNG:[[137,80,78,71]],TIFF:[[77,77,0,42],[73,73,42,0]],JPEG:[[255,216,255,224,void 0,void 0,74,70,73,70,0],[255,216,255,225,void 0,void 0,69,120,105,102,0,0],[255,216,255,219],[255,216,255,238]],JPEG2000:[[0,0,0,12,106,80,32,32]],GIF87a:[[71,73,70,56,55,97]],GIF89a:[[71,73,70,56,57,97]],WEBP:[[82,73,70,70,void 0,void 0,void 0,void 0,87,69,66,80]],BMP:[[66,77],[66,65],[67,73],[67,80],[73,67],[80,84]]},i=t.__addimage__.getImageFileTypeByImageData=function(t,e){var i,a,o,s,c,u=r;if("RGBA"===(e=e||r)||void 0!==t.data&&t.data instanceof Uint8ClampedArray&&"height"in t&&"width"in t)return"RGBA";if(x(t))for(c in n)for(o=n[c],i=0;i>"}),"transparency"in e&&Array.isArray(e.transparency)){for(var o="",s=0,c=e.transparency.length;s>",p.content=i;var b=p.objId+" 0 R";i="<>";else if(r.options.pageNumber){switch(i="<>",this.internal.write(i))}}this.internal.write("]")}}]),t.createAnnotation=function(t){var e=this.internal.getCurrentPageInfo();switch(t.type){case"link":this.link(t.bounds.x,t.bounds.y,t.bounds.w,t.bounds.h,t);break;case"text":case"freetext":e.pageContext.annotations.push(t)}},t.link=function(t,e,r,n,i){var a=this.internal.getCurrentPageInfo(),o=this.internal.getCoordinateString,s=this.internal.getVerticalCoordinateString;a.pageContext.annotations.push({finalBounds:{x:o(t),y:s(e),w:o(t+r),h:s(e+n)},options:i,type:"link"})},t.textWithLink=function(t,e,r,n){var i,a,o=this.getTextWidth(t),s=this.internal.getLineHeight()/this.internal.scaleFactor;if(void 0!==n.maxWidth){a=n.maxWidth;var c=this.splitTextToSize(t,a).length;i=Math.ceil(s*c)}else a=o,i=s;return this.text(t,e,r,n),r+=.2*s,"center"===n.align&&(e-=o/2),"right"===n.align&&(e-=o),this.link(e,r-s,a,i,n),o},t.getTextWidth=function(t){var e=this.internal.getFontSize();return this.getStringUnitWidth(t)*e/this.internal.scaleFactor}}(M.API), /** * @license * Copyright (c) 2017 Aras Abbasi * * Licensed under the MIT License. * http://opensource.org/licenses/mit-license */ function(t){var e={1569:[65152],1570:[65153,65154],1571:[65155,65156],1572:[65157,65158],1573:[65159,65160],1574:[65161,65162,65163,65164],1575:[65165,65166],1576:[65167,65168,65169,65170],1577:[65171,65172],1578:[65173,65174,65175,65176],1579:[65177,65178,65179,65180],1580:[65181,65182,65183,65184],1581:[65185,65186,65187,65188],1582:[65189,65190,65191,65192],1583:[65193,65194],1584:[65195,65196],1585:[65197,65198],1586:[65199,65200],1587:[65201,65202,65203,65204],1588:[65205,65206,65207,65208],1589:[65209,65210,65211,65212],1590:[65213,65214,65215,65216],1591:[65217,65218,65219,65220],1592:[65221,65222,65223,65224],1593:[65225,65226,65227,65228],1594:[65229,65230,65231,65232],1601:[65233,65234,65235,65236],1602:[65237,65238,65239,65240],1603:[65241,65242,65243,65244],1604:[65245,65246,65247,65248],1605:[65249,65250,65251,65252],1606:[65253,65254,65255,65256],1607:[65257,65258,65259,65260],1608:[65261,65262],1609:[65263,65264,64488,64489],1610:[65265,65266,65267,65268],1649:[64336,64337],1655:[64477],1657:[64358,64359,64360,64361],1658:[64350,64351,64352,64353],1659:[64338,64339,64340,64341],1662:[64342,64343,64344,64345],1663:[64354,64355,64356,64357],1664:[64346,64347,64348,64349],1667:[64374,64375,64376,64377],1668:[64370,64371,64372,64373],1670:[64378,64379,64380,64381],1671:[64382,64383,64384,64385],1672:[64392,64393],1676:[64388,64389],1677:[64386,64387],1678:[64390,64391],1681:[64396,64397],1688:[64394,64395],1700:[64362,64363,64364,64365],1702:[64366,64367,64368,64369],1705:[64398,64399,64400,64401],1709:[64467,64468,64469,64470],1711:[64402,64403,64404,64405],1713:[64410,64411,64412,64413],1715:[64406,64407,64408,64409],1722:[64414,64415],1723:[64416,64417,64418,64419],1726:[64426,64427,64428,64429],1728:[64420,64421],1729:[64422,64423,64424,64425],1733:[64480,64481],1734:[64473,64474],1735:[64471,64472],1736:[64475,64476],1737:[64482,64483],1739:[64478,64479],1740:[64508,64509,64510,64511],1744:[64484,64485,64486,64487],1746:[64430,64431],1747:[64432,64433]},r={65247:{65154:65269,65156:65271,65160:65273,65166:65275},65248:{65154:65270,65156:65272,65160:65274,65166:65276},65165:{65247:{65248:{65258:65010}}},1617:{1612:64606,1613:64607,1614:64608,1615:64609,1616:64610}},n={1612:64606,1613:64607,1614:64608,1615:64609,1616:64610},i=[1570,1571,1573,1575];t.__arabicParser__={};var a=t.__arabicParser__.isInArabicSubstitutionA=function(t){return void 0!==e[t.charCodeAt(0)]},o=t.__arabicParser__.isArabicLetter=function(t){return"string"==typeof t&&/^[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]+$/.test(t)},s=t.__arabicParser__.isArabicEndLetter=function(t){return o(t)&&a(t)&&e[t.charCodeAt(0)].length<=2},c=t.__arabicParser__.isArabicAlfLetter=function(t){return o(t)&&i.indexOf(t.charCodeAt(0))>=0};t.__arabicParser__.arabicLetterHasIsolatedForm=function(t){return o(t)&&a(t)&&e[t.charCodeAt(0)].length>=1};var u=t.__arabicParser__.arabicLetterHasFinalForm=function(t){return o(t)&&a(t)&&e[t.charCodeAt(0)].length>=2};t.__arabicParser__.arabicLetterHasInitialForm=function(t){return o(t)&&a(t)&&e[t.charCodeAt(0)].length>=3};var l=t.__arabicParser__.arabicLetterHasMedialForm=function(t){return o(t)&&a(t)&&4==e[t.charCodeAt(0)].length},h=t.__arabicParser__.resolveLigatures=function(t){var e=0,n=r,i="",a=0;for(e=0;e>"),this.internal.out("endobj")})),this.internal.events.subscribe("putCatalog",(function(){this.internal.out("/OpenAction "+e+" 0 R")}))}return this}}(M.API), /** * @license * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv * * Licensed under the MIT License. * http://opensource.org/licenses/mit-license */ function(t){var e=function(){var t=void 0;Object.defineProperty(this,"pdf",{get:function(){return t},set:function(e){t=e}});var e=150;Object.defineProperty(this,"width",{get:function(){return e},set:function(t){e=isNaN(t)||!1===Number.isInteger(t)||t<0?150:t,this.getContext("2d").pageWrapXEnabled&&(this.getContext("2d").pageWrapX=e+1)}});var r=300;Object.defineProperty(this,"height",{get:function(){return r},set:function(t){r=isNaN(t)||!1===Number.isInteger(t)||t<0?300:t,this.getContext("2d").pageWrapYEnabled&&(this.getContext("2d").pageWrapY=r+1)}});var n=[];Object.defineProperty(this,"childNodes",{get:function(){return n},set:function(t){n=t}});var i={};Object.defineProperty(this,"style",{get:function(){return i},set:function(t){i=t}}),Object.defineProperty(this,"parentNode",{})};e.prototype.getContext=function(t,e){var r;if("2d"!==(t=t||"2d"))return null;for(r in e)this.pdf.context2d.hasOwnProperty(r)&&(this.pdf.context2d[r]=e[r]);return this.pdf.context2d._canvas=this,this.pdf.context2d},e.prototype.toDataURL=function(){throw new Error("toDataURL is not implemented.")},t.events.push(["initialized",function(){this.canvas=new e,this.canvas.pdf=this}])}(M.API),function(t){var r={left:0,top:0,bottom:0,right:0},n=!1,i=function(){void 0===this.internal.__cell__&&(this.internal.__cell__={},this.internal.__cell__.padding=3,this.internal.__cell__.headerFunction=void 0,this.internal.__cell__.margins=Object.assign({},r),this.internal.__cell__.margins.width=this.getPageWidth(),a.call(this))},a=function(){this.internal.__cell__.lastCell=new o,this.internal.__cell__.pages=1},o=function(){var t=arguments[0];Object.defineProperty(this,"x",{enumerable:!0,get:function(){return t},set:function(e){t=e}});var e=arguments[1];Object.defineProperty(this,"y",{enumerable:!0,get:function(){return e},set:function(t){e=t}});var r=arguments[2];Object.defineProperty(this,"width",{enumerable:!0,get:function(){return r},set:function(t){r=t}});var n=arguments[3];Object.defineProperty(this,"height",{enumerable:!0,get:function(){return n},set:function(t){n=t}});var i=arguments[4];Object.defineProperty(this,"text",{enumerable:!0,get:function(){return i},set:function(t){i=t}});var a=arguments[5];Object.defineProperty(this,"lineNumber",{enumerable:!0,get:function(){return a},set:function(t){a=t}});var o=arguments[6];return Object.defineProperty(this,"align",{enumerable:!0,get:function(){return o},set:function(t){o=t}}),this};o.prototype.clone=function(){return new o(this.x,this.y,this.width,this.height,this.text,this.lineNumber,this.align)},o.prototype.toArray=function(){return[this.x,this.y,this.width,this.height,this.text,this.lineNumber,this.align]},t.setHeaderFunction=function(t){return i.call(this),this.internal.__cell__.headerFunction="function"==typeof t?t:void 0,this},t.getTextDimensions=function(t,e){i.call(this);var r=(e=e||{}).fontSize||this.getFontSize(),n=e.font||this.getFont(),a=e.scaleFactor||this.internal.scaleFactor,o=0,s=0,c=0,u=this;if(!Array.isArray(t)&&"string"!=typeof t){if("number"!=typeof t)throw new Error("getTextDimensions expects text-parameter to be of type String or type Number or an Array of Strings.");t=String(t)}var l=e.maxWidth;l>0?"string"==typeof t?t=this.splitTextToSize(t,l):"[object Array]"===Object.prototype.toString.call(t)&&(t=t.reduce((function(t,e){return t.concat(u.splitTextToSize(e,l))}),[])):t=Array.isArray(t)?t:[t];for(var h=0;hthis.getPageHeight()?(this.cellAddPage(),t.y=s.top,u&&c&&(this.printHeaderRow(t.lineNumber,!0),t.y+=c[0].height)):t.y=e.y+e.height||t.y),void 0!==t.text[0]&&(this.rect(t.x,t.y,t.width,t.height,!0===n?"FD":void 0),"right"===t.align?this.text(t.text,t.x+t.width-a,t.y+a,{align:"right",baseline:"top"}):"center"===t.align?this.text(t.text,t.x+t.width/2,t.y+a,{align:"center",baseline:"top",maxWidth:t.width-a-a}):this.text(t.text,t.x+a,t.y+a,{align:"left",baseline:"top",maxWidth:t.width-a-a})),this.internal.__cell__.lastCell=t,this};t.table=function(t,n,u,l,h){if(i.call(this),!u)throw new Error("No data for PDF table.");var f,d,p,g,m=[],v=[],b=[],y={},w={},N=[],L=[],A=(h=h||{}).autoSize||!1,x=!1!==h.printHeaders,S=h.css&&void 0!==h.css["font-size"]?16*h.css["font-size"]:h.fontSize||12,_=h.margins||Object.assign({width:this.getPageWidth()},r),P="number"==typeof h.padding?h.padding:3,k=h.headerBackgroundColor||"#c8c8c8",F=h.headerTextColor||"#000";if(a.call(this),this.internal.__cell__.printHeaders=x,this.internal.__cell__.margins=_,this.internal.__cell__.table_font_size=S,this.internal.__cell__.padding=P,this.internal.__cell__.headerBackgroundColor=k,this.internal.__cell__.headerTextColor=F,this.setFontSize(S),null==l)v=m=Object.keys(u[0]),b=m.map((function(){return"left"}));else if(Array.isArray(l)&&"object"===e(l[0]))for(m=l.map((function(t){return t.name})),v=l.map((function(t){return t.prompt||t.name||""})),b=l.map((function(t){return t.align||"left"})),f=0;f0&&this.setTableHeaderRow(c),this.setFont(void 0,"normal"),n=!1}}(M.API);var _t={italic:["italic","oblique","normal"],oblique:["oblique","italic","normal"],normal:["normal","oblique","italic"]},Pt=["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"],kt=St(Pt),Ft=[100,200,300,400,500,600,700,800,900],It=St(Ft);function Ct(t){var e=t.family.replace(/"|'/g,"").toLowerCase(),r=function(t){return _t[t=t||"normal"]?t:"normal"}(t.style),n=function(t){if(!t)return 400;if("number"==typeof t)return t>=100&&t<=900&&t%100==0?t:400;if(/^\d00$/.test(t))return parseInt(t);switch(t){case"bold":return 700;case"normal":default:return 400}}(t.weight),i=function(t){return"number"==typeof kt[t=t||"normal"]?t:"normal"}(t.stretch);return{family:e,style:r,weight:n,stretch:i,src:t.src||[],ref:t.ref||{name:e,style:[i,r,n].join(" ")}}}function jt(t,e,r,n){var i;for(i=r;i>=0&&i=0&&i=2?t[1]:e[0],e[2]=t.length>=3?t[2]:e[0],e[3]=t.length>=4?t[3]:e[1]),f.margin=e}});var o=!1;Object.defineProperty(this,"autoPaging",{get:function(){return o},set:function(t){o=t}});var s=0;Object.defineProperty(this,"lastBreak",{get:function(){return s},set:function(t){s=t}});var c=[];Object.defineProperty(this,"pageBreaks",{get:function(){return c},set:function(t){c=t}}),Object.defineProperty(this,"ctx",{get:function(){return f},set:function(t){t instanceof d&&(f=t)}}),Object.defineProperty(this,"path",{get:function(){return f.path},set:function(t){f.path=t}});var u=[];Object.defineProperty(this,"ctxStack",{get:function(){return u},set:function(t){u=t}}),Object.defineProperty(this,"fillStyle",{get:function(){return this.ctx.fillStyle},set:function(t){var e;e=g(t),this.ctx.fillStyle=e.style,this.ctx.isFillTransparent=0===e.a,this.ctx.fillOpacity=e.a,this.pdf.setFillColor(e.r,e.g,e.b,{a:e.a}),this.pdf.setTextColor(e.r,e.g,e.b,{a:e.a})}}),Object.defineProperty(this,"strokeStyle",{get:function(){return this.ctx.strokeStyle},set:function(t){var e=g(t);this.ctx.strokeStyle=e.style,this.ctx.isStrokeTransparent=0===e.a,this.ctx.strokeOpacity=e.a,0===e.a?this.pdf.setDrawColor(255,255,255):(e.a,this.pdf.setDrawColor(e.r,e.g,e.b))}}),Object.defineProperty(this,"lineCap",{get:function(){return this.ctx.lineCap},set:function(t){-1!==["butt","round","square"].indexOf(t)&&(this.ctx.lineCap=t,this.pdf.setLineCap(t))}}),Object.defineProperty(this,"lineWidth",{get:function(){return this.ctx.lineWidth},set:function(t){isNaN(t)||(this.ctx.lineWidth=t,this.pdf.setLineWidth(t))}}),Object.defineProperty(this,"lineJoin",{get:function(){return this.ctx.lineJoin},set:function(t){-1!==["bevel","round","miter"].indexOf(t)&&(this.ctx.lineJoin=t,this.pdf.setLineJoin(t))}}),Object.defineProperty(this,"miterLimit",{get:function(){return this.ctx.miterLimit},set:function(t){isNaN(t)||(this.ctx.miterLimit=t,this.pdf.setMiterLimit(t))}}),Object.defineProperty(this,"textBaseline",{get:function(){return this.ctx.textBaseline},set:function(t){this.ctx.textBaseline=t}}),Object.defineProperty(this,"textAlign",{get:function(){return this.ctx.textAlign},set:function(t){-1!==["right","end","center","left","start"].indexOf(t)&&(this.ctx.textAlign=t)}});var l=null;function h(t,e){if(null===l){var r=function(t){var e=[];return Object.keys(t).forEach((function(r){t[r].forEach((function(t){var n=null;switch(t){case"bold":n={family:r,weight:"bold"};break;case"italic":n={family:r,style:"italic"};break;case"bolditalic":n={family:r,weight:"bold",style:"italic"};break;case"":case"normal":n={family:r}}null!==n&&(n.ref={name:r,style:t},e.push(n))}))})),e}(t.getFontList());l=function(t){for(var e={},r=0;r=700||"bold"===r)&&(u="bold"),"italic"===r&&(u+="italic"),0===u.length&&(u="normal");for(var l="",f={arial:"Helvetica",Arial:"Helvetica",verdana:"Helvetica",Verdana:"Helvetica",helvetica:"Helvetica",Helvetica:"Helvetica","sans-serif":"Helvetica",fixed:"Courier",monospace:"Courier",terminal:"Courier",cursive:"Times",fantasy:"Times",serif:"Times"},d=0;d=2*Math.PI&&(n=0,a=2*Math.PI),this.path.push({type:"arc",x:t,y:e,radius:r,startAngle:n,endAngle:a,counterclockwise:o})},p.prototype.arcTo=function(t,e,r,n,i){throw new Error("arcTo not implemented.")},p.prototype.rect=function(t,e,r,n){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(n))throw i.error("jsPDF.context2d.rect: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.rect");this.moveTo(t,e),this.lineTo(t+r,e),this.lineTo(t+r,e+n),this.lineTo(t,e+n),this.lineTo(t,e),this.lineTo(t+r,e),this.lineTo(t,e)},p.prototype.fillRect=function(t,e,r,n){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(n))throw i.error("jsPDF.context2d.fillRect: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.fillRect");if(!m.call(this)){var a={};"butt"!==this.lineCap&&(a.lineCap=this.lineCap,this.lineCap="butt"),"miter"!==this.lineJoin&&(a.lineJoin=this.lineJoin,this.lineJoin="miter"),this.beginPath(),this.rect(t,e,r,n),this.fill(),a.hasOwnProperty("lineCap")&&(this.lineCap=a.lineCap),a.hasOwnProperty("lineJoin")&&(this.lineJoin=a.lineJoin)}},p.prototype.strokeRect=function(t,e,r,n){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(n))throw i.error("jsPDF.context2d.strokeRect: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.strokeRect");v.call(this)||(this.beginPath(),this.rect(t,e,r,n),this.stroke())},p.prototype.clearRect=function(t,e,r,n){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(n))throw i.error("jsPDF.context2d.clearRect: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.clearRect");this.ignoreClearRect||(this.fillStyle="#ffffff",this.fillRect(t,e,r,n))},p.prototype.save=function(t){t="boolean"!=typeof t||t;for(var e=this.pdf.internal.getCurrentPageInfo().pageNumber,r=0;r0||this.margin[1]>0||this.margin[2]>0||this.margin[3]>0};p.prototype.drawImage=function(t,e,r,n,i,a,o,s,c){var h=this.pdf.getImageProperties(t),f=1,d=1,p=1,g=1;void 0!==n&&void 0!==s&&(p=s/n,g=c/i,f=h.width/n*s/n,d=h.height/i*c/i),void 0===a&&(a=e,o=r,e=0,r=0),void 0!==n&&void 0===s&&(s=n,c=i),void 0===n&&void 0===s&&(s=h.width,c=h.height);for(var m,v=this.ctx.transform.decompose(),w=q(v.rotate.shx),A=new l,S=(A=(A=(A=A.multiply(v.translate)).multiply(v.skew)).multiply(v.scale)).applyToRectangle(new u(a-e*p,o-r*g,n*f,i*d)),_=y.call(this,S),P=[],k=0;k<_.length;k+=1)-1===P.indexOf(_[k])&&P.push(_[k]);if(L(P),this.autoPaging)for(var F=P[0],I=P[P.length-1],C=F;CF||Cv||S0))for(;c>=0;c--)if(!0!==i[c-1].close&&!0!==i[c-1].begin){i[c-1].deltas.push(r),i[c-1].abs.push(s);break}break;case"bct":r=[s.x1-a[o-1].x,s.y1-a[o-1].y,s.x2-a[o-1].x,s.y2-a[o-1].y,s.x-a[o-1].x,s.y-a[o-1].y],i[i.length-1].deltas.push(r);break;case"qct":var u=a[o-1].x+2/3*(s.x1-a[o-1].x),l=a[o-1].y+2/3*(s.y1-a[o-1].y),h=s.x+2/3*(s.x1-s.x),f=s.y+2/3*(s.y1-s.y),d=s.x,p=s.y;r=[u-a[o-1].x,l-a[o-1].y,h-a[o-1].x,f-a[o-1].y,d-a[o-1].x,p-a[o-1].y],i[i.length-1].deltas.push(r);break;case"arc":i.push({deltas:[],abs:[],arc:!0}),Array.isArray(i[i.length-1].abs)&&i[i.length-1].abs.push(s)}}n=e?null:"stroke"===t?"stroke":"fill";for(var g=!1,b=0;b=.01&&(f=this.pdf.internal.getFontSize(),this.pdf.setFontSize(f*t.scale),d=this.lineWidth,this.lineWidth=d*t.scale);var D="text"!==this.autoPaging;if(D||q.y+q.h<=C){if(D||q.y>=F&&q.x<=O){var R=D?t.text:this.pdf.splitTextToSize(t.text,t.maxWidth||O-q.x)[0],T=N([JSON.parse(JSON.stringify(p))],this.posX+this.margin[3],-M+F+this.ctx.prevPageLastElemOffset)[0],U=D&&(k>A||k=.01&&(this.pdf.setFontSize(f),this.lineWidth=d)}else t.scale>=.01&&(f=this.pdf.internal.getFontSize(),this.pdf.setFontSize(f*t.scale),d=this.lineWidth,this.lineWidth=d*t.scale),this.pdf.text(t.text,a.x+this.posX,a.y+this.posY,{angle:t.angle,align:e,renderingMode:t.renderingMode,maxWidth:t.maxWidth}),t.scale>=.01&&(this.pdf.setFontSize(f),this.lineWidth=d)},j=function(t,e,r,i){r=r||0,i=i||0,this.pdf.internal.out(n(t+r)+" "+a(e+i)+" l")},O=function(t,e,r){return this.pdf.lines(t,e,r,null,null)},B=function(t,e,n,i,a,c,u,l){this.pdf.internal.out([r(o(n+t)),r(s(i+e)),r(o(a+t)),r(s(c+e)),r(o(u+t)),r(s(l+e)),"c"].join(" "))},M=function(t,e,r,n){for(var i=2*Math.PI,a=Math.PI/2;e>r;)e-=i;var o=Math.abs(r-e);o1e-5;){var l=u+c*Math.min(o,a);s.push(E.call(this,t,u,l)),o-=Math.abs(l-u),u=l}return s},E=function(t,e,r){var n=(r-e)/2,i=t*Math.cos(n),a=t*Math.sin(n),o=i,s=-a,c=o*o+s*s,u=c+o*i+s*a,l=4/3*(Math.sqrt(2*c*u)-u)/(o*a-s*i),h=o-l*s,f=s+l*o,d=h,p=-f,g=n+e,m=Math.cos(g),v=Math.sin(g);return{x1:t*Math.cos(e),y1:t*Math.sin(e),x2:h*m-f*v,y2:h*v+f*m,x3:d*m-p*v,y3:d*v+p*m,x4:t*Math.cos(r),y4:t*Math.sin(r)}},q=function(t){return 180*t/Math.PI},D=function(t,e,r,n,i,a){var o=t+.5*(r-t),s=e+.5*(n-e),c=i+.5*(r-i),l=a+.5*(n-a),h=Math.min(t,i,o,c),f=Math.max(t,i,o,c),d=Math.min(e,a,s,l),p=Math.max(e,a,s,l);return new u(h,d,f-h,p-d)},R=function(t,e,r,n,i,a,o,s){var c,l,h,f,d,p,g,m,v,b,y,w,N,L,A=r-t,x=n-e,S=i-r,_=a-n,P=o-i,k=s-a;for(l=0;l<41;l++)v=(g=(h=t+(c=l/40)*A)+c*((d=r+c*S)-h))+c*(d+c*(i+c*P-d)-g),b=(m=(f=e+c*x)+c*((p=n+c*_)-f))+c*(p+c*(a+c*k-p)-m),0==l?(y=v,w=b,N=v,L=b):(y=Math.min(y,v),w=Math.min(w,b),N=Math.max(N,v),L=Math.max(L,b));return new u(Math.round(y),Math.round(w),Math.round(N-y),Math.round(L-w))},T=function(){if(this.prevLineDash||this.ctx.lineDash.length||this.ctx.lineDashOffset){var t,e,r=(t=this.ctx.lineDash,e=this.ctx.lineDashOffset,JSON.stringify({lineDash:t,lineDashOffset:e}));this.prevLineDash!==r&&(this.pdf.setLineDash(this.ctx.lineDash,this.ctx.lineDashOffset),this.prevLineDash=r)}}}(M.API);try{require("worker_threads").Worker}catch(t){}var Ut=Uint8Array,zt=Uint16Array,Ht=Uint32Array,Wt=new Ut([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,0,0,0]),Vt=new Ut([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,0,0]),Gt=new Ut([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Yt=function(t,e){for(var r=new zt(31),n=0;n<31;++n)r[n]=e+=1<>>1|(21845&ee)<<1;re=(61680&(re=(52428&re)>>>2|(13107&re)<<2))>>>4|(3855&re)<<4,te[ee]=((65280&re)>>>8|(255&re)<<8)>>>1}var ne=function(t,e,r){for(var n=t.length,i=0,a=new zt(e);i>>c]=u}else for(o=new zt(n),i=0;i>>15-t[i];return o},ie=new Ut(288);for(ee=0;ee<144;++ee)ie[ee]=8;for(ee=144;ee<256;++ee)ie[ee]=9;for(ee=256;ee<280;++ee)ie[ee]=7;for(ee=280;ee<288;++ee)ie[ee]=8;var ae=new Ut(32);for(ee=0;ee<32;++ee)ae[ee]=5;var oe=ne(ie,9,0),se=ne(ie,9,1),ce=ne(ae,5,0),ue=ne(ae,5,1),le=function(t){for(var e=t[0],r=1;re&&(e=t[r]);return e},he=function(t,e,r){var n=e/8>>0;return(t[n]|t[n+1]<<8)>>>(7&e)&r},fe=function(t,e){var r=e/8>>0;return(t[r]|t[r+1]<<8|t[r+2]<<16)>>>(7&e)},de=function(t){return(t/8>>0)+(7&t&&1)},pe=function(t,e,r){(null==e||e<0)&&(e=0),(null==r||r>t.length)&&(r=t.length);var n=new(t instanceof zt?zt:t instanceof Ht?Ht:Ut)(r-e);return n.set(t.subarray(e,r)),n},ge=function(t,e,r){r<<=7&e;var n=e/8>>0;t[n]|=r,t[n+1]|=r>>>8},me=function(t,e,r){r<<=7&e;var n=e/8>>0;t[n]|=r,t[n+1]|=r>>>8,t[n+2]|=r>>>16},ve=function(t,e){for(var r=[],n=0;nf&&(f=a[n].s);var d=new zt(f+1),p=be(r[l-1],d,0);if(p>e){n=0;var g=0,m=p-e,v=1<e))break;g+=v-(1<>>=m;g>0;){var y=a[n].s;d[y]=0&&g;--n){var w=a[n].s;d[w]==e&&(--d[w],++g)}p=e}return[new Ut(d),p]},be=function(t,e,r){return-1==t.s?Math.max(be(t.l,e,r+1),be(t.r,e,r+1)):e[t.s]=r},ye=function(t){for(var e=t.length;e&&!t[--e];);for(var r=new zt(++e),n=0,i=t[0],a=1,o=function(t){r[n++]=t},s=1;s<=e;++s)if(t[s]==i&&s!=e)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=t[s]}return[r.subarray(0,n),e]},we=function(t,e){for(var r=0,n=0;n>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var a=0;a4&&!_[Gt[k-1]];--k);var F,I,C,j,O=u+5<<3,B=we(i,ie)+we(a,ae)+o,M=we(i,f)+we(a,g)+o+14+3*k+we(A,_)+(2*A[16]+3*A[17]+7*A[18]);if(O<=B&&O<=M)return Ne(e,l,t.subarray(c,c+u));if(ge(e,l,1+(M15&&(ge(e,l,R[x]>>>5&127),l+=R[x]>>>12)}}}else F=oe,I=ie,C=ce,j=ae;for(x=0;x255){T=n[x]>>>18&31;me(e,l,F[T+257]),l+=I[T+257],T>7&&(ge(e,l,n[x]>>>23&31),l+=Wt[T]);var U=31&n[x];me(e,l,C[U]),l+=j[U],U>3&&(me(e,l,n[x]>>>5&8191),l+=Vt[U])}else me(e,l,F[n[x]]),l+=I[n[x]];return me(e,l,F[256]),l+I[256]},Ae=new Ht([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),xe=new Ut(0),Se=function(t,e,r,n,i){return function(t,e,r,n,i,a){var o=t.length,s=new Ut(n+o+5*(1+Math.floor(o/7e3))+i),c=s.subarray(n,s.length-i),u=0;if(!e||o<8)for(var l=0;l<=o;l+=65535){var h=l+65535;h>>13,p=8191&f,g=(1<7e3||_>24576)&&j>423){u=Le(t,c,0,N,L,A,S,_,k,l-k,u),_=x=S=0,k=l;for(var O=0;O<286;++O)L[O]=0;for(O=0;O<30;++O)A[O]=0}var B=2,M=0,E=p,q=I-C&32767;if(j>2&&F==w(l-q))for(var D=Math.min(d,j)-1,R=Math.min(32767,l),T=Math.min(258,j);q<=R&&--E&&I!=C;){if(t[l+B]==t[l+B-q]){for(var U=0;UB){if(B=U,M=q,U>D)break;var z=Math.min(q,U-2),H=0;for(O=0;OH&&(H=V,C=W)}}}q+=(I=C)-(C=m[I])+32768&32767}if(M){N[_++]=268435456|Kt[B]<<18|Qt[M];var G=31&Kt[B],Y=31&Qt[M];S+=Wt[G]+Vt[Y],++L[257+G],++A[Y],P=l+B,++x}else N[_++]=t[l],++L[t[l]]}}u=Le(t,c,a,N,L,A,S,_,k,l-k,u),a||(u=Ne(c,u,xe))}return pe(s,0,n+de(u)+i)}(t,null==e.level?6:e.level,null==e.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+e.mem,r,n,!i)};function _e(t,e){void 0===e&&(e={});var r=function(){var t=1,e=0;return{p:function(r){for(var n=t,i=e,a=r.length,o=0;o!=a;){for(var s=Math.min(o+5552,a);o>>8<<16|(255&e)<<8|e>>>8)+2*((255&t)<<23)}}}();r.p(t);var n=Se(t,e,2,4);return function(t,e){var r=e.level,n=0==r?0:r<6?1:9==r?3:2;t[0]=120,t[1]=n<<6|(n?32-2*n:1)}(n,e),function(t,e,r){for(;r;++e)t[e]=r,r>>>=8}(n,n.length-4,r.d()),n}function Pe(t,e){return function(t,e,r){var n=t.length,i=!e||r,a=!r||r.i;r||(r={}),e||(e=new Ut(3*n));var o=function(t){var r=e.length;if(t>r){var n=new Ut(Math.max(2*r,t));n.set(e),e=n}},s=r.f||0,c=r.p||0,u=r.b||0,l=r.l,h=r.d,f=r.m,d=r.n,p=8*n;do{if(!l){r.f=s=he(t,c,1);var g=he(t,c+1,3);if(c+=3,!g){var m=t[(P=de(c)+4)-4]|t[P-3]<<8,v=P+m;if(v>n){if(a)throw"unexpected EOF";break}i&&o(u+m),e.set(t.subarray(P,v),u),r.b=u+=m,r.p=c=8*v;continue}if(1==g)l=se,h=ue,f=9,d=5;else{if(2!=g)throw"invalid block type";var b=he(t,c,31)+257,y=he(t,c+10,15)+4,w=b+he(t,c+5,31)+1;c+=14;for(var N=new Ut(w),L=new Ut(19),A=0;Ap)break;var _=ne(L,x,1);for(A=0;A>>4)<16)N[A++]=P;else{var F=0,I=0;for(16==P?(I=3+he(t,c,3),c+=2,F=N[A-1]):17==P?(I=3+he(t,c,7),c+=3):18==P&&(I=11+he(t,c,127),c+=7);I--;)N[A++]=F}}var C=N.subarray(0,b),j=N.subarray(b);f=le(C),d=le(j),l=ne(C,f,1),h=ne(j,d,1)}if(c>p)throw"unexpected EOF"}i&&o(u+131072);for(var O=(1<>>4;if((c+=15&F)>p)throw"unexpected EOF";if(!F)throw"invalid length/literal";if(E<256)e[u++]=E;else{if(256==E){l=null;break}var q=E-254;if(E>264){var D=Wt[A=E-257];q=he(t,c,(1<>>4;if(!R)throw"invalid distance";c+=15&R;j=$t[T];if(T>3){D=Vt[T];j+=fe(t,c)&(1<p)throw"unexpected EOF";i&&o(u+131072);for(var U=u+q;u>>4>7||(t[0]<<8|t[1])%31)throw"invalid zlib data";if(32&t[1])throw"invalid zlib data: preset dictionaries not supported"}(t),t.subarray(2,-4)),e)} /** * @license * jsPDF filters PlugIn * Copyright (c) 2014 Aras Abbasi * * Licensed under the MIT License. * http://opensource.org/licenses/mit-license */!function(t){var e=function(t){var e,r,n,i,a,o,s,c,u,l;for(/[^\x00-\xFF]/.test(t),r=[],n=0,i=(t+=e="\0\0\0\0".slice(t.length%4||4)).length;i>n;n+=4)0!==(a=(t.charCodeAt(n)<<24)+(t.charCodeAt(n+1)<<16)+(t.charCodeAt(n+2)<<8)+t.charCodeAt(n+3))?(o=(a=((a=((a=((a=(a-(l=a%85))/85)-(u=a%85))/85)-(c=a%85))/85)-(s=a%85))/85)%85,r.push(o+33,s+33,c+33,u+33,l+33)):r.push(122);return function(t,e){for(var r=e;r>0;r--)t.pop()}(r,e.length),String.fromCharCode.apply(String,r)+"~>"},r=function(t){var e,r,n,i,a,o=String,s="length",c=255,u="charCodeAt",l="slice",h="replace";for(t[l](-2),t=t[l](0,-2)[h](/\s/g,"")[h]("z","!!!!!"),n=[],i=0,a=(t+=e="uuuuu"[l](t[s]%5||5))[s];a>i;i+=5)r=52200625*(t[u](i)-33)+614125*(t[u](i+1)-33)+7225*(t[u](i+2)-33)+85*(t[u](i+3)-33)+(t[u](i+4)-33),n.push(c&r>>24,c&r>>16,c&r>>8,c&r);return function(t,e){for(var r=e;r>0;r--)t.pop()}(n,e[s]),o.fromCharCode.apply(o,n)},n=function(t){var e=new RegExp(/^([0-9A-Fa-f]{2})+$/);if(-1!==(t=t.replace(/\s/g,"")).indexOf(">")&&(t=t.substr(0,t.indexOf(">"))),t.length%2&&(t+="0"),!1===e.test(t))return"";for(var r="",n=0;n",c.push("/ASCIIHexDecode");break;case"FlateEncode":case"/FlateEncode":s=i(s),c.push("/FlateDecode");break;default:throw new Error('The filter: "'+a[o]+'" is not implemented')}return{data:s,reverseChain:c.reverse().join(" ")}}}(M.API), /** * @license * jsPDF fileloading PlugIn * Copyright (c) 2018 Aras Abbasi (aras.abbasi@gmail.com) * * Licensed under the MIT License. * http://opensource.org/licenses/mit-license */ function(t){t.loadFile=function(t,e,r){return function(t,e,r){e=!1!==e,r="function"==typeof r?r:function(){};var n=void 0;try{n=function(t,e,r){var n=new XMLHttpRequest,i=0,a=function(t){var e=t.length,r=[],n=String.fromCharCode;for(i=0;iu&&(c=l,l=u,u=c);else{if("l"!==t&&"landscape"!==t)throw"Invalid orientation: "+t;t="l",u>l&&(c=l,l=u,u=c)}return{width:l,height:u,unit:r,k:a,orientation:t}},n.html=function(t,e){(e=e||{}).callback=e.callback||function(){},e.html2canvas=e.html2canvas||{},e.html2canvas.canvas=e.html2canvas.canvas||this.canvas,e.jsPDF=e.jsPDF||this,e.fontFaces=e.fontFaces?e.fontFaces.map(Ct):null;var r=new c(e);return e.worker?r:r.from(t).doCallback()}}(M.API), /** * @license * ==================================================================== * Copyright (c) 2013 Youssef Beddad, youssef.beddad@gmail.com * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ==================================================================== */ function(t){var e,r,n;t.addJS=function(t){return n=t,this.internal.events.subscribe("postPutResources",(function(){e=this.internal.newObject(),this.internal.out("<<"),this.internal.out("/Names [(EmbeddedJS) "+(e+1)+" 0 R]"),this.internal.out(">>"),this.internal.out("endobj"),r=this.internal.newObject(),this.internal.out("<<"),this.internal.out("/S /JavaScript"),this.internal.out("/JS ("+n+")"),this.internal.out(">>"),this.internal.out("endobj")})),this.internal.events.subscribe("putCatalog",(function(){void 0!==e&&void 0!==r&&this.internal.out("/Names <>")})),this}}(M.API), /** * @license * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv * * Licensed under the MIT License. * http://opensource.org/licenses/mit-license */ function(t){var e;t.events.push(["postPutResources",function(){var t=this,r=/^(\d+) 0 obj$/;if(this.outline.root.children.length>0)for(var n=t.outline.render().split(/\r\n/),i=0;i> endobj")}var f=t.internal.newObject();t.internal.write("<< /Names [ ");for(i=0;i>","endobj"),e=t.internal.newObject(),t.internal.write("<< /Dests "+f+" 0 R"),t.internal.write(">>","endobj")}}]),t.events.push(["putCatalog",function(){this.outline.root.children.length>0&&(this.internal.write("/Outlines",this.outline.makeRef(this.outline.root)),this.outline.createNamedDestinations&&this.internal.write("/Names "+e+" 0 R"))}]),t.events.push(["initialized",function(){var t=this;t.outline={createNamedDestinations:!1,root:{children:[]}},t.outline.add=function(t,e,r){var n={title:e,options:r,children:[]};return null==t&&(t=this.root),t.children.push(n),n},t.outline.render=function(){return this.ctx={},this.ctx.val="",this.ctx.pdf=t,this.genIds_r(this.root),this.renderRoot(this.root),this.renderItems(this.root),this.ctx.val},t.outline.genIds_r=function(e){e.id=t.internal.newObjectDeferred();for(var r=0;r0&&(this.line("/First "+this.makeRef(t.children[0])),this.line("/Last "+this.makeRef(t.children[t.children.length-1]))),this.line("/Count "+this.count_r({count:0},t)),this.objEnd()},t.outline.renderItems=function(e){for(var r=this.ctx.pdf.internal.getVerticalCoordinateString,n=0;n0&&this.line("/Prev "+this.makeRef(e.children[n-1])),n0&&(this.line("/First "+this.makeRef(i.children[0])),this.line("/Last "+this.makeRef(i.children[i.children.length-1])));var a=this.count=this.count_r({count:0},i);if(a>0&&this.line("/Count "+a),i.options&&i.options.pageNumber){var o=t.internal.getPageInfo(i.options.pageNumber);this.line("/Dest ["+o.objId+" 0 R /XYZ 0 "+r(0)+" 0]")}this.objEnd()}for(var s=0;s> \r\nendobj\r\n"},t.outline.count_r=function(t,e){for(var r=0;re;0<=e?++f:--f)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(n=this.palette.length/3,this.transparency.indexed=this.read(e),this.transparency.indexed.length>n)throw new Error("More transparent colors than palette size");if((l=n-this.transparency.indexed.length)>0)for(d=0;0<=l?dl;0<=l?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":s=(h=this.read(e)).indexOf(0),c=String.fromCharCode.apply(String,h.slice(0,s)),this.text[c]=String.fromCharCode.apply(String,h.slice(s+1));break;case"IEND":return o&&this.animation.frames.push(o),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(p=this.colorType)||6===p,r=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*r,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}i.prototype.read=function(t){var e,r;for(r=[],e=0;0<=t?et;0<=t?++e:--e)r.push(this.data[this.pos++]);return r},i.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},i.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},i.prototype.decodePixels=function(t){var e=this.pixelBitlength/8,r=new Uint8Array(this.width*this.height*e),n=0,i=this;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);function a(a,o,s,c){var u,l,h,f,d,p,g,m,v,b,y,w,N,L,A,x,S,_,P,k,F,I=Math.ceil((i.width-a)/s),C=Math.ceil((i.height-o)/c),j=i.width==I&&i.height==C;for(L=e*I,w=j?r:new Uint8Array(L*C),p=t.length,N=0,l=0;N1&&r/i, 2013. * * https://github.com/deanm/omggif * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. * * omggif is a JavaScript implementation of a GIF 89a encoder and decoder, * including animation and compression. It does not rely on any specific * underlying system, so should run in the browser, Node, or Plask. */ function Be(t){var e=0;if(71!==t[e++]||73!==t[e++]||70!==t[e++]||56!==t[e++]||56!=(t[e++]+1&253)||97!==t[e++])throw new Error("Invalid GIF 87a/89a header.");var r=t[e++]|t[e++]<<8,n=t[e++]|t[e++]<<8,i=t[e++],a=i>>7,o=1<<(7&i)+1;t[e++];t[e++];var s=null,c=null;a&&(s=e,c=o,e+=3*o);var u=!0,l=[],h=0,f=null,d=0,p=null;for(this.width=r,this.height=n;u&&e=0))throw Error("Invalid block size");if(0===P)break;e+=P}break;case 249:if(4!==t[e++]||0!==t[e+4])throw new Error("Invalid graphics extension block.");var g=t[e++];h=t[e++]|t[e++]<<8,f=t[e++],0==(1&g)&&(f=null),d=g>>2&7,e++;break;case 254:for(;;){if(!((P=t[e++])>=0))throw Error("Invalid block size");if(0===P)break;e+=P}break;default:throw new Error("Unknown graphic control label: 0x"+t[e-1].toString(16))}break;case 44:var m=t[e++]|t[e++]<<8,v=t[e++]|t[e++]<<8,b=t[e++]|t[e++]<<8,y=t[e++]|t[e++]<<8,w=t[e++],N=w>>6&1,L=1<<(7&w)+1,A=s,x=c,S=!1;if(w>>7){S=!0;A=e,x=L,e+=3*L}var _=e;for(e++;;){var P;if(!((P=t[e++])>=0))throw Error("Invalid block size");if(0===P)break;e+=P}l.push({x:m,y:v,width:b,height:y,has_local_palette:S,palette_offset:A,palette_size:x,data_offset:_,data_length:e-_,transparent_index:f,interlaced:!!N,delay:h,disposal:d});break;case 59:u=!1;break;default:throw new Error("Unknown gif block: 0x"+t[e-1].toString(16))}this.numFrames=function(){return l.length},this.loopCount=function(){return p},this.frameInfo=function(t){if(t<0||t>=l.length)throw new Error("Frame index out of range.");return l[t]},this.decodeAndBlitFrameBGRA=function(e,n){var i=this.frameInfo(e),a=i.width*i.height,o=new Uint8Array(a);Me(t,i.data_offset,o,a);var s=i.palette_offset,c=i.transparent_index;null===c&&(c=256);var u=i.width,l=r-u,h=u,f=4*(i.y*r+i.x),d=4*((i.y+i.height)*r+i.x),p=f,g=4*l;!0===i.interlaced&&(g+=4*r*7);for(var m=8,v=0,b=o.length;v=d&&(g=4*l+4*r*(m-1),p=f+(u+l)*(m<<1),m>>=1)),y===c)p+=4;else{var w=t[s+3*y],N=t[s+3*y+1],L=t[s+3*y+2];n[p++]=L,n[p++]=N,n[p++]=w,n[p++]=255}--h}},this.decodeAndBlitFrameRGBA=function(e,n){var i=this.frameInfo(e),a=i.width*i.height,o=new Uint8Array(a);Me(t,i.data_offset,o,a);var s=i.palette_offset,c=i.transparent_index;null===c&&(c=256);var u=i.width,l=r-u,h=u,f=4*(i.y*r+i.x),d=4*((i.y+i.height)*r+i.x),p=f,g=4*l;!0===i.interlaced&&(g+=4*r*7);for(var m=8,v=0,b=o.length;v=d&&(g=4*l+4*r*(m-1),p=f+(u+l)*(m<<1),m>>=1)),y===c)p+=4;else{var w=t[s+3*y],N=t[s+3*y+1],L=t[s+3*y+2];n[p++]=w,n[p++]=N,n[p++]=L,n[p++]=255}--h}}}function Me(t,e,r,n){for(var a=t[e++],o=1<>=u,h-=u,v!==o){if(v===s)break;for(var b=vo;)w=g[w]>>8,++y;var N=w;if(d+y+(b!==v?1:0)>n)return void i.log("Warning, gif stream longer than expected.");r[d++]=N;var L=d+=y;for(b!==v&&(r[d++]=N),w=b;y--;)w=g[w],r[--L]=255&w,w>>=8;null!==m&&c<4096&&(g[c++]=m<<8|N,c>=l+1&&u<12&&(++u,l=l<<1|1)),m=v}else c=s+1,l=(1<<(u=a+1))-1,m=null}return d!==n&&i.log("Warning, gif stream shorter than expected."),r} /** * @license Copyright (c) 2008, Adobe Systems Incorporated All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Adobe Systems Incorporated nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */function Ee(t){var e,r,n,i,a,o=Math.floor,s=new Array(64),c=new Array(64),u=new Array(64),l=new Array(64),h=new Array(65535),f=new Array(65535),d=new Array(64),p=new Array(64),g=[],m=0,v=7,b=new Array(64),y=new Array(64),w=new Array(64),N=new Array(256),L=new Array(2048),A=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],x=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],S=[0,1,2,3,4,5,6,7,8,9,10,11],_=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],P=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],k=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],F=[0,1,2,3,4,5,6,7,8,9,10,11],I=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],C=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function j(t,e){for(var r=0,n=0,i=new Array,a=1;a<=16;a++){for(var o=1;o<=t[a];o++)i[e[n]]=[],i[e[n]][0]=r,i[e[n]][1]=a,n++,r++;r*=2}return i}function O(t){for(var e=t[0],r=t[1]-1;r>=0;)e&1<>8&255),B(255&t)}function E(t,e,r,n,i){for(var a,o=i[0],s=i[240],c=function(t,e){var r,n,i,a,o,s,c,u,l,h,f=0;for(l=0;l<8;++l){r=t[f],n=t[f+1],i=t[f+2],a=t[f+3],o=t[f+4],s=t[f+5],c=t[f+6];var p=r+(u=t[f+7]),g=r-u,m=n+c,v=n-c,b=i+s,y=i-s,w=a+o,N=a-o,L=p+w,A=p-w,x=m+b,S=m-b;t[f]=L+x,t[f+4]=L-x;var _=.707106781*(S+A);t[f+2]=A+_,t[f+6]=A-_;var P=.382683433*((L=N+y)-(S=v+g)),k=.5411961*L+P,F=1.306562965*S+P,I=.707106781*(x=y+v),C=g+I,j=g-I;t[f+5]=j+k,t[f+3]=j-k,t[f+1]=C+F,t[f+7]=C-F,f+=8}for(f=0,l=0;l<8;++l){r=t[f],n=t[f+8],i=t[f+16],a=t[f+24],o=t[f+32],s=t[f+40],c=t[f+48];var O=r+(u=t[f+56]),B=r-u,M=n+c,E=n-c,q=i+s,D=i-s,R=a+o,T=a-o,U=O+R,z=O-R,H=M+q,W=M-q;t[f]=U+H,t[f+32]=U-H;var V=.707106781*(W+z);t[f+16]=z+V,t[f+48]=z-V;var G=.382683433*((U=T+D)-(W=E+B)),Y=.5411961*U+G,J=1.306562965*W+G,X=.707106781*(H=D+E),K=B+X,Z=B-X;t[f+40]=Z+Y,t[f+24]=Z-Y,t[f+8]=K+J,t[f+56]=K-J,f++}for(l=0;l<64;++l)h=t[l]*e[l],d[l]=h>0?h+.5|0:h-.5|0;return d}(t,e),u=0;u<64;++u)p[A[u]]=c[u];var l=p[0]-r;r=p[0],0==l?O(n[0]):(O(n[f[a=32767+l]]),O(h[a]));for(var g=63;g>0&&0==p[g];)g--;if(0==g)return O(o),r;for(var m,v=1;v<=g;){for(var b=v;0==p[v]&&v<=g;)++v;var y=v-b;if(y>=16){m=y>>4;for(var w=1;w<=m;++w)O(s);y&=15}a=32767+p[v],O(i[(y<<4)+f[a]]),O(h[a]),v++}return 63!=g&&O(o),r}function q(t){(t=Math.min(Math.max(t,1),100),a!=t)&&(!function(t){for(var e=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],r=0;r<64;r++){var n=o((e[r]*t+50)/100);n=Math.min(Math.max(n,1),255),s[A[r]]=n}for(var i=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],a=0;a<64;a++){var h=o((i[a]*t+50)/100);h=Math.min(Math.max(h,1),255),c[A[a]]=h}for(var f=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],d=0,p=0;p<8;p++)for(var g=0;g<8;g++)u[d]=1/(s[A[d]]*f[p]*f[g]*8),l[d]=1/(c[A[d]]*f[p]*f[g]*8),d++}(t<50?Math.floor(5e3/t):Math.floor(200-2*t)),a=t)}this.encode=function(t,a){a&&q(a),g=new Array,m=0,v=7,M(65496),M(65504),M(16),B(74),B(70),B(73),B(70),B(0),B(1),B(1),B(0),M(1),M(1),B(0),B(0),function(){M(65499),M(132),B(0);for(var t=0;t<64;t++)B(s[t]);B(1);for(var e=0;e<64;e++)B(c[e])}(),function(t,e){M(65472),M(17),B(8),M(e),M(t),B(3),B(1),B(17),B(0),B(2),B(17),B(1),B(3),B(17),B(1)}(t.width,t.height),function(){M(65476),M(418),B(0);for(var t=0;t<16;t++)B(x[t+1]);for(var e=0;e<=11;e++)B(S[e]);B(16);for(var r=0;r<16;r++)B(_[r+1]);for(var n=0;n<=161;n++)B(P[n]);B(1);for(var i=0;i<16;i++)B(k[i+1]);for(var a=0;a<=11;a++)B(F[a]);B(17);for(var o=0;o<16;o++)B(I[o+1]);for(var s=0;s<=161;s++)B(C[s])}(),M(65498),M(12),B(3),B(1),B(0),B(2),B(17),B(3),B(17),B(0),B(63),B(0);var o=0,h=0,f=0;m=0,v=7,this.encode.displayName="_encode_";for(var d,p,N,A,j,D,R,T,U,z=t.data,H=t.width,W=t.height,V=4*H,G=0;G>3)*V+(R=4*(7&U)),G+T>=W&&(D-=V*(G+1+T-W)),d+R>=V&&(D-=d+R-V+4),p=z[D++],N=z[D++],A=z[D++],b[U]=(L[p]+L[N+256>>0]+L[A+512>>0]>>16)-128,y[U]=(L[p+768>>0]+L[N+1024>>0]+L[A+1280>>0]>>16)-128,w[U]=(L[p+1280>>0]+L[N+1536>>0]+L[A+1792>>0]>>16)-128;o=E(b,u,o,e,n),h=E(y,l,h,r,i),f=E(w,l,f,r,i),d+=32}G+=8}if(v>=0){var Y=[];Y[1]=v+1,Y[0]=(1<>0]=38470*t,L[t+512>>0]=7471*t+32768,L[t+768>>0]=-11059*t,L[t+1024>>0]=-21709*t,L[t+1280>>0]=32768*t+8421375,L[t+1536>>0]=-27439*t,L[t+1792>>0]=-5329*t}(),q(t)} /** * @license * Copyright (c) 2017 Aras Abbasi * * Licensed under the MIT License. * http://opensource.org/licenses/mit-license */function qe(t,e){if(this.pos=0,this.buffer=t,this.datav=new DataView(t.buffer),this.is_with_alpha=!!e,this.bottom_up=!0,this.flag=String.fromCharCode(this.buffer[0])+String.fromCharCode(this.buffer[1]),this.pos+=2,-1===["BM","BA","CI","CP","IC","PT"].indexOf(this.flag))throw new Error("Invalid BMP File");this.parseHeader(),this.parseBGR()}function De(t){function e(t){if(!t)throw Error("assert :P")}function r(t,e,r){for(var n=0;4>n;n++)if(t[e+n]!=r.charCodeAt(n))return!0;return!1}function n(t,e,r,n,i){for(var a=0;an+1?[]:new e),!(i.length>>0;t&r;)r>>>=1;return r?(t&r-1)+r:t}function u(t,r,n,i,a){e(!(i%n));do{t[r+(i-=n)]=a}while(0=o),512>=o)var s=a(512);else if(null==(s=a(o)))return 0;return function(t,r,n,i,o,s){var l,f,d=r,p=1<l;++l){if(g[l]>1<(L-=g[l]))return 0;for(;0=l;++l,o<<=1){if(N+=L<<=1,0>(L-=g[l]))return 0;for(;0b&&!(0>=(v-=g[b]));)++b,v<<=1;p+=A=1<<(v=b-n),t[r+(b=w&y)].g=v+n,t[r+b].value=d-r-b}i.g=l-n,i.value=s[f++],u(t,d+(w>>n),o,A,i),w=c(w,l)}}return N!=2*m[15]-1?0:p}(t,r,n,i,o,s)}function h(){this.value=this.g=0}function f(){this.value=this.g=0}function d(){this.G=o(5,h),this.H=a(5),this.jc=this.Qb=this.qb=this.nd=0,this.pd=o(Dr,f)}function p(t,r,n,i){e(null!=t),e(null!=r),e(2147483648>i),t.Ca=254,t.I=0,t.b=-8,t.Ka=0,t.oa=r,t.pa=n,t.Jd=r,t.Yc=n+i,t.Zc=4<=i?n+i-4+1:n,_(t)}function g(t,e){for(var r=0;0i),t.Sb=i,t.Ra=0,t.u=0,t.h=0,4>>=8,t.Ra+=t.oa[t.pa+t.bb]<>>0,++t.bb,t.u-=8;A(t)&&(t.h=1,t.u=0)}function y(t,r){if(e(0<=r),!t.h&&r<=Tr){var n=L(t)&Rr[r];return t.u+=r,b(t),n}return t.h=1,t.u=0}function w(){this.b=this.Ca=this.I=0,this.oa=[],this.pa=0,this.Jd=[],this.Yc=0,this.Zc=[],this.Ka=0}function N(){this.Ra=0,this.oa=[],this.h=this.u=this.bb=this.Sb=this.pa=0}function L(t){return t.Ra>>>(t.u&Ur-1)>>>0}function A(t){return e(t.bb<=t.Sb),t.h||t.bb==t.Sb&&t.u>Ur}function x(t,e){t.u=e,t.h=A(t)}function S(t){t.u>=zr&&(e(t.u>=zr),b(t))}function _(t){e(null!=t&&null!=t.oa),t.pa>>0,t.b+=8):(e(null!=t&&null!=t.oa),t.pat.b&&_(t);var n=t.b,i=r*e>>>8,a=(t.I>>>n>i)+0;for(a?(r-=i,t.I-=i+1<>>0):r=i+1,n=r,i=0;256<=n;)i+=8,n>>=8;return n=7^i+Hr[n],t.b-=n,t.Ca=(r<>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=r>>0&255}function I(t,e){return t[e+0]<<0|t[e+1]<<8}function C(t,e){return I(t,e)|t[e+2]<<16}function j(t,e){return I(t,e)|I(t,e+2)<<16}function O(t,r){var n=1<=a||0>=o?0:(n[0]=a,i[0]=o,1)}function q(t,e){return t+(1<>>e}function D(t,e){return((4278255360&t)+(4278255360&e)>>>0&4278255360)+((16711935&t)+(16711935&e)>>>0&16711935)>>>0}function R(e,r){t[r]=function(r,n,i,a,o,s,c){var u;for(u=0;u>>1)+(t&e)>>>0}function z(t){return 0<=t&&256>t?t:0>t?0:255>1))}function W(t,e,r){return Math.abs(e-r)-Math.abs(t-r)}function V(t,e,r,n,i,a,o){for(n=a[o-1],r=0;r>8&255,c=16711935&(c=(c=16711935&o)+((s<<16)+s));n[i+a]=(4278255360&o)+c>>>0}}function Y(t,e){e.jd=t>>0&255,e.hd=t>>8&255,e.ud=t>>16&255}function J(t,e,r,n,i,a){var o;for(o=0;o>>8,u=s,l=255&(l=(l=s>>>16)+((t.jd<<24>>24)*(c<<24>>24)>>>5));u=255&(u=(u=u+((t.hd<<24>>24)*(c<<24>>24)>>>5))+((t.ud<<24>>24)*(l<<24>>24)>>>5));i[a+o]=(4278255360&s)+(l<<16)+u}}function X(e,r,n,i,a){t[r]=function(t,e,r,n,o,s,c,u,l){for(n=c;n>e.b,f=e.Ea,d=e.K[0],p=e.w;if(8>h)for(e=(1<>=h}else t["VP8LMapColor"+n](s,c,d,p,u,l,r,o,f)}}function K(t,e,r,n,i){for(r=e+r;e>16&255,n[i++]=a>>8&255,n[i++]=a>>0&255}}function Z(t,e,r,n,i){for(r=e+r;e>16&255,n[i++]=a>>8&255,n[i++]=a>>0&255,n[i++]=a>>24&255}}function $(t,e,r,n,i){for(r=e+r;e>16&240|o>>12&15,o=o>>0&240|o>>28&15;n[i++]=a,n[i++]=o}}function Q(t,e,r,n,i){for(r=e+r;e>16&248|o>>13&7,o=o>>5&224|o>>3&31;n[i++]=a,n[i++]=o}}function tt(t,e,r,n,i){for(r=e+r;e>0&255,n[i++]=a>>8&255,n[i++]=a>>16&255}}function et(t,e,r,i,a,o){if(0==o)for(r=e+r;e>24|o[1]>>8&65280|o[2]<<8&16711680|o[3]<<24)>>>0),a+=32;else n(i,a,t,e,r)}function rt(e,r){t[r][0]=t[e+"0"],t[r][1]=t[e+"1"],t[r][2]=t[e+"2"],t[r][3]=t[e+"3"],t[r][4]=t[e+"4"],t[r][5]=t[e+"5"],t[r][6]=t[e+"6"],t[r][7]=t[e+"7"],t[r][8]=t[e+"8"],t[r][9]=t[e+"9"],t[r][10]=t[e+"10"],t[r][11]=t[e+"11"],t[r][12]=t[e+"12"],t[r][13]=t[e+"13"],t[r][14]=t[e+"0"],t[r][15]=t[e+"0"]}function nt(t){return t==Hn||t==Wn||t==Vn||t==Gn}function it(){this.eb=[],this.size=this.A=this.fb=0}function at(){this.y=[],this.f=[],this.ea=[],this.F=[],this.Tc=this.Ed=this.Cd=this.Fd=this.lb=this.Db=this.Ab=this.fa=this.J=this.W=this.N=this.O=0}function ot(){this.Rd=this.height=this.width=this.S=0,this.f={},this.f.RGBA=new it,this.f.kb=new at,this.sd=null}function st(){this.width=[0],this.height=[0],this.Pd=[0],this.Qd=[0],this.format=[0]}function ct(){this.Id=this.fd=this.Md=this.hb=this.ib=this.da=this.bd=this.cd=this.j=this.v=this.Da=this.Sd=this.ob=0}function ut(t){return alert("todo:WebPSamplerProcessPlane"),t.T}function lt(t,e){var r=t.T,i=e.ba.f.RGBA,a=i.eb,o=i.fb+t.ka*i.A,s=vi[e.ba.S],c=t.y,u=t.O,l=t.f,h=t.N,f=t.ea,d=t.W,p=e.cc,g=e.dc,m=e.Mc,v=e.Nc,b=t.ka,y=t.ka+t.T,w=t.U,N=w+1>>1;for(0==b?s(c,u,null,null,l,h,f,d,l,h,f,d,a,o,null,null,w):(s(e.ec,e.fc,c,u,p,g,m,v,l,h,f,d,a,o-i.A,a,o,w),++r);b+2r,i=r==qn||r==Rn||r==Tn||r==Un||12==r||nt(r);if(e.memory=null,e.Ib=null,e.Jb=null,e.Nd=null,!Mr(e.Oa,t,i?11:12))return 0;if(i&&nt(r)&&br(),t.da)alert("todo:use_scaling");else{if(n){if(e.Ib=ut,t.Kb){if(r=t.U+1>>1,e.memory=a(t.U+2*r),null==e.memory)return 0;e.ec=e.memory,e.fc=0,e.cc=e.ec,e.dc=e.fc+t.U,e.Mc=e.cc,e.Nc=e.dc+r,e.Ib=lt,br()}}else alert("todo:EmitYUV");i&&(e.Jb=ht,n&&mr())}if(n&&!Ci){for(t=0;256>t;++t)ji[t]=89858*(t-128)+_i>>Si,Mi[t]=-22014*(t-128)+_i,Bi[t]=-45773*(t-128),Oi[t]=113618*(t-128)+_i>>Si;for(t=Pi;t>Si,Ei[t-Pi]=Vt(e,255),qi[t-Pi]=Vt(e+8>>4,15);Ci=1}return 1}function dt(t){var r=t.ma,n=t.U,i=t.T;return e(!(1&t.ka)),0>=n||0>=i?0:(n=r.Ib(t,r),null!=r.Jb&&r.Jb(t,r,n),r.Dc+=n,1)}function pt(t){t.ma.memory=null}function gt(t,e,r,n){return 47!=y(t,8)?0:(e[0]=y(t,14)+1,r[0]=y(t,14)+1,n[0]=y(t,1),0!=y(t,3)?0:!t.h)}function mt(t,e){if(4>t)return t+1;var r=t-2>>1;return(2+(1&t)<>4)*t+(8-(15&r)))?r:1;var r}function bt(t,e,r){var n=L(r),i=t[e+=255&n].g-8;return 0>>0,e(8>=n.g),t.g}function wt(t,r,n){var i=t.xc;return e((r=0==i?0:t.vc[t.md*(n>>i)+(r>>i)])>_.b)*x;vN&&(I=N),(0,Zr[P[k++]>>8&15])(p,g+ +F,y,w+F-N,I-F,y,w+F),F=I}g+=N,w+=N,++v&A||(_+=x)}d!=h.nc&&n(l,u-m,l,u+(d-f-1)*m,m);break;case 1:for(m=p,b=g,N=(p=h.Ea)-(w=p&~(y=(g=1<>h.b)*v;f=a),0o.o&&(i=o.o),n=i?n=0:(a[0]+=4*o.v,o.ka=n-o.j,o.U=o.va-o.v,o.T=i-n,n=1),n){if(c=c[0],11>(n=t.ca).S){var h=n.f.RGBA,f=(i=n.S,a=o.U,o=o.T,l=h.eb,h.A),d=o;for(h=h.fb+t.Ma*h.A;0i){var a=t.l.width,o=n.ca,s=n.tb+a*i,c=t.V,u=t.Ba+t.c*i,l=t.gc;e(1==t.ab),e(3==l[0].hc),Xr(l[0],i,r,c,u,o,s),xt(n,i,r,o,s,a)}t.C=t.Ma=r}function _t(t,r,n,i,a,o,s){var c=t.$/i,u=t.$%i,l=t.m,h=t.s,f=n+t.$,d=f;a=n+i*a;var p=n+i*o,g=280+h.ua,m=t.Pb?c:16777216,v=0=m){var _=f-n;e((m=t).Pb),m.wd=m.m,m.xd=_,0k.g?(x(N,N.u+k.g),_[P]=k.value,N=0):(x(N,N.u+k.g-256),e(256<=k.value),N=k.value),0==N&&(w=!0)}else N=bt(y.G[0],y.H[0],l);if(l.h)break;if(w||256>N){if(!w)if(y.nd)r[f]=(y.qb|N<<8)>>>0;else{if(S(l),w=bt(y.G[1],y.H[1],l),S(l),_=bt(y.G[2],y.H[2],l),P=bt(y.G[3],y.H[3],l),l.h)break;r[f]=(P<<24|w<<16|N<<8|_)>>>0}if(w=!1,++f,++u>=i&&(u=0,++c,null!=s&&c<=o&&!(c%16)&&s(t,c),null!=v))for(;d>>v.Mb]=N}else if(280>N){if(N=mt(N-256,l),_=bt(y.G[4],y.H[4],l),S(l),_=vt(i,_=mt(_,l)),l.h)break;if(f-n<_||a-f=i;)u-=i,++c,null!=s&&c<=o&&!(c%16)&&s(t,c);if(e(f<=a),u&b&&(y=wt(h,u,c)),null!=v)for(;d>>v.Mb]=N}else{if(!(N>>v.Mb]=N;N=f,e(!(w>>>(_=v).Xa)),r[N]=_.X[w],w=!0}w||e(l.h==A(l))}if(t.Pb&&l.h&&fo?o:c),t.a=0,t.$=f-n}return 1}return t.a=3,0}function Pt(t){e(null!=t),t.vc=null,t.yc=null,t.Ya=null;var r=t.Wa;null!=r&&(r.X=null),t.vb=null,e(null!=t)}function kt(){var e=new or;return null==e?null:(e.a=0,e.xb=gi,rt("Predictor","VP8LPredictors"),rt("Predictor","VP8LPredictors_C"),rt("PredictorAdd","VP8LPredictorsAdd"),rt("PredictorAdd","VP8LPredictorsAdd_C"),Gr=G,$r=J,Qr=K,tn=Z,en=$,rn=Q,nn=tt,t.VP8LMapColor32b=Jr,t.VP8LMapColor8b=Kr,e)}function Ft(t,r,n,s,c){var u=1,f=[t],p=[r],g=s.m,m=s.s,v=null,b=0;t:for(;;){if(n)for(;u&&y(g,1);){var w=f,N=p,A=s,_=1,P=A.m,k=A.gc[A.ab],F=y(P,2);if(A.Oc&1<=A.ab),F){case 0:case 1:k.b=y(P,3)+2,_=Ft(q(k.Ea,k.b),q(k.nc,k.b),0,A,k.K),k.K=k.K[0];break;case 3:var I,C=y(P,8)+1,j=16>E.b),T=a(R);if(null==T)I=0;else{var U=E.K[0],z=E.w;for(T[0]=E.K[0][0],B=1;B<1*M;++B)T[B]=D(U[z+B],T[B-1]);for(;B<4*R;++B)T[B]=0;E.K[0]=null,E.K[0]=T,I=1}}_=I;break;case 2:break;default:e(0)}u=_}}if(f=f[0],p=p[0],u&&y(g,1)&&!(u=1<=(b=y(g,4))&&11>=b)){s.a=3;break t}var H;if(H=u)e:{var W,V,G,Y=s,J=f,X=p,K=b,Z=n,$=Y.m,Q=Y.s,tt=[null],et=1,rt=0,nt=Qn[K];r:for(;;){if(Z&&y($,1)){var it=y($,3)+2,at=q(J,it),ot=q(X,it),st=at*ot;if(!Ft(at,ot,0,Y,tt))break r;for(tt=tt[0],Q.xc=it,W=0;W>8&65535;tt[W]=ct,ct>=et&&(et=ct+1)}}if($.h)break r;for(V=0;5>V;++V){var ut=Xn[V];!V&&0=ht),dt=ft;var pt=a(rt);if(null==dt||null==pt||null==lt){Y.a=1;break r}var gt=lt;for(W=G=0;WV;++V){ut=Xn[V],vt[V]=gt,bt[V]=G,!V&&0Gt)break i}else zt=Gt;for(Ht=0;Htte)Yt[Ht++]=te,0!=te&&(Kt=te);else{var ee=16==te,re=te-16,ne=Jn[re],ie=y(Xt,Yn[re])+ne;if(Ht+ie>Gt)break i;for(var ae=ee?Kt:0;0=V){var oe,se=pt[0];for(oe=1;oese&&(se=pt[oe]);Lt+=se}}if(mt.nd=Nt,mt.Qb=0,Nt&&(mt.qb=(vt[3][bt[3]+0].value<<24|vt[1][bt[1]+0].value<<16|vt[2][bt[2]+0].value)>>>0,0==wt&&256>vt[0][bt[0]+0].value&&(mt.Qb=1,mt.qb+=vt[0][bt[0]+0].value<<8)),mt.jc=!mt.Qb&&6>Lt,mt.jc){var ce,ue=mt;for(ce=0;ce>=yt(fe,8,he),le>>=yt(ue.G[1][ue.H[1]+le],16,he),le>>=yt(ue.G[2][ue.H[2]+le],0,he),yt(ue.G[3][ue.H[3]+le],24,he))}}}Q.vc=tt,Q.Wb=et,Q.Ya=dt,Q.yc=lt,H=1;break e}H=0}if(!(u=H)){s.a=3;break t}if(0r+1?[]:0),!(n.lengtht?0:t>e?e:t}function Gt(){this.T=this.U=this.ka=this.height=this.width=0,this.y=[],this.f=[],this.ea=[],this.Rc=this.fa=this.W=this.N=this.O=0,this.ma="void",this.put="VP8IoPutHook",this.ac="VP8IoSetupHook",this.bc="VP8IoTeardownHook",this.ha=this.Kb=0,this.data=[],this.hb=this.ib=this.da=this.o=this.j=this.va=this.v=this.Da=this.ob=this.w=0,this.F=[],this.J=0}function Yt(){var t=new Wt;return null!=t&&(t.a=0,t.sc="OK",t.cb=0,t.Xb=0,ni||(ni=Zt)),t}function Jt(t,e,r){return 0==t.a&&(t.a=e,t.sc=r,t.cb=0),0}function Xt(t,e,r){return 3<=r&&157==t[e+0]&&1==t[e+1]&&42==t[e+2]}function Kt(t,r){if(null==t)return 0;if(t.a=0,t.sc="OK",null==r)return Jt(t,2,"null VP8Io passed to VP8GetHeaders()");var n=r.data,a=r.w,o=r.ha;if(4>o)return Jt(t,7,"Truncated header.");var s=n[a+0]|n[a+1]<<8|n[a+2]<<16,c=t.Od;if(c.Rb=!(1&s),c.td=s>>1&7,c.yd=s>>4&1,c.ub=s>>5,3o)return Jt(t,7,"cannot parse picture header");if(!Xt(n,a,o))return Jt(t,3,"Bad code word");u.c=16383&(n[a+4]<<8|n[a+3]),u.Td=n[a+4]>>6,u.i=16383&(n[a+6]<<8|n[a+5]),u.Ud=n[a+6]>>6,a+=7,o-=7,t.za=u.c+15>>4,t.Ub=u.i+15>>4,r.width=u.c,r.height=u.i,r.Da=0,r.j=0,r.v=0,r.va=r.width,r.o=r.height,r.da=0,r.ib=r.width,r.hb=r.height,r.U=r.width,r.T=r.height,i((s=t.Pa).jb,0,255,s.jb.length),e(null!=(s=t.Qa)),s.Cb=0,s.Bb=0,s.Fb=1,i(s.Zb,0,0,s.Zb.length),i(s.Lb,0,0,s.Lb)}if(c.ub>o)return Jt(t,7,"bad partition length");p(s=t.m,n,a,c.ub),a+=c.ub,o-=c.ub,c.Rb&&(u.Ld=P(s),u.Kd=P(s)),u=t.Qa;var l,h=t.Pa;if(e(null!=s),e(null!=u),u.Cb=P(s),u.Cb){if(u.Bb=P(s),P(s)){for(u.Fb=P(s),l=0;4>l;++l)u.Zb[l]=P(s)?m(s,7):0;for(l=0;4>l;++l)u.Lb[l]=P(s)?m(s,6):0}if(u.Bb)for(l=0;3>l;++l)h.jb[l]=P(s)?g(s,8):255}else u.Bb=0;if(s.Ka)return Jt(t,3,"cannot parse segment header");if((u=t.ed).zd=P(s),u.Tb=g(s,6),u.wb=g(s,3),u.Pc=P(s),u.Pc&&P(s)){for(h=0;4>h;++h)P(s)&&(u.vd[h]=m(s,6));for(h=0;4>h;++h)P(s)&&(u.od[h]=m(s,6))}if(t.L=0==u.Tb?0:u.zd?1:2,s.Ka)return Jt(t,3,"cannot parse filter header");var f=o;if(o=l=a,a=l+f,u=f,t.Xb=(1<u&&(d=u),p(t.Jc[+f],n,l,d),l+=d,u-=d,o+=3}p(t.Jc[+h],n,l,u),n=ld;++d){if(f.Cb){var v=f.Zb[d];f.Fb||(v+=n)}else{if(0>16,8>b.Eb[1]&&(b.Eb[1]=8),b.Qc[0]=ei[Vt(v+h,117)],b.Qc[1]=ri[Vt(v+l,127)],b.lc=v+l}if(!c.Rb)return Jt(t,4,"Not a key frame.");for(P(s),c=t.Pa,n=0;4>n;++n){for(o=0;8>o;++o)for(a=0;3>a;++a)for(u=0;11>u;++u)h=k(s,ui[n][o][a][u])?g(s,8):si[n][o][a][u],c.Wc[n][o].Yb[a][u]=h;for(o=0;17>o;++o)c.Xc[n][o]=c.Wc[n][li[o]]}return t.kc=P(s),t.kc&&(t.Bd=g(s,8)),t.cb=1}function Zt(t,e,r,n,i,a,o){var s=e[i].Yb[r];for(r=0;16>i;++i){if(!k(t,s[r+0]))return i;for(;!k(t,s[r+1]);)if(s=e[++i].Yb[0],r=0,16==i)return 16;var c=e[i+1].Yb;if(k(t,s[r+2])){var u=t,l=0;if(k(u,(f=s)[(h=r)+3]))if(k(u,f[h+6])){for(s=0,h=2*(l=k(u,f[h+8]))+(f=k(u,f[h+9+l])),l=0,f=ii[h];f[s];++s)l+=l+k(u,f[s]);l+=3+(8<(u=t).b&&_(u);var h,f=u.b,d=(h=u.Ca>>1)-(u.I>>f)>>31;--u.b,u.Ca+=d,u.Ca|=1,u.I-=(h+1&d)<>4,t.zb=r.j-s>>4,0>t.yb&&(t.yb=0),0>t.zb&&(t.zb=0)),t.Va=r.o+15+s>>4,t.Hb=r.va+15+s>>4,t.Hb>t.za&&(t.Hb=t.za),t.Va>t.Ub&&(t.Va=t.Ub),0s;++s){var u;if(t.Qa.Cb){var l=t.Qa.Lb[s];t.Qa.Fb||(l+=c.Tb)}else l=c.Tb;for(u=0;1>=u;++u){var h=t.gd[s][u],f=l;if(c.Pc&&(f+=c.vd[0],u&&(f+=c.od[0])),0<(f=0>f?0:63>2:d>>1)>9-c.wb&&(d=9-c.wb)),1>d&&(d=1),h.dd=d,h.tc=2*f+d,h.ld=40<=f?2:15<=f?1:0}else h.tc=0;h.La=u}}}s=0}else Jt(t,6,"Frame setup failed"),s=t.a;if(s=0==s){if(s){t.$c=0,0t.Vb){if(t.Vb=0,t.Ec=a(h),t.Fc=0,null==t.Ec){s=Jt(t,1,"no memory during frame initialization.");break t}t.Vb=h}h=t.Ec,f=t.Fc,t.Ac=h,t.Bc=f,f+=c,t.Gd=o(p,Ht),t.Hd=0,t.rb=o(g+1,Rt),t.sb=1,t.wa=m?o(m,Dt):null,t.Y=0,t.D.Nb=0,t.D.wa=t.wa,t.D.Y=t.Y,0=s;++s)Pn[255+s]=0>s?-s:s;for(s=-1020;1020>=s;++s)kn[1020+s]=-128>s?-128:127=s;++s)Fn[112+s]=-16>s?-16:15=s;++s)In[255+s]=0>s?0:255h;++h){var b,y=p[0+h];for(b=0;4>b;++b){y=ci[f[d+b]][y];for(var w=oi[k(l,y[0])];0>3;for(w=0;256>w;w+=16)h[m+w]=_}A=1,x=d[0]}var P=15&l.la,F=15&v.la;for(w=0;4>w;++w){var I=1&F;for(_=L=0;4>_;++_)P=P>>1|(I=(S=ni(f,x,S=I+(1&P),g.Sc,A,h,m))>A)<<7,L=L<<2|(3>=4,F=F>>1|I<<7,b=(b<<8|L)>>>0}for(x=P,A=F>>4,N=0;4>N;N+=2){for(L=0,P=l.la>>4+N,F=v.la>>4+N,w=0;2>w;++w){for(I=1&F,_=0;2>_;++_)S=I+(1&P),P=P>>1|(I=0<(S=ni(f,d[2],S,g.Qc,0,h,m)))<<3,L=L<<2|(3>=2,F=F>>1|I<<5}y|=L<<4*N,x|=P<<4<=s.zb&&s.M<=s.Va,0==s.Aa)t:{if(o.M=s.M,o.uc=l,Or(s,o),u=1,o=(L=s.D).Nb,l=(y=Ri[s.L])*s.R,f=y/2*s.B,w=16*o*s.R,_=8*o*s.B,d=s.sa,p=s.ta-l+w,g=s.qa,h=s.ra-f+_,m=s.Ha,v=s.Ia-f+_,F=0==(P=L.M),b=P>=s.Va-1,2==s.Aa&&Or(s,L),L.uc)for(I=(S=s).D.M,e(S.D.uc),L=S.yb;Lc.o&&(P=c.o),c.F=null,c.J=null,null!=s.Fa&&0>1),c.W+=s.B*(y>>1),null!=c.F&&(c.J+=c.width*y)),L>1,c.W+=c.v>>1,null!=c.F&&(c.J+=c.v),c.ka=L-c.j,c.U=c.va-c.v,c.T=P-L,u=c.put(c))}o+1!=s.Ic||b||(n(s.sa,s.ta-l,d,p+16*s.R,l),n(s.qa,s.ra-f,g,h+8*s.B,f),n(s.Ha,s.Ia-f,m,v+8*s.B,f))}if(!u)return Jt(t,6,"Output aborted.")}return 1}(t,r)),null!=r.bc&&r.bc(r),s&=1}return s?(t.cb=0,s):0}function te(t,e,r,n,i){i=t[e+r+32*n]+(i>>3),t[e+r+32*n]=-256&i?0>i?0:255:i}function ee(t,e,r,n,i,a){te(t,e,0,r,n+i),te(t,e,1,r,n+a),te(t,e,2,r,n-a),te(t,e,3,r,n-i)}function re(t){return(20091*t>>16)+t}function ne(t,e,r,n){var i,o=0,s=a(16);for(i=0;4>i;++i){var c=t[e+0]+t[e+8],u=t[e+0]-t[e+8],l=(35468*t[e+4]>>16)-re(t[e+12]),h=re(t[e+4])+(35468*t[e+12]>>16);s[o+0]=c+h,s[o+1]=u+l,s[o+2]=u-l,s[o+3]=c-h,o+=4,e++}for(i=o=0;4>i;++i)c=(t=s[o+0]+4)+s[o+8],u=t-s[o+8],l=(35468*s[o+4]>>16)-re(s[o+12]),te(r,n,0,0,c+(h=re(s[o+4])+(35468*s[o+12]>>16))),te(r,n,1,0,u+l),te(r,n,2,0,u-l),te(r,n,3,0,c-h),o++,n+=32}function ie(t,e,r,n){var i=t[e+0]+4,a=35468*t[e+4]>>16,o=re(t[e+4]),s=35468*t[e+1]>>16;ee(r,n,0,i+o,t=re(t[e+1]),s),ee(r,n,1,i+a,t,s),ee(r,n,2,i-a,t,s),ee(r,n,3,i-o,t,s)}function ae(t,e,r,n,i){ne(t,e,r,n),i&&ne(t,e+16,r,n+4)}function oe(t,e,r,n){on(t,e+0,r,n,1),on(t,e+32,r,n+128,1)}function se(t,e,r,n){var i;for(t=t[e+0]+4,i=0;4>i;++i)for(e=0;4>e;++e)te(r,n,e,i,t)}function ce(t,e,r,n){t[e+0]&&un(t,e+0,r,n),t[e+16]&&un(t,e+16,r,n+4),t[e+32]&&un(t,e+32,r,n+128),t[e+48]&&un(t,e+48,r,n+128+4)}function ue(t,e,r,n){var i,o=a(16);for(i=0;4>i;++i){var s=t[e+0+i]+t[e+12+i],c=t[e+4+i]+t[e+8+i],u=t[e+4+i]-t[e+8+i],l=t[e+0+i]-t[e+12+i];o[0+i]=s+c,o[8+i]=s-c,o[4+i]=l+u,o[12+i]=l-u}for(i=0;4>i;++i)s=(t=o[0+4*i]+3)+o[3+4*i],c=o[1+4*i]+o[2+4*i],u=o[1+4*i]-o[2+4*i],l=t-o[3+4*i],r[n+0]=s+c>>3,r[n+16]=l+u>>3,r[n+32]=s-c>>3,r[n+48]=l-u>>3,n+=64}function le(t,e,r){var n,i=e-32,a=Bn,o=255-t[i-1];for(n=0;nr;++r)n(t,e+32*r,t,e-32,16)}function ge(t,e){var r;for(r=16;0n;++n)i(e,r+32*n,t,16)}function ve(t,e){var r,n=16;for(r=0;16>r;++r)n+=t[e-1+32*r]+t[e+r-32];me(n>>5,t,e)}function be(t,e){var r,n=8;for(r=0;16>r;++r)n+=t[e-1+32*r];me(n>>4,t,e)}function ye(t,e){var r,n=8;for(r=0;16>r;++r)n+=t[e+r-32];me(n>>4,t,e)}function we(t,e){me(128,t,e)}function Ne(t,e,r){return t+2*e+r+2>>2}function Le(t,e){var r,i=e-32;i=new Uint8Array([Ne(t[i-1],t[i+0],t[i+1]),Ne(t[i+0],t[i+1],t[i+2]),Ne(t[i+1],t[i+2],t[i+3]),Ne(t[i+2],t[i+3],t[i+4])]);for(r=0;4>r;++r)n(t,e+32*r,i,0,i.length)}function Ae(t,e){var r=t[e-1],n=t[e-1+32],i=t[e-1+64],a=t[e-1+96];F(t,e+0,16843009*Ne(t[e-1-32],r,n)),F(t,e+32,16843009*Ne(r,n,i)),F(t,e+64,16843009*Ne(n,i,a)),F(t,e+96,16843009*Ne(i,a,a))}function xe(t,e){var r,n=4;for(r=0;4>r;++r)n+=t[e+r-32]+t[e-1+32*r];for(n>>=3,r=0;4>r;++r)i(t,e+32*r,n,4)}function Se(t,e){var r=t[e-1+0],n=t[e-1+32],i=t[e-1+64],a=t[e-1-32],o=t[e+0-32],s=t[e+1-32],c=t[e+2-32],u=t[e+3-32];t[e+0+96]=Ne(n,i,t[e-1+96]),t[e+1+96]=t[e+0+64]=Ne(r,n,i),t[e+2+96]=t[e+1+64]=t[e+0+32]=Ne(a,r,n),t[e+3+96]=t[e+2+64]=t[e+1+32]=t[e+0+0]=Ne(o,a,r),t[e+3+64]=t[e+2+32]=t[e+1+0]=Ne(s,o,a),t[e+3+32]=t[e+2+0]=Ne(c,s,o),t[e+3+0]=Ne(u,c,s)}function _e(t,e){var r=t[e+1-32],n=t[e+2-32],i=t[e+3-32],a=t[e+4-32],o=t[e+5-32],s=t[e+6-32],c=t[e+7-32];t[e+0+0]=Ne(t[e+0-32],r,n),t[e+1+0]=t[e+0+32]=Ne(r,n,i),t[e+2+0]=t[e+1+32]=t[e+0+64]=Ne(n,i,a),t[e+3+0]=t[e+2+32]=t[e+1+64]=t[e+0+96]=Ne(i,a,o),t[e+3+32]=t[e+2+64]=t[e+1+96]=Ne(a,o,s),t[e+3+64]=t[e+2+96]=Ne(o,s,c),t[e+3+96]=Ne(s,c,c)}function Pe(t,e){var r=t[e-1+0],n=t[e-1+32],i=t[e-1+64],a=t[e-1-32],o=t[e+0-32],s=t[e+1-32],c=t[e+2-32],u=t[e+3-32];t[e+0+0]=t[e+1+64]=a+o+1>>1,t[e+1+0]=t[e+2+64]=o+s+1>>1,t[e+2+0]=t[e+3+64]=s+c+1>>1,t[e+3+0]=c+u+1>>1,t[e+0+96]=Ne(i,n,r),t[e+0+64]=Ne(n,r,a),t[e+0+32]=t[e+1+96]=Ne(r,a,o),t[e+1+32]=t[e+2+96]=Ne(a,o,s),t[e+2+32]=t[e+3+96]=Ne(o,s,c),t[e+3+32]=Ne(s,c,u)}function ke(t,e){var r=t[e+0-32],n=t[e+1-32],i=t[e+2-32],a=t[e+3-32],o=t[e+4-32],s=t[e+5-32],c=t[e+6-32],u=t[e+7-32];t[e+0+0]=r+n+1>>1,t[e+1+0]=t[e+0+64]=n+i+1>>1,t[e+2+0]=t[e+1+64]=i+a+1>>1,t[e+3+0]=t[e+2+64]=a+o+1>>1,t[e+0+32]=Ne(r,n,i),t[e+1+32]=t[e+0+96]=Ne(n,i,a),t[e+2+32]=t[e+1+96]=Ne(i,a,o),t[e+3+32]=t[e+2+96]=Ne(a,o,s),t[e+3+64]=Ne(o,s,c),t[e+3+96]=Ne(s,c,u)}function Fe(t,e){var r=t[e-1+0],n=t[e-1+32],i=t[e-1+64],a=t[e-1+96];t[e+0+0]=r+n+1>>1,t[e+2+0]=t[e+0+32]=n+i+1>>1,t[e+2+32]=t[e+0+64]=i+a+1>>1,t[e+1+0]=Ne(r,n,i),t[e+3+0]=t[e+1+32]=Ne(n,i,a),t[e+3+32]=t[e+1+64]=Ne(i,a,a),t[e+3+64]=t[e+2+64]=t[e+0+96]=t[e+1+96]=t[e+2+96]=t[e+3+96]=a}function Ie(t,e){var r=t[e-1+0],n=t[e-1+32],i=t[e-1+64],a=t[e-1+96],o=t[e-1-32],s=t[e+0-32],c=t[e+1-32],u=t[e+2-32];t[e+0+0]=t[e+2+32]=r+o+1>>1,t[e+0+32]=t[e+2+64]=n+r+1>>1,t[e+0+64]=t[e+2+96]=i+n+1>>1,t[e+0+96]=a+i+1>>1,t[e+3+0]=Ne(s,c,u),t[e+2+0]=Ne(o,s,c),t[e+1+0]=t[e+3+32]=Ne(r,o,s),t[e+1+32]=t[e+3+64]=Ne(n,r,o),t[e+1+64]=t[e+3+96]=Ne(i,n,r),t[e+1+96]=Ne(a,i,n)}function Ce(t,e){var r;for(r=0;8>r;++r)n(t,e+32*r,t,e-32,8)}function je(t,e){var r;for(r=0;8>r;++r)i(t,e,t[e-1],8),e+=32}function Oe(t,e,r){var n;for(n=0;8>n;++n)i(e,r+32*n,t,8)}function Be(t,e){var r,n=8;for(r=0;8>r;++r)n+=t[e+r-32]+t[e-1+32*r];Oe(n>>4,t,e)}function Me(t,e){var r,n=4;for(r=0;8>r;++r)n+=t[e+r-32];Oe(n>>3,t,e)}function Ee(t,e){var r,n=4;for(r=0;8>r;++r)n+=t[e-1+32*r];Oe(n>>3,t,e)}function qe(t,e){Oe(128,t,e)}function De(t,e,r){var n=t[e-r],i=t[e+0],a=3*(i-n)+jn[1020+t[e-2*r]-t[e+r]],o=On[112+(a+4>>3)];t[e-r]=Bn[255+n+On[112+(a+3>>3)]],t[e+0]=Bn[255+i-o]}function Re(t,e,r,n){var i=t[e+0],a=t[e+r];return Mn[255+t[e-2*r]-t[e-r]]>n||Mn[255+a-i]>n}function Te(t,e,r,n){return 4*Mn[255+t[e-r]-t[e+0]]+Mn[255+t[e-2*r]-t[e+r]]<=n}function Ue(t,e,r,n,i){var a=t[e-3*r],o=t[e-2*r],s=t[e-r],c=t[e+0],u=t[e+r],l=t[e+2*r],h=t[e+3*r];return 4*Mn[255+s-c]+Mn[255+o-u]>n?0:Mn[255+t[e-4*r]-a]<=i&&Mn[255+a-o]<=i&&Mn[255+o-s]<=i&&Mn[255+h-l]<=i&&Mn[255+l-u]<=i&&Mn[255+u-c]<=i}function ze(t,e,r,n){var i=2*n+1;for(n=0;16>n;++n)Te(t,e+n,r,i)&&De(t,e+n,r)}function He(t,e,r,n){var i=2*n+1;for(n=0;16>n;++n)Te(t,e+n*r,1,i)&&De(t,e+n*r,1)}function We(t,e,r,n){var i;for(i=3;0>7,v=18*b+63>>7,b=9*b+63>>7;c[u-3*l]=Bn[255+c[u-3*l]+b],c[u-2*l]=Bn[255+h+v],c[u-l]=Bn[255+f+m],c[u+0]=Bn[255+d-m],c[u+l]=Bn[255+p-v],c[u+2*l]=Bn[255+g-b]}e+=n}}function Ye(t,e,r,n,i,a,o,s){for(a=2*a+1;0>3)],g=On[112+(g+3>>3)],m=p+1>>1;c[u-2*l]=Bn[255+c[u-2*l]+m],c[u-l]=Bn[255+h+g],c[u+0]=Bn[255+f-p],c[u+l]=Bn[255+d-m]}e+=n}}function Je(t,e,r,n,i,a){Ge(t,e,r,1,16,n,i,a)}function Xe(t,e,r,n,i,a){Ge(t,e,1,r,16,n,i,a)}function Ke(t,e,r,n,i,a){var o;for(o=3;0u?0:255:u)&255,u=c,i[a+s]=l}}function hr(t,r,i,o){var s=r.width,c=r.o;if(e(null!=t&&null!=r),0>i||0>=o||i+o>c)return null;if(!t.Cc){if(null==t.ga){var u;if(t.ga=new sr,(u=null==t.ga)||(u=r.width*r.o,e(0==t.Gb.length),t.Gb=a(u),t.Uc=0,null==t.Gb?u=0:(t.mb=t.Gb,t.nb=t.Uc,t.rc=null,u=1),u=!u),!u){u=t.ga;var l=t.Fa,h=t.P,f=t.qc,d=t.mb,p=t.nb,g=h+1,m=f-1,b=u.l;if(e(null!=l&&null!=d&&null!=r),mi[0]=null,mi[1]=cr,mi[2]=ur,mi[3]=lr,u.ca=d,u.tb=p,u.c=r.width,u.i=r.height,e(0=f)r=0;else if(u.$a=l[h+0]>>0&3,u.Z=l[h+0]>>2&3,u.Lc=l[h+0]>>4&3,h=l[h+0]>>6&3,0>u.$a||1=u.c*u.i;u=!r}if(u)return null;1!=t.ga.Lc?t.Ga=0:o=c-i}e(null!=t.ga),e(i+o<=c);t:{if(r=(l=t.ga).c,c=l.l.o,0==l.$a){if(g=t.rc,m=t.Vc,b=t.Fa,h=t.P+1+i*r,f=t.mb,d=t.nb+i*r,e(h<=t.P+t.qc),0!=l.Z)for(e(null!=mi[l.Z]),u=0;u=r)r=1;else if(l.ic||mr(),l.ic){l=u.V,g=u.Ba,m=u.c;var y=u.i,w=(b=1,h=u.$/m,f=u.$%m,d=u.m,p=u.s,u.$),N=m*y,L=m*r,x=p.wc,_=w(y=bt(_.G[0],_.H[0],d)))l[g+w]=y,++w,++f>=m&&(f=0,++h<=r&&!(h%16)&&St(u,h));else{if(!(280>y)){b=0;break e}y=mt(y-256,d);var P,k=bt(_.G[4],_.H[4],d);if(S(d),!(w>=(k=vt(m,k=mt(k,d)))&&N-w>=y)){b=0;break e}for(P=0;P=m;)f-=m,++h<=r&&!(h%16)&&St(u,h);wr?r:h);break e}!b||d.h&&w=c&&(t.Cc=1),o=1}if(!o)return null;if(t.Cc&&(null!=(o=t.ga)&&(o.mc=null),t.ga=null,0>23,s[c+4*o+1]=s[c+4*o+1]*h>>23,s[c+4*o+2]=s[c+4*o+2]*h>>23)}e+=a}}function dr(t,e,r,n,i){for(;0>4)*c>>16;t[e+2*a+0]=(240&o|o>>4)*c>>16&240|(15&o|o<<4)*c>>16>>4&15,t[e+2*a+1]=240&u|s}e+=i}}function pr(t,e,r,n,i,a,o,s){var c,u,l=255;for(u=0;u>8}function mr(){An=fr,xn=dr,Sn=pr,_n=gr}function vr(r,n,i){t[r]=function(t,r,a,o,s,c,u,l,h,f,d,p,g,m,v,b,y){var w,N=y-1>>1,L=s[c+0]|u[l+0]<<16,A=h[f+0]|d[p+0]<<16;e(null!=t);var x=3*L+A+131074>>2;for(n(t[r+0],255&x,x>>16,g,m),null!=a&&(x=3*A+L+131074>>2,n(a[o+0],255&x,x>>16,v,b)),w=1;w<=N;++w){var S=s[c+w]|u[l+w]<<16,_=h[f+w]|d[p+w]<<16,P=L+S+A+_+524296,k=P+2*(S+A)>>3;x=k+L>>1,L=(P=P+2*(L+_)>>3)+S>>1,n(t[r+2*w-1],255&x,x>>16,g,m+(2*w-1)*i),n(t[r+2*w-0],255&L,L>>16,g,m+(2*w-0)*i),null!=a&&(x=P+A>>1,L=k+_>>1,n(a[o+2*w-1],255&x,x>>16,v,b+(2*w-1)*i),n(a[o+2*w+0],255&L,L>>16,v,b+(2*w+0)*i)),L=S,A=_}1&y||(x=3*L+A+131074>>2,n(t[r+y-1],255&x,x>>16,g,m+(y-1)*i),null!=a&&(x=3*A+L+131074>>2,n(a[o+y-1],255&x,x>>16,v,b+(y-1)*i)))}}function br(){vi[En]=bi,vi[qn]=wi,vi[Dn]=yi,vi[Rn]=Ni,vi[Tn]=Li,vi[Un]=Ai,vi[zn]=xi,vi[Hn]=wi,vi[Wn]=Ni,vi[Vn]=Li,vi[Gn]=Ai}function yr(t){return t&~Ii?0>t?0:255:t>>Fi}function wr(t,e){return yr((19077*t>>8)+(26149*e>>8)-14234)}function Nr(t,e,r){return yr((19077*t>>8)-(6419*e>>8)-(13320*r>>8)+8708)}function Lr(t,e){return yr((19077*t>>8)+(33050*e>>8)-17685)}function Ar(t,e,r,n,i){n[i+0]=wr(t,r),n[i+1]=Nr(t,e,r),n[i+2]=Lr(t,e)}function xr(t,e,r,n,i){n[i+0]=Lr(t,e),n[i+1]=Nr(t,e,r),n[i+2]=wr(t,r)}function Sr(t,e,r,n,i){var a=Nr(t,e,r);e=a<<3&224|Lr(t,e)>>3,n[i+0]=248&wr(t,r)|a>>5,n[i+1]=e}function _r(t,e,r,n,i){var a=240&Lr(t,e)|15;n[i+0]=240&wr(t,r)|Nr(t,e,r)>>4,n[i+1]=a}function Pr(t,e,r,n,i){n[i+0]=255,Ar(t,e,r,n,i+1)}function kr(t,e,r,n,i){xr(t,e,r,n,i),n[i+3]=255}function Fr(t,e,r,n,i){Ar(t,e,r,n,i),n[i+3]=255}function Vt(t,e){return 0>t?0:t>e?e:t}function Ir(e,r,n){t[e]=function(t,e,i,a,o,s,c,u,l){for(var h=u+(-2&l)*n;u!=h;)r(t[e+0],i[a+0],o[s+0],c,u),r(t[e+1],i[a+0],o[s+0],c,u+n),e+=2,++a,++s,u+=2*n;1&l&&r(t[e+0],i[a+0],o[s+0],c,u)}}function Cr(t,e,r){return 0==r?0==t?0==e?6:5:0==e?4:0:r}function jr(t,e,r,n,i){switch(t>>>30){case 3:on(e,r,n,i,0);break;case 2:sn(e,r,n,i);break;case 1:un(e,r,n,i)}}function Or(t,e){var r,a,o=e.M,s=e.Nb,c=t.oc,u=t.pc+40,l=t.oc,h=t.pc+584,f=t.oc,d=t.pc+600;for(r=0;16>r;++r)c[u+32*r-1]=129;for(r=0;8>r;++r)l[h+32*r-1]=129,f[d+32*r-1]=129;for(0r;++r)n(c,u+32*r-4,c,u+32*r+12,4);for(r=-1;8>r;++r)n(l,h+32*r-4,l,h+32*r+4,4),n(f,d+32*r-4,f,d+32*r+4,4)}var g=t.Gd,m=t.Hd+a,v=p.ad,b=p.Hc;if(0=t.za-1?i(y,w,g[m].y[15],4):n(y,w,g[m+1].y,0,4)),r=0;4>r;r++)y[w+128+r]=y[w+256+r]=y[w+384+r]=y[w+0+r];for(r=0;16>r;++r,b<<=2)y=c,w=u+Di[r],fi[p.Ob[r]](y,w),jr(b,v,16*+r,y,w)}else if(y=Cr(a,o,p.Ob[0]),hi[y](c,u),0!=b)for(r=0;16>r;++r,b<<=2)jr(b,v,16*+r,c,u+Di[r]);for(r=p.Gc,y=Cr(a,o,p.Dd),di[y](l,h),di[y](f,d),b=v,y=l,w=h,255&(p=r>>0)&&(170&p?cn(b,256,y,w):ln(b,256,y,w)),p=f,b=d,255&(r>>=8)&&(170&r?cn(v,320,p,b):ln(v,320,p,b)),or;++r)n(g,m+r*t.R,c,u+32*r,16);for(r=0;8>r;++r)n(v,p+r*t.B,l,h+32*r,8),n(b,y+r*t.B,f,d+32*r,8)}}function Br(t,n,i,a,o,s,c,u,l){var h=[0],f=[0],d=0,p=null!=l?l.kd:0,g=null!=l?l:new nr;if(null==t||12>i)return 7;g.data=t,g.w=n,g.ha=i,n=[n],i=[i],g.gb=[g.gb];t:{var m=n,b=i,y=g.gb;if(e(null!=t),e(null!=b),e(null!=y),y[0]=0,12<=b[0]&&!r(t,m[0],"RIFF")){if(r(t,m[0]+8,"WEBP")){y=3;break t}var w=j(t,m[0]+4);if(12>w||4294967286b[0]-8){y=7;break t}y[0]=w,m[0]+=12,b[0]-=12}y=0}if(0!=y)return y;for(w=0y[0])y=7;else{if(!r(L,b[0],"VP8X")){if(10!=j(L,b[0]+4)){y=3;break t}if(18>y[0]){y=7;break t}var _=j(L,b[0]+8),P=1+C(L,b[0]+12);if(2147483648<=P*(L=1+C(L,b[0]+15))){y=3;break t}null!=S&&(S[0]=_),null!=A&&(A[0]=P),null!=x&&(x[0]=L),b[0]+=18,y[0]-=18,k[0]=1}y=0}}if(d=d[0],m=m[0],0!=y)return y;if(b=!!(2&m),!w&&d)return 3;if(null!=s&&(s[0]=!!(16&m)),null!=c&&(c[0]=b),null!=u&&(u[0]=0),c=h[0],m=f[0],d&&b&&null==l){y=0;break}if(4>i){y=7;break}if(w&&d||!w&&!d&&!r(t,n[0],"ALPH")){i=[i],g.na=[g.na],g.P=[g.P],g.Sa=[g.Sa];t:{_=t,y=n,w=i;var k=g.gb;A=g.na,x=g.P,S=g.Sa;P=22,e(null!=_),e(null!=w),L=y[0];var F=w[0];for(e(null!=A),e(null!=S),A[0]=null,x[0]=null,S[0]=0;;){if(y[0]=L,w[0]=F,8>F){y=7;break t}var I=j(_,L+4);if(4294967286k){y=3;break t}if(!r(_,L,"VP8 ")||!r(_,L,"VP8L")){y=0;break t}if(F[0]w[0])y=7;else{if(L||P){if(k=j(k,_+4),12<=A&&k>A-12){y=3;break t}if(p&&k>w[0]-8){y=7;break t}x[0]=k,y[0]+=8,w[0]-=8,S[0]=P}else S[0]=5<=w[0]&&47==k[_+0]&&!(k[_+4]>>5),x[0]=w[0];y=0}if(i=i[0],g.Ja=g.Ja[0],g.xa=g.xa[0],n=n[0],0!=y)break;if(4294967286i){y=7;break}u=c,p=m,b=s,null==t||5>i?t=0:5<=i&&47==t[n+0]&&!(t[n+4]>>5)?(w=[0],k=[0],A=[0],v(x=new N,t,n,i),gt(x,w,k,A)?(null!=u&&(u[0]=w[0]),null!=p&&(p[0]=k[0]),null!=b&&(b[0]=A[0]),t=1):t=0):t=0}else{if(10>i){y=7;break}u=m,null==t||10>i||!Xt(t,n+3,i-3)?t=0:(p=t[n+0]|t[n+1]<<8|t[n+2]<<16,b=16383&(t[n+7]<<8|t[n+6]),t=16383&(t[n+9]<<8|t[n+8]),1&p||3<(p>>1&7)||!(p>>4&1)||p>>5>=g.Ja||!b||!t?t=0:(c&&(c[0]=b),u&&(u[0]=t),t=1))}if(!t)return 3;if(c=c[0],m=m[0],d&&(h[0]!=c||f[0]!=m))return 3;null!=l&&(l[0]=g,l.offset=n-l.w,e(4294967286>n-l.w),e(l.offset==l.ha-i));break}return 0==y||7==y&&d&&null==l?(null!=s&&(s[0]|=null!=g.na&&0r||(a&=-2,o&=-2),0>a||0>o||0>=s||0>=c||a+s>n||o+c>i))return 0;if(e.v=a,e.j=o,e.va=a+s,e.o=o+c,e.U=s,e.T=c,e.da=null!=t&&0t.S){var e=t.f.RGBA;e.fb+=(t.height-1)*e.A,e.A=-e.A}else e=t.f.kb,t=t.height,e.O+=(t-1)*e.fa,e.fa=-e.fa,e.N+=(t-1>>1)*e.Ab,e.Ab=-e.Ab,e.W+=(t-1>>1)*e.Db,e.Db=-e.Db,null!=e.F&&(e.J+=(t-1)*e.lb,e.lb=-e.lb);return 0}function qr(t,e,r,n){if(null==n||0>=t||0>=e)return 2;if(null!=r){if(r.Da){var i=r.cd,o=r.bd,s=-2&r.v,c=-2&r.j;if(0>s||0>c||0>=i||0>=o||s+i>t||c+o>e)return 2;t=i,e=o}if(r.da){if(!E(t,e,i=[r.ib],o=[r.hb]))return 2;t=i[0],e=o[0]}}n.width=t,n.height=e;t:{var u=n.width,l=n.height;if(t=n.S,0>=u||0>=l||!(t>=En&&13>t))t=2;else{if(0>=n.Rd&&null==n.sd){s=o=i=e=0;var h=(c=u*zi[t])*l;if(11>t||(o=(l+1)/2*(e=(u+1)/2),12==t&&(s=(i=u)*l)),null==(l=a(h+2*o+s))){t=1;break t}n.sd=l,11>t?((u=n.f.RGBA).eb=l,u.fb=0,u.A=c,u.size=h):((u=n.f.kb).y=l,u.O=0,u.fa=c,u.Fd=h,u.f=l,u.N=0+h,u.Ab=e,u.Cd=o,u.ea=l,u.W=0+h+o,u.Db=e,u.Ed=o,12==t&&(u.F=l,u.J=0+h+2*o),u.Tc=s,u.lb=i)}if(e=1,i=n.S,o=n.width,s=n.height,i>=En&&13>i)if(11>i)t=n.f.RGBA,e&=(c=Math.abs(t.A))*(s-1)+o<=t.size,e&=c>=o*zi[i],e&=null!=t.eb;else{t=n.f.kb,c=(o+1)/2,h=(s+1)/2,u=Math.abs(t.fa);l=Math.abs(t.Ab);var f=Math.abs(t.Db),d=Math.abs(t.lb),p=d*(s-1)+o;e&=u*(s-1)+o<=t.Fd,e&=l*(h-1)+c<=t.Cd,e=(e&=f*(h-1)+c<=t.Ed)&u>=o&l>=c&f>=c,e&=null!=t.y,e&=null!=t.f,e&=null!=t.ea,12==i&&(e&=d>=o,e&=p<=t.Tc,e&=null!=t.F)}else e=0;t=e?0:2}}return 0!=t||null!=r&&r.fd&&(t=Er(n)),t}var Dr=64,Rr=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,262143,524287,1048575,2097151,4194303,8388607,16777215],Tr=24,Ur=32,zr=8,Hr=[0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7];R("Predictor0","PredictorAdd0"),t.Predictor0=function(){return 4278190080},t.Predictor1=function(t){return t},t.Predictor2=function(t,e,r){return e[r+0]},t.Predictor3=function(t,e,r){return e[r+1]},t.Predictor4=function(t,e,r){return e[r-1]},t.Predictor5=function(t,e,r){return U(U(t,e[r+1]),e[r+0])},t.Predictor6=function(t,e,r){return U(t,e[r-1])},t.Predictor7=function(t,e,r){return U(t,e[r+0])},t.Predictor8=function(t,e,r){return U(e[r-1],e[r+0])},t.Predictor9=function(t,e,r){return U(e[r+0],e[r+1])},t.Predictor10=function(t,e,r){return U(U(t,e[r-1]),U(e[r+0],e[r+1]))},t.Predictor11=function(t,e,r){var n=e[r+0];return 0>=W(n>>24&255,t>>24&255,(e=e[r-1])>>24&255)+W(n>>16&255,t>>16&255,e>>16&255)+W(n>>8&255,t>>8&255,e>>8&255)+W(255&n,255&t,255&e)?n:t},t.Predictor12=function(t,e,r){var n=e[r+0];return(z((t>>24&255)+(n>>24&255)-((e=e[r-1])>>24&255))<<24|z((t>>16&255)+(n>>16&255)-(e>>16&255))<<16|z((t>>8&255)+(n>>8&255)-(e>>8&255))<<8|z((255&t)+(255&n)-(255&e)))>>>0},t.Predictor13=function(t,e,r){var n=e[r-1];return(H((t=U(t,e[r+0]))>>24&255,n>>24&255)<<24|H(t>>16&255,n>>16&255)<<16|H(t>>8&255,n>>8&255)<<8|H(t>>0&255,n>>0&255))>>>0};var Wr=t.PredictorAdd0;t.PredictorAdd1=V,R("Predictor2","PredictorAdd2"),R("Predictor3","PredictorAdd3"),R("Predictor4","PredictorAdd4"),R("Predictor5","PredictorAdd5"),R("Predictor6","PredictorAdd6"),R("Predictor7","PredictorAdd7"),R("Predictor8","PredictorAdd8"),R("Predictor9","PredictorAdd9"),R("Predictor10","PredictorAdd10"),R("Predictor11","PredictorAdd11"),R("Predictor12","PredictorAdd12"),R("Predictor13","PredictorAdd13");var Vr=t.PredictorAdd2;X("ColorIndexInverseTransform","MapARGB","32b",(function(t){return t>>8&255}),(function(t){return t})),X("VP8LColorIndexInverseTransformAlpha","MapAlpha","8b",(function(t){return t}),(function(t){return t>>8&255}));var Gr,Yr=t.ColorIndexInverseTransform,Jr=t.MapARGB,Xr=t.VP8LColorIndexInverseTransformAlpha,Kr=t.MapAlpha,Zr=t.VP8LPredictorsAdd=[];Zr.length=16,(t.VP8LPredictors=[]).length=16,(t.VP8LPredictorsAdd_C=[]).length=16,(t.VP8LPredictors_C=[]).length=16;var $r,Qr,tn,en,rn,nn,an,on,sn,cn,un,ln,hn,fn,dn,pn,gn,mn,vn,bn,yn,wn,Nn,Ln,An,xn,Sn,_n,Pn=a(511),kn=a(2041),Fn=a(225),In=a(767),Cn=0,jn=kn,On=Fn,Bn=In,Mn=Pn,En=0,qn=1,Dn=2,Rn=3,Tn=4,Un=5,zn=6,Hn=7,Wn=8,Vn=9,Gn=10,Yn=[2,3,7],Jn=[3,3,11],Xn=[280,256,256,256,40],Kn=[0,1,1,1,0],Zn=[17,18,0,1,2,3,4,5,16,6,7,8,9,10,11,12,13,14,15],$n=[24,7,23,25,40,6,39,41,22,26,38,42,56,5,55,57,21,27,54,58,37,43,72,4,71,73,20,28,53,59,70,74,36,44,88,69,75,52,60,3,87,89,19,29,86,90,35,45,68,76,85,91,51,61,104,2,103,105,18,30,102,106,34,46,84,92,67,77,101,107,50,62,120,1,119,121,83,93,17,31,100,108,66,78,118,122,33,47,117,123,49,63,99,109,82,94,0,116,124,65,79,16,32,98,110,48,115,125,81,95,64,114,126,97,111,80,113,127,96,112],Qn=[2954,2956,2958,2962,2970,2986,3018,3082,3212,3468,3980,5004],ti=8,ei=[4,5,6,7,8,9,10,10,11,12,13,14,15,16,17,17,18,19,20,20,21,21,22,22,23,23,24,25,25,26,27,28,29,30,31,32,33,34,35,36,37,37,38,39,40,41,42,43,44,45,46,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,76,77,78,79,80,81,82,83,84,85,86,87,88,89,91,93,95,96,98,100,101,102,104,106,108,110,112,114,116,118,122,124,126,128,130,132,134,136,138,140,143,145,148,151,154,157],ri=[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,119,122,125,128,131,134,137,140,143,146,149,152,155,158,161,164,167,170,173,177,181,185,189,193,197,201,205,209,213,217,221,225,229,234,239,245,249,254,259,264,269,274,279,284],ni=null,ii=[[173,148,140,0],[176,155,140,135,0],[180,157,141,134,130,0],[254,254,243,230,196,177,153,140,133,130,129,0]],ai=[0,1,4,8,5,2,3,6,9,12,13,10,7,11,14,15],oi=[-0,1,-1,2,-2,3,4,6,-3,5,-4,-5,-6,7,-7,8,-8,-9],si=[[[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]],[[253,136,254,255,228,219,128,128,128,128,128],[189,129,242,255,227,213,255,219,128,128,128],[106,126,227,252,214,209,255,255,128,128,128]],[[1,98,248,255,236,226,255,255,128,128,128],[181,133,238,254,221,234,255,154,128,128,128],[78,134,202,247,198,180,255,219,128,128,128]],[[1,185,249,255,243,255,128,128,128,128,128],[184,150,247,255,236,224,128,128,128,128,128],[77,110,216,255,236,230,128,128,128,128,128]],[[1,101,251,255,241,255,128,128,128,128,128],[170,139,241,252,236,209,255,255,128,128,128],[37,116,196,243,228,255,255,255,128,128,128]],[[1,204,254,255,245,255,128,128,128,128,128],[207,160,250,255,238,128,128,128,128,128,128],[102,103,231,255,211,171,128,128,128,128,128]],[[1,152,252,255,240,255,128,128,128,128,128],[177,135,243,255,234,225,128,128,128,128,128],[80,129,211,255,194,224,128,128,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[246,1,255,128,128,128,128,128,128,128,128],[255,128,128,128,128,128,128,128,128,128,128]]],[[[198,35,237,223,193,187,162,160,145,155,62],[131,45,198,221,172,176,220,157,252,221,1],[68,47,146,208,149,167,221,162,255,223,128]],[[1,149,241,255,221,224,255,255,128,128,128],[184,141,234,253,222,220,255,199,128,128,128],[81,99,181,242,176,190,249,202,255,255,128]],[[1,129,232,253,214,197,242,196,255,255,128],[99,121,210,250,201,198,255,202,128,128,128],[23,91,163,242,170,187,247,210,255,255,128]],[[1,200,246,255,234,255,128,128,128,128,128],[109,178,241,255,231,245,255,255,128,128,128],[44,130,201,253,205,192,255,255,128,128,128]],[[1,132,239,251,219,209,255,165,128,128,128],[94,136,225,251,218,190,255,255,128,128,128],[22,100,174,245,186,161,255,199,128,128,128]],[[1,182,249,255,232,235,128,128,128,128,128],[124,143,241,255,227,234,128,128,128,128,128],[35,77,181,251,193,211,255,205,128,128,128]],[[1,157,247,255,236,231,255,255,128,128,128],[121,141,235,255,225,227,255,255,128,128,128],[45,99,188,251,195,217,255,224,128,128,128]],[[1,1,251,255,213,255,128,128,128,128,128],[203,1,248,255,255,128,128,128,128,128,128],[137,1,177,255,224,255,128,128,128,128,128]]],[[[253,9,248,251,207,208,255,192,128,128,128],[175,13,224,243,193,185,249,198,255,255,128],[73,17,171,221,161,179,236,167,255,234,128]],[[1,95,247,253,212,183,255,255,128,128,128],[239,90,244,250,211,209,255,255,128,128,128],[155,77,195,248,188,195,255,255,128,128,128]],[[1,24,239,251,218,219,255,205,128,128,128],[201,51,219,255,196,186,128,128,128,128,128],[69,46,190,239,201,218,255,228,128,128,128]],[[1,191,251,255,255,128,128,128,128,128,128],[223,165,249,255,213,255,128,128,128,128,128],[141,124,248,255,255,128,128,128,128,128,128]],[[1,16,248,255,255,128,128,128,128,128,128],[190,36,230,255,236,255,128,128,128,128,128],[149,1,255,128,128,128,128,128,128,128,128]],[[1,226,255,128,128,128,128,128,128,128,128],[247,192,255,128,128,128,128,128,128,128,128],[240,128,255,128,128,128,128,128,128,128,128]],[[1,134,252,255,255,128,128,128,128,128,128],[213,62,250,255,255,128,128,128,128,128,128],[55,93,255,128,128,128,128,128,128,128,128]],[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]]],[[[202,24,213,235,186,191,220,160,240,175,255],[126,38,182,232,169,184,228,174,255,187,128],[61,46,138,219,151,178,240,170,255,216,128]],[[1,112,230,250,199,191,247,159,255,255,128],[166,109,228,252,211,215,255,174,128,128,128],[39,77,162,232,172,180,245,178,255,255,128]],[[1,52,220,246,198,199,249,220,255,255,128],[124,74,191,243,183,193,250,221,255,255,128],[24,71,130,219,154,170,243,182,255,255,128]],[[1,182,225,249,219,240,255,224,128,128,128],[149,150,226,252,216,205,255,171,128,128,128],[28,108,170,242,183,194,254,223,255,255,128]],[[1,81,230,252,204,203,255,192,128,128,128],[123,102,209,247,188,196,255,233,128,128,128],[20,95,153,243,164,173,255,203,128,128,128]],[[1,222,248,255,216,213,128,128,128,128,128],[168,175,246,252,235,205,255,255,128,128,128],[47,116,215,255,211,212,255,255,128,128,128]],[[1,121,236,253,212,214,255,255,128,128,128],[141,84,213,252,201,202,255,219,128,128,128],[42,80,160,240,162,185,255,205,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[244,1,255,128,128,128,128,128,128,128,128],[238,1,255,128,128,128,128,128,128,128,128]]]],ci=[[[231,120,48,89,115,113,120,152,112],[152,179,64,126,170,118,46,70,95],[175,69,143,80,85,82,72,155,103],[56,58,10,171,218,189,17,13,152],[114,26,17,163,44,195,21,10,173],[121,24,80,195,26,62,44,64,85],[144,71,10,38,171,213,144,34,26],[170,46,55,19,136,160,33,206,71],[63,20,8,114,114,208,12,9,226],[81,40,11,96,182,84,29,16,36]],[[134,183,89,137,98,101,106,165,148],[72,187,100,130,157,111,32,75,80],[66,102,167,99,74,62,40,234,128],[41,53,9,178,241,141,26,8,107],[74,43,26,146,73,166,49,23,157],[65,38,105,160,51,52,31,115,128],[104,79,12,27,217,255,87,17,7],[87,68,71,44,114,51,15,186,23],[47,41,14,110,182,183,21,17,194],[66,45,25,102,197,189,23,18,22]],[[88,88,147,150,42,46,45,196,205],[43,97,183,117,85,38,35,179,61],[39,53,200,87,26,21,43,232,171],[56,34,51,104,114,102,29,93,77],[39,28,85,171,58,165,90,98,64],[34,22,116,206,23,34,43,166,73],[107,54,32,26,51,1,81,43,31],[68,25,106,22,64,171,36,225,114],[34,19,21,102,132,188,16,76,124],[62,18,78,95,85,57,50,48,51]],[[193,101,35,159,215,111,89,46,111],[60,148,31,172,219,228,21,18,111],[112,113,77,85,179,255,38,120,114],[40,42,1,196,245,209,10,25,109],[88,43,29,140,166,213,37,43,154],[61,63,30,155,67,45,68,1,209],[100,80,8,43,154,1,51,26,71],[142,78,78,16,255,128,34,197,171],[41,40,5,102,211,183,4,1,221],[51,50,17,168,209,192,23,25,82]],[[138,31,36,171,27,166,38,44,229],[67,87,58,169,82,115,26,59,179],[63,59,90,180,59,166,93,73,154],[40,40,21,116,143,209,34,39,175],[47,15,16,183,34,223,49,45,183],[46,17,33,183,6,98,15,32,183],[57,46,22,24,128,1,54,17,37],[65,32,73,115,28,128,23,128,205],[40,3,9,115,51,192,18,6,223],[87,37,9,115,59,77,64,21,47]],[[104,55,44,218,9,54,53,130,226],[64,90,70,205,40,41,23,26,57],[54,57,112,184,5,41,38,166,213],[30,34,26,133,152,116,10,32,134],[39,19,53,221,26,114,32,73,255],[31,9,65,234,2,15,1,118,73],[75,32,12,51,192,255,160,43,51],[88,31,35,67,102,85,55,186,85],[56,21,23,111,59,205,45,37,192],[55,38,70,124,73,102,1,34,98]],[[125,98,42,88,104,85,117,175,82],[95,84,53,89,128,100,113,101,45],[75,79,123,47,51,128,81,171,1],[57,17,5,71,102,57,53,41,49],[38,33,13,121,57,73,26,1,85],[41,10,67,138,77,110,90,47,114],[115,21,2,10,102,255,166,23,6],[101,29,16,10,85,128,101,196,26],[57,18,10,102,102,213,34,20,43],[117,20,15,36,163,128,68,1,26]],[[102,61,71,37,34,53,31,243,192],[69,60,71,38,73,119,28,222,37],[68,45,128,34,1,47,11,245,171],[62,17,19,70,146,85,55,62,70],[37,43,37,154,100,163,85,160,1],[63,9,92,136,28,64,32,201,85],[75,15,9,9,64,255,184,119,16],[86,6,28,5,64,255,25,248,1],[56,8,17,132,137,255,55,116,128],[58,15,20,82,135,57,26,121,40]],[[164,50,31,137,154,133,25,35,218],[51,103,44,131,131,123,31,6,158],[86,40,64,135,148,224,45,183,128],[22,26,17,131,240,154,14,1,209],[45,16,21,91,64,222,7,1,197],[56,21,39,155,60,138,23,102,213],[83,12,13,54,192,255,68,47,28],[85,26,85,85,128,128,32,146,171],[18,11,7,63,144,171,4,4,246],[35,27,10,146,174,171,12,26,128]],[[190,80,35,99,180,80,126,54,45],[85,126,47,87,176,51,41,20,32],[101,75,128,139,118,146,116,128,85],[56,41,15,176,236,85,37,9,62],[71,30,17,119,118,255,17,18,138],[101,38,60,138,55,70,43,26,142],[146,36,19,30,171,255,97,27,20],[138,45,61,62,219,1,81,188,64],[32,41,20,117,151,142,20,21,163],[112,19,12,61,195,128,48,4,24]]],ui=[[[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[176,246,255,255,255,255,255,255,255,255,255],[223,241,252,255,255,255,255,255,255,255,255],[249,253,253,255,255,255,255,255,255,255,255]],[[255,244,252,255,255,255,255,255,255,255,255],[234,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255]],[[255,246,254,255,255,255,255,255,255,255,255],[239,253,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[251,255,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[251,254,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,254,253,255,254,255,255,255,255,255,255],[250,255,254,255,254,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[217,255,255,255,255,255,255,255,255,255,255],[225,252,241,253,255,255,254,255,255,255,255],[234,250,241,250,253,255,253,254,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[223,254,254,255,255,255,255,255,255,255,255],[238,253,254,254,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[249,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,255,255,255,255,255,255,255,255,255],[247,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[252,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[186,251,250,255,255,255,255,255,255,255,255],[234,251,244,254,255,255,255,255,255,255,255],[251,251,243,253,254,255,254,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[236,253,254,255,255,255,255,255,255,255,255],[251,253,253,254,254,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[254,254,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[254,254,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[248,255,255,255,255,255,255,255,255,255,255],[250,254,252,254,255,255,255,255,255,255,255],[248,254,249,253,255,255,255,255,255,255,255]],[[255,253,253,255,255,255,255,255,255,255,255],[246,253,253,255,255,255,255,255,255,255,255],[252,254,251,254,254,255,255,255,255,255,255]],[[255,254,252,255,255,255,255,255,255,255,255],[248,254,253,255,255,255,255,255,255,255,255],[253,255,254,254,255,255,255,255,255,255,255]],[[255,251,254,255,255,255,255,255,255,255,255],[245,251,254,255,255,255,255,255,255,255,255],[253,253,254,255,255,255,255,255,255,255,255]],[[255,251,253,255,255,255,255,255,255,255,255],[252,253,254,255,255,255,255,255,255,255,255],[255,254,255,255,255,255,255,255,255,255,255]],[[255,252,255,255,255,255,255,255,255,255,255],[249,255,254,255,255,255,255,255,255,255,255],[255,255,254,255,255,255,255,255,255,255,255]],[[255,255,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]]],li=[0,1,2,3,6,4,5,6,6,6,6,6,6,6,6,7,0],hi=[],fi=[],di=[],pi=1,gi=2,mi=[],vi=[];vr("UpsampleRgbLinePair",Ar,3),vr("UpsampleBgrLinePair",xr,3),vr("UpsampleRgbaLinePair",Fr,4),vr("UpsampleBgraLinePair",kr,4),vr("UpsampleArgbLinePair",Pr,4),vr("UpsampleRgba4444LinePair",_r,2),vr("UpsampleRgb565LinePair",Sr,2);var bi=t.UpsampleRgbLinePair,yi=t.UpsampleBgrLinePair,wi=t.UpsampleRgbaLinePair,Ni=t.UpsampleBgraLinePair,Li=t.UpsampleArgbLinePair,Ai=t.UpsampleRgba4444LinePair,xi=t.UpsampleRgb565LinePair,Si=16,_i=1<i.ca.S||(alert("todo:WebPInitConvertARGBToYUV"),null!=i.ca.f.kb.F&&mr()),i.Pb&&0(u=n.Md)?0:100l;++l)12>(f=a.pb[l]).lc&&(f.ia=u*Ti[0>f.lc?0:f.lc]>>3),h|=f.ia;h&&(alert("todo:VP8InitRandom"),a.ia=1)}a.Ga=n.Id,100a.Ga&&(a.Ga=0)}Qt(t,i)||(r=t.a)}}else r=t.a}0==r&&null!=s.Oa&&s.Oa.fd&&(r=Er(s.ba))}s=r}o=0!=s?null:11>o?c.f.RGBA.eb:c.f.kb.y}else o=null;return o};var zi=[3,4,3,4,4,2,2,4,4,4,2,1,1]};function u(t,e){for(var r="",n=0;n<4;n++)r+=String.fromCharCode(t[e++]);return r}function l(t,e){return(t[e+0]<<0|t[e+1]<<8|t[e+2]<<16)>>>0}function h(t,e){return(t[e+0]<<0|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}new c;var f=[0],d=[0],p=[],g=new c,m=t,v=function(t,e){var r={},n=0,i=!1,a=0,o=0;if(r.frames=[],! /** @license * Copyright (c) 2017 Dominik Homberger Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. https://webpjs.appspot.com WebPRiffParser dominikhlbg@gmail.com */ function(t,e,r,n){for(var i=0;i>1&1}"ANMF"!=f&&(e+=p)}return r}}(m,0);v.response=m,v.rgbaoutput=!0,v.dataurl=!1;var b=v.header?v.header:null,y=v.frames?v.frames:null;if(b){b.loop_counter=b.loop_count,f=[b.canvas_height],d=[b.canvas_width];for(var w=0;w>>1)&255;return a},c=function(t,e,r){var n,i,a,o,s=[],c=t.length;s[0]=4;for(var l=0;l>>x&255,x+=u.bits;m[w]=y>>>x&255}}if(16===u.bits){g=(p=new Uint32Array(u.decodePixels().buffer)).length,v=new Uint8Array(g*(32/u.pixelBitlength)*u.colors),m=new Uint8Array(g*(32/u.pixelBitlength)),b=u.colors>1,w=0,N=0;for(var _=0;w>>0&255,b&&(v[N++]=y>>>16&255,y=p[w++],v[N++]=y>>>0&255),m[_++]=y>>>16&255;c=8}o!==t.image_compression.NONE&&e()?(n=r(v,u.width*u.colors,u.colors,o),d=r(m,u.width,1,o)):(n=v,d=m,L=void 0)}if(3===u.colorType&&(s=this.color_spaces.INDEXED,f=u.palette,u.transparency.indexed)){var P=u.transparency.indexed,k=0;for(w=0,g=P.length;w=0;t--){for(var n=this.bottom_up?t:this.height-1-t,i=0;i>7-s&1];this.data[o+4*s]=c.blue,this.data[o+4*s+1]=c.green,this.data[o+4*s+2]=c.red,this.data[o+4*s+3]=255}0!==r&&(this.pos+=4-r)}},qe.prototype.bit4=function(){for(var t=Math.ceil(this.width/2),e=t%4,r=this.height-1;r>=0;r--){for(var n=this.bottom_up?r:this.height-1-r,i=0;i>4,c=15&a,u=this.palette[s];if(this.data[o]=u.blue,this.data[o+1]=u.green,this.data[o+2]=u.red,this.data[o+3]=255,2*i+1>=this.width)break;u=this.palette[c],this.data[o+4]=u.blue,this.data[o+4+1]=u.green,this.data[o+4+2]=u.red,this.data[o+4+3]=255}0!==e&&(this.pos+=4-e)}},qe.prototype.bit8=function(){for(var t=this.width%4,e=this.height-1;e>=0;e--){for(var r=this.bottom_up?e:this.height-1-e,n=0;n=0;r--){for(var n=this.bottom_up?r:this.height-1-r,i=0;i>5&e)/e*255|0,c=(a>>10&e)/e*255|0,u=a>>15?255:0,l=n*this.width*4+4*i;this.data[l]=c,this.data[l+1]=s,this.data[l+2]=o,this.data[l+3]=u}this.pos+=t}},qe.prototype.bit16=function(){for(var t=this.width%3,e=parseInt("11111",2),r=parseInt("111111",2),n=this.height-1;n>=0;n--){for(var i=this.bottom_up?n:this.height-1-n,a=0;a>5&r)/r*255|0,u=(o>>11)/e*255|0,l=i*this.width*4+4*a;this.data[l]=u,this.data[l+1]=c,this.data[l+2]=s,this.data[l+3]=255}this.pos+=t}},qe.prototype.bit24=function(){for(var t=this.height-1;t>=0;t--){for(var e=this.bottom_up?t:this.height-1-t,r=0;r=0;t--)for(var e=this.bottom_up?t:this.height-1-t,r=0;rn&&(i.push(t.slice(c,a)),s=0,c=a),s+=e[a],a++;return c!==a&&i.push(t.slice(c,a)),i},je=function(t,e,r){r||(r={});var n,i,a,o,s,c,u,l=[],h=[l],f=r.textIndent||0,d=0,p=0,g=t.split(" "),m=Fe.apply(this,[" ",r])[0];if(c=-1===r.lineIndent?g[0].length+2:r.lineIndent||0){var v=Array(c).join(" "),b=[];g.map((function(t){(t=t.split(/\s*\n/)).length>1?b=b.concat(t.map((function(t,e){return(e&&t.length?"\n":"")+t}))):b.push(t[0])})),g=b,c=Ie.apply(this,[v,r])}for(a=0,o=g.length;ae||y){if(p>e){for(s=Ce.apply(this,[n,i,e-(f+d),e]),l.push(s.shift()),l=[s.pop()];s.length;)h.push([s.shift()]);p=i.slice(n.length-(l[0]?l[0].length:0)).reduce((function(t,e){return t+e}),0)}else l=[n];h.push(l),f=p+c,d=m}else l.push(n),f+=d+p,d=m}return u=c?function(t,e){return(e?v:"")+t.join(" ")}:function(t){return t.join(" ")},h.map(u)},ke.splitTextToSize=function(t,e,r){var n,i=(r=r||{}).fontSize||this.internal.getFontSize(),a=function(t){if(t.widths&&t.kerning)return{widths:t.widths,kerning:t.kerning};var e=this.internal.getFont(t.fontName,t.fontStyle);return e.metadata.Unicode?{widths:e.metadata.Unicode.widths||{0:1},kerning:e.metadata.Unicode.kerning||{}}:{font:e.metadata,fontSize:this.internal.getFontSize(),charSpace:this.internal.getCharSpace()}}.call(this,r);n=Array.isArray(t)?t:String(t).split(/\r?\n/);var o=1*this.internal.scaleFactor*e/i;a.textIndent=r.textIndent?1*r.textIndent*this.internal.scaleFactor/i:0,a.lineIndent=r.lineIndent;var s,c,u=[];for(s=0,c=n.length;s1){for(h=0;h>")})),this.internal.viewerpreferences.isSubscribed=!0),this.internal.viewerpreferences.configuration=n,this}}(M.API), /** ==================================================================== * @license * jsPDF XMP metadata plugin * Copyright (c) 2016 Jussi Utunen, u-jussi@suomi24.fi * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ==================================================================== */ function(t){var e=function(){var t='',e=unescape(encodeURIComponent('')),r=unescape(encodeURIComponent(t)),n=unescape(encodeURIComponent(this.internal.__metadata__.metadata)),i=unescape(encodeURIComponent("")),a=unescape(encodeURIComponent("")),o=r.length+n.length+i.length+e.length+a.length;this.internal.__metadata__.metadata_object_number=this.internal.newObject(),this.internal.write("<< /Type /Metadata /Subtype /XML /Length "+o+" >>"),this.internal.write("stream"),this.internal.write(e+r+n+i+a),this.internal.write("endstream"),this.internal.write("endobj")},r=function(){this.internal.__metadata__.metadata_object_number&&this.internal.write("/Metadata "+this.internal.__metadata__.metadata_object_number+" 0 R")};t.addMetadata=function(t,n){return void 0===this.internal.__metadata__&&(this.internal.__metadata__={metadata:t,namespaceuri:n||"http://jspdf.default.namespaceuri/"},this.internal.events.subscribe("putCatalog",r),this.internal.events.subscribe("postPutResources",e)),this}}(M.API),function(t){var e=t.API,r=e.pdfEscape16=function(t,e){for(var r,n=e.metadata.Unicode.widths,i=["","0","00","000","0000"],a=[""],o=0,s=t.length;o=100&&(a+="\n"+n.length+" beginbfchar\n"+n.join("\n")+"\nendbfchar",n=[]),void 0!==t[e]&&null!==t[e]&&"function"==typeof t[e].toString&&(i=("0000"+t[e].toString(16)).slice(-4),e=("0000"+(+e).toString(16)).slice(-4),n.push("<"+e+"><"+i+">"));return n.length&&(a+="\n"+n.length+" beginbfchar\n"+n.join("\n")+"\nendbfchar\n"),a+="endcmap\nCMapName currentdict /CMap defineresource pop\nend\nend"};e.events.push(["putFont",function(e){!function(e){var r=e.font,i=e.out,a=e.newObject,o=e.putStream;if(r.metadata instanceof t.API.TTFFont&&"Identity-H"===r.encoding){for(var s=r.metadata.Unicode.widths,c=r.metadata.subset.encode(r.metadata.glyIdsUsed,1),u="",l=0;l>"),i("endobj");var p=a();i("<<"),i("/Type /Font"),i("/BaseFont /"+F(r.fontName)),i("/FontDescriptor "+d+" 0 R"),i("/W "+t.API.PDFObject.convert(s)),i("/CIDToGIDMap /Identity"),i("/DW 1000"),i("/Subtype /CIDFontType2"),i("/CIDSystemInfo"),i("<<"),i("/Supplement 0"),i("/Registry (Adobe)"),i("/Ordering ("+r.encoding+")"),i(">>"),i(">>"),i("endobj"),r.objectNumber=a(),i("<<"),i("/Type /Font"),i("/Subtype /Type0"),i("/ToUnicode "+f+" 0 R"),i("/BaseFont /"+F(r.fontName)),i("/Encoding /"+r.encoding),i("/DescendantFonts ["+p+" 0 R]"),i(">>"),i("endobj"),r.isAlreadyPutted=!0}}(e)}]);e.events.push(["putFont",function(e){!function(e){var r=e.font,i=e.out,a=e.newObject,o=e.putStream;if(r.metadata instanceof t.API.TTFFont&&"WinAnsiEncoding"===r.encoding){for(var s=r.metadata.rawData,c="",u=0;u>"),i("endobj"),r.objectNumber=a();for(var d=0;d>"),i("endobj"),r.isAlreadyPutted=!0}}(e)}]);var i=function(t){var e,n=t.text||"",i=t.x,a=t.y,o=t.options||{},s=t.mutex||{},c=s.pdfEscape,u=s.activeFontKey,l=s.fonts,h=u,f="",d=0,p="",g=l[h].encoding;if("Identity-H"!==l[h].encoding)return{text:n,x:i,y:a,options:o,mutex:s};for(p=n,h=u,Array.isArray(n)&&(p=n[0]),d=0;d","<","[","]","[","{","}","{","«","»","«","‹","›","‹","⁅","⁆","⁅","⁽","⁾","⁽","₍","₎","₍","≤","≥","≤","〈","〉","〈","﹙","﹚","﹙","﹛","﹜","﹛","﹝","﹞","﹝","﹤","﹥","﹤"],g=new RegExp(/^([1-4|9]|1[0-9]|2[0-9]|3[0168]|4[04589]|5[012]|7[78]|159|16[0-9]|17[0-2]|21[569]|22[03489]|250)$/),m=!1,v=0;this.__bidiEngine__={};var b=function(t){var e=t.charCodeAt(),r=e>>8,n=d[r];return void 0!==n?u[256*n+(255&e)]:252===r||253===r?"AL":g.test(r)?"L":8===r?"R":"N"},y=function(t){for(var e,r=0;r=e.length||"EN"!==(c=o[s-1])&&"AN"!==c||"EN"!==(u=e[s+1])&&"AN"!==u?f="N":m&&(u="AN"),f=u===c?u:"N";break;case"ES":f="EN"===(c=s>0?o[s-1]:"B")&&s+10&&"EN"===o[s-1]){f="EN";break}if(m){f="N";break}for(l=s+1,h=e.length;l=1425&&d<=2303||64286===d;if(c=e[l],p&&("R"===c||"AL"===c)){f="R";break}}}f=s<1||"B"===(c=e[s-1])?"N":o[s-1];break;case"B":m=!1,r=!0,f=v;break;case"S":n=!0,f="N";break;case"LRE":case"RLE":case"LRO":case"RLO":case"PDF":m=!1;break;case"BN":f="N"}return f},N=function(t,e,r){var n=t.split("");return r&&L(n,r,{hiLevel:v}),n.reverse(),e&&e.reverse(),n.join("")},L=function(t,e,i){var a,o,s,c,u,d=-1,p=t.length,g=0,y=[],N=v?h:l,L=[];for(m=!1,r=!1,n=!1,o=0;o0)if(16===a){for(o=d;o-1){for(o=d;o=0&&"WS"===t[i];i--)e[i]=v}}(L,e,p)},A=function(t,e,n,i,a){if(!(a.hiLevel=t){for(c=h+1;c=t;)c++;for(u=h,s=c-1;u=0&&(t[i]=p[n+1])}(n,r,i),A(2,n,e,r,i),A(1,n,e,r,i),n.join("")};return this.__bidiEngine__.doBidiReorder=function(t,e,r){if(function(t,e){if(e)for(var r=0;r>16))&&(e=-(1+(65535^e))),this.italicAngle=+(e+"."+r)):this.italicAngle=0,this.ascender=Math.round(this.ascender*this.scaleFactor),this.decender=Math.round(this.decender*this.scaleFactor),this.lineGap=Math.round(this.lineGap*this.scaleFactor),this.capHeight=this.os2.exists&&this.os2.capHeight||this.ascender,this.xHeight=this.os2.exists&&this.os2.xHeight||0,this.familyClass=(this.os2.exists&&this.os2.familyClass||0)>>8,this.isSerif=1===(i=this.familyClass)||2===i||3===i||4===i||5===i||7===i,this.isScript=10===this.familyClass,this.flags=0,this.post.isFixedPitch&&(this.flags|=1),this.isSerif&&(this.flags|=2),this.isScript&&(this.flags|=8),0!==this.italicAngle&&(this.flags|=64),this.flags|=32,!this.cmap.unicode)throw new Error("No unicode cmap for font")},t.prototype.characterToGlyph=function(t){var e;return(null!=(e=this.cmap.unicode)?e.codeMap[t]:void 0)||0},t.prototype.widthOfGlyph=function(t){var e;return e=1e3/this.head.unitsPerEm,this.hmtx.forGlyph(t).advance*e},t.prototype.widthOfString=function(t,e,r){var n,i,a,o;for(a=0,i=0,o=(t=""+t).length;0<=o?io;i=0<=o?++i:--i)n=t.charCodeAt(i),a+=this.widthOfGlyph(this.characterToGlyph(n))+r*(1e3/e)||0;return a*(e/1e3)},t.prototype.lineHeight=function(t,e){var r;return null==e&&(e=!1),r=e?this.lineGap:0,(this.ascender+r-this.decender)/1e3*t},t}();var Re,Te=function(){function t(t){this.data=null!=t?t:[],this.pos=0,this.length=this.data.length}return t.prototype.readByte=function(){return this.data[this.pos++]},t.prototype.writeByte=function(t){return this.data[this.pos++]=t},t.prototype.readUInt32=function(){return 16777216*this.readByte()+(this.readByte()<<16)+(this.readByte()<<8)+this.readByte()},t.prototype.writeUInt32=function(t){return this.writeByte(t>>>24&255),this.writeByte(t>>16&255),this.writeByte(t>>8&255),this.writeByte(255&t)},t.prototype.readInt32=function(){var t;return(t=this.readUInt32())>=2147483648?t-4294967296:t},t.prototype.writeInt32=function(t){return t<0&&(t+=4294967296),this.writeUInt32(t)},t.prototype.readUInt16=function(){return this.readByte()<<8|this.readByte()},t.prototype.writeUInt16=function(t){return this.writeByte(t>>8&255),this.writeByte(255&t)},t.prototype.readInt16=function(){var t;return(t=this.readUInt16())>=32768?t-65536:t},t.prototype.writeInt16=function(t){return t<0&&(t+=65536),this.writeUInt16(t)},t.prototype.readString=function(t){var e,r;for(r=[],e=0;0<=t?et;e=0<=t?++e:--e)r[e]=String.fromCharCode(this.readByte());return r.join("")},t.prototype.writeString=function(t){var e,r,n;for(n=[],e=0,r=t.length;0<=r?er;e=0<=r?++e:--e)n.push(this.writeByte(t.charCodeAt(e)));return n},t.prototype.readShort=function(){return this.readInt16()},t.prototype.writeShort=function(t){return this.writeInt16(t)},t.prototype.readLongLong=function(){var t,e,r,n,i,a,o,s;return t=this.readByte(),e=this.readByte(),r=this.readByte(),n=this.readByte(),i=this.readByte(),a=this.readByte(),o=this.readByte(),s=this.readByte(),128&t?-1*(72057594037927940*(255^t)+281474976710656*(255^e)+1099511627776*(255^r)+4294967296*(255^n)+16777216*(255^i)+65536*(255^a)+256*(255^o)+(255^s)+1):72057594037927940*t+281474976710656*e+1099511627776*r+4294967296*n+16777216*i+65536*a+256*o+s},t.prototype.writeLongLong=function(t){var e,r;return e=Math.floor(t/4294967296),r=4294967295&t,this.writeByte(e>>24&255),this.writeByte(e>>16&255),this.writeByte(e>>8&255),this.writeByte(255&e),this.writeByte(r>>24&255),this.writeByte(r>>16&255),this.writeByte(r>>8&255),this.writeByte(255&r)},t.prototype.readInt=function(){return this.readInt32()},t.prototype.writeInt=function(t){return this.writeInt32(t)},t.prototype.read=function(t){var e,r;for(e=[],r=0;0<=t?rt;r=0<=t?++r:--r)e.push(this.readByte());return e},t.prototype.write=function(t){var e,r,n,i;for(i=[],r=0,n=t.length;rn;r=0<=n?++r:--r)e={tag:t.readString(4),checksum:t.readInt(),offset:t.readInt(),length:t.readInt()},this.tables[e.tag]=e}return e.prototype.encode=function(e){var r,n,i,a,o,s,c,u,l,h,f,d,p;for(p in f=Object.keys(e).length,s=Math.log(2),l=16*Math.floor(Math.log(f)/s),a=Math.floor(l/s),u=16*f-l,(n=new Te).writeInt(this.scalarType),n.writeShort(f),n.writeShort(l),n.writeShort(a),n.writeShort(u),i=16*f,c=n.pos+i,o=null,d=[],e)for(h=e[p],n.writeString(p),n.writeInt(t(h)),n.writeInt(c),n.writeInt(h.length),d=d.concat(h),"head"===p&&(o=c),c+=h.length;c%4;)d.push(0),c++;return n.write(d),r=2981146554-t(n.data),n.pos=o+8,n.writeUInt32(r),n.data},t=function(t){var e,r,n,i;for(t=tr.call(t);t.length%4;)t.push(0);for(n=new Te(t),r=0,e=0,i=t.length;eh;s=0<=h?++e:--e)r.push(t.readUInt16());return r}(),t.pos+=2,p=function(){var e,r;for(r=[],s=e=0;0<=h?eh;s=0<=h?++e:--e)r.push(t.readUInt16());return r}(),c=function(){var e,r;for(r=[],s=e=0;0<=h?eh;s=0<=h?++e:--e)r.push(t.readUInt16());return r}(),u=function(){var e,r;for(r=[],s=e=0;0<=h?eh;s=0<=h?++e:--e)r.push(t.readUInt16());return r}(),n=(this.length-t.pos+this.offset)/2,o=function(){var e,r;for(r=[],s=e=0;0<=n?en;s=0<=n?++e:--e)r.push(t.readUInt16());return r}(),s=m=0,b=i.length;m=g;r=d<=g?++v:--v)0===u[s]?a=r+c[s]:0!==(a=o[u[s]/2+(r-d)-(h-s)]||0)&&(a+=c[s]),this.codeMap[r]=65535&a}t.pos=l}return t.encode=function(t,e){var r,n,i,a,o,s,c,u,l,h,f,d,p,g,m,v,b,y,w,N,L,A,x,S,_,P,k,F,I,C,j,O,B,M,E,q,D,R,T,U,z,H,W,V,G,Y;switch(F=new Te,a=Object.keys(t).sort((function(t,e){return t-e})),e){case"macroman":for(p=0,g=function(){var t=[];for(d=0;d<256;++d)t.push(0);return t}(),v={0:0},i={},I=0,B=a.length;I=32768)for(s.push(0),N.push(2*(f.length+x-d)),n=O=_;_<=u?O<=u:O>=u;n=_<=u?++O:--O)f.push(r[n].new);else s.push(k-_),N.push(0)}for(F.writeUInt16(3),F.writeUInt16(1),F.writeUInt32(12),F.writeUInt16(4),F.writeUInt16(16+8*x+2*f.length),F.writeUInt16(0),F.writeUInt16(S),F.writeUInt16(A),F.writeUInt16(h),F.writeUInt16(L),z=0,q=l.length;zn;r=0<=n?++r:--r)e=new Ve(t,this.offset),this.tables.push(e),e.isUnicode&&null==this.unicode&&(this.unicode=e);return!0},e.encode=function(t,e){var r,n;return null==e&&(e="macroman"),r=Ve.encode(t,e),(n=new Te).writeUInt16(0),n.writeUInt16(1),r.table=n.data.concat(r.subtable),r},e}(Re),Ye=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return He(e,t),e.prototype.tag="hhea",e.prototype.parse=function(t){return t.pos=this.offset,this.version=t.readInt(),this.ascender=t.readShort(),this.decender=t.readShort(),this.lineGap=t.readShort(),this.advanceWidthMax=t.readShort(),this.minLeftSideBearing=t.readShort(),this.minRightSideBearing=t.readShort(),this.xMaxExtent=t.readShort(),this.caretSlopeRise=t.readShort(),this.caretSlopeRun=t.readShort(),this.caretOffset=t.readShort(),t.pos+=8,this.metricDataFormat=t.readShort(),this.numberOfMetrics=t.readUInt16()},e}(Re),Je=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return He(e,t),e.prototype.tag="OS/2",e.prototype.parse=function(t){if(t.pos=this.offset,this.version=t.readUInt16(),this.averageCharWidth=t.readShort(),this.weightClass=t.readUInt16(),this.widthClass=t.readUInt16(),this.type=t.readShort(),this.ySubscriptXSize=t.readShort(),this.ySubscriptYSize=t.readShort(),this.ySubscriptXOffset=t.readShort(),this.ySubscriptYOffset=t.readShort(),this.ySuperscriptXSize=t.readShort(),this.ySuperscriptYSize=t.readShort(),this.ySuperscriptXOffset=t.readShort(),this.ySuperscriptYOffset=t.readShort(),this.yStrikeoutSize=t.readShort(),this.yStrikeoutPosition=t.readShort(),this.familyClass=t.readShort(),this.panose=function(){var e,r;for(r=[],e=0;e<10;++e)r.push(t.readByte());return r}(),this.charRange=function(){var e,r;for(r=[],e=0;e<4;++e)r.push(t.readInt());return r}(),this.vendorID=t.readString(4),this.selection=t.readShort(),this.firstCharIndex=t.readShort(),this.lastCharIndex=t.readShort(),this.version>0&&(this.ascent=t.readShort(),this.descent=t.readShort(),this.lineGap=t.readShort(),this.winAscent=t.readShort(),this.winDescent=t.readShort(),this.codePageRange=function(){var e,r;for(r=[],e=0;e<2;e=++e)r.push(t.readInt());return r}(),this.version>1))return this.xHeight=t.readShort(),this.capHeight=t.readShort(),this.defaultChar=t.readShort(),this.breakChar=t.readShort(),this.maxContext=t.readShort()},e}(Re),Xe=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return He(e,t),e.prototype.tag="post",e.prototype.parse=function(t){var e,r,n;switch(t.pos=this.offset,this.format=t.readInt(),this.italicAngle=t.readInt(),this.underlinePosition=t.readShort(),this.underlineThickness=t.readShort(),this.isFixedPitch=t.readInt(),this.minMemType42=t.readInt(),this.maxMemType42=t.readInt(),this.minMemType1=t.readInt(),this.maxMemType1=t.readInt(),this.format){case 65536:break;case 131072:var i;for(r=t.readUInt16(),this.glyphNameIndex=[],i=0;0<=r?ir;i=0<=r?++i:--i)this.glyphNameIndex.push(t.readUInt16());for(this.names=[],n=[];t.posr;i=0<=r?++e:--e)n.push(t.readUInt32());return n}.call(this)}},e}(Re),Ke=function(t,e){this.raw=t,this.length=t.length,this.platformID=e.platformID,this.encodingID=e.encodingID,this.languageID=e.languageID},Ze=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return He(e,t),e.prototype.tag="name",e.prototype.parse=function(t){var e,r,n,i,a,o,s,c,u,l,h;for(t.pos=this.offset,t.readShort(),e=t.readShort(),o=t.readShort(),r=[],i=0;0<=e?ie;i=0<=e?++i:--i)r.push({platformID:t.readShort(),encodingID:t.readShort(),languageID:t.readShort(),nameID:t.readShort(),length:t.readShort(),offset:this.offset+o+t.readShort()});for(s={},i=u=0,l=r.length;uo;e=0<=o?++e:--e)this.metrics.push({advance:t.readUInt16(),lsb:t.readInt16()});for(n=this.file.maxp.numGlyphs-this.file.hhea.numberOfMetrics,this.leftSideBearings=function(){var r,i;for(i=[],e=r=0;0<=n?rn;e=0<=n?++r:--r)i.push(t.readInt16());return i}(),this.widths=function(){var t,e,r,n;for(n=[],t=0,e=(r=this.metrics).length;tn;e=0<=n?++a:--a)s.push(this.widths.push(r));return s},e.prototype.forGlyph=function(t){return t in this.metrics?this.metrics[t]:{advance:this.metrics[this.metrics.length-1].advance,lsb:this.leftSideBearings[t-this.metrics.length]}},e}(Re),tr=[].slice,er=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return He(e,t),e.prototype.tag="glyf",e.prototype.parse=function(){return this.cache={}},e.prototype.glyphFor=function(t){var e,r,n,i,a,o,s,c,u,l;return t in this.cache?this.cache[t]:(i=this.file.loca,e=this.file.contents,r=i.indexOf(t),0===(n=i.lengthOf(t))?this.cache[t]=null:(e.pos=this.offset+r,a=(o=new Te(e.read(n))).readShort(),c=o.readShort(),l=o.readShort(),s=o.readShort(),u=o.readShort(),this.cache[t]=-1===a?new nr(o,c,l,s,u):new rr(o,a,c,l,s,u),this.cache[t]))},e.prototype.encode=function(t,e,r){var n,i,a,o,s;for(a=[],i=[],o=0,s=e.length;o0&&(n+=s)}for(var c=new Array(4*r.length),u=0;u>8,c[4*u+1]=(16711680&r[u])>>16,c[4*u]=(4278190080&r[u])>>24;return c},e}(Re),ar=function(){function t(t){this.font=t,this.subset={},this.unicodes={},this.next=33}return t.prototype.generateCmap=function(){var t,e,r,n,i;for(e in n=this.font.cmap.tables[0].codeMap,t={},i=this.subset)r=i[e],t[e]=n[r];return t},t.prototype.glyphsFor=function(t){var e,r,n,i,a,o,s;for(n={},a=0,o=t.length;a0)for(i in s=this.glyphsFor(e))r=s[i],n[i]=r;return n},t.prototype.encode=function(t,e){var r,n,i,a,o,s,c,u,l,h,f,d,p,g,m;for(n in r=Ge.encode(this.generateCmap(),"unicode"),a=this.glyphsFor(t),f={0:0},m=r.charMap)f[(s=m[n]).old]=s.new;for(d in h=r.maxGlyphID,a)d in f||(f[d]=h++);return u=function(t){var e,r;for(e in r={},t)r[t[e]]=e;return r}(f),l=Object.keys(u).sort((function(t,e){return t-e})),p=function(){var t,e,r;for(r=[],t=0,e=l.length;t>"),a.join("\n")}return""+r},e}(),t.AcroForm=xt,t.AcroFormAppearance=Lt,t.AcroFormButton=gt,t.AcroFormCheckBox=yt,t.AcroFormChoiceField=ht,t.AcroFormComboBox=dt,t.AcroFormEditBox=pt,t.AcroFormListBox=ft,t.AcroFormPasswordField=Nt,t.AcroFormPushButton=mt,t.AcroFormRadioButton=vt,t.AcroFormTextField=wt,t.GState=C,t.ShadingPattern=O,t.TilingPattern=B,t.default=M,t.jsPDF=M,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=jspdf.umd.min.js.map
Piece & container settings piece thickness · weight · pallet min/max · container type
Tray capacity = min(piece-count limit, ⌊tray depth ÷ thickness⌋) · 1-ft=12" · 2-ft=24" · flat=11.5" · Pallet groups trays until max weight reached · Sack used when pallet min not met
`, 'USPS_Tray_Labels.html','text/html'); } // ─── Download: statement ────────────────────────────────────────── function dlStatement(){ if(!result)return; const{bd,totalRecs,t1,t2,trays,cfg,mc}=result; const isFCM=mc==='fcm',isMktL=mc==='mktL'; const useFS=document.getElementById('fs').checked,useSCF=document.getElementById('scf').checked; const today=new Date().toLocaleDateString('en-US',{month:'2-digit',day:'2-digit',year:'numeric'}); const p5=bd.filter(t=>t.level==='5-Digit').reduce((s,t)=>s+t.count,0); const pA=bd.filter(t=>t.level==='AADC').reduce((s,t)=>s+t.count,0); const pM=bd.filter(t=>t.level==='Mixed AADC').reduce((s,t)=>s+t.count,0); const p3=bd.filter(t=>t.level==='3-Digit').reduce((s,t)=>s+t.count,0); const pS=bd.filter(t=>t.level==='Single Piece').reduce((s,t)=>s+t.count,0); const r=cfg.rates; const dFS5=useFS?p5*cfg.discounts.fs:0,dFSA=useFS?pA*cfg.discounts.fs:0; const dSCF5=useSCF?p5*cfg.discounts.scf:0,dSCFA=useSCF?pA*cfg.discounts.scf:0; const n5=p5*r.fiveDigit-dFS5-dSCF5,nA=pA*r.aadc-dFSA-dSCFA; const pAT=n5+nA+pM*r.mixed+p3*(r.threeDigit||r.aadc),pBT=pS*r.single,tot=pAT+pBT; const f4=n=>n.toFixed(4),f2=n=>n.toFixed(2); const title=isFCM?'Postage Statement — First-Class Mail':'Postage Statement — USPS Marketing Mail'; const form=isFCM?'PS Form 3600-FCM, January 2026':'PS Form 3600-C, January 2026'; const pr=(ln,d,price,pcs,sub,disc,tot2)=>pcs===0?'':`${ln}${d}$${price.toFixed(3)}${pcs.toLocaleString()}${f4(sub)}${disc>0?f4(disc):''}$${f4(tot2)}`; const dr=(ln,d,pcs,mult,v)=>pcs===0?'':`${ln}${d}${pcs.toLocaleString()}×$${mult.toFixed(3)}=${v>0?f4(v):'—'}`; const pAr=isFCM?pr('A4','5-Digit',r.fiveDigit,p5,p5*r.fiveDigit,dFS5+dSCF5,n5)+pr('A5','AADC',r.aadc,pA,pA*r.aadc,dFSA+dSCFA,nA)+pr('A6','Mixed AADC',r.mixed,pM,pM*r.mixed,0,pM*r.mixed)+(useFS?dr('A20','Full-Service IM',p5+pA,cfg.discounts.fs,dFS5+dFSA):''):isMktL?pr('A1','5-Digit',r.fiveDigit,p5,p5*r.fiveDigit,0,p5*r.fiveDigit)+pr('A2','AADC',r.aadc,pA,pA*r.aadc,0,pA*r.aadc)+pr('A3','Mixed AADC',r.mixed,pM,pM*r.mixed,0,pM*r.mixed):pr('A7','5-Digit',r.fiveDigit,p5,p5*r.fiveDigit,0,p5*r.fiveDigit)+pr('A8','3-Digit',r.threeDigit||r.aadc,p3,p3*(r.threeDigit||r.aadc),0,p3*(r.threeDigit||r.aadc))+pr('A9','AADC',r.aadc,pA,pA*r.aadc,0,pA*r.aadc)+pr('A10','Mixed AADC',r.mixed,pM,pM*r.mixed,0,pM*r.mixed); const aTL=isFCM?'A11':isMktL?'A4':'A11'; const partB=isFCM&&pBT>0?`
Part B
${pr('B6','Single-Piece',r.single,pS,pS*r.single,0,pS*r.single)}
B21Part B Total$${f4(pBT)}
`:''; dlText(`USPS Postage Statement
United States Postal Service
${title}
MAILER
Post OfficeMailing Date${today}Permit No.Move UpdateNCOALink
MAILING
Total Pieces${totalRecs.toLocaleString()}1-ft Trays${t1}2-ft Trays${t2}Total Trays${trays.length}
POSTAGE
Part A
${pAr}
LineCategoryPricePiecesSubtotalDiscountTotal
${aTL}Part A Total$ ${f4(pAT)}
${partB}
Part Z — Discounts
Z15SCF Pallet${(dSCF5+dSCFA)>0?f4(dSCF5+dSCFA):'—'}
Z16Full-Service IM${(dFS5+dFSA)>0?f4(dFS5+dFSA):'—'}
1 Subtotal$ ${f4(tot)}
4 Net Postage Due$ ${f2(tot)}
${form}Generated ${today}
`, 'USPS_Postage_Statement.html','text/html'); } // ═══════════════════════════════════════════════════════════════════════════════ // REPORTS & OUTPUT FILES MODULE // Generates: Mail Sort Listing, USPS Qualification Report, Register of Mailing, // Postal Statement PDF, V3 CSV, V2 CSV, PresortOutput CSV // ═══════════════════════════════════════════════════════════════════════════════ // ── Shared helpers ────────────────────────────────────────────────────────── function rpt_status(msg){ const el=document.getElementById('rpt-status'); if(!el) return; el.textContent=msg; const isErr=msg.startsWith('✗'),isOk=msg.startsWith('✓'); el.style.color=isErr?'var(--text-danger)':isOk?'var(--text-success)':'var(--text2)'; el.style.background=isErr?'var(--bg-danger)':isOk?'var(--bg-success)':'var(--bg2)'; el.style.padding=msg?'4px 8px':'0'; el.style.display=msg?'block':'none'; } function rpt_queueDownload(doc,filename){ try{ const blob=doc.output('blob'); const url=URL.createObjectURL(blob); const links=document.getElementById('rpt-links'); const dl=document.getElementById('rpt-downloads'); if(!links||!dl) return; const a=document.createElement('a'); a.href=url; a.download=filename; const label=filename.replace(/_\d+/g,'').replace('.pdf','').replace(/_/g,' '); a.textContent='⬇ '+label; a.style.cssText='display:inline-block;padding:5px 10px;background:var(--bg-info);color:var(--text-info);border:0.5px solid var(--border-info);border-radius:4px;font-size:11px;font-weight:500;text-decoration:none;cursor:pointer;white-space:nowrap'; links.appendChild(a); dl.style.display='block'; }catch(e){console.error('rpt_queueDownload:',e);} } function rpt_clearDownloads(){ const links=document.getElementById('rpt-links'); const dl=document.getElementById('rpt-downloads'); if(links) links.innerHTML=''; if(dl) dl.style.display='none'; } function rpt_today(){ const d=new Date(); const mon=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; return `${String(d.getDate()).padStart(2,'0')}-${mon[d.getMonth()]}-${d.getFullYear()}`; } function rpt_todayFull(){ const d=new Date(); return `${String(d.getMonth()+1).padStart(2,'0')}/${String(d.getDate()).padStart(2,'0')}/${d.getFullYear()}`; } function rpt_pad(s,n,r=false){ s=String(s||''); return r ? s.padStart(n,' ').substring(0,n) : s.padEnd(n,' ').substring(0,n); } function rpt_f2(n){ return (+(n||0)).toFixed(2); } function rpt_f3(n){ return (+(n||0)).toFixed(3); } function rpt_f4(n){ return (+(n||0)).toFixed(4); } // ── jsPDF colour constants ──────────────────────────────────────────────────── const RPT_USPS_BLUE = [0, 51, 128]; const RPT_USPS_RED = [187, 0, 0]; const RPT_GRAY = [80, 80, 80]; const RPT_LGRAY = [220, 220, 220]; const RPT_DGRAY = [50, 50, 50]; const RPT_WHITE = [255, 255, 255]; const RPT_CREAM = [250, 248, 242]; const RPT_HLBLUE = [235, 243, 255]; // ── jsPDF drawing helpers ───────────────────────────────────────────────────── function rpt_doc(orientation='portrait'){ const {jsPDF}=window.jspdf; return new jsPDF({unit:'pt',format:'letter',orientation}); } function rpt_setFont(doc,weight='normal',size=9){ doc.setFont('helvetica',weight); doc.setFontSize(size); } function rpt_hline(doc,x1,y,x2,thick=0.5,color){ doc.setDrawColor(...(color||RPT_LGRAY)); doc.setLineWidth(thick); doc.line(x1,y,x2,y); } function rpt_vline(doc,x,y1,y2,thick=0.5,color){ doc.setDrawColor(...(color||RPT_LGRAY)); doc.setLineWidth(thick); doc.line(x,y1,x,y2); } function rpt_rect(doc,x,y,w,h,fill,stroke){ if(fill){ doc.setFillColor(...fill); doc.rect(x,y,w,h,stroke?'FD':'F'); } else{ doc.setDrawColor(...(stroke||RPT_LGRAY)); doc.setLineWidth(0.5); doc.rect(x,y,w,h,'S'); } } function rpt_text(doc,txt,x,y,opts){ opts=opts||{}; doc.setTextColor(...(opts.color||RPT_DGRAY)); doc.setFont('helvetica',opts.weight||'normal'); doc.setFontSize(opts.size||9); const align=opts.align||'left'; doc.text(String(txt),x,y,{align:align==='right'?'right':align==='center'?'center':'left'}); } function rpt_pageHeader(doc,title,sub,pg,pgTotal,PW){ doc.setFillColor(...RPT_USPS_BLUE); doc.rect(0,0,PW,30,'F'); doc.setTextColor(255,255,255); doc.setFont('helvetica','bold'); doc.setFontSize(8); doc.text('United States Postal Service',10,11); doc.text(title,10,22); if(sub){ doc.setFont('helvetica','normal'); doc.setFontSize(7); doc.text(sub,PW/2,18,{align:'center'}); } doc.setFont('helvetica','normal'); doc.setFontSize(7); doc.text('Page '+(pg||1)+(pgTotal?' of '+pgTotal:''),PW-10,18,{align:'right'}); } function rpt_sectionBar(doc,label,x,y,w,h){ h=h||15; doc.setFillColor(...RPT_USPS_BLUE); doc.rect(x,y,w,h,'F'); doc.setTextColor(255,255,255); doc.setFont('helvetica','bold'); doc.setFontSize(8); doc.text(label,x+5,y+h-4); return y+h; } function rpt_fieldRow(doc,label,value,x,y,lw,vw,h,bg){ h=h||14; if(bg){ doc.setFillColor(...bg); doc.rect(x,y,lw+vw,h,'F'); } doc.setDrawColor(...RPT_LGRAY); doc.setLineWidth(0.3); doc.line(x,y+h,x+lw+vw,y+h); doc.setFont('helvetica','bold'); doc.setFontSize(7); doc.setTextColor(...RPT_GRAY); doc.text(label,x+3,y+h-5); if(value){ doc.setFont('helvetica','normal'); doc.setFontSize(8); doc.setTextColor(...RPT_DGRAY); doc.text(String(value),x+lw+3,y+h-4); } return y+h; } function rpt_getInfo(){ if(!result) return null; const {bd,trays,allContainers,totalRecs,total,cfg,mc,cs} = result; const jobId = document.getElementById('md-jobid')?.value || '00000001'; const mid = document.getElementById('md-mid')?.value || '105957000'; const entryPO = document.getElementById('entryPO')?.value || 'NEW ORLEANS, LA 70113-9998'; const today = rpt_today(); const todayFull = rpt_todayFull(); // Tray-level summary const levels = {}; for(const t of bd){ const k = t.level; if(!levels[k]) levels[k]={count:0, pcs:0, sub:0}; levels[k].count++; levels[k].pcs+=t.count; levels[k].sub+=t.sub||0; } return {bd,trays,allContainers,totalRecs,total,cfg,mc,cs,jobId,mid,entryPO,today,todayFull,levels}; } // ── Level abbreviation mapping ──────────────────────────────────────────── const RPT_LVL = { '5-Digit Scheme':'5DGS', '5-Digit':'5DG', '3-Digit':'3DG', 'AADC':'AADC', 'Mixed AADC':'MAAD', 'Single Piece':'SGL', 'Non-automation residual':'SGL' }; const RPT_COL = { '5-Digit Scheme':'5B', '5-Digit':'5B', '3-Digit':'3D', 'AADC':'AD', 'Mixed AADC':'MD', 'Single Piece':'MB' }; // ───────────────────────────────────────────────────────────────────────────── // 1. MAIL SORT LISTING // ───────────────────────────────────────────────────────────────────────────── // ───────────────────────────────────────────────────────────────────────────── // 1. MAIL SORT LISTING — exact match to USPS MFL format // Tray-level production listing, packages inline, running totals // Reference: 01515178_Mail_Sort_Listing.pdf, 01515160_Mail_Sort_Listing.pdf // ───────────────────────────────────────────────────────────────────────────── // ───────────────────────────────────────────────────────────────────────────── // 2. USPS QUALIFICATION REPORT — per-tray, per-ZIP detail with running totals // Reference: 01515178_USPS_Qualification_Report.pdf // Columns: Tray | Size | Lvl | Zip Dest | Group | WS|HDP|HD|CR|5B|AB|MB|5D|3D|AD|MD | Running // ───────────────────────────────────────────────────────────────────────────── function rpt_qualificationReport(){ const info = rpt_getInfo(); if(!info){ rpt_status('✗ Run presort first — load a job and click Run.'); return; } if(!window.jspdf){ rpt_status('✗ jsPDF library not available. Please reload the page.'); return; } const {bd,totalRecs,cfg,entryPO,today,jobId} = info; const mcLabel = cfg?.label||'USPS Marketing Mail Letters'; const dmmRef = mcLabel.includes('First')?'245.3':mcLabel.includes('Flat')?'245.8':'245.7'; try{ const doc = rpt_doc('landscape'); const PW=792, PH=612, ML=18, MR=18, MT=46, MB=20; const TW=PW-ML-MR; // Column layout — matches reference exactly const COLS=[ {k:'tray',lbl:'Tray\nNo.', w:28, align:'right'}, {k:'size',lbl:'Tray\nSize', w:28, align:'left'}, {k:'lvl', lbl:'Tray\nLvl', w:28, align:'left'}, {k:'dest',lbl:'Zip Dest', w:52, align:'left'}, {k:'grp', lbl:'Group\nID', w:22, align:'center'}, {k:'WS', lbl:'WS', w:24, align:'right'}, {k:'HDP', lbl:'HDP', w:26, align:'right'}, {k:'HD', lbl:'HD', w:24, align:'right'}, {k:'CR', lbl:'CR', w:24, align:'right'}, {k:'5B', lbl:'5B', w:32, align:'right'}, {k:'AB', lbl:'AB', w:32, align:'right'}, {k:'MB', lbl:'MB', w:28, align:'right'}, {k:'5D', lbl:'5D', w:24, align:'right'}, {k:'3D', lbl:'3D', w:24, align:'right'}, {k:'AD', lbl:'AD', w:32, align:'right'}, {k:'MD', lbl:'MD', w:28, align:'right'}, {k:'run', lbl:'Running\nTotals', w:48, align:'right'}, ]; let cx=ML; COLS.forEach(c=>{c.x=cx;cx+=c.w;}); const tableW=cx-ML; const ROW_H=10, HDR_H=18; const COL_FOR=(lvl)=>RPT_COL[lvl]||'AD'; const totals={WS:0,HDP:0,HD:0,CR:0,'5B':0,AB:0,MB:0,'5D':0,'3D':0,AD:0,MD:0}; let pgTots={WS:0,HDP:0,HD:0,CR:0,'5B':0,AB:0,MB:0,'5D':0,'3D':0,AD:0,MD:0}; let running=0, trayNo=0, pg=1, y=MT, rowIdx=0; function drawPageHeader(){ // Navy band doc.setFillColor(...RPT_USPS_BLUE); doc.rect(0,0,PW,28,'F'); doc.setTextColor(255,255,255); doc.setFont('helvetica','bold'); doc.setFontSize(9); doc.text('USPS Qualification Report',ML,12); doc.setFont('helvetica','normal'); doc.setFontSize(7); doc.text(`${mcLabel} (DMM ${dmmRef}) · ${entryPO}`,ML,20); doc.text(`Page ${pg}`,PW-MR,18,{align:'right'}); // Sub row doc.setFillColor(240,244,252); doc.rect(0,28,PW,16,'F'); doc.setTextColor(...RPT_GRAY); doc.setFontSize(7); doc.text(`Job ID: ${jobId}`,ML,38); doc.text(`Date: ${today}`,PW-MR,38,{align:'right'}); // Column header row const hy=MT; doc.setFillColor(230,236,250); doc.rect(ML,hy,tableW,HDR_H,'F'); doc.setDrawColor(...RPT_USPS_BLUE); doc.setLineWidth(0.8); doc.line(ML,hy,ML+tableW,hy); doc.line(ML,hy+HDR_H,ML+tableW,hy+HDR_H); COLS.forEach(c=>{ const tx=c.align==='right'?c.x+c.w-2:c.align==='center'?c.x+c.w/2:c.x+2; doc.setFont('helvetica','bold'); doc.setFontSize(6); doc.setTextColor(...RPT_USPS_BLUE); const lines=c.lbl.split('\n'); lines.forEach((l,i)=>doc.text(l,tx,hy+7+i*7,{align:c.align==='center'?'center':c.align==='right'?'right':'left'})); if(c!==COLS[COLS.length-1]){ doc.setDrawColor(...RPT_LGRAY); doc.setLineWidth(0.3); doc.line(c.x+c.w,hy,c.x+c.w,hy+HDR_H); } }); return hy+HDR_H; } function flushPageTotals(){ const ty=y+2; doc.setFillColor(240,244,252); doc.rect(ML,ty,tableW,ROW_H+2,'F'); doc.setDrawColor(...RPT_USPS_BLUE); doc.setLineWidth(0.8); doc.line(ML,ty,ML+tableW,ty); doc.setFont('helvetica','bold'); doc.setFontSize(6.5); doc.setTextColor(...RPT_USPS_BLUE); doc.text('Page Total',ML+2,ty+ROW_H-1); const vks=['WS','HDP','HD','CR','5B','AB','MB','5D','3D','AD','MD']; vks.forEach(k=>{ const c=COLS.find(c=>c.k===k); if(!c||!pgTots[k]) return; doc.text(pgTots[k].toLocaleString(),c.x+c.w-2,ty+ROW_H-1,{align:'right'}); }); doc.setDrawColor(...RPT_LGRAY); doc.line(ML,ty+ROW_H+2,ML+tableW,ty+ROW_H+2); y=ty+ROW_H+4; } function needPage(extra=1){ if(y+extra*ROW_H > PH-MB-20){ flushPageTotals(); pgTots={WS:0,HDP:0,HD:0,CR:0,'5B':0,AB:0,MB:0,'5D':0,'3D':0,AD:0,MD:0}; doc.addPage('letter','landscape'); pg++; y=drawPageHeader(); rowIdx=0; } } y=drawPageHeader(); for(const t of bd){ trayNo++; const lvl =RPT_LVL[t.level]||'AADC'; const col =COL_FOR(t.level); const sz =(t.size||'1-ft').replace('-ft','\'').replace('ft','\''); const byZip={}; for(const r of (t.records||[])) byZip[r.zip5]=(byZip[r.zip5]||0)+1; const zips=Object.keys(byZip).sort(); let first=true; for(const z of zips){ needPage(1); const pcs=byZip[z]; running+=pcs; pgTots[col]=(pgTots[col]||0)+pcs; totals[col]=(totals[col]||0)+pcs; const vals={WS:0,HDP:0,HD:0,CR:0,'5B':0,AB:0,MB:0,'5D':0,'3D':0,AD:0,MD:0}; vals[col]=pcs; // Alternating row bg if(rowIdx%2!==0){doc.setFillColor(248,249,252);doc.rect(ML,y,tableW,ROW_H,'F');} COLS.forEach(c=>{ let v=''; if(c.k==='tray'&&first) v=String(trayNo); else if(c.k==='size'&&first) v=sz; else if(c.k==='lvl'&&first) v=lvl; else if(c.k==='dest') v=z; else if(c.k==='grp') v='2'; else if(c.k==='run') v=running.toLocaleString(); else if(vals[c.k]) v=vals[c.k].toLocaleString(); if(!v) return; const tx=c.align==='right'?c.x+c.w-2:c.align==='center'?c.x+c.w/2:c.x+2; const key5b=(c.k==='5B'||c.k==='AB'||c.k==='MB')&&vals[c.k]; doc.setFont('helvetica',key5b?'bold':'normal'); doc.setFontSize(6.5); doc.setTextColor(key5b?RPT_USPS_BLUE:RPT_DGRAY); doc.text(v,tx,y+ROW_H-2,{align:c.align==='center'?'center':c.align==='right'?'right':'left'}); }); doc.setDrawColor(238,238,238); doc.setLineWidth(0.2); doc.line(ML,y+ROW_H,ML+tableW,y+ROW_H); y+=ROW_H; rowIdx++; first=false; } } // Final page totals flushPageTotals(); y+=6; // Mailing Rate Summary doc.setFillColor(...RPT_USPS_BLUE); doc.rect(ML,y,tableW,12,'F'); doc.setTextColor(255,255,255); doc.setFont('helvetica','bold'); doc.setFontSize(7.5); doc.text('Mailing Rate Summary',ML+3,y+9); y+=14; const sumRows=[ ['Automation 5-Digit/Scheme (5B)', totals['5B']||0], ['Automation AADC (AB)', totals['AB']||0], ['Mixed Automation ADC (MB)', totals['MB']||0], ['Carrier Route (CR)', totals['CR']||0], ['3-Digit (3D)', totals['3D']||0], ['ADC / Single Piece (AD+MD)', (totals['AD']||0)+(totals['MD']||0)], ].filter(r=>r[1]>0); sumRows.push(['GRAND TOTAL', running]); sumRows.forEach((r,i)=>{ const isGT=i===sumRows.length-1; if(isGT){doc.setFillColor(...RPT_HLBLUE);doc.rect(ML,y,280,14,'F');} doc.setFont('helvetica',isGT?'bold':'normal'); doc.setFontSize(8); doc.setTextColor(isGT?RPT_USPS_BLUE:RPT_DGRAY); doc.text(r[0],ML+4,y+10); doc.setFont('helvetica','bold'); doc.text(r[1].toLocaleString(),ML+236,y+10,{align:'right'}); doc.setDrawColor(...RPT_LGRAY); doc.line(ML,y+14,ML+280,y+14); y+=14; }); doc.setFont('helvetica','normal'); doc.setFontSize(6.5); doc.setTextColor(...RPT_GRAY); doc.text(`USPS Qualification Report · Presort Engine · ${today} · Job ${jobId}`,PW/2,PH-10,{align:'center'}); rpt_queueDownload(doc, `USPS_Qualification_Report_${jobId||'job'}.pdf`); rpt_status(`✓ Qualification Report ready (${trayNo} trays, ${running.toLocaleString()} pcs)`); }catch(e){ console.error("rpt_qualificationReport error:",e); rpt_status("✗ Error generating report: "+e.message); } } // ───────────────────────────────────────────────────────────────────────────── // rpt_generatePDF — plain-text to PDF (used by any text-based fallback reports) // ───────────────────────────────────────────────────────────────────────────── function rpt_generatePDF(filename, bodyText, title){ const jspdf=window.jspdf; if(jspdf&&jspdf.jsPDF){ const{jsPDF}=jspdf; const doc=new jsPDF({unit:'pt',format:'letter',orientation:'landscape'}); const PW=792,PH=612,ML=28,MT=40,MB=28,FS=6.5,LH=FS*1.42; const usableH=PH-MT-MB,linesPerPage=Math.floor(usableH/LH); function drawBand(pg,txt){ doc.setFillColor(...RPT_USPS_BLUE);doc.rect(0,0,PW,26,'F'); doc.setTextColor(255,255,255);doc.setFont('helvetica','bold');doc.setFontSize(9); doc.text(txt,ML,17); doc.setFont('helvetica','normal');doc.setFontSize(7); doc.text(`Page ${pg}`,PW-ML,17,{align:'right'}); doc.setTextColor(...RPT_DGRAY); } doc.setFont('courier','normal');doc.setFontSize(FS); const allLines=bodyText.split('\n'); let pg2=1,lineOnPage=0; drawBand(pg2,title); for(const line of allLines){ if(lineOnPage>=linesPerPage){ doc.addPage('letter','landscape');pg2++;lineOnPage=0;drawBand(pg2,title); } const ly=MT+lineOnPage*LH; const safe=line.substring(0,195); doc.setTextColor(...RPT_DGRAY); doc.text(safe,ML,ly); lineOnPage++; } rpt_queueDownload(doc, `${filename}.pdf`); } else { dlText(bodyText,`${filename}.txt`,'text/plain'); } } // ───────────────────────────────────────────────────────────────────────────── // REPORT DRAWING PRIMITIVES — standalone (no nested functions, no try/catch) // These are called by report functions with explicit doc + coordinate params // ───────────────────────────────────────────────────────────────────────────── function _rpt_navyBand(doc,PW,title,subtitle,pg,jobId,today){ doc.setFillColor(0,51,128); doc.rect(0,0,PW,28,'F'); doc.setTextColor(255,255,255); doc.setFont('helvetica','bold'); doc.setFontSize(9); doc.text(String(title),18,12); doc.setFont('helvetica','normal'); doc.setFontSize(7); if(subtitle) doc.text(String(subtitle),18,21); doc.text('Page '+pg, PW-18, 18, {align:'right'}); doc.setFillColor(240,244,252); doc.rect(0,28,PW,14,'F'); doc.setTextColor(50,50,50); doc.setFontSize(6.5); doc.text('Job: '+jobId, 18, 38); doc.text('Date: '+today, PW-18, 38, {align:'right'}); } function _rpt_colHeaders(doc, COLS, tableW, ML, hy, HDR_H){ doc.setFillColor(230,236,250); doc.rect(ML,hy,tableW,HDR_H,'F'); doc.setDrawColor(0,51,128); doc.setLineWidth(0.8); doc.line(ML,hy,ML+tableW,hy); doc.line(ML,hy+HDR_H,ML+tableW,hy+HDR_H); COLS.forEach(function(c){ var tx = c.align==='right' ? c.x+c.w-2 : c.align==='center' ? c.x+c.w/2 : c.x+2; doc.setFont('helvetica','bold'); doc.setFontSize(6); doc.setTextColor(0,51,128); var lines = c.lbl.split('\n'); lines.forEach(function(l,i){ doc.text(String(l), tx, hy+7+i*7, {align: c.align==='center'?'center': c.align==='right'?'right':'left'}); }); doc.setDrawColor(220,220,220); doc.setLineWidth(0.3); doc.line(c.x+c.w, hy, c.x+c.w, hy+HDR_H); }); } function _rpt_pageTotalsBar(doc, pgTots, COLS, tableW, ML, ROW_H, y){ doc.setFillColor(240,244,252); doc.rect(ML,y,tableW,ROW_H+2,'F'); doc.setDrawColor(0,51,128); doc.setLineWidth(0.8); doc.line(ML,y,ML+tableW,y); doc.setFont('helvetica','bold'); doc.setFontSize(6.5); doc.setTextColor(0,51,128); doc.text('Page Total', ML+2, y+ROW_H-1); COLS.forEach(function(c){ if(pgTots[c.k]) doc.text(String(pgTots[c.k].toLocaleString()), c.x+c.w-2, y+ROW_H-1, {align:'right'}); }); doc.setDrawColor(220,220,220); doc.line(ML,y+ROW_H+2,ML+tableW,y+ROW_H+2); } function _rpt_sectionBanner(doc,label,x,y,w,h,ML2){ h=h||12; ML2=ML2||x; doc.setFillColor(0,51,128); doc.rect(x,y,w,h,'F'); doc.setTextColor(255,255,255); doc.setFont('helvetica','bold'); doc.setFontSize(8); doc.text(String(label), ML2+4, y+h-3); return y+h; } function _rpt_fieldPair(doc,label,value,x,y,lw,fw,h,bg){ h=h||14; if(bg){ doc.setFillColor(bg[0],bg[1],bg[2]); doc.rect(x,y,lw+fw,h,'F'); } doc.setDrawColor(210,210,210); doc.setLineWidth(0.3); doc.line(x,y+h,x+lw+fw,y+h); doc.setFont('helvetica','bold'); doc.setFontSize(6.5); doc.setTextColor(100,100,100); doc.text(String(label), x+3, y+h-5); if(value!==null && value!==undefined && value!==''){ doc.setFont('helvetica','normal'); doc.setFontSize(8.5); doc.setTextColor(50,50,50); doc.text(String(value), x+lw+3, y+h-3); } return y+h; } // ───────────────────────────────────────────────────────────────────────────── // 1. MAIL SORT LISTING // ───────────────────────────────────────────────────────────────────────────── function rpt_mailSortListing(){ if(!result){ rpt_status('✗ Run presort first.'); return; } if(!window.jspdf){ rpt_status('✗ jsPDF not loaded — reload page.'); return; } var info=rpt_getInfo(); if(!info) return; var bd=info.bd, totalRecs=info.totalRecs, cfg=info.cfg; var entryPO=info.entryPO, today=info.today, jobId=info.jobId; var mcLabel=cfg&&cfg.label?cfg.label:'USPS Marketing Mail Letters'; var isFCM=mcLabel.indexOf('First')>=0; var dmmRef=isFCM?'705.8':mcLabel.indexOf('Flat')>=0?'245.8':'245.7'; var wtLbs=result&&result.cs?result.cs.wtLbs:0.025; var doc=new window.jspdf.jsPDF({unit:'pt',format:'letter',orientation:'landscape'}); var PW=792,PH=612,ML=18,MR=18,MT=46,MB=20,TW=PW-ML-MR; var FS=6.5,LH=9.5; var COL={ pallet:{x:ML,w:26},prep:{x:ML+26,w:16},lvl:{x:ML+42,w:26}, dest:{x:ML+68,w:50},tray:{x:ML+118,w:24},size:{x:ML+142,w:28}, pkgs:{x:ML+170,w:24},copies:{x:ML+194,w:36}, pkg0:{x:ML+233,w:100},pkg1:{x:ML+333,w:100}, pkg2:{x:ML+433,w:100},pkg3:{x:ML+533,w:100},pkg4:{x:ML+633,w:100} }; var PLT={'5-Digit Scheme':'PS5','5-Digit':'PS5','AADC':'BAS','Mixed AADC':'MXD','3-Digit':'PS3','Single Piece':'MXD'}; var pg=1,y=MT; var runTrays=0,runPkgs=0,runCopies=0; function drawHdr(){ _rpt_navyBand(doc,PW,'Mail Sort Listing [MFL]', 'Presort: STD, '+mcLabel+' (DMM '+dmmRef+')',pg,jobId,today); doc.setFillColor(240,244,252); doc.rect(0,28,PW,16,'F'); doc.setTextColor(0,51,128); doc.setFontSize(7); doc.setFont('helvetica','normal'); doc.text('Entry Point: '+entryPO, ML, 37); // Column headers var hy=MT; doc.setFillColor(230,236,250); doc.rect(ML,hy,TW,16,'F'); doc.setDrawColor(0,51,128); doc.setLineWidth(0.8); doc.line(ML,hy,ML+TW,hy); doc.line(ML,hy+16,ML+TW,hy+16); doc.setFont('helvetica','bold'); doc.setFontSize(6); doc.setTextColor(0,51,128); var hdrs=[['pallet','Pallet'],['prep','Prep'],['lvl','Lvl'],['dest','Destination'], ['tray','Tray#'],['size','Size'],['pkgs','Pkgs'],['copies','Copies'], ['pkg0','Pkg/Dest/Copies']]; hdrs.forEach(function(h){ doc.text(h[1], COL[h[0]].x+2, hy+11); }); doc.setTextColor(50,50,50); return hy+18; } y=drawHdr(); bd.forEach(function(t){ if(y+LH > PH-MB-20){ pg++; doc.addPage('letter','landscape'); y=drawHdr(); } var trayNo=t.trayNo||0; var lvl=RPT_LVL[t.level]||t.level.substring(0,4).toUpperCase(); var pltLbl=PLT[t.level]||'MXD'; var dest=(t.key||'').substring(0,8); var sz=(t.size||'1-ft').replace('-ft',"'"); var prep=sz.indexOf('U')>=0?'P':'L'; // Packages var maxPkg=150, cnt=t.count||0; var numPkgs=Math.max(1,Math.ceil(cnt/maxPkg)); var base=Math.floor(cnt/numPkgs), rem=cnt-base*numPkgs; var pkgs=[]; for(var pi=0;pi=0; var dmmRef=isFCM?'245.3':mcLabel.indexOf('Flat')>=0?'245.8':'245.7'; var doc=new window.jspdf.jsPDF({unit:'pt',format:'letter',orientation:'landscape'}); var PW=792,PH=612,ML=18,MR=18,MT=46,MB=20,TW=PW-ML-MR; // Build COLS with x positions var COLS=[ {k:'tray',lbl:'Tray\nNo.', w:28,align:'right'}, {k:'size',lbl:'Tray\nSize', w:28,align:'left'}, {k:'lvl', lbl:'Tray\nLvl', w:28,align:'left'}, {k:'dest',lbl:'Zip Dest', w:52,align:'left'}, {k:'grp', lbl:'Group', w:22,align:'center'}, {k:'WS', lbl:'WS', w:24,align:'right'}, {k:'HDP', lbl:'HDP', w:26,align:'right'}, {k:'HD', lbl:'HD', w:24,align:'right'}, {k:'CR', lbl:'CR', w:24,align:'right'}, {k:'5B', lbl:'5B', w:32,align:'right'}, {k:'AB', lbl:'AB', w:32,align:'right'}, {k:'MB', lbl:'MB', w:28,align:'right'}, {k:'5D', lbl:'5D', w:24,align:'right'}, {k:'3D', lbl:'3D', w:24,align:'right'}, {k:'AD', lbl:'AD', w:32,align:'right'}, {k:'MD', lbl:'MD', w:28,align:'right'}, {k:'run', lbl:'Running\nTotals',w:48,align:'right'}, ]; var cx=ML; COLS.forEach(function(c){ c.x=cx; cx+=c.w; }); var tableW=cx-ML; var ROW_H=10, HDR_H=18; var totals={WS:0,HDP:0,HD:0,CR:0,'5B':0,AB:0,MB:0,'5D':0,'3D':0,AD:0,MD:0}; var pgTots={WS:0,HDP:0,HD:0,CR:0,'5B':0,AB:0,MB:0,'5D':0,'3D':0,AD:0,MD:0}; var running=0,trayNo=0,pg=1,rowIdx=0; function drawHdr(){ _rpt_navyBand(doc,PW,'USPS Qualification Report', mcLabel+' (DMM '+dmmRef+') · '+entryPO, pg, jobId, today); _rpt_colHeaders(doc, COLS, tableW, ML, MT, HDR_H); return MT+HDR_H; } var y=drawHdr(); function flushPgTotals(){ var ty=y+2; _rpt_pageTotalsBar(doc, pgTots, COLS, tableW, ML, ROW_H, ty); y=ty+ROW_H+4; pgTots={WS:0,HDP:0,HD:0,CR:0,'5B':0,AB:0,MB:0,'5D':0,'3D':0,AD:0,MD:0}; } var COL_MAP={'5-Digit Scheme':'5B','5-Digit':'5B','3-Digit':'3D','AADC':'AB','Mixed AADC':'MB','Single Piece':'MB','Non-automation residual':'MB'}; bd.forEach(function(t){ trayNo++; var lvl=RPT_LVL[t.level]||'AADC'; var col=COL_MAP[t.level]||'AD'; var sz=(t.size||'1-ft').replace('-ft',"'"); var byZip={}; (t.records||[]).forEach(function(r){ byZip[r.zip5]=(byZip[r.zip5]||0)+1; }); var zips=Object.keys(byZip).sort(); var first=true; zips.forEach(function(z){ if(y+ROW_H > PH-MB-20){ flushPgTotals(); pg++; doc.addPage('letter','landscape'); y=drawHdr(); rowIdx=0; } var pcs=byZip[z]; running+=pcs; pgTots[col]=(pgTots[col]||0)+pcs; totals[col]=(totals[col]||0)+pcs; var vals={}; vals[col]=pcs; if(rowIdx%2!==0){ doc.setFillColor(248,249,252); doc.rect(ML,y,tableW,ROW_H,'F'); } COLS.forEach(function(c){ var v=''; if(c.k==='tray'&&first) v=String(trayNo); else if(c.k==='size'&&first) v=sz; else if(c.k==='lvl'&&first) v=lvl; else if(c.k==='dest') v=z; else if(c.k==='grp') v='2'; else if(c.k==='run') v=running.toLocaleString(); else if(vals[c.k]) v=vals[c.k].toLocaleString(); if(!v) return; var tx=c.align==='right'?c.x+c.w-2:c.align==='center'?c.x+c.w/2:c.x+2; var isKey=(c.k==='5B'||c.k==='AB'||c.k==='MB')&&vals[c.k]; doc.setFont('helvetica',isKey?'bold':'normal'); doc.setFontSize(6.5); doc.setTextColor(isKey?0:50, isKey?51:50, isKey?128:50); doc.text(v, tx, y+ROW_H-2, {align:c.align==='right'?'right':c.align==='center'?'center':'left'}); }); doc.setDrawColor(238,238,238); doc.setLineWidth(0.2); doc.line(ML,y+ROW_H,ML+tableW,y+ROW_H); y+=ROW_H; rowIdx++; first=false; }); }); flushPgTotals(); y+=6; // Summary doc.setFillColor(0,51,128); doc.rect(ML,y,tableW,12,'F'); doc.setTextColor(255,255,255); doc.setFont('helvetica','bold'); doc.setFontSize(7.5); doc.text('Mailing Rate Summary',ML+3,y+9); y+=14; var sumRows=[ ['Automation 5-Digit/Scheme (5B)', totals['5B']||0], ['Automation AADC (AB)', totals['AB']||0], ['Mixed Automation ADC (MB)', totals['MB']||0], ['Carrier Route / Other', (totals['CR']||0)+(totals['AD']||0)+(totals['MD']||0)], ].filter(function(r){ return r[1]>0; }); sumRows.push(['GRAND TOTAL', running]); sumRows.forEach(function(r,i){ var isGT=i===sumRows.length-1; if(isGT){ doc.setFillColor(235,243,255); doc.rect(ML,y,300,14,'F'); } doc.setFont('helvetica',isGT?'bold':'normal'); doc.setFontSize(8); doc.setTextColor(isGT?0:50, isGT?51:50, isGT?128:50); doc.text(r[0], ML+4, y+10); doc.setFont('helvetica','bold'); doc.text(r[1].toLocaleString(), ML+252, y+10, {align:'right'}); doc.setDrawColor(220,220,220); doc.line(ML,y+14,ML+300,y+14); y+=14; }); doc.setFont('helvetica','normal'); doc.setFontSize(6.5); doc.setTextColor(150,150,150); doc.text('USPS Qualification Report · Presort Engine · '+today+' · Job '+jobId, PW/2, PH-10, {align:'center'}); rpt_queueDownload(doc, 'USPS_Qualification_Report_'+jobId+'.pdf'); rpt_status('✓ Qualification Report ready ('+trayNo+' trays, '+running.toLocaleString()+' pcs)'); } // ───────────────────────────────────────────────────────────────────────────── // 3. REGISTER OF MAILINGS — detailed single-page landscape summary // ───────────────────────────────────────────────────────────────────────────── function rpt_registerOfMailing(){ if(!result){ rpt_status('✗ Run presort first.'); return; } if(!window.jspdf){ rpt_status('✗ jsPDF not loaded — reload page.'); return; } var info=rpt_getInfo(); if(!info) return; var bd=info.bd, totalRecs=info.totalRecs, total=info.total; var cfg=info.cfg, entryPO=info.entryPO, today=info.today; var todayFull=info.todayFull, jobId=info.jobId, levels=info.levels; var mcLabel=cfg&&cfg.label?cfg.label:'USPS Marketing Mail Letters'; var isNP=mcLabel.toLowerCase().indexOf('nonprofit')>=0; var isFCM=mcLabel.toLowerCase().indexOf('first')>=0; var t1=bd.filter(function(t){return t.size==='1-ft';}).length; var t2=bd.filter(function(t){return t.size==='2-ft';}).length; var wtLbs=result&&result.cs?result.cs.wtLbs:0.025; var totalWt=(totalRecs*wtLbs).toFixed(4); var permitNo=document.getElementById('md-permit')&&document.getElementById('md-permit').value?document.getElementById('md-permit').value:'—'; var doc=new window.jspdf.jsPDF({unit:'pt',format:'letter',orientation:'landscape'}); var PW=792,PH=612,ML=28,MR=28,MT=44,MB=28,TW=PW-ML-MR; var y=MT; // Header doc.setFillColor(0,51,128); doc.rect(0,0,PW,30,'F'); doc.setTextColor(255,255,255); doc.setFont('helvetica','bold'); doc.setFontSize(11); doc.text('Register of Mailings [MFL]', ML, 13); doc.setFont('helvetica','normal'); doc.setFontSize(7.5); doc.text('Page 1', PW-MR, 18, {align:'right'}); doc.text('Job: '+jobId+' · '+today, ML, 22); doc.setFillColor(240,244,252); doc.rect(0,30,PW,14,'F'); doc.setTextColor(0,51,128); doc.setFontSize(7); doc.text('TEC PROJECT #: '+jobId, ML, 40); doc.text(today, PW/2, 40, {align:'center'}); doc.text('Entry Point: '+entryPO, PW-MR, 40, {align:'right'}); doc.setDrawColor(0,51,128); doc.setLineWidth(1); doc.line(0,44,PW,44); y=50; // Number of statements doc.setTextColor(50,50,50); doc.setFont('helvetica','normal'); doc.setFontSize(8); doc.text('Number of Statements: 1', ML, y); y+=10; doc.text('Sequence Number Range: 0001 to 0001', ML, y); y+=14; // ── Main table ────────────────────────────────────────────────────────────── var COLS=[ {lbl:'Sequence\nNumber', w:52, align:'center'}, {lbl:'Entry Post Office', w:160, align:'left'}, {lbl:'Sacks', w:36, align:'right'}, {lbl:'Trays', w:36, align:'right'}, {lbl:'Pallets', w:40, align:'right'}, {lbl:'Copies', w:58, align:'right'}, {lbl:'Weight\n(lbs)', w:68, align:'right'}, {lbl:'Postage', w:82, align:'right'}, ]; var tcx=ML; COLS.forEach(function(c){ c.x=tcx; tcx+=c.w; }); var tblW=tcx-ML; // Table header doc.setFillColor(235,243,255); doc.rect(ML,y,tblW,22,'F'); doc.setDrawColor(0,51,128); doc.setLineWidth(1); doc.line(ML,y,ML+tblW,y); doc.setFont('helvetica','bold'); doc.setFontSize(7); doc.setTextColor(0,51,128); COLS.forEach(function(c){ var tx=c.align==='right'?c.x+c.w-3:c.align==='center'?c.x+c.w/2:c.x+3; var lines=c.lbl.split('\n'); lines.forEach(function(l,i){ doc.text(l, tx, y+8+i*8, {align:c.align==='right'?'right':c.align==='center'?'center':'left'}); }); }); doc.line(ML,y+22,ML+tblW,y+22); y+=24; // Build data rows var autoLvls=['5-Digit Scheme','5-Digit','AADC','Mixed AADC','3-Digit']; var spLvls=['Single Piece','Non-automation residual']; var autoPcs=autoLvls.reduce(function(s,l){ return s+(levels[l]?levels[l].pcs:0); },0); var autoSub=autoLvls.reduce(function(s,l){ return s+(levels[l]?levels[l].sub:0); },0); var spPcs=spLvls.reduce(function(s,l){ return s+(levels[l]?levels[l].pcs:0); },0); var spSub=spLvls.reduce(function(s,l){ return s+(levels[l]?levels[l].sub:0); },0); var rows=[]; if(autoPcs>0) rows.push(['0001',entryPO,0,t1+t2,0,autoPcs,(autoPcs*wtLbs).toFixed(4),autoSub]); if(spPcs>0) rows.push(['0001',entryPO,0,1,0,spPcs,(spPcs*wtLbs).toFixed(4),spSub]); if(rows.length===0) rows.push(['0001',entryPO,0,t1+t2,0,totalRecs,totalWt,total]); var totSacks=0,totTrays=0,totPallets=0,totCopies=0,totWeight=0,totPostage=0; rows.forEach(function(row,ri){ var bg=ri%2===0?null:[248,249,255]; if(bg){ doc.setFillColor(bg[0],bg[1],bg[2]); doc.rect(ML,y,tblW,14,'F'); } var vals=[row[0],row[1],row[2],row[3],row[4], Number(row[5]).toLocaleString(), parseFloat(row[6]).toFixed(4), '$ '+Number(row[7]).toFixed(3)]; COLS.forEach(function(c,ci){ var tx=c.align==='right'?c.x+c.w-3:c.align==='center'?c.x+c.w/2:c.x+3; doc.setFont('helvetica','normal'); doc.setFontSize(8); doc.setTextColor(50,50,50); doc.text(String(vals[ci]||''), tx, y+10, {align:c.align==='right'?'right':c.align==='center'?'center':'left'}); }); doc.setDrawColor(220,220,220); doc.setLineWidth(0.3); doc.line(ML,y+14,ML+tblW,y+14); totSacks+=row[2]; totTrays+=row[3]; totPallets+=row[4]; totCopies+=Number(row[5]); totWeight+=parseFloat(row[6]); totPostage+=Number(row[7]); y+=14; }); // Subtotals doc.setFillColor(240,244,252); doc.rect(ML,y,tblW,14,'F'); doc.setDrawColor(0,51,128); doc.setLineWidth(0.8); doc.line(ML,y,ML+tblW,y); doc.setFont('helvetica','bold'); doc.setFontSize(7.5); doc.setTextColor(0,51,128); doc.text('Subtotals:', ML+3, y+10); [[2,totSacks],[3,totTrays],[4,totPallets],[5,totCopies.toLocaleString()], [6,totWeight.toFixed(4)],[7,'$ '+totPostage.toFixed(3)]].forEach(function(kv){ var c=COLS[kv[0]]; doc.text(String(kv[1]), c.x+c.w-3, y+10, {align:'right'}); }); doc.line(ML,y+14,ML+tblW,y+14); y+=16; // Totals doc.setFillColor(235,243,255); doc.rect(ML,y,tblW,16,'F'); doc.setDrawColor(0,51,128); doc.setLineWidth(1.5); doc.line(ML,y,ML+tblW,y); doc.setFont('helvetica','bold'); doc.setFontSize(8.5); doc.setTextColor(0,51,128); doc.text('Totals:', ML+3, y+11); [[2,totSacks],[3,totTrays],[4,totPallets],[5,totCopies.toLocaleString()], [6,totWeight.toFixed(4)],[7,'$ '+totPostage.toFixed(2)]].forEach(function(kv){ var c=COLS[kv[0]]; doc.text(String(kv[1]), c.x+c.w-3, y+12, {align:'right'}); }); y+=20; // ── Mailing summary panel ────────────────────────────────────────────────── y+=6; doc.setDrawColor(180,180,180); doc.setLineWidth(0.5); doc.rect(ML, y, TW/2-10, 58, 'S'); y=_rpt_sectionBanner(doc,'Mailing Summary',ML,y,TW/2-10,13,ML); doc.setFont('helvetica','normal'); doc.setFontSize(8); doc.setTextColor(50,50,50); var sumFields=[ ['Mail Class:', mcLabel], ['Processing:', 'Automation Letters (IMb)'], ['Total Pieces:', totalRecs.toLocaleString()], ['Total Weight:', totalWt+' lbs'], ['Net Postage Due:', '$ '+total.toFixed(2)], ]; sumFields.forEach(function(f,i){ doc.setFont('helvetica','bold'); doc.text(f[0], ML+5, y+5+i*10); doc.setFont('helvetica','normal'); doc.text(f[1], ML+95, y+5+i*10); }); y+=sumFields.length*10+8; // ── Presort scheme parameters ────────────────────────────────────────────── var px=ML+TW/2, pw2=TW/2-10; doc.setDrawColor(180,180,180); doc.setLineWidth(0.5); var paneTop=y-sumFields.length*10-8; doc.rect(px, paneTop, pw2, 58, 'S'); _rpt_sectionBanner(doc,'Presort Scheme Parameters',px,paneTop,pw2,13,px); var schemeFields=[ ['Min 5D/Scheme:', '150 pieces'], ['Min AADC:', '150 pieces'], ['Tray Type:', '1-ft and 2-ft Letter Trays'], ['Move Update:', 'NCOALink'], ['IMb STID:', '271 (Marketing Mail Full-Service)'], ]; schemeFields.forEach(function(f,i){ doc.setFont('helvetica','bold'); doc.setFontSize(7.5); doc.setTextColor(50,50,50); doc.text(f[0], px+5, paneTop+13+5+i*8); doc.setFont('helvetica','normal'); doc.text(f[1], px+85, paneTop+13+5+i*8); }); // ── Auxiliary files / dates ──────────────────────────────────────────────── y+=12; doc.setDrawColor(0,51,128); doc.setLineWidth(0.5); doc.line(ML, y, ML+TW, y); y+=8; doc.setFont('helvetica','bold'); doc.setFontSize(7.5); doc.setTextColor(0,51,128); doc.text('Auxiliary Files', ML, y); y+=10; var auxHdr=['File Description','Date','Eff. Date','File Name']; var auxCW=[120,80,80,TW-280]; var ax=ML; doc.setFont('helvetica','bold'); doc.setFontSize(6.5); doc.setTextColor(0,51,128); auxHdr.forEach(function(h,i){ doc.text(h, ax+2, y); ax+=auxCW[i]; }); y+=10; doc.setDrawColor(200,200,200); doc.line(ML,y,ML+TW,y); y+=2; var auxRows=[ ['USPS Presort Data Folder','N/A','N/A','(presort data directories)'], ['L001 Label List',today,'Current','L001.ZIP (carrier route groupings)'], ['L012 Label List',today,'Current','L012.ZIP (5-digit scheme groupings)'], ['ZCF Directory',today,'Current','ZIP+4 city/state lookup'], ]; auxRows.forEach(function(row,ri){ var bg=ri%2===0?null:[248,248,248]; if(bg){ doc.setFillColor(bg[0],bg[1],bg[2]); doc.rect(ML,y,TW,9,'F'); } var bx=ML; row.forEach(function(v,ci){ doc.setFont('helvetica','normal'); doc.setFontSize(7); doc.setTextColor(50,50,50); doc.text(String(v), bx+2, y+7); bx+=auxCW[ci]; }); doc.setDrawColor(230,230,230); doc.line(ML,y+9,ML+TW,y+9); y+=9; }); // ── Warnings ────────────────────────────────────────────────────────────── y+=6; y=_rpt_sectionBanner(doc,'Warnings & Notes',ML,y,TW,12,ML)+4; var warns=[ '*** Scheme groupings per DMM 245.7.5; 5-digit scheme trays require 150-piece minimum combined across all ZIPs in the group.', '*** L012 label list is authoritative for 5-digit scheme dest_zip assignments per USPS DMM 245.1.3.1.', '*** Directory effective dates: verify mail entry is within valid date window (no earlier than dir effective date).', '*** Full-Service IMb discount ($0.005/pc) applies to all automation pieces with valid ZIP+4 + carrier route + DPBC.', ]; warns.forEach(function(w){ doc.setFont('helvetica','normal'); doc.setFontSize(7); doc.setTextColor(80,80,80); doc.text(w, ML+4, y); y+=9; }); // ── Certification ───────────────────────────────────────────────────────── y+=6; y=_rpt_sectionBanner(doc,'Certification',ML,y,TW,12,ML)+4; doc.setFont('helvetica','normal'); doc.setFontSize(7); doc.setTextColor(80,80,80); var certText='The mailer certifies that all information furnished on this form is accurate, truthful, and complete; that the mail and supporting documentation comply with all postal standards; and that the mailing qualifies for the prices and fees claimed. Privacy Notice: visit www.usps.com.'; doc.setLineWidth(0.3); var certLines=doc.splitTextToSize(certText, TW-8); certLines.forEach(function(l){ doc.text(l, ML+4, y); y+=9; }); y+=4; doc.setDrawColor(150,150,150); doc.line(ML, y+8, ML+180, y+8); doc.setFontSize(6.5); doc.text('Signature of Mailer or Agent', ML, y+14); doc.line(ML+200, y+8, ML+360, y+8); doc.text('Printed Name', ML+200, y+14); doc.line(ML+380, y+8, ML+TW, y+8); doc.text('Date / Telephone', ML+380, y+14); // Footer doc.setFont('helvetica','normal'); doc.setFontSize(6.5); doc.setTextColor(150,150,150); doc.text('Register of Mailings · Presort Engine · Generated '+today+' · Job '+jobId, PW/2, PH-10, {align:'center'}); rpt_queueDownload(doc, 'Register_of_Mailings_'+jobId+'.pdf'); rpt_status('✓ Register of Mailings ready'); } // ───────────────────────────────────────────────────────────────────────────── // 4. POSTAL STATEMENT — PS Form 3600-FCM / 3602-R / 3602-N // ───────────────────────────────────────────────────────────────────────────── function rpt_postalStatement(){ if(!result){ rpt_status('✗ Run presort first.'); return; } if(!window.jspdf){ rpt_status('✗ jsPDF not loaded — reload page.'); return; } var info=rpt_getInfo(); if(!info) return; var bd=info.bd, totalRecs=info.totalRecs, total=info.total; var cfg=info.cfg, entryPO=info.entryPO, today=info.today, todayFull=info.todayFull; var jobId=info.jobId, levels=info.levels; var mcLabel=cfg&&cfg.label?cfg.label:'USPS Marketing Mail Letters'; var isFCM=mcLabel.toLowerCase().indexOf('first')>=0; var isNP=mcLabel.toLowerCase().indexOf('nonprofit')>=0; var isFlat=mcLabel.toLowerCase().indexOf('flat')>=0; var formNum=isFCM?'3600-FCM':isNP?'3602-N':'3602-R'; var formTitle=isFCM?'Postage Statement — First-Class Mail and USPS Ground Advantage': isNP?'Postage Statement — Nonprofit USPS Marketing Mail': 'Postage Statement — USPS Marketing Mail'; var t1=bd.filter(function(t){return t.size==='1-ft';}).length; var t2=bd.filter(function(t){return t.size==='2-ft';}).length; var wtLbs=result&&result.cs?result.cs.wtLbs:0.025; var wtSingle=wtLbs.toFixed(4); var wtTotal=(totalRecs*wtLbs).toFixed(4); var permitNo=document.getElementById('md-permit')&&document.getElementById('md-permit').value?document.getElementById('md-permit').value:'—'; // Notice 123 Jan 2026 rates var autoRates=isFCM?{'5-Digit':0.593,'AADC':0.641,'Mixed AADC':0.672}: isNP ?{'5-Digit':0.165,'5-Digit Scheme':0.165,'AADC':0.192,'Mixed AADC':0.214}: {'5-Digit':0.372,'5-Digit Scheme':0.372,'AADC':0.407,'Mixed AADC':0.433}; var dscfRates=isNP?{'5-Digit':0.152,'AADC':0.177}:{'5-Digit':0.355,'AADC':0.390}; function lvlP(keys){ return keys.reduce(function(s,k){ return s+(levels[k]?levels[k].pcs:0); },0); } function lvlS(keys){ return keys.reduce(function(s,k){ return s+(levels[k]?levels[k].sub:0); },0); } var p5d=lvlP(['5-Digit Scheme','5-Digit']), s5d=lvlS(['5-Digit Scheme','5-Digit']); var pA=lvlP(['AADC']), sA=lvlS(['AADC']); var pM=lvlP(['Mixed AADC']), sM=lvlS(['Mixed AADC']); var pSP=lvlP(['Single Piece','Non-automation residual']), sSP=lvlS(['Single Piece','Non-automation residual']); var autoPcs=p5d+pA+pM, fsDisc=autoPcs*0.005; var partATotal=s5d+sA+sM, partBTotal=sSP; var doc=new window.jspdf.jsPDF({unit:'pt',format:'letter',orientation:'portrait'}); var PW=612,PH=792,ML=28,MR=28,TW=PW-ML-MR; var y=0; // ── Page 1: Main form ────────────────────────────────────────────────────── // Title band doc.setFillColor(0,51,128); doc.rect(0,0,PW,26,'F'); doc.setTextColor(255,255,255); doc.setFont('helvetica','bold'); doc.setFontSize(8); doc.text('United States Postal Service', ML, 11); doc.setFontSize(9); doc.text(formTitle, ML, 21); doc.setFont('helvetica','normal'); doc.setFontSize(7); doc.text('Job '+jobId+' · ID '+jobId, PW-MR, 11, {align:'right'}); doc.text('Page 1', PW-MR, 21, {align:'right'}); // Form number box doc.setDrawColor(0,51,128); doc.setLineWidth(0.8); doc.rect(PW-MR-70, 3, 66, 18, 'S'); doc.setFontSize(7); doc.setTextColor(50,50,50); doc.text('PS Form '+formNum, PW-MR-67, 11); doc.setFontSize(6); doc.setTextColor(120,120,120); doc.text('January 2026 Facsimile', PW-MR-67, 18); y=30; // Mailer section y=_rpt_sectionBanner(doc,'Mailer',ML-2,y,TW+4,11,ML)+3; var mCol=Math.floor(TW/3); var mailerLabels=['Permit Holder Name, Address, Email, Telephone', 'Mailing Agent (If other than permit holder)','Mail Owner (If other than permit holder)']; mailerLabels.forEach(function(lbl,i){ var bx=ML-2+i*mCol; doc.setDrawColor(180,180,180); doc.setLineWidth(0.3); doc.rect(bx,y,mCol,44,'S'); doc.setFont('helvetica','bold'); doc.setFontSize(6); doc.setTextColor(120,120,120); doc.text(lbl, bx+2, y+8, {maxWidth:mCol-4}); if(i===0){ doc.setFont('helvetica','normal'); doc.setFontSize(8.5); doc.setTextColor(50,50,50); doc.text('Lob.com, Inc.', bx+2, y+18); doc.text('2261 Market St', bx+2, y+27); doc.text('Permit No. '+permitNo, bx+2, y+38); } else { doc.setFont('helvetica','normal'); doc.setFontSize(7.5); doc.setTextColor(120,120,120); doc.text('(Same as permit holder)', bx+2, y+26); } }); y+=44; // Mailing section y=_rpt_sectionBanner(doc,'Mailing',ML-2,y,TW+4,11,ML)+3; var flds=[ ['Post Office of Mailing', entryPO],['Mailing Date', today], ['Statement Seq. No.', '0001'],['Permit #', permitNo], ['Type of Postage', 'Permit Imprint'],['Processing Category', isFlat?'Flats':'Letters'], ['Total Pieces', totalRecs.toLocaleString()],['Total Weight', wtTotal+' lbs'], ['Weight/Piece', wtSingle+' lbs'],['Move Update', 'NCOALink'], ['Auto Match Date', todayFull.replace(/\//g,'')],['Processing', 'Automation Letters'], ]; var fw=Math.floor(TW/2)-2; flds.forEach(function(f,i){ var col=i%2, row=Math.floor(i/2); var bx=ML-2+col*(fw+4), by=y+row*14; var bg=row%2===0?null:[250,250,255]; _rpt_fieldPair(doc,f[0],f[1],bx,by,70,fw-70,14,bg); }); y+=Math.ceil(flds.length/2)*14+2; // Container counts doc.setFillColor(235,243,255); doc.rect(ML-2,y,TW+4,12,'F'); doc.setFont('helvetica','bold'); doc.setFontSize(8); doc.setTextColor(0,51,128); doc.text('1-ft Trays: '+t1+' 2-ft Trays: '+t2+' Total Letter Trays: '+(t1+t2)+' Pallets: 0 Sacks: 0', ML+2, y+9); y+=14; // Postage summary box y+=4; doc.setDrawColor(0,51,128); doc.setLineWidth(1); doc.rect(ML-2,y,TW+4,52,'S'); doc.setFillColor(255,250,220); doc.rect(ML-2,y,TW+4,52,'F'); doc.setDrawColor(0,51,128); doc.rect(ML-2,y,TW+4,52,'S'); doc.setFont('helvetica','bold'); doc.setFontSize(9); doc.setTextColor(50,50,50); doc.text('1 Subtotal Postage (Add parts totals)', ML+2, y+13); doc.text('$ '+(partATotal+partBTotal).toFixed(4), PW-MR-2, y+13, {align:'right'}); doc.setDrawColor(200,200,200); doc.line(ML-2,y+17,ML-2+TW+4,y+17); doc.setFont('helvetica','normal'); doc.setFontSize(8); doc.setTextColor(100,100,100); doc.text('2 Price at which postage affixed —', ML+2, y+25); doc.text('3 Incentive/Discount Flat Dollar Amount —', ML+2, y+34); doc.setDrawColor(200,200,200); doc.line(ML-2,y+38,ML-2+TW+4,y+38); doc.setFont('helvetica','bold'); doc.setFontSize(10); doc.setTextColor(0,51,128); doc.text('4 Net Postage Due (Line 1 +/- Lines 2, 3) Permit # '+permitNo, ML+2, y+50); doc.setFontSize(13); doc.setTextColor(187,0,0); doc.text('$ '+total.toFixed(2), PW-MR-2, y+50, {align:'right'}); y+=54; // Parts completed y+=4; doc.setFont('helvetica','normal'); doc.setFontSize(7.5); doc.setTextColor(50,50,50); doc.text('Parts Completed: [X] A [X] B [ ] C [ ] D [ ] E [ ] F [ ] G [X] Z [ ] NSA', ML, y+9); y+=14; // Certification y=_rpt_sectionBanner(doc,'Certification',ML-2,y,TW+4,11,ML)+3; doc.setFont('helvetica','normal'); doc.setFontSize(6.5); doc.setTextColor(80,80,80); var certText="The mailer's signature certifies acceptance of liability for and agreement to pay any revenue deficiencies assessed on this mailing. The mailer hereby certifies that all information furnished on this form is accurate, truthful, and complete; that the mail and the supporting documentation comply with all postal standards and the mailing qualifies for the prices and fees claimed."; var clines=doc.splitTextToSize(certText, TW-6); clines.forEach(function(l){ doc.text(l, ML, y); y+=8; }); y+=4; doc.setDrawColor(150,150,150); doc.setLineWidth(0.5); doc.line(ML,y+8,ML+170,y+8); doc.setFontSize(6); doc.text('Signature of Mailer or Agent',ML,y+14); doc.line(ML+190,y+8,ML+340,y+8); doc.text('Printed Name',ML+190,y+14); doc.line(ML+360,y+8,ML+TW,y+8); doc.text('Date / Telephone',ML+360,y+14); y+=22; doc.setFont('helvetica','normal'); doc.setFontSize(6.5); doc.setTextColor(120,120,120); doc.text('PS Form '+formNum+', January 2026 (Page 1) Facsimile Postal Explorer at pe.usps.com', ML, PH-12); doc.text('Presort Engine · '+today, PW-MR, PH-12, {align:'right'}); // ── Page 2: Part A ───────────────────────────────────────────────────────── doc.addPage('letter','portrait'); y=0; doc.setFillColor(235,240,255); doc.rect(0,0,PW,20,'F'); doc.setTextColor(0,51,128); doc.setFont('helvetica','bold'); doc.setFontSize(9); doc.text(isFCM?'First-Class Mail':isNP?'Nonprofit USPS Marketing Mail':'USPS Marketing Mail', ML, 14); doc.setFont('helvetica','normal'); doc.setFontSize(7); doc.setTextColor(50,50,50); doc.text('Page 2', PW-MR, 14, {align:'right'}); y=24; y=_rpt_sectionBanner(doc,'Part A — '+(isFCM?'Automation Price':'Automation Letters'),ML-2,y,TW+4,11,ML)+4; doc.setFont('helvetica','bold'); doc.setFontSize(8); doc.setTextColor(50,50,50); doc.text('Letters 3.5 oz. (0.2188 lbs.) or less', ML, y+9); y+=14; // Part A table header var aHdr=['Line','Entry','Price Category','Price','No. of Pieces','Subtotal Postage','Discount','Total Postage*']; var aCW=[26,36,108,42,60,74,60,74]; var ax=ML; aCW.forEach(function(w,i){ if(!aHdr[i]) return; }); // Draw header row doc.setFillColor(235,243,255); doc.rect(ML-2,y,TW+4,13,'F'); doc.setDrawColor(0,51,128); doc.setLineWidth(0.8); doc.line(ML-2,y,ML-2+TW+4,y); doc.line(ML-2,y+13,ML-2+TW+4,y+13); var ax2=ML; doc.setFont('helvetica','bold'); doc.setFontSize(6.5); doc.setTextColor(0,51,128); aHdr.forEach(function(h,i){ doc.text(h, ax2+2, y+9); ax2+=aCW[i]; }); y+=13; // Part A data rows var aRows=isFCM?[ {ln:'A4',entry:'',cat:'5-Digit', pcs:p5d,sub:s5d,rate:autoRates['5-Digit']||0.593}, {ln:'A5',entry:'',cat:'AADC', pcs:pA, sub:sA, rate:autoRates['AADC']||0.641}, {ln:'A6',entry:'',cat:'Mixed AADC',pcs:pM,sub:sM, rate:autoRates['Mixed AADC']||0.672}, ]:[ {ln:'A1',entry:'None',cat:'5-Digit', pcs:p5d,sub:s5d,rate:autoRates['5-Digit']||autoRates['5-Digit Scheme']||0.372}, {ln:'A2',entry:'None',cat:'AADC', pcs:pA, sub:sA, rate:autoRates['AADC']||0.407}, {ln:'A3',entry:'None',cat:'Mixed AADC',pcs:pM,sub:sM, rate:autoRates['Mixed AADC']||0.433}, {ln:'A4',entry:'DSCF',cat:'5-Digit', pcs:0, sub:0, rate:dscfRates['5-Digit']||0.355}, {ln:'A5',entry:'DSCF',cat:'AADC', pcs:0, sub:0, rate:dscfRates['AADC']||0.390}, ]; aRows.forEach(function(r,ri){ var active=r.pcs>0; var bg=ri%2===0?(active?[252,255,252]:[252,252,252]):(active?[246,252,248]:[248,248,248]); doc.setFillColor(bg[0],bg[1],bg[2]); doc.rect(ML-2,y,TW+4,12,'F'); var disc=active?(r.sub-(r.rate*r.pcs)):0; var vals=[r.ln,r.entry,r.cat, r.rate.toFixed(3), active?r.pcs.toLocaleString():'', active?(r.rate*r.pcs).toFixed(4):'', active&&Math.abs(disc)>0.001?Math.abs(disc).toFixed(4):'', active?r.sub.toFixed(4):'']; var vx=ML; vals.forEach(function(v,vi){ if(v){ doc.setFont('helvetica',vi===0?'bold':'normal'); doc.setFontSize(8); doc.setTextColor(active?50:150, active?50:150, active?50:150); var align=vi>=3&&vi!==2?'right':'left'; var tx=align==='right'?vx+aCW[vi]-2:vx+2; doc.text(String(v), tx, y+9, {align:align}); } vx+=aCW[vi]; }); doc.setDrawColor(220,220,220); doc.setLineWidth(0.3); doc.line(ML-2,y+12,ML-2+TW+4,y+12); y+=12; }); // Footnote doc.setFont('helvetica','normal'); doc.setFontSize(6.5); doc.setTextColor(100,100,100); doc.text('* Full Service Intelligent Mail, promotions, incentives and other discounts — see Instructions page for additional information.', ML, y+8); y+=12; // Part A Total doc.setFillColor(235,243,255); doc.rect(ML-2,y,TW+4,15,'F'); doc.setDrawColor(0,51,128); doc.setLineWidth(0.8); doc.line(ML-2,y,ML-2+TW+4,y); doc.line(ML-2,y+15,ML-2+TW+4,y+15); doc.setFont('helvetica','bold'); doc.setFontSize(8.5); doc.setTextColor(0,51,128); var aTotalLn=isFCM?'A11':'A6'; doc.text(aTotalLn+' Part A Total (Add lines A1–'+(isFCM?'A10':'A5')+')', ML+2, y+11); doc.rect(ML-2+TW+4-88,y+2,86,11,'S'); doc.text('$ '+partATotal.toFixed(4), ML-2+TW+4-4, y+10, {align:'right'}); y+=17; // SCF + FS display lines y+=3; doc.setFont('helvetica','bold'); doc.setFontSize(7); doc.setTextColor(50,50,50); doc.text('SCF Pallet Discount', ML, y); y+=9; var scfLines=isFCM?[ [isFCM?'A14':'','5-Digit Automation Letters','× $0.004 ='], [isFCM?'A15':'','AADC Automation Letters ('+pA.toLocaleString()+' pcs)','× $0.004 = '+(pA*0.004).toFixed(4)], ]:[ ['A7','5-Digit Automation Letters','× $0.003 ='], ['A8','AADC Automation Letters','× $0.003 ='], ]; scfLines.forEach(function(s){ doc.setFillColor(250,250,245); doc.rect(ML-2,y,TW+4,10,'F'); doc.setFont('helvetica','normal'); doc.setFontSize(7.5); doc.setTextColor(100,100,100); doc.text(s[0]+' DISPLAY ONLY '+s[1]+' — Number of Pieces that Comply', ML+2, y+7); doc.text(s[2], PW-MR-2, y+7, {align:'right'}); doc.setDrawColor(235,235,235); doc.line(ML-2,y+10,ML-2+TW+4,y+10); y+=10; }); y+=4; doc.setFont('helvetica','bold'); doc.setFontSize(7); doc.setTextColor(50,50,50); doc.text('Full Service Intelligent Mail Option', ML, y); y+=9; var fsLn=isFCM?'A20':'A10'; doc.setFillColor(235,243,255); doc.rect(ML-2,y,TW+4,11,'F'); doc.setFont('helvetica','normal'); doc.setFontSize(7.5); doc.setTextColor(0,51,128); doc.text(fsLn+' DISPLAY ONLY Letters — Number of Pieces that Comply: '+autoPcs.toLocaleString()+' × $0.005', ML+2, y+8); doc.setFont('helvetica','bold'); doc.text('= $ '+fsDisc.toFixed(4), PW-MR-2, y+8, {align:'right'}); y+=13; doc.setFont('helvetica','normal'); doc.setFontSize(6.5); doc.setTextColor(120,120,120); doc.text('PS Form '+formNum+', January 2026 (Page 2) Facsimile', ML, PH-12); // helper vars needed after page 2 // ── Page 3: Part B ───────────────────────────────────────────────────────── doc.addPage('letter','portrait'); doc.setFillColor(235,240,255); doc.rect(0,0,PW,20,'F'); doc.setTextColor(0,51,128); doc.setFont('helvetica','bold'); doc.setFontSize(9); doc.text(isFCM?'First-Class Mail':'USPS Marketing Mail', ML, 14); doc.setFont('helvetica','normal'); doc.setFontSize(7); doc.setTextColor(50,50,50); doc.text('Page 3', PW-MR, 14, {align:'right'}); y=24; y=_rpt_sectionBanner(doc,'Part B — Nonautomation Letters',ML-2,y,TW+4,11,ML)+4; doc.setFont('helvetica','bold'); doc.setFontSize(8); doc.setTextColor(50,50,50); doc.text('Machinable Letters 3.5 oz. (0.2188 lbs.) or less', ML, y+9); y+=14; // Part B header doc.setFillColor(235,243,255); doc.rect(ML-2,y,TW+4,13,'F'); doc.setDrawColor(0,51,128); doc.setLineWidth(0.8); doc.line(ML-2,y,ML-2+TW+4,y); doc.line(ML-2,y+13,ML-2+TW+4,y+13); var bx3=ML; doc.setFont('helvetica','bold'); doc.setFontSize(6.5); doc.setTextColor(0,51,128); aHdr.forEach(function(h,i){ doc.text(h, bx3+2, y+9); bx3+=aCW[i]; }); y+=13; // B rows var bNAMach=isNP?{'AADC':0.192,'Mixed AADC':0.214}:{'AADC':0.407,'Mixed AADC':0.439}; [{ln:'B1',entry:'None',cat:'AADC',rate:bNAMach['AADC']}, {ln:'B2',entry:'None',cat:'Mixed AADC',rate:bNAMach['Mixed AADC']}, {ln:'B3',entry:'DSCF',cat:'AADC',rate:isNP?0.177:0.390} ].forEach(function(r,ri){ var pcs=(r.cat==='Mixed AADC'&&pSP>0)?pSP:0; var sub=pcs?sSP:0; var active=pcs>0; var bg=ri%2===0?null:[250,250,250]; if(bg){ doc.setFillColor(bg[0],bg[1],bg[2]); doc.rect(ML-2,y,TW+4,12,'F'); } var vals=[r.ln,r.entry,r.cat,r.rate.toFixed(3), active?pcs.toLocaleString():'',active?(r.rate*pcs).toFixed(4):'','',active?sub.toFixed(4):'']; var vx2=ML; vals.forEach(function(v,vi){ if(v){ doc.setFont('helvetica','normal'); doc.setFontSize(8); doc.setTextColor(active?50:150,active?50:150,active?50:150); doc.text(String(v),vi>=3?vx2+aCW[vi]-2:vx2+2,y+9,{align:vi>=3?'right':'left'}); } vx2+=aCW[vi]; }); doc.setDrawColor(220,220,220); doc.setLineWidth(0.3); doc.line(ML-2,y+12,ML-2+TW+4,y+12); y+=12; }); y+=8; // Nonmachinable ≤4oz doc.setFont('helvetica','bold'); doc.setFontSize(8); doc.setTextColor(50,50,50); doc.text('Nonmachinable Letters 4.0 oz. (0.25 lbs.) or less', ML, y+9); y+=14; doc.setFillColor(235,243,255); doc.rect(ML-2,y,TW+4,13,'F'); doc.setDrawColor(0,51,128); doc.setLineWidth(0.8); doc.line(ML-2,y,ML-2+TW+4,y); doc.line(ML-2,y+13,ML-2+TW+4,y+13); var bx4=ML; doc.setFont('helvetica','bold'); doc.setFontSize(6.5); doc.setTextColor(0,51,128); aHdr.forEach(function(h,i){ doc.text(h, bx4+2, y+9); bx4+=aCW[i]; }); y+=13; [{ln:'B4',e:'None',c:'5-Digit',r:0.869},{ln:'B5',e:'None',c:'3-Digit',r:1.046}, {ln:'B6',e:'None',c:'ADC',r:1.110},{ln:'B7',e:'None',c:'Mixed ADC',r:1.220}, {ln:'B8',e:'DSCF',c:'5-Digit',r:0.831},{ln:'B9',e:'DSCF',c:'3-Digit',r:1.008}, {ln:'B10',e:'DSCF',c:'ADC',r:1.072} ].forEach(function(r,ri){ var bg=ri%2===0?null:[248,248,248]; if(bg){ doc.setFillColor(bg[0],bg[1],bg[2]); doc.rect(ML-2,y,TW+4,11,'F'); } doc.setFont('helvetica','normal'); doc.setFontSize(7.5); doc.setTextColor(150,150,150); doc.text(r.ln,ML+2,y+8); doc.text(r.e,ML+28,y+8); doc.text(r.c,ML+66,y+8); doc.text(r.r.toFixed(3),ML+176,y+8); doc.setDrawColor(235,235,235); doc.line(ML-2,y+11,ML-2+TW+4,y+11); y+=11; }); y+=6; doc.setFont('helvetica','normal'); doc.setFontSize(6.5); doc.setTextColor(100,100,100); doc.text('* Promotions, incentives and other discounts — see Instructions page.', ML, y); y+=10; // Part B Total doc.setFillColor(235,243,255); doc.rect(ML-2,y,TW+4,15,'F'); doc.setDrawColor(0,51,128); doc.setLineWidth(0.8); doc.line(ML-2,y,ML-2+TW+4,y); doc.line(ML-2,y+15,ML-2+TW+4,y+15); doc.setFont('helvetica','bold'); doc.setFontSize(8.5); doc.setTextColor(0,51,128); doc.text((isFCM?'B21':'B18')+' Part B Total', ML+2, y+11); doc.rect(ML-2+TW+4-88,y+2,86,11,'S'); doc.text('$ '+partBTotal.toFixed(4), ML-2+TW+4-4, y+10, {align:'right'}); y+=17; doc.setFont('helvetica','normal'); doc.setFontSize(6.5); doc.setTextColor(120,120,120); doc.text('PS Form '+formNum+', January 2026 (Page 3) Facsimile', ML, PH-12); // ── Page 4: Part Z + Final ───────────────────────────────────────────────── doc.addPage('letter','portrait'); doc.setFillColor(235,240,255); doc.rect(0,0,PW,20,'F'); doc.setTextColor(0,51,128); doc.setFont('helvetica','bold'); doc.setFontSize(9); doc.text(isFCM?'First-Class Mail':'USPS Marketing Mail', ML, 14); doc.setFont('helvetica','normal'); doc.setFontSize(7); doc.setTextColor(50,50,50); doc.text('Page 4', PW-MR, 14, {align:'right'}); y=24; y=_rpt_sectionBanner(doc,'Part Z — Promotions, Incentives, Discounts — Optional/Display Only',ML-2,y,TW+4,11,ML)+4; doc.setFont('helvetica','normal'); doc.setFontSize(6.5); doc.setTextColor(100,100,100); doc.text('* Not intended to be used for postage calculations.', ML, y+8); y+=14; // Promotions doc.setFont('helvetica','bold'); doc.setFontSize(7.5); doc.setTextColor(50,50,50); doc.text('Promotions', ML, y); y+=9; var zPromos=isFCM?[ ['Z3','FA','First-Class Mail Advertising Promotion'], ['Z4','IT','Integrated Technology Promotion'], ['Z5','SS','Tactile Sensory Promotion'], ['Z6','PI','Informed Delivery Promotion Add-On'], ['Z7','ST','Sustainability Promotion Add-On'], ]:[ ['Z1','CT','Catalog Insights Promotion'], ['Z2','CC','Continuous Contact Promotion'], ['Z4','IT','Integrated Technology Promotion'], ['Z5','SS','Tactile Sensory Promotion'], ['Z6','PI','Informed Delivery Promotion Add-On'], ['Z7','ST','Sustainability Promotion Add-On'], ]; doc.setFillColor(235,243,255); doc.rect(ML-2,y,TW+4,12,'F'); doc.setDrawColor(0,51,128); doc.setLineWidth(0.8); doc.line(ML-2,y,ML-2+TW+4,y); doc.line(ML-2,y+12,ML-2+TW+4,y+12); doc.setFont('helvetica','bold'); doc.setFontSize(6.5); doc.setTextColor(0,51,128); doc.text('Code', ML+2, y+9); doc.text('Promotion', ML+40, y+9); doc.text('Amount', PW-MR-2, y+9, {align:'right'}); y+=12; zPromos.forEach(function(r,i){ var bg=i%2===0?null:[248,248,248]; if(bg){ doc.setFillColor(bg[0],bg[1],bg[2]); doc.rect(ML-2,y,TW+4,11,'F'); } doc.setFont('helvetica','normal'); doc.setFontSize(7.5); doc.setTextColor(100,100,100); doc.text(r[0], ML+2, y+8); doc.text(r[1]+' — '+r[2], ML+30, y+8); doc.setDrawColor(235,235,235); doc.line(ML-2,y+11,ML-2+TW+4,y+11); y+=11; }); var zPromoTotalLn=isFCM?'Z6':'Z8'; doc.setFillColor(235,243,255); doc.rect(ML-2,y,TW+4,14,'F'); doc.setDrawColor(0,51,128); doc.setLineWidth(0.8); doc.line(ML-2,y,ML-2+TW+4,y); doc.setFont('helvetica','bold'); doc.setFontSize(8); doc.setTextColor(0,51,128); doc.text(zPromoTotalLn+' Part Z — Promotions Total', ML+2, y+10); doc.rect(ML-2+TW+4-88,y+2,86,10,'S'); y+=14; // Discounts y+=6; doc.setFont('helvetica','bold'); doc.setFontSize(7.5); doc.setTextColor(50,50,50); doc.text('Discounts', ML, y); y+=9; doc.setFillColor(235,243,255); doc.rect(ML-2,y,TW+4,12,'F'); doc.setDrawColor(0,51,128); doc.setLineWidth(0.8); doc.line(ML-2,y,ML-2+TW+4,y); doc.line(ML-2,y+12,ML-2+TW+4,y+12); doc.setFont('helvetica','bold'); doc.setFontSize(6.5); doc.setTextColor(0,51,128); doc.text('Discount Description', ML+2, y+9); doc.text('Amount', PW-MR-2, y+9, {align:'right'}); y+=12; var discRows=[ ['Z14','Delivery Sort Container Discount',''], ['Z15','SCF Pallet Discount',''], ['Z16','Full-Service Intelligent Mail Option ('+autoPcs.toLocaleString()+' pcs × $0.005)','$ '+fsDisc.toFixed(4)], ]; discRows.forEach(function(r,i){ var isFS=i===2; if(isFS){ doc.setFillColor(235,243,255); } else if(i%2!==0){ doc.setFillColor(248,248,248); } else { doc.setFillColor(255,255,255); } doc.rect(ML-2,y,TW+4,11,'F'); doc.setFont('helvetica',isFS?'bold':'normal'); doc.setFontSize(7.5); doc.setTextColor(isFS?0:100,isFS?51:100,isFS?128:100); doc.text(r[0], ML+2, y+8); doc.text(r[1], ML+36, y+8); if(r[2]) doc.text(r[2], PW-MR-2, y+8, {align:'right'}); doc.setDrawColor(235,235,235); doc.line(ML-2,y+11,ML-2+TW+4,y+11); y+=11; }); doc.setFillColor(235,243,255); doc.rect(ML-2,y,TW+4,14,'F'); doc.setDrawColor(0,51,128); doc.setLineWidth(0.8); doc.line(ML-2,y,ML-2+TW+4,y); doc.setFont('helvetica','bold'); doc.setFontSize(8); doc.setTextColor(0,51,128); doc.text('Z17 Part Z — Discounts Total (Display Only)', ML+2, y+10); doc.rect(ML-2+TW+4-88,y+2,86,10,'S'); doc.text('$ '+fsDisc.toFixed(4), ML-2+TW+4-4, y+9, {align:'right'}); y+=16; // Final net postage y+=8; doc.setFillColor(255,250,220); doc.rect(ML-2,y,TW+4,58,'F'); doc.setDrawColor(0,51,128); doc.setLineWidth(1.2); doc.rect(ML-2,y,TW+4,58,'S'); doc.setFont('helvetica','bold'); doc.setFontSize(9); doc.setTextColor(50,50,50); doc.text('1 Subtotal Postage (Part A + Part B)', ML+3, y+13); doc.text('$ '+(partATotal+partBTotal).toFixed(4), PW-MR-2, y+13, {align:'right'}); doc.setDrawColor(200,200,200); doc.line(ML-2,y+17,ML-2+TW+4,y+17); doc.setFont('helvetica','normal'); doc.setFontSize(8); doc.setTextColor(100,100,100); doc.text('2 Price at Which Postage Affixed —', ML+3, y+26); doc.text('3 Incentive/Discount Flat Dollar Amount —', ML+3, y+36); doc.setDrawColor(200,200,200); doc.line(ML-2,y+40,ML-2+TW+4,y+40); doc.setFont('helvetica','bold'); doc.setFontSize(11); doc.setTextColor(0,51,128); doc.text('4 NET POSTAGE DUE (Line 1 +/- Lines 2, 3)', ML+3, y+54); doc.setFontSize(14); doc.setTextColor(187,0,0); doc.text('$ '+total.toFixed(2), PW-MR-2, y+54, {align:'right'}); y+=62; doc.setFont('helvetica','normal'); doc.setFontSize(6.5); doc.setTextColor(120,120,120); doc.text('PS Form '+formNum+', January 2026 (Page 4 of 4) Facsimile pe.usps.com', ML, PH-12); doc.text('Presort Engine · Generated '+today+' · Job '+jobId, PW-MR, PH-12, {align:'right'}); rpt_queueDownload(doc, 'Postal_Statement_'+formNum+'_'+jobId+'.pdf'); rpt_status('✓ Postal Statement ('+formNum+') ready — Net Postage Due: $ '+total.toFixed(2)); } function _drawTableHdr(doc, hdrs, cws, y){ const ML=22, TW=564; doc.setFillColor(...RPT_HLBLUE); doc.rect(ML-2, y, TW+4, 13, 'F'); doc.setDrawColor(...RPT_USPS_BLUE); doc.setLineWidth(0.8); doc.line(ML-2,y,ML-2+TW+4,y); doc.line(ML-2,y+13,ML-2+TW+4,y+13); doc.setFont('helvetica','bold'); doc.setFontSize(6.5); doc.setTextColor(...RPT_USPS_BLUE); let x=ML; hdrs.forEach((h,i)=>{ doc.text(h,x+2,y+9); x+=cws[i]; }); } function _drawRateRow(doc, vals, cws, y, ri){ const ML=22, TW=564; const bg = ri%2===0 ? null : [250,250,253]; if(bg){doc.setFillColor(...bg);doc.rect(ML-2,y,TW+4,12,'F');} let x=ML; vals.forEach((v,i)=>{ if(v!==null && v!==undefined && v!==''){ const isAmt = (typeof v==='number'&&i>3) || (typeof v==='string'&&v.match(/^\d+\.\d{4}$/)); doc.setFont('helvetica', i===0?'bold':'normal'); doc.setFontSize(8); doc.setTextColor(v===null?RPT_GRAY:RPT_DGRAY); const fv = typeof v==='number' ? (i===3?v.toFixed(3):v>9999?v.toLocaleString():v.toFixed(4)) : String(v); const align = (i>=3&&i!==2)?'right':'left'; const tx = align==='right' ? x+cws[i]-2 : x+2; doc.text(fv, tx, y+9, {align}); } x+=cws[i]; }); doc.setDrawColor(...RPT_LGRAY); doc.setLineWidth(0.3); doc.line(ML-2,y+12,ML-2+TW+4,y+12); } function _drawTotalRow(doc, label, amount, y){ const ML=22, TW=564; doc.setFillColor(...RPT_HLBLUE); doc.rect(ML-2,y,TW+4,15,'F'); doc.setDrawColor(...RPT_USPS_BLUE); doc.setLineWidth(0.8); doc.line(ML-2,y,ML-2+TW+4,y); doc.line(ML-2,y+15,ML-2+TW+4,y+15); doc.setFont('helvetica','bold'); doc.setFontSize(8.5); doc.setTextColor(...RPT_USPS_BLUE); doc.text(label, ML+2, y+11); if(amount){ const box=ML-2+TW+4-90; doc.rect(box,y+2,88,11,'S'); doc.text(`$ ${amount.toFixed(4)}`, box+86, y+10, {align:'right'}); } } // ───────────────────────────────────────────────────────────────────────────── // 5. V3 CSV — Presort Output V3 (piece-level with presort assignments) // ───────────────────────────────────────────────────────────────────────────── function rpt_v3csv(){ if(!result){ rpt_status('✗ Run presort first — load a job and click Run.'); return; } const {bd,jobId} = rpt_getInfo(); // V3 columns per reference output const V3_COLS = [ 'NAME','ADDRESS1','ADDRESS2','ADDRESS3','CITY','STATE','ZIP','ZIP4', 'COMPANY','CD_MAILOWN','CD_STID','CRT','DPBC','LOT','LOTORD', 'CD_PROMOTI','CD_MID','CD_SERIAL','WIDTH','HEIGHT','THICKNESS','WEIGHT', 'RecordId','PST_OPT_EN','PST_IMB','PST_IMB_EC', 'PST_PC_NO','PST_PKG_BR','PST_PKG_NO','PST_CTN_BR','PST_CTN_NO', 'PST_PLT_BR','PST_PLT_NO', 'FNL_EXTADR','FNL_SECADR','FNL_PRIADR','FNL_CITY','FNL_STATE','FNL_ZIP9', 'manfst_key' ]; // PST_OPT_EN level label per reference: '*************AUTO**SCH 5-DIGIT 17901' etc. const OPT_LVL = { '5-Digit Scheme':'SCH 5-DIGIT', '5-Digit':'5-DIGIT', '3-Digit':'3-DIGIT', 'AADC':'AADC', 'Mixed AADC':'MAADC', 'Single Piece':'SNGLP' }; const csvLines = [V3_COLS.map(c=>`"${c}"`).join(',')]; let pcNo = 1, pkgNo = 1, ctnNo = 1; for(const t of bd){ const ctnNo_t = t.trayNo || ctnNo++; const lvlLabel = OPT_LVL[t.level] || t.level.toUpperCase(); const destKey = (t.key||'').substring(0,11).trim(); // PST_OPT_EN: '*************AUTO**SCH 5-DIGIT 17901' — 13 stars + 'AUTO**' + level + ' ' + dest const optEnCore = `AUTO**${lvlLabel} ${destKey}`; const optEn = ('*'.repeat(Math.max(0,35-optEnCore.length-2)) + optEnCore).substring(0,35); // Wait — ref shows prefix stars then AUTO. Reconstruct: // ref: '*************AUTO**SCH 5-DIGIT 17901' = 35 chars // 13 stars + 'AUTO**SCH 5-DIGIT 17901' = 13 + 22 = 35 const optEnPad = ('*'.repeat(35)).substring(0, Math.max(0, 35 - optEnCore.length - 2)) + 'AUTO**' + lvlLabel + ' ' + destKey; const pst_opt_en = optEnPad.substring(0,35).padEnd(35).substring(0,35); // Net rate for manfst_key const rate = (t.nr||t.rate||0).toFixed(3); let pkgPcNo = 1; const pkgNo_t = pkgNo++; for(const r of (t.records||[])){ const z9 = r.zip5 + (r.zip4 ? '-'+r.zip4 : ''); // PST_IMB: 31-digit = BC_ID(2,'00') + STID(3,'271' for STD NP) + MID(6) + SERIAL(9) + ZIP5(5) + ZIP4(4) + DPBC(2) const bc_id = '00'; const stid = '271'; // USPS Marketing Mail Nonprofit Full-Service const mid = (r.cd_mid||'000000').replace(/\D/g,'').padStart(6,'0').substring(0,6); const serial = (r.cd_serial||String(pcNo)).replace(/\D/g,'').padStart(9,'0').substring(0,9); const z5p = (r.zip5||'00000').padStart(5,'0'); const z4p = (r.zip4||'0000').replace(/\D/g,'').padStart(4,'0').substring(0,4); const dpbcp = (r.dpbc||'00').replace(/\D/g,'').padStart(2,'0').substring(0,2); const pst_imb = bc_id + stid + mid + serial + z5p + z4p + dpbcp; // PST_IMB_EC: 65-char 4-state bar encoding using IMb encoder if available let pst_imb_ec = ''; if(typeof _IMB !== 'undefined' && _IMB.encode){ // Encode the 20-digit tracking portion (BC_ID+STID+MID+SERIAL) + routing const imb20 = (bc_id + stid + mid + serial).padEnd(20,'0').substring(0,20); const bars = _IMB.encode(imb20); if(bars) pst_imb_ec = bars.join(''); } const manfst = `${pcNo} AV ${rate}`; const row = { // ── INPUT pass-through fields (verbatim from input CSV) ── NAME: r.name||'', ADDRESS1: '', // ref always blank ADDRESS2: r.addr2||'', // ref always blank in this job ADDRESS3: r.addr1||'', // primary street address line only CITY: r.city||'', STATE: r.state||'', ZIP: r.zip5||'', ZIP4: r.zip4||'', COMPANY: '', CD_MAILOWN: r.cd_mailown||'', CD_STID: r.cd_stid||'', CRT: r.crt||'', DPBC: r.dpbc||'', LOT: r.lot||'', LOTORD: r.lotord||'A', CD_PROMOTI: r.cd_promoti||'', CD_MID: r.cd_mid||'', // 6-digit Mailer ID from input CD_SERIAL: r.cd_serial||'', // IMb serial from input WIDTH: r.widthIn||'', HEIGHT: r.heightIn||'', THICKNESS: r.thicknessIn||'', WEIGHT: r.weightOz||'', RecordId: r.recordId||pcNo, // original record ID from input // ── PST_ fields — assigned by presort engine ── PST_OPT_EN: pst_opt_en, PST_IMB: pst_imb, PST_IMB_EC: pst_imb_ec, PST_PC_NO: pkgPcNo, // piece # within package PST_PKG_BR: '', // pkg break marker — blank per ref PST_PKG_NO: pkgNo_t, // package number (sequential per tray) PST_CTN_BR: '', // container break marker — blank per ref PST_CTN_NO: ctnNo_t, // tray/container number PST_PLT_BR: '', PST_PLT_NO: '', // pallet number (blank if no pallets) // ── FNL_ fields — final delivery address from CASS/input ── FNL_EXTADR: r.fnl_extadr||'', FNL_SECADR: r.fnl_secadr||'', FNL_PRIADR: r.addr1||'', // primary address line (not combined) FNL_CITY: r.city||'', FNL_STATE: r.state||'', FNL_ZIP9: z9, manfst_key: manfst // '{pcNo} AV {net_rate}' }; const csvRow = V3_COLS.map(c => { const v = String(row[c]||'').replace(/"/g,'""'); return `"${v}"`; }).join(','); csvLines.push(csvRow); pcNo++; pkgPcNo++; } } const content = csvLines.join('\r\n'); dlText(content, `Presort_Output_V3_${jobId||'job'}.csv`, 'text/csv'); rpt_status(`✓ V3 CSV exported — ${pcNo-1} pieces`); } // ───────────────────────────────────────────────────────────────────────────── // 6. V2 CSV — Presort Output V2 (piece-level with expanded FNL_ fields) // ───────────────────────────────────────────────────────────────────────────── function rpt_v2csv(){ if(!result){ rpt_status('✗ Run presort first — load a job and click Run.'); return; } const {bd,jobId} = rpt_getInfo(); const V2_COLS = [ 'NAME','ADDRESS1','ADDRESS2','ADDRESS3','CITY','STATE','ZIP','ZIP4', 'COMPANY','CD_MAILOWN','CD_STID','CRT','DPBC','LOT','LOTORD', 'CD_PROMOTI','CD_MID','CD_SERIAL','WIDTH','HEIGHT','THICKNESS','WEIGHT', 'RecordId','PST_OPT_EN','PST_POSTN1','PST_POSTN2', 'PST_IMB','PST_IMB_EC', 'PST_PC_NO_','PST_Pkg_Br','PST_Pkg_No','PST_Ctn_Br','PST_Ctn_No', 'PST_Plt_Br','PST_Plt_No', 'FNL_EXTADR','FNL_SECADR','FNL_PRIADR','FNL_CITY','FNL_STATE', 'FNL_ZIP','FNL_ZIP4','FNL_CRT','FNL_DPBC','FNL_LOT','FNL_LOTORD', 'FNL_Achkdi','FNL_ERRSTT','FNL_RECTYP','FNL_DPVFTN','FNL_DPVSTT', 'FNL_COUNTY','FNL_CNTNUM','FNL_CONGCD', 'manfst_key' ]; const OPT_LVL = { '5-Digit Scheme':'SCH 5-DIGIT', '5-Digit':'5-DIGIT', '3-Digit':'3-DIGIT', 'AADC':'AADC', 'Mixed AADC':'MAADC', 'Single Piece':'SNGLP' }; const csvLines = [V2_COLS.map(c=>`"${c}"`).join(',')]; let pcNo = 1, pkgNo = 1, ctnNo = 1; for(const t of bd){ const ctnNo_t = t.trayNo || ctnNo++; const lvlLabel = OPT_LVL[t.level] || t.level.toUpperCase(); const destKey = (t.key||'').substring(0,11).trim(); const optEnCore = `AUTO**${lvlLabel} ${destKey}`; const pst_opt_en = ('*'.repeat(35)).substring(0, Math.max(0,35-optEnCore.length-2)) + 'AUTO**' + lvlLabel + ' ' + destKey; const rate = (t.nr||t.rate||0).toFixed(3); const pkgNo_t = pkgNo++; for(const r of (t.records||[])){ // PST_IMB: BC_ID(2) + STID(3) + MID(6) + SERIAL(9) + ZIP5(5) + ZIP4(4) + DPBC(2) = 31 const bc_id = '00'; const stid = '271'; const mid = (r.cd_mid||'000000').replace(/\D/g,'').padStart(6,'0').substring(0,6); const serial = (r.cd_serial||String(pcNo)).replace(/\D/g,'').padStart(9,'0').substring(0,9); const z5p = (r.zip5||'00000').padStart(5,'0'); const z4p = (r.zip4||'0000').replace(/\D/g,'').padStart(4,'0').substring(0,4); const dpbcp = (r.dpbc||'00').replace(/\D/g,'').padStart(2,'0').substring(0,2); const pst_imb = bc_id + stid + mid + serial + z5p + z4p + dpbcp; let pst_imb_ec = ''; if(typeof _IMB !== 'undefined' && _IMB.encode){ const imb20 = (bc_id + stid + mid + serial).padEnd(20,'0').substring(0,20); const bars = _IMB.encode(imb20); if(bars) pst_imb_ec = bars.join(''); } const manfst = `${pcNo} AV ${rate}`; const row = { // ── INPUT pass-through ── NAME: r.name||'', ADDRESS1: '', ADDRESS2: r.addr2||'', ADDRESS3: r.addr1||'', CITY: r.city||'', STATE: r.state||'', ZIP: r.zip5||'', ZIP4: r.zip4||'', COMPANY: '', CD_MAILOWN: r.cd_mailown||'', CD_STID: r.cd_stid||'', CRT: r.crt||'', DPBC: r.dpbc||'', LOT: r.lot||'', LOTORD: r.lotord||'A', CD_PROMOTI: r.cd_promoti||'', CD_MID: r.cd_mid||'', CD_SERIAL: r.cd_serial||'', WIDTH: r.widthIn||'', HEIGHT: r.heightIn||'', THICKNESS: r.thicknessIn||'', WEIGHT: r.weightOz||'', RecordId: r.recordId||pcNo, // ── PST_ — assigned by presort engine ── PST_OPT_EN: pst_opt_en.substring(0,35), PST_POSTN1: '', // presort position 1 — reserved PST_POSTN2: '', // presort position 2 — reserved PST_IMB: pst_imb, PST_IMB_EC: pst_imb_ec, PST_PC_NO_: pcNo, // absolute piece number PST_Pkg_Br: '', // package break — blank per ref PST_Pkg_No: pkgNo_t, PST_Ctn_Br: '', // container break — blank per ref PST_Ctn_No: ctnNo_t, PST_Plt_Br: '', PST_Plt_No: '', // ── FNL_ — final delivery address from CASS/input ── FNL_EXTADR: r.fnl_extadr||'', FNL_SECADR: r.fnl_secadr||'', FNL_PRIADR: r.addr1||'', FNL_CITY: r.city||'', FNL_STATE: r.state||'', FNL_ZIP: r.zip5||'', FNL_ZIP4: r.zip4||'', FNL_CRT: r.crt||'', FNL_DPBC: r.dpbc||'', FNL_LOT: r.lot||'', FNL_LOTORD: r.lotord||'', FNL_Achkdi: '', // CASS address check digit — not in input FNL_ERRSTT: '', // CASS error status — not in input FNL_RECTYP: '', // record type — not in input FNL_DPVFTN: '', // DPV footnote — not in input FNL_DPVSTT: '', // DPV status — not in input FNL_COUNTY: '', // county name — not in input FNL_CNTNUM: '', // county number — not in input FNL_CONGCD: '', // congressional district — not in input manfst_key: manfst }; const csvRow = V2_COLS.map(c => { const v = String(row[c]||'').replace(/"/g,'""'); return `"${v}"`; }).join(','); csvLines.push(csvRow); pcNo++; } } const content = csvLines.join('\r\n'); dlText(content, `Presort_Output_V2_${jobId||'job'}.csv`, 'text/csv'); rpt_status(`✓ V2 CSV exported — ${pcNo-1} pieces`); } // ───────────────────────────────────────────────────────────────────────────── // 7. PresortOutput CSV — tray-level summary // ───────────────────────────────────────────────────────────────────────────── function rpt_presortOutputCsv(){ if(!result){ rpt_status('✗ Run presort first — load a job and click Run.'); return; } const {bd,totalRecs,total,jobId} = rpt_getInfo(); const cols = ['TrayNo','Level','Abbreviation','Destination','Size','Pieces','Rate','Subtotal']; const lines = [cols.map(c=>`"${c}"`).join(',')]; for(const t of bd){ const row = [ t.trayNo||'', t.level||'', RPT_LVL[t.level]||t.level, t.key||'', t.size||'', t.count||0, (t.nr||t.rate||0).toFixed(3), (t.sub||0).toFixed(4) ]; lines.push(row.map(v=>`"${String(v).replace(/"/g,'""')}"`).join(',')); } // Summary footer rows lines.push(`"","","","TOTAL","",${totalRecs},"","${total.toFixed(4)}"`); const content = lines.join('\r\n'); dlText(content, `PresortOutput_${jobId||'job'}.csv`, 'text/csv'); rpt_status(`✓ PresortOutput CSV exported — ${bd.length} trays`); } // ───────────────────────────────────────────────────────────────────────────── // Batch generators // ───────────────────────────────────────────────────────────────────────────── function rpt_all(){ rpt_clearDownloads(); rpt_status('Generating reports...'); // Build all 4 PDFs and queue download links - avoids browser download blocking let count=0, errors=[]; function done(label,ok){ count++; if(!ok) errors.push(label); if(count===4) rpt_status(errors.length?('✗ Errors: '+errors.join(', ')):'✓ All 4 reports ready — click links above to download'); } try{ rpt_mailSortListing(); done('Mail Sort Listing',true); }catch(e){ done('Mail Sort Listing',false); } try{ rpt_qualificationReport(); done('Qualification Report',true); }catch(e){ done('Qualification Report',false); } try{ rpt_registerOfMailing(); done('Register of Mailings',true); }catch(e){ done('Register of Mailings',false); } try{ rpt_postalStatement(); done('Postal Statement',true); }catch(e){ done('Postal Statement',false); } } function rpt_allCsv(){ rpt_v3csv(); setTimeout(()=>rpt_v2csv(), 300); setTimeout(()=>rpt_presortOutputCsv(), 600); setTimeout(()=>rpt_status('✓ All 3 CSV files exported.'), 900); } function dlText(content,name,mime='text/html'){ const b=new Blob([content],{type:mime});const u=URL.createObjectURL(b); const a=document.createElement('a');a.href=u;a.download=name; document.body.appendChild(a);a.click();document.body.removeChild(a);URL.revokeObjectURL(u); } function showErr(m){const e=document.getElementById('err');e.style.display=m?'block':'none';e.textContent=m;} // ─── setMode: toggle between Address blocks and CSV input ─────────────────── if (typeof window.setMode !== 'function') { window.setMode = function(mode) { var tp = document.getElementById('text-input-area'); var cp = document.getElementById('csv-input-area'); var bt = document.getElementById('btn-text'); var bc = document.getElementById('btn-csv'); if (mode === 'csv') { if (tp) tp.style.display = 'none'; if (cp) cp.style.display = 'block'; if (bt) bt.classList.remove('on'); if (bc) bc.classList.add('on'); } else { if (tp) tp.style.display = 'block'; if (cp) cp.style.display = 'none'; if (bt) bt.classList.add('on'); if (bc) bc.classList.remove('on'); } }; }