6 lines
73 KiB
JavaScript
6 lines
73 KiB
JavaScript
import{D as e,M as t}from"./package-Bop5TfAT.js";import{t as n}from"./jszip.min-CoyCHGS6.js";var r=e=>{let t=e.split(` `),n=[],r=0;for(;r<t.length;){if(t[r]===`M`||t[r]===`S`){let e={type:`M`,x:parseFloat(t[r+1]),y:parseFloat(t[r+2])};r+=3,n.push(e)}if(t[r]===`L`){let e={type:`L`,x:parseFloat(t[r+1]),y:parseFloat(t[r+2])};r+=3,n.push(e)}else if(t[r]===`C`)n.push({type:`C`,x:0,y:0}),r++;else if(t[r]===`B`){let e={type:`B`,x1:parseFloat(t[r+1]),y1:parseFloat(t[r+2]),x2:parseFloat(t[r+3]),y2:parseFloat(t[r+4]),x3:parseFloat(t[r+5]),y3:parseFloat(t[r+6])};r+=7,n.push(e)}else r++}return n},i=function(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r.type===`M`||r.type===`L`||r.type===`C`){let e=0,n=0;e=r.x,n=r.y,r.x=d(e),r.y=d(n),t.push(r)}else if(r.type===`B`){let e=r.x1,n=r.y1,i=r.x2,a=r.y2,o=r.x3,s=r.y3,c={type:`B`,x1:d(e),y1:d(n),x2:d(i),y2:d(a),x3:d(o),y3:d(s)};t.push(c)}}return t},a=function(e,t){return e*t/25.4},o=10,s=o,c=function(e){o=e>5?5:e},l=function(e){s=e>1?e:1,s=s>o?o:s},u=function(){return s},d=function(e){return a(e,s*25.4)},f=function(e){if(e.indexOf(`g`)===-1){let t=[];for(let n of e.split(` `))t.push(parseFloat(n));return t}else{let t=e.split(` `),n=!1,r=!1,i=0,a=[];for(let e of t)if(e===`g`)n=!0;else{if(!e||e.trim().length==0)continue;if(n)i=parseInt(e),r=!0,n=!1;else if(r){for(let t=0;t<i;t++)a.push(parseFloat(e));r=!1}else a.push(parseFloat(e))}return a}},p=function(e){let t=0,n=0,r=[];if(!e)return r;for(let i of e){if(!i)continue;t=parseFloat(i[`@_X`]),n=parseFloat(i[`@_Y`]),isNaN(t)&&(t=0),isNaN(n)&&(n=0);let e=[],a=[];i[`@_DeltaX`]&&i[`@_DeltaX`].length>0&&(e=f(i[`@_DeltaX`])),i[`@_DeltaY`]&&i[`@_DeltaY`].length>0&&(a=f(i[`@_DeltaY`]));let o=i[`#text`];if(o){o+=``,o=v(o),o=o.replace(/ /g,` `);for(let i=0;i<o.length;i++){i>0&&e.length>0&&(t+=e[i-1]),i>0&&a.length>0&&(n+=a[i-1]);let s=o.substring(i,i+1),c=r.filter(e=>e.y==d(n));if(c&&c.length)c[0].text+=s;else{let e={x:d(t),y:d(n),text:s};r.push(e)}}}}return r},m=function(e){return e&&e.indexOf(`/`)===0&&(e=e.replace(`/`,``)),e},h=function(e){return!e&&typeof e!=`string`?``:e.substring(e.lastIndexOf(`.`)+1)},g=/&\w+;|&#(\d+);/g,_={"<":`<`,">":`>`,"&":`&`," ":` `,""":`"`,"©":``,"'":`'`},v=function(e){return e??=this.toString(),typeof e==`string`?e.replace(g,function(e,t){var n=_[e];return n??=isNaN(t)?e:String.fromCharCode(t==160?32:t),n}):e},y={楷体:`楷体, KaiTi, Kai, simkai`,kaiti:`楷体, KaiTi, Kai, simkai`,Kai:`楷体, KaiTi, Kai`,simsun:`SimSun, simsun, Songti SC`,宋体:`SimSun, simsun, Songti SC`,黑体:`SimHei, STHeiti, simhei`,仿宋:`FangSong, STFangsong, simfang`,小标宋体:`sSun`,方正小标宋_gbk:`sSun`,仿宋_gb2312:`FangSong, STFangsong, simfang`,楷体_gb2312:`楷体, KaiTi, Kai, simkai`,couriernew:`Courier New`,"courier new":`Courier New`},b=function(e){y[e.toLowerCase()]&&(e=y[e.toLowerCase()]);for(let t of Object.keys(y))if(e.toLowerCase().indexOf(t.toLowerCase())!=-1)return y[t];return e},x=function(e){if(e){let t=e.split(` `);return{x:parseFloat(t[0]),y:parseFloat(t[1]),w:parseFloat(t[2]),h:parseFloat(t[3])}}else return null},S=function(e){return e.split(` `)},C=function(e){if(e){if(e.indexOf(`#`)!==-1)return e=e.replace(/#/g,``),e=e.replace(/ /g,``),e=`#`+e.toString(),e;let t=e.split(` `);return`rgb(${t[0]}, ${t[1]}, ${t[2]})`}else return`rgb(0, 0, 0)`},w=function(e){return{x:d(e.x),y:d(e.y),w:d(e.w),h:d(e.h)}},T=function(e,t,n){let r=n[Object.keys(n)[0]].json[`ofd:Area`],i;if(r){let e=r[`ofd:PhysicalBox`];if(e)i=e;else{let e=r[`ofd:ApplicationBox`];if(e)i=e;else{let e=r[`ofd:ContentBox`];e&&(i=e)}}}else{let e=t[`ofd:CommonData`][`ofd:PageArea`],n=e[`ofd:PhysicalBox`];if(n)i=n;else{let t=e[`ofd:ApplicationBox`];if(t)i=t;else{let t=e[`ofd:ContentBox`];t&&(i=t)}}}let a=i.split(` `),o=((e-10)/parseFloat(a[2])).toFixed(1);return c(o),l(o),i=x(i),i=w(i),i},E=function(e,t){let n=t[Object.keys(t)[0]].json[`ofd:Area`],r;if(n){let e=n[`ofd:PhysicalBox`];if(e)r=e;else{let e=n[`ofd:ApplicationBox`];if(e)r=e;else{let e=n[`ofd:ContentBox`];e&&(r=e)}}}else{let t=e[`ofd:CommonData`][`ofd:PageArea`],n=t[`ofd:PhysicalBox`];if(n)r=n;else{let e=t[`ofd:ApplicationBox`];if(e)r=e;else{let e=t[`ofd:ContentBox`];e&&(r=e)}}}return r=x(r),r=w(r),r},D=function(e,t,n,r,i,a){let o=[],s=e[t[`@_TemplateID`]].json[`ofd:Content`][`ofd:Layer`];o=o.concat(s);for(let e of o)e&&j(n,r,i,a,e,!1)},O=function(e,t,n,r,i,a){let o=Object.keys(t)[0],s=t[o].json[`ofd:Template`];Array.isArray(s)?s.forEach(t=>{t&&D(n,t,e,r,i,a)}):s&&D(n,s,e,r,i,a);let c=t[o]?.json?.[`ofd:Content`]?.[`ofd:Layer`],l=[];l=l.concat(c);for(let t of l)t&&j(e,r,i,a,t,!1);if(t[o].stamp){for(let n of t[o].stamp)if(n.type===`ofd`)A(e,n.obj.pages,n.obj.tpls,!0,n.stamp.stampAnnot,n.obj.fontResObj,n.obj.drawParamResObj,n.obj.multiMediaResObj,n.stamp.sealObj.SES_Signature,n.stamp.signedInfo);else if(n.type===`png`){let t=w(n.obj.boundary),r=Array.isArray(n.stamp.stampAnnot)?n.stamp.stampAnnot[0].pfIndex:n.stamp.stampAnnot.pfIndex,i=P(e.style.width,e.style.height,n.obj.img,t,n.obj.clip,!0,n.stamp.sealObj.SES_Signature,n.stamp.signedInfo,r);e.appendChild(i)}}if(t[o].annotation)for(let n of t[o].annotation)k(e,n,r,i,a)},k=function(e,t,n,r,i){let a=document.createElement(`div`);a.setAttribute(`style`,`overflow: hidden;z-index:${t.pfIndex};position:relative;`);let o=t.appearance?.[`@_Boundary`];if(o){let e=w(x(o));a.setAttribute(`style`,`overflow: hidden;z-index:${t.pfIndex};position:absolute; left: ${e.x}px; top: ${e.y}px; width: ${e.w}px; height: ${e.h}px`)}let s=t.appearance;j(a,n,r,i,s,!1),e.appendChild(a)},A=function(e,t,n,r,i,a,o,s,c,l){for(let u of t){let t=Object.keys(u)[0],d={x:0,y:0,w:0,h:0};r&&i&&(d=i.boundary);let f=w(d),p=document.createElement(`div`);p.setAttribute(`name`,`seal_img_div`),p.setAttribute(`style`,`cursor: pointer; position:relative; left: ${f.x}px; top: ${f.y}px; width: ${f.w}px; height: ${f.h}px`),p.setAttribute(`data-ses-signature`,`${JSON.stringify(c)}`),p.setAttribute(`data-signed-info`,`${JSON.stringify(l)}`);let m=u[t].json[`ofd:Template`];if(m){let e=n[m[`@_TemplateID`]].json[`ofd:Content`][`ofd:Layer`],t=[];t=t.concat(e);for(let e of t)e&&j(p,a,o,s,e,r)}let h=u[t].json[`ofd:Content`][`ofd:Layer`],g=[];g=g.concat(h);for(let e of g)e&&j(p,a,o,s,e,r);e.appendChild(p)}},j=function(e,t,n,r,i,a){let o=null,s=null,c=d(.353),l=i?.[`@_DrawParam`];l&&Object.keys(n).length>0&&n[l]&&(n[l].relative&&(l=n[l].relative,n[l].FillColor&&(o=C(n[l].FillColor)),n[l].StrokeColor&&(s=C(n[l].StrokeColor)),n[l].LineWidth&&(c=d(n[l].LineWidth))),n[l].FillColor&&(o=C(n[l].FillColor)),n[l].StrokeColor&&(s=C(n[l].StrokeColor)),n[l].LineWidth&&(c=d(n[l].LineWidth)));let u=i?.[`ofd:ImageObject`],f=[];f=f.concat(u);for(let t of f)if(t){let n=M(e.style.width,e.style.height,r,t);e.appendChild(n)}let p=i?.[`ofd:PathObject`],m=[];m=m.concat(p);for(let t of m)if(t){let r=I(n,t,o,s,c,a);e.appendChild(r)}let h=i?.[`ofd:TextObject`],g=[];g=g.concat(h);for(let n of g)if(n){let r=F(t,n,o,s);e.appendChild(r)}},M=function(e,t,n,r){let i=x(r[`@_Boundary`]);i=w(i);let a=r[`@_ResourceID`];if(n[a].format===`gbig2`){let e=n[a].img,t=n[a].width,o=n[a].height;return N(e,t,o,i,r.pfIndex)}else return P(e,t,n[a].img,i,!1,!1,null,null,r.pfIndex)},N=function(e,t,n,r,i){let a=new Uint8ClampedArray(4*t*n);for(var o=0;o<e.length;o++)a[4*o]=e[o],a[4*o+1]=e[o],a[4*o+2]=e[o],a[4*o+3]=255;let s=new ImageData(a,t,n),c=document.createElement(`canvas`);return c.width=t,c.height=n,c.getContext(`2d`).putImageData(s,0,0),c.setAttribute(`style`,`left: ${r.x}px; top: ${r.y}px; width: ${r.w}px; height: ${r.h}px;z-index: ${i}`),c.style.position=`absolute`,c},P=function(e,t,n,r,i,a,o,s,c){let l=document.createElement(`div`);a&&(l.setAttribute(`name`,`seal_img_div`),l.setAttribute(`data-ses-signature`,`${JSON.stringify(o)}`),l.setAttribute(`data-signed-info`,`${JSON.stringify(s)}`));let u=document.createElement(`img`);u.src=n,u.setAttribute(`width`,`100%`),u.setAttribute(`height`,`100%`),l.appendChild(u);let d=parseFloat(e.replace(`px`,``)),f=parseFloat(t.replace(`px`,``)),p=r.w>d?d:r.w,m=r.h>f?f:r.h,h=``;return i&&(i=w(i),h=`clip: rect(${i.y}px, ${i.w+i.x}px, ${i.h+i.y}px, ${i.x}px)`),l.setAttribute(`style`,`cursor: pointer; overflow: hidden; position: absolute; left: ${h?r.x:r.x<0?0:r.x}px; top: ${h?r.y:r.y<0?0:r.y}px; width: ${p}px; height: ${m}px; ${h};z-index: ${c}`),l},F=function(e,t,n,r){let i=1,a=x(t[`@_Boundary`]);a=w(a);let o=t[`@_CTM`],s=t[`@_HScale`],c=t[`@_Font`],l=t[`@_Weight`],u=d(parseFloat(t[`@_Size`])),f=[];f=f.concat(t[`ofd:TextCode`]);let m=p(f),h=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);h.setAttribute(`version`,`1.1`);let g=t[`ofd:FillColor`];if(g){n=C(g[`@_Value`]);let e=g[`@_Alpha`];e&&(i=e>1?e/255:e)}for(let t of m)if(t&&!isNaN(t.x)){let a=document.createElementNS(`http://www.w3.org/2000/svg`,`text`);if(a.setAttribute(`x`,t.x),a.setAttribute(`y`,t.y),a.innerHTML=t.text,o){let e=S(o);a.setAttribute(`transform`,`matrix(${e[0]} ${e[1]} ${e[2]} ${e[3]} ${d(e[4])} ${d(e[5])})`)}s&&a.setAttribute(`transform`,`matrix(${s}, 0, 0, 1, ${(1-s)*t.x}, 0)`),a.setAttribute(`fill`,r),a.setAttribute(`fill`,n),a.setAttribute(`fill-opacity`,i),a.setAttribute(`style`,`font-weight: ${l};font-size:${u}px;font-family: ${b(e[c])};`),h.appendChild(a)}let _=a.w,v=a.h,y=a.x,T=a.y;return h.setAttribute(`style`,`overflow:visible;position:absolute;width:${_}px;height:${v}px;left:${y}px;top:${T}px;z-index:${t.pfIndex}`),h},I=function(e,t,n,a,o,s){let c=x(t[`@_Boundary`]);c=w(c);let l=t[`@_LineWidth`],u=t[`ofd:AbbreviatedData`],f=i(r(u)),p=t[`@_CTM`],m=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);m.setAttribute(`version`,`1.1`);let h=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);l&&(o=d(l));let g=t[`@_DrawParam`];if(g&&(l=e[g].LineWidth,l&&(o=d(l))),p){let e=S(p);h.setAttribute(`transform`,`matrix(${e[0]} ${e[1]} ${e[2]} ${e[3]} ${d(e[4])} ${d(e[5])})`)}let _=``,v=t[`ofd:StrokeColor`];v&&(a=C(v[`@_Value`]));let y=`fill: none;`,b=t[`ofd:FillColor`];b&&(n=C(b[`@_Value`])),o>0&&!a&&(a=n,a||=`rgb(0, 0, 0)`),_=`stroke:${a};stroke-width:${o}px;`,t[`@_Stroke`]==`false`&&(_=``),t[`@_Fill`]!=`false`&&(y=`fill:${s?`none`:n||`none`};`),h.setAttribute(`style`,`${_};${y}`);let T=``;for(let e of f)e.type===`M`?T+=`M${e.x} ${e.y} `:e.type===`L`?T+=`L${e.x} ${e.y} `:e.type===`B`?T+=`C${e.x1} ${e.y1} ${e.x2} ${e.y2} ${e.x3} ${e.y3} `:e.type===`C`&&(T+=`Z`);h.setAttribute(`d`,T),m.appendChild(h);let E=s?c.w:Math.ceil(c.w),D=s?c.h:Math.ceil(c.h),O=c.x,k=c.y;return m.setAttribute(`style`,`overflow:visible;position:absolute;width:${E}px;height:${D}px;left:${O}px;top:${k}px;z-index:${t.pfIndex}`),m};Array.prototype.pipeline=async function(e){if(this===null||this===void 0)throw TypeError(`Array.prototype.pipeline called on null or undefined`);if(typeof e!=`function`)throw TypeError(e+` is not a function`);var t,n,r=this.length>>>0;for(t=0;r>t;++t)n=await e(n,this[t],t,this);return n};var L=function(...e){return e.pipeline((e,t)=>t.call(this,e))},R=e((e=>{var t=`[:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*`,n=RegExp(`^[:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`);e.isExist=function(e){return e!==void 0},e.isEmptyObject=function(e){return Object.keys(e).length===0},e.merge=function(e,t,n){if(t){let r=Object.keys(t),i=r.length;for(let a=0;a<i;a++)n===`strict`?e[r[a]]=[t[r[a]]]:e[r[a]]=t[r[a]]}},e.getValue=function(t){return e.isExist(t)?t:``},e.buildOptions=function(e,t,n){var r={};if(!e)return t;for(let i=0;i<n.length;i++)e[n[i]]===void 0?r[n[i]]=t[n[i]]:r[n[i]]=e[n[i]];return r},e.isName=function(e){return n.exec(e)!=null},e.getAllMatches=function(e,t){let n=[],r=t.exec(e);for(;r;){let i=[],a=r.length;for(let e=0;e<a;e++)i.push(r[e]);n.push(i),r=t.exec(e)}return n},e.nameRegexp=t})),z=e((e=>{var t=R(),n=function(e,r){let i={};if((!e.child||t.isEmptyObject(e.child))&&(!e.attrsMap||t.isEmptyObject(e.attrsMap)))return t.isExist(e.val)?e.val:``;t.isExist(e.val)&&(typeof e.val==`string`&&(e.val===``||e.val===r.cdataPositionChar)||(r.arrayMode===`strict`?i[r.textNodeName]=[e.val]:i[r.textNodeName]=e.val)),t.merge(i,e.attrsMap,r.arrayMode);let a=Object.keys(e.child);for(let t=0;t<a.length;t++){var o=a[t];if(e.child[o]&&e.child[o].length>1)for(var s in i[o]=[],e.child[o])global.xmlParseFlag=global.xmlParseFlag+1,i[o].push(n(e.child[o][s],r));else if(r.arrayMode===!0){global.xmlParseFlag=global.xmlParseFlag+1;let t=n(e.child[o][0],r);typeof t==`object`?i[o]=[t]:i[o]=t}else r.arrayMode===`strict`?(global.xmlParseFlag=global.xmlParseFlag+1,i[o]=[n(e.child[o][0],r)]):(global.xmlParseFlag=global.xmlParseFlag+1,i[o]=n(e.child[o][0],r))}return i};e.convertToJson=n})),B=e(((e,t)=>{t.exports=function(e,t,n){this.tagname=e,this.parent=t,this.child={},this.attrsMap={},this.val=n,this.addChild=function(e){Array.isArray(this.child[e.tagname])?this.child[e.tagname].push(e):this.child[e.tagname]=[e]}}})),V=e((e=>{var t=R(),n=R().buildOptions,r=B();`<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)`.replace(/NAME/g,t.nameRegexp),!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt),!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);var i={attributeNamePrefix:`@_`,attrNodeName:!1,textNodeName:`#text`,ignoreAttributes:!0,ignoreNameSpace:!1,allowBooleanAttributes:!1,parseNodeValue:!0,parseAttributeValue:!1,arrayMode:!1,trimValues:!0,cdataTagName:!1,cdataPositionChar:`\\c`,tagValueProcessor:function(e,t){return e},attrValueProcessor:function(e,t){return e},stopNodes:[]};e.defaultOptions=i;var a=[`attributeNamePrefix`,`attrNodeName`,`textNodeName`,`ignoreAttributes`,`ignoreNameSpace`,`allowBooleanAttributes`,`parseNodeValue`,`parseAttributeValue`,`arrayMode`,`trimValues`,`cdataTagName`,`cdataPositionChar`,`tagValueProcessor`,`attrValueProcessor`,`parseTrueNumberOnly`,`stopNodes`];e.props=a;function o(e,t,n){return t&&=(n.trimValues&&(t=t.trim()),t=n.tagValueProcessor(t,e),c(t,n.parseNodeValue,n.parseTrueNumberOnly)),t}function s(e,t){if(t.ignoreNameSpace){let t=e.split(`:`),n=e.charAt(0)===`/`?`/`:``;if(t[0]===`xmlns`)return``;t.length===2&&(e=n+t[1])}return e}function c(e,n,r){if(n&&typeof e==`string`){let t;return e.trim()===``||isNaN(e)?t=e===`true`?!0:e===`false`?!1:e:(e.indexOf(`0x`)===-1?e.indexOf(`.`)===-1?t=Number.parseInt(e,10):(t=Number.parseFloat(e),e=e.replace(/\.?0+$/,``)):t=Number.parseInt(e,16),r&&(t=String(t)===e?t:e)),t}else if(t.isExist(e))return e;else return``}var l=RegExp(`([^\\s=]+)\\s*(=\\s*(['"])(.*?)\\3)?`,`g`);function u(e,n){if(!n.ignoreAttributes&&typeof e==`string`){e=e.replace(/\r?\n/g,` `);let r=t.getAllMatches(e,l),i=r.length,a={};for(let e=0;e<i;e++){let t=s(r[e][1],n);t.length&&(r[e][4]===void 0?n.allowBooleanAttributes&&(a[n.attributeNamePrefix+t]=!0):(n.trimValues&&(r[e][4]=r[e][4].trim()),r[e][4]=n.attrValueProcessor(r[e][4],t),a[n.attributeNamePrefix+t]=c(r[e][4],n.parseAttributeValue,n.parseTrueNumberOnly)))}if(!Object.keys(a).length)return;if(n.attrNodeName){let e={};return e[n.attrNodeName]=a,e}return a}}var d=function(e,s){e=e.replace(/\r\n?/g,`
|
||
`),s=n(s,i,a);let c=new r(`!xml`),l=c,d=``;for(let n=0;n<e.length;n++)if(e[n]===`<`)if(e[n+1]===`/`){let r=p(e,`>`,n,`Closing Tag is not closed.`),i=e.substring(n+2,r).trim();if(s.ignoreNameSpace){let e=i.indexOf(`:`);e!==-1&&(i=i.substr(e+1))}l&&(l.val?l.val=t.getValue(l.val)+``+o(i,d,s):l.val=o(i,d,s)),s.stopNodes.length&&s.stopNodes.includes(l.tagname)&&(l.child=[],l.attrsMap??={},l.val=e.substr(l.startIndex+1,n-l.startIndex-1)),l=l.parent,d=``,n=r}else if(e[n+1]===`?`)n=p(e,`?>`,n,`Pi Tag is not closed.`);else if(e.substr(n+1,3)===`!--`)n=p(e,`-->`,n,`Comment is not closed.`);else if(e.substr(n+1,2)===`!D`){let t=p(e,`>`,n,`DOCTYPE is not closed.`);n=e.substring(n,t).indexOf(`[`)>=0?e.indexOf(`]>`,n)+1:t}else if(e.substr(n+1,2)===`![`){let i=p(e,`]]>`,n,`CDATA is not closed.`)-2,a=e.substring(n+9,i);if(d&&=(l.val=t.getValue(l.val)+``+o(l.tagname,d,s),``),s.cdataTagName){let e=new r(s.cdataTagName,l,a);l.addChild(e),l.val=t.getValue(l.val)+s.cdataPositionChar,a&&(e.val=a)}else l.val=(l.val||``)+(a||``);n=i+2}else{let i=f(e,n+1),a=i.data,c=i.index,p=a.indexOf(` `),m=a;if(p!==-1&&(m=a.substr(0,p).replace(/\s\s*$/,``),a=a.substr(p+1)),s.ignoreNameSpace){let e=m.indexOf(`:`);e!==-1&&(m=m.substr(e+1))}if(l&&d&&l.tagname!==`!xml`&&(l.val=t.getValue(l.val)+``+o(l.tagname,d,s)),a.length>0&&a.lastIndexOf(`/`)===a.length-1){m[m.length-1]===`/`?(m=m.substr(0,m.length-1),a=m):a=a.substr(0,a.length-1);let e=new r(m,l,``);m!==a&&(e.attrsMap=u(a,s)),l.addChild(e)}else{let e=new r(m,l);s.stopNodes.length&&s.stopNodes.includes(e.tagname)&&(e.startIndex=c),m!==a&&(e.attrsMap=u(a,s)),l.addChild(e),l=e}d=``,n=c}else d+=e[n];return c};function f(e,t){let n,r=``;for(let i=t;i<e.length;i++){let t=e[i];if(n)t===n&&(n=``);else if(t===`"`||t===`'`)n=t;else if(t===`>`)return{data:r,index:i};else t===` `&&(t=` `);r+=t}}function p(e,t,n,r){let i=e.indexOf(t,n);if(i===-1)throw Error(r);return i+t.length-1}e.getTraversalObj=d})),H=e((e=>{var t=R(),n={allowBooleanAttributes:!1},r=[`allowBooleanAttributes`];e.validate=function(e,o){o=t.buildOptions(o,n,r);let s=[],l=!1,d=!1;e[0]===``&&(e=e.substr(1));for(let t=0;t<e.length;t++)if(e[t]===`<`)if(t++,e[t]===`?`){if(t=i(e,++t),t.err)return t}else if(e[t]===`!`){t=a(e,t);continue}else{let n=!1;e[t]===`/`&&(n=!0,t++);let r=``;for(;t<e.length&&e[t]!==`>`&&e[t]!==` `&&e[t]!==` `&&e[t]!==`
|
||
`&&e[t]!==`\r`;t++)r+=e[t];if(r=r.trim(),r[r.length-1]===`/`&&(r=r.substring(0,r.length-1),t--),!h(r)){let n;return n=r.trim().length===0?`There is an unnecessary space between tag name and backward slash '</ ..'.`:`Tag '`+r+`' is an invalid name.`,p(`InvalidTag`,n,g(e,t))}let i=c(e,t);if(i===!1)return p(`InvalidAttr`,`Attributes for '`+r+`' have open quote.`,g(e,t));let m=i.value;if(t=i.index,m[m.length-1]===`/`){m=m.substring(0,m.length-1);let n=u(m,o);if(n===!0)l=!0;else return p(n.err.code,n.err.msg,g(e,t-m.length+n.err.line))}else if(n){if(!i.tagClosed)return p(`InvalidTag`,`Closing tag '`+r+`' doesn't have proper closing.`,g(e,t));if(m.trim().length>0)return p(`InvalidTag`,`Closing tag '`+r+`' can't have attributes or invalid starting.`,g(e,t));{let n=s.pop();if(r!==n)return p(`InvalidTag`,`Closing tag '`+n+`' is expected inplace of '`+r+`'.`,g(e,t));s.length==0&&(d=!0)}}else{let n=u(m,o);if(n!==!0)return p(n.err.code,n.err.msg,g(e,t-m.length+n.err.line));if(d===!0)return p(`InvalidXml`,`Multiple possible root nodes found.`,g(e,t));s.push(r),l=!0}for(t++;t<e.length;t++)if(e[t]===`<`)if(e[t+1]===`!`){t++,t=a(e,t);continue}else break;else if(e[t]===`&`){let n=f(e,t);if(n==-1)return p(`InvalidChar`,`char '&' is not expected.`,g(e,t));t=n}e[t]===`<`&&t--}else{if(e[t]===` `||e[t]===` `||e[t]===`
|
||
`||e[t]===`\r`)continue;return p(`InvalidChar`,`char '`+e[t]+`' is not expected.`,g(e,t))}return l?s.length>0?p(`InvalidXml`,`Invalid '`+JSON.stringify(s,null,4).replace(/\r?\n/g,``)+`' found.`,1):!0:p(`InvalidXml`,`Start tag expected.`,1)};function i(e,t){for(var n=t;t<e.length;t++)if(e[t]==`?`||e[t]==` `){var r=e.substr(n,t-n);if(t>5&&r===`xml`)return p(`InvalidXml`,`XML declaration allowed only at the start of the document.`,g(e,t));if(e[t]==`?`&&e[t+1]==`>`){t++;break}else continue}return t}function a(e,t){if(e.length>t+5&&e[t+1]===`-`&&e[t+2]===`-`){for(t+=3;t<e.length;t++)if(e[t]===`-`&&e[t+1]===`-`&&e[t+2]===`>`){t+=2;break}}else if(e.length>t+8&&e[t+1]===`D`&&e[t+2]===`O`&&e[t+3]===`C`&&e[t+4]===`T`&&e[t+5]===`Y`&&e[t+6]===`P`&&e[t+7]===`E`){let n=1;for(t+=8;t<e.length;t++)if(e[t]===`<`)n++;else if(e[t]===`>`&&(n--,n===0))break}else if(e.length>t+9&&e[t+1]===`[`&&e[t+2]===`C`&&e[t+3]===`D`&&e[t+4]===`A`&&e[t+5]===`T`&&e[t+6]===`A`&&e[t+7]===`[`){for(t+=8;t<e.length;t++)if(e[t]===`]`&&e[t+1]===`]`&&e[t+2]===`>`){t+=2;break}}return t}var o=`"`,s=`'`;function c(e,t){let n=``,r=``,i=!1;for(;t<e.length;t++){if(e[t]===o||e[t]===s)if(r===``)r=e[t];else if(r!==e[t])continue;else r=``;else if(e[t]===`>`&&r===``){i=!0;break}n+=e[t]}return r===``?{value:n,index:t,tagClosed:i}:!1}var l=RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,`g`);function u(e,n){let r=t.getAllMatches(e,l),i={};for(let t=0;t<r.length;t++){if(r[t][1].length===0)return p(`InvalidAttr`,`Attribute '`+r[t][2]+`' has no space in starting.`,_(e,r[t][0]));if(r[t][3]===void 0&&!n.allowBooleanAttributes)return p(`InvalidAttr`,`boolean attribute '`+r[t][2]+`' is not allowed.`,_(e,r[t][0]));let a=r[t][2];if(!m(a))return p(`InvalidAttr`,`Attribute '`+a+`' is an invalid name.`,_(e,r[t][0]));if(!i.hasOwnProperty(a))i[a]=1;else return p(`InvalidAttr`,`Attribute '`+a+`' is repeated.`,_(e,r[t][0]))}return!0}function d(e,t){let n=/\d/;for(e[t]===`x`&&(t++,n=/[\da-fA-F]/);t<e.length;t++){if(e[t]===`;`)return t;if(!e[t].match(n))break}return-1}function f(e,t){if(t++,e[t]===`;`)return-1;if(e[t]===`#`)return t++,d(e,t);let n=0;for(;t<e.length;t++,n++)if(!(e[t].match(/\w/)&&n<20)){if(e[t]===`;`)break;return-1}return t}function p(e,t,n){return{err:{code:e,msg:t,line:n}}}function m(e){return t.isName(e)}function h(e){return t.isName(e)}function g(e,t){return e.substring(0,t).split(/\r?\n/).length}function _(e,t){return e.indexOf(t)+t.length}})),U=e((e=>{var t=function(e){return String.fromCharCode(e)},n={nilChar:t(176),missingChar:t(201),nilPremitive:t(175),missingPremitive:t(200),emptyChar:t(178),emptyValue:t(177),boundryChar:t(179),objStart:t(198),arrStart:t(204),arrayEnd:t(185)},r=[n.nilChar,n.nilPremitive,n.missingChar,n.missingPremitive,n.boundryChar,n.emptyChar,n.emptyValue,n.arrayEnd,n.objStart,n.arrStart],i=function(e,t,r){if(typeof t==`string`)return e&&e[0]&&e[0].val!==void 0?a(e[0].val,t):a(e,t);{let s=c(e);if(s===!0){let s=``;if(Array.isArray(t)){s+=n.arrStart;let c=t[0],l=e.length;if(typeof c==`string`)for(let t=0;t<l;t++){let n=a(e[t].val,c);s=o(s,n)}else for(let t=0;t<l;t++){let n=i(e[t],c,r);s=o(s,n)}s+=n.arrayEnd}else{s+=n.objStart;let a=Object.keys(t);Array.isArray(e)&&(e=e[0]);for(let n in a){let c=a[n],l;l=!r.ignoreAttributes&&e.attrsMap&&e.attrsMap[c]?i(e.attrsMap[c],t[c],r):c===r.textNodeName?i(e.val,t[c],r):i(e.child[c],t[c],r),s=o(s,l)}}return s}else return s}},a=function(e){switch(e){case void 0:return n.missingPremitive;case null:return n.nilPremitive;case``:return n.emptyValue;default:return e}},o=function(e,t){return!s(t[0])&&!s(e[e.length-1])&&(e+=n.boundryChar),e+t},s=function(e){return r.indexOf(e)!==-1};function c(e){return e===void 0?n.missingChar:e===null?n.nilChar:e.child&&Object.keys(e.child).length===0&&(!e.attrsMap||Object.keys(e.attrsMap).length===0)?n.emptyChar:!0}var l=V(),u=R().buildOptions;e.convert2nimn=function(e,t,n){return n=u(n,l.defaultOptions,l.props),i(e,t,n)}})),W=e((e=>{var t=R(),n=R().buildOptions,r=V(),i=function(e,t){return t=n(t,r.defaultOptions,r.props),t.indentBy=t.indentBy||``,a(e,t,0)},a=function(e,n,r){let i=`{`,s=Object.keys(e.child);for(let t=0;t<s.length;t++){var c=s[t];if(e.child[c]&&e.child[c].length>1){for(var l in i+=`"`+c+`" : [ `,e.child[c])i+=a(e.child[c][l],n)+` , `;i=i.substr(0,i.length-1)+` ] `}else i+=`"`+c+`" : `+a(e.child[c][0],n)+` ,`}return t.merge(i,e.attrsMap),t.isEmptyObject(i)?t.isExist(e.val)?e.val:``:(t.isExist(e.val)&&(typeof e.val==`string`&&(e.val===``||e.val===n.cdataPositionChar)||(i+=`"`+n.textNodeName+`" : `+o(e.val))),i[i.length-1]===`,`&&(i=i.substr(0,i.length-2)),i+`}`)};function o(e){return e===!0||e===!1||!isNaN(e)?e:`"`+e+`"`}e.convertToJsonString=i})),G=e(((e,t)=>{var n=R().buildOptions,r={attributeNamePrefix:`@_`,attrNodeName:!1,textNodeName:`#text`,ignoreAttributes:!0,cdataTagName:!1,cdataPositionChar:`\\c`,format:!1,indentBy:` `,supressEmptyNode:!1,tagValueProcessor:function(e){return e},attrValueProcessor:function(e){return e}},i=[`attributeNamePrefix`,`attrNodeName`,`textNodeName`,`ignoreAttributes`,`cdataTagName`,`cdataPositionChar`,`format`,`indentBy`,`supressEmptyNode`,`tagValueProcessor`,`attrValueProcessor`];function a(e){this.options=n(e,r,i),this.options.ignoreAttributes||this.options.attrNodeName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=p),this.options.cdataTagName?this.isCDATA=m:this.isCDATA=function(){return!1},this.replaceCDATAstr=o,this.replaceCDATAarr=s,this.options.format?(this.indentate=f,this.tagEndChar=`>
|
||
`,this.newLine=`
|
||
`):(this.indentate=function(){return``},this.tagEndChar=`>`,this.newLine=``),this.options.supressEmptyNode?(this.buildTextNode=d,this.buildObjNode=l):(this.buildTextNode=u,this.buildObjNode=c),this.buildTextValNode=u,this.buildObjectNode=c}a.prototype.parse=function(e){return this.j2x(e,0).val},a.prototype.j2x=function(e,t){let n=``,r=``,i=Object.keys(e),a=i.length;for(let o=0;o<a;o++){let a=i[o];if(e[a]!==void 0)if(e[a]===null)r+=this.indentate(t)+`<`+a+`/`+this.tagEndChar;else if(e[a]instanceof Date)r+=this.buildTextNode(e[a],a,``,t);else if(typeof e[a]!=`object`){let i=this.isAttribute(a);i?n+=` `+i+`="`+this.options.attrValueProcessor(``+e[a])+`"`:this.isCDATA(a)?e[this.options.textNodeName]?r+=this.replaceCDATAstr(e[this.options.textNodeName],e[a]):r+=this.replaceCDATAstr(``,e[a]):a===this.options.textNodeName?e[this.options.cdataTagName]||(r+=this.options.tagValueProcessor(``+e[a])):r+=this.buildTextNode(e[a],a,``,t)}else if(Array.isArray(e[a]))if(this.isCDATA(a))r+=this.indentate(t),e[this.options.textNodeName]?r+=this.replaceCDATAarr(e[this.options.textNodeName],e[a]):r+=this.replaceCDATAarr(``,e[a]);else{let n=e[a].length;for(let i=0;i<n;i++){let n=e[a][i];if(n!==void 0)if(n===null)r+=this.indentate(t)+`<`+a+`/`+this.tagEndChar;else if(typeof n==`object`){let e=this.j2x(n,t+1);r+=this.buildObjNode(e.val,a,e.attrStr,t)}else r+=this.buildTextNode(n,a,``,t)}}else if(this.options.attrNodeName&&a===this.options.attrNodeName){let t=Object.keys(e[a]),r=t.length;for(let i=0;i<r;i++)n+=` `+t[i]+`="`+this.options.attrValueProcessor(``+e[a][t[i]])+`"`}else{let n=this.j2x(e[a],t+1);r+=this.buildObjNode(n.val,a,n.attrStr,t)}}return{attrStr:n,val:r}};function o(e,t){return e=this.options.tagValueProcessor(``+e),this.options.cdataPositionChar===``||e===``?e+`<![CDATA[`+t+`]]`+this.tagEndChar:e.replace(this.options.cdataPositionChar,`<![CDATA[`+t+`]]`+this.tagEndChar)}function s(e,t){if(e=this.options.tagValueProcessor(``+e),this.options.cdataPositionChar===``||e===``)return e+`<![CDATA[`+t.join(`]]><![CDATA[`)+`]]`+this.tagEndChar;for(let n in t)e=e.replace(this.options.cdataPositionChar,`<![CDATA[`+t[n]+`]]>`);return e+this.newLine}function c(e,t,n,r){return n&&!e.includes(`<`)?this.indentate(r)+`<`+t+n+`>`+e+`</`+t+this.tagEndChar:this.indentate(r)+`<`+t+n+this.tagEndChar+e+this.indentate(r)+`</`+t+this.tagEndChar}function l(e,t,n,r){return e===``?this.indentate(r)+`<`+t+n+`/`+this.tagEndChar:this.buildObjectNode(e,t,n,r)}function u(e,t,n,r){return this.indentate(r)+`<`+t+n+`>`+this.options.tagValueProcessor(e)+`</`+t+this.tagEndChar}function d(e,t,n,r){return e===``?this.indentate(r)+`<`+t+n+`/`+this.tagEndChar:this.buildTextValNode(e,t,n,r)}function f(e){return this.options.indentBy.repeat(e)}function p(e){return e.startsWith(this.options.attributeNamePrefix)?e.substr(this.attrPrefixLen):!1}function m(e){return e===this.options.cdataTagName}t.exports=a})),K=e((e=>{var t=z(),n=V(),r=V(),i=R().buildOptions,a=H();e.parse=function(e,o,s){if(s){s===!0&&(s={});let t=a.validate(e,s);if(t!==!0)throw Error(t.err.msg)}o=i(o,r.defaultOptions,r.props);let c=n.getTraversalObj(e,o);return t.convertToJson(c,o)},e.convertTonimn=U().convert2nimn,e.getTraversalObj=n.getTraversalObj,e.convertToJson=t.convertToJson,e.convertToJsonString=W().convertToJsonString,e.validate=a.validate,e.j2xParser=G(),e.parseToNimn=function(t,n,r){return e.convertTonimn(e.getTraversalObj(t,r),n,r)}})),q=t(n(),1),ee=t(K(),1);globalThis._pdfjsCompatibilityChecked||(globalThis._pdfjsCompatibilityChecked=!0);var te={ERRORS:0,WARNINGS:1,INFOS:5},ne=te.WARNINGS;function J(e){ne>=te.INFOS&&console.log(`Info: ${e}`)}function re(e){throw Error(e)}function ie(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!1}),n}var ae=(function(){function e(t){this.constructor===e&&re(`Cannot initialize BaseException.`),this.message=t,this.name=this.constructor.name}return e.prototype=Error(),e.constructor=e,e})();(function(){let e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`;return function(t,n,r=!1){if(!r&&URL.createObjectURL){let e=new Blob([t],{type:n});return URL.createObjectURL(e)}let i=`data:${n};base64,`;for(let n=0,r=t.length;n<r;n+=3){let a=t[n]&255,o=t[n+1]&255,s=t[n+2]&255,c=a>>2,l=(a&3)<<4|o>>4,u=n+1<r?(o&15)<<2|s>>6:64,d=n+2<r?s&63:64;i+=e[c]+e[l]+e[u]+e[d]}return i}})();function oe(e){return e<=0?0:Math.ceil(Math.log2(e))}function Y(e,t){return e[t]<<24>>24}function X(e,t){return e[t]<<8|e[t+1]}function Z(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}var se=[{qe:22017,nmps:1,nlps:1,switchFlag:1},{qe:13313,nmps:2,nlps:6,switchFlag:0},{qe:6145,nmps:3,nlps:9,switchFlag:0},{qe:2753,nmps:4,nlps:12,switchFlag:0},{qe:1313,nmps:5,nlps:29,switchFlag:0},{qe:545,nmps:38,nlps:33,switchFlag:0},{qe:22017,nmps:7,nlps:6,switchFlag:1},{qe:21505,nmps:8,nlps:14,switchFlag:0},{qe:18433,nmps:9,nlps:14,switchFlag:0},{qe:14337,nmps:10,nlps:14,switchFlag:0},{qe:12289,nmps:11,nlps:17,switchFlag:0},{qe:9217,nmps:12,nlps:18,switchFlag:0},{qe:7169,nmps:13,nlps:20,switchFlag:0},{qe:5633,nmps:29,nlps:21,switchFlag:0},{qe:22017,nmps:15,nlps:14,switchFlag:1},{qe:21505,nmps:16,nlps:14,switchFlag:0},{qe:20737,nmps:17,nlps:15,switchFlag:0},{qe:18433,nmps:18,nlps:16,switchFlag:0},{qe:14337,nmps:19,nlps:17,switchFlag:0},{qe:13313,nmps:20,nlps:18,switchFlag:0},{qe:12289,nmps:21,nlps:19,switchFlag:0},{qe:10241,nmps:22,nlps:19,switchFlag:0},{qe:9217,nmps:23,nlps:20,switchFlag:0},{qe:8705,nmps:24,nlps:21,switchFlag:0},{qe:7169,nmps:25,nlps:22,switchFlag:0},{qe:6145,nmps:26,nlps:23,switchFlag:0},{qe:5633,nmps:27,nlps:24,switchFlag:0},{qe:5121,nmps:28,nlps:25,switchFlag:0},{qe:4609,nmps:29,nlps:26,switchFlag:0},{qe:4353,nmps:30,nlps:27,switchFlag:0},{qe:2753,nmps:31,nlps:28,switchFlag:0},{qe:2497,nmps:32,nlps:29,switchFlag:0},{qe:2209,nmps:33,nlps:30,switchFlag:0},{qe:1313,nmps:34,nlps:31,switchFlag:0},{qe:1089,nmps:35,nlps:32,switchFlag:0},{qe:673,nmps:36,nlps:33,switchFlag:0},{qe:545,nmps:37,nlps:34,switchFlag:0},{qe:321,nmps:38,nlps:35,switchFlag:0},{qe:273,nmps:39,nlps:36,switchFlag:0},{qe:133,nmps:40,nlps:37,switchFlag:0},{qe:73,nmps:41,nlps:38,switchFlag:0},{qe:37,nmps:42,nlps:39,switchFlag:0},{qe:21,nmps:43,nlps:40,switchFlag:0},{qe:9,nmps:44,nlps:41,switchFlag:0},{qe:5,nmps:45,nlps:42,switchFlag:0},{qe:1,nmps:45,nlps:43,switchFlag:0},{qe:22017,nmps:46,nlps:46,switchFlag:0}],ce=class{constructor(e,t,n){this.data=e,this.bp=t,this.dataEnd=n,this.chigh=e[t],this.clow=0,this.byteIn(),this.chigh=this.chigh<<7&65535|this.clow>>9&127,this.clow=this.clow<<7&65535,this.ct-=7,this.a=32768}byteIn(){let e=this.data,t=this.bp;e[t]===255?e[t+1]>143?(this.clow+=65280,this.ct=8):(t++,this.clow+=e[t]<<9,this.ct=7,this.bp=t):(t++,this.clow+=t<this.dataEnd?e[t]<<8:65280,this.ct=8,this.bp=t),this.clow>65535&&(this.chigh+=this.clow>>16,this.clow&=65535)}readBit(e,t){let n=e[t]>>1,r=e[t]&1,i=se[n],a=i.qe,o,s=this.a-a;if(this.chigh<a)s<a?(s=a,o=r,n=i.nmps):(s=a,o=1^r,i.switchFlag===1&&(r=o),n=i.nlps);else{if(this.chigh-=a,s&32768)return this.a=s,r;s<a?(o=1^r,i.switchFlag===1&&(r=o),n=i.nlps):(o=r,n=i.nmps)}do this.ct===0&&this.byteIn(),s<<=1,this.chigh=this.chigh<<1&65535|this.clow>>15&1,this.clow=this.clow<<1&65535,this.ct--;while(!(s&32768));return this.a=s,e[t]=n<<1|r,o}},le=(function(){let e=[[-1,-1],[-1,-1],[7,8],[7,7],[6,6],[6,6],[6,5],[6,5],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2]],t=[[-1,-1],[12,-2],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[12,1984],[12,2048],[12,2112],[12,2176],[12,2240],[12,2304],[11,1856],[11,1856],[11,1920],[11,1920],[12,2368],[12,2432],[12,2496],[12,2560]],n=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[8,29],[8,29],[8,30],[8,30],[8,45],[8,45],[8,46],[8,46],[7,22],[7,22],[7,22],[7,22],[7,23],[7,23],[7,23],[7,23],[8,47],[8,47],[8,48],[8,48],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[7,20],[7,20],[7,20],[7,20],[8,33],[8,33],[8,34],[8,34],[8,35],[8,35],[8,36],[8,36],[8,37],[8,37],[8,38],[8,38],[7,19],[7,19],[7,19],[7,19],[8,31],[8,31],[8,32],[8,32],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[8,53],[8,53],[8,54],[8,54],[7,26],[7,26],[7,26],[7,26],[8,39],[8,39],[8,40],[8,40],[8,41],[8,41],[8,42],[8,42],[8,43],[8,43],[8,44],[8,44],[7,21],[7,21],[7,21],[7,21],[7,28],[7,28],[7,28],[7,28],[8,61],[8,61],[8,62],[8,62],[8,63],[8,63],[8,0],[8,0],[8,320],[8,320],[8,384],[8,384],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[7,27],[7,27],[7,27],[7,27],[8,59],[8,59],[8,60],[8,60],[9,1472],[9,1536],[9,1600],[9,1728],[7,18],[7,18],[7,18],[7,18],[7,24],[7,24],[7,24],[7,24],[8,49],[8,49],[8,50],[8,50],[8,51],[8,51],[8,52],[8,52],[7,25],[7,25],[7,25],[7,25],[8,55],[8,55],[8,56],[8,56],[8,57],[8,57],[8,58],[8,58],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[8,448],[8,448],[8,512],[8,512],[9,704],[9,768],[8,640],[8,640],[8,576],[8,576],[9,832],[9,896],[9,960],[9,1024],[9,1088],[9,1152],[9,1216],[9,1280],[9,1344],[9,1408],[7,256],[7,256],[7,256],[7,256],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7]],r=[[-1,-1],[-1,-1],[12,-2],[12,-2],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[11,1792],[11,1792],[12,1984],[12,1984],[12,2048],[12,2048],[12,2112],[12,2112],[12,2176],[12,2176],[12,2240],[12,2240],[12,2304],[12,2304],[11,1856],[11,1856],[11,1856],[11,1856],[11,1920],[11,1920],[11,1920],[11,1920],[12,2368],[12,2368],[12,2432],[12,2432],[12,2496],[12,2496],[12,2560],[12,2560],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[12,52],[12,52],[13,640],[13,704],[13,768],[13,832],[12,55],[12,55],[12,56],[12,56],[13,1280],[13,1344],[13,1408],[13,1472],[12,59],[12,59],[12,60],[12,60],[13,1536],[13,1600],[11,24],[11,24],[11,24],[11,24],[11,25],[11,25],[11,25],[11,25],[13,1664],[13,1728],[12,320],[12,320],[12,384],[12,384],[12,448],[12,448],[13,512],[13,576],[12,53],[12,53],[12,54],[12,54],[13,896],[13,960],[13,1024],[13,1088],[13,1152],[13,1216],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64]],i=[[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[11,23],[11,23],[12,50],[12,51],[12,44],[12,45],[12,46],[12,47],[12,57],[12,58],[12,61],[12,256],[10,16],[10,16],[10,16],[10,16],[10,17],[10,17],[10,17],[10,17],[12,48],[12,49],[12,62],[12,63],[12,30],[12,31],[12,32],[12,33],[12,40],[12,41],[11,22],[11,22],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[12,128],[12,192],[12,26],[12,27],[12,28],[12,29],[11,19],[11,19],[11,20],[11,20],[12,34],[12,35],[12,36],[12,37],[12,38],[12,39],[11,21],[11,21],[12,42],[12,43],[10,0],[10,0],[10,0],[10,0],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12]],a=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[6,9],[6,8],[5,7],[5,7],[4,6],[4,6],[4,6],[4,6],[4,5],[4,5],[4,5],[4,5],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2]];function o(e,t={}){if(!e||typeof e.next!=`function`)throw Error(`CCITTFaxDecoder - invalid "source" parameter.`);this.source=e,this.eof=!1,this.encoding=t.K||0,this.eoline=t.EndOfLine||!1,this.byteAlign=t.EncodedByteAlign||!1,this.columns=t.Columns||1728,this.rows=t.Rows||0;let n=t.EndOfBlock;n??=!0,this.eoblock=n,this.black=t.BlackIs1||!1,this.codingLine=new Uint32Array(this.columns+1),this.refLine=new Uint32Array(this.columns+2),this.codingLine[0]=this.columns,this.codingPos=0,this.row=0,this.nextLine2D=this.encoding<0,this.inputBits=0,this.inputBuf=0,this.outputBits=0,this.rowsDone=!1;let r;for(;(r=this._lookBits(12))===0;)this._eatBits(1);r===1&&this._eatBits(12),this.encoding>0&&(this.nextLine2D=!this._lookBits(1),this._eatBits(1))}return o.prototype={readNextChar(){if(this.eof)return-1;let e=this.refLine,t=this.codingLine,n=this.columns,r,i,a,o;if(this.outputBits===0){if(this.rowsDone&&(this.eof=!0),this.eof)return-1;this.err=!1;let a,s,c;if(this.nextLine2D){for(o=0;t[o]<n;++o)e[o]=t[o];for(e[o++]=n,e[o]=n,t[0]=0,this.codingPos=0,r=0,i=0;t[this.codingPos]<n;)switch(a=this._getTwoDimCode(),a){case 0:this._addPixels(e[r+1],i),e[r+1]<n&&(r+=2);break;case 1:if(a=s=0,i){do a+=c=this._getBlackCode();while(c>=64);do s+=c=this._getWhiteCode();while(c>=64)}else{do a+=c=this._getWhiteCode();while(c>=64);do s+=c=this._getBlackCode();while(c>=64)}for(this._addPixels(t[this.codingPos]+a,i),t[this.codingPos]<n&&this._addPixels(t[this.codingPos]+s,i^1);e[r]<=t[this.codingPos]&&e[r]<n;)r+=2;break;case 7:if(this._addPixels(e[r]+3,i),i^=1,t[this.codingPos]<n)for(++r;e[r]<=t[this.codingPos]&&e[r]<n;)r+=2;break;case 5:if(this._addPixels(e[r]+2,i),i^=1,t[this.codingPos]<n)for(++r;e[r]<=t[this.codingPos]&&e[r]<n;)r+=2;break;case 3:if(this._addPixels(e[r]+1,i),i^=1,t[this.codingPos]<n)for(++r;e[r]<=t[this.codingPos]&&e[r]<n;)r+=2;break;case 2:if(this._addPixels(e[r],i),i^=1,t[this.codingPos]<n)for(++r;e[r]<=t[this.codingPos]&&e[r]<n;)r+=2;break;case 8:if(this._addPixelsNeg(e[r]-3,i),i^=1,t[this.codingPos]<n)for(r>0?--r:++r;e[r]<=t[this.codingPos]&&e[r]<n;)r+=2;break;case 6:if(this._addPixelsNeg(e[r]-2,i),i^=1,t[this.codingPos]<n)for(r>0?--r:++r;e[r]<=t[this.codingPos]&&e[r]<n;)r+=2;break;case 4:if(this._addPixelsNeg(e[r]-1,i),i^=1,t[this.codingPos]<n)for(r>0?--r:++r;e[r]<=t[this.codingPos]&&e[r]<n;)r+=2;break;case-1:this._addPixels(n,0),this.eof=!0;break;default:J(`bad 2d code`),this._addPixels(n,0),this.err=!0}}else for(t[0]=0,this.codingPos=0,i=0;t[this.codingPos]<n;){if(a=0,i)do a+=c=this._getBlackCode();while(c>=64);else do a+=c=this._getWhiteCode();while(c>=64);this._addPixels(t[this.codingPos]+a,i),i^=1}let l=!1;if(this.byteAlign&&(this.inputBits&=-8),!this.eoblock&&this.row===this.rows-1)this.rowsDone=!0;else{if(a=this._lookBits(12),this.eoline)for(;a!==-1&&a!==1;)this._eatBits(1),a=this._lookBits(12);else for(;a===0;)this._eatBits(1),a=this._lookBits(12);a===1?(this._eatBits(12),l=!0):a===-1&&(this.eof=!0)}if(!this.eof&&this.encoding>0&&!this.rowsDone&&(this.nextLine2D=!this._lookBits(1),this._eatBits(1)),this.eoblock&&l&&this.byteAlign){if(a=this._lookBits(12),a===1){if(this._eatBits(12),this.encoding>0&&(this._lookBits(1),this._eatBits(1)),this.encoding>=0)for(o=0;o<4;++o)a=this._lookBits(12),a!==1&&J(`bad rtc code: `+a),this._eatBits(12),this.encoding>0&&(this._lookBits(1),this._eatBits(1));this.eof=!0}}else if(this.err&&this.eoline){for(;;){if(a=this._lookBits(13),a===-1)return this.eof=!0,-1;if(a>>1==1)break;this._eatBits(1)}this._eatBits(12),this.encoding>0&&(this._eatBits(1),this.nextLine2D=!(a&1))}t[0]>0?this.outputBits=t[this.codingPos=0]:this.outputBits=t[this.codingPos=1],this.row++}let s;if(this.outputBits>=8)s=this.codingPos&1?0:255,this.outputBits-=8,this.outputBits===0&&t[this.codingPos]<n&&(this.codingPos++,this.outputBits=t[this.codingPos]-t[this.codingPos-1]);else{a=8,s=0;do this.outputBits>a?(s<<=a,this.codingPos&1||(s|=255>>8-a),this.outputBits-=a,a=0):(s<<=this.outputBits,this.codingPos&1||(s|=255>>8-this.outputBits),a-=this.outputBits,this.outputBits=0,t[this.codingPos]<n?(this.codingPos++,this.outputBits=t[this.codingPos]-t[this.codingPos-1]):a>0&&(s<<=a,a=0));while(a)}return this.black&&(s^=255),s},_addPixels(e,t){let n=this.codingLine,r=this.codingPos;e>n[r]&&(e>this.columns&&(J(`row is wrong length`),this.err=!0,e=this.columns),r&1^t&&++r,n[r]=e),this.codingPos=r},_addPixelsNeg(e,t){let n=this.codingLine,r=this.codingPos;if(e>n[r])e>this.columns&&(J(`row is wrong length`),this.err=!0,e=this.columns),r&1^t&&++r,n[r]=e;else if(e<n[r]){for(e<0&&(J(`invalid code`),this.err=!0,e=0);r>0&&e<n[r-1];)--r;n[r]=e}this.codingPos=r},_findTableCode(e,t,n,r){let i=r||0;for(let r=e;r<=t;++r){let e=this._lookBits(r);if(e===-1)return[!0,1,!1];if(r<t&&(e<<=t-r),!i||e>=i){let t=n[e-i];if(t[0]===r)return this._eatBits(r),[!0,t[1],!0]}}return[!1,0,!1]},_getTwoDimCode(){let t=0,n;if(this.eoblock){if(t=this._lookBits(7),n=e[t],n&&n[0]>0)return this._eatBits(n[0]),n[1]}else{let t=this._findTableCode(1,7,e);if(t[0]&&t[2])return t[1]}return J(`Bad two dim code`),-1},_getWhiteCode(){let e=0,r;if(this.eoblock){if(e=this._lookBits(12),e===-1)return 1;if(r=e>>5?n[e>>3]:t[e],r[0]>0)return this._eatBits(r[0]),r[1]}else{let e=this._findTableCode(1,9,n);if(e[0]||(e=this._findTableCode(11,12,t),e[0]))return e[1]}return J(`bad white code`),this._eatBits(1),1},_getBlackCode(){let e,t;if(this.eoblock){if(e=this._lookBits(13),e===-1)return 1;if(t=e>>7?!(e>>9)&&e>>7?i[(e>>1)-64]:a[e>>7]:r[e],t[0]>0)return this._eatBits(t[0]),t[1]}else{let e=this._findTableCode(2,6,a);if(e[0]||(e=this._findTableCode(7,12,i,64),e[0])||(e=this._findTableCode(10,13,r),e[0]))return e[1]}return J(`bad black code`),this._eatBits(1),1},_lookBits(e){let t;for(;this.inputBits<e;){if((t=this.source.next())===-1)return this.inputBits===0?-1:this.inputBuf<<e-this.inputBits&65535>>16-e;this.inputBuf=this.inputBuf<<8|t,this.inputBits+=8}return this.inputBuf>>this.inputBits-e&65535>>16-e},_eatBits(e){(this.inputBits-=e)<0&&(this.inputBits=0)}},o})(),Q=class extends ae{constructor(e){super(`JBIG2 error: ${e}`)}},ue=(function(){function e(){}e.prototype={getContexts(e){return e in this?this[e]:this[e]=new Int8Array(65536)}};function t(e,t,n){this.data=e,this.start=t,this.end=n}t.prototype={get decoder(){var e=new ce(this.data,this.start,this.end);return ie(this,`decoder`,e)},get contextCache(){var t=new e;return ie(this,`contextCache`,t)}};function n(e,t,n){var r=e.getContexts(t),i=1;function a(e){for(var t=0,a=0;a<e;a++){var o=n.readBit(r,i);i=i<256?i<<1|o:(i<<1|o)&511|256,t=t<<1|o}return t>>>0}var o=a(1),s=a(1)?a(1)?a(1)?a(1)?a(1)?a(32)+4436:a(12)+340:a(8)+84:a(6)+20:a(4)+4:a(2);return o===0?s:s>0?-s:null}function r(e,t,n){for(var r=e.getContexts(`IAID`),i=1,a=0;a<n;a++){var o=t.readBit(r,i);i=i<<1|o}return n<31?i&(1<<n)-1:i&2147483647}var i=[`SymbolDictionary`,null,null,null,`IntermediateTextRegion`,null,`ImmediateTextRegion`,`ImmediateLosslessTextRegion`,null,null,null,null,null,null,null,null,`PatternDictionary`,null,null,null,`IntermediateHalftoneRegion`,null,`ImmediateHalftoneRegion`,`ImmediateLosslessHalftoneRegion`,null,null,null,null,null,null,null,null,null,null,null,null,`IntermediateGenericRegion`,null,`ImmediateGenericRegion`,`ImmediateLosslessGenericRegion`,`IntermediateGenericRefinementRegion`,null,`ImmediateGenericRefinementRegion`,`ImmediateLosslessGenericRefinementRegion`,null,null,null,null,`PageInformation`,`EndOfPage`,`EndOfStripe`,`EndOfFile`,`Profiles`,`Tables`,null,null,null,null,null,null,null,null,`Extension`],a=[[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:2,y:-1},{x:-4,y:0},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}],[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:2,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:2,y:-1},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}],[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-2,y:0},{x:-1,y:0}],[{x:-3,y:-1},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-4,y:0},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}]],o=[{coding:[{x:0,y:-1},{x:1,y:-1},{x:-1,y:0}],reference:[{x:0,y:-1},{x:1,y:-1},{x:-1,y:0},{x:0,y:0},{x:1,y:0},{x:-1,y:1},{x:0,y:1},{x:1,y:1}]},{coding:[{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-1,y:0}],reference:[{x:0,y:-1},{x:-1,y:0},{x:0,y:0},{x:1,y:0},{x:0,y:1},{x:1,y:1}]}],s=[39717,1941,229,405],c=[32,8];function l(e,t,n){var r=n.decoder,i=n.contextCache.getContexts(`GB`),a,o,s,c,l,u,d,f=[],p=31735;for(o=0;o<t;o++)for(l=f[o]=new Uint8Array(e),u=o<1?l:f[o-1],d=o<2?l:f[o-2],a=d[0]<<13|d[1]<<12|d[2]<<11|u[0]<<7|u[1]<<6|u[2]<<5|u[3]<<4,s=0;s<e;s++)l[s]=c=r.readBit(i,a),a=(a&p)<<1|(s+3<e?d[s+3]<<11:0)|(s+4<e?u[s+4]<<4:0)|c;return f}function u(e,t,n,r,i,o,c,u){if(e)return I(new j(u.data,u.start,u.end),t,n,!1);if(r===0&&!o&&!i&&c.length===4&&c[0].x===3&&c[0].y===-1&&c[1].x===-3&&c[1].y===-1&&c[2].x===2&&c[2].y===-2&&c[3].x===-2&&c[3].y===-2)return l(t,n,u);var d=!!o,f=a[r].concat(c);f.sort(function(e,t){return e.y-t.y||e.x-t.x});var p=f.length,m=new Int8Array(p),h=new Int8Array(p),g=[],_=0,v=0,y=0,b=0,x,S;for(S=0;S<p;S++)m[S]=f[S].x,h[S]=f[S].y,v=Math.min(v,f[S].x),y=Math.max(y,f[S].x),b=Math.min(b,f[S].y),S<p-1&&f[S].y===f[S+1].y&&f[S].x===f[S+1].x-1?_|=1<<p-1-S:g.push(S);var C=g.length,w=new Int8Array(C),T=new Int8Array(C),E=new Uint16Array(C);for(x=0;x<C;x++)S=g[x],w[x]=f[S].x,T[x]=f[S].y,E[x]=1<<p-1-S;for(var D=-v,O=-b,k=t-y,A=s[r],M=new Uint8Array(t),N=[],P=u.decoder,F=u.contextCache.getContexts(`GB`),L=0,R,z,B,V=0,H,U,W=0;W<n;W++){if(i){var G=P.readBit(F,A);if(L^=G,L){N.push(M);continue}}for(M=new Uint8Array(M),N.push(M),R=0;R<t;R++){if(d&&o[W][R]){M[R]=0;continue}if(R>=D&&R<k&&W>=O)for(V=V<<1&_,S=0;S<C;S++)z=W+T[S],B=R+w[S],H=N[z][B],H&&(H=E[S],V|=H);else for(V=0,U=p-1,S=0;S<p;S++,U--)B=R+m[S],B>=0&&B<t&&(z=W+h[S],z>=0&&(H=N[z][B],H&&(V|=H<<U)));var K=P.readBit(F,V);M[R]=K}}return N}function d(e,t,n,r,i,a,s,l,u){var d=o[n].coding;n===0&&(d=d.concat([l[0]]));var f=d.length,p=new Int32Array(f),m=new Int32Array(f),h;for(h=0;h<f;h++)p[h]=d[h].x,m[h]=d[h].y;var g=o[n].reference;n===0&&(g=g.concat([l[1]]));var _=g.length,v=new Int32Array(_),y=new Int32Array(_);for(h=0;h<_;h++)v[h]=g[h].x,y[h]=g[h].y;for(var b=r[0].length,x=r.length,S=c[n],C=[],w=u.decoder,T=u.contextCache.getContexts(`GR`),E=0,D=0;D<t;D++){if(s){var O=w.readBit(T,S);if(E^=O,E)throw new Q(`prediction is not supported`)}var k=new Uint8Array(e);C.push(k);for(var A=0;A<e;A++){var j,M,N=0;for(h=0;h<f;h++)j=D+m[h],M=A+p[h],j<0||M<0||M>=e?N<<=1:N=N<<1|C[j][M];for(h=0;h<_;h++)j=D+y[h]-a,M=A+v[h]-i,j<0||j>=x||M<0||M>=b?N<<=1:N=N<<1|r[j][M];k[A]=w.readBit(T,N)}}return C}function f(e,t,i,a,o,s,c,l,f,m,h,g){if(e&&t)throw new Q(`symbol refinement with Huffman is not supported`);var _=[],v=0,y=oe(i.length+a),b=h.decoder,x=h.contextCache;let S,C;for(e&&(S=A(1),C=[],y=Math.max(y,1));_.length<a;){var w=e?s.tableDeltaHeight.decode(g):n(x,`IADH`,b);v+=w;let a=0,o=0,S=e?C.length:0;for(;;){var T=e?s.tableDeltaWidth.decode(g):n(x,`IADW`,b);if(T===null)break;a+=T,o+=a;var E;if(t){var D=n(x,`IAAI`,b);if(D>1)E=p(e,t,a,v,0,D,1,i.concat(_),y,0,0,1,0,s,f,m,h,0,g);else{var O=r(x,b,y),k=n(x,`IARDX`,b),j=n(x,`IARDY`,b),M=O<i.length?i[O]:_[O-i.length];E=d(a,v,f,M,k,j,!1,m,h)}_.push(E)}else e?C.push(a):(E=u(!1,a,v,c,!1,null,l,h),_.push(E))}if(e&&!t){let e=s.tableBitmapSize.decode(g);g.byteAlign();let t;if(e===0)t=F(g,o,v);else{let n=g.end,r=g.position+e;g.end=r,t=I(g,o,v,!1),g.end=n,g.position=r}let n=C.length;if(S===n-1)_.push(t);else{let e,r,i=0,a,o,s;for(e=S;e<n;e++){for(o=C[e],a=i+o,s=[],r=0;r<v;r++)s.push(t[r].subarray(i,a));_.push(s),i=a}}}}for(var N=[],P=[],L=!1,R=i.length+a;P.length<R;){for(var z=e?S.decode(g):n(x,`IAEX`,b);z--;)P.push(L);L=!L}for(var B=0,V=i.length;B<V;B++)P[B]&&N.push(i[B]);for(var H=0;H<a;B++,H++)P[B]&&N.push(_[H]);return N}function p(e,t,i,a,o,s,c,l,u,f,p,m,h,g,_,v,y,b,x){if(e&&t)throw new Q(`refinement with Huffman is not supported`);var S=[],C,w;for(C=0;C<a;C++){if(w=new Uint8Array(i),o)for(var T=0;T<i;T++)w[T]=o;S.push(w)}var E=y.decoder,D=y.contextCache,O=e?-g.tableDeltaT.decode(x):-n(D,`IADT`,E),k=0;for(C=0;C<s;){var A=e?g.tableDeltaT.decode(x):n(D,`IADT`,E);O+=A;var j=e?g.tableFirstS.decode(x):n(D,`IAFS`,E);k+=j;var M=k;do{let a=0;c>1&&(a=e?x.readBits(b):n(D,`IAIT`,E));var N=c*O+a,P=e?g.symbolIDTable.decode(x):r(D,E,u),F=t&&(e?x.readBit():n(D,`IARI`,E)),I=l[P],L=I[0].length,R=I.length;if(F){var z=n(D,`IARDW`,E),B=n(D,`IARDH`,E),V=n(D,`IARDX`,E),H=n(D,`IARDY`,E);L+=z,R+=B,I=d(L,R,_,I,(z>>1)+V,(B>>1)+H,!1,v,y)}var U=N-(m&1?0:R-1),W=M-(m&2?L-1:0),G,K,q;if(f){for(G=0;G<R;G++)if(w=S[W+G],w){q=I[G];var ee=Math.min(i-U,L);switch(h){case 0:for(K=0;K<ee;K++)w[U+K]|=q[K];break;case 2:for(K=0;K<ee;K++)w[U+K]^=q[K];break;default:throw new Q(`operator ${h} is not supported`)}}M+=R-1}else{for(K=0;K<R;K++)if(w=S[U+K],w)switch(q=I[K],h){case 0:for(G=0;G<L;G++)w[W+G]|=q[G];break;case 2:for(G=0;G<L;G++)w[W+G]^=q[G];break;default:throw new Q(`operator ${h} is not supported`)}M+=L-1}C++;var te=e?g.tableDeltaS.decode(x):n(D,`IADS`,E);if(te===null)break;M+=te+p}while(!0)}return S}function m(e,t,n,r,i,a){let o=[];e||(o.push({x:-t,y:0}),i===0&&(o.push({x:-3,y:-1}),o.push({x:2,y:-2}),o.push({x:-2,y:-2})));let s=u(e,(r+1)*t,n,i,!1,null,o,a),c=[];for(let e=0;e<=r;e++){let r=[],i=t*e,a=i+t;for(let e=0;e<n;e++)r.push(s[e].subarray(i,a));c.push(r)}return c}function h(e,t,n,r,i,a,o,s,c,l,d,f,p,m,h){if(o)throw new Q(`skip is not supported`);if(s!==0)throw new Q(`operator `+s+` is not supported in halftone region`);let g=[],_,v,y;for(_=0;_<i;_++){if(y=new Uint8Array(r),a)for(v=0;v<r;v++)y[v]=a;g.push(y)}let b=t.length,x=t[0],S=x[0].length,C=x.length,w=oe(b),T=[];e||(T.push({x:n<=1?3:2,y:-1}),n===0&&(T.push({x:-3,y:-1}),T.push({x:2,y:-2}),T.push({x:-2,y:-2})));let E=[],D,O;for(e&&(D=new j(h.data,h.start,h.end)),_=w-1;_>=0;_--)O=e?I(D,c,l,!0):u(!1,c,l,n,!1,null,T,h),E[_]=O;let k,A,M,N,P,F,L,R,z;for(k=0;k<l;k++)for(A=0;A<c;A++){for(M=0,N=0,v=w-1;v>=0;v--)M=E[v][k][A]^M,N|=M<<v;if(P=t[N],F=d+k*m+A*p>>8,L=f+k*p-A*m>>8,F>=0&&F+S<=r&&L>=0&&L+C<=i)for(_=0;_<C;_++)for(z=g[L+_],R=P[_],v=0;v<S;v++)z[F+v]|=R[v];else{let e,t;for(_=0;_<C;_++)if(t=L+_,!(t<0||t>=i))for(z=g[t],R=P[_],v=0;v<S;v++)e=F+v,e>=0&&e<r&&(z[e]|=R[v])}}return g}function g(e,t){var n={};n.number=Z(e,t);var r=e[t+4],a=r&63;if(!i[a])throw new Q(`invalid segment type: `+a);n.type=a,n.typeName=i[a],n.deferredNonRetain=!!(r&128);var o=!!(r&64),s=e[t+5],c=s>>5&7,l=[s&31],u=t+6;if(s===7){c=Z(e,u-1)&536870911,u+=3;var d=c+7>>3;for(l[0]=e[u++];--d>0;)l.push(e[u++])}else if(s===5||s===6)throw new Q(`invalid referred-to flags`);n.retainBits=l;let f=4;n.number<=256?f=1:n.number<=65536&&(f=2);var p=[],m,h;for(m=0;m<c;m++){let t;t=f===1?e[u]:f===2?X(e,u):Z(e,u),p.push(t),u+=f}if(n.referredTo=p,o?(n.pageAssociation=Z(e,u),u+=4):n.pageAssociation=e[u++],n.length=Z(e,u),u+=4,n.length===4294967295)if(a===38){var g=v(e,u),_=!!(e[u+y]&1),b=6,x=new Uint8Array(b);for(_||(x[0]=255,x[1]=172),x[2]=g.height>>>24&255,x[3]=g.height>>16&255,x[4]=g.height>>8&255,x[5]=g.height&255,m=u,h=e.length;m<h;m++){for(var S=0;S<b&&x[S]===e[m+S];)S++;if(S===b){n.length=m+b;break}}if(n.length===4294967295)throw new Q(`segment end was not found`)}else throw new Q(`invalid unknown segment length`);return n.headerEnd=u,n}function _(e,t,n,r){for(var i=[],a=n;a<r;){var o=g(t,a);a=o.headerEnd;var s={header:o,data:t};if(e.randomAccess||(s.start=a,a+=o.length,s.end=a),i.push(s),o.type===51)break}if(e.randomAccess)for(var c=0,l=i.length;c<l;c++)i[c].start=a,a+=i[c].header.length,i[c].end=a;return i}function v(e,t){return{width:Z(e,t),height:Z(e,t+4),x:Z(e,t+8),y:Z(e,t+12),combinationOperator:e[t+16]&7}}var y=17;function b(e,t){var n=e.header,r=e.data,i=e.start,a=e.end,o,s,c,l;switch(n.type){case 0:var u={},d=X(r,i);if(u.huffman=!!(d&1),u.refinement=!!(d&2),u.huffmanDHSelector=d>>2&3,u.huffmanDWSelector=d>>4&3,u.bitmapSizeSelector=d>>6&1,u.aggregationInstancesSelector=d>>7&1,u.bitmapCodingContextUsed=!!(d&256),u.bitmapCodingContextRetained=!!(d&512),u.template=d>>10&3,u.refinementTemplate=d>>12&1,i+=2,!u.huffman){for(l=u.template===0?4:1,s=[],c=0;c<l;c++)s.push({x:Y(r,i),y:Y(r,i+1)}),i+=2;u.at=s}if(u.refinement&&!u.refinementTemplate){for(s=[],c=0;c<2;c++)s.push({x:Y(r,i),y:Y(r,i+1)}),i+=2;u.refinementAt=s}u.numberOfExportedSymbols=Z(r,i),i+=4,u.numberOfNewSymbols=Z(r,i),i+=4,o=[u,n.number,n.referredTo,r,i,a];break;case 6:case 7:var f={};f.info=v(r,i),i+=y;var p=X(r,i);if(i+=2,f.huffman=!!(p&1),f.refinement=!!(p&2),f.logStripSize=p>>2&3,f.stripSize=1<<f.logStripSize,f.referenceCorner=p>>4&3,f.transposed=!!(p&64),f.combinationOperator=p>>7&3,f.defaultPixelValue=p>>9&1,f.dsOffset=p<<17>>27,f.refinementTemplate=p>>15&1,f.huffman){var m=X(r,i);i+=2,f.huffmanFS=m&3,f.huffmanDS=m>>2&3,f.huffmanDT=m>>4&3,f.huffmanRefinementDW=m>>6&3,f.huffmanRefinementDH=m>>8&3,f.huffmanRefinementDX=m>>10&3,f.huffmanRefinementDY=m>>12&3,f.huffmanRefinementSizeSelector=!!(m&16384)}if(f.refinement&&!f.refinementTemplate){for(s=[],c=0;c<2;c++)s.push({x:Y(r,i),y:Y(r,i+1)}),i+=2;f.refinementAt=s}f.numberOfSymbolInstances=Z(r,i),i+=4,o=[f,n.referredTo,r,i,a];break;case 16:let e={},t=r[i++];e.mmr=!!(t&1),e.template=t>>1&3,e.patternWidth=r[i++],e.patternHeight=r[i++],e.maxPatternIndex=Z(r,i),i+=4,o=[e,n.number,r,i,a];break;case 22:case 23:let x={};x.info=v(r,i),i+=y;let S=r[i++];x.mmr=!!(S&1),x.template=S>>1&3,x.enableSkip=!!(S&8),x.combinationOperator=S>>4&7,x.defaultPixelValue=S>>7&1,x.gridWidth=Z(r,i),i+=4,x.gridHeight=Z(r,i),i+=4,x.gridOffsetX=Z(r,i)&4294967295,i+=4,x.gridOffsetY=Z(r,i)&4294967295,i+=4,x.gridVectorX=X(r,i),i+=2,x.gridVectorY=X(r,i),i+=2,o=[x,n.referredTo,r,i,a];break;case 38:case 39:var h={};h.info=v(r,i),i+=y;var g=r[i++];if(h.mmr=!!(g&1),h.template=g>>1&3,h.prediction=!!(g&8),!h.mmr){for(l=h.template===0?4:1,s=[],c=0;c<l;c++)s.push({x:Y(r,i),y:Y(r,i+1)}),i+=2;h.at=s}o=[h,r,i,a];break;case 48:var _={width:Z(r,i),height:Z(r,i+4),resolutionX:Z(r,i+8),resolutionY:Z(r,i+12)};_.height===4294967295&&delete _.height;var b=r[i+16];X(r,i+17),_.lossless=!!(b&1),_.refinement=!!(b&2),_.defaultPixelValue=b>>2&1,_.combinationOperator=b>>3&3,_.requiresBuffer=!!(b&32),_.combinationOperatorOverride=!!(b&64),o=[_];break;case 49:break;case 50:break;case 51:break;case 53:o=[n.number,r,i,a];break;case 62:break;default:throw new Q(`segment type ${n.typeName}(${n.type}) is not implemented`)}var x=`on`+n.typeName;x in t&&t[x].apply(t,o)}function x(e,t){for(var n=0,r=e.length;n<r;n++)b(e[n],t)}function S(e){for(var t=new w,n=0,r=e.length;n<r;n++){var i=e[n];x(_({},i.data,i.start,i.end),t)}return t.buffer}function C(e){let t=e.length,n=0;if(e[n]!==151||e[n+1]!==74||e[n+2]!==66||e[n+3]!==50||e[n+4]!==13||e[n+5]!==10||e[n+6]!==26||e[n+7]!==10)throw new Q(`parseJbig2 - invalid header.`);let r=Object.create(null);n+=8;let i=e[n++];r.randomAccess=!(i&1),i&2||(r.numberOfPages=Z(e,n),n+=4);let a=_(r,e,n,t),o=new w;x(a,o);let{width:s,height:c}=o.currentPageInfo,l=o.buffer,u=new Uint8ClampedArray(s*c),d=0,f=0;for(let e=0;e<c;e++){let e=0,t;for(let n=0;n<s;n++)e||(e=128,t=l[f++]),u[d++]=t&e?0:255,e>>=1}return{imgData:u,width:s,height:c}}function w(){}w.prototype={onPageInformation:function(e){this.currentPageInfo=e;var t=e.width+7>>3,n=new Uint8ClampedArray(t*e.height);if(e.defaultPixelValue)for(var r=0,i=n.length;r<i;r++)n[r]=255;this.buffer=n},drawBitmap:function(e,t){var n=this.currentPageInfo,r=e.width,i=e.height,a=n.width+7>>3,o=n.combinationOperatorOverride?e.combinationOperator:n.combinationOperator,s=this.buffer,c=128>>(e.x&7),l=e.y*a+(e.x>>3),u,d,f,p;switch(o){case 0:for(u=0;u<i;u++){for(f=c,p=l,d=0;d<r;d++)t[u][d]&&(s[p]|=f),f>>=1,f||(f=128,p++);l+=a}break;case 2:for(u=0;u<i;u++){for(f=c,p=l,d=0;d<r;d++)t[u][d]&&(s[p]^=f),f>>=1,f||(f=128,p++);l+=a}break;default:throw new Q(`operator ${o} is not supported`)}},onImmediateGenericRegion:function(e,n,r,i){var a=e.info,o=new t(n,r,i),s=u(e.mmr,a.width,a.height,e.template,e.prediction,null,e.at,o);this.drawBitmap(a,s)},onImmediateLosslessGenericRegion:function(){this.onImmediateGenericRegion.apply(this,arguments)},onSymbolDictionary:function(e,n,r,i,a,o){let s,c;e.huffman&&(s=P(e,r,this.customTables),c=new j(i,a,o));var l=this.symbols;l||(this.symbols=l={});for(var u=[],d=0,p=r.length;d<p;d++){let e=l[r[d]];e&&(u=u.concat(e))}var m=new t(i,a,o);l[n]=f(e.huffman,e.refinement,u,e.numberOfNewSymbols,e.numberOfExportedSymbols,s,e.template,e.at,e.refinementTemplate,e.refinementAt,m,c)},onImmediateTextRegion:function(e,n,r,i,a){var o=e.info;let s,c;for(var l=this.symbols,u=[],d=0,f=n.length;d<f;d++){let e=l[n[d]];e&&(u=u.concat(e))}var m=oe(u.length);e.huffman&&(c=new j(r,i,a),s=N(e,n,this.customTables,u.length,c));var h=new t(r,i,a),g=p(e.huffman,e.refinement,o.width,o.height,e.defaultPixelValue,e.numberOfSymbolInstances,e.stripSize,u,m,e.transposed,e.dsOffset,e.referenceCorner,e.combinationOperator,s,e.refinementTemplate,e.refinementAt,h,e.logStripSize,c);this.drawBitmap(o,g)},onImmediateLosslessTextRegion:function(){this.onImmediateTextRegion.apply(this,arguments)},onPatternDictionary(e,n,r,i,a){let o=this.patterns;o||(this.patterns=o={});let s=new t(r,i,a);o[n]=m(e.mmr,e.patternWidth,e.patternHeight,e.maxPatternIndex,e.template,s)},onImmediateHalftoneRegion(e,n,r,i,a){let o=this.patterns[n[0]],s=e.info,c=new t(r,i,a),l=h(e.mmr,o,e.template,s.width,s.height,e.defaultPixelValue,e.enableSkip,e.combinationOperator,e.gridWidth,e.gridHeight,e.gridOffsetX,e.gridOffsetY,e.gridVectorX,e.gridVectorY,c);this.drawBitmap(s,l)},onImmediateLosslessHalftoneRegion(){this.onImmediateHalftoneRegion.apply(this,arguments)},onTables(e,t,n,r){let i=this.customTables;i||(this.customTables=i={}),i[e]=O(t,n,r)}};function T(e){e.length===2?(this.isOOB=!0,this.rangeLow=0,this.prefixLength=e[0],this.rangeLength=0,this.prefixCode=e[1],this.isLowerRange=!1):(this.isOOB=!1,this.rangeLow=e[0],this.prefixLength=e[1],this.rangeLength=e[2],this.prefixCode=e[3],this.isLowerRange=e[4]===`lower`)}function E(e){this.children=[],e?(this.isLeaf=!0,this.rangeLength=e.rangeLength,this.rangeLow=e.rangeLow,this.isLowerRange=e.isLowerRange,this.isOOB=e.isOOB):this.isLeaf=!1}E.prototype={buildTree(e,t){let n=e.prefixCode>>t&1;if(t<=0)this.children[n]=new E(e);else{let r=this.children[n];r||(this.children[n]=r=new E(null)),r.buildTree(e,t-1)}},decodeNode(e){if(this.isLeaf){if(this.isOOB)return null;let t=e.readBits(this.rangeLength);return this.rangeLow+(this.isLowerRange?-t:t)}let t=this.children[e.readBit()];if(!t)throw new Q(`invalid Huffman data`);return t.decodeNode(e)}};function D(e,t){t||this.assignPrefixCodes(e),this.rootNode=new E(null);for(let t=0,n=e.length;t<n;t++){let n=e[t];n.prefixLength>0&&this.rootNode.buildTree(n,n.prefixLength-1)}}D.prototype={decode(e){return this.rootNode.decodeNode(e)},assignPrefixCodes(e){let t=e.length,n=0;for(let r=0;r<t;r++)n=Math.max(n,e[r].prefixLength);let r=new Uint32Array(n+1);for(let n=0;n<t;n++)r[e[n].prefixLength]++;let i=1,a=0,o,s,c;for(r[0]=0;i<=n;){for(a=a+r[i-1]<<1,o=a,s=0;s<t;)c=e[s],c.prefixLength===i&&(c.prefixCode=o,o++),s++;i++}}};function O(e,t,n){let r=e[t],i=Z(e,t+1)&4294967295,a=Z(e,t+5)&4294967295,o=new j(e,t+9,n),s=(r>>1&7)+1,c=(r>>4&7)+1,l=[],u,d,f=i;do u=o.readBits(s),d=o.readBits(c),l.push(new T([f,u,d,0])),f+=1<<d;while(f<a);return u=o.readBits(s),l.push(new T([i-1,u,32,0,`lower`])),u=o.readBits(s),l.push(new T([a,u,32,0])),r&1&&(u=o.readBits(s),l.push(new T([u,0]))),new D(l,!1)}let k={};function A(e){let t=k[e];if(t)return t;let n;switch(e){case 1:n=[[0,1,4,0],[16,2,8,2],[272,3,16,6],[65808,3,32,7]];break;case 2:n=[[0,1,0,0],[1,2,0,2],[2,3,0,6],[3,4,3,14],[11,5,6,30],[75,6,32,62],[6,63]];break;case 3:n=[[-256,8,8,254],[0,1,0,0],[1,2,0,2],[2,3,0,6],[3,4,3,14],[11,5,6,30],[-257,8,32,255,`lower`],[75,7,32,126],[6,62]];break;case 4:n=[[1,1,0,0],[2,2,0,2],[3,3,0,6],[4,4,3,14],[12,5,6,30],[76,5,32,31]];break;case 5:n=[[-255,7,8,126],[1,1,0,0],[2,2,0,2],[3,3,0,6],[4,4,3,14],[12,5,6,30],[-256,7,32,127,`lower`],[76,6,32,62]];break;case 6:n=[[-2048,5,10,28],[-1024,4,9,8],[-512,4,8,9],[-256,4,7,10],[-128,5,6,29],[-64,5,5,30],[-32,4,5,11],[0,2,7,0],[128,3,7,2],[256,3,8,3],[512,4,9,12],[1024,4,10,13],[-2049,6,32,62,`lower`],[2048,6,32,63]];break;case 7:n=[[-1024,4,9,8],[-512,3,8,0],[-256,4,7,9],[-128,5,6,26],[-64,5,5,27],[-32,4,5,10],[0,4,5,11],[32,5,5,28],[64,5,6,29],[128,4,7,12],[256,3,8,1],[512,3,9,2],[1024,3,10,3],[-1025,5,32,30,`lower`],[2048,5,32,31]];break;case 8:n=[[-15,8,3,252],[-7,9,1,508],[-5,8,1,253],[-3,9,0,509],[-2,7,0,124],[-1,4,0,10],[0,2,1,0],[2,5,0,26],[3,6,0,58],[4,3,4,4],[20,6,1,59],[22,4,4,11],[38,4,5,12],[70,5,6,27],[134,5,7,28],[262,6,7,60],[390,7,8,125],[646,6,10,61],[-16,9,32,510,`lower`],[1670,9,32,511],[2,1]];break;case 9:n=[[-31,8,4,252],[-15,9,2,508],[-11,8,2,253],[-7,9,1,509],[-5,7,1,124],[-3,4,1,10],[-1,3,1,2],[1,3,1,3],[3,5,1,26],[5,6,1,58],[7,3,5,4],[39,6,2,59],[43,4,5,11],[75,4,6,12],[139,5,7,27],[267,5,8,28],[523,6,8,60],[779,7,9,125],[1291,6,11,61],[-32,9,32,510,`lower`],[3339,9,32,511],[2,0]];break;case 10:n=[[-21,7,4,122],[-5,8,0,252],[-4,7,0,123],[-3,5,0,24],[-2,2,2,0],[2,5,0,25],[3,6,0,54],[4,7,0,124],[5,8,0,253],[6,2,6,1],[70,5,5,26],[102,6,5,55],[134,6,6,56],[198,6,7,57],[326,6,8,58],[582,6,9,59],[1094,6,10,60],[2118,7,11,125],[-22,8,32,254,`lower`],[4166,8,32,255],[2,2]];break;case 11:n=[[1,1,0,0],[2,2,1,2],[4,4,0,12],[5,4,1,13],[7,5,1,28],[9,5,2,29],[13,6,2,60],[17,7,2,122],[21,7,3,123],[29,7,4,124],[45,7,5,125],[77,7,6,126],[141,7,32,127]];break;case 12:n=[[1,1,0,0],[2,2,0,2],[3,3,1,6],[5,5,0,28],[6,5,1,29],[8,6,1,60],[10,7,0,122],[11,7,1,123],[13,7,2,124],[17,7,3,125],[25,7,4,126],[41,8,5,254],[73,8,32,255]];break;case 13:n=[[1,1,0,0],[2,3,0,4],[3,4,0,12],[4,5,0,28],[5,4,1,13],[7,3,3,5],[15,6,1,58],[17,6,2,59],[21,6,3,60],[29,6,4,61],[45,6,5,62],[77,7,6,126],[141,7,32,127]];break;case 14:n=[[-2,3,0,4],[-1,3,0,5],[0,1,0,0],[1,3,0,6],[2,3,0,7]];break;case 15:n=[[-24,7,4,124],[-8,6,2,60],[-4,5,1,28],[-2,4,0,12],[-1,3,0,4],[0,1,0,0],[1,3,0,5],[2,4,0,13],[3,5,1,29],[5,6,2,61],[9,7,4,125],[-25,7,32,126,`lower`],[25,7,32,127]];break;default:throw new Q(`standard table B.${e} does not exist`)}for(let e=0,t=n.length;e<t;e++)n[e]=new T(n[e]);return t=new D(n,!0),k[e]=t,t}function j(e,t,n){this.data=e,this.start=t,this.end=n,this.position=t,this.shift=-1,this.currentByte=0}j.prototype={readBit(){if(this.shift<0){if(this.position>=this.end)throw new Q(`end of data while reading bit`);this.currentByte=this.data[this.position++],this.shift=7}let e=this.currentByte>>this.shift&1;return this.shift--,e},readBits(e){let t=0,n;for(n=e-1;n>=0;n--)t|=this.readBit()<<n;return t},byteAlign(){this.shift=-1},next(){return this.position>=this.end?-1:this.data[this.position++]}};function M(e,t,n){let r=0;for(let i=0,a=t.length;i<a;i++){let a=n[t[i]];if(a){if(e===r)return a;r++}}throw new Q(`can't find custom Huffman table`)}function N(e,t,n,r,i){let a=[];for(let e=0;e<=34;e++){let t=i.readBits(4);a.push(new T([e,t,0,0]))}let o=new D(a,!1);a.length=0;for(let e=0;e<r;){let t=o.decode(i);if(t>=32){let n,r,o;switch(t){case 32:if(e===0)throw new Q(`no previous value in symbol ID table`);r=i.readBits(2)+3,n=a[e-1].prefixLength;break;case 33:r=i.readBits(3)+3,n=0;break;case 34:r=i.readBits(7)+11,n=0;break;default:throw new Q(`invalid code length in symbol ID table`)}for(o=0;o<r;o++)a.push(new T([e,n,0,0])),e++}else a.push(new T([e,t,0,0])),e++}i.byteAlign();let s=new D(a,!1),c=0,l,u,d;switch(e.huffmanFS){case 0:case 1:l=A(e.huffmanFS+6);break;case 3:l=M(c,t,n),c++;break;default:throw new Q(`invalid Huffman FS selector`)}switch(e.huffmanDS){case 0:case 1:case 2:u=A(e.huffmanDS+8);break;case 3:u=M(c,t,n),c++;break;default:throw new Q(`invalid Huffman DS selector`)}switch(e.huffmanDT){case 0:case 1:case 2:d=A(e.huffmanDT+11);break;case 3:d=M(c,t,n),c++;break;default:throw new Q(`invalid Huffman DT selector`)}if(e.refinement)throw new Q(`refinement with Huffman is not supported`);return{symbolIDTable:s,tableFirstS:l,tableDeltaS:u,tableDeltaT:d}}function P(e,t,n){let r=0,i,a;switch(e.huffmanDHSelector){case 0:case 1:i=A(e.huffmanDHSelector+4);break;case 3:i=M(r,t,n),r++;break;default:throw new Q(`invalid Huffman DH selector`)}switch(e.huffmanDWSelector){case 0:case 1:a=A(e.huffmanDWSelector+2);break;case 3:a=M(r,t,n),r++;break;default:throw new Q(`invalid Huffman DW selector`)}let o,s;return e.bitmapSizeSelector?(o=M(r,t,n),r++):o=A(1),s=e.aggregationInstancesSelector?M(r,t,n):A(1),{tableDeltaHeight:i,tableDeltaWidth:a,tableBitmapSize:o,tableAggregateInstances:s}}function F(e,t,n){let r=[];for(let i=0;i<n;i++){let n=new Uint8Array(t);r.push(n);for(let r=0;r<t;r++)n[r]=e.readBit();e.byteAlign()}return r}function I(e,t,n,r){let i=new le(e,{K:-1,Columns:t,Rows:n,BlackIs1:!0,EndOfBlock:r}),a=[],o,s=!1;for(let e=0;e<n;e++){let e=new Uint8Array(t);a.push(e);let n=-1;for(let r=0;r<t;r++)n<0&&(o=i.readNextChar(),o===-1&&(o=0,s=!0),n=7),e[r]=o>>n&1,n--}if(r&&!s)for(let e=0;e<5&&i.readNextChar()!==-1;e++);return a}function L(){}return L.prototype={parseChunks(e){return S(e)},parse(e){let{imgData:t,width:n,height:r}=C(e);return this.width=n,this.height=r,t}},L})(),de=()=>{globalThis.global||(globalThis.global=globalThis),globalThis.xmlParseFlag=0},fe=function(e){return new Promise((t,n)=>{q.default.loadAsync(e).then(function(e){t(e)},function(e){n(e)})})},pe=async function(e){let t=(await $(e,`OFD.xml`)).json[`ofd:OFD`][`ofd:DocBody`],n=[];return n=n.concat(t),[e,n]},me=async function([e,t]){let n=[];for(let r of t)if(r){let t=await he(e,r);t=await ge(t),t=await ve(t),t=await ye(t),t=await be(t),t=await xe(t),n.push(t)}return n},he=async function(e,t){let n=t[`ofd:DocRoot`];n=m(n);let r=n.split(`/`)[0],i=t[`ofd:Signatures`],a=await Ee(e,i,r),o={};for(let e of a)if(e.sealObj&&Object.keys(e.sealObj).length>0){if(e.sealObj.type===`ofd`){let t=await De(e);for(let n of t)e.stampAnnot.boundary=x(e.stampAnnot[`@_Boundary`]),e.stampAnnot.pageRef=e.stampAnnot[`@_PageRef`],o[e.stampAnnot[`@_PageRef`]]||(o[e.stampAnnot[`@_PageRef`]]=[]),o[e.stampAnnot[`@_PageRef`]].push({type:`ofd`,obj:n,stamp:e})}else if(e.sealObj.type===`png`){let t=`data:image/png;base64,`+btoa(String.fromCharCode.apply(null,e.sealObj.ofdArray)),n=[];n=n.concat(e.stampAnnot);for(let r of n)if(r){let n={img:t,pageId:r[`@_PageRef`],boundary:x(r[`@_Boundary`]),clip:x(r[`@_Clip`])};o[r[`@_PageRef`]]||(o[r[`@_PageRef`]]=[]),o[r[`@_PageRef`]].push({type:`png`,obj:n,stamp:e})}}}return[e,r,n,o]},ge=async function([e,t,n,r]){let i=(await $(e,n)).json[`ofd:Document`],a=i[`ofd:Annotations`],o=[],s;return a&&(a.indexOf(`/`)!==-1&&(s=a.substring(0,a.indexOf(`/`))),a.indexOf(t)===-1&&(a=`${t}/${a}`),e.files[a]&&(a=await $(e,a),o=o.concat(a.json[`ofd:Annotations`][`ofd:Page`]))),[e,t,i,r,await _e(s,o,t,e)]},_e=async function(e,t,n,r){let i={};for(let a of t){if(!a)continue;let t=a[`@_PageID`],o=a[`ofd:FileLoc`];if(o=m(o),e&&o.indexOf(e)===-1&&(o=`${e}/${o}`),o.indexOf(n)===-1&&(o=`${n}/${o}`),r.files[o]){let e=await $(r,o),n=[];n=n.concat(e.json[`ofd:PageAnnot`][`ofd:Annot`]),i[t]||(i[t]=[]);for(let e of n){if(!e)continue;let n=e[`@_Type`],r=e[`@_Visible`]?e[`@_Visible`]:!0,a={type:n,appearance:e[`ofd:Appearance`],visible:r};i[t].push(a)}}}return i},ve=async function([e,t,n,r,i]){let a=n[`ofd:CommonData`][`ofd:DocumentRes`],o={},s={},c={};if(a&&(a.indexOf(t)==-1&&(a=`${t}/${a}`),e.files[a])){let n=(await $(e,a)).json[`ofd:Res`];o=await Se(n),s=await Ce(n),c=await we(e,n,t)}return[e,t,n,r,i,o,s,c]},ye=async function([e,t,n,r,i,a,o,s]){let c=n[`ofd:CommonData`][`ofd:PublicRes`];if(c&&(c.indexOf(t)==-1&&(c=`${t}/${c}`),e.files[c])){let n=(await $(e,c)).json[`ofd:Res`],r=await Se(n);a=Object.assign(a,r);let i=await Ce(n);o=Object.assign(o,i);let l=await we(e,n,t);s=Object.assign(s,l)}return[e,t,n,r,i,a,o,s]},be=async function([e,t,n,r,i,a,o,s]){let c=n[`ofd:CommonData`][`ofd:TemplatePage`],l=[];l=l.concat(c);let u={};for(let n of l)if(n){let r=await Te(e,n,t);u[Object.keys(r)[0]]=r[Object.keys(r)[0]]}return[e,t,n,r,i,u,a,o,s]},xe=async function([e,t,n,r,i,a,o,s,c]){let l=n[`ofd:Pages`][`ofd:Page`],u=[];u=u.concat(l);let d=[];for(let n of u)if(n){let a=await Te(e,n,t),o=Object.keys(a)[0],s=r[o];s&&(a[o].stamp=s);let c=i[o];c&&(a[o].annotation=c),d.push(a)}return{doc:t,document:n,pages:d,tpls:a,stampAnnot:r,fontResObj:o,drawParamResObj:s,multiMediaResObj:c}},Se=async function(e){let t=e[`ofd:Fonts`],n={};if(t){let e=[];e=e.concat(t[`ofd:Font`]);for(let t of e)t&&(t[`@_FamilyName`]?n[t[`@_ID`]]=t[`@_FamilyName`]:n[t[`@_ID`]]=t[`@_FontName`])}return n},Ce=async function(e){let t=e[`ofd:DrawParams`],n={};if(t){let e=[];e=e.concat(t[`ofd:DrawParam`]);for(let t of e)t&&(n[t[`@_ID`]]={LineWidth:t[`@_LineWidth`],FillColor:t[`ofd:FillColor`]?t[`ofd:FillColor`][`@_Value`]:``,StrokeColor:t[`ofd:StrokeColor`]?t[`ofd:StrokeColor`][`@_Value`]:``,relative:t[`@_Relative`]})}return n},we=async function(e,t,n){let r=t[`ofd:MultiMedias`],i={};if(r){let a=[];a=a.concat(r[`ofd:MultiMedia`]);for(let r of a)if(r){let a=r[`ofd:MediaFile`];if(t[`@_BaseLoc`]&&a.indexOf(t[`@_BaseLoc`])===-1&&(a=`${t[`@_BaseLoc`]}/${a}`),a.indexOf(n)===-1&&(a=`${n}/${a}`),r[`@_Type`].toLowerCase()===`image`){let t=r[`@_Format`],n=h(a);if(t&&(t.toLowerCase()===`gbig2`||t.toLowerCase()===`jb2`)||n&&(n.toLowerCase()===`jb2`||n.toLowerCase()===`gbig2`)){let t=await Oe(e,a);i[r[`@_ID`]]=t}else{let t=await ke(e,a);i[r[`@_ID`]]={img:t,format:`png`}}}else i[r[`@_ID`]]=a}}return i},Te=async function(e,t,n){let r=t[`@_BaseLoc`];r.indexOf(n)==-1&&(r=`${n}/${r}`);let i=await $(e,r),a={};return a[t[`@_ID`]]={json:i.json[`ofd:Page`],xml:i.xml},a},Ee=async function(e,t,n){return[]},De=function(){return Promise.resolve([])},$=async function(e,t){return new Promise((n,r)=>{e.files[t].async(`string`).then(function(e){de(),n({xml:e,json:ee.parse(e,{attributeNamePrefix:`@_`,ignoreAttributes:!1,parseNodeValue:!1,trimValues:!1})})},function(e){r(e)})})},Oe=async function(e,t){return new Promise((n,r)=>{e.files[t].async(`uint8array`).then(function(e){let t=new ue;n({img:t.parse(e),width:t.width,height:t.height,format:`gbig2`})},function(e){r(e)})})},ke=async function(e,t){return new Promise((n,r)=>{e.files[t].async(`base64`).then(function(e){n(`data:image/png;base64,`+e)},function(e){r(e)})})},Ae=function(e){e.ofd instanceof File||e.ofd instanceof Blob||e.ofd instanceof ArrayBuffer?je(e):e.fail?.(Error(`OFD 预览只接收 File、Blob 或 ArrayBuffer 数据`))},je=function(e){L.call(this,async()=>await fe(e.ofd),pe,me).then(t=>{e.success&&e.success(t)}).catch(t=>{console.log(t),e.fail&&e.fail(t)})},Me=function(e,t){let n=[];if(!t)return n;for(let r of t.pages){let i=T(e,t.document,r),a=Object.keys(r)[0],o=document.createElement(`div`);o.id=a,o.setAttribute(`style`,`margin-bottom: 20px;position: relative;width:${i.w}px;height:${i.h}px;background: white;`),O(o,r,t.tpls,t.fontResObj,t.drawParamResObj,t.multiMediaResObj),n.push(o)}return n},Ne=function(e){let t=[];if(!e)return t;for(let n of e.pages){let r=E(e.document,n),i=Object.keys(n)[0],a=document.createElement(`div`);a.id=i,a.setAttribute(`style`,`margin-bottom: 20px;position: relative;width:${r.w}px;height:${r.h}px;background: white;`),O(a,n,e.tpls,e.fontResObj,e.drawParamResObj,e.multiMediaResObj),t.push(a)}return t},Pe=function(e){return e?.arr,!1},Fe=function(e){l(e)},Ie=function(){return u()};export{T as calPageBox,E as calPageBoxScale,Pe as digestCheck,Ie as getPageScale,Ae as parseOfdDocument,Me as renderOfd,Ne as renderOfdByScale,O as renderPage,Fe as setPageScale}; |