@file-viewer/assets-design 3.0.1

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.
Files changed (32) hide show
  1. package/LICENSE +160 -0
  2. package/README.en.md +3 -0
  3. package/README.md +3 -0
  4. package/bin/install.mjs +7 -0
  5. package/file-viewer.asset-pack.json +7 -0
  6. package/package.json +46 -0
  7. package/viewer/file-viewer-asset-pack.json +612 -0
  8. package/viewer/vendor/design/LICENSE.Carlito-OFL-1.1.txt +94 -0
  9. package/viewer/vendor/design/LICENSE.Cousine-OFL-1.1.txt +93 -0
  10. package/viewer/vendor/design/LICENSE.NotoSansSymbols2-OFL-1.1.txt +93 -0
  11. package/viewer/vendor/design/LICENSE.Tinos-OFL-1.1.txt +93 -0
  12. package/viewer/vendor/design/LICENSE.ag-psd-MIT.txt +24 -0
  13. package/viewer/vendor/design/LICENSE.base64-js-MIT.txt +21 -0
  14. package/viewer/vendor/design/LICENSE.fzstd-MIT.txt +21 -0
  15. package/viewer/vendor/design/LICENSE.illustrator-pgf-MIT.txt +9 -0
  16. package/viewer/vendor/design/LICENSE.introspect-wasm-MPL-2.0.txt +373 -0
  17. package/viewer/vendor/design/LICENSE.pako-MIT.txt +21 -0
  18. package/viewer/vendor/design/LICENSE.saxes-ISC.txt +57 -0
  19. package/viewer/vendor/design/LICENSE.stet-Apache-2.0.txt +190 -0
  20. package/viewer/vendor/design/LICENSE.stet-MIT.txt +21 -0
  21. package/viewer/vendor/design/LICENSE.webtoon-psd-MIT.txt +19 -0
  22. package/viewer/vendor/design/LICENSE.xmlchars-MIT.txt +18 -0
  23. package/viewer/vendor/design/LICENSE.xmldom-MIT.txt +8 -0
  24. package/viewer/vendor/design/THIRD_PARTY_NOTICES.md +91 -0
  25. package/viewer/vendor/design/adobe-container.worker.js +44 -0
  26. package/viewer/vendor/design/adobe-resource.worker.js +11 -0
  27. package/viewer/vendor/design/idml.worker.js +38 -0
  28. package/viewer/vendor/design/illustrator-pgf.worker.js +2 -0
  29. package/viewer/vendor/design/paged_introspect_wasm_bg.wasm +0 -0
  30. package/viewer/vendor/design/photoshop.worker.js +11 -0
  31. package/viewer/vendor/design/postscript.worker.js +1 -0
  32. package/viewer/vendor/design/stet_wasm_bg.wasm +0 -0
