@silurus/ooxml 0.85.3 → 0.86.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/README.md +39 -7
- package/dist/assets/render-worker-BCGnuBLj.js +10 -0
- package/dist/assets/render-worker-CB4DxjXg.js +31 -0
- package/dist/assets/render-worker-CHW0F0n6.js +11 -0
- package/dist/{bounded-raw-part-cache-C6ro6Ezf.js → bounded-raw-part-cache-DVx3Camo.js} +12 -10
- package/dist/{canvas-viewer-mechanics-CDNMJ-Yz.js → canvas-viewer-mechanics-B3A7KLLi.js} +1 -1
- package/dist/{comment-ui-runtime-DAKBCpsM.js → comment-ui-runtime-DEtgcmj7.js} +5 -5
- package/dist/comment-ui-runtime-TLHustXJ.js +2 -0
- package/dist/{comment-ui-runtime-CAbpuWi_.js → comment-ui-runtime-ssI6IE39.js} +4 -4
- package/dist/{comments-Brfxa3hQ.js → comments-CAn2A_Xh.js} +1 -1
- package/dist/delimited-text-worker-host-DcHj_JZt.js +27 -0
- package/dist/{document-pull-client-F3ox_VXK.js → document-pull-client-xZrA2IjM.js} +577 -576
- package/dist/{docx-BYvm3TWw.js → docx-DzDiGvqe.js} +63 -63
- package/dist/docx.mjs +5 -5
- package/dist/docx_parser_bg.wasm +0 -0
- package/dist/{dom-interaction-boundary-CDGegIB5.js → dom-interaction-boundary-DK1JLkrz.js} +2 -2
- package/dist/{line-metrics-BGtFM-ec.js → hyperlink-enyPbflR.js} +847 -877
- package/dist/index.mjs +3 -3
- package/dist/line-distribute-BFB575d6.js +1023 -0
- package/dist/line-metrics-CBbw80Ko.js +60 -0
- package/dist/node.mjs +91 -91
- package/dist/{pptx-BqpVTP8p.js → pptx-D_U62nl-.js} +71 -71
- package/dist/pptx.mjs +5 -5
- package/dist/pptx_parser_bg.wasm +0 -0
- package/dist/{render-DeZpRCfx.js → render-DSn0d35X.js} +1 -1
- package/dist/{render-worker-host-CBcQXsR5.js → render-worker-host-BHz9vjxB.js} +1 -1
- package/dist/{render-worker-host-BKtXmlEF.js → render-worker-host-CO0UYoQh.js} +1 -1
- package/dist/{render-worker-host-CNKQ76tu.js → render-worker-host-CbYDBg7U.js} +1 -1
- package/dist/{resource-measurement-D41R-0Bl.js → resource-measurement-Do07ZRcR.js} +7 -7
- package/dist/{session-n2p5_jxV.js → session-C1GYhr6n.js} +77 -77
- package/dist/{slide-pull-client-Dwek7xW8.js → slide-pull-client-DuEaUxPw.js} +732 -732
- package/dist/types/chart-ex.d.ts +2 -2
- package/dist/types/docx.d.ts +10 -10
- package/dist/types/index.d.ts +38 -18
- package/dist/types/math.d.ts +1 -1
- package/dist/types/node.d.ts +6 -5
- package/dist/types/pptx.d.ts +10 -10
- package/dist/types/region-map.d.ts +2 -2
- package/dist/types/three-d.d.ts +2 -2
- package/dist/types/tiff.d.ts +1 -1
- package/dist/types/xlsx.d.ts +34 -14
- package/dist/{worksheet-pull-client-C9sC36Vu.js → worksheet-pull-client-eDiHHEG2.js} +99 -96
- package/dist/{xlsx-DSU6pV1O.js → xlsx-CMHmYTHP.js} +1629 -1469
- package/dist/xlsx.mjs +5 -5
- package/dist/xlsx_parser_bg.wasm +0 -0
- package/package.json +1 -1
- package/dist/assets/render-worker-D1O73gYW.js +0 -10
- package/dist/assets/render-worker-DHP0rgcW.js +0 -24
- package/dist/assets/render-worker-V2wWYA4O.js +0 -11
- package/dist/comment-ui-runtime-DTaaZdXC.js +0 -2
- package/dist/line-distribute-BsV4MVZ2.js +0 -1023
- /package/dist/{comment-occurrence-tj54AXXB.js → comment-occurrence-Dhdplprg.js} +0 -0
- /package/dist/{highlight-rect-DBcYVJDv.js → highlight-rect-FuUSmL3a.js} +0 -0
- /package/dist/{read-only-comment-decoration-Mv_SAiHy.js → read-only-comment-decoration-BTnWEeo5.js} +0 -0
- /package/dist/{read-only-comment-margin-Cqu-Ir0C.js → read-only-comment-margin-plStyGfE.js} +0 -0
- /package/dist/{source-key-BkBB3X82.js → source-key-Ktb1GRE5.js} +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { t as e } from "./chunk-DmhlhrBa.js";
|
|
2
|
-
import { a as t, c as n, d as r, f as i, i as a, l as o, n as s, o as c, r as l, s as u, t as d, u as f } from "./slide-pull-client-
|
|
3
|
-
import {
|
|
4
|
-
import { C as
|
|
5
|
-
import { a as
|
|
6
|
-
import { a as
|
|
2
|
+
import { a as t, c as n, d as r, f as i, i as a, l as o, n as s, o as c, r as l, s as u, t as d, u as f } from "./slide-pull-client-DuEaUxPw.js";
|
|
3
|
+
import { $ as p, H as m, I as h, L as g, Q as _, R as v, U as y, Xt as b, ct as x, dt as S, gt as C, on as w, qt as ee, r as T, sn as E } from "./hyperlink-enyPbflR.js";
|
|
4
|
+
import { C as te, D as ne, E as re, S as ie, T as ae, _ as oe, a as D, b as se, c as O, d as ce, f as le, g as ue, h as de, i as k, l as A, m as fe, n as pe, o as me, p as he, r as ge, s as _e, t as ve, v as ye, w as be, x as xe, y as Se } from "./canvas-viewer-mechanics-B3A7KLLi.js";
|
|
5
|
+
import { a as Ce, i as we, n as Te, t as Ee } from "./bounded-raw-part-cache-DVx3Camo.js";
|
|
6
|
+
import { a as De, c as Oe, i as ke, l as j, n as Ae, r as je, t as Me } from "./dom-interaction-boundary-DK1JLkrz.js";
|
|
7
7
|
import { l as Ne, s as Pe } from "./pixel-budget-Dgjw269h.js";
|
|
8
8
|
import { i as M } from "./units-EJdC96r6.js";
|
|
9
9
|
import { i as Fe, s as Ie } from "./raster-target-ojDdQizC.js";
|
|
10
|
-
import { n as Le } from "./resource-measurement-
|
|
10
|
+
import { n as Le } from "./resource-measurement-Do07ZRcR.js";
|
|
11
11
|
import { n as Re } from "./renderer-module-contract-Cu-GKuPd.js";
|
|
12
12
|
import { t as ze } from "./visible-index-DPoQYSDt.js";
|
|
13
|
-
import { n as Be, t as N } from "./highlight-rect-
|
|
14
|
-
import { t as P } from "./comment-occurrence-
|
|
13
|
+
import { n as Be, t as N } from "./highlight-rect-FuUSmL3a.js";
|
|
14
|
+
import { t as P } from "./comment-occurrence-Dhdplprg.js";
|
|
15
15
|
//#region packages/core/src/nav/internal-target.ts
|
|
16
16
|
function Ve(e, t) {
|
|
17
17
|
let n = t.startsWith("/") ? [] : e.split("/").filter((e) => e !== "");
|
|
@@ -170,8 +170,8 @@ var Je = class {
|
|
|
170
170
|
if (n !== this._generation) return [];
|
|
171
171
|
let o = r === this._runsRevision ? i : new Map([...i, ...this._slideRuns]), s = [];
|
|
172
172
|
for (let n = 0; n < a; n++) {
|
|
173
|
-
let r = o.get(n) ?? [], i =
|
|
174
|
-
for (let a of
|
|
173
|
+
let r = o.get(n) ?? [], i = fe(r);
|
|
174
|
+
for (let a of de(i, e, t)) {
|
|
175
175
|
if (!qe(r, a.slices)) continue;
|
|
176
176
|
let e = a.slices.map((e) => r[e.runIndex].text.slice(e.start, e.end)).join("");
|
|
177
177
|
s.push({
|
|
@@ -184,10 +184,10 @@ var Je = class {
|
|
|
184
184
|
return this._runsRevision++, this._slideRuns = o, this._matches = s, this._active = -1, this.matches();
|
|
185
185
|
}
|
|
186
186
|
next() {
|
|
187
|
-
return this._active =
|
|
187
|
+
return this._active = le(this._active, this._matches.length), this._activePublic();
|
|
188
188
|
}
|
|
189
189
|
prev() {
|
|
190
|
-
return this._active =
|
|
190
|
+
return this._active = he(this._active, this._matches.length), this._activePublic();
|
|
191
191
|
}
|
|
192
192
|
_activePublic() {
|
|
193
193
|
let e = this._matches[this._active];
|
|
@@ -508,7 +508,7 @@ var _t = class {
|
|
|
508
508
|
#o;
|
|
509
509
|
constructor(e) {
|
|
510
510
|
if (!Number.isSafeInteger(e.slideCount) || e.slideCount < 0) throw TypeError("slideCount must be a non-negative safe integer");
|
|
511
|
-
this.#e = e.slideCount, this.#t = e.loadSlide, this.#n = new
|
|
511
|
+
this.#e = e.slideCount, this.#t = e.loadSlide, this.#n = new Te({
|
|
512
512
|
maxEntries: e.maxCachedSlides,
|
|
513
513
|
maxWeight: e.maxCachedStructuralBytes,
|
|
514
514
|
measure: (e) => Le(e).jsonBytes
|
|
@@ -559,7 +559,7 @@ var _t = class {
|
|
|
559
559
|
}
|
|
560
560
|
};
|
|
561
561
|
function vt(e) {
|
|
562
|
-
return e instanceof
|
|
562
|
+
return e instanceof E ? e : y(e);
|
|
563
563
|
}
|
|
564
564
|
//#endregion
|
|
565
565
|
//#region packages/pptx/src/embedded-fonts.ts
|
|
@@ -607,7 +607,7 @@ function xt(e, t) {
|
|
|
607
607
|
}
|
|
608
608
|
//#endregion
|
|
609
609
|
//#region packages/pptx/src/worker.ts?worker&inline
|
|
610
|
-
var St = "var e=(e,t)=>()=>(e&&(t=e(e=0)),t),t=class e extends Error{code;constructor(t,n){super(n),this.name=`OoxmlError`,this.code=t,Object.setPrototypeOf(this,e.prototype)}},n=class e extends Error{code=`ooxml-resource-limit`;details;constructor(t,n){super(t),this.name=`OoxmlResourceLimitError`;let r=n.violation,i=Object.freeze({format:r.format,operation:r.operation,resource:r.resource,metric:r.metric,...r.part===void 0?{}:{part:r.part},limit:r.limit,observed:r.observed,configurable:r.configurable,usage:Object.freeze({archiveEntryCount:r.usage.archiveEntryCount,declaredInflatedBytes:r.usage.declaredInflatedBytes,...r.usage.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:r.usage.largestInflatedEntryBytes},distinctInflatedBytes:r.usage.distinctInflatedBytes,operationInflatedBytes:r.usage.operationInflatedBytes})});this.details=Object.freeze({stage:n.stage,violation:i}),Object.setPrototypeOf(this,e.prototype)}};const r=67108864,i=`https://fonts.googleapis.com/css2?family=Noto+Naskh+Arabic:wght@400;700&display=swap`,a=`https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@400;700&display=swap`,o=`https://fonts.googleapis.com/css2?family=Libre+Franklin:ital,wght@0,400;0,600;0,700;1,400;1,600;1,700&display=swap`,s={calibri:{url:`https://fonts.googleapis.com/css2?family=Carlito:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Carlito`},\"calibri light\":{url:`https://fonts.googleapis.com/css2?family=Carlito:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Carlito`},cambria:{url:`https://fonts.googleapis.com/css2?family=Caladea:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Caladea`},\"cambria math\":{url:`https://fonts.googleapis.com/css2?family=Caladea:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Caladea`},\"franklin gothic book\":{url:o,loadFamily:`Libre Franklin`},\"franklin gothic medium\":{url:o,loadFamily:`Libre Franklin`},\"nunito sans\":{url:`https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap`},nunito:{url:`https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,400;0,700;1,400;1,700&display=swap`},\"open sans\":{url:`https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap`},roboto:{url:`https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,700;1,400;1,700&display=swap`},lato:{url:`https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;1,400;1,700&display=swap`},montserrat:{url:`https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,400;0,700;1,400;1,700&display=swap`},poppins:{url:`https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,700;1,400;1,700&display=swap`},raleway:{url:`https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,400;0,700;1,400;1,700&display=swap`},\"playfair display\":{url:`https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400;1,700&display=swap`},ubuntu:{url:`https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,400;0,700;1,400;1,700&display=swap`},\"sakkal majalla\":{url:i,loadFamily:`Noto Naskh Arabic`},\"traditional arabic\":{url:i,loadFamily:`Noto Naskh Arabic`},\"simplified arabic\":{url:i,loadFamily:`Noto Naskh Arabic`},\"arabic typesetting\":{url:i,loadFamily:`Noto Naskh Arabic`},\"univers next arabic\":{url:a,loadFamily:`Noto Sans Arabic`},\"noto naskh arabic\":{url:i,loadFamily:`Noto Naskh Arabic`},\"noto sans arabic\":{url:a,loadFamily:`Noto Sans Arabic`}};function c(e){if(!e)return null;let t=e.toLowerCase();return/[ᄀ-ᇿ-가-]/.test(e)?`kr`:/[-ヿ]/.test(e)?`jp`:/jhenghei|微軟正黑|新細明|細明|pmingliu|mingliu|dfkai|標楷|華康|cns11643|kaiti tc|ming\\s*liu/.test(t)||/新細明體|細明體|標楷體|微軟正黑體|華康/.test(e)?`tc`:/simsun|nsimsun|simhei|simkai|simfang|yahei|dengxian|fangsong|kaiti|youyuan|lisu|stsong|stkaiti|stfangsong|stheiti|stxihei|stzhongsong|songti sc|heiti sc|微软雅黑/.test(t)||/宋体|黑体|楷体|仿宋|等线|微软雅黑|隶书|幼圆/.test(e)?`sc`:/malgun|batang|gulim|dotum|gungsuh|nanum|new gulim|hancom|hy(gothic|graphic|namu)?/.test(t)?`kr`:/\\bmeiryo\\b|\\byu\\s*(gothic|mincho)\\b|yugothic|yumincho|hiragino|\\bms\\s*(gothic|mincho|pgothic|pmincho|ui\\s*gothic)\\b|\\bms[pg]?(gothic|mincho)\\b|ipa(ex)?(gothic|mincho)|noto\\s+(sans|serif)\\s+jp|游ゴシック|游明朝|MS|メイリオ|ヒラギノ/.test(t)||/游ゴシック|游明朝|MS ゴシック|MS 明朝|MS Pゴシック|メイリオ|ヒラギノ/.test(e)?`jp`:null}const l=e=>`https://fonts.googleapis.com/css2?family=${e}:wght@400;700&display=swap`,u={\"noto sans kr\":{url:l(`Noto+Sans+KR`)},\"noto sans sc\":{url:l(`Noto+Sans+SC`)},\"noto sans tc\":{url:l(`Noto+Sans+TC`)},\"noto sans jp\":{url:l(`Noto+Sans+JP`)},\"noto serif kr\":{url:l(`Noto+Serif+KR`)},\"noto serif sc\":{url:l(`Noto+Serif+SC`)},\"noto serif tc\":{url:l(`Noto+Serif+TC`)},\"noto serif jp\":{url:l(`Noto+Serif+JP`)},\"noto sans\":{url:l(`Noto+Sans`)},\"noto serif\":{url:l(`Noto+Serif`)},\"noto sans devanagari\":{url:l(`Noto+Sans+Devanagari`)},\"noto sans thai\":{url:l(`Noto+Sans+Thai`)},\"noto sans hebrew\":{url:l(`Noto+Sans+Hebrew`)},\"noto serif hebrew\":{url:l(`Noto+Serif+Hebrew`)}};var d=class e{hasHan=!1;hasHangul=!1;hasKana=!1;hasArabic=!1;hasThai=!1;hasHebrew=!1;hasDevanagari=!1;hasCyrGreek=!1;constructor(e){this.cjkLang=e}clone(){let t=new e(this.cjkLang);return t.hasHan=this.hasHan,t.hasHangul=this.hasHangul,t.hasKana=this.hasKana,t.hasArabic=this.hasArabic,t.hasThai=this.hasThai,t.hasHebrew=this.hasHebrew,t.hasDevanagari=this.hasDevanagari,t.hasCyrGreek=this.hasCyrGreek,t}addText(e){let t=()=>this.hasHan&&this.hasHangul&&this.hasKana&&this.hasArabic&&this.hasThai&&this.hasHebrew&&this.hasDevanagari&&this.hasCyrGreek;outer:for(let n of e)if(n)for(let e of n){let n=e.codePointAt(0);if(n!==void 0&&!(n<=591)&&(n>=4352&&n<=4607||n>=12592&&n<=12687||n>=44032&&n<=55215?this.hasHangul=!0:n>=12352&&n<=12543?this.hasKana=!0:n>=13312&&n<=19903||n>=19968&&n<=40959||n>=63744&&n<=64255||n>=131072&&n<=195103?this.hasHan=!0:n>=1536&&n<=1791||n>=1872&&n<=1919||n>=2208&&n<=2303||n>=64336&&n<=65023||n>=65136&&n<=65279?this.hasArabic=!0:n>=3584&&n<=3711?this.hasThai=!0:n>=1424&&n<=1535||n>=64285&&n<=64335?this.hasHebrew=!0:n>=2304&&n<=2431?this.hasDevanagari=!0:(n>=1024&&n<=1279||n>=880&&n<=1023)&&(this.hasCyrGreek=!0),t()))break outer}}names(){let e=[],t=new Set;this.hasHangul&&t.add(`kr`),this.hasKana&&t.add(`jp`),this.hasHan&&t.size===0&&t.add(this.cjkLang??`jp`);for(let n of[`kr`,`sc`,`tc`,`jp`])if(t.has(n)){let t={kr:`KR`,sc:`SC`,tc:`TC`,jp:`JP`}[n];e.push(`Noto Sans ${t}`,`Noto Serif ${t}`)}return this.hasCyrGreek&&e.push(`Noto Sans`,`Noto Serif`),this.hasArabic&&e.push(`Noto Naskh Arabic`,`Noto Sans Arabic`),this.hasThai&&e.push(`Noto Sans Thai`),this.hasHebrew&&e.push(`Noto Sans Hebrew`,`Noto Serif Hebrew`),this.hasDevanagari&&e.push(`Noto Sans Devanagari`),e}};function f(e){return e===`image-dimension`||e===`image-pixels`||e===`active-decoded-bytes`}function p(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ee(e){if(!(!e||typeof e!=`object`))try{let t=e,n=t.code,r=t.metric,i=t.limit,a=t.observed;return n!==`ooxml-decoded-image-limit`||!f(r)||!p(i)||!p(a)||a<=i?void 0:{metric:r,limit:i,observed:a}}catch{return}}var te,ne,m,re=e((()=>{te=1<<25,ne=1<<27,te*4,ne*4,m=class e extends RangeError{code=`ooxml-decoded-image-limit`;constructor(t,n,r){super(`OOXML decoded image limit exceeded: ${t} ${r} > ${n}`),this.metric=t,this.limit=n,this.observed=r,this.name=`OoxmlDecodedImageLimitError`,Object.setPrototypeOf(this,e.prototype)}}}));function ie(e){if(!(typeof e!=`object`||!e))try{let t=e,n=t.code,r=t.message;return n===`ooxml-tiff-decode`&&typeof r==`string`?{message:r}:void 0}catch{return}}var ae,oe=e((()=>{ae=class e extends Error{code=`ooxml-tiff-decode`;constructor(t,n){super(t,n),this.name=`TiffDecodeError`,Object.setPrototypeOf(this,e.prototype)}}}));function se(e){if(!e.startsWith(`data:`))return null;let t=e.indexOf(`,`);if(t===-1)return null;let n=atob(e.slice(t+1)),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}var ce=class{state=`uninitialized`;generationValue=0;readiness;poisonListeners=new Set;constructor(e,t,n){this.initialize=e,this.reinitialize=t,this.normalizeFailure=n}get generation(){return this.generationValue}get poisoned(){return this.state===`poisoned`}onPoison(e){return this.poisonListeners.add(e),()=>this.poisonListeners.delete(e)}async ensureReady(){if(this.state!==`ready`){if(!this.readiness){let e=this.state===`uninitialized`?this.initialize:this.reinitialize;this.readiness=Promise.resolve().then(e).then(()=>{this.generationValue+=1,this.state=`ready`,this.readiness=void 0},e=>{throw this.readiness=void 0,e})}await this.readiness}}run(e){try{return e()}catch(e){let t=this.normalizeFailure(e);throw t?(this.poison(t),t):e}}tryRunReady(e){if(this.state!==`ready`)return{current:!1};let t=this.generationValue,n=this.run(e);return this.state!==`ready`||t!==this.generationValue?{current:!1}:{current:!0,generation:t,value:n}}poison(e){this.state=`poisoned`,this.readiness=void 0;for(let t of this.poisonListeners)t(e)}assertCurrent(e){if(this.state!==`ready`||e!==this.generationValue)throw Error(`WASM archive session belongs to a discarded runtime generation`)}},le=class e extends Error{code=`parser-crashed`;constructor(t){super(t),this.name=`WasmTrapError`,Object.setPrototypeOf(this,e.prototype)}};function ue(e){let t=globalThis.WebAssembly?.RuntimeError;return t&&e instanceof t||e instanceof RangeError?!0:e instanceof Error?e.name===`RuntimeError`||e.name===`CompileError`||e.name===`LinkError`||e.name===`InternalError`||e.name===`OOMError`:!1}function de(e){try{if((typeof e!=`object`||!e)&&typeof e!=`function`)return;let t=Reflect.get(e,`__destroy_into_raw`);typeof t==`function`&&Reflect.apply(t,e,[])}catch{}}function fe(e,t){return e({module_or_path:t})}var pe=class{runtime;wasmInput=null;currentArchive=null;constructor(e,t={}){this.init=e,this.options=t,this.runtime=new ce(()=>this.invokeConfigured(this.init),()=>this.invokeConfigured(this.options.reinit??this.init),me),this.runtime.onPoison(()=>this.dropPoisonedArchive())}setWasmInput(e){this.wasmInput=e,this.runtime.ensureReady().catch(()=>void 0)}setWasmUrl(e){this.setWasmInput(e)}get archive(){return this.currentArchive}setArchive(e){this.freeArchive(),this.currentArchive=e}disposeArchive(){this.freeArchive()}get poisoned(){return this.runtime.poisoned}async ensureReady(){await this.runtime.ensureReady()}run(e){return this.runtime.run(e)}poison(){this.runtime.poison(new le(`WASM parser was recycled`))}invokeConfigured(e){return this.wasmInput===null?Promise.reject(Error(`WasmParserHost: setWasmInput was never called`)):fe(e,this.wasmInput)}freeArchive(){this.currentArchive!==null&&this.options.freeArchive&&this.options.freeArchive(this.currentArchive),this.currentArchive=null}dropPoisonedArchive(){let e=this.currentArchive;this.currentArchive=null,de(e)}};function me(e){return ue(e)?new le(`WASM parser trapped and was recycled: ${e instanceof Error?e.message:String(e)}`):null}function h(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function he(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return h(t.requiredBytes)&&h(t.offeredBytes)&&t.requiredBytes>t.offeredBytes}var g=class e extends RangeError{code=`ooxml-insufficient-credit`;requiredBytes;offeredBytes;constructor(t){super(`Pull unit requires ${t.requiredBytes} bytes but credit is ${t.offeredBytes}`),this.name=`PullSessionInsufficientCreditError`,this.requiredBytes=t.requiredBytes,this.offeredBytes=t.offeredBytes,Object.setPrototypeOf(this,e.prototype)}};function ge(e){if(e instanceof g)return e;let t=e instanceof Error?e.message:String(e);if(!t.startsWith(`OOXML_INSUFFICIENT_CREDIT:`))return;let n;try{n=JSON.parse(t.slice(26))}catch{return}if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n;if(!(r.code!==`ooxml-insufficient-credit`||!he(r)))return new g(r)}function _e(e,t,n){let r=ge(e);if(!(!r||r.offeredBytes!==t||r.requiredBytes>n))return r}re(),oe();const _=`OOXML_RESOURCE_LIMIT:`;function v(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ve(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return v(t.archiveEntryCount)&&v(t.declaredInflatedBytes)&&(t.largestInflatedEntryBytes===void 0||v(t.largestInflatedEntryBytes))&&v(t.distinctInflatedBytes)&&v(t.operationInflatedBytes)}function ye(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch{throw TypeError(`OOXML resource usage checkpoint is not valid JSON`)}if(!ve(t))throw TypeError(`OOXML resource usage checkpoint is invalid`);return t}function be(e){return e===`docx`||e===`xlsx`||e===`pptx`}function xe(e){return e===`container`||e===`decompression`||e===`parsing`||e===`serialization`||e===`layout`||e===`rendering`||e===`worker`}function y(e,t){return typeof e==`string`&&e.length>0&&e.length<=t&&!/[\\u0000-\\u001f\\u007f]/u.test(e)}function b(e){return y(e,128)&&/^[a-z0-9][a-z0-9-]*$/u.test(e)}function Se(e){return!y(e,4096)||e.startsWith(`/`)||e.startsWith(`\\\\`)||e.includes(`\\\\`)||e.includes(`?`)||e.includes(`#`)||e.includes(`://`)||/^[a-z]:/iu.test(e)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`)}const x=new Map([[`archive-entry:declared-inflated-bytes`,{stage:`container`,part:`required`}],[`archive-entry:actual-inflated-bytes`,{stage:`decompression`,part:`required`}],[`archive:entry-count`,{stage:`container`,part:`forbidden`}],[`archive:central-directory-bytes`,{stage:`container`,part:`forbidden`,configurable:!1}],[`archive:distinct-inflated-bytes`,{stage:`decompression`,part:`required`}],[`xml-event:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-context:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-tree:depth`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-row:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-shell:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}]]),Ce=new Set([...x.keys()].map(e=>e.slice(0,e.indexOf(`:`)))),we=new Set([...x.keys()].map(e=>e.slice(e.indexOf(`:`)+1)));function Te(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return!be(t.format)||!y(t.operation,256)||!b(t.resource)||!b(t.metric)||!v(t.limit)||!v(t.observed)||typeof t.configurable!=`boolean`||!ve(t.usage)?!1:!(`part`in t)||Se(t.part)}function S(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(!xe(t.stage)||!Te(t.violation))return!1;let n=t.violation,r=x.get(`${n.resource}:${n.metric}`);return r?t.stage!==r.stage||r.configurable===!1&&n.configurable!==!1?!1:r.part===`required`?n.part!==void 0:r.part===`forbidden`?n.part===void 0:!0:!(Ce.has(n.resource)&&we.has(n.metric))}function Ee(e){return{archiveEntryCount:e.archiveEntryCount,declaredInflatedBytes:e.declaredInflatedBytes,...e.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:e.largestInflatedEntryBytes},distinctInflatedBytes:e.distinctInflatedBytes,operationInflatedBytes:e.operationInflatedBytes}}function De(e){if(!S(e))return;let t=e.violation,n={stage:e.stage,violation:{format:t.format,operation:t.operation,resource:t.resource,metric:t.metric,...t.part===void 0?{}:{part:t.part},limit:t.limit,observed:t.observed,configurable:t.configurable,usage:Ee(t.usage)}};return S(n)?n:void 0}function Oe(e){let t=e.violation;return`OOXML resource limit exceeded${t.part?` for ${t.part}`:``}: ${t.metric} ${t.observed} > ${t.limit}`}function C(e){let t=e instanceof Error?e.message:String(e);if(!t.startsWith(_))return;let r;try{r=JSON.parse(t.slice(21))}catch{return}if(!r||typeof r!=`object`)return;let i=r;if(!(i.code!==`ooxml-resource-limit`||!S(i.details)))return new n(Oe(i.details),i.details)}function ke(e){let r=ee(e);if(r){let e=new m(r.metric,r.limit,r.observed);return{message:e.message,errorName:e.name,code:e.code,decodedImage:r}}let i=ie(e);if(i)return{message:i.message,errorName:`TiffDecodeError`,code:`ooxml-tiff-decode`};let a=ge(e);if(a)return{message:a.message,errorName:a.name,code:a.code,insufficientCredit:{requiredBytes:a.requiredBytes,offeredBytes:a.offeredBytes}};let o=e instanceof t||e instanceof n?e:C(e);if(o instanceof n){let e=De(o.details);return e?{message:typeof o.message==`string`?o.message:Oe(e),errorName:`OoxmlResourceLimitError`,code:`ooxml-resource-limit`,resourceLimit:e}:{message:`Invalid OOXML resource-limit error payload`,errorName:`Error`}}if(o instanceof t)return{message:typeof o.message==`string`?o.message:String(o.message),errorName:y(o.name,128)?o.name:`OoxmlError`,...b(o.code)?{code:o.code}:{}};let s=e instanceof Error?e.message:String(e);if(typeof s==`string`&&s.startsWith(_))return{message:`Invalid OOXML resource-limit payload`,errorName:`Error`};let c=e instanceof Error?e:Error(s),l=c;return{message:typeof c.message==`string`?c.message:String(c.message),errorName:y(c.name,128)?c.name:`Error`,...typeof l.code==`string`?{code:l.code}:{}}}function w(e){try{return ke(e)}catch{return{message:`Worker operation failed with an unreadable error`,errorName:`Error`}}}const Ae=new Set([`encrypted`,`invalid-password`,`unsupported-encryption`,`legacy-binary-format`,`not-ooxml`]),je={\"image-dimension\":!0,\"image-pixels\":!0,\"active-decoded-bytes\":!0};function Me(e){return typeof e==`string`&&Object.prototype.hasOwnProperty.call(je,e)}function Ne(e,t){if(e!==`ooxml-decoded-image-limit`||!t||typeof t!=`object`)return;let n=t,r=n.metric,i=n.limit,a=n.observed;if(!(!Me(r)||!v(i)||!v(a)||a<=i))return{metric:r,limit:i,observed:a}}function Pe(e){let r=e.message,i=e.errorName,a=e.code,o=e.decodedImage,s=e.insufficientCredit,c=e.resourceLimit,l=typeof r==`string`?r:`Worker operation failed with an invalid error payload`,u=y(i,128)?i:void 0,d=typeof a==`string`?a:void 0,f=Ne(d,o);if(f)return new m(f.metric,f.limit,f.observed);if(d===`ooxml-tiff-decode`)return new ae(l);if(d===`ooxml-insufficient-credit`&&he(s))return new g(s);if(d===`ooxml-resource-limit`&&S(c))return new n(l,c);if(d&&Ae.has(d))return new t(d,l);let p=u===`TypeError`?TypeError(l):u===`RangeError`?RangeError(l):Error(l);return u&&(p.name=u),d!==void 0&&Object.assign(p,{code:d}),p}function Fe(e){try{return Pe(e)}catch{return Error(`Worker operation failed with an unreadable error payload`)}}function Ie(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&e.buffer instanceof ArrayBuffer?e.buffer:e.slice().buffer}Object.freeze({maxArchiveEntryBytes:134217728,maxTotalInflatedBytes:268435456,maxArchiveEntries:4096});function Le(e){return[e.maxArchiveEntryBytes===null?0n:BigInt(e.maxArchiveEntryBytes),e.maxTotalInflatedBytes===null?0n:BigInt(e.maxTotalInflatedBytes),e.maxArchiveEntries===null?0n:BigInt(e.maxArchiveEntries)]}const T=`ooxml-pull-v1`;function E(e,t){if(!Number.isSafeInteger(e)||e<=0)throw RangeError(`${t} must be a positive safe integer`)}function Re(e){if(!(typeof e==`string`&&e.length>0||typeof e==`number`&&Number.isSafeInteger(e)&&e>0))throw RangeError(`session id must be a non-empty string or positive safe integer`)}var ze=class{owner;queue=Promise.resolve();leases=new Map;retainedBytes=0;retainedCount=0;maxRetainedBytes;maxRetainedCount;cleanups=new Set;pendingFatalCleanups=[];poisonRunning=!1;fatal;constructor(e){this.maxRetainedBytes=e?.maxRetainedBytes??64*1024*1024,this.maxRetainedCount=e?.maxRetainedCount??256,E(this.maxRetainedBytes,`max retained lease bytes`),E(this.maxRetainedCount,`max retained lease count`)}enqueue(e){let t=this.queue.then(e,e);return this.queue=t.then(()=>void 0,()=>void 0),t}acquire(e){return this.owner===void 0?(this.owner=e,!0):this.owner===e}release(e){this.owner===e&&(this.owner=void 0)}retainLease(e,t,n){if(!Number.isSafeInteger(n)||n<0)throw RangeError(`retained lease bytes are invalid`);let r=this.leases.get(e)??new Map;if(r.has(t))throw Error(`driver returned a duplicate lease id`);if(this.retainedCount+1>this.maxRetainedCount)throw RangeError(`retained lease count exceeds limit`);if(this.retainedBytes+n>this.maxRetainedBytes)throw RangeError(`retained lease bytes exceed limit`);r.set(t,n),this.leases.set(e,r),this.retainedCount++,this.retainedBytes+=n}releaseLease(e,t){let n=this.leases.get(e),r=n?.get(t);r!==void 0&&(n?.delete(t),n?.size===0&&this.leases.delete(e),this.retainedCount--,this.retainedBytes-=r)}registerCleanup(e){return this.fatal?(this.poisonRunning?this.pendingFatalCleanups.push(e):this.enqueue(e).catch(()=>void 0),()=>void 0):(this.cleanups.add(e),()=>this.cleanups.delete(e))}get fatalError(){return this.fatal}get registeredHostCount(){return this.cleanups.size}async poison(e){if(this.fatal??=e,this.poisonRunning)return this.fatal;this.poisonRunning=!0,this.pendingFatalCleanups.push(...this.cleanups);try{let e;for(;(e=this.pendingFatalCleanups.shift())!==void 0;)await e().catch(()=>void 0)}finally{this.poisonRunning=!1}return this.fatal}},Be=class{options;coordinator;coordinatorOwner=Symbol(`pull-session-host`);unregisterCleanup;sequence=0;unacked;leases=new Map;activeDriverLeases=new Set;nextWireLeaseId;cancelRequested=!1;cancelComplete=!1;closeRequested=!1;closeComplete=!1;driverCancelComplete=!1;driverCloseComplete=!1;completed=!1;constructor(e){Re(e.sessionId),E(e.operationId,`operation id`),E(e.generation,`generation`),E(e.maxByteCredit,`max byte credit`),e.wireLeaseIdStart!==void 0&&E(e.wireLeaseIdStart,`wire lease id start`),this.options=e,this.coordinator=e.coordinator,this.nextWireLeaseId=e.wireLeaseIdStart??1,this.unregisterCleanup=this.coordinator.registerCleanup(()=>this.forceFatalCleanup())}dispatch(e,t){return this.coordinator.enqueue(async()=>{let n=await this.execute(e);try{t(n.response,n.transfer)}catch(e){throw await this.rollbackFailedPost(n),e}})}async rollbackFailedPost(e){let t=e.response;if(t.kind===`chunk`){let n=t.leaseId===void 0?void 0:this.leases.get(t.leaseId);try{await this.options.driver.disposeInvalidChunk?.({payload:t.payload,byteLength:t.byteLength,done:t.done,leaseId:n?.driverLeaseId,retainedBytes:n?.retainedBytes,transfer:e.transfer})}catch{}}this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);for(let[e,t]of[...this.leases])try{await this.options.driver.releaseLease?.(t.driverLeaseId)}catch{}finally{this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e)}if(this.cancelRequested=!0,!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch{}this.unregisterCleanup()}async execute(e){try{if(this.isStaleLifecycle(e)){let t=e.kind===`cancel`?`cancel`:`close`;return this.sameOperationIdentity(e)?{response:this.accepted(e,t,!0)}:{response:this.errorResponse(e,{message:`stale lifecycle targets another session or operation`,errorName:`PullSessionProtocolError`,code:`ooxml-stale-lifecycle`})}}this.validateCommandIdentity(e);let t=this.coordinator.fatalError;if(t)return e.kind===`pull`?{response:this.errorResponse(e,t)}:(e.kind===`cancel`?await this.cancel():e.kind===`close`?await this.close():e.kind===`release`&&await this.release(e.leaseId),{response:this.accepted(e,e.kind)});switch(e.kind){case`pull`:return await this.pull(e);case`ack`:return await this.ack(e.sequence),{response:this.accepted(e,`ack`)};case`release`:return await this.release(e.leaseId),{response:this.accepted(e,`release`)};case`cancel`:return await this.cancel(),{response:this.accepted(e,`cancel`)};case`close`:return await this.close(),{response:this.accepted(e,`close`)}}}catch(t){let n=w(t);return n.code===`ooxml-resource-limit`&&(n=await this.coordinator.poison(n)),{response:this.errorResponse(e,n)}}}async pull(e){if(this.closeRequested||this.cancelRequested||this.completed)throw Error(`pull session is closed`);if(this.unacked)throw Error(`previous chunk is not acknowledged`);if(!Number.isSafeInteger(e.sequence)||e.sequence<0||e.sequence!==this.sequence)throw Error(`pull command sequence mismatch`);if(this.validateHostCredit(e.byteCredit),!this.coordinator.acquire(this.coordinatorOwner))throw Error(`another operation has an unacknowledged package chunk`);let t;try{t=await this.options.driver.pull(e.byteCredit)}catch(e){throw this.coordinator.release(this.coordinatorOwner),e}let n=!1,r=!1,i,a;try{let o=this.options.driver.measureChunk(t),s=this.arrayBufferTransferBytes(t.transfer);if(o<s)throw RangeError(`measured chunk bytes are below ArrayBuffer transfer bytes`);if(a=Math.max(o,s),t.leaseId!==void 0){if(E(t.leaseId,`lease id`),t.retainedBytes===void 0)throw Error(`retained lease bytes are required`);if(this.activeDriverLeases.has(t.leaseId))throw r=!0,Error(`driver returned an active duplicate lease id`);i=this.allocateWireLeaseId(),this.coordinator.retainLease(this.coordinatorOwner,i,t.retainedBytes),this.leases.set(i,{driverLeaseId:t.leaseId,retainedBytes:t.retainedBytes}),this.activeDriverLeases.add(t.leaseId),n=!0}else if(t.retainedBytes!==void 0)throw Error(`retained lease bytes require a lease id`);if(!Number.isSafeInteger(a)||a<0)throw RangeError(`host chunk byte length must be a non-negative safe integer`);if(a>e.byteCredit)throw RangeError(`host chunk exceeds byte credit`)}catch(e){let a;try{await this.options.driver.disposeInvalidChunk?.(t)}catch(e){a=e}if(n&&i!==void 0)try{await this.release(i)}catch(e){a??=e}else if(t.leaseId!==void 0&&!r)try{await this.options.driver.releaseLease?.(t.leaseId)}catch(e){a??=e}if(r)try{await this.cancel()}catch(e){a??=e}throw this.coordinator.release(this.coordinatorOwner),a||e}return this.unacked={sequence:this.sequence,done:t.done},{response:{kind:`chunk`,protocol:T,...this.identity(),requestId:e.requestId,sequence:this.sequence,byteLength:a,done:t.done,payload:t.payload,leaseId:i,usage:this.resourceUsage()},transfer:t.transfer}}async ack(e){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`invalid ack sequence`);if(e<this.sequence)return;if(!this.unacked||e!==this.sequence)throw Error(`ack sequence mismatch`);let t=this.unacked.done;await this.options.driver.acknowledge?.(e),this.unacked=void 0,this.coordinator.release(this.coordinatorOwner),this.sequence++,t&&(this.completed=!0,this.maybeUnregisterCompleted())}async release(e){E(e,`wire lease id`);let t=this.leases.get(e);t&&(await this.options.driver.releaseLease?.(t.driverLeaseId),this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e),this.maybeUnregisterCompleted())}async cancel(){if(this.cancelComplete)return;this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.cancelComplete=!0,this.unregisterCleanup()}async close(){if(this.closeComplete)return;this.closeRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCloseComplete)try{await this.options.driver.close?.(),this.driverCloseComplete=!0}catch(t){e??=t}if(e)throw e;this.closeComplete=!0,this.unregisterCleanup()}async releaseAllLeases(){let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(e)throw e}validateCommandIdentity(e){if(e.protocol!==`ooxml-pull-v1`||e.sessionId!==this.options.sessionId||e.operationId!==this.options.operationId||e.generation!==this.options.generation||!Number.isSafeInteger(e.requestId)||e.requestId<=0)throw Error(`stale or mismatched pull session command`)}validateHostCredit(e){if(E(e,`byte credit`),e>this.options.maxByteCredit)throw RangeError(`byte credit exceeds host maximum`)}accepted(e,t,n=!1){return{kind:`accepted`,protocol:T,...n?{sessionId:e.sessionId,operationId:e.operationId,generation:e.generation}:this.identity(),requestId:e.requestId,command:t,usage:this.resourceUsage()}}identity(){return{sessionId:this.options.sessionId,operationId:this.options.operationId,generation:this.options.generation}}isStaleLifecycle(e){return(e.kind===`cancel`||e.kind===`close`)&&e.protocol===`ooxml-pull-v1`&&Number.isSafeInteger(e.requestId)&&e.requestId>0&&Number.isSafeInteger(e.generation)&&e.generation>0&&e.generation<this.options.generation}sameOperationIdentity(e){return e.sessionId===this.options.sessionId&&e.operationId===this.options.operationId}errorResponse(e,t){return{kind:`error`,protocol:T,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:t,usage:this.errorResourceUsage()}}async forceFatalCleanup(){this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.unregisterCleanup()}allocateWireLeaseId(){if(!Number.isSafeInteger(this.nextWireLeaseId)||this.nextWireLeaseId<=0)throw RangeError(`wire lease id space exhausted`);return this.nextWireLeaseId++}arrayBufferTransferBytes(e){let t=0;for(let n of e??[])if(n instanceof ArrayBuffer&&(t+=n.byteLength,!Number.isSafeInteger(t)))throw RangeError(`ArrayBuffer transfer bytes overflow`);return t}maybeUnregisterCompleted(){this.completed&&this.leases.size===0&&this.unregisterCleanup()}resourceUsage(){return this.options.driver.resourceUsage?.()}errorResourceUsage(){try{return this.resourceUsage()}catch{return}}};function D(e,t){if(!Number.isSafeInteger(e)||e<0)throw Error(`${t} must be a non-negative safe integer`)}function O(e,t,n){return D(e,`resource measurement`),D(t,`resource measurement`),D(n,`resource measurement limit`),e>n||t>n||t>n-e?n===2**53-1?n:n+1:e+t}function Ve(e,t=2**53-1){D(t,`resource measurement limit`);let n=0;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r),a;if(i<=127)a=1;else if(i<=2047)a=2;else if(i>=55296&&i<=56319&&r+1<e.length){let t=e.charCodeAt(r+1);t>=56320&&t<=57343?(a=4,r+=1):a=3}else a=3;if(n=O(n,a,t),n>t)return n}return n}function He(e,t=2**53-1){D(t,`resource measurement limit`);let n=O(0,2,t);if(n>t)return n;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r),a;if(i===34||i===92||i===8||i===9||i===10||i===12||i===13)a=2;else if(i<=31)a=6;else if(i<=127)a=1;else if(i<=2047)a=2;else if(i>=55296&&i<=56319&&r+1<e.length){let t=e.charCodeAt(r+1);t>=56320&&t<=57343?(a=4,r+=1):a=6}else a=i>=55296&&i<=57343?6:3;if(n=O(n,a,t),n>t)return n}return n}function k(e,t){return O(0,e,t)}function A(e,t=2**53-1,n=!1){if(D(t,`resource measurement limit`),e===null)return{jsonBytes:k(4,t),stringValueUtf8Bytes:0};if(typeof e==`string`)return{jsonBytes:He(e,t),stringValueUtf8Bytes:Ve(e,t)};if(typeof e==`boolean`)return{jsonBytes:k(e?4:5,t),stringValueUtf8Bytes:0};if(typeof e==`number`)return{jsonBytes:k((Number.isFinite(e)?String(Object.is(e,-0)?0:e):`null`).length,t),stringValueUtf8Bytes:0};if(typeof e==`bigint`)throw TypeError(`BigInt values cannot be serialized to JSON`);if(Array.isArray(e)){let n=k(2,t),r=0;for(let i=0;i<e.length;i+=1){i!==0&&(n=O(n,1,t));let a=A(e[i],t,!0);n=O(n,a.jsonBytes,t),r=O(r,a.stringValueUtf8Bytes,t)}return{jsonBytes:n,stringValueUtf8Bytes:r}}if(typeof e==`object`){let n=k(2,t),r=0,i=0;for(let[a,o]of Object.entries(e)){if(o===void 0||typeof o==`function`||typeof o==`symbol`)continue;i++!==0&&(n=O(n,1,t)),n=O(n,He(a,t),t),n=O(n,1,t);let e=A(o,t);n=O(n,e.jsonBytes,t),r=O(r,e.stringValueUtf8Bytes,t)}return{jsonBytes:n,stringValueUtf8Bytes:r}}return{jsonBytes:n?k(4,t):0,stringValueUtf8Bytes:0}}({...s,...u});function*Ue(e){for(let t of e?.paragraphs??[])for(let e of t.runs)e.type===`text`&&(yield e.text)}function*j(e){for(let t of e?.paragraphs??[]){t.defFontFamily&&(yield t.defFontFamily);for(let e of t.runs)e.type===`text`&&(e.fontFamily&&(yield e.fontFamily),e.fontFamilyEa&&(yield e.fontFamilyEa),e.fontFamilySym&&(yield e.fontFamilySym))}}function*We(e){for(let t of e.elements)if(t.type===`shape`)yield*Ue(t.textBody);else if(t.type===`table`)for(let e of t.rows)for(let t of e.cells)yield*Ue(t.textBody);else if(t.type===`chart`){t.chart.title&&(yield t.chart.title);for(let e of t.chart.categories)yield e;for(let e of t.chart.series)e.name&&(yield e.name)}}var Ge=class e{scripts;families;constructor(e,t,n,r){this.majorFont=e,this.minorFont=t;let i=c(e)??c(t)??null;this.scripts=n??new d(i),this.families=r??new Set,e&&this.families.add(e),t&&this.families.add(t)}addSlide(e){this.scripts.addText(We(e));for(let t of e.elements)if(t.type===`shape`)for(let e of j(t.textBody))this.families.add(e);else if(t.type===`table`)for(let e of t.rows)for(let t of e.cells)for(let e of j(t.textBody))this.families.add(e)}names(){return[...this.families,...this.scripts.names()]}withSlide(t){let n=new e(this.majorFont,this.minorFont,this.scripts.clone(),new Set(this.families));return n.addSlide(t),n}};const M=Object.freeze({archiveEntryCount:0,declaredInflatedBytes:0,distinctInflatedBytes:0,operationInflatedBytes:0}),Ke=67108864;function N(e,t){if(e!==null&&typeof e!=`string`)throw Error(`invalid PPTX presentation bootstrap ${t}`)}function qe(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`invalid PPTX presentation bootstrap slide at ${t}`);let n=e;if(n.index!==t)throw Error(`invalid PPTX presentation bootstrap slide index ${n.index}`);if(n.partName!==void 0&&typeof n.partName!=`string`)throw Error(`invalid PPTX presentation bootstrap slide partName at ${t}`);return Object.freeze({index:n.index,...n.partName===void 0?{}:{partName:n.partName}})}function Je(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`invalid PPTX presentation bootstrap embedded font at ${t}`);let n=e;if(typeof n.fontName!=`string`||n.fontName.length===0||![`regular`,`bold`,`italic`,`boldItalic`].includes(n.style??``)||typeof n.partPath!=`string`||n.partPath.length===0||n.partPath.startsWith(`/`)||n.partPath.split(`/`).includes(`..`)||![`application/x-font-ttf`,`application/x-fontdata`].includes(n.contentType??``))throw Error(`invalid PPTX presentation bootstrap embedded font fields at ${t}`);return Object.freeze({fontName:n.fontName,style:n.style,partPath:n.partPath,contentType:n.contentType})}function Ye(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`invalid PPTX presentation bootstrap payload`);let t=e;if(!Number.isSafeInteger(t.slideCount)||(t.slideCount??-1)<0||!Number.isSafeInteger(t.slideWidth)||(t.slideWidth??0)<=0||!Number.isSafeInteger(t.slideHeight)||(t.slideHeight??0)<=0||!Array.isArray(t.embeddedFonts)||!Array.isArray(t.slides)||t.slides.length!==t.slideCount)throw Error(`invalid PPTX presentation bootstrap dimensions or slide count`);return N(t.defaultTextColor,`defaultTextColor`),N(t.majorFont,`majorFont`),N(t.minorFont,`minorFont`),N(t.hlinkColor,`hlinkColor`),N(t.folHlinkColor,`folHlinkColor`),Object.freeze({slideCount:t.slideCount,slideWidth:t.slideWidth,slideHeight:t.slideHeight,defaultTextColor:t.defaultTextColor,majorFont:t.majorFont,minorFont:t.minorFont,hlinkColor:t.hlinkColor,folHlinkColor:t.folHlinkColor,embeddedFonts:Object.freeze(t.embeddedFonts.map(Je)),slides:Object.freeze(t.slides.map(qe))})}function Xe(e){return Object.freeze({type:`media`,x:e.x,y:e.y,width:e.width,height:e.height,rotation:e.rotation,flipH:e.flipH,flipV:e.flipV,mediaKind:e.mediaKind,posterPath:e.posterPath,posterMimeType:e.posterMimeType,mediaPath:e.mediaPath,mimeType:e.mimeType})}function Ze(e){return Object.freeze({...e.id===void 0?{}:{id:e.id},...e.authorId===void 0?{}:{authorId:e.authorId},...e.author===void 0?{}:{author:e.author},...e.date===void 0?{}:{date:e.date},...e.status===void 0?{}:{status:e.status},text:e.text})}function Qe(e){return Object.freeze({...e})}function $e(e){return Object.freeze({...e.authorId===void 0?{}:{authorId:e.authorId},...e.modernAuthorId===void 0?{}:{modernAuthorId:e.modernAuthorId},...e.id===void 0?{}:{id:e.id},...e.index===void 0?{}:{index:e.index},...e.author===void 0?{}:{author:e.author},...e.date===void 0?{}:{date:e.date},...e.x===void 0?{}:{x:e.x},...e.y===void 0?{}:{y:e.y},...e.anchors?.length?{anchors:Object.freeze(e.anchors.map(Qe))}:{},...e.status===void 0?{}:{status:e.status},text:e.text,...e.replies?.length?{replies:Object.freeze(e.replies.map(Ze))}:{}})}function et(e,t){if(e.index!==t.index||e.partName!==t.partName)throw Error(`PPTX pulled slide identity does not match bootstrap index ${t.index}`);return Object.freeze({index:t.index,...t.partName===void 0?{}:{partName:t.partName},notes:e.notes??null,hidden:e.hidden??!1,mediaElements:Object.freeze(e.elements.filter(e=>e.type===`media`).map(Xe)),...e.comments?.length?{comments:Object.freeze(e.comments.map($e))}:{}})}function tt(e,t,r){if(!(e<=t))throw new n(`PPTX presentation preflight exceeded its hard limit of ${t} projected bytes`,{stage:`parsing`,violation:{format:`pptx`,operation:`presentation-preflight`,resource:`presentation-preflight`,metric:`projected-bytes`,limit:t,observed:Math.min(e,t+1),configurable:!1,usage:r}})}var nt=class{slideCountValue;slideWidthValue;slideHeightValue;defaultTextColorValue;majorFontValue;minorFontValue;hlinkColorValue;folHlinkColorValue;embeddedFontsValue;descriptors;slides=[];fonts;fontPreloadNames;fontProjectionBytes;projectionBytesValue;limit;pending=null;finished=null;constructor(e,t={}){let n=Ye(e),r=t.hardLimitForTesting??Ke;if(!Number.isSafeInteger(r)||r<=0||r>Ke)throw Error(`invalid PPTX presentation preflight test limit`);this.limit=r,this.slideCountValue=n.slideCount,this.slideWidthValue=n.slideWidth,this.slideHeightValue=n.slideHeight,this.defaultTextColorValue=n.defaultTextColor,this.majorFontValue=n.majorFont,this.minorFontValue=n.minorFont,this.hlinkColorValue=n.hlinkColor,this.folHlinkColorValue=n.folHlinkColor,this.embeddedFontsValue=n.embeddedFonts,this.descriptors=[...n.slides],this.fonts=new Ge(this.majorFontValue,this.minorFontValue),this.fontPreloadNames=Object.freeze(this.fonts.names()),this.fontProjectionBytes=A(this.fontPreloadNames,this.limit).jsonBytes,this.projectionBytesValue=A({slideCount:this.slideCountValue,slideWidth:this.slideWidthValue,slideHeight:this.slideHeightValue,defaultTextColor:this.defaultTextColorValue,majorFont:this.majorFontValue,minorFont:this.minorFontValue,hlinkColor:this.hlinkColorValue,folHlinkColor:this.folHlinkColorValue,embeddedFonts:this.embeddedFontsValue,remainingSlides:this.descriptors,slides:[],fontPreloadNames:this.fontPreloadNames},this.limit).jsonBytes,tt(this.projectionBytesValue,this.limit,M)}get acceptedSlideCount(){return this.finished?.slideCount??this.slides.length}get projectedBytes(){return this.projectionBytesValue}get remainingDescriptorCount(){return this.descriptors.reduce((e,t)=>e+Number(t!==void 0),0)}get latestSlide(){return this.slides[this.slides.length-1]}get currentFontPreloadNames(){return this.fontPreloadNames}snapshot(){if(this.finished)return this.finished;if(this.pending)throw Error(`PPTX presentation preflight has an uncommitted slide`);return Object.freeze({slideCount:this.slideCountValue,slideWidth:this.slideWidthValue,slideHeight:this.slideHeightValue,defaultTextColor:this.defaultTextColorValue,majorFont:this.majorFontValue,minorFont:this.minorFontValue,hlinkColor:this.hlinkColorValue,folHlinkColor:this.folHlinkColorValue,embeddedFonts:this.embeddedFontsValue,slides:Object.freeze([...this.slides]),fontPreloadNames:this.fontPreloadNames})}addSlide(e,t=M){this.prepareSlide(e,t).commit()}prepareSlide(e,t=M){if(this.finished)throw Error(`PPTX presentation preflight is already finished`);if(this.pending)throw Error(`PPTX presentation preflight already has a prepared slide`);let n=this.slides.length,r=this.descriptors[n];if(!r)throw Error(`PPTX presentation preflight received an extra slide`);let i=et(e,r),a=this.fonts.withSlide(e),o=Object.freeze(a.names()),s=A(o,this.limit).jsonBytes,c=A(i,this.limit).jsonBytes,l=this.projectionBytesValue-this.fontProjectionBytes-A(r,this.limit).jsonBytes+4;l=O(l,s,this.limit),l=O(l,c,this.limit),this.slides.length!==0&&(l=O(l,1,this.limit));let u=A({slide:i,fontPreloadNames:o},this.limit).jsonBytes,d=O(this.projectionBytesValue,u,this.limit);tt(Math.max(d,l),this.limit,t);let f={state:`prepared`,fact:i,fonts:a,fontNames:o,fontBytes:s,committedBytes:l};return this.pending=f,{projectedBytes:d,commit:()=>{if(f.state!==`committed`){if(f.state===`rolled-back`)throw Error(`PPTX presentation preflight cannot commit a rolled-back slide`);if(this.pending!==f)throw Error(`PPTX presentation preflight prepared slide is stale`);this.descriptors[n]=void 0,this.slides.push(f.fact),this.fonts=f.fonts,this.fontPreloadNames=f.fontNames,this.fontProjectionBytes=f.fontBytes,this.projectionBytesValue=f.committedBytes,f.state=`committed`,this.pending=null}},rollback:()=>{if(f.state!==`rolled-back`){if(f.state===`committed`)throw Error(`PPTX presentation preflight cannot roll back a committed slide`);if(this.pending!==f)throw Error(`PPTX presentation preflight prepared slide is stale`);f.state=`rolled-back`,this.pending=null}}}}finish(){if(this.finished)return this.finished;if(this.pending)throw Error(`PPTX presentation preflight has an uncommitted slide`);if(this.slides.length!==this.slideCountValue)throw Error(`PPTX presentation preflight is incomplete: ${this.slides.length}/${this.slideCountValue} slides`);return this.finished=Object.freeze({slideCount:this.slideCountValue,slideWidth:this.slideWidthValue,slideHeight:this.slideHeightValue,defaultTextColor:this.defaultTextColorValue,majorFont:this.majorFontValue,minorFont:this.minorFontValue,hlinkColor:this.hlinkColorValue,folHlinkColor:this.folHlinkColorValue,embeddedFonts:this.embeddedFontsValue,slides:Object.freeze([...this.slides]),fontPreloadNames:this.fontPreloadNames}),this.descriptors=[],this.slides=[],this.projectionBytesValue=A(this.finished,this.limit).jsonBytes,this.finished}};function rt(e){try{return ye(e(e=>e.slide_cursor_resource_usage()))}catch(e){if(String(e).includes(`slide cursor usage is unavailable`))return;throw e}}function it(e,t,n,r,i){let a,o;try{if(i){if(!r)throw Error(`slide payload is missing before acknowledgement`);let t=i(n,r,rt(e));typeof t==`function`?a=t:t&&({rollback:a,commit:o}=t)}e(e=>e.acknowledge_slide(t.operationId,t.generation)),o?.()}catch(e){try{a?.()}catch{}throw e}}var at=class{coordinatorGeneration=new ze;sessions=new Map;pendingOpens=new Map;operationTail=Promise.resolve();resourceFailure;lifecycleState=`ready`;resetBarrier;resetIdentities=new Map;constructor(e,t,n=e=>e(this.requireArchive())){this.archive=e,this.acceptSlide=t,this.executeArchive=n}get coordinator(){return this.coordinatorGeneration}reserveOpen(e){if(this.assertReady(),st(e),this.pendingOpens.has(e.sessionId)||this.sessions.has(e.sessionId))throw Error(`slide pull session id is already reserved`);this.pendingOpens.set(e.sessionId,{identity:e,canceled:!1})}abandonOpen(e){this.pendingOpens.delete(e)}get pendingOpenCount(){return this.pendingOpens.size}async open(e,t){if(this.assertReady(),this.resourceFailure)throw this.resourceFailure;if(!Number.isSafeInteger(e)||e<0)throw RangeError(`slide index must be a non-negative safe integer`);let n=this.pendingOpens.get(t.sessionId);if(!n||!P(n.identity,t))throw Error(`slide pull session open reservation is stale or missing`);let i,a=new Promise(e=>{i=e}),o=this.operationTail.then(()=>this.coordinator.enqueue(async()=>{if(n.canceled)throw Error(`slide pull session open was canceled`);let a,o=!1,s=new Be({...t,maxByteCredit:r,coordinator:this.coordinator,driver:{pull:n=>{let i;try{i=this.executeArchive(r=>r.pull_slide(e,t.operationId,t.generation,n))}catch(e){throw _e(e,n,r)||(this.latchResourceFailure(e),e)}let s=Ie(i);return this.acceptSlide&&(a=JSON.parse(new TextDecoder().decode(new Uint8Array(s)))),o=!0,{payload:s,byteLength:s.byteLength,done:!0,transfer:[s]}},measureChunk:({payload:e})=>e.byteLength,acknowledge:()=>{if(!o)throw Error(`slide unit is not awaiting acknowledgement`);try{it(this.executeArchive,t,e,a,this.acceptSlide)}catch(e){throw this.latchResourceFailure(e),e}o=!1,a=void 0,this.sessions.delete(t.sessionId),i()},cancel:async()=>{try{this.archive()&&await this.executeArchive(e=>e.cancel_slide())}finally{a=void 0,o=!1,this.sessions.delete(t.sessionId),i()}},close:async()=>{try{this.archive()&&await this.executeArchive(e=>e.cancel_slide())}finally{a=void 0,o=!1,this.sessions.delete(t.sessionId),i()}},resourceUsage:()=>{try{return this.readResourceUsage()}catch(e){throw this.latchResourceFailure(e),e}}}});this.sessions.set(t.sessionId,{host:s,identity:t}),this.pendingOpens.delete(t.sessionId)}));this.operationTail=o.then(()=>a,()=>void 0);try{await o}catch(e){throw this.pendingOpens.delete(t.sessionId),i(),e}}async postOpenedSafely(e,t,n){if(this.lifecycleState!==`ready`){try{n(this.lifecycleError())}catch{}return}try{t()}catch(t){await this.closeIdentity(e);try{n(t)}catch{}}}dispatch(e,t){if(this.lifecycleState!==`ready`)return t(this.responseDuringReset(e)),Promise.resolve();let n=this.sessions.get(e.sessionId);if(n)return n.host.dispatch(e,t);let r=this.pendingOpens.get(e.sessionId);if(r&&(e.kind===`cancel`||e.kind===`close`)){let n=P(r.identity,e);return n&&(r.canceled=!0),t(n?{protocol:T,kind:`accepted`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,command:e.kind}:this.staleLifecycleResponse(e)),Promise.resolve()}return e.kind===`cancel`||e.kind===`close`?(t({protocol:T,kind:`accepted`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,command:e.kind}),Promise.resolve()):(t({protocol:T,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:w(Error(`slide pull session is not open`))}),Promise.resolve())}async dispatchSafely(e,t){try{await this.dispatch(e,t)}catch(n){try{t({protocol:T,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:w(n)})}catch{}}}run(e){if(this.lifecycleState!==`ready`)return Promise.reject(this.lifecycleError());let t=this.operationTail.then(()=>this.coordinator.enqueue(async()=>{if(this.resourceFailure)throw this.resourceFailure;return e()})).catch(e=>{throw this.latchResourceFailure(e),e});return this.operationTail=t.then(()=>void 0,()=>void 0),t}reset(){if(this.resetBarrier)return this.resetBarrier;this.lifecycleState=`resetting`,this.captureResetIdentities();let e=this.performReset().then(()=>{this.resetIdentities.clear(),this.lifecycleState=`ready`},e=>{throw this.lifecycleState=`reset-failed`,e}).finally(()=>{this.resetBarrier===e&&(this.resetBarrier=void 0)});return this.resetBarrier=e,e}async performReset(){for(let e of this.pendingOpens.values())e.canceled=!0;let e=1;for(let{host:t,identity:n}of[...this.sessions.values()]){let r;if(await t.dispatch({protocol:T,kind:`close`,...n,requestId:e++},e=>{e.kind===`error`&&(r=Fe(e.error))}),r)throw r}this.sessions.clear(),await this.operationTail,this.pendingOpens.clear(),this.archive()&&await this.executeArchive(e=>e.close_presentation_session()),this.coordinatorGeneration=new ze,this.resourceFailure=void 0}assertReady(){if(this.lifecycleState!==`ready`)throw this.lifecycleError()}lifecycleError(){let e=this.lifecycleState===`reset-failed`,t=Error(e?`slide pull worker reset failed; retry reset before new work`:`slide pull worker reset is in progress`);return t.name=`PullSessionLifecycleError`,Object.assign(t,{code:e?`ooxml-pull-reset-failed`:`ooxml-pull-resetting`})}captureResetIdentities(){for(let{identity:e}of this.sessions.values())this.resetIdentities.set(e.sessionId,e);for(let{identity:e}of this.pendingOpens.values())this.resetIdentities.set(e.sessionId,e)}responseDuringReset(e){if(e.kind===`cancel`||e.kind===`close`){let t=this.resetIdentities.get(e.sessionId);return t&&!P(t,e)?this.staleLifecycleResponse(e):{protocol:T,kind:`accepted`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,command:e.kind}}return{protocol:T,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:w(this.lifecycleError())}}requireArchive(){let e=this.archive();if(!e)throw Error(`Presentation not loaded`);return e}async closeIdentity(e){if(this.lifecycleState!==`ready`)return;let t=this.sessions.get(e.sessionId);if(t){await t.host.dispatch({protocol:T,kind:`close`,...e,requestId:1},()=>void 0);return}let n=this.pendingOpens.get(e.sessionId);n&&P(n.identity,e)&&(n.canceled=!0)}readResourceUsage(){return rt(this.executeArchive)}latchResourceFailure(e){let t=e instanceof n?e:C(e);t&&(this.resourceFailure??=t)}staleLifecycleResponse(e){return{protocol:T,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:{message:`stale lifecycle targets another slide operation`,errorName:`PullSessionProtocolError`,code:`ooxml-stale-lifecycle`}}}};function ot(e){return!!e&&typeof e==`object`&&e.protocol===`ooxml-pull-v1`}function st(e){if(!Number.isSafeInteger(e.sessionId)||e.sessionId<=0)throw RangeError(`session id must be a positive safe integer`);if(!Number.isSafeInteger(e.operationId)||e.operationId<=0)throw RangeError(`operation id must be a positive safe integer`);if(!Number.isSafeInteger(e.generation)||e.generation<=0)throw RangeError(`generation must be a positive safe integer`)}function P(e,t){return e.sessionId===t.sessionId&&e.operationId===t.operationId&&e.generation===t.generation}var F=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,lt.unregister(this),e}free(){let e=this.__destroy_into_raw();J.__wbg_pptxarchive_free(e,0)}acknowledge_slide(e,t){let n=J.pptxarchive_acknowledge_slide(this.__wbg_ptr,e,t);if(n[1])throw U(n[0])}assert_healthy(){let e=J.pptxarchive_assert_healthy(this.__wbg_ptr);if(e[1])throw U(e[0])}cancel_slide(){J.pptxarchive_cancel_slide(this.__wbg_ptr)}close_presentation_session(){J.pptxarchive_close_presentation_session(this.__wbg_ptr)}extract_font(e){let t=H(e,J.__wbindgen_malloc,J.__wbindgen_realloc),n=q,r=J.pptxarchive_extract_font(this.__wbg_ptr,t,n);if(r[3])throw U(r[2]);var i=I(r[0],r[1]).slice();return J.__wbindgen_free(r[0],r[1]*1,1),i}extract_image(e){let t=H(e,J.__wbindgen_malloc,J.__wbindgen_realloc),n=q,r=J.pptxarchive_extract_image(this.__wbg_ptr,t,n);if(r[3])throw U(r[2]);var i=I(r[0],r[1]).slice();return J.__wbindgen_free(r[0],r[1]*1,1),i}extract_media(e){let t=H(e,J.__wbindgen_malloc,J.__wbindgen_realloc),n=q,r=J.pptxarchive_extract_media(this.__wbg_ptr,t,n);if(r[3])throw U(r[2]);var i=I(r[0],r[1]).slice();return J.__wbindgen_free(r[0],r[1]*1,1),i}constructor(e,t,n,r){let i=dt(e,J.__wbindgen_malloc),a=q,o=J.pptxarchive_new(i,a,!V(t),V(t)?BigInt(0):t,!V(n),V(n)?BigInt(0):n,!V(r),V(r)?BigInt(0):r);if(o[2])throw U(o[1]);return this.__wbg_ptr=o[0]>>>0,lt.register(this,this.__wbg_ptr,this),this}parse(){let e=J.pptxarchive_parse(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}presentation_bootstrap(){let e=J.pptxarchive_presentation_bootstrap(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}pull_slide(e,t,n,r){let i=J.pptxarchive_pull_slide(this.__wbg_ptr,e,t,n,r);if(i[3])throw U(i[2]);var a=I(i[0],i[1]).slice();return J.__wbindgen_free(i[0],i[1]*1,1),a}resource_usage(){let e=J.pptxarchive_resource_usage(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}slide_cursor_resource_usage(){let e=J.pptxarchive_slide_cursor_resource_usage(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}to_markdown(){let e,t;try{let i=J.pptxarchive_to_markdown(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,U(i[2]);return e=n,t=r,R(n,r)}finally{J.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(F.prototype[Symbol.dispose]=F.prototype.free);function ct(){return{__proto__:null,\"./pptx_parser_bg.js\":{__proto__:null,__wbg___wbindgen_throw_6b64449b9b9ed33c:function(e,t){throw Error(R(e,t))},__wbg_error_a6fa202b58aa1cd3:function(e,t){let n,r;try{n=e,r=t,console.error(R(e,t))}finally{J.__wbindgen_free(n,r,1)}},__wbg_new_227d7c05414eb861:function(){return Error()},__wbg_stack_3b0d974bbf31e44f:function(e,t){let n=t.stack,r=H(n,J.__wbindgen_malloc,J.__wbindgen_realloc),i=q;ut().setInt32(e+4,i,!0),ut().setInt32(e+0,r,!0)},__wbindgen_cast_0000000000000001:function(e,t){return R(e,t)},__wbindgen_init_externref_table:function(){let e=J.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const lt=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>J.__wbg_pptxarchive_free(e>>>0,1));function I(e,t){return e>>>=0,B().subarray(e/1,e/1+t)}let L=null;function ut(){return(L===null||L.buffer.detached===!0||L.buffer.detached===void 0&&L.buffer!==J.memory.buffer)&&(L=new DataView(J.memory.buffer)),L}function R(e,t){return e>>>=0,ft(e,t)}let z=null;function B(){return(z===null||z.byteLength===0)&&(z=new Uint8Array(J.memory.buffer)),z}function V(e){return e==null}function dt(e,t){let n=t(e.length*1,1)>>>0;return B().set(e,n/1),q=e.length,n}function H(e,t,n){if(n===void 0){let n=K.encode(e),r=t(n.length,1)>>>0;return B().subarray(r,r+n.length).set(n),q=n.length,r}let r=e.length,i=t(r,1)>>>0,a=B(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=B().subarray(i+o,i+r),a=K.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return q=o,i}function U(e){let t=J.__wbindgen_externrefs.get(e);return J.__externref_table_dealloc(e),t}let W=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});W.decode();let G=0;function ft(e,t){return G+=t,G>=2146435072&&(W=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),W.decode(),G=t),W.decode(B().subarray(e,e+t))}const K=new TextEncoder;`encodeInto`in K||(K.encodeInto=function(e,t){let n=K.encode(e);return t.set(n),{read:e.length,written:n.length}});let q=0,J;function pt(e,t){return J=e.exports,L=null,z=null,J.__wbindgen_start(),J}async function mt(e,t){if(typeof Response==`function`&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(e.ok&&n(e.type)&&e.headers.get(`Content-Type`)!==`application/wasm`)console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\",t);else throw t}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}function n(e){switch(e){case`basic`:case`cors`:case`default`:return!0}return!1}}async function ht(e){if(J!==void 0)return J;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn(`using deprecated parameters for the initialization function; pass a single object instead`));let t=ct();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await mt(await e,t);return pt(n,r)}async function gt(e){return J=void 0,L=null,z=null,ht(e)}const Y=new pe(ht,{freeArchive:e=>e.free(),reinit:gt});let X=null,Z=`empty`;function _t(){if(Z!==`empty`){let e=Error(`this PPTX worker already owns a presentation parse`);throw e.name=`PptxWorkerStateError`,Object.assign(e,{code:`ooxml-pptx-parse-already-started`})}Z=`opening`}const Q=new at(()=>Y.archive,(e,t,n)=>{if(X){if(e!==X.acceptedSlideCount)throw Error(`PPTX preflight expected slide ${X.acceptedSlideCount}, received ${e}`);return X.prepareSlide(t,n)}},e=>{let t=Y.archive;if(!t)throw Error(`Presentation not loaded`);return Y.run(()=>e(t))}),$=(e,t)=>self.postMessage(e,t);self.onmessage=async e=>{let t=e.data;if(ot(t)){await Q.dispatchSafely(t,$);return}if(t.kind===`init`){Y.setWasmInput(se(t.wasmUrl)??t.wasmUrl);return}let n=t.id,r=!1;try{if(t.kind===`openSlideSession`&&Q.reserveOpen(t),t.kind===`parse`&&(_t(),r=!0),t.kind===`openSlideSession`){await Y.ensureReady(),await Q.open(t.slideIndex,t),await Q.postOpenedSafely(t,()=>$({kind:`slideSessionOpened`,id:n,sessionId:t.sessionId,operationId:t.operationId,generation:t.generation}),e=>$({kind:`error`,id:n,...w(e)}));return}t.kind===`parse`&&await Q.reset(),await Q.run(async()=>{if(await Y.ensureReady(),t.kind!==`parse`&&Y.archive){let e=Y.archive;Y.run(()=>e.assert_healthy())}if(t.kind===`parse`){X=null;let[e,r,i]=Le(t.resourcePolicy),a=Y.run(()=>{let n=new F(new Uint8Array(t.buffer),e,r,i);return Y.setArchive(n),JSON.parse(new TextDecoder().decode(n.presentation_bootstrap()))});X=t.progressiveLayout?null:new nt(a),$({kind:`presentationOpened`,id:n,bootstrap:a}),Z=`ready`;return}let e=Y.archive;if(!e)throw Error(`No pptx loaded`);if(t.kind===`finishPresentationPreflight`){if(!X)throw Error(`PPTX presentation preflight is not active`);let e=X.finish();X=null,$({kind:`presentationPreflightReady`,id:n,preflight:e});return}if(t.kind===`extractMedia`){let r=Y.run(()=>e.extract_media(t.path).buffer);$({kind:`mediaExtracted`,id:n,bytes:r},[r]);return}if(t.kind===`extractImage`){let r=Y.run(()=>e.extract_image(t.path).buffer);$({kind:`imageExtracted`,id:n,bytes:r},[r]);return}if(t.kind===`extractFont`){let r=Y.run(()=>e.extract_font(t.path).buffer);$({kind:`fontExtracted`,id:n,bytes:r},[r]);return}if(t.kind===`resourceUsage`){$({kind:`resourceUsage`,id:n,usage:ye(Y.run(()=>e.resource_usage()))});return}t.kind===`toMarkdown`&&$({kind:`markdownRendered`,id:n,markdown:Y.run(()=>e.to_markdown())})})}catch(e){r&&(Z=`failed`),t.kind===`openSlideSession`&&Q.abandonOpen(t.sessionId);try{$({kind:`error`,id:n,...w(e)})}catch{}}};", Ct = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", St], { type: "text/javascript;charset=utf-8" });
|
|
610
|
+
var St = "var e=(e,t)=>()=>(e&&(t=e(e=0)),t),t=class e extends Error{code;constructor(t,n){super(n),this.name=`OoxmlError`,this.code=t,Object.setPrototypeOf(this,e.prototype)}},n=class e extends Error{code=`ooxml-resource-limit`;details;constructor(t,n){super(t),this.name=`OoxmlResourceLimitError`;let r=n.violation,i=Object.freeze({format:r.format,operation:r.operation,resource:r.resource,metric:r.metric,...r.part===void 0?{}:{part:r.part},limit:r.limit,observed:r.observed,configurable:r.configurable,usage:Object.freeze({archiveEntryCount:r.usage.archiveEntryCount,declaredInflatedBytes:r.usage.declaredInflatedBytes,...r.usage.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:r.usage.largestInflatedEntryBytes},distinctInflatedBytes:r.usage.distinctInflatedBytes,operationInflatedBytes:r.usage.operationInflatedBytes})});this.details=Object.freeze({stage:n.stage,violation:i}),Object.setPrototypeOf(this,e.prototype)}};const r=67108864,i=`https://fonts.googleapis.com/css2?family=Noto+Naskh+Arabic:wght@400;700&display=swap`,a=`https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@400;700&display=swap`,o=`https://fonts.googleapis.com/css2?family=Libre+Franklin:ital,wght@0,400;0,600;0,700;1,400;1,600;1,700&display=swap`,s={calibri:{url:`https://fonts.googleapis.com/css2?family=Carlito:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Carlito`},\"calibri light\":{url:`https://fonts.googleapis.com/css2?family=Carlito:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Carlito`},cambria:{url:`https://fonts.googleapis.com/css2?family=Caladea:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Caladea`},\"cambria math\":{url:`https://fonts.googleapis.com/css2?family=Caladea:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Caladea`},\"franklin gothic book\":{url:o,loadFamily:`Libre Franklin`},\"franklin gothic medium\":{url:o,loadFamily:`Libre Franklin`},\"nunito sans\":{url:`https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap`},nunito:{url:`https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,400;0,700;1,400;1,700&display=swap`},\"open sans\":{url:`https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap`},roboto:{url:`https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,700;1,400;1,700&display=swap`},lato:{url:`https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;1,400;1,700&display=swap`},montserrat:{url:`https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,400;0,700;1,400;1,700&display=swap`},poppins:{url:`https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,700;1,400;1,700&display=swap`},raleway:{url:`https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,400;0,700;1,400;1,700&display=swap`},\"playfair display\":{url:`https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400;1,700&display=swap`},ubuntu:{url:`https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,400;0,700;1,400;1,700&display=swap`},\"sakkal majalla\":{url:i,loadFamily:`Noto Naskh Arabic`},\"traditional arabic\":{url:i,loadFamily:`Noto Naskh Arabic`},\"simplified arabic\":{url:i,loadFamily:`Noto Naskh Arabic`},\"arabic typesetting\":{url:i,loadFamily:`Noto Naskh Arabic`},\"univers next arabic\":{url:a,loadFamily:`Noto Sans Arabic`},\"noto naskh arabic\":{url:i,loadFamily:`Noto Naskh Arabic`},\"noto sans arabic\":{url:a,loadFamily:`Noto Sans Arabic`}},c={\"noto sans cjk sc\":`Noto Sans SC`,\"noto serif cjk sc\":`Noto Serif SC`,\"noto sans cjk tc\":`Noto Sans TC`,\"noto serif cjk tc\":`Noto Serif TC`,\"noto sans cjk jp\":`Noto Sans JP`,\"noto serif cjk jp\":`Noto Serif JP`,\"noto sans cjk kr\":`Noto Sans KR`,\"noto serif cjk kr\":`Noto Serif KR`,\"noto sans cjk hk\":`Noto Sans HK`};function l(e){return e?c[e.trim().toLowerCase()]??null:null}function u(e){if(!e)return null;let t=l(e)??e.trim(),n=t.toLowerCase(),r=n.match(/^noto\\s+(?:sans|serif)\\s+(?:cjk\\s+)?(sc|tc|hk|jp|kr)$/);return r?r[1]:/[ᄀ-ᇿ-가-]/.test(t)?`kr`:/[-ヿ]/.test(t)?`jp`:/jhenghei|微軟正黑|新細明|細明|pmingliu|mingliu|dfkai|標楷|華康|cns11643|kaiti tc|ming\\s*liu/.test(n)||/新細明體|細明體|標楷體|微軟正黑體|華康/.test(t)?`tc`:/simsun|nsimsun|simhei|simkai|simfang|yahei|dengxian|fangsong|kaiti|youyuan|lisu|stsong|stkaiti|stfangsong|stheiti|stxihei|stzhongsong|songti sc|heiti sc|微软雅黑/.test(n)||/宋体|黑体|楷体|仿宋|等线|微软雅黑|隶书|幼圆/.test(t)?`sc`:/malgun|batang|gulim|dotum|gungsuh|nanum|new gulim|hancom|hy(gothic|graphic|namu)?/.test(n)?`kr`:/\\bmeiryo\\b|\\byu\\s*(gothic|mincho)\\b|yugothic|yumincho|hiragino|\\bms\\s*(gothic|mincho|pgothic|pmincho|ui\\s*gothic)\\b|\\bms[pg]?(gothic|mincho)\\b|ipa(ex)?(gothic|mincho)|noto\\s+(sans|serif)\\s+jp|游ゴシック|游明朝|MS|メイリオ|ヒラギノ/.test(n)||/游ゴシック|游明朝|MS ゴシック|MS 明朝|MS Pゴシック|メイリオ|ヒラギノ/.test(t)?`jp`:null}const d=e=>`https://fonts.googleapis.com/css2?family=${e}:wght@400;700&display=swap`,f={\"noto sans kr\":{url:d(`Noto+Sans+KR`)},\"noto sans sc\":{url:d(`Noto+Sans+SC`)},\"noto sans tc\":{url:d(`Noto+Sans+TC`)},\"noto sans hk\":{url:d(`Noto+Sans+HK`)},\"noto sans jp\":{url:d(`Noto+Sans+JP`)},\"noto serif kr\":{url:d(`Noto+Serif+KR`)},\"noto serif sc\":{url:d(`Noto+Serif+SC`)},\"noto serif tc\":{url:d(`Noto+Serif+TC`)},\"noto serif jp\":{url:d(`Noto+Serif+JP`)}},p=Object.fromEntries(Object.entries(c).map(([e,t])=>[e,{...f[t.toLowerCase()],loadFamily:t}])),ee={...f,...p,\"noto sans\":{url:d(`Noto+Sans`)},\"noto serif\":{url:d(`Noto+Serif`)},\"noto sans devanagari\":{url:d(`Noto+Sans+Devanagari`)},\"noto sans thai\":{url:d(`Noto+Sans+Thai`)},\"noto sans hebrew\":{url:d(`Noto+Sans+Hebrew`)},\"noto serif hebrew\":{url:d(`Noto+Serif+Hebrew`)}};var te=class e{hasHan=!1;hasHangul=!1;hasKana=!1;hasArabic=!1;hasThai=!1;hasHebrew=!1;hasDevanagari=!1;hasCyrGreek=!1;constructor(e){this.cjkLang=e}clone(){let t=new e(this.cjkLang);return t.hasHan=this.hasHan,t.hasHangul=this.hasHangul,t.hasKana=this.hasKana,t.hasArabic=this.hasArabic,t.hasThai=this.hasThai,t.hasHebrew=this.hasHebrew,t.hasDevanagari=this.hasDevanagari,t.hasCyrGreek=this.hasCyrGreek,t}addText(e){let t=()=>this.hasHan&&this.hasHangul&&this.hasKana&&this.hasArabic&&this.hasThai&&this.hasHebrew&&this.hasDevanagari&&this.hasCyrGreek;outer:for(let n of e)if(n)for(let e of n){let n=e.codePointAt(0);if(n!==void 0&&!(n<=591)&&(n>=4352&&n<=4607||n>=12592&&n<=12687||n>=44032&&n<=55215?this.hasHangul=!0:n>=12352&&n<=12543?this.hasKana=!0:n>=13312&&n<=19903||n>=19968&&n<=40959||n>=63744&&n<=64255||n>=131072&&n<=195103?this.hasHan=!0:n>=1536&&n<=1791||n>=1872&&n<=1919||n>=2208&&n<=2303||n>=64336&&n<=65023||n>=65136&&n<=65279?this.hasArabic=!0:n>=3584&&n<=3711?this.hasThai=!0:n>=1424&&n<=1535||n>=64285&&n<=64335?this.hasHebrew=!0:n>=2304&&n<=2431?this.hasDevanagari=!0:(n>=1024&&n<=1279||n>=880&&n<=1023)&&(this.hasCyrGreek=!0),t()))break outer}}names(){let e=[],t=new Set;this.hasHangul&&t.add(`kr`),this.hasKana&&t.add(`jp`),this.hasHan&&t.size===0&&t.add(this.cjkLang??`jp`);for(let n of[`kr`,`sc`,`tc`,`hk`,`jp`])if(t.has(n)){let t={kr:`KR`,sc:`SC`,tc:`TC`,hk:`HK`,jp:`JP`}[n];e.push(`Noto Sans ${t}`),n!==`hk`&&e.push(`Noto Serif ${t}`)}return this.hasCyrGreek&&e.push(`Noto Sans`,`Noto Serif`),this.hasArabic&&e.push(`Noto Naskh Arabic`,`Noto Sans Arabic`),this.hasThai&&e.push(`Noto Sans Thai`),this.hasHebrew&&e.push(`Noto Sans Hebrew`,`Noto Serif Hebrew`),this.hasDevanagari&&e.push(`Noto Sans Devanagari`),e}};function ne(e){return e===`image-dimension`||e===`image-pixels`||e===`active-decoded-bytes`}function re(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ie(e){if(!(!e||typeof e!=`object`))try{let t=e,n=t.code,r=t.metric,i=t.limit,a=t.observed;return n!==`ooxml-decoded-image-limit`||!ne(r)||!re(i)||!re(a)||a<=i?void 0:{metric:r,limit:i,observed:a}}catch{return}}var ae,oe,m,se=e((()=>{ae=1<<25,oe=1<<27,ae*4,oe*4,m=class e extends RangeError{code=`ooxml-decoded-image-limit`;constructor(t,n,r){super(`OOXML decoded image limit exceeded: ${t} ${r} > ${n}`),this.metric=t,this.limit=n,this.observed=r,this.name=`OoxmlDecodedImageLimitError`,Object.setPrototypeOf(this,e.prototype)}}}));function ce(e){if(!(typeof e!=`object`||!e))try{let t=e,n=t.code,r=t.message;return n===`ooxml-tiff-decode`&&typeof r==`string`?{message:r}:void 0}catch{return}}var le,ue=e((()=>{le=class e extends Error{code=`ooxml-tiff-decode`;constructor(t,n){super(t,n),this.name=`TiffDecodeError`,Object.setPrototypeOf(this,e.prototype)}}}));function de(e){if(!e.startsWith(`data:`))return null;let t=e.indexOf(`,`);if(t===-1)return null;let n=atob(e.slice(t+1)),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}var fe=class{state=`uninitialized`;generationValue=0;readiness;poisonListeners=new Set;constructor(e,t,n){this.initialize=e,this.reinitialize=t,this.normalizeFailure=n}get generation(){return this.generationValue}get poisoned(){return this.state===`poisoned`}onPoison(e){return this.poisonListeners.add(e),()=>this.poisonListeners.delete(e)}async ensureReady(){if(this.state!==`ready`){if(!this.readiness){let e=this.state===`uninitialized`?this.initialize:this.reinitialize;this.readiness=Promise.resolve().then(e).then(()=>{this.generationValue+=1,this.state=`ready`,this.readiness=void 0},e=>{throw this.readiness=void 0,e})}await this.readiness}}run(e){try{return e()}catch(e){let t=this.normalizeFailure(e);throw t?(this.poison(t),t):e}}tryRunReady(e){if(this.state!==`ready`)return{current:!1};let t=this.generationValue,n=this.run(e);return this.state!==`ready`||t!==this.generationValue?{current:!1}:{current:!0,generation:t,value:n}}poison(e){this.state=`poisoned`,this.readiness=void 0;for(let t of this.poisonListeners)t(e)}assertCurrent(e){if(this.state!==`ready`||e!==this.generationValue)throw Error(`WASM archive session belongs to a discarded runtime generation`)}},h=class e extends Error{code=`parser-crashed`;constructor(t){super(t),this.name=`WasmTrapError`,Object.setPrototypeOf(this,e.prototype)}};function pe(e){let t=globalThis.WebAssembly?.RuntimeError;return t&&e instanceof t||e instanceof RangeError?!0:e instanceof Error?e.name===`RuntimeError`||e.name===`CompileError`||e.name===`LinkError`||e.name===`InternalError`||e.name===`OOMError`:!1}function me(e){try{if((typeof e!=`object`||!e)&&typeof e!=`function`)return;let t=Reflect.get(e,`__destroy_into_raw`);typeof t==`function`&&Reflect.apply(t,e,[])}catch{}}function he(e,t){return e({module_or_path:t})}var ge=class{runtime;wasmInput=null;currentArchive=null;constructor(e,t={}){this.init=e,this.options=t,this.runtime=new fe(()=>this.invokeConfigured(this.init),()=>this.invokeConfigured(this.options.reinit??this.init),_e),this.runtime.onPoison(()=>this.dropPoisonedArchive())}setWasmInput(e){this.wasmInput=e,this.runtime.ensureReady().catch(()=>void 0)}setWasmUrl(e){this.setWasmInput(e)}get archive(){return this.currentArchive}setArchive(e){this.freeArchive(),this.currentArchive=e}disposeArchive(){this.freeArchive()}get poisoned(){return this.runtime.poisoned}async ensureReady(){await this.runtime.ensureReady()}run(e){return this.runtime.run(e)}poison(){this.runtime.poison(new h(`WASM parser was recycled`))}invokeConfigured(e){return this.wasmInput===null?Promise.reject(Error(`WasmParserHost: setWasmInput was never called`)):he(e,this.wasmInput)}freeArchive(){this.currentArchive!==null&&this.options.freeArchive&&this.options.freeArchive(this.currentArchive),this.currentArchive=null}dropPoisonedArchive(){let e=this.currentArchive;this.currentArchive=null,me(e)}};function _e(e){return pe(e)?new h(`WASM parser trapped and was recycled: ${e instanceof Error?e.message:String(e)}`):null}function ve(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function ye(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return ve(t.requiredBytes)&&ve(t.offeredBytes)&&t.requiredBytes>t.offeredBytes}var g=class e extends RangeError{code=`ooxml-insufficient-credit`;requiredBytes;offeredBytes;constructor(t){super(`Pull unit requires ${t.requiredBytes} bytes but credit is ${t.offeredBytes}`),this.name=`PullSessionInsufficientCreditError`,this.requiredBytes=t.requiredBytes,this.offeredBytes=t.offeredBytes,Object.setPrototypeOf(this,e.prototype)}};function be(e){if(e instanceof g)return e;let t=e instanceof Error?e.message:String(e);if(!t.startsWith(`OOXML_INSUFFICIENT_CREDIT:`))return;let n;try{n=JSON.parse(t.slice(26))}catch{return}if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n;if(!(r.code!==`ooxml-insufficient-credit`||!ye(r)))return new g(r)}function xe(e,t,n){let r=be(e);if(!(!r||r.offeredBytes!==t||r.requiredBytes>n))return r}se(),ue();const _=`OOXML_RESOURCE_LIMIT:`;function v(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function Se(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return v(t.archiveEntryCount)&&v(t.declaredInflatedBytes)&&(t.largestInflatedEntryBytes===void 0||v(t.largestInflatedEntryBytes))&&v(t.distinctInflatedBytes)&&v(t.operationInflatedBytes)}function y(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch{throw TypeError(`OOXML resource usage checkpoint is not valid JSON`)}if(!Se(t))throw TypeError(`OOXML resource usage checkpoint is invalid`);return t}function Ce(e){return e===`docx`||e===`xlsx`||e===`pptx`}function we(e){return e===`container`||e===`decompression`||e===`parsing`||e===`serialization`||e===`layout`||e===`rendering`||e===`worker`}function b(e,t){return typeof e==`string`&&e.length>0&&e.length<=t&&!/[\\u0000-\\u001f\\u007f]/u.test(e)}function x(e){return b(e,128)&&/^[a-z0-9][a-z0-9-]*$/u.test(e)}function Te(e){return!b(e,4096)||e.startsWith(`/`)||e.startsWith(`\\\\`)||e.includes(`\\\\`)||e.includes(`?`)||e.includes(`#`)||e.includes(`://`)||/^[a-z]:/iu.test(e)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`)}const S=new Map([[`archive-entry:declared-inflated-bytes`,{stage:`container`,part:`required`}],[`archive-entry:actual-inflated-bytes`,{stage:`decompression`,part:`required`}],[`archive:entry-count`,{stage:`container`,part:`forbidden`}],[`archive:central-directory-bytes`,{stage:`container`,part:`forbidden`,configurable:!1}],[`archive:distinct-inflated-bytes`,{stage:`decompression`,part:`required`}],[`xml-event:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-context:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-tree:depth`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-row:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-shell:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}]]),Ee=new Set([...S.keys()].map(e=>e.slice(0,e.indexOf(`:`)))),De=new Set([...S.keys()].map(e=>e.slice(e.indexOf(`:`)+1)));function Oe(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return!Ce(t.format)||!b(t.operation,256)||!x(t.resource)||!x(t.metric)||!v(t.limit)||!v(t.observed)||typeof t.configurable!=`boolean`||!Se(t.usage)?!1:!(`part`in t)||Te(t.part)}function C(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(!we(t.stage)||!Oe(t.violation))return!1;let n=t.violation,r=S.get(`${n.resource}:${n.metric}`);return r?t.stage!==r.stage||r.configurable===!1&&n.configurable!==!1?!1:r.part===`required`?n.part!==void 0:r.part===`forbidden`?n.part===void 0:!0:!(Ee.has(n.resource)&&De.has(n.metric))}function ke(e){return{archiveEntryCount:e.archiveEntryCount,declaredInflatedBytes:e.declaredInflatedBytes,...e.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:e.largestInflatedEntryBytes},distinctInflatedBytes:e.distinctInflatedBytes,operationInflatedBytes:e.operationInflatedBytes}}function Ae(e){if(!C(e))return;let t=e.violation,n={stage:e.stage,violation:{format:t.format,operation:t.operation,resource:t.resource,metric:t.metric,...t.part===void 0?{}:{part:t.part},limit:t.limit,observed:t.observed,configurable:t.configurable,usage:ke(t.usage)}};return C(n)?n:void 0}function je(e){let t=e.violation;return`OOXML resource limit exceeded${t.part?` for ${t.part}`:``}: ${t.metric} ${t.observed} > ${t.limit}`}function Me(e){let t=e instanceof Error?e.message:String(e);if(!t.startsWith(_))return;let r;try{r=JSON.parse(t.slice(21))}catch{return}if(!r||typeof r!=`object`)return;let i=r;if(!(i.code!==`ooxml-resource-limit`||!C(i.details)))return new n(je(i.details),i.details)}function Ne(e){let r=ie(e);if(r){let e=new m(r.metric,r.limit,r.observed);return{message:e.message,errorName:e.name,code:e.code,decodedImage:r}}let i=ce(e);if(i)return{message:i.message,errorName:`TiffDecodeError`,code:`ooxml-tiff-decode`};let a=be(e);if(a)return{message:a.message,errorName:a.name,code:a.code,insufficientCredit:{requiredBytes:a.requiredBytes,offeredBytes:a.offeredBytes}};let o=e instanceof t||e instanceof n?e:Me(e);if(o instanceof n){let e=Ae(o.details);return e?{message:typeof o.message==`string`?o.message:je(e),errorName:`OoxmlResourceLimitError`,code:`ooxml-resource-limit`,resourceLimit:e}:{message:`Invalid OOXML resource-limit error payload`,errorName:`Error`}}if(o instanceof t)return{message:typeof o.message==`string`?o.message:String(o.message),errorName:b(o.name,128)?o.name:`OoxmlError`,...x(o.code)?{code:o.code}:{}};let s=e instanceof Error?e.message:String(e);if(typeof s==`string`&&s.startsWith(_))return{message:`Invalid OOXML resource-limit payload`,errorName:`Error`};let c=e instanceof Error?e:Error(s),l=c;return{message:typeof c.message==`string`?c.message:String(c.message),errorName:b(c.name,128)?c.name:`Error`,...typeof l.code==`string`?{code:l.code}:{}}}function w(e){try{return Ne(e)}catch{return{message:`Worker operation failed with an unreadable error`,errorName:`Error`}}}const Pe=new Set([`encrypted`,`invalid-password`,`unsupported-encryption`,`legacy-binary-format`,`not-ooxml`]),Fe={\"image-dimension\":!0,\"image-pixels\":!0,\"active-decoded-bytes\":!0};function Ie(e){return typeof e==`string`&&Object.prototype.hasOwnProperty.call(Fe,e)}function Le(e,t){if(e!==`ooxml-decoded-image-limit`||!t||typeof t!=`object`)return;let n=t,r=n.metric,i=n.limit,a=n.observed;if(!(!Ie(r)||!v(i)||!v(a)||a<=i))return{metric:r,limit:i,observed:a}}function Re(e){let r=e.message,i=e.errorName,a=e.code,o=e.decodedImage,s=e.insufficientCredit,c=e.resourceLimit,l=typeof r==`string`?r:`Worker operation failed with an invalid error payload`,u=b(i,128)?i:void 0,d=typeof a==`string`?a:void 0,f=Le(d,o);if(f)return new m(f.metric,f.limit,f.observed);if(d===`ooxml-tiff-decode`)return new le(l);if(d===`ooxml-insufficient-credit`&&ye(s))return new g(s);if(d===`ooxml-resource-limit`&&C(c))return new n(l,c);if(d&&Pe.has(d))return new t(d,l);let p=u===`TypeError`?TypeError(l):u===`RangeError`?RangeError(l):Error(l);return u&&(p.name=u),d!==void 0&&Object.assign(p,{code:d}),p}function ze(e){try{return Re(e)}catch{return Error(`Worker operation failed with an unreadable error payload`)}}function Be(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&e.buffer instanceof ArrayBuffer?e.buffer:e.slice().buffer}Object.freeze({maxArchiveEntryBytes:134217728,maxTotalInflatedBytes:268435456,maxArchiveEntries:4096});function Ve(e){return[e.maxArchiveEntryBytes===null?0n:BigInt(e.maxArchiveEntryBytes),e.maxTotalInflatedBytes===null?0n:BigInt(e.maxTotalInflatedBytes),e.maxArchiveEntries===null?0n:BigInt(e.maxArchiveEntries)]}const T=`ooxml-pull-v1`;function E(e,t){if(!Number.isSafeInteger(e)||e<=0)throw RangeError(`${t} must be a positive safe integer`)}function He(e){if(!(typeof e==`string`&&e.length>0||typeof e==`number`&&Number.isSafeInteger(e)&&e>0))throw RangeError(`session id must be a non-empty string or positive safe integer`)}var Ue=class{owner;queue=Promise.resolve();leases=new Map;retainedBytes=0;retainedCount=0;maxRetainedBytes;maxRetainedCount;cleanups=new Set;pendingFatalCleanups=[];poisonRunning=!1;fatal;constructor(e){this.maxRetainedBytes=e?.maxRetainedBytes??64*1024*1024,this.maxRetainedCount=e?.maxRetainedCount??256,E(this.maxRetainedBytes,`max retained lease bytes`),E(this.maxRetainedCount,`max retained lease count`)}enqueue(e){let t=this.queue.then(e,e);return this.queue=t.then(()=>void 0,()=>void 0),t}acquire(e){return this.owner===void 0?(this.owner=e,!0):this.owner===e}release(e){this.owner===e&&(this.owner=void 0)}retainLease(e,t,n){if(!Number.isSafeInteger(n)||n<0)throw RangeError(`retained lease bytes are invalid`);let r=this.leases.get(e)??new Map;if(r.has(t))throw Error(`driver returned a duplicate lease id`);if(this.retainedCount+1>this.maxRetainedCount)throw RangeError(`retained lease count exceeds limit`);if(this.retainedBytes+n>this.maxRetainedBytes)throw RangeError(`retained lease bytes exceed limit`);r.set(t,n),this.leases.set(e,r),this.retainedCount++,this.retainedBytes+=n}releaseLease(e,t){let n=this.leases.get(e),r=n?.get(t);r!==void 0&&(n?.delete(t),n?.size===0&&this.leases.delete(e),this.retainedCount--,this.retainedBytes-=r)}registerCleanup(e){return this.fatal?(this.poisonRunning?this.pendingFatalCleanups.push(e):this.enqueue(e).catch(()=>void 0),()=>void 0):(this.cleanups.add(e),()=>this.cleanups.delete(e))}get fatalError(){return this.fatal}get registeredHostCount(){return this.cleanups.size}async poison(e){if(this.fatal??=e,this.poisonRunning)return this.fatal;this.poisonRunning=!0,this.pendingFatalCleanups.push(...this.cleanups);try{let e;for(;(e=this.pendingFatalCleanups.shift())!==void 0;)await e().catch(()=>void 0)}finally{this.poisonRunning=!1}return this.fatal}},We=class{options;coordinator;coordinatorOwner=Symbol(`pull-session-host`);unregisterCleanup;sequence=0;unacked;leases=new Map;activeDriverLeases=new Set;nextWireLeaseId;cancelRequested=!1;cancelComplete=!1;closeRequested=!1;closeComplete=!1;driverCancelComplete=!1;driverCloseComplete=!1;completed=!1;constructor(e){He(e.sessionId),E(e.operationId,`operation id`),E(e.generation,`generation`),E(e.maxByteCredit,`max byte credit`),e.wireLeaseIdStart!==void 0&&E(e.wireLeaseIdStart,`wire lease id start`),this.options=e,this.coordinator=e.coordinator,this.nextWireLeaseId=e.wireLeaseIdStart??1,this.unregisterCleanup=this.coordinator.registerCleanup(()=>this.forceFatalCleanup())}dispatch(e,t){return this.coordinator.enqueue(async()=>{let n=await this.execute(e);try{t(n.response,n.transfer)}catch(e){throw await this.rollbackFailedPost(n),e}})}async rollbackFailedPost(e){let t=e.response;if(t.kind===`chunk`){let n=t.leaseId===void 0?void 0:this.leases.get(t.leaseId);try{await this.options.driver.disposeInvalidChunk?.({payload:t.payload,byteLength:t.byteLength,done:t.done,leaseId:n?.driverLeaseId,retainedBytes:n?.retainedBytes,transfer:e.transfer})}catch{}}this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);for(let[e,t]of[...this.leases])try{await this.options.driver.releaseLease?.(t.driverLeaseId)}catch{}finally{this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e)}if(this.cancelRequested=!0,!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch{}this.unregisterCleanup()}async execute(e){try{if(this.isStaleLifecycle(e)){let t=e.kind===`cancel`?`cancel`:`close`;return this.sameOperationIdentity(e)?{response:this.accepted(e,t,!0)}:{response:this.errorResponse(e,{message:`stale lifecycle targets another session or operation`,errorName:`PullSessionProtocolError`,code:`ooxml-stale-lifecycle`})}}this.validateCommandIdentity(e);let t=this.coordinator.fatalError;if(t)return e.kind===`pull`?{response:this.errorResponse(e,t)}:(e.kind===`cancel`?await this.cancel():e.kind===`close`?await this.close():e.kind===`release`&&await this.release(e.leaseId),{response:this.accepted(e,e.kind)});switch(e.kind){case`pull`:return await this.pull(e);case`ack`:return await this.ack(e.sequence),{response:this.accepted(e,`ack`)};case`release`:return await this.release(e.leaseId),{response:this.accepted(e,`release`)};case`cancel`:return await this.cancel(),{response:this.accepted(e,`cancel`)};case`close`:return await this.close(),{response:this.accepted(e,`close`)}}}catch(t){let n=w(t);return n.code===`ooxml-resource-limit`&&(n=await this.coordinator.poison(n)),{response:this.errorResponse(e,n)}}}async pull(e){if(this.closeRequested||this.cancelRequested||this.completed)throw Error(`pull session is closed`);if(this.unacked)throw Error(`previous chunk is not acknowledged`);if(!Number.isSafeInteger(e.sequence)||e.sequence<0||e.sequence!==this.sequence)throw Error(`pull command sequence mismatch`);if(this.validateHostCredit(e.byteCredit),!this.coordinator.acquire(this.coordinatorOwner))throw Error(`another operation has an unacknowledged package chunk`);let t;try{t=await this.options.driver.pull(e.byteCredit)}catch(e){throw this.coordinator.release(this.coordinatorOwner),e}let n=!1,r=!1,i,a;try{let o=this.options.driver.measureChunk(t),s=this.arrayBufferTransferBytes(t.transfer);if(o<s)throw RangeError(`measured chunk bytes are below ArrayBuffer transfer bytes`);if(a=Math.max(o,s),t.leaseId!==void 0){if(E(t.leaseId,`lease id`),t.retainedBytes===void 0)throw Error(`retained lease bytes are required`);if(this.activeDriverLeases.has(t.leaseId))throw r=!0,Error(`driver returned an active duplicate lease id`);i=this.allocateWireLeaseId(),this.coordinator.retainLease(this.coordinatorOwner,i,t.retainedBytes),this.leases.set(i,{driverLeaseId:t.leaseId,retainedBytes:t.retainedBytes}),this.activeDriverLeases.add(t.leaseId),n=!0}else if(t.retainedBytes!==void 0)throw Error(`retained lease bytes require a lease id`);if(!Number.isSafeInteger(a)||a<0)throw RangeError(`host chunk byte length must be a non-negative safe integer`);if(a>e.byteCredit)throw RangeError(`host chunk exceeds byte credit`)}catch(e){let a;try{await this.options.driver.disposeInvalidChunk?.(t)}catch(e){a=e}if(n&&i!==void 0)try{await this.release(i)}catch(e){a??=e}else if(t.leaseId!==void 0&&!r)try{await this.options.driver.releaseLease?.(t.leaseId)}catch(e){a??=e}if(r)try{await this.cancel()}catch(e){a??=e}throw this.coordinator.release(this.coordinatorOwner),a||e}return this.unacked={sequence:this.sequence,done:t.done},{response:{kind:`chunk`,protocol:T,...this.identity(),requestId:e.requestId,sequence:this.sequence,byteLength:a,done:t.done,payload:t.payload,leaseId:i,usage:this.resourceUsage()},transfer:t.transfer}}async ack(e){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`invalid ack sequence`);if(e<this.sequence)return;if(!this.unacked||e!==this.sequence)throw Error(`ack sequence mismatch`);let t=this.unacked.done;await this.options.driver.acknowledge?.(e),this.unacked=void 0,this.coordinator.release(this.coordinatorOwner),this.sequence++,t&&(this.completed=!0,this.maybeUnregisterCompleted())}async release(e){E(e,`wire lease id`);let t=this.leases.get(e);t&&(await this.options.driver.releaseLease?.(t.driverLeaseId),this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e),this.maybeUnregisterCompleted())}async cancel(){if(this.cancelComplete)return;this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.cancelComplete=!0,this.unregisterCleanup()}async close(){if(this.closeComplete)return;this.closeRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCloseComplete)try{await this.options.driver.close?.(),this.driverCloseComplete=!0}catch(t){e??=t}if(e)throw e;this.closeComplete=!0,this.unregisterCleanup()}async releaseAllLeases(){let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(e)throw e}validateCommandIdentity(e){if(e.protocol!==`ooxml-pull-v1`||e.sessionId!==this.options.sessionId||e.operationId!==this.options.operationId||e.generation!==this.options.generation||!Number.isSafeInteger(e.requestId)||e.requestId<=0)throw Error(`stale or mismatched pull session command`)}validateHostCredit(e){if(E(e,`byte credit`),e>this.options.maxByteCredit)throw RangeError(`byte credit exceeds host maximum`)}accepted(e,t,n=!1){return{kind:`accepted`,protocol:T,...n?{sessionId:e.sessionId,operationId:e.operationId,generation:e.generation}:this.identity(),requestId:e.requestId,command:t,usage:this.resourceUsage()}}identity(){return{sessionId:this.options.sessionId,operationId:this.options.operationId,generation:this.options.generation}}isStaleLifecycle(e){return(e.kind===`cancel`||e.kind===`close`)&&e.protocol===`ooxml-pull-v1`&&Number.isSafeInteger(e.requestId)&&e.requestId>0&&Number.isSafeInteger(e.generation)&&e.generation>0&&e.generation<this.options.generation}sameOperationIdentity(e){return e.sessionId===this.options.sessionId&&e.operationId===this.options.operationId}errorResponse(e,t){return{kind:`error`,protocol:T,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:t,usage:this.errorResourceUsage()}}async forceFatalCleanup(){this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.unregisterCleanup()}allocateWireLeaseId(){if(!Number.isSafeInteger(this.nextWireLeaseId)||this.nextWireLeaseId<=0)throw RangeError(`wire lease id space exhausted`);return this.nextWireLeaseId++}arrayBufferTransferBytes(e){let t=0;for(let n of e??[])if(n instanceof ArrayBuffer&&(t+=n.byteLength,!Number.isSafeInteger(t)))throw RangeError(`ArrayBuffer transfer bytes overflow`);return t}maybeUnregisterCompleted(){this.completed&&this.leases.size===0&&this.unregisterCleanup()}resourceUsage(){return this.options.driver.resourceUsage?.()}errorResourceUsage(){try{return this.resourceUsage()}catch{return}}};function D(e,t){if(!Number.isSafeInteger(e)||e<0)throw Error(`${t} must be a non-negative safe integer`)}function O(e,t,n){return D(e,`resource measurement`),D(t,`resource measurement`),D(n,`resource measurement limit`),e>n||t>n||t>n-e?n===2**53-1?n:n+1:e+t}function Ge(e,t=2**53-1){D(t,`resource measurement limit`);let n=0;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r),a;if(i<=127)a=1;else if(i<=2047)a=2;else if(i>=55296&&i<=56319&&r+1<e.length){let t=e.charCodeAt(r+1);t>=56320&&t<=57343?(a=4,r+=1):a=3}else a=3;if(n=O(n,a,t),n>t)return n}return n}function Ke(e,t=2**53-1){D(t,`resource measurement limit`);let n=O(0,2,t);if(n>t)return n;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r),a;if(i===34||i===92||i===8||i===9||i===10||i===12||i===13)a=2;else if(i<=31)a=6;else if(i<=127)a=1;else if(i<=2047)a=2;else if(i>=55296&&i<=56319&&r+1<e.length){let t=e.charCodeAt(r+1);t>=56320&&t<=57343?(a=4,r+=1):a=6}else a=i>=55296&&i<=57343?6:3;if(n=O(n,a,t),n>t)return n}return n}function k(e,t){return O(0,e,t)}function A(e,t=2**53-1,n=!1){if(D(t,`resource measurement limit`),e===null)return{jsonBytes:k(4,t),stringValueUtf8Bytes:0};if(typeof e==`string`)return{jsonBytes:Ke(e,t),stringValueUtf8Bytes:Ge(e,t)};if(typeof e==`boolean`)return{jsonBytes:k(e?4:5,t),stringValueUtf8Bytes:0};if(typeof e==`number`)return{jsonBytes:k((Number.isFinite(e)?String(Object.is(e,-0)?0:e):`null`).length,t),stringValueUtf8Bytes:0};if(typeof e==`bigint`)throw TypeError(`BigInt values cannot be serialized to JSON`);if(Array.isArray(e)){let n=k(2,t),r=0;for(let i=0;i<e.length;i+=1){i!==0&&(n=O(n,1,t));let a=A(e[i],t,!0);n=O(n,a.jsonBytes,t),r=O(r,a.stringValueUtf8Bytes,t)}return{jsonBytes:n,stringValueUtf8Bytes:r}}if(typeof e==`object`){let n=k(2,t),r=0,i=0;for(let[a,o]of Object.entries(e)){if(o===void 0||typeof o==`function`||typeof o==`symbol`)continue;i++!==0&&(n=O(n,1,t)),n=O(n,Ke(a,t),t),n=O(n,1,t);let e=A(o,t);n=O(n,e.jsonBytes,t),r=O(r,e.stringValueUtf8Bytes,t)}return{jsonBytes:n,stringValueUtf8Bytes:r}}return{jsonBytes:n?k(4,t):0,stringValueUtf8Bytes:0}}({...s,...ee});function*j(e){for(let t of e?.paragraphs??[])for(let e of t.runs)e.type===`text`&&(yield e.text)}function*qe(e){for(let t of e?.paragraphs??[]){t.defFontFamily&&(yield t.defFontFamily);for(let e of t.runs)e.type===`text`&&(e.fontFamily&&(yield e.fontFamily),e.fontFamilyEa&&(yield e.fontFamilyEa),e.fontFamilySym&&(yield e.fontFamilySym))}}function*Je(e){for(let t of e.elements)if(t.type===`shape`)yield*j(t.textBody);else if(t.type===`table`)for(let e of t.rows)for(let t of e.cells)yield*j(t.textBody);else if(t.type===`chart`){t.chart.title&&(yield t.chart.title);for(let e of t.chart.categories)yield e;for(let e of t.chart.series)e.name&&(yield e.name)}}var Ye=class e{scripts;families;constructor(e,t,n,r){this.majorFont=e,this.minorFont=t;let i=u(e)??u(t)??null;this.scripts=n??new te(i),this.families=r??new Set,e&&this.families.add(e),t&&this.families.add(t)}addSlide(e){this.scripts.addText(Je(e));for(let t of e.elements)if(t.type===`shape`)for(let e of qe(t.textBody))this.families.add(e);else if(t.type===`table`)for(let e of t.rows)for(let t of e.cells)for(let e of qe(t.textBody))this.families.add(e)}names(){return[...this.families,...this.scripts.names()]}withSlide(t){let n=new e(this.majorFont,this.minorFont,this.scripts.clone(),new Set(this.families));return n.addSlide(t),n}};const M=Object.freeze({archiveEntryCount:0,declaredInflatedBytes:0,distinctInflatedBytes:0,operationInflatedBytes:0}),Xe=67108864;function N(e,t){if(e!==null&&typeof e!=`string`)throw Error(`invalid PPTX presentation bootstrap ${t}`)}function Ze(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`invalid PPTX presentation bootstrap slide at ${t}`);let n=e;if(n.index!==t)throw Error(`invalid PPTX presentation bootstrap slide index ${n.index}`);if(n.partName!==void 0&&typeof n.partName!=`string`)throw Error(`invalid PPTX presentation bootstrap slide partName at ${t}`);return Object.freeze({index:n.index,...n.partName===void 0?{}:{partName:n.partName}})}function Qe(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`invalid PPTX presentation bootstrap embedded font at ${t}`);let n=e;if(typeof n.fontName!=`string`||n.fontName.length===0||![`regular`,`bold`,`italic`,`boldItalic`].includes(n.style??``)||typeof n.partPath!=`string`||n.partPath.length===0||n.partPath.startsWith(`/`)||n.partPath.split(`/`).includes(`..`)||![`application/x-font-ttf`,`application/x-fontdata`].includes(n.contentType??``))throw Error(`invalid PPTX presentation bootstrap embedded font fields at ${t}`);return Object.freeze({fontName:n.fontName,style:n.style,partPath:n.partPath,contentType:n.contentType})}function $e(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`invalid PPTX presentation bootstrap payload`);let t=e;if(!Number.isSafeInteger(t.slideCount)||(t.slideCount??-1)<0||!Number.isSafeInteger(t.slideWidth)||(t.slideWidth??0)<=0||!Number.isSafeInteger(t.slideHeight)||(t.slideHeight??0)<=0||!Array.isArray(t.embeddedFonts)||!Array.isArray(t.slides)||t.slides.length!==t.slideCount)throw Error(`invalid PPTX presentation bootstrap dimensions or slide count`);return N(t.defaultTextColor,`defaultTextColor`),N(t.majorFont,`majorFont`),N(t.minorFont,`minorFont`),N(t.hlinkColor,`hlinkColor`),N(t.folHlinkColor,`folHlinkColor`),Object.freeze({slideCount:t.slideCount,slideWidth:t.slideWidth,slideHeight:t.slideHeight,defaultTextColor:t.defaultTextColor,majorFont:t.majorFont,minorFont:t.minorFont,hlinkColor:t.hlinkColor,folHlinkColor:t.folHlinkColor,embeddedFonts:Object.freeze(t.embeddedFonts.map(Qe)),slides:Object.freeze(t.slides.map(Ze))})}function et(e){return Object.freeze({type:`media`,x:e.x,y:e.y,width:e.width,height:e.height,rotation:e.rotation,flipH:e.flipH,flipV:e.flipV,mediaKind:e.mediaKind,posterPath:e.posterPath,posterMimeType:e.posterMimeType,mediaPath:e.mediaPath,mimeType:e.mimeType})}function tt(e){return Object.freeze({...e.id===void 0?{}:{id:e.id},...e.authorId===void 0?{}:{authorId:e.authorId},...e.author===void 0?{}:{author:e.author},...e.date===void 0?{}:{date:e.date},...e.status===void 0?{}:{status:e.status},text:e.text})}function nt(e){return Object.freeze({...e})}function rt(e){return Object.freeze({...e.authorId===void 0?{}:{authorId:e.authorId},...e.modernAuthorId===void 0?{}:{modernAuthorId:e.modernAuthorId},...e.id===void 0?{}:{id:e.id},...e.index===void 0?{}:{index:e.index},...e.author===void 0?{}:{author:e.author},...e.date===void 0?{}:{date:e.date},...e.x===void 0?{}:{x:e.x},...e.y===void 0?{}:{y:e.y},...e.anchors?.length?{anchors:Object.freeze(e.anchors.map(nt))}:{},...e.status===void 0?{}:{status:e.status},text:e.text,...e.replies?.length?{replies:Object.freeze(e.replies.map(tt))}:{}})}function it(e,t){if(e.index!==t.index||e.partName!==t.partName)throw Error(`PPTX pulled slide identity does not match bootstrap index ${t.index}`);return Object.freeze({index:t.index,...t.partName===void 0?{}:{partName:t.partName},notes:e.notes??null,hidden:e.hidden??!1,mediaElements:Object.freeze(e.elements.filter(e=>e.type===`media`).map(et)),...e.comments?.length?{comments:Object.freeze(e.comments.map(rt))}:{}})}function at(e,t,r){if(!(e<=t))throw new n(`PPTX presentation preflight exceeded its hard limit of ${t} projected bytes`,{stage:`parsing`,violation:{format:`pptx`,operation:`presentation-preflight`,resource:`presentation-preflight`,metric:`projected-bytes`,limit:t,observed:Math.min(e,t+1),configurable:!1,usage:r}})}var ot=class{slideCountValue;slideWidthValue;slideHeightValue;defaultTextColorValue;majorFontValue;minorFontValue;hlinkColorValue;folHlinkColorValue;embeddedFontsValue;descriptors;slides=[];fonts;fontPreloadNames;fontProjectionBytes;projectionBytesValue;limit;pending=null;finished=null;constructor(e,t={}){let n=$e(e),r=t.hardLimitForTesting??Xe;if(!Number.isSafeInteger(r)||r<=0||r>Xe)throw Error(`invalid PPTX presentation preflight test limit`);this.limit=r,this.slideCountValue=n.slideCount,this.slideWidthValue=n.slideWidth,this.slideHeightValue=n.slideHeight,this.defaultTextColorValue=n.defaultTextColor,this.majorFontValue=n.majorFont,this.minorFontValue=n.minorFont,this.hlinkColorValue=n.hlinkColor,this.folHlinkColorValue=n.folHlinkColor,this.embeddedFontsValue=n.embeddedFonts,this.descriptors=[...n.slides],this.fonts=new Ye(this.majorFontValue,this.minorFontValue),this.fontPreloadNames=Object.freeze(this.fonts.names()),this.fontProjectionBytes=A(this.fontPreloadNames,this.limit).jsonBytes,this.projectionBytesValue=A({slideCount:this.slideCountValue,slideWidth:this.slideWidthValue,slideHeight:this.slideHeightValue,defaultTextColor:this.defaultTextColorValue,majorFont:this.majorFontValue,minorFont:this.minorFontValue,hlinkColor:this.hlinkColorValue,folHlinkColor:this.folHlinkColorValue,embeddedFonts:this.embeddedFontsValue,remainingSlides:this.descriptors,slides:[],fontPreloadNames:this.fontPreloadNames},this.limit).jsonBytes,at(this.projectionBytesValue,this.limit,M)}get acceptedSlideCount(){return this.finished?.slideCount??this.slides.length}get projectedBytes(){return this.projectionBytesValue}get remainingDescriptorCount(){return this.descriptors.reduce((e,t)=>e+Number(t!==void 0),0)}get latestSlide(){return this.slides[this.slides.length-1]}get currentFontPreloadNames(){return this.fontPreloadNames}snapshot(){if(this.finished)return this.finished;if(this.pending)throw Error(`PPTX presentation preflight has an uncommitted slide`);return Object.freeze({slideCount:this.slideCountValue,slideWidth:this.slideWidthValue,slideHeight:this.slideHeightValue,defaultTextColor:this.defaultTextColorValue,majorFont:this.majorFontValue,minorFont:this.minorFontValue,hlinkColor:this.hlinkColorValue,folHlinkColor:this.folHlinkColorValue,embeddedFonts:this.embeddedFontsValue,slides:Object.freeze([...this.slides]),fontPreloadNames:this.fontPreloadNames})}addSlide(e,t=M){this.prepareSlide(e,t).commit()}prepareSlide(e,t=M){if(this.finished)throw Error(`PPTX presentation preflight is already finished`);if(this.pending)throw Error(`PPTX presentation preflight already has a prepared slide`);let n=this.slides.length,r=this.descriptors[n];if(!r)throw Error(`PPTX presentation preflight received an extra slide`);let i=it(e,r),a=this.fonts.withSlide(e),o=Object.freeze(a.names()),s=A(o,this.limit).jsonBytes,c=A(i,this.limit).jsonBytes,l=this.projectionBytesValue-this.fontProjectionBytes-A(r,this.limit).jsonBytes+4;l=O(l,s,this.limit),l=O(l,c,this.limit),this.slides.length!==0&&(l=O(l,1,this.limit));let u=A({slide:i,fontPreloadNames:o},this.limit).jsonBytes,d=O(this.projectionBytesValue,u,this.limit);at(Math.max(d,l),this.limit,t);let f={state:`prepared`,fact:i,fonts:a,fontNames:o,fontBytes:s,committedBytes:l};return this.pending=f,{projectedBytes:d,commit:()=>{if(f.state!==`committed`){if(f.state===`rolled-back`)throw Error(`PPTX presentation preflight cannot commit a rolled-back slide`);if(this.pending!==f)throw Error(`PPTX presentation preflight prepared slide is stale`);this.descriptors[n]=void 0,this.slides.push(f.fact),this.fonts=f.fonts,this.fontPreloadNames=f.fontNames,this.fontProjectionBytes=f.fontBytes,this.projectionBytesValue=f.committedBytes,f.state=`committed`,this.pending=null}},rollback:()=>{if(f.state!==`rolled-back`){if(f.state===`committed`)throw Error(`PPTX presentation preflight cannot roll back a committed slide`);if(this.pending!==f)throw Error(`PPTX presentation preflight prepared slide is stale`);f.state=`rolled-back`,this.pending=null}}}}finish(){if(this.finished)return this.finished;if(this.pending)throw Error(`PPTX presentation preflight has an uncommitted slide`);if(this.slides.length!==this.slideCountValue)throw Error(`PPTX presentation preflight is incomplete: ${this.slides.length}/${this.slideCountValue} slides`);return this.finished=Object.freeze({slideCount:this.slideCountValue,slideWidth:this.slideWidthValue,slideHeight:this.slideHeightValue,defaultTextColor:this.defaultTextColorValue,majorFont:this.majorFontValue,minorFont:this.minorFontValue,hlinkColor:this.hlinkColorValue,folHlinkColor:this.folHlinkColorValue,embeddedFonts:this.embeddedFontsValue,slides:Object.freeze([...this.slides]),fontPreloadNames:this.fontPreloadNames}),this.descriptors=[],this.slides=[],this.projectionBytesValue=A(this.finished,this.limit).jsonBytes,this.finished}};function st(e){try{return y(e(e=>e.slide_cursor_resource_usage()))}catch(e){if(String(e).includes(`slide cursor usage is unavailable`))return;throw e}}function ct(e,t,n,r,i){let a,o;try{if(i){if(!r)throw Error(`slide payload is missing before acknowledgement`);let t=i(n,r,st(e));typeof t==`function`?a=t:t&&({rollback:a,commit:o}=t)}e(e=>e.acknowledge_slide(t.operationId,t.generation)),o?.()}catch(e){try{a?.()}catch{}throw e}}var lt=class{coordinatorGeneration=new Ue;sessions=new Map;pendingOpens=new Map;operationTail=Promise.resolve();resourceFailure;lifecycleState=`ready`;resetBarrier;resetIdentities=new Map;constructor(e,t,n=e=>e(this.requireArchive())){this.archive=e,this.acceptSlide=t,this.executeArchive=n}get coordinator(){return this.coordinatorGeneration}reserveOpen(e){if(this.assertReady(),dt(e),this.pendingOpens.has(e.sessionId)||this.sessions.has(e.sessionId))throw Error(`slide pull session id is already reserved`);this.pendingOpens.set(e.sessionId,{identity:e,canceled:!1})}abandonOpen(e){this.pendingOpens.delete(e)}get pendingOpenCount(){return this.pendingOpens.size}async open(e,t){if(this.assertReady(),this.resourceFailure)throw this.resourceFailure;if(!Number.isSafeInteger(e)||e<0)throw RangeError(`slide index must be a non-negative safe integer`);let n=this.pendingOpens.get(t.sessionId);if(!n||!P(n.identity,t))throw Error(`slide pull session open reservation is stale or missing`);let i,a=new Promise(e=>{i=e}),o=this.operationTail.then(()=>this.coordinator.enqueue(async()=>{if(n.canceled)throw Error(`slide pull session open was canceled`);let a,o=!1,s=new We({...t,maxByteCredit:r,coordinator:this.coordinator,driver:{pull:n=>{let i;try{i=this.executeArchive(r=>r.pull_slide(e,t.operationId,t.generation,n))}catch(e){throw xe(e,n,r)||(this.latchResourceFailure(e),e)}let s=Be(i);return this.acceptSlide&&(a=JSON.parse(new TextDecoder().decode(new Uint8Array(s)))),o=!0,{payload:s,byteLength:s.byteLength,done:!0,transfer:[s]}},measureChunk:({payload:e})=>e.byteLength,acknowledge:()=>{if(!o)throw Error(`slide unit is not awaiting acknowledgement`);try{ct(this.executeArchive,t,e,a,this.acceptSlide)}catch(e){throw this.latchResourceFailure(e),e}o=!1,a=void 0,this.sessions.delete(t.sessionId),i()},cancel:async()=>{try{this.archive()&&await this.executeArchive(e=>e.cancel_slide())}finally{a=void 0,o=!1,this.sessions.delete(t.sessionId),i()}},close:async()=>{try{this.archive()&&await this.executeArchive(e=>e.cancel_slide())}finally{a=void 0,o=!1,this.sessions.delete(t.sessionId),i()}},resourceUsage:()=>{try{return this.readResourceUsage()}catch(e){throw this.latchResourceFailure(e),e}}}});this.sessions.set(t.sessionId,{host:s,identity:t}),this.pendingOpens.delete(t.sessionId)}));this.operationTail=o.then(()=>a,()=>void 0);try{await o}catch(e){throw this.pendingOpens.delete(t.sessionId),i(),e}}async postOpenedSafely(e,t,n){if(this.lifecycleState!==`ready`){try{n(this.lifecycleError())}catch{}return}try{t()}catch(t){await this.closeIdentity(e);try{n(t)}catch{}}}dispatch(e,t){if(this.lifecycleState!==`ready`)return t(this.responseDuringReset(e)),Promise.resolve();let n=this.sessions.get(e.sessionId);if(n)return n.host.dispatch(e,t);let r=this.pendingOpens.get(e.sessionId);if(r&&(e.kind===`cancel`||e.kind===`close`)){let n=P(r.identity,e);return n&&(r.canceled=!0),t(n?{protocol:T,kind:`accepted`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,command:e.kind}:this.staleLifecycleResponse(e)),Promise.resolve()}return e.kind===`cancel`||e.kind===`close`?(t({protocol:T,kind:`accepted`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,command:e.kind}),Promise.resolve()):(t({protocol:T,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:w(Error(`slide pull session is not open`))}),Promise.resolve())}async dispatchSafely(e,t){try{await this.dispatch(e,t)}catch(n){try{t({protocol:T,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:w(n)})}catch{}}}run(e){if(this.lifecycleState!==`ready`)return Promise.reject(this.lifecycleError());let t=this.operationTail.then(()=>this.coordinator.enqueue(async()=>{if(this.resourceFailure)throw this.resourceFailure;return e()})).catch(e=>{throw this.latchResourceFailure(e),e});return this.operationTail=t.then(()=>void 0,()=>void 0),t}reset(){if(this.resetBarrier)return this.resetBarrier;this.lifecycleState=`resetting`,this.captureResetIdentities();let e=this.performReset().then(()=>{this.resetIdentities.clear(),this.lifecycleState=`ready`},e=>{throw this.lifecycleState=`reset-failed`,e}).finally(()=>{this.resetBarrier===e&&(this.resetBarrier=void 0)});return this.resetBarrier=e,e}async performReset(){for(let e of this.pendingOpens.values())e.canceled=!0;let e=1;for(let{host:t,identity:n}of[...this.sessions.values()]){let r;if(await t.dispatch({protocol:T,kind:`close`,...n,requestId:e++},e=>{e.kind===`error`&&(r=ze(e.error))}),r)throw r}this.sessions.clear(),await this.operationTail,this.pendingOpens.clear(),this.archive()&&await this.executeArchive(e=>e.close_presentation_session()),this.coordinatorGeneration=new Ue,this.resourceFailure=void 0}assertReady(){if(this.lifecycleState!==`ready`)throw this.lifecycleError()}lifecycleError(){let e=this.lifecycleState===`reset-failed`,t=Error(e?`slide pull worker reset failed; retry reset before new work`:`slide pull worker reset is in progress`);return t.name=`PullSessionLifecycleError`,Object.assign(t,{code:e?`ooxml-pull-reset-failed`:`ooxml-pull-resetting`})}captureResetIdentities(){for(let{identity:e}of this.sessions.values())this.resetIdentities.set(e.sessionId,e);for(let{identity:e}of this.pendingOpens.values())this.resetIdentities.set(e.sessionId,e)}responseDuringReset(e){if(e.kind===`cancel`||e.kind===`close`){let t=this.resetIdentities.get(e.sessionId);return t&&!P(t,e)?this.staleLifecycleResponse(e):{protocol:T,kind:`accepted`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,command:e.kind}}return{protocol:T,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:w(this.lifecycleError())}}requireArchive(){let e=this.archive();if(!e)throw Error(`Presentation not loaded`);return e}async closeIdentity(e){if(this.lifecycleState!==`ready`)return;let t=this.sessions.get(e.sessionId);if(t){await t.host.dispatch({protocol:T,kind:`close`,...e,requestId:1},()=>void 0);return}let n=this.pendingOpens.get(e.sessionId);n&&P(n.identity,e)&&(n.canceled=!0)}readResourceUsage(){return st(this.executeArchive)}latchResourceFailure(e){let t=e instanceof n?e:Me(e);t&&(this.resourceFailure??=t)}staleLifecycleResponse(e){return{protocol:T,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:{message:`stale lifecycle targets another slide operation`,errorName:`PullSessionProtocolError`,code:`ooxml-stale-lifecycle`}}}};function ut(e){return!!e&&typeof e==`object`&&e.protocol===`ooxml-pull-v1`}function dt(e){if(!Number.isSafeInteger(e.sessionId)||e.sessionId<=0)throw RangeError(`session id must be a positive safe integer`);if(!Number.isSafeInteger(e.operationId)||e.operationId<=0)throw RangeError(`operation id must be a positive safe integer`);if(!Number.isSafeInteger(e.generation)||e.generation<=0)throw RangeError(`generation must be a positive safe integer`)}function P(e,t){return e.sessionId===t.sessionId&&e.operationId===t.operationId&&e.generation===t.generation}var F=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,pt.unregister(this),e}free(){let e=this.__destroy_into_raw();J.__wbg_pptxarchive_free(e,0)}acknowledge_slide(e,t){let n=J.pptxarchive_acknowledge_slide(this.__wbg_ptr,e,t);if(n[1])throw U(n[0])}assert_healthy(){let e=J.pptxarchive_assert_healthy(this.__wbg_ptr);if(e[1])throw U(e[0])}cancel_slide(){J.pptxarchive_cancel_slide(this.__wbg_ptr)}close_presentation_session(){J.pptxarchive_close_presentation_session(this.__wbg_ptr)}extract_font(e){let t=H(e,J.__wbindgen_malloc,J.__wbindgen_realloc),n=q,r=J.pptxarchive_extract_font(this.__wbg_ptr,t,n);if(r[3])throw U(r[2]);var i=I(r[0],r[1]).slice();return J.__wbindgen_free(r[0],r[1]*1,1),i}extract_image(e){let t=H(e,J.__wbindgen_malloc,J.__wbindgen_realloc),n=q,r=J.pptxarchive_extract_image(this.__wbg_ptr,t,n);if(r[3])throw U(r[2]);var i=I(r[0],r[1]).slice();return J.__wbindgen_free(r[0],r[1]*1,1),i}extract_media(e){let t=H(e,J.__wbindgen_malloc,J.__wbindgen_realloc),n=q,r=J.pptxarchive_extract_media(this.__wbg_ptr,t,n);if(r[3])throw U(r[2]);var i=I(r[0],r[1]).slice();return J.__wbindgen_free(r[0],r[1]*1,1),i}constructor(e,t,n,r){let i=ht(e,J.__wbindgen_malloc),a=q,o=J.pptxarchive_new(i,a,!V(t),V(t)?BigInt(0):t,!V(n),V(n)?BigInt(0):n,!V(r),V(r)?BigInt(0):r);if(o[2])throw U(o[1]);return this.__wbg_ptr=o[0]>>>0,pt.register(this,this.__wbg_ptr,this),this}parse(){let e=J.pptxarchive_parse(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}presentation_bootstrap(){let e=J.pptxarchive_presentation_bootstrap(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}pull_slide(e,t,n,r){let i=J.pptxarchive_pull_slide(this.__wbg_ptr,e,t,n,r);if(i[3])throw U(i[2]);var a=I(i[0],i[1]).slice();return J.__wbindgen_free(i[0],i[1]*1,1),a}resource_usage(){let e=J.pptxarchive_resource_usage(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}slide_cursor_resource_usage(){let e=J.pptxarchive_slide_cursor_resource_usage(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}to_markdown(){let e,t;try{let i=J.pptxarchive_to_markdown(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,U(i[2]);return e=n,t=r,R(n,r)}finally{J.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(F.prototype[Symbol.dispose]=F.prototype.free);function ft(){return{__proto__:null,\"./pptx_parser_bg.js\":{__proto__:null,__wbg___wbindgen_throw_6b64449b9b9ed33c:function(e,t){throw Error(R(e,t))},__wbg_error_a6fa202b58aa1cd3:function(e,t){let n,r;try{n=e,r=t,console.error(R(e,t))}finally{J.__wbindgen_free(n,r,1)}},__wbg_new_227d7c05414eb861:function(){return Error()},__wbg_stack_3b0d974bbf31e44f:function(e,t){let n=t.stack,r=H(n,J.__wbindgen_malloc,J.__wbindgen_realloc),i=q;mt().setInt32(e+4,i,!0),mt().setInt32(e+0,r,!0)},__wbindgen_cast_0000000000000001:function(e,t){return R(e,t)},__wbindgen_init_externref_table:function(){let e=J.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const pt=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>J.__wbg_pptxarchive_free(e>>>0,1));function I(e,t){return e>>>=0,B().subarray(e/1,e/1+t)}let L=null;function mt(){return(L===null||L.buffer.detached===!0||L.buffer.detached===void 0&&L.buffer!==J.memory.buffer)&&(L=new DataView(J.memory.buffer)),L}function R(e,t){return e>>>=0,gt(e,t)}let z=null;function B(){return(z===null||z.byteLength===0)&&(z=new Uint8Array(J.memory.buffer)),z}function V(e){return e==null}function ht(e,t){let n=t(e.length*1,1)>>>0;return B().set(e,n/1),q=e.length,n}function H(e,t,n){if(n===void 0){let n=K.encode(e),r=t(n.length,1)>>>0;return B().subarray(r,r+n.length).set(n),q=n.length,r}let r=e.length,i=t(r,1)>>>0,a=B(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=B().subarray(i+o,i+r),a=K.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return q=o,i}function U(e){let t=J.__wbindgen_externrefs.get(e);return J.__externref_table_dealloc(e),t}let W=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});W.decode();let G=0;function gt(e,t){return G+=t,G>=2146435072&&(W=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),W.decode(),G=t),W.decode(B().subarray(e,e+t))}const K=new TextEncoder;`encodeInto`in K||(K.encodeInto=function(e,t){let n=K.encode(e);return t.set(n),{read:e.length,written:n.length}});let q=0,J;function _t(e,t){return J=e.exports,L=null,z=null,J.__wbindgen_start(),J}async function vt(e,t){if(typeof Response==`function`&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(e.ok&&n(e.type)&&e.headers.get(`Content-Type`)!==`application/wasm`)console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\",t);else throw t}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}function n(e){switch(e){case`basic`:case`cors`:case`default`:return!0}return!1}}async function yt(e){if(J!==void 0)return J;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn(`using deprecated parameters for the initialization function; pass a single object instead`));let t=ft();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await vt(await e,t);return _t(n,r)}async function bt(e){return J=void 0,L=null,z=null,yt(e)}const Y=new ge(yt,{freeArchive:e=>e.free(),reinit:bt});let X=null,Z=`empty`;function xt(){if(Z!==`empty`){let e=Error(`this PPTX worker already owns a presentation parse`);throw e.name=`PptxWorkerStateError`,Object.assign(e,{code:`ooxml-pptx-parse-already-started`})}Z=`opening`}const Q=new lt(()=>Y.archive,(e,t,n)=>{if(X){if(e!==X.acceptedSlideCount)throw Error(`PPTX preflight expected slide ${X.acceptedSlideCount}, received ${e}`);return X.prepareSlide(t,n)}},e=>{let t=Y.archive;if(!t)throw Error(`Presentation not loaded`);return Y.run(()=>e(t))}),$=(e,t)=>self.postMessage(e,t);self.onmessage=async e=>{let t=e.data;if(ut(t)){await Q.dispatchSafely(t,$);return}if(t.kind===`init`){Y.setWasmInput(de(t.wasmUrl)??t.wasmUrl);return}let n=t.id,r=!1;try{if(t.kind===`openSlideSession`&&Q.reserveOpen(t),t.kind===`parse`&&(xt(),r=!0),t.kind===`openSlideSession`){await Y.ensureReady(),await Q.open(t.slideIndex,t),await Q.postOpenedSafely(t,()=>$({kind:`slideSessionOpened`,id:n,sessionId:t.sessionId,operationId:t.operationId,generation:t.generation}),e=>$({kind:`error`,id:n,...w(e)}));return}t.kind===`parse`&&await Q.reset(),await Q.run(async()=>{if(await Y.ensureReady(),t.kind!==`parse`&&Y.archive){let e=Y.archive;Y.run(()=>e.assert_healthy())}if(t.kind===`parse`){X=null;let[e,r,i]=Ve(t.resourcePolicy),a=Y.run(()=>{let n=new F(new Uint8Array(t.buffer),e,r,i);return Y.setArchive(n),JSON.parse(new TextDecoder().decode(n.presentation_bootstrap()))});X=t.progressiveLayout?null:new ot(a),$({kind:`presentationOpened`,id:n,bootstrap:a}),Z=`ready`;return}let e=Y.archive;if(!e)throw Error(`No pptx loaded`);if(t.kind===`finishPresentationPreflight`){if(!X)throw Error(`PPTX presentation preflight is not active`);let e=X.finish();X=null,$({kind:`presentationPreflightReady`,id:n,preflight:e});return}if(t.kind===`extractMedia`){let r=Y.run(()=>e.extract_media(t.path).buffer);$({kind:`mediaExtracted`,id:n,bytes:r},[r]);return}if(t.kind===`extractImage`){let r=Y.run(()=>e.extract_image(t.path).buffer);$({kind:`imageExtracted`,id:n,bytes:r},[r]);return}if(t.kind===`extractFont`){let r=Y.run(()=>e.extract_font(t.path).buffer);$({kind:`fontExtracted`,id:n,bytes:r},[r]);return}if(t.kind===`resourceUsage`){$({kind:`resourceUsage`,id:n,usage:y(Y.run(()=>e.resource_usage()))});return}t.kind===`toMarkdown`&&$({kind:`markdownRendered`,id:n,markdown:Y.run(()=>e.to_markdown())})})}catch(e){r&&(Z=`failed`),t.kind===`openSlideSession`&&Q.abandonOpen(t.sessionId);try{$({kind:`error`,id:n,...w(e)})}catch{}}};", Ct = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", St], { type: "text/javascript;charset=utf-8" });
|
|
611
611
|
function wt(e) {
|
|
612
612
|
let t;
|
|
613
613
|
try {
|
|
@@ -731,7 +731,7 @@ function It(e, t, n, r = {}) {
|
|
|
731
731
|
for (let r = t.elements.length - 1; r >= 0; r--) {
|
|
732
732
|
let i = t.elements[r];
|
|
733
733
|
if (!At(i, n, o)) continue;
|
|
734
|
-
let s = i.type === "chart" ?
|
|
734
|
+
let s = i.type === "chart" ? ce(i.chart, a) : Ft(Mt(i), a);
|
|
735
735
|
return {
|
|
736
736
|
format: "pptx",
|
|
737
737
|
kind: "element",
|
|
@@ -876,9 +876,9 @@ var J = class e {
|
|
|
876
876
|
_slidePullClient = null;
|
|
877
877
|
_resourceFailure = null;
|
|
878
878
|
_slidePartIndex = null;
|
|
879
|
-
_rawParts = new
|
|
879
|
+
_rawParts = new Ee({
|
|
880
880
|
maxEntries: 64,
|
|
881
|
-
maxBytes:
|
|
881
|
+
maxBytes: b
|
|
882
882
|
});
|
|
883
883
|
_googleFontFaces = [];
|
|
884
884
|
_embeddedFontFaces = [];
|
|
@@ -893,9 +893,9 @@ var J = class e {
|
|
|
893
893
|
_chartEx;
|
|
894
894
|
_tiff;
|
|
895
895
|
constructor(e, t, n) {
|
|
896
|
-
this._worker = e, this._mode = t, this._bridge = new
|
|
896
|
+
this._worker = e, this._mode = t, this._bridge = new be(this._worker, {
|
|
897
897
|
correlate: (e) => "protocol" in e && e.protocol === "ooxml-pull-v1" ? e.requestId : "id" in e ? e.id : void 0,
|
|
898
|
-
toError: (e) => !("protocol" in e) && e.kind === "error" ?
|
|
898
|
+
toError: (e) => !("protocol" in e) && e.kind === "error" ? m(e) : void 0,
|
|
899
899
|
onUnsolicited: (e) => this._onWorkerLayoutPush(e)
|
|
900
900
|
});
|
|
901
901
|
let r = new URL(n ?? Tt, location.href).href;
|
|
@@ -908,11 +908,11 @@ var J = class e {
|
|
|
908
908
|
if (this._resourceFailure) throw this._resourceFailure;
|
|
909
909
|
}
|
|
910
910
|
_rethrowWithResourceFailure(e) {
|
|
911
|
-
let t = e instanceof
|
|
911
|
+
let t = e instanceof E ? e : y(e);
|
|
912
912
|
throw t ? (this._resourceFailure ??= t, this._resourceFailure) : e;
|
|
913
913
|
}
|
|
914
914
|
static async load(t, r = {}) {
|
|
915
|
-
let i =
|
|
915
|
+
let i = v(r), a = r.mode ?? "main", o = new h({
|
|
916
916
|
enabled: !0,
|
|
917
917
|
format: "pptx",
|
|
918
918
|
mode: a,
|
|
@@ -928,8 +928,8 @@ var J = class e {
|
|
|
928
928
|
if (!e.ok) throw Error(`Failed to fetch: ${e.status} ${e.statusText}`);
|
|
929
929
|
s = await e.arrayBuffer();
|
|
930
930
|
} else s = t;
|
|
931
|
-
s =
|
|
932
|
-
let c = a === "worker" ? (await import("./render-worker-host-
|
|
931
|
+
s = ne(await re(s, r.password)), o.setSourceBytes(s.byteLength), o.checkpoint("container ready");
|
|
932
|
+
let c = a === "worker" ? (await import("./render-worker-host-CO0UYoQh.js")).createRenderWorker() : new wt(), l = a === "worker" ? Re(r) : void 0, u;
|
|
933
933
|
try {
|
|
934
934
|
u = new e(c, a, r.wasmUrl), u._metrics = o, r.math && a === "worker" && !l?.math && console.warn("[ooxml] a custom math renderer cannot cross the worker boundary; equations will be skipped in mode: 'worker'. Use the math renderer from @silurus/ooxml/math."), r.threeD && a === "worker" && !l?.threeD && console.warn("[ooxml] a custom 3-D chart renderer cannot cross the worker boundary; charts use their 2-D family fallback in mode: 'worker'. Use the renderer from @silurus/ooxml/three-d."), u._math = a === "worker" ? void 0 : r.math, u._threeD = a === "worker" ? void 0 : r.threeD, r.regionMap && a === "worker" && !l?.regionMap && console.warn("[ooxml] a custom Region Map renderer cannot cross the worker boundary; geospatial charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/region-map."), u._regionMap = a === "worker" ? void 0 : r.regionMap, r.chartEx && a === "worker" && !l?.chartEx && console.warn("[ooxml] a custom ChartEx renderer cannot cross the worker boundary; ChartEx charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/chart-ex."), u._chartEx = a === "worker" ? void 0 : r.chartEx, r.tiff && a === "worker" && !l?.tiff && console.warn("[ooxml] a custom TIFF codec cannot cross the worker boundary; recognized TIFF images will use an unavailable-image placeholder in mode: 'worker'. Use the codec from @silurus/ooxml/tiff to display them."), u._tiff = a === "worker" ? void 0 : r.tiff;
|
|
935
935
|
let t = r.progressiveLayout ? {
|
|
@@ -941,10 +941,10 @@ var J = class e {
|
|
|
941
941
|
deferred: !1,
|
|
942
942
|
settled: !1
|
|
943
943
|
} : void 0;
|
|
944
|
-
return await u._parse(s, i.policy, !!r.useGoogleFonts, r.workerTimeoutMs, (e) => o.observeUsage(e), l, t), o.checkpoint("presentation preflight ready"), a === "main" && r.useGoogleFonts && u._preflight && !t && (u._googleFontFaces = await
|
|
944
|
+
return await u._parse(s, i.policy, !!r.useGoogleFonts, r.workerTimeoutMs, (e) => o.observeUsage(e), l, t), o.checkpoint("presentation preflight ready"), a === "main" && r.useGoogleFonts && u._preflight && !t && (u._googleFontFaces = await we(xt(u._preflight.fontPreloadNames, u._embeddedFontAliases), n)), o.succeed({ slides: u.slideCount }), u;
|
|
945
945
|
} catch (e) {
|
|
946
946
|
let t = u;
|
|
947
|
-
throw
|
|
947
|
+
throw te(c, t ? () => t.destroy() : void 0), e;
|
|
948
948
|
}
|
|
949
949
|
} catch (e) {
|
|
950
950
|
throw o.fail(e), e;
|
|
@@ -1004,7 +1004,7 @@ var J = class e {
|
|
|
1004
1004
|
this._preflight = c(m.preflight), this._availableSlideCount = this._preflight.slideCount, this._slides = new _t({
|
|
1005
1005
|
slideCount: this._preflight.slideCount,
|
|
1006
1006
|
maxCachedSlides: 8,
|
|
1007
|
-
maxCachedStructuralBytes:
|
|
1007
|
+
maxCachedStructuralBytes: ee,
|
|
1008
1008
|
loadSlide: async (e) => {
|
|
1009
1009
|
let t = await this._slidePullClient?.load(e, !0, i);
|
|
1010
1010
|
if (!t) throw Error("PPTX slide pull client is unavailable");
|
|
@@ -1027,7 +1027,7 @@ var J = class e {
|
|
|
1027
1027
|
this._slidePullClient = this._createSlidePullClient(c.slideCount, a, o), this._slides = new _t({
|
|
1028
1028
|
slideCount: c.slideCount,
|
|
1029
1029
|
maxCachedSlides: 8,
|
|
1030
|
-
maxCachedStructuralBytes:
|
|
1030
|
+
maxCachedStructuralBytes: ee,
|
|
1031
1031
|
loadSlide: async (e) => {
|
|
1032
1032
|
let t = await this._slidePullClient?.load(e, !0, a);
|
|
1033
1033
|
if (!t) throw Error("PPTX slide pull client is unavailable");
|
|
@@ -1039,7 +1039,7 @@ var J = class e {
|
|
|
1039
1039
|
let e = xt(d.currentFontPreloadNames, this._embeddedFontAliases).filter((e) => !!e && !f.has(e));
|
|
1040
1040
|
if (e.length !== 0) {
|
|
1041
1041
|
for (let t of e) f.add(t);
|
|
1042
|
-
this._googleFontFaces.push(...await
|
|
1042
|
+
this._googleFontFaces.push(...await we(e, n));
|
|
1043
1043
|
}
|
|
1044
1044
|
};
|
|
1045
1045
|
this._layoutCompletion = (async () => {
|
|
@@ -1084,7 +1084,7 @@ var J = class e {
|
|
|
1084
1084
|
});
|
|
1085
1085
|
}
|
|
1086
1086
|
_onWorkerLayoutPush(e) {
|
|
1087
|
-
if (!
|
|
1087
|
+
if (!ie((e, t) => this._worker.postMessage(e, t), e) && !(!("kind" in e) || e.kind !== "presentationLayoutPartial" || e.forId !== this._parseRequestId || !this._progressive)) try {
|
|
1088
1088
|
this._rearmProgressiveWatchdog(), e.usage && this._metrics?.observeUsage(e.usage), e.bootstrap && (this._bootstrap = t(e.bootstrap));
|
|
1089
1089
|
let n = this._bootstrap;
|
|
1090
1090
|
if (!n) throw Error("PPTX progressive worker published before bootstrap");
|
|
@@ -1223,7 +1223,7 @@ var J = class e {
|
|
|
1223
1223
|
this._assertSlideIndex(t), await this._waitForSlide(t);
|
|
1224
1224
|
let i = this._preflight, a = this._slides;
|
|
1225
1225
|
if (!i || !a) throw Error("Presentation not loaded");
|
|
1226
|
-
let o = n.dpr ??
|
|
1226
|
+
let o = n.dpr ?? _(), s = n.width ?? ((p(e) ? e.offsetWidth : 0) || 960);
|
|
1227
1227
|
await a.withSlide(t, (t) => (this._assertResourceHealthy(), r(e, t, i.slideWidth, i.slideHeight, {
|
|
1228
1228
|
width: s,
|
|
1229
1229
|
dpr: o,
|
|
@@ -1252,7 +1252,7 @@ var J = class e {
|
|
|
1252
1252
|
this._assertResourceHealthy();
|
|
1253
1253
|
try {
|
|
1254
1254
|
this._assertSlideIndex(e), await this._waitForSlide(e);
|
|
1255
|
-
let n = t.width ?? 960, r = t.dpr ??
|
|
1255
|
+
let n = t.width ?? 960, r = t.dpr ?? _();
|
|
1256
1256
|
if (this._mode === "worker") {
|
|
1257
1257
|
let i = await this._bridge.request((i) => ({
|
|
1258
1258
|
kind: "renderSlide",
|
|
@@ -1267,7 +1267,7 @@ var J = class e {
|
|
|
1267
1267
|
try {
|
|
1268
1268
|
if (t.onTextRun) for (let e of i.runs) t.onTextRun(e);
|
|
1269
1269
|
} catch (e) {
|
|
1270
|
-
throw
|
|
1270
|
+
throw C(i.bitmap), e;
|
|
1271
1271
|
}
|
|
1272
1272
|
return i.bitmap;
|
|
1273
1273
|
}
|
|
@@ -1385,7 +1385,7 @@ var J = class e {
|
|
|
1385
1385
|
async getResourceMetrics() {
|
|
1386
1386
|
let e = this._metrics;
|
|
1387
1387
|
if (!e) throw Error("Presentation not loaded");
|
|
1388
|
-
return
|
|
1388
|
+
return g(e, async (e) => (await this._bridge.request((e) => ({
|
|
1389
1389
|
kind: "resourceUsage",
|
|
1390
1390
|
id: e
|
|
1391
1391
|
}), void 0, { timeoutMs: e })).usage);
|
|
@@ -1405,7 +1405,7 @@ var J = class e {
|
|
|
1405
1405
|
this._assertResourceHealthy();
|
|
1406
1406
|
try {
|
|
1407
1407
|
if (this._assertSlideIndex(t), await this._waitForSlide(t), !this._preflight) throw Error("Presentation not loaded");
|
|
1408
|
-
let r = n.dpr ??
|
|
1408
|
+
let r = n.dpr ?? _(), i = n.width ?? (e.offsetWidth || 960), a = this.slideWidth > 0 ? i * this.slideHeight / this.slideWidth : 0;
|
|
1409
1409
|
e.style.width = `${Math.round(i)}px`, e.style.height = `${Math.round(a)}px`, e.style.display || (e.style.display = "block");
|
|
1410
1410
|
let o = this._mode === "worker" ? async () => {
|
|
1411
1411
|
let a = await this.renderSlideToBitmap(t, {
|
|
@@ -1422,7 +1422,7 @@ var J = class e {
|
|
|
1422
1422
|
if (!t) throw Error("2D context not available");
|
|
1423
1423
|
t.drawImage(a, 0, 0);
|
|
1424
1424
|
} finally {
|
|
1425
|
-
|
|
1425
|
+
C(a);
|
|
1426
1426
|
}
|
|
1427
1427
|
} : () => this.renderSlide(e, t, {
|
|
1428
1428
|
width: i,
|
|
@@ -1446,7 +1446,7 @@ var J = class e {
|
|
|
1446
1446
|
}
|
|
1447
1447
|
}
|
|
1448
1448
|
destroy() {
|
|
1449
|
-
this._destroyed = !0, this._clearProgressiveWatchdog(), this._slidePullClient?.cancelAll(), this._bridge.terminate(), this._slides?.clear(), this._slides = null, this._slidePullClient = null, this._bootstrap = null, this._preflight = null, this._availableSlideCount = 0, this._layoutLifecycle.succeed(), this._layoutCompletion = null, this._progressive = null, this._parseRequestId = null, this._wakeLayoutWaiters(), this._resourceFailure = null, this._slidePartIndex = null, this._rawParts.clear(), this._googleFontFaces.length > 0 && (
|
|
1449
|
+
this._destroyed = !0, this._clearProgressiveWatchdog(), this._slidePullClient?.cancelAll(), this._bridge.terminate(), this._slides?.clear(), this._slides = null, this._slidePullClient = null, this._bootstrap = null, this._preflight = null, this._availableSlideCount = 0, this._layoutLifecycle.succeed(), this._layoutCompletion = null, this._progressive = null, this._parseRequestId = null, this._wakeLayoutWaiters(), this._resourceFailure = null, this._slidePartIndex = null, this._rawParts.clear(), this._googleFontFaces.length > 0 && (Ce(this._googleFontFaces), this._googleFontFaces = []), this._embeddedFontFaces.length > 0 && (j(this._embeddedFontFaces), this._embeddedFontFaces = []), this._embeddedFontAliases = /* @__PURE__ */ new Map(), this._embeddedFontAuthoredFamilies = /* @__PURE__ */ new Map(), S(this._fetchImage), x(this._fetchImage);
|
|
1450
1450
|
}
|
|
1451
1451
|
};
|
|
1452
1452
|
//#endregion
|
|
@@ -1496,7 +1496,7 @@ function Ht(e) {
|
|
|
1496
1496
|
return null;
|
|
1497
1497
|
}
|
|
1498
1498
|
function X(e, t, n = {}) {
|
|
1499
|
-
let r =
|
|
1499
|
+
let r = _e(e, t, (e) => {
|
|
1500
1500
|
let t = Ht(e), n = Y(e.dataset.runIndex);
|
|
1501
1501
|
if (t === null || n === null) return null;
|
|
1502
1502
|
let r = Y(e.dataset.elementIndex), i = e.dataset.elementOrigin, a = r !== null && (i === "master" || i === "layout" || i === "slide");
|
|
@@ -1591,17 +1591,17 @@ var Ut = Symbol("PptxViewer.borrowedPresentation"), Wt = {
|
|
|
1591
1591
|
constructor(e, t = {}) {
|
|
1592
1592
|
this.opts = t, this.canvas = e;
|
|
1593
1593
|
let n = t[Ut];
|
|
1594
|
-
this.borrowed = n !== void 0, this._mode =
|
|
1594
|
+
this.borrowed = n !== void 0, this._mode = A("PptxViewer", t.mode, n), this.presentationOwner = new D("PptxViewer", n ?? null, !1);
|
|
1595
1595
|
let r = e.ownerDocument?.defaultView ?? (typeof window < "u" ? window : null);
|
|
1596
1596
|
if (!r) throw Error("PptxViewer requires a canvas with an active Window");
|
|
1597
1597
|
this.hostWindow = r;
|
|
1598
1598
|
let i = t.elementHitTolerance ?? 6;
|
|
1599
1599
|
if (!Number.isFinite(i) || i < 0) throw RangeError("elementHitTolerance must be a finite non-negative number.");
|
|
1600
|
-
this.elementHitTolerance = i, this._hiddenMode = t.hiddenSlideMode ?? "show", this.canvasMount = new
|
|
1600
|
+
this.elementHitTolerance = i, this._hiddenMode = t.hiddenSlideMode ?? "show", this.canvasMount = new ve(e, {
|
|
1601
1601
|
wrapperCssText: "position:relative;display:inline-block;vertical-align:top;",
|
|
1602
1602
|
forceDisplayBlock: !0
|
|
1603
|
-
}), this.wrapper = this.canvasMount.wrapper, this.renderDispatcher = new
|
|
1604
|
-
let a = new
|
|
1603
|
+
}), this.wrapper = this.canvasMount.wrapper, this.renderDispatcher = new k(e, this._mode === "worker" && !t.enableMediaPlayback), this.errorRouter = new ge("PptxViewer", t.onError);
|
|
1604
|
+
let a = new pe(this.wrapper, t.enableTextSelection === !0, t.enableElementSelection === !0);
|
|
1605
1605
|
this.textLayer = a.textLayer, this.highlightLayer = a.highlightLayer, this.elementLayer = a.elementLayer, this._loadingLayer = this.wrapper.ownerDocument.createElement("span"), this._loadingLayer.style.cssText = [
|
|
1606
1606
|
"position:absolute",
|
|
1607
1607
|
"inset:0",
|
|
@@ -1758,14 +1758,14 @@ var Ut = Symbol("PptxViewer.borrowedPresentation"), Wt = {
|
|
|
1758
1758
|
return this.opts.zoomMax ?? 4;
|
|
1759
1759
|
}
|
|
1760
1760
|
async setScale(e) {
|
|
1761
|
-
let t =
|
|
1761
|
+
let t = ue(e, this._zoomMin(), this._zoomMax()), n = t !== this.getScale();
|
|
1762
1762
|
this._scale = t, await this.renderCurrentSlide(), n && this.opts.onScaleChange?.(t);
|
|
1763
1763
|
}
|
|
1764
1764
|
async zoomIn() {
|
|
1765
|
-
await this.setScale(
|
|
1765
|
+
await this.setScale(ye(this.getScale()));
|
|
1766
1766
|
}
|
|
1767
1767
|
async zoomOut() {
|
|
1768
|
-
await this.setScale(
|
|
1768
|
+
await this.setScale(Se(this.getScale()));
|
|
1769
1769
|
}
|
|
1770
1770
|
async fitWidth() {
|
|
1771
1771
|
await this._fit("width");
|
|
@@ -1777,7 +1777,7 @@ var Ut = Symbol("PptxViewer.borrowedPresentation"), Wt = {
|
|
|
1777
1777
|
if (!this.engine) return;
|
|
1778
1778
|
let t = this.wrapper.parentElement;
|
|
1779
1779
|
if (!t) return;
|
|
1780
|
-
let n =
|
|
1780
|
+
let n = oe({
|
|
1781
1781
|
contentWidth: this.engine.slideWidth / M,
|
|
1782
1782
|
contentHeight: this.engine.slideHeight / M,
|
|
1783
1783
|
containerWidth: t.clientWidth,
|
|
@@ -1938,7 +1938,7 @@ var Ut = Symbol("PptxViewer.borrowedPresentation"), Wt = {
|
|
|
1938
1938
|
return;
|
|
1939
1939
|
}
|
|
1940
1940
|
if (t.kind === "external") {
|
|
1941
|
-
|
|
1941
|
+
T(t.url, void 0, this.hostWindow);
|
|
1942
1942
|
return;
|
|
1943
1943
|
}
|
|
1944
1944
|
t.slideIndex !== void 0 && this.goToSlide(t.slideIndex).catch((e) => this._reportRenderError(e));
|
|
@@ -1977,10 +1977,10 @@ var Ut = Symbol("PptxViewer.borrowedPresentation"), Wt = {
|
|
|
1977
1977
|
_redrawElementOutline() {
|
|
1978
1978
|
let e = this.elementContext, t = this.engine;
|
|
1979
1979
|
if (!e || !t || e.slideIndex !== this.currentSlide) {
|
|
1980
|
-
|
|
1980
|
+
O(this.elementLayer, null);
|
|
1981
1981
|
return;
|
|
1982
1982
|
}
|
|
1983
|
-
|
|
1983
|
+
O(this.elementLayer, {
|
|
1984
1984
|
x: e.bounds.x / t.slideWidth,
|
|
1985
1985
|
y: e.bounds.y / t.slideHeight,
|
|
1986
1986
|
width: e.bounds.width / t.slideWidth,
|
|
@@ -2027,7 +2027,7 @@ var Ut = Symbol("PptxViewer.borrowedPresentation"), Wt = {
|
|
|
2027
2027
|
}
|
|
2028
2028
|
}, Kt = 150, qt = "0 1px 3px rgba(0,0,0,0.2)", Q = 12, Jt;
|
|
2029
2029
|
function Yt() {
|
|
2030
|
-
return Jt ??= import("./comment-ui-runtime-
|
|
2030
|
+
return Jt ??= import("./comment-ui-runtime-ssI6IE39.js");
|
|
2031
2031
|
}
|
|
2032
2032
|
var $ = 440, Xt = 20, Zt = Symbol("PptxScrollViewer.borrowedPresentation"), Qt = class e {
|
|
2033
2033
|
_presentationOwner;
|
|
@@ -2096,12 +2096,12 @@ var $ = 440, Xt = 20, Zt = Symbol("PptxScrollViewer.borrowedPresentation"), Qt =
|
|
|
2096
2096
|
}
|
|
2097
2097
|
constructor(e, t = {}) {
|
|
2098
2098
|
if (e.tagName === "CANVAS") throw Error("PptxScrollViewer takes a container element (e.g. a <div>), not a <canvas> — the viewer creates and manages its own canvases. Pass a block container; for the single-slide canvas API use PptxViewer.");
|
|
2099
|
-
this._container = e, this._opts = t, this._errorRouter = new
|
|
2099
|
+
this._container = e, this._opts = t, this._errorRouter = new ge("PptxScrollViewer", t.onError);
|
|
2100
2100
|
let n = t.elementHitTolerance ?? 6;
|
|
2101
2101
|
if (!Number.isFinite(n) || n < 0) throw RangeError("elementHitTolerance must be a finite non-negative number.");
|
|
2102
2102
|
this._elementHitTolerance = n, this._pageShadow = t.pageShadow ?? qt;
|
|
2103
2103
|
let r = t[Zt];
|
|
2104
|
-
this._borrowed = r !== void 0, r ? (this._presentationOwner = new
|
|
2104
|
+
this._borrowed = r !== void 0, r ? (this._presentationOwner = new D("PptxScrollViewer", r, !1), this._mode = A("PptxScrollViewer", t.mode, r), this._scanAvailableComments(r, !1)) : (this._presentationOwner = new D("PptxScrollViewer"), this._mode = A("PptxScrollViewer", t.mode, void 0)), this._wrapper = document.createElement("div"), this._wrapper.style.cssText = "position:relative;width:100%;height:100%;overflow:hidden;", this._scrollHost = document.createElement("div"), this._scrollHost.style.cssText = "position:absolute;inset:0;overflow:auto;", this._scrollHost.style.scrollbarGutter = "stable", t.background && (this._scrollHost.style.background = t.background), this._spacer = document.createElement("div"), this._spacer.style.cssText = "position:absolute;top:0;left:0;width:1px;height:0;pointer-events:none;", this._scrollHost.appendChild(this._spacer), this._wrapper.appendChild(this._scrollHost), this._container.appendChild(this._wrapper), this._commentsEnabled() && Yt().then((e) => {
|
|
2105
2105
|
if (!this._destroyed) {
|
|
2106
2106
|
this._commentUi = e;
|
|
2107
2107
|
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
@@ -2120,7 +2120,7 @@ var $ = 440, Xt = 20, Zt = Symbol("PptxScrollViewer.borrowedPresentation"), Qt =
|
|
|
2120
2120
|
this._pendingZoomAnchor = Number.isFinite(n) && Number.isFinite(r) ? {
|
|
2121
2121
|
x: n,
|
|
2122
2122
|
y: r
|
|
2123
|
-
} : null, this.setScale(
|
|
2123
|
+
} : null, this.setScale(xe(this._scale, e.deltaY, e.deltaMode));
|
|
2124
2124
|
}, this._scrollHost.addEventListener("wheel", this._wheelListener, { passive: !1 })), typeof ResizeObserver < "u" && (this._resizeObserver = new ResizeObserver(() => this._onResize()), this._resizeObserver.observe(this._container)), this._borrowed && (this._bindLayoutPresentation(r), this.relayout());
|
|
2125
2125
|
}
|
|
2126
2126
|
async load(e) {
|
|
@@ -2280,10 +2280,10 @@ var $ = 440, Xt = 20, Zt = Symbol("PptxScrollViewer.borrowedPresentation"), Qt =
|
|
|
2280
2280
|
return this._pad().leading + e * (this._uniformSlideHeight + this._gap());
|
|
2281
2281
|
}
|
|
2282
2282
|
_slideIndexAtOffset(e) {
|
|
2283
|
-
return
|
|
2283
|
+
return De(this._pres?.slideCount ?? 0, this._uniformSlideHeight, this._gap(), e, 0, 0, this._pad()).topIndex;
|
|
2284
2284
|
}
|
|
2285
2285
|
_rangeAt(e, t) {
|
|
2286
|
-
return
|
|
2286
|
+
return De(this._pres?.slideCount ?? 0, this._uniformSlideHeight, this._gap(), e, this._scrollHost.clientHeight, t, this._pad());
|
|
2287
2287
|
}
|
|
2288
2288
|
_range() {
|
|
2289
2289
|
return this._rangeAt(this._scrollHost.scrollTop, this._overscan());
|
|
@@ -2351,7 +2351,7 @@ var $ = 440, Xt = 20, Zt = Symbol("PptxScrollViewer.borrowedPresentation"), Qt =
|
|
|
2351
2351
|
o.setAttribute("aria-hidden", "true"), a.appendChild(o), t.appendChild(a);
|
|
2352
2352
|
let s = null, c = null, l = null;
|
|
2353
2353
|
this._commentsEnabled() && (s = document.createElement("div"), s.style.cssText = "position:absolute;inset:0;overflow:hidden;pointer-events:none;", t.appendChild(s), this._commentsOptions()?.cards !== !1 && (c = document.createElement("div"), c.style.cssText = "position:absolute;top:0;height:100%;box-sizing:border-box;overflow-x:hidden;overflow-y:auto;pointer-events:auto;", this._syncCommentMarginGeometry(c), this._commentsOptions()?.connectors !== void 0 && (l = document.createElement("div"), l.style.cssText = "position:absolute;top:0;left:0;overflow:visible;pointer-events:none;", t.appendChild(l)), t.appendChild(c)));
|
|
2354
|
-
let u =
|
|
2354
|
+
let u = me(t, this._opts.enableElementSelection === !0);
|
|
2355
2355
|
return this._scrollHost.appendChild(t), {
|
|
2356
2356
|
wrapper: t,
|
|
2357
2357
|
canvas: n,
|
|
@@ -2368,7 +2368,7 @@ var $ = 440, Xt = 20, Zt = Symbol("PptxScrollViewer.borrowedPresentation"), Qt =
|
|
|
2368
2368
|
commentAnchorGeneration: 0,
|
|
2369
2369
|
renderedSlide: -1,
|
|
2370
2370
|
renderedScale: -1,
|
|
2371
|
-
dispatcher: new
|
|
2371
|
+
dispatcher: new k(n, this._mode === "worker" && !this._opts.enableMediaPlayback),
|
|
2372
2372
|
presentationHandle: null,
|
|
2373
2373
|
mediaInteractive: !1,
|
|
2374
2374
|
renderGeneration: 0,
|
|
@@ -2376,7 +2376,7 @@ var $ = 440, Xt = 20, Zt = Symbol("PptxScrollViewer.borrowedPresentation"), Qt =
|
|
|
2376
2376
|
};
|
|
2377
2377
|
}
|
|
2378
2378
|
_recycleSlot(e, t) {
|
|
2379
|
-
this._slots.delete(e), t.renderGeneration++, t.presentationGeneration++, t.presentationHandle?.destroy(), t.presentationHandle = null, t.mediaInteractive = !1, t.dispatcher.destroy(), this._destroyed || (t.dispatcher = new
|
|
2379
|
+
this._slots.delete(e), t.renderGeneration++, t.presentationGeneration++, t.presentationHandle?.destroy(), t.presentationHandle = null, t.mediaInteractive = !1, t.dispatcher.destroy(), this._destroyed || (t.dispatcher = new k(t.canvas, this._mode === "worker" && !this._opts.enableMediaPlayback)), t.textLayer && (t.textLayer.innerHTML = "", this._clearTextLayerPreview(t.textLayer)), t.highlightLayer.innerHTML = "", t.highlightLayer.style.transform = "", t.highlightLayer.style.transformOrigin = "", t.loadingLayer.style.display = "none", t.commentMarkerLayer && (t.commentMarkerLayer.replaceChildren(), t.commentMarkerLayer.style.visibility = ""), t.commentMargin && (this._commentUi?.disposeReadOnlyCommentMargin(t.commentMargin), this._commentUi || t.commentMargin.replaceChildren(), t.commentMargin.style.visibility = ""), t.commentDecorationLayer && (this._commentUi?.disposeReadOnlyCommentDecoration(t.commentDecorationLayer), this._commentUi || t.commentDecorationLayer.replaceChildren(), t.commentDecorationLayer.style.visibility = ""), t.commentElementBounds = Object.freeze([]), t.commentGeometry = null, t.commentAnchorSlide = -1, t.commentAnchorGeneration++, O(t.elementLayer, null), t.canvas.style.height = "", t.renderedSlide = -1, t.renderedScale = -1, t.wrapper.remove(), this._free.push(t);
|
|
2380
2380
|
}
|
|
2381
2381
|
_positionSlot(e, t, n) {
|
|
2382
2382
|
e.wrapper.dataset.slideIndex = String(t), e.wrapper.style.top = `${this._slideOffset(t)}px`;
|
|
@@ -2553,7 +2553,7 @@ var $ = 440, Xt = 20, Zt = Symbol("PptxScrollViewer.borrowedPresentation"), Qt =
|
|
|
2553
2553
|
let h = Math.max(0, m.totalHeight - this._scrollHost.clientHeight), g = this._slideOffset(l) + d * this._uniformSlideHeight, _ = c < this._slideOffset(0) ? s : g - o;
|
|
2554
2554
|
if (this._scrollHost.scrollTop = Math.min(h, Math.max(0, _)), i) {
|
|
2555
2555
|
let e = Math.max(0, (this._spacer.offsetWidth || 0) - this._scrollHost.clientWidth);
|
|
2556
|
-
this._scrollHost.scrollLeft =
|
|
2556
|
+
this._scrollHost.scrollLeft = se(p, i.x - f, a, r, { maxScroll: e });
|
|
2557
2557
|
}
|
|
2558
2558
|
this._previewVisible(), this._scheduleSettle(), this._opts.onScaleChange?.(r);
|
|
2559
2559
|
}
|
|
@@ -2561,10 +2561,10 @@ var $ = 440, Xt = 20, Zt = Symbol("PptxScrollViewer.borrowedPresentation"), Qt =
|
|
|
2561
2561
|
return this._scaleEstablished ? this._scale : this._pendingScale ?? 1;
|
|
2562
2562
|
}
|
|
2563
2563
|
zoomIn() {
|
|
2564
|
-
this.setScale(
|
|
2564
|
+
this.setScale(ye(this.getScale()));
|
|
2565
2565
|
}
|
|
2566
2566
|
zoomOut() {
|
|
2567
|
-
this.setScale(
|
|
2567
|
+
this.setScale(Se(this.getScale(), this._effectiveZoomMin()));
|
|
2568
2568
|
}
|
|
2569
2569
|
_effectiveZoomMin() {
|
|
2570
2570
|
let e = this._opts.zoomMin ?? .1;
|
|
@@ -2578,7 +2578,7 @@ var $ = 440, Xt = 20, Zt = Symbol("PptxScrollViewer.borrowedPresentation"), Qt =
|
|
|
2578
2578
|
}
|
|
2579
2579
|
_fit(e) {
|
|
2580
2580
|
if (!this._pres || this._pres.slideCount === 0) return;
|
|
2581
|
-
let t =
|
|
2581
|
+
let t = oe({
|
|
2582
2582
|
contentWidth: this._pres.slideWidth / M,
|
|
2583
2583
|
contentHeight: this._pres.slideHeight / M,
|
|
2584
2584
|
containerWidth: this._fitWidthPx(),
|
|
@@ -2642,7 +2642,7 @@ var $ = 440, Xt = 20, Zt = Symbol("PptxScrollViewer.borrowedPresentation"), Qt =
|
|
|
2642
2642
|
}
|
|
2643
2643
|
let o = document.createElement("canvas"), s = ++t.renderGeneration;
|
|
2644
2644
|
o.style.cssText = "display:block;background:#fff;", this._applyPageShadow(o);
|
|
2645
|
-
let c = new
|
|
2645
|
+
let c = new k(o, !1), l = c.begin(), u = [], d = !!this._opts.enableTextSelection && !!t.textLayer, f = d || this._findActive, p = f ? (e) => u.push(e) : void 0;
|
|
2646
2646
|
Z(this._pres, o, e, "main", {
|
|
2647
2647
|
width: r,
|
|
2648
2648
|
dpr: n,
|
|
@@ -2676,7 +2676,7 @@ var $ = 440, Xt = 20, Zt = Symbol("PptxScrollViewer.borrowedPresentation"), Qt =
|
|
|
2676
2676
|
return;
|
|
2677
2677
|
}
|
|
2678
2678
|
let d = t.canvas, f = t.presentationHandle;
|
|
2679
|
-
t.dispatcher.destroy(), t.wrapper.insertBefore(s, d), d.remove(), t.canvas = s, t.dispatcher = new
|
|
2679
|
+
t.dispatcher.destroy(), t.wrapper.insertBefore(s, d), d.remove(), t.canvas = s, t.dispatcher = new k(s, !1), t.presentationHandle = r, t.renderedScale = i, f?.destroy(), t.textLayer && (this._clearTextLayerPreview(t.textLayer), l && I(t.textLayer, c, Math.round(n), Math.round(this._slideHeightPx()), this._hyperlinkHandler(), e)), u && this._refreshFindRuns(e, c), this._commitSlotComments(e, t), this._redrawSlotHighlights(e, t);
|
|
2680
2680
|
}).catch((e) => {
|
|
2681
2681
|
o === t.presentationGeneration && this._reportRenderError(e);
|
|
2682
2682
|
});
|
|
@@ -2878,7 +2878,7 @@ var $ = 440, Xt = 20, Zt = Symbol("PptxScrollViewer.borrowedPresentation"), Qt =
|
|
|
2878
2878
|
return;
|
|
2879
2879
|
}
|
|
2880
2880
|
if (t.kind === "external") {
|
|
2881
|
-
|
|
2881
|
+
T(t.url);
|
|
2882
2882
|
return;
|
|
2883
2883
|
}
|
|
2884
2884
|
t.slideIndex !== void 0 && this.scrollToSlide(t.slideIndex);
|
|
@@ -2973,10 +2973,10 @@ var $ = 440, Xt = 20, Zt = Symbol("PptxScrollViewer.borrowedPresentation"), Qt =
|
|
|
2973
2973
|
_redrawElementOutlineForSlot(e, t) {
|
|
2974
2974
|
let n = this._elementContext, r = this._pres;
|
|
2975
2975
|
if (!n || !r || n.slideIndex !== e) {
|
|
2976
|
-
|
|
2976
|
+
O(t.elementLayer, null);
|
|
2977
2977
|
return;
|
|
2978
2978
|
}
|
|
2979
|
-
|
|
2979
|
+
O(t.elementLayer, {
|
|
2980
2980
|
x: n.bounds.x / r.slideWidth,
|
|
2981
2981
|
y: n.bounds.y / r.slideHeight,
|
|
2982
2982
|
width: n.bounds.width / r.slideWidth,
|
|
@@ -3029,18 +3029,18 @@ var $ = 440, Xt = 20, Zt = Symbol("PptxScrollViewer.borrowedPresentation"), Qt =
|
|
|
3029
3029
|
}
|
|
3030
3030
|
}, $t = /* @__PURE__ */ e({
|
|
3031
3031
|
OoxmlDecodedImageLimitError: () => Pe,
|
|
3032
|
-
OoxmlError: () =>
|
|
3033
|
-
OoxmlResourceLimitError: () =>
|
|
3032
|
+
OoxmlError: () => w,
|
|
3033
|
+
OoxmlResourceLimitError: () => E,
|
|
3034
3034
|
PptxPresentation: () => J,
|
|
3035
3035
|
PptxScrollViewer: () => Qt,
|
|
3036
3036
|
PptxViewer: () => Gt,
|
|
3037
3037
|
TiffDecodeError: () => Fe,
|
|
3038
|
-
autoResize: () =>
|
|
3038
|
+
autoResize: () => ae,
|
|
3039
3039
|
buildPptxHighlightLayer: () => L,
|
|
3040
3040
|
buildPptxTextLayer: () => I,
|
|
3041
3041
|
isOoxmlDecodedImageLimitError: () => Ne,
|
|
3042
3042
|
isTiffDecodeError: () => Ie,
|
|
3043
|
-
openExternalHyperlink: () =>
|
|
3043
|
+
openExternalHyperlink: () => T,
|
|
3044
3044
|
readPptxTextSelectionContext: () => X,
|
|
3045
3045
|
renderSlide: () => f
|
|
3046
3046
|
});
|