document-model 1.0.4 → 1.0.5

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.
@@ -0,0 +1,1650 @@
1
+ var mr = Object.defineProperty;
2
+ var xr = (n, a, s) => a in n ? mr(n, a, { enumerable: !0, configurable: !0, writable: !0, value: s }) : n[a] = s;
3
+ var G = (n, a, s) => (xr(n, typeof a != "symbol" ? a + "" : a, s), s);
4
+ import dr from "json-stringify-deterministic";
5
+ import { produce as vt, castDraft as wr } from "immer";
6
+ import { z as d } from "zod";
7
+ import Ft from "jszip";
8
+ const _t = (n) => n != null, yr = d.any().refine((n) => _t(n)), At = d.enum(["LOAD_STATE"]), Bt = d.enum(["PRUNE"]), St = d.enum(["REDO"]), jt = d.enum(["SET_NAME"]), Ut = d.enum(["UNDO"]);
9
+ function gr() {
10
+ return d.object({
11
+ __typename: d.literal("Action").optional(),
12
+ type: d.string()
13
+ });
14
+ }
15
+ function It() {
16
+ return d.union([
17
+ rt(),
18
+ it(),
19
+ et(),
20
+ nt(),
21
+ at()
22
+ ]);
23
+ }
24
+ function vr() {
25
+ return d.object({
26
+ __typename: d.literal("DocumentFile").optional(),
27
+ data: d.string(),
28
+ extension: d.string().nullable(),
29
+ fileName: d.string().nullable(),
30
+ mimeType: d.string()
31
+ });
32
+ }
33
+ function rt() {
34
+ return d.object({
35
+ input: d.lazy(() => kt()),
36
+ type: At
37
+ });
38
+ }
39
+ function kt() {
40
+ return d.object({
41
+ operations: d.number(),
42
+ state: d.lazy(() => Tt())
43
+ });
44
+ }
45
+ function Tt() {
46
+ return d.object({
47
+ data: d.unknown().nullish(),
48
+ name: d.string()
49
+ });
50
+ }
51
+ function Er() {
52
+ return d.object({
53
+ __typename: d.literal("Operation").optional(),
54
+ hash: d.string(),
55
+ index: d.number(),
56
+ timestamp: d.string().datetime(),
57
+ type: d.string()
58
+ });
59
+ }
60
+ function it() {
61
+ return d.object({
62
+ input: d.lazy(() => Dt()),
63
+ type: Bt
64
+ });
65
+ }
66
+ function Dt() {
67
+ return d.object({
68
+ end: d.number().nullish(),
69
+ start: d.number().nullish()
70
+ });
71
+ }
72
+ function et() {
73
+ return d.object({
74
+ input: d.number(),
75
+ type: St
76
+ });
77
+ }
78
+ function nt() {
79
+ return d.object({
80
+ input: d.string(),
81
+ type: jt
82
+ });
83
+ }
84
+ function br() {
85
+ return d.object({
86
+ __typename: d.literal("SetNameOperation").optional(),
87
+ hash: d.string(),
88
+ index: d.number(),
89
+ input: d.string(),
90
+ timestamp: d.string().datetime(),
91
+ type: d.string()
92
+ });
93
+ }
94
+ function at() {
95
+ return d.object({
96
+ input: d.number(),
97
+ type: Ut
98
+ });
99
+ }
100
+ const Ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
101
+ __proto__: null,
102
+ ActionSchema: gr,
103
+ BaseActionSchema: It,
104
+ DocumentFileSchema: vr,
105
+ LoadStateActionInputSchema: kt,
106
+ LoadStateActionSchema: rt,
107
+ LoadStateActionStateInputSchema: Tt,
108
+ Load_StateSchema: At,
109
+ OperationSchema: Er,
110
+ PruneActionInputSchema: Dt,
111
+ PruneActionSchema: it,
112
+ PruneSchema: Bt,
113
+ RedoActionSchema: et,
114
+ RedoSchema: St,
115
+ SetNameActionSchema: nt,
116
+ SetNameOperationSchema: br,
117
+ Set_NameSchema: jt,
118
+ UndoActionSchema: at,
119
+ UndoSchema: Ut,
120
+ definedNonNullAnySchema: yr,
121
+ isDefinedNonNullAny: _t
122
+ }, Symbol.toStringTag, { value: "Module" }));
123
+ function Ot(n) {
124
+ return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
125
+ }
126
+ function $() {
127
+ this._types = /* @__PURE__ */ Object.create(null), this._extensions = /* @__PURE__ */ Object.create(null);
128
+ for (let n = 0; n < arguments.length; n++)
129
+ this.define(arguments[n]);
130
+ this.define = this.define.bind(this), this.getType = this.getType.bind(this), this.getExtension = this.getExtension.bind(this);
131
+ }
132
+ $.prototype.define = function(n, a) {
133
+ for (let s in n) {
134
+ let c = n[s].map(function(f) {
135
+ return f.toLowerCase();
136
+ });
137
+ s = s.toLowerCase();
138
+ for (let f = 0; f < c.length; f++) {
139
+ const m = c[f];
140
+ if (m[0] !== "*") {
141
+ if (!a && m in this._types)
142
+ throw new Error(
143
+ 'Attempt to change mapping for "' + m + '" extension from "' + this._types[m] + '" to "' + s + '". Pass `force=true` to allow this, otherwise remove "' + m + '" from the list of extensions for "' + s + '".'
144
+ );
145
+ this._types[m] = s;
146
+ }
147
+ }
148
+ if (a || !this._extensions[s]) {
149
+ const f = c[0];
150
+ this._extensions[s] = f[0] !== "*" ? f : f.substr(1);
151
+ }
152
+ }
153
+ };
154
+ $.prototype.getType = function(n) {
155
+ n = String(n);
156
+ let a = n.replace(/^.*[/\\]/, "").toLowerCase(), s = a.replace(/^.*\./, "").toLowerCase(), c = a.length < n.length;
157
+ return (s.length < a.length - 1 || !c) && this._types[s] || null;
158
+ };
159
+ $.prototype.getExtension = function(n) {
160
+ return n = /^\s*([^;\s]*)/.test(n) && RegExp.$1, n && this._extensions[n.toLowerCase()] || null;
161
+ };
162
+ var Fr = $, _r = { "application/andrew-inset": ["ez"], "application/applixware": ["aw"], "application/atom+xml": ["atom"], "application/atomcat+xml": ["atomcat"], "application/atomdeleted+xml": ["atomdeleted"], "application/atomsvc+xml": ["atomsvc"], "application/atsc-dwd+xml": ["dwd"], "application/atsc-held+xml": ["held"], "application/atsc-rsat+xml": ["rsat"], "application/bdoc": ["bdoc"], "application/calendar+xml": ["xcs"], "application/ccxml+xml": ["ccxml"], "application/cdfx+xml": ["cdfx"], "application/cdmi-capability": ["cdmia"], "application/cdmi-container": ["cdmic"], "application/cdmi-domain": ["cdmid"], "application/cdmi-object": ["cdmio"], "application/cdmi-queue": ["cdmiq"], "application/cu-seeme": ["cu"], "application/dash+xml": ["mpd"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["es", "ecma"], "application/emma+xml": ["emma"], "application/emotionml+xml": ["emotionml"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/express": ["exp"], "application/fdt+xml": ["fdt"], "application/font-tdpfr": ["pfr"], "application/geo+json": ["geojson"], "application/gml+xml": ["gml"], "application/gpx+xml": ["gpx"], "application/gxf": ["gxf"], "application/gzip": ["gz"], "application/hjson": ["hjson"], "application/hyperstudio": ["stk"], "application/inkml+xml": ["ink", "inkml"], "application/ipfix": ["ipfix"], "application/its+xml": ["its"], "application/java-archive": ["jar", "war", "ear"], "application/java-serialized-object": ["ser"], "application/java-vm": ["class"], "application/javascript": ["js", "mjs"], "application/json": ["json", "map"], "application/json5": ["json5"], "application/jsonml+json": ["jsonml"], "application/ld+json": ["jsonld"], "application/lgr+xml": ["lgr"], "application/lost+xml": ["lostxml"], "application/mac-binhex40": ["hqx"], "application/mac-compactpro": ["cpt"], "application/mads+xml": ["mads"], "application/manifest+json": ["webmanifest"], "application/marc": ["mrc"], "application/marcxml+xml": ["mrcx"], "application/mathematica": ["ma", "nb", "mb"], "application/mathml+xml": ["mathml"], "application/mbox": ["mbox"], "application/mediaservercontrol+xml": ["mscml"], "application/metalink+xml": ["metalink"], "application/metalink4+xml": ["meta4"], "application/mets+xml": ["mets"], "application/mmt-aei+xml": ["maei"], "application/mmt-usd+xml": ["musd"], "application/mods+xml": ["mods"], "application/mp21": ["m21", "mp21"], "application/mp4": ["mp4s", "m4p"], "application/msword": ["doc", "dot"], "application/mxf": ["mxf"], "application/n-quads": ["nq"], "application/n-triples": ["nt"], "application/node": ["cjs"], "application/octet-stream": ["bin", "dms", "lrf", "mar", "so", "dist", "distz", "pkg", "bpk", "dump", "elc", "deploy", "exe", "dll", "deb", "dmg", "iso", "img", "msi", "msp", "msm", "buffer"], "application/oda": ["oda"], "application/oebps-package+xml": ["opf"], "application/ogg": ["ogx"], "application/omdoc+xml": ["omdoc"], "application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"], "application/oxps": ["oxps"], "application/p2p-overlay+xml": ["relo"], "application/patch-ops-error+xml": ["xer"], "application/pdf": ["pdf"], "application/pgp-encrypted": ["pgp"], "application/pgp-signature": ["asc", "sig"], "application/pics-rules": ["prf"], "application/pkcs10": ["p10"], "application/pkcs7-mime": ["p7m", "p7c"], "application/pkcs7-signature": ["p7s"], "application/pkcs8": ["p8"], "application/pkix-attr-cert": ["ac"], "application/pkix-cert": ["cer"], "application/pkix-crl": ["crl"], "application/pkix-pkipath": ["pkipath"], "application/pkixcmp": ["pki"], "application/pls+xml": ["pls"], "application/postscript": ["ai", "eps", "ps"], "application/provenance+xml": ["provx"], "application/pskc+xml": ["pskcxml"], "application/raml+yaml": ["raml"], "application/rdf+xml": ["rdf", "owl"], "application/reginfo+xml": ["rif"], "application/relax-ng-compact-syntax": ["rnc"], "application/resource-lists+xml": ["rl"], "application/resource-lists-diff+xml": ["rld"], "application/rls-services+xml": ["rs"], "application/route-apd+xml": ["rapd"], "application/route-s-tsid+xml": ["sls"], "application/route-usd+xml": ["rusd"], "application/rpki-ghostbusters": ["gbr"], "application/rpki-manifest": ["mft"], "application/rpki-roa": ["roa"], "application/rsd+xml": ["rsd"], "application/rss+xml": ["rss"], "application/rtf": ["rtf"], "application/sbml+xml": ["sbml"], "application/scvp-cv-request": ["scq"], "application/scvp-cv-response": ["scs"], "application/scvp-vp-request": ["spq"], "application/scvp-vp-response": ["spp"], "application/sdp": ["sdp"], "application/senml+xml": ["senmlx"], "application/sensml+xml": ["sensmlx"], "application/set-payment-initiation": ["setpay"], "application/set-registration-initiation": ["setreg"], "application/shf+xml": ["shf"], "application/sieve": ["siv", "sieve"], "application/smil+xml": ["smi", "smil"], "application/sparql-query": ["rq"], "application/sparql-results+xml": ["srx"], "application/srgs": ["gram"], "application/srgs+xml": ["grxml"], "application/sru+xml": ["sru"], "application/ssdl+xml": ["ssdl"], "application/ssml+xml": ["ssml"], "application/swid+xml": ["swidtag"], "application/tei+xml": ["tei", "teicorpus"], "application/thraud+xml": ["tfi"], "application/timestamped-data": ["tsd"], "application/toml": ["toml"], "application/trig": ["trig"], "application/ttml+xml": ["ttml"], "application/ubjson": ["ubj"], "application/urc-ressheet+xml": ["rsheet"], "application/urc-targetdesc+xml": ["td"], "application/voicexml+xml": ["vxml"], "application/wasm": ["wasm"], "application/widget": ["wgt"], "application/winhlp": ["hlp"], "application/wsdl+xml": ["wsdl"], "application/wspolicy+xml": ["wspolicy"], "application/xaml+xml": ["xaml"], "application/xcap-att+xml": ["xav"], "application/xcap-caps+xml": ["xca"], "application/xcap-diff+xml": ["xdf"], "application/xcap-el+xml": ["xel"], "application/xcap-ns+xml": ["xns"], "application/xenc+xml": ["xenc"], "application/xhtml+xml": ["xhtml", "xht"], "application/xliff+xml": ["xlf"], "application/xml": ["xml", "xsl", "xsd", "rng"], "application/xml-dtd": ["dtd"], "application/xop+xml": ["xop"], "application/xproc+xml": ["xpl"], "application/xslt+xml": ["*xsl", "xslt"], "application/xspf+xml": ["xspf"], "application/xv+xml": ["mxml", "xhvml", "xvml", "xvm"], "application/yang": ["yang"], "application/yin+xml": ["yin"], "application/zip": ["zip"], "audio/3gpp": ["*3gpp"], "audio/adpcm": ["adp"], "audio/amr": ["amr"], "audio/basic": ["au", "snd"], "audio/midi": ["mid", "midi", "kar", "rmi"], "audio/mobile-xmf": ["mxmf"], "audio/mp3": ["*mp3"], "audio/mp4": ["m4a", "mp4a"], "audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"], "audio/ogg": ["oga", "ogg", "spx", "opus"], "audio/s3m": ["s3m"], "audio/silk": ["sil"], "audio/wav": ["wav"], "audio/wave": ["*wav"], "audio/webm": ["weba"], "audio/xm": ["xm"], "font/collection": ["ttc"], "font/otf": ["otf"], "font/ttf": ["ttf"], "font/woff": ["woff"], "font/woff2": ["woff2"], "image/aces": ["exr"], "image/apng": ["apng"], "image/avif": ["avif"], "image/bmp": ["bmp"], "image/cgm": ["cgm"], "image/dicom-rle": ["drle"], "image/emf": ["emf"], "image/fits": ["fits"], "image/g3fax": ["g3"], "image/gif": ["gif"], "image/heic": ["heic"], "image/heic-sequence": ["heics"], "image/heif": ["heif"], "image/heif-sequence": ["heifs"], "image/hej2k": ["hej2"], "image/hsj2": ["hsj2"], "image/ief": ["ief"], "image/jls": ["jls"], "image/jp2": ["jp2", "jpg2"], "image/jpeg": ["jpeg", "jpg", "jpe"], "image/jph": ["jph"], "image/jphc": ["jhc"], "image/jpm": ["jpm"], "image/jpx": ["jpx", "jpf"], "image/jxr": ["jxr"], "image/jxra": ["jxra"], "image/jxrs": ["jxrs"], "image/jxs": ["jxs"], "image/jxsc": ["jxsc"], "image/jxsi": ["jxsi"], "image/jxss": ["jxss"], "image/ktx": ["ktx"], "image/ktx2": ["ktx2"], "image/png": ["png"], "image/sgi": ["sgi"], "image/svg+xml": ["svg", "svgz"], "image/t38": ["t38"], "image/tiff": ["tif", "tiff"], "image/tiff-fx": ["tfx"], "image/webp": ["webp"], "image/wmf": ["wmf"], "message/disposition-notification": ["disposition-notification"], "message/global": ["u8msg"], "message/global-delivery-status": ["u8dsn"], "message/global-disposition-notification": ["u8mdn"], "message/global-headers": ["u8hdr"], "message/rfc822": ["eml", "mime"], "model/3mf": ["3mf"], "model/gltf+json": ["gltf"], "model/gltf-binary": ["glb"], "model/iges": ["igs", "iges"], "model/mesh": ["msh", "mesh", "silo"], "model/mtl": ["mtl"], "model/obj": ["obj"], "model/step+xml": ["stpx"], "model/step+zip": ["stpz"], "model/step-xml+zip": ["stpxz"], "model/stl": ["stl"], "model/vrml": ["wrl", "vrml"], "model/x3d+binary": ["*x3db", "x3dbz"], "model/x3d+fastinfoset": ["x3db"], "model/x3d+vrml": ["*x3dv", "x3dvz"], "model/x3d+xml": ["x3d", "x3dz"], "model/x3d-vrml": ["x3dv"], "text/cache-manifest": ["appcache", "manifest"], "text/calendar": ["ics", "ifb"], "text/coffeescript": ["coffee", "litcoffee"], "text/css": ["css"], "text/csv": ["csv"], "text/html": ["html", "htm", "shtml"], "text/jade": ["jade"], "text/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["markdown", "md"], "text/mathml": ["mml"], "text/mdx": ["mdx"], "text/n3": ["n3"], "text/plain": ["txt", "text", "conf", "def", "list", "log", "in", "ini"], "text/richtext": ["rtx"], "text/rtf": ["*rtf"], "text/sgml": ["sgml", "sgm"], "text/shex": ["shex"], "text/slim": ["slim", "slm"], "text/spdx": ["spdx"], "text/stylus": ["stylus", "styl"], "text/tab-separated-values": ["tsv"], "text/troff": ["t", "tr", "roff", "man", "me", "ms"], "text/turtle": ["ttl"], "text/uri-list": ["uri", "uris", "urls"], "text/vcard": ["vcard"], "text/vtt": ["vtt"], "text/xml": ["*xml"], "text/yaml": ["yaml", "yml"], "video/3gpp": ["3gp", "3gpp"], "video/3gpp2": ["3g2"], "video/h261": ["h261"], "video/h263": ["h263"], "video/h264": ["h264"], "video/iso.segment": ["m4s"], "video/jpeg": ["jpgv"], "video/jpm": ["*jpm", "jpgm"], "video/mj2": ["mj2", "mjp2"], "video/mp2t": ["ts"], "video/mp4": ["mp4", "mp4v", "mpg4"], "video/mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v"], "video/ogg": ["ogv"], "video/quicktime": ["qt", "mov"], "video/webm": ["webm"] };
163
+ let Ar = Fr;
164
+ var Br = new Ar(_r);
165
+ const Sr = /* @__PURE__ */ Ot(Br);
166
+ var Q = { exports: {} };
167
+ typeof Object.create == "function" ? Q.exports = function(a, s) {
168
+ s && (a.super_ = s, a.prototype = Object.create(s.prototype, {
169
+ constructor: {
170
+ value: a,
171
+ enumerable: !1,
172
+ writable: !0,
173
+ configurable: !0
174
+ }
175
+ }));
176
+ } : Q.exports = function(a, s) {
177
+ if (s) {
178
+ a.super_ = s;
179
+ var c = function() {
180
+ };
181
+ c.prototype = s.prototype, a.prototype = new c(), a.prototype.constructor = a;
182
+ }
183
+ };
184
+ var jr = Q.exports, tt = { exports: {} }, Nt = {}, J = {};
185
+ J.byteLength = kr;
186
+ J.toByteArray = Dr;
187
+ J.fromByteArray = Mr;
188
+ var k = [], j = [], Ur = typeof Uint8Array < "u" ? Uint8Array : Array, V = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
189
+ for (var D = 0, Ir = V.length; D < Ir; ++D)
190
+ k[D] = V[D], j[V.charCodeAt(D)] = D;
191
+ j["-".charCodeAt(0)] = 62;
192
+ j["_".charCodeAt(0)] = 63;
193
+ function Mt(n) {
194
+ var a = n.length;
195
+ if (a % 4 > 0)
196
+ throw new Error("Invalid string. Length must be a multiple of 4");
197
+ var s = n.indexOf("=");
198
+ s === -1 && (s = a);
199
+ var c = s === a ? 0 : 4 - s % 4;
200
+ return [s, c];
201
+ }
202
+ function kr(n) {
203
+ var a = Mt(n), s = a[0], c = a[1];
204
+ return (s + c) * 3 / 4 - c;
205
+ }
206
+ function Tr(n, a, s) {
207
+ return (a + s) * 3 / 4 - s;
208
+ }
209
+ function Dr(n) {
210
+ var a, s = Mt(n), c = s[0], f = s[1], m = new Ur(Tr(n, c, f)), u = 0, o = f > 0 ? c - 4 : c, x;
211
+ for (x = 0; x < o; x += 4)
212
+ a = j[n.charCodeAt(x)] << 18 | j[n.charCodeAt(x + 1)] << 12 | j[n.charCodeAt(x + 2)] << 6 | j[n.charCodeAt(x + 3)], m[u++] = a >> 16 & 255, m[u++] = a >> 8 & 255, m[u++] = a & 255;
213
+ return f === 2 && (a = j[n.charCodeAt(x)] << 2 | j[n.charCodeAt(x + 1)] >> 4, m[u++] = a & 255), f === 1 && (a = j[n.charCodeAt(x)] << 10 | j[n.charCodeAt(x + 1)] << 4 | j[n.charCodeAt(x + 2)] >> 2, m[u++] = a >> 8 & 255, m[u++] = a & 255), m;
214
+ }
215
+ function Or(n) {
216
+ return k[n >> 18 & 63] + k[n >> 12 & 63] + k[n >> 6 & 63] + k[n & 63];
217
+ }
218
+ function Nr(n, a, s) {
219
+ for (var c, f = [], m = a; m < s; m += 3)
220
+ c = (n[m] << 16 & 16711680) + (n[m + 1] << 8 & 65280) + (n[m + 2] & 255), f.push(Or(c));
221
+ return f.join("");
222
+ }
223
+ function Mr(n) {
224
+ for (var a, s = n.length, c = s % 3, f = [], m = 16383, u = 0, o = s - c; u < o; u += m)
225
+ f.push(Nr(n, u, u + m > o ? o : u + m));
226
+ return c === 1 ? (a = n[s - 1], f.push(
227
+ k[a >> 2] + k[a << 4 & 63] + "=="
228
+ )) : c === 2 && (a = (n[s - 2] << 8) + n[s - 1], f.push(
229
+ k[a >> 10] + k[a >> 4 & 63] + k[a << 2 & 63] + "="
230
+ )), f.join("");
231
+ }
232
+ var ot = {};
233
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
234
+ ot.read = function(n, a, s, c, f) {
235
+ var m, u, o = f * 8 - c - 1, x = (1 << o) - 1, y = x >> 1, v = -7, F = s ? f - 1 : 0, U = s ? -1 : 1, B = n[a + F];
236
+ for (F += U, m = B & (1 << -v) - 1, B >>= -v, v += o; v > 0; m = m * 256 + n[a + F], F += U, v -= 8)
237
+ ;
238
+ for (u = m & (1 << -v) - 1, m >>= -v, v += c; v > 0; u = u * 256 + n[a + F], F += U, v -= 8)
239
+ ;
240
+ if (m === 0)
241
+ m = 1 - y;
242
+ else {
243
+ if (m === x)
244
+ return u ? NaN : (B ? -1 : 1) * (1 / 0);
245
+ u = u + Math.pow(2, c), m = m - y;
246
+ }
247
+ return (B ? -1 : 1) * u * Math.pow(2, m - c);
248
+ };
249
+ ot.write = function(n, a, s, c, f, m) {
250
+ var u, o, x, y = m * 8 - f - 1, v = (1 << y) - 1, F = v >> 1, U = f === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, B = c ? 0 : m - 1, O = c ? 1 : -1, N = a < 0 || a === 0 && 1 / a < 0 ? 1 : 0;
251
+ for (a = Math.abs(a), isNaN(a) || a === 1 / 0 ? (o = isNaN(a) ? 1 : 0, u = v) : (u = Math.floor(Math.log(a) / Math.LN2), a * (x = Math.pow(2, -u)) < 1 && (u--, x *= 2), u + F >= 1 ? a += U / x : a += U * Math.pow(2, 1 - F), a * x >= 2 && (u++, x /= 2), u + F >= v ? (o = 0, u = v) : u + F >= 1 ? (o = (a * x - 1) * Math.pow(2, f), u = u + F) : (o = a * Math.pow(2, F - 1) * Math.pow(2, f), u = 0)); f >= 8; n[s + B] = o & 255, B += O, o /= 256, f -= 8)
252
+ ;
253
+ for (u = u << f | o, y += f; y > 0; n[s + B] = u & 255, B += O, u /= 256, y -= 8)
254
+ ;
255
+ n[s + B - O] |= N * 128;
256
+ };
257
+ /*!
258
+ * The buffer module from node.js, for the browser.
259
+ *
260
+ * @author Feross Aboukhadijeh <https://feross.org>
261
+ * @license MIT
262
+ */
263
+ (function(n) {
264
+ var a = J, s = ot, c = typeof Symbol == "function" && typeof Symbol.for == "function" ? Symbol.for("nodejs.util.inspect.custom") : null;
265
+ n.Buffer = o, n.SlowBuffer = Xt, n.INSPECT_MAX_BYTES = 50;
266
+ var f = 2147483647;
267
+ n.kMaxLength = f, o.TYPED_ARRAY_SUPPORT = m(), !o.TYPED_ARRAY_SUPPORT && typeof console < "u" && typeof console.error == "function" && console.error(
268
+ "This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
269
+ );
270
+ function m() {
271
+ try {
272
+ var i = new Uint8Array(1), t = { foo: function() {
273
+ return 42;
274
+ } };
275
+ return Object.setPrototypeOf(t, Uint8Array.prototype), Object.setPrototypeOf(i, t), i.foo() === 42;
276
+ } catch {
277
+ return !1;
278
+ }
279
+ }
280
+ Object.defineProperty(o.prototype, "parent", {
281
+ enumerable: !0,
282
+ get: function() {
283
+ if (o.isBuffer(this))
284
+ return this.buffer;
285
+ }
286
+ }), Object.defineProperty(o.prototype, "offset", {
287
+ enumerable: !0,
288
+ get: function() {
289
+ if (o.isBuffer(this))
290
+ return this.byteOffset;
291
+ }
292
+ });
293
+ function u(i) {
294
+ if (i > f)
295
+ throw new RangeError('The value "' + i + '" is invalid for option "size"');
296
+ var t = new Uint8Array(i);
297
+ return Object.setPrototypeOf(t, o.prototype), t;
298
+ }
299
+ function o(i, t, r) {
300
+ if (typeof i == "number") {
301
+ if (typeof t == "string")
302
+ throw new TypeError(
303
+ 'The "string" argument must be of type string. Received type number'
304
+ );
305
+ return F(i);
306
+ }
307
+ return x(i, t, r);
308
+ }
309
+ o.poolSize = 8192;
310
+ function x(i, t, r) {
311
+ if (typeof i == "string")
312
+ return U(i, t);
313
+ if (ArrayBuffer.isView(i))
314
+ return O(i);
315
+ if (i == null)
316
+ throw new TypeError(
317
+ "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof i
318
+ );
319
+ if (I(i, ArrayBuffer) || i && I(i.buffer, ArrayBuffer) || typeof SharedArrayBuffer < "u" && (I(i, SharedArrayBuffer) || i && I(i.buffer, SharedArrayBuffer)))
320
+ return N(i, t, r);
321
+ if (typeof i == "number")
322
+ throw new TypeError(
323
+ 'The "value" argument must not be of type number. Received type number'
324
+ );
325
+ var e = i.valueOf && i.valueOf();
326
+ if (e != null && e !== i)
327
+ return o.from(e, t, r);
328
+ var p = Kt(i);
329
+ if (p)
330
+ return p;
331
+ if (typeof Symbol < "u" && Symbol.toPrimitive != null && typeof i[Symbol.toPrimitive] == "function")
332
+ return o.from(
333
+ i[Symbol.toPrimitive]("string"),
334
+ t,
335
+ r
336
+ );
337
+ throw new TypeError(
338
+ "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof i
339
+ );
340
+ }
341
+ o.from = function(i, t, r) {
342
+ return x(i, t, r);
343
+ }, Object.setPrototypeOf(o.prototype, Uint8Array.prototype), Object.setPrototypeOf(o, Uint8Array);
344
+ function y(i) {
345
+ if (typeof i != "number")
346
+ throw new TypeError('"size" argument must be of type number');
347
+ if (i < 0)
348
+ throw new RangeError('The value "' + i + '" is invalid for option "size"');
349
+ }
350
+ function v(i, t, r) {
351
+ return y(i), i <= 0 ? u(i) : t !== void 0 ? typeof r == "string" ? u(i).fill(t, r) : u(i).fill(t) : u(i);
352
+ }
353
+ o.alloc = function(i, t, r) {
354
+ return v(i, t, r);
355
+ };
356
+ function F(i) {
357
+ return y(i), u(i < 0 ? 0 : Y(i) | 0);
358
+ }
359
+ o.allocUnsafe = function(i) {
360
+ return F(i);
361
+ }, o.allocUnsafeSlow = function(i) {
362
+ return F(i);
363
+ };
364
+ function U(i, t) {
365
+ if ((typeof t != "string" || t === "") && (t = "utf8"), !o.isEncoding(t))
366
+ throw new TypeError("Unknown encoding: " + t);
367
+ var r = ct(i, t) | 0, e = u(r), p = e.write(i, t);
368
+ return p !== r && (e = e.slice(0, p)), e;
369
+ }
370
+ function B(i) {
371
+ for (var t = i.length < 0 ? 0 : Y(i.length) | 0, r = u(t), e = 0; e < t; e += 1)
372
+ r[e] = i[e] & 255;
373
+ return r;
374
+ }
375
+ function O(i) {
376
+ if (I(i, Uint8Array)) {
377
+ var t = new Uint8Array(i);
378
+ return N(t.buffer, t.byteOffset, t.byteLength);
379
+ }
380
+ return B(i);
381
+ }
382
+ function N(i, t, r) {
383
+ if (t < 0 || i.byteLength < t)
384
+ throw new RangeError('"offset" is outside of buffer bounds');
385
+ if (i.byteLength < t + (r || 0))
386
+ throw new RangeError('"length" is outside of buffer bounds');
387
+ var e;
388
+ return t === void 0 && r === void 0 ? e = new Uint8Array(i) : r === void 0 ? e = new Uint8Array(i, t) : e = new Uint8Array(i, t, r), Object.setPrototypeOf(e, o.prototype), e;
389
+ }
390
+ function Kt(i) {
391
+ if (o.isBuffer(i)) {
392
+ var t = Y(i.length) | 0, r = u(t);
393
+ return r.length === 0 || i.copy(r, 0, 0, t), r;
394
+ }
395
+ if (i.length !== void 0)
396
+ return typeof i.length != "number" || X(i.length) ? u(0) : B(i);
397
+ if (i.type === "Buffer" && Array.isArray(i.data))
398
+ return B(i.data);
399
+ }
400
+ function Y(i) {
401
+ if (i >= f)
402
+ throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + f.toString(16) + " bytes");
403
+ return i | 0;
404
+ }
405
+ function Xt(i) {
406
+ return +i != i && (i = 0), o.alloc(+i);
407
+ }
408
+ o.isBuffer = function(t) {
409
+ return t != null && t._isBuffer === !0 && t !== o.prototype;
410
+ }, o.compare = function(t, r) {
411
+ if (I(t, Uint8Array) && (t = o.from(t, t.offset, t.byteLength)), I(r, Uint8Array) && (r = o.from(r, r.offset, r.byteLength)), !o.isBuffer(t) || !o.isBuffer(r))
412
+ throw new TypeError(
413
+ 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
414
+ );
415
+ if (t === r)
416
+ return 0;
417
+ for (var e = t.length, p = r.length, l = 0, h = Math.min(e, p); l < h; ++l)
418
+ if (t[l] !== r[l]) {
419
+ e = t[l], p = r[l];
420
+ break;
421
+ }
422
+ return e < p ? -1 : p < e ? 1 : 0;
423
+ }, o.isEncoding = function(t) {
424
+ switch (String(t).toLowerCase()) {
425
+ case "hex":
426
+ case "utf8":
427
+ case "utf-8":
428
+ case "ascii":
429
+ case "latin1":
430
+ case "binary":
431
+ case "base64":
432
+ case "ucs2":
433
+ case "ucs-2":
434
+ case "utf16le":
435
+ case "utf-16le":
436
+ return !0;
437
+ default:
438
+ return !1;
439
+ }
440
+ }, o.concat = function(t, r) {
441
+ if (!Array.isArray(t))
442
+ throw new TypeError('"list" argument must be an Array of Buffers');
443
+ if (t.length === 0)
444
+ return o.alloc(0);
445
+ var e;
446
+ if (r === void 0)
447
+ for (r = 0, e = 0; e < t.length; ++e)
448
+ r += t[e].length;
449
+ var p = o.allocUnsafe(r), l = 0;
450
+ for (e = 0; e < t.length; ++e) {
451
+ var h = t[e];
452
+ if (I(h, Uint8Array))
453
+ l + h.length > p.length ? o.from(h).copy(p, l) : Uint8Array.prototype.set.call(
454
+ p,
455
+ h,
456
+ l
457
+ );
458
+ else if (o.isBuffer(h))
459
+ h.copy(p, l);
460
+ else
461
+ throw new TypeError('"list" argument must be an Array of Buffers');
462
+ l += h.length;
463
+ }
464
+ return p;
465
+ };
466
+ function ct(i, t) {
467
+ if (o.isBuffer(i))
468
+ return i.length;
469
+ if (ArrayBuffer.isView(i) || I(i, ArrayBuffer))
470
+ return i.byteLength;
471
+ if (typeof i != "string")
472
+ throw new TypeError(
473
+ 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof i
474
+ );
475
+ var r = i.length, e = arguments.length > 2 && arguments[2] === !0;
476
+ if (!e && r === 0)
477
+ return 0;
478
+ for (var p = !1; ; )
479
+ switch (t) {
480
+ case "ascii":
481
+ case "latin1":
482
+ case "binary":
483
+ return r;
484
+ case "utf8":
485
+ case "utf-8":
486
+ return K(i).length;
487
+ case "ucs2":
488
+ case "ucs-2":
489
+ case "utf16le":
490
+ case "utf-16le":
491
+ return r * 2;
492
+ case "hex":
493
+ return r >>> 1;
494
+ case "base64":
495
+ return wt(i).length;
496
+ default:
497
+ if (p)
498
+ return e ? -1 : K(i).length;
499
+ t = ("" + t).toLowerCase(), p = !0;
500
+ }
501
+ }
502
+ o.byteLength = ct;
503
+ function Gt(i, t, r) {
504
+ var e = !1;
505
+ if ((t === void 0 || t < 0) && (t = 0), t > this.length || ((r === void 0 || r > this.length) && (r = this.length), r <= 0) || (r >>>= 0, t >>>= 0, r <= t))
506
+ return "";
507
+ for (i || (i = "utf8"); ; )
508
+ switch (i) {
509
+ case "hex":
510
+ return pr(this, t, r);
511
+ case "utf8":
512
+ case "utf-8":
513
+ return ft(this, t, r);
514
+ case "ascii":
515
+ return ar(this, t, r);
516
+ case "latin1":
517
+ case "binary":
518
+ return or(this, t, r);
519
+ case "base64":
520
+ return er(this, t, r);
521
+ case "ucs2":
522
+ case "ucs-2":
523
+ case "utf16le":
524
+ case "utf-16le":
525
+ return sr(this, t, r);
526
+ default:
527
+ if (e)
528
+ throw new TypeError("Unknown encoding: " + i);
529
+ i = (i + "").toLowerCase(), e = !0;
530
+ }
531
+ }
532
+ o.prototype._isBuffer = !0;
533
+ function T(i, t, r) {
534
+ var e = i[t];
535
+ i[t] = i[r], i[r] = e;
536
+ }
537
+ o.prototype.swap16 = function() {
538
+ var t = this.length;
539
+ if (t % 2 !== 0)
540
+ throw new RangeError("Buffer size must be a multiple of 16-bits");
541
+ for (var r = 0; r < t; r += 2)
542
+ T(this, r, r + 1);
543
+ return this;
544
+ }, o.prototype.swap32 = function() {
545
+ var t = this.length;
546
+ if (t % 4 !== 0)
547
+ throw new RangeError("Buffer size must be a multiple of 32-bits");
548
+ for (var r = 0; r < t; r += 4)
549
+ T(this, r, r + 3), T(this, r + 1, r + 2);
550
+ return this;
551
+ }, o.prototype.swap64 = function() {
552
+ var t = this.length;
553
+ if (t % 8 !== 0)
554
+ throw new RangeError("Buffer size must be a multiple of 64-bits");
555
+ for (var r = 0; r < t; r += 8)
556
+ T(this, r, r + 7), T(this, r + 1, r + 6), T(this, r + 2, r + 5), T(this, r + 3, r + 4);
557
+ return this;
558
+ }, o.prototype.toString = function() {
559
+ var t = this.length;
560
+ return t === 0 ? "" : arguments.length === 0 ? ft(this, 0, t) : Gt.apply(this, arguments);
561
+ }, o.prototype.toLocaleString = o.prototype.toString, o.prototype.equals = function(t) {
562
+ if (!o.isBuffer(t))
563
+ throw new TypeError("Argument must be a Buffer");
564
+ return this === t ? !0 : o.compare(this, t) === 0;
565
+ }, o.prototype.inspect = function() {
566
+ var t = "", r = n.INSPECT_MAX_BYTES;
567
+ return t = this.toString("hex", 0, r).replace(/(.{2})/g, "$1 ").trim(), this.length > r && (t += " ... "), "<Buffer " + t + ">";
568
+ }, c && (o.prototype[c] = o.prototype.inspect), o.prototype.compare = function(t, r, e, p, l) {
569
+ if (I(t, Uint8Array) && (t = o.from(t, t.offset, t.byteLength)), !o.isBuffer(t))
570
+ throw new TypeError(
571
+ 'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof t
572
+ );
573
+ if (r === void 0 && (r = 0), e === void 0 && (e = t ? t.length : 0), p === void 0 && (p = 0), l === void 0 && (l = this.length), r < 0 || e > t.length || p < 0 || l > this.length)
574
+ throw new RangeError("out of range index");
575
+ if (p >= l && r >= e)
576
+ return 0;
577
+ if (p >= l)
578
+ return -1;
579
+ if (r >= e)
580
+ return 1;
581
+ if (r >>>= 0, e >>>= 0, p >>>= 0, l >>>= 0, this === t)
582
+ return 0;
583
+ for (var h = l - p, w = e - r, g = Math.min(h, w), E = this.slice(p, l), A = t.slice(r, e), b = 0; b < g; ++b)
584
+ if (E[b] !== A[b]) {
585
+ h = E[b], w = A[b];
586
+ break;
587
+ }
588
+ return h < w ? -1 : w < h ? 1 : 0;
589
+ };
590
+ function lt(i, t, r, e, p) {
591
+ if (i.length === 0)
592
+ return -1;
593
+ if (typeof r == "string" ? (e = r, r = 0) : r > 2147483647 ? r = 2147483647 : r < -2147483648 && (r = -2147483648), r = +r, X(r) && (r = p ? 0 : i.length - 1), r < 0 && (r = i.length + r), r >= i.length) {
594
+ if (p)
595
+ return -1;
596
+ r = i.length - 1;
597
+ } else if (r < 0)
598
+ if (p)
599
+ r = 0;
600
+ else
601
+ return -1;
602
+ if (typeof t == "string" && (t = o.from(t, e)), o.isBuffer(t))
603
+ return t.length === 0 ? -1 : ut(i, t, r, e, p);
604
+ if (typeof t == "number")
605
+ return t = t & 255, typeof Uint8Array.prototype.indexOf == "function" ? p ? Uint8Array.prototype.indexOf.call(i, t, r) : Uint8Array.prototype.lastIndexOf.call(i, t, r) : ut(i, [t], r, e, p);
606
+ throw new TypeError("val must be string, number or Buffer");
607
+ }
608
+ function ut(i, t, r, e, p) {
609
+ var l = 1, h = i.length, w = t.length;
610
+ if (e !== void 0 && (e = String(e).toLowerCase(), e === "ucs2" || e === "ucs-2" || e === "utf16le" || e === "utf-16le")) {
611
+ if (i.length < 2 || t.length < 2)
612
+ return -1;
613
+ l = 2, h /= 2, w /= 2, r /= 2;
614
+ }
615
+ function g(yt, gt) {
616
+ return l === 1 ? yt[gt] : yt.readUInt16BE(gt * l);
617
+ }
618
+ var E;
619
+ if (p) {
620
+ var A = -1;
621
+ for (E = r; E < h; E++)
622
+ if (g(i, E) === g(t, A === -1 ? 0 : E - A)) {
623
+ if (A === -1 && (A = E), E - A + 1 === w)
624
+ return A * l;
625
+ } else
626
+ A !== -1 && (E -= E - A), A = -1;
627
+ } else
628
+ for (r + w > h && (r = h - w), E = r; E >= 0; E--) {
629
+ for (var b = !0, z = 0; z < w; z++)
630
+ if (g(i, E + z) !== g(t, z)) {
631
+ b = !1;
632
+ break;
633
+ }
634
+ if (b)
635
+ return E;
636
+ }
637
+ return -1;
638
+ }
639
+ o.prototype.includes = function(t, r, e) {
640
+ return this.indexOf(t, r, e) !== -1;
641
+ }, o.prototype.indexOf = function(t, r, e) {
642
+ return lt(this, t, r, e, !0);
643
+ }, o.prototype.lastIndexOf = function(t, r, e) {
644
+ return lt(this, t, r, e, !1);
645
+ };
646
+ function Vt(i, t, r, e) {
647
+ r = Number(r) || 0;
648
+ var p = i.length - r;
649
+ e ? (e = Number(e), e > p && (e = p)) : e = p;
650
+ var l = t.length;
651
+ e > l / 2 && (e = l / 2);
652
+ for (var h = 0; h < e; ++h) {
653
+ var w = parseInt(t.substr(h * 2, 2), 16);
654
+ if (X(w))
655
+ return h;
656
+ i[r + h] = w;
657
+ }
658
+ return h;
659
+ }
660
+ function Qt(i, t, r, e) {
661
+ return L(K(t, i.length - r), i, r, e);
662
+ }
663
+ function tr(i, t, r, e) {
664
+ return L(ur(t), i, r, e);
665
+ }
666
+ function rr(i, t, r, e) {
667
+ return L(wt(t), i, r, e);
668
+ }
669
+ function ir(i, t, r, e) {
670
+ return L(fr(t, i.length - r), i, r, e);
671
+ }
672
+ o.prototype.write = function(t, r, e, p) {
673
+ if (r === void 0)
674
+ p = "utf8", e = this.length, r = 0;
675
+ else if (e === void 0 && typeof r == "string")
676
+ p = r, e = this.length, r = 0;
677
+ else if (isFinite(r))
678
+ r = r >>> 0, isFinite(e) ? (e = e >>> 0, p === void 0 && (p = "utf8")) : (p = e, e = void 0);
679
+ else
680
+ throw new Error(
681
+ "Buffer.write(string, encoding, offset[, length]) is no longer supported"
682
+ );
683
+ var l = this.length - r;
684
+ if ((e === void 0 || e > l) && (e = l), t.length > 0 && (e < 0 || r < 0) || r > this.length)
685
+ throw new RangeError("Attempt to write outside buffer bounds");
686
+ p || (p = "utf8");
687
+ for (var h = !1; ; )
688
+ switch (p) {
689
+ case "hex":
690
+ return Vt(this, t, r, e);
691
+ case "utf8":
692
+ case "utf-8":
693
+ return Qt(this, t, r, e);
694
+ case "ascii":
695
+ case "latin1":
696
+ case "binary":
697
+ return tr(this, t, r, e);
698
+ case "base64":
699
+ return rr(this, t, r, e);
700
+ case "ucs2":
701
+ case "ucs-2":
702
+ case "utf16le":
703
+ case "utf-16le":
704
+ return ir(this, t, r, e);
705
+ default:
706
+ if (h)
707
+ throw new TypeError("Unknown encoding: " + p);
708
+ p = ("" + p).toLowerCase(), h = !0;
709
+ }
710
+ }, o.prototype.toJSON = function() {
711
+ return {
712
+ type: "Buffer",
713
+ data: Array.prototype.slice.call(this._arr || this, 0)
714
+ };
715
+ };
716
+ function er(i, t, r) {
717
+ return t === 0 && r === i.length ? a.fromByteArray(i) : a.fromByteArray(i.slice(t, r));
718
+ }
719
+ function ft(i, t, r) {
720
+ r = Math.min(i.length, r);
721
+ for (var e = [], p = t; p < r; ) {
722
+ var l = i[p], h = null, w = l > 239 ? 4 : l > 223 ? 3 : l > 191 ? 2 : 1;
723
+ if (p + w <= r) {
724
+ var g, E, A, b;
725
+ switch (w) {
726
+ case 1:
727
+ l < 128 && (h = l);
728
+ break;
729
+ case 2:
730
+ g = i[p + 1], (g & 192) === 128 && (b = (l & 31) << 6 | g & 63, b > 127 && (h = b));
731
+ break;
732
+ case 3:
733
+ g = i[p + 1], E = i[p + 2], (g & 192) === 128 && (E & 192) === 128 && (b = (l & 15) << 12 | (g & 63) << 6 | E & 63, b > 2047 && (b < 55296 || b > 57343) && (h = b));
734
+ break;
735
+ case 4:
736
+ g = i[p + 1], E = i[p + 2], A = i[p + 3], (g & 192) === 128 && (E & 192) === 128 && (A & 192) === 128 && (b = (l & 15) << 18 | (g & 63) << 12 | (E & 63) << 6 | A & 63, b > 65535 && b < 1114112 && (h = b));
737
+ }
738
+ }
739
+ h === null ? (h = 65533, w = 1) : h > 65535 && (h -= 65536, e.push(h >>> 10 & 1023 | 55296), h = 56320 | h & 1023), e.push(h), p += w;
740
+ }
741
+ return nr(e);
742
+ }
743
+ var ht = 4096;
744
+ function nr(i) {
745
+ var t = i.length;
746
+ if (t <= ht)
747
+ return String.fromCharCode.apply(String, i);
748
+ for (var r = "", e = 0; e < t; )
749
+ r += String.fromCharCode.apply(
750
+ String,
751
+ i.slice(e, e += ht)
752
+ );
753
+ return r;
754
+ }
755
+ function ar(i, t, r) {
756
+ var e = "";
757
+ r = Math.min(i.length, r);
758
+ for (var p = t; p < r; ++p)
759
+ e += String.fromCharCode(i[p] & 127);
760
+ return e;
761
+ }
762
+ function or(i, t, r) {
763
+ var e = "";
764
+ r = Math.min(i.length, r);
765
+ for (var p = t; p < r; ++p)
766
+ e += String.fromCharCode(i[p]);
767
+ return e;
768
+ }
769
+ function pr(i, t, r) {
770
+ var e = i.length;
771
+ (!t || t < 0) && (t = 0), (!r || r < 0 || r > e) && (r = e);
772
+ for (var p = "", l = t; l < r; ++l)
773
+ p += hr[i[l]];
774
+ return p;
775
+ }
776
+ function sr(i, t, r) {
777
+ for (var e = i.slice(t, r), p = "", l = 0; l < e.length - 1; l += 2)
778
+ p += String.fromCharCode(e[l] + e[l + 1] * 256);
779
+ return p;
780
+ }
781
+ o.prototype.slice = function(t, r) {
782
+ var e = this.length;
783
+ t = ~~t, r = r === void 0 ? e : ~~r, t < 0 ? (t += e, t < 0 && (t = 0)) : t > e && (t = e), r < 0 ? (r += e, r < 0 && (r = 0)) : r > e && (r = e), r < t && (r = t);
784
+ var p = this.subarray(t, r);
785
+ return Object.setPrototypeOf(p, o.prototype), p;
786
+ };
787
+ function _(i, t, r) {
788
+ if (i % 1 !== 0 || i < 0)
789
+ throw new RangeError("offset is not uint");
790
+ if (i + t > r)
791
+ throw new RangeError("Trying to access beyond buffer length");
792
+ }
793
+ o.prototype.readUintLE = o.prototype.readUIntLE = function(t, r, e) {
794
+ t = t >>> 0, r = r >>> 0, e || _(t, r, this.length);
795
+ for (var p = this[t], l = 1, h = 0; ++h < r && (l *= 256); )
796
+ p += this[t + h] * l;
797
+ return p;
798
+ }, o.prototype.readUintBE = o.prototype.readUIntBE = function(t, r, e) {
799
+ t = t >>> 0, r = r >>> 0, e || _(t, r, this.length);
800
+ for (var p = this[t + --r], l = 1; r > 0 && (l *= 256); )
801
+ p += this[t + --r] * l;
802
+ return p;
803
+ }, o.prototype.readUint8 = o.prototype.readUInt8 = function(t, r) {
804
+ return t = t >>> 0, r || _(t, 1, this.length), this[t];
805
+ }, o.prototype.readUint16LE = o.prototype.readUInt16LE = function(t, r) {
806
+ return t = t >>> 0, r || _(t, 2, this.length), this[t] | this[t + 1] << 8;
807
+ }, o.prototype.readUint16BE = o.prototype.readUInt16BE = function(t, r) {
808
+ return t = t >>> 0, r || _(t, 2, this.length), this[t] << 8 | this[t + 1];
809
+ }, o.prototype.readUint32LE = o.prototype.readUInt32LE = function(t, r) {
810
+ return t = t >>> 0, r || _(t, 4, this.length), (this[t] | this[t + 1] << 8 | this[t + 2] << 16) + this[t + 3] * 16777216;
811
+ }, o.prototype.readUint32BE = o.prototype.readUInt32BE = function(t, r) {
812
+ return t = t >>> 0, r || _(t, 4, this.length), this[t] * 16777216 + (this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3]);
813
+ }, o.prototype.readIntLE = function(t, r, e) {
814
+ t = t >>> 0, r = r >>> 0, e || _(t, r, this.length);
815
+ for (var p = this[t], l = 1, h = 0; ++h < r && (l *= 256); )
816
+ p += this[t + h] * l;
817
+ return l *= 128, p >= l && (p -= Math.pow(2, 8 * r)), p;
818
+ }, o.prototype.readIntBE = function(t, r, e) {
819
+ t = t >>> 0, r = r >>> 0, e || _(t, r, this.length);
820
+ for (var p = r, l = 1, h = this[t + --p]; p > 0 && (l *= 256); )
821
+ h += this[t + --p] * l;
822
+ return l *= 128, h >= l && (h -= Math.pow(2, 8 * r)), h;
823
+ }, o.prototype.readInt8 = function(t, r) {
824
+ return t = t >>> 0, r || _(t, 1, this.length), this[t] & 128 ? (255 - this[t] + 1) * -1 : this[t];
825
+ }, o.prototype.readInt16LE = function(t, r) {
826
+ t = t >>> 0, r || _(t, 2, this.length);
827
+ var e = this[t] | this[t + 1] << 8;
828
+ return e & 32768 ? e | 4294901760 : e;
829
+ }, o.prototype.readInt16BE = function(t, r) {
830
+ t = t >>> 0, r || _(t, 2, this.length);
831
+ var e = this[t + 1] | this[t] << 8;
832
+ return e & 32768 ? e | 4294901760 : e;
833
+ }, o.prototype.readInt32LE = function(t, r) {
834
+ return t = t >>> 0, r || _(t, 4, this.length), this[t] | this[t + 1] << 8 | this[t + 2] << 16 | this[t + 3] << 24;
835
+ }, o.prototype.readInt32BE = function(t, r) {
836
+ return t = t >>> 0, r || _(t, 4, this.length), this[t] << 24 | this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3];
837
+ }, o.prototype.readFloatLE = function(t, r) {
838
+ return t = t >>> 0, r || _(t, 4, this.length), s.read(this, t, !0, 23, 4);
839
+ }, o.prototype.readFloatBE = function(t, r) {
840
+ return t = t >>> 0, r || _(t, 4, this.length), s.read(this, t, !1, 23, 4);
841
+ }, o.prototype.readDoubleLE = function(t, r) {
842
+ return t = t >>> 0, r || _(t, 8, this.length), s.read(this, t, !0, 52, 8);
843
+ }, o.prototype.readDoubleBE = function(t, r) {
844
+ return t = t >>> 0, r || _(t, 8, this.length), s.read(this, t, !1, 52, 8);
845
+ };
846
+ function S(i, t, r, e, p, l) {
847
+ if (!o.isBuffer(i))
848
+ throw new TypeError('"buffer" argument must be a Buffer instance');
849
+ if (t > p || t < l)
850
+ throw new RangeError('"value" argument is out of bounds');
851
+ if (r + e > i.length)
852
+ throw new RangeError("Index out of range");
853
+ }
854
+ o.prototype.writeUintLE = o.prototype.writeUIntLE = function(t, r, e, p) {
855
+ if (t = +t, r = r >>> 0, e = e >>> 0, !p) {
856
+ var l = Math.pow(2, 8 * e) - 1;
857
+ S(this, t, r, e, l, 0);
858
+ }
859
+ var h = 1, w = 0;
860
+ for (this[r] = t & 255; ++w < e && (h *= 256); )
861
+ this[r + w] = t / h & 255;
862
+ return r + e;
863
+ }, o.prototype.writeUintBE = o.prototype.writeUIntBE = function(t, r, e, p) {
864
+ if (t = +t, r = r >>> 0, e = e >>> 0, !p) {
865
+ var l = Math.pow(2, 8 * e) - 1;
866
+ S(this, t, r, e, l, 0);
867
+ }
868
+ var h = e - 1, w = 1;
869
+ for (this[r + h] = t & 255; --h >= 0 && (w *= 256); )
870
+ this[r + h] = t / w & 255;
871
+ return r + e;
872
+ }, o.prototype.writeUint8 = o.prototype.writeUInt8 = function(t, r, e) {
873
+ return t = +t, r = r >>> 0, e || S(this, t, r, 1, 255, 0), this[r] = t & 255, r + 1;
874
+ }, o.prototype.writeUint16LE = o.prototype.writeUInt16LE = function(t, r, e) {
875
+ return t = +t, r = r >>> 0, e || S(this, t, r, 2, 65535, 0), this[r] = t & 255, this[r + 1] = t >>> 8, r + 2;
876
+ }, o.prototype.writeUint16BE = o.prototype.writeUInt16BE = function(t, r, e) {
877
+ return t = +t, r = r >>> 0, e || S(this, t, r, 2, 65535, 0), this[r] = t >>> 8, this[r + 1] = t & 255, r + 2;
878
+ }, o.prototype.writeUint32LE = o.prototype.writeUInt32LE = function(t, r, e) {
879
+ return t = +t, r = r >>> 0, e || S(this, t, r, 4, 4294967295, 0), this[r + 3] = t >>> 24, this[r + 2] = t >>> 16, this[r + 1] = t >>> 8, this[r] = t & 255, r + 4;
880
+ }, o.prototype.writeUint32BE = o.prototype.writeUInt32BE = function(t, r, e) {
881
+ return t = +t, r = r >>> 0, e || S(this, t, r, 4, 4294967295, 0), this[r] = t >>> 24, this[r + 1] = t >>> 16, this[r + 2] = t >>> 8, this[r + 3] = t & 255, r + 4;
882
+ }, o.prototype.writeIntLE = function(t, r, e, p) {
883
+ if (t = +t, r = r >>> 0, !p) {
884
+ var l = Math.pow(2, 8 * e - 1);
885
+ S(this, t, r, e, l - 1, -l);
886
+ }
887
+ var h = 0, w = 1, g = 0;
888
+ for (this[r] = t & 255; ++h < e && (w *= 256); )
889
+ t < 0 && g === 0 && this[r + h - 1] !== 0 && (g = 1), this[r + h] = (t / w >> 0) - g & 255;
890
+ return r + e;
891
+ }, o.prototype.writeIntBE = function(t, r, e, p) {
892
+ if (t = +t, r = r >>> 0, !p) {
893
+ var l = Math.pow(2, 8 * e - 1);
894
+ S(this, t, r, e, l - 1, -l);
895
+ }
896
+ var h = e - 1, w = 1, g = 0;
897
+ for (this[r + h] = t & 255; --h >= 0 && (w *= 256); )
898
+ t < 0 && g === 0 && this[r + h + 1] !== 0 && (g = 1), this[r + h] = (t / w >> 0) - g & 255;
899
+ return r + e;
900
+ }, o.prototype.writeInt8 = function(t, r, e) {
901
+ return t = +t, r = r >>> 0, e || S(this, t, r, 1, 127, -128), t < 0 && (t = 255 + t + 1), this[r] = t & 255, r + 1;
902
+ }, o.prototype.writeInt16LE = function(t, r, e) {
903
+ return t = +t, r = r >>> 0, e || S(this, t, r, 2, 32767, -32768), this[r] = t & 255, this[r + 1] = t >>> 8, r + 2;
904
+ }, o.prototype.writeInt16BE = function(t, r, e) {
905
+ return t = +t, r = r >>> 0, e || S(this, t, r, 2, 32767, -32768), this[r] = t >>> 8, this[r + 1] = t & 255, r + 2;
906
+ }, o.prototype.writeInt32LE = function(t, r, e) {
907
+ return t = +t, r = r >>> 0, e || S(this, t, r, 4, 2147483647, -2147483648), this[r] = t & 255, this[r + 1] = t >>> 8, this[r + 2] = t >>> 16, this[r + 3] = t >>> 24, r + 4;
908
+ }, o.prototype.writeInt32BE = function(t, r, e) {
909
+ return t = +t, r = r >>> 0, e || S(this, t, r, 4, 2147483647, -2147483648), t < 0 && (t = 4294967295 + t + 1), this[r] = t >>> 24, this[r + 1] = t >>> 16, this[r + 2] = t >>> 8, this[r + 3] = t & 255, r + 4;
910
+ };
911
+ function mt(i, t, r, e, p, l) {
912
+ if (r + e > i.length)
913
+ throw new RangeError("Index out of range");
914
+ if (r < 0)
915
+ throw new RangeError("Index out of range");
916
+ }
917
+ function xt(i, t, r, e, p) {
918
+ return t = +t, r = r >>> 0, p || mt(i, t, r, 4), s.write(i, t, r, e, 23, 4), r + 4;
919
+ }
920
+ o.prototype.writeFloatLE = function(t, r, e) {
921
+ return xt(this, t, r, !0, e);
922
+ }, o.prototype.writeFloatBE = function(t, r, e) {
923
+ return xt(this, t, r, !1, e);
924
+ };
925
+ function dt(i, t, r, e, p) {
926
+ return t = +t, r = r >>> 0, p || mt(i, t, r, 8), s.write(i, t, r, e, 52, 8), r + 8;
927
+ }
928
+ o.prototype.writeDoubleLE = function(t, r, e) {
929
+ return dt(this, t, r, !0, e);
930
+ }, o.prototype.writeDoubleBE = function(t, r, e) {
931
+ return dt(this, t, r, !1, e);
932
+ }, o.prototype.copy = function(t, r, e, p) {
933
+ if (!o.isBuffer(t))
934
+ throw new TypeError("argument should be a Buffer");
935
+ if (e || (e = 0), !p && p !== 0 && (p = this.length), r >= t.length && (r = t.length), r || (r = 0), p > 0 && p < e && (p = e), p === e || t.length === 0 || this.length === 0)
936
+ return 0;
937
+ if (r < 0)
938
+ throw new RangeError("targetStart out of bounds");
939
+ if (e < 0 || e >= this.length)
940
+ throw new RangeError("Index out of range");
941
+ if (p < 0)
942
+ throw new RangeError("sourceEnd out of bounds");
943
+ p > this.length && (p = this.length), t.length - r < p - e && (p = t.length - r + e);
944
+ var l = p - e;
945
+ return this === t && typeof Uint8Array.prototype.copyWithin == "function" ? this.copyWithin(r, e, p) : Uint8Array.prototype.set.call(
946
+ t,
947
+ this.subarray(e, p),
948
+ r
949
+ ), l;
950
+ }, o.prototype.fill = function(t, r, e, p) {
951
+ if (typeof t == "string") {
952
+ if (typeof r == "string" ? (p = r, r = 0, e = this.length) : typeof e == "string" && (p = e, e = this.length), p !== void 0 && typeof p != "string")
953
+ throw new TypeError("encoding must be a string");
954
+ if (typeof p == "string" && !o.isEncoding(p))
955
+ throw new TypeError("Unknown encoding: " + p);
956
+ if (t.length === 1) {
957
+ var l = t.charCodeAt(0);
958
+ (p === "utf8" && l < 128 || p === "latin1") && (t = l);
959
+ }
960
+ } else
961
+ typeof t == "number" ? t = t & 255 : typeof t == "boolean" && (t = Number(t));
962
+ if (r < 0 || this.length < r || this.length < e)
963
+ throw new RangeError("Out of range index");
964
+ if (e <= r)
965
+ return this;
966
+ r = r >>> 0, e = e === void 0 ? this.length : e >>> 0, t || (t = 0);
967
+ var h;
968
+ if (typeof t == "number")
969
+ for (h = r; h < e; ++h)
970
+ this[h] = t;
971
+ else {
972
+ var w = o.isBuffer(t) ? t : o.from(t, p), g = w.length;
973
+ if (g === 0)
974
+ throw new TypeError('The value "' + t + '" is invalid for argument "value"');
975
+ for (h = 0; h < e - r; ++h)
976
+ this[h + r] = w[h % g];
977
+ }
978
+ return this;
979
+ };
980
+ var cr = /[^+/0-9A-Za-z-_]/g;
981
+ function lr(i) {
982
+ if (i = i.split("=")[0], i = i.trim().replace(cr, ""), i.length < 2)
983
+ return "";
984
+ for (; i.length % 4 !== 0; )
985
+ i = i + "=";
986
+ return i;
987
+ }
988
+ function K(i, t) {
989
+ t = t || 1 / 0;
990
+ for (var r, e = i.length, p = null, l = [], h = 0; h < e; ++h) {
991
+ if (r = i.charCodeAt(h), r > 55295 && r < 57344) {
992
+ if (!p) {
993
+ if (r > 56319) {
994
+ (t -= 3) > -1 && l.push(239, 191, 189);
995
+ continue;
996
+ } else if (h + 1 === e) {
997
+ (t -= 3) > -1 && l.push(239, 191, 189);
998
+ continue;
999
+ }
1000
+ p = r;
1001
+ continue;
1002
+ }
1003
+ if (r < 56320) {
1004
+ (t -= 3) > -1 && l.push(239, 191, 189), p = r;
1005
+ continue;
1006
+ }
1007
+ r = (p - 55296 << 10 | r - 56320) + 65536;
1008
+ } else
1009
+ p && (t -= 3) > -1 && l.push(239, 191, 189);
1010
+ if (p = null, r < 128) {
1011
+ if ((t -= 1) < 0)
1012
+ break;
1013
+ l.push(r);
1014
+ } else if (r < 2048) {
1015
+ if ((t -= 2) < 0)
1016
+ break;
1017
+ l.push(
1018
+ r >> 6 | 192,
1019
+ r & 63 | 128
1020
+ );
1021
+ } else if (r < 65536) {
1022
+ if ((t -= 3) < 0)
1023
+ break;
1024
+ l.push(
1025
+ r >> 12 | 224,
1026
+ r >> 6 & 63 | 128,
1027
+ r & 63 | 128
1028
+ );
1029
+ } else if (r < 1114112) {
1030
+ if ((t -= 4) < 0)
1031
+ break;
1032
+ l.push(
1033
+ r >> 18 | 240,
1034
+ r >> 12 & 63 | 128,
1035
+ r >> 6 & 63 | 128,
1036
+ r & 63 | 128
1037
+ );
1038
+ } else
1039
+ throw new Error("Invalid code point");
1040
+ }
1041
+ return l;
1042
+ }
1043
+ function ur(i) {
1044
+ for (var t = [], r = 0; r < i.length; ++r)
1045
+ t.push(i.charCodeAt(r) & 255);
1046
+ return t;
1047
+ }
1048
+ function fr(i, t) {
1049
+ for (var r, e, p, l = [], h = 0; h < i.length && !((t -= 2) < 0); ++h)
1050
+ r = i.charCodeAt(h), e = r >> 8, p = r % 256, l.push(p), l.push(e);
1051
+ return l;
1052
+ }
1053
+ function wt(i) {
1054
+ return a.toByteArray(lr(i));
1055
+ }
1056
+ function L(i, t, r, e) {
1057
+ for (var p = 0; p < e && !(p + r >= t.length || p >= i.length); ++p)
1058
+ t[p + r] = i[p];
1059
+ return p;
1060
+ }
1061
+ function I(i, t) {
1062
+ return i instanceof t || i != null && i.constructor != null && i.constructor.name != null && i.constructor.name === t.name;
1063
+ }
1064
+ function X(i) {
1065
+ return i !== i;
1066
+ }
1067
+ var hr = function() {
1068
+ for (var i = "0123456789abcdef", t = new Array(256), r = 0; r < 16; ++r)
1069
+ for (var e = r * 16, p = 0; p < 16; ++p)
1070
+ t[e + p] = i[r] + i[p];
1071
+ return t;
1072
+ }();
1073
+ })(Nt);
1074
+ /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
1075
+ (function(n, a) {
1076
+ var s = Nt, c = s.Buffer;
1077
+ function f(u, o) {
1078
+ for (var x in u)
1079
+ o[x] = u[x];
1080
+ }
1081
+ c.from && c.alloc && c.allocUnsafe && c.allocUnsafeSlow ? n.exports = s : (f(s, a), a.Buffer = m);
1082
+ function m(u, o, x) {
1083
+ return c(u, o, x);
1084
+ }
1085
+ m.prototype = Object.create(c.prototype), f(c, m), m.from = function(u, o, x) {
1086
+ if (typeof u == "number")
1087
+ throw new TypeError("Argument must not be a number");
1088
+ return c(u, o, x);
1089
+ }, m.alloc = function(u, o, x) {
1090
+ if (typeof u != "number")
1091
+ throw new TypeError("Argument must be a number");
1092
+ var y = c(u);
1093
+ return o !== void 0 ? typeof x == "string" ? y.fill(o, x) : y.fill(o) : y.fill(0), y;
1094
+ }, m.allocUnsafe = function(u) {
1095
+ if (typeof u != "number")
1096
+ throw new TypeError("Argument must be a number");
1097
+ return c(u);
1098
+ }, m.allocUnsafeSlow = function(u) {
1099
+ if (typeof u != "number")
1100
+ throw new TypeError("Argument must be a number");
1101
+ return s.SlowBuffer(u);
1102
+ };
1103
+ })(tt, tt.exports);
1104
+ var Ct = tt.exports, Rt = Ct.Buffer;
1105
+ function P(n, a) {
1106
+ this._block = Rt.alloc(n), this._finalSize = a, this._blockSize = n, this._len = 0;
1107
+ }
1108
+ P.prototype.update = function(n, a) {
1109
+ typeof n == "string" && (a = a || "utf8", n = Rt.from(n, a));
1110
+ for (var s = this._block, c = this._blockSize, f = n.length, m = this._len, u = 0; u < f; ) {
1111
+ for (var o = m % c, x = Math.min(f - u, c - o), y = 0; y < x; y++)
1112
+ s[o + y] = n[u + y];
1113
+ m += x, u += x, m % c === 0 && this._update(s);
1114
+ }
1115
+ return this._len += f, this;
1116
+ };
1117
+ P.prototype.digest = function(n) {
1118
+ var a = this._len % this._blockSize;
1119
+ this._block[a] = 128, this._block.fill(0, a + 1), a >= this._finalSize && (this._update(this._block), this._block.fill(0));
1120
+ var s = this._len * 8;
1121
+ if (s <= 4294967295)
1122
+ this._block.writeUInt32BE(s, this._blockSize - 4);
1123
+ else {
1124
+ var c = (s & 4294967295) >>> 0, f = (s - c) / 4294967296;
1125
+ this._block.writeUInt32BE(f, this._blockSize - 8), this._block.writeUInt32BE(c, this._blockSize - 4);
1126
+ }
1127
+ this._update(this._block);
1128
+ var m = this._hash();
1129
+ return n ? m.toString(n) : m;
1130
+ };
1131
+ P.prototype._update = function() {
1132
+ throw new Error("_update must be implemented by subclass");
1133
+ };
1134
+ var Cr = P, Rr = jr, Lt = Cr, Lr = Ct.Buffer, zr = [
1135
+ 1518500249,
1136
+ 1859775393,
1137
+ -1894007588,
1138
+ -899497514
1139
+ ], qr = new Array(80);
1140
+ function C() {
1141
+ this.init(), this._w = qr, Lt.call(this, 64, 56);
1142
+ }
1143
+ Rr(C, Lt);
1144
+ C.prototype.init = function() {
1145
+ return this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520, this;
1146
+ };
1147
+ function $r(n) {
1148
+ return n << 1 | n >>> 31;
1149
+ }
1150
+ function Jr(n) {
1151
+ return n << 5 | n >>> 27;
1152
+ }
1153
+ function Pr(n) {
1154
+ return n << 30 | n >>> 2;
1155
+ }
1156
+ function Wr(n, a, s, c) {
1157
+ return n === 0 ? a & s | ~a & c : n === 2 ? a & s | a & c | s & c : a ^ s ^ c;
1158
+ }
1159
+ C.prototype._update = function(n) {
1160
+ for (var a = this._w, s = this._a | 0, c = this._b | 0, f = this._c | 0, m = this._d | 0, u = this._e | 0, o = 0; o < 16; ++o)
1161
+ a[o] = n.readInt32BE(o * 4);
1162
+ for (; o < 80; ++o)
1163
+ a[o] = $r(a[o - 3] ^ a[o - 8] ^ a[o - 14] ^ a[o - 16]);
1164
+ for (var x = 0; x < 80; ++x) {
1165
+ var y = ~~(x / 20), v = Jr(s) + Wr(y, c, f, m) + u + a[x] + zr[y] | 0;
1166
+ u = m, m = f, f = Pr(c), c = s, s = v;
1167
+ }
1168
+ this._a = s + this._a | 0, this._b = c + this._b | 0, this._c = f + this._c | 0, this._d = m + this._d | 0, this._e = u + this._e | 0;
1169
+ };
1170
+ C.prototype._hash = function() {
1171
+ var n = Lr.allocUnsafe(20);
1172
+ return n.writeInt32BE(this._a | 0, 0), n.writeInt32BE(this._b | 0, 4), n.writeInt32BE(this._c | 0, 8), n.writeInt32BE(this._d | 0, 12), n.writeInt32BE(this._e | 0, 16), n;
1173
+ };
1174
+ var Hr = C;
1175
+ const Zr = /* @__PURE__ */ Ot(Hr), pt = new Error("File system not available.");
1176
+ function Yr(n, a, s) {
1177
+ throw pt;
1178
+ }
1179
+ function zt(n) {
1180
+ throw pt;
1181
+ }
1182
+ function Kr(n) {
1183
+ throw pt;
1184
+ }
1185
+ const Xr = async (n) => zt();
1186
+ function Gr(n) {
1187
+ let a = "";
1188
+ for (let s = 0; s < n.length; s += 2)
1189
+ a += String.fromCharCode(parseInt(n.substr(s, 2), 16));
1190
+ return btoa(a);
1191
+ }
1192
+ const W = (n, a = "sha1") => {
1193
+ if (a !== "sha1")
1194
+ throw new Error("Only sha1 algorithm is available.");
1195
+ const s = new Zr();
1196
+ return Gr(s.update(n).digest("hex"));
1197
+ }, qt = async (n) => {
1198
+ const a = new Ft(), { name: s, revision: c, documentType: f, created: m, lastModified: u } = n, o = {
1199
+ name: s,
1200
+ revision: c,
1201
+ documentType: f,
1202
+ created: m,
1203
+ lastModified: u
1204
+ };
1205
+ return a.file("header.json", JSON.stringify(o, null, 2)), a.file(
1206
+ "state.json",
1207
+ JSON.stringify(n.initialState || {}, null, 2)
1208
+ ), a.file("operations.json", JSON.stringify(n.operations, null, 2)), Object.keys(n.attachments).forEach((y) => {
1209
+ const { data: v, ...F } = n.attachments[y];
1210
+ a.file(y, v, {
1211
+ base64: !0,
1212
+ createFolders: !0,
1213
+ comment: JSON.stringify(F)
1214
+ });
1215
+ }), a;
1216
+ }, Vr = async (n, a, s, c) => {
1217
+ await (await qt(n)).generateAsync({
1218
+ type: "uint8array",
1219
+ streamFiles: !0
1220
+ });
1221
+ const m = c ?? n.name, u = `.${s}.zip`;
1222
+ return Yr(
1223
+ a,
1224
+ m.endsWith(u) ? m : `${m}${u}`
1225
+ );
1226
+ }, bi = async (n, a) => {
1227
+ const c = await (await qt(n)).generateAsync({ type: "blob" }), f = await a.createWritable();
1228
+ await f.write(c), await f.close();
1229
+ }, Et = async (n, a) => {
1230
+ const s = zt();
1231
+ return Qr(s, a);
1232
+ }, Qr = async (n, a) => {
1233
+ const s = new Ft();
1234
+ return await s.loadAsync(n), ti(s, a);
1235
+ };
1236
+ async function ti(n, a) {
1237
+ const s = n.file("state.json");
1238
+ if (!s)
1239
+ throw new Error("Initial state not found");
1240
+ const c = await s.async("string"), f = JSON.parse(c), m = n.file("header.json");
1241
+ let u = null;
1242
+ m && (u = JSON.parse(await m.async("string")));
1243
+ const o = n.file("operations.json");
1244
+ if (!o)
1245
+ throw new Error("Operations history not found");
1246
+ const x = JSON.parse(
1247
+ await o.async("string")
1248
+ ), y = {
1249
+ ...f,
1250
+ ...u,
1251
+ initialState: f,
1252
+ operations: [],
1253
+ attachments: { ...f.attachments }
1254
+ };
1255
+ let v = x.slice(0, u == null ? void 0 : u.revision).reduce(
1256
+ (F, U) => a(F, U),
1257
+ y
1258
+ );
1259
+ return u && (v = {
1260
+ ...v,
1261
+ ...u,
1262
+ operations: [
1263
+ ...v.operations,
1264
+ ...x.slice(u.revision)
1265
+ ]
1266
+ }), v;
1267
+ }
1268
+ function $t(n) {
1269
+ const a = n.replace(/^.*\./, "") || void 0, s = n.replace(/^.*[/\\]/, "") || void 0;
1270
+ return { extension: a, fileName: s };
1271
+ }
1272
+ async function Fi(n) {
1273
+ const { buffer: a, mimeType: s = "application/octet-stream" } = await Kr(), c = $t(n), f = a.toString("base64");
1274
+ return {
1275
+ data: f,
1276
+ hash: W(f),
1277
+ mimeType: s,
1278
+ ...c
1279
+ };
1280
+ }
1281
+ async function _i(n) {
1282
+ const a = await Xr(), s = Sr.getType(n) || "application/octet-stream", c = $t(n), f = a.toString("base64");
1283
+ return { data: f, hash: W(f), mimeType: s, ...c };
1284
+ }
1285
+ function q(n, a, s) {
1286
+ const c = mi(n), f = fi(s);
1287
+ return a.reduce(
1288
+ (m, u) => f(m, u),
1289
+ c
1290
+ );
1291
+ }
1292
+ function ri(n, a) {
1293
+ return { ...n, name: a };
1294
+ }
1295
+ function ii(n, a, s) {
1296
+ const c = Math.min(a, n.revision), f = n.operations.slice(
1297
+ 0,
1298
+ n.revision - c
1299
+ );
1300
+ return {
1301
+ ...q(
1302
+ n.initialState,
1303
+ f,
1304
+ s
1305
+ ),
1306
+ operations: n.operations,
1307
+ revision: n.revision - c
1308
+ };
1309
+ }
1310
+ function ei(n, a, s) {
1311
+ const c = n.operations.length - n.revision;
1312
+ if (!c)
1313
+ throw new Error("There is no UNDO operation to REDO");
1314
+ const f = a < c ? a : c, m = n.operations.slice(
1315
+ 0,
1316
+ n.revision + f
1317
+ );
1318
+ return {
1319
+ ...q(
1320
+ n.initialState,
1321
+ m,
1322
+ s
1323
+ ),
1324
+ operations: n.operations,
1325
+ revision: n.revision + f
1326
+ };
1327
+ }
1328
+ function ni(n, a, s, c) {
1329
+ a = a || 0, s = s || n.operations.length;
1330
+ const f = n.operations.slice(a, s), m = n.operations.slice(0, a), u = n.operations.slice(s), o = q(
1331
+ n.initialState,
1332
+ m.concat(f),
1333
+ c
1334
+ ), { name: x, state: y } = o;
1335
+ return q(
1336
+ n.initialState,
1337
+ [
1338
+ ...m,
1339
+ st({ name: x, state: y }, f.length),
1340
+ ...u
1341
+ ],
1342
+ c
1343
+ );
1344
+ }
1345
+ function ai(n, a) {
1346
+ return {
1347
+ ...n,
1348
+ name: a.name,
1349
+ state: a.state ?? {}
1350
+ };
1351
+ }
1352
+ const Jt = "SET_NAME", H = "UNDO", Z = "REDO", M = "PRUNE", Pt = "LOAD_STATE";
1353
+ function oi(n, a) {
1354
+ return [H, Z, M].includes(a.type) ? n.revision : n.revision + 1;
1355
+ }
1356
+ function pi(n, a) {
1357
+ return {
1358
+ ...n,
1359
+ revision: oi(n, a),
1360
+ lastModified: (/* @__PURE__ */ new Date()).toISOString()
1361
+ };
1362
+ }
1363
+ function si(n, a) {
1364
+ if ([H, Z, M, M].includes(a.type))
1365
+ return n;
1366
+ const s = n.operations.slice(0, n.revision);
1367
+ return {
1368
+ ...n,
1369
+ operations: [
1370
+ ...s,
1371
+ {
1372
+ ...a,
1373
+ index: s.length,
1374
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1375
+ hash: ""
1376
+ }
1377
+ ]
1378
+ };
1379
+ }
1380
+ function ci(n, a) {
1381
+ let s = si(n, a);
1382
+ return s = pi(s, a), s;
1383
+ }
1384
+ function li(n, a, s) {
1385
+ switch (It().parse(a), a.type) {
1386
+ case Jt:
1387
+ return ri(n, a.input);
1388
+ case H:
1389
+ return ii(n, a.input, s);
1390
+ case Z:
1391
+ return ei(n, a.input, s);
1392
+ case M:
1393
+ return ni(
1394
+ n,
1395
+ a.input.start,
1396
+ a.input.end,
1397
+ s
1398
+ );
1399
+ case Pt:
1400
+ return ai(n, a.input.state);
1401
+ default:
1402
+ return n;
1403
+ }
1404
+ }
1405
+ function ui(n, a, s) {
1406
+ let c = n;
1407
+ return bt(a) && (c = li(c, a, s)), c = ci(c, a), c = vt(c, (f) => {
1408
+ const m = s(f.state, a);
1409
+ if (m)
1410
+ return wr({
1411
+ ...c,
1412
+ state: m
1413
+ });
1414
+ }), vt(c, (f) => {
1415
+ f.operations[f.operations.length - 1].hash = xi(f), !bt(a) && a.attachments && a.attachments.forEach((m) => {
1416
+ const { hash: u, ...o } = m;
1417
+ f.attachments[u] = {
1418
+ ...o
1419
+ };
1420
+ });
1421
+ });
1422
+ }
1423
+ function bt(n) {
1424
+ return [Jt, H, Z, M, Pt].includes(n.type);
1425
+ }
1426
+ function R(n, a, s, c) {
1427
+ if (!n)
1428
+ throw new Error("Empty action type");
1429
+ if (typeof n != "string")
1430
+ throw new Error(`Invalid action type: ${n}`);
1431
+ const f = s ? { type: n, input: a, attachments: s } : { type: n, input: a };
1432
+ return c == null || c().parse(f), f;
1433
+ }
1434
+ function fi(n, a = ui) {
1435
+ return (s, c) => a(s, c, n);
1436
+ }
1437
+ const hi = (n, a) => ({
1438
+ name: "",
1439
+ documentType: "",
1440
+ revision: 0,
1441
+ created: (/* @__PURE__ */ new Date()).toISOString(),
1442
+ lastModified: (/* @__PURE__ */ new Date()).toISOString(),
1443
+ attachments: {},
1444
+ ...n,
1445
+ state: (a == null ? void 0 : a(n == null ? void 0 : n.state)) ?? (n == null ? void 0 : n.state) ?? {}
1446
+ }), mi = (n, a) => {
1447
+ const s = hi(
1448
+ n,
1449
+ a
1450
+ );
1451
+ return {
1452
+ ...s,
1453
+ initialState: s,
1454
+ operations: []
1455
+ };
1456
+ }, xi = (n) => W(dr(n.state)), Ai = (n, a = 1e3) => {
1457
+ const s = Math.random() * a;
1458
+ return W(`${(n ?? /* @__PURE__ */ new Date()).toISOString()}${s}`);
1459
+ }, Wt = (n) => R(
1460
+ "SET_NAME",
1461
+ n,
1462
+ void 0,
1463
+ nt
1464
+ ), Ht = (n = 1) => R("UNDO", n, void 0, at), Zt = (n = 1) => R("REDO", n, void 0, et), Yt = (n, a) => R(
1465
+ "PRUNE",
1466
+ { start: n, end: a },
1467
+ void 0,
1468
+ it
1469
+ ), st = (n, a) => R(
1470
+ "LOAD_STATE",
1471
+ { state: n, operations: a },
1472
+ void 0,
1473
+ rt
1474
+ ), Bi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1475
+ __proto__: null,
1476
+ loadState: st,
1477
+ prune: Yt,
1478
+ redo: Zt,
1479
+ setName: Wt,
1480
+ undo: Ht
1481
+ }, Symbol.toStringTag, { value: "Module" }));
1482
+ class Si {
1483
+ /**
1484
+ * Constructs a BaseDocument instance with an initial state.
1485
+ * @param reducer - The reducer function that updates the state.
1486
+ * @param document - The initial state of the document.
1487
+ */
1488
+ constructor(a, s) {
1489
+ G(this, "_document");
1490
+ G(this, "_reducer");
1491
+ this._reducer = a, this._document = s;
1492
+ }
1493
+ /**
1494
+ * Dispatches an action to update the state of the document.
1495
+ * @param action - The action to dispatch.
1496
+ * @returns The Document instance.
1497
+ */
1498
+ dispatch(a) {
1499
+ return this._document = this._reducer(this._document, a), this;
1500
+ }
1501
+ /**
1502
+ * Saves the state of the document to a file.
1503
+ * @param path - The file path where the state should be saved.
1504
+ * @param extension - The file extension to use when saving the state.
1505
+ * @returns The file path where the state was saved.
1506
+ */
1507
+ saveToFile(a, s, c) {
1508
+ return Vr(this._document, a, s, c);
1509
+ }
1510
+ /**
1511
+ * Loads the state of the document from a file.
1512
+ * @param path - The file path where the state is stored.
1513
+ */
1514
+ async loadFromFile(a) {
1515
+ this._document = await Et(a, this._reducer);
1516
+ }
1517
+ /**
1518
+ * Loads the state of the document from a file and returns it.
1519
+ * @param path - The file path where the state is stored.
1520
+ * @param reducer - The reducer function that updates the state.
1521
+ * @returns The state of the document.
1522
+ */
1523
+ static async stateFromFile(a, s) {
1524
+ return await Et(a, s);
1525
+ }
1526
+ /**
1527
+ * Gets the current state of the document.
1528
+ */
1529
+ get state() {
1530
+ return this._document.state;
1531
+ }
1532
+ /**
1533
+ * Gets the list of operations performed on the document.
1534
+ */
1535
+ get operations() {
1536
+ return this._document.operations;
1537
+ }
1538
+ /**
1539
+ * Gets the name of the document.
1540
+ */
1541
+ get name() {
1542
+ return this._document.name;
1543
+ }
1544
+ /**
1545
+ * Gets the type of document.
1546
+ */
1547
+ get documentType() {
1548
+ return this._document.documentType;
1549
+ }
1550
+ /**
1551
+ * Gets the timestamp of the date the document was created.
1552
+ */
1553
+ get created() {
1554
+ return this._document.created;
1555
+ }
1556
+ /**
1557
+ * Gets the timestamp of the date the document was last modified.
1558
+ */
1559
+ get lastModified() {
1560
+ return this._document.lastModified;
1561
+ }
1562
+ /**
1563
+ * Gets the revision number of the document.
1564
+ */
1565
+ get revision() {
1566
+ return this._document.revision;
1567
+ }
1568
+ /**
1569
+ * Gets the initial state of the document.
1570
+ */
1571
+ get initialState() {
1572
+ return this._document.initialState;
1573
+ }
1574
+ /**
1575
+ * Gets the attachment associated with the given key.
1576
+ * @param attachment - The key of the attachment to retrieve.
1577
+ */
1578
+ getAttachment(a) {
1579
+ return this._document.attachments[a];
1580
+ }
1581
+ /**
1582
+ * Sets the name of the document.
1583
+ * @param name - The new name of the document.
1584
+ */
1585
+ setName(a) {
1586
+ return this.dispatch(Wt(a)), this;
1587
+ }
1588
+ /**
1589
+ * Reverts a number of actions from the document.
1590
+ * @param count - The number of actions to revert.
1591
+ */
1592
+ undo(a) {
1593
+ return this.dispatch(Ht(a)), this;
1594
+ }
1595
+ /**
1596
+ * Reapplies a number of actions to the document.
1597
+ * @param count - The number of actions to reapply.
1598
+ */
1599
+ redo(a) {
1600
+ return this.dispatch(Zt(a)), this;
1601
+ }
1602
+ /**
1603
+ * Removes a range of operations from the document.
1604
+ * @param start - The starting index of the range to remove.
1605
+ * @param end - The ending index of the range to remove.
1606
+ */
1607
+ prune(a, s) {
1608
+ return this.dispatch(Yt(a, s)), this;
1609
+ }
1610
+ /**
1611
+ * Loads a document state and a set of operations.
1612
+ * @param state - The state to load.
1613
+ * @param operations - The operations to apply to the document.
1614
+ */
1615
+ loadState(a, s) {
1616
+ return this.dispatch(st(a, s)), this;
1617
+ }
1618
+ }
1619
+ function ji(n, a) {
1620
+ a.forEach((s) => {
1621
+ Object.getOwnPropertyNames(s.prototype).forEach((c) => {
1622
+ Object.defineProperty(
1623
+ n.prototype,
1624
+ c,
1625
+ Object.getOwnPropertyDescriptor(s.prototype, c) || /* @__PURE__ */ Object.create(null)
1626
+ );
1627
+ });
1628
+ });
1629
+ }
1630
+ export {
1631
+ Si as B,
1632
+ hi as a,
1633
+ mi as b,
1634
+ fi as c,
1635
+ bi as d,
1636
+ Qr as e,
1637
+ R as f,
1638
+ ji as g,
1639
+ Bi as h,
1640
+ bt as i,
1641
+ qt as j,
1642
+ _i as k,
1643
+ Et as l,
1644
+ Fi as m,
1645
+ xi as n,
1646
+ Ai as o,
1647
+ ui as p,
1648
+ Vr as s,
1649
+ Ei as z
1650
+ };