@file-viewer/assets-design 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/assets-design",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Independent self-hosted Worker and WebAssembly runtime for Adobe design previews.",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"file-viewer-assets-design": "./bin/install.mjs"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@file-viewer/asset-installer": "3.1.
|
|
24
|
+
"@file-viewer/asset-installer": "3.1.2"
|
|
25
25
|
},
|
|
26
26
|
"engines": {
|
|
27
27
|
"node": ">=20"
|
|
@@ -56,9 +56,9 @@ Source: <https://github.com/nodeca/pako/tree/2.1.0>
|
|
|
56
56
|
|
|
57
57
|
The MIT-licensed DEFLATE implementation is bundled transitively through `ag-psd` in the Photoshop document and resource Workers. The complete upstream license is shipped as `LICENSES/pako-MIT.txt`.
|
|
58
58
|
|
|
59
|
-
## @paged-media/introspect-wasm 0.
|
|
59
|
+
## @paged-media/introspect-wasm 0.63.0
|
|
60
60
|
|
|
61
|
-
Source: <https://github.com/paged-media/core/tree/v0.
|
|
61
|
+
Source: <https://github.com/paged-media/core/tree/v0.63.0>
|
|
62
62
|
|
|
63
63
|
The package declares `MPL-2.0 OR LicenseRef-PMEL`. File Viewer elects the Mozilla Public License 2.0 option for the distributed JavaScript and WebAssembly runtime. The complete MPL-2.0 text is shipped as `LICENSES/MPL-2.0.txt` and copied next to the self-hosted IDML runtime assets.
|
|
64
64
|
|
|
@@ -6,7 +6,7 @@ var ls=Object.create;var vt=Object.defineProperty;var fs=Object.getOwnPropertyDe
|
|
|
6
6
|
`,s=this.i,n=v;break;case E:return this.text+=i.slice(s),!1;default:}if(n===t)return this.text+=i.slice(s,this.prevI),!0}}captureNameChars(){let{chunk:t,i:s}=this;for(;;){let i=this.getCode();if(i===E)return this.name+=t.slice(s),E;if(!Ae(i))return this.name+=t.slice(s,this.prevI),i===U?v:i}}skipSpaces(){for(;;){let t=this.getCodeNorm();if(t===E||!R(t))return t}}setXMLVersion(t){this.currentXMLVersion=t,t==="1.0"?(this.isChar=Ns,this.getCode=this.getCode10):(this.isChar=Rs,this.getCode=this.getCode11)}sBegin(){this.chunk.charCodeAt(0)===65279&&(this.i++,this.column++),this.state=Bs}sBeginWhitespace(){let t=this.i,s=this.skipSpaces();switch(this.prevI!==t&&(this.xmlDeclPossible=!1),s){case X:if(this.state=Wt,this.text.length!==0)throw new Error("no-empty text at start");break;case E:break;default:this.unget(),this.state=C,this.xmlDeclPossible=!1}}sDoctype(){var t;let s=this.captureTo(di);switch(s){case y:{(t=this.doctypeHandler)===null||t===void 0||t.call(this,this.text),this.text="",this.state=C,this.doctype=!0;break}case E:break;default:this.text+=String.fromCodePoint(s),s===He?this.state=tt:Lt(s)&&(this.state=$s,this.q=s)}}sDoctypeQuote(){let t=this.q;this.captureToChar(t)&&(this.text+=String.fromCodePoint(t),this.q=null,this.state=Gt)}sDTD(){let t=this.captureTo(hi);t!==E&&(this.text+=String.fromCodePoint(t),t===st?this.state=Gt:t===X?this.state=Hs:Lt(t)&&(this.state=Us,this.q=t))}sDTDQuoted(){let t=this.q;this.captureToChar(t)&&(this.text+=String.fromCodePoint(t),this.state=tt,this.q=null)}sDTDOpenWaka(){let t=this.getCodeNorm();switch(this.text+=String.fromCodePoint(t),t){case Pe:this.state=Gs,this.openWakaBang="";break;case w:this.state=Xs;break;default:this.state=tt}}sDTDOpenWakaBang(){let t=String.fromCodePoint(this.getCodeNorm()),s=this.openWakaBang+=t;this.text+=t,s!=="-"&&(this.state=s==="--"?Zt:tt,this.openWakaBang="")}sDTDComment(){this.captureToChar(Tt)&&(this.text+="-",this.state=Zs)}sDTDCommentEnding(){let t=this.getCodeNorm();this.text+=String.fromCodePoint(t),this.state=t===Tt?Ws:Zt}sDTDCommentEnded(){let t=this.getCodeNorm();this.text+=String.fromCodePoint(t),t===y?this.state=tt:(this.fail("malformed comment."),this.state=Zt)}sDTDPI(){this.captureToChar(w)&&(this.text+="?",this.state=Ys)}sDTDPIEnding(){let t=this.getCodeNorm();this.text+=String.fromCodePoint(t),t===y&&(this.state=tt)}sText(){this.tags.length!==0?this.handleTextInRoot():this.handleTextOutsideRoot()}sEntity(){let{i:t}=this,{chunk:s}=this;t:for(;;)switch(this.getCode()){case U:this.entity+=`${s.slice(t,this.prevI)}
|
|
7
7
|
`,t=this.i;break;case ci:{let{entityReturnState:i}=this,n=this.entity+s.slice(t,this.prevI);this.state=i;let r;n===""?(this.fail("empty entity name."),r="&;"):(r=this.parseEntity(n),this.entity=""),(i!==C||this.textHandler!==void 0)&&(this.text+=r);break t}case E:this.entity+=s.slice(t);break t;default:}}sOpenWaka(){let t=this.getCode();if(ht(t))this.state=ii,this.unget(),this.xmlDeclPossible=!1;else switch(t){case Ct:this.state=ai,this.xmlDeclPossible=!1;break;case Pe:this.state=Vs,this.openWakaBang="",this.xmlDeclPossible=!1;break;case w:this.state=Qs;break;default:this.fail("disallowed character in tag name"),this.state=C,this.xmlDeclPossible=!1}}sOpenWakaBang(){switch(this.openWakaBang+=String.fromCodePoint(this.getCodeNorm()),this.openWakaBang){case"[CDATA[":!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0),this.state=Yt,this.openWakaBang="";break;case"--":this.state=Xt,this.openWakaBang="";break;case"DOCTYPE":this.state=Gt,(this.doctype||this.sawRoot)&&this.fail("inappropriately located doctype declaration."),this.openWakaBang="";break;default:this.openWakaBang.length>=7&&this.fail("incorrect syntax.")}}sComment(){this.captureToChar(Tt)&&(this.state=zs)}sCommentEnding(){var t;let s=this.getCodeNorm();s===Tt?(this.state=js,(t=this.commentHandler)===null||t===void 0||t.call(this,this.text),this.text=""):(this.text+=`-${String.fromCodePoint(s)}`,this.state=Xt)}sCommentEnded(){let t=this.getCodeNorm();t!==y?(this.fail("malformed comment."),this.text+=`--${String.fromCodePoint(t)}`,this.state=Xt):this.state=C}sCData(){this.captureToChar(st)&&(this.state=qs)}sCDataEnding(){let t=this.getCodeNorm();t===st?this.state=Js:(this.text+=`]${String.fromCodePoint(t)}`,this.state=Yt)}sCDataEnding2(){var t;let s=this.getCodeNorm();switch(s){case y:{(t=this.cdataHandler)===null||t===void 0||t.call(this,this.text),this.text="",this.state=C;break}case st:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(s)}`,this.state=Yt}}sPIFirstChar(){let t=this.getCodeNorm();this.nameStartCheck(t)?(this.piTarget+=String.fromCodePoint(t),this.state=Se):t===w||R(t)?(this.fail("processing instruction without a target."),this.state=t===w?St:Vt):(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(t),this.state=Se)}sPIRest(){let{chunk:t,i:s}=this;for(;;){let i=this.getCodeNorm();if(i===E){this.piTarget+=t.slice(s);return}if(!this.nameCheck(i)){this.piTarget+=t.slice(s,this.prevI);let n=i===w;n||R(i)?this.piTarget==="xml"?(this.xmlDeclPossible||this.fail("an XML declaration must be at the start of the document."),this.state=n?z:Te):this.state=n?St:Vt:(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(i));break}}}sPIBody(){if(this.text.length===0){let t=this.getCodeNorm();t===w?this.state=St:R(t)||(this.text=String.fromCodePoint(t))}else this.captureToChar(w)&&(this.state=St)}sPIEnding(){var t;let s=this.getCodeNorm();if(s===y){let{piTarget:i}=this;i.toLowerCase()==="xml"&&this.fail("the XML declaration must appear at the start of the document."),(t=this.piHandler)===null||t===void 0||t.call(this,{target:i,body:this.text}),this.piTarget=this.text="",this.state=C}else s===w?this.text+="?":(this.text+=`?${String.fromCodePoint(s)}`,this.state=Vt);this.xmlDeclPossible=!1}sXMLDeclNameStart(){let t=this.skipSpaces();if(t===w){this.state=z;return}t!==E&&(this.state=Ks,this.name=String.fromCodePoint(t))}sXMLDeclName(){let t=this.captureTo(li);if(t===w){this.state=z,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(R(t)||t===et){if(this.name+=this.text,this.text="",!this.xmlDeclExpects.includes(this.name))switch(this.name.length){case 0:this.fail("did not expect any more name/value pairs.");break;case 1:this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expected one of ${this.xmlDeclExpects.join(", ")}`)}this.state=t===et?Ce:ti}}sXMLDeclEq(){let t=this.getCodeNorm();if(t===w){this.state=z,this.fail("XML declaration is incomplete.");return}R(t)||(t!==et&&this.fail("value required."),this.state=Ce)}sXMLDeclValueStart(){let t=this.getCodeNorm();if(t===w){this.state=z,this.fail("XML declaration is incomplete.");return}R(t)||(Lt(t)?this.q=t:(this.fail("value must be quoted."),this.q=Re),this.state=ei)}sXMLDeclValue(){let t=this.captureTo([this.q,w]);if(t===w){this.state=z,this.text="",this.fail("XML declaration is incomplete.");return}if(t===E)return;let s=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];let i=s;this.xmlDecl.version=i,/^1\.[0-9]+$/.test(i)?this.opt.forceXMLVersion||this.setXMLVersion(i):this.fail("version number must match /^1\\.[0-9]+$/.");break}case"encoding":/^[A-Za-z][A-Za-z0-9._-]*$/.test(s)||this.fail("encoding value must match /^[A-Za-z0-9][A-Za-z0-9._-]*$/."),this.xmlDeclExpects=["standalone"],this.xmlDecl.encoding=s;break;case"standalone":s!=="yes"&&s!=="no"&&this.fail('standalone value must match "yes" or "no".'),this.xmlDeclExpects=[],this.xmlDecl.standalone=s;break;default:}this.name="",this.state=si}sXMLDeclSeparator(){let t=this.getCodeNorm();if(t===w){this.state=z;return}R(t)||(this.fail("whitespace required."),this.unget()),this.state=Te}sXMLDeclEnding(){var t;this.getCodeNorm()===y?(this.piTarget!=="xml"?this.fail("processing instructions are not allowed before root."):this.name!=="version"&&this.xmlDeclExpects.includes("version")&&this.fail("XML declaration must contain a version."),(t=this.xmldeclHandler)===null||t===void 0||t.call(this,this.xmlDecl),this.name="",this.piTarget=this.text="",this.state=C):this.fail("The character ? is disallowed anywhere in XML declarations."),this.xmlDeclPossible=!1}sOpenTag(){var t;let s=this.captureNameChars();if(s===E)return;let i=this.tag={name:this.name,attributes:Object.create(null)};switch(this.name="",this.xmlnsOpt&&(this.topNS=i.ns=Object.create(null)),(t=this.openTagStartHandler)===null||t===void 0||t.call(this,i),this.sawRoot=!0,!this.fragmentOpt&&this.closedRoot&&this.fail("documents may contain only one root."),s){case y:this.openTag();break;case Ct:this.state=zt;break;default:R(s)||this.fail("disallowed character in tag name."),this.state=lt}}sOpenTagSlash(){this.getCode()===y?this.openSelfClosingTag():(this.fail("forward-slash in opening tag not followed by >."),this.state=lt)}sAttrib(){let t=this.skipSpaces();t!==E&&(ht(t)?(this.unget(),this.state=jt):t===y?this.openTag():t===Ct?this.state=zt:this.fail("disallowed character in attribute name."))}sAttribName(){let t=this.captureNameChars();t===et?this.state=Le:R(t)?this.state=ni:t===y?(this.fail("attribute without value."),this.pushAttrib(this.name,this.name),this.name=this.text="",this.openTag()):t!==E&&this.fail("disallowed character in attribute name.")}sAttribNameSawWhite(){let t=this.skipSpaces();switch(t){case E:return;case et:this.state=Le;break;default:this.fail("attribute without value."),this.text="",this.name="",t===y?this.openTag():ht(t)?(this.unget(),this.state=jt):(this.fail("disallowed character in attribute name."),this.state=lt)}}sAttribValue(){let t=this.getCodeNorm();Lt(t)?(this.q=t,this.state=Ne):R(t)||(this.fail("unquoted attribute value."),this.state=Me,this.unget())}sAttribValueQuoted(){let{q:t,chunk:s}=this,{i}=this;for(;;)switch(this.getCode()){case t:this.pushAttrib(this.name,this.text+s.slice(i,this.prevI)),this.name=this.text="",this.q=null,this.state=ri;return;case ft:this.text+=s.slice(i,this.prevI),this.state=wt,this.entityReturnState=Ne;return;case v:case U:case qt:this.text+=`${s.slice(i,this.prevI)} `,i=this.i;break;case X:this.text+=s.slice(i,this.prevI),this.fail("disallowed character.");return;case E:this.text+=s.slice(i);return;default:}}sAttribValueClosed(){let t=this.getCodeNorm();R(t)?this.state=lt:t===y?this.openTag():t===Ct?this.state=zt:ht(t)?(this.fail("no whitespace between attributes."),this.unget(),this.state=jt):this.fail("disallowed character in attribute name.")}sAttribValueUnquoted(){let t=this.captureTo(fi);switch(t){case ft:this.state=wt,this.entityReturnState=Me;break;case X:this.fail("disallowed character.");break;case E:break;default:this.text.includes("]]>")&&this.fail('the string "]]>" is disallowed in char data.'),this.pushAttrib(this.name,this.text),this.name=this.text="",t===y?this.openTag():this.state=lt}}sCloseTag(){let t=this.captureNameChars();t===y?this.closeTag():R(t)?this.state=oi:t!==E&&this.fail("disallowed character in closing tag.")}sCloseTagSawWhite(){switch(this.skipSpaces()){case y:this.closeTag();break;case E:break;default:this.fail("disallowed character in closing tag.")}}handleTextInRoot(){let{i:t,forbiddenState:s}=this,{chunk:i,textHandler:n}=this;t:for(;;)switch(this.getCode()){case X:{if(this.state=Wt,n!==void 0){let{text:r}=this,a=i.slice(t,this.prevI);r.length!==0?(n(r+a),this.text=""):a.length!==0&&n(a)}s=j;break t}case ft:this.state=wt,this.entityReturnState=C,n!==void 0&&(this.text+=i.slice(t,this.prevI)),s=j;break t;case st:switch(s){case j:s=ke;break;case ke:s=Qt;break;case Qt:break;default:throw new Error("impossible state")}break;case y:s===Qt&&this.fail('the string "]]>" is disallowed in char data.'),s=j;break;case U:n!==void 0&&(this.text+=`${i.slice(t,this.prevI)}
|
|
8
8
|
`),t=this.i,s=j;break;case E:n!==void 0&&(this.text+=i.slice(t));break t;default:s=j}this.forbiddenState=s}handleTextOutsideRoot(){let{i:t}=this,{chunk:s,textHandler:i}=this,n=!1;t:for(;;){let r=this.getCode();switch(r){case X:{if(this.state=Wt,i!==void 0){let{text:a}=this,o=s.slice(t,this.prevI);a.length!==0?(i(a+o),this.text=""):o.length!==0&&i(o)}break t}case ft:this.state=wt,this.entityReturnState=C,i!==void 0&&(this.text+=s.slice(t,this.prevI)),n=!0;break t;case U:i!==void 0&&(this.text+=`${s.slice(t,this.prevI)}
|
|
9
|
-
`),t=this.i;break;case E:i!==void 0&&(this.text+=s.slice(t));break t;default:R(r)||(n=!0)}}n&&(!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0))}pushAttribNS(t,s){var i;let{prefix:n,local:r}=this.qname(t),a={name:t,prefix:n,local:r,value:s};if(this.attribList.push(a),(i=this.attributeHandler)===null||i===void 0||i.call(this,a),n==="xmlns"){let o=s.trim();this.currentXMLVersion==="1.0"&&o===""&&this.fail("invalid attempt to undefine prefix in XML 1.0"),this.topNS[r]=o,Kt(this,r,o)}else if(t==="xmlns"){let o=s.trim();this.topNS[""]=o,Kt(this,"",o)}}pushAttribPlain(t,s){var i;let n={name:t,value:s};this.attribList.push(n),(i=this.attributeHandler)===null||i===void 0||i.call(this,n)}end(){var t,s;this.sawRoot||this.fail("document must contain a root element.");let{tags:i}=this;for(;i.length>0;){let r=i.pop();this.fail(`unclosed tag: ${r.name}`)}this.state!==we&&this.state!==C&&this.fail("unexpected end.");let{text:n}=this;return n.length!==0&&((t=this.textHandler)===null||t===void 0||t.call(this,n),this.text=""),this._closed=!0,(s=this.endHandler)===null||s===void 0||s.call(this),this._init(),this}resolve(t){var s,i;let n=this.topNS[t];if(n!==void 0)return n;let{tags:r}=this;for(let a=r.length-1;a>=0;a--)if(n=r[a].ns[t],n!==void 0)return n;return n=this.ns[t],n!==void 0?n:(i=(s=this.opt).resolvePrefix)===null||i===void 0?void 0:i.call(s,t)}qname(t){let s=t.indexOf(":");if(s===-1)return{prefix:"",local:t};let i=t.slice(s+1),n=t.slice(0,s);return(n===""||i===""||i.includes(":"))&&this.fail(`malformed name: ${t}.`),{prefix:n,local:i}}processAttribsNS(){var t;let{attribList:s}=this,i=this.tag;{let{prefix:a,local:o}=this.qname(i.name);i.prefix=a,i.local=o;let c=i.uri=(t=this.resolve(a))!==null&&t!==void 0?t:"";a!==""&&(a==="xmlns"&&this.fail('tags may not have "xmlns" as prefix.'),c===""&&(this.fail(`unbound namespace prefix: ${JSON.stringify(a)}.`),i.uri=a))}if(s.length===0)return;let{attributes:n}=i,r=new Set;for(let a of s){let{name:o,prefix:c,local:d}=a,h,l;c===""?(h=o==="xmlns"?it:"",l=o):(h=this.resolve(c),h===void 0&&(this.fail(`unbound namespace prefix: ${JSON.stringify(c)}.`),h=c),l=`{${h}}${d}`),r.has(l)&&this.fail(`duplicate attribute: ${l}.`),r.add(l),a.uri=h,n[o]=a}this.attribList=[]}processAttribsPlain(){let{attribList:t}=this,s=this.tag.attributes;for(let{name:i,value:n}of t)s[i]!==void 0&&this.fail(`duplicate attribute: ${i}.`),s[i]=n;this.attribList=[]}openTag(){var t;this.processAttribs();let{tags:s}=this,i=this.tag;i.isSelfClosing=!1,(t=this.openTagHandler)===null||t===void 0||t.call(this,i),s.push(i),this.state=C,this.name=""}openSelfClosingTag(){var t,s,i;this.processAttribs();let{tags:n}=this,r=this.tag;r.isSelfClosing=!0,(t=this.openTagHandler)===null||t===void 0||t.call(this,r),(s=this.closeTagHandler)===null||s===void 0||s.call(this,r),(this.tag=(i=n[n.length-1])!==null&&i!==void 0?i:null)===null&&(this.closedRoot=!0),this.state=C,this.name=""}closeTag(){let{tags:t,name:s}=this;if(this.state=C,this.name="",s===""){this.fail("weird empty close tag."),this.text+="</>";return}let i=this.closeTagHandler,n=t.length;for(;n-- >0;){let r=this.tag=t.pop();if(this.topNS=r.ns,i?.(r),r.name===s)break;this.fail("unexpected close tag.")}n===0?this.closedRoot=!0:n<0&&(this.fail(`unmatched closing tag: ${s}.`),this.text+=`</${s}>`)}parseEntity(t){if(t[0]!=="#"){let i=this.ENTITIES[t];return i!==void 0?i:(this.fail(this.isName(t)?"undefined entity.":"disallowed character in entity name."),`&${t};`)}let s=NaN;return t[1]==="x"&&/^#x[0-9a-f]+$/i.test(t)?s=parseInt(t.slice(2),16):/^#[0-9]+$/.test(t)&&(s=parseInt(t.slice(1),10)),this.isChar(s)?String.fromCodePoint(s):(this.fail("malformed character entity."),`&${t};`)}};nt.SaxesParser=te});var os={};_s(os,{Inspector:()=>bt,default:()=>zi,describeCatalog:()=>Bi,initSync:()=>Vi,on_start:()=>$i});function Bi(){let e,t;try{let n=p.describeCatalog();var s=n[0],i=n[1];if(n[3])throw s=0,i=0,Y(n[2]);return e=s,t=i,G(s,i)}finally{p.__wbindgen_free(e,t,1)}}function $i(){p.on_start()}function rs(){return{__proto__:null,"./paged_introspect_wasm_bg.js":{__proto__:null,__wbg_Error_ef53bc310eb298a0:function(t,s){return Error(G(t,s))},__wbg___wbindgen_throw_1506f2235d1bdba0:function(t,s){throw new Error(G(t,s))},__wbg_error_a6fa202b58aa1cd3:function(t,s){let i,n;try{i=t,n=s,console.error(G(t,s))}finally{p.__wbindgen_free(i,n,1)}},__wbg_log_cf2e968649f3384e:function(t){console.log(t)},__wbg_new_227d7c05414eb861:function(){return new Error},__wbg_stack_3b0d974bbf31e44f:function(t,s){let i=s.stack,n=re(i,p.__wbindgen_malloc,p.__wbindgen_realloc),r=J;ns().setInt32(t+4,r,!0),ns().setInt32(t+0,n,!0)},__wbindgen_cast_0000000000000001:function(t,s){return G(t,s)},__wbindgen_init_externref_table:function(){let t=p.__wbindgen_externrefs,s=t.grow(4);t.set(0,void 0),t.set(s+0,void 0),t.set(s+1,null),t.set(s+2,!0),t.set(s+3,!1)}}}}function Ui(e,t){return e=e>>>0,ct().subarray(e/1,e/1+t)}function ns(){return(q===null||q.buffer.detached===!0||q.buffer.detached===void 0&&q.buffer!==p.memory.buffer)&&(q=new DataView(p.memory.buffer)),q}function G(e,t){return Zi(e>>>0,t)}function ct(){return(xt===null||xt.byteLength===0)&&(xt=new Uint8Array(p.memory.buffer)),xt}function Hi(e,t){let s=t(e.length*1,1)>>>0;return ct().set(e,s/1),J=e.length,s}function re(e,t,s){if(s===void 0){let o=It.encode(e),c=t(o.length,1)>>>0;return ct().subarray(c,c+o.length).set(o),J=o.length,c}let i=e.length,n=t(i,1)>>>0,r=ct(),a=0;for(;a<i;a++){let o=e.charCodeAt(a);if(o>127)break;r[n+a]=o}if(a!==i){a!==0&&(e=e.slice(a)),n=s(n,i,i=a+e.length*3,1)>>>0;let o=ct().subarray(n+a,n+i),c=It.encodeInto(e,o);a+=c.written,n=s(n,i,a,1)>>>0}return J=a,n}function Y(e){let t=p.__wbindgen_externrefs.get(e);return p.__externref_table_dealloc(e),t}function Zi(e,t){return ne+=t,ne>=Gi&&(Ot=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Ot.decode(),ne=t),Ot.decode(ct().subarray(e,e+t))}function as(e,t){return Xi=e,p=e.exports,Wi=t,q=null,xt=null,p.__wbindgen_start(),p}async function Yi(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(n){if(e.ok&&s(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",n);else throw n}let i=await e.arrayBuffer();return await WebAssembly.instantiate(i,t)}else{let i=await WebAssembly.instantiate(e,t);return i instanceof WebAssembly.Instance?{instance:i,module:e}:i}function s(i){switch(i){case"basic":case"cors":case"default":return!0}return!1}}function Vi(e){if(p!==void 0)return p;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module:e}=e:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=rs();e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e));let s=new WebAssembly.Instance(e,t);return as(s,e)}async function zi(e){if(p!==void 0)return p;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),e===void 0&&(e=new URL("paged_introspect_wasm_bg.wasm",import.meta.url));let t=rs();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:s,module:i}=await Yi(await e,t);return as(s,i)}var bt,is,q,xt,Ot,Gi,ne,It,J,Wi,Xi,p,cs=gs(()=>{bt=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,is.unregister(this),t}free(){let t=this.__destroy_into_raw();p.__wbg_inspector_free(t,0)}apply(t){let s,i;try{let a=re(t,p.__wbindgen_malloc,p.__wbindgen_realloc),o=J,c=p.inspector_apply(this.__wbg_ptr,a,o);var n=c[0],r=c[1];if(c[3])throw n=0,r=0,Y(c[2]);return s=n,i=r,G(n,r)}finally{p.__wbindgen_free(s,i,1)}}constructor(t){let s=Hi(t,p.__wbindgen_malloc),i=J,n=p.inspector_new(s,i);if(n[2])throw Y(n[1]);return this.__wbg_ptr=n[0],is.register(this,this.__wbg_ptr,this),this}properties(t){let s,i;try{let a=re(t,p.__wbindgen_malloc,p.__wbindgen_realloc),o=J,c=p.inspector_properties(this.__wbg_ptr,a,o);var n=c[0],r=c[1];if(c[3])throw n=0,r=0,Y(c[2]);return s=n,i=r,G(n,r)}finally{p.__wbindgen_free(s,i,1)}}redo(){let t,s;try{let r=p.inspector_redo(this.__wbg_ptr);var i=r[0],n=r[1];if(r[3])throw i=0,n=0,Y(r[2]);return t=i,s=n,G(i,n)}finally{p.__wbindgen_free(t,s,1)}}renderPage(t,s){let i=p.inspector_renderPage(this.__wbg_ptr,t,s);if(i[3])throw Y(i[2]);var n=Ui(i[0],i[1]).slice();return p.__wbindgen_free(i[0],i[1]*1,1),n}tree(){let t,s;try{let r=p.inspector_tree(this.__wbg_ptr);var i=r[0],n=r[1];if(r[3])throw i=0,n=0,Y(r[2]);return t=i,s=n,G(i,n)}finally{p.__wbindgen_free(t,s,1)}}undo(){let t,s;try{let r=p.inspector_undo(this.__wbg_ptr);var i=r[0],n=r[1];if(r[3])throw i=0,n=0,Y(r[2]);return t=i,s=n,G(i,n)}finally{p.__wbindgen_free(t,s,1)}}};Symbol.dispose&&(bt.prototype[Symbol.dispose]=bt.prototype.free);is=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>p.__wbg_inspector_free(e,1));q=null;xt=null;Ot=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Ot.decode();Gi=2146435072,ne=0;It=new TextEncoder;"encodeInto"in It||(It.encodeInto=function(e,t){let s=It.encode(e);return t.set(s),{read:e.length,written:s.length}});J=0});var Je=Is(Ze(),1);var gi="application/vnd.adobe.indesign-idml-package";var ut=class extends Error{constructor(s,i){super(i);this.code=s;this.name="IdmlPreflightError"}code},f=(e,t)=>{throw new ut(e,t)},H=(e,t,s,i)=>{(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||e<0||t<0||e>s||t>s-e)&&f("IDML_ZIP_RANGE",`${i} points outside the IDML package.`)},Mt=(e,t,s)=>{let i=e+t;return Number.isSafeInteger(i)||f("IDML_ZIP_RANGE",`${s} exceeds JavaScript's safe integer range.`),i},_i=(e,t)=>{if(e.byteLength!==t.byteLength)return!1;for(let s=0;s<e.byteLength;s+=1)if(e[s]!==t[s])return!1;return!0},xi=e=>{try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{return f("IDML_ZIP_PATH","An IDML ZIP entry path is not valid UTF-8.")}},Ii=(e,t)=>{(e.byteLength===0||e.byteLength>4096)&&f("IDML_ZIP_PATH","An IDML ZIP entry has an empty or oversized path."),(t&2048)===0&&e.some(r=>r>127)&&f("IDML_ZIP_PATH","A non-UTF-8 IDML ZIP entry uses an ambiguous non-ASCII path.");let s=xi(e);(s.includes("\0")||s.includes("\\")||s.startsWith("/")||/^[A-Za-z]:/.test(s))&&f("IDML_ZIP_PATH",`Unsafe IDML ZIP entry path ${JSON.stringify(s)}.`);let i=s.endsWith("/"),n=s.split("/");return i&&n.pop(),(n.length===0||n.some(r=>r===""||r==="."||r===".."))&&f("IDML_ZIP_PATH",`Unsafe IDML ZIP entry path ${JSON.stringify(s)}.`),s},bi=e=>{e.byteLength<22&&f("IDML_ZIP_EOCD","The IDML package is too short to contain a ZIP directory.");let t=Math.max(0,e.byteLength-65557);for(let s=e.byteLength-22;s>=t;s-=1){if(e.getUint32(s,!0)!==101010256)continue;let i=e.getUint16(s+20,!0);if(s+22+i===e.byteLength)return s}return f("IDML_ZIP_EOCD","The IDML ZIP end-of-central-directory record is missing or truncated.")},Xe=(e,t)=>{let s=new DataView(e.buffer,e.byteOffset,e.byteLength),i=0;for(;i<e.byteLength;){H(i,4,e.byteLength,`${t} extra-field header`);let n=s.getUint16(i,!0),r=s.getUint16(i+2,!0);H(i+4,r,e.byteLength,`${t} extra field`),n===1&&f("IDML_ZIP64_UNSUPPORTED","ZIP64 IDML packages are not accepted by this bounded renderer."),n===39169&&f("IDML_ZIP_ENCRYPTED","Encrypted IDML ZIP entries are not supported."),i+=4+r}},Ei=e=>e===0?"stored":e===8?"deflate":f("IDML_ZIP_COMPRESSION",`Unsupported IDML ZIP compression method ${e}.`),Di=(e,t,s,i)=>{H(i.localHeaderOffset,30,s,`Local header for ${i.path}`),t.getUint32(i.localHeaderOffset,!0)!==67324752&&f("IDML_ZIP_LOCAL_HEADER",`The local header for ${JSON.stringify(i.path)} is missing.`);let n=t.getUint16(i.localHeaderOffset+6,!0),r=t.getUint16(i.localHeaderOffset+8,!0);(n!==i.flags||r!==i.method)&&f("IDML_ZIP_LOCAL_HEADER",`The local and central headers disagree for ${JSON.stringify(i.path)}.`);let a=t.getUint16(i.localHeaderOffset+26,!0),o=t.getUint16(i.localHeaderOffset+28,!0),c=i.localHeaderOffset+30;H(c,a+o,s,`Local path for ${i.path}`);let d=e.subarray(c,c+a);_i(d,i.rawName)||f("IDML_ZIP_LOCAL_HEADER",`The local path does not match the central path for ${JSON.stringify(i.path)}.`),Xe(e.subarray(c+a,c+a+o),`Local header for ${i.path}`);let h=c+a+o,l=Mt(h,i.compressedSize,`Compressed payload for ${i.path}`);H(h,i.compressedSize,s,`Compressed payload for ${i.path}`);let g=l;if((i.flags&8)!==0){H(l,12,s,`Data descriptor for ${i.path}`);let m=t.getUint32(l,!0)===134695760,_=l+(m?4:0);H(_,12,s,`Data descriptor for ${i.path}`),(t.getUint32(_,!0)!==i.crc32||t.getUint32(_+4,!0)!==i.compressedSize||t.getUint32(_+8,!0)!==i.uncompressedSize)&&f("IDML_ZIP_DATA_DESCRIPTOR",`Invalid data descriptor for ${JSON.stringify(i.path)}.`),g=_+12}else(t.getUint32(i.localHeaderOffset+14,!0)!==i.crc32||t.getUint32(i.localHeaderOffset+18,!0)!==i.compressedSize||t.getUint32(i.localHeaderOffset+22,!0)!==i.uncompressedSize)&&f("IDML_ZIP_LOCAL_HEADER",`The local sizes or CRC disagree for ${JSON.stringify(i.path)}.`);return{dataOffset:h,localEnd:g}},Ye=(e,t)=>{let s=e instanceof Uint8Array?e:new Uint8Array(e);s.byteLength>t.maxFileBytes&&f("IDML_FILE_LIMIT",`IDML source exceeds the ${t.maxFileBytes}-byte safety limit.`);let i=new DataView(s.buffer,s.byteOffset,s.byteLength),n=bi(i),r=i.getUint16(n+4,!0),a=i.getUint16(n+6,!0),o=i.getUint16(n+8,!0),c=i.getUint16(n+10,!0),d=i.getUint32(n+12,!0),h=i.getUint32(n+16,!0);(r!==0||a!==0||o!==c)&&f("IDML_ZIP_MULTIDISK","Multi-disk IDML ZIP packages are not supported."),(c===65535||d===4294967295||h===4294967295)&&f("IDML_ZIP64_UNSUPPORTED","ZIP64 IDML packages are not accepted by this bounded renderer."),(c===0||c>t.maxEntries)&&f("IDML_ENTRY_LIMIT",`IDML ZIP entry count ${c} is outside the configured safety limit.`),H(h,d,n,"IDML central directory"),h+d!==n&&f("IDML_ZIP_DIRECTORY","The IDML central directory has an unsupported gap or trailing record.");let l=new Set,g=[],m=h,_=0,L=0;for(let u=0;u<c;u+=1){H(m,46,n,`IDML central entry ${u}`),i.getUint32(m,!0)!==33639248&&f("IDML_ZIP_DIRECTORY",`IDML central entry ${u} has an invalid signature.`);let A=i.getUint16(m+8,!0),Z=i.getUint16(m+10,!0),K=i.getUint32(m+16,!0),O=i.getUint32(m+20,!0),F=i.getUint32(m+24,!0),W=i.getUint16(m+28,!0),$=i.getUint16(m+30,!0),yt=i.getUint16(m+32,!0),oe=i.getUint16(m+34,!0),ce=i.getUint32(m+42,!0);(A&8257)!==0&&f("IDML_ZIP_ENCRYPTED","Encrypted IDML ZIP entries are not supported."),(O===4294967295||F===4294967295||ce===4294967295||oe===65535)&&f("IDML_ZIP64_UNSUPPORTED","ZIP64 IDML entries are not accepted by this bounded renderer."),oe!==0&&f("IDML_ZIP_MULTIDISK","An IDML entry points to another ZIP disk.");let de=Ei(Z);de==="stored"&&O!==F&&f("IDML_ZIP_SIZE","A stored IDML ZIP entry declares different compressed and uncompressed sizes."),O>t.maxEntryCompressedBytes&&f("IDML_ENTRY_LIMIT","An IDML ZIP entry exceeds the compressed-byte safety limit."),F>t.maxEntryUncompressedBytes&&f("IDML_ENTRY_LIMIT","An IDML ZIP entry exceeds the uncompressed-byte safety limit.");let he=F===0?1:F/Math.max(1,O);he>t.maxCompressionRatio&&f("IDML_ZIP_BOMB",`An IDML ZIP entry declares a ${he.toFixed(1)}:1 compression ratio.`),_=Mt(_,O,"IDML compressed byte total"),L=Mt(L,F,"IDML uncompressed byte total"),L>t.maxTotalUncompressedBytes&&f("IDML_ZIP_BOMB","The IDML ZIP declared uncompressed total exceeds the configured safety limit.");let le=W+$+yt;H(m+46,le,n,`IDML central entry ${u} metadata`);let fe=s.subarray(m+46,m+46+W),dt=Ii(fe,A);l.has(dt)&&f("IDML_ZIP_DUPLICATE",`Duplicate IDML ZIP entry ${JSON.stringify(dt)}.`),l.add(dt),Xe(s.subarray(m+46+W,m+46+W+$),`Central header for ${dt}`);let ue={centralIndex:u,path:dt,compression:de,compressedSize:O,uncompressedSize:F,localHeaderOffset:ce,flags:A,method:Z,crc32:K,rawName:fe},hs=Di(s,i,h,ue);g.push({...ue,...hs}),m+=46+le}m!==n&&f("IDML_ZIP_DIRECTORY","The IDML central directory size does not match its entries.");let N=[...g].sort((u,A)=>u.localHeaderOffset-A.localHeaderOffset);for(let u=1;u<N.length;u+=1)N[u-1].localEnd>N[u].localHeaderOffset&&f("IDML_ZIP_OVERLAP","IDML ZIP local entries overlap.");let I=g.find(u=>u.path==="mimetype"),k=g.find(u=>u.path==="designmap.xml");if(!I)return f("IDML_REQUIRED_ENTRY","IDML package must contain an exact-case mimetype entry.");if(!k)return f("IDML_REQUIRED_ENTRY","IDML package must contain an exact-case designmap.xml entry.");(I.localHeaderOffset!==0||I.compression!=="stored")&&f("IDML_MIMETYPE","IDML mimetype must be the first local entry and must be stored.");let T=s.subarray(I.dataOffset,I.dataOffset+I.uncompressedSize);return new TextDecoder().decode(T)!==gi&&f("IDML_MIMETYPE","IDML mimetype entry has an unexpected value."),k.uncompressedSize===0&&f("IDML_REQUIRED_ENTRY","IDML designmap.xml must not be empty."),{fileBytes:s.byteLength,entryCount:c,compressedBytes:_,uncompressedBytes:L,compressionRatio:L===0?1:L/Math.max(1,_),entries:g.map(u=>({path:u.path,compression:u.compression,compressedSize:u.compressedSize,uncompressedSize:u.uncompressedSize,crc32:u.crc32,localHeaderOffset:u.localHeaderOffset,dataOffset:u.dataOffset}))}},at,yi=()=>{if(at)return at;at=new Uint32Array(256);for(let e=0;e<at.length;e+=1){let t=e;for(let s=0;s<8;s+=1)t=(t&1)!==0?3988292384^t>>>1:t>>>1;at[e]=t>>>0}return at},Ai=(e,t)=>{let s=yi(),i=e;for(let n of t)i=s[(i^n)&255]^i>>>8;return i},We=e=>e.reason instanceof Error?e.reason:new DOMException("IDML ZIP extraction was aborted.","AbortError"),Ve=async(e,t,s,i,n)=>{let r=e instanceof Uint8Array?e:new Uint8Array(e);t.fileBytes!==r.byteLength&&f("IDML_ZIP_RANGE","The IDML ZIP directory belongs to a different source buffer.");let a=t.entries.find(l=>l.path===s)??f("IDML_REQUIRED_ENTRY",`IDML ZIP entry ${JSON.stringify(s)} is missing.`);if(n?.aborted)throw We(n);let o=r.subarray(a.dataOffset,a.dataOffset+a.compressedSize),c=0,d=4294967295,h=l=>{if(n?.aborted)throw We(n);c=Mt(c,l.byteLength,`Expanded payload for ${s}`),c>a.uncompressedSize&&f("IDML_ZIP_SIZE",`IDML ZIP entry ${JSON.stringify(s)} expanded past its declared size.`),d=Ai(d,l),i(l)};if(a.compression==="stored")for(let g=0;g<o.byteLength;g+=65536)h(o.subarray(g,Math.min(o.byteLength,g+65536)));else{typeof DecompressionStream>"u"&&f("IDML_ZIP_DEFLATE_UNAVAILABLE","This browser does not provide the raw DEFLATE decoder required for IDML metadata.");let l;try{l=new DecompressionStream("deflate-raw")}catch{return f("IDML_ZIP_DEFLATE_UNAVAILABLE","This browser does not support raw DEFLATE streams required by IDML metadata.")}let g=Uint8Array.from(o),m=new Blob([g]).stream().pipeThrough(l).getReader();try{for(;;){let _=await m.read();if(_.done)break;h(_.value)}}catch(_){throw await m.cancel(_).catch(()=>{}),_}finally{m.releaseLock()}}c!==a.uncompressedSize&&f("IDML_ZIP_SIZE",`IDML ZIP entry ${JSON.stringify(s)} expanded to ${c} bytes instead of ${a.uncompressedSize}.`),(d^4294967295)>>>0!==a.crc32&&f("IDML_ZIP_CRC",`IDML ZIP entry ${JSON.stringify(s)} failed CRC-32 validation.`)};var wi=72,ze=4,Si=32*1024,mt=class extends Error{constructor(s,i){super(i);this.code=s;this.name="IdmlPageGeometryError"}code},S=(e,t)=>{throw new mt(e,t)},je=e=>e.split(":").pop()||e,Ti=(e,t)=>{let s=(e||"").trim().split(/\s+/).map(Number);if(s.length!==4||s.some(d=>!Number.isFinite(d)))return S("IDML_PAGE_GEOMETRY",`${t} contains a Page without four finite GeometricBounds coordinates.`);let[i,n,r,a]=s,o=Math.abs(a-n),c=Math.abs(r-i);return!(o>0)||!(c>0)?S("IDML_PAGE_GEOMETRY",`${t} contains an empty Page GeometricBounds rectangle.`):{top:i,left:n,bottom:r,right:a,widthPoints:o,heightPoints:c,label:""}},qe=async(e,t,s,i,n)=>{let r=new TextDecoder("utf-8",{fatal:!0}),a=new Je.SaxesParser({xmlns:!1,position:!1,fileName:s});a.on("error",o=>{throw o}),a.on("doctype",()=>S("IDML_PAGE_GEOMETRY_XML",`${s} contains a forbidden DTD or ENTITY declaration.`)),a.on("processinginstruction",o=>{o.target.toLowerCase()==="xml-stylesheet"&&S("IDML_PAGE_GEOMETRY_XML",`${s} contains an external-capable XML stylesheet instruction.`)}),a.on("opentag",i);try{await Ve(e,t,s,o=>a.write(r.decode(o,{stream:!0})),n),a.write(r.decode()).close()}catch(o){throw o instanceof mt||o instanceof DOMException&&o.name==="AbortError"||o instanceof Error&&"code"in o?o:new mt("IDML_PAGE_GEOMETRY_XML",`${s} could not be parsed for page geometry: ${o instanceof Error?o.message:String(o)}`)}},Qe=async(e,t,s,i)=>{let n=[],r=new Set;await qe(e,t,"designmap.xml",c=>{if(je(c.name)!=="Spread")return;let d=c.attributes.src;(!d||!/^Spreads\/[^/]+\.xml$/.test(d))&&S("IDML_PAGE_GEOMETRY","designmap.xml contains an invalid or missing packaged Spread reference."),r.has(d)&&S("IDML_PAGE_GEOMETRY",`designmap.xml references ${JSON.stringify(d)} twice.`),n.length>=s.maxPages&&S("IDML_PAGE_GEOMETRY",`designmap.xml exceeds the ${s.maxPages}-spread page-geometry limit.`),t.entries.some(h=>h.path===d)||S("IDML_REQUIRED_ENTRY",`Referenced IDML spread ${JSON.stringify(d)} is missing.`),r.add(d),n.push(d)},i),n.length===0&&S("IDML_PAGE_GEOMETRY","designmap.xml does not reference any document spreads.");let a=[],o=0;for(let c of n){let d=[];await qe(e,t,c,h=>{if(je(h.name)!=="Page")return;o+=1,o>s.maxPages&&S("IDML_PAGE_GEOMETRY",`IDML spread XML exceeds the ${s.maxPages}-page geometry limit.`);let l=Ti(h.attributes.GeometricBounds,c);l.label=(h.attributes.Name||"").slice(0,512),d.push(l)},i),d.length===0&&S("IDML_PAGE_GEOMETRY",`${c} does not contain any Page geometry.`),a.push(d)}return a},Rt=(e,t,s)=>{let i=e*t;return Number.isSafeInteger(i)?i:S("IDML_RENDER_DIMENSION_LIMIT",`${s} exceeds JavaScript's safe integer range.`)},Ci=e=>e+Math.floor(e/4096)+Math.floor(e/16384)+Math.floor(e/33554432)+13,Ke=(e,t,s)=>{let i=t/wi,n=Math.ceil(e.widthPoints*i),r=Math.ceil(e.heightPoints*i);if(!Number.isSafeInteger(n)||!Number.isSafeInteger(r)||n<=0||r<=0||n>s.maxRenderedDimension||r>s.maxRenderedDimension)return S("IDML_RENDER_DIMENSION_LIMIT",`IDML page projects to ${n} x ${r} pixels at ${t} DPI, exceeding the ${s.maxRenderedDimension}-pixel width/height safety limit.`);let a=Rt(n,r,"IDML rendered pixel count");if(a>s.maxRenderedPixels)return S("IDML_RENDER_PIXEL_LIMIT",`IDML page projects to ${a} pixels (${n} x ${r}) at ${t} DPI, exceeding the ${s.maxRenderedPixels}-pixel safety limit.`);let o=Rt(n,ze,"IDML rendered row byte count"),c=Rt(o+1,r,"IDML PNG scanline byte count"),d=Ci(c),h=Math.max(1,Math.ceil(d/Si)),l=33+d+h*12+12;if(!Number.isSafeInteger(l)||l>s.maxRenderedPngBytes)return S("IDML_RENDER_PNG_LIMIT",`IDML page projects to a worst-case ${l}-byte PNG, exceeding the ${s.maxRenderedPngBytes}-byte safety limit.`);let g=Rt(a,ze,"IDML rendered RGBA byte count"),m=l+d+g*3+(o+1)*2;return!Number.isSafeInteger(m)||m>s.maxRenderWorkingSetBytes?S("IDML_RENDER_WORKING_SET_LIMIT",`IDML page projects to a ${m}-byte render/decode working set, exceeding the ${s.maxRenderWorkingSetBytes}-byte safety limit.`):{width:n,height:r,pixels:a,rgbaBytes:g,estimatedPngBytes:l,projectedWorkingSetBytes:m}};var Pt=Uint8Array.of(137,80,78,71,13,10,26,10),ot=4,Li=1e5,D=class extends Error{code="IDML_PNG_INVALID";constructor(t){super(t),this.name="IdmlPngError"}},se=(e,t,s,i)=>{if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||e<0||t<0||e>s||t>s-e)throw new D(`${i} points outside the Inspector PNG.`)},pt,Ni=()=>{if(pt)return pt;pt=new Uint32Array(256);for(let e=0;e<256;e+=1){let t=e;for(let s=0;s<8;s+=1)t=(t&1)!==0?3988292384^t>>>1:t>>>1;pt[e]=t>>>0}return pt},Mi=(e,t)=>{let s=Ni(),i=4294967295;for(let n of[e,t])for(let r=0;r<n.byteLength;r+=1)i=s[(i^n[r])&255]^i>>>8;return(i^4294967295)>>>0},Ri=e=>String.fromCharCode(...e),Pi=(e,t)=>{if(e.byteLength>t.maxRenderedPngBytes)throw new D(`Inspector PNG exceeds the ${t.maxRenderedPngBytes}-byte safety limit.`);se(0,Pt.byteLength,e.byteLength,"PNG signature");for(let I=0;I<Pt.byteLength;I+=1)if(e[I]!==Pt[I])throw new D("Inspector render did not return a PNG image.");let s=new DataView(e.buffer,e.byteOffset,e.byteLength),i=[],n=0,r=0,a=0,o=!1,c=!1,d=Pt.byteLength,h=0;for(;d<e.byteLength;){if(h+=1,h>Li)throw new D("Inspector PNG contains too many chunks.");se(d,12,e.byteLength,"PNG chunk header");let I=s.getUint32(d,!1),k=e.subarray(d+4,d+8),T=Ri(k),u=d+8;se(u,I+4,e.byteLength,`PNG ${T} chunk`);let A=e.subarray(u,u+I),Z=s.getUint32(u+I,!1);if(Mi(k,A)!==Z)throw new D(`Inspector PNG ${T} CRC is invalid.`);if(h===1&&T!=="IHDR")throw new D("Inspector PNG does not start with IHDR.");if(T==="IHDR"){if(o||I!==13)throw new D("Inspector PNG has an invalid IHDR chunk.");r=s.getUint32(u,!1),a=s.getUint32(u+4,!1);let K=s.getUint8(u+8),O=s.getUint8(u+9),F=s.getUint8(u+10),W=s.getUint8(u+11),$=s.getUint8(u+12);if(r===0||a===0||K!==8||O!==6||F!==0||W!==0||$!==0)throw new D("Inspector PNG must be non-interlaced 8-bit RGBA.");let yt=r*a;if(!Number.isSafeInteger(yt)||yt>t.maxRenderedPixels)throw new D(`Inspector PNG exceeds the ${t.maxRenderedPixels}-pixel safety limit.`);o=!0}else if(T==="IDAT"){if(!o||c)throw new D("Inspector PNG has IDAT chunks in an invalid position.");if(n+=A.byteLength,n>t.maxRenderedPngBytes)throw new D("Inspector PNG IDAT data is oversized.");i.push(A)}else if(T==="IEND"){if(I!==0||c)throw new D("Inspector PNG has an invalid IEND chunk.");if(c=!0,d=u+I+4,d!==e.byteLength)throw new D("Inspector PNG has trailing bytes after IEND.");break}else if((k[0]&32)===0)throw new D(`Inspector PNG contains unsupported critical chunk ${T}.`);d=u+I+4}if(!o||!c||i.length===0)throw new D("Inspector PNG is missing IHDR, IDAT, or IEND.");let l=r*ot,g=(l+1)*a;if(!Number.isSafeInteger(g))throw new D("Inspector PNG dimensions overflow.");let m=l*a,_=e.byteLength+n+m*3+(l+1)*2;if(!Number.isSafeInteger(_)||_>t.maxRenderWorkingSetBytes)throw new D(`Inspector PNG projected working set exceeds the ${t.maxRenderWorkingSetBytes}-byte safety limit.`);let L=new Uint8Array(n),N=0;for(let I of i)L.set(I,N),N+=I.byteLength;return{width:r,height:a,expectedInflatedBytes:g,idat:L}},Ft=e=>e.reason instanceof Error?e.reason:new DOMException("IDML page decoding was aborted.","AbortError"),Fi=async(e,t,s,i)=>{if(typeof DecompressionStream>"u")throw new D("This browser does not provide the deflate decoder required for Inspector PNG output.");if(i?.aborted)throw Ft(i);let n=new DecompressionStream("deflate"),r=n.writable.getWriter(),a=n.readable.getReader(),o=e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Uint8Array.from(e),c=t*ot,d=(c+1)*s,h=new Uint8ClampedArray(c*s),l=0,g=0,m=0,_=0,L=()=>{a.cancel(Ft(i)).catch(()=>{}),r.abort(Ft(i)).catch(()=>{})};i?.addEventListener("abort",L,{once:!0});let N=(async()=>{for(;;){let I=await a.read();if(I.done)break;let k=I.value;for(let T=0;T<k.byteLength;T+=1){if(l>=d)throw await a.cancel("Inspector PNG expands beyond its declared dimensions."),new D("Inspector PNG expands beyond its declared dimensions.");let u=k[T];if(m===0){if(_=u,_>4)throw await a.cancel(`Inspector PNG uses unknown row filter ${_}.`),new D(`Inspector PNG uses unknown row filter ${_}.`)}else{let A=m-1,Z=g*c,K=Z-c,O=A>=ot?h[Z+A-ot]:0,F=g>0?h[K+A]:0,W=g>0&&A>=ot?h[K+A-ot]:0,$=u;_===1?$+=O:_===2?$+=F:_===3?$+=Math.floor((O+F)/2):_===4&&($+=Oi(O,F,W)),h[Z+A]=$&255}l+=1,m+=1,m===c+1&&(g+=1,m=0)}}})();try{await Promise.all([(async()=>{await r.write(o),await r.close()})(),N])}finally{i?.removeEventListener("abort",L)}if(l!==d)throw new D("Inspector PNG decompressed byte count is invalid.");return h},Oi=(e,t,s)=>{let i=e+t-s,n=Math.abs(i-e),r=Math.abs(i-t),a=Math.abs(i-s);return n<=r&&n<=a?e:r<=a?t:s},ts=async(e,t,s)=>{let i=Pi(e,t),n=await Fi(i.idat,i.width,i.height,s);if(s?.aborted)throw Ft(s);return{width:i.width,height:i.height,rgba:n}};var P=class extends Error{code="IDML_TREE_INVALID";constructor(t){super(t),this.name="IdmlTreeError"}},gt=(e,t)=>{if(typeof e!="object"||e===null||Array.isArray(e))throw new P(`${t} must be an object.`);return e},ie=(e,t)=>{if(!Array.isArray(e))throw new P(`${t} must be an array.`);return e},_t=(e,t,s)=>{if(typeof e!="string"||e.length===0||e.length>s)throw new P(`${t} must be a non-empty string no longer than ${s} characters.`);return e},es=(e,t)=>{if(!Number.isSafeInteger(e)||Number(e)<0)throw new P(`${t} must be a non-negative integer.`);return Number(e)},ki=(e,t)=>{let s=gt(e,t);return{kind:_t(s.kind,`${t}.kind`,128),id:_t(s.id,`${t}.id`,2048)}},vi=(e,t)=>{let s=gt(e,t);return{id:ki(s.id,`${t}.id`),label:_t(s.label,`${t}.label`,512)}},ss=(e,t)=>{if(typeof e!="string")throw new P("Inspector tree output must be a JSON string.");if(e.length>t.maxTreeJsonBytes)throw new P(`Inspector tree exceeds the ${t.maxTreeJsonBytes}-byte safety limit.`);if(new TextEncoder().encode(e).byteLength>t.maxTreeJsonBytes)throw new P(`Inspector tree exceeds the ${t.maxTreeJsonBytes}-byte safety limit.`);let i;try{i=JSON.parse(e)}catch{throw new P("Inspector tree is not valid JSON.")}let n=gt(i,"Inspector tree"),r=ie(n.spreads,"Inspector tree spreads");if(r.length>t.maxPages)throw new P("Inspector tree contains more spreads than the configured page limit.");let a=0,o=0,c=r.map((d,h)=>{let l=gt(d,`Spread ${h}`),g=es(l.index,`Spread ${h}.index`),_=ie(l.pages,`Spread ${h}.pages`).map((L,N)=>{if(a>=t.maxPages)throw new P(`Inspector tree exceeds the ${t.maxPages}-page safety limit.`);let I=gt(L,`Spread ${h} page ${N}`),k=ie(I.frames,`Spread ${h} page ${N}.frames`).map((u,A)=>{if(o+=1,o>t.maxFrames)throw new P(`Inspector tree exceeds the ${t.maxFrames}-frame safety limit.`);return vi(u,`Spread ${h} page ${N} frame ${A}`)}),T={index:a,indexInSpread:es(I.index,`Spread ${h} page ${N}.index`),spreadIndex:g,label:_t(I.label,`Spread ${h} page ${N}.label`,512),frames:k};return a+=1,T});return{index:g,label:_t(l.label,`Spread ${h}.label`,512),pages:_}});if(a===0)throw new P("Inspector tree does not contain any pages.");return{spreads:c,pageCount:a,frameCount:o}};var B=class extends Error{constructor(s,i){super(i);this.code=s;this.name="IdmlEngineError"}code},Et,ae,ji=async e=>{if(Et){if(e&&e!==ae)throw new B("IDML_WASM_URL_CHANGED","The IDML Worker cannot switch introspect-wasm binaries after initialization.");return Et}ae=e,Et=(async()=>{let t=await Promise.resolve().then(()=>(cs(),os));if(await t.default(e?{module_or_path:e}:void 0),typeof t.Inspector!="function")throw new B("IDML_ENGINE_API","introspect-wasm did not export Inspector.");return{Inspector:t.Inspector}})();try{return await Et}catch(t){throw Et=void 0,ae=void 0,t}},V=e=>{if(e?.aborted)throw e.reason instanceof Error?e.reason:new DOMException("IDML operation was aborted.","AbortError")},qi=e=>e instanceof Uint8Array?new Uint8Array(e):new Uint8Array(e),kt=class e{constructor(t,s,i,n){this.inspector=t;this.limits=s;this.pageBounds=i;this.opened=n}inspector;limits;pageBounds;opened;destroyed=!1;static async open(t,s,i={}){V(i.signal);let n=qi(t),r=Ye(n,s),a=await Qe(n,r,s,i.signal);V(i.signal);let o=await(i.runtimeLoader??ji)(i.wasmUrl);V(i.signal);let c;try{c=new o.Inspector(n),V(i.signal);let d=ss(c.tree(),s);if(d.spreads.length!==a.length)throw new B("IDML_PAGE_GEOMETRY_MISMATCH","Inspector spread count does not match the preflighted IDML page geometry.");for(let g=0;g<d.spreads.length;g+=1)if(d.spreads[g].pages.length!==a[g].length)throw new B("IDML_PAGE_GEOMETRY_MISMATCH",`Inspector page count for spread ${g} does not match the preflighted IDML page geometry.`);let h=a.flat();if(h.length!==d.pageCount)throw new B("IDML_PAGE_GEOMETRY_MISMATCH","Inspector page count does not match the preflighted IDML page geometry.");let l={engine:"@paged-media/introspect-wasm",engineVersion:"0.62.0",renderBackend:"cpu-tiny-skia",tree:d,archive:{entryCount:r.entryCount,compressedBytes:r.compressedBytes,uncompressedBytes:r.uncompressedBytes,compressionRatio:r.compressionRatio}};return new e(c,s,h,l)}catch(d){throw c?.free(),d}}async renderPage(t,s,i){let n=this.inspector;if(this.destroyed||!n)throw new B("IDML_SESSION_DESTROYED","IDML document session was destroyed.");if(!Number.isSafeInteger(t)||t<0||t>=this.opened.tree.pageCount)throw new B("IDML_PAGE_RANGE",`IDML page index ${t} is outside 0..${this.opened.tree.pageCount-1}.`);if(!Number.isFinite(s)||s<this.limits.minDpi||s>this.limits.maxDpi)throw new B("IDML_DPI_RANGE",`IDML render DPI must be between ${this.limits.minDpi} and ${this.limits.maxDpi}.`);V(i);let r=Ke(this.pageBounds[t],s,this.limits);V(i);let a=n.renderPage(t,s);V(i);let o=await ts(a,this.limits,i);if(V(i),o.width>r.width||o.height>r.height)throw new B("IDML_RENDER_GEOMETRY_MISMATCH",`Inspector rendered ${o.width} x ${o.height} pixels beyond the preflighted ${r.width} x ${r.height} page bounds.`);return{pageIndex:t,dpi:s,...o}}destroy(){this.destroyed||(this.destroyed=!0,this.inspector?.free(),this.inspector=void 0)}};var Dt=self,Q,Ji=e=>e instanceof ut||e instanceof Error&&"code"in e&&typeof e.code=="string"?e.code:"IDML_ENGINE_FAILURE",Qi=async e=>{try{if(e.type==="open"){Q?.destroy(),Q=void 0;let i=await kt.open(e.buffer,e.limits,{wasmUrl:e.wasmUrl});Q=i;let n={id:e.id,ok:!0,type:"open",result:i.opened};Dt.postMessage(n);return}if(e.type==="destroy"){Q?.destroy(),Q=void 0;let i={id:e.id,ok:!0,type:"destroy"};Dt.postMessage(i);return}if(!Q)throw new Error("IDML Worker has no open document.");let t=await Q.renderPage(e.pageIndex,e.dpi),s={id:e.id,ok:!0,type:"renderPage",result:t};Dt.postMessage(s,[t.rgba.buffer])}catch(t){let s=Ji(t),i={id:e.id,ok:!1,error:{name:t instanceof Error?t.name:"Error",code:s,message:t instanceof Error?t.message:String(t),fatal:e.type==="open"||s==="IDML_PNG_INVALID"||t instanceof RangeError}};Dt.postMessage(i)}},ds=Promise.resolve();Dt.addEventListener("message",e=>{ds=ds.catch(()=>{}).then(()=>Qi(e.data))});
|
|
9
|
+
`),t=this.i;break;case E:i!==void 0&&(this.text+=s.slice(t));break t;default:R(r)||(n=!0)}}n&&(!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0))}pushAttribNS(t,s){var i;let{prefix:n,local:r}=this.qname(t),a={name:t,prefix:n,local:r,value:s};if(this.attribList.push(a),(i=this.attributeHandler)===null||i===void 0||i.call(this,a),n==="xmlns"){let o=s.trim();this.currentXMLVersion==="1.0"&&o===""&&this.fail("invalid attempt to undefine prefix in XML 1.0"),this.topNS[r]=o,Kt(this,r,o)}else if(t==="xmlns"){let o=s.trim();this.topNS[""]=o,Kt(this,"",o)}}pushAttribPlain(t,s){var i;let n={name:t,value:s};this.attribList.push(n),(i=this.attributeHandler)===null||i===void 0||i.call(this,n)}end(){var t,s;this.sawRoot||this.fail("document must contain a root element.");let{tags:i}=this;for(;i.length>0;){let r=i.pop();this.fail(`unclosed tag: ${r.name}`)}this.state!==we&&this.state!==C&&this.fail("unexpected end.");let{text:n}=this;return n.length!==0&&((t=this.textHandler)===null||t===void 0||t.call(this,n),this.text=""),this._closed=!0,(s=this.endHandler)===null||s===void 0||s.call(this),this._init(),this}resolve(t){var s,i;let n=this.topNS[t];if(n!==void 0)return n;let{tags:r}=this;for(let a=r.length-1;a>=0;a--)if(n=r[a].ns[t],n!==void 0)return n;return n=this.ns[t],n!==void 0?n:(i=(s=this.opt).resolvePrefix)===null||i===void 0?void 0:i.call(s,t)}qname(t){let s=t.indexOf(":");if(s===-1)return{prefix:"",local:t};let i=t.slice(s+1),n=t.slice(0,s);return(n===""||i===""||i.includes(":"))&&this.fail(`malformed name: ${t}.`),{prefix:n,local:i}}processAttribsNS(){var t;let{attribList:s}=this,i=this.tag;{let{prefix:a,local:o}=this.qname(i.name);i.prefix=a,i.local=o;let c=i.uri=(t=this.resolve(a))!==null&&t!==void 0?t:"";a!==""&&(a==="xmlns"&&this.fail('tags may not have "xmlns" as prefix.'),c===""&&(this.fail(`unbound namespace prefix: ${JSON.stringify(a)}.`),i.uri=a))}if(s.length===0)return;let{attributes:n}=i,r=new Set;for(let a of s){let{name:o,prefix:c,local:d}=a,h,l;c===""?(h=o==="xmlns"?it:"",l=o):(h=this.resolve(c),h===void 0&&(this.fail(`unbound namespace prefix: ${JSON.stringify(c)}.`),h=c),l=`{${h}}${d}`),r.has(l)&&this.fail(`duplicate attribute: ${l}.`),r.add(l),a.uri=h,n[o]=a}this.attribList=[]}processAttribsPlain(){let{attribList:t}=this,s=this.tag.attributes;for(let{name:i,value:n}of t)s[i]!==void 0&&this.fail(`duplicate attribute: ${i}.`),s[i]=n;this.attribList=[]}openTag(){var t;this.processAttribs();let{tags:s}=this,i=this.tag;i.isSelfClosing=!1,(t=this.openTagHandler)===null||t===void 0||t.call(this,i),s.push(i),this.state=C,this.name=""}openSelfClosingTag(){var t,s,i;this.processAttribs();let{tags:n}=this,r=this.tag;r.isSelfClosing=!0,(t=this.openTagHandler)===null||t===void 0||t.call(this,r),(s=this.closeTagHandler)===null||s===void 0||s.call(this,r),(this.tag=(i=n[n.length-1])!==null&&i!==void 0?i:null)===null&&(this.closedRoot=!0),this.state=C,this.name=""}closeTag(){let{tags:t,name:s}=this;if(this.state=C,this.name="",s===""){this.fail("weird empty close tag."),this.text+="</>";return}let i=this.closeTagHandler,n=t.length;for(;n-- >0;){let r=this.tag=t.pop();if(this.topNS=r.ns,i?.(r),r.name===s)break;this.fail("unexpected close tag.")}n===0?this.closedRoot=!0:n<0&&(this.fail(`unmatched closing tag: ${s}.`),this.text+=`</${s}>`)}parseEntity(t){if(t[0]!=="#"){let i=this.ENTITIES[t];return i!==void 0?i:(this.fail(this.isName(t)?"undefined entity.":"disallowed character in entity name."),`&${t};`)}let s=NaN;return t[1]==="x"&&/^#x[0-9a-f]+$/i.test(t)?s=parseInt(t.slice(2),16):/^#[0-9]+$/.test(t)&&(s=parseInt(t.slice(1),10)),this.isChar(s)?String.fromCodePoint(s):(this.fail("malformed character entity."),`&${t};`)}};nt.SaxesParser=te});var os={};_s(os,{Inspector:()=>bt,default:()=>zi,describeCatalog:()=>Bi,initSync:()=>Vi,on_start:()=>$i});function Bi(){let e,t;try{let n=p.describeCatalog();var s=n[0],i=n[1];if(n[3])throw s=0,i=0,Y(n[2]);return e=s,t=i,G(s,i)}finally{p.__wbindgen_free(e,t,1)}}function $i(){p.on_start()}function rs(){return{__proto__:null,"./paged_introspect_wasm_bg.js":{__proto__:null,__wbg_Error_ef53bc310eb298a0:function(t,s){return Error(G(t,s))},__wbg___wbindgen_throw_1506f2235d1bdba0:function(t,s){throw new Error(G(t,s))},__wbg_error_a6fa202b58aa1cd3:function(t,s){let i,n;try{i=t,n=s,console.error(G(t,s))}finally{p.__wbindgen_free(i,n,1)}},__wbg_log_cf2e968649f3384e:function(t){console.log(t)},__wbg_new_227d7c05414eb861:function(){return new Error},__wbg_stack_3b0d974bbf31e44f:function(t,s){let i=s.stack,n=re(i,p.__wbindgen_malloc,p.__wbindgen_realloc),r=J;ns().setInt32(t+4,r,!0),ns().setInt32(t+0,n,!0)},__wbindgen_cast_0000000000000001:function(t,s){return G(t,s)},__wbindgen_init_externref_table:function(){let t=p.__wbindgen_externrefs,s=t.grow(4);t.set(0,void 0),t.set(s+0,void 0),t.set(s+1,null),t.set(s+2,!0),t.set(s+3,!1)}}}}function Ui(e,t){return e=e>>>0,ct().subarray(e/1,e/1+t)}function ns(){return(q===null||q.buffer.detached===!0||q.buffer.detached===void 0&&q.buffer!==p.memory.buffer)&&(q=new DataView(p.memory.buffer)),q}function G(e,t){return Zi(e>>>0,t)}function ct(){return(xt===null||xt.byteLength===0)&&(xt=new Uint8Array(p.memory.buffer)),xt}function Hi(e,t){let s=t(e.length*1,1)>>>0;return ct().set(e,s/1),J=e.length,s}function re(e,t,s){if(s===void 0){let o=It.encode(e),c=t(o.length,1)>>>0;return ct().subarray(c,c+o.length).set(o),J=o.length,c}let i=e.length,n=t(i,1)>>>0,r=ct(),a=0;for(;a<i;a++){let o=e.charCodeAt(a);if(o>127)break;r[n+a]=o}if(a!==i){a!==0&&(e=e.slice(a)),n=s(n,i,i=a+e.length*3,1)>>>0;let o=ct().subarray(n+a,n+i),c=It.encodeInto(e,o);a+=c.written,n=s(n,i,a,1)>>>0}return J=a,n}function Y(e){let t=p.__wbindgen_externrefs.get(e);return p.__externref_table_dealloc(e),t}function Zi(e,t){return ne+=t,ne>=Gi&&(Ot=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Ot.decode(),ne=t),Ot.decode(ct().subarray(e,e+t))}function as(e,t){return Xi=e,p=e.exports,Wi=t,q=null,xt=null,p.__wbindgen_start(),p}async function Yi(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(n){if(e.ok&&s(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",n);else throw n}let i=await e.arrayBuffer();return await WebAssembly.instantiate(i,t)}else{let i=await WebAssembly.instantiate(e,t);return i instanceof WebAssembly.Instance?{instance:i,module:e}:i}function s(i){switch(i){case"basic":case"cors":case"default":return!0}return!1}}function Vi(e){if(p!==void 0)return p;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module:e}=e:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=rs();e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e));let s=new WebAssembly.Instance(e,t);return as(s,e)}async function zi(e){if(p!==void 0)return p;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),e===void 0&&(e=new URL("paged_introspect_wasm_bg.wasm",import.meta.url));let t=rs();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:s,module:i}=await Yi(await e,t);return as(s,i)}var bt,is,q,xt,Ot,Gi,ne,It,J,Wi,Xi,p,cs=gs(()=>{bt=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,is.unregister(this),t}free(){let t=this.__destroy_into_raw();p.__wbg_inspector_free(t,0)}apply(t){let s,i;try{let a=re(t,p.__wbindgen_malloc,p.__wbindgen_realloc),o=J,c=p.inspector_apply(this.__wbg_ptr,a,o);var n=c[0],r=c[1];if(c[3])throw n=0,r=0,Y(c[2]);return s=n,i=r,G(n,r)}finally{p.__wbindgen_free(s,i,1)}}constructor(t){let s=Hi(t,p.__wbindgen_malloc),i=J,n=p.inspector_new(s,i);if(n[2])throw Y(n[1]);return this.__wbg_ptr=n[0],is.register(this,this.__wbg_ptr,this),this}properties(t){let s,i;try{let a=re(t,p.__wbindgen_malloc,p.__wbindgen_realloc),o=J,c=p.inspector_properties(this.__wbg_ptr,a,o);var n=c[0],r=c[1];if(c[3])throw n=0,r=0,Y(c[2]);return s=n,i=r,G(n,r)}finally{p.__wbindgen_free(s,i,1)}}redo(){let t,s;try{let r=p.inspector_redo(this.__wbg_ptr);var i=r[0],n=r[1];if(r[3])throw i=0,n=0,Y(r[2]);return t=i,s=n,G(i,n)}finally{p.__wbindgen_free(t,s,1)}}renderPage(t,s){let i=p.inspector_renderPage(this.__wbg_ptr,t,s);if(i[3])throw Y(i[2]);var n=Ui(i[0],i[1]).slice();return p.__wbindgen_free(i[0],i[1]*1,1),n}tree(){let t,s;try{let r=p.inspector_tree(this.__wbg_ptr);var i=r[0],n=r[1];if(r[3])throw i=0,n=0,Y(r[2]);return t=i,s=n,G(i,n)}finally{p.__wbindgen_free(t,s,1)}}undo(){let t,s;try{let r=p.inspector_undo(this.__wbg_ptr);var i=r[0],n=r[1];if(r[3])throw i=0,n=0,Y(r[2]);return t=i,s=n,G(i,n)}finally{p.__wbindgen_free(t,s,1)}}};Symbol.dispose&&(bt.prototype[Symbol.dispose]=bt.prototype.free);is=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>p.__wbg_inspector_free(e,1));q=null;xt=null;Ot=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Ot.decode();Gi=2146435072,ne=0;It=new TextEncoder;"encodeInto"in It||(It.encodeInto=function(e,t){let s=It.encode(e);return t.set(s),{read:e.length,written:s.length}});J=0});var Je=Is(Ze(),1);var gi="application/vnd.adobe.indesign-idml-package";var ut=class extends Error{constructor(s,i){super(i);this.code=s;this.name="IdmlPreflightError"}code},f=(e,t)=>{throw new ut(e,t)},H=(e,t,s,i)=>{(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||e<0||t<0||e>s||t>s-e)&&f("IDML_ZIP_RANGE",`${i} points outside the IDML package.`)},Mt=(e,t,s)=>{let i=e+t;return Number.isSafeInteger(i)||f("IDML_ZIP_RANGE",`${s} exceeds JavaScript's safe integer range.`),i},_i=(e,t)=>{if(e.byteLength!==t.byteLength)return!1;for(let s=0;s<e.byteLength;s+=1)if(e[s]!==t[s])return!1;return!0},xi=e=>{try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{return f("IDML_ZIP_PATH","An IDML ZIP entry path is not valid UTF-8.")}},Ii=(e,t)=>{(e.byteLength===0||e.byteLength>4096)&&f("IDML_ZIP_PATH","An IDML ZIP entry has an empty or oversized path."),(t&2048)===0&&e.some(r=>r>127)&&f("IDML_ZIP_PATH","A non-UTF-8 IDML ZIP entry uses an ambiguous non-ASCII path.");let s=xi(e);(s.includes("\0")||s.includes("\\")||s.startsWith("/")||/^[A-Za-z]:/.test(s))&&f("IDML_ZIP_PATH",`Unsafe IDML ZIP entry path ${JSON.stringify(s)}.`);let i=s.endsWith("/"),n=s.split("/");return i&&n.pop(),(n.length===0||n.some(r=>r===""||r==="."||r===".."))&&f("IDML_ZIP_PATH",`Unsafe IDML ZIP entry path ${JSON.stringify(s)}.`),s},bi=e=>{e.byteLength<22&&f("IDML_ZIP_EOCD","The IDML package is too short to contain a ZIP directory.");let t=Math.max(0,e.byteLength-65557);for(let s=e.byteLength-22;s>=t;s-=1){if(e.getUint32(s,!0)!==101010256)continue;let i=e.getUint16(s+20,!0);if(s+22+i===e.byteLength)return s}return f("IDML_ZIP_EOCD","The IDML ZIP end-of-central-directory record is missing or truncated.")},Xe=(e,t)=>{let s=new DataView(e.buffer,e.byteOffset,e.byteLength),i=0;for(;i<e.byteLength;){H(i,4,e.byteLength,`${t} extra-field header`);let n=s.getUint16(i,!0),r=s.getUint16(i+2,!0);H(i+4,r,e.byteLength,`${t} extra field`),n===1&&f("IDML_ZIP64_UNSUPPORTED","ZIP64 IDML packages are not accepted by this bounded renderer."),n===39169&&f("IDML_ZIP_ENCRYPTED","Encrypted IDML ZIP entries are not supported."),i+=4+r}},Ei=e=>e===0?"stored":e===8?"deflate":f("IDML_ZIP_COMPRESSION",`Unsupported IDML ZIP compression method ${e}.`),Di=(e,t,s,i)=>{H(i.localHeaderOffset,30,s,`Local header for ${i.path}`),t.getUint32(i.localHeaderOffset,!0)!==67324752&&f("IDML_ZIP_LOCAL_HEADER",`The local header for ${JSON.stringify(i.path)} is missing.`);let n=t.getUint16(i.localHeaderOffset+6,!0),r=t.getUint16(i.localHeaderOffset+8,!0);(n!==i.flags||r!==i.method)&&f("IDML_ZIP_LOCAL_HEADER",`The local and central headers disagree for ${JSON.stringify(i.path)}.`);let a=t.getUint16(i.localHeaderOffset+26,!0),o=t.getUint16(i.localHeaderOffset+28,!0),c=i.localHeaderOffset+30;H(c,a+o,s,`Local path for ${i.path}`);let d=e.subarray(c,c+a);_i(d,i.rawName)||f("IDML_ZIP_LOCAL_HEADER",`The local path does not match the central path for ${JSON.stringify(i.path)}.`),Xe(e.subarray(c+a,c+a+o),`Local header for ${i.path}`);let h=c+a+o,l=Mt(h,i.compressedSize,`Compressed payload for ${i.path}`);H(h,i.compressedSize,s,`Compressed payload for ${i.path}`);let g=l;if((i.flags&8)!==0){H(l,12,s,`Data descriptor for ${i.path}`);let m=t.getUint32(l,!0)===134695760,_=l+(m?4:0);H(_,12,s,`Data descriptor for ${i.path}`),(t.getUint32(_,!0)!==i.crc32||t.getUint32(_+4,!0)!==i.compressedSize||t.getUint32(_+8,!0)!==i.uncompressedSize)&&f("IDML_ZIP_DATA_DESCRIPTOR",`Invalid data descriptor for ${JSON.stringify(i.path)}.`),g=_+12}else(t.getUint32(i.localHeaderOffset+14,!0)!==i.crc32||t.getUint32(i.localHeaderOffset+18,!0)!==i.compressedSize||t.getUint32(i.localHeaderOffset+22,!0)!==i.uncompressedSize)&&f("IDML_ZIP_LOCAL_HEADER",`The local sizes or CRC disagree for ${JSON.stringify(i.path)}.`);return{dataOffset:h,localEnd:g}},Ye=(e,t)=>{let s=e instanceof Uint8Array?e:new Uint8Array(e);s.byteLength>t.maxFileBytes&&f("IDML_FILE_LIMIT",`IDML source exceeds the ${t.maxFileBytes}-byte safety limit.`);let i=new DataView(s.buffer,s.byteOffset,s.byteLength),n=bi(i),r=i.getUint16(n+4,!0),a=i.getUint16(n+6,!0),o=i.getUint16(n+8,!0),c=i.getUint16(n+10,!0),d=i.getUint32(n+12,!0),h=i.getUint32(n+16,!0);(r!==0||a!==0||o!==c)&&f("IDML_ZIP_MULTIDISK","Multi-disk IDML ZIP packages are not supported."),(c===65535||d===4294967295||h===4294967295)&&f("IDML_ZIP64_UNSUPPORTED","ZIP64 IDML packages are not accepted by this bounded renderer."),(c===0||c>t.maxEntries)&&f("IDML_ENTRY_LIMIT",`IDML ZIP entry count ${c} is outside the configured safety limit.`),H(h,d,n,"IDML central directory"),h+d!==n&&f("IDML_ZIP_DIRECTORY","The IDML central directory has an unsupported gap or trailing record.");let l=new Set,g=[],m=h,_=0,L=0;for(let u=0;u<c;u+=1){H(m,46,n,`IDML central entry ${u}`),i.getUint32(m,!0)!==33639248&&f("IDML_ZIP_DIRECTORY",`IDML central entry ${u} has an invalid signature.`);let A=i.getUint16(m+8,!0),Z=i.getUint16(m+10,!0),K=i.getUint32(m+16,!0),O=i.getUint32(m+20,!0),F=i.getUint32(m+24,!0),W=i.getUint16(m+28,!0),$=i.getUint16(m+30,!0),yt=i.getUint16(m+32,!0),oe=i.getUint16(m+34,!0),ce=i.getUint32(m+42,!0);(A&8257)!==0&&f("IDML_ZIP_ENCRYPTED","Encrypted IDML ZIP entries are not supported."),(O===4294967295||F===4294967295||ce===4294967295||oe===65535)&&f("IDML_ZIP64_UNSUPPORTED","ZIP64 IDML entries are not accepted by this bounded renderer."),oe!==0&&f("IDML_ZIP_MULTIDISK","An IDML entry points to another ZIP disk.");let de=Ei(Z);de==="stored"&&O!==F&&f("IDML_ZIP_SIZE","A stored IDML ZIP entry declares different compressed and uncompressed sizes."),O>t.maxEntryCompressedBytes&&f("IDML_ENTRY_LIMIT","An IDML ZIP entry exceeds the compressed-byte safety limit."),F>t.maxEntryUncompressedBytes&&f("IDML_ENTRY_LIMIT","An IDML ZIP entry exceeds the uncompressed-byte safety limit.");let he=F===0?1:F/Math.max(1,O);he>t.maxCompressionRatio&&f("IDML_ZIP_BOMB",`An IDML ZIP entry declares a ${he.toFixed(1)}:1 compression ratio.`),_=Mt(_,O,"IDML compressed byte total"),L=Mt(L,F,"IDML uncompressed byte total"),L>t.maxTotalUncompressedBytes&&f("IDML_ZIP_BOMB","The IDML ZIP declared uncompressed total exceeds the configured safety limit.");let le=W+$+yt;H(m+46,le,n,`IDML central entry ${u} metadata`);let fe=s.subarray(m+46,m+46+W),dt=Ii(fe,A);l.has(dt)&&f("IDML_ZIP_DUPLICATE",`Duplicate IDML ZIP entry ${JSON.stringify(dt)}.`),l.add(dt),Xe(s.subarray(m+46+W,m+46+W+$),`Central header for ${dt}`);let ue={centralIndex:u,path:dt,compression:de,compressedSize:O,uncompressedSize:F,localHeaderOffset:ce,flags:A,method:Z,crc32:K,rawName:fe},hs=Di(s,i,h,ue);g.push({...ue,...hs}),m+=46+le}m!==n&&f("IDML_ZIP_DIRECTORY","The IDML central directory size does not match its entries.");let N=[...g].sort((u,A)=>u.localHeaderOffset-A.localHeaderOffset);for(let u=1;u<N.length;u+=1)N[u-1].localEnd>N[u].localHeaderOffset&&f("IDML_ZIP_OVERLAP","IDML ZIP local entries overlap.");let I=g.find(u=>u.path==="mimetype"),k=g.find(u=>u.path==="designmap.xml");if(!I)return f("IDML_REQUIRED_ENTRY","IDML package must contain an exact-case mimetype entry.");if(!k)return f("IDML_REQUIRED_ENTRY","IDML package must contain an exact-case designmap.xml entry.");(I.localHeaderOffset!==0||I.compression!=="stored")&&f("IDML_MIMETYPE","IDML mimetype must be the first local entry and must be stored.");let T=s.subarray(I.dataOffset,I.dataOffset+I.uncompressedSize);return new TextDecoder().decode(T)!==gi&&f("IDML_MIMETYPE","IDML mimetype entry has an unexpected value."),k.uncompressedSize===0&&f("IDML_REQUIRED_ENTRY","IDML designmap.xml must not be empty."),{fileBytes:s.byteLength,entryCount:c,compressedBytes:_,uncompressedBytes:L,compressionRatio:L===0?1:L/Math.max(1,_),entries:g.map(u=>({path:u.path,compression:u.compression,compressedSize:u.compressedSize,uncompressedSize:u.uncompressedSize,crc32:u.crc32,localHeaderOffset:u.localHeaderOffset,dataOffset:u.dataOffset}))}},at,yi=()=>{if(at)return at;at=new Uint32Array(256);for(let e=0;e<at.length;e+=1){let t=e;for(let s=0;s<8;s+=1)t=(t&1)!==0?3988292384^t>>>1:t>>>1;at[e]=t>>>0}return at},Ai=(e,t)=>{let s=yi(),i=e;for(let n of t)i=s[(i^n)&255]^i>>>8;return i},We=e=>e.reason instanceof Error?e.reason:new DOMException("IDML ZIP extraction was aborted.","AbortError"),Ve=async(e,t,s,i,n)=>{let r=e instanceof Uint8Array?e:new Uint8Array(e);t.fileBytes!==r.byteLength&&f("IDML_ZIP_RANGE","The IDML ZIP directory belongs to a different source buffer.");let a=t.entries.find(l=>l.path===s)??f("IDML_REQUIRED_ENTRY",`IDML ZIP entry ${JSON.stringify(s)} is missing.`);if(n?.aborted)throw We(n);let o=r.subarray(a.dataOffset,a.dataOffset+a.compressedSize),c=0,d=4294967295,h=l=>{if(n?.aborted)throw We(n);c=Mt(c,l.byteLength,`Expanded payload for ${s}`),c>a.uncompressedSize&&f("IDML_ZIP_SIZE",`IDML ZIP entry ${JSON.stringify(s)} expanded past its declared size.`),d=Ai(d,l),i(l)};if(a.compression==="stored")for(let g=0;g<o.byteLength;g+=65536)h(o.subarray(g,Math.min(o.byteLength,g+65536)));else{typeof DecompressionStream>"u"&&f("IDML_ZIP_DEFLATE_UNAVAILABLE","This browser does not provide the raw DEFLATE decoder required for IDML metadata.");let l;try{l=new DecompressionStream("deflate-raw")}catch{return f("IDML_ZIP_DEFLATE_UNAVAILABLE","This browser does not support raw DEFLATE streams required by IDML metadata.")}let g=Uint8Array.from(o),m=new Blob([g]).stream().pipeThrough(l).getReader();try{for(;;){let _=await m.read();if(_.done)break;h(_.value)}}catch(_){throw await m.cancel(_).catch(()=>{}),_}finally{m.releaseLock()}}c!==a.uncompressedSize&&f("IDML_ZIP_SIZE",`IDML ZIP entry ${JSON.stringify(s)} expanded to ${c} bytes instead of ${a.uncompressedSize}.`),(d^4294967295)>>>0!==a.crc32&&f("IDML_ZIP_CRC",`IDML ZIP entry ${JSON.stringify(s)} failed CRC-32 validation.`)};var wi=72,ze=4,Si=32*1024,mt=class extends Error{constructor(s,i){super(i);this.code=s;this.name="IdmlPageGeometryError"}code},S=(e,t)=>{throw new mt(e,t)},je=e=>e.split(":").pop()||e,Ti=(e,t)=>{let s=(e||"").trim().split(/\s+/).map(Number);if(s.length!==4||s.some(d=>!Number.isFinite(d)))return S("IDML_PAGE_GEOMETRY",`${t} contains a Page without four finite GeometricBounds coordinates.`);let[i,n,r,a]=s,o=Math.abs(a-n),c=Math.abs(r-i);return!(o>0)||!(c>0)?S("IDML_PAGE_GEOMETRY",`${t} contains an empty Page GeometricBounds rectangle.`):{top:i,left:n,bottom:r,right:a,widthPoints:o,heightPoints:c,label:""}},qe=async(e,t,s,i,n)=>{let r=new TextDecoder("utf-8",{fatal:!0}),a=new Je.SaxesParser({xmlns:!1,position:!1,fileName:s});a.on("error",o=>{throw o}),a.on("doctype",()=>S("IDML_PAGE_GEOMETRY_XML",`${s} contains a forbidden DTD or ENTITY declaration.`)),a.on("processinginstruction",o=>{o.target.toLowerCase()==="xml-stylesheet"&&S("IDML_PAGE_GEOMETRY_XML",`${s} contains an external-capable XML stylesheet instruction.`)}),a.on("opentag",i);try{await Ve(e,t,s,o=>a.write(r.decode(o,{stream:!0})),n),a.write(r.decode()).close()}catch(o){throw o instanceof mt||o instanceof DOMException&&o.name==="AbortError"||o instanceof Error&&"code"in o?o:new mt("IDML_PAGE_GEOMETRY_XML",`${s} could not be parsed for page geometry: ${o instanceof Error?o.message:String(o)}`)}},Qe=async(e,t,s,i)=>{let n=[],r=new Set;await qe(e,t,"designmap.xml",c=>{if(je(c.name)!=="Spread")return;let d=c.attributes.src;(!d||!/^Spreads\/[^/]+\.xml$/.test(d))&&S("IDML_PAGE_GEOMETRY","designmap.xml contains an invalid or missing packaged Spread reference."),r.has(d)&&S("IDML_PAGE_GEOMETRY",`designmap.xml references ${JSON.stringify(d)} twice.`),n.length>=s.maxPages&&S("IDML_PAGE_GEOMETRY",`designmap.xml exceeds the ${s.maxPages}-spread page-geometry limit.`),t.entries.some(h=>h.path===d)||S("IDML_REQUIRED_ENTRY",`Referenced IDML spread ${JSON.stringify(d)} is missing.`),r.add(d),n.push(d)},i),n.length===0&&S("IDML_PAGE_GEOMETRY","designmap.xml does not reference any document spreads.");let a=[],o=0;for(let c of n){let d=[];await qe(e,t,c,h=>{if(je(h.name)!=="Page")return;o+=1,o>s.maxPages&&S("IDML_PAGE_GEOMETRY",`IDML spread XML exceeds the ${s.maxPages}-page geometry limit.`);let l=Ti(h.attributes.GeometricBounds,c);l.label=(h.attributes.Name||"").slice(0,512),d.push(l)},i),d.length===0&&S("IDML_PAGE_GEOMETRY",`${c} does not contain any Page geometry.`),a.push(d)}return a},Rt=(e,t,s)=>{let i=e*t;return Number.isSafeInteger(i)?i:S("IDML_RENDER_DIMENSION_LIMIT",`${s} exceeds JavaScript's safe integer range.`)},Ci=e=>e+Math.floor(e/4096)+Math.floor(e/16384)+Math.floor(e/33554432)+13,Ke=(e,t,s)=>{let i=t/wi,n=Math.ceil(e.widthPoints*i),r=Math.ceil(e.heightPoints*i);if(!Number.isSafeInteger(n)||!Number.isSafeInteger(r)||n<=0||r<=0||n>s.maxRenderedDimension||r>s.maxRenderedDimension)return S("IDML_RENDER_DIMENSION_LIMIT",`IDML page projects to ${n} x ${r} pixels at ${t} DPI, exceeding the ${s.maxRenderedDimension}-pixel width/height safety limit.`);let a=Rt(n,r,"IDML rendered pixel count");if(a>s.maxRenderedPixels)return S("IDML_RENDER_PIXEL_LIMIT",`IDML page projects to ${a} pixels (${n} x ${r}) at ${t} DPI, exceeding the ${s.maxRenderedPixels}-pixel safety limit.`);let o=Rt(n,ze,"IDML rendered row byte count"),c=Rt(o+1,r,"IDML PNG scanline byte count"),d=Ci(c),h=Math.max(1,Math.ceil(d/Si)),l=33+d+h*12+12;if(!Number.isSafeInteger(l)||l>s.maxRenderedPngBytes)return S("IDML_RENDER_PNG_LIMIT",`IDML page projects to a worst-case ${l}-byte PNG, exceeding the ${s.maxRenderedPngBytes}-byte safety limit.`);let g=Rt(a,ze,"IDML rendered RGBA byte count"),m=l+d+g*3+(o+1)*2;return!Number.isSafeInteger(m)||m>s.maxRenderWorkingSetBytes?S("IDML_RENDER_WORKING_SET_LIMIT",`IDML page projects to a ${m}-byte render/decode working set, exceeding the ${s.maxRenderWorkingSetBytes}-byte safety limit.`):{width:n,height:r,pixels:a,rgbaBytes:g,estimatedPngBytes:l,projectedWorkingSetBytes:m}};var Pt=Uint8Array.of(137,80,78,71,13,10,26,10),ot=4,Li=1e5,D=class extends Error{code="IDML_PNG_INVALID";constructor(t){super(t),this.name="IdmlPngError"}},se=(e,t,s,i)=>{if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||e<0||t<0||e>s||t>s-e)throw new D(`${i} points outside the Inspector PNG.`)},pt,Ni=()=>{if(pt)return pt;pt=new Uint32Array(256);for(let e=0;e<256;e+=1){let t=e;for(let s=0;s<8;s+=1)t=(t&1)!==0?3988292384^t>>>1:t>>>1;pt[e]=t>>>0}return pt},Mi=(e,t)=>{let s=Ni(),i=4294967295;for(let n of[e,t])for(let r=0;r<n.byteLength;r+=1)i=s[(i^n[r])&255]^i>>>8;return(i^4294967295)>>>0},Ri=e=>String.fromCharCode(...e),Pi=(e,t)=>{if(e.byteLength>t.maxRenderedPngBytes)throw new D(`Inspector PNG exceeds the ${t.maxRenderedPngBytes}-byte safety limit.`);se(0,Pt.byteLength,e.byteLength,"PNG signature");for(let I=0;I<Pt.byteLength;I+=1)if(e[I]!==Pt[I])throw new D("Inspector render did not return a PNG image.");let s=new DataView(e.buffer,e.byteOffset,e.byteLength),i=[],n=0,r=0,a=0,o=!1,c=!1,d=Pt.byteLength,h=0;for(;d<e.byteLength;){if(h+=1,h>Li)throw new D("Inspector PNG contains too many chunks.");se(d,12,e.byteLength,"PNG chunk header");let I=s.getUint32(d,!1),k=e.subarray(d+4,d+8),T=Ri(k),u=d+8;se(u,I+4,e.byteLength,`PNG ${T} chunk`);let A=e.subarray(u,u+I),Z=s.getUint32(u+I,!1);if(Mi(k,A)!==Z)throw new D(`Inspector PNG ${T} CRC is invalid.`);if(h===1&&T!=="IHDR")throw new D("Inspector PNG does not start with IHDR.");if(T==="IHDR"){if(o||I!==13)throw new D("Inspector PNG has an invalid IHDR chunk.");r=s.getUint32(u,!1),a=s.getUint32(u+4,!1);let K=s.getUint8(u+8),O=s.getUint8(u+9),F=s.getUint8(u+10),W=s.getUint8(u+11),$=s.getUint8(u+12);if(r===0||a===0||K!==8||O!==6||F!==0||W!==0||$!==0)throw new D("Inspector PNG must be non-interlaced 8-bit RGBA.");let yt=r*a;if(!Number.isSafeInteger(yt)||yt>t.maxRenderedPixels)throw new D(`Inspector PNG exceeds the ${t.maxRenderedPixels}-pixel safety limit.`);o=!0}else if(T==="IDAT"){if(!o||c)throw new D("Inspector PNG has IDAT chunks in an invalid position.");if(n+=A.byteLength,n>t.maxRenderedPngBytes)throw new D("Inspector PNG IDAT data is oversized.");i.push(A)}else if(T==="IEND"){if(I!==0||c)throw new D("Inspector PNG has an invalid IEND chunk.");if(c=!0,d=u+I+4,d!==e.byteLength)throw new D("Inspector PNG has trailing bytes after IEND.");break}else if((k[0]&32)===0)throw new D(`Inspector PNG contains unsupported critical chunk ${T}.`);d=u+I+4}if(!o||!c||i.length===0)throw new D("Inspector PNG is missing IHDR, IDAT, or IEND.");let l=r*ot,g=(l+1)*a;if(!Number.isSafeInteger(g))throw new D("Inspector PNG dimensions overflow.");let m=l*a,_=e.byteLength+n+m*3+(l+1)*2;if(!Number.isSafeInteger(_)||_>t.maxRenderWorkingSetBytes)throw new D(`Inspector PNG projected working set exceeds the ${t.maxRenderWorkingSetBytes}-byte safety limit.`);let L=new Uint8Array(n),N=0;for(let I of i)L.set(I,N),N+=I.byteLength;return{width:r,height:a,expectedInflatedBytes:g,idat:L}},Ft=e=>e.reason instanceof Error?e.reason:new DOMException("IDML page decoding was aborted.","AbortError"),Fi=async(e,t,s,i)=>{if(typeof DecompressionStream>"u")throw new D("This browser does not provide the deflate decoder required for Inspector PNG output.");if(i?.aborted)throw Ft(i);let n=new DecompressionStream("deflate"),r=n.writable.getWriter(),a=n.readable.getReader(),o=e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Uint8Array.from(e),c=t*ot,d=(c+1)*s,h=new Uint8ClampedArray(c*s),l=0,g=0,m=0,_=0,L=()=>{a.cancel(Ft(i)).catch(()=>{}),r.abort(Ft(i)).catch(()=>{})};i?.addEventListener("abort",L,{once:!0});let N=(async()=>{for(;;){let I=await a.read();if(I.done)break;let k=I.value;for(let T=0;T<k.byteLength;T+=1){if(l>=d)throw await a.cancel("Inspector PNG expands beyond its declared dimensions."),new D("Inspector PNG expands beyond its declared dimensions.");let u=k[T];if(m===0){if(_=u,_>4)throw await a.cancel(`Inspector PNG uses unknown row filter ${_}.`),new D(`Inspector PNG uses unknown row filter ${_}.`)}else{let A=m-1,Z=g*c,K=Z-c,O=A>=ot?h[Z+A-ot]:0,F=g>0?h[K+A]:0,W=g>0&&A>=ot?h[K+A-ot]:0,$=u;_===1?$+=O:_===2?$+=F:_===3?$+=Math.floor((O+F)/2):_===4&&($+=Oi(O,F,W)),h[Z+A]=$&255}l+=1,m+=1,m===c+1&&(g+=1,m=0)}}})();try{await Promise.all([(async()=>{await r.write(o),await r.close()})(),N])}finally{i?.removeEventListener("abort",L)}if(l!==d)throw new D("Inspector PNG decompressed byte count is invalid.");return h},Oi=(e,t,s)=>{let i=e+t-s,n=Math.abs(i-e),r=Math.abs(i-t),a=Math.abs(i-s);return n<=r&&n<=a?e:r<=a?t:s},ts=async(e,t,s)=>{let i=Pi(e,t),n=await Fi(i.idat,i.width,i.height,s);if(s?.aborted)throw Ft(s);return{width:i.width,height:i.height,rgba:n}};var P=class extends Error{code="IDML_TREE_INVALID";constructor(t){super(t),this.name="IdmlTreeError"}},gt=(e,t)=>{if(typeof e!="object"||e===null||Array.isArray(e))throw new P(`${t} must be an object.`);return e},ie=(e,t)=>{if(!Array.isArray(e))throw new P(`${t} must be an array.`);return e},_t=(e,t,s)=>{if(typeof e!="string"||e.length===0||e.length>s)throw new P(`${t} must be a non-empty string no longer than ${s} characters.`);return e},es=(e,t)=>{if(!Number.isSafeInteger(e)||Number(e)<0)throw new P(`${t} must be a non-negative integer.`);return Number(e)},ki=(e,t)=>{let s=gt(e,t);return{kind:_t(s.kind,`${t}.kind`,128),id:_t(s.id,`${t}.id`,2048)}},vi=(e,t)=>{let s=gt(e,t);return{id:ki(s.id,`${t}.id`),label:_t(s.label,`${t}.label`,512)}},ss=(e,t)=>{if(typeof e!="string")throw new P("Inspector tree output must be a JSON string.");if(e.length>t.maxTreeJsonBytes)throw new P(`Inspector tree exceeds the ${t.maxTreeJsonBytes}-byte safety limit.`);if(new TextEncoder().encode(e).byteLength>t.maxTreeJsonBytes)throw new P(`Inspector tree exceeds the ${t.maxTreeJsonBytes}-byte safety limit.`);let i;try{i=JSON.parse(e)}catch{throw new P("Inspector tree is not valid JSON.")}let n=gt(i,"Inspector tree"),r=ie(n.spreads,"Inspector tree spreads");if(r.length>t.maxPages)throw new P("Inspector tree contains more spreads than the configured page limit.");let a=0,o=0,c=r.map((d,h)=>{let l=gt(d,`Spread ${h}`),g=es(l.index,`Spread ${h}.index`),_=ie(l.pages,`Spread ${h}.pages`).map((L,N)=>{if(a>=t.maxPages)throw new P(`Inspector tree exceeds the ${t.maxPages}-page safety limit.`);let I=gt(L,`Spread ${h} page ${N}`),k=ie(I.frames,`Spread ${h} page ${N}.frames`).map((u,A)=>{if(o+=1,o>t.maxFrames)throw new P(`Inspector tree exceeds the ${t.maxFrames}-frame safety limit.`);return vi(u,`Spread ${h} page ${N} frame ${A}`)}),T={index:a,indexInSpread:es(I.index,`Spread ${h} page ${N}.index`),spreadIndex:g,label:_t(I.label,`Spread ${h} page ${N}.label`,512),frames:k};return a+=1,T});return{index:g,label:_t(l.label,`Spread ${h}.label`,512),pages:_}});if(a===0)throw new P("Inspector tree does not contain any pages.");return{spreads:c,pageCount:a,frameCount:o}};var B=class extends Error{constructor(s,i){super(i);this.code=s;this.name="IdmlEngineError"}code},Et,ae,ji=async e=>{if(Et){if(e&&e!==ae)throw new B("IDML_WASM_URL_CHANGED","The IDML Worker cannot switch introspect-wasm binaries after initialization.");return Et}ae=e,Et=(async()=>{let t=await Promise.resolve().then(()=>(cs(),os));if(await t.default(e?{module_or_path:e}:void 0),typeof t.Inspector!="function")throw new B("IDML_ENGINE_API","introspect-wasm did not export Inspector.");return{Inspector:t.Inspector}})();try{return await Et}catch(t){throw Et=void 0,ae=void 0,t}},V=e=>{if(e?.aborted)throw e.reason instanceof Error?e.reason:new DOMException("IDML operation was aborted.","AbortError")},qi=e=>e instanceof Uint8Array?new Uint8Array(e):new Uint8Array(e),kt=class e{constructor(t,s,i,n){this.inspector=t;this.limits=s;this.pageBounds=i;this.opened=n}inspector;limits;pageBounds;opened;destroyed=!1;static async open(t,s,i={}){V(i.signal);let n=qi(t),r=Ye(n,s),a=await Qe(n,r,s,i.signal);V(i.signal);let o=await(i.runtimeLoader??ji)(i.wasmUrl);V(i.signal);let c;try{c=new o.Inspector(n),V(i.signal);let d=ss(c.tree(),s);if(d.spreads.length!==a.length)throw new B("IDML_PAGE_GEOMETRY_MISMATCH","Inspector spread count does not match the preflighted IDML page geometry.");for(let g=0;g<d.spreads.length;g+=1)if(d.spreads[g].pages.length!==a[g].length)throw new B("IDML_PAGE_GEOMETRY_MISMATCH",`Inspector page count for spread ${g} does not match the preflighted IDML page geometry.`);let h=a.flat();if(h.length!==d.pageCount)throw new B("IDML_PAGE_GEOMETRY_MISMATCH","Inspector page count does not match the preflighted IDML page geometry.");let l={engine:"@paged-media/introspect-wasm",engineVersion:"0.63.0",renderBackend:"cpu-tiny-skia",tree:d,archive:{entryCount:r.entryCount,compressedBytes:r.compressedBytes,uncompressedBytes:r.uncompressedBytes,compressionRatio:r.compressionRatio}};return new e(c,s,h,l)}catch(d){throw c?.free(),d}}async renderPage(t,s,i){let n=this.inspector;if(this.destroyed||!n)throw new B("IDML_SESSION_DESTROYED","IDML document session was destroyed.");if(!Number.isSafeInteger(t)||t<0||t>=this.opened.tree.pageCount)throw new B("IDML_PAGE_RANGE",`IDML page index ${t} is outside 0..${this.opened.tree.pageCount-1}.`);if(!Number.isFinite(s)||s<this.limits.minDpi||s>this.limits.maxDpi)throw new B("IDML_DPI_RANGE",`IDML render DPI must be between ${this.limits.minDpi} and ${this.limits.maxDpi}.`);V(i);let r=Ke(this.pageBounds[t],s,this.limits);V(i);let a=n.renderPage(t,s);V(i);let o=await ts(a,this.limits,i);if(V(i),o.width>r.width||o.height>r.height)throw new B("IDML_RENDER_GEOMETRY_MISMATCH",`Inspector rendered ${o.width} x ${o.height} pixels beyond the preflighted ${r.width} x ${r.height} page bounds.`);return{pageIndex:t,dpi:s,...o}}destroy(){this.destroyed||(this.destroyed=!0,this.inspector?.free(),this.inspector=void 0)}};var Dt=self,Q,Ji=e=>e instanceof ut||e instanceof Error&&"code"in e&&typeof e.code=="string"?e.code:"IDML_ENGINE_FAILURE",Qi=async e=>{try{if(e.type==="open"){Q?.destroy(),Q=void 0;let i=await kt.open(e.buffer,e.limits,{wasmUrl:e.wasmUrl});Q=i;let n={id:e.id,ok:!0,type:"open",result:i.opened};Dt.postMessage(n);return}if(e.type==="destroy"){Q?.destroy(),Q=void 0;let i={id:e.id,ok:!0,type:"destroy"};Dt.postMessage(i);return}if(!Q)throw new Error("IDML Worker has no open document.");let t=await Q.renderPage(e.pageIndex,e.dpi),s={id:e.id,ok:!0,type:"renderPage",result:t};Dt.postMessage(s,[t.rgba.buffer])}catch(t){let s=Ji(t),i={id:e.id,ok:!1,error:{name:t instanceof Error?t.name:"Error",code:s,message:t instanceof Error?t.message:String(t),fatal:e.type==="open"||s==="IDML_PNG_INVALID"||t instanceof RangeError}};Dt.postMessage(i)}},ds=Promise.resolve();Dt.addEventListener("message",e=>{ds=ds.catch(()=>{}).then(()=>Qi(e.data))});
|
|
10
10
|
/*! Bundled license information:
|
|
11
11
|
|
|
12
12
|
xmlchars/xml/1.0/ed5.js:
|
|
Binary file
|