@@ -0,0 +1,38 @@
1
+ var ls=Object.create;var vt=Object.defineProperty;var fs=Object.getOwnPropertyDescriptor;var us=Object.getOwnPropertyNames;var ms=Object.getPrototypeOf,ps=Object.prototype.hasOwnProperty;var gs=(e,t,s)=>()=>{if(s)throw s[0];try{return e&&(t=e(e=0)),t}catch(i){throw s=[i],i}};var At=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(s){throw t=0,s}},_s=(e,t)=>{for(var s in t)vt(e,s,{get:t[s],enumerable:!0})},xs=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of us(t))!ps.call(e,n)&&n!==s&&vt(e,n,{get:()=>t[n],enumerable:!(i=fs(t,n))||i.enumerable});return e};var Is=(e,t,s)=>(s=e!=null?ls(ms(e)):{},xs(t||!e||!e.__esModule?vt(s,"default",{value:e,enumerable:!0}):s,e));var pe=At(b=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0});b.CHAR=`
2
+ \r -\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}`;b.S=` \r
3
+ `;b.NAME_START_CHAR=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";b.NAME_CHAR="-"+b.NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";b.CHAR_RE=new RegExp("^["+b.CHAR+"]$","u");b.S_RE=new RegExp("^["+b.S+"]+$","u");b.NAME_START_CHAR_RE=new RegExp("^["+b.NAME_START_CHAR+"]$","u");b.NAME_CHAR_RE=new RegExp("^["+b.NAME_CHAR+"]$","u");b.NAME_RE=new RegExp("^["+b.NAME_START_CHAR+"]["+b.NAME_CHAR+"]*$","u");b.NMTOKEN_RE=new RegExp("^["+b.NAME_CHAR+"]+$","u");var Bt=9,$t=10,Ut=13,Ht=32;b.S_LIST=[Ht,$t,Ut,Bt];function bs(e){return e>=Ht&&e<=55295||e===$t||e===Ut||e===Bt||e>=57344&&e<=65533||e>=65536&&e<=1114111}b.isChar=bs;function Es(e){return e===Ht||e===$t||e===Ut||e===Bt}b.isS=Es;function me(e){return e>=65&&e<=90||e>=97&&e<=122||e===58||e===95||e===8204||e===8205||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}b.isNameStartChar=me;function Ds(e){return me(e)||e>=48&&e<=57||e===45||e===46||e===183||e>=768&&e<=879||e>=8255&&e<=8256}b.isNameChar=Ds});var Ee=At(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.CHAR="-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}";x.RESTRICTED_CHAR="-\b\v\f-\x7F-\x84\x86-\x9F";x.S=` \r
4
+ `;x.NAME_START_CHAR=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";x.NAME_CHAR="-"+x.NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";x.CHAR_RE=new RegExp("^["+x.CHAR+"]$","u");x.RESTRICTED_CHAR_RE=new RegExp("^["+x.RESTRICTED_CHAR+"]$","u");x.S_RE=new RegExp("^["+x.S+"]+$","u");x.NAME_START_CHAR_RE=new RegExp("^["+x.NAME_START_CHAR+"]$","u");x.NAME_CHAR_RE=new RegExp("^["+x.NAME_CHAR+"]$","u");x.NAME_RE=new RegExp("^["+x.NAME_START_CHAR+"]["+x.NAME_CHAR+"]*$","u");x.NMTOKEN_RE=new RegExp("^["+x.NAME_CHAR+"]+$","u");var ge=9,_e=10,xe=13,Ie=32;x.S_LIST=[Ie,_e,xe,ge];function ys(e){return e>=1&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111}x.isChar=ys;function As(e){return e>=1&&e<=8||e===11||e===12||e>=14&&e<=31||e>=127&&e<=132||e>=134&&e<=159}x.isRestrictedChar=As;function ws(e){return e===9||e===10||e===13||e>31&&e<127||e===133||e>159&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111}x.isCharAndNotRestricted=ws;function Ss(e){return e===Ie||e===_e||e===xe||e===ge}x.isS=Ss;function be(e){return e>=65&&e<=90||e>=97&&e<=122||e===58||e===95||e===8204||e===8205||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}x.isNameStartChar=be;function Ts(e){return be(e)||e>=48&&e<=57||e===45||e===46||e===183||e>=768&&e<=879||e>=8255&&e<=8256}x.isNameChar=Ts});var ye=At(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.NC_NAME_START_CHAR="A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";M.NC_NAME_CHAR="-"+M.NC_NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";M.NC_NAME_START_CHAR_RE=new RegExp("^["+M.NC_NAME_START_CHAR+"]$","u");M.NC_NAME_CHAR_RE=new RegExp("^["+M.NC_NAME_CHAR+"]$","u");M.NC_NAME_RE=new RegExp("^["+M.NC_NAME_START_CHAR+"]["+M.NC_NAME_CHAR+"]*$","u");function De(e){return e>=65&&e<=90||e===95||e>=97&&e<=122||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}M.isNCNameStartChar=De;function Cs(e){return De(e)||e===45||e===46||e>=48&&e<=57||e===183||e>=768&&e<=879||e>=8255&&e<=8256}M.isNCNameChar=Cs});var Ze=At(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.SaxesParser=nt.EVENTS=void 0;var rt=pe(),Ls=Ee(),ee=ye(),R=rt.isS,Ns=rt.isChar,ht=rt.isNameStartChar,Ae=rt.isNameChar,Be=rt.S_LIST,Ms=rt.NAME_RE,Rs=Ls.isChar,Ps=ee.isNCNameStartChar,Fs=ee.isNCNameChar,Os=ee.NC_NAME_RE,Nt="http://www.w3.org/XML/1998/namespace",it="http://www.w3.org/2000/xmlns/",ks={__proto__:null,xml:Nt,xmlns:it},vs={__proto__:null,amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},E=-1,U=-2,we=0,Bs=1,Gt=2,$s=3,tt=4,Us=5,Hs=6,Gs=7,Zt=8,Zs=9,Ws=10,Xs=11,Ys=12,C=13,wt=14,Wt=15,Vs=16,Xt=17,zs=18,js=19,Yt=20,qs=21,Js=22,Qs=23,Se=24,Vt=25,St=26,Te=27,Ks=28,ti=29,Ce=30,ei=31,si=32,z=33,ii=34,zt=35,lt=36,jt=37,ni=38,Le=39,Ne=40,ri=41,Me=42,ai=43,oi=44,qt=9,v=10,Jt=13,Re=32,Pe=33,$e=34,ft=38,Ue=39,Tt=45,Ct=47,ci=59,X=60,et=61,y=62,w=63,He=91,st=93,Fe=133,Oe=8232,Lt=e=>e===$e||e===Ue,Ge=[$e,Ue],di=[...Ge,He,y],hi=[...Ge,X,st],li=[et,w,...Be],fi=[...Be,y,ft,X];function Kt(e,t,s){switch(t){case"xml":s!==Nt&&e.fail(`xml prefix must be bound to ${Nt}.`);break;case"xmlns":s!==it&&e.fail(`xmlns prefix must be bound to ${it}.`);break;default:}switch(s){case it:e.fail(t===""?`the default namespace may not be set to ${s}.`:`may not assign a prefix (even "xmlns") to the URI ${it}.`);break;case Nt:switch(t){case"xml":break;case"":e.fail(`the default namespace may not be set to ${s}.`);break;default:e.fail("may not assign the xml namespace to another prefix.")}break;default:}}function ui(e,t){for(let s of Object.keys(t))Kt(e,s,t[s])}var mi=e=>Os.test(e),pi=e=>Ms.test(e),j=0,ke=1,Qt=2;nt.EVENTS=["xmldecl","text","processinginstruction","doctype","comment","opentagstart","attribute","opentag","closetag","cdata","error","end","ready"];var ve={xmldecl:"xmldeclHandler",text:"textHandler",processinginstruction:"piHandler",doctype:"doctypeHandler",comment:"commentHandler",opentagstart:"openTagStartHandler",attribute:"attributeHandler",opentag:"openTagHandler",closetag:"closeTagHandler",cdata:"cdataHandler",error:"errorHandler",end:"endHandler",ready:"readyHandler"},te=class{constructor(t){this.opt=t??{},this.fragmentOpt=!!this.opt.fragment;let s=this.xmlnsOpt=!!this.opt.xmlns;if(this.trackPosition=this.opt.position!==!1,this.fileName=this.opt.fileName,s){this.nameStartCheck=Ps,this.nameCheck=Fs,this.isName=mi,this.processAttribs=this.processAttribsNS,this.pushAttrib=this.pushAttribNS,this.ns=Object.assign({__proto__:null},ks);let i=this.opt.additionalNamespaces;i!=null&&(ui(this,i),Object.assign(this.ns,i))}else this.nameStartCheck=ht,this.nameCheck=Ae,this.isName=pi,this.processAttribs=this.processAttribsPlain,this.pushAttrib=this.pushAttribPlain;this.stateTable=[this.sBegin,this.sBeginWhitespace,this.sDoctype,this.sDoctypeQuote,this.sDTD,this.sDTDQuoted,this.sDTDOpenWaka,this.sDTDOpenWakaBang,this.sDTDComment,this.sDTDCommentEnding,this.sDTDCommentEnded,this.sDTDPI,this.sDTDPIEnding,this.sText,this.sEntity,this.sOpenWaka,this.sOpenWakaBang,this.sComment,this.sCommentEnding,this.sCommentEnded,this.sCData,this.sCDataEnding,this.sCDataEnding2,this.sPIFirstChar,this.sPIRest,this.sPIBody,this.sPIEnding,this.sXMLDeclNameStart,this.sXMLDeclName,this.sXMLDeclEq,this.sXMLDeclValueStart,this.sXMLDeclValue,this.sXMLDeclSeparator,this.sXMLDeclEnding,this.sOpenTag,this.sOpenTagSlash,this.sAttrib,this.sAttribName,this.sAttribNameSawWhite,this.sAttribValue,this.sAttribValueQuoted,this.sAttribValueClosed,this.sAttribValueUnquoted,this.sCloseTag,this.sCloseTagSawWhite],this._init()}get closed(){return this._closed}_init(){var t;this.openWakaBang="",this.text="",this.name="",this.piTarget="",this.entity="",this.q=null,this.tags=[],this.tag=null,this.topNS=null,this.chunk="",this.chunkPosition=0,this.i=0,this.prevI=0,this.carriedFromPrevious=void 0,this.forbiddenState=j,this.attribList=[];let{fragmentOpt:s}=this;this.state=s?C:we,this.reportedTextBeforeRoot=this.reportedTextAfterRoot=this.closedRoot=this.sawRoot=s,this.xmlDeclPossible=!s,this.xmlDeclExpects=["version"],this.entityReturnState=void 0;let{defaultXMLVersion:i}=this.opt;if(i===void 0){if(this.opt.forceXMLVersion===!0)throw new Error("forceXMLVersion set but defaultXMLVersion is not set");i="1.0"}this.setXMLVersion(i),this.positionAtNewLine=0,this.doctype=!1,this._closed=!1,this.xmlDecl={version:void 0,encoding:void 0,standalone:void 0},this.line=1,this.column=0,this.ENTITIES=Object.create(vs),(t=this.readyHandler)===null||t===void 0||t.call(this)}get position(){return this.chunkPosition+this.i}get columnIndex(){return this.position-this.positionAtNewLine}on(t,s){this[ve[t]]=s}off(t){this[ve[t]]=void 0}makeError(t){var s;let i=(s=this.fileName)!==null&&s!==void 0?s:"";return this.trackPosition&&(i.length>0&&(i+=":"),i+=`${this.line}:${this.column}`),i.length>0&&(i+=": "),new Error(i+t)}fail(t){let s=this.makeError(t),i=this.errorHandler;if(i===void 0)throw s;return i(s),this}write(t){if(this.closed)return this.fail("cannot write after close; assign an onready handler.");let s=!1;t===null?(s=!0,t=""):typeof t=="object"&&(t=t.toString()),this.carriedFromPrevious!==void 0&&(t=`${this.carriedFromPrevious}${t}`,this.carriedFromPrevious=void 0);let i=t.length,n=t.charCodeAt(i-1);!s&&(n===Jt||n>=55296&&n<=56319)&&(this.carriedFromPrevious=t[i-1],i--,t=t.slice(0,i));let{stateTable:r}=this;for(this.chunk=t,this.i=0;this.i<i;)r[this.state].call(this);return this.chunkPosition+=i,s?this.end():this}close(){return this.write(null)}getCode10(){let{chunk:t,i:s}=this;if(this.prevI=s,this.i=s+1,s>=t.length)return E;let i=t.charCodeAt(s);if(this.column++,i<55296){if(i>=Re||i===qt)return i;switch(i){case v:return this.line++,this.column=0,this.positionAtNewLine=this.position,v;case Jt:return t.charCodeAt(s+1)===v&&(this.i=s+2),this.line++,this.column=0,this.positionAtNewLine=this.position,U;default:return this.fail("disallowed character."),i}}if(i>56319)return i>=57344&&i<=65533||this.fail("disallowed character."),i;let n=65536+(i-55296)*1024+(t.charCodeAt(s+1)-56320);return this.i=s+2,n>1114111&&this.fail("disallowed character."),n}getCode11(){let{chunk:t,i:s}=this;if(this.prevI=s,this.i=s+1,s>=t.length)return E;let i=t.charCodeAt(s);if(this.column++,i<55296){if(i>31&&i<127||i>159&&i!==Oe||i===qt)return i;switch(i){case v:return this.line++,this.column=0,this.positionAtNewLine=this.position,v;case Jt:{let r=t.charCodeAt(s+1);(r===v||r===Fe)&&(this.i=s+2)}case Fe:case Oe:return this.line++,this.column=0,this.positionAtNewLine=this.position,U;default:return this.fail("disallowed character."),i}}if(i>56319)return i>=57344&&i<=65533||this.fail("disallowed character."),i;let n=65536+(i-55296)*1024+(t.charCodeAt(s+1)-56320);return this.i=s+2,n>1114111&&this.fail("disallowed character."),n}getCodeNorm(){let t=this.getCode();return t===U?v:t}unget(){this.i=this.prevI,this.column--}captureTo(t){let{i:s}=this,{chunk:i}=this;for(;;){let n=this.getCode(),r=n===U,a=r?v:n;if(a===E||t.includes(a))return this.text+=i.slice(s,this.prevI),a;r&&(this.text+=`${i.slice(s,this.prevI)}
5
+ `,s=this.i)}}captureToChar(t){let{i:s}=this,{chunk:i}=this;for(;;){let n=this.getCode();switch(n){case U:this.text+=`${i.slice(s,this.prevI)}
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
+ `,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
+ `),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))});
10
+ /*! Bundled license information:
11
+
12
+ xmlchars/xml/1.0/ed5.js:
13
+ (**
14
+ * Character classes and associated utilities for the 5th edition of XML 1.0.
15
+ *
16
+ * @author Louis-Dominique Dubeau
17
+ * @license MIT
18
+ * @copyright Louis-Dominique Dubeau
19
+ *)
20
+
21
+ xmlchars/xml/1.1/ed2.js:
22
+ (**
23
+ * Character classes and associated utilities for the 2nd edition of XML 1.1.
24
+ *
25
+ * @author Louis-Dominique Dubeau
26
+ * @license MIT
27
+ * @copyright Louis-Dominique Dubeau
28
+ *)
29
+
30
+ xmlchars/xmlns/1.0/ed3.js:
31
+ (**
32
+ * Character class utilities for XML NS 1.0 edition 3.
33
+ *
34
+ * @author Louis-Dominique Dubeau
35
+ * @license MIT
36
+ * @copyright Louis-Dominique Dubeau
37
+ *)
38
+ */
@@ -0,0 +1,2 @@
1
+ var ue=(n,t,e)=>()=>{if(e)throw e[0];try{return n&&(t=n(n=0)),t}catch(r){throw e=[r],r}};function E(n,t,e,r,i={}){return{code:n,severity:t,stage:e,message:r,...i}}var l,G=ue(()=>{l=class extends Error{code;stage;diagnostics;constructor(t,e,r,i=[]){super(r),this.name="IllustratorError",this.code=t,this.stage=e,this.diagnostics=i}}});function j(n){let t=[];for(let e=0;e<n.length;e+=Pt){let r=Math.min(n.length,e+Pt),i=new Array(r-e);for(let s=e;s<r;s++)i[s-e]=n[s];t.push(String.fromCharCode(...i))}return t.join("")}function J(n){let t=new Uint8Array(n.length);for(let e=0;e<n.length;e++){let r=n.charCodeAt(e);if(r>255)throw new l("AI_ENCODING_NOT_LATIN1","lex",`Character U+${r.toString(16).toUpperCase()} at offset ${e} is not byte-preserving Latin-1.`);t[e]=r}return t}async function Te(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(await n.arrayBuffer())}function Pe(n,t=Number.MAX_SAFE_INTEGER){let e=0;for(let s of n)if(e+=s.byteLength,!Number.isSafeInteger(e)||e>t)throw new l("AI_CONCAT_LIMIT","decode",`Combined data exceeds the ${t}-byte limit.`);let r=new Uint8Array(e),i=0;for(let s of n)r.set(s,i),i+=s.byteLength;return r}function Nt(n){let t="";for(let e of n)t+=e.toString(16).padStart(2,"0");return t}function Rt(n){let t=n.replace(/\s+/gu,"");if(!/^[0-9a-f]*$/iu.test(t))throw new l("AI_HEX_INVALID","decode","Hex data contains a non-hexadecimal character.");let e=t.length%2===0?t:`${t}0`,r=new Uint8Array(e.length/2);for(let i=0;i<e.length;i+=2)r[i/2]=Number.parseInt(e.slice(i,i+2),16);return r}async function Ne(n){if(globalThis.crypto?.subtle!==void 0){let t=n.byteOffset===0&&n.byteLength===n.buffer.byteLength?n.buffer:n.slice().buffer;return Nt(new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256",t)))}return Nt(fr(n))}function fr(n){let t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),r=BigInt(n.byteLength)*8n,i=Math.ceil((n.byteLength+9)/64)*64,s=new Uint8Array(i);s.set(n),s[n.length]=128;let o=new DataView(s.buffer);o.setUint32(i-8,Number(r>>32n&0xffffffffn),!1),o.setUint32(i-4,Number(r&0xffffffffn),!1);let d=new Uint32Array(64),c=(h,f)=>h>>>f|h<<32-f;for(let h=0;h<s.length;h+=64){for(let S=0;S<16;S++)d[S]=o.getUint32(h+S*4,!1);for(let S=16;S<64;S++){let T=d[S-15],k=d[S-2],A=c(T,7)^c(T,18)^T>>>3,y=c(k,17)^c(k,19)^k>>>10;d[S]=d[S-16]+A+d[S-7]+y>>>0}let[f,m,I,g,p,b,x,D]=t;for(let S=0;S<64;S++){let T=c(p,6)^c(p,11)^c(p,25),k=p&b^~p&x,A=D+T+k+e[S]+d[S]>>>0,y=c(f,2)^c(f,13)^c(f,22),v=f&m^f&I^m&I,P=y+v>>>0;D=x,x=b,b=p,p=g+A>>>0,g=I,I=m,m=f,f=A+P>>>0}t[0]=t[0]+f>>>0,t[1]=t[1]+m>>>0,t[2]=t[2]+I>>>0,t[3]=t[3]+g>>>0,t[4]=t[4]+p>>>0,t[5]=t[5]+b>>>0,t[6]=t[6]+x>>>0,t[7]=t[7]+D>>>0}let a=new Uint8Array(32),u=new DataView(a.buffer);for(let h=0;h<8;h++)u.setUint32(h*4,t[h],!1);return a}function ze(n){if(n?.aborted===!0)throw new l("AI_ABORTED","parse","The Illustrator operation was aborted.")}function Xe(n,t){return{a:n.a*t.a+n.c*t.b,b:n.b*t.a+n.d*t.b,c:n.a*t.c+n.c*t.d,d:n.b*t.c+n.d*t.d,e:n.a*t.e+n.c*t.f+n.e,f:n.b*t.e+n.d*t.f+n.f}}function H(n,t){return{x:n.a*t.x+n.c*t.y+n.e,y:n.b*t.x+n.d*t.y+n.f}}function ge(n,t){return n===void 0?t:t===void 0?n:{left:Math.min(n.left,t.left),bottom:Math.min(n.bottom,t.bottom),right:Math.max(n.right,t.right),top:Math.max(n.top,t.top)}}function Ce(n){if(n.length===0)return;let t=n[0].x,e=t,r=n[0].y,i=r;for(let s=1;s<n.length;s++){let o=n[s];t=Math.min(t,o.x),e=Math.max(e,o.x),r=Math.min(r,o.y),i=Math.max(i,o.y)}return{left:t,bottom:r,right:e,top:i}}function ne(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function Me(n,t="transparent"){return n===void 0?t:/^(?:#[0-9a-f]{3,8}|rgba?\([\d.,%\s+-]+\)|hsla?\([\d.,%\s+-]+\)|[a-z]+)$/iu.test(n)?n:t}function ie(n,t){return`${n}-${t.toString(36)}`}function _(n,t=0,e=1){return Math.max(t,Math.min(e,n))}var Pt,B,Se,Re,K=ue(()=>{G();Pt=32768;B=class{signal;started=performance.now();counters=new Map;deadline;constructor(t,e){this.signal=t,this.deadline=this.started+Math.max(1,e)}checkpoint(t="parse"){if(this.signal?.aborted===!0)throw new l("AI_ABORTED",t,"The Illustrator operation was aborted.");if(performance.now()>this.deadline)throw new l("AI_TIMEOUT",t,"The Illustrator operation exceeded its time budget.")}consume(t,e,r,i){if(!Number.isFinite(e)||e<0)throw new l("AI_BUDGET_INVALID",i,`Invalid ${t} budget amount.`);let s=(this.counters.get(t)??0)+e;if(s>r)throw new l(`AI_LIMIT_${t.toUpperCase()}`,i,`${t} exceeds the configured limit of ${r}.`);return this.counters.set(t,s),(s&1023)===0&&this.checkpoint(i),s}},Se=class{source;lineStarts=[0];constructor(t){this.source=t;for(let e=0;e<t.length;e++){let r=t.charCodeAt(e);r===13?(t.charCodeAt(e+1)===10&&e++,this.lineStarts.push(e+1)):r===10&&this.lineStarts.push(e+1)}}position(t){let e=Math.max(0,Math.min(this.source.length,t)),r=0,i=this.lineStarts.length;for(;r+1<i;){let s=r+i>>>1;this.lineStarts[s]<=e?r=s:i=s}return{offset:e,line:r+1,column:e-this.lineStarts[r]+1}}span(t,e){return{start:this.position(t),end:this.position(e)}}},Re=Object.freeze({a:1,b:0,c:0,d:1,e:0,f:0})});async function Ct(n,t,e,r){if(ze(r),typeof DecompressionStream>"u")throw new l("AI_CODEC_UNAVAILABLE","decode",`${n} decompression is unavailable in this runtime.`);let i;try{i=new DecompressionStream(n)}catch(u){throw new l("AI_CODEC_UNAVAILABLE","decode",`${n} decompression is unavailable: ${u instanceof Error?u.message:String(u)}`)}let s=t.slice(),d=new Response(new Blob([s]).stream().pipeThrough(i)).body?.getReader();if(d===void 0)throw new l("AI_CODEC_FAILED","decode","Decompression stream produced no readable body.");let c=[],a=0;try{for(;;){ze(r);let u=await d.read();if(u.done)break;if(a+=u.value.byteLength,a>e)throw await d.cancel("output-limit"),new l("AI_DECODE_OUTPUT_LIMIT","decode",`Decompressed data exceeds the ${e}-byte limit.`);c.push(u.value)}}catch(u){throw u instanceof l?u:new l("AI_CODEC_FAILED","decode",`${n} decompression failed: ${u instanceof Error?u.message:String(u)}`)}finally{d.releaseLock()}return Pe(c,e)}function Oe(n){return{...hr,...n===void 0?{}:{zstd:n}}}function pr(n,t){let e=new Uint8Array(Math.min(t,Math.ceil(n.byteLength/2))),r=-1,i=0;for(let s of n){if(s===62)break;if(s===0||s===9||s===10||s===12||s===13||s===32)continue;let o=s>=48&&s<=57?s-48:s>=65&&s<=70?s-55:s>=97&&s<=102?s-87:-1;if(o<0)throw new l("AI_ASCIIHEX_INVALID","decode",`Invalid ASCIIHex byte 0x${s.toString(16)}.`);if(r<0)r=o;else{if(i>=t)throw new l("AI_DECODE_OUTPUT_LIMIT","decode",`ASCIIHex output exceeds ${t} bytes.`);e[i++]=r<<4|o,r=-1}}if(r>=0){if(i>=t)throw new l("AI_DECODE_OUTPUT_LIMIT","decode",`ASCIIHex output exceeds ${t} bytes.`);e[i++]=r<<4}return e.slice(0,i)}function He(n,t){let e=[],r=[],i=!1,s=!1,o=(d=5)=>{for(;r.length<5;)r.push(84);let c=0;for(let h of r)c=c*85+h;let a=[c>>>24&255,c>>>16&255,c>>>8&255,c&255],u=d-1;if(e.length+u>t)throw new l("AI_DECODE_OUTPUT_LIMIT","decode",`ASCII85 output exceeds ${t} bytes.`);for(let h=0;h<u;h++)e.push(a[h]);r=[]};for(let d=0;d<n.length;d++){let c=n[d];if(!i&&c===60&&n[d+1]===126){i=!0,d++;continue}if(c===126&&n[d+1]===62){if(r.length===1)throw new l("AI_ASCII85_INVALID","decode","ASCII85 has a one-digit final tuple.");r.length>1&&o(r.length),s=!0;break}if(!(c===0||c===9||c===10||c===12||c===13||c===32)){if(i=!0,c===122){if(r.length!==0)throw new l("AI_ASCII85_INVALID","decode","ASCII85 z abbreviation appears inside a tuple.");if(e.length+4>t)throw new l("AI_DECODE_OUTPUT_LIMIT","decode",`ASCII85 output exceeds ${t} bytes.`);e.push(0,0,0,0);continue}if(c<33||c>117)throw new l("AI_ASCII85_INVALID","decode",`Invalid ASCII85 byte 0x${c.toString(16)}.`);r.push(c-33),r.length===5&&o()}}if(!s&&r.length>0){if(r.length===1)throw new l("AI_ASCII85_INVALID","decode","ASCII85 has a one-digit final tuple.");o(r.length)}return Uint8Array.from(e)}function mr(n,t){let e=[],r=0;for(;r<n.length;){let i=n[r++];if(i===128)break;if(i<=127){let s=i+1;if(r+s>n.length)throw new l("AI_RUNLENGTH_TRUNCATED","decode","RunLength literal segment is truncated.");if(e.length+s>t)throw new l("AI_DECODE_OUTPUT_LIMIT","decode",`RunLength output exceeds ${t} bytes.`);for(let o=0;o<s;o++)e.push(n[r+o]);r+=s}else{if(r>=n.length)throw new l("AI_RUNLENGTH_TRUNCATED","decode","RunLength repeated segment is truncated.");let s=257-i;if(e.length+s>t)throw new l("AI_DECODE_OUTPUT_LIMIT","decode",`RunLength output exceeds ${t} bytes.`);let o=n[r++];for(let d=0;d<s;d++)e.push(o)}}return Uint8Array.from(e)}function gr(n,t,e){let r=t.predictor??1;if(r===1)return n;let i=t.colors??1,s=t.bitsPerComponent??8,o=t.columns??1;if(![1,2,4,8,16].includes(s)||i<1||o<1)throw new l("AI_PDF_PREDICTOR_INVALID","decode","Invalid PDF predictor parameters.");let d=Math.max(1,Math.ceil(i*s/8)),c=Math.ceil(i*o*s/8);if(r===2){if(n.length>e)throw new l("AI_DECODE_OUTPUT_LIMIT","decode",`Predictor output exceeds ${e} bytes.`);let I=n.slice();for(let g=0;g<I.length;g+=c)for(let p=d;p<Math.min(c,I.length-g);p++)I[g+p]=I[g+p]+I[g+p-d]&255;return I}if(r<10||r>15)throw new l("AI_PDF_PREDICTOR_UNSUPPORTED","decode",`Unsupported PDF predictor ${r}.`);let a=c+1;if(n.length%a!==0)throw new l("AI_PDF_PREDICTOR_TRUNCATED","decode","PNG predictor data has a truncated row.");let u=n.length/a,h=u*c;if(h>e)throw new l("AI_DECODE_OUTPUT_LIMIT","decode",`Predictor output exceeds ${e} bytes.`);let f=new Uint8Array(h),m=(I,g,p)=>{let b=I+g-p,x=Math.abs(b-I),D=Math.abs(b-g),S=Math.abs(b-p);return x<=D&&x<=S?I:D<=S?g:p};for(let I=0;I<u;I++){let g=n[I*a],p=I*a+1,b=I*c;for(let x=0;x<c;x++){let D=n[p+x],S=x>=d?f[b+x-d]:0,T=I>0?f[b+x-c]:0,k=I>0&&x>=d?f[b+x-c-d]:0,A=g===0?D:g===1?D+S:g===2?D+T:g===3?D+Math.floor((S+T)/2):g===4?D+m(S,T,k):Number.NaN;if(!Number.isFinite(A))throw new l("AI_PDF_PREDICTOR_INVALID","decode",`Unknown PNG predictor row filter ${g}.`);f[b+x]=A&255}}return f}async function Ke(n,t,e,r,i){let s=new B(i,3e4),o=n;for(let d of t){s.checkpoint("decode");let c=d.name.replace(/^\//u,"");switch(c){case"ASCIIHexDecode":case"AHx":o=pr(o,r);break;case"ASCII85Decode":case"A85":o=He(o,r);break;case"FlateDecode":case"Fl":{o=await e.inflate(o,r,i),o=gr(o,d.parameters??{},r);break}case"RunLengthDecode":case"RL":o=mr(o,r);break;default:throw new l("AI_PDF_FILTER_UNSUPPORTED","decode",`Unsupported PDF stream filter /${c}.`)}if(o.byteLength>r)throw new l("AI_DECODE_OUTPUT_LIMIT","decode",`Decoded stream exceeds ${r} bytes.`)}return o}var hr,Ie=ue(()=>{G();K();hr={inflate:(n,t,e)=>Ct("deflate",n,t,e),inflateRaw:(n,t,e)=>Ct("deflate-raw",n,t,e)}});function V(n){let t={...Ir};if(n===void 0)return t;for(let e of Object.keys(t)){let r=n[e];if(r!==void 0){if(!Number.isSafeInteger(r)||r<=0)throw new RangeError(`${e} must be a positive safe integer.`);t[e]=r}}return t}var Ir,Z=ue(()=>{Ir=Object.freeze({maxFileBytes:134217728,maxDecodedBytes:134217728,maxPdfObjects:25e4,maxPrivateBlocks:1e4,maxTokens:1e6,maxStatements:25e4,maxNodes:25e4,maxPathPoints:1e6,maxNesting:256,maxStringBytes:8388608,maxSingleRasterPixels:64e6,maxTotalRasterBytes:268435456,maxWorkerTimeMs:3e4,maxRenderPixels:32e6,maxCacheBytes:134217728})});function Nr(n){return typeof n!="string"?j(n):(J(n),n)}function at(n){return n===0||n===9||n===10||n===12||n===13||n===32}function Vt(n){return n===void 0||at(n)||n===40||n===41||n===60||n===62||n===91||n===93||n===123||n===125||n===47||n===37}function Rr(n){let t=[];for(let e=1;e<n.length;e++)n.charCodeAt(e)===35&&/^[0-9a-f]{2}$/iu.test(n.slice(e+1,e+3))?(t.push(Number.parseInt(n.slice(e+1,e+3),16)),e+=2):t.push(n.charCodeAt(e)&255);return j(Uint8Array.from(t))}function Cr(n){let t=[];for(let e=1;e<n.length-1;e++){let r=n.charCodeAt(e);if(r!==92){t.push(r&255);continue}if(++e>=n.length-1)break;if(r=n.charCodeAt(e),r===110)t.push(10);else if(r===114)t.push(13);else if(r===116)t.push(9);else if(r===98)t.push(8);else if(r===102)t.push(12);else if(r!==10)if(r===13)n.charCodeAt(e+1)===10&&e++;else if(r>=48&&r<=55){let i=r-48,s=1;for(;s<3&&e+1<n.length-1;){let o=n.charCodeAt(e+1);if(o<48||o>55)break;i=i*8+o-48,e++,s++}t.push(i&255)}else t.push(r&255)}return j(Uint8Array.from(t))}function Mr(n){return/^[+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?$/u.test(n)?{kind:"number",value:Number(n)}:n==="true"?{kind:"boolean",value:!0}:n==="false"?{kind:"boolean",value:!1}:n==="null"?{kind:"null",value:null}:{kind:"word",value:n}}function Or(n,t,e,r="%%EndData"){let i=Math.min(n.length,t+e+1),s=t;for(;s<i;){let o=n.indexOf(r,s);if(o<0||o>=i)return-1;let d=n.charCodeAt(o+r.length);if(d===10||d===13||Number.isNaN(d))return o;s=o+1}return-1}function Wt(n,t={}){let e=Nr(n),r=V(t.limits);if(e.length>r.maxDecodedBytes)throw new l("AI_SOURCE_LIMIT","lex",`Illustrator source exceeds ${r.maxDecodedBytes} bytes.`);let i=new B(t.signal,Math.min(t.timeoutMs??r.maxWorkerTimeMs,r.maxWorkerTimeMs)),s=new Se(e),o=[],d=[],c=(f,m,I,g)=>{i.consume("tokens",1,r.maxTokens,"lex"),o.push({kind:f,raw:e.slice(m,I),span:s.span(m,I),...g===void 0?{}:{value:g}})},a=0,u=0;for(;a<e.length;){if(i.checkpoint("lex"),u>0){let b=Math.min(e.length,a+u);b-a!==u&&d.push(E("AI_BINARY_TRUNCATED","error","lex",`Declared binary resource has ${u} bytes, but only ${b-a} remain.`,{sourceSpan:s.span(a,b)})),c("binary",a,b,J(e.slice(a,b))),a=b,u=0;continue}let f=e.charCodeAt(a);if(at(f)){let b=a++;for(;a<e.length&&at(e.charCodeAt(a));)a++;c("whitespace",b,a);continue}if(f===37){let b=a++;for(;a<e.length&&e.charCodeAt(a)!==10&&e.charCodeAt(a)!==13;)a++;let x=e.slice(b,a),D=/^%_(?!%)/u.test(x)||/^%AI\d*_/u.test(x);c(D?"pseudo-comment":"comment",b,a,x.slice(1));let S=/^%%BeginBinary\s*:\s*(\d+)/iu.exec(x),T=/^(%_)?%%BeginData\s*:\s*(\d+)(?:\s+.*)?$/iu.exec(x),k=S??T;if(k!==null){let A=Number(T?.[2]??k[1]);if(!Number.isSafeInteger(A)||A<0||A>r.maxStringBytes)throw new l("AI_BINARY_LIMIT","lex",`Binary resource declaration exceeds ${r.maxStringBytes} bytes.`);let y=a;if(e.charCodeAt(y)===13&&y++,e.charCodeAt(y)===10&&y++,y>a&&(c("whitespace",a,y),a=y),T!==null){let v=Or(e,a,r.maxStringBytes,T[1]==="%_"?"%_%%EndData":"%%EndData");if(v<0){let P=Math.min(e.length,a+r.maxStringBytes);d.push(E("AI_BINARY_ENDDATA_MISSING","error","lex","%%BeginData has no %%EndData terminator within the binary resource limit.",{sourceSpan:s.span(b,P)})),c("binary",a,P,J(e.slice(a,P))),a=P}else c("binary",a,v,J(e.slice(a,v))),a=v}else u=A}continue}if(f===40){let b=a++,x=1;for(;a<e.length&&x>0;){let S=e.charCodeAt(a++);if(S===92?a<e.length&&(e.charCodeAt(a)===13&&e.charCodeAt(a+1)===10?a+=2:a++):S===40?x++:S===41&&x--,a-b>r.maxStringBytes)throw new l("AI_STRING_LIMIT","lex",`PostScript string exceeds ${r.maxStringBytes} bytes.`)}x!==0&&d.push(E("AI_STRING_UNCLOSED","error","lex","PostScript string is not closed.",{sourceSpan:s.span(b,a)}));let D=e.slice(b,a);c("string",b,a,x===0?Cr(D):D.slice(1));continue}if(f===60){if(e.charCodeAt(a+1)===60){c("dict-start",a,a+2),a+=2;continue}if(e.charCodeAt(a+1)===126){let T=a,k=e.indexOf("~>",a+2);a=k<0?e.length:k+2,k<0&&d.push(E("AI_ASCII85_UNCLOSED","error","lex","ASCII85 data is not terminated.",{sourceSpan:s.span(T,a)}));let A=e.slice(T,a),y=new Uint8Array;try{y=He(J(A),r.maxStringBytes)}catch(v){d.push(E("AI_ASCII85_INVALID","error","lex",v instanceof Error?v.message:String(v),{sourceSpan:s.span(T,a)}))}c("ascii85",T,a,y);continue}let b=a++;for(;a<e.length&&e.charCodeAt(a)!==62;){if(a-b>r.maxStringBytes*2+2)throw new l("AI_STRING_LIMIT","lex",`Hex string exceeds ${r.maxStringBytes} decoded bytes.`);a++}let x=a<e.length;x?a++:d.push(E("AI_HEX_UNCLOSED","error","lex","Hex string is not terminated.",{sourceSpan:s.span(b,a)}));let D=e.slice(b,a),S=new Uint8Array;try{S=Rt(D.slice(1,x?-1:void 0))}catch(T){d.push(E("AI_HEX_INVALID","error","lex",T instanceof Error?T.message:String(T),{sourceSpan:s.span(b,a)}))}c("hex-string",b,a,S);continue}if(f===62&&e.charCodeAt(a+1)===62){c("dict-end",a,a+2),a+=2;continue}let m={91:"array-start",93:"array-end",123:"procedure-start",125:"procedure-end"};if(m[f]!==void 0){c(m[f],a,a+1),a++;continue}if(f===47){let b=a++;for(;a<e.length&&!Vt(e.charCodeAt(a));)a++;let x=e.slice(b,a);c("literal-name",b,a,Rr(x));continue}let I=a;for(;a<e.length&&!Vt(e.charCodeAt(a));)a++;if(a===I){c("unknown",a,a+1,e[a]),a++;continue}let g=e.slice(I,a),p=Mr(g);c(p.kind,I,a,p.value)}if(o.map(f=>f.raw).join("")!==e)throw new l("AI_LEXER_LOSS","lex","Internal lexer invariant failed: token raw values do not reconstruct the source exactly.");return{source:e,tokens:o,diagnostics:d}}var Gt=ue(()=>{Ie();G();Z();K()});function te(n,t,e){if(t>=n.length){let r=n.at(-1)?.span.end??{offset:0,line:1,column:1};return{start:r,end:r}}return{start:n[t].span.start,end:n[Math.max(t,e-1)].span.end}}function $r(n){return n?.kind==="whitespace"||n?.kind==="comment"||n?.kind==="pseudo-comment"}function zt(n,t={}){let e=Wt(n,t),r=V(t.limits),i=new B(t.signal,Math.min(t.timeoutMs??r.maxWorkerTimeMs,r.maxWorkerTimeMs));return new ct(e.source,e.tokens,e.diagnostics,r,i).parse()}function dt(n){return n.tokens.map(t=>t.raw).join("")}var ct,ut=ue(()=>{G();Gt();Z();K();ct=class{source;tokens;limits;budget;diagnostics;statements=[];statementCount=0;constructor(t,e,r,i,s){this.source=t,this.tokens=e,this.limits=i,this.budget=s,this.diagnostics=[...r]}parse(){let t=0,e=[],r=-1,i=!1;for(;t<this.tokens.length;){this.budget.checkpoint("parse");let o=this.tokens[t];if(o.kind==="whitespace"){t++;continue}if(o.kind==="comment"||o.kind==="pseudo-comment"){this.addStatement({kind:"comment",pseudo:o.kind==="pseudo-comment",text:String(o.value??o.raw.slice(1)),span:o.span,tokenRange:[t,t+1],raw:o.raw}),t++;continue}if(o.kind==="binary"){e.length>0&&this.flushTrailing(e,r,t);let c=o.value instanceof Uint8Array?o.value:J(o.raw);this.addStatement({kind:"resource",resourceKind:"binary",value:c,span:o.span,tokenRange:[t,t+1],raw:o.raw}),e=[],r=-1,t++;continue}if(o.kind==="word"){let c=String(o.value??o.raw),a=r>=0?r:t,u={kind:"operator",operator:c,operands:e,span:te(this.tokens,a,t+1),tokenRange:[a,t+1],raw:this.raw(a,t+1)};this.addStatement(u),c==="Bd"?i=!0:c==="BD"&&(i=!1),e=[],r=-1,t++;continue}if(o.kind==="array-start"&&i){r<0&&(r=t),e.push({kind:"name",value:"[",literal:!1,span:o.span,tokenIndex:t}),t++;continue}let d=this.parseValue(t,0);r<0&&(r=t),e.push(d.value),t=d.next}e.length>0&&this.flushTrailing(e,r,this.tokens.length);let s={format:"adobe-illustrator.lossless-ast",schemaVersion:1,encoding:"latin1",sourceByteLength:this.source.length,tokens:this.tokens,statements:this.statements,diagnostics:this.diagnostics};if(dt(s)!==this.source)throw new l("AI_AST_LOSS","parse","Internal AST invariant failed: tokens do not reconstruct the original source.");return s}addStatement(t){if(this.statementCount++,this.statementCount>this.limits.maxStatements)throw new l("AI_STATEMENT_LIMIT","parse",`Illustrator source exceeds ${this.limits.maxStatements} statements.`);this.statements.push(t)}flushTrailing(t,e,r){this.addStatement({kind:"trailing-values",values:[...t],span:te(this.tokens,e,r),tokenRange:[e,r],raw:this.raw(e,r)}),this.diagnostics.push(E("AI_TRAILING_OPERANDS","warning","parse",`Preserved ${t.length} operand(s) without a following operator.`,{sourceSpan:te(this.tokens,e,r)}))}raw(t,e){return this.tokens.slice(t,e).map(r=>r.raw).join("")}skipTrivia(t){for(;t<this.tokens.length&&$r(this.tokens[t]);)t++;return t}parseValue(t,e){if(e>this.limits.maxNesting)throw new l("AI_AST_NESTING_LIMIT","parse",`AST nesting exceeds ${this.limits.maxNesting}.`);t=this.skipTrivia(t);let r=this.tokens[t];if(r===void 0)return{value:{kind:"unknown",raw:"",span:te(this.tokens,this.tokens.length,this.tokens.length),tokenIndex:this.tokens.length},next:this.tokens.length};let s=(()=>{switch(r.kind){case"number":return{kind:"number",value:Number(r.value),span:r.span,tokenIndex:t};case"boolean":return{kind:"boolean",value:!!r.value,span:r.span,tokenIndex:t};case"null":return{kind:"null",value:null,span:r.span,tokenIndex:t};case"literal-name":return{kind:"name",value:String(r.value??r.raw.slice(1)),literal:!0,span:r.span,tokenIndex:t};case"word":return{kind:"name",value:String(r.value??r.raw),literal:!1,span:r.span,tokenIndex:t};case"string":{let o=String(r.value??"");return{kind:"string",value:o,rawBytes:J(o),span:r.span,tokenIndex:t}}case"hex-string":case"ascii85":case"binary":return{kind:r.kind,value:r.value instanceof Uint8Array?r.value:J(r.raw),span:r.span,tokenIndex:t};case"unknown":return{kind:"unknown",raw:r.raw,span:r.span,tokenIndex:t};default:return}})();if(s!==void 0)return{value:s,next:t+1};if(r.kind==="array-start"||r.kind==="procedure-start"){let o=r.kind==="array-start"?"array-end":"procedure-end",d=[],c=t+1;for(;;){if(c=this.skipTrivia(c),c>=this.tokens.length){let u=te(this.tokens,t,this.tokens.length);return this.diagnostics.push(E("AI_COMPOSITE_UNCLOSED","error","parse",`${r.kind==="array-start"?"Array":"Procedure"} is not closed.`,{sourceSpan:u})),{value:{kind:r.kind==="array-start"?"array":"procedure",values:d,span:u,tokenRange:[t,this.tokens.length]},next:this.tokens.length}}if(this.tokens[c].kind===o){let u=c+1;return{value:{kind:r.kind==="array-start"?"array":"procedure",values:d,span:te(this.tokens,t,u),tokenRange:[t,u]},next:u}}if(["array-end","procedure-end","dict-end"].includes(this.tokens[c].kind)){this.diagnostics.push(E("AI_COMPOSITE_MISMATCH","error","parse",`Unexpected ${this.tokens[c].kind} while parsing ${r.kind}.`,{sourceSpan:this.tokens[c].span})),d.push({kind:"unknown",raw:this.tokens[c].raw,span:this.tokens[c].span,tokenIndex:c}),c++;continue}let a=this.parseValue(c,e+1);d.push(a.value),c=a.next}}if(r.kind==="dict-start"){let o=[],d=t+1;for(;;){if(d=this.skipTrivia(d),d>=this.tokens.length){let a=te(this.tokens,t,this.tokens.length);return this.diagnostics.push(E("AI_DICTIONARY_UNCLOSED","error","parse","Dictionary is not closed.",{sourceSpan:a})),{value:this.dictionaryValue(o,t,this.tokens.length,a),next:this.tokens.length}}if(this.tokens[d].kind==="dict-end"){let a=d+1;return{value:this.dictionaryValue(o,t,a,te(this.tokens,t,a)),next:a}}let c=this.parseValue(d,e+1);o.push(c.value),d=c.next}}return this.diagnostics.push(E("AI_DELIMITER_UNEXPECTED","error","parse",`Unexpected ${r.kind} was preserved as unknown.`,{sourceSpan:r.span})),{value:{kind:"unknown",raw:r.raw,span:r.span,tokenIndex:t},next:t+1}}dictionaryValue(t,e,r,i){let s=[];for(let o=0;o<t.length;o+=2){let d=t[o],c=t[o+1];c===void 0?(this.diagnostics.push(E("AI_DICTIONARY_ODD_VALUES","error","parse","Dictionary has a key without a value; the missing value is represented as unknown.",{sourceSpan:d.span})),s.push({key:d,value:{kind:"unknown",raw:"",span:d.span,tokenIndex:r-1}})):s.push({key:d,value:c})}return{kind:"dictionary",entries:s,span:i,tokenRange:[e,r]}}}});Ie();G();Z();Ie();G();K();var yr=new Set([0,9,10,12,13,32]),br=new Set([40,41,60,62,91,93,123,125,47,37]);function Ze(n){return n!==void 0&&yr.has(n)}function Q(n){return n===void 0||Ze(n)||br.has(n)}function Je(n){return n!==void 0&&(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102)}function Ye(n){return n<=57?n-48:n<=70?n-55:n-87}var Y=class{bytes;maximumDepth;budget;offset;constructor(t,e,r,i){this.bytes=t,this.maximumDepth=r,this.budget=i,this.offset=e}skipTrivia(){for(;this.offset<this.bytes.length;){let t=this.bytes[this.offset];if(Ze(t)){this.offset++;continue}if(t===37){for(this.offset++;this.offset<this.bytes.length&&this.bytes[this.offset]!==10&&this.bytes[this.offset]!==13;)this.offset++;continue}break}}matchKeyword(t){if(this.skipTrivia(),this.offset+t.length>this.bytes.length)return!1;for(let e=0;e<t.length;e++)if(this.bytes[this.offset+e]!==t.charCodeAt(e))return!1;return!Q(this.bytes[this.offset-1])||!Q(this.bytes[this.offset+t.length])?!1:(this.offset+=t.length,!0)}peekKeyword(t){let e=this.offset,r=this.matchKeyword(t);return this.offset=e,r}parseValue(t=0){if(this.budget.checkpoint("container"),t>this.maximumDepth)throw new l("AI_PDF_NESTING_LIMIT","container",`PDF value nesting exceeds ${this.maximumDepth}.`);this.skipTrivia();let e=this.bytes[this.offset];if(e===void 0)throw new l("AI_PDF_VALUE_TRUNCATED","container","Unexpected end of PDF while reading a value.");if(e===47)return this.parseName();if(e===40)return this.parseLiteralString();if(e===91)return this.parseArray(t+1);if(e===60)return this.bytes[this.offset+1]===60?this.parseDictionary(t+1):this.parseHexString();if(this.matchKeyword("true"))return!0;if(this.matchKeyword("false"))return!1;if(this.matchKeyword("null"))return null;let r=this.parseNumberOrWord();if(typeof r=="number"&&Number.isInteger(r)&&r>=0){let i=this.offset;try{let s=this.parseNumberOrWord();if(typeof s=="number"&&Number.isInteger(s)&&s>=0&&this.matchKeyword("R"))return{kind:"reference",objectNumber:r,generation:s}}catch{}this.offset=i}return r}parseName(){this.offset++;let t=[];for(;this.offset<this.bytes.length&&!Q(this.bytes[this.offset]);){let e=this.bytes[this.offset++];e===35&&Je(this.bytes[this.offset])&&Je(this.bytes[this.offset+1])?(t.push(Ye(this.bytes[this.offset])<<4|Ye(this.bytes[this.offset+1])),this.offset+=2):t.push(e)}return{kind:"name",value:j(Uint8Array.from(t))}}parseLiteralString(){this.offset++;let t=1,e=[];for(;this.offset<this.bytes.length&&t>0;){let r=this.bytes[this.offset++];if(r===92){if(this.offset>=this.bytes.length)break;if(r=this.bytes[this.offset++],r===110)e.push(10);else if(r===114)e.push(13);else if(r===116)e.push(9);else if(r===98)e.push(8);else if(r===102)e.push(12);else if(r===13)this.bytes[this.offset]===10&&this.offset++;else if(r!==10)if(r>=48&&r<=55){let i=r-48,s=1;for(;s<3&&this.bytes[this.offset]!==void 0&&this.bytes[this.offset]>=48&&this.bytes[this.offset]<=55;)i=i*8+this.bytes[this.offset++]-48,s++;e.push(i&255)}else e.push(r)}else r===40?(t++,e.push(r)):r===41?(t--,t>0&&e.push(r)):e.push(r)}if(t!==0)throw new l("AI_PDF_STRING_TRUNCATED","container","PDF literal string is not closed.");return{kind:"string",bytes:Uint8Array.from(e),hex:!1}}parseHexString(){this.offset++;let t=[],e=!1;for(;this.offset<this.bytes.length;){let i=this.bytes[this.offset++];if(i===62){e=!0;break}if(!Ze(i)){if(!Je(i))throw new l("AI_PDF_HEX_INVALID","container","PDF hex string contains an invalid character.");t.push(Ye(i))}}if(!e)throw new l("AI_PDF_STRING_TRUNCATED","container","PDF hex string is not closed.");t.length%2!==0&&t.push(0);let r=new Uint8Array(t.length/2);for(let i=0;i<t.length;i+=2)r[i/2]=t[i]<<4|t[i+1];return{kind:"string",bytes:r,hex:!0}}parseArray(t){this.offset++;let e=[];for(;;){if(this.skipTrivia(),this.offset>=this.bytes.length)throw new l("AI_PDF_ARRAY_TRUNCATED","container","PDF array is not closed.");if(this.bytes[this.offset]===93){this.offset++;break}e.push(this.parseValue(t))}return{kind:"array",values:e}}parseDictionary(t){this.offset+=2;let e=new Map;for(;;){if(this.skipTrivia(),this.offset+1<this.bytes.length&&this.bytes[this.offset]===62&&this.bytes[this.offset+1]===62){this.offset+=2;break}if(this.offset>=this.bytes.length)throw new l("AI_PDF_DICTIONARY_TRUNCATED","container","PDF dictionary is not closed.");let r=this.parseName();if(e.has(r.value))throw new l("AI_PDF_DUPLICATE_KEY","container",`PDF dictionary contains duplicate /${r.value}.`);e.set(r.value,this.parseValue(t))}return{kind:"dictionary",entries:e}}parseNumberOrWord(){this.skipTrivia();let t=this.offset;for(;this.offset<this.bytes.length&&!Q(this.bytes[this.offset]);)this.offset++;if(this.offset===t)throw new l("AI_PDF_TOKEN_INVALID","container",`Invalid PDF token at byte ${t}.`);let e=j(this.bytes.subarray(t,this.offset));if(/^[+-]?(?:\d+\.?\d*|\.\d+)$/u.test(e)){let r=Number(e);if(!Number.isFinite(r))throw new l("AI_PDF_NUMBER_INVALID","container",`Invalid PDF number ${e}.`);return r}return e}};function se(n){return typeof n=="object"&&n!==null&&n.kind==="dictionary"}function Qe(n){return typeof n=="object"&&n!==null&&n.kind==="array"}function Ft(n){return typeof n=="object"&&n!==null&&n.kind==="name"}function et(n){return typeof n=="object"&&n!==null&&n.kind==="reference"}function tt(n){return Ft(n)?n.value:void 0}function L(n){return typeof n=="number"?n:void 0}function rt(n){return typeof n=="string"?n:typeof n=="object"&&n!==null&&n.kind==="string"?j(n.bytes):void 0}function ye(n){return Qe(n)?n.values:void 0}function ee(n){return se(n)?n:void 0}function le(n){return et(n)?n:void 0}function z(n,t){return n?.entries.get(t)}function qe(n,t,e){let r=0;for(let i=0;i<e;i++)if(r=r*256+n[t+i],!Number.isSafeInteger(r))throw new l("AI_PDF_XREF_OVERFLOW","container","PDF xref field exceeds the safe integer range.");return r}function wr(n,t,e,r=n.length){e:for(let i=Math.max(0,e);i+t.length<=r;i++)if(Q(n[i-1])){for(let s=0;s<t.length;s++)if(n[i+s]!==t.charCodeAt(s))continue e;if(Q(n[i+t.length]))return i}return-1}function xr(n,t){e:for(let e=n.length-t.length;e>=0;e--)if(Q(n[e-1])){for(let r=0;r<t.length;r++)if(n[e+r]!==t.charCodeAt(r))continue e;if(Q(n[e+t.length]))return e}return-1}function Mt(n,t){let e=t;if(n[e]===13)e++,n[e]===10&&e++;else if(n[e]===10)e++;else throw new l("AI_PDF_STREAM_EOL","container","PDF stream keyword must be followed by CR, LF, or CRLF.");return e}var $e=class n{bytes;limits;codecs;budget;diagnostics=[];version;headerOffset;xref=new Map;xrefOffsets=new Set;objectCache=new Map;objectStreamCache=new Map;trailers=[];revision=0;constructor(t,e,r,i,s,o){this.bytes=t,this.limits=e,this.codecs=r,this.budget=i,this.headerOffset=s,this.version=o}static async open(t,e){if(t.byteLength>e.limits.maxFileBytes)throw new l("AI_FILE_LIMIT","container",`PDF exceeds the ${e.limits.maxFileBytes}-byte file limit.`);let r=-1,i=Math.min(t.length,1024);for(let h=0;h+8<=i;h++)if(t[h]===37&&t[h+1]===80&&t[h+2]===68&&t[h+3]===70&&t[h+4]===45){r=h;break}if(r<0)throw new l("AI_PDF_HEADER_MISSING","container","Input does not contain a valid PDF header in the first 1024 bytes.");let s=j(t.subarray(r+5,Math.min(r+8,t.length))).match(/^\d\.\d/u)?.[0];if(s===void 0)throw new l("AI_PDF_VERSION_INVALID","container","PDF header has an invalid version.");let o=Math.min(e.timeoutMs??e.limits.maxWorkerTimeMs,e.limits.maxWorkerTimeMs),d=new n(t,e.limits,e.codecs,new B(e.signal,o),r,s),c=xr(t,"startxref");if(c<0)throw new l("AI_PDF_STARTXREF_MISSING","container","PDF startxref marker is missing.");let u=new Y(t,c+9,e.limits.maxNesting,d.budget).parseNumberOrWord();if(typeof u!="number"||!Number.isSafeInteger(u)||u<0||u>=t.length)throw new l("AI_PDF_STARTXREF_INVALID","container","PDF startxref offset is invalid.");if(await d.loadXref(u,0),d.xref.size>e.limits.maxPdfObjects)throw new l("AI_PDF_OBJECT_LIMIT","container",`PDF xref exceeds ${e.limits.maxPdfObjects} objects.`);if(d.trailers.some(h=>h.entries.has("Encrypt")))throw new l("AI_PDF_ENCRYPTED","container","Encrypted PDF private source cannot be read safely.");if(d.getRootReference()===void 0)throw new l("AI_PDF_ROOT_MISSING","container","PDF trailer chain does not contain a Catalog /Root reference.");return d}get objectCount(){return[...this.xref.values()].filter(t=>t.type!==0).length}getRootReference(){for(let t of this.trailers){let e=le(t.entries.get("Root"));if(e!==void 0)return e}}getTrailerValue(t){for(let e of this.trailers)if(e.entries.has(t))return e.entries.get(t)}async getRoot(){let t=this.getRootReference();if(t===void 0)throw new l("AI_PDF_ROOT_MISSING","container","PDF Catalog reference is missing.");return this.getObject(t)}async getObject(t,e=[]){this.budget.checkpoint("container");let r=`${t.objectNumber}:${t.generation}`;if(e.includes(r))throw new l("AI_PDF_REFERENCE_CYCLE","container",`PDF reference cycle detected at ${r}.`);let i=this.xref.get(t.objectNumber);if(i===void 0||i.type===0)throw new l("AI_PDF_OBJECT_MISSING","container",`PDF object ${r} is missing.`);if(i.generation!==t.generation)throw new l("AI_PDF_GENERATION_MISMATCH","container",`PDF object ${t.objectNumber} has generation ${i.generation}, not ${t.generation}.`);let s=this.objectCache.get(r);return s===void 0&&(s=i.type===1?this.parseIndirectObjectAt(i.offset,t.objectNumber,t.generation,[...e,r]):this.getCompressedObject(i.objectStream,i.index,t.objectNumber,[...e,r]),this.objectCache.set(r,s)),s}async resolve(t,e=[]){if(!et(t))return t;let r=await this.getObject(t,e);return this.resolve(r.value,[...e,`${t.objectNumber}:${t.generation}`])}async resolveDictionary(t,e=[]){if(t===void 0)return;let r=await this.resolve(t,e);return ee(r)}async allObjects(){let t=[],e=[...this.xref.entries()].filter(([,r])=>r.type!==0).sort(([r],[i])=>r-i);for(let[r,i]of e)this.budget.checkpoint("container"),t.push(await this.getObject({kind:"reference",objectNumber:r,generation:i.generation}));return t}async decodeStream(t,e=this.limits.maxDecodedBytes,r){if(t.stream===void 0)throw new l("AI_PDF_STREAM_MISSING","decode",`PDF object ${t.objectNumber} is not a stream.`);return Ke(t.stream.encoded,t.stream.filters,this.codecs,Math.min(e,this.limits.maxDecodedBytes),r)}mergeEntry(t,e,r){if(!Number.isSafeInteger(t)||t<0)throw new l("AI_PDF_XREF_INVALID","container","PDF xref contains an invalid object number.");if(r.has(t))throw new l("AI_PDF_XREF_DUPLICATE","container",`PDF xref revision defines object ${t} more than once.`);r.add(t),this.budget.consume("pdfObjects",1,this.limits.maxPdfObjects,"container");let i=this.xref.get(t);i===void 0?this.xref.set(t,e):i.revision===e.revision&&JSON.stringify(i)!==JSON.stringify(e)&&this.diagnostics.push(E("AI_PDF_XREF_HYBRID_CONFLICT","warning","container",`Hybrid xref entries disagree for object ${t}; the primary xref entry was retained.`))}async loadXref(t,e){if(this.budget.checkpoint("container"),!Number.isSafeInteger(t)||t<0||t>=this.bytes.length)throw new l("AI_PDF_XREF_OFFSET_INVALID","container",`PDF xref offset ${t} is outside the file.`);if(this.xrefOffsets.has(t))throw new l("AI_PDF_XREF_CYCLE","container",`PDF incremental xref chain loops at offset ${t}.`);this.xrefOffsets.add(t),this.revision=Math.max(this.revision,e);let r=new Y(this.bytes,t,this.limits.maxNesting,this.budget);r.matchKeyword("xref")?await this.loadClassicXref(r,t,e):await this.loadXrefStream(t,e)}async loadClassicXref(t,e,r){let i=new Set;for(;t.skipTrivia(),!t.peekKeyword("trailer");){let o=t.parseNumberOrWord(),d=t.parseNumberOrWord();if(typeof o!="number"||typeof d!="number"||!Number.isSafeInteger(o)||!Number.isSafeInteger(d)||o<0||d<0)throw new l("AI_PDF_XREF_INVALID","container","Classic PDF xref subsection header is invalid.");if(d>this.limits.maxPdfObjects)throw new l("AI_PDF_OBJECT_LIMIT","container",`PDF xref subsection exceeds ${this.limits.maxPdfObjects} entries.`);for(let c=0;c<d;c++){let a=t.parseNumberOrWord(),u=t.parseNumberOrWord(),h=t.parseNumberOrWord();if(typeof a!="number"||typeof u!="number"||typeof h!="string"||!Number.isSafeInteger(a)||!Number.isSafeInteger(u))throw new l("AI_PDF_XREF_INVALID","container",`Classic PDF xref entry ${o+c} is invalid.`);if(h==="n")this.mergeEntry(o+c,{type:1,offset:a,generation:u,revision:r},i);else if(h==="f")this.mergeEntry(o+c,{type:0,generation:u,revision:r},i);else throw new l("AI_PDF_XREF_INVALID","container",`Classic PDF xref entry ${o+c} has state ${h}.`)}}if(!t.matchKeyword("trailer"))throw new l("AI_PDF_TRAILER_MISSING","container","Classic PDF xref has no trailer dictionary.");let s=t.parseValue();if(!se(s))throw new l("AI_PDF_TRAILER_INVALID","container","Classic PDF trailer is not a dictionary.");await this.processTrailer(s,e,r)}async loadXrefStream(t,e){let r=this.parseIndirectObjectRaw(t);if(!se(r.value)||r.stream===void 0)throw new l("AI_PDF_XREF_STREAM_INVALID","container",`Object at xref offset ${t} is not an xref stream.`);let i=tt(r.value.entries.get("Type"));if(i!==void 0&&i!=="XRef")throw new l("AI_PDF_XREF_STREAM_INVALID","container",`Object at xref offset ${t} has /Type /${i}, not /XRef.`);let s=ye(r.value.entries.get("W"))?.map(L);if(s===void 0||s.length!==3||s.some(f=>f===void 0||!Number.isSafeInteger(f)||f<0||f>8))throw new l("AI_PDF_XREF_STREAM_INVALID","container","PDF xref stream /W must contain three widths between 0 and 8.");let o=await Ke(r.stream.encoded,r.stream.filters,this.codecs,this.limits.maxDecodedBytes,this.budget.signal),d=L(r.value.entries.get("Size"));if(d===void 0||!Number.isSafeInteger(d)||d<0||d>this.limits.maxPdfObjects+1)throw new l("AI_PDF_XREF_STREAM_INVALID","container","PDF xref stream /Size is invalid.");let c=ye(r.value.entries.get("Index"))?.map(L)??[0,d];if(c.length%2!==0||c.some(f=>f===void 0||!Number.isSafeInteger(f)||f<0))throw new l("AI_PDF_XREF_STREAM_INVALID","container","PDF xref stream /Index is invalid.");let a=s[0]+s[1]+s[2];if(a<=0)throw new l("AI_PDF_XREF_STREAM_INVALID","container","PDF xref stream entry width is zero.");let u=0,h=new Set;for(let f=0;f<c.length;f+=2){let m=c[f],I=c[f+1];if(m+I>this.limits.maxPdfObjects+1)throw new l("AI_PDF_OBJECT_LIMIT","container","PDF xref stream object range exceeds the object limit.");for(let g=0;g<I;g++){if(u+a>o.length)throw new l("AI_PDF_XREF_STREAM_TRUNCATED","container","PDF xref stream data is truncated.");let p=s[0]===0?1:qe(o,u,s[0]),b=qe(o,u+s[0],s[1]),x=qe(o,u+s[0]+s[1],s[2]),D=m+g;p===0?this.mergeEntry(D,{type:0,generation:x,revision:e},h):p===1?this.mergeEntry(D,{type:1,offset:b,generation:x,revision:e},h):p===2?this.mergeEntry(D,{type:2,objectStream:b,index:x,generation:0,revision:e},h):this.diagnostics.push(E("AI_PDF_XREF_ENTRY_UNKNOWN","warning","container",`Ignored xref stream entry type ${p} for object ${D}.`)),u+=a}}u!==o.length&&this.diagnostics.push(E("AI_PDF_XREF_TRAILING_DATA","warning","container",`PDF xref stream contains ${o.length-u} trailing bytes.`)),this.xref.has(r.objectNumber)||this.xref.set(r.objectNumber,{type:1,offset:t,generation:r.generation,revision:e}),await this.processTrailer(r.value,t,e)}async processTrailer(t,e,r){if(this.trailers.push(t),t.entries.has("Encrypt"))throw new l("AI_PDF_ENCRYPTED","container","Encrypted PDF private source cannot be read safely.");let i=L(t.entries.get("XRefStm"));i!==void 0&&i!==e&&await this.loadXref(i,r);let s=L(t.entries.get("Prev"));s!==void 0&&await this.loadXref(s,r+1)}parseIndirectObjectRaw(t){let e=new Y(this.bytes,t,this.limits.maxNesting,this.budget),r=e.parseNumberOrWord(),i=e.parseNumberOrWord();if(typeof r!="number"||typeof i!="number"||!Number.isSafeInteger(r)||!Number.isSafeInteger(i)||!e.matchKeyword("obj"))throw new l("AI_PDF_OBJECT_HEADER_INVALID","container",`PDF indirect object header at offset ${t} is invalid.`);let s=e.parseValue();e.skipTrivia();let o;if(se(s)&&e.matchKeyword("stream")){let d=Mt(this.bytes,e.offset),c=L(s.entries.get("Length")),a;if(c!==void 0&&Number.isSafeInteger(c)&&c>=0)a=d+c;else{if(a=wr(this.bytes,"endstream",d),a<0)throw new l("AI_PDF_STREAM_TRUNCATED","container",`PDF stream object ${r} is not terminated.`);for(;a>d&&(this.bytes[a-1]===10||this.bytes[a-1]===13);)a--}if(a<d||a>this.bytes.length||a-d>this.limits.maxFileBytes)throw new l("AI_PDF_STREAM_LENGTH_INVALID","container",`PDF stream object ${r} has an invalid length.`);o={dictionary:s,encoded:this.bytes.slice(d,a),filters:$t(s)}}return{objectNumber:r,generation:i,value:s,...o===void 0?{}:{stream:o},offset:t,compressed:!1}}async parseIndirectObjectAt(t,e,r,i){let s=new Y(this.bytes,t,this.limits.maxNesting,this.budget),o=s.parseNumberOrWord(),d=s.parseNumberOrWord();if(o!==e||d!==r||!s.matchKeyword("obj"))throw new l("AI_PDF_OBJECT_OFFSET_MISMATCH","container",`xref points to ${e} ${r}, but offset ${t} contains ${String(o)} ${String(d)}.`);let c=s.parseValue();s.skipTrivia();let a;if(se(c)&&s.matchKeyword("stream")){let u=Mt(this.bytes,s.offset),h=c.entries.get("Length"),f;if(typeof h=="number")f=h;else if(et(h)){let g=await this.getObject(h,i);typeof g.value=="number"&&(f=g.value)}if(f===void 0||!Number.isSafeInteger(f)||f<0)throw new l("AI_PDF_STREAM_LENGTH_INVALID","container",`PDF stream ${o} has no valid direct or indirect /Length.`);if(f>this.limits.maxFileBytes||u+f>this.bytes.length)throw new l("AI_PDF_STREAM_LENGTH_INVALID","container",`PDF stream ${o} exceeds the file boundary or configured limit.`);let m=u+f,I=new Y(this.bytes,m,this.limits.maxNesting,this.budget);if(!I.matchKeyword("endstream"))throw new l("AI_PDF_STREAM_LENGTH_MISMATCH","container",`PDF stream ${o} /Length does not end at endstream.`);if(!I.matchKeyword("endobj"))throw new l("AI_PDF_OBJECT_TRUNCATED","container",`PDF stream object ${o} is not followed by endobj.`);a={dictionary:c,encoded:this.bytes.slice(u,m),filters:$t(c)}}else if(!s.matchKeyword("endobj"))throw new l("AI_PDF_OBJECT_TRUNCATED","container",`PDF object ${o} is not followed by endobj.`);return{objectNumber:o,generation:d,value:c,...a===void 0?{}:{stream:a},offset:t,compressed:!1}}async getCompressedObject(t,e,r,i){let s=this.objectStreamCache.get(t);s===void 0&&(s=this.parseObjectStream(t,i),this.objectStreamCache.set(t,s));let o=await s,d=o.get(r);if(d===void 0)throw new l("AI_PDF_OBJECT_STREAM_MISSING","container",`Object stream ${t} does not contain object ${r}.`);if([...o.values()][e]?.objectNumber!==r)throw new l("AI_PDF_OBJECT_STREAM_INDEX","container",`xref index ${e} for object ${r} does not match object stream ${t}.`);return d}async parseObjectStream(t,e){let r=this.xref.get(t);if(r===void 0||r.type!==1)throw new l("AI_PDF_OBJECT_STREAM_INVALID","container",`Object stream ${t} is not an uncompressed indirect object.`);let i=await this.getObject({kind:"reference",objectNumber:t,generation:r.generation},e);if(i.stream===void 0||!se(i.value))throw new l("AI_PDF_OBJECT_STREAM_INVALID","container",`Object ${t} is not a stream.`);let s=tt(i.value.entries.get("Type"));if(s!==void 0&&s!=="ObjStm")throw new l("AI_PDF_OBJECT_STREAM_INVALID","container",`Object ${t} has /Type /${s}, not /ObjStm.`);let o=L(i.value.entries.get("N")),d=L(i.value.entries.get("First"));if(o===void 0||d===void 0||!Number.isSafeInteger(o)||!Number.isSafeInteger(d)||o<0||o>this.limits.maxPdfObjects||d<0)throw new l("AI_PDF_OBJECT_STREAM_INVALID","container",`Object stream ${t} has invalid /N or /First.`);let c=await this.decodeStream(i,this.limits.maxDecodedBytes,this.budget.signal);if(d>c.length)throw new l("AI_PDF_OBJECT_STREAM_TRUNCATED","container",`Object stream ${t} /First is outside decoded data.`);let a=new Y(c,0,this.limits.maxNesting,this.budget),u=[],h=new Set;for(let m=0;m<o;m++){let I=a.parseNumberOrWord(),g=a.parseNumberOrWord();if(typeof I!="number"||typeof g!="number"||!Number.isSafeInteger(I)||!Number.isSafeInteger(g)||I<0||g<0)throw new l("AI_PDF_OBJECT_STREAM_INVALID","container",`Object stream ${t} header pair ${m} is invalid.`);if(h.has(I))throw new l("AI_PDF_OBJECT_STREAM_DUPLICATE","container",`Object stream ${t} repeats object ${I}.`);h.add(I),u.push({objectNumber:I,relativeOffset:g})}if(a.offset>d)throw new l("AI_PDF_OBJECT_STREAM_INVALID","container",`Object stream ${t} header overlaps object data.`);let f=new Map;for(let m=0;m<u.length;m++){let I=u[m],g=d+I.relativeOffset,p=m+1<u.length?d+u[m+1].relativeOffset:c.length;if(g<d||p<g||p>c.length)throw new l("AI_PDF_OBJECT_STREAM_INVALID","container",`Object ${I.objectNumber} has an invalid offset in object stream ${t}.`);let b=new Y(c,g,this.limits.maxNesting,this.budget),x=b.parseValue();if(b.skipTrivia(),b.offset>p)throw new l("AI_PDF_OBJECT_STREAM_OVERLAP","container",`Object ${I.objectNumber} overlaps the next compressed object.`);f.set(I.objectNumber,{objectNumber:I.objectNumber,generation:0,value:x,offset:g,compressed:!0})}return f}};function Ot(n){if(n!=null){if(!se(n))throw new l("AI_PDF_DECODEPARMS_INVALID","decode","PDF /DecodeParms entry is not a dictionary.");return{...L(n.entries.get("Predictor"))===void 0?{}:{predictor:L(n.entries.get("Predictor"))},...L(n.entries.get("Colors"))===void 0?{}:{colors:L(n.entries.get("Colors"))},...L(n.entries.get("BitsPerComponent"))===void 0?{}:{bitsPerComponent:L(n.entries.get("BitsPerComponent"))},...L(n.entries.get("Columns"))===void 0?{}:{columns:L(n.entries.get("Columns"))}}}}function $t(n){let t=n.entries.get("Filter");if(t===void 0)return[];let e=Ft(t)?[t.value]:Qe(t)?t.values.map(s=>{let o=tt(s);if(o===void 0)throw new l("AI_PDF_FILTER_INVALID","decode","PDF /Filter array contains a non-name value.");return o}):(()=>{throw new l("AI_PDF_FILTER_INVALID","decode","PDF /Filter must be a name or an array of names.")})(),r=n.entries.get("DecodeParms")??n.entries.get("DP"),i;if(r==null)i=e.map(()=>{});else if(Qe(r)){if(r.values.length!==e.length)throw new l("AI_PDF_DECODEPARMS_INVALID","decode","PDF /DecodeParms array length does not match /Filter.");i=r.values.map(Ot)}else{if(e.length!==1)throw new l("AI_PDF_DECODEPARMS_INVALID","decode","A single /DecodeParms dictionary cannot describe multiple filters.");i=[Ot(r)]}return e.map((s,o)=>({name:s,...i[o]===void 0?{}:{parameters:i[o]}}))}K();function Ar(n){return n?.codecProvider!==void 0?n.codecProvider:Oe(n?.zstdDecoder)}function nt(n,t){let e=[];for(let r of t){let i=[new RegExp(String.raw`/${r}\s+([0-9]+(?:\.[0-9]+)?)`,"giu"),new RegExp(String.raw`%+${r}\s*:\s*([0-9]+(?:\.[0-9]+)?)`,"giu"),new RegExp(String.raw`\b${r}\s*=\s*([0-9]+(?:\.[0-9]+)?)`,"giu")];for(let s of i)for(let o of n.matchAll(s))e.push(Number(o[1]))}return e.filter(Number.isFinite)}function it(n,t,e){let r=[...new Set(n)];return r.length>1&&e.push(`${t} has conflicting values: ${r.join(", ")}.`),r[0]}function st(n,t,e,r,i){let s=[],o=[...new Set([...n.matchAll(/%(AI\d+_[A-Za-z0-9_]+)/gu)].map(m=>`%${m[1]}`))],d=it(nt(n,["ContainerVersion"]),"ContainerVersion",s),c=it(nt(n,["CreatorVersion"]),"CreatorVersion",s),a=it(nt(n,["RoundtripVersion"]),"RoundtripVersion",s),u=/%%AI8_CreatorVersion\s*:\s*([^\r\n]+)/iu.exec(n)?.[1]?.trim(),h=/%%AI5_FileFormat\s*:\s*([0-9]+(?:\.[0-9]+)?)/iu.exec(n)?.[1],f=/(?:xmlns:illustrator|xmlns:ai)\s*=\s*["']([^"']+)["']/iu.exec(n)?.[1];return{sourceKind:t,...e===void 0?{}:{pdfVersion:e},...d===void 0?{}:{containerVersion:d},...c===void 0?{}:{creatorVersion:c},...a===void 0?{}:{roundtripVersion:a},...u===void 0?{}:{ai8CreatorVersion:u},...h===void 0?{}:{ai5FileFormat:Number(h)},featureMarkers:o,...r===void 0?{}:{mime:r},...i===void 0?{}:{creator:i},...f===void 0?{}:{illustratorNamespace:f},contradictions:s}}function _r(n){return/^%!PS-Adobe(?:-|\s)/u.test(n)&&/%%Creator\s*:\s*.*Adobe\s+Illustrator/iu.test(n)}function vr(n,t){for(let e=t;e<n.length;e++){if(n[e]===10)return e+1;if(n[e]===13)return n[e+1]===10?e+2:e+1}return-1}function Ut(n,t=[0]){let e=[];for(let r of t){if(!Number.isSafeInteger(r)||r<0||r>=n.length)continue;let i=j(n.subarray(r,Math.min(n.length,r+256)));if(/^%!PS-Adobe(?:-|\s)/u.test(i)){e.push({compression:"none",markerOffset:r,payloadOffset:r});continue}for(let[s,o]of[[/^%AI(?:12|13|14|15|16|17|18|19|20|21|22|23)_CompressedData/u,"deflate"],[/^%AI24_ZStandard_Data/u,"zstd"]]){let d=s.exec(i);if(d===null)continue;let c=r+d.index,a=c+d[0].length,u=n[a];if(u===10){e.push({compression:o,markerOffset:c,payloadOffset:a+1,marker:d[0]});continue}if(u===13){e.push({compression:o,markerOffset:c,payloadOffset:n[a+1]===10?a+2:a+1,marker:d[0]});continue}let h=o==="deflate"&&u===120,f=o==="zstd"&&u===40&&n[a+1]===181&&n[a+2]===47&&n[a+3]===253;if(h||f){e.push({compression:o,markerOffset:c,payloadOffset:a,marker:d[0]});continue}throw vr(n,a)<0?new l("AI_PRIVATE_MARKER_TRUNCATED","decode",`${d[0]} marker has neither a line ending nor a recognized adjacent codec header.`):new l("AI_PRIVATE_MARKER_INVALID","decode",`${d[0]} marker is followed by unexpected text before its payload.`)}}if(e.length>1)throw new l("AI_PRIVATE_MARKER_AMBIGUOUS","decode","Multiple private-source payload markers were found at Illustrator block boundaries.");if(e.length===1)return e[0];throw new l("AI_PRIVATE_MARKER_UNKNOWN","decode","Illustrator private source has no recognized PostScript, deflate, or zstd marker.")}function Bt(n){let t=[],e=0;for(let r of n)t.push(e),e+=r.decodedBytes??0;return t}function Lt(n,t){let e=[],r=j(n);if(!/^%!PS-Adobe(?:-|\s)/u.test(r))throw new l("AI_SOURCE_HEADER_INVALID","decode","Decoded Illustrator source does not begin with a PostScript header.");if(!/%%Creator\s*:\s*.*Adobe\s+Illustrator/iu.test(r))throw new l("AI_SOURCE_CREATOR_INVALID","decode","Decoded source is not identified as Adobe Illustrator source.");let i=r.lastIndexOf("%%EOF");if(i<0){if(t)throw new l("AI_SOURCE_EOF_MISSING","decode","Decoded Illustrator source has no %%EOF terminator.");e.push(E("AI_SOURCE_EOF_MISSING","warning","decode","Decoded Illustrator source has no %%EOF terminator."))}else{let s=r.slice(i+5);/^[\s\0]*$/u.test(s)||e.push(E("AI_SOURCE_TRAILING_DATA","warning","decode",`Decoded Illustrator source contains ${s.length} non-whitespace characters after %%EOF.`))}return e}async function Dr(n){let t=n.getTrailerValue("Info"),e=await n.resolveDictionary(t);return rt(z(e,"Creator"))??rt(z(e,"Producer"))}async function kr(n,t){if(/saved without PDF Content|without PDF compatible content|PDF Content is not available/iu.test(t))return"warning-placeholder";let e=await n.getRoot(),r=ee(e.value);if(r===void 0)return"unknown";let i=await n.resolveDictionary(z(r,"Pages"));if(i===void 0)return"absent";let s=L(z(i,"Count")),o=ye(z(i,"Kids"));return s!==void 0&&s>0||o!==void 0&&o.length>0?"usable":"absent"}function ot(n){let t=[];for(let[e,r]of n.entries){let i=/^(?:AI|AIPDF)PrivateData(\d+)$/u.exec(e);i!==null&&t.push({part:Number(i[1]),value:r,key:e})}return t}async function Er(n){let t=new Map;for(let c of await n.allObjects()){let a=ee(c.value);if(a!==void 0&&ot(a).length>0){let u=`obj:${c.objectNumber}:${c.generation}`;t.set(u,{id:u,dictionary:a,object:c,reachable:!1})}}let e=0,r=new Map,i=async(c,a)=>{if(c===void 0)return;let u=le(c);if(u!==void 0){let f=await n.getObject(u),m=ee(f.value);return m===void 0?void 0:{id:`obj:${f.objectNumber}:${f.generation}`,dictionary:m,object:f}}let h=ee(c);return h===void 0?void 0:{id:`direct:${a}:${e++}`,dictionary:h}},s=async(c,a)=>{let u=await i(z(c,"PieceInfo"),`${a}:piece`);if(u===void 0)return;let h=await i(z(u.dictionary,"Illustrator"),`${a}:illustrator`);if(h===void 0)return;let f=await i(z(h.dictionary,"Private"),`${a}:private`);if(f===void 0||ot(f.dictionary).length===0)return;let m=t.get(f.id),I=m===void 0?{id:f.id,dictionary:f.dictionary,...f.object===void 0?{}:{object:f.object},reachable:!0}:{...m,reachable:!0};t.set(I.id,I),r.set(I.id,I)},o=await n.getRoot(),d=ee(o.value);if(d!==void 0){await s(d,"catalog");let c=z(d,"Pages"),a=le(c),u=a===void 0?[]:[a],h=new Set;for(;u.length>0;){let f=u.pop(),m=`${f.objectNumber}:${f.generation}`;if(h.has(m))throw new l("AI_PDF_PAGE_TREE_CYCLE","container",`PDF page tree contains a cycle at ${m}.`);if(h.size>=n.limits.maxPdfObjects)throw new l("AI_PDF_PAGE_TREE_LIMIT","container","PDF page tree exceeds the object limit.");h.add(m);let I=await n.getObject(f),g=ee(I.value);if(g===void 0)throw new l("AI_PDF_PAGE_TREE_INVALID","container",`PDF page tree object ${m} is not a dictionary.`);await s(g,`page:${m}`);for(let p of ye(z(g,"Kids"))??[]){let b=le(p);if(b===void 0)throw new l("AI_PDF_PAGE_TREE_INVALID","container",`PDF page tree object ${m} contains a direct or invalid /Kids entry.`);u.push(b)}}}return{all:[...t.values()],reachable:[...r.values()]}}async function Sr(n,t,e){let r=await Er(n);if(r.reachable.length>1)throw new l("AI_PRIVATE_DESCRIPTOR_AMBIGUOUS","container","Multiple Catalog-reachable Illustrator private-source descriptors were found.");if(r.reachable.length===1){let i=r.reachable[0];if(r.all.filter(o=>o.id!==i.id).length>0)throw new l("AI_PRIVATE_DESCRIPTOR_AMBIGUOUS","container","PDF contains additional unreferenced Illustrator private-source descriptors.");return i}if(r.all.length>1)throw new l("AI_PRIVATE_DESCRIPTOR_AMBIGUOUS","container","PDF contains multiple ambiguous Illustrator private-source descriptors.");if(r.all.length===1){if(!t)throw new l("AI_PRIVATE_EVIDENCE_MISSING","container","An unreferenced AIPrivateData dictionary is present without independent Illustrator evidence.");return e.push(E("AI_PRIVATE_DESCRIPTOR_UNREACHABLE","warning","container","The only Illustrator private-source descriptor is not reachable through Catalog/PieceInfo; it is accepted with reduced trust.",{recovery:"Re-save the file from Illustrator with editing capabilities preserved."})),r.all[0]}}async function Tr(n,t,e,r){let i=ot(t.dictionary).sort((f,m)=>f.part-m.part);if(i.length===0)throw new l("AI_PRIVATE_BLOCKS_MISSING","container","Illustrator private-source descriptor contains no data blocks.");if(i.length>e.maxPrivateBlocks)throw new l("AI_PRIVATE_BLOCK_LIMIT","container",`Illustrator private source exceeds ${e.maxPrivateBlocks} blocks.`);let s=z(t.dictionary,"NumBlock"),o=s===void 0?void 0:await n.resolve(s),d=L(o);if(d!==void 0&&(!Number.isSafeInteger(d)||d!==i.length))throw new l("AI_PRIVATE_BLOCK_COUNT_MISMATCH","container",`/NumBlock declares ${d}, but ${i.length} blocks are present.`);let c=new Set,a=[],u=[],h=0;for(let f=0;f<i.length;f++){let m=i[f];if(c.has(m.part)||m.part!==f+1)throw new l("AI_PRIVATE_BLOCK_SEQUENCE","container","Illustrator private-source block numbers must be unique and contiguous from 1.");c.add(m.part);let I=le(m.value);if(I===void 0)throw new l("AI_PRIVATE_BLOCK_REFERENCE","container",`/${m.key} is not an indirect PDF stream reference.`);let g=await n.getObject(I);if(g.stream===void 0)throw new l("AI_PRIVATE_BLOCK_STREAM_MISSING","container",`/${m.key} references PDF object ${I.objectNumber}, which is not a stream.`);let p=await n.decodeStream(g,e.maxDecodedBytes-h,r);if(h+=p.byteLength,h>e.maxDecodedBytes)throw new l("AI_PRIVATE_PACKED_LIMIT","decode",`Packed Illustrator source exceeds ${e.maxDecodedBytes} bytes.`);a.push(p),u.push({part:m.part,objectNumber:g.objectNumber,generation:g.generation,encodedBytes:g.stream.encoded.byteLength,decodedBytes:p.byteLength,sha256:await Ne(p),filters:g.stream.filters.map(b=>b.name)})}return{packed:Pe(a,e.maxDecodedBytes),blocks:u}}async function Pr(n,t,e){let r=V(t.limits),i=[],s=await $e.open(n,{limits:r,codecs:e,signal:t.signal,timeoutMs:t.timeoutMs});i.push(...s.diagnostics);let o=j(n),d=await Dr(s),c=/Adobe\s+Illustrator|xmlns:(?:illustrator|ai)\s*=|\/AI(?:PDF)?PrivateData\d+/iu.test(o)||/Illustrator/iu.test(d??""),a=await Sr(s,c,i),u=c||a!==void 0,h=await kr(s,o),f,m=[],I;if(a!==void 0){let x=await Tr(s,a,r,t.signal);f=x.packed,m=x.blocks;let D=Ut(f,Bt(m));I=D.compression,D.markerOffset>0&&i.push(E("AI_PRIVATE_PREFIX_BLOCKS_SKIPPED","info","decode",`Skipped ${D.markerOffset} bytes of alternate private preview data before the native revisable-source payload.`,{details:{prefixBytes:D.markerOffset}}))}let g=a!==void 0?"pdf-private":u?"pdf-surface-only":"unknown",p=st(o,g,s.version,t.mime,d);for(let x of p.contradictions)i.push(E("AI_VERSION_CONTRADICTION","warning","container",x));let b={kind:g,illustratorEvidence:u,pdfSurface:h,privateSource:a===void 0?"missing":"present",...I===void 0?{}:{compression:I},...p.containerVersion===void 0?{}:{containerVersion:p.containerVersion},...p.creatorVersion===void 0?{}:{creatorVersion:p.creatorVersion},...p.roundtripVersion===void 0?{}:{roundtripVersion:p.roundtripVersion},privateBlocks:m.length,fingerprint:p,diagnostics:i};return{pdf:s,inspection:b,...a===void 0?{}:{descriptor:a},...f===void 0?{}:{packed:f},blocks:m,diagnostics:i}}async function jt(n,t={},e={}){let r=await Te(n),i=V(t.limits);if(r.byteLength>i.maxFileBytes)throw new l("AI_FILE_LIMIT","container",`Input exceeds the ${i.maxFileBytes}-byte file limit.`);let s=Math.min(t.timeoutMs??i.maxWorkerTimeMs,i.maxWorkerTimeMs),o=new B(t.signal,s),d=j(r);if(/^%!PS-Adobe(?:-|\s)/u.test(d)){if(!_r(d))throw new l("AI_DIRECT_CREATOR_MISMATCH","container","PostScript input was not authored by Adobe Illustrator.");if(r.byteLength>i.maxDecodedBytes)throw new l("AI_DECODE_OUTPUT_LIMIT","decode",`Illustrator source exceeds ${i.maxDecodedBytes} bytes.`);let x=Lt(r,t.strictSourceTermination??!0),D=st(d,"direct-postscript",void 0,t.mime,/%%Creator\s*:\s*([^\r\n]+)/iu.exec(d)?.[1]?.trim());return D.sourceSha256=await Ne(r),{bytes:r,text:d,compression:"none",fingerprint:D,blocks:[],diagnostics:x}}let c=Ar(e),a=await Pr(r,t,c);if(a.inspection.kind==="unknown")throw new l("AI_NOT_ILLUSTRATOR","container","PDF has no validated Illustrator evidence or private source.");if(a.descriptor===void 0||a.packed===void 0)throw new l("AI_PRIVATE_SOURCE_MISSING","container","Illustrator PDF contains no recoverable native private source.");o.checkpoint("decode");let u=Ut(a.packed,Bt(a.blocks)),h=a.packed.subarray(u.payloadOffset),f;if(u.compression==="none")f=h;else if(u.compression==="deflate")f=await c.inflate(h,i.maxDecodedBytes,t.signal);else{if(c.zstd===void 0)throw new l("AI_ZSTD_UNAVAILABLE","decode","This Illustrator file uses zstd private-source compression; configure a local zstd decoder/WASM asset.");f=await c.zstd(h,i.maxDecodedBytes,t.signal)}if(f.byteLength>i.maxDecodedBytes)throw new l("AI_DECODE_OUTPUT_LIMIT","decode",`Decoded Illustrator source exceeds ${i.maxDecodedBytes} bytes.`);let m=j(f),I=Lt(f,t.strictSourceTermination??!0),g=st(m,"pdf-private",a.pdf.version,t.mime,a.inspection.fingerprint.creator),p={...a.inspection.fingerprint,...g,sourceKind:"pdf-private",featureMarkers:[...new Set([...a.inspection.fingerprint.featureMarkers,...g.featureMarkers])],contradictions:[...new Set([...a.inspection.fingerprint.contradictions,...g.contradictions])],sourceSha256:await Ne(f)},b=[...a.diagnostics,...I];for(let x of g.contradictions)b.push(E("AI_VERSION_CONTRADICTION","warning","container",x));return{bytes:f,text:m,compression:u.compression,fingerprint:p,blocks:a.blocks,diagnostics:b}}ut();G();Z();G();K();var lt=Object.freeze({kind:"none"}),ft=Object.freeze({kind:"gray",gray:0,alpha:1}),Gn=Object.freeze({kind:"gray",gray:1,alpha:1});function oe(n=Re){return{...n}}function ae(){return{fills:[],strokes:[],opacity:1,blendMode:"normal",knockout:!1,isolated:!1,effects:[],source:"native"}}var Xt={exact:4,high:3,partial:2,"structure-only":1,unsupported:0};function ce(n,t){return Xt[n]<=Xt[t]?n:t}function Fe(n,t){let e=r=>{if(t(r),r.type==="Layer"||r.type==="Group"||r.type==="ClipGroup"||r.type==="SymbolDefinition")for(let i of r.children)e(i)};for(let r of n.children)e(r)}function Ht(n){let t;return Fe(n,e=>{e.visible&&(t=ge(t,e.bounds))}),t}function Kt(n){let t=new Set,e=(i,s,o)=>{if(t.has(i.id))throw new l("AI_SCENE_DUPLICATE_ID","lower",`Scene node ID ${i.id} is duplicated.`);if(t.add(i.id),i.parentId!==s)throw new l("AI_SCENE_PARENT_MISMATCH","lower",`Scene node ${i.id} has parent ${i.parentId??"(none)"}, expected ${s??"(none)"}.`);let d=i.type==="Layer"?i.id:o;if(i.layerId!==void 0&&i.layerId!==d)throw new l("AI_SCENE_LAYER_MISMATCH","lower",`Scene node ${i.id} has inconsistent layer ownership.`);if(i.type==="Layer"||i.type==="Group"||i.type==="ClipGroup"||i.type==="SymbolDefinition")for(let c of i.children)e(c,i.id,d)};for(let i of n.children)e(i);let r=new Set(n.layers.map(i=>i.id));for(let i of r)if(!t.has(i))throw new l("AI_SCENE_LAYER_ORPHAN","lower",`Layer ${i} is not present in the scene tree.`)}function Jt(n){let t=0,e=0,r=0;return Fe(n,i=>{t++,i.type==="Path"||i.type==="CompoundPath"?e++:i.type==="Text"&&r++}),{sourceKind:n.sourceFingerprint.sourceKind,artboards:n.artboards.length,layers:n.layers.length,nodes:t,paths:e,textFrames:r,resources:Object.keys(n.resources).length,fidelity:n.fidelity,...Ht(n)===void 0?{}:{bounds:Ht(n)},sourceFingerprint:n.sourceFingerprint}}function Fr(n){return n.fidelity==="partial"?"partial":n.fidelity==="structure-only"?"structure":"unsupported"}function Yt(n){let t={};Fe(n,o=>{o.type==="UnknownNode"&&o.operator!==void 0&&(t[o.operator]=(t[o.operator]??0)+1)});let e=new Set,r=new Set;for(let o of n.unsupportedFeatures){let d=Fr(o);d==="partial"?e.add(o.feature):d==="structure"&&r.add(o.feature)}let i=["lossless-token-order","source-spans","unknown-syntax-preservation"],s=["basic-path-geometry","compound-paths","groups","layers","process-color","stroke-geometry","shared-canvas-artboards"];return{fidelity:n.fidelity,exactFeatures:i,highFeatures:s,partialFeatures:[...e].sort(),structureOnlyFeatures:[...r].sort(),unsupportedFeatures:n.unsupportedFeatures,unknownOperators:t,diagnostics:n.diagnostics}}function qt(n){let t=[...n.diagnostics];return Fe(n,e=>t.push(...e.diagnostics)),t}K();ut();var pt=class{definitions=new Map;register(t){let e=this.definitions.get(t.operator)??[];return e.push(t),e.sort((r,i)=>(i.minVersion??-1/0)-(r.minVersion??-1/0)),this.definitions.set(t.operator,e),this}resolve(t,e){let r=this.definitions.get(t);if(r!==void 0)return r.find(i=>(e===void 0||i.minVersion===void 0||e>=i.minVersion)&&(e===void 0||i.maxVersion===void 0||e<=i.maxVersion))}coverage(){return[...this.definitions.values()].flat().map(({handler:t,...e})=>e).sort((t,e)=>t.operator.localeCompare(e.operator)||t.family.localeCompare(e.family))}};function X(n){return n?.kind==="number"?n.value:void 0}function fe(n){return n?.kind==="string"||n?.kind==="name"?n.value:void 0}function ht(n){if(n?.kind!=="array")return;let t=n.values.map(X);return t.some(e=>e===void 0)?void 0:t}function mt(n,t){if(n.length<t)return;let e=n.slice(-t).map(X);return e.some(r=>r===void 0)?void 0:e}function be(n){return fe(n.at(-1))}function q(n){return structuredClone(n)}function Lr(n){return{...n,transform:oe(n.transform),fill:q(n.fill),stroke:q(n.stroke),dashArray:[...n.dashArray]}}function Ur(n){return n.replace(/\\([nrtbf()\\]|[0-7]{1,3})/gu,(t,e)=>/^[0-7]+$/u.test(e)?String.fromCharCode(Number.parseInt(e,8)):{n:`
2
+ `,r:"\r",t:" ",b:"\b",f:"\f"}[e]??e)}function Br(n){let t=[];for(let r of n.matchAll(/^%AIArtboard\s*:\s*([^|\r\n]+)\|\s*([+-]?[\d.]+)\s+([+-]?[\d.]+)\s+([+-]?[\d.]+)\s+([+-]?[\d.]+)/gimu)){let i=Number(r[2]),s=Number(r[3]),o=Number(r[4]),d=Number(r[5]);[i,s,o,d].every(Number.isFinite)&&t.push({id:ie("artboard",t.length),name:r[1].trim(),bounds:{left:Math.min(i,o),bottom:Math.min(s,d),right:Math.max(i,o),top:Math.max(s,d)},bleed:{top:0,right:0,bottom:0,left:0},rulerOrigin:{x:0,y:0},selected:t.length===0,locked:!1,pixelAspectRatio:1})}let e=n.indexOf("(ArtboardArray)");if(t.length===0&&e>=0){let i=n.slice(Math.max(0,e-524288),e).split(/%_?\s*\/Dictionary\s*:/u),s=String.raw`[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?`;for(let o of i){let d=g=>new RegExp(`(${s})\\s+(${s})\\s+/RealPointRelToROrigin[\\s%_]*\\(${g}\\)`,"u"),c=d("PositionPoint1").exec(o),a=d("PositionPoint2").exec(o),u=/\(((?:\\.|[^\\)])*)\)\s+\/UnicodeString\s+\(Name\)/u.exec(o);if(c===null||a===null||u===null)continue;let h=Number(c[1]),f=Number(c[2]),m=Number(a[1]),I=Number(a[2]);[h,f,m,I].every(Number.isFinite)&&t.push({id:ie("artboard",t.length),name:Ur(u[1]),bounds:{left:Math.min(h,m),bottom:Math.min(f,I),right:Math.max(h,m),top:Math.max(f,I)},bleed:{top:0,right:0,bottom:0,left:0},rulerOrigin:{x:0,y:0},selected:t.length===0,locked:!1,pixelAspectRatio:1})}}if(t.length===0){let r=/%%HiResBoundingBox\s*:\s*([+-]?[\d.]+)\s+([+-]?[\d.]+)\s+([+-]?[\d.]+)\s+([+-]?[\d.]+)/iu.exec(n)??/%%BoundingBox\s*:\s*([+-]?[\d.]+)\s+([+-]?[\d.]+)\s+([+-]?[\d.]+)\s+([+-]?[\d.]+)/iu.exec(n);if(r!==null){let i=r.slice(1).map(Number);i.every(Number.isFinite)&&t.push({id:"artboard-0",name:"Artboard 1",bounds:{left:i[0],bottom:i[1],right:i[2],top:i[3]},bleed:{top:0,right:0,bottom:0,left:0},rulerOrigin:{x:0,y:0},selected:!0,locked:!1,pixelAspectRatio:1})}}return t}var gt=class{ast;source;fingerprint;limits;budget;diagnostics;resources={};layers=[];rootChildren=[];containers=[{children:this.rootChildren}];savedStates=[];unsupported=new Map;state={transform:oe(),fill:ft,stroke:lt,lineWidth:1,lineCap:"butt",lineJoin:"miter",miterLimit:10,dashArray:[],dashOffset:0,fillOpacity:1,strokeOpacity:1,opacity:1,blendMode:"normal",overprintFill:!1,overprintStroke:!1,fillRule:"nonzero"};path={contours:[],statementIndices:[]};text;compound;pendingClipRule;resourceCapture;contentActive=!0;colorMode="unknown";fidelity="high";nodeCounter=0;resourceCounter=0;statementIndex=-1;constructor(t,e,r,i,s){this.ast=t,this.source=e,this.fingerprint=r,this.limits=i,this.budget=s,this.diagnostics=[...t.diagnostics]}build(t){let e=this.fingerprint.featureMarkers.map(c=>Number(/%AI(\d+)/u.exec(c)?.[1])).filter(c=>Number.isFinite(c)&&c>24);e.length>0&&(this.fidelity=ce(this.fidelity,"partial"),this.diagnostics.push(E("AI_FUTURE_VERSION","warning","lower",`Unknown future Illustrator format marker(s): ${e.join(", ")}. Unknown extensions will remain opaque.`)));for(let c=0;c<this.ast.statements.length;c++){this.budget.checkpoint("lower"),this.statementIndex=c;let a=this.ast.statements[c];if(a.kind==="comment"){this.handleComment(a.raw);continue}if(a.kind==="resource"){this.captureRaw(a.raw);let h=ie("binary-resource",this.resourceCounter++);this.resources[h]={id:h,kind:"unknown",raw:a.raw,metadata:{bytes:a.value.byteLength},fidelity:"structure-only",sourceSpan:a.span},this.markUnsupported("binary-resource",!1,"structure-only",c,"Binary resource is preserved but has no registered semantic decoder.");continue}if(a.kind!=="operator")continue;this.captureRaw(a.raw);let u=t.resolve(a.operator,this.fingerprint.creatorVersion);if(u===void 0){this.handleUnknownOperator(a,c);continue}a.operands.length<u.operands.length&&!u.variadic&&this.diagnostics.push(E("AI_OPERATOR_OPERANDS","warning","parse",`Operator ${a.operator} expects at least ${u.operands.length} operand(s), received ${a.operands.length}.`,{sourceSpan:a.span,feature:a.operator}));try{u.handler({builder:this,statement:a,statementIndex:c,operands:a.operands})}catch(h){this.diagnostics.push(E("AI_OPERATOR_HANDLER_FAILED","error","lower",`Operator ${a.operator} could not be lowered: ${h instanceof Error?h.message:String(h)}`,{sourceSpan:a.span,feature:a.operator})),this.handleUnknownOperator(a,c)}}for(this.flushPath(!1,!1,this.state.fillRule,this.ast.statements.at(-1)?.span),this.compound!==void 0&&this.emitCompound(this.compound.fill,this.compound.stroke,this.compound.fillRule,this.ast.statements.at(-1)?.span),this.text!==void 0&&this.endText(this.ast.statements.at(-1)?.span);this.containers.length>1;){let c=this.containers.pop();this.diagnostics.push(E("AI_HIERARCHY_UNCLOSED","warning","lower",`Unclosed ${c.node?.type??"container"} was closed at end of source.`,{nodeId:c.node?.id}))}for(;this.savedStates.length>0;)this.savedStates.pop(),this.diagnostics.push(E("AI_GSTATE_UNCLOSED","warning","lower","Unclosed graphics-state save was discarded at end of source."));let r=Br(this.source),i=this.computeAllBounds();r.length===0&&i!==void 0&&r.push({id:"artboard-0",name:"Artboard 1",bounds:i,bleed:{top:0,right:0,bottom:0,left:0},rulerOrigin:{x:0,y:0},selected:!0,locked:!1,pixelAspectRatio:1});let s=[...this.unsupported.entries()].map(([c,a])=>({feature:c,count:a.count,visible:a.visible,fidelity:a.fidelity,statementIndices:a.statementIndices,diagnostics:a.diagnostics})).sort((c,a)=>c.feature.localeCompare(a.feature)),o=Number(/(?:LargeCanvasScale|largeCanvasScale)\D+([\d.]+)/iu.exec(this.source)?.[1]??1),d={format:"adobe-illustrator.scene",schemaVersion:1,unit:"pt",coordinateSystem:"illustrator-y-up",largeCanvasScale:Number.isFinite(o)&&o>0?o:1,colorMode:this.colorMode,metadata:this.extractMetadata(),artboards:r,layers:this.layers,children:this.rootChildren,resources:this.resources,diagnostics:this.diagnostics,unsupportedFeatures:s,sourceFingerprint:this.fingerprint,fidelity:s.reduce((c,a)=>ce(c,a.fidelity),this.fidelity)};return Kt(d),d}extractMetadata(){let t={};for(let e of["Title","Creator","For","CreationDate","DocumentData","LanguageLevel"]){let r=new RegExp(`^%%${e}\\s*:\\s*([^\\r\\n]+)`,"imu").exec(this.source)?.[1]?.trim();r!==void 0&&(t[e]=r)}return t}currentFrame(){return this.containers[this.containers.length-1]}currentLayerId(){return this.currentFrame().layerId}nodeBase(t,e,r,i,s){let o=this.currentFrame(),d=s??o.node?.id;return{id:ie("node",this.nodeCounter++),...t===void 0?{}:{sourceSpan:t},...d===void 0?{}:{parentId:d},...this.currentLayerId()===void 0?{}:{layerId:this.currentLayerId()},transform:oe(this.state.transform),visible:!0,locked:!1,printable:!0,appearance:e,fidelity:r,diagnostics:[],rawStatementIndices:[...i]}}addNode(t){this.budget.consume("nodes",1,this.limits.maxNodes,"lower"),this.currentFrame().children.push(t)}beginGroup(t,e,r){let i=ae();i.opacity=this.state.opacity,i.blendMode=this.state.blendMode;let s={...this.nodeBase(e,i,"high",[r]),type:t,children:[],isolated:!1,knockout:!1};return this.addNode(s),this.containers.push({node:s,children:s.children,layerId:this.currentLayerId()}),s}endContainer(t,e){for(let r=this.containers.length-1;r>0;r--){let i=this.containers[r];if(i.node!==void 0&&t.includes(i.node.type)){for(;this.containers.length-1>=r;)this.containers.pop();return}}this.diagnostics.push(E("AI_HIERARCHY_UNDERFLOW","warning","lower",`No open ${t.join("/")} exists for closing operator.`,{sourceSpan:e}))}moveTo(t,e,r){let i={start:t,segments:[],closed:!1};this.path.contours.push(i),this.path.current=i,this.path.startedAt??=e,this.path.statementIndices.push(r),this.budget.consume("pathPoints",1,this.limits.maxPathPoints,"lower")}lineTo(t,e,r){this.ensureContour(e,r).segments.push({kind:"line",to:t}),this.path.statementIndices.push(r),this.budget.consume("pathPoints",1,this.limits.maxPathPoints,"lower")}cubicTo(t,e,r,i,s){this.ensureContour(i,s).segments.push({kind:"cubic",control1:t,control2:e,to:r}),this.path.statementIndices.push(s),this.budget.consume("pathPoints",3,this.limits.maxPathPoints,"lower")}closePath(t){this.path.current!==void 0&&(this.path.current.closed=!0,this.path.statementIndices.push(t))}currentPoint(){let t=this.path.current;return t===void 0?{x:0,y:0}:t.segments.at(-1)?.to??t.start}markClip(t){this.pendingClipRule=t}beginCompound(t,e){if(this.compound!==void 0){this.diagnostics.push(E("AI_COMPOUND_NESTED","warning","lower","Nested compound-path start was preserved as unsupported.",{sourceSpan:t})),this.markUnsupported("nested-compound-path",!0,"partial",e,"Nested compound path requires version-specific recovery.");return}this.compound={contours:[],statementIndices:[e],startSpan:t,ready:!1,fill:!1,stroke:!1,fillRule:this.state.fillRule}}endCompound(t,e){if(this.compound===void 0){this.diagnostics.push(E("AI_COMPOUND_UNDERFLOW","warning","lower","Compound-path end has no matching start.",{sourceSpan:t}));return}this.appendPathToCompound(!1,!1,this.state.fillRule),this.compound.statementIndices.push(e),this.compound.ready=!0}flushPath(t,e,r,i){if(this.compound?.ready===!0){this.compound.fill||=t,this.compound.stroke||=e,this.compound.fillRule=r,this.emitCompound(this.compound.fill,this.compound.stroke,r,i);return}if(this.compound!==void 0){this.appendPathToCompound(t,e,r);return}if(this.path.contours.length===0)return;let s={contours:this.path.contours.map(u=>({start:{...u.start},segments:u.segments.map(h=>structuredClone(h)),closed:u.closed})),fillRule:r},o=[...new Set(this.path.statementIndices)],d=this.path.startedAt===void 0?i:{start:this.path.startedAt.start,end:(i??this.path.startedAt).end},c=this.pendingClipRule!==void 0;if(this.path={contours:[],statementIndices:[]},!this.contentActive){this.pendingClipRule=void 0;return}if(c){let u=this.beginGroup("ClipGroup",d??i,o.at(-1)??this.statementIndex),h=this.createPathNode(s,!1,!1,d,o,!0);u.appearance.clippingMask=h.id,this.addNode(h),this.pendingClipRule=void 0;return}let a=this.createPathNode(s,t,e,d,o,!1);this.addNode(a)}appendPathToCompound(t,e,r){this.compound===void 0||this.path.contours.length===0||(this.compound.contours.push(...this.path.contours.map(i=>({start:{...i.start},segments:i.segments.map(s=>structuredClone(s)),closed:i.closed}))),this.compound.statementIndices.push(...this.path.statementIndices),this.compound.fill||=t,this.compound.stroke||=e,this.compound.fillRule=r,this.path={contours:[],statementIndices:[]})}emitCompound(t,e,r,i){let s=this.compound;if(s===void 0||(this.appendPathToCompound(t,e,r),this.compound=void 0,s.contours.length===0||!this.contentActive))return;let o={start:s.startSpan.start,end:(i??s.startSpan).end},d=this.createPathNode({contours:s.contours,fillRule:r},t,e,o,[...new Set(s.statementIndices)],!1,!0);this.addNode(d)}ensureContour(t,e){return this.path.current!==void 0?this.path.current:(this.diagnostics.push(E("AI_PATH_IMPLICIT_MOVE","warning","lower","Path segment appeared before move; an implicit move to (0,0) was inserted.",{sourceSpan:t})),this.moveTo({x:0,y:0},t,e),this.path.current)}appearance(t,e){let r=ae();return t&&this.state.fill.kind!=="none"&&(r.fills=[{paint:q(this.state.fill),opacity:this.state.fillOpacity,overprint:this.state.overprintFill}]),e&&this.state.stroke.kind!=="none"&&(r.strokes=[{paint:q(this.state.stroke),width:this.state.lineWidth,alignment:"center",cap:this.state.lineCap,join:this.state.lineJoin,miterLimit:this.state.miterLimit,dashArray:[...this.state.dashArray],dashOffset:this.state.dashOffset,opacity:this.state.strokeOpacity,overprint:this.state.overprintStroke}]),r.opacity=this.state.opacity,r.blendMode=this.state.blendMode,r}createPathNode(t,e,r,i,s,o,d=!1){let c=[];for(let u of t.contours){c.push(H(this.state.transform,u.start));for(let h of u.segments)h.kind==="cubic"&&c.push(H(this.state.transform,h.control1),H(this.state.transform,h.control2)),c.push(H(this.state.transform,h.to))}return{...this.nodeBase(i,this.appearance(e,r),"high",s),type:d||t.contours.length>1?"CompoundPath":"Path",geometry:t,paintPath:e||r,clippingPath:o,bounds:Ce(c),visible:o||e||r}}saveGraphicsState(){this.savedStates.push({state:Lr(this.state),containerDepth:this.containers.length})}restoreGraphicsState(t){let e=this.savedStates.pop();if(e===void 0){this.diagnostics.push(E("AI_GSTATE_UNDERFLOW","warning","lower","Graphics-state restore has no matching save.",{sourceSpan:t}));return}for(this.state=e.state;this.containers.length>e.containerDepth;)this.containers.pop()}concatTransform(t){this.state.transform=Xe(this.state.transform,t)}setTransform(t){this.state.transform=oe(t)}beginLayer(t,e,r){let i=t.slice(-14).map(X),s=t.slice(-10).map(X),o=i.length===14&&i.every(m=>m!==void 0),d=s.length===10&&s.every(m=>m!==void 0),c=o||d,a=o?i:d?s:[1,1,1,1,0,0,0,79,128,255],u=o?8:7;c||this.diagnostics.push(E("AI_LAYER_FLAGS_INVALID","warning","lower","Layer flags were incomplete; safe defaults were used.",{sourceSpan:e}));let h=ae(),f={...this.nodeBase(e,h,"high",[r]),type:"Layer",children:[],preview:a[1]!==0,visible:a[0]!==0,locked:a[2]===0,printable:a[3]!==0,color:{kind:"rgb",red:_(a[u]/255),green:_(a[u+1]/255),blue:_(a[u+2]/255),alpha:1}};f.layerId=f.id,this.addNode(f),this.layers.push(f),this.containers.push({node:f,children:f.children,layerId:f.id})}nameLayer(t,e){for(let r=this.containers.length-1;r>0;r--){let i=this.containers[r].node;if(i?.type==="Layer"){i.name=t;return}}this.diagnostics.push(E("AI_LAYER_NAME_ORPHAN","warning","lower","Layer name has no open layer.",{sourceSpan:e}))}beginText(t,e,r){this.text!==void 0&&this.endText(e);let i=t===0?"point":t===1?"area":t===2?"path":"unknown";this.text={kind:i,direction:"horizontal",matrix:oe(this.state.transform),position:this.currentPoint(),runs:[],fontSize:12,statementIndices:[r],startSpan:e}}setTextFont(t,e,r){this.text!==void 0&&(t!==void 0&&(this.text.font=t.replace(/^\//u,"")),e!==void 0&&e>0&&(this.text.fontSize=e),this.text.statementIndices.push(r))}setTextMatrix(t,e){this.text===void 0||t.length<6||(this.text.matrix={a:t[0],b:t[1],c:t[2],d:t[3],e:t[4],f:t[5]},this.text.position={x:0,y:0},this.text.statementIndices.push(e))}moveText(t,e,r){this.text!==void 0&&(this.text.position={x:this.text.position.x+t,y:this.text.position.y+e},this.text.statementIndices.push(r))}showText(t,e,r){this.text===void 0&&this.beginText(0,r,e);let i=this.text;i.runs.push({text:t,...i.font===void 0?{}:{fontPostScriptName:i.font},fontSize:i.fontSize,tracking:0,baselineShift:0,horizontalScale:1,verticalScale:1,fill:q(this.state.fill),stroke:q(this.state.stroke),opacity:this.state.opacity}),i.statementIndices.push(e)}endText(t){let e=this.text;if(e===void 0||(this.text=void 0,!this.contentActive))return;let r=e.runs.map(m=>m.text).join(""),i=Math.max(1,e.runs.reduce((m,I)=>m+I.text.length*I.fontSize*.6,0)),s=Math.max(1,e.runs.reduce((m,I)=>Math.max(m,I.fontSize*1.2),e.fontSize*1.2)),o=Xe(e.matrix,{a:1,b:0,c:0,d:1,e:e.position.x,f:e.position.y}),d=-s*.2,c=s*.8,a=Ce([H(o,{x:0,y:d}),H(o,{x:i,y:d}),H(o,{x:i,y:c}),H(o,{x:0,y:c})]),u=ae();e.runs.some(m=>m.fill.kind!=="none")&&(u.fills=[{paint:q(e.runs.find(m=>m.fill.kind!=="none")?.fill??this.state.fill),opacity:this.state.fillOpacity,overprint:this.state.overprintFill}]);let h=[];e.font===void 0?h.push(E("AI_TEXT_FONT_UNKNOWN","warning","resource","Text frame has no resolved PostScript font name.",{feature:"font"})):h.push(E("AI_TEXT_FONT_EXTERNAL","warning","resource",`Font ${e.font} must be resolved by the host before layout can be considered exact.`,{feature:"font"})),e.kind!=="point"&&h.push(E("AI_TEXT_LAYOUT_PARTIAL","warning","lower",`${e.kind} text content is preserved, but full Illustrator layout is not reconstructed.`,{feature:`${e.kind}-text`}));let f={...this.nodeBase({start:e.startSpan.start,end:(t??e.startSpan).end},u,"partial",[...new Set(e.statementIndices)]),type:"Text",textKind:e.kind,direction:e.direction,runs:e.runs,transform:o,...a===void 0?{}:{bounds:a},diagnostics:h};this.addNode(f),this.fidelity=ce(this.fidelity,"partial"),this.markUnsupported(e.kind==="point"?"font-dependent-text-layout":`${e.kind}-text-layout`,!0,"partial",e.statementIndices[0]??this.statementIndex,"Text remains native and selectable, but needs a font resolver and version-specific layout rules.")}beginResource(t,e,r,i="structure-only"){this.resourceCapture!==void 0&&this.endResource(),this.resourceCapture={kind:t,id:ie(`${t}-resource`,this.resourceCounter++),...e===void 0?{}:{name:e},raw:[],startSpan:r,fidelity:i}}captureRaw(t){this.resourceCapture?.raw.push(t)}endResource(){let t=this.resourceCapture;t!==void 0&&(this.resourceCapture=void 0,this.resources[t.id]={id:t.id,kind:t.kind,...t.name===void 0?{}:{name:t.name},sourceSpan:t.startSpan,raw:t.raw.join(""),metadata:{},fidelity:t.fidelity},this.fidelity=ce(this.fidelity,t.fidelity))}addImage(t,e,r){if(!this.contentActive)return;let i=ie(t==="RasterImage"?"image":"link",this.resourceCounter++);this.resources[i]={id:i,kind:"image",sourceSpan:e.span,raw:e.raw,metadata:{operator:e.operator},fidelity:"structure-only"};let s=e.operands.map(X).filter(u=>u!==void 0),o=s.length>=2?Math.abs(s.at(-2)):void 0,d=s.length>=1?Math.abs(s.at(-1)):void 0,c=o!==void 0&&d!==void 0?Ce([H(this.state.transform,{x:0,y:0}),H(this.state.transform,{x:o,y:d})]):void 0,a={...this.nodeBase(e.span,ae(),"structure-only",[r]),type:t,resourceId:i,...o===void 0?{}:{pixelWidth:o},...d===void 0?{}:{pixelHeight:d},linked:t==="PlacedImage",...c===void 0?{}:{bounds:c}};this.addNode(a),this.markUnsupported(t==="RasterImage"?"embedded-raster-decoder":"placed-image-resolver",!0,"structure-only",r,"Image identity and transform are preserved; pixel/link decoding requires a registered resource handler.")}markUnsupported(t,e,r,i,s){let o=this.unsupported.get(t)??{count:0,visible:!1,fidelity:r,statementIndices:[],diagnostics:[]};o.count++,o.visible||=e,o.fidelity=ce(o.fidelity,r),o.statementIndices.includes(i)||o.statementIndices.push(i),o.diagnostics.includes(s)||o.diagnostics.push(s),this.unsupported.set(t,o),this.fidelity=ce(this.fidelity,r)}handleUnknownOperator(t,e){let r=jr(t.operator),i=this.contentActive&&r.visible,s=i?"partial":"structure-only";if(this.markUnsupported(r.name,i,s,e,`Unknown operator ${t.operator} is preserved losslessly and was not executed.`),this.diagnostics.push(E("AI_OPERATOR_UNKNOWN",i?"warning":"info","lower",`Unknown Illustrator operator ${t.operator} was preserved${i?" and may affect visible output":""}.`,{sourceSpan:t.span,feature:t.operator})),!i)return;let o={...this.nodeBase(t.span,ae(),s,[e]),type:"UnknownNode",operator:t.operator,payload:t.raw,visibleImpact:!0,unsupportedReason:`No declarative handler is registered for ${t.operator}.`,visible:!1};this.addNode(o)}handleComment(t){/^%%BeginProlog\b/iu.test(t)||/^%%BeginSetup\b/iu.test(t)?this.contentActive=!1:(/^%%EndProlog\b/iu.test(t)||/^%%EndSetup\b/iu.test(t)||/^%%Page\b/iu.test(t))&&(this.contentActive=!0),/^%AI11_BeginTextDocument\b/iu.test(t)?this.beginResource("font","AI11 Text Document",this.ast.statements[this.statementIndex].span,"structure-only"):/^%AI11_EndTextDocument\b/iu.test(t)&&(this.captureRaw(t),this.endResource(),this.markUnsupported("ai11-text-document",!0,"structure-only",this.statementIndex,"AI11 text resource is preserved; only explicit text operators are lowered."))}computeAllBounds(){let t=r=>{let i=r.bounds;if(r.type==="Layer"||r.type==="Group"||r.type==="ClipGroup"||r.type==="SymbolDefinition"){i=void 0;for(let s of r.children)i=ge(i,t(s));i!==void 0&&(r.bounds=i)}return i},e;for(let r of this.rootChildren)e=ge(e,t(r));return e}};function jr(n){let t=n.toLowerCase();return/gradient|mesh|pattern|symbol|brush|effect|plugin|opacity|blend|mask|raster|image|placed|text|font/iu.test(n)?{name:t.replace(/[^a-z0-9]+/gu,"-")||"unknown-extension",visible:!0}:/^(?:def|bind|begin|end|dict|array|string|dup|exch|pop|put|get|load|where|if|ifelse|for|repeat|loop|exit|currentdict|readonly|executeonly|cvx|cvlit|save|restore|setpagedevice|showpage|findfont|scalefont|setfont|mark|cleartomark)$/u.test(n)?{name:"unexecuted-postscript-program",visible:!1}:{name:"unknown-visible-operator",visible:!0}}function w(n,t,e,r,i={}){n.register({operator:t,family:i.family??"base",operands:e,stateReads:i.stateReads??[],stateWrites:i.stateWrites??[],produces:i.produces??"scene",fidelity:i.fidelity??"high",fixtureId:i.fixtureId??`operator-${t.replace(/[^a-z0-9]/giu,"_")}`,...i.minVersion===void 0?{}:{minVersion:i.minVersion},...i.maxVersion===void 0?{}:{maxVersion:i.maxVersion},...i.variadic===void 0?{}:{variadic:i.variadic},handler:r})}function U(n,t){let e=mt(n.operands,t);return e===void 0&&n.builder.diagnostics.push(E("AI_OPERATOR_NUMBERS","warning","lower",`Operator ${n.statement.operator} requires ${t} numeric operand(s).`,{sourceSpan:n.statement.span})),e}function Vr(n,t,e,r=!1){return({builder:i,statement:s,statementIndex:o})=>{r&&i.closePath(o),i.flushPath(n,t,e,s.span)}}function Wr(n,t){let e=t==="gray"?1:t==="rgb"?3:4;return r=>{let i=U(r,e);if(i===void 0)return;let s=t==="gray"?{kind:t,gray:_(i[0]),alpha:1}:t==="rgb"?{kind:t,red:_(i[0]),green:_(i[1]),blue:_(i[2]),alpha:1}:{kind:t,cyan:_(i[0]),magenta:_(i[1]),yellow:_(i[2]),black:_(i[3]),alpha:1};r.builder.state[n]=s,r.builder.colorMode=t==="gray"?r.builder.colorMode:t}}function Zt(n){return t=>{let e=[...t.operands].reverse().map(fe).find(o=>o!==void 0)??"Unnamed Ink",r=t.operands.map(X).filter(o=>o!==void 0),i=_(r.at(-1)??1),s=r.length>=5?{kind:"cmyk",cyan:_(r[0]),magenta:_(r[1]),yellow:_(r[2]),black:_(r[3]),alpha:1}:q(t.builder.state[n]);t.builder.state[n]={kind:"spot",name:e,tint:i,alternate:s,alpha:1},t.builder.colorMode="cmyk"}}function Qt(n){return t=>{let e=[...t.operands].reverse().map(fe).find(o=>o!==void 0)??"Unnamed Ink",r=t.operands.map(X).filter(o=>o!==void 0),i=_(r.at(-1)??1),s=r.length>=7?{kind:"rgb",red:_(r[4]),green:_(r[5]),blue:_(r[6]),alpha:1}:r.length>=4?{kind:"cmyk",cyan:_(r[0]),magenta:_(r[1]),yellow:_(r[2]),black:_(r[3]),alpha:1}:q(t.builder.state[n]);t.builder.state[n]={kind:"spot",name:e,tint:i,alternate:s,alpha:1},t.builder.colorMode=s.kind==="rgb"?"rgb":"cmyk"}}function Gr(){let n=new pt;w(n,"m",["number","number"],e=>{let r=U(e,2);r&&e.builder.moveTo({x:r[0],y:r[1]},e.statement.span,e.statementIndex)},{stateWrites:["path"],fixtureId:"path-move"}),w(n,"moveto",["number","number"],n.resolve("m").handler,{stateWrites:["path"],fixtureId:"path-moveto"}),w(n,"l",["number","number"],e=>{let r=U(e,2);r&&e.builder.lineTo({x:r[0],y:r[1]},e.statement.span,e.statementIndex)},{stateReads:["path"],stateWrites:["path"],fixtureId:"path-line"}),w(n,"lineto",["number","number"],n.resolve("l").handler,{stateReads:["path"],stateWrites:["path"],fixtureId:"path-lineto"}),w(n,"L",["number","number"],n.resolve("l").handler,{family:"ai5",stateReads:["path"],stateWrites:["path"],fixtureId:"path-line-ai"}),w(n,"c",["number","number","number","number","number","number"],e=>{let r=U(e,6);r&&e.builder.cubicTo({x:r[0],y:r[1]},{x:r[2],y:r[3]},{x:r[4],y:r[5]},e.statement.span,e.statementIndex)},{stateReads:["path"],stateWrites:["path"],fixtureId:"path-cubic"}),w(n,"curveto",["number","number","number","number","number","number"],n.resolve("c").handler,{stateReads:["path"],stateWrites:["path"],fixtureId:"path-curveto"}),w(n,"C",["number","number","number","number","number","number"],n.resolve("c").handler,{family:"ai5",stateReads:["path"],stateWrites:["path"],fixtureId:"path-cubic-ai"}),w(n,"v",["number","number","number","number"],e=>{let r=U(e,4);if(r){let i=e.builder.currentPoint();e.builder.cubicTo(i,{x:r[0],y:r[1]},{x:r[2],y:r[3]},e.statement.span,e.statementIndex)}},{family:"ai3",stateReads:["path"],stateWrites:["path"],fixtureId:"path-cubic-v"}),w(n,"y",["number","number","number","number"],e=>{let r=U(e,4);if(r){let i={x:r[2],y:r[3]};e.builder.cubicTo({x:r[0],y:r[1]},i,i,e.statement.span,e.statementIndex)}},{family:"ai3",stateReads:["path"],stateWrites:["path"],fixtureId:"path-cubic-y"});for(let e of["h","closepath"])w(n,e,[],({builder:r,statementIndex:i})=>r.closePath(i),{stateReads:["path"],stateWrites:["path"],fixtureId:`path-close-${e}`});for(let[e,r,i,s,o]of[["n",!1,!1,"nonzero",!1],["N",!1,!1,"nonzero",!1],["S",!1,!0,"nonzero",!1],["stroke",!1,!0,"nonzero",!1],["s",!1,!0,"nonzero",!0],["f",!0,!1,"nonzero",!1],["F",!0,!1,"nonzero",!1],["fill",!0,!1,"nonzero",!1],["f*",!0,!1,"evenodd",!1],["eofill",!0,!1,"evenodd",!1],["B",!0,!0,"nonzero",!1],["B*",!0,!0,"evenodd",!1],["b",!0,!0,"nonzero",!0],["b*",!0,!0,"evenodd",!0]])w(n,e,[],Vr(r,i,s,o),{stateReads:["path","paint"],stateWrites:["path"],fixtureId:`path-paint-${e}`});w(n,"*",["string"],e=>{let r=be(e.operands),i=r===void 0?void 0:n.resolve(r);i!==void 0&&["n","N","S","s","f","F","B","b","f*","B*","b*"].includes(r)?i.handler(e):e.builder.handleUnknownOperator(e.statement,e.statementIndex)},{family:"ai5",stateReads:["path","paint"],stateWrites:["path"],fixtureId:"path-paint-indirect"}),w(n,"W",[],({builder:e})=>e.markClip("nonzero"),{stateReads:["path"],stateWrites:["clipping"],fixtureId:"clip-nonzero"}),w(n,"W*",[],({builder:e})=>e.markClip("evenodd"),{stateReads:["path"],stateWrites:["clipping"],fixtureId:"clip-evenodd"}),w(n,"clip",[],({builder:e})=>e.markClip("nonzero"),{stateReads:["path"],stateWrites:["clipping"],fixtureId:"clip-ps"}),w(n,"eoclip",[],({builder:e})=>e.markClip("evenodd"),{stateReads:["path"],stateWrites:["clipping"],fixtureId:"clip-eops"}),w(n,"*u",[],({builder:e,statement:r,statementIndex:i})=>e.beginCompound(r.span,i),{family:"ai3",stateWrites:["compound"],fixtureId:"compound-begin"}),w(n,"*U",[],({builder:e,statement:r,statementIndex:i})=>e.endCompound(r.span,i),{family:"ai3",stateWrites:["compound"],fixtureId:"compound-end"}),w(n,"u",[],({builder:e,statement:r,statementIndex:i})=>e.beginGroup("Group",r.span,i),{family:"ai3",stateWrites:["hierarchy"],fixtureId:"group-begin"}),w(n,"U",[],({builder:e,statement:r})=>e.endContainer(["Group","ClipGroup"],r.span),{family:"ai3",stateWrites:["hierarchy"],fixtureId:"group-end"});for(let e of["q","gsave"])w(n,e,[],({builder:r})=>r.saveGraphicsState(),{stateReads:["graphics-state"],stateWrites:["graphics-state"],fixtureId:`gstate-save-${e}`});for(let e of["Q","grestore"])w(n,e,[],({builder:r,statement:i})=>r.restoreGraphicsState(i.span),{stateReads:["graphics-state"],stateWrites:["graphics-state"],fixtureId:`gstate-restore-${e}`});w(n,"cm",["number","number","number","number","number","number"],e=>{let r=U(e,6);r&&e.builder.concatTransform({a:r[0],b:r[1],c:r[2],d:r[3],e:r[4],f:r[5]})},{stateWrites:["transform"],fixtureId:"transform-concat"}),w(n,"concat",["array"],e=>{let r=ht(e.operands.at(-1))??mt(e.operands,6);r?.length===6&&e.builder.concatTransform({a:r[0],b:r[1],c:r[2],d:r[3],e:r[4],f:r[5]})},{stateWrites:["transform"],fixtureId:"transform-concat-array"}),w(n,"setmatrix",["array"],e=>{let r=ht(e.operands.at(-1))??mt(e.operands,6);r?.length===6&&e.builder.setTransform({a:r[0],b:r[1],c:r[2],d:r[3],e:r[4],f:r[5]})},{stateWrites:["transform"],fixtureId:"transform-set"}),w(n,"initmatrix",[],({builder:e})=>e.setTransform(Re),{stateWrites:["transform"],fixtureId:"transform-init"}),w(n,"translate",["number","number"],e=>{let r=U(e,2);r&&e.builder.concatTransform({a:1,b:0,c:0,d:1,e:r[0],f:r[1]})},{stateWrites:["transform"],fixtureId:"transform-translate"}),w(n,"scale",["number","number"],e=>{let r=U(e,2);r&&e.builder.concatTransform({a:r[0],b:0,c:0,d:r[1],e:0,f:0})},{stateWrites:["transform"],fixtureId:"transform-scale"}),w(n,"rotate",["number"],e=>{let r=U(e,1);if(r){let i=r[0]*Math.PI/180,s=Math.cos(i),o=Math.sin(i);e.builder.concatTransform({a:s,b:o,c:-o,d:s,e:0,f:0})}},{stateWrites:["transform"],fixtureId:"transform-rotate"});for(let[e,r,i]of[["g","fill","gray"],["G","stroke","gray"],["setgray","fill","gray"],["rg","fill","rgb"],["RG","stroke","rgb"],["Xa","fill","rgb"],["XA","stroke","rgb"],["setrgbcolor","fill","rgb"],["k","fill","cmyk"],["K","stroke","cmyk"],["setcmykcolor","fill","cmyk"]])w(n,e,Array(i==="gray"?1:i==="rgb"?3:4).fill("number"),Wr(r,i),{stateWrites:[r,"color-mode"],fixtureId:`paint-${e}`});w(n,"x",["any"],Zt("fill"),{family:"ai3",variadic:!0,stateWrites:["fill","color-mode"],fidelity:"partial",fixtureId:"paint-custom-fill"}),w(n,"X",["any"],Zt("stroke"),{family:"ai3",variadic:!0,stateWrites:["stroke","color-mode"],fidelity:"partial",fixtureId:"paint-custom-stroke"}),w(n,"Xk",["any"],Qt("fill"),{family:"ai5",variadic:!0,stateWrites:["fill","color-mode"],fidelity:"partial",fixtureId:"paint-custom-fill-ai5"}),w(n,"XK",["any"],Qt("stroke"),{family:"ai5",variadic:!0,stateWrites:["stroke","color-mode"],fidelity:"partial",fixtureId:"paint-custom-stroke-ai5"}),w(n,"w",["number"],e=>{let r=U(e,1);r&&r[0]>=0&&(e.builder.state.lineWidth=r[0])},{stateWrites:["stroke"],fixtureId:"stroke-width"}),w(n,"setlinewidth",["number"],n.resolve("w").handler,{stateWrites:["stroke"],fixtureId:"stroke-width-ps"}),w(n,"J",["number"],e=>{let r=U(e,1);r&&(e.builder.state.lineCap=r[0]===1?"round":r[0]===2?"square":"butt")},{stateWrites:["stroke"],fixtureId:"stroke-cap"}),w(n,"setlinecap",["number"],n.resolve("J").handler,{stateWrites:["stroke"],fixtureId:"stroke-cap-ps"}),w(n,"j",["number"],e=>{let r=U(e,1);r&&(e.builder.state.lineJoin=r[0]===1?"round":r[0]===2?"bevel":"miter")},{stateWrites:["stroke"],fixtureId:"stroke-join"}),w(n,"setlinejoin",["number"],n.resolve("j").handler,{stateWrites:["stroke"],fixtureId:"stroke-join-ps"}),w(n,"M",["number"],e=>{let r=U(e,1);r&&r[0]>0&&(e.builder.state.miterLimit=r[0])},{stateWrites:["stroke"],fixtureId:"stroke-miter"}),w(n,"setmiterlimit",["number"],n.resolve("M").handler,{stateWrites:["stroke"],fixtureId:"stroke-miter-ps"}),w(n,"d",["array","number"],e=>{let r=X(e.operands.at(-1)),i=ht(e.operands.at(-2));r!==void 0&&i!==void 0&&i.every(s=>s>=0)?(e.builder.state.dashArray=i,e.builder.state.dashOffset=r):e.builder.diagnostics.push(E("AI_DASH_INVALID","warning","lower","Stroke dash operands are invalid.",{sourceSpan:e.statement.span}))},{stateWrites:["stroke"],fixtureId:"stroke-dash"}),w(n,"setdash",["array","number"],n.resolve("d").handler,{stateWrites:["stroke"],fixtureId:"stroke-dash-ps"}),w(n,"Lb",["any"],({builder:e,operands:r,statement:i,statementIndex:s})=>e.beginLayer(r,i.span,s),{family:"ai5",minVersion:5,variadic:!0,stateWrites:["hierarchy"],fixtureId:"layer-begin"}),w(n,"Ln",["string"],({builder:e,operands:r,statement:i})=>e.nameLayer(be(r)??"Unnamed Layer",i.span),{family:"ai5",minVersion:5,stateWrites:["hierarchy"],fixtureId:"layer-name"}),w(n,"LB",[],({builder:e,statement:r})=>e.endContainer(["Layer"],r.span),{family:"ai5",minVersion:5,stateWrites:["hierarchy"],fixtureId:"layer-end"}),w(n,"Mb",["any"],({builder:e,statementIndex:r})=>e.markUnsupported("multi-layer-mask",!0,"structure-only",r,"Multi-layer mask parameters are preserved, but the mask hierarchy is not reconstructed."),{family:"ai8",variadic:!0,produces:"metadata",fidelity:"structure-only",fixtureId:"multilayer-mask-begin"}),w(n,"Md",["any"],({builder:e,statementIndex:r})=>e.markUnsupported("multi-layer-mask",!0,"structure-only",r,"Multi-layer mask definition is opaque."),{family:"ai8",variadic:!0,produces:"metadata",fidelity:"structure-only",fixtureId:"multilayer-mask-define"}),w(n,"MB",[],()=>{},{family:"ai8",produces:"metadata",fidelity:"structure-only",fixtureId:"multilayer-mask-end"}),w(n,"To",["number"],({builder:e,operands:r,statement:i,statementIndex:s})=>e.beginText(X(r.at(-1)),i.span,s),{family:"ai3",stateWrites:["text"],fidelity:"partial",fixtureId:"text-begin-ai"}),w(n,"BT",[],({builder:e,statement:r,statementIndex:i})=>e.beginText(0,r.span,i),{stateWrites:["text"],fidelity:"partial",fixtureId:"text-begin"});for(let e of["TO","ET"])w(n,e,[],({builder:r,statement:i})=>r.endText(i.span),{family:e==="TO"?"ai3":"base",stateWrites:["text"],fidelity:"partial",fixtureId:`text-end-${e}`});w(n,"Tf",["name","number"],({builder:e,operands:r,statementIndex:i})=>e.setTextFont(fe(r.at(-2)),X(r.at(-1)),i),{stateWrites:["text"],fidelity:"partial",fixtureId:"text-font"}),w(n,"Tm",["number","number","number","number","number","number"],e=>{let r=U(e,6);r&&e.builder.setTextMatrix(r,e.statementIndex)},{stateWrites:["text"],fidelity:"partial",fixtureId:"text-matrix"}),w(n,"Tp",["any"],e=>{let r=e.operands.map(X).filter(i=>i!==void 0);r.length>=6&&e.builder.setTextMatrix(r.slice(-6),e.statementIndex)},{family:"ai3",variadic:!0,stateWrites:["text"],fidelity:"partial",fixtureId:"text-path-matrix"}),w(n,"Td",["number","number"],e=>{let r=U(e,2);r&&e.builder.moveText(r[0],r[1],e.statementIndex)},{stateWrites:["text"],fidelity:"partial",fixtureId:"text-move"});for(let e of["Tx","Tj","show"])w(n,e,["string"],({builder:r,operands:i,statement:s,statementIndex:o})=>r.showText(be(i)??"",o,s.span),{family:e==="Tx"?"ai3":"base",stateWrites:["text"],fidelity:"partial",fixtureId:`text-show-${e}`});w(n,"TJ",["array"],({builder:e,operands:r,statement:i,statementIndex:s})=>{let o=r.at(-1),d=o?.kind==="array"?o.values.map(c=>fe(c)??"").join(""):"";e.showText(d,s,i.span)},{stateWrites:["text"],fidelity:"partial",fixtureId:"text-show-array"});for(let e of["XI","image","colorimage"])w(n,e,["any"],({builder:r,statement:i,statementIndex:s})=>r.addImage("RasterImage",i,s),{family:e==="XI"?"ai3":"base",variadic:!0,produces:"scene",fidelity:"structure-only",fixtureId:`image-raster-${e}`});for(let e of["XF","XG"])w(n,e,["any"],({builder:r,statement:i,statementIndex:s})=>r.addImage("PlacedImage",i,s),{family:"ai7",variadic:!0,produces:"scene",fidelity:"structure-only",fixtureId:`image-placed-${e}`});w(n,"Bd",["any"],({builder:e,operands:r,statement:i})=>e.beginResource("gradient",be(r),i.span,"structure-only"),{family:"ai8",variadic:!0,produces:"resource",fidelity:"structure-only",fixtureId:"gradient-definition-begin"}),w(n,"BD",[],({builder:e,statementIndex:r})=>{e.endResource(),e.markUnsupported("gradient-definition",!0,"structure-only",r,"Gradient definition is preserved as an opaque resource.")},{family:"ai8",produces:"resource",fidelity:"structure-only",fixtureId:"gradient-definition-end"}),w(n,"Bg",["any"],({builder:e,statement:r,statementIndex:i})=>e.handleUnknownOperator(r,i),{family:"ai8",variadic:!0,produces:"fallback",fidelity:"partial",fixtureId:"gradient-instance"}),w(n,"Bp",["any"],({builder:e,operands:r,statement:i})=>e.beginResource("pattern",be(r),i.span,"structure-only"),{family:"ai8",variadic:!0,produces:"resource",fidelity:"structure-only",fixtureId:"pattern-begin"}),w(n,"EP",[],({builder:e,statementIndex:r})=>{e.endResource(),e.markUnsupported("pattern-definition",!0,"structure-only",r,"Pattern definition is preserved as an opaque resource.")},{family:"ai8",produces:"resource",fidelity:"structure-only",fixtureId:"pattern-end"}),w(n,"ca",["number"],e=>{let r=U(e,1);r&&(e.builder.state.fillOpacity=_(r[0]))},{family:"ai9",stateWrites:["opacity"],fidelity:"partial",fixtureId:"opacity-fill"}),w(n,"CA",["number"],e=>{let r=U(e,1);r&&(e.builder.state.strokeOpacity=_(r[0]))},{family:"ai9",stateWrites:["opacity"],fidelity:"partial",fixtureId:"opacity-stroke"}),w(n,"setopacityalpha",["number"],e=>{let r=U(e,1);r&&(e.builder.state.opacity=_(r[0]))},{family:"ai9",stateWrites:["opacity"],fidelity:"partial",fixtureId:"opacity-object"}),w(n,"Xy",["any"],e=>{let r=e.operands.map(X).filter(i=>i!==void 0);r.length>=2&&(e.builder.state.opacity=_(r[1]))},{family:"ai9",variadic:!0,stateWrites:["opacity","blend"],fidelity:"partial",fixtureId:"opacity-object-ai"}),w(n,"BM",["name"],({builder:e,operands:r})=>{e.state.blendMode=fe(r.at(-1))??"normal"},{family:"ai9",stateWrites:["blend"],fidelity:"partial",fixtureId:"blend-mode"}),w(n,"op",["boolean"],({builder:e,operands:r})=>{let i=r.at(-1);i?.kind==="boolean"&&(e.state.overprintFill=i.value)},{stateWrites:["overprint"],fidelity:"partial",fixtureId:"overprint-fill"}),w(n,"OP",["boolean"],({builder:e,operands:r})=>{let i=r.at(-1);i?.kind==="boolean"&&(e.state.overprintStroke=i.value)},{stateWrites:["overprint"],fidelity:"partial",fixtureId:"overprint-stroke"}),w(n,"newpath",[],({builder:e,statement:r})=>e.flushPath(!1,!1,e.state.fillRule,r.span),{stateWrites:["path"],produces:"none",fixtureId:"path-new"}),w(n,"initgraphics",[],({builder:e})=>{e.state={transform:oe(),fill:ft,stroke:lt,lineWidth:1,lineCap:"butt",lineJoin:"miter",miterLimit:10,dashArray:[],dashOffset:0,fillOpacity:1,strokeOpacity:1,opacity:1,blendMode:"normal",overprintFill:!1,overprintStroke:!1,fillRule:"nonzero"}},{stateWrites:["graphics-state"],produces:"none",fixtureId:"graphics-init"});let t=["def","bind","begin","end","dict","array","string","dup","exch","pop","put","get","load","where","if","ifelse","for","repeat","loop","exit","currentdict","readonly","executeonly","cvx","cvlit","save","restore","setpagedevice","showpage","findfont","scalefont","setfont","mark","cleartomark","count","index","roll","copy","known","maxlength","currentfile","readstring","readhexstring","flushfile","setflat","sethalftone","setscreen","settransfer","setcolortransfer","setcolorspace","setcolor","setrenderingintent","ri","ddef","xput","npop","Adobe_Illustrator_AI5","Adobe_Illustrator_AI8","terminate","exec","currentpoint","charpath","stringwidth","widthshow","ashow","awidthshow","kshow","rmoveto","rlineto","rcurveto",",",":",";"];for(let e of t)n.resolve(e)===void 0&&w(n,e,[],()=>{},{variadic:!0,produces:"none",fidelity:"structure-only",fixtureId:`program-${e.replace(/[^a-z0-9]/giu,"_")}`});return n}function er(n,t={},e=Gr()){let r=dt(n),i=V(t.limits),s=new B(t.signal,Math.min(t.timeoutMs??i.maxWorkerTimeMs,i.maxWorkerTimeMs)),o=t.sourceFingerprint??{sourceKind:/^%!PS-Adobe/u.test(r)?"direct-postscript":"unknown",featureMarkers:[...new Set([...r.matchAll(/%(AI\d+_[A-Za-z0-9_]+)/gu)].map(d=>`%${d[1]}`))],contradictions:[]};return new gt(n,r,o,i,s).build(e)}G();Z();K();function Le(n,t){switch(n.kind){case"none":return;case"gray":{let e=Math.round(_(n.gray)*255);return`rgba(${e},${e},${e},${_(n.alpha)})`}case"rgb":return`rgba(${Math.round(_(n.red)*255)},${Math.round(_(n.green)*255)},${Math.round(_(n.blue)*255)},${_(n.alpha)})`;case"cmyk":return t.push(E("AI_RENDER_CMYK_APPROXIMATION","warning","render","CMYK paint was approximated in sRGB for Canvas2D.",{feature:"cmyk"})),`rgba(${Math.round(255*(1-_(n.cyan))*(1-_(n.black)))},${Math.round(255*(1-_(n.magenta))*(1-_(n.black)))},${Math.round(255*(1-_(n.yellow))*(1-_(n.black)))},${_(n.alpha)})`;case"lab":{t.push(E("AI_RENDER_LAB_APPROXIMATION","warning","render","Lab paint was approximated as neutral gray for Canvas2D.",{feature:"lab"}));let e=Math.round(_(n.lightness/100)*255);return`rgba(${e},${e},${e},${_(n.alpha)})`}case"spot":return t.push(E("AI_RENDER_SPOT_APPROXIMATION","warning","render",`Spot ink ${n.name} was rendered through its alternate color.`,{feature:"spot-color"})),Le(n.alternate,t);default:t.push(E("AI_RENDER_PAINT_UNSUPPORTED","warning","render",`${n.kind} paint has no resolved Canvas2D resource.`,{feature:n.kind}));return}}function tr(n,t){n.beginPath();for(let e of t.geometry.contours){n.moveTo(e.start.x,e.start.y);for(let r of e.segments)r.kind==="line"?n.lineTo(r.to.x,r.to.y):n.bezierCurveTo(r.control1.x,r.control1.y,r.control2.x,r.control2.y,r.to.x,r.to.y);e.closed&&n.closePath()}}function It(n,t){let e=t.transform;n.transform(e.a,e.b,e.c,e.d,e.e,e.f)}function yt(n){let t=["source-over","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],e=n==="normal"?"source-over":n;return t.includes(e)?e:"source-over"}function zr(n){if("getContext"in n){let t=n.getContext("2d");if(t===null)throw new Error("Canvas2D context is unavailable.");return{context:t,canvas:n}}return{context:n,canvas:n.canvas}}async function bt(n,t,e={}){let r=V(),i=new B(e.signal,r.maxWorkerTimeMs),s=[],o=e.artboardId===void 0?n.artboards[0]:n.artboards.find(A=>A.id===e.artboardId),d=e.viewport??o?.bounds;if(d===void 0)throw new Error("Scene has no artboard or explicit viewport to render.");let c=Math.max(.001,d.right-d.left),a=Math.max(.001,d.top-d.bottom),u=Math.max(1,Math.round(e.width??c)),h=Math.max(1,Math.round(e.height??a)),f=Math.max(.1,e.dpr??globalThis.devicePixelRatio??1),m=Math.max(1,Math.round(u*f)),I=Math.max(1,Math.round(h*f)),g=Math.min(e.maxPixels??r.maxRenderPixels,r.maxRenderPixels);if(m*I>g)throw new Error(`Canvas render exceeds the ${g}-pixel limit.`);let{context:p,canvas:b}=zr(t);b.width=m,b.height=I,typeof HTMLCanvasElement<"u"&&b instanceof HTMLCanvasElement&&(b.style.width=`${u}px`,b.style.height=`${h}px`),p.save(),p.setTransform(1,0,0,1,0,0),p.clearRect(0,0,m,I),e.background!==void 0&&(p.fillStyle=Me(e.background,"transparent"),p.fillRect(0,0,m,I));let x=m/c,D=I/a;p.setTransform(x,0,0,-D,-d.left*x,d.top*D);let S=new Set(e.hiddenLayerIds??[]),T=(A,y=!1)=>{if(p.save(),It(p,A),tr(p,A),y){p.restore();return}p.globalAlpha*=_(A.appearance.opacity),p.globalCompositeOperation=yt(A.appearance.blendMode);for(let v of A.appearance.fills){let P=Le(v.paint,s);P!==void 0&&(p.fillStyle=P,p.globalAlpha*=_(v.opacity),p.fill(A.geometry.fillRule),p.globalAlpha=_(A.appearance.opacity))}for(let v of A.appearance.strokes){let P=Le(v.paint,s);P!==void 0&&(p.strokeStyle=P,p.lineWidth=Math.max(0,v.width),p.lineCap=v.cap,p.lineJoin=v.join,p.miterLimit=Math.max(1,v.miterLimit),p.setLineDash([...v.dashArray]),p.lineDashOffset=v.dashOffset,p.globalAlpha=_(A.appearance.opacity*v.opacity),p.stroke())}p.restore()},k=A=>{if(i.consume("renderNodes",1,r.maxNodes,"render"),!(!A.visible||A.type==="Layer"&&S.has(A.id))){if(A.type==="Path"||A.type==="CompoundPath"){A.clippingPath||T(A);return}if(A.type==="ClipGroup"){p.save();let y=A.children.find(v=>(v.type==="Path"||v.type==="CompoundPath")&&v.clippingPath);if(y!==void 0){It(p,y),tr(p,y),p.clip(y.geometry.fillRule);let v=y.transform;(v.a!==1||v.b!==0||v.c!==0||v.d!==1||v.e!==0||v.f!==0)&&p.setTransform(x,0,0,-D,-d.left*x,d.top*D)}for(let v of A.children)v!==y&&k(v);p.restore();return}if(A.type==="Layer"||A.type==="Group"||A.type==="SymbolDefinition"){p.save(),p.globalAlpha*=_(A.appearance.opacity),p.globalCompositeOperation=yt(A.appearance.blendMode);for(let y of A.children)k(y);p.restore();return}if(A.type==="Text"){p.save(),p.globalCompositeOperation=yt(A.appearance.blendMode),It(p,A),p.scale(1,-1);let y=0,v=0;for(let P of A.runs){let C=Le(P.fill,s);if(C!==void 0){p.fillStyle=C,p.globalAlpha=_(P.opacity);let M=(P.fontPostScriptName??"sans-serif").replace(/["'<>]/gu,"");p.font=`${Math.max(.1,P.fontSize)}px "${M}"`,p.fillText(P.text,y,v)}y+=P.text.length*P.fontSize*.6}p.restore();return}s.push(E("AI_RENDER_NODE_OMITTED","warning","render",`${A.type} ${A.id} has no resolved Canvas2D representation and was omitted.`,{nodeId:A.id,feature:A.type}))}};for(let A of n.children)k(A);return p.restore(),{width:u,height:h,revision:e.revision??0,fidelity:s.some(A=>A.severity==="error")?"partial":n.fidelity,diagnostics:s}}G();Z();K();function Ue(n,t){switch(n.kind){case"none":return"none";case"gray":{let e=Math.round(_(n.gray)*255);return`rgba(${e},${e},${e},${_(n.alpha)})`}case"rgb":return`rgba(${Math.round(_(n.red)*255)},${Math.round(_(n.green)*255)},${Math.round(_(n.blue)*255)},${_(n.alpha)})`;case"cmyk":{let e=255*(1-_(n.cyan))*(1-_(n.black)),r=255*(1-_(n.magenta))*(1-_(n.black)),i=255*(1-_(n.yellow))*(1-_(n.black));return t.push(E("AI_RENDER_CMYK_APPROXIMATION","warning","render","CMYK paint was approximated in sRGB for SVG output.",{feature:"cmyk"})),`rgba(${Math.round(e)},${Math.round(r)},${Math.round(i)},${_(n.alpha)})`}case"lab":{let e=Math.round(_(n.lightness/100)*255);return t.push(E("AI_RENDER_LAB_APPROXIMATION","warning","render","Lab paint was approximated as neutral gray because no ICC transform was supplied.",{feature:"lab"})),`rgba(${e},${e},${e},${_(n.alpha)})`}case"spot":return t.push(E("AI_RENDER_SPOT_APPROXIMATION","warning","render",`Spot ink ${n.name} was rendered through its alternate color.`,{feature:"spot-color"})),Ue(n.alternate,t);default:return t.push(E("AI_RENDER_PAINT_UNSUPPORTED","warning","render",`${n.kind} paint requires a resolved resource and was omitted.`,{feature:n.kind})),"none"}}function Xr(n){let t=[];for(let e of n.geometry.contours){t.push(`M${e.start.x} ${e.start.y}`);for(let r of e.segments)r.kind==="line"?t.push(`L${r.to.x} ${r.to.y}`):t.push(`C${r.control1.x} ${r.control1.y} ${r.control2.x} ${r.control2.y} ${r.to.x} ${r.to.y}`);e.closed&&t.push("Z")}return t.join(" ")}function rr(n){let t=n.transform;return`matrix(${t.a} ${t.b} ${t.c} ${t.d} ${t.e} ${t.f})`}function nr(n){return new Set(["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]).has(n)?n:"normal"}function Hr(n,t={}){let e=V(),r=new B(t.signal,e.maxWorkerTimeMs),i=[],s=t.artboardId===void 0?n.artboards[0]:n.artboards.find(y=>y.id===t.artboardId),o=t.viewport??s?.bounds;if(o===void 0)throw new Error("Scene has no artboard or explicit viewport to export.");let d=Math.max(.001,o.right-o.left),c=Math.max(.001,o.top-o.bottom),a=Math.max(1,Math.round(t.width??d)),u=Math.max(1,Math.round(t.height??c)),h=Math.max(.1,t.dpr??1),f=a*u*h*h,m=Math.min(t.maxPixels??e.maxRenderPixels,e.maxRenderPixels);if(!Number.isFinite(f)||f>m)throw new Error(`SVG viewport exceeds the ${m}-pixel render budget.`);let I=(t.namespace??"ai").replace(/[^A-Za-z0-9_-]/gu,"_").slice(0,64)||"ai",g=new Set(t.hiddenLayerIds??[]),p=[],b=new Set,x=(y,v="")=>{let P=Xr(y),C=`d="${ne(P)}" transform="${rr(y)}" fill-rule="${y.geometry.fillRule}" opacity="${_(y.appearance.opacity)}" style="mix-blend-mode:${nr(y.appearance.blendMode)}" ${v}`,M=[];for(let O of y.appearance.fills)M.push(`<path ${C} fill="${Ue(O.paint,i)}" fill-opacity="${_(O.opacity)}" stroke="none"/>`);for(let O of y.appearance.strokes)M.push(`<path ${C} fill="none" stroke="${Ue(O.paint,i)}" stroke-width="${Math.max(0,O.width)}" stroke-linecap="${O.cap}" stroke-linejoin="${O.join}" stroke-miterlimit="${Math.max(1,O.miterLimit)}" stroke-dasharray="${O.dashArray.join(" ")}" stroke-dashoffset="${O.dashOffset}" stroke-opacity="${_(O.opacity)}"/>`);return M.length===0&&y.clippingPath&&M.push(`<path ${C} fill="black" stroke="none"/>`),M.join("")},D=y=>{if(r.consume("renderNodes",1,e.maxNodes,"render"),!y.visible||y.type==="Layer"&&g.has(y.id))return"";if(b.add(y.id),y.type==="Path"||y.type==="CompoundPath")return y.clippingPath?"":x(y);if(y.type==="Layer"||y.type==="Group"||y.type==="SymbolDefinition"){let v=y.children.map(D).join("");return`<g id="${I}-${ne(y.id)}" opacity="${_(y.appearance.opacity)}" style="mix-blend-mode:${nr(y.appearance.blendMode)}">${v}</g>`}if(y.type==="ClipGroup"){let v=y.children.find(M=>(M.type==="Path"||M.type==="CompoundPath")&&M.clippingPath),P=`${I}-clip-${y.id.replace(/[^A-Za-z0-9_-]/gu,"_")}`;v!==void 0&&p.push(`<clipPath id="${P}" clipPathUnits="userSpaceOnUse">${x(v)}</clipPath>`);let C=y.children.filter(M=>M!==v).map(D).join("");return v===void 0?`<g>${C}</g>`:`<g clip-path="url(#${P})">${C}</g>`}if(y.type==="Text"){let v=0,P=y.runs.map(C=>{let M=ne((C.fontPostScriptName??"sans-serif").replace(/["'<>]/gu,"")),O=ne(C.text),R=`<tspan x="${v}" y="0" font-family="${M}" font-size="${Math.max(.1,C.fontSize)}" fill="${Ue(C.fill,i)}" fill-opacity="${_(C.opacity)}">${O}</tspan>`;return v+=C.text.length*C.fontSize*.6,R}).join("");return`<text transform="${rr(y)} scale(1 -1)">${P}</text>`}return(y.type==="UnknownNode"||y.type==="PluginObject"||y.type==="GradientMesh"||y.type==="RasterImage"||y.type==="PlacedImage"||y.type==="SymbolInstance")&&i.push(E("AI_RENDER_NODE_OMITTED","warning","render",`${y.type} ${y.id} has no safe resolved visual representation and was omitted.`,{nodeId:y.id,feature:y.type})),""},S=n.children.map(D).join(""),T=t.background===void 0?"":`<rect x="${o.left}" y="${-o.top}" width="${d}" height="${c}" fill="${ne(Me(t.background,"transparent"))}"/>`,k=t.includeMetadata===!0?`<metadata>${ne(JSON.stringify({format:n.format,schemaVersion:n.schemaVersion,fidelity:n.fidelity,sourceFingerprint:n.sourceFingerprint,emittedNodeIds:[...b]}))}</metadata>`:"",A=`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${u}" viewBox="${o.left} ${-o.top} ${d} ${c}" role="img" data-fidelity="${n.fidelity}">${k}${p.length===0?"":`<defs>${p.join("")}</defs>`}${T}<g transform="scale(1 -1)">${S}</g></svg>`;if(/<script\b|\son[a-z]+\s*=|<foreignObject\b|(?:href|src)\s*=\s*["'](?:https?:|data:|javascript:)/iu.test(A))throw new Error("Internal SVG safety invariant failed.");return{svg:A,diagnostics:i}}function ir(n,t={}){return Hr(n,t).svg}G();K();Z();Ie();async function Kr(n,t={},e={}){let r=await jt(n,t,e),i=zt(r.bytes,{...t,sourceFingerprint:r.fingerprint}),s=er(i,{...t,sourceFingerprint:r.fingerprint}),o={...s,diagnostics:[...r.diagnostics,...s.diagnostics]},d=qt(o);return{ast:i,scene:o,diagnostics:d}}var wt=class{onDispose;disposed=!1;ast;scene;diagnostics;constructor(t,e){this.onDispose=e,this.ast=t.ast,this.scene=t.scene,this.diagnostics=t.diagnostics}ensure(){if(this.disposed||this.ast===void 0||this.scene===void 0||this.diagnostics===void 0)throw new l("AI_SESSION_DISPOSED","resource","Illustrator document session has been disposed.");return{ast:this.ast,scene:this.scene,diagnostics:this.diagnostics}}async getSummary(){return Jt(this.ensure().scene)}async getArtboards(){return this.ensure().scene.artboards}async getLayerTree(){return this.ensure().scene.layers}async getSupportReport(){return Yt(this.ensure().scene)}async getDiagnostics(){return this.ensure().diagnostics}async getLosslessAst(){return this.ensure().ast}async render(t,e={}){return bt(this.ensure().scene,t,e)}async renderToBitmap(t={}){let e=this.ensure().scene;if(typeof OffscreenCanvas>"u")throw new l("AI_OFFSCREEN_UNAVAILABLE","render","OffscreenCanvas is unavailable; render into an HTMLCanvasElement instead.");let r=t.artboardId===void 0?e.artboards[0]:e.artboards.find(c=>c.id===t.artboardId),i=t.viewport??r?.bounds;if(i===void 0)throw new l("AI_VIEWPORT_MISSING","render","No artboard or viewport is available for bitmap rendering.");let s=Math.max(1,Math.round(t.width??i.right-i.left)),o=Math.max(1,Math.round(t.height??i.top-i.bottom)),d=new OffscreenCanvas(s,o);return await bt(e,d,{...t,width:s,height:o,dpr:1}),d.transferToImageBitmap()}async exportSvg(t={}){return ir(this.ensure().scene,t)}async exportSceneJson(t={}){let e=structuredClone(this.ensure().scene);if(t.includeOpaqueResourceRaw===!1)for(let r of Object.values(e.resources))r.raw="";if(t.includeAstReferences===!1){let r=i=>{if(i.rawStatementIndices=[],i.type==="Layer"||i.type==="Group"||i.type==="ClipGroup"||i.type==="SymbolDefinition")for(let s of i.children)r(s)};for(let i of e.children)r(i)}return e}async trimCache(t){this.ensure()}dispose(){this.disposed||(this.disposed=!0,this.ast=void 0,this.scene=void 0,this.diagnostics=void 0,this.onDispose())}},Be=class{options;disposed=!1;sessions=new Set;runtime;constructor(t={},e={}){this.options=t,this.runtime=e.codecProvider===void 0&&e.zstdDecoder===void 0?{codecProvider:Oe(t.zstdDecoder)}:e}async open(t,e={}){if(this.disposed)throw new l("AI_ENGINE_DISPOSED","resource","Illustrator engine has been disposed.");let r=V({...this.options.limits,...e.limits}),i=await Te(t),s=await Kr(i,{...e,limits:r,timeoutMs:e.timeoutMs??this.options.defaultTimeoutMs},this.runtime),o;return o=new wt(s,()=>this.sessions.delete(o)),this.sessions.add(o),o}dispose(){if(!this.disposed){this.disposed=!0;for(let t of[...this.sessions])t.dispose();this.sessions.clear()}}};G();function xt(n){return n instanceof l?{name:n.name,code:n.code,stage:n.stage,message:n.message,diagnostics:n.diagnostics,...n.stack===void 0?{}:{stack:n.stack}}:n instanceof DOMException&&n.name==="AbortError"?{name:n.name,code:"AI_ABORTED",stage:"resource",message:n.message||"The Illustrator operation was aborted."}:{name:n instanceof Error?n.name:"Error",code:"AI_WORKER_UNEXPECTED",stage:"resource",message:n instanceof Error?n.message:String(n),...n instanceof Error&&n.stack!==void 0?{stack:n.stack}:{}}}function Jr(n){return"sessionId"in n?n.sessionId:void 0}function sr(n,t={}){let e=new Be({forceDirect:!0,limits:t.limits,defaultTimeoutMs:t.defaultTimeoutMs,zstdDecoder:t.zstdDecoder}),r=new Map,i=new Map,s=1,o=!1,d=(u,h=[])=>{(!o||u.ok||u.requestId>=0)&&n.postMessage(u,h)},c=u=>{let h=Jr(u),f=h===void 0?void 0:r.get(h);if(f===void 0)throw new l("AI_SESSION_UNKNOWN","resource",`Unknown or disposed Illustrator session ${String(h)}.`);return f},a=async u=>{if(!Number.isSafeInteger(u.requestId)||u.requestId<0)return;if(u.type==="cancel"){i.get(u.targetRequestId)?.abort(new DOMException("The operation was cancelled by the host.","AbortError")),d({requestId:u.requestId,ok:!0,result:null});return}if(o){d({requestId:u.requestId,ok:!1,error:xt(new l("AI_ENGINE_DISPOSED","resource","Illustrator worker runtime has been disposed."))});return}if(i.has(u.requestId)){d({requestId:u.requestId,ok:!1,error:xt(new l("AI_REQUEST_DUPLICATE","resource",`Duplicate worker request ID ${u.requestId}.`))});return}let h=new AbortController;i.set(u.requestId,h);try{switch(u.type){case"open":{let f=await e.open(new Uint8Array(u.bytes),{...u.options,signal:h.signal}),m=s++;r.set(m,f),d({requestId:u.requestId,ok:!0,result:{sessionId:m}});return}case"getSummary":d({requestId:u.requestId,ok:!0,result:await c(u).getSummary()});return;case"getArtboards":d({requestId:u.requestId,ok:!0,result:await c(u).getArtboards()});return;case"getLayers":d({requestId:u.requestId,ok:!0,result:await c(u).getLayerTree()});return;case"getSupportReport":d({requestId:u.requestId,ok:!0,result:await c(u).getSupportReport()});return;case"getDiagnostics":d({requestId:u.requestId,ok:!0,result:await c(u).getDiagnostics()});return;case"getLosslessAst":d({requestId:u.requestId,ok:!0,result:await c(u).getLosslessAst()});return;case"renderBitmap":{let f=c(u),m=await f.renderToBitmap({...u.options,signal:h.signal}),I=await f.getSupportReport(),g={bitmap:m,render:{width:m.width,height:m.height,revision:u.options.revision??0,fidelity:I.fidelity,diagnostics:I.diagnostics.filter(p=>p.stage==="render")}};d({requestId:u.requestId,ok:!0,result:g},[m]);return}case"exportSvg":d({requestId:u.requestId,ok:!0,result:await c(u).exportSvg({...u.options,signal:h.signal})});return;case"exportScene":d({requestId:u.requestId,ok:!0,result:await c(u).exportSceneJson(u.options)});return;case"trimCache":await c(u).trimCache(u.maxBytes),d({requestId:u.requestId,ok:!0,result:null});return;case"disposeSession":{c(u).dispose(),r.delete(u.sessionId),d({requestId:u.requestId,ok:!0,result:null});return}case"disposeEngine":{for(let f of r.values())f.dispose();r.clear(),e.dispose(),d({requestId:u.requestId,ok:!0,result:null}),o=!0,n.close?.();return}}}catch(f){d({requestId:u.requestId,ok:!1,error:xt(f)})}finally{i.delete(u.requestId)}};return n.addEventListener("message",u=>{a(u.data)}),{dispose(){if(!o){o=!0;for(let u of i.values())u.abort(new DOMException("The worker runtime was disposed.","AbortError"));i.clear();for(let u of r.values())u.dispose();r.clear(),e.dispose()}}}}var Yr=ArrayBuffer,F=Uint8Array,je=Uint16Array,qr=Int16Array;var Ve=Int32Array,At=function(n,t,e){if(F.prototype.slice)return F.prototype.slice.call(n,t,e);(t==null||t<0)&&(t=0),(e==null||e>n.length)&&(e=n.length);var r=new F(e-t);return r.set(n.subarray(t,e)),r},xe=function(n,t,e,r){if(F.prototype.fill)return F.prototype.fill.call(n,t,e,r);for((e==null||e<0)&&(e=0),(r==null||r>n.length)&&(r=n.length);e<r;++e)n[e]=t;return n},Zr=function(n,t,e,r){if(F.prototype.copyWithin)return F.prototype.copyWithin.call(n,t,e,r);for((e==null||e<0)&&(e=0),(r==null||r>n.length)&&(r=n.length);e<r;)n[t++]=n[e++]};var Qr=["invalid zstd data","window size too large (>2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],$=function(n,t,e){var r=new Error(t||Qr[n]);if(r.code=n,Error.captureStackTrace&&Error.captureStackTrace(r,$),!e)throw r;return r},or=function(n,t,e){for(var r=0,i=0;r<e;++r)i|=n[t++]<<(r<<3);return i},en=function(n,t){return(n[t]|n[t+1]<<8|n[t+2]<<16|n[t+3]<<24)>>>0},tn=function(n,t){var e=n[0]|n[1]<<8|n[2]<<16;if(e==3126568&&n[3]==253){var r=n[4],i=r>>5&1,s=r>>2&1,o=r&3,d=r>>6;r&8&&$(0);var c=6-i,a=o==3?4:o,u=or(n,c,a);c+=a;var h=d?1<<d:i,f=or(n,c,h)+(d==1&&256),m=f;if(!i){var I=1<<10+(n[5]>>3);m=I+(I>>3)*(n[5]&7)}m>2145386496&&$(1);var g=new F((t==1?f||m:t?0:m)+12);return g[0]=1,g[4]=4,g[8]=8,{b:c+h,y:0,l:0,d:u,w:t&&t!=1?t:g.subarray(12),e:m,o:new Ve(g.buffer,0,3),u:f,c:s,m:Math.min(131072,m)}}else if((e>>4|n[3]<<20)==25481893)return en(n,4)+8;$(0)},de=function(n){for(var t=0;1<<t<=n;++t);return t-1},Ae=function(n,t,e){var r=(t<<3)+4,i=(n[t]&15)+5;i>e&&$(3);for(var s=1<<i,o=s,d=-1,c=-1,a=-1,u=s,h=new Yr(512+(s<<2)),f=new qr(h,0,256),m=new je(h,0,256),I=new je(h,512,s),g=512+(s<<1),p=new F(h,g,s),b=new F(h,g+s);d<255&&o>0;){var x=de(o+1),D=r>>3,S=(1<<x+1)-1,T=(n[D]|n[D+1]<<8|n[D+2]<<16)>>(r&7)&S,k=(1<<x)-1,A=S-o-1,y=T&k;if(y<A?(r+=x,T=y):(r+=x+1,T>k&&(T-=A)),f[++d]=--T,T==-1?(o+=T,p[--u]=d):o-=T,!T)do{var v=r>>3;c=(n[v]|n[v+1]<<8)>>(r&7)&3,r+=2,d+=c}while(c==3)}(d>255||o)&&$(0);for(var P=0,C=(s>>1)+(s>>3)+3,M=s-1,O=0;O<=d;++O){var R=f[O];if(R<1){m[O]=-R;continue}for(a=0;a<R;++a){p[P]=O;do P=P+C&M;while(P>=u)}}for(P&&$(0),a=0;a<s;++a){var N=m[p[a]]++,W=b[a]=i-de(N);I[a]=(N<<W)-s}return[r+7>>3,{b:i,s:p,n:b,t:I}]},rn=function(n,t){var e=0,r=-1,i=new F(292),s=n[t],o=i.subarray(0,256),d=i.subarray(256,268),c=new je(i.buffer,268);if(s<128){var a=Ae(n,t+1,6),u=a[0],h=a[1];t+=s;var f=u<<3,m=n[t];m||$(0);for(var I=0,g=0,p=h.b,b=p,x=(++t<<3)-8+de(m);x-=p,!(x<f);){var D=x>>3;if(I+=(n[D]|n[D+1]<<8)>>(x&7)&(1<<p)-1,o[++r]=h.s[I],x-=b,x<f)break;D=x>>3,g+=(n[D]|n[D+1]<<8)>>(x&7)&(1<<b)-1,o[++r]=h.s[g],p=h.n[I],I=h.t[I],b=h.n[g],g=h.t[g]}++r>255&&$(0)}else{for(r=s-127;e<r;e+=2){var S=n[++t];o[e]=S>>4,o[e+1]=S&15}++t}var T=0;for(e=0;e<r;++e){var k=o[e];k>11&&$(0),T+=k&&1<<k-1}var A=de(T)+1,y=1<<A,v=y-T;for(v&v-1&&$(0),o[r++]=de(v)+1,e=0;e<r;++e){var k=o[e];++d[o[e]=k&&A+1-k]}var P=new F(y<<1),C=P.subarray(0,y),M=P.subarray(y);for(c[A]=0,e=A;e>0;--e){var O=c[e];xe(M,e,O,c[e-1]=O+d[e]*(1<<A-e))}for(c[0]!=y&&$(0),e=0;e<r;++e){var R=o[e];if(R){var N=c[R];xe(C,e,N,c[R]=N+(1<<A-R))}}return[t,{n:M,b:A,s:C}]},nn=Ae(new F([81,16,99,140,49,198,24,99,12,33,196,24,99,102,102,134,70,146,4]),0,6)[1],sn=Ae(new F([33,20,196,24,99,140,33,132,16,66,8,33,132,16,66,8,33,68,68,68,68,68,68,68,68,36,9]),0,6)[1],on=Ae(new F([32,132,16,66,102,70,68,68,68,68,36,73,2]),0,5)[1],cr=function(n,t){for(var e=n.length,r=new Ve(e),i=0;i<e;++i)r[i]=t,t+=1<<n[i];return r},_t=new F(new Ve([0,0,0,0,16843009,50528770,134678020,202050057,269422093]).buffer,0,36),an=cr(_t,0),vt=new F(new Ve([0,0,0,0,0,0,0,0,16843009,50528770,117769220,185207048,252579084,16]).buffer,0,53),cn=cr(vt,3),we=function(n,t,e){var r=n.length,i=t.length,s=n[r-1],o=(1<<e.b)-1,d=-e.b;s||$(0);for(var c=0,a=e.b,u=(r<<3)-8+de(s)-a,h=-1;u>d&&h<i;){var f=u>>3,m=(n[f]|n[f+1]<<8|n[f+2]<<16)>>(u&7);c=(c<<a|m)&o,t[++h]=e.s[c],u-=a=e.n[c]}(u!=d||h+1!=i)&&$(0)},dn=function(n,t,e){var r=6,i=t.length,s=i+3>>2,o=s<<1,d=s+o;we(n.subarray(r,r+=n[0]|n[1]<<8),t.subarray(0,s),e),we(n.subarray(r,r+=n[2]|n[3]<<8),t.subarray(s,o),e),we(n.subarray(r,r+=n[4]|n[5]<<8),t.subarray(o,d),e),we(n.subarray(r),t.subarray(d),e)},un=function(n,t,e){var r,i=t.b,s=n[i],o=s>>1&3;t.l=s&1;var d=s>>3|n[i+1]<<5|n[i+2]<<13,c=(i+=3)+d;if(o==1)return i>=n.length?void 0:(t.b=i+1,e?(xe(e,n[i],t.y,t.y+=d),e):xe(new F(d),n[i]));if(!(c>n.length)){if(o==0)return t.b=c,e?(e.set(n.subarray(i,c),t.y),t.y+=d,e):At(n,i,c);if(o==2){var a=n[i],u=a&3,h=a>>2&3,f=a>>4,m=0,I=0;u<2?h&1?f|=n[++i]<<4|(h&2&&n[++i]<<12):f=a>>3:(I=h,h<2?(f|=(n[++i]&63)<<4,m=n[i]>>6|n[++i]<<2):h==2?(f|=n[++i]<<4|(n[++i]&3)<<12,m=n[i]>>2|n[++i]<<6):(f|=n[++i]<<4|(n[++i]&63)<<12,m=n[i]>>6|n[++i]<<2|n[++i]<<10)),++i;var g=e?e.subarray(t.y,t.y+t.m):new F(t.m),p=g.length-f;if(u==0)g.set(n.subarray(i,i+=f),p);else if(u==1)xe(g,n[i++],p);else{var b=t.h;if(u==2){var x=rn(n,i);m+=i-(i=x[0]),t.h=b=x[1]}else b||$(0);(I?dn:we)(n.subarray(i,i+=m),g.subarray(p),b)}var D=n[i++];if(D){D==255?D=(n[i++]|n[i++]<<8)+32512:D>127&&(D=D-128<<8|n[i++]);var S=n[i++];S&3&&$(0);for(var T=[sn,on,nn],k=2;k>-1;--k){var A=S>>(k<<1)+2&3;if(A==1){var y=new F([0,0,n[i++]]);T[k]={s:y.subarray(2,3),n:y.subarray(0,1),t:new je(y.buffer,0,1),b:0}}else A==2?(r=Ae(n,i,9-(k&1)),i=r[0],T[k]=r[1]):A==3&&(t.t||$(0),T[k]=t.t[k])}var v=t.t=T,P=v[0],C=v[1],M=v[2],O=n[c-1];O||$(0);var R=(c<<3)-8+de(O)-M.b,N=R>>3,W=0,_e=(n[N]|n[N+1]<<8)>>(R&7)&(1<<M.b)-1;N=(R-=C.b)>>3;var ve=(n[N]|n[N+1]<<8)>>(R&7)&(1<<C.b)-1;N=(R-=P.b)>>3;var De=(n[N]|n[N+1]<<8)>>(R&7)&(1<<P.b)-1;for(++D;--D;){var We=M.s[_e],Dt=M.n[_e],Ge=P.s[De],kt=P.n[De],Et=C.s[ve],St=C.n[ve];N=(R-=Et)>>3;var Tt=1<<Et,re=Tt+((n[N]|n[N+1]<<8|n[N+2]<<16|n[N+3]<<24)>>>(R&7)&Tt-1);N=(R-=vt[Ge])>>3;var he=cn[Ge]+((n[N]|n[N+1]<<8|n[N+2]<<16)>>(R&7)&(1<<vt[Ge])-1);N=(R-=_t[We])>>3;var ke=an[We]+((n[N]|n[N+1]<<8|n[N+2]<<16)>>(R&7)&(1<<_t[We])-1);if(N=(R-=Dt)>>3,_e=M.t[_e]+((n[N]|n[N+1]<<8)>>(R&7)&(1<<Dt)-1),N=(R-=kt)>>3,De=P.t[De]+((n[N]|n[N+1]<<8)>>(R&7)&(1<<kt)-1),N=(R-=St)>>3,ve=C.t[ve]+((n[N]|n[N+1]<<8)>>(R&7)&(1<<St)-1),re>3)t.o[2]=t.o[1],t.o[1]=t.o[0],t.o[0]=re-=3;else{var Ee=re-(ke!=0);Ee?(re=Ee==3?t.o[0]-1:t.o[Ee],Ee>1&&(t.o[2]=t.o[1]),t.o[1]=t.o[0],t.o[0]=re):re=t.o[0]}for(var k=0;k<ke;++k)g[W+k]=g[p+k];W+=ke,p+=ke;var pe=W-re;if(pe<0){var me=-pe,lr=t.e+pe;me>he&&(me=he);for(var k=0;k<me;++k)g[W+k]=t.w[lr+k];W+=me,he-=me,pe=0}for(var k=0;k<he;++k)g[W+k]=g[pe+k];W+=he}if(W!=p)for(;p<g.length;)g[W++]=g[p++];else W=g.length;e?t.y+=W:g=At(g,0,W)}else if(e){if(t.y+=f,p)for(var k=0;k<f;++k)g[k]=g[p+k]}else p&&(g=At(g,p));return t.b=c,g}$(2)}},ar=function(n,t){if(n.length==1)return n[0];for(var e=new F(t),r=0,i=0;r<n.length;++r){var s=n[r];e.set(s,i),i+=s.length}return e};var dr=(function(){function n(t){this.ondata=t,this.c=[],this.l=0,this.z=0}return n.prototype.push=function(t,e){if(typeof this.s=="number"){var r=Math.min(t.length,this.s);t=t.subarray(r),this.s-=r}var i=t.length,s=i+this.l;if(!this.s){if(e){if(!s){this.ondata(new F(0),!0);return}s<5&&$(5)}else if(s<18){this.c.push(t),this.l=s;return}if(this.l&&(this.c.push(t),t=ar(this.c,s),this.c=[],this.l=0),typeof(this.s=tn(t))=="number")return this.push(t,e)}if(typeof this.s!="number"){if(s<(this.z||3)){e&&$(5),this.c.push(t),this.l=s;return}if(this.l&&(this.c.push(t),t=ar(this.c,s),this.c=[],this.l=0),!this.z&&s<(this.z=t[this.s.b]&2?4:3+(t[this.s.b]>>3|t[this.s.b+1]<<5|t[this.s.b+2]<<13))){e&&$(5),this.c.push(t),this.l=s;return}else this.z=0;for(;;){var o=un(t,this.s);if(o)this.ondata(o,!1),Zr(this.s.w,0,o.length),this.s.w.set(o,this.s.w.length-o.length);else{e&&$(5);var d=t.subarray(this.s.b);this.s.b=0,this.c.push(d),this.l+=d.length;return}if(this.s.l){var c=t.subarray(this.s.b);this.s=this.s.c*4,this.push(c,e);return}}}else e&&$(5)},n})();async function ur(n,t,e){if(!Number.isSafeInteger(t)||t<=0)throw new l("AI_DECODE_OUTPUT_LIMIT","decode","The zstd output limit must be a positive safe integer.");if(e?.aborted===!0)throw new l("AI_ABORTED","decode","The Illustrator zstd decode operation was aborted.");let r=[],i=0,s=!1;try{new dr((a,u)=>{if(e?.aborted===!0)throw new l("AI_ABORTED","decode","The Illustrator zstd decode operation was aborted.");if(a.byteLength>t-i)throw new l("AI_DECODE_OUTPUT_LIMIT","decode",`Zstd output exceeds the ${t}-byte limit.`);i+=a.byteLength,a.byteLength>0&&r.push(a),s=u===!0}).push(n,!0)}catch(c){throw c instanceof l?c:new l("AI_CODEC_FAILED","decode",`Zstd decompression failed: ${c instanceof Error?c.message:String(c)}`)}if(!s)throw new l("AI_CODEC_FAILED","decode","Zstd decompression ended without a complete frame.");let o=new Uint8Array(i),d=0;for(let c of r)o.set(c,d),d+=c.byteLength;return o}sr(self,{zstdDecoder:ur});