document-model 1.0.18 → 1.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/browser/document/actions/creators.d.ts +4 -4
  2. package/dist/browser/document/actions/index.d.ts +4 -4
  3. package/dist/browser/document/object.d.ts +119 -13
  4. package/dist/browser/document/schema/types.d.ts +5 -4
  5. package/dist/browser/document/schema/zod.d.ts +14 -12
  6. package/dist/browser/document/types.d.ts +2 -5
  7. package/dist/browser/document/utils/base.d.ts +6 -2
  8. package/dist/browser/document-model/gen/schema/zod.d.ts +5 -3
  9. package/dist/browser/document-model/index.d.ts +3 -3
  10. package/dist/browser/document-model.cjs +1 -1
  11. package/dist/browser/document-model.js +2 -2
  12. package/dist/browser/document.cjs +1 -1
  13. package/dist/browser/document.js +6 -6
  14. package/dist/browser/index.cjs +1 -1
  15. package/dist/browser/index.js +4 -4
  16. package/dist/browser/internal/{index-10a12861.js → index-22f88bf2.js} +361 -357
  17. package/dist/browser/internal/index-3607fd07.js +34 -0
  18. package/dist/browser/internal/index-79fde5f3.js +1 -0
  19. package/dist/browser/internal/index-dda5d688.js +22 -0
  20. package/dist/browser/internal/object-32802eed.js +6 -0
  21. package/dist/browser/internal/object-d03c84c9.js +1779 -0
  22. package/dist/node/document/actions/creators.d.ts +4 -4
  23. package/dist/node/document/actions/index.d.ts +4 -4
  24. package/dist/node/document/object.d.ts +119 -13
  25. package/dist/node/document/schema/types.d.ts +5 -4
  26. package/dist/node/document/schema/zod.d.ts +14 -12
  27. package/dist/node/document/types.d.ts +2 -5
  28. package/dist/node/document/utils/base.d.ts +6 -2
  29. package/dist/node/document-model/gen/schema/zod.d.ts +5 -3
  30. package/dist/node/document-model/index.d.ts +3 -3
  31. package/dist/node/document-model.cjs +1 -1
  32. package/dist/node/document-model.js +3 -3
  33. package/dist/node/document.cjs +1 -1
  34. package/dist/node/document.js +5 -5
  35. package/dist/node/index.cjs +1 -1
  36. package/dist/node/index.js +4 -4
  37. package/dist/node/internal/{index-09364517.js → index-14279b3a.js} +362 -358
  38. package/dist/node/internal/index-4b25c8a5.js +1 -0
  39. package/dist/node/internal/index-bfc402ef.js +22 -0
  40. package/dist/node/internal/index-e02d7854.js +34 -0
  41. package/dist/node/internal/object-ac706c4a.js +1 -0
  42. package/dist/node/internal/{object-c32ea0a0.js → object-b97efc1b.js} +469 -402
  43. package/package.json +1 -1
  44. package/dist/browser/internal/index-2aee8ea9.js +0 -1
  45. package/dist/browser/internal/index-a1282d5c.js +0 -31
  46. package/dist/browser/internal/index-ec8cd58f.js +0 -22
  47. package/dist/browser/internal/object-24df9d92.js +0 -6
  48. package/dist/browser/internal/object-7e8eaff4.js +0 -1712
  49. package/dist/node/internal/index-284511b8.js +0 -22
  50. package/dist/node/internal/index-2d4783d9.js +0 -1
  51. package/dist/node/internal/index-5ef0c6b0.js +0 -31
  52. package/dist/node/internal/object-21f3d2ee.js +0 -1
