@pretextbook/import 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import-mode-C8xFGO8j.cjs +115 -0
- package/dist/{import-mode-G2KcSH17.js → import-mode-Dc8qmZP6.js} +1698 -1685
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/lib/pretext-divisions.d.ts +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.js +1 -1
- package/package.json +1 -1
- package/dist/import-mode-DlOXwZkx.cjs +0 -115
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./import-mode-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./import-mode-C8xFGO8j.cjs"),S={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",pdf:"application/pdf",eps:"application/postscript",ps:"application/postscript",bmp:"image/bmp",tiff:"image/tiff",tif:"image/tiff",webp:"image/webp",ico:"image/vnd.microsoft.icon"};function v(t){const o=t.split(".").pop()?.toLowerCase()??"";return S[o]??"application/octet-stream"}const f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function M(t){const o=t.length,r=[];for(let n=0;n<o;n+=3){const i=t[n],s=n+1<o,l=n+2<o,c=s?t[n+1]:0,u=l?t[n+2]:0;r.push(f[i>>2]),r.push(f[(i&3)<<4|c>>4]),r.push(s?f[(c&15)<<2|u>>6]:"="),r.push(l?f[u&63]:"=")}return r.join("")}function R(t){return{ref:t.ref,kind:"file",title:t.fileName,short_description:t.fileName,file:{filename:t.fileName,content_type:v(t.fileName),data:M(t.data)}}}function j(t){return{title:t.title,docinfo:t.docinfo,document_type:t.documentKind,divisions_attributes:t.divisions.map(o=>({ref:o.xmlId,source:o.content,source_format:o.sourceFormat,is_root:o.isRoot})),assets_attributes:t.assets.map(R)}}const P={mainSourcePath:"source/main.ptx",publicationPath:"publication/publication.ptx",projectFilePath:"project.ptx",docinfoPath:"source/docinfo.ptx"};function g(t){return e.findAnyElement(t,"pretext")?t:`<pretext>
|
|
2
2
|
${t}
|
|
3
3
|
</pretext>`}function h(t,o,r){const n=new Map,i=[],s=`${o}-`;return t.forEach((l,c)=>{const u=l.attributes["xml:id"];let p;if(u){const d=e.slugify(u);p=d.startsWith(s)?d:`${s}${d}`}else p=`${s}${e.padIndex(c+1,t.length)}`,r.push({action:"anomaly",severity:"info",kind:"structure",category:"missing_xml_id",macro:l.name,occurrences:1,message:`<${l.name}> at position ${c+1} has no xml:id; using \`${p}\` as filename.`});const m=n.get(p)??0;n.set(p,m+1);const a=m===0?p:`${p}-${m+1}`;i.push({span:l,slug:a,filename:`${a}.ptx`})}),i}function E(t,o,r,n){const i=e.findTopLevelElements(t,"section");if(i.length===0)return t;const l=h(i,"sec",n).map(c=>{const u=`source/${o}/${c.filename}`;return r[u]=e.withProlog(c.span.outer),{start:c.span.start,end:c.span.end,replacement:`<xi:include href="${o}/${c.filename}"/>`}});return e.spliceReplacements(t,l)}function _(t,o,r){const n=e.findAnyElement(t,"book");if(!n)return r.push({action:"anomaly",severity:"warning",kind:"structure",category:"missing_root",macro:"book",occurrences:1,message:"Document was treated as a book but no <book> element found; emitting as a single file."}),T(t,o);const i={},s=e.findTopLevelElements(n.inner,"chapter");let l=n.inner;if(o.splitChapters&&s.length>0){const m=h(s,"ch",r).map(a=>{let d=a.span.outer;if(o.splitSections){const b=a.span.inner,F=E(b,a.slug,i,r);d=a.span.outer.slice(0,a.span.startTagEnd-a.span.start)+F+a.span.outer.slice(a.span.contentEnd-a.span.start)}const x=`source/${a.filename}`;return i[x]=e.withProlog(d),{start:a.span.start,end:a.span.end,replacement:`<xi:include href="${a.filename}"/>`}});l=e.spliceReplacements(n.inner,m)}const c=t.slice(n.start,n.startTagEnd)+l+t.slice(n.contentEnd,n.end),u=t.slice(0,n.start)+c+t.slice(n.end);return i[o.mainSourcePath]=e.withProlog(e.ensureXIncludeNamespace(g(u.trim()))),i}function T(t,o,r){const n={};return n[o.mainSourcePath]=e.withProlog(g(t.trim())),n}function A(t,o={}){const r=[],n=o.documentKind??e.detectDocumentKind(t),i={splitChapters:o.splitChapters??n==="book",splitSections:o.splitSections??!1,mainSourcePath:o.mainSourcePath??P.mainSourcePath,publicationPath:o.publicationPath??P.publicationPath,projectFilePath:o.projectFilePath??P.projectFilePath,docinfoPath:o.docinfoPath??P.docinfoPath},s=n==="book"?_(t,i,r):T(t,i);return s[i.projectFilePath]=e.renderProjectPtx({mainSource:i.mainSourcePath,publication:i.publicationPath}),s[i.publicationPath]=e.renderPublicationPtx(),{files:s,documentKind:n,warnings:r}}exports.LATEX_FORMAT_MARKERS=e.LATEX_FORMAT_MARKERS;exports.MARKDOWN_FORMAT_MARKERS=e.MARKDOWN_FORMAT_MARKERS;exports.PRETEXT_DIVISION_TAGS=e.PRETEXT_DIVISION_TAGS;exports.PRETEXT_ROOT_TAGS=e.PRETEXT_ROOT_TAGS;exports.analyzeImportSources=e.analyzeImportSources;exports.assetsForImportMode=e.assetsForImportMode;exports.attachLatexRoots=e.attachLatexRoots;exports.attachMarkdownRoots=e.attachMarkdownRoots;exports.buildDivisionPool=e.buildDivisionPool;exports.buildNativeDivisionPool=e.buildNativeDivisionPool;exports.carryOverProjectFiles=e.carryOverProjectFiles;exports.cleanLatex=e.cleanLatex;exports.convertLatexToPretext=e.convertLatexToPretext;exports.convertMarkdownToPretext=e.convertMarkdownToPretext;exports.convertSourceToPretext=e.convertSourceToPretext;exports.defaultAttachLevel=e.defaultAttachLevel;exports.defaultManifestTarget=e.defaultManifestTarget;exports.detectDocumentKind=e.detectDocumentKind;exports.detectSourceFormat=e.detectSourceFormat;exports.divisionChildRefs=e.divisionChildRefs;exports.expandPretextIncludes=e.expandPretextIncludes;exports.extractUpload=e.extractUpload;exports.filePrefixForDivision=e.filePrefixForDivision;exports.filesForImportMode=e.filesForImportMode;exports.findProjectManifest=e.findProjectManifest;exports.formatWarningLine=e.formatWarningLine;exports.getConversionErrorMessage=e.getConversionErrorMessage;exports.handleImportUploadFile=e.handleImportUploadFile;exports.importProjectFromFiles=e.importProjectFromFiles;exports.isDivisionTag=e.isDivisionTag;exports.normalizePretextSource=e.normalizePretextSource;exports.parseProjectManifest=e.parseProjectManifest;exports.projectForImportMode=e.projectForImportMode;exports.renderProjectPtx=e.renderProjectPtx;exports.renderProjectPtxFromManifest=e.renderProjectPtxFromManifest;exports.renderPublicationPtx=e.renderPublicationPtx;exports.resolveSplitLevel=e.resolveSplitLevel;exports.sanitizeRef=e.sanitizeRef;exports.serializeProjectToFiles=e.serializeProjectToFiles;exports.buildPretextProjectFiles=A;exports.serializeProjectToPlusPayload=j;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as j, r as v, a as R, f as g, b as h, w as P, s as b, e as A, c as M, p as $ } from "./import-mode-
|
|
2
|
-
import { L as B, M as W, P as X, g as G, h as U, i as H, j as q, k as J, l as Q, m as V, n as Y, o as Z, q as tt, t as et, u as nt, v as at, x as st, y as ot, z as it, A as rt, B as ct, C as lt, D as pt, E as ut, F as mt, G as ft, H as dt, I as Pt, J as gt, K as ht, N as bt, O as xt, Q as Tt, R as Ft, S as St, T as Et } from "./import-mode-
|
|
1
|
+
import { d as j, r as v, a as R, f as g, b as h, w as P, s as b, e as A, c as M, p as $ } from "./import-mode-Dc8qmZP6.js";
|
|
2
|
+
import { L as B, M as W, P as X, g as G, h as U, i as H, j as q, k as J, l as Q, m as V, n as Y, o as Z, q as tt, t as et, u as nt, v as at, x as st, y as ot, z as it, A as rt, B as ct, C as lt, D as pt, E as ut, F as mt, G as ft, H as dt, I as Pt, J as gt, K as ht, N as bt, O as xt, Q as Tt, R as Ft, S as St, T as Et } from "./import-mode-Dc8qmZP6.js";
|
|
3
3
|
const k = {
|
|
4
4
|
png: "image/png",
|
|
5
5
|
jpg: "image/jpeg",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Root elements of a PreTeXt document. */
|
|
2
2
|
export declare const PRETEXT_ROOT_TAGS: readonly ["book", "article"];
|
|
3
3
|
/** Divisions that may be split into their own file, in rough outline order. */
|
|
4
|
-
export declare const PRETEXT_DIVISION_TAGS: readonly ["frontmatter", "preface", "acknowledgement", "dedication", "biography", "contributors", "part", "chapter", "section", "subsection", "subsubsection", "exercises", "worksheet", "reading-questions", "references", "solutions", "glossary", "backmatter", "appendix", "index", "colophon"];
|
|
4
|
+
export declare const PRETEXT_DIVISION_TAGS: readonly ["frontmatter", "preface", "acknowledgement", "dedication", "biography", "contributors", "part", "introduction", "chapter", "section", "subsection", "subsubsection", "conclusion", "exercises", "worksheet", "handout", "reading-questions", "references", "solutions", "glossary", "backmatter", "appendix", "index", "colophon"];
|
|
5
5
|
export type PretextRootTag = (typeof PRETEXT_ROOT_TAGS)[number];
|
|
6
6
|
export type PretextDivisionTag = (typeof PRETEXT_DIVISION_TAGS)[number];
|
|
7
7
|
export declare function isDivisionTag(name: string): name is PretextDivisionTag;
|
package/dist/react.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),_=require("./import-mode-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),_=require("./import-mode-C8xFGO8j.cjs");var re={exports:{}},q={};var se;function ce(){if(se)return q;se=1;var o=Symbol.for("react.transitional.element"),h=Symbol.for("react.fragment");function v(T,b,c){var j=null;if(c!==void 0&&(j=""+c),b.key!==void 0&&(j=""+b.key),"key"in b){c={};for(var g in b)g!=="key"&&(c[g]=b[g])}else c=b;return b=c.ref,{$$typeof:o,type:T,key:j,ref:b!==void 0?b:null,props:c}}return q.Fragment=h,q.jsx=v,q.jsxs=v,q}var J={};var ae;function ie(){return ae||(ae=1,process.env.NODE_ENV!=="production"&&(function(){function o(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===Z?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case I:return"Fragment";case L:return"Profiler";case N:return"StrictMode";case Y:return"Suspense";case V:return"SuspenseList";case H:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case R:return"Portal";case y:return t.displayName||"Context";case x:return(t._context.displayName||"Context")+".Consumer";case $:var n=t.render;return t=t.displayName,t||(t=n.displayName||n.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case G:return n=t.displayName||null,n!==null?n:o(t.type)||"Memo";case C:n=t._payload,t=t._init;try{return o(t(n))}catch{}}return null}function h(t){return""+t}function v(t){try{h(t);var n=!1}catch{n=!0}if(n){n=console;var u=n.error,f=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return u.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",f),h(t)}}function T(t){if(t===I)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===C)return"<...>";try{var n=o(t);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function b(){var t=D.A;return t===null?null:t.getOwner()}function c(){return Error("react-stack-top-frame")}function j(t){if(X.call(t,"key")){var n=Object.getOwnPropertyDescriptor(t,"key").get;if(n&&n.isReactWarning)return!1}return t.key!==void 0}function g(t,n){function u(){B||(B=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",n))}u.isReactWarning=!0,Object.defineProperty(t,"key",{get:u,configurable:!0})}function p(){var t=o(this.type);return z[t]||(z[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),t=this.props.ref,t!==void 0?t:null}function A(t,n,u,f,r,s){var a=u.ref;return t={$$typeof:k,type:t,key:n,props:u,_owner:f},(a!==void 0?a:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:p}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:r}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:s}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function S(t,n,u,f,r,s){var a=n.children;if(a!==void 0)if(f)if(M(a)){for(f=0;f<a.length;f++)w(a[f]);Object.freeze&&Object.freeze(a)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else w(a);if(X.call(n,"key")){a=o(t);var m=Object.keys(n).filter(function(O){return O!=="key"});f=0<m.length?"{key: someKey, "+m.join(": ..., ")+": ...}":"{key: someKey}",K[a+f]||(m=0<m.length?"{"+m.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
package/dist/react.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import me, { useRef as ce, useState as h, useMemo as re } from "react";
|
|
2
|
-
import { H as ie, D as se, I as xe, B as pe, h as de, y as fe, u as he } from "./import-mode-
|
|
2
|
+
import { H as ie, D as se, I as xe, B as pe, h as de, y as fe, u as he } from "./import-mode-Dc8qmZP6.js";
|
|
3
3
|
var te = { exports: {} }, K = {};
|
|
4
4
|
var ae;
|
|
5
5
|
function be() {
|
package/package.json
CHANGED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";const wn=require("@pretextbook/format"),xn=require("@pretextbook/latex-pretext"),kn=require("@pretextbook/remark-pretext"),Ee=["\\documentclass","\\begin{document}","\\begin{","\\section","\\chapter","\\title","\\author"],ze=["# ","## ","### ","#### "];function Dt(n){const r=n.trim();return!r||r.startsWith("<")?"pretext":Ee.some(t=>r.includes(t))?"latex":ze.some(t=>r.startsWith(t))?"markdown":"pretext"}const Sn=[{kind:"presentation",category:"latex_fonts",macros:["textrm","textit","textbf","textsc","texttt"]}],fe={kind:"presentation",category:"tex_fonts",pairs:[{from:"rm",to:"textrm"},{from:"em",to:"emph"},{from:"it",to:"textit"},{from:"itshape",to:"textit"},{from:"bf",to:"textbf"},{from:"bfseries",to:"textbf"},{from:"sf",to:"textsf"},{from:"sffamily",to:"textss"},{from:"textsl",to:"testsl"}]},En=[{kind:"accessibility",category:"consistency",macros:["renewcommand"]}],zn=[{kind:"unused",category:"conditionals",macros:["if","fi","iffalse","then","else","loop","repeat"]},{kind:"presentation",category:"font_size",macros:["tiny","scriptsize","footnotesize","small","normalsize","large","Large","LARGE","huge","Huge","normalfont"]},{kind:"presentation",category:"spacing_vertical",macros:["smallskip","medskip","bigskip","vfil","vfill"]},{kind:"presentation",category:"archaic_tex",macros:["centerline","centering","noindent","par","linebreak"]},{kind:"mistake",category:"nonstructural",macros:["ensuremath"]},{kind:"archaic",category:"low_level_tex",macros:["relax","makeatletter","makeatother","csname","endcsname","shipout","noexpand","expandafter","clearpage"]},{kind:"archaic",category:"file_manipulation",macros:["newwrite","newread","immediate","write","write18","read","readline","readfile","openin","openout","jobname"]}],Cn=[{kind:"archaic",category:"low_level_tex",macros:["catcode","newtheorem","maketitle","setlength"]}],An=[{kind:"publisher",category:"zzzzz",macros:["theoremstyle","makeindex","allowdisplaybreaks","frontmatter","mainmatter","appendix","numberwithin","setcounter","tableofcontents","FloatBarrier"]}],Tn=[{kind:"archaic",category:"use_newcommand_only",macros:["def","let","edef","gdef","xdef","global","long"]}],In=[{kind:"presentation",category:"spacing_horizontal",macros:[{name:"hspace",arity:1}]},{kind:"other",category:"other",macros:[{name:"date",arity:1}]},{kind:"accessibility",category:"colors",macros:[{name:"color",arity:1},{name:"textcolor",arity:1},{name:"mathcolor",arity:1},{name:"definecolor",arity:3}]}],On=[{kind:"presentation",category:"nonstructural",environments:["center","minipage"]}];function de(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function he(n,r){let t=n;const u=[];for(const{from:s,to:i}of r.pairs){let e,a;r.category==="tex_fonts"?(e=`\\{ *\\\\${de(s)}\\b *`,a=`\\${i}{`):(e=`\\\\${de(s)}\\b *`,a=`\\${i}`);const l=new RegExp(e,"g"),d=t.match(l);d&&(u.push({action:"replace",severity:"info",kind:r.kind,category:r.category,macro:s,replacement:i,occurrences:d.length}),t=t.replace(l,a))}return{output:t,warnings:u}}function Rn(n){let r=n;const t=[],u=r.match(/\(\\ref\{([^{}]+)\}\)/g);u&&(t.push({action:"rewrite",severity:"info",kind:"presentation",category:"math_refs",macro:"(\\ref{...})",replacement:"\\eqref{...}",occurrences:u.length}),r=r.replace(/\(\\ref\{([^{}]+)\}\)/g,"\\eqref{$1}")),r=r.replace(/(\\vfil)l\b/g,"$1"),r=r.replace(/(\\vfil)(\s*\\vfil\b)+\b/g,"$1");const s=r.match(/(\\vfil)\b/g);return s&&(t.push({action:"rewrite",severity:"info",kind:"presentation",category:"spacing_vertical",macro:"vfil",replacement:"\\vspace{1in}",occurrences:s.length}),r=r.replace(/(\\vfil)\b/g,"\\vspace{1in}")),r=r.replace(/\\vskip\*? *([0-9]+|-) *([a-zA-Z]+).*/g,"\\vspace{$1$2}"),r=r.replace(/(\\vspace)\*? */g,"$1"),r=r.replace(/(\\vspace) *\{([0-9]+|-) *([a-zA-Z]+).*?\}/g,"$1{$2$3}"),{output:r,warnings:t}}function Pn(n){const r=n.split("\\begin{document}");if(r.length<2)return{preamble:"",body:n,bibliography:""};const t=r[0];let u=r.slice(1).join("\\begin{document}"),s="";if(/\\begin\{thebibliography\}/.test(u)){const[i,...e]=u.split("\\begin{thebibliography}");u=i,s=e.join("\\begin{thebibliography}")}return{preamble:t,body:u,bibliography:s}}function Ce(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Fn(n,r,t){const u=Ce(n);if(r==="hasarg"){let s=`\\\\${u}\\b\\*?`;for(let i=0;i<t;i+=1)s+="\\{[^{}]*\\}";return new RegExp(`(${s})`,"g")}return r==="line"?new RegExp(`(\\\\${u}\\b.*)`,"g"):new RegExp(`(\\\\${u}\\b)`,"g")}function ut(n,r,t,u){const{type:s="",action:i="mark",extra:e="",save:a=!1}=t;"macros"in r&&r.macros[0];let l=n;const d=r.macros;for(const _ of d){const m=typeof _=="string"?_:_.name,v=typeof _=="string"?0:_.arity,h=Fn(m,s,v),g=l.match(h);!g||g.length===0||(a&&u.push({action:"save",severity:"warning",kind:r.kind,category:r.category,macro:m,occurrences:g.length,examples:g.slice(0,5),message:e||void 0}),i==="delete"?(u.push({action:"delete",severity:"info",kind:r.kind,category:r.category,macro:m,occurrences:g.length,message:e||void 0}),l=l.replace(h,"")):u.push({action:"anomaly",severity:"warning",kind:r.kind,category:r.category,macro:m,occurrences:g.length,message:e||void 0,examples:g.slice(0,5)}))}return l}function Dn(n,r,t){let u=n;for(const s of r.environments){const i=Ce(s),e=new RegExp(`(\\\\(begin|end)\\{\\s*${i}\\})`,"g"),a=u.match(e);a&&a.length>0&&(t.push({action:"delete",severity:"info",kind:r.kind,category:r.category,macro:s,occurrences:a.length}),u=u.replace(e,""))}return u}function jn(n){const r=[],t=Pn(n);let{preamble:u,body:s}=t;const{bibliography:i}=t;for(const d of zn)u=ut(u,d,{action:"delete"},r),s=ut(s,d,{action:"delete"},r);for(const d of En)u=ut(u,d,{type:"line",action:"delete",extra:"in the preamble",save:!0},r),s=ut(s,d,{type:"line",action:"delete",extra:"in the main text",save:!0},r);for(const d of Tn)u=ut(u,d,{type:"line",action:"delete",extra:"in the preamble",save:!0},r),s=ut(s,d,{type:"line",action:"delete",extra:"in the main text",save:!0},r);for(const d of In)u=ut(u,d,{type:"hasarg",action:"delete"},r),s=ut(s,d,{type:"hasarg",action:"delete"},r);for(const d of Cn)u=ut(u,d,{type:"line",action:"delete"},r),s=ut(s,d,{type:"line",action:"delete"},r);for(const d of An)u=ut(u,d,{type:"line",action:"delete",extra:"this is a publisher choice in PreTeXt"},r),s=ut(s,d,{type:"line",action:"delete",extra:"this is a publisher choice in PreTeXt"},r);for(const d of Sn)s=ut(s,d,{action:"mark"},r);for(const d of On)s=Dn(s,d,r);const e=n.includes("\\begin{document}"),a=i.length>0;let l=u;return e?l+=`\\begin{document}
|
|
2
|
-
`+s:l=s,a&&(l+=`\\begin{thebibliography}
|
|
3
|
-
`+i),{output:l,warnings:r}}function Bn(n){let r=n;return r=r.replace(/\s+%.*/g,""),r=r.replace(/([^\\])%.*/g,"$1"),r=r.replace(/^%.*/,""),r}function $n(n){return n.replace(/(.*\{)([^{}]+)(\}.*)/,(r,t,u,s)=>{const i=String(u).replace(/\s/g,"_").replace(/[^a-zA-Z0-9_]/g,"-");return`${t}${i}${s}`})}function Ln(n){let r=n;return r=r.replace(/> */g,"\\gt "),r=r.replace(/< */g,"\\lt "),r=r.replace(/(\\(ref|eqref|cref|Cref|label)\{([^{}]+)\})/g,$n),r}function Nn(n){let r=n;return r=r.replace(/\\begin +/g,"\\begin"),r=r.replace(/\\chapter +/g,"\\chapter"),r=r.replace(/\\section +/g,"\\section"),r=r.replace(/\\section\*/g,"\\section"),r=Bn(r),r=Ln(r),r=r.replace(/\\end\{document\}.*/s,""),r=r.replace(/^\s+/,""),r=r.replace(/\n{3,}/g,`
|
|
4
|
-
|
|
5
|
-
`),r}function pe(n,r=0,t="{",u="}"){let s=n.trimStart();if(!s)return["",""];let i="",e="",a=r;if(a===0&&s[0]!==t)return["",s];for(a===0&&(e=t,a=1,s=s.substring(1));a>0&&s;){const l=s[0];l===t&&i!=="\\"?a+=1:l===u&&i!=="\\"&&(a-=1),e+=l,i==="\\"&&l==="\\"?i=`
|
|
6
|
-
`:i=l,s=s.substring(1)}return a===0?[e,s]:["",e.substring(1)]}function Ae(n){const r=[];let t=Nn(n).replace(/(\n *){3,}/g,`
|
|
7
|
-
|
|
8
|
-
`);const u=Rn(t);t=u.output,r.push(...u.warnings);const s=he(t,fe);t=s.output,r.push(...s.warnings);const i=he(t,fe);t=i.output,r.push(...i.warnings);const e=jn(t);return t=e.output.replace(/(\n *){3,}/g,`
|
|
9
|
-
|
|
10
|
-
`),r.push(...e.warnings),{output:t,warnings:r}}function At(n){const r="\\begin{document}",t="\\end{document}",u=n.indexOf(r);if(u===-1)return{preamble:"",body:n};const s=n.slice(0,u).trim(),i=n.slice(u+r.length),e=i.indexOf(t),a=(e===-1?i:i.slice(0,e)).trim();return{preamble:s,body:a}}function jt(n,r){const u=new RegExp(`\\\\${r}(?![a-zA-Z])`).exec(n);if(!u)return"";let s=n.slice(u.index+u[0].length).trimStart();if(s.startsWith("[")){const[e,a]=pe(s,0,"[","]");e&&(s=a.trimStart())}const[i]=pe(s);return i?i.slice(1,-1).trim():""}const Un=/^[ \t]*(\\(?:new|renew|provide)command\*?|\\DeclareMathOperator\*?|\\newenvironment\*?)\b/;function me(n){let r=0;for(let t=0;t<n.length;t++){if(n[t]==="\\"){t++;continue}n[t]==="{"?r++:n[t]==="}"&&r--}return r}function Te(n){const r=n.split(`
|
|
11
|
-
`),t=[];let u=0;for(;u<r.length;){if(!Un.test(r[u])){u++;continue}let s=r[u],i=me(r[u]);for(u++;i>0&&u<r.length;)s+=`
|
|
12
|
-
`+r[u],i+=me(r[u]),u++;t.push(s.trim())}return t.join(`
|
|
13
|
-
`)}function Mn(n){const r=/\\documentclass(?:\[[^\]]*\])?\{([^}]+)\}/.exec(n);return r?r[1].trim():"article"}function Wn(n){const r=n.replace(/(^|[^\\])%[^\n]*/gm,"$1");return{documentClass:Mn(r),title:jt(r,"title"),author:jt(r,"author"),macros:Te(r)}}function Zn(n){if(typeof n=="string")return n;if(typeof n=="object"&&n!==null&&"value"in n){const r=n.value;if(typeof r=="string")return r;if(r!=null)return String(r)}return String(n)}function Ie(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Oe(n){return n.replace(/\\LaTeX\b/g,"LaTeX").replace(/\\TeX\b/g,"TeX").replace(/\\thanks\{[^{}]*(?:\{[^{}]*\}[^{}]*)?\}/g,"").replace(/\\inst\{[^{}]*\}/g,"").replace(/\\email\{[^{}]*\}/g,"").replace(/\\[a-zA-Z]+\{([^{}]*)\}/g,"$1").replace(/\\\s/g," ").replace(/~/g," ").replace(/\s+/g," ").trim()}function Xn(n){const r=[];if(n.macros){const t=n.macros.split(`
|
|
14
|
-
`).map(u=>` ${u}`).join(`
|
|
15
|
-
`);r.push(` <macros>
|
|
16
|
-
${t}
|
|
17
|
-
</macros>`)}if(n.author){const t=n.author.split(/\s+\\and\s+/)[0].trim(),u=Ie(Oe(t));u&&r.push(` <author>
|
|
18
|
-
<personname>${u}</personname>
|
|
19
|
-
</author>`)}return r.length===0?"":`<docinfo>
|
|
20
|
-
${r.join(`
|
|
21
|
-
`)}
|
|
22
|
-
</docinfo>`}function Gn(n,r){const t=n.replace(/^\s*<p\s*\/>\s*/g,"").replace(/^\s*<p>\s*<\/p>\s*/g,"").trim();if(!t)return"";const s=/<chapter[\s>]/.test(t)?"book":"article",i=Xn(r),e=r.title?` <title>${Ie(Oe(r.title))}</title>
|
|
23
|
-
`:"",a=`<${s}>
|
|
24
|
-
${e}${t}
|
|
25
|
-
</${s}>`;return`<pretext>
|
|
26
|
-
${[i,a].filter(Boolean).join(`
|
|
27
|
-
`)}
|
|
28
|
-
</pretext>`}function Ut(n){const r=n.trim();return r?wn.formatPretext(r):""}function Re(n){const r=n.trim();if(!r)return{pretext:"",cleanedLatex:"",warnings:[]};const{preamble:t,body:u}=At(r),s=Wn(t),i=u?[`\\documentclass{${s.documentClass}}`,s.macros,"\\begin{document}",u,"\\end{document}"].filter(Boolean).join(`
|
|
29
|
-
`):r,{output:e,warnings:a}=Ae(i);if(!e.trim())return{pretext:"",cleanedLatex:e,warnings:a};const l=u?e+`
|
|
30
|
-
\\end{document}`:e,d=Zn(xn.latexToPretext(l)).trim();if(!d)return{pretext:"",cleanedLatex:e,warnings:a};const _=Gn(d,s);return{pretext:_?Ut(_):"",cleanedLatex:e,warnings:a}}function Pe(n){const r=n.trim();if(!r)return{pretext:"",cleanedMarkdown:""};const t=String(kn.markdownToPretext(r)).trim();return{pretext:t?Ut(t):"",cleanedMarkdown:r}}function Fe(n){return n instanceof Error&&n.message.trim()?n.message.trim():"Could not convert source content to PreTeXt."}function De(n,r){const t=Dt(n),u=r??t;try{if(u==="pretext")return{sourceFormat:u,detectedSourceFormat:t,pretextSource:Ut(n),warnings:[]};if(u==="markdown"){const{pretext:a,cleanedMarkdown:l}=Pe(n);return{sourceFormat:u,detectedSourceFormat:t,pretextSource:a,cleanedNativeSource:l,warnings:[]}}const{pretext:s,cleanedLatex:i,warnings:e}=Re(n);return{sourceFormat:u,detectedSourceFormat:t,pretextSource:s,cleanedNativeSource:i,warnings:e}}catch(s){return{sourceFormat:u,detectedSourceFormat:t,pretextError:Fe(s),warnings:[]}}}var Ot=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Hn(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Rt(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Xt={exports:{}};var ge;function Kn(){return ge||(ge=1,(function(n,r){(function(t){n.exports=t()})(function(){return(function t(u,s,i){function e(d,_){if(!s[d]){if(!u[d]){var m=typeof Rt=="function"&&Rt;if(!_&&m)return m(d,!0);if(a)return a(d,!0);var v=new Error("Cannot find module '"+d+"'");throw v.code="MODULE_NOT_FOUND",v}var h=s[d]={exports:{}};u[d][0].call(h.exports,function(g){var f=u[d][1][g];return e(f||g)},h,h.exports,t,u,s,i)}return s[d].exports}for(var a=typeof Rt=="function"&&Rt,l=0;l<i.length;l++)e(i[l]);return e})({1:[function(t,u,s){var i=t("./utils"),e=t("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";s.encode=function(l){for(var d,_,m,v,h,g,f,b=[],p=0,w=l.length,S=w,E=i.getTypeOf(l)!=="string";p<l.length;)S=w-p,m=E?(d=l[p++],_=p<w?l[p++]:0,p<w?l[p++]:0):(d=l.charCodeAt(p++),_=p<w?l.charCodeAt(p++):0,p<w?l.charCodeAt(p++):0),v=d>>2,h=(3&d)<<4|_>>4,g=1<S?(15&_)<<2|m>>6:64,f=2<S?63&m:64,b.push(a.charAt(v)+a.charAt(h)+a.charAt(g)+a.charAt(f));return b.join("")},s.decode=function(l){var d,_,m,v,h,g,f=0,b=0,p="data:";if(l.substr(0,p.length)===p)throw new Error("Invalid base64 input, it looks like a data url.");var w,S=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&S--,l.charAt(l.length-2)===a.charAt(64)&&S--,S%1!=0)throw new Error("Invalid base64 input, bad content length.");for(w=e.uint8array?new Uint8Array(0|S):new Array(0|S);f<l.length;)d=a.indexOf(l.charAt(f++))<<2|(v=a.indexOf(l.charAt(f++)))>>4,_=(15&v)<<4|(h=a.indexOf(l.charAt(f++)))>>2,m=(3&h)<<6|(g=a.indexOf(l.charAt(f++))),w[b++]=d,h!==64&&(w[b++]=_),g!==64&&(w[b++]=m);return w}},{"./support":30,"./utils":32}],2:[function(t,u,s){var i=t("./external"),e=t("./stream/DataWorker"),a=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function d(_,m,v,h,g){this.compressedSize=_,this.uncompressedSize=m,this.crc32=v,this.compression=h,this.compressedContent=g}d.prototype={getContentWorker:function(){var _=new e(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),m=this;return _.on("end",function(){if(this.streamInfo.data_length!==m.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),_},getCompressedWorker:function(){return new e(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},d.createWorkerFrom=function(_,m,v){return _.pipe(new a).pipe(new l("uncompressedSize")).pipe(m.compressWorker(v)).pipe(new l("compressedSize")).withStreamInfo("compression",m)},u.exports=d},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,u,s){var i=t("./stream/GenericWorker");s.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},s.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,u,s){var i=t("./utils"),e=(function(){for(var a,l=[],d=0;d<256;d++){a=d;for(var _=0;_<8;_++)a=1&a?3988292384^a>>>1:a>>>1;l[d]=a}return l})();u.exports=function(a,l){return a!==void 0&&a.length?i.getTypeOf(a)!=="string"?(function(d,_,m,v){var h=e,g=v+m;d^=-1;for(var f=v;f<g;f++)d=d>>>8^h[255&(d^_[f])];return-1^d})(0|l,a,a.length,0):(function(d,_,m,v){var h=e,g=v+m;d^=-1;for(var f=v;f<g;f++)d=d>>>8^h[255&(d^_.charCodeAt(f))];return-1^d})(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(t,u,s){s.base64=!1,s.binary=!1,s.dir=!1,s.createFolders=!0,s.date=null,s.compression=null,s.compressionOptions=null,s.comment=null,s.unixPermissions=null,s.dosPermissions=null},{}],6:[function(t,u,s){var i=null;i=typeof Promise<"u"?Promise:t("lie"),u.exports={Promise:i}},{lie:37}],7:[function(t,u,s){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",e=t("pako"),a=t("./utils"),l=t("./stream/GenericWorker"),d=i?"uint8array":"array";function _(m,v){l.call(this,"FlateWorker/"+m),this._pako=null,this._pakoAction=m,this._pakoOptions=v,this.meta={}}s.magic="\b\0",a.inherits(_,l),_.prototype.processChunk=function(m){this.meta=m.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(d,m.data),!1)},_.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},_.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},_.prototype._createPako=function(){this._pako=new e[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var m=this;this._pako.onData=function(v){m.push({data:v,meta:m.meta})}},s.compressWorker=function(m){return new _("Deflate",m)},s.uncompressWorker=function(){return new _("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,u,s){function i(h,g){var f,b="";for(f=0;f<g;f++)b+=String.fromCharCode(255&h),h>>>=8;return b}function e(h,g,f,b,p,w){var S,E,z=h.file,F=h.compression,D=w!==d.utf8encode,$=a.transformTo("string",w(z.name)),P=a.transformTo("string",d.utf8encode(z.name)),W=z.comment,q=a.transformTo("string",w(W)),k=a.transformTo("string",d.utf8encode(W)),j=P.length!==z.name.length,c=k.length!==W.length,I="",Y="",N="",tt=z.dir,M=z.date,Q={crc32:0,compressedSize:0,uncompressedSize:0};g&&!f||(Q.crc32=h.crc32,Q.compressedSize=h.compressedSize,Q.uncompressedSize=h.uncompressedSize);var O=0;g&&(O|=8),D||!j&&!c||(O|=2048);var T=0,J=0;tt&&(T|=16),p==="UNIX"?(J=798,T|=(function(G,st){var lt=G;return G||(lt=st?16893:33204),(65535<)<<16})(z.unixPermissions,tt)):(J=20,T|=(function(G){return 63&(G||0)})(z.dosPermissions)),S=M.getUTCHours(),S<<=6,S|=M.getUTCMinutes(),S<<=5,S|=M.getUTCSeconds()/2,E=M.getUTCFullYear()-1980,E<<=4,E|=M.getUTCMonth()+1,E<<=5,E|=M.getUTCDate(),j&&(Y=i(1,1)+i(_($),4)+P,I+="up"+i(Y.length,2)+Y),c&&(N=i(1,1)+i(_(q),4)+k,I+="uc"+i(N.length,2)+N);var H="";return H+=`
|
|
31
|
-
\0`,H+=i(O,2),H+=F.magic,H+=i(S,2),H+=i(E,2),H+=i(Q.crc32,4),H+=i(Q.compressedSize,4),H+=i(Q.uncompressedSize,4),H+=i($.length,2),H+=i(I.length,2),{fileRecord:m.LOCAL_FILE_HEADER+H+$+I,dirRecord:m.CENTRAL_FILE_HEADER+i(J,2)+H+i(q.length,2)+"\0\0\0\0"+i(T,4)+i(b,4)+$+I+q}}var a=t("../utils"),l=t("../stream/GenericWorker"),d=t("../utf8"),_=t("../crc32"),m=t("../signature");function v(h,g,f,b){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=g,this.zipPlatform=f,this.encodeFileName=b,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(v,l),v.prototype.push=function(h){var g=h.meta.percent||0,f=this.entriesCount,b=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:f?(g+100*(f-b-1))/f:100}}))},v.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var g=this.streamFiles&&!h.file.dir;if(g){var f=e(h,g,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:f.fileRecord,meta:{percent:0}})}else this.accumulate=!0},v.prototype.closedSource=function(h){this.accumulate=!1;var g=this.streamFiles&&!h.file.dir,f=e(h,g,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(f.dirRecord),g)this.push({data:(function(b){return m.DATA_DESCRIPTOR+i(b.crc32,4)+i(b.compressedSize,4)+i(b.uncompressedSize,4)})(h),meta:{percent:100}});else for(this.push({data:f.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},v.prototype.flush=function(){for(var h=this.bytesWritten,g=0;g<this.dirRecords.length;g++)this.push({data:this.dirRecords[g],meta:{percent:100}});var f=this.bytesWritten-h,b=(function(p,w,S,E,z){var F=a.transformTo("string",z(E));return m.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(p,2)+i(p,2)+i(w,4)+i(S,4)+i(F.length,2)+F})(this.dirRecords.length,f,h,this.zipComment,this.encodeFileName);this.push({data:b,meta:{percent:100}})},v.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},v.prototype.registerPrevious=function(h){this._sources.push(h);var g=this;return h.on("data",function(f){g.processChunk(f)}),h.on("end",function(){g.closedSource(g.previous.streamInfo),g._sources.length?g.prepareNextSource():g.end()}),h.on("error",function(f){g.error(f)}),this},v.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},v.prototype.error=function(h){var g=this._sources;if(!l.prototype.error.call(this,h))return!1;for(var f=0;f<g.length;f++)try{g[f].error(h)}catch{}return!0},v.prototype.lock=function(){l.prototype.lock.call(this);for(var h=this._sources,g=0;g<h.length;g++)h[g].lock()},u.exports=v},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,u,s){var i=t("../compressions"),e=t("./ZipFileWorker");s.generateWorker=function(a,l,d){var _=new e(l.streamFiles,d,l.platform,l.encodeFileName),m=0;try{a.forEach(function(v,h){m++;var g=(function(w,S){var E=w||S,z=i[E];if(!z)throw new Error(E+" is not a valid compression method !");return z})(h.options.compression,l.compression),f=h.options.compressionOptions||l.compressionOptions||{},b=h.dir,p=h.date;h._compressWorker(g,f).withStreamInfo("file",{name:v,dir:b,date:p,comment:h.comment||"",unixPermissions:h.unixPermissions,dosPermissions:h.dosPermissions}).pipe(_)}),_.entriesCount=m}catch(v){_.error(v)}return _}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,u,s){function i(){if(!(this instanceof i))return new i;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var e=new i;for(var a in this)typeof this[a]!="function"&&(e[a]=this[a]);return e}}(i.prototype=t("./object")).loadAsync=t("./load"),i.support=t("./support"),i.defaults=t("./defaults"),i.version="3.10.1",i.loadAsync=function(e,a){return new i().loadAsync(e,a)},i.external=t("./external"),u.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(t,u,s){var i=t("./utils"),e=t("./external"),a=t("./utf8"),l=t("./zipEntries"),d=t("./stream/Crc32Probe"),_=t("./nodejsUtils");function m(v){return new e.Promise(function(h,g){var f=v.decompressed.getContentWorker().pipe(new d);f.on("error",function(b){g(b)}).on("end",function(){f.streamInfo.crc32!==v.decompressed.crc32?g(new Error("Corrupted zip : CRC32 mismatch")):h()}).resume()})}u.exports=function(v,h){var g=this;return h=i.extend(h||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),_.isNode&&_.isStream(v)?e.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):i.prepareContent("the loaded zip file",v,!0,h.optimizedBinaryString,h.base64).then(function(f){var b=new l(h);return b.load(f),b}).then(function(f){var b=[e.Promise.resolve(f)],p=f.files;if(h.checkCRC32)for(var w=0;w<p.length;w++)b.push(m(p[w]));return e.Promise.all(b)}).then(function(f){for(var b=f.shift(),p=b.files,w=0;w<p.length;w++){var S=p[w],E=S.fileNameStr,z=i.resolve(S.fileNameStr);g.file(z,S.decompressed,{binary:!0,optimizedBinaryString:!0,date:S.date,dir:S.dir,comment:S.fileCommentStr.length?S.fileCommentStr:null,unixPermissions:S.unixPermissions,dosPermissions:S.dosPermissions,createFolders:h.createFolders}),S.dir||(g.file(z).unsafeOriginalName=E)}return b.zipComment.length&&(g.comment=b.zipComment),g})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,u,s){var i=t("../utils"),e=t("../stream/GenericWorker");function a(l,d){e.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(d)}i.inherits(a,e),a.prototype._bindStream=function(l){var d=this;(this._stream=l).pause(),l.on("data",function(_){d.push({data:_,meta:{percent:0}})}).on("error",function(_){d.isPaused?this.generatedError=_:d.error(_)}).on("end",function(){d.isPaused?d._upstreamEnded=!0:d.end()})},a.prototype.pause=function(){return!!e.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!e.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},u.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(t,u,s){var i=t("readable-stream").Readable;function e(a,l,d){i.call(this,l),this._helper=a;var _=this;a.on("data",function(m,v){_.push(m)||_._helper.pause(),d&&d(v)}).on("error",function(m){_.emit("error",m)}).on("end",function(){_.push(null)})}t("../utils").inherits(e,i),e.prototype._read=function(){this._helper.resume()},u.exports=e},{"../utils":32,"readable-stream":16}],14:[function(t,u,s){u.exports={isNode:typeof Buffer<"u",newBufferFrom:function(i,e){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(i,e);if(typeof i=="number")throw new Error('The "data" argument must not be a number');return new Buffer(i,e)},allocBuffer:function(i){if(Buffer.alloc)return Buffer.alloc(i);var e=new Buffer(i);return e.fill(0),e},isBuffer:function(i){return Buffer.isBuffer(i)},isStream:function(i){return i&&typeof i.on=="function"&&typeof i.pause=="function"&&typeof i.resume=="function"}}},{}],15:[function(t,u,s){function i(z,F,D){var $,P=a.getTypeOf(F),W=a.extend(D||{},_);W.date=W.date||new Date,W.compression!==null&&(W.compression=W.compression.toUpperCase()),typeof W.unixPermissions=="string"&&(W.unixPermissions=parseInt(W.unixPermissions,8)),W.unixPermissions&&16384&W.unixPermissions&&(W.dir=!0),W.dosPermissions&&16&W.dosPermissions&&(W.dir=!0),W.dir&&(z=p(z)),W.createFolders&&($=b(z))&&w.call(this,$,!0);var q=P==="string"&&W.binary===!1&&W.base64===!1;D&&D.binary!==void 0||(W.binary=!q),(F instanceof m&&F.uncompressedSize===0||W.dir||!F||F.length===0)&&(W.base64=!1,W.binary=!0,F="",W.compression="STORE",P="string");var k=null;k=F instanceof m||F instanceof l?F:g.isNode&&g.isStream(F)?new f(z,F):a.prepareContent(z,F,W.binary,W.optimizedBinaryString,W.base64);var j=new v(z,k,W);this.files[z]=j}var e=t("./utf8"),a=t("./utils"),l=t("./stream/GenericWorker"),d=t("./stream/StreamHelper"),_=t("./defaults"),m=t("./compressedObject"),v=t("./zipObject"),h=t("./generate"),g=t("./nodejsUtils"),f=t("./nodejs/NodejsStreamInputAdapter"),b=function(z){z.slice(-1)==="/"&&(z=z.substring(0,z.length-1));var F=z.lastIndexOf("/");return 0<F?z.substring(0,F):""},p=function(z){return z.slice(-1)!=="/"&&(z+="/"),z},w=function(z,F){return F=F!==void 0?F:_.createFolders,z=p(z),this.files[z]||i.call(this,z,null,{dir:!0,createFolders:F}),this.files[z]};function S(z){return Object.prototype.toString.call(z)==="[object RegExp]"}var E={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(z){var F,D,$;for(F in this.files)$=this.files[F],(D=F.slice(this.root.length,F.length))&&F.slice(0,this.root.length)===this.root&&z(D,$)},filter:function(z){var F=[];return this.forEach(function(D,$){z(D,$)&&F.push($)}),F},file:function(z,F,D){if(arguments.length!==1)return z=this.root+z,i.call(this,z,F,D),this;if(S(z)){var $=z;return this.filter(function(W,q){return!q.dir&&$.test(W)})}var P=this.files[this.root+z];return P&&!P.dir?P:null},folder:function(z){if(!z)return this;if(S(z))return this.filter(function(P,W){return W.dir&&z.test(P)});var F=this.root+z,D=w.call(this,F),$=this.clone();return $.root=D.name,$},remove:function(z){z=this.root+z;var F=this.files[z];if(F||(z.slice(-1)!=="/"&&(z+="/"),F=this.files[z]),F&&!F.dir)delete this.files[z];else for(var D=this.filter(function(P,W){return W.name.slice(0,z.length)===z}),$=0;$<D.length;$++)delete this.files[D[$].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(z){var F,D={};try{if((D=a.extend(z||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:e.utf8encode})).type=D.type.toLowerCase(),D.compression=D.compression.toUpperCase(),D.type==="binarystring"&&(D.type="string"),!D.type)throw new Error("No output type specified.");a.checkSupport(D.type),D.platform!=="darwin"&&D.platform!=="freebsd"&&D.platform!=="linux"&&D.platform!=="sunos"||(D.platform="UNIX"),D.platform==="win32"&&(D.platform="DOS");var $=D.comment||this.comment||"";F=h.generateWorker(this,D,$)}catch(P){(F=new l("error")).error(P)}return new d(F,D.type||"string",D.mimeType)},generateAsync:function(z,F){return this.generateInternalStream(z).accumulate(F)},generateNodeStream:function(z,F){return(z=z||{}).type||(z.type="nodebuffer"),this.generateInternalStream(z).toNodejsStream(F)}};u.exports=E},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(t,u,s){u.exports=t("stream")},{stream:void 0}],17:[function(t,u,s){var i=t("./DataReader");function e(a){i.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}t("../utils").inherits(e,i),e.prototype.byteAt=function(a){return this.data[this.zero+a]},e.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),d=a.charCodeAt(1),_=a.charCodeAt(2),m=a.charCodeAt(3),v=this.length-4;0<=v;--v)if(this.data[v]===l&&this.data[v+1]===d&&this.data[v+2]===_&&this.data[v+3]===m)return v-this.zero;return-1},e.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),d=a.charCodeAt(1),_=a.charCodeAt(2),m=a.charCodeAt(3),v=this.readData(4);return l===v[0]&&d===v[1]&&_===v[2]&&m===v[3]},e.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},u.exports=e},{"../utils":32,"./DataReader":18}],18:[function(t,u,s){var i=t("../utils");function e(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}e.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,d=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)d=(d<<8)+this.byteAt(l);return this.index+=a,d},readString:function(a){return i.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},u.exports=e},{"../utils":32}],19:[function(t,u,s){var i=t("./Uint8ArrayReader");function e(a){i.call(this,a)}t("../utils").inherits(e,i),e.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},u.exports=e},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,u,s){var i=t("./DataReader");function e(a){i.call(this,a)}t("../utils").inherits(e,i),e.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},e.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},e.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},e.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},u.exports=e},{"../utils":32,"./DataReader":18}],21:[function(t,u,s){var i=t("./ArrayReader");function e(a){i.call(this,a)}t("../utils").inherits(e,i),e.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},u.exports=e},{"../utils":32,"./ArrayReader":17}],22:[function(t,u,s){var i=t("../utils"),e=t("../support"),a=t("./ArrayReader"),l=t("./StringReader"),d=t("./NodeBufferReader"),_=t("./Uint8ArrayReader");u.exports=function(m){var v=i.getTypeOf(m);return i.checkSupport(v),v!=="string"||e.uint8array?v==="nodebuffer"?new d(m):e.uint8array?new _(i.transformTo("uint8array",m)):new a(i.transformTo("array",m)):new l(m)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,u,s){s.LOCAL_FILE_HEADER="PK",s.CENTRAL_FILE_HEADER="PK",s.CENTRAL_DIRECTORY_END="PK",s.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",s.ZIP64_CENTRAL_DIRECTORY_END="PK",s.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,u,s){var i=t("./GenericWorker"),e=t("../utils");function a(l){i.call(this,"ConvertWorker to "+l),this.destType=l}e.inherits(a,i),a.prototype.processChunk=function(l){this.push({data:e.transformTo(this.destType,l.data),meta:l.meta})},u.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(t,u,s){var i=t("./GenericWorker"),e=t("../crc32");function a(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(a,i),a.prototype.processChunk=function(l){this.streamInfo.crc32=e(l.data,this.streamInfo.crc32||0),this.push(l)},u.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,u,s){var i=t("../utils"),e=t("./GenericWorker");function a(l){e.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}i.inherits(a,e),a.prototype.processChunk=function(l){if(l){var d=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=d+l.data.length}e.prototype.processChunk.call(this,l)},u.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(t,u,s){var i=t("../utils"),e=t("./GenericWorker");function a(l){e.call(this,"DataWorker");var d=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(_){d.dataIsReady=!0,d.data=_,d.max=_&&_.length||0,d.type=i.getTypeOf(_),d.isPaused||d._tickAndRepeat()},function(_){d.error(_)})}i.inherits(a,e),a.prototype.cleanUp=function(){e.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!e.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,d=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,d);break;case"uint8array":l=this.data.subarray(this.index,d);break;case"array":case"nodebuffer":l=this.data.slice(this.index,d)}return this.index=d,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},u.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(t,u,s){function i(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,a){return this._listeners[e].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,a){if(this._listeners[e])for(var l=0;l<this._listeners[e].length;l++)this._listeners[e][l].call(this,a)},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var a=this;return e.on("data",function(l){a.processChunk(l)}),e.on("end",function(){a.end()}),e.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var e=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),e=!0),this.previous&&this.previous.resume(),!e},flush:function(){},processChunk:function(e){this.push(e)},withStreamInfo:function(e,a){return this.extraStreamInfo[e]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,e)&&(this.streamInfo[e]=this.extraStreamInfo[e])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var e="Worker "+this.name;return this.previous?this.previous+" -> "+e:e}},u.exports=i},{}],29:[function(t,u,s){var i=t("../utils"),e=t("./ConvertWorker"),a=t("./GenericWorker"),l=t("../base64"),d=t("../support"),_=t("../external"),m=null;if(d.nodestream)try{m=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function v(g,f){return new _.Promise(function(b,p){var w=[],S=g._internalType,E=g._outputType,z=g._mimeType;g.on("data",function(F,D){w.push(F),f&&f(D)}).on("error",function(F){w=[],p(F)}).on("end",function(){try{var F=(function(D,$,P){switch(D){case"blob":return i.newBlob(i.transformTo("arraybuffer",$),P);case"base64":return l.encode($);default:return i.transformTo(D,$)}})(E,(function(D,$){var P,W=0,q=null,k=0;for(P=0;P<$.length;P++)k+=$[P].length;switch(D){case"string":return $.join("");case"array":return Array.prototype.concat.apply([],$);case"uint8array":for(q=new Uint8Array(k),P=0;P<$.length;P++)q.set($[P],W),W+=$[P].length;return q;case"nodebuffer":return Buffer.concat($);default:throw new Error("concat : unsupported type '"+D+"'")}})(S,w),z);b(F)}catch(D){p(D)}w=[]}).resume()})}function h(g,f,b){var p=f;switch(f){case"blob":case"arraybuffer":p="uint8array";break;case"base64":p="string"}try{this._internalType=p,this._outputType=f,this._mimeType=b,i.checkSupport(p),this._worker=g.pipe(new e(p)),g.lock()}catch(w){this._worker=new a("error"),this._worker.error(w)}}h.prototype={accumulate:function(g){return v(this,g)},on:function(g,f){var b=this;return g==="data"?this._worker.on(g,function(p){f.call(b,p.data,p.meta)}):this._worker.on(g,function(){i.delay(f,arguments,b)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(g){if(i.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new m(this,{objectMode:this._outputType!=="nodebuffer"},g)}},u.exports=h},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(t,u,s){if(s.base64=!0,s.array=!0,s.string=!0,s.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",s.nodebuffer=typeof Buffer<"u",s.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")s.blob=!1;else{var i=new ArrayBuffer(0);try{s.blob=new Blob([i],{type:"application/zip"}).size===0}catch{try{var e=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);e.append(i),s.blob=e.getBlob("application/zip").size===0}catch{s.blob=!1}}}try{s.nodestream=!!t("readable-stream").Readable}catch{s.nodestream=!1}},{"readable-stream":16}],31:[function(t,u,s){for(var i=t("./utils"),e=t("./support"),a=t("./nodejsUtils"),l=t("./stream/GenericWorker"),d=new Array(256),_=0;_<256;_++)d[_]=252<=_?6:248<=_?5:240<=_?4:224<=_?3:192<=_?2:1;d[254]=d[254]=1;function m(){l.call(this,"utf-8 decode"),this.leftOver=null}function v(){l.call(this,"utf-8 encode")}s.utf8encode=function(h){return e.nodebuffer?a.newBufferFrom(h,"utf-8"):(function(g){var f,b,p,w,S,E=g.length,z=0;for(w=0;w<E;w++)(64512&(b=g.charCodeAt(w)))==55296&&w+1<E&&(64512&(p=g.charCodeAt(w+1)))==56320&&(b=65536+(b-55296<<10)+(p-56320),w++),z+=b<128?1:b<2048?2:b<65536?3:4;for(f=e.uint8array?new Uint8Array(z):new Array(z),w=S=0;S<z;w++)(64512&(b=g.charCodeAt(w)))==55296&&w+1<E&&(64512&(p=g.charCodeAt(w+1)))==56320&&(b=65536+(b-55296<<10)+(p-56320),w++),b<128?f[S++]=b:(b<2048?f[S++]=192|b>>>6:(b<65536?f[S++]=224|b>>>12:(f[S++]=240|b>>>18,f[S++]=128|b>>>12&63),f[S++]=128|b>>>6&63),f[S++]=128|63&b);return f})(h)},s.utf8decode=function(h){return e.nodebuffer?i.transformTo("nodebuffer",h).toString("utf-8"):(function(g){var f,b,p,w,S=g.length,E=new Array(2*S);for(f=b=0;f<S;)if((p=g[f++])<128)E[b++]=p;else if(4<(w=d[p]))E[b++]=65533,f+=w-1;else{for(p&=w===2?31:w===3?15:7;1<w&&f<S;)p=p<<6|63&g[f++],w--;1<w?E[b++]=65533:p<65536?E[b++]=p:(p-=65536,E[b++]=55296|p>>10&1023,E[b++]=56320|1023&p)}return E.length!==b&&(E.subarray?E=E.subarray(0,b):E.length=b),i.applyFromCharCode(E)})(h=i.transformTo(e.uint8array?"uint8array":"array",h))},i.inherits(m,l),m.prototype.processChunk=function(h){var g=i.transformTo(e.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(e.uint8array){var f=g;(g=new Uint8Array(f.length+this.leftOver.length)).set(this.leftOver,0),g.set(f,this.leftOver.length)}else g=this.leftOver.concat(g);this.leftOver=null}var b=(function(w,S){var E;for((S=S||w.length)>w.length&&(S=w.length),E=S-1;0<=E&&(192&w[E])==128;)E--;return E<0||E===0?S:E+d[w[E]]>S?E:S})(g),p=g;b!==g.length&&(e.uint8array?(p=g.subarray(0,b),this.leftOver=g.subarray(b,g.length)):(p=g.slice(0,b),this.leftOver=g.slice(b,g.length))),this.push({data:s.utf8decode(p),meta:h.meta})},m.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=m,i.inherits(v,l),v.prototype.processChunk=function(h){this.push({data:s.utf8encode(h.data),meta:h.meta})},s.Utf8EncodeWorker=v},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,u,s){var i=t("./support"),e=t("./base64"),a=t("./nodejsUtils"),l=t("./external");function d(f){return f}function _(f,b){for(var p=0;p<f.length;++p)b[p]=255&f.charCodeAt(p);return b}t("setimmediate"),s.newBlob=function(f,b){s.checkSupport("blob");try{return new Blob([f],{type:b})}catch{try{var p=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return p.append(f),p.getBlob(b)}catch{throw new Error("Bug : can't construct the Blob.")}}};var m={stringifyByChunk:function(f,b,p){var w=[],S=0,E=f.length;if(E<=p)return String.fromCharCode.apply(null,f);for(;S<E;)b==="array"||b==="nodebuffer"?w.push(String.fromCharCode.apply(null,f.slice(S,Math.min(S+p,E)))):w.push(String.fromCharCode.apply(null,f.subarray(S,Math.min(S+p,E)))),S+=p;return w.join("")},stringifyByChar:function(f){for(var b="",p=0;p<f.length;p++)b+=String.fromCharCode(f[p]);return b},applyCanBeUsed:{uint8array:(function(){try{return i.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return i.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function v(f){var b=65536,p=s.getTypeOf(f),w=!0;if(p==="uint8array"?w=m.applyCanBeUsed.uint8array:p==="nodebuffer"&&(w=m.applyCanBeUsed.nodebuffer),w)for(;1<b;)try{return m.stringifyByChunk(f,p,b)}catch{b=Math.floor(b/2)}return m.stringifyByChar(f)}function h(f,b){for(var p=0;p<f.length;p++)b[p]=f[p];return b}s.applyFromCharCode=v;var g={};g.string={string:d,array:function(f){return _(f,new Array(f.length))},arraybuffer:function(f){return g.string.uint8array(f).buffer},uint8array:function(f){return _(f,new Uint8Array(f.length))},nodebuffer:function(f){return _(f,a.allocBuffer(f.length))}},g.array={string:v,array:d,arraybuffer:function(f){return new Uint8Array(f).buffer},uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return a.newBufferFrom(f)}},g.arraybuffer={string:function(f){return v(new Uint8Array(f))},array:function(f){return h(new Uint8Array(f),new Array(f.byteLength))},arraybuffer:d,uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return a.newBufferFrom(new Uint8Array(f))}},g.uint8array={string:v,array:function(f){return h(f,new Array(f.length))},arraybuffer:function(f){return f.buffer},uint8array:d,nodebuffer:function(f){return a.newBufferFrom(f)}},g.nodebuffer={string:v,array:function(f){return h(f,new Array(f.length))},arraybuffer:function(f){return g.nodebuffer.uint8array(f).buffer},uint8array:function(f){return h(f,new Uint8Array(f.length))},nodebuffer:d},s.transformTo=function(f,b){if(b=b||"",!f)return b;s.checkSupport(f);var p=s.getTypeOf(b);return g[p][f](b)},s.resolve=function(f){for(var b=f.split("/"),p=[],w=0;w<b.length;w++){var S=b[w];S==="."||S===""&&w!==0&&w!==b.length-1||(S===".."?p.pop():p.push(S))}return p.join("/")},s.getTypeOf=function(f){return typeof f=="string"?"string":Object.prototype.toString.call(f)==="[object Array]"?"array":i.nodebuffer&&a.isBuffer(f)?"nodebuffer":i.uint8array&&f instanceof Uint8Array?"uint8array":i.arraybuffer&&f instanceof ArrayBuffer?"arraybuffer":void 0},s.checkSupport=function(f){if(!i[f.toLowerCase()])throw new Error(f+" is not supported by this platform")},s.MAX_VALUE_16BITS=65535,s.MAX_VALUE_32BITS=-1,s.pretty=function(f){var b,p,w="";for(p=0;p<(f||"").length;p++)w+="\\x"+((b=f.charCodeAt(p))<16?"0":"")+b.toString(16).toUpperCase();return w},s.delay=function(f,b,p){setImmediate(function(){f.apply(p||null,b||[])})},s.inherits=function(f,b){function p(){}p.prototype=b.prototype,f.prototype=new p},s.extend=function(){var f,b,p={};for(f=0;f<arguments.length;f++)for(b in arguments[f])Object.prototype.hasOwnProperty.call(arguments[f],b)&&p[b]===void 0&&(p[b]=arguments[f][b]);return p},s.prepareContent=function(f,b,p,w,S){return l.Promise.resolve(b).then(function(E){return i.blob&&(E instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(E))!==-1)&&typeof FileReader<"u"?new l.Promise(function(z,F){var D=new FileReader;D.onload=function($){z($.target.result)},D.onerror=function($){F($.target.error)},D.readAsArrayBuffer(E)}):E}).then(function(E){var z=s.getTypeOf(E);return z?(z==="arraybuffer"?E=s.transformTo("uint8array",E):z==="string"&&(S?E=e.decode(E):p&&w!==!0&&(E=(function(F){return _(F,i.uint8array?new Uint8Array(F.length):new Array(F.length))})(E))),E):l.Promise.reject(new Error("Can't read the data of '"+f+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(t,u,s){var i=t("./reader/readerFor"),e=t("./utils"),a=t("./signature"),l=t("./zipEntry"),d=t("./support");function _(m){this.files=[],this.loadOptions=m}_.prototype={checkSignature:function(m){if(!this.reader.readAndCheckSignature(m)){this.reader.index-=4;var v=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+e.pretty(v)+", expected "+e.pretty(m)+")")}},isSignature:function(m,v){var h=this.reader.index;this.reader.setIndex(m);var g=this.reader.readString(4)===v;return this.reader.setIndex(h),g},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var m=this.reader.readData(this.zipCommentLength),v=d.uint8array?"uint8array":"array",h=e.transformTo(v,m);this.zipComment=this.loadOptions.decodeFileName(h)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var m,v,h,g=this.zip64EndOfCentralSize-44;0<g;)m=this.reader.readInt(2),v=this.reader.readInt(4),h=this.reader.readData(v),this.zip64ExtensibleData[m]={id:m,length:v,value:h}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var m,v;for(m=0;m<this.files.length;m++)v=this.files[m],this.reader.setIndex(v.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),v.readLocalPart(this.reader),v.handleUTF8(),v.processAttributes()},readCentralDir:function(){var m;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(m=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(m);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var m=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(m<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(m);var v=m;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===e.MAX_VALUE_16BITS||this.diskWithCentralDirStart===e.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===e.MAX_VALUE_16BITS||this.centralDirRecords===e.MAX_VALUE_16BITS||this.centralDirSize===e.MAX_VALUE_32BITS||this.centralDirOffset===e.MAX_VALUE_32BITS){if(this.zip64=!0,(m=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(m),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var h=this.centralDirOffset+this.centralDirSize;this.zip64&&(h+=20,h+=12+this.zip64EndOfCentralSize);var g=v-h;if(0<g)this.isSignature(v,a.CENTRAL_FILE_HEADER)||(this.reader.zero=g);else if(g<0)throw new Error("Corrupted zip: missing "+Math.abs(g)+" bytes.")},prepareReader:function(m){this.reader=i(m)},load:function(m){this.prepareReader(m),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},u.exports=_},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,u,s){var i=t("./reader/readerFor"),e=t("./utils"),a=t("./compressedObject"),l=t("./crc32"),d=t("./utf8"),_=t("./compressions"),m=t("./support");function v(h,g){this.options=h,this.loadOptions=g}v.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(h){var g,f;if(h.skip(22),this.fileNameLength=h.readInt(2),f=h.readInt(2),this.fileName=h.readData(this.fileNameLength),h.skip(f),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((g=(function(b){for(var p in _)if(Object.prototype.hasOwnProperty.call(_,p)&&_[p].magic===b)return _[p];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+e.pretty(this.compressionMethod)+" unknown (inner file : "+e.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,g,h.readData(this.compressedSize))},readCentralPart:function(h){this.versionMadeBy=h.readInt(2),h.skip(2),this.bitFlag=h.readInt(2),this.compressionMethod=h.readString(2),this.date=h.readDate(),this.crc32=h.readInt(4),this.compressedSize=h.readInt(4),this.uncompressedSize=h.readInt(4);var g=h.readInt(2);if(this.extraFieldsLength=h.readInt(2),this.fileCommentLength=h.readInt(2),this.diskNumberStart=h.readInt(2),this.internalFileAttributes=h.readInt(2),this.externalFileAttributes=h.readInt(4),this.localHeaderOffset=h.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");h.skip(g),this.readExtraFields(h),this.parseZIP64ExtraField(h),this.fileComment=h.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var h=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=i(this.extraFields[1].value);this.uncompressedSize===e.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===e.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===e.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===e.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var g,f,b,p=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4<p;)g=h.readInt(2),f=h.readInt(2),b=h.readData(f),this.extraFields[g]={id:g,length:f,value:b};h.setIndex(p)},handleUTF8:function(){var h=m.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=d.utf8decode(this.fileName),this.fileCommentStr=d.utf8decode(this.fileComment);else{var g=this.findExtraFieldUnicodePath();if(g!==null)this.fileNameStr=g;else{var f=e.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(f)}var b=this.findExtraFieldUnicodeComment();if(b!==null)this.fileCommentStr=b;else{var p=e.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(p)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var g=i(h.value);return g.readInt(1)!==1||l(this.fileName)!==g.readInt(4)?null:d.utf8decode(g.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var g=i(h.value);return g.readInt(1)!==1||l(this.fileComment)!==g.readInt(4)?null:d.utf8decode(g.readData(h.length-5))}return null}},u.exports=v},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,u,s){function i(g,f,b){this.name=g,this.dir=b.dir,this.date=b.date,this.comment=b.comment,this.unixPermissions=b.unixPermissions,this.dosPermissions=b.dosPermissions,this._data=f,this._dataBinary=b.binary,this.options={compression:b.compression,compressionOptions:b.compressionOptions}}var e=t("./stream/StreamHelper"),a=t("./stream/DataWorker"),l=t("./utf8"),d=t("./compressedObject"),_=t("./stream/GenericWorker");i.prototype={internalStream:function(g){var f=null,b="string";try{if(!g)throw new Error("No output type specified.");var p=(b=g.toLowerCase())==="string"||b==="text";b!=="binarystring"&&b!=="text"||(b="string"),f=this._decompressWorker();var w=!this._dataBinary;w&&!p&&(f=f.pipe(new l.Utf8EncodeWorker)),!w&&p&&(f=f.pipe(new l.Utf8DecodeWorker))}catch(S){(f=new _("error")).error(S)}return new e(f,b,"")},async:function(g,f){return this.internalStream(g).accumulate(f)},nodeStream:function(g,f){return this.internalStream(g||"nodebuffer").toNodejsStream(f)},_compressWorker:function(g,f){if(this._data instanceof d&&this._data.compression.magic===g.magic)return this._data.getCompressedWorker();var b=this._decompressWorker();return this._dataBinary||(b=b.pipe(new l.Utf8EncodeWorker)),d.createWorkerFrom(b,g,f)},_decompressWorker:function(){return this._data instanceof d?this._data.getContentWorker():this._data instanceof _?this._data:new a(this._data)}};for(var m=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],v=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<m.length;h++)i.prototype[m[h]]=v;u.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,u,s){(function(i){var e,a,l=i.MutationObserver||i.WebKitMutationObserver;if(l){var d=0,_=new l(g),m=i.document.createTextNode("");_.observe(m,{characterData:!0}),e=function(){m.data=d=++d%2}}else if(i.setImmediate||i.MessageChannel===void 0)e="document"in i&&"onreadystatechange"in i.document.createElement("script")?function(){var f=i.document.createElement("script");f.onreadystatechange=function(){g(),f.onreadystatechange=null,f.parentNode.removeChild(f),f=null},i.document.documentElement.appendChild(f)}:function(){setTimeout(g,0)};else{var v=new i.MessageChannel;v.port1.onmessage=g,e=function(){v.port2.postMessage(0)}}var h=[];function g(){var f,b;a=!0;for(var p=h.length;p;){for(b=h,h=[],f=-1;++f<p;)b[f]();p=h.length}a=!1}u.exports=function(f){h.push(f)!==1||a||e()}}).call(this,typeof Ot<"u"?Ot:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(t,u,s){var i=t("immediate");function e(){}var a={},l=["REJECTED"],d=["FULFILLED"],_=["PENDING"];function m(p){if(typeof p!="function")throw new TypeError("resolver must be a function");this.state=_,this.queue=[],this.outcome=void 0,p!==e&&f(this,p)}function v(p,w,S){this.promise=p,typeof w=="function"&&(this.onFulfilled=w,this.callFulfilled=this.otherCallFulfilled),typeof S=="function"&&(this.onRejected=S,this.callRejected=this.otherCallRejected)}function h(p,w,S){i(function(){var E;try{E=w(S)}catch(z){return a.reject(p,z)}E===p?a.reject(p,new TypeError("Cannot resolve promise with itself")):a.resolve(p,E)})}function g(p){var w=p&&p.then;if(p&&(typeof p=="object"||typeof p=="function")&&typeof w=="function")return function(){w.apply(p,arguments)}}function f(p,w){var S=!1;function E(D){S||(S=!0,a.reject(p,D))}function z(D){S||(S=!0,a.resolve(p,D))}var F=b(function(){w(z,E)});F.status==="error"&&E(F.value)}function b(p,w){var S={};try{S.value=p(w),S.status="success"}catch(E){S.status="error",S.value=E}return S}(u.exports=m).prototype.finally=function(p){if(typeof p!="function")return this;var w=this.constructor;return this.then(function(S){return w.resolve(p()).then(function(){return S})},function(S){return w.resolve(p()).then(function(){throw S})})},m.prototype.catch=function(p){return this.then(null,p)},m.prototype.then=function(p,w){if(typeof p!="function"&&this.state===d||typeof w!="function"&&this.state===l)return this;var S=new this.constructor(e);return this.state!==_?h(S,this.state===d?p:w,this.outcome):this.queue.push(new v(S,p,w)),S},v.prototype.callFulfilled=function(p){a.resolve(this.promise,p)},v.prototype.otherCallFulfilled=function(p){h(this.promise,this.onFulfilled,p)},v.prototype.callRejected=function(p){a.reject(this.promise,p)},v.prototype.otherCallRejected=function(p){h(this.promise,this.onRejected,p)},a.resolve=function(p,w){var S=b(g,w);if(S.status==="error")return a.reject(p,S.value);var E=S.value;if(E)f(p,E);else{p.state=d,p.outcome=w;for(var z=-1,F=p.queue.length;++z<F;)p.queue[z].callFulfilled(w)}return p},a.reject=function(p,w){p.state=l,p.outcome=w;for(var S=-1,E=p.queue.length;++S<E;)p.queue[S].callRejected(w);return p},m.resolve=function(p){return p instanceof this?p:a.resolve(new this(e),p)},m.reject=function(p){var w=new this(e);return a.reject(w,p)},m.all=function(p){var w=this;if(Object.prototype.toString.call(p)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=p.length,E=!1;if(!S)return this.resolve([]);for(var z=new Array(S),F=0,D=-1,$=new this(e);++D<S;)P(p[D],D);return $;function P(W,q){w.resolve(W).then(function(k){z[q]=k,++F!==S||E||(E=!0,a.resolve($,z))},function(k){E||(E=!0,a.reject($,k))})}},m.race=function(p){var w=this;if(Object.prototype.toString.call(p)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=p.length,E=!1;if(!S)return this.resolve([]);for(var z=-1,F=new this(e);++z<S;)D=p[z],w.resolve(D).then(function($){E||(E=!0,a.resolve(F,$))},function($){E||(E=!0,a.reject(F,$))});var D;return F}},{immediate:36}],38:[function(t,u,s){var i={};(0,t("./lib/utils/common").assign)(i,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),u.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(t,u,s){var i=t("./zlib/deflate"),e=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/messages"),d=t("./zlib/zstream"),_=Object.prototype.toString,m=0,v=-1,h=0,g=8;function f(p){if(!(this instanceof f))return new f(p);this.options=e.assign({level:v,method:g,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},p||{});var w=this.options;w.raw&&0<w.windowBits?w.windowBits=-w.windowBits:w.gzip&&0<w.windowBits&&w.windowBits<16&&(w.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var S=i.deflateInit2(this.strm,w.level,w.method,w.windowBits,w.memLevel,w.strategy);if(S!==m)throw new Error(l[S]);if(w.header&&i.deflateSetHeader(this.strm,w.header),w.dictionary){var E;if(E=typeof w.dictionary=="string"?a.string2buf(w.dictionary):_.call(w.dictionary)==="[object ArrayBuffer]"?new Uint8Array(w.dictionary):w.dictionary,(S=i.deflateSetDictionary(this.strm,E))!==m)throw new Error(l[S]);this._dict_set=!0}}function b(p,w){var S=new f(w);if(S.push(p,!0),S.err)throw S.msg||l[S.err];return S.result}f.prototype.push=function(p,w){var S,E,z=this.strm,F=this.options.chunkSize;if(this.ended)return!1;E=w===~~w?w:w===!0?4:0,typeof p=="string"?z.input=a.string2buf(p):_.call(p)==="[object ArrayBuffer]"?z.input=new Uint8Array(p):z.input=p,z.next_in=0,z.avail_in=z.input.length;do{if(z.avail_out===0&&(z.output=new e.Buf8(F),z.next_out=0,z.avail_out=F),(S=i.deflate(z,E))!==1&&S!==m)return this.onEnd(S),!(this.ended=!0);z.avail_out!==0&&(z.avail_in!==0||E!==4&&E!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(e.shrinkBuf(z.output,z.next_out))):this.onData(e.shrinkBuf(z.output,z.next_out)))}while((0<z.avail_in||z.avail_out===0)&&S!==1);return E===4?(S=i.deflateEnd(this.strm),this.onEnd(S),this.ended=!0,S===m):E!==2||(this.onEnd(m),!(z.avail_out=0))},f.prototype.onData=function(p){this.chunks.push(p)},f.prototype.onEnd=function(p){p===m&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=e.flattenChunks(this.chunks)),this.chunks=[],this.err=p,this.msg=this.strm.msg},s.Deflate=f,s.deflate=b,s.deflateRaw=function(p,w){return(w=w||{}).raw=!0,b(p,w)},s.gzip=function(p,w){return(w=w||{}).gzip=!0,b(p,w)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,u,s){var i=t("./zlib/inflate"),e=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/constants"),d=t("./zlib/messages"),_=t("./zlib/zstream"),m=t("./zlib/gzheader"),v=Object.prototype.toString;function h(f){if(!(this instanceof h))return new h(f);this.options=e.assign({chunkSize:16384,windowBits:0,to:""},f||{});var b=this.options;b.raw&&0<=b.windowBits&&b.windowBits<16&&(b.windowBits=-b.windowBits,b.windowBits===0&&(b.windowBits=-15)),!(0<=b.windowBits&&b.windowBits<16)||f&&f.windowBits||(b.windowBits+=32),15<b.windowBits&&b.windowBits<48&&(15&b.windowBits)==0&&(b.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new _,this.strm.avail_out=0;var p=i.inflateInit2(this.strm,b.windowBits);if(p!==l.Z_OK)throw new Error(d[p]);this.header=new m,i.inflateGetHeader(this.strm,this.header)}function g(f,b){var p=new h(b);if(p.push(f,!0),p.err)throw p.msg||d[p.err];return p.result}h.prototype.push=function(f,b){var p,w,S,E,z,F,D=this.strm,$=this.options.chunkSize,P=this.options.dictionary,W=!1;if(this.ended)return!1;w=b===~~b?b:b===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof f=="string"?D.input=a.binstring2buf(f):v.call(f)==="[object ArrayBuffer]"?D.input=new Uint8Array(f):D.input=f,D.next_in=0,D.avail_in=D.input.length;do{if(D.avail_out===0&&(D.output=new e.Buf8($),D.next_out=0,D.avail_out=$),(p=i.inflate(D,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&P&&(F=typeof P=="string"?a.string2buf(P):v.call(P)==="[object ArrayBuffer]"?new Uint8Array(P):P,p=i.inflateSetDictionary(this.strm,F)),p===l.Z_BUF_ERROR&&W===!0&&(p=l.Z_OK,W=!1),p!==l.Z_STREAM_END&&p!==l.Z_OK)return this.onEnd(p),!(this.ended=!0);D.next_out&&(D.avail_out!==0&&p!==l.Z_STREAM_END&&(D.avail_in!==0||w!==l.Z_FINISH&&w!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(S=a.utf8border(D.output,D.next_out),E=D.next_out-S,z=a.buf2string(D.output,S),D.next_out=E,D.avail_out=$-E,E&&e.arraySet(D.output,D.output,S,E,0),this.onData(z)):this.onData(e.shrinkBuf(D.output,D.next_out)))),D.avail_in===0&&D.avail_out===0&&(W=!0)}while((0<D.avail_in||D.avail_out===0)&&p!==l.Z_STREAM_END);return p===l.Z_STREAM_END&&(w=l.Z_FINISH),w===l.Z_FINISH?(p=i.inflateEnd(this.strm),this.onEnd(p),this.ended=!0,p===l.Z_OK):w!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(D.avail_out=0))},h.prototype.onData=function(f){this.chunks.push(f)},h.prototype.onEnd=function(f){f===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=e.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg},s.Inflate=h,s.inflate=g,s.inflateRaw=function(f,b){return(b=b||{}).raw=!0,g(f,b)},s.ungzip=g},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(t,u,s){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";s.assign=function(l){for(var d=Array.prototype.slice.call(arguments,1);d.length;){var _=d.shift();if(_){if(typeof _!="object")throw new TypeError(_+"must be non-object");for(var m in _)_.hasOwnProperty(m)&&(l[m]=_[m])}}return l},s.shrinkBuf=function(l,d){return l.length===d?l:l.subarray?l.subarray(0,d):(l.length=d,l)};var e={arraySet:function(l,d,_,m,v){if(d.subarray&&l.subarray)l.set(d.subarray(_,_+m),v);else for(var h=0;h<m;h++)l[v+h]=d[_+h]},flattenChunks:function(l){var d,_,m,v,h,g;for(d=m=0,_=l.length;d<_;d++)m+=l[d].length;for(g=new Uint8Array(m),d=v=0,_=l.length;d<_;d++)h=l[d],g.set(h,v),v+=h.length;return g}},a={arraySet:function(l,d,_,m,v){for(var h=0;h<m;h++)l[v+h]=d[_+h]},flattenChunks:function(l){return[].concat.apply([],l)}};s.setTyped=function(l){l?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,e)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,a))},s.setTyped(i)},{}],42:[function(t,u,s){var i=t("./common"),e=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{e=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new i.Buf8(256),d=0;d<256;d++)l[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;function _(m,v){if(v<65537&&(m.subarray&&a||!m.subarray&&e))return String.fromCharCode.apply(null,i.shrinkBuf(m,v));for(var h="",g=0;g<v;g++)h+=String.fromCharCode(m[g]);return h}l[254]=l[254]=1,s.string2buf=function(m){var v,h,g,f,b,p=m.length,w=0;for(f=0;f<p;f++)(64512&(h=m.charCodeAt(f)))==55296&&f+1<p&&(64512&(g=m.charCodeAt(f+1)))==56320&&(h=65536+(h-55296<<10)+(g-56320),f++),w+=h<128?1:h<2048?2:h<65536?3:4;for(v=new i.Buf8(w),f=b=0;b<w;f++)(64512&(h=m.charCodeAt(f)))==55296&&f+1<p&&(64512&(g=m.charCodeAt(f+1)))==56320&&(h=65536+(h-55296<<10)+(g-56320),f++),h<128?v[b++]=h:(h<2048?v[b++]=192|h>>>6:(h<65536?v[b++]=224|h>>>12:(v[b++]=240|h>>>18,v[b++]=128|h>>>12&63),v[b++]=128|h>>>6&63),v[b++]=128|63&h);return v},s.buf2binstring=function(m){return _(m,m.length)},s.binstring2buf=function(m){for(var v=new i.Buf8(m.length),h=0,g=v.length;h<g;h++)v[h]=m.charCodeAt(h);return v},s.buf2string=function(m,v){var h,g,f,b,p=v||m.length,w=new Array(2*p);for(h=g=0;h<p;)if((f=m[h++])<128)w[g++]=f;else if(4<(b=l[f]))w[g++]=65533,h+=b-1;else{for(f&=b===2?31:b===3?15:7;1<b&&h<p;)f=f<<6|63&m[h++],b--;1<b?w[g++]=65533:f<65536?w[g++]=f:(f-=65536,w[g++]=55296|f>>10&1023,w[g++]=56320|1023&f)}return _(w,g)},s.utf8border=function(m,v){var h;for((v=v||m.length)>m.length&&(v=m.length),h=v-1;0<=h&&(192&m[h])==128;)h--;return h<0||h===0?v:h+l[m[h]]>v?h:v}},{"./common":41}],43:[function(t,u,s){u.exports=function(i,e,a,l){for(var d=65535&i|0,_=i>>>16&65535|0,m=0;a!==0;){for(a-=m=2e3<a?2e3:a;_=_+(d=d+e[l++]|0)|0,--m;);d%=65521,_%=65521}return d|_<<16|0}},{}],44:[function(t,u,s){u.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(t,u,s){var i=(function(){for(var e,a=[],l=0;l<256;l++){e=l;for(var d=0;d<8;d++)e=1&e?3988292384^e>>>1:e>>>1;a[l]=e}return a})();u.exports=function(e,a,l,d){var _=i,m=d+l;e^=-1;for(var v=d;v<m;v++)e=e>>>8^_[255&(e^a[v])];return-1^e}},{}],46:[function(t,u,s){var i,e=t("../utils/common"),a=t("./trees"),l=t("./adler32"),d=t("./crc32"),_=t("./messages"),m=0,v=4,h=0,g=-2,f=-1,b=4,p=2,w=8,S=9,E=286,z=30,F=19,D=2*E+1,$=15,P=3,W=258,q=W+P+1,k=42,j=113,c=1,I=2,Y=3,N=4;function tt(o,B){return o.msg=_[B],B}function M(o){return(o<<1)-(4<o?9:0)}function Q(o){for(var B=o.length;0<=--B;)o[B]=0}function O(o){var B=o.state,R=B.pending;R>o.avail_out&&(R=o.avail_out),R!==0&&(e.arraySet(o.output,B.pending_buf,B.pending_out,R,o.next_out),o.next_out+=R,B.pending_out+=R,o.total_out+=R,o.avail_out-=R,B.pending-=R,B.pending===0&&(B.pending_out=0))}function T(o,B){a._tr_flush_block(o,0<=o.block_start?o.block_start:-1,o.strstart-o.block_start,B),o.block_start=o.strstart,O(o.strm)}function J(o,B){o.pending_buf[o.pending++]=B}function H(o,B){o.pending_buf[o.pending++]=B>>>8&255,o.pending_buf[o.pending++]=255&B}function G(o,B){var R,x,y=o.max_chain_length,C=o.strstart,L=o.prev_length,U=o.nice_match,A=o.strstart>o.w_size-q?o.strstart-(o.w_size-q):0,Z=o.window,K=o.w_mask,X=o.prev,V=o.strstart+W,it=Z[C+L-1],nt=Z[C+L];o.prev_length>=o.good_match&&(y>>=2),U>o.lookahead&&(U=o.lookahead);do if(Z[(R=B)+L]===nt&&Z[R+L-1]===it&&Z[R]===Z[C]&&Z[++R]===Z[C+1]){C+=2,R++;do;while(Z[++C]===Z[++R]&&Z[++C]===Z[++R]&&Z[++C]===Z[++R]&&Z[++C]===Z[++R]&&Z[++C]===Z[++R]&&Z[++C]===Z[++R]&&Z[++C]===Z[++R]&&Z[++C]===Z[++R]&&C<V);if(x=W-(V-C),C=V-W,L<x){if(o.match_start=B,U<=(L=x))break;it=Z[C+L-1],nt=Z[C+L]}}while((B=X[B&K])>A&&--y!=0);return L<=o.lookahead?L:o.lookahead}function st(o){var B,R,x,y,C,L,U,A,Z,K,X=o.w_size;do{if(y=o.window_size-o.lookahead-o.strstart,o.strstart>=X+(X-q)){for(e.arraySet(o.window,o.window,X,X,0),o.match_start-=X,o.strstart-=X,o.block_start-=X,B=R=o.hash_size;x=o.head[--B],o.head[B]=X<=x?x-X:0,--R;);for(B=R=X;x=o.prev[--B],o.prev[B]=X<=x?x-X:0,--R;);y+=X}if(o.strm.avail_in===0)break;if(L=o.strm,U=o.window,A=o.strstart+o.lookahead,Z=y,K=void 0,K=L.avail_in,Z<K&&(K=Z),R=K===0?0:(L.avail_in-=K,e.arraySet(U,L.input,L.next_in,K,A),L.state.wrap===1?L.adler=l(L.adler,U,K,A):L.state.wrap===2&&(L.adler=d(L.adler,U,K,A)),L.next_in+=K,L.total_in+=K,K),o.lookahead+=R,o.lookahead+o.insert>=P)for(C=o.strstart-o.insert,o.ins_h=o.window[C],o.ins_h=(o.ins_h<<o.hash_shift^o.window[C+1])&o.hash_mask;o.insert&&(o.ins_h=(o.ins_h<<o.hash_shift^o.window[C+P-1])&o.hash_mask,o.prev[C&o.w_mask]=o.head[o.ins_h],o.head[o.ins_h]=C,C++,o.insert--,!(o.lookahead+o.insert<P)););}while(o.lookahead<q&&o.strm.avail_in!==0)}function lt(o,B){for(var R,x;;){if(o.lookahead<q){if(st(o),o.lookahead<q&&B===m)return c;if(o.lookahead===0)break}if(R=0,o.lookahead>=P&&(o.ins_h=(o.ins_h<<o.hash_shift^o.window[o.strstart+P-1])&o.hash_mask,R=o.prev[o.strstart&o.w_mask]=o.head[o.ins_h],o.head[o.ins_h]=o.strstart),R!==0&&o.strstart-R<=o.w_size-q&&(o.match_length=G(o,R)),o.match_length>=P)if(x=a._tr_tally(o,o.strstart-o.match_start,o.match_length-P),o.lookahead-=o.match_length,o.match_length<=o.max_lazy_match&&o.lookahead>=P){for(o.match_length--;o.strstart++,o.ins_h=(o.ins_h<<o.hash_shift^o.window[o.strstart+P-1])&o.hash_mask,R=o.prev[o.strstart&o.w_mask]=o.head[o.ins_h],o.head[o.ins_h]=o.strstart,--o.match_length!=0;);o.strstart++}else o.strstart+=o.match_length,o.match_length=0,o.ins_h=o.window[o.strstart],o.ins_h=(o.ins_h<<o.hash_shift^o.window[o.strstart+1])&o.hash_mask;else x=a._tr_tally(o,0,o.window[o.strstart]),o.lookahead--,o.strstart++;if(x&&(T(o,!1),o.strm.avail_out===0))return c}return o.insert=o.strstart<P-1?o.strstart:P-1,B===v?(T(o,!0),o.strm.avail_out===0?Y:N):o.last_lit&&(T(o,!1),o.strm.avail_out===0)?c:I}function et(o,B){for(var R,x,y;;){if(o.lookahead<q){if(st(o),o.lookahead<q&&B===m)return c;if(o.lookahead===0)break}if(R=0,o.lookahead>=P&&(o.ins_h=(o.ins_h<<o.hash_shift^o.window[o.strstart+P-1])&o.hash_mask,R=o.prev[o.strstart&o.w_mask]=o.head[o.ins_h],o.head[o.ins_h]=o.strstart),o.prev_length=o.match_length,o.prev_match=o.match_start,o.match_length=P-1,R!==0&&o.prev_length<o.max_lazy_match&&o.strstart-R<=o.w_size-q&&(o.match_length=G(o,R),o.match_length<=5&&(o.strategy===1||o.match_length===P&&4096<o.strstart-o.match_start)&&(o.match_length=P-1)),o.prev_length>=P&&o.match_length<=o.prev_length){for(y=o.strstart+o.lookahead-P,x=a._tr_tally(o,o.strstart-1-o.prev_match,o.prev_length-P),o.lookahead-=o.prev_length-1,o.prev_length-=2;++o.strstart<=y&&(o.ins_h=(o.ins_h<<o.hash_shift^o.window[o.strstart+P-1])&o.hash_mask,R=o.prev[o.strstart&o.w_mask]=o.head[o.ins_h],o.head[o.ins_h]=o.strstart),--o.prev_length!=0;);if(o.match_available=0,o.match_length=P-1,o.strstart++,x&&(T(o,!1),o.strm.avail_out===0))return c}else if(o.match_available){if((x=a._tr_tally(o,0,o.window[o.strstart-1]))&&T(o,!1),o.strstart++,o.lookahead--,o.strm.avail_out===0)return c}else o.match_available=1,o.strstart++,o.lookahead--}return o.match_available&&(x=a._tr_tally(o,0,o.window[o.strstart-1]),o.match_available=0),o.insert=o.strstart<P-1?o.strstart:P-1,B===v?(T(o,!0),o.strm.avail_out===0?Y:N):o.last_lit&&(T(o,!1),o.strm.avail_out===0)?c:I}function rt(o,B,R,x,y){this.good_length=o,this.max_lazy=B,this.nice_length=R,this.max_chain=x,this.func=y}function ct(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=w,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new e.Buf16(2*D),this.dyn_dtree=new e.Buf16(2*(2*z+1)),this.bl_tree=new e.Buf16(2*(2*F+1)),Q(this.dyn_ltree),Q(this.dyn_dtree),Q(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new e.Buf16($+1),this.heap=new e.Buf16(2*E+1),Q(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new e.Buf16(2*E+1),Q(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function ot(o){var B;return o&&o.state?(o.total_in=o.total_out=0,o.data_type=p,(B=o.state).pending=0,B.pending_out=0,B.wrap<0&&(B.wrap=-B.wrap),B.status=B.wrap?k:j,o.adler=B.wrap===2?0:1,B.last_flush=m,a._tr_init(B),h):tt(o,g)}function mt(o){var B=ot(o);return B===h&&(function(R){R.window_size=2*R.w_size,Q(R.head),R.max_lazy_match=i[R.level].max_lazy,R.good_match=i[R.level].good_length,R.nice_match=i[R.level].nice_length,R.max_chain_length=i[R.level].max_chain,R.strstart=0,R.block_start=0,R.lookahead=0,R.insert=0,R.match_length=R.prev_length=P-1,R.match_available=0,R.ins_h=0})(o.state),B}function pt(o,B,R,x,y,C){if(!o)return g;var L=1;if(B===f&&(B=6),x<0?(L=0,x=-x):15<x&&(L=2,x-=16),y<1||S<y||R!==w||x<8||15<x||B<0||9<B||C<0||b<C)return tt(o,g);x===8&&(x=9);var U=new ct;return(o.state=U).strm=o,U.wrap=L,U.gzhead=null,U.w_bits=x,U.w_size=1<<U.w_bits,U.w_mask=U.w_size-1,U.hash_bits=y+7,U.hash_size=1<<U.hash_bits,U.hash_mask=U.hash_size-1,U.hash_shift=~~((U.hash_bits+P-1)/P),U.window=new e.Buf8(2*U.w_size),U.head=new e.Buf16(U.hash_size),U.prev=new e.Buf16(U.w_size),U.lit_bufsize=1<<y+6,U.pending_buf_size=4*U.lit_bufsize,U.pending_buf=new e.Buf8(U.pending_buf_size),U.d_buf=1*U.lit_bufsize,U.l_buf=3*U.lit_bufsize,U.level=B,U.strategy=C,U.method=R,mt(o)}i=[new rt(0,0,0,0,function(o,B){var R=65535;for(R>o.pending_buf_size-5&&(R=o.pending_buf_size-5);;){if(o.lookahead<=1){if(st(o),o.lookahead===0&&B===m)return c;if(o.lookahead===0)break}o.strstart+=o.lookahead,o.lookahead=0;var x=o.block_start+R;if((o.strstart===0||o.strstart>=x)&&(o.lookahead=o.strstart-x,o.strstart=x,T(o,!1),o.strm.avail_out===0)||o.strstart-o.block_start>=o.w_size-q&&(T(o,!1),o.strm.avail_out===0))return c}return o.insert=0,B===v?(T(o,!0),o.strm.avail_out===0?Y:N):(o.strstart>o.block_start&&(T(o,!1),o.strm.avail_out),c)}),new rt(4,4,8,4,lt),new rt(4,5,16,8,lt),new rt(4,6,32,32,lt),new rt(4,4,16,16,et),new rt(8,16,32,32,et),new rt(8,16,128,128,et),new rt(8,32,128,256,et),new rt(32,128,258,1024,et),new rt(32,258,258,4096,et)],s.deflateInit=function(o,B){return pt(o,B,w,15,8,0)},s.deflateInit2=pt,s.deflateReset=mt,s.deflateResetKeep=ot,s.deflateSetHeader=function(o,B){return o&&o.state?o.state.wrap!==2?g:(o.state.gzhead=B,h):g},s.deflate=function(o,B){var R,x,y,C;if(!o||!o.state||5<B||B<0)return o?tt(o,g):g;if(x=o.state,!o.output||!o.input&&o.avail_in!==0||x.status===666&&B!==v)return tt(o,o.avail_out===0?-5:g);if(x.strm=o,R=x.last_flush,x.last_flush=B,x.status===k)if(x.wrap===2)o.adler=0,J(x,31),J(x,139),J(x,8),x.gzhead?(J(x,(x.gzhead.text?1:0)+(x.gzhead.hcrc?2:0)+(x.gzhead.extra?4:0)+(x.gzhead.name?8:0)+(x.gzhead.comment?16:0)),J(x,255&x.gzhead.time),J(x,x.gzhead.time>>8&255),J(x,x.gzhead.time>>16&255),J(x,x.gzhead.time>>24&255),J(x,x.level===9?2:2<=x.strategy||x.level<2?4:0),J(x,255&x.gzhead.os),x.gzhead.extra&&x.gzhead.extra.length&&(J(x,255&x.gzhead.extra.length),J(x,x.gzhead.extra.length>>8&255)),x.gzhead.hcrc&&(o.adler=d(o.adler,x.pending_buf,x.pending,0)),x.gzindex=0,x.status=69):(J(x,0),J(x,0),J(x,0),J(x,0),J(x,0),J(x,x.level===9?2:2<=x.strategy||x.level<2?4:0),J(x,3),x.status=j);else{var L=w+(x.w_bits-8<<4)<<8;L|=(2<=x.strategy||x.level<2?0:x.level<6?1:x.level===6?2:3)<<6,x.strstart!==0&&(L|=32),L+=31-L%31,x.status=j,H(x,L),x.strstart!==0&&(H(x,o.adler>>>16),H(x,65535&o.adler)),o.adler=1}if(x.status===69)if(x.gzhead.extra){for(y=x.pending;x.gzindex<(65535&x.gzhead.extra.length)&&(x.pending!==x.pending_buf_size||(x.gzhead.hcrc&&x.pending>y&&(o.adler=d(o.adler,x.pending_buf,x.pending-y,y)),O(o),y=x.pending,x.pending!==x.pending_buf_size));)J(x,255&x.gzhead.extra[x.gzindex]),x.gzindex++;x.gzhead.hcrc&&x.pending>y&&(o.adler=d(o.adler,x.pending_buf,x.pending-y,y)),x.gzindex===x.gzhead.extra.length&&(x.gzindex=0,x.status=73)}else x.status=73;if(x.status===73)if(x.gzhead.name){y=x.pending;do{if(x.pending===x.pending_buf_size&&(x.gzhead.hcrc&&x.pending>y&&(o.adler=d(o.adler,x.pending_buf,x.pending-y,y)),O(o),y=x.pending,x.pending===x.pending_buf_size)){C=1;break}C=x.gzindex<x.gzhead.name.length?255&x.gzhead.name.charCodeAt(x.gzindex++):0,J(x,C)}while(C!==0);x.gzhead.hcrc&&x.pending>y&&(o.adler=d(o.adler,x.pending_buf,x.pending-y,y)),C===0&&(x.gzindex=0,x.status=91)}else x.status=91;if(x.status===91)if(x.gzhead.comment){y=x.pending;do{if(x.pending===x.pending_buf_size&&(x.gzhead.hcrc&&x.pending>y&&(o.adler=d(o.adler,x.pending_buf,x.pending-y,y)),O(o),y=x.pending,x.pending===x.pending_buf_size)){C=1;break}C=x.gzindex<x.gzhead.comment.length?255&x.gzhead.comment.charCodeAt(x.gzindex++):0,J(x,C)}while(C!==0);x.gzhead.hcrc&&x.pending>y&&(o.adler=d(o.adler,x.pending_buf,x.pending-y,y)),C===0&&(x.status=103)}else x.status=103;if(x.status===103&&(x.gzhead.hcrc?(x.pending+2>x.pending_buf_size&&O(o),x.pending+2<=x.pending_buf_size&&(J(x,255&o.adler),J(x,o.adler>>8&255),o.adler=0,x.status=j)):x.status=j),x.pending!==0){if(O(o),o.avail_out===0)return x.last_flush=-1,h}else if(o.avail_in===0&&M(B)<=M(R)&&B!==v)return tt(o,-5);if(x.status===666&&o.avail_in!==0)return tt(o,-5);if(o.avail_in!==0||x.lookahead!==0||B!==m&&x.status!==666){var U=x.strategy===2?(function(A,Z){for(var K;;){if(A.lookahead===0&&(st(A),A.lookahead===0)){if(Z===m)return c;break}if(A.match_length=0,K=a._tr_tally(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++,K&&(T(A,!1),A.strm.avail_out===0))return c}return A.insert=0,Z===v?(T(A,!0),A.strm.avail_out===0?Y:N):A.last_lit&&(T(A,!1),A.strm.avail_out===0)?c:I})(x,B):x.strategy===3?(function(A,Z){for(var K,X,V,it,nt=A.window;;){if(A.lookahead<=W){if(st(A),A.lookahead<=W&&Z===m)return c;if(A.lookahead===0)break}if(A.match_length=0,A.lookahead>=P&&0<A.strstart&&(X=nt[V=A.strstart-1])===nt[++V]&&X===nt[++V]&&X===nt[++V]){it=A.strstart+W;do;while(X===nt[++V]&&X===nt[++V]&&X===nt[++V]&&X===nt[++V]&&X===nt[++V]&&X===nt[++V]&&X===nt[++V]&&X===nt[++V]&&V<it);A.match_length=W-(it-V),A.match_length>A.lookahead&&(A.match_length=A.lookahead)}if(A.match_length>=P?(K=a._tr_tally(A,1,A.match_length-P),A.lookahead-=A.match_length,A.strstart+=A.match_length,A.match_length=0):(K=a._tr_tally(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++),K&&(T(A,!1),A.strm.avail_out===0))return c}return A.insert=0,Z===v?(T(A,!0),A.strm.avail_out===0?Y:N):A.last_lit&&(T(A,!1),A.strm.avail_out===0)?c:I})(x,B):i[x.level].func(x,B);if(U!==Y&&U!==N||(x.status=666),U===c||U===Y)return o.avail_out===0&&(x.last_flush=-1),h;if(U===I&&(B===1?a._tr_align(x):B!==5&&(a._tr_stored_block(x,0,0,!1),B===3&&(Q(x.head),x.lookahead===0&&(x.strstart=0,x.block_start=0,x.insert=0))),O(o),o.avail_out===0))return x.last_flush=-1,h}return B!==v?h:x.wrap<=0?1:(x.wrap===2?(J(x,255&o.adler),J(x,o.adler>>8&255),J(x,o.adler>>16&255),J(x,o.adler>>24&255),J(x,255&o.total_in),J(x,o.total_in>>8&255),J(x,o.total_in>>16&255),J(x,o.total_in>>24&255)):(H(x,o.adler>>>16),H(x,65535&o.adler)),O(o),0<x.wrap&&(x.wrap=-x.wrap),x.pending!==0?h:1)},s.deflateEnd=function(o){var B;return o&&o.state?(B=o.state.status)!==k&&B!==69&&B!==73&&B!==91&&B!==103&&B!==j&&B!==666?tt(o,g):(o.state=null,B===j?tt(o,-3):h):g},s.deflateSetDictionary=function(o,B){var R,x,y,C,L,U,A,Z,K=B.length;if(!o||!o.state||(C=(R=o.state).wrap)===2||C===1&&R.status!==k||R.lookahead)return g;for(C===1&&(o.adler=l(o.adler,B,K,0)),R.wrap=0,K>=R.w_size&&(C===0&&(Q(R.head),R.strstart=0,R.block_start=0,R.insert=0),Z=new e.Buf8(R.w_size),e.arraySet(Z,B,K-R.w_size,R.w_size,0),B=Z,K=R.w_size),L=o.avail_in,U=o.next_in,A=o.input,o.avail_in=K,o.next_in=0,o.input=B,st(R);R.lookahead>=P;){for(x=R.strstart,y=R.lookahead-(P-1);R.ins_h=(R.ins_h<<R.hash_shift^R.window[x+P-1])&R.hash_mask,R.prev[x&R.w_mask]=R.head[R.ins_h],R.head[R.ins_h]=x,x++,--y;);R.strstart=x,R.lookahead=P-1,st(R)}return R.strstart+=R.lookahead,R.block_start=R.strstart,R.insert=R.lookahead,R.lookahead=0,R.match_length=R.prev_length=P-1,R.match_available=0,o.next_in=U,o.input=A,o.avail_in=L,R.wrap=C,h},s.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(t,u,s){u.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(t,u,s){u.exports=function(i,e){var a,l,d,_,m,v,h,g,f,b,p,w,S,E,z,F,D,$,P,W,q,k,j,c,I;a=i.state,l=i.next_in,c=i.input,d=l+(i.avail_in-5),_=i.next_out,I=i.output,m=_-(e-i.avail_out),v=_+(i.avail_out-257),h=a.dmax,g=a.wsize,f=a.whave,b=a.wnext,p=a.window,w=a.hold,S=a.bits,E=a.lencode,z=a.distcode,F=(1<<a.lenbits)-1,D=(1<<a.distbits)-1;t:do{S<15&&(w+=c[l++]<<S,S+=8,w+=c[l++]<<S,S+=8),$=E[w&F];e:for(;;){if(w>>>=P=$>>>24,S-=P,(P=$>>>16&255)===0)I[_++]=65535&$;else{if(!(16&P)){if((64&P)==0){$=E[(65535&$)+(w&(1<<P)-1)];continue e}if(32&P){a.mode=12;break t}i.msg="invalid literal/length code",a.mode=30;break t}W=65535&$,(P&=15)&&(S<P&&(w+=c[l++]<<S,S+=8),W+=w&(1<<P)-1,w>>>=P,S-=P),S<15&&(w+=c[l++]<<S,S+=8,w+=c[l++]<<S,S+=8),$=z[w&D];n:for(;;){if(w>>>=P=$>>>24,S-=P,!(16&(P=$>>>16&255))){if((64&P)==0){$=z[(65535&$)+(w&(1<<P)-1)];continue n}i.msg="invalid distance code",a.mode=30;break t}if(q=65535&$,S<(P&=15)&&(w+=c[l++]<<S,(S+=8)<P&&(w+=c[l++]<<S,S+=8)),h<(q+=w&(1<<P)-1)){i.msg="invalid distance too far back",a.mode=30;break t}if(w>>>=P,S-=P,(P=_-m)<q){if(f<(P=q-P)&&a.sane){i.msg="invalid distance too far back",a.mode=30;break t}if(j=p,(k=0)===b){if(k+=g-P,P<W){for(W-=P;I[_++]=p[k++],--P;);k=_-q,j=I}}else if(b<P){if(k+=g+b-P,(P-=b)<W){for(W-=P;I[_++]=p[k++],--P;);if(k=0,b<W){for(W-=P=b;I[_++]=p[k++],--P;);k=_-q,j=I}}}else if(k+=b-P,P<W){for(W-=P;I[_++]=p[k++],--P;);k=_-q,j=I}for(;2<W;)I[_++]=j[k++],I[_++]=j[k++],I[_++]=j[k++],W-=3;W&&(I[_++]=j[k++],1<W&&(I[_++]=j[k++]))}else{for(k=_-q;I[_++]=I[k++],I[_++]=I[k++],I[_++]=I[k++],2<(W-=3););W&&(I[_++]=I[k++],1<W&&(I[_++]=I[k++]))}break}}break}}while(l<d&&_<v);l-=W=S>>3,w&=(1<<(S-=W<<3))-1,i.next_in=l,i.next_out=_,i.avail_in=l<d?d-l+5:5-(l-d),i.avail_out=_<v?v-_+257:257-(_-v),a.hold=w,a.bits=S}},{}],49:[function(t,u,s){var i=t("../utils/common"),e=t("./adler32"),a=t("./crc32"),l=t("./inffast"),d=t("./inftrees"),_=1,m=2,v=0,h=-2,g=1,f=852,b=592;function p(k){return(k>>>24&255)+(k>>>8&65280)+((65280&k)<<8)+((255&k)<<24)}function w(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function S(k){var j;return k&&k.state?(j=k.state,k.total_in=k.total_out=j.total=0,k.msg="",j.wrap&&(k.adler=1&j.wrap),j.mode=g,j.last=0,j.havedict=0,j.dmax=32768,j.head=null,j.hold=0,j.bits=0,j.lencode=j.lendyn=new i.Buf32(f),j.distcode=j.distdyn=new i.Buf32(b),j.sane=1,j.back=-1,v):h}function E(k){var j;return k&&k.state?((j=k.state).wsize=0,j.whave=0,j.wnext=0,S(k)):h}function z(k,j){var c,I;return k&&k.state?(I=k.state,j<0?(c=0,j=-j):(c=1+(j>>4),j<48&&(j&=15)),j&&(j<8||15<j)?h:(I.window!==null&&I.wbits!==j&&(I.window=null),I.wrap=c,I.wbits=j,E(k))):h}function F(k,j){var c,I;return k?(I=new w,(k.state=I).window=null,(c=z(k,j))!==v&&(k.state=null),c):h}var D,$,P=!0;function W(k){if(P){var j;for(D=new i.Buf32(512),$=new i.Buf32(32),j=0;j<144;)k.lens[j++]=8;for(;j<256;)k.lens[j++]=9;for(;j<280;)k.lens[j++]=7;for(;j<288;)k.lens[j++]=8;for(d(_,k.lens,0,288,D,0,k.work,{bits:9}),j=0;j<32;)k.lens[j++]=5;d(m,k.lens,0,32,$,0,k.work,{bits:5}),P=!1}k.lencode=D,k.lenbits=9,k.distcode=$,k.distbits=5}function q(k,j,c,I){var Y,N=k.state;return N.window===null&&(N.wsize=1<<N.wbits,N.wnext=0,N.whave=0,N.window=new i.Buf8(N.wsize)),I>=N.wsize?(i.arraySet(N.window,j,c-N.wsize,N.wsize,0),N.wnext=0,N.whave=N.wsize):(I<(Y=N.wsize-N.wnext)&&(Y=I),i.arraySet(N.window,j,c-I,Y,N.wnext),(I-=Y)?(i.arraySet(N.window,j,c-I,I,0),N.wnext=I,N.whave=N.wsize):(N.wnext+=Y,N.wnext===N.wsize&&(N.wnext=0),N.whave<N.wsize&&(N.whave+=Y))),0}s.inflateReset=E,s.inflateReset2=z,s.inflateResetKeep=S,s.inflateInit=function(k){return F(k,15)},s.inflateInit2=F,s.inflate=function(k,j){var c,I,Y,N,tt,M,Q,O,T,J,H,G,st,lt,et,rt,ct,ot,mt,pt,o,B,R,x,y=0,C=new i.Buf8(4),L=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!k||!k.state||!k.output||!k.input&&k.avail_in!==0)return h;(c=k.state).mode===12&&(c.mode=13),tt=k.next_out,Y=k.output,Q=k.avail_out,N=k.next_in,I=k.input,M=k.avail_in,O=c.hold,T=c.bits,J=M,H=Q,B=v;t:for(;;)switch(c.mode){case g:if(c.wrap===0){c.mode=13;break}for(;T<16;){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}if(2&c.wrap&&O===35615){C[c.check=0]=255&O,C[1]=O>>>8&255,c.check=a(c.check,C,2,0),T=O=0,c.mode=2;break}if(c.flags=0,c.head&&(c.head.done=!1),!(1&c.wrap)||(((255&O)<<8)+(O>>8))%31){k.msg="incorrect header check",c.mode=30;break}if((15&O)!=8){k.msg="unknown compression method",c.mode=30;break}if(T-=4,o=8+(15&(O>>>=4)),c.wbits===0)c.wbits=o;else if(o>c.wbits){k.msg="invalid window size",c.mode=30;break}c.dmax=1<<o,k.adler=c.check=1,c.mode=512&O?10:12,T=O=0;break;case 2:for(;T<16;){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}if(c.flags=O,(255&c.flags)!=8){k.msg="unknown compression method",c.mode=30;break}if(57344&c.flags){k.msg="unknown header flags set",c.mode=30;break}c.head&&(c.head.text=O>>8&1),512&c.flags&&(C[0]=255&O,C[1]=O>>>8&255,c.check=a(c.check,C,2,0)),T=O=0,c.mode=3;case 3:for(;T<32;){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}c.head&&(c.head.time=O),512&c.flags&&(C[0]=255&O,C[1]=O>>>8&255,C[2]=O>>>16&255,C[3]=O>>>24&255,c.check=a(c.check,C,4,0)),T=O=0,c.mode=4;case 4:for(;T<16;){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}c.head&&(c.head.xflags=255&O,c.head.os=O>>8),512&c.flags&&(C[0]=255&O,C[1]=O>>>8&255,c.check=a(c.check,C,2,0)),T=O=0,c.mode=5;case 5:if(1024&c.flags){for(;T<16;){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}c.length=O,c.head&&(c.head.extra_len=O),512&c.flags&&(C[0]=255&O,C[1]=O>>>8&255,c.check=a(c.check,C,2,0)),T=O=0}else c.head&&(c.head.extra=null);c.mode=6;case 6:if(1024&c.flags&&(M<(G=c.length)&&(G=M),G&&(c.head&&(o=c.head.extra_len-c.length,c.head.extra||(c.head.extra=new Array(c.head.extra_len)),i.arraySet(c.head.extra,I,N,G,o)),512&c.flags&&(c.check=a(c.check,I,G,N)),M-=G,N+=G,c.length-=G),c.length))break t;c.length=0,c.mode=7;case 7:if(2048&c.flags){if(M===0)break t;for(G=0;o=I[N+G++],c.head&&o&&c.length<65536&&(c.head.name+=String.fromCharCode(o)),o&&G<M;);if(512&c.flags&&(c.check=a(c.check,I,G,N)),M-=G,N+=G,o)break t}else c.head&&(c.head.name=null);c.length=0,c.mode=8;case 8:if(4096&c.flags){if(M===0)break t;for(G=0;o=I[N+G++],c.head&&o&&c.length<65536&&(c.head.comment+=String.fromCharCode(o)),o&&G<M;);if(512&c.flags&&(c.check=a(c.check,I,G,N)),M-=G,N+=G,o)break t}else c.head&&(c.head.comment=null);c.mode=9;case 9:if(512&c.flags){for(;T<16;){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}if(O!==(65535&c.check)){k.msg="header crc mismatch",c.mode=30;break}T=O=0}c.head&&(c.head.hcrc=c.flags>>9&1,c.head.done=!0),k.adler=c.check=0,c.mode=12;break;case 10:for(;T<32;){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}k.adler=c.check=p(O),T=O=0,c.mode=11;case 11:if(c.havedict===0)return k.next_out=tt,k.avail_out=Q,k.next_in=N,k.avail_in=M,c.hold=O,c.bits=T,2;k.adler=c.check=1,c.mode=12;case 12:if(j===5||j===6)break t;case 13:if(c.last){O>>>=7&T,T-=7&T,c.mode=27;break}for(;T<3;){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}switch(c.last=1&O,T-=1,3&(O>>>=1)){case 0:c.mode=14;break;case 1:if(W(c),c.mode=20,j!==6)break;O>>>=2,T-=2;break t;case 2:c.mode=17;break;case 3:k.msg="invalid block type",c.mode=30}O>>>=2,T-=2;break;case 14:for(O>>>=7&T,T-=7&T;T<32;){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}if((65535&O)!=(O>>>16^65535)){k.msg="invalid stored block lengths",c.mode=30;break}if(c.length=65535&O,T=O=0,c.mode=15,j===6)break t;case 15:c.mode=16;case 16:if(G=c.length){if(M<G&&(G=M),Q<G&&(G=Q),G===0)break t;i.arraySet(Y,I,N,G,tt),M-=G,N+=G,Q-=G,tt+=G,c.length-=G;break}c.mode=12;break;case 17:for(;T<14;){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}if(c.nlen=257+(31&O),O>>>=5,T-=5,c.ndist=1+(31&O),O>>>=5,T-=5,c.ncode=4+(15&O),O>>>=4,T-=4,286<c.nlen||30<c.ndist){k.msg="too many length or distance symbols",c.mode=30;break}c.have=0,c.mode=18;case 18:for(;c.have<c.ncode;){for(;T<3;){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}c.lens[L[c.have++]]=7&O,O>>>=3,T-=3}for(;c.have<19;)c.lens[L[c.have++]]=0;if(c.lencode=c.lendyn,c.lenbits=7,R={bits:c.lenbits},B=d(0,c.lens,0,19,c.lencode,0,c.work,R),c.lenbits=R.bits,B){k.msg="invalid code lengths set",c.mode=30;break}c.have=0,c.mode=19;case 19:for(;c.have<c.nlen+c.ndist;){for(;rt=(y=c.lencode[O&(1<<c.lenbits)-1])>>>16&255,ct=65535&y,!((et=y>>>24)<=T);){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}if(ct<16)O>>>=et,T-=et,c.lens[c.have++]=ct;else{if(ct===16){for(x=et+2;T<x;){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}if(O>>>=et,T-=et,c.have===0){k.msg="invalid bit length repeat",c.mode=30;break}o=c.lens[c.have-1],G=3+(3&O),O>>>=2,T-=2}else if(ct===17){for(x=et+3;T<x;){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}T-=et,o=0,G=3+(7&(O>>>=et)),O>>>=3,T-=3}else{for(x=et+7;T<x;){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}T-=et,o=0,G=11+(127&(O>>>=et)),O>>>=7,T-=7}if(c.have+G>c.nlen+c.ndist){k.msg="invalid bit length repeat",c.mode=30;break}for(;G--;)c.lens[c.have++]=o}}if(c.mode===30)break;if(c.lens[256]===0){k.msg="invalid code -- missing end-of-block",c.mode=30;break}if(c.lenbits=9,R={bits:c.lenbits},B=d(_,c.lens,0,c.nlen,c.lencode,0,c.work,R),c.lenbits=R.bits,B){k.msg="invalid literal/lengths set",c.mode=30;break}if(c.distbits=6,c.distcode=c.distdyn,R={bits:c.distbits},B=d(m,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,R),c.distbits=R.bits,B){k.msg="invalid distances set",c.mode=30;break}if(c.mode=20,j===6)break t;case 20:c.mode=21;case 21:if(6<=M&&258<=Q){k.next_out=tt,k.avail_out=Q,k.next_in=N,k.avail_in=M,c.hold=O,c.bits=T,l(k,H),tt=k.next_out,Y=k.output,Q=k.avail_out,N=k.next_in,I=k.input,M=k.avail_in,O=c.hold,T=c.bits,c.mode===12&&(c.back=-1);break}for(c.back=0;rt=(y=c.lencode[O&(1<<c.lenbits)-1])>>>16&255,ct=65535&y,!((et=y>>>24)<=T);){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}if(rt&&(240&rt)==0){for(ot=et,mt=rt,pt=ct;rt=(y=c.lencode[pt+((O&(1<<ot+mt)-1)>>ot)])>>>16&255,ct=65535&y,!(ot+(et=y>>>24)<=T);){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}O>>>=ot,T-=ot,c.back+=ot}if(O>>>=et,T-=et,c.back+=et,c.length=ct,rt===0){c.mode=26;break}if(32&rt){c.back=-1,c.mode=12;break}if(64&rt){k.msg="invalid literal/length code",c.mode=30;break}c.extra=15&rt,c.mode=22;case 22:if(c.extra){for(x=c.extra;T<x;){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}c.length+=O&(1<<c.extra)-1,O>>>=c.extra,T-=c.extra,c.back+=c.extra}c.was=c.length,c.mode=23;case 23:for(;rt=(y=c.distcode[O&(1<<c.distbits)-1])>>>16&255,ct=65535&y,!((et=y>>>24)<=T);){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}if((240&rt)==0){for(ot=et,mt=rt,pt=ct;rt=(y=c.distcode[pt+((O&(1<<ot+mt)-1)>>ot)])>>>16&255,ct=65535&y,!(ot+(et=y>>>24)<=T);){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}O>>>=ot,T-=ot,c.back+=ot}if(O>>>=et,T-=et,c.back+=et,64&rt){k.msg="invalid distance code",c.mode=30;break}c.offset=ct,c.extra=15&rt,c.mode=24;case 24:if(c.extra){for(x=c.extra;T<x;){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}c.offset+=O&(1<<c.extra)-1,O>>>=c.extra,T-=c.extra,c.back+=c.extra}if(c.offset>c.dmax){k.msg="invalid distance too far back",c.mode=30;break}c.mode=25;case 25:if(Q===0)break t;if(G=H-Q,c.offset>G){if((G=c.offset-G)>c.whave&&c.sane){k.msg="invalid distance too far back",c.mode=30;break}st=G>c.wnext?(G-=c.wnext,c.wsize-G):c.wnext-G,G>c.length&&(G=c.length),lt=c.window}else lt=Y,st=tt-c.offset,G=c.length;for(Q<G&&(G=Q),Q-=G,c.length-=G;Y[tt++]=lt[st++],--G;);c.length===0&&(c.mode=21);break;case 26:if(Q===0)break t;Y[tt++]=c.length,Q--,c.mode=21;break;case 27:if(c.wrap){for(;T<32;){if(M===0)break t;M--,O|=I[N++]<<T,T+=8}if(H-=Q,k.total_out+=H,c.total+=H,H&&(k.adler=c.check=c.flags?a(c.check,Y,H,tt-H):e(c.check,Y,H,tt-H)),H=Q,(c.flags?O:p(O))!==c.check){k.msg="incorrect data check",c.mode=30;break}T=O=0}c.mode=28;case 28:if(c.wrap&&c.flags){for(;T<32;){if(M===0)break t;M--,O+=I[N++]<<T,T+=8}if(O!==(4294967295&c.total)){k.msg="incorrect length check",c.mode=30;break}T=O=0}c.mode=29;case 29:B=1;break t;case 30:B=-3;break t;case 31:return-4;default:return h}return k.next_out=tt,k.avail_out=Q,k.next_in=N,k.avail_in=M,c.hold=O,c.bits=T,(c.wsize||H!==k.avail_out&&c.mode<30&&(c.mode<27||j!==4))&&q(k,k.output,k.next_out,H-k.avail_out)?(c.mode=31,-4):(J-=k.avail_in,H-=k.avail_out,k.total_in+=J,k.total_out+=H,c.total+=H,c.wrap&&H&&(k.adler=c.check=c.flags?a(c.check,Y,H,k.next_out-H):e(c.check,Y,H,k.next_out-H)),k.data_type=c.bits+(c.last?64:0)+(c.mode===12?128:0)+(c.mode===20||c.mode===15?256:0),(J==0&&H===0||j===4)&&B===v&&(B=-5),B)},s.inflateEnd=function(k){if(!k||!k.state)return h;var j=k.state;return j.window&&(j.window=null),k.state=null,v},s.inflateGetHeader=function(k,j){var c;return k&&k.state?(2&(c=k.state).wrap)==0?h:((c.head=j).done=!1,v):h},s.inflateSetDictionary=function(k,j){var c,I=j.length;return k&&k.state?(c=k.state).wrap!==0&&c.mode!==11?h:c.mode===11&&e(1,j,I,0)!==c.check?-3:q(k,j,I,I)?(c.mode=31,-4):(c.havedict=1,v):h},s.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,u,s){var i=t("../utils/common"),e=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],d=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];u.exports=function(_,m,v,h,g,f,b,p){var w,S,E,z,F,D,$,P,W,q=p.bits,k=0,j=0,c=0,I=0,Y=0,N=0,tt=0,M=0,Q=0,O=0,T=null,J=0,H=new i.Buf16(16),G=new i.Buf16(16),st=null,lt=0;for(k=0;k<=15;k++)H[k]=0;for(j=0;j<h;j++)H[m[v+j]]++;for(Y=q,I=15;1<=I&&H[I]===0;I--);if(I<Y&&(Y=I),I===0)return g[f++]=20971520,g[f++]=20971520,p.bits=1,0;for(c=1;c<I&&H[c]===0;c++);for(Y<c&&(Y=c),k=M=1;k<=15;k++)if(M<<=1,(M-=H[k])<0)return-1;if(0<M&&(_===0||I!==1))return-1;for(G[1]=0,k=1;k<15;k++)G[k+1]=G[k]+H[k];for(j=0;j<h;j++)m[v+j]!==0&&(b[G[m[v+j]]++]=j);if(D=_===0?(T=st=b,19):_===1?(T=e,J-=257,st=a,lt-=257,256):(T=l,st=d,-1),k=c,F=f,tt=j=O=0,E=-1,z=(Q=1<<(N=Y))-1,_===1&&852<Q||_===2&&592<Q)return 1;for(;;){for($=k-tt,W=b[j]<D?(P=0,b[j]):b[j]>D?(P=st[lt+b[j]],T[J+b[j]]):(P=96,0),w=1<<k-tt,c=S=1<<N;g[F+(O>>tt)+(S-=w)]=$<<24|P<<16|W|0,S!==0;);for(w=1<<k-1;O&w;)w>>=1;if(w!==0?(O&=w-1,O+=w):O=0,j++,--H[k]==0){if(k===I)break;k=m[v+b[j]]}if(Y<k&&(O&z)!==E){for(tt===0&&(tt=Y),F+=c,M=1<<(N=k-tt);N+tt<I&&!((M-=H[N+tt])<=0);)N++,M<<=1;if(Q+=1<<N,_===1&&852<Q||_===2&&592<Q)return 1;g[E=O&z]=Y<<24|N<<16|F-f|0}}return O!==0&&(g[F+O]=k-tt<<24|64<<16|0),p.bits=Y,0}},{"../utils/common":41}],51:[function(t,u,s){u.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(t,u,s){var i=t("../utils/common"),e=0,a=1;function l(y){for(var C=y.length;0<=--C;)y[C]=0}var d=0,_=29,m=256,v=m+1+_,h=30,g=19,f=2*v+1,b=15,p=16,w=7,S=256,E=16,z=17,F=18,D=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],$=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],P=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],W=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],q=new Array(2*(v+2));l(q);var k=new Array(2*h);l(k);var j=new Array(512);l(j);var c=new Array(256);l(c);var I=new Array(_);l(I);var Y,N,tt,M=new Array(h);function Q(y,C,L,U,A){this.static_tree=y,this.extra_bits=C,this.extra_base=L,this.elems=U,this.max_length=A,this.has_stree=y&&y.length}function O(y,C){this.dyn_tree=y,this.max_code=0,this.stat_desc=C}function T(y){return y<256?j[y]:j[256+(y>>>7)]}function J(y,C){y.pending_buf[y.pending++]=255&C,y.pending_buf[y.pending++]=C>>>8&255}function H(y,C,L){y.bi_valid>p-L?(y.bi_buf|=C<<y.bi_valid&65535,J(y,y.bi_buf),y.bi_buf=C>>p-y.bi_valid,y.bi_valid+=L-p):(y.bi_buf|=C<<y.bi_valid&65535,y.bi_valid+=L)}function G(y,C,L){H(y,L[2*C],L[2*C+1])}function st(y,C){for(var L=0;L|=1&y,y>>>=1,L<<=1,0<--C;);return L>>>1}function lt(y,C,L){var U,A,Z=new Array(b+1),K=0;for(U=1;U<=b;U++)Z[U]=K=K+L[U-1]<<1;for(A=0;A<=C;A++){var X=y[2*A+1];X!==0&&(y[2*A]=st(Z[X]++,X))}}function et(y){var C;for(C=0;C<v;C++)y.dyn_ltree[2*C]=0;for(C=0;C<h;C++)y.dyn_dtree[2*C]=0;for(C=0;C<g;C++)y.bl_tree[2*C]=0;y.dyn_ltree[2*S]=1,y.opt_len=y.static_len=0,y.last_lit=y.matches=0}function rt(y){8<y.bi_valid?J(y,y.bi_buf):0<y.bi_valid&&(y.pending_buf[y.pending++]=y.bi_buf),y.bi_buf=0,y.bi_valid=0}function ct(y,C,L,U){var A=2*C,Z=2*L;return y[A]<y[Z]||y[A]===y[Z]&&U[C]<=U[L]}function ot(y,C,L){for(var U=y.heap[L],A=L<<1;A<=y.heap_len&&(A<y.heap_len&&ct(C,y.heap[A+1],y.heap[A],y.depth)&&A++,!ct(C,U,y.heap[A],y.depth));)y.heap[L]=y.heap[A],L=A,A<<=1;y.heap[L]=U}function mt(y,C,L){var U,A,Z,K,X=0;if(y.last_lit!==0)for(;U=y.pending_buf[y.d_buf+2*X]<<8|y.pending_buf[y.d_buf+2*X+1],A=y.pending_buf[y.l_buf+X],X++,U===0?G(y,A,C):(G(y,(Z=c[A])+m+1,C),(K=D[Z])!==0&&H(y,A-=I[Z],K),G(y,Z=T(--U),L),(K=$[Z])!==0&&H(y,U-=M[Z],K)),X<y.last_lit;);G(y,S,C)}function pt(y,C){var L,U,A,Z=C.dyn_tree,K=C.stat_desc.static_tree,X=C.stat_desc.has_stree,V=C.stat_desc.elems,it=-1;for(y.heap_len=0,y.heap_max=f,L=0;L<V;L++)Z[2*L]!==0?(y.heap[++y.heap_len]=it=L,y.depth[L]=0):Z[2*L+1]=0;for(;y.heap_len<2;)Z[2*(A=y.heap[++y.heap_len]=it<2?++it:0)]=1,y.depth[A]=0,y.opt_len--,X&&(y.static_len-=K[2*A+1]);for(C.max_code=it,L=y.heap_len>>1;1<=L;L--)ot(y,Z,L);for(A=V;L=y.heap[1],y.heap[1]=y.heap[y.heap_len--],ot(y,Z,1),U=y.heap[1],y.heap[--y.heap_max]=L,y.heap[--y.heap_max]=U,Z[2*A]=Z[2*L]+Z[2*U],y.depth[A]=(y.depth[L]>=y.depth[U]?y.depth[L]:y.depth[U])+1,Z[2*L+1]=Z[2*U+1]=A,y.heap[1]=A++,ot(y,Z,1),2<=y.heap_len;);y.heap[--y.heap_max]=y.heap[1],(function(nt,dt){var kt,gt,St,at,Tt,Zt,_t=dt.dyn_tree,le=dt.max_code,bn=dt.stat_desc.static_tree,yn=dt.stat_desc.has_stree,vn=dt.stat_desc.extra_bits,ue=dt.stat_desc.extra_base,Et=dt.stat_desc.max_length,It=0;for(at=0;at<=b;at++)nt.bl_count[at]=0;for(_t[2*nt.heap[nt.heap_max]+1]=0,kt=nt.heap_max+1;kt<f;kt++)Et<(at=_t[2*_t[2*(gt=nt.heap[kt])+1]+1]+1)&&(at=Et,It++),_t[2*gt+1]=at,le<gt||(nt.bl_count[at]++,Tt=0,ue<=gt&&(Tt=vn[gt-ue]),Zt=_t[2*gt],nt.opt_len+=Zt*(at+Tt),yn&&(nt.static_len+=Zt*(bn[2*gt+1]+Tt)));if(It!==0){do{for(at=Et-1;nt.bl_count[at]===0;)at--;nt.bl_count[at]--,nt.bl_count[at+1]+=2,nt.bl_count[Et]--,It-=2}while(0<It);for(at=Et;at!==0;at--)for(gt=nt.bl_count[at];gt!==0;)le<(St=nt.heap[--kt])||(_t[2*St+1]!==at&&(nt.opt_len+=(at-_t[2*St+1])*_t[2*St],_t[2*St+1]=at),gt--)}})(y,C),lt(Z,it,y.bl_count)}function o(y,C,L){var U,A,Z=-1,K=C[1],X=0,V=7,it=4;for(K===0&&(V=138,it=3),C[2*(L+1)+1]=65535,U=0;U<=L;U++)A=K,K=C[2*(U+1)+1],++X<V&&A===K||(X<it?y.bl_tree[2*A]+=X:A!==0?(A!==Z&&y.bl_tree[2*A]++,y.bl_tree[2*E]++):X<=10?y.bl_tree[2*z]++:y.bl_tree[2*F]++,Z=A,it=(X=0)===K?(V=138,3):A===K?(V=6,3):(V=7,4))}function B(y,C,L){var U,A,Z=-1,K=C[1],X=0,V=7,it=4;for(K===0&&(V=138,it=3),U=0;U<=L;U++)if(A=K,K=C[2*(U+1)+1],!(++X<V&&A===K)){if(X<it)for(;G(y,A,y.bl_tree),--X!=0;);else A!==0?(A!==Z&&(G(y,A,y.bl_tree),X--),G(y,E,y.bl_tree),H(y,X-3,2)):X<=10?(G(y,z,y.bl_tree),H(y,X-3,3)):(G(y,F,y.bl_tree),H(y,X-11,7));Z=A,it=(X=0)===K?(V=138,3):A===K?(V=6,3):(V=7,4)}}l(M);var R=!1;function x(y,C,L,U){H(y,(d<<1)+(U?1:0),3),(function(A,Z,K,X){rt(A),J(A,K),J(A,~K),i.arraySet(A.pending_buf,A.window,Z,K,A.pending),A.pending+=K})(y,C,L)}s._tr_init=function(y){R||((function(){var C,L,U,A,Z,K=new Array(b+1);for(A=U=0;A<_-1;A++)for(I[A]=U,C=0;C<1<<D[A];C++)c[U++]=A;for(c[U-1]=A,A=Z=0;A<16;A++)for(M[A]=Z,C=0;C<1<<$[A];C++)j[Z++]=A;for(Z>>=7;A<h;A++)for(M[A]=Z<<7,C=0;C<1<<$[A]-7;C++)j[256+Z++]=A;for(L=0;L<=b;L++)K[L]=0;for(C=0;C<=143;)q[2*C+1]=8,C++,K[8]++;for(;C<=255;)q[2*C+1]=9,C++,K[9]++;for(;C<=279;)q[2*C+1]=7,C++,K[7]++;for(;C<=287;)q[2*C+1]=8,C++,K[8]++;for(lt(q,v+1,K),C=0;C<h;C++)k[2*C+1]=5,k[2*C]=st(C,5);Y=new Q(q,D,m+1,v,b),N=new Q(k,$,0,h,b),tt=new Q(new Array(0),P,0,g,w)})(),R=!0),y.l_desc=new O(y.dyn_ltree,Y),y.d_desc=new O(y.dyn_dtree,N),y.bl_desc=new O(y.bl_tree,tt),y.bi_buf=0,y.bi_valid=0,et(y)},s._tr_stored_block=x,s._tr_flush_block=function(y,C,L,U){var A,Z,K=0;0<y.level?(y.strm.data_type===2&&(y.strm.data_type=(function(X){var V,it=4093624447;for(V=0;V<=31;V++,it>>>=1)if(1&it&&X.dyn_ltree[2*V]!==0)return e;if(X.dyn_ltree[18]!==0||X.dyn_ltree[20]!==0||X.dyn_ltree[26]!==0)return a;for(V=32;V<m;V++)if(X.dyn_ltree[2*V]!==0)return a;return e})(y)),pt(y,y.l_desc),pt(y,y.d_desc),K=(function(X){var V;for(o(X,X.dyn_ltree,X.l_desc.max_code),o(X,X.dyn_dtree,X.d_desc.max_code),pt(X,X.bl_desc),V=g-1;3<=V&&X.bl_tree[2*W[V]+1]===0;V--);return X.opt_len+=3*(V+1)+5+5+4,V})(y),A=y.opt_len+3+7>>>3,(Z=y.static_len+3+7>>>3)<=A&&(A=Z)):A=Z=L+5,L+4<=A&&C!==-1?x(y,C,L,U):y.strategy===4||Z===A?(H(y,2+(U?1:0),3),mt(y,q,k)):(H(y,4+(U?1:0),3),(function(X,V,it,nt){var dt;for(H(X,V-257,5),H(X,it-1,5),H(X,nt-4,4),dt=0;dt<nt;dt++)H(X,X.bl_tree[2*W[dt]+1],3);B(X,X.dyn_ltree,V-1),B(X,X.dyn_dtree,it-1)})(y,y.l_desc.max_code+1,y.d_desc.max_code+1,K+1),mt(y,y.dyn_ltree,y.dyn_dtree)),et(y),U&&rt(y)},s._tr_tally=function(y,C,L){return y.pending_buf[y.d_buf+2*y.last_lit]=C>>>8&255,y.pending_buf[y.d_buf+2*y.last_lit+1]=255&C,y.pending_buf[y.l_buf+y.last_lit]=255&L,y.last_lit++,C===0?y.dyn_ltree[2*L]++:(y.matches++,C--,y.dyn_ltree[2*(c[L]+m+1)]++,y.dyn_dtree[2*T(C)]++),y.last_lit===y.lit_bufsize-1},s._tr_align=function(y){H(y,2,3),G(y,S,q),(function(C){C.bi_valid===16?(J(C,C.bi_buf),C.bi_buf=0,C.bi_valid=0):8<=C.bi_valid&&(C.pending_buf[C.pending++]=255&C.bi_buf,C.bi_buf>>=8,C.bi_valid-=8)})(y)}},{"../utils/common":41}],53:[function(t,u,s){u.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,u,s){(function(i){(function(e,a){if(!e.setImmediate){var l,d,_,m,v=1,h={},g=!1,f=e.document,b=Object.getPrototypeOf&&Object.getPrototypeOf(e);b=b&&b.setTimeout?b:e,l={}.toString.call(e.process)==="[object process]"?function(E){process.nextTick(function(){w(E)})}:(function(){if(e.postMessage&&!e.importScripts){var E=!0,z=e.onmessage;return e.onmessage=function(){E=!1},e.postMessage("","*"),e.onmessage=z,E}})()?(m="setImmediate$"+Math.random()+"$",e.addEventListener?e.addEventListener("message",S,!1):e.attachEvent("onmessage",S),function(E){e.postMessage(m+E,"*")}):e.MessageChannel?((_=new MessageChannel).port1.onmessage=function(E){w(E.data)},function(E){_.port2.postMessage(E)}):f&&"onreadystatechange"in f.createElement("script")?(d=f.documentElement,function(E){var z=f.createElement("script");z.onreadystatechange=function(){w(E),z.onreadystatechange=null,d.removeChild(z),z=null},d.appendChild(z)}):function(E){setTimeout(w,0,E)},b.setImmediate=function(E){typeof E!="function"&&(E=new Function(""+E));for(var z=new Array(arguments.length-1),F=0;F<z.length;F++)z[F]=arguments[F+1];var D={callback:E,args:z};return h[v]=D,l(v),v++},b.clearImmediate=p}function p(E){delete h[E]}function w(E){if(g)setTimeout(w,0,E);else{var z=h[E];if(z){g=!0;try{(function(F){var D=F.callback,$=F.args;switch($.length){case 0:D();break;case 1:D($[0]);break;case 2:D($[0],$[1]);break;case 3:D($[0],$[1],$[2]);break;default:D.apply(a,$)}})(z)}finally{p(E),g=!1}}}}function S(E){E.source===e&&typeof E.data=="string"&&E.data.indexOf(m)===0&&w(+E.data.slice(m.length))}})(typeof self>"u"?i===void 0?this:i:self)}).call(this,typeof Ot<"u"?Ot:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Xt)),Xt.exports}var Yn=Kn();const Vn=Hn(Yn);function ft(n){const r=n.replace(/\\/g,"/"),t=r.startsWith("/"),u=[];for(const s of r.split("/"))if(!(s===""||s===".")){if(s===".."){u.length>0&&u[u.length-1]!==".."?u.pop():t||u.push("..");continue}u.push(s)}return(t?"/":"")+u.join("/")}function ee(n){const r=n.lastIndexOf("/");return r>=0?n.slice(0,r):""}function yt(n){return n.split("/").pop()??n}function vt(n){const r=yt(n).toLowerCase().match(/\.([^.]+)$/);return r?r[1]:""}function Bt(n){return yt(n).replace(/\.[^.]+$/,"")}function bt(...n){return ft(n.filter(r=>!!r).join("/"))}function qn(n,r){if(!n)return r;const t=n.endsWith("/")?n:`${n}/`;return r.startsWith(t)?r.slice(t.length):r}const Kt=/(\\(input|include) *\{([^{}]+)\})/g;function ne(n,r,t){const u=ee(r);return[n,`${n}.tex`,u?bt(u,n):n,u?bt(u,`${n}.tex`):`${n}.tex`].map(ft).find(i=>i in t)??null}function _e(n,r,t,u=3){let s=0;const i=[],e=new Set,a=d=>{let _=!1;return{output:d.replace(Kt,(v,h,g,f)=>{const b=ne(f,r,t);return b?e.has(b)?"":(_=!0,s+=1,e.add(b),t[b]):(i.includes(f)||i.push(f),v)}),changed:_}};let l=n;for(let d=0;d<u;d+=1){const{output:_,changed:m}=a(l);if(l=_,!m)break}return{expandedText:l,expandedCount:s,missingInputs:i,consumedPaths:[...e]}}function Jn(n){const r=new Set;for(const[t,u]of Object.entries(n)){Kt.lastIndex=0;let s;for(;(s=Kt.exec(u))!==null;){const i=ne(s[3],t,n);i&&i!==t&&r.add(i)}}return r}const Yt=/<xi:include\b[^>]*\bhref\s*=\s*(?:"([^"]+)"|'([^']+)')[^>]*\/>/g;function je(n,r,t){const u=ee(r),s=[n,`${n}.ptx`,`${n}.xml`,u?bt(u,n):null,u?bt(u,`${n}.ptx`):`${n}.ptx`,u?bt(u,`${n}.xml`):`${n}.xml`].filter(i=>i!==null);for(const i of s){const e=ft(i);if(e in t)return e}return null}function Qn(n){return n.replace(/^\s*<\?xml[^?]*\?>\s*/,"")}function Be(n,r,t,u=5){let s=0;const i=[],e=[],a=new Set,l=(_,m)=>{let v=!1;return{output:_.replace(Yt,(g,f,b)=>{const p=f??b??"",w=je(p,m,t);return w?e.includes(w)?g:(v=!0,s+=1,a.add(w),Qn(t[w])):(i.includes(p)||i.push(p),g)}),changed:v}};let d=n;for(let _=0;_<u;_+=1){e.push(r);const{output:m,changed:v}=l(d,r);if(e.pop(),d=m,!v)break}return{expandedText:d,expandedCount:s,missingIncludes:i,consumedPaths:[...a]}}function tr(n){const r=new Set;for(const[t,u]of Object.entries(n)){Yt.lastIndex=0;let s;for(;(s=Yt.exec(u))!==null;){const i=s[1]??s[2]??"",e=je(i,t,n);e&&e!==t&&r.add(e)}}return r}function $e(n){const{mainSource:r,publication:t,outputBase:u="output"}=n;return`<?xml version="1.0" encoding="UTF-8"?>
|
|
32
|
-
<project ptx-version="2">
|
|
33
|
-
<targets>
|
|
34
|
-
<target name="web">
|
|
35
|
-
<format>html</format>
|
|
36
|
-
<source>${r}</source>
|
|
37
|
-
<publication>${t}</publication>
|
|
38
|
-
<output-dir>${u}/web</output-dir>
|
|
39
|
-
</target>
|
|
40
|
-
<target name="print">
|
|
41
|
-
<format>pdf</format>
|
|
42
|
-
<source>${r}</source>
|
|
43
|
-
<publication>${t}</publication>
|
|
44
|
-
<output-dir>${u}/print</output-dir>
|
|
45
|
-
</target>
|
|
46
|
-
</targets>
|
|
47
|
-
</project>
|
|
48
|
-
`}function re(){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
49
|
-
<publication>
|
|
50
|
-
<source>
|
|
51
|
-
<directories external="external" generated="generated"/>
|
|
52
|
-
</source>
|
|
53
|
-
<common>
|
|
54
|
-
<chunking level="1"/>
|
|
55
|
-
</common>
|
|
56
|
-
</publication>
|
|
57
|
-
`}function er(){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
58
|
-
`}const be=/([a-zA-Z_:][\w:.-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;function $t(n){const r={};let t;for(be.lastIndex=0;(t=be.exec(n))!==null;)r[t[1]]=t[2]??t[3]??"";return r}function Le(n){const r=[];let t=0;const u=n.length;for(;t<u;){const s=n.indexOf("<",t);if(s<0)break;if(n.startsWith("<!--",s)){const f=n.indexOf("-->",s+4);t=f<0?u:f+3;continue}if(n.startsWith("<![CDATA[",s)){const f=n.indexOf("]]>",s+9);t=f<0?u:f+3;continue}if(n.startsWith("<?",s)){const f=n.indexOf("?>",s+2);t=f<0?u:f+2;continue}if(n.startsWith("<!",s)){const f=n.indexOf(">",s+2);t=f<0?u:f+1;continue}let i=s+1,e=!1;n[i]==="/"&&(e=!0,i+=1);const a=/^[a-zA-Z_:][\w:.-]*/.exec(n.slice(i));if(!a){t=s+1;continue}const l=a[0];i+=l.length;let d=i,_=null;for(;i<u;){const f=n[i];if(_){f===_&&(_=null),i+=1;continue}if(f==='"'||f==="'"){_=f,i+=1;continue}if(f===">")break;i+=1}if(i>=u)break;const m=i+1,v=n.slice(d,i),h=!e&&v.trimEnd().endsWith("/"),g=h?v.replace(/\/\s*$/,""):v;e?r.push({kind:"close",name:l,pos:s,end:m}):h?r.push({kind:"selfclose",name:l,attrs:g,pos:s,end:m}):r.push({kind:"open",name:l,attrs:g,pos:s,end:m}),t=m}return r}function ie(n,r){return Ne(n,t=>t===r)}function Ne(n,r){const t=Le(n),u=[];let s=0,i=null;for(const e of t){if(e.kind==="selfclose"){s===0&&r(e.name)&&u.push({name:e.name,start:e.pos,startTagEnd:e.end,contentEnd:e.end,end:e.end,inner:"",outer:n.slice(e.pos,e.end),attributes:$t(e.attrs)});continue}if(e.kind==="open"){s===0&&r(e.name)&&!i&&(i=e),s+=1;continue}s-=1,s<0&&(s=0),i&&s===0&&e.name===i.name&&(u.push({name:i.name,start:i.pos,startTagEnd:i.end,contentEnd:e.pos,end:e.end,inner:n.slice(i.end,e.pos),outer:n.slice(i.pos,e.end),attributes:$t(i.attrs)}),i=null)}return u}function ht(n,r){return ie(n,r)[0]??null}function Ct(n,r){const t=Le(n);let u=0,s=null,i=-1;for(const e of t){if(e.kind==="selfclose"){if(!s&&e.name===r)return{name:r,start:e.pos,startTagEnd:e.end,contentEnd:e.end,end:e.end,inner:"",outer:n.slice(e.pos,e.end),attributes:$t(e.attrs)};continue}if(e.kind==="open"){!s&&e.name===r&&(s=e,i=u),u+=1;continue}if(u-=1,u<0&&(u=0),s&&e.name===r&&u===i){const a=s.attrs;return{name:r,start:s.pos,startTagEnd:s.end,contentEnd:e.pos,end:e.end,inner:n.slice(s.end,e.pos),outer:n.slice(s.pos,e.end),attributes:$t(a)}}}return null}function Ue(n){return Ct(n,"book")?"book":Ct(n,"article")?"article":Ct(n,"chapter")?"book":"article"}const nr="http://www.w3.org/2001/XInclude";function se(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)}function xt(n,r){const t=String(r).length;return String(n).padStart(Math.max(t,2),"0")}function Me(n,r){const t=[...r].sort((i,e)=>i.start-e.start);let u="",s=0;for(const i of t)u+=n.slice(s,i.start),u+=i.replacement,s=i.end;return u+=n.slice(s),u}function Vt(n){return n.replace(/<([a-zA-Z_][\w:.-]*)\b([^>]*)>/,(r,t,u)=>/\bxmlns:xi\s*=/.test(u)?r:`<${t}${u} xmlns:xi="${nr}">`)}function qt(n){return n.startsWith("<?xml")?n:er()+n}const rr=["book","article"],We=["frontmatter","preface","acknowledgement","dedication","biography","contributors","part","chapter","section","subsection","subsubsection","exercises","worksheet","reading-questions","references","solutions","glossary","backmatter","appendix","index","colophon"],ir=new Set(We);function Ze(n){return ir.has(n)}const sr={chapter:"ch",section:"sec",subsection:"subsec",subsubsection:"subsubsec",appendix:"app"};function oe(n){return sr[n]??n}const or=new Set(["frontmatter","backmatter","preface","acknowledgement","dedication","biography","contributors","colophon","glossary","index"]);function ar(n){return or.has(n)}function Mt(n){return n.trim().replace(/[^a-zA-Z0-9\-_]+/g,"-").replace(/^[^a-zA-Z_]+/,"").replace(/-+$/,"")}class ae{used=new Set;claim(r){let t=r,u=2;for(;this.used.has(t);)t=`${r}-${u}`,u+=1;return this.used.add(t),t}has(r){return this.used.has(r)}}function Jt(n,r,t){if(n){const u=Mt(n)||t,s=r.claim(u);return s!==n?{ref:s,renamedFrom:n,generated:!1}:{ref:s,generated:!1}}return{ref:r.claim(t),generated:!0}}function Lt(n,r,t,u){r.renamedFrom!==void 0?n.push({action:"anomaly",severity:"warning",kind:"structure",category:"renamed_xml_id",macro:t,occurrences:1,message:`${t} id \`${r.renamedFrom}\` is not a valid ref (or collides with another); renamed to \`${r.ref}\`. Cross-references to the old id will break.`}):r.generated&&n.push({action:"anomaly",severity:"info",kind:"structure",category:"missing_xml_id",macro:t,occurrences:1,message:`${t} at position ${u} has no id; assigned \`${r.ref}\`.`})}function Nt(n,r){return Object.entries(n).map(([t,u])=>{const s=t.split("/").pop()??t,i=s.replace(/\.[^.]+$/,"");return{ref:r.claim(Mt(i)||"asset"),fileName:s,data:u}})}function Xe(n,r){return n.splitLevel!==void 0?Math.max(0,n.splitLevel):n.splitChapters===!1?0:n.splitSections?r==="book"?2:1:r==="book"?1:0}function Ge(n,r,t){const u=n.slice(0,r),s=n.slice(r);return/\bxml:id\s*=\s*(?:"[^"]*"|'[^']*')/.test(u)?u.replace(/\bxml:id\s*=\s*(?:"[^"]*"|'[^']*')/,`xml:id="${t}"`)+s:u.replace(/^<([a-zA-Z_:][\w:.-]*)/,`<$1 xml:id="${t}"`)+s}function He(n){const r=ht(n,"title");return r?r.inner.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim():""}function Ke(n,r,t){return Jt(n.attributes["xml:id"],r,t)}function Ye(n,r){const t=n.outer.slice(0,n.startTagEnd-n.start),u=n.outer.slice(n.contentEnd-n.start);return t+r+u}function Ve(n,r,t,u){if(t>u.maxDepth)return n;const s=Ne(n,Ze);if(s.length===0)return n;const i=s.map((e,a)=>{const l=a+1,_=`${oe(e.name)}-${xt(l,s.length)}`,m=t===1?_:`${r}-${_}`,v=Ke(e,u.refs,m);Lt(u.warnings,v,e.name,l);const h=Ve(e.inner,v.ref,t+1,u);return u.divisions.push({xmlId:v.ref,type:e.name,title:He(e.inner),sourceFormat:"pretext",content:Ge(Ye(e,h),e.startTagEnd-e.start,v.ref),isRoot:!1}),{start:e.start,end:e.end,replacement:`<plus:${e.name} ref="${v.ref}"/>`}});return Me(n,i)}function qe(n,r={}){const t=[],u=r.documentKind??Ue(n),s=Xe(r,u),i=Ct(n,"pretext"),e=i?i.inner:n,a=ht(e,"docinfo"),l=a?.outer.trim()??"";let d=ht(e,"book")??ht(e,"article");if(!d){const p=u==="book"?"book":"article",w=(a?e.slice(0,a.start)+e.slice(a.end):e).trim();d=ht(`<${p}>
|
|
59
|
-
${w}
|
|
60
|
-
</${p}>`,p)}if(!d)throw new Error("Could not locate a root element for the division pool.");u==="book"&&d.name!=="book"&&t.push({action:"anomaly",severity:"warning",kind:"structure",category:"missing_root",macro:"book",occurrences:1,message:"Document was treated as a book but no <book> element found; importing with the existing root."});const _=new ae,m=[],v=Ke(d,_,"document");v.renamedFrom!==void 0&&Lt(t,v,d.name,1);const h=He(d.inner),g=Ve(d.inner,v.ref,1,{refs:_,divisions:m,warnings:t,maxDepth:s}),f={xmlId:v.ref,type:d.name==="book"?"book":"article",title:h,sourceFormat:"pretext",content:Ge(Ye(d,g),d.startTagEnd-d.start,v.ref),isRoot:!0};m.unshift(f);const b=Nt(r.assets??{},_);return{project:{title:h,docinfo:l,documentKind:u,divisions:m,assets:b},warnings:t}}function Je(n,r,t={}){return r==="latex"?fr(n,t):hr(n,t)}function ye(n){return Mt(se(n))}function Wt(n,r,t,u,s,i,e){if(n){const d=Jt(n,t,ye(r)||u);return Lt(e,d,s,i),d.ref}const a=ye(r);if(a)return t.claim(a);const l=Jt(void 0,t,u);return Lt(e,l,s,i),l.ref}function Qe(n){return n.replace(/\\[a-zA-Z]+\{([^{}]*)\}/g,"$1").replace(/\\[a-zA-Z]+/g,"").replace(/[{}]/g,"").replace(/\s+/g," ").trim()}function cr(n,r){let t=r;for(;t<n.length&&/\s/.test(n[t]);)t++;if(n[t]!=="{")return null;const u=t;let s=0;for(;t<n.length;t++){const i=n[t];if(i==="\\"){t++;continue}if(i==="{")s++;else if(i==="}"&&(s--,s===0))return{inner:n.slice(u+1,t),end:t+1}}return null}function lr(n,r){let t=r;for(;t<n.length&&/\s/.test(n[t]);)t++;if(n[t]!=="[")return r;let u=0;for(;t<n.length;t++){const s=n[t];if(s==="\\"){t++;continue}if(s==="[")u++;else if(s==="]"&&(u--,u===0))return t+1}return r}function ur(n,r){let t=0;for(let u=0;u<r;u++){const s=n[u];if(s==="\\"){u++;continue}s==="{"?t++:s==="}"&&t--}return t}function tn(n,r){const t=[],u=new RegExp(`\\\\${r}\\*?(?![a-zA-Z])`,"g");let s;for(;(s=u.exec(n))!==null;){const i=s.index;if(ur(n,i)!==0)continue;const e=cr(n,lr(n,i+s[0].length));if(!e)continue;let a=e.end,l;const d=/^\s*\\label\s*\{([^{}]*)\}/.exec(n.slice(e.end));d&&(l=d[1].trim(),a=e.end+d[0].length),t.push({start:i,rawTitle:e.inner,contentStart:a,labelId:l})}return t}function fr(n,r){const t=[],{body:u}=At(n),s=(u||n).trim(),i=tn(s,"chapter"),e=r.documentKind??(i.length>0?"book":"article"),a=r.splitChapters??e==="book",l=r.splitSections??!1,d=new ae,_=d.claim("document"),m=[];let v=s;if(a&&e==="book"&&i.length>0){const b=[s.slice(0,i[0].start)];i.forEach((p,w)=>{const S=i[w+1]?.start??s.length,E=Qe(p.rawTitle),z=Wt(p.labelId,E,d,`ch-${xt(w+1,i.length)}`,"chapter",w+1,t);let F=s.slice(p.contentStart,S);l&&(F=dr(F,z,d,m,t)),m.push({xmlId:z,type:"chapter",title:E,sourceFormat:"latex",content:`\\chapter{${p.rawTitle}}\\label{${z}}
|
|
61
|
-
${F.trim()}`,isRoot:!1}),b.push(`\\plus{chapter}{${z}}`)}),v=b.join(`
|
|
62
|
-
|
|
63
|
-
`).trim()}const h=e==="book"?"book":"article",g=r.title??"",f=`\\${h}{${g}}\\label{${_}}`;return m.unshift({xmlId:_,type:h,title:g,sourceFormat:"latex",content:v?`${f}
|
|
64
|
-
${v}`:f,isRoot:!0}),{project:{title:r.title??"",docinfo:r.docinfo??"",documentKind:e,divisions:m,assets:Nt(r.assets??{},d)},warnings:t}}function dr(n,r,t,u,s){const i=tn(n,"section");if(i.length===0)return n;const e=[n.slice(0,i[0].start)];return i.forEach((a,l)=>{const d=i[l+1]?.start??n.length,_=Qe(a.rawTitle),m=Wt(a.labelId,_,t,`${r}-sec-${xt(l+1,i.length)}`,"section",l+1,s),v=n.slice(a.contentStart,d).trim();u.push({xmlId:m,type:"section",title:_,sourceFormat:"latex",content:`\\section{${a.rawTitle}}\\label{${m}}
|
|
65
|
-
${v}`,isRoot:!1}),e.push(`\\plus{section}{${m}}`)}),e.join(`
|
|
66
|
-
|
|
67
|
-
`).trim()}function en(n,r){const t=new RegExp(`^#{${r}}\\s+(.*)$`),u=[],s=[];let i=null,e=!1,a="";for(const l of n.split(`
|
|
68
|
-
`)){const d=/^\s*(```+|~~~+)/.exec(l);if(d){const m=d[1][0];e?m===a&&(e=!1):(e=!0,a=m),(i?i.bodyLines:s).push(l);continue}const _=e?null:t.exec(l);_?(i&&u.push(i),i={headingText:_[1].trim(),bodyLines:[]}):(i?i.bodyLines:s).push(l)}return i&&u.push(i),{preamble:s.join(`
|
|
69
|
-
`).trim(),sections:u.map(l=>({headingText:l.headingText,body:l.bodyLines.join(`
|
|
70
|
-
`).trim()}))}}function Pt(n){return`---
|
|
71
|
-
${Object.entries(n).map(([t,u])=>`${t}: ${u}`).join(`
|
|
72
|
-
`)}
|
|
73
|
-
---`}function hr(n,r){const t=[],u=n.trim(),s=r.documentKind??"article",i=r.splitChapters??s==="book",e=r.splitSections??!1,a=new ae,l=a.claim("document"),d=[];if(!(i&&s==="book"))return d.push({xmlId:l,type:s==="book"?"book":"article",title:r.title??"",sourceFormat:"markdown",content:`${Pt({division:s,id:l,title:r.title??""})}
|
|
74
|
-
|
|
75
|
-
${u}`.trim(),isRoot:!0}),{project:{title:r.title??"",docinfo:r.docinfo??"",documentKind:s,divisions:d,assets:Nt(r.assets??{},a)},warnings:t};const{preamble:_,sections:m}=en(u,1),v=_?[_]:[];return m.forEach((h,g)=>{const f=Wt(void 0,h.headingText,a,`ch-${xt(g+1,m.length)}`,"chapter",g+1,t);let b=h.body;e&&(b=pr(h.body,f,a,d,t)),d.push({xmlId:f,type:"chapter",title:h.headingText,sourceFormat:"markdown",content:`${Pt({division:"chapter",id:f,title:h.headingText})}
|
|
76
|
-
|
|
77
|
-
# ${h.headingText}
|
|
78
|
-
|
|
79
|
-
${b}`.trim(),isRoot:!1}),v.push(`::chapter{ref="${f}"}`)}),d.unshift({xmlId:l,type:"book",title:r.title??"",sourceFormat:"markdown",content:`${Pt({division:"book",id:l,title:r.title??""})}
|
|
80
|
-
|
|
81
|
-
${v.join(`
|
|
82
|
-
|
|
83
|
-
`)}`.trim(),isRoot:!0}),{project:{title:r.title??"",docinfo:r.docinfo??"",documentKind:s,divisions:d,assets:Nt(r.assets??{},a)},warnings:t}}function pr(n,r,t,u,s){const{preamble:i,sections:e}=en(n,2);if(e.length===0)return n;const a=i?[i]:[];return e.forEach((l,d)=>{const _=Wt(void 0,l.headingText,t,`${r}-sec-${xt(d+1,e.length)}`,"section",d+1,s);u.push({xmlId:_,type:"section",title:l.headingText,sourceFormat:"markdown",content:`${Pt({division:"section",id:_,title:l.headingText})}
|
|
84
|
-
|
|
85
|
-
# ${l.headingText}
|
|
86
|
-
|
|
87
|
-
${l.body}`.trim(),isRoot:!1}),a.push(`::section{ref="${_}"}`)}),a.join(`
|
|
88
|
-
|
|
89
|
-
`).trim()}const Gt={mainSourcePath:"source/main.ptx",publicationPath:"publication/publication.ptx",projectFilePath:"project.ptx"},Qt=/<plus:([a-zA-Z][a-zA-Z-]*)\s+ref="([^"]+)"\s*\/>/g;function Ft(n){const r=[];Qt.lastIndex=0;let t;for(;(t=Qt.exec(n))!==null;)r.push(t[2]);return r}function mr(n,r){const t=se(n)||"division";return t.startsWith(`${r}-`)?t:`${r}-${t}`}function gr(n,r){let t=r,u=2;for(;n.has(t);)t=`${r}-${u}`,u+=1;return n.add(t),t}function _r(n,r){const t=`${r}-`;return n.startsWith(t)?n.slice(t.length):n}function ve(n,r){return n.replace(Qt,(t,u,s)=>{const i=r.get(s);return i?`<xi:include href="${i}"/>`:t})}function nn(n,r={}){const t=r.mainSourcePath??Gt.mainSourcePath,u=r.publicationPath??Gt.publicationPath,s=r.projectFilePath??Gt.projectFilePath,i=r.includeScaffold??!0,e={},a=new Map(n.divisions.map(E=>[E.xmlId,E])),l=n.divisions.find(E=>E.isRoot);if(!l)throw new Error("Division pool has no root division.");const d=new Map,_=t.includes("/")?t.slice(0,t.lastIndexOf("/")+1):"",m=[],v=new Set,h=new Map;function g(E,z){let F=h.get(E);return F||(F=new Set,h.set(E,F)),gr(F,z)}function f(E,z,F,D){if(v.has(E.xmlId))return;v.add(E.xmlId);const $=g(z,ar(E.type)?E.type:mr(_r(E.xmlId,D),oe(E.type)));d.set(E.xmlId,`${F}${$}.ptx`),m.push({division:E,filePath:`${z}${$}.ptx`});for(const P of Ft(E.content)){const W=a.get(P);W&&f(W,`${z}${$}/`,`${$}/`,E.xmlId)}}for(const E of Ft(l.content)){const z=a.get(E);z&&f(z,_,"",l.xmlId)}const b=new Set;for(const E of n.divisions)for(const z of Ft(E.content))b.add(z);for(const E of n.divisions)E.isRoot||b.has(E.xmlId)||f(E,_,"",l.xmlId);for(const{division:E,filePath:z}of m){const F=ve(E.content,d),D=F===E.content?F:Vt(F);e[z]=qt(D)}const p=ve(l.content,d),S=`<pretext>
|
|
90
|
-
${n.docinfo?`${n.docinfo}
|
|
91
|
-
`:""}${p}
|
|
92
|
-
</pretext>`;return e[t]=qt(p===l.content?S:Vt(S)),i&&(e[s]=$e({mainSource:t,publication:u}),e[u]=re()),{files:e}}const br="source",yr="publication",we="main.ptx";function zt(n,r){const t=ht(n.inner,r);if(!t)return;const u=t.inner.trim();return u.length>0?u:void 0}function Ht(n,r,t){const u=zt(n,r);if(u!==void 0)return ft(u);const s=n.attributes[r];if(s!==void 0&&s.trim().length>0)return bt(t,s.trim())}function rn(n,r){const t=ht(n,"project");if(!t)return null;const u=ee(ft(r)),s=t.attributes.source?.trim()||br,i=t.attributes.publication?.trim()||yr,e=t.attributes.output?.trim()||"output",a={manifestPath:ft(r),projectRoot:u,ptxVersion:t.attributes["ptx-version"],sourceDir:s,publicationDir:i,targets:[]},l=ht(t.inner,"targets"),d=l?ie(l.inner,"target"):[];for(const _ of d)a.targets.push({name:_.attributes.name??"",format:_.attributes.format??zt(_,"format")??"",source:Ht(_,"source",s)??bt(s,we),publication:Ht(_,"publication",i),outputDir:Ht(_,"output-dir",e),standalone:_.attributes.standalone!==void 0&&_.attributes.standalone!=="no"});if(a.targets.length===0){const _=zt(t,"source");a.targets.push({name:"default",format:zt(t,"format")??"",source:_?ft(_):bt(s,we),publication:zt(t,"publication"),standalone:!1})}return a}function sn(n){const r=Object.keys(n).filter(t=>yt(t).toLowerCase()==="project.ptx").sort((t,u)=>{const s=t.split("/").length-u.split("/").length;return s!==0?s:t.localeCompare(u)});for(const t of r){const u=rn(n[t],t);if(u)return u}return null}function on(n){return n.targets.find(r=>!r.standalone)??n.targets[0]}const vr=new Set(["md","markdown"]),wr=new Set(["ptx","xml"]),xr=new Set(["readme","changelog","contributing","license"]),xe=["main","book","index","root","master","thesis","dissertation","article","paper"];function ce(n,r){return Object.fromEntries(Object.entries(n).filter(([t])=>r.has(vt(t))))}function an(n){const r=ht(n,"pretext")??ht(n,"book")??ht(n,"article"),t=r?r.inner:n;return ht(t,"title")?.inner.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim()||void 0}function kr(n){const r=/^#\s+(.+)$/m.exec(n);return r?r[1].trim():void 0}function ke(n){return jt(n,"title")||void 0}function Sr(n){return/\\documentclass\b/.test(n)||/\\begin *\{document\}/.test(n)}const Er=/<(pretext|book|article)\b/;function zr(n,r){const t=on(n),u=t?[t,...n.targets.filter(e=>e!==t)]:n.targets,s=new Set,i=[];for(const e of u){const a=bt(n.projectRoot,e.source);s.has(a)||!(a in r)||(s.add(a),i.push({path:a,format:"pretext",reason:"manifest-target",title:an(r[a]),targetName:e.name,targetFormat:e.format}))}return i}function Cr(n){const r=ce(n,new Set(["tex","ltx"])),t=Jn(r),u=Object.keys(r).filter(l=>!t.has(l)&&Sr(r[l])).sort(),s=l=>{let d=0;const _=r[l].match(/\\(input|include) *\{[^{}]+\}/g)??[];for(const m of _){const v=/\{([^{}]+)\}/.exec(m)?.[1];v&&ne(v,l,r)&&(d+=1)}return d},i=l=>{const d=xe.indexOf(Bt(l).toLowerCase());return d>=0?d:xe.length},a=[...u].sort((l,d)=>{const _=+!/\\documentclass\b/.test(r[l])-+!/\\documentclass\b/.test(r[d]);if(_!==0)return _;const m=i(l)-i(d);if(m!==0)return m;const v=s(d)-s(l);return v!==0?v:l.localeCompare(d)}).map(l=>({path:l,format:"latex",reason:"latex-root",title:ke(r[l])}));return a.length>0?a:Object.keys(r).sort().map(l=>({path:l,format:"latex",reason:"fallback",title:ke(r[l])}))}function Ar(n){const r=ce(n,vr),t=Object.keys(r).sort(),u=e=>xr.has(Bt(e).toLowerCase()),s=["main","index","book","article"],i=e=>u(e)?2:s.indexOf(Bt(e).toLowerCase())>=0?0:1;return[...t].sort((e,a)=>i(e)-i(a)||e.localeCompare(a)).map(e=>({path:e,format:"markdown",reason:"markdown-root",title:kr(r[e])}))}function Tr(n){const r=ce(n,wr),t=tr(r);return Object.keys(r).filter(s=>!t.has(s)&&Er.test(r[s])&&yt(s).toLowerCase()!=="project.ptx"&&yt(s).toLowerCase()!=="publication.ptx").sort().map(s=>({path:s,format:"pretext",reason:"pretext-root",title:an(r[s])}))}function cn(n,r={}){const t=sn(n),u=[...t?zr(t,n):[],...Cr(n),...Ar(n),...Tr(n)],s=[],i=new Set;for(const m of u)i.has(m.path)||(i.add(m.path),s.push(m));const e=r.sourceFormat?s.filter(m=>m.format===r.sourceFormat):s,a=[];for(const m of s)a.includes(m.format)||a.push(m.format);let l=e[0]??null;if(r.mainFile){const m=r.mainFile;l=e.find(v=>v.path===m)??s.find(v=>v.path===m)??(m in n?{path:m,format:r.sourceFormat??Dt(n[m]),reason:"fallback"}:l)}if(!l){const m=Object.keys(n).sort()[0];l=m?{path:m,format:r.sourceFormat??Dt(n[m]),reason:"fallback"}:null}const d=l,_=d&&(d.format==="latex"||d.format==="markdown")?e.filter(m=>m.path!==d.path&&m.format===d.format&&m.reason!=="manifest-target"):[];return{manifest:t,candidates:e,formats:a,primary:l,extraRoots:_}}const Se="\\begin{document}",Ir="\\end{document}",Or=/\\documentclass\s*(?:\[[^\]]*\])?\s*\{(book|report|memoir|scrbook|scrreprt|amsbook)\}/;function ln(n){return Bt(n).replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,r=>r.toUpperCase())||"Untitled"}function te(n,r){return{action:"anomaly",severity:"info",kind:"structure",category:"attached_root",macro:n.level,occurrences:1,message:r}}function un(n){const{preamble:r,body:t}=At(n);return Or.test(r)||/\\chapter\b/.test(t)?"chapter":"section"}function Rr(n,r){const t=n.replace(/^\s*(%[^\n]*\n\s*)*/,"");return r==="chapter"?/^\\(chapter|part)\b/.test(t):/^\\(section|chapter|part)\b/.test(t)}function fn(n,r,t){const u=r.filter(g=>g.include!==!1);if(u.length===0)return{source:n,attached:[],warnings:[]};const s=n.includes(Se),{preamble:i,body:e}=At(n),a=un(n),l=[],d=[],_=[],m=[];for(const g of u){const f=t[g.path];if(f===void 0){d.push({action:"anomaly",severity:"warning",kind:"structure",category:"attached_root_missing",macro:g.path,occurrences:1,message:`Cannot attach \`${g.path}\`: it is not among the uploaded files.`});continue}const b=g.level??a,p=g.title||jt(f,"title")||ln(g.path),w={path:g.path,title:p,level:b},S=At(f),E=Te(S.preamble);E&&_.push(E);const z=S.body.trim();if(!z){d.push(te(w,`\`${g.path}\` is empty; skipped.`));continue}m.push(Rr(z,b)?z:`\\${b}{${p}}
|
|
93
|
-
|
|
94
|
-
${z}`),l.push(w),d.push(te(w,`Attached \`${g.path}\` as a ${b}: “${p}”.`))}if(m.length===0)return{source:n,attached:l,warnings:d};const v=[e.trim(),...m].filter(Boolean).join(`
|
|
95
|
-
|
|
96
|
-
`);return s?{source:[[i,..._].filter(Boolean).join(`
|
|
97
|
-
`),Se,v,Ir].join(`
|
|
98
|
-
`),attached:l,warnings:d}:{source:[i,..._,v].filter(Boolean).join(`
|
|
99
|
-
|
|
100
|
-
`),attached:l,warnings:d}}function dn(n,r,t){const u=r.filter(a=>a.include!==!1),s=[],i=[],e=[];for(const a of u){const l=t[a.path];if(l===void 0){i.push({action:"anomaly",severity:"warning",kind:"structure",category:"attached_root_missing",macro:a.path,occurrences:1,message:`Cannot attach \`${a.path}\`: it is not among the uploaded files.`});continue}const d=l.trim();if(!d)continue;const _=/^#\s+(.+)$/m.exec(d),m=a.title||_?.[1]?.trim()||ln(a.path),v={path:a.path,title:m,level:a.level??"chapter"};e.push(d.startsWith("# ")?d:`# ${m}
|
|
101
|
-
|
|
102
|
-
${d}`),s.push(v),i.push(te(v,`Attached \`${a.path}\`: “${m}”.`))}return e.length===0?{source:n,attached:s,warnings:i}:{source:[n.trim(),...e].filter(Boolean).join(`
|
|
103
|
-
|
|
104
|
-
`),attached:s,warnings:i}}const Pr=["output",".git",".github/workflows/.cache","node_modules",".ptx","__pycache__",".venv","__MACOSX"];function Fr(n,r){const t=n.toLowerCase();return[...Pr,...r].some(u=>u.length>0&&t.startsWith(`${u.toLowerCase()}/`))}function hn(n){const{manifest:r,files:t,assets:u}=n,s=r.projectRoot,i=new Set(n.consumedPaths),e=[...new Set(r.targets.map(d=>d.outputDir?.split("/")[0]).filter(d=>!!d))],a={files:{},assets:{},skipped:[]},l=(d,_)=>{if(s&&!d.startsWith(`${s}/`))return;const m=qn(s,d);if(!(i.has(d)||d===r.manifestPath)){if(Fr(m,e)){a.skipped.push(m);return}_(m)}};for(const[d,_]of Object.entries(t))l(d,m=>{a.files[m]=_});for(const[d,_]of Object.entries(u))l(d,m=>{a.assets[m]=_});return a}function pn(n,r,t){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
105
|
-
<project ptx-version="2">
|
|
106
|
-
<targets>
|
|
107
|
-
${n.targets.map(s=>{const i=s.source===r.source,e=i?t.mainSource:s.source,a=i?t.publication??s.publication:s.publication;return[` <target name="${s.name}"${s.standalone?' standalone="yes"':""}>`,s.format?` <format>${s.format}</format>`:"",` <source>${e}</source>`,a?` <publication>${a}</publication>`:"",s.outputDir?` <output-dir>${s.outputDir}</output-dir>`:""," </target>"].filter(Boolean).join(`
|
|
108
|
-
`)}).join(`
|
|
109
|
-
`)}
|
|
110
|
-
</targets>
|
|
111
|
-
</project>
|
|
112
|
-
`}const Dr=/\.(tex|zip|md|markdown|ptx|xml|tar\.gz|tgz)$/i,jr=["tex","md","markdown","ptx","xml","bib","sty","txt","pdf","eps","png","ps","bbl"],Br=new Set(["png","jpg","jpeg","gif","pdf","eps","ps","bmp","tiff","tif","webp","ico"]),$r=new Set(["png","jpg","jpeg","gif","svg","bmp","tiff","tif","webp","ico","pdf","eps","ps"]);function mn(n){return Br.has(n.toLowerCase())}function Lr(n){const r=yt(n),t=vt(r);return $r.has(t)?`source/assets/${r}`:null}function Nr(n){const r=yt(n);return vt(r)==="bib"?`source/${r}`:null}function wt(n){return n.replace(/\r\n?/g,`
|
|
113
|
-
`).replace(/(\n *){3,}/g,`
|
|
114
|
-
|
|
115
|
-
`)}function Ur(n){const r=n.toLowerCase();return r.endsWith(".tar.gz")||r.endsWith(".tgz")?"tar.gz":r.endsWith(".zip")?"zip":r.endsWith(".tex")?"tex":r.endsWith(".md")||r.endsWith(".markdown")?"markdown":r.endsWith(".ptx")||r.endsWith(".xml")?"pretext":null}function Mr(n){const r=(t,u)=>new TextDecoder().decode(n.slice(t,u)).split("\0")[0];return{name:r(0,100),size:parseInt(r(124,136),8)||0,type:r(156,157)}}async function Wr(n){if(typeof DecompressionStream>"u")throw new Error("This runtime does not support gzip decompression.");const u=new ReadableStream({start(l){l.enqueue(new Uint8Array(n)),l.close()}}).pipeThrough(new DecompressionStream("gzip")).getReader(),s=[];for(;;){const{done:l,value:d}=await u.read();if(l)break;s.push(d)}const i=s.reduce((l,d)=>l+d.length,0),e=new Uint8Array(i);let a=0;for(const l of s)e.set(l,a),a+=l.length;return e.buffer}function Zr(n){const r={},t={};let u=0;for(;u<n.length&&!(u+512>n.length);){const s=n.slice(u,u+512),i=Mr(s);if(!i.name)break;u+=512;const e=i.size,a=Math.ceil(e/512)*512;if(i.type==="0"||i.type===""){const l=n.slice(u,u+e),d=ft(i.name);if(mn(vt(d)))t[d]=l;else{const _=new TextDecoder().decode(l);r[d]=wt(_)}}u+=a}return{files:r,assets:t}}async function gn(n){const r=Ur(n.name);if(!r)throw new Error("File format not supported: please upload .tex, .md, .ptx, .xml, .zip, or .tar.gz.");if(r==="tex"||r==="markdown"||r==="pretext"){const s=await n.text();return{files:{[ft(n.name)]:wt(s)},assets:{}}}if(r==="zip"){const i=await new Vn().loadAsync(n),e={},a={};for(const[l,d]of Object.entries(i.files)){if(d.dir)continue;const _=ft(l);if(mn(vt(_)))a[_]=await d.async("uint8array");else{const m=await d.async("string");e[_]=wt(m)}}return{files:e,assets:a}}const t=await n.arrayBuffer(),u=await Wr(t);return Zr(new Uint8Array(u))}function Xr(n){const r={other:0};for(const t of jr)r[t]=0;for(const t of Object.keys(n)){const u=vt(t);u in r?r[u]+=1:r.other+=1}return r}function Gr(n,r){const t=Xr(r);n.push({type:"success",message:"File types:"});for(const u of Object.keys(t).sort())t[u]&&n.push({type:"success",message:`${u}: ${t[u]}`})}function Hr(n){return n==="latex"?"tex":n==="markdown"?"markdown":"pretext"}function Kr(n,r){return n.targets.find(t=>t.source===r)}function Yr(n,r){return n===!1?[]:Array.isArray(n)?n.filter(t=>t.include!==!1):r.extraRoots.map(t=>({path:t.path}))}function Vr(n){if(n.reason==="manifest-target"){const r=n.targetName?` (target \`${n.targetName}\`)`:"";return`Main source file: ${n.path}${r}`}return`Main source file: ${n.path}`}function _n(n,r={}){const t=[];try{const u=Object.fromEntries(Object.entries(n).map(([c,I])=>[ft(c),wt(I)])),s=Object.keys(u).length;t.push({type:"success",message:`Found ${s} file${s===1?"":"s"}.`}),Gr(t,u);const i=cn(u,{sourceFormat:r.sourceFormat,mainFile:r.mainFile?ft(r.mainFile):void 0}),e=i.primary;if(!e)throw new Error("No files were found in the uploaded source.");const a=e.path,l=Hr(e.format);let d=u[a]??"";const _=new Set([a]);if(i.manifest){const c=i.manifest.targets.length;t.push({type:"success",message:`Found ${i.manifest.manifestPath} with ${c} target${c===1?"":"s"}: ${i.manifest.targets.map(I=>I.name).join(", ")}.`})}const m=Yr(r.attachRoots,i);let v=[];const h=[];if(e.format==="latex"){const c=Object.fromEntries(Object.entries(u).filter(([Y])=>vt(Y)==="tex")),I=_e(d,a,c);if(d=wt(I.expandedText),I.consumedPaths.forEach(Y=>_.add(Y)),I.expandedCount>0&&t.push({type:"success",message:`Expanded ${I.expandedCount} input/include reference${I.expandedCount===1?"":"s"}.`}),I.missingInputs.length>0&&t.push({type:"error",message:`Missing input/include files: ${I.missingInputs.join(", ")}.`}),m.length>0){const Y={};for(const tt of m){const M=u[tt.path];if(M===void 0)continue;const Q=_e(M,tt.path,c);Y[tt.path]=Q.expandedText,Q.consumedPaths.forEach(O=>_.add(O)),_.add(tt.path)}const N=fn(d,m,Y);d=wt(N.source),v=N.attached,h.push(...N.warnings)}}else if(e.format==="markdown"){if(m.length>0){const c=dn(d,m,u);d=wt(c.source),v=c.attached,h.push(...c.warnings),v.forEach(I=>_.add(I.path))}}else{const c=Object.fromEntries(Object.entries(u).filter(([Y])=>{const N=vt(Y);return N==="ptx"||N==="xml"})),I=Be(d,a,c);d=I.expandedText,I.consumedPaths.forEach(Y=>_.add(Y)),I.expandedCount>0&&t.push({type:"success",message:`Expanded ${I.expandedCount} xi:include reference${I.expandedCount===1?"":"s"}.`}),I.missingIncludes.length>0&&t.push({type:"error",message:`Missing xi:include targets: ${I.missingIncludes.join(", ")}.`})}t.push({type:"success",message:Vr(e)});for(const c of v)t.push({type:"success",message:`Attached ${c.path} as a ${c.level}: ${c.title}`});const g=De(d,e.format);if("pretextError"in g)return{pretextError:g.pretextError,statusMessages:t,warnings:[...g.warnings,...h]};const{buildLayout:f=!0,assets:b={},...p}=r,w=i.manifest,S=w&&e.reason==="manifest-target"?Kr(w,e.path.slice(w.projectRoot?w.projectRoot.length+1:0)):void 0,E=f&&w!==null&&S!==void 0&&(r.preserveProjectLayout??!0),z={mainSourcePath:p.mainSourcePath??(E&&S?S.source:"source/main.ptx"),publicationPath:p.publicationPath??(E&&S?.publication?S.publication:"publication/publication.ptx"),projectFilePath:p.projectFilePath??"project.ptx",preserved:E},F={},D={},$={};if(E&&w&&S){const c=hn({manifest:w,target:S,files:u,assets:b,consumedPaths:_});Object.assign($,c.files),Object.assign(F,c.assets);for(const[I,Y]of Object.entries(b))D[I]=Y;t.push({type:"success",message:`Carried over ${Object.keys(c.files).length} project file${Object.keys(c.files).length===1?"":"s"} and ${Object.keys(c.assets).length} asset${Object.keys(c.assets).length===1?"":"s"} unchanged.`}),c.skipped.length>0&&t.push({type:"success",message:`Skipped build output: ${c.skipped.length} file${c.skipped.length===1?"":"s"}.`})}else for(const[c,I]of Object.entries(b)){const Y=Lr(c);Y&&(F[Y]=I,D[c]=I)}const P=qe(g.pretextSource,{documentKind:p.documentKind,splitLevel:f?p.splitLevel:0,splitChapters:f?p.splitChapters:!1,splitSections:f?p.splitSections:!1,assets:D});f?(Object.assign($,nn(P.project,{mainSourcePath:z.mainSourcePath,publicationPath:z.publicationPath,projectFilePath:z.projectFilePath,includeScaffold:!E}).files),E&&w&&S&&($[z.projectFilePath]=pn(w,S,{mainSource:z.mainSourcePath,publication:z.publicationPath}),z.publicationPath in $||($[z.publicationPath]=re()))):$["source/main.ptx"]=g.pretextSource;for(const[c,I]of Object.entries(u)){const Y=Nr(c);Y&&!(Y in $)&&($[Y]=I)}const W=P.project.documentKind,q=[...g.warnings,...h,...P.warnings];let k,j;return g.cleanedNativeSource!==void 0&&g.cleanedNativeSource.length>0&&(g.sourceFormat==="latex"||g.sourceFormat==="markdown")&&(k={[g.sourceFormat==="latex"?"source/main.tex":"source/main.md"]:g.cleanedNativeSource},j=Je(g.cleanedNativeSource,g.sourceFormat,{documentKind:W,splitChapters:f?p.splitChapters:!1,splitSections:f?p.splitSections:!1,title:P.project.title,docinfo:P.project.docinfo,assets:D}).project),Object.keys(b).length>0&&t.push({type:"success",message:`Routed ${Object.keys(F).length} binary asset${Object.keys(F).length===1?"":"s"}.`}),{...g,warnings:q,sourcePath:a,sourceName:yt(a),sourceType:l,analysis:i,attachedRoots:v,projectLayout:z,project:P.project,nativeProject:j,files:u,assets:b,outputFiles:$,outputAssets:F,nativeOutputFiles:k,documentKind:W,statusMessages:t}}catch(u){const s=u instanceof Error?u.message:String(u);return t.push({type:"error",message:s}),{pretextError:s,statusMessages:t,warnings:[]}}}async function qr(n,r={}){const t=[],u=ft(n.name);if(!Dr.test(u.toLowerCase()))return{pretextError:"File format not supported: please upload .tex, .md, .ptx, .xml, .zip, or .tar.gz.",statusMessages:[{type:"error",message:"File format not supported: please upload .tex, .md, .ptx, .xml, .zip, or .tar.gz."}],warnings:[]};t.push({type:"loading",message:`Processing ${u}...`});try{const{files:s,assets:i}=await gn(n),e=_n(s,{...r,assets:i});return{...e,statusMessages:[...t,...e.statusMessages]}}catch(s){const i=s instanceof Error?s.message:String(s);return{pretextError:i,statusMessages:[...t,{type:"error",message:i}],warnings:[]}}}function Jr(n,r){return r==="native"?n.nativeProject??n.project:n.project}function Qr(n,r){return r==="converted"?n.outputFiles:n.nativeOutputFiles??n.files}function ti(n,r){return r==="converted"?n.outputAssets:n.assets}function ei(n){const r=n.action==="replace"||n.action==="rewrite"?`replaced with \`${n.replacement}\``:n.message??n.action,t=n.occurrences>1?` (x${n.occurrences})`:"";return`[${n.severity}] ${n.macro}: ${r}${t}`}exports.LATEX_FORMAT_MARKERS=Ee;exports.MARKDOWN_FORMAT_MARKERS=ze;exports.PRETEXT_DIVISION_TAGS=We;exports.PRETEXT_ROOT_TAGS=rr;exports.analyzeImportSources=cn;exports.assetsForImportMode=ti;exports.attachLatexRoots=fn;exports.attachMarkdownRoots=dn;exports.buildDivisionPool=qe;exports.buildNativeDivisionPool=Je;exports.carryOverProjectFiles=hn;exports.cleanLatex=Ae;exports.convertLatexToPretext=Re;exports.convertMarkdownToPretext=Pe;exports.convertSourceToPretext=De;exports.defaultAttachLevel=un;exports.defaultManifestTarget=on;exports.detectDocumentKind=Ue;exports.detectSourceFormat=Dt;exports.divisionChildRefs=Ft;exports.ensureXIncludeNamespace=Vt;exports.expandPretextIncludes=Be;exports.extractUpload=gn;exports.filePrefixForDivision=oe;exports.filesForImportMode=Qr;exports.findAnyElement=Ct;exports.findProjectManifest=sn;exports.findTopLevelElements=ie;exports.formatWarningLine=ei;exports.getConversionErrorMessage=Fe;exports.handleImportUploadFile=qr;exports.importProjectFromFiles=_n;exports.isDivisionTag=Ze;exports.normalizePretextSource=Ut;exports.padIndex=xt;exports.parseProjectManifest=rn;exports.projectForImportMode=Jr;exports.renderProjectPtx=$e;exports.renderProjectPtxFromManifest=pn;exports.renderPublicationPtx=re;exports.resolveSplitLevel=Xe;exports.sanitizeRef=Mt;exports.serializeProjectToFiles=nn;exports.slugify=se;exports.spliceReplacements=Me;exports.withProlog=qt;
|