@@ -1,1712 +0,0 @@
1
- var yr = Object.defineProperty;
2
- var vr = (e, a, s) => a in e ? yr(e, a, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[a] = s;
3
- var q = (e, a, s) => (vr(e, typeof a != "symbol" ? a + "" : a, s), s);
4
- import br from "json-stringify-deterministic";
5
- import { produce as bt, castDraft as Er, castImmutable as _r, freeze as Fr } from "immer";
6
- import At from "jszip";
7
- import { z as g } from "zod";
8
- const St = (e) => e != null, Ar = g.any().refine((e) => St(e)), Bt = g.enum(["LOAD_STATE"]), jt = g.enum(["PRUNE"]), It = g.enum(["REDO"]), Ut = g.enum(["SET_NAME"]), kt = g.enum(["UNDO"]);
9
- function Sr() {
10
- return g.object({
11
- __typename: g.literal("Action").optional(),
12
- type: g.string()
13
- });
14
- }
15
- function Tt() {
16
- return g.union([
17
- Dt(),
18
- Nt(),
19
- Mt(),
20
- Ct(),
21
- Rt()
22
- ]);
23
- }
24
- function Br() {
25
- return g.object({
26
- __typename: g.literal("DocumentFile").optional(),
27
- data: g.string(),
28
- extension: g.string().nullable(),
29
- fileName: g.string().nullable(),
30
- mimeType: g.string()
31
- });
32
- }
33
- function Dt() {
34
- return g.object({
35
- input: g.lazy(() => it()),
36
- type: Bt,
37
- scope: g.literal("global")
38
- });
39
- }
40
- function it() {
41
- return g.object({
42
- operations: g.number(),
43
- state: g.lazy(() => Ot())
44
- });
45
- }
46
- function Ot() {
47
- return g.object({
48
- data: g.unknown().nullish(),
49
- name: g.string()
50
- });
51
- }
52
- function jr() {
53
- return g.object({
54
- __typename: g.literal("Operation").optional(),
55
- hash: g.string(),
56
- index: g.number(),
57
- timestamp: g.string().datetime(),
58
- type: g.string()
59
- });
60
- }
61
- function Nt() {
62
- return g.object({
63
- input: g.lazy(() => et()),
64
- type: jt,
65
- scope: g.literal("global")
66
- });
67
- }
68
- function et() {
69
- return g.object({
70
- end: g.number().nullish(),
71
- start: g.number().nullish()
72
- });
73
- }
74
- const nt = g.number;
75
- function Mt() {
76
- return g.object({
77
- input: nt(),
78
- type: It,
79
- scope: g.literal("global")
80
- });
81
- }
82
- const at = g.string;
83
- function Ct() {
84
- return g.object({
85
- input: at(),
86
- type: Ut,
87
- scope: g.literal("global")
88
- });
89
- }
90
- function Ir() {
91
- return g.object({
92
- __typename: g.literal("SetNameOperation").optional(),
93
- hash: g.string(),
94
- index: g.number(),
95
- input: g.string(),
96
- timestamp: g.string().datetime(),
97
- type: g.string()
98
- });
99
- }
100
- const ot = g.number;
101
- function Rt() {
102
- return g.object({
103
- input: ot(),
104
- type: kt,
105
- scope: g.literal("global")
106
- });
107
- }
108
- const Bi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
109
- __proto__: null,
110
- ActionSchema: Sr,
111
- BaseActionSchema: Tt,
112
- DocumentFileSchema: Br,
113
- LoadStateActionInputSchema: it,
114
- LoadStateActionSchema: Dt,
115
- LoadStateActionStateInputSchema: Ot,
116
- Load_StateSchema: Bt,
117
- OperationSchema: jr,
118
- PruneActionInputSchema: et,
119
- PruneActionSchema: Nt,
120
- PruneSchema: jt,
121
- RedoActionInputSchema: nt,
122
- RedoActionSchema: Mt,
123
- RedoSchema: It,
124
- SetNameActionInputSchema: at,
125
- SetNameActionSchema: Ct,
126
- SetNameOperationSchema: Ir,
127
- Set_NameSchema: Ut,
128
- UndoActionInputSchema: ot,
129
- UndoActionSchema: Rt,
130
- UndoSchema: kt,
131
- definedNonNullAnySchema: Ar,
132
- isDefinedNonNullAny: St
133
- }, Symbol.toStringTag, { value: "Module" }));
134
- function Lt(e) {
135
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
136
- }
137
- function P() {
138
- this._types = /* @__PURE__ */ Object.create(null), this._extensions = /* @__PURE__ */ Object.create(null);
139
- for (let e = 0; e < arguments.length; e++)
140
- this.define(arguments[e]);
141
- this.define = this.define.bind(this), this.getType = this.getType.bind(this), this.getExtension = this.getExtension.bind(this);
142
- }
143
- P.prototype.define = function(e, a) {
144
- for (let s in e) {
145
- let l = e[s].map(function(f) {
146
- return f.toLowerCase();
147
- });
148
- s = s.toLowerCase();
149
- for (let f = 0; f < l.length; f++) {
150
- const h = l[f];
151
- if (h[0] !== "*") {
152
- if (!a && h in this._types)
153
- throw new Error(
154
- 'Attempt to change mapping for "' + h + '" extension from "' + this._types[h] + '" to "' + s + '". Pass `force=true` to allow this, otherwise remove "' + h + '" from the list of extensions for "' + s + '".'
155
- );
156
- this._types[h] = s;
157
- }
158
- }
159
- if (a || !this._extensions[s]) {
160
- const f = l[0];
161
- this._extensions[s] = f[0] !== "*" ? f : f.substr(1);
162
- }
163
- }
164
- };
165
- P.prototype.getType = function(e) {
166
- e = String(e);
167
- let a = e.replace(/^.*[/\\]/, "").toLowerCase(), s = a.replace(/^.*\./, "").toLowerCase(), l = a.length < e.length;
168
- return (s.length < a.length - 1 || !l) && this._types[s] || null;
169
- };
170
- P.prototype.getExtension = function(e) {
171
- return e = /^\s*([^;\s]*)/.test(e) && RegExp.$1, e && this._extensions[e.toLowerCase()] || null;
172
- };
173
- var Ur = P, kr = { "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"] };
174
- let Tr = Ur;
175
- var Dr = new Tr(kr);
176
- const Or = /* @__PURE__ */ Lt(Dr);
177
- var tt = { exports: {} };
178
- typeof Object.create == "function" ? tt.exports = function(a, s) {
179
- s && (a.super_ = s, a.prototype = Object.create(s.prototype, {
180
- constructor: {
181
- value: a,
182
- enumerable: !1,
183
- writable: !0,
184
- configurable: !0
185
- }
186
- }));
187
- } : tt.exports = function(a, s) {
188
- if (s) {
189
- a.super_ = s;
190
- var l = function() {
191
- };
192
- l.prototype = s.prototype, a.prototype = new l(), a.prototype.constructor = a;
193
- }
194
- };
195
- var Nr = tt.exports, rt = { exports: {} }, zt = {}, W = {};
196
- W.byteLength = Rr;
197
- W.toByteArray = zr;
198
- W.fromByteArray = Jr;
199
- var k = [], j = [], Mr = typeof Uint8Array < "u" ? Uint8Array : Array, Q = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
200
- for (var D = 0, Cr = Q.length; D < Cr; ++D)
201
- k[D] = Q[D], j[Q.charCodeAt(D)] = D;
202
- j["-".charCodeAt(0)] = 62;
203
- j["_".charCodeAt(0)] = 63;
204
- function qt(e) {
205
- var a = e.length;
206
- if (a % 4 > 0)
207
- throw new Error("Invalid string. Length must be a multiple of 4");
208
- var s = e.indexOf("=");
209
- s === -1 && (s = a);
210
- var l = s === a ? 0 : 4 - s % 4;
211
- return [s, l];
212
- }
213
- function Rr(e) {
214
- var a = qt(e), s = a[0], l = a[1];
215
- return (s + l) * 3 / 4 - l;
216
- }
217
- function Lr(e, a, s) {
218
- return (a + s) * 3 / 4 - s;
219
- }
220
- function zr(e) {
221
- var a, s = qt(e), l = s[0], f = s[1], h = new Mr(Lr(e, l, f)), c = 0, o = f > 0 ? l - 4 : l, x;
222
- for (x = 0; x < o; x += 4)
223
- a = j[e.charCodeAt(x)] << 18 | j[e.charCodeAt(x + 1)] << 12 | j[e.charCodeAt(x + 2)] << 6 | j[e.charCodeAt(x + 3)], h[c++] = a >> 16 & 255, h[c++] = a >> 8 & 255, h[c++] = a & 255;
224
- return f === 2 && (a = j[e.charCodeAt(x)] << 2 | j[e.charCodeAt(x + 1)] >> 4, h[c++] = a & 255), f === 1 && (a = j[e.charCodeAt(x)] << 10 | j[e.charCodeAt(x + 1)] << 4 | j[e.charCodeAt(x + 2)] >> 2, h[c++] = a >> 8 & 255, h[c++] = a & 255), h;
225
- }
226
- function qr(e) {
227
- return k[e >> 18 & 63] + k[e >> 12 & 63] + k[e >> 6 & 63] + k[e & 63];
228
- }
229
- function $r(e, a, s) {
230
- for (var l, f = [], h = a; h < s; h += 3)
231
- l = (e[h] << 16 & 16711680) + (e[h + 1] << 8 & 65280) + (e[h + 2] & 255), f.push(qr(l));
232
- return f.join("");
233
- }
234
- function Jr(e) {
235
- for (var a, s = e.length, l = s % 3, f = [], h = 16383, c = 0, o = s - l; c < o; c += h)
236
- f.push($r(e, c, c + h > o ? o : c + h));
237
- return l === 1 ? (a = e[s - 1], f.push(
238
- k[a >> 2] + k[a << 4 & 63] + "=="
239
- )) : l === 2 && (a = (e[s - 2] << 8) + e[s - 1], f.push(
240
- k[a >> 10] + k[a >> 4 & 63] + k[a << 2 & 63] + "="
241
- )), f.join("");
242
- }
243
- var pt = {};
244
- /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
245
- pt.read = function(e, a, s, l, f) {
246
- var h, c, o = f * 8 - l - 1, x = (1 << o) - 1, w = x >> 1, y = -7, _ = s ? f - 1 : 0, I = s ? -1 : 1, S = e[a + _];
247
- for (_ += I, h = S & (1 << -y) - 1, S >>= -y, y += o; y > 0; h = h * 256 + e[a + _], _ += I, y -= 8)
248
- ;
249
- for (c = h & (1 << -y) - 1, h >>= -y, y += l; y > 0; c = c * 256 + e[a + _], _ += I, y -= 8)
250
- ;
251
- if (h === 0)
252
- h = 1 - w;
253
- else {
254
- if (h === x)
255
- return c ? NaN : (S ? -1 : 1) * (1 / 0);
256
- c = c + Math.pow(2, l), h = h - w;
257
- }
258
- return (S ? -1 : 1) * c * Math.pow(2, h - l);
259
- };
260
- pt.write = function(e, a, s, l, f, h) {
261
- var c, o, x, w = h * 8 - f - 1, y = (1 << w) - 1, _ = y >> 1, I = f === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, S = l ? 0 : h - 1, O = l ? 1 : -1, N = a < 0 || a === 0 && 1 / a < 0 ? 1 : 0;
262
- for (a = Math.abs(a), isNaN(a) || a === 1 / 0 ? (o = isNaN(a) ? 1 : 0, c = y) : (c = Math.floor(Math.log(a) / Math.LN2), a * (x = Math.pow(2, -c)) < 1 && (c--, x *= 2), c + _ >= 1 ? a += I / x : a += I * Math.pow(2, 1 - _), a * x >= 2 && (c++, x /= 2), c + _ >= y ? (o = 0, c = y) : c + _ >= 1 ? (o = (a * x - 1) * Math.pow(2, f), c = c + _) : (o = a * Math.pow(2, _ - 1) * Math.pow(2, f), c = 0)); f >= 8; e[s + S] = o & 255, S += O, o /= 256, f -= 8)
263
- ;
264
- for (c = c << f | o, w += f; w > 0; e[s + S] = c & 255, S += O, c /= 256, w -= 8)
265
- ;
266
- e[s + S - O] |= N * 128;
267
- };
268
- /*!
269
- * The buffer module from node.js, for the browser.
270
- *
271
- * @author Feross Aboukhadijeh <https://feross.org>
272
- * @license MIT
273
- */
274
- (function(e) {
275
- var a = W, s = pt, l = typeof Symbol == "function" && typeof Symbol.for == "function" ? Symbol.for("nodejs.util.inspect.custom") : null;
276
- e.Buffer = o, e.SlowBuffer = rr, e.INSPECT_MAX_BYTES = 50;
277
- var f = 2147483647;
278
- e.kMaxLength = f, o.TYPED_ARRAY_SUPPORT = h(), !o.TYPED_ARRAY_SUPPORT && typeof console < "u" && typeof console.error == "function" && console.error(
279
- "This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
280
- );
281
- function h() {
282
- try {
283
- var i = new Uint8Array(1), t = { foo: function() {
284
- return 42;
285
- } };
286
- return Object.setPrototypeOf(t, Uint8Array.prototype), Object.setPrototypeOf(i, t), i.foo() === 42;
287
- } catch {
288
- return !1;
289
- }
290
- }
291
- Object.defineProperty(o.prototype, "parent", {
292
- enumerable: !0,
293
- get: function() {
294
- if (o.isBuffer(this))
295
- return this.buffer;
296
- }
297
- }), Object.defineProperty(o.prototype, "offset", {
298
- enumerable: !0,
299
- get: function() {
300
- if (o.isBuffer(this))
301
- return this.byteOffset;
302
- }
303
- });
304
- function c(i) {
305
- if (i > f)
306
- throw new RangeError('The value "' + i + '" is invalid for option "size"');
307
- var t = new Uint8Array(i);
308
- return Object.setPrototypeOf(t, o.prototype), t;
309
- }
310
- function o(i, t, r) {
311
- if (typeof i == "number") {
312
- if (typeof t == "string")
313
- throw new TypeError(
314
- 'The "string" argument must be of type string. Received type number'
315
- );
316
- return _(i);
317
- }
318
- return x(i, t, r);
319
- }
320
- o.poolSize = 8192;
321
- function x(i, t, r) {
322
- if (typeof i == "string")
323
- return I(i, t);
324
- if (ArrayBuffer.isView(i))
325
- return O(i);
326
- if (i == null)
327
- throw new TypeError(
328
- "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof i
329
- );
330
- if (U(i, ArrayBuffer) || i && U(i.buffer, ArrayBuffer) || typeof SharedArrayBuffer < "u" && (U(i, SharedArrayBuffer) || i && U(i.buffer, SharedArrayBuffer)))
331
- return N(i, t, r);
332
- if (typeof i == "number")
333
- throw new TypeError(
334
- 'The "value" argument must not be of type number. Received type number'
335
- );
336
- var n = i.valueOf && i.valueOf();
337
- if (n != null && n !== i)
338
- return o.from(n, t, r);
339
- var p = tr(i);
340
- if (p)
341
- return p;
342
- if (typeof Symbol < "u" && Symbol.toPrimitive != null && typeof i[Symbol.toPrimitive] == "function")
343
- return o.from(
344
- i[Symbol.toPrimitive]("string"),
345
- t,
346
- r
347
- );
348
- throw new TypeError(
349
- "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof i
350
- );
351
- }
352
- o.from = function(i, t, r) {
353
- return x(i, t, r);
354
- }, Object.setPrototypeOf(o.prototype, Uint8Array.prototype), Object.setPrototypeOf(o, Uint8Array);
355
- function w(i) {
356
- if (typeof i != "number")
357
- throw new TypeError('"size" argument must be of type number');
358
- if (i < 0)
359
- throw new RangeError('The value "' + i + '" is invalid for option "size"');
360
- }
361
- function y(i, t, r) {
362
- return w(i), i <= 0 ? c(i) : t !== void 0 ? typeof r == "string" ? c(i).fill(t, r) : c(i).fill(t) : c(i);
363
- }
364
- o.alloc = function(i, t, r) {
365
- return y(i, t, r);
366
- };
367
- function _(i) {
368
- return w(i), c(i < 0 ? 0 : X(i) | 0);
369
- }
370
- o.allocUnsafe = function(i) {
371
- return _(i);
372
- }, o.allocUnsafeSlow = function(i) {
373
- return _(i);
374
- };
375
- function I(i, t) {
376
- if ((typeof t != "string" || t === "") && (t = "utf8"), !o.isEncoding(t))
377
- throw new TypeError("Unknown encoding: " + t);
378
- var r = ct(i, t) | 0, n = c(r), p = n.write(i, t);
379
- return p !== r && (n = n.slice(0, p)), n;
380
- }
381
- function S(i) {
382
- for (var t = i.length < 0 ? 0 : X(i.length) | 0, r = c(t), n = 0; n < t; n += 1)
383
- r[n] = i[n] & 255;
384
- return r;
385
- }
386
- function O(i) {
387
- if (U(i, Uint8Array)) {
388
- var t = new Uint8Array(i);
389
- return N(t.buffer, t.byteOffset, t.byteLength);
390
- }
391
- return S(i);
392
- }
393
- function N(i, t, r) {
394
- if (t < 0 || i.byteLength < t)
395
- throw new RangeError('"offset" is outside of buffer bounds');
396
- if (i.byteLength < t + (r || 0))
397
- throw new RangeError('"length" is outside of buffer bounds');
398
- var n;
399
- return t === void 0 && r === void 0 ? n = new Uint8Array(i) : r === void 0 ? n = new Uint8Array(i, t) : n = new Uint8Array(i, t, r), Object.setPrototypeOf(n, o.prototype), n;
400
- }
401
- function tr(i) {
402
- if (o.isBuffer(i)) {
403
- var t = X(i.length) | 0, r = c(t);
404
- return r.length === 0 || i.copy(r, 0, 0, t), r;
405
- }
406
- if (i.length !== void 0)
407
- return typeof i.length != "number" || V(i.length) ? c(0) : S(i);
408
- if (i.type === "Buffer" && Array.isArray(i.data))
409
- return S(i.data);
410
- }
411
- function X(i) {
412
- if (i >= f)
413
- throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + f.toString(16) + " bytes");
414
- return i | 0;
415
- }
416
- function rr(i) {
417
- return +i != i && (i = 0), o.alloc(+i);
418
- }
419
- o.isBuffer = function(t) {
420
- return t != null && t._isBuffer === !0 && t !== o.prototype;
421
- }, o.compare = function(t, r) {
422
- if (U(t, Uint8Array) && (t = o.from(t, t.offset, t.byteLength)), U(r, Uint8Array) && (r = o.from(r, r.offset, r.byteLength)), !o.isBuffer(t) || !o.isBuffer(r))
423
- throw new TypeError(
424
- 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
425
- );
426
- if (t === r)
427
- return 0;
428
- for (var n = t.length, p = r.length, u = 0, m = Math.min(n, p); u < m; ++u)
429
- if (t[u] !== r[u]) {
430
- n = t[u], p = r[u];
431
- break;
432
- }
433
- return n < p ? -1 : p < n ? 1 : 0;
434
- }, o.isEncoding = function(t) {
435
- switch (String(t).toLowerCase()) {
436
- case "hex":
437
- case "utf8":
438
- case "utf-8":
439
- case "ascii":
440
- case "latin1":
441
- case "binary":
442
- case "base64":
443
- case "ucs2":
444
- case "ucs-2":
445
- case "utf16le":
446
- case "utf-16le":
447
- return !0;
448
- default:
449
- return !1;
450
- }
451
- }, o.concat = function(t, r) {
452
- if (!Array.isArray(t))
453
- throw new TypeError('"list" argument must be an Array of Buffers');
454
- if (t.length === 0)
455
- return o.alloc(0);
456
- var n;
457
- if (r === void 0)
458
- for (r = 0, n = 0; n < t.length; ++n)
459
- r += t[n].length;
460
- var p = o.allocUnsafe(r), u = 0;
461
- for (n = 0; n < t.length; ++n) {
462
- var m = t[n];
463
- if (U(m, Uint8Array))
464
- u + m.length > p.length ? o.from(m).copy(p, u) : Uint8Array.prototype.set.call(
465
- p,
466
- m,
467
- u
468
- );
469
- else if (o.isBuffer(m))
470
- m.copy(p, u);
471
- else
472
- throw new TypeError('"list" argument must be an Array of Buffers');
473
- u += m.length;
474
- }
475
- return p;
476
- };
477
- function ct(i, t) {
478
- if (o.isBuffer(i))
479
- return i.length;
480
- if (ArrayBuffer.isView(i) || U(i, ArrayBuffer))
481
- return i.byteLength;
482
- if (typeof i != "string")
483
- throw new TypeError(
484
- 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof i
485
- );
486
- var r = i.length, n = arguments.length > 2 && arguments[2] === !0;
487
- if (!n && r === 0)
488
- return 0;
489
- for (var p = !1; ; )
490
- switch (t) {
491
- case "ascii":
492
- case "latin1":
493
- case "binary":
494
- return r;
495
- case "utf8":
496
- case "utf-8":
497
- return G(i).length;
498
- case "ucs2":
499
- case "ucs-2":
500
- case "utf16le":
501
- case "utf-16le":
502
- return r * 2;
503
- case "hex":
504
- return r >>> 1;
505
- case "base64":
506
- return wt(i).length;
507
- default:
508
- if (p)
509
- return n ? -1 : G(i).length;
510
- t = ("" + t).toLowerCase(), p = !0;
511
- }
512
- }
513
- o.byteLength = ct;
514
- function ir(i, t, r) {
515
- var n = !1;
516
- 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))
517
- return "";
518
- for (i || (i = "utf8"); ; )
519
- switch (i) {
520
- case "hex":
521
- return fr(this, t, r);
522
- case "utf8":
523
- case "utf-8":
524
- return ht(this, t, r);
525
- case "ascii":
526
- return cr(this, t, r);
527
- case "latin1":
528
- case "binary":
529
- return ur(this, t, r);
530
- case "base64":
531
- return sr(this, t, r);
532
- case "ucs2":
533
- case "ucs-2":
534
- case "utf16le":
535
- case "utf-16le":
536
- return hr(this, t, r);
537
- default:
538
- if (n)
539
- throw new TypeError("Unknown encoding: " + i);
540
- i = (i + "").toLowerCase(), n = !0;
541
- }
542
- }
543
- o.prototype._isBuffer = !0;
544
- function T(i, t, r) {
545
- var n = i[t];
546
- i[t] = i[r], i[r] = n;
547
- }
548
- o.prototype.swap16 = function() {
549
- var t = this.length;
550
- if (t % 2 !== 0)
551
- throw new RangeError("Buffer size must be a multiple of 16-bits");
552
- for (var r = 0; r < t; r += 2)
553
- T(this, r, r + 1);
554
- return this;
555
- }, o.prototype.swap32 = function() {
556
- var t = this.length;
557
- if (t % 4 !== 0)
558
- throw new RangeError("Buffer size must be a multiple of 32-bits");
559
- for (var r = 0; r < t; r += 4)
560
- T(this, r, r + 3), T(this, r + 1, r + 2);
561
- return this;
562
- }, o.prototype.swap64 = function() {
563
- var t = this.length;
564
- if (t % 8 !== 0)
565
- throw new RangeError("Buffer size must be a multiple of 64-bits");
566
- for (var r = 0; r < t; r += 8)
567
- T(this, r, r + 7), T(this, r + 1, r + 6), T(this, r + 2, r + 5), T(this, r + 3, r + 4);
568
- return this;
569
- }, o.prototype.toString = function() {
570
- var t = this.length;
571
- return t === 0 ? "" : arguments.length === 0 ? ht(this, 0, t) : ir.apply(this, arguments);
572
- }, o.prototype.toLocaleString = o.prototype.toString, o.prototype.equals = function(t) {
573
- if (!o.isBuffer(t))
574
- throw new TypeError("Argument must be a Buffer");
575
- return this === t ? !0 : o.compare(this, t) === 0;
576
- }, o.prototype.inspect = function() {
577
- var t = "", r = e.INSPECT_MAX_BYTES;
578
- return t = this.toString("hex", 0, r).replace(/(.{2})/g, "$1 ").trim(), this.length > r && (t += " ... "), "<Buffer " + t + ">";
579
- }, l && (o.prototype[l] = o.prototype.inspect), o.prototype.compare = function(t, r, n, p, u) {
580
- if (U(t, Uint8Array) && (t = o.from(t, t.offset, t.byteLength)), !o.isBuffer(t))
581
- throw new TypeError(
582
- 'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof t
583
- );
584
- if (r === void 0 && (r = 0), n === void 0 && (n = t ? t.length : 0), p === void 0 && (p = 0), u === void 0 && (u = this.length), r < 0 || n > t.length || p < 0 || u > this.length)
585
- throw new RangeError("out of range index");
586
- if (p >= u && r >= n)
587
- return 0;
588
- if (p >= u)
589
- return -1;
590
- if (r >= n)
591
- return 1;
592
- if (r >>>= 0, n >>>= 0, p >>>= 0, u >>>= 0, this === t)
593
- return 0;
594
- for (var m = u - p, d = n - r, v = Math.min(m, d), b = this.slice(p, u), A = t.slice(r, n), E = 0; E < v; ++E)
595
- if (b[E] !== A[E]) {
596
- m = b[E], d = A[E];
597
- break;
598
- }
599
- return m < d ? -1 : d < m ? 1 : 0;
600
- };
601
- function ut(i, t, r, n, p) {
602
- if (i.length === 0)
603
- return -1;
604
- if (typeof r == "string" ? (n = r, r = 0) : r > 2147483647 ? r = 2147483647 : r < -2147483648 && (r = -2147483648), r = +r, V(r) && (r = p ? 0 : i.length - 1), r < 0 && (r = i.length + r), r >= i.length) {
605
- if (p)
606
- return -1;
607
- r = i.length - 1;
608
- } else if (r < 0)
609
- if (p)
610
- r = 0;
611
- else
612
- return -1;
613
- if (typeof t == "string" && (t = o.from(t, n)), o.isBuffer(t))
614
- return t.length === 0 ? -1 : ft(i, t, r, n, p);
615
- if (typeof t == "number")
616
- return t = t & 255, typeof Uint8Array.prototype.indexOf == "function" ? p ? Uint8Array.prototype.indexOf.call(i, t, r) : Uint8Array.prototype.lastIndexOf.call(i, t, r) : ft(i, [t], r, n, p);
617
- throw new TypeError("val must be string, number or Buffer");
618
- }
619
- function ft(i, t, r, n, p) {
620
- var u = 1, m = i.length, d = t.length;
621
- if (n !== void 0 && (n = String(n).toLowerCase(), n === "ucs2" || n === "ucs-2" || n === "utf16le" || n === "utf-16le")) {
622
- if (i.length < 2 || t.length < 2)
623
- return -1;
624
- u = 2, m /= 2, d /= 2, r /= 2;
625
- }
626
- function v(yt, vt) {
627
- return u === 1 ? yt[vt] : yt.readUInt16BE(vt * u);
628
- }
629
- var b;
630
- if (p) {
631
- var A = -1;
632
- for (b = r; b < m; b++)
633
- if (v(i, b) === v(t, A === -1 ? 0 : b - A)) {
634
- if (A === -1 && (A = b), b - A + 1 === d)
635
- return A * u;
636
- } else
637
- A !== -1 && (b -= b - A), A = -1;
638
- } else
639
- for (r + d > m && (r = m - d), b = r; b >= 0; b--) {
640
- for (var E = !0, z = 0; z < d; z++)
641
- if (v(i, b + z) !== v(t, z)) {
642
- E = !1;
643
- break;
644
- }
645
- if (E)
646
- return b;
647
- }
648
- return -1;
649
- }
650
- o.prototype.includes = function(t, r, n) {
651
- return this.indexOf(t, r, n) !== -1;
652
- }, o.prototype.indexOf = function(t, r, n) {
653
- return ut(this, t, r, n, !0);
654
- }, o.prototype.lastIndexOf = function(t, r, n) {
655
- return ut(this, t, r, n, !1);
656
- };
657
- function er(i, t, r, n) {
658
- r = Number(r) || 0;
659
- var p = i.length - r;
660
- n ? (n = Number(n), n > p && (n = p)) : n = p;
661
- var u = t.length;
662
- n > u / 2 && (n = u / 2);
663
- for (var m = 0; m < n; ++m) {
664
- var d = parseInt(t.substr(m * 2, 2), 16);
665
- if (V(d))
666
- return m;
667
- i[r + m] = d;
668
- }
669
- return m;
670
- }
671
- function nr(i, t, r, n) {
672
- return L(G(t, i.length - r), i, r, n);
673
- }
674
- function ar(i, t, r, n) {
675
- return L(gr(t), i, r, n);
676
- }
677
- function or(i, t, r, n) {
678
- return L(wt(t), i, r, n);
679
- }
680
- function pr(i, t, r, n) {
681
- return L(dr(t, i.length - r), i, r, n);
682
- }
683
- o.prototype.write = function(t, r, n, p) {
684
- if (r === void 0)
685
- p = "utf8", n = this.length, r = 0;
686
- else if (n === void 0 && typeof r == "string")
687
- p = r, n = this.length, r = 0;
688
- else if (isFinite(r))
689
- r = r >>> 0, isFinite(n) ? (n = n >>> 0, p === void 0 && (p = "utf8")) : (p = n, n = void 0);
690
- else
691
- throw new Error(
692
- "Buffer.write(string, encoding, offset[, length]) is no longer supported"
693
- );
694
- var u = this.length - r;
695
- if ((n === void 0 || n > u) && (n = u), t.length > 0 && (n < 0 || r < 0) || r > this.length)
696
- throw new RangeError("Attempt to write outside buffer bounds");
697
- p || (p = "utf8");
698
- for (var m = !1; ; )
699
- switch (p) {
700
- case "hex":
701
- return er(this, t, r, n);
702
- case "utf8":
703
- case "utf-8":
704
- return nr(this, t, r, n);
705
- case "ascii":
706
- case "latin1":
707
- case "binary":
708
- return ar(this, t, r, n);
709
- case "base64":
710
- return or(this, t, r, n);
711
- case "ucs2":
712
- case "ucs-2":
713
- case "utf16le":
714
- case "utf-16le":
715
- return pr(this, t, r, n);
716
- default:
717
- if (m)
718
- throw new TypeError("Unknown encoding: " + p);
719
- p = ("" + p).toLowerCase(), m = !0;
720
- }
721
- }, o.prototype.toJSON = function() {
722
- return {
723
- type: "Buffer",
724
- data: Array.prototype.slice.call(this._arr || this, 0)
725
- };
726
- };
727
- function sr(i, t, r) {
728
- return t === 0 && r === i.length ? a.fromByteArray(i) : a.fromByteArray(i.slice(t, r));
729
- }
730
- function ht(i, t, r) {
731
- r = Math.min(i.length, r);
732
- for (var n = [], p = t; p < r; ) {
733
- var u = i[p], m = null, d = u > 239 ? 4 : u > 223 ? 3 : u > 191 ? 2 : 1;
734
- if (p + d <= r) {
735
- var v, b, A, E;
736
- switch (d) {
737
- case 1:
738
- u < 128 && (m = u);
739
- break;
740
- case 2:
741
- v = i[p + 1], (v & 192) === 128 && (E = (u & 31) << 6 | v & 63, E > 127 && (m = E));
742
- break;
743
- case 3:
744
- v = i[p + 1], b = i[p + 2], (v & 192) === 128 && (b & 192) === 128 && (E = (u & 15) << 12 | (v & 63) << 6 | b & 63, E > 2047 && (E < 55296 || E > 57343) && (m = E));
745
- break;
746
- case 4:
747
- v = i[p + 1], b = i[p + 2], A = i[p + 3], (v & 192) === 128 && (b & 192) === 128 && (A & 192) === 128 && (E = (u & 15) << 18 | (v & 63) << 12 | (b & 63) << 6 | A & 63, E > 65535 && E < 1114112 && (m = E));
748
- }
749
- }
750
- m === null ? (m = 65533, d = 1) : m > 65535 && (m -= 65536, n.push(m >>> 10 & 1023 | 55296), m = 56320 | m & 1023), n.push(m), p += d;
751
- }
752
- return lr(n);
753
- }
754
- var mt = 4096;
755
- function lr(i) {
756
- var t = i.length;
757
- if (t <= mt)
758
- return String.fromCharCode.apply(String, i);
759
- for (var r = "", n = 0; n < t; )
760
- r += String.fromCharCode.apply(
761
- String,
762
- i.slice(n, n += mt)
763
- );
764
- return r;
765
- }
766
- function cr(i, t, r) {
767
- var n = "";
768
- r = Math.min(i.length, r);
769
- for (var p = t; p < r; ++p)
770
- n += String.fromCharCode(i[p] & 127);
771
- return n;
772
- }
773
- function ur(i, t, r) {
774
- var n = "";
775
- r = Math.min(i.length, r);
776
- for (var p = t; p < r; ++p)
777
- n += String.fromCharCode(i[p]);
778
- return n;
779
- }
780
- function fr(i, t, r) {
781
- var n = i.length;
782
- (!t || t < 0) && (t = 0), (!r || r < 0 || r > n) && (r = n);
783
- for (var p = "", u = t; u < r; ++u)
784
- p += wr[i[u]];
785
- return p;
786
- }
787
- function hr(i, t, r) {
788
- for (var n = i.slice(t, r), p = "", u = 0; u < n.length - 1; u += 2)
789
- p += String.fromCharCode(n[u] + n[u + 1] * 256);
790
- return p;
791
- }
792
- o.prototype.slice = function(t, r) {
793
- var n = this.length;
794
- t = ~~t, r = r === void 0 ? n : ~~r, t < 0 ? (t += n, t < 0 && (t = 0)) : t > n && (t = n), r < 0 ? (r += n, r < 0 && (r = 0)) : r > n && (r = n), r < t && (r = t);
795
- var p = this.subarray(t, r);
796
- return Object.setPrototypeOf(p, o.prototype), p;
797
- };
798
- function F(i, t, r) {
799
- if (i % 1 !== 0 || i < 0)
800
- throw new RangeError("offset is not uint");
801
- if (i + t > r)
802
- throw new RangeError("Trying to access beyond buffer length");
803
- }
804
- o.prototype.readUintLE = o.prototype.readUIntLE = function(t, r, n) {
805
- t = t >>> 0, r = r >>> 0, n || F(t, r, this.length);
806
- for (var p = this[t], u = 1, m = 0; ++m < r && (u *= 256); )
807
- p += this[t + m] * u;
808
- return p;
809
- }, o.prototype.readUintBE = o.prototype.readUIntBE = function(t, r, n) {
810
- t = t >>> 0, r = r >>> 0, n || F(t, r, this.length);
811
- for (var p = this[t + --r], u = 1; r > 0 && (u *= 256); )
812
- p += this[t + --r] * u;
813
- return p;
814
- }, o.prototype.readUint8 = o.prototype.readUInt8 = function(t, r) {
815
- return t = t >>> 0, r || F(t, 1, this.length), this[t];
816
- }, o.prototype.readUint16LE = o.prototype.readUInt16LE = function(t, r) {
817
- return t = t >>> 0, r || F(t, 2, this.length), this[t] | this[t + 1] << 8;
818
- }, o.prototype.readUint16BE = o.prototype.readUInt16BE = function(t, r) {
819
- return t = t >>> 0, r || F(t, 2, this.length), this[t] << 8 | this[t + 1];
820
- }, o.prototype.readUint32LE = o.prototype.readUInt32LE = function(t, r) {
821
- return t = t >>> 0, r || F(t, 4, this.length), (this[t] | this[t + 1] << 8 | this[t + 2] << 16) + this[t + 3] * 16777216;
822
- }, o.prototype.readUint32BE = o.prototype.readUInt32BE = function(t, r) {
823
- return t = t >>> 0, r || F(t, 4, this.length), this[t] * 16777216 + (this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3]);
824
- }, o.prototype.readIntLE = function(t, r, n) {
825
- t = t >>> 0, r = r >>> 0, n || F(t, r, this.length);
826
- for (var p = this[t], u = 1, m = 0; ++m < r && (u *= 256); )
827
- p += this[t + m] * u;
828
- return u *= 128, p >= u && (p -= Math.pow(2, 8 * r)), p;
829
- }, o.prototype.readIntBE = function(t, r, n) {
830
- t = t >>> 0, r = r >>> 0, n || F(t, r, this.length);
831
- for (var p = r, u = 1, m = this[t + --p]; p > 0 && (u *= 256); )
832
- m += this[t + --p] * u;
833
- return u *= 128, m >= u && (m -= Math.pow(2, 8 * r)), m;
834
- }, o.prototype.readInt8 = function(t, r) {
835
- return t = t >>> 0, r || F(t, 1, this.length), this[t] & 128 ? (255 - this[t] + 1) * -1 : this[t];
836
- }, o.prototype.readInt16LE = function(t, r) {
837
- t = t >>> 0, r || F(t, 2, this.length);
838
- var n = this[t] | this[t + 1] << 8;
839
- return n & 32768 ? n | 4294901760 : n;
840
- }, o.prototype.readInt16BE = function(t, r) {
841
- t = t >>> 0, r || F(t, 2, this.length);
842
- var n = this[t + 1] | this[t] << 8;
843
- return n & 32768 ? n | 4294901760 : n;
844
- }, o.prototype.readInt32LE = function(t, r) {
845
- return t = t >>> 0, r || F(t, 4, this.length), this[t] | this[t + 1] << 8 | this[t + 2] << 16 | this[t + 3] << 24;
846
- }, o.prototype.readInt32BE = function(t, r) {
847
- return t = t >>> 0, r || F(t, 4, this.length), this[t] << 24 | this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3];
848
- }, o.prototype.readFloatLE = function(t, r) {
849
- return t = t >>> 0, r || F(t, 4, this.length), s.read(this, t, !0, 23, 4);
850
- }, o.prototype.readFloatBE = function(t, r) {
851
- return t = t >>> 0, r || F(t, 4, this.length), s.read(this, t, !1, 23, 4);
852
- }, o.prototype.readDoubleLE = function(t, r) {
853
- return t = t >>> 0, r || F(t, 8, this.length), s.read(this, t, !0, 52, 8);
854
- }, o.prototype.readDoubleBE = function(t, r) {
855
- return t = t >>> 0, r || F(t, 8, this.length), s.read(this, t, !1, 52, 8);
856
- };
857
- function B(i, t, r, n, p, u) {
858
- if (!o.isBuffer(i))
859
- throw new TypeError('"buffer" argument must be a Buffer instance');
860
- if (t > p || t < u)
861
- throw new RangeError('"value" argument is out of bounds');
862
- if (r + n > i.length)
863
- throw new RangeError("Index out of range");
864
- }
865
- o.prototype.writeUintLE = o.prototype.writeUIntLE = function(t, r, n, p) {
866
- if (t = +t, r = r >>> 0, n = n >>> 0, !p) {
867
- var u = Math.pow(2, 8 * n) - 1;
868
- B(this, t, r, n, u, 0);
869
- }
870
- var m = 1, d = 0;
871
- for (this[r] = t & 255; ++d < n && (m *= 256); )
872
- this[r + d] = t / m & 255;
873
- return r + n;
874
- }, o.prototype.writeUintBE = o.prototype.writeUIntBE = function(t, r, n, p) {
875
- if (t = +t, r = r >>> 0, n = n >>> 0, !p) {
876
- var u = Math.pow(2, 8 * n) - 1;
877
- B(this, t, r, n, u, 0);
878
- }
879
- var m = n - 1, d = 1;
880
- for (this[r + m] = t & 255; --m >= 0 && (d *= 256); )
881
- this[r + m] = t / d & 255;
882
- return r + n;
883
- }, o.prototype.writeUint8 = o.prototype.writeUInt8 = function(t, r, n) {
884
- return t = +t, r = r >>> 0, n || B(this, t, r, 1, 255, 0), this[r] = t & 255, r + 1;
885
- }, o.prototype.writeUint16LE = o.prototype.writeUInt16LE = function(t, r, n) {
886
- return t = +t, r = r >>> 0, n || B(this, t, r, 2, 65535, 0), this[r] = t & 255, this[r + 1] = t >>> 8, r + 2;
887
- }, o.prototype.writeUint16BE = o.prototype.writeUInt16BE = function(t, r, n) {
888
- return t = +t, r = r >>> 0, n || B(this, t, r, 2, 65535, 0), this[r] = t >>> 8, this[r + 1] = t & 255, r + 2;
889
- }, o.prototype.writeUint32LE = o.prototype.writeUInt32LE = function(t, r, n) {
890
- return t = +t, r = r >>> 0, n || B(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;
891
- }, o.prototype.writeUint32BE = o.prototype.writeUInt32BE = function(t, r, n) {
892
- return t = +t, r = r >>> 0, n || B(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;
893
- }, o.prototype.writeIntLE = function(t, r, n, p) {
894
- if (t = +t, r = r >>> 0, !p) {
895
- var u = Math.pow(2, 8 * n - 1);
896
- B(this, t, r, n, u - 1, -u);
897
- }
898
- var m = 0, d = 1, v = 0;
899
- for (this[r] = t & 255; ++m < n && (d *= 256); )
900
- t < 0 && v === 0 && this[r + m - 1] !== 0 && (v = 1), this[r + m] = (t / d >> 0) - v & 255;
901
- return r + n;
902
- }, o.prototype.writeIntBE = function(t, r, n, p) {
903
- if (t = +t, r = r >>> 0, !p) {
904
- var u = Math.pow(2, 8 * n - 1);
905
- B(this, t, r, n, u - 1, -u);
906
- }
907
- var m = n - 1, d = 1, v = 0;
908
- for (this[r + m] = t & 255; --m >= 0 && (d *= 256); )
909
- t < 0 && v === 0 && this[r + m + 1] !== 0 && (v = 1), this[r + m] = (t / d >> 0) - v & 255;
910
- return r + n;
911
- }, o.prototype.writeInt8 = function(t, r, n) {
912
- return t = +t, r = r >>> 0, n || B(this, t, r, 1, 127, -128), t < 0 && (t = 255 + t + 1), this[r] = t & 255, r + 1;
913
- }, o.prototype.writeInt16LE = function(t, r, n) {
914
- return t = +t, r = r >>> 0, n || B(this, t, r, 2, 32767, -32768), this[r] = t & 255, this[r + 1] = t >>> 8, r + 2;
915
- }, o.prototype.writeInt16BE = function(t, r, n) {
916
- return t = +t, r = r >>> 0, n || B(this, t, r, 2, 32767, -32768), this[r] = t >>> 8, this[r + 1] = t & 255, r + 2;
917
- }, o.prototype.writeInt32LE = function(t, r, n) {
918
- return t = +t, r = r >>> 0, n || B(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;
919
- }, o.prototype.writeInt32BE = function(t, r, n) {
920
- return t = +t, r = r >>> 0, n || B(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;
921
- };
922
- function xt(i, t, r, n, p, u) {
923
- if (r + n > i.length)
924
- throw new RangeError("Index out of range");
925
- if (r < 0)
926
- throw new RangeError("Index out of range");
927
- }
928
- function gt(i, t, r, n, p) {
929
- return t = +t, r = r >>> 0, p || xt(i, t, r, 4), s.write(i, t, r, n, 23, 4), r + 4;
930
- }
931
- o.prototype.writeFloatLE = function(t, r, n) {
932
- return gt(this, t, r, !0, n);
933
- }, o.prototype.writeFloatBE = function(t, r, n) {
934
- return gt(this, t, r, !1, n);
935
- };
936
- function dt(i, t, r, n, p) {
937
- return t = +t, r = r >>> 0, p || xt(i, t, r, 8), s.write(i, t, r, n, 52, 8), r + 8;
938
- }
939
- o.prototype.writeDoubleLE = function(t, r, n) {
940
- return dt(this, t, r, !0, n);
941
- }, o.prototype.writeDoubleBE = function(t, r, n) {
942
- return dt(this, t, r, !1, n);
943
- }, o.prototype.copy = function(t, r, n, p) {
944
- if (!o.isBuffer(t))
945
- throw new TypeError("argument should be a Buffer");
946
- if (n || (n = 0), !p && p !== 0 && (p = this.length), r >= t.length && (r = t.length), r || (r = 0), p > 0 && p < n && (p = n), p === n || t.length === 0 || this.length === 0)
947
- return 0;
948
- if (r < 0)
949
- throw new RangeError("targetStart out of bounds");
950
- if (n < 0 || n >= this.length)
951
- throw new RangeError("Index out of range");
952
- if (p < 0)
953
- throw new RangeError("sourceEnd out of bounds");
954
- p > this.length && (p = this.length), t.length - r < p - n && (p = t.length - r + n);
955
- var u = p - n;
956
- return this === t && typeof Uint8Array.prototype.copyWithin == "function" ? this.copyWithin(r, n, p) : Uint8Array.prototype.set.call(
957
- t,
958
- this.subarray(n, p),
959
- r
960
- ), u;
961
- }, o.prototype.fill = function(t, r, n, p) {
962
- if (typeof t == "string") {
963
- if (typeof r == "string" ? (p = r, r = 0, n = this.length) : typeof n == "string" && (p = n, n = this.length), p !== void 0 && typeof p != "string")
964
- throw new TypeError("encoding must be a string");
965
- if (typeof p == "string" && !o.isEncoding(p))
966
- throw new TypeError("Unknown encoding: " + p);
967
- if (t.length === 1) {
968
- var u = t.charCodeAt(0);
969
- (p === "utf8" && u < 128 || p === "latin1") && (t = u);
970
- }
971
- } else
972
- typeof t == "number" ? t = t & 255 : typeof t == "boolean" && (t = Number(t));
973
- if (r < 0 || this.length < r || this.length < n)
974
- throw new RangeError("Out of range index");
975
- if (n <= r)
976
- return this;
977
- r = r >>> 0, n = n === void 0 ? this.length : n >>> 0, t || (t = 0);
978
- var m;
979
- if (typeof t == "number")
980
- for (m = r; m < n; ++m)
981
- this[m] = t;
982
- else {
983
- var d = o.isBuffer(t) ? t : o.from(t, p), v = d.length;
984
- if (v === 0)
985
- throw new TypeError('The value "' + t + '" is invalid for argument "value"');
986
- for (m = 0; m < n - r; ++m)
987
- this[m + r] = d[m % v];
988
- }
989
- return this;
990
- };
991
- var mr = /[^+/0-9A-Za-z-_]/g;
992
- function xr(i) {
993
- if (i = i.split("=")[0], i = i.trim().replace(mr, ""), i.length < 2)
994
- return "";
995
- for (; i.length % 4 !== 0; )
996
- i = i + "=";
997
- return i;
998
- }
999
- function G(i, t) {
1000
- t = t || 1 / 0;
1001
- for (var r, n = i.length, p = null, u = [], m = 0; m < n; ++m) {
1002
- if (r = i.charCodeAt(m), r > 55295 && r < 57344) {
1003
- if (!p) {
1004
- if (r > 56319) {
1005
- (t -= 3) > -1 && u.push(239, 191, 189);
1006
- continue;
1007
- } else if (m + 1 === n) {
1008
- (t -= 3) > -1 && u.push(239, 191, 189);
1009
- continue;
1010
- }
1011
- p = r;
1012
- continue;
1013
- }
1014
- if (r < 56320) {
1015
- (t -= 3) > -1 && u.push(239, 191, 189), p = r;
1016
- continue;
1017
- }
1018
- r = (p - 55296 << 10 | r - 56320) + 65536;
1019
- } else
1020
- p && (t -= 3) > -1 && u.push(239, 191, 189);
1021
- if (p = null, r < 128) {
1022
- if ((t -= 1) < 0)
1023
- break;
1024
- u.push(r);
1025
- } else if (r < 2048) {
1026
- if ((t -= 2) < 0)
1027
- break;
1028
- u.push(
1029
- r >> 6 | 192,
1030
- r & 63 | 128
1031
- );
1032
- } else if (r < 65536) {
1033
- if ((t -= 3) < 0)
1034
- break;
1035
- u.push(
1036
- r >> 12 | 224,
1037
- r >> 6 & 63 | 128,
1038
- r & 63 | 128
1039
- );
1040
- } else if (r < 1114112) {
1041
- if ((t -= 4) < 0)
1042
- break;
1043
- u.push(
1044
- r >> 18 | 240,
1045
- r >> 12 & 63 | 128,
1046
- r >> 6 & 63 | 128,
1047
- r & 63 | 128
1048
- );
1049
- } else
1050
- throw new Error("Invalid code point");
1051
- }
1052
- return u;
1053
- }
1054
- function gr(i) {
1055
- for (var t = [], r = 0; r < i.length; ++r)
1056
- t.push(i.charCodeAt(r) & 255);
1057
- return t;
1058
- }
1059
- function dr(i, t) {
1060
- for (var r, n, p, u = [], m = 0; m < i.length && !((t -= 2) < 0); ++m)
1061
- r = i.charCodeAt(m), n = r >> 8, p = r % 256, u.push(p), u.push(n);
1062
- return u;
1063
- }
1064
- function wt(i) {
1065
- return a.toByteArray(xr(i));
1066
- }
1067
- function L(i, t, r, n) {
1068
- for (var p = 0; p < n && !(p + r >= t.length || p >= i.length); ++p)
1069
- t[p + r] = i[p];
1070
- return p;
1071
- }
1072
- function U(i, t) {
1073
- return i instanceof t || i != null && i.constructor != null && i.constructor.name != null && i.constructor.name === t.name;
1074
- }
1075
- function V(i) {
1076
- return i !== i;
1077
- }
1078
- var wr = function() {
1079
- for (var i = "0123456789abcdef", t = new Array(256), r = 0; r < 16; ++r)
1080
- for (var n = r * 16, p = 0; p < 16; ++p)
1081
- t[n + p] = i[r] + i[p];
1082
- return t;
1083
- }();
1084
- })(zt);
1085
- /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
1086
- (function(e, a) {
1087
- var s = zt, l = s.Buffer;
1088
- function f(c, o) {
1089
- for (var x in c)
1090
- o[x] = c[x];
1091
- }
1092
- l.from && l.alloc && l.allocUnsafe && l.allocUnsafeSlow ? e.exports = s : (f(s, a), a.Buffer = h);
1093
- function h(c, o, x) {
1094
- return l(c, o, x);
1095
- }
1096
- h.prototype = Object.create(l.prototype), f(l, h), h.from = function(c, o, x) {
1097
- if (typeof c == "number")
1098
- throw new TypeError("Argument must not be a number");
1099
- return l(c, o, x);
1100
- }, h.alloc = function(c, o, x) {
1101
- if (typeof c != "number")
1102
- throw new TypeError("Argument must be a number");
1103
- var w = l(c);
1104
- return o !== void 0 ? typeof x == "string" ? w.fill(o, x) : w.fill(o) : w.fill(0), w;
1105
- }, h.allocUnsafe = function(c) {
1106
- if (typeof c != "number")
1107
- throw new TypeError("Argument must be a number");
1108
- return l(c);
1109
- }, h.allocUnsafeSlow = function(c) {
1110
- if (typeof c != "number")
1111
- throw new TypeError("Argument must be a number");
1112
- return s.SlowBuffer(c);
1113
- };
1114
- })(rt, rt.exports);
1115
- var $t = rt.exports, Jt = $t.Buffer;
1116
- function H(e, a) {
1117
- this._block = Jt.alloc(e), this._finalSize = a, this._blockSize = e, this._len = 0;
1118
- }
1119
- H.prototype.update = function(e, a) {
1120
- typeof e == "string" && (a = a || "utf8", e = Jt.from(e, a));
1121
- for (var s = this._block, l = this._blockSize, f = e.length, h = this._len, c = 0; c < f; ) {
1122
- for (var o = h % l, x = Math.min(f - c, l - o), w = 0; w < x; w++)
1123
- s[o + w] = e[c + w];
1124
- h += x, c += x, h % l === 0 && this._update(s);
1125
- }
1126
- return this._len += f, this;
1127
- };
1128
- H.prototype.digest = function(e) {
1129
- var a = this._len % this._blockSize;
1130
- this._block[a] = 128, this._block.fill(0, a + 1), a >= this._finalSize && (this._update(this._block), this._block.fill(0));
1131
- var s = this._len * 8;
1132
- if (s <= 4294967295)
1133
- this._block.writeUInt32BE(s, this._blockSize - 4);
1134
- else {
1135
- var l = (s & 4294967295) >>> 0, f = (s - l) / 4294967296;
1136
- this._block.writeUInt32BE(f, this._blockSize - 8), this._block.writeUInt32BE(l, this._blockSize - 4);
1137
- }
1138
- this._update(this._block);
1139
- var h = this._hash();
1140
- return e ? h.toString(e) : h;
1141
- };
1142
- H.prototype._update = function() {
1143
- throw new Error("_update must be implemented by subclass");
1144
- };
1145
- var Pr = H, Wr = Nr, Pt = Pr, Hr = $t.Buffer, Zr = [
1146
- 1518500249,
1147
- 1859775393,
1148
- -1894007588,
1149
- -899497514
1150
- ], Yr = new Array(80);
1151
- function C() {
1152
- this.init(), this._w = Yr, Pt.call(this, 64, 56);
1153
- }
1154
- Wr(C, Pt);
1155
- C.prototype.init = function() {
1156
- return this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520, this;
1157
- };
1158
- function Kr(e) {
1159
- return e << 1 | e >>> 31;
1160
- }
1161
- function Xr(e) {
1162
- return e << 5 | e >>> 27;
1163
- }
1164
- function Gr(e) {
1165
- return e << 30 | e >>> 2;
1166
- }
1167
- function Vr(e, a, s, l) {
1168
- return e === 0 ? a & s | ~a & l : e === 2 ? a & s | a & l | s & l : a ^ s ^ l;
1169
- }
1170
- C.prototype._update = function(e) {
1171
- for (var a = this._w, s = this._a | 0, l = this._b | 0, f = this._c | 0, h = this._d | 0, c = this._e | 0, o = 0; o < 16; ++o)
1172
- a[o] = e.readInt32BE(o * 4);
1173
- for (; o < 80; ++o)
1174
- a[o] = Kr(a[o - 3] ^ a[o - 8] ^ a[o - 14] ^ a[o - 16]);
1175
- for (var x = 0; x < 80; ++x) {
1176
- var w = ~~(x / 20), y = Xr(s) + Vr(w, l, f, h) + c + a[x] + Zr[w] | 0;
1177
- c = h, h = f, f = Gr(l), l = s, s = y;
1178
- }
1179
- this._a = s + this._a | 0, this._b = l + this._b | 0, this._c = f + this._c | 0, this._d = h + this._d | 0, this._e = c + this._e | 0;
1180
- };
1181
- C.prototype._hash = function() {
1182
- var e = Hr.allocUnsafe(20);
1183
- return e.writeInt32BE(this._a | 0, 0), e.writeInt32BE(this._b | 0, 4), e.writeInt32BE(this._c | 0, 8), e.writeInt32BE(this._d | 0, 12), e.writeInt32BE(this._e | 0, 16), e;
1184
- };
1185
- var Qr = C;
1186
- const ti = /* @__PURE__ */ Lt(Qr), st = new Error("File system not available.");
1187
- function ri(e, a, s) {
1188
- throw st;
1189
- }
1190
- function Wt(e) {
1191
- throw st;
1192
- }
1193
- function ii(e) {
1194
- throw st;
1195
- }
1196
- const ei = async (e) => Wt();
1197
- function ni(e) {
1198
- let a = "";
1199
- for (let s = 0; s < e.length; s += 2)
1200
- a += String.fromCharCode(parseInt(e.substr(s, 2), 16));
1201
- return btoa(a);
1202
- }
1203
- const Z = (e, a = "sha1") => {
1204
- if (a !== "sha1")
1205
- throw new Error("Only sha1 algorithm is available.");
1206
- const s = new ti();
1207
- return ni(s.update(e).digest("hex"));
1208
- }, Ht = async (e) => {
1209
- const a = new At(), { name: s, revision: l, documentType: f, created: h, lastModified: c } = e, o = {
1210
- name: s,
1211
- revision: l,
1212
- documentType: f,
1213
- created: h,
1214
- lastModified: c
1215
- };
1216
- return a.file("header.json", JSON.stringify(o, null, 2)), a.file(
1217
- "state.json",
1218
- JSON.stringify(e.initialState || {}, null, 2)
1219
- ), a.file("operations.json", JSON.stringify(e.operations, null, 2)), Object.keys(e.attachments).forEach((w) => {
1220
- const { data: y, ..._ } = e.attachments[w];
1221
- a.file(w, y, {
1222
- base64: !0,
1223
- createFolders: !0,
1224
- comment: JSON.stringify(_)
1225
- });
1226
- }), a;
1227
- }, ai = async (e, a, s, l) => {
1228
- await (await Ht(e)).generateAsync({
1229
- type: "uint8array",
1230
- streamFiles: !0
1231
- });
1232
- const h = l ?? e.name, c = `.${s}.zip`;
1233
- return ri(
1234
- a,
1235
- h.endsWith(c) ? h : `${h}${c}`
1236
- );
1237
- }, ji = async (e, a) => {
1238
- const l = await (await Ht(e)).generateAsync({ type: "blob" }), f = await a.createWritable();
1239
- await f.write(l), await f.close();
1240
- }, Et = async (e, a) => {
1241
- const s = Wt();
1242
- return oi(s, a);
1243
- }, oi = async (e, a) => {
1244
- const s = new At();
1245
- return await s.loadAsync(e), pi(s, a);
1246
- };
1247
- async function pi(e, a) {
1248
- const s = e.file("state.json");
1249
- if (!s)
1250
- throw new Error("Initial state not found");
1251
- const l = await s.async("string"), f = JSON.parse(l), h = e.file("header.json");
1252
- let c = null;
1253
- h && (c = JSON.parse(await h.async("string")));
1254
- const o = e.file("operations.json");
1255
- if (!o)
1256
- throw new Error("Operations history not found");
1257
- const x = JSON.parse(
1258
- await o.async("string")
1259
- ), w = {
1260
- ...f,
1261
- ...c,
1262
- initialState: f,
1263
- operations: { global: [], local: [] },
1264
- attachments: { ...f.attachments }
1265
- };
1266
- let y = x.global.concat(x.local).slice(0, c == null ? void 0 : c.revision).reduce(
1267
- (_, I) => a(_, I),
1268
- w
1269
- );
1270
- return c && (y = {
1271
- ...y,
1272
- ...c,
1273
- operations: {
1274
- global: [
1275
- ...y.operations.global,
1276
- ...x.global.slice(c.revision)
1277
- ],
1278
- local: y.operations.local
1279
- }
1280
- }), y;
1281
- }
1282
- function Zt(e) {
1283
- const a = e.replace(/^.*\./, "") || void 0, s = e.replace(/^.*[/\\]/, "") || void 0;
1284
- return { extension: a, fileName: s };
1285
- }
1286
- async function Ii(e) {
1287
- const { buffer: a, mimeType: s = "application/octet-stream" } = await ii(), l = Zt(e), f = a.toString("base64");
1288
- return {
1289
- data: f,
1290
- hash: Z(f),
1291
- mimeType: s,
1292
- ...l
1293
- };
1294
- }
1295
- async function Ui(e) {
1296
- const a = await ei(), s = Or.getType(e) || "application/octet-stream", l = Zt(e), f = a.toString("base64");
1297
- return { data: f, hash: Z(f), mimeType: s, ...l };
1298
- }
1299
- function J(e, a, s, l) {
1300
- const f = bi(e), h = yi(s);
1301
- return a.global.concat(a.local).reduce(
1302
- (c, o) => h(c, o, l),
1303
- f
1304
- );
1305
- }
1306
- function si(e, a) {
1307
- return { ...e, name: a };
1308
- }
1309
- function li(e, a, s) {
1310
- const l = Math.min(a, e.revision), f = e.operations.global.slice(
1311
- 0,
1312
- e.revision - l
1313
- );
1314
- return {
1315
- ...J(
1316
- e.initialState,
1317
- {
1318
- global: f,
1319
- local: e.operations.local
1320
- },
1321
- s
1322
- ),
1323
- operations: e.operations,
1324
- revision: e.revision - l
1325
- };
1326
- }
1327
- function ci(e, a, s) {
1328
- const l = e.operations.global.length - e.revision;
1329
- if (!l)
1330
- throw new Error("There is no UNDO operation to REDO");
1331
- const f = a < l ? a : l, h = e.operations.global.slice(
1332
- 0,
1333
- e.revision + f
1334
- );
1335
- return {
1336
- ...J(
1337
- e.initialState,
1338
- {
1339
- global: h,
1340
- local: e.operations.local
1341
- },
1342
- s
1343
- ),
1344
- operations: e.operations,
1345
- revision: e.revision + f
1346
- };
1347
- }
1348
- function ui(e, a, s, l) {
1349
- a = a || 0, s = s || e.operations.global.length;
1350
- const f = e.operations.global.slice(a, s), h = e.operations.global.slice(0, a), c = e.operations.global.slice(s), o = J(
1351
- e.initialState,
1352
- {
1353
- global: h.concat(f),
1354
- local: e.operations.local
1355
- },
1356
- l
1357
- ), { name: x, state: w } = o;
1358
- return J(
1359
- e.initialState,
1360
- {
1361
- global: [
1362
- ...h,
1363
- lt({ name: x, state: w }, f.length),
1364
- ...c
1365
- ],
1366
- local: e.operations.local
1367
- },
1368
- l
1369
- );
1370
- }
1371
- function fi(e, a) {
1372
- return {
1373
- ...e,
1374
- name: a.name,
1375
- state: a.state ?? { global: {}, local: {} }
1376
- };
1377
- }
1378
- const Yt = "SET_NAME", Y = "UNDO", K = "REDO", M = "PRUNE", Kt = "LOAD_STATE";
1379
- function hi(e, a) {
1380
- return [Y, K, M].includes(a.type) ? e.revision : e.revision + 1;
1381
- }
1382
- function mi(e, a) {
1383
- return {
1384
- ...e,
1385
- revision: hi(e, a),
1386
- lastModified: (/* @__PURE__ */ new Date()).toISOString()
1387
- };
1388
- }
1389
- function xi(e, a) {
1390
- if ([Y, K, M, M].includes(a.type))
1391
- return e;
1392
- const s = e.operations.global.slice(
1393
- 0,
1394
- e.revision
1395
- ), l = e.operations.local.slice();
1396
- return !a.scope || a.scope === "global" ? s.push({
1397
- ...a,
1398
- index: s.length,
1399
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1400
- hash: "",
1401
- scope: "global"
1402
- }) : a.scope === "local" && l.push({
1403
- ...a,
1404
- index: l.length,
1405
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1406
- hash: "",
1407
- scope: "local"
1408
- }), {
1409
- ...e,
1410
- operations: {
1411
- global: s,
1412
- local: l
1413
- }
1414
- };
1415
- }
1416
- function gi(e, a) {
1417
- let s = xi(e, a);
1418
- return (!a.scope || a.scope === "global") && (s = mi(s, a)), s;
1419
- }
1420
- function di(e, a, s) {
1421
- switch (Tt().parse(a), a.type) {
1422
- case Yt:
1423
- return si(e, a.input);
1424
- case Y:
1425
- return li(e, a.input, s);
1426
- case K:
1427
- return ci(e, a.input, s);
1428
- case M:
1429
- return ui(
1430
- e,
1431
- a.input.start,
1432
- a.input.end,
1433
- s
1434
- );
1435
- case Kt:
1436
- return fi(e, a.input.state);
1437
- default:
1438
- return e;
1439
- }
1440
- }
1441
- function wi(e, a, s, l) {
1442
- let f = e;
1443
- return _t(a) && (f = di(f, a, s)), f = gi(f, a), f = bt(f, (h) => {
1444
- const c = s(h.state, a, l);
1445
- if (c)
1446
- return Er({
1447
- ...f,
1448
- state: c
1449
- });
1450
- }), bt(f, (h) => {
1451
- !a.scope || a.scope === "global" ? h.operations.global[h.operations.global.length - 1].hash = Ft(h, "global") : a.scope === "local" && (h.operations.local[h.operations.local.length - 1].hash = Ft(h, "local")), !_t(a) && a.attachments && a.attachments.forEach((c) => {
1452
- const { hash: o, ...x } = c;
1453
- h.attachments[o] = {
1454
- ...x
1455
- };
1456
- });
1457
- });
1458
- }
1459
- function _t(e) {
1460
- return [Yt, Y, K, M, Kt].includes(e.type);
1461
- }
1462
- function R(e, a, s, l, f = "global") {
1463
- if (!e)
1464
- throw new Error("Empty action type");
1465
- if (typeof e != "string")
1466
- throw new Error(`Invalid action type: ${e}`);
1467
- const h = { type: e, input: a, scope: f };
1468
- s && (h.attachments = s);
1469
- try {
1470
- l == null || l().parse(h.input);
1471
- } catch (c) {
1472
- throw new Error(`Invalid action input: ${c}`);
1473
- }
1474
- return h;
1475
- }
1476
- function yi(e, a = wi) {
1477
- return (s, l, f) => a(s, l, e, f);
1478
- }
1479
- const vi = (e, a) => ({
1480
- name: "",
1481
- documentType: "",
1482
- revision: 0,
1483
- created: (/* @__PURE__ */ new Date()).toISOString(),
1484
- lastModified: (/* @__PURE__ */ new Date()).toISOString(),
1485
- attachments: {},
1486
- ...e,
1487
- state: (a == null ? void 0 : a(e == null ? void 0 : e.state)) ?? (e == null ? void 0 : e.state) ?? { global: {}, local: {} }
1488
- }), bi = (e, a) => {
1489
- const s = vi(
1490
- e,
1491
- a
1492
- );
1493
- return {
1494
- ...s,
1495
- initialState: s,
1496
- operations: { global: [], local: [] }
1497
- };
1498
- }, Ft = (e, a = "global") => Z(
1499
- br(
1500
- a === "local" ? e.state.local : e.state.global
1501
- )
1502
- ), ki = (e, a = 1e3) => {
1503
- const s = Math.random() * a;
1504
- return Z(`${(e ?? /* @__PURE__ */ new Date()).toISOString()}${s}`);
1505
- };
1506
- function $(e) {
1507
- return _r(Fr(e, !0));
1508
- }
1509
- const Xt = (e) => R(
1510
- "SET_NAME",
1511
- e,
1512
- void 0,
1513
- at
1514
- ), Gt = (e = 1) => R("UNDO", e, void 0, ot), Vt = (e = 1) => R("REDO", e, void 0, nt), Qt = (e, a) => R(
1515
- "PRUNE",
1516
- { start: e, end: a },
1517
- void 0,
1518
- et
1519
- ), lt = (e, a) => R(
1520
- "LOAD_STATE",
1521
- { state: e, operations: a },
1522
- void 0,
1523
- it
1524
- ), Ti = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1525
- __proto__: null,
1526
- loadState: lt,
1527
- prune: Qt,
1528
- redo: Vt,
1529
- setName: Xt,
1530
- undo: Gt
1531
- }, Symbol.toStringTag, { value: "Module" }));
1532
- class Di {
1533
- /**
1534
- * Constructs a BaseDocument instance with an initial state.
1535
- * @param reducer - The reducer function that updates the state.
1536
- * @param document - The initial state of the document.
1537
- */
1538
- constructor(a, s, l) {
1539
- q(this, "_document");
1540
- q(this, "_reducer");
1541
- q(this, "_signalDispatch");
1542
- this._reducer = a, this._document = s, this._signalDispatch = l;
1543
- }
1544
- /**
1545
- * Dispatches an action to update the state of the document.
1546
- * @param action - The action to dispatch.
1547
- * @returns The Document instance.
1548
- */
1549
- dispatch(a) {
1550
- return this._document = this._reducer(
1551
- this._document,
1552
- a,
1553
- this._signalDispatch
1554
- ), this;
1555
- }
1556
- /**
1557
- * Saves the state of the document to a file.
1558
- * @param path - The file path where the state should be saved.
1559
- * @param extension - The file extension to use when saving the state.
1560
- * @returns The file path where the state was saved.
1561
- */
1562
- saveToFile(a, s, l) {
1563
- return ai(this._document, a, s, l);
1564
- }
1565
- /**
1566
- * Loads the state of the document from a file.
1567
- * @param path - The file path where the state is stored.
1568
- */
1569
- async loadFromFile(a) {
1570
- this._document = await Et(a, this._reducer);
1571
- }
1572
- /**
1573
- * Loads the state of the document from a file and returns it.
1574
- * @param path - The file path where the state is stored.
1575
- * @param reducer - The reducer function that updates the state.
1576
- * @returns The state of the document.
1577
- */
1578
- static async stateFromFile(a, s) {
1579
- return await Et(a, s);
1580
- }
1581
- /**
1582
- * Gets the current state of the document.
1583
- */
1584
- get state() {
1585
- return $(this._document.state);
1586
- }
1587
- /**
1588
- * Gets the list of operations performed on the document.
1589
- */
1590
- get operations() {
1591
- return $(this._document.operations);
1592
- }
1593
- /**
1594
- * Gets the name of the document.
1595
- */
1596
- get name() {
1597
- return this._document.name;
1598
- }
1599
- /**
1600
- * Gets the type of document.
1601
- */
1602
- get documentType() {
1603
- return this._document.documentType;
1604
- }
1605
- /**
1606
- * Gets the timestamp of the date the document was created.
1607
- */
1608
- get created() {
1609
- return this._document.created;
1610
- }
1611
- /**
1612
- * Gets the timestamp of the date the document was last modified.
1613
- */
1614
- get lastModified() {
1615
- return this._document.lastModified;
1616
- }
1617
- /**
1618
- * Gets the revision number of the document.
1619
- */
1620
- get revision() {
1621
- return this._document.revision;
1622
- }
1623
- /**
1624
- * Gets the initial state of the document.
1625
- */
1626
- get initialState() {
1627
- return $(this._document.initialState);
1628
- }
1629
- /**
1630
- * Returns the current document as an object
1631
- */
1632
- toDocument() {
1633
- return $(this._document);
1634
- }
1635
- /**
1636
- * Gets the attachment associated with the given key.
1637
- * @param attachment - The key of the attachment to retrieve.
1638
- */
1639
- getAttachment(a) {
1640
- return this._document.attachments[a];
1641
- }
1642
- /**
1643
- * Sets the name of the document.
1644
- * @param name - The new name of the document.
1645
- */
1646
- setName(a) {
1647
- return this.dispatch(Xt(a)), this;
1648
- }
1649
- /**
1650
- * Reverts a number of actions from the document.
1651
- * @param count - The number of actions to revert.
1652
- */
1653
- undo(a) {
1654
- return this.dispatch(Gt(a)), this;
1655
- }
1656
- /**
1657
- * Reapplies a number of actions to the document.
1658
- * @param count - The number of actions to reapply.
1659
- */
1660
- redo(a) {
1661
- return this.dispatch(Vt(a)), this;
1662
- }
1663
- /**
1664
- * Removes a range of operations from the document.
1665
- * @param start - The starting index of the range to remove.
1666
- * @param end - The ending index of the range to remove.
1667
- */
1668
- prune(a, s) {
1669
- return this.dispatch(Qt(a, s)), this;
1670
- }
1671
- /**
1672
- * Loads a document state and a set of operations.
1673
- * @param state - The state to load.
1674
- * @param operations - The operations to apply to the document.
1675
- */
1676
- loadState(a, s) {
1677
- return this.dispatch(lt(a, s)), this;
1678
- }
1679
- }
1680
- function Oi(e, a) {
1681
- a.forEach((s) => {
1682
- Object.getOwnPropertyNames(s.prototype).forEach((l) => {
1683
- Object.defineProperty(
1684
- e.prototype,
1685
- l,
1686
- Object.getOwnPropertyDescriptor(s.prototype, l) || /* @__PURE__ */ Object.create(null)
1687
- );
1688
- });
1689
- });
1690
- }
1691
- export {
1692
- Di as B,
1693
- vi as a,
1694
- bi as b,
1695
- yi as c,
1696
- ji as d,
1697
- oi as e,
1698
- R as f,
1699
- Oi as g,
1700
- Ti as h,
1701
- _t as i,
1702
- Ht as j,
1703
- Ui as k,
1704
- Et as l,
1705
- Ii as m,
1706
- Ft as n,
1707
- ki as o,
1708
- wi as p,
1709
- $ as r,
1710
- ai as s,
1711
- Bi as z
1712
- };